summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchin <none@none>2007-08-17 12:01:52 -0700
committerchin <none@none>2007-08-17 12:01:52 -0700
commitda2e3ebdc1edfbc5028edf1354e7dd2fa69a7968 (patch)
tree5280d3b78e289fe9551371ab6e7f15ef9944ea14
parent073dbf9103ef2a2b05d8a16e2d26db04e0374b0e (diff)
downloadillumos-joyent-da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968.tar.gz
6437624 RFE: Add ksh93 (as /usr/bin/ksh93) and libshell.so to OS/Net
6505835 AST tools and library (libpp) required for creating l10n messages for ksh93 PSARC/2006/550 Korn Shell 93 Integration PSARC/2006/587 /etc/ksh.kshrc for ksh93 PSARC/2007/035 ksh93 Amendments Contributed by Roland Mainz <roland.mainz@nrubsig.org> --HG-- rename : usr/src/lib/libcmd/common/mapfile-vers => deleted_files/usr/src/lib/libcmd/common/mapfile-vers rename : usr/src/lib/libcmd/common/placeholder.c => deleted_files/usr/src/lib/libcmd/common/placeholder.c
-rw-r--r--deleted_files/usr/src/lib/libcmd/common/mapfile-vers (renamed from usr/src/lib/libcmd/common/mapfile-vers)0
-rw-r--r--deleted_files/usr/src/lib/libcmd/common/placeholder.c (renamed from usr/src/lib/libcmd/common/placeholder.c)0
-rw-r--r--usr/src/Makefile.ast67
-rw-r--r--usr/src/Makefile.ksh93switch36
-rw-r--r--usr/src/Makefile.lint1
-rw-r--r--usr/src/Targetdirs3
-rw-r--r--usr/src/cmd/Makefile4
-rw-r--r--usr/src/cmd/ast/Makefile50
-rw-r--r--usr/src/cmd/ast/THIRDPARTYLICENSE245
-rw-r--r--usr/src/cmd/ast/THIRDPARTYLICENSE.descrip1
-rw-r--r--usr/src/cmd/ast/msgcc/Makefile75
-rw-r--r--usr/src/cmd/ast/msgcc/NOTES65
-rw-r--r--usr/src/cmd/ast/msgcc/PROMO.mm22
-rw-r--r--usr/src/cmd/ast/msgcc/msgcc.sh405
-rw-r--r--usr/src/cmd/ast/msgcc/msgcc.tst28
-rw-r--r--usr/src/cmd/ast/msgcc/msgcpp.c289
-rw-r--r--usr/src/cmd/ast/msgcc/msgcvt.c691
-rw-r--r--usr/src/cmd/ast/msgcc/msggen.c522
-rw-r--r--usr/src/cmd/ast/msgcc/msgget.c109
-rw-r--r--usr/src/cmd/ksh/Makefile81
-rw-r--r--usr/src/cmd/ksh/Makefile.com110
-rw-r--r--usr/src/cmd/ksh/Makefile.testshell163
-rw-r--r--usr/src/cmd/ksh/amd64/Makefile47
-rw-r--r--usr/src/cmd/ksh/i386/Makefile46
-rw-r--r--usr/src/cmd/ksh/sparc/Makefile46
-rw-r--r--usr/src/cmd/ksh/sparcv9/Makefile47
-rw-r--r--usr/src/cmd/nsadmin/Makefile14
-rw-r--r--usr/src/cmd/nsadmin/ksh.kshrc42
-rw-r--r--usr/src/cmd/nsadmin/profile13
-rw-r--r--usr/src/cmd/sgs/libelf/Makefile.com17
-rw-r--r--usr/src/cmd/sgs/libelf/Makefile.targ12
-rw-r--r--usr/src/lib/Makefile21
-rw-r--r--usr/src/lib/Makefile.asthdr87
-rw-r--r--usr/src/lib/Makefile.astmsg97
-rw-r--r--usr/src/lib/Makefile.lib10
-rw-r--r--usr/src/lib/Makefile.targ7
-rw-r--r--usr/src/lib/libast/Makefile158
-rw-r--r--usr/src/lib/libast/Makefile.com738
-rw-r--r--usr/src/lib/libast/THIRDPARTYLICENSE245
-rw-r--r--usr/src/lib/libast/THIRDPARTYLICENSE.descrip1
-rw-r--r--usr/src/lib/libast/amd64/Makefile48
-rw-r--r--usr/src/lib/libast/amd64/include/ast/align.h54
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast.h381
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_botch.h26
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_ccode.h50
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_common.h220
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_dir.h86
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_dirent.h103
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_fcntl.h135
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_float.h233
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_fs.h174
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_getopt.h51
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_iconv.h153
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_lib.h181
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_limits.h128
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_map.h459
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_mmap.h47
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_mode.h35
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_nl_types.h123
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_param.h30
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_standards.h49
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_std.h343
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_stdio.h600
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_sys.h172
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_time.h104
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_tty.h155
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_types.h26
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_version.h10
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_vfork.h88
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_wait.h32
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_wchar.h208
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ast_windows.h48
-rw-r--r--usr/src/lib/libast/amd64/include/ast/bytesex.h43
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ccode.h101
-rw-r--r--usr/src/lib/libast/amd64/include/ast/cdt.h311
-rw-r--r--usr/src/lib/libast/amd64/include/ast/debug.h63
-rw-r--r--usr/src/lib/libast/amd64/include/ast/dirent.h22
-rw-r--r--usr/src/lib/libast/amd64/include/ast/dt.h49
-rw-r--r--usr/src/lib/libast/amd64/include/ast/endian.h54
-rw-r--r--usr/src/lib/libast/amd64/include/ast/error.h196
-rw-r--r--usr/src/lib/libast/amd64/include/ast/find.h97
-rw-r--r--usr/src/lib/libast/amd64/include/ast/fnmatch.h71
-rw-r--r--usr/src/lib/libast/amd64/include/ast/fnv.h81
-rw-r--r--usr/src/lib/libast/amd64/include/ast/fs3d.h120
-rw-r--r--usr/src/lib/libast/amd64/include/ast/fts.h160
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ftw.h71
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ftwalk.h137
-rw-r--r--usr/src/lib/libast/amd64/include/ast/getopt.h31
-rw-r--r--usr/src/lib/libast/amd64/include/ast/glob.h155
-rw-r--r--usr/src/lib/libast/amd64/include/ast/hash.h213
-rw-r--r--usr/src/lib/libast/amd64/include/ast/hashkey.h73
-rw-r--r--usr/src/lib/libast/amd64/include/ast/hashpart.h60
-rw-r--r--usr/src/lib/libast/amd64/include/ast/iconv.h22
-rw-r--r--usr/src/lib/libast/amd64/include/ast/lc.h158
-rw-r--r--usr/src/lib/libast/amd64/include/ast/ls.h99
-rw-r--r--usr/src/lib/libast/amd64/include/ast/magic.h96
-rw-r--r--usr/src/lib/libast/amd64/include/ast/magicid.h55
-rw-r--r--usr/src/lib/libast/amd64/include/ast/mc.h107
-rw-r--r--usr/src/lib/libast/amd64/include/ast/mime.h102
-rw-r--r--usr/src/lib/libast/amd64/include/ast/mnt.h69
-rw-r--r--usr/src/lib/libast/amd64/include/ast/modecanon.h74
-rw-r--r--usr/src/lib/libast/amd64/include/ast/modex.h62
-rw-r--r--usr/src/lib/libast/amd64/include/ast/namval.h51
-rw-r--r--usr/src/lib/libast/amd64/include/ast/nl_types.h22
-rw-r--r--usr/src/lib/libast/amd64/include/ast/option.h119
-rw-r--r--usr/src/lib/libast/amd64/include/ast/preroot.h27
-rw-r--r--usr/src/lib/libast/amd64/include/ast/proc.h113
-rw-r--r--usr/src/lib/libast/amd64/include/ast/prototyped.h59
-rw-r--r--usr/src/lib/libast/amd64/include/ast/re_comp.h52
-rw-r--r--usr/src/lib/libast/amd64/include/ast/recfmt.h94
-rw-r--r--usr/src/lib/libast/amd64/include/ast/regex.h227
-rw-r--r--usr/src/lib/libast/amd64/include/ast/regexp.h139
-rw-r--r--usr/src/lib/libast/amd64/include/ast/sfdisc.h82
-rw-r--r--usr/src/lib/libast/amd64/include/ast/sfio.h452
-rw-r--r--usr/src/lib/libast/amd64/include/ast/sfio_s.h51
-rw-r--r--usr/src/lib/libast/amd64/include/ast/sfio_t.h126
-rw-r--r--usr/src/lib/libast/amd64/include/ast/sig.h152
-rw-r--r--usr/src/lib/libast/amd64/include/ast/stack.h94
-rw-r--r--usr/src/lib/libast/amd64/include/ast/stak.h64
-rw-r--r--usr/src/lib/libast/amd64/include/ast/stdio.h22
-rw-r--r--usr/src/lib/libast/amd64/include/ast/stk.h91
-rw-r--r--usr/src/lib/libast/amd64/include/ast/swap.h64
-rw-r--r--usr/src/lib/libast/amd64/include/ast/tar.h127
-rw-r--r--usr/src/lib/libast/amd64/include/ast/times.h65
-rw-r--r--usr/src/lib/libast/amd64/include/ast/tm.h205
-rw-r--r--usr/src/lib/libast/amd64/include/ast/tmx.h149
-rw-r--r--usr/src/lib/libast/amd64/include/ast/tok.h58
-rw-r--r--usr/src/lib/libast/amd64/include/ast/tv.h132
-rw-r--r--usr/src/lib/libast/amd64/include/ast/usage.h37
-rw-r--r--usr/src/lib/libast/amd64/include/ast/vdb.h55
-rw-r--r--usr/src/lib/libast/amd64/include/ast/vecargs.h56
-rw-r--r--usr/src/lib/libast/amd64/include/ast/vmalloc.h315
-rw-r--r--usr/src/lib/libast/amd64/include/ast/wait.h107
-rw-r--r--usr/src/lib/libast/amd64/include/ast/wchar.h22
-rw-r--r--usr/src/lib/libast/amd64/include/ast/wordexp.h74
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/align33
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/botch5
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/ccode29
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/common200
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/dirent82
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/eaccess5
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/errno7
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/fcntl114
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/float212
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/fs153
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/hack5
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/iconv132
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/lib160
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/libpath6
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/limits107
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/map438
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/mmap26
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/mode14
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/nl_types102
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/omitted5
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/param9
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/preroot6
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/sfinit5332
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/sfio16
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/sig131
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/signal175
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/standards28
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/stdio579
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/sys151
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/time83
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tmlib68
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tmx128
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tty134
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tv111
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tvlib17
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/types5
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/uwin17
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/vfork67
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/vmalloc36
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/wait11
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/FEATURE/wchar187
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/align.h33
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_botch.h5
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_ccode.h29
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_common.h199
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_dirent.h82
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_fcntl.h114
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_float.h212
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_fs.h153
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_iconv.h132
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_lib.h160
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_limits.h107
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_map.h438
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_mmap.h26
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_mode.h14
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_nl_types.h102
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_param.h9
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_standards.h28
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_stdio.h579
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_sys.h151
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_time.h83
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_tty.h134
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_types.h5
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_vfork.h67
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_wait.h11
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/ast_wchar.h187
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/conftab.c451
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/conftab.h154
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/lc.h158
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/lctab.h2630
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/preroot.h6
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/sig.h131
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/tmx.h128
-rw-r--r--usr/src/lib/libast/amd64/src/lib/libast/tv.h111
-rw-r--r--usr/src/lib/libast/common/README95
-rw-r--r--usr/src/lib/libast/common/RELEASE1420
-rw-r--r--usr/src/lib/libast/common/cdt/dtclose.c69
-rw-r--r--usr/src/lib/libast/common/cdt/dtdisc.c129
-rw-r--r--usr/src/lib/libast/common/cdt/dtextract.c55
-rw-r--r--usr/src/lib/libast/common/cdt/dtflatten.c75
-rw-r--r--usr/src/lib/libast/common/cdt/dthash.c368
-rw-r--r--usr/src/lib/libast/common/cdt/dthdr.h84
-rw-r--r--usr/src/lib/libast/common/cdt/dtlist.c196
-rw-r--r--usr/src/lib/libast/common/cdt/dtmethod.c107
-rw-r--r--usr/src/lib/libast/common/cdt/dtnew.c73
-rw-r--r--usr/src/lib/libast/common/cdt/dtopen.c109
-rw-r--r--usr/src/lib/libast/common/cdt/dtrenew.c79
-rw-r--r--usr/src/lib/libast/common/cdt/dtrestore.c88
-rw-r--r--usr/src/lib/libast/common/cdt/dtsize.c61
-rw-r--r--usr/src/lib/libast/common/cdt/dtstat.c132
-rw-r--r--usr/src/lib/libast/common/cdt/dtstrhash.c61
-rw-r--r--usr/src/lib/libast/common/cdt/dttree.c391
-rw-r--r--usr/src/lib/libast/common/cdt/dttreeset.c83
-rw-r--r--usr/src/lib/libast/common/cdt/dtview.c155
-rw-r--r--usr/src/lib/libast/common/cdt/dtwalk.c52
-rw-r--r--usr/src/lib/libast/common/comp/atexit.c115
-rw-r--r--usr/src/lib/libast/common/comp/basename.c55
-rw-r--r--usr/src/lib/libast/common/comp/catopen.c178
-rw-r--r--usr/src/lib/libast/common/comp/closelog.c51
-rw-r--r--usr/src/lib/libast/common/comp/conf.sh1511
-rw-r--r--usr/src/lib/libast/common/comp/conf.tab586
-rw-r--r--usr/src/lib/libast/common/comp/creat64.c38
-rw-r--r--usr/src/lib/libast/common/comp/dirname.c61
-rw-r--r--usr/src/lib/libast/common/comp/dup2.c46
-rw-r--r--usr/src/lib/libast/common/comp/eaccess.c139
-rw-r--r--usr/src/lib/libast/common/comp/errno.c40
-rw-r--r--usr/src/lib/libast/common/comp/execlp.c50
-rw-r--r--usr/src/lib/libast/common/comp/execve.c70
-rw-r--r--usr/src/lib/libast/common/comp/execvp.c50
-rw-r--r--usr/src/lib/libast/common/comp/execvpe.c78
-rw-r--r--usr/src/lib/libast/common/comp/fcntl.c98
-rw-r--r--usr/src/lib/libast/common/comp/fmtmsglib.c335
-rw-r--r--usr/src/lib/libast/common/comp/fnmatch.c79
-rw-r--r--usr/src/lib/libast/common/comp/fnmatch.h60
-rw-r--r--usr/src/lib/libast/common/comp/frexp.c153
-rw-r--r--usr/src/lib/libast/common/comp/frexpl.c161
-rw-r--r--usr/src/lib/libast/common/comp/fsync.c46
-rw-r--r--usr/src/lib/libast/common/comp/ftw.c50
-rw-r--r--usr/src/lib/libast/common/comp/ftw.h60
-rw-r--r--usr/src/lib/libast/common/comp/getdate.c83
-rw-r--r--usr/src/lib/libast/common/comp/getgroups.c78
-rw-r--r--usr/src/lib/libast/common/comp/getlogin.c42
-rw-r--r--usr/src/lib/libast/common/comp/getopt.c78
-rw-r--r--usr/src/lib/libast/common/comp/getopt.h48
-rw-r--r--usr/src/lib/libast/common/comp/getoptl.c150
-rw-r--r--usr/src/lib/libast/common/comp/getpgrp.c47
-rw-r--r--usr/src/lib/libast/common/comp/getsubopt.c94
-rw-r--r--usr/src/lib/libast/common/comp/getwd.c37
-rw-r--r--usr/src/lib/libast/common/comp/gross.c99
-rw-r--r--usr/src/lib/libast/common/comp/hsearch.c138
-rw-r--r--usr/src/lib/libast/common/comp/iconv.c1496
-rw-r--r--usr/src/lib/libast/common/comp/killpg.c40
-rw-r--r--usr/src/lib/libast/common/comp/libgen.h52
-rw-r--r--usr/src/lib/libast/common/comp/link.c47
-rw-r--r--usr/src/lib/libast/common/comp/localeconv.c96
-rw-r--r--usr/src/lib/libast/common/comp/lstat.c39
-rw-r--r--usr/src/lib/libast/common/comp/memccpy.c51
-rw-r--r--usr/src/lib/libast/common/comp/memchr.c49
-rw-r--r--usr/src/lib/libast/common/comp/memcmp.c45
-rw-r--r--usr/src/lib/libast/common/comp/memcpy.c60
-rw-r--r--usr/src/lib/libast/common/comp/memmove.c53
-rw-r--r--usr/src/lib/libast/common/comp/memset.c42
-rw-r--r--usr/src/lib/libast/common/comp/mkdir.c62
-rw-r--r--usr/src/lib/libast/common/comp/mkfifo.c50
-rw-r--r--usr/src/lib/libast/common/comp/mknod.c50
-rw-r--r--usr/src/lib/libast/common/comp/mktemp.c85
-rw-r--r--usr/src/lib/libast/common/comp/mktime.c77
-rw-r--r--usr/src/lib/libast/common/comp/mount.c49
-rw-r--r--usr/src/lib/libast/common/comp/nftw.c61
-rw-r--r--usr/src/lib/libast/common/comp/omitted.c1069
-rw-r--r--usr/src/lib/libast/common/comp/open.c119
-rw-r--r--usr/src/lib/libast/common/comp/openlog.c58
-rw-r--r--usr/src/lib/libast/common/comp/putenv.c53
-rw-r--r--usr/src/lib/libast/common/comp/re_comp.c81
-rw-r--r--usr/src/lib/libast/common/comp/re_comp.h41
-rw-r--r--usr/src/lib/libast/common/comp/readlink.c61
-rw-r--r--usr/src/lib/libast/common/comp/realpath.c48
-rw-r--r--usr/src/lib/libast/common/comp/regcmp.c211
-rw-r--r--usr/src/lib/libast/common/comp/regexp.c123
-rw-r--r--usr/src/lib/libast/common/comp/regexp.h129
-rw-r--r--usr/src/lib/libast/common/comp/remove.c49
-rw-r--r--usr/src/lib/libast/common/comp/rename.c98
-rw-r--r--usr/src/lib/libast/common/comp/resolvepath.c70
-rw-r--r--usr/src/lib/libast/common/comp/rmdir.c66
-rw-r--r--usr/src/lib/libast/common/comp/setenv.c58
-rw-r--r--usr/src/lib/libast/common/comp/setlocale.c946
-rw-r--r--usr/src/lib/libast/common/comp/setlogmask.c48
-rw-r--r--usr/src/lib/libast/common/comp/setpgid.c80
-rw-r--r--usr/src/lib/libast/common/comp/setsid.c90
-rw-r--r--usr/src/lib/libast/common/comp/sigunblock.c63
-rw-r--r--usr/src/lib/libast/common/comp/spawnveg.c270
-rw-r--r--usr/src/lib/libast/common/comp/statvfs.c163
-rw-r--r--usr/src/lib/libast/common/comp/strcasecmp.c58
-rw-r--r--usr/src/lib/libast/common/comp/strchr.c57
-rw-r--r--usr/src/lib/libast/common/comp/strftime.c104
-rw-r--r--usr/src/lib/libast/common/comp/strncasecmp.c62
-rw-r--r--usr/src/lib/libast/common/comp/strptime.c82
-rw-r--r--usr/src/lib/libast/common/comp/strrchr.c60
-rw-r--r--usr/src/lib/libast/common/comp/strstr.c76
-rw-r--r--usr/src/lib/libast/common/comp/strtod.c31
-rw-r--r--usr/src/lib/libast/common/comp/strtol.c34
-rw-r--r--usr/src/lib/libast/common/comp/strtold.c43
-rw-r--r--usr/src/lib/libast/common/comp/strtoll.c44
-rw-r--r--usr/src/lib/libast/common/comp/strtoul.c35
-rw-r--r--usr/src/lib/libast/common/comp/strtoull.c45
-rw-r--r--usr/src/lib/libast/common/comp/swab.c60
-rw-r--r--usr/src/lib/libast/common/comp/symlink.c59
-rw-r--r--usr/src/lib/libast/common/comp/syslog.c363
-rw-r--r--usr/src/lib/libast/common/comp/system.c55
-rw-r--r--usr/src/lib/libast/common/comp/tempnam.c58
-rw-r--r--usr/src/lib/libast/common/comp/tmpnam.c51
-rw-r--r--usr/src/lib/libast/common/comp/transition.c86
-rw-r--r--usr/src/lib/libast/common/comp/tsearch.c238
-rw-r--r--usr/src/lib/libast/common/comp/unlink.c38
-rw-r--r--usr/src/lib/libast/common/comp/unsetenv.c50
-rw-r--r--usr/src/lib/libast/common/comp/vfork.c55
-rw-r--r--usr/src/lib/libast/common/comp/waitpid.c199
-rw-r--r--usr/src/lib/libast/common/comp/wc.c139
-rw-r--r--usr/src/lib/libast/common/comp/wordexp.c217
-rw-r--r--usr/src/lib/libast/common/comp/wordexp.h63
-rw-r--r--usr/src/lib/libast/common/dir/dirlib.h174
-rw-r--r--usr/src/lib/libast/common/dir/getdents.c166
-rw-r--r--usr/src/lib/libast/common/dir/opendir.c95
-rw-r--r--usr/src/lib/libast/common/dir/readdir.c61
-rw-r--r--usr/src/lib/libast/common/dir/rewinddir.c46
-rw-r--r--usr/src/lib/libast/common/dir/seekdir.c56
-rw-r--r--usr/src/lib/libast/common/dir/telldir.c43
-rw-r--r--usr/src/lib/libast/common/disc/memfatal.c79
-rw-r--r--usr/src/lib/libast/common/disc/sfdcdio.c228
-rw-r--r--usr/src/lib/libast/common/disc/sfdcdos.c416
-rw-r--r--usr/src/lib/libast/common/disc/sfdcfilter.c186
-rw-r--r--usr/src/lib/libast/common/disc/sfdchdr.h28
-rw-r--r--usr/src/lib/libast/common/disc/sfdcmore.c369
-rw-r--r--usr/src/lib/libast/common/disc/sfdcprefix.c153
-rw-r--r--usr/src/lib/libast/common/disc/sfdcseekable.c227
-rw-r--r--usr/src/lib/libast/common/disc/sfdcslow.c83
-rw-r--r--usr/src/lib/libast/common/disc/sfdcsubstr.c217
-rw-r--r--usr/src/lib/libast/common/disc/sfdctee.c102
-rw-r--r--usr/src/lib/libast/common/disc/sfdcunion.c203
-rw-r--r--usr/src/lib/libast/common/disc/sfkeyprintf.c388
-rw-r--r--usr/src/lib/libast/common/disc/sfstrtmp.c62
-rw-r--r--usr/src/lib/libast/common/features/align.c167
-rw-r--r--usr/src/lib/libast/common/features/botch.c72
-rw-r--r--usr/src/lib/libast/common/features/ccode81
-rw-r--r--usr/src/lib/libast/common/features/common540
-rw-r--r--usr/src/lib/libast/common/features/dirent275
-rw-r--r--usr/src/lib/libast/common/features/eaccess11
-rw-r--r--usr/src/lib/libast/common/features/errno31
-rw-r--r--usr/src/lib/libast/common/features/fcntl.c360
-rw-r--r--usr/src/lib/libast/common/features/float1162
-rw-r--r--usr/src/lib/libast/common/features/fs234
-rw-r--r--usr/src/lib/libast/common/features/hack1
-rw-r--r--usr/src/lib/libast/common/features/iconv98
-rw-r--r--usr/src/lib/libast/common/features/lib648
-rw-r--r--usr/src/lib/libast/common/features/libpath.sh73
-rw-r--r--usr/src/lib/libast/common/features/limits.c339
-rw-r--r--usr/src/lib/libast/common/features/map.c523
-rw-r--r--usr/src/lib/libast/common/features/mmap342
-rw-r--r--usr/src/lib/libast/common/features/mode.c218
-rw-r--r--usr/src/lib/libast/common/features/nl_types64
-rw-r--r--usr/src/lib/libast/common/features/omitted110
-rw-r--r--usr/src/lib/libast/common/features/param.sh47
-rw-r--r--usr/src/lib/libast/common/features/preroot.sh46
-rw-r--r--usr/src/lib/libast/common/features/sfinit.c94
-rw-r--r--usr/src/lib/libast/common/features/sfio160
-rw-r--r--usr/src/lib/libast/common/features/sig.sh125
-rw-r--r--usr/src/lib/libast/common/features/signal.c278
-rw-r--r--usr/src/lib/libast/common/features/standards121
-rw-r--r--usr/src/lib/libast/common/features/stdio559
-rw-r--r--usr/src/lib/libast/common/features/sys273
-rw-r--r--usr/src/lib/libast/common/features/time46
-rw-r--r--usr/src/lib/libast/common/features/tmlib32
-rw-r--r--usr/src/lib/libast/common/features/tmx104
-rw-r--r--usr/src/lib/libast/common/features/tty127
-rw-r--r--usr/src/lib/libast/common/features/tv81
-rw-r--r--usr/src/lib/libast/common/features/tvlib67
-rw-r--r--usr/src/lib/libast/common/features/uwin6
-rw-r--r--usr/src/lib/libast/common/features/vfork13
-rw-r--r--usr/src/lib/libast/common/features/vmalloc163
-rw-r--r--usr/src/lib/libast/common/features/wait9
-rw-r--r--usr/src/lib/libast/common/features/wchar111
-rw-r--r--usr/src/lib/libast/common/hash/hashalloc.c200
-rw-r--r--usr/src/lib/libast/common/hash/hashdump.c173
-rw-r--r--usr/src/lib/libast/common/hash/hashfree.c144
-rw-r--r--usr/src/lib/libast/common/hash/hashlast.c43
-rw-r--r--usr/src/lib/libast/common/hash/hashlib.h104
-rw-r--r--usr/src/lib/libast/common/hash/hashlook.c366
-rw-r--r--usr/src/lib/libast/common/hash/hashscan.c139
-rw-r--r--usr/src/lib/libast/common/hash/hashsize.c84
-rw-r--r--usr/src/lib/libast/common/hash/hashview.c88
-rw-r--r--usr/src/lib/libast/common/hash/hashwalk.c51
-rw-r--r--usr/src/lib/libast/common/hash/memhash.c45
-rw-r--r--usr/src/lib/libast/common/hash/memsum.c53
-rw-r--r--usr/src/lib/libast/common/hash/strhash.c45
-rw-r--r--usr/src/lib/libast/common/hash/strkey.c49
-rw-r--r--usr/src/lib/libast/common/hash/strsum.c53
-rw-r--r--usr/src/lib/libast/common/include/ast.h362
-rw-r--r--usr/src/lib/libast/common/include/ast_dir.h77
-rw-r--r--usr/src/lib/libast/common/include/ast_getopt.h42
-rw-r--r--usr/src/lib/libast/common/include/ast_std.h327
-rw-r--r--usr/src/lib/libast/common/include/ast_version.h28
-rw-r--r--usr/src/lib/libast/common/include/ast_windows.h39
-rw-r--r--usr/src/lib/libast/common/include/ccode.h90
-rw-r--r--usr/src/lib/libast/common/include/cdt.h311
-rw-r--r--usr/src/lib/libast/common/include/debug.h52
-rw-r--r--usr/src/lib/libast/common/include/dt.h38
-rw-r--r--usr/src/lib/libast/common/include/error.h182
-rw-r--r--usr/src/lib/libast/common/include/find.h86
-rw-r--r--usr/src/lib/libast/common/include/fnv.h72
-rw-r--r--usr/src/lib/libast/common/include/fs3d.h109
-rw-r--r--usr/src/lib/libast/common/include/fts.h149
-rw-r--r--usr/src/lib/libast/common/include/ftwalk.h126
-rw-r--r--usr/src/lib/libast/common/include/glob.h144
-rw-r--r--usr/src/lib/libast/common/include/hash.h202
-rw-r--r--usr/src/lib/libast/common/include/hashkey.h62
-rw-r--r--usr/src/lib/libast/common/include/hashpart.h51
-rw-r--r--usr/src/lib/libast/common/include/ls.h88
-rw-r--r--usr/src/lib/libast/common/include/magic.h85
-rw-r--r--usr/src/lib/libast/common/include/magicid.h46
-rw-r--r--usr/src/lib/libast/common/include/mc.h96
-rw-r--r--usr/src/lib/libast/common/include/mime.h91
-rw-r--r--usr/src/lib/libast/common/include/mnt.h58
-rw-r--r--usr/src/lib/libast/common/include/modecanon.h65
-rw-r--r--usr/src/lib/libast/common/include/modex.h51
-rw-r--r--usr/src/lib/libast/common/include/namval.h42
-rw-r--r--usr/src/lib/libast/common/include/option.h105
-rw-r--r--usr/src/lib/libast/common/include/proc.h102
-rw-r--r--usr/src/lib/libast/common/include/recfmt.h83
-rw-r--r--usr/src/lib/libast/common/include/regex.h243
-rw-r--r--usr/src/lib/libast/common/include/sfdisc.h71
-rw-r--r--usr/src/lib/libast/common/include/sfio.h452
-rw-r--r--usr/src/lib/libast/common/include/sfio_s.h51
-rw-r--r--usr/src/lib/libast/common/include/sfio_t.h126
-rw-r--r--usr/src/lib/libast/common/include/stack.h83
-rw-r--r--usr/src/lib/libast/common/include/stak.h55
-rw-r--r--usr/src/lib/libast/common/include/stk.h77
-rw-r--r--usr/src/lib/libast/common/include/swap.h53
-rw-r--r--usr/src/lib/libast/common/include/tar.h118
-rw-r--r--usr/src/lib/libast/common/include/times.h54
-rw-r--r--usr/src/lib/libast/common/include/tm.h191
-rw-r--r--usr/src/lib/libast/common/include/tok.h47
-rw-r--r--usr/src/lib/libast/common/include/usage.h37
-rw-r--r--usr/src/lib/libast/common/include/vdb.h46
-rw-r--r--usr/src/lib/libast/common/include/vecargs.h45
-rw-r--r--usr/src/lib/libast/common/include/vmalloc.h315
-rw-r--r--usr/src/lib/libast/common/include/wait.h98
-rw-r--r--usr/src/lib/libast/common/llib-last662
-rw-r--r--usr/src/lib/libast/common/man/LIBAST.398
-rw-r--r--usr/src/lib/libast/common/man/ast.3283
-rw-r--r--usr/src/lib/libast/common/man/astsa.3161
-rw-r--r--usr/src/lib/libast/common/man/cdt.3593
-rw-r--r--usr/src/lib/libast/common/man/chr.3126
-rw-r--r--usr/src/lib/libast/common/man/compat.3103
-rw-r--r--usr/src/lib/libast/common/man/error.3283
-rw-r--r--usr/src/lib/libast/common/man/find.389
-rw-r--r--usr/src/lib/libast/common/man/fmt.3210
-rw-r--r--usr/src/lib/libast/common/man/fmtls.3144
-rw-r--r--usr/src/lib/libast/common/man/fs3d.392
-rw-r--r--usr/src/lib/libast/common/man/ftwalk.3235
-rw-r--r--usr/src/lib/libast/common/man/getcwd.367
-rw-r--r--usr/src/lib/libast/common/man/hash.3644
-rw-r--r--usr/src/lib/libast/common/man/iblocks.362
-rw-r--r--usr/src/lib/libast/common/man/int.368
-rw-r--r--usr/src/lib/libast/common/man/magic.3493
-rw-r--r--usr/src/lib/libast/common/man/mem.398
-rw-r--r--usr/src/lib/libast/common/man/mime.3117
-rw-r--r--usr/src/lib/libast/common/man/modecanon.3104
-rw-r--r--usr/src/lib/libast/common/man/optget.368
-rw-r--r--usr/src/lib/libast/common/man/path.3391
-rw-r--r--usr/src/lib/libast/common/man/preroot.3151
-rw-r--r--usr/src/lib/libast/common/man/proc.3319
-rw-r--r--usr/src/lib/libast/common/man/re.3214
-rw-r--r--usr/src/lib/libast/common/man/setenviron.379
-rw-r--r--usr/src/lib/libast/common/man/sfdisc.3118
-rw-r--r--usr/src/lib/libast/common/man/sfio.32311
-rw-r--r--usr/src/lib/libast/common/man/sig.375
-rw-r--r--usr/src/lib/libast/common/man/spawnveg.397
-rw-r--r--usr/src/lib/libast/common/man/stak.3169
-rw-r--r--usr/src/lib/libast/common/man/stk.3160
-rw-r--r--usr/src/lib/libast/common/man/strcopy.354
-rw-r--r--usr/src/lib/libast/common/man/strdup.355
-rw-r--r--usr/src/lib/libast/common/man/strelapsed.377
-rw-r--r--usr/src/lib/libast/common/man/strerror.353
-rw-r--r--usr/src/lib/libast/common/man/stresc.353
-rw-r--r--usr/src/lib/libast/common/man/streval.383
-rw-r--r--usr/src/lib/libast/common/man/strgid.353
-rw-r--r--usr/src/lib/libast/common/man/strmatch.3101
-rw-r--r--usr/src/lib/libast/common/man/stropt.3130
-rw-r--r--usr/src/lib/libast/common/man/strperm.3109
-rw-r--r--usr/src/lib/libast/common/man/strsignal.353
-rw-r--r--usr/src/lib/libast/common/man/strsort.373
-rw-r--r--usr/src/lib/libast/common/man/strtape.386
-rw-r--r--usr/src/lib/libast/common/man/strton.397
-rw-r--r--usr/src/lib/libast/common/man/struid.353
-rw-r--r--usr/src/lib/libast/common/man/swap.3138
-rw-r--r--usr/src/lib/libast/common/man/tab.374
-rw-r--r--usr/src/lib/libast/common/man/tm.3775
-rw-r--r--usr/src/lib/libast/common/man/tmx.3576
-rw-r--r--usr/src/lib/libast/common/man/tok.3217
-rw-r--r--usr/src/lib/libast/common/man/touch.368
-rw-r--r--usr/src/lib/libast/common/man/tv.3173
-rw-r--r--usr/src/lib/libast/common/man/vecargs.3126
-rw-r--r--usr/src/lib/libast/common/man/vmalloc.3565
-rw-r--r--usr/src/lib/libast/common/misc/error.c661
-rw-r--r--usr/src/lib/libast/common/misc/errorf.c41
-rw-r--r--usr/src/lib/libast/common/misc/errormsg.c41
-rw-r--r--usr/src/lib/libast/common/misc/errorx.c49
-rw-r--r--usr/src/lib/libast/common/misc/fastfind.c1303
-rw-r--r--usr/src/lib/libast/common/misc/findlib.h123
-rw-r--r--usr/src/lib/libast/common/misc/fmtrec.c102
-rw-r--r--usr/src/lib/libast/common/misc/fs3d.c90
-rw-r--r--usr/src/lib/libast/common/misc/fts.c1510
-rw-r--r--usr/src/lib/libast/common/misc/ftwalk.c154
-rw-r--r--usr/src/lib/libast/common/misc/ftwflags.c35
-rw-r--r--usr/src/lib/libast/common/misc/getcwd.c290
-rw-r--r--usr/src/lib/libast/common/misc/glob.c813
-rw-r--r--usr/src/lib/libast/common/misc/liberror.c40
-rw-r--r--usr/src/lib/libast/common/misc/libevent.c41
-rw-r--r--usr/src/lib/libast/common/misc/magic.c2419
-rw-r--r--usr/src/lib/libast/common/misc/mime.c807
-rw-r--r--usr/src/lib/libast/common/misc/mimelib.h52
-rw-r--r--usr/src/lib/libast/common/misc/mimetype.c69
-rw-r--r--usr/src/lib/libast/common/misc/optesc.c93
-rw-r--r--usr/src/lib/libast/common/misc/optget.c5176
-rw-r--r--usr/src/lib/libast/common/misc/optjoin.c123
-rw-r--r--usr/src/lib/libast/common/misc/optlib.h106
-rw-r--r--usr/src/lib/libast/common/misc/procclose.c91
-rw-r--r--usr/src/lib/libast/common/misc/procfree.c43
-rw-r--r--usr/src/lib/libast/common/misc/proclib.h63
-rw-r--r--usr/src/lib/libast/common/misc/procopen.c825
-rw-r--r--usr/src/lib/libast/common/misc/procrun.c40
-rw-r--r--usr/src/lib/libast/common/misc/recfmt.c165
-rw-r--r--usr/src/lib/libast/common/misc/reclen.c71
-rw-r--r--usr/src/lib/libast/common/misc/recstr.c203
-rw-r--r--usr/src/lib/libast/common/misc/setenviron.c142
-rw-r--r--usr/src/lib/libast/common/misc/sigcrit.c199
-rw-r--r--usr/src/lib/libast/common/misc/sigdata.c40
-rw-r--r--usr/src/lib/libast/common/misc/signal.c126
-rw-r--r--usr/src/lib/libast/common/misc/stack.c172
-rw-r--r--usr/src/lib/libast/common/misc/state.c40
-rw-r--r--usr/src/lib/libast/common/misc/stk.c508
-rw-r--r--usr/src/lib/libast/common/misc/systrace.c68
-rw-r--r--usr/src/lib/libast/common/misc/translate.c418
-rw-r--r--usr/src/lib/libast/common/misc/univdata.c58
-rw-r--r--usr/src/lib/libast/common/misc/univlib.h93
-rw-r--r--usr/src/lib/libast/common/obsolete/spawn.c152
-rw-r--r--usr/src/lib/libast/common/path/pathaccess.c57
-rw-r--r--usr/src/lib/libast/common/path/pathbin.c46
-rw-r--r--usr/src/lib/libast/common/path/pathcanon.c202
-rw-r--r--usr/src/lib/libast/common/path/pathcat.c54
-rw-r--r--usr/src/lib/libast/common/path/pathcd.c142
-rw-r--r--usr/src/lib/libast/common/path/pathcheck.c91
-rw-r--r--usr/src/lib/libast/common/path/pathexists.c134
-rw-r--r--usr/src/lib/libast/common/path/pathfind.c168
-rw-r--r--usr/src/lib/libast/common/path/pathgetlink.c102
-rw-r--r--usr/src/lib/libast/common/path/pathkey.c295
-rw-r--r--usr/src/lib/libast/common/path/pathnative.c126
-rw-r--r--usr/src/lib/libast/common/path/pathpath.c111
-rw-r--r--usr/src/lib/libast/common/path/pathposix.c128
-rw-r--r--usr/src/lib/libast/common/path/pathprobe.c300
-rw-r--r--usr/src/lib/libast/common/path/pathrepl.c77
-rw-r--r--usr/src/lib/libast/common/path/pathsetlink.c72
-rw-r--r--usr/src/lib/libast/common/path/pathshell.c112
-rw-r--r--usr/src/lib/libast/common/path/pathstat.c45
-rw-r--r--usr/src/lib/libast/common/path/pathtemp.c289
-rw-r--r--usr/src/lib/libast/common/path/pathtmp.c41
-rw-r--r--usr/src/lib/libast/common/port/astconf.c1546
-rw-r--r--usr/src/lib/libast/common/port/astcopy.c90
-rw-r--r--usr/src/lib/libast/common/port/astdynamic.c132
-rw-r--r--usr/src/lib/libast/common/port/astlicense.c1147
-rw-r--r--usr/src/lib/libast/common/port/astmath.c62
-rw-r--r--usr/src/lib/libast/common/port/astquery.c109
-rw-r--r--usr/src/lib/libast/common/port/aststatic.c44
-rw-r--r--usr/src/lib/libast/common/port/astwinsize.c143
-rw-r--r--usr/src/lib/libast/common/port/iblocks.c95
-rw-r--r--usr/src/lib/libast/common/port/lc.c832
-rw-r--r--usr/src/lib/libast/common/port/lc.tab275
-rw-r--r--usr/src/lib/libast/common/port/lcgen.c775
-rw-r--r--usr/src/lib/libast/common/port/lclib.h61
-rw-r--r--usr/src/lib/libast/common/port/mc.c677
-rw-r--r--usr/src/lib/libast/common/port/mnt.c792
-rw-r--r--usr/src/lib/libast/common/port/touch.c74
-rw-r--r--usr/src/lib/libast/common/preroot/getpreroot.c165
-rw-r--r--usr/src/lib/libast/common/preroot/ispreroot.c71
-rw-r--r--usr/src/lib/libast/common/preroot/realopen.c47
-rw-r--r--usr/src/lib/libast/common/preroot/setpreroot.c75
-rw-r--r--usr/src/lib/libast/common/regex/regalloc.c36
-rw-r--r--usr/src/lib/libast/common/regex/regcache.c174
-rw-r--r--usr/src/lib/libast/common/regex/regclass.c243
-rw-r--r--usr/src/lib/libast/common/regex/regcoll.c297
-rw-r--r--usr/src/lib/libast/common/regex/regcomp.c3485
-rw-r--r--usr/src/lib/libast/common/regex/regdecomp.c448
-rw-r--r--usr/src/lib/libast/common/regex/regerror.c95
-rw-r--r--usr/src/lib/libast/common/regex/regexec.c54
-rw-r--r--usr/src/lib/libast/common/regex/regfatal.c49
-rw-r--r--usr/src/lib/libast/common/regex/reginit.c402
-rw-r--r--usr/src/lib/libast/common/regex/reglib.h578
-rw-r--r--usr/src/lib/libast/common/regex/regnexec.c2047
-rw-r--r--usr/src/lib/libast/common/regex/regrecord.c34
-rw-r--r--usr/src/lib/libast/common/regex/regrexec.c145
-rw-r--r--usr/src/lib/libast/common/regex/regstat.c46
-rw-r--r--usr/src/lib/libast/common/regex/regsub.c268
-rw-r--r--usr/src/lib/libast/common/regex/regsubcomp.c452
-rw-r--r--usr/src/lib/libast/common/regex/regsubexec.c190
-rw-r--r--usr/src/lib/libast/common/regex/ucs_names.h6426
-rw-r--r--usr/src/lib/libast/common/sfio/_sfclrerr.c34
-rw-r--r--usr/src/lib/libast/common/sfio/_sfdlen.c34
-rw-r--r--usr/src/lib/libast/common/sfio/_sfeof.c34
-rw-r--r--usr/src/lib/libast/common/sfio/_sferror.c34
-rw-r--r--usr/src/lib/libast/common/sfio/_sffileno.c34
-rw-r--r--usr/src/lib/libast/common/sfio/_sfgetc.c34
-rw-r--r--usr/src/lib/libast/common/sfio/_sfgetl.c42
-rw-r--r--usr/src/lib/libast/common/sfio/_sfgetl2.c50
-rw-r--r--usr/src/lib/libast/common/sfio/_sfgetu.c42
-rw-r--r--usr/src/lib/libast/common/sfio/_sfgetu2.c50
-rw-r--r--usr/src/lib/libast/common/sfio/_sfllen.c34
-rw-r--r--usr/src/lib/libast/common/sfio/_sfopen.c215
-rw-r--r--usr/src/lib/libast/common/sfio/_sfputc.c35
-rw-r--r--usr/src/lib/libast/common/sfio/_sfputd.c95
-rw-r--r--usr/src/lib/libast/common/sfio/_sfputl.c81
-rw-r--r--usr/src/lib/libast/common/sfio/_sfputm.c77
-rw-r--r--usr/src/lib/libast/common/sfio/_sfputu.c74
-rw-r--r--usr/src/lib/libast/common/sfio/_sfslen.c33
-rw-r--r--usr/src/lib/libast/common/sfio/_sfstacked.c34
-rw-r--r--usr/src/lib/libast/common/sfio/_sfulen.c34
-rw-r--r--usr/src/lib/libast/common/sfio/_sfvalue.c34
-rw-r--r--usr/src/lib/libast/common/sfio/sfclose.c168
-rw-r--r--usr/src/lib/libast/common/sfio/sfclrlock.c62
-rw-r--r--usr/src/lib/libast/common/sfio/sfcvt.c396
-rw-r--r--usr/src/lib/libast/common/sfio/sfdisc.c265
-rw-r--r--usr/src/lib/libast/common/sfio/sfdlen.c58
-rw-r--r--usr/src/lib/libast/common/sfio/sfecvt.c38
-rw-r--r--usr/src/lib/libast/common/sfio/sfexcept.c132
-rw-r--r--usr/src/lib/libast/common/sfio/sfextern.c101
-rw-r--r--usr/src/lib/libast/common/sfio/sffcvt.c38
-rw-r--r--usr/src/lib/libast/common/sfio/sffilbuf.c115
-rw-r--r--usr/src/lib/libast/common/sfio/sfflsbuf.c116
-rw-r--r--usr/src/lib/libast/common/sfio/sfgetd.c78
-rw-r--r--usr/src/lib/libast/common/sfio/sfgetl.c69
-rw-r--r--usr/src/lib/libast/common/sfio/sfgetm.c67
-rw-r--r--usr/src/lib/libast/common/sfio/sfgetr.c163
-rw-r--r--usr/src/lib/libast/common/sfio/sfgetu.c66
-rw-r--r--usr/src/lib/libast/common/sfio/sfhdr.h1257
-rw-r--r--usr/src/lib/libast/common/sfio/sfllen.c39
-rw-r--r--usr/src/lib/libast/common/sfio/sfmode.c593
-rw-r--r--usr/src/lib/libast/common/sfio/sfmove.c240
-rw-r--r--usr/src/lib/libast/common/sfio/sfmutex.c69
-rw-r--r--usr/src/lib/libast/common/sfio/sfnew.c129
-rw-r--r--usr/src/lib/libast/common/sfio/sfnotify.c38
-rw-r--r--usr/src/lib/libast/common/sfio/sfnputc.c80
-rw-r--r--usr/src/lib/libast/common/sfio/sfopen.c40
-rw-r--r--usr/src/lib/libast/common/sfio/sfpeek.c89
-rw-r--r--usr/src/lib/libast/common/sfio/sfpkrd.c290
-rw-r--r--usr/src/lib/libast/common/sfio/sfpoll.c245
-rw-r--r--usr/src/lib/libast/common/sfio/sfpool.c360
-rw-r--r--usr/src/lib/libast/common/sfio/sfpopen.c293
-rw-r--r--usr/src/lib/libast/common/sfio/sfprintf.c116
-rw-r--r--usr/src/lib/libast/common/sfio/sfprints.c125
-rw-r--r--usr/src/lib/libast/common/sfio/sfpurge.c97
-rw-r--r--usr/src/lib/libast/common/sfio/sfputd.c35
-rw-r--r--usr/src/lib/libast/common/sfio/sfputl.c35
-rw-r--r--usr/src/lib/libast/common/sfio/sfputm.c36
-rw-r--r--usr/src/lib/libast/common/sfio/sfputr.c121
-rw-r--r--usr/src/lib/libast/common/sfio/sfputu.c35
-rw-r--r--usr/src/lib/libast/common/sfio/sfraise.c106
-rw-r--r--usr/src/lib/libast/common/sfio/sfrd.c316
-rw-r--r--usr/src/lib/libast/common/sfio/sfread.c139
-rw-r--r--usr/src/lib/libast/common/sfio/sfreserve.c197
-rw-r--r--usr/src/lib/libast/common/sfio/sfresize.c81
-rw-r--r--usr/src/lib/libast/common/sfio/sfscanf.c102
-rw-r--r--usr/src/lib/libast/common/sfio/sfseek.c280
-rw-r--r--usr/src/lib/libast/common/sfio/sfset.c88
-rw-r--r--usr/src/lib/libast/common/sfio/sfsetbuf.c403
-rw-r--r--usr/src/lib/libast/common/sfio/sfsetfd.c135
-rw-r--r--usr/src/lib/libast/common/sfio/sfsize.c108
-rw-r--r--usr/src/lib/libast/common/sfio/sfsk.c105
-rw-r--r--usr/src/lib/libast/common/sfio/sfstack.c115
-rw-r--r--usr/src/lib/libast/common/sfio/sfstrtod.c157
-rw-r--r--usr/src/lib/libast/common/sfio/sfstrtof.h544
-rw-r--r--usr/src/lib/libast/common/sfio/sfswap.c119
-rw-r--r--usr/src/lib/libast/common/sfio/sfsync.c171
-rw-r--r--usr/src/lib/libast/common/sfio/sftable.c541
-rw-r--r--usr/src/lib/libast/common/sfio/sftell.c58
-rw-r--r--usr/src/lib/libast/common/sfio/sftmp.c402
-rw-r--r--usr/src/lib/libast/common/sfio/sfungetc.c107
-rw-r--r--usr/src/lib/libast/common/sfio/sfvprintf.c1377
-rw-r--r--usr/src/lib/libast/common/sfio/sfvscanf.c1097
-rw-r--r--usr/src/lib/libast/common/sfio/sfwr.c248
-rw-r--r--usr/src/lib/libast/common/sfio/sfwrite.c170
-rw-r--r--usr/src/lib/libast/common/sfio/vthread.h219
-rw-r--r--usr/src/lib/libast/common/std/bytesex.h43
-rw-r--r--usr/src/lib/libast/common/std/dirent.h22
-rw-r--r--usr/src/lib/libast/common/std/endian.h54
-rw-r--r--usr/src/lib/libast/common/std/iconv.h22
-rw-r--r--usr/src/lib/libast/common/std/nl_types.h22
-rw-r--r--usr/src/lib/libast/common/std/stdio.h22
-rw-r--r--usr/src/lib/libast/common/std/wchar.h22
-rw-r--r--usr/src/lib/libast/common/stdio/_doprnt.c32
-rw-r--r--usr/src/lib/libast/common/stdio/_doscan.c32
-rw-r--r--usr/src/lib/libast/common/stdio/_filbuf.c36
-rw-r--r--usr/src/lib/libast/common/stdio/_flsbuf.c44
-rw-r--r--usr/src/lib/libast/common/stdio/_stdfun.c78
-rw-r--r--usr/src/lib/libast/common/stdio/_stdopen.c32
-rw-r--r--usr/src/lib/libast/common/stdio/_stdprintf.c38
-rw-r--r--usr/src/lib/libast/common/stdio/_stdscanf.c38
-rw-r--r--usr/src/lib/libast/common/stdio/_stdsprnt.c38
-rw-r--r--usr/src/lib/libast/common/stdio/_stdvbuf.c32
-rw-r--r--usr/src/lib/libast/common/stdio/_stdvsnprnt.c32
-rw-r--r--usr/src/lib/libast/common/stdio/_stdvsprnt.c32
-rw-r--r--usr/src/lib/libast/common/stdio/_stdvsscn.c32
-rw-r--r--usr/src/lib/libast/common/stdio/asprintf.c36
-rw-r--r--usr/src/lib/libast/common/stdio/clearerr.c33
-rw-r--r--usr/src/lib/libast/common/stdio/fclose.c32
-rw-r--r--usr/src/lib/libast/common/stdio/fdopen.c34
-rw-r--r--usr/src/lib/libast/common/stdio/feof.c42
-rw-r--r--usr/src/lib/libast/common/stdio/ferror.c42
-rw-r--r--usr/src/lib/libast/common/stdio/fflush.c37
-rw-r--r--usr/src/lib/libast/common/stdio/fgetc.c32
-rw-r--r--usr/src/lib/libast/common/stdio/fgetpos.c48
-rw-r--r--usr/src/lib/libast/common/stdio/fgets.c110
-rw-r--r--usr/src/lib/libast/common/stdio/fgetwc.c35
-rw-r--r--usr/src/lib/libast/common/stdio/fgetws.c52
-rw-r--r--usr/src/lib/libast/common/stdio/fileno.c42
-rw-r--r--usr/src/lib/libast/common/stdio/fopen.c30
-rw-r--r--usr/src/lib/libast/common/stdio/fprintf.c39
-rw-r--r--usr/src/lib/libast/common/stdio/fpurge.c32
-rw-r--r--usr/src/lib/libast/common/stdio/fputc.c42
-rw-r--r--usr/src/lib/libast/common/stdio/fputs.c32
-rw-r--r--usr/src/lib/libast/common/stdio/fputwc.c33
-rw-r--r--usr/src/lib/libast/common/stdio/fputws.c36
-rw-r--r--usr/src/lib/libast/common/stdio/fread.c34
-rw-r--r--usr/src/lib/libast/common/stdio/freopen.c32
-rw-r--r--usr/src/lib/libast/common/stdio/fscanf.c39
-rw-r--r--usr/src/lib/libast/common/stdio/fseek.c48
-rw-r--r--usr/src/lib/libast/common/stdio/fseeko.c48
-rw-r--r--usr/src/lib/libast/common/stdio/fsetpos.c48
-rw-r--r--usr/src/lib/libast/common/stdio/ftell.c48
-rw-r--r--usr/src/lib/libast/common/stdio/ftello.c48
-rw-r--r--usr/src/lib/libast/common/stdio/fwide.c51
-rw-r--r--usr/src/lib/libast/common/stdio/fwprintf.c36
-rw-r--r--usr/src/lib/libast/common/stdio/fwrite.c34
-rw-r--r--usr/src/lib/libast/common/stdio/fwscanf.c39
-rw-r--r--usr/src/lib/libast/common/stdio/getc.c42
-rw-r--r--usr/src/lib/libast/common/stdio/getchar.c40
-rw-r--r--usr/src/lib/libast/common/stdio/getw.c34
-rw-r--r--usr/src/lib/libast/common/stdio/getwc.c30
-rw-r--r--usr/src/lib/libast/common/stdio/getwchar.c30
-rw-r--r--usr/src/lib/libast/common/stdio/pclose.c32
-rw-r--r--usr/src/lib/libast/common/stdio/popen.c30
-rw-r--r--usr/src/lib/libast/common/stdio/printf.c36
-rw-r--r--usr/src/lib/libast/common/stdio/putc.c42
-rw-r--r--usr/src/lib/libast/common/stdio/putchar.c40
-rw-r--r--usr/src/lib/libast/common/stdio/puts.c30
-rw-r--r--usr/src/lib/libast/common/stdio/putw.c32
-rw-r--r--usr/src/lib/libast/common/stdio/putwc.c30
-rw-r--r--usr/src/lib/libast/common/stdio/putwchar.c30
-rw-r--r--usr/src/lib/libast/common/stdio/rewind.c33
-rw-r--r--usr/src/lib/libast/common/stdio/scanf.c36
-rw-r--r--usr/src/lib/libast/common/stdio/setbuf.c32
-rw-r--r--usr/src/lib/libast/common/stdio/setbuffer.c32
-rw-r--r--usr/src/lib/libast/common/stdio/setlinebuf.c33
-rw-r--r--usr/src/lib/libast/common/stdio/setvbuf.c48
-rw-r--r--usr/src/lib/libast/common/stdio/snprintf.c36
-rw-r--r--usr/src/lib/libast/common/stdio/sprintf.c36
-rw-r--r--usr/src/lib/libast/common/stdio/sscanf.c36
-rw-r--r--usr/src/lib/libast/common/stdio/stdhdr.h115
-rw-r--r--usr/src/lib/libast/common/stdio/stdio_c99.c118
-rw-r--r--usr/src/lib/libast/common/stdio/stdio_gnu.c74
-rw-r--r--usr/src/lib/libast/common/stdio/swprintf.c36
-rw-r--r--usr/src/lib/libast/common/stdio/swscanf.c36
-rw-r--r--usr/src/lib/libast/common/stdio/tmpfile.c30
-rw-r--r--usr/src/lib/libast/common/stdio/ungetc.c32
-rw-r--r--usr/src/lib/libast/common/stdio/ungetwc.c39
-rw-r--r--usr/src/lib/libast/common/stdio/vasprintf.c45
-rw-r--r--usr/src/lib/libast/common/stdio/vfprintf.c32
-rw-r--r--usr/src/lib/libast/common/stdio/vfscanf.c32
-rw-r--r--usr/src/lib/libast/common/stdio/vfwprintf.c65
-rw-r--r--usr/src/lib/libast/common/stdio/vfwscanf.c129
-rw-r--r--usr/src/lib/libast/common/stdio/vprintf.c30
-rw-r--r--usr/src/lib/libast/common/stdio/vscanf.c30
-rw-r--r--usr/src/lib/libast/common/stdio/vsnprintf.c55
-rw-r--r--usr/src/lib/libast/common/stdio/vsprintf.c30
-rw-r--r--usr/src/lib/libast/common/stdio/vsscanf.c30
-rw-r--r--usr/src/lib/libast/common/stdio/vswprintf.c55
-rw-r--r--usr/src/lib/libast/common/stdio/vswscanf.c51
-rw-r--r--usr/src/lib/libast/common/stdio/vwprintf.c30
-rw-r--r--usr/src/lib/libast/common/stdio/vwscanf.c30
-rw-r--r--usr/src/lib/libast/common/stdio/wprintf.c36
-rw-r--r--usr/src/lib/libast/common/stdio/wscanf.c36
-rw-r--r--usr/src/lib/libast/common/string/base64.c302
-rw-r--r--usr/src/lib/libast/common/string/ccmap.c746
-rw-r--r--usr/src/lib/libast/common/string/ccmapid.c173
-rw-r--r--usr/src/lib/libast/common/string/ccnative.c56
-rw-r--r--usr/src/lib/libast/common/string/chresc.c181
-rw-r--r--usr/src/lib/libast/common/string/chrtoi.c55
-rw-r--r--usr/src/lib/libast/common/string/fmtbase.c56
-rw-r--r--usr/src/lib/libast/common/string/fmtbuf.c69
-rw-r--r--usr/src/lib/libast/common/string/fmtclock.c56
-rw-r--r--usr/src/lib/libast/common/string/fmtdev.c57
-rw-r--r--usr/src/lib/libast/common/string/fmtelapsed.c61
-rw-r--r--usr/src/lib/libast/common/string/fmterror.c37
-rw-r--r--usr/src/lib/libast/common/string/fmtesc.c237
-rw-r--r--usr/src/lib/libast/common/string/fmtfmt.c205
-rw-r--r--usr/src/lib/libast/common/string/fmtfs.c100
-rw-r--r--usr/src/lib/libast/common/string/fmtgid.c101
-rw-r--r--usr/src/lib/libast/common/string/fmtident.c77
-rw-r--r--usr/src/lib/libast/common/string/fmtip4.c43
-rw-r--r--usr/src/lib/libast/common/string/fmtls.c120
-rw-r--r--usr/src/lib/libast/common/string/fmtmatch.c286
-rw-r--r--usr/src/lib/libast/common/string/fmtmode.c47
-rw-r--r--usr/src/lib/libast/common/string/fmtnum.c92
-rw-r--r--usr/src/lib/libast/common/string/fmtperm.c91
-rw-r--r--usr/src/lib/libast/common/string/fmtre.c225
-rw-r--r--usr/src/lib/libast/common/string/fmtscale.c94
-rw-r--r--usr/src/lib/libast/common/string/fmtsignal.c62
-rw-r--r--usr/src/lib/libast/common/string/fmttime.c41
-rw-r--r--usr/src/lib/libast/common/string/fmttmx.c45
-rw-r--r--usr/src/lib/libast/common/string/fmttv.c44
-rw-r--r--usr/src/lib/libast/common/string/fmtuid.c101
-rw-r--r--usr/src/lib/libast/common/string/fmtversion.c53
-rw-r--r--usr/src/lib/libast/common/string/memdup.c44
-rw-r--r--usr/src/lib/libast/common/string/modedata.c69
-rw-r--r--usr/src/lib/libast/common/string/modei.c55
-rw-r--r--usr/src/lib/libast/common/string/modelib.h55
-rw-r--r--usr/src/lib/libast/common/string/modex.c75
-rw-r--r--usr/src/lib/libast/common/string/stracmp.c62
-rw-r--r--usr/src/lib/libast/common/string/strcopy.c36
-rw-r--r--usr/src/lib/libast/common/string/strdup.c44
-rw-r--r--usr/src/lib/libast/common/string/strelapsed.c142
-rw-r--r--usr/src/lib/libast/common/string/strerror.c147
-rw-r--r--usr/src/lib/libast/common/string/stresc.c58
-rw-r--r--usr/src/lib/libast/common/string/streval.c50
-rw-r--r--usr/src/lib/libast/common/string/strexpr.c294
-rw-r--r--usr/src/lib/libast/common/string/strgid.c121
-rw-r--r--usr/src/lib/libast/common/string/strlcat.c78
-rw-r--r--usr/src/lib/libast/common/string/strlcpy.c71
-rw-r--r--usr/src/lib/libast/common/string/strlook.c50
-rw-r--r--usr/src/lib/libast/common/string/strmatch.c167
-rw-r--r--usr/src/lib/libast/common/string/strmode.c51
-rw-r--r--usr/src/lib/libast/common/string/strnacmp.c66
-rw-r--r--usr/src/lib/libast/common/string/strncopy.c46
-rw-r--r--usr/src/lib/libast/common/string/strntod.c32
-rw-r--r--usr/src/lib/libast/common/string/strntol.c31
-rw-r--r--usr/src/lib/libast/common/string/strntold.c32
-rw-r--r--usr/src/lib/libast/common/string/strntoll.c31
-rw-r--r--usr/src/lib/libast/common/string/strntoul.c32
-rw-r--r--usr/src/lib/libast/common/string/strntoull.c32
-rw-r--r--usr/src/lib/libast/common/string/stropt.c188
-rw-r--r--usr/src/lib/libast/common/string/strperm.c267
-rw-r--r--usr/src/lib/libast/common/string/strpsearch.c125
-rw-r--r--usr/src/lib/libast/common/string/strsearch.c57
-rw-r--r--usr/src/lib/libast/common/string/strsort.c57
-rw-r--r--usr/src/lib/libast/common/string/strtape.c148
-rw-r--r--usr/src/lib/libast/common/string/strtoi.h610
-rw-r--r--usr/src/lib/libast/common/string/strtoip4.c150
-rw-r--r--usr/src/lib/libast/common/string/strton.c31
-rw-r--r--usr/src/lib/libast/common/string/strtonll.c31
-rw-r--r--usr/src/lib/libast/common/string/struid.c109
-rw-r--r--usr/src/lib/libast/common/string/struniq.c51
-rw-r--r--usr/src/lib/libast/common/string/swapget.c57
-rw-r--r--usr/src/lib/libast/common/string/swapmem.c109
-rw-r--r--usr/src/lib/libast/common/string/swapop.c59
-rw-r--r--usr/src/lib/libast/common/string/swapput.c50
-rw-r--r--usr/src/lib/libast/common/string/tok.c190
-rw-r--r--usr/src/lib/libast/common/string/tokline.c193
-rw-r--r--usr/src/lib/libast/common/string/tokscan.c360
-rw-r--r--usr/src/lib/libast/common/tm/tmdata.c282
-rw-r--r--usr/src/lib/libast/common/tm/tmdate.c41
-rw-r--r--usr/src/lib/libast/common/tm/tmequiv.c57
-rw-r--r--usr/src/lib/libast/common/tm/tmfix.c163
-rw-r--r--usr/src/lib/libast/common/tm/tmfmt.c41
-rw-r--r--usr/src/lib/libast/common/tm/tmform.c44
-rw-r--r--usr/src/lib/libast/common/tm/tmgoff.c77
-rw-r--r--usr/src/lib/libast/common/tm/tminit.c454
-rw-r--r--usr/src/lib/libast/common/tm/tmleap.c41
-rw-r--r--usr/src/lib/libast/common/tm/tmlex.c67
-rw-r--r--usr/src/lib/libast/common/tm/tmlocale.c619
-rw-r--r--usr/src/lib/libast/common/tm/tmmake.c41
-rw-r--r--usr/src/lib/libast/common/tm/tmpoff.c62
-rw-r--r--usr/src/lib/libast/common/tm/tmscan.c41
-rw-r--r--usr/src/lib/libast/common/tm/tmsleep.c42
-rw-r--r--usr/src/lib/libast/common/tm/tmtime.c41
-rw-r--r--usr/src/lib/libast/common/tm/tmtype.c57
-rw-r--r--usr/src/lib/libast/common/tm/tmweek.c87
-rw-r--r--usr/src/lib/libast/common/tm/tmword.c89
-rw-r--r--usr/src/lib/libast/common/tm/tmxdate.c1226
-rw-r--r--usr/src/lib/libast/common/tm/tmxfmt.c541
-rw-r--r--usr/src/lib/libast/common/tm/tmxgettime.c44
-rw-r--r--usr/src/lib/libast/common/tm/tmxleap.c51
-rw-r--r--usr/src/lib/libast/common/tm/tmxmake.c134
-rw-r--r--usr/src/lib/libast/common/tm/tmxscan.c523
-rw-r--r--usr/src/lib/libast/common/tm/tmxsettime.c45
-rw-r--r--usr/src/lib/libast/common/tm/tmxsleep.c41
-rw-r--r--usr/src/lib/libast/common/tm/tmxtime.c137
-rw-r--r--usr/src/lib/libast/common/tm/tmxtouch.c81
-rw-r--r--usr/src/lib/libast/common/tm/tmzone.c95
-rw-r--r--usr/src/lib/libast/common/tm/tvcmp.c46
-rw-r--r--usr/src/lib/libast/common/tm/tvgettime.c70
-rw-r--r--usr/src/lib/libast/common/tm/tvsettime.c72
-rw-r--r--usr/src/lib/libast/common/tm/tvsleep.c144
-rw-r--r--usr/src/lib/libast/common/tm/tvtouch.c232
-rw-r--r--usr/src/lib/libast/common/uwin/a64l.c76
-rw-r--r--usr/src/lib/libast/common/uwin/acosh.c108
-rw-r--r--usr/src/lib/libast/common/uwin/asinh.c107
-rw-r--r--usr/src/lib/libast/common/uwin/atanh.c89
-rw-r--r--usr/src/lib/libast/common/uwin/cbrt.c38
-rw-r--r--usr/src/lib/libast/common/uwin/crypt.c959
-rw-r--r--usr/src/lib/libast/common/uwin/erf.c403
-rw-r--r--usr/src/lib/libast/common/uwin/err.c124
-rw-r--r--usr/src/lib/libast/common/uwin/exp.c213
-rw-r--r--usr/src/lib/libast/common/uwin/exp__E.c142
-rw-r--r--usr/src/lib/libast/common/uwin/expm1.c173
-rw-r--r--usr/src/lib/libast/common/uwin/gamma.c343
-rw-r--r--usr/src/lib/libast/common/uwin/getpass.c79
-rw-r--r--usr/src/lib/libast/common/uwin/lgamma.c316
-rw-r--r--usr/src/lib/libast/common/uwin/log.c496
-rw-r--r--usr/src/lib/libast/common/uwin/log1p.c176
-rw-r--r--usr/src/lib/libast/common/uwin/log__L.c116
-rw-r--r--usr/src/lib/libast/common/uwin/rand48.c177
-rw-r--r--usr/src/lib/libast/common/uwin/random.c381
-rw-r--r--usr/src/lib/libast/common/uwin/rcmd.c571
-rw-r--r--usr/src/lib/libast/common/uwin/rint.c41
-rw-r--r--usr/src/lib/libast/common/uwin/support.c605
-rw-r--r--usr/src/lib/libast/common/vec/vecargs.c76
-rw-r--r--usr/src/lib/libast/common/vec/vecfile.c62
-rw-r--r--usr/src/lib/libast/common/vec/vecfree.c48
-rw-r--r--usr/src/lib/libast/common/vec/vecload.c96
-rw-r--r--usr/src/lib/libast/common/vec/vecstring.c46
-rw-r--r--usr/src/lib/libast/common/vmalloc/malloc.c919
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmbest.c1465
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmclear.c89
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmclose.c89
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmdcheap.c64
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmdebug.c732
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmdisc.c57
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmexit.c100
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmgetmem.c57
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmhdr.h549
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmlast.c453
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmmopen.c324
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmopen.c176
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmpool.c345
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmprivate.c307
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmprofile.c734
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmregion.c44
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmsegment.c61
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmset.c70
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmstat.c128
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmstrdup.c48
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmtrace.c285
-rw-r--r--usr/src/lib/libast/common/vmalloc/vmwalk.c76
-rw-r--r--usr/src/lib/libast/i386/Makefile47
-rw-r--r--usr/src/lib/libast/i386/include/ast/align.h54
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast.h381
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_botch.h26
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_ccode.h50
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_common.h219
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_dir.h86
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_dirent.h127
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_fcntl.h135
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_float.h234
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_fs.h179
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_getopt.h51
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_iconv.h153
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_lib.h192
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_limits.h128
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_map.h459
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_mmap.h47
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_mode.h35
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_nl_types.h123
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_param.h30
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_standards.h49
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_std.h343
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_stdio.h600
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_sys.h172
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_time.h104
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_tty.h155
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_types.h26
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_version.h10
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_vfork.h88
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_wait.h32
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_wchar.h208
-rw-r--r--usr/src/lib/libast/i386/include/ast/ast_windows.h48
-rw-r--r--usr/src/lib/libast/i386/include/ast/bytesex.h43
-rw-r--r--usr/src/lib/libast/i386/include/ast/ccode.h101
-rw-r--r--usr/src/lib/libast/i386/include/ast/cdt.h311
-rw-r--r--usr/src/lib/libast/i386/include/ast/debug.h63
-rw-r--r--usr/src/lib/libast/i386/include/ast/dirent.h22
-rw-r--r--usr/src/lib/libast/i386/include/ast/dt.h49
-rw-r--r--usr/src/lib/libast/i386/include/ast/endian.h54
-rw-r--r--usr/src/lib/libast/i386/include/ast/error.h196
-rw-r--r--usr/src/lib/libast/i386/include/ast/find.h97
-rw-r--r--usr/src/lib/libast/i386/include/ast/fnmatch.h71
-rw-r--r--usr/src/lib/libast/i386/include/ast/fnv.h81
-rw-r--r--usr/src/lib/libast/i386/include/ast/fs3d.h120
-rw-r--r--usr/src/lib/libast/i386/include/ast/fts.h160
-rw-r--r--usr/src/lib/libast/i386/include/ast/ftw.h71
-rw-r--r--usr/src/lib/libast/i386/include/ast/ftwalk.h137
-rw-r--r--usr/src/lib/libast/i386/include/ast/getopt.h31
-rw-r--r--usr/src/lib/libast/i386/include/ast/glob.h155
-rw-r--r--usr/src/lib/libast/i386/include/ast/hash.h213
-rw-r--r--usr/src/lib/libast/i386/include/ast/hashkey.h73
-rw-r--r--usr/src/lib/libast/i386/include/ast/hashpart.h60
-rw-r--r--usr/src/lib/libast/i386/include/ast/iconv.h22
-rw-r--r--usr/src/lib/libast/i386/include/ast/lc.h158
-rw-r--r--usr/src/lib/libast/i386/include/ast/ls.h99
-rw-r--r--usr/src/lib/libast/i386/include/ast/magic.h96
-rw-r--r--usr/src/lib/libast/i386/include/ast/magicid.h55
-rw-r--r--usr/src/lib/libast/i386/include/ast/mc.h107
-rw-r--r--usr/src/lib/libast/i386/include/ast/mime.h102
-rw-r--r--usr/src/lib/libast/i386/include/ast/mnt.h69
-rw-r--r--usr/src/lib/libast/i386/include/ast/modecanon.h74
-rw-r--r--usr/src/lib/libast/i386/include/ast/modex.h62
-rw-r--r--usr/src/lib/libast/i386/include/ast/namval.h51
-rw-r--r--usr/src/lib/libast/i386/include/ast/nl_types.h22
-rw-r--r--usr/src/lib/libast/i386/include/ast/option.h119
-rw-r--r--usr/src/lib/libast/i386/include/ast/preroot.h27
-rw-r--r--usr/src/lib/libast/i386/include/ast/proc.h113
-rw-r--r--usr/src/lib/libast/i386/include/ast/prototyped.h59
-rw-r--r--usr/src/lib/libast/i386/include/ast/re_comp.h52
-rw-r--r--usr/src/lib/libast/i386/include/ast/recfmt.h94
-rw-r--r--usr/src/lib/libast/i386/include/ast/regex.h227
-rw-r--r--usr/src/lib/libast/i386/include/ast/regexp.h139
-rw-r--r--usr/src/lib/libast/i386/include/ast/sfdisc.h82
-rw-r--r--usr/src/lib/libast/i386/include/ast/sfio.h452
-rw-r--r--usr/src/lib/libast/i386/include/ast/sfio_s.h51
-rw-r--r--usr/src/lib/libast/i386/include/ast/sfio_t.h126
-rw-r--r--usr/src/lib/libast/i386/include/ast/sig.h152
-rw-r--r--usr/src/lib/libast/i386/include/ast/stack.h94
-rw-r--r--usr/src/lib/libast/i386/include/ast/stak.h64
-rw-r--r--usr/src/lib/libast/i386/include/ast/stdio.h22
-rw-r--r--usr/src/lib/libast/i386/include/ast/stk.h91
-rw-r--r--usr/src/lib/libast/i386/include/ast/swap.h64
-rw-r--r--usr/src/lib/libast/i386/include/ast/tar.h127
-rw-r--r--usr/src/lib/libast/i386/include/ast/times.h65
-rw-r--r--usr/src/lib/libast/i386/include/ast/tm.h205
-rw-r--r--usr/src/lib/libast/i386/include/ast/tmx.h149
-rw-r--r--usr/src/lib/libast/i386/include/ast/tok.h58
-rw-r--r--usr/src/lib/libast/i386/include/ast/tv.h132
-rw-r--r--usr/src/lib/libast/i386/include/ast/usage.h37
-rw-r--r--usr/src/lib/libast/i386/include/ast/vdb.h55
-rw-r--r--usr/src/lib/libast/i386/include/ast/vecargs.h56
-rw-r--r--usr/src/lib/libast/i386/include/ast/vmalloc.h315
-rw-r--r--usr/src/lib/libast/i386/include/ast/wait.h107
-rw-r--r--usr/src/lib/libast/i386/include/ast/wchar.h22
-rw-r--r--usr/src/lib/libast/i386/include/ast/wordexp.h74
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/align33
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/botch5
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/ccode29
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/common199
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/dirent106
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/eaccess5
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/errno7
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/fcntl114
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/float213
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/fs158
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/hack5
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/iconv132
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/lib171
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/libpath6
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/limits107
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/map438
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/mmap26
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/mode14
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/nl_types102
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/omitted5
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/param9
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/preroot6
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/sfinit5332
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/sfio14
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/sig131
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/signal175
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/standards28
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/stdio579
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/sys151
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/time83
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/tmlib68
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/tmx128
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/tty134
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/tv111
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/tvlib17
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/types5
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/uwin17
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/vfork67
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/vmalloc36
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/wait11
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/FEATURE/wchar187
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/align.h33
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_botch.h5
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_ccode.h29
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_common.h198
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_dirent.h106
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_fcntl.h114
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_float.h213
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_fs.h158
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_iconv.h132
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_lib.h171
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_limits.h107
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_map.h438
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_mmap.h26
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_mode.h14
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_nl_types.h102
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_param.h9
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_standards.h28
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_stdio.h579
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_sys.h151
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_time.h83
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_tty.h134
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_types.h5
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_vfork.h67
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_wait.h11
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/ast_wchar.h187
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/conftab.c451
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/conftab.h154
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/lc.h158
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/lctab.h2630
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/preroot.h6
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/sig.h131
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/tmx.h128
-rw-r--r--usr/src/lib/libast/i386/src/lib/libast/tv.h111
-rw-r--r--usr/src/lib/libast/mapfile-vers727
-rw-r--r--usr/src/lib/libast/sparc/Makefile47
-rw-r--r--usr/src/lib/libast/sparc/include/ast/align.h54
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast.h381
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_botch.h26
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_ccode.h50
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_common.h219
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_dir.h86
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_dirent.h127
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_fcntl.h135
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_float.h234
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_fs.h175
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_getopt.h51
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_iconv.h153
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_lib.h192
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_limits.h128
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_map.h459
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_mmap.h47
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_mode.h35
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_nl_types.h123
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_param.h30
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_standards.h49
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_std.h343
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_stdio.h600
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_sys.h172
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_time.h104
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_tty.h155
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_types.h26
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_version.h10
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_vfork.h89
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_wait.h32
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_wchar.h208
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ast_windows.h48
-rw-r--r--usr/src/lib/libast/sparc/include/ast/bytesex.h43
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ccode.h101
-rw-r--r--usr/src/lib/libast/sparc/include/ast/cdt.h311
-rw-r--r--usr/src/lib/libast/sparc/include/ast/debug.h63
-rw-r--r--usr/src/lib/libast/sparc/include/ast/dirent.h22
-rw-r--r--usr/src/lib/libast/sparc/include/ast/dt.h49
-rw-r--r--usr/src/lib/libast/sparc/include/ast/endian.h54
-rw-r--r--usr/src/lib/libast/sparc/include/ast/error.h196
-rw-r--r--usr/src/lib/libast/sparc/include/ast/find.h97
-rw-r--r--usr/src/lib/libast/sparc/include/ast/fnmatch.h71
-rw-r--r--usr/src/lib/libast/sparc/include/ast/fnv.h81
-rw-r--r--usr/src/lib/libast/sparc/include/ast/fs3d.h120
-rw-r--r--usr/src/lib/libast/sparc/include/ast/fts.h160
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ftw.h71
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ftwalk.h137
-rw-r--r--usr/src/lib/libast/sparc/include/ast/getopt.h31
-rw-r--r--usr/src/lib/libast/sparc/include/ast/glob.h155
-rw-r--r--usr/src/lib/libast/sparc/include/ast/hash.h213
-rw-r--r--usr/src/lib/libast/sparc/include/ast/hashkey.h73
-rw-r--r--usr/src/lib/libast/sparc/include/ast/hashpart.h60
-rw-r--r--usr/src/lib/libast/sparc/include/ast/iconv.h22
-rw-r--r--usr/src/lib/libast/sparc/include/ast/lc.h158
-rw-r--r--usr/src/lib/libast/sparc/include/ast/ls.h99
-rw-r--r--usr/src/lib/libast/sparc/include/ast/magic.h96
-rw-r--r--usr/src/lib/libast/sparc/include/ast/magicid.h55
-rw-r--r--usr/src/lib/libast/sparc/include/ast/mc.h107
-rw-r--r--usr/src/lib/libast/sparc/include/ast/mime.h102
-rw-r--r--usr/src/lib/libast/sparc/include/ast/mnt.h69
-rw-r--r--usr/src/lib/libast/sparc/include/ast/modecanon.h74
-rw-r--r--usr/src/lib/libast/sparc/include/ast/modex.h62
-rw-r--r--usr/src/lib/libast/sparc/include/ast/namval.h51
-rw-r--r--usr/src/lib/libast/sparc/include/ast/nl_types.h22
-rw-r--r--usr/src/lib/libast/sparc/include/ast/option.h119
-rw-r--r--usr/src/lib/libast/sparc/include/ast/preroot.h27
-rw-r--r--usr/src/lib/libast/sparc/include/ast/proc.h113
-rw-r--r--usr/src/lib/libast/sparc/include/ast/prototyped.h59
-rw-r--r--usr/src/lib/libast/sparc/include/ast/re_comp.h52
-rw-r--r--usr/src/lib/libast/sparc/include/ast/recfmt.h94
-rw-r--r--usr/src/lib/libast/sparc/include/ast/regex.h227
-rw-r--r--usr/src/lib/libast/sparc/include/ast/regexp.h139
-rw-r--r--usr/src/lib/libast/sparc/include/ast/sfdisc.h82
-rw-r--r--usr/src/lib/libast/sparc/include/ast/sfio.h452
-rw-r--r--usr/src/lib/libast/sparc/include/ast/sfio_s.h51
-rw-r--r--usr/src/lib/libast/sparc/include/ast/sfio_t.h126
-rw-r--r--usr/src/lib/libast/sparc/include/ast/sig.h152
-rw-r--r--usr/src/lib/libast/sparc/include/ast/stack.h94
-rw-r--r--usr/src/lib/libast/sparc/include/ast/stak.h64
-rw-r--r--usr/src/lib/libast/sparc/include/ast/stdio.h22
-rw-r--r--usr/src/lib/libast/sparc/include/ast/stk.h91
-rw-r--r--usr/src/lib/libast/sparc/include/ast/swap.h64
-rw-r--r--usr/src/lib/libast/sparc/include/ast/tar.h127
-rw-r--r--usr/src/lib/libast/sparc/include/ast/times.h65
-rw-r--r--usr/src/lib/libast/sparc/include/ast/tm.h205
-rw-r--r--usr/src/lib/libast/sparc/include/ast/tmx.h149
-rw-r--r--usr/src/lib/libast/sparc/include/ast/tok.h58
-rw-r--r--usr/src/lib/libast/sparc/include/ast/tv.h132
-rw-r--r--usr/src/lib/libast/sparc/include/ast/usage.h37
-rw-r--r--usr/src/lib/libast/sparc/include/ast/vdb.h55
-rw-r--r--usr/src/lib/libast/sparc/include/ast/vecargs.h56
-rw-r--r--usr/src/lib/libast/sparc/include/ast/vmalloc.h315
-rw-r--r--usr/src/lib/libast/sparc/include/ast/wait.h107
-rw-r--r--usr/src/lib/libast/sparc/include/ast/wchar.h22
-rw-r--r--usr/src/lib/libast/sparc/include/ast/wordexp.h74
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/align33
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/botch5
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/ccode29
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/common199
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/dirent106
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/eaccess5
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/errno7
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/fcntl114
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/float213
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/fs154
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/hack5
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/iconv132
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/lib171
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/libpath6
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/limits107
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/map438
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/mmap26
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/mode14
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/nl_types102
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/omitted5
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/param9
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/preroot6
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/sfinit5332
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/sfio14
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/sig131
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/signal175
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/standards28
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/stdio579
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/sys151
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/time83
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tmlib68
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tmx128
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tty134
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tv111
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tvlib17
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/types5
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/uwin17
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/vfork68
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/vmalloc36
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/wait11
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/FEATURE/wchar187
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/align.h33
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_botch.h5
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_ccode.h29
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_common.h198
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_dirent.h106
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_fcntl.h114
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_float.h213
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_fs.h154
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_iconv.h132
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_lib.h171
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_limits.h107
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_map.h438
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_mmap.h26
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_mode.h14
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_nl_types.h102
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_param.h9
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_standards.h28
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_stdio.h579
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_sys.h151
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_time.h83
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_tty.h134
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_types.h5
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_vfork.h68
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_wait.h11
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/ast_wchar.h187
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/conftab.c451
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/conftab.h154
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/lc.h158
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/lctab.h2630
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/preroot.h6
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/sig.h131
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/tmx.h128
-rw-r--r--usr/src/lib/libast/sparc/src/lib/libast/tv.h111
-rw-r--r--usr/src/lib/libast/sparcv9/Makefile48
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/align.h54
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast.h381
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_botch.h26
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_ccode.h50
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_common.h220
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_dir.h86
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_dirent.h103
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_fcntl.h135
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_float.h233
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_fs.h174
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_getopt.h51
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_iconv.h153
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_lib.h181
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_limits.h128
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_map.h459
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_mmap.h47
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_mode.h35
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_nl_types.h123
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_param.h30
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_standards.h49
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_std.h343
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_stdio.h600
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_sys.h172
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_time.h104
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_tty.h155
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_types.h26
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_version.h10
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_vfork.h89
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_wait.h32
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_wchar.h208
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ast_windows.h48
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/bytesex.h43
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ccode.h101
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/cdt.h311
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/debug.h63
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/dirent.h22
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/dt.h49
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/endian.h54
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/error.h196
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/find.h97
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/fnmatch.h71
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/fnv.h81
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/fs3d.h120
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/fts.h160
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ftw.h71
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ftwalk.h137
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/getopt.h31
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/glob.h155
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/hash.h213
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/hashkey.h73
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/hashpart.h60
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/iconv.h22
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/lc.h158
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/ls.h99
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/magic.h96
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/magicid.h55
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/mc.h107
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/mime.h102
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/mnt.h69
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/modecanon.h74
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/modex.h62
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/namval.h51
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/nl_types.h22
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/option.h119
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/preroot.h27
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/proc.h113
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/prototyped.h59
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/re_comp.h52
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/recfmt.h94
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/regex.h227
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/regexp.h139
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/sfdisc.h82
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/sfio.h452
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/sfio_s.h51
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/sfio_t.h126
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/sig.h152
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/stack.h94
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/stak.h64
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/stdio.h22
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/stk.h91
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/swap.h64
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/tar.h127
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/times.h65
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/tm.h205
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/tmx.h149
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/tok.h58
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/tv.h132
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/usage.h37
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/vdb.h55
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/vecargs.h56
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/vmalloc.h315
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/wait.h107
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/wchar.h22
-rw-r--r--usr/src/lib/libast/sparcv9/include/ast/wordexp.h74
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/align33
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/botch5
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/ccode29
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/common200
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/dirent82
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/eaccess5
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/errno7
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/fcntl114
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/float212
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/fs153
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/hack5
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/iconv132
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/lib160
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/libpath6
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/limits107
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/map438
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/mmap26
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/mode14
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/nl_types102
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/omitted5
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/param9
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/preroot6
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/sfinit5332
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/sfio16
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/sig131
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/signal175
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/standards28
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/stdio579
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/sys151
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/time83
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tmlib68
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tmx128
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tty134
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tv111
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tvlib17
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/types5
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/uwin17
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/vfork68
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/vmalloc36
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/wait11
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/wchar187
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/align.h33
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_botch.h5
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_ccode.h29
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_common.h199
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_dirent.h82
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_fcntl.h114
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_float.h212
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_fs.h153
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_iconv.h132
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_lib.h160
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_limits.h107
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_map.h438
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_mmap.h26
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_mode.h14
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_nl_types.h102
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_param.h9
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_standards.h28
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_stdio.h579
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_sys.h151
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_time.h83
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_tty.h134
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_types.h5
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_vfork.h68
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_wait.h11
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/ast_wchar.h187
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/conftab.c451
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/conftab.h154
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/lc.h158
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/lctab.h2630
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/preroot.h6
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/sig.h131
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/tmx.h128
-rw-r--r--usr/src/lib/libast/sparcv9/src/lib/libast/tv.h111
-rw-r--r--usr/src/lib/libc/amd64/Makefile5
-rw-r--r--usr/src/lib/libc/i386/Makefile.com5
-rw-r--r--usr/src/lib/libc/port/gen/getusershell.c13
-rw-r--r--usr/src/lib/libc/port/regex/wordexp.c265
-rw-r--r--usr/src/lib/libc/sparc/Makefile5
-rw-r--r--usr/src/lib/libc/sparcv9/Makefile5
-rw-r--r--usr/src/lib/libcmd/Makefile22
-rw-r--r--usr/src/lib/libcmd/Makefile.com105
-rw-r--r--usr/src/lib/libcmd/THIRDPARTYLICENSE245
-rw-r--r--usr/src/lib/libcmd/THIRDPARTYLICENSE.descrip1
-rw-r--r--usr/src/lib/libcmd/amd64/include/ast/cmd.h187
-rw-r--r--usr/src/lib/libcmd/amd64/include/ast/cmdext.h69
-rw-r--r--usr/src/lib/libcmd/amd64/src/lib/libcmd/FEATURE/ids15
-rw-r--r--usr/src/lib/libcmd/amd64/src/lib/libcmd/FEATURE/sockets13
-rw-r--r--usr/src/lib/libcmd/amd64/src/lib/libcmd/FEATURE/symlink8
-rw-r--r--usr/src/lib/libcmd/amd64/src/lib/libcmd/FEATURE/utsname16
-rw-r--r--usr/src/lib/libcmd/common/RELEASE217
-rw-r--r--usr/src/lib/libcmd/common/basename.c116
-rw-r--r--usr/src/lib/libcmd/common/cat.c381
-rw-r--r--usr/src/lib/libcmd/common/chgrp.c454
-rw-r--r--usr/src/lib/libcmd/common/chmod.c296
-rw-r--r--usr/src/lib/libcmd/common/chown.c39
-rw-r--r--usr/src/lib/libcmd/common/cksum.c599
-rw-r--r--usr/src/lib/libcmd/common/cmd.h173
-rw-r--r--usr/src/lib/libcmd/common/cmdinit.c68
-rw-r--r--usr/src/lib/libcmd/common/cmp.c288
-rw-r--r--usr/src/lib/libcmd/common/comm.c201
-rw-r--r--usr/src/lib/libcmd/common/cp.c927
-rw-r--r--usr/src/lib/libcmd/common/cut.c512
-rw-r--r--usr/src/lib/libcmd/common/date.c489
-rw-r--r--usr/src/lib/libcmd/common/dirname.c116
-rw-r--r--usr/src/lib/libcmd/common/expr.c535
-rw-r--r--usr/src/lib/libcmd/common/fds.c168
-rw-r--r--usr/src/lib/libcmd/common/features/ids8
-rw-r--r--usr/src/lib/libcmd/common/features/sockets3
-rw-r--r--usr/src/lib/libcmd/common/features/symlink21
-rw-r--r--usr/src/lib/libcmd/common/features/utsname12
-rw-r--r--usr/src/lib/libcmd/common/fmt.c632
-rw-r--r--usr/src/lib/libcmd/common/fold.c242
-rw-r--r--usr/src/lib/libcmd/common/getconf.c393
-rw-r--r--usr/src/lib/libcmd/common/head.c150
-rw-r--r--usr/src/lib/libcmd/common/id.c468
-rw-r--r--usr/src/lib/libcmd/common/join.c816
-rw-r--r--usr/src/lib/libcmd/common/llib-lcmd68
-rw-r--r--usr/src/lib/libcmd/common/ln.c35
-rw-r--r--usr/src/lib/libcmd/common/logname.c78
-rw-r--r--usr/src/lib/libcmd/common/md5sum.c35
-rw-r--r--usr/src/lib/libcmd/common/mkdir.c152
-rw-r--r--usr/src/lib/libcmd/common/mkfifo.c89
-rw-r--r--usr/src/lib/libcmd/common/mv.c35
-rw-r--r--usr/src/lib/libcmd/common/paste.c247
-rw-r--r--usr/src/lib/libcmd/common/pathchk.c248
-rw-r--r--usr/src/lib/libcmd/common/rev.c128
-rw-r--r--usr/src/lib/libcmd/common/rev.h34
-rw-r--r--usr/src/lib/libcmd/common/revlib.c112
-rw-r--r--usr/src/lib/libcmd/common/rm.c414
-rw-r--r--usr/src/lib/libcmd/common/rmdir.c122
-rw-r--r--usr/src/lib/libcmd/common/stty.c943
-rw-r--r--usr/src/lib/libcmd/common/sum.c35
-rw-r--r--usr/src/lib/libcmd/common/sync.c79
-rw-r--r--usr/src/lib/libcmd/common/tail.c683
-rw-r--r--usr/src/lib/libcmd/common/tee.c181
-rw-r--r--usr/src/lib/libcmd/common/tty.c94
-rw-r--r--usr/src/lib/libcmd/common/uname.c512
-rw-r--r--usr/src/lib/libcmd/common/uniq.c302
-rw-r--r--usr/src/lib/libcmd/common/wc.c186
-rw-r--r--usr/src/lib/libcmd/common/wc.h57
-rw-r--r--usr/src/lib/libcmd/common/wclib.c197
-rw-r--r--usr/src/lib/libcmd/i386/include/ast/cmd.h187
-rw-r--r--usr/src/lib/libcmd/i386/include/ast/cmdext.h69
-rw-r--r--usr/src/lib/libcmd/i386/src/lib/libcmd/FEATURE/ids15
-rw-r--r--usr/src/lib/libcmd/i386/src/lib/libcmd/FEATURE/sockets13
-rw-r--r--usr/src/lib/libcmd/i386/src/lib/libcmd/FEATURE/symlink8
-rw-r--r--usr/src/lib/libcmd/i386/src/lib/libcmd/FEATURE/utsname16
-rw-r--r--usr/src/lib/libcmd/mapfile-vers82
-rw-r--r--usr/src/lib/libcmd/sparc/include/ast/cmd.h187
-rw-r--r--usr/src/lib/libcmd/sparc/include/ast/cmdext.h69
-rw-r--r--usr/src/lib/libcmd/sparc/src/lib/libcmd/FEATURE/ids15
-rw-r--r--usr/src/lib/libcmd/sparc/src/lib/libcmd/FEATURE/sockets13
-rw-r--r--usr/src/lib/libcmd/sparc/src/lib/libcmd/FEATURE/symlink8
-rw-r--r--usr/src/lib/libcmd/sparc/src/lib/libcmd/FEATURE/utsname16
-rw-r--r--usr/src/lib/libcmd/sparcv9/include/ast/cmd.h187
-rw-r--r--usr/src/lib/libcmd/sparcv9/include/ast/cmdext.h69
-rw-r--r--usr/src/lib/libcmd/sparcv9/src/lib/libcmd/FEATURE/ids15
-rw-r--r--usr/src/lib/libcmd/sparcv9/src/lib/libcmd/FEATURE/sockets13
-rw-r--r--usr/src/lib/libcmd/sparcv9/src/lib/libcmd/FEATURE/symlink8
-rw-r--r--usr/src/lib/libcmd/sparcv9/src/lib/libcmd/FEATURE/utsname16
-rw-r--r--usr/src/lib/libdll/Makefile65
-rw-r--r--usr/src/lib/libdll/Makefile.com96
-rw-r--r--usr/src/lib/libdll/THIRDPARTYLICENSE245
-rw-r--r--usr/src/lib/libdll/THIRDPARTYLICENSE.descrip1
-rw-r--r--usr/src/lib/libdll/amd64/Makefile38
-rw-r--r--usr/src/lib/libdll/amd64/src/lib/libdll/FEATURE/dll125
-rw-r--r--usr/src/lib/libdll/amd64/src/lib/libdll/dlldefs.h125
-rw-r--r--usr/src/lib/libdll/common/RELEASE40
-rw-r--r--usr/src/lib/libdll/common/dlfcn.c536
-rw-r--r--usr/src/lib/libdll/common/dllfind.c46
-rw-r--r--usr/src/lib/libdll/common/dlllook.c46
-rw-r--r--usr/src/lib/libdll/common/dllnext.c223
-rw-r--r--usr/src/lib/libdll/common/dllplug.c75
-rw-r--r--usr/src/lib/libdll/common/dllscan.c492
-rw-r--r--usr/src/lib/libdll/common/features/dll235
-rw-r--r--usr/src/lib/libdll/common/llib-ldll45
-rw-r--r--usr/src/lib/libdll/i386/Makefile37
-rw-r--r--usr/src/lib/libdll/i386/src/lib/libdll/FEATURE/dll125
-rw-r--r--usr/src/lib/libdll/i386/src/lib/libdll/dlldefs.h125
-rw-r--r--usr/src/lib/libdll/mapfile-vers42
-rw-r--r--usr/src/lib/libdll/sparc/Makefile37
-rw-r--r--usr/src/lib/libdll/sparc/src/lib/libdll/FEATURE/dll125
-rw-r--r--usr/src/lib/libdll/sparc/src/lib/libdll/dlldefs.h125
-rw-r--r--usr/src/lib/libdll/sparcv9/Makefile38
-rw-r--r--usr/src/lib/libdll/sparcv9/src/lib/libdll/FEATURE/dll125
-rw-r--r--usr/src/lib/libdll/sparcv9/src/lib/libdll/dlldefs.h125
-rw-r--r--usr/src/lib/libpp/Makefile66
-rw-r--r--usr/src/lib/libpp/Makefile.com121
-rw-r--r--usr/src/lib/libpp/THIRDPARTYLICENSE245
-rw-r--r--usr/src/lib/libpp/THIRDPARTYLICENSE.descrip1
-rw-r--r--usr/src/lib/libpp/common/BUGS6
-rw-r--r--usr/src/lib/libpp/common/HISTORY220
-rw-r--r--usr/src/lib/libpp/common/NOTES83
-rw-r--r--usr/src/lib/libpp/common/RELEASE432
-rw-r--r--usr/src/lib/libpp/common/gentab.sh234
-rw-r--r--usr/src/lib/libpp/common/llib-lpp53
-rw-r--r--usr/src/lib/libpp/common/pp.3890
-rw-r--r--usr/src/lib/libpp/common/pp.def282
-rw-r--r--usr/src/lib/libpp/common/pp.h452
-rw-r--r--usr/src/lib/libpp/common/pp.key117
-rw-r--r--usr/src/lib/libpp/common/pp.probe1210
-rw-r--r--usr/src/lib/libpp/common/pp.tab233
-rw-r--r--usr/src/lib/libpp/common/ppargs.c603
-rw-r--r--usr/src/lib/libpp/common/ppbuiltin.c397
-rw-r--r--usr/src/lib/libpp/common/ppcall.c452
-rw-r--r--usr/src/lib/libpp/common/ppcomment.c35
-rw-r--r--usr/src/lib/libpp/common/ppcontext.c65
-rw-r--r--usr/src/lib/libpp/common/ppcontrol.c2295
-rw-r--r--usr/src/lib/libpp/common/ppcpp.c30
-rw-r--r--usr/src/lib/libpp/common/ppdata.c179
-rw-r--r--usr/src/lib/libpp/common/pperror.c38
-rw-r--r--usr/src/lib/libpp/common/ppexpr.c697
-rw-r--r--usr/src/lib/libpp/common/ppfsm.c946
-rw-r--r--usr/src/lib/libpp/common/ppfsm.h278
-rw-r--r--usr/src/lib/libpp/common/ppincref.c49
-rw-r--r--usr/src/lib/libpp/common/ppinput.c721
-rw-r--r--usr/src/lib/libpp/common/ppkey.c118
-rw-r--r--usr/src/lib/libpp/common/ppkey.h146
-rw-r--r--usr/src/lib/libpp/common/pplex.c2441
-rw-r--r--usr/src/lib/libpp/common/pplib.h863
-rw-r--r--usr/src/lib/libpp/common/ppline.c86
-rw-r--r--usr/src/lib/libpp/common/ppmacref.c58
-rw-r--r--usr/src/lib/libpp/common/ppmisc.c242
-rw-r--r--usr/src/lib/libpp/common/ppop.c1553
-rw-r--r--usr/src/lib/libpp/common/pppragma.c66
-rw-r--r--usr/src/lib/libpp/common/ppprintf.c45
-rw-r--r--usr/src/lib/libpp/common/ppproto.c2549
-rw-r--r--usr/src/lib/libpp/common/ppsearch.c807
-rw-r--r--usr/src/lib/libpp/common/ppsym.c94
-rw-r--r--usr/src/lib/libpp/common/pptrace.c264
-rw-r--r--usr/src/lib/libpp/i386/Makefile30
-rw-r--r--usr/src/lib/libpp/i386/pp.req2
-rw-r--r--usr/src/lib/libpp/i386/pp.yacc1
-rw-r--r--usr/src/lib/libpp/i386/ppdebug.h211
-rw-r--r--usr/src/lib/libpp/i386/ppdef.h220
-rw-r--r--usr/src/lib/libpp/i386/pptab.h152
-rw-r--r--usr/src/lib/libpp/mapfile-vers39
-rw-r--r--usr/src/lib/libpp/sparc/Makefile30
-rw-r--r--usr/src/lib/libpp/sparc/pp.req2
-rw-r--r--usr/src/lib/libpp/sparc/pp.yacc1
-rw-r--r--usr/src/lib/libpp/sparc/ppdebug.h211
-rw-r--r--usr/src/lib/libpp/sparc/ppdef.h220
-rw-r--r--usr/src/lib/libpp/sparc/pptab.h152
-rw-r--r--usr/src/lib/libshell/Makefile70
-rw-r--r--usr/src/lib/libshell/Makefile.com168
-rw-r--r--usr/src/lib/libshell/Makefile.demo74
-rw-r--r--usr/src/lib/libshell/THIRDPARTYLICENSE245
-rw-r--r--usr/src/lib/libshell/THIRDPARTYLICENSE.descrip1
-rw-r--r--usr/src/lib/libshell/amd64/Makefile31
-rw-r--r--usr/src/lib/libshell/amd64/include/ast/history.h84
-rw-r--r--usr/src/lib/libshell/amd64/include/ast/nval.h317
-rw-r--r--usr/src/lib/libshell/amd64/include/ast/shell.h256
-rw-r--r--usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/acct12
-rw-r--r--usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/cmds36
-rw-r--r--usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/dynamic23
-rw-r--r--usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/execargs10
-rw-r--r--usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/externs81
-rw-r--r--usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/locale38
-rw-r--r--usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/math162
-rw-r--r--usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/options23
-rw-r--r--usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/poll119
-rw-r--r--usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/pstat10
-rw-r--r--usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/rlimits19
-rw-r--r--usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/setjmp35
-rw-r--r--usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/sigfeatures54
-rw-r--r--usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/time28
-rw-r--r--usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/ttys19
-rw-r--r--usr/src/lib/libshell/common/COMPATIBILITY129
-rw-r--r--usr/src/lib/libshell/common/DESIGN163
-rw-r--r--usr/src/lib/libshell/common/OBSOLETE152
-rw-r--r--usr/src/lib/libshell/common/PROMO.mm141
-rw-r--r--usr/src/lib/libshell/common/README227
-rw-r--r--usr/src/lib/libshell/common/RELEASE1455
-rw-r--r--usr/src/lib/libshell/common/RELEASE88422
-rw-r--r--usr/src/lib/libshell/common/RELEASE93455
-rw-r--r--usr/src/lib/libshell/common/bltins/alarm.c276
-rw-r--r--usr/src/lib/libshell/common/bltins/cd_pwd.c280
-rw-r--r--usr/src/lib/libshell/common/bltins/cflow.c118
-rw-r--r--usr/src/lib/libshell/common/bltins/getopts.c185
-rw-r--r--usr/src/lib/libshell/common/bltins/hist.c309
-rw-r--r--usr/src/lib/libshell/common/bltins/misc.c589
-rw-r--r--usr/src/lib/libshell/common/bltins/mkservice.c494
-rw-r--r--usr/src/lib/libshell/common/bltins/print.c897
-rw-r--r--usr/src/lib/libshell/common/bltins/read.c590
-rw-r--r--usr/src/lib/libshell/common/bltins/shiocmd_solaris.c1180
-rw-r--r--usr/src/lib/libshell/common/bltins/shopen.c533
-rw-r--r--usr/src/lib/libshell/common/bltins/sleep.c190
-rw-r--r--usr/src/lib/libshell/common/bltins/test.c629
-rw-r--r--usr/src/lib/libshell/common/bltins/trap.c347
-rw-r--r--usr/src/lib/libshell/common/bltins/typeset.c979
-rw-r--r--usr/src/lib/libshell/common/bltins/ulimit.c211
-rw-r--r--usr/src/lib/libshell/common/bltins/umask.c98
-rw-r--r--usr/src/lib/libshell/common/bltins/whence.c273
-rw-r--r--usr/src/lib/libshell/common/builtins.mm631
-rw-r--r--usr/src/lib/libshell/common/data/aliases.c58
-rw-r--r--usr/src/lib/libshell/common/data/bash_pre_rc.sh221
-rw-r--r--usr/src/lib/libshell/common/data/builtins.c1833
-rw-r--r--usr/src/lib/libshell/common/data/keywords.c63
-rw-r--r--usr/src/lib/libshell/common/data/lexstates.c411
-rw-r--r--usr/src/lib/libshell/common/data/limits.c57
-rw-r--r--usr/src/lib/libshell/common/data/math.tab64
-rw-r--r--usr/src/lib/libshell/common/data/msg.c188
-rw-r--r--usr/src/lib/libshell/common/data/options.c140
-rw-r--r--usr/src/lib/libshell/common/data/signals.c227
-rw-r--r--usr/src/lib/libshell/common/data/solaris_cmdlist.h128
-rw-r--r--usr/src/lib/libshell/common/data/strdata.c104
-rw-r--r--usr/src/lib/libshell/common/data/testops.c168
-rw-r--r--usr/src/lib/libshell/common/data/variables.c105
-rw-r--r--usr/src/lib/libshell/common/edit/completion.c522
-rw-r--r--usr/src/lib/libshell/common/edit/edit.c1489
-rw-r--r--usr/src/lib/libshell/common/edit/emacs.c1444
-rw-r--r--usr/src/lib/libshell/common/edit/hexpand.c736
-rw-r--r--usr/src/lib/libshell/common/edit/history.c1109
-rw-r--r--usr/src/lib/libshell/common/edit/vi.c2635
-rw-r--r--usr/src/lib/libshell/common/features/cmds1
-rw-r--r--usr/src/lib/libshell/common/features/dynamic12
-rw-r--r--usr/src/lib/libshell/common/features/externs12
-rw-r--r--usr/src/lib/libshell/common/features/locale25
-rw-r--r--usr/src/lib/libshell/common/features/math4
-rw-r--r--usr/src/lib/libshell/common/features/math.sh158
-rw-r--r--usr/src/lib/libshell/common/features/options46
-rw-r--r--usr/src/lib/libshell/common/features/poll149
-rw-r--r--usr/src/lib/libshell/common/features/rlimits3
-rw-r--r--usr/src/lib/libshell/common/features/setjmp18
-rw-r--r--usr/src/lib/libshell/common/features/sigfeatures49
-rw-r--r--usr/src/lib/libshell/common/features/time35
-rw-r--r--usr/src/lib/libshell/common/features/ttys3
-rw-r--r--usr/src/lib/libshell/common/fun/dirs108
-rw-r--r--usr/src/lib/libshell/common/fun/gnaw1029
-rw-r--r--usr/src/lib/libshell/common/fun/mandelbrotset1234
-rw-r--r--usr/src/lib/libshell/common/fun/popd111
-rw-r--r--usr/src/lib/libshell/common/fun/pushd111
-rw-r--r--usr/src/lib/libshell/common/fun/rssread414
-rw-r--r--usr/src/lib/libshell/common/fun/termclock267
-rw-r--r--usr/src/lib/libshell/common/fun/title57
-rw-r--r--usr/src/lib/libshell/common/include/argnod.h147
-rw-r--r--usr/src/lib/libshell/common/include/builtins.h200
-rw-r--r--usr/src/lib/libshell/common/include/defs.h377
-rw-r--r--usr/src/lib/libshell/common/include/edit.h257
-rw-r--r--usr/src/lib/libshell/common/include/env.h50
-rw-r--r--usr/src/lib/libshell/common/include/fault.h124
-rw-r--r--usr/src/lib/libshell/common/include/fcin.h62
-rw-r--r--usr/src/lib/libshell/common/include/history.h75
-rw-r--r--usr/src/lib/libshell/common/include/io.h123
-rw-r--r--usr/src/lib/libshell/common/include/jobs.h159
-rw-r--r--usr/src/lib/libshell/common/include/lexstates.h151
-rw-r--r--usr/src/lib/libshell/common/include/name.h208
-rw-r--r--usr/src/lib/libshell/common/include/national.h37
-rw-r--r--usr/src/lib/libshell/common/include/nval.h305
-rw-r--r--usr/src/lib/libshell/common/include/path.h140
-rw-r--r--usr/src/lib/libshell/common/include/shell.h245
-rw-r--r--usr/src/lib/libshell/common/include/shlex.h152
-rw-r--r--usr/src/lib/libshell/common/include/shnodes.h222
-rw-r--r--usr/src/lib/libshell/common/include/shtable.h65
-rw-r--r--usr/src/lib/libshell/common/include/streval.h195
-rw-r--r--usr/src/lib/libshell/common/include/terminal.h195
-rw-r--r--usr/src/lib/libshell/common/include/test.h71
-rw-r--r--usr/src/lib/libshell/common/include/timeout.h30
-rw-r--r--usr/src/lib/libshell/common/include/ulimit.h175
-rw-r--r--usr/src/lib/libshell/common/include/variables.h104
-rw-r--r--usr/src/lib/libshell/common/include/version.h20
-rw-r--r--usr/src/lib/libshell/common/llib-lshell138
-rw-r--r--usr/src/lib/libshell/common/nval.3619
-rw-r--r--usr/src/lib/libshell/common/sh.17453
-rw-r--r--usr/src/lib/libshell/common/sh.memo3248
-rw-r--r--usr/src/lib/libshell/common/sh/args.c846
-rw-r--r--usr/src/lib/libshell/common/sh/arith.c363
-rw-r--r--usr/src/lib/libshell/common/sh/array.c865
-rw-r--r--usr/src/lib/libshell/common/sh/bash.c430
-rw-r--r--usr/src/lib/libshell/common/sh/defs.c47
-rw-r--r--usr/src/lib/libshell/common/sh/deparse.c584
-rw-r--r--usr/src/lib/libshell/common/sh/env.c255
-rw-r--r--usr/src/lib/libshell/common/sh/expand.c465
-rw-r--r--usr/src/lib/libshell/common/sh/fault.c573
-rw-r--r--usr/src/lib/libshell/common/sh/fcin.c211
-rw-r--r--usr/src/lib/libshell/common/sh/init.c1465
-rw-r--r--usr/src/lib/libshell/common/sh/io.c2215
-rw-r--r--usr/src/lib/libshell/common/sh/jobs.c1706
-rw-r--r--usr/src/lib/libshell/common/sh/lex.c2276
-rw-r--r--usr/src/lib/libshell/common/sh/macro.c2301
-rw-r--r--usr/src/lib/libshell/common/sh/main.c769
-rw-r--r--usr/src/lib/libshell/common/sh/name.c2382
-rw-r--r--usr/src/lib/libshell/common/sh/nvdisc.c1263
-rw-r--r--usr/src/lib/libshell/common/sh/nvtree.c679
-rw-r--r--usr/src/lib/libshell/common/sh/parse.c1757
-rw-r--r--usr/src/lib/libshell/common/sh/path.c1697
-rw-r--r--usr/src/lib/libshell/common/sh/pmain.c30
-rw-r--r--usr/src/lib/libshell/common/sh/shcomp.c172
-rw-r--r--usr/src/lib/libshell/common/sh/streval.c904
-rw-r--r--usr/src/lib/libshell/common/sh/string.c704
-rw-r--r--usr/src/lib/libshell/common/sh/subshell.c555
-rw-r--r--usr/src/lib/libshell/common/sh/suid_exec.c509
-rw-r--r--usr/src/lib/libshell/common/sh/tdump.c260
-rw-r--r--usr/src/lib/libshell/common/sh/timers.c248
-rw-r--r--usr/src/lib/libshell/common/sh/trestore.c342
-rw-r--r--usr/src/lib/libshell/common/sh/waitevent.c54
-rw-r--r--usr/src/lib/libshell/common/sh/xec.c2947
-rw-r--r--usr/src/lib/libshell/common/shell.3408
-rw-r--r--usr/src/lib/libshell/common/tests/alias.sh83
-rw-r--r--usr/src/lib/libshell/common/tests/append.sh72
-rw-r--r--usr/src/lib/libshell/common/tests/arith.sh466
-rw-r--r--usr/src/lib/libshell/common/tests/arrays.sh381
-rw-r--r--usr/src/lib/libshell/common/tests/attributes.sh216
-rw-r--r--usr/src/lib/libshell/common/tests/basic.sh336
-rw-r--r--usr/src/lib/libshell/common/tests/bracket.sh233
-rw-r--r--usr/src/lib/libshell/common/tests/builtins.sh451
-rw-r--r--usr/src/lib/libshell/common/tests/case.sh81
-rw-r--r--usr/src/lib/libshell/common/tests/comvar.sh197
-rw-r--r--usr/src/lib/libshell/common/tests/coprocess.sh218
-rw-r--r--usr/src/lib/libshell/common/tests/exit.sh81
-rw-r--r--usr/src/lib/libshell/common/tests/expand.sh123
-rw-r--r--usr/src/lib/libshell/common/tests/functions.sh758
-rw-r--r--usr/src/lib/libshell/common/tests/glob.sh303
-rw-r--r--usr/src/lib/libshell/common/tests/grep.sh102
-rw-r--r--usr/src/lib/libshell/common/tests/heredoc.sh213
-rw-r--r--usr/src/lib/libshell/common/tests/io.sh251
-rw-r--r--usr/src/lib/libshell/common/tests/nameref.sh229
-rw-r--r--usr/src/lib/libshell/common/tests/options.sh313
-rw-r--r--usr/src/lib/libshell/common/tests/path.sh186
-rw-r--r--usr/src/lib/libshell/common/tests/quoting.sh331
-rw-r--r--usr/src/lib/libshell/common/tests/quoting2.sh200
-rw-r--r--usr/src/lib/libshell/common/tests/return.sh177
-rw-r--r--usr/src/lib/libshell/common/tests/select.sh63
-rw-r--r--usr/src/lib/libshell/common/tests/shtests63
-rw-r--r--usr/src/lib/libshell/common/tests/substring.sh504
-rw-r--r--usr/src/lib/libshell/common/tests/sun_solaris_getconf.sh160
-rw-r--r--usr/src/lib/libshell/common/tests/tilde.sh87
-rw-r--r--usr/src/lib/libshell/common/tests/variables.sh558
-rw-r--r--usr/src/lib/libshell/i386/Makefile30
-rw-r--r--usr/src/lib/libshell/i386/include/ast/history.h84
-rw-r--r--usr/src/lib/libshell/i386/include/ast/nval.h317
-rw-r--r--usr/src/lib/libshell/i386/include/ast/shell.h256
-rw-r--r--usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/acct12
-rw-r--r--usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/cmds36
-rw-r--r--usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/dynamic23
-rw-r--r--usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/execargs10
-rw-r--r--usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/externs81
-rw-r--r--usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/locale38
-rw-r--r--usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/math162
-rw-r--r--usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/options23
-rw-r--r--usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/poll119
-rw-r--r--usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/pstat10
-rw-r--r--usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/rlimits19
-rw-r--r--usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/setjmp35
-rw-r--r--usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/sigfeatures54
-rw-r--r--usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/time28
-rw-r--r--usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/ttys19
-rw-r--r--usr/src/lib/libshell/mapfile-vers170
-rw-r--r--usr/src/lib/libshell/misc/ERRATA.txt327
-rw-r--r--usr/src/lib/libshell/misc/buildksh93.ksh373
-rw-r--r--usr/src/lib/libshell/misc/buildksh93.readme74
-rw-r--r--usr/src/lib/libshell/misc/filelist.txt91
-rw-r--r--usr/src/lib/libshell/sparc/Makefile30
-rw-r--r--usr/src/lib/libshell/sparc/include/ast/history.h84
-rw-r--r--usr/src/lib/libshell/sparc/include/ast/nval.h317
-rw-r--r--usr/src/lib/libshell/sparc/include/ast/shell.h256
-rw-r--r--usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/acct12
-rw-r--r--usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/cmds36
-rw-r--r--usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/dynamic23
-rw-r--r--usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/execargs10
-rw-r--r--usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/externs81
-rw-r--r--usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/locale38
-rw-r--r--usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/math162
-rw-r--r--usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/options26
-rw-r--r--usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/poll119
-rw-r--r--usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/pstat10
-rw-r--r--usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/rlimits19
-rw-r--r--usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/setjmp35
-rw-r--r--usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/sigfeatures54
-rw-r--r--usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/time28
-rw-r--r--usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/ttys19
-rw-r--r--usr/src/lib/libshell/sparcv9/Makefile31
-rw-r--r--usr/src/lib/libshell/sparcv9/include/ast/history.h84
-rw-r--r--usr/src/lib/libshell/sparcv9/include/ast/nval.h317
-rw-r--r--usr/src/lib/libshell/sparcv9/include/ast/shell.h256
-rw-r--r--usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/acct12
-rw-r--r--usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/cmds36
-rw-r--r--usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/dynamic23
-rw-r--r--usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/execargs10
-rw-r--r--usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/externs81
-rw-r--r--usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/locale38
-rw-r--r--usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/math162
-rw-r--r--usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/options26
-rw-r--r--usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/poll119
-rw-r--r--usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/pstat10
-rw-r--r--usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/rlimits19
-rw-r--r--usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/setjmp35
-rw-r--r--usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/sigfeatures54
-rw-r--r--usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/time28
-rw-r--r--usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/ttys19
-rw-r--r--usr/src/pkgdefs/Makefile3
-rw-r--r--usr/src/pkgdefs/SUNW0on/prototype_com10
-rw-r--r--usr/src/pkgdefs/SUNWarc/prototype_com2
-rw-r--r--usr/src/pkgdefs/SUNWarc/prototype_i3861
-rw-r--r--usr/src/pkgdefs/SUNWarc/prototype_sparc1
-rw-r--r--usr/src/pkgdefs/SUNWastdev/Makefile37
-rw-r--r--usr/src/pkgdefs/SUNWastdev/pkginfo.tmpl58
-rw-r--r--usr/src/pkgdefs/SUNWastdev/prototype_com59
-rw-r--r--usr/src/pkgdefs/SUNWastdev/prototype_i38650
-rw-r--r--usr/src/pkgdefs/SUNWastdev/prototype_sparc50
-rw-r--r--usr/src/pkgdefs/SUNWcsl/prototype_com3
-rw-r--r--usr/src/pkgdefs/SUNWcsl/prototype_i3863
-rw-r--r--usr/src/pkgdefs/SUNWcsl/prototype_sparc3
-rw-r--r--usr/src/pkgdefs/SUNWcsr/prototype_com1
-rw-r--r--usr/src/pkgdefs/SUNWcsu/prototype_com2
-rw-r--r--usr/src/pkgdefs/SUNWcsu/prototype_i3866
-rw-r--r--usr/src/pkgdefs/SUNWcsu/prototype_sparc4
-rw-r--r--usr/src/pkgdefs/SUNWhea/prototype_com101
-rw-r--r--usr/src/pkgdefs/SUNWosdem/prototype_com48
-rw-r--r--usr/src/pkgdefs/etc/exception_list_i38630
-rw-r--r--usr/src/pkgdefs/etc/exception_list_sparc30
-rw-r--r--usr/src/tools/findunref/exception_list59
-rw-r--r--usr/src/tools/opensolaris/license-list6
-rw-r--r--usr/src/tools/scripts/bfu.sh1
1915 files changed, 379824 insertions, 74 deletions
diff --git a/usr/src/lib/libcmd/common/mapfile-vers b/deleted_files/usr/src/lib/libcmd/common/mapfile-vers
index 891b6fd3a2..891b6fd3a2 100644
--- a/usr/src/lib/libcmd/common/mapfile-vers
+++ b/deleted_files/usr/src/lib/libcmd/common/mapfile-vers
diff --git a/usr/src/lib/libcmd/common/placeholder.c b/deleted_files/usr/src/lib/libcmd/common/placeholder.c
index f4b2bc015c..f4b2bc015c 100644
--- a/usr/src/lib/libcmd/common/placeholder.c
+++ b/deleted_files/usr/src/lib/libcmd/common/placeholder.c
diff --git a/usr/src/Makefile.ast b/usr/src/Makefile.ast
new file mode 100644
index 0000000000..aaef8f8442
--- /dev/null
+++ b/usr/src/Makefile.ast
@@ -0,0 +1,67 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+# Override this top level flag so the compiler builds in its native
+# C99 mode. This has been enabled to support the math stuff in the
+# AST tools (including ksh93).
+C99MODE= $(C99_ENABLE) -D_XOPEN_SOURCE=600 -D__EXTENSIONS__=1
+
+# silence common AST&co. warnings...
+# ... about |#pragma prototyped| ...
+CERRWARN += -erroff=E_UNRECOGNIZED_PRAGMA_IGNORED
+
+# common CPP flags for libshell consumers (ksh etc.)
+LIBSHELLCPPFLAGS = \
+ -I$(ROOT)/usr/include/ast \
+ -DKSHELL \
+ -DSHOPT_BRACEPAT \
+ -DSHOPT_CMDLIB_BLTIN=0 \
+ '-DSH_CMDLIB_DIR="/usr/ast/bin"' \
+ '-DSHOPT_CMDLIB_HDR="solaris_cmdlist.h"' \
+ -DSHOPT_DYNAMIC \
+ -DSHOPT_ESH \
+ -DSHOPT_FILESCAN \
+ -DSHOPT_HISTEXPAND \
+ -DSHOPT_KIA \
+ -DSHOPT_MULTIBYTE \
+ -DSHOPT_NAMESPACE \
+ -DSHOPT_OPTIMIZE \
+ -DSHOPT_PFSH \
+ -DSHOPT_RAWONLY \
+ -DSHOPT_SUID_EXEC \
+ -DSHOPT_SYSRC \
+ -DSHOPT_VSH \
+ -D_BLD_shell \
+ -D_PACKAGE_ast \
+ -DERROR_CONTEXT_T=Error_context_t \
+ '-DUSAGE_LICENSE=\
+ "[-author?David Korn <dgk@research.att.com>]"\
+ "[-copyright?Copyright (c) 1982-2007 AT&T Knowledge Ventures]"\
+ "[-license?http://www.opensource.org/licenses/cpl1.0.txt]"\
+ "[--catalog?libshell]"'
+
+
diff --git a/usr/src/Makefile.ksh93switch b/usr/src/Makefile.ksh93switch
new file mode 100644
index 0000000000..071e225170
--- /dev/null
+++ b/usr/src/Makefile.ksh93switch
@@ -0,0 +1,36 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+# Should we build ksh93 as /bin/ksh ?
+# This can be overridden at build time via:
+# $ export ON_BUILD_KSH93_AS_BINKSH=1
+ON_BUILD_KSH93_AS_BINKSH=0
+
+BINKSH_IS_KSH93_1= $(ON_BUILD_KSH93_AS_BINKSH:0=$(POUND_SIGN))
+BINKSH_ISNOT_KSH93_1=$(ON_BUILD_KSH93_AS_BINKSH:1=$(POUND_SIGN))
+BINKSH_IS_KSH93= $(BINKSH_IS_KSH93_1:1=)
+BINKSH_ISNOT_KSH93= $(BINKSH_ISNOT_KSH93_1:0=)
diff --git a/usr/src/Makefile.lint b/usr/src/Makefile.lint
index d48d3c4f53..5a7070d237 100644
--- a/usr/src/Makefile.lint
+++ b/usr/src/Makefile.lint
@@ -307,7 +307,6 @@ COMMON_SUBDIRS = \
lib/libc \
lib/libc_db \
lib/libcfgadm \
- lib/libcmd \
lib/libcmdutils \
lib/libcontract \
lib/libcryptoutil \
diff --git a/usr/src/Targetdirs b/usr/src/Targetdirs
index a4c42a1f1e..20bf086e12 100644
--- a/usr/src/Targetdirs
+++ b/usr/src/Targetdirs
@@ -219,6 +219,8 @@ ROOT.BIN= \
/lib/svc/seed \
/lib/svc/share \
/usr/4lib \
+ /usr/ast \
+ /usr/ast/bin \
/usr/bin \
/usr/bin/$(MACH32) \
/usr/ccs \
@@ -229,6 +231,7 @@ ROOT.BIN= \
/usr/games \
/usr/include \
/usr/kvm \
+ /usr/include/ast \
/usr/include/sys/crypto \
/usr/include/fm \
/usr/include/gssapi \
diff --git a/usr/src/cmd/Makefile b/usr/src/cmd/Makefile
index 52ba9b89e0..14950a9cb5 100644
--- a/usr/src/cmd/Makefile
+++ b/usr/src/cmd/Makefile
@@ -27,6 +27,7 @@
# ident "%Z%%M% %I% %E% SMI"
include ../Makefile.master
+include ../Makefile.ksh93switch
#
# Note that the commands 'agents', 'lp', 'perl', and 'man' are first in
@@ -61,6 +62,7 @@ COMMON_SUBDIRS= \
acctadm \
arch \
asa \
+ ast \
audio \
auths \
autopush \
@@ -210,6 +212,7 @@ COMMON_SUBDIRS= \
keyserv \
killall \
krb5 \
+ ksh \
kstat \
last \
lastcomm \
@@ -574,6 +577,7 @@ MSGSUBDIRS= \
join \
kbd \
krb5 \
+ ksh \
kstat \
last \
ldap \
diff --git a/usr/src/cmd/ast/Makefile b/usr/src/cmd/ast/Makefile
new file mode 100644
index 0000000000..c2259a2191
--- /dev/null
+++ b/usr/src/cmd/ast/Makefile
@@ -0,0 +1,50 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+SHELL=/usr/bin/ksh
+
+include ../Makefile.cmd
+
+SUBDIRS= \
+ msgcc
+
+all := TARGET = all
+install := TARGET = install
+clean := TARGET = clean
+clobber := TARGET = clobber
+lint := TARGET = lint
+
+.KEEP_STATE:
+
+all install clean clobber lint: $(SUBDIRS)
+
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
+
+include ../Makefile.targ
diff --git a/usr/src/cmd/ast/THIRDPARTYLICENSE b/usr/src/cmd/ast/THIRDPARTYLICENSE
new file mode 100644
index 0000000000..50c6364c06
--- /dev/null
+++ b/usr/src/cmd/ast/THIRDPARTYLICENSE
@@ -0,0 +1,245 @@
++------------------------------------------------------------------------------+
+| This license covers all software that refers to the URL |
+| http://www.opensource.org/licenses/cpl1.0.txt |
++------------------------------------------------------------------------------+
+
+Common Public License Version 1.0
+
+ THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON
+ PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF
+ THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+ 1. DEFINITIONS
+
+ "Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and
+ documentation distributed under this Agreement, and
+
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from
+ and are distributed by that particular Contributor. A Contribution
+ 'originates' from a Contributor if it was added to the Program by
+ such Contributor itself or anyone acting on such Contributor's
+ behalf. Contributions do not include additions to the Program
+ which: (i) are separate modules of software distributed in
+ conjunction with the Program under their own license agreement, and
+ (ii) are not derivative works of the Program.
+
+ "Contributor" means any person or entity that distributes the Program.
+
+ "Licensed Patents " mean patent claims licensable by a Contributor
+ which are necessarily infringed by the use or sale of its Contribution
+ alone or when combined with the Program.
+
+ "Program" means the Contributions distributed in accordance with this
+ Agreement.
+
+ "Recipient" means anyone who receives the Program under this
+ Agreement, including all Contributors.
+
+ 2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free copyright
+ license to reproduce, prepare derivative works of, publicly
+ display, publicly perform, distribute and sublicense the
+ Contribution of such Contributor, if any, and such derivative
+ works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free patent
+ license under Licensed Patents to make, use, sell, offer to sell,
+ import and otherwise transfer the Contribution of such Contributor,
+ if any, in source code and object code form. This patent license
+ shall apply to the combination of the Contribution and the Program
+ if, at the time the Contribution is added by the Contributor, such
+ addition of the Contribution causes such combination to be covered
+ by the Licensed Patents. The patent license shall not apply to any
+ other combinations which include the Contribution. No hardware per
+ se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the
+ licenses to its Contributions set forth herein, no assurances are
+ provided by any Contributor that the Program does not infringe the
+ patent or other intellectual property rights of any other entity.
+ Each Contributor disclaims any liability to Recipient for claims
+ brought by any other entity based on infringement of intellectual
+ property rights or otherwise. As a condition to exercising the
+ rights and licenses granted hereunder, each Recipient hereby
+ assumes sole responsibility to secure any other intellectual
+ property rights needed, if any. For example, if a third party
+ patent license is required to allow Recipient to distribute the
+ Program, it is Recipient's responsibility to acquire that license
+ before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has
+ sufficient copyright rights in its Contribution, if any, to grant
+ the copyright license set forth in this Agreement.
+
+ 3. REQUIREMENTS
+
+ A Contributor may choose to distribute the Program in object code form
+ under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all
+ warranties and conditions, express and implied, including
+ warranties or conditions of title and non-infringement, and implied
+ warranties or conditions of merchantability and fitness for a
+ particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all
+ liability for damages, including direct, indirect, special,
+ incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement
+ are offered by that Contributor alone and not by any other party;
+ and
+
+ iv) states that source code for the Program is available from such
+ Contributor, and informs licensees how to obtain it in a reasonable
+ manner on or through a medium customarily used for software
+ exchange.
+
+ When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the
+ Program.
+
+ Contributors may not remove or alter any copyright notices contained
+ within the Program.
+
+ Each Contributor must identify itself as the originator of its
+ Contribution, if any, in a manner that reasonably allows subsequent
+ Recipients to identify the originator of the Contribution.
+
+ 4. COMMERCIAL DISTRIBUTION
+
+ Commercial distributors of software may accept certain
+ responsibilities with respect to end users, business partners and the
+ like. While this license is intended to facilitate the commercial use
+ of the Program, the Contributor who includes the Program in a
+ commercial product offering should do so in a manner which does not
+ create potential liability for other Contributors. Therefore, if a
+ Contributor includes the Program in a commercial product offering,
+ such Contributor ("Commercial Contributor") hereby agrees to defend
+ and indemnify every other Contributor ("Indemnified Contributor")
+ against any losses, damages and costs (collectively "Losses") arising
+ from claims, lawsuits and other legal actions brought by a third party
+ against the Indemnified Contributor to the extent caused by the acts
+ or omissions of such Commercial Contributor in connection with its
+ distribution of the Program in a commercial product offering. The
+ obligations in this section do not apply to any claims or Losses
+ relating to any actual or alleged intellectual property infringement.
+ In order to qualify, an Indemnified Contributor must: a) promptly
+ notify the Commercial Contributor in writing of such claim, and b)
+ allow the Commercial Contributor to control, and cooperate with the
+ Commercial Contributor in, the defense and any related settlement
+ negotiations. The Indemnified Contributor may participate in any such
+ claim at its own expense.
+
+ For example, a Contributor might include the Program in a commercial
+ product offering, Product X. That Contributor is then a Commercial
+ Contributor. If that Commercial Contributor then makes performance
+ claims, or offers warranties related to Product X, those performance
+ claims and warranties are such Commercial Contributor's responsibility
+ alone. Under this section, the Commercial Contributor would have to
+ defend claims against the other Contributors related to those
+ performance claims and warranties, and if a court requires any other
+ Contributor to pay any damages as a result, the Commercial Contributor
+ must pay those damages.
+
+ 5. NO WARRANTY
+
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+ PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
+ WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
+ OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+ responsible for determining the appropriateness of using and
+ distributing the Program and assumes all risks associated with its
+ exercise of rights under this Agreement, including but not limited to
+ the risks and costs of program errors, compliance with applicable
+ laws, damage to or loss of data, programs or equipment, and
+ unavailability or interruption of operations.
+
+ 6. DISCLAIMER OF LIABILITY
+
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
+ ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+ WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+ DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+ 7. GENERAL
+
+ If any provision of this Agreement is invalid or unenforceable under
+ applicable law, it shall not affect the validity or enforceability of
+ the remainder of the terms of this Agreement, and without further
+ action by the parties hereto, such provision shall be reformed to the
+ minimum extent necessary to make such provision valid and enforceable.
+
+ If Recipient institutes patent litigation against a Contributor with
+ respect to a patent applicable to software (including a cross-claim or
+ counterclaim in a lawsuit), then any patent licenses granted by that
+ Contributor to such Recipient under this Agreement shall terminate as
+ of the date such litigation is filed. In addition, if Recipient
+ institutes patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Program
+ itself (excluding combinations of the Program with other software or
+ hardware) infringes such Recipient's patent(s), then such Recipient's
+ rights granted under Section 2(b) shall terminate as of the date such
+ litigation is filed.
+
+ All Recipient's rights under this Agreement shall terminate if it
+ fails to comply with any of the material terms or conditions of this
+ Agreement and does not cure such failure in a reasonable period of
+ time after becoming aware of such noncompliance. If all Recipient's
+ rights under this Agreement terminate, Recipient agrees to cease use
+ and distribution of the Program as soon as reasonably practicable.
+ However, Recipient's obligations under this Agreement and any licenses
+ granted by Recipient relating to the Program shall continue and
+ survive.
+
+ Everyone is permitted to copy and distribute copies of this Agreement,
+ but in order to avoid inconsistency the Agreement is copyrighted and
+ may only be modified in the following manner. The Agreement Steward
+ reserves the right to publish new versions (including revisions) of
+ this Agreement from time to time. No one other than the Agreement
+ Steward has the right to modify this Agreement. IBM is the initial
+ Agreement Steward. IBM may assign the responsibility to serve as the
+ Agreement Steward to a suitable separate entity. Each new version of
+ the Agreement will be given a distinguishing version number. The
+ Program (including Contributions) may always be distributed subject to
+ the version of the Agreement under which it was received. In addition,
+ after a new version of the Agreement is published, Contributor may
+ elect to distribute the Program (including its Contributions) under
+ the new version. Except as expressly stated in Sections 2(a) and 2(b)
+ above, Recipient receives no rights or licenses to the intellectual
+ property of any Contributor under this Agreement, whether expressly,
+ by implication, estoppel or otherwise. All rights in the Program not
+ expressly granted under this Agreement are reserved.
+
+ This Agreement is governed by the laws of the State of New York and
+ the intellectual property laws of the United States of America. No
+ party to this Agreement will bring a legal action under this Agreement
+ more than one year after the cause of action arose. Each party waives
+ its rights to a jury trial in any resulting litigation.
+
+Copyright (c) 2004 by the Open Source Initiative
+This is a copy of the license posted on 2004-10-06 at:
+ http://www.opensource.org/licenses/cpl
diff --git a/usr/src/cmd/ast/THIRDPARTYLICENSE.descrip b/usr/src/cmd/ast/THIRDPARTYLICENSE.descrip
new file mode 100644
index 0000000000..6281d83ba5
--- /dev/null
+++ b/usr/src/cmd/ast/THIRDPARTYLICENSE.descrip
@@ -0,0 +1 @@
+AT&T ADVANCED SOFTWARE TECHNOLOGY UTILITIES
diff --git a/usr/src/cmd/ast/msgcc/Makefile b/usr/src/cmd/ast/msgcc/Makefile
new file mode 100644
index 0000000000..b11651278a
--- /dev/null
+++ b/usr/src/cmd/ast/msgcc/Makefile
@@ -0,0 +1,75 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+SHELL=/usr/bin/ksh
+
+include ../../Makefile.cmd
+
+.KEEP_STATE:
+
+# Set common AST build flags (e.g., needed to support the math stuff).
+include ../../../Makefile.ast
+
+# build rules
+CPPFLAGS = \
+ $(DTEXTDOM) $(DTS_ERRNO) \
+ -I$(ROOT)/usr/include/ast \
+ -D_PACKAGE_ast \
+ '-DUSAGE_LICENSE=\
+ "[-author?Glenn Fowler <gsf@research.att.com>]"\
+ "[-copyright?Copyright (c) 2000-2007 AT&T Knowledge Ventures]"\
+ "[-license?http://www.opensource.org/licenses/cpl1.0.txt]"\
+ "[--catalog?msgcc]"'
+
+CFLAGS += \
+ $(CCVERBOSE) \
+ -xstrconst
+
+LDLIBS += -last
+msgcpp := LDLIBS += -lpp
+
+msgcc: msgcc.sh
+ rm -f msgcc ; \
+ ( \
+ print "#!/usr/bin/ksh93" ; \
+ print "export PATH=/usr/ast/bin:/usr/xpg6/bin:/usr/xpg4/bin:/usr/bin:\$${PATH}" ; \
+ print "builtin date" ; \
+ cat "msgcc.sh" ; \
+ ) >msgcc ; \
+ chmod a+rx msgcc
+
+ROOTCMDDIR=$(ROOT)/usr/ast/bin
+
+PROG= msgcvt msggen msgget msgcpp msgcc
+
+all: $(PROG)
+
+install: all $(ROOTCMD)
+
+clean lint:
+
+include ../../Makefile.targ
diff --git a/usr/src/cmd/ast/msgcc/NOTES b/usr/src/cmd/ast/msgcc/NOTES
new file mode 100644
index 0000000000..864a3a206c
--- /dev/null
+++ b/usr/src/cmd/ast/msgcc/NOTES
@@ -0,0 +1,65 @@
+2000-04-01 ast message catalog plan
+
+(1) error_info.dictionary should be error_info.catalog
+ to match xopen and the internal naming in our implementation
+ and also to more closely match the webster definition
+ (catalog == enumerated list)
+
+ DONE
+
+(2) nmake by default will
+ CATALOG = $(ID:N=+([A-Za-z0-9_]):?$(PWD:N=*/lib/*:Y,lib,,)$(ID)?$(PWD:B)?)
+ ERROR_CATALOG == "$(CATALOG)"
+ e.g., commands in src/cmd/std will use the "std" catalog; all of the
+ commands in src/lib/libcmd will use the "libcmd" catalog
+
+ nmake will add "[--catalog?$(CATALOG)]" to USAGE_LICENSE
+ optget() will set error_info.catalog if not defined on the first call
+ commands that don't emit messages before optget() need not change
+ otherwise the command should
+
+ error_info.id = "foo";
+ error_info.catalog = ERROR_CATALOG;
+
+ undefined references to { USAGE_LICENSE ERROR_CATALOG } are hard
+ compile time errors
+
+ DONE
+
+(3) add catalog argument to libcmd <cmd.h> cmdinit(argv, context, catalog)
+
+ DONE
+
+(4) msgcat global target build msgs/*.mso and $(CATALOG).msg
+ each Makefile will generate one catalog $(CATALOG).msg where
+
+ the *.msg files are weird -- we need to build them viewed over an
+ architecture specific tree, even though they will be eventually used
+ as architecture independent source
+
+ $(CATALOG).msg will be the "C" locale
+
+ debug will be a debugging locale that will translate each message to
+ (CATALOG-NAME:MESSAGE-INDEX)\n
+ this will make it easy to locate text that escaped translation (in what
+ should be translated output); it will also be a way for us to do
+ regression tests in the face of typo fixes -- presumably typos can be
+ fixed without changing the message index
+
+ see msgadmin(1)
+
+ DONE
+
+(5) once all this is working I'll do catopen(3) and msggen(1)
+
+ DONE
+
+(6) the makerules "all" action will
+ catgen $(CATALOG).cat
+ catgen $(CATALOG)-*.cat
+ and the makerules "install" action will copy the catgen output to
+ $(LOCALEDIR)/$(LOCALE)/LC_MESSAGES/$(CATALOG)*
+ where
+ LOCALEDIR = $(INSTALLROOT)/lib/locale
+
+ NOTE: still under consideration
diff --git a/usr/src/cmd/ast/msgcc/PROMO.mm b/usr/src/cmd/ast/msgcc/PROMO.mm
new file mode 100644
index 0000000000..d39264185e
--- /dev/null
+++ b/usr/src/cmd/ast/msgcc/PROMO.mm
@@ -0,0 +1,22 @@
+.H 1 msgcc
+.B msgcc
+and
+.B msgcpp
+extract message text from C source for
+.BR gencat (1)
+message catalogs.
+.BR msggen (1)
+is a
+.BR gencat (1)
+replacement that generates machine independent binary message
+catalogs that are compatible with the
+.B ast
+.BR catgets (3)
+implementation.
+.B catgets
+also supports native message catalogs where available.
+.BR msgcvt (1)
+and
+.BR msgadmin (1)
+are administrative commands that support machine translation
+of C locale message catalogs.
diff --git a/usr/src/cmd/ast/msgcc/msgcc.sh b/usr/src/cmd/ast/msgcc/msgcc.sh
new file mode 100644
index 0000000000..aad98f7c1f
--- /dev/null
+++ b/usr/src/cmd/ast/msgcc/msgcc.sh
@@ -0,0 +1,405 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 2000-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# Glenn Fowler <gsf@research.att.com> #
+# #
+########################################################################
+: C language message catalog compiler
+
+# NOTE: all variable names match __*__ to avoid clash with msgcpp def vars
+
+__command__=msgcc
+integer __similar__=30
+
+case `(getopts '[-][123:xyz]' opt --xyz; echo 0$opt) 2>/dev/null` in
+0123) ARGV0="-a $__command__"
+ USAGE=$'
+[-?
+@(#)$Id: msgcc (AT&T Labs Research) 2002-09-15 $
+]
+'$USAGE_LICENSE$'
+[+NAME?msgcc - C language message catalog compiler]
+[+DESCRIPTION?\bmsgcc\b is a C language message catalog compiler. It accepts
+ \bcc\b(1) style options and arguments. A \bmsgcpp\b(1) \b.mso\b file
+ is generated for each input \b.c\b file. If the \b-c\b option is not
+ specified then a \bgencat\b(1) format \b.msg\b file is generated from
+ the input \b.mso\b and \b.msg\b files. If \b-c\b is not specified then
+ a \b.msg\b suffix is appended to the \b-o\b \afile\a if it doesn\'t
+ already have a suffix. The default output is \ba.out.msg\b if \b-c\b
+ and \b-o\b are not specified.]
+[+?If \b-M-new\b is not specified then messages are merged with those in the
+ pre-existing \b-o\b file.]
+[M?Set a \bmsgcc\b specific \aoption\a. \aoption\a may be:]:[-option]{
+ [+mkmsgs?The \b-o\b file is assumed to be in \bmkmsgs\b(1) format.]
+ [+new?Create a new \b-o\b file.]
+ [+preserve?Messages in the \b-o\b file that are not in new
+ \b.msg\b file arguments are preserved. The default is to
+ either reuse the message numbers with new message text that
+ is similar to the old or to delete the message text, leaving
+ an unused message number.]
+ [+set=\anumber\a?Set the message set number to \anumber\a. The default
+ is \b1\b.]
+ [+similar=\anumber\a?The message text similarity measure thresshold.
+ The similarity measure between \aold\a and \anew\a message
+ text is 100*(2*gzip(\aold\a+\anew\a)/(gzip(\aold\a)+gzip(\anew\a))-1),
+ where gzip(\ax\a) is the size of text \ax\a when compressed by
+ \bgzip\b(1). The default threshhold is '$__similar__$'. A
+ threshhold of \b0\b turns off message replacement, but unused
+ old messages are still deleted. Use \b-M-preserve\b to preserve
+ all old messages.]
+ [+verbose?Trace similar message replacements on the standard error.]
+}
+
+file ...
+
+[+SEE ALSO?\bcc\b(1), \bcpp\b(1), \bgencat\b(1), \bmsggen\b(1),
+ \bmsgcpp\b(1), \bmsgcvt\b(1)]
+'
+ ;;
+*) ARGV0=""
+ USAGE="M:[-option] [ cc-options ] file ..."
+ ;;
+esac
+
+usage()
+{
+ OPTIND=0
+ getopts $ARGV0 "$USAGE" OPT '-?'
+ exit 2
+}
+
+keys()
+{
+ $1 --??keys -- 2>&1 | grep '^".*"$'
+}
+
+typeset -A __index__
+typeset __keep__ __text__ __drop__ __oz__ __nz__ __z__ __hit__ __hit_i__
+typeset __compile__ __debug__ __mkmsgs__ __preprocess__
+typeset __merge__=1 __preserve__ __verbose__
+integer __i__=0 __args__=0 __code__=0 __files__=0 __max__=0 __num__=0 __skip__=0
+integer __set__=1 __sources__=0 __cmds__=0 __ndrop__=0 __new__=0 __old__=0
+__out__=a.out.msg
+__OUT__=
+
+case " $* " in
+*" --"*|*" -?"*)
+ while getopts $ARGV0 "$USAGE" OPT
+ do case $OPT in
+ *) break ;;
+ esac
+ done
+ ;;
+esac
+while :
+do case $# in
+ 0) break ;;
+ esac
+ __arg__=$1
+ case $__arg__ in
+ -c) __compile__=1
+ ;;
+ -[DIU]*)__argv__[__args__]=$__arg__
+ (( __args__++ ))
+ ;;
+ -E) __preprocess__=1
+ ;;
+ -M-debug)
+ __debug__=1
+ ;;
+ -M-mkmsgs)
+ __mkmsgs__=1
+ ;;
+ -M-new) __merge__=
+ ;;
+ -M-perserve)
+ __preserve__=1
+ ;;
+ -M-set=*)
+ __set__=$(msggen -s ${__arg__#*=}.1)
+ ;;
+ -M-similar=*)
+ __similar__=${__arg__#*=}
+ ;;
+ -M-verbose)
+ __verbose__=1
+ ;;
+ -o) case $# in
+ 1) print -u2 $"$__command__: output argument expected"
+ exit 1
+ ;;
+ esac
+ shift
+ __out__=${1%.*}.msg
+ __OUT__=$1
+ ;;
+ [-+]*|*.[aAlLsS]*)
+ ;;
+ *.[cCiI]*|*.[oO]*)
+ case $__arg__ in
+ *.[oO]*);;
+ *) __srcv__[__files__]=$__arg__
+ (( __sources__++ ))
+ ;;
+ esac
+ __arg__=${__arg__##*/}
+ __arg__=${__arg__%.*}.mso
+ __objv__[__files__]=$__arg__
+ (( __files__++ ))
+ ;;
+ *.ms[go])
+ __objv__[__files__]=$__arg__
+ (( __files__++ ))
+ ;;
+ *) __cmdv__[__cmds__]=$__arg__
+ (( __cmds__++ ))
+ ;;
+ esac
+ shift
+done
+__cmdv__[__cmds__]=${__out__%.msg}
+(( __cmds__++ ))
+
+# generate the .mso files
+
+if [[ $__OUT__ && $__compile__ ]]
+then __objv__[0]=$__OUT__
+fi
+
+if (( __sources__ ))
+then for (( __i__=0; __i__<=__files__; __i__++ ))
+ do if [[ ${__srcv__[__i__]} ]]
+ then if (( __sources__ > 1 ))
+ then print "${__srcv__[__i__]}:"
+ fi
+ if [[ $__preprocess__ ]]
+ then msgcpp "${__argv__[@]}" "${__srcv__[__i__]}"
+ else msgcpp "${__argv__[@]}" "${__srcv__[__i__]}" > "${__objv__[__i__]}"
+ fi
+ fi
+ done
+fi
+
+# combine the .mso and .msg files
+
+if [[ ! $__compile__ && ! $__preprocess__ ]]
+then if [[ $__merge__ && -r $__out__ ]]
+ then __tmp__=$__out__.tmp
+ trap '__code__=$?; rm -f ${__tmp__}*; exit $__code__' 0 1 2
+ while read -r __line__
+ do if (( $__skip__ ))
+ then if [[ $__line__ == '%}'* ]]
+ then __skip__=0
+ fi
+ continue
+ fi
+ if [[ $__mkmsgs__ && $__line__ == '%{'* ]]
+ then __skip__=1
+ continue
+ fi
+ if [[ $__mkmsgs__ ]]
+ then if [[ $__line__ == '%#'*';;'* ]]
+ then __line__=${__line__#'%#'}
+ __num__=${__line__%';;'*}
+ read -r __line__
+ elif [[ $__line__ == %* ]]
+ then continue
+ else print -u2 $"$__command__: unrecognized line=$__line__"
+ __code__=1
+ fi
+ else case $__line__ in
+ +([0-9])' '*)
+ __num__=${__line__%%' '*}
+ __line__=${__line__#*'"'}
+ __line__=${__line__%'"'}
+ ;;
+ *) continue
+ ;;
+ esac
+ fi
+ __index__["$__line__"]=$__num__
+ __text__[$__num__]=$__line__
+ if (( __max__ < __num__ ))
+ then (( __max__=__num__ ))
+ fi
+ done < $__out__
+ (( __new__=__max__+1 ))
+ else __tmp__=$__out__
+ (( __new__=1 ))
+ fi
+ if (( __code__ ))
+ then exit $__code__
+ fi
+ exec 1>$__tmp__ 9>&1
+ print -r -- '$'" ${__out__%.msg} message catalog"
+ print -r -- '$translation'" $__command__ $(date +%Y-%m-%d)"
+ print -r -- '$set'" $__set__"
+ print -r -- '$quote "'
+ sort -u "${__objv__[@]}" | {
+ while read -r __line__
+ do __op__=${__line__%% *}
+ __line__=${__line__#* }
+ case $__op__ in
+ cmd) __a1__=${__line__%% *}
+ case $__a1__ in
+ dot_cmd) __a1__=. ;;
+ esac
+ keys $__a1__
+ ;;
+ def) __a1__=${__line__%% *}
+ __a2__=${__line__#* }
+ eval $__a1__='$'__a2__
+ ;;
+ str) print -r -- "$__line__"
+ ;;
+ var) __a1__=${__line__%% *}
+ __a2__=${__line__#* }
+ case $__a1__ in
+ [[:digit:]]*)
+ eval __v__='$'$__a2__
+ __v__='"'${__v__:__a1__+1}
+ ;;
+ *) eval __v__='$'$__a1__
+ ;;
+ esac
+ if [[ $__v__ == '"'*'"' ]]
+ then print -r -- "$__v__"
+ fi
+ ;;
+ [[:digit:]]*)
+ [[ $__preserve__ ]] && print -r -- "$__line__"
+ ;;
+ '$') print -r -u9 $__op__ include $__line__
+ ;;
+ esac
+ done
+ for (( __i__=0; __i__ < __cmds__; __i__++ ))
+ do keys ${__cmdv__[__i__]}
+ done
+ } | {
+ __num__=1
+ while read -r __line__
+ do case $__line__ in
+ '$'[\ \ ]*)
+ print -r -- "$__line__"
+ continue
+ ;;
+ '$'*|*"@(#)"*|*"<"*([[:word:] .-])"@"*([[:word:] .-])">"*([ ])'"'|"http://"*)
+ continue
+ ;;
+ *[[:alpha:]][[:alpha:]]*)
+ __line__=${__line__#*'"'}
+ __line__=${__line__%'"'}
+ if [[ $__line__ ]]
+ then if [[ ${__index__["$__line__"]} ]]
+ then if [[ ! $__preserve__ ]]
+ then __num__=${__index__["$__line__"]}
+ __keep__[$__num__]=1
+ fi
+ else while [[ ${__text__[$__num__]} ]]
+ do (( __num__++ ))
+ done
+ if (( __max__ < __num__ ))
+ then (( __max__=__num__ ))
+ fi
+ if [[ ! $__preserve__ ]]
+ then __keep__[$__num__]=1
+ fi
+ __text__[$__num__]=$__line__
+ __index__["$__line__"]=$__num__
+ (( __num__++ ))
+ fi
+ fi
+ ;;
+ esac
+ done
+ if (( __max__ < __num__ ))
+ then (( __max__=__num__ ))
+ fi
+ if [[ $__debug__ ]]
+ then for (( __num__=1; __num__<=__max__; __num__++ ))
+ do if [[ ${__text__[$__num__]} ]]
+ then if (( __num__ > __new__ ))
+ then if [[ ! ${__keep__[$__num__]} ]]
+ then print -r -u2 -- $__num__ HUH '"'"${__text__[$__num__]}"'"'
+ else print -r -u2 -- $__num__ NEW '"'"${__text__[$__num__]}"'"'
+ fi
+ elif [[ ${__keep__[$__num__]} ]]
+ then print -r -u2 -- $__num__ OLD '"'"${__text__[$__num__]}"'"'
+ else print -r -u2 -- $__num__ XXX '"'"${__text__[$__num__]}"'"'
+ fi
+ fi
+ done
+ exit 0
+ fi
+ # check for replacements
+ if [[ ! $__preserve__ ]]
+ then for (( __num__=1; __num__<__new__; __num__++ ))
+ do if [[ ${__text__[$__num__]} && ! ${__keep__[$__num__]} ]]
+ then (( __ndrop__++ ))
+ __drop__[__ndrop__]=$__num__
+ fi
+ done
+ [[ $__verbose__ ]] && print -u2 $__command__: old:1-$((__new__-1)) new:$__new__-$__max__ drop $__ndrop__ add $((__max__-__new__+1))
+ if (( __ndrop__ ))
+ then for (( __i__=1; __i__<=__ndrop__; __i__++ ))
+ do (( __old__=${__drop__[$__i__]} ))
+ __oz__[__i__]=$(print -r -- "\"${__text__[$__old__]}\"" | gzip | wc -c)
+ done
+ for (( __num__=__new__; __num__<=__max__; __num__++ ))
+ do [[ ${__text__[$__num__]} ]] || continue
+ __nz__=$(print -r -- "\"${__text__[$__num__]}\"" | gzip | wc -c)
+ __hit__=0
+ (( __bz__=__similar__ ))
+ for (( __i__=1; __i__<=__ndrop__; __i__++ ))
+ do if (( __old__=${__drop__[$__i__]} ))
+ then __z__=$(print -r -- "\"${__text__[$__old__]}\"""\"${__text__[$__num__]}\"" | gzip | wc -c)
+ (( __z__ = (__z__ * 200 / (${__oz__[__i__]} + $__nz__)) - 100 ))
+ if (( __z__ < __bz__ ))
+ then (( __bz__=__z__ ))
+ (( __hit__=__old__ ))
+ (( __hit_i__=__i__ ))
+ fi
+ fi
+ done
+ if (( __hit__ ))
+ then [[ $__verbose__ ]] && print -u2 $__command__: $__hit__ $__num__ $__bz__
+ __text__[$__hit__]=${__text__[$__num__]}
+ __keep__[$__hit__]=1
+ __drop__[$__hit_i__]=0
+ __text__[$__num__]=
+ __keep__[$__num__]=
+ fi
+ done
+ fi
+ fi
+ # final output
+ for (( __num__=1; __num__<=__max__; __num__++ ))
+ do if [[ ${__text__[$__num__]} && ( $__preserve__ || ${__keep__[$__num__]} ) ]]
+ then print -r -- $__num__ "\"${__text__[$__num__]}\""
+ fi
+ done
+ }
+ if [[ $__tmp__ != $__out__ ]]
+ then grep -v '^\$' $__tmp__ > ${__tmp__}n
+ [[ -f $__out__ ]] && grep -v '^\$' $__out__ > ${__tmp__}o
+ cmp -s ${__tmp__}n ${__tmp__}o || {
+ [[ -f $__out__ ]] && mv $__out__ $__out__.old
+ mv $__tmp__ $__out__
+ }
+ fi
+fi
+exit $__code__
diff --git a/usr/src/cmd/ast/msgcc/msgcc.tst b/usr/src/cmd/ast/msgcc/msgcc.tst
new file mode 100644
index 0000000000..101b05de5b
--- /dev/null
+++ b/usr/src/cmd/ast/msgcc/msgcc.tst
@@ -0,0 +1,28 @@
+# regression tests for the msgcc utility
+
+TEST 01 'basics'
+ EXEC -c t.c
+ NOTE 'pp:allpossible'
+ INPUT t.c $'
+ #include <foo-bar.h>
+ void f(void)
+ {
+ #if 0
+ error(1, "foo bar");
+ #else
+ errormsg(locale, 2, "%s: bar foo");
+ #endif
+ }
+ '
+ OUTPUT t.mso $'str "foo bar"\nstr "%s: bar foo"'
+ OUTPUT -
+ EXEC -Dfprintf=_STDIO_ -c t.c
+ NOTE 'ignore readonly redefinitions'
+ INPUT t.c $'
+ #define stderr foo
+ void f(void)
+ {
+ fprintf(stderr, "foo bar");
+ }
+ '
+ OUTPUT t.mso $'str "foo bar"'
diff --git a/usr/src/cmd/ast/msgcc/msgcpp.c b/usr/src/cmd/ast/msgcc/msgcpp.c
new file mode 100644
index 0000000000..677065f6cf
--- /dev/null
+++ b/usr/src/cmd/ast/msgcc/msgcpp.c
@@ -0,0 +1,289 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 2000-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * C message catalog preprocessor
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: msgcpp (AT&T Research) 2002-03-11 $\n]"
+USAGE_LICENSE
+"[+NAME?msgcpp - C language message catalog preprocessor]"
+"[+DESCRIPTION?\bmsgcpp\b is a C language message catalog preprocessor."
+" It accepts \bcpp\b(1) style options and arguments. \bmsgcpp\b"
+" preprocesses an input C source file and emits keyed lines to the"
+" output, usually for further processing by \bmsgcc\b(1). \bmsgcc\b"
+" output is in the \bgencat\b(1) syntax. Candidate message text is"
+" determined by arguments to the \bast\b \b<error.h>\b and"
+" \b<option.h>\b functions. The \bmsgcpp\b keyed output lines are:]{"
+" [+cmd \acommand\a?\acommand\a is a candidate for \b--??keys\b"
+" option string generation. Triggered by"
+" \bb_\b\acommand\a\b(int argc,\b in the input.]"
+" [+def \aname\a \astring\a?\aname\a is a candidate variable with"
+" string value \astring\a.]"
+" [+str \astring\a?\astring\a should be entered into the catalog.]"
+" [+var \aname\a?If \bdef\b \aname\a occurs then its \astring\a value"
+" should be entered into the catalog.]"
+" }"
+"[+?The input source file is preprocessed with the \bpp:allpossible\b"
+" option on. This enables non-C semantics; all source should first"
+" be compiled error-free with a real compiler before running \bmsgcpp\b."
+" The following changes are enabled for the top level files (i.e.,"
+" included file behavior is not affected):]{"
+" [+(1)?All \b#if\b, \b#ifdef\b and \b#ifndef\b branches"
+" are enabled.]"
+" [+(2)?The first definition for a macro is retained, even when"
+" subsequent \b#define\b statements would normally"
+" redefine the macro. \b#undef\b must be used to"
+" redefine a macro.]"
+" [+(3)?Macro calls with an improper number of arguments are"
+" silently ignored.]"
+" [+(4)?\b#include\b on non-existent headers are silently"
+" ignored.]"
+" [+(5)?Invalid C source characters are silently ignored.]"
+" }"
+"[+?\b\"msgcat.h\"\b is included if it exists. This file may contain macro"
+" definitions for functions that translate string arguments. If \afoo\a"
+" is a function that translates its string arguments then include the"
+" line \b#define \b\afoo\a\b _TRANSLATE_\b in \bmsgcat.h\b or specify"
+" the option \b-D\b\afoo\a\b=_TRANSLATE_\b. If \abar\a is a function"
+" that translates string arguments if the first argument is \bstderr\b"
+" then use either \b#define \b\abar\a\b _STDIO_\b or"
+" \b-D\b\abar\a\b=_STDIO_\b.]"
+"[+?The macro \b_BLD_msgcat\b is defined to be \b1\b. As an alternative to"
+" \bmsgcat.h\b, \b_TRANSLATE_\b definitions could be placed inside"
+" \b#ifdef _BLD_msgcat\b ... \b#endif\b.]"
+
+"\n"
+"\n[ input [ output ] ]\n"
+"\n"
+
+"[+SEE ALSO?\bcc\b(1), \bcpp\b(1), \bgencat\b(1), \bmsggen\b(1),"
+" \bmsgcc\b(1), \bmsgcvt\b(1)]"
+;
+
+#include <ast.h>
+#include <error.h>
+
+#include "pp.h"
+#include "ppkey.h"
+
+#define T_STDERR (T_KEYWORD+1)
+#define T_STDIO (T_KEYWORD+2)
+#define T_TRANSLATE (T_KEYWORD+3)
+
+#define OMIT "*@(\\[[-+]*\\?*\\]|\\@\\(#\\)|Copyright \\(c\\)|\\\\000|\\\\00[!0-9]|\\\\0[!0-9])*"
+
+static struct ppkeyword keys[] =
+{
+ "char", T_CHAR,
+ "int", T_INT,
+ "sfstderr", T_STDERR,
+ "stderr", T_STDERR,
+ "_STDIO_", T_STDIO,
+ "_TRANSLATE_", T_TRANSLATE,
+ 0, 0
+};
+
+static int
+msgppargs(char** argv, int last)
+{
+ for (;;)
+ {
+ switch (optget(argv, usage))
+ {
+ case 0:
+ break;
+ case '?':
+ if (!last)
+ {
+ opt_info.again = 1;
+ return 1;
+ }
+ error(ERROR_USAGE|4, "%s", opt_info.arg);
+ break;
+ case ':':
+ if (!last)
+ {
+ opt_info.again = 1;
+ return 1;
+ }
+ error(2, "%s", opt_info.arg);
+ continue;
+ default:
+ if (!last)
+ {
+ opt_info.again = 1;
+ return 1;
+ }
+ continue;
+ }
+ break;
+ }
+ return argv[opt_info.index] != 0;
+}
+
+int
+main(int argc, char** argv)
+{
+ register char* s;
+ register int x;
+ register int c;
+ Sfio_t* tmp;
+
+ NoP(argc);
+ if (s = strrchr(*argv, '/'))
+ s++;
+ else
+ s = *argv;
+ error_info.id = s;
+ ppop(PP_DEFAULT, PPDEFAULT);
+ optjoin(argv, msgppargs, ppargs, NiL);
+ if (strlen(s) >= 5 && *(s + 3) != 'c')
+ {
+ ppop(PP_PLUSPLUS, 1);
+ ppop(PP_NOHASH, 1);
+ ppop(PP_PROBE, "CC");
+ }
+ ppop(PP_SPACEOUT, 0);
+ ppop(PP_COMPILE, keys);
+ ppop(PP_OPTION, "allpossible");
+ ppop(PP_OPTION, "catliteral");
+ ppop(PP_OPTION, "modern");
+ ppop(PP_OPTION, "readonly");
+ ppop(PP_DEFINE, "_BLD_msgcat=1");
+ ppop(PP_DEFINE, "const=");
+ ppop(PP_DEFINE, "errorf=_TRANSLATE_");
+ ppop(PP_DEFINE, "register=");
+ ppop(PP_DEFINE, "sfstderr=sfstderr");
+ ppop(PP_DEFINE, "stderr=stderr");
+ ppop(PP_DEFINE, "_(m)=_TRANSLATE_(m)");
+ ppop(PP_DEFINE, "__(m)=_TRANSLATE_(m)");
+ ppop(PP_DEFINE, "gettxt(i,m)=_TRANSLATE_(m)");
+ ppop(PP_DEFINE, "gettext(m)=_TRANSLATE_(m)");
+ ppop(PP_DEFINE, "dgettext(d,m)=_TRANSLATE_(m)");
+ ppop(PP_DEFINE, "dcgettext(d,m,c)=_TRANSLATE_(m)");
+ ppop(PP_DEFINE, "ERROR_catalog(m)=_TRANSLATE_(m)");
+ ppop(PP_DEFINE, "ERROR_dictionary(m)=_TRANSLATE_(m)");
+ ppop(PP_DEFINE, "ERROR_translate(l,i,c,m)=_TRANSLATE_(m)");
+ ppop(PP_DEFINE, "error(l,f,...)=_TRANSLATE_(f)");
+ ppop(PP_DEFINE, "errormsg(t,l,f,...)=_TRANSLATE_(f)");
+ ppop(PP_DIRECTIVE, "include \"msgcat.h\"");
+ ppop(PP_OPTION, "noreadonly");
+ ppop(PP_INIT);
+ if (!(tmp = sfstropen()))
+ error(ERROR_SYSTEM|3, "out of space");
+ x = 0;
+ for (;;)
+ {
+ c = pplex();
+ again:
+ switch (c)
+ {
+ case 0:
+ break;
+ case T_TRANSLATE:
+ switch (c = pplex())
+ {
+ case '(':
+ x = 1;
+ break;
+ case ')':
+ if ((c = pplex()) != '(')
+ {
+ x = 0;
+ goto again;
+ }
+ x = 1;
+ break;
+ default:
+ x = 0;
+ goto again;
+ }
+ continue;
+ case '(':
+ if (x > 0)
+ x++;
+ continue;
+ case ')':
+ if (x > 0)
+ x--;
+ continue;
+ case T_STDIO:
+ if ((c = pplex()) != '(' || (c = pplex()) != T_STDERR || (c = pplex()) != ',')
+ {
+ x = 0;
+ goto again;
+ }
+ x = 1;
+ continue;
+ case T_STRING:
+ if (x > 0 && !strmatch(pp.token, OMIT))
+ sfprintf(sfstdout, "str \"%s\"\n", pp.token);
+ continue;
+ case T_ID:
+ s = pp.symbol->name;
+ if (x > 0)
+ {
+ if ((c = pplex()) == '+' && ppisinteger(c = pplex()))
+ sfprintf(sfstdout, "var %s %s\n", pp.token, s);
+ else
+ sfprintf(sfstdout, "var %s\n", s);
+ }
+ else if (s[0] == 'b' && s[1] == '_' && s[2])
+ {
+ if ((c = pplex()) == '(' && (c = pplex()) == T_INT && (c = pplex()) == T_ID && (c = pplex()) == ',' && (c = pplex()) == T_CHAR && (c = pplex()) == '*')
+ sfprintf(sfstdout, "cmd %s\n", s + 2);
+ else
+ goto again;
+ }
+ else
+ {
+ if ((c = pplex()) == '[')
+ {
+ if (ppisinteger(c = pplex()))
+ c = pplex();
+ if (c != ']')
+ goto again;
+ c = pplex();
+ }
+ if (c == '=' && (c = pplex()) == T_STRING && !strmatch(pp.token, OMIT))
+ {
+ sfprintf(sfstdout, "def %s \"%s\"\n", s, pp.token);
+ sfprintf(tmp, "#define %s \"%s\"\n", s, pp.token);
+ if (!(s = sfstruse(tmp)))
+ error(ERROR_SYSTEM|3, "out of space");
+ ppinput(s, "string", 0);
+ }
+ else
+ goto again;
+ }
+ continue;
+ default:
+ continue;
+ }
+ break;
+ }
+ ppop(PP_DONE);
+ return error_info.errors != 0;
+}
diff --git a/usr/src/cmd/ast/msgcc/msgcvt.c b/usr/src/cmd/ast/msgcc/msgcvt.c
new file mode 100644
index 0000000000..89dd3e848d
--- /dev/null
+++ b/usr/src/cmd/ast/msgcc/msgcvt.c
@@ -0,0 +1,691 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 2000-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: msgcvt (AT&T Research) 2000-05-01 $\n]"
+USAGE_LICENSE
+"[+NAME?msgcvt - convert message file to/from html]"
+"[+DESCRIPTION?\bmsgcvt\b reads a \bgencat\b(1) format file on the standard"
+" input and converts it to \bhtml\b on the standard output. The input"
+" file must contain the control statement \b$quote \"\b and use the \""
+" character to quote message text. The output is in a form suitable for"
+" automatic translation by web sites like"
+" \bhttp://babelfish.altavista.com/\b or filters like"
+" \btranslate\b(1).]"
+"[h:html?Generate \bhtml\b from \bgencat\b(1) input. This is the default.]"
+"[m:msg?Generate a \bgencat\b(1) message file from (presumably translated)"
+" \bhtml\b. Wide characters are UTF-8 encoded.]"
+"[r:raw?The message file is raw message text, one message per line, with no"
+" quoting or line numbering.]"
+"[+SEE ALSO?\bgencat\b(1), \bmsgcc\b(1), \bmsggen\b(1), \btranslate\b(1)]"
+;
+
+#include <ast.h>
+#include <ctype.h>
+#include <error.h>
+
+#define MSG_RAW (1<<0)
+#define MSG_SPLICE (1<<1)
+
+#define SPACE(s) (isspace(*s)&&(s+=1)||*s=='\\'&&(*(s+1)=='n'||*(s+1)=='t')&&(s+=2))
+
+typedef void (*Convert_f)(Sfio_t*, Sfio_t*, int);
+
+typedef struct
+{
+ const char* name;
+ int code;
+} Code_t;
+
+static const Code_t codes[] =
+{
+ "aacute", 225,
+ "Aacute", 193,
+ "acirc", 226,
+ "Acirc", 194,
+ "aelig", 230,
+ "AElig", 198,
+ "agrave", 224,
+ "Agrave", 192,
+ "amp", '&',
+ "aring", 229,
+ "Aring", 197,
+ "atilde", 227,
+ "Atilde", 195,
+ "auml", 228,
+ "Auml", 196,
+ "ccedil", 231,
+ "Ccedil", 199,
+ "copy", 169,
+ "eacute", 233,
+ "Eacute", 201,
+ "ecirc", 234,
+ "Ecirc", 202,
+ "egrave", 232,
+ "Egrave", 200,
+ "euml", 235,
+ "Euml", 203,
+ "gt", '>',
+ "iacute", 237,
+ "Iacute", 205,
+ "icirc", 238,
+ "Icirc", 206,
+ "igrave", 236,
+ "Igrave", 204,
+ "iuml", 239,
+ "Iuml", 207,
+ "lt", '<',
+ "nbsp", ' ',
+ "ntilde", 241,
+ "Ntilde", 209,
+ "oacute", 243,
+ "Oacute", 211,
+ "ocirc", 244,
+ "Ocirc", 212,
+ "ograve", 242,
+ "Ograve", 210,
+ "oslash", 248,
+ "Oslash", 216,
+ "otilde", 245,
+ "Otilde", 213,
+ "ouml", 246,
+ "Ouml", 214,
+ "quot", '"',
+ "reg", 174,
+ "szlig", 223,
+ "uacute", 250,
+ "Uacute", 218,
+ "ucirc", 251,
+ "Ucirc", 219,
+ "ugrave", 249,
+ "Ugrave", 217,
+ "uuml", 252,
+ "Uuml", 220,
+ "yuml", 255,
+};
+
+static int
+decode(Sfio_t* ip)
+{
+ register int c;
+ register int i;
+ char name[32];
+
+ if ((c = sfgetc(ip)) == EOF)
+ return '&';
+ name[0] = c;
+ i = 1;
+ if (c != '#' && !isalpha(c))
+ goto bad;
+ while ((c = sfgetc(ip)) != EOF && c != ';')
+ {
+ if (c == '&')
+ i = 0;
+ else
+ {
+ name[i++] = c;
+ if (!isalnum(c) && (i > 1 || c != '#') || i >= (elementsof(name) - 1))
+ goto bad;
+ }
+ }
+ name[i] = 0;
+ if (name[0] == '#')
+ {
+ switch (c = strtol(name + 1, NiL, 10))
+ {
+ case 91:
+ c = '[';
+ break;
+ case 93:
+ c = ']';
+ break;
+ }
+ }
+ else
+ {
+ for (i = 0; i < elementsof(codes); i++)
+ if (streq(codes[i].name, name))
+ {
+ c = codes[i].code;
+ break;
+ }
+ if (i >= elementsof(codes))
+ goto bad;
+ }
+ return c;
+ bad:
+ name[i] = 0;
+ if (c == ';')
+ error(1, "&%s: unknown HTML special character -- & assumed", name);
+ else
+ error(1, "&%s: invalid HTML special character -- & assumed", name);
+ while (i--)
+ sfungetc(ip, name[i]);
+ return '&';
+}
+
+static int
+sfpututf(Sfio_t* op, register int w)
+{
+ if (!(w & ~0x7F))
+ return sfputc(op, w);
+ else if (!(w & ~0x7FF))
+ sfputc(op, 0xC0 + (w >> 6));
+ else if (!(w & ~0xFFFF))
+ {
+ sfputc(op, 0xE0 + (w >> 12));
+ sfputc(op, 0x80 + (w >> 6 ) & 0x3F);
+ }
+ else
+ return sfputc(op, '?');
+ return sfputc(op, 0x80 + (w & 0x3F));
+}
+
+static int
+sfnext(Sfio_t* ip)
+{
+ register int c;
+
+ while (isspace(c = sfgetc(ip)));
+ return c;
+}
+
+static void
+html2msg(register Sfio_t* ip, register Sfio_t* op, int flags)
+{
+ register int c;
+ register int q;
+
+ again:
+ while ((c = sfgetc(ip)) != EOF)
+ if (c == '<')
+ {
+ if ((c = sfnext(ip)) == 'O' &&
+ (c = sfnext(ip)) == 'L' &&
+ isspace(c = sfgetc(ip)) &&
+ (c = sfnext(ip)) == 'S' &&
+ (c = sfnext(ip)) == 'T' &&
+ (c = sfnext(ip)) == 'A' &&
+ (c = sfnext(ip)) == 'R' &&
+ (c = sfnext(ip)) == 'T' &&
+ (c = sfnext(ip)) == '=' &&
+ (c = sfnext(ip)) == '"' &&
+ (c = sfnext(ip)) == '5' &&
+ (c = sfnext(ip)) == '5' &&
+ (c = sfnext(ip)) == '0' &&
+ (c = sfnext(ip)) == '7' &&
+ (c = sfnext(ip)) == '1' &&
+ (c = sfnext(ip)) == '7' &&
+ (c = sfnext(ip)) == '"' &&
+ (c = sfnext(ip)) == '>')
+ break;
+ while (c != EOF && c != '>')
+ c = sfgetc(ip);
+ }
+ if ((c = sfnext(ip)) != EOF)
+ sfungetc(ip, c);
+ q = 0;
+ for (;;)
+ {
+ switch (c = sfgetc(ip))
+ {
+ case EOF:
+ break;
+ case '&':
+ c = decode(ip);
+ sfpututf(op, c);
+ if (isspace(c))
+ {
+ while (isspace(c = sfgetc(ip)));
+ if (c == EOF)
+ break;
+ sfungetc(ip, c);
+ }
+ continue;
+ case '<':
+ switch (c = sfnext(ip))
+ {
+ case '/':
+ if ((c = sfnext(ip)) == 'O' &&
+ (c = sfgetc(ip)) == 'L' &&
+ (c = sfnext(ip)) == '>')
+ {
+ if (q)
+ {
+ sfputc(op, q);
+ q = '"';
+ }
+ goto again;
+ }
+ break;
+ case 'B':
+ if ((c = sfgetc(ip)) == 'R' &&
+ (c = sfnext(ip)) == '>')
+ sfputc(op, ' ');
+ break;
+ case 'L':
+ if ((c = sfgetc(ip)) == 'I' &&
+ (c = sfnext(ip)) == '>' &&
+ isdigit(c = sfnext(ip)))
+ {
+ if (q)
+ sfputc(op, q);
+ else
+ q = '"';
+ sfputc(op, '\n');
+ do
+ {
+ sfputc(op, c);
+ } while (isdigit(c = sfgetc(ip)));
+ if (c == EOF)
+ break;
+ sfputc(op, ' ');
+ sfputc(op, '"');
+ if (isspace(c))
+ c = sfnext(ip);
+ if (c == '<' &&
+ (c = sfnext(ip)) == 'L' &&
+ (c = sfgetc(ip)) == 'I' &&
+ (c = sfnext(ip)) == '>')
+ /* great */;
+ continue;
+ }
+ break;
+ case 'P':
+ if ((c = sfnext(ip)) == '>')
+ sfputc(op, '\n');
+ else if (c == 'C' &&
+ (c = sfgetc(ip)) == 'L' &&
+ (c = sfgetc(ip)) == 'A' &&
+ (c = sfgetc(ip)) == 'S' &&
+ (c = sfgetc(ip)) == 'S' &&
+ (c = sfnext(ip)) == '=' &&
+ (c = sfnext(ip)) == '"')
+ for (;;)
+ {
+ switch (c = sfgetc(ip))
+ {
+ case EOF:
+ case '"':
+ break;
+ case '&':
+ c = decode(ip);
+ sfpututf(op, c);
+ continue;
+ default:
+ sfpututf(op, c);
+ continue;
+ }
+ break;
+ }
+ break;
+ }
+ while (c != EOF && c != '>')
+ c = sfgetc(ip);
+ if (c == EOF || (c = sfgetc(ip)) == EOF)
+ break;
+ sfungetc(ip, c);
+ continue;
+ case '"':
+ if (!flags)
+ sfputc(op, '\\');
+ sfputc(op, c);
+ continue;
+ case '\n':
+ if (flags)
+ {
+ sfputc(op, c);
+ continue;
+ }
+ /*FALLTHROUGH*/
+ case ' ':
+ case '\t':
+ while ((c = sfgetc(ip)) != EOF)
+ if (c == '&')
+ {
+ c = decode(ip);
+ if (!isspace(c))
+ sfputc(op, ' ');
+ sfpututf(op, c);
+ break;
+ }
+ else if (!isspace(c))
+ {
+ if (c == '<')
+ {
+ c = sfgetc(ip);
+ if (c == EOF)
+ break;
+ sfungetc(ip, c);
+ sfungetc(ip, '<');
+ if (c != 'L' && c != '/')
+ sfputc(op, ' ');
+ }
+ else
+ {
+ if (c != EOF)
+ sfungetc(ip, c);
+ sfputc(op, ' ');
+ }
+ break;
+ }
+ continue;
+ case '\r':
+ case '[':
+ case ']':
+ continue;
+ default:
+ sfpututf(op, c);
+ continue;
+ }
+ break;
+ }
+ if (q)
+ sfputc(op, q);
+ sfputc(op, '\n');
+}
+
+static void
+encode(Sfio_t* op, register int c)
+{
+ if (c == '<')
+ sfprintf(op, "&lt;");
+ else if (c == '>')
+ sfprintf(op, "&gt;");
+ else if (c == '"')
+ sfprintf(op, "&quot;");
+ else if (c == '&')
+ sfprintf(op, "&amp;");
+ else if (c == '[')
+ sfprintf(op, "&#091;");
+ else if (c == ']')
+ sfprintf(op, "&#093;");
+ else
+ sfputc(op, c);
+}
+
+static void
+msg2html(register Sfio_t* ip, register Sfio_t* op, register int flags)
+{
+ register char* s;
+ register int c;
+ register int q;
+ register int p;
+
+ sfprintf(op, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\"><HTML><HEAD><!-- text massaged for external translation --></HEAD><BODY>\n");
+ sfprintf(op, "<OL START=\"550717\">\n");
+ p = q = 0;
+ while (s = sfgetr(ip, '\n', 1))
+ {
+ error_info.line++;
+ if (flags)
+ sfprintf(op, "<P>");
+ else
+ {
+ if (*s == '$')
+ {
+ if (p)
+ sfprintf(op, "<P>");
+ else
+ p = 1;
+ sfprintf(op, "<P CLASS=\"", s);
+ while (c = *s++)
+ encode(op, c);
+ sfprintf(op, "\">\n");
+ continue;
+ }
+ p = 0;
+ if (!isdigit(*s))
+ continue;
+ sfprintf(op, "<LI>");
+ while (isdigit(c = *s++))
+ sfputc(op, c);
+ sfprintf(op, "<LI>");
+ while (c && c != '"')
+ c = *s++;
+ if (!c)
+ s--;
+ else if (isspace(*s))
+ {
+ s++;
+ sfprintf(op, "<BR>");
+ }
+ }
+ for (;;)
+ {
+ switch (c = *s++)
+ {
+ case 0:
+ flags &= ~MSG_SPLICE;
+ if (q)
+ {
+ q = 0;
+ sfprintf(op, "\">");
+ }
+ sfputc(op, '\n');
+ break;
+ case '<':
+ sfprintf(op, "&lt;");
+ continue;
+ case '>':
+ sfprintf(op, "&gt;");
+ continue;
+ case '&':
+ sfprintf(op, "&amp;");
+ continue;
+ case '[':
+ sfprintf(op, "&#091;");
+ continue;
+ case ']':
+ sfprintf(op, "&#093;");
+ continue;
+ case '$':
+ if (!q)
+ {
+ q = 1;
+ sfprintf(op, "<P CLASS=\"");
+ }
+ sfputc(op, c);
+ while (isalnum(c = *s++))
+ sfputc(op, c);
+ s--;
+ continue;
+ case '%':
+ if (!q)
+ {
+ q = 1;
+ sfprintf(op, "<P CLASS=\"");
+ }
+ sfputc(op, c);
+ if (*s == '%')
+ sfputc(op, *s++);
+ else
+ do
+ {
+ if (!(c = *s++) || c == '"')
+ {
+ s--;
+ break;
+ }
+ encode(op, c);
+ } while (!isalpha(c) || (!islower(c) || c == 'h' || c == 'l') && isalpha(*s));
+ if (SPACE(s))
+ sfprintf(op, "&nbsp;");
+ continue;
+ case '"':
+ if (!(flags & MSG_RAW))
+ {
+ s = "";
+ continue;
+ }
+ /*FALLTHROUGH*/
+ case '\'':
+ case ':':
+ case '/':
+ case '+':
+ case '@':
+ if (!q)
+ {
+ q = 1;
+ sfprintf(op, "<P CLASS=\"");
+ }
+ /*FALLTHROUGH*/
+ case '.':
+ case ',':
+ sfputc(op, c);
+ if (SPACE(s))
+ sfprintf(op, "&nbsp;");
+ continue;
+ case '\\':
+ if (!(c = *s++))
+ {
+ flags |= MSG_SPLICE;
+ break;
+ }
+ if (c != 'n' && c != 't')
+ {
+ if (!q)
+ {
+ q = 1;
+ sfprintf(op, "<P CLASS=\"");
+ }
+ sfputc(op, '\\');
+ encode(op, c);
+ if (c == 'b')
+ {
+ for (;;)
+ {
+ if (!(c = *s++) || c == '"')
+ {
+ s--;
+ break;
+ }
+ if (c == '?')
+ {
+ if (*s != '?')
+ {
+ s--;
+ break;
+ }
+ sfputc(op, c);
+ sfputc(op, *s++);
+ continue;
+ }
+ if (c == '\\')
+ {
+ if (!*s)
+ break;
+ sfputc(op, c);
+ if (*s == 'a' || *s == 'b' || *s == '0')
+ {
+ sfputc(op, *s++);
+ break;
+ }
+ c = *s++;
+ }
+ encode(op, c);
+ }
+ }
+ else if (isdigit(c) && isdigit(*s))
+ {
+ sfputc(op, *s++);
+ if (isdigit(*s))
+ sfputc(op, *s++);
+ }
+ if (SPACE(s))
+ sfprintf(op, "&nbsp;");
+ continue;
+ }
+ /*FALLTHROUGH*/
+ case ' ':
+ case '\t':
+ while (isspace(*s) || *s == '\\' && (*(s + 1) == 'n' || *(s + 1) == 't') && s++)
+ s++;
+ if (*s == '"')
+ {
+ if (q)
+ {
+ q = 0;
+ sfprintf(op, " \">");
+ }
+ else
+ sfprintf(op, "<BR>");
+ continue;
+ }
+ c = ' ';
+ /*FALLTHROUGH*/
+ default:
+ if (q)
+ {
+ q = 0;
+ sfprintf(op, "\">");
+ }
+ sfputc(op, c);
+ continue;
+ }
+ break;
+ }
+ }
+ sfprintf(op, "</OL>\n");
+ sfprintf(op, "</BODY></HTML>\n");
+ error_info.line = 0;
+}
+
+int
+main(int argc, char** argv)
+{
+ int flags = 0;
+ Convert_f convert = msg2html;
+
+ NoP(argc);
+ error_info.id = "msgcvt";
+ for (;;)
+ {
+ switch (optget(argv, usage))
+ {
+ case 'h':
+ convert = msg2html;
+ continue;
+ case 'm':
+ convert = html2msg;
+ continue;
+ case 'r':
+ flags |= MSG_RAW;
+ continue;
+ case '?':
+ error(ERROR_USAGE|4, "%s", opt_info.arg);
+ continue;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ continue;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ if (error_info.errors)
+ error(ERROR_USAGE|4, "%s", optusage(NiL));
+ (*convert)(sfstdin, sfstdout, flags);
+ return error_info.errors != 0;
+}
diff --git a/usr/src/cmd/ast/msgcc/msggen.c b/usr/src/cmd/ast/msgcc/msggen.c
new file mode 100644
index 0000000000..5c34d20c40
--- /dev/null
+++ b/usr/src/cmd/ast/msgcc/msggen.c
@@ -0,0 +1,522 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 2000-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: msggen (AT&T Research) 2002-03-11 $\n]"
+USAGE_LICENSE
+"[+NAME?msggen - generate a machine independent formatted message catalog]"
+"[+DESCRIPTION?\bmsggen\b merges the message text source files \amsgfile\a"
+" into a machine independent formatted message catalog \acatfile\a."
+" The file \acatfile\a will be created if it does not already exist."
+" If \acatfile\a does exist, its messages will be included in the new"
+" \acatfile\a. If set and message numbers collide, the new message"
+" text defined in \amsgfile\a will replace the old message text"
+" currently contained in \acatfile\a. Non-ASCII characters must be"
+" UTF-8 encoded. \biconv\b(1) can be used to convert to/from UTF-8.]"
+"[f:format?List the \bprintf\b(3) format signature for each message in"
+" \acatfile\a. A format signature is one line containing one character"
+" per format specification:]{"
+" [c?char]"
+" [d?double]"
+" [D?long double]"
+" [f?float]"
+" [h?short]"
+" [i?int]"
+" [j?long long]"
+" [l?long]"
+" [p?void*]"
+" [s?string]"
+" [t?ptrdiff_t]"
+" [z?size_t]"
+" [???unknown]"
+"}"
+"[l:list?List \acatfile\a in UTF-8 \amsgfile\a form.]"
+"[s:set?Convert the \acatfile\a operand to a message set number and"
+" print the number on the standard output.]"
+"[+EXTENDED DESCRIPTION?Message text source files are in \bgencat\b(1)"
+" format, defined as follows. Note that the fields of a message text"
+" source line are separated by a single blank character. Any other"
+" blank characters are considered as being part of the subsequent"
+" field. The \bNL_*\b constants are defined in one or both of"
+" \b<limits.h>\b and \b<nl_types.h>\b.]{"
+" [+$ \acomment\a?A line beginning with \b$\b followed by a"
+" blank character is treated as a comment.]"
+" [+$delset \an\a \acomment\a?This line deletes message set"
+" \an\a from an existing message catalog. \an\a"
+" denotes the set number [1, \bNL_SETMAX\b]]. Any"
+" text following the set number is treated as a"
+" comment.]"
+" [+$quote \ac\a?This line specifies an optional quote"
+" character \ac\a, which can be used to surround"
+" \amessage-text\a so that trailing spaces or"
+" empty messages are visible in a message source"
+" line. By default, or if an empty \b$quote\b"
+" directive is supplied, no quoting of \amessage-text\a"
+" will be recognized.]"
+" [+$set \an\a \acomment\a?This line specifies the set"
+" identifier of the following messages until the next"
+" \b$set\b or end-of-file appears. \an\a denotes the set"
+" identifier, which is defined as a number in the range"
+" [1, \bNL_SETMAX\b]]. Set numbers need not be"
+" contiguous. Any text following the set identifier is"
+" treated as a comment. If no \b$set\b directive is"
+" specified in a message text source file, all messages"
+" will be located in message set \b1\b.]"
+" [+$translation \aidentification\a \aYYYY-MM-DD\a[,...]]?Append"
+" translation info to the message catalog header. Only"
+" the newest date for a given \aidentification\a"
+" is retained in the catalog. Multiple translation lines"
+" are combined into a single \b,\b separated list.]"
+" [+\am\a \amessage-text\a?\am\a denotes the message identifier,"
+" which is defined as a number in the range"
+" [1, \bNL_MSGMAX\b]]. The message-text is stored in the"
+" message catalogue with the set identifier specified by"
+" the last \b$set\b directive, and with message"
+" identifier \am\a. If the \amessage-text\a is empty,"
+" and a blank character field separator is present, an"
+" empty string is stored in the message catalogue. If a"
+" message source line has a message number, but neither"
+" a field separator nor \amessage-text\a, the existing"
+" message with that number (if any) is deleted from the"
+" catalogue. Message identifiers need not be contiguous."
+" There are no \amessage-text\a length restrictions.]"
+"}"
+
+"\n"
+"\ncatfile [ msgfile ]\n"
+"\n"
+
+"[+SEE ALSO?\bgencat\b(1), \biconv\b(1), \bmsgcc\b(1), \btranslate\b(1),"
+" \bfmtfmt\b(3)]"
+;
+
+#include <ast.h>
+#include <ctype.h>
+#include <ccode.h>
+#include <error.h>
+#include <mc.h>
+
+typedef struct Xl_s
+{
+ struct Xl_s* next;
+ char* date;
+ char name[1];
+} Xl_t;
+
+/*
+ * append s to the translation list
+ */
+
+static Xl_t*
+translation(Xl_t* xp, register char* s)
+{
+ register Xl_t* px;
+ register char* t;
+ char* d;
+ char* e;
+
+ do
+ {
+ for (; isspace(*s); s++);
+ for (d = e = 0, t = s; *t; t++)
+ if (*t == ',')
+ {
+ e = t;
+ *e++ = 0;
+ break;
+ }
+ else if (isspace(*t))
+ d = t;
+ if (d)
+ {
+ *d++ = 0;
+ for (px = xp; px; px = px->next)
+ if (streq(px->name, s))
+ {
+ if (strcoll(px->date, d) < 0)
+ {
+ free(px->date);
+ if (!(px->date = strdup(d)))
+ error(ERROR_SYSTEM|3, "out of space [translation]");
+ }
+ break;
+ }
+ if (!px)
+ {
+ if (!(px = newof(0, Xl_t, 1, strlen(s))) || !(px->date = strdup(d)))
+ error(ERROR_SYSTEM|3, "out of space [translation]");
+ strcpy(px->name, s);
+ px->next = xp;
+ xp = px;
+ }
+ }
+ } while (s = e);
+ return xp;
+}
+
+/*
+ * sfprintf() with ccmaps(from,to)
+ */
+
+static int
+ccsfprintf(int from, int to, Sfio_t* sp, const char* format, ...)
+{
+ va_list ap;
+ Sfio_t* tp;
+ char* s;
+ int n;
+
+ va_start(ap, format);
+ if (from == to)
+ n = sfvprintf(sp, format, ap);
+ else if (tp = sfstropen())
+ {
+ n = sfvprintf(tp, format, ap);
+ s = sfstrbase(tp);
+ ccmaps(s, n, from, to);
+ n = sfwrite(sp, s, n);
+ sfstrclose(tp);
+ }
+ else
+ n = -1;
+ return n;
+}
+
+int
+main(int argc, char** argv)
+{
+ register Mc_t* mc;
+ register char* s;
+ register char* t;
+ register int c;
+ register int q;
+ register int i;
+ int num;
+ char* b;
+ char* e;
+ char* catfile;
+ char* msgfile;
+ Sfio_t* sp;
+ Sfio_t* mp;
+ Sfio_t* tp;
+ Xl_t* px;
+ Xl_t* bp;
+
+ Xl_t* xp = 0;
+ int format = 0;
+ int list = 0;
+ int set = 0;
+
+ NoP(argc);
+ error_info.id = "msggen";
+ for (;;)
+ {
+ switch (optget(argv, usage))
+ {
+ case 'f':
+ format = list = 1;
+ continue;
+ case 'l':
+ list = 1;
+ continue;
+ case 's':
+ set = 1;
+ continue;
+ case '?':
+ error(ERROR_USAGE|4, "%s", opt_info.arg);
+ continue;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ continue;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ if (error_info.errors || !(catfile = *argv++))
+ error(ERROR_USAGE|4, "%s", optusage(NiL));
+
+ /*
+ * set and list only need catfile
+ */
+
+ if (set)
+ {
+ sfprintf(sfstdout, "%d\n", mcindex(catfile, NiL, NiL, NiL));
+ return error_info.errors != 0;
+ }
+ else if (list)
+ {
+ if (!(sp = sfopen(NiL, catfile, "r")))
+ error(ERROR_SYSTEM|3, "%s: cannot read catalog", catfile);
+ if (!(mc = mcopen(sp)))
+ error(ERROR_SYSTEM|3, "%s: catalog content error", catfile);
+ sfclose(sp);
+ if (format)
+ {
+ for (set = 1; set <= mc->num; set++)
+ if (mc->set[set].num)
+ {
+ sfprintf(sfstdout, "$set %d\n", set);
+ for (num = 1; num <= mc->set[set].num; num++)
+ if (s = mc->set[set].msg[num])
+ sfprintf(sfstdout, "%d \"%s\"\n", num, fmtfmt(s));
+ }
+ }
+ else
+ {
+ if (*mc->translation)
+ {
+ ccsfprintf(CC_NATIVE, CC_ASCII, sfstdout, "$translation ");
+ sfprintf(sfstdout, "%s", mc->translation);
+ ccsfprintf(CC_NATIVE, CC_ASCII, sfstdout, "\n");
+ }
+ ccsfprintf(CC_NATIVE, CC_ASCII, sfstdout, "$quote \"\n");
+ for (set = 1; set <= mc->num; set++)
+ if (mc->set[set].num)
+ {
+ ccsfprintf(CC_NATIVE, CC_ASCII, sfstdout, "$set %d\n", set);
+ for (num = 1; num <= mc->set[set].num; num++)
+ if (s = mc->set[set].msg[num])
+ {
+ ccsfprintf(CC_NATIVE, CC_ASCII, sfstdout, "%d \"", num);
+ while (c = *s++)
+ {
+ /*INDENT...*/
+
+ switch (c)
+ {
+ case 0x22: /* " */
+ case 0x5C: /* \ */
+ sfputc(sfstdout, 0x5C);
+ break;
+ case 0x07: /* \a */
+ c = 0x61;
+ sfputc(sfstdout, 0x5C);
+ break;
+ case 0x08: /* \b */
+ c = 0x62;
+ sfputc(sfstdout, 0x5C);
+ break;
+ case 0x0A: /* \n */
+ c = 0x6E;
+ sfputc(sfstdout, 0x5C);
+ break;
+ case 0x0B: /* \v */
+ c = 0x76;
+ sfputc(sfstdout, 0x5C);
+ break;
+ case 0x0C: /* \f */
+ c = 0x66;
+ sfputc(sfstdout, 0x5C);
+ break;
+ case 0x0D: /* \r */
+ c = 0x72;
+ sfputc(sfstdout, 0x5C);
+ break;
+ }
+
+ /*...UNDENT*/
+ sfputc(sfstdout, c);
+ }
+ ccsfprintf(CC_NATIVE, CC_ASCII, sfstdout, "\"\n");
+ }
+ }
+ }
+ mcclose(mc);
+ return error_info.errors != 0;
+ }
+ else if (!(msgfile = *argv++) || *argv)
+ error(3, "exactly one message file must be specified");
+
+ /*
+ * open the files and handles
+ */
+
+ if (!(tp = sfstropen()))
+ error(ERROR_SYSTEM|3, "out of space [string stream]");
+ if (!(mp = sfopen(NiL, msgfile, "r")))
+ error(ERROR_SYSTEM|3, "%s: cannot read message file", msgfile);
+ sp = sfopen(NiL, catfile, "r");
+ if (!(mc = mcopen(sp)))
+ error(ERROR_SYSTEM|3, "%s: catalog content error", catfile);
+ if (sp)
+ sfclose(sp);
+ xp = translation(xp, mc->translation);
+
+ /*
+ * read the message file
+ */
+
+ q = 0;
+ set = 1;
+ error_info.file = msgfile;
+ while (s = sfgetr(mp, '\n', 1))
+ {
+ error_info.line++;
+ if (!*s)
+ continue;
+ if (*s == '$')
+ {
+ if (!*++s || isspace(*s))
+ continue;
+ for (t = s; *s && !isspace(*s); s++);
+ if (*s)
+ *s++ = 0;
+ if (streq(t, "delset"))
+ {
+ while (isspace(*s))
+ s++;
+ num = (int)strtol(s, NiL, 0);
+ if (num < mc->num && mc->set[num].num)
+ for (i = 1; i <= mc->set[num].num; i++)
+ mcput(mc, num, i, NiL);
+ }
+ else if (streq(t, "quote"))
+ q = *s ? *s : 0;
+ else if (streq(t, "set"))
+ {
+ while (isspace(*s))
+ s++;
+ num = (int)strtol(s, &e, 0);
+ if (e != s)
+ set = num;
+ else
+ error(2, "set number expected");
+ }
+ else if (streq(t, "translation"))
+ xp = translation(xp, s);
+ }
+ else
+ {
+ t = s + sfvalue(mp);
+ num = (int)strtol(s, &e, 0);
+ if (e != s)
+ {
+ s = e;
+ if (!*s)
+ {
+ if (mcput(mc, set, num, NiL))
+ error(2, "(%d,%d): cannot delete message", set, num);
+ }
+ else if (isspace(*s++))
+ {
+ if (t > (s + 1) && *(t -= 2) == '\\')
+ {
+ sfwrite(tp, s, t - s);
+ while (s = sfgetr(mp, '\n', 0))
+ {
+ error_info.line++;
+ t = s + sfvalue(mp);
+ if (t <= (s + 1) || *(t -= 2) != '\\')
+ break;
+ sfwrite(tp, s, t - s);
+ }
+ if (!(s = sfstruse(tp)))
+ error(ERROR_SYSTEM|3, "out of space");
+ }
+ if (q)
+ {
+ if (*s++ != q)
+ {
+ error(2, "(%d,%d): %c quote expected", set, num, q);
+ continue;
+ }
+ b = t = s;
+ while (c = *s++)
+ {
+ if (c == '\\')
+ {
+ c = chresc(s - 1, &e);
+ s = e;
+ if (c)
+ *t++ = c;
+ else
+ error(1, "nul character ignored");
+ }
+ else if (c == q)
+ break;
+ else
+ *t++ = c;
+ }
+ if (*s)
+ {
+ error(2, "(%d,%d): characters after quote not expected", set, num);
+ continue;
+ }
+ *t = 0;
+ s = b;
+ }
+ if (mcput(mc, set, num, s))
+ error(2, "(%d,%d): cannot add message", set, num);
+ }
+ else
+ error(2, "message text expected");
+ }
+ else
+ error(2, "message number expected");
+ }
+ }
+ error_info.file = 0;
+ error_info.line = 0;
+
+ /*
+ * fix up the translation record
+ */
+
+ if (xp)
+ {
+ t = "";
+ for (;;)
+ {
+ for (bp = 0, px = xp; px; px = px->next)
+ if (px->date && (!bp || strcoll(bp->date, px->date) < 0))
+ bp = px;
+ if (!bp)
+ break;
+ sfprintf(tp, "%s%s %s", t, bp->name, bp->date);
+ t = ", ";
+ bp->date = 0;
+ }
+ if (!(mc->translation = sfstruse(tp)))
+ error(ERROR_SYSTEM|3, "out of space");
+ }
+
+ /*
+ * dump the catalog to a local temporary
+ * rename if no errors
+ */
+
+ if (!(s = pathtemp(NiL, 0, "", error_info.id, NiL)) || !(sp = sfopen(NiL, s, "w")))
+ error(ERROR_SYSTEM|3, "%s: cannot write catalog file", catfile);
+ if (mcdump(mc, sp) || mcclose(mc) || sfclose(sp))
+ {
+ remove(s);
+ error(ERROR_SYSTEM|3, "%s: temporary catalog file write error", s);
+ }
+ remove(catfile);
+ if (rename(s, catfile))
+ error(ERROR_SYSTEM|3, "%s: cannot rename from temporary catalog file %s", catfile, s);
+ return error_info.errors != 0;
+}
diff --git a/usr/src/cmd/ast/msgcc/msgget.c b/usr/src/cmd/ast/msgcc/msgget.c
new file mode 100644
index 0000000000..bd06c6d343
--- /dev/null
+++ b/usr/src/cmd/ast/msgcc/msgget.c
@@ -0,0 +1,109 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 2000-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: msgget (AT&T Research) 2001-04-21 $\n]"
+USAGE_LICENSE
+"[+NAME?msgget - get a message from a message catalog]"
+"[+DESCRIPTION?\bmsgget\b gets the message corresponding to the parameters."
+" If \alocale\a is \b-\b then the current locale is used. \acommand\a"
+" may be specified for command specific messages. \acatalog\a specifies"
+" the message catalog name. [\aset\a.]]\anumber\a identifies the message"
+" by message \anumber\a and an optional message \aset\a; if specified as"
+" \b-\b then the message set and number are determined by looking up"
+" \atext\a in the corresponding \bC\b locale message catalog.]"
+
+"\n"
+"\nlocale [command:]catalog [set.]number [ text ]\n"
+"\n"
+
+"[+SEE ALSO?\biconv\b(1), \bmsgcc\b(1), \bmsggen\b(1)]"
+;
+
+#include <ast.h>
+#include <error.h>
+#include <mc.h>
+
+int
+main(int argc, char** argv)
+{
+ register Mc_t* mc;
+ register char* s;
+ char* loc;
+ char* cmd;
+ char* cat;
+ char* msg;
+ int set;
+ int num;
+ Sfio_t* sp;
+ char path[PATH_MAX];
+
+ NoP(argc);
+ error_info.id = "msgget";
+ for (;;)
+ {
+ switch (optget(argv, usage))
+ {
+ case '?':
+ error(ERROR_USAGE|4, "%s", opt_info.arg);
+ continue;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ continue;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ if (error_info.errors || !(loc = *argv++) || !(cmd = *argv++) || !(s = *argv++))
+ error(ERROR_USAGE|4, "%s", optusage(NiL));
+ if (streq(s, "-"))
+ set = num = 0;
+ else
+ mcindex(s, NiL, &set, &num);
+ if (!(msg = *argv++))
+ msg = "";
+ else if (*argv)
+ error(ERROR_USAGE|4, "%s", optusage(NiL));
+ if (streq(loc, "-"))
+ loc = 0;
+ if (cat = strchr(cmd, ':'))
+ *cat++ = 0;
+ if (!mcfind(path, loc, cmd, LC_MESSAGES, 0) && (!cat || !mcfind(path, loc, cat, LC_MESSAGES, 0)))
+ {
+ if (cat)
+ *--cat = ':';
+ error(3, "%s: cannot locate message catalog", cmd);
+ }
+ if (!(sp = sfopen(NiL, path, "r")))
+ error(ERROR_SYSTEM|3, "%s: cannot read message catalog", path);
+ if (!(mc = mcopen(sp)))
+ error(3, "%s: invalid message catalog", path);
+ if (set)
+ s = mcget(mc, set, num, msg);
+ else
+ s = errorx(loc, cmd, cat, msg);
+ sfputr(sfstdout, s, '\n');
+ return error_info.errors != 0;
+}
diff --git a/usr/src/cmd/ksh/Makefile b/usr/src/cmd/ksh/Makefile
new file mode 100644
index 0000000000..2412f65264
--- /dev/null
+++ b/usr/src/cmd/ksh/Makefile
@@ -0,0 +1,81 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+SHELL=/usr/bin/ksh
+
+include ../../Makefile.ksh93switch
+
+$(BINKSH_IS_KSH93)PROG= ksh
+$(BINKSH_IS_KSH93)USRKSH_ALIAS_LIST=ksh ksh93 rksh rksh93 pfksh
+
+$(BINKSH_ISNOT_KSH93)PROG= ksh93
+$(BINKSH_ISNOT_KSH93)USRKSH_ALIAS_LIST=ksh93 rksh93
+
+include ../Makefile.cmd
+
+SUBDIRS= $(MACH)
+$(BUILD64)SUBDIRS += $(MACH64)
+
+# Serialise the build to avoid that we run the test suite for 32bit
+# and 64bit in parallel
+.NO_PARALLEL: $(SUBDIRS)
+
+all := TARGET = all
+install := TARGET = install
+clean := TARGET = clean
+clobber := TARGET = clobber
+lint := TARGET = lint
+testshell := TARGET = testshell
+
+.KEEP_STATE:
+
+all clean clobber lint testshell: $(SUBDIRS)
+
+# dummy file since AST/ksh doesn't use *.po files
+# (and "ksh" is just a frontend which calls directly into libshell,
+# e.g. there are no l10n strings here)
+$(PROG).po:
+ $(RM) ksh.po ksh93.po
+ touch $(PROG).po
+
+install: $(ISAEXEC) $(SUBDIRS)
+ $(RM) $(ROOTPROG)
+ $(LN) $(ISAEXEC) $(ROOTPROG)
+ @(set -o xtrace ; \
+ for i in $(USRKSH_ALIAS_LIST) ; do \
+ [[ "$$i" = "$(PROG)" ]] && continue ; \
+ $(RM) "$(ROOTBIN)/$$i" ; \
+ $(LN) "$(ROOTBIN)/$(PROG)" "$(ROOTBIN)/$$i" ; \
+ done \
+ )
+
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
+
+include ../Makefile.targ
diff --git a/usr/src/cmd/ksh/Makefile.com b/usr/src/cmd/ksh/Makefile.com
new file mode 100644
index 0000000000..3094d06f89
--- /dev/null
+++ b/usr/src/cmd/ksh/Makefile.com
@@ -0,0 +1,110 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+SHELL=/usr/bin/ksh
+
+include ../../../Makefile.ksh93switch
+
+$(BINKSH_IS_KSH93)PROG= ksh
+$(BINKSH_IS_KSH93)USRKSH_ALIAS_LIST=ksh ksh93 rksh rksh93 pfksh
+
+$(BINKSH_ISNOT_KSH93)PROG= ksh93
+$(BINKSH_ISNOT_KSH93)USRKSH_ALIAS_LIST=ksh93 rksh93
+
+OBJECTS= \
+ pmain.o
+
+LIBSHELLSRC=../../../lib/libshell/common/sh
+
+SRCS= $(OBJECTS:%.o=$(LIBSHELLSRC)/%.c)
+
+GROUP= bin
+LDLIBS += -lshell
+
+# 1. Make sure that the -D/-U defines in CFLAGS below are in sync
+# with usr/src/lib/libshell/Makefile.com
+# 2. We use "=" here since using $(CPPFLAGS.master) is very tricky in our
+# case - it MUST come as the last element but future changes in -D options
+# may then cause silent breakage in the AST sources because the last -D
+# option specified overrides previous -D options so we prefer the current
+# way to explicitly list each single flag.
+CPPFLAGS = \
+ $(DTEXTDOM) $(DTS_ERRNO) \
+ $(LIBSHELLCPPFLAGS)
+
+CFLAGS += \
+ $(CCVERBOSE) \
+ -xstrconst
+CFLAGS64 += \
+ $(CCVERBOSE) \
+ -xstrconst
+
+# Set common AST build flags (e.g., needed to support the math stuff).
+include ../../../Makefile.ast
+
+.KEEP_STATE:
+
+%.o: $(LIBSHELLSRC)/%.c
+ $(COMPILE.c) -c -o $@ $<
+ $(POST_PROCESS_O)
+
+all: $(PROG)
+
+# We explicitly delete "ksh" and "ksh93" to catch changes in
+# BUILD_KSH93_AS_BINKSH (see Makefile.ksh93switch)
+# and soft-link $(PROG) to ksh/ksh93 below because ksh93 test
+# suite seems to require that ksh93 is available as "ksh" in
+# ${PATH} (see comment about "io.sh" in Makefile.testshell).
+$(PROG): $(OBJECTS)
+ $(RM) ksh ksh93
+ $(LINK.c) $(OBJECTS) -o $@ $(LDLIBS)
+ $(POST_PROCESS)
+ (set +o errexit ; \
+ [[ ! -x ksh93 ]] && ln $(PROG) ksh93 ; \
+ [[ ! -x ksh ]] && ln $(PROG) ksh ; \
+ true \
+ )
+
+clean:
+ $(RM) $(OBJECTS)
+
+# We explicitly delete "ksh" and "ksh93" to catch changes in
+# BUILD_KSH93_AS_BINKSH (see Makefile.ksh93switch)
+CLOBBERFILES += \
+ ksh \
+ ksh93
+
+#
+# ksh is not lint-clean yet; fake up a target. (You can use
+# "make lintcheck" to actually run lint; please send all lint fixes
+# upstream (to AT&T) so the next update will pull them into ON.)
+#
+lint:
+ @ print "usr/src/cmd/ksh is not lint-clean: skipping"
+ @ $(TRUE)
+
+include ../Makefile.testshell
diff --git a/usr/src/cmd/ksh/Makefile.testshell b/usr/src/cmd/ksh/Makefile.testshell
new file mode 100644
index 0000000000..6e9a264f0c
--- /dev/null
+++ b/usr/src/cmd/ksh/Makefile.testshell
@@ -0,0 +1,163 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+#
+# run the ksh93 minimum set of tests
+#
+# Notes:
+# - "builtins.sh" may fail in some locales like this:
+# -- snip --
+# ## Running ksh test: LANG='zh_TW.EUC' script='builtins.sh'
+# builtins.sh[274]: printf "%T" now
+# -- snip --
+#
+# - "options.sh" may currently fail in some locales with:
+# -- snip --
+# options.sh[145]: -G ** failed -- expected 'bam.c bar bar.c bar/bam.c bar/foo.c foo foo/bam.c', got 'bam.c bar bar/bam.c bar.c bar/foo.c foo foo/bam.c'
+# options.sh[149]: -G **/*.c failed -- expected 'bam.c bar.c bar/bam.c bar/foo.c foo/bam.c', got 'bam.c bar/bam.c bar.c bar/foo.c foo/bam.c'
+# -- snip --
+# This may be simply a different sort order or a bug in the test suite.
+# Currently under investigation.
+#
+# - "io.sh" may fail due a subtle bug in ksh93 or the test suite which
+# only happens when ksh93 is NOT called "ksh"; to work around the
+# problem the test sequence currently uses $(SRC)/cmd/ksh/$(CMDTRANSMACH)/ksh
+# instead of $(SRC)/cmd/ksh/$(CMDTRANSMACH)/$(PROG) until we+upstream figure
+# out what exactly is going wrong in this case.
+# -- snip --
+# ./close0[2]: ./close1: cannot execute [Exec format error]
+# io.sh[81]: picked up file descriptor zero for opening script file
+# -- snip --
+#
+# - These tests need a working system clock, otherwise they'll bite you.
+#
+# - The test frontend in this Makefile should be rewritten in ksh93
+# instead of the current /usr/bin/ksh (=ksh88i). This would be far less
+# complicated.
+#
+# - More locales should be tested here (via ON_KSH_TEST_LOCALES below).
+# Locales like "ru_RU.KOI8-R","de_DE.UTF-8", "is_IS.ISO8859-1",
+# "is_IS.UTF-8" and "nl_BE.ISO8859-15" are on our wishlist - but
+# that is getting little bit more compliciated because these locales use
+# ',' as decimal delimter. The best solution may be to wait for ksh93
+# being integrated into OS/Net and then change the test sequence to
+# use ksh93's associate/compound variables (this may require a flag
+# day... ;-( ).
+# The current list was mainly composed to cover various encodings and
+# all important markets based on suggestions by Sun's i18n team.
+#
+# - Due to the timing sensitivity of some of the tests, these tests should
+# be run on a quiet system with no other activity.
+#
+
+TESTSRC= $(LIBSHELLSRC)/../tests
+
+# ON_KSH_TEST_LOCALES can be overridden via
+# $ export ON_KSH_TEST_LOCALES=<value> # before $ make install #
+ON_KSH_TEST_LOCALES = \
+ C \
+ en_US en_US.UTF-8 \
+ he_IL.UTF-8 \
+ hi_IN.UTF-8 \
+ ja_JP.PCK ja_JP.UTF-8 ja_JP.eucJP \
+ ko_KR.EUC \
+ th_TH.TIS620 \
+ zh_CN.EUC zh_CN.GBK zh_CN.GB18030 zh_CN.UTF-8 \
+ zh_HK.BIG5HK \
+ zh_TW.BIG5 zh_TW.EUC zh_TW.UTF-8
+
+# ON_KSH_TEST_LIST can be overridden via
+# $ export ON_KSH_TEST_LIST=<value> # before $ make install #
+ON_KSH_TEST_LIST = $(TESTSRC)/*.sh
+
+# Flag to control whether we should make test failures non-fatal
+ON_KSH_TEST_IGNORE_TESTFAILURE=false
+
+# We must wait for other things in this subdir to finish before running
+# the test suite, otherwise we may run into trouble that this activity
+# may disturb the test suite run (resulting in weird "heisenbug"-like
+# test failures).
+testshell: $(PROG)
+ @ \
+ print '# NOTE: Make sure your binaries in ROOT match your kernel!' ; \
+ ( \
+ set +o errexit ; \
+ export PATH="$(SRC)/cmd/ksh/$(CMDTRANSMACH):/bin:/usr/bin" ; \
+ printf "# which ksh='%s', ksh93='%s'\n" \
+ "$$(which ksh)" "$$(which ksh93)" ; \
+ ) ; \
+ if [[ "$$(isalist | fgrep "$(CMDTRANSMACH)")" = "" ]] ; then \
+ printf \
+ "# ISA='%s' not available on this system, skipping tests...\n" \
+ "$(CMDTRANSMACH)" ; \
+ exit 0 ; \
+ fi ; \
+ exec 2>&1 ; \
+ (supported_locales="$$(/usr/bin/locale -a)" ; \
+ for test_lang in $(ON_KSH_TEST_LOCALES) ; do \
+ if [[ "$$(print "$${supported_locales}" | \
+ egrep "^$${test_lang}\$$")" = "" ]] ; then \
+ printf \
+ "# Locale '%s' not supported, skipping tests...\n" \
+ "$${test_lang}" ; \
+ continue ; \
+ fi ; \
+ (for test_item in $(ON_KSH_TEST_LIST) ; do \
+ [[ "$${test_item}" = "$(TESTSRC)/builtins.sh" || \
+ "$${test_item}" = "$(TESTSRC)/options.sh" ]] || \
+ $(ON_KSH_TEST_IGNORE_TESTFAILURE) && \
+ set +o errexit ; \
+ printf \
+ "## Running %s test: LANG='%s' script='%s'\n" \
+ "$(CMDTRANSMACH)/ksh" \
+ "$${test_lang}" \
+ "$$(basename "$${test_item}")"; \
+ ( \
+ test_output="$$( ( \
+ export \
+ SHELL="$(SRC)/cmd/ksh/$(CMDTRANSMACH)/ksh" \
+ LD_LIBRARY_PATH_64="$(ROOTLIB64)/" \
+ LD_LIBRARY_PATH_32="$(ROOTLIB)/" ; \
+ LD_LIBRARY_PATH="$(ROOTLIB64)/:$(ROOTLIB)/" ; \
+ "$${SHELL}" "$(TESTSRC)/shtests" -t \
+ LD_LIBRARY_PATH_64="$${LD_LIBRARY_PATH_64}" \
+ LD_LIBRARY_PATH_32="$${LD_LIBRARY_PATH_32}" \
+ LD_LIBRARY_PATH="$${LD_LIBRARY_PATH}" \
+ SHELL="$${SHELL}" \
+ LANG="$${test_lang}" \
+ LC_ALL="$${test_lang}" \
+ "$${test_item}" \
+ ) 2>&1 | while read ; do \
+ printf "#\t%s\n" "$${REPLY}" ; \
+ done | tee /dev/stderr)" ; \
+ [[ "$$(print "$${test_output}" | \
+ egrep 'passed \[ .* tests 0 errors \]')" != "" ]] || \
+ (print "##> test failed" ; exit 1) \
+ ) ; \
+ set -o errexit ; \
+ done) ; \
+ done)
diff --git a/usr/src/cmd/ksh/amd64/Makefile b/usr/src/cmd/ksh/amd64/Makefile
new file mode 100644
index 0000000000..093e92da1e
--- /dev/null
+++ b/usr/src/cmd/ksh/amd64/Makefile
@@ -0,0 +1,47 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+# Specify the MACH we currently use to build and test ksh
+CMDTRANSMACH= $(MACH64)
+
+include ../../Makefile.cmd
+include ../../Makefile.cmd.64
+
+include ../Makefile.com
+
+install: all $(ROOTPROG64)
+ @ \
+ (print "# Installing 64bit $(PROG) aliases $(USRKSH_ALIAS_LIST)" ; \
+ set -o xtrace ; \
+ for i in $(USRKSH_ALIAS_LIST) ; do \
+ [[ "$$i" = "$(PROG)" ]] && continue ; \
+ $(RM) "$(ROOTBIN64)/$$i" ; \
+ $(LN) "$(ROOTBIN64)/$(PROG)" "$(ROOTBIN64)/$$i" ; \
+ done \
+ )
+
+include ../../Makefile.targ
diff --git a/usr/src/cmd/ksh/i386/Makefile b/usr/src/cmd/ksh/i386/Makefile
new file mode 100644
index 0000000000..da5146beb6
--- /dev/null
+++ b/usr/src/cmd/ksh/i386/Makefile
@@ -0,0 +1,46 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+# Specify the MACH we currently use to build and test ksh
+CMDTRANSMACH= $(MACH)
+
+include ../../Makefile.cmd
+
+include ../Makefile.com
+
+install: all $(ROOTPROG32)
+ @ \
+ (print "# Installing 32bit $(PROG) aliases $(USRKSH_ALIAS_LIST)" ; \
+ set -o xtrace ; \
+ for i in $(USRKSH_ALIAS_LIST) ; do \
+ [[ "$$i" = "$(PROG)" ]] && continue ; \
+ $(RM) "$(ROOTBIN32)/$$i" ; \
+ $(LN) "$(ROOTBIN32)/$(PROG)" "$(ROOTBIN32)/$$i" ; \
+ done \
+ )
+
+include ../../Makefile.targ
diff --git a/usr/src/cmd/ksh/sparc/Makefile b/usr/src/cmd/ksh/sparc/Makefile
new file mode 100644
index 0000000000..da5146beb6
--- /dev/null
+++ b/usr/src/cmd/ksh/sparc/Makefile
@@ -0,0 +1,46 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+# Specify the MACH we currently use to build and test ksh
+CMDTRANSMACH= $(MACH)
+
+include ../../Makefile.cmd
+
+include ../Makefile.com
+
+install: all $(ROOTPROG32)
+ @ \
+ (print "# Installing 32bit $(PROG) aliases $(USRKSH_ALIAS_LIST)" ; \
+ set -o xtrace ; \
+ for i in $(USRKSH_ALIAS_LIST) ; do \
+ [[ "$$i" = "$(PROG)" ]] && continue ; \
+ $(RM) "$(ROOTBIN32)/$$i" ; \
+ $(LN) "$(ROOTBIN32)/$(PROG)" "$(ROOTBIN32)/$$i" ; \
+ done \
+ )
+
+include ../../Makefile.targ
diff --git a/usr/src/cmd/ksh/sparcv9/Makefile b/usr/src/cmd/ksh/sparcv9/Makefile
new file mode 100644
index 0000000000..093e92da1e
--- /dev/null
+++ b/usr/src/cmd/ksh/sparcv9/Makefile
@@ -0,0 +1,47 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+# Specify the MACH we currently use to build and test ksh
+CMDTRANSMACH= $(MACH64)
+
+include ../../Makefile.cmd
+include ../../Makefile.cmd.64
+
+include ../Makefile.com
+
+install: all $(ROOTPROG64)
+ @ \
+ (print "# Installing 64bit $(PROG) aliases $(USRKSH_ALIAS_LIST)" ; \
+ set -o xtrace ; \
+ for i in $(USRKSH_ALIAS_LIST) ; do \
+ [[ "$$i" = "$(PROG)" ]] && continue ; \
+ $(RM) "$(ROOTBIN64)/$$i" ; \
+ $(LN) "$(ROOTBIN64)/$(PROG)" "$(ROOTBIN64)/$$i" ; \
+ done \
+ )
+
+include ../../Makefile.targ
diff --git a/usr/src/cmd/nsadmin/Makefile b/usr/src/cmd/nsadmin/Makefile
index 5787f3a441..601d2dd963 100644
--- a/usr/src/cmd/nsadmin/Makefile
+++ b/usr/src/cmd/nsadmin/Makefile
@@ -2,9 +2,8 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,12 @@
# CDDL HEADER END
#
#
-#ident "%Z%%M% %I% %E% SMI"
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
#
-# Copyright (c) 1989, 2001 by Sun Microsystems, Inc.
-# All rights reserved.
+# ident "%Z%%M% %I% %E% SMI"
-PROG= profile .login system
+PROG= profile .login ksh.kshrc system
PROGSKEL= local.login local.profile local.cshrc
include ../Makefile.cmd
@@ -57,4 +56,3 @@ clobber:
$(RM) .login
lint:
-
diff --git a/usr/src/cmd/nsadmin/ksh.kshrc b/usr/src/cmd/nsadmin/ksh.kshrc
new file mode 100644
index 0000000000..0622755de0
--- /dev/null
+++ b/usr/src/cmd/nsadmin/ksh.kshrc
@@ -0,0 +1,42 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+#
+# This file is sourced by interactive ksh93 shells before ${HOME}/.kshrc
+#
+
+# Enable "gmacs" editor mode if the user did not set an input mode yet
+# (for example via ${EDITOR}, ${VISUAL} or any "set -o" flag)
+if [[ "$(set +o)" != ~(E)--(gmacs|emacs|vi)( |$) ]] ; then
+ set -o gmacs
+fi
+
+
+# enable multiline input mode
+#set -o multiline
+
diff --git a/usr/src/cmd/nsadmin/profile b/usr/src/cmd/nsadmin/profile
index bff9862af4..09a024ceeb 100644
--- a/usr/src/cmd/nsadmin/profile
+++ b/usr/src/cmd/nsadmin/profile
@@ -2,9 +2,8 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
@@ -19,7 +18,11 @@
#
# CDDL HEADER END
#
-#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.3 */
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "%Z%%M% %I% %E% SMI"
# The profile that all logins get before using their own .profile.
@@ -41,7 +44,7 @@ fi
# -rsh is given its environment in its .profile.
case "$0" in
--sh | -ksh | -jsh | -bash)
+-sh | -ksh | -ksh93 | -jsh | -bash)
if [ ! -f .hushlogin ]
then
diff --git a/usr/src/cmd/sgs/libelf/Makefile.com b/usr/src/cmd/sgs/libelf/Makefile.com
index 4e17b26de8..b7b4b5ac45 100644
--- a/usr/src/cmd/sgs/libelf/Makefile.com
+++ b/usr/src/cmd/sgs/libelf/Makefile.com
@@ -19,7 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
@@ -50,10 +50,14 @@ MISCOBJS64= nlist.o
OBJECTS= $(BLTOBJS) $(MACHOBJS) $(COMOBJS) $(CLASSOBJS) $(MISCOBJS)
+include $(SRC)/lib/Makefile.lib
+
DEMOFILES= Makefile README acom.c dcom.c \
pcom.c tpcom.c dispsyms.c
+DEMOFILESRCDIR= ../demo
+ROOTDEMODIRBASE=$(ROOT)/usr/demo/ELF
+ROOTDEMODIRS= $(ROOTDEMODIRBASE)
-include $(SRC)/lib/Makefile.lib
include $(SRC)/cmd/sgs/Makefile.com
#
@@ -107,15 +111,8 @@ ROOTFS_LINTLIB64= $(LINTLIB:%=$(ROOTFS_LIBDIR64)/%)
$(ROOTFS_DYNLIB) := FILEMODE= 755
$(ROOTFS_DYNLIB64) := FILEMODE= 755
-ROOTDEMODIR= $(ROOT)/usr/demo/ELF
-ROOTDEMOFILES= $(DEMOFILES:%=$(ROOTDEMODIR)/%)
-
LIBS = $(DYNLIB) $(LINTLIB)
CLEANFILES += $(LINTOUTS) $(BLTSRCS) $(BLTFILES) $(WARLOCKFILES)
-$(ROOTDEMODIR) := OWNER = root
-$(ROOTDEMODIR) := GROUP = bin
-$(ROOTDEMODIR) := DIRMODE = $(VAR_LIBELF_ROOTDEMODIR_DIRMODE)
-
-.PARALLEL: $(LIBS) $(ROOTDEMOFILES)
+.PARALLEL: $(LIBS)
diff --git a/usr/src/cmd/sgs/libelf/Makefile.targ b/usr/src/cmd/sgs/libelf/Makefile.targ
index d7d29db908..c816e490ec 100644
--- a/usr/src/cmd/sgs/libelf/Makefile.targ
+++ b/usr/src/cmd/sgs/libelf/Makefile.targ
@@ -49,9 +49,10 @@ pics/%.o: ../common/%.c
all: $(BLTSRCS) .WAIT $(LIBS) $(LIBLINKS)
-install: all .WAIT $(ROOTFS_LIBS) $(ROOTFS_LINKS) $(ROOTDEMODIR) \
+install: all .WAIT $(ROOTFS_LIBS) $(ROOTFS_LINKS) \
$(ROOTFS_LINTLIB) \
- .WAIT $(ROOTDEMOFILES) $(ROOTFS_LIBDIR)/$(LINTLIBSRC)
+ .WAIT $(ROOTDEMODIRS) .WAIT $(ROOTDEMOFILES) \
+ $(ROOTFS_LIBDIR)/$(LINTLIBSRC)
$(VAR_POUND_1)$(ROOTFS_LIBDIR)/$(LINTLIBSRC): ../common/$(LINTLIBSRC)
$(VAR_POUND_1) $(INS.file) ../common/$(LINTLIBSRC)
@@ -74,13 +75,6 @@ $(LIBLINKS):
include $(SRC)/lib/Makefile.targ
include $(SRC)/cmd/sgs/Makefile.targ
-
-$(ROOTDEMODIR):
- $(INS.dir)
-
-$(ROOTDEMODIR)/%: ../demo/%
- $(INS.file)
-
xlate.c: ../common/xlate.m4
$(M4) < ../common/xlate.m4 > xlate.c
diff --git a/usr/src/lib/Makefile b/usr/src/lib/Makefile
index 4a8c33ac76..44a056019e 100644
--- a/usr/src/lib/Makefile
+++ b/usr/src/lib/Makefile
@@ -79,6 +79,10 @@ SUBDIRS += \
libintl .WAIT \
../cmd/sgs/librtld_db \
libaio \
+ libast \
+ libdll \
+ libcmd \
+ libshell \
librt \
libadm \
libctf \
@@ -93,7 +97,6 @@ SUBDIRS += \
libpthread .WAIT \
libslp \
libbsdmalloc \
- libcmd \
libdoor \
libdevinfo \
libdladm \
@@ -132,6 +135,7 @@ SUBDIRS += \
libsysevent \
libnisdb \
libpool \
+ libpp \
libproc \
libproject \
libsendfile \
@@ -266,9 +270,11 @@ MSGSUBDIRS= \
gss_mechs/mech_dh \
gss_mechs/mech_krb5 \
krb5 \
+ libast \
libbsm \
libc \
libcfgadm \
+ libcmd \
libcontract \
libcurses \
libdhcpsvc \
@@ -276,6 +282,7 @@ MSGSUBDIRS= \
libipsecutil \
libdiskmgt \
libdladm \
+ libdll \
libgss \
libidmap \
libinetcfg \
@@ -284,11 +291,13 @@ MSGSUBDIRS= \
libpam \
libpicl \
libpool \
+ libpp \
libscf \
libsasl \
libldap5 \
libsecdb \
libshare \
+ libshell \
libsldap \
libslp \
libsmedia \
@@ -314,9 +323,11 @@ sparc_MSGSUBDIRS= \
HDRSUBDIRS= \
auditd_plugins \
+ libast \
libbrand \
libbsm \
libc \
+ libcmd \
libcmdutils \
libcontract \
libcpc \
@@ -328,6 +339,7 @@ HDRSUBDIRS= \
libdevinfo \
libdiskmgt \
libdladm \
+ libdll \
libdlpi \
libdhcpagent \
libdhcpsvc \
@@ -361,6 +373,7 @@ HDRSUBDIRS= \
libpicltree \
libplot \
libpool \
+ libpp \
libproc \
libraidcfg \
librcm \
@@ -372,6 +385,7 @@ HDRSUBDIRS= \
librsm \
libsasl \
libsec \
+ libshell \
libslp \
libsmedia \
libsqlite \
@@ -465,7 +479,9 @@ auditd_plugins: libbsm libnsl libsecdb
gss_mechs/mech_krb5: libgss libnsl libsocket libresolv pkcs11
libadt_jni: libbsm
$(CLOSED_BUILD)libc: $(CLOSED)/lib/libc_i18n
+libast: libsocket
libbsm: libtsol
+libcmd: libast libsocket libnsl
libcmdutils: libavl
libcontract: libnvpair
libdevid: libdevinfo
@@ -474,6 +490,7 @@ libdhcpagent: libsocket libdhcputil libuuid libdlpi
libdhcpsvc: libinetutil
libdhcputil: libnsl libgen libinetutil libdlpi
libdladm: libdlpi libdevinfo libinetutil libsocket
+libdll: libast
libdlpi: libinetutil
libdtrace: libproc libgen libctf
libdtrace_jni: libuutil libdtrace
@@ -492,11 +509,13 @@ libsecdb: libnsl
libsasl: libgss libsocket pkcs11 libmd
sasl_plugins: pkcs11 libgss libsocket libsasl
libsctp: libsocket
+libshell: libast libcmd libdll libsocket libsecdb
libsip: libmd5
libsocket: libnsl
libldap5: libsasl libsocket libnsl libmd
libsldap: libldap5 libtsol
libpool: libnvpair libexacct
+libpp: libast
libzonecfg: libc libsocket libnsl libuuid libnvpair libsysevent libsec \
libbrand libpool libscf
libproc: ../cmd/sgs/librtld_db ../cmd/sgs/libelf libctf
diff --git a/usr/src/lib/Makefile.asthdr b/usr/src/lib/Makefile.asthdr
new file mode 100644
index 0000000000..defc22d4cc
--- /dev/null
+++ b/usr/src/lib/Makefile.asthdr
@@ -0,0 +1,87 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+# Note: libast headers are generated by the AST build system outside OS/Net
+# (and then copied here) and depend on the architecture (e.g. "i386", "amd64",
+# "sparc", "sparcv9" etc. ...), we later merge them into one unified file
+# (see below)
+
+ROOTHDRDIR= $(ROOT)/usr/include/ast
+
+# Define the symbol used to distinguish between 32bit and 64bit parts of the
+# include file. We cannot use |_LP64| here because not every compiler (like
+# Studio 10/11/12) sets it by default (this doesn't harm because the AST
+# includes are OS- and platform-specific anyway) and we can't rely on the
+# system includes like <sys/isa_defs.h> because "/usr/bin/diff -D<symbol>"
+# adds the "#ifdef <symbol>" before any other content and "injecting" an
+# "#include <sys/isa_defs.h>" will alter the behaviour of the AST code
+# in unpredictable ways (e.g. the resulting code will not longer work).
+# Sun-Bug #6524070 ("RFE: Please set |_LP64| for 64bit platforms by default
+# (like gcc does)") has been filed against the Sun Studio compiler as RFE
+# to set |_LP64| for 64bit targets.
+# (INTEL_BLD is '#' for a Sparc build and SPARC_BLD is '#' for an Intel build)
+$(SPARC_BLD)AST64BITCPPSYMBOL = __sparcv9
+$(INTEL_BLD)AST64BITCPPSYMBOL = __amd64
+
+# We use a custom install sequence here to unify 32bit and 64bit AST includes
+# since we can only ship one set of includes. Therefore we use
+# "/usr/bin/diff -D <64bit>" (and for some exceptions a manual path) to
+# generate an unified version of the include files (and add a boilerplate text
+# which explains the interface stability status).
+# ToDo: Rewrite this in ksh93 to simplify the boilerplate generation
+$(ROOTHDRDIR)/%: $(HDRDIR32)/% $(HDRDIR64)/%
+ @mkdir -p tmpastinclude ; \
+ boilerplate="" \
+ boilerplate="$${boilerplate}/*\n" \
+ boilerplate="$${boilerplate} * BEGIN OpenSolaris section\n" \
+ boilerplate="$${boilerplate} * This is an unstable interface; changes may be made\n" \
+ boilerplate="$${boilerplate} * without notice.\n" \
+ boilerplate="$${boilerplate} * END OpenSolaris section\n" \
+ boilerplate="$${boilerplate} */\n" ; \
+ if [[ "$(@F)" = "ast_limits.h" || \
+ "$(@F)" = "ast_dirent.h" ]] ; then \
+ print "# Building (concatenation) $(@F)" ; \
+ ( \
+ print -n "$${boilerplate}" ; \
+ print '#ifndef $(AST64BITCPPSYMBOL)' ; \
+ cat "$(HDRDIR32)/$(@F)" ; \
+ print '#else /* $(AST64BITCPPSYMBOL) */' ; \
+ cat "$(HDRDIR64)/$(@F)" ; \
+ print '#endif /* $(AST64BITCPPSYMBOL) */' ; \
+ ) >"tmpastinclude/$(@F)" ; \
+ else \
+ print "# Building (diff) $(@F)" ; \
+ ( \
+ set +o errexit ; \
+ print -n "$${boilerplate}" ; \
+ /usr/bin/diff -D $(AST64BITCPPSYMBOL) "$(HDRDIR32)/$(@F)" "$(HDRDIR64)/$(@F)" ; true ;\
+ ) >"tmpastinclude/$(@F)" ; \
+ fi
+ $(INS) -s -m $(FILEMODE) -f $(@D) "tmpastinclude/$(@F)"
+
+# Add temporary include files to the list of files to "clobber"
+CLOBBERFILES += tmpastinclude/*
diff --git a/usr/src/lib/Makefile.astmsg b/usr/src/lib/Makefile.astmsg
new file mode 100644
index 0000000000..de1e091fd5
--- /dev/null
+++ b/usr/src/lib/Makefile.astmsg
@@ -0,0 +1,97 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+#
+# Temporarily control building AST l10n catalogs until all build
+# machines have been updated.
+#
+
+# Should we build AST l10n catalogs ?
+# This can be overridden at build time via:
+# $ export ON_BUILD_KSH93_AS_BINKSH=1
+ON_BUILD_AST_L10N_CATALOGS=0
+
+DO_BUILD_AST_CATALOGS_1= $(ON_BUILD_AST_L10N_CATALOGS:0=$(POUND_SIGN))
+DONT_BUILD_AST_CATALOGS_1= $(ON_BUILD_AST_L10N_CATALOGS:1=$(POUND_SIGN))
+DO_BUILD_AST_CATALOGS= $(DO_BUILD_AST_CATALOGS_1:1=)
+DONT_BUILD_AST_CATALOGS= $(DONT_BUILD_AST_CATALOGS_1:0=)
+
+#
+# l10n message catalog generation for AST libraries
+#
+
+MSGLIBNAME= $(LIBRARY:.a=)
+ASTMSGCATALOG= $(ROOT)/usr/lib/locale/C/LC_MESSAGES/$(MSGLIBNAME)
+
+# We can't support LD_LIBRARY_PATH/ROOT hacks that attempt to run software
+# out of the proto area.
+$(DO_BUILD_AST_CATALOGS)ASTMSGCC= \
+ PATH="$(ROOT)/usr/ast/bin/:/bin:/usr/bin" \
+ LD_LIBRARY_PATH="$(ROOT)/usr/lib/$(MACH64):$(ROOT)/usr/lib/" \
+ "$(ROOT)/bin/ksh93" "$(ROOT)/usr/ast/bin/msgcc" >>msgcc.out 2>&1
+
+ASTMSGS= $(OBJECTS:%.o=msgs/%.mso)
+
+# cpp defines needed by msgcc
+i386_ASTMSGCCFLAGS= -D__i386
+amd64_ASTMSGCCFLAGS= -D__amd64
+sparc_ASTMSGCCFLAGS= -D__sparc
+sparcv9_ASTMSGCCFLAGS= -D__sparcv9
+ASTMSGCCFLAGS= -D_STDC_C99 -D__STDC__ -D__BUILTIN_VA_ARG_INCR $($(TARGETMACH)_ASTMSGCCFLAGS)
+
+msgs/%.mso: ../common/%.c
+ @mkdir -p "$$(dirname "$@")" ; \
+ print "# Processing file $< to $@" >>msgcc.out ; \
+ $(ASTMSGCC) -M-set=ast $(ASTMSGCCFLAGS) $(CFLAGS) $(CPPFLAGS) -c "$<" -o "$@"
+msgs/%.mso: ../%.c
+ @mkdir -p "$$(dirname "$@")" ; \
+ print "# Processing file $< to $@" >>msgcc.out ; \
+ $(ASTMSGCC) -M-set=ast $(ASTMSGCCFLAGS) $(CFLAGS) $(CPPFLAGS) -c "$<" -o "$@"
+
+$(MSGLIBNAME).msg: $(ASTMSGS)
+ @print "# Processing files $(ASTMSGS) to $@" >>msgcc.out ; \
+ $(ASTMSGCC) -M-set=ast $(ASTMSGCCFLAGS) $(CFLAGS) $(CPPFLAGS) -o $@ $(ASTMSGS)
+
+$(ASTMSGCATALOG): $(MSGLIBNAME).msg
+ @$(RM) "$(ASTMSGCATALOG)" ; \
+ sed 's/^$$translation msgcc .*//' <"$(MSGLIBNAME).msg" | gencat "$@" -
+
+# Main catalog target
+$(DO_BUILD_AST_CATALOGS)_msg: $(ASTMSGCATALOG)
+
+# Create empty catalog file when we do not build it (to avoid that we have to hack the
+# package database each time we toggle the switch)
+$(DONT_BUILD_AST_CATALOGS)_msg:
+$(DONT_BUILD_AST_CATALOGS) $(RM) $(ASTMSGCATALOG) ; \
+ $(TOUCH) $(ASTMSGCATALOG)
+
+# Add message catalogs to the list of files to "clobber"
+CLOBBERFILES += \
+ $(ASTMSGS) \
+ $(ASTMSGCATALOG) \
+ $(MSGLIBNAME).msg \
+ msgcc.out
diff --git a/usr/src/lib/Makefile.lib b/usr/src/lib/Makefile.lib
index 2c2954c356..714618b165 100644
--- a/usr/src/lib/Makefile.lib
+++ b/usr/src/lib/Makefile.lib
@@ -122,6 +122,16 @@ $(ROOTMAN3FILES) := FILEMODE= 444
$(ROOTMAN3FILES) := OWNER= root
$(ROOTMAN3FILES) := GROUP= bin
+# Demo rules
+DEMOFILES=
+DEMOFILESRCDIR= common
+ROOTDEMODIRBASE= __nonexistent_directory__
+ROOTDEMODIRS=
+ROOTDEMOFILES= $(DEMOFILES:%=$(ROOTDEMODIRBASE)/%)
+$(ROOTDEMODIRS) := OWNER = root
+$(ROOTDEMODIRS) := GROUP = bin
+$(ROOTDEMODIRS) := DIRMODE = 755
+
#
# Begin /usr/sfw freeware rules for freeware that has "External"
# taxonomy stability level.
diff --git a/usr/src/lib/Makefile.targ b/usr/src/lib/Makefile.targ
index 9918ad77fd..b30eb2b533 100644
--- a/usr/src/lib/Makefile.targ
+++ b/usr/src/lib/Makefile.targ
@@ -19,7 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
@@ -71,6 +71,11 @@ $(ROOTLINTDIR)/%: $(SRCDIR)/%
$(ROOTFS_LINTDIR)/%: $(SRCDIR)/%
$(INS.file)
+$(ROOTDEMODIRS):
+ $(INS.dir)
+$(ROOTDEMODIRBASE)/%: $(DEMOFILESRCDIR)/%
+ $(INS.file)
+
objs/%.o pics/%.o: $(SRCDIR)/%.c
$(COMPILE.c) -o $@ $<
$(POST_PROCESS_O)
diff --git a/usr/src/lib/libast/Makefile b/usr/src/lib/libast/Makefile
new file mode 100644
index 0000000000..65a4302008
--- /dev/null
+++ b/usr/src/lib/libast/Makefile
@@ -0,0 +1,158 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+SHELL=/usr/bin/ksh
+
+include ../Makefile.lib
+
+SUBDIRS = $(MACH)
+$(BUILD64)SUBDIRS += $(MACH64)
+
+all := TARGET= all
+clean := TARGET= clean
+clobber := TARGET= clobber
+install := TARGET= install
+lint := TARGET= lint
+_msg := TARGET= _msg
+
+.KEEP_STATE:
+
+all clean clobber install lint _msg: $(SUBDIRS)
+
+LIBRARY= libast.a
+
+HDRS= \
+ align.h \
+ ast_botch.h \
+ ast_ccode.h \
+ ast_common.h \
+ ast_dir.h \
+ ast_dirent.h \
+ ast_fcntl.h \
+ ast_float.h \
+ ast_fs.h \
+ ast_getopt.h \
+ ast_iconv.h \
+ ast_lib.h \
+ ast_limits.h \
+ ast_map.h \
+ ast_mmap.h \
+ ast_mode.h \
+ ast_nl_types.h \
+ ast_param.h \
+ ast_standards.h \
+ ast_std.h \
+ ast_stdio.h \
+ ast_sys.h \
+ ast_time.h \
+ ast_tty.h \
+ ast_types.h \
+ ast_version.h \
+ ast_vfork.h \
+ ast_wait.h \
+ ast_wchar.h \
+ ast_windows.h \
+ ast.h \
+ bytesex.h \
+ ccode.h \
+ cdt.h \
+ debug.h \
+ dirent.h \
+ dt.h \
+ endian.h \
+ error.h \
+ find.h \
+ fnmatch.h \
+ fnv.h \
+ fs3d.h \
+ fts.h \
+ ftw.h \
+ ftwalk.h \
+ getopt.h \
+ glob.h \
+ hash.h \
+ hashkey.h \
+ hashpart.h \
+ iconv.h \
+ lc.h \
+ ls.h \
+ magic.h \
+ magicid.h \
+ mc.h \
+ mime.h \
+ mnt.h \
+ modecanon.h \
+ modex.h \
+ namval.h \
+ nl_types.h \
+ option.h \
+ preroot.h \
+ proc.h \
+ prototyped.h \
+ re_comp.h \
+ recfmt.h \
+ regex.h \
+ regexp.h \
+ sfdisc.h \
+ sfio_s.h \
+ sfio_t.h \
+ sfio.h \
+ sig.h \
+ stack.h \
+ stak.h \
+ stdio.h \
+ stk.h \
+ swap.h \
+ tar.h \
+ times.h \
+ tm.h \
+ tmx.h \
+ tok.h \
+ tv.h \
+ usage.h \
+ vdb.h \
+ vecargs.h \
+ vmalloc.h \
+ wait.h \
+ wchar.h \
+ wordexp.h
+
+HDRDIR32= $(MACH)/include/ast
+HDRDIR64= $(MACH64)/include/ast
+include ../Makefile.asthdr
+
+install_h: $(ROOTHDRS)
+
+# We don't check these header files because they're owned by AT&T/AST
+check:
+
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
+
+include ../Makefile.targ
diff --git a/usr/src/lib/libast/Makefile.com b/usr/src/lib/libast/Makefile.com
new file mode 100644
index 0000000000..b982eee7d5
--- /dev/null
+++ b/usr/src/lib/libast/Makefile.com
@@ -0,0 +1,738 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+SHELL=/usr/bin/ksh
+
+LIBRARY= libast.a
+VERS= .1
+
+# platform-independent sources are in common/
+OBJECTS += \
+ common/cdt/dtclose.o \
+ common/cdt/dtdisc.o \
+ common/cdt/dtextract.o \
+ common/cdt/dtflatten.o \
+ common/cdt/dthash.o \
+ common/cdt/dtlist.o \
+ common/cdt/dtmethod.o \
+ common/cdt/dtnew.o \
+ common/cdt/dtopen.o \
+ common/cdt/dtrenew.o \
+ common/cdt/dtrestore.o \
+ common/cdt/dtsize.o \
+ common/cdt/dtstat.o \
+ common/cdt/dtstrhash.o \
+ common/cdt/dttree.o \
+ common/cdt/dttreeset.o \
+ common/cdt/dtview.o \
+ common/cdt/dtwalk.o \
+ common/comp/atexit.o \
+ common/comp/basename.o \
+ common/comp/catopen.o \
+ common/comp/closelog.o \
+ common/comp/creat64.o \
+ common/comp/dirname.o \
+ common/comp/dup2.o \
+ common/comp/eaccess.o \
+ common/comp/errno.o \
+ common/comp/execlp.o \
+ common/comp/execve.o \
+ common/comp/execvp.o \
+ common/comp/execvpe.o \
+ common/comp/fcntl.o \
+ common/comp/fmtmsglib.o \
+ common/comp/fnmatch.o \
+ common/comp/frexp.o \
+ common/comp/frexpl.o \
+ common/comp/fsync.o \
+ common/comp/ftw.o \
+ common/comp/getdate.o \
+ common/comp/getgroups.o \
+ common/comp/getlogin.o \
+ common/comp/getopt.o \
+ common/comp/getoptl.o \
+ common/comp/getpgrp.o \
+ common/comp/getsubopt.o \
+ common/comp/getwd.o \
+ common/comp/gross.o \
+ common/comp/hsearch.o \
+ common/comp/iconv.o \
+ common/comp/killpg.o \
+ common/comp/link.o \
+ common/comp/localeconv.o \
+ common/comp/lstat.o \
+ common/comp/memccpy.o \
+ common/comp/memchr.o \
+ common/comp/memcmp.o \
+ common/comp/memcpy.o \
+ common/comp/memmove.o \
+ common/comp/memset.o \
+ common/comp/mkdir.o \
+ common/comp/mkfifo.o \
+ common/comp/mknod.o \
+ common/comp/mktemp.o \
+ common/comp/mktime.o \
+ common/comp/mount.o \
+ common/comp/nftw.o \
+ common/comp/omitted.o \
+ common/comp/open.o \
+ common/comp/openlog.o \
+ common/comp/putenv.o \
+ common/comp/re_comp.o \
+ common/comp/readlink.o \
+ common/comp/realpath.o \
+ common/comp/regcmp.o \
+ common/comp/regexp.o \
+ common/comp/remove.o \
+ common/comp/rename.o \
+ common/comp/resolvepath.o \
+ common/comp/rmdir.o \
+ common/comp/setenv.o \
+ common/comp/setlocale.o \
+ common/comp/setlogmask.o \
+ common/comp/setpgid.o \
+ common/comp/setsid.o \
+ common/comp/sigunblock.o \
+ common/comp/spawnveg.o \
+ common/comp/statvfs.o \
+ common/comp/strcasecmp.o \
+ common/comp/strchr.o \
+ common/comp/strftime.o \
+ common/comp/strncasecmp.o \
+ common/comp/strptime.o \
+ common/comp/strrchr.o \
+ common/comp/strstr.o \
+ common/comp/strtod.o \
+ common/comp/strtol.o \
+ common/comp/strtold.o \
+ common/comp/strtoll.o \
+ common/comp/strtoul.o \
+ common/comp/strtoull.o \
+ common/comp/swab.o \
+ common/comp/symlink.o \
+ common/comp/syslog.o \
+ common/comp/system.o \
+ common/comp/tempnam.o \
+ common/comp/tmpnam.o \
+ common/comp/transition.o \
+ common/comp/tsearch.o \
+ common/comp/unlink.o \
+ common/comp/unsetenv.o \
+ common/comp/vfork.o \
+ common/comp/waitpid.o \
+ common/comp/wc.o \
+ common/comp/wordexp.o \
+ common/dir/getdents.o \
+ common/dir/opendir.o \
+ common/dir/readdir.o \
+ common/dir/rewinddir.o \
+ common/dir/seekdir.o \
+ common/dir/telldir.o \
+ common/disc/memfatal.o \
+ common/disc/sfdcdio.o \
+ common/disc/sfdcdos.o \
+ common/disc/sfdcfilter.o \
+ common/disc/sfdcmore.o \
+ common/disc/sfdcprefix.o \
+ common/disc/sfdcseekable.o \
+ common/disc/sfdcslow.o \
+ common/disc/sfdcsubstr.o \
+ common/disc/sfdctee.o \
+ common/disc/sfdcunion.o \
+ common/disc/sfkeyprintf.o \
+ common/disc/sfstrtmp.o \
+ common/hash/hashalloc.o \
+ common/hash/hashdump.o \
+ common/hash/hashfree.o \
+ common/hash/hashlast.o \
+ common/hash/hashlook.o \
+ common/hash/hashscan.o \
+ common/hash/hashsize.o \
+ common/hash/hashview.o \
+ common/hash/hashwalk.o \
+ common/hash/memhash.o \
+ common/hash/memsum.o \
+ common/hash/strhash.o \
+ common/hash/strkey.o \
+ common/hash/strsum.o \
+ common/misc/error.o \
+ common/misc/errorf.o \
+ common/misc/errormsg.o \
+ common/misc/errorx.o \
+ common/misc/fastfind.o \
+ common/misc/fmtrec.o \
+ common/misc/fs3d.o \
+ common/misc/fts.o \
+ common/misc/ftwalk.o \
+ common/misc/ftwflags.o \
+ common/misc/getcwd.o \
+ common/misc/glob.o \
+ common/misc/liberror.o \
+ common/misc/libevent.o \
+ common/misc/magic.o \
+ common/misc/mime.o \
+ common/misc/mimetype.o \
+ common/misc/optesc.o \
+ common/misc/optget.o \
+ common/misc/optjoin.o \
+ common/misc/procclose.o \
+ common/misc/procfree.o \
+ common/misc/procopen.o \
+ common/misc/procrun.o \
+ common/misc/recfmt.o \
+ common/misc/reclen.o \
+ common/misc/recstr.o \
+ common/misc/setenviron.o \
+ common/misc/sigcrit.o \
+ common/misc/sigdata.o \
+ common/misc/signal.o \
+ common/misc/stack.o \
+ common/misc/state.o \
+ common/misc/stk.o \
+ common/misc/systrace.o \
+ common/misc/translate.o \
+ common/misc/univdata.o \
+ common/obsolete/spawn.o \
+ common/path/pathaccess.o \
+ common/path/pathbin.o \
+ common/path/pathcanon.o \
+ common/path/pathcat.o \
+ common/path/pathcd.o \
+ common/path/pathcheck.o \
+ common/path/pathexists.o \
+ common/path/pathfind.o \
+ common/path/pathgetlink.o \
+ common/path/pathkey.o \
+ common/path/pathnative.o \
+ common/path/pathpath.o \
+ common/path/pathposix.o \
+ common/path/pathprobe.o \
+ common/path/pathrepl.o \
+ common/path/pathsetlink.o \
+ common/path/pathshell.o \
+ common/path/pathstat.o \
+ common/path/pathtemp.o \
+ common/path/pathtmp.o \
+ common/port/astconf.o \
+ common/port/astcopy.o \
+ common/port/astdynamic.o \
+ common/port/astlicense.o \
+ common/port/astquery.o \
+ common/port/aststatic.o \
+ common/port/astwinsize.o \
+ common/port/iblocks.o \
+ common/port/lc.o \
+ common/port/mc.o \
+ common/port/mnt.o \
+ common/port/touch.o \
+ common/preroot/getpreroot.o \
+ common/preroot/ispreroot.o \
+ common/preroot/realopen.o \
+ common/preroot/setpreroot.o \
+ common/regex/regalloc.o \
+ common/regex/regcache.o \
+ common/regex/regclass.o \
+ common/regex/regcoll.o \
+ common/regex/regcomp.o \
+ common/regex/regdecomp.o \
+ common/regex/regerror.o \
+ common/regex/regexec.o \
+ common/regex/regfatal.o \
+ common/regex/reginit.o \
+ common/regex/regnexec.o \
+ common/regex/regrecord.o \
+ common/regex/regrexec.o \
+ common/regex/regstat.o \
+ common/regex/regsub.o \
+ common/regex/regsubcomp.o \
+ common/regex/regsubexec.o \
+ common/sfio/_sfclrerr.o \
+ common/sfio/_sfdlen.o \
+ common/sfio/_sfeof.o \
+ common/sfio/_sferror.o \
+ common/sfio/_sffileno.o \
+ common/sfio/_sfgetc.o \
+ common/sfio/_sfgetl.o \
+ common/sfio/_sfgetl2.o \
+ common/sfio/_sfgetu.o \
+ common/sfio/_sfgetu2.o \
+ common/sfio/_sfllen.o \
+ common/sfio/_sfopen.o \
+ common/sfio/_sfputc.o \
+ common/sfio/_sfputd.o \
+ common/sfio/_sfputl.o \
+ common/sfio/_sfputm.o \
+ common/sfio/_sfputu.o \
+ common/sfio/_sfslen.o \
+ common/sfio/_sfstacked.o \
+ common/sfio/_sfulen.o \
+ common/sfio/_sfvalue.o \
+ common/sfio/sfclose.o \
+ common/sfio/sfclrlock.o \
+ common/sfio/sfcvt.o \
+ common/sfio/sfdisc.o \
+ common/sfio/sfdlen.o \
+ common/sfio/sfecvt.o \
+ common/sfio/sfexcept.o \
+ common/sfio/sfextern.o \
+ common/sfio/sffcvt.o \
+ common/sfio/sffilbuf.o \
+ common/sfio/sfflsbuf.o \
+ common/sfio/sfgetd.o \
+ common/sfio/sfgetl.o \
+ common/sfio/sfgetm.o \
+ common/sfio/sfgetr.o \
+ common/sfio/sfgetu.o \
+ common/sfio/sfllen.o \
+ common/sfio/sfmode.o \
+ common/sfio/sfmove.o \
+ common/sfio/sfmutex.o \
+ common/sfio/sfnew.o \
+ common/sfio/sfnotify.o \
+ common/sfio/sfnputc.o \
+ common/sfio/sfopen.o \
+ common/sfio/sfpeek.o \
+ common/sfio/sfpkrd.o \
+ common/sfio/sfpoll.o \
+ common/sfio/sfpool.o \
+ common/sfio/sfpopen.o \
+ common/sfio/sfprintf.o \
+ common/sfio/sfprints.o \
+ common/sfio/sfpurge.o \
+ common/sfio/sfputd.o \
+ common/sfio/sfputl.o \
+ common/sfio/sfputm.o \
+ common/sfio/sfputr.o \
+ common/sfio/sfputu.o \
+ common/sfio/sfraise.o \
+ common/sfio/sfrd.o \
+ common/sfio/sfread.o \
+ common/sfio/sfreserve.o \
+ common/sfio/sfresize.o \
+ common/sfio/sfscanf.o \
+ common/sfio/sfseek.o \
+ common/sfio/sfset.o \
+ common/sfio/sfsetbuf.o \
+ common/sfio/sfsetfd.o \
+ common/sfio/sfsize.o \
+ common/sfio/sfsk.o \
+ common/sfio/sfstack.o \
+ common/sfio/sfstrtod.o \
+ common/sfio/sfswap.o \
+ common/sfio/sfsync.o \
+ common/sfio/sftable.o \
+ common/sfio/sftell.o \
+ common/sfio/sftmp.o \
+ common/sfio/sfungetc.o \
+ common/sfio/sfvprintf.o \
+ common/sfio/sfvscanf.o \
+ common/sfio/sfwr.o \
+ common/sfio/sfwrite.o \
+ common/stdio/_doprnt.o \
+ common/stdio/_doscan.o \
+ common/stdio/_filbuf.o \
+ common/stdio/_flsbuf.o \
+ common/stdio/_stdfun.o \
+ common/stdio/_stdopen.o \
+ common/stdio/_stdprintf.o \
+ common/stdio/_stdscanf.o \
+ common/stdio/_stdsprnt.o \
+ common/stdio/_stdvbuf.o \
+ common/stdio/_stdvsnprnt.o \
+ common/stdio/_stdvsprnt.o \
+ common/stdio/_stdvsscn.o \
+ common/stdio/asprintf.o \
+ common/stdio/clearerr.o \
+ common/stdio/fclose.o \
+ common/stdio/fdopen.o \
+ common/stdio/feof.o \
+ common/stdio/ferror.o \
+ common/stdio/fflush.o \
+ common/stdio/fgetc.o \
+ common/stdio/fgetpos.o \
+ common/stdio/fgets.o \
+ common/stdio/fgetwc.o \
+ common/stdio/fgetws.o \
+ common/stdio/fileno.o \
+ common/stdio/fopen.o \
+ common/stdio/fprintf.o \
+ common/stdio/fpurge.o \
+ common/stdio/fputc.o \
+ common/stdio/fputs.o \
+ common/stdio/fputwc.o \
+ common/stdio/fputws.o \
+ common/stdio/fread.o \
+ common/stdio/freopen.o \
+ common/stdio/fscanf.o \
+ common/stdio/fseek.o \
+ common/stdio/fseeko.o \
+ common/stdio/fsetpos.o \
+ common/stdio/ftell.o \
+ common/stdio/ftello.o \
+ common/stdio/fwide.o \
+ common/stdio/fwprintf.o \
+ common/stdio/fwrite.o \
+ common/stdio/fwscanf.o \
+ common/stdio/getc.o \
+ common/stdio/getchar.o \
+ common/stdio/getw.o \
+ common/stdio/getwc.o \
+ common/stdio/getwchar.o \
+ common/stdio/pclose.o \
+ common/stdio/popen.o \
+ common/stdio/printf.o \
+ common/stdio/putc.o \
+ common/stdio/putchar.o \
+ common/stdio/puts.o \
+ common/stdio/putw.o \
+ common/stdio/putwc.o \
+ common/stdio/putwchar.o \
+ common/stdio/rewind.o \
+ common/stdio/scanf.o \
+ common/stdio/setbuf.o \
+ common/stdio/setbuffer.o \
+ common/stdio/setlinebuf.o \
+ common/stdio/setvbuf.o \
+ common/stdio/snprintf.o \
+ common/stdio/sprintf.o \
+ common/stdio/sscanf.o \
+ common/stdio/stdio_c99.o \
+ common/stdio/stdio_gnu.o \
+ common/stdio/swprintf.o \
+ common/stdio/swscanf.o \
+ common/stdio/tmpfile.o \
+ common/stdio/ungetc.o \
+ common/stdio/ungetwc.o \
+ common/stdio/vasprintf.o \
+ common/stdio/vfprintf.o \
+ common/stdio/vfscanf.o \
+ common/stdio/vfwprintf.o \
+ common/stdio/vfwscanf.o \
+ common/stdio/vprintf.o \
+ common/stdio/vscanf.o \
+ common/stdio/vsnprintf.o \
+ common/stdio/vsprintf.o \
+ common/stdio/vsscanf.o \
+ common/stdio/vswprintf.o \
+ common/stdio/vswscanf.o \
+ common/stdio/vwprintf.o \
+ common/stdio/vwscanf.o \
+ common/stdio/wprintf.o \
+ common/stdio/wscanf.o \
+ common/string/base64.o \
+ common/string/ccmap.o \
+ common/string/ccmapid.o \
+ common/string/ccnative.o \
+ common/string/chresc.o \
+ common/string/chrtoi.o \
+ common/string/fmtbase.o \
+ common/string/fmtbuf.o \
+ common/string/fmtclock.o \
+ common/string/fmtdev.o \
+ common/string/fmtelapsed.o \
+ common/string/fmterror.o \
+ common/string/fmtesc.o \
+ common/string/fmtfmt.o \
+ common/string/fmtfs.o \
+ common/string/fmtgid.o \
+ common/string/fmtident.o \
+ common/string/fmtip4.o \
+ common/string/fmtls.o \
+ common/string/fmtmatch.o \
+ common/string/fmtmode.o \
+ common/string/fmtnum.o \
+ common/string/fmtperm.o \
+ common/string/fmtre.o \
+ common/string/fmtscale.o \
+ common/string/fmtsignal.o \
+ common/string/fmttime.o \
+ common/string/fmttmx.o \
+ common/string/fmttv.o \
+ common/string/fmtuid.o \
+ common/string/fmtversion.o \
+ common/string/memdup.o \
+ common/string/modedata.o \
+ common/string/modei.o \
+ common/string/modex.o \
+ common/string/stracmp.o \
+ common/string/strcopy.o \
+ common/string/strdup.o \
+ common/string/strelapsed.o \
+ common/string/strerror.o \
+ common/string/stresc.o \
+ common/string/streval.o \
+ common/string/strexpr.o \
+ common/string/strgid.o \
+ common/string/strlcat.o \
+ common/string/strlcpy.o \
+ common/string/strlook.o \
+ common/string/strmatch.o \
+ common/string/strmode.o \
+ common/string/strnacmp.o \
+ common/string/strncopy.o \
+ common/string/strntod.o \
+ common/string/strntol.o \
+ common/string/strntold.o \
+ common/string/strntoll.o \
+ common/string/strntoul.o \
+ common/string/strntoull.o \
+ common/string/stropt.o \
+ common/string/strperm.o \
+ common/string/strpsearch.o \
+ common/string/strsearch.o \
+ common/string/strsort.o \
+ common/string/strtape.o \
+ common/string/strtoip4.o \
+ common/string/strton.o \
+ common/string/strtonll.o \
+ common/string/struid.o \
+ common/string/struniq.o \
+ common/string/swapget.o \
+ common/string/swapmem.o \
+ common/string/swapop.o \
+ common/string/swapput.o \
+ common/string/tok.o \
+ common/string/tokline.o \
+ common/string/tokscan.o \
+ common/tm/tmdata.o \
+ common/tm/tmdate.o \
+ common/tm/tmequiv.o \
+ common/tm/tmfix.o \
+ common/tm/tmfmt.o \
+ common/tm/tmform.o \
+ common/tm/tmgoff.o \
+ common/tm/tminit.o \
+ common/tm/tmleap.o \
+ common/tm/tmlex.o \
+ common/tm/tmlocale.o \
+ common/tm/tmmake.o \
+ common/tm/tmpoff.o \
+ common/tm/tmscan.o \
+ common/tm/tmsleep.o \
+ common/tm/tmtime.o \
+ common/tm/tmtype.o \
+ common/tm/tmweek.o \
+ common/tm/tmword.o \
+ common/tm/tmxdate.o \
+ common/tm/tmxfmt.o \
+ common/tm/tmxgettime.o \
+ common/tm/tmxleap.o \
+ common/tm/tmxmake.o \
+ common/tm/tmxscan.o \
+ common/tm/tmxsettime.o \
+ common/tm/tmxsleep.o \
+ common/tm/tmxtime.o \
+ common/tm/tmxtouch.o \
+ common/tm/tmzone.o \
+ common/tm/tvcmp.o \
+ common/tm/tvgettime.o \
+ common/tm/tvsettime.o \
+ common/tm/tvsleep.o \
+ common/tm/tvtouch.o \
+ common/uwin/a64l.o \
+ common/uwin/acosh.o \
+ common/uwin/asinh.o \
+ common/uwin/atanh.o \
+ common/uwin/cbrt.o \
+ common/uwin/crypt.o \
+ common/uwin/erf.o \
+ common/uwin/err.o \
+ common/uwin/exp.o \
+ common/uwin/exp__E.o \
+ common/uwin/expm1.o \
+ common/uwin/gamma.o \
+ common/uwin/getpass.o \
+ common/uwin/lgamma.o \
+ common/uwin/log.o \
+ common/uwin/log1p.o \
+ common/uwin/log__L.o \
+ common/uwin/rand48.o \
+ common/uwin/random.o \
+ common/uwin/rcmd.o \
+ common/uwin/rint.o \
+ common/uwin/support.o \
+ common/vec/vecargs.o \
+ common/vec/vecfile.o \
+ common/vec/vecfree.o \
+ common/vec/vecload.o \
+ common/vec/vecstring.o \
+ common/vmalloc/malloc.o \
+ common/vmalloc/vmbest.o \
+ common/vmalloc/vmclear.o \
+ common/vmalloc/vmclose.o \
+ common/vmalloc/vmdcheap.o \
+ common/vmalloc/vmdebug.o \
+ common/vmalloc/vmdisc.o \
+ common/vmalloc/vmexit.o \
+ common/vmalloc/vmgetmem.o \
+ common/vmalloc/vmlast.o \
+ common/vmalloc/vmmopen.o \
+ common/vmalloc/vmopen.o \
+ common/vmalloc/vmpool.o \
+ common/vmalloc/vmprivate.o \
+ common/vmalloc/vmprofile.o \
+ common/vmalloc/vmregion.o \
+ common/vmalloc/vmsegment.o \
+ common/vmalloc/vmset.o \
+ common/vmalloc/vmstat.o \
+ common/vmalloc/vmstrdup.o \
+ common/vmalloc/vmtrace.o \
+ common/vmalloc/vmwalk.o
+
+# We are storing the object files into subdirs avoid the
+# confusion with having 550+ object files in the toplevel pics/
+# directory (this matches the way how the original AST build system
+# deals with this "logistic" issue) - the rules below ensure that
+# the destination directory is available.
+OBJDIRS += \
+ common/cdt \
+ common/comp \
+ common/dir \
+ common/disc \
+ common/hash \
+ common/misc \
+ common/obsolete \
+ common/path \
+ common/port \
+ common/preroot \
+ common/regex \
+ common/sfio \
+ common/stdio \
+ common/string \
+ common/tm \
+ common/uwin \
+ common/vec \
+ common/vmalloc
+PICSDIRS= $(OBJDIRS:%=pics/%)
+mkpicdirs:
+ @mkdir -p $(PICSDIRS)
+
+# We need our own rules here since some source files come from
+# the plaftorm-specific directories and the default rules do
+# not cover this
+pics/%.o: ../%.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+ $(POST_PROCESS_O)
+
+include ../../Makefile.astmsg
+
+include ../../Makefile.lib
+
+# mapfile-vers does not live with the sources in in common/ to make
+# automated code updates easier.
+MAPFILES= ../mapfile-vers
+
+# Set common AST build flags (e.g., needed to support the math stuff).
+include ../../../Makefile.ast
+
+# special rule because sources live both ../common (normal)
+# and $(TRANSMACH) (generated)
+SRCS= $(OBJECTS:%.o=../%.c)
+
+LIBS = $(DYNLIB) $(LINTLIB)
+
+LDLIBS += \
+ -z lazyload -lsocket -z nolazyload \
+ -lm -lc
+
+$(LINTLIB) := SRCS = $(SRCDIR)/$(LINTSRC)
+
+SRCDIR = ../common
+
+# We use "=" here since using $(CPPFLAGS.master) is very tricky in our
+# case - it MUST come as the last element but future changes in -D options
+# may then cause silent breakage in the AST sources because the last -D
+# option specified overrides previous -D options so we prefer the current
+# way to explicitly list each single flag.
+# Notes:
+# - "-D_BLD_DLL" comes from ${mam_cc_DLL} in Mamfile
+# - Be careful with "-D__OBSOLETE__=xxx". Make sure this is in sync with
+# upstream (see Mamfile) and do not change the |__OBSOLETE__| value
+# without examining the symbols that will be removed, and evaluating
+# whether that breaks compatibility with upstream binaries.
+CPPFLAGS = \
+ $(DTEXTDOM) $(DTS_ERRNO) \
+ $(ASTPLATFORMCPPFLAGS) \
+ -Isrc/lib/libast \
+ -I$(SRCDIR) \
+ -I$(SRCDIR)/comp \
+ -I$(SRCDIR)/include \
+ -I$(SRCDIR)/std \
+ -I$(SRCDIR)/dir \
+ -I$(SRCDIR)/port \
+ -I$(SRCDIR)/sfio \
+ -I$(SRCDIR)/astsa \
+ -I$(SRCDIR)/misc \
+ -I$(SRCDIR)/string \
+ -Iinclude/ast \
+ '-DCONF_LIBSUFFIX=".so"' \
+ '-DCONF_LIBPREFIX="lib"' \
+ -DERROR_CATALOG=\""libast"\" \
+ -D__OBSOLETE__=20060101 \
+ -D_BLD_ast \
+ -D_PACKAGE_ast \
+ -D_BLD_DLL
+
+CFLAGS += \
+ $(CCVERBOSE) \
+ -xstrconst
+CFLAGS64 += \
+ $(CCVERBOSE) \
+ -xstrconst
+
+pics/$(MACH)/src/lib/libast/conftab.o := CERRWARN += -erroff=E_C99_INTEGER_PROMOTION
+pics/$(MACH)/src/lib/libast/conftab.o \
+pics/$(MACH64)/src/lib/libast/conftab.o := CERRWARN += -erroff=E_INIT_DOES_NOT_FIT
+pics/common/hash/hashlook.o := CERRWARN += -erroff=E_CONST_PROMOTED_UNSIGNED_LONG
+pics/common/hash/memhash.o := CERRWARN += -erroff=E_CONST_PROMOTED_UNSIGNED_LONG
+pics/common/hash/memsum.o := CERRWARN += -erroff=E_CONST_PROMOTED_UNSIGNED_LONG
+pics/common/hash/strhash.o := CERRWARN += -erroff=E_CONST_PROMOTED_UNSIGNED_LONG
+pics/common/hash/strsum.o := CERRWARN += -erroff=E_CONST_PROMOTED_UNSIGNED_LONG
+pics/common/path/pathkey.o := CERRWARN += -erroff=E_CONST_PROMOTED_UNSIGNED_LONG
+pics/common/comp/setlocale.o := CERRWARN += -erroff=E_INTEGER_OVERFLOW_DETECTED
+pics/common/comp/setlocale.o := CERRWARN += -erroff=E_INIT_DOES_NOT_FIT
+pics/common/misc/translate.o := CERRWARN += -erroff=E_INTEGER_OVERFLOW_DETECTED
+pics/common/misc/recstr.o := CERRWARN += -erroff=E_INTEGER_OVERFLOW_DETECTED
+pics/common/sfio/sfmove.o := CERRWARN += -erroff=E_NO_IMPLICIT_DECL_ALLOWED
+pics/common/sfio/sfrd.o := CERRWARN += -erroff=E_NO_IMPLICIT_DECL_ALLOWED
+pics/common/sfio/sfvscanf.o := CERRWARN += -erroff=E_END_OF_LOOP_CODE_NOT_REACHED
+pics/common/port/astconf.o := CERRWARN += -erroff=E_CONST_OBJ_SHOULD_HAVE_INITIZR
+
+.KEEP_STATE:
+
+all: mkpicdirs .WAIT $(LIBS)
+
+#
+# libast is not lint-clean yet; fake up a target. (You can use
+# "make lintcheck" to actually run lint; please send all lint fixes
+# upstream (to AT&T) so the next update will pull them into ON.)
+#
+lint:
+ @ print "usr/src/lib/libast is not lint-clean: skipping"
+ @ $(TRUE)
+
+include ../../Makefile.targ
diff --git a/usr/src/lib/libast/THIRDPARTYLICENSE b/usr/src/lib/libast/THIRDPARTYLICENSE
new file mode 100644
index 0000000000..50c6364c06
--- /dev/null
+++ b/usr/src/lib/libast/THIRDPARTYLICENSE
@@ -0,0 +1,245 @@
++------------------------------------------------------------------------------+
+| This license covers all software that refers to the URL |
+| http://www.opensource.org/licenses/cpl1.0.txt |
++------------------------------------------------------------------------------+
+
+Common Public License Version 1.0
+
+ THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON
+ PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF
+ THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+ 1. DEFINITIONS
+
+ "Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and
+ documentation distributed under this Agreement, and
+
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from
+ and are distributed by that particular Contributor. A Contribution
+ 'originates' from a Contributor if it was added to the Program by
+ such Contributor itself or anyone acting on such Contributor's
+ behalf. Contributions do not include additions to the Program
+ which: (i) are separate modules of software distributed in
+ conjunction with the Program under their own license agreement, and
+ (ii) are not derivative works of the Program.
+
+ "Contributor" means any person or entity that distributes the Program.
+
+ "Licensed Patents " mean patent claims licensable by a Contributor
+ which are necessarily infringed by the use or sale of its Contribution
+ alone or when combined with the Program.
+
+ "Program" means the Contributions distributed in accordance with this
+ Agreement.
+
+ "Recipient" means anyone who receives the Program under this
+ Agreement, including all Contributors.
+
+ 2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free copyright
+ license to reproduce, prepare derivative works of, publicly
+ display, publicly perform, distribute and sublicense the
+ Contribution of such Contributor, if any, and such derivative
+ works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free patent
+ license under Licensed Patents to make, use, sell, offer to sell,
+ import and otherwise transfer the Contribution of such Contributor,
+ if any, in source code and object code form. This patent license
+ shall apply to the combination of the Contribution and the Program
+ if, at the time the Contribution is added by the Contributor, such
+ addition of the Contribution causes such combination to be covered
+ by the Licensed Patents. The patent license shall not apply to any
+ other combinations which include the Contribution. No hardware per
+ se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the
+ licenses to its Contributions set forth herein, no assurances are
+ provided by any Contributor that the Program does not infringe the
+ patent or other intellectual property rights of any other entity.
+ Each Contributor disclaims any liability to Recipient for claims
+ brought by any other entity based on infringement of intellectual
+ property rights or otherwise. As a condition to exercising the
+ rights and licenses granted hereunder, each Recipient hereby
+ assumes sole responsibility to secure any other intellectual
+ property rights needed, if any. For example, if a third party
+ patent license is required to allow Recipient to distribute the
+ Program, it is Recipient's responsibility to acquire that license
+ before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has
+ sufficient copyright rights in its Contribution, if any, to grant
+ the copyright license set forth in this Agreement.
+
+ 3. REQUIREMENTS
+
+ A Contributor may choose to distribute the Program in object code form
+ under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all
+ warranties and conditions, express and implied, including
+ warranties or conditions of title and non-infringement, and implied
+ warranties or conditions of merchantability and fitness for a
+ particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all
+ liability for damages, including direct, indirect, special,
+ incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement
+ are offered by that Contributor alone and not by any other party;
+ and
+
+ iv) states that source code for the Program is available from such
+ Contributor, and informs licensees how to obtain it in a reasonable
+ manner on or through a medium customarily used for software
+ exchange.
+
+ When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the
+ Program.
+
+ Contributors may not remove or alter any copyright notices contained
+ within the Program.
+
+ Each Contributor must identify itself as the originator of its
+ Contribution, if any, in a manner that reasonably allows subsequent
+ Recipients to identify the originator of the Contribution.
+
+ 4. COMMERCIAL DISTRIBUTION
+
+ Commercial distributors of software may accept certain
+ responsibilities with respect to end users, business partners and the
+ like. While this license is intended to facilitate the commercial use
+ of the Program, the Contributor who includes the Program in a
+ commercial product offering should do so in a manner which does not
+ create potential liability for other Contributors. Therefore, if a
+ Contributor includes the Program in a commercial product offering,
+ such Contributor ("Commercial Contributor") hereby agrees to defend
+ and indemnify every other Contributor ("Indemnified Contributor")
+ against any losses, damages and costs (collectively "Losses") arising
+ from claims, lawsuits and other legal actions brought by a third party
+ against the Indemnified Contributor to the extent caused by the acts
+ or omissions of such Commercial Contributor in connection with its
+ distribution of the Program in a commercial product offering. The
+ obligations in this section do not apply to any claims or Losses
+ relating to any actual or alleged intellectual property infringement.
+ In order to qualify, an Indemnified Contributor must: a) promptly
+ notify the Commercial Contributor in writing of such claim, and b)
+ allow the Commercial Contributor to control, and cooperate with the
+ Commercial Contributor in, the defense and any related settlement
+ negotiations. The Indemnified Contributor may participate in any such
+ claim at its own expense.
+
+ For example, a Contributor might include the Program in a commercial
+ product offering, Product X. That Contributor is then a Commercial
+ Contributor. If that Commercial Contributor then makes performance
+ claims, or offers warranties related to Product X, those performance
+ claims and warranties are such Commercial Contributor's responsibility
+ alone. Under this section, the Commercial Contributor would have to
+ defend claims against the other Contributors related to those
+ performance claims and warranties, and if a court requires any other
+ Contributor to pay any damages as a result, the Commercial Contributor
+ must pay those damages.
+
+ 5. NO WARRANTY
+
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+ PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
+ WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
+ OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+ responsible for determining the appropriateness of using and
+ distributing the Program and assumes all risks associated with its
+ exercise of rights under this Agreement, including but not limited to
+ the risks and costs of program errors, compliance with applicable
+ laws, damage to or loss of data, programs or equipment, and
+ unavailability or interruption of operations.
+
+ 6. DISCLAIMER OF LIABILITY
+
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
+ ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+ WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+ DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+ 7. GENERAL
+
+ If any provision of this Agreement is invalid or unenforceable under
+ applicable law, it shall not affect the validity or enforceability of
+ the remainder of the terms of this Agreement, and without further
+ action by the parties hereto, such provision shall be reformed to the
+ minimum extent necessary to make such provision valid and enforceable.
+
+ If Recipient institutes patent litigation against a Contributor with
+ respect to a patent applicable to software (including a cross-claim or
+ counterclaim in a lawsuit), then any patent licenses granted by that
+ Contributor to such Recipient under this Agreement shall terminate as
+ of the date such litigation is filed. In addition, if Recipient
+ institutes patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Program
+ itself (excluding combinations of the Program with other software or
+ hardware) infringes such Recipient's patent(s), then such Recipient's
+ rights granted under Section 2(b) shall terminate as of the date such
+ litigation is filed.
+
+ All Recipient's rights under this Agreement shall terminate if it
+ fails to comply with any of the material terms or conditions of this
+ Agreement and does not cure such failure in a reasonable period of
+ time after becoming aware of such noncompliance. If all Recipient's
+ rights under this Agreement terminate, Recipient agrees to cease use
+ and distribution of the Program as soon as reasonably practicable.
+ However, Recipient's obligations under this Agreement and any licenses
+ granted by Recipient relating to the Program shall continue and
+ survive.
+
+ Everyone is permitted to copy and distribute copies of this Agreement,
+ but in order to avoid inconsistency the Agreement is copyrighted and
+ may only be modified in the following manner. The Agreement Steward
+ reserves the right to publish new versions (including revisions) of
+ this Agreement from time to time. No one other than the Agreement
+ Steward has the right to modify this Agreement. IBM is the initial
+ Agreement Steward. IBM may assign the responsibility to serve as the
+ Agreement Steward to a suitable separate entity. Each new version of
+ the Agreement will be given a distinguishing version number. The
+ Program (including Contributions) may always be distributed subject to
+ the version of the Agreement under which it was received. In addition,
+ after a new version of the Agreement is published, Contributor may
+ elect to distribute the Program (including its Contributions) under
+ the new version. Except as expressly stated in Sections 2(a) and 2(b)
+ above, Recipient receives no rights or licenses to the intellectual
+ property of any Contributor under this Agreement, whether expressly,
+ by implication, estoppel or otherwise. All rights in the Program not
+ expressly granted under this Agreement are reserved.
+
+ This Agreement is governed by the laws of the State of New York and
+ the intellectual property laws of the United States of America. No
+ party to this Agreement will bring a legal action under this Agreement
+ more than one year after the cause of action arose. Each party waives
+ its rights to a jury trial in any resulting litigation.
+
+Copyright (c) 2004 by the Open Source Initiative
+This is a copy of the license posted on 2004-10-06 at:
+ http://www.opensource.org/licenses/cpl
diff --git a/usr/src/lib/libast/THIRDPARTYLICENSE.descrip b/usr/src/lib/libast/THIRDPARTYLICENSE.descrip
new file mode 100644
index 0000000000..718db11918
--- /dev/null
+++ b/usr/src/lib/libast/THIRDPARTYLICENSE.descrip
@@ -0,0 +1 @@
+AT&T ADVANCED SOFTWARE TECHNOLOGY LIBRARY (LIBAST)
diff --git a/usr/src/lib/libast/amd64/Makefile b/usr/src/lib/libast/amd64/Makefile
new file mode 100644
index 0000000000..1d299936f6
--- /dev/null
+++ b/usr/src/lib/libast/amd64/Makefile
@@ -0,0 +1,48 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+# Fetch minor version from RELEASE, e.g. "10" for "5.10", "11" for "5.11" etc.
+GETRELEASEMINOR = /usr/bin/ksh -c 'x=$(RELEASE) ; print "$${x$(POUND_SIGN)$(POUND_SIGN)*.}"'
+
+# Platform-specific config
+# Note that "HOSTTYPE" matches the value used by AT&T upstream.
+ASTPLATFORMCPPFLAGS = '-DHOSTTYPE="sol$(GETRELEASEMINOR:sh).i386"'
+
+# platform-specific sources
+OBJECTS = \
+ amd64/src/lib/libast/conftab.o
+OBJDIRS = \
+ amd64/src/lib/libast
+
+include ../Makefile.com
+include ../../Makefile.lib.64
+
+# Use -KPIC since libast is too big for -Kpic on 64bit
+# (and on 32bit it is close to the barrier)
+amd64_C_PICFLAGS = $(C_BIGPICFLAGS)
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/libast/amd64/include/ast/align.h b/usr/src/lib/libast/amd64/include/ast/align.h
new file mode 100644
index 0000000000..2e9d6bdda8
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/align.h
@@ -0,0 +1,54 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/align.c by iffe version 2007-04-04 : : */
+#ifndef _def_align_ast
+#define _def_align_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+typedef unsigned long ALIGN_INTEGRAL;
+
+#define ALIGN_CHUNK 8192
+#define ALIGN_INTEGRAL long
+#define ALIGN_INTEGER(x) ((ALIGN_INTEGRAL)(x))
+#define ALIGN_POINTER(x) ((char*)(x))
+#define ALIGN_ROUND(x,y) ALIGN_POINTER(ALIGN_INTEGER((x)+(y)-1)&~((y)-1))
+
+#define ALIGN_BOUND ALIGN_BOUND2
+#define ALIGN_ALIGN(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC(x) ALIGN_TRUNC2(x)
+
+#define ALIGN_BIT1 0x1
+#define ALIGN_BOUND1 ALIGN_BOUND2
+#define ALIGN_ALIGN1(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC1(x) ALIGN_TRUNC2(x)
+#define ALIGN_CLRBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffffe)
+#define ALIGN_SETBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x1)
+#define ALIGN_TSTBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x1)
+
+#define ALIGN_BIT2 0x2
+#define ALIGN_BOUND2 16
+#define ALIGN_ALIGN2(x) ALIGN_TRUNC2((x)+15)
+#define ALIGN_TRUNC2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffff0)
+#define ALIGN_CLRBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffffd)
+#define ALIGN_SETBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x2)
+#define ALIGN_TSTBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x2)
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast.h b/usr/src/lib/libast/amd64/include/ast/ast.h
new file mode 100644
index 0000000000..ea1569f946
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast.h
@@ -0,0 +1,381 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Advanced Software Technology Library
+ * AT&T Research
+ *
+ * std + posix + ast
+ */
+
+#ifndef _AST_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_H
+
+#include <ast_version.h>
+
+#ifndef _AST_STD_H
+#include <ast_std.h>
+#endif
+
+#ifndef _SFIO_H
+#include <sfio.h>
+#endif
+
+#ifndef ast
+#define ast _ast_info
+#endif
+
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif
+
+/*
+ * workaround botched headers that assume <stdio.h>
+ */
+
+#ifndef FILE
+#ifndef _SFIO_H
+struct _sfio_s;
+#endif
+#define FILE struct _sfio_s
+#ifndef __FILE_typedef
+#define __FILE_typedef 1
+#endif
+#ifndef _FILEDEFED
+#define _FILEDEFED 1
+#endif
+#endif
+
+/*
+ * exit() support -- this matches shell exit codes
+ */
+
+#define EXIT_BITS 8 /* # exit status bits */
+
+#define EXIT_USAGE 2 /* usage exit code */
+#define EXIT_QUIT ((1<<(EXIT_BITS))-1) /* parent should quit */
+#define EXIT_NOTFOUND ((1<<(EXIT_BITS-1))-1) /* command not found */
+#define EXIT_NOEXEC ((1<<(EXIT_BITS-1))-2) /* other exec error */
+
+#define EXIT_CODE(x) ((x)&((1<<EXIT_BITS)-1))
+#define EXIT_CORE(x) (EXIT_CODE(x)|(1<<EXIT_BITS)|(1<<(EXIT_BITS-1)))
+#define EXIT_TERM(x) (EXIT_CODE(x)|(1<<EXIT_BITS))
+
+/*
+ * NOTE: for compatibility the following work for EXIT_BITS={7,8}
+ */
+
+#define EXIT_STATUS(x) (((x)&((1<<(EXIT_BITS-2))-1))?(x):EXIT_CODE((x)>>EXIT_BITS))
+
+#define EXITED_CORE(x) (((x)&((1<<EXIT_BITS)|(1<<(EXIT_BITS-1))))==((1<<EXIT_BITS)|(1<<(EXIT_BITS-1)))||((x)&((1<<(EXIT_BITS-1))|(1<<(EXIT_BITS-2))))==((1<<(EXIT_BITS-1))|(1<<(EXIT_BITS-2))))
+#define EXITED_TERM(x) ((x)&((1<<EXIT_BITS)|(1<<(EXIT_BITS-1))))
+
+/*
+ * astconflist() flags
+ */
+
+#define ASTCONF_parse 0x0001
+#define ASTCONF_write 0x0002
+#define ASTCONF_read 0x0004
+#define ASTCONF_lower 0x0008
+#define ASTCONF_base 0x0010
+#define ASTCONF_defined 0x0020
+#define ASTCONF_quote 0x0040
+#define ASTCONF_table 0x0080
+#define ASTCONF_matchcall 0x0100
+#define ASTCONF_matchname 0x0200
+#define ASTCONF_matchstandard 0x0400
+#define ASTCONF_error 0x0800
+#define ASTCONF_system 0x1000
+#define ASTCONF_AST 0x2000
+
+/*
+ * pathcanon() flags
+ */
+
+#define PATH_PHYSICAL 01
+#define PATH_DOTDOT 02
+#define PATH_EXISTS 04
+#define PATH_VERIFIED(n) (((n)&01777)<<5)
+
+/*
+ * pathaccess() flags
+ */
+
+#define PATH_READ 004
+#define PATH_WRITE 002
+#define PATH_EXECUTE 001
+#define PATH_REGULAR 010
+#define PATH_ABSOLUTE 020
+
+/*
+ * touch() flags
+ */
+
+#define PATH_TOUCH_CREATE 01
+#define PATH_TOUCH_VERBATIM 02
+
+/*
+ * pathcheck() info
+ */
+
+typedef struct
+{
+ unsigned long date;
+ char* feature;
+ char* host;
+ char* user;
+} Pathcheck_t;
+
+/*
+ * strgrpmatch() flags
+ */
+
+#define STR_MAXIMAL 01 /* maximal match */
+#define STR_LEFT 02 /* implicit left anchor */
+#define STR_RIGHT 04 /* implicit right anchor */
+#define STR_ICASE 010 /* ignore case */
+#define STR_GROUP 020 /* (|&) inside [@|&](...) only */
+
+/*
+ * fmtquote() flags
+ */
+
+#define FMT_ALWAYS 0x01 /* always quote */
+#define FMT_ESCAPED 0x02 /* already escaped */
+#define FMT_SHELL 0x04 /* escape $ ` too */
+#define FMT_WIDE 0x08 /* don't escape 8 bit chars */
+#define FMT_PARAM 0x10 /* disable FMT_SHELL ${$( quote */
+
+/*
+ * multibyte macros
+ */
+
+#define mbmax() (ast.mb_cur_max)
+#define mberr() (ast.tmp_int<0)
+
+#define mbcoll() (ast.mb_xfrm!=0)
+#define mbwide() (mbmax()>1)
+
+#define mbchar(p) (mbwide()?((ast.tmp_int=(*ast.mb_towc)(&ast.tmp_wchar,(char*)(p),mbmax()))>0?((p+=ast.tmp_int),ast.tmp_wchar):(p++,ast.tmp_int)):(*(unsigned char*)(p++)))
+#define mbinit() (mbwide()?(*ast.mb_towc)((wchar_t*)0,(char*)0,mbmax()):0)
+#define mbsize(p) (mbwide()?(*ast.mb_len)((char*)(p),mbmax()):((p),1))
+#define mbconv(s,w) (ast.mb_conv?(*ast.mb_conv)(s,w):((*(s)=(w)),1))
+#define mbwidth(w) (ast.mb_width&&((ast.tmp_int=(*ast.mb_width)(w))>=0||(w)>UCHAR_MAX)?ast.tmp_int:1)
+#define mbxfrm(t,f,n) (mbcoll()?(*ast.mb_xfrm)((char*)(t),(char*)(f),n):0)
+
+/*
+ * common macros
+ */
+
+#define elementsof(x) (sizeof(x)/sizeof(x[0]))
+#define integralof(x) (((char*)(x))-((char*)0))
+#define newof(p,t,n,x) ((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)calloc(1,sizeof(t)*(n)+(x)))
+#define oldof(p,t,n,x) ((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)malloc(sizeof(t)*(n)+(x)))
+#define pointerof(x) ((__V_*)((char*)0+(x)))
+#define roundof(x,y) (((x)+(y)-1)&~((y)-1))
+#define ssizeof(x) ((int)sizeof(x))
+
+#define streq(a,b) (*(a)==*(b)&&!strcmp(a,b))
+#define strneq(a,b,n) (*(a)==*(b)&&!strncmp(a,b,n))
+#define strsignal(s) fmtsignal(s)
+
+#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
+#define NiL 0
+#define NoP(x) (void)(x)
+#else
+#define NiL ((char*)0)
+#define NoP(x) (&x,1)
+#endif
+
+#if !defined(NoF)
+#if defined(__STDC__) || defined(__STDPP__)
+#define NoF(x) void _DATA_ ## x () {}
+#else
+#define NoF(x) void _DATA_/**/x () {}
+#endif
+#if !defined(_DATA_)
+#define _DATA_
+#endif
+#endif
+
+#if !defined(NoN)
+#if defined(__STDC__) || defined(__STDPP__)
+#define NoN(x) void _STUB_ ## x () {}
+#else
+#define NoN(x) void _STUB_/**/x () {}
+#endif
+#if !defined(_STUB_)
+#define _STUB_
+#endif
+#endif
+
+#define NOT_USED(x) NoP(x)
+
+typedef int (*Error_f) __PROTO__((__V_*, __V_*, int, ...));
+
+typedef int (*Ast_confdisc_f) __PROTO__((const char*, const char*, const char*));
+typedef int (*Strcmp_context_f) __PROTO__((const char*, const char*, __V_*));
+typedef int (*Strcmp_f) __PROTO__((const char*, const char*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ char* astgetconf __PROTO__((const char*, const char*, const char*, int, Error_f));
+extern __MANGLE__ char* astconf __PROTO__((const char*, const char*, const char*));
+extern __MANGLE__ Ast_confdisc_f astconfdisc __PROTO__((Ast_confdisc_f));
+extern __MANGLE__ void astconflist __PROTO__((Sfio_t*, const char*, int, const char*));
+extern __MANGLE__ off_t astcopy __PROTO__((int, int, off_t));
+extern __MANGLE__ int astlicense __PROTO__((char*, int, char*, char*, int, int, int));
+extern __MANGLE__ int astquery __PROTO__((int, const char*, ...));
+extern __MANGLE__ void astwinsize __PROTO__((int, int*, int*));
+
+extern __MANGLE__ ssize_t base64encode __PROTO__((const __V_*, size_t, __V_**, __V_*, size_t, __V_**));
+extern __MANGLE__ ssize_t base64decode __PROTO__((const __V_*, size_t, __V_**, __V_*, size_t, __V_**));
+extern __MANGLE__ int chresc __PROTO__((const char*, char**));
+extern __MANGLE__ int chrtoi __PROTO__((const char*));
+extern __MANGLE__ int eaccess __PROTO__((const char*, int));
+extern __MANGLE__ char* fmtbase __PROTO__((long, int, int));
+extern __MANGLE__ char* fmtbasell __PROTO__((intmax_t, int, int));
+#define fmtbase(a,b,c) fmtbasell((intmax_t)(a),b,c) /* until 2003-09-01 */
+extern __MANGLE__ char* fmtbuf __PROTO__((size_t));
+extern __MANGLE__ char* fmtclock __PROTO__((Sfulong_t));
+extern __MANGLE__ char* fmtelapsed __PROTO__((unsigned long, int));
+extern __MANGLE__ char* fmterror __PROTO__((int));
+extern __MANGLE__ char* fmtesc __PROTO__((const char*));
+extern __MANGLE__ char* fmtesq __PROTO__((const char*, const char*));
+extern __MANGLE__ char* fmtident __PROTO__((const char*));
+extern __MANGLE__ char* fmtip4 __PROTO__((uint32_t, int));
+extern __MANGLE__ char* fmtfmt __PROTO__((const char*));
+extern __MANGLE__ char* fmtgid __PROTO__((int));
+extern __MANGLE__ char* fmtmatch __PROTO__((const char*));
+extern __MANGLE__ char* fmtmode __PROTO__((int, int));
+extern __MANGLE__ char* fmtnesq __PROTO__((const char*, const char*, size_t));
+extern __MANGLE__ char* fmtnum __PROTO__((unsigned long, int));
+extern __MANGLE__ char* fmtperm __PROTO__((int));
+extern __MANGLE__ char* fmtquote __PROTO__((const char*, const char*, const char*, size_t, int));
+extern __MANGLE__ char* fmtre __PROTO__((const char*));
+extern __MANGLE__ char* fmtscale __PROTO__((Sfulong_t, int));
+extern __MANGLE__ char* fmtsignal __PROTO__((int));
+extern __MANGLE__ char* fmttime __PROTO__((const char*, time_t));
+extern __MANGLE__ char* fmtuid __PROTO__((int));
+extern __MANGLE__ char* fmtversion __PROTO__((unsigned long));
+extern __MANGLE__ __V_* memdup __PROTO__((const __V_*, size_t));
+extern __MANGLE__ void memfatal __PROTO__((void));
+extern __MANGLE__ unsigned int memhash __PROTO__((const __V_*, int));
+extern __MANGLE__ unsigned long memsum __PROTO__((const __V_*, int, unsigned long));
+extern __MANGLE__ char* pathaccess __PROTO__((char*, const char*, const char*, const char*, int));
+extern __MANGLE__ char* pathbin __PROTO__((void));
+extern __MANGLE__ char* pathcanon __PROTO__((char*, int));
+extern __MANGLE__ char* pathcat __PROTO__((char*, const char*, int, const char*, const char*));
+extern __MANGLE__ int pathcd __PROTO__((const char*, const char*));
+extern __MANGLE__ int pathcheck __PROTO__((const char*, const char*, Pathcheck_t*));
+extern __MANGLE__ int pathexists __PROTO__((char*, int));
+extern __MANGLE__ char* pathfind __PROTO__((const char*, const char*, const char*, char*, size_t));
+extern __MANGLE__ int pathgetlink __PROTO__((const char*, char*, int));
+extern __MANGLE__ int pathinclude __PROTO__((const char*));
+extern __MANGLE__ char* pathkey __PROTO__((char*, char*, const char*, const char*, const char*));
+extern __MANGLE__ size_t pathnative __PROTO__((const char*, char*, size_t));
+extern __MANGLE__ char* pathpath __PROTO__((char*, const char*, const char*, int));
+extern __MANGLE__ size_t pathposix __PROTO__((const char*, char*, size_t));
+extern __MANGLE__ char* pathprobe __PROTO__((char*, char*, const char*, const char*, const char*, int));
+extern __MANGLE__ char* pathrepl __PROTO__((char*, const char*, const char*));
+extern __MANGLE__ int pathsetlink __PROTO__((const char*, const char*));
+extern __MANGLE__ char* pathshell __PROTO__((void));
+extern __MANGLE__ char* pathtemp __PROTO__((char*, size_t, const char*, const char*, int*));
+extern __MANGLE__ char* pathtmp __PROTO__((char*, const char*, const char*, int*));
+extern __MANGLE__ char* setenviron __PROTO__((const char*));
+extern __MANGLE__ int stracmp __PROTO__((const char*, const char*));
+extern __MANGLE__ char* strcopy __PROTO__((char*, const char*));
+extern __MANGLE__ unsigned long strelapsed __PROTO__((const char*, char**, int));
+extern __MANGLE__ int stresc __PROTO__((char*));
+extern __MANGLE__ long streval __PROTO__((const char*, char**, long(*)(const char*, char**)));
+extern __MANGLE__ long strexpr __PROTO__((const char*, char**, long(*)(const char*, char**, __V_*), __V_*));
+extern __MANGLE__ int strgid __PROTO__((const char*));
+extern __MANGLE__ int strgrpmatch __PROTO__((const char*, const char*, int*, int, int));
+extern __MANGLE__ unsigned int strhash __PROTO__((const char*));
+extern __MANGLE__ __V_* strlook __PROTO__((const __V_*, size_t, const char*));
+extern __MANGLE__ int strmatch __PROTO__((const char*, const char*));
+extern __MANGLE__ int strmode __PROTO__((const char*));
+extern __MANGLE__ int strnacmp __PROTO__((const char*, const char*, size_t));
+extern __MANGLE__ char* strncopy __PROTO__((char*, const char*, size_t));
+extern __MANGLE__ double strntod __PROTO__((const char*, size_t, char**));
+extern __MANGLE__ _ast_fltmax_t strntold __PROTO__((const char*, size_t, char**));
+extern __MANGLE__ long strntol __PROTO__((const char*, size_t, char**, int));
+extern __MANGLE__ intmax_t strntoll __PROTO__((const char*, size_t, char**, int));
+extern __MANGLE__ unsigned long strntoul __PROTO__((const char*, size_t, char**, int));
+extern __MANGLE__ uintmax_t strntoull __PROTO__((const char*, size_t, char**, int));
+extern __MANGLE__ int stropt __PROTO__((const char*, const __V_*, int, int(*)(__V_*, const __V_*, int, const char*), __V_*));
+extern __MANGLE__ int strperm __PROTO__((const char*, char**, int));
+extern __MANGLE__ __V_* strpsearch __PROTO__((const __V_*, size_t, size_t, const char*, char**));
+extern __MANGLE__ __V_* strsearch __PROTO__((const __V_*, size_t, size_t, Strcmp_f, const char*, __V_*));
+extern __MANGLE__ void strsort __PROTO__((char**, int, int(*)(const char*, const char*)));
+extern __MANGLE__ char* strsubmatch __PROTO__((const char*, const char*, int));
+extern __MANGLE__ unsigned long strsum __PROTO__((const char*, unsigned long));
+extern __MANGLE__ char* strtape __PROTO__((const char*, char**));
+extern __MANGLE__ int strtoip4 __PROTO__((const char*, char**, uint32_t*, unsigned char*));
+extern __MANGLE__ long strton __PROTO__((const char*, char**, char*, int));
+extern __MANGLE__ intmax_t strtonll __PROTO__((const char*, char**, char*, int));
+extern __MANGLE__ int struid __PROTO__((const char*));
+extern __MANGLE__ int struniq __PROTO__((char**, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+/*
+ * C library global data symbols not prototyped by <unistd.h>
+ */
+
+#if !defined(environ) && defined(__DYNAMIC__)
+#define environ __DYNAMIC__(environ)
+#else
+extern __MANGLE__ char** environ;
+#endif
+
+/*
+ * really handy malloc()/free() (__FILE__,__LINE__,__FUNCTION__) tracing
+ * make with VMDEBUG==1 or debug=1 or CCFLAGS=$(CC.DEBUG)
+ * VMDEBUG==0 disables
+ * at runtime export VMDEBUG or VMTRACE per vmalloc.3
+ * to list originating call locations
+ */
+
+#if !_std_malloc && !defined(VMFL) && !defined(_VMHDR_H) && \
+ (!defined(VMDEBUG) || VMDEBUG) && (VMDEBUG || _BLD_DEBUG)
+
+#define VMFL 1
+#include <vmalloc.h>
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_botch.h b/usr/src/lib/libast/amd64/include/ast/ast_botch.h
new file mode 100644
index 0000000000..2c136acb13
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_botch.h
@@ -0,0 +1,26 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/botch.c by iffe version 2007-04-04 : : */
+#ifndef _def_botch_ast
+#define _def_botch_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_ccode.h b/usr/src/lib/libast/amd64/include/ast/ast_ccode.h
new file mode 100644
index 0000000000..96a54d2381
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_ccode.h
@@ -0,0 +1,50 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/ccode by iffe version 2007-04-04 : : */
+#ifndef _def_ccode_ast
+#define _def_ccode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define CC_ASCII 1 /* ISO-8859-1 */
+#define CC_EBCDIC_E 2 /* Xopen dd(1) EBCDIC */
+#define CC_EBCDIC_I 3 /* Xopen dd(1) IBM */
+#define CC_EBCDIC_O 4 /* IBM-1047 mvs OpenEdition */
+#define CC_EBCDIC_S 5 /* Siemens posix-bc */
+#define CC_EBCDIC_H 6 /* IBM-37 AS/400 */
+#define CC_EBCDIC_M 7 /* IBM mvs cobol */
+#define CC_EBCDIC_U 8 /* microfocus cobol */
+
+#define CC_MAPS 8 /* number of code maps */
+
+#define CC_EBCDIC CC_EBCDIC_E
+#define CC_EBCDIC1 CC_EBCDIC_E
+#define CC_EBCDIC2 CC_EBCDIC_I
+#define CC_EBCDIC3 CC_EBCDIC_O
+
+#define CC_NATIVE CC_ASCII /* native character code */
+#define CC_ALIEN CC_EBCDIC /* alien character code */
+
+#define CC_bel 0007 /* bel character */
+#define CC_esc 0033 /* esc character */
+#define CC_sub 0032 /* sub character */
+#define CC_vt 0013 /* vt character */
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_common.h b/usr/src/lib/libast/amd64/include/ast/ast_common.h
new file mode 100644
index 0000000000..3354b1dd8d
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_common.h
@@ -0,0 +1,220 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/common by iffe version 2007-04-04 : : */
+#ifndef _AST_COMMON_H
+#define _AST_COMMON_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_pthread 1 /* #include <pthread.h> ok */
+#define _hdr_stdarg 1 /* #include <stdarg.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdint 1 /* #include <stdint.h> ok */
+#define _hdr_inttypes 1 /* #include <inttypes.h> ok */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_long_double 1 /* long double is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _std_proto 1 /* standard C prototypes ok */
+#define _ptr_void 1 /* standard C void* ok */
+/* disable non-standard linux/gnu inlines */
+#ifdef __GNUC__
+# undef __OPTIMIZE_SIZE__
+# define __OPTIMIZE_SIZE__ 1
+#endif
+
+/* __STD_C indicates that the language is ANSI-C or C++ */
+#if !defined(__STD_C) && __STDC__
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && (__cplusplus || c_plusplus)
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && _std_proto
+# define __STD_C 1
+#endif
+#if !defined(__STD_C)
+# define __STD_C 0
+#endif
+
+/* extern symbols must be protected against C++ name mangling */
+#ifndef _BEGIN_EXTERNS_
+# if __cplusplus || c_plusplus
+# define _BEGIN_EXTERNS_ extern "C" {
+# define _END_EXTERNS_ }
+# else
+# define _BEGIN_EXTERNS_
+# define _END_EXTERNS_
+# endif
+#endif
+
+/* _ARG_ simplifies function prototyping among flavors of C */
+#ifndef _ARG_
+# if __STD_C
+# define _ARG_(x) x
+# else
+# define _ARG_(x) ()
+# endif
+#endif
+
+/* _NIL_ simplifies defining nil pointers to a given type */
+#ifndef _NIL_
+# define _NIL_(x) ((x)0)
+#endif
+
+/* __INLINE__ is the inline keyword */
+#if !defined(__INLINE__) && defined(__cplusplus)
+# define __INLINE__ inline
+#endif
+#if !defined(__INLINE__) && defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+#endif
+
+/* Void_t is defined so that Void_t* can address any type */
+#ifndef Void_t
+# if __STD_C
+# define Void_t void
+# else
+# define Void_t char
+# endif
+#endif
+
+/* windows variants and veneers */
+#if !defined(_WINIX) && (_UWIN || __CYGWIN__ || __EMX__)
+# define _WINIX 1
+#endif
+
+/* dynamic linked library external scope handling */
+#ifdef __DYNAMIC__
+# undef __DYNAMIC__
+# ifndef _DLL
+# define _DLL 1
+# endif
+#endif
+#if _dll_import
+# if _BLD_STATIC && !_BLD_DLL
+# undef _DLL
+# else
+# if !_UWIN && !defined(_DLL)
+# define _DLL 1
+# endif
+# endif
+# if !defined(__EXPORT__) && _BLD_DLL
+# define __EXPORT__ __declspec(dllexport)
+# endif
+# if !defined(__IMPORT__) && ( _BLD_DLL || defined(_DLL) )
+# define __IMPORT__ __declspec(dllimport)
+# endif
+# if _BLD_DLL && _UWIN
+# define __DYNAMIC__(v) (_ast_getdll()->_ast_ ## v)
+# endif
+#endif
+#if !defined(_astimport)
+# if defined(__IMPORT__) && defined(_DLL)
+# define _astimport __IMPORT__
+# else
+# define _astimport extern
+# endif
+#endif
+#if _dll_import && ( !_BLD_DLL || _WINIX && !_UWIN )
+# ifdef __STDC__
+# define __EXTERN__(T,obj) extern T obj; T* _imp__ ## obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__ ## obj = &obj
+# else
+# define __EXTERN__(T,obj) extern T obj; T* _imp__/**/obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__/**/obj = &obj
+# endif
+#else
+# define __EXTERN__(T,obj) extern T obj
+# define __DEFINE__(T,obj,val) T obj = val
+#endif
+
+#define _ast_LL 1 /* LL numeric suffix supported */
+#define _ast_int1_t char
+#define _ast_int2_t short
+#define _ast_int4_t int
+#define _ast_int8_t long
+#define _ast_intmax_t _ast_int8_t
+#define _ast_intmax_long 1
+#define _ast_intswap 7
+
+#define _ast_flt4_t float
+#define _ast_flt8_t double
+#define _ast_flt16_t long double
+#define _ast_fltmax_t _ast_flt16_t
+#define _typ_int8_t 1 /* int8_t is a type */
+#define _typ_uint8_t 1 /* uint8_t is a type */
+#define _typ_int16_t 1 /* int16_t is a type */
+#define _typ_uint16_t 1 /* uint16_t is a type */
+#define _typ_int32_t 1 /* int32_t is a type */
+#define _typ_uint32_t 1 /* uint32_t is a type */
+#define _typ_int64_t 1 /* int64_t is a type */
+#define _typ_uint64_t 1 /* uint64_t is a type */
+#define _typ_intmax_t 1 /* intmax_t is a type */
+#define _typ_uintmax_t 1 /* uintmax_t is a type */
+
+#ifndef va_listref
+#define va_listref(p) (&(p)) /* pass va_list to varargs function */
+#define va_listval(p) (*(p)) /* retrieve va_list from va_arg(ap,va_listarg) */
+#define va_listarg va_list* /* va_arg() va_list type */
+#ifndef va_start
+#if __STD_C
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+#endif
+#ifndef _AST_STD_H
+# if __STD_C && _hdr_stddef
+# include <stddef.h>
+# endif
+# if _sys_types
+# include <sys/types.h>
+# endif
+# if _hdr_stdint
+# include <stdint.h>
+# else
+# if _hdr_inttypes
+# include <inttypes.h>
+# endif
+# endif
+#endif
+#if !_typ_size_t
+# define _typ_size_t 1
+ typedef int size_t;
+#endif
+#if !_typ_ssize_t
+# define _typ_ssize_t 1
+ typedef int ssize_t;
+#endif
+#ifndef _AST_STD_H
+# if !_def_map_ast
+# include <ast_map.h>
+# endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_dir.h b/usr/src/lib/libast/amd64/include/ast/ast_dir.h
new file mode 100644
index 0000000000..336b7f38a6
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_dir.h
@@ -0,0 +1,86 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * AT&T Research
+ *
+ * common dirent maintenance interface
+ */
+
+#ifndef _AST_DIR_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_DIR_H
+
+#include <ast_lib.h>
+
+#if _mem_d_fileno_dirent || _mem_d_ino_dirent
+#if !_mem_d_fileno_dirent
+#undef _mem_d_fileno_dirent
+#define _mem_d_fileno_dirent 1
+#define d_fileno d_ino
+#endif
+#endif
+
+#if _BLD_ast
+#include "dirlib.h"
+#else
+#include <dirent.h>
+#endif
+
+#if _mem_d_fileno_dirent
+#define D_FILENO(d) ((d)->d_fileno)
+#endif
+
+#if _mem_d_namlen_dirent
+#define D_NAMLEN(d) ((d)->d_namlen)
+#else
+#define D_NAMLEN(d) (strlen((d)->d_name))
+#endif
+
+#if _mem_d_reclen_dirent
+#define D_RECLEN(d) ((d)->d_reclen)
+#else
+#define D_RECLEN(d) D_RECSIZ(d,D_NAMLEN(d))
+#endif
+
+#define D_RECSIZ(d,n) (sizeof(*(d))-sizeof((d)->d_name)+((n)+sizeof(char*))&~(sizeof(char*)-1))
+
+/*
+ * NOTE: 2003-03-27 mac osx bug symlink==DT_REG bug discovered;
+ * the kernel *and* all directories must be fixed, so d_type
+ * is summarily disabled until we see that happen
+ */
+
+#if _mem_d_type_dirent && defined(DT_UNKNOWN) && defined(DT_REG) && defined(DT_DIR) && defined(DT_LNK) && ! ( __APPLE__ || __MACH__ )
+#define D_TYPE(d) ((d)->d_type)
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_dirent.h b/usr/src/lib/libast/amd64/include/ast/ast_dirent.h
new file mode 100644
index 0000000000..55c226bc01
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_dirent.h
@@ -0,0 +1,103 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/dirent by iffe version 2007-04-04 : : */
+
+#ifndef _def_dirent_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dirent_ast 1
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _nxt_dirent <../include/dirent.h> /* include path for the native <dirent.h> */
+#define _nxt_dirent_str "../include/dirent.h" /* include string for the native <dirent.h> */
+/*
+ * <dirent.h> for systems with ok <dirent.h>
+ */
+
+#ifndef _DIRENT_H
+
+#include <../include/dirent.h> /* the native <dirent.h> */
+
+#ifndef _DIRENT_H
+#define _DIRENT_H
+#endif
+
+#endif
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_fcntl.h b/usr/src/lib/libast/amd64/include/ast/ast_fcntl.h
new file mode 100644
index 0000000000..271e6a1c0e
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_fcntl.h
@@ -0,0 +1,135 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/fcntl.c by iffe version 2007-04-04 : : */
+#ifndef _def_fcntl_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fcntl_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <ast_fs.h>
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#define O_BINARY 0
+#define O_TEMPORARY 0
+#define O_TEXT 0
+
+#include <ast_fs.h>
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_fstat64
+#define fstat fstat64
+#endif
+#if _lib_lstat64
+#define lstat lstat64
+#endif
+#if _lib_stat64
+#define stat stat64
+#endif
+#if _lib_creat64
+#define creat creat64
+#endif
+#if _lib_mmap64
+#define mmap mmap64
+#endif
+#if _lib_open64
+#undef open
+#define open open64
+#endif
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_float.h b/usr/src/lib/libast/amd64/include/ast/ast_float.h
new file mode 100644
index 0000000000..844f02c25a
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_float.h
@@ -0,0 +1,233 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/float by iffe version 2007-04-04 : : */
+
+#ifndef _def_float_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_float_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_float 1 /* #include <float.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _hdr_values 1 /* #include <values.h> ok */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_frexp 1 /* frexp() in default lib(s) */
+#define _lib_frexpl 1 /* frexpl() in default lib(s) */
+#define _lib_ldexp 1 /* ldexp() in default lib(s) */
+#define _lib_ldexpl 1 /* ldexpl() in default lib(s) */
+#define _lib_finite 1 /* finite() in default lib(s) */
+#define _lib_isnan 1 /* isnan() in default lib(s) */
+#define _lib_isnanl 1 /* isnanl() in default lib(s) */
+#define _lib_copysign 1 /* copysign() in default lib(s) */
+#define _lib_copysignl 1 /* copysignl() in default lib(s) */
+#include <ast_common.h>
+#include <float.h>
+#include <math.h>
+#ifndef FLT_DIG
+#define FLT_DIG 6
+#endif
+#ifndef FLT_MAX
+#define FLT_MAX 3.4028234663852885981170E+38F
+#endif
+#ifndef FLT_MAX_10_EXP
+#define FLT_MAX_10_EXP ( + 38 )
+#endif
+#ifndef FLT_MAX_EXP
+#define FLT_MAX_EXP ( + 128 )
+#endif
+#ifndef FLT_MIN
+#define FLT_MIN 1.1754943508222875079688E-38F
+#endif
+#ifndef FLT_MIN_10_EXP
+#define FLT_MIN_10_EXP ( - 37 )
+#endif
+#ifndef FLT_MIN_EXP
+#define FLT_MIN_EXP ( - 125 )
+#endif
+#ifndef DBL_DIG
+#define DBL_DIG 15
+#endif
+#ifndef DBL_MAX
+#define DBL_MAX 1.7976931348623157081452E+308
+#endif
+#ifndef DBL_MAX_10_EXP
+#define DBL_MAX_10_EXP ( + 308 )
+#endif
+#ifndef DBL_MAX_EXP
+#define DBL_MAX_EXP ( + 1024 )
+#endif
+#ifndef DBL_MIN
+#define DBL_MIN 2.2250738585072013830903E-308
+#endif
+#ifndef DBL_MIN_10_EXP
+#define DBL_MIN_10_EXP ( - 307 )
+#endif
+#ifndef DBL_MIN_EXP
+#define DBL_MIN_EXP ( - 1021 )
+#endif
+#ifndef LDBL_DIG
+#define LDBL_DIG 18
+#endif
+#ifndef LDBL_MAX
+#define LDBL_MAX 1.1897314953572317650213E+4932L
+#endif
+#ifndef LDBL_MAX_10_EXP
+#define LDBL_MAX_10_EXP ( + 4932 )
+#endif
+#ifndef LDBL_MAX_EXP
+#define LDBL_MAX_EXP ( + 16384 )
+#endif
+#ifndef LDBL_MIN
+#define LDBL_MIN 3.3621031431120935062627E-4932L
+#endif
+#ifndef LDBL_MIN_10_EXP
+#define LDBL_MIN_10_EXP ( - 4931 )
+#endif
+#ifndef LDBL_MIN_EXP
+#define LDBL_MIN_EXP ( - 16381 )
+#endif
+
+
+#define USHRT_DIG 4
+#define UINT_DIG 9
+#define ULONG_DIG 19
+#define UINTMAX_DIG ULONG_DIG
+
+#define FLT_ULONG_MAX 18446744073709551615.0F
+#define FLT_ULLONG_MAX FLT_ULONG_MAX
+#define FLT_UINTMAX_MAX FLT_ULONG_MAX
+#define FLT_LONG_MAX 9223372036854775807.0F
+#define FLT_LLONG_MAX FLT_LONG_MAX
+#define FLT_INTMAX_MAX FLT_LONG_MAX
+#define FLT_LONG_MIN (-9223372036854775808.0F)
+#define FLT_LLONG_MIN FLT_LONG_MIN
+#define FLT_INTMAX_MIN FLT_LONG_MIN
+
+#define DBL_ULONG_MAX 18446744073709551615.0
+#define DBL_ULLONG_MAX DBL_ULONG_MAX
+#define DBL_UINTMAX_MAX DBL_ULONG_MAX
+#define DBL_LONG_MAX 9223372036854775807.0
+#define DBL_LLONG_MAX DBL_LONG_MAX
+#define DBL_INTMAX_MAX DBL_LONG_MAX
+#define DBL_LONG_MIN (-9223372036854775808.0)
+#define DBL_LLONG_MIN DBL_LONG_MIN
+#define DBL_INTMAX_MIN DBL_LONG_MIN
+
+#define LDBL_ULONG_MAX 18446744073709551615.0L
+#define LDBL_ULLONG_MAX LDBL_ULONG_MAX
+#define LDBL_UINTMAX_MAX LDBL_ULONG_MAX
+#define LDBL_LONG_MAX 9223372036854775807.0L
+#define LDBL_LLONG_MAX LDBL_LONG_MAX
+#define LDBL_INTMAX_MAX LDBL_LONG_MAX
+#define LDBL_LONG_MIN (-9223372036854775808.0L)
+#define LDBL_LLONG_MIN LDBL_LONG_MIN
+#define LDBL_INTMAX_MIN LDBL_LONG_MIN
+
+#define FLTMAX_UINTMAX_MAX LDBL_UINTMAX_MAX
+#define FLTMAX_INTMAX_MAX LDBL_INTMAX_MAX
+#define FLTMAX_INTMAX_MIN LDBL_INTMAX_MIN
+
+typedef union _ast_dbl_exp_u
+{
+ uint32_t e[sizeof(double)/4];
+ double f;
+} _ast_dbl_exp_t;
+
+#define _ast_dbl_exp_index 1
+#define _ast_dbl_exp_shift 20
+
+typedef union _fltmax_exp_u
+{
+ uint32_t e[sizeof(_ast_fltmax_t)/4];
+ _ast_fltmax_t f;
+} _ast_fltmax_exp_t;
+
+#define _ast_fltmax_exp_index 2
+#define _ast_fltmax_exp_shift 0
+
+#define _ast_flt_unsigned_max_t unsigned long long
+#define _ast_flt_nan_init 0xff,0xff,0xff,0x7f
+#define _ast_flt_inf_init 0x00,0x00,0x80,0x7f
+#define _ast_dbl_nan_init 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f
+#define _ast_dbl_inf_init 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x7f
+#define _ast_ldbl_nan_init 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x40,0x00,0x00,0x00,0x00,0x00
+#define _ast_ldbl_inf_init 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x7f,0x40,0x00,0x00,0x00,0x00,0x00
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_fs.h b/usr/src/lib/libast/amd64/include/ast/ast_fs.h
new file mode 100644
index 0000000000..344cf98089
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_fs.h
@@ -0,0 +1,174 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/fs by iffe version 2007-04-04 : : */
+
+#ifndef _def_fs_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fs_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _lib_lstat 1 /* lstat() in default lib(s) */
+#define _lib_mknod 1 /* mknod() in default lib(s) */
+#define _lib_sync 1 /* sync() in default lib(s) */
+#include <sys/stat.h>
+#define FS_default "ufs"
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef major
+#define major(x) ( major_t ) ( ( ( ( unsigned ) ( ( x ) ) ) >> 8 ) & 0x7f )
+#endif
+#ifndef minor
+#define minor(x) ( minor_t ) ( ( ( x ) ) & 0xff )
+#endif
+#ifndef makedev
+#define makedev(x,y) ( unsigned short ) ( ( ( ( x ) ) << 8 ) | ( ( ( y ) ) & 0xff ) )
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _sys_mntent 1 /* #include <sys/mntent.h> ok */
+#define _sys_mnttab 1 /* #include <sys/mnttab.h> ok */
+#define _mem_st_blocks_stat 1 /* st_blocks is a member of struct stat */
+#define _mem_st_blksize_stat 1 /* st_blksize is a member of struct stat */
+#define _mem_st_rdev_stat 1 /* st_rdev is a member of struct stat */
+#define _sys_statfs 1 /* #include <sys/statfs.h> ok */
+#define _mem_f_files_statfs 1 /* f_files is a member of struct statfs */
+#define _sys_vfs 1 /* #include <sys/vfs.h> ok */
+#define _sys_param 1 /* #include <sys/param.h> ok */
+#define _sys_mount 1 /* #include <sys/mount.h> ok */
+#define _sys_statvfs 1 /* #include <sys/statvfs.h> ok */
+#define _mem_f_basetype_statvfs 1 /* f_basetype is a member of struct statvfs */
+#define _mem_f_frsize_statvfs 1 /* f_frsize is a member of struct statvfs */
+#define _lib_getmntent 1 /* getmntent() in default lib(s) */
+#define _lib_statfs 1 /* statfs() in default lib(s) */
+#define _lib_statvfs 1 /* statvfs() in default lib(s) */
+#define _lib_statfs4 1 /* compile{\ passed */
+#if _sys_statvfs
+#include <sys/statvfs.h>
+#if !_mem_statvfs_f_basetype
+#if _ary_f_reserved7
+#define f_basetype f_reserved7
+#endif
+#endif
+#else
+#define _mem_f_basetype_statvfs 1
+#define _mem_f_frsize_statvfs 1
+struct statvfs
+{
+unsigned long f_bsize; /* fundamental file system block size */
+unsigned long f_frsize; /* fragment size */
+unsigned long f_blocks; /* total # of blocks of f_frsize on fs */
+unsigned long f_bfree; /* total # of free blocks of f_frsize */
+unsigned long f_bavail; /* # of free blocks avail to non-superuser */
+unsigned long f_files; /* total # of file nodes (inodes) */
+unsigned long f_ffree; /* total # of free file nodes */
+unsigned long f_favail; /* # of free nodes avail to non-superuser */
+unsigned long f_fsid; /* file system id (dev for now) */
+char f_basetype[16]; /* target fs type name, null-terminated */
+unsigned long f_flag; /* bit-mask of flags */
+unsigned long f_namemax; /* maximum file name length */
+char f_fstr[32]; /* filesystem-specific string */
+unsigned long f_filler[16]; /* reserved for future expansion */
+};
+extern __MANGLE__ int fstatvfs __PROTO__((int, struct statvfs*));
+extern __MANGLE__ int statvfs __PROTO__((const char*, struct statvfs*));
+#endif
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_statvfs64 && !defined(statvfs)
+#define statvfs statvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int statvfs64 __PROTO__((const char*, struct statvfs64*));
+#endif
+#endif
+#if _lib_fstatvfs64 && !defined(fstatvfs)
+#define fstatvfs fstatvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int fstatvfs64 __PROTO__((int, struct statvfs64*));
+#endif
+#endif
+
+#define _str_st_fstype 1 /* stat.st_fstype is a string */
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_getopt.h b/usr/src/lib/libast/amd64/include/ast/ast_getopt.h
new file mode 100644
index 0000000000..0de85c6172
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_getopt.h
@@ -0,0 +1,51 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * legacy standard getopt interface
+ */
+
+#ifndef _AST_GETOPT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_GETOPT_H 1
+
+extern __MANGLE__ int opterr;
+extern __MANGLE__ int optind;
+extern __MANGLE__ int optopt;
+extern __MANGLE__ char* optarg;
+
+#ifndef NULL /* in case <stdlib.h> or <stdio.h> got here first */
+
+extern __MANGLE__ int getopt __PROTO__((int, char* const*, const char*));
+extern __MANGLE__ int getsubopt __PROTO__((char**, char* const*, char**));
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_iconv.h b/usr/src/lib/libast/amd64/include/ast/ast_iconv.h
new file mode 100644
index 0000000000..04a18320d1
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_iconv.h
@@ -0,0 +1,153 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/iconv by iffe version 2007-04-04 : : */
+
+#ifndef _def_iconv_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_iconv_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_iconv 1 /* #include <iconv.h> ok */
+#define _lib_iconv_open 1 /* iconv_open() in default lib(s) */
+#define _lib_iconv_close 1 /* iconv_close() in default lib(s) */
+#define _lib_iconv 1 /* iconv() in default lib(s) */
+#define _nxt_iconv <../include/iconv.h> /* include path for the native <iconv.h> */
+#define _nxt_iconv_str "../include/iconv.h" /* include string for the native <iconv.h> */
+#include <ast_common.h>
+#include <ccode.h>
+#include <../include/iconv.h> /* the native iconv.h */
+
+#define CC_ICONV (-1)
+#define CC_UCS (-2)
+#define CC_SCU (-3)
+#define CC_UTF (-4)
+#define CC_UME (-5)
+
+#ifndef _ICONV_LIST_PRIVATE_
+#undef iconv_t
+#define iconv_t _ast_iconv_t
+#undef iconv_f
+#define iconv_f _ast_iconv_f
+#undef iconv_list_t
+#define iconv_list_t _ast_iconv_list_t
+#undef iconv_open
+#define iconv_open _ast_iconv_open
+#undef iconv
+#define iconv _ast_iconv
+#undef iconv_close
+#define iconv_close _ast_iconv_close
+#undef iconv_list
+#define iconv_list _ast_iconv_list
+#undef iconv_move
+#define iconv_move _ast_iconv_move
+#undef iconv_name
+#define iconv_name _ast_iconv_name
+#undef iconv_write
+#define iconv_write _ast_iconv_write
+#endif
+
+typedef Ccmap_t _ast_iconv_list_t;
+typedef __V_* _ast_iconv_t;
+typedef size_t (*_ast_iconv_f) __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ _ast_iconv_t _ast_iconv_open __PROTO__((const char*, const char*));
+extern __MANGLE__ size_t _ast_iconv __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+extern __MANGLE__ int _ast_iconv_close __PROTO__((_ast_iconv_t));
+extern __MANGLE__ _ast_iconv_list_t* _ast_iconv_list __PROTO__((_ast_iconv_list_t*));
+extern __MANGLE__ int _ast_iconv_name __PROTO__((const char*, char*, size_t));
+#if _SFIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, Sfio_t*, Sfio_t*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, Sfio_t*, char**, size_t*, size_t*));
+#else
+#if _SFSTDIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, FILE*, FILE*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, FILE*, char**, size_t*, size_t*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_lib.h b/usr/src/lib/libast/amd64/include/ast/ast_lib.h
new file mode 100644
index 0000000000..f493d01f09
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_lib.h
@@ -0,0 +1,181 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/lib by iffe version 2007-04-04 : : */
+#ifndef _def_lib_ast
+#define _def_lib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _hdr_fmtmsg 1 /* #include <fmtmsg.h> ok */
+#define _hdr_fnmatch 1 /* #include <fnmatch.h> ok */
+#define _hdr_libgen 1 /* #include <libgen.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_locale 1 /* #include <locale.h> ok */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_spawn 1 /* #include <spawn.h> ok */
+#define _hdr_syslog 1 /* #include <syslog.h> ok */
+#define _hdr_utime 1 /* #include <utime.h> ok */
+#define _hdr_wctype 1 /* #include <wctype.h> ok */
+#define _hdr_wchar 1 /* <wchar.h> and isw*() really work */
+#define _dat__tzname 1 /* _tzname in default lib(s) */
+#define _dat_tzname 1 /* tzname in default lib(s) */
+#define _lib__cleanup 1 /* _cleanup() in default lib(s) */
+#define _lib_atexit 1 /* atexit() in default lib(s) */
+#define _lib_bcopy 1 /* bcopy() in default lib(s) */
+#define _lib_bzero 1 /* bzero() in default lib(s) */
+#define _lib_catclose 1 /* catclose() in default lib(s) */
+#define _lib_catgets 1 /* catgets() in default lib(s) */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_confstr 1 /* confstr() in default lib(s) */
+#define _lib_dup2 1 /* dup2() in default lib(s) */
+#define _lib_execlp 1 /* execlp() in default lib(s) */
+#define _lib_execve 1 /* execve() in default lib(s) */
+#define _lib_execvp 1 /* execvp() in default lib(s) */
+#define _lib_fchmod 1 /* fchmod() in default lib(s) */
+#define _lib_fcntl 1 /* fcntl() in default lib(s) */
+#define _lib_fmtmsg 1 /* fmtmsg() in default lib(s) */
+#define _lib_fnmatch 1 /* fnmatch() in default lib(s) */
+#define _lib_fork 1 /* fork() in default lib(s) */
+#define _lib_fsync 1 /* fsync() in default lib(s) */
+#define _lib_getdents 1 /* getdents() in default lib(s) */
+#define _lib_getdtablesize 1 /* getdtablesize() in default lib(s) */
+#define _lib_getdate 1 /* getdate() in default lib(s) */
+#define _lib_getgroups 1 /* getgroups() in default lib(s) */
+#define _lib_gethostname 1 /* gethostname() in default lib(s) */
+#define _lib_getlogin 1 /* getlogin() in default lib(s) */
+#define _lib_getpagesize 1 /* getpagesize() in default lib(s) */
+#define _lib_getrlimit 1 /* getrlimit() in default lib(s) */
+#define _lib_getopt 1 /* getopt() in default lib(s) */
+#define _lib_getsubopt 1 /* getsubopt() in default lib(s) */
+#define _lib_getopt_long 1 /* getopt_long() in default lib(s) */
+#define _lib_getopt_long_only 1 /* getopt_long_only() in default lib(s) */
+#define _lib_glob 1 /* glob() in default lib(s) */
+#define _lib_index 1 /* index() in default lib(s) */
+#define _lib_iswblank 1 /* iswblank() in default lib(s) */
+#define _lib_iswctype 1 /* iswctype() in default lib(s) */
+#define _lib_killpg 1 /* killpg() in default lib(s) */
+#define _lib_link 1 /* link() in default lib(s) */
+#define _lib_localeconv 1 /* localeconv() in default lib(s) */
+#define _lib_madvise 1 /* madvise() in default lib(s) */
+#define _lib_mbtowc 1 /* mbtowc() in default lib(s) */
+#define _lib_mbrtowc 1 /* mbrtowc() in default lib(s) */
+#define _lib_memalign 1 /* memalign() in default lib(s) */
+#define _lib_memchr 1 /* memchr() in default lib(s) */
+#define _lib_memcpy 1 /* memcpy() in default lib(s) */
+#define _lib_memmove 1 /* memmove() in default lib(s) */
+#define _lib_memset 1 /* memset() in default lib(s) */
+#define _lib_mkdir 1 /* mkdir() in default lib(s) */
+#define _lib_mkfifo 1 /* mkfifo() in default lib(s) */
+#define _lib_mktemp 1 /* mktemp() in default lib(s) */
+#define _lib_mktime 1 /* mktime() in default lib(s) */
+#define _lib_mount 1 /* mount() in default lib(s) */
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _lib_pathconf 1 /* pathconf() in default lib(s) */
+#define _lib_readlink 1 /* readlink() in default lib(s) */
+#define _lib_remove 1 /* remove() in default lib(s) */
+#define _lib_rename 1 /* rename() in default lib(s) */
+#define _lib_rewinddir 1 /* rewinddir() in default lib(s) */
+#define _lib_rindex 1 /* rindex() in default lib(s) */
+#define _lib_rmdir 1 /* rmdir() in default lib(s) */
+#define _lib_setlocale 1 /* setlocale() in default lib(s) */
+#define _lib_setpgid 1 /* setpgid() in default lib(s) */
+#define _lib_setpgrp 1 /* setpgrp() in default lib(s) */
+#define _lib_setreuid 1 /* setreuid() in default lib(s) */
+#define _lib_setsid 1 /* setsid() in default lib(s) */
+#define _lib_setuid 1 /* setuid() in default lib(s) */
+#define _lib_sigaction 1 /* sigaction() in default lib(s) */
+#define _lib_sigprocmask 1 /* sigprocmask() in default lib(s) */
+#define _lib_socketpair 1 /* socketpair() in default lib(s) */
+#define _lib_strchr 1 /* strchr() in default lib(s) */
+#define _lib_strcoll 1 /* strcoll() in default lib(s) */
+#define _lib_strdup 1 /* strdup() in default lib(s) */
+#define _lib_strerror 1 /* strerror() in default lib(s) */
+#define _lib_strcasecmp 1 /* strcasecmp() in default lib(s) */
+#define _lib_strncasecmp 1 /* strncasecmp() in default lib(s) */
+#define _lib_strrchr 1 /* strrchr() in default lib(s) */
+#define _lib_strstr 1 /* strstr() in default lib(s) */
+#define _lib_strxfrm 1 /* strxfrm() in default lib(s) */
+#define _lib_strftime 1 /* strftime() in default lib(s) */
+#define _lib_swab 1 /* swab() in default lib(s) */
+#define _lib_symlink 1 /* symlink() in default lib(s) */
+#define _lib_sysconf 1 /* sysconf() in default lib(s) */
+#define _lib_sysinfo 1 /* sysinfo() in default lib(s) */
+#define _lib_syslog 1 /* syslog() in default lib(s) */
+#define _lib_telldir 1 /* telldir() in default lib(s) */
+#define _lib_tmpnam 1 /* tmpnam() in default lib(s) */
+#define _lib_tzset 1 /* tzset() in default lib(s) */
+#define _lib_unlink 1 /* unlink() in default lib(s) */
+#define _lib_utime 1 /* utime() in default lib(s) */
+#define _lib_wctype 1 /* wctype() in default lib(s) */
+#define _lib_ftruncate 1 /* ftruncate() in default lib(s) */
+#define _lib_truncate 1 /* truncate() in default lib(s) */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _lib_strtod 1 /* strtod() in default lib(s) */
+#define _lib_strtold 1 /* strtold() in default lib(s) */
+#define _lib_strtol 1 /* strtol() in default lib(s) */
+#define _lib_strtoll 1 /* strtoll() in default lib(s) */
+#define _lib_strtoul 1 /* strtoul() in default lib(s) */
+#define _lib_strtoull 1 /* strtoull() in default lib(s) */
+#define _mem_d_ino_dirent 1 /* d_ino is a member of struct dirent */
+#define _mem_d_off_dirent 1 /* d_off is a member of struct dirent */
+#define _mem_d_reclen_dirent 1 /* d_reclen is a member of struct dirent */
+#define _mem_DIR 1 /* DIR is a non-opaque struct */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _sys_jioctl 1 /* #include <sys/jioctl.h> ok */
+#define _sys_localedef 1 /* #include <sys/localedef.h> ok */
+#define _sys_ptem 1 /* #include <sys/ptem.h> ok */
+#define _sys_resource 1 /* #include <sys/resource.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _sys_stream 1 /* #include <sys/stream.h> ok */
+#define _sys_systeminfo 1 /* #include <sys/systeminfo.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_off64_t 1 /* off64_t is a type */
+#define _typ_struct_dirent64 1 /* struct dirent64 is a type */
+#define _tst_errno 1 /* errno can be assigned */
+#define _lib_poll_fd_1 1 /* fd is first arg to poll() */
+#define _lib_poll 1 /* _lib_poll_fd_1||_lib_poll_fd_2 is true */
+#define _lib_select 1 /* select() has standard 5 arg interface */
+#define _pipe_rw 1 /* full duplex pipes */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _lib_vfork 1 /* vfork exists and it works */
+#define _real_vfork 1 /* vfork child shares data with parent */
+#define _lib_posix_spawn 1 /* posix_spawn exists and it works and its worth using */
+#define _stream_peek 1 /* ioctl(I_PEEK) works */
+#define _socket_peek 1 /* recv(MSG_PEEK) works */
+#define _hdr_string 1 /* #include <string.h> ok */
+#define _lib_memcmp 1 /* standard memcmp interface that works */
+#define _hdr_fcntl 1 /* #include <fcntl.h> ok */
+#define _hdr_signal 1 /* #include <signal.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_memccpy 1 /* standard memccpy interface that works */
+#define _lib_utime_now 1 /* utime works with 0 time vector */
+#define _UNIV_DEFAULT "att" /* default universe name */
+#define _std_cleanup 1 /* stuck with standard _cleanup */
+#define _std_strcoll 1 /* standard strcoll works */
+#if !_AST_no_spawnveg
+#define _use_spawnveg 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_limits.h b/usr/src/lib/libast/amd64/include/ast/ast_limits.h
new file mode 100644
index 0000000000..d833cba6d9
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_limits.h
@@ -0,0 +1,128 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/limits.c by iffe version 2007-04-04 : : */
+#ifndef _def_limits_ast
+#define _def_limits_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+#ifndef CHAR_MAX
+#define CHAR_MAX 127
+#endif
+#ifndef CHAR_MIN
+#define CHAR_MIN -128
+#endif
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC 1000000
+#endif
+#ifndef INT_MIN
+#define INT_MIN -2147483648
+#endif
+#ifndef LLONG_MAX
+#define LLONG_MAX 9223372036854775807
+#endif
+#ifndef LLONG_MIN
+#define LLONG_MIN -9223372036854775808
+#endif
+#ifndef LONG_MAX
+#define LONG_MAX 2147483647
+#endif
+#ifndef LONG_MIN
+#define LONG_MIN -2147483648
+#endif
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 5
+#endif
+#ifndef OPEN_MAX_CEIL
+#ifndef OPEN_MAX
+#define OPEN_MAX 256
+#endif
+#define OPEN_MAX_CEIL OPEN_MAX
+#endif
+#ifndef PTHREAD_STACK_MIN
+#define PTHREAD_STACK_MIN 4096
+#endif
+#ifndef PTRDIFF_MAX
+#define PTRDIFF_MAX 9223372036854775807
+#endif
+#ifndef PTRDIFF_MIN
+#define PTRDIFF_MIN -9223372036854775808
+#endif
+#ifndef SCHAR_MAX
+#define SCHAR_MAX 127
+#endif
+#ifndef SCHAR_MIN
+#define SCHAR_MIN -128
+#endif
+#ifndef SHRT_MIN
+#define SHRT_MIN -32768
+#endif
+#ifndef SIG_ATOMIC_MAX
+#define SIG_ATOMIC_MAX 2147483647
+#endif
+#ifndef SIG_ATOMIC_MIN
+#define SIG_ATOMIC_MIN -2147483648
+#endif
+#ifndef SIZE_MAX
+#ifndef UINT_MAX
+#define UINT_MAX 4294967295
+#endif
+#define SIZE_MAX UINT_MAX
+#endif
+#ifndef SSIZE_MAX
+#ifndef INT_MAX
+#define INT_MAX 2147483647
+#endif
+#define SSIZE_MAX INT_MAX
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+#ifndef UCHAR_MAX
+#define UCHAR_MAX 255
+#endif
+#ifndef ULLONG_MAX
+#define ULLONG_MAX 18446744073709551615
+#endif
+#ifndef ULONG_MAX
+#define ULONG_MAX 4294967295
+#endif
+#ifndef USHRT_MAX
+#define USHRT_MAX 65535
+#endif
+#ifndef WCHAR_MAX
+#define WCHAR_MAX 2147483647
+#endif
+#ifndef WCHAR_MIN
+#define WCHAR_MIN -2147483648
+#endif
+#ifndef WINT_MAX
+#define WINT_MAX 2147483647
+#endif
+#ifndef WINT_MIN
+#define WINT_MIN -2147483648
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_map.h b/usr/src/lib/libast/amd64/include/ast/ast_map.h
new file mode 100644
index 0000000000..97f67eb4cd
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_map.h
@@ -0,0 +1,459 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/map.c by iffe version 2007-04-04 : : */
+#ifndef _def_map_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_map_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+/*
+ * prototypes provided for standard interfaces hijacked
+ * by ast and mapped to _ast_* but already prototyped
+ * unmapped in native headers included by <ast_std.h>
+ */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+
+#define _map_libc 1
+#undef basename
+#define basename _ast_basename
+#undef dirname
+#define dirname _ast_dirname
+#undef eaccess
+#define eaccess _ast_eaccess
+#undef execvpe
+#define execvpe _ast_execvpe
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+#undef fnmatch
+#define fnmatch _ast_fnmatch
+#undef fts_children
+#define fts_children _ast_fts_children
+#undef fts_close
+#define fts_close _ast_fts_close
+#undef fts_flags
+#define fts_flags _ast_fts_flags
+#undef fts_notify
+#define fts_notify _ast_fts_notify
+#undef fts_open
+#define fts_open _ast_fts_open
+#undef fts_read
+#define fts_read _ast_fts_read
+#undef fts_set
+#define fts_set _ast_fts_set
+#undef ftw
+#define ftw _ast_ftw
+#undef ftwalk
+#define ftwalk _ast_ftwalk
+#undef ftwflags
+#define ftwflags _ast_ftwflags
+#undef getcwd
+#define getcwd _ast_getcwd
+extern __MANGLE__ char* getcwd __PROTO__((char*, size_t));
+#undef getdate
+#define getdate _ast_getdate
+#undef getopt
+#define getopt _ast_getopt
+#undef getsubopt
+#define getsubopt _ast_getsubopt
+#undef getopt_long
+#define getopt_long _ast_getopt_long
+#undef getopt_long_only
+#define getopt_long_only _ast_getopt_long_only
+#undef getwd
+#define getwd _ast_getwd
+extern __MANGLE__ char* getwd __PROTO__((char*));
+#undef glob
+#define glob _ast_glob
+#undef globfree
+#define globfree _ast_globfree
+#undef memdup
+#define memdup _ast_memdup
+#undef memfatal
+#define memfatal _ast_memfatal
+#undef memhash
+#define memhash _ast_memhash
+#undef memsum
+#define memsum _ast_memsum
+#undef mkstemp
+#define mkstemp _ast_mkstemp
+extern __MANGLE__ int mkstemp __PROTO__((char*));
+#undef mktemp
+#define mktemp _ast_mktemp
+extern __MANGLE__ char* mktemp __PROTO__((char*));
+#undef mktime
+#define mktime _ast_mktime
+#undef nftw
+#define nftw _ast_nftw
+#undef optesc
+#define optesc _ast_optesc
+#undef optget
+#define optget _ast_optget
+#undef opthelp
+#define opthelp _ast_opthelp
+#undef optjoin
+#define optjoin _ast_optjoin
+#undef optstr
+#define optstr _ast_optstr
+#undef optusage
+#define optusage _ast_optusage
+#undef pathaccess
+#define pathaccess _ast_pathaccess
+#undef pathbin
+#define pathbin _ast_pathbin
+#undef pathcanon
+#define pathcanon _ast_pathcanon
+#undef pathcat
+#define pathcat _ast_pathcat
+#undef pathcd
+#define pathcd _ast_pathcd
+#undef pathcheck
+#define pathcheck _ast_pathcheck
+#undef pathexists
+#define pathexists _ast_pathexists
+#undef pathfind
+#define pathfind _ast_pathfind
+#undef pathgetlink
+#define pathgetlink _ast_pathgetlink
+#undef pathinclude
+#define pathinclude _ast_pathinclude
+#undef pathkey
+#define pathkey _ast_pathkey
+#undef pathnative
+#define pathnative _ast_pathnative
+#undef pathpath
+#define pathpath _ast_pathpath
+#undef pathposix
+#define pathposix _ast_pathposix
+#undef pathprobe
+#define pathprobe _ast_pathprobe
+#undef pathrepl
+#define pathrepl _ast_pathrepl
+#undef pathsetlink
+#define pathsetlink _ast_pathsetlink
+#undef pathshell
+#define pathshell _ast_pathshell
+#undef pathstat
+#define pathstat _ast_pathstat
+#undef pathtemp
+#define pathtemp _ast_pathtemp
+#undef pathtmp
+#define pathtmp _ast_pathtmp
+#undef procclose
+#define procclose _ast_procclose
+#undef procfree
+#define procfree _ast_procfree
+#undef procopen
+#define procopen _ast_procopen
+#undef procrun
+#define procrun _ast_procrun
+#undef putenv
+#define putenv _ast_putenv
+#undef re_comp
+#define re_comp _ast_re_comp
+#undef re_exec
+#define re_exec _ast_re_exec
+#undef realpath
+#define realpath _ast_realpath
+extern __MANGLE__ char* realpath __PROTO__((const char*, char*));
+#undef regaddclass
+#define regaddclass _ast_regaddclass
+#undef regalloc
+#define regalloc _ast_regalloc
+#undef regcache
+#define regcache _ast_regcache
+#undef regclass
+#define regclass _ast_regclass
+#undef regcmp
+#define regcmp _ast_regcmp
+#undef regcollate
+#define regcollate _ast_regcollate
+#undef regcomb
+#define regcomb _ast_regcomb
+#undef regcomp
+#define regcomp _ast_regcomp
+#undef regdecomp
+#define regdecomp _ast_regdecomp
+#undef regdup
+#define regdup _ast_regdup
+#undef regerror
+#define regerror _ast_regerror
+#undef regex
+#define regex _ast_regex
+#undef regexec
+#define regexec _ast_regexec
+#undef regfatal
+#define regfatal _ast_regfatal
+#undef regfatalpat
+#define regfatalpat _ast_regfatalpat
+#undef regfree
+#define regfree _ast_regfree
+#undef regncomp
+#define regncomp _ast_regncomp
+#undef regnexec
+#define regnexec _ast_regnexec
+#undef regrecord
+#define regrecord _ast_regrecord
+#undef regrexec
+#define regrexec _ast_regrexec
+#undef regstat
+#define regstat _ast_regstat
+#undef regsub
+#define regsub _ast_regsub
+#undef regsubcomp
+#define regsubcomp _ast_regsubcomp
+#undef regsubexec
+#define regsubexec _ast_regsubexec
+#undef regsubflags
+#define regsubflags _ast_regsubflags
+#undef regsubfree
+#define regsubfree _ast_regsubfree
+#undef remove
+#define remove _ast_remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#undef resolvepath
+#define resolvepath _ast_resolvepath
+extern __MANGLE__ char* resolvepath __PROTO__((const char*, char*, size_t));
+#undef setenv
+#define setenv _ast_setenv
+extern __MANGLE__ int setenv __PROTO__((const char*, const char*, int));
+#undef setenviron
+#define setenviron _ast_setenviron
+#undef sigcritical
+#define sigcritical _ast_sigcritical
+#undef signal
+#define signal _ast_signal
+#undef sigunblock
+#define sigunblock _ast_sigunblock
+#undef stracmp
+#define stracmp _ast_stracmp
+#undef strcopy
+#define strcopy _ast_strcopy
+#undef strelapsed
+#define strelapsed _ast_strelapsed
+#undef stresc
+#define stresc _ast_stresc
+#undef streval
+#define streval _ast_streval
+#undef strexpr
+#define strexpr _ast_strexpr
+#undef strftime
+#define strftime _ast_strftime
+#undef strgid
+#define strgid _ast_strgid
+#undef strgrpmatch
+#define strgrpmatch _ast_strgrpmatch
+#undef strhash
+#define strhash _ast_strhash
+#undef strkey
+#define strkey _ast_strkey
+#undef strlcat
+#define strlcat _ast_strlcat
+extern __MANGLE__ size_t strlcat __PROTO__((char*, const char*, size_t));
+#undef strlcpy
+#define strlcpy _ast_strlcpy
+extern __MANGLE__ size_t strlcpy __PROTO__((char*, const char*, size_t));
+#undef strlook
+#define strlook _ast_strlook
+#undef strmatch
+#define strmatch _ast_strmatch
+#undef strmode
+#define strmode _ast_strmode
+#undef strnacmp
+#define strnacmp _ast_strnacmp
+#undef strncopy
+#define strncopy _ast_strncopy
+#undef strntod
+#define strntod _ast_strntod
+#undef strntol
+#define strntol _ast_strntol
+#undef strntold
+#define strntold _ast_strntold
+#undef strntoll
+#define strntoll _ast_strntoll
+#undef strntoul
+#define strntoul _ast_strntoul
+#undef strntoull
+#define strntoull _ast_strntoull
+#undef stropt
+#define stropt _ast_stropt
+#undef strperm
+#define strperm _ast_strperm
+#undef strpsearch
+#define strpsearch _ast_strpsearch
+#undef strptime
+#define strptime _ast_strptime
+#undef strsearch
+#define strsearch _ast_strsearch
+#undef strsort
+#define strsort _ast_strsort
+#undef strsubmatch
+#define strsubmatch _ast_strsubmatch
+#undef strsum
+#define strsum _ast_strsum
+#undef strtape
+#define strtape _ast_strtape
+#undef strtoip4
+#define strtoip4 _ast_strtoip4
+#undef strton
+#define strton _ast_strton
+#undef strtonll
+#define strtonll _ast_strtonll
+#undef struid
+#define struid _ast_struid
+#undef struniq
+#define struniq _ast_struniq
+#undef system
+#define system _ast_system
+extern __MANGLE__ int system __PROTO__((const char*));
+#undef tempnam
+#define tempnam _ast_tempnam
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+#undef tmpnam
+#define tmpnam _ast_tmpnam
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+#undef touch
+#define touch _ast_touch
+#undef wordexp
+#define wordexp _ast_wordexp
+#undef wordfree
+#define wordfree _ast_wordfree
+#undef unsetenv
+#define unsetenv _ast_unsetenv
+
+/* cannot override local malloc */
+#define _map_malloc 1
+#undef calloc
+#define calloc _ast_calloc
+extern __MANGLE__ __V_* calloc __PROTO__((size_t, size_t));
+#undef cfree
+#define cfree _ast_cfree
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+#undef free
+#define free _ast_free
+extern __MANGLE__ void free __PROTO__((__V_*));
+#undef malloc
+#define malloc _ast_malloc
+extern __MANGLE__ __V_* malloc __PROTO__((size_t));
+#undef memalign
+#define memalign _ast_memalign
+extern __MANGLE__ __V_* memalign __PROTO__((size_t, size_t));
+#undef realloc
+#define realloc _ast_realloc
+extern __MANGLE__ __V_* realloc __PROTO__((__V_*, size_t));
+#undef strdup
+#define strdup _ast_strdup
+extern __MANGLE__ char* strdup __PROTO__((const char*));
+#undef valloc
+#define valloc _ast_valloc
+extern __MANGLE__ __V_* valloc __PROTO__((size_t));
+#undef strtol
+#define strtol _ast_strtol
+#undef strtoul
+#define strtoul _ast_strtoul
+#undef strtoll
+#define strtoll _ast_strtoll
+#undef strtoull
+#define strtoull _ast_strtoull
+#undef strtod
+#define strtod _ast_strtod
+#undef strtold
+#define strtold _ast_strtold
+extern __MANGLE__ long strtol __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned long strtoul __PROTO__((const char*, char**, int));
+extern __MANGLE__ double strtod __PROTO__((const char*, char**));
+#if !_UWIN
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
+extern __MANGLE__ _ast_fltmax_t strtold __PROTO__((const char*, char**));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+extern __MANGLE__ _ast_intmax_t strtoll __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned _ast_intmax_t strtoull __PROTO__((const char*, char**, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_mmap.h b/usr/src/lib/libast/amd64/include/ast/ast_mmap.h
new file mode 100644
index 0000000000..b539e3007f
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_mmap.h
@@ -0,0 +1,47 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/mmap by iffe version 2007-04-04 : : */
+#ifndef _def_mmap_ast
+#define _def_mmap_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_mmap 1 /* standard mmap interface that works */
+#define _lib_mmap64 1 /* mmap64 interface and implementation work */
+#define _mmap_anon 1 /* use mmap MAP_ANON to get raw memory */
+#define _mmap_devzero 1 /* use mmap on /dev/zero to get raw memory */
+
+/* some systems get it wrong but escape concise detection */
+#ifndef _NO_MMAP
+#if __CYGWIN__
+#define _NO_MMAP 1
+#endif
+#endif
+
+#if _NO_MMAP
+#undef _lib_mmap
+#undef _lib_mmap64
+#undef _mmap_anon
+#undef _mmap_devzero
+#undef _mmap_worthy
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_mode.h b/usr/src/lib/libast/amd64/include/ast/ast_mode.h
new file mode 100644
index 0000000000..be06d22a5b
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_mode.h
@@ -0,0 +1,35 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/mode.c by iffe version 2007-04-04 : : */
+#ifndef _def_mode_ast
+#define _def_mode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define S_ITYPE(m) ((m)&S_IFMT)
+
+#define S_IPERM (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
+
+#define _S_IDPERM 1
+#define _S_IDTYPE 1
+
+#define BUFFERSIZE 8192
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_nl_types.h b/usr/src/lib/libast/amd64/include/ast/ast_nl_types.h
new file mode 100644
index 0000000000..c2bcc1de13
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_nl_types.h
@@ -0,0 +1,123 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/nl_types by iffe version 2007-04-04 : : */
+
+#ifndef _def_nl_types_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_nl_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_nl_langinfo 1 /* nl_langinfo() in default lib(s) */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_langinfo 1 /* #include <langinfo.h> ok */
+#define _nxt_nl_types <../include/nl_types.h> /* include path for the native <nl_types.h> */
+#define _nxt_nl_types_str "../include/nl_types.h" /* include string for the native <nl_types.h> */
+#include <limits.h>
+#include <../include/nl_types.h> /* the native nl_types.h */
+
+#undef NL_SETMAX
+#define NL_SETMAX 1023
+#undef NL_MSGMAX
+#define NL_MSGMAX 32767
+#undef nl_catd
+#define nl_catd _ast_nl_catd
+#undef catopen
+#define catopen _ast_catopen
+#undef catgets
+#define catgets _ast_catgets
+#undef catclose
+#define catclose _ast_catclose
+
+typedef __V_* nl_catd;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ nl_catd catopen __PROTO__((const char*, int));
+extern __MANGLE__ char* catgets __PROTO__((nl_catd, int, int, const char*));
+extern __MANGLE__ int catclose __PROTO__((nl_catd));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_param.h b/usr/src/lib/libast/amd64/include/ast/ast_param.h
new file mode 100644
index 0000000000..d6eb9ac498
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_param.h
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/param.sh by iffe version 2007-04-04 : : */
+#ifndef _def_param_ast
+#define _def_param_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#include <sys/param.h>
+#ifndef S_IFDIR
+#include <sys/stat.h>
+#endif
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_standards.h b/usr/src/lib/libast/amd64/include/ast/ast_standards.h
new file mode 100644
index 0000000000..5a33b1fa95
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_standards.h
@@ -0,0 +1,49 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/standards by iffe version 2007-04-04 : : */
+#ifndef _def_standards_ast
+#define _def_standards_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* _ALL_SOURCE & _ISOC99_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works */
+#ifndef _ALL_SOURCE
+#define _ALL_SOURCE 1
+#endif
+#ifndef _ISOC99_SOURCE
+#define _ISOC99_SOURCE 1
+#endif
+#ifndef _POSIX_SOURCE
+#define _POSIX_SOURCE 1
+#endif
+#ifndef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 21000101L
+#endif
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 9900
+#endif
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#ifndef __EXTENSIONS__
+#define __EXTENSIONS__ 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_std.h b/usr/src/lib/libast/amd64/include/ast/ast_std.h
new file mode 100644
index 0000000000..68e7984670
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_std.h
@@ -0,0 +1,343 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Advanced Software Technology Library
+ * AT&T Research
+ *
+ * a union of standard headers that works
+ * with local extensions enabled
+ * and local omission compensation
+ */
+
+#ifndef _AST_STD_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_STD_H 1
+#define _AST_STD_I 1
+
+#include <ast_common.h>
+
+#if _BLD_ast
+#define _BLD_cdt 1
+#define _BLD_sfio 1
+#if !_UWIN
+#define _BLD_vmalloc 1
+#endif
+#endif
+
+#ifdef _SFSTDIO_H
+#define _SKIP_SFSTDIO_H
+#else
+#define _SFSTDIO_H
+#ifndef FILE
+#ifndef _SFIO_H
+struct _sfio_s;
+#endif
+#define FILE struct _sfio_s
+#ifndef __FILE_typedef
+#define __FILE_typedef 1
+#endif
+#ifndef _FILEDEFED
+#define _FILEDEFED 1
+#endif
+#endif
+#endif
+
+#include <ast_lib.h>
+#include <ast_sys.h>
+#include <ast_getopt.h> /* <stdlib.h> does this */
+#include <ast_fcntl.h>
+#include <ast_limits.h>
+#include <ast_botch.h>
+
+#ifdef _SKIP_SFSTDIO_H
+#undef _SKIP_SFSTDIO_H
+#else
+#undef _SFSTDIO_H
+#undef FILE
+#endif
+
+/* locale stuff */
+
+#if !_hdr_locale
+
+struct lconv
+{
+ char* decimal_point;
+ char* thousands_sep;
+ char* grouping;
+ char* int_curr_symbol;
+ char* currency_symbol;
+ char* mon_decimal_point;
+ char* mon_thousands_sep;
+ char* mon_grouping;
+ char* positive_sign;
+ char* negative_sign;
+ char int_frac_digits;
+ char frac_digits;
+ char p_cs_precedes;
+ char p_sep_by_space;
+ char n_cs_precedes;
+ char n_sep_by_space;
+ char p_sign_posn;
+ char n_sign_posn;
+};
+
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#undef localeconv
+#define localeconv _ast_localeconv
+
+#undef setlocale
+#define setlocale _ast_setlocale
+
+#undef strerror
+#define strerror _ast_strerror
+
+extern __MANGLE__ struct lconv* localeconv __PROTO__((void));
+extern __MANGLE__ char* setlocale __PROTO__((int, const char*));
+extern __MANGLE__ char* strerror __PROTO__((int));
+
+#define AST_MESSAGE_SET 3 /* see <mc.h> mcindex() */
+
+/*
+ * maintain this order when adding categories
+ */
+
+#define AST_LC_ALL 0
+#define AST_LC_COLLATE 1
+#define AST_LC_CTYPE 2
+#define AST_LC_MESSAGES 3
+#define AST_LC_MONETARY 4
+#define AST_LC_NUMERIC 5
+#define AST_LC_TIME 6
+#define AST_LC_IDENTIFICATION 7
+#define AST_LC_ADDRESS 8
+#define AST_LC_NAME 9
+#define AST_LC_TELEPHONE 10
+#define AST_LC_XLITERATE 11
+#define AST_LC_MEASUREMENT 12
+#define AST_LC_PAPER 13
+#define AST_LC_COUNT 14
+
+#define AST_LC_find (1L<<28)
+#define AST_LC_debug (1L<<29)
+#define AST_LC_setlocale (1L<<30)
+#define AST_LC_translate (1L<<31)
+
+#ifndef LC_ALL
+#define LC_ALL (-AST_LC_ALL)
+#endif
+#ifndef LC_COLLATE
+#define LC_COLLATE (-AST_LC_COLLATE)
+#endif
+#ifndef LC_CTYPE
+#define LC_CTYPE (-AST_LC_CTYPE)
+#endif
+#ifndef LC_MESSAGES
+#define LC_MESSAGES (-AST_LC_MESSAGES)
+#endif
+#ifndef LC_MONETARY
+#define LC_MONETARY (-AST_LC_MONETARY)
+#endif
+#ifndef LC_NUMERIC
+#define LC_NUMERIC (-AST_LC_NUMERIC)
+#endif
+#ifndef LC_TIME
+#define LC_TIME (-AST_LC_TIME)
+#endif
+#ifndef LC_ADDRESS
+#define LC_ADDRESS (-AST_LC_ADDRESS)
+#endif
+#ifndef LC_IDENTIFICATION
+#define LC_IDENTIFICATION (-AST_LC_IDENTIFICATION)
+#endif
+#ifndef LC_NAME
+#define LC_NAME (-AST_LC_NAME)
+#endif
+#ifndef LC_TELEPHONE
+#define LC_TELEPHONE (-AST_LC_TELEPHONE)
+#endif
+#ifndef LC_XLITERATE
+#define LC_XLITERATE (-AST_LC_XLITERATE)
+#endif
+#ifndef LC_MEASUREMENT
+#define LC_MEASUREMENT (-AST_LC_MEASUREMENT)
+#endif
+#ifndef LC_PAPER
+#define LC_PAPER (-AST_LC_PAPER)
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#undef strcoll
+#if _std_strcoll
+#define strcoll _ast_info.collate
+#else
+#define strcoll strcmp
+#endif
+
+typedef struct
+{
+
+ char* id;
+
+ struct
+ {
+ uint32_t serial;
+ uint32_t set;
+ } locale;
+
+ long tmp_long;
+ size_t tmp_size;
+ short tmp_short;
+ char tmp_char;
+ wchar_t tmp_wchar;
+
+ int (*collate) __PROTO__((const char*, const char*));
+
+ int tmp_int;
+ __V_* tmp_pointer;
+
+ int mb_cur_max;
+ int (*mb_len) __PROTO__((const char*, size_t));
+ int (*mb_towc) __PROTO__((wchar_t*, const char*, size_t));
+ size_t (*mb_xfrm) __PROTO__((char*, const char*, size_t));
+ int (*mb_width) __PROTO__((wchar_t));
+ int (*mb_conv) __PROTO__((char*, wchar_t));
+
+ uint32_t env_serial;
+
+ char pad[944];
+
+} _Ast_info_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ _Ast_info_t _ast_info;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+/* largefile hackery -- ast uses the large versions by default */
+
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if !defined(ftruncate) && _lib_ftruncate64
+#define ftruncate ftruncate64
+extern __MANGLE__ int ftruncate64 __PROTO__((int, off64_t));
+#endif
+#if !defined(lseek) && _lib_lseek64
+#define lseek lseek64
+extern __MANGLE__ off64_t lseek64 __PROTO__((int, off64_t, int));
+#endif
+#if !defined(truncate) && _lib_truncate64
+#define truncate truncate64
+extern __MANGLE__ int truncate64 __PROTO__((const char*, off64_t));
+#endif
+
+/* direct macro access for bsd crossover */
+
+#if !defined(__cplusplus)
+
+#if !defined(memcpy) && !defined(_lib_memcpy) && defined(_lib_bcopy)
+#define memcpy(t,f,n) (bcopy(f,t,n),(t))
+#endif
+
+#if !defined(memzero) && !defined(_lib_memzero)
+#if defined(_lib_memset) || !defined(_lib_bzero)
+#define memzero(b,n) memset(b,0,n)
+#else
+#define memzero(b,n) (bzero(b,n),(b))
+#endif
+#endif
+
+#endif
+
+#if !defined(remove)
+extern __MANGLE__ int remove __PROTO__((const char*));
+#endif
+
+#if !defined(rename)
+extern __MANGLE__ int rename __PROTO__((const char*, const char*));
+#endif
+
+#if !defined(strchr) && !defined(_lib_strchr) && defined(_lib_index)
+#define strchr(s,c) index(s,c)
+#endif
+
+#if !defined(strrchr) && !defined(_lib_strrchr) && defined(_lib_rindex)
+#define strrchr(s,c) rindex(s,c)
+#endif
+
+/* and now introducing prototypes botched by the standard(s) */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#undef getpgrp
+#define getpgrp() _ast_getpgrp()
+extern __MANGLE__ int _ast_getpgrp __PROTO__((void));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+/*
+ * and finally, standard interfaces hijacked by ast
+ * _ATS_STD_I delays headers that require <ast_map.h>
+ */
+
+#include <ast_map.h>
+
+#undef _AST_STD_I
+
+#if _REGEX_H < 0
+#undef _REGEX_H
+#include <regex.h>
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_stdio.h b/usr/src/lib/libast/amd64/include/ast/ast_stdio.h
new file mode 100644
index 0000000000..8ae1a4061b
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_stdio.h
@@ -0,0 +1,600 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/stdio by iffe version 2007-04-04 : : */
+
+#ifndef _SFSTDIO_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SFSTDIO_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define __FILE_typedef 1
+#define _FILE_DEFINED 1
+#define _FILE_defined 1
+#define _FILEDEFED 1
+
+#ifndef __FILE_TAG
+#define __FILE_TAG _sfio_s
+#endif
+
+#undef FILE
+#undef _FILE
+#undef fpos_t
+#undef fpos64_t
+
+typedef struct _sfio_s _sfio_FILE;
+
+#define FILE _sfio_FILE
+#define _FILE FILE
+
+#if !defined(__FILE) && !__CYGWIN__
+#undef __FILE
+#define __FILE FILE
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define BUFSIZ SF_BUFSIZE
+
+#else
+
+#ifndef BUFSIZ
+#define BUFSIZ 8192
+#endif
+
+#ifndef EOF
+#define EOF (-1)
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+#include <ast_std.h>
+
+#include <sfio_s.h>
+
+#if __cplusplus
+#define _sf_(f) (f)
+#else
+#define _sf_(f) ((struct _sfio_s*)(f))
+#endif
+
+#define _SF_EOF 0000200
+#define _SF_ERROR 0000400
+
+#endif
+
+#ifdef _NO_LARGEFILE64_SOURCE
+#undef _LARGEFILE64_SOURCE
+#endif
+
+#ifdef _LARGEFILE64_SOURCE
+#undef off_t
+#endif
+
+#define fpos_t _ast_fpos_t
+#if _typ_int64_t
+#define fpos64_t _ast_fpos_t
+#endif
+
+typedef struct _ast_fpos_s
+{
+ intmax_t _sf_offset;
+ unsigned char _sf_state[64 - sizeof(intmax_t)];
+} _ast_fpos_t;
+
+#define _base _data
+#define _ptr _next
+#define _IOFBF 0
+#define _IONBF 1
+#define _IOLBF 2
+
+#if defined(__cplusplus) && defined(__THROW) && !defined(_UWIN)
+
+#undef FILE
+#define FILE FILE
+typedef struct _sfio_s FILE;
+
+#undef strerror
+extern __MANGLE__ char* strerror(int) __THROW;
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#endif
+
+#ifndef FILENAME_MAX
+#define FILENAME_MAX 1024
+#endif
+#ifndef FOPEN_MAX
+#define FOPEN_MAX 20
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+
+#define _doprnt _ast_doprnt
+#define _doscan _ast_doscan
+#define asprintf _ast_asprintf
+#define clearerr _ast_clearerr
+#define fclose _ast_fclose
+#define fdopen _ast_fdopen
+#define fflush _ast_fflush
+#define fgetc _ast_fgetc
+#define fgetpos _ast_fgetpos
+#define fgetpos64 _ast_fgetpos64
+#define fgets _ast_fgets
+#define fopen _ast_fopen
+#define fprintf _ast_fprintf
+#define fpurge _ast_fpurge
+#define fputs _ast_fputs
+#define fread _ast_fread
+#define freopen _ast_freopen
+#define fscanf _ast_fscanf
+#define fseek _ast_fseek
+#define fseek64 _ast_fseek64
+#define fseeko _ast_fseeko
+#define fseeko64 _ast_fseeko64
+#define fsetpos _ast_fsetpos
+#define fsetpos64 _ast_fsetpos64
+#define ftell _ast_ftell
+#define ftell64 _ast_ftell64
+#define ftello _ast_ftello
+#define ftello64 _ast_ftello64
+#define fwrite _ast_fwrite
+#define gets _ast_gets
+#define getw _ast_getw
+#define pclose _ast_pclose
+#define popen _ast_popen
+#define printf _ast_printf
+#define puts _ast_puts
+#define putw _ast_putw
+#define rewind _ast_rewind
+#define scanf _ast_scanf
+#define setbuf _ast_setbuf
+#undef setbuffer
+#define setbuffer _ast_setbuffer
+#define setlinebuf _ast_setlinebuf
+#define setvbuf _ast_setvbuf
+#define snprintf _ast_snprintf
+#define sprintf _ast_sprintf
+#define sscanf _ast_sscanf
+#define tmpfile _ast_tmpfile
+#define ungetc _ast_ungetc
+#define vasprintf _ast_vasprintf
+#define vfprintf _ast_vfprintf
+#define vfscanf _ast_vfscanf
+#define vprintf _ast_vprintf
+#define vscanf _ast_vscanf
+#define vsnprintf _ast_vsnprintf
+#define vsprintf _ast_vsprintf
+#define vsscanf _ast_vsscanf
+#define fcloseall _ast_fcloseall
+#define fmemopen _ast_fmemopen
+#define __getdelim _ast___getdelim
+#define getdelim _ast_getdelim
+#define getline _ast_getline
+#define clearerr_unlocked _ast_clearerr_unlocked
+#define feof_unlocked _ast_feof_unlocked
+#define ferror_unlocked _ast_ferror_unlocked
+#define fflush_unlocked _ast_fflush_unlocked
+#define fgetc_unlocked _ast_fgetc_unlocked
+#define fgets_unlocked _ast_fgets_unlocked
+#define fileno_unlocked _ast_fileno_unlocked
+#define fputc_unlocked _ast_fputc_unlocked
+#define fputs_unlocked _ast_fputs_unlocked
+#define fread_unlocked _ast_fread_unlocked
+#define fwrite_unlocked _ast_fwrite_unlocked
+#define getc_unlocked _ast_getc_unlocked
+#define getchar_unlocked _ast_getchar_unlocked
+#define putc_unlocked _ast_putc_unlocked
+#define putchar_unlocked _ast_putchar_unlocked
+
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef P_tmpdir
+#define P_tmpdir "/var/tmp/" /*NOCATLITERAL*/
+#endif
+#ifndef L_ctermid
+#define L_ctermid 9
+#endif
+#ifndef L_tmpnam
+#define L_tmpnam 25
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#if defined(__cplusplus) && defined(__THROW)
+extern __MANGLE__ char* ctermid(char*) __THROW;
+#else
+extern __MANGLE__ char* ctermid __PROTO__((char*));
+#endif
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+extern __MANGLE__ void perror __PROTO__((const char*));
+#ifndef _AST_STD_H
+#ifndef remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#endif
+#ifndef rename
+extern __MANGLE__ int rename __PROTO__((const char*, const char*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#ifdef _LARGEFILE64_SOURCE
+
+#undef fpos_t
+#undef off_t
+#undef fgetpos
+#undef fsetpos
+#undef fseek
+#undef fseeko
+#undef ftell
+#undef ftello
+
+#define fpos_t fpos64_t
+#if _typ_off64_t
+#define off_t off64_t
+#else
+#define off_t int64_t
+#endif
+
+#define fgetpos fgetpos64
+#define fsetpos fsetpos64
+#define fseek fseek64
+#define fseeko fseeko64
+#define ftell ftell64
+#define ftello ftello64
+
+#endif
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_DLL && _DLL_INDIRECT_DATA
+
+#define stdin ((FILE*)_ast_dll->_ast_stdin)
+#define stdout ((FILE*)_ast_dll->_ast_stdout)
+#define stderr ((FILE*)_ast_dll->_ast_stderr)
+
+#else
+
+#define stdin (&_Sfstdin)
+#define stdout (&_Sfstdout)
+#define stderr (&_Sfstderr)
+
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define feof(f) sfeof(f)
+#define ferror(f) sferror(f)
+#define fileno(f) sffileno(f)
+#define fputc(c,f) sfputc(f,c)
+#define getc(f) sfgetc(f)
+#define getchar() sfgetc(sfstdin)
+#define putc(c,f) sfputc(f,c)
+#define putchar(c) sfputc(sfstdout,c)
+
+#else
+
+#if !_UWIN
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+#endif
+
+extern __MANGLE__ FILE _Sfstdin;
+extern __MANGLE__ FILE _Sfstdout;
+extern __MANGLE__ FILE _Sfstderr;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define feof(f) (_sf_(f)->_flags&_SF_EOF)
+#define ferror(f) (_sf_(f)->_flags&_SF_ERROR)
+#define fileno(f) (_sf_(f)->_file)
+#define fputc(c,f) (_sf_(f)->_next>=_sf_(f)->_endw?_sfflsbuf(_sf_(f),(int)((unsigned char)(c))):(int)(*_sf_(f)->_next++=(unsigned char)(c)))
+#define getc(f) (_sf_(f)->_next>=_sf_(f)->_endr?_sffilbuf(_sf_(f),0):(int)(*_sf_(f)->_next++))
+#define getchar() getc(stdin)
+#define putc(c,f) fputc(c,f)
+#define putchar(c) fputc(c,stdout)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _sffilbuf __PROTO__((FILE*, int));
+extern __MANGLE__ int _sfflsbuf __PROTO__((FILE*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_sys.h b/usr/src/lib/libast/amd64/include/ast/ast_sys.h
new file mode 100644
index 0000000000..b2c4abc96b
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_sys.h
@@ -0,0 +1,172 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/sys by iffe version 2007-04-04 : : */
+
+#ifndef _AST_SYS_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_SYS_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#if __mips == 2 && !defined(_NO_LARGEFILE64_SOURCE)
+#define _NO_LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_NO_LARGEFILE64_SOURCE) && _typ_off64_t && _lib_lseek64 && _lib_stat64
+#if !defined(_LARGEFILE64_SOURCE)
+#define _LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_LARGEFILE_SOURCE)
+#define _LARGEFILE_SOURCE 1
+#endif
+#else
+#undef _LARGEFILE64_SOURCE
+#undef _LARGEFILE_SOURCE
+#undef _typ_off64_t
+#undef _typ_struct_dirent64
+#undef _lib_creat64
+#undef _lib_fstat64
+#undef _lib_fstatvfs64
+#undef _lib_ftruncate64
+#undef _lib_lseek64
+#undef _lib_lstat64
+#undef _lib_mmap64
+#undef _lib_open64
+#undef _lib_readdir64
+#undef _lib_stat64
+#undef _lib_statvfs64
+#undef _lib_truncate64
+#endif
+#if defined(__STDC__) && !defined(__USE_FIXED_PROTOTYPES__)
+#define __USE_FIXED_PROTOTYPES__ 1 /* kick gcc out of the past */
+#endif
+#include <stdlib.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <locale.h>
+#include <sys/localedef.h>
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _typ_dev_t 1 /* dev_t is a type */
+#define _typ_nlink_t 1 /* nlink_t is a type */
+#define _typ_gid_t 1 /* gid_t is a type */
+#define _typ_mode_t 1 /* mode_t is a type */
+#define _typ_uid_t 1 /* uid_t is a type */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _typ_wchar_t 1 /* wchar_t is a type */
+#define _typ_pid_t 1 /* pid_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _typ_wint_t 1 /* wint_t is a type */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _typ_socklen_t 1 /* socklen_t is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_ino_t 1 /* ino_t is a type */
+#define _typ_off_t 1 /* off_t is a type */
+#define _typ_ptrdiff_t 1 /* ptrdiff_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#define _typ_div_t 1 /* div_t is a type */
+#define _typ_ldiv_t 1 /* ldiv_t is a type */
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+extern __MANGLE__ int eaccess __PROTO__((const char*, int));
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+extern __MANGLE__ __V_* pvalloc __PROTO__((size_t));
+extern __MANGLE__ pid_t spawnveg __PROTO__((const char*, char* const[], char* const[], pid_t));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#if !defined(va_start)
+#if defined(__STDARG__)
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_time.h b/usr/src/lib/libast/amd64/include/ast/ast_time.h
new file mode 100644
index 0000000000..9ee992b550
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_time.h
@@ -0,0 +1,104 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/time by iffe version 2007-04-04 : : */
+
+#ifndef _def_time_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_time_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_nanosleep 1 /* nanosleep() in default lib(s) */
+#define _lib_usleep 1 /* usleep() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#include <sys/time.h>
+
+#include <sys/times.h>
+
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC CLK_TCK
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_tty.h b/usr/src/lib/libast/amd64/include/ast/ast_tty.h
new file mode 100644
index 0000000000..3de9691447
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_tty.h
@@ -0,0 +1,155 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/tty by iffe version 2007-04-04 : : */
+#ifndef _def_tty_ast
+#define _def_tty_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_termios 1 /* #include <termios.h> ok */
+#define _hdr_termio 1 /* #include <termio.h> ok */
+#define _hdr_sgtty 1 /* #include <sgtty.h> ok */
+#define _sys_termios 1 /* #include <sys/termios.h> ok */
+#define _sys_termio 1 /* #include <sys/termio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _lib_tcgetattr 1 /* tcgetattr() in default lib(s) */
+#define _lib_tcgetpgrp 1 /* tcgetpgrp() in default lib(s) */
+#define _mac__POSIX_VDISABLE 1 /* _POSIX_VDISABLE is a macro */
+
+#ifdef _hdr_termios
+# if _mac__POSIX_VDISABLE
+# undef _POSIX_VDISABLE
+# endif
+# include <termios.h>
+#else
+# if defined(_sys_termios) && defined(_lib_tcgetattr)
+# include <sys/termios.h>
+# define _hdr_termios 1
+# else
+# undef _sys_termios
+# endif /* _sys_termios */
+#endif /* _hdr_termios */
+
+#ifdef _hdr_termios
+# undef _hdr_sgtty
+# undef tcgetattr
+# undef tcsetattr
+# undef tcgetpgrp
+# undef tcsetpgrp
+# undef cfgetospeed
+# ifndef TCSANOW
+# define TCSANOW TCSETS
+# define TCSADRAIN TCSETSW
+# define TCSAFLUSH TCSETSF
+# endif /* TCSANOW */
+ /* The following corrects bugs in some implementations */
+# if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
+# define TCSAFLUSH TCSADFLUSH
+# endif /* TCSADFLUSH */
+# ifndef _lib_tcgetattr
+# undef tcgetattr
+# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
+# undef tcsetattr
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# undef cfgetospeed
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# endif /* _lib_tcgetattr */
+# undef TIOCGETC
+#else
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfgetispeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfsetispeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# define cfsetospeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# ifdef _hdr_termio
+# include <termio.h>
+# else
+# ifdef _sys_termio
+# include <sys/termio.h>
+# define _hdr_termio 1
+# endif /* _sys_termio */
+# endif /* _hdr_termio */
+# ifdef _hdr_termio
+# define termios termio
+# undef TIOCGETC
+# define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+
+# ifdef _sys_bsdtty
+# include <sys/bsdtty.h>
+# endif /* _sys_bsdtty */
+# else
+# ifdef _hdr_sgtty
+# include <sgtty.h>
+# ifndef LPENDIN
+# ifdef _sys_nttyio
+# include <sys/nttyio.h>
+# endif /* _sys_nttyio */
+# endif /* LPENDIN */
+# define termios sgttyb
+# ifdef TIOCSETN
+# undef TCSETAW
+# endif /* TIOCSETN */
+# ifdef TIOCGETP
+# define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# else
+# define tcgetattr(fd,tty) gtty(fd, tty)
+# define tcsetattr(fd,action,tty) stty(fd, tty)
+# endif /* TIOCGETP */
+# else
+# ifdef _sys_ttyio
+# include <sys/ttyio.h>
+# endif
+# endif /* _hdr_sgtty */
+# endif /* hdr_termio */
+
+# ifndef TCSANOW
+# ifdef TCSETAW
+# define TCSANOW TCSETA
+# define TCSAFLUSH TCSETAF
+# else
+# ifdef TIOCSETN
+# define TCSANOW TIOCSETN
+# define TCSADRAIN TIOCSETN
+# define TCSAFLUSH TIOCSETP
+# endif /* TIOCSETN */
+# endif /* TCSETAW */
+# endif /* TCSANOW */
+#endif /* _hdr_termios */
+
+/* set ECHOCTL if driver can echo control charaters as ^c */
+#ifdef LCTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LCTLECH
+# endif /* !ECHOCTL */
+#endif /* LCTLECH */
+#ifdef LNEW_CTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LNEW_CTLECH
+# endif /* !ECHOCTL */
+#endif /* LNEW_CTLECH */
+#ifdef LNEW_PENDIN
+# ifndef PENDIN
+# define PENDIN LNEW_PENDIN
+# endif /* !PENDIN */
+#endif /* LNEW_PENDIN */
+
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_types.h b/usr/src/lib/libast/amd64/include/ast/ast_types.h
new file mode 100644
index 0000000000..6449f59df8
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_types.h
@@ -0,0 +1,26 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_types_ast
+#define _def_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_version.h b/usr/src/lib/libast/amd64/include/ast/ast_version.h
new file mode 100644
index 0000000000..0e586f9555
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_version.h
@@ -0,0 +1,10 @@
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+#define _AST_VERSION 20061111L
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_vfork.h b/usr/src/lib/libast/amd64/include/ast/ast_vfork.h
new file mode 100644
index 0000000000..fbc689d24c
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_vfork.h
@@ -0,0 +1,88 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/vfork by iffe version 2007-04-04 : : */
+
+#ifndef _def_vfork_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_vfork_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+extern __MANGLE__ pid_t vfork __PROTO__((void));
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_wait.h b/usr/src/lib/libast/amd64/include/ast/ast_wait.h
new file mode 100644
index 0000000000..41bf68a551
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_wait.h
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/wait by iffe version 2007-04-04 : : */
+#ifndef _def_wait_ast
+#define _def_wait_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_wait 1 /* wait() in default lib(s) */
+#define _lib_wait3 1 /* wait3() in default lib(s) */
+#define _lib_wait4 1 /* wait4() in default lib(s) */
+#define _lib_waitpid 1 /* waitpid() in default lib(s) */
+#define _sys_wait 1 /* #include <sys/wait.h> ok */
+#define _ok_wif 1 /* posix wait macros ok */
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_wchar.h b/usr/src/lib/libast/amd64/include/ast/ast_wchar.h
new file mode 100644
index 0000000000..c883c78ad1
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_wchar.h
@@ -0,0 +1,208 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/wchar by iffe version 2007-04-04 : : */
+
+#ifndef _def_wchar_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_wchar_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _lib_mbstowcs 1 /* mbstowcs() in default lib(s) */
+#define _lib_wctomb 1 /* wctomb() in default lib(s) */
+#define _lib_wcrtomb 1 /* wcrtomb() in default lib(s) */
+#define _lib_wcslen 1 /* wcslen() in default lib(s) */
+#define _lib_wcstombs 1 /* wcstombs() in default lib(s) */
+#define _lib_wcwidth 1 /* wcwidth() in default lib(s) */
+#define _lib_towlower 1 /* towlower() in default lib(s) */
+#define _lib_towupper 1 /* towupper() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_mbstate_t 1 /* mbstate_t is a type */
+#define _nxt_wchar <../include/wchar.h> /* include path for the native <wchar.h> */
+#define _nxt_wchar_str "../include/wchar.h" /* include string for the native <wchar.h> */
+#ifndef _SFSTDIO_H
+#include <ast_common.h>
+#include <stdio.h>
+#endif
+#if _hdr_wchar && defined(_nxt_wchar)
+#include <../include/wchar.h> /* the native wchar.h */
+#endif
+#if _hdr_wctype
+#include <wctype.h>
+#endif
+
+#ifndef WEOF
+#define WEOF (-1)
+#endif
+
+#undef fgetwc
+#undef fgetws
+#undef fputwc
+#undef fputws
+#undef getwc
+#undef getwchar
+#undef getws
+#undef putwc
+#undef putwchar
+#undef ungetwc
+
+#define fgetwc _ast_fgetwc
+#define fgetws _ast_fgetws
+#define fputwc _ast_fputwc
+#define fputws _ast_fputws
+#define fwide _ast_fwide
+#define fwprintf _ast_fwprintf
+#define fwscanf _ast_fwscanf
+#define getwc _ast_getwc
+#define getwchar _ast_getwchar
+#define getws _ast_getws
+#define putwc _ast_putwc
+#define putwchar _ast_putwchar
+#define swprintf _ast_swprintf
+#define swscanf _ast_swscanf
+#define ungetwc _ast_ungetwc
+#define vfwprintf _ast_vfwprintf
+#define vfwscanf _ast_vfwscanf
+#define vswprintf _ast_vswprintf
+#define vswscanf _ast_vswscanf
+#define vwprintf _ast_vwprintf
+#define vwscanf _ast_vwscanf
+#define wprintf _ast_wprintf
+#define wscanf _ast_wscanf
+
+#if !_typ_mbstate_t
+#undef _typ_mbstate_t
+#define _typ_mbstate_t 1
+typedef char mbstate_t;
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#if !_lib_mbstowcs
+extern __MANGLE__ size_t mbstowcs __PROTO__((wchar_t*, const char*, size_t));
+#endif
+#if !_lib_wctomb
+extern __MANGLE__ int wctomb __PROTO__((char*, wchar_t));
+#endif
+#if !_lib_wcrtomb
+extern __MANGLE__ size_t wcrtomb __PROTO__((char*, wchar_t, mbstate_t*));
+#endif
+#if !_lib_wcslen
+extern __MANGLE__ size_t wcslen __PROTO__((const wchar_t*));
+#endif
+#if !_lib_wcstombs
+extern __MANGLE__ size_t wcstombs __PROTO__((char*, const wchar_t*, size_t));
+#endif
+
+extern __MANGLE__ int fwprintf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ int fwscanf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ wint_t fgetwc __PROTO__((FILE*));
+extern __MANGLE__ wchar_t* fgetws __PROTO__((wchar_t*, int, FILE*));
+extern __MANGLE__ wint_t fputwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ int fputws __PROTO__((const wchar_t*, FILE*));
+extern __MANGLE__ int fwide __PROTO__((FILE*, int));
+extern __MANGLE__ wint_t getwc __PROTO__((FILE*));
+extern __MANGLE__ wint_t getwchar __PROTO__((void));
+extern __MANGLE__ wchar_t* getws __PROTO__((wchar_t*));
+extern __MANGLE__ wint_t putwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ wint_t putwchar __PROTO__((wchar_t));
+extern __MANGLE__ int swprintf __PROTO__((wchar_t*, size_t, const wchar_t*, ...));
+extern __MANGLE__ int swscanf __PROTO__((const wchar_t*, const wchar_t*, ...));
+extern __MANGLE__ wint_t ungetwc __PROTO__((wint_t, FILE*));
+extern __MANGLE__ int vfwprintf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vfwscanf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vwprintf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vwscanf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vswprintf __PROTO__((wchar_t*, size_t, const wchar_t*, va_list));
+extern __MANGLE__ int vswscanf __PROTO__((const wchar_t*, const wchar_t*, va_list));
+extern __MANGLE__ int wprintf __PROTO__((const wchar_t*, ...));
+extern __MANGLE__ int wscanf __PROTO__((const wchar_t*, ...));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ast_windows.h b/usr/src/lib/libast/amd64/include/ast/ast_windows.h
new file mode 100644
index 0000000000..90e0260f59
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ast_windows.h
@@ -0,0 +1,48 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * AT&T Research
+ *
+ * ast <windows.h> wrapper
+ * for libast only
+ * include after ast headers
+ */
+
+#ifndef _AST_WINDOWS_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_WINDOWS_H 1
+
+#undef SF_ERROR /* clash in <oaidl.h> */
+
+#include <windows.h>
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/bytesex.h b/usr/src/lib/libast/amd64/include/ast/bytesex.h
new file mode 100644
index 0000000000..2bf2022afb
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/bytesex.h
@@ -0,0 +1,43 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * linux/gnu compatibility
+ */
+
+#ifndef _BYTESEX_H
+#define _BYTESEX_H
+
+#include <ast_common.h>
+
+#undef __BYTE_ORDER
+
+#if ( _ast_intswap & 3 ) == 3
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#else
+#if ( _ast_intswap & 3 ) == 1
+#define __BYTE_ORDER __PDP_ENDIAN
+#else
+#define __BYTE_ORDER __BIG_ENDIAN
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ccode.h b/usr/src/lib/libast/amd64/include/ast/ccode.h
new file mode 100644
index 0000000000..d26926ebc4
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ccode.h
@@ -0,0 +1,101 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * character code map interface
+ *
+ * NOTE: used for mapping between 8-bit character encodings
+ * ISO character sets are handled by sfio
+ */
+
+#ifndef _CHARCODE_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _CHARCODE_H 1
+
+#include <ast.h>
+#include <ast_ccode.h>
+
+typedef struct Ccmap_s
+{
+ const char* name; /* code set name */
+ const char* match; /* strmatch() pattern */
+ const char* desc; /* code set description */
+ const char* canon; /* canonical name format */
+ const char* index; /* default index */
+ int ccode; /* <ccode.h> code index */
+ __V_* data; /* map specific data */
+} Ccmap_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ unsigned char* _ccmap __PROTO__((int, int));
+extern __MANGLE__ __V_* _ccmapcpy __PROTO__((unsigned char*, __V_*, const __V_*, size_t));
+extern __MANGLE__ __V_* _ccmapstr __PROTO__((unsigned char*, __V_*, size_t));
+
+extern __MANGLE__ int ccmapid __PROTO__((const char*));
+extern __MANGLE__ char* ccmapname __PROTO__((int));
+extern __MANGLE__ __V_* ccnative __PROTO__((__V_*, const __V_*, size_t));
+extern __MANGLE__ Ccmap_t* ccmaplist __PROTO__((Ccmap_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define CCOP(i,o) ((i)==(o)?0:(((o)<<8)|(i)))
+#define CCIN(x) ((x)&0xFF)
+#define CCOUT(x) (((x)>>8)&0xFF)
+#define CCCONVERT(x) ((x)&0xFF00)
+
+#define CCCVT(x) CCMAP(x,0)
+#define CCMAP(i,o) ((i)==(o)?(unsigned char*)0:_ccmap(i,o))
+#define CCMAPCHR(m,c) ((m)?(m)[c]:(c))
+#define CCMAPCPY(m,t,f,n) ((m)?_ccmapcpy(m,t,f,n):memcpy(t,f,n))
+#define CCMAPSTR(m,s,n) ((m)?_ccmapstr(m,s,n):(__V_*)(s))
+
+#define ccmap(i,o) CCMAP(i,o)
+#define ccmapchr(m,c) CCMAPCHR(m,c)
+#define ccmapcpy(m,t,f,n) CCMAPCPY(m,t,f,n)
+#define ccmapstr(m,s,n) CCMAPSTR(m,s,n)
+
+#define CCMAPC(c,i,o) ((i)==(o)?(c):CCMAP(i,o)[c])
+#define CCMAPM(t,f,n,i,o) ((i)==(o)?memcpy(t,f,n):_ccmapcpy(CCMAP(i,o),t,f,n))
+#define CCMAPS(s,n,i,o) ((i)==(o)?(__V_*)(s):_ccmapstr(CCMAP(i,o),s,n))
+
+#define ccmapc(c,i,o) CCMAPC(c,i,o)
+#define ccmapm(t,f,n,i,o) CCMAPM(t,f,n,i,o)
+#define ccmaps(s,n,i,o) CCMAPS(s,n,i,o)
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/cdt.h b/usr/src/lib/libast/amd64/include/ast/cdt.h
new file mode 100644
index 0000000000..f6274cef92
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/cdt.h
@@ -0,0 +1,311 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _CDT_H
+#define _CDT_H 1
+
+/* Public interface for the dictionary library
+**
+** Written by Kiem-Phong Vo
+*/
+
+#define CDT_VERSION 20050420L
+
+#if _PACKAGE_ast
+#include <ast_std.h>
+#else
+#include <ast_common.h>
+#endif
+
+typedef struct _dtlink_s Dtlink_t;
+typedef struct _dthold_s Dthold_t;
+typedef struct _dtdisc_s Dtdisc_t;
+typedef struct _dtmethod_s Dtmethod_t;
+typedef struct _dtdata_s Dtdata_t;
+typedef struct _dt_s Dt_t;
+typedef struct _dt_s Dict_t; /* for libdict compatibility */
+typedef struct _dtstat_s Dtstat_t;
+typedef Void_t* (*Dtsearch_f)_ARG_((Dt_t*,Void_t*,int));
+typedef Void_t* (*Dtmake_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*));
+typedef void (*Dtfree_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*));
+typedef int (*Dtcompar_f)_ARG_((Dt_t*,Void_t*,Void_t*,Dtdisc_t*));
+typedef unsigned int (*Dthash_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*));
+typedef Void_t* (*Dtmemory_f)_ARG_((Dt_t*,Void_t*,size_t,Dtdisc_t*));
+typedef int (*Dtevent_f)_ARG_((Dt_t*,int,Void_t*,Dtdisc_t*));
+
+struct _dtlink_s
+{ Dtlink_t* right; /* right child */
+ union
+ { unsigned int _hash; /* hash value */
+ Dtlink_t* _left; /* left child */
+ } hl;
+};
+
+/* private structure to hold an object */
+struct _dthold_s
+{ Dtlink_t hdr; /* header */
+ Void_t* obj; /* user object */
+};
+
+/* method to manipulate dictionary structure */
+struct _dtmethod_s
+{ Dtsearch_f searchf; /* search function */
+ int type; /* type of operation */
+};
+
+/* stuff that may be in shared memory */
+struct _dtdata_s
+{ int type; /* type of dictionary */
+ Dtlink_t* here; /* finger to last search element */
+ union
+ { Dtlink_t** _htab; /* hash table */
+ Dtlink_t* _head; /* linked list */
+ } hh;
+ int ntab; /* number of hash slots */
+ int size; /* number of objects */
+ int loop; /* number of nested loops */
+ int minp; /* min path before splay, always even */
+ /* for hash dt, > 0: fixed table size */
+};
+
+/* structure to hold methods that manipulate an object */
+struct _dtdisc_s
+{ int key; /* where the key begins in an object */
+ int size; /* key size and type */
+ int link; /* offset to Dtlink_t field */
+ Dtmake_f makef; /* object constructor */
+ Dtfree_f freef; /* object destructor */
+ Dtcompar_f comparf;/* to compare two objects */
+ Dthash_f hashf; /* to compute hash value of an object */
+ Dtmemory_f memoryf;/* to allocate/free memory */
+ Dtevent_f eventf; /* to process events */
+};
+
+#define DTDISC(dc,ky,sz,lk,mkf,frf,cmpf,hshf,memf,evf) \
+ ( (dc)->key = (ky), (dc)->size = (sz), (dc)->link = (lk), \
+ (dc)->makef = (mkf), (dc)->freef = (frf), \
+ (dc)->comparf = (cmpf), (dc)->hashf = (hshf), \
+ (dc)->memoryf = (memf), (dc)->eventf = (evf) )
+
+#ifdef offsetof
+#define DTOFFSET(struct_s, member) offsetof(struct_s, member)
+#else
+#define DTOFFSET(struct_s, member) ((int)(&((struct_s*)0)->member))
+#endif
+
+/* the dictionary structure itself */
+struct _dt_s
+{ Dtsearch_f searchf;/* search function */
+ Dtdisc_t* disc; /* method to manipulate objs */
+ Dtdata_t* data; /* sharable data */
+ Dtmemory_f memoryf;/* function to alloc/free memory */
+ Dtmethod_t* meth; /* dictionary method */
+ int type; /* type information */
+ int nview; /* number of parent view dictionaries */
+ Dt_t* view; /* next on viewpath */
+ Dt_t* walk; /* dictionary being walked */
+ Void_t* user; /* for user's usage */
+};
+
+/* structure to get status of a dictionary */
+struct _dtstat_s
+{ int dt_meth; /* method type */
+ int dt_size; /* number of elements */
+ int dt_n; /* number of chains or levels */
+ int dt_max; /* max size of a chain or a level */
+ int* dt_count; /* counts of chains or levels by size */
+};
+
+/* flag set if the last search operation actually found the object */
+#define DT_FOUND 0100000
+
+/* supported storage methods */
+#define DT_SET 0000001 /* set with unique elements */
+#define DT_BAG 0000002 /* multiset */
+#define DT_OSET 0000004 /* ordered set (self-adjusting tree) */
+#define DT_OBAG 0000010 /* ordered multiset */
+#define DT_LIST 0000020 /* linked list */
+#define DT_STACK 0000040 /* stack */
+#define DT_QUEUE 0000100 /* queue */
+#define DT_METHODS 0000177 /* all currently supported methods */
+
+/* asserts to dtdisc() */
+#define DT_SAMECMP 0000001 /* compare methods equivalent */
+#define DT_SAMEHASH 0000002 /* hash methods equivalent */
+
+/* types of search */
+#define DT_INSERT 0000001 /* insert object if not found */
+#define DT_DELETE 0000002 /* delete object if found */
+#define DT_SEARCH 0000004 /* look for an object */
+#define DT_NEXT 0000010 /* look for next element */
+#define DT_PREV 0000020 /* find previous element */
+#define DT_RENEW 0000040 /* renewing an object */
+#define DT_CLEAR 0000100 /* clearing all objects */
+#define DT_FIRST 0000200 /* get first object */
+#define DT_LAST 0000400 /* get last object */
+#define DT_MATCH 0001000 /* find object matching key */
+#define DT_VSEARCH 0002000 /* search using internal representation */
+#define DT_ATTACH 0004000 /* attach an object to the dictionary */
+#define DT_DETACH 0010000 /* detach an object from the dictionary */
+
+/* events */
+#define DT_OPEN 1 /* a dictionary is being opened */
+#define DT_CLOSE 2 /* a dictionary is being closed */
+#define DT_DISC 3 /* discipline is about to be changed */
+#define DT_METH 4 /* method is about to be changed */
+#define DT_ENDOPEN 5 /* dtopen() is done */
+#define DT_ENDCLOSE 6 /* dtclose() is done */
+#define DT_HASHSIZE 7 /* setting hash table size */
+
+_BEGIN_EXTERNS_ /* public data */
+#if _BLD_cdt && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+#if !_BLD_cdt && defined(__IMPORT__)
+#define extern __IMPORT__
+#endif
+
+extern Dtmethod_t* Dtset;
+extern Dtmethod_t* Dtbag;
+extern Dtmethod_t* Dtoset;
+extern Dtmethod_t* Dtobag;
+extern Dtmethod_t* Dtlist;
+extern Dtmethod_t* Dtstack;
+extern Dtmethod_t* Dtqueue;
+
+/* compatibility stuff; will go away */
+#ifndef KPVDEL
+extern Dtmethod_t* Dtorder;
+extern Dtmethod_t* Dttree;
+extern Dtmethod_t* Dthash;
+extern Dtmethod_t _Dttree;
+extern Dtmethod_t _Dthash;
+extern Dtmethod_t _Dtlist;
+extern Dtmethod_t _Dtqueue;
+extern Dtmethod_t _Dtstack;
+#endif
+
+#undef extern
+_END_EXTERNS_
+
+_BEGIN_EXTERNS_ /* public functions */
+#if _BLD_cdt && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Dt_t* dtopen _ARG_((Dtdisc_t*, Dtmethod_t*));
+extern int dtclose _ARG_((Dt_t*));
+extern Dt_t* dtview _ARG_((Dt_t*, Dt_t*));
+extern Dtdisc_t* dtdisc _ARG_((Dt_t* dt, Dtdisc_t*, int));
+extern Dtmethod_t* dtmethod _ARG_((Dt_t*, Dtmethod_t*));
+
+extern Dtlink_t* dtflatten _ARG_((Dt_t*));
+extern Dtlink_t* dtextract _ARG_((Dt_t*));
+extern int dtrestore _ARG_((Dt_t*, Dtlink_t*));
+
+extern int dttreeset _ARG_((Dt_t*, int, int));
+
+extern int dtwalk _ARG_((Dt_t*, int(*)(Dt_t*,Void_t*,Void_t*), Void_t*));
+
+extern Void_t* dtrenew _ARG_((Dt_t*, Void_t*));
+
+extern int dtsize _ARG_((Dt_t*));
+extern int dtstat _ARG_((Dt_t*, Dtstat_t*, int));
+extern unsigned int dtstrhash _ARG_((unsigned int, Void_t*, int));
+
+#if !_PACKAGE_ast
+extern int memcmp _ARG_((const Void_t*, const Void_t*, size_t));
+extern int strcmp _ARG_((const char*, const char*));
+#endif
+
+#undef extern
+_END_EXTERNS_
+
+/* internal functions for translating among holder, object and key */
+#define _DT(dt) ((Dt_t*)(dt))
+#define _DTDSC(dc,ky,sz,lk,cmpf) \
+ (ky = (dc)->key, sz = (dc)->size, lk = (dc)->link, cmpf = (dc)->comparf)
+#define _DTLNK(o,lk) ((Dtlink_t*)((char*)(o) + lk) )
+#define _DTOBJ(e,lk) ((lk) < 0 ? ((Dthold_t*)(e))->obj : (Void_t*)((char*)(e) - (lk)) )
+#define _DTKEY(o,ky,sz) (Void_t*)((sz) < 0 ? *((char**)((char*)(o)+(ky))) : ((char*)(o)+(ky)))
+
+#define _DTCMP(dt,k1,k2,dc,cmpf,sz) \
+ ((cmpf) ? (*cmpf)(dt,k1,k2,dc) : \
+ ((sz) <= 0 ? strcmp(k1,k2) : memcmp(k1,k2,sz)) )
+#define _DTHSH(dt,ky,dc,sz) ((dc)->hashf ? (*(dc)->hashf)(dt,ky,dc) : dtstrhash(0,ky,sz) )
+
+/* special search function for tree structure only */
+#define _DTMTCH(dt,key,action) \
+ do { Dtlink_t* _e; Void_t *_o, *_k, *_key; Dtdisc_t* _dc; \
+ int _ky, _sz, _lk, _cmp; Dtcompar_f _cmpf; \
+ _dc = (dt)->disc; _DTDSC(_dc, _ky, _sz, _lk, _cmpf); \
+ _key = (key); \
+ for(_e = (dt)->data->here; _e; _e = _cmp < 0 ? _e->hl._left : _e->right) \
+ { _o = _DTOBJ(_e, _lk); _k = _DTKEY(_o, _ky, _sz); \
+ if((_cmp = _DTCMP((dt), _key, _k, _dc, _cmpf, _sz)) == 0) \
+ break; \
+ } \
+ action (_e ? _o : (Void_t*)0); \
+ } while(0)
+
+#define _DTSRCH(dt,obj,action) \
+ do { Dtlink_t* _e; Void_t *_o, *_k, *_key; Dtdisc_t* _dc; \
+ int _ky, _sz, _lk, _cmp; Dtcompar_f _cmpf; \
+ _dc = (dt)->disc; _DTDSC(_dc, _ky, _sz, _lk, _cmpf); \
+ _key = _DTKEY(obj, _ky, _sz); \
+ for(_e = (dt)->data->here; _e; _e = _cmp < 0 ? _e->hl._left : _e->right) \
+ { _o = _DTOBJ(_e, _lk); _k = _DTKEY(_o, _ky, _sz); \
+ if((_cmp = _DTCMP((dt), _key, _k, _dc, _cmpf, _sz)) == 0) \
+ break; \
+ } \
+ action (_e ? _o : (Void_t*)0); \
+ } while(0)
+
+#define DTTREEMATCH(dt,key,action) _DTMTCH(_DT(dt),(Void_t*)(key),action)
+#define DTTREESEARCH(dt,obj,action) _DTSRCH(_DT(dt),(Void_t*)(obj),action)
+
+#define dtvnext(d) (_DT(d)->view)
+#define dtvcount(d) (_DT(d)->nview)
+#define dtvhere(d) (_DT(d)->walk)
+
+#define dtlink(d,e) (((Dtlink_t*)(e))->right)
+#define dtobj(d,e) _DTOBJ((e), _DT(d)->disc->link)
+#define dtfinger(d) (_DT(d)->data->here ? dtobj((d),_DT(d)->data->here):(Void_t*)(0))
+
+#define dtfirst(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_FIRST)
+#define dtnext(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_NEXT)
+#define dtleast(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH|DT_NEXT)
+#define dtlast(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_LAST)
+#define dtprev(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_PREV)
+#define dtmost(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH|DT_PREV)
+#define dtsearch(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH)
+#define dtmatch(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_MATCH)
+#define dtinsert(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_INSERT)
+#define dtdelete(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_DELETE)
+#define dtattach(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_ATTACH)
+#define dtdetach(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_DETACH)
+#define dtclear(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_CLEAR)
+#define dtfound(d) (_DT(d)->type & DT_FOUND)
+
+#define DT_PRIME 17109811 /* 2#00000001 00000101 00010011 00110011 */
+#define dtcharhash(h,c) (((unsigned int)(h) + (unsigned int)(c)) * DT_PRIME )
+
+#endif /* _CDT_H */
diff --git a/usr/src/lib/libast/amd64/include/ast/debug.h b/usr/src/lib/libast/amd64/include/ast/debug.h
new file mode 100644
index 0000000000..ad7ecb7a54
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/debug.h
@@ -0,0 +1,63 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * common ast debug definitions
+ * include after the ast headers
+ */
+
+#ifndef _DEBUG_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _DEBUG_H
+
+#include <ast.h>
+#include <error.h>
+
+#if DEBUG || _BLD_DEBUG
+#define debug(x) x
+#define message(x) do if (error_info.trace < 0) { error x; } while (0)
+#define messagef(x) do if (error_info.trace < 0) { errorf x; } while (0)
+#else
+#define debug(x)
+#define message(x)
+#define messagef(x)
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ void systrace __PROTO__((const char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/dirent.h b/usr/src/lib/libast/amd64/include/ast/dirent.h
new file mode 100644
index 0000000000..32f33800b5
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/dirent.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_dirent.h>
diff --git a/usr/src/lib/libast/amd64/include/ast/dt.h b/usr/src/lib/libast/amd64/include/ast/dt.h
new file mode 100644
index 0000000000..0b7c331577
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/dt.h
@@ -0,0 +1,49 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+#ifndef _DT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _DT_H 1
+
+#include <cdt.h>
+#include <vmalloc.h>
+
+#if _BLD_cdt && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Dt_t* dtnew __PROTO__((Vmalloc_t*, Dtdisc_t*, Dtmethod_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/endian.h b/usr/src/lib/libast/amd64/include/ast/endian.h
new file mode 100644
index 0000000000..2299b5a3bc
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/endian.h
@@ -0,0 +1,54 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * linux/gnu compatibility
+ */
+
+#ifndef _ENDIAN_H
+#define _ENDIAN_H
+
+#include <bytesex.h>
+
+#define __LITTLE_ENDIAN 1234
+#define __BIG_ENDIAN 4321
+#define __PDP_ENDIAN 3412
+
+#if defined (__USE_BSD) && !defined(__STRICT_ANSI__)
+
+#ifndef LITTLE_ENDIAN
+#define LITTLE_ENDIAN __LITTLE_ENDIAN
+#endif
+
+#ifndef BIG_ENDIAN
+#define BIG_ENDIAN __BIG_ENDIAN
+#endif
+
+#ifndef PDP_ENDIAN
+#define PDP_ENDIAN __PDP_ENDIAN
+#endif
+
+#undef BYTE_ORDER
+#define BYTE_ORDER __BYTE_ORDER
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/error.h b/usr/src/lib/libast/amd64/include/ast/error.h
new file mode 100644
index 0000000000..d6d171a15e
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/error.h
@@ -0,0 +1,196 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * option, error and message formatter external definitions
+ */
+
+#ifndef _ERROR_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _ERROR_H
+
+#include <ast.h>
+#include <option.h>
+#include <errno.h>
+
+#define ERROR_VERSION 20070319L
+
+#if !defined(errno) && defined(__DYNAMIC__)
+#define errno __DYNAMIC__(errno)
+#endif
+
+#define ERROR_debug(n) (-(n))
+#define ERROR_exit(n) ((n)+ERROR_ERROR)
+#define ERROR_system(n) (((n)+ERROR_ERROR)|ERROR_SYSTEM)
+#define ERROR_usage(n) ((((n)?2:0)+ERROR_ERROR)|ERROR_USAGE)
+#define ERROR_warn(n) (ERROR_WARNING)
+
+#ifndef ERROR_catalog
+#define ERROR_catalog(t) t
+#endif
+#ifndef ERROR_dictionary
+#define ERROR_dictionary(t) t
+#endif
+
+#ifndef ERROR_translate
+#define ERROR_translating() (error_info.translate&&(ast.locale.set&(1<<AST_LC_MESSAGES)))
+#define ERROR_translate(l,i,d,m) (ERROR_translating()?errorx((const char*)l,(const char*)i,(const char*)d,(const char*)m):(m))
+#endif
+
+#define ERROR_INFO 0 /* info message -- no err_id */
+#define ERROR_WARNING 1 /* warning message */
+#define ERROR_ERROR 2 /* error message -- no err_exit */
+#define ERROR_FATAL 3 /* error message with err_exit */
+#define ERROR_NOEXEC EXIT_NOEXEC /* shell convention */
+#define ERROR_NOENT EXIT_NOTFOUND /* shell convention */
+#define ERROR_PANIC ERROR_LEVEL /* panic message with err_exit */
+
+#define ERROR_LEVEL 0x00ff /* level portion of status */
+#define ERROR_SYSTEM 0x0100 /* report system errno message */
+#define ERROR_OUTPUT 0x0200 /* next arg is error fd */
+#define ERROR_SOURCE 0x0400 /* next 2 args are FILE,LINE */
+#define ERROR_USAGE 0x0800 /* usage message */
+#define ERROR_PROMPT 0x1000 /* omit trailing newline */
+#define ERROR_NOID 0x2000 /* omit err_id */
+#define ERROR_LIBRARY 0x4000 /* library routine error */
+
+#define ERROR_INTERACTIVE 0x0001 /* context is interactive */
+#define ERROR_SILENT 0x0002 /* context is silent */
+#define ERROR_NOTIFY 0x0004 /* main(-sig,0,ctx) on signal */
+
+#define ERROR_FREE 0x0010 /* free context on pop */
+#define ERROR_POP 0x0020 /* pop context */
+#define ERROR_PUSH 0x0040 /* push context */
+#define ERROR_SET 0x0080 /* set context */
+
+/*
+ * errorpush()/errorpop() are obsolete -- use errorctx() instead
+ */
+
+#ifndef ERROR_CONTEXT_T
+#define ERROR_CONTEXT_T Error_info_t
+#endif
+
+#define ERROR_CONTEXT_BASE ((Error_context_t*)&error_info.context)
+
+#define errorpush(p,f) (*(p)= *ERROR_CONTEXT_BASE,*ERROR_CONTEXT_BASE=error_info.empty,error_info.context=(Error_context_t*)(p),error_info.flags=(f))
+#define errorpop(p) (*ERROR_CONTEXT_BASE= *(p))
+
+typedef struct Error_info_s Error_info_t;
+typedef struct Error_context_s Error_context_t;
+
+#define ERROR_CONTEXT \
+ ERROR_CONTEXT_T* context; /* prev context stack element */ \
+ int errors; /* >= ERROR_ERROR count */ \
+ int flags; /* context flags */ \
+ int line; /* input|output line number */ \
+ int warnings; /* ERROR_WARNING count */ \
+ char* file; /* input|output file name */ \
+ char* id; /* command id */
+
+struct Error_context_s /* context stack element */
+{
+ ERROR_CONTEXT
+};
+
+struct Error_info_s /* error state */
+{
+ int fd; /* write(2) fd */
+
+ void (*exit) __PROTO__((int)); /* error exit */
+ ssize_t (*write) __PROTO__((int, const __V_*, size_t)); /* error output */
+
+ /* the rest are implicitly initialized */
+
+ int clear; /* default clear ERROR_* flags */
+ int core; /* level>=core -> core dump */
+ int indent; /* debug trace indent level */
+ int init; /* initialized */
+ int last_errno; /* last reported errno */
+ int mask; /* multi level debug trace mask */
+ int set; /* default set ERROR_* flags */
+ int trace; /* debug trace level */
+
+ char* version; /* ERROR_SOURCE command version */
+
+ int (*auxilliary) __PROTO__((Sfio_t*, int, int)); /* aux info to append */
+
+ ERROR_CONTEXT /* top of context stack */
+
+ Error_context_t empty; /* empty context stack element */
+
+ unsigned long time; /* debug time trace */
+
+ char* (*translate) __PROTO__((const char*, const char*, const char*, const char*)); /* format translator */
+
+ const char* catalog; /* message catalog */
+};
+
+#ifndef errno
+extern __MANGLE__ int errno; /* system call error status */
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Error_info_t* _error_infop_;
+
+#define error_info (*_error_infop_)
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ void error __PROTO__((int, ...));
+extern __MANGLE__ int errormsg __PROTO__((const char*, int, ...));
+extern __MANGLE__ int errorf __PROTO__((__V_*, __V_*, int, ...));
+extern __MANGLE__ void errorv __PROTO__((const char*, int, va_list));
+#ifndef errorx
+extern __MANGLE__ char* errorx __PROTO__((const char*, const char*, const char*, const char*));
+#endif
+extern __MANGLE__ Error_info_t* errorctx __PROTO__((Error_info_t*, int, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/find.h b/usr/src/lib/libast/amd64/include/ast/find.h
new file mode 100644
index 0000000000..0caf2019cf
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/find.h
@@ -0,0 +1,97 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * fast find interface definitions
+ */
+
+#ifndef _FIND_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FIND_H
+
+#define FIND_VERSION 19980301L
+
+#ifndef FIND_CODES
+#define FIND_CODES "lib/find/codes"
+#endif
+
+#define FIND_CODES_ENV "FINDCODES"
+
+#define FIND_GENERATE (1<<0) /* generate new codes */
+#define FIND_ICASE (1<<1) /* ignore case in match */
+#define FIND_GNU (1<<2) /* generate gnu format codes */
+#define FIND_OLD (1<<3) /* generate old format codes */
+#define FIND_TYPE (1<<4) /* generate type with codes */
+#define FIND_VERIFY (1<<5) /* verify the dir hierarchy */
+
+#define FIND_USER (1L<<16) /* first user flag bit */
+
+struct Find_s;
+struct Finddisc_s;
+
+typedef int (*Findverify_f) __PROTO__((struct Find_s*, const char*, size_t, struct Finddisc_s*));
+
+typedef struct Finddisc_s
+{
+ unsigned long version; /* interface version */
+ unsigned long flags; /* FIND_* flags */
+ Error_f errorf; /* error function */
+ Findverify_f verifyf; /* dir verify function */
+ char** dirs; /* dir prefixes to search */
+} Finddisc_t;
+
+typedef struct Find_s
+{
+ const char* id; /* library id string */
+ unsigned long stamp; /* codes time stamp */
+
+#ifdef _FIND_PRIVATE_
+ _FIND_PRIVATE_
+#endif
+
+} Find_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Find_t* findopen __PROTO__((const char*, const char*, const char*, Finddisc_t*));
+extern __MANGLE__ char* findread __PROTO__((Find_t*));
+extern __MANGLE__ int findwrite __PROTO__((Find_t*, const char*, size_t, const char*));
+extern __MANGLE__ int findclose __PROTO__((Find_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/fnmatch.h b/usr/src/lib/libast/amd64/include/ast/fnmatch.h
new file mode 100644
index 0000000000..83e2dd9943
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/fnmatch.h
@@ -0,0 +1,71 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * posix fnmatch interface definitions
+ */
+
+#ifndef _FNMATCH_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FNMATCH_H
+
+#include <ast_common.h>
+
+/* fnmatch flags */
+
+#define FNM_NOESCAPE 0x0001 /* \ is literal */
+#define FNM_PATHNAME 0x0002 /* explicit match for / */
+#define FNM_PERIOD 0x0004 /* explicit match for leading . */
+#define FNM_NOSYS 0x0010 /* not implemented */
+
+/* nonstandard fnmatch() flags */
+
+#define FNM_AUGMENTED 0x0008 /* enable ! & ( | ) */
+#define FNM_ICASE 0x0020 /* ignore case in match */
+#define FNM_LEADING_DIR 0x0040 /* match up to implicit / */
+
+#define FNM_CASEFOLD FNM_ICASE /* gnu compatibility */
+#define FNM_FILE_NAME FNM_PATHNAME /* gnu compatibility */
+
+/* fnmatch error codes -- other non-zero values from <regex.h> */
+
+#define FNM_NOMATCH 1 /* == REG_NOMATCH */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int fnmatch __PROTO__((const char*, const char*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/fnv.h b/usr/src/lib/libast/amd64/include/ast/fnv.h
new file mode 100644
index 0000000000..6af5c1489c
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/fnv.h
@@ -0,0 +1,81 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * Landon Kurt Knoll
+ * Phong Vo
+ *
+ * FNV-1 linear congruent checksum/hash/PRNG
+ * see http://www.isthe.com/chongo/tech/comp/fnv/
+ */
+
+#ifndef _FNV_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FNV_H
+
+#include <ast_common.h>
+
+#define FNV_INIT 0x811c9dc5L
+#define FNV_MULT 0x01000193L
+
+#define FNVINIT(h) (h = FNV_INIT)
+#define FNVPART(h,c) (h = (h) * FNV_MULT ^ (c))
+#define FNVSUM(h,s,n) do { \
+ register size_t _i_ = 0; \
+ while (_i_ < n) \
+ FNVPART(h, ((unsigned char*)s)[_i_++]); \
+ } while (0)
+
+#if _typ_int64_t
+
+#ifdef _ast_LL
+
+#define FNV_INIT64 0xcbf29ce484222325LL
+#define FNV_MULT64 0x00000100000001b3LL
+
+#else
+
+#define FNV_INIT64 ((int64_t)0xcbf29ce484222325)
+#define FNV_MULT64 ((int64_t)0x00000100000001b3)
+
+#endif
+
+#define FNVINIT64(h) (h = FNV_INIT64)
+#define FNVPART64(h,c) (h = (h) * FNV_MULT64 ^ (c))
+#define FNVSUM64(h,s,n) do { \
+ register int _i_ = 0; \
+ while (_i_ < n) \
+ FNVPART64(h, ((unsigned char*)s)[_i_++]); \
+ } while (0)
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/fs3d.h b/usr/src/lib/libast/amd64/include/ast/fs3d.h
new file mode 100644
index 0000000000..a16099d7ae
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/fs3d.h
@@ -0,0 +1,120 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * 3d fs interface definitions
+ */
+
+#ifndef _FS3D_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FS3D_H
+
+#include <ast_fs.h>
+
+#if _int_st_spare1
+#define iview(p) ((p)->st_spare1)
+#define IVIEW(p,v) ((p)->st_spare1=(v))
+#else
+#if _ary_st_spare4
+#define iview(p) ((p)->st_spare4[0])
+#define IVIEW(p,v) ((p)->st_spare4[0]=(v))
+#else
+#if _ary_st_pad4
+#define iview(p) ((p)->st_pad4[0])
+#define IVIEW(p,v) ((p)->st_pad4[0]=(v))
+#else
+#if _mem_st_rdev_stat
+#define iview(p) ((S_ISBLK((p)->st_mode)||S_ISCHR((p)->st_mode))?0:(p)->st_rdev)
+#define IVIEW(p,v) do{if(!S_ISBLK((p)->st_mode)&&!S_ISCHR((p)->st_mode))(p)->st_rdev=(v);}while(0)
+#else
+#define iview(p) 0
+#define IVIEW(p,v)
+#endif
+#endif
+#endif
+#endif
+
+/*
+ * special options
+ */
+
+#define FS3D_init "/#option/init"
+#define FS3D_on "/#option/3d"
+#define FS3D_off "/#option/2d"
+
+/*
+ * fs3d(3) ops
+ */
+
+#define FS3D_OP(o,a) (((a)<<3)|(o))
+
+#define FS3D_INIT FS3D_OP_INIT /* re-initialize tables */
+#define FS3D_OFF FS3D_OP_OFF
+#define FS3D_ON FS3D_OP_ON
+#define FS3D_TEST FS3D_OP_TEST
+#define FS3D_LIMIT(n) FS3D_OP(FS3D_OP_LIMIT,n)
+
+#define FS3D_op(x) ((x)&07)
+#define FS3D_arg(x) (((x)>>3)&07777)
+
+#define FS3D_OP_OFF 0
+#define FS3D_OP_ON 1
+#define FS3D_OP_TEST 2
+#define FS3D_OP_LIMIT 3
+#define FS3D_OP_INIT 7
+
+/*
+ * mount(2) ops
+ */
+
+#define FS3D_ALL (FS3D_VIEW|FS3D_VERSION)
+#define FS3D_VIEW 002
+#define FS3D_VERSION 004
+#define FS3D_GET 010
+#define FS3D_SIZE(n) ((n)<<4)
+#define FS3D_SIZEOF(n) ((n)>>4)
+
+extern __MANGLE__ int mount __PROTO__((const char*, char*, int, __V_*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int fs3d __PROTO__((int));
+extern __MANGLE__ char* pathnext __PROTO__((char*, char*, long*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/fts.h b/usr/src/lib/libast/amd64/include/ast/fts.h
new file mode 100644
index 0000000000..081fe2a712
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/fts.h
@@ -0,0 +1,160 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * David Korn
+ * Phong Vo
+ * AT&T Research
+ *
+ * fts interface definitions
+ */
+
+#ifndef _FTS_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FTS_H
+
+#include <ls.h>
+
+/*
+ * fts_open flags
+ */
+
+#define FTS_LOGICAL 0 /* logical traversal, follow symlinks */
+#define FTS_META (1<<0) /* follow top dir symlinks even if phys */
+#define FTS_NOCHDIR (1<<1) /* don't chdir */
+#define FTS_NOPOSTORDER (1<<2) /* no postorder visits */
+#define FTS_NOPREORDER (1<<3) /* no preorder visits */
+#define FTS_NOSEEDOTDIR (1<<11) /* never retain leading . dir */
+#define FTS_NOSTAT (1<<4) /* don't stat children */
+#define FTS_ONEPATH (1<<5) /* pathnames arg is one const char* */
+#define FTS_PHYSICAL (1<<6) /* physical traversal, don't follow */
+#define FTS_SEEDOT (1<<7) /* return . and .. */
+#define FTS_SEEDOTDIR (1<<10) /* always retain leading . dir */
+#define FTS_TOP (1<<8) /* don't traverse subdirectories */
+#define FTS_XDEV (1<<9) /* don't cross mount points */
+
+#define FTS_USER (1<<12) /* first user flag bit */
+
+#define FTS_COMFOLLOW FTS_META
+
+/*
+ * fts_info flags
+ */
+
+#define FTS_DEFAULT 0 /* ok, someone must have wanted this */
+
+#define FTS_NS (1<<0) /* stat failed */
+#define FTS_F (1<<1) /* file - not directory or symbolic link*/
+#define FTS_SL (1<<2) /* symbolic link */
+#define FTS_D (1<<3) /* directory - pre-order visit */
+
+#define FTS_C (1<<4) /* causes cycle */
+#define FTS_ERR (1<<5) /* some other error */
+#define FTS_DD (1<<6) /* . or .. */
+#define FTS_NR (1<<7) /* cannot read */
+#define FTS_NX (1<<8) /* cannot search */
+#define FTS_OK (1<<9) /* no info but otherwise ok */
+#define FTS_P (1<<10) /* post-order visit */
+
+#define FTS_DC (FTS_D|FTS_C) /* dir - would cause cycle */
+#define FTS_DNR (FTS_D|FTS_NR) /* dir - no read permission */
+#define FTS_DNX (FTS_D|FTS_NX) /* dir - no search permission */
+#define FTS_DOT (FTS_D|FTS_DD) /* . or .. */
+#define FTS_DP (FTS_D|FTS_P) /* dir - post-order visit */
+#define FTS_NSOK (FTS_NS|FTS_OK) /* no stat (because you asked) */
+#define FTS_SLNONE (FTS_SL|FTS_NS) /* symlink - to nowhere */
+
+/*
+ * fts_set flags
+ */
+
+#define FTS_AGAIN FTS_TOP /* process entry again */
+#define FTS_FOLLOW FTS_META /* follow FTS_SL symlink */
+#define FTS_SKIP FTS_NOSTAT /* skip FTS_D directory */
+#define FTS_STAT FTS_PHYSICAL /* stat() done by user */
+
+typedef struct Fts FTS;
+typedef struct Ftsent FTSENT;
+
+struct Ftsent
+{
+ char* fts_accpath; /* path relative to . */
+ char* fts_name; /* file name */
+ char* fts_path; /* path relative to top dir */
+ FTSENT* fts_cycle; /* offender if cycle */
+ FTSENT* fts_link; /* next child */
+ FTSENT* fts_parent; /* parent directory */
+ struct stat* fts_statp; /* stat info */
+#ifdef _FTSENT_LOCAL_PRIVATE_
+ _FTSENT_LOCAL_PRIVATE_
+#else
+ __V_* fts_pointer; /* local pointer value */
+#endif
+ long fts_number; /* local numeric value */
+ int fts_errno; /* errno for this entry */
+ unsigned short fts_info; /* info flags */
+ unsigned short fts_namelen; /* strlen(fts_name) */
+ unsigned short fts_pathlen; /* strlen(fts_path) */
+ short fts_level; /* file tree depth, 0 at top */
+
+#ifdef _FTSENT_PRIVATE_
+ _FTSENT_PRIVATE_
+#endif
+
+};
+
+struct Fts
+{
+ int fts_errno; /* last errno */
+
+#ifdef _FTS_PRIVATE_
+ _FTS_PRIVATE_
+#endif
+
+};
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ FTSENT* fts_children __PROTO__((FTS*, int));
+extern __MANGLE__ int fts_close __PROTO__((FTS*));
+extern __MANGLE__ int fts_flags __PROTO__((void));
+extern __MANGLE__ int fts_notify __PROTO__((int(*)(FTS*, FTSENT*, __V_*), __V_*));
+extern __MANGLE__ FTS* fts_open __PROTO__((char* const*, int, int(*)(FTSENT* const*, FTSENT* const*)));
+extern __MANGLE__ FTSENT* fts_read __PROTO__((FTS*));
+extern __MANGLE__ int fts_set __PROTO__((FTS*, FTSENT*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ftw.h b/usr/src/lib/libast/amd64/include/ast/ftw.h
new file mode 100644
index 0000000000..bd39851cbc
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ftw.h
@@ -0,0 +1,71 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * ftw,nftw over ftwalk
+ */
+
+#ifndef _FTW_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FTW_H
+
+#define FTW FTWALK
+#include <ftwalk.h>
+#undef FTW
+
+#define FTW_SLN (FTW_SL|FTW_NR)
+
+#define FTW_PHYS (FTW_PHYSICAL)
+#define FTW_CHDIR (FTW_DOT)
+#define FTW_DEPTH (FTW_POST)
+#define FTW_OPEN (0)
+
+struct FTW
+{
+ int quit;
+ int base;
+ int level;
+};
+
+#define FTW_SKD FTW_SKIP
+#define FTW_PRUNE FTW_SKIP
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int ftw __PROTO__((const char*, int(*)(const char*, const struct stat*, int), int));
+extern __MANGLE__ int nftw __PROTO__((const char*, int(*)(const char*, const struct stat*, int, struct FTW*), int, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ftwalk.h b/usr/src/lib/libast/amd64/include/ast/ftwalk.h
new file mode 100644
index 0000000000..1ee713a37a
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ftwalk.h
@@ -0,0 +1,137 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Phong Vo
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * ast ftwalk interface definitions
+ * ftwalk was the initial improvement on ftw and nftw
+ * which formed the basis for the POSIX fts proposal
+ *
+ * NOTE: this file is in cahoots with the fts implementation
+ */
+
+#ifndef _FTWALK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FTWALK_H
+
+#define fts_info info
+#define fts_level level
+#define fts_link link
+#define fts_name name
+#define fts_namelen namelen
+#define fts_parent parent
+#define fts_path path
+#define fts_pathlen pathlen
+
+#define FTSENT Ftw_t /* <fts.h> internal */
+#define Ftsent FTW /* <fts.h> internal */
+
+#define _FTSENT_LOCAL_PRIVATE_ /* <fts.h> internal */ \
+ union \
+ { \
+ long number; /* local numeric value */ \
+ __V_* pointer; /* local pointer value */ \
+ } local;
+
+#define _FTSENT_PRIVATE_ /* fts internal */ \
+ short status; /* internal status */ \
+ struct stat statb; /* fts_statp data */
+
+#include <fts.h>
+
+/*
+ * ftwalk() argument flags
+ */
+
+#define FTW_CANON FTS_CANON
+#define FTW_CHILDREN (FTS_USER<<0)
+#define FTW_DELAY FTS_NOSTAT
+#define FTW_DOT FTS_NOCHDIR
+#define FTW_META FTS_META
+#define FTW_MOUNT FTS_XDEV
+#define FTW_MULTIPLE FTS_ONEPATH
+#define FTW_NOSEEDOTDIR FTS_NOSEEDOTDIR
+#define FTW_PHYSICAL FTS_PHYSICAL
+#define FTW_POST (FTS_USER<<1)
+#define FTW_SEEDOTDIR FTS_SEEDOTDIR
+#define FTW_TOP FTS_TOP
+#define FTW_TWICE (FTS_USER<<2)
+#define FTW_USER (FTS_USER<<3)
+
+/*
+ * Ftw_t.info type bits
+ */
+
+#define FTW_C FTS_C
+#define FTW_D FTS_D
+#define FTW_DC FTS_DC
+#define FTW_DNR FTS_DNR
+#define FTW_DNX FTS_DNX
+#define FTW_DP FTS_DP
+#define FTW_F FTS_F
+#define FTW_NR FTS_NR
+#define FTW_NS FTS_NS
+#define FTW_NSOK FTS_NSOK
+#define FTW_NX FTS_NX
+#define FTW_P FTS_P
+#define FTW_SL FTS_SL
+
+/*
+ * Ftw_t.status entry values
+ */
+
+#define FTW_NAME FTS_DOT /* access by Ftw_t.name */
+#define FTW_PATH FTS_NOCHDIR /* access by Ftw_t.path */
+
+/*
+ * Ftw_t.status return values
+ */
+
+#define FTW_AGAIN FTS_AGAIN
+#define FTW_FOLLOW FTS_FOLLOW
+#define FTW_NOPOST FTS_NOPOSTORDER
+#define FTW_SKIP FTS_SKIP
+#define FTW_STAT FTS_STAT
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int ftwalk __PROTO__((const char*, int(*)(Ftw_t*), int, int(*)(Ftw_t*, Ftw_t*)));
+extern __MANGLE__ int ftwflags __PROTO__((void));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/getopt.h b/usr/src/lib/libast/amd64/include/ast/getopt.h
new file mode 100644
index 0000000000..01348b6402
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/getopt.h
@@ -0,0 +1,31 @@
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+#include <ast_getopt.h>
+
+#if !defined(_GETOPT_H) && !defined(_AST_STD_I)
+
+#define _GETOPT_H 1
+
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+struct option
+{
+ const char* name;
+ int has_arg;
+ int* flag;
+ int val;
+};
+
+extern __MANGLE__ int getopt_long __PROTO__((int, char* const*, const char*, const struct option*, int*));
+extern __MANGLE__ int getopt_long_only __PROTO__((int, char* const*, const char*, const struct option*, int*));
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/glob.h b/usr/src/lib/libast/amd64/include/ast/glob.h
new file mode 100644
index 0000000000..e02733177d
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/glob.h
@@ -0,0 +1,155 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * posix glob interface definitions with gnu extensions
+ */
+
+#ifndef _GLOB_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _GLOB_H
+
+#define GLOB_VERSION 20060717L
+
+#include <stdlib.h>
+
+struct dirent;
+struct stat;
+
+struct _glob_;
+struct _globlist_;
+
+typedef struct _glob_ glob_t;
+typedef struct _globlist_ globlist_t;
+
+struct _globlist_
+{
+ globlist_t* gl_next;
+ char* gl_begin;
+ unsigned char gl_flags;
+ char gl_path[1];
+};
+
+struct _glob_
+{
+ size_t gl_pathc;
+ char** gl_pathv;
+ size_t gl_offs;
+ globlist_t* gl_list;
+ int gl_flags;
+
+ /* GLOB_DISC data -- memset(&gl,0,sizeof(gl)) before using! */
+
+ const char* gl_fignore;
+ const char* gl_suffix;
+ unsigned char* gl_intr;
+
+ int gl_delim;
+
+ __V_* gl_handle;
+ __V_* (*gl_diropen) __PROTO__((glob_t*, const char*));
+ char* (*gl_dirnext) __PROTO__((glob_t*, __V_*));
+ void (*gl_dirclose) __PROTO__((glob_t*, __V_*));
+ int (*gl_type) __PROTO__((glob_t*, const char*));
+ int (*gl_attr) __PROTO__((glob_t*, const char*));
+
+ /* gnu extensions -- but how do you synthesize dirent and stat? */
+
+ __V_* (*gl_opendir) __PROTO__((const char*));
+ struct dirent* (*gl_readdir) __PROTO__((__V_*));
+ void (*gl_closedir) __PROTO__((__V_*));
+ int (*gl_stat) __PROTO__((const char*, struct stat*));
+ int (*gl_lstat) __PROTO__((const char*, struct stat*));
+
+ /* ast additions */
+
+ char* (*gl_nextdir) __PROTO__((glob_t*, char*));
+ unsigned long gl_status;
+ unsigned long gl_version;
+ unsigned short gl_extra;
+
+#ifdef _GLOB_PRIVATE_
+ _GLOB_PRIVATE_
+#else
+ char* gl_pad[23];
+#endif
+
+};
+
+/* standard interface */
+#define GLOB_APPEND 0x0001 /* append to previous */
+#define GLOB_DOOFFS 0x0002 /* gl_offs defines argv offset */
+#define GLOB_ERR 0x0004 /* abort on error */
+#define GLOB_MARK 0x0008 /* append / to directories */
+#define GLOB_NOCHECK 0x0010 /* nomatch is original pattern */
+#define GLOB_NOESCAPE 0x0020 /* don't treat \ specially */
+#define GLOB_NOSORT 0x0040 /* don't sort the list */
+
+/* extended interface */
+#define GLOB_STARSTAR 0x0080 /* enable [/]**[/] expansion */
+#define GLOB_BRACE 0x0100 /* enable {...} expansion */
+#define GLOB_ICASE 0x0200 /* ignore case on match */
+#define GLOB_COMPLETE 0x0400 /* shell file completeion */
+#define GLOB_AUGMENTED 0x0800 /* augmented shell patterns */
+#define GLOB_STACK 0x1000 /* allocate on current stack */
+#define GLOB_LIST 0x2000 /* just create gl_list */
+#define GLOB_ALTDIRFUNC 0x4000 /* gnu discipline functions */
+#define GLOB_DISC 0x8000 /* discipline initialized */
+
+/* gl_status */
+#define GLOB_NOTDIR 0x0001 /* last gl_dirnext() not a dir */
+
+/* gl_type return */
+#define GLOB_NOTFOUND 0 /* does not exist */
+#define GLOB_DEV 1 /* exists but not DIR EXE REG */
+#define GLOB_DIR 2 /* directory */
+#define GLOB_EXE 3 /* executable regular file */
+#define GLOB_REG 4 /* regular file */
+
+/* error return values */
+#define GLOB_ABORTED 1
+#define GLOB_NOMATCH 2
+#define GLOB_NOSPACE 3
+#define GLOB_INTR 4
+#define GLOB_APPERR 5
+#define GLOB_NOSYS 6
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int glob __PROTO__((const char*, int, int(*)(const char*,int), glob_t*));
+extern __MANGLE__ void globfree __PROTO__((glob_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif /* _GLOB_H */
diff --git a/usr/src/lib/libast/amd64/include/ast/hash.h b/usr/src/lib/libast/amd64/include/ast/hash.h
new file mode 100644
index 0000000000..4050612983
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/hash.h
@@ -0,0 +1,213 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * hash table library interface definitions
+ *
+ * NOTE: new code should use the more general <cdt.h>
+ */
+
+#ifndef _HASH_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _HASH_H
+
+#define HASH_ALLOCATE (1L<<0) /* allocate new key names */
+#define HASH_FIXED (1L<<1) /* fixed table size */
+#define HASH_HASHED (1L<<6) /* key names already hashed */
+#define HASH_RESIZE (1L<<2) /* table has been resized */
+#define HASH_SCANNING (1L<<3) /* currently scanning scope */
+#define HASH_SCOPE (1L<<4) /* push scope / create in bot */
+#define HASH_STATIC (1L<<5) /* static table allocation */
+
+#define HASH_CREATE (1L<<8) /* create bucket if not found */
+#define HASH_DELETE (1L<<9) /* delete bucket if found */
+#define HASH_LOOKUP 0 /* default op */
+#define HASH_RENAME (1L<<7) /* rename bucket if found */
+
+#define HASH_BUCKET (1L<<11) /* name is installed bucket */
+#define HASH_INSTALL (1L<<12) /* install allocated bucket */
+#define HASH_NOSCOPE (1L<<13) /* top scope only */
+#define HASH_OPAQUE (1L<<14) /* opaque bucket */
+#define HASH_VALUE (1L<<15) /* value bucket field used */
+
+#define HASH_SIZE(n) (((long)(n))<<16) /* fixed bucket size */
+#define HASH_SIZEOF(f) ((((long)(f))>>16)&0xffff) /* extract size */
+
+#define HASH_DELETED ((unsigned long)1<<(8*sizeof(int)-1)) /* deleted placeholder */
+#define HASH_KEEP (1L<<(8*sizeof(int)-2)) /* no free on bucket */
+#define HASH_HIDDEN (1L<<(8*sizeof(int)-3)) /* hidden by scope */
+#define HASH_HIDES (1L<<(8*sizeof(int)-4)) /* hides lower scope */
+#define HASH_OPAQUED (1L<<(8*sizeof(int)-5)) /* opaqued placeholder */
+#define HASH_FREENAME (1L<<(8*sizeof(int)-6)) /* free bucket name */
+
+#define HASH_RESET (HASH_RESIZE|HASH_SCOPE|HASH_STATIC|HASH_VALUE)
+#define HASH_INTERNAL (HASH_BUCKET|HASH_RESIZE|HASH_SCANNING|HASH_STATIC)
+#define HASH_FLAGS (HASH_DELETED|HASH_FREENAME|HASH_HIDDEN|HASH_HIDES|HASH_KEEP|HASH_OPAQUED)
+
+#define HASH_alloc 1
+#define HASH_clear 2
+#define HASH_compare 3
+#define HASH_free 4
+#define HASH_hash 5
+#define HASH_meanchain 6
+#define HASH_name 7
+#define HASH_namesize 8
+#define HASH_set 9
+#define HASH_size 10
+#define HASH_table 11
+#define HASH_va_list 12
+
+#define HASH_bucketsize 13
+
+#define HASH_region 14
+
+#include <hashpart.h>
+
+#define hashclear(t,f) ((t)->flags &= ~((f) & ~HASH_INTERNAL))
+#define hashcover(b) (((b)->hash&HASH_HIDES)?(Hash_bucket_t*)((b)->name):(Hash_bucket_t*)0)
+#define hashdel(t,n) hashlook(t, (char*)(n), HASH_DELETE, (char*)0)
+#define hashget(t,n) hashlook(t, (char*)(n), HASH_LOOKUP|HASH_VALUE, (char*)0)
+#define hashgetbucket(s) ((Hash_bucket_t*)((s)-((sizeof(Hash_bucket_t)+sizeof(char*)-1)/sizeof(char*))*sizeof(char*)))
+#define hashkeep(b) ((b)->hash|=HASH_KEEP)
+#define hashname(b) ((((b)->hash&HASH_HIDES)?((Hash_bucket_t*)((b)->name)):(b))->name)
+#define hashput(t,n,v) hashlook(t, (char*)(n), HASH_CREATE|HASH_VALUE, (char*)(v))
+#define hashref(t,n) hashlook(t, (char*)(n), HASH_LOOKUP|HASH_INTERNAL|HASH_VALUE, (char*)0)
+#define hashscope(t) ((t)->scope)
+#define hashset(t,f) ((t)->flags |= ((f) & ~HASH_INTERNAL))
+
+/*
+ * DEPRECATED renames for compatibility
+ */
+
+#define Hashbin_t Hash_bucket_t
+#define HASHBUCKET Hash_bucket_t
+#define Hashhdr_t Hash_header_t
+#define HASHHEADER Hash_header_t
+#define Hashpos_t Hash_position_t
+#define HASHPOSITION Hash_position_t
+#define Hashtab_t Hash_table_t
+#define HASHTABLE Hash_table_t
+
+#define vhashalloc hashvalloc
+#define hashvalloc(t,a) hashalloc(t,HASH_va_list,a,0)
+
+/*
+ * the #define's avoid union tags
+ */
+
+typedef struct Hash_bucket Hash_bucket_t;
+typedef struct Hash_root Hash_root_t;
+typedef struct Hash_table Hash_table_t;
+
+#define HASH_HEADER /* common bucket header */ \
+ Hash_bucket_t* next; /* next in collision chain */ \
+ unsigned int hash; /* hash flags and value */ \
+ char* name /* key name */
+
+#define HASH_DEFAULT /* HASH_VALUE bucket elements */ \
+ char* value /* key value */
+
+typedef struct /* bucket header */
+{
+ HASH_HEADER;
+} Hash_header_t;
+
+struct Hash_bucket /* prototype bucket */
+{
+ HASH_HEADER;
+ HASH_DEFAULT;
+};
+
+typedef struct /* hash scan bucket position */
+{
+ Hash_bucket_t* bucket; /* bucket */
+#ifdef _HASH_POSITION_PRIVATE_
+ _HASH_POSITION_PRIVATE_
+#endif
+} Hash_position_t;
+
+typedef struct /* last lookup cache */
+{
+ Hash_table_t* table; /* last lookup table */
+ Hash_bucket_t* bucket; /* last lookup bucket */
+#ifdef _HASH_LAST_PRIVATE_
+ _HASH_LAST_PRIVATE_
+#endif
+} Hash_last_t;
+
+struct Hash_root /* root hash table information */
+{
+ int accesses; /* number of accesses */
+ int collisions; /* number of collisions */
+ int flags; /* flags: see HASH_[A-Z]* */
+ Hash_last_t last; /* last lookup cache */
+ __V_* context; /* user defined context */
+#ifdef _HASH_ROOT_PRIVATE_
+ _HASH_ROOT_PRIVATE_
+#endif
+};
+
+struct Hash_table /* hash table information */
+{
+ Hash_root_t* root; /* root hash table information */
+ int size; /* table size */
+ int buckets; /* active bucket count */
+ char* name; /* table name */
+ Hash_table_t* scope; /* scope covered table */
+ short flags; /* flags: see HASH_[A-Z]* */
+#ifdef _HASH_TABLE_PRIVATE_
+ _HASH_TABLE_PRIVATE_
+#endif
+};
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Hash_table_t* hashalloc __PROTO__((Hash_table_t*, ...));
+extern __MANGLE__ void hashdone __PROTO__((Hash_position_t*));
+extern __MANGLE__ void hashdump __PROTO__((Hash_table_t*, int));
+extern __MANGLE__ Hash_table_t* hashfree __PROTO__((Hash_table_t*));
+extern __MANGLE__ Hash_bucket_t* hashlast __PROTO__((Hash_table_t*));
+extern __MANGLE__ char* hashlook __PROTO__((Hash_table_t*, const char*, long, const char*));
+extern __MANGLE__ Hash_bucket_t* hashnext __PROTO__((Hash_position_t*));
+extern __MANGLE__ Hash_position_t* hashscan __PROTO__((Hash_table_t*, int));
+extern __MANGLE__ void hashsize __PROTO__((Hash_table_t*, int));
+extern __MANGLE__ Hash_table_t* hashview __PROTO__((Hash_table_t*, Hash_table_t*));
+extern __MANGLE__ int hashwalk __PROTO__((Hash_table_t*, int, int (*)(const char*, char*, __V_*), __V_*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/hashkey.h b/usr/src/lib/libast/amd64/include/ast/hashkey.h
new file mode 100644
index 0000000000..1ce051ff26
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/hashkey.h
@@ -0,0 +1,73 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * 1-6 char lower-case keyword -> long hash
+ * digit args passed as HASHKEYN('2')
+ */
+
+#ifndef _HASHKEY_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _HASHKEY_H
+
+#define HASHKEYMAX 6
+#define HASHKEYBIT 5
+#define HASHKEYOFF ('a'-1)
+#define HASHKEYPART(h,c) (((h)<<HASHKEYBIT)+HASHKEY1(c))
+
+#define HASHKEYN(n) ((n)-'0'+'z'+1)
+
+#define HASHKEY1(c1) ((c1)-HASHKEYOFF)
+#define HASHKEY2(c1,c2) HASHKEYPART(HASHKEY1(c1),c2)
+#define HASHKEY3(c1,c2,c3) HASHKEYPART(HASHKEY2(c1,c2),c3)
+#define HASHKEY4(c1,c2,c3,c4) HASHKEYPART(HASHKEY3(c1,c2,c3),c4)
+#define HASHKEY5(c1,c2,c3,c4,c5) HASHKEYPART(HASHKEY4(c1,c2,c3,c4),c5)
+#define HASHKEY6(c1,c2,c3,c4,c5,c6) HASHKEYPART(HASHKEY5(c1,c2,c3,c4,c5),c6)
+
+#define HASHNKEY1(n,c1) HASHKEY2((n)+HASHKEYOFF,c1)
+#define HASHNKEY2(n,c2,c1) HASHKEY3((n)+HASHKEYOFF,c2,c1)
+#define HASHNKEY3(n,c3,c2,c1) HASHKEY4((n)+HASHKEYOFF,c3,c2,c1)
+#define HASHNKEY4(n,c4,c3,c2,c1) HASHKEY5((n)+'a',c4,c3,c2,c1)
+#define HASHNKEY5(n,c5,c4,c3,c2,c1) HASHKEY6((n)+'a',c5,c4,c3,c2,c1)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ long strkey __PROTO__((const char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/hashpart.h b/usr/src/lib/libast/amd64/include/ast/hashpart.h
new file mode 100644
index 0000000000..b2aa79649a
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/hashpart.h
@@ -0,0 +1,60 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * K. P. Vo
+ * G. S. Fowler
+ * AT&T Research
+ *
+ * ``the best'' combined linear congruent checksum/hash/PRNG
+ */
+
+#ifndef _HASHPART_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _HASHPART_H
+
+#define HASH_ADD(h) (0x9c39c33dL)
+
+#if __sparc__ || __sparc || sparc
+
+#define HASH_A(h,n) ((((h) << 2) - (h)) << (n))
+#define HASH_B(h,n) ((((h) << 4) - (h)) << (n))
+#define HASH_C(h,n) ((HASH_A(h,7) + HASH_B(h,0)) << (n))
+#define HASH_MPY(h) (HASH_C(h,22)+HASH_C(h,10)+HASH_A(h,6)+HASH_A(h,3)+(h))
+
+#else
+
+#define HASH_MPY(h) ((h)*0x63c63cd9L)
+
+#endif
+
+#define HASHPART(h,c) (h = HASH_MPY(h) + HASH_ADD(h) + (c))
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/iconv.h b/usr/src/lib/libast/amd64/include/ast/iconv.h
new file mode 100644
index 0000000000..e63b3f0fcd
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/iconv.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_iconv.h>
diff --git a/usr/src/lib/libast/amd64/include/ast/lc.h b/usr/src/lib/libast/amd64/include/ast/lc.h
new file mode 100644
index 0000000000..fdd804f36e
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/lc.h
@@ -0,0 +1,158 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated by ./lcgen : : */
+
+
+#ifndef _LC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _LC_H 1
+
+#include <ast.h>
+
+#define LC_abbreviated 0x00001
+#define LC_checked 0x00002
+#define LC_default 0x00004
+#define LC_defined 0x00008
+#define LC_debug 0x00010
+#define LC_local 0x00020
+#define LC_primary 0x00040
+#define LC_qualified 0x00080
+#define LC_undefined 0x00100
+#define LC_verbose 0x00200
+#define LC_user 0x10000
+#define LC_language_attribute_max 2
+#define LC_territory_language_max 4
+
+struct Lc_s;
+
+typedef struct Lc_info_s
+{
+ const struct Lc_s* lc;
+ unsigned long number;
+ __V_* data;
+} Lc_info_t;
+
+typedef struct Lc_attribute_s
+{
+ const char* name;
+ unsigned long flags;
+ unsigned long index;
+} Lc_attribute_t;
+
+typedef struct Lc_charset_s
+{
+ const char* code;
+ const char* alternates;
+ const char* ms;
+ unsigned long index;
+} Lc_charset_t;
+
+typedef struct Lc_language_s
+{
+ const char* code;
+ const char* name;
+ const char* alternates;
+ const Lc_charset_t* charset;
+ unsigned long flags;
+ unsigned long index;
+ const Lc_attribute_t* attributes[LC_language_attribute_max];
+} Lc_language_t;
+
+typedef struct Lc_territory_s
+{
+ const char* code;
+ const char* name;
+ unsigned long flags;
+ unsigned long index;
+ const Lc_language_t* languages[LC_territory_language_max];
+#ifdef _LC_TERRITORY_PRIVATE_
+ _LC_TERRITORY_PRIVATE_
+#endif
+} Lc_territory_t;
+
+typedef struct Lc_map_s
+{
+ const char* code;
+ const Lc_language_t* language;
+ const Lc_territory_t* territory;
+ const Lc_charset_t* charset;
+ const Lc_attribute_t* attribute;
+} Lc_map_t;
+
+typedef struct Lc_attribute_list_s
+{
+ struct Lc_attribute_list_s* next;
+ const Lc_attribute_t* attribute;
+} Lc_attribute_list_t;
+
+typedef struct Lc_s
+{
+ const char* name;
+ const char* code;
+ const Lc_language_t* language;
+ const Lc_territory_t* territory;
+ const Lc_charset_t* charset;
+ const Lc_attribute_list_t* attributes;
+ unsigned long flags;
+ unsigned long index;
+#ifdef _LC_PRIVATE_
+ _LC_PRIVATE_
+#endif
+} Lc_t;
+
+struct Lc_category_s;
+
+typedef int (*Lc_category_set_f) __PROTO__((struct Lc_category_s*));
+
+typedef struct Lc_category_s
+{
+ const char* name;
+ int external;
+ int internal;
+ Lc_category_set_f setf;
+ Lc_t* prev;
+} Lc_category_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ size_t lccanon __PROTO__((Lc_t*, unsigned long flags, char*, size_t));
+extern __MANGLE__ Lc_category_t* lccategories __PROTO__((void));
+extern __MANGLE__ int lcindex __PROTO__((int, int));
+extern __MANGLE__ Lc_info_t* lcinfo __PROTO__((int));
+extern __MANGLE__ Lc_t* lcmake __PROTO__((const char*));
+extern __MANGLE__ Lc_t* lcscan __PROTO__((Lc_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/ls.h b/usr/src/lib/libast/amd64/include/ast/ls.h
new file mode 100644
index 0000000000..cce1771b3f
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/ls.h
@@ -0,0 +1,99 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * ls formatter interface definitions
+ */
+
+#ifndef _LS_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _LS_H
+
+#include <ast_std.h>
+#include <ast_fs.h>
+#include <ast_mode.h>
+
+/*
+ * some systems (could it beee AIX) pollute the std name space
+ */
+
+#undef fileid
+#define fileid fileID
+
+#define LS_BLOCKSIZE 512
+
+#define iblocks(p) _iblocks(p)
+
+#if _mem_st_rdev_stat
+#define idevice(p) ((p)->st_rdev)
+#define IDEVICE(p,v) ((p)->st_rdev=(v))
+#else
+#define idevice(p) 0
+#define IDEVICE(p,v)
+#endif
+
+#define LS_ATIME (1<<0) /* list st_atime */
+#define LS_BLOCKS (1<<1) /* list blocks used by file */
+#define LS_CTIME (1<<2) /* list st_ctime */
+#define LS_EXTERNAL (1<<3) /* st_mode is modex canonical */
+#define LS_INUMBER (1<<4) /* list st_ino */
+#define LS_LONG (1<<5) /* long listing */
+#define LS_MARK (1<<6) /* append file name marks */
+#define LS_NOGROUP (1<<7) /* omit group name for LS_LONG */
+#define LS_NOUSER (1<<8) /* omit user name for LS_LONG */
+#define LS_NUMBER (1<<9) /* number instead of name */
+
+#define LS_USER (1<<10) /* first user flag bit */
+
+#define LS_W_BLOCKS 6 /* LS_BLOCKS field width */
+#define LS_W_INUMBER 7 /* LS_INUMBER field width */
+#define LS_W_LONG 55 /* LS_LONG width (w/o names) */
+#define LS_W_LINK 4 /* link text width (w/o names) */
+#define LS_W_MARK 1 /* LS_MARK field width */
+#define LS_W_NAME 9 /* group|user name field width */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ off_t _iblocks __PROTO__((struct stat*));
+extern __MANGLE__ char* fmtdev __PROTO__((struct stat*));
+extern __MANGLE__ char* fmtfs __PROTO__((struct stat*));
+extern __MANGLE__ char* fmtls __PROTO__((char*, const char*, struct stat*, const char*, const char*, int));
+extern __MANGLE__ int pathstat __PROTO__((const char*, struct stat*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/magic.h b/usr/src/lib/libast/amd64/include/ast/magic.h
new file mode 100644
index 0000000000..f484f2b20d
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/magic.h
@@ -0,0 +1,96 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * magic interface definitions
+ */
+
+#ifndef _MAGIC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MAGIC_H
+
+#include <sfio.h>
+#include <ls.h>
+
+#define MAGIC_VERSION 19961031L
+
+#ifndef MAGIC_FILE
+#define MAGIC_FILE "lib/file/magic"
+#endif
+
+#ifndef MAGIC_DIR
+#define MAGIC_DIR "lib/file"
+#endif
+
+#define MAGIC_FILE_ENV "MAGICFILE"
+
+#define MAGIC_MIME (1<<0) /* magictype returns MIME type */
+#define MAGIC_VERBOSE (1<<1) /* verbose magic file errors */
+
+#define MAGIC_USER (1L<<16) /* first user flag bit */
+
+struct Magic_s;
+struct Magicdisc_s;
+
+typedef struct Magicdisc_s
+{
+ unsigned long version; /* interface version */
+ unsigned long flags; /* MAGIC_* flags */
+ Error_f errorf; /* error function */
+} Magicdisc_t;
+
+typedef struct Magic_s
+{
+ const char* id; /* library id string */
+
+#ifdef _MAGIC_PRIVATE_
+ _MAGIC_PRIVATE_
+#endif
+
+} Magic_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Magic_t* magicopen __PROTO__((Magicdisc_t*));
+extern __MANGLE__ int magicload __PROTO__((Magic_t*, const char*, unsigned long));
+extern __MANGLE__ int magiclist __PROTO__((Magic_t*, Sfio_t*));
+extern __MANGLE__ char* magictype __PROTO__((Magic_t*, Sfio_t*, const char*, struct stat*));
+extern __MANGLE__ int magicclose __PROTO__((Magic_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/magicid.h b/usr/src/lib/libast/amd64/include/ast/magicid.h
new file mode 100644
index 0000000000..ceadff2653
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/magicid.h
@@ -0,0 +1,55 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * generic binary magic id definitions
+ */
+
+#ifndef _MAGICID_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MAGICID_H 1
+
+#include <ast_common.h>
+
+#define MAGICID 0x00010203
+
+typedef uint32_t Magicid_data_t;
+
+typedef struct Magicid_s
+{
+ Magicid_data_t magic; /* magic number */
+ char name[8]; /* generic data/application name*/
+ char type[12]; /* specific data type */
+ Magicid_data_t version; /* YYYYMMDD or 0xWWXXYYZZ */
+ Magicid_data_t size;
+} Magicid_t;
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/mc.h b/usr/src/lib/libast/amd64/include/ast/mc.h
new file mode 100644
index 0000000000..4b55665b3b
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/mc.h
@@ -0,0 +1,107 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * machine independent binary message catalog interface
+ *
+ * file layout
+ * all numbers are sfputu() format
+ *
+ * 4 char magic (^M^S^G0)
+ * <method locale YYYY-MM-DD>\0
+ * (<optional strings>\0)*
+ * \0
+ * string table size
+ * #msgs total
+ * #max set number
+ * #set-id 1
+ * #msgs in set 1
+ * ...
+ * #set-id #sets
+ * #msgs in set #sets
+ * end of sets (0)
+ * msg(1,1) size
+ * ...
+ * msg(#sets,#msgs) size
+ * string table
+ */
+
+#ifndef _MC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MC_H
+
+#include <ast.h>
+
+#define MC_MAGIC "\015\023\007\000"
+#define MC_MAGIC_SIZE 4
+
+#define MC_SET_MAX 1023
+#define MC_NUM_MAX 32767
+
+#define MC_NLS (1<<10)
+
+#define MC_MESSAGE_SET(s) mcindex(s,NiL,NiL,NiL)
+
+typedef struct
+{
+ char** msg;
+ int num;
+ int gen;
+} Mcset_t;
+
+typedef struct
+{
+ Mcset_t* set;
+ int num;
+ int gen;
+ char* translation;
+#ifdef _MC_PRIVATE_
+ _MC_PRIVATE_
+#endif
+} Mc_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ char* mcfind __PROTO__((char*, const char*, const char*, int, int));
+extern __MANGLE__ Mc_t* mcopen __PROTO__((Sfio_t*));
+extern __MANGLE__ char* mcget __PROTO__((Mc_t*, int, int, const char*));
+extern __MANGLE__ int mcput __PROTO__((Mc_t*, int, int, const char*));
+extern __MANGLE__ int mcdump __PROTO__((Mc_t*, Sfio_t*));
+extern __MANGLE__ int mcindex __PROTO__((const char*, char**, int*, int*));
+extern __MANGLE__ int mcclose __PROTO__((Mc_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/mime.h b/usr/src/lib/libast/amd64/include/ast/mime.h
new file mode 100644
index 0000000000..b018b68c9a
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/mime.h
@@ -0,0 +1,102 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * mime/mailcap interface
+ */
+
+#ifndef _MIMETYPE_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MIMETYPE_H 1
+
+#include <sfio.h>
+#include <ls.h>
+
+#define MIME_VERSION 19970717L
+
+#ifndef MIME_FILES
+#define MIME_FILES "~/.mailcap:/usr/local/etc/mailcap:/usr/etc/mailcap:/etc/mailcap:/etc/mail/mailcap:/usr/public/lib/mailcap"
+#endif
+
+#define MIME_FILES_ENV "MAILCAP"
+
+#define MIME_LIST (1<<0) /* mimeload arg is : list */
+#define MIME_NOMAGIC (1<<1) /* no magic for mimetype() */
+#define MIME_PIPE (1<<2) /* mimeview() io is piped */
+#define MIME_REPLACE (1<<3) /* replace existing definition */
+
+#define MIME_USER (1L<<16) /* first user flag bit */
+
+struct Mime_s;
+typedef struct Mime_s Mime_t;
+
+struct Mimedisc_s;
+typedef struct Mimedisc_s Mimedisc_t;
+
+typedef int (*Mimevalue_f) __PROTO__((Mime_t*, __V_*, char*, size_t, Mimedisc_t*));
+
+struct Mimedisc_s
+{
+ unsigned long version; /* interface version */
+ unsigned long flags; /* MIME_* flags */
+ Error_f errorf; /* error function */
+ Mimevalue_f valuef; /* value extraction function */
+};
+
+struct Mime_s
+{
+ const char* id; /* library id string */
+
+#ifdef _MIME_PRIVATE_
+ _MIME_PRIVATE_
+#endif
+
+};
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Mime_t* mimeopen __PROTO__((Mimedisc_t*));
+extern __MANGLE__ int mimeload __PROTO__((Mime_t*, const char*, unsigned long));
+extern __MANGLE__ int mimelist __PROTO__((Mime_t*, Sfio_t*, const char*));
+extern __MANGLE__ int mimeclose __PROTO__((Mime_t*));
+extern __MANGLE__ int mimeset __PROTO__((Mime_t*, char*, unsigned long));
+extern __MANGLE__ char* mimetype __PROTO__((Mime_t*, Sfio_t*, const char*, struct stat*));
+extern __MANGLE__ char* mimeview __PROTO__((Mime_t*, const char*, const char*, const char*, const char*));
+extern __MANGLE__ int mimehead __PROTO__((Mime_t*, __V_*, size_t, size_t, char*));
+extern __MANGLE__ int mimecmp __PROTO__((const char*, const char*, char**));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/mnt.h b/usr/src/lib/libast/amd64/include/ast/mnt.h
new file mode 100644
index 0000000000..d877416642
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/mnt.h
@@ -0,0 +1,69 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * mounted filesystem scan interface
+ */
+
+#ifndef _MNT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MNT_H 1
+
+#undef MNT_REMOTE /* aix clash */
+#define MNT_REMOTE (1<<0) /* remote mount */
+
+typedef struct
+{
+ char* fs; /* filesystem name */
+ char* dir; /* mounted dir */
+ char* type; /* filesystem type */
+ char* options; /* options */
+ int freq; /* backup frequency */
+ int npass; /* number of parallel passes */
+ int flags; /* MNT_* flags */
+} Mnt_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ __V_* mntopen __PROTO__((const char*, const char*));
+extern __MANGLE__ Mnt_t* mntread __PROTO__((__V_*));
+extern __MANGLE__ int mntwrite __PROTO__((__V_*, const Mnt_t*));
+extern __MANGLE__ int mntclose __PROTO__((__V_*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/modecanon.h b/usr/src/lib/libast/amd64/include/ast/modecanon.h
new file mode 100644
index 0000000000..ce107238e3
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/modecanon.h
@@ -0,0 +1,74 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * canonical mode_t representation
+ */
+
+#ifndef _MODECANON_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MODECANON_H
+
+#define X_ITYPE(m) ((m)&X_IFMT)
+
+#define X_IFMT 0170000
+#define X_IFWHT 0160000
+#define X_IFDOOR 0150000
+#define X_IFSOCK 0140000
+#define X_IFLNK 0120000
+#define X_IFCTG 0110000
+#define X_IFREG 0100000
+#define X_IFBLK 0060000
+#define X_IFDIR 0040000
+#define X_IFCHR 0020000
+#define X_IFIFO 0010000
+
+#define X_IPERM 0007777
+#define X_ISUID 0004000
+#define X_ISGID 0002000
+#define X_ISVTX 0001000
+#define X_IRUSR 0000400
+#define X_IWUSR 0000200
+#define X_IXUSR 0000100
+#define X_IRGRP 0000040
+#define X_IWGRP 0000020
+#define X_IXGRP 0000010
+#define X_IROTH 0000004
+#define X_IWOTH 0000002
+#define X_IXOTH 0000001
+
+#define X_IRWXU (X_IRUSR|X_IWUSR|X_IXUSR)
+#define X_IRWXG (X_IRGRP|X_IWGRP|X_IXGRP)
+#define X_IRWXO (X_IROTH|X_IWOTH|X_IXOTH)
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/modex.h b/usr/src/lib/libast/amd64/include/ast/modex.h
new file mode 100644
index 0000000000..458ad18ac1
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/modex.h
@@ -0,0 +1,62 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * AT&T Research
+ *
+ * external mode_t representation support
+ */
+
+#ifndef _MODEX_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MODEX_H
+
+#include <ast_fs.h>
+#include <modecanon.h>
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int modei __PROTO__((int));
+extern __MANGLE__ int modex __PROTO__((int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _S_IDPERM
+#define modei(m) ((m)&X_IPERM)
+#if _S_IDTYPE
+#define modex(m) (m)
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/namval.h b/usr/src/lib/libast/amd64/include/ast/namval.h
new file mode 100644
index 0000000000..d746970d58
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/namval.h
@@ -0,0 +1,51 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * common name-value struct support
+ */
+
+#ifndef _NAMVAL_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _NAMVAL_H
+
+typedef struct
+{
+ char* name;
+ int value;
+#ifdef _NAMVAL_PRIVATE_
+ _NAMVAL_PRIVATE_
+#endif
+} Namval_t;
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/nl_types.h b/usr/src/lib/libast/amd64/include/ast/nl_types.h
new file mode 100644
index 0000000000..db7383c626
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/nl_types.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_nl_types.h>
diff --git a/usr/src/lib/libast/amd64/include/ast/option.h b/usr/src/lib/libast/amd64/include/ast/option.h
new file mode 100644
index 0000000000..7204047891
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/option.h
@@ -0,0 +1,119 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * command line option parse interface
+ */
+
+#ifndef _OPTION_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _OPTION_H
+
+#include <ast.h>
+
+#define OPT_VERSION 20070319L
+
+#define OPT_USER (1L<<16) /* first user flag bit */
+
+struct Opt_s;
+struct Optdisc_s;
+
+typedef int (*Optinfo_f) __PROTO__((struct Opt_s*, Sfio_t*, const char*, struct Optdisc_s*));
+
+typedef struct Optdisc_s
+{
+ unsigned long version; /* OPT_VERSION */
+ unsigned long flags; /* OPT_* flags */
+ char* catalog; /* error catalog id */
+ Optinfo_f infof; /* runtime info function */
+} Optdisc_t;
+
+/* NOTE: Opt_t member order fixed by a previous binary release */
+
+#ifndef _OPT_PRIVATE_
+#define _OPT_PRIVATE_ \
+ char pad[3*sizeof(__V_*)];
+#endif
+
+typedef struct Opt_s
+{
+ int again; /* see optjoin() */
+ char* arg; /* {:,#} string argument */
+ char** argv; /* most recent argv */
+ int index; /* argv index */
+ char* msg; /* error/usage message buffer */
+ long num; /* OBSOLETE -- use number */
+ int offset; /* char offset in argv[index] */
+ char option[8]; /* current flag {-,+} + option */
+ char name[64]; /* current long name or flag */
+ Optdisc_t* disc; /* user discipline */
+ intmax_t number; /* # numeric argument */
+ unsigned char assignment; /* option arg assigment op */
+ unsigned char pads[sizeof(__V_*)-1];
+ _OPT_PRIVATE_
+} Opt_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Opt_t* _opt_infop_;
+
+#define opt_info (*_opt_infop_)
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define optinit(d,f) (memset(d,0,sizeof(*(d))),(d)->version=OPT_VERSION,(d)->infof=(f),opt_info.disc=(d))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int optget __PROTO__((char**, const char*));
+extern __MANGLE__ int optjoin __PROTO__((char**, ...));
+extern __MANGLE__ char* opthelp __PROTO__((const char*, const char*));
+extern __MANGLE__ char* optusage __PROTO__((const char*));
+extern __MANGLE__ int optstr __PROTO__((const char*, const char*));
+extern __MANGLE__ int optesc __PROTO__((Sfio_t*, const char*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/preroot.h b/usr/src/lib/libast/amd64/include/ast/preroot.h
new file mode 100644
index 0000000000..c9dd06aed7
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/preroot.h
@@ -0,0 +1,27 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/preroot.sh by iffe version 2007-04-04 : : */
+#ifndef _def_preroot_ast
+#define _def_preroot_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* preroot not enabled */
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/proc.h b/usr/src/lib/libast/amd64/include/ast/proc.h
new file mode 100644
index 0000000000..1196fc5b3f
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/proc.h
@@ -0,0 +1,113 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * process library interface
+ */
+
+#ifndef _PROC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _PROC_H
+
+#include <ast.h>
+
+#define PROC_ARGMOD (1<<0) /* argv[-1],argv[0] can be modified */
+#define PROC_BACKGROUND (1<<1) /* shell background (&) setup */
+#define PROC_CLEANUP (1<<2) /* close parent redirect fds on error */
+#define PROC_DAEMON (1<<3) /* daemon setup */
+#define PROC_ENVCLEAR (1<<4) /* clear environment */
+#define PROC_FOREGROUND (1<<14) /* system(3) setup */
+#define PROC_GID (1<<5) /* setgid(getgid()) */
+#define PROC_IGNORE (1<<6) /* ignore parent pipe errors */
+#define PROC_OVERLAY (1<<7) /* overlay current process if possible */
+#define PROC_PARANOID (1<<8) /* restrict everything */
+#define PROC_PRIVELEGED (1<<9) /* setuid(0), setgid(getegid()) */
+#define PROC_READ (1<<10) /* proc pipe fd 1 returned */
+#define PROC_SESSION (1<<11) /* session leader */
+#define PROC_UID (1<<12) /* setuid(getuid()) */
+#define PROC_WRITE (1<<13) /* proc pipe fd 0 returned */
+#define PROC_ZOMBIE (1<<15) /* proc may leave a zombie behind */
+
+#define PROC_ARG_BIT 14 /* bits per op arg */
+#define PROC_OP_BIT 4 /* bits per op */
+
+#define PROC_ARG_NULL ((1<<PROC_ARG_BIT)-1)
+
+#define PROC_fd_dup 0x4
+#define PROC_FD_CHILD 0x1
+#define PROC_FD_PARENT 0x2
+
+#define PROC_sig_dfl 0x8
+#define PROC_sig_ign 0x9
+
+#define PROC_sys_pgrp 0xa
+#define PROC_sys_umask 0xb
+
+#define PROC_op1(o,a) (((o)<<(2*PROC_ARG_BIT))|((a)&((PROC_ARG_NULL<<PROC_ARG_BIT)|PROC_ARG_NULL)))
+#define PROC_op2(o,a,b) (((o)<<(2*PROC_ARG_BIT))|(((b)&PROC_ARG_NULL)<<PROC_ARG_BIT)|((a)&PROC_ARG_NULL))
+
+#define PROC_FD_CLOSE(p,f) PROC_op2(PROC_fd_dup|(f),p,PROC_ARG_NULL)
+#define PROC_FD_DUP(p,c,f) PROC_op2(PROC_fd_dup|(f),p,c)
+#define PROC_SIG_DFL(s) PROC_op1(PROC_sig_dfl,s,0)
+#define PROC_SIG_IGN(s) PROC_op1(PROC_sig_ign,s,0)
+#define PROC_SYS_PGRP(g) PROC_op1(PROC_sys_pgrp,g)
+#define PROC_SYS_UMASK(m) PROC_op1(PROC_sys_umask,m,0)
+
+#define PROC_OP(x) (((x)>>(2*PROC_ARG_BIT))&((1<<PROC_OP_BIT)-1))
+#define PROC_ARG(x,n) ((n)?(((x)>>(((n)-1)*PROC_ARG_BIT))&PROC_ARG_NULL):(((x)&~((1<<(2*PROC_ARG_BIT))-1))==~((1<<(2*PROC_ARG_BIT))-1))?(-1):((x)&~((1<<(2*PROC_ARG_BIT))-1)))
+
+typedef struct
+{
+ pid_t pid; /* process id */
+ pid_t pgrp; /* process group id */
+ int rfd; /* read fd if applicable */
+ int wfd; /* write fd if applicable */
+
+#ifdef _PROC_PRIVATE_
+_PROC_PRIVATE_
+#endif
+
+} Proc_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int procclose __PROTO__((Proc_t*));
+extern __MANGLE__ int procfree __PROTO__((Proc_t*));
+extern __MANGLE__ Proc_t* procopen __PROTO__((const char*, char**, char**, long*, long));
+extern __MANGLE__ int procrun __PROTO__((const char*, char**));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/prototyped.h b/usr/src/lib/libast/amd64/include/ast/prototyped.h
new file mode 100644
index 0000000000..113fb94d24
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/prototyped.h
@@ -0,0 +1,59 @@
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/re_comp.h b/usr/src/lib/libast/amd64/include/ast/re_comp.h
new file mode 100644
index 0000000000..5da565e880
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/re_comp.h
@@ -0,0 +1,52 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * re_comp interface definitions
+ *
+ * OBSOLETE: use <regex.h>
+ */
+
+#ifndef _RE_COMP_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _RE_COMP_H
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ char* re_comp __PROTO__((const char*));
+extern __MANGLE__ int re_exec __PROTO__((const char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/recfmt.h b/usr/src/lib/libast/amd64/include/ast/recfmt.h
new file mode 100644
index 0000000000..1a66761ec2
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/recfmt.h
@@ -0,0 +1,94 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * record format interface
+ */
+
+#ifndef _RECFMT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _RECFMT_H 1
+
+#include <ast.h>
+
+typedef uint32_t Recfmt_t;
+
+#define REC_delimited 0
+#define REC_fixed 1
+#define REC_variable 2
+#define REC_method 14
+#define REC_none 15
+
+#define REC_M_path 0
+#define REC_M_data 1
+
+#define RECTYPE(f) (((f)>>28)&((1<<4)-1))
+
+#define REC_D_TYPE(d) ((REC_delimited<<28)|((d)&((1<<8)-1)))
+#define REC_D_DELIMITER(f) ((f)&((1<<8)-1))
+
+#define REC_F_TYPE(s) ((REC_fixed<<28)|((s)&((1<<28)-1)))
+#define REC_F_SIZE(f) ((f)&((1<<28)-1))
+
+#define REC_U_TYPE(t,a) (((t)<<28)|((a)&((1<<28)-1)))
+#define REC_U_ATTRIBUTES(f) ((f)&~((1<<28)-1))
+
+#define REC_V_TYPE(h,o,z,l,i) ((REC_variable<<28)|((h)<<23)|((o)<<19)|(((z)-1)<<18)|((l)<<17)|((i)<<16))
+#define REC_V_RECORD(f,s) (((f)&(((1<<16)-1)<<16))|(s))
+#define REC_V_HEADER(f) (((f)>>23)&((1<<5)-1))
+#define REC_V_OFFSET(f) (((f)>>19)&((1<<4)-1))
+#define REC_V_LENGTH(f) ((((f)>>18)&1)+1)
+#define REC_V_LITTLE(f) (((f)>>17)&1)
+#define REC_V_INCLUSIVE(f) (((f)>>16)&1)
+#define REC_V_SIZE(f) ((f)&((1<<16)-1))
+#define REC_V_ATTRIBUTES(f) ((f)&~((1<<16)-1))
+
+#define REC_M_TYPE(i) ((REC_method<<28)|(i))
+#define REC_M_INDEX(f) ((f)&((1<<28)-1))
+
+#define REC_N_TYPE() 0xffffffff
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ char* fmtrec __PROTO__((Recfmt_t, int));
+extern __MANGLE__ Recfmt_t recfmt __PROTO__((const __V_*, size_t, off_t));
+extern __MANGLE__ Recfmt_t recstr __PROTO__((const char*, char**));
+extern __MANGLE__ ssize_t reclen __PROTO__((Recfmt_t, const __V_*, size_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/regex.h b/usr/src/lib/libast/amd64/include/ast/regex.h
new file mode 100644
index 0000000000..b1a8976991
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/regex.h
@@ -0,0 +1,227 @@
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+#ifdef _AST_STD_I
+#define _REGEX_H -1
+#define regex_t int
+#define regmatch_t int
+#endif
+#ifndef _REGEX_H
+#define _REGEX_H 1
+#undef regex_t
+#undef regmatch_t
+
+#include <ast_common.h>
+
+#define REG_VERSION 20030916L
+
+/* regcomp flags */
+
+#define REG_AUGMENTED 0x00000001 /* enable ! & < > */
+#define REG_EXTENDED 0x00000002 /* enable ( | ) */
+#define REG_ICASE 0x00000004 /* ignore case in match */
+#define REG_NEWLINE 0x00000008 /* ^/$ match embedded \n */
+#define REG_NOSUB 0x00000010 /* don't report subexp matches */
+#define REG_SHELL 0x00000020 /* shell pattern syntax */
+
+/* nonstandard regcomp flags */
+
+#define REG_LEFT 0x00000100 /* implicit ^... */
+#define REG_LITERAL 0x00000200 /* no operators */
+#define REG_MINIMAL 0x00000400 /* minimal match */
+#define REG_NULL 0x00000800 /* allow null patterns */
+#define REG_RIGHT 0x00001000 /* implicit ...$ */
+#define REG_LENIENT 0x00002000 /* look the other way */
+#define REG_ESCAPE 0x00004000 /* \ escapes delimiter in [...] */
+#define REG_FIRST 0x00008000 /* first match found will do */
+#define REG_MULTIPLE 0x00010000 /* multiple \n sep patterns */
+#define REG_DISCIPLINE 0x00020000 /* regex_t.re_disc is valid */
+#define REG_SPAN 0x00040000 /* . matches \n */
+#define REG_COMMENT 0x00080000 /* ignore pattern space & #...\n*/
+#define REG_MULTIREF 0x00100000 /* multiple digit backrefs */
+#define REG_MUSTDELIM 0x08000000 /* all delimiters required */
+#define REG_DELIMITED 0x10000000 /* pattern[0] is delimiter */
+#define REG_SHELL_GROUP 0x20000000 /* (|&) inside [@|&](...) only */
+
+#define REG_SHELL_DOT 0x00200000 /* explicit leading . match */
+#define REG_SHELL_ESCAPED 0x00400000 /* \ not special */
+#define REG_SHELL_PATH 0x00800000 /* explicit / match */
+
+/* regexec flags */
+
+#define REG_NOTBOL 0x00000040 /* ^ is not a special char */
+#define REG_NOTEOL 0x00000080 /* $ is not a special char */
+
+/* nonstandard regexec flags */
+
+#define REG_INVERT 0x01000000 /* invert regrexec match sense */
+#define REG_STARTEND 0x02000000 /* subject==match[0].rm_{so,eo} */
+#define REG_ADVANCE 0x04000000 /* advance match[0].rm_{so,eo} */
+
+/* regalloc flags */
+
+#define REG_NOFREE 0x00000001 /* don't free */
+
+/* regsub flags */
+
+#define REG_SUB_ALL 0x00000001 /* substitute all occurrences */
+#define REG_SUB_LOWER 0x00000002 /* substitute to lower case */
+#define REG_SUB_UPPER 0x00000004 /* substitute to upper case */
+#define REG_SUB_PRINT 0x00000010 /* internal no-op */
+#define REG_SUB_NUMBER 0x00000020 /* internal no-op */
+#define REG_SUB_STOP 0x00000040 /* internal no-op */
+#define REG_SUB_WRITE 0x00000080 /* internal no-op */
+#define REG_SUB_LAST 0x00000100 /* last substitution option */
+#define REG_SUB_FULL 0x00000200 /* fully delimited */
+#define REG_SUB_USER 0x00001000 /* first user flag bit */
+
+/* regex error codes */
+
+#define REG_ENOSYS (-1) /* not supported */
+#define REG_NOMATCH 1 /* regexec didn't match */
+#define REG_BADPAT 2 /* invalid regular expression */
+#define REG_ECOLLATE 3 /* invalid collation element */
+#define REG_ECTYPE 4 /* invalid character class */
+#define REG_EESCAPE 5 /* trailing \ in pattern */
+#define REG_ESUBREG 6 /* invalid \digit backreference */
+#define REG_EBRACK 7 /* [...] imbalance */
+#define REG_EPAREN 8 /* \(...\) or (...) imbalance */
+#define REG_EBRACE 9 /* \{...\} or {...} imbalance */
+#define REG_BADBR 10 /* invalid {...} digits */
+#define REG_ERANGE 11 /* invalid [...] range endpoint */
+#define REG_ESPACE 12 /* out of space */
+#define REG_BADRPT 13 /* unary op not preceeded by re */
+#define REG_ENULL 14 /* empty subexpr in pattern */
+#define REG_ECOUNT 15 /* re component count overflow */
+#define REG_BADESC 16 /* invalid \char escape */
+#define REG_VERSIONID 17 /* version id (pseudo error) */
+#define REG_EFLAGS 18 /* flags conflict */
+#define REG_EDELIM 19 /* invalid or omitted delimiter */
+#define REG_PANIC 20 /* unrecoverable internal error */
+
+struct regex_s; typedef struct regex_s regex_t;
+struct regdisc_s; typedef struct regdisc_s regdisc_t;
+
+typedef int (*regclass_t) __PROTO__((int));
+typedef int32_t regflags_t;
+typedef int regoff_t;
+typedef int (*regerror_t) __PROTO__((const regex_t*, regdisc_t*, int, ...));
+typedef __V_* (*regcomp_t) __PROTO__((const regex_t*, const char*, size_t, regdisc_t*));
+typedef int (*regexec_t) __PROTO__((const regex_t*, __V_*, const char*, size_t, const char*, size_t, char**, regdisc_t*));
+typedef __V_* (*regresize_t) __PROTO__((__V_*, __V_*, size_t));
+typedef int (*regrecord_t) __PROTO__((__V_*, const char*, size_t));
+
+typedef struct regmatch_s
+{
+ regoff_t rm_so; /* offset of start */
+ regoff_t rm_eo; /* offset of end */
+} regmatch_t;
+
+typedef struct regsub_s
+{
+ regflags_t re_flags; /* regsubcomp() flags */
+ char* re_buf; /* regsubexec() output buffer */
+ size_t re_len; /* re_buf length */
+ int re_min; /* regsubcomp() min matches */
+#ifdef _REG_SUB_PRIVATE_
+ _REG_SUB_PRIVATE_
+#endif
+} regsub_t;
+
+struct regdisc_s
+{
+ unsigned long re_version; /* discipline version */
+ regflags_t re_flags; /* discipline flags */
+ regerror_t re_errorf; /* error function */
+ int re_errorlevel; /* errorf level */
+ regresize_t re_resizef; /* alloc/free function */
+ __V_* re_resizehandle;/* resizef handle */
+ regcomp_t re_compf; /* (?{...}) compile function */
+ regexec_t re_execf; /* (?{...}) execute function */
+ unsigned char* re_map; /* external to native ccode map */
+};
+
+typedef struct regstat_s
+{
+ regflags_t re_flags; /* REG_LEFT|REG_RIGHT */
+ ssize_t re_min; /* min anchored match length */
+ ssize_t re_max; /* max anchored match length */
+ ssize_t re_record; /* regrexec() match length */
+} regstat_t;
+
+struct regex_s
+{
+ size_t re_nsub; /* number of subexpressions */
+ struct reglib_s*re_info; /* library private info */
+ size_t re_npat; /* number of pattern chars used */
+ regdisc_t* re_disc; /* REG_DISCIPLINE discipline */
+ regsub_t* re_sub; /* regsubcomp() data */
+};
+
+#define reginit(disc) (memset(disc,0,sizeof(*(disc))),(disc)->re_version=REG_VERSION)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int regcomp __PROTO__((regex_t*, const char*, regflags_t));
+extern __MANGLE__ size_t regerror __PROTO__((int, const regex_t*, char*, size_t));
+extern __MANGLE__ int regexec __PROTO__((const regex_t*, const char*, size_t, regmatch_t*, regflags_t));
+extern __MANGLE__ void regfree __PROTO__((regex_t*));
+
+/* nonstandard hooks */
+
+#define _REG_cache 1 /* have regcache() */
+#define _REG_class 1 /* have regclass() */
+#define _REG_collate 1 /* have regcollate(), regclass() */
+#define _REG_comb 1 /* have regcomb() */
+#define _REG_decomp 1 /* have regdecomp() */
+#define _REG_dup 1 /* have regdup() */
+#define _REG_fatal 1 /* have regfatal(), regfatalpat() */
+#define _REG_ncomp 1 /* have regncomp() */
+#define _REG_nexec 1 /* have regnexec() */
+#define _REG_rexec 1 /* have regrexec(), regrecord() */
+#define _REG_stat 1 /* have regstat() */
+#define _REG_subcomp 1 /* have regsubcomp(), regsubexec() */
+
+extern __MANGLE__ regclass_t regclass __PROTO__((const char*, char**));
+extern __MANGLE__ int regaddclass __PROTO__((const char*, regclass_t));
+extern __MANGLE__ int regcollate __PROTO__((const char*, char**, char*, int));
+extern __MANGLE__ int regcomb __PROTO__((regex_t*, regex_t*));
+extern __MANGLE__ size_t regdecomp __PROTO__((regex_t*, regflags_t, char*, size_t));
+extern __MANGLE__ int regdup __PROTO__((regex_t*, regex_t*));
+extern __MANGLE__ int regncomp __PROTO__((regex_t*, const char*, size_t, regflags_t));
+extern __MANGLE__ int regnexec __PROTO__((const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t));
+extern __MANGLE__ void regfatal __PROTO__((regex_t*, int, int));
+extern __MANGLE__ void regfatalpat __PROTO__((regex_t*, int, int, const char*));
+extern __MANGLE__ int regrecord __PROTO__((const regex_t*));
+extern __MANGLE__ int regrexec __PROTO__((const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t, int, __V_*, regrecord_t));
+extern __MANGLE__ regstat_t* regstat __PROTO__((const regex_t*));
+
+extern __MANGLE__ regex_t* regcache __PROTO__((const char*, regflags_t, int*));
+
+extern __MANGLE__ int regsubcomp __PROTO__((regex_t*, const char*, const regflags_t*, int, regflags_t));
+extern __MANGLE__ int regsubexec __PROTO__((const regex_t*, const char*, size_t, regmatch_t*));
+extern __MANGLE__ int regsubflags __PROTO__((regex_t*, const char*, char**, int, const regflags_t*, int*, regflags_t*));
+extern __MANGLE__ void regsubfree __PROTO__((regex_t*));
+
+/* obsolete hooks */
+
+#ifndef _SFIO_H
+struct _sfio_s;
+#endif
+
+extern __MANGLE__ void regalloc __PROTO__((__V_*, regresize_t, regflags_t));
+extern __MANGLE__ int regsub __PROTO__((const regex_t*, struct _sfio_s*, const char*, const char*, size_t, regmatch_t*, regflags_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/regexp.h b/usr/src/lib/libast/amd64/include/ast/regexp.h
new file mode 100644
index 0000000000..b7f3ed6313
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/regexp.h
@@ -0,0 +1,139 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * regexp interface and partial implementation
+ * what a novel approach
+ * don't do it again
+ *
+ * OBSOLETE: use <regex.h>
+ */
+
+#ifndef _REGEXP_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _REGEXP_H
+
+#define NBRA 9
+
+typedef struct
+{
+ char* re_braslist[NBRA];
+ char* re_braelist[NBRA];
+ char* re_loc1;
+ char* re_loc2;
+ char* re_locs;
+ int re_circf;
+ int re_nbra;
+ int re_nodelim;
+ int re_sed;
+} regexp_t;
+
+#define braslist _re_info.re_braslist
+#define braelist _re_info.re_braelist
+#define circf _re_info.re_circf
+#define loc1 _re_info.re_loc1
+#define loc2 _re_info.re_loc2
+#define locs _re_info.re_locs
+#define nbra _re_info.re_nbra
+#define nodelim _re_info.re_nodelim
+#define sed _re_info.re_sed
+
+#define advance(a,b) _re_exec(&_re_info,a,b,1)
+#define compile(a,b,c,d) _re_read(&_re_info,a,b,c,d)
+#define step(a,b) _re_exec(&_re_info,a,b,0)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _re_comp __PROTO__((regexp_t*, const char*, char*, unsigned int));
+extern __MANGLE__ int _re_exec __PROTO__((regexp_t*, const char*, const char*, int));
+extern __MANGLE__ char* _re_putc __PROTO__((int));
+extern __MANGLE__ char* _re_read __PROTO__((regexp_t*, const char*, char*, const char*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#ifndef _REGEXP_DECLARE
+
+regexp_t _re_info;
+
+char*
+_re_read __PARAM__((register regexp_t* re, const char* instring, char* ep, const char* endbuf, int seof), (re, instring, ep, endbuf, seof)) __OTORP__(register regexp_t* re; const char* instring; char* ep; const char* endbuf; int seof;){
+ register int c;
+
+ static const char* prev;
+
+#ifdef INIT
+ INIT;
+#endif
+
+ re->re_nodelim = 0;
+ if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0)
+ {
+ if (c != seof)
+ {
+ UNGETC(c);
+ re->re_nodelim = 1;
+ }
+ if (!re->re_sed && !prev)
+ { ERROR(41); }
+ RETURN((char*)endbuf);
+ }
+ UNGETC(c);
+ prev = 0;
+ for (;;)
+ {
+ if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0)
+ {
+ if (re->re_sed)
+ { ERROR(36); }
+ UNGETC(c);
+ re->re_nodelim = 1;
+ break;
+ }
+ if (c == '\\')
+ {
+ _re_putc(c);
+ if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0)
+ { ERROR(36); }
+ }
+ _re_putc(c);
+ }
+ if (c = _re_comp(re, _re_putc(0), ep, (char*)endbuf - ep))
+ { ERROR(c); }
+ prev = endbuf;
+ RETURN((char*)prev);
+}
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/sfdisc.h b/usr/src/lib/libast/amd64/include/ast/sfdisc.h
new file mode 100644
index 0000000000..9e657f045b
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/sfdisc.h
@@ -0,0 +1,82 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * AT&T Research
+ *
+ * sfio discipline interface definitions
+ */
+
+#ifndef _SFDISC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SFDISC_H
+
+#include <ast.h>
+
+#define SFDCEVENT(a,b,n) ((((a)-'A'+1)<<11)^(((b)-'A'+1)<<6)^(n))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#define SFSK_DISCARD SFDCEVENT('S','K',1)
+
+/*
+ * %(...) printf support
+ */
+
+typedef int (*Sf_key_lookup_t) __PROTO__((__V_*, Sffmt_t*, const char*, char**, Sflong_t*));
+typedef char* (*Sf_key_convert_t) __PROTO__((__V_*, Sffmt_t*, const char*, char*, Sflong_t));
+
+extern __MANGLE__ int sfkeyprintf __PROTO__((Sfio_t*, __V_*, const char*, Sf_key_lookup_t, Sf_key_convert_t));
+#define sfkeyprintf sfkeyprintf_20000308 /* Sffmt_t* callback args */
+extern __MANGLE__ int sfkeyprintf __PROTO__((Sfio_t*, __V_*, const char*, Sf_key_lookup_t, Sf_key_convert_t));
+
+/*
+ * pure sfio read and/or write disciplines
+ */
+
+extern __MANGLE__ int sfdcdio __PROTO__((Sfio_t*, size_t));
+extern __MANGLE__ int sfdcdos __PROTO__((Sfio_t*));
+extern __MANGLE__ int sfdcfilter __PROTO__((Sfio_t*, const char*));
+extern __MANGLE__ int sfdcmore __PROTO__((Sfio_t*, const char*, int, int));
+extern __MANGLE__ int sfdcprefix __PROTO__((Sfio_t*, const char*));
+extern __MANGLE__ int sfdcseekable __PROTO__((Sfio_t*));
+extern __MANGLE__ int sfdcslow __PROTO__((Sfio_t*));
+extern __MANGLE__ int sfdctee __PROTO__((Sfio_t*, Sfio_t*));
+extern __MANGLE__ int sfdcunion __PROTO__((Sfio_t*, Sfio_t**, int));
+
+extern __MANGLE__ Sfio_t* sfdcsubstream __PROTO__((Sfio_t*, Sfio_t*, Sfoff_t, Sfoff_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/sfio.h b/usr/src/lib/libast/amd64/include/ast/sfio.h
new file mode 100644
index 0000000000..9feba3043e
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/sfio.h
@@ -0,0 +1,452 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _SFIO_H
+#define _SFIO_H 1
+
+#define SFIO_VERSION 20050202L
+
+/* Public header file for the sfio library
+**
+** Written by Kiem-Phong Vo
+*/
+
+typedef struct _sfio_s Sfio_t;
+typedef struct _sfdisc_s Sfdisc_t;
+
+#if defined(_AST_STD_H) || defined(_PACKAGE_ast) && defined(_SFIO_PRIVATE)
+#include <ast_std.h>
+#else
+#include <ast_common.h>
+#endif /* _PACKAGE_ast */
+
+/* Sfoff_t should be large enough for largest file address */
+#define Sfoff_t intmax_t
+#define Sflong_t intmax_t
+#define Sfulong_t uintmax_t
+#define Sfdouble_t _ast_fltmax_t
+
+typedef ssize_t (*Sfread_f)_ARG_((Sfio_t*, Void_t*, size_t, Sfdisc_t*));
+typedef ssize_t (*Sfwrite_f)_ARG_((Sfio_t*, const Void_t*, size_t, Sfdisc_t*));
+typedef Sfoff_t (*Sfseek_f)_ARG_((Sfio_t*, Sfoff_t, int, Sfdisc_t*));
+typedef int (*Sfexcept_f)_ARG_((Sfio_t*, int, Void_t*, Sfdisc_t*));
+
+/* discipline structure */
+struct _sfdisc_s
+{ Sfread_f readf; /* read function */
+ Sfwrite_f writef; /* write function */
+ Sfseek_f seekf; /* seek function */
+ Sfexcept_f exceptf; /* to handle exceptions */
+ Sfdisc_t* disc; /* the continuing discipline */
+};
+
+#include <sfio_s.h>
+
+/* formatting environment */
+typedef struct _sffmt_s Sffmt_t;
+typedef int (*Sffmtext_f)_ARG_((Sfio_t*, Void_t*, Sffmt_t*));
+typedef int (*Sffmtevent_f)_ARG_((Sfio_t*, int, Void_t*, Sffmt_t*));
+struct _sffmt_s
+{ long version;/* version of this structure */
+ Sffmtext_f extf; /* function to process arguments */
+ Sffmtevent_f eventf; /* process events */
+
+ char* form; /* format string to stack */
+ va_list args; /* corresponding arg list */
+
+ int fmt; /* format character */
+ ssize_t size; /* object size */
+ int flags; /* formatting flags */
+ int width; /* width of field */
+ int precis; /* precision required */
+ int base; /* conversion base */
+
+ char* t_str; /* type string */
+ ssize_t n_str; /* length of t_str */
+
+ Void_t* mbs; /* multibyte state for format string */
+
+ Void_t* none; /* unused for now */
+};
+#define sffmtversion(fe,type) \
+ ((type) ? ((fe)->version = SFIO_VERSION) : (fe)->version)
+
+#define SFFMT_SSHORT 000000010 /* 'hh' flag, char */
+#define SFFMT_TFLAG 000000020 /* 't' flag, ptrdiff_t */
+#define SFFMT_ZFLAG 000000040 /* 'z' flag, size_t */
+
+#define SFFMT_LEFT 000000100 /* left-justification */
+#define SFFMT_SIGN 000000200 /* must have a sign */
+#define SFFMT_BLANK 000000400 /* if not signed, prepend a blank */
+#define SFFMT_ZERO 000001000 /* zero-padding on the left */
+#define SFFMT_ALTER 000002000 /* alternate formatting */
+#define SFFMT_THOUSAND 000004000 /* thousand grouping */
+#define SFFMT_SKIP 000010000 /* skip assignment in scanf() */
+#define SFFMT_SHORT 000020000 /* 'h' flag */
+#define SFFMT_LONG 000040000 /* 'l' flag */
+#define SFFMT_LLONG 000100000 /* 'll' flag */
+#define SFFMT_LDOUBLE 000200000 /* 'L' flag */
+#define SFFMT_VALUE 000400000 /* value is returned */
+#define SFFMT_ARGPOS 001000000 /* getting arg for $ patterns */
+#define SFFMT_IFLAG 002000000 /* 'I' flag */
+#define SFFMT_JFLAG 004000000 /* 'j' flag, intmax_t */
+#define SFFMT_CENTER 010000000 /* '=' flag, center justification */
+#define SFFMT_SET 017777770 /* flags settable on calling extf */
+
+/* for sfmutex() call */
+#define SFMTX_LOCK 0 /* up mutex count */
+#define SFMTX_TRYLOCK 1 /* try to up mutex count */
+#define SFMTX_UNLOCK 2 /* down mutex count */
+#define SFMTX_CLRLOCK 3 /* clear mutex count */
+
+/* various constants */
+#ifndef NULL
+#define NULL 0
+#endif
+#ifndef EOF
+#define EOF (-1)
+#endif
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+/* bits for various types of files */
+#define SF_READ 0000001 /* open for reading */
+#define SF_WRITE 0000002 /* open for writing */
+#define SF_STRING 0000004 /* a string stream */
+#define SF_APPENDWR 0000010 /* file is in append mode only */
+#define SF_MALLOC 0000020 /* buffer is malloc-ed */
+#define SF_LINE 0000040 /* line buffering */
+#define SF_SHARE 0000100 /* stream with shared file descriptor */
+#define SF_EOF 0000200 /* eof was detected */
+#define SF_ERROR 0000400 /* an error happened */
+#define SF_STATIC 0001000 /* a stream that cannot be freed */
+#define SF_IOCHECK 0002000 /* call exceptf before doing IO */
+#define SF_PUBLIC 0004000 /* SF_SHARE and follow physical seek */
+#define SF_MTSAFE 0010000 /* need thread safety */
+#define SF_WHOLE 0020000 /* preserve wholeness of sfwrite/sfputr */
+#define SF_IOINTR 0040000 /* return on interrupts */
+#define SF_WCWIDTH 0100000 /* wcwidth display stream */
+
+#define SF_FLAGS 0177177 /* PUBLIC FLAGS PASSABLE TO SFNEW() */
+#define SF_SETS 0177163 /* flags passable to sfset() */
+
+#ifndef _SF_NO_OBSOLETE
+#define SF_BUFCONST 0400000 /* unused flag - for compatibility only */
+#endif
+
+/* for sfgetr/sfreserve to hold a record */
+#define SF_LOCKR 0000010 /* lock record, stop access to stream */
+#define SF_LASTR 0000020 /* get the last incomplete record */
+
+/* exception events: SF_NEW(0), SF_READ(1), SF_WRITE(2) and the below */
+#define SF_SEEK 3 /* seek error */
+#define SF_CLOSING 4 /* when stream is about to be closed */
+#define SF_DPUSH 5 /* when discipline is being pushed */
+#define SF_DPOP 6 /* when discipline is being popped */
+#define SF_DPOLL 7 /* see if stream is ready for I/O */
+#define SF_DBUFFER 8 /* buffer not empty during push or pop */
+#define SF_SYNC 9 /* announcing start/end synchronization */
+#define SF_PURGE 10 /* a sfpurge() call was issued */
+#define SF_FINAL 11 /* closing is done except stream free */
+#define SF_READY 12 /* a polled stream is ready */
+#define SF_LOCKED 13 /* stream is in a locked state */
+#define SF_ATEXIT 14 /* process is exiting */
+#define SF_EVENT 100 /* start of user-defined events */
+
+/* for stack and disciplines */
+#define SF_POPSTACK ((Sfio_t*)0) /* pop the stream stack */
+#define SF_POPDISC ((Sfdisc_t*)0) /* pop the discipline stack */
+
+/* for the notify function and discipline exception */
+#define SF_NEW 0 /* new stream */
+#define SF_SETFD (-1) /* about to set the file descriptor */
+
+#define SF_BUFSIZE 8192 /* default buffer size */
+#define SF_UNBOUND (-1) /* unbounded buffer size */
+
+/* namespace incursion workarounds -- migrate to the new names */
+#if !_mac_SF_APPEND
+#define SF_APPEND SF_APPENDWR /* BSDI sys/stat.h */
+#endif
+#if !_mac_SF_CLOSE
+#define SF_CLOSE SF_CLOSING /* AIX sys/socket.h */
+#endif
+
+_BEGIN_EXTERNS_
+
+/* standard in/out/err streams */
+
+#if _BLD_sfio && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+#if !_BLD_sfio && defined(__IMPORT__)
+#define extern extern __IMPORT__
+#endif
+
+extern ssize_t _Sfi;
+extern ssize_t _Sfmaxr;
+
+extern Sfio_t* sfstdin;
+extern Sfio_t* sfstdout;
+extern Sfio_t* sfstderr;
+
+#if _UWIN
+#undef extern
+#endif
+
+extern Sfio_t _Sfstdin;
+extern Sfio_t _Sfstdout;
+extern Sfio_t _Sfstderr;
+
+#undef extern
+
+#if _BLD_sfio && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Sfio_t* sfnew _ARG_((Sfio_t*, Void_t*, size_t, int, int));
+extern Sfio_t* sfopen _ARG_((Sfio_t*, const char*, const char*));
+extern Sfio_t* sfpopen _ARG_((Sfio_t*, const char*, const char*));
+extern Sfio_t* sfstack _ARG_((Sfio_t*, Sfio_t*));
+extern Sfio_t* sfswap _ARG_((Sfio_t*, Sfio_t*));
+extern Sfio_t* sftmp _ARG_((size_t));
+extern int sfpurge _ARG_((Sfio_t*));
+extern int sfpoll _ARG_((Sfio_t**, int, int));
+extern Void_t* sfreserve _ARG_((Sfio_t*, ssize_t, int));
+extern int sfresize _ARG_((Sfio_t*, Sfoff_t));
+extern int sfsync _ARG_((Sfio_t*));
+extern int sfclrlock _ARG_((Sfio_t*));
+extern Void_t* sfsetbuf _ARG_((Sfio_t*, Void_t*, size_t));
+extern Sfdisc_t* sfdisc _ARG_((Sfio_t*,Sfdisc_t*));
+extern int sfraise _ARG_((Sfio_t*, int, Void_t*));
+extern int sfnotify _ARG_((void(*)(Sfio_t*, int, int)));
+extern int sfset _ARG_((Sfio_t*, int, int));
+extern int sfsetfd _ARG_((Sfio_t*, int));
+extern Sfio_t* sfpool _ARG_((Sfio_t*, Sfio_t*, int));
+extern ssize_t sfread _ARG_((Sfio_t*, Void_t*, size_t));
+extern ssize_t sfwrite _ARG_((Sfio_t*, const Void_t*, size_t));
+extern Sfoff_t sfmove _ARG_((Sfio_t*, Sfio_t*, Sfoff_t, int));
+extern int sfclose _ARG_((Sfio_t*));
+extern Sfoff_t sftell _ARG_((Sfio_t*));
+extern Sfoff_t sfseek _ARG_((Sfio_t*, Sfoff_t, int));
+extern ssize_t sfputr _ARG_((Sfio_t*, const char*, int));
+extern char* sfgetr _ARG_((Sfio_t*, int, int));
+extern ssize_t sfnputc _ARG_((Sfio_t*, int, size_t));
+extern int sfungetc _ARG_((Sfio_t*, int));
+extern int sfprintf _ARG_((Sfio_t*, const char*, ...));
+extern char* sfprints _ARG_((const char*, ...));
+extern ssize_t sfsprintf _ARG_((char*, size_t, const char*, ...));
+extern ssize_t sfvsprintf _ARG_((char*, size_t, const char*, va_list));
+extern int sfvprintf _ARG_((Sfio_t*, const char*, va_list));
+extern int sfscanf _ARG_((Sfio_t*, const char*, ...));
+extern int sfsscanf _ARG_((const char*, const char*, ...));
+extern int sfvsscanf _ARG_((const char*, const char*, va_list));
+extern int sfvscanf _ARG_((Sfio_t*, const char*, va_list));
+
+/* mutex locking for thread-safety */
+extern int sfmutex _ARG_((Sfio_t*, int));
+
+/* io functions with discipline continuation */
+extern ssize_t sfrd _ARG_((Sfio_t*, Void_t*, size_t, Sfdisc_t*));
+extern ssize_t sfwr _ARG_((Sfio_t*, const Void_t*, size_t, Sfdisc_t*));
+extern Sfoff_t sfsk _ARG_((Sfio_t*, Sfoff_t, int, Sfdisc_t*));
+extern ssize_t sfpkrd _ARG_((int, Void_t*, size_t, int, long, int));
+
+/* portable handling of primitive types */
+extern int sfdlen _ARG_((Sfdouble_t));
+extern int sfllen _ARG_((Sflong_t));
+extern int sfulen _ARG_((Sfulong_t));
+
+extern int sfputd _ARG_((Sfio_t*, Sfdouble_t));
+extern int sfputl _ARG_((Sfio_t*, Sflong_t));
+extern int sfputu _ARG_((Sfio_t*, Sfulong_t));
+extern int sfputm _ARG_((Sfio_t*, Sfulong_t, Sfulong_t));
+extern int sfputc _ARG_((Sfio_t*, int));
+
+extern Sfdouble_t sfgetd _ARG_((Sfio_t*));
+extern Sflong_t sfgetl _ARG_((Sfio_t*));
+extern Sfulong_t sfgetu _ARG_((Sfio_t*));
+extern Sfulong_t sfgetm _ARG_((Sfio_t*, Sfulong_t));
+extern int sfgetc _ARG_((Sfio_t*));
+
+extern int _sfputd _ARG_((Sfio_t*, Sfdouble_t));
+extern int _sfputl _ARG_((Sfio_t*, Sflong_t));
+extern int _sfputu _ARG_((Sfio_t*, Sfulong_t));
+extern int _sfputm _ARG_((Sfio_t*, Sfulong_t, Sfulong_t));
+extern int _sfflsbuf _ARG_((Sfio_t*, int));
+
+extern int _sffilbuf _ARG_((Sfio_t*, int));
+
+extern int _sfdlen _ARG_((Sfdouble_t));
+extern int _sfllen _ARG_((Sflong_t));
+extern int _sfulen _ARG_((Sfulong_t));
+
+/* miscellaneous function analogues of fast in-line functions */
+extern Sfoff_t sfsize _ARG_((Sfio_t*));
+extern int sfclrerr _ARG_((Sfio_t*));
+extern int sfeof _ARG_((Sfio_t*));
+extern int sferror _ARG_((Sfio_t*));
+extern int sffileno _ARG_((Sfio_t*));
+extern int sfstacked _ARG_((Sfio_t*));
+extern ssize_t sfvalue _ARG_((Sfio_t*));
+extern ssize_t sfslen _ARG_((void));
+extern ssize_t sfmaxr _ARG_((ssize_t, int));
+
+#undef extern
+_END_EXTERNS_
+
+/* coding long integers in a portable and compact fashion */
+#define SF_SBITS 6
+#define SF_UBITS 7
+#define SF_BBITS 8
+#define SF_SIGN (1 << SF_SBITS)
+#define SF_MORE (1 << SF_UBITS)
+#define SF_BYTE (1 << SF_BBITS)
+#define SF_U1 SF_MORE
+#define SF_U2 (SF_U1*SF_U1)
+#define SF_U3 (SF_U2*SF_U1)
+#define SF_U4 (SF_U3*SF_U1)
+
+#if __cplusplus
+#define _SF_(f) (f)
+#else
+#define _SF_(f) ((Sfio_t*)(f))
+#endif
+
+#define __sf_putd(f,v) (_sfputd(_SF_(f),(Sfdouble_t)(v)))
+#define __sf_putl(f,v) (_sfputl(_SF_(f),(Sflong_t)(v)))
+#define __sf_putu(f,v) (_sfputu(_SF_(f),(Sfulong_t)(v)))
+#define __sf_putm(f,v,m) (_sfputm(_SF_(f),(Sfulong_t)(v),(Sfulong_t)(m)))
+
+#define __sf_putc(f,c) (_SF_(f)->_next >= _SF_(f)->_endw ? \
+ _sfflsbuf(_SF_(f),(int)((unsigned char)(c))) : \
+ (int)(*_SF_(f)->_next++ = (unsigned char)(c)) )
+#define __sf_getc(f) (_SF_(f)->_next >= _SF_(f)->_endr ? _sffilbuf(_SF_(f),0) : \
+ (int)(*_SF_(f)->_next++) )
+
+#define __sf_dlen(v) (_sfdlen((Sfdouble_t)(v)) )
+#define __sf_llen(v) (_sfllen((Sflong_t)(v)) )
+#define __sf_ulen(v) ((Sfulong_t)(v) < SF_U1 ? 1 : (Sfulong_t)(v) < SF_U2 ? 2 : \
+ (Sfulong_t)(v) < SF_U3 ? 3 : (Sfulong_t)(v) < SF_U4 ? 4 : 5)
+
+#define __sf_fileno(f) (_SF_(f)->_file)
+#define __sf_eof(f) (_SF_(f)->_flags&SF_EOF)
+#define __sf_error(f) (_SF_(f)->_flags&SF_ERROR)
+#define __sf_clrerr(f) (_SF_(f)->_flags &= ~(SF_ERROR|SF_EOF))
+#define __sf_stacked(f) (_SF_(f)->_push != (Sfio_t*)0)
+#define __sf_value(f) (_SF_(f)->_val)
+#define __sf_slen() (_Sfi)
+#define __sf_maxr(n,s) ((s)?((_Sfi=_Sfmaxr),(_Sfmaxr=(n)),_Sfi):_Sfmaxr)
+
+#if defined(__INLINE__) && !_BLD_sfio
+
+__INLINE__ int sfputd(Sfio_t* f, Sfdouble_t v) { return __sf_putd(f,v); }
+__INLINE__ int sfputl(Sfio_t* f, Sflong_t v) { return __sf_putl(f,v); }
+__INLINE__ int sfputu(Sfio_t* f, Sfulong_t v) { return __sf_putu(f,v); }
+__INLINE__ int sfputm(Sfio_t* f, Sfulong_t v, Sfulong_t m)
+ { return __sf_putm(f,v,m); }
+
+__INLINE__ int sfputc(Sfio_t* f, int c) { return __sf_putc(f,c); }
+__INLINE__ int sfgetc(Sfio_t* f) { return __sf_getc(f); }
+
+__INLINE__ int sfdlen(Sfdouble_t v) { return __sf_dlen(v); }
+__INLINE__ int sfllen(Sflong_t v) { return __sf_llen(v); }
+__INLINE__ int sfulen(Sfulong_t v) { return __sf_ulen(v); }
+
+__INLINE__ int sffileno(Sfio_t* f) { return __sf_fileno(f); }
+__INLINE__ int sfeof(Sfio_t* f) { return __sf_eof(f); }
+__INLINE__ int sferror(Sfio_t* f) { return __sf_error(f); }
+__INLINE__ int sfclrerr(Sfio_t* f) { return __sf_clrerr(f); }
+__INLINE__ int sfstacked(Sfio_t* f) { return __sf_stacked(f); }
+__INLINE__ ssize_t sfvalue(Sfio_t* f) { return __sf_value(f); }
+__INLINE__ ssize_t sfslen() { return __sf_slen(); }
+__INLINE__ ssize_t sfmaxr(ssize_t n, int s) { return __sf_maxr(n,s); }
+
+#else
+
+#define sfputd(f,v) ( __sf_putd((f),(v)) )
+#define sfputl(f,v) ( __sf_putl((f),(v)) )
+#define sfputu(f,v) ( __sf_putu((f),(v)) )
+#define sfputm(f,v,m) ( __sf_putm((f),(v),(m)) )
+
+#define sfputc(f,c) ( __sf_putc((f),(c)) )
+#define sfgetc(f) ( __sf_getc(f) )
+
+#define sfdlen(v) ( __sf_dlen(v) )
+#define sfllen(v) ( __sf_llen(v) )
+#define sfulen(v) ( __sf_ulen(v) )
+
+#define sffileno(f) ( __sf_fileno(f) )
+#define sfeof(f) ( __sf_eof(f) )
+#define sferror(f) ( __sf_error(f) )
+#define sfclrerr(f) ( __sf_clrerr(f) )
+#define sfstacked(f) ( __sf_stacked(f) )
+#define sfvalue(f) ( __sf_value(f) )
+#define sfslen() ( __sf_slen() )
+#define sfmaxr(n,s) ( __sf_maxr(n,s) )
+
+#endif /*__INLINE__*/
+
+#ifndef _SFSTR_H /* GSF's string manipulation stuff */
+#define _SFSTR_H 1
+
+#define sfstropen() sfnew(0, 0, -1, -1, SF_READ|SF_WRITE|SF_STRING)
+#define sfstrclose(f) sfclose(f)
+
+#define sfstrseek(f,p,m) \
+ ( (m) == SEEK_SET ? \
+ (((p) < 0 || (p) > (f)->_size) ? (char*)0 : \
+ (char*)((f)->_next = (f)->_data+(p)) ) \
+ : (m) == SEEK_CUR ? \
+ ((f)->_next += (p), \
+ (((f)->_next < (f)->_data || (f)->_next > (f)->_data+(f)->_size) ? \
+ ((f)->_next -= (p), (char*)0) : (char*)(f)->_next ) ) \
+ : (m) == SEEK_END ? \
+ ( ((p) > 0 || (f)->_size+(p) < 0) ? (char*)0 : \
+ (char*)((f)->_next = (f)->_data+(f)->_size+(p)) ) \
+ : (char*)0 \
+ )
+
+#define sfstrsize(f) ((f)->_size)
+#define sfstrtell(f) ((f)->_next - (f)->_data)
+#define sfstrpend(f) ((f)->_size - sfstrtell())
+#define sfstrbase(f) ((char*)(f)->_data)
+
+#define sfstruse(f) \
+ (sfputc((f),0) < 0 ? (char*)0 : (char*)((f)->_next = (f)->_data) \
+ )
+
+#define sfstrrsrv(f,n) \
+ (sfreserve((f),(n),SF_WRITE|SF_LOCKR), sfwrite((f),(f)->_next,0), \
+ ((f)->_next+(n) <= (f)->_data+(f)->_size ? (char*)(f)->_next : (char*)0) \
+ )
+
+#define sfstrbuf(f,b,n,m) \
+ (sfsetbuf((f),(b),(n)), ((f)->_flags |= (m) ? SF_MALLOC : 0), \
+ ((f)->_data == (unsigned char*)(b) ? 0 : -1) \
+ )
+
+#endif /* _SFSTR_H */
+
+#endif /* _SFIO_H */
diff --git a/usr/src/lib/libast/amd64/include/ast/sfio_s.h b/usr/src/lib/libast/amd64/include/ast/sfio_s.h
new file mode 100644
index 0000000000..27936a16b1
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/sfio_s.h
@@ -0,0 +1,51 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _SFIO_S_H
+#define _SFIO_S_H 1
+
+/*
+ * sfio file structure used by sfio and the stdio source compatibility library
+ */
+
+#if !defined(_SFHDR_H) && defined(_SFIO_H) && SFIO_VERSION < 20020214L
+#define _data data
+#define _endb endb
+#define _next next
+#endif
+
+struct _sfio_s
+{ unsigned char* _next; /* next position to read/write from */
+ unsigned char* _endw; /* end of write buffer */
+ unsigned char* _endr; /* end of read buffer */
+ unsigned char* _endb; /* end of buffer */
+ struct _sfio_s* _push; /* the stream that was pushed on */
+ unsigned short _flags; /* type of stream */
+ short _file; /* file descriptor */
+ unsigned char* _data; /* base of data buffer */
+ ssize_t _size; /* buffer size */
+ ssize_t _val; /* values or string lengths */
+#ifdef _SFIO_PRIVATE
+ _SFIO_PRIVATE
+#endif
+};
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/sfio_t.h b/usr/src/lib/libast/amd64/include/ast/sfio_t.h
new file mode 100644
index 0000000000..36be6ecc94
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/sfio_t.h
@@ -0,0 +1,126 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _SFIO_T_H
+#define _SFIO_T_H 1
+
+/* This header file is for library writers who need to know certain
+** internal info concerning the full Sfio_t structure. Including this
+** file means that you agree to track closely with sfio development
+** in case its internal architecture is changed.
+**
+** Written by Kiem-Phong Vo
+*/
+
+/* the parts of Sfio_t private to sfio functions */
+#define _SFIO_PRIVATE \
+ Sfoff_t extent; /* current file size */ \
+ Sfoff_t here; /* current physical location */ \
+ unsigned char getr; /* the last sfgetr separator */ \
+ unsigned char tiny[1];/* for unbuffered read stream */ \
+ unsigned short bits; /* private flags */ \
+ unsigned int mode; /* current io mode */ \
+ struct _sfdisc_s* disc; /* discipline */ \
+ struct _sfpool_s* pool; /* the pool containing this */ \
+ struct _sfrsrv_s* rsrv; /* reserved buffer */ \
+ struct _sfproc_s* proc; /* coprocess id, etc. */ \
+ Void_t* mutex; /* mutex for thread-safety */ \
+ Void_t* stdio; /* stdio FILE if any */ \
+ Sfoff_t lpos; /* last seek position */ \
+ size_t iosz; /* preferred size for I/O */ \
+ size_t blksz; /* preferred block size */ \
+ Void_t* fill[1];/* modest expansion */
+
+#include "sfio.h"
+
+/* mode bit to indicate that the structure hasn't been initialized */
+#define SF_INIT 0000004
+#define SF_DCDOWN 00010000
+
+/* short-hand for common stream types */
+#define SF_RDWR (SF_READ|SF_WRITE)
+#define SF_RDSTR (SF_READ|SF_STRING)
+#define SF_WRSTR (SF_WRITE|SF_STRING)
+#define SF_RDWRSTR (SF_RDWR|SF_STRING)
+
+/* for static initialization of an Sfio_t structure */
+#define SFNEW(data,size,file,type,disc,mutex) \
+ { (unsigned char*)(data), /* next */ \
+ (unsigned char*)(data), /* endw */ \
+ (unsigned char*)(data), /* endr */ \
+ (unsigned char*)(data), /* endb */ \
+ (Sfio_t*)0, /* push */ \
+ (unsigned short)((type)&SF_FLAGS), /* flags */ \
+ (short)(file), /* file */ \
+ (unsigned char*)(data), /* data */ \
+ (ssize_t)(size), /* size */ \
+ (ssize_t)(-1), /* val */ \
+ (Sfoff_t)0, /* extent */ \
+ (Sfoff_t)0, /* here */ \
+ 0, /* getr */ \
+ {0}, /* tiny */ \
+ 0, /* bits */ \
+ (unsigned int)(((type)&(SF_RDWR))|SF_INIT), /* mode */ \
+ (struct _sfdisc_s*)(disc), /* disc */ \
+ (struct _sfpool_s*)0, /* pool */ \
+ (struct _sfrsrv_s*)0, /* rsrv */ \
+ (struct _sfproc_s*)0, /* proc */ \
+ (mutex), /* mutex */ \
+ (Void_t*)0, /* stdio */ \
+ (Sfoff_t)0, /* lpos */ \
+ (size_t)0 /* iosz */ \
+ }
+
+/* function to clear an Sfio_t structure */
+#define SFCLEAR(f,mtx) \
+ ( (f)->next = (unsigned char*)0, /* next */ \
+ (f)->endw = (unsigned char*)0, /* endw */ \
+ (f)->endr = (unsigned char*)0, /* endr */ \
+ (f)->endb = (unsigned char*)0, /* endb */ \
+ (f)->push = (Sfio_t*)0, /* push */ \
+ (f)->flags = (unsigned short)0, /* flags */ \
+ (f)->file = -1, /* file */ \
+ (f)->data = (unsigned char*)0, /* data */ \
+ (f)->size = (ssize_t)(-1), /* size */ \
+ (f)->val = (ssize_t)(-1), /* val */ \
+ (f)->extent = (Sfoff_t)(-1), /* extent */ \
+ (f)->here = (Sfoff_t)0, /* here */ \
+ (f)->getr = 0, /* getr */ \
+ (f)->tiny[0] = 0, /* tiny */ \
+ (f)->bits = 0, /* bits */ \
+ (f)->mode = 0, /* mode */ \
+ (f)->disc = (struct _sfdisc_s*)0, /* disc */ \
+ (f)->pool = (struct _sfpool_s*)0, /* pool */ \
+ (f)->rsrv = (struct _sfrsrv_s*)0, /* rsrv */ \
+ (f)->proc = (struct _sfproc_s*)0, /* proc */ \
+ (f)->mutex = (mtx), /* mutex */ \
+ (f)->stdio = (Void_t*)0, /* stdio */ \
+ (f)->lpos = (Sfoff_t)0, /* lpos */ \
+ (f)->iosz = (size_t)0 /* iosz */ \
+ )
+
+/* expose next stream inside discipline function; state saved in int f */
+#define SFDCNEXT(sp,f) (((f)=(sp)->bits&SF_DCDOWN),(sp)->bits|=SF_DCDOWN)
+
+/* restore SFDCNEXT() state from int f */
+#define SFDCPREV(sp,f) ((f)?(0):((sp)->bits&=~SF_DCDOWN))
+
+#endif /* _SFIO_T_H */
diff --git a/usr/src/lib/libast/amd64/include/ast/sig.h b/usr/src/lib/libast/amd64/include/ast/sig.h
new file mode 100644
index 0000000000..c868352c39
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/sig.h
@@ -0,0 +1,152 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/sig.sh by iffe version 2007-04-04 : : */
+#ifndef _def_sig_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_sig_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define sig_info _sig_info_
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide kill killpg
+#else
+#define kill ______kill
+#define killpg ______killpg
+#endif
+#include <signal.h>
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide kill killpg
+#else
+#undef kill
+#undef killpg
+#endif
+#ifndef sigmask
+#define sigmask(s) (1<<((s)-1))
+#endif
+typedef void (*Sig_handler_t) __PROTO__((int));
+
+
+#define Handler_t Sig_handler_t
+
+#define SIG_REG_PENDING (-1)
+#define SIG_REG_POP 0
+#define SIG_REG_EXEC 00001
+#define SIG_REG_PROC 00002
+#define SIG_REG_TERM 00004
+#define SIG_REG_ALL 00777
+#define SIG_REG_SET 01000
+
+typedef struct
+{
+ char** name;
+ char** text;
+ int sigmax;
+} Sig_info_t;
+
+extern __MANGLE__ int kill __PROTO__((pid_t, int));
+extern __MANGLE__ int killpg __PROTO__((pid_t, int));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Sig_info_t sig_info;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int sigcritical __PROTO__((int));
+extern __MANGLE__ int sigunblock __PROTO__((int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/stack.h b/usr/src/lib/libast/amd64/include/ast/stack.h
new file mode 100644
index 0000000000..ad32ebb8ab
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/stack.h
@@ -0,0 +1,94 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * homogenous stack routine definitions
+ */
+
+#ifndef _STACK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _STACK_H
+
+typedef struct stacktable* STACK; /* stack pointer */
+typedef struct stackposition STACKPOS; /* stack position */
+
+struct stackblock /* stack block cell */
+{
+ __V_** stack; /* actual stack */
+ struct stackblock* prev; /* previous block in list */
+ struct stackblock* next; /* next block in list */
+};
+
+struct stackposition /* stack position */
+{
+ struct stackblock* block; /* current block pointer */
+ int index; /* index within current block */
+};
+
+struct stacktable /* stack information */
+{
+ struct stackblock* blocks; /* stack table blocks */
+ __V_* error; /* error return value */
+ int size; /* size of each block */
+ STACKPOS position; /* current stack position */
+};
+
+/*
+ * map old names to new
+ */
+
+#define mkstack stackalloc
+#define rmstack stackfree
+#define clrstack stackclear
+#define getstack stackget
+#define pushstack stackpush
+#define popstack stackpop
+#define posstack stacktell
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ STACK stackalloc __PROTO__((int, __V_*));
+extern __MANGLE__ void stackfree __PROTO__((STACK));
+extern __MANGLE__ void stackclear __PROTO__((STACK));
+extern __MANGLE__ __V_* stackget __PROTO__((STACK));
+extern __MANGLE__ int stackpush __PROTO__((STACK, __V_*));
+extern __MANGLE__ int stackpop __PROTO__((STACK));
+extern __MANGLE__ void stacktell __PROTO__((STACK, int, STACKPOS*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/stak.h b/usr/src/lib/libast/amd64/include/ast/stak.h
new file mode 100644
index 0000000000..e0e707b0e5
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/stak.h
@@ -0,0 +1,64 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * David Korn
+ * AT&T Research
+ *
+ * Interface definitions for a stack-like storage library
+ *
+ */
+
+#ifndef _STAK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _STAK_H
+
+#include <stk.h>
+
+#define Stak_t Sfio_t
+#define staksp stkstd
+#define STAK_SMALL STK_SMALL
+
+#define stakptr(n) stkptr(stkstd,n)
+#define staktell() stktell(stkstd)
+#define stakputc(c) sfputc(stkstd,(c))
+#define stakwrite(b,n) sfwrite(stkstd,(b),(n))
+#define stakputs(s) (sfputr(stkstd,(s),0),--stkstd->_next)
+#define stakseek(n) stkseek(stkstd,n)
+#define stakcreate(n) stkopen(n)
+#define stakinstall(s,f) stkinstall(s,f)
+#define stakdelete(s) stkclose(s)
+#define staklink(s) stklink(s)
+#define stakalloc(n) stkalloc(stkstd,n)
+#define stakcopy(s) stkcopy(stkstd,s)
+#define stakset(c,n) stkset(stkstd,c,n)
+#define stakfreeze(n) stkfreeze(stkstd,n)
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/stdio.h b/usr/src/lib/libast/amd64/include/ast/stdio.h
new file mode 100644
index 0000000000..7e137c5712
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/stdio.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_stdio.h>
diff --git a/usr/src/lib/libast/amd64/include/ast/stk.h b/usr/src/lib/libast/amd64/include/ast/stk.h
new file mode 100644
index 0000000000..24947d24f1
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/stk.h
@@ -0,0 +1,91 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * David Korn
+ * AT&T Research
+ *
+ * Interface definitions for a stack-like storage library
+ *
+ */
+
+#ifndef _STK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _STK_H
+
+#include <sfio.h>
+
+#define _Stk_data _Stak_data
+
+#define stkstd (&_Stk_data)
+
+#define Stk_t Sfio_t
+
+#define STK_SMALL 1 /* small stkopen stack */
+#define STK_NULL 2 /* return NULL on overflow */
+
+#define stkptr(sp,n) ((char*)((sp)->_data)+(n))
+#define stktop(sp) ((char*)(sp)->_next)
+#define stktell(sp) ((sp)->_next-(sp)->_data)
+#define stkseek(sp,n) ((n)==0?(char*)((sp)->_next=(sp)->_data):_stkseek(sp,n))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Sfio_t _Stk_data;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Stk_t* stkopen __PROTO__((int));
+extern __MANGLE__ Stk_t* stkinstall __PROTO__((Stk_t*, char*(*)(int)));
+extern __MANGLE__ int stkclose __PROTO__((Stk_t*));
+extern __MANGLE__ int stklink __PROTO__((Stk_t*));
+extern __MANGLE__ char* stkalloc __PROTO__((Stk_t*, unsigned));
+extern __MANGLE__ char* stkcopy __PROTO__((Stk_t*,const char*));
+extern __MANGLE__ char* stkset __PROTO__((Stk_t*, char*, unsigned));
+extern __MANGLE__ char* _stkseek __PROTO__((Stk_t*, unsigned));
+extern __MANGLE__ char* stkfreeze __PROTO__((Stk_t*, unsigned));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/swap.h b/usr/src/lib/libast/amd64/include/ast/swap.h
new file mode 100644
index 0000000000..d89248d12b
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/swap.h
@@ -0,0 +1,64 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * integral representation conversion support definitions
+ * supports sizeof(integral_type)<=sizeof(intmax_t)
+ */
+
+#ifndef _SWAP_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SWAP_H
+
+#include <ast_common.h>
+
+#define int_swap _ast_intswap
+
+#define SWAP_MAX 8
+
+#define SWAPOP(n) (((n)&int_swap)^(n))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ __V_* swapmem __PROTO__((int, const __V_*, __V_*, size_t));
+extern __MANGLE__ intmax_t swapget __PROTO__((int, const __V_*, int));
+extern __MANGLE__ __V_* swapput __PROTO__((int, __V_*, int, intmax_t));
+extern __MANGLE__ int swapop __PROTO__((const __V_*, const __V_*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/tar.h b/usr/src/lib/libast/amd64/include/ast/tar.h
new file mode 100644
index 0000000000..910b6e8612
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/tar.h
@@ -0,0 +1,127 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Standard Archive Format
+ * USTAR - Uniform Standard Tape ARchive
+ */
+
+#ifndef _TAR_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TAR_H
+
+#define TBLOCK 512
+#define NAMSIZ 100
+#define PFXSIZ 155
+
+#define TMODLEN 8
+#define TUIDLEN 8
+#define TGIDLEN 8
+#define TSIZLEN 12
+#define TMTMLEN 12
+#define TCKSLEN 8
+
+#define TMAGIC "ustar" /* ustar and a null */
+#define TMAGLEN 6
+#define TVERSION "00" /* 00 and no null */
+#define TVERSLEN 2
+#define TUNMLEN 32
+#define TGNMLEN 32
+#define TDEVLEN 8
+
+/*
+ * values used in typeflag field
+ */
+
+#define REGTYPE '0' /* regular file */
+#define AREGTYPE 0 /* alternate REGTYPE */
+#define LNKTYPE '1' /* hard link */
+#define SYMTYPE '2' /* soft link */
+#define CHRTYPE '3' /* character special */
+#define BLKTYPE '4' /* block special */
+#define DIRTYPE '5' /* directory */
+#define FIFOTYPE '6' /* FIFO special */
+#define CONTTYPE '7' /* reserved */
+#define SOKTYPE '8' /* socket */
+#define EXTTYPE 'x' /* extended header */
+#define GLBTYPE 'g' /* global extended header */
+#define LLNKTYPE 'K' /* long link path */
+#define LREGTYPE 'L' /* long file path */
+#define VERTYPE 'V' /* version */
+
+/*
+ * bits used in mode field
+ */
+
+#define TSUID 04000 /* set uid on exec */
+#define TSGID 02000 /* set gid on exec */
+#define TSVTX 01000 /* sticky bit -- reserved */
+
+/*
+ * file permissions
+ */
+
+#define TUREAD 00400 /* read by owner */
+#define TUWRITE 00200 /* write by owner */
+#define TUEXEC 00100 /* execute by owner */
+#define TGREAD 00040 /* read by group */
+#define TGWRITE 00020 /* execute by group */
+#define TGEXEC 00010 /* write by group */
+#define TOREAD 00004 /* read by other */
+#define TOWRITE 00002 /* write by other */
+#define TOEXEC 00001 /* execute by other */
+
+struct header
+{
+ char name[NAMSIZ];
+ char mode[TMODLEN];
+ char uid[TUIDLEN];
+ char gid[TGIDLEN];
+ char size[TSIZLEN];
+ char mtime[TMTMLEN];
+ char chksum[TCKSLEN];
+ char typeflag;
+ char linkname[NAMSIZ];
+ char magic[TMAGLEN];
+ char version[TVERSLEN];
+ char uname[TUNMLEN];
+ char gname[TGNMLEN];
+ char devmajor[TDEVLEN];
+ char devminor[TDEVLEN];
+ char prefix[PFXSIZ];
+};
+
+union hblock
+{
+ char dummy[TBLOCK];
+ struct header dbuf;
+};
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/times.h b/usr/src/lib/libast/amd64/include/ast/times.h
new file mode 100644
index 0000000000..25e81662be
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/times.h
@@ -0,0 +1,65 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * -last clock_t,time_t interface definitions plus
+ *
+ * <ast.h>
+ * <time.h>
+ * <sys/time.h>
+ * <sys/times.h>
+ */
+
+#ifndef _TIMES_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TIMES_H
+
+#include <ast.h>
+
+#undef _TIMES_H
+#include <ast_time.h>
+#ifndef _TIMES_H
+#define _TIMES_H
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int touch __PROTO__((const char*, time_t, time_t, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/tm.h b/usr/src/lib/libast/amd64/include/ast/tm.h
new file mode 100644
index 0000000000..f790a9a66e
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/tm.h
@@ -0,0 +1,205 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * time conversion support definitions
+ */
+
+#ifndef _TM_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TM_H
+
+#define TM_VERSION 20070319L
+
+#include <ast.h>
+#include <times.h>
+
+#undef daylight
+
+#define tmset(z) tminit(z)
+#define tmisleapyear(y) (!((y)%4)&&(((y)%100)||!((((y)<1900)?((y)+1900):(y))%400)))
+
+#define TM_ADJUST (1<<0) /* local doesn't do leap secs */
+#define TM_LEAP (1<<1) /* do leap seconds */
+#define TM_UTC (1<<2) /* universal coordinated ref */
+
+#define TM_PEDANTIC (1<<3) /* pedantic date parse */
+#define TM_DATESTYLE (1<<4) /* date(1) style mmddHHMMccyy */
+#define TM_SUBSECOND (1<<5) /* <something>%S => ...%S.%P */
+
+#define TM_DST (-60) /* default minutes for DST */
+#define TM_LOCALZONE (25 * 60) /* use local time zone offset */
+#define TM_UTCZONE (26 * 60) /* UTC "time zone" */
+#define TM_MAXLEAP 1 /* max leap secs per leap */
+#define TM_WINDOW 69 /* century windowing guard year */
+
+/*
+ * these indices must agree with tm_dform[]
+ */
+
+#define TM_MONTH_ABBREV 0
+#define TM_MONTH 12
+#define TM_DAY_ABBREV 24
+#define TM_DAY 31
+#define TM_TIME 38
+#define TM_DATE 39
+#define TM_DEFAULT 40
+#define TM_MERIDIAN 41
+
+#define TM_UT 43
+#define TM_DT 47
+#define TM_SUFFIXES 51
+#define TM_PARTS 55
+#define TM_HOURS 62
+#define TM_DAYS 66
+#define TM_LAST 69
+#define TM_THIS 72
+#define TM_NEXT 75
+#define TM_EXACT 78
+#define TM_NOISE 81
+#define TM_ORDINAL 85
+#define TM_DIGITS 95
+#define TM_CTIME 105
+#define TM_DATE_1 106
+#define TM_INTERNATIONAL 107
+#define TM_RECENT 108
+#define TM_DISTANT 109
+#define TM_MERIDIAN_TIME 110
+#define TM_ERA 111
+#define TM_ERA_DATE 112
+#define TM_ERA_TIME 113
+#define TM_ERA_DEFAULT 114
+#define TM_ERA_YEAR 115
+#define TM_ORDINALS 116
+#define TM_FINAL 126
+
+#define TM_NFORM 129
+
+typedef struct /* leap second info */
+{
+ time_t time; /* the leap second event */
+ int total; /* inclusive total since epoch */
+} Tm_leap_t;
+
+typedef struct /* time zone info */
+{
+ char* type; /* type name */
+ char* standard; /* standard time name */
+ char* daylight; /* daylight or summertime name */
+ short west; /* minutes west of GMT */
+ short dst; /* add to tz.west for DST */
+} Tm_zone_t;
+
+typedef struct /* tm library readonly data */
+{
+ char** format; /* default TM_* format strings */
+ char* lex; /* format lex type classes */
+ char* digit; /* output digits */
+ short* days; /* days in month i */
+ short* sum; /* days in months before i */
+ Tm_leap_t* leap; /* leap second table */
+ Tm_zone_t* zone; /* alternate timezone table */
+} Tm_data_t;
+
+typedef struct /* tm library global info */
+{
+ char* deformat; /* TM_DEFAULT override */
+ int flags; /* flags */
+ char** format; /* current format strings */
+ Tm_zone_t* date; /* timezone from last tmdate() */
+ Tm_zone_t* local; /* local timezone */
+ Tm_zone_t* zone; /* current timezone */
+} Tm_info_t;
+
+typedef struct Tm_s
+{
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+ uint32_t tm_nsec;
+ Tm_zone_t* tm_zone;
+} Tm_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Tm_data_t* _tm_datap_;
+extern __MANGLE__ Tm_info_t* _tm_infop_;
+
+#define tm_data (*_tm_datap_)
+#define tm_info (*_tm_infop_)
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ time_t tmdate __PROTO__((const char*, char**, time_t*));
+extern __MANGLE__ int tmequiv __PROTO__((Tm_t*));
+extern __MANGLE__ Tm_t* tmfix __PROTO__((Tm_t*));
+extern __MANGLE__ char* tmfmt __PROTO__((char*, size_t, const char*, time_t*));
+extern __MANGLE__ char* tmform __PROTO__((char*, const char*, time_t*));
+extern __MANGLE__ int tmgoff __PROTO__((const char*, char**, int));
+extern __MANGLE__ void tminit __PROTO__((Tm_zone_t*));
+extern __MANGLE__ time_t tmleap __PROTO__((time_t*));
+extern __MANGLE__ int tmlex __PROTO__((const char*, char**, char**, int, char**, int));
+extern __MANGLE__ char** tmlocale __PROTO__((void));
+extern __MANGLE__ Tm_t* tmmake __PROTO__((time_t*));
+extern __MANGLE__ char* tmpoff __PROTO__((char*, size_t, const char*, int, int));
+extern __MANGLE__ time_t tmscan __PROTO__((const char*, char**, const char*, char**, time_t*, long));
+extern __MANGLE__ int tmsleep __PROTO__((time_t, time_t));
+extern __MANGLE__ time_t tmtime __PROTO__((Tm_t*, int));
+extern __MANGLE__ Tm_zone_t* tmtype __PROTO__((const char*, char**));
+extern __MANGLE__ int tmweek __PROTO__((Tm_t*, int, int, int));
+extern __MANGLE__ int tmword __PROTO__((const char*, char**, const char*, char**, int));
+extern __MANGLE__ Tm_zone_t* tmzone __PROTO__((const char*, char**, const char*, int*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/tmx.h b/usr/src/lib/libast/amd64/include/ast/tmx.h
new file mode 100644
index 0000000000..239c2c69f8
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/tmx.h
@@ -0,0 +1,149 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/tmx by iffe version 2007-04-04 : : */
+
+#ifndef _TMX_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TMX_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Time_t support
+ */
+
+#include <tm.h>
+#include <tv.h>
+
+#define TMX_MAXDATE "2554-07-21+23:34:33.709551614 UTC"
+#define TMX_MAXYEAR 2554
+#define TMX_MAXSEC ((Time_t)18446744073)
+#define TMX_MAXNSEC 709551614
+#define TMX_RESOLUTION 1000000000
+
+typedef uint64_t Time_t;
+typedef uint64_t Tmxsec_t;
+typedef uint32_t Tmxnsec_t;
+
+#define tmxsec(t) ((Tmxsec_t)((t)/1000000000))
+#define tmxnsec(t) ((Tmxnsec_t)((t)%1000000000))
+#define tmxsns(s,n) (((((Time_t)(s))*1000000000))+((Time_t)(n)))
+
+#define TMX_NOTIME ((Time_t)(-1))
+#define TMX_NOW tmxgettime()
+#define TMX_MAXTIME tmxsns(TMX_MAXSEC,TMX_MAXNSEC)
+
+#define tmx2tv(t,v) ((v)->tv_nsec=tmxnsec(t),(v)->tv_sec=tmxsec(t))
+#define tv2tmx(v) tmxsns((v)->tv_sec,(v)->tv_nsec)
+
+#define tmxclock(p) tmxsns(((p)?*(p):time(NiL)),0)
+
+#define tmxgetatime(s) tmxsns((s)->st_atime,ST_ATIME_NSEC_GET(s))
+#define tmxgetctime(s) tmxsns((s)->st_ctime,ST_CTIME_NSEC_GET(s))
+#define tmxgetmtime(s) tmxsns((s)->st_mtime,ST_MTIME_NSEC_GET(s))
+
+#define tmxsetatime(s,t) ((s)->st_atime=tmxsec(t),ST_ATIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetctime(s,t) ((s)->st_ctime=tmxsec(t),ST_CTIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetmtime(s,t) ((s)->st_mtime=tmxsec(t),ST_MTIME_NSEC_SET(s,tmxnsec(t)))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Time_t tmxdate __PROTO__((const char*, char**, Time_t));
+extern __MANGLE__ char* tmxfmt __PROTO__((char*, size_t, const char*, Time_t));
+extern __MANGLE__ Time_t tmxleap __PROTO__((Time_t));
+extern __MANGLE__ Tm_t* tmxmake __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxscan __PROTO__((const char*, char**, const char*, char**, Time_t, long));
+extern __MANGLE__ int tmxsleep __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxtime __PROTO__((Tm_t*, int));
+
+extern __MANGLE__ Time_t tmxgettime __PROTO__((void));
+extern __MANGLE__ int tmxsettime __PROTO__((Time_t));
+
+extern __MANGLE__ int tmxtouch __PROTO__((const char*, Time_t, Time_t, Time_t, int));
+
+extern __MANGLE__ char* fmttmx __PROTO__((const char*, Time_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/tok.h b/usr/src/lib/libast/amd64/include/ast/tok.h
new file mode 100644
index 0000000000..3637489918
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/tok.h
@@ -0,0 +1,58 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * token stream interface definitions
+ */
+
+#ifndef _TOK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TOK_H
+
+#include <ast.h>
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Sfio_t* tokline __PROTO__((const char*, int, int*));
+extern __MANGLE__ int tokscan __PROTO__((char*, char**, const char*, ...));
+extern __MANGLE__ char* tokopen __PROTO__((char*, int));
+extern __MANGLE__ void tokclose __PROTO__((char*));
+extern __MANGLE__ char* tokread __PROTO__((char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/tv.h b/usr/src/lib/libast/amd64/include/ast/tv.h
new file mode 100644
index 0000000000..6e5dd9cb7c
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/tv.h
@@ -0,0 +1,132 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/tv by iffe version 2007-04-04 : : */
+
+#ifndef _TV_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TV_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Tv_t interface definitions
+ */
+
+#include <ast.h>
+
+#define TV_NSEC_IGNORE (1000000000L)
+#define TV_TOUCH_RETAIN ((Tv_t*)1)
+
+typedef struct Tv_s
+{
+ uint32_t tv_sec;
+ uint32_t tv_nsec;
+} Tv_t;
+
+#define ST_ATIME_NSEC_GET(st) ((st)->st_atim.tv_nsec)
+#define ST_CTIME_NSEC_GET(st) ((st)->st_ctim.tv_nsec)
+#define ST_MTIME_NSEC_GET(st) ((st)->st_mtim.tv_nsec)
+
+#define ST_ATIME_NSEC_SET(st,n) (ST_ATIME_NSEC_GET(st)=(n))
+#define ST_CTIME_NSEC_SET(st,n) (ST_CTIME_NSEC_GET(st)=(n))
+#define ST_MTIME_NSEC_SET(st,n) (ST_MTIME_NSEC_GET(st)=(n))
+
+#define tvgetatime(t,s) ((t)->tv_nsec=ST_ATIME_NSEC_GET(s),(t)->tv_sec=(s)->st_atime)
+#define tvgetmtime(t,s) ((t)->tv_nsec=ST_MTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_mtime)
+#define tvgetctime(t,s) ((t)->tv_nsec=ST_CTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_ctime)
+
+#define tvsetatime(t,s) (ST_ATIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_atime=(t)->tv_sec)
+#define tvsetmtime(t,s) (ST_MTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_mtime=(t)->tv_sec)
+#define tvsetctime(t,s) (ST_CTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_ctime=(t)->tv_sec)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int tvgettime __PROTO__((Tv_t*));
+extern __MANGLE__ int tvsettime __PROTO__((const Tv_t*));
+extern __MANGLE__ int tvcmp __PROTO__((const Tv_t*, const Tv_t*));
+extern __MANGLE__ int tvtouch __PROTO__((const char*, const Tv_t*, const Tv_t*, const Tv_t*, int));
+extern __MANGLE__ int tvsleep __PROTO__((const Tv_t*, Tv_t*));
+
+extern __MANGLE__ char* fmttv __PROTO__((const char*, Tv_t*));
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/usage.h b/usr/src/lib/libast/amd64/include/ast/usage.h
new file mode 100644
index 0000000000..81b59e1aca
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/usage.h
@@ -0,0 +1,37 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * error catalog and usage defaults
+ */
+
+#ifndef _USAGE_H
+#define _USAGE_H
+
+#ifndef ERROR_CATALOG
+#define ERROR_CATALOG 0
+#endif
+
+#ifndef USAGE_LICENSE
+#define USAGE_LICENSE "[-license?THIS IS AN UNLICENSED COPY]"
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/vdb.h b/usr/src/lib/libast/amd64/include/ast/vdb.h
new file mode 100644
index 0000000000..63e310c724
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/vdb.h
@@ -0,0 +1,55 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * virtual db file directory entry constants
+ */
+
+#ifndef VDB_MAGIC
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+
+#define VDB_MAGIC "vdb"
+
+#define VDB_DIRECTORY "DIRECTORY"
+#define VDB_UNION "UNION"
+#define VDB_DATE "DATE"
+#define VDB_MODE "MODE"
+
+#define VDB_DELIMITER ';'
+#define VDB_IGNORE '_'
+#define VDB_FIXED 10
+#define VDB_LENGTH ((int)sizeof(VDB_DIRECTORY)+2*(VDB_FIXED+1))
+#define VDB_OFFSET ((int)sizeof(VDB_DIRECTORY))
+#define VDB_SIZE (VDB_OFFSET+VDB_FIXED+1)
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/vecargs.h b/usr/src/lib/libast/amd64/include/ast/vecargs.h
new file mode 100644
index 0000000000..4d329cd154
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/vecargs.h
@@ -0,0 +1,56 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * vector argument interface definitions
+ */
+
+#ifndef _VECARGS_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _VECARGS_H
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int vecargs __PROTO__((char**, int*, char***));
+extern __MANGLE__ char** vecfile __PROTO__((const char*));
+extern __MANGLE__ void vecfree __PROTO__((char**, int));
+extern __MANGLE__ char** vecload __PROTO__((char*));
+extern __MANGLE__ char** vecstring __PROTO__((const char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/vmalloc.h b/usr/src/lib/libast/amd64/include/ast/vmalloc.h
new file mode 100644
index 0000000000..f0a8114c6a
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/vmalloc.h
@@ -0,0 +1,315 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _VMALLOC_H
+#define _VMALLOC_H 1
+
+/* Public header file for the virtual malloc package.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+
+#define VMALLOC_VERSION 20050928L
+
+#if _PACKAGE_ast
+#include <ast_std.h>
+#else
+#include <ast_common.h>
+#endif
+
+typedef struct _vmalloc_s Vmalloc_t;
+typedef struct _vmstat_s Vmstat_t;
+typedef struct _vmdisc_s Vmdisc_t;
+typedef struct _vmethod_s Vmethod_t;
+typedef Void_t* (*Vmemory_f)_ARG_((Vmalloc_t*, Void_t*, size_t, size_t, Vmdisc_t*));
+typedef int (*Vmexcept_f)_ARG_((Vmalloc_t*, int, Void_t*, Vmdisc_t*));
+
+struct _vmstat_s
+{ int n_busy; /* number of busy blocks */
+ int n_free; /* number of free blocks */
+ size_t s_busy; /* total amount of busy space */
+ size_t s_free; /* total amount of free space */
+ size_t m_busy; /* largest busy piece */
+ size_t m_free; /* largest free piece */
+ int n_seg; /* number of segments */
+ size_t extent; /* total size of region */
+};
+
+struct _vmdisc_s
+{ Vmemory_f memoryf; /* memory manipulator */
+ Vmexcept_f exceptf; /* exception handler */
+ size_t round; /* rounding requirement */
+};
+
+struct _vmethod_s
+{ Void_t* (*allocf)_ARG_((Vmalloc_t*,size_t));
+ Void_t* (*resizef)_ARG_((Vmalloc_t*,Void_t*,size_t,int));
+ int (*freef)_ARG_((Vmalloc_t*,Void_t*));
+ long (*addrf)_ARG_((Vmalloc_t*,Void_t*));
+ long (*sizef)_ARG_((Vmalloc_t*,Void_t*));
+ int (*compactf)_ARG_((Vmalloc_t*));
+ Void_t* (*alignf)_ARG_((Vmalloc_t*,size_t,size_t));
+ unsigned short meth;
+};
+
+struct _vmalloc_s
+{ Vmethod_t meth; /* method for allocation */
+ char* file; /* file name */
+ int line; /* line number */
+ Void_t* func; /* calling function */
+#ifdef _VM_PRIVATE_
+ _VM_PRIVATE_
+#endif
+};
+
+#undef VM_FLAGS /* solaris sys kernel clash */
+
+#define VM_TRUST 0000001 /* forgo some security checks */
+#define VM_TRACE 0000002 /* generate trace */
+#define VM_DBCHECK 0000004 /* check for boundary overwrite */
+#define VM_DBABORT 0000010 /* abort on any warning */
+#define VM_FLAGS 0000017 /* user-settable flags */
+
+#define VM_MTBEST 0000100 /* Vmbest method */
+#define VM_MTPOOL 0000200 /* Vmpool method */
+#define VM_MTLAST 0000400 /* Vmlast method */
+#define VM_MTDEBUG 0001000 /* Vmdebug method */
+#define VM_MTPROFILE 0002000 /* Vmdebug method */
+#define VM_METHODS 0003700 /* available allocation methods */
+
+#define VM_RSCOPY 0000001 /* copy old contents */
+#define VM_RSMOVE 0000002 /* old contents is moveable */
+#define VM_RSZERO 0000004 /* clear new space */
+
+/* exception types */
+#define VM_OPEN 0 /* region being opened */
+#define VM_CLOSE 1 /* announce being closed */
+#define VM_NOMEM 2 /* can't obtain memory */
+#define VM_BADADDR 3 /* bad addr in vmfree/vmresize */
+#define VM_DISC 4 /* discipline being changed */
+#define VM_ALLOC 5 /* announcement from vmalloc() */
+#define VM_FREE 6 /* announcement from vmfree() */
+#define VM_RESIZE 7 /* announcement from vmresize() */
+
+_BEGIN_EXTERNS_ /* public data */
+#if _BLD_vmalloc && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+#if !_BLD_vmalloc && defined(__IMPORT__)
+#define extern extern __IMPORT__
+#endif
+
+extern Vmethod_t* Vmbest; /* best allocation */
+extern Vmethod_t* Vmlast; /* last-block allocation */
+extern Vmethod_t* Vmpool; /* pool allocation */
+extern Vmethod_t* Vmdebug; /* allocation with debugging */
+extern Vmethod_t* Vmprofile; /* profiling memory usage */
+
+extern Vmdisc_t* Vmdcheap; /* heap discipline */
+extern Vmdisc_t* Vmdcsbrk; /* sbrk discipline */
+
+extern Vmalloc_t* Vmheap; /* heap region */
+extern Vmalloc_t* Vmregion; /* malloc region */
+
+#undef extern
+_END_EXTERNS_
+
+_BEGIN_EXTERNS_ /* public functions */
+#if _BLD_vmalloc && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Vmalloc_t* vmopen _ARG_(( Vmdisc_t*, Vmethod_t*, int ));
+extern int vmclose _ARG_(( Vmalloc_t* ));
+extern int vmclear _ARG_(( Vmalloc_t* ));
+extern int vmcompact _ARG_(( Vmalloc_t* ));
+
+extern Vmdisc_t* vmdisc _ARG_(( Vmalloc_t*, Vmdisc_t* ));
+
+extern Vmalloc_t* vmmopen _ARG_(( char*, Void_t*, size_t ));
+extern Void_t* vmmset _ARG_((Vmalloc_t*, int, Void_t*, int));
+
+extern Void_t* vmalloc _ARG_(( Vmalloc_t*, size_t ));
+extern Void_t* vmalign _ARG_(( Vmalloc_t*, size_t, size_t ));
+extern Void_t* vmresize _ARG_(( Vmalloc_t*, Void_t*, size_t, int ));
+extern Void_t* vmgetmem _ARG_(( Vmalloc_t*, Void_t*, size_t ));
+extern int vmfree _ARG_(( Vmalloc_t*, Void_t* ));
+
+extern long vmaddr _ARG_(( Vmalloc_t*, Void_t* ));
+extern long vmsize _ARG_(( Vmalloc_t*, Void_t* ));
+
+extern Vmalloc_t* vmregion _ARG_(( Void_t* ));
+extern Void_t* vmsegment _ARG_(( Vmalloc_t*, Void_t* ));
+extern int vmset _ARG_(( Vmalloc_t*, int, int ));
+
+extern Void_t* vmdbwatch _ARG_(( Void_t* ));
+extern int vmdbcheck _ARG_(( Vmalloc_t* ));
+extern int vmdebug _ARG_(( int ));
+
+extern int vmprofile _ARG_(( Vmalloc_t*, int ));
+
+extern int vmtrace _ARG_(( int ));
+extern int vmtrbusy _ARG_((Vmalloc_t*));
+
+extern int vmstat _ARG_((Vmalloc_t*, Vmstat_t*));
+
+extern int vmwalk _ARG_((Vmalloc_t*,
+ int(*)(Vmalloc_t*,Void_t*,size_t,Vmdisc_t*)));
+extern char* vmstrdup _ARG_((Vmalloc_t*, const char*));
+
+#if !defined(_BLD_vmalloc) && !defined(_AST_STD_H) && \
+ !defined(__stdlib_h) && !defined(__STDLIB_H) && \
+ !defined(_STDLIB_INCLUDED) && !defined(_INC_STDLIB)
+extern Void_t* malloc _ARG_(( size_t ));
+extern Void_t* realloc _ARG_(( Void_t*, size_t ));
+extern void free _ARG_(( Void_t* ));
+extern void cfree _ARG_(( Void_t* ));
+extern Void_t* calloc _ARG_(( size_t, size_t ));
+extern Void_t* memalign _ARG_(( size_t, size_t ));
+extern Void_t* valloc _ARG_(( size_t ));
+#endif
+
+#undef extern
+_END_EXTERNS_
+
+/* to coerce any value to a Vmalloc_t*, make ANSI happy */
+#define _VM_(vm) ((Vmalloc_t*)(vm))
+
+/* enable recording of where a call originates from */
+#ifdef VMFL
+
+#if defined(__FILE__)
+#define _VMFILE_(vm) (_VM_(vm)->file = (char*)__FILE__)
+#else
+#define _VMFILE_(vm) (_VM_(vm)->file = 0)
+#endif
+
+#if defined(__LINE__)
+#define _VMLINE_(vm) (_VM_(vm)->line = __LINE__)
+#else
+#define _VMLINE_(vm) (_VM_(vm)->line = 0)
+#endif
+
+#if defined(__FUNCTION__)
+#define _VMFUNC_(vm) (_VM_(vm)->func = (Void_t*)__FUNCTION__)
+#else
+#define _VMFUNC_(vm) (_VM_(vm)->func = 0)
+#endif
+
+#define _VMFL_(vm) (_VMFILE_(vm), _VMLINE_(vm), _VMFUNC_(vm))
+
+#define vmalloc(vm,sz) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.allocf))((vm),(sz)) )
+#define vmresize(vm,d,sz,type) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.resizef))\
+ ((vm),(Void_t*)(d),(sz),(type)) )
+#define vmfree(vm,d) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.freef))((vm),(Void_t*)(d)) )
+#define vmalign(vm,sz,align) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.alignf))((vm),(sz),(align)) )
+
+#undef malloc
+#undef realloc
+#undef calloc
+#undef free
+#undef memalign
+#undef valloc
+
+#if _map_malloc
+
+#define malloc(s) (_VMFL_(Vmregion), _ast_malloc((size_t)(s)) )
+#define realloc(d,s) (_VMFL_(Vmregion), _ast_realloc((Void_t*)(d),(size_t)(s)) )
+#define calloc(n,s) (_VMFL_(Vmregion), _ast_calloc((size_t)n, (size_t)(s)) )
+#define free(d) (_VMFL_(Vmregion), _ast_free((Void_t*)(d)) )
+#define memalign(a,s) (_VMFL_(Vmregion), _ast_memalign((size_t)(a),(size_t)(s)) )
+#define valloc(s) (_VMFL_(Vmregion), _ast_valloc((size_t)(s) )
+
+#else
+
+#if !_std_malloc
+
+#if __STD_C || defined(__STDPP__) || defined(__GNUC__)
+#define malloc(s) ( _VMFL_(Vmregion), (malloc)((size_t)(s)) )
+#define realloc(d,s) ( _VMFL_(Vmregion), (realloc)((Void_t*)(d),(size_t)(s)) )
+#define calloc(n,s) ( _VMFL_(Vmregion), (calloc)((size_t)n, (size_t)(s)) )
+#define free(d) ( _VMFL_(Vmregion), (free)((Void_t*)(d)) )
+#define memalign(a,s) ( _VMFL_(Vmregion), (memalign)((size_t)(a),(size_t)(s)) )
+#define valloc(s) ( _VMFL_(Vmregion), (valloc)((size_t)(s)) )
+#ifndef strdup
+#define strdup(s) ( _VMFL_(Vmregion), (strdup)((char*)(s)) )
+#endif
+
+#else
+
+#define _VMNM_(a,b,c,d,e,f) a/**/b/**/c/**/d/**/e/**/f
+#define malloc(s) ( _VMFL_(Vmregion), _VMNM_(mallo,/,*,*,/,c)\
+ ( (size_t)(s)) )
+#define realloc(d,s) ( _VMFL_(Vmregion), _VMNM_(reallo,/,*,*,/,c)\
+ ( (Void_t*)(d),(size_t)(s)) )
+#define calloc(n,s) ( _VMFL_(Vmregion), _VMNM_(callo,/,*,*,/,c)\
+ ( (size_t)n, (size_t)(s)) )
+#define free(d) ( _VMFL_(Vmregion), _VMNM_(fre,/,*,*,/,e)((Void_t*)(d)) )
+#define memalign(a,s) ( _VMFL_(Vmregion), _VMNM_(memalig,/,*,*,/,n)\
+ ( (size_t)(a),(size_t)(s)) )
+#define valloc(s) ( _VMFL_(Vmregion), _VMNM_(vallo,/,*,*,/,c)\
+ ( (size_t)(s)) )
+#ifndef strdup
+#define strdup(s) ( _VMFL_(Vmregion), _VMNM_(strdu,/,*,*,/,p)\
+ ((char*)(s)) )
+#endif
+
+#endif /*__STD_C || defined(__STDPP__) || defined(__GNUC__)*/
+
+#define cfree(d) free(d)
+
+#endif /* !_std_malloc */
+
+#endif /* _map_malloc */
+
+#endif /*VMFL*/
+
+/* non-debugging/profiling allocation calls */
+#ifndef vmalloc
+#define vmalloc(vm,sz) (*(_VM_(vm)->meth.allocf))((vm),(sz))
+#endif
+
+#ifndef vmresize
+#define vmresize(vm,d,sz,type) (*(_VM_(vm)->meth.resizef))\
+ ((vm),(Void_t*)(d),(sz),(type))
+#endif
+
+#ifndef vmfree
+#define vmfree(vm,d) (*(_VM_(vm)->meth.freef))((vm),(Void_t*)(d))
+#endif
+
+#ifndef vmalign
+#define vmalign(vm,sz,align) (*(_VM_(vm)->meth.alignf))((vm),(sz),(align))
+#endif
+
+#define vmaddr(vm,addr) (*(_VM_(vm)->meth.addrf))((vm),(Void_t*)(addr))
+#define vmsize(vm,addr) (*(_VM_(vm)->meth.sizef))((vm),(Void_t*)(addr))
+#define vmcompact(vm) (*(_VM_(vm)->meth.compactf))((vm))
+#define vmoldof(v,p,t,n,x) (t*)vmresize((v), (p), sizeof(t)*(n)+(x), \
+ (VM_RSMOVE) )
+#define vmnewof(v,p,t,n,x) (t*)vmresize((v), (p), sizeof(t)*(n)+(x), \
+ (VM_RSMOVE|VM_RSCOPY|VM_RSZERO) )
+
+#endif /* _VMALLOC_H */
diff --git a/usr/src/lib/libast/amd64/include/ast/wait.h b/usr/src/lib/libast/amd64/include/ast/wait.h
new file mode 100644
index 0000000000..6910081961
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/wait.h
@@ -0,0 +1,107 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * ast POSIX wait/exit support
+ */
+
+#ifndef _WAIT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _WAIT_H
+
+#include <ast.h>
+#include <ast_wait.h>
+
+#if _sys_wait
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide wait waitpid
+#else
+#define wait ______wait
+#define waitpid ______waitpid
+#endif
+#include <sys/wait.h>
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide wait waitpid
+#else
+#undef wait
+#undef waitpid
+#endif
+#endif
+
+#ifndef WNOHANG
+#define WNOHANG 1
+#endif
+
+#ifndef WUNTRACED
+#define WUNTRACED 2
+#endif
+
+#if !_ok_wif
+#undef WIFEXITED
+#undef WEXITSTATUS
+#undef WIFSIGNALED
+#undef WTERMSIG
+#undef WIFSTOPPED
+#undef WSTOPSIG
+#undef WTERMCORE
+#endif
+
+#ifndef WIFEXITED
+#define WIFEXITED(x) (!((x)&((1<<(EXIT_BITS-1))-1)))
+#endif
+
+#ifndef WEXITSTATUS
+#define WEXITSTATUS(x) (((x)>>EXIT_BITS)&((1<<EXIT_BITS)-1))
+#endif
+
+#ifndef WIFSIGNALED
+#define WIFSIGNALED(x) (((x)&((1<<(EXIT_BITS-1))-1))!=0)
+#endif
+
+#ifndef WTERMSIG
+#define WTERMSIG(x) ((x)&((1<<(EXIT_BITS-1))-1))
+#endif
+
+#ifndef WIFSTOPPED
+#define WIFSTOPPED(x) (((x)&((1<<EXIT_BITS)-1))==((1<<(EXIT_BITS-1))-1))
+#endif
+
+#ifndef WSTOPSIG
+#define WSTOPSIG(x) WEXITSTATUS(x)
+#endif
+
+#ifndef WTERMCORE
+#define WTERMCORE(x) ((x)&(1<<(EXIT_BITS-1)))
+#endif
+
+extern __MANGLE__ pid_t wait __PROTO__((int*));
+extern __MANGLE__ pid_t waitpid __PROTO__((pid_t, int*, int));
+
+#endif
diff --git a/usr/src/lib/libast/amd64/include/ast/wchar.h b/usr/src/lib/libast/amd64/include/ast/wchar.h
new file mode 100644
index 0000000000..557a403adc
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/wchar.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_wchar.h>
diff --git a/usr/src/lib/libast/amd64/include/ast/wordexp.h b/usr/src/lib/libast/amd64/include/ast/wordexp.h
new file mode 100644
index 0000000000..b2e80d9f35
--- /dev/null
+++ b/usr/src/lib/libast/amd64/include/ast/wordexp.h
@@ -0,0 +1,74 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * posix wordexp interface definitions
+ */
+
+#ifndef _WORDEXP_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _WORDEXP_H
+
+#include <ast_common.h>
+
+#define WRDE_APPEND 01
+#define WRDE_DOOFFS 02
+#define WRDE_NOCMD 04
+#define WRDE_NOSYS 0100
+#define WRDE_REUSE 010
+#define WRDE_SHOWERR 020
+#define WRDE_UNDEF 040
+
+#define WRDE_BADCHAR 1
+#define WRDE_BADVAL 2
+#define WRDE_CMDSUB 3
+#define WRDE_NOSPACE 4
+#define WRDE_SYNTAX 5
+#define WRDE_NOSHELL 6
+
+typedef struct _wdarg
+{
+ size_t we_wordc;
+ char **we_wordv;
+ size_t we_offs;
+} wordexp_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int wordexp __PROTO__((const char*, wordexp_t*, int));
+extern __MANGLE__ int wordfree __PROTO__((wordexp_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif /* _WORDEXP_H */
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/align b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/align
new file mode 100644
index 0000000000..2172421a7d
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/align
@@ -0,0 +1,33 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/align.c by iffe version 2007-04-04 : : */
+#ifndef _def_align_ast
+#define _def_align_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+typedef unsigned long ALIGN_INTEGRAL;
+
+#define ALIGN_CHUNK 8192
+#define ALIGN_INTEGRAL long
+#define ALIGN_INTEGER(x) ((ALIGN_INTEGRAL)(x))
+#define ALIGN_POINTER(x) ((char*)(x))
+#define ALIGN_ROUND(x,y) ALIGN_POINTER(ALIGN_INTEGER((x)+(y)-1)&~((y)-1))
+
+#define ALIGN_BOUND ALIGN_BOUND2
+#define ALIGN_ALIGN(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC(x) ALIGN_TRUNC2(x)
+
+#define ALIGN_BIT1 0x1
+#define ALIGN_BOUND1 ALIGN_BOUND2
+#define ALIGN_ALIGN1(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC1(x) ALIGN_TRUNC2(x)
+#define ALIGN_CLRBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffffe)
+#define ALIGN_SETBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x1)
+#define ALIGN_TSTBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x1)
+
+#define ALIGN_BIT2 0x2
+#define ALIGN_BOUND2 16
+#define ALIGN_ALIGN2(x) ALIGN_TRUNC2((x)+15)
+#define ALIGN_TRUNC2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffff0)
+#define ALIGN_CLRBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffffd)
+#define ALIGN_SETBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x2)
+#define ALIGN_TSTBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x2)
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/botch b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/botch
new file mode 100644
index 0000000000..d70906e8be
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/botch
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/botch.c by iffe version 2007-04-04 : : */
+#ifndef _def_botch_ast
+#define _def_botch_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/ccode b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/ccode
new file mode 100644
index 0000000000..0939e42778
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/ccode
@@ -0,0 +1,29 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/ccode by iffe version 2007-04-04 : : */
+#ifndef _def_ccode_ast
+#define _def_ccode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define CC_ASCII 1 /* ISO-8859-1 */
+#define CC_EBCDIC_E 2 /* Xopen dd(1) EBCDIC */
+#define CC_EBCDIC_I 3 /* Xopen dd(1) IBM */
+#define CC_EBCDIC_O 4 /* IBM-1047 mvs OpenEdition */
+#define CC_EBCDIC_S 5 /* Siemens posix-bc */
+#define CC_EBCDIC_H 6 /* IBM-37 AS/400 */
+#define CC_EBCDIC_M 7 /* IBM mvs cobol */
+#define CC_EBCDIC_U 8 /* microfocus cobol */
+
+#define CC_MAPS 8 /* number of code maps */
+
+#define CC_EBCDIC CC_EBCDIC_E
+#define CC_EBCDIC1 CC_EBCDIC_E
+#define CC_EBCDIC2 CC_EBCDIC_I
+#define CC_EBCDIC3 CC_EBCDIC_O
+
+#define CC_NATIVE CC_ASCII /* native character code */
+#define CC_ALIEN CC_EBCDIC /* alien character code */
+
+#define CC_bel 0007 /* bel character */
+#define CC_esc 0033 /* esc character */
+#define CC_sub 0032 /* sub character */
+#define CC_vt 0013 /* vt character */
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/common b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/common
new file mode 100644
index 0000000000..5bb0460efd
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/common
@@ -0,0 +1,200 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/common by iffe version 2007-04-04 : : */
+#ifndef _AST_COMMON_H
+#define _AST_COMMON_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_pthread 1 /* #include <pthread.h> ok */
+#define _hdr_stdarg 1 /* #include <stdarg.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdint 1 /* #include <stdint.h> ok */
+#define _hdr_inttypes 1 /* #include <inttypes.h> ok */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_long_double 1 /* long double is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _std_proto 1 /* standard C prototypes ok */
+#define _ptr_void 1 /* standard C void* ok */
+/* disable non-standard linux/gnu inlines */
+#ifdef __GNUC__
+# undef __OPTIMIZE_SIZE__
+# define __OPTIMIZE_SIZE__ 1
+#endif
+
+/* __STD_C indicates that the language is ANSI-C or C++ */
+#if !defined(__STD_C) && __STDC__
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && (__cplusplus || c_plusplus)
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && _std_proto
+# define __STD_C 1
+#endif
+#if !defined(__STD_C)
+# define __STD_C 0
+#endif
+
+/* extern symbols must be protected against C++ name mangling */
+#ifndef _BEGIN_EXTERNS_
+# if __cplusplus || c_plusplus
+# define _BEGIN_EXTERNS_ extern "C" {
+# define _END_EXTERNS_ }
+# else
+# define _BEGIN_EXTERNS_
+# define _END_EXTERNS_
+# endif
+#endif
+
+/* _ARG_ simplifies function prototyping among flavors of C */
+#ifndef _ARG_
+# if __STD_C
+# define _ARG_(x) x
+# else
+# define _ARG_(x) ()
+# endif
+#endif
+
+/* _NIL_ simplifies defining nil pointers to a given type */
+#ifndef _NIL_
+# define _NIL_(x) ((x)0)
+#endif
+
+/* __INLINE__ is the inline keyword */
+#if !defined(__INLINE__) && defined(__cplusplus)
+# define __INLINE__ inline
+#endif
+#if !defined(__INLINE__) && defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+#endif
+
+/* Void_t is defined so that Void_t* can address any type */
+#ifndef Void_t
+# if __STD_C
+# define Void_t void
+# else
+# define Void_t char
+# endif
+#endif
+
+/* windows variants and veneers */
+#if !defined(_WINIX) && (_UWIN || __CYGWIN__ || __EMX__)
+# define _WINIX 1
+#endif
+
+/* dynamic linked library external scope handling */
+#ifdef __DYNAMIC__
+# undef __DYNAMIC__
+# ifndef _DLL
+# define _DLL 1
+# endif
+#endif
+#if _dll_import
+# if _BLD_STATIC && !_BLD_DLL
+# undef _DLL
+# else
+# if !_UWIN && !defined(_DLL)
+# define _DLL 1
+# endif
+# endif
+# if !defined(__EXPORT__) && _BLD_DLL
+# define __EXPORT__ __declspec(dllexport)
+# endif
+# if !defined(__IMPORT__) && ( _BLD_DLL || defined(_DLL) )
+# define __IMPORT__ __declspec(dllimport)
+# endif
+# if _BLD_DLL && _UWIN
+# define __DYNAMIC__(v) (_ast_getdll()->_ast_ ## v)
+# endif
+#endif
+#if !defined(_astimport)
+# if defined(__IMPORT__) && defined(_DLL)
+# define _astimport __IMPORT__
+# else
+# define _astimport extern
+# endif
+#endif
+#if _dll_import && ( !_BLD_DLL || _WINIX && !_UWIN )
+# ifdef __STDC__
+# define __EXTERN__(T,obj) extern T obj; T* _imp__ ## obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__ ## obj = &obj
+# else
+# define __EXTERN__(T,obj) extern T obj; T* _imp__/**/obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__/**/obj = &obj
+# endif
+#else
+# define __EXTERN__(T,obj) extern T obj
+# define __DEFINE__(T,obj,val) T obj = val
+#endif
+
+#define _ast_LL 1 /* LL numeric suffix supported */
+#define _ast_int1_t char
+#define _ast_int2_t short
+#define _ast_int4_t int
+#define _ast_int8_t long
+#define _ast_intmax_t _ast_int8_t
+#define _ast_intmax_long 1
+#define _ast_intswap 7
+
+#define _ast_flt4_t float
+#define _ast_flt8_t double
+#define _ast_flt16_t long double
+#define _ast_fltmax_t _ast_flt16_t
+#define _typ_int8_t 1 /* int8_t is a type */
+#define _typ_uint8_t 1 /* uint8_t is a type */
+#define _typ_int16_t 1 /* int16_t is a type */
+#define _typ_uint16_t 1 /* uint16_t is a type */
+#define _typ_int32_t 1 /* int32_t is a type */
+#define _typ_uint32_t 1 /* uint32_t is a type */
+#define _typ_int64_t 1 /* int64_t is a type */
+#define _typ_uint64_t 1 /* uint64_t is a type */
+#define _typ_intmax_t 1 /* intmax_t is a type */
+#define _typ_uintmax_t 1 /* uintmax_t is a type */
+
+#ifndef va_listref
+#define va_listref(p) (&(p)) /* pass va_list to varargs function */
+#define va_listval(p) (*(p)) /* retrieve va_list from va_arg(ap,va_listarg) */
+#define va_listarg va_list* /* va_arg() va_list type */
+#ifndef va_start
+#if __STD_C
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+#endif
+#ifndef _AST_STD_H
+# if __STD_C && _hdr_stddef
+# include <stddef.h>
+# endif
+# if _sys_types
+# include <sys/types.h>
+# endif
+# if _hdr_stdint
+# include <stdint.h>
+# else
+# if _hdr_inttypes
+# include <inttypes.h>
+# endif
+# endif
+#endif
+#if !_typ_size_t
+# define _typ_size_t 1
+ typedef int size_t;
+#endif
+#if !_typ_ssize_t
+# define _typ_ssize_t 1
+ typedef int ssize_t;
+#endif
+#ifndef _AST_STD_H
+# define _def_map_ast 1
+# if !_def_map_ast
+# include <ast_map.h>
+# endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/dirent b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/dirent
new file mode 100644
index 0000000000..e6f040cfb6
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/dirent
@@ -0,0 +1,82 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/dirent by iffe version 2007-04-04 : : */
+
+#ifndef _def_dirent_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dirent_ast 1
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _nxt_dirent <../include/dirent.h> /* include path for the native <dirent.h> */
+#define _nxt_dirent_str "../include/dirent.h" /* include string for the native <dirent.h> */
+/*
+ * <dirent.h> for systems with ok <dirent.h>
+ */
+
+#ifndef _DIRENT_H
+
+#include <../include/dirent.h> /* the native <dirent.h> */
+
+#ifndef _DIRENT_H
+#define _DIRENT_H
+#endif
+
+#endif
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/eaccess b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/eaccess
new file mode 100644
index 0000000000..ffce8235f1
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/eaccess
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/eaccess by iffe version 2007-04-04 : : */
+#ifndef _def_eaccess_ast
+#define _def_eaccess_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/errno b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/errno
new file mode 100644
index 0000000000..714835a4ee
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/errno
@@ -0,0 +1,7 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/errno by iffe version 2007-04-04 : : */
+#ifndef _def_errno_ast
+#define _def_errno_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _dat_sys_nerr 1 /* sys_nerr in default libs */
+#define _dat_sys_errlist 1 /* sys_errlist in default libs */
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/fcntl b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/fcntl
new file mode 100644
index 0000000000..f59e2cdbd1
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/fcntl
@@ -0,0 +1,114 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/fcntl.c by iffe version 2007-04-04 : : */
+#ifndef _def_fcntl_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fcntl_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <ast_fs.h>
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#define O_BINARY 0
+#define O_TEMPORARY 0
+#define O_TEXT 0
+
+#include <ast_fs.h>
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_fstat64
+#define fstat fstat64
+#endif
+#if _lib_lstat64
+#define lstat lstat64
+#endif
+#if _lib_stat64
+#define stat stat64
+#endif
+#if _lib_creat64
+#define creat creat64
+#endif
+#if _lib_mmap64
+#define mmap mmap64
+#endif
+#if _lib_open64
+#undef open
+#define open open64
+#endif
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/float b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/float
new file mode 100644
index 0000000000..40d069f246
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/float
@@ -0,0 +1,212 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/float by iffe version 2007-04-04 : : */
+
+#ifndef _def_float_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_float_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_float 1 /* #include <float.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _hdr_values 1 /* #include <values.h> ok */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_frexp 1 /* frexp() in default lib(s) */
+#define _lib_frexpl 1 /* frexpl() in default lib(s) */
+#define _lib_ldexp 1 /* ldexp() in default lib(s) */
+#define _lib_ldexpl 1 /* ldexpl() in default lib(s) */
+#define _lib_finite 1 /* finite() in default lib(s) */
+#define _lib_isnan 1 /* isnan() in default lib(s) */
+#define _lib_isnanl 1 /* isnanl() in default lib(s) */
+#define _lib_copysign 1 /* copysign() in default lib(s) */
+#define _lib_copysignl 1 /* copysignl() in default lib(s) */
+#include <ast_common.h>
+#include <float.h>
+#include <math.h>
+#ifndef FLT_DIG
+#define FLT_DIG 6
+#endif
+#ifndef FLT_MAX
+#define FLT_MAX 3.4028234663852885981170E+38F
+#endif
+#ifndef FLT_MAX_10_EXP
+#define FLT_MAX_10_EXP ( + 38 )
+#endif
+#ifndef FLT_MAX_EXP
+#define FLT_MAX_EXP ( + 128 )
+#endif
+#ifndef FLT_MIN
+#define FLT_MIN 1.1754943508222875079688E-38F
+#endif
+#ifndef FLT_MIN_10_EXP
+#define FLT_MIN_10_EXP ( - 37 )
+#endif
+#ifndef FLT_MIN_EXP
+#define FLT_MIN_EXP ( - 125 )
+#endif
+#ifndef DBL_DIG
+#define DBL_DIG 15
+#endif
+#ifndef DBL_MAX
+#define DBL_MAX 1.7976931348623157081452E+308
+#endif
+#ifndef DBL_MAX_10_EXP
+#define DBL_MAX_10_EXP ( + 308 )
+#endif
+#ifndef DBL_MAX_EXP
+#define DBL_MAX_EXP ( + 1024 )
+#endif
+#ifndef DBL_MIN
+#define DBL_MIN 2.2250738585072013830903E-308
+#endif
+#ifndef DBL_MIN_10_EXP
+#define DBL_MIN_10_EXP ( - 307 )
+#endif
+#ifndef DBL_MIN_EXP
+#define DBL_MIN_EXP ( - 1021 )
+#endif
+#ifndef LDBL_DIG
+#define LDBL_DIG 18
+#endif
+#ifndef LDBL_MAX
+#define LDBL_MAX 1.1897314953572317650213E+4932L
+#endif
+#ifndef LDBL_MAX_10_EXP
+#define LDBL_MAX_10_EXP ( + 4932 )
+#endif
+#ifndef LDBL_MAX_EXP
+#define LDBL_MAX_EXP ( + 16384 )
+#endif
+#ifndef LDBL_MIN
+#define LDBL_MIN 3.3621031431120935062627E-4932L
+#endif
+#ifndef LDBL_MIN_10_EXP
+#define LDBL_MIN_10_EXP ( - 4931 )
+#endif
+#ifndef LDBL_MIN_EXP
+#define LDBL_MIN_EXP ( - 16381 )
+#endif
+
+
+#define USHRT_DIG 4
+#define UINT_DIG 9
+#define ULONG_DIG 19
+#define UINTMAX_DIG ULONG_DIG
+
+#define FLT_ULONG_MAX 18446744073709551615.0F
+#define FLT_ULLONG_MAX FLT_ULONG_MAX
+#define FLT_UINTMAX_MAX FLT_ULONG_MAX
+#define FLT_LONG_MAX 9223372036854775807.0F
+#define FLT_LLONG_MAX FLT_LONG_MAX
+#define FLT_INTMAX_MAX FLT_LONG_MAX
+#define FLT_LONG_MIN (-9223372036854775808.0F)
+#define FLT_LLONG_MIN FLT_LONG_MIN
+#define FLT_INTMAX_MIN FLT_LONG_MIN
+
+#define DBL_ULONG_MAX 18446744073709551615.0
+#define DBL_ULLONG_MAX DBL_ULONG_MAX
+#define DBL_UINTMAX_MAX DBL_ULONG_MAX
+#define DBL_LONG_MAX 9223372036854775807.0
+#define DBL_LLONG_MAX DBL_LONG_MAX
+#define DBL_INTMAX_MAX DBL_LONG_MAX
+#define DBL_LONG_MIN (-9223372036854775808.0)
+#define DBL_LLONG_MIN DBL_LONG_MIN
+#define DBL_INTMAX_MIN DBL_LONG_MIN
+
+#define LDBL_ULONG_MAX 18446744073709551615.0L
+#define LDBL_ULLONG_MAX LDBL_ULONG_MAX
+#define LDBL_UINTMAX_MAX LDBL_ULONG_MAX
+#define LDBL_LONG_MAX 9223372036854775807.0L
+#define LDBL_LLONG_MAX LDBL_LONG_MAX
+#define LDBL_INTMAX_MAX LDBL_LONG_MAX
+#define LDBL_LONG_MIN (-9223372036854775808.0L)
+#define LDBL_LLONG_MIN LDBL_LONG_MIN
+#define LDBL_INTMAX_MIN LDBL_LONG_MIN
+
+#define FLTMAX_UINTMAX_MAX LDBL_UINTMAX_MAX
+#define FLTMAX_INTMAX_MAX LDBL_INTMAX_MAX
+#define FLTMAX_INTMAX_MIN LDBL_INTMAX_MIN
+
+typedef union _ast_dbl_exp_u
+{
+ uint32_t e[sizeof(double)/4];
+ double f;
+} _ast_dbl_exp_t;
+
+#define _ast_dbl_exp_index 1
+#define _ast_dbl_exp_shift 20
+
+typedef union _fltmax_exp_u
+{
+ uint32_t e[sizeof(_ast_fltmax_t)/4];
+ _ast_fltmax_t f;
+} _ast_fltmax_exp_t;
+
+#define _ast_fltmax_exp_index 2
+#define _ast_fltmax_exp_shift 0
+
+#define _ast_flt_unsigned_max_t unsigned long long
+#define _ast_flt_nan_init 0xff,0xff,0xff,0x7f
+#define _ast_flt_inf_init 0x00,0x00,0x80,0x7f
+#define _ast_dbl_nan_init 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f
+#define _ast_dbl_inf_init 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x7f
+#define _ast_ldbl_nan_init 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x40,0x00,0x00,0x00,0x00,0x00
+#define _ast_ldbl_inf_init 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x7f,0x40,0x00,0x00,0x00,0x00,0x00
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/fs b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/fs
new file mode 100644
index 0000000000..eb8b57cea9
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/fs
@@ -0,0 +1,153 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/fs by iffe version 2007-04-04 : : */
+
+#ifndef _def_fs_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fs_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _lib_lstat 1 /* lstat() in default lib(s) */
+#define _lib_mknod 1 /* mknod() in default lib(s) */
+#define _lib_sync 1 /* sync() in default lib(s) */
+#include <sys/stat.h>
+#define FS_default "ufs"
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef major
+#define major(x) ( major_t ) ( ( ( ( unsigned ) ( ( x ) ) ) >> 8 ) & 0x7f )
+#endif
+#ifndef minor
+#define minor(x) ( minor_t ) ( ( ( x ) ) & 0xff )
+#endif
+#ifndef makedev
+#define makedev(x,y) ( unsigned short ) ( ( ( ( x ) ) << 8 ) | ( ( ( y ) ) & 0xff ) )
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _sys_mntent 1 /* #include <sys/mntent.h> ok */
+#define _sys_mnttab 1 /* #include <sys/mnttab.h> ok */
+#define _mem_st_blocks_stat 1 /* st_blocks is a member of struct stat */
+#define _mem_st_blksize_stat 1 /* st_blksize is a member of struct stat */
+#define _mem_st_rdev_stat 1 /* st_rdev is a member of struct stat */
+#define _sys_statfs 1 /* #include <sys/statfs.h> ok */
+#define _mem_f_files_statfs 1 /* f_files is a member of struct statfs */
+#define _sys_vfs 1 /* #include <sys/vfs.h> ok */
+#define _sys_param 1 /* #include <sys/param.h> ok */
+#define _sys_mount 1 /* #include <sys/mount.h> ok */
+#define _sys_statvfs 1 /* #include <sys/statvfs.h> ok */
+#define _mem_f_basetype_statvfs 1 /* f_basetype is a member of struct statvfs */
+#define _mem_f_frsize_statvfs 1 /* f_frsize is a member of struct statvfs */
+#define _lib_getmntent 1 /* getmntent() in default lib(s) */
+#define _lib_statfs 1 /* statfs() in default lib(s) */
+#define _lib_statvfs 1 /* statvfs() in default lib(s) */
+#define _lib_statfs4 1 /* compile{\ passed */
+#if _sys_statvfs
+#include <sys/statvfs.h>
+#if !_mem_statvfs_f_basetype
+#if _ary_f_reserved7
+#define f_basetype f_reserved7
+#endif
+#endif
+#else
+#define _mem_f_basetype_statvfs 1
+#define _mem_f_frsize_statvfs 1
+struct statvfs
+{
+unsigned long f_bsize; /* fundamental file system block size */
+unsigned long f_frsize; /* fragment size */
+unsigned long f_blocks; /* total # of blocks of f_frsize on fs */
+unsigned long f_bfree; /* total # of free blocks of f_frsize */
+unsigned long f_bavail; /* # of free blocks avail to non-superuser */
+unsigned long f_files; /* total # of file nodes (inodes) */
+unsigned long f_ffree; /* total # of free file nodes */
+unsigned long f_favail; /* # of free nodes avail to non-superuser */
+unsigned long f_fsid; /* file system id (dev for now) */
+char f_basetype[16]; /* target fs type name, null-terminated */
+unsigned long f_flag; /* bit-mask of flags */
+unsigned long f_namemax; /* maximum file name length */
+char f_fstr[32]; /* filesystem-specific string */
+unsigned long f_filler[16]; /* reserved for future expansion */
+};
+extern __MANGLE__ int fstatvfs __PROTO__((int, struct statvfs*));
+extern __MANGLE__ int statvfs __PROTO__((const char*, struct statvfs*));
+#endif
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_statvfs64 && !defined(statvfs)
+#define statvfs statvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int statvfs64 __PROTO__((const char*, struct statvfs64*));
+#endif
+#endif
+#if _lib_fstatvfs64 && !defined(fstatvfs)
+#define fstatvfs fstatvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int fstatvfs64 __PROTO__((int, struct statvfs64*));
+#endif
+#endif
+
+#define _str_st_fstype 1 /* stat.st_fstype is a string */
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/hack b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/hack
new file mode 100644
index 0000000000..31c11abc1d
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/hack
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/hack by iffe version 2007-04-04 : : */
+#ifndef _def_hack_ast
+#define _def_hack_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/iconv b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/iconv
new file mode 100644
index 0000000000..cc251f15d2
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/iconv
@@ -0,0 +1,132 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/iconv by iffe version 2007-04-04 : : */
+
+#ifndef _def_iconv_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_iconv_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_iconv 1 /* #include <iconv.h> ok */
+#define _lib_iconv_open 1 /* iconv_open() in default lib(s) */
+#define _lib_iconv_close 1 /* iconv_close() in default lib(s) */
+#define _lib_iconv 1 /* iconv() in default lib(s) */
+#define _nxt_iconv <../include/iconv.h> /* include path for the native <iconv.h> */
+#define _nxt_iconv_str "../include/iconv.h" /* include string for the native <iconv.h> */
+#include <ast_common.h>
+#include <ccode.h>
+#include <../include/iconv.h> /* the native iconv.h */
+
+#define CC_ICONV (-1)
+#define CC_UCS (-2)
+#define CC_SCU (-3)
+#define CC_UTF (-4)
+#define CC_UME (-5)
+
+#ifndef _ICONV_LIST_PRIVATE_
+#undef iconv_t
+#define iconv_t _ast_iconv_t
+#undef iconv_f
+#define iconv_f _ast_iconv_f
+#undef iconv_list_t
+#define iconv_list_t _ast_iconv_list_t
+#undef iconv_open
+#define iconv_open _ast_iconv_open
+#undef iconv
+#define iconv _ast_iconv
+#undef iconv_close
+#define iconv_close _ast_iconv_close
+#undef iconv_list
+#define iconv_list _ast_iconv_list
+#undef iconv_move
+#define iconv_move _ast_iconv_move
+#undef iconv_name
+#define iconv_name _ast_iconv_name
+#undef iconv_write
+#define iconv_write _ast_iconv_write
+#endif
+
+typedef Ccmap_t _ast_iconv_list_t;
+typedef __V_* _ast_iconv_t;
+typedef size_t (*_ast_iconv_f) __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ _ast_iconv_t _ast_iconv_open __PROTO__((const char*, const char*));
+extern __MANGLE__ size_t _ast_iconv __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+extern __MANGLE__ int _ast_iconv_close __PROTO__((_ast_iconv_t));
+extern __MANGLE__ _ast_iconv_list_t* _ast_iconv_list __PROTO__((_ast_iconv_list_t*));
+extern __MANGLE__ int _ast_iconv_name __PROTO__((const char*, char*, size_t));
+#if _SFIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, Sfio_t*, Sfio_t*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, Sfio_t*, char**, size_t*, size_t*));
+#else
+#if _SFSTDIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, FILE*, FILE*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, FILE*, char**, size_t*, size_t*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/lib b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/lib
new file mode 100644
index 0000000000..a2a479c2d7
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/lib
@@ -0,0 +1,160 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/lib by iffe version 2007-04-04 : : */
+#ifndef _def_lib_ast
+#define _def_lib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _hdr_fmtmsg 1 /* #include <fmtmsg.h> ok */
+#define _hdr_fnmatch 1 /* #include <fnmatch.h> ok */
+#define _hdr_libgen 1 /* #include <libgen.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_locale 1 /* #include <locale.h> ok */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_spawn 1 /* #include <spawn.h> ok */
+#define _hdr_syslog 1 /* #include <syslog.h> ok */
+#define _hdr_utime 1 /* #include <utime.h> ok */
+#define _hdr_wctype 1 /* #include <wctype.h> ok */
+#define _hdr_wchar 1 /* <wchar.h> and isw*() really work */
+#define _dat__tzname 1 /* _tzname in default lib(s) */
+#define _dat_tzname 1 /* tzname in default lib(s) */
+#define _lib__cleanup 1 /* _cleanup() in default lib(s) */
+#define _lib_atexit 1 /* atexit() in default lib(s) */
+#define _lib_bcopy 1 /* bcopy() in default lib(s) */
+#define _lib_bzero 1 /* bzero() in default lib(s) */
+#define _lib_catclose 1 /* catclose() in default lib(s) */
+#define _lib_catgets 1 /* catgets() in default lib(s) */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_confstr 1 /* confstr() in default lib(s) */
+#define _lib_dup2 1 /* dup2() in default lib(s) */
+#define _lib_execlp 1 /* execlp() in default lib(s) */
+#define _lib_execve 1 /* execve() in default lib(s) */
+#define _lib_execvp 1 /* execvp() in default lib(s) */
+#define _lib_fchmod 1 /* fchmod() in default lib(s) */
+#define _lib_fcntl 1 /* fcntl() in default lib(s) */
+#define _lib_fmtmsg 1 /* fmtmsg() in default lib(s) */
+#define _lib_fnmatch 1 /* fnmatch() in default lib(s) */
+#define _lib_fork 1 /* fork() in default lib(s) */
+#define _lib_fsync 1 /* fsync() in default lib(s) */
+#define _lib_getdents 1 /* getdents() in default lib(s) */
+#define _lib_getdtablesize 1 /* getdtablesize() in default lib(s) */
+#define _lib_getdate 1 /* getdate() in default lib(s) */
+#define _lib_getgroups 1 /* getgroups() in default lib(s) */
+#define _lib_gethostname 1 /* gethostname() in default lib(s) */
+#define _lib_getlogin 1 /* getlogin() in default lib(s) */
+#define _lib_getpagesize 1 /* getpagesize() in default lib(s) */
+#define _lib_getrlimit 1 /* getrlimit() in default lib(s) */
+#define _lib_getopt 1 /* getopt() in default lib(s) */
+#define _lib_getsubopt 1 /* getsubopt() in default lib(s) */
+#define _lib_getopt_long 1 /* getopt_long() in default lib(s) */
+#define _lib_getopt_long_only 1 /* getopt_long_only() in default lib(s) */
+#define _lib_glob 1 /* glob() in default lib(s) */
+#define _lib_index 1 /* index() in default lib(s) */
+#define _lib_iswblank 1 /* iswblank() in default lib(s) */
+#define _lib_iswctype 1 /* iswctype() in default lib(s) */
+#define _lib_killpg 1 /* killpg() in default lib(s) */
+#define _lib_link 1 /* link() in default lib(s) */
+#define _lib_localeconv 1 /* localeconv() in default lib(s) */
+#define _lib_madvise 1 /* madvise() in default lib(s) */
+#define _lib_mbtowc 1 /* mbtowc() in default lib(s) */
+#define _lib_mbrtowc 1 /* mbrtowc() in default lib(s) */
+#define _lib_memalign 1 /* memalign() in default lib(s) */
+#define _lib_memchr 1 /* memchr() in default lib(s) */
+#define _lib_memcpy 1 /* memcpy() in default lib(s) */
+#define _lib_memmove 1 /* memmove() in default lib(s) */
+#define _lib_memset 1 /* memset() in default lib(s) */
+#define _lib_mkdir 1 /* mkdir() in default lib(s) */
+#define _lib_mkfifo 1 /* mkfifo() in default lib(s) */
+#define _lib_mktemp 1 /* mktemp() in default lib(s) */
+#define _lib_mktime 1 /* mktime() in default lib(s) */
+#define _lib_mount 1 /* mount() in default lib(s) */
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _lib_pathconf 1 /* pathconf() in default lib(s) */
+#define _lib_readlink 1 /* readlink() in default lib(s) */
+#define _lib_remove 1 /* remove() in default lib(s) */
+#define _lib_rename 1 /* rename() in default lib(s) */
+#define _lib_rewinddir 1 /* rewinddir() in default lib(s) */
+#define _lib_rindex 1 /* rindex() in default lib(s) */
+#define _lib_rmdir 1 /* rmdir() in default lib(s) */
+#define _lib_setlocale 1 /* setlocale() in default lib(s) */
+#define _lib_setpgid 1 /* setpgid() in default lib(s) */
+#define _lib_setpgrp 1 /* setpgrp() in default lib(s) */
+#define _lib_setreuid 1 /* setreuid() in default lib(s) */
+#define _lib_setsid 1 /* setsid() in default lib(s) */
+#define _lib_setuid 1 /* setuid() in default lib(s) */
+#define _lib_sigaction 1 /* sigaction() in default lib(s) */
+#define _lib_sigprocmask 1 /* sigprocmask() in default lib(s) */
+#define _lib_socketpair 1 /* socketpair() in default lib(s) */
+#define _lib_strchr 1 /* strchr() in default lib(s) */
+#define _lib_strcoll 1 /* strcoll() in default lib(s) */
+#define _lib_strdup 1 /* strdup() in default lib(s) */
+#define _lib_strerror 1 /* strerror() in default lib(s) */
+#define _lib_strcasecmp 1 /* strcasecmp() in default lib(s) */
+#define _lib_strncasecmp 1 /* strncasecmp() in default lib(s) */
+#define _lib_strrchr 1 /* strrchr() in default lib(s) */
+#define _lib_strstr 1 /* strstr() in default lib(s) */
+#define _lib_strxfrm 1 /* strxfrm() in default lib(s) */
+#define _lib_strftime 1 /* strftime() in default lib(s) */
+#define _lib_swab 1 /* swab() in default lib(s) */
+#define _lib_symlink 1 /* symlink() in default lib(s) */
+#define _lib_sysconf 1 /* sysconf() in default lib(s) */
+#define _lib_sysinfo 1 /* sysinfo() in default lib(s) */
+#define _lib_syslog 1 /* syslog() in default lib(s) */
+#define _lib_telldir 1 /* telldir() in default lib(s) */
+#define _lib_tmpnam 1 /* tmpnam() in default lib(s) */
+#define _lib_tzset 1 /* tzset() in default lib(s) */
+#define _lib_unlink 1 /* unlink() in default lib(s) */
+#define _lib_utime 1 /* utime() in default lib(s) */
+#define _lib_wctype 1 /* wctype() in default lib(s) */
+#define _lib_ftruncate 1 /* ftruncate() in default lib(s) */
+#define _lib_truncate 1 /* truncate() in default lib(s) */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _lib_strtod 1 /* strtod() in default lib(s) */
+#define _lib_strtold 1 /* strtold() in default lib(s) */
+#define _lib_strtol 1 /* strtol() in default lib(s) */
+#define _lib_strtoll 1 /* strtoll() in default lib(s) */
+#define _lib_strtoul 1 /* strtoul() in default lib(s) */
+#define _lib_strtoull 1 /* strtoull() in default lib(s) */
+#define _mem_d_ino_dirent 1 /* d_ino is a member of struct dirent */
+#define _mem_d_off_dirent 1 /* d_off is a member of struct dirent */
+#define _mem_d_reclen_dirent 1 /* d_reclen is a member of struct dirent */
+#define _mem_DIR 1 /* DIR is a non-opaque struct */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _sys_jioctl 1 /* #include <sys/jioctl.h> ok */
+#define _sys_localedef 1 /* #include <sys/localedef.h> ok */
+#define _sys_ptem 1 /* #include <sys/ptem.h> ok */
+#define _sys_resource 1 /* #include <sys/resource.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _sys_stream 1 /* #include <sys/stream.h> ok */
+#define _sys_systeminfo 1 /* #include <sys/systeminfo.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_off64_t 1 /* off64_t is a type */
+#define _typ_struct_dirent64 1 /* struct dirent64 is a type */
+#define _tst_errno 1 /* errno can be assigned */
+#define _lib_poll_fd_1 1 /* fd is first arg to poll() */
+#define _lib_poll 1 /* _lib_poll_fd_1||_lib_poll_fd_2 is true */
+#define _lib_select 1 /* select() has standard 5 arg interface */
+#define _pipe_rw 1 /* full duplex pipes */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _lib_vfork 1 /* vfork exists and it works */
+#define _real_vfork 1 /* vfork child shares data with parent */
+#define _lib_posix_spawn 1 /* posix_spawn exists and it works and its worth using */
+#define _stream_peek 1 /* ioctl(I_PEEK) works */
+#define _socket_peek 1 /* recv(MSG_PEEK) works */
+#define _hdr_string 1 /* #include <string.h> ok */
+#define _lib_memcmp 1 /* standard memcmp interface that works */
+#define _hdr_fcntl 1 /* #include <fcntl.h> ok */
+#define _hdr_signal 1 /* #include <signal.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_memccpy 1 /* standard memccpy interface that works */
+#define _lib_utime_now 1 /* utime works with 0 time vector */
+#define _UNIV_DEFAULT "att" /* default universe name */
+#define _std_cleanup 1 /* stuck with standard _cleanup */
+#define _std_strcoll 1 /* standard strcoll works */
+#if !_AST_no_spawnveg
+#define _use_spawnveg 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/libpath b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/libpath
new file mode 100644
index 0000000000..d6dc322a20
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/libpath
@@ -0,0 +1,6 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/libpath.sh by iffe version 2007-04-04 : : */
+#ifndef _def_libpath_ast
+#define _def_libpath_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define CONF_LIBPATH "lib/64:LD_LIBRARY_PATH_64:sol.*64*,lib/32:LD_LIBRARY_PATH_32,lib:LD_LIBRARY_PATH"
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/limits b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/limits
new file mode 100644
index 0000000000..7dddc39475
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/limits
@@ -0,0 +1,107 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/limits.c by iffe version 2007-04-04 : : */
+#ifndef _def_limits_ast
+#define _def_limits_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+#ifndef CHAR_MAX
+#define CHAR_MAX 127
+#endif
+#ifndef CHAR_MIN
+#define CHAR_MIN -128
+#endif
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC 1000000
+#endif
+#ifndef INT_MIN
+#define INT_MIN -2147483648
+#endif
+#ifndef LLONG_MAX
+#define LLONG_MAX 9223372036854775807
+#endif
+#ifndef LLONG_MIN
+#define LLONG_MIN -9223372036854775808
+#endif
+#ifndef LONG_MAX
+#define LONG_MAX 2147483647
+#endif
+#ifndef LONG_MIN
+#define LONG_MIN -2147483648
+#endif
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 5
+#endif
+#ifndef OPEN_MAX_CEIL
+#ifndef OPEN_MAX
+#define OPEN_MAX 256
+#endif
+#define OPEN_MAX_CEIL OPEN_MAX
+#endif
+#ifndef PTHREAD_STACK_MIN
+#define PTHREAD_STACK_MIN 4096
+#endif
+#ifndef PTRDIFF_MAX
+#define PTRDIFF_MAX 9223372036854775807
+#endif
+#ifndef PTRDIFF_MIN
+#define PTRDIFF_MIN -9223372036854775808
+#endif
+#ifndef SCHAR_MAX
+#define SCHAR_MAX 127
+#endif
+#ifndef SCHAR_MIN
+#define SCHAR_MIN -128
+#endif
+#ifndef SHRT_MIN
+#define SHRT_MIN -32768
+#endif
+#ifndef SIG_ATOMIC_MAX
+#define SIG_ATOMIC_MAX 2147483647
+#endif
+#ifndef SIG_ATOMIC_MIN
+#define SIG_ATOMIC_MIN -2147483648
+#endif
+#ifndef SIZE_MAX
+#ifndef UINT_MAX
+#define UINT_MAX 4294967295
+#endif
+#define SIZE_MAX UINT_MAX
+#endif
+#ifndef SSIZE_MAX
+#ifndef INT_MAX
+#define INT_MAX 2147483647
+#endif
+#define SSIZE_MAX INT_MAX
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+#ifndef UCHAR_MAX
+#define UCHAR_MAX 255
+#endif
+#ifndef ULLONG_MAX
+#define ULLONG_MAX 18446744073709551615
+#endif
+#ifndef ULONG_MAX
+#define ULONG_MAX 4294967295
+#endif
+#ifndef USHRT_MAX
+#define USHRT_MAX 65535
+#endif
+#ifndef WCHAR_MAX
+#define WCHAR_MAX 2147483647
+#endif
+#ifndef WCHAR_MIN
+#define WCHAR_MIN -2147483648
+#endif
+#ifndef WINT_MAX
+#define WINT_MAX 2147483647
+#endif
+#ifndef WINT_MIN
+#define WINT_MIN -2147483648
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/map b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/map
new file mode 100644
index 0000000000..55c2ef8707
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/map
@@ -0,0 +1,438 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/map.c by iffe version 2007-04-04 : : */
+#ifndef _def_map_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_map_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+/*
+ * prototypes provided for standard interfaces hijacked
+ * by ast and mapped to _ast_* but already prototyped
+ * unmapped in native headers included by <ast_std.h>
+ */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+
+#define _map_libc 1
+#undef basename
+#define basename _ast_basename
+#undef dirname
+#define dirname _ast_dirname
+#undef eaccess
+#define eaccess _ast_eaccess
+#undef execvpe
+#define execvpe _ast_execvpe
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+#undef fnmatch
+#define fnmatch _ast_fnmatch
+#undef fts_children
+#define fts_children _ast_fts_children
+#undef fts_close
+#define fts_close _ast_fts_close
+#undef fts_flags
+#define fts_flags _ast_fts_flags
+#undef fts_notify
+#define fts_notify _ast_fts_notify
+#undef fts_open
+#define fts_open _ast_fts_open
+#undef fts_read
+#define fts_read _ast_fts_read
+#undef fts_set
+#define fts_set _ast_fts_set
+#undef ftw
+#define ftw _ast_ftw
+#undef ftwalk
+#define ftwalk _ast_ftwalk
+#undef ftwflags
+#define ftwflags _ast_ftwflags
+#undef getcwd
+#define getcwd _ast_getcwd
+extern __MANGLE__ char* getcwd __PROTO__((char*, size_t));
+#undef getdate
+#define getdate _ast_getdate
+#undef getopt
+#define getopt _ast_getopt
+#undef getsubopt
+#define getsubopt _ast_getsubopt
+#undef getopt_long
+#define getopt_long _ast_getopt_long
+#undef getopt_long_only
+#define getopt_long_only _ast_getopt_long_only
+#undef getwd
+#define getwd _ast_getwd
+extern __MANGLE__ char* getwd __PROTO__((char*));
+#undef glob
+#define glob _ast_glob
+#undef globfree
+#define globfree _ast_globfree
+#undef memdup
+#define memdup _ast_memdup
+#undef memfatal
+#define memfatal _ast_memfatal
+#undef memhash
+#define memhash _ast_memhash
+#undef memsum
+#define memsum _ast_memsum
+#undef mkstemp
+#define mkstemp _ast_mkstemp
+extern __MANGLE__ int mkstemp __PROTO__((char*));
+#undef mktemp
+#define mktemp _ast_mktemp
+extern __MANGLE__ char* mktemp __PROTO__((char*));
+#undef mktime
+#define mktime _ast_mktime
+#undef nftw
+#define nftw _ast_nftw
+#undef optesc
+#define optesc _ast_optesc
+#undef optget
+#define optget _ast_optget
+#undef opthelp
+#define opthelp _ast_opthelp
+#undef optjoin
+#define optjoin _ast_optjoin
+#undef optstr
+#define optstr _ast_optstr
+#undef optusage
+#define optusage _ast_optusage
+#undef pathaccess
+#define pathaccess _ast_pathaccess
+#undef pathbin
+#define pathbin _ast_pathbin
+#undef pathcanon
+#define pathcanon _ast_pathcanon
+#undef pathcat
+#define pathcat _ast_pathcat
+#undef pathcd
+#define pathcd _ast_pathcd
+#undef pathcheck
+#define pathcheck _ast_pathcheck
+#undef pathexists
+#define pathexists _ast_pathexists
+#undef pathfind
+#define pathfind _ast_pathfind
+#undef pathgetlink
+#define pathgetlink _ast_pathgetlink
+#undef pathinclude
+#define pathinclude _ast_pathinclude
+#undef pathkey
+#define pathkey _ast_pathkey
+#undef pathnative
+#define pathnative _ast_pathnative
+#undef pathpath
+#define pathpath _ast_pathpath
+#undef pathposix
+#define pathposix _ast_pathposix
+#undef pathprobe
+#define pathprobe _ast_pathprobe
+#undef pathrepl
+#define pathrepl _ast_pathrepl
+#undef pathsetlink
+#define pathsetlink _ast_pathsetlink
+#undef pathshell
+#define pathshell _ast_pathshell
+#undef pathstat
+#define pathstat _ast_pathstat
+#undef pathtemp
+#define pathtemp _ast_pathtemp
+#undef pathtmp
+#define pathtmp _ast_pathtmp
+#undef procclose
+#define procclose _ast_procclose
+#undef procfree
+#define procfree _ast_procfree
+#undef procopen
+#define procopen _ast_procopen
+#undef procrun
+#define procrun _ast_procrun
+#undef putenv
+#define putenv _ast_putenv
+#undef re_comp
+#define re_comp _ast_re_comp
+#undef re_exec
+#define re_exec _ast_re_exec
+#undef realpath
+#define realpath _ast_realpath
+extern __MANGLE__ char* realpath __PROTO__((const char*, char*));
+#undef regaddclass
+#define regaddclass _ast_regaddclass
+#undef regalloc
+#define regalloc _ast_regalloc
+#undef regcache
+#define regcache _ast_regcache
+#undef regclass
+#define regclass _ast_regclass
+#undef regcmp
+#define regcmp _ast_regcmp
+#undef regcollate
+#define regcollate _ast_regcollate
+#undef regcomb
+#define regcomb _ast_regcomb
+#undef regcomp
+#define regcomp _ast_regcomp
+#undef regdecomp
+#define regdecomp _ast_regdecomp
+#undef regdup
+#define regdup _ast_regdup
+#undef regerror
+#define regerror _ast_regerror
+#undef regex
+#define regex _ast_regex
+#undef regexec
+#define regexec _ast_regexec
+#undef regfatal
+#define regfatal _ast_regfatal
+#undef regfatalpat
+#define regfatalpat _ast_regfatalpat
+#undef regfree
+#define regfree _ast_regfree
+#undef regncomp
+#define regncomp _ast_regncomp
+#undef regnexec
+#define regnexec _ast_regnexec
+#undef regrecord
+#define regrecord _ast_regrecord
+#undef regrexec
+#define regrexec _ast_regrexec
+#undef regstat
+#define regstat _ast_regstat
+#undef regsub
+#define regsub _ast_regsub
+#undef regsubcomp
+#define regsubcomp _ast_regsubcomp
+#undef regsubexec
+#define regsubexec _ast_regsubexec
+#undef regsubflags
+#define regsubflags _ast_regsubflags
+#undef regsubfree
+#define regsubfree _ast_regsubfree
+#undef remove
+#define remove _ast_remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#undef resolvepath
+#define resolvepath _ast_resolvepath
+extern __MANGLE__ char* resolvepath __PROTO__((const char*, char*, size_t));
+#undef setenv
+#define setenv _ast_setenv
+extern __MANGLE__ int setenv __PROTO__((const char*, const char*, int));
+#undef setenviron
+#define setenviron _ast_setenviron
+#undef sigcritical
+#define sigcritical _ast_sigcritical
+#undef signal
+#define signal _ast_signal
+#undef sigunblock
+#define sigunblock _ast_sigunblock
+#undef stracmp
+#define stracmp _ast_stracmp
+#undef strcopy
+#define strcopy _ast_strcopy
+#undef strelapsed
+#define strelapsed _ast_strelapsed
+#undef stresc
+#define stresc _ast_stresc
+#undef streval
+#define streval _ast_streval
+#undef strexpr
+#define strexpr _ast_strexpr
+#undef strftime
+#define strftime _ast_strftime
+#undef strgid
+#define strgid _ast_strgid
+#undef strgrpmatch
+#define strgrpmatch _ast_strgrpmatch
+#undef strhash
+#define strhash _ast_strhash
+#undef strkey
+#define strkey _ast_strkey
+#undef strlcat
+#define strlcat _ast_strlcat
+extern __MANGLE__ size_t strlcat __PROTO__((char*, const char*, size_t));
+#undef strlcpy
+#define strlcpy _ast_strlcpy
+extern __MANGLE__ size_t strlcpy __PROTO__((char*, const char*, size_t));
+#undef strlook
+#define strlook _ast_strlook
+#undef strmatch
+#define strmatch _ast_strmatch
+#undef strmode
+#define strmode _ast_strmode
+#undef strnacmp
+#define strnacmp _ast_strnacmp
+#undef strncopy
+#define strncopy _ast_strncopy
+#undef strntod
+#define strntod _ast_strntod
+#undef strntol
+#define strntol _ast_strntol
+#undef strntold
+#define strntold _ast_strntold
+#undef strntoll
+#define strntoll _ast_strntoll
+#undef strntoul
+#define strntoul _ast_strntoul
+#undef strntoull
+#define strntoull _ast_strntoull
+#undef stropt
+#define stropt _ast_stropt
+#undef strperm
+#define strperm _ast_strperm
+#undef strpsearch
+#define strpsearch _ast_strpsearch
+#undef strptime
+#define strptime _ast_strptime
+#undef strsearch
+#define strsearch _ast_strsearch
+#undef strsort
+#define strsort _ast_strsort
+#undef strsubmatch
+#define strsubmatch _ast_strsubmatch
+#undef strsum
+#define strsum _ast_strsum
+#undef strtape
+#define strtape _ast_strtape
+#undef strtoip4
+#define strtoip4 _ast_strtoip4
+#undef strton
+#define strton _ast_strton
+#undef strtonll
+#define strtonll _ast_strtonll
+#undef struid
+#define struid _ast_struid
+#undef struniq
+#define struniq _ast_struniq
+#undef system
+#define system _ast_system
+extern __MANGLE__ int system __PROTO__((const char*));
+#undef tempnam
+#define tempnam _ast_tempnam
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+#undef tmpnam
+#define tmpnam _ast_tmpnam
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+#undef touch
+#define touch _ast_touch
+#undef wordexp
+#define wordexp _ast_wordexp
+#undef wordfree
+#define wordfree _ast_wordfree
+#undef unsetenv
+#define unsetenv _ast_unsetenv
+
+/* cannot override local malloc */
+#define _map_malloc 1
+#undef calloc
+#define calloc _ast_calloc
+extern __MANGLE__ __V_* calloc __PROTO__((size_t, size_t));
+#undef cfree
+#define cfree _ast_cfree
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+#undef free
+#define free _ast_free
+extern __MANGLE__ void free __PROTO__((__V_*));
+#undef malloc
+#define malloc _ast_malloc
+extern __MANGLE__ __V_* malloc __PROTO__((size_t));
+#undef memalign
+#define memalign _ast_memalign
+extern __MANGLE__ __V_* memalign __PROTO__((size_t, size_t));
+#undef realloc
+#define realloc _ast_realloc
+extern __MANGLE__ __V_* realloc __PROTO__((__V_*, size_t));
+#undef strdup
+#define strdup _ast_strdup
+extern __MANGLE__ char* strdup __PROTO__((const char*));
+#undef valloc
+#define valloc _ast_valloc
+extern __MANGLE__ __V_* valloc __PROTO__((size_t));
+#undef strtol
+#define strtol _ast_strtol
+#undef strtoul
+#define strtoul _ast_strtoul
+#undef strtoll
+#define strtoll _ast_strtoll
+#undef strtoull
+#define strtoull _ast_strtoull
+#undef strtod
+#define strtod _ast_strtod
+#undef strtold
+#define strtold _ast_strtold
+extern __MANGLE__ long strtol __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned long strtoul __PROTO__((const char*, char**, int));
+extern __MANGLE__ double strtod __PROTO__((const char*, char**));
+#if !_UWIN
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
+extern __MANGLE__ _ast_fltmax_t strtold __PROTO__((const char*, char**));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+extern __MANGLE__ _ast_intmax_t strtoll __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned _ast_intmax_t strtoull __PROTO__((const char*, char**, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/mmap b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/mmap
new file mode 100644
index 0000000000..10483aee18
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/mmap
@@ -0,0 +1,26 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/mmap by iffe version 2007-04-04 : : */
+#ifndef _def_mmap_ast
+#define _def_mmap_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_mmap 1 /* standard mmap interface that works */
+#define _lib_mmap64 1 /* mmap64 interface and implementation work */
+#define _mmap_anon 1 /* use mmap MAP_ANON to get raw memory */
+#define _mmap_devzero 1 /* use mmap on /dev/zero to get raw memory */
+
+/* some systems get it wrong but escape concise detection */
+#ifndef _NO_MMAP
+#if __CYGWIN__
+#define _NO_MMAP 1
+#endif
+#endif
+
+#if _NO_MMAP
+#undef _lib_mmap
+#undef _lib_mmap64
+#undef _mmap_anon
+#undef _mmap_devzero
+#undef _mmap_worthy
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/mode b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/mode
new file mode 100644
index 0000000000..5476393224
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/mode
@@ -0,0 +1,14 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/mode.c by iffe version 2007-04-04 : : */
+#ifndef _def_mode_ast
+#define _def_mode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define S_ITYPE(m) ((m)&S_IFMT)
+
+#define S_IPERM (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
+
+#define _S_IDPERM 1
+#define _S_IDTYPE 1
+
+#define BUFFERSIZE 8192
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/nl_types b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/nl_types
new file mode 100644
index 0000000000..43c7bc9c4d
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/nl_types
@@ -0,0 +1,102 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/nl_types by iffe version 2007-04-04 : : */
+
+#ifndef _def_nl_types_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_nl_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_nl_langinfo 1 /* nl_langinfo() in default lib(s) */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_langinfo 1 /* #include <langinfo.h> ok */
+#define _nxt_nl_types <../include/nl_types.h> /* include path for the native <nl_types.h> */
+#define _nxt_nl_types_str "../include/nl_types.h" /* include string for the native <nl_types.h> */
+#include <limits.h>
+#include <../include/nl_types.h> /* the native nl_types.h */
+
+#undef NL_SETMAX
+#define NL_SETMAX 1023
+#undef NL_MSGMAX
+#define NL_MSGMAX 32767
+#undef nl_catd
+#define nl_catd _ast_nl_catd
+#undef catopen
+#define catopen _ast_catopen
+#undef catgets
+#define catgets _ast_catgets
+#undef catclose
+#define catclose _ast_catclose
+
+typedef __V_* nl_catd;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ nl_catd catopen __PROTO__((const char*, int));
+extern __MANGLE__ char* catgets __PROTO__((nl_catd, int, int, const char*));
+extern __MANGLE__ int catclose __PROTO__((nl_catd));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/omitted b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/omitted
new file mode 100644
index 0000000000..a3539b4918
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/omitted
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/omitted by iffe version 2007-04-04 : : */
+#ifndef _def_omitted_ast
+#define _def_omitted_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/param b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/param
new file mode 100644
index 0000000000..4c28f392e5
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/param
@@ -0,0 +1,9 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/param.sh by iffe version 2007-04-04 : : */
+#ifndef _def_param_ast
+#define _def_param_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#include <sys/param.h>
+#ifndef S_IFDIR
+#include <sys/stat.h>
+#endif
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/preroot b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/preroot
new file mode 100644
index 0000000000..ec3ecd3cfe
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/preroot
@@ -0,0 +1,6 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/preroot.sh by iffe version 2007-04-04 : : */
+#ifndef _def_preroot_ast
+#define _def_preroot_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* preroot not enabled */
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/sfinit b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/sfinit
new file mode 100644
index 0000000000..74fe82ba25
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/sfinit
@@ -0,0 +1,5332 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/sfinit.c by iffe version 2007-04-04 : : */
+#ifndef _def_sfinit_ast
+#define _def_sfinit_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+static const float sf_flt_pow10[] =
+{
+ 1E0F,
+ 1E1F,
+ 1E2F,
+ 1E3F,
+ 1E4F,
+ 1E5F,
+ 1E6F,
+ 1E7F,
+ 1E8F,
+ 1E9F,
+ 1E10F,
+ 1E11F,
+ 1E12F,
+ 1E13F,
+ 1E14F,
+ 1E15F,
+ 1E16F,
+ 1E17F,
+ 1E18F,
+ 1E19F,
+ 1E20F,
+ 1E21F,
+ 1E22F,
+ 1E23F,
+ 1E24F,
+ 1E25F,
+ 1E26F,
+ 1E27F,
+ 1E28F,
+ 1E29F,
+ 1E30F,
+ 1E31F,
+ 1E32F,
+ 1E33F,
+ 1E34F,
+ 1E35F,
+ 1E36F,
+ 1E37F,
+ 1E38F,
+};
+
+static const double sf_dbl_pow10[] =
+{
+ 1E0,
+ 1E1,
+ 1E2,
+ 1E3,
+ 1E4,
+ 1E5,
+ 1E6,
+ 1E7,
+ 1E8,
+ 1E9,
+ 1E10,
+ 1E11,
+ 1E12,
+ 1E13,
+ 1E14,
+ 1E15,
+ 1E16,
+ 1E17,
+ 1E18,
+ 1E19,
+ 1E20,
+ 1E21,
+ 1E22,
+ 1E23,
+ 1E24,
+ 1E25,
+ 1E26,
+ 1E27,
+ 1E28,
+ 1E29,
+ 1E30,
+ 1E31,
+ 1E32,
+ 1E33,
+ 1E34,
+ 1E35,
+ 1E36,
+ 1E37,
+ 1E38,
+ 1E39,
+ 1E40,
+ 1E41,
+ 1E42,
+ 1E43,
+ 1E44,
+ 1E45,
+ 1E46,
+ 1E47,
+ 1E48,
+ 1E49,
+ 1E50,
+ 1E51,
+ 1E52,
+ 1E53,
+ 1E54,
+ 1E55,
+ 1E56,
+ 1E57,
+ 1E58,
+ 1E59,
+ 1E60,
+ 1E61,
+ 1E62,
+ 1E63,
+ 1E64,
+ 1E65,
+ 1E66,
+ 1E67,
+ 1E68,
+ 1E69,
+ 1E70,
+ 1E71,
+ 1E72,
+ 1E73,
+ 1E74,
+ 1E75,
+ 1E76,
+ 1E77,
+ 1E78,
+ 1E79,
+ 1E80,
+ 1E81,
+ 1E82,
+ 1E83,
+ 1E84,
+ 1E85,
+ 1E86,
+ 1E87,
+ 1E88,
+ 1E89,
+ 1E90,
+ 1E91,
+ 1E92,
+ 1E93,
+ 1E94,
+ 1E95,
+ 1E96,
+ 1E97,
+ 1E98,
+ 1E99,
+ 1E100,
+ 1E101,
+ 1E102,
+ 1E103,
+ 1E104,
+ 1E105,
+ 1E106,
+ 1E107,
+ 1E108,
+ 1E109,
+ 1E110,
+ 1E111,
+ 1E112,
+ 1E113,
+ 1E114,
+ 1E115,
+ 1E116,
+ 1E117,
+ 1E118,
+ 1E119,
+ 1E120,
+ 1E121,
+ 1E122,
+ 1E123,
+ 1E124,
+ 1E125,
+ 1E126,
+ 1E127,
+ 1E128,
+ 1E129,
+ 1E130,
+ 1E131,
+ 1E132,
+ 1E133,
+ 1E134,
+ 1E135,
+ 1E136,
+ 1E137,
+ 1E138,
+ 1E139,
+ 1E140,
+ 1E141,
+ 1E142,
+ 1E143,
+ 1E144,
+ 1E145,
+ 1E146,
+ 1E147,
+ 1E148,
+ 1E149,
+ 1E150,
+ 1E151,
+ 1E152,
+ 1E153,
+ 1E154,
+ 1E155,
+ 1E156,
+ 1E157,
+ 1E158,
+ 1E159,
+ 1E160,
+ 1E161,
+ 1E162,
+ 1E163,
+ 1E164,
+ 1E165,
+ 1E166,
+ 1E167,
+ 1E168,
+ 1E169,
+ 1E170,
+ 1E171,
+ 1E172,
+ 1E173,
+ 1E174,
+ 1E175,
+ 1E176,
+ 1E177,
+ 1E178,
+ 1E179,
+ 1E180,
+ 1E181,
+ 1E182,
+ 1E183,
+ 1E184,
+ 1E185,
+ 1E186,
+ 1E187,
+ 1E188,
+ 1E189,
+ 1E190,
+ 1E191,
+ 1E192,
+ 1E193,
+ 1E194,
+ 1E195,
+ 1E196,
+ 1E197,
+ 1E198,
+ 1E199,
+ 1E200,
+ 1E201,
+ 1E202,
+ 1E203,
+ 1E204,
+ 1E205,
+ 1E206,
+ 1E207,
+ 1E208,
+ 1E209,
+ 1E210,
+ 1E211,
+ 1E212,
+ 1E213,
+ 1E214,
+ 1E215,
+ 1E216,
+ 1E217,
+ 1E218,
+ 1E219,
+ 1E220,
+ 1E221,
+ 1E222,
+ 1E223,
+ 1E224,
+ 1E225,
+ 1E226,
+ 1E227,
+ 1E228,
+ 1E229,
+ 1E230,
+ 1E231,
+ 1E232,
+ 1E233,
+ 1E234,
+ 1E235,
+ 1E236,
+ 1E237,
+ 1E238,
+ 1E239,
+ 1E240,
+ 1E241,
+ 1E242,
+ 1E243,
+ 1E244,
+ 1E245,
+ 1E246,
+ 1E247,
+ 1E248,
+ 1E249,
+ 1E250,
+ 1E251,
+ 1E252,
+ 1E253,
+ 1E254,
+ 1E255,
+ 1E256,
+ 1E257,
+ 1E258,
+ 1E259,
+ 1E260,
+ 1E261,
+ 1E262,
+ 1E263,
+ 1E264,
+ 1E265,
+ 1E266,
+ 1E267,
+ 1E268,
+ 1E269,
+ 1E270,
+ 1E271,
+ 1E272,
+ 1E273,
+ 1E274,
+ 1E275,
+ 1E276,
+ 1E277,
+ 1E278,
+ 1E279,
+ 1E280,
+ 1E281,
+ 1E282,
+ 1E283,
+ 1E284,
+ 1E285,
+ 1E286,
+ 1E287,
+ 1E288,
+ 1E289,
+ 1E290,
+ 1E291,
+ 1E292,
+ 1E293,
+ 1E294,
+ 1E295,
+ 1E296,
+ 1E297,
+ 1E298,
+ 1E299,
+ 1E300,
+ 1E301,
+ 1E302,
+ 1E303,
+ 1E304,
+ 1E305,
+ 1E306,
+ 1E307,
+ 1E308,
+};
+
+static const _ast_fltmax_t sf_ldbl_pow10[] =
+{
+ 1E0L,
+ 1E1L,
+ 1E2L,
+ 1E3L,
+ 1E4L,
+ 1E5L,
+ 1E6L,
+ 1E7L,
+ 1E8L,
+ 1E9L,
+ 1E10L,
+ 1E11L,
+ 1E12L,
+ 1E13L,
+ 1E14L,
+ 1E15L,
+ 1E16L,
+ 1E17L,
+ 1E18L,
+ 1E19L,
+ 1E20L,
+ 1E21L,
+ 1E22L,
+ 1E23L,
+ 1E24L,
+ 1E25L,
+ 1E26L,
+ 1E27L,
+ 1E28L,
+ 1E29L,
+ 1E30L,
+ 1E31L,
+ 1E32L,
+ 1E33L,
+ 1E34L,
+ 1E35L,
+ 1E36L,
+ 1E37L,
+ 1E38L,
+ 1E39L,
+ 1E40L,
+ 1E41L,
+ 1E42L,
+ 1E43L,
+ 1E44L,
+ 1E45L,
+ 1E46L,
+ 1E47L,
+ 1E48L,
+ 1E49L,
+ 1E50L,
+ 1E51L,
+ 1E52L,
+ 1E53L,
+ 1E54L,
+ 1E55L,
+ 1E56L,
+ 1E57L,
+ 1E58L,
+ 1E59L,
+ 1E60L,
+ 1E61L,
+ 1E62L,
+ 1E63L,
+ 1E64L,
+ 1E65L,
+ 1E66L,
+ 1E67L,
+ 1E68L,
+ 1E69L,
+ 1E70L,
+ 1E71L,
+ 1E72L,
+ 1E73L,
+ 1E74L,
+ 1E75L,
+ 1E76L,
+ 1E77L,
+ 1E78L,
+ 1E79L,
+ 1E80L,
+ 1E81L,
+ 1E82L,
+ 1E83L,
+ 1E84L,
+ 1E85L,
+ 1E86L,
+ 1E87L,
+ 1E88L,
+ 1E89L,
+ 1E90L,
+ 1E91L,
+ 1E92L,
+ 1E93L,
+ 1E94L,
+ 1E95L,
+ 1E96L,
+ 1E97L,
+ 1E98L,
+ 1E99L,
+ 1E100L,
+ 1E101L,
+ 1E102L,
+ 1E103L,
+ 1E104L,
+ 1E105L,
+ 1E106L,
+ 1E107L,
+ 1E108L,
+ 1E109L,
+ 1E110L,
+ 1E111L,
+ 1E112L,
+ 1E113L,
+ 1E114L,
+ 1E115L,
+ 1E116L,
+ 1E117L,
+ 1E118L,
+ 1E119L,
+ 1E120L,
+ 1E121L,
+ 1E122L,
+ 1E123L,
+ 1E124L,
+ 1E125L,
+ 1E126L,
+ 1E127L,
+ 1E128L,
+ 1E129L,
+ 1E130L,
+ 1E131L,
+ 1E132L,
+ 1E133L,
+ 1E134L,
+ 1E135L,
+ 1E136L,
+ 1E137L,
+ 1E138L,
+ 1E139L,
+ 1E140L,
+ 1E141L,
+ 1E142L,
+ 1E143L,
+ 1E144L,
+ 1E145L,
+ 1E146L,
+ 1E147L,
+ 1E148L,
+ 1E149L,
+ 1E150L,
+ 1E151L,
+ 1E152L,
+ 1E153L,
+ 1E154L,
+ 1E155L,
+ 1E156L,
+ 1E157L,
+ 1E158L,
+ 1E159L,
+ 1E160L,
+ 1E161L,
+ 1E162L,
+ 1E163L,
+ 1E164L,
+ 1E165L,
+ 1E166L,
+ 1E167L,
+ 1E168L,
+ 1E169L,
+ 1E170L,
+ 1E171L,
+ 1E172L,
+ 1E173L,
+ 1E174L,
+ 1E175L,
+ 1E176L,
+ 1E177L,
+ 1E178L,
+ 1E179L,
+ 1E180L,
+ 1E181L,
+ 1E182L,
+ 1E183L,
+ 1E184L,
+ 1E185L,
+ 1E186L,
+ 1E187L,
+ 1E188L,
+ 1E189L,
+ 1E190L,
+ 1E191L,
+ 1E192L,
+ 1E193L,
+ 1E194L,
+ 1E195L,
+ 1E196L,
+ 1E197L,
+ 1E198L,
+ 1E199L,
+ 1E200L,
+ 1E201L,
+ 1E202L,
+ 1E203L,
+ 1E204L,
+ 1E205L,
+ 1E206L,
+ 1E207L,
+ 1E208L,
+ 1E209L,
+ 1E210L,
+ 1E211L,
+ 1E212L,
+ 1E213L,
+ 1E214L,
+ 1E215L,
+ 1E216L,
+ 1E217L,
+ 1E218L,
+ 1E219L,
+ 1E220L,
+ 1E221L,
+ 1E222L,
+ 1E223L,
+ 1E224L,
+ 1E225L,
+ 1E226L,
+ 1E227L,
+ 1E228L,
+ 1E229L,
+ 1E230L,
+ 1E231L,
+ 1E232L,
+ 1E233L,
+ 1E234L,
+ 1E235L,
+ 1E236L,
+ 1E237L,
+ 1E238L,
+ 1E239L,
+ 1E240L,
+ 1E241L,
+ 1E242L,
+ 1E243L,
+ 1E244L,
+ 1E245L,
+ 1E246L,
+ 1E247L,
+ 1E248L,
+ 1E249L,
+ 1E250L,
+ 1E251L,
+ 1E252L,
+ 1E253L,
+ 1E254L,
+ 1E255L,
+ 1E256L,
+ 1E257L,
+ 1E258L,
+ 1E259L,
+ 1E260L,
+ 1E261L,
+ 1E262L,
+ 1E263L,
+ 1E264L,
+ 1E265L,
+ 1E266L,
+ 1E267L,
+ 1E268L,
+ 1E269L,
+ 1E270L,
+ 1E271L,
+ 1E272L,
+ 1E273L,
+ 1E274L,
+ 1E275L,
+ 1E276L,
+ 1E277L,
+ 1E278L,
+ 1E279L,
+ 1E280L,
+ 1E281L,
+ 1E282L,
+ 1E283L,
+ 1E284L,
+ 1E285L,
+ 1E286L,
+ 1E287L,
+ 1E288L,
+ 1E289L,
+ 1E290L,
+ 1E291L,
+ 1E292L,
+ 1E293L,
+ 1E294L,
+ 1E295L,
+ 1E296L,
+ 1E297L,
+ 1E298L,
+ 1E299L,
+ 1E300L,
+ 1E301L,
+ 1E302L,
+ 1E303L,
+ 1E304L,
+ 1E305L,
+ 1E306L,
+ 1E307L,
+ 1E308L,
+ 1E309L,
+ 1E310L,
+ 1E311L,
+ 1E312L,
+ 1E313L,
+ 1E314L,
+ 1E315L,
+ 1E316L,
+ 1E317L,
+ 1E318L,
+ 1E319L,
+ 1E320L,
+ 1E321L,
+ 1E322L,
+ 1E323L,
+ 1E324L,
+ 1E325L,
+ 1E326L,
+ 1E327L,
+ 1E328L,
+ 1E329L,
+ 1E330L,
+ 1E331L,
+ 1E332L,
+ 1E333L,
+ 1E334L,
+ 1E335L,
+ 1E336L,
+ 1E337L,
+ 1E338L,
+ 1E339L,
+ 1E340L,
+ 1E341L,
+ 1E342L,
+ 1E343L,
+ 1E344L,
+ 1E345L,
+ 1E346L,
+ 1E347L,
+ 1E348L,
+ 1E349L,
+ 1E350L,
+ 1E351L,
+ 1E352L,
+ 1E353L,
+ 1E354L,
+ 1E355L,
+ 1E356L,
+ 1E357L,
+ 1E358L,
+ 1E359L,
+ 1E360L,
+ 1E361L,
+ 1E362L,
+ 1E363L,
+ 1E364L,
+ 1E365L,
+ 1E366L,
+ 1E367L,
+ 1E368L,
+ 1E369L,
+ 1E370L,
+ 1E371L,
+ 1E372L,
+ 1E373L,
+ 1E374L,
+ 1E375L,
+ 1E376L,
+ 1E377L,
+ 1E378L,
+ 1E379L,
+ 1E380L,
+ 1E381L,
+ 1E382L,
+ 1E383L,
+ 1E384L,
+ 1E385L,
+ 1E386L,
+ 1E387L,
+ 1E388L,
+ 1E389L,
+ 1E390L,
+ 1E391L,
+ 1E392L,
+ 1E393L,
+ 1E394L,
+ 1E395L,
+ 1E396L,
+ 1E397L,
+ 1E398L,
+ 1E399L,
+ 1E400L,
+ 1E401L,
+ 1E402L,
+ 1E403L,
+ 1E404L,
+ 1E405L,
+ 1E406L,
+ 1E407L,
+ 1E408L,
+ 1E409L,
+ 1E410L,
+ 1E411L,
+ 1E412L,
+ 1E413L,
+ 1E414L,
+ 1E415L,
+ 1E416L,
+ 1E417L,
+ 1E418L,
+ 1E419L,
+ 1E420L,
+ 1E421L,
+ 1E422L,
+ 1E423L,
+ 1E424L,
+ 1E425L,
+ 1E426L,
+ 1E427L,
+ 1E428L,
+ 1E429L,
+ 1E430L,
+ 1E431L,
+ 1E432L,
+ 1E433L,
+ 1E434L,
+ 1E435L,
+ 1E436L,
+ 1E437L,
+ 1E438L,
+ 1E439L,
+ 1E440L,
+ 1E441L,
+ 1E442L,
+ 1E443L,
+ 1E444L,
+ 1E445L,
+ 1E446L,
+ 1E447L,
+ 1E448L,
+ 1E449L,
+ 1E450L,
+ 1E451L,
+ 1E452L,
+ 1E453L,
+ 1E454L,
+ 1E455L,
+ 1E456L,
+ 1E457L,
+ 1E458L,
+ 1E459L,
+ 1E460L,
+ 1E461L,
+ 1E462L,
+ 1E463L,
+ 1E464L,
+ 1E465L,
+ 1E466L,
+ 1E467L,
+ 1E468L,
+ 1E469L,
+ 1E470L,
+ 1E471L,
+ 1E472L,
+ 1E473L,
+ 1E474L,
+ 1E475L,
+ 1E476L,
+ 1E477L,
+ 1E478L,
+ 1E479L,
+ 1E480L,
+ 1E481L,
+ 1E482L,
+ 1E483L,
+ 1E484L,
+ 1E485L,
+ 1E486L,
+ 1E487L,
+ 1E488L,
+ 1E489L,
+ 1E490L,
+ 1E491L,
+ 1E492L,
+ 1E493L,
+ 1E494L,
+ 1E495L,
+ 1E496L,
+ 1E497L,
+ 1E498L,
+ 1E499L,
+ 1E500L,
+ 1E501L,
+ 1E502L,
+ 1E503L,
+ 1E504L,
+ 1E505L,
+ 1E506L,
+ 1E507L,
+ 1E508L,
+ 1E509L,
+ 1E510L,
+ 1E511L,
+ 1E512L,
+ 1E513L,
+ 1E514L,
+ 1E515L,
+ 1E516L,
+ 1E517L,
+ 1E518L,
+ 1E519L,
+ 1E520L,
+ 1E521L,
+ 1E522L,
+ 1E523L,
+ 1E524L,
+ 1E525L,
+ 1E526L,
+ 1E527L,
+ 1E528L,
+ 1E529L,
+ 1E530L,
+ 1E531L,
+ 1E532L,
+ 1E533L,
+ 1E534L,
+ 1E535L,
+ 1E536L,
+ 1E537L,
+ 1E538L,
+ 1E539L,
+ 1E540L,
+ 1E541L,
+ 1E542L,
+ 1E543L,
+ 1E544L,
+ 1E545L,
+ 1E546L,
+ 1E547L,
+ 1E548L,
+ 1E549L,
+ 1E550L,
+ 1E551L,
+ 1E552L,
+ 1E553L,
+ 1E554L,
+ 1E555L,
+ 1E556L,
+ 1E557L,
+ 1E558L,
+ 1E559L,
+ 1E560L,
+ 1E561L,
+ 1E562L,
+ 1E563L,
+ 1E564L,
+ 1E565L,
+ 1E566L,
+ 1E567L,
+ 1E568L,
+ 1E569L,
+ 1E570L,
+ 1E571L,
+ 1E572L,
+ 1E573L,
+ 1E574L,
+ 1E575L,
+ 1E576L,
+ 1E577L,
+ 1E578L,
+ 1E579L,
+ 1E580L,
+ 1E581L,
+ 1E582L,
+ 1E583L,
+ 1E584L,
+ 1E585L,
+ 1E586L,
+ 1E587L,
+ 1E588L,
+ 1E589L,
+ 1E590L,
+ 1E591L,
+ 1E592L,
+ 1E593L,
+ 1E594L,
+ 1E595L,
+ 1E596L,
+ 1E597L,
+ 1E598L,
+ 1E599L,
+ 1E600L,
+ 1E601L,
+ 1E602L,
+ 1E603L,
+ 1E604L,
+ 1E605L,
+ 1E606L,
+ 1E607L,
+ 1E608L,
+ 1E609L,
+ 1E610L,
+ 1E611L,
+ 1E612L,
+ 1E613L,
+ 1E614L,
+ 1E615L,
+ 1E616L,
+ 1E617L,
+ 1E618L,
+ 1E619L,
+ 1E620L,
+ 1E621L,
+ 1E622L,
+ 1E623L,
+ 1E624L,
+ 1E625L,
+ 1E626L,
+ 1E627L,
+ 1E628L,
+ 1E629L,
+ 1E630L,
+ 1E631L,
+ 1E632L,
+ 1E633L,
+ 1E634L,
+ 1E635L,
+ 1E636L,
+ 1E637L,
+ 1E638L,
+ 1E639L,
+ 1E640L,
+ 1E641L,
+ 1E642L,
+ 1E643L,
+ 1E644L,
+ 1E645L,
+ 1E646L,
+ 1E647L,
+ 1E648L,
+ 1E649L,
+ 1E650L,
+ 1E651L,
+ 1E652L,
+ 1E653L,
+ 1E654L,
+ 1E655L,
+ 1E656L,
+ 1E657L,
+ 1E658L,
+ 1E659L,
+ 1E660L,
+ 1E661L,
+ 1E662L,
+ 1E663L,
+ 1E664L,
+ 1E665L,
+ 1E666L,
+ 1E667L,
+ 1E668L,
+ 1E669L,
+ 1E670L,
+ 1E671L,
+ 1E672L,
+ 1E673L,
+ 1E674L,
+ 1E675L,
+ 1E676L,
+ 1E677L,
+ 1E678L,
+ 1E679L,
+ 1E680L,
+ 1E681L,
+ 1E682L,
+ 1E683L,
+ 1E684L,
+ 1E685L,
+ 1E686L,
+ 1E687L,
+ 1E688L,
+ 1E689L,
+ 1E690L,
+ 1E691L,
+ 1E692L,
+ 1E693L,
+ 1E694L,
+ 1E695L,
+ 1E696L,
+ 1E697L,
+ 1E698L,
+ 1E699L,
+ 1E700L,
+ 1E701L,
+ 1E702L,
+ 1E703L,
+ 1E704L,
+ 1E705L,
+ 1E706L,
+ 1E707L,
+ 1E708L,
+ 1E709L,
+ 1E710L,
+ 1E711L,
+ 1E712L,
+ 1E713L,
+ 1E714L,
+ 1E715L,
+ 1E716L,
+ 1E717L,
+ 1E718L,
+ 1E719L,
+ 1E720L,
+ 1E721L,
+ 1E722L,
+ 1E723L,
+ 1E724L,
+ 1E725L,
+ 1E726L,
+ 1E727L,
+ 1E728L,
+ 1E729L,
+ 1E730L,
+ 1E731L,
+ 1E732L,
+ 1E733L,
+ 1E734L,
+ 1E735L,
+ 1E736L,
+ 1E737L,
+ 1E738L,
+ 1E739L,
+ 1E740L,
+ 1E741L,
+ 1E742L,
+ 1E743L,
+ 1E744L,
+ 1E745L,
+ 1E746L,
+ 1E747L,
+ 1E748L,
+ 1E749L,
+ 1E750L,
+ 1E751L,
+ 1E752L,
+ 1E753L,
+ 1E754L,
+ 1E755L,
+ 1E756L,
+ 1E757L,
+ 1E758L,
+ 1E759L,
+ 1E760L,
+ 1E761L,
+ 1E762L,
+ 1E763L,
+ 1E764L,
+ 1E765L,
+ 1E766L,
+ 1E767L,
+ 1E768L,
+ 1E769L,
+ 1E770L,
+ 1E771L,
+ 1E772L,
+ 1E773L,
+ 1E774L,
+ 1E775L,
+ 1E776L,
+ 1E777L,
+ 1E778L,
+ 1E779L,
+ 1E780L,
+ 1E781L,
+ 1E782L,
+ 1E783L,
+ 1E784L,
+ 1E785L,
+ 1E786L,
+ 1E787L,
+ 1E788L,
+ 1E789L,
+ 1E790L,
+ 1E791L,
+ 1E792L,
+ 1E793L,
+ 1E794L,
+ 1E795L,
+ 1E796L,
+ 1E797L,
+ 1E798L,
+ 1E799L,
+ 1E800L,
+ 1E801L,
+ 1E802L,
+ 1E803L,
+ 1E804L,
+ 1E805L,
+ 1E806L,
+ 1E807L,
+ 1E808L,
+ 1E809L,
+ 1E810L,
+ 1E811L,
+ 1E812L,
+ 1E813L,
+ 1E814L,
+ 1E815L,
+ 1E816L,
+ 1E817L,
+ 1E818L,
+ 1E819L,
+ 1E820L,
+ 1E821L,
+ 1E822L,
+ 1E823L,
+ 1E824L,
+ 1E825L,
+ 1E826L,
+ 1E827L,
+ 1E828L,
+ 1E829L,
+ 1E830L,
+ 1E831L,
+ 1E832L,
+ 1E833L,
+ 1E834L,
+ 1E835L,
+ 1E836L,
+ 1E837L,
+ 1E838L,
+ 1E839L,
+ 1E840L,
+ 1E841L,
+ 1E842L,
+ 1E843L,
+ 1E844L,
+ 1E845L,
+ 1E846L,
+ 1E847L,
+ 1E848L,
+ 1E849L,
+ 1E850L,
+ 1E851L,
+ 1E852L,
+ 1E853L,
+ 1E854L,
+ 1E855L,
+ 1E856L,
+ 1E857L,
+ 1E858L,
+ 1E859L,
+ 1E860L,
+ 1E861L,
+ 1E862L,
+ 1E863L,
+ 1E864L,
+ 1E865L,
+ 1E866L,
+ 1E867L,
+ 1E868L,
+ 1E869L,
+ 1E870L,
+ 1E871L,
+ 1E872L,
+ 1E873L,
+ 1E874L,
+ 1E875L,
+ 1E876L,
+ 1E877L,
+ 1E878L,
+ 1E879L,
+ 1E880L,
+ 1E881L,
+ 1E882L,
+ 1E883L,
+ 1E884L,
+ 1E885L,
+ 1E886L,
+ 1E887L,
+ 1E888L,
+ 1E889L,
+ 1E890L,
+ 1E891L,
+ 1E892L,
+ 1E893L,
+ 1E894L,
+ 1E895L,
+ 1E896L,
+ 1E897L,
+ 1E898L,
+ 1E899L,
+ 1E900L,
+ 1E901L,
+ 1E902L,
+ 1E903L,
+ 1E904L,
+ 1E905L,
+ 1E906L,
+ 1E907L,
+ 1E908L,
+ 1E909L,
+ 1E910L,
+ 1E911L,
+ 1E912L,
+ 1E913L,
+ 1E914L,
+ 1E915L,
+ 1E916L,
+ 1E917L,
+ 1E918L,
+ 1E919L,
+ 1E920L,
+ 1E921L,
+ 1E922L,
+ 1E923L,
+ 1E924L,
+ 1E925L,
+ 1E926L,
+ 1E927L,
+ 1E928L,
+ 1E929L,
+ 1E930L,
+ 1E931L,
+ 1E932L,
+ 1E933L,
+ 1E934L,
+ 1E935L,
+ 1E936L,
+ 1E937L,
+ 1E938L,
+ 1E939L,
+ 1E940L,
+ 1E941L,
+ 1E942L,
+ 1E943L,
+ 1E944L,
+ 1E945L,
+ 1E946L,
+ 1E947L,
+ 1E948L,
+ 1E949L,
+ 1E950L,
+ 1E951L,
+ 1E952L,
+ 1E953L,
+ 1E954L,
+ 1E955L,
+ 1E956L,
+ 1E957L,
+ 1E958L,
+ 1E959L,
+ 1E960L,
+ 1E961L,
+ 1E962L,
+ 1E963L,
+ 1E964L,
+ 1E965L,
+ 1E966L,
+ 1E967L,
+ 1E968L,
+ 1E969L,
+ 1E970L,
+ 1E971L,
+ 1E972L,
+ 1E973L,
+ 1E974L,
+ 1E975L,
+ 1E976L,
+ 1E977L,
+ 1E978L,
+ 1E979L,
+ 1E980L,
+ 1E981L,
+ 1E982L,
+ 1E983L,
+ 1E984L,
+ 1E985L,
+ 1E986L,
+ 1E987L,
+ 1E988L,
+ 1E989L,
+ 1E990L,
+ 1E991L,
+ 1E992L,
+ 1E993L,
+ 1E994L,
+ 1E995L,
+ 1E996L,
+ 1E997L,
+ 1E998L,
+ 1E999L,
+ 1E1000L,
+ 1E1001L,
+ 1E1002L,
+ 1E1003L,
+ 1E1004L,
+ 1E1005L,
+ 1E1006L,
+ 1E1007L,
+ 1E1008L,
+ 1E1009L,
+ 1E1010L,
+ 1E1011L,
+ 1E1012L,
+ 1E1013L,
+ 1E1014L,
+ 1E1015L,
+ 1E1016L,
+ 1E1017L,
+ 1E1018L,
+ 1E1019L,
+ 1E1020L,
+ 1E1021L,
+ 1E1022L,
+ 1E1023L,
+ 1E1024L,
+ 1E1025L,
+ 1E1026L,
+ 1E1027L,
+ 1E1028L,
+ 1E1029L,
+ 1E1030L,
+ 1E1031L,
+ 1E1032L,
+ 1E1033L,
+ 1E1034L,
+ 1E1035L,
+ 1E1036L,
+ 1E1037L,
+ 1E1038L,
+ 1E1039L,
+ 1E1040L,
+ 1E1041L,
+ 1E1042L,
+ 1E1043L,
+ 1E1044L,
+ 1E1045L,
+ 1E1046L,
+ 1E1047L,
+ 1E1048L,
+ 1E1049L,
+ 1E1050L,
+ 1E1051L,
+ 1E1052L,
+ 1E1053L,
+ 1E1054L,
+ 1E1055L,
+ 1E1056L,
+ 1E1057L,
+ 1E1058L,
+ 1E1059L,
+ 1E1060L,
+ 1E1061L,
+ 1E1062L,
+ 1E1063L,
+ 1E1064L,
+ 1E1065L,
+ 1E1066L,
+ 1E1067L,
+ 1E1068L,
+ 1E1069L,
+ 1E1070L,
+ 1E1071L,
+ 1E1072L,
+ 1E1073L,
+ 1E1074L,
+ 1E1075L,
+ 1E1076L,
+ 1E1077L,
+ 1E1078L,
+ 1E1079L,
+ 1E1080L,
+ 1E1081L,
+ 1E1082L,
+ 1E1083L,
+ 1E1084L,
+ 1E1085L,
+ 1E1086L,
+ 1E1087L,
+ 1E1088L,
+ 1E1089L,
+ 1E1090L,
+ 1E1091L,
+ 1E1092L,
+ 1E1093L,
+ 1E1094L,
+ 1E1095L,
+ 1E1096L,
+ 1E1097L,
+ 1E1098L,
+ 1E1099L,
+ 1E1100L,
+ 1E1101L,
+ 1E1102L,
+ 1E1103L,
+ 1E1104L,
+ 1E1105L,
+ 1E1106L,
+ 1E1107L,
+ 1E1108L,
+ 1E1109L,
+ 1E1110L,
+ 1E1111L,
+ 1E1112L,
+ 1E1113L,
+ 1E1114L,
+ 1E1115L,
+ 1E1116L,
+ 1E1117L,
+ 1E1118L,
+ 1E1119L,
+ 1E1120L,
+ 1E1121L,
+ 1E1122L,
+ 1E1123L,
+ 1E1124L,
+ 1E1125L,
+ 1E1126L,
+ 1E1127L,
+ 1E1128L,
+ 1E1129L,
+ 1E1130L,
+ 1E1131L,
+ 1E1132L,
+ 1E1133L,
+ 1E1134L,
+ 1E1135L,
+ 1E1136L,
+ 1E1137L,
+ 1E1138L,
+ 1E1139L,
+ 1E1140L,
+ 1E1141L,
+ 1E1142L,
+ 1E1143L,
+ 1E1144L,
+ 1E1145L,
+ 1E1146L,
+ 1E1147L,
+ 1E1148L,
+ 1E1149L,
+ 1E1150L,
+ 1E1151L,
+ 1E1152L,
+ 1E1153L,
+ 1E1154L,
+ 1E1155L,
+ 1E1156L,
+ 1E1157L,
+ 1E1158L,
+ 1E1159L,
+ 1E1160L,
+ 1E1161L,
+ 1E1162L,
+ 1E1163L,
+ 1E1164L,
+ 1E1165L,
+ 1E1166L,
+ 1E1167L,
+ 1E1168L,
+ 1E1169L,
+ 1E1170L,
+ 1E1171L,
+ 1E1172L,
+ 1E1173L,
+ 1E1174L,
+ 1E1175L,
+ 1E1176L,
+ 1E1177L,
+ 1E1178L,
+ 1E1179L,
+ 1E1180L,
+ 1E1181L,
+ 1E1182L,
+ 1E1183L,
+ 1E1184L,
+ 1E1185L,
+ 1E1186L,
+ 1E1187L,
+ 1E1188L,
+ 1E1189L,
+ 1E1190L,
+ 1E1191L,
+ 1E1192L,
+ 1E1193L,
+ 1E1194L,
+ 1E1195L,
+ 1E1196L,
+ 1E1197L,
+ 1E1198L,
+ 1E1199L,
+ 1E1200L,
+ 1E1201L,
+ 1E1202L,
+ 1E1203L,
+ 1E1204L,
+ 1E1205L,
+ 1E1206L,
+ 1E1207L,
+ 1E1208L,
+ 1E1209L,
+ 1E1210L,
+ 1E1211L,
+ 1E1212L,
+ 1E1213L,
+ 1E1214L,
+ 1E1215L,
+ 1E1216L,
+ 1E1217L,
+ 1E1218L,
+ 1E1219L,
+ 1E1220L,
+ 1E1221L,
+ 1E1222L,
+ 1E1223L,
+ 1E1224L,
+ 1E1225L,
+ 1E1226L,
+ 1E1227L,
+ 1E1228L,
+ 1E1229L,
+ 1E1230L,
+ 1E1231L,
+ 1E1232L,
+ 1E1233L,
+ 1E1234L,
+ 1E1235L,
+ 1E1236L,
+ 1E1237L,
+ 1E1238L,
+ 1E1239L,
+ 1E1240L,
+ 1E1241L,
+ 1E1242L,
+ 1E1243L,
+ 1E1244L,
+ 1E1245L,
+ 1E1246L,
+ 1E1247L,
+ 1E1248L,
+ 1E1249L,
+ 1E1250L,
+ 1E1251L,
+ 1E1252L,
+ 1E1253L,
+ 1E1254L,
+ 1E1255L,
+ 1E1256L,
+ 1E1257L,
+ 1E1258L,
+ 1E1259L,
+ 1E1260L,
+ 1E1261L,
+ 1E1262L,
+ 1E1263L,
+ 1E1264L,
+ 1E1265L,
+ 1E1266L,
+ 1E1267L,
+ 1E1268L,
+ 1E1269L,
+ 1E1270L,
+ 1E1271L,
+ 1E1272L,
+ 1E1273L,
+ 1E1274L,
+ 1E1275L,
+ 1E1276L,
+ 1E1277L,
+ 1E1278L,
+ 1E1279L,
+ 1E1280L,
+ 1E1281L,
+ 1E1282L,
+ 1E1283L,
+ 1E1284L,
+ 1E1285L,
+ 1E1286L,
+ 1E1287L,
+ 1E1288L,
+ 1E1289L,
+ 1E1290L,
+ 1E1291L,
+ 1E1292L,
+ 1E1293L,
+ 1E1294L,
+ 1E1295L,
+ 1E1296L,
+ 1E1297L,
+ 1E1298L,
+ 1E1299L,
+ 1E1300L,
+ 1E1301L,
+ 1E1302L,
+ 1E1303L,
+ 1E1304L,
+ 1E1305L,
+ 1E1306L,
+ 1E1307L,
+ 1E1308L,
+ 1E1309L,
+ 1E1310L,
+ 1E1311L,
+ 1E1312L,
+ 1E1313L,
+ 1E1314L,
+ 1E1315L,
+ 1E1316L,
+ 1E1317L,
+ 1E1318L,
+ 1E1319L,
+ 1E1320L,
+ 1E1321L,
+ 1E1322L,
+ 1E1323L,
+ 1E1324L,
+ 1E1325L,
+ 1E1326L,
+ 1E1327L,
+ 1E1328L,
+ 1E1329L,
+ 1E1330L,
+ 1E1331L,
+ 1E1332L,
+ 1E1333L,
+ 1E1334L,
+ 1E1335L,
+ 1E1336L,
+ 1E1337L,
+ 1E1338L,
+ 1E1339L,
+ 1E1340L,
+ 1E1341L,
+ 1E1342L,
+ 1E1343L,
+ 1E1344L,
+ 1E1345L,
+ 1E1346L,
+ 1E1347L,
+ 1E1348L,
+ 1E1349L,
+ 1E1350L,
+ 1E1351L,
+ 1E1352L,
+ 1E1353L,
+ 1E1354L,
+ 1E1355L,
+ 1E1356L,
+ 1E1357L,
+ 1E1358L,
+ 1E1359L,
+ 1E1360L,
+ 1E1361L,
+ 1E1362L,
+ 1E1363L,
+ 1E1364L,
+ 1E1365L,
+ 1E1366L,
+ 1E1367L,
+ 1E1368L,
+ 1E1369L,
+ 1E1370L,
+ 1E1371L,
+ 1E1372L,
+ 1E1373L,
+ 1E1374L,
+ 1E1375L,
+ 1E1376L,
+ 1E1377L,
+ 1E1378L,
+ 1E1379L,
+ 1E1380L,
+ 1E1381L,
+ 1E1382L,
+ 1E1383L,
+ 1E1384L,
+ 1E1385L,
+ 1E1386L,
+ 1E1387L,
+ 1E1388L,
+ 1E1389L,
+ 1E1390L,
+ 1E1391L,
+ 1E1392L,
+ 1E1393L,
+ 1E1394L,
+ 1E1395L,
+ 1E1396L,
+ 1E1397L,
+ 1E1398L,
+ 1E1399L,
+ 1E1400L,
+ 1E1401L,
+ 1E1402L,
+ 1E1403L,
+ 1E1404L,
+ 1E1405L,
+ 1E1406L,
+ 1E1407L,
+ 1E1408L,
+ 1E1409L,
+ 1E1410L,
+ 1E1411L,
+ 1E1412L,
+ 1E1413L,
+ 1E1414L,
+ 1E1415L,
+ 1E1416L,
+ 1E1417L,
+ 1E1418L,
+ 1E1419L,
+ 1E1420L,
+ 1E1421L,
+ 1E1422L,
+ 1E1423L,
+ 1E1424L,
+ 1E1425L,
+ 1E1426L,
+ 1E1427L,
+ 1E1428L,
+ 1E1429L,
+ 1E1430L,
+ 1E1431L,
+ 1E1432L,
+ 1E1433L,
+ 1E1434L,
+ 1E1435L,
+ 1E1436L,
+ 1E1437L,
+ 1E1438L,
+ 1E1439L,
+ 1E1440L,
+ 1E1441L,
+ 1E1442L,
+ 1E1443L,
+ 1E1444L,
+ 1E1445L,
+ 1E1446L,
+ 1E1447L,
+ 1E1448L,
+ 1E1449L,
+ 1E1450L,
+ 1E1451L,
+ 1E1452L,
+ 1E1453L,
+ 1E1454L,
+ 1E1455L,
+ 1E1456L,
+ 1E1457L,
+ 1E1458L,
+ 1E1459L,
+ 1E1460L,
+ 1E1461L,
+ 1E1462L,
+ 1E1463L,
+ 1E1464L,
+ 1E1465L,
+ 1E1466L,
+ 1E1467L,
+ 1E1468L,
+ 1E1469L,
+ 1E1470L,
+ 1E1471L,
+ 1E1472L,
+ 1E1473L,
+ 1E1474L,
+ 1E1475L,
+ 1E1476L,
+ 1E1477L,
+ 1E1478L,
+ 1E1479L,
+ 1E1480L,
+ 1E1481L,
+ 1E1482L,
+ 1E1483L,
+ 1E1484L,
+ 1E1485L,
+ 1E1486L,
+ 1E1487L,
+ 1E1488L,
+ 1E1489L,
+ 1E1490L,
+ 1E1491L,
+ 1E1492L,
+ 1E1493L,
+ 1E1494L,
+ 1E1495L,
+ 1E1496L,
+ 1E1497L,
+ 1E1498L,
+ 1E1499L,
+ 1E1500L,
+ 1E1501L,
+ 1E1502L,
+ 1E1503L,
+ 1E1504L,
+ 1E1505L,
+ 1E1506L,
+ 1E1507L,
+ 1E1508L,
+ 1E1509L,
+ 1E1510L,
+ 1E1511L,
+ 1E1512L,
+ 1E1513L,
+ 1E1514L,
+ 1E1515L,
+ 1E1516L,
+ 1E1517L,
+ 1E1518L,
+ 1E1519L,
+ 1E1520L,
+ 1E1521L,
+ 1E1522L,
+ 1E1523L,
+ 1E1524L,
+ 1E1525L,
+ 1E1526L,
+ 1E1527L,
+ 1E1528L,
+ 1E1529L,
+ 1E1530L,
+ 1E1531L,
+ 1E1532L,
+ 1E1533L,
+ 1E1534L,
+ 1E1535L,
+ 1E1536L,
+ 1E1537L,
+ 1E1538L,
+ 1E1539L,
+ 1E1540L,
+ 1E1541L,
+ 1E1542L,
+ 1E1543L,
+ 1E1544L,
+ 1E1545L,
+ 1E1546L,
+ 1E1547L,
+ 1E1548L,
+ 1E1549L,
+ 1E1550L,
+ 1E1551L,
+ 1E1552L,
+ 1E1553L,
+ 1E1554L,
+ 1E1555L,
+ 1E1556L,
+ 1E1557L,
+ 1E1558L,
+ 1E1559L,
+ 1E1560L,
+ 1E1561L,
+ 1E1562L,
+ 1E1563L,
+ 1E1564L,
+ 1E1565L,
+ 1E1566L,
+ 1E1567L,
+ 1E1568L,
+ 1E1569L,
+ 1E1570L,
+ 1E1571L,
+ 1E1572L,
+ 1E1573L,
+ 1E1574L,
+ 1E1575L,
+ 1E1576L,
+ 1E1577L,
+ 1E1578L,
+ 1E1579L,
+ 1E1580L,
+ 1E1581L,
+ 1E1582L,
+ 1E1583L,
+ 1E1584L,
+ 1E1585L,
+ 1E1586L,
+ 1E1587L,
+ 1E1588L,
+ 1E1589L,
+ 1E1590L,
+ 1E1591L,
+ 1E1592L,
+ 1E1593L,
+ 1E1594L,
+ 1E1595L,
+ 1E1596L,
+ 1E1597L,
+ 1E1598L,
+ 1E1599L,
+ 1E1600L,
+ 1E1601L,
+ 1E1602L,
+ 1E1603L,
+ 1E1604L,
+ 1E1605L,
+ 1E1606L,
+ 1E1607L,
+ 1E1608L,
+ 1E1609L,
+ 1E1610L,
+ 1E1611L,
+ 1E1612L,
+ 1E1613L,
+ 1E1614L,
+ 1E1615L,
+ 1E1616L,
+ 1E1617L,
+ 1E1618L,
+ 1E1619L,
+ 1E1620L,
+ 1E1621L,
+ 1E1622L,
+ 1E1623L,
+ 1E1624L,
+ 1E1625L,
+ 1E1626L,
+ 1E1627L,
+ 1E1628L,
+ 1E1629L,
+ 1E1630L,
+ 1E1631L,
+ 1E1632L,
+ 1E1633L,
+ 1E1634L,
+ 1E1635L,
+ 1E1636L,
+ 1E1637L,
+ 1E1638L,
+ 1E1639L,
+ 1E1640L,
+ 1E1641L,
+ 1E1642L,
+ 1E1643L,
+ 1E1644L,
+ 1E1645L,
+ 1E1646L,
+ 1E1647L,
+ 1E1648L,
+ 1E1649L,
+ 1E1650L,
+ 1E1651L,
+ 1E1652L,
+ 1E1653L,
+ 1E1654L,
+ 1E1655L,
+ 1E1656L,
+ 1E1657L,
+ 1E1658L,
+ 1E1659L,
+ 1E1660L,
+ 1E1661L,
+ 1E1662L,
+ 1E1663L,
+ 1E1664L,
+ 1E1665L,
+ 1E1666L,
+ 1E1667L,
+ 1E1668L,
+ 1E1669L,
+ 1E1670L,
+ 1E1671L,
+ 1E1672L,
+ 1E1673L,
+ 1E1674L,
+ 1E1675L,
+ 1E1676L,
+ 1E1677L,
+ 1E1678L,
+ 1E1679L,
+ 1E1680L,
+ 1E1681L,
+ 1E1682L,
+ 1E1683L,
+ 1E1684L,
+ 1E1685L,
+ 1E1686L,
+ 1E1687L,
+ 1E1688L,
+ 1E1689L,
+ 1E1690L,
+ 1E1691L,
+ 1E1692L,
+ 1E1693L,
+ 1E1694L,
+ 1E1695L,
+ 1E1696L,
+ 1E1697L,
+ 1E1698L,
+ 1E1699L,
+ 1E1700L,
+ 1E1701L,
+ 1E1702L,
+ 1E1703L,
+ 1E1704L,
+ 1E1705L,
+ 1E1706L,
+ 1E1707L,
+ 1E1708L,
+ 1E1709L,
+ 1E1710L,
+ 1E1711L,
+ 1E1712L,
+ 1E1713L,
+ 1E1714L,
+ 1E1715L,
+ 1E1716L,
+ 1E1717L,
+ 1E1718L,
+ 1E1719L,
+ 1E1720L,
+ 1E1721L,
+ 1E1722L,
+ 1E1723L,
+ 1E1724L,
+ 1E1725L,
+ 1E1726L,
+ 1E1727L,
+ 1E1728L,
+ 1E1729L,
+ 1E1730L,
+ 1E1731L,
+ 1E1732L,
+ 1E1733L,
+ 1E1734L,
+ 1E1735L,
+ 1E1736L,
+ 1E1737L,
+ 1E1738L,
+ 1E1739L,
+ 1E1740L,
+ 1E1741L,
+ 1E1742L,
+ 1E1743L,
+ 1E1744L,
+ 1E1745L,
+ 1E1746L,
+ 1E1747L,
+ 1E1748L,
+ 1E1749L,
+ 1E1750L,
+ 1E1751L,
+ 1E1752L,
+ 1E1753L,
+ 1E1754L,
+ 1E1755L,
+ 1E1756L,
+ 1E1757L,
+ 1E1758L,
+ 1E1759L,
+ 1E1760L,
+ 1E1761L,
+ 1E1762L,
+ 1E1763L,
+ 1E1764L,
+ 1E1765L,
+ 1E1766L,
+ 1E1767L,
+ 1E1768L,
+ 1E1769L,
+ 1E1770L,
+ 1E1771L,
+ 1E1772L,
+ 1E1773L,
+ 1E1774L,
+ 1E1775L,
+ 1E1776L,
+ 1E1777L,
+ 1E1778L,
+ 1E1779L,
+ 1E1780L,
+ 1E1781L,
+ 1E1782L,
+ 1E1783L,
+ 1E1784L,
+ 1E1785L,
+ 1E1786L,
+ 1E1787L,
+ 1E1788L,
+ 1E1789L,
+ 1E1790L,
+ 1E1791L,
+ 1E1792L,
+ 1E1793L,
+ 1E1794L,
+ 1E1795L,
+ 1E1796L,
+ 1E1797L,
+ 1E1798L,
+ 1E1799L,
+ 1E1800L,
+ 1E1801L,
+ 1E1802L,
+ 1E1803L,
+ 1E1804L,
+ 1E1805L,
+ 1E1806L,
+ 1E1807L,
+ 1E1808L,
+ 1E1809L,
+ 1E1810L,
+ 1E1811L,
+ 1E1812L,
+ 1E1813L,
+ 1E1814L,
+ 1E1815L,
+ 1E1816L,
+ 1E1817L,
+ 1E1818L,
+ 1E1819L,
+ 1E1820L,
+ 1E1821L,
+ 1E1822L,
+ 1E1823L,
+ 1E1824L,
+ 1E1825L,
+ 1E1826L,
+ 1E1827L,
+ 1E1828L,
+ 1E1829L,
+ 1E1830L,
+ 1E1831L,
+ 1E1832L,
+ 1E1833L,
+ 1E1834L,
+ 1E1835L,
+ 1E1836L,
+ 1E1837L,
+ 1E1838L,
+ 1E1839L,
+ 1E1840L,
+ 1E1841L,
+ 1E1842L,
+ 1E1843L,
+ 1E1844L,
+ 1E1845L,
+ 1E1846L,
+ 1E1847L,
+ 1E1848L,
+ 1E1849L,
+ 1E1850L,
+ 1E1851L,
+ 1E1852L,
+ 1E1853L,
+ 1E1854L,
+ 1E1855L,
+ 1E1856L,
+ 1E1857L,
+ 1E1858L,
+ 1E1859L,
+ 1E1860L,
+ 1E1861L,
+ 1E1862L,
+ 1E1863L,
+ 1E1864L,
+ 1E1865L,
+ 1E1866L,
+ 1E1867L,
+ 1E1868L,
+ 1E1869L,
+ 1E1870L,
+ 1E1871L,
+ 1E1872L,
+ 1E1873L,
+ 1E1874L,
+ 1E1875L,
+ 1E1876L,
+ 1E1877L,
+ 1E1878L,
+ 1E1879L,
+ 1E1880L,
+ 1E1881L,
+ 1E1882L,
+ 1E1883L,
+ 1E1884L,
+ 1E1885L,
+ 1E1886L,
+ 1E1887L,
+ 1E1888L,
+ 1E1889L,
+ 1E1890L,
+ 1E1891L,
+ 1E1892L,
+ 1E1893L,
+ 1E1894L,
+ 1E1895L,
+ 1E1896L,
+ 1E1897L,
+ 1E1898L,
+ 1E1899L,
+ 1E1900L,
+ 1E1901L,
+ 1E1902L,
+ 1E1903L,
+ 1E1904L,
+ 1E1905L,
+ 1E1906L,
+ 1E1907L,
+ 1E1908L,
+ 1E1909L,
+ 1E1910L,
+ 1E1911L,
+ 1E1912L,
+ 1E1913L,
+ 1E1914L,
+ 1E1915L,
+ 1E1916L,
+ 1E1917L,
+ 1E1918L,
+ 1E1919L,
+ 1E1920L,
+ 1E1921L,
+ 1E1922L,
+ 1E1923L,
+ 1E1924L,
+ 1E1925L,
+ 1E1926L,
+ 1E1927L,
+ 1E1928L,
+ 1E1929L,
+ 1E1930L,
+ 1E1931L,
+ 1E1932L,
+ 1E1933L,
+ 1E1934L,
+ 1E1935L,
+ 1E1936L,
+ 1E1937L,
+ 1E1938L,
+ 1E1939L,
+ 1E1940L,
+ 1E1941L,
+ 1E1942L,
+ 1E1943L,
+ 1E1944L,
+ 1E1945L,
+ 1E1946L,
+ 1E1947L,
+ 1E1948L,
+ 1E1949L,
+ 1E1950L,
+ 1E1951L,
+ 1E1952L,
+ 1E1953L,
+ 1E1954L,
+ 1E1955L,
+ 1E1956L,
+ 1E1957L,
+ 1E1958L,
+ 1E1959L,
+ 1E1960L,
+ 1E1961L,
+ 1E1962L,
+ 1E1963L,
+ 1E1964L,
+ 1E1965L,
+ 1E1966L,
+ 1E1967L,
+ 1E1968L,
+ 1E1969L,
+ 1E1970L,
+ 1E1971L,
+ 1E1972L,
+ 1E1973L,
+ 1E1974L,
+ 1E1975L,
+ 1E1976L,
+ 1E1977L,
+ 1E1978L,
+ 1E1979L,
+ 1E1980L,
+ 1E1981L,
+ 1E1982L,
+ 1E1983L,
+ 1E1984L,
+ 1E1985L,
+ 1E1986L,
+ 1E1987L,
+ 1E1988L,
+ 1E1989L,
+ 1E1990L,
+ 1E1991L,
+ 1E1992L,
+ 1E1993L,
+ 1E1994L,
+ 1E1995L,
+ 1E1996L,
+ 1E1997L,
+ 1E1998L,
+ 1E1999L,
+ 1E2000L,
+ 1E2001L,
+ 1E2002L,
+ 1E2003L,
+ 1E2004L,
+ 1E2005L,
+ 1E2006L,
+ 1E2007L,
+ 1E2008L,
+ 1E2009L,
+ 1E2010L,
+ 1E2011L,
+ 1E2012L,
+ 1E2013L,
+ 1E2014L,
+ 1E2015L,
+ 1E2016L,
+ 1E2017L,
+ 1E2018L,
+ 1E2019L,
+ 1E2020L,
+ 1E2021L,
+ 1E2022L,
+ 1E2023L,
+ 1E2024L,
+ 1E2025L,
+ 1E2026L,
+ 1E2027L,
+ 1E2028L,
+ 1E2029L,
+ 1E2030L,
+ 1E2031L,
+ 1E2032L,
+ 1E2033L,
+ 1E2034L,
+ 1E2035L,
+ 1E2036L,
+ 1E2037L,
+ 1E2038L,
+ 1E2039L,
+ 1E2040L,
+ 1E2041L,
+ 1E2042L,
+ 1E2043L,
+ 1E2044L,
+ 1E2045L,
+ 1E2046L,
+ 1E2047L,
+ 1E2048L,
+ 1E2049L,
+ 1E2050L,
+ 1E2051L,
+ 1E2052L,
+ 1E2053L,
+ 1E2054L,
+ 1E2055L,
+ 1E2056L,
+ 1E2057L,
+ 1E2058L,
+ 1E2059L,
+ 1E2060L,
+ 1E2061L,
+ 1E2062L,
+ 1E2063L,
+ 1E2064L,
+ 1E2065L,
+ 1E2066L,
+ 1E2067L,
+ 1E2068L,
+ 1E2069L,
+ 1E2070L,
+ 1E2071L,
+ 1E2072L,
+ 1E2073L,
+ 1E2074L,
+ 1E2075L,
+ 1E2076L,
+ 1E2077L,
+ 1E2078L,
+ 1E2079L,
+ 1E2080L,
+ 1E2081L,
+ 1E2082L,
+ 1E2083L,
+ 1E2084L,
+ 1E2085L,
+ 1E2086L,
+ 1E2087L,
+ 1E2088L,
+ 1E2089L,
+ 1E2090L,
+ 1E2091L,
+ 1E2092L,
+ 1E2093L,
+ 1E2094L,
+ 1E2095L,
+ 1E2096L,
+ 1E2097L,
+ 1E2098L,
+ 1E2099L,
+ 1E2100L,
+ 1E2101L,
+ 1E2102L,
+ 1E2103L,
+ 1E2104L,
+ 1E2105L,
+ 1E2106L,
+ 1E2107L,
+ 1E2108L,
+ 1E2109L,
+ 1E2110L,
+ 1E2111L,
+ 1E2112L,
+ 1E2113L,
+ 1E2114L,
+ 1E2115L,
+ 1E2116L,
+ 1E2117L,
+ 1E2118L,
+ 1E2119L,
+ 1E2120L,
+ 1E2121L,
+ 1E2122L,
+ 1E2123L,
+ 1E2124L,
+ 1E2125L,
+ 1E2126L,
+ 1E2127L,
+ 1E2128L,
+ 1E2129L,
+ 1E2130L,
+ 1E2131L,
+ 1E2132L,
+ 1E2133L,
+ 1E2134L,
+ 1E2135L,
+ 1E2136L,
+ 1E2137L,
+ 1E2138L,
+ 1E2139L,
+ 1E2140L,
+ 1E2141L,
+ 1E2142L,
+ 1E2143L,
+ 1E2144L,
+ 1E2145L,
+ 1E2146L,
+ 1E2147L,
+ 1E2148L,
+ 1E2149L,
+ 1E2150L,
+ 1E2151L,
+ 1E2152L,
+ 1E2153L,
+ 1E2154L,
+ 1E2155L,
+ 1E2156L,
+ 1E2157L,
+ 1E2158L,
+ 1E2159L,
+ 1E2160L,
+ 1E2161L,
+ 1E2162L,
+ 1E2163L,
+ 1E2164L,
+ 1E2165L,
+ 1E2166L,
+ 1E2167L,
+ 1E2168L,
+ 1E2169L,
+ 1E2170L,
+ 1E2171L,
+ 1E2172L,
+ 1E2173L,
+ 1E2174L,
+ 1E2175L,
+ 1E2176L,
+ 1E2177L,
+ 1E2178L,
+ 1E2179L,
+ 1E2180L,
+ 1E2181L,
+ 1E2182L,
+ 1E2183L,
+ 1E2184L,
+ 1E2185L,
+ 1E2186L,
+ 1E2187L,
+ 1E2188L,
+ 1E2189L,
+ 1E2190L,
+ 1E2191L,
+ 1E2192L,
+ 1E2193L,
+ 1E2194L,
+ 1E2195L,
+ 1E2196L,
+ 1E2197L,
+ 1E2198L,
+ 1E2199L,
+ 1E2200L,
+ 1E2201L,
+ 1E2202L,
+ 1E2203L,
+ 1E2204L,
+ 1E2205L,
+ 1E2206L,
+ 1E2207L,
+ 1E2208L,
+ 1E2209L,
+ 1E2210L,
+ 1E2211L,
+ 1E2212L,
+ 1E2213L,
+ 1E2214L,
+ 1E2215L,
+ 1E2216L,
+ 1E2217L,
+ 1E2218L,
+ 1E2219L,
+ 1E2220L,
+ 1E2221L,
+ 1E2222L,
+ 1E2223L,
+ 1E2224L,
+ 1E2225L,
+ 1E2226L,
+ 1E2227L,
+ 1E2228L,
+ 1E2229L,
+ 1E2230L,
+ 1E2231L,
+ 1E2232L,
+ 1E2233L,
+ 1E2234L,
+ 1E2235L,
+ 1E2236L,
+ 1E2237L,
+ 1E2238L,
+ 1E2239L,
+ 1E2240L,
+ 1E2241L,
+ 1E2242L,
+ 1E2243L,
+ 1E2244L,
+ 1E2245L,
+ 1E2246L,
+ 1E2247L,
+ 1E2248L,
+ 1E2249L,
+ 1E2250L,
+ 1E2251L,
+ 1E2252L,
+ 1E2253L,
+ 1E2254L,
+ 1E2255L,
+ 1E2256L,
+ 1E2257L,
+ 1E2258L,
+ 1E2259L,
+ 1E2260L,
+ 1E2261L,
+ 1E2262L,
+ 1E2263L,
+ 1E2264L,
+ 1E2265L,
+ 1E2266L,
+ 1E2267L,
+ 1E2268L,
+ 1E2269L,
+ 1E2270L,
+ 1E2271L,
+ 1E2272L,
+ 1E2273L,
+ 1E2274L,
+ 1E2275L,
+ 1E2276L,
+ 1E2277L,
+ 1E2278L,
+ 1E2279L,
+ 1E2280L,
+ 1E2281L,
+ 1E2282L,
+ 1E2283L,
+ 1E2284L,
+ 1E2285L,
+ 1E2286L,
+ 1E2287L,
+ 1E2288L,
+ 1E2289L,
+ 1E2290L,
+ 1E2291L,
+ 1E2292L,
+ 1E2293L,
+ 1E2294L,
+ 1E2295L,
+ 1E2296L,
+ 1E2297L,
+ 1E2298L,
+ 1E2299L,
+ 1E2300L,
+ 1E2301L,
+ 1E2302L,
+ 1E2303L,
+ 1E2304L,
+ 1E2305L,
+ 1E2306L,
+ 1E2307L,
+ 1E2308L,
+ 1E2309L,
+ 1E2310L,
+ 1E2311L,
+ 1E2312L,
+ 1E2313L,
+ 1E2314L,
+ 1E2315L,
+ 1E2316L,
+ 1E2317L,
+ 1E2318L,
+ 1E2319L,
+ 1E2320L,
+ 1E2321L,
+ 1E2322L,
+ 1E2323L,
+ 1E2324L,
+ 1E2325L,
+ 1E2326L,
+ 1E2327L,
+ 1E2328L,
+ 1E2329L,
+ 1E2330L,
+ 1E2331L,
+ 1E2332L,
+ 1E2333L,
+ 1E2334L,
+ 1E2335L,
+ 1E2336L,
+ 1E2337L,
+ 1E2338L,
+ 1E2339L,
+ 1E2340L,
+ 1E2341L,
+ 1E2342L,
+ 1E2343L,
+ 1E2344L,
+ 1E2345L,
+ 1E2346L,
+ 1E2347L,
+ 1E2348L,
+ 1E2349L,
+ 1E2350L,
+ 1E2351L,
+ 1E2352L,
+ 1E2353L,
+ 1E2354L,
+ 1E2355L,
+ 1E2356L,
+ 1E2357L,
+ 1E2358L,
+ 1E2359L,
+ 1E2360L,
+ 1E2361L,
+ 1E2362L,
+ 1E2363L,
+ 1E2364L,
+ 1E2365L,
+ 1E2366L,
+ 1E2367L,
+ 1E2368L,
+ 1E2369L,
+ 1E2370L,
+ 1E2371L,
+ 1E2372L,
+ 1E2373L,
+ 1E2374L,
+ 1E2375L,
+ 1E2376L,
+ 1E2377L,
+ 1E2378L,
+ 1E2379L,
+ 1E2380L,
+ 1E2381L,
+ 1E2382L,
+ 1E2383L,
+ 1E2384L,
+ 1E2385L,
+ 1E2386L,
+ 1E2387L,
+ 1E2388L,
+ 1E2389L,
+ 1E2390L,
+ 1E2391L,
+ 1E2392L,
+ 1E2393L,
+ 1E2394L,
+ 1E2395L,
+ 1E2396L,
+ 1E2397L,
+ 1E2398L,
+ 1E2399L,
+ 1E2400L,
+ 1E2401L,
+ 1E2402L,
+ 1E2403L,
+ 1E2404L,
+ 1E2405L,
+ 1E2406L,
+ 1E2407L,
+ 1E2408L,
+ 1E2409L,
+ 1E2410L,
+ 1E2411L,
+ 1E2412L,
+ 1E2413L,
+ 1E2414L,
+ 1E2415L,
+ 1E2416L,
+ 1E2417L,
+ 1E2418L,
+ 1E2419L,
+ 1E2420L,
+ 1E2421L,
+ 1E2422L,
+ 1E2423L,
+ 1E2424L,
+ 1E2425L,
+ 1E2426L,
+ 1E2427L,
+ 1E2428L,
+ 1E2429L,
+ 1E2430L,
+ 1E2431L,
+ 1E2432L,
+ 1E2433L,
+ 1E2434L,
+ 1E2435L,
+ 1E2436L,
+ 1E2437L,
+ 1E2438L,
+ 1E2439L,
+ 1E2440L,
+ 1E2441L,
+ 1E2442L,
+ 1E2443L,
+ 1E2444L,
+ 1E2445L,
+ 1E2446L,
+ 1E2447L,
+ 1E2448L,
+ 1E2449L,
+ 1E2450L,
+ 1E2451L,
+ 1E2452L,
+ 1E2453L,
+ 1E2454L,
+ 1E2455L,
+ 1E2456L,
+ 1E2457L,
+ 1E2458L,
+ 1E2459L,
+ 1E2460L,
+ 1E2461L,
+ 1E2462L,
+ 1E2463L,
+ 1E2464L,
+ 1E2465L,
+ 1E2466L,
+ 1E2467L,
+ 1E2468L,
+ 1E2469L,
+ 1E2470L,
+ 1E2471L,
+ 1E2472L,
+ 1E2473L,
+ 1E2474L,
+ 1E2475L,
+ 1E2476L,
+ 1E2477L,
+ 1E2478L,
+ 1E2479L,
+ 1E2480L,
+ 1E2481L,
+ 1E2482L,
+ 1E2483L,
+ 1E2484L,
+ 1E2485L,
+ 1E2486L,
+ 1E2487L,
+ 1E2488L,
+ 1E2489L,
+ 1E2490L,
+ 1E2491L,
+ 1E2492L,
+ 1E2493L,
+ 1E2494L,
+ 1E2495L,
+ 1E2496L,
+ 1E2497L,
+ 1E2498L,
+ 1E2499L,
+ 1E2500L,
+ 1E2501L,
+ 1E2502L,
+ 1E2503L,
+ 1E2504L,
+ 1E2505L,
+ 1E2506L,
+ 1E2507L,
+ 1E2508L,
+ 1E2509L,
+ 1E2510L,
+ 1E2511L,
+ 1E2512L,
+ 1E2513L,
+ 1E2514L,
+ 1E2515L,
+ 1E2516L,
+ 1E2517L,
+ 1E2518L,
+ 1E2519L,
+ 1E2520L,
+ 1E2521L,
+ 1E2522L,
+ 1E2523L,
+ 1E2524L,
+ 1E2525L,
+ 1E2526L,
+ 1E2527L,
+ 1E2528L,
+ 1E2529L,
+ 1E2530L,
+ 1E2531L,
+ 1E2532L,
+ 1E2533L,
+ 1E2534L,
+ 1E2535L,
+ 1E2536L,
+ 1E2537L,
+ 1E2538L,
+ 1E2539L,
+ 1E2540L,
+ 1E2541L,
+ 1E2542L,
+ 1E2543L,
+ 1E2544L,
+ 1E2545L,
+ 1E2546L,
+ 1E2547L,
+ 1E2548L,
+ 1E2549L,
+ 1E2550L,
+ 1E2551L,
+ 1E2552L,
+ 1E2553L,
+ 1E2554L,
+ 1E2555L,
+ 1E2556L,
+ 1E2557L,
+ 1E2558L,
+ 1E2559L,
+ 1E2560L,
+ 1E2561L,
+ 1E2562L,
+ 1E2563L,
+ 1E2564L,
+ 1E2565L,
+ 1E2566L,
+ 1E2567L,
+ 1E2568L,
+ 1E2569L,
+ 1E2570L,
+ 1E2571L,
+ 1E2572L,
+ 1E2573L,
+ 1E2574L,
+ 1E2575L,
+ 1E2576L,
+ 1E2577L,
+ 1E2578L,
+ 1E2579L,
+ 1E2580L,
+ 1E2581L,
+ 1E2582L,
+ 1E2583L,
+ 1E2584L,
+ 1E2585L,
+ 1E2586L,
+ 1E2587L,
+ 1E2588L,
+ 1E2589L,
+ 1E2590L,
+ 1E2591L,
+ 1E2592L,
+ 1E2593L,
+ 1E2594L,
+ 1E2595L,
+ 1E2596L,
+ 1E2597L,
+ 1E2598L,
+ 1E2599L,
+ 1E2600L,
+ 1E2601L,
+ 1E2602L,
+ 1E2603L,
+ 1E2604L,
+ 1E2605L,
+ 1E2606L,
+ 1E2607L,
+ 1E2608L,
+ 1E2609L,
+ 1E2610L,
+ 1E2611L,
+ 1E2612L,
+ 1E2613L,
+ 1E2614L,
+ 1E2615L,
+ 1E2616L,
+ 1E2617L,
+ 1E2618L,
+ 1E2619L,
+ 1E2620L,
+ 1E2621L,
+ 1E2622L,
+ 1E2623L,
+ 1E2624L,
+ 1E2625L,
+ 1E2626L,
+ 1E2627L,
+ 1E2628L,
+ 1E2629L,
+ 1E2630L,
+ 1E2631L,
+ 1E2632L,
+ 1E2633L,
+ 1E2634L,
+ 1E2635L,
+ 1E2636L,
+ 1E2637L,
+ 1E2638L,
+ 1E2639L,
+ 1E2640L,
+ 1E2641L,
+ 1E2642L,
+ 1E2643L,
+ 1E2644L,
+ 1E2645L,
+ 1E2646L,
+ 1E2647L,
+ 1E2648L,
+ 1E2649L,
+ 1E2650L,
+ 1E2651L,
+ 1E2652L,
+ 1E2653L,
+ 1E2654L,
+ 1E2655L,
+ 1E2656L,
+ 1E2657L,
+ 1E2658L,
+ 1E2659L,
+ 1E2660L,
+ 1E2661L,
+ 1E2662L,
+ 1E2663L,
+ 1E2664L,
+ 1E2665L,
+ 1E2666L,
+ 1E2667L,
+ 1E2668L,
+ 1E2669L,
+ 1E2670L,
+ 1E2671L,
+ 1E2672L,
+ 1E2673L,
+ 1E2674L,
+ 1E2675L,
+ 1E2676L,
+ 1E2677L,
+ 1E2678L,
+ 1E2679L,
+ 1E2680L,
+ 1E2681L,
+ 1E2682L,
+ 1E2683L,
+ 1E2684L,
+ 1E2685L,
+ 1E2686L,
+ 1E2687L,
+ 1E2688L,
+ 1E2689L,
+ 1E2690L,
+ 1E2691L,
+ 1E2692L,
+ 1E2693L,
+ 1E2694L,
+ 1E2695L,
+ 1E2696L,
+ 1E2697L,
+ 1E2698L,
+ 1E2699L,
+ 1E2700L,
+ 1E2701L,
+ 1E2702L,
+ 1E2703L,
+ 1E2704L,
+ 1E2705L,
+ 1E2706L,
+ 1E2707L,
+ 1E2708L,
+ 1E2709L,
+ 1E2710L,
+ 1E2711L,
+ 1E2712L,
+ 1E2713L,
+ 1E2714L,
+ 1E2715L,
+ 1E2716L,
+ 1E2717L,
+ 1E2718L,
+ 1E2719L,
+ 1E2720L,
+ 1E2721L,
+ 1E2722L,
+ 1E2723L,
+ 1E2724L,
+ 1E2725L,
+ 1E2726L,
+ 1E2727L,
+ 1E2728L,
+ 1E2729L,
+ 1E2730L,
+ 1E2731L,
+ 1E2732L,
+ 1E2733L,
+ 1E2734L,
+ 1E2735L,
+ 1E2736L,
+ 1E2737L,
+ 1E2738L,
+ 1E2739L,
+ 1E2740L,
+ 1E2741L,
+ 1E2742L,
+ 1E2743L,
+ 1E2744L,
+ 1E2745L,
+ 1E2746L,
+ 1E2747L,
+ 1E2748L,
+ 1E2749L,
+ 1E2750L,
+ 1E2751L,
+ 1E2752L,
+ 1E2753L,
+ 1E2754L,
+ 1E2755L,
+ 1E2756L,
+ 1E2757L,
+ 1E2758L,
+ 1E2759L,
+ 1E2760L,
+ 1E2761L,
+ 1E2762L,
+ 1E2763L,
+ 1E2764L,
+ 1E2765L,
+ 1E2766L,
+ 1E2767L,
+ 1E2768L,
+ 1E2769L,
+ 1E2770L,
+ 1E2771L,
+ 1E2772L,
+ 1E2773L,
+ 1E2774L,
+ 1E2775L,
+ 1E2776L,
+ 1E2777L,
+ 1E2778L,
+ 1E2779L,
+ 1E2780L,
+ 1E2781L,
+ 1E2782L,
+ 1E2783L,
+ 1E2784L,
+ 1E2785L,
+ 1E2786L,
+ 1E2787L,
+ 1E2788L,
+ 1E2789L,
+ 1E2790L,
+ 1E2791L,
+ 1E2792L,
+ 1E2793L,
+ 1E2794L,
+ 1E2795L,
+ 1E2796L,
+ 1E2797L,
+ 1E2798L,
+ 1E2799L,
+ 1E2800L,
+ 1E2801L,
+ 1E2802L,
+ 1E2803L,
+ 1E2804L,
+ 1E2805L,
+ 1E2806L,
+ 1E2807L,
+ 1E2808L,
+ 1E2809L,
+ 1E2810L,
+ 1E2811L,
+ 1E2812L,
+ 1E2813L,
+ 1E2814L,
+ 1E2815L,
+ 1E2816L,
+ 1E2817L,
+ 1E2818L,
+ 1E2819L,
+ 1E2820L,
+ 1E2821L,
+ 1E2822L,
+ 1E2823L,
+ 1E2824L,
+ 1E2825L,
+ 1E2826L,
+ 1E2827L,
+ 1E2828L,
+ 1E2829L,
+ 1E2830L,
+ 1E2831L,
+ 1E2832L,
+ 1E2833L,
+ 1E2834L,
+ 1E2835L,
+ 1E2836L,
+ 1E2837L,
+ 1E2838L,
+ 1E2839L,
+ 1E2840L,
+ 1E2841L,
+ 1E2842L,
+ 1E2843L,
+ 1E2844L,
+ 1E2845L,
+ 1E2846L,
+ 1E2847L,
+ 1E2848L,
+ 1E2849L,
+ 1E2850L,
+ 1E2851L,
+ 1E2852L,
+ 1E2853L,
+ 1E2854L,
+ 1E2855L,
+ 1E2856L,
+ 1E2857L,
+ 1E2858L,
+ 1E2859L,
+ 1E2860L,
+ 1E2861L,
+ 1E2862L,
+ 1E2863L,
+ 1E2864L,
+ 1E2865L,
+ 1E2866L,
+ 1E2867L,
+ 1E2868L,
+ 1E2869L,
+ 1E2870L,
+ 1E2871L,
+ 1E2872L,
+ 1E2873L,
+ 1E2874L,
+ 1E2875L,
+ 1E2876L,
+ 1E2877L,
+ 1E2878L,
+ 1E2879L,
+ 1E2880L,
+ 1E2881L,
+ 1E2882L,
+ 1E2883L,
+ 1E2884L,
+ 1E2885L,
+ 1E2886L,
+ 1E2887L,
+ 1E2888L,
+ 1E2889L,
+ 1E2890L,
+ 1E2891L,
+ 1E2892L,
+ 1E2893L,
+ 1E2894L,
+ 1E2895L,
+ 1E2896L,
+ 1E2897L,
+ 1E2898L,
+ 1E2899L,
+ 1E2900L,
+ 1E2901L,
+ 1E2902L,
+ 1E2903L,
+ 1E2904L,
+ 1E2905L,
+ 1E2906L,
+ 1E2907L,
+ 1E2908L,
+ 1E2909L,
+ 1E2910L,
+ 1E2911L,
+ 1E2912L,
+ 1E2913L,
+ 1E2914L,
+ 1E2915L,
+ 1E2916L,
+ 1E2917L,
+ 1E2918L,
+ 1E2919L,
+ 1E2920L,
+ 1E2921L,
+ 1E2922L,
+ 1E2923L,
+ 1E2924L,
+ 1E2925L,
+ 1E2926L,
+ 1E2927L,
+ 1E2928L,
+ 1E2929L,
+ 1E2930L,
+ 1E2931L,
+ 1E2932L,
+ 1E2933L,
+ 1E2934L,
+ 1E2935L,
+ 1E2936L,
+ 1E2937L,
+ 1E2938L,
+ 1E2939L,
+ 1E2940L,
+ 1E2941L,
+ 1E2942L,
+ 1E2943L,
+ 1E2944L,
+ 1E2945L,
+ 1E2946L,
+ 1E2947L,
+ 1E2948L,
+ 1E2949L,
+ 1E2950L,
+ 1E2951L,
+ 1E2952L,
+ 1E2953L,
+ 1E2954L,
+ 1E2955L,
+ 1E2956L,
+ 1E2957L,
+ 1E2958L,
+ 1E2959L,
+ 1E2960L,
+ 1E2961L,
+ 1E2962L,
+ 1E2963L,
+ 1E2964L,
+ 1E2965L,
+ 1E2966L,
+ 1E2967L,
+ 1E2968L,
+ 1E2969L,
+ 1E2970L,
+ 1E2971L,
+ 1E2972L,
+ 1E2973L,
+ 1E2974L,
+ 1E2975L,
+ 1E2976L,
+ 1E2977L,
+ 1E2978L,
+ 1E2979L,
+ 1E2980L,
+ 1E2981L,
+ 1E2982L,
+ 1E2983L,
+ 1E2984L,
+ 1E2985L,
+ 1E2986L,
+ 1E2987L,
+ 1E2988L,
+ 1E2989L,
+ 1E2990L,
+ 1E2991L,
+ 1E2992L,
+ 1E2993L,
+ 1E2994L,
+ 1E2995L,
+ 1E2996L,
+ 1E2997L,
+ 1E2998L,
+ 1E2999L,
+ 1E3000L,
+ 1E3001L,
+ 1E3002L,
+ 1E3003L,
+ 1E3004L,
+ 1E3005L,
+ 1E3006L,
+ 1E3007L,
+ 1E3008L,
+ 1E3009L,
+ 1E3010L,
+ 1E3011L,
+ 1E3012L,
+ 1E3013L,
+ 1E3014L,
+ 1E3015L,
+ 1E3016L,
+ 1E3017L,
+ 1E3018L,
+ 1E3019L,
+ 1E3020L,
+ 1E3021L,
+ 1E3022L,
+ 1E3023L,
+ 1E3024L,
+ 1E3025L,
+ 1E3026L,
+ 1E3027L,
+ 1E3028L,
+ 1E3029L,
+ 1E3030L,
+ 1E3031L,
+ 1E3032L,
+ 1E3033L,
+ 1E3034L,
+ 1E3035L,
+ 1E3036L,
+ 1E3037L,
+ 1E3038L,
+ 1E3039L,
+ 1E3040L,
+ 1E3041L,
+ 1E3042L,
+ 1E3043L,
+ 1E3044L,
+ 1E3045L,
+ 1E3046L,
+ 1E3047L,
+ 1E3048L,
+ 1E3049L,
+ 1E3050L,
+ 1E3051L,
+ 1E3052L,
+ 1E3053L,
+ 1E3054L,
+ 1E3055L,
+ 1E3056L,
+ 1E3057L,
+ 1E3058L,
+ 1E3059L,
+ 1E3060L,
+ 1E3061L,
+ 1E3062L,
+ 1E3063L,
+ 1E3064L,
+ 1E3065L,
+ 1E3066L,
+ 1E3067L,
+ 1E3068L,
+ 1E3069L,
+ 1E3070L,
+ 1E3071L,
+ 1E3072L,
+ 1E3073L,
+ 1E3074L,
+ 1E3075L,
+ 1E3076L,
+ 1E3077L,
+ 1E3078L,
+ 1E3079L,
+ 1E3080L,
+ 1E3081L,
+ 1E3082L,
+ 1E3083L,
+ 1E3084L,
+ 1E3085L,
+ 1E3086L,
+ 1E3087L,
+ 1E3088L,
+ 1E3089L,
+ 1E3090L,
+ 1E3091L,
+ 1E3092L,
+ 1E3093L,
+ 1E3094L,
+ 1E3095L,
+ 1E3096L,
+ 1E3097L,
+ 1E3098L,
+ 1E3099L,
+ 1E3100L,
+ 1E3101L,
+ 1E3102L,
+ 1E3103L,
+ 1E3104L,
+ 1E3105L,
+ 1E3106L,
+ 1E3107L,
+ 1E3108L,
+ 1E3109L,
+ 1E3110L,
+ 1E3111L,
+ 1E3112L,
+ 1E3113L,
+ 1E3114L,
+ 1E3115L,
+ 1E3116L,
+ 1E3117L,
+ 1E3118L,
+ 1E3119L,
+ 1E3120L,
+ 1E3121L,
+ 1E3122L,
+ 1E3123L,
+ 1E3124L,
+ 1E3125L,
+ 1E3126L,
+ 1E3127L,
+ 1E3128L,
+ 1E3129L,
+ 1E3130L,
+ 1E3131L,
+ 1E3132L,
+ 1E3133L,
+ 1E3134L,
+ 1E3135L,
+ 1E3136L,
+ 1E3137L,
+ 1E3138L,
+ 1E3139L,
+ 1E3140L,
+ 1E3141L,
+ 1E3142L,
+ 1E3143L,
+ 1E3144L,
+ 1E3145L,
+ 1E3146L,
+ 1E3147L,
+ 1E3148L,
+ 1E3149L,
+ 1E3150L,
+ 1E3151L,
+ 1E3152L,
+ 1E3153L,
+ 1E3154L,
+ 1E3155L,
+ 1E3156L,
+ 1E3157L,
+ 1E3158L,
+ 1E3159L,
+ 1E3160L,
+ 1E3161L,
+ 1E3162L,
+ 1E3163L,
+ 1E3164L,
+ 1E3165L,
+ 1E3166L,
+ 1E3167L,
+ 1E3168L,
+ 1E3169L,
+ 1E3170L,
+ 1E3171L,
+ 1E3172L,
+ 1E3173L,
+ 1E3174L,
+ 1E3175L,
+ 1E3176L,
+ 1E3177L,
+ 1E3178L,
+ 1E3179L,
+ 1E3180L,
+ 1E3181L,
+ 1E3182L,
+ 1E3183L,
+ 1E3184L,
+ 1E3185L,
+ 1E3186L,
+ 1E3187L,
+ 1E3188L,
+ 1E3189L,
+ 1E3190L,
+ 1E3191L,
+ 1E3192L,
+ 1E3193L,
+ 1E3194L,
+ 1E3195L,
+ 1E3196L,
+ 1E3197L,
+ 1E3198L,
+ 1E3199L,
+ 1E3200L,
+ 1E3201L,
+ 1E3202L,
+ 1E3203L,
+ 1E3204L,
+ 1E3205L,
+ 1E3206L,
+ 1E3207L,
+ 1E3208L,
+ 1E3209L,
+ 1E3210L,
+ 1E3211L,
+ 1E3212L,
+ 1E3213L,
+ 1E3214L,
+ 1E3215L,
+ 1E3216L,
+ 1E3217L,
+ 1E3218L,
+ 1E3219L,
+ 1E3220L,
+ 1E3221L,
+ 1E3222L,
+ 1E3223L,
+ 1E3224L,
+ 1E3225L,
+ 1E3226L,
+ 1E3227L,
+ 1E3228L,
+ 1E3229L,
+ 1E3230L,
+ 1E3231L,
+ 1E3232L,
+ 1E3233L,
+ 1E3234L,
+ 1E3235L,
+ 1E3236L,
+ 1E3237L,
+ 1E3238L,
+ 1E3239L,
+ 1E3240L,
+ 1E3241L,
+ 1E3242L,
+ 1E3243L,
+ 1E3244L,
+ 1E3245L,
+ 1E3246L,
+ 1E3247L,
+ 1E3248L,
+ 1E3249L,
+ 1E3250L,
+ 1E3251L,
+ 1E3252L,
+ 1E3253L,
+ 1E3254L,
+ 1E3255L,
+ 1E3256L,
+ 1E3257L,
+ 1E3258L,
+ 1E3259L,
+ 1E3260L,
+ 1E3261L,
+ 1E3262L,
+ 1E3263L,
+ 1E3264L,
+ 1E3265L,
+ 1E3266L,
+ 1E3267L,
+ 1E3268L,
+ 1E3269L,
+ 1E3270L,
+ 1E3271L,
+ 1E3272L,
+ 1E3273L,
+ 1E3274L,
+ 1E3275L,
+ 1E3276L,
+ 1E3277L,
+ 1E3278L,
+ 1E3279L,
+ 1E3280L,
+ 1E3281L,
+ 1E3282L,
+ 1E3283L,
+ 1E3284L,
+ 1E3285L,
+ 1E3286L,
+ 1E3287L,
+ 1E3288L,
+ 1E3289L,
+ 1E3290L,
+ 1E3291L,
+ 1E3292L,
+ 1E3293L,
+ 1E3294L,
+ 1E3295L,
+ 1E3296L,
+ 1E3297L,
+ 1E3298L,
+ 1E3299L,
+ 1E3300L,
+ 1E3301L,
+ 1E3302L,
+ 1E3303L,
+ 1E3304L,
+ 1E3305L,
+ 1E3306L,
+ 1E3307L,
+ 1E3308L,
+ 1E3309L,
+ 1E3310L,
+ 1E3311L,
+ 1E3312L,
+ 1E3313L,
+ 1E3314L,
+ 1E3315L,
+ 1E3316L,
+ 1E3317L,
+ 1E3318L,
+ 1E3319L,
+ 1E3320L,
+ 1E3321L,
+ 1E3322L,
+ 1E3323L,
+ 1E3324L,
+ 1E3325L,
+ 1E3326L,
+ 1E3327L,
+ 1E3328L,
+ 1E3329L,
+ 1E3330L,
+ 1E3331L,
+ 1E3332L,
+ 1E3333L,
+ 1E3334L,
+ 1E3335L,
+ 1E3336L,
+ 1E3337L,
+ 1E3338L,
+ 1E3339L,
+ 1E3340L,
+ 1E3341L,
+ 1E3342L,
+ 1E3343L,
+ 1E3344L,
+ 1E3345L,
+ 1E3346L,
+ 1E3347L,
+ 1E3348L,
+ 1E3349L,
+ 1E3350L,
+ 1E3351L,
+ 1E3352L,
+ 1E3353L,
+ 1E3354L,
+ 1E3355L,
+ 1E3356L,
+ 1E3357L,
+ 1E3358L,
+ 1E3359L,
+ 1E3360L,
+ 1E3361L,
+ 1E3362L,
+ 1E3363L,
+ 1E3364L,
+ 1E3365L,
+ 1E3366L,
+ 1E3367L,
+ 1E3368L,
+ 1E3369L,
+ 1E3370L,
+ 1E3371L,
+ 1E3372L,
+ 1E3373L,
+ 1E3374L,
+ 1E3375L,
+ 1E3376L,
+ 1E3377L,
+ 1E3378L,
+ 1E3379L,
+ 1E3380L,
+ 1E3381L,
+ 1E3382L,
+ 1E3383L,
+ 1E3384L,
+ 1E3385L,
+ 1E3386L,
+ 1E3387L,
+ 1E3388L,
+ 1E3389L,
+ 1E3390L,
+ 1E3391L,
+ 1E3392L,
+ 1E3393L,
+ 1E3394L,
+ 1E3395L,
+ 1E3396L,
+ 1E3397L,
+ 1E3398L,
+ 1E3399L,
+ 1E3400L,
+ 1E3401L,
+ 1E3402L,
+ 1E3403L,
+ 1E3404L,
+ 1E3405L,
+ 1E3406L,
+ 1E3407L,
+ 1E3408L,
+ 1E3409L,
+ 1E3410L,
+ 1E3411L,
+ 1E3412L,
+ 1E3413L,
+ 1E3414L,
+ 1E3415L,
+ 1E3416L,
+ 1E3417L,
+ 1E3418L,
+ 1E3419L,
+ 1E3420L,
+ 1E3421L,
+ 1E3422L,
+ 1E3423L,
+ 1E3424L,
+ 1E3425L,
+ 1E3426L,
+ 1E3427L,
+ 1E3428L,
+ 1E3429L,
+ 1E3430L,
+ 1E3431L,
+ 1E3432L,
+ 1E3433L,
+ 1E3434L,
+ 1E3435L,
+ 1E3436L,
+ 1E3437L,
+ 1E3438L,
+ 1E3439L,
+ 1E3440L,
+ 1E3441L,
+ 1E3442L,
+ 1E3443L,
+ 1E3444L,
+ 1E3445L,
+ 1E3446L,
+ 1E3447L,
+ 1E3448L,
+ 1E3449L,
+ 1E3450L,
+ 1E3451L,
+ 1E3452L,
+ 1E3453L,
+ 1E3454L,
+ 1E3455L,
+ 1E3456L,
+ 1E3457L,
+ 1E3458L,
+ 1E3459L,
+ 1E3460L,
+ 1E3461L,
+ 1E3462L,
+ 1E3463L,
+ 1E3464L,
+ 1E3465L,
+ 1E3466L,
+ 1E3467L,
+ 1E3468L,
+ 1E3469L,
+ 1E3470L,
+ 1E3471L,
+ 1E3472L,
+ 1E3473L,
+ 1E3474L,
+ 1E3475L,
+ 1E3476L,
+ 1E3477L,
+ 1E3478L,
+ 1E3479L,
+ 1E3480L,
+ 1E3481L,
+ 1E3482L,
+ 1E3483L,
+ 1E3484L,
+ 1E3485L,
+ 1E3486L,
+ 1E3487L,
+ 1E3488L,
+ 1E3489L,
+ 1E3490L,
+ 1E3491L,
+ 1E3492L,
+ 1E3493L,
+ 1E3494L,
+ 1E3495L,
+ 1E3496L,
+ 1E3497L,
+ 1E3498L,
+ 1E3499L,
+ 1E3500L,
+ 1E3501L,
+ 1E3502L,
+ 1E3503L,
+ 1E3504L,
+ 1E3505L,
+ 1E3506L,
+ 1E3507L,
+ 1E3508L,
+ 1E3509L,
+ 1E3510L,
+ 1E3511L,
+ 1E3512L,
+ 1E3513L,
+ 1E3514L,
+ 1E3515L,
+ 1E3516L,
+ 1E3517L,
+ 1E3518L,
+ 1E3519L,
+ 1E3520L,
+ 1E3521L,
+ 1E3522L,
+ 1E3523L,
+ 1E3524L,
+ 1E3525L,
+ 1E3526L,
+ 1E3527L,
+ 1E3528L,
+ 1E3529L,
+ 1E3530L,
+ 1E3531L,
+ 1E3532L,
+ 1E3533L,
+ 1E3534L,
+ 1E3535L,
+ 1E3536L,
+ 1E3537L,
+ 1E3538L,
+ 1E3539L,
+ 1E3540L,
+ 1E3541L,
+ 1E3542L,
+ 1E3543L,
+ 1E3544L,
+ 1E3545L,
+ 1E3546L,
+ 1E3547L,
+ 1E3548L,
+ 1E3549L,
+ 1E3550L,
+ 1E3551L,
+ 1E3552L,
+ 1E3553L,
+ 1E3554L,
+ 1E3555L,
+ 1E3556L,
+ 1E3557L,
+ 1E3558L,
+ 1E3559L,
+ 1E3560L,
+ 1E3561L,
+ 1E3562L,
+ 1E3563L,
+ 1E3564L,
+ 1E3565L,
+ 1E3566L,
+ 1E3567L,
+ 1E3568L,
+ 1E3569L,
+ 1E3570L,
+ 1E3571L,
+ 1E3572L,
+ 1E3573L,
+ 1E3574L,
+ 1E3575L,
+ 1E3576L,
+ 1E3577L,
+ 1E3578L,
+ 1E3579L,
+ 1E3580L,
+ 1E3581L,
+ 1E3582L,
+ 1E3583L,
+ 1E3584L,
+ 1E3585L,
+ 1E3586L,
+ 1E3587L,
+ 1E3588L,
+ 1E3589L,
+ 1E3590L,
+ 1E3591L,
+ 1E3592L,
+ 1E3593L,
+ 1E3594L,
+ 1E3595L,
+ 1E3596L,
+ 1E3597L,
+ 1E3598L,
+ 1E3599L,
+ 1E3600L,
+ 1E3601L,
+ 1E3602L,
+ 1E3603L,
+ 1E3604L,
+ 1E3605L,
+ 1E3606L,
+ 1E3607L,
+ 1E3608L,
+ 1E3609L,
+ 1E3610L,
+ 1E3611L,
+ 1E3612L,
+ 1E3613L,
+ 1E3614L,
+ 1E3615L,
+ 1E3616L,
+ 1E3617L,
+ 1E3618L,
+ 1E3619L,
+ 1E3620L,
+ 1E3621L,
+ 1E3622L,
+ 1E3623L,
+ 1E3624L,
+ 1E3625L,
+ 1E3626L,
+ 1E3627L,
+ 1E3628L,
+ 1E3629L,
+ 1E3630L,
+ 1E3631L,
+ 1E3632L,
+ 1E3633L,
+ 1E3634L,
+ 1E3635L,
+ 1E3636L,
+ 1E3637L,
+ 1E3638L,
+ 1E3639L,
+ 1E3640L,
+ 1E3641L,
+ 1E3642L,
+ 1E3643L,
+ 1E3644L,
+ 1E3645L,
+ 1E3646L,
+ 1E3647L,
+ 1E3648L,
+ 1E3649L,
+ 1E3650L,
+ 1E3651L,
+ 1E3652L,
+ 1E3653L,
+ 1E3654L,
+ 1E3655L,
+ 1E3656L,
+ 1E3657L,
+ 1E3658L,
+ 1E3659L,
+ 1E3660L,
+ 1E3661L,
+ 1E3662L,
+ 1E3663L,
+ 1E3664L,
+ 1E3665L,
+ 1E3666L,
+ 1E3667L,
+ 1E3668L,
+ 1E3669L,
+ 1E3670L,
+ 1E3671L,
+ 1E3672L,
+ 1E3673L,
+ 1E3674L,
+ 1E3675L,
+ 1E3676L,
+ 1E3677L,
+ 1E3678L,
+ 1E3679L,
+ 1E3680L,
+ 1E3681L,
+ 1E3682L,
+ 1E3683L,
+ 1E3684L,
+ 1E3685L,
+ 1E3686L,
+ 1E3687L,
+ 1E3688L,
+ 1E3689L,
+ 1E3690L,
+ 1E3691L,
+ 1E3692L,
+ 1E3693L,
+ 1E3694L,
+ 1E3695L,
+ 1E3696L,
+ 1E3697L,
+ 1E3698L,
+ 1E3699L,
+ 1E3700L,
+ 1E3701L,
+ 1E3702L,
+ 1E3703L,
+ 1E3704L,
+ 1E3705L,
+ 1E3706L,
+ 1E3707L,
+ 1E3708L,
+ 1E3709L,
+ 1E3710L,
+ 1E3711L,
+ 1E3712L,
+ 1E3713L,
+ 1E3714L,
+ 1E3715L,
+ 1E3716L,
+ 1E3717L,
+ 1E3718L,
+ 1E3719L,
+ 1E3720L,
+ 1E3721L,
+ 1E3722L,
+ 1E3723L,
+ 1E3724L,
+ 1E3725L,
+ 1E3726L,
+ 1E3727L,
+ 1E3728L,
+ 1E3729L,
+ 1E3730L,
+ 1E3731L,
+ 1E3732L,
+ 1E3733L,
+ 1E3734L,
+ 1E3735L,
+ 1E3736L,
+ 1E3737L,
+ 1E3738L,
+ 1E3739L,
+ 1E3740L,
+ 1E3741L,
+ 1E3742L,
+ 1E3743L,
+ 1E3744L,
+ 1E3745L,
+ 1E3746L,
+ 1E3747L,
+ 1E3748L,
+ 1E3749L,
+ 1E3750L,
+ 1E3751L,
+ 1E3752L,
+ 1E3753L,
+ 1E3754L,
+ 1E3755L,
+ 1E3756L,
+ 1E3757L,
+ 1E3758L,
+ 1E3759L,
+ 1E3760L,
+ 1E3761L,
+ 1E3762L,
+ 1E3763L,
+ 1E3764L,
+ 1E3765L,
+ 1E3766L,
+ 1E3767L,
+ 1E3768L,
+ 1E3769L,
+ 1E3770L,
+ 1E3771L,
+ 1E3772L,
+ 1E3773L,
+ 1E3774L,
+ 1E3775L,
+ 1E3776L,
+ 1E3777L,
+ 1E3778L,
+ 1E3779L,
+ 1E3780L,
+ 1E3781L,
+ 1E3782L,
+ 1E3783L,
+ 1E3784L,
+ 1E3785L,
+ 1E3786L,
+ 1E3787L,
+ 1E3788L,
+ 1E3789L,
+ 1E3790L,
+ 1E3791L,
+ 1E3792L,
+ 1E3793L,
+ 1E3794L,
+ 1E3795L,
+ 1E3796L,
+ 1E3797L,
+ 1E3798L,
+ 1E3799L,
+ 1E3800L,
+ 1E3801L,
+ 1E3802L,
+ 1E3803L,
+ 1E3804L,
+ 1E3805L,
+ 1E3806L,
+ 1E3807L,
+ 1E3808L,
+ 1E3809L,
+ 1E3810L,
+ 1E3811L,
+ 1E3812L,
+ 1E3813L,
+ 1E3814L,
+ 1E3815L,
+ 1E3816L,
+ 1E3817L,
+ 1E3818L,
+ 1E3819L,
+ 1E3820L,
+ 1E3821L,
+ 1E3822L,
+ 1E3823L,
+ 1E3824L,
+ 1E3825L,
+ 1E3826L,
+ 1E3827L,
+ 1E3828L,
+ 1E3829L,
+ 1E3830L,
+ 1E3831L,
+ 1E3832L,
+ 1E3833L,
+ 1E3834L,
+ 1E3835L,
+ 1E3836L,
+ 1E3837L,
+ 1E3838L,
+ 1E3839L,
+ 1E3840L,
+ 1E3841L,
+ 1E3842L,
+ 1E3843L,
+ 1E3844L,
+ 1E3845L,
+ 1E3846L,
+ 1E3847L,
+ 1E3848L,
+ 1E3849L,
+ 1E3850L,
+ 1E3851L,
+ 1E3852L,
+ 1E3853L,
+ 1E3854L,
+ 1E3855L,
+ 1E3856L,
+ 1E3857L,
+ 1E3858L,
+ 1E3859L,
+ 1E3860L,
+ 1E3861L,
+ 1E3862L,
+ 1E3863L,
+ 1E3864L,
+ 1E3865L,
+ 1E3866L,
+ 1E3867L,
+ 1E3868L,
+ 1E3869L,
+ 1E3870L,
+ 1E3871L,
+ 1E3872L,
+ 1E3873L,
+ 1E3874L,
+ 1E3875L,
+ 1E3876L,
+ 1E3877L,
+ 1E3878L,
+ 1E3879L,
+ 1E3880L,
+ 1E3881L,
+ 1E3882L,
+ 1E3883L,
+ 1E3884L,
+ 1E3885L,
+ 1E3886L,
+ 1E3887L,
+ 1E3888L,
+ 1E3889L,
+ 1E3890L,
+ 1E3891L,
+ 1E3892L,
+ 1E3893L,
+ 1E3894L,
+ 1E3895L,
+ 1E3896L,
+ 1E3897L,
+ 1E3898L,
+ 1E3899L,
+ 1E3900L,
+ 1E3901L,
+ 1E3902L,
+ 1E3903L,
+ 1E3904L,
+ 1E3905L,
+ 1E3906L,
+ 1E3907L,
+ 1E3908L,
+ 1E3909L,
+ 1E3910L,
+ 1E3911L,
+ 1E3912L,
+ 1E3913L,
+ 1E3914L,
+ 1E3915L,
+ 1E3916L,
+ 1E3917L,
+ 1E3918L,
+ 1E3919L,
+ 1E3920L,
+ 1E3921L,
+ 1E3922L,
+ 1E3923L,
+ 1E3924L,
+ 1E3925L,
+ 1E3926L,
+ 1E3927L,
+ 1E3928L,
+ 1E3929L,
+ 1E3930L,
+ 1E3931L,
+ 1E3932L,
+ 1E3933L,
+ 1E3934L,
+ 1E3935L,
+ 1E3936L,
+ 1E3937L,
+ 1E3938L,
+ 1E3939L,
+ 1E3940L,
+ 1E3941L,
+ 1E3942L,
+ 1E3943L,
+ 1E3944L,
+ 1E3945L,
+ 1E3946L,
+ 1E3947L,
+ 1E3948L,
+ 1E3949L,
+ 1E3950L,
+ 1E3951L,
+ 1E3952L,
+ 1E3953L,
+ 1E3954L,
+ 1E3955L,
+ 1E3956L,
+ 1E3957L,
+ 1E3958L,
+ 1E3959L,
+ 1E3960L,
+ 1E3961L,
+ 1E3962L,
+ 1E3963L,
+ 1E3964L,
+ 1E3965L,
+ 1E3966L,
+ 1E3967L,
+ 1E3968L,
+ 1E3969L,
+ 1E3970L,
+ 1E3971L,
+ 1E3972L,
+ 1E3973L,
+ 1E3974L,
+ 1E3975L,
+ 1E3976L,
+ 1E3977L,
+ 1E3978L,
+ 1E3979L,
+ 1E3980L,
+ 1E3981L,
+ 1E3982L,
+ 1E3983L,
+ 1E3984L,
+ 1E3985L,
+ 1E3986L,
+ 1E3987L,
+ 1E3988L,
+ 1E3989L,
+ 1E3990L,
+ 1E3991L,
+ 1E3992L,
+ 1E3993L,
+ 1E3994L,
+ 1E3995L,
+ 1E3996L,
+ 1E3997L,
+ 1E3998L,
+ 1E3999L,
+ 1E4000L,
+ 1E4001L,
+ 1E4002L,
+ 1E4003L,
+ 1E4004L,
+ 1E4005L,
+ 1E4006L,
+ 1E4007L,
+ 1E4008L,
+ 1E4009L,
+ 1E4010L,
+ 1E4011L,
+ 1E4012L,
+ 1E4013L,
+ 1E4014L,
+ 1E4015L,
+ 1E4016L,
+ 1E4017L,
+ 1E4018L,
+ 1E4019L,
+ 1E4020L,
+ 1E4021L,
+ 1E4022L,
+ 1E4023L,
+ 1E4024L,
+ 1E4025L,
+ 1E4026L,
+ 1E4027L,
+ 1E4028L,
+ 1E4029L,
+ 1E4030L,
+ 1E4031L,
+ 1E4032L,
+ 1E4033L,
+ 1E4034L,
+ 1E4035L,
+ 1E4036L,
+ 1E4037L,
+ 1E4038L,
+ 1E4039L,
+ 1E4040L,
+ 1E4041L,
+ 1E4042L,
+ 1E4043L,
+ 1E4044L,
+ 1E4045L,
+ 1E4046L,
+ 1E4047L,
+ 1E4048L,
+ 1E4049L,
+ 1E4050L,
+ 1E4051L,
+ 1E4052L,
+ 1E4053L,
+ 1E4054L,
+ 1E4055L,
+ 1E4056L,
+ 1E4057L,
+ 1E4058L,
+ 1E4059L,
+ 1E4060L,
+ 1E4061L,
+ 1E4062L,
+ 1E4063L,
+ 1E4064L,
+ 1E4065L,
+ 1E4066L,
+ 1E4067L,
+ 1E4068L,
+ 1E4069L,
+ 1E4070L,
+ 1E4071L,
+ 1E4072L,
+ 1E4073L,
+ 1E4074L,
+ 1E4075L,
+ 1E4076L,
+ 1E4077L,
+ 1E4078L,
+ 1E4079L,
+ 1E4080L,
+ 1E4081L,
+ 1E4082L,
+ 1E4083L,
+ 1E4084L,
+ 1E4085L,
+ 1E4086L,
+ 1E4087L,
+ 1E4088L,
+ 1E4089L,
+ 1E4090L,
+ 1E4091L,
+ 1E4092L,
+ 1E4093L,
+ 1E4094L,
+ 1E4095L,
+ 1E4096L,
+ 1E4097L,
+ 1E4098L,
+ 1E4099L,
+ 1E4100L,
+ 1E4101L,
+ 1E4102L,
+ 1E4103L,
+ 1E4104L,
+ 1E4105L,
+ 1E4106L,
+ 1E4107L,
+ 1E4108L,
+ 1E4109L,
+ 1E4110L,
+ 1E4111L,
+ 1E4112L,
+ 1E4113L,
+ 1E4114L,
+ 1E4115L,
+ 1E4116L,
+ 1E4117L,
+ 1E4118L,
+ 1E4119L,
+ 1E4120L,
+ 1E4121L,
+ 1E4122L,
+ 1E4123L,
+ 1E4124L,
+ 1E4125L,
+ 1E4126L,
+ 1E4127L,
+ 1E4128L,
+ 1E4129L,
+ 1E4130L,
+ 1E4131L,
+ 1E4132L,
+ 1E4133L,
+ 1E4134L,
+ 1E4135L,
+ 1E4136L,
+ 1E4137L,
+ 1E4138L,
+ 1E4139L,
+ 1E4140L,
+ 1E4141L,
+ 1E4142L,
+ 1E4143L,
+ 1E4144L,
+ 1E4145L,
+ 1E4146L,
+ 1E4147L,
+ 1E4148L,
+ 1E4149L,
+ 1E4150L,
+ 1E4151L,
+ 1E4152L,
+ 1E4153L,
+ 1E4154L,
+ 1E4155L,
+ 1E4156L,
+ 1E4157L,
+ 1E4158L,
+ 1E4159L,
+ 1E4160L,
+ 1E4161L,
+ 1E4162L,
+ 1E4163L,
+ 1E4164L,
+ 1E4165L,
+ 1E4166L,
+ 1E4167L,
+ 1E4168L,
+ 1E4169L,
+ 1E4170L,
+ 1E4171L,
+ 1E4172L,
+ 1E4173L,
+ 1E4174L,
+ 1E4175L,
+ 1E4176L,
+ 1E4177L,
+ 1E4178L,
+ 1E4179L,
+ 1E4180L,
+ 1E4181L,
+ 1E4182L,
+ 1E4183L,
+ 1E4184L,
+ 1E4185L,
+ 1E4186L,
+ 1E4187L,
+ 1E4188L,
+ 1E4189L,
+ 1E4190L,
+ 1E4191L,
+ 1E4192L,
+ 1E4193L,
+ 1E4194L,
+ 1E4195L,
+ 1E4196L,
+ 1E4197L,
+ 1E4198L,
+ 1E4199L,
+ 1E4200L,
+ 1E4201L,
+ 1E4202L,
+ 1E4203L,
+ 1E4204L,
+ 1E4205L,
+ 1E4206L,
+ 1E4207L,
+ 1E4208L,
+ 1E4209L,
+ 1E4210L,
+ 1E4211L,
+ 1E4212L,
+ 1E4213L,
+ 1E4214L,
+ 1E4215L,
+ 1E4216L,
+ 1E4217L,
+ 1E4218L,
+ 1E4219L,
+ 1E4220L,
+ 1E4221L,
+ 1E4222L,
+ 1E4223L,
+ 1E4224L,
+ 1E4225L,
+ 1E4226L,
+ 1E4227L,
+ 1E4228L,
+ 1E4229L,
+ 1E4230L,
+ 1E4231L,
+ 1E4232L,
+ 1E4233L,
+ 1E4234L,
+ 1E4235L,
+ 1E4236L,
+ 1E4237L,
+ 1E4238L,
+ 1E4239L,
+ 1E4240L,
+ 1E4241L,
+ 1E4242L,
+ 1E4243L,
+ 1E4244L,
+ 1E4245L,
+ 1E4246L,
+ 1E4247L,
+ 1E4248L,
+ 1E4249L,
+ 1E4250L,
+ 1E4251L,
+ 1E4252L,
+ 1E4253L,
+ 1E4254L,
+ 1E4255L,
+ 1E4256L,
+ 1E4257L,
+ 1E4258L,
+ 1E4259L,
+ 1E4260L,
+ 1E4261L,
+ 1E4262L,
+ 1E4263L,
+ 1E4264L,
+ 1E4265L,
+ 1E4266L,
+ 1E4267L,
+ 1E4268L,
+ 1E4269L,
+ 1E4270L,
+ 1E4271L,
+ 1E4272L,
+ 1E4273L,
+ 1E4274L,
+ 1E4275L,
+ 1E4276L,
+ 1E4277L,
+ 1E4278L,
+ 1E4279L,
+ 1E4280L,
+ 1E4281L,
+ 1E4282L,
+ 1E4283L,
+ 1E4284L,
+ 1E4285L,
+ 1E4286L,
+ 1E4287L,
+ 1E4288L,
+ 1E4289L,
+ 1E4290L,
+ 1E4291L,
+ 1E4292L,
+ 1E4293L,
+ 1E4294L,
+ 1E4295L,
+ 1E4296L,
+ 1E4297L,
+ 1E4298L,
+ 1E4299L,
+ 1E4300L,
+ 1E4301L,
+ 1E4302L,
+ 1E4303L,
+ 1E4304L,
+ 1E4305L,
+ 1E4306L,
+ 1E4307L,
+ 1E4308L,
+ 1E4309L,
+ 1E4310L,
+ 1E4311L,
+ 1E4312L,
+ 1E4313L,
+ 1E4314L,
+ 1E4315L,
+ 1E4316L,
+ 1E4317L,
+ 1E4318L,
+ 1E4319L,
+ 1E4320L,
+ 1E4321L,
+ 1E4322L,
+ 1E4323L,
+ 1E4324L,
+ 1E4325L,
+ 1E4326L,
+ 1E4327L,
+ 1E4328L,
+ 1E4329L,
+ 1E4330L,
+ 1E4331L,
+ 1E4332L,
+ 1E4333L,
+ 1E4334L,
+ 1E4335L,
+ 1E4336L,
+ 1E4337L,
+ 1E4338L,
+ 1E4339L,
+ 1E4340L,
+ 1E4341L,
+ 1E4342L,
+ 1E4343L,
+ 1E4344L,
+ 1E4345L,
+ 1E4346L,
+ 1E4347L,
+ 1E4348L,
+ 1E4349L,
+ 1E4350L,
+ 1E4351L,
+ 1E4352L,
+ 1E4353L,
+ 1E4354L,
+ 1E4355L,
+ 1E4356L,
+ 1E4357L,
+ 1E4358L,
+ 1E4359L,
+ 1E4360L,
+ 1E4361L,
+ 1E4362L,
+ 1E4363L,
+ 1E4364L,
+ 1E4365L,
+ 1E4366L,
+ 1E4367L,
+ 1E4368L,
+ 1E4369L,
+ 1E4370L,
+ 1E4371L,
+ 1E4372L,
+ 1E4373L,
+ 1E4374L,
+ 1E4375L,
+ 1E4376L,
+ 1E4377L,
+ 1E4378L,
+ 1E4379L,
+ 1E4380L,
+ 1E4381L,
+ 1E4382L,
+ 1E4383L,
+ 1E4384L,
+ 1E4385L,
+ 1E4386L,
+ 1E4387L,
+ 1E4388L,
+ 1E4389L,
+ 1E4390L,
+ 1E4391L,
+ 1E4392L,
+ 1E4393L,
+ 1E4394L,
+ 1E4395L,
+ 1E4396L,
+ 1E4397L,
+ 1E4398L,
+ 1E4399L,
+ 1E4400L,
+ 1E4401L,
+ 1E4402L,
+ 1E4403L,
+ 1E4404L,
+ 1E4405L,
+ 1E4406L,
+ 1E4407L,
+ 1E4408L,
+ 1E4409L,
+ 1E4410L,
+ 1E4411L,
+ 1E4412L,
+ 1E4413L,
+ 1E4414L,
+ 1E4415L,
+ 1E4416L,
+ 1E4417L,
+ 1E4418L,
+ 1E4419L,
+ 1E4420L,
+ 1E4421L,
+ 1E4422L,
+ 1E4423L,
+ 1E4424L,
+ 1E4425L,
+ 1E4426L,
+ 1E4427L,
+ 1E4428L,
+ 1E4429L,
+ 1E4430L,
+ 1E4431L,
+ 1E4432L,
+ 1E4433L,
+ 1E4434L,
+ 1E4435L,
+ 1E4436L,
+ 1E4437L,
+ 1E4438L,
+ 1E4439L,
+ 1E4440L,
+ 1E4441L,
+ 1E4442L,
+ 1E4443L,
+ 1E4444L,
+ 1E4445L,
+ 1E4446L,
+ 1E4447L,
+ 1E4448L,
+ 1E4449L,
+ 1E4450L,
+ 1E4451L,
+ 1E4452L,
+ 1E4453L,
+ 1E4454L,
+ 1E4455L,
+ 1E4456L,
+ 1E4457L,
+ 1E4458L,
+ 1E4459L,
+ 1E4460L,
+ 1E4461L,
+ 1E4462L,
+ 1E4463L,
+ 1E4464L,
+ 1E4465L,
+ 1E4466L,
+ 1E4467L,
+ 1E4468L,
+ 1E4469L,
+ 1E4470L,
+ 1E4471L,
+ 1E4472L,
+ 1E4473L,
+ 1E4474L,
+ 1E4475L,
+ 1E4476L,
+ 1E4477L,
+ 1E4478L,
+ 1E4479L,
+ 1E4480L,
+ 1E4481L,
+ 1E4482L,
+ 1E4483L,
+ 1E4484L,
+ 1E4485L,
+ 1E4486L,
+ 1E4487L,
+ 1E4488L,
+ 1E4489L,
+ 1E4490L,
+ 1E4491L,
+ 1E4492L,
+ 1E4493L,
+ 1E4494L,
+ 1E4495L,
+ 1E4496L,
+ 1E4497L,
+ 1E4498L,
+ 1E4499L,
+ 1E4500L,
+ 1E4501L,
+ 1E4502L,
+ 1E4503L,
+ 1E4504L,
+ 1E4505L,
+ 1E4506L,
+ 1E4507L,
+ 1E4508L,
+ 1E4509L,
+ 1E4510L,
+ 1E4511L,
+ 1E4512L,
+ 1E4513L,
+ 1E4514L,
+ 1E4515L,
+ 1E4516L,
+ 1E4517L,
+ 1E4518L,
+ 1E4519L,
+ 1E4520L,
+ 1E4521L,
+ 1E4522L,
+ 1E4523L,
+ 1E4524L,
+ 1E4525L,
+ 1E4526L,
+ 1E4527L,
+ 1E4528L,
+ 1E4529L,
+ 1E4530L,
+ 1E4531L,
+ 1E4532L,
+ 1E4533L,
+ 1E4534L,
+ 1E4535L,
+ 1E4536L,
+ 1E4537L,
+ 1E4538L,
+ 1E4539L,
+ 1E4540L,
+ 1E4541L,
+ 1E4542L,
+ 1E4543L,
+ 1E4544L,
+ 1E4545L,
+ 1E4546L,
+ 1E4547L,
+ 1E4548L,
+ 1E4549L,
+ 1E4550L,
+ 1E4551L,
+ 1E4552L,
+ 1E4553L,
+ 1E4554L,
+ 1E4555L,
+ 1E4556L,
+ 1E4557L,
+ 1E4558L,
+ 1E4559L,
+ 1E4560L,
+ 1E4561L,
+ 1E4562L,
+ 1E4563L,
+ 1E4564L,
+ 1E4565L,
+ 1E4566L,
+ 1E4567L,
+ 1E4568L,
+ 1E4569L,
+ 1E4570L,
+ 1E4571L,
+ 1E4572L,
+ 1E4573L,
+ 1E4574L,
+ 1E4575L,
+ 1E4576L,
+ 1E4577L,
+ 1E4578L,
+ 1E4579L,
+ 1E4580L,
+ 1E4581L,
+ 1E4582L,
+ 1E4583L,
+ 1E4584L,
+ 1E4585L,
+ 1E4586L,
+ 1E4587L,
+ 1E4588L,
+ 1E4589L,
+ 1E4590L,
+ 1E4591L,
+ 1E4592L,
+ 1E4593L,
+ 1E4594L,
+ 1E4595L,
+ 1E4596L,
+ 1E4597L,
+ 1E4598L,
+ 1E4599L,
+ 1E4600L,
+ 1E4601L,
+ 1E4602L,
+ 1E4603L,
+ 1E4604L,
+ 1E4605L,
+ 1E4606L,
+ 1E4607L,
+ 1E4608L,
+ 1E4609L,
+ 1E4610L,
+ 1E4611L,
+ 1E4612L,
+ 1E4613L,
+ 1E4614L,
+ 1E4615L,
+ 1E4616L,
+ 1E4617L,
+ 1E4618L,
+ 1E4619L,
+ 1E4620L,
+ 1E4621L,
+ 1E4622L,
+ 1E4623L,
+ 1E4624L,
+ 1E4625L,
+ 1E4626L,
+ 1E4627L,
+ 1E4628L,
+ 1E4629L,
+ 1E4630L,
+ 1E4631L,
+ 1E4632L,
+ 1E4633L,
+ 1E4634L,
+ 1E4635L,
+ 1E4636L,
+ 1E4637L,
+ 1E4638L,
+ 1E4639L,
+ 1E4640L,
+ 1E4641L,
+ 1E4642L,
+ 1E4643L,
+ 1E4644L,
+ 1E4645L,
+ 1E4646L,
+ 1E4647L,
+ 1E4648L,
+ 1E4649L,
+ 1E4650L,
+ 1E4651L,
+ 1E4652L,
+ 1E4653L,
+ 1E4654L,
+ 1E4655L,
+ 1E4656L,
+ 1E4657L,
+ 1E4658L,
+ 1E4659L,
+ 1E4660L,
+ 1E4661L,
+ 1E4662L,
+ 1E4663L,
+ 1E4664L,
+ 1E4665L,
+ 1E4666L,
+ 1E4667L,
+ 1E4668L,
+ 1E4669L,
+ 1E4670L,
+ 1E4671L,
+ 1E4672L,
+ 1E4673L,
+ 1E4674L,
+ 1E4675L,
+ 1E4676L,
+ 1E4677L,
+ 1E4678L,
+ 1E4679L,
+ 1E4680L,
+ 1E4681L,
+ 1E4682L,
+ 1E4683L,
+ 1E4684L,
+ 1E4685L,
+ 1E4686L,
+ 1E4687L,
+ 1E4688L,
+ 1E4689L,
+ 1E4690L,
+ 1E4691L,
+ 1E4692L,
+ 1E4693L,
+ 1E4694L,
+ 1E4695L,
+ 1E4696L,
+ 1E4697L,
+ 1E4698L,
+ 1E4699L,
+ 1E4700L,
+ 1E4701L,
+ 1E4702L,
+ 1E4703L,
+ 1E4704L,
+ 1E4705L,
+ 1E4706L,
+ 1E4707L,
+ 1E4708L,
+ 1E4709L,
+ 1E4710L,
+ 1E4711L,
+ 1E4712L,
+ 1E4713L,
+ 1E4714L,
+ 1E4715L,
+ 1E4716L,
+ 1E4717L,
+ 1E4718L,
+ 1E4719L,
+ 1E4720L,
+ 1E4721L,
+ 1E4722L,
+ 1E4723L,
+ 1E4724L,
+ 1E4725L,
+ 1E4726L,
+ 1E4727L,
+ 1E4728L,
+ 1E4729L,
+ 1E4730L,
+ 1E4731L,
+ 1E4732L,
+ 1E4733L,
+ 1E4734L,
+ 1E4735L,
+ 1E4736L,
+ 1E4737L,
+ 1E4738L,
+ 1E4739L,
+ 1E4740L,
+ 1E4741L,
+ 1E4742L,
+ 1E4743L,
+ 1E4744L,
+ 1E4745L,
+ 1E4746L,
+ 1E4747L,
+ 1E4748L,
+ 1E4749L,
+ 1E4750L,
+ 1E4751L,
+ 1E4752L,
+ 1E4753L,
+ 1E4754L,
+ 1E4755L,
+ 1E4756L,
+ 1E4757L,
+ 1E4758L,
+ 1E4759L,
+ 1E4760L,
+ 1E4761L,
+ 1E4762L,
+ 1E4763L,
+ 1E4764L,
+ 1E4765L,
+ 1E4766L,
+ 1E4767L,
+ 1E4768L,
+ 1E4769L,
+ 1E4770L,
+ 1E4771L,
+ 1E4772L,
+ 1E4773L,
+ 1E4774L,
+ 1E4775L,
+ 1E4776L,
+ 1E4777L,
+ 1E4778L,
+ 1E4779L,
+ 1E4780L,
+ 1E4781L,
+ 1E4782L,
+ 1E4783L,
+ 1E4784L,
+ 1E4785L,
+ 1E4786L,
+ 1E4787L,
+ 1E4788L,
+ 1E4789L,
+ 1E4790L,
+ 1E4791L,
+ 1E4792L,
+ 1E4793L,
+ 1E4794L,
+ 1E4795L,
+ 1E4796L,
+ 1E4797L,
+ 1E4798L,
+ 1E4799L,
+ 1E4800L,
+ 1E4801L,
+ 1E4802L,
+ 1E4803L,
+ 1E4804L,
+ 1E4805L,
+ 1E4806L,
+ 1E4807L,
+ 1E4808L,
+ 1E4809L,
+ 1E4810L,
+ 1E4811L,
+ 1E4812L,
+ 1E4813L,
+ 1E4814L,
+ 1E4815L,
+ 1E4816L,
+ 1E4817L,
+ 1E4818L,
+ 1E4819L,
+ 1E4820L,
+ 1E4821L,
+ 1E4822L,
+ 1E4823L,
+ 1E4824L,
+ 1E4825L,
+ 1E4826L,
+ 1E4827L,
+ 1E4828L,
+ 1E4829L,
+ 1E4830L,
+ 1E4831L,
+ 1E4832L,
+ 1E4833L,
+ 1E4834L,
+ 1E4835L,
+ 1E4836L,
+ 1E4837L,
+ 1E4838L,
+ 1E4839L,
+ 1E4840L,
+ 1E4841L,
+ 1E4842L,
+ 1E4843L,
+ 1E4844L,
+ 1E4845L,
+ 1E4846L,
+ 1E4847L,
+ 1E4848L,
+ 1E4849L,
+ 1E4850L,
+ 1E4851L,
+ 1E4852L,
+ 1E4853L,
+ 1E4854L,
+ 1E4855L,
+ 1E4856L,
+ 1E4857L,
+ 1E4858L,
+ 1E4859L,
+ 1E4860L,
+ 1E4861L,
+ 1E4862L,
+ 1E4863L,
+ 1E4864L,
+ 1E4865L,
+ 1E4866L,
+ 1E4867L,
+ 1E4868L,
+ 1E4869L,
+ 1E4870L,
+ 1E4871L,
+ 1E4872L,
+ 1E4873L,
+ 1E4874L,
+ 1E4875L,
+ 1E4876L,
+ 1E4877L,
+ 1E4878L,
+ 1E4879L,
+ 1E4880L,
+ 1E4881L,
+ 1E4882L,
+ 1E4883L,
+ 1E4884L,
+ 1E4885L,
+ 1E4886L,
+ 1E4887L,
+ 1E4888L,
+ 1E4889L,
+ 1E4890L,
+ 1E4891L,
+ 1E4892L,
+ 1E4893L,
+ 1E4894L,
+ 1E4895L,
+ 1E4896L,
+ 1E4897L,
+ 1E4898L,
+ 1E4899L,
+ 1E4900L,
+ 1E4901L,
+ 1E4902L,
+ 1E4903L,
+ 1E4904L,
+ 1E4905L,
+ 1E4906L,
+ 1E4907L,
+ 1E4908L,
+ 1E4909L,
+ 1E4910L,
+ 1E4911L,
+ 1E4912L,
+ 1E4913L,
+ 1E4914L,
+ 1E4915L,
+ 1E4916L,
+ 1E4917L,
+ 1E4918L,
+ 1E4919L,
+ 1E4920L,
+ 1E4921L,
+ 1E4922L,
+ 1E4923L,
+ 1E4924L,
+ 1E4925L,
+ 1E4926L,
+ 1E4927L,
+ 1E4928L,
+ 1E4929L,
+ 1E4930L,
+ 1E4931L,
+ 1E4932L,
+};
+
+Sftab_t _Sftable =
+{
+ { 1E1L, 1E2L, 1E4L, 1E8L, 1E16L, 1E32L },
+ { 1E-1L, 1E-2L, 1E-4L, 1E-8L, 1E-16L, 1E-32L },
+ { '0','0', '0','1', '0','2', '0','3', '0','4',
+ '0','5', '0','6', '0','7', '0','8', '0','9',
+ '1','0', '1','1', '1','2', '1','3', '1','4',
+ '1','5', '1','6', '1','7', '1','8', '1','9',
+ '2','0', '2','1', '2','2', '2','3', '2','4',
+ '2','5', '2','6', '2','7', '2','8', '2','9',
+ '3','0', '3','1', '3','2', '3','3', '3','4',
+ '3','5', '3','6', '3','7', '3','8', '3','9',
+ '4','0', '4','1', '4','2', '4','3', '4','4',
+ '4','5', '4','6', '4','7', '4','8', '4','9',
+ '5','0', '5','1', '5','2', '5','3', '5','4',
+ '5','5', '5','6', '5','7', '5','8', '5','9',
+ '6','0', '6','1', '6','2', '6','3', '6','4',
+ '6','5', '6','6', '6','7', '6','8', '6','9',
+ '7','0', '7','1', '7','2', '7','3', '7','4',
+ '7','5', '7','6', '7','7', '7','8', '7','9',
+ '8','0', '8','1', '8','2', '8','3', '8','4',
+ '8','5', '8','6', '8','7', '8','8', '8','9',
+ '9','0', '9','1', '9','2', '9','3', '9','4',
+ '9','5', '9','6', '9','7', '9','8', '9','9',
+ },
+ "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@_",
+ sfcvinit, 0,
+ sffmtpos,
+ sffmtint,
+ (float*)&sf_flt_pow10[0],
+ (double*)&sf_dbl_pow10[0],
+ (_ast_fltmax_t*)&sf_ldbl_pow10[0],
+};
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/sfio b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/sfio
new file mode 100644
index 0000000000..f642b0f436
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/sfio
@@ -0,0 +1,16 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/sfio by iffe version 2007-04-04 : : */
+#ifndef _def_sfio_ast
+#define _def_sfio_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_float 1 /* #include <float.h> ok */
+#define _hdr_floatingpoint 1 /* #include <floatingpoint.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _hdr_values 1 /* #include <values.h> ok */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _key_signed 1 /* signed is a reserved keyword */
+#define _more_void_int 1 /* voidptr is larger than int */
+#define _more_long_int 1 /* long is larger than int */
+#define _lib_cvt 1 /* native floating point conversions ok */
+#define _xopen_stdio 1 /* Stdio fseek/fflush are X/Open-compliant */
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/sig b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/sig
new file mode 100644
index 0000000000..5edc503e1f
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/sig
@@ -0,0 +1,131 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/sig.sh by iffe version 2007-04-04 : : */
+#ifndef _def_sig_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_sig_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define sig_info _sig_info_
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide kill killpg
+#else
+#define kill ______kill
+#define killpg ______killpg
+#endif
+#include <signal.h>
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide kill killpg
+#else
+#undef kill
+#undef killpg
+#endif
+#ifndef sigmask
+#define sigmask(s) (1<<((s)-1))
+#endif
+typedef void (*Sig_handler_t) __PROTO__((int));
+
+
+#define Handler_t Sig_handler_t
+
+#define SIG_REG_PENDING (-1)
+#define SIG_REG_POP 0
+#define SIG_REG_EXEC 00001
+#define SIG_REG_PROC 00002
+#define SIG_REG_TERM 00004
+#define SIG_REG_ALL 00777
+#define SIG_REG_SET 01000
+
+typedef struct
+{
+ char** name;
+ char** text;
+ int sigmax;
+} Sig_info_t;
+
+extern __MANGLE__ int kill __PROTO__((pid_t, int));
+extern __MANGLE__ int killpg __PROTO__((pid_t, int));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Sig_info_t sig_info;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int sigcritical __PROTO__((int));
+extern __MANGLE__ int sigunblock __PROTO__((int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/signal b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/signal
new file mode 100644
index 0000000000..e95c9f5270
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/signal
@@ -0,0 +1,175 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/signal.c by iffe version 2007-04-04 : : */
+#ifndef _def_signal_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_signal_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define SIG_MAX 48
+
+static const char* const sig_name[] =
+{
+ "0",
+ "HUP",
+ "INT",
+ "QUIT",
+ "ILL",
+ "TRAP",
+ "IOT",
+ "EMT",
+ "FPE",
+ "KILL",
+ "BUS",
+ "SEGV",
+ "SYS",
+ "PIPE",
+ "ALRM",
+ "TERM",
+ "USR1",
+ "USR2",
+ "CHLD",
+ "PWR",
+ "WINCH",
+ "URG",
+ "IO",
+ "STOP",
+ "TSTP",
+ "CONT",
+ "TTIN",
+ "TTOU",
+ "VTALRM",
+ "PROF",
+ "XCPU",
+ "XFSZ",
+ "WAITING",
+ "LWP",
+ "FREEZE",
+ "THAW",
+ "36",
+ "LOST",
+ "38",
+ "39",
+ "40",
+ "RTMIN",
+ "RT1",
+ "RT2",
+ "RT3",
+ "RT4",
+ "RT5",
+ "RT6",
+ "RTMAX",
+ 0
+};
+
+static const char* const sig_text[] =
+{
+ "Signal 0",
+ "Hangup",
+ "Interrupt",
+ "Quit",
+ "Illegal instruction",
+ "Trace trap",
+ "IOT trap",
+ "EMT trap",
+ "Floating exception",
+ "Killed",
+ "Bus error",
+ "Memory fault",
+ "Bad system call",
+ "Broken pipe",
+ "Alarm call",
+ "Terminated",
+ "User signal 1",
+ "User signal 2",
+ "Child status change",
+ "Power fail",
+ "Window change",
+ "Urgent IO",
+ "IO possible",
+ "Stopped (signal)",
+ "Stopped",
+ "Stopped process continued",
+ "Stopped (tty input)",
+ "Stopped (tty output)",
+ "Virtual timer alarm",
+ "Profile timer alarm",
+ "CPU time limit",
+ "File size limit",
+ "All threads blocked",
+ "Thread event",
+ "CPR freeze",
+ "CPR thaw",
+ "Signal 36",
+ "Resources lost",
+ "Signal 38",
+ "Signal 39",
+ "Signal 40",
+ "Realtime priority 0 (lo)",
+ "Realtime priority 1",
+ "Realtime priority 2",
+ "Realtime priority 3",
+ "Realtime priority 4",
+ "Realtime priority 5",
+ "Realtime priority 6",
+ "Realtime priority 7 (hi)",
+ 0
+};
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/standards b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/standards
new file mode 100644
index 0000000000..8e8231de26
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/standards
@@ -0,0 +1,28 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/standards by iffe version 2007-04-04 : : */
+#ifndef _def_standards_ast
+#define _def_standards_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* _ALL_SOURCE & _ISOC99_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works */
+#ifndef _ALL_SOURCE
+#define _ALL_SOURCE 1
+#endif
+#ifndef _ISOC99_SOURCE
+#define _ISOC99_SOURCE 1
+#endif
+#ifndef _POSIX_SOURCE
+#define _POSIX_SOURCE 1
+#endif
+#ifndef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 21000101L
+#endif
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 9900
+#endif
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#ifndef __EXTENSIONS__
+#define __EXTENSIONS__ 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/stdio b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/stdio
new file mode 100644
index 0000000000..b17026ca22
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/stdio
@@ -0,0 +1,579 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/stdio by iffe version 2007-04-04 : : */
+
+#ifndef _SFSTDIO_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SFSTDIO_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define __FILE_typedef 1
+#define _FILE_DEFINED 1
+#define _FILE_defined 1
+#define _FILEDEFED 1
+
+#ifndef __FILE_TAG
+#define __FILE_TAG _sfio_s
+#endif
+
+#undef FILE
+#undef _FILE
+#undef fpos_t
+#undef fpos64_t
+
+typedef struct _sfio_s _sfio_FILE;
+
+#define FILE _sfio_FILE
+#define _FILE FILE
+
+#if !defined(__FILE) && !__CYGWIN__
+#undef __FILE
+#define __FILE FILE
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define BUFSIZ SF_BUFSIZE
+
+#else
+
+#ifndef BUFSIZ
+#define BUFSIZ 8192
+#endif
+
+#ifndef EOF
+#define EOF (-1)
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+#include <ast_std.h>
+
+#include <sfio_s.h>
+
+#if __cplusplus
+#define _sf_(f) (f)
+#else
+#define _sf_(f) ((struct _sfio_s*)(f))
+#endif
+
+#define _SF_EOF 0000200
+#define _SF_ERROR 0000400
+
+#endif
+
+#ifdef _NO_LARGEFILE64_SOURCE
+#undef _LARGEFILE64_SOURCE
+#endif
+
+#ifdef _LARGEFILE64_SOURCE
+#undef off_t
+#endif
+
+#define fpos_t _ast_fpos_t
+#if _typ_int64_t
+#define fpos64_t _ast_fpos_t
+#endif
+
+typedef struct _ast_fpos_s
+{
+ intmax_t _sf_offset;
+ unsigned char _sf_state[64 - sizeof(intmax_t)];
+} _ast_fpos_t;
+
+#define _base _data
+#define _ptr _next
+#define _IOFBF 0
+#define _IONBF 1
+#define _IOLBF 2
+
+#if defined(__cplusplus) && defined(__THROW) && !defined(_UWIN)
+
+#undef FILE
+#define FILE FILE
+typedef struct _sfio_s FILE;
+
+#undef strerror
+extern __MANGLE__ char* strerror(int) __THROW;
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#endif
+
+#ifndef FILENAME_MAX
+#define FILENAME_MAX 1024
+#endif
+#ifndef FOPEN_MAX
+#define FOPEN_MAX 20
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+
+#define _doprnt _ast_doprnt
+#define _doscan _ast_doscan
+#define asprintf _ast_asprintf
+#define clearerr _ast_clearerr
+#define fclose _ast_fclose
+#define fdopen _ast_fdopen
+#define fflush _ast_fflush
+#define fgetc _ast_fgetc
+#define fgetpos _ast_fgetpos
+#define fgetpos64 _ast_fgetpos64
+#define fgets _ast_fgets
+#define fopen _ast_fopen
+#define fprintf _ast_fprintf
+#define fpurge _ast_fpurge
+#define fputs _ast_fputs
+#define fread _ast_fread
+#define freopen _ast_freopen
+#define fscanf _ast_fscanf
+#define fseek _ast_fseek
+#define fseek64 _ast_fseek64
+#define fseeko _ast_fseeko
+#define fseeko64 _ast_fseeko64
+#define fsetpos _ast_fsetpos
+#define fsetpos64 _ast_fsetpos64
+#define ftell _ast_ftell
+#define ftell64 _ast_ftell64
+#define ftello _ast_ftello
+#define ftello64 _ast_ftello64
+#define fwrite _ast_fwrite
+#define gets _ast_gets
+#define getw _ast_getw
+#define pclose _ast_pclose
+#define popen _ast_popen
+#define printf _ast_printf
+#define puts _ast_puts
+#define putw _ast_putw
+#define rewind _ast_rewind
+#define scanf _ast_scanf
+#define setbuf _ast_setbuf
+#undef setbuffer
+#define setbuffer _ast_setbuffer
+#define setlinebuf _ast_setlinebuf
+#define setvbuf _ast_setvbuf
+#define snprintf _ast_snprintf
+#define sprintf _ast_sprintf
+#define sscanf _ast_sscanf
+#define tmpfile _ast_tmpfile
+#define ungetc _ast_ungetc
+#define vasprintf _ast_vasprintf
+#define vfprintf _ast_vfprintf
+#define vfscanf _ast_vfscanf
+#define vprintf _ast_vprintf
+#define vscanf _ast_vscanf
+#define vsnprintf _ast_vsnprintf
+#define vsprintf _ast_vsprintf
+#define vsscanf _ast_vsscanf
+#define fcloseall _ast_fcloseall
+#define fmemopen _ast_fmemopen
+#define __getdelim _ast___getdelim
+#define getdelim _ast_getdelim
+#define getline _ast_getline
+#define clearerr_unlocked _ast_clearerr_unlocked
+#define feof_unlocked _ast_feof_unlocked
+#define ferror_unlocked _ast_ferror_unlocked
+#define fflush_unlocked _ast_fflush_unlocked
+#define fgetc_unlocked _ast_fgetc_unlocked
+#define fgets_unlocked _ast_fgets_unlocked
+#define fileno_unlocked _ast_fileno_unlocked
+#define fputc_unlocked _ast_fputc_unlocked
+#define fputs_unlocked _ast_fputs_unlocked
+#define fread_unlocked _ast_fread_unlocked
+#define fwrite_unlocked _ast_fwrite_unlocked
+#define getc_unlocked _ast_getc_unlocked
+#define getchar_unlocked _ast_getchar_unlocked
+#define putc_unlocked _ast_putc_unlocked
+#define putchar_unlocked _ast_putchar_unlocked
+
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef P_tmpdir
+#define P_tmpdir "/var/tmp/" /*NOCATLITERAL*/
+#endif
+#ifndef L_ctermid
+#define L_ctermid 9
+#endif
+#ifndef L_tmpnam
+#define L_tmpnam 25
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#if defined(__cplusplus) && defined(__THROW)
+extern __MANGLE__ char* ctermid(char*) __THROW;
+#else
+extern __MANGLE__ char* ctermid __PROTO__((char*));
+#endif
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+extern __MANGLE__ void perror __PROTO__((const char*));
+#ifndef _AST_STD_H
+#ifndef remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#endif
+#ifndef rename
+extern __MANGLE__ int rename __PROTO__((const char*, const char*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#ifdef _LARGEFILE64_SOURCE
+
+#undef fpos_t
+#undef off_t
+#undef fgetpos
+#undef fsetpos
+#undef fseek
+#undef fseeko
+#undef ftell
+#undef ftello
+
+#define fpos_t fpos64_t
+#if _typ_off64_t
+#define off_t off64_t
+#else
+#define off_t int64_t
+#endif
+
+#define fgetpos fgetpos64
+#define fsetpos fsetpos64
+#define fseek fseek64
+#define fseeko fseeko64
+#define ftell ftell64
+#define ftello ftello64
+
+#endif
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_DLL && _DLL_INDIRECT_DATA
+
+#define stdin ((FILE*)_ast_dll->_ast_stdin)
+#define stdout ((FILE*)_ast_dll->_ast_stdout)
+#define stderr ((FILE*)_ast_dll->_ast_stderr)
+
+#else
+
+#define stdin (&_Sfstdin)
+#define stdout (&_Sfstdout)
+#define stderr (&_Sfstderr)
+
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define feof(f) sfeof(f)
+#define ferror(f) sferror(f)
+#define fileno(f) sffileno(f)
+#define fputc(c,f) sfputc(f,c)
+#define getc(f) sfgetc(f)
+#define getchar() sfgetc(sfstdin)
+#define putc(c,f) sfputc(f,c)
+#define putchar(c) sfputc(sfstdout,c)
+
+#else
+
+#if !_UWIN
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+#endif
+
+extern __MANGLE__ FILE _Sfstdin;
+extern __MANGLE__ FILE _Sfstdout;
+extern __MANGLE__ FILE _Sfstderr;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define feof(f) (_sf_(f)->_flags&_SF_EOF)
+#define ferror(f) (_sf_(f)->_flags&_SF_ERROR)
+#define fileno(f) (_sf_(f)->_file)
+#define fputc(c,f) (_sf_(f)->_next>=_sf_(f)->_endw?_sfflsbuf(_sf_(f),(int)((unsigned char)(c))):(int)(*_sf_(f)->_next++=(unsigned char)(c)))
+#define getc(f) (_sf_(f)->_next>=_sf_(f)->_endr?_sffilbuf(_sf_(f),0):(int)(*_sf_(f)->_next++))
+#define getchar() getc(stdin)
+#define putc(c,f) fputc(c,f)
+#define putchar(c) fputc(c,stdout)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _sffilbuf __PROTO__((FILE*, int));
+extern __MANGLE__ int _sfflsbuf __PROTO__((FILE*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/sys b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/sys
new file mode 100644
index 0000000000..f0a58dff12
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/sys
@@ -0,0 +1,151 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/sys by iffe version 2007-04-04 : : */
+
+#ifndef _AST_SYS_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_SYS_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#if __mips == 2 && !defined(_NO_LARGEFILE64_SOURCE)
+#define _NO_LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_NO_LARGEFILE64_SOURCE) && _typ_off64_t && _lib_lseek64 && _lib_stat64
+#if !defined(_LARGEFILE64_SOURCE)
+#define _LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_LARGEFILE_SOURCE)
+#define _LARGEFILE_SOURCE 1
+#endif
+#else
+#undef _LARGEFILE64_SOURCE
+#undef _LARGEFILE_SOURCE
+#undef _typ_off64_t
+#undef _typ_struct_dirent64
+#undef _lib_creat64
+#undef _lib_fstat64
+#undef _lib_fstatvfs64
+#undef _lib_ftruncate64
+#undef _lib_lseek64
+#undef _lib_lstat64
+#undef _lib_mmap64
+#undef _lib_open64
+#undef _lib_readdir64
+#undef _lib_stat64
+#undef _lib_statvfs64
+#undef _lib_truncate64
+#endif
+#if defined(__STDC__) && !defined(__USE_FIXED_PROTOTYPES__)
+#define __USE_FIXED_PROTOTYPES__ 1 /* kick gcc out of the past */
+#endif
+#include <stdlib.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <locale.h>
+#include <sys/localedef.h>
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _typ_dev_t 1 /* dev_t is a type */
+#define _typ_nlink_t 1 /* nlink_t is a type */
+#define _typ_gid_t 1 /* gid_t is a type */
+#define _typ_mode_t 1 /* mode_t is a type */
+#define _typ_uid_t 1 /* uid_t is a type */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _typ_wchar_t 1 /* wchar_t is a type */
+#define _typ_pid_t 1 /* pid_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _typ_wint_t 1 /* wint_t is a type */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _typ_socklen_t 1 /* socklen_t is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_ino_t 1 /* ino_t is a type */
+#define _typ_off_t 1 /* off_t is a type */
+#define _typ_ptrdiff_t 1 /* ptrdiff_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#define _typ_div_t 1 /* div_t is a type */
+#define _typ_ldiv_t 1 /* ldiv_t is a type */
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+extern __MANGLE__ int eaccess __PROTO__((const char*, int));
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+extern __MANGLE__ __V_* pvalloc __PROTO__((size_t));
+extern __MANGLE__ pid_t spawnveg __PROTO__((const char*, char* const[], char* const[], pid_t));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#if !defined(va_start)
+#if defined(__STDARG__)
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/time b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/time
new file mode 100644
index 0000000000..6c57971e4b
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/time
@@ -0,0 +1,83 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/time by iffe version 2007-04-04 : : */
+
+#ifndef _def_time_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_time_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_nanosleep 1 /* nanosleep() in default lib(s) */
+#define _lib_usleep 1 /* usleep() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#include <sys/time.h>
+
+#include <sys/times.h>
+
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC CLK_TCK
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tmlib b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tmlib
new file mode 100644
index 0000000000..7721ece7ff
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tmlib
@@ -0,0 +1,68 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/tmlib by iffe version 2007-04-04 : : */
+
+#ifndef _def_tmlib_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_tmlib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define tmlocaltime(p) localtime(p)
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tmx b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tmx
new file mode 100644
index 0000000000..8034e1cd9e
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tmx
@@ -0,0 +1,128 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/tmx by iffe version 2007-04-04 : : */
+
+#ifndef _TMX_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TMX_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Time_t support
+ */
+
+#include <tm.h>
+#include <tv.h>
+
+#define TMX_MAXDATE "2554-07-21+23:34:33.709551614 UTC"
+#define TMX_MAXYEAR 2554
+#define TMX_MAXSEC ((Time_t)18446744073)
+#define TMX_MAXNSEC 709551614
+#define TMX_RESOLUTION 1000000000
+
+typedef uint64_t Time_t;
+typedef uint64_t Tmxsec_t;
+typedef uint32_t Tmxnsec_t;
+
+#define tmxsec(t) ((Tmxsec_t)((t)/1000000000))
+#define tmxnsec(t) ((Tmxnsec_t)((t)%1000000000))
+#define tmxsns(s,n) (((((Time_t)(s))*1000000000))+((Time_t)(n)))
+
+#define TMX_NOTIME ((Time_t)(-1))
+#define TMX_NOW tmxgettime()
+#define TMX_MAXTIME tmxsns(TMX_MAXSEC,TMX_MAXNSEC)
+
+#define tmx2tv(t,v) ((v)->tv_nsec=tmxnsec(t),(v)->tv_sec=tmxsec(t))
+#define tv2tmx(v) tmxsns((v)->tv_sec,(v)->tv_nsec)
+
+#define tmxclock(p) tmxsns(((p)?*(p):time(NiL)),0)
+
+#define tmxgetatime(s) tmxsns((s)->st_atime,ST_ATIME_NSEC_GET(s))
+#define tmxgetctime(s) tmxsns((s)->st_ctime,ST_CTIME_NSEC_GET(s))
+#define tmxgetmtime(s) tmxsns((s)->st_mtime,ST_MTIME_NSEC_GET(s))
+
+#define tmxsetatime(s,t) ((s)->st_atime=tmxsec(t),ST_ATIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetctime(s,t) ((s)->st_ctime=tmxsec(t),ST_CTIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetmtime(s,t) ((s)->st_mtime=tmxsec(t),ST_MTIME_NSEC_SET(s,tmxnsec(t)))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Time_t tmxdate __PROTO__((const char*, char**, Time_t));
+extern __MANGLE__ char* tmxfmt __PROTO__((char*, size_t, const char*, Time_t));
+extern __MANGLE__ Time_t tmxleap __PROTO__((Time_t));
+extern __MANGLE__ Tm_t* tmxmake __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxscan __PROTO__((const char*, char**, const char*, char**, Time_t, long));
+extern __MANGLE__ int tmxsleep __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxtime __PROTO__((Tm_t*, int));
+
+extern __MANGLE__ Time_t tmxgettime __PROTO__((void));
+extern __MANGLE__ int tmxsettime __PROTO__((Time_t));
+
+extern __MANGLE__ int tmxtouch __PROTO__((const char*, Time_t, Time_t, Time_t, int));
+
+extern __MANGLE__ char* fmttmx __PROTO__((const char*, Time_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tty b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tty
new file mode 100644
index 0000000000..42f0c1df21
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tty
@@ -0,0 +1,134 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/tty by iffe version 2007-04-04 : : */
+#ifndef _def_tty_ast
+#define _def_tty_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_termios 1 /* #include <termios.h> ok */
+#define _hdr_termio 1 /* #include <termio.h> ok */
+#define _hdr_sgtty 1 /* #include <sgtty.h> ok */
+#define _sys_termios 1 /* #include <sys/termios.h> ok */
+#define _sys_termio 1 /* #include <sys/termio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _lib_tcgetattr 1 /* tcgetattr() in default lib(s) */
+#define _lib_tcgetpgrp 1 /* tcgetpgrp() in default lib(s) */
+#define _mac__POSIX_VDISABLE 1 /* _POSIX_VDISABLE is a macro */
+
+#ifdef _hdr_termios
+# if _mac__POSIX_VDISABLE
+# undef _POSIX_VDISABLE
+# endif
+# include <termios.h>
+#else
+# if defined(_sys_termios) && defined(_lib_tcgetattr)
+# include <sys/termios.h>
+# define _hdr_termios 1
+# else
+# undef _sys_termios
+# endif /* _sys_termios */
+#endif /* _hdr_termios */
+
+#ifdef _hdr_termios
+# undef _hdr_sgtty
+# undef tcgetattr
+# undef tcsetattr
+# undef tcgetpgrp
+# undef tcsetpgrp
+# undef cfgetospeed
+# ifndef TCSANOW
+# define TCSANOW TCSETS
+# define TCSADRAIN TCSETSW
+# define TCSAFLUSH TCSETSF
+# endif /* TCSANOW */
+ /* The following corrects bugs in some implementations */
+# if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
+# define TCSAFLUSH TCSADFLUSH
+# endif /* TCSADFLUSH */
+# ifndef _lib_tcgetattr
+# undef tcgetattr
+# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
+# undef tcsetattr
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# undef cfgetospeed
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# endif /* _lib_tcgetattr */
+# undef TIOCGETC
+#else
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfgetispeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfsetispeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# define cfsetospeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# ifdef _hdr_termio
+# include <termio.h>
+# else
+# ifdef _sys_termio
+# include <sys/termio.h>
+# define _hdr_termio 1
+# endif /* _sys_termio */
+# endif /* _hdr_termio */
+# ifdef _hdr_termio
+# define termios termio
+# undef TIOCGETC
+# define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+
+# ifdef _sys_bsdtty
+# include <sys/bsdtty.h>
+# endif /* _sys_bsdtty */
+# else
+# ifdef _hdr_sgtty
+# include <sgtty.h>
+# ifndef LPENDIN
+# ifdef _sys_nttyio
+# include <sys/nttyio.h>
+# endif /* _sys_nttyio */
+# endif /* LPENDIN */
+# define termios sgttyb
+# ifdef TIOCSETN
+# undef TCSETAW
+# endif /* TIOCSETN */
+# ifdef TIOCGETP
+# define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# else
+# define tcgetattr(fd,tty) gtty(fd, tty)
+# define tcsetattr(fd,action,tty) stty(fd, tty)
+# endif /* TIOCGETP */
+# else
+# ifdef _sys_ttyio
+# include <sys/ttyio.h>
+# endif
+# endif /* _hdr_sgtty */
+# endif /* hdr_termio */
+
+# ifndef TCSANOW
+# ifdef TCSETAW
+# define TCSANOW TCSETA
+# define TCSAFLUSH TCSETAF
+# else
+# ifdef TIOCSETN
+# define TCSANOW TIOCSETN
+# define TCSADRAIN TIOCSETN
+# define TCSAFLUSH TIOCSETP
+# endif /* TIOCSETN */
+# endif /* TCSETAW */
+# endif /* TCSANOW */
+#endif /* _hdr_termios */
+
+/* set ECHOCTL if driver can echo control charaters as ^c */
+#ifdef LCTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LCTLECH
+# endif /* !ECHOCTL */
+#endif /* LCTLECH */
+#ifdef LNEW_CTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LNEW_CTLECH
+# endif /* !ECHOCTL */
+#endif /* LNEW_CTLECH */
+#ifdef LNEW_PENDIN
+# ifndef PENDIN
+# define PENDIN LNEW_PENDIN
+# endif /* !PENDIN */
+#endif /* LNEW_PENDIN */
+
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tv b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tv
new file mode 100644
index 0000000000..6692382606
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tv
@@ -0,0 +1,111 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/tv by iffe version 2007-04-04 : : */
+
+#ifndef _TV_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TV_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Tv_t interface definitions
+ */
+
+#include <ast.h>
+
+#define TV_NSEC_IGNORE (1000000000L)
+#define TV_TOUCH_RETAIN ((Tv_t*)1)
+
+typedef struct Tv_s
+{
+ uint32_t tv_sec;
+ uint32_t tv_nsec;
+} Tv_t;
+
+#define ST_ATIME_NSEC_GET(st) ((st)->st_atim.tv_nsec)
+#define ST_CTIME_NSEC_GET(st) ((st)->st_ctim.tv_nsec)
+#define ST_MTIME_NSEC_GET(st) ((st)->st_mtim.tv_nsec)
+
+#define ST_ATIME_NSEC_SET(st,n) (ST_ATIME_NSEC_GET(st)=(n))
+#define ST_CTIME_NSEC_SET(st,n) (ST_CTIME_NSEC_GET(st)=(n))
+#define ST_MTIME_NSEC_SET(st,n) (ST_MTIME_NSEC_GET(st)=(n))
+
+#define tvgetatime(t,s) ((t)->tv_nsec=ST_ATIME_NSEC_GET(s),(t)->tv_sec=(s)->st_atime)
+#define tvgetmtime(t,s) ((t)->tv_nsec=ST_MTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_mtime)
+#define tvgetctime(t,s) ((t)->tv_nsec=ST_CTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_ctime)
+
+#define tvsetatime(t,s) (ST_ATIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_atime=(t)->tv_sec)
+#define tvsetmtime(t,s) (ST_MTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_mtime=(t)->tv_sec)
+#define tvsetctime(t,s) (ST_CTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_ctime=(t)->tv_sec)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int tvgettime __PROTO__((Tv_t*));
+extern __MANGLE__ int tvsettime __PROTO__((const Tv_t*));
+extern __MANGLE__ int tvcmp __PROTO__((const Tv_t*, const Tv_t*));
+extern __MANGLE__ int tvtouch __PROTO__((const char*, const Tv_t*, const Tv_t*, const Tv_t*, int));
+extern __MANGLE__ int tvsleep __PROTO__((const Tv_t*, Tv_t*));
+
+extern __MANGLE__ char* fmttv __PROTO__((const char*, Tv_t*));
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tvlib b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tvlib
new file mode 100644
index 0000000000..30f4596208
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/tvlib
@@ -0,0 +1,17 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/tvlib by iffe version 2007-04-04 : : */
+#ifndef _def_tvlib_ast
+#define _def_tvlib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _lib_clock_settime 1 /* clock_settime() in default lib(s) */
+#define _lib_gettimeofday 1 /* gettimeofday() in default lib(s) */
+#define _lib_settimeofday 1 /* settimeofday() in default lib(s) */
+#define _lib_stime 1 /* stime() in default lib(s) */
+#define _lib_utimes 1 /* utimes() in default lib(s) */
+#define _lib_nanosleep 1 /* nanosleep() in default lib(s) */
+#define _lib_usleep 1 /* usleep() in default lib(s) */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _lib_clock_gettime 1 /* execute{\ passed */
+#define tmgettimeofday(p) gettimeofday(p,(struct timezone*)0)
+#define tmsettimeofday(p) settimeofday(p,(struct timezone*)0)
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/types b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/types
new file mode 100644
index 0000000000..343b5954a0
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/types
@@ -0,0 +1,5 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_types_ast
+#define _def_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/uwin b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/uwin
new file mode 100644
index 0000000000..40cf5bef90
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/uwin
@@ -0,0 +1,17 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/uwin by iffe version 2007-04-04 : : */
+#ifndef _def_uwin_ast
+#define _def_uwin_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_a64l 1 /* a64l() in default lib(s) */
+#define _lib_crypt 1 /* crypt() in default lib(s) */
+#define _lib_getpass 1 /* getpass() in default lib(s) */
+#define _lib_random 1 /* random() in default lib(s) */
+#define _lib_rcmd 1 /* rcmd() in default lib(s) */
+#define _lib_srand48 1 /* srand48() in default lib(s) */
+#define _lib_logb 1 /* logb() in default lib(s) */
+#define _lib_finite 1 /* finite() in default lib(s) */
+#define _lib_scalb 1 /* scalb() in default lib(s) */
+#define _lib__finite 1 /* _finite() in default lib(s) */
+#define _lib__scalb 1 /* _scalb() in default lib(s) */
+#define _dat__iob 1 /* _iob in default lib(s) */
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/vfork b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/vfork
new file mode 100644
index 0000000000..901931c5ec
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/vfork
@@ -0,0 +1,67 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/vfork by iffe version 2007-04-04 : : */
+
+#ifndef _def_vfork_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_vfork_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+extern __MANGLE__ pid_t vfork __PROTO__((void));
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/vmalloc b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/vmalloc
new file mode 100644
index 0000000000..cbcde955d0
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/vmalloc
@@ -0,0 +1,36 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/vmalloc by iffe version 2007-04-04 : : */
+#ifndef _def_vmalloc_ast
+#define _def_vmalloc_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_atexit 1 /* atexit() in default lib(s) */
+#define _lib_getpagesize 1 /* getpagesize() in default lib(s) */
+#define _lib_memalign 1 /* memalign() in default lib(s) */
+#define _lib_strdup 1 /* strdup() in default lib(s) */
+#define _lib_valloc 1 /* valloc() in default lib(s) */
+#define _hdr_alloca 1 /* #include <alloca.h> ok */
+#define _hdr_malloc 1 /* #include <malloc.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _mem_arena_mallinfo 1 /* arena is a member of struct mallinfo */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _mem_sbrk 1 /* brk()/sbrk() work as expected */
+#define _lib_alloca 1 /* alloca exists */
+#define _stk_down 1 /* stack grows downward */
+#include "FEATURE/mmap"
+#if _BLD_INSTRUMENT || cray || _UWIN && _BLD_ast
+#undef _map_malloc
+#define _std_malloc 1 /* defer to standard malloc */
+#endif
+#if _mmap_anon
+#define _mem_mmap_anon 1
+#endif
+#if _mmap_devzero
+#define _mem_mmap_zero 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/wait b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/wait
new file mode 100644
index 0000000000..96f7b01d8b
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/wait
@@ -0,0 +1,11 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/wait by iffe version 2007-04-04 : : */
+#ifndef _def_wait_ast
+#define _def_wait_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_wait 1 /* wait() in default lib(s) */
+#define _lib_wait3 1 /* wait3() in default lib(s) */
+#define _lib_wait4 1 /* wait4() in default lib(s) */
+#define _lib_waitpid 1 /* waitpid() in default lib(s) */
+#define _sys_wait 1 /* #include <sys/wait.h> ok */
+#define _ok_wif 1 /* posix wait macros ok */
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/wchar b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/wchar
new file mode 100644
index 0000000000..6531edc5fd
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/FEATURE/wchar
@@ -0,0 +1,187 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/wchar by iffe version 2007-04-04 : : */
+
+#ifndef _def_wchar_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_wchar_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _lib_mbstowcs 1 /* mbstowcs() in default lib(s) */
+#define _lib_wctomb 1 /* wctomb() in default lib(s) */
+#define _lib_wcrtomb 1 /* wcrtomb() in default lib(s) */
+#define _lib_wcslen 1 /* wcslen() in default lib(s) */
+#define _lib_wcstombs 1 /* wcstombs() in default lib(s) */
+#define _lib_wcwidth 1 /* wcwidth() in default lib(s) */
+#define _lib_towlower 1 /* towlower() in default lib(s) */
+#define _lib_towupper 1 /* towupper() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_mbstate_t 1 /* mbstate_t is a type */
+#define _nxt_wchar <../include/wchar.h> /* include path for the native <wchar.h> */
+#define _nxt_wchar_str "../include/wchar.h" /* include string for the native <wchar.h> */
+#ifndef _SFSTDIO_H
+#include <ast_common.h>
+#include <stdio.h>
+#endif
+#if _hdr_wchar && defined(_nxt_wchar)
+#include <../include/wchar.h> /* the native wchar.h */
+#endif
+#if _hdr_wctype
+#include <wctype.h>
+#endif
+
+#ifndef WEOF
+#define WEOF (-1)
+#endif
+
+#undef fgetwc
+#undef fgetws
+#undef fputwc
+#undef fputws
+#undef getwc
+#undef getwchar
+#undef getws
+#undef putwc
+#undef putwchar
+#undef ungetwc
+
+#define fgetwc _ast_fgetwc
+#define fgetws _ast_fgetws
+#define fputwc _ast_fputwc
+#define fputws _ast_fputws
+#define fwide _ast_fwide
+#define fwprintf _ast_fwprintf
+#define fwscanf _ast_fwscanf
+#define getwc _ast_getwc
+#define getwchar _ast_getwchar
+#define getws _ast_getws
+#define putwc _ast_putwc
+#define putwchar _ast_putwchar
+#define swprintf _ast_swprintf
+#define swscanf _ast_swscanf
+#define ungetwc _ast_ungetwc
+#define vfwprintf _ast_vfwprintf
+#define vfwscanf _ast_vfwscanf
+#define vswprintf _ast_vswprintf
+#define vswscanf _ast_vswscanf
+#define vwprintf _ast_vwprintf
+#define vwscanf _ast_vwscanf
+#define wprintf _ast_wprintf
+#define wscanf _ast_wscanf
+
+#if !_typ_mbstate_t
+#undef _typ_mbstate_t
+#define _typ_mbstate_t 1
+typedef char mbstate_t;
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#if !_lib_mbstowcs
+extern __MANGLE__ size_t mbstowcs __PROTO__((wchar_t*, const char*, size_t));
+#endif
+#if !_lib_wctomb
+extern __MANGLE__ int wctomb __PROTO__((char*, wchar_t));
+#endif
+#if !_lib_wcrtomb
+extern __MANGLE__ size_t wcrtomb __PROTO__((char*, wchar_t, mbstate_t*));
+#endif
+#if !_lib_wcslen
+extern __MANGLE__ size_t wcslen __PROTO__((const wchar_t*));
+#endif
+#if !_lib_wcstombs
+extern __MANGLE__ size_t wcstombs __PROTO__((char*, const wchar_t*, size_t));
+#endif
+
+extern __MANGLE__ int fwprintf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ int fwscanf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ wint_t fgetwc __PROTO__((FILE*));
+extern __MANGLE__ wchar_t* fgetws __PROTO__((wchar_t*, int, FILE*));
+extern __MANGLE__ wint_t fputwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ int fputws __PROTO__((const wchar_t*, FILE*));
+extern __MANGLE__ int fwide __PROTO__((FILE*, int));
+extern __MANGLE__ wint_t getwc __PROTO__((FILE*));
+extern __MANGLE__ wint_t getwchar __PROTO__((void));
+extern __MANGLE__ wchar_t* getws __PROTO__((wchar_t*));
+extern __MANGLE__ wint_t putwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ wint_t putwchar __PROTO__((wchar_t));
+extern __MANGLE__ int swprintf __PROTO__((wchar_t*, size_t, const wchar_t*, ...));
+extern __MANGLE__ int swscanf __PROTO__((const wchar_t*, const wchar_t*, ...));
+extern __MANGLE__ wint_t ungetwc __PROTO__((wint_t, FILE*));
+extern __MANGLE__ int vfwprintf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vfwscanf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vwprintf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vwscanf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vswprintf __PROTO__((wchar_t*, size_t, const wchar_t*, va_list));
+extern __MANGLE__ int vswscanf __PROTO__((const wchar_t*, const wchar_t*, va_list));
+extern __MANGLE__ int wprintf __PROTO__((const wchar_t*, ...));
+extern __MANGLE__ int wscanf __PROTO__((const wchar_t*, ...));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/align.h b/usr/src/lib/libast/amd64/src/lib/libast/align.h
new file mode 100644
index 0000000000..2172421a7d
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/align.h
@@ -0,0 +1,33 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/align.c by iffe version 2007-04-04 : : */
+#ifndef _def_align_ast
+#define _def_align_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+typedef unsigned long ALIGN_INTEGRAL;
+
+#define ALIGN_CHUNK 8192
+#define ALIGN_INTEGRAL long
+#define ALIGN_INTEGER(x) ((ALIGN_INTEGRAL)(x))
+#define ALIGN_POINTER(x) ((char*)(x))
+#define ALIGN_ROUND(x,y) ALIGN_POINTER(ALIGN_INTEGER((x)+(y)-1)&~((y)-1))
+
+#define ALIGN_BOUND ALIGN_BOUND2
+#define ALIGN_ALIGN(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC(x) ALIGN_TRUNC2(x)
+
+#define ALIGN_BIT1 0x1
+#define ALIGN_BOUND1 ALIGN_BOUND2
+#define ALIGN_ALIGN1(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC1(x) ALIGN_TRUNC2(x)
+#define ALIGN_CLRBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffffe)
+#define ALIGN_SETBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x1)
+#define ALIGN_TSTBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x1)
+
+#define ALIGN_BIT2 0x2
+#define ALIGN_BOUND2 16
+#define ALIGN_ALIGN2(x) ALIGN_TRUNC2((x)+15)
+#define ALIGN_TRUNC2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffff0)
+#define ALIGN_CLRBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffffd)
+#define ALIGN_SETBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x2)
+#define ALIGN_TSTBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x2)
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_botch.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_botch.h
new file mode 100644
index 0000000000..d70906e8be
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_botch.h
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/botch.c by iffe version 2007-04-04 : : */
+#ifndef _def_botch_ast
+#define _def_botch_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_ccode.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_ccode.h
new file mode 100644
index 0000000000..0939e42778
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_ccode.h
@@ -0,0 +1,29 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/ccode by iffe version 2007-04-04 : : */
+#ifndef _def_ccode_ast
+#define _def_ccode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define CC_ASCII 1 /* ISO-8859-1 */
+#define CC_EBCDIC_E 2 /* Xopen dd(1) EBCDIC */
+#define CC_EBCDIC_I 3 /* Xopen dd(1) IBM */
+#define CC_EBCDIC_O 4 /* IBM-1047 mvs OpenEdition */
+#define CC_EBCDIC_S 5 /* Siemens posix-bc */
+#define CC_EBCDIC_H 6 /* IBM-37 AS/400 */
+#define CC_EBCDIC_M 7 /* IBM mvs cobol */
+#define CC_EBCDIC_U 8 /* microfocus cobol */
+
+#define CC_MAPS 8 /* number of code maps */
+
+#define CC_EBCDIC CC_EBCDIC_E
+#define CC_EBCDIC1 CC_EBCDIC_E
+#define CC_EBCDIC2 CC_EBCDIC_I
+#define CC_EBCDIC3 CC_EBCDIC_O
+
+#define CC_NATIVE CC_ASCII /* native character code */
+#define CC_ALIEN CC_EBCDIC /* alien character code */
+
+#define CC_bel 0007 /* bel character */
+#define CC_esc 0033 /* esc character */
+#define CC_sub 0032 /* sub character */
+#define CC_vt 0013 /* vt character */
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_common.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_common.h
new file mode 100644
index 0000000000..371697b9ff
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_common.h
@@ -0,0 +1,199 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/common by iffe version 2007-04-04 : : */
+#ifndef _AST_COMMON_H
+#define _AST_COMMON_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_pthread 1 /* #include <pthread.h> ok */
+#define _hdr_stdarg 1 /* #include <stdarg.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdint 1 /* #include <stdint.h> ok */
+#define _hdr_inttypes 1 /* #include <inttypes.h> ok */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_long_double 1 /* long double is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _std_proto 1 /* standard C prototypes ok */
+#define _ptr_void 1 /* standard C void* ok */
+/* disable non-standard linux/gnu inlines */
+#ifdef __GNUC__
+# undef __OPTIMIZE_SIZE__
+# define __OPTIMIZE_SIZE__ 1
+#endif
+
+/* __STD_C indicates that the language is ANSI-C or C++ */
+#if !defined(__STD_C) && __STDC__
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && (__cplusplus || c_plusplus)
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && _std_proto
+# define __STD_C 1
+#endif
+#if !defined(__STD_C)
+# define __STD_C 0
+#endif
+
+/* extern symbols must be protected against C++ name mangling */
+#ifndef _BEGIN_EXTERNS_
+# if __cplusplus || c_plusplus
+# define _BEGIN_EXTERNS_ extern "C" {
+# define _END_EXTERNS_ }
+# else
+# define _BEGIN_EXTERNS_
+# define _END_EXTERNS_
+# endif
+#endif
+
+/* _ARG_ simplifies function prototyping among flavors of C */
+#ifndef _ARG_
+# if __STD_C
+# define _ARG_(x) x
+# else
+# define _ARG_(x) ()
+# endif
+#endif
+
+/* _NIL_ simplifies defining nil pointers to a given type */
+#ifndef _NIL_
+# define _NIL_(x) ((x)0)
+#endif
+
+/* __INLINE__ is the inline keyword */
+#if !defined(__INLINE__) && defined(__cplusplus)
+# define __INLINE__ inline
+#endif
+#if !defined(__INLINE__) && defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+#endif
+
+/* Void_t is defined so that Void_t* can address any type */
+#ifndef Void_t
+# if __STD_C
+# define Void_t void
+# else
+# define Void_t char
+# endif
+#endif
+
+/* windows variants and veneers */
+#if !defined(_WINIX) && (_UWIN || __CYGWIN__ || __EMX__)
+# define _WINIX 1
+#endif
+
+/* dynamic linked library external scope handling */
+#ifdef __DYNAMIC__
+# undef __DYNAMIC__
+# ifndef _DLL
+# define _DLL 1
+# endif
+#endif
+#if _dll_import
+# if _BLD_STATIC && !_BLD_DLL
+# undef _DLL
+# else
+# if !_UWIN && !defined(_DLL)
+# define _DLL 1
+# endif
+# endif
+# if !defined(__EXPORT__) && _BLD_DLL
+# define __EXPORT__ __declspec(dllexport)
+# endif
+# if !defined(__IMPORT__) && ( _BLD_DLL || defined(_DLL) )
+# define __IMPORT__ __declspec(dllimport)
+# endif
+# if _BLD_DLL && _UWIN
+# define __DYNAMIC__(v) (_ast_getdll()->_ast_ ## v)
+# endif
+#endif
+#if !defined(_astimport)
+# if defined(__IMPORT__) && defined(_DLL)
+# define _astimport __IMPORT__
+# else
+# define _astimport extern
+# endif
+#endif
+#if _dll_import && ( !_BLD_DLL || _WINIX && !_UWIN )
+# ifdef __STDC__
+# define __EXTERN__(T,obj) extern T obj; T* _imp__ ## obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__ ## obj = &obj
+# else
+# define __EXTERN__(T,obj) extern T obj; T* _imp__/**/obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__/**/obj = &obj
+# endif
+#else
+# define __EXTERN__(T,obj) extern T obj
+# define __DEFINE__(T,obj,val) T obj = val
+#endif
+
+#define _ast_LL 1 /* LL numeric suffix supported */
+#define _ast_int1_t char
+#define _ast_int2_t short
+#define _ast_int4_t int
+#define _ast_int8_t long
+#define _ast_intmax_t _ast_int8_t
+#define _ast_intmax_long 1
+#define _ast_intswap 7
+
+#define _ast_flt4_t float
+#define _ast_flt8_t double
+#define _ast_flt16_t long double
+#define _ast_fltmax_t _ast_flt16_t
+#define _typ_int8_t 1 /* int8_t is a type */
+#define _typ_uint8_t 1 /* uint8_t is a type */
+#define _typ_int16_t 1 /* int16_t is a type */
+#define _typ_uint16_t 1 /* uint16_t is a type */
+#define _typ_int32_t 1 /* int32_t is a type */
+#define _typ_uint32_t 1 /* uint32_t is a type */
+#define _typ_int64_t 1 /* int64_t is a type */
+#define _typ_uint64_t 1 /* uint64_t is a type */
+#define _typ_intmax_t 1 /* intmax_t is a type */
+#define _typ_uintmax_t 1 /* uintmax_t is a type */
+
+#ifndef va_listref
+#define va_listref(p) (&(p)) /* pass va_list to varargs function */
+#define va_listval(p) (*(p)) /* retrieve va_list from va_arg(ap,va_listarg) */
+#define va_listarg va_list* /* va_arg() va_list type */
+#ifndef va_start
+#if __STD_C
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+#endif
+#ifndef _AST_STD_H
+# if __STD_C && _hdr_stddef
+# include <stddef.h>
+# endif
+# if _sys_types
+# include <sys/types.h>
+# endif
+# if _hdr_stdint
+# include <stdint.h>
+# else
+# if _hdr_inttypes
+# include <inttypes.h>
+# endif
+# endif
+#endif
+#if !_typ_size_t
+# define _typ_size_t 1
+ typedef int size_t;
+#endif
+#if !_typ_ssize_t
+# define _typ_ssize_t 1
+ typedef int ssize_t;
+#endif
+#ifndef _AST_STD_H
+# if !_def_map_ast
+# include <ast_map.h>
+# endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_dirent.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_dirent.h
new file mode 100644
index 0000000000..e6f040cfb6
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_dirent.h
@@ -0,0 +1,82 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/dirent by iffe version 2007-04-04 : : */
+
+#ifndef _def_dirent_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dirent_ast 1
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _nxt_dirent <../include/dirent.h> /* include path for the native <dirent.h> */
+#define _nxt_dirent_str "../include/dirent.h" /* include string for the native <dirent.h> */
+/*
+ * <dirent.h> for systems with ok <dirent.h>
+ */
+
+#ifndef _DIRENT_H
+
+#include <../include/dirent.h> /* the native <dirent.h> */
+
+#ifndef _DIRENT_H
+#define _DIRENT_H
+#endif
+
+#endif
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_fcntl.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_fcntl.h
new file mode 100644
index 0000000000..f59e2cdbd1
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_fcntl.h
@@ -0,0 +1,114 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/fcntl.c by iffe version 2007-04-04 : : */
+#ifndef _def_fcntl_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fcntl_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <ast_fs.h>
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#define O_BINARY 0
+#define O_TEMPORARY 0
+#define O_TEXT 0
+
+#include <ast_fs.h>
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_fstat64
+#define fstat fstat64
+#endif
+#if _lib_lstat64
+#define lstat lstat64
+#endif
+#if _lib_stat64
+#define stat stat64
+#endif
+#if _lib_creat64
+#define creat creat64
+#endif
+#if _lib_mmap64
+#define mmap mmap64
+#endif
+#if _lib_open64
+#undef open
+#define open open64
+#endif
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_float.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_float.h
new file mode 100644
index 0000000000..40d069f246
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_float.h
@@ -0,0 +1,212 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/float by iffe version 2007-04-04 : : */
+
+#ifndef _def_float_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_float_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_float 1 /* #include <float.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _hdr_values 1 /* #include <values.h> ok */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_frexp 1 /* frexp() in default lib(s) */
+#define _lib_frexpl 1 /* frexpl() in default lib(s) */
+#define _lib_ldexp 1 /* ldexp() in default lib(s) */
+#define _lib_ldexpl 1 /* ldexpl() in default lib(s) */
+#define _lib_finite 1 /* finite() in default lib(s) */
+#define _lib_isnan 1 /* isnan() in default lib(s) */
+#define _lib_isnanl 1 /* isnanl() in default lib(s) */
+#define _lib_copysign 1 /* copysign() in default lib(s) */
+#define _lib_copysignl 1 /* copysignl() in default lib(s) */
+#include <ast_common.h>
+#include <float.h>
+#include <math.h>
+#ifndef FLT_DIG
+#define FLT_DIG 6
+#endif
+#ifndef FLT_MAX
+#define FLT_MAX 3.4028234663852885981170E+38F
+#endif
+#ifndef FLT_MAX_10_EXP
+#define FLT_MAX_10_EXP ( + 38 )
+#endif
+#ifndef FLT_MAX_EXP
+#define FLT_MAX_EXP ( + 128 )
+#endif
+#ifndef FLT_MIN
+#define FLT_MIN 1.1754943508222875079688E-38F
+#endif
+#ifndef FLT_MIN_10_EXP
+#define FLT_MIN_10_EXP ( - 37 )
+#endif
+#ifndef FLT_MIN_EXP
+#define FLT_MIN_EXP ( - 125 )
+#endif
+#ifndef DBL_DIG
+#define DBL_DIG 15
+#endif
+#ifndef DBL_MAX
+#define DBL_MAX 1.7976931348623157081452E+308
+#endif
+#ifndef DBL_MAX_10_EXP
+#define DBL_MAX_10_EXP ( + 308 )
+#endif
+#ifndef DBL_MAX_EXP
+#define DBL_MAX_EXP ( + 1024 )
+#endif
+#ifndef DBL_MIN
+#define DBL_MIN 2.2250738585072013830903E-308
+#endif
+#ifndef DBL_MIN_10_EXP
+#define DBL_MIN_10_EXP ( - 307 )
+#endif
+#ifndef DBL_MIN_EXP
+#define DBL_MIN_EXP ( - 1021 )
+#endif
+#ifndef LDBL_DIG
+#define LDBL_DIG 18
+#endif
+#ifndef LDBL_MAX
+#define LDBL_MAX 1.1897314953572317650213E+4932L
+#endif
+#ifndef LDBL_MAX_10_EXP
+#define LDBL_MAX_10_EXP ( + 4932 )
+#endif
+#ifndef LDBL_MAX_EXP
+#define LDBL_MAX_EXP ( + 16384 )
+#endif
+#ifndef LDBL_MIN
+#define LDBL_MIN 3.3621031431120935062627E-4932L
+#endif
+#ifndef LDBL_MIN_10_EXP
+#define LDBL_MIN_10_EXP ( - 4931 )
+#endif
+#ifndef LDBL_MIN_EXP
+#define LDBL_MIN_EXP ( - 16381 )
+#endif
+
+
+#define USHRT_DIG 4
+#define UINT_DIG 9
+#define ULONG_DIG 19
+#define UINTMAX_DIG ULONG_DIG
+
+#define FLT_ULONG_MAX 18446744073709551615.0F
+#define FLT_ULLONG_MAX FLT_ULONG_MAX
+#define FLT_UINTMAX_MAX FLT_ULONG_MAX
+#define FLT_LONG_MAX 9223372036854775807.0F
+#define FLT_LLONG_MAX FLT_LONG_MAX
+#define FLT_INTMAX_MAX FLT_LONG_MAX
+#define FLT_LONG_MIN (-9223372036854775808.0F)
+#define FLT_LLONG_MIN FLT_LONG_MIN
+#define FLT_INTMAX_MIN FLT_LONG_MIN
+
+#define DBL_ULONG_MAX 18446744073709551615.0
+#define DBL_ULLONG_MAX DBL_ULONG_MAX
+#define DBL_UINTMAX_MAX DBL_ULONG_MAX
+#define DBL_LONG_MAX 9223372036854775807.0
+#define DBL_LLONG_MAX DBL_LONG_MAX
+#define DBL_INTMAX_MAX DBL_LONG_MAX
+#define DBL_LONG_MIN (-9223372036854775808.0)
+#define DBL_LLONG_MIN DBL_LONG_MIN
+#define DBL_INTMAX_MIN DBL_LONG_MIN
+
+#define LDBL_ULONG_MAX 18446744073709551615.0L
+#define LDBL_ULLONG_MAX LDBL_ULONG_MAX
+#define LDBL_UINTMAX_MAX LDBL_ULONG_MAX
+#define LDBL_LONG_MAX 9223372036854775807.0L
+#define LDBL_LLONG_MAX LDBL_LONG_MAX
+#define LDBL_INTMAX_MAX LDBL_LONG_MAX
+#define LDBL_LONG_MIN (-9223372036854775808.0L)
+#define LDBL_LLONG_MIN LDBL_LONG_MIN
+#define LDBL_INTMAX_MIN LDBL_LONG_MIN
+
+#define FLTMAX_UINTMAX_MAX LDBL_UINTMAX_MAX
+#define FLTMAX_INTMAX_MAX LDBL_INTMAX_MAX
+#define FLTMAX_INTMAX_MIN LDBL_INTMAX_MIN
+
+typedef union _ast_dbl_exp_u
+{
+ uint32_t e[sizeof(double)/4];
+ double f;
+} _ast_dbl_exp_t;
+
+#define _ast_dbl_exp_index 1
+#define _ast_dbl_exp_shift 20
+
+typedef union _fltmax_exp_u
+{
+ uint32_t e[sizeof(_ast_fltmax_t)/4];
+ _ast_fltmax_t f;
+} _ast_fltmax_exp_t;
+
+#define _ast_fltmax_exp_index 2
+#define _ast_fltmax_exp_shift 0
+
+#define _ast_flt_unsigned_max_t unsigned long long
+#define _ast_flt_nan_init 0xff,0xff,0xff,0x7f
+#define _ast_flt_inf_init 0x00,0x00,0x80,0x7f
+#define _ast_dbl_nan_init 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f
+#define _ast_dbl_inf_init 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x7f
+#define _ast_ldbl_nan_init 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x40,0x00,0x00,0x00,0x00,0x00
+#define _ast_ldbl_inf_init 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x7f,0x40,0x00,0x00,0x00,0x00,0x00
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_fs.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_fs.h
new file mode 100644
index 0000000000..eb8b57cea9
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_fs.h
@@ -0,0 +1,153 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/fs by iffe version 2007-04-04 : : */
+
+#ifndef _def_fs_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fs_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _lib_lstat 1 /* lstat() in default lib(s) */
+#define _lib_mknod 1 /* mknod() in default lib(s) */
+#define _lib_sync 1 /* sync() in default lib(s) */
+#include <sys/stat.h>
+#define FS_default "ufs"
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef major
+#define major(x) ( major_t ) ( ( ( ( unsigned ) ( ( x ) ) ) >> 8 ) & 0x7f )
+#endif
+#ifndef minor
+#define minor(x) ( minor_t ) ( ( ( x ) ) & 0xff )
+#endif
+#ifndef makedev
+#define makedev(x,y) ( unsigned short ) ( ( ( ( x ) ) << 8 ) | ( ( ( y ) ) & 0xff ) )
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _sys_mntent 1 /* #include <sys/mntent.h> ok */
+#define _sys_mnttab 1 /* #include <sys/mnttab.h> ok */
+#define _mem_st_blocks_stat 1 /* st_blocks is a member of struct stat */
+#define _mem_st_blksize_stat 1 /* st_blksize is a member of struct stat */
+#define _mem_st_rdev_stat 1 /* st_rdev is a member of struct stat */
+#define _sys_statfs 1 /* #include <sys/statfs.h> ok */
+#define _mem_f_files_statfs 1 /* f_files is a member of struct statfs */
+#define _sys_vfs 1 /* #include <sys/vfs.h> ok */
+#define _sys_param 1 /* #include <sys/param.h> ok */
+#define _sys_mount 1 /* #include <sys/mount.h> ok */
+#define _sys_statvfs 1 /* #include <sys/statvfs.h> ok */
+#define _mem_f_basetype_statvfs 1 /* f_basetype is a member of struct statvfs */
+#define _mem_f_frsize_statvfs 1 /* f_frsize is a member of struct statvfs */
+#define _lib_getmntent 1 /* getmntent() in default lib(s) */
+#define _lib_statfs 1 /* statfs() in default lib(s) */
+#define _lib_statvfs 1 /* statvfs() in default lib(s) */
+#define _lib_statfs4 1 /* compile{\ passed */
+#if _sys_statvfs
+#include <sys/statvfs.h>
+#if !_mem_statvfs_f_basetype
+#if _ary_f_reserved7
+#define f_basetype f_reserved7
+#endif
+#endif
+#else
+#define _mem_f_basetype_statvfs 1
+#define _mem_f_frsize_statvfs 1
+struct statvfs
+{
+unsigned long f_bsize; /* fundamental file system block size */
+unsigned long f_frsize; /* fragment size */
+unsigned long f_blocks; /* total # of blocks of f_frsize on fs */
+unsigned long f_bfree; /* total # of free blocks of f_frsize */
+unsigned long f_bavail; /* # of free blocks avail to non-superuser */
+unsigned long f_files; /* total # of file nodes (inodes) */
+unsigned long f_ffree; /* total # of free file nodes */
+unsigned long f_favail; /* # of free nodes avail to non-superuser */
+unsigned long f_fsid; /* file system id (dev for now) */
+char f_basetype[16]; /* target fs type name, null-terminated */
+unsigned long f_flag; /* bit-mask of flags */
+unsigned long f_namemax; /* maximum file name length */
+char f_fstr[32]; /* filesystem-specific string */
+unsigned long f_filler[16]; /* reserved for future expansion */
+};
+extern __MANGLE__ int fstatvfs __PROTO__((int, struct statvfs*));
+extern __MANGLE__ int statvfs __PROTO__((const char*, struct statvfs*));
+#endif
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_statvfs64 && !defined(statvfs)
+#define statvfs statvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int statvfs64 __PROTO__((const char*, struct statvfs64*));
+#endif
+#endif
+#if _lib_fstatvfs64 && !defined(fstatvfs)
+#define fstatvfs fstatvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int fstatvfs64 __PROTO__((int, struct statvfs64*));
+#endif
+#endif
+
+#define _str_st_fstype 1 /* stat.st_fstype is a string */
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_iconv.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_iconv.h
new file mode 100644
index 0000000000..cc251f15d2
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_iconv.h
@@ -0,0 +1,132 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/iconv by iffe version 2007-04-04 : : */
+
+#ifndef _def_iconv_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_iconv_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_iconv 1 /* #include <iconv.h> ok */
+#define _lib_iconv_open 1 /* iconv_open() in default lib(s) */
+#define _lib_iconv_close 1 /* iconv_close() in default lib(s) */
+#define _lib_iconv 1 /* iconv() in default lib(s) */
+#define _nxt_iconv <../include/iconv.h> /* include path for the native <iconv.h> */
+#define _nxt_iconv_str "../include/iconv.h" /* include string for the native <iconv.h> */
+#include <ast_common.h>
+#include <ccode.h>
+#include <../include/iconv.h> /* the native iconv.h */
+
+#define CC_ICONV (-1)
+#define CC_UCS (-2)
+#define CC_SCU (-3)
+#define CC_UTF (-4)
+#define CC_UME (-5)
+
+#ifndef _ICONV_LIST_PRIVATE_
+#undef iconv_t
+#define iconv_t _ast_iconv_t
+#undef iconv_f
+#define iconv_f _ast_iconv_f
+#undef iconv_list_t
+#define iconv_list_t _ast_iconv_list_t
+#undef iconv_open
+#define iconv_open _ast_iconv_open
+#undef iconv
+#define iconv _ast_iconv
+#undef iconv_close
+#define iconv_close _ast_iconv_close
+#undef iconv_list
+#define iconv_list _ast_iconv_list
+#undef iconv_move
+#define iconv_move _ast_iconv_move
+#undef iconv_name
+#define iconv_name _ast_iconv_name
+#undef iconv_write
+#define iconv_write _ast_iconv_write
+#endif
+
+typedef Ccmap_t _ast_iconv_list_t;
+typedef __V_* _ast_iconv_t;
+typedef size_t (*_ast_iconv_f) __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ _ast_iconv_t _ast_iconv_open __PROTO__((const char*, const char*));
+extern __MANGLE__ size_t _ast_iconv __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+extern __MANGLE__ int _ast_iconv_close __PROTO__((_ast_iconv_t));
+extern __MANGLE__ _ast_iconv_list_t* _ast_iconv_list __PROTO__((_ast_iconv_list_t*));
+extern __MANGLE__ int _ast_iconv_name __PROTO__((const char*, char*, size_t));
+#if _SFIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, Sfio_t*, Sfio_t*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, Sfio_t*, char**, size_t*, size_t*));
+#else
+#if _SFSTDIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, FILE*, FILE*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, FILE*, char**, size_t*, size_t*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_lib.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_lib.h
new file mode 100644
index 0000000000..a2a479c2d7
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_lib.h
@@ -0,0 +1,160 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/lib by iffe version 2007-04-04 : : */
+#ifndef _def_lib_ast
+#define _def_lib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _hdr_fmtmsg 1 /* #include <fmtmsg.h> ok */
+#define _hdr_fnmatch 1 /* #include <fnmatch.h> ok */
+#define _hdr_libgen 1 /* #include <libgen.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_locale 1 /* #include <locale.h> ok */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_spawn 1 /* #include <spawn.h> ok */
+#define _hdr_syslog 1 /* #include <syslog.h> ok */
+#define _hdr_utime 1 /* #include <utime.h> ok */
+#define _hdr_wctype 1 /* #include <wctype.h> ok */
+#define _hdr_wchar 1 /* <wchar.h> and isw*() really work */
+#define _dat__tzname 1 /* _tzname in default lib(s) */
+#define _dat_tzname 1 /* tzname in default lib(s) */
+#define _lib__cleanup 1 /* _cleanup() in default lib(s) */
+#define _lib_atexit 1 /* atexit() in default lib(s) */
+#define _lib_bcopy 1 /* bcopy() in default lib(s) */
+#define _lib_bzero 1 /* bzero() in default lib(s) */
+#define _lib_catclose 1 /* catclose() in default lib(s) */
+#define _lib_catgets 1 /* catgets() in default lib(s) */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_confstr 1 /* confstr() in default lib(s) */
+#define _lib_dup2 1 /* dup2() in default lib(s) */
+#define _lib_execlp 1 /* execlp() in default lib(s) */
+#define _lib_execve 1 /* execve() in default lib(s) */
+#define _lib_execvp 1 /* execvp() in default lib(s) */
+#define _lib_fchmod 1 /* fchmod() in default lib(s) */
+#define _lib_fcntl 1 /* fcntl() in default lib(s) */
+#define _lib_fmtmsg 1 /* fmtmsg() in default lib(s) */
+#define _lib_fnmatch 1 /* fnmatch() in default lib(s) */
+#define _lib_fork 1 /* fork() in default lib(s) */
+#define _lib_fsync 1 /* fsync() in default lib(s) */
+#define _lib_getdents 1 /* getdents() in default lib(s) */
+#define _lib_getdtablesize 1 /* getdtablesize() in default lib(s) */
+#define _lib_getdate 1 /* getdate() in default lib(s) */
+#define _lib_getgroups 1 /* getgroups() in default lib(s) */
+#define _lib_gethostname 1 /* gethostname() in default lib(s) */
+#define _lib_getlogin 1 /* getlogin() in default lib(s) */
+#define _lib_getpagesize 1 /* getpagesize() in default lib(s) */
+#define _lib_getrlimit 1 /* getrlimit() in default lib(s) */
+#define _lib_getopt 1 /* getopt() in default lib(s) */
+#define _lib_getsubopt 1 /* getsubopt() in default lib(s) */
+#define _lib_getopt_long 1 /* getopt_long() in default lib(s) */
+#define _lib_getopt_long_only 1 /* getopt_long_only() in default lib(s) */
+#define _lib_glob 1 /* glob() in default lib(s) */
+#define _lib_index 1 /* index() in default lib(s) */
+#define _lib_iswblank 1 /* iswblank() in default lib(s) */
+#define _lib_iswctype 1 /* iswctype() in default lib(s) */
+#define _lib_killpg 1 /* killpg() in default lib(s) */
+#define _lib_link 1 /* link() in default lib(s) */
+#define _lib_localeconv 1 /* localeconv() in default lib(s) */
+#define _lib_madvise 1 /* madvise() in default lib(s) */
+#define _lib_mbtowc 1 /* mbtowc() in default lib(s) */
+#define _lib_mbrtowc 1 /* mbrtowc() in default lib(s) */
+#define _lib_memalign 1 /* memalign() in default lib(s) */
+#define _lib_memchr 1 /* memchr() in default lib(s) */
+#define _lib_memcpy 1 /* memcpy() in default lib(s) */
+#define _lib_memmove 1 /* memmove() in default lib(s) */
+#define _lib_memset 1 /* memset() in default lib(s) */
+#define _lib_mkdir 1 /* mkdir() in default lib(s) */
+#define _lib_mkfifo 1 /* mkfifo() in default lib(s) */
+#define _lib_mktemp 1 /* mktemp() in default lib(s) */
+#define _lib_mktime 1 /* mktime() in default lib(s) */
+#define _lib_mount 1 /* mount() in default lib(s) */
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _lib_pathconf 1 /* pathconf() in default lib(s) */
+#define _lib_readlink 1 /* readlink() in default lib(s) */
+#define _lib_remove 1 /* remove() in default lib(s) */
+#define _lib_rename 1 /* rename() in default lib(s) */
+#define _lib_rewinddir 1 /* rewinddir() in default lib(s) */
+#define _lib_rindex 1 /* rindex() in default lib(s) */
+#define _lib_rmdir 1 /* rmdir() in default lib(s) */
+#define _lib_setlocale 1 /* setlocale() in default lib(s) */
+#define _lib_setpgid 1 /* setpgid() in default lib(s) */
+#define _lib_setpgrp 1 /* setpgrp() in default lib(s) */
+#define _lib_setreuid 1 /* setreuid() in default lib(s) */
+#define _lib_setsid 1 /* setsid() in default lib(s) */
+#define _lib_setuid 1 /* setuid() in default lib(s) */
+#define _lib_sigaction 1 /* sigaction() in default lib(s) */
+#define _lib_sigprocmask 1 /* sigprocmask() in default lib(s) */
+#define _lib_socketpair 1 /* socketpair() in default lib(s) */
+#define _lib_strchr 1 /* strchr() in default lib(s) */
+#define _lib_strcoll 1 /* strcoll() in default lib(s) */
+#define _lib_strdup 1 /* strdup() in default lib(s) */
+#define _lib_strerror 1 /* strerror() in default lib(s) */
+#define _lib_strcasecmp 1 /* strcasecmp() in default lib(s) */
+#define _lib_strncasecmp 1 /* strncasecmp() in default lib(s) */
+#define _lib_strrchr 1 /* strrchr() in default lib(s) */
+#define _lib_strstr 1 /* strstr() in default lib(s) */
+#define _lib_strxfrm 1 /* strxfrm() in default lib(s) */
+#define _lib_strftime 1 /* strftime() in default lib(s) */
+#define _lib_swab 1 /* swab() in default lib(s) */
+#define _lib_symlink 1 /* symlink() in default lib(s) */
+#define _lib_sysconf 1 /* sysconf() in default lib(s) */
+#define _lib_sysinfo 1 /* sysinfo() in default lib(s) */
+#define _lib_syslog 1 /* syslog() in default lib(s) */
+#define _lib_telldir 1 /* telldir() in default lib(s) */
+#define _lib_tmpnam 1 /* tmpnam() in default lib(s) */
+#define _lib_tzset 1 /* tzset() in default lib(s) */
+#define _lib_unlink 1 /* unlink() in default lib(s) */
+#define _lib_utime 1 /* utime() in default lib(s) */
+#define _lib_wctype 1 /* wctype() in default lib(s) */
+#define _lib_ftruncate 1 /* ftruncate() in default lib(s) */
+#define _lib_truncate 1 /* truncate() in default lib(s) */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _lib_strtod 1 /* strtod() in default lib(s) */
+#define _lib_strtold 1 /* strtold() in default lib(s) */
+#define _lib_strtol 1 /* strtol() in default lib(s) */
+#define _lib_strtoll 1 /* strtoll() in default lib(s) */
+#define _lib_strtoul 1 /* strtoul() in default lib(s) */
+#define _lib_strtoull 1 /* strtoull() in default lib(s) */
+#define _mem_d_ino_dirent 1 /* d_ino is a member of struct dirent */
+#define _mem_d_off_dirent 1 /* d_off is a member of struct dirent */
+#define _mem_d_reclen_dirent 1 /* d_reclen is a member of struct dirent */
+#define _mem_DIR 1 /* DIR is a non-opaque struct */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _sys_jioctl 1 /* #include <sys/jioctl.h> ok */
+#define _sys_localedef 1 /* #include <sys/localedef.h> ok */
+#define _sys_ptem 1 /* #include <sys/ptem.h> ok */
+#define _sys_resource 1 /* #include <sys/resource.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _sys_stream 1 /* #include <sys/stream.h> ok */
+#define _sys_systeminfo 1 /* #include <sys/systeminfo.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_off64_t 1 /* off64_t is a type */
+#define _typ_struct_dirent64 1 /* struct dirent64 is a type */
+#define _tst_errno 1 /* errno can be assigned */
+#define _lib_poll_fd_1 1 /* fd is first arg to poll() */
+#define _lib_poll 1 /* _lib_poll_fd_1||_lib_poll_fd_2 is true */
+#define _lib_select 1 /* select() has standard 5 arg interface */
+#define _pipe_rw 1 /* full duplex pipes */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _lib_vfork 1 /* vfork exists and it works */
+#define _real_vfork 1 /* vfork child shares data with parent */
+#define _lib_posix_spawn 1 /* posix_spawn exists and it works and its worth using */
+#define _stream_peek 1 /* ioctl(I_PEEK) works */
+#define _socket_peek 1 /* recv(MSG_PEEK) works */
+#define _hdr_string 1 /* #include <string.h> ok */
+#define _lib_memcmp 1 /* standard memcmp interface that works */
+#define _hdr_fcntl 1 /* #include <fcntl.h> ok */
+#define _hdr_signal 1 /* #include <signal.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_memccpy 1 /* standard memccpy interface that works */
+#define _lib_utime_now 1 /* utime works with 0 time vector */
+#define _UNIV_DEFAULT "att" /* default universe name */
+#define _std_cleanup 1 /* stuck with standard _cleanup */
+#define _std_strcoll 1 /* standard strcoll works */
+#if !_AST_no_spawnveg
+#define _use_spawnveg 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_limits.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_limits.h
new file mode 100644
index 0000000000..7dddc39475
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_limits.h
@@ -0,0 +1,107 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/limits.c by iffe version 2007-04-04 : : */
+#ifndef _def_limits_ast
+#define _def_limits_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+#ifndef CHAR_MAX
+#define CHAR_MAX 127
+#endif
+#ifndef CHAR_MIN
+#define CHAR_MIN -128
+#endif
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC 1000000
+#endif
+#ifndef INT_MIN
+#define INT_MIN -2147483648
+#endif
+#ifndef LLONG_MAX
+#define LLONG_MAX 9223372036854775807
+#endif
+#ifndef LLONG_MIN
+#define LLONG_MIN -9223372036854775808
+#endif
+#ifndef LONG_MAX
+#define LONG_MAX 2147483647
+#endif
+#ifndef LONG_MIN
+#define LONG_MIN -2147483648
+#endif
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 5
+#endif
+#ifndef OPEN_MAX_CEIL
+#ifndef OPEN_MAX
+#define OPEN_MAX 256
+#endif
+#define OPEN_MAX_CEIL OPEN_MAX
+#endif
+#ifndef PTHREAD_STACK_MIN
+#define PTHREAD_STACK_MIN 4096
+#endif
+#ifndef PTRDIFF_MAX
+#define PTRDIFF_MAX 9223372036854775807
+#endif
+#ifndef PTRDIFF_MIN
+#define PTRDIFF_MIN -9223372036854775808
+#endif
+#ifndef SCHAR_MAX
+#define SCHAR_MAX 127
+#endif
+#ifndef SCHAR_MIN
+#define SCHAR_MIN -128
+#endif
+#ifndef SHRT_MIN
+#define SHRT_MIN -32768
+#endif
+#ifndef SIG_ATOMIC_MAX
+#define SIG_ATOMIC_MAX 2147483647
+#endif
+#ifndef SIG_ATOMIC_MIN
+#define SIG_ATOMIC_MIN -2147483648
+#endif
+#ifndef SIZE_MAX
+#ifndef UINT_MAX
+#define UINT_MAX 4294967295
+#endif
+#define SIZE_MAX UINT_MAX
+#endif
+#ifndef SSIZE_MAX
+#ifndef INT_MAX
+#define INT_MAX 2147483647
+#endif
+#define SSIZE_MAX INT_MAX
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+#ifndef UCHAR_MAX
+#define UCHAR_MAX 255
+#endif
+#ifndef ULLONG_MAX
+#define ULLONG_MAX 18446744073709551615
+#endif
+#ifndef ULONG_MAX
+#define ULONG_MAX 4294967295
+#endif
+#ifndef USHRT_MAX
+#define USHRT_MAX 65535
+#endif
+#ifndef WCHAR_MAX
+#define WCHAR_MAX 2147483647
+#endif
+#ifndef WCHAR_MIN
+#define WCHAR_MIN -2147483648
+#endif
+#ifndef WINT_MAX
+#define WINT_MAX 2147483647
+#endif
+#ifndef WINT_MIN
+#define WINT_MIN -2147483648
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_map.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_map.h
new file mode 100644
index 0000000000..55c2ef8707
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_map.h
@@ -0,0 +1,438 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/map.c by iffe version 2007-04-04 : : */
+#ifndef _def_map_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_map_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+/*
+ * prototypes provided for standard interfaces hijacked
+ * by ast and mapped to _ast_* but already prototyped
+ * unmapped in native headers included by <ast_std.h>
+ */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+
+#define _map_libc 1
+#undef basename
+#define basename _ast_basename
+#undef dirname
+#define dirname _ast_dirname
+#undef eaccess
+#define eaccess _ast_eaccess
+#undef execvpe
+#define execvpe _ast_execvpe
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+#undef fnmatch
+#define fnmatch _ast_fnmatch
+#undef fts_children
+#define fts_children _ast_fts_children
+#undef fts_close
+#define fts_close _ast_fts_close
+#undef fts_flags
+#define fts_flags _ast_fts_flags
+#undef fts_notify
+#define fts_notify _ast_fts_notify
+#undef fts_open
+#define fts_open _ast_fts_open
+#undef fts_read
+#define fts_read _ast_fts_read
+#undef fts_set
+#define fts_set _ast_fts_set
+#undef ftw
+#define ftw _ast_ftw
+#undef ftwalk
+#define ftwalk _ast_ftwalk
+#undef ftwflags
+#define ftwflags _ast_ftwflags
+#undef getcwd
+#define getcwd _ast_getcwd
+extern __MANGLE__ char* getcwd __PROTO__((char*, size_t));
+#undef getdate
+#define getdate _ast_getdate
+#undef getopt
+#define getopt _ast_getopt
+#undef getsubopt
+#define getsubopt _ast_getsubopt
+#undef getopt_long
+#define getopt_long _ast_getopt_long
+#undef getopt_long_only
+#define getopt_long_only _ast_getopt_long_only
+#undef getwd
+#define getwd _ast_getwd
+extern __MANGLE__ char* getwd __PROTO__((char*));
+#undef glob
+#define glob _ast_glob
+#undef globfree
+#define globfree _ast_globfree
+#undef memdup
+#define memdup _ast_memdup
+#undef memfatal
+#define memfatal _ast_memfatal
+#undef memhash
+#define memhash _ast_memhash
+#undef memsum
+#define memsum _ast_memsum
+#undef mkstemp
+#define mkstemp _ast_mkstemp
+extern __MANGLE__ int mkstemp __PROTO__((char*));
+#undef mktemp
+#define mktemp _ast_mktemp
+extern __MANGLE__ char* mktemp __PROTO__((char*));
+#undef mktime
+#define mktime _ast_mktime
+#undef nftw
+#define nftw _ast_nftw
+#undef optesc
+#define optesc _ast_optesc
+#undef optget
+#define optget _ast_optget
+#undef opthelp
+#define opthelp _ast_opthelp
+#undef optjoin
+#define optjoin _ast_optjoin
+#undef optstr
+#define optstr _ast_optstr
+#undef optusage
+#define optusage _ast_optusage
+#undef pathaccess
+#define pathaccess _ast_pathaccess
+#undef pathbin
+#define pathbin _ast_pathbin
+#undef pathcanon
+#define pathcanon _ast_pathcanon
+#undef pathcat
+#define pathcat _ast_pathcat
+#undef pathcd
+#define pathcd _ast_pathcd
+#undef pathcheck
+#define pathcheck _ast_pathcheck
+#undef pathexists
+#define pathexists _ast_pathexists
+#undef pathfind
+#define pathfind _ast_pathfind
+#undef pathgetlink
+#define pathgetlink _ast_pathgetlink
+#undef pathinclude
+#define pathinclude _ast_pathinclude
+#undef pathkey
+#define pathkey _ast_pathkey
+#undef pathnative
+#define pathnative _ast_pathnative
+#undef pathpath
+#define pathpath _ast_pathpath
+#undef pathposix
+#define pathposix _ast_pathposix
+#undef pathprobe
+#define pathprobe _ast_pathprobe
+#undef pathrepl
+#define pathrepl _ast_pathrepl
+#undef pathsetlink
+#define pathsetlink _ast_pathsetlink
+#undef pathshell
+#define pathshell _ast_pathshell
+#undef pathstat
+#define pathstat _ast_pathstat
+#undef pathtemp
+#define pathtemp _ast_pathtemp
+#undef pathtmp
+#define pathtmp _ast_pathtmp
+#undef procclose
+#define procclose _ast_procclose
+#undef procfree
+#define procfree _ast_procfree
+#undef procopen
+#define procopen _ast_procopen
+#undef procrun
+#define procrun _ast_procrun
+#undef putenv
+#define putenv _ast_putenv
+#undef re_comp
+#define re_comp _ast_re_comp
+#undef re_exec
+#define re_exec _ast_re_exec
+#undef realpath
+#define realpath _ast_realpath
+extern __MANGLE__ char* realpath __PROTO__((const char*, char*));
+#undef regaddclass
+#define regaddclass _ast_regaddclass
+#undef regalloc
+#define regalloc _ast_regalloc
+#undef regcache
+#define regcache _ast_regcache
+#undef regclass
+#define regclass _ast_regclass
+#undef regcmp
+#define regcmp _ast_regcmp
+#undef regcollate
+#define regcollate _ast_regcollate
+#undef regcomb
+#define regcomb _ast_regcomb
+#undef regcomp
+#define regcomp _ast_regcomp
+#undef regdecomp
+#define regdecomp _ast_regdecomp
+#undef regdup
+#define regdup _ast_regdup
+#undef regerror
+#define regerror _ast_regerror
+#undef regex
+#define regex _ast_regex
+#undef regexec
+#define regexec _ast_regexec
+#undef regfatal
+#define regfatal _ast_regfatal
+#undef regfatalpat
+#define regfatalpat _ast_regfatalpat
+#undef regfree
+#define regfree _ast_regfree
+#undef regncomp
+#define regncomp _ast_regncomp
+#undef regnexec
+#define regnexec _ast_regnexec
+#undef regrecord
+#define regrecord _ast_regrecord
+#undef regrexec
+#define regrexec _ast_regrexec
+#undef regstat
+#define regstat _ast_regstat
+#undef regsub
+#define regsub _ast_regsub
+#undef regsubcomp
+#define regsubcomp _ast_regsubcomp
+#undef regsubexec
+#define regsubexec _ast_regsubexec
+#undef regsubflags
+#define regsubflags _ast_regsubflags
+#undef regsubfree
+#define regsubfree _ast_regsubfree
+#undef remove
+#define remove _ast_remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#undef resolvepath
+#define resolvepath _ast_resolvepath
+extern __MANGLE__ char* resolvepath __PROTO__((const char*, char*, size_t));
+#undef setenv
+#define setenv _ast_setenv
+extern __MANGLE__ int setenv __PROTO__((const char*, const char*, int));
+#undef setenviron
+#define setenviron _ast_setenviron
+#undef sigcritical
+#define sigcritical _ast_sigcritical
+#undef signal
+#define signal _ast_signal
+#undef sigunblock
+#define sigunblock _ast_sigunblock
+#undef stracmp
+#define stracmp _ast_stracmp
+#undef strcopy
+#define strcopy _ast_strcopy
+#undef strelapsed
+#define strelapsed _ast_strelapsed
+#undef stresc
+#define stresc _ast_stresc
+#undef streval
+#define streval _ast_streval
+#undef strexpr
+#define strexpr _ast_strexpr
+#undef strftime
+#define strftime _ast_strftime
+#undef strgid
+#define strgid _ast_strgid
+#undef strgrpmatch
+#define strgrpmatch _ast_strgrpmatch
+#undef strhash
+#define strhash _ast_strhash
+#undef strkey
+#define strkey _ast_strkey
+#undef strlcat
+#define strlcat _ast_strlcat
+extern __MANGLE__ size_t strlcat __PROTO__((char*, const char*, size_t));
+#undef strlcpy
+#define strlcpy _ast_strlcpy
+extern __MANGLE__ size_t strlcpy __PROTO__((char*, const char*, size_t));
+#undef strlook
+#define strlook _ast_strlook
+#undef strmatch
+#define strmatch _ast_strmatch
+#undef strmode
+#define strmode _ast_strmode
+#undef strnacmp
+#define strnacmp _ast_strnacmp
+#undef strncopy
+#define strncopy _ast_strncopy
+#undef strntod
+#define strntod _ast_strntod
+#undef strntol
+#define strntol _ast_strntol
+#undef strntold
+#define strntold _ast_strntold
+#undef strntoll
+#define strntoll _ast_strntoll
+#undef strntoul
+#define strntoul _ast_strntoul
+#undef strntoull
+#define strntoull _ast_strntoull
+#undef stropt
+#define stropt _ast_stropt
+#undef strperm
+#define strperm _ast_strperm
+#undef strpsearch
+#define strpsearch _ast_strpsearch
+#undef strptime
+#define strptime _ast_strptime
+#undef strsearch
+#define strsearch _ast_strsearch
+#undef strsort
+#define strsort _ast_strsort
+#undef strsubmatch
+#define strsubmatch _ast_strsubmatch
+#undef strsum
+#define strsum _ast_strsum
+#undef strtape
+#define strtape _ast_strtape
+#undef strtoip4
+#define strtoip4 _ast_strtoip4
+#undef strton
+#define strton _ast_strton
+#undef strtonll
+#define strtonll _ast_strtonll
+#undef struid
+#define struid _ast_struid
+#undef struniq
+#define struniq _ast_struniq
+#undef system
+#define system _ast_system
+extern __MANGLE__ int system __PROTO__((const char*));
+#undef tempnam
+#define tempnam _ast_tempnam
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+#undef tmpnam
+#define tmpnam _ast_tmpnam
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+#undef touch
+#define touch _ast_touch
+#undef wordexp
+#define wordexp _ast_wordexp
+#undef wordfree
+#define wordfree _ast_wordfree
+#undef unsetenv
+#define unsetenv _ast_unsetenv
+
+/* cannot override local malloc */
+#define _map_malloc 1
+#undef calloc
+#define calloc _ast_calloc
+extern __MANGLE__ __V_* calloc __PROTO__((size_t, size_t));
+#undef cfree
+#define cfree _ast_cfree
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+#undef free
+#define free _ast_free
+extern __MANGLE__ void free __PROTO__((__V_*));
+#undef malloc
+#define malloc _ast_malloc
+extern __MANGLE__ __V_* malloc __PROTO__((size_t));
+#undef memalign
+#define memalign _ast_memalign
+extern __MANGLE__ __V_* memalign __PROTO__((size_t, size_t));
+#undef realloc
+#define realloc _ast_realloc
+extern __MANGLE__ __V_* realloc __PROTO__((__V_*, size_t));
+#undef strdup
+#define strdup _ast_strdup
+extern __MANGLE__ char* strdup __PROTO__((const char*));
+#undef valloc
+#define valloc _ast_valloc
+extern __MANGLE__ __V_* valloc __PROTO__((size_t));
+#undef strtol
+#define strtol _ast_strtol
+#undef strtoul
+#define strtoul _ast_strtoul
+#undef strtoll
+#define strtoll _ast_strtoll
+#undef strtoull
+#define strtoull _ast_strtoull
+#undef strtod
+#define strtod _ast_strtod
+#undef strtold
+#define strtold _ast_strtold
+extern __MANGLE__ long strtol __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned long strtoul __PROTO__((const char*, char**, int));
+extern __MANGLE__ double strtod __PROTO__((const char*, char**));
+#if !_UWIN
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
+extern __MANGLE__ _ast_fltmax_t strtold __PROTO__((const char*, char**));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+extern __MANGLE__ _ast_intmax_t strtoll __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned _ast_intmax_t strtoull __PROTO__((const char*, char**, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_mmap.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_mmap.h
new file mode 100644
index 0000000000..10483aee18
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_mmap.h
@@ -0,0 +1,26 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/mmap by iffe version 2007-04-04 : : */
+#ifndef _def_mmap_ast
+#define _def_mmap_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_mmap 1 /* standard mmap interface that works */
+#define _lib_mmap64 1 /* mmap64 interface and implementation work */
+#define _mmap_anon 1 /* use mmap MAP_ANON to get raw memory */
+#define _mmap_devzero 1 /* use mmap on /dev/zero to get raw memory */
+
+/* some systems get it wrong but escape concise detection */
+#ifndef _NO_MMAP
+#if __CYGWIN__
+#define _NO_MMAP 1
+#endif
+#endif
+
+#if _NO_MMAP
+#undef _lib_mmap
+#undef _lib_mmap64
+#undef _mmap_anon
+#undef _mmap_devzero
+#undef _mmap_worthy
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_mode.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_mode.h
new file mode 100644
index 0000000000..5476393224
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_mode.h
@@ -0,0 +1,14 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/mode.c by iffe version 2007-04-04 : : */
+#ifndef _def_mode_ast
+#define _def_mode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define S_ITYPE(m) ((m)&S_IFMT)
+
+#define S_IPERM (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
+
+#define _S_IDPERM 1
+#define _S_IDTYPE 1
+
+#define BUFFERSIZE 8192
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_nl_types.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_nl_types.h
new file mode 100644
index 0000000000..43c7bc9c4d
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_nl_types.h
@@ -0,0 +1,102 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/nl_types by iffe version 2007-04-04 : : */
+
+#ifndef _def_nl_types_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_nl_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_nl_langinfo 1 /* nl_langinfo() in default lib(s) */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_langinfo 1 /* #include <langinfo.h> ok */
+#define _nxt_nl_types <../include/nl_types.h> /* include path for the native <nl_types.h> */
+#define _nxt_nl_types_str "../include/nl_types.h" /* include string for the native <nl_types.h> */
+#include <limits.h>
+#include <../include/nl_types.h> /* the native nl_types.h */
+
+#undef NL_SETMAX
+#define NL_SETMAX 1023
+#undef NL_MSGMAX
+#define NL_MSGMAX 32767
+#undef nl_catd
+#define nl_catd _ast_nl_catd
+#undef catopen
+#define catopen _ast_catopen
+#undef catgets
+#define catgets _ast_catgets
+#undef catclose
+#define catclose _ast_catclose
+
+typedef __V_* nl_catd;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ nl_catd catopen __PROTO__((const char*, int));
+extern __MANGLE__ char* catgets __PROTO__((nl_catd, int, int, const char*));
+extern __MANGLE__ int catclose __PROTO__((nl_catd));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_param.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_param.h
new file mode 100644
index 0000000000..4c28f392e5
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_param.h
@@ -0,0 +1,9 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/param.sh by iffe version 2007-04-04 : : */
+#ifndef _def_param_ast
+#define _def_param_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#include <sys/param.h>
+#ifndef S_IFDIR
+#include <sys/stat.h>
+#endif
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_standards.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_standards.h
new file mode 100644
index 0000000000..8e8231de26
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_standards.h
@@ -0,0 +1,28 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/standards by iffe version 2007-04-04 : : */
+#ifndef _def_standards_ast
+#define _def_standards_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* _ALL_SOURCE & _ISOC99_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works */
+#ifndef _ALL_SOURCE
+#define _ALL_SOURCE 1
+#endif
+#ifndef _ISOC99_SOURCE
+#define _ISOC99_SOURCE 1
+#endif
+#ifndef _POSIX_SOURCE
+#define _POSIX_SOURCE 1
+#endif
+#ifndef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 21000101L
+#endif
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 9900
+#endif
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#ifndef __EXTENSIONS__
+#define __EXTENSIONS__ 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_stdio.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_stdio.h
new file mode 100644
index 0000000000..b17026ca22
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_stdio.h
@@ -0,0 +1,579 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/stdio by iffe version 2007-04-04 : : */
+
+#ifndef _SFSTDIO_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SFSTDIO_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define __FILE_typedef 1
+#define _FILE_DEFINED 1
+#define _FILE_defined 1
+#define _FILEDEFED 1
+
+#ifndef __FILE_TAG
+#define __FILE_TAG _sfio_s
+#endif
+
+#undef FILE
+#undef _FILE
+#undef fpos_t
+#undef fpos64_t
+
+typedef struct _sfio_s _sfio_FILE;
+
+#define FILE _sfio_FILE
+#define _FILE FILE
+
+#if !defined(__FILE) && !__CYGWIN__
+#undef __FILE
+#define __FILE FILE
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define BUFSIZ SF_BUFSIZE
+
+#else
+
+#ifndef BUFSIZ
+#define BUFSIZ 8192
+#endif
+
+#ifndef EOF
+#define EOF (-1)
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+#include <ast_std.h>
+
+#include <sfio_s.h>
+
+#if __cplusplus
+#define _sf_(f) (f)
+#else
+#define _sf_(f) ((struct _sfio_s*)(f))
+#endif
+
+#define _SF_EOF 0000200
+#define _SF_ERROR 0000400
+
+#endif
+
+#ifdef _NO_LARGEFILE64_SOURCE
+#undef _LARGEFILE64_SOURCE
+#endif
+
+#ifdef _LARGEFILE64_SOURCE
+#undef off_t
+#endif
+
+#define fpos_t _ast_fpos_t
+#if _typ_int64_t
+#define fpos64_t _ast_fpos_t
+#endif
+
+typedef struct _ast_fpos_s
+{
+ intmax_t _sf_offset;
+ unsigned char _sf_state[64 - sizeof(intmax_t)];
+} _ast_fpos_t;
+
+#define _base _data
+#define _ptr _next
+#define _IOFBF 0
+#define _IONBF 1
+#define _IOLBF 2
+
+#if defined(__cplusplus) && defined(__THROW) && !defined(_UWIN)
+
+#undef FILE
+#define FILE FILE
+typedef struct _sfio_s FILE;
+
+#undef strerror
+extern __MANGLE__ char* strerror(int) __THROW;
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#endif
+
+#ifndef FILENAME_MAX
+#define FILENAME_MAX 1024
+#endif
+#ifndef FOPEN_MAX
+#define FOPEN_MAX 20
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+
+#define _doprnt _ast_doprnt
+#define _doscan _ast_doscan
+#define asprintf _ast_asprintf
+#define clearerr _ast_clearerr
+#define fclose _ast_fclose
+#define fdopen _ast_fdopen
+#define fflush _ast_fflush
+#define fgetc _ast_fgetc
+#define fgetpos _ast_fgetpos
+#define fgetpos64 _ast_fgetpos64
+#define fgets _ast_fgets
+#define fopen _ast_fopen
+#define fprintf _ast_fprintf
+#define fpurge _ast_fpurge
+#define fputs _ast_fputs
+#define fread _ast_fread
+#define freopen _ast_freopen
+#define fscanf _ast_fscanf
+#define fseek _ast_fseek
+#define fseek64 _ast_fseek64
+#define fseeko _ast_fseeko
+#define fseeko64 _ast_fseeko64
+#define fsetpos _ast_fsetpos
+#define fsetpos64 _ast_fsetpos64
+#define ftell _ast_ftell
+#define ftell64 _ast_ftell64
+#define ftello _ast_ftello
+#define ftello64 _ast_ftello64
+#define fwrite _ast_fwrite
+#define gets _ast_gets
+#define getw _ast_getw
+#define pclose _ast_pclose
+#define popen _ast_popen
+#define printf _ast_printf
+#define puts _ast_puts
+#define putw _ast_putw
+#define rewind _ast_rewind
+#define scanf _ast_scanf
+#define setbuf _ast_setbuf
+#undef setbuffer
+#define setbuffer _ast_setbuffer
+#define setlinebuf _ast_setlinebuf
+#define setvbuf _ast_setvbuf
+#define snprintf _ast_snprintf
+#define sprintf _ast_sprintf
+#define sscanf _ast_sscanf
+#define tmpfile _ast_tmpfile
+#define ungetc _ast_ungetc
+#define vasprintf _ast_vasprintf
+#define vfprintf _ast_vfprintf
+#define vfscanf _ast_vfscanf
+#define vprintf _ast_vprintf
+#define vscanf _ast_vscanf
+#define vsnprintf _ast_vsnprintf
+#define vsprintf _ast_vsprintf
+#define vsscanf _ast_vsscanf
+#define fcloseall _ast_fcloseall
+#define fmemopen _ast_fmemopen
+#define __getdelim _ast___getdelim
+#define getdelim _ast_getdelim
+#define getline _ast_getline
+#define clearerr_unlocked _ast_clearerr_unlocked
+#define feof_unlocked _ast_feof_unlocked
+#define ferror_unlocked _ast_ferror_unlocked
+#define fflush_unlocked _ast_fflush_unlocked
+#define fgetc_unlocked _ast_fgetc_unlocked
+#define fgets_unlocked _ast_fgets_unlocked
+#define fileno_unlocked _ast_fileno_unlocked
+#define fputc_unlocked _ast_fputc_unlocked
+#define fputs_unlocked _ast_fputs_unlocked
+#define fread_unlocked _ast_fread_unlocked
+#define fwrite_unlocked _ast_fwrite_unlocked
+#define getc_unlocked _ast_getc_unlocked
+#define getchar_unlocked _ast_getchar_unlocked
+#define putc_unlocked _ast_putc_unlocked
+#define putchar_unlocked _ast_putchar_unlocked
+
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef P_tmpdir
+#define P_tmpdir "/var/tmp/" /*NOCATLITERAL*/
+#endif
+#ifndef L_ctermid
+#define L_ctermid 9
+#endif
+#ifndef L_tmpnam
+#define L_tmpnam 25
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#if defined(__cplusplus) && defined(__THROW)
+extern __MANGLE__ char* ctermid(char*) __THROW;
+#else
+extern __MANGLE__ char* ctermid __PROTO__((char*));
+#endif
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+extern __MANGLE__ void perror __PROTO__((const char*));
+#ifndef _AST_STD_H
+#ifndef remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#endif
+#ifndef rename
+extern __MANGLE__ int rename __PROTO__((const char*, const char*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#ifdef _LARGEFILE64_SOURCE
+
+#undef fpos_t
+#undef off_t
+#undef fgetpos
+#undef fsetpos
+#undef fseek
+#undef fseeko
+#undef ftell
+#undef ftello
+
+#define fpos_t fpos64_t
+#if _typ_off64_t
+#define off_t off64_t
+#else
+#define off_t int64_t
+#endif
+
+#define fgetpos fgetpos64
+#define fsetpos fsetpos64
+#define fseek fseek64
+#define fseeko fseeko64
+#define ftell ftell64
+#define ftello ftello64
+
+#endif
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_DLL && _DLL_INDIRECT_DATA
+
+#define stdin ((FILE*)_ast_dll->_ast_stdin)
+#define stdout ((FILE*)_ast_dll->_ast_stdout)
+#define stderr ((FILE*)_ast_dll->_ast_stderr)
+
+#else
+
+#define stdin (&_Sfstdin)
+#define stdout (&_Sfstdout)
+#define stderr (&_Sfstderr)
+
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define feof(f) sfeof(f)
+#define ferror(f) sferror(f)
+#define fileno(f) sffileno(f)
+#define fputc(c,f) sfputc(f,c)
+#define getc(f) sfgetc(f)
+#define getchar() sfgetc(sfstdin)
+#define putc(c,f) sfputc(f,c)
+#define putchar(c) sfputc(sfstdout,c)
+
+#else
+
+#if !_UWIN
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+#endif
+
+extern __MANGLE__ FILE _Sfstdin;
+extern __MANGLE__ FILE _Sfstdout;
+extern __MANGLE__ FILE _Sfstderr;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define feof(f) (_sf_(f)->_flags&_SF_EOF)
+#define ferror(f) (_sf_(f)->_flags&_SF_ERROR)
+#define fileno(f) (_sf_(f)->_file)
+#define fputc(c,f) (_sf_(f)->_next>=_sf_(f)->_endw?_sfflsbuf(_sf_(f),(int)((unsigned char)(c))):(int)(*_sf_(f)->_next++=(unsigned char)(c)))
+#define getc(f) (_sf_(f)->_next>=_sf_(f)->_endr?_sffilbuf(_sf_(f),0):(int)(*_sf_(f)->_next++))
+#define getchar() getc(stdin)
+#define putc(c,f) fputc(c,f)
+#define putchar(c) fputc(c,stdout)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _sffilbuf __PROTO__((FILE*, int));
+extern __MANGLE__ int _sfflsbuf __PROTO__((FILE*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_sys.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_sys.h
new file mode 100644
index 0000000000..f0a58dff12
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_sys.h
@@ -0,0 +1,151 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/sys by iffe version 2007-04-04 : : */
+
+#ifndef _AST_SYS_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_SYS_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#if __mips == 2 && !defined(_NO_LARGEFILE64_SOURCE)
+#define _NO_LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_NO_LARGEFILE64_SOURCE) && _typ_off64_t && _lib_lseek64 && _lib_stat64
+#if !defined(_LARGEFILE64_SOURCE)
+#define _LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_LARGEFILE_SOURCE)
+#define _LARGEFILE_SOURCE 1
+#endif
+#else
+#undef _LARGEFILE64_SOURCE
+#undef _LARGEFILE_SOURCE
+#undef _typ_off64_t
+#undef _typ_struct_dirent64
+#undef _lib_creat64
+#undef _lib_fstat64
+#undef _lib_fstatvfs64
+#undef _lib_ftruncate64
+#undef _lib_lseek64
+#undef _lib_lstat64
+#undef _lib_mmap64
+#undef _lib_open64
+#undef _lib_readdir64
+#undef _lib_stat64
+#undef _lib_statvfs64
+#undef _lib_truncate64
+#endif
+#if defined(__STDC__) && !defined(__USE_FIXED_PROTOTYPES__)
+#define __USE_FIXED_PROTOTYPES__ 1 /* kick gcc out of the past */
+#endif
+#include <stdlib.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <locale.h>
+#include <sys/localedef.h>
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _typ_dev_t 1 /* dev_t is a type */
+#define _typ_nlink_t 1 /* nlink_t is a type */
+#define _typ_gid_t 1 /* gid_t is a type */
+#define _typ_mode_t 1 /* mode_t is a type */
+#define _typ_uid_t 1 /* uid_t is a type */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _typ_wchar_t 1 /* wchar_t is a type */
+#define _typ_pid_t 1 /* pid_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _typ_wint_t 1 /* wint_t is a type */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _typ_socklen_t 1 /* socklen_t is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_ino_t 1 /* ino_t is a type */
+#define _typ_off_t 1 /* off_t is a type */
+#define _typ_ptrdiff_t 1 /* ptrdiff_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#define _typ_div_t 1 /* div_t is a type */
+#define _typ_ldiv_t 1 /* ldiv_t is a type */
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+extern __MANGLE__ int eaccess __PROTO__((const char*, int));
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+extern __MANGLE__ __V_* pvalloc __PROTO__((size_t));
+extern __MANGLE__ pid_t spawnveg __PROTO__((const char*, char* const[], char* const[], pid_t));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#if !defined(va_start)
+#if defined(__STDARG__)
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_time.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_time.h
new file mode 100644
index 0000000000..6c57971e4b
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_time.h
@@ -0,0 +1,83 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/time by iffe version 2007-04-04 : : */
+
+#ifndef _def_time_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_time_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_nanosleep 1 /* nanosleep() in default lib(s) */
+#define _lib_usleep 1 /* usleep() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#include <sys/time.h>
+
+#include <sys/times.h>
+
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC CLK_TCK
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_tty.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_tty.h
new file mode 100644
index 0000000000..42f0c1df21
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_tty.h
@@ -0,0 +1,134 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/tty by iffe version 2007-04-04 : : */
+#ifndef _def_tty_ast
+#define _def_tty_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_termios 1 /* #include <termios.h> ok */
+#define _hdr_termio 1 /* #include <termio.h> ok */
+#define _hdr_sgtty 1 /* #include <sgtty.h> ok */
+#define _sys_termios 1 /* #include <sys/termios.h> ok */
+#define _sys_termio 1 /* #include <sys/termio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _lib_tcgetattr 1 /* tcgetattr() in default lib(s) */
+#define _lib_tcgetpgrp 1 /* tcgetpgrp() in default lib(s) */
+#define _mac__POSIX_VDISABLE 1 /* _POSIX_VDISABLE is a macro */
+
+#ifdef _hdr_termios
+# if _mac__POSIX_VDISABLE
+# undef _POSIX_VDISABLE
+# endif
+# include <termios.h>
+#else
+# if defined(_sys_termios) && defined(_lib_tcgetattr)
+# include <sys/termios.h>
+# define _hdr_termios 1
+# else
+# undef _sys_termios
+# endif /* _sys_termios */
+#endif /* _hdr_termios */
+
+#ifdef _hdr_termios
+# undef _hdr_sgtty
+# undef tcgetattr
+# undef tcsetattr
+# undef tcgetpgrp
+# undef tcsetpgrp
+# undef cfgetospeed
+# ifndef TCSANOW
+# define TCSANOW TCSETS
+# define TCSADRAIN TCSETSW
+# define TCSAFLUSH TCSETSF
+# endif /* TCSANOW */
+ /* The following corrects bugs in some implementations */
+# if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
+# define TCSAFLUSH TCSADFLUSH
+# endif /* TCSADFLUSH */
+# ifndef _lib_tcgetattr
+# undef tcgetattr
+# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
+# undef tcsetattr
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# undef cfgetospeed
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# endif /* _lib_tcgetattr */
+# undef TIOCGETC
+#else
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfgetispeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfsetispeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# define cfsetospeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# ifdef _hdr_termio
+# include <termio.h>
+# else
+# ifdef _sys_termio
+# include <sys/termio.h>
+# define _hdr_termio 1
+# endif /* _sys_termio */
+# endif /* _hdr_termio */
+# ifdef _hdr_termio
+# define termios termio
+# undef TIOCGETC
+# define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+
+# ifdef _sys_bsdtty
+# include <sys/bsdtty.h>
+# endif /* _sys_bsdtty */
+# else
+# ifdef _hdr_sgtty
+# include <sgtty.h>
+# ifndef LPENDIN
+# ifdef _sys_nttyio
+# include <sys/nttyio.h>
+# endif /* _sys_nttyio */
+# endif /* LPENDIN */
+# define termios sgttyb
+# ifdef TIOCSETN
+# undef TCSETAW
+# endif /* TIOCSETN */
+# ifdef TIOCGETP
+# define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# else
+# define tcgetattr(fd,tty) gtty(fd, tty)
+# define tcsetattr(fd,action,tty) stty(fd, tty)
+# endif /* TIOCGETP */
+# else
+# ifdef _sys_ttyio
+# include <sys/ttyio.h>
+# endif
+# endif /* _hdr_sgtty */
+# endif /* hdr_termio */
+
+# ifndef TCSANOW
+# ifdef TCSETAW
+# define TCSANOW TCSETA
+# define TCSAFLUSH TCSETAF
+# else
+# ifdef TIOCSETN
+# define TCSANOW TIOCSETN
+# define TCSADRAIN TIOCSETN
+# define TCSAFLUSH TIOCSETP
+# endif /* TIOCSETN */
+# endif /* TCSETAW */
+# endif /* TCSANOW */
+#endif /* _hdr_termios */
+
+/* set ECHOCTL if driver can echo control charaters as ^c */
+#ifdef LCTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LCTLECH
+# endif /* !ECHOCTL */
+#endif /* LCTLECH */
+#ifdef LNEW_CTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LNEW_CTLECH
+# endif /* !ECHOCTL */
+#endif /* LNEW_CTLECH */
+#ifdef LNEW_PENDIN
+# ifndef PENDIN
+# define PENDIN LNEW_PENDIN
+# endif /* !PENDIN */
+#endif /* LNEW_PENDIN */
+
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_types.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_types.h
new file mode 100644
index 0000000000..343b5954a0
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_types.h
@@ -0,0 +1,5 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_types_ast
+#define _def_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_vfork.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_vfork.h
new file mode 100644
index 0000000000..901931c5ec
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_vfork.h
@@ -0,0 +1,67 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/vfork by iffe version 2007-04-04 : : */
+
+#ifndef _def_vfork_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_vfork_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+extern __MANGLE__ pid_t vfork __PROTO__((void));
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_wait.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_wait.h
new file mode 100644
index 0000000000..96f7b01d8b
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_wait.h
@@ -0,0 +1,11 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/wait by iffe version 2007-04-04 : : */
+#ifndef _def_wait_ast
+#define _def_wait_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_wait 1 /* wait() in default lib(s) */
+#define _lib_wait3 1 /* wait3() in default lib(s) */
+#define _lib_wait4 1 /* wait4() in default lib(s) */
+#define _lib_waitpid 1 /* waitpid() in default lib(s) */
+#define _sys_wait 1 /* #include <sys/wait.h> ok */
+#define _ok_wif 1 /* posix wait macros ok */
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/ast_wchar.h b/usr/src/lib/libast/amd64/src/lib/libast/ast_wchar.h
new file mode 100644
index 0000000000..6531edc5fd
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/ast_wchar.h
@@ -0,0 +1,187 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/wchar by iffe version 2007-04-04 : : */
+
+#ifndef _def_wchar_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_wchar_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _lib_mbstowcs 1 /* mbstowcs() in default lib(s) */
+#define _lib_wctomb 1 /* wctomb() in default lib(s) */
+#define _lib_wcrtomb 1 /* wcrtomb() in default lib(s) */
+#define _lib_wcslen 1 /* wcslen() in default lib(s) */
+#define _lib_wcstombs 1 /* wcstombs() in default lib(s) */
+#define _lib_wcwidth 1 /* wcwidth() in default lib(s) */
+#define _lib_towlower 1 /* towlower() in default lib(s) */
+#define _lib_towupper 1 /* towupper() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_mbstate_t 1 /* mbstate_t is a type */
+#define _nxt_wchar <../include/wchar.h> /* include path for the native <wchar.h> */
+#define _nxt_wchar_str "../include/wchar.h" /* include string for the native <wchar.h> */
+#ifndef _SFSTDIO_H
+#include <ast_common.h>
+#include <stdio.h>
+#endif
+#if _hdr_wchar && defined(_nxt_wchar)
+#include <../include/wchar.h> /* the native wchar.h */
+#endif
+#if _hdr_wctype
+#include <wctype.h>
+#endif
+
+#ifndef WEOF
+#define WEOF (-1)
+#endif
+
+#undef fgetwc
+#undef fgetws
+#undef fputwc
+#undef fputws
+#undef getwc
+#undef getwchar
+#undef getws
+#undef putwc
+#undef putwchar
+#undef ungetwc
+
+#define fgetwc _ast_fgetwc
+#define fgetws _ast_fgetws
+#define fputwc _ast_fputwc
+#define fputws _ast_fputws
+#define fwide _ast_fwide
+#define fwprintf _ast_fwprintf
+#define fwscanf _ast_fwscanf
+#define getwc _ast_getwc
+#define getwchar _ast_getwchar
+#define getws _ast_getws
+#define putwc _ast_putwc
+#define putwchar _ast_putwchar
+#define swprintf _ast_swprintf
+#define swscanf _ast_swscanf
+#define ungetwc _ast_ungetwc
+#define vfwprintf _ast_vfwprintf
+#define vfwscanf _ast_vfwscanf
+#define vswprintf _ast_vswprintf
+#define vswscanf _ast_vswscanf
+#define vwprintf _ast_vwprintf
+#define vwscanf _ast_vwscanf
+#define wprintf _ast_wprintf
+#define wscanf _ast_wscanf
+
+#if !_typ_mbstate_t
+#undef _typ_mbstate_t
+#define _typ_mbstate_t 1
+typedef char mbstate_t;
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#if !_lib_mbstowcs
+extern __MANGLE__ size_t mbstowcs __PROTO__((wchar_t*, const char*, size_t));
+#endif
+#if !_lib_wctomb
+extern __MANGLE__ int wctomb __PROTO__((char*, wchar_t));
+#endif
+#if !_lib_wcrtomb
+extern __MANGLE__ size_t wcrtomb __PROTO__((char*, wchar_t, mbstate_t*));
+#endif
+#if !_lib_wcslen
+extern __MANGLE__ size_t wcslen __PROTO__((const wchar_t*));
+#endif
+#if !_lib_wcstombs
+extern __MANGLE__ size_t wcstombs __PROTO__((char*, const wchar_t*, size_t));
+#endif
+
+extern __MANGLE__ int fwprintf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ int fwscanf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ wint_t fgetwc __PROTO__((FILE*));
+extern __MANGLE__ wchar_t* fgetws __PROTO__((wchar_t*, int, FILE*));
+extern __MANGLE__ wint_t fputwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ int fputws __PROTO__((const wchar_t*, FILE*));
+extern __MANGLE__ int fwide __PROTO__((FILE*, int));
+extern __MANGLE__ wint_t getwc __PROTO__((FILE*));
+extern __MANGLE__ wint_t getwchar __PROTO__((void));
+extern __MANGLE__ wchar_t* getws __PROTO__((wchar_t*));
+extern __MANGLE__ wint_t putwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ wint_t putwchar __PROTO__((wchar_t));
+extern __MANGLE__ int swprintf __PROTO__((wchar_t*, size_t, const wchar_t*, ...));
+extern __MANGLE__ int swscanf __PROTO__((const wchar_t*, const wchar_t*, ...));
+extern __MANGLE__ wint_t ungetwc __PROTO__((wint_t, FILE*));
+extern __MANGLE__ int vfwprintf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vfwscanf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vwprintf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vwscanf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vswprintf __PROTO__((wchar_t*, size_t, const wchar_t*, va_list));
+extern __MANGLE__ int vswscanf __PROTO__((const wchar_t*, const wchar_t*, va_list));
+extern __MANGLE__ int wprintf __PROTO__((const wchar_t*, ...));
+extern __MANGLE__ int wscanf __PROTO__((const wchar_t*, ...));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/conftab.c b/usr/src/lib/libast/amd64/src/lib/libast/conftab.c
new file mode 100644
index 0000000000..b7c7769c7b
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/conftab.c
@@ -0,0 +1,451 @@
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+#include "FEATURE/standards"
+#include "FEATURE/common"
+#include <sys/types.h>
+#include <limits.h>
+#include <unistd.h>
+#if !defined(SYS_NMLEN)
+#define SYS_NMLEN 9
+#endif
+#include <sys/systeminfo.h>
+#include "FEATURE/param"
+#include "conftab.h"
+
+/* : : generated by conf from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/comp/conf.tab : : */
+
+/*
+ * prefix strings -- the first few are indexed by Conf_t.standard
+ */
+
+const Prefix_t prefix[] =
+{
+ "C", 1, CONF_C, -1,
+ "POSIX", 5, CONF_POSIX, -1,
+ "SVID", 4, CONF_SVID, -1,
+ "XOPEN", 5, CONF_XOPEN, -1,
+ "SUN", 3, CONF_SUN, -1,
+ "XBS5", 4, CONF_XBS5, -1,
+ "SCO", 3, CONF_SCO, -1,
+ "AST", 3, CONF_AST, -1,
+ "AES", 3, CONF_AES, -1,
+ "XPG", 3, CONF_XPG, -1,
+ "GNU", 3, CONF_GNU, -1,
+ "TRUSTEDBSD", 10, CONF_TRUSTEDBSD, -1,
+ "XX", 2, CONF_POSIX, CONF_nop,
+ "CS", 2, CONF_POSIX, CONF_confstr,
+ "PC", 2, CONF_POSIX, CONF_pathconf,
+ "SC", 2, CONF_POSIX, CONF_sysconf,
+ "SI", 2, CONF_SVID, CONF_sysinfo,
+};
+
+int prefix_elements = (int)sizeof(prefix) / (int)sizeof(prefix[0]);
+
+/*
+ * conf strings sorted in ascending order
+ */
+
+const Conf_t conf[] =
+{
+{ "ABI_AIO_XFER_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ABI_ASYNCHRONOUS_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ABI_ASYNC_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ADVISORY_INFO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_ADVISORY_INFO },
+{ "AIO_LISTIO_MAX", { 0, 0 }, { _POSIX_AIO_LISTIO_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_AIO_LISTIO_MAX },
+{ "AIO_MAX", { 0, 0 }, { _POSIX_AIO_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_AIO_MAX },
+{ "AIO_PRIO_DELTA_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, _SC_AIO_PRIO_DELTA_MAX },
+{ "ALLOC_SIZE_MIN", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_ALLOC_SIZE_MIN },
+{ "ARCHITECTURE", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "ARG_MAX", { 0, 0 }, { _POSIX_ARG_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_ARG_MAX },
+{ "ASYNCHRONOUS_IO", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_ASYNCHRONOUS_IO },
+{ "ASYNC_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_ASYNC_IO },
+{ "ATEXIT_MAX", { 0, 0 }, { 32, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_XOPEN, 1, CONF_sysconf, _SC_ATEXIT_MAX },
+{ "AUDIT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "AVAIL_PROCESSORS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "AVPHYS_PAGES", { 0, 0 }, { 0, 0 }, 0, CONF_SUN, 1, CONF_sysconf, _SC_AVPHYS_PAGES },
+{ "BARRIERS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_BARRIERS },
+{ "BC_BASE_MAX", { 0, 0 }, { _POSIX2_BC_BASE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_BC_BASE_MAX },
+{ "BC_DIM_MAX", { 0, 0 }, { _POSIX2_BC_DIM_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_BC_DIM_MAX },
+{ "BC_SCALE_MAX", { 0, 0 }, { _POSIX2_BC_SCALE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_BC_SCALE_MAX },
+{ "BC_STRING_MAX", { 0, 0 }, { _POSIX2_BC_STRING_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_BC_STRING_MAX },
+{ "BUSTYPES", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "CHARCLASS_NAME_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "CHAR_BIT", { 8, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "CHAR_MAX", { 127, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "CHAR_MIN", { -128, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "CHAR_TERM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_CHAR_TERM },
+{ "CHILD_MAX", { 0, 0 }, { _POSIX_CHILD_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_CHILD_MAX },
+{ "CHOWN_RESTRICTED", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_CHOWN_RESTRICTED },
+{ "CKPT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "CLK_TCK", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_POSIX, 1, CONF_sysconf, _SC_CLK_TCK },
+{ "CLOCKRES_MIN", { 0, 0 }, { _POSIX_CLOCKRES_MIN, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_PREFIX_ONLY|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "CLOCKS_PER_SEC", { 1000000, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_LIMIT|CONF_LIMIT_DEF, CONF_POSIX, 1, CONF_nop, -1 },
+{ "CLOCK_SELECTION", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_CLOCK_SELECTION },
+{ "COLL_WEIGHTS_MAX", { 0, 0 }, { _POSIX2_COLL_WEIGHTS_MAX, 0 }, CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_COLL_WEIGHTS_MAX },
+{ "CPUTIME", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_CPUTIME },
+{ "CPU_KEYBITS1", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "CPU_VERSION", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "CRYPT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_CRYPT },
+{ "C_BIND", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 2, CONF_sysconf, _SC_2_C_BIND },
+{ "C_DEV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 2, CONF_sysconf, _SC_2_C_DEV },
+{ "C_VERSION", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 2, CONF_sysconf, _SC_2_C_VERSION },
+{ "DATAKEYS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "DELAYTIMER_MAX", { 0, 0 }, { _POSIX_DELAYTIMER_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_DELAYTIMER_MAX },
+{ "ENH_I18N", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_ENH_I18N },
+{ "EQUIV_CLASS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "EXEC_INTERPRETER_LENGTH", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "EXPR_NEST_MAX", { 0, 0 }, { _POSIX2_EXPR_NEST_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_EXPR_NEST_MAX },
+{ "FCHR_MAX", { 0, 0 }, { LONG_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "FILESIZEBITS", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_FILESIZEBITS },
+{ "FILE_LOCKING", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "FORT_DEV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_FORT_DEV },
+{ "FORT_RUN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_FORT_RUN },
+{ "FSYNC", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_FSYNC },
+{ "GETGR_R_SIZE_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_sysconf, _SC_GETGR_R_SIZE_MAX },
+{ "GETPW_R_SIZE_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_sysconf, _SC_GETPW_R_SIZE_MAX },
+{ "HOSTID", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "HOSTNAME", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "HOST_NAME_MAX", { 0, 0 }, { _POSIX_HOST_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_HOST_NAME_MAX },
+{ "HW_PROVIDER", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "HW_SERIAL", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ILP32_OFF32", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XBS5, 1, CONF_sysconf, -1 },
+{ "ILP32_OFF32_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFF32_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFF32_LIBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFF32_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFFBIG", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XBS5, 1, CONF_sysconf, -1 },
+{ "ILP32_OFFBIG_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFFBIG_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFFBIG_LIBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFFBIG_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "INITTAB_NAME", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "INT_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "INT_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "IOV_MAX", { 0, 0 }, { _XOPEN_IOV_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_XOPEN, 1, CONF_sysconf, _SC_IOV_MAX },
+{ "IO_TYPE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "IPV6", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_IPV6 },
+{ "IP_SECOPTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "JOB_CONTROL", { 0, 0 }, { 1, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_JOB_CONTROL },
+{ "KERNEL_CLIST", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_CLIST_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_DISK", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_DISK_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_DMABUF", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_DMABUF_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_FILE", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_FILE_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_FLCKREC", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_FLCKREC_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_INODE", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_INODE_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_MOUNT", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_MOUNT_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_PINODE", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_PINODE_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_PROC", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_PROC_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_REGION", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_REGION_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_S5INODE", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_S5INODE_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_STAMP", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "KERN_POINTERS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "KERN_SIM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "LEGACY", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, -1 },
+{ "LFS64_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS64_CFLAGS },
+{ "LFS64_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS64_LDFLAGS },
+{ "LFS64_LIBS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS64_LIBS },
+{ "LFS64_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS64_LINTFLAGS },
+{ "LFS_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_CFLAGS },
+{ "LFS_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_LDFLAGS },
+{ "LFS_LIBS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_LIBS },
+{ "LFS_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_LINTFLAGS },
+{ "LINE_MAX", { 0, 0 }, { _POSIX2_LINE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_LINE_MAX },
+{ "LINK_MAX", { 0, 0 }, { _POSIX_LINK_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_LINK_MAX },
+{ "LLONG_MAX", { 9223372036854775807LL, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "LLONG_MIN", { (-9223372036854775807LL-1LL), 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "LOCALEDEF", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_LOCALEDEF },
+{ "LOGIN_NAME_MAX", { 0, 0 }, { _POSIX_LOGIN_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_LOGIN_NAME_MAX },
+{ "LOGNAME_MAX", { 0, 0 }, { 8, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, _SC_LOGNAME_MAX },
+{ "LONG_BIT", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "LONG_MAX", { 2147483647, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "LONG_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "LP64_OFF64", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XBS5, 1, CONF_sysconf, -1 },
+{ "LP64_OFF64_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LP64_OFF64_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LP64_OFF64_LIBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LP64_OFF64_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LPBIG_OFFBIG", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XBS5, 1, CONF_sysconf, -1 },
+{ "LPBIG_OFFBIG_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LPBIG_OFFBIG_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LPBIG_OFFBIG_LIBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LPBIG_OFFBIG_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "MACHINE", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "MAPPED_FILES", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MAPPED_FILES },
+{ "MAX_CANON", { 0, 0 }, { _POSIX_MAX_CANON, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_MAX_CANON },
+{ "MAX_INPUT", { 0, 0 }, { _POSIX_MAX_INPUT, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_MAX_INPUT },
+{ "MB_LEN_MAX", { 5, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "MCAS_OFFSET", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "MEMLOCK", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MEMLOCK },
+{ "MEMLOCK_RANGE", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MEMLOCK_RANGE },
+{ "MEMORY_PROTECTION", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MEMORY_PROTECTION },
+{ "MESSAGE_PASSING", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MESSAGE_PASSING },
+{ "MMAP_FIXED_ALIGNMENT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "MONOTONIC_CLOCK", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MONOTONIC_CLOCK },
+{ "MQ_OPEN_MAX", { 0, 0 }, { _POSIX_MQ_OPEN_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_MQ_OPEN_MAX },
+{ "MQ_PRIO_MAX", { 0, 0 }, { _POSIX_MQ_PRIO_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_MQ_PRIO_MAX },
+{ "MSEM_LOCKID", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "MULTI_PROCESS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "NACLS_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "NAME_MAX", { 0, 0 }, { _POSIX_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_NAME_MAX },
+{ "NGROUPS_MAX", { 0, 0 }, { _POSIX_NGROUPS_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_NGROUPS_MAX },
+{ "NL_ARGMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_LANGMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NL_MSGMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_NMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_SETMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_SPECMAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NL_TEXTMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NO_TRUNC", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_NO_TRUNC },
+{ "NPROCESSORS_CONF", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, _SC_NPROCESSORS_CONF },
+{ "NPROCESSORS_ONLN", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, _SC_NPROCESSORS_ONLN },
+{ "NPROC_CONF", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NPROC_ONLN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NSS_BUFLEN_GROUP", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NSS_BUFLEN_PASSWD", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NUM_PROCESSORS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NZERO", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "OPEN_MAX", { 0, 0 }, { _POSIX_OPEN_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_OPEN_MAX },
+{ "OPEN_MAX_CEIL", { OPEN_MAX, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_AST, 1, CONF_nop, -1 },
+{ "OSREL_MAJ", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "OSREL_MIN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "OSREL_PATCH", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "OS_BASE", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "OS_PROVIDER", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "OS_VERSION", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE, CONF_AES, 1, CONF_sysconf, -1 },
+{ "PAGESIZE", { 0, 0 }, { 4096, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_PAGESIZE },
+{ "PAGE_SIZE", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, _SC_PAGE_SIZE },
+{ "PASS_MAX", { 0, 0 }, { 8, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, _SC_PASS_MAX },
+{ "PATH", { 0, 0 }, { 0, "/bin:/usr/bin" }, CONF_DEFER_CALL|CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_confstr, _CS_PATH },
+{ "PATH_MAX", { 0, 0 }, { _POSIX_PATH_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_PATH_MAX },
+{ "PBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS },
+{ "PBS_ACCOUNTING", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_ACCOUNTING },
+{ "PBS_CHECKPOINT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_CHECKPOINT },
+{ "PBS_LOCATE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_LOCATE },
+{ "PBS_MESSAGE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_MESSAGE },
+{ "PBS_TRACK", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_TRACK },
+{ "PHYS_PAGES", { 0, 0 }, { 0, 0 }, 0, CONF_SUN, 1, CONF_sysconf, _SC_PHYS_PAGES },
+{ "PID_MAX", { 0, 0 }, { 30000, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "PII", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_INTERNET", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_INTERNET_DGRAM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_INTERNET_STREAM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_OSI", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_OSI_CLTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_OSI_COTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_OSI_M", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_SOCKET", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_XTI", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PIPE_BUF", { 0, 0 }, { _POSIX_PIPE_BUF, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_PIPE_BUF },
+{ "POLL", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PRIORITIZED_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_PRIORITIZED_IO },
+{ "PRIORITY_SCHEDULING", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_PRIORITY_SCHEDULING },
+{ "PRIO_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_PRIO_IO },
+{ "PROC_RSRC_MGR", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTHREAD_DESTRUCTOR_ITERATIONS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTHREAD_KEYS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTHREAD_STACK_MIN", { 4096, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_LIMIT|CONF_LIMIT_DEF, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTHREAD_THREADS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTRDIFF_MAX", { 9223372036854775807LL, 0 }, { 65535, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "PTRDIFF_MIN", { (-9223372036854775807LL-1LL), 0 }, { -65535, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "RAW_SOCKETS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_RAW_SOCKETS },
+{ "READER_WRITER_LOCKS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_READER_WRITER_LOCKS },
+{ "REALTIME", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, -1 },
+{ "REALTIME_SIGNALS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_REALTIME_SIGNALS },
+{ "REALTIME_THREADS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, -1 },
+{ "REC_INCR_XFER_SIZE", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_REC_INCR_XFER_SIZE },
+{ "REC_MAX_XFER_SIZE", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_REC_MAX_XFER_SIZE },
+{ "REC_MIN_XFER_SIZE", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_REC_MIN_XFER_SIZE },
+{ "REC_XFER_ALIGN", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_REC_XFER_ALIGN },
+{ "REENTRANT_FUNCTIONS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "REGEXP", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_REGEXP },
+{ "REGEX_VERSION", { 0, 0 }, { 20030916, 0 }, CONF_FEATURE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "RELEASE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "RESOURCE_LIMITS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "RE_DUP_MAX", { 0, 0 }, { _POSIX2_RE_DUP_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_RE_DUP_MAX },
+{ "RTSIG_MAX", { 0, 0 }, { _POSIX_RTSIG_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_RTSIG_MAX },
+{ "SAVED_IDS", { 0, 0 }, { 1, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SAVED_IDS },
+{ "SCHAR_MAX", { 127, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SCHAR_MIN", { -128, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SECURITY_CLASS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SELECT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "SEMAPHORES", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SEMAPHORES },
+{ "SEM_NSEMS_MAX", { 0, 0 }, { _POSIX_SEM_NSEMS_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_SEM_NSEMS_MAX },
+{ "SEM_VALUE_MAX", { 0, 0 }, { _POSIX_SEM_VALUE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_SEM_VALUE_MAX },
+{ "SH", { 0, 0 }, { 0, "/bin/sh" }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING|CONF_MINMAX_DEF, CONF_AST, 1, CONF_confstr, -1 },
+{ "SHARED_MEMORY_OBJECTS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SHARED_MEMORY_OBJECTS },
+{ "SHELL", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SHELL },
+{ "SHM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_SHM },
+{ "SHRT_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "SHRT_MIN", { -32768, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SIGQUEUE_MAX", { 0, 0 }, { _POSIX_SIGQUEUE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_SIGQUEUE_MAX },
+{ "SIGRT_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, _SC_SIGRT_MAX },
+{ "SIGRT_MIN", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, _SC_SIGRT_MIN },
+{ "SIG_ATOMIC_MAX", { 2147483647, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SIG_ATOMIC_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SIZE_MAX", { UINT_MAX, 0 }, { 65535, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SLVM_MAXNODES", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SOCK_MAXBUF", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SOFTPOWER", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SPAWN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SPAWN },
+{ "SPIN_LOCKS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SPIN_LOCKS },
+{ "SPORADIC_SERVER", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SPORADIC_SERVER },
+{ "SRPC_DOMAIN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SSIZE_MAX", { INT_MAX, 0 }, { _POSIX_SSIZE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SS_REPL_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SS_REPL_MAX },
+{ "STD_BLK", { 0, 0 }, { 1024, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "STREAMS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_STREAMS },
+{ "STREAM_MAX", { 0, 0 }, { _POSIX_STREAM_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_STREAM_MAX },
+{ "SW_DEV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_SW_DEV },
+{ "SYMLINKS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_pathconf, _PC_2_SYMLINKS },
+{ "SYMLINK_MAX", { 0, 0 }, { _POSIX_SYMLINK_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_SYMLINK_MAX },
+{ "SYMLOOP_MAX", { 0, 0 }, { _POSIX_SYMLOOP_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_SYMLOOP_MAX },
+{ "SYNCHRONIZED_IO", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SYNCHRONIZED_IO },
+{ "SYNC_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_SYNC_IO },
+{ "SYSNAME", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "SYSPID_MAX", { 0, 0 }, { 2, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "THREADS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREADS },
+{ "THREADS_PRIO_CEILING", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "THREADS_PRIO_INHERIT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "THREAD_ATTR_STACKADDR", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_ATTR_STACKADDR },
+{ "THREAD_ATTR_STACKSIZE", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_ATTR_STACKSIZE },
+{ "THREAD_CPUTIME", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_CPUTIME },
+{ "THREAD_DESTRUCTOR_ITERATIONS", { 0, 0 }, { _POSIX_THREAD_DESTRUCTOR_ITERATIONS, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_PREFIX_ONLY|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_DESTRUCTOR_ITERATIONS },
+{ "THREAD_KEYS_MAX", { 0, 0 }, { _POSIX_THREAD_KEYS_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_PREFIX_ONLY|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_KEYS_MAX },
+{ "THREAD_PRIORITY_SCHEDULING", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_PRIORITY_SCHEDULING },
+{ "THREAD_PRIO_INHERIT", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_PRIO_INHERIT },
+{ "THREAD_PRIO_PROTECT", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_PRIO_PROTECT },
+{ "THREAD_PROCESS_SHARED", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_PROCESS_SHARED },
+{ "THREAD_SAFE_FUNCTIONS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_SAFE_FUNCTIONS },
+{ "THREAD_SPORADIC_SERVER", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_SPORADIC_SERVER },
+{ "THREAD_STACK_MIN", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_STACK_MIN },
+{ "THREAD_THREADS_MAX", { 0, 0 }, { _POSIX_THREAD_THREADS_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_PREFIX_ONLY|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_THREADS_MAX },
+{ "TIMEOUTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TIMEOUTS },
+{ "TIMERS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TIMERS },
+{ "TIMER_MAX", { 0, 0 }, { _POSIX_TIMER_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_TIMER_MAX },
+{ "TMP", { 0, 0 }, { 0, "/tmp" }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING|CONF_MINMAX_DEF, CONF_AST, 1, CONF_confstr, -1 },
+{ "TMP_MAX", { 17576, 0 }, { 10000, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_C, 1, CONF_sysconf, -1 },
+{ "TRACE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE },
+{ "TRACE_EVENT_FILTER", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_EVENT_FILTER },
+{ "TRACE_EVENT_NAME_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_EVENT_NAME_MAX },
+{ "TRACE_INHERIT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_INHERIT },
+{ "TRACE_LOG", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_LOG },
+{ "TRACE_NAME_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_NAME_MAX },
+{ "TRACE_SYS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_SYS_MAX },
+{ "TRACE_USER_EVENT_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_USER_EVENT_MAX },
+{ "TTY_NAME_MAX", { 0, 0 }, { _POSIX_TTY_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_TTY_NAME_MAX },
+{ "TYPED_MEMORY_OBJECTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TYPED_MEMORY_OBJECTS },
+{ "TZNAME_MAX", { 0, 0 }, { _POSIX_TZNAME_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_TZNAME_MAX },
+{ "T_IOV_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_C, 1, CONF_sysconf, _SC_T_IOV_MAX },
+{ "UCHAR_MAX", { 255, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "UCHAR_MIN", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "UID_MAX", { 0, 0 }, { 60002, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "UINT_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "UIO_MAXIOV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ULLONG_MAX", { 18446744073709551615ULL, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "ULONG_MAX", { 4294967295, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "UNIX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_UNIX },
+{ "UPE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_UPE },
+{ "USER_LIMIT", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "USHRT_MAX", { 65535, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "V6_ILP32_OFF32", { 0, 0 }, { 0, 0 }, CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_V6_ILP32_OFF32 },
+{ "V6_ILP32_OFFBIG", { 0, 0 }, { 0, 0 }, CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_V6_ILP32_OFFBIG },
+{ "V6_LP64_OFF64", { 0, 0 }, { 0, 0 }, CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_V6_LP64_OFF64 },
+{ "V6_LPBIG_OFFBIG", { 0, 0 }, { 0, 0 }, CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_V6_LPBIG_OFFBIG },
+{ "VDISABLE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_VDISABLE },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_PREFIXED|CONF_STANDARD|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "VERSION", { 0, 0 }, { 200112, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "VERSION", { 0, 0 }, { 200112, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 2, CONF_sysconf, -1 },
+{ "VERSION", { 0, 0 }, { 600, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_VERSION },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_XPG, 3, CONF_sysconf, -1 },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_XPG, 4, CONF_sysconf, -1 },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_PREFIXED|CONF_STANDARD, CONF_AST, 1, CONF_nop, -1 },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_PREFIXED|CONF_STANDARD, CONF_GNU, 1, CONF_nop, -1 },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_PREFIXED|CONF_STANDARD, CONF_TRUSTEDBSD, 1, CONF_nop, -1 },
+{ "VERSION_88", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_LIMIT|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "VERSION_88", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "VERSION_90", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_LIMIT|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "VERSION_90", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "VERSION_93", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_LIMIT|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "VERSION_93", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "WCHAR_MAX", { 2147483647, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "WCHAR_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "WINT_MAX", { 2147483647, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "WINT_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "WORD_BIT", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "XCU_VERSION", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_XCU_VERSION },
+{ "XPG2", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "XPG3", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "XPG4", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_nop, -1 },
+};
+
+int conf_elements = (int)sizeof(conf) / (int)sizeof(conf[0]);
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/conftab.h b/usr/src/lib/libast/amd64/src/lib/libast/conftab.h
new file mode 100644
index 0000000000..a84d5aa9ee
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/conftab.h
@@ -0,0 +1,154 @@
+
+/* : : generated by proto : : */
+
+
+#ifndef _CONFTAB_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _CONFTAB_H
+
+#if !defined(SYS_NMLEN)
+#define SYS_NMLEN 9
+#endif
+#include <sys/systeminfo.h>
+
+/* : : generated by conf from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/comp/conf.tab : : */
+
+#define conf _ast_conf_data
+#define conf_elements _ast_conf_ndata
+
+#define prefix _ast_conf_prefix
+#define prefix_elements _ast_conf_nprefix
+
+#define CONF_nop 0
+#define CONF_confstr 1
+#define CONF_pathconf 2
+#define CONF_sysconf 3
+#define CONF_sysinfo 4
+
+#define CONF_C 0
+#define CONF_POSIX 1
+#define CONF_SVID 2
+#define CONF_XOPEN 3
+#define CONF_SUN 4
+#define CONF_XBS5 5
+#define CONF_SCO 6
+#define CONF_AST 7
+#define CONF_AES 8
+#define CONF_XPG 9
+#define CONF_GNU 10
+#define CONF_TRUSTEDBSD 11
+#define CONF_call 12
+
+#define _pth_getconf "/usr/bin/getconf"
+#define _pth_getconf_a "-a"
+
+#define CONF_DEFER_CALL 0x0001
+#define CONF_DEFER_MM 0x0002
+#define CONF_FEATURE 0x0004
+#define CONF_LIMIT 0x0008
+#define CONF_LIMIT_DEF 0x0010
+#define CONF_MINMAX 0x0020
+#define CONF_MINMAX_DEF 0x0040
+#define CONF_NOSECTION 0x0080
+#define CONF_NOUNDERSCORE 0x0100
+#define CONF_PREFIX_ONLY 0x0200
+#define CONF_PREFIXED 0x0400
+#define CONF_STANDARD 0x0800
+#define CONF_STRING 0x1000
+#define CONF_UNDERSCORE 0x2000
+#define CONF_USER 0x4000
+
+struct Conf_s; typedef struct Conf_s Conf_t;
+
+typedef int (*Conf_f) __PROTO__((Conf_t*, intmax_t*, char**));
+
+typedef struct Value_s
+{
+ intmax_t number;
+ const char* string;
+} Value_t;
+
+struct Conf_s
+{
+ const char name[32];
+ Value_t limit;
+ Value_t minmax;
+ short flags;
+ short standard;
+ short section;
+ short call;
+ short op;
+};
+
+typedef struct Prefix_s
+{
+ const char name[16];
+ short length;
+ short standard;
+ short call;
+} Prefix_t;
+
+extern __MANGLE__ const Conf_t conf[];
+extern __MANGLE__ int conf_elements;
+
+extern __MANGLE__ const Prefix_t prefix[];
+extern __MANGLE__ int prefix_elements;
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/lc.h b/usr/src/lib/libast/amd64/src/lib/libast/lc.h
new file mode 100644
index 0000000000..fdd804f36e
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/lc.h
@@ -0,0 +1,158 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated by ./lcgen : : */
+
+
+#ifndef _LC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _LC_H 1
+
+#include <ast.h>
+
+#define LC_abbreviated 0x00001
+#define LC_checked 0x00002
+#define LC_default 0x00004
+#define LC_defined 0x00008
+#define LC_debug 0x00010
+#define LC_local 0x00020
+#define LC_primary 0x00040
+#define LC_qualified 0x00080
+#define LC_undefined 0x00100
+#define LC_verbose 0x00200
+#define LC_user 0x10000
+#define LC_language_attribute_max 2
+#define LC_territory_language_max 4
+
+struct Lc_s;
+
+typedef struct Lc_info_s
+{
+ const struct Lc_s* lc;
+ unsigned long number;
+ __V_* data;
+} Lc_info_t;
+
+typedef struct Lc_attribute_s
+{
+ const char* name;
+ unsigned long flags;
+ unsigned long index;
+} Lc_attribute_t;
+
+typedef struct Lc_charset_s
+{
+ const char* code;
+ const char* alternates;
+ const char* ms;
+ unsigned long index;
+} Lc_charset_t;
+
+typedef struct Lc_language_s
+{
+ const char* code;
+ const char* name;
+ const char* alternates;
+ const Lc_charset_t* charset;
+ unsigned long flags;
+ unsigned long index;
+ const Lc_attribute_t* attributes[LC_language_attribute_max];
+} Lc_language_t;
+
+typedef struct Lc_territory_s
+{
+ const char* code;
+ const char* name;
+ unsigned long flags;
+ unsigned long index;
+ const Lc_language_t* languages[LC_territory_language_max];
+#ifdef _LC_TERRITORY_PRIVATE_
+ _LC_TERRITORY_PRIVATE_
+#endif
+} Lc_territory_t;
+
+typedef struct Lc_map_s
+{
+ const char* code;
+ const Lc_language_t* language;
+ const Lc_territory_t* territory;
+ const Lc_charset_t* charset;
+ const Lc_attribute_t* attribute;
+} Lc_map_t;
+
+typedef struct Lc_attribute_list_s
+{
+ struct Lc_attribute_list_s* next;
+ const Lc_attribute_t* attribute;
+} Lc_attribute_list_t;
+
+typedef struct Lc_s
+{
+ const char* name;
+ const char* code;
+ const Lc_language_t* language;
+ const Lc_territory_t* territory;
+ const Lc_charset_t* charset;
+ const Lc_attribute_list_t* attributes;
+ unsigned long flags;
+ unsigned long index;
+#ifdef _LC_PRIVATE_
+ _LC_PRIVATE_
+#endif
+} Lc_t;
+
+struct Lc_category_s;
+
+typedef int (*Lc_category_set_f) __PROTO__((struct Lc_category_s*));
+
+typedef struct Lc_category_s
+{
+ const char* name;
+ int external;
+ int internal;
+ Lc_category_set_f setf;
+ Lc_t* prev;
+} Lc_category_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ size_t lccanon __PROTO__((Lc_t*, unsigned long flags, char*, size_t));
+extern __MANGLE__ Lc_category_t* lccategories __PROTO__((void));
+extern __MANGLE__ int lcindex __PROTO__((int, int));
+extern __MANGLE__ Lc_info_t* lcinfo __PROTO__((int));
+extern __MANGLE__ Lc_t* lcmake __PROTO__((const char*));
+extern __MANGLE__ Lc_t* lcscan __PROTO__((Lc_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/lctab.h b/usr/src/lib/libast/amd64/src/lib/libast/lctab.h
new file mode 100644
index 0000000000..6abbd72c65
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/lctab.h
@@ -0,0 +1,2630 @@
+/* : : generated by ./lcgen : : */
+
+static Lc_attribute_t attribute_es[] =
+{
+{"traditional",LC_default,
+#ifdef SUBLANG_SPANISH_TRADITIONAL
+SUBLANG_SPANISH_TRADITIONAL,
+#else
+0,
+#endif
+
+},
+{"modern",0,
+#ifdef SUBLANG_SPANISH_MODERN
+SUBLANG_SPANISH_MODERN,
+#else
+0,
+#endif
+
+},
+};
+
+static const Lc_charset_t charset[] =
+{
+{"iso8859-1","latin1|west-europe","1252",},
+{"iso8859-2","latin2|east-europe","1250",},
+{"iso8859-3","latin3|south-europe","1257",},
+{"iso8859-4","latin4|north-europe",0},
+{"iso8859-5","cyrillic","1251",},
+{"iso8859-6","arabic","1256",},
+{"iso8859-7","greek","1253",},
+{"iso8859-8","hebrew","1255",},
+{"iso8859-9","latin5|turkish","1254",},
+{"iso8859-10","latin6|nordic",0},
+{"iso8859-13","latin7",0},
+{"iso8859-14","latin8|celtic",0},
+{"iso8859-15","latin0",0},
+{"iso2022","japanese|korean",0},
+{"iso4873","japanese-ascii|korean-ascii",0},
+{"koi8-r","russian",0},
+{"utf8","plan9",0},
+ 0
+};
+
+static const Lc_language_t language[] =
+{
+{"C","C","POSIX",&charset[0],LC_default,0,0,0,},
+{"debug","debug",0,&charset[0],LC_debug,0,0,0,},
+{"aa","afar",0,&charset[0],0,
+#ifdef LANG_AFAR
+LANG_AFAR,
+#else
+0,
+#endif
+0,0,
+},
+{"ab","abkhazian",0,&charset[0],0,
+#ifdef LANG_ABKHAZIAN
+LANG_ABKHAZIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"af","afrikaans","afr",&charset[0],0,
+#ifdef LANG_AFRIKAANS
+LANG_AFRIKAANS,
+#else
+0,
+#endif
+0,0,
+},
+{"am","amharic",0,&charset[0],0,
+#ifdef LANG_AMHARIC
+LANG_AMHARIC,
+#else
+0,
+#endif
+0,0,
+},
+{"ar","arabic","ara",&charset[5],0,
+#ifdef LANG_ARABIC
+LANG_ARABIC,
+#else
+0,
+#endif
+0,0,
+},
+{"as","assamese",0,&charset[0],0,
+#ifdef LANG_ASSAMESE
+LANG_ASSAMESE,
+#else
+0,
+#endif
+0,0,
+},
+{"ay","aymara",0,&charset[0],0,
+#ifdef LANG_AYMARA
+LANG_AYMARA,
+#else
+0,
+#endif
+0,0,
+},
+{"az","azerbaijani",0,&charset[0],0,
+#ifdef LANG_AZERBAIJANI
+LANG_AZERBAIJANI,
+#else
+0,
+#endif
+0,0,
+},
+{"ba","bashkir",0,&charset[0],0,
+#ifdef LANG_BASHKIR
+LANG_BASHKIR,
+#else
+0,
+#endif
+0,0,
+},
+{"be","belarusian","bel",&charset[0],0,
+#ifdef LANG_BELARUSIAN
+LANG_BELARUSIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"bg","bulgarian","bul",&charset[4],0,
+#ifdef LANG_BULGARIAN
+LANG_BULGARIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"bh","bihari",0,&charset[0],0,
+#ifdef LANG_BIHARI
+LANG_BIHARI,
+#else
+0,
+#endif
+0,0,
+},
+{"bi","bislama",0,&charset[0],0,
+#ifdef LANG_BISLAMA
+LANG_BISLAMA,
+#else
+0,
+#endif
+0,0,
+},
+{"bn","bengali-bangla",0,&charset[0],0,
+#ifdef LANG_BENGALI_BANGLA
+LANG_BENGALI_BANGLA,
+#else
+0,
+#endif
+0,0,
+},
+{"bo","tibetan",0,&charset[0],0,
+#ifdef LANG_TIBETAN
+LANG_TIBETAN,
+#else
+0,
+#endif
+0,0,
+},
+{"br","breton",0,&charset[0],0,
+#ifdef LANG_BRETON
+LANG_BRETON,
+#else
+0,
+#endif
+0,0,
+},
+{"ca","catalan","cat",&charset[0],0,
+#ifdef LANG_CATALAN
+LANG_CATALAN,
+#else
+0,
+#endif
+0,0,
+},
+{"co","corsican",0,&charset[0],0,
+#ifdef LANG_CORSICAN
+LANG_CORSICAN,
+#else
+0,
+#endif
+0,0,
+},
+{"cs","czech","ces|cze",&charset[1],0,
+#ifdef LANG_CZECH
+LANG_CZECH,
+#else
+0,
+#endif
+0,0,
+},
+{"cy","welsh",0,&charset[0],0,
+#ifdef LANG_WELSH
+LANG_WELSH,
+#else
+0,
+#endif
+0,0,
+},
+{"da","danish","dan",&charset[0],0,
+#ifdef LANG_DANISH
+LANG_DANISH,
+#else
+0,
+#endif
+0,0,
+},
+{"de","german","deu|ger",&charset[0],0,
+#ifdef LANG_GERMAN
+LANG_GERMAN,
+#else
+0,
+#endif
+0,0,
+},
+{"dz","bhutani",0,&charset[0],0,
+#ifdef LANG_BHUTANI
+LANG_BHUTANI,
+#else
+0,
+#endif
+0,0,
+},
+{"el","greek","ell|gre",&charset[6],0,
+#ifdef LANG_GREEK
+LANG_GREEK,
+#else
+0,
+#endif
+0,0,
+},
+{"en","english","eng",&charset[0],0,
+#ifdef LANG_ENGLISH
+LANG_ENGLISH,
+#else
+0,
+#endif
+0,0,
+},
+{"eo","esperanto",0,&charset[0],0,
+#ifdef LANG_ESPERANTO
+LANG_ESPERANTO,
+#else
+0,
+#endif
+0,0,
+},
+{"es","spanish","spa",&charset[0],0,
+#ifdef LANG_SPANISH
+LANG_SPANISH,
+#else
+0,
+#endif
+&attribute_es[0],&attribute_es[1],
+},
+{"et","estonian","est",&charset[2],0,
+#ifdef LANG_ESTONIAN
+LANG_ESTONIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"eu","basque","eus|baq",&charset[0],0,
+#ifdef LANG_BASQUE
+LANG_BASQUE,
+#else
+0,
+#endif
+0,0,
+},
+{"fa","persian",0,&charset[0],0,
+#ifdef LANG_PERSIAN
+LANG_PERSIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"fi","finnish","fin",&charset[0],0,
+#ifdef LANG_FINNISH
+LANG_FINNISH,
+#else
+0,
+#endif
+0,0,
+},
+{"fj","fiji",0,&charset[0],0,
+#ifdef LANG_FIJI
+LANG_FIJI,
+#else
+0,
+#endif
+0,0,
+},
+{"fo","faeroese",0,&charset[0],0,
+#ifdef LANG_FAEROESE
+LANG_FAEROESE,
+#else
+0,
+#endif
+0,0,
+},
+{"fr","french","fra|fre",&charset[0],0,
+#ifdef LANG_FRENCH
+LANG_FRENCH,
+#else
+0,
+#endif
+0,0,
+},
+{"fy","frisian",0,&charset[0],0,
+#ifdef LANG_FRISIAN
+LANG_FRISIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ga","irish",0,&charset[11],0,
+#ifdef LANG_IRISH
+LANG_IRISH,
+#else
+0,
+#endif
+0,0,
+},
+{"gd","scots-gaelic",0,&charset[11],0,
+#ifdef LANG_SCOTS_GAELIC
+LANG_SCOTS_GAELIC,
+#else
+0,
+#endif
+0,0,
+},
+{"gl","galician",0,&charset[0],0,
+#ifdef LANG_GALICIAN
+LANG_GALICIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"gn","guarani",0,&charset[0],0,
+#ifdef LANG_GUARANI
+LANG_GUARANI,
+#else
+0,
+#endif
+0,0,
+},
+{"gu","gujarati",0,&charset[0],0,
+#ifdef LANG_GUJARATI
+LANG_GUJARATI,
+#else
+0,
+#endif
+0,0,
+},
+{"ha","hausa",0,&charset[0],0,
+#ifdef LANG_HAUSA
+LANG_HAUSA,
+#else
+0,
+#endif
+0,0,
+},
+{"he","hebrew","heb",&charset[7],0,
+#ifdef LANG_HEBREW
+LANG_HEBREW,
+#else
+0,
+#endif
+0,0,
+},
+{"hi","hindi",0,&charset[0],0,
+#ifdef LANG_HINDI
+LANG_HINDI,
+#else
+0,
+#endif
+0,0,
+},
+{"hr","croatian","hrv|scr",&charset[1],0,
+#ifdef LANG_CROATIAN
+LANG_CROATIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"hu","hungarian","hun",&charset[1],0,
+#ifdef LANG_HUNGARIAN
+LANG_HUNGARIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"hy","armenian",0,&charset[0],0,
+#ifdef LANG_ARMENIAN
+LANG_ARMENIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ia","interlingua",0,&charset[0],0,
+#ifdef LANG_INTERLINGUA
+LANG_INTERLINGUA,
+#else
+0,
+#endif
+0,0,
+},
+{"id","indonesian","ind",&charset[0],0,
+#ifdef LANG_INDONESIAN
+LANG_INDONESIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ie","interlingue",0,&charset[0],0,
+#ifdef LANG_INTERLINGUE
+LANG_INTERLINGUE,
+#else
+0,
+#endif
+0,0,
+},
+{"ik","inupiak",0,&charset[0],0,
+#ifdef LANG_INUPIAK
+LANG_INUPIAK,
+#else
+0,
+#endif
+0,0,
+},
+{"in","indonesian",0,&charset[0],0,
+#ifdef LANG_INDONESIAN
+LANG_INDONESIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"is","icelandic","isl|ice",&charset[0],0,
+#ifdef LANG_ICELANDIC
+LANG_ICELANDIC,
+#else
+0,
+#endif
+0,0,
+},
+{"it","italian","ita",&charset[0],0,
+#ifdef LANG_ITALIAN
+LANG_ITALIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"iw","hebrew",0,&charset[0],0,
+#ifdef LANG_HEBREW
+LANG_HEBREW,
+#else
+0,
+#endif
+0,0,
+},
+{"ja","japanese","jpn",&charset[0],0,
+#ifdef LANG_JAPANESE
+LANG_JAPANESE,
+#else
+0,
+#endif
+0,0,
+},
+{"ji","yiddish",0,&charset[0],0,
+#ifdef LANG_YIDDISH
+LANG_YIDDISH,
+#else
+0,
+#endif
+0,0,
+},
+{"jw","javanese",0,&charset[0],0,
+#ifdef LANG_JAVANESE
+LANG_JAVANESE,
+#else
+0,
+#endif
+0,0,
+},
+{"ka","georgian",0,&charset[0],0,
+#ifdef LANG_GEORGIAN
+LANG_GEORGIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"kk","kazakh","kaz",&charset[0],0,
+#ifdef LANG_KAZAKH
+LANG_KAZAKH,
+#else
+0,
+#endif
+0,0,
+},
+{"kl","greenlandic",0,&charset[0],0,
+#ifdef LANG_GREENLANDIC
+LANG_GREENLANDIC,
+#else
+0,
+#endif
+0,0,
+},
+{"km","cambodian",0,&charset[0],0,
+#ifdef LANG_CAMBODIAN
+LANG_CAMBODIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"kn","kannada",0,&charset[0],0,
+#ifdef LANG_KANNADA
+LANG_KANNADA,
+#else
+0,
+#endif
+0,0,
+},
+{"ko","korean","kor",&charset[0],0,
+#ifdef LANG_KOREAN
+LANG_KOREAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ks","kashmiri",0,&charset[0],0,
+#ifdef LANG_KASHMIRI
+LANG_KASHMIRI,
+#else
+0,
+#endif
+0,0,
+},
+{"ku","kurdish",0,&charset[0],0,
+#ifdef LANG_KURDISH
+LANG_KURDISH,
+#else
+0,
+#endif
+0,0,
+},
+{"ky","kirghiz",0,&charset[0],0,
+#ifdef LANG_KIRGHIZ
+LANG_KIRGHIZ,
+#else
+0,
+#endif
+0,0,
+},
+{"la","latin",0,&charset[0],0,
+#ifdef LANG_LATIN
+LANG_LATIN,
+#else
+0,
+#endif
+0,0,
+},
+{"ln","lingala",0,&charset[0],0,
+#ifdef LANG_LINGALA
+LANG_LINGALA,
+#else
+0,
+#endif
+0,0,
+},
+{"lo","laothian",0,&charset[0],0,
+#ifdef LANG_LAOTHIAN
+LANG_LAOTHIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"lt","lithuanian","lit",&charset[10],0,
+#ifdef LANG_LITHUANIAN
+LANG_LITHUANIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"lv","latvian","lav",&charset[10],0,
+#ifdef LANG_LATVIAN
+LANG_LATVIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"mg","malagasy",0,&charset[0],0,
+#ifdef LANG_MALAGASY
+LANG_MALAGASY,
+#else
+0,
+#endif
+0,0,
+},
+{"mi","maori",0,&charset[0],0,
+#ifdef LANG_MAORI
+LANG_MAORI,
+#else
+0,
+#endif
+0,0,
+},
+{"mk","macedonian","mkd|mac",&charset[0],0,
+#ifdef LANG_MACEDONIAN
+LANG_MACEDONIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ml","malayalam","mal",&charset[0],0,
+#ifdef LANG_MALAYALAM
+LANG_MALAYALAM,
+#else
+0,
+#endif
+0,0,
+},
+{"mn","mongolian",0,&charset[0],0,
+#ifdef LANG_MONGOLIAN
+LANG_MONGOLIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"mo","moldavian",0,&charset[0],0,
+#ifdef LANG_MOLDAVIAN
+LANG_MOLDAVIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"mr","marathi",0,&charset[0],0,
+#ifdef LANG_MARATHI
+LANG_MARATHI,
+#else
+0,
+#endif
+0,0,
+},
+{"ms","malay","msa|may",&charset[0],0,
+#ifdef LANG_MALAY
+LANG_MALAY,
+#else
+0,
+#endif
+0,0,
+},
+{"mt","maltese",0,&charset[0],0,
+#ifdef LANG_MALTESE
+LANG_MALTESE,
+#else
+0,
+#endif
+0,0,
+},
+{"my","burmese",0,&charset[0],0,
+#ifdef LANG_BURMESE
+LANG_BURMESE,
+#else
+0,
+#endif
+0,0,
+},
+{"na","nauru",0,&charset[0],0,
+#ifdef LANG_NAURU
+LANG_NAURU,
+#else
+0,
+#endif
+0,0,
+},
+{"nb","norwegian-bokmal","nob",&charset[0],0,
+#ifdef LANG_NORWEGIAN_BOKMAL
+LANG_NORWEGIAN_BOKMAL,
+#else
+0,
+#endif
+0,0,
+},
+{"ne","nepali",0,&charset[0],0,
+#ifdef LANG_NEPALI
+LANG_NEPALI,
+#else
+0,
+#endif
+0,0,
+},
+{"nl","dutch","nld|dut",&charset[0],0,
+#ifdef LANG_DUTCH
+LANG_DUTCH,
+#else
+0,
+#endif
+0,0,
+},
+{"nn","norwegian-nynorsk","nno|non",&charset[0],0,
+#ifdef LANG_NORWEGIAN_NYNORSK
+LANG_NORWEGIAN_NYNORSK,
+#else
+0,
+#endif
+0,0,
+},
+{"no","norwegian","nor",&charset[0],0,
+#ifdef LANG_NORWEGIAN
+LANG_NORWEGIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"oc","occitan",0,&charset[0],0,
+#ifdef LANG_OCCITAN
+LANG_OCCITAN,
+#else
+0,
+#endif
+0,0,
+},
+{"om","oromo",0,&charset[0],0,
+#ifdef LANG_OROMO
+LANG_OROMO,
+#else
+0,
+#endif
+0,0,
+},
+{"or","oriya",0,&charset[0],0,
+#ifdef LANG_ORIYA
+LANG_ORIYA,
+#else
+0,
+#endif
+0,0,
+},
+{"pa","punjabi",0,&charset[0],0,
+#ifdef LANG_PUNJABI
+LANG_PUNJABI,
+#else
+0,
+#endif
+0,0,
+},
+{"pl","polish","pol",&charset[1],0,
+#ifdef LANG_POLISH
+LANG_POLISH,
+#else
+0,
+#endif
+0,0,
+},
+{"ps","pushto",0,&charset[0],0,
+#ifdef LANG_PUSHTO
+LANG_PUSHTO,
+#else
+0,
+#endif
+0,0,
+},
+{"pt","portuguese","por",&charset[0],0,
+#ifdef LANG_PORTUGUESE
+LANG_PORTUGUESE,
+#else
+0,
+#endif
+0,0,
+},
+{"qu","quechua",0,&charset[0],0,
+#ifdef LANG_QUECHUA
+LANG_QUECHUA,
+#else
+0,
+#endif
+0,0,
+},
+{"rm","rhaeto-romance",0,&charset[0],0,
+#ifdef LANG_RHAETO_ROMANCE
+LANG_RHAETO_ROMANCE,
+#else
+0,
+#endif
+0,0,
+},
+{"rn","kirundi",0,&charset[0],0,
+#ifdef LANG_KIRUNDI
+LANG_KIRUNDI,
+#else
+0,
+#endif
+0,0,
+},
+{"ro","romanian","ron|rum",&charset[1],0,
+#ifdef LANG_ROMANIAN
+LANG_ROMANIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ru","russian","rus",&charset[4],0,
+#ifdef LANG_RUSSIAN
+LANG_RUSSIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"rw","kinyarwanda",0,&charset[0],0,
+#ifdef LANG_KINYARWANDA
+LANG_KINYARWANDA,
+#else
+0,
+#endif
+0,0,
+},
+{"sa","sanskrit",0,&charset[0],0,
+#ifdef LANG_SANSKRIT
+LANG_SANSKRIT,
+#else
+0,
+#endif
+0,0,
+},
+{"sd","sindhi",0,&charset[0],0,
+#ifdef LANG_SINDHI
+LANG_SINDHI,
+#else
+0,
+#endif
+0,0,
+},
+{"sg","sangro",0,&charset[0],0,
+#ifdef LANG_SANGRO
+LANG_SANGRO,
+#else
+0,
+#endif
+0,0,
+},
+{"sh","serbo-croatian",0,&charset[0],0,
+#ifdef LANG_SERBO_CROATIAN
+LANG_SERBO_CROATIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"si","singhalese",0,&charset[0],0,
+#ifdef LANG_SINGHALESE
+LANG_SINGHALESE,
+#else
+0,
+#endif
+0,0,
+},
+{"sk","slovak","slk|slo",&charset[1],0,
+#ifdef LANG_SLOVAK
+LANG_SLOVAK,
+#else
+0,
+#endif
+0,0,
+},
+{"sl","slovenian","slv",&charset[1],0,
+#ifdef LANG_SLOVENIAN
+LANG_SLOVENIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"sm","samoan",0,&charset[0],0,
+#ifdef LANG_SAMOAN
+LANG_SAMOAN,
+#else
+0,
+#endif
+0,0,
+},
+{"sn","shona",0,&charset[0],0,
+#ifdef LANG_SHONA
+LANG_SHONA,
+#else
+0,
+#endif
+0,0,
+},
+{"so","somali",0,&charset[0],0,
+#ifdef LANG_SOMALI
+LANG_SOMALI,
+#else
+0,
+#endif
+0,0,
+},
+{"sq","albanian","sqi|alb",&charset[0],0,
+#ifdef LANG_ALBANIAN
+LANG_ALBANIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"sr","serbian","srp",&charset[1],0,
+#ifdef LANG_SERBIAN
+LANG_SERBIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ss","siswati",0,&charset[0],0,
+#ifdef LANG_SISWATI
+LANG_SISWATI,
+#else
+0,
+#endif
+0,0,
+},
+{"st","sesotho",0,&charset[0],0,
+#ifdef LANG_SESOTHO
+LANG_SESOTHO,
+#else
+0,
+#endif
+0,0,
+},
+{"su","sudanese",0,&charset[0],0,
+#ifdef LANG_SUDANESE
+LANG_SUDANESE,
+#else
+0,
+#endif
+0,0,
+},
+{"sv","swedish","swe",&charset[0],0,
+#ifdef LANG_SWEDISH
+LANG_SWEDISH,
+#else
+0,
+#endif
+0,0,
+},
+{"sw","swahili","swa",&charset[0],0,
+#ifdef LANG_SWAHILI
+LANG_SWAHILI,
+#else
+0,
+#endif
+0,0,
+},
+{"ta","tamil",0,&charset[0],0,
+#ifdef LANG_TAMIL
+LANG_TAMIL,
+#else
+0,
+#endif
+0,0,
+},
+{"te","telugu",0,&charset[0],0,
+#ifdef LANG_TELUGU
+LANG_TELUGU,
+#else
+0,
+#endif
+0,0,
+},
+{"tg","tajik",0,&charset[0],0,
+#ifdef LANG_TAJIK
+LANG_TAJIK,
+#else
+0,
+#endif
+0,0,
+},
+{"th","thai","tha",&charset[0],0,
+#ifdef LANG_THAI
+LANG_THAI,
+#else
+0,
+#endif
+0,0,
+},
+{"ti","tigrinya",0,&charset[0],0,
+#ifdef LANG_TIGRINYA
+LANG_TIGRINYA,
+#else
+0,
+#endif
+0,0,
+},
+{"tk","turkmen",0,&charset[0],0,
+#ifdef LANG_TURKMEN
+LANG_TURKMEN,
+#else
+0,
+#endif
+0,0,
+},
+{"tl","tagalog",0,&charset[0],0,
+#ifdef LANG_TAGALOG
+LANG_TAGALOG,
+#else
+0,
+#endif
+0,0,
+},
+{"tn","setswana",0,&charset[0],0,
+#ifdef LANG_SETSWANA
+LANG_SETSWANA,
+#else
+0,
+#endif
+0,0,
+},
+{"to","tonga",0,&charset[0],0,
+#ifdef LANG_TONGA
+LANG_TONGA,
+#else
+0,
+#endif
+0,0,
+},
+{"tr","turkish","tur",&charset[8],0,
+#ifdef LANG_TURKISH
+LANG_TURKISH,
+#else
+0,
+#endif
+0,0,
+},
+{"ts","tsonga",0,&charset[0],0,
+#ifdef LANG_TSONGA
+LANG_TSONGA,
+#else
+0,
+#endif
+0,0,
+},
+{"tt","tatar","tat",&charset[0],0,
+#ifdef LANG_TATAR
+LANG_TATAR,
+#else
+0,
+#endif
+0,0,
+},
+{"tw","chinese-traditional","cht",&charset[0],0,
+#ifdef LANG_CHINESE_TRADITIONAL
+LANG_CHINESE_TRADITIONAL,
+#else
+0,
+#endif
+0,0,
+},
+{"uk","ukrainian","ukr",&charset[4],0,
+#ifdef LANG_UKRAINIAN
+LANG_UKRAINIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ur","urdu",0,&charset[0],0,
+#ifdef LANG_URDU
+LANG_URDU,
+#else
+0,
+#endif
+0,0,
+},
+{"uz","uzbek","uzb",&charset[0],0,
+#ifdef LANG_UZBEK
+LANG_UZBEK,
+#else
+0,
+#endif
+0,0,
+},
+{"vi","vietnamese",0,&charset[0],0,
+#ifdef LANG_VIETNAMESE
+LANG_VIETNAMESE,
+#else
+0,
+#endif
+0,0,
+},
+{"vo","volapuk",0,&charset[0],0,
+#ifdef LANG_VOLAPUK
+LANG_VOLAPUK,
+#else
+0,
+#endif
+0,0,
+},
+{"wo","wolof",0,&charset[0],0,
+#ifdef LANG_WOLOF
+LANG_WOLOF,
+#else
+0,
+#endif
+0,0,
+},
+{"xh","xhosa",0,&charset[0],0,
+#ifdef LANG_XHOSA
+LANG_XHOSA,
+#else
+0,
+#endif
+0,0,
+},
+{"yo","yoruba",0,&charset[0],0,
+#ifdef LANG_YORUBA
+LANG_YORUBA,
+#else
+0,
+#endif
+0,0,
+},
+{"zh","chinese-simplified","zho|chi|chs",&charset[0],0,
+#ifdef LANG_CHINESE_SIMPLIFIED
+LANG_CHINESE_SIMPLIFIED,
+#else
+0,
+#endif
+0,0,
+},
+{"zu","zulu",0,&charset[0],0,
+#ifdef LANG_ZULU
+LANG_ZULU,
+#else
+0,
+#endif
+0,0,
+},
+ 0
+};
+
+static const Lc_territory_t territory[] =
+{
+{"C","C",LC_default,0,&language[0],0,0,0,0,0,0,0,},
+{"debug","debug",LC_debug,0,&language[1],0,0,0,0,0,0,0,},
+{"al","albania",0,
+#ifdef CTRY_ALBANIA
+CTRY_ALBANIA,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"an","netherlands-antilles",0,
+#ifdef CTRY_NETHERLANDS_ANTILLES
+CTRY_NETHERLANDS_ANTILLES,
+#else
+0,
+#endif
+&language[86],0,0,0,
+#ifdef SUBLANG_DUTCH_NETHERLANDS_ANTILLES
+SUBLANG_DUTCH_NETHERLANDS_ANTILLES,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ar","argentina",0,
+#ifdef CTRY_ARGENTINA
+CTRY_ARGENTINA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_ARGENTINA
+SUBLANG_SPANISH_ARGENTINA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"at","austria",0,
+#ifdef CTRY_AUSTRIA
+CTRY_AUSTRIA,
+#else
+0,
+#endif
+&language[23],0,0,0,
+#ifdef SUBLANG_GERMAN_AUSTRIA
+SUBLANG_GERMAN_AUSTRIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"au","australia",0,
+#ifdef CTRY_AUSTRALIA
+CTRY_AUSTRALIA,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_AUSTRALIA
+SUBLANG_ENGLISH_AUSTRALIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"az","azerbaijan",0,
+#ifdef CTRY_AZERBAIJAN
+CTRY_AZERBAIJAN,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"be","belgium",0,
+#ifdef CTRY_BELGIUM
+CTRY_BELGIUM,
+#else
+0,
+#endif
+&language[86],&language[35],&language[23],0,
+#ifdef SUBLANG_DUTCH_BELGIUM
+SUBLANG_DUTCH_BELGIUM,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_FRENCH_BELGIUM
+SUBLANG_FRENCH_BELGIUM,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_GERMAN_BELGIUM
+SUBLANG_GERMAN_BELGIUM,
+#else
+0,
+#endif
+0,
+},
+{"bg","bulgaria",0,
+#ifdef CTRY_BULGARIA
+CTRY_BULGARIA,
+#else
+0,
+#endif
+&language[12],0,0,0,
+#ifdef SUBLANG_BULGARIAN_BULGARIA
+SUBLANG_BULGARIAN_BULGARIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"bn","brunei-darussalam",0,
+#ifdef CTRY_BRUNEI_DARUSSALAM
+CTRY_BRUNEI_DARUSSALAM,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_BRUNEI_DARUSSALAM
+SUBLANG_ARABIC_BRUNEI_DARUSSALAM,
+#else
+0,
+#endif
+0,0,0,
+},
+{"bo","bolivia",0,
+#ifdef CTRY_BOLIVIA
+CTRY_BOLIVIA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_BOLIVIA
+SUBLANG_SPANISH_BOLIVIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"br","brazil",0,
+#ifdef CTRY_BRAZIL
+CTRY_BRAZIL,
+#else
+0,
+#endif
+&language[95],0,0,0,
+#ifdef SUBLANG_PORTUGUESE_BRAZIL
+SUBLANG_PORTUGUESE_BRAZIL,
+#else
+0,
+#endif
+0,0,0,
+},
+{"bw","botswana",0,
+#ifdef CTRY_BOTSWANA
+CTRY_BOTSWANA,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_BOTSWANA
+SUBLANG_ENGLISH_BOTSWANA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"by","belarus",0,
+#ifdef CTRY_BELARUS
+CTRY_BELARUS,
+#else
+0,
+#endif
+&language[100],0,0,0,
+#ifdef SUBLANG_RUSSIAN_BELARUS
+SUBLANG_RUSSIAN_BELARUS,
+#else
+0,
+#endif
+0,0,0,
+},
+{"bz","belize",0,
+#ifdef CTRY_BELIZE
+CTRY_BELIZE,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_BELIZE
+SUBLANG_ENGLISH_BELIZE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ca","canada",0,
+#ifdef CTRY_CANADA
+CTRY_CANADA,
+#else
+0,
+#endif
+&language[26],&language[35],0,0,
+#ifdef SUBLANG_ENGLISH_CANADA
+SUBLANG_ENGLISH_CANADA,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_FRENCH_CANADA
+SUBLANG_FRENCH_CANADA,
+#else
+0,
+#endif
+0,0,
+},
+{"ch","switzerland",0,
+#ifdef CTRY_SWITZERLAND
+CTRY_SWITZERLAND,
+#else
+0,
+#endif
+&language[35],&language[23],&language[54],0,
+#ifdef SUBLANG_FRENCH_SWITZERLAND
+SUBLANG_FRENCH_SWITZERLAND,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_GERMAN_SWITZERLAND
+SUBLANG_GERMAN_SWITZERLAND,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_ITALIAN_SWITZERLAND
+SUBLANG_ITALIAN_SWITZERLAND,
+#else
+0,
+#endif
+0,
+},
+{"cl","chile",0,
+#ifdef CTRY_CHILE
+CTRY_CHILE,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_CHILE
+SUBLANG_SPANISH_CHILE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"cn","china",LC_primary,
+#ifdef CTRY_CHINA
+CTRY_CHINA,
+#else
+0,
+#endif
+&language[140],0,0,0,
+#ifdef SUBLANG_CHINESE_SIMPLIFIED_CHINA
+SUBLANG_CHINESE_SIMPLIFIED_CHINA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"co","colombia",0,
+#ifdef CTRY_COLOMBIA
+CTRY_COLOMBIA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_COLOMBIA
+SUBLANG_SPANISH_COLOMBIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"cr","costa-rica",0,
+#ifdef CTRY_COSTA_RICA
+CTRY_COSTA_RICA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_COSTA_RICA
+SUBLANG_SPANISH_COSTA_RICA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"cz","czech-republic",0,
+#ifdef CTRY_CZECH_REPUBLIC
+CTRY_CZECH_REPUBLIC,
+#else
+0,
+#endif
+&language[20],0,0,0,
+#ifdef SUBLANG_CZECH_CZECH_REPUBLIC
+SUBLANG_CZECH_CZECH_REPUBLIC,
+#else
+0,
+#endif
+0,0,0,
+},
+{"de","germany",0,
+#ifdef CTRY_GERMANY
+CTRY_GERMANY,
+#else
+0,
+#endif
+&language[23],0,0,0,
+#ifdef SUBLANG_GERMAN_GERMANY
+SUBLANG_GERMAN_GERMANY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"dk","denmark",0,
+#ifdef CTRY_DENMARK
+CTRY_DENMARK,
+#else
+0,
+#endif
+&language[22],&language[26],0,0,
+#ifdef SUBLANG_DANISH_DENMARK
+SUBLANG_DANISH_DENMARK,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_ENGLISH_DENMARK
+SUBLANG_ENGLISH_DENMARK,
+#else
+0,
+#endif
+0,0,
+},
+{"do","dominican-republic",0,
+#ifdef CTRY_DOMINICAN_REPUBLIC
+CTRY_DOMINICAN_REPUBLIC,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
+SUBLANG_SPANISH_DOMINICAN_REPUBLIC,
+#else
+0,
+#endif
+0,0,0,
+},
+{"dz","algeria",0,
+#ifdef CTRY_ALGERIA
+CTRY_ALGERIA,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"ec","ecuador",0,
+#ifdef CTRY_ECUADOR
+CTRY_ECUADOR,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_ECUADOR
+SUBLANG_SPANISH_ECUADOR,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ee","estonia",0,
+#ifdef CTRY_ESTONIA
+CTRY_ESTONIA,
+#else
+0,
+#endif
+&language[29],0,0,0,
+#ifdef SUBLANG_ESTONIAN_ESTONIA
+SUBLANG_ESTONIAN_ESTONIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"eg","egypt",0,
+#ifdef CTRY_EGYPT
+CTRY_EGYPT,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_EGYPT
+SUBLANG_ARABIC_EGYPT,
+#else
+0,
+#endif
+0,0,0,
+},
+{"es","spain",0,
+#ifdef CTRY_SPAIN
+CTRY_SPAIN,
+#else
+0,
+#endif
+&language[28],&language[18],&language[30],&language[39],
+#ifdef SUBLANG_SPANISH_SPAIN
+SUBLANG_SPANISH_SPAIN,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_CATALAN_SPAIN
+SUBLANG_CATALAN_SPAIN,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_BASQUE_SPAIN
+SUBLANG_BASQUE_SPAIN,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_GALICIAN_SPAIN
+SUBLANG_GALICIAN_SPAIN,
+#else
+0,
+#endif
+
+},
+{"fi","finland",0,
+#ifdef CTRY_FINLAND
+CTRY_FINLAND,
+#else
+0,
+#endif
+&language[117],0,0,0,
+#ifdef SUBLANG_SWEDISH_FINLAND
+SUBLANG_SWEDISH_FINLAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"fo","faroe-islands",0,
+#ifdef CTRY_FAROE_ISLANDS
+CTRY_FAROE_ISLANDS,
+#else
+0,
+#endif
+&language[34],0,0,0,
+#ifdef SUBLANG_FAEROESE_FAROE_ISLANDS
+SUBLANG_FAEROESE_FAROE_ISLANDS,
+#else
+0,
+#endif
+0,0,0,
+},
+{"fr","france",0,
+#ifdef CTRY_FRANCE
+CTRY_FRANCE,
+#else
+0,
+#endif
+&language[35],0,0,0,
+#ifdef SUBLANG_FRENCH_FRANCE
+SUBLANG_FRENCH_FRANCE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"gb","united-kingdom|great-britain|england",LC_primary,
+#ifdef CTRY_UNITED_KINGDOM
+CTRY_UNITED_KINGDOM,
+#else
+#ifdef CTRY_GREAT_BRITAIN
+CTRY_GREAT_BRITAIN,
+#else
+#ifdef CTRY_ENGLAND
+CTRY_ENGLAND,
+#else
+0,
+#endif
+#endif
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_UNITED_KINGDOM
+SUBLANG_ENGLISH_UNITED_KINGDOM,
+#else
+#ifdef SUBLANG_ENGLISH_GREAT_BRITAIN
+SUBLANG_ENGLISH_GREAT_BRITAIN,
+#else
+#ifdef SUBLANG_ENGLISH_ENGLAND
+SUBLANG_ENGLISH_ENGLAND,
+#else
+0,
+#endif
+#endif
+#endif
+0,0,0,
+},
+{"gl","greenland",0,
+#ifdef CTRY_GREENLAND
+CTRY_GREENLAND,
+#else
+0,
+#endif
+&language[61],0,0,0,
+#ifdef SUBLANG_GREENLANDIC_GREENLAND
+SUBLANG_GREENLANDIC_GREENLAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"gr","greece",0,
+#ifdef CTRY_GREECE
+CTRY_GREECE,
+#else
+0,
+#endif
+&language[25],0,0,0,
+#ifdef SUBLANG_GREEK_GREECE
+SUBLANG_GREEK_GREECE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"gt","guatemala",0,
+#ifdef CTRY_GUATEMALA
+CTRY_GUATEMALA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_GUATEMALA
+SUBLANG_SPANISH_GUATEMALA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"hk","hong-kong",0,
+#ifdef CTRY_HONG_KONG
+CTRY_HONG_KONG,
+#else
+0,
+#endif
+&language[140],0,0,0,
+#ifdef SUBLANG_CHINESE_SIMPLIFIED_HONG_KONG
+SUBLANG_CHINESE_SIMPLIFIED_HONG_KONG,
+#else
+0,
+#endif
+0,0,0,
+},
+{"hn","honduras",0,
+#ifdef CTRY_HONDURAS
+CTRY_HONDURAS,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_HONDURAS
+SUBLANG_SPANISH_HONDURAS,
+#else
+0,
+#endif
+0,0,0,
+},
+{"hr","croatia",0,
+#ifdef CTRY_CROATIA
+CTRY_CROATIA,
+#else
+0,
+#endif
+&language[45],0,0,0,
+#ifdef SUBLANG_CROATIAN_CROATIA
+SUBLANG_CROATIAN_CROATIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"hu","hungary",0,
+#ifdef CTRY_HUNGARY
+CTRY_HUNGARY,
+#else
+0,
+#endif
+&language[46],0,0,0,
+#ifdef SUBLANG_HUNGARIAN_HUNGARY
+SUBLANG_HUNGARIAN_HUNGARY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"id","indonesia",0,
+#ifdef CTRY_INDONESIA
+CTRY_INDONESIA,
+#else
+0,
+#endif
+&language[49],0,0,0,
+#ifdef SUBLANG_INDONESIAN_INDONESIA
+SUBLANG_INDONESIAN_INDONESIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ie","ireland",0,
+#ifdef CTRY_IRELAND
+CTRY_IRELAND,
+#else
+0,
+#endif
+&language[26],&language[37],0,0,
+#ifdef SUBLANG_ENGLISH_IRELAND
+SUBLANG_ENGLISH_IRELAND,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_IRISH_IRELAND
+SUBLANG_IRISH_IRELAND,
+#else
+0,
+#endif
+0,0,
+},
+{"il","israel",0,
+#ifdef CTRY_ISRAEL
+CTRY_ISRAEL,
+#else
+0,
+#endif
+&language[43],0,0,0,
+#ifdef SUBLANG_HEBREW_ISRAEL
+SUBLANG_HEBREW_ISRAEL,
+#else
+0,
+#endif
+0,0,0,
+},
+{"iq","iraq",0,
+#ifdef CTRY_IRAQ
+CTRY_IRAQ,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_IRAQ
+SUBLANG_ARABIC_IRAQ,
+#else
+0,
+#endif
+0,0,0,
+},
+{"is","iceland",0,
+#ifdef CTRY_ICELAND
+CTRY_ICELAND,
+#else
+0,
+#endif
+&language[53],0,0,0,
+#ifdef SUBLANG_ICELANDIC_ICELAND
+SUBLANG_ICELANDIC_ICELAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"it","italy",0,
+#ifdef CTRY_ITALY
+CTRY_ITALY,
+#else
+0,
+#endif
+&language[54],0,0,0,
+#ifdef SUBLANG_ITALIAN_ITALY
+SUBLANG_ITALIAN_ITALY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"jm","jamaica",0,
+#ifdef CTRY_JAMAICA
+CTRY_JAMAICA,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_JAMAICA
+SUBLANG_ENGLISH_JAMAICA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"jo","jordan",0,
+#ifdef CTRY_JORDAN
+CTRY_JORDAN,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_JORDAN
+SUBLANG_ARABIC_JORDAN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"jp","japan",0,
+#ifdef CTRY_JAPAN
+CTRY_JAPAN,
+#else
+0,
+#endif
+&language[56],0,0,0,
+#ifdef SUBLANG_JAPANESE_JAPAN
+SUBLANG_JAPANESE_JAPAN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ke","kenya",0,
+#ifdef CTRY_KENYA
+CTRY_KENYA,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"kr","south-korea",0,
+#ifdef CTRY_SOUTH_KOREA
+CTRY_SOUTH_KOREA,
+#else
+0,
+#endif
+&language[64],0,0,0,
+#ifdef SUBLANG_KOREAN_SOUTH_KOREA
+SUBLANG_KOREAN_SOUTH_KOREA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"kw","kuwait",0,
+#ifdef CTRY_KUWAIT
+CTRY_KUWAIT,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_KUWAIT
+SUBLANG_ARABIC_KUWAIT,
+#else
+0,
+#endif
+0,0,0,
+},
+{"lb","lebanon",0,
+#ifdef CTRY_LEBANON
+CTRY_LEBANON,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_LEBANON
+SUBLANG_ARABIC_LEBANON,
+#else
+0,
+#endif
+0,0,0,
+},
+{"li","liechtenstein",0,
+#ifdef CTRY_LIECHTENSTEIN
+CTRY_LIECHTENSTEIN,
+#else
+0,
+#endif
+&language[23],&language[35],0,0,
+#ifdef SUBLANG_GERMAN_LIECHTENSTEIN
+SUBLANG_GERMAN_LIECHTENSTEIN,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_FRENCH_LIECHTENSTEIN
+SUBLANG_FRENCH_LIECHTENSTEIN,
+#else
+0,
+#endif
+0,0,
+},
+{"lt","lithuania",0,
+#ifdef CTRY_LITHUANIA
+CTRY_LITHUANIA,
+#else
+0,
+#endif
+&language[71],0,0,0,
+#ifdef SUBLANG_LITHUANIAN_LITHUANIA
+SUBLANG_LITHUANIAN_LITHUANIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"lu","luxembourg",0,
+#ifdef CTRY_LUXEMBOURG
+CTRY_LUXEMBOURG,
+#else
+0,
+#endif
+&language[23],&language[35],0,0,
+#ifdef SUBLANG_GERMAN_LUXEMBOURG
+SUBLANG_GERMAN_LUXEMBOURG,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_FRENCH_LUXEMBOURG
+SUBLANG_FRENCH_LUXEMBOURG,
+#else
+0,
+#endif
+0,0,
+},
+{"lv","latvia",0,
+#ifdef CTRY_LATVIA
+CTRY_LATVIA,
+#else
+0,
+#endif
+&language[72],0,0,0,
+#ifdef SUBLANG_LATVIAN_LATVIA
+SUBLANG_LATVIAN_LATVIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ly","libya",0,
+#ifdef CTRY_LIBYA
+CTRY_LIBYA,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_LIBYA
+SUBLANG_ARABIC_LIBYA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ma","morocco",0,
+#ifdef CTRY_MOROCCO
+CTRY_MOROCCO,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_MOROCCO
+SUBLANG_ARABIC_MOROCCO,
+#else
+0,
+#endif
+0,0,0,
+},
+{"mk","macedonia",0,
+#ifdef CTRY_MACEDONIA
+CTRY_MACEDONIA,
+#else
+0,
+#endif
+&language[75],0,0,0,
+#ifdef SUBLANG_MACEDONIAN_MACEDONIA
+SUBLANG_MACEDONIAN_MACEDONIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"mo","macau",0,
+#ifdef CTRY_MACAU
+CTRY_MACAU,
+#else
+0,
+#endif
+&language[140],0,0,0,
+#ifdef SUBLANG_CHINESE_SIMPLIFIED_MACAU
+SUBLANG_CHINESE_SIMPLIFIED_MACAU,
+#else
+0,
+#endif
+0,0,0,
+},
+{"mx","mexico",0,
+#ifdef CTRY_MEXICO
+CTRY_MEXICO,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_MEXICO
+SUBLANG_SPANISH_MEXICO,
+#else
+0,
+#endif
+0,0,0,
+},
+{"my","malaysia",0,
+#ifdef CTRY_MALAYSIA
+CTRY_MALAYSIA,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"ni","nicaragua",0,
+#ifdef CTRY_NICARAGUA
+CTRY_NICARAGUA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_NICARAGUA
+SUBLANG_SPANISH_NICARAGUA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"nl","netherlands",0,
+#ifdef CTRY_NETHERLANDS
+CTRY_NETHERLANDS,
+#else
+0,
+#endif
+&language[86],0,0,0,
+#ifdef SUBLANG_DUTCH_NETHERLANDS
+SUBLANG_DUTCH_NETHERLANDS,
+#else
+0,
+#endif
+0,0,0,
+},
+{"no","norway",0,
+#ifdef CTRY_NORWAY
+CTRY_NORWAY,
+#else
+0,
+#endif
+&language[84],&language[88],&language[87],0,
+#ifdef SUBLANG_NORWEGIAN_BOKMAL_NORWAY
+SUBLANG_NORWEGIAN_BOKMAL_NORWAY,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_NORWEGIAN_NORWAY
+SUBLANG_NORWEGIAN_NORWAY,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_NORWEGIAN_NYNORSK_NORWAY
+SUBLANG_NORWEGIAN_NYNORSK_NORWAY,
+#else
+0,
+#endif
+0,
+},
+{"nz","new-zealand",0,
+#ifdef CTRY_NEW_ZEALAND
+CTRY_NEW_ZEALAND,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_NEW_ZEALAND
+SUBLANG_ENGLISH_NEW_ZEALAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"om","oman",0,
+#ifdef CTRY_OMAN
+CTRY_OMAN,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_OMAN
+SUBLANG_ARABIC_OMAN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pa","panama",0,
+#ifdef CTRY_PANAMA
+CTRY_PANAMA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_PANAMA
+SUBLANG_SPANISH_PANAMA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pe","peru",0,
+#ifdef CTRY_PERU
+CTRY_PERU,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_PERU
+SUBLANG_SPANISH_PERU,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pl","poland",0,
+#ifdef CTRY_POLAND
+CTRY_POLAND,
+#else
+0,
+#endif
+&language[93],0,0,0,
+#ifdef SUBLANG_POLISH_POLAND
+SUBLANG_POLISH_POLAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pr","puerto-rico",0,
+#ifdef CTRY_PUERTO_RICO
+CTRY_PUERTO_RICO,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_PUERTO_RICO
+SUBLANG_SPANISH_PUERTO_RICO,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pt","portugal",0,
+#ifdef CTRY_PORTUGAL
+CTRY_PORTUGAL,
+#else
+0,
+#endif
+&language[95],0,0,0,
+#ifdef SUBLANG_PORTUGUESE_PORTUGAL
+SUBLANG_PORTUGUESE_PORTUGAL,
+#else
+0,
+#endif
+0,0,0,
+},
+{"py","paraguay",0,
+#ifdef CTRY_PARAGUAY
+CTRY_PARAGUAY,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_PARAGUAY
+SUBLANG_SPANISH_PARAGUAY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ro","romania",0,
+#ifdef CTRY_ROMANIA
+CTRY_ROMANIA,
+#else
+0,
+#endif
+&language[99],0,0,0,
+#ifdef SUBLANG_ROMANIAN_ROMANIA
+SUBLANG_ROMANIAN_ROMANIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ru","russia",0,
+#ifdef CTRY_RUSSIA
+CTRY_RUSSIA,
+#else
+0,
+#endif
+&language[100],0,0,0,
+#ifdef SUBLANG_RUSSIAN_RUSSIA
+SUBLANG_RUSSIAN_RUSSIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sa","saudi-arabia",0,
+#ifdef CTRY_SAUDI_ARABIA
+CTRY_SAUDI_ARABIA,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_SAUDI_ARABIA
+SUBLANG_ARABIC_SAUDI_ARABIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"se","sweden",LC_primary,
+#ifdef CTRY_SWEDEN
+CTRY_SWEDEN,
+#else
+0,
+#endif
+&language[117],0,0,0,
+#ifdef SUBLANG_SWEDISH_SWEDEN
+SUBLANG_SWEDISH_SWEDEN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sg","singapore",0,
+#ifdef CTRY_SINGAPORE
+CTRY_SINGAPORE,
+#else
+0,
+#endif
+&language[140],0,0,0,
+#ifdef SUBLANG_CHINESE_SIMPLIFIED_SINGAPORE
+SUBLANG_CHINESE_SIMPLIFIED_SINGAPORE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"si","slovenia",0,
+#ifdef CTRY_SLOVENIA
+CTRY_SLOVENIA,
+#else
+0,
+#endif
+&language[108],0,0,0,
+#ifdef SUBLANG_SLOVENIAN_SLOVENIA
+SUBLANG_SLOVENIAN_SLOVENIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sk","slovakia",0,
+#ifdef CTRY_SLOVAKIA
+CTRY_SLOVAKIA,
+#else
+0,
+#endif
+&language[107],0,0,0,
+#ifdef SUBLANG_SLOVAK_SLOVAKIA
+SUBLANG_SLOVAK_SLOVAKIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sp","serbia",0,
+#ifdef CTRY_SERBIA
+CTRY_SERBIA,
+#else
+0,
+#endif
+&language[113],0,0,0,
+#ifdef SUBLANG_SERBIAN_SERBIA
+SUBLANG_SERBIAN_SERBIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sv","el-salvador",0,
+#ifdef CTRY_EL_SALVADOR
+CTRY_EL_SALVADOR,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_EL_SALVADOR
+SUBLANG_SPANISH_EL_SALVADOR,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sy","syria",0,
+#ifdef CTRY_SYRIA
+CTRY_SYRIA,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_SYRIA
+SUBLANG_ARABIC_SYRIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"th","thailand",0,
+#ifdef CTRY_THAILAND
+CTRY_THAILAND,
+#else
+0,
+#endif
+&language[122],0,0,0,
+#ifdef SUBLANG_THAI_THAILAND
+SUBLANG_THAI_THAILAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"tn","tunisia",0,
+#ifdef CTRY_TUNISIA
+CTRY_TUNISIA,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_TUNISIA
+SUBLANG_ARABIC_TUNISIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"tr","turkey",0,
+#ifdef CTRY_TURKEY
+CTRY_TURKEY,
+#else
+0,
+#endif
+&language[128],0,0,0,
+#ifdef SUBLANG_TURKISH_TURKEY
+SUBLANG_TURKISH_TURKEY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"tt","trinidad&tobago",0,
+#ifdef CTRY_TRINIDAD_TOBAGO
+CTRY_TRINIDAD_TOBAGO,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_TRINIDAD_TOBAGO
+SUBLANG_ENGLISH_TRINIDAD_TOBAGO,
+#else
+0,
+#endif
+0,0,0,
+},
+{"tw","taiwan",0,
+#ifdef CTRY_TAIWAN
+CTRY_TAIWAN,
+#else
+0,
+#endif
+&language[131],0,0,0,
+#ifdef SUBLANG_CHINESE_TRADITIONAL_TAIWAN
+SUBLANG_CHINESE_TRADITIONAL_TAIWAN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ua","ukraine",0,
+#ifdef CTRY_UKRAINE
+CTRY_UKRAINE,
+#else
+0,
+#endif
+&language[132],&language[100],0,0,
+#ifdef SUBLANG_UKRAINIAN_UKRAINE
+SUBLANG_UKRAINIAN_UKRAINE,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_RUSSIAN_UKRAINE
+SUBLANG_RUSSIAN_UKRAINE,
+#else
+0,
+#endif
+0,0,
+},
+{"uk","united-kingdom",LC_primary,
+#ifdef CTRY_UNITED_KINGDOM
+CTRY_UNITED_KINGDOM,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_UNITED_KINGDOM
+SUBLANG_ENGLISH_UNITED_KINGDOM,
+#else
+0,
+#endif
+0,0,0,
+},
+{"us","united-states|usa",0,
+#ifdef CTRY_UNITED_STATES
+CTRY_UNITED_STATES,
+#else
+#ifdef CTRY_USA
+CTRY_USA,
+#else
+0,
+#endif
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_UNITED_STATES
+SUBLANG_ENGLISH_UNITED_STATES,
+#else
+#ifdef SUBLANG_ENGLISH_USA
+SUBLANG_ENGLISH_USA,
+#else
+0,
+#endif
+#endif
+0,0,0,
+},
+{"uy","uruguay",0,
+#ifdef CTRY_URUGUAY
+CTRY_URUGUAY,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_URUGUAY
+SUBLANG_SPANISH_URUGUAY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ve","venezuela",0,
+#ifdef CTRY_VENEZUELA
+CTRY_VENEZUELA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_VENEZUELA
+SUBLANG_SPANISH_VENEZUELA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"yu","yugoslavia",0,
+#ifdef CTRY_YUGOSLAVIA
+CTRY_YUGOSLAVIA,
+#else
+0,
+#endif
+&language[113],0,0,0,
+#ifdef SUBLANG_SERBIAN_YUGOSLAVIA
+SUBLANG_SERBIAN_YUGOSLAVIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"za","south-africa",0,
+#ifdef CTRY_SOUTH_AFRICA
+CTRY_SOUTH_AFRICA,
+#else
+0,
+#endif
+&language[4],0,0,0,
+#ifdef SUBLANG_AFRIKAANS_SOUTH_AFRICA
+SUBLANG_AFRIKAANS_SOUTH_AFRICA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"zw","zimbabwe",0,
+#ifdef CTRY_ZIMBABWE
+CTRY_ZIMBABWE,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_ZIMBABWE
+SUBLANG_ENGLISH_ZIMBABWE,
+#else
+0,
+#endif
+0,0,0,
+},
+ 0
+};
+
+static const Lc_map_t map[] =
+{
+{"enu",&language[26],&territory[93],&charset[0],0},
+{"enz",&language[26],&territory[68],&charset[0],0},
+{"esm",&language[28],&territory[63],&charset[0],0},
+{"esn",&language[28],&territory[30],&charset[0],&attribute_es[1]},
+{"esp",&language[28],&territory[30],&charset[0],&attribute_es[0]},
+{"usa",&language[26],&territory[93],&charset[0],0},
+ 0
+};
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/preroot.h b/usr/src/lib/libast/amd64/src/lib/libast/preroot.h
new file mode 100644
index 0000000000..ec3ecd3cfe
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/preroot.h
@@ -0,0 +1,6 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/preroot.sh by iffe version 2007-04-04 : : */
+#ifndef _def_preroot_ast
+#define _def_preroot_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* preroot not enabled */
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/sig.h b/usr/src/lib/libast/amd64/src/lib/libast/sig.h
new file mode 100644
index 0000000000..5edc503e1f
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/sig.h
@@ -0,0 +1,131 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/sig.sh by iffe version 2007-04-04 : : */
+#ifndef _def_sig_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_sig_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define sig_info _sig_info_
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide kill killpg
+#else
+#define kill ______kill
+#define killpg ______killpg
+#endif
+#include <signal.h>
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide kill killpg
+#else
+#undef kill
+#undef killpg
+#endif
+#ifndef sigmask
+#define sigmask(s) (1<<((s)-1))
+#endif
+typedef void (*Sig_handler_t) __PROTO__((int));
+
+
+#define Handler_t Sig_handler_t
+
+#define SIG_REG_PENDING (-1)
+#define SIG_REG_POP 0
+#define SIG_REG_EXEC 00001
+#define SIG_REG_PROC 00002
+#define SIG_REG_TERM 00004
+#define SIG_REG_ALL 00777
+#define SIG_REG_SET 01000
+
+typedef struct
+{
+ char** name;
+ char** text;
+ int sigmax;
+} Sig_info_t;
+
+extern __MANGLE__ int kill __PROTO__((pid_t, int));
+extern __MANGLE__ int killpg __PROTO__((pid_t, int));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Sig_info_t sig_info;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int sigcritical __PROTO__((int));
+extern __MANGLE__ int sigunblock __PROTO__((int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/tmx.h b/usr/src/lib/libast/amd64/src/lib/libast/tmx.h
new file mode 100644
index 0000000000..8034e1cd9e
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/tmx.h
@@ -0,0 +1,128 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/tmx by iffe version 2007-04-04 : : */
+
+#ifndef _TMX_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TMX_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Time_t support
+ */
+
+#include <tm.h>
+#include <tv.h>
+
+#define TMX_MAXDATE "2554-07-21+23:34:33.709551614 UTC"
+#define TMX_MAXYEAR 2554
+#define TMX_MAXSEC ((Time_t)18446744073)
+#define TMX_MAXNSEC 709551614
+#define TMX_RESOLUTION 1000000000
+
+typedef uint64_t Time_t;
+typedef uint64_t Tmxsec_t;
+typedef uint32_t Tmxnsec_t;
+
+#define tmxsec(t) ((Tmxsec_t)((t)/1000000000))
+#define tmxnsec(t) ((Tmxnsec_t)((t)%1000000000))
+#define tmxsns(s,n) (((((Time_t)(s))*1000000000))+((Time_t)(n)))
+
+#define TMX_NOTIME ((Time_t)(-1))
+#define TMX_NOW tmxgettime()
+#define TMX_MAXTIME tmxsns(TMX_MAXSEC,TMX_MAXNSEC)
+
+#define tmx2tv(t,v) ((v)->tv_nsec=tmxnsec(t),(v)->tv_sec=tmxsec(t))
+#define tv2tmx(v) tmxsns((v)->tv_sec,(v)->tv_nsec)
+
+#define tmxclock(p) tmxsns(((p)?*(p):time(NiL)),0)
+
+#define tmxgetatime(s) tmxsns((s)->st_atime,ST_ATIME_NSEC_GET(s))
+#define tmxgetctime(s) tmxsns((s)->st_ctime,ST_CTIME_NSEC_GET(s))
+#define tmxgetmtime(s) tmxsns((s)->st_mtime,ST_MTIME_NSEC_GET(s))
+
+#define tmxsetatime(s,t) ((s)->st_atime=tmxsec(t),ST_ATIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetctime(s,t) ((s)->st_ctime=tmxsec(t),ST_CTIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetmtime(s,t) ((s)->st_mtime=tmxsec(t),ST_MTIME_NSEC_SET(s,tmxnsec(t)))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Time_t tmxdate __PROTO__((const char*, char**, Time_t));
+extern __MANGLE__ char* tmxfmt __PROTO__((char*, size_t, const char*, Time_t));
+extern __MANGLE__ Time_t tmxleap __PROTO__((Time_t));
+extern __MANGLE__ Tm_t* tmxmake __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxscan __PROTO__((const char*, char**, const char*, char**, Time_t, long));
+extern __MANGLE__ int tmxsleep __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxtime __PROTO__((Tm_t*, int));
+
+extern __MANGLE__ Time_t tmxgettime __PROTO__((void));
+extern __MANGLE__ int tmxsettime __PROTO__((Time_t));
+
+extern __MANGLE__ int tmxtouch __PROTO__((const char*, Time_t, Time_t, Time_t, int));
+
+extern __MANGLE__ char* fmttmx __PROTO__((const char*, Time_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/amd64/src/lib/libast/tv.h b/usr/src/lib/libast/amd64/src/lib/libast/tv.h
new file mode 100644
index 0000000000..6692382606
--- /dev/null
+++ b/usr/src/lib/libast/amd64/src/lib/libast/tv.h
@@ -0,0 +1,111 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libast/features/tv by iffe version 2007-04-04 : : */
+
+#ifndef _TV_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TV_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Tv_t interface definitions
+ */
+
+#include <ast.h>
+
+#define TV_NSEC_IGNORE (1000000000L)
+#define TV_TOUCH_RETAIN ((Tv_t*)1)
+
+typedef struct Tv_s
+{
+ uint32_t tv_sec;
+ uint32_t tv_nsec;
+} Tv_t;
+
+#define ST_ATIME_NSEC_GET(st) ((st)->st_atim.tv_nsec)
+#define ST_CTIME_NSEC_GET(st) ((st)->st_ctim.tv_nsec)
+#define ST_MTIME_NSEC_GET(st) ((st)->st_mtim.tv_nsec)
+
+#define ST_ATIME_NSEC_SET(st,n) (ST_ATIME_NSEC_GET(st)=(n))
+#define ST_CTIME_NSEC_SET(st,n) (ST_CTIME_NSEC_GET(st)=(n))
+#define ST_MTIME_NSEC_SET(st,n) (ST_MTIME_NSEC_GET(st)=(n))
+
+#define tvgetatime(t,s) ((t)->tv_nsec=ST_ATIME_NSEC_GET(s),(t)->tv_sec=(s)->st_atime)
+#define tvgetmtime(t,s) ((t)->tv_nsec=ST_MTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_mtime)
+#define tvgetctime(t,s) ((t)->tv_nsec=ST_CTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_ctime)
+
+#define tvsetatime(t,s) (ST_ATIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_atime=(t)->tv_sec)
+#define tvsetmtime(t,s) (ST_MTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_mtime=(t)->tv_sec)
+#define tvsetctime(t,s) (ST_CTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_ctime=(t)->tv_sec)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int tvgettime __PROTO__((Tv_t*));
+extern __MANGLE__ int tvsettime __PROTO__((const Tv_t*));
+extern __MANGLE__ int tvcmp __PROTO__((const Tv_t*, const Tv_t*));
+extern __MANGLE__ int tvtouch __PROTO__((const char*, const Tv_t*, const Tv_t*, const Tv_t*, int));
+extern __MANGLE__ int tvsleep __PROTO__((const Tv_t*, Tv_t*));
+
+extern __MANGLE__ char* fmttv __PROTO__((const char*, Tv_t*));
+
+#endif
diff --git a/usr/src/lib/libast/common/README b/usr/src/lib/libast/common/README
new file mode 100644
index 0000000000..cc0cf82304
--- /dev/null
+++ b/usr/src/lib/libast/common/README
@@ -0,0 +1,95 @@
+The advanced software technology department has been collecting useful C
+routines in a single library called libast. libast is used by nmake, the
+nmake cpp (which is mainly based on another library (libpp)), CIA
+(C information abstractor from Robin Chen), and a collection of other
+/bin and /usr/bin commands that benefit from concentrating functionality
+in libast.
+
+More detail is available in the man pages. libast contains:
+
+ (1) routines to support a generic environment for
+ a variety of UNIX operating system variants
+
+ (2) routines that update standard libc routines
+
+ (3) routines shared between several commands
+
+If you already have nmake 2.0 or newer installed then use
+`nmake install' from this directory, otherwise use
+ship/shipin from the root of the distribution directory tree.
+
+Some of the routines not found in section 3:
+
+hash: generic, scoped hash table support
+
+ hashalloc create a hash table or push new scope
+ hashdump debug dump of one or all hash tables
+ hashfree free a hashalloc()'d table
+ hashlook low level name lookup
+ hashscan entry generator for scoped table scan
+ hashsize explicitly change table size (usually automatic)
+ hashwalk apply function to each table entry
+ memhash return hash code for n-char chunk of memory
+ strhash return hash code for null terminated string
+
+include/ast: libast support headers
+
+ align.h compile time type alignmnent support
+ dirent.h POSIX directory(3) interface definitions
+ error.h error() interface definitions
+ ftw.h ftwalk() interface definitions
+ hash.h hash*() interface definitions
+ ls.h strls() interface definitions
+ re.h re*() interface definitions
+ tar.h POSIX ustar format interface definitions
+ tm.h tm*() interface definitions
+
+misc:
+
+ cmdargs apply a sequence of cmd line option parsers
+ cmdopen like popen() but stdin and stdout are specified
+ cvtatoe convert ASCII to EBCDIC
+ cvtetoa convert EBCDIC to ASCII
+ error output generic error and trace messages
+ ftwalk an ftw(3) that works -- used in new tw(1)
+ getcwd uses $PWD if ok, doesn't use /bin/pwd
+ getshell return full path of shell for cmdopen()
+ ooptget optget() for obsolete ar(1) and tar(1) options
+ optget YA getopt(3) but no argc or error message output
+ pathaccess find file with specific acces on list of dirs
+ pathcanon canonicalize path name in place
+ pathcmd return full path name of executable using $PATH
+ pathroot determine `related root' directory for command
+ perror uses strerror()
+ readargs append each line of file to argv[0]
+
+re: egrep(1) and ed(1) style re's from V9
+ (not the good awk(1) algorithm)
+
+ recomp compile re pattern
+ reerror report re*() errors
+ reexec match string using compiled re
+ resub ed(1) style substitute using last reexec()
+
+string:
+
+ chresc return next char in string converting \ sequences
+ ctoi convert char constant string to int
+ strcopy like strcpy(3) but returns end of destination
+ strdup malloc(3) and strcpy(3) smashed together
+ strerror return error message string given errno
+ stresc convert \ sequences in string in place
+ streval evaluate C expression in string
+ strls ls -l format support
+ strmatch Korn shell file pattern match
+ strmode return ls -l style output given st.st_mode
+ strsignal return signal id string given SIG* number
+ strtape convert generic tape unit to /dev/* file
+ token generate space separated tokens in string
+
+tm: time conversion support
+
+ tmdate convert date string to time_t
+ tmform format time_t to date string
+ tmmake return current time_t
+ tmtime convert struct tm to time_t
diff --git a/usr/src/lib/libast/common/RELEASE b/usr/src/lib/libast/common/RELEASE
new file mode 100644
index 0000000000..c1e6d9c0de
--- /dev/null
+++ b/usr/src/lib/libast/common/RELEASE
@@ -0,0 +1,1420 @@
+07-04-13 tm/tmxdate.c,tm/tmzone.c: handle [-+]0000 UTC zone offset
+07-04-11 sfio/sfvprintf.c: add %F, propagate SFFMT_UPPER
+07-04-11 sfio/sfcvt.c: handle SFFMT_UPPER => nan/inf vs. NAN/INF
+07-04-02 comp/conf.tab,comp/conf.sh: add C/POSIX <stdint.h> symbols
+07-03-28 misc/optget.c: fix l10n --?-
+07-03-25 features/common: fix { ast_std.h ast_map.h stdint.h } logic
+07-03-21 error.h: move from error_info to (*_error_data_)
+07-03-21 option.h: move from opt_info to (*_opt_data_)
+07-03-19 regex/regdecomp.c: fix REX_ONECHAR escapes and add REX_KMP
+07-03-11 tm/tmxscan.c,regex/regnexec.c: fix strict-alias transgressions
+07-02-27 comp/conf.sh: handle native getconf invalid numeric values
+07-02-21 comp/conf.sh,comp/conf.tab: handle SSIZE_MAX vs _POSIX_SSIZE_MAX
+07-02-20 sfio/sfvprintf.c: handle SF_WCWIDTH justification
+07-02-14 features/common: cover <stdint.h>, move to int_(bits)_t
+07-02-14 include/int.h: drop
+07-02-14 include/sfio.h: add SF_WCWIDTH
+07-02-12 comp/conf.sh: fix CONF_LIMIT bug that missed ULONG_MAX etc.
+07-02-12 comp/conf.tab: *LONGLONG* => *LLONG* to match posix
+07-02-12 features/float: *LONGLONG* => *LLONG* to match posix
+07-02-12 port/astconf.c: handle CONF_LIMITS_DEF with no deferral
+07-02-12 stdio/vasprintf.c: add trailing '\0' -- doh
+07-02-04 string/fmtelapsed.c: fix naive multi month/year logic
+07-02-02 misc/optget.c: add --??posix for getopts(1)/getopt(3)
+07-01-26 string/chresc.c: use mbchar()
+07-01-26 misc/optget.c: handle "o:-:" usage for old-style long options
+07-01-22 sfio/sfdisc.c,sfpool.c: handle push on streams with pending peek
+07-01-22 include/sfio.h: mv Sfieee_t to sfio/sfhdr.h
+07-01-17 tm/tmxfmt.c: fix terminating nil logic which clobbered size-1
+07-01-11 misc/stk.c: a 2 day marathon bug fix (can we release now dr ek?)
+07-01-05 comp/spawnveg.c: posix_spawnattr_setflags(POSIX_SPAWN_SETPGROUP)
+07-01-05 misc/error.c: fix multibyte vs. printable logic
+07-01-01 comp/conf.sh: LC_ALL=C
+06-12-26 tm/tmxdate.c: handle nn*.nnnn* == sec.ns
+06-12-20 features/libpath.sh: generalize sol.* LIBPATH patterns
+06-12-18 comp/setlocale.c: include ast_standards.h and ast_wchar.h !
+06-12-12 string/strperm.c: octal modes are absolute!
+06-12-11 comp/conf.tab: always defer ARG_MAX
+06-12-07 Makefile: fix conftab.c generation CCFLAGS to match build - doh
+06-12-04 sfio/sfcvt.c: fix (int) vs. (long) cast mismatches
+06-12-01 comp/conf.tab: add changes to cover solaris { bin xpg4 xpg6 }
+06-12-01 regex/reginit.c: adjust { SRE KRE } escaped (){}*? inside [...]
+06-12-01 sfio/sfcvt.c: add signbit/copysign tests
+06-11-22 comp/spawnveg.c: fix _real_vfork logic to work with 3d
+06-11-20 features/common: bias _ast_int8_t "long long" before "__int64"
+06-11-20 string/strperm.c: fix X to work with all ops (not just +)
+06-11-15 astconf.c,conf.tab: add CONF_DEFER_* for variable constants
+06-11-11 port/astconf.c: validate path arg w.r.t. underlying calls
+06-11-11 comp/conf.sh: fix S CONF_STANDARD bug, add D to defer to native
+06-11-11 comp/conf.tab: add D to defer to native
+06-11-01 include/vmalloc.h: avoid VM_FLAGS sys/v*.h clash
+06-11-01 include/ast.h: add FMT_PARAM for fmtquote()
+06-10-31 disc/sfdcseekable.c: add SFSK_DISCARD for seekable window control
+06-10-31 comp/spawnveg.c,features/lib: handle posix_spawn exit status 127
+06-10-30 features/lib: fix posix_spawn() fork() prototype conflicts
+06-10-30 string/fmtscale.c: fix 1024 rounding bugs
+06-10-27 disc/sfkeyprintf.c: handle 'i' (=='d') -- oops
+06-10-26 sfio/sfvprintf.c: %#d => fmtscale(1000), %#i => fmtscale(1024)
+06-10-26 features/map.c: _map_libc cleanup
+06-10-26 features/fcntl: add to the circle of trust
+06-10-26 features/sys: add <sys/socket.h> socklen_t
+06-10-26 include/regex.h: handle include before <ast_map.h>
+06-10-25 astconf "SHELL" => "SH" to avoid _POSIX_SHELL conflict
+06-10-25 comp/conf.*: drop no-op duplicate conftab.c entries
+06-10-18 string/fmtscale.c: 1000: n[.]n[n](kMGTPE), 1024: n[.]n[n](KMGTPE)i
+06-10-11 ast_std.h: now implies <sys/stat.h> (did on most before anyway)
+06-10-11 strtoi.h: ignore sign for 0, validate scale shift
+06-10-11 strdup.c,vmstrdup.c: handle 0 arg
+06-10-11 add sfstruse()/sfstropen() error checks
+06-10-10 misc/procopen.c: envv==environ => don't modify environ
+06-10-10 misc/procclose.c: return valid exit(1) status
+06-10-06 port/astconf.c,comp/conf.sh,comp/conf.tab: play nice with getconf(1)
+06-10-01 comp/conf.tab: SHELL default checks { _CS_PATH } X { ksh ksh93 sh }
+06-10-01 comp/conf.sh: export CONF_getconf to shell actions
+06-10-01 comp/putenv.c: always enable setenv() for procopen()
+06-10-01 misc/procopen.c: use pathshell() or astconf("SHELL",0,0) if PARANOID
+06-10-01 path/pathshell.c: localize the shell path patterns and accept ksh93
+06-09-28 Makefile: avoid ast <stdio.h> vix iffe -X ast -- doh
+06-09-27 regex/regdecomp.c: add
+06-09-26 regex/regcomp.c: handle KRE ~(...)<invalid-kre>
+06-09-25 reorganize to avoid native header intercepts
+06-09-15 uwin/crypt.c: _UWIN only!
+06-09-14 Makefile: tweak the ast_common.h bootstrap again (finally?)
+06-09-14 misc/optget.c: noncommercial => OPT_proprietary
+06-09-12 string/strelapsed.c: fix multi-char qualifier parse
+06-09-12 string/strtoi.h: drop [cClLqQwW] multipliers
+06-09-11 misc/optget.c: add numeric arg validity check
+06-09-07 misc/optget.c,tm/tmfix.c: fix uninitialzed var refs
+06-09-05 path/pathprobe.c: add version header verification
+06-08-01 Makefile: handle iffe vs FEATURE/common vs ast_common.h
+06-08-31 Makefile: add ast_map.h to the bootstrap list
+06-08-30 misc/glob.c: fix ~(E)re bug that stripped ~(E) before regcomp
+06-08-30 include/ast.h: add { integralof(x) pointerof(x) }
+06-08-27 string/strelapsed.c: fix off-by-one (too little) parse bug
+06-08-25 misc/optget.c: 0*<n>.* numeric option args => <n>.*
+06-08-22 misc/glob.c: handle ~(...) pattern options
+06-08-16 string/strelapsed.c: fix off-by-one (too far) parse bug
+06-08-16 regex/regcomp.c: accept but ignore ~(N)
+06-08-14 features/libpath.sh: add solaris LD_LIBRARY_PATH_64 check
+06-08-05 sfio/sfpool.c: pool SF_READ|SF_WRITE loop fix
+06-08-02 misc/fts.c: fix FTS_NOSTAT optimization to check for ..
+06-07-28 include/glob.h: add gl_extra for user globlist_t expansion
+06-07-27 features/common: #include "ast_map.h"
+06-07-26 comp/fnmatch.[ch]: allow <ast_map.h> to map fnmatch()
+06-07-22 cdt: snarf from kpv
+06-07-17 string/strperm.c: perm==-1 skips umask(1)
+06-07-17 sfio/sfvprintf.c: handle format invalid mb seq
+06-07-17 regex/regcomp.c: inline REG_SHELL => anchored, otherwise not
+06-07-17 regex/regcomp.c: inline B|G:basic E:REG_EXTENDED F|L:REG_LITERAL
+06-07-17 regex/regcomp.c: inline l:REG_LEFT r:REG_RIGHT
+06-07-17 regex/regcomp.c: inline a:REG_LEFT|REG_RIGHT p:~REG_LENIENT
+06-07-17 string/chresc.c: add \Uxxxxxxxx
+06-07-17 sfio/sfstrtof.h: ignore thousands sep after decimal
+06-07-17 string/tokline.c: splice() => spliceline() for bsd
+06-06-27 features/float,sfio/sfcvt.c: fix Nan logic
+06-06-27 port/astmath.c: fix long double isnan() test
+06-06-27 features/map.c: _map_libc for std => _ast_std
+06-06-25 string/strperm.c: handle posix = w.r.t. umask
+06-06-19 port/mnt.c,features/fs: handle netbsd getmntent api change
+06-06-18 regex/regstat.c: add REG_LITERAL check
+06-06-11 cdt/dtview.c: update from kpv
+06-05-31 sfio/sfhdr.h: fix _SFOPEN() typo
+06-05-09 comp/conf.sh: add native getconf -a names to the mix
+06-04-28 misc/optget.c: add solaris long option name compatibility
+06-03-09 string/strmatch.c: add REG_ADVANCE => REG_* flags
+06-02-14 comp/iconv.c: fix uwin iconv_list() /reg/ generator
+06-02-10 port/astconf.c: relax standard prefix filter
+06-02-08 sfrd.c,sfsync.c: lock logic bug fix
+06-02-01 port/astlicense.c: add { parent incorporation }
+06-01-26 port/astconf.c: fix { LIBPREFIX LIBSUFFIX } length
+06-01-06 features/lib: change _UNIV_DEFAULT probe to use cross{...}
+06-01-04 misc/stk.c: fix n**2 realloc behavior
+06-01-01 include/sfio.h: export { _Sfi _Sfmaxr }
+05-12-13 string/chresc.c: handle \C-X => control-X, \M- => ESC
+05-11-22 regex/regcache.c: add, convert string/strmatch.c to regcache()
+05-10-06 string/ccmap.c: update ebcdic-u to be idempotent
+05-09-28 vmalloc: snarf from kpv; fixes large block brk() thrashing
+05-09-26 misc/magic.c,misc/magic.tab: handle latest vcodex header
+05-09-12 misc/optget.c: reset opt_info.offset on error
+ string/strtoi.h: strton() '.' multiplier only if m>1
+ string/fmtesc.c: add unadvertized FMT_PARM for FMT_SHELL
+05-09-09 string/fmtesc.c: fix FMT_SHELL logic w.r.t. [$`]
+05-08-11 string/strerror.c: fix { sys_errlist sys_nerr } prototypes
+05-08-03 sfio: snarf sfvaprints sfaprints
+05-07-21 port/astconf.c: retain most recent synthesized lookup
+05-07-20 sfio/sfsetbuf.c: default file io size now 64K on all systems
+05-07-17 ccmap*: add microfocus cobol EBCDIC_U
+05-06-29 regex/regcomp.c: fix the A & B inline flag logic
+05-06-15 include/recfmt.h: add fs format flag to fmtrec()
+05-06-14 error.c: add ERROR_OPTIONS { break count match }
+05-06-07 features/stdio: drop FEATURE/limits to fix bootstrap circular dep
+05-06-02 features/*,Makefile: drop vestigel iffeio.h bootstrap workaround
+05-05-31 string/fmtbuf.c: unlock (spin) before each return -- doh
+05-05-30 sfio/sfpkrd.c: work around macos 10.4 recv(MSG_PEEK) bug
+05-05-27 regex: add REX_NEST (?%[S.][T.][OT])
+ magic.tab: ammend bsd db magic
+05-05-23 regex: REX_NEST (?%[D.][E.][L.][Q.][oc]...)
+05-05-21 regex: state.fold[] is now locale specific -- doh
+05-05-19 regex: add REX_NEST (?%\\()<>[]""...) %(...) nested match
+05-05-15 recfmt.h: add recstr() reclen() fmtrec()
+05-05-13 optget.c: allow boolean options to take numeric values
+05-05-12 recfmt.c: add to recfmt.h, adjust Recfmt_t encodings
+05-04-30 sfio: add sfmaxr(), default 64K
+05-04-22 comp/omitted.c: fix magic() logic for files < 512 bytes
+05-04-20 cdt: snarf update from kpv; void* Dt_t.user added
+ misc/error.c: library => ERROR_LIBRARY
+05-04-19 regex/regcomp.c: handle REG_SHELL [^...] == [!...]
+05-04-11 tm/tmxscan.c: handle yyy.mm.dd[-+.]hh.mm.ss.nnnnnn
+05-04-07 regex/regnexec.c: fix out of bounds boundary check -- ouch
+ features/align.c: add jmp_buf to the alignment mix (ia64)
+ vmalloc/vmhdr.h: add jmp_buf to the alignment mix (ia64)
+05-03-31 misc/optget.c: fix option { - _ } separator matching
+05-03-30 misc/glob.c: eliminate superfluous GLOB_NOMATCH stat() calls
+05-03-24 port/astwinsize.c: include <sys/ioctl.h> if possible
+05-03-23 string/ccmap.c: add ebcdic-m mvs cobol table
+05-03-11 comp/omitted.c: handle utime[s](const,const)
+ comp/conf.tab: fix linux PID_MAX probe
+05-03-10 comp/setlocale.c: LC_* value "" => unset -- doh
+ misc/optget.c: reorder _PACKAGE_astsa code for msgcc
+05-03-08 misc/optget.c: delete leading space in STYLE_nroff output
+05-03-07 sfio/sfhdr.h: drop extern _sfdscan -- clashes with sfvscanf.c static
+05-03-01 tm/tminit.c: add tmlocaltime() for tzset() getenv() override workaround
+05-02-20 features/tvlib: tmsettimeofday only for systems that have settimeofday
+ features/float: fix mvs.s390 NaN tests
+05-02-18 tm/tmxmake.c: fix <0 west of GMT bug that warped to 1800's -- wow
+05-02-11 port/mnt.c: handle lynxos MOUNTED=/etc/fstab
+05-02-08 features/float,sfio.h,sfcvt.c,sftable.c: add INF and fix NAN
+05-02-04 features/lib: add _std_strtol (for lynxos)
+ include/ast_std.h: add _std_strtol tests
+ comp/strtod.c: #define S2F_function strtod
+ misc/signal.c: fix ancient bsd SV_INTERRUPT vs. SV_ABORT clash
+05-01-11 sfio/sfmove.c: try to seek(fr) when fw==0
+ comp/omitted.c: intercept utimes() too
+ comp/omitted.c: add DOSPATHVARS env var path value conversions
+ features/tvlib,tm/tvtouch.c: check for utimets()
+ misc/optget.c: handle '-' or '_' option word separators
+ sfio/_sfopen.c: allow stream mode changes after initialization
+ sfio: sync with kpv: SF_SYNCED fix for ksh input loss bug
+05-01-09 tm/tmxfmt.c: fix %6N for n<100000000
+05-01-08 regex/regcomp.c: conj() => con() to avoid C99 clash
+05-01-05 tm/*: fix { %U %V %W } logic -- my head hurts
+04-12-30 tm/tmxtime.c: fix tm_isdst<0 loop
+04-12-23 vmalloc/vmbest.c: fix vmresize bug that didn't 0 new data
+04-12-19 misc/optget.c: broaden - long option match
+04-12-09 string/strtoi.h: fix terabyte 't' suffix math
+ string/strmatch.c: flush cache on locale change
+04-12-01 tm/tmsleep.c: add
+ tv.h,tv*.c,tv.3: move from pax
+ tmx.h,tmx*.c,tmx.3: add high resolution tm(3) counterparts
+ features/lib: add *another* sgi linux.ia64 memccpy bug check
+04-10-31 Makefile: __OBSOLETE__ now computed <6 months ago year>0101
+ ccode.h,ccmapid.c: add ccmaplist(Ccmap_t*) iterator
+ option.h,optesc.c: add 3rd arg, 1 => quote '?' too
+ misc/magic.c: fix bug that terminated `string \0a' at \0
+ misc/magic.c: handle vcodex() via decompose()
+ misc/magic.tab: add vcodex magic
+ features/stdio: handle _LARGEFILE64_SOURCE -- oops
+ stdio/(fseek|ftell|fseeko|fsetpos|fgetpos|ftello).c: oops^2
+04-10-28 string/swapop.c: size==-4 => size=4 and extend op=3 to op=7
+ tm/tmfix.c: fix tm_mon<0 logic
+04-10-22 tm/tmdate.c: handle 'final day feb 2004'
+ port/astlicense.c: add query=all|id|${...}${...}
+ port/astlicense.c: "free" => "mit"
+ comp/omitted.c: revert to the open source license
+ string/stropt.c: drop siz==0 => tab is hash table
+ include/sfio.h: incorporate <sfstr.h>
+ include/sfstr.h: drop
+ disc/sfstrtmp.c: drop -- use sfstrbuf()
+04-10-20 misc/magic.tab: update tar magic
+04-10-18 ufc-crypt.h,crypt_util.c: drop GPL code
+ crypt.c: add BSD code
+ pathpath.c: disable { $0 $_ $PWD } related root search
+04-10-01 normalize ident stamps
+ port/astlicense.c: add type=cpl -- yeah
+04-09-25 string/swapop.c: return op < size -- duh
+04-09-23 comp/spawnveg.c: :NOOPTIMIZE: -- volatile sometimes ignored
+04-09-21 comp/spawnveg.c: exec_errno_ptr is volatile -- duh
+04-09-14 tm/tmscan.c: add %| alternation and %& => tmdate()
+04-09-08 misc/optget.c: add :!value: omitted optional arg value
+ misc/optget.c: fix --noNAME ambiguous option logic
+04-08-26 string/strperm.c: add who^mode to propagate least restrictive up
+ astmath.c: add { frexpl ldexpl } checks for ast.req
+ port/astlicense.c: ignore first option if non-assignment
+ include/ast_dir.h: move d_fileno map before struct defs -- duh
+04-08-24 vmalloc/vmbest.c: add {VM_region} VMCHECK=+r for region segment checks
+ misc/recfmt.c,include/recfmt.h: add
+04-08-23 vmalloc/vmbest.c: add {VM_primary VM_secondary} VMCHECK=-s for primary
+ features/common: punt to <stdarg.h> for unknown va_list
+04-08-11 vmalloc: sync _UWIN libposix hooks
+04-07-27 features/common,features/limits.c: ULL suffix for unsigned _ast_int8_t
+04-07-22 include/ast.h,comp/eaccess.c: add eaccess() for effective access()
+04-07-19 comp/open.c,sfio/_sfopen.c: { O_RDONLY O_WRONLY O_RDWR } are values
+04-06-28 misc/error.c: check level after error_info.auxilliary
+04-06-24 string/strmatch.c: strgrpmatch() match[] now variable size array
+04-06-17 features/common: change _DLL null define to (the standard ast) 1
+04-06-11 misc/optget.c: allow optional [-|+|--|++] optstr() option prefix
+ misc/optget.c: reset optstr() state on 0 return
+ misc/optget.c: text()=>textout() linux.ppc symbol hijack workaround
+04-05-31 sfio/sfreserve.c: no side buffer if user buffer is large enough
+04-05-27 string/fmtbuf.c: handle one concurrent buf > sizeof(buf)
+04-05-24 regcomp.c: fix no-advance initialization
+04-05-05 conf.tab,conf.sh: update to align with standards
+ magic.tab: ms suffix update
+04-05-04 port/lcgen.c: fix territory initialization
+04-04-15 tm/tmdate.c,include/tm.h: fix specific and ordinal days
+04-04-08 astconf: retain { HOSTTYPE LIBPATH LIBPREFIX LIBSUFFIX } strict vals
+04-04-07 vmalloc/vmbest.c: fix alpha tiny block bug
+ vmalloc/malloc.c: re-enable on alpha
+04-03-30 tm/tminit.c: GMT => UCT only if tz.daylight not defined
+04-03-25 vmalloc/malloc.c: _AST_std_malloc=1 for __alpha
+ path/pathprobe.c: per-user probe dir => $HOME/.probe/$HOSTTYPE
+04-03-23 regex/reglib.h: fix isw*() redefines
+04-03-17 features/stdio: no __FILE override for __CYGWIN_ (sys/reent.h clash)
+ sfio/sfhdr.h,sfio/sfsetbuf.c: lower sfmove() default buf size 4x
+04-02-29 comp/omitted.c: move env trace after PATH fixup
+ comp/omitted.c: cygwin spawn _P_DETACH => _P_NOWAIT+setpgid(pid,0)
+ misc/optget.c: fix html mailto: match
+ port/astlicense.c: add type=test for fixed 2001 date
+ features/float: check local NaNQ first
+ vmalloc/vmhdr.h: fix _vmextern_ vm_truncate return type
+ misc/magic.tab: add elf s390 index=22
+04-02-26 vmalloc: VMCHECK a:assertions c:arena-check w:warn-instead-of-abort
+ sfio/sfvscanf.c: fix extf arg selection
+04-02-24 features/dirent: set nodefine to avoid ast_std.h _typ_off64_t undef
+ disc/sfkeyprintf.c: only case pattern must be ()[] balanced
+04-02-14 include/sfio_t.h: add SF_DCDOWN, SFDCNEXT(), SFDCPREV()
+04-02-13 string/strmatch.c: fix bug that didn't save one-time sub[] size
+ vmalloc: -g: export VMCHECK=1 enable malloc/free checks
+ vmalloc: -g: free(0) to check and disable malloc/free checks
+ vmalloc: -g: free(1) to check and enable malloc/free checks
+04-02-11 Makefile: add :P=A: to conf and lcgen exec for cross-compile
+ regex: use MBSIZE() instead of mbsize() to grab 1 char on err
+ vmalloc/vmbest.c: updated to do more comprehensive DEBUG tests
+04-02-04 sfio/sfraise.c: add sfraise(0,a,b) to iterate over all streams
+04-02-01 vmalloc/vmbest.c: _BLD_DEBUG free(0) checks the arena
+04-01-31 features/vmalloc: fix typo that missed _mmap_zero
+04-01-23 string/strerror.c: handle real strerror() return value overwrite
+04-01-11 path/pathpath.c: fix size vs. sizeof(buf) typo
+03-12-22 misc/magic.tab: dos EXE tweaks
+03-12-05 vmalloc: sync with kpv, adding exceptf announcements
+03-12-04 port/astlicense.c: fix expand() loop sentinel bug
+03-12-02 include/ast.h: mbchar() advances by 1 on mbtowc() error
+ misc/fts.c: increase MINNAME to 32
+03-11-21 vmalloc/vmbest.c: export VMCHECK=1 to enable $(CC.DEBUG) vmcheck()
+ vmalloc/vmbest.c: export VMCHECK=2 to disable KPVCOMPACT
+ misc/magic.c: add { cobol copybook pl1 } and suffix preference
+03-11-12 features/stdio: drop cuserid,getopt for SUSV3
+03-11-11 vmalloc/*: merge kpv update -- this should stomp the compaction bug
+03-10-23 comp/iconv.c: fix sfreserve lock fallback
+03-10-20 sfio/_sfopen.c: add to allow user sfopen() intercept
+03-10-17 regnexec.c: fix exec time REG_LEFT, \x.... => wctomb()
+03-10-12 string/strtoi.h: fix strton '.' overconsumption
+03-10-12 comp/iconv.c: identity is always (iconv_t)0
+03-10-09 string/fmtesc.c: fix FMT_SHELL to check for all shell magic chars
+03-10-01 port/astlicense.c: unknown authors copied verbatim (instead of ignored)
+03-09-30 string/chresc.c: handle \u..., \x... consumes all trailing hex digits
+ string/stresc.c: \u... and \x... > UCHAR_MAX => wctomb()
+03-09-29 fnv.h: add
+03-09-23 modedata.c: table is for external modes, so no arch specific hacks
+ optget.c: fix option prefix match translation bug
+ optget.c: add `<length> <name>=<value>\n' to optstr()
+ features/lib: add memcmp() test for sgi optimzation bug
+03-09-22 regex.h,regcomp.c: add regncomp()
+ regclass.c: fix for loop dangling ; in regaddclass()
+03-09-20 sftable.c,sfvprintf.c: fix SFFMT_CHAR handling to match extf api
+03-09-19 sfmode.c: update release to kpv's
+03-09-17 regcomp.c: add pedantic backref error checks
+03-09-16 regnexec.c: exec time REG_LEFT => don't advance past initial position
+ regclass.c: add regaddclass() for user defined [:class:]
+ regexec.h: REG_VERSION_N2X, add redisc_t {re_map} ccode map
+ regstat.c: add regstat_t
+03-09-11 optget.c: --n:=v sets opt_info.assign=':', opt_info.number enabled
+03-09-09 disc/sfkeyprintf.c: *pn on lookup is arg separator; lookup "" arg too
+03-09-05 optget.c: [f:l*?] preserves user long name past '*' in opt_info.name[]
+03-09-03 sfstr.h: add sfstrpend() for #pending bytes in read buffer
+03-08-25 regex: add REG_FIRST, optimize bm
+ features/lib: _AST_no_spawnveg==1 falls back to fork/exec
+03-08-22 features/stdio,stdio/asprintf.c,stdio/vasprintf.c: add
+03-08-21 path/pathnative.c,path/pathposix.c: interix updates
+ features/botched: add cygwin _stat => _stat64
+03-08-15 include/ast.h: map out bsd strmode()
+ features/common: add interix _ast_intmax_t workarounds
+ misc/fs3d.c: 3d mount test now uses "" instead of NiL (or cygwin dumps)
+03-08-11 string/fmtesc.c: fix optional quoting checks
+ tm/tmdate.c: fix > 1 year of seconds arithmetic
+ tm/tmfix.c: fix leap year adjustments
+03-08-01 features/lib: beef up sock_peek test for interix
+03-07-29 features/float: add -lm to frexp... test
+ Makefile: fix -lm astmath test sense
+03-07-26 features/mem.c: favor _mem_sbrk over _mem_mmap_*
+03-07-22 vmalloc/vmbest.c: fall back to sbrk() if mmap() fails
+ features/mem.c: _mem_sbrk means sbrk() and brk() work
+03-07-17 regex/regcomp.c: fix bug that treated KRE X{n,m} like {n,m}(X)
+ misc/magic.c: check MAGIC_VERBOSE for all load() messages
+03-07-14 misc/optget.c: handle [...]{[...]\f...\f...}
+03-06-21 misc/sigcrit.c: block SIGCHLD if _lib_sigprocmask || _lib_sigsetmask
+ comp/spawnveg.c,sfio/sfmode.c: use sigcritical() SIG_REG_* macros
+ comp/spawnveg.c: drop ENOEXEC logic
+ vmalloc/*: snarf kpv KPVCOMPACT() fix
+ vmalloc/vmbest.c: export VMCHECK=2 to disable KPVCOMPACT (just in case)
+ string/strdup.c: drop __strdup() etc. intercepts -- malloc gets it
+ features/mem: define _mem_method and _mem_* possible values
+ vmalloc/malloc.c: _AST_mem_method==_mem_* to force mem get method
+ sfio/sfputr.c: __ia64 memccpy is bogus -- how many tries do they get?
+ path/pathshell.c: verify abs path and access(path,X_OK) -- duh
+ vmalloc/vmhdr.h: add private _Vmessage() for non-sfio ASSERT()
+ port/astconf.c: fix bug that always returned the minmax value
+03-06-11 comp/*.c: reorder macro hding for mvs.390 and <ast_map.h>
+ features/vmalloc: add _lib_brk and _lib_sbrk verification
+ include/ast_std.h,etc.: add _map_malloc for malloc => _ast_malloc
+ comp/conf.sh: fix SI_* and *_SI_* macro redefs
+ ast.h: VMDEBUG or _BLD_DEBUG enable <vmalloc.h> and VMFL tracing
+ vmalloc/vmtrace.c: _PACKAGE_ast __FUNCTION__ is a string
+ vmalloc/vmtrace.c: set trace file fd FD_CLOEXEC
+ vmalloc/vmbest.c: set /dev/zero mmap fd FD_CLOEXEC
+ features/mmap: fix ancient read() vs. mmap() time arithmetic typo
+ vmalloc/malloc.c: _AST_std_malloc==1 to force standard malloc
+03-06-09 comp/omitted.c: add _imp__FUNCTION sybols for __CYGWIN__ static link
+ vmalloc/vmbest.c: handle systems with sbrk() but no brk()
+03-06-04 port/astconf.c: drop non-standard diagnostics
+03-06-03 comp/conf.sh: rework symbol collision logic
+03-05-30 conf.tab,conf.sh,astconf.c: add <sys/systeminfo.h> sysinfo() SI_*
+03-05-29 ccode.h: rework for extensibility, drop obsolete mematoe(), memetoa()
+03-05-28 regex/*: recode to use isw*() directly when needed, is*() otherwise
+03-05-27 features/vmalloc: fix _std_malloc test
+03-05-25 misc/optget.c: fix optstr() ???* internal options
+03-05-24 misc/optget.c: fix (ancient) argv null dereference
+03-05-23 comp/getcwd.c: don't intercept on _WINIX -- unreliable st_ino
+03-05-22 sfio/sfsprintf.c: n<0 => don't append '\0'
+03-05-18 misc/fts.c: re-stat FTS_DP to update nlink/times
+ misc/fts.c: add FTSENT.stack to eliminate getlist() recursion
+ regex/ucs_names.h: use "..." catenation to placate some cc's
+03-05-11 string/strtoi.h: handle "-" "+" "0x" "11#"
+03-05-09 vmalloc/vmbest.c: large memory allocation tweaks
+03-05-06 misc/optget.c: fix getopt_long() prefix==1 bug that missed short flags
+03-04-27 comp/system.c: handle <ast_map.h>
+03-04-24 vmalloc/vmmopen.c: drop dup <unistd.h>
+03-04-21 tm/tmdate.c: fix next hour/min logic
+03-04-15 vmalloc/malloc.c: intercept __malloc() along with __libc_malloc()
+ string/strdup.c: intercept __strdup() along with __libc_strdup()
+ features/mmap: consolidate from features/(lib|sfio|vmalloc)
+ add _NO_MMAP==1 to disable all mmap()/munmap() calls
+ path/pathposix.c: add
+03-04-14 comp/setlocale.c: fix debug_mbtowc() return value for *s==0 || n < 1
+ comp/iconv.c: fix error return errno values
+03-04-11 misc/stk.c: fix stkgrow() realloc bug
+03-04-05 string/tok.c: support readonly single token input strings
+ disc/sfdcdio.c: fix F_DIOINFO and FDIRECT #ifdef's
+ include/ast_std.h: allow _LARGEFILE64_SOURCE on __hppa
+ features/common: fix `tst _foo_' => `tst foo_' typo
+ features/float: fix `tst _foo_' => `tst foo_' typo
+ features/float: add FLTMAX_(UINTMAX_MAX,INTMAX_MAX,INTMAX_MIN)
+ comp/omitted.c: fix pathconf => _pathconf => _ast_pathconf loop
+03-04-03 features/float: add _ast_no_um2fm: no usinged intmax => floatmax cast
+ vmalloc/vmbest.c: add getenv("VMCHECK") to initialize Vmcheck
+03-03-28 include/ast_dir.h: add D_TYPE; { D_FILENO D_TYPE } must be #ifdef'd
+ misc/fts.c|getcwd.c|glob.c,preroot/getpreroot.c: add D_FILENO #ifdef's
+ Makefile: make sure _BLD_ast is defined for all compiles
+03-03-27 ast_vfork.h: generate from features/vfork to pick up headers/pragmas
+03-03-25 comp/omitted.c: drop free() of live environ
+ path/pathshell.c: allow trailing .exe -- pox on that
+ string/strtoi.h: fix bug leading 3 digits before thousands sep bug
+ string/(fmt|str)[gu]id.c: we know root when we see it
+03-03-24 misc/optget.c: handle : and ? in := default value
+03-03-21 ast_std.h: drop all spawn*() but spawnveg()
+ obsolete/spawn.c: add for dropped spawn*()
+ features/lib: _use_spawnveg if spawnveg() is a win over fork()/exec()
+ features/lib: drop NutForkExecve() and _map_spawnve
+ features/lib: fix memccpy test to clean up /tmp droppings
+ comp/spawnveg.c: call posix_spawn() if implemented
+ comp/omitted.c: add spawnve() intercept
+ comp/getoptl.c: set getopt_long() optind even if no options
+ tm/tmfmt.c: add %Q<delim>recent<delim>distant<delim>
+ misc/optget.c: fix trailing '*' for option and option args
+ sfio/sfmode.c: getenv("_AST_SFIO_OPTIONS") [,]SF_LINE[,] for fd {0,1,2}
+ vmalloc/*: kpv sync for uwin build independent of libast
+03-03-18 port/astconf.c: switch to dynamic string values (saves 7K data/bss)
+ string/strmatch.c: switch to dynamic regex cache (saves 3K data/bss)
+ regex/regcoll.c,ucs_names.h: initialize rw tables from smaller ro data
+ features/lib: add vfork test for passing SIG_IGN across exec
+ features/lib: add spawn test for passing SIG_IGN across spawn
+03-03-17 comp/omitted.c: unlink() renames to .deleted dir in case file open
+ sfio/sfpopen.c: handle mode "" for spawn with no pipe
+ features/float,comp/frexp.c,comp/frexpl.c: add pow2() table alternative
+03-03-12 features/lib: fix linux.ia64 memccpy() tests -- now its their turn
+ features/vmalloc: fix /dev/zero test
+ features/align: _ast_intmax_t and _ast_fltmax_t join the union
+ misc/stk.c: fix struct frame size to align data
+ disc/sfdcdos.c: change sfslen() => sfvalue(f)
+03-03-10 misc/optget.c: handle [f\f:x:lll\f?ddd]
+03-03-07 port/astconf.c: uninitialized CONFORMANCE + POSIXLY_CORRECT => standard
+03-03-05 comp/omitted.c: make sure at least /bin is in PATH to find cygwin dlls
+03-03-02 path/pathshell.c: write access to /bin is effectively root
+03-02-28 features/float: add (FLT|DBL|LDBL)_U?(LONG|LONGLONG|INTMAX)_(MIN|MAX)
+03-02-25 features/lib: change vfork() test to use _exit() instead of exit()
+03-02-23 include/error.h: update ERROR_VERSION for error_info.number space
+03-02-22 comp/conf.sh: wrap ksh check in eval to avoid premature exit
+03-02-21 misc/fts.c: verify chdir(..) to avoid malicious dir rename()
+03-02-19 string/strtoip4.c: isspace() instead of ' '||'\t'
+03-02-17 regex/regcomp.c: fix stats.l REX_REP logic that botched REX_BM
+03-02-13 string/base64.c: handle catenated encodings
+03-02-11 features/libpath.sh: change LIBPATH to <dir>[:<env>[:<pat>]][,...]
+03-02-07 path/pathfind.c: allow "/dev/null" to be PATH_REGULAR
+03-02-06 include/ast.h,fmtquote.c: add FMT_ALWAYS|FMT_ESCAPED|FMT_SHELL|FMT_WIDE
+03-02-05 tm/tmdate.c,tm/tmword.c,string/strelapsed.c: '_' treated like ' '
+03-02-01 string/strelapsed.c: handle ps style [day-][hour:]min:sec
+03-01-31 port/astlicense.c: fix author=* match
+03-01-30 include/tm.h: add tmisleapyear() macro
+03-01-29 comp/getopt.h,comp/getoptl.c: add gnu getopt_long(), getopt_long_only()
+ include/ast_getopt.h: for non-gnu part of comp/getopt.h
+ include/ast_std.h: include <ast_getopt.h> instead of <getopt.h>
+03-01-28 ast.h,string/base64.c: add base64encode() and base64decode()
+ path/pathfind.c: verify S_ISREG()
+03-01-24 path/pathexists.c: fix abs dir bug and deal with case ignorance
+03-01-23 path/pathpath.c: honor PATH_ABSOLUTE for the easy case too
+03-01-22 path/pathprobe.c: fix search to find both the probe script and command
+03-01-17 misc/magic.tab: application/zip => appplication/(gzip|pzip|zip)
+03-01-14 misc/optget.c: change href="" to href="."
+03-01-10 include/ast_std.h: strtold() import hackery for static __CYGWIN__
+03-01-03 include/regex.h,regex/regcomp.h: add REG_SHELL_GROUP
+ include/ast.h,string/strmatch.c: add STR_GROUP for REG_SHELL_GROUP
+02-12-15 include/error.h: errorcontext => Error_context_s (compatible til 2004)
+02-12-06 misc/sigdata.c: add NoF(sigdadata) -- why nmake was uninterruptable!
+02-12-03 comp/omitted.c,features/omitted: handle cygwin alarm() return botch
+02-11-27 misc/swapop.c: op=3,size=4 => op=7
+ string/strlcat.c,strlcpy.c: fix uwin decl clash
+02-11-26 sfio/sfvprintf.c: fix sfsprintf() '\0' termination bug
+02-11-22 misc/glob.c: move static struniq() to libast extern
+ string/fmtversion.c,include/ast.h: add fmtversion
+02-11-18 string/strncopy.c: add
+ misc/magic.tab: list size for magicid.h magic
+02-11-14 sfio/sfvprintf.c: add %#c for C escapes
+ include/error.h: add ERROR_NOTIFY context flag for builtin commands
+02-11-11 string/strtoi.h: add S2I_size for strnto*() size_t 2nd arg
+ sfio/sfstrtof.h: add S2I_size for strnto*() size_t 2nd arg
+ comp/putenv.c: add setenv() and unsetenv() wrappers for setenviron()
+02-10-31 path/pathfind.c: add dir of including file to the pathinclude() list
+ misc/optesc.c: add
+02-10-30 string/strtoip4.c: set next char pointer even on error
+02-10-29 comp/resolvepath.c: add (size_t version of realpath())
+ misc/mime.c: fix mimehead() to ignore null content values
+02-10-28 misc/glob.c: add GLOB_STARSTAR for /**/ and GLOB_NOTDIR optimization
+02-10-27 string/struniq.c: add
+02-10-23 features/common: fix off-by-one loop check
+02-10-18 include/ast_std.h: avoid off_t,ftruncate,lseek,truncate redefinitions
+02-10-17 misc/mime.c: handle type/* match, fix bogus header parse
+02-10-04 sfio/sfstrtof.h: S2F_static <0:export =0:private >0:static
+02-10-02 features/common: don't define _WIN32; define _WINIX => unix on windows
+ features/tty: finally stomp the bsd _POSIX_VDISABLE redefinition
+ misc/fastfind.c: add more specific findwrite() error messages
+ comp/omitted.c: fix cygwin utime() to update st_ctime
+ comp/strtol.c,strtoul.c: __CYGWIN__ static link workaround XXX
+ string/fmtls.c,fmttime.c: tmform() => tmfmt()
+02-09-22 port/astconf.c: return values in fmtbuf() buffer instead of stack
+ port/mnt.c: don't set MNT_REMOTE for win32 ?:\* paths
+ sfio/sfvscanf.c: _sfdscan() is library global (not static)
+02-09-21 path/pathkey.c: add tool arg for mamake compatible hash
+ features/fcntl.c: handle iffe _hdr_lcl_* => _lcl_* change
+02-09-15 comp/conf.sh: fix enum vs. macro test
+ cdt: kpv sync
+02-09-11 ast.h,features/common: move _WIN32 macro init to features/common
+ features/common: enable __EXTERN__ and __DEFINE__ for _WIN32&!_UWIN
+ features/float: add -lm to _ast_*_nan_init tests
+ vmalloc: kpv sync with vmresizef => vmgetmem
+ features/iconv: must have both <iconv.h> and iconv_open()!
+ features/vmalloc: alloca test must compile *and* link
+ sfio/sfvscanf.c,sfstrtof.h: add flag arg to char get, fix NaN loop
+02-09-10 vmalloc/vmhdr.h: enable getpagesize() and sbrk() prototypes
+ features/fcntl.c: enable mmap64() prototype
+ include/ast_windows.h: windows.h wrapper with ast namespace workarounds
+02-09-07 misc/mime.c: fix quoted value parse bug that ate the whole line
+02-09-05 features/vmalloc: add free() to _std_malloc test
+ include/ast.h: NoF(x) now defines _DATA_x for !_BLD_DLL too
+ tm/tmlocale.c: { C POSIX en } == unix dadgummit
+02-08-29 path/pathfind.c: initialize Dir_t.next=0
+02-08-28 uwin/rint.c: update
+ features/libpath.sh: "bin" is now the default value
+02-08-22 vmtrace.h: add for debugging
+02-08-20 misc/magic.c: convert to use <cdt.h>
+ vmalloc/vmresizef.c: add for generic discipline resizef default
+ string/strelapsed.c: allow long time component names
+02-08-19 misc/optget.c: add `.fp 5 CW' to --nroff output
+ string/(fmtfs|fmtuid|fmtgid|strgid|struid).c: convert to use <cdt.h>
+ include/dt.h,cdt/dtnew.c: add for dtopen() in specific vm region
+02-08-13 comp/omitted.c: fix bzero logic for e.g. unixware.i386
+ include/ast.h: add fmtbase->fmtbasell; swap in 2003-09-01
+02-08-12 regex/regnexec.c: fix REG_MINIMAL REX_DOT mb bug
+02-08-08 features/iconv: <ast_common.h> instead of <sys/types.h> <ast_common.h>
+02-08-07 regex/regcomp.c: recognize anchors in BRE subexpressions
+02-08-06 comp/iconv.c: handle win32 cpNNNN == windows-NNNN aliases
+02-08-05 cdt/*: sync with kpv src
+02-08-02 features/iconv: include sys/types.h for ast_types.h
+02-08-01 misc/magic.c: magic file "." names the default
+ misc/magic.c: handle addr type (from irix string)
+ features/lib: move malloc tests to features/vmalloc
+ features/vmalloc: snarf tests from features/lib
+ vmalloc/*: sync with kpv src
+ comp/libc.c: dropped -- __libc_* intercepts moved to vmalloc/malloc.c
+02-07-30 features/lib: handle __libc_malloc() in _std_malloc test
+ vmalloc/malloc.c: add gnu pvalloc()
+ features/vmalloc: fix alloca check
+02-07-29 features/limits.c: handle netbsd guards
+02-07-27 sfio/sfpoll.c: handle rw pipes
+02-07-25 features/iconv: include ast_types.h for size_t in ast_iconv.h
+02-07-18 apply LARGEFILE64 header prototype clash patches
+ misc/optget.c: __EXTERN__ _opt_info_ instead of opt_info
+02-07-17 ast_std.h: memzero() now defaults to memset() instead of bzero()
+02-07-16 ast_std.h: add ast.env_serial
+ misc/setenviron.c: increment ast.env_serial
+ include/tm.h: tmset() now calls tminit() directly
+ tm/tminit.c: check ast.env_serial for env change
+ tm/tmfix.c: speed up for large values of tm_mday
+02-07-15 comp/fnmatch.c: fix memory leak caused by missing regfree()
+ comp/strstr.c: fix broken interpretation and implementation
+ comp/iconv.c: intercept (but no-op) null to and from buffer pointers
+02-06-27 ast_std.h: map _sysconf => _ast_sysconf for sun
+02-06-26 cdt,sfio,vmalloc: kpv sync -- is this ever easy?
+02-06-24 sfio: kpv sync, vfwscanf(),fputw() fix (wcslen(x)*sizeof(wchar_t)!!)
+ misc/fts.c: fix symlink chdir() optimzation bug
+02-06-11 sfio/sfwrite.c: string to file fix
+ Makefile: __OBSOLETE__==20020101
+02-06-01 regex/regcomp.c: REG_DELIMITED now consumes the delimiter
+02-05-31 regex/reglib.h,regcomp.c,regnexec.c: null subexpression fixes
+02-05-24 misc/fts.c: disable dir link counts in 3d
+ misc/magic.c: fix "*(mkfile)" sh pattern to "*@(mkfile)"
+02-05-20 regex.h,regex/regsubcomp.c,regex/regsubexec.c: add
+ regex/regsub.c: deprecate
+02-05-16 tm/tmfix.c: fix '60+n min/sec ago' bug for n min/sec after the hour
+02-05-14 regex/regsub.c: fix (^|x) null match early termination bug
+02-05-13 dir/dirlib.h: drop errant extern==__EXPORT__
+ features/uwin: add uwin lib tests
+ uwin/*.c: check features/uwin for stubs
+ features/float: add nan representation generation
+ sfio/sftable.h: used _ast_*_nan_init for huge values
+02-05-09 misc/fts.c: fix virtual top to force ``child'' stat()
+ features/common: define va_copy() only if not in <stdarg.h>
+02-05-01 string/strtoip4.c: cisco inverted quad mask must have 4 parts
+02-04-30 misc/magic.tab: fix pzip version check
+02-04-19 string/strtoip4.c: handle cisco inverted quad mask n.n.n.n/i.i.i.i
+02-04-18 misc/fts.c: add chdir() verification stat() optimizations
+ path/pathkey.c: check PROBE_ATTRIBUTES for list of vars
+02-04-12 port/astlicense.c: type=open tweak, fix author list spacing
+02-04-11 regex/regcomp.c: check for pattern number overflow
+02-04-05 tm/tmfmt.c: add %u
+02-04-04 sfkeyprintf.c: fix %c numeric value
+ path/pathpath.c: check plain path first -- duh
+02-04-03 misc/fts.c: fix (FTS_PHYSICAL|FTS_NOSTAT) stat optimizations
+ ftwalk.c: only clear FTW_DELAY if FTW_CHILDREN
+ ftwalk.h: add FTW_NSOK for FTW_DELAY
+02-03-29 ast.h: drop strerror() prototype -- already in <ast_std.h>
+ features/stdio: check for _SFIO_H redundant _Sfstd* declarations
+02-03-26 misc/glob.c: fix GLOB_LIST gl_flags values
+02-03-24 port/mnt.c: update bsd fstype name and mount option logic
+02-03-23 Makefile: add ast_wchar.h to the .check.hdr list (for mamake)
+02-03-17 features/stdio: hack around g++ 3.* clashes
+ Makefile: add ast_nl_types.h to the .check.hdr list (for mamake)
+ string/strtoip4.c: fix validity check bug that only checked last part
+02-03-14 misc/optget.c: fix --keys to not expand inline \f...\f
+02-03-12 port/astlicense.c: add type=free
+ path/pathaccess.c: sibling ".." search ignores relative dirs
+ sfio/sfvscanf.c: sfstrtof get() must return 0 on eof
+02-03-11 path/pathexists.c: check path by pairs checking {ENOTDIR,ENOENT}
+02-02-14 features/float: copy local min/max macros to avoid printf roundoff
+ features/wchar: include <ast_common.h>, not <ast_std.h>
+ misc/magic.c: match[]=>matches[] to fix K&R match() macro conflict
+ include/vmalloc.h: include <stdlib.h> for !_PACKAGE_ast
+ uwin/mini.sym: add sprintf (now required by features/common)
+ regex/regnexec.c: truncate wide chars for <ctype.h> functions
+ Makefile: fix MAM ast_common.h sequencing bug by making it first
+ cdt/dthash.c: fix DT_DELETE memory leak (DT_DETACH typo)
+ cdt/dthash.c: fix DT_DELETE double free (dt->data->here typo)
+ regex/regcomp.c: fix recomb() to reject RE with backref
+ features/iffeio: explicitly generate stdio.lcl
+ stdio: add {fcloseall,f(get|put)s_unlocked,fmemopen,getdelim,getline}
+ tmmake,tmtime: allow negative time_t if native localtime/gmtime do
+ tmdate: allow years before 1969
+ fmtfmt: add
+ include/ast.h: add { PATH_TOUCH_CREATE PATH_TOUCH_VERBATIM }
+ Makefile: add std/*.h for std header iffe overrides
+ comp/iconv.c: fix non-C win32 sfreserve() loop
+02-02-11 features/common: separate long long / long double tests
+ features/common: verify printf handles long long / long double
+02-02-02 include/ast_std.h,sfio/sfhdr.h: drop _hdr_locale tests -- always on now
+ include/ast_std.h: trust _UWIN <unistd.h>
+02-01-31 port/mnt.c: add aix options field
+02-01-30 comp/strstr.c: add for ancient s5
+ stdio/_flsbuf.c: only on systems that transfer to native (e.g., uwin)
+ string/strtoi.h: cat min/max error return values
+02-01-28 features/tty: add cf[gs]et[io]speed macros for <termio.h>
+ comp/rename.c: punt to (ancient) /usr/lib/mv_dir on EISDIR
+02-01-24 sigcrit.c: fix SIGCLD!=SIGCHLD interrupt loop
+ sfvprintf.c: convert fast io macros to functions for uts.390 cc
+ string/strtoi.h: drop #pragma prototyped for standalone sfio
+ sfdcsubstr.c: rename from sfdcsubstream.c for 14 char fs
+02-01-22 execlp,execvp,execvpe,spawnlp,spawnvp,spawnvpe: fix __EXPORT__
+ spawnlp,spawnve,spawnvp,spawnvpe: handle ms mode arg -- barf
+ sftable.c: ifdef hacks for _WIN32&_ALPHA_ fp exception
+ _stdfun.c: add _UWIN&_ALPHA_ iob map
+02-01-18 sfio/sfstrtof.h: drop #pragma prototyped for standalone sfio
+02-01-17 features/hdr: don't include <stddef.h> after it doesn't check out!
+02-01-16 misc/magic.c: add version type for YYYYMMDD or [a.][b.]c.d
+ misc/magic.c: recode mime %s parse -- sensible and no buffer overflow
+02-01-15 misc/magic.tab,magicid.h: add generic binary magic number and header
+02-01-12 tm/tmlocale.c: override win32 default date for {C,POSIX,en} locales
+ comp/omitted.c: fix cygwin workaround logic bugs
+02-01-09 stdio/fseeko.c,ftello.c: add from UNIX98
+02-01-08 comp/conf.sh: use $cc instead of cc
+02-01-07 string/strlcat.c,string/strlcpy.c: add bsd api
+01-12-18 comp/conf.tab: fix LFS_CFLAGS default for sun _CS_LFS_CFLAGS botch
+ features/common: add hdr stdarg test
+ tm/tmdate.c: handle YYYY/MM/DD
+01-12-10 misc/magic.tab: add generic 0x00010203 binary magic
+01-12-03 path/pathprobe.c: return HOME relative path if readonly/non-suid fs
+01-11-30 misc/optget.c: add simple cache for repeat offenders (like ksh read)
+ sfio/sfhdr.h: preserve errno across SFMMSEQON-SFMMSEQOFF
+01-11-29 magic.tab: fix GIF version number listing
+01-11-28 string/fmtbase.c: p!=0 => base always included in output
+01-11-26 misc/fts.c: empty path is an error
+01-11-14 misc/optget.c: fix --?+SECTION queries to include paragraphs
+01-11-20 regex/regnexec.c: fix REG_MINIMAL character class match bug
+01-11-19 features/lib: retain _lib_confstr for all solaris releases
+01-11-16 comp/setlocale.c: fix !_lib_setlocale typo
+01-10-31 regex/ucs_names.h: add string catenation to keep line length low
+ misc/fastfind.c: handle gnu slocate db read
+ misc/optget.c: add --?+SECTION queries
+ comp/fnmatch.h: add FNM_NOSYS
+01-10-30 tm/tmdate.c: fix cron specs when both wday and mday are specified
+01-10-20 misc/glob.c: fix bug that called \ trim() twice on same path
+ misc/glob.c: fix \ trim() bug that restored / to wrong position
+ string/fmtre.c: fix { ^ . $ } translations
+ misc/optget.c: use original string if translation fails -- duh
+ sfio/sfhdr.h: assume <errno.h> assigns proper atttibutes to errno
+ comp/regcmp.c: __ia64 workaround fixed by proper CC.DLL probe
+ comp/getdate.c: __ia64 workaround fixed by proper CC.DLL probe
+ features/lib: add lib getdate
+01-10-18 features/lib: check for strtod static link collision
+ features/float: add another signed cast for old bsd cc
+ features/wchar: add <stdlib.h> <stdio.h> before <wchar.h> for old bsd
+01-10-17 sfio/sfcvt.c: limit max precision to { FLT_DIG DBL_DIG LDBL_DIG }
+ sfio/sfcvt.c: fix %[aA] format to always have leading 0[xX]1.
+ sfio/sfvprintf.c: handle %C %lc %S %ls for wchar_t args
+ sfio/sfvscanf.c: handle %C %lc %S %ls for wchar_t args
+ string/fmtmode.c: fix bug that omitted trailing '\0'
+01-10-12 misc/optget.c: . => \&. for --??nroff
+ comp/wc.c: fix mbstate_t initialization typo
+ features/float: fix max integer / float loop termiation
+ features/float: fix LDBL_UINTMAX_MAX typo that did DBL_UINTMAX_MAX
+01-10-11 include/sfio.h: fix _Sfstd* import/export
+ features/common: fix _UWIN __DYNAMIC__() definition
+01-10-06 features/fcntl.c: { O_BINARY O_TEXT } default to 0
+ features/omitted: add for comp/omitted.c
+ sfio/sfopen.c: O_BINARY default for _WIN32&&!_UWIN
+01-10-05 misc/glob.c: fix `\(x/*' GLOB_NOMATCH bug that returned `(x'
+ misc/optget.c: fix localization lookup that didn't drop doubled : ? ]
+01-10-04 comp/setlocale.c: handle sizeof(wchar_t)!=4 in debug locale
+ comp/conf.sh: handle sytems where _SC_* is both an enum and a macro
+01-09-25 astconf: add LIBPREFIX
+01-09-20 features/common: add __DYNAMIC__() for dll externs
+01-09-19 cdt: kpv update
+ mb*() macros: update for ksh conversion, extend debug locale
+01-09-16 tm/tmlocale.c: add compiled in defaults for C locale
+ misc/glob.c: add gl_nextdir callback for GLOB_COMPLETE
+01-08-14 clarify _WIN32 vs. _UWIN vs. __CYGWIN__
+ tminit: fix standard & daylight initialization
+01-09-11 pathnative.c: add for native fs representation
+ regex.h: fix regerror_t prototype
+01-09-04 regex/regnexec.c: fix REG_ICASE for multi-char collating elements
+ tm/tmlocale.c: fix old ascii LC_TIME load
+ locale*: add new LC_* categories
+ comp/omitted.c: add CYGWIN workarounds
+ features/lib: add CYGWIN workarounds
+01-08-11 features/common: some compilers have long long but no LL constants!
+ features/lib: add mmap64 implementation test (for linux.s390)
+ regex/regcomp.c: fix \ in [...] parse
+ setlocale: retain user locale spelling in setlocale() return value
+ features/limits.c: don't include ./limits.h -- duh
+ fmtesc: don't escape multibyte chars
+ tm/tmlocale.c: fix native C locale default
+01-08-08 features/float: some compilers (msdev) forget long long vs. double
+01-07-31 misc/optget.c: handle suboptions
+01-07-27 cdt.h: add DTDISC()
+01-07-17 iffeio.h: move to include for stdio bootstrap iffe workarounds
+01-06-25 regex: perl extensions added and tested
+01-06-21 misc/error: add ERROR_OPTIONS=prefix=string for message processing
+01-06-15 string/chresc: only 2 hex digits max for \xxx
+ regex/regsub: handle REG_SHELL ~(nnn) rhs backrefs
+01-06-11 regex: handle embedded \0 in pattern and subject string
+ regex: add (?nnn) for backrefs > 9
+ comp/fnmatch: add FNM_LEADING_DIR for gnu compatibility
+ features/float: _ast_flt_unsigned_max_t for bsd.i386 omission
+01-06-06 misc/optget.c: add o option for old ps,ar,tar with optional leading -
+ regex/regcomp.c: REG_LENIENT|REG_DELIMITED \<newline> => <newline>
+ regex/regcomp.c: REG_LENIENT \000 => NUL
+01-06-04 features/dirent: replace Makefile hack with iffe semi-hack
+ regex/regnexec.c: negation must also check REG_SHELL_DOT
+01-06-03 sprintf.c: change buf size from SF_BUFSIZE to INT_MAX
+01-05-31 glob: fix gl_fignore to ignore leading . by default
+ features/lib: add botch_d_ino_dirent64 for linux botch
+01-05-25 port/lc.tab: add a few missing language_territory's
+01-05-23 string/chresc: \C[.collation-element.]
+ fmtmatch,fmtre: update for <regex.h> syntax extensions
+01-05-21 regex: add perl extensions, unicode names for collation elements
+01-05-11 string/chresc: \e == \E == escape, \cX == control X, \x{..} == \x..
+01-05-09 path/pathtemp.c: pathtemp(0,0,0,"/private",0) for mode S_IRUSR|S_IWUSR
+ port/touch.c: handle utime(2) EPERM to fix bug that truncated
+ regex: change REG_MINIMAL to avoid negation -- much faster now
+01-05-08 *.h: add some off_t macro guards for suse linux
+01-05-03 regcomp.c: optimize ((x)!)* to ((x)!)
+ wchar: add <wchar.h> and stdio wchar routines
+01-05-02 feaures/wchar: add <wchar.h> intercept, add stdio wchar functions
+01-05-01 string/strtoi.h: signed strtoi accepts qualified unsigned constants
+01-04-30 comp/setlocale.c: fix code that relied on 2 simultaneous getenv()'s
+ tm/tmlocale.c: check for UTF-8 encoded LC_TIME files
+ misc/magic.tab: add utf-8 and utf-16 U+FEFF magic
+01-04-26 features/common: some cc's have _ast_int8_t but not LL constants
+01-04-24 features/lib: add _std_strtod for mac os X
+01-04-23 ccode: add CC_sub for ms embedded EOF char on ebcdic -- no joke
+01-04-20 iconv: handle ebcdic<=>utf
+ mc.h,mc.c: add mcindex()
+ ast_std.h: add AST_MESSAGE_SET
+01-04-18 features/libpath.sh: fix mvs probe
+ *: sundry mvs fixes
+ glob: fix GLOB_NOCHECK to avoid stat() and properly trim patterns
+01-04-01 strtod,strtold: add
+ strtol,strtoul,strtoll,strtoull,strton,strtonl: handle locale & ERANGE
+ sfvprintf,sfvscanf: handle locale decimal_point,thousands_sep
+ sfvprintf,sfvscanf: handle %a,%A
+ setlocale: add LC_NUMERIC decimal_point,thousands_sep init
+ ast_std.h: __OPTIMIZE_SIZE__==1 to disable non-std __GNUC__ inlines
+ pathexists: path cache to cut down pathpath() access(2) calls
+ features/stdio: __FILE_TAG == _sfio_s for solaris
+01-03-23 iconv: fix iconv_move buffer boundary bug that stopped at 1 block
+01-03-19 glob: add GLOB_AUGMENTED
+ regex: REG_SHELL syntax error implies REG_LITERAL match
+ strto[ln][ll]: add overflow checks
+01-03-17 locale: reimplemented to provide canonical locale namespace
+ locale: add LC_ALL=local for local system user default
+ tm.h: TM_*_3 => TM_*_ABBREV
+ tmfmt: handle standard E and O format modifiers
+ tmlocale: consult nl_langinfo() if defined
+ fmtquote("\"",1) => shell quote
+01-03-08 regex: handle multibyte chars and collation classes
+ strmatch,strgrpmatch: now a wrapper on regex
+ ast_std.h: add mb*() multibyte and collation support
+ sfvscanf: handle locale decimal and thousand
+ proc*,system: handle ignored SIGCHLD
+ sfkeyprintf: handle %*C
+01-03-06 locale: add locale data cache for efficient multiple locale switching
+ optget: fix LC_MESSAGES!=C --man bug
+01-03-01 Makefile: HEADEROPT is not optional for win32.*
+ comp/syslog.h: comply with the de factos
+ optget(): fix \f...\f stack bug that referenced data after pop
+01-02-27 *locale*: a batch of fixes for native LC_MESSAGE&LC_TIME hooks
+01-02-22 pathprobe: reprobe test now checks probe.ini too
+ sfio_s.h: advertize public Sfio_t members with _ prefix
+ sfio.h,features/stdio: add <sfio_s.h> reference
+ sfhdr.h: map <sfio_s.h> _foo to foo
+ sfio.h: SF_APPEND=>SF_APPENDWR, SF_CLOSE=>SF_CLOSING
+01-02-14 comp/conf.sh: probe <unistd.h> for _(CS|PC|SC)_* getconf symbols
+ stdio/*: update for uwin stdio.dll binary compatibility
+ sfread: finally fixed premature pipe read EOF bug
+ fmtscale: format tenths for number > 0 && number < 10
+01-02-09 _sfmode(),_sftype(),_Sfextern: UWIN binary stdio compatibility exports
+01-02-08 sfgetm,sfputm,_sfputm: fix max clash with k&r max() macro
+ setlocale: undef valid for sun4 k&r valid() macro
+01-02-07 catopen.c: don't do native catopen for the debug locale
+01-02-06 sfraise.c: add SF_FINAL check to avoid (posibly) freed disciplines
+01-01-01 features/common: fix uwin __DEFINE__
+ sftable: initialize decimal and thousand
+ magic.tab: add corel wordperfect document
+ syslog: add LOG_LEVEL, add '\n' only if needed
+ include/tm.h: #undef daylight for _WIN32
+ sfio.h: add _SF_APPEND and _SF_CLOSE for native namespace incursion
+ ast_std.h: add AST_LC_multibyte for MB_CUR_MAX>1
+ setlocale: set AST_LC_multibyte
+ strmatch: check AST_LC_multibyte
+ features/limits.c: add _BITS_POSIX1_LIM_H guard for linux
+ features/libpath.sh: fix for aix LIBPATH
+ procopen,procclose: block SIGCHLD if PROC_FOREGROUND (e.g., system(3))
+ optget.c: add enumerated option argument values
+ optget.c: add <!--INTERNAL--> for private --html
+ optget.c: fix memory leak that hit shell builtins hard
+ sfio: drop sfread small chunk logic
+00-12-25 mnt.c: handle " and ' quoting for fstab
+ sftmp.c: let pathtemp() open the fd O_EXCL
+00-12-15 conf.sh: add -v for verbose trace
+ features/(limits|unistd).c: no FEATURE/types because of _POSIX_SOURCE
+ features/time: add default for CLOCKS_PER_SEC
+ features/lib: std_malloc now handles NeXT
+00-12-13 strton: recognize qualifier only if preceded by a digit
+ features/lib: change return in vfork() test to exit() for linux sparc
+ fmtquote: fix $'...' quote logic
+00-12-11 tmdate: fix cron format bug that mishandled months
+00-12-01 optget: handle $Id: ... $ in --?-version
+ features/fcntl.c: fix _STDPP_ mmap munmap
+00-11-27 magic: drop dup sfclose() in load()
+ optget: handle error_info.id==0
+00-11-22 features/stdio: add _FILEDEFED for sol9.sun4
+ strton,stronll: handle [u|U][l|L][ll|LL] qualifiers
+00-10-31 tmdate: add TM_DATESTYLE and mmddHHMM[cc]yy
+ astlicense.c: #include <hashkey.h> MAM workaround
+ astlicense.c: check for non-empty CONTRIBUTORS
+00-10-26 features/stdio: add _FILE and __FILE for gnu
+ misc/stk.c: fix stack pointer check off-by-one (dgk does it too!)
+00-10-23 syslog.h: sync with bsd values
+00-10-18 _STUB_* now functions instead of common symbols
+ all extern data declared with definition to eliminate common symbols
+ fastfind: add mac/bsd /var/db/locate.database
+00-10-17 features/lib: add apple osX (darwin.ppc) workarounds
+00-10-12 add: fmtbuf(), fmtclock(), fmtip4(), strtoip4()
+ fmt*() now use fmtbuf() for tmp fmt buf allocation
+00-10-05 regex: add REG_DISCIPLINE and regdisc_t for alloc/error disc
+00-09-29 features/lib: pipe_rw==0 for sgi: boot rw == bin incompatibility
+00-09-21 astlicense: handle \' and \" in license values
+00-09-20 sfwrite: fix write() error in sfprintf() loop
+00-08-11 hdr,vmhdr.h: check/hide { getpagesize sbrk } prototypes
+ astlicense: add noncommercial
+00-07-31 fflush: don't seek on pipes
+ sfresize: add
+ setlocale: fix bad newof() call
+00-06-01 strmatch: initialize match.current.beg[0] to avoid dump at line 670
+ sfio/stdio: a few more errno tweaks
+ astquery: sfstdin/sfstderr by default
+00-05-26 sfmode: errno=EBADF for invalid stream use
+00-05-22 rewind: fix for xopen test
+00-05-18 mcfind: returns absolute path
+00-05-16 optget: --keys must catch \f...\f too
+ translate,mc: errno cleanup
+00-05-09 magic: add netbsd binary magic
+ fts: PATH_RESOLVE!=logical => FTS_SEEDOTDIR
+ ftwflags: call fts_flags()
+ astconf: astconf(0,0,0) re-syncs with _AST_FEATURES
+00-05-08 optget: --usage & --keys for last -catalog group only
+00-05-02 iconv.c: add; use codes[] in ccmapid() and ccmapname(); "" for native
+00-05-01 pathtmp: copy env values (libshell or putenv may change)
+00-04-01 optget: drop bar from [-foo?bar] for --??keys
+ sfvscanf: add %X -- duh
+ features/common: fix va_listval() for power pc
+ findopen: fix FIND_GENERATE codes file search
+ magic: add ERROR_translate() and msgcat.key
+ tmlocale: add for LC_TIME locale info
+ tmlex: check tm_info.format and tm_data.format
+ tmfix: fix for tm_wday special case (via nl_langinfo on LC_TIME fields)
+ strftime: fix for nl_langinfo special case
+ ast_std.h: provide LC_* defauls if not defined
+ sfnew: check ${_AST_sfio_bufsize} -- don't tell kpv
+ catopen,nl_types.h: add intercept to mc* routines
+ magic.tab: add ast message catalog
+ strerror: add _ast_strerror intercept with ERROR_translate("errno")
+ fmtquote: escapes >0177 only if (flags&2)
+00-03-17 feof: stdio macro functions only for _UWIN
+ optget: proper ERROR_translate() calls
+ astgetconf: add for thread safe error message control
+ astlicense: fix type=special but with non-null notice
+ errorx: add for ERROR_translate() support
+ ERROR_translate: add locale id args for alternate dictionary
+ option.h: move _OPT_PRIVATE_ to pointer to avoid dll size mismatch
+ ftwalk: fix FTW_CHILDREN bug that hit top level non-dirs twice
+ translate.c: default error_info.translate
+ astconf: fix dup loop thrash that never returns, add _AST_VERSION
+00-03-10 ast_std.h: do _LARGEFILE_SOURCE initialization before std headers
+ fmtquote: handle $'...' quotes
+00-03-07 optget: fix numeric option support test
+ sfkeyprintf: add %q for '...' quoting with ansi escapes
+00-03-06 features/stdio: fix _sfflsbuf prototype (dingold@gte.net)
+00-02-14 pathtmp: fix pid cache bug that sometimes repeated after ~10 attempts
+ optget: "..." attribute quote
+ pathfind: eliminate *: prefix in lib, not type
+ proc: PROC_FOREGROUND for system(3) semantics (wait status return)
+ pathtmp: fix mktemp() logic
+ fts: fix FTS_NOSEEDOTDIR bug that botched ./* in top list
+ include/ast/prototyped.h includes include/prototyped.h
+ pathpath: fix strdup(0) bug
+ optget: --html <foo@bar> => ...mailto:foo@bar...
+ sscanf: fix sfsscanf => sfvsscanf typo
+ magic.tab: strengthen tar recognition
+00-02-08 conf.sh: fix ifdef for systems that think sysconf(FOO) is const
+00-02-04 glob: fix globlist_t.gl_flags
+00-02-02 vm*: add NoF() for data only files
+00-01-27 fts: fix top level .==.. statp bug (thanks to dr. ek)
+00-01-25 conf.tab: fix LFS*_*LAGS typo
+00-01-24 astlicense: handle type=verbose, license.notice, author=*
+00-01-11 pathprobe: generate info for first probe script on PATH - duh
+ ast.h: add NoF(x) for files that define no functions
+ tmpfile: fix implementation
+ global change for string ERROR_translate() dictionary names
+ optget: fix new way but no long names off by one
+ optget: handle [--dictionary?name]
+99-11-19 comp/conf.sh: `expr length XXX` is not universal
+ drop sfstdio; stdio via functions everywhere
+ drop Makefile conditionals (and follow our own advice for once)
+ sfio: new stream after atexit() bug fix
+ tm: Tm_zone_t.daylight=0 for standard time within zone
+ stdio: fopen => _ast_fopen: only way short of binary compatibility
+ Makefile: atmain.C falls back to atmain.c
+ optget: add --keys, s<section> option
+ stdio: _UWIN check for foreign stdio
+99-11-11 astlicense: add
+99-10-31 glob: fix regexec pattern; add PATH_ATTRIBUTES case check
+ pathpath: path==0 means malloc space
+99-10-22 tmfmt: %C=2-digit-century, %k=date(1), %y=2-digit-year-in-century
+99-10-18 fastfind: expanded default db lookup
+99-08-11 magic: fix off by one registry malloc
+ features/fs: add __RENAME checks for stat familiy (netbsd)
+ features/fs: major()/minor() fixes for s5
+ features/libpath.sh: netbsd fix -- ld.so not in std places
+ misc/fastfind: fix codes path generation bug
+ optget: beef up --?* description, fix <TR>...</TR> nesting
+ pathprobe: check for override (writable key file) first
+ features/time: int tmtimeofday(struct timeval*);
+ optget: fix opt_info.num, even if opt_info.arg!=0
+ fts: FTS_PHYSICAL => FTS_SEEDOTDIR, add FTS_CHOP
+ fastfind: init dir tab with logical and physical name
+ glob: add gnu GLOB_ALTDIRFUNC
+99-07-17 sfio: kpv update and sfhdr.h sync!
+99-06-24 stdio: fix fflush() to ignore sfseek(0) return value
+99-06-23 magic: '\r' is text not control to placate m$
+99-06-08 stdio: fix fseek,ftell semantics
+ uwin stdio: fflush() => _doflsh() to avoid __cplusplus clash
+ getopt: call liberror() to avoid error() conflict
+ tmfmt,tmscan: %N zone type (nation code), %z zone minutes west offset
+ tmfmt: - no pad _ space pad 0 leading 0 pad
+99-05-28 magic: fix 'x' == '*' for any number, magic.tab tweaks
+ features/lib: verify that stat64 really works
+99-05-21 tm*: add TM_WINDOW==69 for consistent century windowing guard year
+99-05-18 tmtime: add century leap year calc anticipating unsigned time_t
+99-05-17 sfkeyprintf: handle %o and %x!!
+99-05-09 pathprobe: $HOME/.probe if not suid and st_uid!=geteuid()
+99-04-28 magic,magic.tab: add registry()
+99-04-24 regcomp: fix ksh pattern +! parse
+ regfatalpat: add
+ optget: make : ? ] double escape consistent in all contexts
+99-04-01 features: drop iffeio.h and stdio.h when only printf() used
+ regex: fix stats() .l and .k count
+ fmtquote: added; most general fmtesc() form
+99-03-22 fmtesc.c,ast.h: add fmtnesq()
+ optget: --?x works for -x option flag
+99-03-17 features/limits.c: workaround solaris __EXTENSIONS__ _timespec bug
+ workaround limits.h circular prereq with ignore stdio.h
+ sfvprintf: %04e left-pad zero fixed
+99-03-03 fts: uncle already: add FTS_SEEDOTDIR to retain leading ./
+ regex: REG_MULTIPLE, BM for fixed string alternation
+ optget: embedded `-' optional in long options, prefix={0,1,2}
+99-02-14 fastfind: fix dir format bug that emitted wrong paths
+ astconf: fix redef off by one bug
+99-02-11 pathcanon(): don't cache astconf("PATH_LEADING_SLASHES", NiL, NiL)
+99-01-23 optget: move <old_opt.h> back into <option.h>, no open-close
+ optget: add "[index:long-name:description]" for --long-name
+ comp/gross: add weak __libc_attr for irix < 6.5 compatibility
+ features/limits.c: tweak the guards again
+99-01-11 fastfind: handle old format count byte order
+ magic.tab: fix elf to use real phdr offset
+ magic.c,magic.tab: fix | to act like switch/case
+ comp/fross.c,features/hack: for gross hacks
+ features/stdio: avoid sfio namespace pollution
+98-12-25 tmdate: yyyy.mm.dd
+ pathprobe: fix procrun() cmd path bug
+ fmtesq: add
+ features/common: win32.alpha va_list
+ magic: add pc alpha object
+98-11-11 strmatch: add STR_ICASE
+ pathprobe: punt to $HOME/.probe/<key+HOSTTYPE> if not S_ISUID
+ tmzone,tmdate: handle +-minutes, nn/MMM/yyyy
+ stropt: fix nested quote pop
+ tmfmt: add %K => %Y-%m-%d/%H:%M:%S
+ sfio/stdio: fix fseek() SF_PUBLIC omissions
+ fmtesc: catch '\\' (duh)
+ vmalloc: vmbest round bug fix
+98-11-01 fts.c: no pathcanon() if (fts_flags & FTS_PHYSICAL)
+98-10-01 features/stdio prototype fixes
+ optget: strton() instead of strtol() for #
+98-09-22 regcomp: add REG_DELIMITED and REG_ESCAPE delimited re support
+98-09-15 fix _LARGEFILE64_SOURCE stuff
+ ast_std.h: provide mmap() prototype
+98-08-11 fix sfpopen() to ignore SIGPIPE by ignoresig() for sfio but not stdio
+ fix procopen() to ignore SIGPIPE by ignoresig() for PROC_IGNORE
+ sfio sfpopen/popen update
+ magic.src: fix ustar entry
+98-07-17 fix ftwalk() short by one malloc()
+ add fts_notify()
+98-06-25 sfdcmore,sfdcprefix: add
+98-06-19 tokscan: add %f %g
+98-06-01 disc/sf*.c: memset(0) after disc malloc()
+98-05-11 strelapsed: y==Y
+ fts: pathcanon() top list
+98-04-01 error: error_info.time for all msgs, just after cmd id
+ error: no sfsync(sfstdin)
+ sfio: sfpool, Sffmt_t update
+ magic.tab: sgi core dumps -- why aren't these elf?
+ stropt: (v+n) for unknown option is option value if n!=0
+ procopen: fix setsid() for spawnveg() only
+98-03-19 malloc: add realloc foreign region check
+ sfdisc.h: rename to match kpv disciplines
+ fastfind: fix strcasecmp/strcmp directory prefix mixup
+98-03-17 features/fcntl.c,pathtmp,sftmp: add O_TEMPORARY
+98-03-01 pathcanon: fix PATH_LEADING_SLASHES to stat() both slashes
+ pathcanon: add PATH_VERIFIED
+ tmdate: add skip[] to expand separator char set
+ fastfind: FIND_OLD for old 7 bit db, FIND_TYPE for new 8 bit typed db
+ fastfind: default generates gnu LOCATE02 8 bit db
+ magic: handle %s in mime description
+ cdt: kpv update
+ sfio: kpv update
+ stdio: fpos64_t fseek64(), ftell64(), fgetpos64(), fsetpos64()
+ stdio: fseek() => sfseek(SF_PUBLIC) to avoid locking
+ fts: initialize parent stat[bp] from top level *after* statf done
+ astmath: add -lm requirement test
+ *: Astlong_t => _ast_*_t
+ regex: simplify regcollate() (from doug)
+ tmtime: preserve Tm_t*tm when calling tminit()
+ astconf: add readonly PATH_ATTRIBUTES=[cirw]
+98-02-14 fastfind: add FIND_ICASE to ignore case
+ tmdate,tmgoff: handle (+|-)hh[[:]mm[[:]ss]] absolute timezone
+ tmdate: `<n> <part>' now assumes `next <n> <part>' instead of `this'
+ tmfix: fix leap year bug that forgot to add 1900
+ proc: add PROC_ZOMBIE
+98-02-06 strmatch() char class range bug fix
+ regex char class range bug fix
+98-01-23 _WIN32: changed the #if logic again to accomodate _GNUC_
+ mnt: grab the mount options too
+ ast_std.h: hide getopt,getsubopt from stdlib.h
+ features/limits.c: add gnu guard macros to avoid limits.h recursion
+ features/mode.c: include "limits.h" instead of "FEATURE/limits.lcl"
+98-01-11 sfio.h: use Astlong_t, move Sfio_t Sfdisc_t typedef to top for stdio.h
+ sfhdr.h: #undef SETLOCAL for hpux
+ sfvprintf,sfvscanf: %I*x for sizeof(int_arg)
+ handle ftruncate64 and truncate64
+ dtopen.c: __hppa dll needs Dtset Dtlist Dttree refs here
+97-12-18 fmtnum: add
+97-12-11 magic: handle sgi 64 bit core dumps
+97-12-07 pathtmp: add override for TMPPATH,TMPDIR and cycling
+97-11-11 tm: handle 0 return from gmtime(),localtime() (dos negative time_t)
+ features/stdio: fix fflush() macro to do physical sync
+97-10-31 astconf PATH_RESOLVE is logical if 3d&&!std, metaphysical otherwise
+ magic: fix #! mime bug
+ tm: tmtime() now calls tmfix() and adjusts tm_isdst too=>mtime() works
+97-10-11 dllfind,dlfcn: move to separate -ldll so -last can link static, duh
+ Makefile,state.c: move forced header generation state.c => Makefile
+ sfio: update including SF_WHOLE
+97-10-01 sfdostext: add \r\n => \n sfio discipline
+ stropt: NiL table => p=name for all name=value
+97-08-11 pathtmp: check pid to note forks
+ procopen: FD_CLOEXEC rfd && wfd
+ fts: fts_close() after fts_children() with no fts_read() now works
+97-07-17 error: sfsync(sfstdin,sfstdout,sfstderr) instead of sfsync(NiL)
+ _sfcvinit: add sfio internal interface to base conversion tables
+ strton: use _Sfcv* base conversion tables instead of sfsscanf()
+ sfvscanf: use _Sfcv* base conversion tables
+ mime: x- permutations now matched if exact fails
+ mime: original- stripped from content-* headers
+ tmdate: add yyyy-jjj, yyyy-mm-dd
+ dllfind: add
+ ccmapid: fix buf copy loop limit
+ ccmapname,ccmapcpy: add
+ sfstrtmp: add
+97-05-09 streval: fix up casts for pseudo-ansi cc
+ features/types: use _ast_int_8 vars to verify support
+ string/modedata: check for mvs.390 S_IFMT
+ include/ast(_std).h: add #define __FILE_typedef
+ magic: add ccode text check
+ include/ftwalk.h: FTW_PATH=>FTS_NOCHDIR to avoid FTS_AGAIN (duh)
+ fts: clear status for FTS_AGAIN (fixes rm -r bug)
+ mnt: add mvs openedition w_getmntent()
+ sfhdr: _hdr_float && <float.h> for correct MAXDOUBLE
+ vmalloc/vmbest: if _std_malloc then use malloc()/free() not sbrk()
+ remove: check _std_remove
+ procopen: handle pio[{0,1}]=={0,1}
+ setenviron,features/uinstd: test for mvs.390 dll environ hacks
+96-12-25 <sfio_p.h> -> <ast_common.h>
+ __EXTERN__(type,object)
+ __DEFINE__(type,object,value)
+ magic: check strings in !CC_NATIVE code set too
+ system: cmd==0 means check for shell access (xopen)
+ sfhdr.h: fix sfrsrv prototype
+ add __libc_malloc etc for gnu/linux
+ astconf(NiL,path,name) == astconf(name,path,NiL) + no liberror
+ fts_open: if toplist() stat fails return 0
+ ftwalk: handle fts_open()==0 via one phony userf() call
+ sfmode: S_ISFIFO default is SF_SHARE=0
+ features/lib: _WIN32 _lib_vfork=1 by default
+ unsigned<0 comparison and other fixes via sgi.mips4 cc
+ stk.c: use <align.h> ALIGN_BOUND for stkalloc()
+ features/lib,vfork: uwin fix
+ ast_std.h: fix strto[u]ll prototypes with features/types _ast_int_8
+ getsubopt: add for xopen 4.2 compatibility
+ drop function __IMPORT__
+ magic: more magic
+ change #define FILE from Sfio_t to struct _sfio_s
+ state.c: add generated includes that may be hit by std for MAM
+ bytesex: forgot about sizeof(long)=>7; could we fix the name too?
+ vmalloc.h: fix vmnewof() definition
+ sfio.h,stdio.h,ast_common.h: pollution cleanup
+ magic.c: add | op for switch
+ Makefile: stdio.h was on both HEADERSRC and HEADERGEN -- don't do that
+ drop pp:notice to get <sfio.h> ... <ast.h> to work
+ regex: add [[:<:]]==\< and [[:>:]]==\> for bsd compat
+ mime.c: ignore X-* headers while scanning for Content-*
+ magic.c: check for negative indirect offsets
+ magic.tab: fix dos entry that generated negative indirect offsets
+ vmalloc.h: add vmstrdup() prototype
+ hash.h: add hashgetbucket() macro
+ magic.c: MAGIFILE is now a : file list
+ mnt.c: another 4.4 bsd fix -- users must include <sys/crap.h>
+ common: fix _WIN32 chicken&egg with va_copy
+ sfio: forgot to set f->val along with _Sfi in sfexcept()
+ Makefile: add mini target for uwin libmini.a
+ sfcvt.c: workaround for flaky long double optimizers
+ features/common: fix to work with va_list==void*
+ regexec.c: fix REG_STARTEND subexpression offsets
+ strmatch.c: don't forget <wctype.h>
+ regrexec.c: fix REG_INVERT end boundary bug that missed last record
+ astconf.c: notify(0,0,"a=b") called for each setenviron("a=b")
+ pathcanon.c: check astconf(PATH_LEADING_SLASHES) to preserve //*
+96-11-28 _LARGEFILE64_SOURCE by default if possible: NOTE: assumes xopen
+ regerror: fix for xopen
+ getopt: fix for xopen
+ magic: add ciao virtual database
+ astconf: posix/strict/xopen implies "standard" conformance
+ fs3d.h: hide mount prototype
+ ast_std.h,mnt.c,features/fs: ncr port tweaks
+96-10-31 version 5.0
+ add strtoll() strtoull()
+ sfkeyprintf: upgrade to int_max args
+ ast.h: add ssizeof() to work around unsigned botch
+ conf.sh: add shell actions to conf.tab
+ _DLL*: drop for _BLD_<lib> + __EXPORT__ + __IMPORT__
+ sfio,cdt,vmalloc: kpv update
+96-10-11 <ccode.h>: add character code map support
+ procclose: return shell style exit status
+ features/fs: pun statvfs.f_basetype to statvfs.f_reserved7 for mvs
+ uwin: add subdir for uwin additions
+ ast_std.h: swab() is from <stdlib.h>
+ sfio.h: <ast_std.h> if _PACKAGE_ast
+ magic.tab: add mips[1-4], 64-bit
+ port tweaks for sol.sun4 and sun4
+96-09-06 strerror: add
+ fmterror: uses strerror
+ str*search: use sfiso646() order
+ strpsearch: add
+ magic: add Magic_t.mime mime type return for magictype()
+ mime.h: add
+ strton: use sfsscanf()
+ strperm: factor in umask() if no who
+ pathtmp: add TMPPATH check
+ libevent: add
+ magic: add discipline to magicopen()
+ mime: add discipline to mimeopen()
+96-08-31 regex: fix BM fail table generator
+96-08-11 mntread: fix mnt.type for SCO variant
+ conf.tab: add SCO KERNEL_* sysconf() vars
+ fastfind: add findwrite(), fix findread() FF_OFF omission
+ ftwalk: reimplement on top of fts
+ fnmatch,re_comp,regexp: reimplement on top of regex
+ basename,dirname,fmtmsg,fts,ftw,getdate,getsubopt,glob: add
+ hsearch,nftw,realpath,strftime,strptime,swab,tempnam: add
+ tsearch,wordexp: add
+ getcwd: cache last path for easy test
+96-07-17 error: sfsync(NiL) ... write ... sfsync(sfstderr)
+ astconf: handle readonly *(DEV|DIR) vars
+96-04-01 swapop: fix stupid return value bug
+ features/int.c: fix int_swap generation bug
+ regnexec,regrexec: fix unsigned underflow init error
+ ls.h: fix iblocks() to be in units of LS_BLOCKSIZE
+96-02-29 magic: space before function is definition with no call
+ hash: drop hash_info from public interface
+ hash: OBSOLETE hashlast()
+ hash: add Hash_root_t.Hash_last_t to public interface
+ add strsearch() and strnsearch() to complement strlook()
+ add hashkey.h for keyword->long hash
+ pathpath: pathpath(0,0,"",0) disables $0 $_ $PWD relative search
+ sfio: sfstrtod+sfhdr update
+ regex: fix REG_LENIENT to map BRE \[+?|] to ERE [+?|]
+ change _std_malloc iffe test so it doesn't hang on alpha
+ sfhdr.h: features/sfio generates _lib_cvt instead of _i386_cvt
+ ast_hdr.h: add va_copy(a,b) to copy va_list b to a
+ getopt: fix stupid getopt() -> optget() bug
+ sfvprintf: %h? now downcasts
+ regex: handle strto?l() errno in regcomp()
+ sfstrtod: _Sfstrtod_already_defined -> _STUB_sfstrtod
+ ast_std.h: hide valloc() and ignore <strings.h>
+ sfkeyprintf: pass phony va_list for '2'
+ regex: change HIT var type from int to size_t in special()
+ ast.h: add EXIT_STATUS(x) to convert wait() status to sh exit status
+96-02-14 regex: add _ to \<...\> isalnum test
+ regex: fix BM inner loop breakout
+ features/types: size_t is signed on some systems! => _ast_size_t
+ sfio: sfrd discipline peek optimization
+ vmalloc: vmalloc.h malloc family macro upgrade
+ tokopen: fix newline bug for non-restore open
+ sfio: no inline for gcc until it emits for -g too
+96-02-12 sfio: internal upgrade
+96-02-09 regex: Boyer-Moore boundary fix
+ vmalloc: snarf latest
+96-02-06 regex: add regrecord() and regrexec() for Boyer-Moore record filtering
+ regex: rearrange regnexec() args to match buffer,count arg style
+96-01-31 stk: add STK_NULL to stk.h and stk.c
+ regex: privatize regex.h and fix min re length computation
+ workaround lazy strdup() implementations in features/lib _std_malloc
+ fix stkclose() to free(stream) -- purify missed because of sfio links
+ unused var cleanup
+ port/mnt.c must include <ls.h> to get <ast_fs.h>
+ add SF_FINAL to sfio and stk
+ sfio reads now on natural block boundaries
+ add #!!! <level> <message> !!! to tokline()
+ add REX_BM pre-filter to regcomp/regnexec
+96-01-22 add regcomp env.paren overflow checks
+96-01-11 add Doug McIlroy's regex (converted to C from C++ by gsf)
+ AT&T Research now
+ sfgetr optimization
+ regex buglets
+96-01-05 tweak magic.tab for win32
+95-12-25 add !(...) -> (...)! to fmtre()
+ nt tweaks -- functions with no header proto must be defined extern
+95-11-24 version 4.1
+ add mnt.h mntopen mntread mntclose
+ convert fmtfs to mnt.h
+ add RE_LEFTANCHOR and RE_RIGHTANCHOR
+ gcc inlines must also have global library function instantiation!
+ add hashview()
+ fix strtape() internal buffer flow
+ fix mntread() fs/dir transposition for uts mnttab
+95-10-31 change features/unistd.c includes to break limits-param cycle
+ add cdt from kpv
+ sfio snarf from kpv
+ add [ht]search for _WIN32
+95-10-11 clarify PARANOID pathcheck() warning
+ fix procopen() LIB_SPAWN environ bug with setenviron() cache
+ fix setenviron() bug that forgot to reset environ if == 0
+ add %Z '\0' output format to sfkeyprintf()
+ sfio snarf for sfvprintf fix
+ allow multiple hashscan() with scope caveat
+ add comp/fakelink.h to synthesize a few symlink text patterns
+ add !<xxx> magic to misc/magic.tab
+ add FTW_TOP to inhibit recursion (for ftw side effects on top level)
+ add memfatal() common malloc fatal exception message
+ add dos \r\n test to misc/magic.c/cklang()
+ sftmp() O_EXCL+random to avoid collisions
+ pathtemp() uses sftmp() randomizing
+ features/fs uses SF_APPENDWR
+ sftmp() uses pathtemp() -- don't worry, its not circular
+ a few more _WIN32 compatibility additions
+ realloc fixed to use VM_RSCOPY|VM_RSMOVE instead of obsolete 1
+ add hashlook(tab, oldname, HASH_RENAME, newname)
+ a few more tweaks to satisfy port warnings
+ add _SFIO_INLINE_PRIVATE to provide real function too
+ fix <dirent.h> installation test
+ oops object / shared library compat with _sfgetl2 _sfgetu2
+95-09-11 add getopt() compatibility
+ add fstat,lstat,mknod,stat fixes for _x versions in sys/stat.h
+ add getconf CONFORMANCE - posix for things that aren't ast default
+ sfio_t.h: #ifndef _SFIO_H #include "sfio.h" #endif
+ snarf vmalloc from kpv
+95-08-11 fix malloc bug in magic
+ update linux and bsd 386 magic entries
+ error_info.auxilliary returns new level, |=ERROR_OUTPUT if msg done
+ drop fnmatch from strmatch for sparc (solaris) until it collates
+95-07-17 fix port/astconf universe initialization
+ fix misc/optget opt_info.nopt initialization
+ drop tmset() TZ=... because it only worked when TZ=... was ignored
+95-05-09 mongo <ast.h> namespace cleanup
+ drop > 2 year old obsolete interfaces
+ sfvprintf.c fix for (char:8 short:16 int:32 long:64) architectures
+ TMP_MAX back into conf.tab
+ pathbin() and pathshell() now use astconf()
+ fix pathtemp() to not cache getenv("TMPDIR")
+ fix ftwalk() metaphysical to handle non-dirs too
+ initialize *_info = { 0 }; for ancient ld semantics (NeXT)
+ fix magic() to do vmfree()
+ astconf(X_OK) must prefix lines with "getconf"
+ use <wchar.h> and wctype in strmatch() if available
+ _lib_utime_now checks utime(path,0)
+ _lib_poll_notimer checks poll(x,0,timeout)
+ add another _lib_utime_now check to port/touch.c
+ fix dd_buf cast in dir/opendir.c
+ split getconf.h into conftab.h and conftab.c for :READONLY:
+ use mbtowc() only if MB_LEN_MAX>1
+ sfio char* -> Void_t* cleanup
+ handle old syntax in misc/magic.c
+ sigdata.c holds readonly signal strings
+ pathcheck() does AT&T checks for tools matching PARANOID - yuk
+ unused var cleanup
+ deprecate hash_info in favor of hashlast()
+ fix bad conf.sh ksh integer interactions
+ dll cleanup
+ magic.c falls back to malloc for now
+ add environ to <ast.h> -- C library global data syms are *RESERVED*
+ sfhdr.h memccpy(1,2,3,size_t) prototype
+95-04-01 version 4.0
+ convert to vmalloc
+ allow sigcritical() nesting mismatch to work around vfork() bug
+ add strexpr() primitive for streval() with user handle (like ftwalk)
+ add <magic.h> and magic.c file command magic interface
+ update magic mail message entry
+ fix keyprintf() invisible char count nesting bug
+ add sfstrnew(SF_READ|SF_WRITE) for alternate sfstropen() modes
+ sfstrnew(SF_READ) but reading requires sfseek(), sfreserve()
+ add conf.tab and conf.sh to nail C/POSIX limits/unistd macros
+ add getconf() string interface to *conf*
+ _DLL_INTERMEDIATE_DATA for systems that require indirect globals
+ _DLL for building shared libraries with _DLL_INTERMEDIATE_DATA
+ vecfile() restricted to S_ISREG()
+ add spawnveg() for job control
+ convert procopen() PROC_PGRP(id) to spawnveg()
+ fmterror() returns error text given errno (strerror() does same)
+ fmtsignal() returns signal text given errno (strsignal() does same)
+ {sig_name,sig_text,SIG_MAX} -> sig_info.{name,text,sigmax}
+ liberror("",...) omits [%s library] prefix
+ update features/signal.c table
+ add vmdisc() and change vmnewof() to use vmresize()
+ fix conf.sh to allow refs to previously defined limits
+ fix undefined entries in getconf()
+ magic data in magic.tab
+ fix stropt() pointer cast
+ vmalloc() exception handler replaces nomalloc()
+ merge sigdata.c into fmtsignal.c -- sun link needs function w/ data!
+ sftmp() bug fix
+ drop local <unistd.h> even with _POSIX_SOURCE
+ fix vmstrdup() macro arg miscount
+ fix conf.sh to handle enum'd symbolic constants in unistd.h
+ drop malloc() et.al. prototypes from vmalloc.h
+ fix sfvprintf() %d argument reference
+ add OSF/1 AES symbol(s) to conf.tab
+ determine standards prefix from conf.tab
+ add _CS_SHELL to conf.tab
+ getpath() default is confstr(_CS_PATH)
+ getshell() default is confstr(_CS_SHELL)
+ unify keyprintf user function args (should have learned by now!)
+ add quad type to magic
+ add astfeature() to unify universe style dynamic features
+ add ftwflags() to determine FTW_* flags from astfeature()
+95-03-11 fix stropt() to not modify its *const* arg
+ handle "'\ quotes and chresc() in stropt() values
+ , treated like :space: between stropt() options
+ fix procopen() fd dup to ignore self-dups
+ add library id[] to misc/state.c
+ add ftwalk(FTW_METAPHYSICAL) for posix -H
+ sfvprintf() now handles balanced () in %()
+ add tmfmt() with buffer size check to replace tmform()
+ add fmttime() calling tmfmt() to fit fmt*() mold
+ add <keyprintf.h> and keyprintf() to support %(...)? in commands
+ add Hash_table_t for size==0 in stropt()
+ add EXTTYPE extended header to tar.h
+95-02-14 sfmove() buffer size overflow fix
+ add _SFSTDIO_H to sfio.h
+ rename setenv() to setenviron() -- posix finally decided
+ rename <option.h> opt_* to opt_info.*
+ update features/unistd.c for _SC_* and _PC_* posix additions
+95-01-19 (char*)uchar cast in fmtesc()
+ fix hash bucket memory leak in hashlook() [via John Mocenigo]
+ update strings/strtape()
+ fix optget()/optjoin() to handle leading +
+ add ALIGN_ prefix to <align.h> identifiers
+95-01-11 change tm/*.c tmset(0) to tmset(tm_info.zone) to keep user setting
+ fix tmform() %Z null pointer dereference
+95-01-01 add this RELEASE file
+ fix strperm() to properly handle "644 file"
+ fix tokline() to return last '\0' terminated line in string
+ fix tokscan() to properly handle \\n splice
+ add fmtesc() to complement stresc()
+ add LS_NUMBER to fmtls()
+ drop spurious optusage() ' '
diff --git a/usr/src/lib/libast/common/cdt/dtclose.c b/usr/src/lib/libast/common/cdt/dtclose.c
new file mode 100644
index 0000000000..b3b17bbbeb
--- /dev/null
+++ b/usr/src/lib/libast/common/cdt/dtclose.c
@@ -0,0 +1,69 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "dthdr.h"
+
+/* Close a dictionary
+**
+** Written by Kiem-Phong Vo (05/25/96)
+*/
+#if __STD_C
+int dtclose(reg Dt_t* dt)
+#else
+int dtclose(dt)
+reg Dt_t* dt;
+#endif
+{
+ Dtdisc_t *disc;
+ int ev = 0;
+
+ if(!dt || dt->nview > 0 ) /* can't close if being viewed */
+ return -1;
+
+ /* announce the close event to see if we should continue */
+ disc = dt->disc;
+ if(disc->eventf &&
+ (ev = (*disc->eventf)(dt,DT_CLOSE,NIL(Void_t*),disc)) < 0)
+ return -1;
+
+ if(dt->view) /* turn off viewing */
+ dtview(dt,NIL(Dt_t*));
+
+ if(ev == 0) /* release all allocated data */
+ { (void)(*(dt->meth->searchf))(dt,NIL(Void_t*),DT_CLEAR);
+ if(dtsize(dt) > 0)
+ return -1;
+
+ if(dt->data->ntab > 0)
+ (*dt->memoryf)(dt,(Void_t*)dt->data->htab,0,disc);
+ (*dt->memoryf)(dt,(Void_t*)dt->data,0,disc);
+ }
+
+ if(dt->type == DT_MALLOC)
+ free((Void_t*)dt);
+ else if(ev == 0 && dt->type == DT_MEMORYF)
+ (*dt->memoryf)(dt, (Void_t*)dt, 0, disc);
+
+ if(disc->eventf)
+ (void)(*disc->eventf)(dt, DT_ENDCLOSE, NIL(Void_t*), disc);
+
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/cdt/dtdisc.c b/usr/src/lib/libast/common/cdt/dtdisc.c
new file mode 100644
index 0000000000..d38fd77dc9
--- /dev/null
+++ b/usr/src/lib/libast/common/cdt/dtdisc.c
@@ -0,0 +1,129 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "dthdr.h"
+
+/* Change discipline.
+** dt : dictionary
+** disc : discipline
+**
+** Written by Kiem-Phong Vo (5/26/96)
+*/
+
+#if __STD_C
+static Void_t* dtmemory(Dt_t* dt,Void_t* addr,size_t size,Dtdisc_t* disc)
+#else
+static Void_t* dtmemory(dt, addr, size, disc)
+Dt_t* dt; /* dictionary */
+Void_t* addr; /* address to be manipulate */
+size_t size; /* size to obtain */
+Dtdisc_t* disc; /* discipline */
+#endif
+{
+ if(addr)
+ { if(size == 0)
+ { free(addr);
+ return NIL(Void_t*);
+ }
+ else return realloc(addr,size);
+ }
+ else return size > 0 ? malloc(size) : NIL(Void_t*);
+}
+
+#if __STD_C
+Dtdisc_t* dtdisc(Dt_t* dt, Dtdisc_t* disc, int type)
+#else
+Dtdisc_t* dtdisc(dt,disc,type)
+Dt_t* dt;
+Dtdisc_t* disc;
+int type;
+#endif
+{
+ reg Dtsearch_f searchf;
+ reg Dtlink_t *r, *t;
+ reg char* k;
+ reg Dtdisc_t* old;
+
+ if(!(old = dt->disc) ) /* initialization call from dtopen() */
+ { dt->disc = disc;
+ if(!(dt->memoryf = disc->memoryf) )
+ dt->memoryf = dtmemory;
+ return disc;
+ }
+
+ if(!disc) /* only want to know current discipline */
+ return old;
+
+ searchf = dt->meth->searchf;
+
+ UNFLATTEN(dt);
+
+ if(old->eventf && (*old->eventf)(dt,DT_DISC,(Void_t*)disc,old) < 0)
+ return NIL(Dtdisc_t*);
+
+ dt->disc = disc;
+ if(!(dt->memoryf = disc->memoryf) )
+ dt->memoryf = dtmemory;
+
+ if(dt->data->type&(DT_STACK|DT_QUEUE|DT_LIST))
+ goto done;
+ else if(dt->data->type&DT_BAG)
+ { if(type&DT_SAMEHASH)
+ goto done;
+ else goto dt_renew;
+ }
+ else if(dt->data->type&(DT_SET|DT_BAG))
+ { if((type&DT_SAMEHASH) && (type&DT_SAMECMP))
+ goto done;
+ else goto dt_renew;
+ }
+ else /*if(dt->data->type&(DT_OSET|DT_OBAG))*/
+ { if(type&DT_SAMECMP)
+ goto done;
+ dt_renew:
+ r = dtflatten(dt);
+ dt->data->type &= ~DT_FLATTEN;
+ dt->data->here = NIL(Dtlink_t*);
+ dt->data->size = 0;
+
+ if(dt->data->type&(DT_SET|DT_BAG))
+ { reg Dtlink_t **s, **ends;
+ ends = (s = dt->data->htab) + dt->data->ntab;
+ while(s < ends)
+ *s++ = NIL(Dtlink_t*);
+ }
+
+ /* reinsert them */
+ while(r)
+ { t = r->right;
+ if(!(type&DT_SAMEHASH)) /* new hash value */
+ { k = (char*)_DTOBJ(r,disc->link);
+ k = _DTKEY((Void_t*)k,disc->key,disc->size);
+ r->hash = _DTHSH(dt,k,disc,disc->size);
+ }
+ (void)(*searchf)(dt,(Void_t*)r,DT_RENEW);
+ r = t;
+ }
+ }
+
+done:
+ return old;
+}
diff --git a/usr/src/lib/libast/common/cdt/dtextract.c b/usr/src/lib/libast/common/cdt/dtextract.c
new file mode 100644
index 0000000000..28d455740d
--- /dev/null
+++ b/usr/src/lib/libast/common/cdt/dtextract.c
@@ -0,0 +1,55 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "dthdr.h"
+
+/* Extract objects of a dictionary.
+**
+** Written by Kiem-Phong Vo (5/25/96).
+*/
+
+#if __STD_C
+Dtlink_t* dtextract(reg Dt_t* dt)
+#else
+Dtlink_t* dtextract(dt)
+reg Dt_t* dt;
+#endif
+{
+ reg Dtlink_t *list, **s, **ends;
+
+ if(dt->data->type&(DT_OSET|DT_OBAG) )
+ list = dt->data->here;
+ else if(dt->data->type&(DT_SET|DT_BAG))
+ { list = dtflatten(dt);
+ for(ends = (s = dt->data->htab) + dt->data->ntab; s < ends; ++s)
+ *s = NIL(Dtlink_t*);
+ }
+ else /*if(dt->data->type&(DT_LIST|DT_STACK|DT_QUEUE))*/
+ { list = dt->data->head;
+ dt->data->head = NIL(Dtlink_t*);
+ }
+
+ dt->data->type &= ~DT_FLATTEN;
+ dt->data->size = 0;
+ dt->data->here = NIL(Dtlink_t*);
+
+ return list;
+}
diff --git a/usr/src/lib/libast/common/cdt/dtflatten.c b/usr/src/lib/libast/common/cdt/dtflatten.c
new file mode 100644
index 0000000000..86ca685dea
--- /dev/null
+++ b/usr/src/lib/libast/common/cdt/dtflatten.c
@@ -0,0 +1,75 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "dthdr.h"
+
+/* Flatten a dictionary into a linked list.
+** This may be used when many traversals are likely.
+**
+** Written by Kiem-Phong Vo (5/25/96).
+*/
+
+#if __STD_C
+Dtlink_t* dtflatten(Dt_t* dt)
+#else
+Dtlink_t* dtflatten(dt)
+Dt_t* dt;
+#endif
+{
+ reg Dtlink_t *t, *r, *list, *last, **s, **ends;
+
+ /* already flattened */
+ if(dt->data->type&DT_FLATTEN )
+ return dt->data->here;
+
+ list = last = NIL(Dtlink_t*);
+ if(dt->data->type&(DT_SET|DT_BAG))
+ { for(ends = (s = dt->data->htab) + dt->data->ntab; s < ends; ++s)
+ { if((t = *s) )
+ { if(last)
+ last->right = t;
+ else list = last = t;
+ while(last->right)
+ last = last->right;
+ *s = last;
+ }
+ }
+ }
+ else if(dt->data->type&(DT_LIST|DT_STACK|DT_QUEUE) )
+ list = dt->data->head;
+ else if((r = dt->data->here) ) /*if(dt->data->type&(DT_OSET|DT_OBAG))*/
+ { while((t = r->left) )
+ RROTATE(r,t);
+ for(list = last = r, r = r->right; r; last = r, r = r->right)
+ { if((t = r->left) )
+ { do RROTATE(r,t);
+ while((t = r->left) );
+
+ last->right = r;
+ }
+ }
+ }
+
+ dt->data->here = list;
+ dt->data->type |= DT_FLATTEN;
+
+ return list;
+}
diff --git a/usr/src/lib/libast/common/cdt/dthash.c b/usr/src/lib/libast/common/cdt/dthash.c
new file mode 100644
index 0000000000..62e1e1ba02
--- /dev/null
+++ b/usr/src/lib/libast/common/cdt/dthash.c
@@ -0,0 +1,368 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "dthdr.h"
+
+/* Hash table.
+** dt: dictionary
+** obj: what to look for
+** type: type of search
+**
+** Written by Kiem-Phong Vo (05/25/96)
+*/
+
+/* resize the hash table */
+#if __STD_C
+static void dthtab(Dt_t* dt)
+#else
+static void dthtab(dt)
+Dt_t* dt;
+#endif
+{
+ reg Dtlink_t *t, *r, *p, **s, **hs, **is, **olds;
+ int n, k;
+
+ if(dt->data->minp > 0 && dt->data->ntab > 0) /* fixed table size */
+ return;
+ dt->data->minp = 0;
+
+ n = dt->data->ntab;
+ if(dt->disc && dt->disc->eventf &&
+ (*dt->disc->eventf)(dt, DT_HASHSIZE, &n, dt->disc) > 0 )
+ { if(n < 0) /* fix table size */
+ { dt->data->minp = 1;
+ if(dt->data->ntab > 0 )
+ return;
+ }
+ else /* set a particular size */
+ { for(k = 2; k < n; k *= 2)
+ ;
+ n = k;
+ }
+ }
+ else n = 0;
+
+ /* compute new table size */
+ if(n <= 0)
+ { if((n = dt->data->ntab) == 0)
+ n = HSLOT;
+ while(dt->data->size > HLOAD(n))
+ n = HRESIZE(n);
+ }
+ if(n == dt->data->ntab)
+ return;
+
+ /* allocate new table */
+ olds = dt->data->ntab == 0 ? NIL(Dtlink_t**) : dt->data->htab;
+ if(!(s = (Dtlink_t**)(*dt->memoryf)(dt,olds,n*sizeof(Dtlink_t*),dt->disc)) )
+ return;
+ olds = s + dt->data->ntab;
+ dt->data->htab = s;
+ dt->data->ntab = n;
+
+ /* rehash elements */
+ for(hs = s+n-1; hs >= olds; --hs)
+ *hs = NIL(Dtlink_t*);
+ for(hs = s; hs < olds; ++hs)
+ { for(p = NIL(Dtlink_t*), t = *hs; t; t = r)
+ { r = t->right;
+ if((is = s + HINDEX(n,t->hash)) == hs)
+ p = t;
+ else /* move to a new chain */
+ { if(p)
+ p->right = r;
+ else *hs = r;
+ t->right = *is; *is = t;
+ }
+ }
+ }
+}
+
+#if __STD_C
+static Void_t* dthash(Dt_t* dt, reg Void_t* obj, int type)
+#else
+static Void_t* dthash(dt,obj,type)
+Dt_t* dt;
+reg Void_t* obj;
+int type;
+#endif
+{
+ reg Dtlink_t *t, *r, *p;
+ reg Void_t *k, *key;
+ reg uint hsh;
+ reg int lk, sz, ky;
+ reg Dtcompar_f cmpf;
+ reg Dtdisc_t* disc;
+ reg Dtlink_t **s, **ends;
+
+ UNFLATTEN(dt);
+
+ /* initialize discipline data */
+ disc = dt->disc; _DTDSC(disc,ky,sz,lk,cmpf);
+ dt->type &= ~DT_FOUND;
+
+ if(!obj)
+ { if(type&(DT_NEXT|DT_PREV))
+ goto end_walk;
+
+ if(dt->data->size <= 0 || !(type&(DT_CLEAR|DT_FIRST|DT_LAST)) )
+ return NIL(Void_t*);
+
+ ends = (s = dt->data->htab) + dt->data->ntab;
+ if(type&DT_CLEAR)
+ { /* clean out all objects */
+ for(; s < ends; ++s)
+ { t = *s;
+ *s = NIL(Dtlink_t*);
+ if(!disc->freef && disc->link >= 0)
+ continue;
+ while(t)
+ { r = t->right;
+ if(disc->freef)
+ (*disc->freef)(dt,_DTOBJ(t,lk),disc);
+ if(disc->link < 0)
+ (*dt->memoryf)(dt,(Void_t*)t,0,disc);
+ t = r;
+ }
+ }
+ dt->data->here = NIL(Dtlink_t*);
+ dt->data->size = 0;
+ dt->data->loop = 0;
+ return NIL(Void_t*);
+ }
+ else /* computing the first/last object */
+ { t = NIL(Dtlink_t*);
+ while(s < ends && !t )
+ t = (type&DT_LAST) ? *--ends : *s++;
+ if(t && (type&DT_LAST))
+ for(; t->right; t = t->right)
+ ;
+
+ dt->data->loop += 1;
+ dt->data->here = t;
+ return t ? _DTOBJ(t,lk) : NIL(Void_t*);
+ }
+ }
+
+ /* allow apps to delete an object "actually" in the dictionary */
+ if(dt->meth->type == DT_BAG && (type&(DT_DELETE|DT_DETACH)) )
+ { if(!dtsearch(dt,obj) )
+ return NIL(Void_t*);
+
+ s = dt->data->htab + HINDEX(dt->data->ntab,dt->data->here->hash);
+ r = NIL(Dtlink_t*);
+ for(p = NIL(Dtlink_t*), t = *s; t; p = t, t = t->right)
+ { if(_DTOBJ(t,lk) == obj) /* delete this specific object */
+ goto do_delete;
+ if(t == dt->data->here)
+ r = p;
+ }
+
+ /* delete some matching object */
+ p = r; t = dt->data->here;
+ goto do_delete;
+ }
+
+ if(type&(DT_MATCH|DT_SEARCH|DT_INSERT|DT_ATTACH) )
+ { key = (type&DT_MATCH) ? obj : _DTKEY(obj,ky,sz);
+ hsh = _DTHSH(dt,key,disc,sz);
+ goto do_search;
+ }
+ else if(type&(DT_RENEW|DT_VSEARCH) )
+ { r = (Dtlink_t*)obj;
+ obj = _DTOBJ(r,lk);
+ key = _DTKEY(obj,ky,sz);
+ hsh = r->hash;
+ goto do_search;
+ }
+ else /*if(type&(DT_DELETE|DT_DETACH|DT_NEXT|DT_PREV))*/
+ { if((t = dt->data->here) && _DTOBJ(t,lk) == obj)
+ { hsh = t->hash;
+ s = dt->data->htab + HINDEX(dt->data->ntab,hsh);
+ p = NIL(Dtlink_t*);
+ }
+ else
+ { key = _DTKEY(obj,ky,sz);
+ hsh = _DTHSH(dt,key,disc,sz);
+ do_search:
+ t = dt->data->ntab <= 0 ? NIL(Dtlink_t*) :
+ *(s = dt->data->htab + HINDEX(dt->data->ntab,hsh));
+ for(p = NIL(Dtlink_t*); t; p = t, t = t->right)
+ { if(hsh == t->hash)
+ { k = _DTOBJ(t,lk); k = _DTKEY(k,ky,sz);
+ if(_DTCMP(dt,key,k,disc,cmpf,sz) == 0)
+ break;
+ }
+ }
+ }
+ }
+
+ if(t) /* found matching object */
+ dt->type |= DT_FOUND;
+
+ if(type&(DT_MATCH|DT_SEARCH|DT_VSEARCH))
+ { if(!t)
+ return NIL(Void_t*);
+ if(p && (dt->data->type&DT_SET) && dt->data->loop <= 0)
+ { /* move-to-front heuristic */
+ p->right = t->right;
+ t->right = *s;
+ *s = t;
+ }
+ dt->data->here = t;
+ return _DTOBJ(t,lk);
+ }
+ else if(type&(DT_INSERT|DT_ATTACH))
+ { if(t && (dt->data->type&DT_SET) )
+ { dt->data->here = t;
+ return _DTOBJ(t,lk);
+ }
+
+ if(disc->makef && (type&DT_INSERT) &&
+ !(obj = (*disc->makef)(dt,obj,disc)) )
+ return NIL(Void_t*);
+ if(lk >= 0)
+ r = _DTLNK(obj,lk);
+ else
+ { r = (Dtlink_t*)(*dt->memoryf)
+ (dt,NIL(Void_t*),sizeof(Dthold_t),disc);
+ if(r)
+ ((Dthold_t*)r)->obj = obj;
+ else
+ { if(disc->makef && disc->freef && (type&DT_INSERT))
+ (*disc->freef)(dt,obj,disc);
+ return NIL(Void_t*);
+ }
+ }
+ r->hash = hsh;
+
+ /* insert object */
+ do_insert:
+ if((dt->data->size += 1) > HLOAD(dt->data->ntab) && dt->data->loop <= 0 )
+ dthtab(dt);
+ if(dt->data->ntab == 0)
+ { dt->data->size -= 1;
+ if(disc->freef && (type&DT_INSERT))
+ (*disc->freef)(dt,obj,disc);
+ if(disc->link < 0)
+ (*disc->memoryf)(dt,(Void_t*)r,0,disc);
+ return NIL(Void_t*);
+ }
+ s = dt->data->htab + HINDEX(dt->data->ntab,hsh);
+ if(t)
+ { r->right = t->right;
+ t->right = r;
+ }
+ else
+ { r->right = *s;
+ *s = r;
+ }
+ dt->data->here = r;
+ return obj;
+ }
+ else if(type&DT_NEXT)
+ { if(t && !(p = t->right) )
+ { for(ends = dt->data->htab+dt->data->ntab, s += 1; s < ends; ++s)
+ if((p = *s) )
+ break;
+ }
+ goto done_adj;
+ }
+ else if(type&DT_PREV)
+ { if(t && !p)
+ { if((p = *s) != t)
+ { while(p->right != t)
+ p = p->right;
+ }
+ else
+ { p = NIL(Dtlink_t*);
+ for(s -= 1, ends = dt->data->htab; s >= ends; --s)
+ { if((p = *s) )
+ { while(p->right)
+ p = p->right;
+ break;
+ }
+ }
+ }
+ }
+ done_adj:
+ if(!(dt->data->here = p) )
+ { end_walk:
+ if((dt->data->loop -= 1) < 0)
+ dt->data->loop = 0;
+ if(dt->data->size > HLOAD(dt->data->ntab) && dt->data->loop <= 0)
+ dthtab(dt);
+ return NIL(Void_t*);
+ }
+ else
+ { dt->data->type |= DT_WALK;
+ return _DTOBJ(p,lk);
+ }
+ }
+ else if(type&DT_RENEW)
+ { if(!t || (dt->data->type&DT_BAG) )
+ goto do_insert;
+ else
+ { if(disc->freef)
+ (*disc->freef)(dt,obj,disc);
+ if(disc->link < 0)
+ (*dt->memoryf)(dt,(Void_t*)r,0,disc);
+ return t ? _DTOBJ(t,lk) : NIL(Void_t*);
+ }
+ }
+ else /*if(type&(DT_DELETE|DT_DETACH))*/
+ { /* take an element out of the dictionary */
+ do_delete:
+ if(!t)
+ return NIL(Void_t*);
+ else if(p)
+ p->right = t->right;
+ else if((p = *s) == t)
+ p = *s = t->right;
+ else
+ { while(p->right != t)
+ p = p->right;
+ p->right = t->right;
+ }
+ obj = _DTOBJ(t,lk);
+ dt->data->size -= 1;
+ dt->data->here = p;
+ if(disc->freef && (type&DT_DELETE))
+ (*disc->freef)(dt,obj,disc);
+ if(disc->link < 0)
+ (*dt->memoryf)(dt,(Void_t*)t,0,disc);
+ return obj;
+ }
+}
+
+static Dtmethod_t _Dtset = { dthash, DT_SET };
+static Dtmethod_t _Dtbag = { dthash, DT_BAG };
+__DEFINE__(Dtmethod_t*,Dtset,&_Dtset);
+__DEFINE__(Dtmethod_t*,Dtbag,&_Dtbag);
+
+#ifndef KPVDEL /* for backward compatibility - remove next time */
+Dtmethod_t _Dthash = { dthash, DT_SET };
+__DEFINE__(Dtmethod_t*,Dthash,&_Dthash);
+#endif
+
+#ifdef NoF
+NoF(dthash)
+#endif
diff --git a/usr/src/lib/libast/common/cdt/dthdr.h b/usr/src/lib/libast/common/cdt/dthdr.h
new file mode 100644
index 0000000000..3ee951e79f
--- /dev/null
+++ b/usr/src/lib/libast/common/cdt/dthdr.h
@@ -0,0 +1,84 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _DTHDR_H
+#define _DTHDR_H 1
+#ifndef _BLD_cdt
+#define _BLD_cdt 1
+#endif
+
+/* Internal definitions for libcdt.
+** Written by Kiem-Phong Vo (5/25/96)
+*/
+
+#if _PACKAGE_ast
+#include <ast.h>
+#endif
+
+#include <cdt.h>
+
+/* short-hand notations */
+#define NIL(t) ((t)0)
+#define reg register
+#define uint unsigned int
+#define left hl._left
+#define hash hl._hash
+#define htab hh._htab
+#define head hh._head
+
+/* this must be disjoint from DT_METHODS */
+#define DT_FLATTEN 010000 /* dictionary already flattened */
+#define DT_WALK 020000 /* hash table being walked */
+
+/* how the Dt_t handle was allocated */
+#define DT_MALLOC 0
+#define DT_MEMORYF 1
+
+/* max search length before splaying */
+#define DT_MINP (sizeof(size_t)*8 - 2)
+
+/* hash start size and load factor */
+#define HSLOT (256)
+#define HRESIZE(n) ((n) << 1)
+#define HLOAD(s) ((s) << 1)
+#define HINDEX(n,h) ((h)&((n)-1))
+
+#define UNFLATTEN(dt) \
+ ((dt->data->type&DT_FLATTEN) ? dtrestore(dt,NIL(Dtlink_t*)) : 0)
+
+/* tree rotation/linking functions */
+#define rrotate(x,y) ((x)->left = (y)->right, (y)->right = (x))
+#define lrotate(x,y) ((x)->right = (y)->left, (y)->left = (x))
+#define rlink(r,x) ((r) = (r)->left = (x) )
+#define llink(l,x) ((l) = (l)->right = (x) )
+
+#define RROTATE(x,y) (rrotate(x,y), (x) = (y))
+#define LROTATE(x,y) (lrotate(x,y), (x) = (y))
+
+#if !_PACKAGE_ast
+_BEGIN_EXTERNS_
+extern Void_t* malloc _ARG_((size_t));
+extern Void_t* realloc _ARG_((Void_t*, size_t));
+extern void free _ARG_((Void_t*));
+_END_EXTERNS_
+#endif
+
+#endif /* _DTHDR_H */
diff --git a/usr/src/lib/libast/common/cdt/dtlist.c b/usr/src/lib/libast/common/cdt/dtlist.c
new file mode 100644
index 0000000000..7feef4e3a2
--- /dev/null
+++ b/usr/src/lib/libast/common/cdt/dtlist.c
@@ -0,0 +1,196 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "dthdr.h"
+
+/* List, Stack, Queue.
+**
+** Written by Kiem-Phong Vo (05/25/96)
+*/
+
+#if __STD_C
+static Void_t* dtlist(reg Dt_t* dt, reg Void_t* obj, reg int type)
+#else
+static Void_t* dtlist(dt, obj, type)
+reg Dt_t* dt;
+reg Void_t* obj;
+reg int type;
+#endif
+{
+ reg int lk, sz, ky;
+ reg Dtcompar_f cmpf;
+ reg Dtdisc_t* disc;
+ reg Dtlink_t *r, *t;
+ reg Void_t *key, *k;
+
+ UNFLATTEN(dt);
+ disc = dt->disc; _DTDSC(disc,ky,sz,lk,cmpf);
+ dt->type &= ~DT_FOUND;
+
+ if(!obj)
+ { if(type&(DT_LAST|DT_FIRST) )
+ { if((r = dt->data->head) )
+ { if(type&DT_LAST)
+ r = r->left;
+ dt->data->here = r;
+ }
+ return r ? _DTOBJ(r,lk) : NIL(Void_t*);
+ }
+ else if(type&(DT_DELETE|DT_DETACH))
+ { if((dt->data->type&DT_LIST) || !(r = dt->data->head))
+ return NIL(Void_t*);
+ else goto dt_delete;
+ }
+ else if(type&DT_CLEAR)
+ { if(disc->freef || disc->link < 0)
+ { for(r = dt->data->head; r; r = t)
+ { t = r->right;
+ if(disc->freef)
+ (*disc->freef)(dt,_DTOBJ(r,lk),disc);
+ if(disc->link < 0)
+ (*dt->memoryf)(dt,(Void_t*)r,0,disc);
+ }
+ }
+ dt->data->head = dt->data->here = NIL(Dtlink_t*);
+ dt->data->size = 0;
+ return NIL(Void_t*);
+ }
+ else return NIL(Void_t*);
+ }
+
+ if(type&(DT_INSERT|DT_ATTACH))
+ { if(disc->makef && (type&DT_INSERT) &&
+ !(obj = (*disc->makef)(dt,obj,disc)) )
+ return NIL(Void_t*);
+ if(lk >= 0)
+ r = _DTLNK(obj,lk);
+ else
+ { r = (Dtlink_t*)(*dt->memoryf)
+ (dt,NIL(Void_t*),sizeof(Dthold_t),disc);
+ if(r)
+ ((Dthold_t*)r)->obj = obj;
+ else
+ { if(disc->makef && disc->freef && (type&DT_INSERT))
+ (*disc->freef)(dt,obj,disc);
+ return NIL(Void_t*);
+ }
+ }
+
+ if(dt->data->type&DT_LIST)
+ { if((t = dt->data->here) && t != dt->data->head)
+ { r->left = t->left;
+ t->left->right = r;
+ r->right = t;
+ t->left = r;
+ }
+ else goto dt_stack;
+ }
+ else if(dt->data->type&DT_STACK)
+ { dt_stack:
+ r->right = t = dt->data->head;
+ if(t)
+ { r->left = t->left;
+ t->left = r;
+ }
+ else r->left = r;
+ dt->data->head = r;
+ }
+ else /* if(dt->data->type&DT_QUEUE) */
+ { if((t = dt->data->head) )
+ { t->left->right = r;
+ r->left = t->left;
+ t->left = r;
+ }
+ else
+ { dt->data->head = r;
+ r->left = r;
+ }
+ r->right = NIL(Dtlink_t*);
+ }
+
+ if(dt->data->size >= 0)
+ dt->data->size += 1;
+
+ dt->data->here = r;
+ return _DTOBJ(r,lk);
+ }
+
+ if((type&DT_MATCH) || !(r = dt->data->here) || _DTOBJ(r,lk) != obj)
+ { key = (type&DT_MATCH) ? obj : _DTKEY(obj,ky,sz);
+ for(r = dt->data->head; r; r = r->right)
+ { k = _DTOBJ(r,lk); k = _DTKEY(k,ky,sz);
+ if(_DTCMP(dt,key,k,disc,cmpf,sz) == 0)
+ break;
+ }
+ }
+
+ if(!r)
+ return NIL(Void_t*);
+ dt->type |= DT_FOUND;
+
+ if(type&(DT_DELETE|DT_DETACH))
+ { dt_delete:
+ if(r->right)
+ r->right->left = r->left;
+ if(r == (t = dt->data->head) )
+ { dt->data->head = r->right;
+ if(dt->data->head)
+ dt->data->head->left = t->left;
+ }
+ else
+ { r->left->right = r->right;
+ if(r == t->left)
+ t->left = r->left;
+ }
+
+ dt->data->here = r == dt->data->here ? r->right : NIL(Dtlink_t*);
+ dt->data->size -= 1;
+
+ obj = _DTOBJ(r,lk);
+ if(disc->freef && (type&DT_DELETE))
+ (*disc->freef)(dt,obj,disc);
+ if(disc->link < 0)
+ (*dt->memoryf)(dt,(Void_t*)r,0,disc);
+ return obj;
+ }
+ else if(type&DT_NEXT)
+ r = r->right;
+ else if(type&DT_PREV)
+ r = r == dt->data->head ? NIL(Dtlink_t*) : r->left;
+
+ dt->data->here = r;
+ return r ? _DTOBJ(r,lk) : NIL(Void_t*);
+}
+
+#ifndef KPVDEL /* to be remove next round */
+#define static
+#endif
+static Dtmethod_t _Dtlist = { dtlist, DT_LIST };
+static Dtmethod_t _Dtstack = { dtlist, DT_STACK };
+static Dtmethod_t _Dtqueue = { dtlist, DT_QUEUE };
+
+__DEFINE__(Dtmethod_t*,Dtlist,&_Dtlist);
+__DEFINE__(Dtmethod_t*,Dtstack,&_Dtstack);
+__DEFINE__(Dtmethod_t*,Dtqueue,&_Dtqueue);
+
+#ifdef NoF
+NoF(dtlist)
+#endif
diff --git a/usr/src/lib/libast/common/cdt/dtmethod.c b/usr/src/lib/libast/common/cdt/dtmethod.c
new file mode 100644
index 0000000000..c77a134816
--- /dev/null
+++ b/usr/src/lib/libast/common/cdt/dtmethod.c
@@ -0,0 +1,107 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "dthdr.h"
+
+/* Change search method.
+**
+** Written by Kiem-Phong Vo (05/25/96)
+*/
+
+#if __STD_C
+Dtmethod_t* dtmethod(Dt_t* dt, Dtmethod_t* meth)
+#else
+Dtmethod_t* dtmethod(dt, meth)
+Dt_t* dt;
+Dtmethod_t* meth;
+#endif
+{
+ reg Dtlink_t *list, *r;
+ reg Dtdisc_t* disc = dt->disc;
+ reg Dtmethod_t* oldmeth = dt->meth;
+
+ if(!meth || meth->type == oldmeth->type)
+ return oldmeth;
+
+ if(disc->eventf &&
+ (*disc->eventf)(dt,DT_METH,(Void_t*)meth,disc) < 0)
+ return NIL(Dtmethod_t*);
+
+ dt->data->minp = 0;
+
+ /* get the list of elements */
+ list = dtflatten(dt);
+
+ if(dt->data->type&(DT_LIST|DT_STACK|DT_QUEUE) )
+ dt->data->head = NIL(Dtlink_t*);
+ else if(dt->data->type&(DT_SET|DT_BAG) )
+ { if(dt->data->ntab > 0)
+ (*dt->memoryf)(dt,(Void_t*)dt->data->htab,0,disc);
+ dt->data->ntab = 0;
+ dt->data->htab = NIL(Dtlink_t**);
+ }
+
+ dt->data->here = NIL(Dtlink_t*);
+ dt->data->type = (dt->data->type&~(DT_METHODS|DT_FLATTEN)) | meth->type;
+ dt->meth = meth;
+ if(dt->searchf == oldmeth->searchf)
+ dt->searchf = meth->searchf;
+
+ if(meth->type&(DT_LIST|DT_STACK|DT_QUEUE) )
+ { if(!(oldmeth->type&(DT_LIST|DT_STACK|DT_QUEUE)) )
+ { if((r = list) )
+ { reg Dtlink_t* t;
+ for(t = r->right; t; r = t, t = t->right )
+ t->left = r;
+ list->left = r;
+ }
+ }
+ dt->data->head = list;
+ }
+ else if(meth->type&(DT_OSET|DT_OBAG))
+ { dt->data->size = 0;
+ while(list)
+ { r = list->right;
+ (*meth->searchf)(dt,(Void_t*)list,DT_RENEW);
+ list = r;
+ }
+ }
+ else if(!((meth->type&DT_BAG) && (oldmeth->type&DT_SET)) )
+ { int rehash;
+ if((meth->type&(DT_SET|DT_BAG)) && !(oldmeth->type&(DT_SET|DT_BAG)))
+ rehash = 1;
+ else rehash = 0;
+
+ dt->data->size = dt->data->loop = 0;
+ while(list)
+ { r = list->right;
+ if(rehash)
+ { reg Void_t* key = _DTOBJ(list,disc->link);
+ key = _DTKEY(key,disc->key,disc->size);
+ list->hash = _DTHSH(dt,key,disc,disc->size);
+ }
+ (void)(*meth->searchf)(dt,(Void_t*)list,DT_RENEW);
+ list = r;
+ }
+ }
+
+ return oldmeth;
+}
diff --git a/usr/src/lib/libast/common/cdt/dtnew.c b/usr/src/lib/libast/common/cdt/dtnew.c
new file mode 100644
index 0000000000..95de0412fa
--- /dev/null
+++ b/usr/src/lib/libast/common/cdt/dtnew.c
@@ -0,0 +1,73 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * dtopen() with handle placed in specific vm region
+ */
+
+#include <dt.h>
+
+typedef struct Dc_s
+{
+ Dtdisc_t ndisc;
+ Dtdisc_t* odisc;
+ Vmalloc_t* vm;
+} Dc_t;
+
+static int
+eventf(Dt_t* dt, int op, void* data, Dtdisc_t* disc)
+{
+ Dc_t* dc = (Dc_t*)disc;
+ int r;
+
+ if (dc->odisc->eventf && (r = (*dc->odisc->eventf)(dt, op, data, dc->odisc)))
+ return r;
+ return op == DT_ENDOPEN ? 1 : 0;
+}
+
+static void*
+memoryf(Dt_t* dt, void* addr, size_t size, Dtdisc_t* disc)
+{
+ return vmresize(((Dc_t*)disc)->vm, addr, size, VM_RSMOVE);
+}
+
+/*
+ * open a dictionary using disc->memoryf if set or vm otherwise
+ */
+
+Dt_t*
+dtnew(Vmalloc_t* vm, Dtdisc_t* disc, Dtmethod_t* meth)
+{
+ Dt_t* dt;
+ Dc_t dc;
+
+ dc.odisc = disc;
+ dc.ndisc = *disc;
+ dc.ndisc.eventf = eventf;
+ if (!dc.ndisc.memoryf)
+ dc.ndisc.memoryf = memoryf;
+ dc.vm = vm;
+ if (dt = dtopen(&dc.ndisc, meth))
+ dtdisc(dt, disc, DT_SAMECMP|DT_SAMEHASH);
+ return dt;
+}
diff --git a/usr/src/lib/libast/common/cdt/dtopen.c b/usr/src/lib/libast/common/cdt/dtopen.c
new file mode 100644
index 0000000000..2f1ba5b26c
--- /dev/null
+++ b/usr/src/lib/libast/common/cdt/dtopen.c
@@ -0,0 +1,109 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "dthdr.h"
+static char* Version = "\n@(#)$Id: cdt (AT&T Research) 2005-04-20 $\0\n";
+
+/* Make a new dictionary
+**
+** Written by Kiem-Phong Vo (5/25/96)
+*/
+
+#if __STD_C
+Dt_t* dtopen(Dtdisc_t* disc, Dtmethod_t* meth)
+#else
+Dt_t* dtopen(disc, meth)
+Dtdisc_t* disc;
+Dtmethod_t* meth;
+#endif
+{
+ Dt_t* dt = (Dt_t*)Version; /* shut-up unuse warning */
+ reg int e;
+ Dtdata_t* data;
+
+ if(!disc || !meth)
+ return NIL(Dt_t*);
+
+ /* allocate space for dictionary */
+ if(!(dt = (Dt_t*) malloc(sizeof(Dt_t))))
+ return NIL(Dt_t*);
+
+ /* initialize all absolutely private data */
+ dt->searchf = NIL(Dtsearch_f);
+ dt->meth = NIL(Dtmethod_t*);
+ dt->disc = NIL(Dtdisc_t*);
+ dtdisc(dt,disc,0);
+ dt->type = DT_MALLOC;
+ dt->nview = 0;
+ dt->view = dt->walk = NIL(Dt_t*);
+ dt->user = NIL(Void_t*);
+
+ if(disc->eventf)
+ { /* if shared/persistent dictionary, get existing data */
+ data = NIL(Dtdata_t*);
+ if((e = (*disc->eventf)(dt,DT_OPEN,(Void_t*)(&data),disc)) < 0)
+ goto err_open;
+ else if(e > 0)
+ { if(data)
+ { if(data->type&meth->type)
+ goto done;
+ else goto err_open;
+ }
+
+ if(!disc->memoryf)
+ goto err_open;
+
+ free((Void_t*)dt);
+ if(!(dt = (*disc->memoryf)(0, 0, sizeof(Dt_t), disc)) )
+ return NIL(Dt_t*);
+ dt->searchf = NIL(Dtsearch_f);
+ dt->meth = NIL(Dtmethod_t*);
+ dt->disc = NIL(Dtdisc_t*);
+ dtdisc(dt,disc,0);
+ dt->type = DT_MEMORYF;
+ dt->nview = 0;
+ dt->view = dt->walk = NIL(Dt_t*);
+ }
+ }
+
+ /* allocate sharable data */
+ if(!(data = (Dtdata_t*)(dt->memoryf)(dt,NIL(Void_t*),sizeof(Dtdata_t),disc)) )
+ { err_open:
+ free((Void_t*)dt);
+ return NIL(Dt_t*);
+ }
+
+ data->type = meth->type;
+ data->here = NIL(Dtlink_t*);
+ data->htab = NIL(Dtlink_t**);
+ data->ntab = data->size = data->loop = 0;
+ data->minp = 0;
+
+done:
+ dt->data = data;
+ dt->searchf = meth->searchf;
+ dt->meth = meth;
+
+ if(disc->eventf)
+ (*disc->eventf)(dt, DT_ENDOPEN, (Void_t*)dt, disc);
+
+ return dt;
+}
diff --git a/usr/src/lib/libast/common/cdt/dtrenew.c b/usr/src/lib/libast/common/cdt/dtrenew.c
new file mode 100644
index 0000000000..378c27480c
--- /dev/null
+++ b/usr/src/lib/libast/common/cdt/dtrenew.c
@@ -0,0 +1,79 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "dthdr.h"
+
+
+/* Renew the object at the current finger.
+**
+** Written by Kiem-Phong Vo (5/25/96)
+*/
+
+#if __STD_C
+Void_t* dtrenew(Dt_t* dt, reg Void_t* obj)
+#else
+Void_t* dtrenew(dt, obj)
+Dt_t* dt;
+reg Void_t* obj;
+#endif
+{
+ reg Void_t* key;
+ reg Dtlink_t *e, *t, **s;
+ reg Dtdisc_t* disc = dt->disc;
+
+ UNFLATTEN(dt);
+
+ if(!(e = dt->data->here) || _DTOBJ(e,disc->link) != obj)
+ return NIL(Void_t*);
+
+ if(dt->data->type&(DT_STACK|DT_QUEUE|DT_LIST))
+ return obj;
+ else if(dt->data->type&(DT_OSET|DT_OBAG) )
+ { if(!e->right ) /* make left child the new root */
+ dt->data->here = e->left;
+ else /* make right child the new root */
+ { dt->data->here = e->right;
+
+ /* merge left subtree to right subtree */
+ if(e->left)
+ { for(t = e->right; t->left; t = t->left)
+ ;
+ t->left = e->left;
+ }
+ }
+ }
+ else /*if(dt->data->type&(DT_SET|DT_BAG))*/
+ { s = dt->data->htab + HINDEX(dt->data->ntab,e->hash);
+ if((t = *s) == e)
+ *s = e->right;
+ else
+ { for(; t->right != e; t = t->right)
+ ;
+ t->right = e->right;
+ }
+ key = _DTKEY(obj,disc->key,disc->size);
+ e->hash = _DTHSH(dt,key,disc,disc->size);
+ dt->data->here = NIL(Dtlink_t*);
+ }
+
+ dt->data->size -= 1;
+ return (*dt->meth->searchf)(dt,(Void_t*)e,DT_RENEW) ? obj : NIL(Void_t*);
+}
diff --git a/usr/src/lib/libast/common/cdt/dtrestore.c b/usr/src/lib/libast/common/cdt/dtrestore.c
new file mode 100644
index 0000000000..0b1becd0e1
--- /dev/null
+++ b/usr/src/lib/libast/common/cdt/dtrestore.c
@@ -0,0 +1,88 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "dthdr.h"
+
+/* Restore dictionary from given tree or list of elements.
+** There are two cases. If called from within, list is nil.
+** From without, list is not nil and data->size must be 0.
+**
+** Written by Kiem-Phong Vo (5/25/96)
+*/
+
+#if __STD_C
+int dtrestore(reg Dt_t* dt, reg Dtlink_t* list)
+#else
+int dtrestore(dt, list)
+reg Dt_t* dt;
+reg Dtlink_t* list;
+#endif
+{
+ reg Dtlink_t *t, **s, **ends;
+ reg int type;
+ reg Dtsearch_f searchf = dt->meth->searchf;
+
+ type = dt->data->type&DT_FLATTEN;
+ if(!list) /* restoring a flattened dictionary */
+ { if(!type)
+ return -1;
+ list = dt->data->here;
+ }
+ else /* restoring an extracted list of elements */
+ { if(dt->data->size != 0)
+ return -1;
+ type = 0;
+ }
+ dt->data->type &= ~DT_FLATTEN;
+
+ if(dt->data->type&(DT_SET|DT_BAG))
+ { dt->data->here = NIL(Dtlink_t*);
+ if(type) /* restoring a flattened dictionary */
+ { for(ends = (s = dt->data->htab) + dt->data->ntab; s < ends; ++s)
+ { if((t = *s) )
+ { *s = list;
+ list = t->right;
+ t->right = NIL(Dtlink_t*);
+ }
+ }
+ }
+ else /* restoring an extracted list of elements */
+ { dt->data->size = 0;
+ while(list)
+ { t = list->right;
+ (*searchf)(dt,(Void_t*)list,DT_RENEW);
+ list = t;
+ }
+ }
+ }
+ else
+ { if(dt->data->type&(DT_OSET|DT_OBAG))
+ dt->data->here = list;
+ else /*if(dt->data->type&(DT_LIST|DT_STACK|DT_QUEUE))*/
+ { dt->data->here = NIL(Dtlink_t*);
+ dt->data->head = list;
+ }
+ if(!type)
+ dt->data->size = -1;
+ }
+
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/cdt/dtsize.c b/usr/src/lib/libast/common/cdt/dtsize.c
new file mode 100644
index 0000000000..71e6671fac
--- /dev/null
+++ b/usr/src/lib/libast/common/cdt/dtsize.c
@@ -0,0 +1,61 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "dthdr.h"
+
+/* Return the # of objects in the dictionary
+**
+** Written by Kiem-Phong Vo (5/25/96)
+*/
+
+#if __STD_C
+static int treecount(reg Dtlink_t* e)
+#else
+static int treecount(e)
+reg Dtlink_t* e;
+#endif
+{ return e ? treecount(e->left) + treecount(e->right) + 1 : 0;
+}
+
+#if __STD_C
+int dtsize(Dt_t* dt)
+#else
+int dtsize(dt)
+Dt_t* dt;
+#endif
+{
+ reg Dtlink_t* t;
+ reg int size;
+
+ UNFLATTEN(dt);
+
+ if(dt->data->size < 0) /* !(dt->data->type&(DT_SET|DT_BAG)) */
+ { if(dt->data->type&(DT_OSET|DT_OBAG))
+ dt->data->size = treecount(dt->data->here);
+ else if(dt->data->type&(DT_LIST|DT_STACK|DT_QUEUE))
+ { for(size = 0, t = dt->data->head; t; t = t->right)
+ size += 1;
+ dt->data->size = size;
+ }
+ }
+
+ return dt->data->size;
+}
diff --git a/usr/src/lib/libast/common/cdt/dtstat.c b/usr/src/lib/libast/common/cdt/dtstat.c
new file mode 100644
index 0000000000..ee1ffa04e7
--- /dev/null
+++ b/usr/src/lib/libast/common/cdt/dtstat.c
@@ -0,0 +1,132 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "dthdr.h"
+
+/* Get statistics of a dictionary
+**
+** Written by Kiem-Phong Vo (5/25/96)
+*/
+
+#if __STD_C
+static void dttstat(Dtstat_t* ds, Dtlink_t* root, int depth, int* level)
+#else
+static void dttstat(ds,root,depth,level)
+Dtstat_t* ds;
+Dtlink_t* root;
+int depth;
+int* level;
+#endif
+{
+ if(root->left)
+ dttstat(ds,root->left,depth+1,level);
+ if(root->right)
+ dttstat(ds,root->right,depth+1,level);
+ if(depth > ds->dt_n)
+ ds->dt_n = depth;
+ if(level)
+ level[depth] += 1;
+}
+
+#if __STD_C
+static void dthstat(reg Dtdata_t* data, Dtstat_t* ds, reg int* count)
+#else
+static void dthstat(data, ds, count)
+reg Dtdata_t* data;
+Dtstat_t* ds;
+reg int* count;
+#endif
+{
+ reg Dtlink_t* t;
+ reg int n, h;
+
+ for(h = data->ntab-1; h >= 0; --h)
+ { n = 0;
+ for(t = data->htab[h]; t; t = t->right)
+ n += 1;
+ if(count)
+ count[n] += 1;
+ else if(n > 0)
+ { ds->dt_n += 1;
+ if(n > ds->dt_max)
+ ds->dt_max = n;
+ }
+ }
+}
+
+#if __STD_C
+int dtstat(reg Dt_t* dt, Dtstat_t* ds, int all)
+#else
+int dtstat(dt, ds, all)
+reg Dt_t* dt;
+Dtstat_t* ds;
+int all;
+#endif
+{
+ reg int i;
+ static int *Count, Size;
+
+ UNFLATTEN(dt);
+
+ ds->dt_n = ds->dt_max = 0;
+ ds->dt_count = NIL(int*);
+ ds->dt_size = dtsize(dt);
+ ds->dt_meth = dt->data->type&DT_METHODS;
+
+ if(!all)
+ return 0;
+
+ if(dt->data->type&(DT_SET|DT_BAG))
+ { dthstat(dt->data,ds,NIL(int*));
+ if(ds->dt_max+1 > Size)
+ { if(Size > 0)
+ free(Count);
+ if(!(Count = (int*)malloc((ds->dt_max+1)*sizeof(int))) )
+ return -1;
+ Size = ds->dt_max+1;
+ }
+ for(i = ds->dt_max; i >= 0; --i)
+ Count[i] = 0;
+ dthstat(dt->data,ds,Count);
+ }
+ else if(dt->data->type&(DT_OSET|DT_OBAG))
+ { if(dt->data->here)
+ { dttstat(ds,dt->data->here,0,NIL(int*));
+ if(ds->dt_n+1 > Size)
+ { if(Size > 0)
+ free(Count);
+ if(!(Count = (int*)malloc((ds->dt_n+1)*sizeof(int))) )
+ return -1;
+ Size = ds->dt_n+1;
+ }
+
+ for(i = ds->dt_n; i >= 0; --i)
+ Count[i] = 0;
+ dttstat(ds,dt->data->here,0,Count);
+ for(i = ds->dt_n; i >= 0; --i)
+ if(Count[i] > ds->dt_max)
+ ds->dt_max = Count[i];
+ }
+ }
+ ds->dt_count = Count;
+
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/cdt/dtstrhash.c b/usr/src/lib/libast/common/cdt/dtstrhash.c
new file mode 100644
index 0000000000..cf700f2081
--- /dev/null
+++ b/usr/src/lib/libast/common/cdt/dtstrhash.c
@@ -0,0 +1,61 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "dthdr.h"
+
+/* Hashing a string into an unsigned integer.
+** The basic method is to continuingly accumulate bytes and multiply
+** with some given prime. The length n of the string is added last.
+** The recurrent equation is like this:
+** h[k] = (h[k-1] + bytes)*prime for 0 <= k < n
+** h[n] = (h[n-1] + n)*prime
+** The prime is chosen to have a good distribution of 1-bits so that
+** the multiplication will distribute the bits in the accumulator well.
+** The below code accumulates 2 bytes at a time for speed.
+**
+** Written by Kiem-Phong Vo (02/28/03)
+*/
+
+#if __STD_C
+uint dtstrhash(reg uint h, Void_t* args, reg int n)
+#else
+uint dtstrhash(h,args,n)
+reg uint h;
+Void_t* args;
+reg int n;
+#endif
+{
+ reg unsigned char* s = (unsigned char*)args;
+
+ if(n <= 0)
+ { for(; *s != 0; s += s[1] ? 2 : 1)
+ h = (h + (s[0]<<8) + s[1])*DT_PRIME;
+ n = s - (unsigned char*)args;
+ }
+ else
+ { reg unsigned char* ends;
+ for(ends = s+n-1; s < ends; s += 2)
+ h = (h + (s[0]<<8) + s[1])*DT_PRIME;
+ if(s <= ends)
+ h = (h + (s[0]<<8))*DT_PRIME;
+ }
+ return (h+n)*DT_PRIME;
+}
diff --git a/usr/src/lib/libast/common/cdt/dttree.c b/usr/src/lib/libast/common/cdt/dttree.c
new file mode 100644
index 0000000000..29b87016cc
--- /dev/null
+++ b/usr/src/lib/libast/common/cdt/dttree.c
@@ -0,0 +1,391 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "dthdr.h"
+
+/* Ordered set/multiset
+** dt: dictionary being searched
+** obj: the object to look for.
+** type: search type.
+**
+** Written by Kiem-Phong Vo (5/25/96)
+*/
+
+#if __STD_C
+static Void_t* dttree(Dt_t* dt, Void_t* obj, int type)
+#else
+static Void_t* dttree(dt,obj,type)
+Dt_t* dt;
+Void_t* obj;
+int type;
+#endif
+{
+ Dtlink_t *root, *t;
+ int cmp, lk, sz, ky;
+ Void_t *o, *k, *key;
+ Dtlink_t *l, *r, *me, link;
+ int n, minp, turn[DT_MINP];
+ Dtcompar_f cmpf;
+ Dtdisc_t* disc;
+
+ UNFLATTEN(dt);
+ disc = dt->disc; _DTDSC(disc,ky,sz,lk,cmpf);
+ dt->type &= ~DT_FOUND;
+
+ root = dt->data->here;
+ if(!obj)
+ { if(!root || !(type&(DT_CLEAR|DT_FIRST|DT_LAST)) )
+ return NIL(Void_t*);
+
+ if(type&DT_CLEAR) /* delete all objects */
+ { if(disc->freef || disc->link < 0)
+ { do
+ { while((t = root->left) )
+ RROTATE(root,t);
+ t = root->right;
+ if(disc->freef)
+ (*disc->freef)(dt,_DTOBJ(root,lk),disc);
+ if(disc->link < 0)
+ (*dt->memoryf)(dt,(Void_t*)root,0,disc);
+ } while((root = t) );
+ }
+
+ dt->data->size = 0;
+ dt->data->here = NIL(Dtlink_t*);
+ return NIL(Void_t*);
+ }
+ else /* computing largest/smallest element */
+ { if(type&DT_LAST)
+ { while((t = root->right) )
+ LROTATE(root,t);
+ }
+ else /* type&DT_FIRST */
+ { while((t = root->left) )
+ RROTATE(root,t);
+ }
+
+ dt->data->here = root;
+ return _DTOBJ(root,lk);
+ }
+ }
+
+ /* note that link.right is LEFT tree and link.left is RIGHT tree */
+ l = r = &link;
+
+ /* allow apps to delete an object "actually" in the dictionary */
+ if(dt->meth->type == DT_OBAG && (type&(DT_DELETE|DT_DETACH)) )
+ { key = _DTKEY(obj,ky,sz);
+ for(o = dtsearch(dt,obj); o; o = dtnext(dt,o) )
+ { k = _DTKEY(o,ky,sz);
+ if(_DTCMP(dt,key,k,disc,cmpf,sz) != 0)
+ break;
+ if(o == obj)
+ { root = dt->data->here;
+ l->right = root->left;
+ r->left = root->right;
+ goto dt_delete;
+ }
+ }
+ }
+
+ if(type&(DT_MATCH|DT_SEARCH|DT_INSERT|DT_ATTACH))
+ { key = (type&DT_MATCH) ? obj : _DTKEY(obj,ky,sz);
+ if(root)
+ goto do_search;
+ }
+ else if(type&DT_RENEW)
+ { me = (Dtlink_t*)obj;
+ obj = _DTOBJ(me,lk);
+ key = _DTKEY(obj,ky,sz);
+ if(root)
+ goto do_search;
+ }
+ else if(root && _DTOBJ(root,lk) != obj)
+ { key = _DTKEY(obj,ky,sz);
+ do_search:
+ if(dt->meth->type == DT_OSET &&
+ (minp = dt->data->minp) != 0 && (type&(DT_MATCH|DT_SEARCH)) )
+ { /* simple search, note that minp should be even */
+ for(t = root, n = 0; n < minp; ++n)
+ { k = _DTOBJ(t,lk); k = _DTKEY(k,ky,sz);
+ if((cmp = _DTCMP(dt,key,k,disc,cmpf,sz)) == 0)
+ return _DTOBJ(t,lk);
+ else
+ { turn[n] = cmp;
+ if(!(t = cmp < 0 ? t->left : t->right) )
+ return NIL(Void_t*);
+ }
+ }
+
+ /* exceed search length, top-down splay now */
+ for(n = 0; n < minp; n += 2)
+ { if(turn[n] < 0)
+ { t = root->left;
+ if(turn[n+1] < 0)
+ { rrotate(root,t);
+ rlink(r,t);
+ root = t->left;
+ }
+ else
+ { llink(l,t);
+ rlink(r,root);
+ root = t->right;
+ }
+ }
+ else
+ { t = root->right;
+ if(turn[n+1] > 0)
+ { lrotate(root,t);
+ llink(l,t);
+ root = t->right;
+ }
+ else
+ { rlink(r,t);
+ llink(l,root);
+ root = t->left;
+ }
+ }
+ }
+ }
+
+ while(1)
+ { k = _DTOBJ(root,lk); k = _DTKEY(k,ky,sz);
+ if((cmp = _DTCMP(dt,key,k,disc,cmpf,sz)) == 0)
+ break;
+ else if(cmp < 0)
+ { if((t = root->left) )
+ { k = _DTOBJ(t,lk); k = _DTKEY(k,ky,sz);
+ if((cmp = _DTCMP(dt,key,k,disc,cmpf,sz)) < 0)
+ { rrotate(root,t);
+ rlink(r,t);
+ if(!(root = t->left) )
+ break;
+ }
+ else if(cmp == 0)
+ { rlink(r,root);
+ root = t;
+ break;
+ }
+ else /* if(cmp > 0) */
+ { llink(l,t);
+ rlink(r,root);
+ if(!(root = t->right) )
+ break;
+ }
+ }
+ else
+ { rlink(r,root);
+ root = NIL(Dtlink_t*);
+ break;
+ }
+ }
+ else /* if(cmp > 0) */
+ { if((t = root->right) )
+ { k = _DTOBJ(t,lk); k = _DTKEY(k,ky,sz);
+ if((cmp = _DTCMP(dt,key,k,disc,cmpf,sz)) > 0)
+ { lrotate(root,t);
+ llink(l,t);
+ if(!(root = t->right) )
+ break;
+ }
+ else if(cmp == 0)
+ { llink(l,root);
+ root = t;
+ break;
+ }
+ else /* if(cmp < 0) */
+ { rlink(r,t);
+ llink(l,root);
+ if(!(root = t->left) )
+ break;
+ }
+ }
+ else
+ { llink(l,root);
+ root = NIL(Dtlink_t*);
+ break;
+ }
+ }
+ }
+ }
+
+ if(root)
+ { /* found it, now isolate it */
+ dt->type |= DT_FOUND;
+ l->right = root->left;
+ r->left = root->right;
+
+ if(type&(DT_SEARCH|DT_MATCH))
+ { has_root:
+ root->left = link.right;
+ root->right = link.left;
+ if((dt->meth->type&DT_OBAG) && (type&(DT_SEARCH|DT_MATCH)) )
+ { key = _DTOBJ(root,lk); key = _DTKEY(key,ky,sz);
+ while((t = root->left) )
+ { /* find max of left subtree */
+ while((r = t->right) )
+ LROTATE(t,r);
+ root->left = t;
+
+ /* now see if it's in the same group */
+ k = _DTOBJ(t,lk); k = _DTKEY(k,ky,sz);
+ if(_DTCMP(dt,key,k,disc,cmpf,sz) != 0)
+ break;
+ RROTATE(root,t);
+ }
+ }
+ dt->data->here = root;
+ return _DTOBJ(root,lk);
+ }
+ else if(type&DT_NEXT)
+ { root->left = link.right;
+ root->right = NIL(Dtlink_t*);
+ link.right = root;
+ dt_next:
+ if((root = link.left) )
+ { while((t = root->left) )
+ RROTATE(root,t);
+ link.left = root->right;
+ goto has_root;
+ }
+ else goto no_root;
+ }
+ else if(type&DT_PREV)
+ { root->right = link.left;
+ root->left = NIL(Dtlink_t*);
+ link.left = root;
+ dt_prev:
+ if((root = link.right) )
+ { while((t = root->right) )
+ LROTATE(root,t);
+ link.right = root->left;
+ goto has_root;
+ }
+ else goto no_root;
+ }
+ else if(type&(DT_DELETE|DT_DETACH))
+ { /* taking an object out of the dictionary */
+ dt_delete:
+ obj = _DTOBJ(root,lk);
+ if(disc->freef && (type&DT_DELETE))
+ (*disc->freef)(dt,obj,disc);
+ if(disc->link < 0)
+ (*dt->memoryf)(dt,(Void_t*)root,0,disc);
+ if((dt->data->size -= 1) < 0)
+ dt->data->size = -1;
+ goto no_root;
+ }
+ else if(type&(DT_INSERT|DT_ATTACH))
+ { if(dt->meth->type&DT_OSET)
+ goto has_root;
+ else
+ { root->left = NIL(Dtlink_t*);
+ root->right = link.left;
+ link.left = root;
+ goto dt_insert;
+ }
+ }
+ else if(type&DT_RENEW) /* a duplicate */
+ { if(dt->meth->type&DT_OSET)
+ { if(disc->freef)
+ (*disc->freef)(dt,obj,disc);
+ if(disc->link < 0)
+ (*dt->memoryf)(dt,(Void_t*)me,0,disc);
+ }
+ else
+ { me->left = NIL(Dtlink_t*);
+ me->right = link.left;
+ link.left = me;
+ dt->data->size += 1;
+ }
+ goto has_root;
+ }
+ }
+ else
+ { /* not found, finish up LEFT and RIGHT trees */
+ r->left = NIL(Dtlink_t*);
+ l->right = NIL(Dtlink_t*);
+
+ if(type&DT_NEXT)
+ goto dt_next;
+ else if(type&DT_PREV)
+ goto dt_prev;
+ else if(type&(DT_SEARCH|DT_MATCH))
+ { no_root:
+ while((t = r->left) )
+ r = t;
+ r->left = link.right;
+ dt->data->here = link.left;
+ return (type&DT_DELETE) ? obj : NIL(Void_t*);
+ }
+ else if(type&(DT_INSERT|DT_ATTACH))
+ { dt_insert:
+ if(disc->makef && (type&DT_INSERT))
+ obj = (*disc->makef)(dt,obj,disc);
+ if(obj)
+ { if(lk >= 0)
+ root = _DTLNK(obj,lk);
+ else
+ { root = (Dtlink_t*)(*dt->memoryf)
+ (dt,NIL(Void_t*),sizeof(Dthold_t),disc);
+ if(root)
+ ((Dthold_t*)root)->obj = obj;
+ else if(disc->makef && disc->freef &&
+ (type&DT_INSERT))
+ (*disc->freef)(dt,obj,disc);
+ }
+ }
+ if(root)
+ { if(dt->data->size >= 0)
+ dt->data->size += 1;
+ goto has_root;
+ }
+ else goto no_root;
+ }
+ else if(type&DT_RENEW)
+ { root = me;
+ dt->data->size += 1;
+ goto has_root;
+ }
+ else /*if(type&DT_DELETE)*/
+ { obj = NIL(Void_t*);
+ goto no_root;
+ }
+ }
+
+ return NIL(Void_t*);
+}
+
+/* make this method available */
+static Dtmethod_t _Dtoset = { dttree, DT_OSET };
+static Dtmethod_t _Dtobag = { dttree, DT_OBAG };
+__DEFINE__(Dtmethod_t*,Dtoset,&_Dtoset);
+__DEFINE__(Dtmethod_t*,Dtobag,&_Dtobag);
+
+#ifndef KPVDEL /* backward compatibility - delete next time around */
+Dtmethod_t _Dttree = { dttree, DT_OSET };
+__DEFINE__(Dtmethod_t*,Dtorder,&_Dttree);
+__DEFINE__(Dtmethod_t*,Dttree,&_Dttree);
+#endif
+
+#ifdef NoF
+NoF(dttree)
+#endif
diff --git a/usr/src/lib/libast/common/cdt/dttreeset.c b/usr/src/lib/libast/common/cdt/dttreeset.c
new file mode 100644
index 0000000000..7e0d237071
--- /dev/null
+++ b/usr/src/lib/libast/common/cdt/dttreeset.c
@@ -0,0 +1,83 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "dthdr.h"
+
+/* Set attributes of a tree.
+**
+** Written by Kiem-Phong Vo (09/17/2001)
+*/
+
+#if __STD_C
+static Dtlink_t* treebalance(Dtlink_t* list, int size)
+#else
+static Dtlink_t* treebalance(list, size)
+Dtlink_t* list;
+int size;
+#endif
+{
+ int n;
+ Dtlink_t *l, *mid;
+
+ if(size <= 2)
+ return list;
+
+ for(l = list, n = size/2 - 1; n > 0; n -= 1)
+ l = l->right;
+
+ mid = l->right; l->right = NIL(Dtlink_t*);
+ mid->left = treebalance(list, (n = size/2) );
+ mid->right = treebalance(mid->right, size - (n + 1));
+ return mid;
+}
+
+#if __STD_C
+int dttreeset(Dt_t* dt, int minp, int balance)
+#else
+int dttreeset(dt, minp, balance)
+Dt_t* dt;
+int minp;
+int balance;
+#endif
+{
+ int size;
+
+ if(dt->meth->type != DT_OSET)
+ return -1;
+
+ size = dtsize(dt);
+
+ if(minp < 0)
+ { for(minp = 0; minp < DT_MINP; ++minp)
+ if((1 << minp) >= size)
+ break;
+ if(minp <= DT_MINP-4) /* use log(size) + 4 */
+ minp += 4;
+ }
+
+ if((dt->data->minp = minp + (minp%2)) > DT_MINP)
+ dt->data->minp = DT_MINP;
+
+ if(balance)
+ dt->data->here = treebalance(dtflatten(dt), size);
+
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/cdt/dtview.c b/usr/src/lib/libast/common/cdt/dtview.c
new file mode 100644
index 0000000000..483f5f496f
--- /dev/null
+++ b/usr/src/lib/libast/common/cdt/dtview.c
@@ -0,0 +1,155 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "dthdr.h"
+
+/* Set a view path from dict to view.
+**
+** Written by Kiem-Phong Vo (5/25/96)
+*/
+
+
+#if __STD_C
+static Void_t* dtvsearch(Dt_t* dt, reg Void_t* obj, reg int type)
+#else
+static Void_t* dtvsearch(dt,obj,type)
+Dt_t* dt;
+reg Void_t* obj;
+reg int type;
+#endif
+{
+ Dt_t *d, *p;
+ Void_t *o, *n, *ok, *nk;
+ int cmp, lk, sz, ky;
+ Dtcompar_f cmpf;
+
+ /* these operations only happen at the top level */
+ if(type&(DT_INSERT|DT_DELETE|DT_CLEAR|DT_RENEW))
+ return (*(dt->meth->searchf))(dt,obj,type);
+
+ if((type&(DT_MATCH|DT_SEARCH)) || /* order sets first/last done below */
+ ((type&(DT_FIRST|DT_LAST)) && !(dt->meth->type&(DT_OBAG|DT_OSET)) ) )
+ { for(d = dt; d; d = d->view)
+ if((o = (*(d->meth->searchf))(d,obj,type)) )
+ break;
+ dt->walk = d;
+ return o;
+ }
+
+ if(dt->meth->type & (DT_OBAG|DT_OSET) )
+ { if(!(type & (DT_FIRST|DT_LAST|DT_NEXT|DT_PREV)) )
+ return NIL(Void_t*);
+
+ n = nk = NIL(Void_t*); p = NIL(Dt_t*);
+ for(d = dt; d; d = d->view)
+ { if(!(o = (*d->meth->searchf)(d, obj, type)) )
+ continue;
+ _DTDSC(d->disc,ky,sz,lk,cmpf);
+ ok = _DTKEY(o,ky,sz);
+
+ if(n) /* get the right one among all dictionaries */
+ { cmp = _DTCMP(d,ok,nk,d->disc,cmpf,sz);
+ if(((type & (DT_NEXT|DT_FIRST)) && cmp < 0) ||
+ ((type & (DT_PREV|DT_LAST)) && cmp > 0) )
+ goto a_dj;
+ }
+ else /* looks good for now */
+ { a_dj: p = d;
+ n = o;
+ nk = ok;
+ }
+ }
+
+ dt->walk = p;
+ return n;
+ }
+
+ /* non-ordered methods */
+ if(!(type & (DT_NEXT|DT_PREV)) )
+ return NIL(Void_t*);
+
+ if(!dt->walk || obj != _DTOBJ(dt->walk->data->here, dt->walk->disc->link) )
+ { for(d = dt; d; d = d->view)
+ if((o = (*(d->meth->searchf))(d, obj, DT_SEARCH)) )
+ break;
+ dt->walk = d;
+ if(!(obj = o) )
+ return NIL(Void_t*);
+ }
+
+ for(d = dt->walk, obj = (*d->meth->searchf)(d, obj, type);; )
+ { while(obj) /* keep moving until finding an uncovered object */
+ { for(p = dt; ; p = p->view)
+ { if(p == d) /* adjacent object is uncovered */
+ return obj;
+ if((*(p->meth->searchf))(p, obj, DT_SEARCH) )
+ break;
+ }
+ obj = (*d->meth->searchf)(d, obj, type);
+ }
+
+ if(!(d = dt->walk = d->view) ) /* move on to next dictionary */
+ return NIL(Void_t*);
+ else if(type&DT_NEXT)
+ obj = (*(d->meth->searchf))(d,NIL(Void_t*),DT_FIRST);
+ else obj = (*(d->meth->searchf))(d,NIL(Void_t*),DT_LAST);
+ }
+}
+
+#if __STD_C
+Dt_t* dtview(reg Dt_t* dt, reg Dt_t* view)
+#else
+Dt_t* dtview(dt,view)
+reg Dt_t* dt;
+reg Dt_t* view;
+#endif
+{
+ reg Dt_t* d;
+
+ UNFLATTEN(dt);
+ if(view)
+ { UNFLATTEN(view);
+ if(view->meth != dt->meth) /* must use the same method */
+ return NIL(Dt_t*);
+ }
+
+ /* make sure there won't be a cycle */
+ for(d = view; d; d = d->view)
+ if(d == dt)
+ return NIL(Dt_t*);
+
+ /* no more viewing lower dictionary */
+ if((d = dt->view) )
+ d->nview -= 1;
+ dt->view = dt->walk = NIL(Dt_t*);
+
+ if(!view)
+ { dt->searchf = dt->meth->searchf;
+ return d;
+ }
+
+ /* ok */
+ dt->view = view;
+ dt->searchf = dtvsearch;
+ view->nview += 1;
+
+ return view;
+}
diff --git a/usr/src/lib/libast/common/cdt/dtwalk.c b/usr/src/lib/libast/common/cdt/dtwalk.c
new file mode 100644
index 0000000000..654f2aa982
--- /dev/null
+++ b/usr/src/lib/libast/common/cdt/dtwalk.c
@@ -0,0 +1,52 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "dthdr.h"
+
+/* Walk a dictionary and all dictionaries viewed through it.
+** userf: user function
+**
+** Written by Kiem-Phong Vo (5/25/96)
+*/
+
+#if __STD_C
+int dtwalk(reg Dt_t* dt, int (*userf)(Dt_t*, Void_t*, Void_t*), Void_t* data)
+#else
+int dtwalk(dt,userf,data)
+reg Dt_t* dt;
+int(* userf)();
+Void_t* data;
+#endif
+{
+ reg Void_t *obj, *next;
+ reg Dt_t* walk;
+ reg int rv;
+
+ for(obj = dtfirst(dt); obj; )
+ { if(!(walk = dt->walk) )
+ walk = dt;
+ next = dtnext(dt,obj);
+ if((rv = (*userf)(walk, obj, data )) < 0)
+ return rv;
+ obj = next;
+ }
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/comp/atexit.c b/usr/src/lib/libast/common/comp/atexit.c
new file mode 100644
index 0000000000..f2de7ed290
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/atexit.c
@@ -0,0 +1,115 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * ANSI C atexit()
+ * arrange for func to be called LIFO on exit()
+ */
+
+#include <ast.h>
+
+#if _lib_atexit
+
+NoN(atexit)
+
+#else
+
+#if _lib_onexit || _lib_on_exit
+
+#if !_lib_onexit
+#define onexit on_exit
+#endif
+
+extern int onexit(void(*)(void));
+
+int
+atexit(void (*func)(void))
+{
+ return(onexit(func));
+}
+
+#else
+
+struct list
+{
+ struct list* next;
+ void (*func)(void);
+};
+
+static struct list* funclist;
+
+extern void _exit(int);
+
+int
+atexit(void (*func)(void))
+{
+ register struct list* p;
+
+ if (!(p = newof(0, struct list, 1, 0))) return(-1);
+ p->func = func;
+ p->next = funclist;
+ funclist = p;
+ return(0);
+}
+
+void
+_ast_atexit(void)
+{
+ register struct list* p;
+
+ while (p = funclist)
+ {
+ funclist = p->next;
+ (*p->func)();
+ }
+}
+
+#if _std_cleanup
+
+#if _lib__cleanup
+extern void _cleanup(void);
+#endif
+
+void
+exit(int code)
+{
+ _ast_atexit();
+#if _lib__cleanup
+ _cleanup();
+#endif
+ _exit(code);
+}
+
+#else
+
+void
+_cleanup(void)
+{
+ _ast_atexit();
+}
+
+#endif
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/basename.c b/usr/src/lib/libast/common/comp/basename.c
new file mode 100644
index 0000000000..43f4957604
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/basename.c
@@ -0,0 +1,55 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * basename(3) implementation
+ */
+
+#include <ast_std.h>
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern char *basename(register char *pathname)
+{
+ register char *first, *last;
+ for(first=last=pathname; *last; last++);
+ /* back over trailing '/' */
+ if(last>first)
+ while(*--last=='/' && last > first);
+ if(last==first && *last=='/')
+ {
+ /* all '/' or "" */
+ if(*first=='/')
+ if(*++last=='/') /* keep leading // */
+ last++;
+ }
+ else
+ {
+ for(first=last++;first>pathname && *first!='/';first--);
+ if(*first=='/')
+ first++;
+ }
+ *last = 0;
+ return(first);
+}
diff --git a/usr/src/lib/libast/common/comp/catopen.c b/usr/src/lib/libast/common/comp/catopen.c
new file mode 100644
index 0000000000..2ae5cbc27b
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/catopen.c
@@ -0,0 +1,178 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * catopen intercept
+ * the ast catalogs are checked first
+ * the ast mc* and native cat* routines do all the work
+ * catalogs found by mcfind() are converted from utf to ucs
+ *
+ * nl_catd is cast to void*
+ * this is either an Mc_t* (Mc_t.set != 0)
+ * or a Cc_t* where Cc_t.cat is the native nl_catd
+ */
+
+#include <ast.h>
+#include <mc.h>
+#include <nl_types.h>
+#include <iconv.h>
+
+#ifndef DEBUG_trace
+#define DEBUG_trace 0
+#endif
+
+#if _lib_catopen
+
+#undef nl_catd
+#undef catopen
+#undef catgets
+#undef catclose
+
+typedef struct
+{
+ Mcset_t* set;
+ nl_catd cat;
+ iconv_t cvt;
+ Sfio_t* tmp;
+} Cc_t;
+
+#else
+
+#define _ast_nl_catd nl_catd
+#define _ast_catopen catopen
+#define _ast_catgets catgets
+#define _ast_catclose catclose
+
+#endif
+
+_ast_nl_catd
+_ast_catopen(const char* name, int flag)
+{
+ Mc_t* mc;
+ char* s;
+ Sfio_t* ip;
+ char path[PATH_MAX];
+
+ /*
+ * first try the ast catalogs
+ */
+
+#if DEBUG_trace
+sfprintf(sfstderr, "AHA#%d:%s %s\n", __LINE__, __FILE__, name);
+#endif
+ if ((s = mcfind(path, NiL, name, LC_MESSAGES, flag)) && (ip = sfopen(NiL, s, "r")))
+ {
+#if DEBUG_trace
+sfprintf(sfstderr, "AHA#%d:%s %s\n", __LINE__, __FILE__, s);
+#endif
+ mc = mcopen(ip);
+ sfclose(ip);
+ if (mc)
+ return (_ast_nl_catd)mc;
+ }
+#if _lib_catopen
+ if (strcmp(setlocale(LC_MESSAGES, NiL), "debug"))
+ {
+ Cc_t* cc;
+ nl_catd d;
+
+ /*
+ * now the native catalogs
+ */
+
+ if (s && (d = catopen(s, flag)) != (nl_catd)(-1) || !(s = 0) && (d = catopen(name, flag)) != (nl_catd)(-1))
+ {
+ if (!(cc = newof(0, Cc_t, 1, 0)))
+ {
+ catclose(d);
+ return (_ast_nl_catd)(-1);
+ }
+ cc->cat = d;
+ if ((s || *name == '/') && (ast.locale.set & (1<<AST_LC_MESSAGES)))
+ {
+ if ((cc->cvt = iconv_open("", "utf")) == (iconv_t)(-1) || !(cc->tmp = sfstropen()))
+ {
+ catclose(d);
+ return (_ast_nl_catd)(-1);
+ }
+ }
+ else
+ cc->cvt = (iconv_t)(-1);
+#if DEBUG_trace
+sfprintf(sfstderr, "AHA#%d:%s %s %s native %p\n", __LINE__, __FILE__, s, name, cc->cat);
+#endif
+ return (_ast_nl_catd)cc;
+ }
+ }
+#endif
+
+ /*
+ * loser
+ */
+
+ return (_ast_nl_catd)(-1);
+}
+
+char*
+_ast_catgets(_ast_nl_catd cat, int set, int num, const char* msg)
+{
+ if (cat == (_ast_nl_catd)(-1))
+ return (char*)msg;
+#if _lib_catopen
+ if (!((Cc_t*)cat)->set)
+ {
+ char* s;
+ size_t n;
+
+ msg = (char*)catgets(((Cc_t*)cat)->cat, set, num, msg);
+ if (((Cc_t*)cat)->cvt != (iconv_t)(-1))
+ {
+ s = (char*)msg;
+ n = strlen(s);
+ iconv_write(((Cc_t*)cat)->cvt, ((Cc_t*)cat)->tmp, &s, &n, NiL);
+ if (s = sfstruse(((Cc_t*)cat)->tmp))
+ return s;
+ }
+ return (char*)msg;
+ }
+#endif
+ return mcget((Mc_t*)cat, set, num, msg);
+}
+
+int
+_ast_catclose(_ast_nl_catd cat)
+{
+ if (cat == (_ast_nl_catd)(-1))
+ return -1;
+#if _lib_catopen
+ if (!((Cc_t*)cat)->set)
+ {
+ if (((Cc_t*)cat)->cvt != (iconv_t)(-1))
+ iconv_close(((Cc_t*)cat)->cvt);
+ if (((Cc_t*)cat)->tmp)
+ sfclose(((Cc_t*)cat)->tmp);
+ return catclose(((Cc_t*)cat)->cat);
+ }
+#endif
+ return mcclose((Mc_t*)cat);
+}
diff --git a/usr/src/lib/libast/common/comp/closelog.c b/usr/src/lib/libast/common/comp/closelog.c
new file mode 100644
index 0000000000..9a91d041bb
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/closelog.c
@@ -0,0 +1,51 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * closelog implementation
+ */
+
+#include <ast.h>
+
+#if _lib_syslog
+
+NoN(closelog)
+
+#else
+
+#include "sysloglib.h"
+
+void
+closelog(void)
+{
+ if (log.fd >= 0)
+ {
+ close(log.fd);
+ log.fd = -1;
+ }
+ log.facility = 0;
+ log.flags = 0;
+ log.mask = ~0;
+ log.attempt = 0;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/conf.sh b/usr/src/lib/libast/common/comp/conf.sh
new file mode 100644
index 0000000000..483a4cee77
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/conf.sh
@@ -0,0 +1,1511 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1985-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# Glenn Fowler <gsf@research.att.com> #
+# David Korn <dgk@research.att.com> #
+# Phong Vo <kpv@research.att.com> #
+# #
+########################################################################
+: generate getconf and limits info
+#
+# @(#)conf.sh (AT&T Research) 2007-04-02
+#
+# this script generates these files from the table file in the first arg
+# the remaining args are the C compiler name and flags
+#
+# conflim.h supplemental limits.h definitions
+# conftab.h readonly string table definitions
+# conftab.c readonly string table data
+#
+# you may think it should be simpler
+# but you shall be confused anyway
+#
+
+case $-:$BASH_VERSION in
+*x*:[0123456789]*) : bash set -x is broken :; set +ex ;;
+esac
+
+LC_ALL=C
+export LC_ALL
+
+command=conf
+
+shell=`eval 'x=123&&integer n=\${#x}\${x#1?}&&((n==330/(10)))&&echo ksh' 2>/dev/null`
+
+append=0
+debug=
+extra=0
+keep_call='*'
+keep_name='*'
+trace=
+verbose=0
+while :
+do case $1 in
+ -a) append=1 ;;
+ -c*) keep_call=${1#-?} ;;
+ -d*) debug=$1 ;;
+ -l) extra=1 ;;
+ -n*) keep_name=${1#-?} ;;
+ -t) trace=1 ;;
+ -v) verbose=1 ;;
+ -*) echo "Usage: $command [-a] [-ccall-pattern] [-dN] [-l] [-nname_pattern] [-t] [-v] conf.tab" >&2; exit 2 ;;
+ *) break ;;
+ esac
+ shift
+done
+head='#include "FEATURE/standards"
+#include "FEATURE/common"'
+tail='#include "FEATURE/param"'
+generated="/* : : generated by $command from $1 : : */"
+hdr=
+ifs=${IFS-'
+ '}
+nl='
+'
+sp=' '
+ob='{'
+cb='}'
+sym=[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_]*
+tmp=conf.tmp
+case $verbose:$debug$trace in
+1:?*) echo "$command: debug=$debug trace=$trace keep_call=$keep_call keep_name=$keep_name" >&2 ;;
+esac
+case $trace in
+1) PS4='+$LINENO+ '; set -x ;;
+esac
+
+case $# in
+0) case $extra in
+ 0) echo "$command: table argument expected" >&2
+ exit 1
+ ;;
+ esac
+ tab=/dev/null
+ ;;
+*) tab=$1
+ shift
+ if test ! -f $tab
+ then echo "$command: $tab: cannot read" >&2
+ exit 1
+ fi
+ ;;
+esac
+case $# in
+0) cc=cc ;;
+*) cc=$* ;;
+esac
+
+rm -f $tmp.*
+case $debug in
+'') trap "code=\$?; rm -f $tmp.*; exit \$code" 0 1 2 ;;
+esac
+
+# determine the intmax_t printf format
+
+cat > $tmp.c <<!
+${head}
+int
+main()
+{
+#if _ast_intmax_long
+ return 1;
+#else
+ return 0;
+#endif
+}
+!
+if $cc -o $tmp.exe $tmp.c >/dev/null 2>&1 && ./$tmp.exe
+then LL='ll'
+else LL='l'
+fi
+
+# set up the names and keys
+
+keys=
+standards=
+
+case $append$extra in
+00) case $verbose in
+ 1) echo "$command: read $tab" >&2 ;;
+ esac
+ exec < $tab
+ while :
+ do IFS=""
+ read line
+ eof=$?
+ IFS=$ifs
+ case $eof in
+ 0) ;;
+ *) break ;;
+ esac
+ case $line in
+ ""|\#*) ;;
+ *) set x $line
+ shift; name=$1
+ shift; standard=$1
+ shift; call=$1
+ shift; section=$1
+ shift; flags=$1
+ alternates=
+ define=
+ values=
+ script=
+ headers=
+ while :
+ do shift
+ case $# in
+ 0) break ;;
+ esac
+ case $1 in
+ ":") shift
+ eval script='$'script_$1
+ break
+ ;;
+ *"{") case $1 in
+ "sh{") script="# $name" ;;
+ *) script= ;;
+ esac
+ shift
+ args="$*"
+ IFS=""
+ while read line
+ do case $line in
+ "}") break ;;
+ esac
+ script=$script$nl$line
+ done
+ IFS=$ifs
+ break
+ ;;
+ *.h) case $shell in
+ ksh) f=${1%.h} ;;
+ *) f=`echo $1 | sed 's,\.h$,,'` ;;
+ esac
+ case " $hdr " in
+ *" $f "*)
+ headers=$headers$nl#include$sp'<'$1'>'
+ ;;
+ *" -$f- "*)
+ ;;
+ *) if iffe -n - hdr $f | grep -q _hdr_$f
+ then hdr="$hdr $f"
+ headers=$headers$nl#include$sp'<'$1'>'
+ else hdr="$hdr -$f-"
+ fi
+ ;;
+ esac
+ ;;
+ *) values=$values$sp$1
+ case $1 in
+ $sym) echo "$1" >> $tmp.v ;;
+ esac
+ ;;
+ esac
+ done
+ case " $standards " in
+ *" $standard "*)
+ ;;
+ *) standards="$standards $standard"
+ ;;
+ esac
+ case $name:$flags in
+ *:*S*) ;;
+ VERSION)flags="${flags}S" ;;
+ esac
+ case $name in
+ *VERSION*)key=${standard}${section} ;;
+ *) key= ;;
+ esac
+ case $key in
+ ''|*_) key=${key}${name} ;;
+ *) key=${key}_${name} ;;
+ esac
+ eval sys='$'CONF_call_${key}
+ case $sys in
+ ?*) call=$sys ;;
+ esac
+ case $call in
+ SI) sys=CS ;;
+ *) sys=$call ;;
+ esac
+ key=${sys}_${key}
+ keys="$keys$nl$key"
+ eval CONF_name_${key}='$'name
+ eval CONF_standard_${key}='$'standard
+ eval CONF_call_${key}='$'call
+ eval CONF_section_${key}='$'section
+ eval CONF_flags_${key}='$'flags
+ eval CONF_define_${key}='$'define
+ eval CONF_values_${key}='$'values
+ eval CONF_script_${key}='$'script
+ eval CONF_args_${key}='$'args
+ eval CONF_headers_${key}='$'headers
+ eval CONF_keys_${name}=\"'$'CONF_keys_${name} '$'key\"
+ ;;
+ esac
+ done
+ ;;
+esac
+case $debug in
+-d1) for key in $keys
+ do eval name=\"'$'CONF_name_$key\"
+ case $name in
+ ?*) eval standard=\"'$'CONF_standard_$key\"
+ eval call=\"'$'CONF_call_$key\"
+ eval section=\"'$'CONF_section_$key\"
+ eval flags=\"'$'CONF_flags_$key\"
+ eval define=\"'$'CONF_define_$key\"
+ eval values=\"'$'CONF_values_$key\"
+ eval script=\"'$'CONF_script_$key\"
+ eval args=\"'$'CONF_args_$key\"
+ eval headers=\"'$'CONF_headers_$key\"
+ printf "%29s %35s %8s %2s %1d %5s %s$nl" "$name" "$key" "$standard" "$call" "$section" "$flags" "$define${values:+$sp=$values}${headers:+$sp$headers$nl}${script:+$sp$ob$script$nl$cb}"
+ ;;
+ esac
+ done
+ exit
+ ;;
+esac
+
+systeminfo='
+#if !defined(SYS_NMLEN)
+#define SYS_NMLEN 9
+#endif
+#include <sys/systeminfo.h>'
+echo "$systeminfo" > $tmp.c
+$cc -E $tmp.c >/dev/null 2>&1 || systeminfo=
+
+# check for native getconf(1)
+
+CONF_getconf=
+CONF_getconf_a=
+for d in /usr/bin /bin /usr/sbin /sbin
+do if test -x $d/getconf
+ then case `$d/getconf --?-version 2>&1` in
+ *"AT&T"*"Research"*)
+ : presumably an implementation also configured from conf.tab
+ ;;
+ *) CONF_getconf=$d/getconf
+ if $CONF_getconf -a >/dev/null 2>&1
+ then CONF_getconf_a=-a
+ fi
+ ;;
+ esac
+ break
+ fi
+done
+export CONF_getconf CONF_getconf_a
+
+case $verbose in
+1) echo "$command: check ${CONF_getconf:+$CONF_getconf(1),}confstr(2),pathconf(2),sysconf(2),sysinfo(2) configuration names" >&2 ;;
+esac
+{
+ echo "#include <unistd.h>$systeminfo
+int i = 0;" > $tmp.c
+ $cc -E $tmp.c
+} |
+sed \
+ -e '/^#[^0123456789]*1[ ]*".*".*/!d' \
+ -e 's/^#[^0123456789]*1[ ]*"\(.*\)".*/\1/' |
+sort -u > $tmp.f
+{
+sed \
+ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]/ /g' \
+ -e 's/[ ][ ]*/\n/g' \
+ `cat $tmp.f` 2>/dev/null |
+ egrep '^(SI|_(CS|PC|SC|SI))_.'
+ case $CONF_getconf_a in
+ ?*) $CONF_getconf $CONF_getconf_a | sed 's,[=: ].*,,'
+ ;;
+ *) case $CONF_getconf in
+ ?*) for v in `strings $CONF_getconf | grep '^[ABCDEFGHIJKLMNOPQRSTUVWXYZ_][ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]*$'`
+ do if $CONF_getconf $v >/dev/null
+ then echo $v
+ fi
+ done
+ ;;
+ esac
+ ;;
+ esac 2>/dev/null
+} |
+egrep -v '^_[ABCDEFGHIJKLMNOPQRSTUVWXYZ]+_(COUNT|LAST|N|STR)$' |
+sort -u > $tmp.g
+{
+ grep '^_' $tmp.g
+ grep '^[^_]' $tmp.g
+} > $tmp.t
+mv $tmp.t $tmp.g
+case $debug in
+-d2) exit ;;
+esac
+
+HOST=`package | sed -e 's,[0123456789.].*,,' | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
+case $HOST in
+'') HOST=SYSTEM ;;
+esac
+
+exec < $tmp.g
+
+while read line
+do flags=F
+ section=
+ underscore=
+ define=$line
+ IFS=_
+ set $line
+ IFS=$ifs
+ case $1 in
+ '') case $# in
+ 0) continue ;;
+ esac
+ shift
+ ;;
+ esac
+ case $1 in
+ CS|PC|SC|SI)
+ call=$1
+ shift
+ standard=$1
+ ;;
+ *) flags=${flags}R
+ standard=$1
+ while :
+ do case $# in
+ 0) continue 2 ;;
+ esac
+ shift
+ case $1 in
+ CS|PC|SC|SI)
+ call=$1
+ shift
+ break
+ ;;
+ O|o|OLD|old)
+ continue 2
+ ;;
+ esac
+ standard=${standard}_$1
+ done
+ ;;
+ esac
+ case $1 in
+ SET) continue ;;
+ esac
+ case $standard in
+ _*) standard=`echo $standard | sed 's,^_*,,'` ;;
+ esac
+ case " $standards " in
+ *" $standard "*)
+ ;;
+ *) case $standard in
+ [0123456789]*)
+ section=$standard
+ standard=POSIX
+ ;;
+ *[0123456789])
+ eval `echo $standard | sed 's,\(.*\)\([0123456789]*\),standard=\1 section=\2,'`
+ ;;
+ esac
+ ;;
+ esac
+ case $flags in
+ *R*) case $call in
+ SI) ;;
+ *) underscore=U ;;
+ esac
+ ;;
+ *) case " $standards " in
+ " C ") shift
+ ;;
+ *" $standard "*)
+ case $call in
+ SI) ;;
+ *) flags=${flags}P
+ underscore=U
+ ;;
+ esac
+ shift
+ ;;
+ *) standard=
+ ;;
+ esac
+ ;;
+ esac
+ case $standard in
+ '') standard=$HOST
+ case $call in
+ SI) ;;
+ *) underscore=U ;;
+ esac
+ case $call in
+ CS|PC|SC)
+ case $define in
+ _${call}_*)
+ standard=POSIX
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+ part=$section
+ case $section in
+ '') section=1
+ case $standard in
+ POSIX|XOPEN) part=$section ;;
+ esac
+ ;;
+ esac
+ name=
+ while :
+ do case $# in
+ 0) break ;;
+ esac
+ case $name in
+ '') name=$1 ;;
+ *) name=${name}_$1 ;;
+ esac
+ shift
+ done
+ case $name in
+ '') ;;
+ CONFORMANCE|FS_3D|HOSTTYPE|LIBPATH|LIBPREFIX|LIBSUFFIX|PATH_ATTRIBUTES|PATH_RESOLVE|UNIVERSE)
+ ;;
+ *) values=
+ script=
+ args=
+ headers=
+ case $name in
+ V[123456789]_*|V[123456789][0123456789]_*) underscore=VW ;;
+ esac
+ case $call in
+ CS|SI) key=CS ;;
+ *) key=$call ;;
+ esac
+ case $name in
+ *VERSION*)key=${key}_${standard}${part} ;;
+ esac
+ key=${key}_${name}
+ eval x='$'CONF_keys_$name
+ case $x in
+ '') eval x='$'CONF_name_$key
+ case $x in
+ '') case $call in
+ SI) flags=O$flags ;;
+ esac
+ case $underscore in
+ ?*) flags=${flags}${underscore} ;;
+ esac
+ old=QQ
+ case $name in
+ *VERSION*)old=${old}_${standard}${part} ;;
+ esac
+ old=${old}_${name}
+ eval x='$'CONF_name_$old
+ case $x in
+ ?*) eval CONF_name_$old=
+ eval flags='$'flags'$'CONF_flags_$old
+ eval values='$'CONF_values_$old
+ eval script='$'CONF_script_$old
+ eval args='$'CONF_args_$old
+ eval headers='$'CONF_headers_$old
+ ;;
+ esac
+ keys="$keys$nl$key"
+ eval CONF_name_${key}='$'name
+ eval CONF_standard_${key}='$'standard
+ eval CONF_call_${key}='$'call
+ eval CONF_section_${key}='$'section
+ eval CONF_flags_${key}=d'$'flags
+ eval CONF_define_${key}='$'define
+ eval CONF_values_${key}='$'values
+ eval CONF_script_${key}='$'script
+ eval CONF_args_${key}='$'args
+ eval CONF_headers_${key}='$'headers
+ ;;
+ *) eval x='$'CONF_define_$key
+ case $x in
+ ?*) case $call in
+ CS) eval x='$'CONF_call_$key
+ case $x in
+ SI) ;;
+ *) define= ;;
+ esac
+ ;;
+ *) define=
+ ;;
+ esac
+ ;;
+ esac
+ case $define in
+ ?*) eval CONF_define_${key}='$'define
+ eval CONF_call_${key}='$'call
+ eval x='$'CONF_call_${key}
+ case $x in
+ QQ) ;;
+ *) case $flags in
+ *R*) flags=R ;;
+ *) flags= ;;
+ esac
+ ;;
+ esac
+ case $call in
+ SI) flags=O$flags ;;
+ esac
+ eval CONF_flags_${key}=d'$'flags'$'CONF_flags_${key}
+ ;;
+ esac
+ old=QQ
+ case $name in
+ *VERSION*)old=${old}_${standard}${part} ;;
+ esac
+ old=${old}_${name}
+ eval CONF_name_$old=
+ esac
+ ;;
+ *) for key in $x
+ do eval x='$'CONF_call_${key}
+ case $x in
+ XX) eval CONF_call_${key}=QQ
+ eval CONF_flags_${key}=S'$'CONF_flags_${key}
+ ;;
+ esac
+ done
+ esac
+ ;;
+ esac
+done
+
+# sort keys by name
+
+keys=`for key in $keys
+do eval echo '$'CONF_name_$key '$'key
+done | sort -u | sed 's,.* ,,'`
+case $debug in
+-d3) for key in $keys
+ do eval name=\"'$'CONF_name_$key\"
+ case $name in
+ ?*) eval standard=\"'$'CONF_standard_$key\"
+ eval call=\"'$'CONF_call_$key\"
+ eval section=\"'$'CONF_section_$key\"
+ eval flags=\"'$'CONF_flags_$key\"
+ eval define=\"'$'CONF_define_$key\"
+ eval values=\"'$'CONF_values_$key\"
+ eval script=\"'$'CONF_script_$key\"
+ eval headers=\"'$'CONF_headers_$key\"
+ printf "%29s %35s %8s %2s %1d %5s %s$nl" "$name" "$key" "$standard" "$call" "$section" "$flags" "$define${values:+$sp=$values}${headers:+$sp$headers$nl}${script:+$sp$ob$script$nl$cb}"
+ ;;
+ esac
+ done
+ exit
+ ;;
+esac
+
+# mark the dups CONF_PREFIXED
+
+prev_key=
+prev_name=
+for key in $keys
+do eval name=\"'$'CONF_name_$key\"
+ case $name in
+ '') continue
+ ;;
+ $prev_name)
+ eval p='$'CONF_flags_${prev_key}
+ eval c='$'CONF_flags_${key}
+ case $p:$c in
+ *L*:*L*);;
+ *L*:*) c=L${c} ;;
+ *:*L*) p=L${p} ;;
+ *) p=P$p c=P$c ;;
+ esac
+ eval CONF_flags_${prev_key}=$p
+ eval CONF_flags_${key}=$c
+ ;;
+ esac
+ prev_name=$name
+ prev_key=$key
+done
+
+# collect all the macros/enums
+
+for key in $keys
+do eval name=\"'$'CONF_name_$key\"
+ case $name in
+ '') continue ;;
+ $keep_name) ;;
+ *) continue ;;
+ esac
+ eval call=\"'$'CONF_call_$key\"
+ case $call in
+ $keep_call) ;;
+ *) continue ;;
+ esac
+ eval standard=\"'$'CONF_standard_$key\"
+ eval section=\"'$'CONF_section_$key\"
+ eval flags=\"'$'CONF_flags_$key\"
+ eval define=\"'$'CONF_define_$key\"
+ eval values=\"'$'CONF_values_$key\"
+ eval script=\"'$'CONF_script_$key\"
+ eval args=\"'$'CONF_args_$key\"
+ eval headers=\"'$'CONF_headers_$key\"
+ conf_name=$name
+ case $call in
+ QQ) call=XX
+ for c in SC PC CS
+ do case $flags in
+ *S*) case $section in
+ 1) eval x='$'CONF_call_${c}_${standard}_${name} ;;
+ *) eval x='$'CONF_call_${c}_${standard}${section}_${name} ;;
+ esac
+ ;;
+ *) eval x='$'CONF_call_${c}_${name}
+ ;;
+ esac
+ case $x in
+ ?*) call=$x
+ break
+ ;;
+ esac
+ done
+ case $call in
+ XX) for c in SC PC CS
+ do echo "_${c}_${name}"
+ case $flags in
+ *S*) case $section in
+ 1) echo "_${c}_${standard}_${name}" ;;
+ *) echo "_${c}_${standard}${section}_${name}" ;;
+ esac
+ ;;
+ esac
+ done
+ ;;
+ esac
+ ;;
+ esac
+ case $call in
+ CS|PC|SC|SI|XX)
+ ;;
+ *) echo "$command: $name: $call: invalid call" >&2
+ exit 1
+ ;;
+ esac
+ case $flags in
+ *[ABEGHIJQTYZabcefghijklmnopqrstuvwxyz_123456789]*)
+ echo "$command: $name: $flags: invalid flag(s)" >&2
+ exit 1
+ ;;
+ esac
+ case $section in
+ [01]) ;;
+ *) case $flags in
+ *N*) ;;
+ *) name=${section}_${name} ;;
+ esac
+ standard=${standard}${section}
+ ;;
+ esac
+ case $call in
+ XX) ;;
+ *) case $flags in
+ *d*) conf_op=${define} ;;
+ *O*) conf_op=${call}_${name} ;;
+ *R*) conf_op=_${standard}_${call}_${name} ;;
+ *S*) conf_op=_${call}_${standard}_${name} ;;
+ *) conf_op=_${call}_${name} ;;
+ esac
+ echo "${conf_op}"
+ ;;
+ esac
+ case $standard:$flags in
+ C:*) ;;
+ *:*L*) echo "${conf_name}"
+ echo "_${standard}_${conf_name}"
+ ;;
+ *:*M*) case $section in
+ 1) echo "_${standard}_${conf_name}" ;;
+ *) echo "_${standard}${section}_${conf_name}" ;;
+ esac
+ ;;
+ esac
+done > $tmp.q
+sort -u < $tmp.q > $tmp.t
+mv $tmp.t $tmp.q
+sort -u < $tmp.v > $tmp.t
+mv $tmp.t $tmp.v
+case $debug in
+-d4) exit ;;
+esac
+
+# test all the macros in a few batches (some compilers have an error limit)
+
+defined() # list-file
+{
+ : > $tmp.p
+ while :
+ do {
+ cat <<!
+${head}
+#include <sys/types.h>
+#include <limits.h>
+#include <unistd.h>$systeminfo$headers
+${tail}
+#undef conf
+unsigned int conf[] = {
+!
+ sed 's/$/,/' $1
+ echo "};"
+ } > $tmp.c
+ [[ -f $tmp.1.c ]] || cp $tmp.c $tmp.1.c
+ if $cc -c $tmp.c > $tmp.e 2>&1
+ then break
+ fi
+ [[ -f $tmp.1.e ]] || cp $tmp.e $tmp.1.e
+ snl='\
+'
+ sed "s/[^_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789][^_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789]*/${snl}/g" $tmp.e |
+ grep '^[_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz][_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789]*$' |
+ sort -u > $tmp.n
+ cmp -s $tmp.n $tmp.p && break
+ fgrep -x -v -f $tmp.n $1 > $tmp.y
+ mv $tmp.y $1
+ mv $tmp.n $tmp.p
+ done
+ {
+ cat <<!
+${head}
+#include <sys/types.h>
+#include <limits.h>
+#include <unistd.h>$systeminfo$headers
+${tail}
+#undef conf
+!
+ sed 's/.*/conf "&" = &/' $1
+ } > $tmp.c
+ $cc -E $tmp.c 2>/dev/null |
+ sed -e '/conf[ ]*".*"[ ]*=[ ]*/!d' -e '/[_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789][ ]*(/!d' -e 's/.*"\(.*\)".*/\1/' > $tmp.n
+ if test -s $tmp.n
+ then fgrep -x -v -f $tmp.n $1 > $tmp.y
+ mv $tmp.y $1
+ fi
+}
+
+case $verbose in
+1) echo "$command: check macros/enums as static initializers" >&2 ;;
+esac
+defined $tmp.q
+defined $tmp.v
+case $debug in
+-d5) exit ;;
+esac
+
+# mark the constant macros/enums
+
+exec < $tmp.q
+while read line
+do eval CONF_const_${line}=1
+done
+exec < $tmp.v
+while read line
+do eval CONF_const_${line}=1
+done
+
+# mark the string literal values
+
+{
+ cat <<!
+${head}
+#include <sys/types.h>
+#include <limits.h>
+#include <unistd.h>$systeminfo$headers
+${tail}
+#undef conf
+!
+ sed 's/.*/conf "&" = &/' $tmp.q
+} > $tmp.c
+$cc -E $tmp.c 2>/dev/null |
+sed -e '/conf[ ]*".*"[ ]*=[ ]*"/!d' -e 's/.*"\([^"]*\)".*/\1/' > $tmp.e
+exec < $tmp.e
+while read line
+do eval CONF_string_${line}=1
+done
+
+# walk through the table
+
+case $shell in
+ksh) integer len name_max ;;
+esac
+name_max=1
+export tmp name standard call cc
+
+for key in $keys
+do eval name=\"'$'CONF_name_$key\"
+ case $name in
+ '') continue ;;
+ $keep_name) ;;
+ *) continue ;;
+ esac
+ eval call=\"'$'CONF_call_$key\"
+ case $call in
+ $keep_call) ;;
+ *) continue ;;
+ esac
+ eval standard=\"'$'CONF_standard_$key\"
+ eval section=\"'$'CONF_section_$key\"
+ eval flags=\"'$'CONF_flags_$key\"
+ eval define=\"'$'CONF_define_$key\"
+ eval values=\"'$'CONF_values_$key\"
+ eval script=\"'$'CONF_script_$key\"
+ eval args=\"'$'CONF_args_$key\"
+ eval headers=\"'$'CONF_headers_$key\"
+ conf_name=$name
+ case $call in
+ QQ) call=XX
+ for c in SC PC CS
+ do case $flags in
+ *S*) case $section in
+ 1) eval x='$'CONF_call_${c}_${standard}_${name} ;;
+ *) eval x='$'CONF_call_${c}_${standard}${section}_${name} ;;
+ esac
+ ;;
+ *) eval x='$'CONF_call_${c}_${name}
+ ;;
+ esac
+ case $x in
+ ?*) call=$x
+ break
+ ;;
+ esac
+ done
+ case $call in
+ XX) for c in SC PC CS
+ do case $flags in
+ *S*) case $section in
+ 1) eval x='$'CONF_const__${c}_${standard}_${name} ;;
+ *) eval x='$'CONF_const__${c}_${standard}${section}_${name} ;;
+ esac
+ ;;
+ *) eval x='$'CONF_const__${c}_${name}
+ ;;
+ esac
+ case $x in
+ 1) call=$c
+ break
+ ;;
+ esac
+ done
+ ;;
+ esac
+ case $call in
+ XX) case $standard in
+ C) standard=POSIX ;;
+ esac
+ case $flags in
+ *L*) flags=lFU ;;
+ *) flags=FU ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+ case " $standards " in
+ *" $standard "*)
+ ;;
+ *) standards="$standards $standard"
+ ;;
+ esac
+ conf_standard=CONF_${standard}
+ case $call in
+ CS) conf_call=CONF_confstr
+ ;;
+ PC) conf_call=CONF_pathconf
+ ;;
+ SC) conf_call=CONF_sysconf
+ ;;
+ SI) conf_call=CONF_sysinfo
+ ;;
+ XX) conf_call=CONF_nop
+ ;;
+ esac
+ conf_op=-1
+ for s in _${call}_${standard}${section}_${name} _${call}_${standard}_${name} _${call}_${section}_${name} _${call}_${name} ${call}_${name}
+ do eval x='$'CONF_const_${s}
+ case $x in
+ 1) conf_op=${s}
+ break
+ ;;
+ esac
+ done
+ conf_section=$section
+ conf_flags=0
+ case $flags in
+ *C*) conf_flags="${conf_flags}|CONF_DEFER_CALL" ;;
+ esac
+ case $flags in
+ *D*) conf_flags="${conf_flags}|CONF_DEFER_MM" ;;
+ esac
+ case $flags in
+ *F*) conf_flags="${conf_flags}|CONF_FEATURE" ;;
+ esac
+ case $flags in
+ *L*) conf_flags="${conf_flags}|CONF_LIMIT" ;;
+ esac
+ case $flags in
+ *M*) conf_flags="${conf_flags}|CONF_MINMAX" ;;
+ esac
+ case $flags in
+ *N*) conf_flags="${conf_flags}|CONF_NOSECTION" ;;
+ esac
+ case $flags in
+ *P*) conf_flags="${conf_flags}|CONF_PREFIXED" ;;
+ esac
+ case $flags in
+ *S*) conf_flags="${conf_flags}|CONF_STANDARD" ;;
+ esac
+ case $flags in
+ *U*) conf_flags="${conf_flags}|CONF_UNDERSCORE" ;;
+ esac
+ case $flags in
+ *V*) conf_flags="${conf_flags}|CONF_NOUNDERSCORE" ;;
+ esac
+ case $flags in
+ *W*) conf_flags="${conf_flags}|CONF_PREFIX_ONLY" ;;
+ esac
+ case $shell in
+ ksh) conf_flags=${conf_flags#0?} ;;
+ esac
+ case $debug in
+ ?*) case $standard in
+ ????) sep=" " ;;
+ ???) sep=" " ;;
+ ??) sep=" " ;;
+ ?) sep=" " ;;
+ *) sep="" ;;
+ esac
+ echo "$command: test: $sep$standard $call $name" >&2
+ ;;
+ esac
+ case $call in
+ CS|SI) conf_flags="${conf_flags}|CONF_STRING"
+ string=1
+ ;;
+ *) eval string='$'CONF_string_${key}
+ ;;
+ esac
+ conf_limit=0
+ case $flags in
+ *[Ll]*) d=
+ case ${conf_name} in
+ LONG_MAX|SSIZE_MAX)
+ x=
+ ;;
+ *) eval x='$'CONF_const_${conf_name}
+ ;;
+ esac
+ case $x in
+ '') for s in ${values}
+ do case $s in
+ $sym) eval x='$'CONF_const_${s}
+ case $x in
+ 1) eval a='$'CONF_const_${standard}_${s}
+ case $a in
+ $x) x= ;;
+ *) x=$s ;;
+ esac
+ break
+ ;;
+ esac
+ ;;
+ [0123456789]*|[-+][0123456789]*)
+ d=$s
+ break
+ ;;
+ esac
+ done
+ case ${x:+1}:$flags:$conf_op in
+ :*:-1|:*X*:*)
+ case $verbose in
+ 1) echo "$command: probe for ${conf_name} <limits.h> value" >&2 ;;
+ esac
+ x=
+ case $CONF_getconf in
+ ?*) if $CONF_getconf $conf_name > $tmp.x 2>/dev/null
+ then x=`cat $tmp.x`
+ case $x in
+ undefined) x= ;;
+ esac
+ fi
+ ;;
+ esac
+ case ${x:+1} in
+ '') case $script in
+ '#'*) echo "$script" > $tmp.sh
+ chmod +x $tmp.sh
+ x=`./$tmp.sh 2>/dev/null`
+ ;;
+ '') case $conf_name in
+ SIZE_*|U*|*_MAX)
+ f="%${LL}u"
+ t="unsigned _ast_intmax_t"
+ ;;
+ *) f="%${LL}d"
+ t="_ast_intmax_t"
+ ;;
+ esac
+ cat > $tmp.c <<!
+${head}
+#include <stdio.h>
+#include <sys/types.h>
+#include <limits.h>
+#include <unistd.h>$systeminfo$headers
+${tail}
+int
+main()
+{
+ printf("$f\n", ($t)$conf_name);
+ return 0;
+}
+!
+ ;;
+ *) cat > $tmp.c <<!
+${head}
+#include <sys/types.h>
+#include <limits.h>
+#include <unistd.h>$systeminfo$headers
+${tail}
+${script}
+!
+ ;;
+ esac
+ case $args in
+ '') set "" ;;
+ *) eval set '""' '"'$args'"'; shift ;;
+ esac
+ for a
+ do case $script in
+ '#'*) ./$tmp.sh $a > $tmp.x 2>/dev/null
+ x=$?
+ ;;
+ *) $cc $a -o $tmp.exe $tmp.c >/dev/null 2>&1 && ./$tmp.exe > $tmp.x 2>/dev/null
+ x=$?
+ ;;
+ esac
+ case $x in
+ 0) x=`cat $tmp.x`
+ case $x in
+ "-") x=$a ;;
+ esac
+ break
+ ;;
+ *) x=
+ ;;
+ esac
+ done
+ ;;
+ esac
+ case $x in
+ '') x=$d ;;
+ esac
+ ;;
+ esac
+ case ${x:+1}:$flags:$conf_op in
+ 1:*:-1|1:*X*:*)
+ conf_limit=$x
+ case $flags in
+ *L*) ;;
+ *) conf_flags="${conf_flags}|CONF_LIMIT" ;;
+ esac
+ conf_flags="${conf_flags}|CONF_LIMIT_DEF"
+ case $string:$x in
+ 1:*) cat >> $tmp.l <<!
+printf("#ifndef ${conf_name}\n");
+printf("#define ${conf_name} \"${x}\"\n");
+printf("#endif\n");
+!
+ ;;
+ *:U*) cat >> $tmp.l <<!
+printf("#ifndef ${conf_name}\n");
+printf("#ifndef ${x}\n");
+printf("#define ${x} %lu\n", ${x});
+printf("#endif\n");
+printf("#define ${conf_name} ${x}\n");
+printf("#endif\n");
+!
+ ;;
+ *:$sym) cat >> $tmp.l <<!
+printf("#ifndef ${conf_name}\n");
+printf("#ifndef ${x}\n");
+printf("#define ${x} %ld\n", ${x});
+printf("#endif\n");
+printf("#define ${conf_name} ${x}\n");
+printf("#endif\n");
+!
+ ;;
+ *) cat >> $tmp.l <<!
+printf("#ifndef ${conf_name}\n");
+printf("#define ${conf_name} ${x}\n");
+printf("#endif\n");
+!
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+ case $section in
+ [01]) ;;
+ *) case $flags in
+ *N*) ;;
+ *) name=${section}_${name} ;;
+ esac
+ standard=${standard}${section}
+ ;;
+ esac
+ conf_minmax=0
+ case $call:$standard:$flags in
+ *:C:*M*)for s in _${standard}_${conf_name} ${values}
+ do case $s in
+ $sym) ;;
+ *) conf_minmax=$s
+ conf_flags="${conf_flags}|CONF_MINMAX_DEF"
+ break
+ ;;
+ esac
+ done
+ ;;
+ *:C:*) ;;
+ [CPSX][CSX]:*:*[FM]*)
+ x=
+ for s in _${standard}_${conf_name} ${values}
+ do case $s in
+ $sym) eval x='$'CONF_const_${s} ;;
+ *) x=1 ;;
+ esac
+ case $x in
+ 1) conf_minmax=$s
+ case $flags in
+ *M*) conf_flags="${conf_flags}|CONF_MINMAX_DEF" ;;
+ esac
+ break
+ ;;
+ esac
+ done
+ case ${x:+1}:${script:+1} in
+ :1) case $verbose in
+ 1) echo "$command: probe for _${standard}_${conf_name} minmax value" >&2 ;;
+ esac
+ case $CONF_getconf in
+ ?*) if $CONF_getconf _${standard}_${conf_name} > $tmp.x 2>/dev/null
+ then x=`cat $tmp.x`
+ case $x in
+ undefined) x= ;;
+ esac
+ fi
+ ;;
+ esac
+ case $x in
+ '') case $script in
+ '#'*) echo "$script" > $tmp.sh
+ chmod +x $tmp.sh
+ x=`./$tmp.sh 2>/dev/null`
+ ;;
+ *) cat > $tmp.c <<!
+${head}
+#include <sys/types.h>
+#include <limits.h>
+#include <unistd.h>$systeminfo$headers
+${tail}
+${script}
+!
+ ;;
+ esac
+ case $args in
+ '') set "" ;;
+ *) eval set '""' "$args"; shift ;;
+ esac
+ for a
+ do case $script in
+ '#'*) ./$tmp.sh $a > $tmp.x 2>/dev/null
+ x=$?
+ ;;
+ *) $cc $a -o $tmp.exe $tmp.c >/dev/null 2>&1 && ./$tmp.exe > $tmp.x 2>/dev/null
+ x=$?
+ ;;
+ esac
+ case $x in
+ 0) x=`cat $tmp.x`
+ case $x in
+ "-") x=$a ;;
+ esac
+ break
+ ;;
+ *) x=
+ ;;
+ esac
+ done
+ ;;
+ esac
+ case $x in
+ ?*) conf_minmax=$x
+ case $flags in
+ *M*) conf_flags="${conf_flags}|CONF_MINMAX_DEF" ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+ case $string in
+ 1) conf_limit="{ 0, $conf_limit }" conf_minmax="{ 0, $conf_minmax }"
+ ;;
+ *) case $conf_limit in
+ 0[xX]*|-*|+*|[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_]*)
+ ;;
+ *[!0123456789abcdefABCDEF]*)
+ conf_limit=0
+ ;;
+ *[!0123456789]*)
+ conf_limit=0x$conf_limit
+ ;;
+ esac
+ case $conf_minmax in
+ 0[xX]*|-*|+*|[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_]*)
+ ;;
+ *[!0123456789abcdefABCDEF]*)
+ conf_minmax=0
+ ;;
+ *[!0123456789]*)
+ conf_minmax=0x$conf_minmax
+ ;;
+ esac
+ conf_limit="{ $conf_limit, 0 }" conf_minmax="{ $conf_minmax, 0 }"
+ ;;
+ esac
+ echo "{ \"$conf_name\", $conf_limit, $conf_minmax, $conf_flags, $conf_standard, $conf_section, $conf_call, $conf_op },"
+ case $shell in
+ ksh) len=${#conf_name}
+ if ((len>=name_max))
+ then ((name_max=len+1))
+ fi
+ ;;
+ *) len=`echo ${conf_name} | wc -c`
+ if expr \( $len - 1 \) \>= ${name_max} >/dev/null
+ then name_max=$len
+ fi
+ ;;
+ esac
+done > $tmp.t
+case $debug in
+-d6) exit ;;
+esac
+
+# conf string table
+
+base=conftab
+case $verbose in
+1) echo "$command: generate ${base}.h string table header" >&2 ;;
+esac
+case $shell in
+ksh) ((name_max=name_max+3)); ((name_max=name_max/4*4)) ;; # bsd /bin/sh !
+*) name_max=`expr \( $name_max + 3 \) / 4 \* 4` ;;
+esac
+{
+cat <<!
+#pragma prototyped
+
+#ifndef _CONFTAB_H
+#define _CONFTAB_H
+$systeminfo
+
+${generated}
+
+#define conf _ast_conf_data
+#define conf_elements _ast_conf_ndata
+
+#define prefix _ast_conf_prefix
+#define prefix_elements _ast_conf_nprefix
+
+#define CONF_nop 0
+#define CONF_confstr 1
+#define CONF_pathconf 2
+#define CONF_sysconf 3
+#define CONF_sysinfo 4
+
+!
+index=0
+for standard in $standards
+do echo "#define CONF_${standard} ${index}"
+ case $shell in
+ ksh) ((index=index+1)) ;;
+ *) index=`expr ${index} + 1` ;;
+ esac
+done
+echo "#define CONF_call ${index}"
+case $CONF_getconf in
+?*) echo
+ echo "#define _pth_getconf \"$CONF_getconf\""
+ case $CONF_getconf_a in
+ ?*) echo "#define _pth_getconf_a \"$CONF_getconf_a\"" ;;
+ esac
+ ;;
+esac
+cat <<!
+
+#define CONF_DEFER_CALL 0x0001
+#define CONF_DEFER_MM 0x0002
+#define CONF_FEATURE 0x0004
+#define CONF_LIMIT 0x0008
+#define CONF_LIMIT_DEF 0x0010
+#define CONF_MINMAX 0x0020
+#define CONF_MINMAX_DEF 0x0040
+#define CONF_NOSECTION 0x0080
+#define CONF_NOUNDERSCORE 0x0100
+#define CONF_PREFIX_ONLY 0x0200
+#define CONF_PREFIXED 0x0400
+#define CONF_STANDARD 0x0800
+#define CONF_STRING 0x1000
+#define CONF_UNDERSCORE 0x2000
+#define CONF_USER 0x4000
+
+struct Conf_s; typedef struct Conf_s Conf_t;
+
+typedef int (*Conf_f)(Conf_t*, intmax_t*, char**);
+
+typedef struct Value_s
+{
+ intmax_t number;
+ const char* string;
+} Value_t;
+
+struct Conf_s
+{
+ const char name[${name_max}];
+ Value_t limit;
+ Value_t minmax;
+ short flags;
+ short standard;
+ short section;
+ short call;
+ short op;
+};
+
+typedef struct Prefix_s
+{
+ const char name[16];
+ short length;
+ short standard;
+ short call;
+} Prefix_t;
+
+extern const Conf_t conf[];
+extern int conf_elements;
+
+extern const Prefix_t prefix[];
+extern int prefix_elements;
+
+#endif
+!
+} > $tmp.1
+proto < $tmp.1 > $tmp.2
+case $debug in
+-d7) echo $command: $tmp.2 ${base}.h ;;
+*) cmp -s $tmp.2 ${base}.h 2>/dev/null || mv $tmp.2 ${base}.h ;;
+esac
+
+case $verbose in
+1) echo "$command: generate ${base}.c string table" >&2 ;;
+esac
+{
+cat <<!
+#pragma prototyped
+${head}
+#include <sys/types.h>
+#include <limits.h>
+#include <unistd.h>$systeminfo$headers
+${tail}
+#include "${base}.h"
+
+${generated}
+
+/*
+ * prefix strings -- the first few are indexed by Conf_t.standard
+ */
+
+const Prefix_t prefix[] =
+{
+!
+for standard in $standards
+do case $shell in
+ ksh) len=${#standard} ;;
+ *) len=`echo ${standard} | wc -c`; len=`expr $len - 1` ;;
+ esac
+ echo " \"${standard}\", ${len}, CONF_${standard}, -1,"
+done
+cat <<!
+ "XX", 2, CONF_POSIX, CONF_nop,
+ "CS", 2, CONF_POSIX, CONF_confstr,
+ "PC", 2, CONF_POSIX, CONF_pathconf,
+ "SC", 2, CONF_POSIX, CONF_sysconf,
+ "SI", 2, CONF_SVID, CONF_sysinfo,
+};
+
+int prefix_elements = (int)sizeof(prefix) / (int)sizeof(prefix[0]);
+
+/*
+ * conf strings sorted in ascending order
+ */
+
+const Conf_t conf[] =
+{
+!
+cat $tmp.t
+cat <<!
+};
+
+int conf_elements = (int)sizeof(conf) / (int)sizeof(conf[0]);
+!
+} > $tmp.3
+proto < $tmp.3 > $tmp.4
+case $debug in
+-d7) echo $command: $tmp.4 ${base}.c ;;
+*) cmp -s $tmp.4 ${base}.c 2>/dev/null || mv $tmp.4 ${base}.c ;;
+esac
+
+# limits.h generation code
+
+base=conflim
+case $verbose in
+1) echo "$command: generate ${base}.h supplemental <limits.h> values" >&2 ;;
+esac
+{
+cat <<!
+${generated}
+
+/*
+ * supplemental <limits.h> values
+ */
+
+!
+test -f $tmp.l && cat $tmp.l
+} > $tmp.5
+case $debug in
+-d7) echo $command: $tmp.5 ${base}.h ;;
+*) cmp -s $tmp.5 ${base}.h 2>/dev/null || mv $tmp.5 ${base}.h ;;
+esac
+exit 0
diff --git a/usr/src/lib/libast/common/comp/conf.tab b/usr/src/lib/libast/common/comp/conf.tab
new file mode 100644
index 0000000000..38858c9258
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/conf.tab
@@ -0,0 +1,586 @@
+#
+# posix { getconf limits } macro table
+#
+# @(#)conf.tab (AT&T Research) 2007-04-01
+#
+# name standard section call flags [ header ... ] [ value ... ]
+#
+# name: sans prefix
+# standard: AST, C, POSIX, SVID, XOPEN, <vendor> { SCO, SGI, SUN, ... }
+# section: section number in standard
+# call: CS=confstr PC=pathconf SC=sysconf SI=sysinfo QQ=query XX=none
+# flags: 0 no flags
+# C defer call to native getconf(1)
+# D defer minmax to native getconf(1)
+# F unistd.h feature
+# L limits.h constant
+# M has _<standard><section>_<name> minmax value
+# N _<call>_<name>
+# O use original name and definition
+# R _<standard>_<call>_<section>_<name>
+# S _<call>_<standard><section>_<name>
+# U <standard><section>_<name> prefixed by underscore
+# V _ prefix not allowed
+# W standard required
+# X define even if native is dynamic (ast special)
+#
+# default names if <section> <= 1
+#
+# _<call>_<name>
+# <standard>_<name>
+#
+# default names if <section> > 1
+#
+# _<call>_<section>_<name>
+# <standard><section>_<name>
+#
+# the [NSU] flags modify the default names
+#
+
+ABI_AIO_XFER_MAX C QQ 1 L
+ABI_ASYNCHRONOUS_IO C QQ 1 L
+ABI_ASYNC_IO C QQ 1 L
+ADVISORY_INFO POSIX SC 1 FUW
+AIO_LISTIO_MAX POSIX SC 1 LMU 2
+AIO_MAX POSIX SC 1 LMU 1
+AIO_PRIO_DELTA_MAX POSIX SC 1 LMU
+ALLOC_SIZE_MIN POSIX PC 1 LUVW
+ARCHITECTURE SVID SI 1 0
+ARG_MAX POSIX SC 1 CDLMUX NCARGS 4096
+ASYNCHRONOUS_IO POSIX SC 1 CDFUW
+ASYNC_IO POSIX PC 1 FUW
+ATEXIT_MAX XOPEN SC 1 LMU 32
+AUDIT C QQ 1 L
+AVAIL_PROCESSORS C QQ 1 L
+AVPHYS_PAGES SUN SC 1 0
+BARRIERS POSIX SC 1 FUW
+BC_BASE_MAX POSIX SC 2 LMN 99
+BC_DIM_MAX POSIX SC 2 LMN 2048
+BC_SCALE_MAX POSIX SC 2 LMN 99
+BC_STRING_MAX POSIX SC 2 LMN 1000
+BUSTYPES SVID SI 1 0
+CHARCLASS_NAME_MAX XOPEN XX 1 L 14
+CHAR_BIT C XX 1 L 8
+CHAR_MAX C XX 1 L
+CHAR_MIN C XX 1 L
+CHAR_TERM POSIX SC 2 FUW
+CHILD_MAX POSIX SC 1 CDLMUX 6 cc{
+ #if _lib_fork
+ #define child() fork()
+ #else
+ #ifdef _map_spawnve
+ #define spawnve _map_spawnve
+ #endif
+ extern int spawnve(const char*, char* const[], char* const[]);
+ static char* cmd[] = { "/bin/echo", 0 };
+ #define child() spawnve(cmd[0],cmd,(char**)0)
+ #endif
+ int main()
+ {
+ int i;
+ int n;
+ for (i = 3; i < 512 && (n = child()) >= 0; i++)
+ if (!n) _exit(0);
+ while (wait((int*)0) > 0);
+ for (n = 8; n < i; n <<= 1);
+ printf("%d", n);
+ return 0;
+ }
+}
+CHOWN_RESTRICTED POSIX PC 1 FUW
+CKPT POSIX SC 1 FU
+CLK_TCK POSIX SC 1 L HZ 60
+CLOCKRES_MIN POSIX SC 1 MUW 1
+CLOCKS_PER_SEC C QQ 1 L
+CLOCK_SELECTION POSIX SC 1 FUVW
+COLL_WEIGHTS_MAX POSIX SC 2 DLMN 2
+CPUTIME POSIX SC 1 FUW
+CPU_KEYBITS1 C QQ 1 L
+CPU_VERSION C QQ 1 L
+CRYPT XOPEN SC 1 FSUW
+C_BIND POSIX SC 2 FU
+C_DEV POSIX SC 2 FU
+C_VERSION POSIX SC 2 CDFU
+DATAKEYS_MAX C QQ 1 0
+DELAYTIMER_MAX POSIX SC 1 LMU 32
+ENH_I18N XOPEN SC 1 FSUW
+EQUIV_CLASS_MAX C QQ 1 L
+EXEC_INTERPRETER_LENGTH C QQ 1 L
+EXPR_NEST_MAX POSIX SC 2 LMN 32
+FCHR_MAX SVID SC 1 LMU LONG_MAX 2147483647
+FILESIZEBITS POSIX PC 1 LMU (8*sizeof(off_t)) 32
+FILE_LOCKING POSIX SC 1 FU
+FORT_DEV POSIX SC 2 FUW
+FORT_RUN POSIX SC 2 FUW
+FSYNC POSIX SC 1 CDFUW _lib_fsync
+GETGR_R_SIZE_MAX C QQ 1 L
+GETPW_R_SIZE_MAX C QQ 1 L
+HOSTID C QQ 1 L
+HOSTNAME SVID SI 1 0
+HOST_NAME_MAX POSIX SC 1 LMU 255
+HW_PROVIDER SVID SI 1 0
+HW_SERIAL C QQ 1 L
+ILP32_OFF32 XBS5 SC 1 FU
+ILP32_OFF32_CFLAGS XBS5 CS 1 FU
+ILP32_OFF32_LDFLAGS XBS5 CS 1 FU
+ILP32_OFF32_LIBS XBS5 CS 1 FU
+ILP32_OFF32_LINTFLAGS XBS5 CS 1 FU
+ILP32_OFFBIG XBS5 SC 1 FU
+ILP32_OFFBIG_CFLAGS XBS5 CS 1 FU
+ILP32_OFFBIG_LDFLAGS XBS5 CS 1 FU
+ILP32_OFFBIG_LIBS XBS5 CS 1 FU
+ILP32_OFFBIG_LINTFLAGS XBS5 CS 1 FU
+INITTAB_NAME SVID SI 1 0
+INT_MAX C XX 1 L 32767
+INT_MIN C XX 1 L -32767
+IOV_MAX XOPEN SC 1 LMU 16
+IO_TYPE C QQ 1 L
+IPV6 POSIX SC 1 FUW
+IP_SECOPTS C QQ 1 L
+JOB_CONTROL POSIX SC 1 FUW cc{
+ #include "FEATURE/wait"
+ #if _ok_wif
+ int main()
+ {
+ printf("1");
+ return 0;
+ }
+ #endif
+}
+KERNEL_CLIST SCO SC 1 0
+KERNEL_CLIST_MAX SCO SC 1 0
+KERNEL_DISK SCO SC 1 0
+KERNEL_DISK_MAX SCO SC 1 0
+KERNEL_DMABUF SCO SC 1 0
+KERNEL_DMABUF_MAX SCO SC 1 0
+KERNEL_FILE SCO SC 1 0
+KERNEL_FILE_MAX SCO SC 1 0
+KERNEL_FLCKREC SCO SC 1 0
+KERNEL_FLCKREC_MAX SCO SC 1 0
+KERNEL_INODE SCO SC 1 0
+KERNEL_INODE_MAX SCO SC 1 0
+KERNEL_MOUNT SCO SC 1 0
+KERNEL_MOUNT_MAX SCO SC 1 0
+KERNEL_PINODE SCO SC 1 0
+KERNEL_PINODE_MAX SCO SC 1 0
+KERNEL_PROC SCO SC 1 0
+KERNEL_PROC_MAX SCO SC 1 0
+KERNEL_REGION SCO SC 1 0
+KERNEL_REGION_MAX SCO SC 1 0
+KERNEL_S5INODE SCO SC 1 0
+KERNEL_S5INODE_MAX SCO SC 1 0
+KERNEL_STAMP SVID SI 1 0
+KERN_POINTERS C QQ 1 L
+KERN_SIM C QQ 1 L
+LEGACY XOPEN SC 1 FU
+LFS_CFLAGS POSIX CS 1 MU cc{ -D_LARGEFILE_SOURCE "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" -D_LARGEFILE64_SOURCE -64
+ #include <sys/types.h>
+ int
+ main()
+ {
+ if (sizeof(off_t) >= sizeof(off_64_t))
+ {
+ printf("-");
+ return 0;
+ }
+ return 1;
+ }
+}
+LFS64_CFLAGS POSIX CS 1 MU : LFS_CFLAGS
+LFS64_LDFLAGS POSIX CS 1 MU : LFS_CFLAGS
+LFS64_LIBS POSIX CS 1 MU
+LFS64_LINTFLAGS POSIX CS 1 MU : LFS_CFLAGS
+LFS_LDFLAGS POSIX CS 1 MU : LFS_CFLAGS
+LFS_LIBS POSIX CS 1 MU
+LFS_LINTFLAGS POSIX CS 1 MU : LFS_CFLAGS
+LINE_MAX POSIX SC 2 LMN 2048
+LINK_MAX POSIX PC 1 LMU MAXLINK SHRT_MAX 8
+LLONG_MAX C XX 1 L
+LLONG_MIN C XX 1 L
+LOCALEDEF POSIX SC 1 FUW
+LOCALEDEF POSIX SC 2 FUW
+LOGIN_NAME_MAX POSIX SC 1 LMU
+LOGNAME_MAX SVID SC 1 MU 8
+LONG_BIT XOPEN XX 1 L (8*sizeof(long)) 32
+LONG_MAX C XX 1 L 2147483647
+LONG_MIN C XX 1 L -2147483647
+LP64_OFF64 XBS5 SC 1 FU
+LP64_OFF64_CFLAGS XBS5 CS 1 FU
+LP64_OFF64_LDFLAGS XBS5 CS 1 FU
+LP64_OFF64_LIBS XBS5 CS 1 FU
+LP64_OFF64_LINTFLAGS XBS5 CS 1 FU
+LPBIG_OFFBIG XBS5 SC 1 FU
+LPBIG_OFFBIG_CFLAGS XBS5 CS 1 FU
+LPBIG_OFFBIG_LDFLAGS XBS5 CS 1 FU
+LPBIG_OFFBIG_LIBS XBS5 CS 1 FU
+LPBIG_OFFBIG_LINTFLAGS XBS5 CS 1 FU
+MACHINE SVID SI 1 0
+MAPPED_FILES POSIX SC 1 CDFUW _lib_mmap
+MAX_CANON POSIX PC 1 LMU CANBSIZ 255
+MAX_INPUT POSIX PC 1 LMU MAX_CANON 255
+MB_LEN_MAX C XX 1 L 1
+MCAS_OFFSET C QQ 1 L
+MEMLOCK POSIX SC 1 CDFUW
+MEMLOCK_RANGE POSIX SC 1 CDFUW
+MEMORY_PROTECTION POSIX SC 1 CDFUW
+MESSAGE_PASSING POSIX SC 1 CDFUW
+MMAP_FIXED_ALIGNMENT C QQ 1 L _AST_PAGESIZE
+MONOTONIC_CLOCK POSIX SC 1 FUW
+MQ_OPEN_MAX POSIX SC 1 LMU 8
+MQ_PRIO_MAX POSIX SC 1 LMU 32
+MSEM_LOCKID C QQ 1 L
+MULTI_PROCESS POSIX SC 1 FU
+NACLS_MAX SVID SC 1 0
+NAME_MAX POSIX PC 1 LMU 14 cc{
+ int main()
+ {
+ #ifdef MAXNAMLEN
+ printf("%d", MAXNAMLEN);
+ #else
+ #if !defined(remove) && (!_lib_remove || _lib_unlink)
+ #define remove unlink
+ #endif
+ int i;
+ int n;
+ int v;
+ char name[256];
+ for (i = 0; i < sizeof(name); i++)
+ name[i] = 'F';
+ name[8] = '.';
+ name[sizeof(name) - 1] = 0;
+ if ((n = creat(name, 0666)) >= 0)
+ {
+ close(n);
+ for (v = 12; v < sizeof(name); v++)
+ {
+ name[v] = 0;
+ if (remove(name) >= 0) break;
+ name[v] = 'F';
+ }
+ }
+ else for (v = 12; v < sizeof(name); v++)
+ {
+ name[v] = 0;
+ if ((n = creat(name, 0666)) >= 0)
+ {
+ close(n);
+ remove(name);
+ name[v] = 'F';
+ }
+ else
+ {
+ v--;
+ break;
+ }
+ }
+ printf("%d", v);
+ return 0;
+ }
+ #endif
+}
+NGROUPS_MAX POSIX SC 1 CDLMU 8 cc{
+ #if _lib_getgroups
+ int main()
+ {
+ int n;
+ gid_t g;
+ if ((n = getgroups(0, &g)) < 0)
+ #if defined(NGROUPS) && (NGROUPS-0) > 0
+ n = NGROUPS;
+ #else
+ return 1;
+ #endif
+ printf("%d", n);
+ return 0;
+ }
+ #endif
+}
+NL_ARGMAX XOPEN XX 1 L 9
+NL_LANGMAX XOPEN XX 1 L 14
+NL_MAX C QQ 1 L
+NL_MSGMAX XOPEN XX 1 L 32767
+NL_NMAX XOPEN XX 1 L 1
+NL_SETMAX XOPEN XX 1 L 255
+NL_SPECMAX C QQ 1 L
+NL_TEXTMAX XOPEN XX 1 L LINE_MAX
+NO_TRUNC POSIX PC 1 FUW
+NPROCESSORS_CONF SVID SC 1 0
+NPROCESSORS_ONLN SVID SC 1 0
+NPROC_CONF C QQ 1 L
+NPROC_ONLN C QQ 1 L
+NSS_BUFLEN_GROUP C QQ 1 L
+NSS_BUFLEN_PASSWD C QQ 1 L
+NUM_PROCESSORS C QQ 1 L
+NZERO XOPEN XX 1 L 20
+OPEN_MAX POSIX SC 1 CDLMUX 16 cc{
+ #if _lib_getdtablesize
+ extern int getdtablesize(void);
+ int main()
+ {
+ printf("%d", getdtablesize());
+ return 0;
+ }
+ #else
+ int main()
+ {
+ int i;
+ int n;
+ int v;
+ n = 0;
+ v = 2;
+ while ((i = dup(0)) >= 0)
+ {
+ if (!n) n = i;
+ if (i > v) v = i;
+ }
+ while (n <= v) close(n++);
+ printf("%d", v);
+ return 0;
+ }
+ #endif
+}
+OPEN_MAX_CEIL AST XX 1 L OPEN_MAX
+OSREL_MAJ C QQ 1 L
+OSREL_MIN C QQ 1 L
+OSREL_PATCH C QQ 1 L
+OS_BASE SVID SI 1 0
+OS_PROVIDER SVID SI 1 0
+OS_VERSION AES SC 1 FSU
+PAGESIZE POSIX SC 1 MU PAGESIZE PAGE_SIZE 4096 cc{
+ int main()
+ {
+ #if _WIN32
+ printf("%ld", 64*1024L);
+ return 0;
+ #else
+ #if _lib_getpagesize
+ #if _npt_getpagesize
+ extern size_t getpagesize(void);
+ #endif
+ printf("%d", getpagesize());
+ return 0;
+ #endif
+ #else
+ return 1;
+ #endif
+ }
+}
+PAGE_SIZE POSIX SC 1 MU _AST_PAGESIZE
+PASS_MAX SVID SC 1 CDLMU 8
+PATH POSIX CS 1 CMU "/bin:/usr/bin"
+PATH_MAX POSIX PC 1 CDLMUX MAXPATHLEN 1024
+PBS POSIX SC 2 FUW
+PBS_ACCOUNTING POSIX SC 2 FUW
+PBS_CHECKPOINT POSIX SC 2 FUW
+PBS_LOCATE POSIX SC 2 FUW
+PBS_MESSAGE POSIX SC 2 FUW
+PBS_TRACK POSIX SC 2 FUW
+PHYS_PAGES SUN SC 1 0
+PID_MAX SVID SC 1 LMU 30000 cc{
+ int main()
+ {
+ int fd;
+ int n;
+ char buf[1024];
+ if ((fd = open("/proc/sys/kernel/pid_max", 0)) < 0)
+ return 1;
+ if ((n = read(fd, buf, sizeof(buf)-1)) < 2)
+ return 1;
+ buf[n] = 0;
+ n = (int)strtol(buf, (char**)0, 0);
+ printf("%ld", n);
+ return 0;
+ }
+}
+PII POSIX SC 1 FU
+PII_INTERNET POSIX SC 1 FU
+PII_INTERNET_DGRAM POSIX SC 1 FU
+PII_INTERNET_STREAM POSIX SC 1 FU
+PII_OSI POSIX SC 1 FU
+PII_OSI_CLTS POSIX SC 1 FU
+PII_OSI_COTS POSIX SC 1 FU
+PII_OSI_M POSIX SC 1 FU
+PII_SOCKET POSIX SC 1 FU
+PII_XTI POSIX SC 1 FU
+PIPE_BUF POSIX PC 1 LMU 512
+POLL POSIX SC 1 FU
+PRIORITIZED_IO POSIX SC 1 FUW
+PRIORITY_SCHEDULING POSIX SC 1 CDFUW
+PRIO_IO POSIX PC 1 FUW
+PROC_RSRC_MGR C QQ 1 L
+PTHREAD_DESTRUCTOR_ITERATIONS C QQ 1 L
+PTHREAD_KEYS_MAX C QQ 1 L
+PTHREAD_STACK_MIN C QQ 1 L
+PTHREAD_THREADS_MAX C QQ 1 L
+PTRDIFF_MAX C XX 1 LMU stdint.h 65535
+PTRDIFF_MIN C XX 1 LMU stdint.h -65535
+RAW_SOCKETS POSIX SC 1 FUW
+READER_WRITER_LOCKS POSIX SC 1 FUW
+REALTIME XOPEN SC 1 FU
+REALTIME_SIGNALS POSIX SC 1 CDFUW
+REALTIME_THREADS XOPEN SC 1 FU
+REC_INCR_XFER_SIZE POSIX PC 1 LVW
+REC_MAX_XFER_SIZE POSIX PC 1 LVW
+REC_MIN_XFER_SIZE POSIX PC 1 LVW
+REC_XFER_ALIGN POSIX PC 1 LVW
+REENTRANT_FUNCTIONS POSIX SC 1 FU
+REGEXP POSIX SC 1 FUW
+REGEX_VERSION POSIX SC 1 F 20030916
+RELEASE C QQ 1 L
+RESOURCE_LIMITS POSIX SC 1 FU
+RE_DUP_MAX POSIX SC 2 LMN 255
+RTSIG_MAX POSIX SC 1 LMU 8
+SAVED_IDS POSIX SC 1 FUW cc{
+ #if _lib_setuid && !_lib_setreuid
+ int main()
+ {
+ printf("1");
+ return 0;
+ }
+ #endif
+}
+SCHAR_MAX C XX 1 L 127
+SCHAR_MIN C XX 1 L -127
+SECURITY_CLASS C QQ 1 L
+SELECT POSIX SC 1 FU
+SEMAPHORES POSIX SC 1 CDFUW
+SEM_NSEMS_MAX POSIX SC 1 LMU 256
+SEM_VALUE_MAX POSIX SC 1 LMU 32767
+SH AST CS 1 MU sh{
+ ifs=$IFS
+ IFS=:
+ set '' `$CONF_getconf PATH 2>/dev/null` /bin /usr/bin /sbin /usr/sbin
+ shift
+ path=$*
+ IFS=$ifs
+ for s in ksh ksh93 sh
+ do for d in $path
+ do if test -x $d/$s
+ then case $s in
+ ksh) case `$d/$s '--?-author' 2>&1` in
+ *'David Korn'*) ;;
+ *) continue ;;
+ esac
+ ;;
+ esac
+ echo "\"$d/$s\""
+ exit
+ fi
+ done
+ done
+ echo '"/bin/sh"'
+}
+SHARED_MEMORY_OBJECTS POSIX SC 1 CDFUW
+SHELL POSIX SC 1 FUVW
+SHM XOPEN SC 1 FSUW
+SHRT_MAX C XX 1 L 32767
+SHRT_MIN C XX 1 L -32767
+SIG_ATOMIC_MAX C XX 1 L signal.h
+SIG_ATOMIC_MIN C XX 1 L signal.h
+SIGQUEUE_MAX POSIX SC 1 LMU 32
+SIGQUEUE_MAX POSIX SC 1 LMU 32
+SIGRT_MAX SVID SC 1 0
+SIGRT_MIN SVID SC 1 0
+SIZE_MAX C XX 1 LMX stdint.h UINT_MAX 65535
+SLVM_MAXNODES C QQ 1 L
+SOCK_MAXBUF C QQ 1 0
+SOFTPOWER C QQ 1 L
+SPAWN POSIX SC 1 FUW
+SPIN_LOCKS POSIX SC 1 FUW
+SPORADIC_SERVER POSIX SC 1 FUW
+SRPC_DOMAIN C QQ 1 0
+SS_REPL_MAX POSIX SC 1 FUW
+SSIZE_MAX POSIX XX 1 LMUX INT_MAX 32767
+STD_BLK SVID SC 1 LMU 1024
+STREAM_MAX POSIX SC 1 LMU OPEN_MAX 8
+STREAMS XOPEN SC 1 FSUW
+SW_DEV POSIX SC 2 FUW
+SYMLINK_MAX POSIX PC 1 LMU 255 cc{
+ int main()
+ {
+ printf("%d", PATH_MAX-1);
+ return 0;
+ }
+}
+SYMLINKS POSIX PC 2 FUW
+SYMLOOP_MAX POSIX SC 1 LMU 8
+SYNCHRONIZED_IO POSIX SC 1 CDFUW
+SYNC_IO POSIX PC 1 FUW
+SYSNAME SVID SI 1 0
+SYSPID_MAX SVID SC 1 LMU 2
+THREADS POSIX SC 1 CDFUW
+THREADS_PRIO_CEILING POSIX SC 1 FUW
+THREADS_PRIO_INHERIT POSIX SC 1 FUW
+THREAD_ATTR_STACKADDR POSIX SC 1 CDFUW
+THREAD_ATTR_STACKSIZE POSIX SC 1 CDFUW
+THREAD_CPUTIME POSIX SC 1 FUW
+THREAD_DESTRUCTOR_ITERATIONS POSIX SC 1 LMUW PTHREAD_DESTRUCTOR_ITERATIONS 4
+THREAD_KEYS_MAX POSIX SC 1 LMUW PTHREAD_KEYS_MAX 128
+THREAD_PRIORITY_SCHEDULING POSIX SC 1 CDFUW
+THREAD_PRIO_INHERIT POSIX SC 1 CDFUW
+THREAD_PRIO_PROTECT POSIX SC 1 CDFUW
+THREAD_PROCESS_SHARED POSIX SC 1 CDFUW
+THREAD_SAFE_FUNCTIONS POSIX SC 1 CDFUW
+THREAD_SPORADIC_SERVER POSIX SC 1 FUW
+THREAD_STACK_MIN POSIX SC 1 LUW PTHREAD_STACK_MIN
+THREAD_THREADS_MAX POSIX SC 1 LMUW PTHREAD_THREADS_MAX 64
+TIMEOUTS POSIX SC 1 FUW
+TIMERS POSIX SC 1 CDFUW
+TIMER_MAX POSIX SC 1 LMU 32
+TMP AST CS 1 MU "/tmp"
+TMP_MAX C SC 1 LMU 10000
+TRACE POSIX SC 1 FUW
+TRACE_EVENT_FILTER POSIX SC 1 FUW
+TRACE_EVENT_NAME_MAX POSIX SC 1 FUVW
+TRACE_INHERIT POSIX SC 1 FUW
+TRACE_LOG POSIX SC 1 FUW
+TRACE_NAME_MAX POSIX SC 1 FUVW
+TRACE_SYS_MAX POSIX SC 1 FUVW
+TRACE_USER_EVENT_MAX POSIX SC 1 FUVW
+TTY_NAME_MAX POSIX SC 1 LMU 9
+TYPED_MEMORY_OBJECTS POSIX SC 1 FUW
+TZNAME_MAX POSIX SC 1 CDLMU 6
+T_IOV_MAX C QQ 1 0
+UCHAR_MAX C XX 1 L 255
+UCHAR_MIN C XX 1 L
+UID_MAX SVID SC 1 LMU 60002
+UINT_MAX C XX 1 L 65535
+UIO_MAXIOV C QQ 1 0
+ULLONG_MAX C XX 1 L
+ULONG_MAX C XX 1 L 4294967295
+UNIX XOPEN SC 1 FSUW
+UPE POSIX SC 2 FUW
+USER_LIMIT SVID SI 1 0
+USHRT_MAX C XX 1 L 65535
+V6_ILP32_OFF32 POSIX SC 1 W
+V6_ILP32_OFFBIG POSIX SC 1 W
+V6_LP64_OFF64 POSIX SC 1 W
+V6_LPBIG_OFFBIG POSIX SC 1 W
+VDISABLE POSIX PC 1 FUW
+VERSION POSIX SC 1 CDFSU 200112
+VERSION POSIX SC 2 CDFSU 200112
+VERSION XOPEN SC 1 CDFSU 600
+VERSION AST XX 1 MS _AST_VERSION
+VERSION SVID SI 1 S
+VERSION XPG SC 3 DFSU
+VERSION XPG SC 4 DFSU
+VERSION_88 C XX 1 L
+VERSION_88 POSIX SC 1 FSU
+VERSION_90 C XX 1 L
+VERSION_90 POSIX SC 1 FSU
+VERSION_93 C XX 1 L
+VERSION_93 POSIX SC 1 FSU
+WCHAR_MAX C XX 1 L stddef.h
+WCHAR_MIN C XX 1 L stddef.h
+WINT_MIN C XX 1 L wchar.h
+WINT_MAX C XX 1 L wchar.h
+WORD_BIT XOPEN XX 1 L (8*sizeof(int))
+XCU_VERSION XOPEN SC 1 CDFSU
+XPG2 XOPEN XX 1 FU
+XPG3 XOPEN XX 1 FU
+XPG4 XOPEN XX 1 FU
+
+# vendor prefixes
+
+VERSION GNU XX 1 S
+VERSION TRUSTEDBSD XX 1 S
diff --git a/usr/src/lib/libast/common/comp/creat64.c b/usr/src/lib/libast/common/comp/creat64.c
new file mode 100644
index 0000000000..db3cb93c82
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/creat64.c
@@ -0,0 +1,38 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if defined(_lib_creat64) || !defined(_lib_open64)
+
+NoN(creat64)
+
+#else
+
+int
+creat64(const char* path, mode_t mode)
+{
+ return open64(path, O_WRONLY|O_CREAT|O_TRUNC, mode);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/dirname.c b/usr/src/lib/libast/common/comp/dirname.c
new file mode 100644
index 0000000000..311c431556
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/dirname.c
@@ -0,0 +1,61 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * dirname(3) implementation
+ */
+
+#include <ast_std.h>
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern char *dirname(register char *pathname)
+{
+ register char *last;
+ /* go to end of path */
+ for(last=pathname; *last; last++);
+ /* back over trailing '/' */
+ while(last>pathname && *--last=='/');
+ /* back over non-slash chars */
+ for(;last>pathname && *last!='/';last--);
+ if(last==pathname)
+ {
+ /* all '/' or "" */
+ if(*last!='/')
+ *last = '.';
+ /* preserve // */
+ else if(last[1]=='/')
+ last++;
+ }
+ else
+ {
+ /* back over trailing '/' */
+ for(;*last=='/' && last > pathname; last--);
+ /* preserve // */
+ if(last==pathname && *pathname=='/' && pathname[1]=='/')
+ last++;
+ }
+ *(last + 1) = 0;
+ return(pathname);
+}
diff --git a/usr/src/lib/libast/common/comp/dup2.c b/usr/src/lib/libast/common/comp/dup2.c
new file mode 100644
index 0000000000..220bb2f72d
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/dup2.c
@@ -0,0 +1,46 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_dup2
+
+NoN(dup2)
+
+#else
+
+#include <error.h>
+
+int
+dup2(int d1, int d2)
+{
+ int save_errno;
+
+ if (d1 == d2) return(d1);
+ save_errno = errno;
+ close(d2);
+ errno = save_errno;
+ return(fcntl(d1, F_DUPFD, d2));
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/eaccess.c b/usr/src/lib/libast/common/comp/eaccess.c
new file mode 100644
index 0000000000..3604fe835f
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/eaccess.c
@@ -0,0 +1,139 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * access() euid/egid implementation
+ */
+
+#include <ast.h>
+#include <errno.h>
+#include <ls.h>
+
+#include "FEATURE/eaccess"
+
+#if _lib_eaccess
+
+NoN(eaccess)
+
+#else
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int
+eaccess(const char* path, register int flags)
+{
+#ifdef EFF_ONLY_OK
+ return access(path, flags|EFF_ONLY_OK);
+#else
+#if _lib_euidaccess
+ return euidaccess(path, flags);
+#else
+ register int mode;
+ struct stat st;
+
+ static int init;
+ static uid_t ruid;
+ static uid_t euid;
+ static gid_t rgid;
+ static gid_t egid;
+
+ if (!init)
+ {
+ ruid = getuid();
+ euid = geteuid();
+ rgid = getgid();
+ egid = getegid();
+ init = (ruid == euid && rgid == egid) ? 1 : -1;
+ }
+ if (init > 0 || flags == F_OK)
+ return access(path, flags);
+ if (stat(path, &st))
+ return -1;
+ mode = 0;
+ if (euid == 0)
+ {
+ if (!S_ISREG(st.st_mode) || !(flags & X_OK) || (st.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)))
+ return 0;
+ goto nope;
+ }
+ else if (euid == st.st_uid)
+ {
+ if (flags & R_OK)
+ mode |= S_IRUSR;
+ if (flags & W_OK)
+ mode |= S_IWUSR;
+ if (flags & X_OK)
+ mode |= S_IXUSR;
+ }
+ else if (egid == st.st_gid)
+ {
+#if _lib_getgroups
+ setgroup:
+#endif
+ if (flags & R_OK)
+ mode |= S_IRGRP;
+ if (flags & W_OK)
+ mode |= S_IWGRP;
+ if (flags & X_OK)
+ mode |= S_IXGRP;
+ }
+ else
+ {
+#if _lib_getgroups
+ register int n;
+
+ static int ngroups = -2;
+ static gid_t* groups;
+
+ if (ngroups == -2)
+ {
+ if ((ngroups = getgroups(0, (gid_t*)0)) <= 0)
+ ngroups = NGROUPS_MAX;
+ if (!(groups = newof(0, gid_t, ngroups + 1, 0)))
+ ngroups = -1;
+ else
+ ngroups = getgroups(ngroups, groups);
+ }
+ n = ngroups;
+ while (--n >= 0)
+ if (groups[n] == st.st_gid)
+ goto setgroup;
+#endif
+ if (flags & R_OK)
+ mode |= S_IROTH;
+ if (flags & W_OK)
+ mode |= S_IWOTH;
+ if (flags & X_OK)
+ mode |= S_IXOTH;
+ }
+ if ((st.st_mode & mode) == mode)
+ return 0;
+ nope:
+ errno = EACCES;
+ return -1;
+#endif
+#endif
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/errno.c b/usr/src/lib/libast/common/comp/errno.c
new file mode 100644
index 0000000000..e6acc4d0a6
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/errno.c
@@ -0,0 +1,40 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _tst_errno
+
+NoN(errno)
+
+#else
+
+/*
+ * this avoids multiple definitions with some libc's
+ * that define both an ast library supplied routine and
+ * errno in the same .o
+ */
+
+int errno;
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/execlp.c b/usr/src/lib/libast/common/comp/execlp.c
new file mode 100644
index 0000000000..6a3c0183fc
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/execlp.c
@@ -0,0 +1,50 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast_lib.h>
+
+#if _lib_execlp
+
+#include <ast.h>
+
+NoN(execlp)
+
+#else
+
+#if defined(__EXPORT__)
+__EXPORT__ int execlp(const char*, const char*, ...);
+#endif
+
+#include <ast.h>
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int
+execlp(const char* name, const char* arg, ...)
+{
+ return execvp(name, (char *const*)&arg);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/execve.c b/usr/src/lib/libast/common/comp/execve.c
new file mode 100644
index 0000000000..057821298f
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/execve.c
@@ -0,0 +1,70 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_execve
+
+NoN(execve)
+
+#else
+
+#include <sig.h>
+#include <wait.h>
+#include <error.h>
+
+static pid_t childpid;
+
+static void
+execsig(int sig)
+{
+ kill(childpid, sig);
+ signal(sig, execsig);
+}
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int
+execve(const char* path, char* const argv[], char* const arge[])
+{
+ int status;
+
+ if ((childpid = spawnve(path, argv, arge)) < 0)
+ return(-1);
+ for (status = 0; status < 64; status++)
+ signal(status, execsig);
+ while (waitpid(childpid, &status, 0) == -1)
+ if (errno != EINTR) return(-1);
+ if (WIFSIGNALED(status))
+ {
+ signal(WTERMSIG(status), SIG_DFL);
+ kill(getpid(), WTERMSIG(status));
+ pause();
+ }
+ else status = WEXITSTATUS(status);
+ exit(status);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/execvp.c b/usr/src/lib/libast/common/comp/execvp.c
new file mode 100644
index 0000000000..f0467cdf0b
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/execvp.c
@@ -0,0 +1,50 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast_lib.h>
+
+#if _lib_execvp
+
+#include <ast.h>
+
+NoN(execvp)
+
+#else
+
+#if defined(__EXPORT__)
+__EXPORT__ int execvp(const char*, char* const[]);
+#endif
+
+#include <ast.h>
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int
+execvp(const char* name, char* const argv[])
+{
+ return execvpe(name, argv, environ);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/execvpe.c b/usr/src/lib/libast/common/comp/execvpe.c
new file mode 100644
index 0000000000..4c189c8059
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/execvpe.c
@@ -0,0 +1,78 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast_lib.h>
+
+#if _lib_execvpe
+
+#include <ast.h>
+
+NoN(execvpe)
+
+#else
+
+#if defined(__EXPORT__)
+__EXPORT__ int execvpe(const char*, char* const[], char* const[]);
+#endif
+
+#include <ast.h>
+#include <errno.h>
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int
+execvpe(const char* name, char* const argv[], char* const envv[])
+{
+ register const char* path = name;
+ char buffer[PATH_MAX];
+
+ if (*path != '/' && !(path = pathpath(buffer, name, NULL, PATH_REGULAR|PATH_EXECUTE)))
+ path = name;
+ execve(path, argv, envv);
+ if (errno == ENOEXEC)
+ {
+ register char** newargv;
+ register char** ov;
+ register char** nv;
+
+ for (ov = (char**)argv; *ov++;);
+ if (newargv = newof(0, char*, ov + 1 - (char**)argv, 0))
+ {
+ nv = newargv;
+ *nv++ = "sh";
+ *nv++ = (char*)path;
+ ov = (char**)argv;
+ while (*nv++ = *++ov);
+ path = pathshell();
+ execve(path, newargv, envv);
+ free(newargv);
+ }
+ else
+ errno = ENOMEM;
+ }
+ return -1;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/fcntl.c b/usr/src/lib/libast/common/comp/fcntl.c
new file mode 100644
index 0000000000..f1d1a42b70
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/fcntl.c
@@ -0,0 +1,98 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * -last fcntl
+ */
+
+#include <ast.h>
+
+#ifndef fcntl
+
+NoN(fcntl)
+
+#else
+
+#include <ls.h>
+#include <ast_tty.h>
+#include <error.h>
+
+#if F_SETFD >= _ast_F_LOCAL
+#if _sys_filio
+#include <sys/filio.h>
+#endif
+#endif
+
+#if _lib_fcntl
+#undef fcntl
+extern int fcntl(int, int, ...);
+#endif
+
+int
+_ast_fcntl(int fd, int op, ...)
+{
+ int n;
+ int save_errno;
+ struct stat st;
+ va_list ap;
+
+ save_errno = errno;
+ va_start(ap, op);
+ if (op >= _ast_F_LOCAL) switch (op)
+ {
+#if F_DUPFD >= _ast_F_LOCAL
+ case F_DUPFD:
+ n = va_arg(ap, int);
+ op = dup2(fd, n);
+ break;
+#endif
+#if F_GETFL >= _ast_F_LOCAL
+ case F_GETFL:
+ op = fstat(fd, &st);
+ break;
+#endif
+#if F_SETFD >= _ast_F_LOCAL && defined(FIOCLEX)
+ case F_SETFD:
+ n = va_arg(ap, int);
+ op = ioctl(fd, n == FD_CLOEXEC ? FIOCLEX : FIONCLEX, 0);
+ break;
+#endif
+ default:
+ errno = EINVAL;
+ op = -1;
+ break;
+ }
+ else
+#if _lib_fcntl
+ op = fcntl(fd, op, va_arg(ap, int));
+#else
+ {
+ errno = EINVAL;
+ op = -1;
+ }
+#endif
+ va_end(ap);
+ return(op);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/fmtmsglib.c b/usr/src/lib/libast/common/comp/fmtmsglib.c
new file mode 100644
index 0000000000..6ae1fd1c83
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/fmtmsglib.c
@@ -0,0 +1,335 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * fmtmsg implementation
+ */
+
+#include <ast.h>
+
+#if _lib_fmtmsg
+
+NoN(fmtmsg)
+
+#else
+
+#define MM_TABLES
+
+#include <fmtmsg.h>
+
+#define INIT_VERB 0x1
+#define INIT_CONSOLE 0x2
+
+static struct
+{
+ int console;
+ unsigned int init;
+ unsigned int mask;
+} mm;
+
+const MM_table_t mm_class[] =
+{
+ "null", 0, 0,
+ "hard", "HARDWARE", MM_HARD,
+ "soft", "SOFTWARE", MM_SOFT,
+ "firm", "FIRMWARE", MM_FIRM,
+ "appl", "APPLICATION", MM_APPL,
+ "util", "UTILITY", MM_UTIL,
+ "opsys", "KERNEL", MM_OPSYS,
+ "print", 0, MM_PRINT,
+ "console", 0, MM_CONSOLE,
+ "recov", "RECOVERABLE", MM_RECOVER,
+ "nrecov", "PANIC", MM_NRECOV,
+ 0, 0, 0
+};
+
+static const MM_table_t mm_severity_init[] =
+{
+ "nosev", 0, MM_NOSEV,
+ "halt", "HALT", MM_HALT,
+ "error", "ERROR", MM_ERROR,
+ "warn", "WARNING", MM_WARNING,
+ "info", "INFO", MM_INFO,
+ 0, 0, 0
+};
+
+const MM_table_t mm_verb[] =
+{
+ "all", 0, MM_all,
+ "action", 0, MM_action,
+ "class", 0, MM_class,
+ "default", 0, MM_default,
+ "label", 0, MM_label,
+ "severity", 0, MM_severity,
+ "source", 0, MM_source,
+ "tag", 0, MM_tag,
+ "text", 0, MM_text,
+ 0, 0, 0
+};
+
+const MM_table_t*
+_mm_severity(void)
+{
+ static MM_table_t* severity;
+
+ if (!severity)
+ {
+ register char* s;
+ register MM_table_t* p;
+ register int n;
+ register int c;
+ char* e;
+ MM_table_t* q;
+
+ n = 0;
+ if ((s = getenv(MM_SEVERITY_ENV)) && *s)
+ {
+ e = s;
+ c = 0;
+ for (;;)
+ {
+ switch (*s++)
+ {
+ case 0:
+ break;
+ case ',':
+ if (++c > 2)
+ {
+ n = 0;
+ break;
+ }
+ continue;
+ case ':':
+ if (c != 2)
+ {
+ n = 0;
+ break;
+ }
+ c = 0;
+ n++;
+ continue;
+ default:
+ continue;
+ }
+ break;
+ }
+ if (c == 2)
+ n++;
+ else n = 0;
+ if (n)
+ {
+ for (p = (MM_table_t*)mm_severity_init; p->name; p++);
+ n += p - (MM_table_t*)mm_severity_init + 1;
+ if (severity = newof(0, MM_table_t, n, s - e))
+ {
+ s = (char*)severity + n * sizeof(MM_table_t);
+ strcpy(s, e);
+ p = severity;
+ for (q = (MM_table_t*)mm_severity_init; q->name; q++)
+ *p++ = *q;
+ p->name = s;
+ c = 0;
+ for (;;)
+ {
+ switch (*s++)
+ {
+ case 0:
+ break;
+ case ',':
+ switch (c++)
+ {
+ case 0:
+ *(s - 1) = 0;
+ p->value = strtol(s, NiL, 0);
+ break;
+ case 1:
+ p->display = s;
+ break;
+ }
+ continue;
+ case ':':
+ c = 0;
+ *(s - 1) = 0;
+ (++p)->name = s;
+ continue;
+ default:
+ continue;
+ }
+ break;
+ }
+ }
+ }
+ }
+ if (!severity)
+ severity = (MM_table_t*)mm_severity_init;
+ }
+ return (const MM_table_t*)severity;
+}
+
+static char*
+display(register const MM_table_t* tab, int value, int mask)
+{
+ while (tab->name)
+ {
+ if (value == tab->value || mask && (value & tab->value))
+ return (char*)tab->display;
+ tab++;
+ }
+ return 0;
+}
+
+int
+fmtmsg(long classification, const char* label, int severity, const char* text, const char* action, const char* tag)
+{
+ register int c;
+ register char* s;
+ register char* t;
+ register MM_table_t* p;
+ int n;
+ int m;
+ int r;
+ int fd;
+ unsigned int mask;
+ Sfio_t* sp;
+ char lab[MM_LABEL_1_MAX + MM_LABEL_2_MAX + 3];
+
+ if (!mm.init)
+ {
+ mm.init = INIT_VERB;
+ if (!(s = getenv(MM_VERB_ENV)))
+ mm.mask = MM_default;
+ else for (;;)
+ {
+ if (t = strchr(s, ':'))
+ *t = 0;
+ if (!(p = (MM_table_t*)strlook(mm_verb, sizeof(MM_table_t), s)))
+ {
+ mm.mask = MM_default;
+ if (t)
+ *t = ':';
+ break;
+ }
+ mm.mask |= p->value;
+ if (!t)
+ break;
+ *t++ = ':';
+ s = t;
+ }
+ }
+ if (!(classification & (MM_CONSOLE|MM_PRINT)))
+ return 0;
+ if (!(sp = sfstropen()))
+ return MM_NOTOK;
+ r = 0;
+ if (s = (char*)label)
+ {
+ if (t = strchr(s, ':'))
+ {
+ if ((n = t - s) > MM_LABEL_1_MAX)
+ n = MM_LABEL_1_MAX;
+ sfprintf(sp, "%*.*s:", n, n, s);
+ s = ++t;
+ if ((n = strlen(t)) > MM_LABEL_2_MAX)
+ n = MM_LABEL_2_MAX;
+ sfprintf(sp, "%*.*s", n, n, s);
+ }
+ else
+ {
+ if ((n = strlen(t)) > MM_LABEL_1_MAX)
+ n = MM_LABEL_1_MAX;
+ sfprintf(sp, "%*.*s", n, n, s);
+ }
+ if (!(s = sfstruse(sp)))
+ {
+ sfstrclose(sp);
+ return MM_NOTOK;
+ }
+ strcpy(lab, s);
+ }
+ for (;;)
+ {
+ if (classification & MM_CONSOLE)
+ {
+ classification &= ~MM_CONSOLE;
+ if (!(mm.init & INIT_CONSOLE))
+ mm.console = open("/dev/console", O_WRONLY|O_APPEND|O_NOCTTY);
+ if (mm.console < 0)
+ {
+ r |= MM_NOCON;
+ continue;
+ }
+ c = MM_NOCON;
+ fd = mm.console;
+ mask = MM_all;
+ }
+ else if (classification & MM_PRINT)
+ {
+ classification &= ~MM_PRINT;
+ c = MM_NOMSG;
+ fd = 2;
+ mask = mm.mask;
+ }
+ else break;
+ if ((mask & MM_label) && label)
+ sfprintf(sp, "%s: ", lab);
+ if ((mask & MM_severity) && (s = display(mm_severity, severity, 0)))
+ sfprintf(sp, "%s: ", s);
+ n = sfstrtell(sp);
+ if ((mask & MM_text) && text)
+ sfprintf(sp, "%s\n", text);
+ else sfputc(sp, '\n');
+ if ((mask & MM_action) && action || (mask & MM_tag) && (label || tag))
+ {
+ if (fd != mm.console && (n -= 8) > 0)
+ sfprintf(sp, "%*.*s", n, n, "");
+ sfprintf(sp, "TO FIX:");
+ if ((mask & MM_action) && action)
+ sfprintf(sp, " %s", action);
+ if ((mask & MM_tag) && (label || tag))
+ {
+ sfprintf(sp, " ");
+ if (!tag || label && !strchr(tag, ':'))
+ sfprintf(sp, "%s%s", lab, tag ? ":" : "");
+ if (tag)
+ sfprintf(sp, "%s", tag);
+ }
+ if (mask & (MM_class|MM_source|MM_status))
+ {
+ sfputc(sp, ' ');
+ if ((mask & MM_source) && (m = classification & (MM_APPL|MM_UTIL|MM_OPSYS)) && (s = display(mm_class, m, 1)))
+ sfprintf(sp, " %s", s);
+ if ((mask & MM_class) && (m = classification & (MM_HARD|MM_SOFT|MM_FIRM)) && (s = display(mm_class, m, 1)))
+ sfprintf(sp, " %s", s);
+ if ((mask & MM_status) && (m = classification & (MM_RECOVER|MM_NRECOV)) && (s = display(mm_class, m, 1)))
+ sfprintf(sp, " %s", s);
+ }
+ sfputc(sp, '\n');
+ }
+ n = sfstrtell(sp);
+ if (!(s = sfstruse(sp)) || write(fd, s, n) != n)
+ r |= c;
+ }
+ sfstrclose(sp);
+ return r;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/fnmatch.c b/usr/src/lib/libast/common/comp/fnmatch.c
new file mode 100644
index 0000000000..71ffc9cd9b
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/fnmatch.c
@@ -0,0 +1,79 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * fnmatch implementation
+ */
+
+#include <ast_lib.h>
+
+#include <ast.h>
+#include <regex.h>
+#include <fnmatch.h>
+
+typedef struct
+{
+ int fnm; /* fnmatch flag */
+ int reg; /* regex flag */
+} Map_t;
+
+static const Map_t map[] =
+{
+ FNM_AUGMENTED, REG_AUGMENTED,
+ FNM_ICASE, REG_ICASE,
+ FNM_NOESCAPE, REG_SHELL_ESCAPED,
+ FNM_PATHNAME, REG_SHELL_PATH,
+ FNM_PERIOD, REG_SHELL_DOT,
+};
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int
+fnmatch(const char* pattern, const char* subject, register int flags)
+{
+ register int reflags = REG_SHELL|REG_LEFT;
+ register const Map_t* mp;
+ regex_t re;
+ regmatch_t match;
+
+ for (mp = map; mp < &map[elementsof(map)]; mp++)
+ if (flags & mp->fnm)
+ reflags |= mp->reg;
+ if (flags & FNM_LEADING_DIR)
+ {
+ if (!(reflags = regcomp(&re, pattern, reflags)))
+ {
+ reflags = regexec(&re, subject, 1, &match, 0);
+ regfree(&re);
+ if (!reflags && (reflags = subject[match.rm_eo]))
+ reflags = reflags == '/' ? 0 : FNM_NOMATCH;
+ }
+ }
+ else if (!(reflags = regcomp(&re, pattern, reflags|REG_RIGHT)))
+ {
+ reflags = regexec(&re, subject, 0, NiL, 0);
+ regfree(&re);
+ }
+ return reflags;
+}
diff --git a/usr/src/lib/libast/common/comp/fnmatch.h b/usr/src/lib/libast/common/comp/fnmatch.h
new file mode 100644
index 0000000000..d0e9500f22
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/fnmatch.h
@@ -0,0 +1,60 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * posix fnmatch interface definitions
+ */
+
+#ifndef _FNMATCH_H
+#define _FNMATCH_H
+
+#include <ast_common.h>
+
+/* fnmatch flags */
+
+#define FNM_NOESCAPE 0x0001 /* \ is literal */
+#define FNM_PATHNAME 0x0002 /* explicit match for / */
+#define FNM_PERIOD 0x0004 /* explicit match for leading . */
+#define FNM_NOSYS 0x0010 /* not implemented */
+
+/* nonstandard fnmatch() flags */
+
+#define FNM_AUGMENTED 0x0008 /* enable ! & ( | ) */
+#define FNM_ICASE 0x0020 /* ignore case in match */
+#define FNM_LEADING_DIR 0x0040 /* match up to implicit / */
+
+#define FNM_CASEFOLD FNM_ICASE /* gnu compatibility */
+#define FNM_FILE_NAME FNM_PATHNAME /* gnu compatibility */
+
+/* fnmatch error codes -- other non-zero values from <regex.h> */
+
+#define FNM_NOMATCH 1 /* == REG_NOMATCH */
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int fnmatch(const char*, const char*, int);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/frexp.c b/usr/src/lib/libast/common/comp/frexp.c
new file mode 100644
index 0000000000..27fee2d38a
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/frexp.c
@@ -0,0 +1,153 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * frexp/ldexp implementation
+ */
+
+#include <ast.h>
+
+#include "FEATURE/float"
+
+#if _lib_frexp && _lib_ldexp
+
+NoN(frexp)
+
+#else
+
+#if defined(_ast_dbl_exp_index) && defined(_ast_dbl_exp_shift)
+
+#define INIT() _ast_dbl_exp_t _pow_
+#define pow2(i) (_pow_.f=1,_pow_.e[_ast_dbl_exp_index]+=((i)<<_ast_dbl_exp_shift),_pow_.f)
+
+#else
+
+static double pow2tab[DBL_MAX_EXP + 1];
+
+static int
+init(void)
+{
+ register int x;
+ double g;
+
+ g = 1;
+ for (x = 0; x < elementsof(pow2tab); x++)
+ {
+ pow2tab[x] = g;
+ g *= 2;
+ }
+ return 0;
+}
+
+#define INIT() (pow2tab[0]?0:init())
+
+#define pow2(i) pow2tab[i]
+
+#endif
+
+#if !_lib_frexp
+
+extern double
+frexp(double f, int* p)
+{
+ register int k;
+ register int x;
+ double g;
+
+ INIT();
+
+ /*
+ * normalize
+ */
+
+ x = k = DBL_MAX_EXP / 2;
+ if (f < 1)
+ {
+ g = 1.0L / f;
+ for (;;)
+ {
+ k = (k + 1) / 2;
+ if (g < pow2(x))
+ x -= k;
+ else if (k == 1 && g < pow2(x+1))
+ break;
+ else
+ x += k;
+ }
+ if (g == pow2(x))
+ x--;
+ x = -x;
+ }
+ else if (f > 1)
+ {
+ for (;;)
+ {
+ k = (k + 1) / 2;
+ if (f > pow2(x))
+ x += k;
+ else if (k == 1 && f > pow2(x-1))
+ break;
+ else
+ x -= k;
+ }
+ if (f == pow2(x))
+ x++;
+ }
+ else
+ x = 1;
+ *p = x;
+
+ /*
+ * shift
+ */
+
+ x = -x;
+ if (x < 0)
+ f /= pow2(-x);
+ else if (x < DBL_MAX_EXP)
+ f *= pow2(x);
+ else
+ f = (f * pow2(DBL_MAX_EXP - 1)) * pow2(x - (DBL_MAX_EXP - 1));
+ return f;
+}
+
+#endif
+
+#if !_lib_ldexp
+
+extern double
+ldexp(double f, register int x)
+{
+ INIT();
+ if (x < 0)
+ f /= pow2(-x);
+ else if (x < DBL_MAX_EXP)
+ f *= pow2(x);
+ else
+ f = (f * pow2(DBL_MAX_EXP - 1)) * pow2(x - (DBL_MAX_EXP - 1));
+ return f;
+}
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/frexpl.c b/usr/src/lib/libast/common/comp/frexpl.c
new file mode 100644
index 0000000000..6555dfa03d
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/frexpl.c
@@ -0,0 +1,161 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * frexpl/ldexpl implementation
+ */
+
+#include <ast.h>
+
+#include "FEATURE/float"
+
+#if _lib_frexpl && _lib_ldexpl
+
+NoN(frexpl)
+
+#else
+
+#ifndef LDBL_MAX_EXP
+#define LDBL_MAX_EXP DBL_MAX_EXP
+#endif
+
+#if defined(_ast_fltmax_exp_index) && defined(_ast_fltmax_exp_shift)
+
+#define INIT() _ast_fltmax_exp_t _pow_
+#define pow2(i) (_pow_.f=1,_pow_.e[_ast_fltmax_exp_index]+=((i)<<_ast_fltmax_exp_shift),_pow_.f)
+
+#else
+
+static _ast_fltmax_t pow2tab[LDBL_MAX_EXP + 1];
+
+static int
+init(void)
+{
+ register int x;
+ _ast_fltmax_t g;
+
+ g = 1;
+ for (x = 0; x < elementsof(pow2tab); x++)
+ {
+ pow2tab[x] = g;
+ g *= 2;
+ }
+ return 0;
+}
+
+#define INIT() (pow2tab[0]?0:init())
+
+#define pow2(i) (pow2tab[i])
+
+#endif
+
+#if !_lib_frexpl
+
+#undef frexpl
+
+extern _ast_fltmax_t
+frexpl(_ast_fltmax_t f, int* p)
+{
+ register int k;
+ register int x;
+ _ast_fltmax_t g;
+
+ INIT();
+
+ /*
+ * normalize
+ */
+
+ x = k = LDBL_MAX_EXP / 2;
+ if (f < 1)
+ {
+ g = 1.0L / f;
+ for (;;)
+ {
+ k = (k + 1) / 2;
+ if (g < pow2(x))
+ x -= k;
+ else if (k == 1 && g < pow2(x+1))
+ break;
+ else
+ x += k;
+ }
+ if (g == pow2(x))
+ x--;
+ x = -x;
+ }
+ else if (f > 1)
+ {
+ for (;;)
+ {
+ k = (k + 1) / 2;
+ if (f > pow2(x))
+ x += k;
+ else if (k == 1 && f > pow2(x-1))
+ break;
+ else
+ x -= k;
+ }
+ if (f == pow2(x))
+ x++;
+ }
+ else
+ x = 1;
+ *p = x;
+
+ /*
+ * shift
+ */
+
+ x = -x;
+ if (x < 0)
+ f /= pow2(-x);
+ else if (x < LDBL_MAX_EXP)
+ f *= pow2(x);
+ else
+ f = (f * pow2(LDBL_MAX_EXP - 1)) * pow2(x - (LDBL_MAX_EXP - 1));
+ return f;
+}
+
+#endif
+
+#if !_lib_ldexpl
+
+#undef ldexpl
+
+extern _ast_fltmax_t
+ldexpl(_ast_fltmax_t f, register int x)
+{
+ INIT();
+ if (x < 0)
+ f /= pow2(-x);
+ else if (x < LDBL_MAX_EXP)
+ f *= pow2(x);
+ else
+ f = (f * pow2(LDBL_MAX_EXP - 1)) * pow2(x - (LDBL_MAX_EXP - 1));
+ return f;
+}
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/fsync.c b/usr/src/lib/libast/common/comp/fsync.c
new file mode 100644
index 0000000000..1d847de241
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/fsync.c
@@ -0,0 +1,46 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_fsync
+
+NoN(fsync)
+
+#else
+
+#include <error.h>
+
+#ifndef ENOSYS
+#define ENOSYS EINVAL
+#endif
+
+int
+fsync(int fd)
+{
+ NoP(fd);
+ errno = ENOSYS;
+ return -1;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/ftw.c b/usr/src/lib/libast/common/comp/ftw.c
new file mode 100644
index 0000000000..21831c9821
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/ftw.c
@@ -0,0 +1,50 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * ftw implementation
+ */
+
+#include <ast.h>
+#include <ftw.h>
+
+static int (*ftw_userf)(const char*, const struct stat*, int);
+
+static int
+ftw_user(Ftw_t* ftw)
+{
+ register int n = ftw->info;
+
+ if (n & (FTW_C|FTW_NX))
+ n = FTW_DNR;
+ else if (n & FTW_SL)
+ n = FTW_NS;
+ return (*ftw_userf)(ftw->path, &ftw->statb, n);
+}
+
+int
+ftw(const char* path, int(*userf)(const char*, const struct stat*, int), int depth)
+{
+ NoP(depth);
+ ftw_userf = userf;
+ return ftwalk(path, ftw_user, FTW_DOT, NiL);
+}
diff --git a/usr/src/lib/libast/common/comp/ftw.h b/usr/src/lib/libast/common/comp/ftw.h
new file mode 100644
index 0000000000..2b312416fe
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/ftw.h
@@ -0,0 +1,60 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * ftw,nftw over ftwalk
+ */
+
+#ifndef _FTW_H
+#define _FTW_H
+
+#define FTW FTWALK
+#include <ftwalk.h>
+#undef FTW
+
+#define FTW_SLN (FTW_SL|FTW_NR)
+
+#define FTW_PHYS (FTW_PHYSICAL)
+#define FTW_CHDIR (FTW_DOT)
+#define FTW_DEPTH (FTW_POST)
+#define FTW_OPEN (0)
+
+struct FTW
+{
+ int quit;
+ int base;
+ int level;
+};
+
+#define FTW_SKD FTW_SKIP
+#define FTW_PRUNE FTW_SKIP
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int ftw(const char*, int(*)(const char*, const struct stat*, int), int);
+extern int nftw(const char*, int(*)(const char*, const struct stat*, int, struct FTW*), int, int);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/getdate.c b/usr/src/lib/libast/common/comp/getdate.c
new file mode 100644
index 0000000000..e1d64d09e7
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/getdate.c
@@ -0,0 +1,83 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * getdate implementation
+ */
+
+#define getdate ______getdate
+
+#include <ast.h>
+#include <tm.h>
+
+#undef getdate
+
+#undef _def_map_ast
+#include <ast_map.h>
+
+#undef _lib_getdate /* we can pass X/Open */
+
+#if _lib_getdate
+
+NoN(getdate)
+
+#else
+
+#ifndef getdate_err
+__DEFINE__(int, getdate_err, 0);
+#endif
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern struct tm*
+getdate(const char* s)
+{
+ char* e;
+ char* f;
+ time_t t;
+ Tm_t* tm;
+
+ static struct tm ts;
+
+ t = tmscan(s, &e, NiL, &f, NiL, TM_PEDANTIC);
+ if (*e || *f)
+ {
+ /* of course we all know what 7 means */
+ getdate_err = 7;
+ return 0;
+ }
+ tm = tmmake(&t);
+ ts.tm_sec = tm->tm_sec;
+ ts.tm_min = tm->tm_min;
+ ts.tm_hour = tm->tm_hour;
+ ts.tm_mday = tm->tm_mday;
+ ts.tm_mon = tm->tm_mon;
+ ts.tm_year = tm->tm_year;
+ ts.tm_wday = tm->tm_wday;
+ ts.tm_yday = tm->tm_yday;
+ ts.tm_isdst = tm->tm_isdst;
+ return &ts;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/getgroups.c b/usr/src/lib/libast/common/comp/getgroups.c
new file mode 100644
index 0000000000..b909c37a96
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/getgroups.c
@@ -0,0 +1,78 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if !defined(getgroups) && defined(_lib_getgroups)
+
+NoN(getgroups)
+
+#else
+
+#include <error.h>
+
+#if defined(getgroups)
+#undef getgroups
+#define ast_getgroups _ast_getgroups
+#define botched 1
+extern int getgroups(int, int*);
+#else
+#define ast_getgroups getgroups
+#endif
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int
+ast_getgroups(int len, gid_t* set)
+{
+#if botched
+#if NGROUPS_MAX < 1
+#undef NGROUPS_MAX
+#define NGROUPS_MAX 1
+#endif
+ register int i;
+ int big[NGROUPS_MAX];
+#else
+#undef NGROUPS_MAX
+#define NGROUPS_MAX 1
+#endif
+ if (!len) return(NGROUPS_MAX);
+ if (len < 0 || !set)
+ {
+ errno = EINVAL;
+ return(-1);
+ }
+#if botched
+ len = getgroups(len > NGROUPS_MAX ? NGROUPS_MAX : len, big);
+ for (i = 0; i < len; i++)
+ set[i] = big[i];
+ return(len);
+#else
+ *set = getgid();
+ return(1);
+#endif
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/getlogin.c b/usr/src/lib/libast/common/comp/getlogin.c
new file mode 100644
index 0000000000..b781e99895
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/getlogin.c
@@ -0,0 +1,42 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_getlogin
+
+NoN(getlogin)
+
+#else
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern char*
+getlogin(void)
+{
+ return fmtuid(getuid());
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/getopt.c b/usr/src/lib/libast/common/comp/getopt.c
new file mode 100644
index 0000000000..86e32d1bc1
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/getopt.c
@@ -0,0 +1,78 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#undef _lib_getopt /* we can satisfy the api */
+
+#if _lib_getopt
+
+NoN(getopt)
+
+#else
+
+#undef _BLD_ast /* enable ast imports since we're user static */
+
+#include <error.h>
+#include <option.h>
+
+int opterr = 1;
+int optind = 1;
+int optopt = 0;
+char* optarg = 0;
+
+static int lastoptind;
+
+extern int
+getopt(int argc, char* const* argv, const char* optstring)
+{
+ int n;
+
+ NoP(argc);
+ opt_info.index = (optind > 1 || optind == lastoptind) ? optind : 0;
+ if (opt_info.index >= argc)
+ return -1;
+ switch (n = optget((char**)argv, optstring))
+ {
+ case ':':
+ n = '?';
+ /*FALLTHROUGH*/
+ case '?':
+ if (opterr && (!optstring || *optstring != ':'))
+ {
+ if (!error_info.id)
+ error_info.id = argv[0];
+ errormsg(NiL, 2, opt_info.arg);
+ }
+ optopt = opt_info.option[1];
+ break;
+ case 0:
+ n = -1;
+ break;
+ }
+ optarg = opt_info.arg;
+ lastoptind = optind = opt_info.index;
+ return n;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/getopt.h b/usr/src/lib/libast/common/comp/getopt.h
new file mode 100644
index 0000000000..e26806d288
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/getopt.h
@@ -0,0 +1,48 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * gnu getopt interface
+ */
+
+#include <ast_getopt.h>
+
+#if !defined(_GETOPT_H) && !defined(_AST_STD_I)
+
+#define _GETOPT_H 1
+
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+struct option
+{
+ const char* name;
+ int has_arg;
+ int* flag;
+ int val;
+};
+
+extern int getopt_long(int, char* const*, const char*, const struct option*, int*);
+extern int getopt_long_only(int, char* const*, const char*, const struct option*, int*);
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/getoptl.c b/usr/src/lib/libast/common/comp/getoptl.c
new file mode 100644
index 0000000000..4aec979ffa
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/getoptl.c
@@ -0,0 +1,150 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#undef _BLD_ast /* enable ast imports since we're user static */
+
+#include <error.h>
+#include <option.h>
+#include <getopt.h>
+#include <ctype.h>
+
+static const char* lastoptstring;
+static const struct option* lastlongopts;
+static char* usage;
+static Sfio_t* up;
+
+static int lastoptind;
+
+static int
+golly(int argc, char* const* argv, const char* optstring, const struct option* longopts, int* longindex, int flags)
+{
+ register char* s;
+ register const struct option* o;
+ register int c;
+ char* t;
+
+ if (!up || optstring != lastoptstring || longopts != lastlongopts)
+ {
+ if (!up && !(up = sfstropen()))
+ return -1;
+ sfprintf(up, "[-1p%d]", flags);
+ t = strdup(optstring);
+ for (o = longopts; o->name; o++)
+ {
+ if (o->flag || o->val <= 0 || o->val > UCHAR_MAX || !isalnum(o->val))
+ sfprintf(up, "\n[%d:%s]", UCHAR_MAX + 1 + (o - longopts), o->name);
+ else
+ {
+ sfprintf(up, "\n[%c:%s]", o->val, o->name);
+ if (s = strchr(t, o->val))
+ {
+ *s++ = ' ';
+ if (*s == ':')
+ {
+ *s++ = ' ';
+ if (*s == ':')
+ *s = ' ';
+ }
+ }
+ }
+ if (o->has_arg)
+ {
+ sfputc(up, ':');
+ if (o->has_arg == optional_argument)
+ sfputc(up, '?');
+ sfprintf(up, "[string]");
+ }
+ }
+ s = t;
+ while (c = *s++)
+ if (c != ' ')
+ {
+ sfprintf(up, "\n[%c]", c);
+ if (*s == ':')
+ {
+ sfputc(up, *s);
+ if (*++s == ':')
+ {
+ sfputc(up, '?');
+ s++;
+ }
+ sfputc(up, '[');
+ sfputc(up, ']');
+ }
+ }
+ sfputc(up, '\n');
+ if (!(usage = sfstruse(up)))
+ return -1;
+ lastoptstring = optstring;
+ lastlongopts = longopts;
+ }
+ opt_info.index = (optind > 1 || optind == lastoptind) ? optind : 0;
+ if (opt_info.index >= argc || !(c = optget((char**)argv, usage)))
+ {
+ sfstrclose(up);
+ up = 0;
+ c = -1;
+ }
+ else
+ {
+ if (c == ':' || c == '?')
+ {
+ if (opterr && (!optstring || *optstring != ':'))
+ {
+ if (!error_info.id)
+ error_info.id = argv[0];
+ errormsg(NiL, c == '?' ? (ERROR_USAGE|4) : 2, "%s", opt_info.arg);
+ }
+ optopt = opt_info.option[1];
+ c = '?';
+ }
+ optarg = opt_info.arg;
+ if (c < 0)
+ {
+ o = longopts - c - UCHAR_MAX - 1;
+ if (o->flag)
+ {
+ *o->flag = o->val;
+ c = 0;
+ }
+ else
+ c = o->val;
+ }
+ }
+ lastoptind = optind = opt_info.index;
+ return c;
+}
+
+extern int
+getopt_long(int argc, char* const* argv, const char* optstring, const struct option* longopts, int* longindex)
+{
+ return golly(argc, argv, optstring, longopts, longindex, 2);
+}
+
+extern int
+getopt_long_only(int argc, char* const* argv, const char* optstring, const struct option* longopts, int* longindex)
+{
+ return golly(argc, argv, optstring, longopts, longindex, 1);
+}
diff --git a/usr/src/lib/libast/common/comp/getpgrp.c b/usr/src/lib/libast/common/comp/getpgrp.c
new file mode 100644
index 0000000000..fb361d8468
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/getpgrp.c
@@ -0,0 +1,47 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#define getpgrp ______getpgrp
+
+#include <ast_std.h>
+
+#undef getpgrp
+
+/*
+ * bsd int getpgrp(int);
+ * s5 int getpgrp(void);
+ * posix pid_t getpgrp(void);
+ * user SOL
+ */
+
+extern int getpgrp(int);
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int
+_ast_getpgrp(void)
+{
+ return getpgrp(0);
+}
diff --git a/usr/src/lib/libast/common/comp/getsubopt.c b/usr/src/lib/libast/common/comp/getsubopt.c
new file mode 100644
index 0000000000..b0a04940ee
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/getsubopt.c
@@ -0,0 +1,94 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Xopen 4.2 compatibility
+ */
+
+#include <ast_lib.h>
+
+#undef _lib_getsubopt /* we can satisfy the api */
+
+#if _lib_getsubopt
+
+#include <ast.h>
+
+NoN(getsubopt)
+
+#else
+
+#define getsubopt ______getsubopt
+
+#include <ast.h>
+
+#undef getsubopt
+
+#include <error.h>
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int
+getsubopt(register char** op, char* const* tp, char** vp)
+{
+ register char* b;
+ register char* s;
+ register char* v;
+
+ if (*(b = *op))
+ {
+ v = 0;
+ s = b;
+ for (;;)
+ {
+ switch (*s++)
+ {
+ case 0:
+ s--;
+ break;
+ case ',':
+ *(s - 1) = 0;
+ break;
+ case '=':
+ if (!v)
+ {
+ *(s - 1) = 0;
+ v = s;
+ }
+ continue;
+ default:
+ continue;
+ }
+ break;
+ }
+ *op = s;
+ *vp = v;
+ for (op = (char**)tp; *op; op++)
+ if (streq(b, *op))
+ return op - (char**)tp;
+ }
+ *vp = b;
+ return -1;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/getwd.c b/usr/src/lib/libast/common/comp/getwd.c
new file mode 100644
index 0000000000..4e6bdc2899
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/getwd.c
@@ -0,0 +1,37 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * getwd() using getcwd()
+ *
+ * some getwd()'s are incredible
+ */
+
+#include <ast.h>
+
+char*
+getwd(char* path)
+{
+ if (getcwd(path, PATH_MAX)) return(path);
+ strcpy(path, "getwd: error in . or ..");
+ return(0);
+}
diff --git a/usr/src/lib/libast/common/comp/gross.c b/usr/src/lib/libast/common/comp/gross.c
new file mode 100644
index 0000000000..58a11c3159
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/gross.c
@@ -0,0 +1,99 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * porting hacks here
+ */
+
+#include <ast.h>
+#include <ls.h>
+
+#include "FEATURE/hack"
+
+void _STUB_gross(){}
+
+#if _lcl_xstat
+
+extern int fstat(int fd, struct stat* st)
+{
+#if _lib___fxstat
+ return __fxstat(_STAT_VER, fd, st);
+#else
+ return _fxstat(_STAT_VER, fd, st);
+#endif
+}
+
+extern int lstat(const char* path, struct stat* st)
+{
+#if _lib___lxstat
+ return __lxstat(_STAT_VER, path, st);
+#else
+ return _lxstat(_STAT_VER, path, st);
+#endif
+}
+
+extern int stat(const char* path, struct stat* st)
+{
+#if _lib___xstat
+ return __xstat(_STAT_VER, path, st);
+#else
+ return _xstat(_STAT_VER, path, st);
+#endif
+}
+
+#endif
+
+#if _lcl_xstat64
+
+extern int fstat64(int fd, struct stat64* st)
+{
+#if _lib___fxstat64
+ return __fxstat64(_STAT_VER, fd, st);
+#else
+ return _fxstat64(_STAT_VER, fd, st);
+#endif
+}
+
+extern int lstat64(const char* path, struct stat64* st)
+{
+#if _lib___lxstat64
+ return __lxstat64(_STAT_VER, path, st);
+#else
+ return _lxstat64(_STAT_VER, path, st);
+#endif
+}
+
+extern int stat64(const char* path, struct stat64* st)
+{
+#if _lib___xstat64
+ return __xstat64(_STAT_VER, path, st);
+#else
+ return _xstat64(_STAT_VER, path, st);
+#endif
+}
+
+#endif
+
+#if __sgi && _hdr_locale_attr
+
+#include "gross_sgi.h"
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/hsearch.c b/usr/src/lib/libast/common/comp/hsearch.c
new file mode 100644
index 0000000000..039dc3a007
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/hsearch.c
@@ -0,0 +1,138 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * hsearch() for systems that have <search.h> but no hsearch()
+ * why would such a system provide the interface but not the
+ * implementation? that's what happens when one slimes their
+ * way through standards compliance
+ *
+ * NOTE: please excuse the crude feature test
+ */
+
+#if !_UWIN
+
+void _STUB_hsearch(){}
+
+#else
+
+#if _PACKAGE_ast
+#include <ast.h>
+#endif
+
+#define hcreate ______hcreate
+#define hdestroy ______hdestroy
+#define hsearch ______hsearch
+
+#include <search.h>
+
+#undef hcreate
+#undef hdestroy
+#undef hsearch
+
+#include "dthdr.h"
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+/* POSIX hsearch library based on libdt
+** Written by Kiem-Phong Vo (AT&T Research, 07/19/95)
+*/
+
+/* type of objects in hash table */
+typedef struct _hash_s
+{ Dtlink_t link;
+ ENTRY item;
+} Hash_t;
+
+/* object delete function */
+#if __STD_C
+static void hashfree(Dt_t* dt, Void_t* obj, Dtdisc_t* disc)
+#else
+static void hashfree(dt, obj, disc)
+Dt_t* dt;
+Void_t* obj;
+Dtdisc_t* disc;
+#endif
+{
+ free(((Hash_t*)obj)->item.key);
+ free(obj);
+}
+
+static Dt_t* Hashtab; /* object dictionary */
+static Dtdisc_t Hashdisc = /* discipline */
+{ sizeof(Dtlink_t), -1,
+ 0,
+ NIL(Dtmake_f), hashfree,
+ NIL(Dtcompar_f), /* always use strcmp */
+ NIL(Dthash_f),
+ NIL(Dtmemory_f),
+ NIL(Dtevent_f)
+};
+
+extern
+#if __STD_C
+int hcreate(size_t nel)
+#else
+int hcreate(nel)
+size_t nel;
+#endif
+{
+ if(Hashtab) /* already opened */
+ return 0;
+
+ if(!(Hashtab = dtopen(&Hashdisc,Dtset)) )
+ return 0;
+
+ return 1;
+}
+
+extern void hdestroy()
+{ if(Hashtab)
+ dtclose(Hashtab);
+ Hashtab = NIL(Dt_t*);
+}
+
+extern
+#if __STD_C
+ENTRY* hsearch(ENTRY item, ACTION action)
+#else
+ENTRY* hsearch(item, action)
+ENTRY item;
+ACTION action;
+#endif
+{
+ reg Hash_t* o;
+
+ if(!Hashtab)
+ return NIL(ENTRY*);
+
+ if(!(o = (Hash_t*)dtmatch(Hashtab,item.key)) && action == ENTER &&
+ (o = (Hash_t*)malloc(sizeof(Hash_t)) ) )
+ { o->item = item;
+ o = (Hash_t*)dtinsert(Hashtab,o);
+ }
+
+ return o ? &(o->item) : NIL(ENTRY*);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/iconv.c b/usr/src/lib/libast/common/comp/iconv.c
new file mode 100644
index 0000000000..016831e660
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/iconv.c
@@ -0,0 +1,1496 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * iconv intercept
+ * minimally provides { utf*<=>bin ascii<=>ebcdic* }
+ */
+
+#include <ast.h>
+#include <dirent.h>
+
+#define DEBUG_TRACE 0
+#define _ICONV_LIST_PRIVATE_
+
+#include <ccode.h>
+#include <ctype.h>
+#include <iconv.h>
+
+#include "lclib.h"
+
+#if !_lib_iconv_open
+
+#define _ast_iconv_t iconv_t
+#define _ast_iconv_f iconv_f
+#define _ast_iconv_list_t iconv_list_t
+#define _ast_iconv_open iconv_open
+#define _ast_iconv iconv
+#define _ast_iconv_close iconv_close
+#define _ast_iconv_list iconv_list
+#define _ast_iconv_move iconv_move
+#define _ast_iconv_name iconv_name
+#define _ast_iconv_write iconv_write
+
+#endif
+
+#ifndef E2BIG
+#define E2BIG ENOMEM
+#endif
+#ifndef EILSEQ
+#define EILSEQ EIO
+#endif
+
+#define RETURN(e,n,fn) \
+ if (*fn && !e) e = E2BIG; \
+ if (e) { errno = e; return (size_t)(-1); } \
+ return n;
+
+typedef struct Map_s
+{
+ char* name;
+ const unsigned char* map;
+ _ast_iconv_f fun;
+ int index;
+} Map_t;
+
+typedef struct Conv_s
+{
+ iconv_t cvt;
+ char* buf;
+ size_t size;
+ Map_t from;
+ Map_t to;
+} Conv_t;
+
+static Conv_t* freelist[4];
+static int freeindex;
+
+static const char name_local[] = "local";
+static const char name_native[] = "native";
+
+static const _ast_iconv_list_t codes[] =
+{
+ {
+ "utf",
+ "un|unicode|utf",
+ "multibyte 8-bit unicode",
+ "UTF-%s",
+ "8",
+ CC_UTF,
+ },
+
+ {
+ "ume",
+ "um|ume|utf?(-)7",
+ "multibyte 7-bit unicode",
+ "UTF-7",
+ 0,
+ CC_UME,
+ },
+
+ {
+ "euc",
+ "(big|euc)*",
+ "euc family",
+ 0,
+ 0,
+ CC_ICONV,
+ },
+
+ {
+ "dos",
+ "dos?(-)?(855)",
+ "dos code page",
+ "DOS855",
+ 0,
+ CC_ICONV,
+ },
+
+ {
+ "ucs",
+ "ucs?(-)?(2)?(be)|utf-16?(be)",
+ "unicode runes",
+ "UCS-%s",
+ "2",
+ CC_UCS,
+ },
+
+ {
+ "ucs-le",
+ "ucs?(-)?(2)le|utf-16le",
+ "little endian unicode runes",
+ "UCS-%sLE",
+ "2",
+ CC_SCU,
+ },
+
+ { 0 },
+};
+
+#if _UWIN
+
+#include <ast_windows.h>
+
+#ifndef CP_UCS2
+#define CP_UCS2 0x0000
+#endif
+
+static char _win_maps[] = "/reg/local_machine/SOFTWARE/Classes/MIME/Database/Charset";
+
+/*
+ * return the codeset index given its name or alias
+ * the map is in the what? oh, the registry
+ */
+
+static int
+_win_codeset(const char* name)
+{
+ register char* s;
+ char* e;
+ int n;
+ Sfio_t* sp;
+ char aka[128];
+ char tmp[128];
+
+#if DEBUG_TRACE
+error(DEBUG_TRACE, "AHA#%d _win_codeset name=%s", __LINE__, name);
+#endif
+ if (name == name_native)
+ return CP_ACP;
+ if (!strcasecmp(name, "utf") || !strcasecmp(name, "utf8") || !strcasecmp(name, "utf-8"))
+ return CP_UTF8;
+ if (!strcasecmp(name, "ucs") || !strcasecmp(name, "ucs2") || !strcasecmp(name, "ucs-2"))
+ return CP_UCS2;
+ if (name[0] == '0' && name[1] == 'x' && (n = strtol(name, &e, 0)) > 0 && !*e)
+ return n;
+ for (;;)
+ {
+ sfsprintf(tmp, sizeof(tmp), "%s/%s", _win_maps, name);
+ if (!(sp = sfopen(0, tmp, "r")))
+ {
+ s = (char*)name;
+ if ((s[0] == 'c' || s[0] == 'C') && (s[1] == 'p' || s[1] == 'P'))
+ s += 2;
+ if (!isdigit(s[0]))
+ break;
+ sfsprintf(tmp, sizeof(tmp), "%s/windows-%s", _win_maps, s);
+ if (!(sp = sfopen(0, tmp, "r")))
+ break;
+ }
+ for (;;)
+ {
+ if (!(s = sfgetr(sp, '\n', 0)))
+ {
+ sfclose(sp);
+ return -1;
+ }
+ if (!strncasecmp(s, "AliasForCharSet=", 16))
+ {
+ n = sfvalue(sp) - 17;
+ s += 16;
+ if (n >= sizeof(aka))
+ n = sizeof(aka) - 1;
+ memcpy(aka, s, n);
+ aka[n] = 0;
+ sfclose(sp);
+ name = (const char*)aka;
+ break;
+ }
+ if (!strncasecmp(s, "CodePage=", 9))
+ {
+ s += 9;
+ n = strtol(s, 0, 0);
+ sfclose(sp);
+ return n;
+ }
+ }
+ }
+ return -1;
+}
+
+/*
+ * get and check the codeset indices
+ */
+
+static _ast_iconv_t
+_win_iconv_open(register Conv_t* cc, const char* t, const char* f)
+{
+#if DEBUG_TRACE
+error(DEBUG_TRACE, "AHA#%d _win_iconv_open f=%s t=%s\n", __LINE__, f, t);
+#endif
+ if ((cc->from.index = _win_codeset(f)) < 0)
+ return (_ast_iconv_t)(-1);
+ if ((cc->to.index = _win_codeset(t)) < 0)
+ return (_ast_iconv_t)(-1);
+#if DEBUG_TRACE
+error(DEBUG_TRACE, "AHA#%d _win_iconv_open f=0x%04x t=0x%04x\n", __LINE__, cc->from.index, cc->to.index);
+#endif
+ return (_ast_iconv_t)cc;
+}
+
+/*
+ * even though the indices already check out
+ * they could still be rejected
+ */
+
+static size_t
+_win_iconv(_ast_iconv_t cd, char** fb, size_t* fn, char** tb, size_t* tn)
+{
+ Conv_t* cc = (Conv_t*)cd;
+ size_t un;
+ size_t tz;
+ size_t fz;
+ size_t bz;
+ size_t pz;
+ size_t oz;
+ LPWSTR ub;
+
+#if DEBUG_TRACE
+error(DEBUG_TRACE, "AHA#%d _win_iconv from=0x%04x to=0x%04x\n", __LINE__, cc->from.index, cc->to.index);
+#endif
+ if (cc->from.index == cc->to.index)
+ {
+ /*
+ * easy
+ */
+
+ fz = tz = (*fn < *tn) ? *fn : *tn;
+ memcpy(*tb, *fb, fz);
+ }
+ else
+ {
+ ub = 0;
+ un = *fn;
+
+ /*
+ * from => ucs-2
+ */
+
+ if (cc->to.index == CP_UCS2)
+ {
+ if ((tz = MultiByteToWideChar(cc->from.index, 0, (LPCSTR)*fb, (int)*fn, (LPWSTR)*tb, *tn)) && tz <= *tn)
+ {
+ fz = *fn;
+ tz *= sizeof(WCHAR);
+ }
+ else
+ {
+ /*
+ * target too small
+ * binary search on input size to make it fit
+ */
+
+ oz = 0;
+ pz = *fn / 2;
+ fz = *fn - pz;
+ for (;;)
+ {
+ while (!(tz = MultiByteToWideChar(cc->from.index, 0, (LPCSTR)*fb, (int)fz, (LPWSTR)*tb, 0)))
+ if (++fz >= *fn)
+ goto nope;
+ tz *= sizeof(WCHAR);
+ if (tz == *tn)
+ break;
+ if (!(pz /= 2))
+ {
+ if (!(fz = oz))
+ goto nope;
+ break;
+ }
+ if (tz > *tn)
+ fz -= pz;
+ else
+ {
+ oz = fz;
+ fz += pz;
+ }
+ }
+ }
+ }
+ else
+ {
+ if (cc->from.index == CP_UCS2)
+ {
+ un = *fn / sizeof(WCHAR);
+ ub = (LPWSTR)*fb;
+ }
+ else if (!(un = MultiByteToWideChar(cc->from.index, 0, (LPCSTR)*fb, (int)*fn, (LPWSTR)*tb, 0)))
+ goto nope;
+ else if (!(ub = (LPWSTR)malloc(un * sizeof(WCHAR))))
+ goto nope;
+ else if (!(un = MultiByteToWideChar(cc->from.index, 0, (LPCSTR)*fb, (int)*fn, (LPWSTR)ub, un)))
+ goto nope;
+
+ /*
+ * ucs-2 => to
+ */
+
+ if (tz = WideCharToMultiByte(cc->to.index, 0, (LPCWSTR)ub, un, *tb, *tn, 0, 0))
+ fz = *fn;
+ else
+ {
+ /*
+ * target too small
+ * binary search on input size to make it fit
+ */
+
+ oz = 0;
+ pz = *fn / 2;
+ bz = *fn - pz;
+ for (;;)
+ {
+ while (!(fz = MultiByteToWideChar(cc->from.index, 0, (LPCSTR)*fb, (int)bz, (LPWSTR)ub, un)))
+ if (++bz > *fn)
+ goto nope;
+ if (!(tz = WideCharToMultiByte(cc->to.index, 0, (LPCWSTR)ub, fz, *tb, 0, 0, 0)))
+ goto nope;
+ if (tz == *tn)
+ break;
+ if (!(pz /= 2))
+ {
+ if (!(fz = oz))
+ goto nope;
+ break;
+ }
+ if (tz > *tn)
+ bz -= pz;
+ else
+ {
+ oz = bz;
+ bz += pz;
+ }
+ }
+ if (!(tz = WideCharToMultiByte(cc->to.index, 0, (LPCWSTR)ub, fz, *tb, tz, 0, 0)))
+ goto nope;
+#if DEBUG_TRACE
+error(DEBUG_TRACE, "AHA#%d _win_iconv *fn=%u fz=%u[%u] *tn=%u tz=%u\n", __LINE__, *fn, fz, fz * sizeof(WCHAR), *tn, tz);
+#endif
+#if 0
+ fz *= sizeof(WCHAR);
+#endif
+ }
+ if (ub != (LPWSTR)*fb)
+ free(ub);
+ }
+ }
+ *fb += fz;
+ *fn -= fz;
+ *tb += tz;
+ *tn -= tz;
+ return fz;
+ nope:
+ if (ub && ub != (LPWSTR)*fb)
+ free(ub);
+ errno = EINVAL;
+ return (size_t)(-1);
+}
+
+#endif
+
+/*
+ * return canonical character code set name for m
+ * if b!=0 then canonical name placed in b of size n
+ * <ccode.h> index returned
+ */
+
+int
+_ast_iconv_name(register const char* m, register char* b, size_t n)
+{
+ register const _ast_iconv_list_t* cp;
+ const _ast_iconv_list_t* bp;
+ register int c;
+ register char* e;
+ int sub[2];
+ char buf[16];
+#if DEBUG_TRACE
+ char* o;
+#endif
+
+ if (!b)
+ {
+ b = buf;
+ n = sizeof(buf);
+ }
+#if DEBUG_TRACE
+ o = b;
+#endif
+ e = b + n - 1;
+ bp = 0;
+ n = 0;
+ cp = ccmaplist(NiL);
+#if DEBUG_TRACE
+if (error_info.trace < DEBUG_TRACE) sfprintf(sfstderr, "%s: debug-%d: AHA%d _ast_iconv_name m=\"%s\"\n", error_info.id, error_info.trace, __LINE__, m);
+#endif
+ for (;;)
+ {
+#if DEBUG_TRACE
+if (error_info.trace < DEBUG_TRACE) sfprintf(sfstderr, "%s: debug-%d: AHA%d _ast_iconv_name n=%d bp=%p cp=%p ccode=%d name=\"%s\"\n", error_info.id, error_info.trace, __LINE__, n, bp, cp, cp->ccode, cp->name);
+#endif
+ if (strgrpmatch(m, cp->match, sub, elementsof(sub) / 2, STR_MAXIMAL|STR_LEFT|STR_ICASE))
+ {
+ if (!(c = m[sub[1]]))
+ {
+ bp = cp;
+ break;
+ }
+ if (sub[1] > n && !isalpha(c))
+ {
+ bp = cp;
+ n = sub[1];
+ }
+ }
+ if (cp->ccode < 0)
+ {
+ if (!(++cp)->name)
+ break;
+ }
+ else if (!(cp = (const _ast_iconv_list_t*)ccmaplist((_ast_iconv_list_t*)cp)))
+ cp = codes;
+ }
+ if (cp = bp)
+ {
+ if (cp->canon)
+ {
+ if (cp->index)
+ {
+ for (m += sub[1]; *m && !isalnum(*m); m++);
+ if (!isdigit(*m))
+ m = cp->index;
+ }
+ else
+ m = "1";
+ b += sfsprintf(b, e - b, cp->canon, m);
+ }
+ else if (cp->ccode == CC_NATIVE)
+ {
+ if ((locales[AST_LC_CTYPE]->flags & LC_default) || !locales[AST_LC_CTYPE]->charset || !(m = locales[AST_LC_CTYPE]->charset->code) || streq(m, "iso8859-1"))
+ switch (CC_NATIVE)
+ {
+ case CC_EBCDIC:
+ m = (const char*)"EBCDIC";
+ break;
+ case CC_EBCDIC_I:
+ m = (const char*)"EBCDIC-I";
+ break;
+ case CC_EBCDIC_O:
+ m = (const char*)"EBCDIC-O";
+ break;
+ default:
+ m = (const char*)"ISO-8859-1";
+ break;
+ }
+ b += sfsprintf(b, e - b, "%s", m);
+ }
+ *b = 0;
+#if DEBUG_TRACE
+if (error_info.trace < DEBUG_TRACE) sfprintf(sfstderr, "%s: debug-%d: AHA%d _ast_iconv_name ccode=%d canon=\"%s\"\n", error_info.id, error_info.trace, __LINE__, cp->ccode, o);
+#endif
+ return cp->ccode;
+ }
+ while (b < e && (c = *m++))
+ {
+ if (islower(c))
+ c = toupper(c);
+ *b++ = c;
+ }
+ *b = 0;
+#if DEBUG_TRACE
+if (error_info.trace < DEBUG_TRACE) sfprintf(sfstderr, "%s: debug-%d: AHA%d _ast_iconv_name ccode=%d canon=\"%s\"\n", error_info.id, error_info.trace, __LINE__, CC_ICONV, o);
+#endif
+ return CC_ICONV;
+}
+
+/*
+ * convert utf-8 to bin
+ */
+
+static size_t
+utf2bin(_ast_iconv_t cd, char** fb, size_t* fn, char** tb, size_t* tn)
+{
+ register unsigned char* f;
+ register unsigned char* fe;
+ register unsigned char* t;
+ register unsigned char* te;
+ register unsigned char* p;
+ register int c;
+ register int w;
+ size_t n;
+ int e;
+
+ e = 0;
+ f = (unsigned char*)(*fb);
+ fe = f + (*fn);
+ t = (unsigned char*)(*tb);
+ te = t + (*tn);
+ while (t < te && f < fe)
+ {
+ p = f;
+ c = *f++;
+ if (c & 0x80)
+ {
+ if (!(c & 0x40))
+ {
+ f = p;
+ e = EILSEQ;
+ break;
+ }
+ if (c & 0x20)
+ {
+ w = (c & 0x0F) << 12;
+ if (f >= fe)
+ {
+ f = p;
+ e = EINVAL;
+ break;
+ }
+ c = *f++;
+ if (c & 0x40)
+ {
+ f = p;
+ e = EILSEQ;
+ break;
+ }
+ w |= (c & 0x3F) << 6;
+ }
+ else
+ w = (c & 0x1F) << 6;
+ if (f >= fe)
+ {
+ f = p;
+ e = EINVAL;
+ break;
+ }
+ c = *f++;
+ w |= (c & 0x3F);
+ }
+ else
+ w = c;
+ *t++ = w;
+ }
+ *fn -= (char*)f - (*fb);
+ *fb = (char*)f;
+ *tn -= (n = (char*)t - (*tb));
+ *tb = (char*)t;
+ RETURN(e, n, fn);
+}
+
+/*
+ * convert bin to utf-8
+ */
+
+static size_t
+bin2utf(_ast_iconv_t cd, char** fb, size_t* fn, char** tb, size_t* tn)
+{
+ register unsigned char* f;
+ register unsigned char* fe;
+ register unsigned char* t;
+ register unsigned char* te;
+ register int c;
+ wchar_t w;
+ size_t n;
+ int e;
+
+ e = 0;
+ f = (unsigned char*)(*fb);
+ fe = f + (*fn);
+ t = (unsigned char*)(*tb);
+ te = t + (*tn);
+ while (f < fe && t < te)
+ {
+ if (!mbwide())
+ {
+ c = 1;
+ w = *f;
+ }
+ else if ((c = (*_ast_info.mb_towc)(&w, (char*)f, fe - f)) < 0)
+ {
+ e = EINVAL;
+ break;
+ }
+ else if (!c)
+ c = 1;
+ if (!(w & ~0x7F))
+ *t++ = w;
+ else
+ {
+ if (!(w & ~0x7FF))
+ {
+ if (t >= (te - 2))
+ {
+ e = E2BIG;
+ break;
+ }
+ *t++ = 0xC0 + (w >> 6);
+ }
+ else if (!(w & ~0xffff))
+ {
+ if (t >= (te - 3))
+ {
+ e = E2BIG;
+ break;
+ }
+ *t++ = 0xE0 + (w >> 12);
+ *t++ = 0x80 + ((w >> 6 ) & 0x3F);
+ }
+ else
+ {
+ e = EILSEQ;
+ break;
+ }
+ *t++ = 0x80 + (w & 0x3F);
+ }
+ f += c;
+ }
+ *fn -= (n = (char*)f - (*fb));
+ *fb = (char*)f;
+ *tn -= (char*)t - (*tb);
+ *tb = (char*)t;
+ RETURN(e, n, fn);
+}
+
+static const unsigned char ume_D[] =
+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'(),-./:?!\"#$%&*;<=>@[]^_`{|} \t\n";
+
+static const unsigned char ume_M[] =
+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+static unsigned char ume_d[UCHAR_MAX+1];
+
+static unsigned char ume_m[UCHAR_MAX+1];
+
+#define NOE 0xFF
+#define UMEINIT() (ume_d[ume_D[0]]?0:umeinit())
+
+/*
+ * initialize the ume tables
+ */
+
+static int
+umeinit(void)
+{
+ register const unsigned char* s;
+ register int i;
+ register int c;
+
+ if (!ume_d[ume_D[0]])
+ {
+ s = ume_D;
+ while (c = *s++)
+ ume_d[c] = 1;
+ memset(ume_m, NOE, sizeof(ume_m));
+ for (i = 0; c = ume_M[i]; i++)
+ ume_m[c] = i;
+ }
+ return 0;
+}
+
+/*
+ * convert utf-7 to bin
+ */
+
+static size_t
+ume2bin(_ast_iconv_t cd, char** fb, size_t* fn, char** tb, size_t* tn)
+{
+ register unsigned char* f;
+ register unsigned char* fe;
+ register unsigned char* t;
+ register unsigned char* te;
+ register unsigned char* p;
+ register int s;
+ register int c;
+ register int w;
+ size_t n;
+ int e;
+
+ e = 0;
+ UMEINIT();
+ f = (unsigned char*)(*fb);
+ fe = f + (*fn);
+ t = (unsigned char*)(*tb);
+ te = t + (*tn);
+ s = 0;
+ while (f < fe && t < te)
+ {
+ p = f;
+ c = *f++;
+ if (s)
+ {
+ if (c == '-' && s > 1)
+ s = 0;
+ else if ((w = ume_m[c]) == NOE)
+ {
+ s = 0;
+ *t++ = c;
+ }
+ else if (f >= (fe - 2))
+ {
+ f = p;
+ e = EINVAL;
+ break;
+ }
+ else
+ {
+ s = 2;
+ w = (w << 6) | ume_m[*f++];
+ w = (w << 6) | ume_m[*f++];
+ if (!(w & ~0xFF))
+ *t++ = w;
+ else if (t >= (te - 1))
+ {
+ f = p;
+ e = E2BIG;
+ break;
+ }
+ else
+ {
+ *t++ = (w >> 8) & 0xFF;
+ *t++ = w & 0xFF;
+ }
+ }
+ }
+ else if (c == '+')
+ s = 1;
+ else
+ *t++ = c;
+ }
+ *fn -= (char*)f - (*fb);
+ *fb = (char*)f;
+ *tn -= (n = (char*)t - (*tb));
+ *tb = (char*)t;
+ RETURN(e, n, fn);
+}
+
+/*
+ * convert bin to utf-7
+ */
+
+static size_t
+bin2ume(_ast_iconv_t cd, char** fb, size_t* fn, char** tb, size_t* tn)
+{
+ register unsigned char* f;
+ register unsigned char* fe;
+ register unsigned char* t;
+ register unsigned char* te;
+ register int c;
+ register int s;
+ wchar_t w;
+ size_t n;
+ int e;
+
+ e = 0;
+ UMEINIT();
+ f = (unsigned char*)(*fb);
+ fe = f + (*fn);
+ t = (unsigned char*)(*tb);
+ te = t + (*tn);
+ s = 0;
+ while (f < fe && t < (te - s))
+ {
+ if (!mbwide())
+ {
+ c = 1;
+ w = *f;
+ }
+ else if ((c = (*_ast_info.mb_towc)(&w, (char*)f, fe - f)) < 0)
+ {
+ e = EINVAL;
+ break;
+ }
+ else if (!c)
+ c = 1;
+ if (!(w & ~0x7F) && ume_d[w])
+ {
+ if (s)
+ {
+ s = 0;
+ *t++ = '-';
+ }
+ *t++ = w;
+ }
+ else if (t >= (te - (4 + s)))
+ {
+ e = E2BIG;
+ break;
+ }
+ else
+ {
+ if (!s)
+ {
+ s = 1;
+ *t++ = '+';
+ }
+ *t++ = ume_M[(w >> 12) & 0x3F];
+ *t++ = ume_M[(w >> 6) & 0x3F];
+ *t++ = ume_M[w & 0x3F];
+ }
+ f += c;
+ }
+ if (s)
+ *t++ = '-';
+ *fn -= (n = (char*)f - (*fb));
+ *fb = (char*)f;
+ *tn -= (char*)t - (*tb);
+ *tb = (char*)t;
+ RETURN(e, n, fn);
+}
+
+/*
+ * convert ucs-2 to bin with no byte swap
+ */
+
+static size_t
+ucs2bin(_ast_iconv_t cd, char** fb, size_t* fn, char** tb, size_t* tn)
+{
+ register unsigned char* f;
+ register unsigned char* fe;
+ register unsigned char* t;
+ register unsigned char* te;
+ register int w;
+ size_t n;
+ int e;
+
+ e = 0;
+ f = (unsigned char*)(*fb);
+ fe = f + (*fn);
+ t = (unsigned char*)(*tb);
+ te = t + (*tn);
+ while (f < (fe - 1) && t < te)
+ {
+ w = *f++;
+ w = (w << 8) | *f++;
+ if (!(w & ~0xFF))
+ *t++ = w;
+ else if (t >= (te - 1))
+ {
+ f -= 2;
+ e = E2BIG;
+ break;
+ }
+ else
+ {
+ *t++ = (w >> 8) & 0xFF;
+ *t++ = w & 0xFF;
+ }
+ }
+ *fn -= (char*)f - (*fb);
+ *fb = (char*)f;
+ *tn -= (n = (char*)t - (*tb));
+ *tb = (char*)t;
+ RETURN(e, n, fn);
+}
+
+/*
+ * convert bin to ucs-2 with no byte swap
+ */
+
+static size_t
+bin2ucs(_ast_iconv_t cd, char** fb, size_t* fn, char** tb, size_t* tn)
+{
+ register unsigned char* f;
+ register unsigned char* fe;
+ register unsigned char* t;
+ register unsigned char* te;
+ register int c;
+ wchar_t w;
+ size_t n;
+ int e;
+
+ e = 0;
+ f = (unsigned char*)(*fb);
+ fe = f + (*fn);
+ t = (unsigned char*)(*tb);
+ te = t + (*tn);
+ while (f < fe && t < (te - 1))
+ {
+ if (!mbwide())
+ {
+ c = 1;
+ w = *f;
+ }
+ if ((c = (*_ast_info.mb_towc)(&w, (char*)f, fe - f)) < 0)
+ {
+ e = EINVAL;
+ break;
+ }
+ else if (!c)
+ c = 1;
+ *t++ = (w >> 8) & 0xFF;
+ *t++ = w & 0xFF;
+ f += c;
+ }
+ *fn -= (n = (char*)f - (*fb));
+ *fb = (char*)f;
+ *tn -= (char*)t - (*tb);
+ *tb = (char*)t;
+ RETURN(e, n, fn);
+}
+
+/*
+ * convert ucs-2 to bin with byte swap
+ */
+
+static size_t
+scu2bin(_ast_iconv_t cd, char** fb, size_t* fn, char** tb, size_t* tn)
+{
+ register unsigned char* f;
+ register unsigned char* fe;
+ register unsigned char* t;
+ register unsigned char* te;
+ register int w;
+ size_t n;
+ int e;
+
+ e = 0;
+ f = (unsigned char*)(*fb);
+ fe = f + (*fn);
+ t = (unsigned char*)(*tb);
+ te = t + (*tn);
+ while (f < (fe - 1) && t < te)
+ {
+ w = *f++;
+ w = w | (*f++ << 8);
+ if (!(w & ~0xFF))
+ *t++ = w;
+ else if (t >= (te - 1))
+ {
+ f -= 2;
+ e = E2BIG;
+ break;
+ }
+ else
+ {
+ *t++ = (w >> 8) & 0xFF;
+ *t++ = w & 0xFF;
+ }
+ }
+ *fn -= (char*)f - (*fb);
+ *fb = (char*)f;
+ *tn -= (n = (char*)t - (*tb));
+ *tb = (char*)t;
+ RETURN(e, n, fn);
+}
+
+/*
+ * convert bin to ucs-2 with byte swap
+ */
+
+static size_t
+bin2scu(_ast_iconv_t cd, char** fb, size_t* fn, char** tb, size_t* tn)
+{
+ register unsigned char* f;
+ register unsigned char* fe;
+ register unsigned char* t;
+ register unsigned char* te;
+ register int c;
+ wchar_t w;
+ size_t n;
+ int e;
+
+ e = 0;
+ f = (unsigned char*)(*fb);
+ fe = f + (*fn);
+ t = (unsigned char*)(*tb);
+ te = t + (*tn);
+ while (f < fe && t < (te - 1))
+ {
+ if (!mbwide())
+ {
+ c = 1;
+ w = *f;
+ }
+ else if ((c = (*_ast_info.mb_towc)(&w, (char*)f, fe - f)) < 0)
+ {
+ e = EINVAL;
+ break;
+ }
+ else if (!c)
+ c = 1;
+ *t++ = w & 0xFF;
+ *t++ = (w >> 8) & 0xFF;
+ f += c;
+ }
+ *fn -= (n = (char*)f - (*fb));
+ *fb = (char*)f;
+ *tn -= (char*)t - (*tb);
+ *tb = (char*)t;
+ RETURN(e, n, fn);
+}
+
+/*
+ * open a character code conversion map from f to t
+ */
+
+_ast_iconv_t
+_ast_iconv_open(const char* t, const char* f)
+{
+ register Conv_t* cc;
+ int fc;
+ int tc;
+ int i;
+
+ char fr[64];
+ char to[64];
+
+#if DEBUG_TRACE
+error(DEBUG_TRACE, "AHA#%d _ast_iconv_open f=%s t=%s\n", __LINE__, f, t);
+#endif
+ if (!t || !*t || *t == '-' && !*(t + 1) || !strcasecmp(t, name_local) || !strcasecmp(t, name_native))
+ t = name_native;
+ if (!f || !*f || *f == '-' && !*(f + 1) || !strcasecmp(t, name_local) || !strcasecmp(f, name_native))
+ f = name_native;
+
+ /*
+ * the ast identify is always (iconv_t)(0)
+ */
+
+ if (t == f)
+ return (iconv_t)(0);
+ fc = _ast_iconv_name(f, fr, sizeof(fr));
+ tc = _ast_iconv_name(t, to, sizeof(to));
+#if DEBUG_TRACE
+error(DEBUG_TRACE, "AHA#%d _ast_iconv_open f=%s:%s:%d t=%s:%s:%d\n", __LINE__, f, fr, fc, t, to, tc);
+#endif
+ if (fc != CC_ICONV && fc == tc || streq(fr, to))
+ return (iconv_t)(0);
+
+ /*
+ * first check the free list
+ */
+
+ for (i = 0; i < elementsof(freelist); i++)
+ if ((cc = freelist[i]) && streq(to, cc->to.name) && streq(fr, cc->from.name))
+ {
+ freelist[i] = 0;
+#if _lib_iconv_open
+ /*
+ * reset the shift state if any
+ */
+
+ if (cc->cvt != (iconv_t)(-1))
+ iconv(cc->cvt, NiL, NiL, NiL, NiL);
+#endif
+ return cc;
+ }
+
+ /*
+ * allocate a new one
+ */
+
+ if (!(cc = newof(0, Conv_t, 1, strlen(to) + strlen(fr) + 2)))
+ return (iconv_t)(-1);
+ cc->to.name = (char*)(cc + 1);
+ cc->from.name = strcopy(cc->to.name, to) + 1;
+ strcpy(cc->from.name, fr);
+ cc->cvt = (iconv_t)(-1);
+
+ /*
+ * 8 bit maps are the easiest
+ */
+
+ if (fc >= 0 && tc >= 0)
+ cc->from.map = ccmap(fc, tc);
+#if _lib_iconv_open
+ else if ((cc->cvt = iconv_open(to, fr)) != (iconv_t)(-1))
+ cc->from.fun = (_ast_iconv_f)iconv;
+#endif
+#if _UWIN
+ else if ((cc->cvt = _win_iconv_open(cc, to, fr)) != (_ast_iconv_t)(-1))
+ cc->from.fun = (_ast_iconv_f)_win_iconv;
+#endif
+ else
+ {
+ switch (fc)
+ {
+ case CC_UTF:
+ cc->from.fun = utf2bin;
+ break;
+ case CC_UME:
+ cc->from.fun = ume2bin;
+ break;
+ case CC_UCS:
+ cc->from.fun = ucs2bin;
+ break;
+ case CC_SCU:
+ cc->from.fun = scu2bin;
+ break;
+ case CC_ASCII:
+ break;
+ default:
+ if (fc < 0)
+ goto nope;
+ cc->from.map = ccmap(fc, CC_ASCII);
+ break;
+ }
+ switch (tc)
+ {
+ case CC_UTF:
+ cc->to.fun = bin2utf;
+ break;
+ case CC_UME:
+ cc->to.fun = bin2ume;
+ break;
+ case CC_UCS:
+ cc->to.fun = bin2ucs;
+ break;
+ case CC_SCU:
+ cc->to.fun = bin2scu;
+ break;
+ case CC_ASCII:
+ break;
+ default:
+ if (tc < 0)
+ goto nope;
+ cc->to.map = ccmap(CC_ASCII, tc);
+ break;
+ }
+ }
+ return (iconv_t)cc;
+ nope:
+ return (iconv_t)(-1);
+}
+
+/*
+ * close a character code conversion map
+ */
+
+int
+_ast_iconv_close(_ast_iconv_t cd)
+{
+ Conv_t* cc;
+ Conv_t* oc;
+ int i;
+ int r = 0;
+
+ if (cd == (_ast_iconv_t)(-1))
+ return -1;
+ if (!(cc = (Conv_t*)cd))
+ return 0;
+
+ /*
+ * add to the free list
+ */
+
+ i = freeindex;
+ for (;;)
+ {
+ if (++ i >= elementsof(freelist))
+ i = 0;
+ if (!freelist[i])
+ break;
+ if (i == freeindex)
+ {
+ if (++ i >= elementsof(freelist))
+ i = 0;
+
+ /*
+ * close the oldest
+ */
+
+ if (oc = freelist[i])
+ {
+#if _lib_iconv_open
+ if (oc->cvt != (iconv_t)(-1))
+ r = iconv_close(oc->cvt);
+#endif
+ if (oc->buf)
+ free(oc->buf);
+ free(oc);
+ }
+ break;
+ }
+ }
+ freelist[freeindex = i] = cc;
+ return r;
+}
+
+/*
+ * copy *fb size *fn to *tb size *tn
+ * fb,fn tb,tn updated on return
+ */
+
+size_t
+_ast_iconv(_ast_iconv_t cd, char** fb, size_t* fn, char** tb, size_t* tn)
+{
+ Conv_t* cc = (Conv_t*)cd;
+ register unsigned char* f;
+ register unsigned char* t;
+ register unsigned char* e;
+ register const unsigned char* m;
+ register size_t n;
+ char* b;
+ char* tfb;
+ size_t tfn;
+ size_t i;
+
+ if (!fb || !*fb)
+ {
+ /* TODO: reset to the initial state */
+ if (!tb || !*tb)
+ return 0;
+ /* TODO: write the initial state shift sequence */
+ return 0;
+ }
+ n = *tn;
+ if (cc)
+ {
+ if (cc->from.fun)
+ {
+ if (cc->to.fun)
+ {
+ if (!cc->buf && !(cc->buf = oldof(0, char, cc->size = SF_BUFSIZE, 0)))
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+ b = cc->buf;
+ i = cc->size;
+ tfb = *fb;
+ tfn = *fn;
+ if ((*cc->from.fun)(cc->cvt, &tfb, &tfn, &b, &i) == (size_t)(-1))
+ return -1;
+ tfn = b - cc->buf;
+ tfb = cc->buf;
+ n = (*cc->to.fun)(cc->cvt, &tfb, &tfn, tb, tn);
+ i = tfb - cc->buf;
+ *fb += i;
+ *fn -= i;
+ return n;
+ }
+ if ((*cc->from.fun)(cc->cvt, fb, fn, tb, tn) == (size_t)(-1))
+ return -1;
+ n -= *tn;
+ if (m = cc->to.map)
+ {
+ e = (unsigned char*)(*tb);
+ for (t = e - n; t < e; t++)
+ *t = m[*t];
+ }
+ return n;
+ }
+ else if (cc->to.fun)
+ {
+ if (!(m = cc->from.map))
+ return (*cc->to.fun)(cc->cvt, fb, fn, tb, tn);
+ if (!cc->buf && !(cc->buf = oldof(0, char, cc->size = SF_BUFSIZE, 0)))
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+ if ((n = *fn) > cc->size)
+ n = cc->size;
+ f = (unsigned char*)(*fb);
+ e = f + n;
+ t = (unsigned char*)(b = cc->buf);
+ while (f < e)
+ *t++ = m[*f++];
+ n = (*cc->to.fun)(cc->cvt, &b, fn, tb, tn);
+ *fb += b - cc->buf;
+ return n;
+ }
+ }
+ if (n > *fn)
+ n = *fn;
+ if (cc && (m = cc->from.map))
+ {
+ f = (unsigned char*)(*fb);
+ e = f + n;
+ t = (unsigned char*)(*tb);
+ while (f < e)
+ *t++ = m[*f++];
+ }
+ else
+ memcpy(*tb, *fb, n);
+ *fb += n;
+ *fn -= n;
+ *tb += n;
+ *tn -= n;
+ return n;
+}
+
+/*
+ * write *fb size *fn to op
+ * fb,fn updated on return
+ * total bytes written to op returned
+ */
+
+ssize_t
+_ast_iconv_write(_ast_iconv_t cd, Sfio_t* op, char** fb, size_t* fn, size_t* e)
+{
+ char* tb;
+ char* ts;
+ size_t tn;
+ size_t r;
+
+ r = 0;
+ tn = 0;
+ while (*fn > 0)
+ {
+ if (!(tb = (char*)sfreserve(op, -(tn + 1), SF_WRITE|SF_LOCKR)))
+ return r ? r : -1;
+ ts = tb;
+ tn = sfvalue(op);
+#if DEBUG_TRACE
+error(DEBUG_TRACE, "AHA#%d iconv_write ts=%p tn=%d", __LINE__, ts, tn);
+ for (;;)
+#else
+ while (_ast_iconv(cd, fb, fn, &ts, &tn) == (size_t)(-1))
+#endif
+ {
+#if DEBUG_TRACE
+ ssize_t _r;
+error(DEBUG_TRACE, "AHA#%d iconv_write %d => %d `%-.*s'", __LINE__, *fn, tn, *fn, *fb);
+ _r = _ast_iconv(cd, fb, fn, &ts, &tn);
+error(DEBUG_TRACE, "AHA#%d iconv_write %d => %d [%d]", __LINE__, *fn, tn, _r);
+ if (_r != (size_t)(-1))
+ break;
+#endif
+ if (errno == E2BIG)
+ break;
+ if (e)
+ (*e)++;
+ if (!tn)
+ break;
+ *ts++ = *(*fb)++;
+ tn--;
+ (*fn)--;
+ }
+#if DEBUG_TRACE
+error(DEBUG_TRACE, "AHA#%d iconv_write %d", __LINE__, ts - tb);
+#endif
+
+ sfwrite(op, tb, ts - tb);
+ r += ts - tb;
+ }
+ return r;
+}
+
+/*
+ * move n bytes from ip to op
+ */
+
+ssize_t
+_ast_iconv_move(_ast_iconv_t cd, Sfio_t* ip, Sfio_t* op, size_t n, size_t* e)
+{
+ char* fb;
+ char* fs;
+ char* tb;
+ char* ts;
+ size_t fn;
+ size_t fo;
+ size_t tn;
+ size_t i;
+ ssize_t r = 0;
+ int locked;
+
+ fn = n;
+ for (;;)
+ {
+ if (fn != SF_UNBOUND)
+ fn = -((ssize_t)(fn & (((size_t)(~0))>>1)));
+ if (!(fb = (char*)sfreserve(ip, fn, locked = SF_LOCKR)) &&
+ !(fb = (char*)sfreserve(ip, fn, locked = 0)))
+ break;
+ fs = fb;
+ fn = fo = sfvalue(ip);
+ if (!(tb = (char*)sfreserve(op, SF_UNBOUND, SF_WRITE|SF_LOCKR)))
+ {
+ sfread(ip, fb, 0);
+ return r ? r : -1;
+ }
+ ts = tb;
+ tn = sfvalue(op);
+ while (_ast_iconv(cd, &fs, &fn, &ts, &tn) != (size_t)(-1) && fn > 0)
+ {
+ if (tn > 0)
+ {
+ *ts++ = '_';
+ tn--;
+ }
+ if (e)
+ (*e)++;
+ fs++;
+ fn--;
+ }
+ sfwrite(op, tb, ts - tb);
+ r += ts - tb;
+ if (locked)
+ sfread(ip, fb, fs - fb);
+ else
+ for (i = fn; --i >= (fs - fb);)
+ sfungetc(ip, fb[i]);
+ if (n != SF_UNBOUND)
+ {
+ if (n <= (fs - fb))
+ break;
+ n -= fs - fb;
+ }
+ if (fn == fo)
+ fn++;
+ }
+ return r;
+}
+
+/*
+ * iconv_list_t iterator
+ * call with arg 0 to start
+ * prev return value is current arg
+ */
+
+_ast_iconv_list_t*
+_ast_iconv_list(_ast_iconv_list_t* cp)
+{
+#if _UWIN
+ struct dirent* ent;
+
+ if (!cp)
+ {
+ if (!(cp = newof(0, _ast_iconv_list_t, 1, 0)))
+ return ccmaplist(NiL);
+ if (!(cp->data = opendir(_win_maps)))
+ {
+ free(cp);
+ return ccmaplist(NiL);
+ }
+ }
+ if (cp->data)
+ {
+ if (ent = readdir((DIR*)cp->data))
+ {
+ cp->name = cp->match = cp->desc = (const char*)ent->d_name;
+ return cp;
+ }
+ closedir((DIR*)cp->data);
+ free(cp);
+ return ccmaplist(NiL);
+ }
+#else
+ if (!cp)
+ return ccmaplist(NiL);
+#endif
+ if (cp->ccode >= 0)
+ return (cp = ccmaplist(cp)) ? cp : (_ast_iconv_list_t*)codes;
+ return (++cp)->name ? cp : (_ast_iconv_list_t*)0;
+}
diff --git a/usr/src/lib/libast/common/comp/killpg.c b/usr/src/lib/libast/common/comp/killpg.c
new file mode 100644
index 0000000000..e3638bbcb8
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/killpg.c
@@ -0,0 +1,40 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_killpg
+
+NoN(killpg)
+
+#else
+
+#include <sig.h>
+
+int
+killpg(pid_t g, int s)
+{
+ return(kill(-g, s));
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/libgen.h b/usr/src/lib/libast/common/comp/libgen.h
new file mode 100644
index 0000000000..2a908b129a
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/libgen.h
@@ -0,0 +1,52 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * libgen interface definitions
+ */
+
+#ifndef _LIBGEN_H
+#define _LIBGEN_H
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#define extern extern __IMPORT__
+#endif
+
+extern char* __loc1;
+
+#undef extern
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern char* regcmp(const char*, ...);
+extern char* regex(const char*, const char*, ...);
+extern char* basename(char*);
+extern char* dirname(char*);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/link.c b/usr/src/lib/libast/common/comp/link.c
new file mode 100644
index 0000000000..5b4e66c41b
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/link.c
@@ -0,0 +1,47 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_link
+
+NoN(link)
+
+#else
+
+#include <error.h>
+
+#ifndef ENOSYS
+#define ENOSYS EINVAL
+#endif
+
+int
+link(const char* from, const char* to)
+{
+ NoP(from);
+ NoP(to);
+ errno = ENOSYS;
+ return -1;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/localeconv.c b/usr/src/lib/libast/common/comp/localeconv.c
new file mode 100644
index 0000000000..3516d7096e
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/localeconv.c
@@ -0,0 +1,96 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * localeconv() intercept
+ */
+
+#include "lclib.h"
+
+#undef localeconv
+
+static char null[] = "";
+
+static struct lconv debug_lconv =
+{
+ ",",
+ ".",
+ &null[0],
+ &null[0],
+ &null[0],
+ &null[0],
+ &null[0],
+ &null[0],
+ &null[0],
+ &null[0],
+ CHAR_MAX,
+ CHAR_MAX,
+ CHAR_MAX,
+ CHAR_MAX,
+ CHAR_MAX,
+ CHAR_MAX,
+ CHAR_MAX,
+ CHAR_MAX,
+};
+
+#if !_lib_localeconv
+
+static struct lconv default_lconv =
+{
+ ".",
+ &null[0],
+ &null[0],
+ &null[0],
+ &null[0],
+ &null[0],
+ &null[0],
+ &null[0],
+ &null[0],
+ &null[0],
+ CHAR_MAX,
+ CHAR_MAX,
+ CHAR_MAX,
+ CHAR_MAX,
+ CHAR_MAX,
+ CHAR_MAX,
+ CHAR_MAX,
+ CHAR_MAX,
+};
+
+struct lconv*
+localeconv(void)
+{
+ return &default_lconv;
+}
+
+#endif
+
+/*
+ * localeconv() intercept
+ */
+
+struct lconv*
+_ast_localeconv(void)
+{
+ return ((locales[AST_LC_MONETARY]->flags | locales[AST_LC_NUMERIC]->flags) & LC_debug) ? &debug_lconv : localeconv();
+}
diff --git a/usr/src/lib/libast/common/comp/lstat.c b/usr/src/lib/libast/common/comp/lstat.c
new file mode 100644
index 0000000000..32cd1d4ce4
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/lstat.c
@@ -0,0 +1,39 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+#include <ls.h>
+
+#if _lib_lstat
+
+NoN(lstat)
+
+#else
+
+int
+lstat(const char* path, struct stat* st)
+{
+ return(stat(path, st));
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/memccpy.c b/usr/src/lib/libast/common/comp/memccpy.c
new file mode 100644
index 0000000000..17967374b0
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/memccpy.c
@@ -0,0 +1,51 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_memccpy && !_UWIN
+
+NoN(memccpy)
+
+#else
+
+/*
+ * Copy s2 to s1, stopping if character c is copied. Copy no more than n bytes.
+ * Return a pointer to the byte after character c in the copy,
+ * or 0 if c is not found in the first n bytes.
+ */
+
+void*
+memccpy(void* as1, const void* as2, register int c, size_t n)
+{
+ register char* s1 = (char*)as1;
+ register const char* s2 = (char*)as2;
+ register const char* ep = s2 + n;
+
+ while (s2 < ep)
+ if ((*s1++ = *s2++) == c)
+ return(s1);
+ return(0);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/memchr.c b/usr/src/lib/libast/common/comp/memchr.c
new file mode 100644
index 0000000000..2baf827ca2
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/memchr.c
@@ -0,0 +1,49 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_memchr
+
+NoN(memchr)
+
+#else
+
+/*
+ * Return the ptr in sp at which the character c appears;
+ * 0 if not found in n chars; don't stop at \0.
+ */
+
+void*
+memchr(const void* asp, register int c, size_t n)
+{
+ register const char* sp = (char*)asp;
+ register const char* ep = sp + n;
+
+ while (sp < ep)
+ if (*sp++ == c)
+ return(--sp);
+ return(0);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/memcmp.c b/usr/src/lib/libast/common/comp/memcmp.c
new file mode 100644
index 0000000000..89c713422b
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/memcmp.c
@@ -0,0 +1,45 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_memcmp
+
+NoN(memcmp)
+
+#else
+
+int
+memcmp(const void* ab1, const void* ab2, size_t n)
+{
+ register const unsigned char* b1 = (const unsigned char*)ab1;
+ register const unsigned char* b2 = (const unsigned char*)ab2;
+ register const unsigned char* e = b1 + n;
+
+ while (b1 < e)
+ if (*b1++ != *b2++)
+ return(*--b1 - *--b2);
+ return(0);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/memcpy.c b/usr/src/lib/libast/common/comp/memcpy.c
new file mode 100644
index 0000000000..d4151e64bc
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/memcpy.c
@@ -0,0 +1,60 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_memcpy
+
+NoN(memcpy)
+
+#else
+
+#undef memcpy
+
+#if _lib_bcopy
+
+extern void bcopy(void*, void*, size_t);
+
+void*
+memcpy(void* s1, void* s2, size_t n)
+{
+ bcopy(s2, s1, n);
+ return(s1);
+}
+
+#else
+
+void*
+memcpy(void* as1, const void* as2, register size_t n)
+{
+ register char* s1 = (char*)as1;
+ register const char* s2 = (const char*)as2;
+
+ while (n-- > 0)
+ *s1++ = *s2++;
+ return(as1);
+}
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/memmove.c b/usr/src/lib/libast/common/comp/memmove.c
new file mode 100644
index 0000000000..3f1ec8f8d7
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/memmove.c
@@ -0,0 +1,53 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_memmove
+
+NoN(memmove)
+
+#else
+
+void*
+memmove(void* to, const void* from, register size_t n)
+{
+ register char* out = (char*)to;
+ register char* in = (char*)from;
+
+ if (n <= 0) /* works if size_t is signed or not */
+ ;
+ else if (in + n <= out || out + n <= in)
+ return(memcpy(to, from, n)); /* hope it's fast*/
+ else if (out < in)
+ do *out++ = *in++; while (--n > 0);
+ else
+ {
+ out += n;
+ in += n;
+ do *--out = *--in; while(--n > 0);
+ }
+ return(to);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/memset.c b/usr/src/lib/libast/common/comp/memset.c
new file mode 100644
index 0000000000..545295ad9d
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/memset.c
@@ -0,0 +1,42 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_memset
+
+NoN(memset)
+
+#else
+
+void*
+memset(void* asp, register int c, register size_t n)
+{
+ register char* sp = (char*)asp;
+
+ while (n-- > 0)
+ *sp++ = c;
+ return(asp);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/mkdir.c b/usr/src/lib/libast/common/comp/mkdir.c
new file mode 100644
index 0000000000..19c72f8aea
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/mkdir.c
@@ -0,0 +1,62 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_mkdir
+
+NoN(mkdir)
+
+#else
+
+#include <ls.h>
+#include <wait.h>
+#include <error.h>
+
+int
+mkdir(const char* path, mode_t mode)
+{
+ register int n;
+ char* av[3];
+
+ static char* cmd[] = { "/bin/mkdir", "/usr/5bin/mkdir", 0 };
+
+
+ n = errno;
+ if (!access(path, F_OK))
+ {
+ errno = EEXIST;
+ return(-1);
+ }
+ if (errno != ENOENT) return(-1);
+ errno = n;
+ av[0] = "mkdir";
+ av[1] = path;
+ av[2] = 0;
+ for (n = 0; n < elementsof(cmd); n++)
+ if (procclose(procopen(cmd[n], av, NiL, NiL, 0)) != -1)
+ break;
+ return(chmod(path, mode));
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/mkfifo.c b/usr/src/lib/libast/common/comp/mkfifo.c
new file mode 100644
index 0000000000..005f162d8b
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/mkfifo.c
@@ -0,0 +1,50 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_mkfifo
+
+NoN(mkfifo)
+
+#else
+
+#include <ls.h>
+#include <error.h>
+
+#ifndef ENOSYS
+#define ENOSYS EINVAL
+#endif
+
+int
+mkfifo(const char* path, mode_t mode)
+{
+#ifdef S_IFIFO
+ return mknod(path, S_IFIFO|(mode & ~S_IFMT), 0);
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/mknod.c b/usr/src/lib/libast/common/comp/mknod.c
new file mode 100644
index 0000000000..624e32fcde
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/mknod.c
@@ -0,0 +1,50 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+#include <ls.h>
+
+#if _lib_mknod
+
+NoN(mknod)
+
+#else
+
+#include <error.h>
+
+#ifndef ENOSYS
+#define ENOSYS EINVAL
+#endif
+
+int
+mknod(const char* path, mode_t mode, dev_t dev)
+{
+ if (S_ISFIFO(mode))
+ return mkfifo(path, mode);
+ if (S_ISDIR(mode))
+ return mkdir(path, mode);
+ errno = ENOSYS;
+ return -1;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/mktemp.c b/usr/src/lib/libast/common/comp/mktemp.c
new file mode 100644
index 0000000000..91ced5ba3e
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/mktemp.c
@@ -0,0 +1,85 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * mktemp,mkstemp implementation
+ */
+
+#define mktemp ______mktemp
+#define mkstemp ______mkstemp
+
+#include <ast.h>
+#include <stdio.h>
+
+#undef mktemp
+#undef mkstemp
+
+#undef _def_map_ast
+#include <ast_map.h>
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+static char*
+temp(char* buf, int* fdp)
+{
+ char* s;
+ char* d;
+ int n;
+ size_t len;
+
+ len = strlen(buf);
+ if (s = strrchr(buf, '/'))
+ {
+ *s++ = 0;
+ d = buf;
+ }
+ else
+ {
+ s = buf;
+ d = "";
+ }
+ if ((n = strlen(s)) < 6 || strcmp(s + n - 6, "XXXXXX"))
+ *buf = 0;
+ else
+ {
+ *(s + n - 6) = 0;
+ if (!pathtemp(buf, len, d, s, fdp))
+ *buf = 0;
+ }
+ return buf;
+}
+
+extern char*
+mktemp(char* buf)
+{
+ return temp(buf, NiL);
+}
+
+extern int
+mkstemp(char* buf)
+{
+ int fd;
+
+ return *temp(buf, &fd) ? fd : -1;
+}
diff --git a/usr/src/lib/libast/common/comp/mktime.c b/usr/src/lib/libast/common/comp/mktime.c
new file mode 100644
index 0000000000..d11b0869fa
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/mktime.c
@@ -0,0 +1,77 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * mktime implementation
+ */
+
+#define mktime ______mktime
+
+#include <ast.h>
+#include <tm.h>
+
+#undef mktime
+
+#undef _def_map_ast
+#include <ast_map.h>
+
+#undef _lib_mktime /* we can pass X/Open */
+
+#if _lib_mktime
+
+NoN(mktime)
+
+#else
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern time_t
+mktime(struct tm* ts)
+{
+ time_t t;
+ Tm_t tm;
+
+ tm.tm_sec = ts->tm_sec;
+ tm.tm_min = ts->tm_min;
+ tm.tm_hour = ts->tm_hour;
+ tm.tm_mday = ts->tm_mday;
+ tm.tm_mon = ts->tm_mon;
+ tm.tm_year = ts->tm_year;
+ tm.tm_wday = ts->tm_wday;
+ tm.tm_yday = ts->tm_yday;
+ tm.tm_isdst = ts->tm_isdst;
+ t = tmtime(&tm, TM_LOCALZONE);
+ ts->tm_sec = tm.tm_sec;
+ ts->tm_min = tm.tm_min;
+ ts->tm_hour = tm.tm_hour;
+ ts->tm_mday = tm.tm_mday;
+ ts->tm_mon = tm.tm_mon;
+ ts->tm_year = tm.tm_year;
+ ts->tm_wday = tm.tm_wday;
+ ts->tm_yday = tm.tm_yday;
+ ts->tm_isdst = tm.tm_isdst;
+ return t;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/mount.c b/usr/src/lib/libast/common/comp/mount.c
new file mode 100644
index 0000000000..f766bd71c8
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/mount.c
@@ -0,0 +1,49 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_mount
+
+NoN(mount)
+
+#else
+
+#include <error.h>
+
+#ifndef ENOSYS
+#define ENOSYS EINVAL
+#endif
+
+int
+mount(const char* a, char* b, int c, void* d)
+{
+ NoP(a);
+ NoP(b);
+ NoP(c);
+ NoP(d);
+ errno = ENOSYS;
+ return -1;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/nftw.c b/usr/src/lib/libast/common/comp/nftw.c
new file mode 100644
index 0000000000..f0706f2f94
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/nftw.c
@@ -0,0 +1,61 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * nftw implementation
+ */
+
+#include <ast.h>
+#include <ftw.h>
+
+static int nftw_flags;
+static int (*nftw_userf)(const char*, const struct stat*, int, struct FTW*);
+
+static int
+nftw_user(Ftw_t* ftw)
+{
+ register int n = ftw->info;
+ struct FTW nftw;
+ struct stat st;
+
+ if (n & (FTW_C|FTW_NX))
+ n = FTW_DNR;
+ else if ((n & FTW_SL) && (!(nftw_flags & FTW_PHYSICAL) || stat(ftw->path, &st)))
+ n = FTW_SLN;
+ nftw.base = ftw->pathlen - ftw->namelen;
+ nftw.level = ftw->level;
+ nftw.quit = 0;
+ n = (*nftw_userf)(ftw->path, &ftw->statb, n, &nftw);
+ ftw->status = nftw.quit;
+ return n;
+}
+
+int
+nftw(const char* path, int(*userf)(const char*, const struct stat*, int, struct FTW*), int depth, int flags)
+{
+ NoP(depth);
+ nftw_userf = userf;
+ if (flags & FTW_CHDIR) flags &= ~FTW_DOT;
+ else flags |= FTW_DOT;
+ nftw_flags = flags;
+ return ftwalk(path, nftw_user, flags, NiL);
+}
diff --git a/usr/src/lib/libast/common/comp/omitted.c b/usr/src/lib/libast/common/comp/omitted.c
new file mode 100644
index 0000000000..10a20ba533
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/omitted.c
@@ -0,0 +1,1069 @@
+#pragma prototyped noticed
+
+/*
+ * workarounds to bring the native interface close to posix and x/open
+ */
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide utime utimes
+#else
+#define utime ______utime
+#define utimes ______utimes
+#endif
+
+#include <ast.h>
+#include <error.h>
+#include <tm.h>
+
+#include "FEATURE/omitted"
+
+#undef OMITTED
+
+#if _win32_botch
+
+#define OMITTED 1
+
+#include <ls.h>
+#include <utime.h>
+
+#if __CYGWIN__
+#include <ast_windows.h>
+#if _win32_botch_execve || _lib_spawn_mode
+#define CONVERT 1
+#endif
+#endif
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide utime utimes
+#else
+#undef utime
+#undef utimes
+#endif
+
+#ifndef MAX_PATH
+#define MAX_PATH PATH_MAX
+#endif
+
+/*
+ * these workarounds assume each system call foo() has a _foo() entry
+ * which is true for __CYGWIN__ and __EMX__ (both gnu based)
+ *
+ * the workarounds handle:
+ *
+ * (1) .exe suffix inconsistencies
+ * (2) /bin/sh reference in execve() and spawnve()
+ * (3) bogus getpagesize() return values
+ * (4) a fork() bug that screws up shell fork()+script
+ *
+ * NOTE: Not all workarounds can be handled by unix syscall intercepts.
+ * In particular, { ksh nmake } have workarounds for case-ignorant
+ * filesystems and { libast } has workarounds for win32 locale info.
+ */
+
+#undef _pathconf
+#undef pathconf
+#undef stat
+
+extern int _access(const char*, int);
+extern unsigned int _alarm(unsigned int);
+extern int _chmod(const char*, mode_t);
+extern int _close(int);
+extern pid_t _execve(const char*, char* const*, char* const*);
+extern int _link(const char*, const char*);
+extern int _open(const char*, int, ...);
+extern long _pathconf(const char*, int);
+extern ssize_t _read(int, void*, size_t);
+extern int _rename(const char*, const char*);
+extern pid_t _spawnve(int, const char*, char* const*, char* const*);
+extern int _stat(const char*, struct stat*);
+extern int _unlink(const char*);
+extern int _utime(const char*, const struct utimbuf*);
+extern int _utimes(const char*, const struct timeval*);
+extern ssize_t _write(int, const void*, size_t);
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+static char*
+suffix(register const char* path)
+{
+ register const char* s = path + strlen(path);
+ register int c;
+
+ while (s > path)
+ if ((c = *--s) == '.')
+ return (char*)s + 1;
+ else if (c == '/' || c == '\\')
+ break;
+ return 0;
+}
+
+static int
+execrate(const char* path, char* buf, int size, int physical)
+{
+ char* s;
+ int n;
+ int oerrno;
+
+ if (suffix(path))
+ return 0;
+ oerrno = errno;
+ if (physical || strlen(path) >= size || !(s = pathcanon(strcpy(buf, path), PATH_PHYSICAL|PATH_DOTDOT|PATH_EXISTS)))
+ snprintf(buf, size, "%s.exe", path);
+ else if (!suffix(buf) && ((buf + size) - s) >= 4)
+ strcpy(s, ".exe");
+ errno = oerrno;
+ return 1;
+}
+
+/*
+ * return 0 if path is magic, -1 otherwise
+ * ux!=0 set to 1 if path is unix executable
+ * ux!=0 also retains errno for -1 return
+ */
+
+static int
+magic(const char* path, int* ux)
+{
+ int fd;
+ int r;
+ int n;
+ int m;
+ int oerrno;
+#if CONVERT
+ unsigned char buf[512];
+#else
+ unsigned char buf[2];
+#endif
+
+ oerrno = errno;
+ if ((fd = _open(path, O_RDONLY, 0)) >= 0)
+ {
+#if CONVERT
+ if (ux)
+ n = sizeof(buf);
+ else
+#endif
+ n = 2;
+ r = (m = _read(fd, buf, n)) >= 2 && (buf[1] == 0x5a && (buf[0] == 0x4c || buf[0] == 0x4d) || ux && buf[0] == '#' && buf[1] == '!' && (*ux = 1) && !(ux = 0)) ? 0 : -1;
+ close(fd);
+ if (ux)
+ {
+ if (r)
+ oerrno = ENOEXEC;
+ else if (m > 61 && (n = buf[60] | (buf[61]<<8) + 92) < (m - 1))
+ *ux = (buf[n] | (buf[n+1]<<8)) == 3;
+ else
+ *ux = 0;
+ }
+ }
+ else if (!ux)
+ r = -1;
+ else if (errno == ENOENT)
+ {
+ oerrno = errno;
+ r = -1;
+ }
+ else
+ {
+ r = 0;
+ *ux = 0;
+ }
+ errno = oerrno;
+ return r;
+}
+
+#if _win32_botch_access
+
+extern int
+access(const char* path, int op)
+{
+ int r;
+ int oerrno;
+ char buf[PATH_MAX];
+
+ oerrno = errno;
+ if ((r = _access(path, op)) && errno == ENOENT && execrate(path, buf, sizeof(buf), 0))
+ {
+ errno = oerrno;
+ r = _access(buf, op);
+ }
+ return r;
+}
+
+#endif
+
+#if _win32_botch_alarm
+
+extern unsigned int
+alarm(unsigned int s)
+{
+ unsigned int n;
+ unsigned int r;
+
+ static unsigned int a;
+
+ n = (unsigned int)time(NiL);
+ if (a <= n)
+ r = 0;
+ else
+ r = a - n;
+ a = n + s - 1;
+ (void)_alarm(s);
+ return r;
+}
+
+#endif
+
+#if _win32_botch_chmod
+
+extern int
+chmod(const char* path, mode_t mode)
+{
+ int r;
+ int oerrno;
+ char buf[PATH_MAX];
+
+ if ((r = _chmod(path, mode)) && errno == ENOENT && execrate(path, buf, sizeof(buf), 0))
+ {
+ errno = oerrno;
+ return _chmod(buf, mode);
+ }
+ if (!(r = _chmod(path, mode)) &&
+ (mode & (S_IXUSR|S_IXGRP|S_IXOTH)) &&
+ !suffix(path) &&
+ (strlen(path) + 4) < sizeof(buf))
+ {
+ oerrno = errno;
+ if (!magic(path, NiL))
+ {
+ snprintf(buf, sizeof(buf), "%s.exe", path);
+ _rename(path, buf);
+ }
+ errno = oerrno;
+ }
+ return r;
+}
+
+#endif
+
+#if _win32_botch_execve || _lib_spawn_mode
+
+#if _lib_spawn_mode
+
+/*
+ * can anyone get const prototype args straight?
+ */
+
+#define execve ______execve
+#define spawnve ______spawnve
+
+#include <process.h>
+
+#undef execve
+#undef spawnve
+
+#endif
+
+#if CONVERT
+
+/*
+ * this intercept converts dos env vars to unix
+ * we'd rather intercept main but can't twist cc to do it
+ * getuid() gets ksh to do the right thing and
+ * that's our main concern
+ *
+ * DOSPATHVARS='a b c' convert { a b c }
+ */
+
+extern uid_t _getuid(void);
+
+static int convertinit;
+
+/*
+ * convertvars[0] names the list of env var names
+ * convertvars[i] are not converted
+ */
+
+static const char* convertvars[] = { "DOSPATHVARS", "PATH" };
+
+static int
+convert(register const char* d, const char* s)
+{
+ register const char* t;
+ register const char* v;
+ int i;
+
+ for (i = 0; i < elementsof(convertvars); i++)
+ {
+ for (v = convertvars[i], t = s; *t && *t == *v; t++, v++);
+ if (*t == '=' && *v == 0)
+ return 0;
+ }
+ for (;;)
+ {
+ while (*d == ' ' || *d == '\t')
+ d++;
+ if (!*d)
+ break;
+ for (t = s; *t && *t == *d; d++, t++);
+ if (*t == '=' && (*d == ' ' || *d == '\t' || *d == 0))
+ return t - s + 1;
+ while (*d && *d != ' ' && *d != '\t')
+ d++;
+ }
+ return 0;
+}
+
+uid_t
+getuid(void)
+{
+ register char* d;
+ register char* s;
+ register char* t;
+ register char** e;
+ int n;
+ int m;
+
+ if (!convertinit++ && (d = getenv(convertvars[0])))
+ for (e = environ; s = *e; e++)
+ if ((n = convert(d, s)) && (m = cygwin_win32_to_posix_path_list_buf_size(s + n)) > 0)
+ {
+ if (!(t = malloc(n + m + 1)))
+ break;
+ *e = t;
+ memcpy(t, s, n);
+ cygwin_win32_to_posix_path_list(s + n, t + n);
+ }
+ return _getuid();
+}
+
+#endif
+
+#ifndef _P_OVERLAY
+#define _P_OVERLAY (-1)
+#endif
+
+#define DEBUG 1
+
+static pid_t
+runve(int mode, const char* path, char* const* argv, char* const* envv)
+{
+ register char* s;
+ register char** p;
+ register char** v;
+
+ void* m1;
+ void* m2;
+ pid_t pid;
+ int oerrno;
+ int ux;
+ int n;
+#if defined(_P_DETACH) && defined(_P_NOWAIT)
+ int pgrp;
+#endif
+#if CONVERT
+ char* d;
+ char* t;
+ int m;
+#endif
+ struct stat st;
+ char buf[PATH_MAX];
+ char tmp[PATH_MAX];
+
+#if DEBUG
+ static int trace;
+#endif
+
+#if defined(_P_DETACH) && defined(_P_NOWAIT)
+ if (mode == _P_DETACH)
+ {
+ /*
+ * 2004-02-29 cygwin _P_DETACH is useless:
+ * spawn*() returns 0 instead of the spawned pid
+ * spawned { pgid sid } are the same as the parent
+ */
+
+ mode = _P_NOWAIT;
+ pgrp = 1;
+ }
+ else
+ pgrp = 0;
+#endif
+ if (!envv)
+ envv = (char* const*)environ;
+ m1 = m2 = 0;
+ oerrno = errno;
+#if DEBUG
+ if (!trace)
+ trace = (s = getenv("_AST_exec_trace")) ? *s : 'n';
+#endif
+ if (execrate(path, buf, sizeof(buf), 0))
+ {
+ if (!_stat(buf, &st))
+ path = (const char*)buf;
+ else
+ errno = oerrno;
+ }
+ if (path != (const char*)buf && _stat(path, &st))
+ return -1;
+ if (!S_ISREG(st.st_mode) || !(st.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)))
+ {
+ errno = EACCES;
+ return -1;
+ }
+ if (magic(path, &ux))
+ {
+#if _CYGWIN_fork_works
+ errno = ENOEXEC;
+ return -1;
+#else
+ ux = 1;
+ p = (char**)argv;
+ while (*p++);
+ if (!(v = (char**)malloc((p - (char**)argv + 2) * sizeof(char*))))
+ {
+ errno = EAGAIN;
+ return -1;
+ }
+ m1 = v;
+ p = v;
+ *p++ = (char*)path;
+ *p++ = (char*)path;
+ path = (const char*)pathshell();
+ if (*argv)
+ argv++;
+ while (*p++ = (char*)*argv++);
+ argv = (char* const*)v;
+#endif
+ }
+
+ /*
+ * the win32 dll search order is
+ * (1) the directory of path
+ * (2) .
+ * (3) /c/(WINNT|WINDOWS)/system32 /c/(WINNT|WINDOWS)
+ * (4) the directories on $PATH
+ * there are no cygwin dlls in (3), so if (1) and (2) fail
+ * to produce the required dlls its up to (4)
+ *
+ * the standard allows PATH to be anything once the path
+ * to an executable is determined; this code ensures that PATH
+ * contains /bin so that at least the cygwin dll, required
+ * by all cygwin executables, will be found
+ */
+
+ if (p = (char**)envv)
+ {
+ n = 1;
+ while (s = *p++)
+ if (strneq(s, "PATH=", 5))
+ {
+ s += 5;
+ do
+ {
+ s = pathcat(tmp, s, ':', NiL, "");
+ if (streq(tmp, "/usr/bin/") || streq(tmp, "/bin/"))
+ {
+ n = 0;
+ break;
+ }
+ } while (s);
+ if (n)
+ {
+ n = 0;
+ snprintf(tmp, sizeof(tmp), "%s:/bin", *(p - 1));
+ *(p - 1) = tmp;
+ }
+ break;
+ }
+ if (n)
+ {
+ n = p - (char**)envv + 1;
+ p = (char**)envv;
+ if (v = (char**)malloc(n * sizeof(char*)))
+ {
+ m2 = v;
+ envv = (char* const*)v;
+ *v++ = strcpy(tmp, "PATH=/bin");
+ while (*v++ = *p++);
+ }
+ }
+#if CONVERT
+ if (!ux && (d = getenv(convertvars[0])))
+ for (p = (char**)envv; s = *p; p++)
+ if ((n = convert(d, s)) && (m = cygwin_posix_to_win32_path_list_buf_size(s + n)) > 0)
+ {
+ if (!(t = malloc(n + m + 1)))
+ break;
+ *p = t;
+ memcpy(t, s, n);
+ cygwin_posix_to_win32_path_list(s + n, t + n);
+ }
+#endif
+ }
+
+#if DEBUG
+ if (trace == 'a' || trace == 'e')
+ {
+ sfprintf(sfstderr, "%s %s [", mode == _P_OVERLAY ? "_execve" : "_spawnve", path);
+ for (n = 0; argv[n]; n++)
+ sfprintf(sfstderr, " '%s'", argv[n]);
+ if (trace == 'e')
+ {
+ sfprintf(sfstderr, " ] [");
+ for (n = 0; envv[n]; n++)
+ sfprintf(sfstderr, " '%s'", envv[n]);
+ }
+ sfprintf(sfstderr, " ]\n");
+ sfsync(sfstderr);
+ }
+#endif
+#if _lib_spawn_mode
+ if (mode != _P_OVERLAY)
+ {
+ pid = _spawnve(mode, path, argv, envv);
+#if defined(_P_DETACH) && defined(_P_NOWAIT)
+ if (pid > 0 && pgrp)
+ setpgid(pid, 0);
+#endif
+ }
+ else
+#endif
+ {
+#if defined(_P_DETACH) && defined(_P_NOWAIT)
+ if (pgrp)
+ setpgid(0, 0);
+#endif
+ pid = _execve(path, argv, envv);
+ }
+ if (m1)
+ free(m1);
+ if (m2)
+ free(m2);
+ return pid;
+}
+
+#if _win32_botch_execve
+
+extern pid_t
+execve(const char* path, char* const* argv, char* const* envv)
+{
+ return runve(_P_OVERLAY, path, argv, envv);
+}
+
+#endif
+
+#if _lib_spawn_mode
+
+extern pid_t
+spawnve(int mode, const char* path, char* const* argv, char* const* envv)
+{
+ return runve(mode, path, argv, envv);
+}
+
+#endif
+
+#endif
+
+#if _win32_botch_getpagesize
+
+extern size_t
+getpagesize(void)
+{
+ return 64 * 1024;
+}
+
+#endif
+
+#if _win32_botch_link
+
+extern int
+link(const char* fp, const char* tp)
+{
+ int r;
+ int oerrno;
+ char fb[PATH_MAX];
+ char tb[PATH_MAX];
+
+ oerrno = errno;
+ if ((r = _link(fp, tp)) && errno == ENOENT && execrate(fp, fb, sizeof(fb), 1))
+ {
+ if (execrate(tp, tb, sizeof(tb), 1))
+ tp = tb;
+ errno = oerrno;
+ r = _link(fb, tp);
+ }
+ return r;
+}
+
+#endif
+
+#if _win32_botch_open || _win32_botch_copy
+
+#if _win32_botch_copy
+
+/*
+ * this should intercept the important cases
+ * dup*() and exec*() fd's will not be intercepted
+ */
+
+typedef struct Exe_test_s
+{
+ int test;
+ ino_t ino;
+ char path[PATH_MAX];
+} Exe_test_t;
+
+static Exe_test_t* exe[16];
+
+extern int
+close(int fd)
+{
+ int r;
+ int oerrno;
+ struct stat st;
+ char buf[PATH_MAX];
+
+ if (fd >= 0 && fd < elementsof(exe) && exe[fd])
+ {
+ r = exe[fd]->test;
+ exe[fd]->test = 0;
+ if (r > 0 && !fstat(fd, &st) && st.st_ino == exe[fd]->ino)
+ {
+ if (r = _close(fd))
+ return r;
+ oerrno = errno;
+ if (!stat(exe[fd]->path, &st) && st.st_ino == exe[fd]->ino)
+ {
+ snprintf(buf, sizeof(buf), "%s.exe", exe[fd]->path);
+ _rename(exe[fd]->path, buf);
+ }
+ errno = oerrno;
+ return 0;
+ }
+ }
+ return _close(fd);
+}
+
+extern ssize_t
+write(int fd, const void* buf, size_t n)
+{
+ if (fd >= 0 && fd < elementsof(exe) && exe[fd] && exe[fd]->test < 0)
+ exe[fd]->test = n >= 2 && ((unsigned char*)buf)[1] == 0x5a && (((unsigned char*)buf)[0] == 0x4c || ((unsigned char*)buf)[0] == 0x4d) && !lseek(fd, (off_t)0, SEEK_CUR);
+ return _write(fd, buf, n);
+}
+
+#endif
+
+extern int
+open(const char* path, int flags, ...)
+{
+ int fd;
+ int mode;
+ int oerrno;
+ char buf[PATH_MAX];
+#if _win32_botch_copy
+ struct stat st;
+#endif
+ va_list ap;
+
+ va_start(ap, flags);
+ mode = (flags & O_CREAT) ? va_arg(ap, int) : 0;
+ oerrno = errno;
+ fd = _open(path, flags, mode);
+#if _win32_botch_open
+ if (fd < 0 && errno == ENOENT && execrate(path, buf, sizeof(buf), 0))
+ {
+ errno = oerrno;
+ fd = _open(buf, flags, mode);
+ }
+#endif
+#if _win32_botch_copy
+ if (fd >= 0 && fd < elementsof(exe) && strlen(path) < PATH_MAX &&
+ (flags & (O_CREAT|O_TRUNC)) == (O_CREAT|O_TRUNC) && (mode & 0111))
+ {
+ if (!suffix(path) && !fstat(fd, &st) && (exe[fd] || (exe[fd] = (Exe_test_t*)malloc(sizeof(Exe_test_t)))))
+ {
+ exe[fd]->test = -1;
+ exe[fd]->ino = st.st_ino;
+ strcpy(exe[fd]->path, path);
+ }
+ errno = oerrno;
+ }
+#endif
+ va_end(ap);
+ return fd;
+}
+
+#endif
+
+#if _win32_botch_pathconf
+
+extern long
+pathconf(const char* path, int op)
+{
+ if (_access(path, F_OK))
+ return -1;
+ return _pathconf(path, op);
+}
+
+#endif
+
+#if _win32_botch_rename
+
+extern int
+rename(const char* fp, const char* tp)
+{
+ int r;
+ int oerrno;
+ char fb[PATH_MAX];
+ char tb[PATH_MAX];
+
+ oerrno = errno;
+ if ((r = _rename(fp, tp)) && errno == ENOENT && execrate(fp, fb, sizeof(fb), 1))
+ {
+ if (execrate(tp, tb, sizeof(tb), 1))
+ tp = tb;
+ errno = oerrno;
+ r = _rename(fb, tp);
+ }
+ return r;
+}
+
+#endif
+
+#if _win32_botch_stat
+
+extern int
+stat(const char* path, struct stat* st)
+{
+ int r;
+ int oerrno;
+ char buf[PATH_MAX];
+
+ oerrno = errno;
+ if ((r = _stat(path, st)) && errno == ENOENT && execrate(path, buf, sizeof(buf), 0))
+ {
+ errno = oerrno;
+ r = _stat(buf, st);
+ }
+ return r;
+}
+
+#endif
+
+#if _win32_botch_truncate
+
+extern int
+truncate(const char* path, off_t offset)
+{
+ int r;
+ int oerrno;
+ char buf[PATH_MAX];
+
+ oerrno = errno;
+ if ((r = _truncate(path, offset)) && errno == ENOENT && execrate(path, buf, sizeof(buf), 0))
+ {
+ errno = oerrno;
+ r = _truncate(buf, offset);
+ }
+ return r;
+}
+
+#endif
+
+#if _win32_botch_unlink
+
+extern int
+unlink(const char* path)
+{
+ int r;
+ int drive;
+ int mask;
+ int suffix;
+ int stop;
+ int oerrno;
+ unsigned long base;
+ char buf[PATH_MAX];
+ char tmp[MAX_PATH];
+
+#define DELETED_DIR_1 7
+#define DELETED_DIR_2 16
+
+ static char deleted[] = "%c:\\temp\\.deleted\\%08x.%03x";
+
+ static int count = 0;
+
+#if __CYGWIN__
+
+ DWORD fattr = FILE_ATTRIBUTE_NORMAL|FILE_FLAG_DELETE_ON_CLOSE;
+ DWORD share = FILE_SHARE_DELETE;
+ HANDLE hp;
+ struct stat st;
+ char nat[MAX_PATH];
+
+ oerrno = errno;
+ if (lstat(path, &st) || !S_ISREG(st.st_mode))
+ goto try_unlink;
+ cygwin_conv_to_full_win32_path(path, nat);
+ if (!strncasecmp(nat + 1, ":\\temp\\", 7))
+ goto try_unlink;
+ drive = nat[0];
+ path = (const char*)nat;
+ for (;;)
+ {
+ hp = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_DELETE_ON_CLOSE, NULL);
+ if (hp != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(hp);
+ errno = oerrno;
+ return 0;
+ }
+ if (GetLastError() != ERROR_FILE_NOT_FOUND)
+ break;
+ if (path == (const char*)buf || !execrate(path, buf, sizeof(buf), 1))
+ {
+ errno = ENOENT;
+ return -1;
+ }
+ path = (const char*)buf;
+ }
+#else
+ if (_access(path, 0))
+#if _win32_botch_access
+ {
+ if (errno != ENOENT || !execrate(path, buf, sizeof(buf), 1) || _access(buf, 0))
+ return -1;
+ path = (const char*)buf;
+ }
+#else
+ return -1;
+#endif
+ drive = 'C':
+#endif
+
+ /*
+ * rename to a `deleted' path just in case the file is open
+ * otherwise directory readers may choke on phantom entries
+ */
+
+ base = ((getuid() & 0xffff) << 16) | (time(NiL) & 0xffff);
+ suffix = (getpid() & 0xfff) + count++;
+ snprintf(tmp, sizeof(tmp), deleted, drive, base, suffix);
+ if (!_rename(path, tmp))
+ {
+ path = (const char*)tmp;
+ goto try_delete;
+ }
+ if (errno != ENOTDIR && errno != ENOENT)
+ goto try_unlink;
+ tmp[DELETED_DIR_2] = 0;
+ if (_access(tmp, 0))
+ {
+ mask = umask(0);
+ tmp[DELETED_DIR_1] = 0;
+ if (_access(tmp, 0) && _mkdir(tmp, S_IRWXU|S_IRWXG|S_IRWXO))
+ {
+ umask(mask);
+ goto try_unlink;
+ }
+ tmp[DELETED_DIR_1] = '\\';
+ r = _mkdir(tmp, S_IRWXU|S_IRWXG|S_IRWXO);
+ umask(mask);
+ if (r)
+ goto try_unlink;
+ errno = 0;
+ }
+ tmp[DELETED_DIR_2] = '\\';
+ if (!errno && !_rename(path, tmp))
+ {
+ path = (const char*)tmp;
+ goto try_delete;
+ }
+#if !__CYGWIN__
+ if (errno == ENOENT)
+ {
+#if !_win32_botch_access
+ if (execrate(path, buf, sizeof(buf), 1) && !_rename(buf, tmp))
+ path = (const char*)tmp;
+#endif
+ goto try_unlink;
+ }
+#endif
+ stop = suffix;
+ do
+ {
+ snprintf(tmp, sizeof(tmp), deleted, drive, base, suffix);
+ if (!_rename(path, tmp))
+ {
+ path = (const char*)tmp;
+ goto try_delete;
+ }
+ if (++suffix > 0xfff)
+ suffix = 0;
+ } while (suffix != stop);
+ try_delete:
+#if __CYGWIN__
+ hp = CreateFile(path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_DELETE_ON_CLOSE, NULL);
+ if (hp != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(hp);
+ errno = oerrno;
+ return 0;
+ }
+#endif
+ try_unlink:
+ errno = oerrno;
+ return _unlink(path);
+}
+
+#endif
+
+#if _win32_botch_utime
+
+#if __CYGWIN__
+
+/*
+ * cygwin refuses to set st_ctime for some operations
+ * this rejects that refusal
+ */
+
+static void
+ctime_now(const char* path)
+{
+ HANDLE hp;
+ SYSTEMTIME st;
+ FILETIME ct;
+ WIN32_FIND_DATA ff;
+ struct stat fs;
+ int oerrno;
+ char tmp[MAX_PATH];
+
+ if (_stat(path, &fs) || (fs.st_mode & S_IWUSR) || _chmod(path, (fs.st_mode | S_IWUSR) & S_IPERM))
+ fs.st_mode = 0;
+ cygwin_conv_to_win32_path(path, tmp);
+ hp = CreateFile(tmp, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (hp && hp != INVALID_HANDLE_VALUE)
+ {
+ GetSystemTime(&st);
+ SystemTimeToFileTime(&st, &ct);
+ SetFileTime(hp, &ct, 0, 0);
+ CloseHandle(hp);
+ }
+ if (fs.st_mode)
+ _chmod(path, fs.st_mode & S_IPERM);
+ errno = oerrno;
+}
+
+#else
+
+#define ctime_now(p)
+
+#endif
+
+extern int
+utimes(const char* path, const struct timeval* ut)
+{
+ int r;
+ int oerrno;
+ char buf[PATH_MAX];
+
+ oerrno = errno;
+ if ((r = _utimes(path, ut)) && errno == ENOENT && execrate(path, buf, sizeof(buf), 0))
+ {
+ errno = oerrno;
+ r = _utimes(path = buf, ut);
+ }
+ if (!r)
+ ctime_now(path);
+ return r;
+}
+
+extern int
+utime(const char* path, const struct utimbuf* ut)
+{
+ int r;
+ int oerrno;
+ char buf[PATH_MAX];
+
+ oerrno = errno;
+ if ((r = _utime(path, ut)) && errno == ENOENT && execrate(path, buf, sizeof(buf), 0))
+ {
+ errno = oerrno;
+ r = _utime(path = buf, ut);
+ }
+ if (!r)
+ ctime_now(path);
+ return r;
+}
+
+#endif
+
+#endif
+
+/*
+ * some systems (sun) miss a few functions required by their
+ * own bsd-like macros
+ */
+
+#if !_lib_bzero || defined(bzero)
+
+#undef bzero
+
+void
+bzero(void* b, size_t n)
+{
+ memset(b, 0, n);
+}
+
+#endif
+
+#if !_lib_getpagesize || defined(getpagesize)
+
+#ifndef OMITTED
+#define OMITTED 1
+#endif
+
+#undef getpagesize
+
+#ifdef _SC_PAGESIZE
+#undef _AST_PAGESIZE
+#define _AST_PAGESIZE (int)sysconf(_SC_PAGESIZE)
+#else
+#ifndef _AST_PAGESIZE
+#define _AST_PAGESIZE 4096
+#endif
+#endif
+
+int
+getpagesize()
+{
+ return _AST_PAGESIZE;
+}
+
+#endif
+
+#if __CYGWIN__ && defined(__IMPORT__) && defined(__EXPORT__)
+
+#ifndef OMITTED
+#define OMITTED 1
+#endif
+
+/*
+ * a few _imp__FUNCTION symbols are needed to avoid
+ * static link multiple definitions
+ */
+
+#ifndef strtod
+__EXPORT__ double (*_imp__strtod)(const char*, char**) = strtod;
+#endif
+
+#endif
+
+#ifndef OMITTED
+
+NoN(omitted)
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/open.c b/usr/src/lib/libast/common/comp/open.c
new file mode 100644
index 0000000000..b9667d859b
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/open.c
@@ -0,0 +1,119 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * -last 3 arg open
+ */
+
+#include <ast.h>
+
+#if !defined(open) || !defined(_ast_O_LOCAL)
+
+NoN(open)
+
+#else
+
+#undef open
+
+extern int open(const char*, int, ...);
+
+#include <ls.h>
+#include <error.h>
+
+#ifdef O_NOCTTY
+#include <ast_tty.h>
+#endif
+
+int
+_ast_open(const char* path, int op, ...)
+{
+ int fd;
+ int mode;
+ int save_errno;
+ struct stat st;
+ va_list ap;
+
+ save_errno = errno;
+ va_start(ap, op);
+ mode = (op & O_CREAT) ? va_arg(ap, int) : S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
+ va_end(ap);
+ if (op & ~(_ast_O_LOCAL-1))
+ {
+ if (!(op & O_CREAT))
+ op &= ~O_EXCL;
+ for (;;)
+ {
+ if (op & O_TRUNC)
+ {
+ if ((op & O_EXCL) && !access(path, F_OK))
+ {
+ errno = EEXIST;
+ return(-1);
+ }
+ if ((fd = creat(path, (op & O_EXCL) ? 0 : mode)) < 0)
+ return(-1);
+ if (op & O_EXCL)
+ {
+ if (fstat(fd, &st) || (st.st_mode & S_IPERM))
+ {
+ errno = EEXIST;
+ close(fd);
+ return(-1);
+ }
+#if _lib_fchmod
+ if (mode && fchmod(fd, mode))
+#else
+ if (mode && chmod(path, mode))
+#endif
+ errno = save_errno;
+ }
+ if ((op & O_ACCMODE) == O_RDWR)
+ {
+ close(fd);
+ op &= ~(O_CREAT|O_TRUNC);
+ continue;
+ }
+ }
+ else if ((fd = open(path, op & (_ast_O_LOCAL-1), mode)) < 0)
+ {
+ if (op & O_CREAT)
+ {
+ op |= O_TRUNC;
+ continue;
+ }
+ return(-1);
+ }
+ else if ((op & O_APPEND) && lseek(fd, 0L, SEEK_END) == -1L)
+ errno = save_errno;
+#if O_NOCTTY
+ if ((op & O_NOCTTY) && ioctl(fd, TIOCNOTTY, 0))
+ errno = save_errno;
+#endif
+ break;
+ }
+ }
+ else fd = open(path, op, mode);
+ return(fd);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/openlog.c b/usr/src/lib/libast/common/comp/openlog.c
new file mode 100644
index 0000000000..2ccec4b018
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/openlog.c
@@ -0,0 +1,58 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * openlog implementation
+ */
+
+#include <ast.h>
+
+#if _lib_syslog
+
+NoN(openlog)
+
+#else
+
+#include "sysloglib.h"
+
+void
+openlog(const char* ident, int flags, int facility)
+{
+ int n;
+
+ if (ident)
+ {
+ n = strlen(ident);
+ if (n >= sizeof(log.ident))
+ n = sizeof(log.ident) - 1;
+ memcpy(log.ident, ident, n);
+ log.ident[n] = 0;
+ }
+ else
+ log.ident[0] = 0;
+ log.facility = facility;
+ log.flags = flags;
+ if (!(log.flags & LOG_ODELAY))
+ sendlog(NiL);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/putenv.c b/usr/src/lib/libast/common/comp/putenv.c
new file mode 100644
index 0000000000..81e01b0f27
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/putenv.c
@@ -0,0 +1,53 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#define putenv ______putenv
+
+#if _UWIN
+#define _STDLIB_H_ 1
+#endif
+
+#include <ast.h>
+
+#undef putenv
+
+#if _lib_putenv
+
+NoN(putenv)
+
+#else
+
+#undef _def_map_ast
+#include <ast_map.h>
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int
+putenv(const char* s)
+{
+ return setenviron(s) ? 0 : -1;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/re_comp.c b/usr/src/lib/libast/common/comp/re_comp.c
new file mode 100644
index 0000000000..d2afd5fa84
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/re_comp.c
@@ -0,0 +1,81 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * re_comp implementation
+ */
+
+#include <ast.h>
+#include <re_comp.h>
+#include <regex.h>
+
+#undef error
+#undef valid
+
+static struct
+{
+ char error[64];
+ regex_t re;
+ int valid;
+} state;
+
+char*
+re_comp(const char* pattern)
+{
+ register int r;
+
+ if (!pattern || !*pattern)
+ {
+ if (state.valid)
+ return 0;
+ r = REG_BADPAT;
+ }
+ else
+ {
+ if (state.valid)
+ {
+ state.valid = 0;
+ regfree(&state.re);
+ }
+ if (!(r = regcomp(&state.re, pattern, REG_LENIENT|REG_NOSUB|REG_NULL)))
+ {
+ state.valid = 1;
+ return 0;
+ }
+ }
+ regerror(r, &state.re, state.error, sizeof(state.error));
+ return state.error;
+}
+
+int
+re_exec(const char* subject)
+{
+ if (state.valid && subject)
+ switch (regexec(&state.re, subject, 0, NiL, 0))
+ {
+ case 0:
+ return 1;
+ case REG_NOMATCH:
+ return 0;
+ }
+ return -1;
+}
diff --git a/usr/src/lib/libast/common/comp/re_comp.h b/usr/src/lib/libast/common/comp/re_comp.h
new file mode 100644
index 0000000000..661cedd2e9
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/re_comp.h
@@ -0,0 +1,41 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * re_comp interface definitions
+ *
+ * OBSOLETE: use <regex.h>
+ */
+
+#ifndef _RE_COMP_H
+#define _RE_COMP_H
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern char* re_comp(const char*);
+extern int re_exec(const char*);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/readlink.c b/usr/src/lib/libast/common/comp/readlink.c
new file mode 100644
index 0000000000..d2aad33df7
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/readlink.c
@@ -0,0 +1,61 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_readlink
+
+NoN(readlink)
+
+#else
+
+#include "fakelink.h"
+
+#include <error.h>
+
+#ifndef ENOSYS
+#define ENOSYS EINVAL
+#endif
+
+int
+readlink(const char* path, char* buf, int siz)
+{
+ int fd;
+ int n;
+
+ if (siz > sizeof(FAKELINK_MAGIC))
+ {
+ if ((fd = open(path, O_RDONLY)) < 0)
+ return -1;
+ if (read(fd, buf, sizeof(FAKELINK_MAGIC)) == sizeof(FAKELINK_MAGIC) && !strcmp(buf, FAKELINK_MAGIC) && (n = read(fd, buf, siz)) > 0 && !buf[n - 1])
+ {
+ close(fd);
+ return n;
+ }
+ close(fd);
+ }
+ errno = ENOSYS;
+ return -1;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/realpath.c b/usr/src/lib/libast/common/comp/realpath.c
new file mode 100644
index 0000000000..8fcbc1d170
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/realpath.c
@@ -0,0 +1,48 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * realpath implementation
+ */
+
+#define realpath ______realpath
+#define resolvepath ______resolvepath
+
+#include <ast.h>
+
+#undef realpath
+#undef resolvepath
+
+#undef _def_map_ast
+#include <ast_map.h>
+
+extern char* resolvepath(const char*, char*, size_t);
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern char*
+realpath(const char* file, char* path)
+{
+ return resolvepath(file, path, PATH_MAX);
+}
diff --git a/usr/src/lib/libast/common/comp/regcmp.c b/usr/src/lib/libast/common/comp/regcmp.c
new file mode 100644
index 0000000000..bba7a45697
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/regcmp.c
@@ -0,0 +1,211 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * regcmp implementation
+ */
+
+#include <ast.h>
+#include <libgen.h>
+#include <regex.h>
+#include <align.h>
+
+#define INC (2*1024)
+#define TOT (16*1024)
+#define SUB 10
+
+typedef struct
+{
+ char* cur;
+ regex_t re;
+ unsigned char sub[SUB];
+ int nsub;
+ size_t size;
+ char buf[ALIGN_BOUND2];
+} Regex_t;
+
+__DEFINE__(char*, __loc1, 0);
+
+static void*
+block(void* handle, void* data, size_t size)
+{
+ register Regex_t* re = (Regex_t*)handle;
+
+ if (data || (size = roundof(size, ALIGN_BOUND2)) > (re->buf + re->size - re->cur))
+ return 0;
+ data = (void*)re->cur;
+ re->cur += size;
+ return data;
+}
+
+char*
+regcmp(const char* pattern, ...)
+{
+ register char* s;
+ register Regex_t* re;
+ register size_t n;
+ register int c;
+ register int p;
+ int b;
+ int i;
+ int j;
+ int nsub;
+ register Sfio_t* sp;
+ unsigned char paren[128];
+ unsigned char sub[SUB];
+ va_list ap;
+
+ va_start(ap, pattern);
+ if (!pattern || !*pattern || !(sp = sfstropen()))
+ return 0;
+ memset(paren, 0, sizeof(paren));
+ n = 0;
+ p = -1;
+ b = 0;
+ nsub = 0;
+ s = (char*)pattern;
+ do
+ {
+ while (c = *s++)
+ {
+ if (c == '\\')
+ {
+ sfputc(sp, c);
+ if (!(c = *s++))
+ break;
+ }
+ else if (b)
+ {
+ if (c == ']')
+ b = 0;
+ }
+ else if (c == '[')
+ {
+ b = 1;
+ if (*s == '^')
+ {
+ sfputc(sp, c);
+ c = *s++;
+ }
+ if (*s == ']')
+ {
+ sfputc(sp, c);
+ c = *s++;
+ }
+ }
+ else if (c == '(')
+ {
+ /*
+ * someone explain in one sentence why
+ * a cast is needed to make this work
+ */
+
+ if (p < (int)(elementsof(paren) - 1))
+ p++;
+ paren[p] = ++n;
+ }
+ else if (c == ')' && p >= 0)
+ {
+ for (i = p; i > 0; i--)
+ if (paren[i])
+ break;
+ if (*s == '$' && (j = *(s + 1)) >= '0' && j <= '9')
+ {
+ s += 2;
+ j -= '0';
+ if (nsub <= j)
+ {
+ if (!nsub)
+ memset(sub, 0, sizeof(sub));
+ nsub = j + 1;
+ }
+ sub[j] = paren[i] + 1;
+ }
+ paren[i] = 0;
+ }
+ sfputc(sp, c);
+ }
+ } while (s = va_arg(ap, char*));
+ va_end(ap);
+ if (!(s = sfstruse(sp)))
+ {
+ sfstrclose(sp);
+ return 0;
+ }
+ re = 0;
+ n = 0;
+ do
+ {
+ if ((n += INC) > TOT || !(re = newof(re, Regex_t, 0, n)))
+ {
+ if (re)
+ free(re);
+ sfstrclose(sp);
+ return 0;
+ }
+ re->cur = re->buf;
+ re->size = n + ALIGN_BOUND2 - sizeof(Regex_t);
+ regalloc(re, block, REG_NOFREE);
+ c = regcomp(&re->re, s, REG_EXTENDED|REG_LENIENT|REG_NULL);
+ regalloc(NiL, NiL, 0);
+ } while (c == REG_ESPACE);
+ sfstrclose(sp);
+ if (c)
+ {
+ free(re);
+ return 0;
+ }
+ if (re->nsub = nsub)
+ memcpy(re->sub, sub, (nsub + 1) * sizeof(sub[0]));
+ return (char*)re;
+}
+
+char*
+regex(const char* handle, const char* subject, ...)
+{
+ register Regex_t* re;
+ register int n;
+ register int i;
+ register int k;
+ char* sub[SUB + 1];
+ regmatch_t match[SUB + 1];
+ va_list ap;
+
+ va_start(ap, subject);
+ if (!(re = (Regex_t*)handle) || !subject)
+ return 0;
+ for (n = 0; n < re->nsub; n++)
+ sub[n] = va_arg(ap, char*);
+ va_end(ap);
+ if (regexec(&re->re, subject, SUB + 1, match, 0))
+ return 0;
+ for (n = 0; n < re->nsub; n++)
+ if (i = re->sub[n])
+ {
+ i--;
+ k = match[i].rm_eo - match[i].rm_so;
+ strncpy(sub[n], subject + match[i].rm_so, k);
+ *(sub[n] + k) = 0;
+ }
+ __loc1 = (char*)subject + match[0].rm_so;
+ return (char*)subject + match[0].rm_eo;
+}
diff --git a/usr/src/lib/libast/common/comp/regexp.c b/usr/src/lib/libast/common/comp/regexp.c
new file mode 100644
index 0000000000..10d67fa30d
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/regexp.c
@@ -0,0 +1,123 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * <regexp.h> library support
+ */
+
+#define _REGEXP_DECLARE
+
+#include <ast.h>
+#include <regexp.h>
+#include <regex.h>
+#include <align.h>
+
+typedef struct
+{
+ regex_t re;
+ char* buf;
+ char* cur;
+ unsigned int size;
+} Env_t;
+
+static void*
+block(void* handle, void* data, size_t size)
+{
+ register Env_t* env = (Env_t*)handle;
+
+ if (data || (size = roundof(size, ALIGN_BOUND2)) > (env->buf + env->size - env->cur))
+ return 0;
+ data = (void*)env->cur;
+ env->cur += size;
+ return data;
+}
+
+int
+_re_comp(regexp_t* re, const char* pattern, char* handle, unsigned int size)
+{
+ register Env_t* env = (Env_t*)handle;
+ register int n;
+
+ if (size <= sizeof(Env_t))
+ return 50;
+ env->buf = env->cur = (char*)env + sizeof(Env_t);
+ env->size = size - sizeof(Env_t);
+ regalloc(env, block, REG_NOFREE);
+ n = regcomp(&env->re, pattern, REG_LENIENT|REG_NULL);
+ switch (n)
+ {
+ case 0:
+ break;
+ case REG_ERANGE:
+ n = 11;
+ break;
+ case REG_BADBR:
+ n = 16;
+ break;
+ case REG_ESUBREG:
+ n = 25;
+ break;
+ case REG_EPAREN:
+ n = 42;
+ break;
+ case REG_EBRACK:
+ n = 49;
+ break;
+ default:
+ n = 50;
+ break;
+ }
+ re->re_nbra = env->re.re_nsub;
+ return n;
+}
+
+int
+_re_exec(regexp_t* re, const char* subject, const char* handle, int anchor)
+{
+ register Env_t* env = (Env_t*)handle;
+ register int n;
+ regmatch_t match[elementsof(re->re_braslist)+1];
+
+ if (regexec(&env->re, subject, elementsof(match), match, 0) || anchor && match[0].rm_so)
+ return 0;
+ re->re_loc1 = (char*)subject + match[0].rm_so;
+ re->re_loc2 = (char*)subject + match[0].rm_eo;
+ for (n = 1; n <= env->re.re_nsub; n++)
+ {
+ re->re_braslist[n-1] = (char*)subject + match[n].rm_so;
+ re->re_braelist[n-1] = (char*)subject + match[n].rm_eo;
+ }
+ return 1;
+}
+
+char*
+_re_putc(int c)
+{
+ static Sfio_t* sp;
+
+ if (!sp && !(sp = sfstropen()))
+ return 0;
+ if (!c)
+ return sfstruse(sp);
+ sfputc(sp, c);
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/comp/regexp.h b/usr/src/lib/libast/common/comp/regexp.h
new file mode 100644
index 0000000000..ab00216b50
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/regexp.h
@@ -0,0 +1,129 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * regexp interface and partial implementation
+ * what a novel approach
+ * don't do it again
+ *
+ * OBSOLETE: use <regex.h>
+ */
+
+#ifndef _REGEXP_H
+#define _REGEXP_H
+
+#define NBRA 9
+
+typedef struct
+{
+ char* re_braslist[NBRA];
+ char* re_braelist[NBRA];
+ char* re_loc1;
+ char* re_loc2;
+ char* re_locs;
+ int re_circf;
+ int re_nbra;
+ int re_nodelim;
+ int re_sed;
+} regexp_t;
+
+#define braslist _re_info.re_braslist
+#define braelist _re_info.re_braelist
+#define circf _re_info.re_circf
+#define loc1 _re_info.re_loc1
+#define loc2 _re_info.re_loc2
+#define locs _re_info.re_locs
+#define nbra _re_info.re_nbra
+#define nodelim _re_info.re_nodelim
+#define sed _re_info.re_sed
+
+#define advance(a,b) _re_exec(&_re_info,a,b,1)
+#define compile(a,b,c,d) _re_read(&_re_info,a,b,c,d)
+#define step(a,b) _re_exec(&_re_info,a,b,0)
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int _re_comp(regexp_t*, const char*, char*, unsigned int);
+extern int _re_exec(regexp_t*, const char*, const char*, int);
+extern char* _re_putc(int);
+extern char* _re_read(regexp_t*, const char*, char*, const char*, int);
+
+#undef extern
+
+#ifndef _REGEXP_DECLARE
+
+regexp_t _re_info;
+
+char*
+_re_read(register regexp_t* re, const char* instring, char* ep, const char* endbuf, int seof)
+{
+ register int c;
+
+ static const char* prev;
+
+#ifdef INIT
+ INIT;
+#endif
+
+ re->re_nodelim = 0;
+ if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0)
+ {
+ if (c != seof)
+ {
+ UNGETC(c);
+ re->re_nodelim = 1;
+ }
+ if (!re->re_sed && !prev)
+ { ERROR(41); }
+ RETURN((char*)endbuf);
+ }
+ UNGETC(c);
+ prev = 0;
+ for (;;)
+ {
+ if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0)
+ {
+ if (re->re_sed)
+ { ERROR(36); }
+ UNGETC(c);
+ re->re_nodelim = 1;
+ break;
+ }
+ if (c == '\\')
+ {
+ _re_putc(c);
+ if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0)
+ { ERROR(36); }
+ }
+ _re_putc(c);
+ }
+ if (c = _re_comp(re, _re_putc(0), ep, (char*)endbuf - ep))
+ { ERROR(c); }
+ prev = endbuf;
+ RETURN((char*)prev);
+}
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/remove.c b/usr/src/lib/libast/common/comp/remove.c
new file mode 100644
index 0000000000..c470e35806
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/remove.c
@@ -0,0 +1,49 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#define remove ______remove
+
+#include <ast.h>
+
+#undef remove
+
+#undef _def_map_ast
+#include <ast_map.h>
+
+#if _std_remove || !_lib_unlink
+
+NoN(remove)
+
+#else
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int
+remove(const char* path)
+{
+ return unlink(path);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/rename.c b/usr/src/lib/libast/common/comp/rename.c
new file mode 100644
index 0000000000..1c0955bbbf
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/rename.c
@@ -0,0 +1,98 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_rename
+
+NoN(rename)
+
+#else
+
+#include <error.h>
+#include <proc.h>
+
+#ifdef EPERM
+
+static int
+mvdir(const char* from, const char* to)
+{
+ char* argv[4];
+ int oerrno;
+
+ static const char mvdir[] = "/usr/lib/mv_dir";
+
+ oerrno = errno;
+ if (!eaccess(mvdir, X_OK))
+ {
+ argv[0] = mvdir;
+ argv[1] = from;
+ argv[2] = to;
+ argv[3] = 0;
+ if (!procrun(argv[0], argv))
+ {
+ errno = oerrno;
+ return 0;
+ }
+ }
+ errno = EPERM;
+ return -1;
+}
+
+#endif
+
+int
+rename(const char* from, const char* to)
+{
+ int oerrno;
+ int ooerrno;
+
+ ooerrno = errno;
+ while (link(from, to))
+ {
+#ifdef EPERM
+ if (errno == EPERM)
+ {
+ errno = ooerrno;
+ return mvdir(from, to);
+ }
+#endif
+ oerrno = errno;
+ if (unlink(to))
+ {
+#ifdef EPERM
+ if (errno == EPERM)
+ {
+ errno = ooerrno;
+ return mvdir(from, to);
+ }
+#endif
+ errno = oerrno;
+ return -1;
+ }
+ }
+ errno = ooerrno;
+ return unlink(from);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/resolvepath.c b/usr/src/lib/libast/common/comp/resolvepath.c
new file mode 100644
index 0000000000..2e9b09cb46
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/resolvepath.c
@@ -0,0 +1,70 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * resolvepath implementation
+ */
+
+#define resolvepath ______resolvepath
+
+#include <ast.h>
+#include <error.h>
+
+#undef resolvepath
+
+#undef _def_map_ast
+#include <ast_map.h>
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern char*
+resolvepath(const char* file, char* path, size_t size)
+{
+ register char* s;
+ register int n;
+ register int r;
+
+ r = *file != '/';
+ n = strlen(file) + r + 1;
+ if (n >= size)
+ {
+#ifdef ENAMETOOLONG
+ errno = ENAMETOOLONG;
+#else
+ errno = ENOMEM;
+#endif
+ return 0;
+ }
+ if (!r)
+ s = path;
+ else if (!getcwd(path, size - n))
+ return 0;
+ else
+ {
+ s = path + strlen(path);
+ *s++ = '/';
+ }
+ strcpy(s, file);
+ return pathcanon(path, PATH_PHYSICAL|PATH_DOTDOT|PATH_EXISTS) ? path : (char*)0;
+}
diff --git a/usr/src/lib/libast/common/comp/rmdir.c b/usr/src/lib/libast/common/comp/rmdir.c
new file mode 100644
index 0000000000..581c86a0c4
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/rmdir.c
@@ -0,0 +1,66 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_rmdir
+
+NoN(rmdir)
+
+#else
+
+#include <ls.h>
+#include <error.h>
+
+int
+rmdir(const char* path)
+{
+ register int n;
+ struct stat st;
+ char* av[3];
+
+ static char* cmd[] = { "/bin/rmdir", "/usr/5bin/rmdir", 0 };
+
+ if (stat(path, &st) < 0) return(-1);
+ if (!S_ISDIR(st.st_mode))
+ {
+ errno = ENOTDIR;
+ return(-1);
+ }
+ av[0] = "rmdir";
+ av[1] = path;
+ av[2] = 0;
+ for (n = 0; n < elementsof(cmd); n++)
+ if (procclose(procopen(cmd[n], av, NiL, NiL, 0)) != -1)
+ break;
+ n = errno;
+ if (access(path, F_OK) < 0)
+ {
+ errno = n;
+ return(0);
+ }
+ errno = EPERM;
+ return(-1);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/setenv.c b/usr/src/lib/libast/common/comp/setenv.c
new file mode 100644
index 0000000000..2de75c5a49
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/setenv.c
@@ -0,0 +1,58 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#define setenv ______setenv
+
+#include <ast.h>
+
+#undef setenv
+#undef _lib_setenv /* procopen() calls setenv() */
+
+#if _lib_setenv
+
+NoN(setenv)
+
+#else
+
+#undef _def_map_ast
+#include <ast_map.h>
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int
+setenv(const char* name, const char* value, int overwrite)
+{
+ char* s;
+
+ if (overwrite || !getenv(name))
+ {
+ if (!(s = sfprints("%s=%s", name, value)) || !(s = strdup(s)))
+ return -1;
+ return setenviron(s) ? 0 : -1;
+ }
+ return 0;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/setlocale.c b/usr/src/lib/libast/common/comp/setlocale.c
new file mode 100644
index 0000000000..3240e2b697
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/setlocale.c
@@ -0,0 +1,946 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * setlocale() intercept
+ * maintains a bitmask of non-default categories
+ * and a permanent locale namespace for pointer comparison
+ * and persistent private data for locale related functions
+ */
+
+#include <ast_standards.h>
+
+#include "lclib.h"
+
+#include <ast_wchar.h>
+#include <ctype.h>
+#include <mc.h>
+#include <namval.h>
+
+#if ( _lib_wcwidth || _lib_wctomb ) && _hdr_wctype
+#include <wctype.h>
+#endif
+
+#if _lib_wcwidth
+#undef wcwidth
+#else
+#define wcwidth 0
+#endif
+
+#if _lib_wctomb
+#undef wctomb
+#else
+#define wctomb 0
+#endif
+
+#ifdef mblen
+#undef mblen
+extern int mblen(const char*, size_t);
+#endif
+
+#undef mbtowc
+#undef setlocale
+#undef strcmp
+#undef strcoll
+#undef strxfrm
+#undef valid
+
+#ifndef AST_LC_CANONICAL
+#define AST_LC_CANONICAL LC_abbreviated
+#endif
+
+#if _UWIN
+
+#include <ast_windows.h>
+
+#undef _lib_setlocale
+#define _lib_setlocale 1
+
+#define setlocale(c,l) native_setlocale(c,l)
+
+extern char* uwin_setlocale(int, const char*);
+
+/*
+ * convert locale to native locale name in buf
+ */
+
+static char*
+native_locale(const char* locale, char* buf, size_t siz)
+{
+ Lc_t* lc;
+ const Lc_attribute_list_t* ap;
+ int i;
+ unsigned long lcid;
+ unsigned long lang;
+ unsigned long ctry;
+ char lbuf[128];
+ char cbuf[128];
+
+ if (locale && *locale)
+ {
+ if (!(lc = lcmake(locale)))
+ return 0;
+ lang = lc->language->index;
+ ctry = 0;
+ for (ap = lc->attributes; ap; ap = ap->next)
+ if (ctry = ap->attribute->index)
+ break;
+ if (!ctry)
+ {
+ for (i = 0; i < elementsof(lc->territory->languages); i++)
+ if (lc->territory->languages[i] == lc->language)
+ {
+ ctry = lc->territory->indices[i];
+ break;
+ }
+ if (!ctry)
+ ctry = SUBLANG_DEFAULT;
+ }
+ lcid = MAKELCID(MAKELANGID(lang, ctry), SORT_DEFAULT);
+ }
+ else
+ lcid = GetUserDefaultLCID();
+ if (GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, lbuf, sizeof(lbuf)) <= 0 ||
+ GetLocaleInfo(lcid, LOCALE_SENGCOUNTRY, cbuf, sizeof(cbuf)) <= 0)
+ return 0;
+ if (lc->charset->ms)
+ sfsprintf(buf, siz, "%s_%s.%s", lbuf, cbuf, lc->charset->ms);
+ else
+ sfsprintf(buf, siz, "%s_%s", lbuf, cbuf);
+ return buf;
+}
+
+/*
+ * locale!=0 here
+ */
+
+static char*
+native_setlocale(int category, const char* locale)
+{
+ char* usr;
+ char* sys;
+ char buf[256];
+
+ /*
+ * win32 doesn't have LC_MESSAGES
+ */
+
+ if (category == LC_MESSAGES)
+ return (char*)locale;
+ if (!(usr = native_locale(locale, buf, sizeof(buf))))
+ return 0;
+ sys = uwin_setlocale(category, usr);
+ if (ast.locale.set & AST_LC_debug)
+ sfprintf(sfstderr, "locale uwin %17s %-24s %-24s\n", categories[lcindex(category, 0)].name, usr, sys);
+ return sys;
+}
+
+#else
+
+#define native_locale(a,b,c) ((char*)0)
+
+#endif
+
+/*
+ * LC_COLLATE and LC_CTYPE native support
+ */
+
+#if !_lib_mbtowc || MB_LEN_MAX <= 1
+#define mblen 0
+#define mbtowc 0
+#endif
+
+#if !_lib_strcoll
+#define strcoll 0
+#endif
+
+#if !_lib_strxfrm
+#define strxfrm 0
+#endif
+
+/*
+ * LC_COLLATE and LC_CTYPE debug support
+ *
+ * mutibyte debug encoding
+ *
+ * DL0 [ '0' .. '4' ] c1 ... c4 DR0
+ * DL1 [ '0' .. '4' ] c1 ... c4 DR1
+ *
+ * with these ligatures
+ *
+ * ch CH sst SST
+ *
+ * and private collation order
+ *
+ * wide character display width is the low order 3 bits
+ * wctomb() uses DL1...DR1
+ */
+
+#define DEBUG_MB_CUR_MAX 7
+
+#if DEBUG_MB_CUR_MAX < MB_LEN_MAX
+#undef DEBUG_MB_CUR_MAX
+#define DEBUG_MB_CUR_MAX MB_LEN_MAX
+#endif
+
+#define DL0 '<'
+#define DL1 0xab /* 8-bit mini << on xterm */
+#define DR0 '>'
+#define DR1 0xbb /* 8-bit mini >> on xterm */
+
+#define DB ((int)sizeof(wchar_t)*8-1)
+#define DC 7 /* wchar_t embedded char bits */
+#define DX (DB/DC) /* wchar_t max embedded chars */
+#define DZ (DB-DX*DC+1) /* wchar_t embedded size bits */
+#define DD 3 /* # mb delimiter chars <n...> */
+
+static unsigned char debug_order[] =
+{
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31,
+ 99, 100, 101, 102, 98, 103, 104, 105,
+ 106, 107, 108, 43, 109, 44, 42, 110,
+ 32, 33, 34, 35, 36, 37, 38, 39,
+ 40, 41, 111, 112, 113, 114, 115, 116,
+ 117, 71, 72, 73, 74, 75, 76, 77,
+ 78, 79, 80, 81, 82, 83, 84, 85,
+ 86, 87, 88, 89, 90, 91, 92, 93,
+ 94, 95, 96, 118, 119, 120, 121, 97,
+ 122, 45, 46, 47, 48, 49, 50, 51,
+ 52, 53, 54, 55, 56, 57, 58, 59,
+ 60, 61, 62, 63, 64, 65, 66, 67,
+ 68, 69, 70, 123, 124, 125, 126, 127,
+ 128, 129, 130, 131, 132, 133, 134, 135,
+ 136, 137, 138, 139, 140, 141, 142, 143,
+ 144, 145, 146, 147, 148, 149, 150, 151,
+ 152, 153, 154, 155, 156, 157, 158, 159,
+ 160, 161, 162, 163, 164, 165, 166, 167,
+ 168, 169, 170, 171, 172, 173, 174, 175,
+ 176, 177, 178, 179, 180, 181, 182, 183,
+ 184, 185, 186, 187, 188, 189, 190, 191,
+ 192, 193, 194, 195, 196, 197, 198, 199,
+ 200, 201, 202, 203, 204, 205, 206, 207,
+ 208, 209, 210, 211, 212, 213, 214, 215,
+ 216, 217, 218, 219, 220, 221, 222, 223,
+ 224, 225, 226, 227, 228, 229, 230, 231,
+ 232, 233, 234, 235, 236, 237, 238, 239,
+ 240, 241, 242, 243, 244, 245, 246, 247,
+ 248, 249, 250, 251, 252, 253, 254, 255,
+};
+
+static int
+debug_mbtowc(register wchar_t* p, register const char* s, size_t n)
+{
+ register const char* q;
+ register const char* r;
+ register int w;
+ register int dr;
+ wchar_t c;
+
+ if (n < 1)
+ return -1;
+ if (!s || !*s)
+ return 0;
+ switch (((unsigned char*)s)[0])
+ {
+ case DL0:
+ dr = DR0;
+ break;
+ case DL1:
+ dr = DR1;
+ break;
+ default:
+ if (p)
+ *p = ((unsigned char*)s)[0] & ((1<<DC)-1);
+ return 1;
+ }
+ if (n < 2)
+ return -1;
+ if ((w = ((unsigned char*)s)[1]) == ((unsigned char*)s)[0])
+ {
+ if (p)
+ *p = w;
+ return 2;
+ }
+ if (w < '0' || w > ('0' + DX))
+ return -1;
+ if ((w -= '0' - DD) > n)
+ return -1;
+ r = s + w - 1;
+ q = s += 2;
+ while (q < r && *q)
+ q++;
+ if (q != r || *((unsigned char*)q) != dr)
+ return -1;
+ if (p)
+ {
+ c = 0;
+ while (--q >= s)
+ {
+ c <<= DC;
+ c |= *((unsigned char*)q);
+ }
+ c <<= DZ;
+ c |= w - DD;
+ *p = c;
+ }
+ return w;
+}
+
+static int
+debug_wctomb(char* s, wchar_t c)
+{
+ int w;
+ int i;
+ int k;
+
+ w = 0;
+ if (c >= 0 && c <= UCHAR_MAX)
+ {
+ w++;
+ if (s)
+ *s = c;
+ }
+ else if ((i = c & ((1<<DZ)-1)) > DX)
+ return -1;
+ else
+ {
+ w++;
+ if (s)
+ *s++ = DL1;
+ c >>= DZ;
+ w++;
+ if (s)
+ *s++ = i + '0';
+ while (i--)
+ {
+ w++;
+ if (s)
+ *s++ = (k = c & ((1<<DC)-1)) ? k : '?';
+ c >>= DC;
+ }
+ w++;
+ if (s)
+ *s++ = DR1;
+ }
+ return w;
+}
+
+static int
+debug_mblen(const char* s, size_t n)
+{
+ return debug_mbtowc(NiL, s, n);
+}
+
+static int
+debug_wcwidth(wchar_t c)
+{
+ if (c >= 0 && c <= UCHAR_MAX)
+ return 1;
+ if ((c &= ((1<<DZ)-1)) > DX)
+ return -1;
+ return c + DD;
+}
+
+static size_t
+debug_strxfrm(register char* t, register const char* s, size_t n)
+{
+ register const char* q;
+ register const char* r;
+ register char* e;
+ register size_t z;
+ register int w;
+
+ z = 0;
+ if (e = t)
+ e += n;
+ while (s[0])
+ {
+ if ((((unsigned char*)s)[0] == DL0 || ((unsigned char*)s)[0] == DL1) && (w = s[1]) >= '0' && w <= ('0' + DC))
+ {
+ w -= '0';
+ q = s + 2;
+ r = q + w;
+ while (q < r && *q)
+ q++;
+ if (*((unsigned char*)q) == DR0 || *((unsigned char*)q) == DR1)
+ {
+ if (t)
+ {
+ for (q = s + 2; q < r; q++)
+ if (t < e)
+ *t++ = debug_order[*q];
+ while (w++ < DX)
+ if (t < e)
+ *t++ = 1;
+ }
+ s = r + 1;
+ z += DX;
+ continue;
+ }
+ }
+ if ((s[0] == 'c' || s[0] == 'C') && (s[1] == 'h' || s[1] == 'H'))
+ {
+ if (t)
+ {
+ if (t < e)
+ *t++ = debug_order[s[0]];
+ if (t < e)
+ *t++ = debug_order[s[1]];
+ if (t < e)
+ *t++ = 1;
+ if (t < e)
+ *t++ = 1;
+ }
+ s += 2;
+ z += DX;
+ continue;
+ }
+ if ((s[0] == 's' || s[0] == 'S') && (s[1] == 's' || s[1] == 'S') && (s[2] == 't' || s[2] == 'T'))
+ {
+ if (t)
+ {
+ if (t < e)
+ *t++ = debug_order[s[0]];
+ if (t < e)
+ *t++ = debug_order[s[1]];
+ if (t < e)
+ *t++ = debug_order[s[2]];
+ if (t < e)
+ *t++ = 1;
+ }
+ s += 3;
+ z += DX;
+ continue;
+ }
+ if (t)
+ {
+ if (t < e)
+ *t++ = debug_order[s[0]];
+ if (t < e)
+ *t++ = 1;
+ if (t < e)
+ *t++ = 1;
+ if (t < e)
+ *t++ = 1;
+ }
+ s++;
+ z += DX;
+ }
+ if (t < e)
+ *t = 0;
+ return z;
+}
+
+static int
+debug_strcoll(const char* a, const char* b)
+{
+ char ab[1024];
+ char bb[1024];
+
+ debug_strxfrm(ab, a, sizeof(ab) - 1);
+ ab[sizeof(ab)-1] = 0;
+ debug_strxfrm(bb, b, sizeof(bb) - 1);
+ bb[sizeof(bb)-1] = 0;
+ return strcmp(ab, bb);
+}
+
+/*
+ * default locale
+ */
+
+static int
+default_wcwidth(wchar_t w)
+{
+ return w >= 0 && w <= 255 && !iscntrl(w) ? 1 : -1;
+}
+
+/*
+ * called when LC_COLLATE initialized or changes
+ */
+
+static int
+set_collate(Lc_category_t* cp)
+{
+ if (locales[cp->internal]->flags & LC_debug)
+ {
+ ast.collate = debug_strcoll;
+ ast.mb_xfrm = debug_strxfrm;
+ }
+ else if (locales[cp->internal]->flags & LC_default)
+ {
+ ast.collate = strcmp;
+ ast.mb_xfrm = 0;
+ }
+ else
+ {
+ ast.collate = strcoll;
+ ast.mb_xfrm = strxfrm;
+ }
+ return 0;
+}
+
+/*
+ * called when LC_CTYPE initialized or changes
+ */
+
+static int
+set_ctype(Lc_category_t* cp)
+{
+ if (locales[cp->internal]->flags & LC_debug)
+ {
+ ast.mb_cur_max = DEBUG_MB_CUR_MAX;
+ ast.mb_len = debug_mblen;
+ ast.mb_towc = debug_mbtowc;
+ ast.mb_width = debug_wcwidth;
+ ast.mb_conv = debug_wctomb;
+ }
+ else if ((locales[cp->internal]->flags & LC_default) || (ast.mb_cur_max = MB_CUR_MAX) <= 1 || !(ast.mb_len = mblen) || !(ast.mb_towc = mbtowc))
+ {
+ ast.mb_cur_max = 1;
+ ast.mb_len = 0;
+ ast.mb_towc = 0;
+ ast.mb_width = default_wcwidth;
+ ast.mb_conv = 0;
+ }
+ else
+ {
+ if (!(ast.mb_width = wcwidth))
+ ast.mb_width = default_wcwidth;
+ ast.mb_conv = wctomb;
+ }
+ return 0;
+}
+
+/*
+ * called when LC_NUMERIC initialized or changes
+ */
+
+static int
+set_numeric(Lc_category_t* cp)
+{
+ register int category = cp->internal;
+ struct lconv* lp;
+ Lc_numeric_t* dp;
+
+ static Lc_numeric_t default_numeric = { '.', -1 };
+
+ if (!LCINFO(category)->data)
+ {
+ if ((lp = localeconv()) && (dp = newof(0, Lc_numeric_t, 1, 0)))
+ {
+ dp->decimal = lp->decimal_point && *lp->decimal_point ? *(unsigned char*)lp->decimal_point : '.';
+ dp->thousand = lp->thousands_sep && *lp->thousands_sep ? *(unsigned char*)lp->thousands_sep : -1;
+ }
+ else
+ dp = &default_numeric;
+ LCINFO(category)->data = (void*)dp;
+ if (ast.locale.set & (AST_LC_debug|AST_LC_setlocale))
+ sfprintf(sfstderr, "locale info %17s decimal '%c' thousands '%c'\n", categories[category].name, dp->decimal, dp->thousand >= 0 ? dp->thousand : 'X');
+ }
+ return 0;
+}
+
+/*
+ * this table is indexed by AST_LC_[A-Z]*
+ */
+
+Lc_category_t categories[] =
+{
+{ "LC_ALL", LC_ALL, AST_LC_ALL, 0 },
+{ "LC_COLLATE", LC_COLLATE, AST_LC_COLLATE, set_collate },
+{ "LC_CTYPE", LC_CTYPE, AST_LC_CTYPE, set_ctype },
+{ "LC_MESSAGES", LC_MESSAGES, AST_LC_MESSAGES, 0 },
+{ "LC_MONETARY", LC_MONETARY, AST_LC_MONETARY, 0 },
+{ "LC_NUMERIC", LC_NUMERIC, AST_LC_NUMERIC, set_numeric },
+{ "LC_TIME", LC_TIME, AST_LC_TIME, 0 },
+{ "LC_IDENTIFICATION",LC_IDENTIFICATION,AST_LC_IDENTIFICATION,0 },
+{ "LC_ADDRESS", LC_ADDRESS, AST_LC_ADDRESS, 0 },
+{ "LC_NAME", LC_NAME, AST_LC_NAME, 0 },
+{ "LC_TELEPHONE", LC_TELEPHONE, AST_LC_TELEPHONE, 0 },
+{ "LC_XLITERATE", LC_XLITERATE, AST_LC_XLITERATE, 0 },
+{ "LC_MEASUREMENT", LC_MEASUREMENT, AST_LC_MEASUREMENT, 0 },
+{ "LC_PAPER", LC_PAPER, AST_LC_PAPER, 0 },
+};
+
+static const Namval_t options[] =
+{
+ "debug", AST_LC_debug,
+ "find", AST_LC_find,
+ "setlocale", AST_LC_setlocale,
+ "translate", AST_LC_translate,
+ 0, 0
+};
+
+/*
+ * called by stropt() to set options
+ */
+
+static int
+setopt(void* a, const void* p, int n, const char* v)
+{
+ if (p)
+ {
+ if (n)
+ ast.locale.set |= ((Namval_t*)p)->value;
+ else
+ ast.locale.set &= ~((Namval_t*)p)->value;
+ }
+ return 0;
+}
+
+#if !_lib_setlocale
+
+#define setlocale(c,l) default_setlocale(c,l)
+
+static char*
+default_setlocale(int category, const char* locale)
+{
+ Lc_t* lc;
+
+ if (locale)
+ {
+ if (!(lc = lcmake(locale)) || !(lc->flags & LC_default))
+ return 0;
+ locales[0]->flags &= ~lc->flags;
+ locales[1]->flags &= ~lc->flags;
+ return lc->name;
+ }
+ return (locales[1]->flags & (1<<category)) ? locales[1]->name : locales[0]->name;
+}
+
+#endif
+
+/*
+ * set a single AST_LC_* locale category
+ * the caller must validate category
+ * lc==0 restores the previous state
+ */
+
+static char*
+single(int category, Lc_t* lc)
+{
+ const char* sys;
+ int i;
+
+ if (!lc && !(lc = categories[category].prev))
+ lc = lcmake(NiL);
+ if (locales[category] != lc)
+ {
+ if (categories[category].external == -categories[category].internal)
+ {
+ sys = 0;
+ for (i = 1; i < AST_LC_COUNT; i++)
+ if (locales[i] == lc)
+ {
+ sys = (char*)lc->name;
+ break;
+ }
+ }
+ else if (lc->flags & (LC_debug|LC_local))
+ sys = setlocale(categories[category].external, lcmake(NiL)->name);
+ else if (!(sys = setlocale(categories[category].external, lc->name)) &&
+ (streq(lc->name, lc->code) || !(sys = setlocale(categories[category].external, lc->code))) &&
+ !streq(lc->code, lc->language->code))
+ sys = setlocale(categories[category].external, lc->language->code);
+ if (ast.locale.set & (AST_LC_debug|AST_LC_setlocale))
+ sfprintf(sfstderr, "locale set %17s %-24s %-24s\n", categories[category].name, lc->name, sys);
+ if (!sys)
+ {
+ /*
+ * check for local override
+ * currently this means an LC_MESSAGES dir exists
+ */
+
+ if (!(lc->flags & LC_checked))
+ {
+ char path[PATH_MAX];
+
+ if (mcfind(path, lc->code, NiL, LC_MESSAGES, 0))
+ lc->flags |= LC_local;
+ lc->flags |= LC_checked;
+ }
+ if (!(lc->flags & LC_local))
+ return 0;
+ if (categories[category].external != -categories[category].internal)
+ setlocale(categories[category].external, lcmake(NiL)->name);
+ }
+ locales[category] = lc;
+ if (categories[category].setf && (*categories[category].setf)(&categories[category]))
+ {
+ locales[category] = categories[category].prev;
+ return 0;
+ }
+ if (lc->flags & LC_default)
+ ast.locale.set &= ~(1<<category);
+ else
+ ast.locale.set |= (1<<category);
+ }
+ return (char*)lc->name;
+}
+
+/*
+ * set composite AST_LC_ALL locale categories
+ * return <0:composite-error 0:not-composite >0:composite-ok
+ */
+
+static int
+composite(register const char* s, int initialize)
+{
+ register const char* t;
+ register int i;
+ register int j;
+ register int k;
+ int n;
+ const char* w;
+ Lc_t* p;
+ int cat[AST_LC_COUNT];
+ int stk[AST_LC_COUNT];
+ char buf[PATH_MAX / 2];
+
+ k = n = 0;
+ while (s[0] == 'L' && s[1] == 'C' && s[2] == '_')
+ {
+ n++;
+ j = 0;
+ w = s;
+ for (i = 1; i < AST_LC_COUNT; i++)
+ {
+ s = w;
+ t = categories[i].name;
+ while (*t && *s++ == *t++);
+ if (!*t && *s++ == '=')
+ {
+ cat[j++] = i;
+ if (s[0] != 'L' || s[1] != 'C' || s[2] != '_')
+ break;
+ w = s;
+ i = -1;
+ }
+ }
+ for (s = w; *s && *s != '='; s++);
+ if (!*s)
+ {
+ for (i = 0; i < k; i++)
+ single(stk[i], NiL);
+ return -1;
+ }
+ w = ++s;
+ for (;;)
+ {
+ if (!*s)
+ {
+ p = lcmake(w);
+ break;
+ }
+ else if (*s++ == ';')
+ {
+ if ((n = s - w - 1) >= sizeof(buf))
+ n = sizeof(buf) - 1;
+ memcpy(buf, w, n);
+ buf[n] = 0;
+ p = lcmake(buf);
+ break;
+ }
+ }
+ for (i = 0; i < j; i++)
+ if (!initialize)
+ {
+ if (!single(cat[i], p))
+ {
+ for (i = 0; i < k; i++)
+ single(stk[i], NiL);
+ return -1;
+ }
+ stk[k++] = cat[i];
+ }
+ else if (!categories[cat[i]].prev)
+ categories[cat[i]].prev = p;
+ }
+ while (s[0] == '/' && s[1] && n < AST_LC_COUNT)
+ {
+ n++;
+ for (w = ++s; *s && *s != '/'; s++);
+ if (!*s)
+ p = lcmake(w);
+ else
+ {
+ if ((j = s - w - 1) >= sizeof(buf))
+ j = sizeof(buf) - 1;
+ memcpy(buf, w, j);
+ buf[j] = 0;
+ p = lcmake(buf);
+ }
+ if (!initialize)
+ {
+ if (!single(n, p))
+ {
+ for (i = 1; i < n; i++)
+ single(i, NiL);
+ return -1;
+ }
+ }
+ else if (!categories[n].prev)
+ categories[n].prev = p;
+ }
+ return n;
+}
+
+/*
+ * setlocale() intercept
+ */
+
+char*
+_ast_setlocale(int category, const char* locale)
+{
+ register char* s;
+ register int i;
+ register int j;
+ int k;
+ char* a;
+ Lc_t* p;
+ int cat[AST_LC_COUNT];
+
+ static Sfio_t* sp;
+ static int initialized;
+ static char local[] = "local";
+
+ if ((category = lcindex(category, 0)) < 0)
+ return 0;
+ if (!locale)
+ {
+ /*
+ * return the current state
+ */
+
+ compose:
+ if (category != AST_LC_ALL)
+ return (char*)locales[category]->name;
+ if (!sp && !(sp = sfstropen()))
+ return 0;
+ for (i = 1; i < AST_LC_COUNT; i++)
+ cat[i] = -1;
+ for (i = 1, k = 0; i < AST_LC_COUNT; i++)
+ if (cat[i] < 0)
+ {
+ k++;
+ cat[i] = i;
+ for (j = i + 1; j < AST_LC_COUNT; j++)
+ if (locales[j] == locales[i])
+ cat[j] = i;
+ }
+ if (k == 1)
+ return (char*)locales[1]->name;
+ for (i = 1; i < AST_LC_COUNT; i++)
+ if (cat[i] >= 0 && !(locales[i]->flags & LC_default))
+ {
+ if (sfstrtell(sp))
+ sfprintf(sp, ";");
+ for (j = i, k = cat[i]; j < AST_LC_COUNT; j++)
+ if (cat[j] == k)
+ {
+ cat[j] = -1;
+ sfprintf(sp, "%s=", categories[j].name);
+ }
+ sfprintf(sp, "%s", locales[i]->name);
+ }
+ if (!sfstrtell(sp))
+ return (char*)locales[0]->name;
+ return sfstruse(sp);
+ }
+ if (!ast.locale.serial++)
+ stropt(getenv("LC_OPTIONS"), options, sizeof(*options), setopt, NiL);
+ if (!*locale)
+ {
+ if (!initialized)
+ {
+ char* u;
+ char tmp[256];
+
+ /*
+ * initialize from the environment
+ * precedence determined by X/Open
+ */
+
+ u = 0;
+ if (!(a = getenv("LC_ALL")) || !*a)
+ {
+ for (i = 1; i < AST_LC_COUNT; i++)
+ if ((s = getenv(categories[i].name)) && *s)
+ {
+ if (streq(s, local) && (u || (u = native_locale(locale, tmp, sizeof(tmp)))))
+ s = u;
+ categories[i].prev = lcmake(s);
+ }
+ a = getenv("LANG");
+ }
+ if (a)
+ {
+ if (streq(a, local) && (u || (u = native_locale(locale, tmp, sizeof(tmp)))))
+ a = u;
+ if (composite(a, 1))
+ a = 0;
+ }
+ p = 0;
+ for (i = 1; i < AST_LC_COUNT; i++)
+ {
+ if (!categories[i].prev)
+ {
+ if (!p && !(p = lcmake(a)))
+ break;
+ categories[i].prev = p;
+ }
+ if (!single(i, categories[i].prev))
+ {
+ while (i--)
+ single(i, NiL);
+ return 0;
+ }
+ }
+ if (ast.locale.set & AST_LC_debug)
+ for (i = 1; i < AST_LC_COUNT; i++)
+ sfprintf(sfstderr, "locale env %17s %s\n", categories[i].name, locales[i]->name);
+ initialized = 1;
+ }
+ goto compose;
+ }
+ else if (category != AST_LC_ALL)
+ return single(category, lcmake(locale));
+ else if (!(i = composite(locale, 0)))
+ {
+ if (!(p = lcmake(locale)))
+ return 0;
+ for (i = 1; i < AST_LC_COUNT; i++)
+ if (!single(i, p))
+ {
+ while (i--)
+ single(i, NiL);
+ return 0;
+ }
+ }
+ else if (i < 0)
+ return 0;
+ goto compose;
+}
diff --git a/usr/src/lib/libast/common/comp/setlogmask.c b/usr/src/lib/libast/common/comp/setlogmask.c
new file mode 100644
index 0000000000..35da3c3a7b
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/setlogmask.c
@@ -0,0 +1,48 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * syslog implementation
+ */
+
+#include <ast.h>
+
+#if _lib_syslog
+
+NoN(setlogmask)
+
+#else
+
+#include "sysloglib.h"
+
+int
+setlogmask(int mask)
+{
+ int old_mask;
+
+ old_mask = log.mask;
+ if (mask)
+ log.mask = mask;
+ return old_mask;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/setpgid.c b/usr/src/lib/libast/common/comp/setpgid.c
new file mode 100644
index 0000000000..7a5a2341c7
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/setpgid.c
@@ -0,0 +1,80 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_setpgid
+
+NoN(setpgid)
+
+#else
+
+#include <error.h>
+
+#ifndef ENOSYS
+#define ENOSYS EINVAL
+#endif
+
+#if _lib_setpgrp2
+#define setpgrp setpgrp2
+#else
+#if _lib_BSDsetpgrp
+#define _lib_setpgrp2 1
+#define setpgrp BSDsetpgrp
+#else
+#if _lib_wait3
+#define _lib_setpgrp2 1
+#endif
+#endif
+#endif
+
+#if _lib_setpgrp2
+extern int setpgrp(int, int);
+#else
+extern int setpgrp(void);
+#endif
+
+/*
+ * set process group id
+ */
+
+int
+setpgid(pid_t pid, pid_t pgid)
+{
+#if _lib_setpgrp2
+ return(setpgrp(pid, pgid));
+#else
+#if _lib_setpgrp
+ int caller = getpid();
+
+ if ((pid == 0 || pid == caller) && (pgid == 0 || pgid == caller))
+ return(setpgrp());
+ errno = EINVAL;
+#else
+ errno = ENOSYS;
+#endif
+ return(-1);
+#endif
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/setsid.c b/usr/src/lib/libast/common/comp/setsid.c
new file mode 100644
index 0000000000..3fffd606ec
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/setsid.c
@@ -0,0 +1,90 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_setsid
+
+NoN(setsid)
+
+#else
+
+#include <ast_tty.h>
+#include <error.h>
+
+/*
+ * become new process group leader and drop control tty
+ */
+
+pid_t
+setsid(void)
+{
+ int pg;
+#ifdef TIOCNOTTY
+ int fd;
+#endif
+
+ /*
+ * become a new process group leader
+ */
+
+ if ((pg = getpid()) == getpgrp())
+ {
+ errno = EPERM;
+ return(-1);
+ }
+ setpgid(pg, pg);
+#ifdef TIOCNOTTY
+
+ /*
+ * drop the control tty
+ */
+
+ if ((fd = open("/dev/tty", O_RDONLY)) >= 0)
+ {
+ ioctl(fd, TIOCNOTTY, 0);
+ close(fd);
+ }
+#else
+
+ /*
+ * second child in s5 to avoid reacquiring the control tty
+ */
+
+#if _lib_fork && HUH920711 /* some s5's botch this */
+ switch (fork())
+ {
+ case -1:
+ exit(1);
+ case 0:
+ break;
+ default:
+ exit(0);
+ }
+#endif
+
+#endif
+ return(pg);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/sigunblock.c b/usr/src/lib/libast/common/comp/sigunblock.c
new file mode 100644
index 0000000000..0163951d8a
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/sigunblock.c
@@ -0,0 +1,63 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_sigunblock
+
+NoN(sigunblock)
+
+#else
+
+#include <sig.h>
+
+#ifndef SIG_UNBLOCK
+#undef _lib_sigprocmask
+#endif
+
+int
+sigunblock(int s)
+{
+#if _lib_sigprocmask
+ int op;
+ sigset_t mask;
+
+ sigemptyset(&mask);
+ if (s)
+ {
+ sigaddset(&mask, s);
+ op = SIG_UNBLOCK;
+ }
+ else op = SIG_SETMASK;
+ return(sigprocmask(op, &mask, NiL));
+#else
+#if _lib_sigsetmask
+ return(sigsetmask(s ? (sigsetmask(0L) & ~sigmask(s)) : 0L));
+#else
+ NoP(s);
+ return(0);
+#endif
+#endif
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/spawnveg.c b/usr/src/lib/libast/common/comp/spawnveg.c
new file mode 100644
index 0000000000..fd6768c6b9
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/spawnveg.c
@@ -0,0 +1,270 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * spawnveg -- spawnve with process group or session control
+ *
+ * pgid <0 setsid() [session group leader]
+ * 0 nothing [retain session and process group]
+ * 1 setpgid(0,0) [process group leader]
+ * >1 setpgid(0,pgid) [join process group]
+ */
+
+#include <ast.h>
+
+#if _lib_spawnveg
+
+NoN(spawnveg)
+
+#else
+
+#if _lib_posix_spawn > 1 /* reports underlying exec() errors */
+
+#include <spawn.h>
+#include <error.h>
+#include <wait.h>
+
+pid_t
+spawnveg(const char* path, char* const argv[], char* const envv[], pid_t pgid)
+{
+ int err;
+ pid_t pid;
+ posix_spawnattr_t attr;
+
+ if (err = posix_spawnattr_init(&attr))
+ goto bad;
+ if (pgid)
+ {
+ if (pgid <= 1)
+ pgid = 0;
+ if (err = posix_spawnattr_setpgroup(&attr, pgid))
+ goto bad;
+ if (err = posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETPGROUP))
+ goto bad;
+ }
+ if (err = posix_spawn(&pid, path, NiL, &attr, argv, envv ? envv : environ))
+ goto bad;
+ posix_spawnattr_destroy(&attr);
+#if _lib_posix_spawn < 2
+ if (waitpid(pid, &err, WNOHANG|WNOWAIT) == pid && EXIT_STATUS(err) == 127)
+ {
+ while (waitpid(pid, NiL, 0) == -1 && errno == EINTR);
+ if (!access(path, X_OK))
+ errno = ENOEXEC;
+ pid = -1;
+ }
+#endif
+ return pid;
+ bad:
+ errno = err;
+ return -1;
+}
+
+#else
+
+#if _lib_spawn_mode
+
+#include <process.h>
+
+#ifndef P_NOWAIT
+#define P_NOWAIT _P_NOWAIT
+#endif
+#ifndef P_DETACH
+#define P_DETACH _P_DETACH
+#endif
+
+pid_t
+spawnveg(const char* path, char* const argv[], char* const envv[], pid_t pgid)
+{
+ return spawnve(pgid ? P_DETACH : P_NOWAIT, path, argv, envv ? envv : environ);
+}
+
+#else
+
+#if _lib_spawn && _hdr_spawn && _mem_pgroup_inheritance
+
+#include <spawn.h>
+
+/*
+ * open-edition/mvs/zos fork+exec+(setpgid)
+ */
+
+pid_t
+spawnveg(const char* path, char* const argv[], char* const envv[], pid_t pgid)
+{
+ struct inheritance inherit;
+
+ inherit.flags = 0;
+ if (pgid)
+ {
+ inherit.flags |= SPAWN_SETGROUP;
+ inherit.pgroup = (pgid > 1) ? pgid : SPAWN_NEWPGROUP;
+ }
+ return spawn(path, 0, (int*)0, &inherit, (const char**)argv, (const char**)envv);
+}
+
+#else
+
+#include <error.h>
+#include <wait.h>
+#include <sig.h>
+#include <ast_vfork.h>
+
+#ifndef ENOSYS
+#define ENOSYS EINVAL
+#endif
+
+#if _lib_spawnve && _hdr_process
+#include <process.h>
+#if defined(P_NOWAIT) || defined(_P_NOWAIT)
+#undef _lib_spawnve
+#endif
+#endif
+
+#if !_lib_vfork
+#undef _real_vfork
+#endif
+
+/*
+ * fork+exec+(setsid|setpgid)
+ */
+
+pid_t
+spawnveg(const char* path, char* const argv[], char* const envv[], pid_t pgid)
+{
+#if _lib_fork || _lib_vfork
+ int n;
+ int m;
+ pid_t pid;
+ pid_t rid;
+#if _real_vfork
+ volatile int exec_errno;
+ volatile int* volatile exec_errno_ptr;
+#else
+ int err[2];
+#endif
+#endif
+
+#if 0
+ if (access(path, X_OK))
+ return -1;
+#endif
+ if (!envv)
+ envv = environ;
+#if _lib_spawnve
+#if _lib_fork || _lib_vfork
+ if (!pgid)
+#endif
+ return spawnve(path, argv, envv);
+#endif
+#if _lib_fork || _lib_vfork
+ n = errno;
+#if _real_vfork
+ exec_errno = 0;
+ exec_errno_ptr = &exec_errno;
+#else
+ if (pipe(err) < 0)
+ err[0] = -1;
+ else
+ {
+ fcntl(err[0], F_SETFD, FD_CLOEXEC);
+ fcntl(err[1], F_SETFD, FD_CLOEXEC);
+ }
+#endif
+ sigcritical(1);
+#if _lib_vfork
+ pid = vfork();
+#else
+ pid = fork();
+#endif
+ sigcritical(0);
+ if (!pid)
+ {
+ if (pgid < 0)
+ setsid();
+ else if (pgid > 0)
+ {
+ if (pgid == 1)
+ pgid = 0;
+ if (setpgid(0, pgid) < 0 && pgid && errno == EPERM)
+ setpgid(0, 0);
+ }
+ execve(path, argv, envv);
+#if _real_vfork
+ *exec_errno_ptr = errno;
+#else
+ if (err[0] != -1)
+ {
+ n = errno;
+ write(err[1], &n, sizeof(n));
+ }
+#endif
+ _exit(errno == ENOENT ? EXIT_NOTFOUND : EXIT_NOEXEC);
+ }
+ rid = pid;
+#if _real_vfork
+ if (pid != -1 && (m = *exec_errno_ptr))
+ {
+ while (waitpid(pid, NiL, 0) == -1 && errno == EINTR);
+ rid = pid = -1;
+ n = m;
+ }
+#else
+ if (pid != -1 && err[0] != -1)
+ {
+ close(err[1]);
+ if (read(err[0], &m, sizeof(m)) == sizeof(m) && m)
+ {
+ while (waitpid(pid, NiL, 0) == -1 && errno == EINTR);
+ rid = pid = -1;
+ n = m;
+ }
+ close(err[0]);
+ }
+#endif
+ if (pid != -1 && pgid > 0)
+ {
+ /*
+ * parent and child are in a race here
+ */
+
+ if (pgid == 1)
+ pgid = pid;
+ if (setpgid(pid, pgid) < 0 && pid != pgid && errno == EPERM)
+ setpgid(pid, pid);
+ }
+ errno = n;
+ return rid;
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+}
+
+#endif
+
+#endif
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/statvfs.c b/usr/src/lib/libast/common/comp/statvfs.c
new file mode 100644
index 0000000000..3ba4c56c95
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/statvfs.c
@@ -0,0 +1,163 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+#include <ls.h>
+
+#if _lib_statvfs
+
+NoN(statvfs)
+
+#else
+
+#include <error.h>
+
+#define HUH (-1)
+
+#if _lib_statfs && _mem_f_files_statfs && ( _sys_statfs || _sys_vfs || _sys_mount )
+
+#if _sys_statfs
+#include <sys/statfs.h>
+#else
+#if _sys_vfs
+#include <sys/vfs.h>
+#else
+#if _sys_mount
+#if _lib_getmntinfo
+#include <sys/param.h> /* expect some macro redefinitions here */
+#endif
+#include <sys/mount.h>
+#endif
+#endif
+#endif
+
+#if _lib_statfs4
+#define FSTATFS(a,b) fstatfs(a,b,sizeof(struct statfs),0)
+#define STATFS(a,b) statfs(a,b,sizeof(struct statfs),0)
+#else
+#define FSTATFS(a,b) fstatfs(a,b)
+#define STATFS(a,b) statfs(a,b)
+#endif
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+static void
+us2v(register struct statfs* ufs, register struct stat* st, register struct statvfs* vfs)
+{
+ memset(vfs, 0, sizeof(*vfs));
+ vfs->f_bsize = vfs->f_frsize = ufs->f_bsize;
+ vfs->f_blocks = ufs->f_blocks;
+ vfs->f_bfree = ufs->f_bfree;
+ vfs->f_bavail =
+#if _mem_f_bavail_statfs
+ ufs->f_bavail;
+#else
+ ufs->f_bfree;
+#endif
+ vfs->f_files = ufs->f_files;
+ vfs->f_ffree = ufs->f_ffree;
+ vfs->f_favail = (ufs->f_ffree > 10) ? (ufs->f_ffree - 10) : 0;
+ vfs->f_fsid = st->st_dev;
+ strncpy(vfs->f_basetype, FS_default, sizeof(vfs->f_basetype) - 1);
+ vfs->f_namemax = 14;
+ strncpy(vfs->f_fstr, vfs->f_basetype, sizeof(vfs->f_fstr) - 1);
+}
+
+extern int
+fstatvfs(int fd, struct statvfs* vfs)
+{
+ struct statfs ufs;
+ struct stat st;
+
+ if (FSTATFS(fd, &ufs) || fstat(fd, &st))
+ return(-1);
+ us2v(&ufs, &st, vfs);
+ return(0);
+}
+
+extern int
+statvfs(const char* path, struct statvfs* vfs)
+{
+ struct statfs ufs;
+ struct stat st;
+
+ if (STATFS(path, &ufs) || stat(path, &st))
+ return(-1);
+ us2v(&ufs, &st, vfs);
+ return(0);
+}
+
+#else
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+static void
+s2v(register struct stat* st, register struct statvfs* vfs)
+{
+ memset(vfs, 0, sizeof(*vfs));
+ vfs->f_bsize = vfs->f_frsize =
+#if _mem_st_blksize_stat
+ st->st_blksize;
+#else
+ 512;
+#endif
+ vfs->f_blocks = HUH;
+ vfs->f_bfree = HUH;
+ vfs->f_files = HUH;
+ vfs->f_ffree = HUH;
+ vfs->f_favail = HUH;
+ vfs->f_fsid = st->st_dev;
+ strncpy(vfs->f_basetype, FS_default, sizeof(vfs->f_basetype) - 1);
+ vfs->f_namemax = 14;
+ strncpy(vfs->f_fstr, vfs->f_basetype, sizeof(vfs->f_fstr) - 1);
+}
+
+extern int
+fstatvfs(int fd, struct statvfs* vfs)
+{
+ struct stat st;
+
+ if (fstat(fd, &st))
+ return(-1);
+ s2v(&st, vfs);
+ return(0);
+}
+
+extern int
+statvfs(const char* path, struct statvfs* vfs)
+{
+ struct stat st;
+
+ if (stat(path, &st))
+ return(-1);
+ s2v(&st, vfs);
+ return(0);
+}
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/strcasecmp.c b/usr/src/lib/libast/common/comp/strcasecmp.c
new file mode 100644
index 0000000000..42e170a055
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/strcasecmp.c
@@ -0,0 +1,58 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_strcasecmp
+
+NoN(strcasecmp)
+
+#else
+
+#include <ctype.h>
+
+#undef strcasecmp
+
+int
+strcasecmp(register const char* a, register const char* b)
+{
+ register int ac;
+ register int bc;
+ register int d;
+
+ for (;;)
+ {
+ ac = *a++;
+ if (isupper(ac))
+ ac = tolower(ac);
+ bc = *b++;
+ if (isupper(bc))
+ bc = tolower(bc);
+ if (d = ac - bc)
+ return d;
+ if (!ac)
+ return 0;
+ }
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/strchr.c b/usr/src/lib/libast/common/comp/strchr.c
new file mode 100644
index 0000000000..aa09c3be5d
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/strchr.c
@@ -0,0 +1,57 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_strchr
+
+NoN(strchr)
+
+#else
+
+#undef strchr
+
+#if _lib_index
+
+#undef index
+
+extern char* index(const char*, int);
+
+char*
+strchr(const char* s, int c)
+{
+ return(index(s, c));
+}
+
+#else
+
+char*
+strchr(register const char* s, register int c)
+{
+ do if (*s == c) return((char*)s); while(*s++);
+ return(0);
+}
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/strftime.c b/usr/src/lib/libast/common/comp/strftime.c
new file mode 100644
index 0000000000..737f93fe95
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/strftime.c
@@ -0,0 +1,104 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * strftime implementation
+ */
+
+#define strftime ______strftime
+
+#include <ast.h>
+#include <tm.h>
+
+#undef strftime
+
+#undef _def_map_ast
+#include <ast_map.h>
+
+#undef _lib_strftime /* we can pass X/Open */
+
+#if _lib_strftime
+
+NoN(strftime)
+
+#else
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern size_t
+strftime(char* buf, size_t len, const char* format, const struct tm* tm)
+{
+ register char* s;
+ time_t t;
+ Tm_t tl;
+
+ memset(&tl, 0, sizeof(tl));
+
+ /*
+ * nl_langinfo() may call strftime() with bogus tm except for
+ * one value -- what a way to go
+ */
+
+ if (tm->tm_sec < 0 || tm->tm_sec > 60 ||
+ tm->tm_min < 0 || tm->tm_min > 59 ||
+ tm->tm_hour < 0 || tm->tm_hour > 23 ||
+ tm->tm_wday < 0 || tm->tm_wday > 6 ||
+ tm->tm_mday < 1 || tm->tm_mday > 31 ||
+ tm->tm_mon < 0 || tm->tm_mon > 11 ||
+ tm->tm_year < 0 || tm->tm_year > (2138 - 1900))
+ {
+ if (tm->tm_sec >= 0 && tm->tm_sec <= 60)
+ tl.tm_sec = tm->tm_sec;
+ if (tm->tm_min >= 0 && tm->tm_min <= 59)
+ tl.tm_min = tm->tm_min;
+ if (tm->tm_hour >= 0 && tm->tm_hour <= 23)
+ tl.tm_hour = tm->tm_hour;
+ if (tm->tm_wday >= 0 && tm->tm_wday <= 6)
+ tl.tm_wday = tm->tm_wday;
+ if (tm->tm_mday >= 0 && tm->tm_mday <= 31)
+ tl.tm_mday = tm->tm_mday;
+ if (tm->tm_mon >= 0 && tm->tm_mon <= 11)
+ tl.tm_mon = tm->tm_mon;
+ if (tm->tm_year >= 0 && tm->tm_year <= (2138 - 1900))
+ tl.tm_year = tm->tm_year;
+ }
+ else
+ {
+ tl.tm_sec = tm->tm_sec;
+ tl.tm_min = tm->tm_min;
+ tl.tm_hour = tm->tm_hour;
+ tl.tm_mday = tm->tm_mday;
+ tl.tm_mon = tm->tm_mon;
+ tl.tm_year = tm->tm_year;
+ tl.tm_wday = tm->tm_wday;
+ tl.tm_yday = tm->tm_yday;
+ tl.tm_isdst = tm->tm_isdst;
+ }
+ t = tmtime(&tl, TM_LOCALZONE);
+ if (!(s = tmfmt(buf, len, format, &t)))
+ return 0;
+ return s - buf;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/strncasecmp.c b/usr/src/lib/libast/common/comp/strncasecmp.c
new file mode 100644
index 0000000000..a49159154e
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/strncasecmp.c
@@ -0,0 +1,62 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_strncasecmp
+
+NoN(strncasecmp)
+
+#else
+
+#include <ctype.h>
+
+#undef strncasecmp
+
+int
+strncasecmp(register const char* a, register const char* b, size_t n)
+{
+ register const char* e;
+ register int ac;
+ register int bc;
+ register int d;
+
+ e = a + n;
+ for (;;)
+ {
+ if (a >= e)
+ return 0;
+ ac = *a++;
+ if (isupper(ac))
+ ac = tolower(ac);
+ bc = *b++;
+ if (isupper(bc))
+ bc = tolower(bc);
+ if (d = ac - bc)
+ return d;
+ if (!ac)
+ return 0;
+ }
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/strptime.c b/usr/src/lib/libast/common/comp/strptime.c
new file mode 100644
index 0000000000..14f9c5afe8
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/strptime.c
@@ -0,0 +1,82 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * strptime implementation
+ */
+
+#define strptime ______strptime
+
+#include <ast.h>
+#include <tm.h>
+
+#undef strptime
+
+#undef _def_map_ast
+#include <ast_map.h>
+
+#if _lib_strptime
+
+NoN(strptime)
+
+#else
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern char*
+strptime(const char* s, const char* format, struct tm* ts)
+{
+ char* e;
+ char* f;
+ time_t t;
+ Tm_t tm;
+ Tm_t* tn;
+
+ tm.tm_sec = ts->tm_sec;
+ tm.tm_min = ts->tm_min;
+ tm.tm_hour = ts->tm_hour;
+ tm.tm_mday = ts->tm_mday;
+ tm.tm_mon = ts->tm_mon;
+ tm.tm_year = ts->tm_year;
+ tm.tm_wday = ts->tm_wday;
+ tm.tm_yday = ts->tm_yday;
+ tm.tm_isdst = ts->tm_isdst;
+ t = tmtime(&tm, TM_LOCALZONE);
+ t = tmscan(s, &e, format, &f, &t, 0);
+ if (e == (char*)s || *f)
+ return 0;
+ tn = tmmake(&t);
+ ts->tm_sec = tn->tm_sec;
+ ts->tm_min = tn->tm_min;
+ ts->tm_hour = tn->tm_hour;
+ ts->tm_mday = tn->tm_mday;
+ ts->tm_mon = tn->tm_mon;
+ ts->tm_year = tn->tm_year;
+ ts->tm_wday = tn->tm_wday;
+ ts->tm_yday = tn->tm_yday;
+ ts->tm_isdst = tn->tm_isdst;
+ return e;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/strrchr.c b/usr/src/lib/libast/common/comp/strrchr.c
new file mode 100644
index 0000000000..22aab17068
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/strrchr.c
@@ -0,0 +1,60 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_strrchr
+
+NoN(strrchr)
+
+#else
+
+#undef strrchr
+
+#if _lib_rindex
+
+#undef rindex
+
+extern char* rindex(const char*, int);
+
+char*
+strrchr(const char* s, int c)
+{
+ return(rindex(s, c));
+}
+
+#else
+
+char*
+strrchr(register const char* s, register int c)
+{
+ register const char* r;
+
+ r = 0;
+ do if (*s == c) r = s; while(*s++);
+ return((char*)r);
+}
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/strstr.c b/usr/src/lib/libast/common/comp/strstr.c
new file mode 100644
index 0000000000..ea4b78dc40
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/strstr.c
@@ -0,0 +1,76 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide strstr
+#else
+#define strstr ______strstr
+#endif
+
+#include <ast.h>
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide strstr
+#else
+#undef strstr
+#endif
+
+#if _lib_strstr
+
+NoN(strstr)
+
+#else
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern char*
+strstr(register const char* s1, register const char* s2)
+{
+ register int c1;
+ register int c2;
+ register const char* t1;
+ register const char* t2;
+
+ if (s2)
+ {
+ if (!*s2)
+ return (char*)s1;
+ c2 = *s2++;
+ while (c1 = *s1++)
+ if (c1 == c2)
+ {
+ t1 = s1;
+ t2 = s2;
+ do
+ {
+ if (!*t2)
+ return (char*)s1 - 1;
+ } while (*t1++ == *t2++);
+ }
+ }
+ return 0;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/strtod.c b/usr/src/lib/libast/common/comp/strtod.c
new file mode 100644
index 0000000000..5c3af99fac
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/strtod.c
@@ -0,0 +1,31 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * strtod() implementation
+ */
+
+#include <ast.h>
+
+#define S2F_function strtod
+#define S2F_type 1
+
+#include "sfstrtof.h"
diff --git a/usr/src/lib/libast/common/comp/strtol.c b/usr/src/lib/libast/common/comp/strtol.c
new file mode 100644
index 0000000000..428baf4cb7
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/strtol.c
@@ -0,0 +1,34 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * strtol() implementation
+ */
+
+#if ! __CYGWIN__ /* 1.3.* static link conflict -- no iffe for this yet */
+
+#define S2I_function strtol
+#define S2I_number long
+#define S2I_unumber unsigned long
+
+#include "strtoi.h"
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/strtold.c b/usr/src/lib/libast/common/comp/strtold.c
new file mode 100644
index 0000000000..3d14b6a810
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/strtold.c
@@ -0,0 +1,43 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * strtold() implementation
+ */
+
+#define S2F_function strtold
+#define S2F_type 2
+
+/*
+ * ast strtold() => strtod() when double == long double
+ */
+
+#define _AST_STD_H 1
+#define strtold ______strtold
+
+#include <ast_common.h>
+#include <ast_lib.h>
+#include <ast_sys.h>
+
+#undef strtold
+#undef _AST_STD_H
+
+#include "sfstrtof.h"
diff --git a/usr/src/lib/libast/common/comp/strtoll.c b/usr/src/lib/libast/common/comp/strtoll.c
new file mode 100644
index 0000000000..fadcfc0033
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/strtoll.c
@@ -0,0 +1,44 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * strtoll() implementation
+ */
+
+#define strtoll ______strtoll
+
+#include <ast.h>
+
+#undef strtoll
+
+#if !_UWIN
+
+#undef _def_map_ast
+
+#include <ast_map.h>
+
+#endif
+
+#define S2I_function strtoll
+#define S2I_number intmax_t
+#define S2I_unumber uintmax_t
+
+#include "strtoi.h"
diff --git a/usr/src/lib/libast/common/comp/strtoul.c b/usr/src/lib/libast/common/comp/strtoul.c
new file mode 100644
index 0000000000..68fede797d
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/strtoul.c
@@ -0,0 +1,35 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * strtoul() implementation
+ */
+
+#if ! __CYGWIN__ /* 1.3.* static link conflict -- no iffe for this yet */
+
+#define S2I_function strtoul
+#define S2I_number long
+#define S2I_unumber unsigned long
+#define S2I_unsigned 1
+
+#include "strtoi.h"
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/strtoull.c b/usr/src/lib/libast/common/comp/strtoull.c
new file mode 100644
index 0000000000..5860a07c69
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/strtoull.c
@@ -0,0 +1,45 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * strtoull() implementation
+ */
+
+#define strtoull ______strtoull
+
+#include <ast.h>
+
+#undef strtoull
+
+#if !_UWIN
+
+#undef _def_map_ast
+
+#include <ast_map.h>
+
+#endif
+
+#define S2I_function strtoull
+#define S2I_number intmax_t
+#define S2I_unumber uintmax_t
+#define S2I_unsigned 1
+
+#include "strtoi.h"
diff --git a/usr/src/lib/libast/common/comp/swab.c b/usr/src/lib/libast/common/comp/swab.c
new file mode 100644
index 0000000000..9251572149
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/swab.c
@@ -0,0 +1,60 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * swab implementation
+ */
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide swab
+#else
+#define swab ______swab
+#endif
+
+#include <ast.h>
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide swab
+#else
+#undef swab
+#endif
+
+#if _lib_swab
+
+NoN(swab)
+
+#else
+
+#include <swap.h>
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern void
+swab(const void* src, void* dst, ssize_t n)
+{
+ if (n > 1)
+ swapmem(1, src, dst, n & ~1);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/symlink.c b/usr/src/lib/libast/common/comp/symlink.c
new file mode 100644
index 0000000000..0e27c426b8
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/symlink.c
@@ -0,0 +1,59 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_symlink
+
+NoN(symlink)
+
+#else
+
+#include "fakelink.h"
+
+#include <error.h>
+
+#ifndef ENOSYS
+#define ENOSYS EINVAL
+#endif
+
+int
+symlink(const char* a, char* b)
+{
+ if (*a == '/' && (*(a + 1) == 'd' || *(a + 1) == 'p' || *(a + 1) == 'n') && (!strncmp(a, "/dev/tcp/", 9) || !strncmp(a, "/dev/udp/", 9) || !strncmp(a, "/proc/", 6) || !strncmp(a, "/n/", 3)))
+ {
+ int n;
+ int fd;
+
+ if ((fd = open(b, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) < 0)
+ return -1;
+ n = strlen(a) + 1;
+ n = (write(fd, FAKELINK_MAGIC, sizeof(FAKELINK_MAGIC)) != sizeof(FAKELINK_MAGIC) || write(fd, a, n) != n) ? -1 : 0;
+ close(fd);
+ return n;
+ }
+ errno = ENOSYS;
+ return -1;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/syslog.c b/usr/src/lib/libast/common/comp/syslog.c
new file mode 100644
index 0000000000..d210299e27
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/syslog.c
@@ -0,0 +1,363 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * syslog implementation
+ */
+
+#include <ast.h>
+
+#if _lib_syslog
+
+NoN(syslog)
+
+#else
+
+#define LOG_TABLES
+
+#include "sysloglib.h"
+
+#include <error.h>
+#include <tm.h>
+
+Syslog_state_t log = { LOG_USER, -1, 0, ~0 };
+
+static const Namval_t attempt[] =
+{
+ "/dev/log", 0,
+ "lib/syslog/log", 0,
+ "/dev/console", LOG_CONS,
+};
+
+const Namval_t log_facility[] =
+{
+ "default", 0,
+ "user", LOG_USER,
+ "kernel", LOG_KERN,
+ "mail", LOG_MAIL,
+ "daemon", LOG_DAEMON,
+ "security", LOG_AUTH,
+ "syslog", LOG_SYSLOG,
+ "lpr", LOG_LPR,
+ "news", LOG_NEWS,
+ "uucp", LOG_UUCP,
+ "cron", LOG_CRON,
+ "audit", LOG_AUDIT,
+ "logalert", LOG_LFMT,
+#ifdef LOG_SYSTEM2
+ "system2", LOG_SYSTEM2,
+#endif
+#ifdef LOG_SYSTEM1
+ "system1", LOG_SYSTEM1,
+#endif
+#ifdef LOG_SYSTEM0
+ "system0", LOG_SYSTEM0,
+#endif
+ 0, 0
+};
+
+const Namval_t log_severity[] =
+{
+ "panic", LOG_EMERG,
+ "alert", LOG_ALERT,
+ "critical", LOG_CRIT,
+ "error", LOG_ERR,
+ "warning", LOG_WARNING,
+ "notice", LOG_NOTICE,
+ "info", LOG_INFO,
+ "debug", LOG_DEBUG,
+ 0, 0
+};
+
+#if _UWIN
+
+/*
+ * open /dev/(fdp|tcp|udp)/HOST/SERVICE for read
+ */
+
+#include <ctype.h>
+#include <ls.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <netdb.h>
+#include <netinet/in.h>
+
+#if !defined(htons) && !_lib_htons
+# define htons(x) (x)
+#endif
+#if !defined(htonl) && !_lib_htonl
+# define htonl(x) (x)
+#endif
+
+#ifndef INADDR_LOOPBACK
+#define INADDR_LOOPBACK 0x7f000001L
+#endif
+
+/*
+ * convert s to sockaddr_in
+ * -1 returned on error
+ */
+
+static int
+str2inet(register char* s, char* prot, struct sockaddr_in* addr)
+{
+ register int c;
+ register int v;
+ register int n = 0;
+ unsigned long a = 0;
+ unsigned short p = 0;
+
+ if (!memcmp(s, "local/", 6))
+ {
+ a = INADDR_LOOPBACK;
+ n = 4;
+ s += 6;
+ }
+ else if (!isdigit(*s))
+ {
+ struct hostent* hp;
+ char* e = strchr(s, '/');
+
+ if (!(e = strchr(s, '/')))
+ return -1;
+ *e = 0;
+ hp = gethostbyname(s);
+ *e = '/';
+ if (!hp || hp->h_addrtype != AF_INET || hp->h_length > sizeof(struct in_addr))
+ return -1;
+ a = (unsigned long)((struct in_addr*)hp->h_addr)->s_addr;
+ n = 6;
+ s = e + 1;
+ }
+ for (;;)
+ {
+ v = 0;
+ while ((c = *s++) >= '0' && c <= '9')
+ v = v * 10 + c - '0';
+ if (++n <= 4)
+ a = (a << 8) | (v & 0xff);
+ else
+ {
+ if (n <= 5)
+ a = htonl(a);
+ if (c)
+ {
+ struct servent* sp;
+
+ if (!(sp = getservbyname(s - 1, prot)))
+ return -1;
+ p = sp->s_port;
+ }
+ else
+ p = htons(v);
+ break;
+ }
+ if (c != '.' && c != '/')
+ return -1;
+ }
+ memset((char*)addr, 0, sizeof(*addr));
+ addr->sin_family = AF_INET;
+ addr->sin_addr.s_addr = a;
+ addr->sin_port = p;
+ return 0;
+}
+
+/*
+ * call this after open fails to see if path is a socket
+ */
+
+int
+sockopen(const char* path)
+{
+ int fd;
+ struct sockaddr_in addr;
+ char buf[PATH_MAX];
+
+ if (pathgetlink(path, buf, sizeof(buf)) <= 0)
+ {
+ if (strlen(path) >= sizeof(buf))
+ return -1;
+ strcpy(buf, path);
+ }
+#if LOCAL
+ {
+ int ul;
+ struct sockaddr_un ua;
+ struct stat st;
+
+ if ((ul = strlen(buf)) < sizeof(ua.sun_path) && !stat(buf, &st) && S_ISSOCK(st.st_mode))
+ {
+ if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
+ return -1;
+ ua.sun_family = AF_UNIX;
+ strcpy(ua.sun_path, buf);
+ ul += sizeof(ua.sun_family) + 1;
+ if (!connect(fd, (struct sockaddr*)&ua, ul))
+ return fd;
+ close(fd);
+ return -1;
+ }
+ }
+#endif
+ if (!strmatch(buf, "/dev/(tcp|udp)/*/*"))
+ return -1;
+ buf[8] = 0;
+ if (str2inet(buf + 9, buf + 5, &addr))
+ return -1;
+ if ((fd = socket(AF_INET, buf[5] == 't' ? SOCK_STREAM : SOCK_DGRAM, 0)) < 0)
+ return -1;
+ if (connect(fd, (struct sockaddr*)&addr, sizeof(addr)))
+ {
+ close(fd);
+ return -1;
+ }
+ return fd;
+}
+
+#else
+
+int
+sockopen(const char* path)
+{
+ return -1;
+}
+
+#endif
+
+void
+sendlog(const char* msg)
+{
+ register char* s;
+ register Namval_t* p;
+ register int n;
+
+ n = msg ? strlen(msg) : 0;
+ for (;;)
+ {
+ if (log.fd < 0)
+ {
+ char buf[PATH_MAX];
+
+ if (log.attempt >= elementsof(attempt))
+ break;
+ p = (Namval_t*)&attempt[log.attempt++];
+ if (p->value && !(p->value & log.flags))
+ continue;
+ if (*(s = p->name) != '/' && !(s = pathpath(buf, s, "", PATH_REGULAR|PATH_READ)))
+ continue;
+ if ((log.fd = open(s, O_WRONLY|O_APPEND|O_NOCTTY)) < 0 && (log.fd = sockopen(s)) < 0)
+ continue;
+ fcntl(log.fd, F_SETFD, FD_CLOEXEC);
+ }
+ if (!n || write(log.fd, msg, n) > 0)
+ break;
+ close(log.fd);
+ log.fd = -1;
+ }
+ if (n && (log.flags & LOG_PERROR))
+ write(2, msg, n);
+}
+
+static int
+extend(Sfio_t* sp, void* vp, Sffmt_t* dp)
+{
+ if (dp->fmt == 'm')
+ {
+ dp->flags |= SFFMT_VALUE;
+ dp->fmt = 's';
+ dp->size = -1;
+ *((char**)vp) = fmterror(errno);
+ }
+ return 0;
+}
+
+void
+vsyslog(int priority, const char* format, va_list ap)
+{
+ register int c;
+ register char* s;
+ Sfio_t* sp;
+ Sffmt_t fmt;
+ char buf[16];
+
+ if (!LOG_FACILITY(priority))
+ priority |= log.facility;
+ if (!(priority & log.mask))
+ return;
+ if (sp = sfstropen())
+ {
+ sfputr(sp, fmttime("%b %d %H:%M:%S", time(NiL)), -1);
+ if (log.flags & LOG_LEVEL)
+ {
+ if ((c = LOG_SEVERITY(priority)) < elementsof(log_severity))
+ s = (char*)log_severity[c].name;
+ else
+ sfsprintf(s = buf, sizeof(buf), "debug%d", c);
+ sfprintf(sp, " %-8s ", s);
+ if ((c = LOG_FACILITY(priority)) < elementsof(log_facility))
+ s = (char*)log_facility[c].name;
+ else
+ sfsprintf(s = buf, sizeof(buf), "local%d", c);
+ sfprintf(sp, " %-8s ", s);
+ }
+#if _lib_gethostname
+ if (!*log.host && gethostname(log.host, sizeof(log.host)-1))
+ strcpy(log.host, "localhost");
+ sfprintf(sp, " %s", log.host);
+#endif
+ if (*log.ident)
+ sfprintf(sp, " %s", log.ident);
+ if (log.flags & LOG_PID)
+ {
+ if (!*log.ident)
+ sfprintf(sp, " ");
+ sfprintf(sp, "[%d]", getpid());
+ }
+ if (format)
+ {
+ sfprintf(sp, ": ");
+ memset(&fmt, 0, sizeof(fmt));
+ fmt.version = SFIO_VERSION;
+ fmt.form = (char*)format;
+ fmt.extf = extend;
+ va_copy(fmt.args, ap);
+ sfprintf(sp, "%!", &fmt);
+ }
+ if ((s = sfstrseek(sp, 0, SEEK_CUR)) && *(s - 1) != '\n')
+ sfputc(sp, '\n');
+ if (s = sfstruse(sp))
+ sendlog(s);
+ sfstrclose(sp);
+ }
+}
+
+void
+syslog(int priority, const char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ vsyslog(priority, format, ap);
+ va_end(ap);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/system.c b/usr/src/lib/libast/common/comp/system.c
new file mode 100644
index 0000000000..c5424f9721
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/system.c
@@ -0,0 +1,55 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * ast library system(3)
+ */
+
+#define system ______system
+
+#define _STDLIB_H_ 1 /* uwin workaround */
+
+#include <ast.h>
+#include <proc.h>
+
+#undef system
+
+#undef _def_map_ast
+#include <ast_map.h>
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int
+system(const char* cmd)
+{
+ char* sh[4];
+
+ if (!cmd)
+ return !eaccess(pathshell(), X_OK);
+ sh[0] = "sh";
+ sh[1] = "-c";
+ sh[2] = (char*)cmd;
+ sh[3] = 0;
+ return procrun(NiL, sh);
+}
diff --git a/usr/src/lib/libast/common/comp/tempnam.c b/usr/src/lib/libast/common/comp/tempnam.c
new file mode 100644
index 0000000000..a90aecec19
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/tempnam.c
@@ -0,0 +1,58 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * tempnam implementation
+ */
+
+#include <ast_std.h>
+
+#ifdef tempnam
+#define _def_tempnam 1
+#else
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide tempnam
+#else
+#define tempnam ______tempnam
+#endif
+#endif
+
+#include <ast.h>
+#include <stdio.h>
+
+#if !_def_tempnam
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide tempnam
+#else
+#undef tempnam
+#endif
+#endif
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern char*
+tempnam(const char* dir, const char* pfx)
+{
+ return pathtmp(NiL, dir, pfx, NiL);
+}
diff --git a/usr/src/lib/libast/common/comp/tmpnam.c b/usr/src/lib/libast/common/comp/tmpnam.c
new file mode 100644
index 0000000000..46940f4460
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/tmpnam.c
@@ -0,0 +1,51 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * tmpnam implementation
+ */
+
+#define tmpnam ______tmpnam
+
+#include <ast.h>
+#include <stdio.h>
+
+#undef tmpnam
+
+#undef _def_map_ast
+#include <ast_map.h>
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+#ifndef L_tmpnam
+#define L_tmpnam 25
+#endif
+
+extern char*
+tmpnam(char* s)
+{
+ static char buf[L_tmpnam];
+
+ return pathtemp(s ? s : buf, L_tmpnam, NiL, "tn", NiL);
+}
diff --git a/usr/src/lib/libast/common/comp/transition.c b/usr/src/lib/libast/common/comp/transition.c
new file mode 100644
index 0000000000..2d29d5a2dd
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/transition.c
@@ -0,0 +1,86 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * transient code to aid transition between releases
+ */
+
+#include <ast.h>
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+#define STUB 1
+
+/*
+ * 2006-09-28
+ *
+ * on some systems the _std_strtol iffe changed (due to a faulty
+ * test prototype) and the cause programs dynamically linked to
+ * an updated -last to fail at runtime with missing _ast_strtol etc.
+ */
+
+#if !_std_strtol
+
+#ifndef strtol
+#undef STUB
+extern long
+_ast_strtol(const char* a, char** b, int c)
+{
+ return strtol(a, b, c);
+}
+#endif
+
+#ifndef strtoul
+#undef STUB
+extern unsigned long
+_ast_strtoul(const char* a, char** b, int c)
+{
+ return strtoul(a, b, c);
+}
+#endif
+
+#ifndef strtoll
+#undef STUB
+extern intmax_t
+_ast_strtoll(const char* a, char** b, int c)
+{
+ return strtoll(a, b, c);
+}
+#endif
+
+#ifndef strtoull
+#undef STUB
+extern uintmax_t
+_ast_strtoull(const char* a, char** b, int c)
+{
+ return strtoull(a, b, c);
+}
+#endif
+
+#endif
+
+#if STUB
+NoN(transition)
+#endif
diff --git a/usr/src/lib/libast/common/comp/tsearch.c b/usr/src/lib/libast/common/comp/tsearch.c
new file mode 100644
index 0000000000..bd2c050481
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/tsearch.c
@@ -0,0 +1,238 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * tsearch() for systems that have <search.h> but no tsearch()
+ * why would such a system provide the interface but not the
+ * implementation? that's what happens when one slimes their
+ * way through standards compliance
+ *
+ * NOTE: please excuse the crude feature test
+ */
+
+#if !_UWIN
+
+void _STUB_tsearch(){}
+
+#else
+
+#if _PACKAGE_ast
+#include <ast.h>
+#endif
+
+#define tdelete ______tdelete
+#define tfind ______tfind
+#define tsearch ______tsearch
+#define twalk ______twalk
+
+#include <search.h>
+
+#undef tdelete
+#undef tfind
+#undef tsearch
+#undef twalk
+
+#include "dthdr.h"
+
+/* POSIX tsearch library based on libcdt
+** Written by Kiem-Phong Vo (AT&T Research, 07/19/95)
+*/
+
+typedef struct _tree_s
+{ Dtlink_t link;
+ Void_t* key;
+} Tree_t;
+
+typedef struct _treedisc_s
+{ Dtdisc_t disc;
+ int(* comparf)_ARG_((const Void_t*, const Void_t*));
+} Treedisc_t;
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+/* compare function */
+#if __STD_C
+static int treecompare(Dt_t* dt, char* one, char* two, Dtdisc_t* disc)
+#else
+static int treecompare(dt, one, two, disc)
+Dt_t* dt;
+char* one;
+char* two;
+Dtdisc_t* disc;
+#endif
+{
+ return (*((Treedisc_t*)disc)->comparf)((Void_t*)one,(Void_t*)two);
+}
+
+static Treedisc_t Treedisc =
+{ { sizeof(Dtlink_t), -1, /* object is key */
+ 0,
+ NIL(Dtmake_f), NIL(Dtfree_f),
+ treecompare,
+ NIL(Dthash_f),
+ NIL(Dtmemory_f),
+ NIL(Dtevent_f)
+ },
+ 0
+};
+
+extern
+#if __STD_C
+Void_t* tsearch(const Void_t* key, Void_t** rootp,
+ int(*comparf)(const Void_t*,const Void_t*) )
+#else
+Void_t* tsearch(key, rootp, comparf)
+Void_t* key;
+Void_t** rootp;
+int(* comparf)();
+#endif
+{
+ reg Dt_t* dt;
+ reg Tree_t* o;
+
+ if(!rootp ||
+ (!(dt = *((Dt_t**)rootp)) && !(dt = dtopen((Dtdisc_t*)(&Treedisc),Dtorder))) )
+ return NIL(Void_t*);
+
+ /* dangerous to set comparf on each call but that's tsearch */
+ Treedisc.comparf = comparf;
+
+ if(!(o = (Tree_t*)dtmatch(dt,key)) )
+ { if(!(o = (Tree_t*)malloc(sizeof(Tree_t))) )
+ return NIL(Void_t*);
+ o->key = (Void_t*)key;
+ dtinsert(dt,o);
+ }
+
+ if(o)
+ *rootp = (Void_t*)dt;
+ else if(*rootp == NIL(Void_t*) )
+ dtclose(dt);
+
+ return (Void_t*)(&o->key);
+}
+
+extern
+#if __STD_C
+Void_t* tfind(const Void_t* key, Void_t*const* rootp,
+ int(*comparf)(const Void_t*, const Void_t*) )
+#else
+Void_t* tfind(key, rootp, comparf)
+Void_t* key;
+Void_t** rootp;
+int(* comparf)();
+#endif
+{
+ reg Dt_t* dt;
+ reg Tree_t* o;
+
+ if(!rootp || !(dt = *((Dt_t**)rootp)) )
+ return NIL(Void_t*);
+ Treedisc.comparf = comparf;
+
+ return (o = (Tree_t*)dtmatch(dt,key)) ? (Void_t*)(&o->key) : NIL(Void_t*);
+}
+
+/* the original tdelete() specifies that it will return the parent pointer
+** in the tree if there is one. Since we are using a splay tree, a deleted
+** node is always rotated to the root first. So this implementation always
+** returns the key of the new root.
+*/
+extern
+#if __STD_C
+Void_t* tdelete(const Void_t* key, Void_t** rootp,
+ int(*comparf)(const Void_t*, const Void_t*) )
+#else
+Void_t* tdelete(key, rootp, comparf)
+Void_t* key;
+Void_t** rootp;
+int(* comparf)();
+#endif
+{
+ reg Dt_t* dt;
+ reg Tree_t* o;
+ Tree_t obj;
+
+ if(!rootp || !(dt = *((Dt_t**)rootp)) )
+ return NIL(Void_t*);
+
+ Treedisc.comparf = comparf;
+
+ obj.key = (Void_t*)key;
+ dtdelete(dt,&obj);
+
+ if(!(o = dtfinger(dt)) )
+ { dtclose(dt);
+ *rootp = NIL(Void_t*);
+ }
+
+ return o ? (Void_t*)(&o->key) : NIL(Void_t*);
+}
+
+/* the below routine assumes a particular layout of Dtlink_t.
+** If this ever gets changed, this routine should be redone.
+*/
+#define lchild link.hl._left
+#define rchild link.right
+
+#if __STD_C
+static void _twalk(Tree_t* obj, void(*action)(const Void_t*,VISIT,int), int level)
+#else
+static void _twalk(obj,action,level)
+Tree_t* obj;
+void(* action)();
+int level;
+#endif
+{ if(!obj->lchild && !obj->rchild)
+ (*action)((Void_t*)obj,leaf,level);
+ else
+ { (*action)((Void_t*)obj,preorder,level);
+ if(obj->lchild)
+ _twalk((Tree_t*)obj->lchild,action,level+1);
+ (*action)((Void_t*)obj,postorder,level);
+ if(obj->rchild)
+ _twalk((Tree_t*)obj->rchild,action,level+1);
+ (*action)((Void_t*)obj,endorder,level);
+ }
+}
+
+/* the original twalk allows specifying arbitrary node to start traversal.
+** Since our root is a dictionary structure, the search here will start
+** at whichever node happens to be current root.
+*/
+extern
+#if __STD_C
+void twalk(const Void_t* root, void(*action)(const Void_t*,VISIT,int) )
+#else
+void twalk(root, action)
+Void_t* root;
+void(* action)();
+#endif
+{
+ reg Tree_t* o;
+
+ if(root && (o = (Tree_t*)dtfinger((Dt_t*)root)) )
+ _twalk(o,action,0);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/unlink.c b/usr/src/lib/libast/common/comp/unlink.c
new file mode 100644
index 0000000000..59ea891a83
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/unlink.c
@@ -0,0 +1,38 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_unlink
+
+NoN(unlink)
+
+#else
+
+int
+unlink(const char* path)
+{
+ return(remove(path));
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/unsetenv.c b/usr/src/lib/libast/common/comp/unsetenv.c
new file mode 100644
index 0000000000..b5fee475d4
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/unsetenv.c
@@ -0,0 +1,50 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#define unsetenv ______unsetenv
+
+#include <ast.h>
+
+#undef unsetenv
+
+#if _lib_unsetenv
+
+NoN(unsetenv)
+
+#else
+
+#undef _def_map_ast
+#include <ast_map.h>
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern void
+unsetenv(const char *name)
+{
+ if (!strchr(name, '='))
+ setenviron(name);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/vfork.c b/usr/src/lib/libast/common/comp/vfork.c
new file mode 100644
index 0000000000..bbc6369ddc
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/vfork.c
@@ -0,0 +1,55 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_vfork
+
+NoN(vfork)
+
+#else
+
+#include <error.h>
+
+#ifndef ENOSYS
+#define ENOSYS EINVAL
+#endif
+
+#undef vfork
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern pid_t
+vfork(void)
+{
+#if _lib_fork
+ return(fork());
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/waitpid.c b/usr/src/lib/libast/common/comp/waitpid.c
new file mode 100644
index 0000000000..95b29abdab
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/waitpid.c
@@ -0,0 +1,199 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * POSIX waitpid()
+ *
+ * pid < -1 WUNTRACED may not be fully supported
+ * process group specifics ignored by non-{waitpid,wait4}
+ */
+
+#include <ast.h>
+#include <wait.h>
+
+#if _lib_waitpid
+
+NoN(waitpid)
+
+#else
+
+#if _lib_wait4
+
+struct rusage;
+
+extern int wait4(int, int*, int, struct rusage*);
+
+pid_t
+waitpid(pid_t pid, int* status, int flags)
+{
+ return(wait4(pid, status, flags, NiL));
+}
+
+#else
+
+#undef SIGCLD
+
+#if _lib_wait3
+
+extern int wait3(int*, int, struct rusage*);
+
+#else
+
+#if _lib_wait2
+
+#define wait3(s,f,u) wait2(s,f)
+
+extern int wait2(int*, int);
+
+#else
+
+#include <sig.h>
+
+#define wait3(s,f,u) wait(s)
+
+static int caught;
+
+static void
+catch(sig)
+int sig;
+{
+ NoP(sig);
+ caught = 1;
+}
+
+#endif
+
+#endif
+
+#include <error.h>
+
+struct zombie
+{
+ struct zombie* next;
+ int status;
+ pid_t pid;
+};
+
+pid_t
+waitpid(pid_t pid, int* status, int flags)
+{
+ register struct zombie* zp;
+ register struct zombie* pp;
+ register int p;
+ int s;
+#if !_lib_wait2 && !_lib_wait3
+#if !defined(SIGCLD)
+ int n;
+ int oerrno;
+#endif
+ Sig_handler_t handler;
+#endif
+
+ static struct zombie* zombies;
+
+ pp = 0;
+ zp = zombies;
+ while (zp)
+ {
+ if (zp->pid >= 0 && (zp->pid == pid || pid <= 0))
+ {
+ if (pp) pp->next = zp->next;
+ else zombies = zp->next;
+ if (status) *status = zp->status;
+ pid = zp->pid;
+ free(zp);
+ return(pid);
+ }
+ }
+ if (pid > 0 && kill(pid, 0) < 0) return(-1);
+ for (;;)
+ {
+#if !_lib_wait2 && !_lib_wait3
+#if !defined(SIGCLD)
+ oerrno = errno;
+#endif
+ if (flags & WNOHANG)
+ {
+ caught = 0;
+#if defined(SIGCLD)
+ handler = signal(SIGCLD, catch);
+ if (!caught)
+ {
+ signal(SIGCLD, handler);
+ return(0);
+ }
+#else
+#if defined(SIGALRM)
+ handler = signal(SIGALRM, catch);
+ n = alarm(1);
+#endif
+#endif
+ }
+#endif
+ p = wait3(&s, flags, NiL);
+#if !_lib_wait3
+#if !_lib_wait2
+#if defined(SIGCLD)
+ if (flags & WNOHANG) signal(SIGCLD, handler);
+#else
+#if defined(SIGALRM)
+ if (flags & WNOHANG)
+ {
+ if (n == 0 && !caught || n == 1) alarm(n);
+ else if (n > 1) alarm(n - caught);
+ signal(SIGALRM, handler);
+ }
+ if (p == -1 && errno == EINTR)
+ {
+ errno = oerrno;
+ p = 0;
+ s = 0;
+ }
+#endif
+#endif
+#else
+ if (p == -1 && errno == EINVAL && (flags & ~WNOHANG))
+ p = wait3(&s, flags & WNOHANG, NiL);
+#endif
+#endif
+ if (p <= 0)
+ {
+ if (p == 0 && status) *status = s;
+ return(p);
+ }
+ if (pid <= 0 || p == pid)
+ {
+ if (status) *status = s;
+ return(p);
+ }
+ if (!(zp = newof(0, struct zombie, 1, 0))) return(-1);
+ zp->pid = p;
+ zp->status = s;
+ zp->next = zombies;
+ zombies = zp;
+ }
+ /*NOTREACHED*/
+}
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/comp/wc.c b/usr/src/lib/libast/common/comp/wc.c
new file mode 100644
index 0000000000..0273b1a0b6
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/wc.c
@@ -0,0 +1,139 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * NOTE: mbs* and wcs* are provided to avoid link errors only
+ */
+
+#include <ast.h>
+#include <wchar.h>
+
+#define STUB 1
+
+#if !_lib_mbtowc
+#undef STUB
+size_t
+mbtowc(wchar_t* t, const char* s, size_t n)
+{
+ if (t && n > 0)
+ *t = *s;
+ return 1;
+}
+#endif
+
+#if !_lib_mbrtowc
+#undef STUB
+size_t
+mbrtowc(wchar_t* t, const char* s, size_t n, mbstate_t* q)
+{
+#if _lib_mbtowc
+#undef STUB
+ memset(q, 0, sizeof(*q));
+ return mbtowc(t, s, n);
+#else
+ *q = 0;
+ if (t && n > 0)
+ *t = *s;
+ return 1;
+#endif
+}
+#endif
+
+#if !_lib_mbstowcs
+#undef STUB
+size_t
+mbstowcs(wchar_t* t, const char* s, size_t n)
+{
+ register wchar_t* p = t;
+ register wchar_t* e = t + n;
+ register unsigned char* u = (unsigned char*)s;
+
+ if (t)
+ while (p < e && (*p++ = *u++));
+ else
+ while (p++, *u++);
+ return p - t;
+}
+#endif
+
+#if !_lib_wctomb
+#undef STUB
+int
+wctomb(char* s, wchar_t c)
+{
+ if (s)
+ *s = c;
+ return 1;
+}
+#endif
+
+#if !_lib_wcrtomb
+#undef STUB
+size_t
+wcrtomb(char* s, wchar_t c, mbstate_t* q)
+{
+#if _lib_wctomb
+#undef STUB
+ memset(q, 0, sizeof(*q));
+ return wctomb(s, c);
+#else
+ if (s)
+ *s = c;
+ *q = 0;
+ return 1;
+#endif
+}
+#endif
+
+#if !_lib_wcslen
+#undef STUB
+size_t
+wcslen(const wchar_t* s)
+{
+ register const wchar_t* p = s;
+
+ while (*p)
+ p++;
+ return p - s;
+}
+#endif
+
+#if !_lib_wcstombs
+#undef STUB
+size_t
+wcstombs(char* t, register const wchar_t* s, size_t n)
+{
+ register char* p = t;
+ register char* e = t + n;
+
+ if (t)
+ while (p < e && (*p++ = *s++));
+ else
+ while (p++, *s++);
+ return p - t;
+}
+#endif
+
+#if STUB
+NoN(wc)
+#endif
diff --git a/usr/src/lib/libast/common/comp/wordexp.c b/usr/src/lib/libast/common/comp/wordexp.c
new file mode 100644
index 0000000000..475b8f132f
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/wordexp.c
@@ -0,0 +1,217 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * POSIX 1003.2 wordexp implementation
+ */
+
+#include <ast.h>
+#include <wordexp.h>
+#include <stak.h>
+
+struct list
+{
+ struct list *next;
+};
+
+/*
+ * elimnates shell quoting as inserted with sh_fmtq
+ * result relaces <string>
+ * length of resulting string is returned.
+ */
+static int sh_unquote(char* string)
+{
+ register char *sp=string, *dp;
+ register int c;
+ while((c= *sp) && c!='\'')
+ sp++;
+ if(c==0)
+ return(sp-string);
+ if((dp=sp) > string && sp[-1]=='$')
+ {
+ register int n=stresc(sp+1);
+ /* copy all but trailing ' */
+ while(--n>0)
+ *dp++ = *++sp;
+ }
+ else
+ {
+ while((c= *++sp) && c!='\'')
+ *dp++ = c;
+ }
+ *dp=0;
+ return(dp-string);
+}
+
+int wordexp(const char *string, wordexp_t *wdarg, register int flags)
+{
+ register Sfio_t *iop;
+ register char *cp=(char*)string;
+ register int c,quoted=0,literal=0,ac=0;
+ int offset;
+ char *savebase,**av;
+ if(offset=staktell())
+ savebase = stakfreeze(0);
+ if(flags&WRDE_REUSE)
+ wordfree(wdarg);
+ else if(!(flags&WRDE_APPEND))
+ {
+ wdarg->we_wordv = 0;
+ wdarg->we_wordc = 0;
+ }
+ if(flags&WRDE_UNDEF)
+ stakwrite("set -u\n",7);
+ if(!(flags&WRDE_SHOWERR))
+ stakwrite("exec 2> /dev/null\n",18);
+ stakwrite("print -f \"%q\\n\" ",16);
+ if(*cp=='#')
+ stakputc('\\');
+ while(c = *cp++)
+ {
+ if(c=='\'' && !quoted)
+ literal = !literal;
+ else if(!literal)
+ {
+ if(c=='\\' && (!quoted || strchr("\\\"`\n$",c)))
+ {
+ stakputc('\\');
+ if(c= *cp)
+ cp++;
+ else
+ c = '\\';
+ }
+ else if(c=='"')
+ quoted = !quoted;
+ else if(c=='`' || (c=='$' && *cp=='('))
+ {
+ if(flags&WRDE_NOCMD)
+ {
+ c=WRDE_CMDSUB;
+ goto err;
+ }
+ /* only the shell can parse the rest */
+ stakputs(cp-1);
+ break;
+ }
+ else if(!quoted && strchr("|&\n;<>"+ac,c))
+ {
+ c=WRDE_BADCHAR;
+ goto err;
+ }
+ else if(c=='(') /* allow | and & inside pattern */
+ ac=2;
+ }
+ stakputc(c);
+ }
+ stakputc(0);
+ if(!(iop = sfpopen((Sfio_t*)0,stakptr(0),"r")))
+ {
+ c = WRDE_NOSHELL;
+ goto err;
+ }
+ stakseek(0);
+ ac = 0;
+ while((c=sfgetc(iop)) != EOF)
+ {
+ if(c=='\'')
+ quoted = ! quoted;
+ else if(!quoted && (c==' ' || c=='\n'))
+ {
+ ac++;
+ c = 0;
+ }
+ stakputc(c);
+ }
+ if(c=sfclose(iop))
+ {
+ if(c==3 || !(flags&WRDE_UNDEF))
+ c=WRDE_SYNTAX;
+ else
+ c=WRDE_BADVAL;
+ goto err;
+ }
+ c = ac+2;
+ if(flags&WRDE_DOOFFS)
+ c += wdarg->we_offs;
+ if(flags&WRDE_APPEND)
+ av = (char**)realloc((void*)&wdarg->we_wordv[-1], (wdarg->we_wordc+c)*sizeof(char*));
+ else if(av = (char**)malloc(c*sizeof(char*)))
+ {
+ if(flags&WRDE_DOOFFS)
+ memset((void*)av,0,(wdarg->we_offs+1)*sizeof(char*));
+ else
+ av[0] = 0;
+ }
+ if(!av)
+ return(WRDE_NOSPACE);
+ c = staktell();
+ if(!(cp = (char*)malloc(sizeof(char*)+c)))
+ {
+ c=WRDE_NOSPACE;
+ goto err;
+ }
+ ((struct list*)cp)->next = (struct list*)(*av);
+ *av++ = (char*)cp;
+ cp += sizeof(char*);
+ wdarg->we_wordv = av;
+ if(flags&WRDE_APPEND)
+ av += wdarg->we_wordc;
+ wdarg->we_wordc += ac;
+ if(flags&WRDE_DOOFFS)
+ av += wdarg->we_offs;
+ memcpy((void*)cp,stakptr(offset),c);
+ while(ac-- > 0)
+ {
+ *av++ = cp;
+ sh_unquote(cp);
+ while(c= *cp++);
+ }
+ *av = 0;
+ c=0;
+err:
+ if(offset)
+ stakset(savebase,offset);
+ else
+ stakseek(0);
+ return(c);
+}
+
+/*
+ * free fields in <wdarg>
+ */
+int wordfree(register wordexp_t *wdarg)
+{
+ struct list *arg, *argnext;
+ if(wdarg->we_wordv)
+ {
+ argnext = (struct list*)wdarg->we_wordv[-1];
+ while(arg=argnext)
+ {
+ argnext = arg->next;
+ free((void*)arg);
+ }
+ free((void*)&wdarg->we_wordv[-1]);
+ wdarg->we_wordv = 0;
+ }
+ wdarg->we_wordc=0;
+ return(0);
+}
diff --git a/usr/src/lib/libast/common/comp/wordexp.h b/usr/src/lib/libast/common/comp/wordexp.h
new file mode 100644
index 0000000000..ac0f6b6f86
--- /dev/null
+++ b/usr/src/lib/libast/common/comp/wordexp.h
@@ -0,0 +1,63 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * posix wordexp interface definitions
+ */
+
+#ifndef _WORDEXP_H
+#define _WORDEXP_H
+
+#include <ast_common.h>
+
+#define WRDE_APPEND 01
+#define WRDE_DOOFFS 02
+#define WRDE_NOCMD 04
+#define WRDE_NOSYS 0100
+#define WRDE_REUSE 010
+#define WRDE_SHOWERR 020
+#define WRDE_UNDEF 040
+
+#define WRDE_BADCHAR 1
+#define WRDE_BADVAL 2
+#define WRDE_CMDSUB 3
+#define WRDE_NOSPACE 4
+#define WRDE_SYNTAX 5
+#define WRDE_NOSHELL 6
+
+typedef struct _wdarg
+{
+ size_t we_wordc;
+ char **we_wordv;
+ size_t we_offs;
+} wordexp_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int wordexp(const char*, wordexp_t*, int);
+extern int wordfree(wordexp_t*);
+
+#undef extern
+
+#endif /* _WORDEXP_H */
diff --git a/usr/src/lib/libast/common/dir/dirlib.h b/usr/src/lib/libast/common/dir/dirlib.h
new file mode 100644
index 0000000000..3e7afa4d80
--- /dev/null
+++ b/usr/src/lib/libast/common/dir/dirlib.h
@@ -0,0 +1,174 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * AT&T Research
+ *
+ * directory stream access library private definitions
+ * library routines should include this file rather than <dirent.h>
+ */
+
+#ifndef _DIRLIB_H
+#define _DIRLIB_H
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide getdents getdirentries
+#else
+#undef getdents
+#define getdents ______getdents
+#undef getdirentries
+#define getdirentries ______getdirentries
+#endif
+
+#include <ast.h>
+#include <errno.h>
+
+#if _lib_opendir && ( _hdr_dirent || _hdr_ndir || _sys_dir )
+
+#define _dir_ok 1
+
+#include <ls.h>
+
+#ifndef _DIRENT_H
+#if _hdr_dirent
+#if _typ_off64_t
+#undef off_t
+#endif
+#include <dirent.h>
+#if _typ_off64_t
+#define off_t off64_t
+#endif
+#else
+#if _hdr_ndir
+#include <ndir.h>
+#else
+#include <sys/dir.h>
+#endif
+#ifndef dirent
+#define dirent direct
+#endif
+#endif
+#endif
+
+#define DIRdirent dirent
+
+#else
+
+#define dirent DIRdirent
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide DIR closedir opendir readdir seekdir telldir
+#else
+#undef DIR
+#define DIR ______DIR
+#undef closedir
+#define closedir ______closedir
+#undef opendir
+#define opendir ______opendir
+#undef readdir
+#define readdir ______readdir
+#undef seekdir
+#define seekdir ______seekdir
+#undef telldir
+#define telldir ______telldir
+#endif
+
+#include <ast_param.h>
+
+#include <ls.h>
+#include <limits.h>
+
+#ifndef _DIRENT_H
+#if _hdr_dirent
+#if _typ_off64_t
+#undef off_t
+#endif
+#include <dirent.h>
+#if _typ_off64_t
+#define off_t off64_t
+#endif
+#else
+#if _hdr_direntry
+#include <direntry.h>
+#else
+#include <sys/dir.h>
+#endif
+#endif
+#endif
+
+#undef dirent
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide DIR closedir opendir readdir seekdir telldir
+#else
+#undef DIR
+#undef closedir
+#undef opendir
+#undef readdir
+#undef seekdir
+#undef telldir
+#endif
+
+#define _DIR_PRIVATE_ \
+ int dd_loc; /* offset in block */ \
+ int dd_size; /* valid data in block */ \
+ char* dd_buf; /* directory block */
+
+#ifdef _BLD_3d
+#define DIR DIRDIR
+#endif
+#undef _DIRENT_H
+#include "dirstd.h"
+#ifndef _DIRENT_H
+#define _DIRENT_H 1
+#endif
+#ifdef _BLD_3d
+#undef DIR
+#endif
+
+#ifndef DIRBLKSIZ
+#ifdef DIRBLK
+#define DIRBLKSIZ DIRBLK
+#else
+#ifdef DIRBUF
+#define DIRBLKSIZ DIRBUF
+#else
+#define DIRBLKSIZ 8192
+#endif
+#endif
+#endif
+
+#endif
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide getdents getdirentries
+#else
+#undef getdents
+#undef getdirentries
+#endif
+
+#ifndef errno
+extern int errno;
+#endif
+
+extern ssize_t getdents(int, void*, size_t);
+
+#endif
diff --git a/usr/src/lib/libast/common/dir/getdents.c b/usr/src/lib/libast/common/dir/getdents.c
new file mode 100644
index 0000000000..7a79f47d04
--- /dev/null
+++ b/usr/src/lib/libast/common/dir/getdents.c
@@ -0,0 +1,166 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "dirlib.h"
+
+#if _dir_ok || _lib_getdents
+
+NoN(getdents)
+
+#else
+
+/*
+ * getdents
+ *
+ * read directory entries into directory block
+ *
+ * NOTE: directory entries must fit within DIRBLKSIZ boundaries
+ */
+
+#ifndef MAXNAMLEN
+#define MAXNAMLEN 255
+#endif
+
+#if _lib_dirread
+extern int dirread(int, char*, int);
+#endif
+#if _lib_getdirentries
+extern int getdirentries(int, char*, int, long*);
+#endif
+
+ssize_t
+getdents(int fd, void* buf, size_t siz)
+{
+ struct stat st;
+
+ if (siz < DIRBLKSIZ)
+ {
+ errno = EINVAL;
+ return(-1);
+ }
+ if (fstat(fd, &st)) return(-1);
+ if (!S_ISDIR(st.st_mode))
+ {
+#ifdef ENOTDIR
+ errno = ENOTDIR;
+#else
+ errno = EBADF;
+#endif
+ return(-1);
+ }
+#if _lib_getdirentries
+ {
+ long off;
+ return(getdirentries(fd, buf, siz, &off));
+ }
+#else
+#if _lib_dirread
+ {
+ register char* sp; /* system */
+ register struct dirent* up; /* user */
+ char* u;
+ int n;
+ int m;
+ int i;
+
+ m = (siz * 6) / 10;
+ m = roundof(m, 8);
+ sp = (char*)buf + siz - m - 1;
+ if (!(n = dirread(fd, sp, m))) return(0);
+ if (n > 0)
+ {
+ up = (struct dirent*)buf;
+ sp[n] = 0;
+ while (sp < (char*)buf + siz - m + n)
+ {
+ i = 0;
+ while (*sp >= '0' && *sp <= '9')
+ i = 10 * i + *sp++ - '0';
+ while (*sp && *sp != '\t') sp++;
+ if (*sp++)
+ {
+ up->d_fileno = i;
+ u = up->d_name;
+ while ((*u = *sp++) && u < up->d_name + MAXNAMLEN) u++;
+ *u = 0;
+ up->d_reclen = sizeof(struct dirent) - sizeof(up->d_name) + (up->d_namlen = u - up->d_name) + 1;
+ up->d_reclen = roundof(up->d_reclen, 8);
+ up = (struct dirent*)((char*)up + up->d_reclen);
+ }
+ }
+ return((char*)up - (char*)buf);
+ }
+ }
+#else
+#if _mem_d_reclen_direct
+ return(read(fd, buf, siz));
+#else
+ {
+
+#define MAXREC roundof(sizeof(*up)-sizeof(up->d_name)+sizeof(sp->d_name)+1,8)
+
+ register struct direct* sp; /* system */
+ register struct dirent* up; /* user */
+ register char* s;
+ register char* u;
+ int n;
+ int m;
+ char tmp[sizeof(sp->d_name) + 1];
+
+ /*
+ * we assume sizeof(struct dirent) > sizeof(struct direct)
+ */
+
+ up = (struct dirent*)buf;
+ n = (siz / MAXREC) * sizeof(struct direct);
+ if ((!(m = n & ~511) || m < MAXREC) && (!(m = n & ~255) || m < MAXREC)) m = n;
+ do
+ {
+ if ((n = read(fd, (char*)buf + siz - m, m)) <= 0) break;
+ sp = (struct direct*)((char*)buf + siz - m);
+ while (sp < (struct direct*)((char*)buf + siz - m + n))
+ {
+ if (sp->d_ino)
+ {
+ up->d_fileno = sp->d_ino;
+ s = sp->d_name;
+ u = tmp;
+ while (s < sp->d_name + sizeof(sp->d_name) && *s)
+ *u++ = *s++;
+ *u = 0;
+ strcpy(up->d_name, tmp);
+ up->d_reclen = sizeof(struct dirent) - sizeof(up->d_name) + (up->d_namlen = u - tmp) + 1;
+ up->d_reclen = roundof(up->d_reclen, 8);
+ up = (struct dirent*)((char*)up + up->d_reclen);
+ }
+ sp++;
+ }
+ } while (up == (struct dirent*)buf);
+ return((char*)up - (char*)buf);
+ }
+#endif
+#endif
+#endif
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/dir/opendir.c b/usr/src/lib/libast/common/dir/opendir.c
new file mode 100644
index 0000000000..e41a5cccea
--- /dev/null
+++ b/usr/src/lib/libast/common/dir/opendir.c
@@ -0,0 +1,95 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * opendir, closedir
+ *
+ * open|close directory stream
+ *
+ * POSIX compatible directory stream access routines:
+ *
+ * #include <sys/types.h>
+ * #include <dirent.h>
+ *
+ * NOTE: readdir() returns a pointer to struct dirent
+ */
+
+#include "dirlib.h"
+
+#if _dir_ok
+
+NoN(opendir)
+
+#else
+
+static const char id_dir[] = "\n@(#)$Id: directory (AT&T Research) 1993-04-01 $\0\n";
+
+static DIR* freedirp; /* always keep one dirp */
+
+DIR*
+opendir(register const char* path)
+{
+ register DIR* dirp = 0;
+ register int fd;
+ struct stat st;
+
+ if ((fd = open(path, O_RDONLY)) < 0) return(0);
+ if (fstat(fd, &st) < 0 ||
+ !S_ISDIR(st.st_mode) && (errno = ENOTDIR) ||
+ fcntl(fd, F_SETFD, FD_CLOEXEC) ||
+ !(dirp = freedirp ? freedirp :
+#if defined(_DIR_PRIVATE_) || _ptr_dd_buf
+ newof(0, DIR, 1, DIRBLKSIZ)
+#else
+ newof(0, DIR, 1, 0)
+#endif
+ ))
+ {
+ close(fd);
+ if (dirp)
+ {
+ if (!freedirp) freedirp = dirp;
+ else free(dirp);
+ }
+ return(0);
+ }
+ freedirp = 0;
+ dirp->dd_fd = fd;
+ dirp->dd_loc = dirp->dd_size = 0; /* refill needed */
+#if defined(_DIR_PRIVATE_) || _ptr_dd_buf
+ dirp->dd_buf = (void*)((char*)dirp + sizeof(DIR));
+#endif
+ return(dirp);
+}
+
+void
+closedir(register DIR* dirp)
+{
+ if (dirp)
+ {
+ close(dirp->dd_fd);
+ if (!freedirp) freedirp = dirp;
+ else free(dirp);
+ }
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/dir/readdir.c b/usr/src/lib/libast/common/dir/readdir.c
new file mode 100644
index 0000000000..421c014c22
--- /dev/null
+++ b/usr/src/lib/libast/common/dir/readdir.c
@@ -0,0 +1,61 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * readdir
+ *
+ * read from directory stream
+ *
+ * NOTE: directory entries must fit within DIRBLKSIZ boundaries
+ */
+
+#include "dirlib.h"
+
+#if _dir_ok
+
+NoN(readdir)
+
+#else
+
+struct dirent*
+readdir(register DIR* dirp)
+{
+ register struct dirent* dp;
+
+ for (;;)
+ {
+ if (dirp->dd_loc >= dirp->dd_size)
+ {
+ if (dirp->dd_size < 0) return(0);
+ dirp->dd_loc = 0;
+ if ((dirp->dd_size = getdents(dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0)
+ return(0);
+ }
+ dp = (struct dirent*)((char*)dirp->dd_buf + dirp->dd_loc);
+ if (dp->d_reclen <= 0) return(0);
+ dirp->dd_loc += dp->d_reclen;
+ if (dp->d_fileno) return(dp);
+ }
+ /*NOTREACHED*/
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/dir/rewinddir.c b/usr/src/lib/libast/common/dir/rewinddir.c
new file mode 100644
index 0000000000..37a5090a64
--- /dev/null
+++ b/usr/src/lib/libast/common/dir/rewinddir.c
@@ -0,0 +1,46 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * rewinddir
+ *
+ * rewind directory stream
+ * provided for POSIX compatibility
+ */
+
+#include "dirlib.h"
+
+#if _dir_ok && ( defined(rewinddir) || _lib_rewinddir )
+
+NoN(rewinddir)
+
+#else
+
+#undef rewinddir
+
+void
+rewinddir(DIR* dirp)
+{
+ seekdir(dirp, 0L);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/dir/seekdir.c b/usr/src/lib/libast/common/dir/seekdir.c
new file mode 100644
index 0000000000..361c83a7b4
--- /dev/null
+++ b/usr/src/lib/libast/common/dir/seekdir.c
@@ -0,0 +1,56 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * seekdir
+ *
+ * seek on directory stream
+ * this is not optimal because there aren't portable
+ * semantics for directory seeks
+ */
+
+#include "dirlib.h"
+
+#if _dir_ok
+
+NoN(seekdir)
+
+#else
+
+void
+seekdir(register DIR* dirp, long loc)
+{
+ off_t base; /* file location of block */
+ off_t offset; /* offset within block */
+
+ if (telldir(dirp) != loc)
+ {
+ lseek(dirp->dd_fd, 0L, SEEK_SET);
+ dirp->dd_loc = dirp->dd_size = 0;
+ while (telldir(dirp) != loc)
+ if (!readdir(dirp))
+ break; /* "can't happen" */
+ }
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/dir/telldir.c b/usr/src/lib/libast/common/dir/telldir.c
new file mode 100644
index 0000000000..e9760130f3
--- /dev/null
+++ b/usr/src/lib/libast/common/dir/telldir.c
@@ -0,0 +1,43 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * telldir
+ *
+ * get directory stream pointer offset for seekdir()
+ */
+
+#include "dirlib.h"
+
+#if _dir_ok
+
+NoN(telldir)
+
+#else
+
+long
+telldir(DIR* dirp)
+{
+ return(lseek(dirp->dd_fd, 0L, SEEK_CUR) + (long)dirp->dd_loc);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/disc/memfatal.c b/usr/src/lib/libast/common/disc/memfatal.c
new file mode 100644
index 0000000000..866ed70307
--- /dev/null
+++ b/usr/src/lib/libast/common/disc/memfatal.c
@@ -0,0 +1,79 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * install error message handler for fatal malloc exceptions
+ */
+
+#include <ast.h>
+#include <error.h>
+#include <vmalloc.h>
+
+#include "FEATURE/vmalloc"
+
+#if _std_malloc
+
+void
+memfatal(void)
+{
+}
+
+#else
+
+/*
+ * print message and fail on VM_BADADDR,VM_NOMEM
+ */
+
+static int
+nomalloc(Vmalloc_t* region, int type, void* obj, Vmdisc_t* disc)
+{
+ Vmstat_t st;
+
+ NoP(disc);
+ switch (type)
+ {
+ case VM_BADADDR:
+ error(ERROR_SYSTEM|3, "invalid pointer %p passed to free or realloc", obj);
+ return(-1);
+ case VM_NOMEM:
+ vmstat(region, &st);
+ error(ERROR_SYSTEM|3, "storage allocator out of space on %lu byte request ( region %lu segments %lu busy %lu:%lu:%lu free %lu:%lu:%lu )", (size_t)obj, st.extent, st.n_seg, st.n_busy, st.s_busy, st.m_busy, st.n_free, st.s_free, st.m_free);
+ return(-1);
+ }
+ return(0);
+}
+
+/*
+ * initialize the malloc exception handler
+ */
+
+void
+memfatal(void)
+{
+ Vmdisc_t* disc;
+
+ if (disc = vmdisc(Vmheap, NiL))
+ disc->exceptf = nomalloc;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/disc/sfdcdio.c b/usr/src/lib/libast/common/disc/sfdcdio.c
new file mode 100644
index 0000000000..ed7720d229
--- /dev/null
+++ b/usr/src/lib/libast/common/disc/sfdcdio.c
@@ -0,0 +1,228 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfdchdr.h"
+
+/* Discipline to turn on direct IO capability.
+** This currently only works for XFS on SGI's.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 03/18/1998.
+*/
+
+#ifndef FDIRECT
+#undef F_FIOINFO
+#endif
+
+typedef struct _direct_s
+{ Sfdisc_t disc; /* Sfio discipline */
+ int cntl; /* file control flags */
+#ifdef F_DIOINFO
+ struct dioattr dio; /* direct IO params */
+#endif
+} Direct_t;
+
+/* convert a pointer to an int */
+#define P2I(p) (Sfulong_t)((char*)(p) - (char*)0)
+
+#if __STD_C
+static ssize_t diordwr(Sfio_t* f, Void_t* buf, size_t n, Direct_t* di, int type)
+#else
+static ssize_t diordwr(f, buf, n, di, type)
+Sfio_t* f;
+Void_t* buf;
+size_t n;
+Direct_t* di;
+int type;
+#endif
+{
+ size_t rw, done;
+ ssize_t rv;
+
+ done = 0; /* amount processed by direct IO */
+
+#ifdef F_DIOINFO
+ if((P2I(buf)%di->dio.d_mem) == 0 &&
+ (f->here%di->dio.d_miniosz) == 0 && n >= di->dio.d_miniosz )
+ { /* direct IO ok, make sure we're in the right mode */
+ if(!(di->cntl & FDIRECT) )
+ { di->cntl |= FDIRECT;
+ (void)fcntl(f->file, F_SETFL, di->cntl);
+ }
+
+ for(rw = (n/di->dio.d_miniosz)*di->dio.d_miniosz;; )
+ { size_t io;
+
+ if((io = rw) > di->dio.d_maxiosz )
+ io = di->dio.d_maxiosz;
+ if(type == SF_READ)
+ rv = read(f->file,buf,io);
+ else rv = write(f->file,buf,io);
+
+ if(rv > 0)
+ { rw -= rv; done += rv;
+ buf = (Void_t*)((char*)buf + rv);
+ }
+
+ if(rv < io || rw < di->dio.d_miniosz)
+ break;
+ }
+ }
+
+ if(done < n && (di->cntl & FDIRECT) )
+ { /* turn off directIO for remaining IO operation */
+ di->cntl &= ~FDIRECT;
+ (void)fcntl(f->file, F_SETFL, di->cntl);
+ }
+#endif /*F_DIOINFO*/
+
+ if((rw = n-done) > 0 &&
+ (rv = type == SF_READ ? read(f->file,buf,rw) : write(f->file,buf,rw)) > 0 )
+ done += rv;
+
+ return done ? done : rv;
+}
+
+#if __STD_C
+static ssize_t dioread(Sfio_t* f, Void_t* buf, size_t n, Sfdisc_t* disc)
+#else
+static ssize_t dioread(f, buf, n, disc)
+Sfio_t* f;
+Void_t* buf;
+size_t n;
+Sfdisc_t* disc;
+#endif
+{
+ return diordwr(f, buf, n, (Direct_t*)disc, SF_READ);
+}
+
+#if __STD_C
+static ssize_t diowrite(Sfio_t* f, const Void_t* buf, size_t n, Sfdisc_t* disc)
+#else
+static ssize_t diowrite(f, buf, n, disc)
+Sfio_t* f;
+Void_t* buf;
+size_t n;
+Sfdisc_t* disc;
+#endif
+{
+ return diordwr(f, (Void_t*)buf, n, (Direct_t*)disc, SF_WRITE);
+}
+
+#if __STD_C
+static int dioexcept(Sfio_t* f, int type, Void_t* data, Sfdisc_t* disc)
+#else
+static int dioexcept(f,type,data,disc)
+Sfio_t* f;
+int type;
+Void_t* data;
+Sfdisc_t* disc;
+#endif
+{
+ Direct_t* di = (Direct_t*)disc;
+
+ if(type == SF_FINAL || type == SF_DPOP)
+ {
+#ifdef F_DIOINFO
+ if(di->cntl&FDIRECT)
+ { di->cntl &= ~FDIRECT;
+ (void)fcntl(f->file,F_SETFL,di->cntl);
+ }
+#endif
+ free(disc);
+ }
+
+ return 0;
+}
+
+#if __STD_C
+int sfdcdio(Sfio_t* f, size_t bufsize)
+#else
+int sfdcdio(f, bufsize)
+Sfio_t* f;
+size_t bufsize;
+#endif
+{
+#ifndef F_DIOINFO
+ return -1;
+#else
+ int cntl;
+ struct dioattr dio;
+ Void_t* buf;
+ Direct_t* di;
+
+ if(f->extent < 0 || (f->flags&SF_STRING))
+ return -1;
+
+ if((cntl = fcntl(f->file,F_GETFL,0)) < 0)
+ return -1;
+
+ if(!(cntl&FDIRECT) )
+ { cntl |= FDIRECT;
+ if(fcntl(f->file,F_SETFL,cntl) < 0)
+ return -1;
+ }
+
+ if(fcntl(f->file,F_DIOINFO,&dio) < 0)
+ goto no_direct;
+
+ if(bufsize > 0)
+ bufsize = (bufsize/dio.d_miniosz)*dio.d_miniosz;
+ if(bufsize <= 0)
+ bufsize = dio.d_miniosz*64;
+ if(bufsize > dio.d_maxiosz)
+ bufsize = dio.d_maxiosz;
+
+ if(!(di = (Direct_t*)malloc(sizeof(Direct_t))) )
+ goto no_direct;
+
+ if(!(buf = (Void_t*)memalign(dio.d_mem,bufsize)) )
+ { free(di);
+ goto no_direct;
+ }
+
+ sfsetbuf(f,buf,bufsize);
+ if(sfsetbuf(f,buf,0) == buf)
+ sfset(f,SF_MALLOC,1);
+ else
+ { free(buf);
+ free(di);
+ goto no_direct;
+ }
+
+ di->disc.readf = dioread;
+ di->disc.writef = diowrite;
+ di->disc.seekf = NIL(Sfseek_f);
+ di->disc.exceptf = dioexcept;
+ di->cntl = cntl;
+ di->dio = dio;
+
+ if(sfdisc(f,(Sfdisc_t*)di) != (Sfdisc_t*)di)
+ { free(di);
+ no_direct:
+ cntl &= ~FDIRECT;
+ (void)fcntl(f->file,F_SETFL,cntl);
+ return -1;
+ }
+
+ return 0;
+
+#endif /*F_DIOINFO*/
+}
diff --git a/usr/src/lib/libast/common/disc/sfdcdos.c b/usr/src/lib/libast/common/disc/sfdcdos.c
new file mode 100644
index 0000000000..e90efac7f8
--- /dev/null
+++ b/usr/src/lib/libast/common/disc/sfdcdos.c
@@ -0,0 +1,416 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfdchdr.h"
+
+/* Discipline to turn \r\n into \n.
+** This is useful to deal with DOS text files.
+**
+** Written by David Korn (03/18/1998).
+*/
+
+#define MINMAP 8
+#define CHUNK 1024
+
+struct map
+{
+ Sfoff_t logical;
+ Sfoff_t physical;
+};
+
+typedef struct _dosdisc
+{
+ Sfdisc_t disc;
+ struct map *maptable;
+ int mapsize;
+ int maptop;
+ Sfoff_t lhere;
+ Sfoff_t llast;
+ Sfoff_t lmax;
+ Sfoff_t pmax;
+ Sfoff_t phere;
+ Sfoff_t plast;
+ Sfoff_t begin;
+ int skip;
+ void *buff;
+ char last;
+ char extra;
+ int bsize;
+} Dosdisc_t;
+
+#if __STD_C
+static void addmapping(register Dosdisc_t *dp)
+#else
+static void addmapping(dp)
+register Dosdisc_t *dp;
+#endif
+{
+ register int n;
+ if((n=dp->maptop++)>=dp->mapsize)
+ {
+ dp->mapsize *= 2;
+ if(!(dp->maptable=(struct map*)realloc((void*)dp->maptable,(dp->mapsize+1)*sizeof(struct map))))
+ {
+ dp->maptop--;
+ dp->mapsize *= 2;
+ return;
+ }
+ }
+ dp->maptable[n].physical = dp->phere;
+ dp->maptable[n].logical = dp->lhere;
+ dp->maptable[dp->maptop].logical=0;
+}
+
+#if __STD_C
+static struct map *getmapping(Dosdisc_t *dp, Sfoff_t offset, register int whence)
+#else
+static struct map *getmapping(dp, offset, whence)
+Dosdisc_t *dp;
+Sfoff_t offset;
+register int whence;
+#endif
+{
+ register struct map *mp;
+ static struct map dummy;
+ if(offset <= dp->begin)
+ {
+ dummy.logical = dummy.physical = offset;
+ return(&dummy);
+ }
+ if(!(mp=dp->maptable))
+ {
+ dummy.logical = dp->begin;
+ dummy.physical = dummy.logical+1;
+ return(&dummy);
+ }
+ while((++mp)->logical && (whence==SEEK_CUR?mp->physical:mp->logical) <= offset);
+ return(mp-1);
+}
+
+#if __STD_C
+static ssize_t dos_read(Sfio_t *iop, void *buff, size_t size, Sfdisc_t* disc)
+#else
+static ssize_t dos_read(iop, buff, size, disc)
+Sfio_t *iop;
+void *buff;
+size_t size;
+Sfdisc_t* disc;
+#endif
+{
+ register Dosdisc_t *dp = (Dosdisc_t*)disc;
+ register char *cp = (char*)buff, *first, *cpmax;
+ register int n, count, m;
+ if(dp->extra)
+ {
+ dp->extra=0;
+ *cp = dp->last;
+ return(1);
+ }
+ while(1)
+ {
+ if((n = sfrd(iop,buff,size,disc)) <= 0)
+ return(n);
+ dp->plast=dp->phere;
+ dp->phere +=n;
+ dp->llast = dp->lhere;
+ cpmax = cp+n-1;
+ if(dp->last=='\r' && *cp!='\n')
+ {
+ /* should insert a '\r' */ ;
+ }
+ dp->last = *cpmax;
+ if(n>1)
+ break;
+ if(dp->last!='\r')
+ {
+ dp->lhere++;
+ return(1);
+ }
+ }
+ if(dp->last=='\r')
+ n--;
+ else if(dp->last!='\n' || cpmax[-1]!='\r')
+ *cpmax = '\r';
+ dp->lhere += n;
+ while(1)
+ {
+ while(*cp++ != '\r');
+ if(cp > cpmax || *cp=='\n')
+ break;
+ }
+ dp->skip = cp-1 - (char*)buff;
+ /* if not \r\n in buffer, just return */
+ if((count = cpmax+1-cp) <=0)
+ {
+ *cpmax = dp->last;
+ if(!dp->maptable)
+ dp->begin +=n;
+ dp->skip++;
+ count=0;
+ goto done;
+ }
+ if(!dp->maptable)
+ {
+ dp->begin += cp - (char*)buff-1;
+ if(dp->maptable=(struct map*)malloc((MINMAP+1)*sizeof(struct map)))
+ {
+ dp->mapsize = MINMAP;
+ dp->maptable[0].logical= dp->begin;
+ dp->maptable[0].physical = dp->maptable[0].logical+1;
+ dp->maptable[1].logical=0;
+ dp->maptop = 1;
+ }
+ }
+ /* save original discipline inside buffer */
+ if(count>dp->bsize)
+ {
+ if(dp->bsize==0)
+ dp->buff = malloc(count);
+ else
+ dp->buff = realloc(dp->buff,count);
+ dp->bsize = count;
+ if(!dp->buff)
+ return(-1);
+ }
+ memcpy(dp->buff, cp, count);
+ count=1;
+ while(1)
+ {
+ first=cp;
+ if(cp==cpmax)
+ cp++;
+ else
+ while(*cp++ != '\r');
+ if(cp<=cpmax && *cp!='\n')
+ continue;
+ if((m=(cp-first)-1) >0)
+ memcpy(first-count, first, m);
+ if(cp > cpmax)
+ break;
+ count++;
+ }
+ cpmax[-count] = dp->last;
+ dp->lhere -= count;
+done:
+ if(dp->lhere>dp->lmax)
+ {
+ dp->lmax = dp->lhere;
+ dp->pmax = dp->phere;
+ if(dp->maptable && dp->lmax > dp->maptable[dp->maptop-1].logical+CHUNK)
+ addmapping(dp);
+ }
+ return(n-count);
+}
+
+/*
+ * returns the current offset
+ * <offset> must be in the current buffer
+ * if <whence> is SEEK_CUR, physical offset converted to logical offset
+ * otherwise, logical offset is converted to physical offset
+ */
+#if __STD_C
+static Sfoff_t cur_offset(Dosdisc_t *dp, Sfoff_t offset,Sfio_t *iop,register int whence)
+#else
+static Sfoff_t cur_offset(dp, offset, iop, whence)
+Dosdisc_t *dp;
+Sfoff_t offset;
+Sfio_t *iop;
+register int whence;
+#endif
+{
+ register Sfoff_t n,m=0;
+ register char *cp;
+
+ if(whence==SEEK_CUR)
+ {
+ whence= -1;
+ n = offset - dp->plast;
+ iop->next = iop->data + n;
+ offset = dp->llast;
+ }
+ else
+ {
+ whence = 1;
+ n = offset - dp->llast;
+ offset = dp->plast;
+ }
+ offset +=n;
+ if((n -= dp->skip) > 0)
+ {
+ m=whence;
+ cp = (char*)dp->buff;
+ while(n--)
+ {
+ if(*cp++=='\r' && *cp=='\n')
+ {
+ m += whence;
+ if(whence>0)
+ n++;
+ }
+ }
+ }
+ if(whence<0)
+ iop->next += m;
+ return(offset+m);
+}
+
+#if __STD_C
+static Sfoff_t dos_seek(Sfio_t *iop, Sfoff_t offset, register int whence, Sfdisc_t* disc)
+#else
+static Sfoff_t dos_seek(iop, offset, whence, disc)
+Sfio_t *iop;
+Sfoff_t offset;
+register int whence;
+Sfdisc_t* disc;
+#endif
+{
+ register Dosdisc_t *dp = (Dosdisc_t*)disc;
+ struct map dummy, *mp=0;
+ Sfoff_t physical;
+ register int n,size;
+retry:
+ switch(whence)
+ {
+ case SEEK_CUR:
+ offset = sfsk(iop, (Sfoff_t)0,SEEK_CUR,disc);
+ if(offset<=dp->begin)
+ return(offset);
+ /* check for seek outside buffer */
+ if(offset==dp->phere)
+ return(dp->lhere);
+ else if(offset==dp->plast)
+ return(dp->llast);
+ else if(offset<dp->plast || offset>dp->phere)
+ mp = getmapping(dp,offset,whence);
+ break;
+ case SEEK_SET:
+ /* check for seek outside buffer */
+ if(offset<dp->llast || offset > dp->lhere)
+ mp = getmapping(dp,offset,whence);
+ break;
+ case SEEK_END:
+ if(!dp->maptable)
+ return(sfsk(iop,offset,SEEK_END,disc));
+ mp = &dummy;
+ mp->physical = dp->plast;
+ mp->logical = dp->llast;
+ break;
+ }
+ if(sfsetbuf(iop,(char*)iop,0))
+ size = sfvalue(iop);
+ else
+ size = iop->endb-iop->data;
+ if(mp)
+ {
+ sfsk(iop,mp->physical,SEEK_SET,disc);
+ dp->phere = mp->physical;
+ dp->lhere = mp->logical;
+ if((*disc->readf)(iop,iop->data,size,disc)<0)
+ return(-1);
+ }
+ while(1)
+ {
+ if(whence==SEEK_CUR && dp->phere>=offset)
+ break;
+ if(whence==SEEK_SET && dp->lhere>=offset)
+ break;
+ n=(*disc->readf)(iop,iop->data,size,disc);
+ if(n < 0)
+ return(-1);
+ if(n==0)
+ {
+ if(whence==SEEK_END && offset<0)
+ {
+ offset = dp->lhere;
+ whence=SEEK_SET;
+ goto retry;
+ }
+ break;
+ }
+ }
+ if(whence==SEEK_END)
+ offset += dp->lhere;
+ else
+ {
+ physical = cur_offset(dp,offset,iop,whence);
+ if(whence==SEEK_SET)
+ {
+ sfsk(iop, physical ,SEEK_SET,disc);
+ dp->phere = physical;
+ dp->lhere = offset;
+ }
+ else
+ offset = physical;
+ }
+ return(offset);
+}
+
+#if __STD_C
+static int dos_except(Sfio_t *iop, int type, void *arg, Sfdisc_t *disc)
+#else
+static int dos_except(iop, type, arg, disc)
+Sfio_t *iop;
+int type;
+void *arg;
+Sfdisc_t *disc;
+#endif
+{
+ register Dosdisc_t *dp = (Dosdisc_t*)disc;
+ if(type==SF_DPOP || type==SF_FINAL)
+ {
+ if(dp->bsize>0)
+ free((void*)dp->buff);
+ if(dp->mapsize)
+ free((void*)dp->maptable);
+ free((void*)disc);
+ }
+ return(0);
+}
+
+#if __STD_C
+int sfdcdos(Sfio_t *f)
+#else
+int sfdcdos(f)
+Sfio_t *f;
+#endif
+{
+ Dosdisc_t *dos;
+
+ /* this is a readonly discipline */
+ if(sfset(f,0,0)&SF_WRITE)
+ return(-1);
+
+ if(!(dos = (Dosdisc_t*)malloc(sizeof(Dosdisc_t))) )
+ return -1;
+ memset(dos,'\0',sizeof(Dosdisc_t));
+
+ dos->disc.readf = dos_read;
+ dos->disc.writef = NIL(Sfwrite_f);
+ dos->disc.seekf = dos_seek;
+ dos->disc.exceptf = dos_except;
+
+ if(sfdisc(f,(Sfdisc_t*)dos) != (Sfdisc_t*)dos)
+ { free(dos);
+ return -1;
+ }
+
+ return(0);
+}
diff --git a/usr/src/lib/libast/common/disc/sfdcfilter.c b/usr/src/lib/libast/common/disc/sfdcfilter.c
new file mode 100644
index 0000000000..5ecfe9d827
--- /dev/null
+++ b/usr/src/lib/libast/common/disc/sfdcfilter.c
@@ -0,0 +1,186 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfdchdr.h"
+
+/* Discipline to invoke UNIX processes as data filters.
+** These processes must be able to fit in pipelines.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 03/18/1998.
+*/
+
+typedef struct _filter_s
+{ Sfdisc_t disc; /* discipline structure */
+ Sfio_t* filter; /* the filter stream */
+ char* next; /* data unwritten */
+ char* endb; /* end of data */
+ char raw[4096]; /* raw data buffer */
+} Filter_t;
+
+/* read data from the filter */
+#if __STD_C
+static ssize_t filterread(Sfio_t* f, Void_t* buf, size_t n, Sfdisc_t* disc)
+#else
+static ssize_t filterread(f, buf, n, disc)
+Sfio_t* f; /* stream reading from */
+Void_t* buf; /* buffer to read into */
+size_t n; /* number of bytes requested */
+Sfdisc_t* disc; /* discipline */
+#endif
+{
+ Filter_t* fi;
+ ssize_t r, w;
+
+ fi = (Filter_t*)disc;
+ for(;;)
+ {
+ /* get some raw data to stuff down the pipe */
+ if(fi->next && fi->next >= fi->endb )
+ { if((r = sfrd(f,fi->raw,sizeof(fi->raw),disc)) > 0)
+ { fi->next = fi->raw;
+ fi->endb = fi->raw+r;
+ }
+ else
+ { /* eof, close write end of pipes */
+ sfset(fi->filter,SF_READ,0);
+ close(sffileno(fi->filter));
+ sfset(fi->filter,SF_READ,1);
+ fi->next = fi->endb = NIL(char*);
+ }
+ }
+
+ if(fi->next && (w = fi->endb - fi->next) > 0 )
+ { /* see if pipe is ready for write */
+ sfset(fi->filter, SF_READ, 0);
+ r = sfpoll(&fi->filter, 1, 1);
+ sfset(fi->filter, SF_READ, 1);
+
+ if(r == 1) /* non-blocking write */
+ { errno = 0;
+ if((w = sfwr(fi->filter, fi->next, w, 0)) > 0)
+ fi->next += w;
+ else if(errno != EAGAIN)
+ return 0;
+ }
+ }
+
+ /* see if pipe is ready for read */
+ sfset(fi->filter, SF_WRITE, 0);
+ w = sfpoll(&fi->filter, 1, fi->next ? 1 : -1);
+ sfset(fi->filter, SF_WRITE, 1);
+
+ if(!fi->next || w == 1) /* non-blocking read */
+ { errno = 0;
+ if((r = sfrd(fi->filter, buf, n, 0)) > 0)
+ return r;
+ if(errno != EAGAIN)
+ return 0;
+ }
+ }
+}
+
+#if __STD_C
+static ssize_t filterwrite(Sfio_t* f, const Void_t* buf, size_t n, Sfdisc_t* disc)
+#else
+static ssize_t filterwrite(f, buf, n, disc)
+Sfio_t* f; /* stream writing to */
+Void_t* buf; /* buffer to write into */
+size_t n; /* number of bytes requested */
+Sfdisc_t* disc; /* discipline */
+#endif
+{
+ return -1;
+}
+
+/* for the duration of this discipline, the stream is unseekable */
+#if __STD_C
+static Sfoff_t filterseek(Sfio_t* f, Sfoff_t addr, int offset, Sfdisc_t* disc)
+#else
+static Sfoff_t filterseek(f, addr, offset, disc)
+Sfio_t* f;
+Sfoff_t addr;
+int offset;
+Sfdisc_t* disc;
+#endif
+{ f = NIL(Sfio_t*);
+ addr = 0;
+ offset = 0;
+ disc = NIL(Sfdisc_t*);
+ return (Sfoff_t)(-1);
+}
+
+/* on close, remove the discipline */
+#if __STD_C
+static int filterexcept(Sfio_t* f, int type, Void_t* data, Sfdisc_t* disc)
+#else
+static int filterexcept(f,type,data,disc)
+Sfio_t* f;
+int type;
+Void_t* data;
+Sfdisc_t* disc;
+#endif
+{
+ if(type == SF_FINAL || type == SF_DPOP)
+ { sfclose(((Filter_t*)disc)->filter);
+ free(disc);
+ }
+
+ return 0;
+}
+
+#if __STD_C
+int sfdcfilter(Sfio_t* f, const char* cmd)
+#else
+int sfdcfilter(f, cmd)
+Sfio_t* f; /* stream to filter data */
+char* cmd; /* program to run as a filter */
+#endif
+{
+ reg Filter_t* fi;
+ reg Sfio_t* filter;
+
+ /* open filter for read&write */
+ if(!(filter = sfpopen(NIL(Sfio_t*),cmd,"r+")) )
+ return -1;
+
+ /* unbuffered stream */
+ sfsetbuf(filter,NIL(Void_t*),0);
+
+ if(!(fi = (Filter_t*)malloc(sizeof(Filter_t))) )
+ { sfclose(filter);
+ return -1;
+ }
+
+ fi->disc.readf = filterread;
+ fi->disc.writef = filterwrite;
+ fi->disc.seekf = filterseek;
+ fi->disc.exceptf = filterexcept;
+ fi->filter = filter;
+ fi->next = fi->endb = fi->raw;
+
+ if(sfdisc(f,(Sfdisc_t*)fi) != (Sfdisc_t*)fi)
+ { sfclose(filter);
+ free(fi);
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/disc/sfdchdr.h b/usr/src/lib/libast/common/disc/sfdchdr.h
new file mode 100644
index 0000000000..17a9e584c8
--- /dev/null
+++ b/usr/src/lib/libast/common/disc/sfdchdr.h
@@ -0,0 +1,28 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * common header for discipline functions
+ */
+
+#include "sfhdr.h"
+
+#include <sfdisc.h>
diff --git a/usr/src/lib/libast/common/disc/sfdcmore.c b/usr/src/lib/libast/common/disc/sfdcmore.c
new file mode 100644
index 0000000000..bedcac96dd
--- /dev/null
+++ b/usr/src/lib/libast/common/disc/sfdcmore.c
@@ -0,0 +1,369 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfdchdr.h"
+
+#if _PACKAGE_ast
+#include <ast_tty.h>
+#include <signal.h>
+#endif
+
+/*
+ * a simple but fast more style pager discipline
+ * if on sfstdout then sfstdin ops reset the page state
+ *
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * @(#)$Id: sfdcmore (AT&T Research) 1998-06-25 $
+ */
+
+typedef struct
+{
+ Sfdisc_t disc; /* sfio discipline */
+ Sfio_t* input; /* tied with this input stream */
+ Sfio_t* error; /* tied with this error stream */
+ int rows; /* max rows */
+ int cols; /* max cols */
+ int row; /* current row */
+ int col; /* current col */
+ int match; /* match length, 0 if none */
+ char pattern[128]; /* match pattern */
+ char prompt[1]; /* prompt string */
+} More_t;
+
+/*
+ * more read
+ * we assume line-at-a-time input
+ */
+
+#if __STD_C
+static ssize_t moreread(Sfio_t* f, void* buf, size_t n, Sfdisc_t* dp)
+#else
+static ssize_t moreread(f, buf, n, dp)
+Sfio_t* f;
+void* buf;
+size_t n;
+Sfdisc_t* dp;
+#endif
+{
+ register More_t* more = (More_t*)dp;
+
+ more->match = 0;
+ more->row = 2;
+ more->col = 1;
+ return sfrd(f, buf, n, dp);
+}
+
+/*
+ * output label on wfd and return next char on rfd with no echo
+ * return < -1 is -(signal + 1)
+ */
+
+#if __STD_C
+static int ttyquery(Sfio_t* rp, Sfio_t* wp, const char* label, Sfdisc_t* dp)
+#else
+static int ttyquery(rp, wp, label, dp)
+Sfio_t* rp;
+Sfio_t* wp;
+char* label;
+Sfdisc_t* dp;
+#endif
+{
+ register int r;
+ int n;
+
+#ifdef TCSADRAIN
+ unsigned char c;
+ struct termios old;
+ struct termios tty;
+ int rfd = sffileno(rp);
+ int wfd = sffileno(rp);
+
+ if (!label)
+ n = 0;
+ else if (n = strlen(label))
+ write(wfd, label, n);
+ tcgetattr(rfd, &old);
+ tty = old;
+ tty.c_cc[VTIME] = 0;
+ tty.c_cc[VMIN] = 1;
+ tty.c_lflag &= ~(ICANON|ECHO|ECHOK|ISIG);
+ tcsetattr(rfd, TCSADRAIN, &tty);
+ if ((r = read(rfd, &c, 1)) == 1)
+ {
+ if (c == old.c_cc[VEOF])
+ r = -1;
+ else if (c == old.c_cc[VINTR])
+ r = -(SIGINT + 1);
+ else if (c == old.c_cc[VQUIT])
+ r = -(SIGQUIT + 1);
+ else if (c == '\r')
+ r = '\n';
+ else
+ r = c;
+ }
+ tcsetattr(rfd, TCSADRAIN, &old);
+ if (n)
+ {
+ write(wfd, "\r", 1);
+ while (n-- > 0)
+ write(wfd, " ", 1);
+ write(wfd, "\r", 1);
+ }
+#else
+ register char* s;
+
+ if (label && (n = strlen(label)))
+ sfwr(wp, label, n, dp);
+ r = (s = sfgetr(rp, '\n', 0)) ? *s : -1;
+#endif
+ return r;
+}
+
+/*
+ * more write
+ */
+
+#if __STD_C
+static ssize_t morewrite(Sfio_t* f, const Void_t* buf, register size_t n, Sfdisc_t* dp)
+#else
+static ssize_t morewrite(f, buf, n, dp)
+Sfio_t* f;
+Void_t* buf;
+register size_t n;
+Sfdisc_t* dp;
+#endif
+{
+ register More_t* more = (More_t*)dp;
+ register char* b;
+ register char* s;
+ register char* e;
+ register ssize_t w;
+ register int r;
+
+ if (!more->row)
+ return n;
+ if (!more->col)
+ return sfwr(f, buf, n, dp);
+ w = 0;
+ b = (char*)buf;
+ s = b;
+ e = s + n;
+ if (more->match)
+ {
+ match:
+ for (r = more->pattern[0];; s++)
+ {
+ if (s >= e)
+ return n;
+ if (*s == '\n')
+ b = s + 1;
+ else if (*s == r && (e - s) >= more->match && !strncmp(s, more->pattern, more->match))
+ break;
+ }
+ s = b;
+ w += b - (char*)buf;
+ more->match = 0;
+ }
+ while (s < e)
+ {
+ switch (*s++)
+ {
+ case '\t':
+ more->col = ((more->col + 8) & ~7) - 1;
+ /*FALLTHROUGH*/
+ default:
+ if (++more->col <= more->cols || s < e && *s == '\n')
+ continue;
+ /*FALLTHROUGH*/
+ case '\n':
+ more->col = 1;
+ if (++more->row < more->rows)
+ continue;
+ break;
+ case '\b':
+ if (more->col > 1)
+ more->col--;
+ continue;
+ case '\r':
+ more->col = 1;
+ continue;
+ }
+ w += sfwr(f, b, s - b, dp);
+ b = s;
+ r = ttyquery(sfstdin, f, more->prompt, dp);
+ if (r == '/' || r == 'n')
+ {
+ if (r == '/')
+ {
+ sfwr(f, "/", 1, dp);
+ if ((s = sfgetr(sfstdin, '\n', 1)) && (n = sfvalue(sfstdin) - 1) > 0)
+ {
+ if (n >= sizeof(more->pattern))
+ n = sizeof(more->pattern) - 1;
+ memcpy(more->pattern, s, n);
+ more->pattern[n] = 0;
+ }
+ }
+ if (more->match = strlen(more->pattern))
+ {
+ more->row = 1;
+ more->col = 1;
+ goto match;
+ }
+ }
+ switch (r)
+ {
+ case '\n':
+ case '\r':
+ more->row--;
+ more->col = 1;
+ break;
+ case ' ':
+ more->row = 2;
+ more->col = 1;
+ break;
+ default:
+ more->row = 0;
+ return n;
+ }
+ }
+ if (s > b)
+ w += sfwr(f, b, s - b, dp);
+ return w;
+}
+
+/*
+ * remove the discipline on close
+ */
+
+#if __STD_C
+static int moreexcept(Sfio_t* f, int type, Void_t* data, Sfdisc_t* dp)
+#else
+static int moreexcept(f, type, data, dp)
+Sfio_t* f;
+int type;
+Void_t* data;
+Sfdisc_t* dp;
+#endif
+{
+ register More_t* more = (More_t*)dp;
+
+ if (type == SF_FINAL || type == SF_DPOP)
+ {
+ if (f = more->input)
+ {
+ more->input = 0;
+ sfdisc(f, SF_POPDISC);
+ }
+ else if (f = more->error)
+ {
+ more->error = 0;
+ sfdisc(f, SF_POPDISC);
+ }
+ else
+ free(dp);
+ }
+ else if (type == SF_SYNC)
+ {
+ more->match = 0;
+ more->row = 1;
+ more->col = 1;
+ }
+ return 0;
+}
+
+/*
+ * push the more discipline on f
+ * if prompt==0 then a default ansi prompt is used
+ * if rows==0 or cols==0 then they are deterimined from the tty
+ * if f==sfstdout then input on sfstdin also resets the state
+ */
+
+#if __STD_C
+int sfdcmore(Sfio_t* f, const char* prompt, int rows, int cols)
+#else
+int sfdcmore(f, prompt, rows, cols)
+Sfio_t* f;
+char* prompt;
+int rows;
+int cols;
+#endif
+{
+ register More_t* more;
+ size_t n;
+
+ /*
+ * this is a writeonly discipline for interactive io
+ */
+
+ if (!(sfset(f, 0, 0) & SF_WRITE) || !isatty(sffileno(sfstdin)) || !isatty(sffileno(sfstdout)))
+ return -1;
+ if (!prompt)
+ prompt = "\033[7m More\033[m";
+ n = strlen(prompt) + 1;
+ if (!(more = (More_t*)malloc(sizeof(More_t) + n)))
+ return -1;
+ memset(more, 0, sizeof(*more));
+
+ more->disc.readf = moreread;
+ more->disc.writef = morewrite;
+ more->disc.exceptf = moreexcept;
+ memcpy(more->prompt, prompt, n);
+ if (!rows || !cols)
+ {
+#if _PACKAGE_ast
+ astwinsize(sffileno(sfstdin), &rows, &cols);
+#endif
+ if (!rows)
+ rows = 24;
+ if (!cols)
+ cols = 80;
+ }
+ more->rows = rows;
+ more->cols = cols;
+ more->row = 1;
+ more->col = 1;
+
+ if (sfdisc(f, &more->disc) != &more->disc)
+ {
+ free(more);
+ return -1;
+ }
+ if (f == sfstdout)
+ {
+ if (sfdisc(sfstdin, &more->disc) != &more->disc)
+ {
+ sfdisc(f, SF_POPDISC);
+ return -1;
+ }
+ more->input = sfstdin;
+ if (sfdisc(sfstderr, &more->disc) != &more->disc)
+ {
+ sfdisc(f, SF_POPDISC);
+ return -1;
+ }
+ more->error = sfstdin;
+ }
+
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/disc/sfdcprefix.c b/usr/src/lib/libast/common/disc/sfdcprefix.c
new file mode 100644
index 0000000000..38d8045ba4
--- /dev/null
+++ b/usr/src/lib/libast/common/disc/sfdcprefix.c
@@ -0,0 +1,153 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfdchdr.h"
+
+/*
+ * a discipline that prepends a prefix string to each output line
+ *
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * @(#)$Id: sfdcprefix (AT&T Research) 1998-06-25 $
+ */
+
+typedef struct
+{
+ Sfdisc_t disc; /* sfio discipline */
+ size_t length; /* prefix length */
+ size_t empty; /* empty line prefix length */
+ int skip; /* this line already prefixed */
+ char prefix[1]; /* prefix string */
+} Prefix_t;
+
+/*
+ * prefix write
+ */
+
+#if __STD_C
+static ssize_t pfxwrite(Sfio_t* f, const Void_t* buf, register size_t n, Sfdisc_t* dp)
+#else
+static ssize_t pfxwrite(f, buf, n, dp)
+Sfio_t* f;
+Void_t* buf;
+register size_t n;
+Sfdisc_t* dp;
+#endif
+{
+ register Prefix_t* pfx = (Prefix_t*)dp;
+ register char* b;
+ register char* s;
+ register char* e;
+ register char* t;
+ register ssize_t w;
+ int skip;
+
+ skip = 0;
+ w = 0;
+ b = (char*)buf;
+ s = b;
+ e = s + n;
+ do
+ {
+ if (!(t = memchr(s, '\n', e - s)))
+ {
+ skip = 1;
+ t = e - 1;
+ }
+ n = t - s + 1;
+ if (pfx->skip)
+ pfx->skip = 0;
+ else
+ sfwr(f, pfx->prefix, n > 1 ? pfx->length : pfx->empty, dp);
+ w += sfwr(f, s, n, dp);
+ if ((s = t + 1) >= e)
+ return w;
+ } while ((s = t + 1) < e);
+ pfx->skip = skip;
+ return w;
+
+}
+
+/*
+ * remove the discipline on close
+ */
+
+#if __STD_C
+static int pfxexcept(Sfio_t* f, int type, Void_t* data, Sfdisc_t* dp)
+#else
+static int pfxexcept(f, type, data, dp)
+Sfio_t* f;
+int type;
+Void_t* data;
+Sfdisc_t* dp;
+#endif
+{
+ if (type == SF_FINAL || type == SF_DPOP)
+ free(dp);
+ return 0;
+}
+
+/*
+ * push the prefix discipline on f
+ */
+
+#if __STD_C
+int sfdcprefix(Sfio_t* f, const char* prefix)
+#else
+int sfdcprefix(f, prefix)
+Sfio_t* f;
+char* prefix;
+#endif
+{
+ register Prefix_t* pfx;
+ register char* s;
+ size_t n;
+
+ /*
+ * this is a writeonly discipline
+ */
+
+ if (!prefix || !(n = strlen(prefix)) || !(sfset(f, 0, 0) & SF_WRITE))
+ return -1;
+ if (!(pfx = (Prefix_t*)malloc(sizeof(Prefix_t) + n)))
+ return -1;
+ memset(pfx, 0, sizeof(*pfx));
+
+ pfx->disc.writef = pfxwrite;
+ pfx->disc.exceptf = pfxexcept;
+ pfx->length = n;
+ memcpy(pfx->prefix, prefix, n);
+ s = (char*)prefix + n;
+ while (--s > (char*)prefix && (*s == ' ' || *s == '\t'));
+ n = s - (char*)prefix;
+ if (*s != ' ' || *s != '\t')
+ n++;
+ pfx->empty = n;
+
+ if (sfdisc(f, &pfx->disc) != &pfx->disc)
+ {
+ free(pfx);
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/disc/sfdcseekable.c b/usr/src/lib/libast/common/disc/sfdcseekable.c
new file mode 100644
index 0000000000..265067177b
--- /dev/null
+++ b/usr/src/lib/libast/common/disc/sfdcseekable.c
@@ -0,0 +1,227 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfdchdr.h"
+
+/* Discipline to make an unseekable read stream seekable
+**
+** sfraise(f,SFSK_DISCARD,0) discards previous seek data
+** but seeks from current offset on still allowed
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 03/18/1998.
+*/
+
+typedef struct _skable_s
+{ Sfdisc_t disc; /* sfio discipline */
+ Sfio_t* shadow; /* to shadow data */
+ Sfoff_t discard;/* sfseek(f,-1,SEEK_SET) discarded data */
+ Sfoff_t extent; /* shadow extent */
+ int eof; /* if eof has been reached */
+} Seek_t;
+
+#if __STD_C
+static ssize_t skwrite(Sfio_t* f, const Void_t* buf, size_t n, Sfdisc_t* disc)
+#else
+static ssize_t skwrite(f, buf, n, disc)
+Sfio_t* f; /* stream involved */
+Void_t* buf; /* buffer to read into */
+size_t n; /* number of bytes to read */
+Sfdisc_t* disc; /* discipline */
+#endif
+{
+ return (ssize_t)(-1);
+}
+
+#if __STD_C
+static ssize_t skread(Sfio_t* f, Void_t* buf, size_t n, Sfdisc_t* disc)
+#else
+static ssize_t skread(f, buf, n, disc)
+Sfio_t* f; /* stream involved */
+Void_t* buf; /* buffer to read into */
+size_t n; /* number of bytes to read */
+Sfdisc_t* disc; /* discipline */
+#endif
+{
+ Seek_t* sk;
+ Sfio_t* sf;
+ Sfoff_t addr;
+ ssize_t r, w, p;
+
+ sk = (Seek_t*)disc;
+ sf = sk->shadow;
+ if(sk->eof)
+ return sfread(sf,buf,n);
+
+ addr = sfseek(sf,(Sfoff_t)0,SEEK_CUR);
+
+ if(addr+n <= sk->extent)
+ return sfread(sf,buf,n);
+
+ if((r = (ssize_t)(sk->extent-addr)) > 0)
+ { if((w = sfread(sf,buf,r)) != r)
+ return w;
+ buf = (char*)buf + r;
+ n -= r;
+ }
+
+ /* do a raw read */
+ if((w = sfrd(f,buf,n,disc)) <= 0)
+ { sk->eof = 1;
+ w = 0;
+ }
+ else
+ {
+ if((p = sfwrite(sf,buf,w)) != w)
+ sk->eof = 1;
+ if(p > 0)
+ sk->extent += p;
+ }
+
+ return r+w;
+}
+
+#if __STD_C
+static Sfoff_t skseek(Sfio_t* f, Sfoff_t addr, int type, Sfdisc_t* disc)
+#else
+static Sfoff_t skseek(f, addr, type, disc)
+Sfio_t* f;
+Sfoff_t addr;
+int type;
+Sfdisc_t* disc;
+#endif
+{
+ Seek_t* sk;
+ Sfio_t* sf;
+ char buf[SF_BUFSIZE];
+ ssize_t r, w;
+
+ sk = (Seek_t*)disc;
+ sf = sk->shadow;
+
+ switch (type)
+ {
+ case SEEK_SET:
+ addr -= sk->discard;
+ break;
+ case SEEK_CUR:
+ addr += sftell(sf);
+ break;
+ case SEEK_END:
+ addr += sk->extent;
+ break;
+ default:
+ return -1;
+ }
+
+ if(addr < 0)
+ return (Sfoff_t)(-1);
+ else if(addr > sk->extent)
+ { if(sk->eof)
+ return (Sfoff_t)(-1);
+
+ /* read enough to reach the seek point */
+ while(addr > sk->extent)
+ { if(addr > sk->extent+sizeof(buf) )
+ w = sizeof(buf);
+ else w = (int)(addr-sk->extent);
+ if((r = sfrd(f,buf,w,disc)) <= 0)
+ w = r-1;
+ else if((w = sfwrite(sf,buf,r)) > 0)
+ sk->extent += w;
+ if(w != r)
+ { sk->eof = 1;
+ break;
+ }
+ }
+
+ if(addr > sk->extent)
+ return (Sfoff_t)(-1);
+ }
+
+ return sfseek(sf,addr,SEEK_SET) + sk->discard;
+}
+
+/* on close, remove the discipline */
+#if __STD_C
+static int skexcept(Sfio_t* f, int type, Void_t* data, Sfdisc_t* disc)
+#else
+static int skexcept(f,type,data,disc)
+Sfio_t* f;
+int type;
+Void_t* data;
+Sfdisc_t* disc;
+#endif
+{
+ Seek_t* sk;
+
+ sk = (Seek_t*)disc;
+
+ switch (type)
+ {
+ case SF_FINAL:
+ case SF_DPOP:
+ sfclose(sk->shadow);
+ free(disc);
+ break;
+ case SFSK_DISCARD:
+ sk->eof = 0;
+ sk->discard += sk->extent;
+ sk->extent = 0;
+ sfseek(sk->shadow,(Sfoff_t)0,SEEK_SET);
+ break;
+ }
+ return 0;
+}
+
+#if __STD_C
+int sfdcseekable(Sfio_t* f)
+#else
+int sfdcseekable(f)
+Sfio_t* f;
+#endif
+{
+ reg Seek_t* sk;
+
+ /* see if already seekable */
+ if(sfseek(f,(Sfoff_t)0,SEEK_CUR) >= 0)
+ return 0;
+
+ if(!(sk = (Seek_t*)malloc(sizeof(Seek_t))) )
+ return -1;
+ memset(sk, 0, sizeof(*sk));
+
+ sk->disc.readf = skread;
+ sk->disc.writef = skwrite;
+ sk->disc.seekf = skseek;
+ sk->disc.exceptf = skexcept;
+ sk->shadow = sftmp(SF_BUFSIZE);
+ sk->discard = 0;
+ sk->extent = 0;
+ sk->eof = 0;
+
+ if(sfdisc(f, (Sfdisc_t*)sk) != (Sfdisc_t*)sk)
+ { sfclose(sk->shadow);
+ free(sk);
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/disc/sfdcslow.c b/usr/src/lib/libast/common/disc/sfdcslow.c
new file mode 100644
index 0000000000..c42f163cf4
--- /dev/null
+++ b/usr/src/lib/libast/common/disc/sfdcslow.c
@@ -0,0 +1,83 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfdchdr.h"
+
+/* Make a stream op return immediately on interrupts.
+** This is useful on slow streams (hence the name).
+**
+** Written by Glenn Fowler (03/18/1998).
+*/
+
+#if __STD_C
+static int slowexcept(Sfio_t* f, int type, Void_t* v, Sfdisc_t* disc)
+#else
+static int slowexcept(f, type, v, disc)
+Sfio_t* f;
+int type;
+Void_t* v;
+Sfdisc_t* disc;
+#endif
+{
+ NOTUSED(f);
+ NOTUSED(v);
+ NOTUSED(disc);
+
+ switch (type)
+ {
+ case SF_FINAL:
+ case SF_DPOP:
+ free(disc);
+ break;
+ case SF_READ:
+ case SF_WRITE:
+ if (errno == EINTR)
+ return(-1);
+ break;
+ }
+
+ return(0);
+}
+
+#if __STD_C
+int sfdcslow(Sfio_t* f)
+#else
+int sfdcslow(f)
+Sfio_t* f;
+#endif
+{
+ Sfdisc_t* disc;
+
+ if(!(disc = (Sfdisc_t*)malloc(sizeof(Sfdisc_t))) )
+ return(-1);
+
+ disc->readf = NIL(Sfread_f);
+ disc->writef = NIL(Sfwrite_f);
+ disc->seekf = NIL(Sfseek_f);
+ disc->exceptf = slowexcept;
+
+ if(sfdisc(f,disc) != disc)
+ { free(disc);
+ return(-1);
+ }
+
+ return(0);
+}
diff --git a/usr/src/lib/libast/common/disc/sfdcsubstr.c b/usr/src/lib/libast/common/disc/sfdcsubstr.c
new file mode 100644
index 0000000000..20a643836b
--- /dev/null
+++ b/usr/src/lib/libast/common/disc/sfdcsubstr.c
@@ -0,0 +1,217 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfdchdr.h"
+
+
+/* Discipline to treat a contiguous segment of a stream as a stream
+** in its own right. The hard part in all this is to allow multiple
+** segments of the stream to be used as substreams at the same time.
+**
+** Written by David G. Korn and Kiem-Phong Vo (03/18/1998)
+*/
+
+typedef struct _subfile_s
+{
+ Sfdisc_t disc; /* sfio discipline */
+ Sfio_t* parent; /* parent stream */
+ Sfoff_t offset; /* starting offset */
+ Sfoff_t extent; /* size wanted */
+ Sfoff_t here; /* current seek location */
+} Subfile_t;
+
+#if __STD_C
+static ssize_t streamio(Sfio_t* f, Void_t* buf, size_t n, Sfdisc_t* disc, int type)
+#else
+static ssize_t streamio(f, buf, n, disc, type)
+Sfio_t* f;
+Void_t* buf;
+size_t n;
+Sfdisc_t* disc;
+int type;
+#endif
+{
+ reg Subfile_t *su;
+ reg Sfoff_t here, parent;
+ reg ssize_t io;
+
+ su = (Subfile_t*)disc;
+
+ /* read just what we need */
+ if(su->extent >= 0 && (ssize_t)n > (io = (ssize_t)(su->extent - su->here)) )
+ n = io;
+ if(n <= 0)
+ return n;
+
+ /* save current location in parent stream */
+ parent = sfsk(f,(Sfoff_t)0,SEEK_CUR,disc);
+
+ /* read data */
+ here = su->here + su->offset;
+ if(sfsk(f,here,SEEK_SET,disc) != here)
+ io = 0;
+ else
+ { if(type == SF_WRITE)
+ io = sfwr(f,buf,n,disc);
+ else io = sfrd(f,buf,n,disc);
+ if(io > 0)
+ su->here += io;
+ }
+
+ /* restore parent current position */
+ sfsk(f,parent,SEEK_SET,disc);
+
+ return io;
+}
+
+#if __STD_C
+static ssize_t streamwrite(Sfio_t* f, const Void_t* buf, size_t n, Sfdisc_t* disc)
+#else
+static ssize_t streamwrite(f, buf, n, disc)
+Sfio_t* f;
+Void_t* buf;
+size_t n;
+Sfdisc_t* disc;
+#endif
+{
+ return streamio(f,(Void_t*)buf,n,disc,SF_WRITE);
+}
+
+#if __STD_C
+static ssize_t streamread(Sfio_t* f, Void_t* buf, size_t n, Sfdisc_t* disc)
+#else
+static ssize_t streamread(f, buf, n, disc)
+Sfio_t* f;
+Void_t* buf;
+size_t n;
+Sfdisc_t* disc;
+#endif
+{
+ return streamio(f,buf,n,disc,SF_READ);
+}
+
+#if __STD_C
+static Sfoff_t streamseek(Sfio_t* f, Sfoff_t pos, int type, Sfdisc_t* disc)
+#else
+static Sfoff_t streamseek(f, pos, type, disc)
+Sfio_t* f;
+Sfoff_t pos;
+int type;
+Sfdisc_t* disc;
+#endif
+{
+ reg Subfile_t* su;
+ reg Sfoff_t here, parent;
+
+ su = (Subfile_t*)disc;
+
+ switch(type)
+ {
+ case SEEK_SET:
+ here = 0;
+ break;
+ case SEEK_CUR:
+ here = su->here;
+ break;
+ case SEEK_END:
+ if(su->extent >= 0)
+ here = su->extent;
+ else
+ { parent = sfsk(f,(Sfoff_t)0,SEEK_CUR,disc);
+ if((here = sfsk(f,(Sfoff_t)0,SEEK_END,disc)) < 0)
+ return -1;
+ else here -= su->offset;
+ sfsk(f,parent,SEEK_SET,disc);
+ }
+ break;
+ default:
+ return -1;
+ }
+
+ pos += here;
+ if(pos < 0 || (su->extent >= 0 && pos >= su->extent))
+ return -1;
+
+ return (su->here = pos);
+}
+
+#if __STD_C
+static int streamexcept(Sfio_t* f, int type, Void_t* data, Sfdisc_t* disc)
+#else
+static int streamexcept(f, type, data, disc)
+Sfio_t* f;
+int type;
+Void_t* data;
+Sfdisc_t* disc;
+#endif
+{
+ if(type == SF_FINAL || type == SF_DPOP)
+ free(disc);
+ return 0;
+}
+
+#if __STD_C
+Sfio_t* sfdcsubstream(Sfio_t* f, Sfio_t* parent, Sfoff_t offset, Sfoff_t extent)
+#else
+Sfio_t* sfdcsubstream(f, parent, offset, extent)
+Sfio_t* f; /* stream */
+Sfio_t* parent; /* parent stream */
+Sfoff_t offset; /* offset in f */
+Sfoff_t extent; /* desired size */
+#endif
+{
+ reg Sfio_t* sp;
+ reg Subfile_t* su;
+ reg Sfoff_t here;
+
+ /* establish that we can seek to offset */
+ if((here = sfseek(parent,(Sfoff_t)0,SEEK_CUR)) < 0 || sfseek(parent,offset,SEEK_SET) < 0)
+ return 0;
+ else sfseek(parent,here,SEEK_SET);
+ sfpurge(parent);
+
+ if (!(sp = f) && !(sp = sfnew(NIL(Sfio_t*), NIL(Void_t*), (size_t)SF_UNBOUND, dup(sffileno(parent)), parent->flags)))
+ return 0;
+
+ if(!(su = (Subfile_t*)malloc(sizeof(Subfile_t))))
+ { if(sp != f)
+ sfclose(sp);
+ return 0;
+ }
+ memset(su, 0, sizeof(*su));
+
+ su->disc.readf = streamread;
+ su->disc.writef = streamwrite;
+ su->disc.seekf = streamseek;
+ su->disc.exceptf = streamexcept;
+ su->parent = parent;
+ su->offset = offset;
+ su->extent = extent;
+
+ if(sfdisc(sp, (Sfdisc_t*)su) != (Sfdisc_t*)su)
+ { free(su);
+ if(sp != f)
+ sfclose(sp);
+ return 0;
+ }
+
+ return sp;
+}
diff --git a/usr/src/lib/libast/common/disc/sfdctee.c b/usr/src/lib/libast/common/disc/sfdctee.c
new file mode 100644
index 0000000000..4be44b3885
--- /dev/null
+++ b/usr/src/lib/libast/common/disc/sfdctee.c
@@ -0,0 +1,102 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfdchdr.h"
+
+/* A discipline to tee the output to a stream to another stream.
+** This is similar to what the "tee" program does. As implemented
+** this discipline only works with file streams.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 03/18/1998.
+*/
+
+/* the discipline structure for tee-ing */
+typedef struct _tee_s
+{ Sfdisc_t disc; /* the sfio discipline structure */
+ Sfio_t* tee; /* the stream to tee to */
+ int status; /* if tee stream is still ok */
+} Tee_t;
+
+/* write to the teed stream. */
+#if __STD_C
+static ssize_t teewrite(Sfio_t* f, const Void_t* buf, size_t size, Sfdisc_t* disc)
+#else
+static ssize_t teewrite(f,buf,size,disc)
+Sfio_t* f; /* the stream being written to */
+Void_t* buf; /* the buffer of data being output */
+size_t size; /* the data size */
+Sfdisc_t* disc; /* the tee discipline */
+#endif
+{
+ reg Tee_t* te = (Tee_t*)disc;
+
+ /* tee data if still ok */
+ if(te->status == 0 && sfwrite(te->tee,buf,size) != (ssize_t)size)
+ te->status = -1;
+
+ /* do the actual write */
+ return sfwr(f,buf,size,disc);
+}
+
+/* on close, remove the discipline */
+#if __STD_C
+static int teeexcept(Sfio_t* f, int type, Void_t* data, Sfdisc_t* disc)
+#else
+static int teeexcept(f,type,data,disc)
+Sfio_t* f;
+int type;
+Void_t* data;
+Sfdisc_t* disc;
+#endif
+{
+ if(type == SF_FINAL || type == SF_DPOP)
+ free(disc);
+
+ return 0;
+}
+
+#if __STD_C
+int sfdctee(Sfio_t* f, Sfio_t* tee)
+#else
+int sfdctee(f, tee)
+Sfio_t* f; /* stream to tee from */
+Sfio_t* tee; /* stream to tee to */
+#endif
+{
+ reg Tee_t* te;
+
+ if(!(te = (Tee_t*)malloc(sizeof(Tee_t))) )
+ return -1;
+
+ te->disc.readf = NIL(Sfread_f);
+ te->disc.seekf = NIL(Sfseek_f);
+ te->disc.writef = teewrite;
+ te->disc.exceptf = teeexcept;
+ te->tee = tee;
+ te->status = 0;
+
+ if(sfdisc(f,(Sfdisc_t*)te) != (Sfdisc_t*)te)
+ { free(te);
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/disc/sfdcunion.c b/usr/src/lib/libast/common/disc/sfdcunion.c
new file mode 100644
index 0000000000..00197c293f
--- /dev/null
+++ b/usr/src/lib/libast/common/disc/sfdcunion.c
@@ -0,0 +1,203 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfdchdr.h"
+
+
+/* Make a sequence of streams act like a single stream.
+** This is for reading only.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 03/18/1998.
+*/
+
+#define UNSEEKABLE 1
+
+typedef struct _file_s
+{ Sfio_t* f; /* the stream */
+ Sfoff_t lower; /* its lowest end */
+} File_t;
+
+typedef struct _union_s
+{
+ Sfdisc_t disc; /* discipline structure */
+ short type; /* type of streams */
+ short c; /* current stream */
+ short n; /* number of streams */
+ Sfoff_t here; /* current location */
+ File_t f[1]; /* array of streams */
+} Union_t;
+
+#if __STD_C
+static ssize_t unwrite(Sfio_t* f, const Void_t* buf, size_t n, Sfdisc_t* disc)
+#else
+static ssize_t unwrite(f, buf, n, disc)
+Sfio_t* f; /* stream involved */
+Void_t* buf; /* buffer to read into */
+size_t n; /* number of bytes to read */
+Sfdisc_t* disc; /* discipline */
+#endif
+{
+ return -1;
+}
+
+#if __STD_C
+static ssize_t unread(Sfio_t* f, Void_t* buf, size_t n, Sfdisc_t* disc)
+#else
+static ssize_t unread(f, buf, n, disc)
+Sfio_t* f; /* stream involved */
+Void_t* buf; /* buffer to read into */
+size_t n; /* number of bytes to read */
+Sfdisc_t* disc; /* discipline */
+#endif
+{
+ reg Union_t* un;
+ reg ssize_t r, m;
+
+ un = (Union_t*)disc;
+ m = n;
+ f = un->f[un->c].f;
+ while(1)
+ { if((r = sfread(f,buf,m)) < 0 || (r == 0 && un->c == un->n-1) )
+ break;
+
+ m -= r;
+ un->here += r;
+
+ if(m == 0)
+ break;
+
+ buf = (char*)buf + r;
+ if(sfeof(f) && un->c < un->n-1)
+ f = un->f[un->c += 1].f;
+ }
+ return n-m;
+}
+
+#if __STD_C
+static Sfoff_t unseek(Sfio_t* f, Sfoff_t addr, int type, Sfdisc_t* disc)
+#else
+static Sfoff_t unseek(f, addr, type, disc)
+Sfio_t* f;
+Sfoff_t addr;
+int type;
+Sfdisc_t* disc;
+#endif
+{
+ reg Union_t* un;
+ reg int i;
+ reg Sfoff_t extent, s;
+
+ un = (Union_t*)disc;
+ if(un->type&UNSEEKABLE)
+ return -1L;
+
+ if(type == 2)
+ { extent = 0;
+ for(i = 0; i < un->n; ++i)
+ extent += (sfsize(un->f[i].f) - un->f[i].lower);
+ addr += extent;
+ }
+ else if(type == 1)
+ addr += un->here;
+
+ if(addr < 0)
+ return -1;
+
+ /* find the stream where the addr could be in */
+ extent = 0;
+ for(i = 0; i < un->n-1; ++i)
+ { s = sfsize(un->f[i].f) - un->f[i].lower;
+ if(addr < extent + s)
+ break;
+ extent += s;
+ }
+
+ s = (addr-extent) + un->f[i].lower;
+ if(sfseek(un->f[i].f,s,0) != s)
+ return -1;
+
+ un->c = i;
+ un->here = addr;
+
+ for(i += 1; i < un->n; ++i)
+ sfseek(un->f[i].f,un->f[i].lower,0);
+
+ return addr;
+}
+
+/* on close, remove the discipline */
+#if __STD_C
+static int unexcept(Sfio_t* f, int type, Void_t* data, Sfdisc_t* disc)
+#else
+static int unexcept(f,type,data,disc)
+Sfio_t* f;
+int type;
+Void_t* data;
+Sfdisc_t* disc;
+#endif
+{
+ if(type == SF_FINAL || type == SF_DPOP)
+ free(disc);
+
+ return 0;
+}
+
+#if __STD_C
+int sfdcunion(Sfio_t* f, Sfio_t** array, int n)
+#else
+int sfdcunion(f, array, n)
+Sfio_t* f;
+Sfio_t** array;
+int n;
+#endif
+{
+ reg Union_t* un;
+ reg int i;
+
+ if(n <= 0)
+ return -1;
+
+ if(!(un = (Union_t*)malloc(sizeof(Union_t)+(n-1)*sizeof(File_t))) )
+ return -1;
+ memset(un, 0, sizeof(*un));
+
+ un->disc.readf = unread;
+ un->disc.writef = unwrite;
+ un->disc.seekf = unseek;
+ un->disc.exceptf = unexcept;
+ un->n = n;
+
+ for(i = 0; i < n; ++i)
+ { un->f[i].f = array[i];
+ if(!(un->type&UNSEEKABLE))
+ { un->f[i].lower = sfseek(array[i],(Sfoff_t)0,1);
+ if(un->f[i].lower < 0)
+ un->type |= UNSEEKABLE;
+ }
+ }
+
+ if(sfdisc(f,(Sfdisc_t*)un) != (Sfdisc_t*)un)
+ { free(un);
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/disc/sfkeyprintf.c b/usr/src/lib/libast/common/disc/sfkeyprintf.c
new file mode 100644
index 0000000000..a0cf5eb1b8
--- /dev/null
+++ b/usr/src/lib/libast/common/disc/sfkeyprintf.c
@@ -0,0 +1,388 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * keyword printf support
+ */
+
+#include <ast.h>
+#include <ccode.h>
+#include <ctype.h>
+#include <sfdisc.h>
+#include <regex.h>
+
+#define FMT_case 1
+#define FMT_edit 2
+
+typedef struct
+{
+ Sffmt_t fmt;
+ void* handle;
+ Sf_key_lookup_t lookup;
+ Sf_key_convert_t convert;
+ Sfio_t* tmp[2];
+ regex_t red[2];
+ regex_t* re[2];
+ int invisible;
+ int level;
+ int version;
+} Fmt_t;
+
+typedef struct
+{
+ char* next;
+ int delimiter;
+ int first;
+} Field_t;
+
+typedef union
+{
+ char** p;
+ char* s;
+ Sflong_t q;
+ long l;
+ int i;
+ short h;
+ char c;
+} Value_t;
+
+#define initfield(f,s) ((f)->first = (f)->delimiter = *((f)->next = (s)))
+
+static char*
+getfield(register Field_t* f, int restore)
+{
+ register char* s;
+ register int n;
+ register int c;
+ register int lp;
+ register int rp;
+ char* b;
+
+ if (!f->delimiter)
+ return 0;
+ s = f->next;
+ if (f->first)
+ f->first = 0;
+ else if (restore)
+ *s = f->delimiter;
+ b = ++s;
+ lp = rp = n = 0;
+ for (;;)
+ {
+ if (!(c = *s++))
+ {
+ f->delimiter = 0;
+ break;
+ }
+ else if (c == CC_esc || c == '\\')
+ {
+ if (*s)
+ s++;
+ }
+ else if (c == lp)
+ n++;
+ else if (c == rp)
+ n--;
+ else if (n <= 0)
+ {
+ if (c == '(' && restore)
+ {
+ lp = '(';
+ rp = ')';
+ n = 1;
+ }
+ else if (c == '[' && restore)
+ {
+ lp = '[';
+ rp = ']';
+ n = 1;
+ }
+ else if (c == f->delimiter)
+ {
+ *(f->next = --s) = 0;
+ break;
+ }
+ }
+ }
+ return b;
+}
+
+/*
+ * sfio %! extension function
+ */
+
+static int
+getfmt(Sfio_t* sp, void* vp, Sffmt_t* dp)
+{
+ register Fmt_t* fp = (Fmt_t*)dp;
+ Value_t* value = (Value_t*)vp;
+ register char* v;
+ char* t;
+ char* b;
+ char* a = 0;
+ char* s = 0;
+ Sflong_t n = 0;
+ int h = 0;
+ int i = 0;
+ int x = 0;
+ int d;
+ Field_t f;
+ regmatch_t match[10];
+
+ fp->level++;
+ if (fp->fmt.t_str && fp->fmt.n_str > 0 && (v = fmtbuf(fp->fmt.n_str + 1)))
+ {
+ memcpy(v, fp->fmt.t_str, fp->fmt.n_str);
+ v[fp->fmt.n_str] = 0;
+ b = v;
+ for (;;)
+ {
+ switch (*v++)
+ {
+ case 0:
+ break;
+ case '(':
+ h++;
+ continue;
+ case ')':
+ h--;
+ continue;
+ case '=':
+ case ':':
+ case ',':
+ if (h <= 0)
+ {
+ a = v;
+ break;
+ }
+ continue;
+ default:
+ continue;
+ }
+ if (i = *--v)
+ {
+ *v = 0;
+ if (i == ':' && fp->fmt.fmt == 's' && strlen(a) > 4 && !isalnum(*(a + 4)))
+ {
+ d = *(a + 4);
+ *(a + 4) = 0;
+ if (streq(a, "case"))
+ x = FMT_case;
+ else if (streq(a, "edit"))
+ x = FMT_edit;
+ *(a + 4) = d;
+ if (x)
+ a = 0;
+ }
+ }
+ break;
+ }
+ n = i;
+ t = fp->fmt.t_str;
+ fp->fmt.t_str = b;
+ h = (*fp->lookup)(fp->handle, &fp->fmt, a, &s, &n);
+ fp->fmt.t_str = t;
+ if (i)
+ *v++ = i;
+ }
+ else
+ {
+ h = (*fp->lookup)(fp->handle, &fp->fmt, a, &s, &n);
+ v = 0;
+ }
+ fp->fmt.flags |= SFFMT_VALUE;
+ switch (fp->fmt.fmt)
+ {
+ case 'c':
+ value->c = s ? *s : n;
+ break;
+ case 'd':
+ case 'i':
+ fp->fmt.size = sizeof(Sflong_t);
+ value->q = (Sflong_t)(s ? strtoll(s, NiL, 0) : n);
+ break;
+ case 'o':
+ case 'u':
+ case 'x':
+ fp->fmt.size = sizeof(Sflong_t);
+ value->q = s ? (Sflong_t)strtoull(s, NiL, 0) : n;
+ break;
+ case 'p':
+ if (s)
+ n = strtoll(s, NiL, 0);
+ value->p = pointerof(n);
+ break;
+ case 'q':
+ if (s)
+ {
+ fp->fmt.fmt = 's';
+ value->s = fmtquote(s, "$'", "'", strlen(s), 0);
+ }
+ else
+ {
+ fp->fmt.fmt = 'd';
+ value->q = n;
+ }
+ break;
+ case 's':
+ if (!s && (!h || !fp->tmp[1] && !(fp->tmp[1] = sfstropen()) || sfprintf(fp->tmp[1], "%I*d", sizeof(n), n) <= 0 || !(s = sfstruse(fp->tmp[1]))))
+ s = "";
+ if (x)
+ {
+ h = 0;
+ d = initfield(&f, v + 4);
+ switch (x)
+ {
+ case FMT_case:
+ while ((a = getfield(&f, 1)) && (v = getfield(&f, 0)))
+ {
+ if (strmatch(s, a))
+ {
+ Fmt_t fmt;
+
+ fmt = *fp;
+ fmt.fmt.form = v;
+ for (h = 0; h < elementsof(fmt.tmp); h++)
+ fmt.tmp[h] = 0;
+ if (!fp->tmp[0] && !(fp->tmp[0] = sfstropen()) || sfprintf(fp->tmp[0], "%!", &fmt) <= 0 || !(s = sfstruse(fp->tmp[0])))
+ s = "";
+ *(v - 1) = d;
+ if (f.delimiter)
+ *f.next = d;
+ for (h = 0; h < elementsof(fmt.tmp); h++)
+ if (fmt.tmp[h])
+ sfclose(fmt.tmp[h]);
+ h = 1;
+ break;
+ }
+ *(v - 1) = d;
+ }
+ break;
+ case FMT_edit:
+ for (x = 0; *f.next; x ^= 1)
+ {
+ if (fp->re[x])
+ regfree(fp->re[x]);
+ else
+ fp->re[x] = &fp->red[x];
+ if (regcomp(fp->re[x], f.next, REG_DELIMITED|REG_NULL))
+ break;
+ f.next += fp->re[x]->re_npat;
+ if (regsubcomp(fp->re[x], f.next, NiL, 0, 0))
+ break;
+ f.next += fp->re[x]->re_npat;
+ if (!regexec(fp->re[x], s, elementsof(match), match, 0) && !regsubexec(fp->re[x], s, elementsof(match), match))
+ {
+ s = fp->re[x]->re_sub->re_buf;
+ if (fp->re[x]->re_sub->re_flags & REG_SUB_STOP)
+ break;
+ }
+ }
+ h = 1;
+ break;
+ }
+ if (!h)
+ s = "";
+ }
+ value->s = s;
+ if (fp->level == 1)
+ while ((s = strchr(s, CC_esc)) && *(s + 1) == '[')
+ do fp->invisible++; while (*s && !islower(*s++));
+ break;
+ case 'Z':
+ fp->fmt.fmt = 'c';
+ value->c = 0;
+ break;
+ case '\n':
+ value->s = "\n";
+ break;
+ case '.':
+ value->i = n;
+ break;
+ default:
+ if ((!fp->convert || !(value->s = (*fp->convert)(fp->handle, &fp->fmt, a, s, n))) && (!fp->tmp[0] && !(fp->tmp[0] = sfstropen()) || sfprintf(fp->tmp[0], "%%%c", fp->fmt.fmt) <= 0 || !(value->s = sfstruse(fp->tmp[0]))))
+ value->s = "";
+ break;
+ }
+ fp->level--;
+ return 0;
+}
+
+/*
+ * this is the 20000308 interface with Sffmt_t* callback args
+ */
+
+int
+sfkeyprintf(Sfio_t* sp, void* handle, const char* format, Sf_key_lookup_t lookup, Sf_key_convert_t convert)
+{
+ register int i;
+ int r;
+ Fmt_t fmt;
+
+ memset(&fmt, 0, sizeof(fmt));
+ fmt.version = 20030909;
+ fmt.fmt.version = SFIO_VERSION;
+ fmt.fmt.form = (char*)format;
+ fmt.fmt.extf = getfmt;
+ fmt.handle = handle;
+ fmt.lookup = lookup;
+ fmt.convert = convert;
+ r = sfprintf(sp, "%!", &fmt) - fmt.invisible;
+ for (i = 0; i < elementsof(fmt.tmp); i++)
+ if (fmt.tmp[i])
+ sfclose(fmt.tmp[i]);
+ return r;
+}
+
+/*
+ * this is the original interface
+ */
+
+#undef sfkeyprintf
+
+int
+sfkeyprintf(Sfio_t* sp, void* handle, const char* format, Sf_key_lookup_t lookup, Sf_key_convert_t convert)
+{
+ register int i;
+ int r;
+ Fmt_t fmt;
+
+ memset(&fmt, 0, sizeof(fmt));
+ fmt.fmt.version = SFIO_VERSION;
+ fmt.fmt.form = (char*)format;
+ fmt.fmt.extf = getfmt;
+ fmt.handle = handle;
+ fmt.lookup = lookup;
+ fmt.convert = convert;
+ r = sfprintf(sp, "%!", &fmt) - fmt.invisible;
+ for (i = 0; i < elementsof(fmt.tmp); i++)
+ if (fmt.tmp[i])
+ sfclose(fmt.tmp[i]);
+ for (i = 0; i < elementsof(fmt.re); i++)
+ if (fmt.re[i])
+ regfree(fmt.re[i]);
+ return r;
+}
diff --git a/usr/src/lib/libast/common/disc/sfstrtmp.c b/usr/src/lib/libast/common/disc/sfstrtmp.c
new file mode 100644
index 0000000000..d6f358f672
--- /dev/null
+++ b/usr/src/lib/libast/common/disc/sfstrtmp.c
@@ -0,0 +1,62 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * sfio tmp string buffer support
+ */
+
+#include <sfio_t.h>
+#include <ast.h>
+
+#if __OBSOLETE__ >= 20070101 /* sfstr* macros now use sfsetbuf() */
+
+NoN(sfstrtmp)
+
+#else
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+/*
+ * replace buffer in string stream f for either SF_READ or SF_WRITE
+ */
+
+extern int
+sfstrtmp(register Sfio_t* f, int mode, void* buf, size_t siz)
+{
+ if (!(f->_flags & SF_STRING))
+ return -1;
+ if (f->_flags & SF_MALLOC)
+ free(f->_data);
+ f->_flags &= ~(SF_ERROR|SF_MALLOC);
+ f->mode = mode;
+ f->_next = f->_data = (unsigned char*)buf;
+ f->_endw = f->_endr = f->_endb = f->_data + siz;
+ f->_size = siz;
+ return 0;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/features/align.c b/usr/src/lib/libast/common/features/align.c
new file mode 100644
index 0000000000..f8aebf70b0
--- /dev/null
+++ b/usr/src/lib/libast/common/features/align.c
@@ -0,0 +1,167 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * generate align features
+ *
+ * NOTE: two's complement binary integral representation assumed
+ */
+
+#include "FEATURE/common"
+
+#include <setjmp.h>
+
+union _u_
+{
+ long u1;
+ char* u2;
+ double u3;
+ char u4[1024];
+ intmax_t u5;
+ uintmax_t u6;
+ _ast_fltmax_t u7;
+ void* u8;
+ char* (*u9)();
+ jmp_buf u10;
+};
+
+struct _s_
+{
+ char s1;
+ union _u_ s2;
+};
+
+#define roundof(x,y) (((x)+((y)-1))&~((y)-1))
+
+static union _u_ u;
+static union _u_ v;
+
+int
+main()
+{
+ register int i;
+ register int j;
+ register int k;
+
+ int align0;
+ int align1;
+ int align2;
+ unsigned long bit1;
+ unsigned long bit2;
+ unsigned long bits0;
+ unsigned long bits1;
+ unsigned long bits2;
+
+ u.u2 = u.u4;
+ v.u2 = u.u2 + 1;
+ bit1 = u.u1 ^ v.u1;
+ v.u2 = u.u2 + 2;
+ bit2 = u.u1 ^ v.u1;
+ align0 = sizeof(struct _s_) - sizeof(union _u_);
+ bits0 = 0;
+ k = 0;
+ for (j = 0; j < align0; j++)
+ {
+ u.u2 = u.u4 + j;
+ bits1 = 0;
+ for (i = 0; i < align0; i++)
+ {
+ v.u2 = u.u2 + i;
+ bits1 |= u.u1 ^ v.u1;
+ }
+ if (!bits0 || bits1 < bits0)
+ {
+ bits0 = bits1;
+ k = j;
+ }
+ }
+ align1 = roundof(align0, 2);
+ u.u2 = u.u4 + k;
+ for (bits1 = bits0; i < align1; i++)
+ {
+ v.u2 = u.u2 + i;
+ bits1 |= u.u1 ^ v.u1;
+ }
+ align2 = roundof(align0, 4);
+ for (bits2 = bits1; i < align2; i++)
+ {
+ v.u2 = u.u2 + i;
+ bits2 |= u.u1 ^ v.u1;
+ }
+ printf("typedef unsigned %s ALIGN_INTEGRAL;\n", sizeof(char*) >= sizeof(long) ? "long" : sizeof(char*) >= sizeof(int) ? "int" : "short");
+ printf("\n");
+ printf("#define ALIGN_CHUNK %d\n", sizeof(char*) >= 4 ? 8192 : 1024);
+ printf("#define ALIGN_INTEGRAL %s\n", sizeof(char*) >= sizeof(long) ? "long" : sizeof(char*) >= sizeof(int) ? "int" : "short");
+ printf("#define ALIGN_INTEGER(x) ((ALIGN_INTEGRAL)(x))\n");
+ printf("#define ALIGN_POINTER(x) ((char*)(x))\n");
+ if (bits2 == (align2 - 1)) printf("#define ALIGN_ROUND(x,y) ALIGN_POINTER(ALIGN_INTEGER((x)+(y)-1)&~((y)-1))\n");
+ else printf("#define ALIGN_ROUND(x,y) ALIGN_POINTER(ALIGN_INTEGER(ALIGN_ALIGN(x)+(((y)+%d)/%d)-1)&~((((y)+%d)/%d)-1))\n", align0, align0, align0, align0);
+ printf("\n");
+ if (align0 == align2)
+ {
+ printf("#define ALIGN_BOUND ALIGN_BOUND2\n");
+ printf("#define ALIGN_ALIGN(x) ALIGN_ALIGN2(x)\n");
+ printf("#define ALIGN_TRUNC(x) ALIGN_TRUNC2(x)\n");
+ }
+ else if (align0 == align1)
+ {
+ printf("#define ALIGN_BOUND ALIGN_BOUND1\n");
+ printf("#define ALIGN_ALIGN(x) ALIGN_ALIGN1(x)\n");
+ printf("#define ALIGN_TRUNC(x) ALIGN_TRUNC1(x)\n");
+ }
+ else
+ {
+ printf("#define ALIGN_BOUND 1\n");
+ printf("#define ALIGN_ALIGN(x) ALIGN_POINTER(x)\n");
+ printf("#define ALIGN_TRUNC(x) ALIGN_POINTER(x)\n");
+ }
+ printf("\n");
+ printf("#define ALIGN_BIT1 0x%lx\n", bit1);
+ if (align1 == align2)
+ {
+ printf("#define ALIGN_BOUND1 ALIGN_BOUND2\n");
+ printf("#define ALIGN_ALIGN1(x) ALIGN_ALIGN2(x)\n");
+ printf("#define ALIGN_TRUNC1(x) ALIGN_TRUNC2(x)\n");
+ }
+ else
+ {
+ printf("#define ALIGN_BOUND1 %d\n", align1);
+ printf("#define ALIGN_ALIGN1(x) ALIGN_TRUNC1((x)+%d)\n", align1 - 1);
+ printf("#define ALIGN_TRUNC1(x) ALIGN_POINTER(ALIGN_INTEGER((x)+%d)&0x%lx)\n", align1 - 1, ~(bits0|bits1));
+ }
+ printf("#define ALIGN_CLRBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x%lx)\n", ~bit1);
+ printf("#define ALIGN_SETBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x%lx)\n", bit1);
+ printf("#define ALIGN_TSTBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x%lx)\n", bit1);
+ printf("\n");
+ printf("#define ALIGN_BIT2 0x%lx\n", bit2);
+ printf("#define ALIGN_BOUND2 %d\n", align2);
+ printf("#define ALIGN_ALIGN2(x) ALIGN_TRUNC2((x)+%d)\n", align2 - 1);
+ printf("#define ALIGN_TRUNC2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x%lx)\n", ~(bits0|bits1|bits2));
+ printf("#define ALIGN_CLRBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x%lx)\n", ~bit2);
+ printf("#define ALIGN_SETBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x%lx)\n", bit2);
+ printf("#define ALIGN_TSTBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x%lx)\n", bit2);
+ printf("\n");
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/features/botch.c b/usr/src/lib/libast/common/features/botch.c
new file mode 100644
index 0000000000..9107ba4d6a
--- /dev/null
+++ b/usr/src/lib/libast/common/features/botch.c
@@ -0,0 +1,72 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * generate ast traps for botched standard prototypes
+ */
+
+#include <sys/types.h>
+
+#include "FEATURE/lib"
+#include "FEATURE/types"
+
+#if _lib_getgroups
+extern int getgroups(int, gid_t*);
+#endif
+
+int
+main()
+{
+#if _lib_getgroups
+ if (sizeof(int) > sizeof(gid_t))
+ {
+ int n;
+ int i;
+ int r;
+ gid_t groups[32 * sizeof(int) / sizeof(gid_t)];
+
+ r = sizeof(int) / sizeof(gid_t);
+ if ((n = getgroups((sizeof(groups) / sizeof(groups[0])) / r, groups)) > 0)
+ for (i = 1; i <= n; i++)
+ {
+ groups[i] = ((gid_t)0);
+ if (getgroups(i, groups) != i)
+ goto botched;
+ if (groups[i] != ((gid_t)0))
+ goto botched;
+ groups[i] = ((gid_t)-1);
+ if (getgroups(i, groups) != i)
+ goto botched;
+ if (groups[i] != ((gid_t)-1))
+ goto botched;
+ }
+ }
+ return 0;
+ botched:
+ printf("#undef getgroups\n");
+ printf("#define getgroups _ast_getgroups /* implementation botches gid_t* arg */\n");
+#endif
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/features/ccode b/usr/src/lib/libast/common/features/ccode
new file mode 100644
index 0000000000..0175763008
--- /dev/null
+++ b/usr/src/lib/libast/common/features/ccode
@@ -0,0 +1,81 @@
+tst output{
+ int main()
+ {
+ printf("\n");
+ printf("#define CC_ASCII 1 /* ISO-8859-1 */\n");
+ printf("#define CC_EBCDIC_E 2 /* Xopen dd(1) EBCDIC */\n");
+ printf("#define CC_EBCDIC_I 3 /* Xopen dd(1) IBM */\n");
+ printf("#define CC_EBCDIC_O 4 /* IBM-1047 mvs OpenEdition */\n");
+ printf("#define CC_EBCDIC_S 5 /* Siemens posix-bc */\n");
+ printf("#define CC_EBCDIC_H 6 /* IBM-37 AS/400 */\n");
+ printf("#define CC_EBCDIC_M 7 /* IBM mvs cobol */\n");
+ printf("#define CC_EBCDIC_U 8 /* microfocus cobol */\n");
+ printf("\n");
+ printf("#define CC_MAPS 8 /* number of code maps */\n");
+ printf("\n");
+ printf("#define CC_EBCDIC CC_EBCDIC_E\n");
+ printf("#define CC_EBCDIC1 CC_EBCDIC_E\n");
+ printf("#define CC_EBCDIC2 CC_EBCDIC_I\n");
+ printf("#define CC_EBCDIC3 CC_EBCDIC_O\n");
+ printf("\n");
+ switch ('~')
+ {
+ case 0137:
+ printf("#define CC_NATIVE CC_EBCDIC_E /* native character code */\n");
+ break;
+ case 0176:
+ printf("#define CC_NATIVE CC_ASCII /* native character code */\n");
+ break;
+ case 0241:
+ switch ('\n')
+ {
+ case 0025:
+ printf("#define CC_NATIVE CC_EBCDIC_O /* native character code */\n");
+ break;
+ default:
+ switch ('[')
+ {
+ case 0272:
+ printf("#define CC_NATIVE CC_EBCDIC_H /* native character code */\n");
+ break;
+ default:
+ printf("#define CC_NATIVE CC_EBCDIC_I /* native character code */\n");
+ break;
+ }
+ break;
+ }
+ break;
+ case 0377:
+ printf("#define CC_NATIVE CC_EBCDIC_S /* native character code */\n");
+ break;
+ default:
+ switch ('A')
+ {
+ case 0301:
+ printf("#define CC_NATIVE CC_EBCDIC_O /* native character code */\n");
+ break;
+ default:
+ printf("#define CC_NATIVE CC_ASCII /* native character code */\n");
+ break;
+ }
+ break;
+ }
+ if ('A' == 0101)
+ {
+ printf("#define CC_ALIEN CC_EBCDIC /* alien character code */\n\n");
+ printf("#define CC_bel 0007 /* bel character */\n");
+ printf("#define CC_esc 0033 /* esc character */\n");
+ printf("#define CC_sub 0032 /* sub character */\n");
+ printf("#define CC_vt 0013 /* vt character */\n");
+ }
+ else
+ {
+ printf("#define CC_ALIEN CC_ASCII /* alien character code */\n\n");
+ printf("#define CC_bel 0057 /* bel character */\n");
+ printf("#define CC_esc 0047 /* esc character */\n");
+ printf("#define CC_sub 0077 /* sub character */\n");
+ printf("#define CC_vt 0013 /* vt character */\n");
+ }
+ return 0;
+ }
+}end
diff --git a/usr/src/lib/libast/common/features/common b/usr/src/lib/libast/common/features/common
new file mode 100644
index 0000000000..ebb697fedb
--- /dev/null
+++ b/usr/src/lib/libast/common/features/common
@@ -0,0 +1,540 @@
+iff AST_COMMON
+hdr pthread,stdarg,stddef,stdint,inttypes,types,unistd
+sys types
+typ long.double,size_t,ssize_t
+
+mac SF_APPEND,SF_CLOSE sys/stat.h sys/socket.h
+
+dll import note{ Microsoft import/export nonsense }end execute{
+ __declspec(dllimport) int foo;
+ int main() { return foo == 5 ? 0 : 1; }
+ int bar = 5;
+ int* _imp__foo = &bar;
+}end
+
+std proto note{ standard C prototypes ok }end compile{
+ extern int foo(int, int);
+ bar() { foo(1, 1); }
+}end
+
+tst ptr_void note{ standard C void* ok }end compile{
+ extern void* foo();
+ void* bar() { return foo(); }
+}end
+
+cat{
+ /* disable non-standard linux/gnu inlines */
+ #ifdef __GNUC__
+ # undef __OPTIMIZE_SIZE__
+ # define __OPTIMIZE_SIZE__ 1
+ #endif
+
+ /* __STD_C indicates that the language is ANSI-C or C++ */
+ #if !defined(__STD_C) && __STDC__
+ # define __STD_C 1
+ #endif
+ #if !defined(__STD_C) && (__cplusplus || c_plusplus)
+ # define __STD_C 1
+ #endif
+ #if !defined(__STD_C) && _std_proto
+ # define __STD_C 1
+ #endif
+ #if !defined(__STD_C)
+ # define __STD_C 0
+ #endif
+
+ /* extern symbols must be protected against C++ name mangling */
+ #ifndef _BEGIN_EXTERNS_
+ # if __cplusplus || c_plusplus
+ # define _BEGIN_EXTERNS_ extern "C" {
+ # define _END_EXTERNS_ }
+ # else
+ # define _BEGIN_EXTERNS_
+ # define _END_EXTERNS_
+ # endif
+ #endif
+
+ /* _ARG_ simplifies function prototyping among flavors of C */
+ #ifndef _ARG_
+ # if __STD_C
+ # define _ARG_(x) x
+ # else
+ # define _ARG_(x) ()
+ # endif
+ #endif
+
+ /* _NIL_ simplifies defining nil pointers to a given type */
+ #ifndef _NIL_
+ # define _NIL_(x) ((x)0)
+ #endif
+
+ /* __INLINE__ is the inline keyword */
+ #if !defined(__INLINE__) && defined(__cplusplus)
+ # define __INLINE__ inline
+ #endif
+ #if !defined(__INLINE__) && defined(_WIN32) && !defined(__GNUC__)
+ # define __INLINE__ __inline
+ #endif
+
+ /* Void_t is defined so that Void_t* can address any type */
+ #ifndef Void_t
+ # if __STD_C
+ # define Void_t void
+ # else
+ # define Void_t char
+ # endif
+ #endif
+
+ /* windows variants and veneers */
+ #if !defined(_WINIX) && (_UWIN || __CYGWIN__ || __EMX__)
+ # define _WINIX 1
+ #endif
+
+ /* dynamic linked library external scope handling */
+ #ifdef __DYNAMIC__
+ # undef __DYNAMIC__
+ # ifndef _DLL
+ # define _DLL 1
+ # endif
+ #endif
+ #if _dll_import
+ # if _BLD_STATIC && !_BLD_DLL
+ # undef _DLL
+ # else
+ # if !_UWIN && !defined(_DLL)
+ # define _DLL 1
+ # endif
+ # endif
+ # if !defined(__EXPORT__) && _BLD_DLL
+ # define __EXPORT__ __declspec(dllexport)
+ # endif
+ # if !defined(__IMPORT__) && ( _BLD_DLL || defined(_DLL) )
+ # define __IMPORT__ __declspec(dllimport)
+ # endif
+ # if _BLD_DLL && _UWIN
+ # define __DYNAMIC__(v) (_ast_getdll()->_ast_ ## v)
+ # endif
+ #endif
+ #if !defined(_astimport)
+ # if defined(__IMPORT__) && defined(_DLL)
+ # define _astimport __IMPORT__
+ # else
+ # define _astimport extern
+ # endif
+ #endif
+ #if _dll_import && ( !_BLD_DLL || _WINIX && !_UWIN )
+ # ifdef __STDC__
+ # define __EXTERN__(T,obj) extern T obj; T* _imp__ ## obj = &obj
+ # define __DEFINE__(T,obj,val) T obj = val; T* _imp__ ## obj = &obj
+ # else
+ # define __EXTERN__(T,obj) extern T obj; T* _imp__/**/obj = &obj
+ # define __DEFINE__(T,obj,val) T obj = val; T* _imp__/**/obj = &obj
+ # endif
+ #else
+ # define __EXTERN__(T,obj) extern T obj
+ # define __DEFINE__(T,obj,val) T obj = val
+ #endif
+}end
+
+tst ast_LL note{ LL numeric suffix supported }end compile{
+ int i = 1LL;
+ unsigned int u = 1ULL; /* NOTE: some compilers choke on 1LLU */
+}end
+
+tst - -DN=1 - -DN=2 - -DN=3 - -DN=4 - -DN=5 - -DN=6 - -DN=7 - -DN=8 - -DN=0 output{
+ #define _BYTESEX_H
+
+ #include <string.h>
+ #include <sys/types.h>
+
+ #if _STD_
+ #if N == 1
+ #define _ast_int8_t long
+ #define _ast_int8_str "long"
+ #endif
+ #if N == 2
+ #define _ast_int8_t long long
+ #define _ast_int8_str "long long"
+ #endif
+ #if N == 3
+ #define _ast_int8_t __int64
+ #define _ast_int8_str "__int64"
+ #endif
+ #if N == 4
+ #define _ast_int8_t __int64_t
+ #define _ast_int8_str "__int64_t"
+ #endif
+ #if N == 5
+ #define _ast_int8_t _int64_t
+ #define _ast_int8_str "_int64_t"
+ #endif
+ #if N == 6
+ #define _ast_int8_t int64_t
+ #define _ast_int8_str "int64_t"
+ #endif
+ #if N == 7
+ #define _ast_int8_t _int64
+ #define _ast_int8_str "_int64"
+ #endif
+ #if N == 8
+ #define _ast_int8_t int64
+ #define _ast_int8_str "int64"
+ #endif
+ #endif
+
+ #define elementsof(x) (sizeof(x)/sizeof(x[0]))
+
+ static char i_char = 1;
+ static short i_short = 1;
+ static int i_int = 1;
+ static long i_long = 1L;
+ #ifdef _ast_int8_t
+ #if _ast_LL
+ static _ast_int8_t i_long_long = 1LL;
+ static unsigned _ast_int8_t u_long_long = 18446744073709551615ULL;
+ #else
+ static _ast_int8_t i_long_long = 1;
+ static unsigned _ast_int8_t u_long_long = 18446744073709551615;
+ #endif
+ #endif
+
+ static struct
+ {
+ char* name;
+ int size;
+ char* swap;
+ } int_type[] =
+ {
+ "char", sizeof(char), (char*)&i_char,
+ "short", sizeof(short), (char*)&i_short,
+ "int", sizeof(int), (char*)&i_int,
+ "long", sizeof(long), (char*)&i_long,
+ #ifdef _ast_int8_t
+ _ast_int8_str, sizeof(_ast_int8_t), (char*)&i_long_long,
+ #endif
+ };
+
+ static int int_size[] = { 1, 2, 4, 8 };
+
+ int
+ main()
+ {
+ register int t;
+ register int s;
+ register int m = 1;
+ register int b = 1;
+ register int w = 0;
+
+ #ifdef _ast_int8_t
+ unsigned _ast_int8_t p;
+ char buf[64];
+
+ if (int_type[elementsof(int_type)-1].size <= 4)
+ return 1;
+ p = 0x12345678;
+ p <<= 32;
+ p |= 0x9abcdef0;
+ sprintf(buf, "0x%016llx", p);
+ if (strcmp(buf, "0x123456789abcdef0"))
+ return 1;
+ #endif
+ for (s = 0; s < elementsof(int_size); s++)
+ {
+ for (t = 0; t < elementsof(int_type) && int_type[t].size < int_size[s]; t++);
+ if (t < elementsof(int_type))
+ {
+ m = int_size[s];
+ #if __INTERIX
+ if (m == 8)
+ {
+ printf("#ifdef _MSC_VER\n");
+ printf("#define _ast_int8_t __int64\n");
+ printf("#else\n");
+ printf("#define _ast_int8_t long long\n");
+ printf("#endif\n");
+ }
+ else
+ #endif
+ printf("#define _ast_int%d_t %s\n", m, int_type[t].name);
+ if (m > 1)
+ {
+ if (*int_type[t].swap)
+ w |= b;
+ b <<= 1;
+ }
+ }
+ }
+ printf("#define _ast_intmax_t _ast_int%d_t\n", m);
+ if (m == sizeof(long))
+ printf("#define _ast_intmax_long 1\n");
+ printf("#define _ast_intswap %d\n", w);
+ printf("\n");
+ return 0;
+ }
+}end
+
+tst - -DN=1 - -DN=0 output{
+ #define _BYTESEX_H
+
+ #include <string.h>
+ #include <sys/types.h>
+
+ #if !N || !_STD_
+ #undef _typ_long_double
+ #endif
+
+ #define elementsof(x) (sizeof(x)/sizeof(x[0]))
+
+ static struct
+ {
+ char* name;
+ int size;
+ } flt_type[] =
+ {
+ "float", sizeof(float),
+ "double", sizeof(double),
+ #ifdef _typ_long_double
+ "long double", sizeof(long double),
+ #endif
+ };
+
+ int
+ main()
+ {
+ register int t;
+ register int m = 1;
+
+ #ifdef _typ_long_double
+ long double p;
+ char buf[64];
+
+ if (flt_type[elementsof(flt_type)-1].size <= sizeof(double))
+ return 1;
+ p = 1.12345E-55;
+ sprintf(buf, "%1.5LE", p);
+ if (strcmp(buf, "1.12345E-55"))
+ return 1;
+ #endif
+ for (t = 0; t < elementsof(flt_type); t++)
+ {
+ while (t < (elementsof(flt_type) - 1) && flt_type[t].size == flt_type[t + 1].size)
+ t++;
+ m = flt_type[t].size;
+ printf("#define _ast_flt%d_t %s\n", flt_type[t].size, flt_type[t].name);
+ }
+ printf("#define _ast_fltmax_t _ast_flt%d_t\n", m);
+ if (m == sizeof(double))
+ printf("#define _ast_fltmax_double 1\n");
+ return 0;
+ }
+}end
+
+typ int8_t stdint.h inttypes.h no{
+ #undef _typ_int8_t
+ #define _typ_int8_t 1
+ typedef _ast_int1_t int8_t;
+}end
+typ uint8_t stdint.h inttypes.h no{
+ #undef _typ_uint8_t
+ #define _typ_uint8_t 1
+ typedef unsigned _ast_int1_t uint8_t;
+}end
+typ int16_t stdint.h inttypes.h no{
+ #undef _typ_int16_t
+ #define _typ_int16_t 1
+ typedef _ast_int2_t int16_t;
+}end
+typ uint16_t stdint.h inttypes.h no{
+ #undef _typ_uint16_t
+ #define _typ_uint16_t 1
+ typedef unsigned _ast_int2_t uint16_t;
+}end
+typ int32_t stdint.h inttypes.h no{
+ #undef _typ_int32_t
+ #define _typ_int32_t 1
+ typedef _ast_int4_t int32_t;
+}end
+typ uint32_t stdint.h inttypes.h no{
+ #undef _typ_uint32_t
+ #define _typ_uint32_t 1
+ typedef unsigned _ast_int4_t uint32_t;
+}end
+typ int64_t stdint.h inttypes.h no{
+ #ifdef _ast_int8_t
+ #undef _typ_int64_t
+ #define _typ_int64_t 1
+ typedef _ast_int8_t int64_t;
+ #endif
+}end
+typ uint64_t stdint.h inttypes.h no{
+ #ifdef _ast_int8_t
+ #undef _typ_uint64_t
+ #define _typ_uint64_t 1
+ typedef unsigned _ast_int8_t uint64_t;
+ #endif
+}end
+typ intmax_t stdint.h inttypes.h no{
+ typedef _ast_intmax_t intmax_t;
+}end
+typ uintmax_t stdint.h inttypes.h no{
+ typedef unsigned _ast_intmax_t uintmax_t;
+}end
+
+tst - -DTRY=1 - -DTRY=1 -Dvoid=char - -DTRY=2 - -DTRY=3 - -DTRY=4 output{
+ #if _STD_ && _hdr_stdarg
+ #include <stdarg.h>
+ static void
+ varyfunny(int* p, ...)
+ {
+ va_list ap;
+ va_start(ap, p);
+ #if TRY == 1
+ *p = *ap++ != 0;
+ #endif /*TRY == 1*/
+ #if TRY == 2
+ *p = *ap != 0;
+ #endif /*TRY == 2*/
+ #if TRY == 3
+ *p = ap++ != 0;
+ #endif /*TRY == 3*/
+ va_end(ap);
+ }
+ #else
+ #include <varargs.h>
+ static void
+ varyfunny(va_alist)
+ va_dcl
+ {
+ va_list ap;
+ int* p;
+ va_start(ap);
+ p = va_arg(ap, int*);
+ #if TRY == 1
+ *p = *ap++ != 0;
+ #endif /*TRY == 1*/
+ #if TRY == 2
+ *p = *ap != 0;
+ #endif /*TRY == 2*/
+ #if TRY == 3
+ *p = ap++ != 0;
+ #endif /*TRY == 3*/
+ va_end(ap);
+ }
+ #endif
+ int
+ main()
+ {
+ int r;
+ printf("\n#ifndef va_listref\n");
+ #if TRY == 4
+ printf("#define va_listref(p) (&(p))\t");
+ printf("/* pass va_list to varargs function */\n");
+ printf("#define va_listval(p) (*(p))\t");
+ printf("/* retrieve va_list from va_arg(ap,va_listarg) */\n");
+ printf("#define va_listarg va_list*\t");
+ printf("/* va_arg() va_list type */\n");
+ #else
+ varyfunny(&r);
+ printf("#define va_listref(p) (p)\t");
+ printf("/* pass va_list to varargs function */\n");
+ if (sizeof(va_list) > sizeof(void*))
+ printf("#define va_listval(p) (*(p))\t");
+ else
+ printf("#define va_listval(p) (p)\t");
+ printf("/* retrieve va_list from va_arg(ap,va_listarg) */\n");
+ #if TRY == 2
+ printf("#define va_listarg va_list*\t");
+ #else
+ printf("#define va_listarg va_list\t");
+ #endif /*TRY == 2*/
+ printf("/* va_arg() va_list type */\n");
+ #endif /*TRY == 4*/
+
+ #if _UWIN
+ printf("#ifndef va_copy\n");
+ printf("#define va_copy(to,fr) ((to)=(fr))\t");
+ printf("/* copy va_list fr -> to */\n");
+ printf("#endif\n");
+ #else
+ #if !defined(va_copy)
+ #if defined(__va_copy)
+ printf("#ifndef va_copy\n");
+ printf("#define va_copy(to,fr) __va_copy(to,fr)\t");
+ printf("/* copy va_list fr -> to */\n");
+ printf("#endif\n");
+ #else
+ #if TRY == 2
+ printf("#ifndef va_copy\n");
+ printf("#define va_copy(to,fr) memcpy(to,fr,sizeof(va_list))\t");
+ printf("/* copy va_list fr -> to */\n");
+ printf("#endif\n");
+ #else
+ printf("#ifndef va_copy\n");
+ printf("#define va_copy(to,fr) ((to)=(fr))\t");
+ printf("/* copy va_list fr -> to */\n");
+ printf("#endif\n");
+ #endif
+ #endif
+ #endif
+ #endif
+
+ printf("#ifndef va_start\n");
+ printf("#if __STD_C\n");
+ printf("#include <stdarg.h>\n");
+ printf("#else\n");
+ printf("#include <varargs.h>\n");
+ printf("#endif\n");
+ printf("#endif\n");
+
+ printf("#endif\n");
+ return 0;
+ }
+}end
+
+cat{
+ #ifndef _AST_STD_H
+ # if __STD_C && _hdr_stddef
+ # include <stddef.h>
+ # endif
+ # if _sys_types
+ # include <sys/types.h>
+ # endif
+ # if _hdr_stdint
+ # include <stdint.h>
+ # else
+ # if _hdr_inttypes
+ # include <inttypes.h>
+ # endif
+ # endif
+ #endif
+ #if !_typ_size_t
+ # define _typ_size_t 1
+ typedef int size_t;
+ #endif
+ #if !_typ_ssize_t
+ # define _typ_ssize_t 1
+ typedef int ssize_t;
+ #endif
+ #ifndef _AST_STD_H
+ # define _def_map_ast 1
+ # if !_def_map_ast
+ # include <ast_map.h>
+ # endif
+ #endif
+}end
+
+run{
+ grep __NO_INCLUDE_WARN__ /usr/include/stat.h >/dev/null 2>&1 &&
+ grep '<name.h>' /usr/include/sys/stat.h >/dev/null 2>&1 &&
+ grep __name_h /usr/include/name.h >/dev/null 2>&1 &&
+ cat <<!
+ /* disable ${HOSTTYPE} <sys/foo.h> vs. <foo.h> clash warnings */
+ #ifndef __NO_INCLUDE_WARN__
+ #define __NO_INCLUDE_WARN__ 1
+ #endif
+ /* disable ${HOSTTYPE} <sys/stat.h> <name.h> hijack */
+ #ifndef __name_h
+ #define __name_h 1
+ #endif
+ !
+}end
diff --git a/usr/src/lib/libast/common/features/dirent b/usr/src/lib/libast/common/features/dirent
new file mode 100644
index 0000000000..3e7d8d3900
--- /dev/null
+++ b/usr/src/lib/libast/common/features/dirent
@@ -0,0 +1,275 @@
+set prototyped
+
+set nodefine
+lib stat64 -D_LARGEFILE64_SOURCE
+typ off64_t -D_LARGEFILE64_SOURCE
+set define
+
+lib opendir
+hdr dirent,ndir
+sys dir
+nxt dirent
+
+tst botch_d_ino_dirent64 -D_LARGEFILE64_SOURCE note{ dirent64.d_ino vs. readdir64 mismatch }end compile{
+ #if !__arm__
+ )
+ #endif
+ #include <dirent.h>
+ int
+ main()
+ {
+ struct dirent64 ent;
+ char aha[5-((int)sizeof(ent.d_ino))];
+ return sizeof(aha);
+ }
+}end
+
+if ( ! _lib_opendir ) {
+ /*
+ * <dirent.h> for systems with no opendir()
+ */
+
+ #ifndef _DIRENT_H
+ #define _DIRENT_H
+
+ typedef struct
+ {
+ int dd_fd; /* file descriptor */
+ #ifdef _DIR_PRIVATE_
+ _DIR_PRIVATE_
+ #endif
+ } DIR;
+
+ struct dirent
+ {
+ long d_fileno; /* entry serial number */
+ int d_reclen; /* entry length */
+ int d_namlen; /* entry name length */
+ char d_name[1]; /* entry name */
+ };
+
+ #ifndef _DIR_PRIVATE_
+
+ #ifdef rewinddir
+ #undef rewinddir
+ #define rewinddir(p) seekdir(p,0L)
+ #endif
+
+ extern DIR* opendir(const char*);
+ extern void closedir(DIR*);
+ extern struct dirent* readdir(DIR*);
+ extern void seekdir(DIR*, long);
+ extern long telldir(DIR*);
+
+ #endif
+
+ #endif
+}
+elif ( _nxt_dirent && _lib_stat64 && _typ_off64_t && _botch_d_ino_dirent64 ) pass{
+cat <<!
+ /*
+ * <dirent.h> for [fl]stat64 and off64_t with sizeof(ino64_t)==4
+ */
+
+ #ifndef _AST_STD_H
+
+ #include $_nxt_dirent /* the native <dirent.h> */
+
+ #else
+
+ #ifndef _DIR64_H
+ #define _DIR64_H
+
+ #include <ast_std.h>
+
+ #if _typ_off64_t
+ #undef off_t
+ #endif
+
+ #undef __ino64_t
+ #define __ino64_t int64_t
+
+ #include $_nxt_dirent /* the native <dirent.h> */
+
+ #undef __ino64_t
+ #define __ino64_t __ino64_t
+
+ #if _typ_off64_t
+ #define off_t off64_t
+ #endif
+
+ #if _lib_readdir64 && _typ_struct_dirent64
+ #ifndef dirent
+ #define dirent dirent64
+ #endif
+ #ifndef readdir
+ #define readdir readdir64
+ #endif
+ #endif
+
+ #endif
+
+ #endif
+!
+}end
+elif ( _nxt_dirent && _lib_stat64 && _typ_off64_t ) pass{
+cat <<!
+ /*
+ * <dirent.h> for [fl]stat64 and off64_t
+ */
+
+ #ifndef _AST_STD_H
+
+ #include $_nxt_dirent /* the native <dirent.h> */
+
+ #else
+
+ #ifndef _DIR64_H
+ #define _DIR64_H
+
+ #include <ast_std.h>
+
+ #if _typ_off64_t
+ #undef off_t
+ #endif
+
+ #include $_nxt_dirent /* the native <dirent.h> */
+
+ #if _typ_off64_t
+ #define off_t off64_t
+ #endif
+
+ #if _lib_readdir64 && _typ_struct_dirent64
+ #ifndef dirent
+ #define dirent dirent64
+ #endif
+ #ifndef readdir
+ #define readdir readdir64
+ #endif
+ #endif
+
+ #endif
+
+ #endif
+!
+}end
+elif ( _nxt_dirent && _hdr_dirent ) pass{
+cat <<!
+ /*
+ * <dirent.h> for systems with ok <dirent.h>
+ */
+
+ #ifndef _DIRENT_H
+
+ #include $_nxt_dirent /* the native <dirent.h> */
+
+ #ifndef _DIRENT_H
+ #define _DIRENT_H
+ #endif
+
+ #endif
+!
+}end
+elif ( _hdr_ndir ) {
+ /*
+ * <dirent.h> for systems with opendir() and <ndir.h>
+ */
+
+ #ifndef _DIRENT_H
+ #define _DIRENT_H
+
+ #if defined(__STDPP__directive) && defined(__STDPP__hide)
+ __STDPP__directive pragma pp:hide closedir opendir readdir seekdir telldir
+ #else
+ #define closedir ______closedir
+ #define opendir ______opendir
+ #define readdir ______readdir
+ #define seekdir ______seekdir
+ #define telldir ______telldir
+ #endif
+
+ #include <ndir.h>
+
+ #if defined(__STDPP__directive) && defined(__STDPP__hide)
+ __STDPP__directive pragma pp:nohide closedir opendir readdir seekdir telldir
+ #else
+ #undef closedir
+ #undef opendir
+ #undef readdir
+ #undef seekdir
+ #undef telldir
+ #endif
+
+ #ifndef dirent
+ #define dirent direct
+ #endif
+
+ #if !defined(d_fileno) && !defined(d_ino)
+ #define d_fileno d_ino
+ #endif
+
+ #ifdef rewinddir
+ #undef rewinddir
+ #define rewinddir(p) seekdir(p,0L)
+ #endif
+
+ extern DIR* opendir(const char*);
+ extern void closedir(DIR*);
+ extern struct dirent* readdir(DIR*);
+ extern void seekdir(DIR*, long);
+ extern long telldir(DIR*);
+
+ #endif
+}
+elif ( _sys_dir ) {
+ /*
+ * <dirent.h> for systems with opendir() and no <ndir.h>
+ */
+
+ #ifndef _DIRENT_H
+ #define _DIRENT_H
+
+ #if defined(__STDPP__directive) && defined(__STDPP__hide)
+ __STDPP__directive pragma pp:hide closedir opendir readdir seekdir telldir
+ #else
+ #define closedir ______closedir
+ #define opendir ______opendir
+ #define readdir ______readdir
+ #define seekdir ______seekdir
+ #define telldir ______telldir
+ #endif
+
+ #include <sys/dir.h>
+
+ #if defined(__STDPP__directive) && defined(__STDPP__hide)
+ __STDPP__directive pragma pp:nohide closedir opendir readdir seekdir telldir
+ #else
+ #undef closedir
+ #undef opendir
+ #undef readdir
+ #undef seekdir
+ #undef telldir
+ #endif
+
+ #ifndef dirent
+ #define dirent direct
+ #endif
+
+ #if !defined(d_fileno) && !defined(d_ino)
+ #define d_fileno d_ino
+ #endif
+
+ #ifdef rewinddir
+ #undef rewinddir
+ #define rewinddir(p) seekdir(p,0L)
+ #endif
+
+ extern DIR* opendir(const char*);
+ extern void closedir(DIR*);
+ extern struct dirent* readdir(DIR*);
+ extern void seekdir(DIR*, long);
+ extern long telldir(DIR*);
+
+ #endif
+}
+endif
diff --git a/usr/src/lib/libast/common/features/eaccess b/usr/src/lib/libast/common/features/eaccess
new file mode 100644
index 0000000000..bf9710a2e6
--- /dev/null
+++ b/usr/src/lib/libast/common/features/eaccess
@@ -0,0 +1,11 @@
+lib eaccess,euidaccess
+macro{
+ #include <sys/types.h>
+ #include <unistd.h>
+ #ifdef EFF_ONLY_OK
+ <<"#define EFF_ONLY_OK">> EFF_ONLY_OK
+ #endif
+ #ifdef EX_OK
+ <<"#define EX_OK">> EX_OK
+ #endif
+}end
diff --git a/usr/src/lib/libast/common/features/errno b/usr/src/lib/libast/common/features/errno
new file mode 100644
index 0000000000..271fe6d174
--- /dev/null
+++ b/usr/src/lib/libast/common/features/errno
@@ -0,0 +1,31 @@
+tst dat_sys_nerr note{ sys_nerr in default libs }end compile{
+ extern int sys_nerr;
+ int f()
+ {
+ return sys_nerr > 0;
+ }
+}end
+
+tst def_errno_sys_nerr note{ sys_nerr declared in errno.h }end compile{
+ #include <errno.h>
+ int f()
+ {
+ return sys_nerr > 0;
+ }
+}end
+
+tst dat_sys_errlist note{ sys_errlist in default libs }end compile{
+ extern char* sys_errlist[];
+ int f()
+ {
+ return *sys_errlist[1] != 0;
+ }
+}end
+
+tst def_errno_sys_errlist note{ sys_errlist declared in errno.h }end compile{
+ #include <errno.h>
+ int f()
+ {
+ return *sys_errlist[1] != 0;
+ }
+}end
diff --git a/usr/src/lib/libast/common/features/fcntl.c b/usr/src/lib/libast/common/features/fcntl.c
new file mode 100644
index 0000000000..a022e5c451
--- /dev/null
+++ b/usr/src/lib/libast/common/features/fcntl.c
@@ -0,0 +1,360 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * generate POSIX fcntl.h
+ */
+
+#include <sys/types.h>
+
+#include "FEATURE/lib"
+
+#define getdtablesize ______getdtablesize
+#define getpagesize ______getpagesize
+#define ioctl ______ioctl
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#if _hdr_fcntl
+#include <fcntl.h>
+#endif
+#if _hdr_unistd
+#include <unistd.h>
+#endif
+
+#include <sys/stat.h>
+
+#include "FEATURE/fs"
+
+#undef getdtablesize
+#undef getpagesize
+#undef ioctl
+
+#include "FEATURE/tty"
+
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+
+int
+main()
+{
+ int f_local = 0;
+ int f_lck = 0;
+ int o_local = 2;
+
+ printf("#pragma prototyped\n");
+ printf("\n");
+ printf("#if _typ_off64_t\n");
+ printf("#undef off_t\n");
+ printf("#ifdef __STDC__\n");
+ printf("#define off_t off_t\n");
+ printf("#endif\n");
+ printf("#endif\n");
+ printf("\n");
+ printf("#include <ast_fs.h>\n");
+ printf("\n");
+ printf("#if _typ_off64_t\n");
+ printf("#undef off_t\n");
+ printf("#ifdef __STDC__\n");
+ printf("#define off_t off_t\n");
+ printf("#endif\n");
+ printf("#endif\n");
+ printf("\n");
+ printf("#include <fcntl.h>\n");
+#if _hdr_mman
+ printf("#include <mman.h>\n");
+#else
+#if _sys_mman
+ printf("#include <sys/mman.h>\n");
+#endif
+#endif
+ printf("\n");
+#ifndef FD_CLOEXEC
+ printf("#define FD_CLOEXEC 1\n");
+ printf("\n");
+#endif
+
+#ifndef F_DUPFD
+#define NEED_F 1
+#else
+ if (F_DUPFD > f_local) f_local = F_DUPFD;
+#endif
+#ifndef F_GETFD
+#define NEED_F 1
+#else
+ if (F_GETFD > f_local) f_local = F_GETFD;
+#endif
+#ifndef F_GETFL
+#define NEED_F 1
+#else
+ if (F_GETFL > f_local) f_local = F_GETFL;
+#endif
+#ifndef F_GETLK
+#define NEED_F 1
+#else
+ if (F_GETLK > f_local) f_local = F_GETLK;
+#endif
+#ifndef F_RDLCK
+#define NEED_F 1
+#define NEED_LCK 1
+#else
+ if (F_RDLCK > f_lck) f_lck = F_RDLCK;
+#endif
+#ifndef F_SETFD
+#define NEED_F 1
+#else
+ if (F_SETFD > f_local) f_local = F_SETFD;
+#endif
+#ifndef F_SETFL
+#define NEED_F 1
+#else
+ if (F_SETFL > f_local) f_local = F_SETFL;
+#endif
+#ifndef F_SETLK
+#define NEED_F 1
+#else
+ if (F_SETLK > f_local) f_local = F_SETLK;
+#endif
+#ifndef F_SETLKW
+#define NEED_F 1
+#else
+ if (F_SETLKW > f_local) f_local = F_SETLKW;
+#endif
+#ifndef F_UNLCK
+#define NEED_F 1
+#define NEED_LCK 1
+#else
+ if (F_UNLCK > f_lck) f_lck = F_UNLCK;
+#endif
+#ifndef F_WRLCK
+#define NEED_F 1
+#define NEED_LCK 1
+#else
+ if (F_WRLCK > f_lck) f_lck = F_WRLCK;
+#endif
+
+#if NEED_F
+ printf("#define fcntl _ast_fcntl\n");
+#if _lib_fcntl
+ printf("#define _lib_fcntl 1\n");
+#endif
+ printf("#define _ast_F_LOCAL %d\n", f_local + 1);
+#ifndef F_DUPFD
+ printf("#define F_DUPFD %d\n", ++f_local);
+#endif
+#ifndef F_GETFD
+ printf("#define F_GETFD %d\n", ++f_local);
+#endif
+#ifndef F_GETFL
+ printf("#define F_GETFL %d\n", ++f_local);
+#endif
+#ifndef F_GETLK
+ printf("#define F_GETLK %d\n", ++f_local);
+#endif
+#ifndef F_SETFD
+ printf("#define F_SETFD %d\n", ++f_local);
+#endif
+#ifndef F_SETFL
+ printf("#define F_SETFL %d\n", ++f_local);
+#endif
+#ifndef F_SETLK
+ printf("#define F_SETLK %d\n", ++f_local);
+#endif
+#ifndef F_SETLKW
+ printf("#define F_SETLKW %d\n", ++f_local);
+#endif
+#if NEED_LCK
+ printf("\n");
+#ifndef F_RDLCK
+ printf("#define F_RDLCK %d\n", f_lck++);
+#endif
+#ifndef F_WRLCK
+ printf("#define F_WRLCK %d\n", f_lck++);
+#endif
+#ifndef F_UNLCK
+ printf("#define F_UNLCK %d\n", f_lck++);
+#endif
+#endif
+ printf("\n");
+ if (f_lck == 3)
+ {
+ printf("struct flock\n");
+ printf("{\n");
+ printf(" short l_type;\n");
+ printf(" short l_whence;\n");
+ printf(" off_t l_start;\n");
+ printf(" off_t l_len;\n");
+ printf(" short l_pid;\n");
+ printf("};\n");
+ printf("\n");
+ }
+ printf("\n");
+#endif
+
+#ifndef O_APPEND
+#define NEED_O 1
+#else
+ if (O_APPEND > o_local) o_local = O_APPEND;
+#endif
+#ifndef O_CREAT
+#define NEED_O 1
+#else
+ if (O_CREAT > o_local) o_local = O_CREAT;
+#endif
+#ifndef O_EXCL
+#define NEED_O 1
+#else
+ if (O_EXCL > o_local) o_local = O_EXCL;
+#endif
+#ifndef O_NOCTTY
+#ifdef TIOCNOTTY
+#define NEED_O 1
+#endif
+#else
+ if (O_NOCTTY > o_local) o_local = O_NOCTTY;
+#endif
+#ifndef O_NONBLOCK
+#ifndef O_NDELAY
+#define NEED_O 1
+#endif
+#else
+ if (O_NONBLOCK > o_local) o_local = O_NONBLOCK;
+#endif
+#ifndef O_RDONLY
+#define NEED_O 1
+#endif
+#ifndef O_RDWR
+#define NEED_O 1
+#endif
+#ifndef O_TRUNC
+#define NEED_O 1
+#else
+ if (O_TRUNC > o_local) o_local = O_TRUNC;
+#endif
+#ifndef O_WRONLY
+#define NEED_O 1
+#endif
+
+#if NEED_O
+ printf("#define open _ast_open\n");
+ printf("#define _ast_O_LOCAL 0%o\n", o_local<<1);
+#ifndef O_RDONLY
+ printf("#define O_RDONLY 0\n");
+#endif
+#ifndef O_WRONLY
+ printf("#define O_WRONLY 1\n");
+#endif
+#ifndef O_RDWR
+ printf("#define O_RDWR 2\n");
+#endif
+#ifndef O_APPEND
+ printf("#define O_APPEND 0%o\n", o_local <<= 1);
+#endif
+#ifndef O_CREAT
+ printf("#define O_CREAT 0%o\n", o_local <<= 1);
+#endif
+#ifndef O_EXCL
+ printf("#define O_EXCL 0%o\n", o_local <<= 1);
+#endif
+#ifndef O_NOCTTY
+#ifdef TIOCNOTTY
+ printf("#define O_NOCTTY 0%o\n", o_local <<= 1);
+#endif
+#endif
+#ifndef O_NONBLOCK
+#ifndef O_NDELAY
+ printf("#define O_NONBLOCK 0%o\n", o_local <<= 1);
+#endif
+#endif
+#ifndef O_TRUNC
+ printf("#define O_TRUNC 0%o\n", o_local <<= 1);
+#endif
+#endif
+#ifndef O_ACCMODE
+ printf("#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)\n");
+#endif
+#ifndef O_NOCTTY
+#ifndef TIOCNOTTY
+ printf("#define O_NOCTTY 0\n");
+#endif
+#endif
+#ifndef O_NONBLOCK
+#ifdef O_NDELAY
+ printf("#define O_NONBLOCK O_NDELAY\n");
+#endif
+#endif
+#ifndef O_BINARY
+ printf("#define O_BINARY 0\n");
+#endif
+#ifndef O_TEMPORARY
+ printf("#define O_TEMPORARY 0\n");
+#endif
+#ifndef O_TEXT
+ printf("#define O_TEXT 0\n");
+#endif
+#if NEED_F || NEED_O
+ printf("\n");
+#if NEED_F
+ printf("extern int fcntl(int, int, ...);\n");
+#endif
+#if NEED_O
+ printf("extern int open(const char*, int, ...);\n");
+#endif
+#endif
+ printf("\n");
+ printf("#include <ast_fs.h>\n");
+ printf("#if _typ_off64_t\n");
+ printf("#undef off_t\n");
+ printf("#define off_t off64_t\n");
+ printf("#endif\n");
+ printf("#if _lib_fstat64\n");
+ printf("#define fstat fstat64\n");
+ printf("#endif\n");
+ printf("#if _lib_lstat64\n");
+ printf("#define lstat lstat64\n");
+ printf("#endif\n");
+ printf("#if _lib_stat64\n");
+ printf("#define stat stat64\n");
+ printf("#endif\n");
+ printf("#if _lib_creat64\n");
+ printf("#define creat creat64\n");
+ printf("#endif\n");
+ printf("#if _lib_mmap64\n");
+ printf("#define mmap mmap64\n");
+ printf("#endif\n");
+ printf("#if _lib_open64\n");
+ printf("#undef open\n");
+ printf("#define open open64\n");
+ printf("#endif\n");
+
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/features/float b/usr/src/lib/libast/common/features/float
new file mode 100644
index 0000000000..3897d49e11
--- /dev/null
+++ b/usr/src/lib/libast/common/features/float
@@ -0,0 +1,1162 @@
+set prototyped
+hdr float,limits,math,values
+lib fpclassify,frexp,frexpl,ldexp,ldexpl,finite,finitel,isinf,isinfl,isnan,isnanl,signbit,copysign,copysignl <math.h> -lm
+
+tst ast_no_um2fm note{ no unsigned intmax => floatmax cast }end nolink{
+ #include "FEATURE/common"
+ int
+ main()
+ {
+ _ast_fltmax_t f = 0;
+ unsigned _ast_intmax_t i = 0;
+ f = i;
+ i = f;
+ return f == i;
+ }
+}end
+
+tst ast_mpy_overflow_fpe note{ fpe on mpy overflow }end noexecute{
+ int
+ main()
+ {
+ float f;
+ float p;
+ int i;
+
+ i = 0;
+ p = f = 1.0;
+ do
+ {
+ p = f;
+ f *= 2.0;
+ } while (f != p && ++i < 1024);
+ return 0;
+ }
+}end
+
+tst ast_div_underflow_fpe note{ fpe on div underflow }end noexecute{
+ int
+ main()
+ {
+ float f;
+ float p;
+ int i;
+
+ i = 0;
+ p = f = 1.0;
+ do
+ {
+ p = f;
+ f /= 2.0;
+ } while (f != p && ++i < 1024);
+ return 0;
+ }
+}end
+
+macro{
+ #if _hdr_float
+ #include <float.h>
+ #endif
+ #if _hdr_limits
+ #include <limits.h>
+ #endif
+ #if _hdr_math
+ #include <math.h>
+ #endif
+ #if _hdr_values
+ #include <values.h>
+ #endif
+
+ #if !defined(FLT_MIN_EXP) && defined(FMINEXP)
+ #define FLT_MIN_EXP FMINEXP
+ #endif
+ #if !defined(FLT_MIN) && defined(MINFLOAT)
+ #define FLT_MIN MINFLOAT
+ #endif
+ #if !defined(FLT_MAX_EXP) && defined(FMAXEXP)
+ #define FLT_MAX_EXP FMAXEXP
+ #endif
+ #if !defined(FLT_MAX) && defined(MAXFLOAT)
+ #define FLT_MAX MAXFLOAT
+ #endif
+
+ #if !defined(DBL_MIN_EXP) && defined(DMINEXP)
+ #define DBL_MIN_EXP DMINEXP
+ #endif
+ #if !defined(DBL_MIN) && defined(MINDOUBLE)
+ #define DBL_MIN MINDOUBLE
+ #endif
+ #if !defined(DBL_MAX_EXP) && defined(DMAXEXP)
+ #define DBL_MAX_EXP DMAXEXP
+ #endif
+ #if !defined(DBL_MAX) && defined(MAXDOUBLE)
+ #define DBL_MAX MAXDOUBLE
+ #endif
+
+ <<"#include <ast_common.h>">>
+ #if _hdr_float
+ <<"#include <float.h>">>
+ #endif
+ #if _hdr_math
+ <<"#include <math.h>">>
+ #endif
+ #ifdef FLT_DIG
+ <<"#ifndef FLT_DIG">>
+ <<"#define FLT_DIG">> FLT_DIG
+ <<"#endif">>
+ #endif
+ #ifdef FLT_MAX
+ <<"#ifndef FLT_MAX">>
+ <<"#define FLT_MAX">> FLT_MAX
+ <<"#endif">>
+ #endif
+ #ifdef FLT_MAX_10_EXP
+ <<"#ifndef FLT_MAX_10_EXP">>
+ <<"#define FLT_MAX_10_EXP">> FLT_MAX_10_EXP
+ <<"#endif">>
+ #endif
+ #ifdef FLT_MAX_EXP
+ <<"#ifndef FLT_MAX_EXP">>
+ <<"#define FLT_MAX_EXP">> FLT_MAX_EXP
+ <<"#endif">>
+ #endif
+ #ifdef FLT_MIN
+ <<"#ifndef FLT_MIN">>
+ <<"#define FLT_MIN">> FLT_MIN
+ <<"#endif">>
+ #endif
+ #ifdef FLT_MIN_10_EXP
+ <<"#ifndef FLT_MIN_10_EXP">>
+ <<"#define FLT_MIN_10_EXP">> FLT_MIN_10_EXP
+ <<"#endif">>
+ #endif
+ #ifdef FLT_MIN_EXP
+ <<"#ifndef FLT_MIN_EXP">>
+ <<"#define FLT_MIN_EXP">> FLT_MIN_EXP
+ <<"#endif">>
+ #endif
+
+ #ifdef DBL_DIG
+ <<"#ifndef DBL_DIG">>
+ <<"#define DBL_DIG">> DBL_DIG
+ <<"#endif">>
+ #endif
+ #ifdef DBL_MAX
+ <<"#ifndef DBL_MAX">>
+ <<"#define DBL_MAX">> DBL_MAX
+ <<"#endif">>
+ #endif
+ #ifdef DBL_MAX_10_EXP
+ <<"#ifndef DBL_MAX_10_EXP">>
+ <<"#define DBL_MAX_10_EXP">> DBL_MAX_10_EXP
+ <<"#endif">>
+ #endif
+ #ifdef DBL_MAX_EXP
+ <<"#ifndef DBL_MAX_EXP">>
+ <<"#define DBL_MAX_EXP">> DBL_MAX_EXP
+ <<"#endif">>
+ #endif
+ #ifdef DBL_MIN
+ <<"#ifndef DBL_MIN">>
+ <<"#define DBL_MIN">> DBL_MIN
+ <<"#endif">>
+ #endif
+ #ifdef DBL_MIN_10_EXP
+ <<"#ifndef DBL_MIN_10_EXP">>
+ <<"#define DBL_MIN_10_EXP">> DBL_MIN_10_EXP
+ <<"#endif">>
+ #endif
+ #ifdef DBL_MIN_EXP
+ <<"#ifndef DBL_MIN_EXP">>
+ <<"#define DBL_MIN_EXP">> DBL_MIN_EXP
+ <<"#endif">>
+ #endif
+
+ #ifdef LDBL_DIG
+ <<"#ifndef LDBL_DIG">>
+ <<"#define LDBL_DIG">> LDBL_DIG
+ <<"#endif">>
+ #endif
+ #ifdef LDBL_MAX
+ <<"#ifndef LDBL_MAX">>
+ <<"#define LDBL_MAX">> LDBL_MAX
+ <<"#endif">>
+ #endif
+ #ifdef LDBL_MAX_10_EXP
+ <<"#ifndef LDBL_MAX_10_EXP">>
+ <<"#define LDBL_MAX_10_EXP">> LDBL_MAX_10_EXP
+ <<"#endif">>
+ #endif
+ #ifdef LDBL_MAX_EXP
+ <<"#ifndef LDBL_MAX_EXP">>
+ <<"#define LDBL_MAX_EXP">> LDBL_MAX_EXP
+ <<"#endif">>
+ #endif
+ #ifdef LDBL_MIN
+ <<"#ifndef LDBL_MIN">>
+ <<"#define LDBL_MIN">> LDBL_MIN
+ <<"#endif">>
+ #endif
+ #ifdef LDBL_MIN_10_EXP
+ <<"#ifndef LDBL_MIN_10_EXP">>
+ <<"#define LDBL_MIN_10_EXP">> LDBL_MIN_10_EXP
+ <<"#endif">>
+ #endif
+ #ifdef LDBL_MIN_EXP
+ <<"#ifndef LDBL_MIN_EXP">>
+ <<"#define LDBL_MIN_EXP">> LDBL_MIN_EXP
+ <<"#endif">>
+ #endif
+}end
+
+tst - note{ missing floating point limits }end output{
+ #include "FEATURE/common"
+ #if _hdr_float
+ #include <float.h>
+ #endif
+ #if _hdr_limits
+ #include <limits.h>
+ #endif
+ #if _hdr_math
+ #include <math.h>
+ #endif
+ #if _hdr_values
+ #include <values.h>
+ #endif
+ #include <signal.h>
+ #ifdef SIGFPE
+ static int caught = 0;
+ #if _STD_
+ static void catch(int sig)
+ #else
+ static void catch(sig) int sig;
+ #endif
+ {
+ signal(sig, SIG_IGN);
+ caught++;
+ }
+ #endif
+ int
+ main()
+ {
+ register int i;
+ register int s;
+ float f;
+ float pf;
+ float mf;
+ float xf;
+ double d;
+ double pd;
+ double md;
+ char* fp;
+ #if _ast_fltmax_double
+ char* fs = "";
+ char* ds = "";
+ #else
+ _ast_fltmax_t l;
+ _ast_fltmax_t pl;
+ _ast_fltmax_t ml;
+ char* fs = "F";
+ char* ds = "";
+ char* ls = "L";
+ #endif
+ unsigned long u;
+ unsigned _ast_intmax_t w;
+ unsigned _ast_intmax_t pw;
+ unsigned _ast_intmax_t x;
+ unsigned short us;
+ unsigned int ui;
+ unsigned long ul;
+ unsigned _ast_intmax_t uq;
+
+ #ifdef SIGFPE
+ signal(SIGFPE, catch);
+ #endif
+ printf("\n");
+ printf("\n");
+ us = 0;
+ us = ~us;
+ i = 0;
+ while (us /= 10)
+ i++;
+ printf("#define USHRT_DIG %d\n", i);
+ ui = 0;
+ ui = ~ui;
+ i = 0;
+ while (ui /= 10)
+ i++;
+ printf("#define UINT_DIG %d\n", i);
+ ul = 0;
+ ul = ~ul;
+ i = 0;
+ while (ul /= 10)
+ i++;
+ printf("#define ULONG_DIG %d\n", i);
+ if (sizeof(uq) > sizeof(ul))
+ {
+ uq = 0;
+ uq = ~uq;
+ i = 0;
+ while (uq /= 10)
+ i++;
+ printf("#define ULLONG_DIG %d\n", i);
+ printf("#define UINTMAX_DIG ULLONG_DIG\n");
+ }
+ else
+ printf("#define UINTMAX_DIG ULONG_DIG\n");
+ printf("\n");
+ w = 1;
+ do
+ {
+ pw = w;
+ w *= 2;
+ f = (_ast_intmax_t)w;
+ x = (_ast_intmax_t)f;
+ } while (w > pw && w == x);
+ w = (pw - 1) + pw;
+ u = ~0;
+ if (u > w)
+ u = w;
+ printf("#define FLT_ULONG_MAX %lu.0F\n", u);
+ if (sizeof(w) > sizeof(u))
+ {
+ printf("#define FLT_ULLONG_MAX %llu.0F\n", w);
+ printf("#define FLT_UINTMAX_MAX FLT_ULLONG_MAX\n");
+ }
+ else
+ {
+ printf("#define FLT_ULLONG_MAX FLT_ULONG_MAX\n");
+ printf("#define FLT_UINTMAX_MAX FLT_ULONG_MAX\n");
+ }
+ u /= 2;
+ w /= 2;
+ printf("#define FLT_LONG_MAX %lu.0F\n", u);
+ if (sizeof(w) > sizeof(u))
+ {
+ printf("#define FLT_LLONG_MAX %llu.0F\n", w);
+ printf("#define FLT_INTMAX_MAX FLT_LLONG_MAX\n");
+ }
+ else
+ {
+ printf("#define FLT_LLONG_MAX FLT_LONG_MAX\n");
+ printf("#define FLT_INTMAX_MAX FLT_LONG_MAX\n");
+ }
+ u++;
+ w++;
+ printf("#define FLT_LONG_MIN (-%lu.0F)\n", u);
+ if (sizeof(w) > sizeof(u))
+ {
+ printf("#define FLT_LLONG_MIN (-%llu.0F)\n", w);
+ printf("#define FLT_INTMAX_MIN FLT_LLONG_MIN\n");
+ }
+ else
+ {
+ printf("#define FLT_LLONG_MIN FLT_LONG_MIN\n");
+ printf("#define FLT_INTMAX_MIN FLT_LONG_MIN\n");
+ }
+ #ifdef FLT_DIG
+ s = FLT_DIG;
+ #else
+ f = pf = 1.0;
+ s = -1;
+ do
+ {
+ s++;
+ f *= 10.0;
+ } while (f != (f + pf));
+ #endif
+ #if defined(FLT_MIN) && defined(FLT_MIN_EXP)
+ i = FLT_MIN_EXP;
+ mf = FLT_MIN;
+ #else
+ i = 3;
+ f = pf = 1.0;
+ do
+ {
+ i--;
+ mf = pf;
+ pf = f;
+ f /= 2.0;
+ } while (f < pf);
+ #ifdef FLT_MIN_EXP
+ i = FLT_MIN_EXP;
+ #endif
+ #ifdef FLT_MIN
+ mf = FLT_MIN;
+ #endif
+ #endif
+ #ifndef FLT_DIG
+ printf("#ifndef FLT_DIG\n");
+ printf("#define FLT_DIG %d\n", s);
+ printf("#endif\n");
+ #endif
+ #ifndef FLT_MIN
+ printf("#ifndef FLT_MIN\n");
+ printf("#define FLT_MIN %.*E%s\n", s + 1, mf, fs);
+ printf("#endif\n");
+ #endif
+ #ifndef FLT_MIN_EXP
+ printf("#ifndef FLT_MIN_EXP\n");
+ printf("#define FLT_MIN_EXP (%d)\n", i);
+ printf("#endif\n");
+ #endif
+
+ #if defined(FLT_MAX) && defined(FLT_MAX_EXP)
+ i = FLT_MAX_EXP;
+ f = FLT_MAX;
+ #else
+ i = -1;
+ f = pf = 1.0;
+ do
+ {
+ i++;
+ mf = pf;
+ pf = f;
+ f *= 2.0;
+ } while (f > pf);
+ #ifdef FLT_MAX_EXP
+ i = FLT_MAX_EXP;
+ #endif
+ #ifdef FLT_MAX
+ f = FLT_MAX;
+ #endif
+ #endif
+ #ifdef FLT_MAX_EXP
+ i = FLT_MAX_EXP;
+ #else
+ f = 1;
+ do
+ {
+ f *= 2.0;
+ } while (mf == (mf + f));
+ f = (mf - f) * 2.0 + f;
+ #endif
+ xf = f;
+ #ifndef FLT_MAX
+ printf("#ifndef FLT_MAX\n");
+ printf("#define FLT_MAX %.*E%s\n", s + 1, f, fs);
+ printf("#endif\n");
+ #endif
+ #ifndef FLT_MAX_EXP
+ printf("#ifndef FLT_MAX_EXP\n");
+ printf("#define FLT_MAX_EXP %d\n", i);
+ printf("#endif\n");
+ #endif
+
+ #ifdef FLT_MIN_10_EXP
+ i = FLT_MIN_10_EXP;
+ #else
+ i = 2;
+ f = 1.0;
+ do
+ {
+ i--;
+ pf = f;
+ f /= 10.0;
+ } while (f < pf);
+ #endif
+ #ifndef FLT_MIN_10_EXP
+ printf("#ifndef FLT_MIN_10_EXP\n");
+ printf("#define FLT_MIN_10_EXP (%d)\n", i);
+ printf("#endif\n");
+ #endif
+
+ #ifdef FLT_MAX_10_EXP
+ i = FLT_MAX_10_EXP;
+ #else
+ i = -2;
+ f = 1.0;
+ do
+ {
+ i++;
+ pf = f;
+ f *= 10.0;
+ } while (f > pf);
+ #endif
+ #ifndef FLT_MAX_10_EXP
+ printf("#ifndef FLT_MAX_10_EXP\n");
+ printf("#define FLT_MAX_10_EXP %d\n", i);
+ printf("#endif\n");
+ #endif
+
+ printf("\n");
+ w = 1;
+ do
+ {
+ pw = w;
+ w *= 2;
+ d = (_ast_intmax_t)w;
+ x = (_ast_intmax_t)d;
+ } while (w > pw && w == x);
+ w = (pw - 1) + pw;
+ u = ~0;
+ if (u > w)
+ u = w;
+ printf("#define DBL_ULONG_MAX %lu.0\n", u);
+ if (sizeof(w) > sizeof(u))
+ {
+ printf("#define DBL_ULLONG_MAX %llu.0\n", w);
+ printf("#define DBL_UINTMAX_MAX DBL_ULLONG_MAX\n");
+ }
+ else
+ {
+ printf("#define DBL_ULLONG_MAX DBL_ULONG_MAX\n");
+ printf("#define DBL_UINTMAX_MAX DBL_ULONG_MAX\n");
+ }
+ u /= 2;
+ w /= 2;
+ printf("#define DBL_LONG_MAX %lu.0\n", u);
+ if (sizeof(w) > sizeof(u))
+ {
+ printf("#define DBL_LLONG_MAX %llu.0\n", w);
+ printf("#define DBL_INTMAX_MAX DBL_LLONG_MAX\n");
+ }
+ else
+ {
+ printf("#define DBL_LLONG_MAX DBL_LONG_MAX\n");
+ printf("#define DBL_INTMAX_MAX DBL_LONG_MAX\n");
+ }
+ u++;
+ w++;
+ printf("#define DBL_LONG_MIN (-%lu.0)\n", u);
+ if (sizeof(w) > sizeof(u))
+ {
+ printf("#define DBL_LLONG_MIN (-%llu.0)\n", w);
+ printf("#define DBL_INTMAX_MIN DBL_LLONG_MIN\n");
+ }
+ else
+ {
+ printf("#define DBL_LLONG_MIN DBL_LONG_MIN\n");
+ printf("#define DBL_INTMAX_MIN DBL_LONG_MIN\n");
+ }
+ #ifdef DBL_DIG
+ s = DBL_DIG;
+ #else
+ d = pd = 1.0;
+ s = -1;
+ do
+ {
+ s++;
+ d *= 10.0;
+ } while (d != (d + pd));
+ #endif
+ #if defined(DBL_MIN) && defined(DBL_MIN_EXP)
+ i = DBL_MIN_EXP;
+ md = DBL_MIN;
+ #else
+ i = 3;
+ d = pd = 1.0;
+ do
+ {
+ i--;
+ md = pd;
+ pd = d;
+ d /= 2.0;
+ } while (d < pd);
+ #ifdef DBL_MIN_EXP
+ i = DBL_MIN_EXP;
+ #endif
+ #ifdef DBL_MIN
+ md = DBL_MIN;
+ #endif
+ #endif
+ #ifndef DBL_DIG
+ printf("#ifndef DBL_DIG\n");
+ printf("#define DBL_DIG %d\n", s);
+ printf("#endif\n");
+ #endif
+ #ifndef DBL_MIN
+ printf("#ifndef DBL_MIN\n");
+ printf("#define DBL_MIN %.*E%s\n", s + 1, md, ds);
+ printf("#endif\n");
+ #endif
+ #ifndef DBL_MIN_EXP
+ printf("#ifndef DBL_MIN_EXP\n");
+ printf("#define DBL_MIN_EXP (%d)\n", i);
+ printf("#endif\n");
+ #endif
+
+ #if defined(DBL_MAX) && defined(DBL_MAX_EXP)
+ i = DBL_MAX_EXP;
+ d = DBL_MAX;
+ #else
+ i = -1;
+ d = pd = 1.0;
+ do
+ {
+ i++;
+ md = pd;
+ pd = d;
+ d *= 2.0;
+ } while (d > pd);
+ d = 1.0;
+ do
+ {
+ d *= 2.0;
+ } while (md == (md + d));
+ d = (md - d) * 2.0 + d;
+ #ifdef DBL_MAX_EXP
+ i = DBL_MAX_EXP;
+ #endif
+ #ifdef DBL_MAX
+ d = DBL_MAX;
+ #endif
+ #endif
+ #ifndef DBL_MAX
+ printf("#ifndef DBL_MAX\n");
+ printf("#define DBL_MAX %.*E%s\n", s + 1, d, ds);
+ printf("#endif\n");
+ #endif
+ #ifndef DBL_MAX_EXP
+ printf("#ifndef DBL_MAX_EXP\n");
+ printf("#define DBL_MAX_EXP %d\n", i);
+ printf("#endif\n");
+ #endif
+
+ #ifdef DBL_MIN_10_EXP
+ i = DBL_MIN_10_EXP;
+ #else
+ i = 2;
+ d = 1.0;
+ do
+ {
+ i--;
+ pd = d;
+ d /= 10.0;
+ } while (d < pd);
+ #endif
+ #ifndef DBL_MIN_10_EXP
+ printf("#ifndef DBL_MIN_10_EXP\n");
+ printf("#define DBL_MIN_10_EXP (%d)\n", i);
+ printf("#endif\n");
+ #endif
+
+ #ifdef DBL_MAX_10_EXP
+ i = DBL_MAX_10_EXP;
+ #else
+ i = -2;
+ d = 1.0;
+ do
+ {
+ i++;
+ pd = d;
+ d *= 10.0;
+ } while (d > pd);
+ #endif
+ #ifndef DBL_MAX_10_EXP
+ printf("#ifndef DBL_MAX_10_EXP\n");
+ printf("#define DBL_MAX_10_EXP %d\n", i);
+ printf("#endif\n");
+ #endif
+
+ #if !_ast_fltmax_double
+ printf("\n");
+ w = 1;
+ do
+ {
+ pw = w;
+ w *= 2;
+ l = (_ast_intmax_t)w;
+ x = (_ast_intmax_t)l;
+ } while (w > pw && w == x);
+ w = (pw - 1) + pw;
+ u = ~0;
+ if (u > w)
+ u = w;
+ printf("#define LDBL_ULONG_MAX %lu.0L\n", u);
+ if (sizeof(w) > sizeof(u))
+ {
+ printf("#define LDBL_ULLONG_MAX %llu.0L\n", w);
+ printf("#define LDBL_UINTMAX_MAX LDBL_ULLONG_MAX\n");
+ }
+ else
+ {
+ printf("#define LDBL_ULLONG_MAX LDBL_ULONG_MAX\n");
+ printf("#define LDBL_UINTMAX_MAX LDBL_ULONG_MAX\n");
+ }
+ u /= 2;
+ w /= 2;
+ printf("#define LDBL_LONG_MAX %lu.0L\n", u);
+ if (sizeof(w) > sizeof(u))
+ {
+ printf("#define LDBL_LLONG_MAX %llu.0L\n", w);
+ printf("#define LDBL_INTMAX_MAX LDBL_LLONG_MAX\n");
+ }
+ else
+ {
+ printf("#define LDBL_LLONG_MAX LDBL_LONG_MAX\n");
+ printf("#define LDBL_INTMAX_MAX LDBL_LONG_MAX\n");
+ }
+ u++;
+ w++;
+ printf("#define LDBL_LONG_MIN (-%lu.0L)\n", u);
+ if (sizeof(w) > sizeof(u))
+ {
+ printf("#define LDBL_LLONG_MIN (-%llu.0L)\n", w);
+ printf("#define LDBL_INTMAX_MIN LDBL_LLONG_MIN\n");
+ }
+ else
+ {
+ printf("#define LDBL_LLONG_MIN LDBL_LONG_MIN\n");
+ printf("#define LDBL_INTMAX_MIN LDBL_LONG_MIN\n");
+ }
+ #ifdef LDBL_DIG
+ s = LDBL_DIG;
+ #else
+ l = pl = 1.0L;
+ s = -1;
+ do
+ {
+ s++;
+ l *= 10.0L;
+ } while (l != (l + pl));
+ #endif
+ #if defined(LDBL_MIN) && defined(LDBL_MIN_EXP)
+ i = LDBL_MIN_EXP;
+ ml = LDBL_MIN;
+ #else
+ i = 3;
+ l = pl = 1.0L;
+ do
+ {
+ i--;
+ ml = pl;
+ pl = l;
+ l /= 2.0L;
+ } while (l < pl);
+ #ifdef LDBL_MIN_EXP
+ i = LDBL_MIN_EXP;
+ #endif
+ #ifdef LDBL_MIN
+ ml = LDBL_MIN;
+ #endif
+ #endif
+ #ifndef LDBL_DIG
+ printf("#ifndef LDBL_DIG\n");
+ printf("#define LDBL_DIG %d\n", s);
+ printf("#endif\n");
+ #endif
+ #ifndef LDBL_MIN
+ printf("#ifndef LDBL_MIN\n");
+ printf("#define LDBL_MIN %.*LE%s\n", s + 1, ml, ls);
+ printf("#endif\n");
+ #endif
+ #ifndef LDBL_MIN_EXP
+ printf("#ifndef LDBL_MIN_EXP\n");
+ printf("#define LDBL_MIN_EXP (%d)\n", i);
+ printf("#endif\n");
+ #endif
+
+ #if defined(LDBL_MAX) && defined(LDBL_MAX_EXP)
+ i = LDBL_MAX_EXP;
+ l = LDBL_MAX;
+ #else
+ i = -1;
+ l = pl = 1.0L;
+ do
+ {
+ i++;
+ ml = pl;
+ pl = l;
+ l *= 2.0L;
+ } while (l > pl);
+ l = 1.0L;
+ do
+ {
+ l *= 2.0L;
+ } while (ml == (ml + l));
+ l = (ml - l) * 2.0L + l;
+ #ifdef LDBL_MAX_EXP
+ i = LDBL_MAX_EXP;
+ #endif
+ #ifdef LDBL_MAX
+ l = LDBL_MAX;
+ #endif
+ #endif
+ #ifndef LDBL_MAX
+ printf("#ifndef LDBL_MAX\n");
+ printf("#define LDBL_MAX %.*LE%s\n", s + 1, l, ls);
+ printf("#endif\n");
+ #endif
+ #ifndef LDBL_MAX_EXP
+ printf("#ifndef LDBL_MAX_EXP\n");
+ printf("#define LDBL_MAX_EXP %d\n", i);
+ printf("#endif\n");
+ #endif
+
+ #ifdef LDBL_MIN_10_EXP
+ i = LDBL_MIN_10_EXP;
+ #else
+ i = 2;
+ l = 1.0L;
+ do
+ {
+ i--;
+ pl = l;
+ l /= 10.0L;
+ } while (l < pl);
+ #endif
+ #ifndef LDBL_MIN_10_EXP
+ printf("#ifndef LDBL_MIN_10_EXP\n");
+ printf("#define LDBL_MIN_10_EXP (%d)\n", i);
+ printf("#endif\n");
+ #endif
+
+ #ifdef LDBL_MAX_10_EXP
+ i = LDBL_MAX_10_EXP;
+ #else
+ i = -2;
+ l = 1.0L;
+ do
+ {
+ i++;
+ pl = l;
+ l *= 10.0L;
+ } while (l > pl);
+ #endif
+ #ifndef LDBL_MAX_10_EXP
+ printf("#ifndef LDBL_MAX_10_EXP\n");
+ printf("#define LDBL_MAX_10_EXP %d\n", i);
+ printf("#endif\n");
+ #endif
+ fp = "LDBL";
+ #else
+ fp = "DBL";
+ #endif
+
+ printf("\n");
+ printf("#define FLTMAX_UINTMAX_MAX %s_UINTMAX_MAX\n", fp);
+ printf("#define FLTMAX_INTMAX_MAX %s_INTMAX_MAX\n", fp);
+ printf("#define FLTMAX_INTMAX_MIN %s_INTMAX_MIN\n", fp);
+
+ #ifdef SIGFPE
+ if (!caught)
+ {
+ #if !__MVS__
+ f = xf;
+ f *= 2;
+ if (!f)
+ #endif
+ caught = 1;
+ }
+ if (caught)
+ printf("\n#define _ast_fltsig %d\n", SIGFPE);
+ #endif
+
+ printf("\n");
+ #if !_lib_frexp
+ printf("extern double frexp(double, int*);\n");
+ #endif
+ #if !_lib_frexpl
+ printf("extern _ast_fltmax_t frexpl(_ast_fltmax_t, int*);\n");
+ #endif
+ #if !_lib_ldexp
+ printf("extern double ldexp(double, int);\n");
+ #endif
+ #if !_lib_ldexpl
+ printf("extern _ast_fltmax_t ldexpl(_ast_fltmax_t, int);\n");
+ #endif
+
+ return 0;
+ }
+}end
+
+tst - note{ double exponent bitfoolery }end output{
+ #include "FEATURE/common"
+ typedef union _dbl_exp_u
+ {
+ unsigned _ast_int4_t e[sizeof(double) / 4];
+ double f;
+ } _ast_dbl_exp_t;
+ int
+ main()
+ {
+ int i;
+ int j;
+ unsigned _ast_int4_t e;
+ _ast_dbl_exp_t a;
+ _ast_dbl_exp_t b;
+ a.f = 1;
+ b.f = 2;
+ for (i = 0; i < sizeof(a.e) / sizeof(a.e[0]); i++)
+ if (e = a.e[i] ^ b.e[i])
+ {
+ for (j = i + 1; j < sizeof(a.e) / sizeof(a.e[0]); j++)
+ if (a.e[j] ^ b.e[j])
+ return 0;
+ printf("typedef union _ast_dbl_exp_u\n{\n\tuint32_t\t\te[sizeof(double)/4];\n\tdouble\t\t\tf;\n} _ast_dbl_exp_t;\n\n");
+ printf("#define _ast_dbl_exp_index %d\n", i);
+ for (i = 0; !(e & 1); e >>= 1, i++);
+ printf("#define _ast_dbl_exp_shift %d\n\n", i);
+ return 0;
+ }
+ return 0;
+ }
+}end
+
+tst - note{ long double exponent bitfoolery }end output{
+ #include "FEATURE/common"
+ typedef union _ast_fltmax_exp_u
+ {
+ unsigned _ast_int4_t e[sizeof(_ast_fltmax_t) / 4];
+ _ast_fltmax_t f;
+ } _ast_fltmax_exp_t;
+ int
+ main()
+ {
+ int i;
+ int j;
+ unsigned _ast_int4_t e;
+ _ast_fltmax_exp_t a;
+ _ast_fltmax_exp_t b;
+ a.f = 1;
+ b.f = 2;
+ for (i = 0; i < sizeof(a.e) / sizeof(a.e[0]); i++)
+ if (e = a.e[i] ^ b.e[i])
+ {
+ for (j = i + 1; j < sizeof(a.e) / sizeof(a.e[0]); j++)
+ if (a.e[j] ^ b.e[j])
+ return 0;
+ printf("typedef union _fltmax_exp_u\n{\n\tuint32_t\t\te[sizeof(_ast_fltmax_t)/4];\n\t_ast_fltmax_t\t\tf;\n} _ast_fltmax_exp_t;\n\n");
+ printf("#define _ast_fltmax_exp_index\t%d\n", i);
+ for (i = 0; !(e & 1); e >>= 1, i++);
+ printf("#define _ast_fltmax_exp_shift\t%d\n\n", i);
+ return 0;
+ }
+ return 0;
+ }
+}end
+
+tst - -DN=1 - -DN=2 note{ _ast_fltmax_t maximum integral type }end output{
+ int
+ main()
+ {
+ #if N == 1
+ unsigned long long m;
+ long double f = 123.456;
+
+ m = f;
+ if (!m || f == m)
+ return 1;
+ printf("#define _ast_flt_unsigned_max_t unsigned long long\n");
+ #else
+ printf("#define _ast_flt_unsigned_max_t unsigned long\n");
+ #endif
+ return 0;
+ }
+}end
+
+tst - -lm -DSTRTO=1 - -DSCAN=1 - -DDIV=1 - -DEXP=1 - -DADD=1 - -DMPY=1 note{ INF and NAN memory representations }end output{
+ #include "FEATURE/common"
+ #include <sys/types.h>
+ #include <signal.h>
+ #if _hdr_float
+ #include <float.h>
+ #endif
+ #if _hdr_limits
+ #include <limits.h>
+ #endif
+ #if _hdr_math
+ #include <math.h>
+ #endif
+ #if _hdr_values
+ #include <values.h>
+ #endif
+ #if STRTO && _hdr_stdlib
+ #include <stdlib.h>
+ #endif
+ #if !defined(FLT_MAX) && defined(MAXFLOAT)
+ #define FLT_MAX MAXFLOAT
+ #endif
+ #if !defined(DBL_MAX) && defined(MAXDOUBLE)
+ #define DBL_MAX MAXDOUBLE
+ #endif
+ #if _ast_fltmax_double
+ #undef LDBL_MAX
+ #endif
+ static void
+ #if _STD_
+ list(const char* typ, const char* var, void* val, int siz)
+ #else
+ list(typ, var, val, siz)
+ char* typ;
+ char* var;
+ void* val;
+ int siz;
+ #endif
+ {
+ register unsigned char* u = (unsigned char*)val;
+ register unsigned char* e = u + siz;
+
+ printf("#define _ast_%s_%s_init\t0x%02x", typ, var, *u);
+ while (++u < e)
+ printf(",0x%02x", *u);
+ printf("\n");
+ }
+ int
+ main()
+ {
+ #if SCAN || STRTO
+ #undef NAN
+ #define NAN "NaN"
+ #undef INF
+ #define INF "INF"
+ {
+ float f;
+
+ #if SCAN
+ if (sscanf(NAN, "%g", &f) != 1)
+ return 1;
+ #else
+ f = atof(NAN);
+ #endif
+ list("flt", "nan", &f, sizeof(f));
+ #if SCAN
+ if (sscanf(INF, "%g", &f) != 1)
+ return 1;
+ #else
+ f = atof(INF);
+ #endif
+ list("flt", "inf", &f, sizeof(f));
+ }
+ {
+ double f;
+ #if STRTO
+ char* e;
+ #endif
+
+ #if SCAN
+ if (sscanf(NAN, "%lg", &f) != 1)
+ return 1;
+ #else
+ f = strtod(NAN, &e);
+ if (*e)
+ return 1;
+ #endif
+ list("dbl", "nan", &f, sizeof(f));
+ #if SCAN
+ if (sscanf(INF, "%lg", &f) != 1)
+ return 1;
+ #else
+ f = strtod(INF, &e);
+ if (*e)
+ return 1;
+ #endif
+ list("dbl", "inf", &f, sizeof(f));
+ }
+ #ifdef LDBL_MAX
+ {
+ long double f;
+ #if STRTO
+ char* e;
+ #endif
+
+ #if SCAN
+ if (sscanf(NAN, "%Lg", &f) != 1)
+ return 1;
+ #else
+ f = strtold(NAN, &e);
+ if (*e)
+ return 1;
+ #endif
+ list("ldbl", "nan", &f, sizeof(f));
+ #if SCAN
+ if (sscanf(INF, "%Lg", &f) != 1)
+ return 1;
+ #else
+ f = strtold(INF, &e);
+ if (*e)
+ return 1;
+ #endif
+ list("ldbl", "inf", &f, sizeof(f));
+ }
+ #endif
+ #else
+ #ifdef SIGFPE
+ signal(SIGFPE, SIG_IGN);
+ #endif
+ #ifdef FLT_MAX
+ {
+ float f = FLT_MAX;
+ #if DIV
+ float z = 0;
+
+ f = 0.0 / z;
+ if (!f)
+ return 1;
+ list("flt", "nan", &f, sizeof(f));
+ f = 1.0 / z;
+ list("flt", "inf", &f, sizeof(f));
+ #else
+ #if ADD
+ f += f;
+ #endif
+ #if EXP
+ f = exp(f);
+ #endif
+ #if MPY
+ f *= 2;
+ #endif
+ list("flt", "nan", &f, sizeof(f));
+ list("flt", "inf", &f, sizeof(f));
+ #endif
+ }
+ #endif
+ #ifdef DBL_MAX
+ {
+ double f = DBL_MAX;
+ #if DIV
+ double z = 0;
+
+ f = 0.0 / z;
+ if (!f)
+ return 1;
+ list("dbl", "nan", &f, sizeof(f));
+ f = 1.0 / z;
+ list("dbl", "inf", &f, sizeof(f));
+ #else
+ #if ADD
+ f += f;
+ #endif
+ #if EXP
+ f = exp(f);
+ #endif
+ #if MPY
+ f *= 2;
+ #endif
+ list("dbl", "nan", &f, sizeof(f));
+ list("dbl", "inf", &f, sizeof(f));
+ #endif
+ }
+ #endif
+ #ifdef LDBL_MAX
+ {
+ long double f = LDBL_MAX;
+ #if DIV
+ long double z = 0;
+
+ f = 0.0 / z;
+ if (!f)
+ return 1;
+ list("ldbl", "nan", &f, sizeof(f));
+ f = 1.0 / z;
+ list("ldbl", "inf", &f, sizeof(f));
+ #else
+ #if ADD
+ f += f;
+ #endif
+ #if EXP
+ f = exp(f);
+ #endif
+ #if MPY
+ f *= 2;
+ #endif
+ list("ldbl", "nan", &f, sizeof(f));
+ list("ldbl", "inf", &f, sizeof(f));
+ #endif
+ }
+ #endif
+ #endif
+ return 0;
+ }
+}end
diff --git a/usr/src/lib/libast/common/features/fs b/usr/src/lib/libast/common/features/fs
new file mode 100644
index 0000000000..470d20162e
--- /dev/null
+++ b/usr/src/lib/libast/common/features/fs
@@ -0,0 +1,234 @@
+set prototyped
+lib _fxstat,__fxstat,_lxstat,__lxstat,_xmknod,__xmknod,_xstat,__xstat,lstat,mknod,sync sys/types.h sys/stat.h
+lib _fxstat64,__fxstat64,_lxstat64,__lxstat64,_xstat64,__xstat64 -D_LARGEFILE64_SOURCE sys/types.h sys/stat.h
+mac fstat,lstat,stat,mknod sys/types.h sys/stat.h
+
+lcl xstat -D_LARGEFILE64_SOURCE link{
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ struct stat64 { int xxx; }; /* disable if stat64 available */
+ #if _STD_
+ extern int stat(const char* path, struct stat* st)
+ #else
+ int stat(path, st)
+ char* path;
+ struct stat* st;
+ #endif
+ {
+ #if _lib___xstat
+ return __xstat(_STAT_VER, path, st);
+ #else
+ return _xstat(_STAT_VER, path, st);
+ #endif
+ }
+ int
+ main()
+ {
+ struct stat st;
+ return stat(".",&st) < 0;
+ }
+}end
+
+lcl xstat64 -D_LARGEFILE64_SOURCE link{
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #if _STD_
+ extern int stat64(const char* path, struct stat64* st)
+ #else
+ int stat64(path, st)
+ char* path;
+ #endif
+ {
+ #if _lib___xstat64
+ return __xstat64(_STAT_VER, path, st);
+ #else
+ return _xstat64(_STAT_VER, path, st);
+ #endif
+ }
+ int
+ main()
+ {
+ struct stat64 st;
+ return stat64(".",&st) < 0;
+ }
+}end
+
+header sys/stat.h
+
+extern chmod int (const char*, mode_t)
+extern fstat int (int, struct stat*)
+extern lstat int (const char*, struct stat*)
+extern mkdir int (const char*, mode_t)
+extern mkfifo int (const char*, mode_t)
+extern mknod int (const char*, mode_t, dev_t)
+extern stat int (const char*, struct stat*)
+extern mkfifo mode_t (mode_t)
+
+define FS_default "ufs"
+
+macro{
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #ifndef major
+ #include <sys/param.h>
+ #ifndef major
+ #include <sys/sysmacros.h>
+ #endif
+ <<"#if defined(__STDPP__directive) && defined(__STDPP__initial)">>
+ <<"__STDPP__directive pragma pp:initial">>
+ <<"#endif">>
+ <<"#ifndef major">>
+ #ifdef major
+ <<"#define major(x)">> major((x))
+ #else
+ #ifndef L_BITSMAJOR
+ #define L_BITSMAJOR 8
+ #endif
+ #ifndef L_BITSMINOR
+ #define L_BITSMINOR 8
+ #endif
+ #ifndef L_MAXMAJ
+ #define L_MAXMAJ ((1<<L_BITSMAJOR)-1)
+ #endif
+ #ifndef L_MAXMIN
+ #define L_MAXMIN ((1<<L_BITSMINOR)-1)
+ #endif
+ <<"#define major(x)">> ((int)(((unsigned)(x)>>L_BITSMINOR)&L_MAXMAJ))
+ #endif
+ <<"#endif">>
+ <<"#ifndef minor">>
+ #ifdef minor
+ <<"#define minor(x)">> minor((x))
+ #else
+ <<"#define minor(x)">> ((int)((x)&L_MAXMIN))
+ #endif
+ <<"#endif">>
+ <<"#ifndef makedev">>
+ #ifdef makedev
+ <<"#define makedev(x,y)">> makedev((x),(y))
+ #else
+ <<"#define makedev(x,y)">> ((dev_t)((((x)&0377)<<8)|((y)&0377)))
+ #endif
+ <<"#endif">>
+ #endif
+ <<"#if defined(__STDPP__directive) && defined(__STDPP__initial)">>
+ <<"__STDPP__directive pragma pp:noinitial">>
+ <<"#endif">>
+}end fail{
+ cat <<!
+ #ifndef major
+ #define major(x) ((int)(((unsigned)(x)>>8)&0377))
+ #endif
+ #ifndef minor
+ #define minor(x) ((int)((x)&0377))
+ #endif
+ #ifndef makedev
+ #define makedev(x,y) ((dev_t)((((x)&0377)<<8)|((y)&0377)))
+ #endif
+ !
+}end
+
+mem mnttab.mt_dev,mnttab.mt_filsys,mnttab.mt_fstyp sys/types.h mnttab.h
+mem mntent.mnt_opts,w_mntent.mnt_opts,mnttab.mnt_opts sys/types.h stdio.h mntent.h sys/mntent.h
+mem mntent.mnt_opts,mnttab.mnt_opts sys/types.h mnttab.h sys/mnttab.h
+mem stat.st_blocks,stat.st_blksize,stat.st_rdev sys/types.h sys/stat.h
+mem statfs.f_files,statfs.f_bavail sys/types.h - sys/statfs.h - sys/vfs.h - sys/param.h sys/mount.h
+mem statvfs.f_basetype,statvfs.f_frsize sys/types.h sys/statvfs.h
+
+ary f_reserved7 sys/types.h sys/statvfs.h note{ statvfs.f_reserved7 can double for statvfs.f_basetype }end compile{
+ int f(vp)struct statvfs* vp;{return vp->f_reserved7[0] = 1;}
+}end
+
+hdr mntent,mnttab
+lib getmntent,getmntinfo,mntctl,mntopen,mntread,mntclose,setmntent
+lib w_getmntent
+lib statfs,statvfs
+sys fs_types,mntent,mnttab,mount,statfs,statvfs,vfs,vmount
+
+lib statfs4 sys/types.h - sys/statfs.h - sys/vfs.h - sys/mount.h compile{
+ int f()
+ {
+ struct statfs fs;
+ return statfs("/",&fs,sizeof(fs),0);
+ }
+}end
+
+lib getmntinfo_statvfs note{ getmntinfo uses statvfs -- since when? }end compile{
+ #include <sys/types.h>
+ #include <sys/mount.h>
+ int
+ gmi(struct statvfs* fs)
+ {
+ fs->f_flag = 0;
+ return getmntinfo(fs, 0);
+ }
+}end
+
+cat{
+ #if _sys_statvfs
+ #include <sys/statvfs.h>
+ #if !_mem_statvfs_f_basetype
+ #if _ary_f_reserved7
+ #define f_basetype f_reserved7
+ #endif
+ #endif
+ #else
+ #define _mem_f_basetype_statvfs 1
+ #define _mem_f_frsize_statvfs 1
+ struct statvfs
+ {
+ unsigned long f_bsize; /* fundamental file system block size */
+ unsigned long f_frsize; /* fragment size */
+ unsigned long f_blocks; /* total # of blocks of f_frsize on fs */
+ unsigned long f_bfree; /* total # of free blocks of f_frsize */
+ unsigned long f_bavail; /* # of free blocks avail to non-superuser */
+ unsigned long f_files; /* total # of file nodes (inodes) */
+ unsigned long f_ffree; /* total # of free file nodes */
+ unsigned long f_favail; /* # of free nodes avail to non-superuser */
+ unsigned long f_fsid; /* file system id (dev for now) */
+ char f_basetype[16]; /* target fs type name, null-terminated */
+ unsigned long f_flag; /* bit-mask of flags */
+ unsigned long f_namemax; /* maximum file name length */
+ char f_fstr[32]; /* filesystem-specific string */
+ unsigned long f_filler[16]; /* reserved for future expansion */
+ };
+ extern int fstatvfs(int, struct statvfs*);
+ extern int statvfs(const char*, struct statvfs*);
+ #endif
+ #if _typ_off64_t
+ #undef off_t
+ #define off_t off64_t
+ #endif
+ #if _lib_statvfs64 && !defined(statvfs)
+ #define statvfs statvfs64
+ #if !defined(__USE_LARGEFILE64)
+ extern int statvfs64(const char*, struct statvfs64*);
+ #endif
+ #endif
+ #if _lib_fstatvfs64 && !defined(fstatvfs)
+ #define fstatvfs fstatvfs64
+ #if !defined(__USE_LARGEFILE64)
+ extern int fstatvfs64(int, struct statvfs64*);
+ #endif
+ #endif
+}end
+
+str st_fstype sys/types.h sys/stat.h note{ stat.st_fstype is a string }end compile{
+ int f(st)struct stat* st;{return st->st_fstype[0];}
+}end
+
+int st_fstype sys/types.h sys/stat.h note{ stat.st_fstype is an int }end compile{
+ int f(st)struct stat* st;{return st->st_fstype = 1;}
+}end
+
+int st_spare1 sys/types.h sys/stat.h note{ stat.st_spare1 is an int }end compile{
+ int f(st)struct stat* st;{return st->st_spare1 = 1;}
+}end
+
+ary st_spare4 sys/types.h sys/stat.h note{ stat.st_spare4 is an array }end compile{
+ int f(st)struct stat* st;{return st->st_spare4[0] = 1;}
+}end
+
+ary st_pad4 sys/types.h sys/stat.h note{ stat.st_pad4 is an array }end compile{
+ int f(st)struct stat* st;{return st->st_pad4[0] = 1;}
+}end
diff --git a/usr/src/lib/libast/common/features/hack b/usr/src/lib/libast/common/features/hack
new file mode 100644
index 0000000000..2be7af9822
--- /dev/null
+++ b/usr/src/lib/libast/common/features/hack
@@ -0,0 +1 @@
+hdr locale_attr
diff --git a/usr/src/lib/libast/common/features/iconv b/usr/src/lib/libast/common/features/iconv
new file mode 100644
index 0000000000..656a16f0ed
--- /dev/null
+++ b/usr/src/lib/libast/common/features/iconv
@@ -0,0 +1,98 @@
+set prototyped
+hdr iconv
+lib iconv_open,iconv_close,iconv -liconv
+nxt iconv
+
+tst output{
+ #if !_lib_iconv_open
+ #define _undef_hdr_iconv 1
+ #undef _hdr_iconv
+ #endif
+ #if !_hdr_iconv
+ #define _undef_lib_iconv_open 1
+ #undef _lib_iconv_open
+ #endif
+ #if _hdr_iconv
+ #include <sys/types.h>
+ #include <iconv.h>
+ #endif
+
+ int
+ main()
+ {
+ char* lib;
+
+ printf("#include <ast_common.h>\n");
+ printf("#include <ccode.h>\n");
+ #if _undef_hdr_iconv
+ printf("#undef _hdr_iconv\n");
+ #endif
+ #if _undef_lib_iconv_open
+ printf("#undef _lib_iconv_open\n");
+ #endif
+ #if _hdr_iconv && defined(_nxt_iconv_str)
+ printf("#include <%s> /* the native iconv.h */\n", _nxt_iconv_str);
+ #endif
+ printf("\n");
+ printf("#define CC_ICONV (-1)\n");
+ printf("#define CC_UCS (-2)\n");
+ printf("#define CC_SCU (-3)\n");
+ printf("#define CC_UTF (-4)\n");
+ printf("#define CC_UME (-5)\n");
+ printf("\n");
+ #if _lib_iconv_open
+ lib = "_ast_";
+ printf("#ifndef _ICONV_LIST_PRIVATE_\n");
+ printf("#undef iconv_t\n");
+ printf("#define iconv_t %siconv_t\n", lib);
+ printf("#undef iconv_f\n");
+ printf("#define iconv_f %siconv_f\n", lib);
+ printf("#undef iconv_list_t\n");
+ printf("#define iconv_list_t %siconv_list_t\n", lib);
+ printf("#undef iconv_open\n");
+ printf("#define iconv_open %siconv_open\n", lib);
+ printf("#undef iconv\n");
+ printf("#define iconv %siconv\n", lib);
+ printf("#undef iconv_close\n");
+ printf("#define iconv_close %siconv_close\n", lib);
+ printf("#undef iconv_list\n");
+ printf("#define iconv_list %siconv_list\n", lib);
+ printf("#undef iconv_move\n");
+ printf("#define iconv_move %siconv_move\n", lib);
+ printf("#undef iconv_name\n");
+ printf("#define iconv_name %siconv_name\n", lib);
+ printf("#undef iconv_write\n");
+ printf("#define iconv_write %siconv_write\n", lib);
+ printf("#endif\n");
+ #else
+ lib = "";
+ #endif
+ printf("\n");
+ printf("typedef Ccmap_t %siconv_list_t;\n", lib);
+ printf("typedef void* %siconv_t;\n", lib);
+ printf("typedef size_t (*%siconv_f)(%siconv_t, char**, size_t*, char**, size_t*);\n", lib, lib);
+ printf("\n");
+ printf("#if _BLD_ast && defined(__EXPORT__)\n");
+ printf("#define extern __EXPORT__\n");
+ printf("#endif\n");
+ printf("\n");
+ printf("extern %siconv_t %siconv_open(const char*, const char*);\n", lib, lib);
+ printf("extern size_t %siconv(%siconv_t, char**, size_t*, char**, size_t*);\n", lib, lib);
+ printf("extern int %siconv_close(%siconv_t);\n", lib, lib);
+ printf("extern %siconv_list_t* %siconv_list(%siconv_list_t*);\n", lib, lib, lib);
+ printf("extern int %siconv_name(const char*, char*, size_t);\n", lib);
+ printf("#if _SFIO_H\n");
+ printf("extern ssize_t %siconv_move(%siconv_t, Sfio_t*, Sfio_t*, size_t, size_t*);\n", lib, lib);
+ printf("extern ssize_t %siconv_write(%siconv_t, Sfio_t*, char**, size_t*, size_t*);\n", lib, lib);
+ printf("#else\n");
+ printf("#if _SFSTDIO_H\n");
+ printf("extern ssize_t %siconv_move(%siconv_t, FILE*, FILE*, size_t, size_t*);\n", lib, lib);
+ printf("extern ssize_t %siconv_write(%siconv_t, FILE*, char**, size_t*, size_t*);\n", lib, lib);
+ printf("#endif\n");
+ printf("#endif\n");
+ printf("\n");
+ printf("#undef extern\n");
+ printf("\n");
+ return 0;
+ }
+}end
diff --git a/usr/src/lib/libast/common/features/lib b/usr/src/lib/libast/common/features/lib
new file mode 100644
index 0000000000..8795cefa05
--- /dev/null
+++ b/usr/src/lib/libast/common/features/lib
@@ -0,0 +1,648 @@
+ref -D_def_map_ast=1
+
+cmd universe
+
+hdr dirent,direntry,filio,fmtmsg,fnmatch,jioctl,libgen,limits
+hdr locale,ndir,nl_types,process,spawn,syslog,utime,vfork,wctype
+hdr wchar note{ <wchar.h> and isw*() really work }end execute{
+ #include <wchar.h>
+ int
+ main()
+ {
+ wchar_t w = 'a';
+ return iswalnum(w) == 0;
+ }
+}end
+
+dat _tzname,tzname
+
+lib BSDsetpgrp
+lib _cleanup
+lib atexit,bcopy,bzero,catclose,catgets,catopen,confstr,dirread,dup2
+lib execlp,execve,execvp,execvpe
+lib fchmod,fcntl,fmtmsg,fnmatch,fork,fsync
+lib getconf,getdents,getdirentries,getdtablesize,getdate
+lib getgroups,gethostname,getlogin,getpagesize,getrlimit,getuniverse
+lib getopt,getsubopt,getopt_long,getopt_long_only
+lib glob,index,iswblank,iswctype,killpg,link,localeconv,madvise
+lib mbtowc,mbrtowc,memalign,memchr,memcpy,memdup,memmove,memset
+lib mkdir,mkfifo,mktemp,mktime
+lib mount,on_exit,onexit,opendir,pathconf
+lib readlink,remove,rename,rewinddir,rindex,rmdir,setlocale
+lib setpgid,setpgrp,setpgrp2,setreuid,setsid,setuid,sigaction
+lib sigprocmask,sigsetmask,sigunblock,sigvec,socketpair
+lib spawn,spawnve,spawnveg
+lib strchr,strcoll,strdup,strerror,strcasecmp,strncasecmp,strrchr,strstr
+lib strmode,strxfrm,strftime,swab,symlink,sysconf,sysinfo,syslog
+lib telldir,tmpnam,tzset,universe,unlink,utime,wctype
+lib ftruncate,truncate
+lib creat64,fstat64,fstatvfs64,ftruncate64 -D_LARGEFILE64_SOURCE
+lib lseek64,lstat64 -D_LARGEFILE64_SOURCE
+lib open64,readdir64,stat64,statvfs64,truncate64 -D_LARGEFILE64_SOURCE
+
+lib,npt strtod,strtold,strtol,strtoll,strtoul,strtoull stdlib.h
+
+mem direct.d_reclen sys/types.h sys/dir.h
+mem dirent.d_fileno,dirent.d_ino,dirent.d_namlen,dirent.d_off,dirent.d_reclen,dirent.d_type sys/types.h dirent.h
+mem DIR sys/types.h - dirent.h - sys/dir.h
+mem DIR.dd_fd sys/types.h - dirent.h - sys/dir.h
+mem inheritance.pgroup spawn.h
+
+sys dir,filio,jioctl,localedef,ptem,resource
+sys socket,stream,systeminfo,universe,vfork
+
+typ off64_t -D_LARGEFILE64_SOURCE
+typ struct.dirent64 -D_LARGEFILE64_SOURCE dirent.h
+
+tst tst_errno note{ errno can be assigned }end link{
+ _BEGIN_EXTERNS_
+ #define error ______error
+ #define strerror ______strerror
+ #include <errno.h>
+ #undef error
+ #undef strerror
+ #ifndef errno
+ extern int errno;
+ #endif
+ error() { }
+ strerror() { }
+ _END_EXTERNS_
+ int main() { errno = 0; error(); strerror(); return 0; }
+}end
+
+tst lib_poll_fd_1 note{ fd is first arg to poll() }end execute{
+ #include <poll.h>
+ _BEGIN_EXTERNS_
+ extern int pipe _ARG_((int*));
+ _END_EXTERNS_
+ int
+ main()
+ { int rw[2];
+ struct pollfd fd;
+ if (pipe(rw) < 0) return 1;
+ fd.fd = rw[0];
+ fd.events = POLLIN;
+ fd.revents = 0;
+ if (poll(&fd, 1, 0) < 0 || fd.revents != 0) return 1;
+ if (write(rw[1], "x", 1) != 1) return 1;
+ if (poll(&fd, 1, 0) < 0 || fd.revents == 0) return 1;
+ return 0;
+ }
+}end
+
+tst lib_poll_fd_2 note{ fd is second arg to poll() }end execute{
+ #include <poll.h>
+ _BEGIN_EXTERNS_
+ extern int pipe _ARG_((int*));
+ _END_EXTERNS_
+ int
+ main()
+ { int rw[2];
+ struct pollfd fd;
+ if (pipe(rw) < 0) return 1;
+ fd.fd = rw[0];
+ fd.events = POLLIN;
+ fd.revents = 0;
+ return poll(1, &fd, 0) < 0;
+ if (poll(1, &fd, 0) < 0 || fd.revents != 0) return 1;
+ if (write(rw[1], "x", 1) != 1) return 1;
+ if (poll(1, &fd, 0) < 0 || fd.revents == 0) return 1;
+ return 0;
+ }
+}end
+
+exp _lib_poll _lib_poll_fd_1||_lib_poll_fd_2
+
+tst lib_poll_notimer note{ poll with no fds ignores timeout }end execute{
+ #include <sys/types.h>
+ #include <poll.h>
+ _BEGIN_EXTERNS_
+ extern time_t time _ARG_((time_t*));
+ _END_EXTERNS_
+ #define TIMEOUT 4
+ int
+ main()
+ {
+ unsigned long start;
+ unsigned long finish;
+ struct pollfd fd;
+ start = time((time_t*)0);
+ if (poll(&fd, 0, TIMEOUT * 1000) < 0)
+ return 0;
+ finish = time((time_t*)0);
+ return (finish - start) > (TIMEOUT / 2);
+ }
+}end
+
+tst lib_select note{ select() has standard 5 arg interface }end link{
+ #include <sys/types.h>
+ #include <sys/time.h>
+ #include <sys/socket.h>
+ int
+ main()
+ { struct timeval tmb;
+ fd_set rd;
+ FD_ZERO(&rd);
+ FD_SET(0,&rd);
+ tmb.tv_sec = 0;
+ tmb.tv_usec = 0;
+ select(1,&rd,(fd_set*)0,(fd_set*)0,&tmb);
+ return 0;
+ }
+}end
+
+tst pipe_rw note{ full duplex pipes }end execute{
+ _BEGIN_EXTERNS_
+ extern int pipe _ARG_((int*));
+ extern int read _ARG_((int, void*, int));
+ extern int strcmp _ARG_((const char*, const char*));
+ extern int write _ARG_((int, void*, int));
+ _END_EXTERNS_
+ int
+ main()
+ {
+ #if defined(__sgi) || defined(_sgi) || defined(sgi)
+ /* boot tuneable pipes force one way for bin compatibility */
+ return 1;
+ #else
+ static char test[] = "test\n";
+ int io[2];
+ char buf[sizeof(test)];
+ if (pipe(io)) return 1;
+ if (write(io[1], test, sizeof(test)) != sizeof(test)) return 1;
+ if (read(io[0], buf, sizeof(test)) != sizeof(test)) return 1;
+ if (strcmp(test, buf)) return 1;
+ if (write(io[0], test, sizeof(test)) != sizeof(test)) return 1;
+ if (read(io[1], buf, sizeof(test)) != sizeof(test)) return 1;
+ if (strcmp(test, buf)) return 1;
+ return 0;
+ #endif
+ }
+}end
+
+tst lib_vfork unistd.h stdlib.h vfork.h note{ vfork exists and it works }end execute{
+ #include <signal.h>
+ int
+ main(argc, argv)
+ int argc;
+ char** argv;
+ {
+ int status;
+ char* cmd[3];
+ if (argv[1])
+ _exit(signal(SIGHUP, SIG_DFL) != SIG_IGN);
+ signal(SIGHUP, SIG_IGN);
+ switch (vfork())
+ {
+ case -1:
+ _exit(1);
+ case 0:
+ cmd[0] = argv[0];
+ cmd[1] = "test";
+ cmd[2] = 0;
+ execv(cmd[0], cmd);
+ _exit(2);
+ }
+ status = 1;
+ _exit(wait(&status) < 0 || status != 0);
+ }
+}end
+
+tst real_vfork note{ vfork child shares data with parent }end execute{
+ _BEGIN_EXTERNS_
+ extern int _exit _ARG_((int));
+ extern int vfork _ARG_((void));
+ _END_EXTERNS_
+ int code;
+ int
+ main()
+ {
+ code = 1;
+ if (!vfork())
+ code = 0;
+ _exit(code);
+ }
+}end
+
+tst lib_posix_spawn unistd.h stdlib.h spawn.h -Dfork=______fork note{ posix_spawn exists and it works and its worth using }end status{
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <sys/wait.h>
+ #include <spawn.h>
+ #include <signal.h>
+ #include <fcntl.h>
+ #include <string.h>
+ #undef fork
+ /* if it uses fork() why bother? */
+ pid_t fork _ARG_((void)) { return -1; }
+ pid_t _fork _ARG_((void)) { return -1; }
+ pid_t __fork _ARG_((void)) { return -1; }
+ int
+ main(argc, argv)
+ int argc;
+ char** argv;
+ {
+ char* s;
+ pid_t pid;
+ posix_spawnattr_t attr;
+ int n;
+ int status;
+ char* cmd[3];
+ char tmp[1024];
+ if (argv[1])
+ _exit(signal(SIGHUP, SIG_DFL) != SIG_IGN);
+ signal(SIGHUP, SIG_IGN);
+ if (posix_spawnattr_init(&attr))
+ _exit(0);
+ if (posix_spawnattr_setpgroup(&attr, 0))
+ _exit(0);
+ if (posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETPGROUP))
+ _exit(0);
+ /* first try an a.out and verify that SIGHUP is ignored */
+ cmd[0] = argv[0];
+ cmd[1] = "test";
+ cmd[2] = 0;
+ if (posix_spawn(&pid, cmd[0], 0, &attr, cmd, 0))
+ _exit(0);
+ status = 1;
+ if (wait(&status) < 0 || status != 0)
+ _exit(0);
+ /* passing ENOEXEC to the shell is bogus */
+ n = strlen(cmd[0]);
+ if (n >= (sizeof(tmp) - 3))
+ _exit(0);
+ strcpy(tmp, cmd[0]);
+ tmp[n] = '.';
+ tmp[n+1] = 's';
+ tmp[n+2] = 'h';
+ tmp[n+3] = 0;
+ if (close(open(tmp, O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO)) < 0 || chmod(tmp, S_IRWXU|S_IRWXG|S_IRWXO) < 0)
+ _exit(0);
+ cmd[0] = tmp;
+ n = 0;
+ pid = -1;
+ if (posix_spawn(&pid, cmd[0], 0, &attr, cmd, 0))
+ n = 2;
+ else
+ {
+ n = pid != -1 && waitpid(pid, &status, WNOHANG|WNOWAIT) == pid && ((status>>8)&0x7f) == 127;
+ wait(&status);
+ }
+ _exit(n);
+ }
+}end
+
+tst lib_spawn_mode unistd.h stdlib.h note{ first spawn arg is mode and it works }end execute{
+ #include <signal.h>
+ #include <process.h>
+ #ifndef P_NOWAIT
+ #define P_NOWAIT _P_NOWAIT
+ #endif
+ int
+ main(argc, argv)
+ int argc;
+ char** argv;
+ {
+ int status;
+ char* cmd[3];
+ if (argv[1])
+ _exit(signal(SIGHUP, SIG_DFL) != SIG_IGN);
+ signal(SIGHUP, SIG_IGN);
+ cmd[0] = argv[0];
+ cmd[1] = "test";
+ cmd[2] = 0;
+ if (spawnv(P_NOWAIT, cmd[0], cmd) < 0)
+ _exit(1);
+ status = 1;
+ _exit(wait(&status) < 0 || status != 0);
+ }
+}end
+
+tst stream_peek note{ ioctl(I_PEEK) works }end link{
+ #include <sys/types.h>
+ #include <stropts.h>
+ int
+ main()
+ { struct strpeek pbuf;
+ pbuf.flags = 0;
+ pbuf.ctlbuf.maxlen = pbuf.databuf.maxlen =
+ pbuf.ctlbuf.len = pbuf.databuf.len = 0;
+ pbuf.ctlbuf.buf = pbuf.databuf.buf = 0;
+ ioctl(0,I_PEEK,&pbuf);
+ return 0;
+ }
+}end
+
+tst socket_peek note{ recv(MSG_PEEK) works }end execute{
+ #include <unistd.h>
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ int
+ main()
+ {
+ int i;
+ int fds[2];
+ char buf[128];
+
+ static char msg[] = "abcd";
+
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds))
+ return 1;
+ if (write(fds[1], msg, sizeof(msg)) != sizeof(msg))
+ return 1;
+ if (recv(fds[0], buf, sizeof(buf), MSG_PEEK) != sizeof(msg))
+ return 1;
+ for (i = 0; i < sizeof(msg); i++)
+ if (buf[i] != msg[i])
+ return 1;
+ if (read(fds[0], buf, sizeof(msg)) != sizeof(msg))
+ return 1;
+ for (i = 0; i < sizeof(msg); i++)
+ if (buf[i] != msg[i])
+ return 1;
+ return 0;
+ }
+}end
+
+tst lib_memcmp string.h note{ standard memcmp interface that works }end execute{
+ /* sgi again -- we're sick of being their regression test */
+ #define L 8
+ char a[L] = { '0' };
+ char b[L] = { '1' };
+ int
+ main()
+ {
+ return memcmp(a, b, L) >= 0;
+ }
+}end
+
+tst lib_memccpy string.h unistd.h stdlib.h fcntl.h signal.h sys/types.h sys/stat.h sys/mman.h fcntl.h note{ standard memccpy interface that works }end execute{
+ #if _STD_
+ static void gotcha(int sig)
+ #else
+ static int gotcha(sig) int sig;
+ #endif
+ {
+ exit(1);
+ }
+ #ifdef MAP_PRIVATE
+ static const char x[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxN";
+ #if _STD_
+ static int indict_sgi_ia64_4Q_2004(int n)
+ #else
+ static int indict_sgi_ia64_4Q_2004(n) int n;
+ #endif
+ {
+ char* b;
+ char* s;
+ char* e;
+ char* t;
+ long m;
+ int d;
+ char u[1024];
+
+ static char p[32] = {'/','t','m','p','/','m','m'};
+
+ for (d = 7; d < 13; d++)
+ p[d] = 'X';
+ p[d] = 0;
+ if ((d = mkstemp(p)) < 0)
+ return 1;
+ remove(p);
+ for (m = 0; m < n; m++)
+ if (write(d, x, sizeof(x)-1) != sizeof(x)-1)
+ {
+ close(d);
+ return 1;
+ }
+ if (lseek(d, (off_t)0, SEEK_SET))
+ {
+ close(d);
+ return 1;
+ }
+ m = n * (sizeof(x)-1);
+ if (!(b = mmap((void*)0, m, PROT_READ|PROT_WRITE, MAP_PRIVATE, d, (off_t)0)))
+ {
+ close(d);
+ return 1;
+ }
+ for (e = (s = b) + m; s < e && (t = memccpy(u, s, 'N', (e-s) > sizeof(u) ? sizeof(u) : (e-s))); s += (t-u))
+ if ((t-u) != (sizeof(x)-1) || memcmp(u, s, t-u))
+ {
+ close(d);
+ return 1;
+ }
+ if (s < e)
+ {
+ close(d);
+ return 1;
+ }
+ close(d);
+ return 0;
+ }
+ #endif
+
+ int
+ main ()
+ {
+ char buf[1024];
+ #ifdef MAP_PRIVATE
+ char* srcbuf;
+ char* dstbuf;
+ int fd;
+ size_t siz;
+ int i;
+ #endif
+
+ /*
+ * early mac osx failed here -- fixed 3Q 2001
+ */
+
+ if (memccpy(buf, "abc", 0, sizeof(buf)) != (buf + 4))
+ return 1;
+ #ifdef MAP_PRIVATE
+ siz = 64 * 1024;
+ if (!(dstbuf = malloc(2 * siz)))
+ return 0;
+ if ((fd = open("/dev/zero", O_RDWR)) < 0)
+ return 0;
+ if (!(srcbuf = (char*)mmap(NULL, siz, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0)))
+ return 0;
+ if (!mmap(srcbuf + siz, siz, PROT_NONE, MAP_PRIVATE, fd, 0))
+ return 0;
+ for (i = 0; i < siz; i++)
+ srcbuf[i] = 'x';
+ srcbuf[siz - 1] = 0;
+ alarm(10);
+ signal(SIGSEGV, gotcha);
+ signal(SIGBUS, gotcha);
+ signal(SIGALRM, gotcha);
+ /*
+ * sgi ia64 dumps here as of 3Q 2001
+ * bug acknowleged 1Q 2003
+ */
+ memccpy(dstbuf, srcbuf, 0, siz + 10);
+ alarm(0);
+ if (strcmp(srcbuf, dstbuf))
+ return 1;
+ if (indict_sgi_ia64_4Q_2004(1))
+ return 1;
+ if (indict_sgi_ia64_4Q_2004(257))
+ return 1;
+ #endif
+ return 0;
+ }
+}end
+
+tst lib_utime_now note{ utime works with 0 time vector }end execute{
+ #include <sys/types.h>
+ _BEGIN_EXTERNS_
+ extern int utime _ARG_((const char*, void*));
+ _END_EXTERNS_
+ int
+ main()
+ {
+ return utime(".", (void*)0) == -1;
+ }
+}end
+
+tst cross{
+ u=att
+ case `/bin/cat -s /dev/null/foo 2>&1` in
+ '') ;;
+ *) case `/bin/echo '\\t'` in
+ '\t') u=ucb ;;
+ esac
+ ;;
+ esac
+ echo "#define _UNIV_DEFAULT \"$u\" /* default universe name */"
+}end
+
+std cleanup note{ stuck with standard _cleanup }end noexecute{
+ _BEGIN_EXTERNS_
+ extern void exit _ARG_((int));
+ extern void _exit _ARG_((int));
+ extern void _cleanup();
+ void _cleanup() { _exit(0); }
+ _END_EXTERNS_
+ int main() { printf("cleanup\n"); exit(1); }
+}end
+
+std remove note{ stuck with standard remove() }end nostatic{
+ _BEGIN_EXTERNS_
+ extern int unlink _ARG_((const char*));
+ _END_EXTERNS_
+ #if _STD_
+ int remove(const char* path) { return 0; }
+ #else
+ int remove(path) char* path; { return 0; }
+ #endif
+ int main() { return unlink("foo"); }
+}end
+
+std signal note{ stuck with standard signal }end nolink{
+ _BEGIN_EXTERNS_
+ extern int abort();
+ int signal() { return 0; }
+ _END_EXTERNS_
+ int main() { signal(); abort(); return 0; }
+}end
+
+std strcoll note{ standard strcoll works }end execute{
+ #include <string.h>
+ #define S "hello world"
+ int
+ main()
+ {
+ char s[] = S;
+ char t[] = S;
+ return strcoll(s, t) || strcmp(s, t);
+ }
+}end
+
+std strtod stdlib.h note{ stuck with standard strtod }end nostatic{
+ _BEGIN_EXTERNS_
+ #if _STD_
+ double strtod(const char* s, char** e) { return 0.0; }
+ #else
+ double strtod(s, e) char* s; char** e; { return 0.0; }
+ #endif
+ _END_EXTERNS_
+ int main() { printf(""); return strtod("1",0) != 0; }
+}end
+
+std strtold stdlib.h note{ stuck with standard strtold }end nostatic{
+ _BEGIN_EXTERNS_
+ #if _STD_
+ long double strtold(const char* s, char** e) { return 0.0; }
+ #else
+ long double strtold(s, e) char* s; char** e; { return 0.0; }
+ #endif
+ _END_EXTERNS_
+ int main() { printf(""); return strtold("1",0) != 0; }
+}end
+
+std strtol note{ stuck with standard strtol }end nostatic{
+ _BEGIN_EXTERNS_
+ #if _STD_
+ extern long atol(const char*);
+ long strtol(const char* s, char** e, int b) { return 0; }
+ #else
+ extern long atol();
+ long strtol(s, e, b) char* s; char** e; int b; { return 0; }
+ #endif
+ _END_EXTERNS_
+ int main() { printf(""); return (atol("1") + strtol("1",(char**)0,0)) != 0; }
+}end
+
+tst - output{
+ int
+ main()
+ {
+ #if _UWIN
+ printf("\n");
+ printf("/* override some uwin feature tests */\n");
+ printf("#undef _lib_execlp\n");
+ printf("#undef _lib_execvp\n");
+ printf("#undef _lib_execvpe\n");
+ printf("#undef _lib_fork\n");
+ printf("#undef _std_string\n");
+ printf("#define _std_string 1\n");
+ printf("#undef _stream_peek\n");
+ printf("\n");
+ #endif
+
+ #if _lib_spawnveg || _lib_posix_spawn || _lib_spawn_mode || _lib_spawn && _hdr_spawn && _mem_pgroup_inheritance || _lib_vfork && _real_vfork
+ printf("#if !_AST_no_spawnveg\n");
+ printf("#define _use_spawnveg 1\n");
+ printf("#endif\n");
+ printf("\n");
+ #endif
+
+ return 0;
+ }
+
+}end
+
+tst no64 -D_LARGEFILE64_SOURCE note{ largefile 64 broken }end execute{
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ int
+ main()
+ {
+ struct stat64 st;
+ return !stat64(".", &st) && st.st_mode && st.st_mtime;
+ }
+}end pass{
+ echo "/* can we at least agree that a successful return means success? */"
+ echo "#undef _lib_creat64"
+ echo "#undef _lib_fstat64"
+ echo "#undef _lib_fstatvfs64"
+ echo "#undef _lib_ftruncate64"
+ echo "#undef _lib_lseek64"
+ echo "#undef _lib_lstat64"
+ echo "#undef _lib_mmap64"
+ echo "#undef _lib_stat64"
+ echo "#undef _lib_statvfs64"
+ echo "#undef _lib_truncate64"
+}end
diff --git a/usr/src/lib/libast/common/features/libpath.sh b/usr/src/lib/libast/common/features/libpath.sh
new file mode 100644
index 0000000000..89c12b0fb4
--- /dev/null
+++ b/usr/src/lib/libast/common/features/libpath.sh
@@ -0,0 +1,73 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1985-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# Glenn Fowler <gsf@research.att.com> #
+# David Korn <dgk@research.att.com> #
+# Phong Vo <kpv@research.att.com> #
+# #
+########################################################################
+ok=0
+for i in \
+ -x /lib/ld.so /lib/ld-*.so /usr/lib/ld.so /lib/rld \
+ -f /usr/shlib/libc.so /shlib/libc.so /usr/lib/libc.so \
+ -r /usr/shlib/libc.so /shlib/libc.so
+do case $i in
+ -*) op=$i; continue ;;
+ esac
+ if test $op $i
+ then ok=1
+ break
+ fi
+ set x $i.[0-9]*
+ if test $op $2
+ then ok=1
+ break
+ fi
+done
+if test "0" != "$ok"
+then libpath=lib:LD_LIBRARY_PATH
+ case `package` in
+ sgi.*) if test -d /lib32
+ then libpath="lib32:LD_LIBRARYN32_PATH:sgi.mips3|sgi.*-n32,$libpath"
+ fi
+ if test -d /lib64
+ then libpath="lib64:LD_LIBRARY64_PATH:sgi.mips[4-9]|sgi.*-64,$libpath"
+ fi
+ ;;
+ sol*.*) if test -d /lib/32
+ then libpath="lib/32:LD_LIBRARY_PATH_32,$libpath"
+ fi
+ if test -d /lib/64
+ then libpath="lib/64:LD_LIBRARY_PATH_64:sol.*64*,$libpath"
+ fi
+ ;;
+ esac
+elif test -x /lib/dld.sl
+then libpath=lib:SHLIB_PATH
+elif test -x /usr/lib/dyld
+then libpath=lib:DYLD_LIBRARY_PATH
+else case `package` in
+ ibm.*|mvs.*)
+ libpath=lib:LIBPATH
+ ;;
+ *) libpath=
+ ;;
+ esac
+fi
+case $libpath in
+'') libpath=bin ;;
+esac
+echo "#define CONF_LIBPATH \"$libpath\""
diff --git a/usr/src/lib/libast/common/features/limits.c b/usr/src/lib/libast/common/features/limits.c
new file mode 100644
index 0000000000..a95d92b853
--- /dev/null
+++ b/usr/src/lib/libast/common/features/limits.c
@@ -0,0 +1,339 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * generate limits features
+ *
+ * FOPEN_MAX POSIX says ANSI defines it but it's not in ANSI
+ *
+ * NOTE: two's complement binary integral representation assumed
+ */
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide getpagesize getdtablesize
+#else
+#define getpagesize ______getpagesize
+#define getdtablesize ______getdtablesize
+#endif
+
+/*
+ * we'd like as many symbols as possible defined
+ * the standards push the vendors the other way
+ * but don't provide guard that lets everything through
+ * so each vendor adds their own guard
+ * many now include something like <standards.h> to
+ * get it straight in one place -- <sys/types.h> should
+ * kick that in
+ */
+
+#include "FEATURE/standards"
+#include "FEATURE/lib"
+
+#ifdef __sun
+#define _timespec timespec
+#endif
+
+#include <sys/types.h>
+
+#undef _SGIAPI
+#define _SGIAPI 1
+
+#if _hdr_limits
+#include <limits.h>
+#endif
+
+#undef _SGIAPI
+#define _SGIAPI 0
+
+#include "FEATURE/lib"
+#include "FEATURE/common"
+
+#if _hdr_unistd
+#include <unistd.h>
+#endif
+
+#include "FEATURE/param"
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide getpagesize getdtablesize
+#else
+#undef getpagesize
+#undef getdtablesize
+#endif
+
+int main()
+{
+ char c;
+ unsigned char uc;
+ unsigned short us;
+ unsigned int ui;
+ unsigned long ul;
+ unsigned long val;
+#if _typ_uint64_t
+ uint64_t ull;
+ uint64_t vll;
+#endif
+
+ /*
+ * <limits.h> with *constant* valued macros
+ */
+
+ printf("\n");
+#ifndef CHAR_BIT
+ uc = 0;
+ uc = ~uc;
+ val = 1;
+ while (uc >>= 1) val++;
+ printf("#define CHAR_BIT %lu\n", val);
+#endif
+#ifndef MB_LEN_MAX
+ val = 1;
+ printf("#define MB_LEN_MAX %lu\n", val);
+#endif
+
+ c = 0;
+ c = ~c;
+ uc = 0;
+ uc = ~uc;
+ us = 0;
+ us = ~us;
+ ui = 0;
+ ui = ~ui;
+ ul = 0;
+ ul = ~ul;
+#if _typ_uint64_t
+ ull = 0;
+ ull = ~ull;
+#endif
+
+#ifndef UCHAR_MAX
+ val = uc;
+ printf("#if defined(__STDC__)\n");
+ printf("#define UCHAR_MAX %luU\n", val);
+ printf("#else\n");
+ printf("#define UCHAR_MAX %lu\n", val);
+ printf("#endif\n");
+#endif
+
+#ifndef SCHAR_MIN
+ val = (unsigned char)(uc >> 1) + 1;
+ printf("#define SCHAR_MIN (-%lu)\n", val);
+#endif
+
+#ifndef SCHAR_MAX
+ val = (unsigned char)(uc >> 1);
+ printf("#define SCHAR_MAX %lu\n", val);
+#endif
+
+ if (c < 0)
+ {
+#ifndef CHAR_MIN
+ printf("#define CHAR_MIN SCHAR_MIN\n");
+#endif
+
+#ifndef CHAR_MAX
+ printf("#define CHAR_MAX SCHAR_MAX\n");
+#endif
+ }
+ else
+ {
+#ifndef CHAR_MIN
+ printf("#define CHAR_MIN 0\n");
+#endif
+
+#ifndef CHAR_MAX
+ printf("#define CHAR_MAX UCHAR_MAX\n");
+#endif
+ }
+
+#ifndef USHRT_MAX
+ val = us;
+ printf("#if defined(__STDC__)\n");
+ printf("#define USHRT_MAX %luU\n", val);
+ printf("#else\n");
+ printf("#define USHRT_MAX %lu\n", val);
+ printf("#endif\n");
+#endif
+
+#ifndef SHRT_MIN
+ val = (unsigned short)(us >> 1) + 1;
+ printf("#define SHRT_MIN (-%lu)\n", val);
+#endif
+
+#ifndef SHRT_MAX
+ val = (unsigned short)(us >> 1);
+ printf("#define SHRT_MAX %lu\n", val);
+#endif
+
+ if (ui == us)
+ {
+#ifndef UINT_MAX
+ printf("#define UINT_MAX USHRT_MAX\n");
+#endif
+
+#ifndef INT_MIN
+ printf("#define INT_MIN SHRT_MIN\n");
+#endif
+
+#ifndef INT_MAX
+ printf("#define INT_MAX SHRT_MAX\n");
+#endif
+ }
+ else
+ {
+#ifndef UINT_MAX
+ val = ui;
+ printf("#if defined(__STDC__)\n");
+ printf("#define UINT_MAX %luU\n", val);
+ printf("#else\n");
+ printf("#define UINT_MAX %lu\n", val);
+ printf("#endif\n");
+#endif
+
+#ifndef INT_MIN
+ val = (unsigned int)(ui >> 1) + 1;
+ if (ui == ul) printf("#define INT_MIN (-%lu-1)\n", val - 1);
+ else printf("#define INT_MIN (-%lu)\n", val);
+#endif
+
+#ifndef INT_MAX
+ val = (unsigned int)(ui >> 1);
+ printf("#define INT_MAX %lu\n", val);
+#endif
+ }
+
+ if (ul == ui)
+ {
+#ifndef ULONG_MAX
+ printf("#define ULONG_MAX UINT_MAX\n");
+#endif
+
+#ifndef LONG_MIN
+ printf("#define LONG_MIN INT_MIN\n");
+#endif
+
+#ifndef LONG_MAX
+ printf("#define LONG_MAX INT_MAX\n");
+#endif
+ }
+ else
+ {
+#ifndef ULONG_MAX
+ val = ul;
+ printf("#if defined(__STDC__)\n");
+ printf("#define ULONG_MAX %luLU\n", val);
+ printf("#else\n");
+ printf("#define ULONG_MAX %lu\n", val);
+ printf("#endif\n");
+#endif
+
+#ifndef LONG_MIN
+ val = (unsigned long)(ul >> 1) + 1;
+ printf("#define LONG_MIN (-%luL-1L)\n", val - 1);
+#endif
+
+#ifndef LONG_MAX
+ val = (unsigned long)(ul >> 1);
+ printf("#define LONG_MAX %luL\n", val);
+#endif
+ }
+
+#if _typ_uint64_t && !_ast_intmax_long
+ if (ull == ul)
+ {
+#ifndef ULLONG_MAX
+ printf("#define ULLONG_MAX ULONG_MAX\n");
+#endif
+
+#ifndef LLONG_MIN
+ printf("#define LLONG_MIN LONG_MIN\n");
+#endif
+
+#ifndef LLONG_MAX
+ printf("#define LLONG_MAX LONG_MAX\n");
+#endif
+ }
+ else
+ {
+#ifndef ULLONG_MAX
+ vll = ull;
+ printf("#ifndef ULLONG_MAX\n");
+ printf("#if defined(__STDC__) && _ast_LL\n");
+ printf("#define ULLONG_MAX %lluULL\n", vll);
+ printf("#else\n");
+ printf("#define ULLONG_MAX %llu\n", vll);
+ printf("#endif\n");
+ printf("#endif\n");
+#endif
+
+#ifndef LLONG_MIN
+ vll = (uint64_t)(ull >> 1) + 1;
+ printf("#ifndef LLONG_MIN\n");
+ printf("#if defined(__STDC__) && _ast_LL\n");
+ printf("#define LLONG_MIN (-%lluLL-1LL)\n", vll - 1);
+ printf("#else\n");
+ printf("#define LLONG_MIN (-%llu-1)\n", vll - 1);
+ printf("#endif\n");
+ printf("#endif\n");
+#endif
+
+#ifndef LLONG_MAX
+ vll = (uint64_t)(ull >> 1);
+ printf("#ifndef LLONG_MAX\n");
+ printf("#if defined(__STDC__) && _ast_LL\n");
+ printf("#define LLONG_MAX %lluLL\n", vll);
+ printf("#else\n");
+ printf("#define LLONG_MAX %llu\n", vll);
+ printf("#endif\n");
+ printf("#endif\n");
+#endif
+ }
+#endif
+
+ printf("\n");
+#ifdef _UWIN
+ printf("#ifdef _UWIN\n");
+ printf("#ifndef DBL_DIG\n");
+ printf("#define DBL_DIG 15\n");
+ printf("#endif\n");
+ printf("#ifndef DBL_MAX\n");
+ printf("#define DBL_MAX 1.7976931348623158e+308\n");
+ printf("#endif\n");
+ printf("#ifndef FLT_DIG\n");
+ printf("#define FLT_DIG 6\n");
+ printf("#endif\n");
+ printf("#ifndef FLT_MAX\n");
+ printf("#define FLT_MAX 3.402823466e+38F\n");
+ printf("#endif\n");
+ printf("#endif\n");
+ printf("\n");
+#endif
+
+#include "conflim.h"
+
+ printf("\n");
+
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/features/map.c b/usr/src/lib/libast/common/features/map.c
new file mode 100644
index 0000000000..bad5d052c5
--- /dev/null
+++ b/usr/src/lib/libast/common/features/map.c
@@ -0,0 +1,523 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * some systems may pull in <ast_common.h> and its <ast_map.h>
+ * which we are in the process of generating ... this prevents it
+ */
+
+#define _def_map_ast 1
+
+#include "FEATURE/lib"
+#include "FEATURE/mmap"
+#include "FEATURE/vmalloc"
+
+int
+main()
+{
+ printf("#pragma prototyped\n");
+ printf("\n");
+ printf("/*\n");
+ printf(" * prototypes provided for standard interfaces hijacked\n");
+ printf(" * by ast and mapped to _ast_* but already prototyped\n");
+ printf(" * unmapped in native headers included by <ast_std.h>\n");
+ printf(" */\n");
+ printf("\n");
+ printf("#if _BLD_ast && defined(__EXPORT__)\n");
+ printf("#define extern __EXPORT__\n");
+ printf("#endif\n");
+ printf("\n");
+#if __MVS__
+#undef _map_libc
+#define _map_libc 1
+ printf("\n");
+ printf("/* mvs.390 libc.dll routines can't be intercepted by user dlls */\n");
+ printf("#undef _mem_dd_fd_DIR\n");
+ printf("#undef _typ_long_double\n");
+#endif
+#if _map_libc
+#undef _map_malloc
+#define _map_malloc 1
+ printf("\n");
+ printf("#define _map_libc 1\n");
+ printf("#undef basename\n");
+ printf("#define basename _ast_basename\n");
+ printf("#undef dirname\n");
+ printf("#define dirname _ast_dirname\n");
+ printf("#undef eaccess\n");
+ printf("#define eaccess _ast_eaccess\n");
+#if !_lib_execvpe
+ printf("#undef execvpe\n");
+ printf("#define execvpe _ast_execvpe\n");
+ printf("extern int execvpe(const char*, char* const[], char* const[]);\n");
+#endif
+ printf("#undef fnmatch\n");
+ printf("#define fnmatch _ast_fnmatch\n");
+ printf("#undef fts_children\n");
+ printf("#define fts_children _ast_fts_children\n");
+ printf("#undef fts_close\n");
+ printf("#define fts_close _ast_fts_close\n");
+ printf("#undef fts_flags\n");
+ printf("#define fts_flags _ast_fts_flags\n");
+ printf("#undef fts_notify\n");
+ printf("#define fts_notify _ast_fts_notify\n");
+ printf("#undef fts_open\n");
+ printf("#define fts_open _ast_fts_open\n");
+ printf("#undef fts_read\n");
+ printf("#define fts_read _ast_fts_read\n");
+ printf("#undef fts_set\n");
+ printf("#define fts_set _ast_fts_set\n");
+ printf("#undef ftw\n");
+ printf("#define ftw _ast_ftw\n");
+ printf("#undef ftwalk\n");
+ printf("#define ftwalk _ast_ftwalk\n");
+ printf("#undef ftwflags\n");
+ printf("#define ftwflags _ast_ftwflags\n");
+#if !_WINIX
+ printf("#undef getcwd\n");
+ printf("#define getcwd _ast_getcwd\n");
+ printf("extern char* getcwd(char*, size_t);\n");
+#endif
+ printf("#undef getdate\n");
+ printf("#define getdate _ast_getdate\n");
+#if _lib_getopt || _lib_getsubopt || _lib_getopt_long || _lib_getopt_long_only
+ printf("#undef getopt\n");
+ printf("#define getopt _ast_getopt\n");
+ printf("#undef getsubopt\n");
+ printf("#define getsubopt _ast_getsubopt\n");
+ printf("#undef getopt_long\n");
+ printf("#define getopt_long _ast_getopt_long\n");
+ printf("#undef getopt_long_only\n");
+ printf("#define getopt_long_only _ast_getopt_long_only\n");
+#endif
+ printf("#undef getwd\n");
+ printf("#define getwd _ast_getwd\n");
+ printf("extern char* getwd(char*);\n");
+ printf("#undef glob\n");
+ printf("#define glob _ast_glob\n");
+ printf("#undef globfree\n");
+ printf("#define globfree _ast_globfree\n");
+ printf("#undef memdup\n");
+ printf("#define memdup _ast_memdup\n");
+ printf("#undef memfatal\n");
+ printf("#define memfatal _ast_memfatal\n");
+ printf("#undef memhash\n");
+ printf("#define memhash _ast_memhash\n");
+ printf("#undef memsum\n");
+ printf("#define memsum _ast_memsum\n");
+ printf("#undef mkstemp\n");
+ printf("#define mkstemp _ast_mkstemp\n");
+ printf("extern int mkstemp(char*);\n");
+ printf("#undef mktemp\n");
+ printf("#define mktemp _ast_mktemp\n");
+ printf("extern char* mktemp(char*);\n");
+ printf("#undef mktime\n");
+ printf("#define mktime _ast_mktime\n");
+ printf("#undef nftw\n");
+ printf("#define nftw _ast_nftw\n");
+ printf("#undef optesc\n");
+ printf("#define optesc _ast_optesc\n");
+ printf("#undef optget\n");
+ printf("#define optget _ast_optget\n");
+ printf("#undef opthelp\n");
+ printf("#define opthelp _ast_opthelp\n");
+ printf("#undef optjoin\n");
+ printf("#define optjoin _ast_optjoin\n");
+ printf("#undef optstr\n");
+ printf("#define optstr _ast_optstr\n");
+ printf("#undef optusage\n");
+ printf("#define optusage _ast_optusage\n");
+ printf("#undef pathaccess\n");
+ printf("#define pathaccess _ast_pathaccess\n");
+ printf("#undef pathbin\n");
+ printf("#define pathbin _ast_pathbin\n");
+ printf("#undef pathcanon\n");
+ printf("#define pathcanon _ast_pathcanon\n");
+ printf("#undef pathcat\n");
+ printf("#define pathcat _ast_pathcat\n");
+ printf("#undef pathcd\n");
+ printf("#define pathcd _ast_pathcd\n");
+ printf("#undef pathcheck\n");
+ printf("#define pathcheck _ast_pathcheck\n");
+ printf("#undef pathexists\n");
+ printf("#define pathexists _ast_pathexists\n");
+ printf("#undef pathfind\n");
+ printf("#define pathfind _ast_pathfind\n");
+ printf("#undef pathgetlink\n");
+ printf("#define pathgetlink _ast_pathgetlink\n");
+ printf("#undef pathinclude\n");
+ printf("#define pathinclude _ast_pathinclude\n");
+ printf("#undef pathkey\n");
+ printf("#define pathkey _ast_pathkey\n");
+ printf("#undef pathnative\n");
+ printf("#define pathnative _ast_pathnative\n");
+ printf("#undef pathpath\n");
+ printf("#define pathpath _ast_pathpath\n");
+ printf("#undef pathposix\n");
+ printf("#define pathposix _ast_pathposix\n");
+ printf("#undef pathprobe\n");
+ printf("#define pathprobe _ast_pathprobe\n");
+ printf("#undef pathrepl\n");
+ printf("#define pathrepl _ast_pathrepl\n");
+ printf("#undef pathsetlink\n");
+ printf("#define pathsetlink _ast_pathsetlink\n");
+ printf("#undef pathshell\n");
+ printf("#define pathshell _ast_pathshell\n");
+ printf("#undef pathstat\n");
+ printf("#define pathstat _ast_pathstat\n");
+ printf("#undef pathtemp\n");
+ printf("#define pathtemp _ast_pathtemp\n");
+ printf("#undef pathtmp\n");
+ printf("#define pathtmp _ast_pathtmp\n");
+ printf("#undef procclose\n");
+ printf("#define procclose _ast_procclose\n");
+ printf("#undef procfree\n");
+ printf("#define procfree _ast_procfree\n");
+ printf("#undef procopen\n");
+ printf("#define procopen _ast_procopen\n");
+ printf("#undef procrun\n");
+ printf("#define procrun _ast_procrun\n");
+ printf("#undef putenv\n");
+ printf("#define putenv _ast_putenv\n");
+ printf("#undef re_comp\n");
+ printf("#define re_comp _ast_re_comp\n");
+ printf("#undef re_exec\n");
+ printf("#define re_exec _ast_re_exec\n");
+ printf("#undef realpath\n");
+ printf("#define realpath _ast_realpath\n");
+ printf("extern char* realpath(const char*, char*);\n");
+ printf("#undef regaddclass\n");
+ printf("#define regaddclass _ast_regaddclass\n");
+ printf("#undef regalloc\n");
+ printf("#define regalloc _ast_regalloc\n");
+ printf("#undef regcache\n");
+ printf("#define regcache _ast_regcache\n");
+ printf("#undef regclass\n");
+ printf("#define regclass _ast_regclass\n");
+ printf("#undef regcmp\n");
+ printf("#define regcmp _ast_regcmp\n");
+ printf("#undef regcollate\n");
+ printf("#define regcollate _ast_regcollate\n");
+ printf("#undef regcomb\n");
+ printf("#define regcomb _ast_regcomb\n");
+ printf("#undef regcomp\n");
+ printf("#define regcomp _ast_regcomp\n");
+ printf("#undef regdecomp\n");
+ printf("#define regdecomp _ast_regdecomp\n");
+ printf("#undef regdup\n");
+ printf("#define regdup _ast_regdup\n");
+ printf("#undef regerror\n");
+ printf("#define regerror _ast_regerror\n");
+ printf("#undef regex\n");
+ printf("#define regex _ast_regex\n");
+ printf("#undef regexec\n");
+ printf("#define regexec _ast_regexec\n");
+ printf("#undef regfatal\n");
+ printf("#define regfatal _ast_regfatal\n");
+ printf("#undef regfatalpat\n");
+ printf("#define regfatalpat _ast_regfatalpat\n");
+ printf("#undef regfree\n");
+ printf("#define regfree _ast_regfree\n");
+ printf("#undef regncomp\n");
+ printf("#define regncomp _ast_regncomp\n");
+ printf("#undef regnexec\n");
+ printf("#define regnexec _ast_regnexec\n");
+ printf("#undef regrecord\n");
+ printf("#define regrecord _ast_regrecord\n");
+ printf("#undef regrexec\n");
+ printf("#define regrexec _ast_regrexec\n");
+ printf("#undef regstat\n");
+ printf("#define regstat _ast_regstat\n");
+ printf("#undef regsub\n");
+ printf("#define regsub _ast_regsub\n");
+ printf("#undef regsubcomp\n");
+ printf("#define regsubcomp _ast_regsubcomp\n");
+ printf("#undef regsubexec\n");
+ printf("#define regsubexec _ast_regsubexec\n");
+ printf("#undef regsubflags\n");
+ printf("#define regsubflags _ast_regsubflags\n");
+ printf("#undef regsubfree\n");
+ printf("#define regsubfree _ast_regsubfree\n");
+ printf("#undef remove\n");
+ printf("#define remove _ast_remove\n");
+ printf("extern int remove(const char*);\n");
+ printf("#undef resolvepath\n");
+ printf("#define resolvepath _ast_resolvepath\n");
+ printf("extern char* resolvepath(const char*, char*, size_t);\n");
+ printf("#undef setenv\n");
+ printf("#define setenv _ast_setenv\n");
+ printf("extern int setenv(const char*, const char*, int);\n");
+ printf("#undef setenviron\n");
+ printf("#define setenviron _ast_setenviron\n");
+ printf("#undef sigcritical\n");
+ printf("#define sigcritical _ast_sigcritical\n");
+ printf("#undef signal\n");
+ printf("#define signal _ast_signal\n");
+ printf("#undef sigunblock\n");
+ printf("#define sigunblock _ast_sigunblock\n");
+ printf("#undef stracmp\n");
+ printf("#define stracmp _ast_stracmp\n");
+ printf("#undef strcopy\n");
+ printf("#define strcopy _ast_strcopy\n");
+ printf("#undef strelapsed\n");
+ printf("#define strelapsed _ast_strelapsed\n");
+ printf("#undef stresc\n");
+ printf("#define stresc _ast_stresc\n");
+ printf("#undef streval\n");
+ printf("#define streval _ast_streval\n");
+ printf("#undef strexpr\n");
+ printf("#define strexpr _ast_strexpr\n");
+ printf("#undef strftime\n");
+ printf("#define strftime _ast_strftime\n");
+ printf("#undef strgid\n");
+ printf("#define strgid _ast_strgid\n");
+ printf("#undef strgrpmatch\n");
+ printf("#define strgrpmatch _ast_strgrpmatch\n");
+ printf("#undef strhash\n");
+ printf("#define strhash _ast_strhash\n");
+ printf("#undef strkey\n");
+ printf("#define strkey _ast_strkey\n");
+ printf("#undef strlcat\n");
+ printf("#define strlcat _ast_strlcat\n");
+ printf("extern size_t strlcat(char*, const char*, size_t);\n");
+ printf("#undef strlcpy\n");
+ printf("#define strlcpy _ast_strlcpy\n");
+ printf("extern size_t strlcpy(char*, const char*, size_t);\n");
+ printf("#undef strlook\n");
+ printf("#define strlook _ast_strlook\n");
+ printf("#undef strmatch\n");
+ printf("#define strmatch _ast_strmatch\n");
+#endif
+#if _map_libc || _lib_strmode
+ printf("#undef strmode\n");
+ printf("#define strmode _ast_strmode\n");
+#endif
+#if _map_libc
+ printf("#undef strnacmp\n");
+ printf("#define strnacmp _ast_strnacmp\n");
+ printf("#undef strncopy\n");
+ printf("#define strncopy _ast_strncopy\n");
+ printf("#undef strntod\n");
+ printf("#define strntod _ast_strntod\n");
+ printf("#undef strntol\n");
+ printf("#define strntol _ast_strntol\n");
+ printf("#undef strntold\n");
+ printf("#define strntold _ast_strntold\n");
+ printf("#undef strntoll\n");
+ printf("#define strntoll _ast_strntoll\n");
+ printf("#undef strntoul\n");
+ printf("#define strntoul _ast_strntoul\n");
+ printf("#undef strntoull\n");
+ printf("#define strntoull _ast_strntoull\n");
+ printf("#undef stropt\n");
+ printf("#define stropt _ast_stropt\n");
+ printf("#undef strperm\n");
+ printf("#define strperm _ast_strperm\n");
+ printf("#undef strpsearch\n");
+ printf("#define strpsearch _ast_strpsearch\n");
+#if !_lib_strptime
+ printf("#undef strptime\n");
+ printf("#define strptime _ast_strptime\n");
+#endif
+ printf("#undef strsearch\n");
+ printf("#define strsearch _ast_strsearch\n");
+ printf("#undef strsort\n");
+ printf("#define strsort _ast_strsort\n");
+ printf("#undef strsubmatch\n");
+ printf("#define strsubmatch _ast_strsubmatch\n");
+ printf("#undef strsum\n");
+ printf("#define strsum _ast_strsum\n");
+ printf("#undef strtape\n");
+ printf("#define strtape _ast_strtape\n");
+ printf("#undef strtoip4\n");
+ printf("#define strtoip4 _ast_strtoip4\n");
+ printf("#undef strton\n");
+ printf("#define strton _ast_strton\n");
+ printf("#undef strtonll\n");
+ printf("#define strtonll _ast_strtonll\n");
+ printf("#undef struid\n");
+ printf("#define struid _ast_struid\n");
+ printf("#undef struniq\n");
+ printf("#define struniq _ast_struniq\n");
+ printf("#undef system\n");
+ printf("#define system _ast_system\n");
+ printf("extern int system(const char*);\n");
+ printf("#undef tempnam\n");
+ printf("#define tempnam _ast_tempnam\n");
+ printf("extern char* tempnam(const char*, const char*);\n");
+ printf("#undef tmpnam\n");
+ printf("#define tmpnam _ast_tmpnam\n");
+ printf("extern char* tmpnam(char*);\n");
+ printf("#undef touch\n");
+ printf("#define touch _ast_touch\n");
+ printf("#undef wordexp\n");
+ printf("#define wordexp _ast_wordexp\n");
+ printf("#undef wordfree\n");
+ printf("#define wordfree _ast_wordfree\n");
+ printf("#undef unsetenv\n");
+ printf("#define unsetenv _ast_unsetenv\n");
+#endif
+#if _std_malloc
+ printf("\n");
+ printf("/* no local malloc override */\n");
+ printf("#define _std_malloc 1\n");
+#else
+#if _map_malloc
+ printf("\n");
+ printf("/* cannot override local malloc */\n");
+ printf("#define _map_malloc 1\n");
+ printf("#undef calloc\n");
+ printf("#define calloc _ast_calloc\n");
+ printf("extern void* calloc(size_t, size_t);\n");
+ printf("#undef cfree\n");
+ printf("#define cfree _ast_cfree\n");
+ printf("extern void cfree(void*);\n");
+ printf("#undef free\n");
+ printf("#define free _ast_free\n");
+ printf("extern void free(void*);\n");
+#if _lib_mallinfo
+ printf("#undef mallinfo\n");
+ printf("#define mallinfo _ast_mallinfo\n");
+#endif
+ printf("#undef malloc\n");
+ printf("#define malloc _ast_malloc\n");
+ printf("extern void* malloc(size_t);\n");
+#if _lib_mallopt
+ printf("#undef mallopt\n");
+ printf("#define mallopt _ast_mallopt\n");
+#endif
+#if _lib_memalign
+ printf("#undef memalign\n");
+ printf("#define memalign _ast_memalign\n");
+ printf("extern void* memalign(size_t, size_t);\n");
+#endif
+#if _lib_mstats
+ printf("#undef mstats\n");
+ printf("#define mstats _ast_mstats\n");
+#endif
+#if _lib_pvalloc
+ printf("#undef pvalloc\n");
+ printf("#define pvalloc _ast_pvalloc\n");
+#endif
+ printf("#undef realloc\n");
+ printf("#define realloc _ast_realloc\n");
+ printf("extern void* realloc(void*, size_t);\n");
+ printf("#undef strdup\n");
+ printf("#define strdup _ast_strdup\n");
+ printf("extern char* strdup(const char*);\n");
+#if _lib_valloc
+ printf("#undef valloc\n");
+ printf("#define valloc _ast_valloc\n");
+ printf("extern void* valloc(size_t);\n");
+#endif
+#endif
+#endif
+
+ /*
+ * overriding <stdlib.h> strto*() is problematic to say the least
+ */
+
+#if _map_libc || _std_strtol
+#if !__CYGWIN__
+ printf("#undef strtol\n");
+ printf("#define strtol _ast_strtol\n");
+ printf("#undef strtoul\n");
+ printf("#define strtoul _ast_strtoul\n");
+#endif
+ printf("#undef strtoll\n");
+ printf("#define strtoll _ast_strtoll\n");
+ printf("#undef strtoull\n");
+ printf("#define strtoull _ast_strtoull\n");
+#endif
+#if _map_libc || _std_strtod
+ printf("#undef strtod\n");
+ printf("#define strtod _ast_strtod\n");
+#endif
+#if _map_libc || _std_strtold
+ printf("#undef strtold\n");
+ printf("#define strtold _ast_strtold\n");
+#endif
+#if !__CYGWIN__
+#if _npt_strtol || _map_libc || _std_strtol
+#if _npt_strtol && !_map_libc && !_std_strtol
+ printf("#ifndef _ISOC99_SOURCE\n");
+#endif
+ printf("extern long strtol(const char*, char**, int);\n");
+#if _npt_strtol && !_map_libc && !_std_strtol
+ printf("#endif\n");
+#endif
+#endif
+#if _npt_strtoul || _map_libc || _std_strtol
+#if _npt_strtoul && !_map_libc && !_std_strtol
+ printf("#ifndef _ISOC99_SOURCE\n");
+#endif
+ printf("extern unsigned long strtoul(const char*, char**, int);\n");
+#if _npt_strtoul && !_map_libc && !_std_strtol
+ printf("#endif\n");
+#endif
+#endif
+#endif
+#if _npt_strtod || _map_libc || _std_strtod
+#if _npt_strtod && !_map_libc && !_std_strtod
+ printf("#ifndef _ISOC99_SOURCE\n");
+#endif
+ printf("extern double strtod(const char*, char**);\n");
+#if _npt_strtod && !_map_libc && !_std_strtod
+ printf("#endif\n");
+#endif
+#endif
+ printf("#if !_UWIN\n");
+ printf("#undef extern\n");
+ printf("#endif\n");
+#if _npt_strtold || _map_libc || _std_strtold
+#if _npt_strtold && !_map_libc && !_std_strtold
+ printf("#ifndef _ISOC99_SOURCE\n");
+#endif
+ printf("extern _ast_fltmax_t strtold(const char*, char**);\n");
+#if _npt_strtold && !_map_libc && !_std_strtold
+ printf("#endif\n");
+#endif
+#endif
+ printf("#undef extern\n");
+#if _npt_strtoll || _map_libc || _std_strtol
+#if _npt_strtoll && !_map_libc && !_std_strtol
+ printf("#ifndef _ISOC99_SOURCE\n");
+#endif
+ printf("extern _ast_intmax_t strtoll(const char*, char**, int);\n");
+#if _npt_strtoll && !_map_libc && !_std_strtol
+ printf("#endif\n");
+#endif
+#endif
+#if _npt_strtoull || _map_libc || _std_strtol
+#if _npt_strtoull && !_map_libc && !_std_strtol
+ printf("#ifndef _ISOC99_SOURCE\n");
+#endif
+ printf("extern unsigned _ast_intmax_t strtoull(const char*, char**, int);\n");
+#if _npt_strtoull && !_map_libc && !_std_strtoul
+ printf("#endif\n");
+#endif
+#endif
+ printf("\n");
+ printf("#undef extern\n");
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/features/mmap b/usr/src/lib/libast/common/features/mmap
new file mode 100644
index 0000000000..41ac44e7ea
--- /dev/null
+++ b/usr/src/lib/libast/common/features/mmap
@@ -0,0 +1,342 @@
+ref -D_def_map_ast=1
+
+sys mman
+
+tst lib_mmap note{ standard mmap interface that works }end execute{
+ #include <unistd.h>
+ #include <fcntl.h>
+ #include <sys/types.h>
+ #include <sys/mman.h>
+ #include <sys/stat.h>
+ #include <sys/times.h>
+
+ #define MAPSIZE (64*1024)
+ #define BUFSIZE (8*1024)
+ #define WRITE (64)
+
+ #define Failed(file) (remove(file),1)
+
+ int
+ #if _STD_
+ main(int argc, char** argv)
+ #else
+ main(argc,argv)
+ int argc;
+ char** argv;
+ #endif
+ {
+ caddr_t mm;
+ char *t, *u, *f;
+ int i, fd, okfixed;
+ char file[1024], buf[MAPSIZE];
+ struct tms stm, etm;
+ clock_t rdtm, mmtm;
+
+ /* create data file in a local fs if possible */
+ t = file;
+ if (access(f = "/tmp", 0) == 0 ||
+ access(f = "/usr/tmp", 0) == 0)
+ {
+ while (*t = *f++)
+ t++;
+ *t++ = '/';
+ }
+ u = t;
+ f = argv[0];
+ while (*t = *f++)
+ if (*t == '/')
+ t = u;
+ else if (*t != '.')
+ t++;
+ *t++ = '.'; *t++ = 'D'; *t = 0;
+ if ((fd = open(file, O_CREAT|O_TRUNC|O_WRONLY, 0666)) < 0)
+ return 1;
+
+ for (i = 0; i < sizeof(buf); ++i)
+ buf[i] = '0' + (i%10);
+ for (i = 0; i < WRITE; ++i)
+ if (write(fd,buf,sizeof(buf)) != sizeof(buf))
+ return Failed(file);
+ close(fd);
+
+ /* see if can overwrite fixed map */
+ #ifndef MAP_VARIABLE
+ #define MAP_VARIABLE 0
+ #endif
+ if ((fd = open(file, O_RDWR)) < 0)
+ return Failed(file);
+
+ mm = mmap((caddr_t)0, sizeof(buf), (PROT_READ|PROT_WRITE),
+ (MAP_PRIVATE|MAP_VARIABLE), fd, 0);
+ if(mm == (caddr_t)0 || mm == (caddr_t)(-1))
+ return Failed(file);
+ mm = mmap(mm, sizeof(buf), (PROT_READ|PROT_WRITE),
+ (MAP_PRIVATE|MAP_FIXED), fd, 0);
+ okfixed = (mm == (caddr_t)0 || mm == (caddr_t)(-1)) ? 0 : 1;
+ munmap(mm, sizeof(buf));
+ close(fd);
+
+ /* read time */
+ if((fd = open(file, O_RDWR)) < 0)
+ return Failed(file);
+ times(&stm);
+ for (i = 0; i < WRITE; ++i)
+ if (read(fd,buf,BUFSIZE) != BUFSIZE)
+ return Failed(file);
+ times(&etm);
+ close(fd);
+ rdtm = (etm.tms_utime-stm.tms_utime) + (etm.tms_stime-stm.tms_stime);
+
+ /* mmap time */
+ if ((fd = open(file, O_RDWR)) < 0)
+ return Failed(file);
+ times(&stm);
+ for(i = 0, mm = (caddr_t)0; i < WRITE; ++i)
+ { if(okfixed)
+ { mm = (caddr_t)mmap(mm, MAPSIZE,
+ (PROT_READ|PROT_WRITE),
+ (MAP_PRIVATE | (mm ? MAP_FIXED : MAP_VARIABLE)),
+ fd, i*MAPSIZE );
+ }
+ else
+ { if(mm)
+ munmap(mm, MAPSIZE);
+ mm = (caddr_t)mmap((caddr_t)0, MAPSIZE,
+ (PROT_READ|PROT_WRITE),
+ (MAP_PRIVATE|MAP_VARIABLE),
+ fd, i*MAPSIZE );
+ }
+ if(mm == (caddr_t)(-1) || mm == (caddr_t)0)
+ return Failed(file);
+ }
+ times(&etm);
+ close(fd);
+ remove(file);
+ mmtm = (etm.tms_utime-stm.tms_utime) + (etm.tms_stime-stm.tms_stime);
+
+ return rdtm+60 < mmtm ? 1 : 0;
+ }
+}end
+
+tst lib_mmap64 -D_LARGEFILE64_SOURCE note{ mmap64 interface and implementation work }end execute{
+ #if !_lib_mmap
+ (
+ #endif
+
+ #include <unistd.h>
+ #include <fcntl.h>
+ #include <sys/types.h>
+ #include <sys/mman.h>
+ #include <sys/stat.h>
+
+ int
+ main()
+ {
+ off64_t off;
+ int fd;
+ int n;
+ char* s;
+ struct stat64 st;
+ char file[32] = {'/','t','m','p','/','m','m','X','X','X','X','X','X'};
+
+ /* hey, stubs are supposed to fail! */
+ if (stat64(".", &st) || !st.st_mode || !st.st_mtime)
+ return 1;
+ if (!mktemp(file) || (fd = open64(file, O_CREAT|O_WRONLY, 0600)) < 0)
+ {
+ remove(file);
+ return 1;
+ }
+ off = (1<<8);
+ off *= off;
+ if (lseek64(fd, off, SEEK_SET) != off)
+ {
+ remove(file);
+ return 1;
+ }
+ n = strlen(file) + 1;
+ if (write(fd, file, n) != n)
+ {
+ remove(file);
+ return 1;
+ }
+ if (close(fd) < 0 || (fd = open64(file, O_RDWR)) < 0)
+ {
+ remove(file);
+ return 1;
+ }
+ if (!(s = mmap64((caddr_t)0, (size_t)n, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, off)))
+ {
+ remove(file);
+ return 1;
+ }
+ if (strcmp(s, file))
+ {
+ remove(file);
+ return 1;
+ }
+ close(fd);
+ remove(file);
+ return 0;
+ }
+}end
+
+tst mmap_anon note{ use mmap MAP_ANON to get raw memory }end execute{
+ #if !_lib_mmap
+ (
+ #endif
+ #include <unistd.h>
+ #include <fcntl.h>
+ #include <sys/types.h>
+ #include <sys/mman.h>
+ #if defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
+ #define MAP_ANON MAP_ANONYMOUS
+ #endif
+ int
+ main()
+ { void *addr;
+ addr = mmap(0,1024*1024,PROT_READ|PROT_WRITE,MAP_ANON|MAP_PRIVATE,-1,0);
+ return (addr && addr != (void*)(-1)) ? 0 : 1;
+ }
+}end
+
+tst mmap_devzero note{ use mmap on /dev/zero to get raw memory }end execute{
+ #if !_lib_mmap
+ (
+ #endif
+ #include <unistd.h>
+ #include <fcntl.h>
+ #include <sys/types.h>
+ #include <sys/mman.h>
+ int
+ main()
+ { int fd;
+ void *addr;
+ if((fd = open("/dev/zero", O_RDWR)) < 0)
+ return 1;
+ addr = mmap(0,1024*1024,PROT_READ|PROT_WRITE,MAP_PRIVATE,fd,0);
+ return (addr && addr != (void*)(-1)) ? 0 : 1;
+ }
+}end
+
+tst note{ mmap is worth using }end output{
+ #if !_lib_mmap
+ (
+ #endif
+ #include <unistd.h>
+ #include <fcntl.h>
+ #include <sys/types.h>
+ #include <sys/mman.h>
+ #include <sys/stat.h>
+ #include <sys/times.h>
+
+ #define MAPSIZE (64*1024)
+ #define BUFSIZE (MAPSIZE/8)
+ #define WRITE (64)
+ #define RUN (64)
+
+ #define Failed(file) (remove(file),1)
+
+ int
+ #if _STD_
+ main(int argc, char** argv)
+ #else
+ main(argc,argv)
+ int argc;
+ char** argv;
+ #endif
+ {
+ caddr_t mm;
+ char *t, *f;
+ int i, fd, k, run;
+ char file[1024], buf[MAPSIZE];
+ struct tms stm, etm;
+ clock_t rdtm, mmtm;
+
+ /* create data file */
+ f = argv[0]; t = file;
+ while (*t = *f++)
+ t++;
+ *t++ = '.'; *t++ = 'D'; *t = 0;
+ if ((fd = open(file, O_CREAT|O_TRUNC|O_WRONLY, 0666)) < 0)
+ return 1;
+
+ for (i = 0; i < sizeof(buf); ++i)
+ buf[i] = '0' + (i%10);
+ for (i = 0; i < WRITE; ++i)
+ if (write(fd,buf,sizeof(buf)) != sizeof(buf))
+ return Failed(file);
+ close(fd);
+
+ /* read time */
+ times(&stm);
+ for(run = 0; run < RUN; ++run)
+ { if((fd = open(file, O_RDWR)) < 0)
+ return Failed(file);
+ for (i = 0; i < WRITE; ++i)
+ { for(k = 0; k < MAPSIZE; k += BUFSIZE)
+ if (read(fd,buf,BUFSIZE) != BUFSIZE)
+ return Failed(file);
+ }
+ close(fd);
+ }
+ times(&etm);
+ rdtm = (etm.tms_utime-stm.tms_utime) + (etm.tms_stime-stm.tms_stime);
+
+ /* mmap time */
+ times(&stm);
+ for(run = 0; run < RUN; ++run)
+ { if ((fd = open(file, O_RDWR)) < 0)
+ return Failed(file);
+ for(i = 0, mm = (caddr_t)0; i < WRITE; ++i)
+ { if(mm)
+ munmap(mm, MAPSIZE);
+ mm = (caddr_t)mmap((caddr_t)0, MAPSIZE,
+ (PROT_READ|PROT_WRITE),
+ MAP_PRIVATE, fd, i*MAPSIZE );
+ if(mm == (caddr_t)(-1) || mm == (caddr_t)0)
+ return Failed(file);
+
+ /* the memcpy is < BUFSIZE to simulate the
+ fact that functions like sfreserve/sfgetr do
+ not do buffer copying.
+ */
+ t = (char*)mm;
+ for(k = 0; k < MAPSIZE; k += BUFSIZE, t += BUFSIZE)
+ memcpy(buf,t,(3*BUFSIZE)/4);
+ }
+ close(fd);
+ }
+ times(&etm);
+ mmtm = (etm.tms_utime-stm.tms_utime) + (etm.tms_stime-stm.tms_stime);
+
+ remove(file);
+
+ if(4*mmtm <= 3*rdtm)
+ printf("#define _mmap_worthy 2 /* mmap is great */\n");
+ else if(4*mmtm <= 5*rdtm)
+ printf("#define _mmap_worthy 1 /* mmap is good */\n");
+
+ else
+ return 1;
+ return 0;
+ }
+}end
+
+cat{
+
+ /* some systems get it wrong but escape concise detection */
+ #ifndef _NO_MMAP
+ #if __CYGWIN__
+ #define _NO_MMAP 1
+ #endif
+ #endif
+
+ #if _NO_MMAP
+ #undef _lib_mmap
+ #undef _lib_mmap64
+ #undef _mmap_anon
+ #undef _mmap_devzero
+ #undef _mmap_worthy
+ #endif
+}end
diff --git a/usr/src/lib/libast/common/features/mode.c b/usr/src/lib/libast/common/features/mode.c
new file mode 100644
index 0000000000..c2b33b6951
--- /dev/null
+++ b/usr/src/lib/libast/common/features/mode.c
@@ -0,0 +1,218 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * generate mode features
+ */
+
+#include "limits.h"
+
+#include "FEATURE/param"
+
+#include <modecanon.h>
+
+int
+main()
+{
+ int n;
+ int idperm;
+ int idtype;
+
+ idperm = idtype = 1;
+#ifndef S_ITYPE
+#ifdef S_IFMT
+ printf("#define S_ITYPE(m) ((m)&S_IFMT)\n");
+#else
+ printf("#define S_ITYPE(m) ((m)&~S_IPERM)\n");
+#endif
+#endif
+#ifdef S_ISBLK
+ if (!S_ISBLK(X_IFBLK)) idtype = 0;
+#else
+#ifdef S_IFBLK
+ printf("#define S_ISBLK(m) (S_ITYPE(m)==S_IFBLK)\n");
+#else
+ printf("#define S_ISBLK(m) 0\n");
+#endif
+#endif
+#ifdef S_ISCHR
+ if (!S_ISCHR(X_IFCHR)) idtype = 0;
+#else
+#ifdef S_IFCHR
+ printf("#define S_ISCHR(m) (S_ITYPE(m)==S_IFCHR)\n");
+#else
+ printf("#define S_ISCHR(m) 0\n");
+#endif
+#endif
+#ifdef S_ISCTG
+ if (!S_ISCTG(X_IFCTG)) idtype = 0;
+#else
+#ifdef S_IFCTG
+ printf("#define S_ISCTG(m) (S_ITYPE(m)==S_IFCTG)\n");
+#endif
+#endif
+#ifdef S_ISDIR
+ if (!S_ISDIR(X_IFDIR)) idtype = 0;
+#else
+#ifdef S_IFDIR
+ printf("#define S_ISDIR(m) (S_ITYPE(m)==S_IFDIR)\n");
+#else
+ printf("#define S_ISDIR(m) 0\n");
+#endif
+#endif
+#ifdef S_ISFIFO
+ if (!S_ISFIFO(X_IFIFO)) idtype = 0;
+#else
+#ifdef S_IFIFO
+ printf("#define S_ISFIFO(m) (S_ITYPE(m)==S_IFIFO)\n");
+#else
+ printf("#define S_ISFIFO(m) 0\n");
+#endif
+#endif
+#ifdef S_ISLNK
+ if (!S_ISLNK(X_IFLNK)) idtype = 0;
+#else
+#ifdef S_IFLNK
+ printf("#define S_ISLNK(m) (S_ITYPE(m)==S_IFLNK)\n");
+#else
+ printf("#define S_ISLNK(m) 0\n");
+#endif
+#endif
+#ifdef S_ISREG
+ if (!S_ISREG(X_IFREG)) idtype = 0;
+#else
+#ifdef S_IFREG
+ printf("#define S_ISREG(m) (S_ITYPE(m)==S_IFREG)\n");
+#else
+ printf("#define S_ISREG(m) 0\n");
+#endif
+#endif
+#ifdef S_ISSOCK
+ if (!S_ISSOCK(X_IFSOCK)) idtype = 0;
+#else
+#ifdef S_IFSOCK
+ printf("#define S_ISSOCK(m) (S_ITYPE(m)==S_IFSOCK)\n");
+#endif
+#endif
+ printf("\n");
+#ifndef S_IPERM
+ printf("#define S_IPERM (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)\n");
+#endif
+#ifndef S_ISUID
+ printf("#define S_ISUID 0%04o\n", X_ISUID);
+#else
+ if (S_ISUID != X_ISUID) idperm = 0;
+#endif
+#ifndef S_ISGID
+ printf("#define S_ISGID 0%04o\n", X_ISGID);
+#else
+ if (S_ISGID != X_ISGID) idperm = 0;
+#endif
+#ifndef S_ISVTX
+ printf("#define S_ISVTX 0%04o\n", X_ISVTX);
+#else
+ if (S_ISVTX != X_ISVTX) idperm = 0;
+#endif
+#ifndef S_IRUSR
+ printf("#define S_IRUSR 0%04o\n", X_IRUSR);
+#else
+ if (S_IRUSR != X_IRUSR) idperm = 0;
+#endif
+#ifndef S_IWUSR
+ printf("#define S_IWUSR 0%04o\n", X_IWUSR);
+#else
+ if (S_IWUSR != X_IWUSR) idperm = 0;
+#endif
+#ifndef S_IXUSR
+ printf("#define S_IXUSR 0%04o\n", X_IXUSR);
+#else
+ if (S_IXUSR != X_IXUSR) idperm = 0;
+#endif
+#ifndef S_IRGRP
+ printf("#define S_IRGRP 0%04o\n", X_IRGRP);
+#else
+ if (S_IRGRP != X_IRGRP) idperm = 0;
+#endif
+#ifndef S_IWGRP
+ printf("#define S_IWGRP 0%04o\n", X_IWGRP);
+#else
+ if (S_IWGRP != X_IWGRP) idperm = 0;
+#endif
+#ifndef S_IXGRP
+ printf("#define S_IXGRP 0%04o\n", X_IXGRP);
+#else
+ if (S_IXGRP != X_IXGRP) idperm = 0;
+#endif
+#ifndef S_IROTH
+ printf("#define S_IROTH 0%04o\n", X_IROTH);
+#else
+ if (S_IROTH != X_IROTH) idperm = 0;
+#endif
+#ifndef S_IWOTH
+ printf("#define S_IWOTH 0%04o\n", X_IWOTH);
+#else
+ if (S_IWOTH != X_IWOTH) idperm = 0;
+#endif
+#ifndef S_IXOTH
+ printf("#define S_IXOTH 0%04o\n", X_IXOTH);
+#else
+ if (S_IXOTH != X_IXOTH) idperm = 0;
+#endif
+#ifndef S_IRWXU
+ printf("#define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)\n");
+#endif
+#ifndef S_IRWXG
+ printf("#define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)\n");
+#endif
+#ifndef S_IRWXO
+ printf("#define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)\n");
+#endif
+ printf("\n");
+ if (idperm) printf("#define _S_IDPERM 1\n");
+ if (idtype) printf("#define _S_IDTYPE 1\n");
+ printf("\n");
+#ifdef BUFFERSIZE
+ n = BUFFERSIZE;
+#else
+#ifdef MAXBSIZE
+ n = MAXBSIZE;
+#else
+#ifdef SBUFSIZE
+ n = SBUFSIZE;
+#else
+#ifdef BUFSIZ
+ n = BUFSIZ;
+#else
+ if (sizeof(char*) > 4) n = 8192;
+ else if (sizeof(char*) < 4) n = 512;
+ else n = 4096;
+#endif
+#endif
+#endif
+#endif
+ printf("#define BUFFERSIZE %u\n", n);
+ printf("\n");
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/features/nl_types b/usr/src/lib/libast/common/features/nl_types
new file mode 100644
index 0000000000..02cae3e695
--- /dev/null
+++ b/usr/src/lib/libast/common/features/nl_types
@@ -0,0 +1,64 @@
+set prototyped
+lib catopen,nl_langinfo
+hdr nl_types,langinfo
+nxt nl_types
+
+tst output{
+ #if !_lib_catopen
+ #undef _hdr_nl_types
+ #endif
+ #include "FEATURE/limits"
+ #if _hdr_nl_types
+ #include <nl_types.h>
+ #endif
+
+ int
+ main()
+ {
+ printf("#include <limits.h>\n");
+ #if _hdr_nl_types && defined(_nxt_nl_types_str)
+ printf("#include <%s> /* the native nl_types.h */\n", _nxt_nl_types_str);
+ #endif
+ printf("\n");
+ #ifndef NL_SETMAX
+ printf("#undef NL_SETMAX\n");
+ printf("#define NL_SETMAX 1023\n");
+ #endif
+ #ifndef NL_MSGMAX
+ printf("#undef NL_MSGMAX\n");
+ printf("#define NL_MSGMAX 32767\n");
+ #endif
+ #ifndef NL_SETD
+ printf("#undef NL_SETD\n");
+ printf("#define NL_SETD 1\n");
+ #endif
+ #ifndef NL_CAT_LOCALE
+ printf("#undef NL_CAT_LOCALE\n");
+ printf("#define NL_CAT_LOCALE 1\n");
+ #endif
+ #if _lib_catopen
+ printf("#undef nl_catd\n");
+ printf("#define nl_catd _ast_nl_catd\n");
+ printf("#undef catopen\n");
+ printf("#define catopen _ast_catopen\n");
+ printf("#undef catgets\n");
+ printf("#define catgets _ast_catgets\n");
+ printf("#undef catclose\n");
+ printf("#define catclose _ast_catclose\n");
+ #endif
+ printf("\n");
+ printf("typedef void* nl_catd;\n");
+ printf("\n");
+ printf("#if _BLD_ast && defined(__EXPORT__)\n");
+ printf("#define extern __EXPORT__\n");
+ printf("#endif\n");
+ printf("\n");
+ printf("extern nl_catd catopen(const char*, int);\n");
+ printf("extern char* catgets(nl_catd, int, int, const char*);\n");
+ printf("extern int catclose(nl_catd);\n");
+ printf("\n");
+ printf("#undef extern\n");
+ printf("\n");
+ return 0;
+ }
+}end
diff --git a/usr/src/lib/libast/common/features/omitted b/usr/src/lib/libast/common/features/omitted
new file mode 100644
index 0000000000..1e4eca422e
--- /dev/null
+++ b/usr/src/lib/libast/common/features/omitted
@@ -0,0 +1,110 @@
+tst note{ check for win32 .exe botches }end output{
+ #include <unistd.h>
+ #include <fcntl.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ static int
+ cp(const char* from, const char* to)
+ {
+ ssize_t n;
+ int fd;
+ int td;
+ struct stat fs;
+ char buf[1024];
+
+ if ((fd = _open(from, O_RDONLY|O_BINARY)) < 0)
+ return -1;
+ if (_fstat(fd, &fs) || (td = _open(to, O_CREAT|O_WRONLY|O_TRUNC|O_BINARY, fs.st_mode & 0777)) < 0)
+ {
+ _close(fd);
+ return -1;
+ }
+ while ((n = _read(fd, buf, sizeof(buf))) > 0 && _write(td, buf, n) == n);
+ _close(fd);
+ _close(td);
+ return n ? -1 : 0;
+ }
+ int
+ main(int argc, char** argv)
+ {
+ int fd;
+ int fix;
+ struct stat st;
+ char buf[256];
+
+ snprintf(buf, sizeof(buf), "rm -rf /tmp/iff-%d", getpid());
+ if (_mkdir(buf+7, 0755))
+ return 1;
+ if (_chdir(buf+7))
+ return 1;
+ if (cp("/bin/cat.exe", "foo.exe"))
+ return 1;
+ fix = 0;
+ if (_access("foo", X_OK))
+ fix++,printf("#define _win32_botch_access 1\n");
+ if (_chmod("foo", 0755))
+ fix++,printf("#define _win32_botch_chmod 1\n");
+ if (cp("/bin/cat", "bam") || _access("bam.exe", X_OK))
+ fix++,printf("#define _win32_botch_copy 1\n");
+ if (_getpagesize() != 64 * 1024)
+ fix++,printf("#define _win32_botch_getpagesize 1\n");
+ #if !__EMX__
+ if (_link("foo", "bar") || _access("bar.exe", X_OK))
+ fix++,printf("#define _win32_botch_link 1\n");
+ else
+ #endif
+ cp("foo.exe", "bar.exe");
+ if ((fd = _open("foo", O_RDONLY)) < 0)
+ fix++,printf("#define _win32_botch_open 1\n");
+ else
+ _close(fd);
+ if (_pathconf("huh", _PC_NAME_MAX) >= 0)
+ fix++,printf("#define _win32_botch_pathconf 1\n");
+ if (_rename("foo", "aha") || _access("aha.exe", X_OK))
+ fix++,printf("#define _win32_botch_rename 1\n");
+ else
+ _rename("foo.exe", "aha.exe");
+ if (_stat("bar", &st))
+ {
+ fix++,printf("#define _win32_botch_stat 1\n");
+ if (sizeof(st.st_ino) == 8)
+ printf("#define _stat _stat64\n");
+ }
+ if (_truncate("aha", 0))
+ fix++,printf("#define _win32_botch_truncate 1\n");
+ if (_unlink("bar"))
+ fix++,printf("#define _win32_botch_unlink 1\n");
+ if (_utime("aha", 0))
+ fix++,printf("#define _win32_botch_utime 1\n");
+ if (fix)
+ {
+ printf("#define _win32_botch_execve 1\n");
+ printf("#define _win32_botch 1\n");
+ }
+ _chdir("/tmp");
+ system(buf);
+ return 0;
+ }
+}end
+
+tst win32_botch_alarm note{ win32 alarm(2) return botched }end noexecute{
+ #include <signal.h>
+ #include <unistd.h>
+ #include <time.h>
+
+ static int sigalrm = 0;
+
+ static void
+ handler(int sig)
+ {
+ sigalrm++;
+ }
+ int
+ main(int argc, char** argv)
+ {
+ signal(SIGALRM, handler);
+ alarm(2);
+ pause();
+ return sigalrm != 1 || alarm(0) != 0;
+ }
+}end
diff --git a/usr/src/lib/libast/common/features/param.sh b/usr/src/lib/libast/common/features/param.sh
new file mode 100644
index 0000000000..ea162202a7
--- /dev/null
+++ b/usr/src/lib/libast/common/features/param.sh
@@ -0,0 +1,47 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1985-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# Glenn Fowler <gsf@research.att.com> #
+# David Korn <dgk@research.att.com> #
+# Phong Vo <kpv@research.att.com> #
+# #
+########################################################################
+: generate "<sys/param.h> + <sys/types.h> + <sys/stat.h>" include sequence
+case $# in
+0) ;;
+*) eval $1
+ shift
+ ;;
+esac
+for i in "#include <sys/param.h>" "#include <sys/param.h>
+#ifndef S_IFDIR
+#include <sys/stat.h>
+#endif" "#include <sys/param.h>
+#ifndef S_IFDIR
+#include <sys/types.h>
+#include <sys/stat.h>
+#endif" "#ifndef S_IFDIR
+#include <sys/types.h>
+#include <sys/stat.h>
+#endif"
+do echo "$i
+struct stat V_stat_V;
+F_stat_F() { V_stat_V.st_mode = 0; }" > $tmp.c
+ if $cc -c $tmp.c >/dev/null
+ then echo "$i"
+ break
+ fi
+done
diff --git a/usr/src/lib/libast/common/features/preroot.sh b/usr/src/lib/libast/common/features/preroot.sh
new file mode 100644
index 0000000000..f997e2c93b
--- /dev/null
+++ b/usr/src/lib/libast/common/features/preroot.sh
@@ -0,0 +1,46 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1985-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# Glenn Fowler <gsf@research.att.com> #
+# David Korn <dgk@research.att.com> #
+# Phong Vo <kpv@research.att.com> #
+# #
+########################################################################
+: generate preroot features
+case $# in
+0) ;;
+*) eval $1
+ shift
+ ;;
+esac
+if /etc/preroot / /bin/echo >/dev/null
+then cat <<!
+#pragma prototyped
+
+#define FS_PREROOT 1 /* preroot enabled */
+#define PR_BASE "CCS" /* preroot base env var */
+#define PR_COMMAND "/etc/preroot" /* the preroot command */
+#define PR_REAL "/dev/.." /* real root pathname */
+#define PR_SILENT "CCSQUIET" /* no command trace */
+
+extern char* getpreroot(char*, const char*);
+extern int ispreroot(const char*);
+extern int realopen(const char*, int, int);
+extern void setpreroot(char**, const char*);
+
+!
+else echo "/* preroot not enabled */"
+fi
diff --git a/usr/src/lib/libast/common/features/sfinit.c b/usr/src/lib/libast/common/features/sfinit.c
new file mode 100644
index 0000000000..f3feb5493b
--- /dev/null
+++ b/usr/src/lib/libast/common/features/sfinit.c
@@ -0,0 +1,94 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * generate sfio _Sftable static initializers
+ */
+
+#include "FEATURE/common"
+#include "FEATURE/float"
+
+int
+main()
+{
+ register int i;
+#if _ast_fltmax_double
+ char* fs = "";
+ char* ds = "";
+ char* ls = "";
+#else
+ char* fs = "F";
+ char* ds = "";
+ char* ls = "L";
+#endif
+
+ printf("\nstatic const float sf_flt_pow10[] =\n{\n");
+ for (i = 0; i <= FLT_MAX_10_EXP; i++)
+ printf("\t1E%d%s,\n", i, fs);
+ printf("};\n");
+ printf("\nstatic const double sf_dbl_pow10[] =\n{\n");
+ for (i = 0; i <= DBL_MAX_10_EXP; i++)
+ printf("\t1E%d%s,\n", i, ds);
+ printf("};\n");
+#if !_ast_fltmax_double
+ printf("\nstatic const _ast_fltmax_t sf_ldbl_pow10[] =\n{\n");
+ for (i = 0; i <= LDBL_MAX_10_EXP; i++)
+ printf("\t1E%d%s,\n", i, ls);
+ printf("};\n");
+#endif
+ printf("\nSftab_t _Sftable =\n{\n");
+ printf("\t{ 1E1%s, 1E2%s, 1E4%s, 1E8%s, 1E16%s, 1E32%s },\n", ls, ls, ls, ls, ls, ls);
+ printf("\t{ 1E-1%s, 1E-2%s, 1E-4%s, 1E-8%s, 1E-16%s, 1E-32%s },\n", ls, ls, ls, ls, ls, ls);
+ printf("\t{ '0','0', '0','1', '0','2', '0','3', '0','4',\n");
+ printf("\t '0','5', '0','6', '0','7', '0','8', '0','9',\n");
+ printf("\t '1','0', '1','1', '1','2', '1','3', '1','4',\n");
+ printf("\t '1','5', '1','6', '1','7', '1','8', '1','9',\n");
+ printf("\t '2','0', '2','1', '2','2', '2','3', '2','4',\n");
+ printf("\t '2','5', '2','6', '2','7', '2','8', '2','9',\n");
+ printf("\t '3','0', '3','1', '3','2', '3','3', '3','4',\n");
+ printf("\t '3','5', '3','6', '3','7', '3','8', '3','9',\n");
+ printf("\t '4','0', '4','1', '4','2', '4','3', '4','4',\n");
+ printf("\t '4','5', '4','6', '4','7', '4','8', '4','9',\n");
+ printf("\t '5','0', '5','1', '5','2', '5','3', '5','4',\n");
+ printf("\t '5','5', '5','6', '5','7', '5','8', '5','9',\n");
+ printf("\t '6','0', '6','1', '6','2', '6','3', '6','4',\n");
+ printf("\t '6','5', '6','6', '6','7', '6','8', '6','9',\n");
+ printf("\t '7','0', '7','1', '7','2', '7','3', '7','4',\n");
+ printf("\t '7','5', '7','6', '7','7', '7','8', '7','9',\n");
+ printf("\t '8','0', '8','1', '8','2', '8','3', '8','4',\n");
+ printf("\t '8','5', '8','6', '8','7', '8','8', '8','9',\n");
+ printf("\t '9','0', '9','1', '9','2', '9','3', '9','4',\n");
+ printf("\t '9','5', '9','6', '9','7', '9','8', '9','9',\n");
+ printf("\t},\n");
+ printf("\t\"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@_\",\n");
+ printf("\tsfcvinit, 0,\n");
+ printf("\tsffmtpos,\n");
+ printf("\tsffmtint,\n");
+ printf("\t(float*)&sf_flt_pow10[0],\n");
+ printf("\t(double*)&sf_dbl_pow10[0],\n");
+#if _ast_fltmax_double
+ printf("\t0,\n");
+#else
+ printf("\t(_ast_fltmax_t*)&sf_ldbl_pow10[0],\n");
+#endif
+ printf("};\n");
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/features/sfio b/usr/src/lib/libast/common/features/sfio
new file mode 100644
index 0000000000..6129a16c41
--- /dev/null
+++ b/usr/src/lib/libast/common/features/sfio
@@ -0,0 +1,160 @@
+ref -D_def_map_ast=1
+hdr float,floatingpoint,math,values
+sys filio,ioctl
+lib qfrexp,qldexp
+key signed
+
+tst tmp_rmfail note{ open files cannot be removed }end execute{
+ #include <string.h>
+ #include <time.h>
+ int
+ main()
+ {
+ #if !_UWIN
+ int n;
+ char* s;
+ FILE* fr;
+ FILE* fw;
+ char file[16];
+ static char data[] = "0123456789";
+ s = file;
+ *s++ = '1';
+ *s++ = 'F';
+ *s++ = 'F';
+ *s++ = '3';
+ n = (int)time(0);
+ *s++ = (n & 0xF) + 'A';
+ *s++ = ((n >> 4) & 0xF) + 'A';
+ *s++ = ((n >> 8) & 0xF) + 'A';
+ *s++ = ((n >> 12) & 0xF) + 'A';
+ *s++ = '.';
+ *s++ = 'T';
+ *s++ = 'M';
+ *s++ = 'P';
+ *s = 0;
+ remove(file);
+ if (!(fw = fopen(file, "w")))
+ return 0;
+ if (!(fr = fopen(file, "r")))
+ {
+ fclose(fw);
+ remove(file);
+ return 0;
+ }
+ if (remove(file) < 0)
+ {
+ fclose(fr);
+ fclose(fw);
+ remove(file);
+ return 0;
+ }
+ if (fwrite(data, sizeof(data), 1, fw) != 1)
+ return 0;
+ fclose(fw);
+ if (fread(file, sizeof(data), 1, fr) != 1)
+ return 0;
+ fclose(fr);
+ if (strcmp(file, data) != 0)
+ return 0;
+ #endif
+ return 1;
+ }
+}end
+
+more void_int note{ voidptr is larger than int }end execute{
+ int
+ main()
+ {
+ return sizeof(char*) > sizeof(int) ? 0 : 1;
+ }
+}end
+
+more long_int note{ long is larger than int }end execute{
+ int
+ main()
+ {
+ return sizeof(long) > sizeof(int) ? 0 : 1;
+ }
+}end
+
+tst vax_asm note{ register layout ok for vax string operations }end execute{
+ int
+ main()
+ {
+ #ifndef vax
+ return absurd = -1;
+ #else
+ register int r11, r10, r9, r8, r7, r6;
+ r11 = r10 = r9 = r8 = r7 = r6 = -1;
+ asm("clrw r11");
+ asm("clrw r10");
+ asm("clrw r9");
+ asm("clrw r8");
+ asm("clrw r7");
+ asm("clrw r6");
+ if(sizeof(int) != sizeof(char*) || r11 || r10 || r9 || r8 || r7 || r6 )
+ return -1;
+ return 0;
+ #endif
+ }
+}end
+
+tst lib_cvt note{ native floating point conversions ok }end link{
+ _BEGIN_EXTERNS_
+ extern char* ecvt _ARG_((double, int, int*, int*));
+ extern char* fcvt _ARG_((double, int, int*, int*));
+ extern double strtod _ARG_((const char*, char**));
+ _END_EXTERNS_
+ int
+ main()
+ {
+ ecvt(0.0, 0, 0, 0);
+ fcvt(0.0, 0, 0, 0);
+ strtod(0, 0);
+ return 0;
+ }
+}end
+
+tst xopen_stdio note{ Stdio fseek/fflush are X/Open-compliant }end execute{
+ #define Failed(file) (unlink(file),1)
+ int
+ main(argc, argv)
+ int argc;
+ char** argv;
+ { FILE *f1, *f2;
+ char file[1024], buf[1024], *f, *t;
+ int i, fd;
+
+ /* create file */
+ for(f = argv[0], t = file; (*t = *f++) != 0; )
+ t++;
+ *t++ = '.'; *t++ = 'D'; *t++ = 0;
+ if((fd = creat(file,0666)) < 0)
+ return 1;
+
+ for (i = 0; i < sizeof(buf); ++i)
+ buf[i] = '0' + (i%10);
+ for (i = 0; i < 16; ++i)
+ if (write(fd,buf,sizeof(buf)) != sizeof(buf))
+ return Failed(file);
+ close(fd);
+
+ if(!(f1 = fopen(file,"r+")) ||
+ (fd = dup(fileno(f1))) < 0 ||
+ !(f2 = fdopen(fd,"r+")) )
+ return Failed(file);
+
+ if(fread(buf, 1, 7, f2) != 7 || ftell(f2) != 7)
+ return Failed(file);
+
+ if(fseek(f1, 1010, 0) < 0 || ftell(f1) != 1010)
+ return Failed(file);
+
+ fflush(f2); /* this should set the seek location to 1010 */
+ if(ftell(f2) != 1010)
+ return Failed(file);
+
+ unlink(file);
+ return 0;
+ }
+}end
diff --git a/usr/src/lib/libast/common/features/sig.sh b/usr/src/lib/libast/common/features/sig.sh
new file mode 100644
index 0000000000..d52aaa947d
--- /dev/null
+++ b/usr/src/lib/libast/common/features/sig.sh
@@ -0,0 +1,125 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1985-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# Glenn Fowler <gsf@research.att.com> #
+# David Korn <dgk@research.att.com> #
+# Phong Vo <kpv@research.att.com> #
+# #
+########################################################################
+: generate sig features
+case $# in
+0) ;;
+*) eval $1
+ shift
+ ;;
+esac
+echo "#include <signal.h>
+int xxx;" > $tmp.c
+$cc -c $tmp.c >/dev/null 2>$tmp.e
+echo "#pragma prototyped
+#define sig_info _sig_info_
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide kill killpg
+#else
+#define kill ______kill
+#define killpg ______killpg
+#endif
+#include <signal.h>
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide kill killpg
+#else
+#undef kill
+#undef killpg
+#endif
+#ifndef sigmask
+#define sigmask(s) (1<<((s)-1))
+#endif"
+echo "#include <signal.h>
+#ifdef TYPE
+#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
+typedef TYPE (*Sig_handler_t)(ARG);
+#else
+typedef TYPE (*Sig_handler_t)();
+#endif
+#endif
+Sig_handler_t f()
+{
+ Sig_handler_t handler;
+ handler = signal(1, SIG_IGN);
+ return(handler);
+}" > $tmp.c
+if $cc -c $tmp.c >/dev/null
+then :
+else e=`wc -l $tmp.e`
+ i1= j1=
+ for i in void int
+ do for j in int,... ... int
+ do $cc -c -DTYPE=$i -DARG=$j $tmp.c >/dev/null 2>$tmp.e || continue
+ case `wc -l $tmp.e` in
+ $e) i1= j1=; break 2 ;;
+ esac
+ case $i1 in
+ "") i1=$i j1=$j ;;
+ esac
+ done
+ done
+ case $i1 in
+ ?*) i=$i1 j=$j1 ;;
+ esac
+ echo "typedef $i (*Sig_handler_t)($j);"
+fi
+echo '
+
+#define Handler_t Sig_handler_t
+
+#define SIG_REG_PENDING (-1)
+#define SIG_REG_POP 0
+#define SIG_REG_EXEC 00001
+#define SIG_REG_PROC 00002
+#define SIG_REG_TERM 00004
+#define SIG_REG_ALL 00777
+#define SIG_REG_SET 01000
+
+typedef struct
+{
+ char** name;
+ char** text;
+ int sigmax;
+} Sig_info_t;
+
+extern int kill(pid_t, int);
+extern int killpg(pid_t, int);
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#define extern extern __IMPORT__
+#endif
+
+extern Sig_info_t sig_info;
+
+#undef extern
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int sigcritical(int);
+extern int sigunblock(int);
+
+#undef extern'
diff --git a/usr/src/lib/libast/common/features/signal.c b/usr/src/lib/libast/common/features/signal.c
new file mode 100644
index 0000000000..60f60d2ee6
--- /dev/null
+++ b/usr/src/lib/libast/common/features/signal.c
@@ -0,0 +1,278 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * generate signal features
+ */
+
+#include <signal.h>
+
+struct _m_
+{
+ char* text;
+ char* name;
+ int value;
+};
+
+#define elementsof(x) (sizeof(x)/sizeof(x[0]))
+
+static struct _m_ map[] =
+{
+#ifdef SIGABRT
+"Abort", "ABRT", SIGABRT,
+#endif
+#ifdef SIGAIO
+"Asynchronous I/O", "AIO", SIGAIO,
+#endif
+#ifdef SIGALRM
+"Alarm call", "ALRM", SIGALRM,
+#endif
+#ifdef SIGAPOLLO
+"Apollo", "APOLLO", SIGAPOLLO,
+#endif
+#ifdef SIGBUS
+"Bus error", "BUS", SIGBUS,
+#endif
+#ifdef SIGCHLD
+"Child status change", "CHLD", SIGCHLD,
+#endif
+#ifdef SIGCLD
+"Death of child", "CLD", SIGCLD,
+#endif
+#ifdef SIGCONT
+"Stopped process continued", "CONT", SIGCONT,
+#endif
+#ifdef SIGDANGER
+"System crash soon", "DANGER", SIGDANGER,
+#endif
+#ifdef SIGDEBUG
+"Debug trap", "DEBUG", SIGDEBUG,
+#endif
+#ifdef SIGDIL
+"DIL trap", "DIL", SIGDIL,
+#endif
+#ifdef SIGEMT
+"EMT trap", "EMT", SIGEMT,
+#endif
+#ifdef SIGERR
+"ERR trap", "ERR", SIGERR,
+#endif
+#ifdef SIGEXIT
+"Exit", "EXIT", SIGEXIT,
+#endif
+#ifdef SIGFPE
+"Floating exception", "FPE", SIGFPE,
+#endif
+#ifdef SIGFREEZE
+"CPR freeze", "FREEZE", SIGFREEZE,
+#endif
+#ifdef SIGHUP
+"Hangup", "HUP", SIGHUP,
+#endif
+#ifdef SIGILL
+"Illegal instruction", "ILL", SIGILL,
+#endif
+#ifdef SIGINT
+"Interrupt", "INT", SIGINT,
+#endif
+#ifdef SIGIO
+"IO possible", "IO", SIGIO,
+#endif
+#ifdef SIGIOT
+"IOT trap", "IOT", SIGIOT,
+#endif
+#ifdef SIGKILL
+"Killed", "KILL", SIGKILL,
+#endif
+#ifdef SIGLAB
+"Security label changed", "LAB", SIGLAB,
+#endif
+#ifdef SIGLOST
+"Resources lost", "LOST", SIGLOST,
+#endif
+#ifdef SIGLWP
+"Thread event", "LWP", SIGLWP,
+#endif
+#ifdef SIGMIGRATE
+"Migrate process", "MIGRATE", SIGMIGRATE,
+#endif
+#ifdef SIGPHONE
+"Phone status change", "PHONE", SIGPHONE,
+#endif
+#ifdef SIGPIPE
+"Broken pipe", "PIPE", SIGPIPE,
+#endif
+#ifdef SIGPOLL
+"Poll event", "POLL", SIGPOLL,
+#endif
+#ifdef SIGPROF
+"Profile timer alarm", "PROF", SIGPROF,
+#endif
+#ifdef SIGPWR
+"Power fail", "PWR", SIGPWR,
+#endif
+#ifdef SIGQUIT
+"Quit", "QUIT", SIGQUIT,
+#endif
+#ifdef SIGSEGV
+"Memory fault", "SEGV", SIGSEGV,
+#endif
+#ifdef SIGSOUND
+"Sound completed", "SOUND", SIGSOUND,
+#endif
+#ifdef SIGSSTOP
+"Sendable stop", "SSTOP", SIGSSTOP,
+#endif
+#ifdef gould
+"Stack overflow", "STKOV", 28,
+#endif
+#ifdef SIGSTOP
+"Stopped (signal)", "STOP", SIGSTOP,
+#endif
+#ifdef SIGSYS
+"Bad system call", "SYS", SIGSYS,
+#endif
+#ifdef SIGTERM
+"Terminated", "TERM", SIGTERM,
+#endif
+#ifdef SIGTHAW
+"CPR thaw", "THAW", SIGTHAW,
+#endif
+#ifdef SIGTINT
+"Interrupt (terminal)", "TINT", SIGTINT,
+#endif
+#ifdef SIGTRAP
+"Trace trap", "TRAP", SIGTRAP,
+#endif
+#ifdef SIGTSTP
+"Stopped", "TSTP", SIGTSTP,
+#endif
+#ifdef SIGTTIN
+"Stopped (tty input)", "TTIN", SIGTTIN,
+#endif
+#ifdef SIGTTOU
+"Stopped (tty output)", "TTOU", SIGTTOU,
+#endif
+#ifdef SIGURG
+"Urgent IO", "URG", SIGURG,
+#endif
+#ifdef SIGUSR1
+"User signal 1", "USR1", SIGUSR1,
+#endif
+#ifdef SIGUSR2
+"User signal 2", "USR2", SIGUSR2,
+#endif
+#ifdef SIGVTALRM
+"Virtual timer alarm", "VTALRM", SIGVTALRM,
+#endif
+#ifdef SIGWAITING
+"All threads blocked", "WAITING", SIGWAITING,
+#endif
+#ifdef SIGWINCH
+"Window change", "WINCH", SIGWINCH,
+#endif
+#ifdef SIGWIND
+"Window change", "WIND", SIGWIND,
+#endif
+#ifdef SIGWINDOW
+"Window change", "WINDOW", SIGWINDOW,
+#endif
+#ifdef SIGXCPU
+"CPU time limit", "XCPU", SIGXCPU,
+#endif
+#ifdef SIGXFSZ
+"File size limit", "XFSZ", SIGXFSZ,
+#endif
+0
+};
+
+#define RANGE_MIN (1<<14)
+#define RANGE_MAX (1<<13)
+#define RANGE_RT (1<<12)
+
+#define RANGE_SIG (~(RANGE_MIN|RANGE_MAX|RANGE_RT))
+
+static int index[64];
+
+int
+main()
+{
+ register int i;
+ register int j;
+ register int k;
+ int n;
+
+ k = 0;
+ for (i = 0; map[i].name; i++)
+ if ((j = map[i].value) > 0 && j < elementsof(index) && !index[j])
+ {
+ if (j > k) k = j;
+ index[j] = i;
+ }
+#ifdef SIGRTMIN
+ i = SIGRTMIN;
+#ifdef SIGRTMAX
+ j = SIGRTMAX;
+#else
+ j = i;
+#endif
+ if (j >= elementsof(index)) j = elementsof(index) - 1;
+ if (i <= j && i > 0 && i < elementsof(index) && j > 0 && j < elementsof(index))
+ {
+ if (j > k) k = j;
+ index[i] = RANGE_MIN | RANGE_RT;
+ n = 1;
+ while (++i < j)
+ index[i] = RANGE_RT | n++;
+ index[j] = RANGE_MAX | RANGE_RT | n;
+ }
+#endif
+ printf("#pragma prototyped\n");
+ printf("#define SIG_MAX %d\n", k);
+ printf("\n");
+ printf("static const char* const sig_name[] =\n");
+ printf("{\n");
+ for (i = 0; i <= k; i++)
+ if (!(j = index[i])) printf(" \"%d\",\n", i);
+ else if (j & RANGE_RT)
+ {
+ if (j & RANGE_MIN) printf(" \"RTMIN\",\n");
+ else if (j & RANGE_MAX) printf(" \"RTMAX\",\n");
+ else printf(" \"RT%d\",\n", j & RANGE_SIG);
+ }
+ else printf(" \"%s\",\n", map[j].name);
+ printf(" 0\n");
+ printf("};\n");
+ printf("\n");
+ printf("static const char* const sig_text[] =\n");
+ printf("{\n");
+ for (i = 0; i <= k; i++)
+ if (!(j = index[i])) printf(" \"Signal %d\",\n", i);
+ else if (j & RANGE_RT) printf(" \"Realtime priority %d%s\",\n", j & RANGE_SIG, (j & RANGE_MIN) ? " (lo)" : (j & RANGE_MAX) ? " (hi)" : "");
+ else printf(" \"%s\",\n", map[j].text);
+ printf(" 0\n");
+ printf("};\n");
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/features/standards b/usr/src/lib/libast/common/features/standards
new file mode 100644
index 0000000000..9250fae63e
--- /dev/null
+++ b/usr/src/lib/libast/common/features/standards
@@ -0,0 +1,121 @@
+if tst note{ _ALL_SOURCE & _ISOC99_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{
+ #define _ALL_SOURCE 1
+ #define _ISOC99_SOURCE 1
+ #define _POSIX_SOURCE 1
+ #define _POSIX_C_SOURCE 21000101L
+ #define _XOPEN_SOURCE 9900
+ #define _GNU_SOURCE 1
+ #define __EXTENSIONS__ 1
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+ }end {
+ #ifndef _ALL_SOURCE
+ #define _ALL_SOURCE 1
+ #endif
+ #ifndef _ISOC99_SOURCE
+ #define _ISOC99_SOURCE 1
+ #endif
+ #ifndef _POSIX_SOURCE
+ #define _POSIX_SOURCE 1
+ #endif
+ #ifndef _POSIX_C_SOURCE
+ #define _POSIX_C_SOURCE 21000101L
+ #endif
+ #ifndef _XOPEN_SOURCE
+ #define _XOPEN_SOURCE 9900
+ #endif
+ #ifndef _GNU_SOURCE
+ #define _GNU_SOURCE 1
+ #endif
+ #ifndef __EXTENSIONS__
+ #define __EXTENSIONS__ 1
+ #endif
+ }
+elif tst note{ _ISOC99_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{
+ #define _ISOC99_SOURCE 1
+ #define _POSIX_SOURCE 1
+ #define _POSIX_C_SOURCE 21000101L
+ #define _XOPEN_SOURCE 9900
+ #define _GNU_SOURCE 1
+ #define __EXTENSIONS__ 1
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+ }end {
+ #ifndef _ISOC99_SOURCE
+ #define _ISOC99_SOURCE 1
+ #endif
+ #ifndef _POSIX_SOURCE
+ #define _POSIX_SOURCE 1
+ #endif
+ #ifndef _POSIX_C_SOURCE
+ #define _POSIX_C_SOURCE 21000101L
+ #endif
+ #ifndef _XOPEN_SOURCE
+ #define _XOPEN_SOURCE 9900
+ #endif
+ #ifndef _GNU_SOURCE
+ #define _GNU_SOURCE 1
+ #endif
+ #ifndef __EXTENSIONS__
+ #define __EXTENSIONS__ 1
+ #endif
+ }
+elif tst note{ _POSIX_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{
+ #define _POSIX_SOURCE 1
+ #define _XOPEN_SOURCE 1
+ #define __EXTENSIONS__ 1
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+ }end {
+ #ifndef _POSIX_SOURCE
+ #define _POSIX_SOURCE 1
+ #endif
+ #ifndef _XOPEN_SOURCE
+ #define _XOPEN_SOURCE 1
+ #endif
+ #ifndef __EXTENSIONS__
+ #define __EXTENSIONS__ 1
+ #endif
+ }
+elif tst note{ _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{
+ #define _XOPEN_SOURCE 1
+ #define __EXTENSIONS__ 1
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+ }end {
+ #ifndef _XOPEN_SOURCE
+ #define _XOPEN_SOURCE 1
+ #endif
+ #ifndef __EXTENSIONS__
+ #define __EXTENSIONS__ 1
+ #endif
+ }
+elif tst note{ _XOPEN_SOURCE works }end compile{
+ #define _XOPEN_SOURCE 1
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+ }end {
+ #ifndef _XOPEN_SOURCE
+ #define _XOPEN_SOURCE 1
+ #endif
+ }
+else tst note{ __EXTENSIONS__ works }end compile{
+ #define __EXTENSIONS__ 1
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ }end {
+ #ifndef __EXTENSIONS__
+ #define __EXTENSIONS__ 1
+ #endif
+ }
+endif
diff --git a/usr/src/lib/libast/common/features/stdio b/usr/src/lib/libast/common/features/stdio
new file mode 100644
index 0000000000..9951d517b8
--- /dev/null
+++ b/usr/src/lib/libast/common/features/stdio
@@ -0,0 +1,559 @@
+set prototyped
+ref -D_def_map_ast=1
+iff SFSTDIO
+cat{
+ #define __FILE_typedef 1
+ #define _FILE_DEFINED 1
+ #define _FILE_defined 1
+ #define _FILEDEFED 1
+
+ #ifndef __FILE_TAG
+ #define __FILE_TAG _sfio_s
+ #endif
+
+ #undef FILE
+ #undef _FILE
+ #undef fpos_t
+ #undef fpos64_t
+
+ typedef struct _sfio_s _sfio_FILE;
+
+ #define FILE _sfio_FILE
+ #define _FILE FILE
+
+ #if !defined(__FILE) && !__CYGWIN__
+ #undef __FILE
+ #define __FILE FILE
+ #endif
+
+ #if defined(_AST_H) || defined(_SFIO_H)
+
+ #define BUFSIZ SF_BUFSIZE
+
+ #else
+
+ #ifndef BUFSIZ
+ #define BUFSIZ 8192
+ #endif
+
+ #ifndef EOF
+ #define EOF (-1)
+ #endif
+
+ #ifndef NULL
+ #define NULL 0
+ #endif
+
+ #ifndef SEEK_SET
+ #define SEEK_SET 0
+ #define SEEK_CUR 1
+ #define SEEK_END 2
+ #endif
+
+ #include <ast_std.h>
+
+ #include <sfio_s.h>
+
+ #if __cplusplus
+ #define _sf_(f) (f)
+ #else
+ #define _sf_(f) ((struct _sfio_s*)(f))
+ #endif
+
+ #define _SF_EOF 0000200
+ #define _SF_ERROR 0000400
+
+ #endif
+
+ #ifdef _NO_LARGEFILE64_SOURCE
+ #undef _LARGEFILE64_SOURCE
+ #endif
+
+ #ifdef _LARGEFILE64_SOURCE
+ #undef off_t
+ #endif
+
+ #define fpos_t _ast_fpos_t
+ #if _typ_int64_t
+ #define fpos64_t _ast_fpos_t
+ #endif
+
+ typedef struct _ast_fpos_s
+ {
+ intmax_t _sf_offset;
+ unsigned char _sf_state[64 - sizeof(intmax_t)];
+ } _ast_fpos_t;
+
+ #define _base _data
+ #define _ptr _next
+ #define _IOFBF 0
+ #define _IONBF 1
+ #define _IOLBF 2
+
+ #if defined(__cplusplus) && defined(__THROW) && !defined(_UWIN)
+
+ #undef FILE
+ #define FILE FILE
+ typedef struct _sfio_s FILE;
+
+ #undef strerror
+ extern char* strerror(int) __THROW;
+
+ extern int _doprnt(const char*, va_list, FILE*);
+ extern int _doscan(FILE*, const char*, va_list);
+ extern int asprintf(char**, const char*, ...);
+ extern int clearerr(FILE*);
+ extern int fclose(FILE*);
+ extern FILE* fdopen(int, const char*);
+ extern int feof(FILE*);
+ extern int ferror(FILE*);
+ extern int fflush(FILE*);
+ extern int fgetc(FILE*);
+ extern int fgetpos(FILE*, fpos_t*);
+ extern char* fgets(char*, int, FILE*);
+ extern int fileno(FILE*);
+ extern FILE* fopen(const char*, const char*);
+ extern int fprintf(FILE*, const char*, ...);
+ extern int fpurge(FILE*);
+ extern int fputc(int, FILE*);
+ extern int fputs(const char*, FILE*);
+ extern ssize_t fread(void*, size_t, size_t, FILE*);
+ extern FILE* freopen(const char*, const char*, FILE*);
+ extern int fscanf(FILE*, const char*, ...);
+ extern int fseek(FILE*, long, int);
+ extern int fseeko(FILE*, off_t, int);
+ extern int fsetpos(FILE*, const fpos_t*);
+ extern long ftell(FILE*);
+ extern off_t ftello(FILE*);
+ extern ssize_t fwrite(const void*, size_t, size_t, FILE*);
+ extern int getc(FILE*);
+ extern int getchar(void);
+ extern char* gets(char*);
+ extern int getw(FILE*);
+ extern int pclose(FILE*);
+ extern FILE* popen(const char*, const char*);
+ extern int printf(const char*, ...);
+ extern int putc(int, FILE*);
+ extern int putchar(int);
+ extern int puts(const char*);
+ extern int putw(int, FILE*);
+ extern void rewind(FILE*);
+ extern int scanf(const char*, ...);
+ extern void setbuf(FILE*, char*);
+ extern int setbuffer(FILE*, char*, int);
+ extern int setlinebuf(FILE*);
+ extern int setvbuf(FILE*, char*, int, size_t);
+ extern int snprintf(char*, int, const char*, ...);
+ extern int sprintf(char*, const char*, ...);
+ extern int sscanf(const char*, const char*, ...);
+ extern FILE* tmpfile(void);
+ extern int ungetc(int, FILE*);
+ extern int vasprintf(char**, const char*, va_list);
+ extern int vfprintf(FILE*, const char*, va_list);
+ extern int vfscanf(FILE*, const char*, va_list);
+ extern int vprintf(const char*, va_list);
+ extern int vscanf(const char*, va_list);
+ extern int vsnprintf(char*, int, const char*, va_list);
+ extern int vsprintf(char*, const char*, va_list);
+ extern int vsscanf(const char*, const char*, va_list);
+
+ #if _typ_int64_t
+
+ extern int fgetpos64(FILE*, fpos64_t*);
+ extern int fsetpos64(FILE*, const fpos64_t*);
+ extern int fseek64(FILE*, int64_t, int);
+ extern int fseeko64(FILE*, int64_t, int);
+ extern int64_t ftell64(FILE*);
+ extern int64_t ftello64(FILE*);
+
+ #endif
+
+ extern void clearerr_unlocked(FILE*);
+ extern int feof_unlocked(FILE*);
+ extern int ferror_unlocked(FILE*);
+ extern int fflush_unlocked(FILE*);
+ extern int fgetc_unlocked(FILE*);
+ extern char* fgets_unlocked(char*, int, FILE*);
+ extern int fileno_unlocked(FILE*);
+ extern int fputc_unlocked(int, FILE*);
+ extern int fputs_unlocked(char*, FILE*);
+ extern size_t fread_unlocked(void*, size_t, size_t, FILE*);
+ extern size_t fwrite_unlocked(void*, size_t, size_t, FILE*);
+ extern int getc_unlocked(FILE*);
+ extern int getchar_unlocked(void);
+ extern int putc_unlocked(int, FILE*);
+ extern int putchar_unlocked(int);
+
+ #ifdef _USE_GNU
+
+ extern int fcloseall(void);
+ extern FILE* fmemopen(void*, size_t, const char*);
+ extern ssize_t __getdelim(char**, size_t*, int, FILE*);
+ extern ssize_t getdelim(char**, size_t*, int, FILE*);
+ extern ssize_t getline(char**, size_t*, FILE*);
+
+ #endif
+
+ #endif
+}end
+output{
+ #include <stdio.h>
+ #ifndef FILENAME_MAX
+ #ifndef NAME_MAX
+ #ifndef _POSIX_NAME_MAX
+ #define _POSIX_NAME_MAX 14
+ #endif
+ #define NAME_MAX _POSIX_NAME_MAX
+ #endif
+ #define FILENAME_MAX NAME_MAX
+ #endif
+ #ifndef FOPEN_MAX
+ #ifdef STREAM_MAX
+ #define FOPEN_MAX STREAM_MAX
+ #else
+ #ifndef OPEN_MAX
+ #ifndef _POSIX_OPEN_MAX
+ #define _POSIX_OPEN_MAX 20
+ #endif
+ #define OPEN_MAX _POSIX_OPEN_MAX
+ #endif
+ #define FOPEN_MAX OPEN_MAX
+ #endif
+ #endif
+ #ifndef TMP_MAX
+ #define TMP_MAX 33520641
+ #endif
+ int
+ main()
+ {
+ printf("#ifndef FILENAME_MAX\n");
+ printf("#define FILENAME_MAX %d\n", FILENAME_MAX);
+ printf("#endif\n");
+ printf("#ifndef FOPEN_MAX\n");
+ printf("#define FOPEN_MAX %d\n", FOPEN_MAX);
+ printf("#endif\n");
+ printf("#ifndef TMP_MAX\n");
+ printf("#define TMP_MAX %d\n", TMP_MAX);
+ printf("#endif\n");
+ #if !_UWIN
+ printf("\n");
+ printf("#define _doprnt _ast_doprnt\n");
+ printf("#define _doscan _ast_doscan\n");
+ printf("#define asprintf _ast_asprintf\n");
+ printf("#define clearerr _ast_clearerr\n");
+ printf("#define fclose _ast_fclose\n");
+ printf("#define fdopen _ast_fdopen\n");
+ printf("#define fflush _ast_fflush\n");
+ printf("#define fgetc _ast_fgetc\n");
+ printf("#define fgetpos _ast_fgetpos\n");
+ printf("#define fgetpos64 _ast_fgetpos64\n");
+ printf("#define fgets _ast_fgets\n");
+ printf("#define fopen _ast_fopen\n");
+ printf("#define fprintf _ast_fprintf\n");
+ printf("#define fpurge _ast_fpurge\n");
+ printf("#define fputs _ast_fputs\n");
+ printf("#define fread _ast_fread\n");
+ printf("#define freopen _ast_freopen\n");
+ printf("#define fscanf _ast_fscanf\n");
+ printf("#define fseek _ast_fseek\n");
+ printf("#define fseek64 _ast_fseek64\n");
+ printf("#define fseeko _ast_fseeko\n");
+ printf("#define fseeko64 _ast_fseeko64\n");
+ printf("#define fsetpos _ast_fsetpos\n");
+ printf("#define fsetpos64 _ast_fsetpos64\n");
+ printf("#define ftell _ast_ftell\n");
+ printf("#define ftell64 _ast_ftell64\n");
+ printf("#define ftello _ast_ftello\n");
+ printf("#define ftello64 _ast_ftello64\n");
+ printf("#define fwrite _ast_fwrite\n");
+ printf("#define gets _ast_gets\n");
+ printf("#define getw _ast_getw\n");
+ printf("#define pclose _ast_pclose\n");
+ printf("#define popen _ast_popen\n");
+ printf("#define printf _ast_printf\n");
+ printf("#define puts _ast_puts\n");
+ printf("#define putw _ast_putw\n");
+ printf("#define rewind _ast_rewind\n");
+ printf("#define scanf _ast_scanf\n");
+ printf("#define setbuf _ast_setbuf\n");
+ printf("#undef setbuffer\n");
+ printf("#define setbuffer _ast_setbuffer\n");
+ printf("#define setlinebuf _ast_setlinebuf\n");
+ printf("#define setvbuf _ast_setvbuf\n");
+ printf("#define snprintf _ast_snprintf\n");
+ printf("#define sprintf _ast_sprintf\n");
+ printf("#define sscanf _ast_sscanf\n");
+ printf("#define tmpfile _ast_tmpfile\n");
+ printf("#define ungetc _ast_ungetc\n");
+ printf("#define vasprintf _ast_vasprintf\n");
+ printf("#define vfprintf _ast_vfprintf\n");
+ printf("#define vfscanf _ast_vfscanf\n");
+ printf("#define vprintf _ast_vprintf\n");
+ printf("#define vscanf _ast_vscanf\n");
+ printf("#define vsnprintf _ast_vsnprintf\n");
+ printf("#define vsprintf _ast_vsprintf\n");
+ printf("#define vsscanf _ast_vsscanf\n");
+
+ printf("#define fcloseall _ast_fcloseall\n");
+ printf("#define fmemopen _ast_fmemopen\n");
+ printf("#define __getdelim _ast___getdelim\n");
+ printf("#define getdelim _ast_getdelim\n");
+ printf("#define getline _ast_getline\n");
+
+ printf("#define clearerr_unlocked _ast_clearerr_unlocked\n");
+ printf("#define feof_unlocked _ast_feof_unlocked\n");
+ printf("#define ferror_unlocked _ast_ferror_unlocked\n");
+ printf("#define fflush_unlocked _ast_fflush_unlocked\n");
+ printf("#define fgetc_unlocked _ast_fgetc_unlocked\n");
+ printf("#define fgets_unlocked _ast_fgets_unlocked\n");
+ printf("#define fileno_unlocked _ast_fileno_unlocked\n");
+ printf("#define fputc_unlocked _ast_fputc_unlocked\n");
+ printf("#define fputs_unlocked _ast_fputs_unlocked\n");
+ printf("#define fread_unlocked _ast_fread_unlocked\n");
+ printf("#define fwrite_unlocked _ast_fwrite_unlocked\n");
+ printf("#define getc_unlocked _ast_getc_unlocked\n");
+ printf("#define getchar_unlocked _ast_getchar_unlocked\n");
+ printf("#define putc_unlocked _ast_putc_unlocked\n");
+ printf("#define putchar_unlocked _ast_putchar_unlocked\n");
+
+ printf("\n");
+ #endif
+ return 0;
+ }
+}end
+macro{
+ <<"#if defined(__STDPP__directive) && defined(__STDPP__initial)">>
+ <<"__STDPP__directive pragma pp:initial">>
+ <<"#endif">>
+ <<"#ifndef P_tmpdir">>
+ #ifndef P_tmpdir
+ #define P_tmpdir "/usr/tmp/"
+ #endif
+ <<"#define P_tmpdir">> P_tmpdir <<"/*NOCATLITERAL*/">>
+ <<"#endif">>
+ <<"#ifndef L_ctermid">>
+ #ifndef L_ctermid
+ #define L_ctermid 9
+ #endif
+ <<"#define L_ctermid">> L_ctermid
+ <<"#endif">>
+ <<"#ifndef L_tmpnam">>
+ #ifndef L_tmpnam
+ #define L_tmpnam (sizeof(P_tmpdir)+15)
+ #endif
+ <<"#define L_tmpnam">> L_tmpnam
+ <<"#endif">>
+ <<"#if defined(__STDPP__directive) && defined(__STDPP__initial)">>
+ <<"__STDPP__directive pragma pp:noinitial">>
+ <<"#endif">>
+}end
+cat{
+ #if defined(__cplusplus) && defined(__THROW)
+ extern char* ctermid(char*) __THROW;
+ #else
+ extern char* ctermid(char*);
+ #endif
+ extern char* tmpnam(char*);
+ extern char* tempnam(const char*, const char*);
+ extern void perror(const char*);
+ #ifndef _AST_STD_H
+ #ifndef remove
+ extern int remove(const char*);
+ #endif
+ #ifndef rename
+ extern int rename(const char*, const char*);
+ #endif
+ #endif
+
+ #undef extern
+
+ #if _BLD_ast && defined(__EXPORT__)
+ #define extern __EXPORT__
+ #endif
+
+ extern int _doprnt(const char*, va_list, FILE*);
+ extern int _doscan(FILE*, const char*, va_list);
+ extern int asprintf(char**, const char*, ...);
+ extern int clearerr(FILE*);
+ extern int fclose(FILE*);
+ extern FILE* fdopen(int, const char*);
+ extern int feof(FILE*);
+ extern int ferror(FILE*);
+ extern int fflush(FILE*);
+ extern int fgetc(FILE*);
+ extern int fgetpos(FILE*, fpos_t*);
+ extern char* fgets(char*, int, FILE*);
+ extern int fileno(FILE*);
+ extern FILE* fopen(const char*, const char*);
+ extern int fprintf(FILE*, const char*, ...);
+ extern int fpurge(FILE*);
+ extern int fputc(int, FILE*);
+ extern int fputs(const char*, FILE*);
+ extern ssize_t fread(void*, size_t, size_t, FILE*);
+ extern FILE* freopen(const char*, const char*, FILE*);
+ extern int fscanf(FILE*, const char*, ...);
+ extern int fseek(FILE*, long, int);
+ extern int fseeko(FILE*, off_t, int);
+ extern int fsetpos(FILE*, const fpos_t*);
+ extern long ftell(FILE*);
+ extern off_t ftello(FILE*);
+ extern ssize_t fwrite(const void*, size_t, size_t, FILE*);
+ extern int getc(FILE*);
+ extern int getchar(void);
+ extern char* gets(char*);
+ extern int getw(FILE*);
+ extern int pclose(FILE*);
+ extern FILE* popen(const char*, const char*);
+ extern int printf(const char*, ...);
+ extern int putc(int, FILE*);
+ extern int putchar(int);
+ extern int puts(const char*);
+ extern int putw(int, FILE*);
+ extern void rewind(FILE*);
+ extern int scanf(const char*, ...);
+ extern void setbuf(FILE*, char*);
+ extern int setbuffer(FILE*, char*, int);
+ extern int setlinebuf(FILE*);
+ extern int setvbuf(FILE*, char*, int, size_t);
+ extern int snprintf(char*, int, const char*, ...);
+ extern int sprintf(char*, const char*, ...);
+ extern int sscanf(const char*, const char*, ...);
+ extern FILE* tmpfile(void);
+ extern int ungetc(int, FILE*);
+ extern int vasprintf(char**, const char*, va_list);
+ extern int vfprintf(FILE*, const char*, va_list);
+ extern int vfscanf(FILE*, const char*, va_list);
+ extern int vprintf(const char*, va_list);
+ extern int vscanf(const char*, va_list);
+ extern int vsnprintf(char*, int, const char*, va_list);
+ extern int vsprintf(char*, const char*, va_list);
+ extern int vsscanf(const char*, const char*, va_list);
+
+ #if _typ_int64_t
+
+ extern int fgetpos64(FILE*, fpos64_t*);
+ extern int fsetpos64(FILE*, const fpos64_t*);
+ extern int fseek64(FILE*, int64_t, int);
+ extern int fseeko64(FILE*, int64_t, int);
+ extern int64_t ftell64(FILE*);
+ extern int64_t ftello64(FILE*);
+
+ #ifdef _LARGEFILE64_SOURCE
+
+ #undef fpos_t
+ #undef off_t
+ #undef fgetpos
+ #undef fsetpos
+ #undef fseek
+ #undef fseeko
+ #undef ftell
+ #undef ftello
+
+ #define fpos_t fpos64_t
+ #if _typ_off64_t
+ #define off_t off64_t
+ #else
+ #define off_t int64_t
+ #endif
+
+ #define fgetpos fgetpos64
+ #define fsetpos fsetpos64
+ #define fseek fseek64
+ #define fseeko fseeko64
+ #define ftell ftell64
+ #define ftello ftello64
+
+ #endif
+
+ #endif
+
+ extern void clearerr_unlocked(FILE*);
+ extern int feof_unlocked(FILE*);
+ extern int ferror_unlocked(FILE*);
+ extern int fflush_unlocked(FILE*);
+ extern int fgetc_unlocked(FILE*);
+ extern char* fgets_unlocked(char*, int, FILE*);
+ extern int fileno_unlocked(FILE*);
+ extern int fputc_unlocked(int, FILE*);
+ extern int fputs_unlocked(char*, FILE*);
+ extern size_t fread_unlocked(void*, size_t, size_t, FILE*);
+ extern size_t fwrite_unlocked(void*, size_t, size_t, FILE*);
+ extern int getc_unlocked(FILE*);
+ extern int getchar_unlocked(void);
+ extern int putc_unlocked(int, FILE*);
+ extern int putchar_unlocked(int);
+
+ #ifdef _USE_GNU
+
+ extern int fcloseall(void);
+ extern FILE* fmemopen(void*, size_t, const char*);
+ extern ssize_t __getdelim(char**, size_t*, int, FILE*);
+ extern ssize_t getdelim(char**, size_t*, int, FILE*);
+ extern ssize_t getline(char**, size_t*, FILE*);
+
+ #endif
+
+ #undef extern
+
+ #if _BLD_DLL && _DLL_INDIRECT_DATA
+
+ #define stdin ((FILE*)_ast_dll->_ast_stdin)
+ #define stdout ((FILE*)_ast_dll->_ast_stdout)
+ #define stderr ((FILE*)_ast_dll->_ast_stderr)
+
+ #else
+
+ #define stdin (&_Sfstdin)
+ #define stdout (&_Sfstdout)
+ #define stderr (&_Sfstderr)
+
+ #endif
+
+ #if defined(_AST_H) || defined(_SFIO_H)
+
+ #define feof(f) sfeof(f)
+ #define ferror(f) sferror(f)
+ #define fileno(f) sffileno(f)
+ #define fputc(c,f) sfputc(f,c)
+ #define getc(f) sfgetc(f)
+ #define getchar() sfgetc(sfstdin)
+ #define putc(c,f) sfputc(f,c)
+ #define putchar(c) sfputc(sfstdout,c)
+
+ #else
+
+ #if !_UWIN
+ #if _BLD_ast && defined(__EXPORT__)
+ #define extern extern __EXPORT__
+ #endif
+ #if !_BLD_ast && defined(__IMPORT__)
+ #define extern extern __IMPORT__
+ #endif
+ #endif
+
+ extern FILE _Sfstdin;
+ extern FILE _Sfstdout;
+ extern FILE _Sfstderr;
+
+ #undef extern
+
+ #define feof(f) (_sf_(f)->_flags&_SF_EOF)
+ #define ferror(f) (_sf_(f)->_flags&_SF_ERROR)
+ #define fileno(f) (_sf_(f)->_file)
+ #define fputc(c,f) (_sf_(f)->_next>=_sf_(f)->_endw?_sfflsbuf(_sf_(f),(int)((unsigned char)(c))):(int)(*_sf_(f)->_next++=(unsigned char)(c)))
+ #define getc(f) (_sf_(f)->_next>=_sf_(f)->_endr?_sffilbuf(_sf_(f),0):(int)(*_sf_(f)->_next++))
+ #define getchar() getc(stdin)
+ #define putc(c,f) fputc(c,f)
+ #define putchar(c) fputc(c,stdout)
+
+ #if _BLD_ast && defined(__EXPORT__)
+ #define extern __EXPORT__
+ #endif
+
+ extern int _sffilbuf(FILE*, int);
+ extern int _sfflsbuf(FILE*, int);
+
+ #undef extern
+
+ #endif
+}end
diff --git a/usr/src/lib/libast/common/features/sys b/usr/src/lib/libast/common/features/sys
new file mode 100644
index 0000000000..3e30180cbf
--- /dev/null
+++ b/usr/src/lib/libast/common/features/sys
@@ -0,0 +1,273 @@
+set prototyped
+iff AST_SYS
+ref -D_def_map_ast
+
+print #if __mips == 2 && !defined(_NO_LARGEFILE64_SOURCE)
+print #define _NO_LARGEFILE64_SOURCE 1
+print #endif
+print #if !defined(_NO_LARGEFILE64_SOURCE) && _typ_off64_t && _lib_lseek64 && _lib_stat64
+print #if !defined(_LARGEFILE64_SOURCE)
+print #define _LARGEFILE64_SOURCE 1
+print #endif
+print #if !defined(_LARGEFILE_SOURCE)
+print #define _LARGEFILE_SOURCE 1
+print #endif
+print #else
+print #undef _LARGEFILE64_SOURCE
+print #undef _LARGEFILE_SOURCE
+print #undef _typ_off64_t
+print #undef _typ_struct_dirent64
+print #undef _lib_creat64
+print #undef _lib_fstat64
+print #undef _lib_fstatvfs64
+print #undef _lib_ftruncate64
+print #undef _lib_lseek64
+print #undef _lib_lstat64
+print #undef _lib_mmap64
+print #undef _lib_open64
+print #undef _lib_readdir64
+print #undef _lib_stat64
+print #undef _lib_statvfs64
+print #undef _lib_truncate64
+print #endif
+
+print #if defined(__STDC__) && !defined(__USE_FIXED_PROTOTYPES__)
+print #define __USE_FIXED_PROTOTYPES__ 1 /* kick gcc out of the past */
+print #endif
+
+header stdlib.h
+header stddef.h
+header sys/types.h
+header stdint.h
+header inttypes.h
+header string.h
+header unistd.h
+header limits.h
+header fcntl.h
+header locale.h
+header sys/localedef.h
+
+typ dev_t,nlink_t fail{
+ echo "#ifndef $m"
+ echo "#define $m 1"
+ echo "typedef short $v;"
+ echo "#endif"
+}end
+typ gid_t,mode_t,uid_t fail{
+ echo "#ifndef $m"
+ echo "#define $m 1"
+ echo "typedef unsigned short $v;"
+ echo "#endif"
+}end
+typ wchar_t stdio.h wchar.h fail{
+ echo "#ifndef $m"
+ echo "#define $m 1"
+ echo "typedef unsigned short $v;"
+ echo "#endif"
+}end
+typ pid_t,ssize_t fail{
+ echo "#ifndef $m"
+ echo "#define $m 1"
+ echo "typedef int $v;"
+ echo "#endif"
+}end
+typ wint_t stdio.h wchar.h fail{
+ echo "#ifndef $m"
+ echo "#define $m 1"
+ echo "typedef int $v;"
+ echo "#endif"
+}end
+typ socklen_t sys/socket.h fail{
+ echo "#ifndef $m"
+ echo "#define $m 1"
+ echo "typedef int $v;"
+ echo "#endif"
+}end
+typ size_t fail{
+ echo "#ifndef $m"
+ echo "#define $m 1"
+ echo "typedef unsigned int $v;"
+ echo "#endif"
+}end
+typ clock_t,ino_t,off_t,ptrdiff_t fail{
+ echo "#ifndef $m"
+ echo "#define $m 1"
+ echo "typedef long $v;"
+ echo "#endif"
+}end
+typ time_t fail{
+ echo "#ifndef $m"
+ echo "#define $m 1"
+ echo "typedef unsigned long $v;"
+ echo "#endif"
+}end
+typ div_t fail{
+ echo "#ifndef $m"
+ echo "#define $m 1"
+ echo "typedef struct { int quot; int rem; } $v;"
+ echo "#endif"
+}end
+typ ldiv_t fail{
+ echo "#ifndef $m"
+ echo "#define $m 1"
+ echo "typedef struct { long quot; long rem; } $v;"
+ echo "#endif"
+}end
+tst typ_signed_size_t output{
+ #include <sys/types.h>
+ int
+ main()
+ {
+ unsigned long u = ~0;
+ size_t s = ~0;
+ if (s >= 0)
+ return 1;
+ printf("#if !defined(__cplusplus) && !defined(c_plusplus) && !defined(_typ_signed_size_t)\n/* what dipsticks made size_t signed? sun. */\ntypedef unsigned %s _ast_size_t;\n#undef\tsize_t\n#define size_t\t_ast_size_t\n#endif\n", u == (unsigned long)s ? "long" : "int");
+ return 0;
+ }
+}end
+
+define offsetof (type,member) ((size_t)&(((type*)0)->member))
+define EXIT_FAILURE 1
+define EXIT_SUCCESS 0
+define MB_CUR_MAX 1
+define RAND_MAX 32767
+
+define STDIN_FILENO 0
+define STDOUT_FILENO 1
+define STDERR_FILENO 2
+
+define NULL 0
+
+define SEEK_SET 0
+define SEEK_CUR 1
+define SEEK_END 2
+
+define F_OK 0
+define X_OK 1
+define W_OK 2
+define R_OK 4
+
+print #if _BLD_ast && defined(__EXPORT__)
+print #define extern __EXPORT__
+print #endif
+
+extern _exit void (int)
+extern abort void (void)
+extern abs int (int)
+extern access int (const char*, int)
+extern alarm unsigned (unsigned)
+extern atexit int (void(*)(void))
+extern atof double (const char*)
+extern atoi int (const char*)
+extern atol long (const char*)
+extern bsearch void* (const void*, const void*, size_t, size_t, int(*)(const void*, const void*))
+extern calloc void* (size_t, size_t)
+extern cfree void (void*)
+extern chdir int (const char*)
+extern chown int (const char*, uid_t, gid_t)
+extern close int (int)
+extern confstr size_t (int, char*, size_t)
+extern div div_t (int, int)
+extern dup int (int)
+extern dup2 int (int, int)
+extern eaccess int (const char*, int)
+extern execl int (const char*, const char*, ...)
+extern execle int (const char*, const char*, ...)
+extern execlp int (const char*, const char*, ...)
+extern execv int (const char*, char* const[])
+extern execve int (const char*, char* const[], char* const[])
+extern execve int (const char*, char* const[], char* const[])
+extern execvp int (const char*, char* const[])
+extern execvpe int (const char*, char* const[], char* const[])
+extern exit void (int)
+extern fork pid_t (void)
+extern fpathconf long (int, int)
+extern free void (void*)
+extern fsync int (int)
+extern ftruncate int (int, off_t)
+extern getcwd char* (char*, size_t)
+extern getegid gid_t (void)
+extern getenv char* (const char*)
+extern geteuid uid_t (void)
+extern getgid gid_t (void)
+extern getgroups int (int, gid_t[])
+extern getlogin char* (void)
+extern getpgrp pid_t (void)
+extern getpid pid_t (void)
+extern getppid pid_t (void)
+extern gettxt char* (const char*, const char*)
+extern getuid uid_t (void)
+extern isatty int (int)
+extern labs long (long)
+extern ldiv ldiv_t (long, long)
+extern link int (const char*, const char*)
+extern lseek off_t (int, off_t, int)
+extern malloc void* (size_t)
+extern mblen int (const char*, size_t)
+extern mbstowcs size_t (wchar_t*, const char*, size_t)
+extern mbtowc int (wchar_t*, const char*, size_t)
+extern memalign void* (size_t, size_t)
+extern memccpy void* (void*, const void*, int, size_t)
+extern memchr void* (const void*, int, size_t)
+extern memcmp int (const void*, const void*, size_t)
+extern memcpy void* (void*, const void*, size_t)
+extern memmove void* (void*, const void*, size_t)
+extern memset void* (void*, int, size_t)
+extern pathconf long (const char*, int)
+extern pause int (void)
+extern pipe int (int[])
+extern pvalloc void* (size_t)
+extern qsort void (void*, size_t, size_t, int(*)(const void*, const void*))
+extern rand int (void)
+extern read ssize_t (int, void*, size_t)
+extern realloc void* (void*, size_t)
+extern realpath char* (const char*, char*)
+extern resolvepath char* (const char*, char*, size_t)
+extern rmdir int (const char*)
+extern setgid int (gid_t)
+extern setpgid int (pid_t, pid_t)
+extern setsid pid_t (void)
+extern setuid int (uid_t)
+extern sleep unsigned (unsigned int)
+extern spawnveg pid_t (const char*, char* const[], char* const[], pid_t)
+extern srand void (unsigned int)
+extern strcasecmp int (const char*, const char*)
+extern strcat char* (char*, const char*)
+extern strchr char* (const char*, int)
+extern strcmp int (const char*, const char*)
+extern strcoll int (const char*, const char*)
+extern strcpy char* (char*, const char*)
+extern strcspn size_t (const char*, const char*)
+extern strdup char* (const char*)
+extern strlcat size_t (char*, const char*, size_t)
+extern strlcpy size_t (char*, const char*, size_t)
+extern strlen size_t (const char*)
+extern strncasecmp int (const char*, const char*, size_t)
+extern strncat char* (char*, const char*, size_t)
+extern strncmp int (const char*, const char*, size_t)
+extern strncpy char* (char*, const char*, size_t)
+extern strpbrk char* (const char*, const char*)
+extern strrchr char* (const char*, int)
+extern strspn size_t (const char*, const char*)
+extern strstr char* (const char*, const char*)
+extern strtok char* (char*, const char*)
+extern strxfrm size_t (char*, const char*, size_t)
+extern swab void (const void*, void*, ssize_t)
+extern sysconf long (int)
+extern system int (const char*)
+extern tcgetpgrp pid_t (int)
+extern tcsetpgrp int (int, pid_t)
+extern truncate int (const char*, off_t)
+extern ttyname char* (int)
+extern unlink int (const char*)
+extern valloc void* (size_t)
+extern wcstombs size_t (char*, const wchar_t*, size_t)
+extern wctomb int (char*, wchar_t)
+extern write ssize_t (int, const void*, size_t)
+
+print #undef extern
+
+# <stdarg.h> is handled by proto so this must be after the last test
+
+print #include <stdarg.h>
diff --git a/usr/src/lib/libast/common/features/time b/usr/src/lib/libast/common/features/time
new file mode 100644
index 0000000000..4dc5167ab8
--- /dev/null
+++ b/usr/src/lib/libast/common/features/time
@@ -0,0 +1,46 @@
+set prototyped
+lib nanosleep,usleep,_strftime
+typ clock_t = uint32_t
+typ time_t = uint32_t
+
+if sys time {
+ #include <sys/time.h>
+}
+endif
+
+if ! mem tm.tm_sec sys/time.h
+ if hdr time {
+ #include <time.h>
+ }
+ endif
+endif
+
+if sys times {
+ #include <sys/times.h>
+}
+else {
+ struct tms
+ {
+ clock_t tms_utime;
+ clock_t tms_stime;
+ clock_t tms_cutime;
+ clock_t tms_cstime;
+ };
+ extern clock_t times(struct tms*);
+}
+endif
+
+if ! mem timeval.tv_sec sys/time.h {
+ struct timeval
+ {
+ time_t tv_sec;
+ time_t tv_usec;
+ };
+}
+endif
+
+cat{
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC CLK_TCK
+#endif
+}end
diff --git a/usr/src/lib/libast/common/features/tmlib b/usr/src/lib/libast/common/features/tmlib
new file mode 100644
index 0000000000..2f88e5e625
--- /dev/null
+++ b/usr/src/lib/libast/common/features/tmlib
@@ -0,0 +1,32 @@
+set prototyped
+
+tst tzset_environ note{ tzset() bypasses user getenv() }end execute{
+ #include <time.h>
+ extern char** environ;
+ extern char* tzname[2];
+ #if _STD_
+ extern char* getenv(char* s)
+ #else
+ extern char* getenv(s)
+ char* s;
+ #endif
+ {
+ return "foo0bar";
+ }
+ int main()
+ {
+ tzset();
+ return tzname[0] && !strcmp(tzname[0], "foo") &&
+ tzname[1] && !strcmp(tzname[1], "bar");
+ }
+}end
+
+if ( _tzset_environ ) {
+ #define tmlocaltime(p) _tm_localtime(p)
+
+ extern struct tm* _tm_localtime(const time_t*);
+}
+else {
+ #define tmlocaltime(p) localtime(p)
+}
+endif
diff --git a/usr/src/lib/libast/common/features/tmx b/usr/src/lib/libast/common/features/tmx
new file mode 100644
index 0000000000..6db5dbcc52
--- /dev/null
+++ b/usr/src/lib/libast/common/features/tmx
@@ -0,0 +1,104 @@
+set prototyped
+set explicit
+iff TMX
+
+cat{
+ /*
+ * AT&T Research
+ *
+ * high resolution Time_t support
+ */
+
+ #include <tm.h>
+ #include <tv.h>
+}end
+
+inc FEATURE/common
+
+if ( _ast_int8_t ) {
+ #define TMX_MAXDATE "2554-07-21+23:34:33.709551614 UTC"
+ #define TMX_MAXYEAR 2554
+ #define TMX_MAXSEC ((Time_t)18446744073)
+ #define TMX_MAXNSEC 709551614
+ #define TMX_RESOLUTION 1000000000
+
+ typedef uint64_t Time_t;
+ typedef uint64_t Tmxsec_t;
+ typedef uint32_t Tmxnsec_t;
+
+ #define tmxsec(t) ((Tmxsec_t)((t)/1000000000))
+ #define tmxnsec(t) ((Tmxnsec_t)((t)%1000000000))
+ #define tmxsns(s,n) (((((Time_t)(s))*1000000000))+((Time_t)(n)))
+}
+elif ( _ast_flt8_t ) {
+ #define TMX_FLOAT 1
+ #define TMX_MAXDATE "2106-02-07+06:28:15.999 UTC"
+ #define TMX_MAXYEAR 2106
+ #define TMX_MAXSEC 0xffffffffL
+ #define TMX_MAXNSEC 999000000L
+ #define TMX_RESOLUTION 1000
+
+ typedef _ast_flt8_t Time_t;
+ typedef uint32_t Tmxsec_t;
+ typedef uint32_t Tmxnsec_t;
+
+ #define tmxsec(t) ((Tmxsec_t)(t))
+ #define tmxnsec(t) (((Tmxnsec_t)(((t)-((uint32_t)(t))+0.0000005)*1000L))*1000000L)
+ #define tmxsns(s,n) (((Time_t)(s))+((((uint32_t)(n))/1000L)/1e6))
+}
+else {
+ #define TMX_MAXDATE "2106-02-07+06:28:14 UTC"
+ #define TMX_MAXYEAR 2106
+ #define TMX_MAXSEC 0xfffffffeL
+ #define TMX_MAXNSEC 0L
+ #define TMX_RESOLUTION 1
+
+ typedef uint32_t Time_t;
+ typedef uint32_t Tmxsec_t;
+ typedef uint32_t Tmxnsec_t;
+
+ #define tmxsec(t) ((Tmxsec_t)(t))
+ #define tmxnsec(t) (0)
+ #define tmxsns(s,n) ((Time_t)(s))
+}
+endif
+
+cat{
+ #define TMX_NOTIME ((Time_t)(-1))
+ #define TMX_NOW tmxgettime()
+ #define TMX_MAXTIME tmxsns(TMX_MAXSEC,TMX_MAXNSEC)
+
+ #define tmx2tv(t,v) ((v)->tv_nsec=tmxnsec(t),(v)->tv_sec=tmxsec(t))
+ #define tv2tmx(v) tmxsns((v)->tv_sec,(v)->tv_nsec)
+
+ #define tmxclock(p) tmxsns(((p)?*(p):time(NiL)),0)
+
+ #define tmxgetatime(s) tmxsns((s)->st_atime,ST_ATIME_NSEC_GET(s))
+ #define tmxgetctime(s) tmxsns((s)->st_ctime,ST_CTIME_NSEC_GET(s))
+ #define tmxgetmtime(s) tmxsns((s)->st_mtime,ST_MTIME_NSEC_GET(s))
+
+ #define tmxsetatime(s,t) ((s)->st_atime=tmxsec(t),ST_ATIME_NSEC_SET(s,tmxnsec(t)))
+ #define tmxsetctime(s,t) ((s)->st_ctime=tmxsec(t),ST_CTIME_NSEC_SET(s,tmxnsec(t)))
+ #define tmxsetmtime(s,t) ((s)->st_mtime=tmxsec(t),ST_MTIME_NSEC_SET(s,tmxnsec(t)))
+
+ #if _BLD_ast && defined(__EXPORT__)
+ #define extern __EXPORT__
+ #endif
+
+ extern Time_t tmxdate(const char*, char**, Time_t);
+ extern char* tmxfmt(char*, size_t, const char*, Time_t);
+ extern Time_t tmxleap(Time_t);
+ extern Tm_t* tmxmake(Time_t);
+ extern Time_t tmxscan(const char*, char**, const char*, char**, Time_t, long);
+ extern int tmxsleep(Time_t);
+ extern Time_t tmxtime(Tm_t*, int);
+
+ extern Time_t tmxgettime(void);
+ extern int tmxsettime(Time_t);
+
+ extern int tmxtouch(const char*, Time_t, Time_t, Time_t, int);
+
+ extern char* fmttmx(const char*, Time_t);
+
+ #undef extern
+}end
diff --git a/usr/src/lib/libast/common/features/tty b/usr/src/lib/libast/common/features/tty
new file mode 100644
index 0000000000..a75edeb181
--- /dev/null
+++ b/usr/src/lib/libast/common/features/tty
@@ -0,0 +1,127 @@
+hdr termios,termio,sgtty
+sys termios,termio,ioctl,bsdtty,nttyio,ttyio
+lib tcgetattr,tcgetpgrp termios.h
+mac _POSIX_VDISABLE termios.h
+mem termios.c_line termios.h
+
+cat{
+
+#ifdef _hdr_termios
+# if _mac__POSIX_VDISABLE
+# undef _POSIX_VDISABLE
+# endif
+# include <termios.h>
+#else
+# if defined(_sys_termios) && defined(_lib_tcgetattr)
+# include <sys/termios.h>
+# define _hdr_termios 1
+# else
+# undef _sys_termios
+# endif /* _sys_termios */
+#endif /* _hdr_termios */
+
+#ifdef _hdr_termios
+# undef _hdr_sgtty
+# undef tcgetattr
+# undef tcsetattr
+# undef tcgetpgrp
+# undef tcsetpgrp
+# undef cfgetospeed
+# ifndef TCSANOW
+# define TCSANOW TCSETS
+# define TCSADRAIN TCSETSW
+# define TCSAFLUSH TCSETSF
+# endif /* TCSANOW */
+ /* The following corrects bugs in some implementations */
+# if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
+# define TCSAFLUSH TCSADFLUSH
+# endif /* TCSADFLUSH */
+# ifndef _lib_tcgetattr
+# undef tcgetattr
+# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
+# undef tcsetattr
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# undef cfgetospeed
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# endif /* _lib_tcgetattr */
+# undef TIOCGETC
+#else
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfgetispeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfsetispeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# define cfsetospeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# ifdef _hdr_termio
+# include <termio.h>
+# else
+# ifdef _sys_termio
+# include <sys/termio.h>
+# define _hdr_termio 1
+# endif /* _sys_termio */
+# endif /* _hdr_termio */
+# ifdef _hdr_termio
+# define termios termio
+# undef TIOCGETC
+# define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+
+# ifdef _sys_bsdtty
+# include <sys/bsdtty.h>
+# endif /* _sys_bsdtty */
+# else
+# ifdef _hdr_sgtty
+# include <sgtty.h>
+# ifndef LPENDIN
+# ifdef _sys_nttyio
+# include <sys/nttyio.h>
+# endif /* _sys_nttyio */
+# endif /* LPENDIN */
+# define termios sgttyb
+# ifdef TIOCSETN
+# undef TCSETAW
+# endif /* TIOCSETN */
+# ifdef TIOCGETP
+# define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# else
+# define tcgetattr(fd,tty) gtty(fd, tty)
+# define tcsetattr(fd,action,tty) stty(fd, tty)
+# endif /* TIOCGETP */
+# else
+# ifdef _sys_ttyio
+# include <sys/ttyio.h>
+# endif
+# endif /* _hdr_sgtty */
+# endif /* hdr_termio */
+
+# ifndef TCSANOW
+# ifdef TCSETAW
+# define TCSANOW TCSETA
+# define TCSAFLUSH TCSETAF
+# else
+# ifdef TIOCSETN
+# define TCSANOW TIOCSETN
+# define TCSADRAIN TIOCSETN
+# define TCSAFLUSH TIOCSETP
+# endif /* TIOCSETN */
+# endif /* TCSETAW */
+# endif /* TCSANOW */
+#endif /* _hdr_termios */
+
+/* set ECHOCTL if driver can echo control charaters as ^c */
+#ifdef LCTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LCTLECH
+# endif /* !ECHOCTL */
+#endif /* LCTLECH */
+#ifdef LNEW_CTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LNEW_CTLECH
+# endif /* !ECHOCTL */
+#endif /* LNEW_CTLECH */
+#ifdef LNEW_PENDIN
+# ifndef PENDIN
+# define PENDIN LNEW_PENDIN
+# endif /* !PENDIN */
+#endif /* LNEW_PENDIN */
+
+}end
diff --git a/usr/src/lib/libast/common/features/tv b/usr/src/lib/libast/common/features/tv
new file mode 100644
index 0000000000..ae15682121
--- /dev/null
+++ b/usr/src/lib/libast/common/features/tv
@@ -0,0 +1,81 @@
+set prototyped
+set explicit
+iff TV
+
+cat{
+ /*
+ * AT&T Research
+ *
+ * high resolution Tv_t interface definitions
+ */
+
+ #include <ast.h>
+
+ #define TV_NSEC_IGNORE (1000000000L)
+ #define TV_TOUCH_RETAIN ((Tv_t*)1)
+
+ typedef struct Tv_s
+ {
+ uint32_t tv_sec;
+ uint32_t tv_nsec;
+ } Tv_t;
+}end
+
+if mem stat.st_mtimespec.tv_nsec sys/stat.h {
+ #define ST_ATIME_NSEC_GET(st) ((st)->st_atimespec.tv_nsec)
+ #define ST_CTIME_NSEC_GET(st) ((st)->st_ctimespec.tv_nsec)
+ #define ST_MTIME_NSEC_GET(st) ((st)->st_mtimespec.tv_nsec)
+}
+elif mem stat.st_mtim.st__tim.tv_nsec sys/stat.h {
+ #define ST_ATIME_NSEC_GET(st) ((st)->st_atim.st__tim.tv_nsec)
+ #define ST_CTIME_NSEC_GET(st) ((st)->st_ctim.st__tim.tv_nsec)
+ #define ST_MTIME_NSEC_GET(st) ((st)->st_mtim.st__tim.tv_nsec)
+}
+elif mem stat.st_mtim.tv_nsec sys/stat.h {
+ #define ST_ATIME_NSEC_GET(st) ((st)->st_atim.tv_nsec)
+ #define ST_CTIME_NSEC_GET(st) ((st)->st_ctim.tv_nsec)
+ #define ST_MTIME_NSEC_GET(st) ((st)->st_mtim.tv_nsec)
+}
+elif mem stat.st_mtimensec sys/stat.h {
+ #define ST_ATIME_NSEC_GET(st) ((st)->st_atimensec)
+ #define ST_CTIME_NSEC_GET(st) ((st)->st_ctimensec)
+ #define ST_MTIME_NSEC_GET(st) ((st)->st_mtimensec)
+}
+else pass{ no_stat_nsec=1 }end {
+ #define ST_ATIME_NSEC_GET(st) 0
+ #define ST_CTIME_NSEC_GET(st) 0
+ #define ST_MTIME_NSEC_GET(st) 0
+
+ #define ST_ATIME_NSEC_SET(st,n) 0
+ #define ST_CTIME_NSEC_SET(st,n) 0
+ #define ST_MTIME_NSEC_SET(st,n) 0
+}
+endif
+if ( !no_stat_nsec ) {
+ #define ST_ATIME_NSEC_SET(st,n) (ST_ATIME_NSEC_GET(st)=(n))
+ #define ST_CTIME_NSEC_SET(st,n) (ST_CTIME_NSEC_GET(st)=(n))
+ #define ST_MTIME_NSEC_SET(st,n) (ST_MTIME_NSEC_GET(st)=(n))
+}
+endif
+
+cat{
+ #define tvgetatime(t,s) ((t)->tv_nsec=ST_ATIME_NSEC_GET(s),(t)->tv_sec=(s)->st_atime)
+ #define tvgetmtime(t,s) ((t)->tv_nsec=ST_MTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_mtime)
+ #define tvgetctime(t,s) ((t)->tv_nsec=ST_CTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_ctime)
+
+ #define tvsetatime(t,s) (ST_ATIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_atime=(t)->tv_sec)
+ #define tvsetmtime(t,s) (ST_MTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_mtime=(t)->tv_sec)
+ #define tvsetctime(t,s) (ST_CTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_ctime=(t)->tv_sec)
+
+ #if _BLD_ast && defined(__EXPORT__)
+ #define extern __EXPORT__
+ #endif
+
+ extern int tvgettime(Tv_t*);
+ extern int tvsettime(const Tv_t*);
+ extern int tvcmp(const Tv_t*, const Tv_t*);
+ extern int tvtouch(const char*, const Tv_t*, const Tv_t*, const Tv_t*, int);
+ extern int tvsleep(const Tv_t*, Tv_t*);
+
+ extern char* fmttv(const char*, Tv_t*);
+}end
diff --git a/usr/src/lib/libast/common/features/tvlib b/usr/src/lib/libast/common/features/tvlib
new file mode 100644
index 0000000000..e1440f99f6
--- /dev/null
+++ b/usr/src/lib/libast/common/features/tvlib
@@ -0,0 +1,67 @@
+hdr time
+lib clock_settime,gettimeofday,settimeofday,stime,utimes
+lib nanosleep,usleep
+
+if ! mem timeval.tv_sec sys/time.h {
+ struct timeval
+ {
+ time_t tv_sec;
+ time_t tv_usec;
+ };
+}
+endif
+
+lib clock_gettime execute{
+ #include <time.h>
+ main()
+ {
+ struct timespec tv;
+ return clock_gettime(CLOCK_REALTIME, &tv) != 0;
+ }
+}end
+
+lib utimets link{
+ #include <time.h>
+ #include <sys/time.h>
+ static struct timespec tv;
+ main()
+ {
+ return utimets(".", &tv) != 0;
+ }
+}end
+
+tst - -DN=1 - -DN=2 - -DN=3 - -DN=4 output{
+ #include <sys/types.h>
+ #include <sys/time.h>
+ int
+ main()
+ {
+ struct timeval tv;
+#if N == 1
+ struct timezone tz;
+ if (gettimeofday(&tv, (struct timezone*)0) < 0)
+ return 1;
+ printf("#define tmgettimeofday(p) gettimeofday(p,(struct timezone*)0)\n");
+#if _lib_settimeofday
+ printf("#define tmsettimeofday(p) settimeofday(p,(struct timezone*)0)\n");
+#endif
+#endif
+#if N == 2
+ if (gettimeofday(&tv, (void*)0) < 0)
+ return 1;
+ printf("#define tmgettimeofday(p) gettimeofday(p,(void*)0)\n");
+#if _lib_settimeofday
+ printf("#define tmsettimeofday(p) gettimeofday(p,(void*)0)\n");
+#endif
+#endif
+#if N == 3
+ if (gettimeofday(&tv) < 0)
+ return 1;
+ printf("#define tmgettimeofday(p) gettimeofday(p)\n");
+#if _lib_settimeofday
+ printf("#define tmsettimeofday(p) settimeofday(p)\n");
+#endif
+#endif
+ return 0;
+ }
+}end
diff --git a/usr/src/lib/libast/common/features/uwin b/usr/src/lib/libast/common/features/uwin
new file mode 100644
index 0000000000..8c4640fcc9
--- /dev/null
+++ b/usr/src/lib/libast/common/features/uwin
@@ -0,0 +1,6 @@
+lib a64l,acosh,asinh,atanh,cbrt,ceil,crypt,erf,exp,expm1,floor
+lib gamma,getpass,lgamma,log,log1p,random,rcmd,rint,srand48
+lib copysign,logb,finite,drem,sqrt,ilogb,remainder,scalb
+lib _copysign,_finite,_scalb,__iob_func,_p__iob
+
+dat _iob
diff --git a/usr/src/lib/libast/common/features/vfork b/usr/src/lib/libast/common/features/vfork
new file mode 100644
index 0000000000..f1a0ea7d15
--- /dev/null
+++ b/usr/src/lib/libast/common/features/vfork
@@ -0,0 +1,13 @@
+set prototyped
+hdr vfork
+sys vfork
+
+tst run{
+ if test "$_hdr_vfork" = 1
+ then echo "#include <vfork.h>"
+ elif test "$_sys_vfork" = 1
+ then echo "#include <sys/vfork.h>"
+ else echo '#include <unistd.h>' > $tmp.c
+ $cc -E $tmp.c | grep vfork
+ fi
+}end
diff --git a/usr/src/lib/libast/common/features/vmalloc b/usr/src/lib/libast/common/features/vmalloc
new file mode 100644
index 0000000000..cc33c8f81f
--- /dev/null
+++ b/usr/src/lib/libast/common/features/vmalloc
@@ -0,0 +1,163 @@
+#
+# This file defines probes for local features that vmalloc requires.
+# Such probes are interpreted by the "iffe" language interpreter.
+# Results are stored in the FEATURE directory. Some of the
+# {lib,hdr,sys,typ} tests may also be done in the AST features/lib;
+# repeating them here allows for single standalone and AST sources.
+#
+
+ref -D_def_map_ast=1
+
+lib atexit,getpagesize,mallinfo,mallopt,memalign,mstats
+lib onexit,pvalloc,strdup,valloc,vmalloc
+lib _malloc,__malloc,__libc_malloc
+hdr alloca,malloc,stat,stdlib,unistd
+mem mallinfo.arena,mstats.bytes_total malloc.h
+sys stat
+typ ssize_t
+
+tst mem_sbrk note{ brk()/sbrk() work as expected }end execute{
+ #include <sys/types.h>
+ #include <unistd.h>
+ #undef uchar
+ #define uchar unsigned char
+ int main()
+ { uchar *brk0, *brk1;
+
+ /* allocate a big chunk */
+ if(!(brk0 = (uchar*)sbrk(0)) || brk0 == (uchar*)(-1))
+ return 1;
+ brk0 += 256*1024;
+ if(brk(brk0) != 0)
+ return 1;
+ if((brk1 = (uchar*)sbrk(0)) != brk0)
+ return 1;
+
+ /* now return half of it */
+ brk1 -= 128*1024;
+ if(brk(brk1) != 0 )
+ return 1;
+ if((brk0 = (uchar*)sbrk(0)) != brk1)
+ return 1;
+
+ return 0;
+ }
+}end
+
+tst map_malloc note{ map malloc to _ast_malloc }end noexecute{
+ #if __CYGWIN__
+ int main() { return 1; }
+ #else
+ static int user = 0;
+ _BEGIN_EXTERNS_
+ #if _lib_strdup
+ extern char* strdup _ARG_((const char*));
+ #define LOCAL() strdup("s")
+ #else
+ extern void* calloc _ARG_((unsigned int, unsigned int));
+ #define LOCAL() calloc(1,1)
+ #endif
+ #if __CYGWIN__
+ #define extern __declspec(dllexport)
+ #endif
+ #define HT double
+ static HT heap[1024 * 4];
+ static HT* hp = &heap[1];
+ static HT* op;
+ #define MALLOC(n) if(user)return&heap[0];op=hp;hp+=(n+sizeof(HT)-1)/sizeof(HT);return(void*)op;
+ #define INTERCEPTED(p) (((char*)(p))==((char*)&heap[0]))
+ #if _STD_
+ extern void free(void* p) { }
+ extern void _free(void* p) { }
+ extern void __free(void* p) { }
+ extern void __libc_free(void* p) { }
+ extern void* malloc(unsigned int n) { MALLOC(n); }
+ extern void* _malloc(unsigned int n) { MALLOC(n); }
+ extern void* __malloc(unsigned int n) { MALLOC(n); }
+ extern void* __libc_malloc(unsigned int n) { MALLOC(n); }
+ #else
+ extern void free(p) char* p; { }
+ extern void _free(p) char* p; { }
+ extern void __free(p) char* p; { }
+ extern void __libc_free(p) char* p; { }
+ extern void* malloc(n) unsigned int n; { MALLOC(n); }
+ extern void* _malloc(n) unsigned int n; { MALLOC(n); }
+ extern void* __malloc(n) unsigned int n; { MALLOC(n); }
+ extern void* __libc_malloc(n) unsigned int n; { MALLOC(n); }
+ #endif
+ _END_EXTERNS_
+ int main() { user = 1; return !INTERCEPTED(LOCAL()); }
+ #endif
+}end
+
+tst map_malloc note{ map malloc to _ast_malloc -- wimp-o mach? }end noexecute{
+ #if _map_malloc
+ int main() { return 0; }
+ #else
+ _BEGIN_EXTERNS_
+ #if _STD_
+ void* calloc(unsigned n, unsigned m) { exit(1); }
+ #else
+ void* calloc(n, m) unsigned n, m; { exit(1); }
+ #endif
+ _END_EXTERNS_
+ int main() { return 0; }
+ #endif
+}end
+
+lib alloca note{ alloca exists }end link{
+ #if _hdr_alloca
+ #include <alloca.h>
+ #endif
+ int
+ main()
+ { alloca(10);
+ }
+}end
+
+tst mal_alloca note{ alloca is based on malloc() }end execute{
+ #if _hdr_alloca
+ #include <alloca.h>
+ #endif
+ #if _STD_
+ void* malloc(unsigned int size)
+ #else
+ void* malloc(size) unsigned int size;
+ #endif
+ { exit(0);
+ return 0;
+ }
+ int main()
+ { alloca(10);
+ return 1;
+ }
+}end
+
+tst stk_down note{ stack grows downward }end execute{
+ static growdown()
+ { static char* addr = 0;
+ char array[4];
+ if(!addr)
+ { addr = &array[0];
+ return growdown();
+ }
+ else if(addr < &array[0])
+ return 0;
+ else return 1;
+ }
+ int main() { return growdown() ? 0 : 1; }
+}end
+
+cat{
+ #include "FEATURE/mmap"
+ #if _BLD_INSTRUMENT || cray || _UWIN && _BLD_ast
+ #undef _map_malloc
+ #define _std_malloc 1 /* defer to standard malloc */
+ #endif
+ #if _mmap_anon
+ #define _mem_mmap_anon 1
+ #endif
+ #if _mmap_devzero
+ #define _mem_mmap_zero 1
+ #endif
+}end
diff --git a/usr/src/lib/libast/common/features/wait b/usr/src/lib/libast/common/features/wait
new file mode 100644
index 0000000000..74c8c8119a
--- /dev/null
+++ b/usr/src/lib/libast/common/features/wait
@@ -0,0 +1,9 @@
+lib wait,wait2,wait3,wait4,waitpid
+tst ok_wif sys/types.h sys/wait.h note{ posix wait macros ok }end compile{
+ int ifexited = WIFEXITED(0);
+ int exitstatus = WEXITSTATUS(0);
+ int ifsignaled = WIFSIGNALED(0);
+ int termsig = WTERMSIG(0);
+ int ifstopped = WIFSTOPPED(0);
+ int stopsig = WSTOPSIG(0);
+}end
diff --git a/usr/src/lib/libast/common/features/wchar b/usr/src/lib/libast/common/features/wchar
new file mode 100644
index 0000000000..0c2199e8ef
--- /dev/null
+++ b/usr/src/lib/libast/common/features/wchar
@@ -0,0 +1,111 @@
+set prototyped
+lib mbstowcs,wctomb,wcrtomb,wcslen,wcstombs,wcwidth stdlib.h stdio.h wchar.h
+lib towlower,towupper stdlib.h stdio.h wchar.h
+typ mbstate_t stdlib.h stdio.h wchar.h
+nxt wchar
+
+run{
+cat <<!
+ #ifndef _SFSTDIO_H
+ #include <ast_common.h>
+ #include <stdio.h>
+ #endif
+ #if _hdr_wchar && defined(_nxt_wchar)
+ #include $_nxt_wchar /* the native wchar.h */
+ #endif
+ #if _hdr_wctype
+ #include <wctype.h>
+ #endif
+
+ #ifndef WEOF
+ #define WEOF (-1)
+ #endif
+
+ #undef fgetwc
+ #undef fgetws
+ #undef fputwc
+ #undef fputws
+ #undef getwc
+ #undef getwchar
+ #undef getws
+ #undef putwc
+ #undef putwchar
+ #undef ungetwc
+
+ #define fgetwc _ast_fgetwc
+ #define fgetws _ast_fgetws
+ #define fputwc _ast_fputwc
+ #define fputws _ast_fputws
+ #define fwide _ast_fwide
+ #define fwprintf _ast_fwprintf
+ #define fwscanf _ast_fwscanf
+ #define getwc _ast_getwc
+ #define getwchar _ast_getwchar
+ #define getws _ast_getws
+ #define putwc _ast_putwc
+ #define putwchar _ast_putwchar
+ #define swprintf _ast_swprintf
+ #define swscanf _ast_swscanf
+ #define ungetwc _ast_ungetwc
+ #define vfwprintf _ast_vfwprintf
+ #define vfwscanf _ast_vfwscanf
+ #define vswprintf _ast_vswprintf
+ #define vswscanf _ast_vswscanf
+ #define vwprintf _ast_vwprintf
+ #define vwscanf _ast_vwscanf
+ #define wprintf _ast_wprintf
+ #define wscanf _ast_wscanf
+
+ #if !_typ_mbstate_t
+ #undef _typ_mbstate_t
+ #define _typ_mbstate_t 1
+ typedef char mbstate_t;
+ #endif
+
+ #if _BLD_ast && defined(__EXPORT__)
+ #define extern __EXPORT__
+ #endif
+
+ #if !_lib_mbstowcs
+ extern size_t mbstowcs(wchar_t*, const char*, size_t);
+ #endif
+ #if !_lib_wctomb
+ extern int wctomb(char*, wchar_t);
+ #endif
+ #if !_lib_wcrtomb
+ extern size_t wcrtomb(char*, wchar_t, mbstate_t*);
+ #endif
+ #if !_lib_wcslen
+ extern size_t wcslen(const wchar_t*);
+ #endif
+ #if !_lib_wcstombs
+ extern size_t wcstombs(char*, const wchar_t*, size_t);
+ #endif
+
+ extern int fwprintf(FILE*, const wchar_t*, ...);
+ extern int fwscanf(FILE*, const wchar_t*, ...);
+ extern wint_t fgetwc(FILE*);
+ extern wchar_t* fgetws(wchar_t*, int, FILE*);
+ extern wint_t fputwc(wchar_t, FILE*);
+ extern int fputws(const wchar_t*, FILE*);
+ extern int fwide(FILE*, int);
+ extern wint_t getwc(FILE*);
+ extern wint_t getwchar(void);
+ extern wchar_t* getws(wchar_t*);
+ extern wint_t putwc(wchar_t, FILE*);
+ extern wint_t putwchar(wchar_t);
+ extern int swprintf(wchar_t*, size_t, const wchar_t*, ...);
+ extern int swscanf(const wchar_t*, const wchar_t*, ...);
+ extern wint_t ungetwc(wint_t, FILE*);
+ extern int vfwprintf(FILE*, const wchar_t*, va_list);
+ extern int vfwscanf(FILE*, const wchar_t*, va_list);
+ extern int vwprintf(const wchar_t*, va_list);
+ extern int vwscanf(const wchar_t*, va_list);
+ extern int vswprintf(wchar_t*, size_t, const wchar_t*, va_list);
+ extern int vswscanf(const wchar_t*, const wchar_t*, va_list);
+ extern int wprintf(const wchar_t*, ...);
+ extern int wscanf(const wchar_t*, ...);
+
+ #undef extern
+!
+}end
diff --git a/usr/src/lib/libast/common/hash/hashalloc.c b/usr/src/lib/libast/common/hash/hashalloc.c
new file mode 100644
index 0000000000..f920439f86
--- /dev/null
+++ b/usr/src/lib/libast/common/hash/hashalloc.c
@@ -0,0 +1,200 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * hash table library
+ */
+
+static const char id_hash[] = "\n@(#)$Id: hash (AT&T Research) 1996-08-11 $\0\n";
+
+#include "hashlib.h"
+
+Hash_info_t hash_info = { 0 };
+
+/*
+ * create a new hash table
+ */
+
+Hash_table_t*
+hashalloc(Hash_table_t* ref, ...)
+{
+ register Hash_table_t* tab;
+ register Hash_table_t* ret = 0;
+ register int internal;
+ int n;
+ va_list ap;
+ va_list va[4];
+ va_list* vp = va;
+ Hash_region_f region = 0;
+ void* handle;
+
+ va_start(ap, ref);
+
+ /*
+ * check for HASH_region which must be first
+ */
+
+ n = va_arg(ap, int);
+ if (!ref && n == HASH_region)
+ {
+ region = va_arg(ap, Hash_region_f);
+ handle = va_arg(ap, void*);
+ n = va_arg(ap, int);
+ if (!(tab = (Hash_table_t*)(*region)(handle, NiL, sizeof(Hash_table_t), 0)))
+ goto out;
+ memset(tab, 0, sizeof(Hash_table_t));
+ }
+ else if (!(tab = newof(0, Hash_table_t, 1, 0)))
+ goto out;
+ tab->bucketsize = (sizeof(Hash_header_t) + sizeof(char*) - 1) / sizeof(char*);
+ if (ref)
+ {
+ tab->flags = ref->flags & ~HASH_RESET;
+ tab->root = ref->root;
+ internal = HASH_INTERNAL;
+ }
+ else
+ {
+ if (region)
+ {
+ if (!(tab->root = (Hash_root_t*)(*region)(handle, NiL, sizeof(Hash_root_t), 0)))
+ goto out;
+ memset(tab->root, 0, sizeof(Hash_root_t));
+ }
+ else if (!(tab->root = newof(0, Hash_root_t, 1, 0)))
+ goto out;
+ if (!(tab->root->local = newof(0, Hash_local_t, 1, 0)))
+ goto out;
+ if (tab->root->local->region = region)
+ tab->root->local->handle = handle;
+ tab->root->meanchain = HASHMEANCHAIN;
+ internal = 0;
+ }
+ tab->size = HASHMINSIZE;
+ for (;;)
+ {
+ switch (n)
+ {
+ case HASH_alloc:
+ if (ref) goto out;
+ tab->root->local->alloc = va_arg(ap, Hash_alloc_f);
+ break;
+ case HASH_bucketsize:
+ n = (va_arg(ap, int) + sizeof(char*) - 1) / sizeof(char*);
+ if (n > UCHAR_MAX) goto out;
+ if (n > tab->bucketsize) tab->bucketsize = n;
+ break;
+ case HASH_clear:
+ tab->flags &= ~(va_arg(ap, int) & ~internal);
+ break;
+ case HASH_compare:
+ if (ref) goto out;
+ tab->root->local->compare = va_arg(ap, Hash_compare_f);
+ break;
+ case HASH_free:
+ if (ref) goto out;
+ tab->root->local->free = va_arg(ap, Hash_free_f);
+ break;
+ case HASH_hash:
+ if (ref) goto out;
+ tab->root->local->hash = va_arg(ap, Hash_hash_f);
+ break;
+ case HASH_meanchain:
+ if (ref) goto out;
+ tab->root->meanchain = va_arg(ap, int);
+ break;
+ case HASH_name:
+ tab->name = va_arg(ap, char*);
+ break;
+ case HASH_namesize:
+ if (ref) goto out;
+ tab->root->namesize = va_arg(ap, int);
+ break;
+ case HASH_region:
+ goto out;
+ case HASH_set:
+ tab->flags |= (va_arg(ap, int) & ~internal);
+ break;
+ case HASH_size:
+ tab->size = va_arg(ap, int);
+ if (tab->size & (tab->size - 1)) tab->flags |= HASH_FIXED;
+ break;
+ case HASH_table:
+ tab->table = va_arg(ap, Hash_bucket_t**);
+ tab->flags |= HASH_STATIC;
+ break;
+ case HASH_va_list:
+ if (vp < &va[elementsof(va)])
+ {
+ va_copy(*vp, ap);
+ vp++;
+ }
+ va_copy(ap, va_listval(va_arg(ap, va_listarg)));
+ break;
+ case 0:
+ if (vp > va)
+ {
+ vp--;
+ va_copy(ap, *vp);
+ break;
+ }
+ if (tab->flags & HASH_SCOPE)
+ {
+ if (!(tab->scope = ref)) goto out;
+ ref->frozen++;
+ }
+ if (!tab->table)
+ {
+ if (region)
+ {
+ if (!(tab->table = (Hash_bucket_t**)(*region)(handle, NiL, sizeof(Hash_bucket_t*) * tab->size, 0)))
+ goto out;
+ memset(tab->table, 0, sizeof(Hash_bucket_t*) * tab->size);
+ }
+ else if (!(tab->table = newof(0, Hash_bucket_t*, tab->size, 0))) goto out;
+ }
+ if (!ref)
+ {
+ tab->root->flags = tab->flags & HASH_INTERNAL;
+ tab->root->next = hash_info.list;
+ hash_info.list = tab->root;
+ }
+ if (!region)
+ {
+ tab->next = tab->root->references;
+ tab->root->references = tab;
+ }
+ ret = tab;
+ goto out;
+ default:
+ goto out;
+ }
+ n = va_arg(ap, int);
+ }
+ out:
+ va_end(ap);
+ if (!ret) hashfree(tab);
+ return(ret);
+}
diff --git a/usr/src/lib/libast/common/hash/hashdump.c b/usr/src/lib/libast/common/hash/hashdump.c
new file mode 100644
index 0000000000..b1dad4d4b5
--- /dev/null
+++ b/usr/src/lib/libast/common/hash/hashdump.c
@@ -0,0 +1,173 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * hash table library
+ */
+
+#include "hashlib.h"
+
+/*
+ * dump HASH_* flags
+ */
+
+static void
+dumpflags(register int flags)
+{
+ if (flags & HASH_ALLOCATE) sfprintf(sfstderr, "allocate ");
+ if (flags & HASH_BUCKET) sfprintf(sfstderr, "bucket ");
+ if (flags & HASH_FIXED) sfprintf(sfstderr, "fixed ");
+ if (flags & HASH_HASHED) sfprintf(sfstderr, "hashed ");
+ if (flags & HASH_RESIZE) sfprintf(sfstderr, "resize ");
+ if (flags & HASH_STATIC) sfprintf(sfstderr, "static ");
+ if (flags & HASH_VALUE) sfprintf(sfstderr, "value ");
+}
+
+/*
+ * dump hash table bucket info
+ */
+
+static void
+dumpbucket(register Hash_table_t* tab, int flags)
+{
+ register Hash_bucket_t** sp;
+ register Hash_bucket_t* b;
+ Hash_bucket_t** sx;
+ int n;
+ unsigned char* s;
+
+ NoP(flags);
+ sx = tab->table + tab->size;
+ for (sp = tab->table; sp < sx; sp++)
+ {
+ n = 0;
+ for (b = *sp; b; b = b->next)
+ if (!(b->hash & HASH_DELETED) && (!(tab->flags & HASH_VALUE) || b->value))
+ n++;
+ if (n)
+ {
+ sfprintf(sfstderr, "%5d %2d :", sp - tab->table, n);
+ for (b = *sp; b; b = b->next)
+ if (!(b->hash & HASH_DELETED) && (!(tab->flags & HASH_VALUE) || b->value))
+ {
+ if (n = tab->root->namesize)
+ {
+ sfprintf(sfstderr, " 0x");
+ s = (unsigned char*)hashname(b);
+ while (n-- > 0)
+ sfprintf(sfstderr, "%02x", *s++);
+ }
+ else sfprintf(sfstderr, " %s", hashname(b));
+ if (b->hash & HASH_FLAGS)
+ {
+ sfprintf(sfstderr, "|");
+ if (b->hash & HASH_HIDES) sfprintf(sfstderr, "hides|");
+ if (b->hash & HASH_HIDDEN) sfprintf(sfstderr, "hidden|");
+ if (b->hash & HASH_KEEP) sfprintf(sfstderr, "keep|");
+ if (b->hash & HASH_OPAQUED) sfprintf(sfstderr, "opaque|");
+ }
+ if (tab->flags & HASH_VALUE) sfprintf(sfstderr, "=0x%08lx", (long)b->value);
+ }
+ sfprintf(sfstderr, "\n");
+ }
+ }
+ sfprintf(sfstderr, "\n");
+}
+
+/*
+ * dump info on a single table
+ */
+
+static void
+dumptable(register Hash_table_t* tab, register int flags)
+{
+ Hash_table_t* scope;
+ int level;
+
+ sfprintf(sfstderr, " name: %s", tab->name ? tab->name : "*no name*");
+ if (scope = tab->scope)
+ {
+ level = 1;
+ while (scope = scope->scope) level++;
+ sfprintf(sfstderr, " level %d scope on 0x%08lx", level, (unsigned long)tab->scope);
+ }
+ sfprintf(sfstderr, "\n");
+ sfprintf(sfstderr, " address: 0x%08lx\n", (unsigned long)tab);
+ sfprintf(sfstderr, " flags: ");
+ if (tab->frozen) sfprintf(sfstderr, "frozen=%d ", tab->frozen);
+ dumpflags(tab->flags);
+ sfprintf(sfstderr, "\n");
+ sfprintf(sfstderr, " size: %d\n", tab->size);
+ sfprintf(sfstderr, " buckets: %d\n", tab->buckets);
+ sfprintf(sfstderr, " bucketsize: %d\n", tab->bucketsize * sizeof(char*));
+ sfprintf(sfstderr, "\n");
+ if ((flags | tab->flags) & HASH_BUCKET) dumpbucket(tab, flags);
+}
+
+/*
+ * dump hash table root info
+ */
+
+static void
+dumproot(register Hash_root_t* root, register int flags)
+{
+ register Hash_table_t* tab;
+
+ sfprintf(sfstderr, " root\n");
+ sfprintf(sfstderr, " address: 0x%08lx\n", (unsigned long)root);
+ sfprintf(sfstderr, " flags: ");
+ dumpflags(root->flags);
+ if (root->namesize) sfprintf(sfstderr, "namesize=%d ", root->namesize);
+ if (root->local->alloc) sfprintf(sfstderr, "alloc=0x%08lx ", (unsigned long)root->local->alloc);
+ if (root->local->compare) sfprintf(sfstderr, "compare=0x%08lx ", (unsigned long)root->local->compare);
+ if (root->local->free) sfprintf(sfstderr, "free=0x%08lx ", (unsigned long)root->local->free);
+ if (root->local->hash) sfprintf(sfstderr, "hash=0x%08lx ", (unsigned long)root->local->hash);
+ if (root->local->region) sfprintf(sfstderr, "region=0x%08lx handle=0x%08lx ", (unsigned long)root->local->region, (unsigned long)root->local->handle);
+ sfprintf(sfstderr, "\n");
+ sfprintf(sfstderr, " meanchain: %d\n", root->meanchain);
+ sfprintf(sfstderr, " accesses: %d\n", root->accesses);
+ sfprintf(sfstderr, " collisions: %d\n", root->collisions);
+ sfprintf(sfstderr, "\n");
+ for (tab = root->references; tab; tab = tab->next)
+ dumptable(tab, flags);
+}
+
+/*
+ * dump hash table accounting info
+ * if tab is 0 then dump all tables in hash_info.list
+ * flags are HASH_* flags that specifiy optional dump info
+ */
+
+void
+hashdump(register Hash_table_t* tab, int flags)
+{
+ register Hash_root_t* root;
+
+ sfprintf(sfstderr, "\nhash table information:\n\n");
+ if (tab) dumproot(tab->root, flags);
+ else for (root = hash_info.list; root; root = root->next)
+ dumproot(root, flags);
+ sfsync(sfstderr);
+}
diff --git a/usr/src/lib/libast/common/hash/hashfree.c b/usr/src/lib/libast/common/hash/hashfree.c
new file mode 100644
index 0000000000..8b54e7af3e
--- /dev/null
+++ b/usr/src/lib/libast/common/hash/hashfree.c
@@ -0,0 +1,144 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * hash table library
+ */
+
+#include "hashlib.h"
+
+/*
+ * free (remove) a hash table
+ * can be called for partially constructed tables
+ * scope covered table pointer is returned
+ * root info freed when last reference freed
+ */
+
+Hash_table_t*
+hashfree(register Hash_table_t* tab)
+{
+ register Hash_bucket_t** sp;
+ register Hash_bucket_t* b;
+ register Hash_bucket_t* p;
+ Hash_bucket_t** sx;
+ Hash_root_t* rp;
+ Hash_table_t* tp;
+ Hash_free_f freevalue;
+ Hash_free_f freebucket;
+ Hash_region_f region;
+ void* handle;
+
+ if (!tab) return(0);
+ if (tab->table)
+ {
+ freebucket = 0;
+ freevalue = 0;
+ if (tab->root->local->free)
+ {
+ if (tab->root->flags & HASH_BUCKET) freebucket = tab->root->local->free;
+ else freevalue = tab->root->local->free;
+ }
+ if (region = tab->root->local->region)
+ handle = tab->root->local->handle;
+ sx = &tab->table[tab->size];
+ sp = &tab->table[0];
+ while (sp < sx)
+ {
+ b = *sp++;
+ while (b)
+ {
+ p = b;
+ b = b->next;
+ if (freebucket) (*freebucket)((char*)p);
+ else if (freevalue && p->value) (*freevalue)(p->value);
+ if (p->hash & HASH_FREENAME)
+ {
+ p->hash &= ~HASH_FREENAME;
+ if (region) (*region)(handle, p->name, 0, 0);
+ else free(p->name);
+ }
+ if (!(p->hash & HASH_KEEP))
+ {
+ if (region) (*region)(handle, p, 0, 0);
+ else free(p);
+ }
+ else if (p->hash & HASH_HIDES)
+ {
+ p->hash &= ~HASH_HIDES;
+ p->name = ((Hash_bucket_t*)p->name)->name;
+ }
+ }
+ }
+ if ((tab->flags & (HASH_RESIZE|HASH_STATIC)) != HASH_STATIC)
+ {
+ if (region) (*region)(handle, tab->table, 0, 0);
+ else free(tab->table);
+ }
+ }
+ else region = 0;
+ if (tab->root)
+ {
+ if (!region)
+ {
+ /*
+ * remove from the table lists
+ */
+
+ if ((tp = tab->root->references) != tab)
+ {
+ for (; tp; tp = tp->next)
+ if (tp->next == tab)
+ {
+ tp->next = tab->next;
+ break;
+ }
+ }
+ else if (!(tab->root->references = tp->next))
+ {
+ if ((rp = hash_info.list) != tab->root)
+ {
+ for (; rp; rp = rp->next)
+ if (rp->next == tab->root)
+ {
+ rp->next = tab->root->next;
+ break;
+ }
+ }
+ else hash_info.list = rp->next;
+ }
+ }
+ if (!(tab->root->references))
+ {
+ if (tab->root->local)
+ free(tab->root->local);
+ if (region) (*region)(handle, tab->root, 0, 0);
+ else free(tab->root);
+ }
+ }
+ if (tp = tab->scope) tp->frozen--;
+ if (region) (*region)(handle, tab, 0, 0);
+ else free(tab);
+ return(tp);
+}
diff --git a/usr/src/lib/libast/common/hash/hashlast.c b/usr/src/lib/libast/common/hash/hashlast.c
new file mode 100644
index 0000000000..b6e7c65006
--- /dev/null
+++ b/usr/src/lib/libast/common/hash/hashlast.c
@@ -0,0 +1,43 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/* OBSOLETE 19960229 -- use tab->root->last.{table|bucket} */
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * hash table library
+ */
+
+#include "hashlib.h"
+
+/*
+ * return last lookup bucket for table
+ */
+
+Hash_bucket_t*
+hashlast(Hash_table_t* tab)
+{
+ return(tab->root->last.bucket);
+}
diff --git a/usr/src/lib/libast/common/hash/hashlib.h b/usr/src/lib/libast/common/hash/hashlib.h
new file mode 100644
index 0000000000..226e6a9ea1
--- /dev/null
+++ b/usr/src/lib/libast/common/hash/hashlib.h
@@ -0,0 +1,104 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * hash table library private definitions
+ */
+
+#ifndef _HASHLIB_H
+#define _HASHLIB_H
+
+#include <ast.h>
+
+#define hash_info _hash_info_
+
+typedef void* (*Hash_alloc_f)(size_t);
+typedef int (*Hash_compare_f)(const char*, const char*, ...);
+typedef unsigned int (*Hash_hash_f)(const char*, ...);
+typedef void (*Hash_free_f)(void*);
+typedef void* (*Hash_region_f)(void*, void*, size_t, int);
+
+typedef struct /* root local pointers */
+{
+ Hash_hash_f hash; /* name hash routine */
+ Hash_compare_f compare; /* name comparision routine */
+ Hash_alloc_f alloc; /* value allocation routine */
+ Hash_free_f free; /* value free routine */
+ Hash_region_f region; /* region alloc/free routine */
+ void* handle; /* region handle arg */
+} Hash_local_t;
+
+#define _HASH_POSITION_PRIVATE_ \
+ Hash_table_t* tab; /* table pointer */ \
+ int flags; /* scan flags */ \
+ Hash_bucket_t** slot; /* table slot */ \
+ Hash_bucket_t** limit; /* slot limit */
+
+#define _HASH_LAST_PRIVATE_ \
+ const char* name; /* last lookup name */ \
+ unsigned int hash; /* last lookup hash */
+
+#define _HASH_ROOT_PRIVATE_ \
+ int namesize; /* fixed name size: 0 => string */ \
+ int meanchain; /* resize mean chain length */ \
+ Hash_local_t* local; /* root local pointers */ \
+ Hash_root_t* next; /* next in list of all roots */ \
+ Hash_table_t* references; /* referencing table list */
+
+#define _HASH_TABLE_PRIVATE_ \
+ unsigned char frozen; /* table freeze nesting */ \
+ unsigned char bucketsize; /* min bucket size in char*'s */ \
+ Hash_bucket_t** table; /* hash slot table */ \
+ Hash_table_t* next; /* root reference list link */
+
+#include <hash.h>
+
+#define HASHMINSIZE (1<<4) /* min table slots (power of 2) */
+#define HASHMEANCHAIN 2 /* def resize mean chain len */
+
+#define HASHMOD(t,h) (h &= (t->size - 1))
+#define HASHVAL(x) ((x)&~HASH_FLAGS)
+
+#define HASH(r,n,h) if (r->local->hash) h = r->namesize ? (*r->local->hash)(n, r->namesize) : (*r->local->hash)(n);\
+ else\
+ {\
+ register const char* _hash_s1 = n;\
+ h = 0;\
+ if (r->namesize)\
+ {\
+ register const char* _hash_s2 = _hash_s1 + r->namesize;\
+ while (_hash_s1 < _hash_s2) HASHPART(h, *_hash_s1++);\
+ }\
+ else while (*_hash_s1) HASHPART(h, *_hash_s1++);\
+ }
+
+typedef struct /* library private info */
+{
+ Hash_root_t* list; /* root table list */
+} Hash_info_t;
+
+extern Hash_info_t hash_info;
+
+#endif
diff --git a/usr/src/lib/libast/common/hash/hashlook.c b/usr/src/lib/libast/common/hash/hashlook.c
new file mode 100644
index 0000000000..ed8aef3e4b
--- /dev/null
+++ b/usr/src/lib/libast/common/hash/hashlook.c
@@ -0,0 +1,366 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * hash table library
+ */
+
+#include "hashlib.h"
+
+/*
+ * hash table lookup
+ */
+
+char*
+hashlook(register Hash_table_t* tab, const char* name, long flags, const char* value)
+{
+ register Hash_bucket_t* b;
+ register unsigned int n;
+ register Hash_last_t* last;
+ Hash_table_t* top;
+ Hash_bucket_t* prev;
+ unsigned int i;
+
+ if ((flags & (HASH_LOOKUP|HASH_INTERNAL)) == (HASH_LOOKUP|HASH_INTERNAL))
+ {
+ register char* s1;
+ register const char* s2;
+ register int c;
+
+ if (flags & HASH_HASHED) n = *((unsigned int*)value);
+ else
+ {
+ s2 = name;
+ n = 0;
+ while (c = *s2++) HASHPART(n, c);
+ }
+ i = n;
+ for (;;)
+ {
+ HASHMOD(tab, n);
+ for (b = tab->table[n]; b; b = b->next)
+ {
+ s1 = hashname(b);
+ s2 = name;
+ while ((c = *s1++) == *s2++)
+ if (!c) return((flags & HASH_VALUE) ? b->value : (char*)b);
+ }
+ if (!(tab = tab->scope) || (flags & HASH_NOSCOPE))
+ return(0);
+ n = i;
+ }
+ }
+ tab->root->accesses++;
+ top = tab;
+ last = &tab->root->last;
+ if (name)
+ {
+ last->table = tab;
+ if (flags & (HASH_BUCKET|HASH_INSTALL))
+ {
+ last->bucket = (Hash_bucket_t*)name;
+ name = hashname(last->bucket);
+ }
+ else last->bucket = 0;
+ last->name = name;
+ if (flags & HASH_BUCKET) n = last->bucket->hash;
+ else if (tab->flags & HASH_HASHED)
+ {
+ n = (unsigned int)integralof(name);
+ if (!(flags & HASH_HASHED)) n >>= 3;
+ }
+ else if (flags & HASH_HASHED) n = *((unsigned int*)value);
+ else HASH(tab->root, name, n);
+ last->hash = i = HASHVAL(n);
+ for (;;)
+ {
+ HASHMOD(tab, n);
+ for (prev = 0, b = tab->table[n]; b; prev = b, b = b->next)
+ {
+ if (i == HASHVAL(b->hash) && ((b->hash & (HASH_DELETED|HASH_OPAQUED)) != HASH_DELETED || (flags & (HASH_CREATE|HASH_DELETE|HASH_INSTALL|HASH_RENAME))))
+ {
+ if (!tab->root->local->compare)
+ {
+ register char* s1 = hashname(b);
+ register const char* s2 = name;
+
+ if (tab->root->namesize)
+ {
+ register char* s3 = s1 + tab->root->namesize;
+
+ while (*s1++ == *s2++)
+ if (s1 >= s3) goto found;
+ }
+ else while (*s1 == *s2++)
+ if (!*s1++) goto found;
+ }
+ else if (tab->root->namesize)
+ {
+ if (!(*tab->root->local->compare)(hashname(b), name, tab->root->namesize)) goto found;
+ }
+ else if (!(*tab->root->local->compare)(hashname(b), name)) goto found;
+ }
+ tab->root->collisions++;
+ }
+ if (!tab->scope || (flags & (HASH_CREATE|HASH_INSTALL|HASH_NOSCOPE)) == HASH_NOSCOPE) break;
+ tab = tab->scope;
+ n = i;
+ }
+ }
+ else
+ {
+ tab = last->table;
+ name = last->name;
+ n = i = last->hash;
+ prev = 0;
+ HASHMOD(tab, n);
+ if (b = last->bucket)
+ {
+ /*
+ * found the bucket
+ */
+
+ found:
+ if (prev && !tab->frozen)
+ {
+ /*
+ * migrate popular buckets to the front
+ */
+
+ prev->next = b->next;
+ b->next = tab->table[n];
+ tab->table[n] = b;
+ }
+ switch (flags & (HASH_CREATE|HASH_DELETE|HASH_INSTALL|HASH_RENAME))
+ {
+ case HASH_CREATE:
+ case HASH_CREATE|HASH_INSTALL:
+ case HASH_INSTALL:
+ if (tab != top && !(flags & HASH_SCOPE)) break;
+ if (flags & HASH_OPAQUE) b->hash |= HASH_OPAQUED;
+ goto exists;
+
+ case HASH_DELETE:
+ value = 0;
+ if (tab == top || (flags & HASH_SCOPE))
+ {
+ if (flags & HASH_OPAQUE) b->hash &= ~HASH_OPAQUED;
+ else if (!(tab->root->flags & HASH_BUCKET))
+ {
+ if (tab->root->local->free && b->value)
+ {
+ (*tab->root->local->free)(b->value);
+ b->value = 0;
+ }
+ else if (tab->flags & HASH_VALUE)
+ {
+ value = b->value;
+ b->value = 0;
+ }
+ }
+ tab->buckets--;
+ if (tab->frozen || (b->hash & HASH_OPAQUED)) b->hash |= HASH_DELETED;
+ else
+ {
+ tab->table[n] = b->next;
+ name = (b->hash & HASH_FREENAME) ? (char*)b->name : (char*)0;
+ if (tab->root->local->free && (tab->root->flags & HASH_BUCKET)) (*tab->root->local->free)((char*)b);
+ else if (!(b->hash & HASH_KEEP))
+ {
+ if (tab->root->local->region) (*tab->root->local->region)(tab->root->local->handle, b, 0, 0);
+ else free(b);
+ }
+ if (name)
+ {
+ if (tab->root->local->region) (*tab->root->local->region)(tab->root->local->handle, (char*)name, 0, 0);
+ else free((char*)name);
+ }
+ }
+ }
+ return((char*)value);
+
+ case HASH_RENAME:
+ if (tab != top || tab->frozen || (b->hash & (HASH_KEEP|HASH_OPAQUED)) || hashlook(top, value, (flags&(HASH_HASHED|HASH_INTERNAL))|HASH_LOOKUP, NiL))
+ return(0);
+ name = (char*)b->name;
+ if (!(tab->flags & HASH_ALLOCATE)) b->name = (char*)value;
+ else if (b->name && tab->root->namesize)
+ {
+ memcpy(b->name, value, tab->root->namesize);
+ name = 0;
+ }
+ else
+ {
+ int m;
+ char* t;
+
+ if (!(i = tab->bucketsize))
+ i = (sizeof(Hash_bucket_t) + sizeof(char*) - 1) / sizeof(char*);
+ i *= sizeof(char*);
+ if (b->name == ((char*)b + i) && strlen(b->name) <= (m = strlen(value)))
+ {
+ strcpy(b->name, value);
+ name = 0;
+ }
+ else
+ {
+ m++;
+ if (!(t = tab->root->local->region ? (char*)(*tab->root->local->region)(tab->root->local->handle, NiL, m, 0) : (char*)malloc(m)))
+ return(0);
+ b->name = strcpy(t, value);
+ }
+ }
+ if (name && (b->hash & HASH_FREENAME))
+ {
+ b->hash &= ~HASH_FREENAME;
+ if (tab->root->local->region) (*tab->root->local->region)(tab->root->local->handle, (char*)name, 0, 0);
+ else free((char*)name);
+ }
+ tab->buckets--;
+ tab->table[n] = b->next;
+ flags = HASH_CREATE|HASH_INSTALL;
+ last->bucket = b;
+ i = last->hash;
+ goto create;
+
+ default:
+ if (!(b->hash & HASH_DELETED)) goto exists;
+ return(0);
+ }
+ }
+ }
+ if (!(flags & (HASH_CREATE|HASH_INSTALL))) return(0);
+
+ /*
+ * create a new bucket
+ */
+
+ create:
+ if (tab == top) prev = 0;
+ else
+ {
+ if (prev = b)
+ {
+ name = (b->hash & HASH_HIDES) ? b->name : (char*)b;
+ i |= HASH_HIDES;
+ }
+ if (!(flags & HASH_SCOPE)) tab = top;
+ }
+
+ /*
+ * check for table expansion
+ */
+
+ if (!tab->frozen && !(tab->flags & HASH_FIXED) && tab->buckets > tab->root->meanchain * tab->size)
+ hashsize(tab, tab->size << 1);
+ if (flags & HASH_INSTALL)
+ {
+ b = last->bucket;
+ i |= HASH_KEEP;
+ }
+ else
+ {
+ int m = tab->bucketsize * sizeof(char*);
+
+ if (flags & HASH_VALUE)
+ {
+ tab->flags |= HASH_VALUE;
+ if (m < sizeof(Hash_bucket_t))
+ {
+ tab->bucketsize = (sizeof(Hash_bucket_t) + sizeof(char*) - 1) / sizeof(char*);
+ m = tab->bucketsize * sizeof(char*);
+ }
+ n = m;
+ }
+ else if (!(n = HASH_SIZEOF(flags)))
+ {
+ if (!(flags & HASH_FIXED)) n = m;
+ else if ((n = (int)integralof(value)) < m) n = m;
+ }
+ else if (n < m) n = m;
+ if (!prev && (tab->flags & HASH_ALLOCATE))
+ {
+ m = tab->root->namesize ? tab->root->namesize : strlen(name) + 1;
+ if (tab->root->local->region)
+ {
+ if (!(b = (Hash_bucket_t*)(*tab->root->local->region)(tab->root->local->handle, NiL, n + m, 0)))
+ return(0);
+ memset(b, 0, n + m);
+ }
+ else if (!(b = newof(0, Hash_bucket_t, 0, n + m)))
+ return(0);
+ b->name = (char*)b + n;
+ memcpy(b->name, name, m);
+ }
+ else
+ {
+ if (tab->root->local->region)
+ {
+ if (!(b = (Hash_bucket_t*)(*tab->root->local->region)(tab->root->local->handle, NiL, n, 0)))
+ return(0);
+ memset(b, 0, n);
+ }
+ else if (!(b = newof(0, Hash_bucket_t, 0, n)))
+ return(0);
+ b->name = (char*)name;
+ }
+ }
+ b->hash = n = i;
+ HASHMOD(tab, n);
+ b->next = tab->table[n];
+ tab->table[n] = b;
+ tab->buckets++;
+ if (flags & HASH_OPAQUE)
+ {
+ tab->buckets--;
+ b->hash |= HASH_DELETED|HASH_OPAQUED;
+ return(0);
+ }
+
+ /*
+ * finally got the bucket
+ */
+
+ exists:
+ if (b->hash & HASH_DELETED)
+ {
+ b->hash &= ~HASH_DELETED;
+ tab->buckets++;
+ }
+ last->bucket = b;
+ last->table = tab;
+ switch (flags & (HASH_CREATE|HASH_VALUE))
+ {
+ case HASH_CREATE|HASH_VALUE:
+ if (tab->root->local->free && !(tab->root->flags & HASH_BUCKET) && b->value) (*tab->root->local->free)(b->value);
+ if (value && tab->root->local->alloc) value = (*tab->root->local->alloc)((unsigned int)integralof(value));
+ b->value = (char*)value;
+ return((char*)hashname(b));
+ case HASH_VALUE:
+ return(b->value);
+ default:
+ return((char*)b);
+ }
+}
diff --git a/usr/src/lib/libast/common/hash/hashscan.c b/usr/src/lib/libast/common/hash/hashscan.c
new file mode 100644
index 0000000000..9443307b3a
--- /dev/null
+++ b/usr/src/lib/libast/common/hash/hashscan.c
@@ -0,0 +1,139 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * hash table library
+ */
+
+#include "hashlib.h"
+
+/*
+ * hash table sequential scan
+ *
+ * Hash_position_t* pos;
+ * Hash_bucket_t* b;
+ * pos = hashscan(tab, flags);
+ * while (b = hashnext(&pos)) ...;
+ * hashdone(pos);
+ */
+
+/*
+ * return pos for scan on table
+ */
+
+Hash_position_t*
+hashscan(register Hash_table_t* tab, register int flags)
+{
+ register Hash_position_t* pos;
+
+ static Hash_bucket_t empty;
+
+ if (!(pos = newof(0, Hash_position_t, 1, 0))) return(0);
+ pos->tab = tab->root->last.table = tab;
+ pos->bucket = &empty;
+ pos->slot = tab->table - 1;
+ pos->limit = tab->table + tab->size;
+ if (tab->scope && !(flags & HASH_NOSCOPE))
+ {
+ pos->flags = HASH_SCOPE;
+ do
+ {
+ register Hash_bucket_t* b;
+
+ if (tab->frozen)
+ {
+ register Hash_bucket_t** sp = tab->table;
+ register Hash_bucket_t** sx = tab->table + tab->size;
+
+ while (sp < sx)
+ for (b = *sp++; b; b = b->next)
+ b->hash &= ~HASH_HIDDEN;
+ }
+ } while (tab = tab->scope);
+ tab = pos->tab;
+ }
+ else pos->flags = 0;
+ tab->frozen++;
+ return(pos);
+}
+
+/*
+ * return next scan element
+ */
+
+Hash_bucket_t*
+hashnext(register Hash_position_t* pos)
+{
+ register Hash_bucket_t* b;
+
+ if (!pos) return(pos->tab->root->last.bucket = 0);
+ b = pos->bucket;
+ for (;;)
+ {
+ if (!(b = b->next))
+ {
+ do
+ {
+ if (++pos->slot >= pos->limit)
+ {
+ pos->tab->frozen--;
+ if (!pos->flags || !pos->tab->scope) return(0);
+ pos->tab = pos->tab->scope;
+ pos->tab->root->last.table = pos->tab;
+ pos->limit = (pos->slot = pos->tab->table) + pos->tab->size;
+ pos->tab->frozen++;
+ }
+ } while (!(b = *pos->slot));
+ }
+ if (!(b->hash & HASH_DELETED) && (!(pos->tab->flags & HASH_VALUE) || b->value) && (!pos->flags || !(b->hash & (HASH_HIDDEN|HASH_HIDES)))) break;
+ if (b->hash & HASH_HIDES)
+ {
+ register Hash_bucket_t* h = (Hash_bucket_t*)b->name;
+
+ if (!(h->hash & HASH_HIDDEN))
+ {
+ h->hash |= HASH_HIDDEN;
+ if (!(b->hash & HASH_DELETED)) break;
+ }
+ }
+ else b->hash &= ~HASH_HIDDEN;
+ }
+ return(pos->tab->root->last.bucket = pos->bucket = b);
+}
+
+/*
+ * terminate scan
+ */
+
+void
+hashdone(register Hash_position_t* pos)
+{
+ if (pos)
+ {
+ if (pos->tab->frozen)
+ pos->tab->frozen--;
+ free(pos);
+ }
+}
diff --git a/usr/src/lib/libast/common/hash/hashsize.c b/usr/src/lib/libast/common/hash/hashsize.c
new file mode 100644
index 0000000000..504f931ad9
--- /dev/null
+++ b/usr/src/lib/libast/common/hash/hashsize.c
@@ -0,0 +1,84 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * hash table library
+ */
+
+#include "hashlib.h"
+
+/*
+ * change table size and rehash
+ * size must be a power of 2
+ */
+
+void
+hashsize(register Hash_table_t* tab, int size)
+{
+ register Hash_bucket_t** old_s;
+ register Hash_bucket_t** new_s;
+ register Hash_bucket_t* old_b;
+ register Hash_bucket_t* new_b;
+ Hash_bucket_t** old_sx;
+ unsigned int index;
+ Hash_region_f region;
+ void* handle;
+
+ if (size > 0 && size != tab->size && !(size & (size - 1)))
+ {
+ if (region = tab->root->local->region)
+ {
+ handle = tab->root->local->handle;
+ new_s = (Hash_bucket_t**)(*region)(handle, NiL, sizeof(Hash_bucket_t*) * size, 0);
+ }
+ else new_s = newof(0, Hash_bucket_t*, size, 0);
+ if (!new_s) tab->flags |= HASH_FIXED;
+ else
+ {
+ old_sx = (old_s = tab->table) + tab->size;
+ tab->size = size;
+ while (old_s < old_sx)
+ {
+ old_b = *old_s++;
+ while (old_b)
+ {
+ new_b = old_b;
+ old_b = old_b->next;
+ index = new_b->hash;
+ HASHMOD(tab, index);
+ new_b->next = new_s[index];
+ new_s[index] = new_b;
+ }
+ }
+ if ((tab->flags & (HASH_RESIZE|HASH_STATIC)) != HASH_STATIC)
+ {
+ if (region) (*region)(handle, tab->table, 0, 0);
+ else free(tab->table);
+ }
+ tab->table = new_s;
+ tab->flags |= HASH_RESIZE;
+ }
+ }
+}
diff --git a/usr/src/lib/libast/common/hash/hashview.c b/usr/src/lib/libast/common/hash/hashview.c
new file mode 100644
index 0000000000..5aa230d3c7
--- /dev/null
+++ b/usr/src/lib/libast/common/hash/hashview.c
@@ -0,0 +1,88 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * hash table library
+ */
+
+#include "hashlib.h"
+
+/*
+ * push/pop/query hash table scope
+ *
+ * bot==0 pop top scope
+ * bot==top query
+ * bot!=0 push top on bot
+ *
+ * scope table pointer returned
+ */
+
+Hash_table_t*
+hashview(Hash_table_t* top, Hash_table_t* bot)
+{
+ register Hash_bucket_t* b;
+ register Hash_bucket_t* p;
+ register Hash_bucket_t** sp;
+ register Hash_bucket_t** sx;
+
+ if (!top || top->frozen)
+ bot = 0;
+ else if (top == bot)
+ bot = top->scope;
+ else if (bot)
+ {
+ if (top->scope)
+ bot = 0;
+ else
+ {
+ sx = &top->table[top->size];
+ sp = &top->table[0];
+ while (sp < sx)
+ for (b = *sp++; b; b = b->next)
+ if (p = (Hash_bucket_t*)hashlook(bot, b->name, HASH_LOOKUP, NiL))
+ {
+ b->name = (p->hash & HASH_HIDES) ? p->name : (char*)b;
+ b->hash |= HASH_HIDES;
+ }
+ top->scope = bot;
+ bot->frozen++;
+ }
+ }
+ else if (bot = top->scope)
+ {
+ sx = &top->table[top->size];
+ sp = &top->table[0];
+ while (sp < sx)
+ for (b = *sp++; b; b = b->next)
+ if (b->hash & HASH_HIDES)
+ {
+ b->hash &= ~HASH_HIDES;
+ b->name = ((Hash_bucket_t*)b->name)->name;
+ }
+ top->scope = 0;
+ bot->frozen--;
+ }
+ return(bot);
+}
diff --git a/usr/src/lib/libast/common/hash/hashwalk.c b/usr/src/lib/libast/common/hash/hashwalk.c
new file mode 100644
index 0000000000..fe79808d9d
--- /dev/null
+++ b/usr/src/lib/libast/common/hash/hashwalk.c
@@ -0,0 +1,51 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * hash table library
+ */
+
+#include "hashlib.h"
+
+/*
+ * apply walker to each active bucket in the table
+ */
+
+int
+hashwalk(Hash_table_t* tab, int flags, register int (*walker)(const char*, char*, void*), void* handle)
+{
+ register Hash_bucket_t* b;
+ register int v;
+ Hash_position_t* pos;
+
+ if (!(pos = hashscan(tab, flags)))
+ return(-1);
+ v = 0;
+ while (b = hashnext(pos))
+ if ((v = (*walker)(hashname(b), (tab->flags & HASH_VALUE) ? b->value : (char*)b, handle)) < 0)
+ break;
+ hashdone(pos);
+ return(v);
+}
diff --git a/usr/src/lib/libast/common/hash/memhash.c b/usr/src/lib/libast/common/hash/memhash.c
new file mode 100644
index 0000000000..8c8fd15203
--- /dev/null
+++ b/usr/src/lib/libast/common/hash/memhash.c
@@ -0,0 +1,45 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * hash table library
+ */
+
+#include "hashlib.h"
+
+/*
+ * return the hash of buffer s of length n
+ */
+
+unsigned int
+memhash(const void* as, int n)
+{
+ register const unsigned char* s = (const unsigned char*)as;
+ register const unsigned char* e = s + n;
+ register unsigned int c = 0;
+
+ while (s < e) HASHPART(c, *s++);
+ return(c);
+}
diff --git a/usr/src/lib/libast/common/hash/memsum.c b/usr/src/lib/libast/common/hash/memsum.c
new file mode 100644
index 0000000000..78de588e6c
--- /dev/null
+++ b/usr/src/lib/libast/common/hash/memsum.c
@@ -0,0 +1,53 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * hash table library
+ */
+
+#include "hashlib.h"
+
+/*
+ * return a running 32 bit checksum of buffer b of length n
+ *
+ * c is the return value from a previous
+ * memsum() or strsum() call, 0 on the first call
+ *
+ * the result is the same on all implementations
+ */
+
+unsigned long
+memsum(const void* ap, int n, register unsigned long c)
+{
+ register const unsigned char* p = (const unsigned char*)ap;
+ register const unsigned char* e = p + n;
+
+ while (p < e) HASHPART(c, *p++);
+#if LONG_MAX > 2147483647
+ return(c & 0xffffffff);
+#else
+ return(c);
+#endif
+}
diff --git a/usr/src/lib/libast/common/hash/strhash.c b/usr/src/lib/libast/common/hash/strhash.c
new file mode 100644
index 0000000000..27d954b8fc
--- /dev/null
+++ b/usr/src/lib/libast/common/hash/strhash.c
@@ -0,0 +1,45 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * hash table library
+ */
+
+#include "hashlib.h"
+
+/*
+ * return the hash of the null terminated string s
+ */
+
+unsigned int
+strhash(const char* as)
+{
+ register const unsigned char* s = (const unsigned char*)as;
+ register unsigned int i = 0;
+ register unsigned int c;
+
+ while (c = *s++) HASHPART(i, c);
+ return(i);
+}
diff --git a/usr/src/lib/libast/common/hash/strkey.c b/usr/src/lib/libast/common/hash/strkey.c
new file mode 100644
index 0000000000..59f8a7310a
--- /dev/null
+++ b/usr/src/lib/libast/common/hash/strkey.c
@@ -0,0 +1,49 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ */
+
+#include <ast.h>
+#include <hashkey.h>
+
+long
+strkey(register const char* s)
+{
+ register long x = 0;
+ register int n = 0;
+ register int c;
+
+ while (n++ < HASHKEYMAX)
+ {
+ c = *s;
+ if (c >= 'a' && c <= 'z')
+ x = HASHKEYPART(x, c);
+ else if (c >= '0' && c <= '9')
+ x = HASHKEYPART(x, HASHKEYN(c));
+ else break;
+ s++;
+ }
+ return x;
+}
diff --git a/usr/src/lib/libast/common/hash/strsum.c b/usr/src/lib/libast/common/hash/strsum.c
new file mode 100644
index 0000000000..7881b87263
--- /dev/null
+++ b/usr/src/lib/libast/common/hash/strsum.c
@@ -0,0 +1,53 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * hash table library
+ */
+
+#include "hashlib.h"
+
+/*
+ * return a running 32 bit checksum of string s
+ *
+ * c is the return value from a previous
+ * memsum() or strsum() call, 0 on the first call
+ *
+ * the result is the same on all implementations
+ */
+
+unsigned long
+strsum(const char* as, register unsigned long c)
+{
+ register const unsigned char* s = (const unsigned char*)as;
+ register int n;
+
+ while (n = *s++) HASHPART(c, n);
+#if LONG_MAX > 2147483647
+ return(c & 0xffffffff);
+#else
+ return(c);
+#endif
+}
diff --git a/usr/src/lib/libast/common/include/ast.h b/usr/src/lib/libast/common/include/ast.h
new file mode 100644
index 0000000000..6c35bd418b
--- /dev/null
+++ b/usr/src/lib/libast/common/include/ast.h
@@ -0,0 +1,362 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Advanced Software Technology Library
+ * AT&T Research
+ *
+ * std + posix + ast
+ */
+
+#ifndef _AST_H
+#define _AST_H
+
+#include <ast_version.h>
+
+#ifndef _AST_STD_H
+#include <ast_std.h>
+#endif
+
+#ifndef _SFIO_H
+#include <sfio.h>
+#endif
+
+#ifndef ast
+#define ast _ast_info
+#endif
+
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif
+
+/*
+ * workaround botched headers that assume <stdio.h>
+ */
+
+#ifndef FILE
+#ifndef _SFIO_H
+struct _sfio_s;
+#endif
+#define FILE struct _sfio_s
+#ifndef __FILE_typedef
+#define __FILE_typedef 1
+#endif
+#ifndef _FILEDEFED
+#define _FILEDEFED 1
+#endif
+#endif
+
+/*
+ * exit() support -- this matches shell exit codes
+ */
+
+#define EXIT_BITS 8 /* # exit status bits */
+
+#define EXIT_USAGE 2 /* usage exit code */
+#define EXIT_QUIT ((1<<(EXIT_BITS))-1) /* parent should quit */
+#define EXIT_NOTFOUND ((1<<(EXIT_BITS-1))-1) /* command not found */
+#define EXIT_NOEXEC ((1<<(EXIT_BITS-1))-2) /* other exec error */
+
+#define EXIT_CODE(x) ((x)&((1<<EXIT_BITS)-1))
+#define EXIT_CORE(x) (EXIT_CODE(x)|(1<<EXIT_BITS)|(1<<(EXIT_BITS-1)))
+#define EXIT_TERM(x) (EXIT_CODE(x)|(1<<EXIT_BITS))
+
+/*
+ * NOTE: for compatibility the following work for EXIT_BITS={7,8}
+ */
+
+#define EXIT_STATUS(x) (((x)&((1<<(EXIT_BITS-2))-1))?(x):EXIT_CODE((x)>>EXIT_BITS))
+
+#define EXITED_CORE(x) (((x)&((1<<EXIT_BITS)|(1<<(EXIT_BITS-1))))==((1<<EXIT_BITS)|(1<<(EXIT_BITS-1)))||((x)&((1<<(EXIT_BITS-1))|(1<<(EXIT_BITS-2))))==((1<<(EXIT_BITS-1))|(1<<(EXIT_BITS-2))))
+#define EXITED_TERM(x) ((x)&((1<<EXIT_BITS)|(1<<(EXIT_BITS-1))))
+
+/*
+ * astconflist() flags
+ */
+
+#define ASTCONF_parse 0x0001
+#define ASTCONF_write 0x0002
+#define ASTCONF_read 0x0004
+#define ASTCONF_lower 0x0008
+#define ASTCONF_base 0x0010
+#define ASTCONF_defined 0x0020
+#define ASTCONF_quote 0x0040
+#define ASTCONF_table 0x0080
+#define ASTCONF_matchcall 0x0100
+#define ASTCONF_matchname 0x0200
+#define ASTCONF_matchstandard 0x0400
+#define ASTCONF_error 0x0800
+#define ASTCONF_system 0x1000
+#define ASTCONF_AST 0x2000
+
+/*
+ * pathcanon() flags
+ */
+
+#define PATH_PHYSICAL 01
+#define PATH_DOTDOT 02
+#define PATH_EXISTS 04
+#define PATH_VERIFIED(n) (((n)&01777)<<5)
+
+/*
+ * pathaccess() flags
+ */
+
+#define PATH_READ 004
+#define PATH_WRITE 002
+#define PATH_EXECUTE 001
+#define PATH_REGULAR 010
+#define PATH_ABSOLUTE 020
+
+/*
+ * touch() flags
+ */
+
+#define PATH_TOUCH_CREATE 01
+#define PATH_TOUCH_VERBATIM 02
+
+/*
+ * pathcheck() info
+ */
+
+typedef struct
+{
+ unsigned long date;
+ char* feature;
+ char* host;
+ char* user;
+} Pathcheck_t;
+
+/*
+ * strgrpmatch() flags
+ */
+
+#define STR_MAXIMAL 01 /* maximal match */
+#define STR_LEFT 02 /* implicit left anchor */
+#define STR_RIGHT 04 /* implicit right anchor */
+#define STR_ICASE 010 /* ignore case */
+#define STR_GROUP 020 /* (|&) inside [@|&](...) only */
+
+/*
+ * fmtquote() flags
+ */
+
+#define FMT_ALWAYS 0x01 /* always quote */
+#define FMT_ESCAPED 0x02 /* already escaped */
+#define FMT_SHELL 0x04 /* escape $ ` too */
+#define FMT_WIDE 0x08 /* don't escape 8 bit chars */
+#define FMT_PARAM 0x10 /* disable FMT_SHELL ${$( quote */
+
+/*
+ * multibyte macros
+ */
+
+#define mbmax() (ast.mb_cur_max)
+#define mberr() (ast.tmp_int<0)
+
+#define mbcoll() (ast.mb_xfrm!=0)
+#define mbwide() (mbmax()>1)
+
+#define mbchar(p) (mbwide()?((ast.tmp_int=(*ast.mb_towc)(&ast.tmp_wchar,(char*)(p),mbmax()))>0?((p+=ast.tmp_int),ast.tmp_wchar):(p++,ast.tmp_int)):(*(unsigned char*)(p++)))
+#define mbinit() (mbwide()?(*ast.mb_towc)((wchar_t*)0,(char*)0,mbmax()):0)
+#define mbsize(p) (mbwide()?(*ast.mb_len)((char*)(p),mbmax()):((p),1))
+#define mbconv(s,w) (ast.mb_conv?(*ast.mb_conv)(s,w):((*(s)=(w)),1))
+#define mbwidth(w) (ast.mb_width&&((ast.tmp_int=(*ast.mb_width)(w))>=0||(w)>UCHAR_MAX)?ast.tmp_int:1)
+#define mbxfrm(t,f,n) (mbcoll()?(*ast.mb_xfrm)((char*)(t),(char*)(f),n):0)
+
+/*
+ * common macros
+ */
+
+#define elementsof(x) (sizeof(x)/sizeof(x[0]))
+#define integralof(x) (((char*)(x))-((char*)0))
+#define newof(p,t,n,x) ((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)calloc(1,sizeof(t)*(n)+(x)))
+#define oldof(p,t,n,x) ((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)malloc(sizeof(t)*(n)+(x)))
+#define pointerof(x) ((void*)((char*)0+(x)))
+#define roundof(x,y) (((x)+(y)-1)&~((y)-1))
+#define ssizeof(x) ((int)sizeof(x))
+
+#define streq(a,b) (*(a)==*(b)&&!strcmp(a,b))
+#define strneq(a,b,n) (*(a)==*(b)&&!strncmp(a,b,n))
+#define strsignal(s) fmtsignal(s)
+
+#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
+#define NiL 0
+#define NoP(x) (void)(x)
+#else
+#define NiL ((char*)0)
+#define NoP(x) (&x,1)
+#endif
+
+#if !defined(NoF)
+#define NoF(x) void _DATA_ ## x () {}
+#if !defined(_DATA_)
+#define _DATA_
+#endif
+#endif
+
+#if !defined(NoN)
+#define NoN(x) void _STUB_ ## x () {}
+#if !defined(_STUB_)
+#define _STUB_
+#endif
+#endif
+
+#define NOT_USED(x) NoP(x)
+
+typedef int (*Error_f)(void*, void*, int, ...);
+
+typedef int (*Ast_confdisc_f)(const char*, const char*, const char*);
+typedef int (*Strcmp_context_f)(const char*, const char*, void*);
+typedef int (*Strcmp_f)(const char*, const char*);
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern char* astgetconf(const char*, const char*, const char*, int, Error_f);
+extern char* astconf(const char*, const char*, const char*);
+extern Ast_confdisc_f astconfdisc(Ast_confdisc_f);
+extern void astconflist(Sfio_t*, const char*, int, const char*);
+extern off_t astcopy(int, int, off_t);
+extern int astlicense(char*, int, char*, char*, int, int, int);
+extern int astquery(int, const char*, ...);
+extern void astwinsize(int, int*, int*);
+
+extern ssize_t base64encode(const void*, size_t, void**, void*, size_t, void**);
+extern ssize_t base64decode(const void*, size_t, void**, void*, size_t, void**);
+extern int chresc(const char*, char**);
+extern int chrtoi(const char*);
+extern int eaccess(const char*, int);
+extern char* fmtbase(long, int, int);
+extern char* fmtbasell(intmax_t, int, int);
+#define fmtbase(a,b,c) fmtbasell((intmax_t)(a),b,c) /* until 2003-09-01 */
+extern char* fmtbuf(size_t);
+extern char* fmtclock(Sfulong_t);
+extern char* fmtelapsed(unsigned long, int);
+extern char* fmterror(int);
+extern char* fmtesc(const char*);
+extern char* fmtesq(const char*, const char*);
+extern char* fmtident(const char*);
+extern char* fmtip4(uint32_t, int);
+extern char* fmtfmt(const char*);
+extern char* fmtgid(int);
+extern char* fmtmatch(const char*);
+extern char* fmtmode(int, int);
+extern char* fmtnesq(const char*, const char*, size_t);
+extern char* fmtnum(unsigned long, int);
+extern char* fmtperm(int);
+extern char* fmtquote(const char*, const char*, const char*, size_t, int);
+extern char* fmtre(const char*);
+extern char* fmtscale(Sfulong_t, int);
+extern char* fmtsignal(int);
+extern char* fmttime(const char*, time_t);
+extern char* fmtuid(int);
+extern char* fmtversion(unsigned long);
+extern void* memdup(const void*, size_t);
+extern void memfatal(void);
+extern unsigned int memhash(const void*, int);
+extern unsigned long memsum(const void*, int, unsigned long);
+extern char* pathaccess(char*, const char*, const char*, const char*, int);
+extern char* pathbin(void);
+extern char* pathcanon(char*, int);
+extern char* pathcat(char*, const char*, int, const char*, const char*);
+extern int pathcd(const char*, const char*);
+extern int pathcheck(const char*, const char*, Pathcheck_t*);
+extern int pathexists(char*, int);
+extern char* pathfind(const char*, const char*, const char*, char*, size_t);
+extern int pathgetlink(const char*, char*, int);
+extern int pathinclude(const char*);
+extern char* pathkey(char*, char*, const char*, const char*, const char*);
+extern size_t pathnative(const char*, char*, size_t);
+extern char* pathpath(char*, const char*, const char*, int);
+extern size_t pathposix(const char*, char*, size_t);
+extern char* pathprobe(char*, char*, const char*, const char*, const char*, int);
+extern char* pathrepl(char*, const char*, const char*);
+extern int pathsetlink(const char*, const char*);
+extern char* pathshell(void);
+extern char* pathtemp(char*, size_t, const char*, const char*, int*);
+extern char* pathtmp(char*, const char*, const char*, int*);
+extern char* setenviron(const char*);
+extern int stracmp(const char*, const char*);
+extern char* strcopy(char*, const char*);
+extern unsigned long strelapsed(const char*, char**, int);
+extern int stresc(char*);
+extern long streval(const char*, char**, long(*)(const char*, char**));
+extern long strexpr(const char*, char**, long(*)(const char*, char**, void*), void*);
+extern int strgid(const char*);
+extern int strgrpmatch(const char*, const char*, int*, int, int);
+extern unsigned int strhash(const char*);
+extern void* strlook(const void*, size_t, const char*);
+extern int strmatch(const char*, const char*);
+extern int strmode(const char*);
+extern int strnacmp(const char*, const char*, size_t);
+extern char* strncopy(char*, const char*, size_t);
+extern double strntod(const char*, size_t, char**);
+extern _ast_fltmax_t strntold(const char*, size_t, char**);
+extern long strntol(const char*, size_t, char**, int);
+extern intmax_t strntoll(const char*, size_t, char**, int);
+extern unsigned long strntoul(const char*, size_t, char**, int);
+extern uintmax_t strntoull(const char*, size_t, char**, int);
+extern int stropt(const char*, const void*, int, int(*)(void*, const void*, int, const char*), void*);
+extern int strperm(const char*, char**, int);
+extern void* strpsearch(const void*, size_t, size_t, const char*, char**);
+extern void* strsearch(const void*, size_t, size_t, Strcmp_f, const char*, void*);
+extern void strsort(char**, int, int(*)(const char*, const char*));
+extern char* strsubmatch(const char*, const char*, int);
+extern unsigned long strsum(const char*, unsigned long);
+extern char* strtape(const char*, char**);
+extern int strtoip4(const char*, char**, uint32_t*, unsigned char*);
+extern long strton(const char*, char**, char*, int);
+extern intmax_t strtonll(const char*, char**, char*, int);
+extern int struid(const char*);
+extern int struniq(char**, int);
+
+#undef extern
+
+/*
+ * C library global data symbols not prototyped by <unistd.h>
+ */
+
+#if !defined(environ) && defined(__DYNAMIC__)
+#define environ __DYNAMIC__(environ)
+#else
+extern char** environ;
+#endif
+
+/*
+ * really handy malloc()/free() (__FILE__,__LINE__,__FUNCTION__) tracing
+ * make with VMDEBUG==1 or debug=1 or CCFLAGS=$(CC.DEBUG)
+ * VMDEBUG==0 disables
+ * at runtime export VMDEBUG or VMTRACE per vmalloc.3
+ * to list originating call locations
+ */
+
+#if !_std_malloc && !defined(VMFL) && !defined(_VMHDR_H) && \
+ (!defined(VMDEBUG) || VMDEBUG) && (VMDEBUG || _BLD_DEBUG)
+
+#define VMFL 1
+#include <vmalloc.h>
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/include/ast_dir.h b/usr/src/lib/libast/common/include/ast_dir.h
new file mode 100644
index 0000000000..1d92240c2c
--- /dev/null
+++ b/usr/src/lib/libast/common/include/ast_dir.h
@@ -0,0 +1,77 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * AT&T Research
+ *
+ * common dirent maintenance interface
+ */
+
+#ifndef _AST_DIR_H
+#define _AST_DIR_H
+
+#include <ast_lib.h>
+
+#if _mem_d_fileno_dirent || _mem_d_ino_dirent
+#if !_mem_d_fileno_dirent
+#undef _mem_d_fileno_dirent
+#define _mem_d_fileno_dirent 1
+#define d_fileno d_ino
+#endif
+#endif
+
+#if _BLD_ast
+#include "dirlib.h"
+#else
+#include <dirent.h>
+#endif
+
+#if _mem_d_fileno_dirent
+#define D_FILENO(d) ((d)->d_fileno)
+#endif
+
+#if _mem_d_namlen_dirent
+#define D_NAMLEN(d) ((d)->d_namlen)
+#else
+#define D_NAMLEN(d) (strlen((d)->d_name))
+#endif
+
+#if _mem_d_reclen_dirent
+#define D_RECLEN(d) ((d)->d_reclen)
+#else
+#define D_RECLEN(d) D_RECSIZ(d,D_NAMLEN(d))
+#endif
+
+#define D_RECSIZ(d,n) (sizeof(*(d))-sizeof((d)->d_name)+((n)+sizeof(char*))&~(sizeof(char*)-1))
+
+/*
+ * NOTE: 2003-03-27 mac osx bug symlink==DT_REG bug discovered;
+ * the kernel *and* all directories must be fixed, so d_type
+ * is summarily disabled until we see that happen
+ */
+
+#if _mem_d_type_dirent && defined(DT_UNKNOWN) && defined(DT_REG) && defined(DT_DIR) && defined(DT_LNK) && ! ( __APPLE__ || __MACH__ )
+#define D_TYPE(d) ((d)->d_type)
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/include/ast_getopt.h b/usr/src/lib/libast/common/include/ast_getopt.h
new file mode 100644
index 0000000000..26673deed7
--- /dev/null
+++ b/usr/src/lib/libast/common/include/ast_getopt.h
@@ -0,0 +1,42 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * legacy standard getopt interface
+ */
+
+#ifndef _AST_GETOPT_H
+#define _AST_GETOPT_H 1
+
+extern int opterr;
+extern int optind;
+extern int optopt;
+extern char* optarg;
+
+#ifndef NULL /* in case <stdlib.h> or <stdio.h> got here first */
+
+extern int getopt(int, char* const*, const char*);
+extern int getsubopt(char**, char* const*, char**);
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/include/ast_std.h b/usr/src/lib/libast/common/include/ast_std.h
new file mode 100644
index 0000000000..431be6e02b
--- /dev/null
+++ b/usr/src/lib/libast/common/include/ast_std.h
@@ -0,0 +1,327 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Advanced Software Technology Library
+ * AT&T Research
+ *
+ * a union of standard headers that works
+ * with local extensions enabled
+ * and local omission compensation
+ */
+
+#ifndef _AST_STD_H
+#define _AST_STD_H 1
+#define _AST_STD_I 1
+
+#include <ast_common.h>
+
+#if _BLD_ast
+#define _BLD_cdt 1
+#define _BLD_sfio 1
+#if !_UWIN
+#define _BLD_vmalloc 1
+#endif
+#endif
+
+#ifdef _SFSTDIO_H
+#define _SKIP_SFSTDIO_H
+#else
+#define _SFSTDIO_H
+#ifndef FILE
+#ifndef _SFIO_H
+struct _sfio_s;
+#endif
+#define FILE struct _sfio_s
+#ifndef __FILE_typedef
+#define __FILE_typedef 1
+#endif
+#ifndef _FILEDEFED
+#define _FILEDEFED 1
+#endif
+#endif
+#endif
+
+#include <ast_lib.h>
+#include <ast_sys.h>
+#include <ast_getopt.h> /* <stdlib.h> does this */
+#include <ast_fcntl.h>
+#include <ast_limits.h>
+#include <ast_botch.h>
+
+#ifdef _SKIP_SFSTDIO_H
+#undef _SKIP_SFSTDIO_H
+#else
+#undef _SFSTDIO_H
+#undef FILE
+#endif
+
+/* locale stuff */
+
+#if !_hdr_locale
+
+struct lconv
+{
+ char* decimal_point;
+ char* thousands_sep;
+ char* grouping;
+ char* int_curr_symbol;
+ char* currency_symbol;
+ char* mon_decimal_point;
+ char* mon_thousands_sep;
+ char* mon_grouping;
+ char* positive_sign;
+ char* negative_sign;
+ char int_frac_digits;
+ char frac_digits;
+ char p_cs_precedes;
+ char p_sep_by_space;
+ char n_cs_precedes;
+ char n_sep_by_space;
+ char p_sign_posn;
+ char n_sign_posn;
+};
+
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+#undef localeconv
+#define localeconv _ast_localeconv
+
+#undef setlocale
+#define setlocale _ast_setlocale
+
+#undef strerror
+#define strerror _ast_strerror
+
+extern struct lconv* localeconv(void);
+extern char* setlocale(int, const char*);
+extern char* strerror(int);
+
+#define AST_MESSAGE_SET 3 /* see <mc.h> mcindex() */
+
+/*
+ * maintain this order when adding categories
+ */
+
+#define AST_LC_ALL 0
+#define AST_LC_COLLATE 1
+#define AST_LC_CTYPE 2
+#define AST_LC_MESSAGES 3
+#define AST_LC_MONETARY 4
+#define AST_LC_NUMERIC 5
+#define AST_LC_TIME 6
+#define AST_LC_IDENTIFICATION 7
+#define AST_LC_ADDRESS 8
+#define AST_LC_NAME 9
+#define AST_LC_TELEPHONE 10
+#define AST_LC_XLITERATE 11
+#define AST_LC_MEASUREMENT 12
+#define AST_LC_PAPER 13
+#define AST_LC_COUNT 14
+
+#define AST_LC_find (1L<<28)
+#define AST_LC_debug (1L<<29)
+#define AST_LC_setlocale (1L<<30)
+#define AST_LC_translate (1L<<31)
+
+#ifndef LC_ALL
+#define LC_ALL (-AST_LC_ALL)
+#endif
+#ifndef LC_COLLATE
+#define LC_COLLATE (-AST_LC_COLLATE)
+#endif
+#ifndef LC_CTYPE
+#define LC_CTYPE (-AST_LC_CTYPE)
+#endif
+#ifndef LC_MESSAGES
+#define LC_MESSAGES (-AST_LC_MESSAGES)
+#endif
+#ifndef LC_MONETARY
+#define LC_MONETARY (-AST_LC_MONETARY)
+#endif
+#ifndef LC_NUMERIC
+#define LC_NUMERIC (-AST_LC_NUMERIC)
+#endif
+#ifndef LC_TIME
+#define LC_TIME (-AST_LC_TIME)
+#endif
+#ifndef LC_ADDRESS
+#define LC_ADDRESS (-AST_LC_ADDRESS)
+#endif
+#ifndef LC_IDENTIFICATION
+#define LC_IDENTIFICATION (-AST_LC_IDENTIFICATION)
+#endif
+#ifndef LC_NAME
+#define LC_NAME (-AST_LC_NAME)
+#endif
+#ifndef LC_TELEPHONE
+#define LC_TELEPHONE (-AST_LC_TELEPHONE)
+#endif
+#ifndef LC_XLITERATE
+#define LC_XLITERATE (-AST_LC_XLITERATE)
+#endif
+#ifndef LC_MEASUREMENT
+#define LC_MEASUREMENT (-AST_LC_MEASUREMENT)
+#endif
+#ifndef LC_PAPER
+#define LC_PAPER (-AST_LC_PAPER)
+#endif
+
+#undef extern
+
+#undef strcoll
+#if _std_strcoll
+#define strcoll _ast_info.collate
+#else
+#define strcoll strcmp
+#endif
+
+typedef struct
+{
+
+ char* id;
+
+ struct
+ {
+ uint32_t serial;
+ uint32_t set;
+ } locale;
+
+ long tmp_long;
+ size_t tmp_size;
+ short tmp_short;
+ char tmp_char;
+ wchar_t tmp_wchar;
+
+ int (*collate)(const char*, const char*);
+
+ int tmp_int;
+ void* tmp_pointer;
+
+ int mb_cur_max;
+ int (*mb_len)(const char*, size_t);
+ int (*mb_towc)(wchar_t*, const char*, size_t);
+ size_t (*mb_xfrm)(char*, const char*, size_t);
+ int (*mb_width)(wchar_t);
+ int (*mb_conv)(char*, wchar_t);
+
+ uint32_t env_serial;
+
+ char pad[944];
+
+} _Ast_info_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#define extern extern __IMPORT__
+#endif
+
+extern _Ast_info_t _ast_info;
+
+#undef extern
+
+/* largefile hackery -- ast uses the large versions by default */
+
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if !defined(ftruncate) && _lib_ftruncate64
+#define ftruncate ftruncate64
+extern int ftruncate64(int, off64_t);
+#endif
+#if !defined(lseek) && _lib_lseek64
+#define lseek lseek64
+extern off64_t lseek64(int, off64_t, int);
+#endif
+#if !defined(truncate) && _lib_truncate64
+#define truncate truncate64
+extern int truncate64(const char*, off64_t);
+#endif
+
+/* direct macro access for bsd crossover */
+
+#if !defined(__cplusplus)
+
+#if !defined(memcpy) && !defined(_lib_memcpy) && defined(_lib_bcopy)
+#define memcpy(t,f,n) (bcopy(f,t,n),(t))
+#endif
+
+#if !defined(memzero) && !defined(_lib_memzero)
+#if defined(_lib_memset) || !defined(_lib_bzero)
+#define memzero(b,n) memset(b,0,n)
+#else
+#define memzero(b,n) (bzero(b,n),(b))
+#endif
+#endif
+
+#endif
+
+#if !defined(remove)
+extern int remove(const char*);
+#endif
+
+#if !defined(rename)
+extern int rename(const char*, const char*);
+#endif
+
+#if !defined(strchr) && !defined(_lib_strchr) && defined(_lib_index)
+#define strchr(s,c) index(s,c)
+#endif
+
+#if !defined(strrchr) && !defined(_lib_strrchr) && defined(_lib_rindex)
+#define strrchr(s,c) rindex(s,c)
+#endif
+
+/* and now introducing prototypes botched by the standard(s) */
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+#undef getpgrp
+#define getpgrp() _ast_getpgrp()
+extern int _ast_getpgrp(void);
+
+#undef extern
+
+/*
+ * and finally, standard interfaces hijacked by ast
+ * _ATS_STD_I delays headers that require <ast_map.h>
+ */
+
+#include <ast_map.h>
+
+#undef _AST_STD_I
+
+#if _REGEX_H < 0
+#undef _REGEX_H
+#include <regex.h>
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/include/ast_version.h b/usr/src/lib/libast/common/include/ast_version.h
new file mode 100644
index 0000000000..09b618f16b
--- /dev/null
+++ b/usr/src/lib/libast/common/include/ast_version.h
@@ -0,0 +1,28 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Advanced Software Technology
+ * AT&T Research
+ */
+
+#define _AST_VERSION 20061111L
diff --git a/usr/src/lib/libast/common/include/ast_windows.h b/usr/src/lib/libast/common/include/ast_windows.h
new file mode 100644
index 0000000000..0459cbe072
--- /dev/null
+++ b/usr/src/lib/libast/common/include/ast_windows.h
@@ -0,0 +1,39 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * AT&T Research
+ *
+ * ast <windows.h> wrapper
+ * for libast only
+ * include after ast headers
+ */
+
+#ifndef _AST_WINDOWS_H
+#define _AST_WINDOWS_H 1
+
+#undef SF_ERROR /* clash in <oaidl.h> */
+
+#include <windows.h>
+
+#endif
diff --git a/usr/src/lib/libast/common/include/ccode.h b/usr/src/lib/libast/common/include/ccode.h
new file mode 100644
index 0000000000..1642c99181
--- /dev/null
+++ b/usr/src/lib/libast/common/include/ccode.h
@@ -0,0 +1,90 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * character code map interface
+ *
+ * NOTE: used for mapping between 8-bit character encodings
+ * ISO character sets are handled by sfio
+ */
+
+#ifndef _CHARCODE_H
+#define _CHARCODE_H 1
+
+#include <ast.h>
+#include <ast_ccode.h>
+
+typedef struct Ccmap_s
+{
+ const char* name; /* code set name */
+ const char* match; /* strmatch() pattern */
+ const char* desc; /* code set description */
+ const char* canon; /* canonical name format */
+ const char* index; /* default index */
+ int ccode; /* <ccode.h> code index */
+ void* data; /* map specific data */
+} Ccmap_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern unsigned char* _ccmap(int, int);
+extern void* _ccmapcpy(unsigned char*, void*, const void*, size_t);
+extern void* _ccmapstr(unsigned char*, void*, size_t);
+
+extern int ccmapid(const char*);
+extern char* ccmapname(int);
+extern void* ccnative(void*, const void*, size_t);
+extern Ccmap_t* ccmaplist(Ccmap_t*);
+
+#undef extern
+
+#define CCOP(i,o) ((i)==(o)?0:(((o)<<8)|(i)))
+#define CCIN(x) ((x)&0xFF)
+#define CCOUT(x) (((x)>>8)&0xFF)
+#define CCCONVERT(x) ((x)&0xFF00)
+
+#define CCCVT(x) CCMAP(x,0)
+#define CCMAP(i,o) ((i)==(o)?(unsigned char*)0:_ccmap(i,o))
+#define CCMAPCHR(m,c) ((m)?(m)[c]:(c))
+#define CCMAPCPY(m,t,f,n) ((m)?_ccmapcpy(m,t,f,n):memcpy(t,f,n))
+#define CCMAPSTR(m,s,n) ((m)?_ccmapstr(m,s,n):(void*)(s))
+
+#define ccmap(i,o) CCMAP(i,o)
+#define ccmapchr(m,c) CCMAPCHR(m,c)
+#define ccmapcpy(m,t,f,n) CCMAPCPY(m,t,f,n)
+#define ccmapstr(m,s,n) CCMAPSTR(m,s,n)
+
+#define CCMAPC(c,i,o) ((i)==(o)?(c):CCMAP(i,o)[c])
+#define CCMAPM(t,f,n,i,o) ((i)==(o)?memcpy(t,f,n):_ccmapcpy(CCMAP(i,o),t,f,n))
+#define CCMAPS(s,n,i,o) ((i)==(o)?(void*)(s):_ccmapstr(CCMAP(i,o),s,n))
+
+#define ccmapc(c,i,o) CCMAPC(c,i,o)
+#define ccmapm(t,f,n,i,o) CCMAPM(t,f,n,i,o)
+#define ccmaps(s,n,i,o) CCMAPS(s,n,i,o)
+
+#endif
diff --git a/usr/src/lib/libast/common/include/cdt.h b/usr/src/lib/libast/common/include/cdt.h
new file mode 100644
index 0000000000..f6274cef92
--- /dev/null
+++ b/usr/src/lib/libast/common/include/cdt.h
@@ -0,0 +1,311 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _CDT_H
+#define _CDT_H 1
+
+/* Public interface for the dictionary library
+**
+** Written by Kiem-Phong Vo
+*/
+
+#define CDT_VERSION 20050420L
+
+#if _PACKAGE_ast
+#include <ast_std.h>
+#else
+#include <ast_common.h>
+#endif
+
+typedef struct _dtlink_s Dtlink_t;
+typedef struct _dthold_s Dthold_t;
+typedef struct _dtdisc_s Dtdisc_t;
+typedef struct _dtmethod_s Dtmethod_t;
+typedef struct _dtdata_s Dtdata_t;
+typedef struct _dt_s Dt_t;
+typedef struct _dt_s Dict_t; /* for libdict compatibility */
+typedef struct _dtstat_s Dtstat_t;
+typedef Void_t* (*Dtsearch_f)_ARG_((Dt_t*,Void_t*,int));
+typedef Void_t* (*Dtmake_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*));
+typedef void (*Dtfree_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*));
+typedef int (*Dtcompar_f)_ARG_((Dt_t*,Void_t*,Void_t*,Dtdisc_t*));
+typedef unsigned int (*Dthash_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*));
+typedef Void_t* (*Dtmemory_f)_ARG_((Dt_t*,Void_t*,size_t,Dtdisc_t*));
+typedef int (*Dtevent_f)_ARG_((Dt_t*,int,Void_t*,Dtdisc_t*));
+
+struct _dtlink_s
+{ Dtlink_t* right; /* right child */
+ union
+ { unsigned int _hash; /* hash value */
+ Dtlink_t* _left; /* left child */
+ } hl;
+};
+
+/* private structure to hold an object */
+struct _dthold_s
+{ Dtlink_t hdr; /* header */
+ Void_t* obj; /* user object */
+};
+
+/* method to manipulate dictionary structure */
+struct _dtmethod_s
+{ Dtsearch_f searchf; /* search function */
+ int type; /* type of operation */
+};
+
+/* stuff that may be in shared memory */
+struct _dtdata_s
+{ int type; /* type of dictionary */
+ Dtlink_t* here; /* finger to last search element */
+ union
+ { Dtlink_t** _htab; /* hash table */
+ Dtlink_t* _head; /* linked list */
+ } hh;
+ int ntab; /* number of hash slots */
+ int size; /* number of objects */
+ int loop; /* number of nested loops */
+ int minp; /* min path before splay, always even */
+ /* for hash dt, > 0: fixed table size */
+};
+
+/* structure to hold methods that manipulate an object */
+struct _dtdisc_s
+{ int key; /* where the key begins in an object */
+ int size; /* key size and type */
+ int link; /* offset to Dtlink_t field */
+ Dtmake_f makef; /* object constructor */
+ Dtfree_f freef; /* object destructor */
+ Dtcompar_f comparf;/* to compare two objects */
+ Dthash_f hashf; /* to compute hash value of an object */
+ Dtmemory_f memoryf;/* to allocate/free memory */
+ Dtevent_f eventf; /* to process events */
+};
+
+#define DTDISC(dc,ky,sz,lk,mkf,frf,cmpf,hshf,memf,evf) \
+ ( (dc)->key = (ky), (dc)->size = (sz), (dc)->link = (lk), \
+ (dc)->makef = (mkf), (dc)->freef = (frf), \
+ (dc)->comparf = (cmpf), (dc)->hashf = (hshf), \
+ (dc)->memoryf = (memf), (dc)->eventf = (evf) )
+
+#ifdef offsetof
+#define DTOFFSET(struct_s, member) offsetof(struct_s, member)
+#else
+#define DTOFFSET(struct_s, member) ((int)(&((struct_s*)0)->member))
+#endif
+
+/* the dictionary structure itself */
+struct _dt_s
+{ Dtsearch_f searchf;/* search function */
+ Dtdisc_t* disc; /* method to manipulate objs */
+ Dtdata_t* data; /* sharable data */
+ Dtmemory_f memoryf;/* function to alloc/free memory */
+ Dtmethod_t* meth; /* dictionary method */
+ int type; /* type information */
+ int nview; /* number of parent view dictionaries */
+ Dt_t* view; /* next on viewpath */
+ Dt_t* walk; /* dictionary being walked */
+ Void_t* user; /* for user's usage */
+};
+
+/* structure to get status of a dictionary */
+struct _dtstat_s
+{ int dt_meth; /* method type */
+ int dt_size; /* number of elements */
+ int dt_n; /* number of chains or levels */
+ int dt_max; /* max size of a chain or a level */
+ int* dt_count; /* counts of chains or levels by size */
+};
+
+/* flag set if the last search operation actually found the object */
+#define DT_FOUND 0100000
+
+/* supported storage methods */
+#define DT_SET 0000001 /* set with unique elements */
+#define DT_BAG 0000002 /* multiset */
+#define DT_OSET 0000004 /* ordered set (self-adjusting tree) */
+#define DT_OBAG 0000010 /* ordered multiset */
+#define DT_LIST 0000020 /* linked list */
+#define DT_STACK 0000040 /* stack */
+#define DT_QUEUE 0000100 /* queue */
+#define DT_METHODS 0000177 /* all currently supported methods */
+
+/* asserts to dtdisc() */
+#define DT_SAMECMP 0000001 /* compare methods equivalent */
+#define DT_SAMEHASH 0000002 /* hash methods equivalent */
+
+/* types of search */
+#define DT_INSERT 0000001 /* insert object if not found */
+#define DT_DELETE 0000002 /* delete object if found */
+#define DT_SEARCH 0000004 /* look for an object */
+#define DT_NEXT 0000010 /* look for next element */
+#define DT_PREV 0000020 /* find previous element */
+#define DT_RENEW 0000040 /* renewing an object */
+#define DT_CLEAR 0000100 /* clearing all objects */
+#define DT_FIRST 0000200 /* get first object */
+#define DT_LAST 0000400 /* get last object */
+#define DT_MATCH 0001000 /* find object matching key */
+#define DT_VSEARCH 0002000 /* search using internal representation */
+#define DT_ATTACH 0004000 /* attach an object to the dictionary */
+#define DT_DETACH 0010000 /* detach an object from the dictionary */
+
+/* events */
+#define DT_OPEN 1 /* a dictionary is being opened */
+#define DT_CLOSE 2 /* a dictionary is being closed */
+#define DT_DISC 3 /* discipline is about to be changed */
+#define DT_METH 4 /* method is about to be changed */
+#define DT_ENDOPEN 5 /* dtopen() is done */
+#define DT_ENDCLOSE 6 /* dtclose() is done */
+#define DT_HASHSIZE 7 /* setting hash table size */
+
+_BEGIN_EXTERNS_ /* public data */
+#if _BLD_cdt && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+#if !_BLD_cdt && defined(__IMPORT__)
+#define extern __IMPORT__
+#endif
+
+extern Dtmethod_t* Dtset;
+extern Dtmethod_t* Dtbag;
+extern Dtmethod_t* Dtoset;
+extern Dtmethod_t* Dtobag;
+extern Dtmethod_t* Dtlist;
+extern Dtmethod_t* Dtstack;
+extern Dtmethod_t* Dtqueue;
+
+/* compatibility stuff; will go away */
+#ifndef KPVDEL
+extern Dtmethod_t* Dtorder;
+extern Dtmethod_t* Dttree;
+extern Dtmethod_t* Dthash;
+extern Dtmethod_t _Dttree;
+extern Dtmethod_t _Dthash;
+extern Dtmethod_t _Dtlist;
+extern Dtmethod_t _Dtqueue;
+extern Dtmethod_t _Dtstack;
+#endif
+
+#undef extern
+_END_EXTERNS_
+
+_BEGIN_EXTERNS_ /* public functions */
+#if _BLD_cdt && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Dt_t* dtopen _ARG_((Dtdisc_t*, Dtmethod_t*));
+extern int dtclose _ARG_((Dt_t*));
+extern Dt_t* dtview _ARG_((Dt_t*, Dt_t*));
+extern Dtdisc_t* dtdisc _ARG_((Dt_t* dt, Dtdisc_t*, int));
+extern Dtmethod_t* dtmethod _ARG_((Dt_t*, Dtmethod_t*));
+
+extern Dtlink_t* dtflatten _ARG_((Dt_t*));
+extern Dtlink_t* dtextract _ARG_((Dt_t*));
+extern int dtrestore _ARG_((Dt_t*, Dtlink_t*));
+
+extern int dttreeset _ARG_((Dt_t*, int, int));
+
+extern int dtwalk _ARG_((Dt_t*, int(*)(Dt_t*,Void_t*,Void_t*), Void_t*));
+
+extern Void_t* dtrenew _ARG_((Dt_t*, Void_t*));
+
+extern int dtsize _ARG_((Dt_t*));
+extern int dtstat _ARG_((Dt_t*, Dtstat_t*, int));
+extern unsigned int dtstrhash _ARG_((unsigned int, Void_t*, int));
+
+#if !_PACKAGE_ast
+extern int memcmp _ARG_((const Void_t*, const Void_t*, size_t));
+extern int strcmp _ARG_((const char*, const char*));
+#endif
+
+#undef extern
+_END_EXTERNS_
+
+/* internal functions for translating among holder, object and key */
+#define _DT(dt) ((Dt_t*)(dt))
+#define _DTDSC(dc,ky,sz,lk,cmpf) \
+ (ky = (dc)->key, sz = (dc)->size, lk = (dc)->link, cmpf = (dc)->comparf)
+#define _DTLNK(o,lk) ((Dtlink_t*)((char*)(o) + lk) )
+#define _DTOBJ(e,lk) ((lk) < 0 ? ((Dthold_t*)(e))->obj : (Void_t*)((char*)(e) - (lk)) )
+#define _DTKEY(o,ky,sz) (Void_t*)((sz) < 0 ? *((char**)((char*)(o)+(ky))) : ((char*)(o)+(ky)))
+
+#define _DTCMP(dt,k1,k2,dc,cmpf,sz) \
+ ((cmpf) ? (*cmpf)(dt,k1,k2,dc) : \
+ ((sz) <= 0 ? strcmp(k1,k2) : memcmp(k1,k2,sz)) )
+#define _DTHSH(dt,ky,dc,sz) ((dc)->hashf ? (*(dc)->hashf)(dt,ky,dc) : dtstrhash(0,ky,sz) )
+
+/* special search function for tree structure only */
+#define _DTMTCH(dt,key,action) \
+ do { Dtlink_t* _e; Void_t *_o, *_k, *_key; Dtdisc_t* _dc; \
+ int _ky, _sz, _lk, _cmp; Dtcompar_f _cmpf; \
+ _dc = (dt)->disc; _DTDSC(_dc, _ky, _sz, _lk, _cmpf); \
+ _key = (key); \
+ for(_e = (dt)->data->here; _e; _e = _cmp < 0 ? _e->hl._left : _e->right) \
+ { _o = _DTOBJ(_e, _lk); _k = _DTKEY(_o, _ky, _sz); \
+ if((_cmp = _DTCMP((dt), _key, _k, _dc, _cmpf, _sz)) == 0) \
+ break; \
+ } \
+ action (_e ? _o : (Void_t*)0); \
+ } while(0)
+
+#define _DTSRCH(dt,obj,action) \
+ do { Dtlink_t* _e; Void_t *_o, *_k, *_key; Dtdisc_t* _dc; \
+ int _ky, _sz, _lk, _cmp; Dtcompar_f _cmpf; \
+ _dc = (dt)->disc; _DTDSC(_dc, _ky, _sz, _lk, _cmpf); \
+ _key = _DTKEY(obj, _ky, _sz); \
+ for(_e = (dt)->data->here; _e; _e = _cmp < 0 ? _e->hl._left : _e->right) \
+ { _o = _DTOBJ(_e, _lk); _k = _DTKEY(_o, _ky, _sz); \
+ if((_cmp = _DTCMP((dt), _key, _k, _dc, _cmpf, _sz)) == 0) \
+ break; \
+ } \
+ action (_e ? _o : (Void_t*)0); \
+ } while(0)
+
+#define DTTREEMATCH(dt,key,action) _DTMTCH(_DT(dt),(Void_t*)(key),action)
+#define DTTREESEARCH(dt,obj,action) _DTSRCH(_DT(dt),(Void_t*)(obj),action)
+
+#define dtvnext(d) (_DT(d)->view)
+#define dtvcount(d) (_DT(d)->nview)
+#define dtvhere(d) (_DT(d)->walk)
+
+#define dtlink(d,e) (((Dtlink_t*)(e))->right)
+#define dtobj(d,e) _DTOBJ((e), _DT(d)->disc->link)
+#define dtfinger(d) (_DT(d)->data->here ? dtobj((d),_DT(d)->data->here):(Void_t*)(0))
+
+#define dtfirst(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_FIRST)
+#define dtnext(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_NEXT)
+#define dtleast(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH|DT_NEXT)
+#define dtlast(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_LAST)
+#define dtprev(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_PREV)
+#define dtmost(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH|DT_PREV)
+#define dtsearch(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH)
+#define dtmatch(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_MATCH)
+#define dtinsert(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_INSERT)
+#define dtdelete(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_DELETE)
+#define dtattach(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_ATTACH)
+#define dtdetach(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_DETACH)
+#define dtclear(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_CLEAR)
+#define dtfound(d) (_DT(d)->type & DT_FOUND)
+
+#define DT_PRIME 17109811 /* 2#00000001 00000101 00010011 00110011 */
+#define dtcharhash(h,c) (((unsigned int)(h) + (unsigned int)(c)) * DT_PRIME )
+
+#endif /* _CDT_H */
diff --git a/usr/src/lib/libast/common/include/debug.h b/usr/src/lib/libast/common/include/debug.h
new file mode 100644
index 0000000000..36ef9f0044
--- /dev/null
+++ b/usr/src/lib/libast/common/include/debug.h
@@ -0,0 +1,52 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * common ast debug definitions
+ * include after the ast headers
+ */
+
+#ifndef _DEBUG_H
+#define _DEBUG_H
+
+#include <ast.h>
+#include <error.h>
+
+#if DEBUG || _BLD_DEBUG
+#define debug(x) x
+#define message(x) do if (error_info.trace < 0) { error x; } while (0)
+#define messagef(x) do if (error_info.trace < 0) { errorf x; } while (0)
+#else
+#define debug(x)
+#define message(x)
+#define messagef(x)
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern void systrace(const char*);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/dt.h b/usr/src/lib/libast/common/include/dt.h
new file mode 100644
index 0000000000..be441089ad
--- /dev/null
+++ b/usr/src/lib/libast/common/include/dt.h
@@ -0,0 +1,38 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#ifndef _DT_H
+#define _DT_H 1
+
+#include <cdt.h>
+#include <vmalloc.h>
+
+#if _BLD_cdt && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Dt_t* dtnew(Vmalloc_t*, Dtdisc_t*, Dtmethod_t*);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/error.h b/usr/src/lib/libast/common/include/error.h
new file mode 100644
index 0000000000..e1af2396de
--- /dev/null
+++ b/usr/src/lib/libast/common/include/error.h
@@ -0,0 +1,182 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * option, error and message formatter external definitions
+ */
+
+#ifndef _ERROR_H
+#define _ERROR_H
+
+#include <ast.h>
+#include <option.h>
+#include <errno.h>
+
+#define ERROR_VERSION 20070319L
+
+#if !defined(errno) && defined(__DYNAMIC__)
+#define errno __DYNAMIC__(errno)
+#endif
+
+#define ERROR_debug(n) (-(n))
+#define ERROR_exit(n) ((n)+ERROR_ERROR)
+#define ERROR_system(n) (((n)+ERROR_ERROR)|ERROR_SYSTEM)
+#define ERROR_usage(n) ((((n)?2:0)+ERROR_ERROR)|ERROR_USAGE)
+#define ERROR_warn(n) (ERROR_WARNING)
+
+#ifndef ERROR_catalog
+#define ERROR_catalog(t) t
+#endif
+#ifndef ERROR_dictionary
+#define ERROR_dictionary(t) t
+#endif
+
+#ifndef ERROR_translate
+#define ERROR_translating() (error_info.translate&&(ast.locale.set&(1<<AST_LC_MESSAGES)))
+#define ERROR_translate(l,i,d,m) (ERROR_translating()?errorx((const char*)l,(const char*)i,(const char*)d,(const char*)m):(m))
+#endif
+
+#define ERROR_INFO 0 /* info message -- no err_id */
+#define ERROR_WARNING 1 /* warning message */
+#define ERROR_ERROR 2 /* error message -- no err_exit */
+#define ERROR_FATAL 3 /* error message with err_exit */
+#define ERROR_NOEXEC EXIT_NOEXEC /* shell convention */
+#define ERROR_NOENT EXIT_NOTFOUND /* shell convention */
+#define ERROR_PANIC ERROR_LEVEL /* panic message with err_exit */
+
+#define ERROR_LEVEL 0x00ff /* level portion of status */
+#define ERROR_SYSTEM 0x0100 /* report system errno message */
+#define ERROR_OUTPUT 0x0200 /* next arg is error fd */
+#define ERROR_SOURCE 0x0400 /* next 2 args are FILE,LINE */
+#define ERROR_USAGE 0x0800 /* usage message */
+#define ERROR_PROMPT 0x1000 /* omit trailing newline */
+#define ERROR_NOID 0x2000 /* omit err_id */
+#define ERROR_LIBRARY 0x4000 /* library routine error */
+
+#define ERROR_INTERACTIVE 0x0001 /* context is interactive */
+#define ERROR_SILENT 0x0002 /* context is silent */
+#define ERROR_NOTIFY 0x0004 /* main(-sig,0,ctx) on signal */
+
+#define ERROR_FREE 0x0010 /* free context on pop */
+#define ERROR_POP 0x0020 /* pop context */
+#define ERROR_PUSH 0x0040 /* push context */
+#define ERROR_SET 0x0080 /* set context */
+
+/*
+ * errorpush()/errorpop() are obsolete -- use errorctx() instead
+ */
+
+#ifndef ERROR_CONTEXT_T
+#define ERROR_CONTEXT_T Error_info_t
+#endif
+
+#define ERROR_CONTEXT_BASE ((Error_context_t*)&error_info.context)
+
+#define errorpush(p,f) (*(p)=*ERROR_CONTEXT_BASE,*ERROR_CONTEXT_BASE=error_info.empty,error_info.context=(Error_context_t*)(p),error_info.flags=(f))
+#define errorpop(p) (*ERROR_CONTEXT_BASE=*(p))
+
+typedef struct Error_info_s Error_info_t;
+typedef struct Error_context_s Error_context_t;
+
+#define ERROR_CONTEXT \
+ ERROR_CONTEXT_T* context; /* prev context stack element */ \
+ int errors; /* >= ERROR_ERROR count */ \
+ int flags; /* context flags */ \
+ int line; /* input|output line number */ \
+ int warnings; /* ERROR_WARNING count */ \
+ char* file; /* input|output file name */ \
+ char* id; /* command id */
+
+struct Error_context_s /* context stack element */
+{
+ ERROR_CONTEXT
+};
+
+struct Error_info_s /* error state */
+{
+ int fd; /* write(2) fd */
+
+ void (*exit)(int); /* error exit */
+ ssize_t (*write)(int, const void*, size_t); /* error output */
+
+ /* the rest are implicitly initialized */
+
+ int clear; /* default clear ERROR_* flags */
+ int core; /* level>=core -> core dump */
+ int indent; /* debug trace indent level */
+ int init; /* initialized */
+ int last_errno; /* last reported errno */
+ int mask; /* multi level debug trace mask */
+ int set; /* default set ERROR_* flags */
+ int trace; /* debug trace level */
+
+ char* version; /* ERROR_SOURCE command version */
+
+ int (*auxilliary)(Sfio_t*, int, int); /* aux info to append */
+
+ ERROR_CONTEXT /* top of context stack */
+
+ Error_context_t empty; /* empty context stack element */
+
+ unsigned long time; /* debug time trace */
+
+ char* (*translate)(const char*, const char*, const char*, const char*); /* format translator */
+
+ const char* catalog; /* message catalog */
+};
+
+#ifndef errno
+extern int errno; /* system call error status */
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#define extern extern __IMPORT__
+#endif
+
+extern Error_info_t* _error_infop_;
+
+#define error_info (*_error_infop_)
+
+#undef extern
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern void error(int, ...);
+extern int errormsg(const char*, int, ...);
+extern int errorf(void*, void*, int, ...);
+extern void errorv(const char*, int, va_list);
+#ifndef errorx
+extern char* errorx(const char*, const char*, const char*, const char*);
+#endif
+extern Error_info_t* errorctx(Error_info_t*, int, int);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/find.h b/usr/src/lib/libast/common/include/find.h
new file mode 100644
index 0000000000..ca5338de7e
--- /dev/null
+++ b/usr/src/lib/libast/common/include/find.h
@@ -0,0 +1,86 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * fast find interface definitions
+ */
+
+#ifndef _FIND_H
+#define _FIND_H
+
+#define FIND_VERSION 19980301L
+
+#ifndef FIND_CODES
+#define FIND_CODES "lib/find/codes"
+#endif
+
+#define FIND_CODES_ENV "FINDCODES"
+
+#define FIND_GENERATE (1<<0) /* generate new codes */
+#define FIND_ICASE (1<<1) /* ignore case in match */
+#define FIND_GNU (1<<2) /* generate gnu format codes */
+#define FIND_OLD (1<<3) /* generate old format codes */
+#define FIND_TYPE (1<<4) /* generate type with codes */
+#define FIND_VERIFY (1<<5) /* verify the dir hierarchy */
+
+#define FIND_USER (1L<<16) /* first user flag bit */
+
+struct Find_s;
+struct Finddisc_s;
+
+typedef int (*Findverify_f)(struct Find_s*, const char*, size_t, struct Finddisc_s*);
+
+typedef struct Finddisc_s
+{
+ unsigned long version; /* interface version */
+ unsigned long flags; /* FIND_* flags */
+ Error_f errorf; /* error function */
+ Findverify_f verifyf; /* dir verify function */
+ char** dirs; /* dir prefixes to search */
+} Finddisc_t;
+
+typedef struct Find_s
+{
+ const char* id; /* library id string */
+ unsigned long stamp; /* codes time stamp */
+
+#ifdef _FIND_PRIVATE_
+ _FIND_PRIVATE_
+#endif
+
+} Find_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Find_t* findopen(const char*, const char*, const char*, Finddisc_t*);
+extern char* findread(Find_t*);
+extern int findwrite(Find_t*, const char*, size_t, const char*);
+extern int findclose(Find_t*);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/fnv.h b/usr/src/lib/libast/common/include/fnv.h
new file mode 100644
index 0000000000..76dc256f80
--- /dev/null
+++ b/usr/src/lib/libast/common/include/fnv.h
@@ -0,0 +1,72 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * Landon Kurt Knoll
+ * Phong Vo
+ *
+ * FNV-1 linear congruent checksum/hash/PRNG
+ * see http://www.isthe.com/chongo/tech/comp/fnv/
+ */
+
+#ifndef _FNV_H
+#define _FNV_H
+
+#include <ast_common.h>
+
+#define FNV_INIT 0x811c9dc5L
+#define FNV_MULT 0x01000193L
+
+#define FNVINIT(h) (h = FNV_INIT)
+#define FNVPART(h,c) (h = (h) * FNV_MULT ^ (c))
+#define FNVSUM(h,s,n) do { \
+ register size_t _i_ = 0; \
+ while (_i_ < n) \
+ FNVPART(h, ((unsigned char*)s)[_i_++]); \
+ } while (0)
+
+#if _typ_int64_t
+
+#ifdef _ast_LL
+
+#define FNV_INIT64 0xcbf29ce484222325LL
+#define FNV_MULT64 0x00000100000001b3LL
+
+#else
+
+#define FNV_INIT64 ((int64_t)0xcbf29ce484222325)
+#define FNV_MULT64 ((int64_t)0x00000100000001b3)
+
+#endif
+
+#define FNVINIT64(h) (h = FNV_INIT64)
+#define FNVPART64(h,c) (h = (h) * FNV_MULT64 ^ (c))
+#define FNVSUM64(h,s,n) do { \
+ register int _i_ = 0; \
+ while (_i_ < n) \
+ FNVPART64(h, ((unsigned char*)s)[_i_++]); \
+ } while (0)
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/include/fs3d.h b/usr/src/lib/libast/common/include/fs3d.h
new file mode 100644
index 0000000000..d0fa846421
--- /dev/null
+++ b/usr/src/lib/libast/common/include/fs3d.h
@@ -0,0 +1,109 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * 3d fs interface definitions
+ */
+
+#ifndef _FS3D_H
+#define _FS3D_H
+
+#include <ast_fs.h>
+
+#if _int_st_spare1
+#define iview(p) ((p)->st_spare1)
+#define IVIEW(p,v) ((p)->st_spare1=(v))
+#else
+#if _ary_st_spare4
+#define iview(p) ((p)->st_spare4[0])
+#define IVIEW(p,v) ((p)->st_spare4[0]=(v))
+#else
+#if _ary_st_pad4
+#define iview(p) ((p)->st_pad4[0])
+#define IVIEW(p,v) ((p)->st_pad4[0]=(v))
+#else
+#if _mem_st_rdev_stat
+#define iview(p) ((S_ISBLK((p)->st_mode)||S_ISCHR((p)->st_mode))?0:(p)->st_rdev)
+#define IVIEW(p,v) do{if(!S_ISBLK((p)->st_mode)&&!S_ISCHR((p)->st_mode))(p)->st_rdev=(v);}while(0)
+#else
+#define iview(p) 0
+#define IVIEW(p,v)
+#endif
+#endif
+#endif
+#endif
+
+/*
+ * special options
+ */
+
+#define FS3D_init "/#option/init"
+#define FS3D_on "/#option/3d"
+#define FS3D_off "/#option/2d"
+
+/*
+ * fs3d(3) ops
+ */
+
+#define FS3D_OP(o,a) (((a)<<3)|(o))
+
+#define FS3D_INIT FS3D_OP_INIT /* re-initialize tables */
+#define FS3D_OFF FS3D_OP_OFF
+#define FS3D_ON FS3D_OP_ON
+#define FS3D_TEST FS3D_OP_TEST
+#define FS3D_LIMIT(n) FS3D_OP(FS3D_OP_LIMIT,n)
+
+#define FS3D_op(x) ((x)&07)
+#define FS3D_arg(x) (((x)>>3)&07777)
+
+#define FS3D_OP_OFF 0
+#define FS3D_OP_ON 1
+#define FS3D_OP_TEST 2
+#define FS3D_OP_LIMIT 3
+#define FS3D_OP_INIT 7
+
+/*
+ * mount(2) ops
+ */
+
+#define FS3D_ALL (FS3D_VIEW|FS3D_VERSION)
+#define FS3D_VIEW 002
+#define FS3D_VERSION 004
+#define FS3D_GET 010
+#define FS3D_SIZE(n) ((n)<<4)
+#define FS3D_SIZEOF(n) ((n)>>4)
+
+extern int mount(const char*, char*, int, void*);
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int fs3d(int);
+extern char* pathnext(char*, char*, long*);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/fts.h b/usr/src/lib/libast/common/include/fts.h
new file mode 100644
index 0000000000..58e00d0f46
--- /dev/null
+++ b/usr/src/lib/libast/common/include/fts.h
@@ -0,0 +1,149 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * David Korn
+ * Phong Vo
+ * AT&T Research
+ *
+ * fts interface definitions
+ */
+
+#ifndef _FTS_H
+#define _FTS_H
+
+#include <ls.h>
+
+/*
+ * fts_open flags
+ */
+
+#define FTS_LOGICAL 0 /* logical traversal, follow symlinks */
+#define FTS_META (1<<0) /* follow top dir symlinks even if phys */
+#define FTS_NOCHDIR (1<<1) /* don't chdir */
+#define FTS_NOPOSTORDER (1<<2) /* no postorder visits */
+#define FTS_NOPREORDER (1<<3) /* no preorder visits */
+#define FTS_NOSEEDOTDIR (1<<11) /* never retain leading . dir */
+#define FTS_NOSTAT (1<<4) /* don't stat children */
+#define FTS_ONEPATH (1<<5) /* pathnames arg is one const char* */
+#define FTS_PHYSICAL (1<<6) /* physical traversal, don't follow */
+#define FTS_SEEDOT (1<<7) /* return . and .. */
+#define FTS_SEEDOTDIR (1<<10) /* always retain leading . dir */
+#define FTS_TOP (1<<8) /* don't traverse subdirectories */
+#define FTS_XDEV (1<<9) /* don't cross mount points */
+
+#define FTS_USER (1<<12) /* first user flag bit */
+
+#define FTS_COMFOLLOW FTS_META
+
+/*
+ * fts_info flags
+ */
+
+#define FTS_DEFAULT 0 /* ok, someone must have wanted this */
+
+#define FTS_NS (1<<0) /* stat failed */
+#define FTS_F (1<<1) /* file - not directory or symbolic link*/
+#define FTS_SL (1<<2) /* symbolic link */
+#define FTS_D (1<<3) /* directory - pre-order visit */
+
+#define FTS_C (1<<4) /* causes cycle */
+#define FTS_ERR (1<<5) /* some other error */
+#define FTS_DD (1<<6) /* . or .. */
+#define FTS_NR (1<<7) /* cannot read */
+#define FTS_NX (1<<8) /* cannot search */
+#define FTS_OK (1<<9) /* no info but otherwise ok */
+#define FTS_P (1<<10) /* post-order visit */
+
+#define FTS_DC (FTS_D|FTS_C) /* dir - would cause cycle */
+#define FTS_DNR (FTS_D|FTS_NR) /* dir - no read permission */
+#define FTS_DNX (FTS_D|FTS_NX) /* dir - no search permission */
+#define FTS_DOT (FTS_D|FTS_DD) /* . or .. */
+#define FTS_DP (FTS_D|FTS_P) /* dir - post-order visit */
+#define FTS_NSOK (FTS_NS|FTS_OK) /* no stat (because you asked) */
+#define FTS_SLNONE (FTS_SL|FTS_NS) /* symlink - to nowhere */
+
+/*
+ * fts_set flags
+ */
+
+#define FTS_AGAIN FTS_TOP /* process entry again */
+#define FTS_FOLLOW FTS_META /* follow FTS_SL symlink */
+#define FTS_SKIP FTS_NOSTAT /* skip FTS_D directory */
+#define FTS_STAT FTS_PHYSICAL /* stat() done by user */
+
+typedef struct Fts FTS;
+typedef struct Ftsent FTSENT;
+
+struct Ftsent
+{
+ char* fts_accpath; /* path relative to . */
+ char* fts_name; /* file name */
+ char* fts_path; /* path relative to top dir */
+ FTSENT* fts_cycle; /* offender if cycle */
+ FTSENT* fts_link; /* next child */
+ FTSENT* fts_parent; /* parent directory */
+ struct stat* fts_statp; /* stat info */
+#ifdef _FTSENT_LOCAL_PRIVATE_
+ _FTSENT_LOCAL_PRIVATE_
+#else
+ void* fts_pointer; /* local pointer value */
+#endif
+ long fts_number; /* local numeric value */
+ int fts_errno; /* errno for this entry */
+ unsigned short fts_info; /* info flags */
+ unsigned short fts_namelen; /* strlen(fts_name) */
+ unsigned short fts_pathlen; /* strlen(fts_path) */
+ short fts_level; /* file tree depth, 0 at top */
+
+#ifdef _FTSENT_PRIVATE_
+ _FTSENT_PRIVATE_
+#endif
+
+};
+
+struct Fts
+{
+ int fts_errno; /* last errno */
+
+#ifdef _FTS_PRIVATE_
+ _FTS_PRIVATE_
+#endif
+
+};
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern FTSENT* fts_children(FTS*, int);
+extern int fts_close(FTS*);
+extern int fts_flags(void);
+extern int fts_notify(int(*)(FTS*, FTSENT*, void*), void*);
+extern FTS* fts_open(char* const*, int, int(*)(FTSENT* const*, FTSENT* const*));
+extern FTSENT* fts_read(FTS*);
+extern int fts_set(FTS*, FTSENT*, int);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/ftwalk.h b/usr/src/lib/libast/common/include/ftwalk.h
new file mode 100644
index 0000000000..e222f6e734
--- /dev/null
+++ b/usr/src/lib/libast/common/include/ftwalk.h
@@ -0,0 +1,126 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Phong Vo
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * ast ftwalk interface definitions
+ * ftwalk was the initial improvement on ftw and nftw
+ * which formed the basis for the POSIX fts proposal
+ *
+ * NOTE: this file is in cahoots with the fts implementation
+ */
+
+#ifndef _FTWALK_H
+#define _FTWALK_H
+
+#define fts_info info
+#define fts_level level
+#define fts_link link
+#define fts_name name
+#define fts_namelen namelen
+#define fts_parent parent
+#define fts_path path
+#define fts_pathlen pathlen
+
+#define FTSENT Ftw_t /* <fts.h> internal */
+#define Ftsent FTW /* <fts.h> internal */
+
+#define _FTSENT_LOCAL_PRIVATE_ /* <fts.h> internal */ \
+ union \
+ { \
+ long number; /* local numeric value */ \
+ void* pointer; /* local pointer value */ \
+ } local;
+
+#define _FTSENT_PRIVATE_ /* fts internal */ \
+ short status; /* internal status */ \
+ struct stat statb; /* fts_statp data */
+
+#include <fts.h>
+
+/*
+ * ftwalk() argument flags
+ */
+
+#define FTW_CANON FTS_CANON
+#define FTW_CHILDREN (FTS_USER<<0)
+#define FTW_DELAY FTS_NOSTAT
+#define FTW_DOT FTS_NOCHDIR
+#define FTW_META FTS_META
+#define FTW_MOUNT FTS_XDEV
+#define FTW_MULTIPLE FTS_ONEPATH
+#define FTW_NOSEEDOTDIR FTS_NOSEEDOTDIR
+#define FTW_PHYSICAL FTS_PHYSICAL
+#define FTW_POST (FTS_USER<<1)
+#define FTW_SEEDOTDIR FTS_SEEDOTDIR
+#define FTW_TOP FTS_TOP
+#define FTW_TWICE (FTS_USER<<2)
+#define FTW_USER (FTS_USER<<3)
+
+/*
+ * Ftw_t.info type bits
+ */
+
+#define FTW_C FTS_C
+#define FTW_D FTS_D
+#define FTW_DC FTS_DC
+#define FTW_DNR FTS_DNR
+#define FTW_DNX FTS_DNX
+#define FTW_DP FTS_DP
+#define FTW_F FTS_F
+#define FTW_NR FTS_NR
+#define FTW_NS FTS_NS
+#define FTW_NSOK FTS_NSOK
+#define FTW_NX FTS_NX
+#define FTW_P FTS_P
+#define FTW_SL FTS_SL
+
+/*
+ * Ftw_t.status entry values
+ */
+
+#define FTW_NAME FTS_DOT /* access by Ftw_t.name */
+#define FTW_PATH FTS_NOCHDIR /* access by Ftw_t.path */
+
+/*
+ * Ftw_t.status return values
+ */
+
+#define FTW_AGAIN FTS_AGAIN
+#define FTW_FOLLOW FTS_FOLLOW
+#define FTW_NOPOST FTS_NOPOSTORDER
+#define FTW_SKIP FTS_SKIP
+#define FTW_STAT FTS_STAT
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int ftwalk(const char*, int(*)(Ftw_t*), int, int(*)(Ftw_t*, Ftw_t*));
+extern int ftwflags(void);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/glob.h b/usr/src/lib/libast/common/include/glob.h
new file mode 100644
index 0000000000..8ba75ac20b
--- /dev/null
+++ b/usr/src/lib/libast/common/include/glob.h
@@ -0,0 +1,144 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * posix glob interface definitions with gnu extensions
+ */
+
+#ifndef _GLOB_H
+#define _GLOB_H
+
+#define GLOB_VERSION 20060717L
+
+#include <stdlib.h>
+
+struct dirent;
+struct stat;
+
+struct _glob_;
+struct _globlist_;
+
+typedef struct _glob_ glob_t;
+typedef struct _globlist_ globlist_t;
+
+struct _globlist_
+{
+ globlist_t* gl_next;
+ char* gl_begin;
+ unsigned char gl_flags;
+ char gl_path[1];
+};
+
+struct _glob_
+{
+ size_t gl_pathc;
+ char** gl_pathv;
+ size_t gl_offs;
+ globlist_t* gl_list;
+ int gl_flags;
+
+ /* GLOB_DISC data -- memset(&gl,0,sizeof(gl)) before using! */
+
+ const char* gl_fignore;
+ const char* gl_suffix;
+ unsigned char* gl_intr;
+
+ int gl_delim;
+
+ void* gl_handle;
+ void* (*gl_diropen)(glob_t*, const char*);
+ char* (*gl_dirnext)(glob_t*, void*);
+ void (*gl_dirclose)(glob_t*, void*);
+ int (*gl_type)(glob_t*, const char*);
+ int (*gl_attr)(glob_t*, const char*);
+
+ /* gnu extensions -- but how do you synthesize dirent and stat? */
+
+ void* (*gl_opendir)(const char*);
+ struct dirent* (*gl_readdir)(void*);
+ void (*gl_closedir)(void*);
+ int (*gl_stat)(const char*, struct stat*);
+ int (*gl_lstat)(const char*, struct stat*);
+
+ /* ast additions */
+
+ char* (*gl_nextdir)(glob_t*, char*);
+ unsigned long gl_status;
+ unsigned long gl_version;
+ unsigned short gl_extra;
+
+#ifdef _GLOB_PRIVATE_
+ _GLOB_PRIVATE_
+#else
+ char* gl_pad[23];
+#endif
+
+};
+
+/* standard interface */
+#define GLOB_APPEND 0x0001 /* append to previous */
+#define GLOB_DOOFFS 0x0002 /* gl_offs defines argv offset */
+#define GLOB_ERR 0x0004 /* abort on error */
+#define GLOB_MARK 0x0008 /* append / to directories */
+#define GLOB_NOCHECK 0x0010 /* nomatch is original pattern */
+#define GLOB_NOESCAPE 0x0020 /* don't treat \ specially */
+#define GLOB_NOSORT 0x0040 /* don't sort the list */
+
+/* extended interface */
+#define GLOB_STARSTAR 0x0080 /* enable [/]**[/] expansion */
+#define GLOB_BRACE 0x0100 /* enable {...} expansion */
+#define GLOB_ICASE 0x0200 /* ignore case on match */
+#define GLOB_COMPLETE 0x0400 /* shell file completeion */
+#define GLOB_AUGMENTED 0x0800 /* augmented shell patterns */
+#define GLOB_STACK 0x1000 /* allocate on current stack */
+#define GLOB_LIST 0x2000 /* just create gl_list */
+#define GLOB_ALTDIRFUNC 0x4000 /* gnu discipline functions */
+#define GLOB_DISC 0x8000 /* discipline initialized */
+
+/* gl_status */
+#define GLOB_NOTDIR 0x0001 /* last gl_dirnext() not a dir */
+
+/* gl_type return */
+#define GLOB_NOTFOUND 0 /* does not exist */
+#define GLOB_DEV 1 /* exists but not DIR EXE REG */
+#define GLOB_DIR 2 /* directory */
+#define GLOB_EXE 3 /* executable regular file */
+#define GLOB_REG 4 /* regular file */
+
+/* error return values */
+#define GLOB_ABORTED 1
+#define GLOB_NOMATCH 2
+#define GLOB_NOSPACE 3
+#define GLOB_INTR 4
+#define GLOB_APPERR 5
+#define GLOB_NOSYS 6
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int glob(const char*, int, int(*)(const char*,int), glob_t*);
+extern void globfree(glob_t*);
+
+#undef extern
+
+#endif /* _GLOB_H */
diff --git a/usr/src/lib/libast/common/include/hash.h b/usr/src/lib/libast/common/include/hash.h
new file mode 100644
index 0000000000..1143461633
--- /dev/null
+++ b/usr/src/lib/libast/common/include/hash.h
@@ -0,0 +1,202 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * hash table library interface definitions
+ *
+ * NOTE: new code should use the more general <cdt.h>
+ */
+
+#ifndef _HASH_H
+#define _HASH_H
+
+#define HASH_ALLOCATE (1L<<0) /* allocate new key names */
+#define HASH_FIXED (1L<<1) /* fixed table size */
+#define HASH_HASHED (1L<<6) /* key names already hashed */
+#define HASH_RESIZE (1L<<2) /* table has been resized */
+#define HASH_SCANNING (1L<<3) /* currently scanning scope */
+#define HASH_SCOPE (1L<<4) /* push scope / create in bot */
+#define HASH_STATIC (1L<<5) /* static table allocation */
+
+#define HASH_CREATE (1L<<8) /* create bucket if not found */
+#define HASH_DELETE (1L<<9) /* delete bucket if found */
+#define HASH_LOOKUP 0 /* default op */
+#define HASH_RENAME (1L<<7) /* rename bucket if found */
+
+#define HASH_BUCKET (1L<<11) /* name is installed bucket */
+#define HASH_INSTALL (1L<<12) /* install allocated bucket */
+#define HASH_NOSCOPE (1L<<13) /* top scope only */
+#define HASH_OPAQUE (1L<<14) /* opaque bucket */
+#define HASH_VALUE (1L<<15) /* value bucket field used */
+
+#define HASH_SIZE(n) (((long)(n))<<16) /* fixed bucket size */
+#define HASH_SIZEOF(f) ((((long)(f))>>16)&0xffff) /* extract size */
+
+#define HASH_DELETED ((unsigned long)1<<(8*sizeof(int)-1)) /* deleted placeholder */
+#define HASH_KEEP (1L<<(8*sizeof(int)-2)) /* no free on bucket */
+#define HASH_HIDDEN (1L<<(8*sizeof(int)-3)) /* hidden by scope */
+#define HASH_HIDES (1L<<(8*sizeof(int)-4)) /* hides lower scope */
+#define HASH_OPAQUED (1L<<(8*sizeof(int)-5)) /* opaqued placeholder */
+#define HASH_FREENAME (1L<<(8*sizeof(int)-6)) /* free bucket name */
+
+#define HASH_RESET (HASH_RESIZE|HASH_SCOPE|HASH_STATIC|HASH_VALUE)
+#define HASH_INTERNAL (HASH_BUCKET|HASH_RESIZE|HASH_SCANNING|HASH_STATIC)
+#define HASH_FLAGS (HASH_DELETED|HASH_FREENAME|HASH_HIDDEN|HASH_HIDES|HASH_KEEP|HASH_OPAQUED)
+
+#define HASH_alloc 1
+#define HASH_clear 2
+#define HASH_compare 3
+#define HASH_free 4
+#define HASH_hash 5
+#define HASH_meanchain 6
+#define HASH_name 7
+#define HASH_namesize 8
+#define HASH_set 9
+#define HASH_size 10
+#define HASH_table 11
+#define HASH_va_list 12
+
+#define HASH_bucketsize 13
+
+#define HASH_region 14
+
+#include <hashpart.h>
+
+#define hashclear(t,f) ((t)->flags &= ~((f) & ~HASH_INTERNAL))
+#define hashcover(b) (((b)->hash&HASH_HIDES)?(Hash_bucket_t*)((b)->name):(Hash_bucket_t*)0)
+#define hashdel(t,n) hashlook(t, (char*)(n), HASH_DELETE, (char*)0)
+#define hashget(t,n) hashlook(t, (char*)(n), HASH_LOOKUP|HASH_VALUE, (char*)0)
+#define hashgetbucket(s) ((Hash_bucket_t*)((s)-((sizeof(Hash_bucket_t)+sizeof(char*)-1)/sizeof(char*))*sizeof(char*)))
+#define hashkeep(b) ((b)->hash|=HASH_KEEP)
+#define hashname(b) ((((b)->hash&HASH_HIDES)?((Hash_bucket_t*)((b)->name)):(b))->name)
+#define hashput(t,n,v) hashlook(t, (char*)(n), HASH_CREATE|HASH_VALUE, (char*)(v))
+#define hashref(t,n) hashlook(t, (char*)(n), HASH_LOOKUP|HASH_INTERNAL|HASH_VALUE, (char*)0)
+#define hashscope(t) ((t)->scope)
+#define hashset(t,f) ((t)->flags |= ((f) & ~HASH_INTERNAL))
+
+/*
+ * DEPRECATED renames for compatibility
+ */
+
+#define Hashbin_t Hash_bucket_t
+#define HASHBUCKET Hash_bucket_t
+#define Hashhdr_t Hash_header_t
+#define HASHHEADER Hash_header_t
+#define Hashpos_t Hash_position_t
+#define HASHPOSITION Hash_position_t
+#define Hashtab_t Hash_table_t
+#define HASHTABLE Hash_table_t
+
+#define vhashalloc hashvalloc
+#define hashvalloc(t,a) hashalloc(t,HASH_va_list,a,0)
+
+/*
+ * the #define's avoid union tags
+ */
+
+typedef struct Hash_bucket Hash_bucket_t;
+typedef struct Hash_root Hash_root_t;
+typedef struct Hash_table Hash_table_t;
+
+#define HASH_HEADER /* common bucket header */ \
+ Hash_bucket_t* next; /* next in collision chain */ \
+ unsigned int hash; /* hash flags and value */ \
+ char* name /* key name */
+
+#define HASH_DEFAULT /* HASH_VALUE bucket elements */ \
+ char* value /* key value */
+
+typedef struct /* bucket header */
+{
+ HASH_HEADER;
+} Hash_header_t;
+
+struct Hash_bucket /* prototype bucket */
+{
+ HASH_HEADER;
+ HASH_DEFAULT;
+};
+
+typedef struct /* hash scan bucket position */
+{
+ Hash_bucket_t* bucket; /* bucket */
+#ifdef _HASH_POSITION_PRIVATE_
+ _HASH_POSITION_PRIVATE_
+#endif
+} Hash_position_t;
+
+typedef struct /* last lookup cache */
+{
+ Hash_table_t* table; /* last lookup table */
+ Hash_bucket_t* bucket; /* last lookup bucket */
+#ifdef _HASH_LAST_PRIVATE_
+ _HASH_LAST_PRIVATE_
+#endif
+} Hash_last_t;
+
+struct Hash_root /* root hash table information */
+{
+ int accesses; /* number of accesses */
+ int collisions; /* number of collisions */
+ int flags; /* flags: see HASH_[A-Z]* */
+ Hash_last_t last; /* last lookup cache */
+ void* context; /* user defined context */
+#ifdef _HASH_ROOT_PRIVATE_
+ _HASH_ROOT_PRIVATE_
+#endif
+};
+
+struct Hash_table /* hash table information */
+{
+ Hash_root_t* root; /* root hash table information */
+ int size; /* table size */
+ int buckets; /* active bucket count */
+ char* name; /* table name */
+ Hash_table_t* scope; /* scope covered table */
+ short flags; /* flags: see HASH_[A-Z]* */
+#ifdef _HASH_TABLE_PRIVATE_
+ _HASH_TABLE_PRIVATE_
+#endif
+};
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Hash_table_t* hashalloc(Hash_table_t*, ...);
+extern void hashdone(Hash_position_t*);
+extern void hashdump(Hash_table_t*, int);
+extern Hash_table_t* hashfree(Hash_table_t*);
+extern Hash_bucket_t* hashlast(Hash_table_t*);
+extern char* hashlook(Hash_table_t*, const char*, long, const char*);
+extern Hash_bucket_t* hashnext(Hash_position_t*);
+extern Hash_position_t* hashscan(Hash_table_t*, int);
+extern void hashsize(Hash_table_t*, int);
+extern Hash_table_t* hashview(Hash_table_t*, Hash_table_t*);
+extern int hashwalk(Hash_table_t*, int, int (*)(const char*, char*, void*), void*);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/hashkey.h b/usr/src/lib/libast/common/include/hashkey.h
new file mode 100644
index 0000000000..6c246aa6bc
--- /dev/null
+++ b/usr/src/lib/libast/common/include/hashkey.h
@@ -0,0 +1,62 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * 1-6 char lower-case keyword -> long hash
+ * digit args passed as HASHKEYN('2')
+ */
+
+#ifndef _HASHKEY_H
+#define _HASHKEY_H
+
+#define HASHKEYMAX 6
+#define HASHKEYBIT 5
+#define HASHKEYOFF ('a'-1)
+#define HASHKEYPART(h,c) (((h)<<HASHKEYBIT)+HASHKEY1(c))
+
+#define HASHKEYN(n) ((n)-'0'+'z'+1)
+
+#define HASHKEY1(c1) ((c1)-HASHKEYOFF)
+#define HASHKEY2(c1,c2) HASHKEYPART(HASHKEY1(c1),c2)
+#define HASHKEY3(c1,c2,c3) HASHKEYPART(HASHKEY2(c1,c2),c3)
+#define HASHKEY4(c1,c2,c3,c4) HASHKEYPART(HASHKEY3(c1,c2,c3),c4)
+#define HASHKEY5(c1,c2,c3,c4,c5) HASHKEYPART(HASHKEY4(c1,c2,c3,c4),c5)
+#define HASHKEY6(c1,c2,c3,c4,c5,c6) HASHKEYPART(HASHKEY5(c1,c2,c3,c4,c5),c6)
+
+#define HASHNKEY1(n,c1) HASHKEY2((n)+HASHKEYOFF,c1)
+#define HASHNKEY2(n,c2,c1) HASHKEY3((n)+HASHKEYOFF,c2,c1)
+#define HASHNKEY3(n,c3,c2,c1) HASHKEY4((n)+HASHKEYOFF,c3,c2,c1)
+#define HASHNKEY4(n,c4,c3,c2,c1) HASHKEY5((n)+'a',c4,c3,c2,c1)
+#define HASHNKEY5(n,c5,c4,c3,c2,c1) HASHKEY6((n)+'a',c5,c4,c3,c2,c1)
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern long strkey(const char*);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/hashpart.h b/usr/src/lib/libast/common/include/hashpart.h
new file mode 100644
index 0000000000..b01ef3d672
--- /dev/null
+++ b/usr/src/lib/libast/common/include/hashpart.h
@@ -0,0 +1,51 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * K. P. Vo
+ * G. S. Fowler
+ * AT&T Research
+ *
+ * ``the best'' combined linear congruent checksum/hash/PRNG
+ */
+
+#ifndef _HASHPART_H
+#define _HASHPART_H
+
+#define HASH_ADD(h) (0x9c39c33dL)
+
+#if __sparc__ || __sparc || sparc
+
+#define HASH_A(h,n) ((((h) << 2) - (h)) << (n))
+#define HASH_B(h,n) ((((h) << 4) - (h)) << (n))
+#define HASH_C(h,n) ((HASH_A(h,7) + HASH_B(h,0)) << (n))
+#define HASH_MPY(h) (HASH_C(h,22)+HASH_C(h,10)+HASH_A(h,6)+HASH_A(h,3)+(h))
+
+#else
+
+#define HASH_MPY(h) ((h)*0x63c63cd9L)
+
+#endif
+
+#define HASHPART(h,c) (h = HASH_MPY(h) + HASH_ADD(h) + (c))
+
+#endif
diff --git a/usr/src/lib/libast/common/include/ls.h b/usr/src/lib/libast/common/include/ls.h
new file mode 100644
index 0000000000..7c76462c86
--- /dev/null
+++ b/usr/src/lib/libast/common/include/ls.h
@@ -0,0 +1,88 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * ls formatter interface definitions
+ */
+
+#ifndef _LS_H
+#define _LS_H
+
+#include <ast_std.h>
+#include <ast_fs.h>
+#include <ast_mode.h>
+
+/*
+ * some systems (could it beee AIX) pollute the std name space
+ */
+
+#undef fileid
+#define fileid fileID
+
+#define LS_BLOCKSIZE 512
+
+#define iblocks(p) _iblocks(p)
+
+#if _mem_st_rdev_stat
+#define idevice(p) ((p)->st_rdev)
+#define IDEVICE(p,v) ((p)->st_rdev=(v))
+#else
+#define idevice(p) 0
+#define IDEVICE(p,v)
+#endif
+
+#define LS_ATIME (1<<0) /* list st_atime */
+#define LS_BLOCKS (1<<1) /* list blocks used by file */
+#define LS_CTIME (1<<2) /* list st_ctime */
+#define LS_EXTERNAL (1<<3) /* st_mode is modex canonical */
+#define LS_INUMBER (1<<4) /* list st_ino */
+#define LS_LONG (1<<5) /* long listing */
+#define LS_MARK (1<<6) /* append file name marks */
+#define LS_NOGROUP (1<<7) /* omit group name for LS_LONG */
+#define LS_NOUSER (1<<8) /* omit user name for LS_LONG */
+#define LS_NUMBER (1<<9) /* number instead of name */
+
+#define LS_USER (1<<10) /* first user flag bit */
+
+#define LS_W_BLOCKS 6 /* LS_BLOCKS field width */
+#define LS_W_INUMBER 7 /* LS_INUMBER field width */
+#define LS_W_LONG 55 /* LS_LONG width (w/o names) */
+#define LS_W_LINK 4 /* link text width (w/o names) */
+#define LS_W_MARK 1 /* LS_MARK field width */
+#define LS_W_NAME 9 /* group|user name field width */
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern off_t _iblocks(struct stat*);
+extern char* fmtdev(struct stat*);
+extern char* fmtfs(struct stat*);
+extern char* fmtls(char*, const char*, struct stat*, const char*, const char*, int);
+extern int pathstat(const char*, struct stat*);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/magic.h b/usr/src/lib/libast/common/include/magic.h
new file mode 100644
index 0000000000..a1dda68470
--- /dev/null
+++ b/usr/src/lib/libast/common/include/magic.h
@@ -0,0 +1,85 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * magic interface definitions
+ */
+
+#ifndef _MAGIC_H
+#define _MAGIC_H
+
+#include <sfio.h>
+#include <ls.h>
+
+#define MAGIC_VERSION 19961031L
+
+#ifndef MAGIC_FILE
+#define MAGIC_FILE "lib/file/magic"
+#endif
+
+#ifndef MAGIC_DIR
+#define MAGIC_DIR "lib/file"
+#endif
+
+#define MAGIC_FILE_ENV "MAGICFILE"
+
+#define MAGIC_MIME (1<<0) /* magictype returns MIME type */
+#define MAGIC_VERBOSE (1<<1) /* verbose magic file errors */
+
+#define MAGIC_USER (1L<<16) /* first user flag bit */
+
+struct Magic_s;
+struct Magicdisc_s;
+
+typedef struct Magicdisc_s
+{
+ unsigned long version; /* interface version */
+ unsigned long flags; /* MAGIC_* flags */
+ Error_f errorf; /* error function */
+} Magicdisc_t;
+
+typedef struct Magic_s
+{
+ const char* id; /* library id string */
+
+#ifdef _MAGIC_PRIVATE_
+ _MAGIC_PRIVATE_
+#endif
+
+} Magic_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Magic_t* magicopen(Magicdisc_t*);
+extern int magicload(Magic_t*, const char*, unsigned long);
+extern int magiclist(Magic_t*, Sfio_t*);
+extern char* magictype(Magic_t*, Sfio_t*, const char*, struct stat*);
+extern int magicclose(Magic_t*);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/magicid.h b/usr/src/lib/libast/common/include/magicid.h
new file mode 100644
index 0000000000..66e7343da3
--- /dev/null
+++ b/usr/src/lib/libast/common/include/magicid.h
@@ -0,0 +1,46 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * generic binary magic id definitions
+ */
+
+#ifndef _MAGICID_H
+#define _MAGICID_H 1
+
+#include <ast_common.h>
+
+#define MAGICID 0x00010203
+
+typedef uint32_t Magicid_data_t;
+
+typedef struct Magicid_s
+{
+ Magicid_data_t magic; /* magic number */
+ char name[8]; /* generic data/application name*/
+ char type[12]; /* specific data type */
+ Magicid_data_t version; /* YYYYMMDD or 0xWWXXYYZZ */
+ Magicid_data_t size;
+} Magicid_t;
+
+#endif
diff --git a/usr/src/lib/libast/common/include/mc.h b/usr/src/lib/libast/common/include/mc.h
new file mode 100644
index 0000000000..88406b6ed2
--- /dev/null
+++ b/usr/src/lib/libast/common/include/mc.h
@@ -0,0 +1,96 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * machine independent binary message catalog interface
+ *
+ * file layout
+ * all numbers are sfputu() format
+ *
+ * 4 char magic (^M^S^G0)
+ * <method locale YYYY-MM-DD>\0
+ * (<optional strings>\0)*
+ * \0
+ * string table size
+ * #msgs total
+ * #max set number
+ * #set-id 1
+ * #msgs in set 1
+ * ...
+ * #set-id #sets
+ * #msgs in set #sets
+ * end of sets (0)
+ * msg(1,1) size
+ * ...
+ * msg(#sets,#msgs) size
+ * string table
+ */
+
+#ifndef _MC_H
+#define _MC_H
+
+#include <ast.h>
+
+#define MC_MAGIC "\015\023\007\000"
+#define MC_MAGIC_SIZE 4
+
+#define MC_SET_MAX 1023
+#define MC_NUM_MAX 32767
+
+#define MC_NLS (1<<10)
+
+#define MC_MESSAGE_SET(s) mcindex(s,NiL,NiL,NiL)
+
+typedef struct
+{
+ char** msg;
+ int num;
+ int gen;
+} Mcset_t;
+
+typedef struct
+{
+ Mcset_t* set;
+ int num;
+ int gen;
+ char* translation;
+#ifdef _MC_PRIVATE_
+ _MC_PRIVATE_
+#endif
+} Mc_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern char* mcfind(char*, const char*, const char*, int, int);
+extern Mc_t* mcopen(Sfio_t*);
+extern char* mcget(Mc_t*, int, int, const char*);
+extern int mcput(Mc_t*, int, int, const char*);
+extern int mcdump(Mc_t*, Sfio_t*);
+extern int mcindex(const char*, char**, int*, int*);
+extern int mcclose(Mc_t*);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/mime.h b/usr/src/lib/libast/common/include/mime.h
new file mode 100644
index 0000000000..a25b06c0ec
--- /dev/null
+++ b/usr/src/lib/libast/common/include/mime.h
@@ -0,0 +1,91 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * mime/mailcap interface
+ */
+
+#ifndef _MIMETYPE_H
+#define _MIMETYPE_H 1
+
+#include <sfio.h>
+#include <ls.h>
+
+#define MIME_VERSION 19970717L
+
+#ifndef MIME_FILES
+#define MIME_FILES "~/.mailcap:/usr/local/etc/mailcap:/usr/etc/mailcap:/etc/mailcap:/etc/mail/mailcap:/usr/public/lib/mailcap"
+#endif
+
+#define MIME_FILES_ENV "MAILCAP"
+
+#define MIME_LIST (1<<0) /* mimeload arg is : list */
+#define MIME_NOMAGIC (1<<1) /* no magic for mimetype() */
+#define MIME_PIPE (1<<2) /* mimeview() io is piped */
+#define MIME_REPLACE (1<<3) /* replace existing definition */
+
+#define MIME_USER (1L<<16) /* first user flag bit */
+
+struct Mime_s;
+typedef struct Mime_s Mime_t;
+
+struct Mimedisc_s;
+typedef struct Mimedisc_s Mimedisc_t;
+
+typedef int (*Mimevalue_f)(Mime_t*, void*, char*, size_t, Mimedisc_t*);
+
+struct Mimedisc_s
+{
+ unsigned long version; /* interface version */
+ unsigned long flags; /* MIME_* flags */
+ Error_f errorf; /* error function */
+ Mimevalue_f valuef; /* value extraction function */
+};
+
+struct Mime_s
+{
+ const char* id; /* library id string */
+
+#ifdef _MIME_PRIVATE_
+ _MIME_PRIVATE_
+#endif
+
+};
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Mime_t* mimeopen(Mimedisc_t*);
+extern int mimeload(Mime_t*, const char*, unsigned long);
+extern int mimelist(Mime_t*, Sfio_t*, const char*);
+extern int mimeclose(Mime_t*);
+extern int mimeset(Mime_t*, char*, unsigned long);
+extern char* mimetype(Mime_t*, Sfio_t*, const char*, struct stat*);
+extern char* mimeview(Mime_t*, const char*, const char*, const char*, const char*);
+extern int mimehead(Mime_t*, void*, size_t, size_t, char*);
+extern int mimecmp(const char*, const char*, char**);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/mnt.h b/usr/src/lib/libast/common/include/mnt.h
new file mode 100644
index 0000000000..402972e6f9
--- /dev/null
+++ b/usr/src/lib/libast/common/include/mnt.h
@@ -0,0 +1,58 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * mounted filesystem scan interface
+ */
+
+#ifndef _MNT_H
+#define _MNT_H 1
+
+#undef MNT_REMOTE /* aix clash */
+#define MNT_REMOTE (1<<0) /* remote mount */
+
+typedef struct
+{
+ char* fs; /* filesystem name */
+ char* dir; /* mounted dir */
+ char* type; /* filesystem type */
+ char* options; /* options */
+ int freq; /* backup frequency */
+ int npass; /* number of parallel passes */
+ int flags; /* MNT_* flags */
+} Mnt_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern void* mntopen(const char*, const char*);
+extern Mnt_t* mntread(void*);
+extern int mntwrite(void*, const Mnt_t*);
+extern int mntclose(void*);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/modecanon.h b/usr/src/lib/libast/common/include/modecanon.h
new file mode 100644
index 0000000000..bed378551d
--- /dev/null
+++ b/usr/src/lib/libast/common/include/modecanon.h
@@ -0,0 +1,65 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * canonical mode_t representation
+ */
+
+#ifndef _MODECANON_H
+#define _MODECANON_H
+
+#define X_ITYPE(m) ((m)&X_IFMT)
+
+#define X_IFMT 0170000
+#define X_IFWHT 0160000
+#define X_IFDOOR 0150000
+#define X_IFSOCK 0140000
+#define X_IFLNK 0120000
+#define X_IFCTG 0110000
+#define X_IFREG 0100000
+#define X_IFBLK 0060000
+#define X_IFDIR 0040000
+#define X_IFCHR 0020000
+#define X_IFIFO 0010000
+
+#define X_IPERM 0007777
+#define X_ISUID 0004000
+#define X_ISGID 0002000
+#define X_ISVTX 0001000
+#define X_IRUSR 0000400
+#define X_IWUSR 0000200
+#define X_IXUSR 0000100
+#define X_IRGRP 0000040
+#define X_IWGRP 0000020
+#define X_IXGRP 0000010
+#define X_IROTH 0000004
+#define X_IWOTH 0000002
+#define X_IXOTH 0000001
+
+#define X_IRWXU (X_IRUSR|X_IWUSR|X_IXUSR)
+#define X_IRWXG (X_IRGRP|X_IWGRP|X_IXGRP)
+#define X_IRWXO (X_IROTH|X_IWOTH|X_IXOTH)
+
+#endif
diff --git a/usr/src/lib/libast/common/include/modex.h b/usr/src/lib/libast/common/include/modex.h
new file mode 100644
index 0000000000..62f3103a1c
--- /dev/null
+++ b/usr/src/lib/libast/common/include/modex.h
@@ -0,0 +1,51 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * AT&T Research
+ *
+ * external mode_t representation support
+ */
+
+#ifndef _MODEX_H
+#define _MODEX_H
+
+#include <ast_fs.h>
+#include <modecanon.h>
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int modei(int);
+extern int modex(int);
+
+#undef extern
+
+#if _S_IDPERM
+#define modei(m) ((m)&X_IPERM)
+#if _S_IDTYPE
+#define modex(m) (m)
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/include/namval.h b/usr/src/lib/libast/common/include/namval.h
new file mode 100644
index 0000000000..fe5f2d4221
--- /dev/null
+++ b/usr/src/lib/libast/common/include/namval.h
@@ -0,0 +1,42 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * common name-value struct support
+ */
+
+#ifndef _NAMVAL_H
+#define _NAMVAL_H
+
+typedef struct
+{
+ char* name;
+ int value;
+#ifdef _NAMVAL_PRIVATE_
+ _NAMVAL_PRIVATE_
+#endif
+} Namval_t;
+
+#endif
diff --git a/usr/src/lib/libast/common/include/option.h b/usr/src/lib/libast/common/include/option.h
new file mode 100644
index 0000000000..87315616fb
--- /dev/null
+++ b/usr/src/lib/libast/common/include/option.h
@@ -0,0 +1,105 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * command line option parse interface
+ */
+
+#ifndef _OPTION_H
+#define _OPTION_H
+
+#include <ast.h>
+
+#define OPT_VERSION 20070319L
+
+#define OPT_USER (1L<<16) /* first user flag bit */
+
+struct Opt_s;
+struct Optdisc_s;
+
+typedef int (*Optinfo_f)(struct Opt_s*, Sfio_t*, const char*, struct Optdisc_s*);
+
+typedef struct Optdisc_s
+{
+ unsigned long version; /* OPT_VERSION */
+ unsigned long flags; /* OPT_* flags */
+ char* catalog; /* error catalog id */
+ Optinfo_f infof; /* runtime info function */
+} Optdisc_t;
+
+/* NOTE: Opt_t member order fixed by a previous binary release */
+
+#ifndef _OPT_PRIVATE_
+#define _OPT_PRIVATE_ \
+ char pad[3*sizeof(void*)];
+#endif
+
+typedef struct Opt_s
+{
+ int again; /* see optjoin() */
+ char* arg; /* {:,#} string argument */
+ char** argv; /* most recent argv */
+ int index; /* argv index */
+ char* msg; /* error/usage message buffer */
+ long num; /* OBSOLETE -- use number */
+ int offset; /* char offset in argv[index] */
+ char option[8]; /* current flag {-,+} + option */
+ char name[64]; /* current long name or flag */
+ Optdisc_t* disc; /* user discipline */
+ intmax_t number; /* # numeric argument */
+ unsigned char assignment; /* option arg assigment op */
+ unsigned char pads[sizeof(void*)-1];
+ _OPT_PRIVATE_
+} Opt_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#define extern extern __IMPORT__
+#endif
+
+extern Opt_t* _opt_infop_;
+
+#define opt_info (*_opt_infop_)
+
+#undef extern
+
+#define optinit(d,f) (memset(d,0,sizeof(*(d))),(d)->version=OPT_VERSION,(d)->infof=(f),opt_info.disc=(d))
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int optget(char**, const char*);
+extern int optjoin(char**, ...);
+extern char* opthelp(const char*, const char*);
+extern char* optusage(const char*);
+extern int optstr(const char*, const char*);
+extern int optesc(Sfio_t*, const char*, int);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/proc.h b/usr/src/lib/libast/common/include/proc.h
new file mode 100644
index 0000000000..8535b49dd7
--- /dev/null
+++ b/usr/src/lib/libast/common/include/proc.h
@@ -0,0 +1,102 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * process library interface
+ */
+
+#ifndef _PROC_H
+#define _PROC_H
+
+#include <ast.h>
+
+#define PROC_ARGMOD (1<<0) /* argv[-1],argv[0] can be modified */
+#define PROC_BACKGROUND (1<<1) /* shell background (&) setup */
+#define PROC_CLEANUP (1<<2) /* close parent redirect fds on error */
+#define PROC_DAEMON (1<<3) /* daemon setup */
+#define PROC_ENVCLEAR (1<<4) /* clear environment */
+#define PROC_FOREGROUND (1<<14) /* system(3) setup */
+#define PROC_GID (1<<5) /* setgid(getgid()) */
+#define PROC_IGNORE (1<<6) /* ignore parent pipe errors */
+#define PROC_OVERLAY (1<<7) /* overlay current process if possible */
+#define PROC_PARANOID (1<<8) /* restrict everything */
+#define PROC_PRIVELEGED (1<<9) /* setuid(0), setgid(getegid()) */
+#define PROC_READ (1<<10) /* proc pipe fd 1 returned */
+#define PROC_SESSION (1<<11) /* session leader */
+#define PROC_UID (1<<12) /* setuid(getuid()) */
+#define PROC_WRITE (1<<13) /* proc pipe fd 0 returned */
+#define PROC_ZOMBIE (1<<15) /* proc may leave a zombie behind */
+
+#define PROC_ARG_BIT 14 /* bits per op arg */
+#define PROC_OP_BIT 4 /* bits per op */
+
+#define PROC_ARG_NULL ((1<<PROC_ARG_BIT)-1)
+
+#define PROC_fd_dup 0x4
+#define PROC_FD_CHILD 0x1
+#define PROC_FD_PARENT 0x2
+
+#define PROC_sig_dfl 0x8
+#define PROC_sig_ign 0x9
+
+#define PROC_sys_pgrp 0xa
+#define PROC_sys_umask 0xb
+
+#define PROC_op1(o,a) (((o)<<(2*PROC_ARG_BIT))|((a)&((PROC_ARG_NULL<<PROC_ARG_BIT)|PROC_ARG_NULL)))
+#define PROC_op2(o,a,b) (((o)<<(2*PROC_ARG_BIT))|(((b)&PROC_ARG_NULL)<<PROC_ARG_BIT)|((a)&PROC_ARG_NULL))
+
+#define PROC_FD_CLOSE(p,f) PROC_op2(PROC_fd_dup|(f),p,PROC_ARG_NULL)
+#define PROC_FD_DUP(p,c,f) PROC_op2(PROC_fd_dup|(f),p,c)
+#define PROC_SIG_DFL(s) PROC_op1(PROC_sig_dfl,s,0)
+#define PROC_SIG_IGN(s) PROC_op1(PROC_sig_ign,s,0)
+#define PROC_SYS_PGRP(g) PROC_op1(PROC_sys_pgrp,g)
+#define PROC_SYS_UMASK(m) PROC_op1(PROC_sys_umask,m,0)
+
+#define PROC_OP(x) (((x)>>(2*PROC_ARG_BIT))&((1<<PROC_OP_BIT)-1))
+#define PROC_ARG(x,n) ((n)?(((x)>>(((n)-1)*PROC_ARG_BIT))&PROC_ARG_NULL):(((x)&~((1<<(2*PROC_ARG_BIT))-1))==~((1<<(2*PROC_ARG_BIT))-1))?(-1):((x)&~((1<<(2*PROC_ARG_BIT))-1)))
+
+typedef struct
+{
+ pid_t pid; /* process id */
+ pid_t pgrp; /* process group id */
+ int rfd; /* read fd if applicable */
+ int wfd; /* write fd if applicable */
+
+#ifdef _PROC_PRIVATE_
+_PROC_PRIVATE_
+#endif
+
+} Proc_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int procclose(Proc_t*);
+extern int procfree(Proc_t*);
+extern Proc_t* procopen(const char*, char**, char**, long*, long);
+extern int procrun(const char*, char**);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/recfmt.h b/usr/src/lib/libast/common/include/recfmt.h
new file mode 100644
index 0000000000..e90375cb03
--- /dev/null
+++ b/usr/src/lib/libast/common/include/recfmt.h
@@ -0,0 +1,83 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * record format interface
+ */
+
+#ifndef _RECFMT_H
+#define _RECFMT_H 1
+
+#include <ast.h>
+
+typedef uint32_t Recfmt_t;
+
+#define REC_delimited 0
+#define REC_fixed 1
+#define REC_variable 2
+#define REC_method 14
+#define REC_none 15
+
+#define REC_M_path 0
+#define REC_M_data 1
+
+#define RECTYPE(f) (((f)>>28)&((1<<4)-1))
+
+#define REC_D_TYPE(d) ((REC_delimited<<28)|((d)&((1<<8)-1)))
+#define REC_D_DELIMITER(f) ((f)&((1<<8)-1))
+
+#define REC_F_TYPE(s) ((REC_fixed<<28)|((s)&((1<<28)-1)))
+#define REC_F_SIZE(f) ((f)&((1<<28)-1))
+
+#define REC_U_TYPE(t,a) (((t)<<28)|((a)&((1<<28)-1)))
+#define REC_U_ATTRIBUTES(f) ((f)&~((1<<28)-1))
+
+#define REC_V_TYPE(h,o,z,l,i) ((REC_variable<<28)|((h)<<23)|((o)<<19)|(((z)-1)<<18)|((l)<<17)|((i)<<16))
+#define REC_V_RECORD(f,s) (((f)&(((1<<16)-1)<<16))|(s))
+#define REC_V_HEADER(f) (((f)>>23)&((1<<5)-1))
+#define REC_V_OFFSET(f) (((f)>>19)&((1<<4)-1))
+#define REC_V_LENGTH(f) ((((f)>>18)&1)+1)
+#define REC_V_LITTLE(f) (((f)>>17)&1)
+#define REC_V_INCLUSIVE(f) (((f)>>16)&1)
+#define REC_V_SIZE(f) ((f)&((1<<16)-1))
+#define REC_V_ATTRIBUTES(f) ((f)&~((1<<16)-1))
+
+#define REC_M_TYPE(i) ((REC_method<<28)|(i))
+#define REC_M_INDEX(f) ((f)&((1<<28)-1))
+
+#define REC_N_TYPE() 0xffffffff
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern char* fmtrec(Recfmt_t, int);
+extern Recfmt_t recfmt(const void*, size_t, off_t);
+extern Recfmt_t recstr(const char*, char**);
+extern ssize_t reclen(Recfmt_t, const void*, size_t);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/regex.h b/usr/src/lib/libast/common/include/regex.h
new file mode 100644
index 0000000000..4251bbefbd
--- /dev/null
+++ b/usr/src/lib/libast/common/include/regex.h
@@ -0,0 +1,243 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * regex library interface
+ */
+
+#ifdef _AST_STD_I
+#define _REGEX_H -1
+#define regex_t int
+#define regmatch_t int
+#endif
+#ifndef _REGEX_H
+#define _REGEX_H 1
+#undef regex_t
+#undef regmatch_t
+
+#include <ast_common.h>
+
+#define REG_VERSION 20030916L
+
+/* regcomp flags */
+
+#define REG_AUGMENTED 0x00000001 /* enable ! & < > */
+#define REG_EXTENDED 0x00000002 /* enable ( | ) */
+#define REG_ICASE 0x00000004 /* ignore case in match */
+#define REG_NEWLINE 0x00000008 /* ^/$ match embedded \n */
+#define REG_NOSUB 0x00000010 /* don't report subexp matches */
+#define REG_SHELL 0x00000020 /* shell pattern syntax */
+
+/* nonstandard regcomp flags */
+
+#define REG_LEFT 0x00000100 /* implicit ^... */
+#define REG_LITERAL 0x00000200 /* no operators */
+#define REG_MINIMAL 0x00000400 /* minimal match */
+#define REG_NULL 0x00000800 /* allow null patterns */
+#define REG_RIGHT 0x00001000 /* implicit ...$ */
+#define REG_LENIENT 0x00002000 /* look the other way */
+#define REG_ESCAPE 0x00004000 /* \ escapes delimiter in [...] */
+#define REG_FIRST 0x00008000 /* first match found will do */
+#define REG_MULTIPLE 0x00010000 /* multiple \n sep patterns */
+#define REG_DISCIPLINE 0x00020000 /* regex_t.re_disc is valid */
+#define REG_SPAN 0x00040000 /* . matches \n */
+#define REG_COMMENT 0x00080000 /* ignore pattern space & #...\n*/
+#define REG_MULTIREF 0x00100000 /* multiple digit backrefs */
+#define REG_MUSTDELIM 0x08000000 /* all delimiters required */
+#define REG_DELIMITED 0x10000000 /* pattern[0] is delimiter */
+#define REG_SHELL_GROUP 0x20000000 /* (|&) inside [@|&](...) only */
+
+#define REG_SHELL_DOT 0x00200000 /* explicit leading . match */
+#define REG_SHELL_ESCAPED 0x00400000 /* \ not special */
+#define REG_SHELL_PATH 0x00800000 /* explicit / match */
+
+/* regexec flags */
+
+#define REG_NOTBOL 0x00000040 /* ^ is not a special char */
+#define REG_NOTEOL 0x00000080 /* $ is not a special char */
+
+/* nonstandard regexec flags */
+
+#define REG_INVERT 0x01000000 /* invert regrexec match sense */
+#define REG_STARTEND 0x02000000 /* subject==match[0].rm_{so,eo} */
+#define REG_ADVANCE 0x04000000 /* advance match[0].rm_{so,eo} */
+
+/* regalloc flags */
+
+#define REG_NOFREE 0x00000001 /* don't free */
+
+/* regsub flags */
+
+#define REG_SUB_ALL 0x00000001 /* substitute all occurrences */
+#define REG_SUB_LOWER 0x00000002 /* substitute to lower case */
+#define REG_SUB_UPPER 0x00000004 /* substitute to upper case */
+#define REG_SUB_PRINT 0x00000010 /* internal no-op */
+#define REG_SUB_NUMBER 0x00000020 /* internal no-op */
+#define REG_SUB_STOP 0x00000040 /* internal no-op */
+#define REG_SUB_WRITE 0x00000080 /* internal no-op */
+#define REG_SUB_LAST 0x00000100 /* last substitution option */
+#define REG_SUB_FULL 0x00000200 /* fully delimited */
+#define REG_SUB_USER 0x00001000 /* first user flag bit */
+
+/* regex error codes */
+
+#define REG_ENOSYS (-1) /* not supported */
+#define REG_NOMATCH 1 /* regexec didn't match */
+#define REG_BADPAT 2 /* invalid regular expression */
+#define REG_ECOLLATE 3 /* invalid collation element */
+#define REG_ECTYPE 4 /* invalid character class */
+#define REG_EESCAPE 5 /* trailing \ in pattern */
+#define REG_ESUBREG 6 /* invalid \digit backreference */
+#define REG_EBRACK 7 /* [...] imbalance */
+#define REG_EPAREN 8 /* \(...\) or (...) imbalance */
+#define REG_EBRACE 9 /* \{...\} or {...} imbalance */
+#define REG_BADBR 10 /* invalid {...} digits */
+#define REG_ERANGE 11 /* invalid [...] range endpoint */
+#define REG_ESPACE 12 /* out of space */
+#define REG_BADRPT 13 /* unary op not preceeded by re */
+#define REG_ENULL 14 /* empty subexpr in pattern */
+#define REG_ECOUNT 15 /* re component count overflow */
+#define REG_BADESC 16 /* invalid \char escape */
+#define REG_VERSIONID 17 /* version id (pseudo error) */
+#define REG_EFLAGS 18 /* flags conflict */
+#define REG_EDELIM 19 /* invalid or omitted delimiter */
+#define REG_PANIC 20 /* unrecoverable internal error */
+
+struct regex_s; typedef struct regex_s regex_t;
+struct regdisc_s; typedef struct regdisc_s regdisc_t;
+
+typedef int (*regclass_t)(int);
+typedef int32_t regflags_t;
+typedef int regoff_t;
+typedef int (*regerror_t)(const regex_t*, regdisc_t*, int, ...);
+typedef void* (*regcomp_t)(const regex_t*, const char*, size_t, regdisc_t*);
+typedef int (*regexec_t)(const regex_t*, void*, const char*, size_t, const char*, size_t, char**, regdisc_t*);
+typedef void* (*regresize_t)(void*, void*, size_t);
+typedef int (*regrecord_t)(void*, const char*, size_t);
+
+typedef struct regmatch_s
+{
+ regoff_t rm_so; /* offset of start */
+ regoff_t rm_eo; /* offset of end */
+} regmatch_t;
+
+typedef struct regsub_s
+{
+ regflags_t re_flags; /* regsubcomp() flags */
+ char* re_buf; /* regsubexec() output buffer */
+ size_t re_len; /* re_buf length */
+ int re_min; /* regsubcomp() min matches */
+#ifdef _REG_SUB_PRIVATE_
+ _REG_SUB_PRIVATE_
+#endif
+} regsub_t;
+
+struct regdisc_s
+{
+ unsigned long re_version; /* discipline version */
+ regflags_t re_flags; /* discipline flags */
+ regerror_t re_errorf; /* error function */
+ int re_errorlevel; /* errorf level */
+ regresize_t re_resizef; /* alloc/free function */
+ void* re_resizehandle;/* resizef handle */
+ regcomp_t re_compf; /* (?{...}) compile function */
+ regexec_t re_execf; /* (?{...}) execute function */
+ unsigned char* re_map; /* external to native ccode map */
+};
+
+typedef struct regstat_s
+{
+ regflags_t re_flags; /* REG_LEFT|REG_RIGHT */
+ ssize_t re_min; /* min anchored match length */
+ ssize_t re_max; /* max anchored match length */
+ ssize_t re_record; /* regrexec() match length */
+} regstat_t;
+
+struct regex_s
+{
+ size_t re_nsub; /* number of subexpressions */
+ struct reglib_s*re_info; /* library private info */
+ size_t re_npat; /* number of pattern chars used */
+ regdisc_t* re_disc; /* REG_DISCIPLINE discipline */
+ regsub_t* re_sub; /* regsubcomp() data */
+};
+
+#define reginit(disc) (memset(disc,0,sizeof(*(disc))),(disc)->re_version=REG_VERSION)
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int regcomp(regex_t*, const char*, regflags_t);
+extern size_t regerror(int, const regex_t*, char*, size_t);
+extern int regexec(const regex_t*, const char*, size_t, regmatch_t*, regflags_t);
+extern void regfree(regex_t*);
+
+/* nonstandard hooks */
+
+#define _REG_cache 1 /* have regcache() */
+#define _REG_class 1 /* have regclass() */
+#define _REG_collate 1 /* have regcollate(), regclass() */
+#define _REG_comb 1 /* have regcomb() */
+#define _REG_decomp 1 /* have regdecomp() */
+#define _REG_dup 1 /* have regdup() */
+#define _REG_fatal 1 /* have regfatal(), regfatalpat() */
+#define _REG_ncomp 1 /* have regncomp() */
+#define _REG_nexec 1 /* have regnexec() */
+#define _REG_rexec 1 /* have regrexec(), regrecord() */
+#define _REG_stat 1 /* have regstat() */
+#define _REG_subcomp 1 /* have regsubcomp(), regsubexec() */
+
+extern regclass_t regclass(const char*, char**);
+extern int regaddclass(const char*, regclass_t);
+extern int regcollate(const char*, char**, char*, int);
+extern int regcomb(regex_t*, regex_t*);
+extern size_t regdecomp(regex_t*, regflags_t, char*, size_t);
+extern int regdup(regex_t*, regex_t*);
+extern int regncomp(regex_t*, const char*, size_t, regflags_t);
+extern int regnexec(const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t);
+extern void regfatal(regex_t*, int, int);
+extern void regfatalpat(regex_t*, int, int, const char*);
+extern int regrecord(const regex_t*);
+extern int regrexec(const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t, int, void*, regrecord_t);
+extern regstat_t* regstat(const regex_t*);
+
+extern regex_t* regcache(const char*, regflags_t, int*);
+
+extern int regsubcomp(regex_t*, const char*, const regflags_t*, int, regflags_t);
+extern int regsubexec(const regex_t*, const char*, size_t, regmatch_t*);
+extern int regsubflags(regex_t*, const char*, char**, int, const regflags_t*, int*, regflags_t*);
+extern void regsubfree(regex_t*);
+
+/* obsolete hooks */
+
+#ifndef _SFIO_H
+struct _sfio_s;
+#endif
+
+extern void regalloc(void*, regresize_t, regflags_t);
+extern int regsub(const regex_t*, struct _sfio_s*, const char*, const char*, size_t, regmatch_t*, regflags_t);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/sfdisc.h b/usr/src/lib/libast/common/include/sfdisc.h
new file mode 100644
index 0000000000..b58d50674f
--- /dev/null
+++ b/usr/src/lib/libast/common/include/sfdisc.h
@@ -0,0 +1,71 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * AT&T Research
+ *
+ * sfio discipline interface definitions
+ */
+
+#ifndef _SFDISC_H
+#define _SFDISC_H
+
+#include <ast.h>
+
+#define SFDCEVENT(a,b,n) ((((a)-'A'+1)<<11)^(((b)-'A'+1)<<6)^(n))
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+#define SFSK_DISCARD SFDCEVENT('S','K',1)
+
+/*
+ * %(...) printf support
+ */
+
+typedef int (*Sf_key_lookup_t)(void*, Sffmt_t*, const char*, char**, Sflong_t*);
+typedef char* (*Sf_key_convert_t)(void*, Sffmt_t*, const char*, char*, Sflong_t);
+
+extern int sfkeyprintf(Sfio_t*, void*, const char*, Sf_key_lookup_t, Sf_key_convert_t);
+#define sfkeyprintf sfkeyprintf_20000308 /* Sffmt_t* callback args */
+extern int sfkeyprintf(Sfio_t*, void*, const char*, Sf_key_lookup_t, Sf_key_convert_t);
+
+/*
+ * pure sfio read and/or write disciplines
+ */
+
+extern int sfdcdio(Sfio_t*, size_t);
+extern int sfdcdos(Sfio_t*);
+extern int sfdcfilter(Sfio_t*, const char*);
+extern int sfdcmore(Sfio_t*, const char*, int, int);
+extern int sfdcprefix(Sfio_t*, const char*);
+extern int sfdcseekable(Sfio_t*);
+extern int sfdcslow(Sfio_t*);
+extern int sfdctee(Sfio_t*, Sfio_t*);
+extern int sfdcunion(Sfio_t*, Sfio_t**, int);
+
+extern Sfio_t* sfdcsubstream(Sfio_t*, Sfio_t*, Sfoff_t, Sfoff_t);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/sfio.h b/usr/src/lib/libast/common/include/sfio.h
new file mode 100644
index 0000000000..9feba3043e
--- /dev/null
+++ b/usr/src/lib/libast/common/include/sfio.h
@@ -0,0 +1,452 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _SFIO_H
+#define _SFIO_H 1
+
+#define SFIO_VERSION 20050202L
+
+/* Public header file for the sfio library
+**
+** Written by Kiem-Phong Vo
+*/
+
+typedef struct _sfio_s Sfio_t;
+typedef struct _sfdisc_s Sfdisc_t;
+
+#if defined(_AST_STD_H) || defined(_PACKAGE_ast) && defined(_SFIO_PRIVATE)
+#include <ast_std.h>
+#else
+#include <ast_common.h>
+#endif /* _PACKAGE_ast */
+
+/* Sfoff_t should be large enough for largest file address */
+#define Sfoff_t intmax_t
+#define Sflong_t intmax_t
+#define Sfulong_t uintmax_t
+#define Sfdouble_t _ast_fltmax_t
+
+typedef ssize_t (*Sfread_f)_ARG_((Sfio_t*, Void_t*, size_t, Sfdisc_t*));
+typedef ssize_t (*Sfwrite_f)_ARG_((Sfio_t*, const Void_t*, size_t, Sfdisc_t*));
+typedef Sfoff_t (*Sfseek_f)_ARG_((Sfio_t*, Sfoff_t, int, Sfdisc_t*));
+typedef int (*Sfexcept_f)_ARG_((Sfio_t*, int, Void_t*, Sfdisc_t*));
+
+/* discipline structure */
+struct _sfdisc_s
+{ Sfread_f readf; /* read function */
+ Sfwrite_f writef; /* write function */
+ Sfseek_f seekf; /* seek function */
+ Sfexcept_f exceptf; /* to handle exceptions */
+ Sfdisc_t* disc; /* the continuing discipline */
+};
+
+#include <sfio_s.h>
+
+/* formatting environment */
+typedef struct _sffmt_s Sffmt_t;
+typedef int (*Sffmtext_f)_ARG_((Sfio_t*, Void_t*, Sffmt_t*));
+typedef int (*Sffmtevent_f)_ARG_((Sfio_t*, int, Void_t*, Sffmt_t*));
+struct _sffmt_s
+{ long version;/* version of this structure */
+ Sffmtext_f extf; /* function to process arguments */
+ Sffmtevent_f eventf; /* process events */
+
+ char* form; /* format string to stack */
+ va_list args; /* corresponding arg list */
+
+ int fmt; /* format character */
+ ssize_t size; /* object size */
+ int flags; /* formatting flags */
+ int width; /* width of field */
+ int precis; /* precision required */
+ int base; /* conversion base */
+
+ char* t_str; /* type string */
+ ssize_t n_str; /* length of t_str */
+
+ Void_t* mbs; /* multibyte state for format string */
+
+ Void_t* none; /* unused for now */
+};
+#define sffmtversion(fe,type) \
+ ((type) ? ((fe)->version = SFIO_VERSION) : (fe)->version)
+
+#define SFFMT_SSHORT 000000010 /* 'hh' flag, char */
+#define SFFMT_TFLAG 000000020 /* 't' flag, ptrdiff_t */
+#define SFFMT_ZFLAG 000000040 /* 'z' flag, size_t */
+
+#define SFFMT_LEFT 000000100 /* left-justification */
+#define SFFMT_SIGN 000000200 /* must have a sign */
+#define SFFMT_BLANK 000000400 /* if not signed, prepend a blank */
+#define SFFMT_ZERO 000001000 /* zero-padding on the left */
+#define SFFMT_ALTER 000002000 /* alternate formatting */
+#define SFFMT_THOUSAND 000004000 /* thousand grouping */
+#define SFFMT_SKIP 000010000 /* skip assignment in scanf() */
+#define SFFMT_SHORT 000020000 /* 'h' flag */
+#define SFFMT_LONG 000040000 /* 'l' flag */
+#define SFFMT_LLONG 000100000 /* 'll' flag */
+#define SFFMT_LDOUBLE 000200000 /* 'L' flag */
+#define SFFMT_VALUE 000400000 /* value is returned */
+#define SFFMT_ARGPOS 001000000 /* getting arg for $ patterns */
+#define SFFMT_IFLAG 002000000 /* 'I' flag */
+#define SFFMT_JFLAG 004000000 /* 'j' flag, intmax_t */
+#define SFFMT_CENTER 010000000 /* '=' flag, center justification */
+#define SFFMT_SET 017777770 /* flags settable on calling extf */
+
+/* for sfmutex() call */
+#define SFMTX_LOCK 0 /* up mutex count */
+#define SFMTX_TRYLOCK 1 /* try to up mutex count */
+#define SFMTX_UNLOCK 2 /* down mutex count */
+#define SFMTX_CLRLOCK 3 /* clear mutex count */
+
+/* various constants */
+#ifndef NULL
+#define NULL 0
+#endif
+#ifndef EOF
+#define EOF (-1)
+#endif
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+/* bits for various types of files */
+#define SF_READ 0000001 /* open for reading */
+#define SF_WRITE 0000002 /* open for writing */
+#define SF_STRING 0000004 /* a string stream */
+#define SF_APPENDWR 0000010 /* file is in append mode only */
+#define SF_MALLOC 0000020 /* buffer is malloc-ed */
+#define SF_LINE 0000040 /* line buffering */
+#define SF_SHARE 0000100 /* stream with shared file descriptor */
+#define SF_EOF 0000200 /* eof was detected */
+#define SF_ERROR 0000400 /* an error happened */
+#define SF_STATIC 0001000 /* a stream that cannot be freed */
+#define SF_IOCHECK 0002000 /* call exceptf before doing IO */
+#define SF_PUBLIC 0004000 /* SF_SHARE and follow physical seek */
+#define SF_MTSAFE 0010000 /* need thread safety */
+#define SF_WHOLE 0020000 /* preserve wholeness of sfwrite/sfputr */
+#define SF_IOINTR 0040000 /* return on interrupts */
+#define SF_WCWIDTH 0100000 /* wcwidth display stream */
+
+#define SF_FLAGS 0177177 /* PUBLIC FLAGS PASSABLE TO SFNEW() */
+#define SF_SETS 0177163 /* flags passable to sfset() */
+
+#ifndef _SF_NO_OBSOLETE
+#define SF_BUFCONST 0400000 /* unused flag - for compatibility only */
+#endif
+
+/* for sfgetr/sfreserve to hold a record */
+#define SF_LOCKR 0000010 /* lock record, stop access to stream */
+#define SF_LASTR 0000020 /* get the last incomplete record */
+
+/* exception events: SF_NEW(0), SF_READ(1), SF_WRITE(2) and the below */
+#define SF_SEEK 3 /* seek error */
+#define SF_CLOSING 4 /* when stream is about to be closed */
+#define SF_DPUSH 5 /* when discipline is being pushed */
+#define SF_DPOP 6 /* when discipline is being popped */
+#define SF_DPOLL 7 /* see if stream is ready for I/O */
+#define SF_DBUFFER 8 /* buffer not empty during push or pop */
+#define SF_SYNC 9 /* announcing start/end synchronization */
+#define SF_PURGE 10 /* a sfpurge() call was issued */
+#define SF_FINAL 11 /* closing is done except stream free */
+#define SF_READY 12 /* a polled stream is ready */
+#define SF_LOCKED 13 /* stream is in a locked state */
+#define SF_ATEXIT 14 /* process is exiting */
+#define SF_EVENT 100 /* start of user-defined events */
+
+/* for stack and disciplines */
+#define SF_POPSTACK ((Sfio_t*)0) /* pop the stream stack */
+#define SF_POPDISC ((Sfdisc_t*)0) /* pop the discipline stack */
+
+/* for the notify function and discipline exception */
+#define SF_NEW 0 /* new stream */
+#define SF_SETFD (-1) /* about to set the file descriptor */
+
+#define SF_BUFSIZE 8192 /* default buffer size */
+#define SF_UNBOUND (-1) /* unbounded buffer size */
+
+/* namespace incursion workarounds -- migrate to the new names */
+#if !_mac_SF_APPEND
+#define SF_APPEND SF_APPENDWR /* BSDI sys/stat.h */
+#endif
+#if !_mac_SF_CLOSE
+#define SF_CLOSE SF_CLOSING /* AIX sys/socket.h */
+#endif
+
+_BEGIN_EXTERNS_
+
+/* standard in/out/err streams */
+
+#if _BLD_sfio && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+#if !_BLD_sfio && defined(__IMPORT__)
+#define extern extern __IMPORT__
+#endif
+
+extern ssize_t _Sfi;
+extern ssize_t _Sfmaxr;
+
+extern Sfio_t* sfstdin;
+extern Sfio_t* sfstdout;
+extern Sfio_t* sfstderr;
+
+#if _UWIN
+#undef extern
+#endif
+
+extern Sfio_t _Sfstdin;
+extern Sfio_t _Sfstdout;
+extern Sfio_t _Sfstderr;
+
+#undef extern
+
+#if _BLD_sfio && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Sfio_t* sfnew _ARG_((Sfio_t*, Void_t*, size_t, int, int));
+extern Sfio_t* sfopen _ARG_((Sfio_t*, const char*, const char*));
+extern Sfio_t* sfpopen _ARG_((Sfio_t*, const char*, const char*));
+extern Sfio_t* sfstack _ARG_((Sfio_t*, Sfio_t*));
+extern Sfio_t* sfswap _ARG_((Sfio_t*, Sfio_t*));
+extern Sfio_t* sftmp _ARG_((size_t));
+extern int sfpurge _ARG_((Sfio_t*));
+extern int sfpoll _ARG_((Sfio_t**, int, int));
+extern Void_t* sfreserve _ARG_((Sfio_t*, ssize_t, int));
+extern int sfresize _ARG_((Sfio_t*, Sfoff_t));
+extern int sfsync _ARG_((Sfio_t*));
+extern int sfclrlock _ARG_((Sfio_t*));
+extern Void_t* sfsetbuf _ARG_((Sfio_t*, Void_t*, size_t));
+extern Sfdisc_t* sfdisc _ARG_((Sfio_t*,Sfdisc_t*));
+extern int sfraise _ARG_((Sfio_t*, int, Void_t*));
+extern int sfnotify _ARG_((void(*)(Sfio_t*, int, int)));
+extern int sfset _ARG_((Sfio_t*, int, int));
+extern int sfsetfd _ARG_((Sfio_t*, int));
+extern Sfio_t* sfpool _ARG_((Sfio_t*, Sfio_t*, int));
+extern ssize_t sfread _ARG_((Sfio_t*, Void_t*, size_t));
+extern ssize_t sfwrite _ARG_((Sfio_t*, const Void_t*, size_t));
+extern Sfoff_t sfmove _ARG_((Sfio_t*, Sfio_t*, Sfoff_t, int));
+extern int sfclose _ARG_((Sfio_t*));
+extern Sfoff_t sftell _ARG_((Sfio_t*));
+extern Sfoff_t sfseek _ARG_((Sfio_t*, Sfoff_t, int));
+extern ssize_t sfputr _ARG_((Sfio_t*, const char*, int));
+extern char* sfgetr _ARG_((Sfio_t*, int, int));
+extern ssize_t sfnputc _ARG_((Sfio_t*, int, size_t));
+extern int sfungetc _ARG_((Sfio_t*, int));
+extern int sfprintf _ARG_((Sfio_t*, const char*, ...));
+extern char* sfprints _ARG_((const char*, ...));
+extern ssize_t sfsprintf _ARG_((char*, size_t, const char*, ...));
+extern ssize_t sfvsprintf _ARG_((char*, size_t, const char*, va_list));
+extern int sfvprintf _ARG_((Sfio_t*, const char*, va_list));
+extern int sfscanf _ARG_((Sfio_t*, const char*, ...));
+extern int sfsscanf _ARG_((const char*, const char*, ...));
+extern int sfvsscanf _ARG_((const char*, const char*, va_list));
+extern int sfvscanf _ARG_((Sfio_t*, const char*, va_list));
+
+/* mutex locking for thread-safety */
+extern int sfmutex _ARG_((Sfio_t*, int));
+
+/* io functions with discipline continuation */
+extern ssize_t sfrd _ARG_((Sfio_t*, Void_t*, size_t, Sfdisc_t*));
+extern ssize_t sfwr _ARG_((Sfio_t*, const Void_t*, size_t, Sfdisc_t*));
+extern Sfoff_t sfsk _ARG_((Sfio_t*, Sfoff_t, int, Sfdisc_t*));
+extern ssize_t sfpkrd _ARG_((int, Void_t*, size_t, int, long, int));
+
+/* portable handling of primitive types */
+extern int sfdlen _ARG_((Sfdouble_t));
+extern int sfllen _ARG_((Sflong_t));
+extern int sfulen _ARG_((Sfulong_t));
+
+extern int sfputd _ARG_((Sfio_t*, Sfdouble_t));
+extern int sfputl _ARG_((Sfio_t*, Sflong_t));
+extern int sfputu _ARG_((Sfio_t*, Sfulong_t));
+extern int sfputm _ARG_((Sfio_t*, Sfulong_t, Sfulong_t));
+extern int sfputc _ARG_((Sfio_t*, int));
+
+extern Sfdouble_t sfgetd _ARG_((Sfio_t*));
+extern Sflong_t sfgetl _ARG_((Sfio_t*));
+extern Sfulong_t sfgetu _ARG_((Sfio_t*));
+extern Sfulong_t sfgetm _ARG_((Sfio_t*, Sfulong_t));
+extern int sfgetc _ARG_((Sfio_t*));
+
+extern int _sfputd _ARG_((Sfio_t*, Sfdouble_t));
+extern int _sfputl _ARG_((Sfio_t*, Sflong_t));
+extern int _sfputu _ARG_((Sfio_t*, Sfulong_t));
+extern int _sfputm _ARG_((Sfio_t*, Sfulong_t, Sfulong_t));
+extern int _sfflsbuf _ARG_((Sfio_t*, int));
+
+extern int _sffilbuf _ARG_((Sfio_t*, int));
+
+extern int _sfdlen _ARG_((Sfdouble_t));
+extern int _sfllen _ARG_((Sflong_t));
+extern int _sfulen _ARG_((Sfulong_t));
+
+/* miscellaneous function analogues of fast in-line functions */
+extern Sfoff_t sfsize _ARG_((Sfio_t*));
+extern int sfclrerr _ARG_((Sfio_t*));
+extern int sfeof _ARG_((Sfio_t*));
+extern int sferror _ARG_((Sfio_t*));
+extern int sffileno _ARG_((Sfio_t*));
+extern int sfstacked _ARG_((Sfio_t*));
+extern ssize_t sfvalue _ARG_((Sfio_t*));
+extern ssize_t sfslen _ARG_((void));
+extern ssize_t sfmaxr _ARG_((ssize_t, int));
+
+#undef extern
+_END_EXTERNS_
+
+/* coding long integers in a portable and compact fashion */
+#define SF_SBITS 6
+#define SF_UBITS 7
+#define SF_BBITS 8
+#define SF_SIGN (1 << SF_SBITS)
+#define SF_MORE (1 << SF_UBITS)
+#define SF_BYTE (1 << SF_BBITS)
+#define SF_U1 SF_MORE
+#define SF_U2 (SF_U1*SF_U1)
+#define SF_U3 (SF_U2*SF_U1)
+#define SF_U4 (SF_U3*SF_U1)
+
+#if __cplusplus
+#define _SF_(f) (f)
+#else
+#define _SF_(f) ((Sfio_t*)(f))
+#endif
+
+#define __sf_putd(f,v) (_sfputd(_SF_(f),(Sfdouble_t)(v)))
+#define __sf_putl(f,v) (_sfputl(_SF_(f),(Sflong_t)(v)))
+#define __sf_putu(f,v) (_sfputu(_SF_(f),(Sfulong_t)(v)))
+#define __sf_putm(f,v,m) (_sfputm(_SF_(f),(Sfulong_t)(v),(Sfulong_t)(m)))
+
+#define __sf_putc(f,c) (_SF_(f)->_next >= _SF_(f)->_endw ? \
+ _sfflsbuf(_SF_(f),(int)((unsigned char)(c))) : \
+ (int)(*_SF_(f)->_next++ = (unsigned char)(c)) )
+#define __sf_getc(f) (_SF_(f)->_next >= _SF_(f)->_endr ? _sffilbuf(_SF_(f),0) : \
+ (int)(*_SF_(f)->_next++) )
+
+#define __sf_dlen(v) (_sfdlen((Sfdouble_t)(v)) )
+#define __sf_llen(v) (_sfllen((Sflong_t)(v)) )
+#define __sf_ulen(v) ((Sfulong_t)(v) < SF_U1 ? 1 : (Sfulong_t)(v) < SF_U2 ? 2 : \
+ (Sfulong_t)(v) < SF_U3 ? 3 : (Sfulong_t)(v) < SF_U4 ? 4 : 5)
+
+#define __sf_fileno(f) (_SF_(f)->_file)
+#define __sf_eof(f) (_SF_(f)->_flags&SF_EOF)
+#define __sf_error(f) (_SF_(f)->_flags&SF_ERROR)
+#define __sf_clrerr(f) (_SF_(f)->_flags &= ~(SF_ERROR|SF_EOF))
+#define __sf_stacked(f) (_SF_(f)->_push != (Sfio_t*)0)
+#define __sf_value(f) (_SF_(f)->_val)
+#define __sf_slen() (_Sfi)
+#define __sf_maxr(n,s) ((s)?((_Sfi=_Sfmaxr),(_Sfmaxr=(n)),_Sfi):_Sfmaxr)
+
+#if defined(__INLINE__) && !_BLD_sfio
+
+__INLINE__ int sfputd(Sfio_t* f, Sfdouble_t v) { return __sf_putd(f,v); }
+__INLINE__ int sfputl(Sfio_t* f, Sflong_t v) { return __sf_putl(f,v); }
+__INLINE__ int sfputu(Sfio_t* f, Sfulong_t v) { return __sf_putu(f,v); }
+__INLINE__ int sfputm(Sfio_t* f, Sfulong_t v, Sfulong_t m)
+ { return __sf_putm(f,v,m); }
+
+__INLINE__ int sfputc(Sfio_t* f, int c) { return __sf_putc(f,c); }
+__INLINE__ int sfgetc(Sfio_t* f) { return __sf_getc(f); }
+
+__INLINE__ int sfdlen(Sfdouble_t v) { return __sf_dlen(v); }
+__INLINE__ int sfllen(Sflong_t v) { return __sf_llen(v); }
+__INLINE__ int sfulen(Sfulong_t v) { return __sf_ulen(v); }
+
+__INLINE__ int sffileno(Sfio_t* f) { return __sf_fileno(f); }
+__INLINE__ int sfeof(Sfio_t* f) { return __sf_eof(f); }
+__INLINE__ int sferror(Sfio_t* f) { return __sf_error(f); }
+__INLINE__ int sfclrerr(Sfio_t* f) { return __sf_clrerr(f); }
+__INLINE__ int sfstacked(Sfio_t* f) { return __sf_stacked(f); }
+__INLINE__ ssize_t sfvalue(Sfio_t* f) { return __sf_value(f); }
+__INLINE__ ssize_t sfslen() { return __sf_slen(); }
+__INLINE__ ssize_t sfmaxr(ssize_t n, int s) { return __sf_maxr(n,s); }
+
+#else
+
+#define sfputd(f,v) ( __sf_putd((f),(v)) )
+#define sfputl(f,v) ( __sf_putl((f),(v)) )
+#define sfputu(f,v) ( __sf_putu((f),(v)) )
+#define sfputm(f,v,m) ( __sf_putm((f),(v),(m)) )
+
+#define sfputc(f,c) ( __sf_putc((f),(c)) )
+#define sfgetc(f) ( __sf_getc(f) )
+
+#define sfdlen(v) ( __sf_dlen(v) )
+#define sfllen(v) ( __sf_llen(v) )
+#define sfulen(v) ( __sf_ulen(v) )
+
+#define sffileno(f) ( __sf_fileno(f) )
+#define sfeof(f) ( __sf_eof(f) )
+#define sferror(f) ( __sf_error(f) )
+#define sfclrerr(f) ( __sf_clrerr(f) )
+#define sfstacked(f) ( __sf_stacked(f) )
+#define sfvalue(f) ( __sf_value(f) )
+#define sfslen() ( __sf_slen() )
+#define sfmaxr(n,s) ( __sf_maxr(n,s) )
+
+#endif /*__INLINE__*/
+
+#ifndef _SFSTR_H /* GSF's string manipulation stuff */
+#define _SFSTR_H 1
+
+#define sfstropen() sfnew(0, 0, -1, -1, SF_READ|SF_WRITE|SF_STRING)
+#define sfstrclose(f) sfclose(f)
+
+#define sfstrseek(f,p,m) \
+ ( (m) == SEEK_SET ? \
+ (((p) < 0 || (p) > (f)->_size) ? (char*)0 : \
+ (char*)((f)->_next = (f)->_data+(p)) ) \
+ : (m) == SEEK_CUR ? \
+ ((f)->_next += (p), \
+ (((f)->_next < (f)->_data || (f)->_next > (f)->_data+(f)->_size) ? \
+ ((f)->_next -= (p), (char*)0) : (char*)(f)->_next ) ) \
+ : (m) == SEEK_END ? \
+ ( ((p) > 0 || (f)->_size+(p) < 0) ? (char*)0 : \
+ (char*)((f)->_next = (f)->_data+(f)->_size+(p)) ) \
+ : (char*)0 \
+ )
+
+#define sfstrsize(f) ((f)->_size)
+#define sfstrtell(f) ((f)->_next - (f)->_data)
+#define sfstrpend(f) ((f)->_size - sfstrtell())
+#define sfstrbase(f) ((char*)(f)->_data)
+
+#define sfstruse(f) \
+ (sfputc((f),0) < 0 ? (char*)0 : (char*)((f)->_next = (f)->_data) \
+ )
+
+#define sfstrrsrv(f,n) \
+ (sfreserve((f),(n),SF_WRITE|SF_LOCKR), sfwrite((f),(f)->_next,0), \
+ ((f)->_next+(n) <= (f)->_data+(f)->_size ? (char*)(f)->_next : (char*)0) \
+ )
+
+#define sfstrbuf(f,b,n,m) \
+ (sfsetbuf((f),(b),(n)), ((f)->_flags |= (m) ? SF_MALLOC : 0), \
+ ((f)->_data == (unsigned char*)(b) ? 0 : -1) \
+ )
+
+#endif /* _SFSTR_H */
+
+#endif /* _SFIO_H */
diff --git a/usr/src/lib/libast/common/include/sfio_s.h b/usr/src/lib/libast/common/include/sfio_s.h
new file mode 100644
index 0000000000..27936a16b1
--- /dev/null
+++ b/usr/src/lib/libast/common/include/sfio_s.h
@@ -0,0 +1,51 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _SFIO_S_H
+#define _SFIO_S_H 1
+
+/*
+ * sfio file structure used by sfio and the stdio source compatibility library
+ */
+
+#if !defined(_SFHDR_H) && defined(_SFIO_H) && SFIO_VERSION < 20020214L
+#define _data data
+#define _endb endb
+#define _next next
+#endif
+
+struct _sfio_s
+{ unsigned char* _next; /* next position to read/write from */
+ unsigned char* _endw; /* end of write buffer */
+ unsigned char* _endr; /* end of read buffer */
+ unsigned char* _endb; /* end of buffer */
+ struct _sfio_s* _push; /* the stream that was pushed on */
+ unsigned short _flags; /* type of stream */
+ short _file; /* file descriptor */
+ unsigned char* _data; /* base of data buffer */
+ ssize_t _size; /* buffer size */
+ ssize_t _val; /* values or string lengths */
+#ifdef _SFIO_PRIVATE
+ _SFIO_PRIVATE
+#endif
+};
+
+#endif
diff --git a/usr/src/lib/libast/common/include/sfio_t.h b/usr/src/lib/libast/common/include/sfio_t.h
new file mode 100644
index 0000000000..36be6ecc94
--- /dev/null
+++ b/usr/src/lib/libast/common/include/sfio_t.h
@@ -0,0 +1,126 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _SFIO_T_H
+#define _SFIO_T_H 1
+
+/* This header file is for library writers who need to know certain
+** internal info concerning the full Sfio_t structure. Including this
+** file means that you agree to track closely with sfio development
+** in case its internal architecture is changed.
+**
+** Written by Kiem-Phong Vo
+*/
+
+/* the parts of Sfio_t private to sfio functions */
+#define _SFIO_PRIVATE \
+ Sfoff_t extent; /* current file size */ \
+ Sfoff_t here; /* current physical location */ \
+ unsigned char getr; /* the last sfgetr separator */ \
+ unsigned char tiny[1];/* for unbuffered read stream */ \
+ unsigned short bits; /* private flags */ \
+ unsigned int mode; /* current io mode */ \
+ struct _sfdisc_s* disc; /* discipline */ \
+ struct _sfpool_s* pool; /* the pool containing this */ \
+ struct _sfrsrv_s* rsrv; /* reserved buffer */ \
+ struct _sfproc_s* proc; /* coprocess id, etc. */ \
+ Void_t* mutex; /* mutex for thread-safety */ \
+ Void_t* stdio; /* stdio FILE if any */ \
+ Sfoff_t lpos; /* last seek position */ \
+ size_t iosz; /* preferred size for I/O */ \
+ size_t blksz; /* preferred block size */ \
+ Void_t* fill[1];/* modest expansion */
+
+#include "sfio.h"
+
+/* mode bit to indicate that the structure hasn't been initialized */
+#define SF_INIT 0000004
+#define SF_DCDOWN 00010000
+
+/* short-hand for common stream types */
+#define SF_RDWR (SF_READ|SF_WRITE)
+#define SF_RDSTR (SF_READ|SF_STRING)
+#define SF_WRSTR (SF_WRITE|SF_STRING)
+#define SF_RDWRSTR (SF_RDWR|SF_STRING)
+
+/* for static initialization of an Sfio_t structure */
+#define SFNEW(data,size,file,type,disc,mutex) \
+ { (unsigned char*)(data), /* next */ \
+ (unsigned char*)(data), /* endw */ \
+ (unsigned char*)(data), /* endr */ \
+ (unsigned char*)(data), /* endb */ \
+ (Sfio_t*)0, /* push */ \
+ (unsigned short)((type)&SF_FLAGS), /* flags */ \
+ (short)(file), /* file */ \
+ (unsigned char*)(data), /* data */ \
+ (ssize_t)(size), /* size */ \
+ (ssize_t)(-1), /* val */ \
+ (Sfoff_t)0, /* extent */ \
+ (Sfoff_t)0, /* here */ \
+ 0, /* getr */ \
+ {0}, /* tiny */ \
+ 0, /* bits */ \
+ (unsigned int)(((type)&(SF_RDWR))|SF_INIT), /* mode */ \
+ (struct _sfdisc_s*)(disc), /* disc */ \
+ (struct _sfpool_s*)0, /* pool */ \
+ (struct _sfrsrv_s*)0, /* rsrv */ \
+ (struct _sfproc_s*)0, /* proc */ \
+ (mutex), /* mutex */ \
+ (Void_t*)0, /* stdio */ \
+ (Sfoff_t)0, /* lpos */ \
+ (size_t)0 /* iosz */ \
+ }
+
+/* function to clear an Sfio_t structure */
+#define SFCLEAR(f,mtx) \
+ ( (f)->next = (unsigned char*)0, /* next */ \
+ (f)->endw = (unsigned char*)0, /* endw */ \
+ (f)->endr = (unsigned char*)0, /* endr */ \
+ (f)->endb = (unsigned char*)0, /* endb */ \
+ (f)->push = (Sfio_t*)0, /* push */ \
+ (f)->flags = (unsigned short)0, /* flags */ \
+ (f)->file = -1, /* file */ \
+ (f)->data = (unsigned char*)0, /* data */ \
+ (f)->size = (ssize_t)(-1), /* size */ \
+ (f)->val = (ssize_t)(-1), /* val */ \
+ (f)->extent = (Sfoff_t)(-1), /* extent */ \
+ (f)->here = (Sfoff_t)0, /* here */ \
+ (f)->getr = 0, /* getr */ \
+ (f)->tiny[0] = 0, /* tiny */ \
+ (f)->bits = 0, /* bits */ \
+ (f)->mode = 0, /* mode */ \
+ (f)->disc = (struct _sfdisc_s*)0, /* disc */ \
+ (f)->pool = (struct _sfpool_s*)0, /* pool */ \
+ (f)->rsrv = (struct _sfrsrv_s*)0, /* rsrv */ \
+ (f)->proc = (struct _sfproc_s*)0, /* proc */ \
+ (f)->mutex = (mtx), /* mutex */ \
+ (f)->stdio = (Void_t*)0, /* stdio */ \
+ (f)->lpos = (Sfoff_t)0, /* lpos */ \
+ (f)->iosz = (size_t)0 /* iosz */ \
+ )
+
+/* expose next stream inside discipline function; state saved in int f */
+#define SFDCNEXT(sp,f) (((f)=(sp)->bits&SF_DCDOWN),(sp)->bits|=SF_DCDOWN)
+
+/* restore SFDCNEXT() state from int f */
+#define SFDCPREV(sp,f) ((f)?(0):((sp)->bits&=~SF_DCDOWN))
+
+#endif /* _SFIO_T_H */
diff --git a/usr/src/lib/libast/common/include/stack.h b/usr/src/lib/libast/common/include/stack.h
new file mode 100644
index 0000000000..4ca2de0cf4
--- /dev/null
+++ b/usr/src/lib/libast/common/include/stack.h
@@ -0,0 +1,83 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * homogenous stack routine definitions
+ */
+
+#ifndef _STACK_H
+#define _STACK_H
+
+typedef struct stacktable* STACK; /* stack pointer */
+typedef struct stackposition STACKPOS; /* stack position */
+
+struct stackblock /* stack block cell */
+{
+ void** stack; /* actual stack */
+ struct stackblock* prev; /* previous block in list */
+ struct stackblock* next; /* next block in list */
+};
+
+struct stackposition /* stack position */
+{
+ struct stackblock* block; /* current block pointer */
+ int index; /* index within current block */
+};
+
+struct stacktable /* stack information */
+{
+ struct stackblock* blocks; /* stack table blocks */
+ void* error; /* error return value */
+ int size; /* size of each block */
+ STACKPOS position; /* current stack position */
+};
+
+/*
+ * map old names to new
+ */
+
+#define mkstack stackalloc
+#define rmstack stackfree
+#define clrstack stackclear
+#define getstack stackget
+#define pushstack stackpush
+#define popstack stackpop
+#define posstack stacktell
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern STACK stackalloc(int, void*);
+extern void stackfree(STACK);
+extern void stackclear(STACK);
+extern void* stackget(STACK);
+extern int stackpush(STACK, void*);
+extern int stackpop(STACK);
+extern void stacktell(STACK, int, STACKPOS*);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/stak.h b/usr/src/lib/libast/common/include/stak.h
new file mode 100644
index 0000000000..c61d313edc
--- /dev/null
+++ b/usr/src/lib/libast/common/include/stak.h
@@ -0,0 +1,55 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Research
+ *
+ * Interface definitions for a stack-like storage library
+ *
+ */
+
+#ifndef _STAK_H
+#define _STAK_H
+
+#include <stk.h>
+
+#define Stak_t Sfio_t
+#define staksp stkstd
+#define STAK_SMALL STK_SMALL
+
+#define stakptr(n) stkptr(stkstd,n)
+#define staktell() stktell(stkstd)
+#define stakputc(c) sfputc(stkstd,(c))
+#define stakwrite(b,n) sfwrite(stkstd,(b),(n))
+#define stakputs(s) (sfputr(stkstd,(s),0),--stkstd->_next)
+#define stakseek(n) stkseek(stkstd,n)
+#define stakcreate(n) stkopen(n)
+#define stakinstall(s,f) stkinstall(s,f)
+#define stakdelete(s) stkclose(s)
+#define staklink(s) stklink(s)
+#define stakalloc(n) stkalloc(stkstd,n)
+#define stakcopy(s) stkcopy(stkstd,s)
+#define stakset(c,n) stkset(stkstd,c,n)
+#define stakfreeze(n) stkfreeze(stkstd,n)
+
+#endif
diff --git a/usr/src/lib/libast/common/include/stk.h b/usr/src/lib/libast/common/include/stk.h
new file mode 100644
index 0000000000..e89cc7a151
--- /dev/null
+++ b/usr/src/lib/libast/common/include/stk.h
@@ -0,0 +1,77 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Research
+ *
+ * Interface definitions for a stack-like storage library
+ *
+ */
+
+#ifndef _STK_H
+#define _STK_H
+
+#include <sfio.h>
+
+#define _Stk_data _Stak_data
+
+#define stkstd (&_Stk_data)
+
+#define Stk_t Sfio_t
+
+#define STK_SMALL 1 /* small stkopen stack */
+#define STK_NULL 2 /* return NULL on overflow */
+
+#define stkptr(sp,n) ((char*)((sp)->_data)+(n))
+#define stktop(sp) ((char*)(sp)->_next)
+#define stktell(sp) ((sp)->_next-(sp)->_data)
+#define stkseek(sp,n) ((n)==0?(char*)((sp)->_next=(sp)->_data):_stkseek(sp,n))
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#define extern extern __IMPORT__
+#endif
+
+extern Sfio_t _Stk_data;
+
+#undef extern
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Stk_t* stkopen(int);
+extern Stk_t* stkinstall(Stk_t*, char*(*)(int));
+extern int stkclose(Stk_t*);
+extern int stklink(Stk_t*);
+extern char* stkalloc(Stk_t*, unsigned);
+extern char* stkcopy(Stk_t*,const char*);
+extern char* stkset(Stk_t*, char*, unsigned);
+extern char* _stkseek(Stk_t*, unsigned);
+extern char* stkfreeze(Stk_t*, unsigned);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/swap.h b/usr/src/lib/libast/common/include/swap.h
new file mode 100644
index 0000000000..25ccbf0a17
--- /dev/null
+++ b/usr/src/lib/libast/common/include/swap.h
@@ -0,0 +1,53 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * integral representation conversion support definitions
+ * supports sizeof(integral_type)<=sizeof(intmax_t)
+ */
+
+#ifndef _SWAP_H
+#define _SWAP_H
+
+#include <ast_common.h>
+
+#define int_swap _ast_intswap
+
+#define SWAP_MAX 8
+
+#define SWAPOP(n) (((n)&int_swap)^(n))
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern void* swapmem(int, const void*, void*, size_t);
+extern intmax_t swapget(int, const void*, int);
+extern void* swapput(int, void*, int, intmax_t);
+extern int swapop(const void*, const void*, int);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/tar.h b/usr/src/lib/libast/common/include/tar.h
new file mode 100644
index 0000000000..c696afdd3f
--- /dev/null
+++ b/usr/src/lib/libast/common/include/tar.h
@@ -0,0 +1,118 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Standard Archive Format
+ * USTAR - Uniform Standard Tape ARchive
+ */
+
+#ifndef _TAR_H
+#define _TAR_H
+
+#define TBLOCK 512
+#define NAMSIZ 100
+#define PFXSIZ 155
+
+#define TMODLEN 8
+#define TUIDLEN 8
+#define TGIDLEN 8
+#define TSIZLEN 12
+#define TMTMLEN 12
+#define TCKSLEN 8
+
+#define TMAGIC "ustar" /* ustar and a null */
+#define TMAGLEN 6
+#define TVERSION "00" /* 00 and no null */
+#define TVERSLEN 2
+#define TUNMLEN 32
+#define TGNMLEN 32
+#define TDEVLEN 8
+
+/*
+ * values used in typeflag field
+ */
+
+#define REGTYPE '0' /* regular file */
+#define AREGTYPE 0 /* alternate REGTYPE */
+#define LNKTYPE '1' /* hard link */
+#define SYMTYPE '2' /* soft link */
+#define CHRTYPE '3' /* character special */
+#define BLKTYPE '4' /* block special */
+#define DIRTYPE '5' /* directory */
+#define FIFOTYPE '6' /* FIFO special */
+#define CONTTYPE '7' /* reserved */
+#define SOKTYPE '8' /* socket */
+#define EXTTYPE 'x' /* extended header */
+#define GLBTYPE 'g' /* global extended header */
+#define LLNKTYPE 'K' /* long link path */
+#define LREGTYPE 'L' /* long file path */
+#define VERTYPE 'V' /* version */
+
+/*
+ * bits used in mode field
+ */
+
+#define TSUID 04000 /* set uid on exec */
+#define TSGID 02000 /* set gid on exec */
+#define TSVTX 01000 /* sticky bit -- reserved */
+
+/*
+ * file permissions
+ */
+
+#define TUREAD 00400 /* read by owner */
+#define TUWRITE 00200 /* write by owner */
+#define TUEXEC 00100 /* execute by owner */
+#define TGREAD 00040 /* read by group */
+#define TGWRITE 00020 /* execute by group */
+#define TGEXEC 00010 /* write by group */
+#define TOREAD 00004 /* read by other */
+#define TOWRITE 00002 /* write by other */
+#define TOEXEC 00001 /* execute by other */
+
+struct header
+{
+ char name[NAMSIZ];
+ char mode[TMODLEN];
+ char uid[TUIDLEN];
+ char gid[TGIDLEN];
+ char size[TSIZLEN];
+ char mtime[TMTMLEN];
+ char chksum[TCKSLEN];
+ char typeflag;
+ char linkname[NAMSIZ];
+ char magic[TMAGLEN];
+ char version[TVERSLEN];
+ char uname[TUNMLEN];
+ char gname[TGNMLEN];
+ char devmajor[TDEVLEN];
+ char devminor[TDEVLEN];
+ char prefix[PFXSIZ];
+};
+
+union hblock
+{
+ char dummy[TBLOCK];
+ struct header dbuf;
+};
+
+#endif
diff --git a/usr/src/lib/libast/common/include/times.h b/usr/src/lib/libast/common/include/times.h
new file mode 100644
index 0000000000..11ed270e78
--- /dev/null
+++ b/usr/src/lib/libast/common/include/times.h
@@ -0,0 +1,54 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * -last clock_t,time_t interface definitions plus
+ *
+ * <ast.h>
+ * <time.h>
+ * <sys/time.h>
+ * <sys/times.h>
+ */
+
+#ifndef _TIMES_H
+#define _TIMES_H
+
+#include <ast.h>
+
+#undef _TIMES_H
+#include <ast_time.h>
+#ifndef _TIMES_H
+#define _TIMES_H
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int touch(const char*, time_t, time_t, int);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/tm.h b/usr/src/lib/libast/common/include/tm.h
new file mode 100644
index 0000000000..0c91344b76
--- /dev/null
+++ b/usr/src/lib/libast/common/include/tm.h
@@ -0,0 +1,191 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * time conversion support definitions
+ */
+
+#ifndef _TM_H
+#define _TM_H
+
+#define TM_VERSION 20070319L
+
+#include <ast.h>
+#include <times.h>
+
+#undef daylight
+
+#define tmset(z) tminit(z)
+#define tmisleapyear(y) (!((y)%4)&&(((y)%100)||!((((y)<1900)?((y)+1900):(y))%400)))
+
+#define TM_ADJUST (1<<0) /* local doesn't do leap secs */
+#define TM_LEAP (1<<1) /* do leap seconds */
+#define TM_UTC (1<<2) /* universal coordinated ref */
+
+#define TM_PEDANTIC (1<<3) /* pedantic date parse */
+#define TM_DATESTYLE (1<<4) /* date(1) style mmddHHMMccyy */
+#define TM_SUBSECOND (1<<5) /* <something>%S => ...%S.%P */
+
+#define TM_DST (-60) /* default minutes for DST */
+#define TM_LOCALZONE (25 * 60) /* use local time zone offset */
+#define TM_UTCZONE (26 * 60) /* UTC "time zone" */
+#define TM_MAXLEAP 1 /* max leap secs per leap */
+#define TM_WINDOW 69 /* century windowing guard year */
+
+/*
+ * these indices must agree with tm_dform[]
+ */
+
+#define TM_MONTH_ABBREV 0
+#define TM_MONTH 12
+#define TM_DAY_ABBREV 24
+#define TM_DAY 31
+#define TM_TIME 38
+#define TM_DATE 39
+#define TM_DEFAULT 40
+#define TM_MERIDIAN 41
+
+#define TM_UT 43
+#define TM_DT 47
+#define TM_SUFFIXES 51
+#define TM_PARTS 55
+#define TM_HOURS 62
+#define TM_DAYS 66
+#define TM_LAST 69
+#define TM_THIS 72
+#define TM_NEXT 75
+#define TM_EXACT 78
+#define TM_NOISE 81
+#define TM_ORDINAL 85
+#define TM_DIGITS 95
+#define TM_CTIME 105
+#define TM_DATE_1 106
+#define TM_INTERNATIONAL 107
+#define TM_RECENT 108
+#define TM_DISTANT 109
+#define TM_MERIDIAN_TIME 110
+#define TM_ERA 111
+#define TM_ERA_DATE 112
+#define TM_ERA_TIME 113
+#define TM_ERA_DEFAULT 114
+#define TM_ERA_YEAR 115
+#define TM_ORDINALS 116
+#define TM_FINAL 126
+
+#define TM_NFORM 129
+
+typedef struct /* leap second info */
+{
+ time_t time; /* the leap second event */
+ int total; /* inclusive total since epoch */
+} Tm_leap_t;
+
+typedef struct /* time zone info */
+{
+ char* type; /* type name */
+ char* standard; /* standard time name */
+ char* daylight; /* daylight or summertime name */
+ short west; /* minutes west of GMT */
+ short dst; /* add to tz.west for DST */
+} Tm_zone_t;
+
+typedef struct /* tm library readonly data */
+{
+ char** format; /* default TM_* format strings */
+ char* lex; /* format lex type classes */
+ char* digit; /* output digits */
+ short* days; /* days in month i */
+ short* sum; /* days in months before i */
+ Tm_leap_t* leap; /* leap second table */
+ Tm_zone_t* zone; /* alternate timezone table */
+} Tm_data_t;
+
+typedef struct /* tm library global info */
+{
+ char* deformat; /* TM_DEFAULT override */
+ int flags; /* flags */
+ char** format; /* current format strings */
+ Tm_zone_t* date; /* timezone from last tmdate() */
+ Tm_zone_t* local; /* local timezone */
+ Tm_zone_t* zone; /* current timezone */
+} Tm_info_t;
+
+typedef struct Tm_s
+{
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+ uint32_t tm_nsec;
+ Tm_zone_t* tm_zone;
+} Tm_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#define extern extern __IMPORT__
+#endif
+
+extern Tm_data_t* _tm_datap_;
+extern Tm_info_t* _tm_infop_;
+
+#define tm_data (*_tm_datap_)
+#define tm_info (*_tm_infop_)
+
+#undef extern
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern time_t tmdate(const char*, char**, time_t*);
+extern int tmequiv(Tm_t*);
+extern Tm_t* tmfix(Tm_t*);
+extern char* tmfmt(char*, size_t, const char*, time_t*);
+extern char* tmform(char*, const char*, time_t*);
+extern int tmgoff(const char*, char**, int);
+extern void tminit(Tm_zone_t*);
+extern time_t tmleap(time_t*);
+extern int tmlex(const char*, char**, char**, int, char**, int);
+extern char** tmlocale(void);
+extern Tm_t* tmmake(time_t*);
+extern char* tmpoff(char*, size_t, const char*, int, int);
+extern time_t tmscan(const char*, char**, const char*, char**, time_t*, long);
+extern int tmsleep(time_t, time_t);
+extern time_t tmtime(Tm_t*, int);
+extern Tm_zone_t* tmtype(const char*, char**);
+extern int tmweek(Tm_t*, int, int, int);
+extern int tmword(const char*, char**, const char*, char**, int);
+extern Tm_zone_t* tmzone(const char*, char**, const char*, int*);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/tok.h b/usr/src/lib/libast/common/include/tok.h
new file mode 100644
index 0000000000..bca70d7ab2
--- /dev/null
+++ b/usr/src/lib/libast/common/include/tok.h
@@ -0,0 +1,47 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * token stream interface definitions
+ */
+
+#ifndef _TOK_H
+#define _TOK_H
+
+#include <ast.h>
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Sfio_t* tokline(const char*, int, int*);
+extern int tokscan(char*, char**, const char*, ...);
+extern char* tokopen(char*, int);
+extern void tokclose(char*);
+extern char* tokread(char*);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/usage.h b/usr/src/lib/libast/common/include/usage.h
new file mode 100644
index 0000000000..81b59e1aca
--- /dev/null
+++ b/usr/src/lib/libast/common/include/usage.h
@@ -0,0 +1,37 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * error catalog and usage defaults
+ */
+
+#ifndef _USAGE_H
+#define _USAGE_H
+
+#ifndef ERROR_CATALOG
+#define ERROR_CATALOG 0
+#endif
+
+#ifndef USAGE_LICENSE
+#define USAGE_LICENSE "[-license?THIS IS AN UNLICENSED COPY]"
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/include/vdb.h b/usr/src/lib/libast/common/include/vdb.h
new file mode 100644
index 0000000000..9288cb36ff
--- /dev/null
+++ b/usr/src/lib/libast/common/include/vdb.h
@@ -0,0 +1,46 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * virtual db file directory entry constants
+ */
+
+#ifndef VDB_MAGIC
+
+#define VDB_MAGIC "vdb"
+
+#define VDB_DIRECTORY "DIRECTORY"
+#define VDB_UNION "UNION"
+#define VDB_DATE "DATE"
+#define VDB_MODE "MODE"
+
+#define VDB_DELIMITER ';'
+#define VDB_IGNORE '_'
+#define VDB_FIXED 10
+#define VDB_LENGTH ((int)sizeof(VDB_DIRECTORY)+2*(VDB_FIXED+1))
+#define VDB_OFFSET ((int)sizeof(VDB_DIRECTORY))
+#define VDB_SIZE (VDB_OFFSET+VDB_FIXED+1)
+
+#endif
diff --git a/usr/src/lib/libast/common/include/vecargs.h b/usr/src/lib/libast/common/include/vecargs.h
new file mode 100644
index 0000000000..55e1279086
--- /dev/null
+++ b/usr/src/lib/libast/common/include/vecargs.h
@@ -0,0 +1,45 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * vector argument interface definitions
+ */
+
+#ifndef _VECARGS_H
+#define _VECARGS_H
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int vecargs(char**, int*, char***);
+extern char** vecfile(const char*);
+extern void vecfree(char**, int);
+extern char** vecload(char*);
+extern char** vecstring(const char*);
+
+#undef extern
+
+#endif
diff --git a/usr/src/lib/libast/common/include/vmalloc.h b/usr/src/lib/libast/common/include/vmalloc.h
new file mode 100644
index 0000000000..f0a8114c6a
--- /dev/null
+++ b/usr/src/lib/libast/common/include/vmalloc.h
@@ -0,0 +1,315 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _VMALLOC_H
+#define _VMALLOC_H 1
+
+/* Public header file for the virtual malloc package.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+
+#define VMALLOC_VERSION 20050928L
+
+#if _PACKAGE_ast
+#include <ast_std.h>
+#else
+#include <ast_common.h>
+#endif
+
+typedef struct _vmalloc_s Vmalloc_t;
+typedef struct _vmstat_s Vmstat_t;
+typedef struct _vmdisc_s Vmdisc_t;
+typedef struct _vmethod_s Vmethod_t;
+typedef Void_t* (*Vmemory_f)_ARG_((Vmalloc_t*, Void_t*, size_t, size_t, Vmdisc_t*));
+typedef int (*Vmexcept_f)_ARG_((Vmalloc_t*, int, Void_t*, Vmdisc_t*));
+
+struct _vmstat_s
+{ int n_busy; /* number of busy blocks */
+ int n_free; /* number of free blocks */
+ size_t s_busy; /* total amount of busy space */
+ size_t s_free; /* total amount of free space */
+ size_t m_busy; /* largest busy piece */
+ size_t m_free; /* largest free piece */
+ int n_seg; /* number of segments */
+ size_t extent; /* total size of region */
+};
+
+struct _vmdisc_s
+{ Vmemory_f memoryf; /* memory manipulator */
+ Vmexcept_f exceptf; /* exception handler */
+ size_t round; /* rounding requirement */
+};
+
+struct _vmethod_s
+{ Void_t* (*allocf)_ARG_((Vmalloc_t*,size_t));
+ Void_t* (*resizef)_ARG_((Vmalloc_t*,Void_t*,size_t,int));
+ int (*freef)_ARG_((Vmalloc_t*,Void_t*));
+ long (*addrf)_ARG_((Vmalloc_t*,Void_t*));
+ long (*sizef)_ARG_((Vmalloc_t*,Void_t*));
+ int (*compactf)_ARG_((Vmalloc_t*));
+ Void_t* (*alignf)_ARG_((Vmalloc_t*,size_t,size_t));
+ unsigned short meth;
+};
+
+struct _vmalloc_s
+{ Vmethod_t meth; /* method for allocation */
+ char* file; /* file name */
+ int line; /* line number */
+ Void_t* func; /* calling function */
+#ifdef _VM_PRIVATE_
+ _VM_PRIVATE_
+#endif
+};
+
+#undef VM_FLAGS /* solaris sys kernel clash */
+
+#define VM_TRUST 0000001 /* forgo some security checks */
+#define VM_TRACE 0000002 /* generate trace */
+#define VM_DBCHECK 0000004 /* check for boundary overwrite */
+#define VM_DBABORT 0000010 /* abort on any warning */
+#define VM_FLAGS 0000017 /* user-settable flags */
+
+#define VM_MTBEST 0000100 /* Vmbest method */
+#define VM_MTPOOL 0000200 /* Vmpool method */
+#define VM_MTLAST 0000400 /* Vmlast method */
+#define VM_MTDEBUG 0001000 /* Vmdebug method */
+#define VM_MTPROFILE 0002000 /* Vmdebug method */
+#define VM_METHODS 0003700 /* available allocation methods */
+
+#define VM_RSCOPY 0000001 /* copy old contents */
+#define VM_RSMOVE 0000002 /* old contents is moveable */
+#define VM_RSZERO 0000004 /* clear new space */
+
+/* exception types */
+#define VM_OPEN 0 /* region being opened */
+#define VM_CLOSE 1 /* announce being closed */
+#define VM_NOMEM 2 /* can't obtain memory */
+#define VM_BADADDR 3 /* bad addr in vmfree/vmresize */
+#define VM_DISC 4 /* discipline being changed */
+#define VM_ALLOC 5 /* announcement from vmalloc() */
+#define VM_FREE 6 /* announcement from vmfree() */
+#define VM_RESIZE 7 /* announcement from vmresize() */
+
+_BEGIN_EXTERNS_ /* public data */
+#if _BLD_vmalloc && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+#if !_BLD_vmalloc && defined(__IMPORT__)
+#define extern extern __IMPORT__
+#endif
+
+extern Vmethod_t* Vmbest; /* best allocation */
+extern Vmethod_t* Vmlast; /* last-block allocation */
+extern Vmethod_t* Vmpool; /* pool allocation */
+extern Vmethod_t* Vmdebug; /* allocation with debugging */
+extern Vmethod_t* Vmprofile; /* profiling memory usage */
+
+extern Vmdisc_t* Vmdcheap; /* heap discipline */
+extern Vmdisc_t* Vmdcsbrk; /* sbrk discipline */
+
+extern Vmalloc_t* Vmheap; /* heap region */
+extern Vmalloc_t* Vmregion; /* malloc region */
+
+#undef extern
+_END_EXTERNS_
+
+_BEGIN_EXTERNS_ /* public functions */
+#if _BLD_vmalloc && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Vmalloc_t* vmopen _ARG_(( Vmdisc_t*, Vmethod_t*, int ));
+extern int vmclose _ARG_(( Vmalloc_t* ));
+extern int vmclear _ARG_(( Vmalloc_t* ));
+extern int vmcompact _ARG_(( Vmalloc_t* ));
+
+extern Vmdisc_t* vmdisc _ARG_(( Vmalloc_t*, Vmdisc_t* ));
+
+extern Vmalloc_t* vmmopen _ARG_(( char*, Void_t*, size_t ));
+extern Void_t* vmmset _ARG_((Vmalloc_t*, int, Void_t*, int));
+
+extern Void_t* vmalloc _ARG_(( Vmalloc_t*, size_t ));
+extern Void_t* vmalign _ARG_(( Vmalloc_t*, size_t, size_t ));
+extern Void_t* vmresize _ARG_(( Vmalloc_t*, Void_t*, size_t, int ));
+extern Void_t* vmgetmem _ARG_(( Vmalloc_t*, Void_t*, size_t ));
+extern int vmfree _ARG_(( Vmalloc_t*, Void_t* ));
+
+extern long vmaddr _ARG_(( Vmalloc_t*, Void_t* ));
+extern long vmsize _ARG_(( Vmalloc_t*, Void_t* ));
+
+extern Vmalloc_t* vmregion _ARG_(( Void_t* ));
+extern Void_t* vmsegment _ARG_(( Vmalloc_t*, Void_t* ));
+extern int vmset _ARG_(( Vmalloc_t*, int, int ));
+
+extern Void_t* vmdbwatch _ARG_(( Void_t* ));
+extern int vmdbcheck _ARG_(( Vmalloc_t* ));
+extern int vmdebug _ARG_(( int ));
+
+extern int vmprofile _ARG_(( Vmalloc_t*, int ));
+
+extern int vmtrace _ARG_(( int ));
+extern int vmtrbusy _ARG_((Vmalloc_t*));
+
+extern int vmstat _ARG_((Vmalloc_t*, Vmstat_t*));
+
+extern int vmwalk _ARG_((Vmalloc_t*,
+ int(*)(Vmalloc_t*,Void_t*,size_t,Vmdisc_t*)));
+extern char* vmstrdup _ARG_((Vmalloc_t*, const char*));
+
+#if !defined(_BLD_vmalloc) && !defined(_AST_STD_H) && \
+ !defined(__stdlib_h) && !defined(__STDLIB_H) && \
+ !defined(_STDLIB_INCLUDED) && !defined(_INC_STDLIB)
+extern Void_t* malloc _ARG_(( size_t ));
+extern Void_t* realloc _ARG_(( Void_t*, size_t ));
+extern void free _ARG_(( Void_t* ));
+extern void cfree _ARG_(( Void_t* ));
+extern Void_t* calloc _ARG_(( size_t, size_t ));
+extern Void_t* memalign _ARG_(( size_t, size_t ));
+extern Void_t* valloc _ARG_(( size_t ));
+#endif
+
+#undef extern
+_END_EXTERNS_
+
+/* to coerce any value to a Vmalloc_t*, make ANSI happy */
+#define _VM_(vm) ((Vmalloc_t*)(vm))
+
+/* enable recording of where a call originates from */
+#ifdef VMFL
+
+#if defined(__FILE__)
+#define _VMFILE_(vm) (_VM_(vm)->file = (char*)__FILE__)
+#else
+#define _VMFILE_(vm) (_VM_(vm)->file = 0)
+#endif
+
+#if defined(__LINE__)
+#define _VMLINE_(vm) (_VM_(vm)->line = __LINE__)
+#else
+#define _VMLINE_(vm) (_VM_(vm)->line = 0)
+#endif
+
+#if defined(__FUNCTION__)
+#define _VMFUNC_(vm) (_VM_(vm)->func = (Void_t*)__FUNCTION__)
+#else
+#define _VMFUNC_(vm) (_VM_(vm)->func = 0)
+#endif
+
+#define _VMFL_(vm) (_VMFILE_(vm), _VMLINE_(vm), _VMFUNC_(vm))
+
+#define vmalloc(vm,sz) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.allocf))((vm),(sz)) )
+#define vmresize(vm,d,sz,type) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.resizef))\
+ ((vm),(Void_t*)(d),(sz),(type)) )
+#define vmfree(vm,d) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.freef))((vm),(Void_t*)(d)) )
+#define vmalign(vm,sz,align) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.alignf))((vm),(sz),(align)) )
+
+#undef malloc
+#undef realloc
+#undef calloc
+#undef free
+#undef memalign
+#undef valloc
+
+#if _map_malloc
+
+#define malloc(s) (_VMFL_(Vmregion), _ast_malloc((size_t)(s)) )
+#define realloc(d,s) (_VMFL_(Vmregion), _ast_realloc((Void_t*)(d),(size_t)(s)) )
+#define calloc(n,s) (_VMFL_(Vmregion), _ast_calloc((size_t)n, (size_t)(s)) )
+#define free(d) (_VMFL_(Vmregion), _ast_free((Void_t*)(d)) )
+#define memalign(a,s) (_VMFL_(Vmregion), _ast_memalign((size_t)(a),(size_t)(s)) )
+#define valloc(s) (_VMFL_(Vmregion), _ast_valloc((size_t)(s) )
+
+#else
+
+#if !_std_malloc
+
+#if __STD_C || defined(__STDPP__) || defined(__GNUC__)
+#define malloc(s) ( _VMFL_(Vmregion), (malloc)((size_t)(s)) )
+#define realloc(d,s) ( _VMFL_(Vmregion), (realloc)((Void_t*)(d),(size_t)(s)) )
+#define calloc(n,s) ( _VMFL_(Vmregion), (calloc)((size_t)n, (size_t)(s)) )
+#define free(d) ( _VMFL_(Vmregion), (free)((Void_t*)(d)) )
+#define memalign(a,s) ( _VMFL_(Vmregion), (memalign)((size_t)(a),(size_t)(s)) )
+#define valloc(s) ( _VMFL_(Vmregion), (valloc)((size_t)(s)) )
+#ifndef strdup
+#define strdup(s) ( _VMFL_(Vmregion), (strdup)((char*)(s)) )
+#endif
+
+#else
+
+#define _VMNM_(a,b,c,d,e,f) a/**/b/**/c/**/d/**/e/**/f
+#define malloc(s) ( _VMFL_(Vmregion), _VMNM_(mallo,/,*,*,/,c)\
+ ( (size_t)(s)) )
+#define realloc(d,s) ( _VMFL_(Vmregion), _VMNM_(reallo,/,*,*,/,c)\
+ ( (Void_t*)(d),(size_t)(s)) )
+#define calloc(n,s) ( _VMFL_(Vmregion), _VMNM_(callo,/,*,*,/,c)\
+ ( (size_t)n, (size_t)(s)) )
+#define free(d) ( _VMFL_(Vmregion), _VMNM_(fre,/,*,*,/,e)((Void_t*)(d)) )
+#define memalign(a,s) ( _VMFL_(Vmregion), _VMNM_(memalig,/,*,*,/,n)\
+ ( (size_t)(a),(size_t)(s)) )
+#define valloc(s) ( _VMFL_(Vmregion), _VMNM_(vallo,/,*,*,/,c)\
+ ( (size_t)(s)) )
+#ifndef strdup
+#define strdup(s) ( _VMFL_(Vmregion), _VMNM_(strdu,/,*,*,/,p)\
+ ((char*)(s)) )
+#endif
+
+#endif /*__STD_C || defined(__STDPP__) || defined(__GNUC__)*/
+
+#define cfree(d) free(d)
+
+#endif /* !_std_malloc */
+
+#endif /* _map_malloc */
+
+#endif /*VMFL*/
+
+/* non-debugging/profiling allocation calls */
+#ifndef vmalloc
+#define vmalloc(vm,sz) (*(_VM_(vm)->meth.allocf))((vm),(sz))
+#endif
+
+#ifndef vmresize
+#define vmresize(vm,d,sz,type) (*(_VM_(vm)->meth.resizef))\
+ ((vm),(Void_t*)(d),(sz),(type))
+#endif
+
+#ifndef vmfree
+#define vmfree(vm,d) (*(_VM_(vm)->meth.freef))((vm),(Void_t*)(d))
+#endif
+
+#ifndef vmalign
+#define vmalign(vm,sz,align) (*(_VM_(vm)->meth.alignf))((vm),(sz),(align))
+#endif
+
+#define vmaddr(vm,addr) (*(_VM_(vm)->meth.addrf))((vm),(Void_t*)(addr))
+#define vmsize(vm,addr) (*(_VM_(vm)->meth.sizef))((vm),(Void_t*)(addr))
+#define vmcompact(vm) (*(_VM_(vm)->meth.compactf))((vm))
+#define vmoldof(v,p,t,n,x) (t*)vmresize((v), (p), sizeof(t)*(n)+(x), \
+ (VM_RSMOVE) )
+#define vmnewof(v,p,t,n,x) (t*)vmresize((v), (p), sizeof(t)*(n)+(x), \
+ (VM_RSMOVE|VM_RSCOPY|VM_RSZERO) )
+
+#endif /* _VMALLOC_H */
diff --git a/usr/src/lib/libast/common/include/wait.h b/usr/src/lib/libast/common/include/wait.h
new file mode 100644
index 0000000000..136def40d1
--- /dev/null
+++ b/usr/src/lib/libast/common/include/wait.h
@@ -0,0 +1,98 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * ast POSIX wait/exit support
+ */
+
+#ifndef _WAIT_H
+#define _WAIT_H
+
+#include <ast.h>
+#include <ast_wait.h>
+
+#if _sys_wait
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide wait waitpid
+#else
+#define wait ______wait
+#define waitpid ______waitpid
+#endif
+#include <sys/wait.h>
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide wait waitpid
+#else
+#undef wait
+#undef waitpid
+#endif
+#endif
+
+#ifndef WNOHANG
+#define WNOHANG 1
+#endif
+
+#ifndef WUNTRACED
+#define WUNTRACED 2
+#endif
+
+#if !_ok_wif
+#undef WIFEXITED
+#undef WEXITSTATUS
+#undef WIFSIGNALED
+#undef WTERMSIG
+#undef WIFSTOPPED
+#undef WSTOPSIG
+#undef WTERMCORE
+#endif
+
+#ifndef WIFEXITED
+#define WIFEXITED(x) (!((x)&((1<<(EXIT_BITS-1))-1)))
+#endif
+
+#ifndef WEXITSTATUS
+#define WEXITSTATUS(x) (((x)>>EXIT_BITS)&((1<<EXIT_BITS)-1))
+#endif
+
+#ifndef WIFSIGNALED
+#define WIFSIGNALED(x) (((x)&((1<<(EXIT_BITS-1))-1))!=0)
+#endif
+
+#ifndef WTERMSIG
+#define WTERMSIG(x) ((x)&((1<<(EXIT_BITS-1))-1))
+#endif
+
+#ifndef WIFSTOPPED
+#define WIFSTOPPED(x) (((x)&((1<<EXIT_BITS)-1))==((1<<(EXIT_BITS-1))-1))
+#endif
+
+#ifndef WSTOPSIG
+#define WSTOPSIG(x) WEXITSTATUS(x)
+#endif
+
+#ifndef WTERMCORE
+#define WTERMCORE(x) ((x)&(1<<(EXIT_BITS-1)))
+#endif
+
+extern pid_t wait(int*);
+extern pid_t waitpid(pid_t, int*, int);
+
+#endif
diff --git a/usr/src/lib/libast/common/llib-last b/usr/src/lib/libast/common/llib-last
new file mode 100644
index 0000000000..69019e07ec
--- /dev/null
+++ b/usr/src/lib/libast/common/llib-last
@@ -0,0 +1,662 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * lib/libast/common/llib-last
+ *
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*LINTLIBRARY*/
+/*PROTOLIB1*/
+
+#define _FTWALK_H 1
+
+#include <ast.h>
+#include <align.h>
+#include <ast_botch.h>
+#include <ast_ccode.h>
+#include <ast_common.h>
+#include <ast_dir.h>
+#include <ast_dirent.h>
+#include <ast_float.h>
+#include <ast_fs.h>
+#include <ast_getopt.h>
+#include <ast_iconv.h>
+#include <ast_lib.h>
+#include <ast_limits.h>
+#include <ast_mmap.h>
+#include <ast_mode.h>
+#include <ast_nl_types.h>
+#include <ast_param.h>
+#include <ast_time.h>
+#include <ast_tty.h>
+#include <ast_types.h>
+#include <ast_version.h>
+#include <bytesex.h>
+#include <ccode.h>
+#include <cdt.h>
+#include <debug.h>
+#include <dirent.h>
+#include <dt.h>
+#include <endian.h>
+#include <error.h>
+#include <find.h>
+#include <fnmatch.h>
+#include <fnv.h>
+#include <fs3d.h>
+#include <fts.h>
+#include <ftw.h>
+#include <getopt.h>
+#include <glob.h>
+#include <hash.h>
+#include <hashkey.h>
+#include <hashpart.h>
+#include <iconv.h>
+#include <lc.h>
+#include <limits.h>
+#include <ls.h>
+#include <magic.h>
+#include <magicid.h>
+#include <mc.h>
+#include <mime.h>
+#include <mnt.h>
+#include <modecanon.h>
+#include <namval.h>
+#include <nl_types.h>
+#include <option.h>
+#include <preroot.h>
+#include <proc.h>
+#include <re_comp.h>
+#include <recfmt.h>
+#include <regex.h>
+#include <regexp.h>
+#include <sfdisc.h>
+#include <sfio_s.h>
+#include <sfio_t.h>
+#include <sig.h>
+#include <stack.h>
+#include <stak.h>
+#include <stk.h>
+#include <swap.h>
+#include <tar.h>
+#include <times.h>
+#include <tm.h>
+#include <tmx.h>
+#include <tok.h>
+#include <tv.h>
+#include <usage.h>
+#include <vdb.h>
+#include <vecargs.h>
+#include <wait.h>
+#include <wchar.h>
+#include <wordexp.h>
+
+#if defined(_AST_STD_H) || defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE)
+#define _AST_mode_t mode_t
+#else
+#define _AST_mode_t int
+#endif
+
+/* automatically generated data start here */
+/* tmpastinclude/ast.h */
+extern char* astconf(const char*, const char*, const char*);
+extern Ast_confdisc_f astconfdisc(Ast_confdisc_f);
+extern void astconflist(Sfio_t*, const char*, int, const char*);
+extern off_t astcopy(int, int, off_t);
+extern int astlicense(char*, int, char*, char*, int, int, int);
+extern int astquery(int, const char*, ...);
+extern void astwinsize(int, int*, int*);
+extern ssize_t base64encode(const void*, size_t, void**, void*, size_t, void**);
+extern ssize_t base64decode(const void*, size_t, void**, void*, size_t, void**);
+extern int chresc(const char*, char**);
+extern int chrtoi(const char*);
+extern int eaccess(const char*, int);
+/*
+extern char* fmtbase(long, int, int);
+extern char* fmtbasell(_ast_intmax_t, int, int);
+extern char* fmtbuf(size_t);
+extern char* fmtclock(Sfulong_t);
+extern char* fmtelapsed(unsigned long, int);
+extern char* fmterror(int);
+extern char* fmtesc(const char*);
+extern char* fmtesq(const char*, const char*);
+extern char* fmtident(const char*);
+extern char* fmtip4(unsigned _ast_int4_t, int);
+extern char* fmtfmt(const char*);
+extern char* fmtgid(int);
+extern char* fmtmatch(const char*);
+extern char* fmtmode(int, int);
+extern char* fmtnesq(const char*, const char*, size_t);
+extern char* fmtnum(unsigned long, int);
+extern char* fmtperm(int);
+extern char* fmtquote(const char*, const char*, const char*, size_t, int);
+extern char* fmtre(const char*);
+extern char* fmtscale(Sfulong_t, int);
+extern char* fmtsignal(int);
+extern char* fmttime(const char*, time_t);
+extern char* fmtuid(int);
+extern char* fmtversion(unsigned long);
+*/
+extern void* _ast_memdup(const void*, size_t);
+extern void _ast_memfatal(void);
+extern unsigned int _ast_memhash(const void*, int);
+extern unsigned long memsum(const void*, int, unsigned long);
+extern char* _ast_pathaccess(char*, const char*, const char*, const char*, int);
+extern char* _ast_pathbin(void);
+extern char* _ast_pathcanon(char*, int);
+extern char* _ast_pathcat(char*, const char*, int, const char*, const char*);
+extern int _ast_pathcd(const char*, const char*);
+extern int _ast_pathcheck(const char*, const char*, Pathcheck_t*);
+extern int _ast_pathexists(char*, int);
+extern char* _ast_pathfind(const char*, const char*, const char*, char*, size_t);
+extern int _ast_pathgetlink(const char*, char*, int);
+extern int _ast_pathinclude(const char*);
+extern char* _ast_pathkey(char*, char*, const char*, const char*, const char*);
+extern size_t _ast_pathnative(const char*, char*, size_t);
+extern char* _ast_pathpath(char*, const char*, const char*, int);
+extern size_t _ast_pathposix(const char*, char*, size_t);
+extern char* _ast_pathprobe(char*, char*, const char*, const char*, const char*, int);
+extern char* _ast_pathrepl(char*, const char*, const char*);
+extern int _ast_pathsetlink(const char*, const char*);
+extern char* _ast_pathshell(void);
+extern char* _ast_pathtemp(char*, size_t, const char*, const char*, int*);
+extern char* _ast_pathtmp(char*, const char*, const char*, int*);
+extern char* _ast_setenviron(const char*);
+extern int _ast_stracmp(const char*, const char*);
+extern char* _ast_strcopy(char*, const char*);
+extern unsigned long _ast_strelapsed(const char*, char**, int);
+extern int _ast_stresc(char*);
+extern long _ast_streval(const char*, char**, long(*)(const char*, char**));
+extern long _ast_strexpr(const char*, char**, long(*)(const char*, char**, void*), void*);
+extern int _ast_strgid(const char*);
+extern int _ast_strgrpmatch(const char*, const char*, int*, int, int);
+extern unsigned int strhash(const char*);
+extern void* _ast_strlook(const void*, size_t, const char*);
+extern int _ast_strmatch(const char*, const char*);
+extern int _ast_strmode(const char*);
+extern int _ast_strnacmp(const char*, const char*, size_t);
+extern char* _ast_strncopy(char*, const char*, size_t);
+extern double _ast_strntod(const char*, size_t, char**);
+extern _ast_fltmax_t _ast_strntold(const char*, size_t, char**);
+extern long _ast_strntol(const char*, size_t, char**, int);
+extern _ast_intmax_t _ast_strntoll(const char*, size_t, char**, int);
+extern unsigned long strntoul(const char*, size_t, char**, int);
+extern unsigned _ast_intmax_t strntoull(const char*, size_t, char**, int);
+extern int _ast_stropt(const char*, const void*, int, int(*)(void*, const void*, int, const char*), void*);
+extern int _ast_strperm(const char*, char**, int);
+extern void* _ast_strpsearch(const void*, size_t, size_t, const char*, char**);
+extern void* _ast_strsearch(const void*, size_t, size_t, Strcmp_f, const char*, void*);
+extern void _ast_strsort(char**, int, int(*)(const char*, const char*));
+extern char* _ast_strsubmatch(const char*, const char*, int);
+extern unsigned long _ast_strsum(const char*, unsigned long);
+extern char* _ast_strtape(const char*, char**);
+extern int _ast_strtoip4(const char*, char**, unsigned _ast_int4_t*, unsigned char*);
+extern long _ast_strton(const char*, char**, char*, int);
+extern _ast_intmax_t _ast_strtonll(const char*, char**, char*, int);
+extern int _ast_struid(const char*);
+extern int _ast_struniq(char**, int);
+extern char** environ;
+
+/* tmpastinclude/align.h */
+
+/* tmpastinclude/ast_botch.h */
+
+/* tmpastinclude/ast_ccode.h */
+
+/* tmpastinclude/ast_common.h */
+
+/* tmpastinclude/ast_dir.h */
+
+/* tmpastinclude/ast_dirent.h */
+
+/* tmpastinclude/ast_float.h */
+
+/* tmpastinclude/ast_fs.h */
+extern int fstatvfs(int, struct statvfs*);
+extern int statvfs(const char*, struct statvfs*);
+extern int statvfs64(const char*, struct statvfs64*);
+extern int fstatvfs64(int, struct statvfs64*);
+
+/* tmpastinclude/ast_getopt.h */
+extern int opterr;
+extern int optind;
+extern int optopt;
+extern char* optarg;
+extern int _ast_getopt(int, char* const*, const char*);
+extern int _ast_getsubopt(char**, char* const*, char**);
+
+/* tmpastinclude/ast_hdr.h */
+
+/* tmpastinclude/ast_iconv.h */
+extern _ast_iconv_t _ast_iconv_open(const char*, const char*);
+extern size_t _ast_iconv(_ast_iconv_t, char**, size_t*, char**, size_t*);
+extern int _ast_iconv_close(_ast_iconv_t);
+extern _ast_iconv_list_t* _ast_iconv_list(_ast_iconv_list_t*);
+extern int _ast_iconv_name(const char*, char*, size_t);
+extern ssize_t _ast_iconv_move(_ast_iconv_t, Sfio_t*, Sfio_t*, size_t, size_t*);
+extern ssize_t _ast_iconv_write(_ast_iconv_t, Sfio_t*, char**, size_t*, size_t*);
+extern ssize_t _ast_iconv_move(_ast_iconv_t, FILE*, FILE*, size_t, size_t*);
+extern ssize_t _ast_iconv_write(_ast_iconv_t, FILE*, char**, size_t*, size_t*);
+
+/* tmpastinclude/ast_lib.h */
+
+/* tmpastinclude/ast_limits.h */
+
+/* tmpastinclude/ast_mmap.h */
+
+/* tmpastinclude/ast_mode.h */
+
+/* tmpastinclude/ast_nl_types.h */
+extern nl_catd catopen(const char*, int);
+extern char* catgets(nl_catd, int, int, const char*);
+extern int catclose(nl_catd);
+
+/* tmpastinclude/ast_param.h */
+
+/* tmpastinclude/ast_time.h */
+
+/* tmpastinclude/ast_tty.h */
+
+/* tmpastinclude/ast_types.h */
+
+/* tmpastinclude/ast_unistd.h */
+
+/* tmpastinclude/ast_version.h */
+
+/* tmpastinclude/ast_wait.h */
+
+/* tmpastinclude/bytesex.h */
+
+/* tmpastinclude/ccode.h */
+extern unsigned char* _ccmap(int, int);
+extern void* _ccmapcpy(unsigned char*, void*, const void*, size_t);
+extern void* _ccmapstr(unsigned char*, void*, size_t);
+extern int ccmapid(const char*);
+extern char* ccmapname(int);
+extern void* ccnative(void*, const void*, size_t);
+extern Ccmap_t* ccmaplist(Ccmap_t*);
+
+/* tmpastinclude/cdt.h */
+extern Dtmethod_t* Dtset;
+extern Dtmethod_t* Dtbag;
+extern Dtmethod_t* Dtoset;
+extern Dtmethod_t* Dtobag;
+extern Dtmethod_t* Dtlist;
+extern Dtmethod_t* Dtstack;
+extern Dtmethod_t* Dtqueue;
+extern Dtmethod_t* Dtorder;
+extern Dtmethod_t* Dttree;
+extern Dtmethod_t* Dthash;
+extern Dtmethod_t _Dttree;
+extern Dtmethod_t _Dthash;
+extern Dtmethod_t _Dtlist;
+extern Dtmethod_t _Dtqueue;
+extern Dtmethod_t _Dtstack;
+extern Dt_t* dtopen(Dtdisc_t*, Dtmethod_t*);
+extern int dtclose(Dt_t*);
+extern Dt_t* dtview(Dt_t*, Dt_t*);
+extern Dtdisc_t* dtdisc(Dt_t* dt, Dtdisc_t*, int);
+extern Dtmethod_t* dtmethod(Dt_t*, Dtmethod_t*);
+extern Dtlink_t* dtflatten(Dt_t*);
+extern Dtlink_t* dtextract(Dt_t*);
+extern int dtrestore(Dt_t*, Dtlink_t*);
+extern int dttreeset(Dt_t*, int, int);
+extern int dtwalk(Dt_t*, int(*)(Dt_t*,Void_t*,Void_t*), Void_t*);
+extern Void_t* dtrenew(Dt_t*, Void_t*);
+extern int dtsize(Dt_t*);
+extern int dtstat(Dt_t*, Dtstat_t*, int);
+extern unsigned int dtstrhash(unsigned int, Void_t*, int);
+extern int memcmp(const Void_t*, const Void_t*, size_t);
+extern int strcmp(const char*, const char*);
+
+/* tmpastinclude/debug.h */
+extern void systrace(const char*);
+
+/* tmpastinclude/dirent.h */
+
+/* tmpastinclude/dt.h */
+extern Dt_t* dtnew(Vmalloc_t*, Dtdisc_t*, Dtmethod_t*);
+
+/* tmpastinclude/endian.h */
+
+/* tmpastinclude/error.h */
+extern int errno;
+extern Error_info_t error_info;
+extern void error(int, ...);
+extern int errormsg(const char*, int, ...);
+extern int errorf(void*, void*, int, ...);
+extern void errorv(const char*, int, va_list);
+extern char* errorx(const char*, const char*, const char*, const char*);
+extern void liberror(const char*, int, ...);
+extern int libevent(void*, void*, int, ...);
+
+/* tmpastinclude/find.h */
+extern Find_t* findopen(const char*, const char*, const char*, Finddisc_t*);
+extern char* findread(Find_t*);
+extern int findwrite(Find_t*, const char*, size_t, const char*);
+extern int findclose(Find_t*);
+
+/* tmpastinclude/fnmatch.h */
+extern int _ast_fnmatch(const char*, const char*, int);
+
+/* tmpastinclude/fnv.h */
+
+/* tmpastinclude/fs3d.h */
+extern int mount(const char*, char*, int, void*);
+extern int fs3d(int);
+extern char* pathnext(char*, char*, long*);
+
+/* tmpastinclude/fts.h */
+extern FTSENT* _ast_fts_children(FTS*, int);
+extern int _ast_fts_close(FTS*);
+extern int _ast_fts_flags(void);
+extern int _ast_fts_notify(int(*)(FTS*, FTSENT*, void*), void*);
+extern FTS* _ast_fts_open(char* const*, int, int(*)(FTSENT* const*, FTSENT* const*));
+extern FTSENT* _ast_fts_read(FTS*);
+extern int _ast_fts_set(FTS*, FTSENT*, int);
+
+/* tmpastinclude/ftw.h */
+extern int _ast_ftw(const char*, int(*)(const char*, const struct stat*, int), int);
+extern int _ast_nftw(const char*, int(*)(const char*, const struct stat*, int, struct FTW*), int, int);
+
+/* tmpastinclude/getopt.h */
+extern int getopt_long(int, char* const*, const char*, const struct option*, int*);
+extern int getopt_long_only(int, char* const*, const char*, const struct option*, int*);
+
+/* tmpastinclude/glob.h */
+extern int _ast_glob(const char*, int, int(*)(const char*,int), glob_t*);
+extern void _ast_globfree(glob_t*);
+
+/* tmpastinclude/hash.h */
+extern Hash_table_t* hashalloc(Hash_table_t*, ...);
+extern void hashdone(Hash_position_t*);
+extern void hashdump(Hash_table_t*, int);
+extern Hash_table_t* hashfree(Hash_table_t*);
+extern Hash_bucket_t* hashlast(Hash_table_t*);
+extern char* hashlook(Hash_table_t*, const char*, long, const char*);
+extern Hash_bucket_t* hashnext(Hash_position_t*);
+extern Hash_position_t* hashscan(Hash_table_t*, int);
+extern void hashsize(Hash_table_t*, int);
+extern Hash_table_t* hashview(Hash_table_t*, Hash_table_t*);
+extern int hashwalk(Hash_table_t*, int, int (*)(const char*, char*, void*), void*);
+
+/* tmpastinclude/hashkey.h */
+extern long _ast_strkey(const char*);
+
+/* tmpastinclude/hashpart.h */
+
+/* tmpastinclude/iconv.h */
+
+/* tmpastinclude/lc.h */
+extern size_t lccanon(Lc_t*, unsigned long flags, char*, size_t);
+extern Lc_category_t* lccategories(void);
+extern int lcindex(int, int);
+extern Lc_info_t* lcinfo(int);
+extern Lc_t* lcmake(const char*);
+extern Lc_t* lcscan(Lc_t*);
+
+/* tmpastinclude/limits.h */
+
+/* tmpastinclude/ls.h */
+extern int chmod(const char*, _AST_mode_t);
+extern int fstat(int, struct stat*);
+extern int lstat(const char*, struct stat*);
+extern int mkdir(const char*, _AST_mode_t);
+extern int mkfifo(const char*, _AST_mode_t);
+extern int mknod(const char*, _AST_mode_t, dev_t);
+extern int stat(const char*, struct stat*);
+extern _AST_mode_t umask(_AST_mode_t);
+extern off_t _iblocks(struct stat*);
+extern char* fmtdev(struct stat*);
+extern char* fmtfs(struct stat*);
+extern char* fmtls(char*, const char*, struct stat*, const char*, const char*, int);
+extern int _ast_pathstat(const char*, struct stat*);
+
+/* tmpastinclude/magic.h */
+extern Magic_t* magicopen(Magicdisc_t*);
+extern int magicload(Magic_t*, const char*, unsigned long);
+extern int magiclist(Magic_t*, Sfio_t*);
+extern char* magictype(Magic_t*, Sfio_t*, const char*, struct stat*);
+extern int magicclose(Magic_t*);
+
+/* tmpastinclude/magicid.h */
+
+/* tmpastinclude/mc.h */
+extern char* mcfind(char*, const char*, const char*, int, int);
+extern Mc_t* mcopen(Sfio_t*);
+extern char* mcget(Mc_t*, int, int, const char*);
+extern int mcput(Mc_t*, int, int, const char*);
+extern int mcdump(Mc_t*, Sfio_t*);
+extern int mcindex(const char*, char**, int*, int*);
+extern int mcclose(Mc_t*);
+
+/* tmpastinclude/mime.h */
+extern Mime_t* mimeopen(Mimedisc_t*);
+extern int mimeload(Mime_t*, const char*, unsigned long);
+extern int mimelist(Mime_t*, Sfio_t*, const char*);
+extern int mimeclose(Mime_t*);
+extern int mimeset(Mime_t*, char*, unsigned long);
+extern char* mimetype(Mime_t*, Sfio_t*, const char*, struct stat*);
+extern char* mimeview(Mime_t*, const char*, const char*, const char*, const char*);
+extern int mimehead(Mime_t*, void*, size_t, size_t, char*);
+extern int mimecmp(const char*, const char*, char**);
+
+/* tmpastinclude/mnt.h */
+extern void* mntopen(const char*, const char*);
+extern Mnt_t* mntread(void*);
+extern int mntwrite(void*, const Mnt_t*);
+extern int mntclose(void*);
+
+/* tmpastinclude/modecanon.h */
+
+/* tmpastinclude/namval.h */
+
+/* tmpastinclude/nl_types.h */
+
+/* tmpastinclude/option.h */
+extern Opt_t opt_info;
+extern int _ast_optget(char**, const char*);
+extern int _ast_optjoin(char**, ...);
+extern char* _ast_opthelp(const char*, const char*);
+extern char* _ast_optusage(const char*);
+extern int _ast_optstr(const char*, const char*);
+extern int _ast_optesc(Sfio_t*, const char*, int);
+
+/* tmpastinclude/preroot.h */
+
+/* tmpastinclude/proc.h */
+extern int _ast_procclose(Proc_t*);
+extern int _ast_procfree(Proc_t*);
+extern Proc_t* _ast_procopen(const char*, char**, char**, long*, long);
+extern int _ast_procrun(const char*, char**);
+
+/* tmpastinclude/re_comp.h */
+extern char* _ast_re_comp(const char*);
+extern int _ast_re_exec(const char*);
+
+/* tmpastinclude/recfmt.h */
+extern char* fmtrec(Recfmt_t, int);
+extern Recfmt_t recfmt(const void*, size_t, off_t);
+extern Recfmt_t recstr(const char*, char**);
+extern ssize_t reclen(Recfmt_t, const void*, size_t);
+
+/* tmpastinclude/regex.h */
+extern int _ast_regcomp(regex_t*, const char*, regflags_t);
+extern size_t _ast_regerror(int, const regex_t*, char*, size_t);
+extern int _ast_regexec(const regex_t*, const char*, size_t, regmatch_t*, regflags_t);
+extern void _ast_regfree(regex_t*);
+extern regclass_t _ast_regclass(const char*, char**);
+extern int _ast_regaddclass(const char*, regclass_t);
+extern int _ast_regcollate(const char*, char**, char*, int);
+extern int _ast_regcomb(regex_t*, regex_t*);
+extern int _ast_regdup(regex_t*, regex_t*);
+extern int _ast_regncomp(regex_t*, const char*, size_t, regflags_t);
+extern int _ast_regnexec(const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t);
+extern void _ast_regfatal(regex_t*, int, int);
+extern void _ast_regfatalpat(regex_t*, int, int, const char*);
+extern int _ast_regrecord(const regex_t*);
+extern int _ast_regrexec(const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t, regflags_t, void*, regrecord_t);
+extern regstat_t* _ast_regstat(const regex_t*);
+extern regex_t* _ast_regcache(const char*, regflags_t, int*);
+extern int _ast_regsubcomp(regex_t*, const char*, const regflags_t*, int, regflags_t);
+extern int _ast_regsubexec(const regex_t*, const char*, size_t, regmatch_t*);
+extern int _ast_regsubflags(regex_t*, const char*, char**, int, const regflags_t*, int*, regflags_t*);
+extern void _ast_regsubfree(regex_t*);
+extern void _ast_regalloc(void*, regresize_t, regflags_t);
+extern int _ast_regsub(const regex_t*, struct _sfio_s*, const char*, const char*, size_t, regmatch_t*, regflags_t);
+
+/* tmpastinclude/regexp.h */
+extern int _re_comp(regexp_t*, const char*, char*, unsigned int);
+extern int _re_exec(regexp_t*, const char*, const char*, int);
+extern char* _re_putc(int);
+extern char* _re_read(regexp_t*, const char*, char*, const char*, int);
+
+/* tmpastinclude/sfdisc.h */
+extern int sfkeyprintf(Sfio_t*, void*, const char*, Sf_key_lookup_t, Sf_key_convert_t);
+extern int sfkeyprintf(Sfio_t*, void*, const char*, Sf_key_lookup_t, Sf_key_convert_t);
+extern int sfdcdio(Sfio_t*, size_t);
+extern int sfdcdos(Sfio_t*);
+extern int sfdcfilter(Sfio_t*, const char*);
+extern int sfdcmore(Sfio_t*, const char*, int, int);
+extern int sfdcprefix(Sfio_t*, const char*);
+extern int sfdcseekable(Sfio_t*);
+extern int sfdcslow(Sfio_t*);
+extern int sfdctee(Sfio_t*, Sfio_t*);
+extern int sfdcunion(Sfio_t*, Sfio_t**, int);
+extern Sfio_t* sfdcsubstream(Sfio_t*, Sfio_t*, Sfoff_t, Sfoff_t);
+
+/* tmpastinclude/sfio_s.h */
+
+/* tmpastinclude/sfio_t.h */
+
+/* tmpastinclude/sig.h */
+extern int kill(pid_t, int);
+extern int killpg(pid_t, int);
+extern Sig_info_t sig_info;
+extern int sigcritical(int);
+extern int sigunblock(int);
+
+/* tmpastinclude/stack.h */
+extern STACK stackalloc(int, void*);
+extern void stackfree(STACK);
+extern void stackclear(STACK);
+extern void* stackget(STACK);
+extern int stackpush(STACK, void*);
+extern int stackpop(STACK);
+extern void stacktell(STACK, int, STACKPOS*);
+
+/* tmpastinclude/stak.h */
+
+/* tmpastinclude/stk.h */
+extern Sfio_t _Stk_data;
+extern Stk_t* stkopen(int);
+extern Stk_t* stkinstall(Stk_t*, char*(*)(int));
+extern int stkclose(Stk_t*);
+extern int stklink(Stk_t*);
+extern char* stkalloc(Stk_t*, unsigned);
+extern char* stkcopy(Stk_t*,const char*);
+extern char* stkset(Stk_t*, char*, unsigned);
+extern char* _stkseek(Stk_t*, unsigned);
+extern char* stkfreeze(Stk_t*, unsigned);
+
+/* tmpastinclude/swap.h */
+extern void* swapmem (int, const void*, void*, size_t);
+extern intmax_t swapget (int, const void*, int);
+extern void* swapput (int, void*, int, intmax_t);
+extern int swapop (const void*, const void*, int);
+
+/* tmpastinclude/tar.h */
+
+/* tmpastinclude/times.h */
+extern int _ast_touch(const char*, time_t, time_t, int);
+
+/* tmpastinclude/tm.h */
+extern Tm_data_t tm_data;
+extern Tm_info_t tm_info;
+extern time_t tmdate(const char*, char**, time_t*);
+extern int tmequiv(Tm_t*);
+extern Tm_t* tmfix(Tm_t*);
+extern char* tmfmt(char*, size_t, const char*, time_t*);
+extern char* tmform(char*, const char*, time_t*);
+extern int tmgoff(const char*, char**, int);
+extern void tminit(Tm_zone_t*);
+extern time_t tmleap(time_t*);
+extern int tmlex(const char*, char**, char**, int, char**, int);
+extern char** tmlocale(void);
+extern Tm_t* tmmake(time_t*);
+extern char* tmpoff(char*, size_t, const char*, int, int);
+extern time_t tmscan(const char*, char**, const char*, char**, time_t*, long);
+extern int tmsleep(time_t, time_t);
+extern time_t tmtime(Tm_t*, int);
+extern Tm_zone_t* tmtype(const char*, char**);
+extern int tmweek(Tm_t*, int, int, int);
+extern int tmword(const char*, char**, const char*, char**, int);
+extern Tm_zone_t* tmzone(const char*, char**, const char*, int*);
+
+/* tmpastinclude/tmx.h */
+extern Time_t tmxdate(const char*, char**, Time_t);
+extern char* tmxfmt(char*, size_t, const char*, Time_t);
+extern Time_t tmxleap(Time_t);
+extern Tm_t* tmxmake(Time_t);
+extern Time_t tmxscan(const char*, char**, const char*, char**, Time_t, long);
+extern int tmxsleep(Time_t);
+extern Time_t tmxtime(Tm_t*, int);
+extern Time_t tmxgettime(void);
+extern int tmxsettime(Time_t);
+extern int tmxtouch(const char*, Time_t, Time_t, Time_t, int);
+extern char* fmttmx(const char*, Time_t);
+
+/* tmpastinclude/tok.h */
+extern Sfio_t* tokline(const char*, int, int*);
+extern int tokscan(char*, char**, const char*, ...);
+extern char* tokopen(char*, int);
+extern void tokclose(char*);
+extern char* tokread(char*);
+
+/* tmpastinclude/tv.h */
+extern int tvgettime(Tv_t*);
+extern int tvsettime(const Tv_t*);
+extern int tvcmp(const Tv_t*, const Tv_t*);
+extern int tvtouch(const char*, const Tv_t*, const Tv_t*, const Tv_t*, int);
+extern int tvsleep(const Tv_t*, Tv_t*);
+extern char* fmttv(const char*, Tv_t*);
+
+/* tmpastinclude/usage.h */
+
+/* tmpastinclude/vdb.h */
+
+/* tmpastinclude/vecargs.h */
+extern int vecargs(char**, int*, char***);
+extern char** vecfile(const char*);
+extern void vecfree(char**, int);
+extern char** vecload(char*);
+extern char** vecstring(const char*);
+
+/* tmpastinclude/wchar.h */
+
+/* tmpastinclude/wordexp.h */
+extern int _ast_wordexp(const char*, wordexp_t*, int);
+extern int _ast_wordfree(wordexp_t*);
+/* end of automatically generated data */
diff --git a/usr/src/lib/libast/common/man/LIBAST.3 b/usr/src/lib/libast/common/man/LIBAST.3
new file mode 100644
index 0000000000..380ebde2dc
--- /dev/null
+++ b/usr/src/lib/libast/common/man/LIBAST.3
@@ -0,0 +1,98 @@
+.fp 5 CW
+.de Af
+.if \\$2 .nr ;G \\$1
+.ie !\\$3 \{\
+\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8"
+\}
+..
+.de aF
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8"
+.ft \\n(;G
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH LIBAST 3
+.UC 4
+.SH NAME
+libast \- introduction to the ast library
+.SH DESCRIPTION
+This section describes the
+.I AST
+(AT&T Software Technology) library functions of the
+.B libast
+library.
+.B libast
+serves three major purposes.
+First, it presents (a subset of) POSIX/ANSI standard headers and interfaces on
+non-compliant systems.
+Second, it provides a portable base of routines that implement concepts
+common to all UNIX system variants.
+Finally, it is a forum for
+modern implementations of features present (or lacking)
+in the standard C libraries.
+Features better provided by separate libraries are omitted from
+.BR libast .
+For example, most terminal driver interface issues are left for
+special purpose libraries such as
+.IR curses (3).
+.PP
+The
+.B libast
+related header files are installed in the directories
+.LR include/ast .
+Routines that do not advertize their own headers are prototyped in
+.LR <ast.h> .
+.L <ast.h>
+is ANSI, K&R and C++ compatible and includes or defines the equivalent of
+.LR <limits.h> ,
+.LR <stddef.h> ,
+.LR <stdlib.h> ,
+.LR <sys/types.h> ,
+.L <string.h>
+and
+.LR <unistd.h> .
+Other libraries that depend on
+.B libast
+may also have headers installed in the
+.L include/ast
+directories.
+.SH FILES
+.nf
+include/ast the \fBast\fP package header directory
+lib/libast.a the \fBlibast\fP library
+lib/libast-g.a the \fBlibast\fP library compiled for debugging
+lib/libast-pg.a the \fBlibast\fP library compiled for profiling
+lib/libast.so.4.0 the \fBlibast\fP shared library
+.fi
+.SH "SEE ALSO"
+intro(3),
+intro(2),
+cc(1)
+.SH CAVEATS
+The library documentation is still under construction.
+Yes, some of it has been in this state for 20 years.
+Thank goodness our commands self-document.
diff --git a/usr/src/lib/libast/common/man/ast.3 b/usr/src/lib/libast/common/man/ast.3
new file mode 100644
index 0000000000..8055be9dbc
--- /dev/null
+++ b/usr/src/lib/libast/common/man/ast.3
@@ -0,0 +1,283 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH AST 3
+.SH NAME
+ast \- miscellaneous libast support
+.SH SYNOPSIS
+.EX
+#include <ast.h>
+
+char* astconf(const char* \fIname\fP, const char* \fIpath\fP, const char* \fIvalue\fP);
+Ast_confdisc_t astconfdisc(Ast_confdisc_t new_notify);
+void astconflist(Sfio_t* stream, const char* path, int flags);
+off_t astcopy(int \fIrfd\fP, int \fIwfd\fP, off_t \fIn\fP);
+int astquery(int \fIfd\fP, const char* \fIformat\fP , ...);
+.EE
+.SH DESCRIPTION
+.L astconf
+is a string interface to the
+.IR confstr (2),
+.IR pathconf (2),
+and
+.IR sysconf (2)
+calls.
+If
+.I value
+is
+.L 0
+then the configuration parameter value for
+.I name
+is returned.
+Some
+.I name
+configuration parameters may consult the
+.I path
+argument.
+In this case if
+.I path
+is
+.L 0
+then
+\f5"/"\fP
+is used.
+Otherwise if
+.I path
+is not
+.L 0
+then it must exist.
+The string return value for
+.I name
+remains unchanged until the next
+.L astconf
+call on
+.IR name .
+If
+.I value
+is
+.L 0
+then a valid string is always returned;
+\f5""\fP
+is returned if
+.I name
+has no configuration value.
+This simplifies the programming interface:
+.EX
+if (!strcmp(astconf("PATH_RESOLVE", NiL, NiL), "logical"))
+ /* the logical way ... */
+.EE
+If
+.I value
+is not
+.L 0
+then the configuration parameter value for
+.I name
+is set to
+.IR value .
+.L 0
+is returned if the value cannot be set.
+The paradigm is:
+.EX
+universe = astconf("UNIVERSE", 0, "att");
+\|.\|.\|.
+astconf("UNIVERSE", 0, universe);
+.EE
+The settable configuration names are:
+.TP
+.L FS_3D
+.L 1
+if
+.IR 3d (1)
+viewpathing is enabled,
+.L 0
+otherwise.
+This is an alternative to the
+.IR fs3d (3)
+interface.
+.TP
+.L PATH_RESOLVE
+.L logical
+if symbolic links are followed during file tree traversal,
+.L physical
+if symbolic links are not followed during file tree traversal,
+and
+.L metaphysical
+if symbolic links are followed at the top level during file tree traversal.
+These correspond to the generic
+.LR \-L ,
+.LR \-P ,
+and
+.L \-H
+command options.
+.TP
+.L UNIVERSE
+.L ucb
+for
+.I Berkeley
+style and
+.L att
+otherwise.
+This configuration parameter controls the
+.I universe
+setting on machines that support it (e.g., Pyramid).
+.L UNIVERSE
+also controls the behavior of some commands like
+.IR cat (1)
+and
+.IR echo (1).
+.PP
+User defined
+.I name
+values may also be set and queried, but these should probably have
+some form of vendor prefix to avoid being stomped by future standards.
+.PP
+.L astconfdisc
+registers a discipline function
+.EX
+int (*notify)(const char* \fIname\fP, const char* \fIpath\fP, const char* \fIvalue\fP);
+.EE
+that is called just before the configuration parameter
+.I name
+is set to
+.I value
+relative to
+.IR path .
+If
+.I notify
+returns
+.L 0
+then the configuration parameter value is not changed.
+.PP
+.L astconflist
+lists the current configuration names and values of
+.IR stream .
+If
+.I path
+is
+.L 0
+then \f5"/"\fP is used where appropriate.
+If
+.I flags
+is
+.L 0
+or
+.L R_OK|W_OK
+then all configuration parameters are listed.
+.L R_OK
+lists the readonly configuration parameters and
+.L W_OK
+lists the settable configuration parameters.
+.L X_OK
+lists the settable configuration parameters in a form that can be
+snarfed for input to the
+.IR getconf (1)
+command.
+.PP
+.L astcopy
+efficiently copies up to
+.I n
+bytes from the file descriptor
+.I rfd
+to the file descriptor
+.IR wfd .
+The actual number of bytes copied is returned; \-1 is returned on error.
+If
+.I n
+is 0 then an optimal number of bytes (with respect to both
+.I rfd
+and
+.IR wfd )
+is copied.
+.PP
+If possible
+.IR mmap (2)
+is used to do the transfer.
+Some implementations may bypass user buffer copies usually required by the
+.IR read (2)- write (2)
+paradigm.
+.PP
+.L astquery
+outputs an
+.IR sfprintf (3)
+prompt specified by
+.I "format, .\|.\|."
+to the controlling terminal and reads a response from the controlling terminal.
+Offirmative response returns
+.LR 0 ,
+.L EOF
+or quit response returns
+.LR \-1 ,
+otherwise
+.L 1
+is returned.
+If
+.I quit
+is greater than
+.L 0
+then
+.I exit(quit)
+is called on a quit response.
+The responses will eventually be locale specific.
+.PP
+.L astwinsize
+returns the number of rows in
+.I *rows
+and the number of columns
+.I *col
+for the terminal file descriptor
+.IR fd .
+If the number of rows or columns cannot be determined or if
+.I fd
+is not a terminal then
+.I *rows
+and
+.I *cols
+are set to
+.LR 0 .
+If
+.I ioctl (2)
+methods fail then the environment variable
+.L LINES
+is used to set
+.I *rows
+and the environment variable
+.L COLUMNS
+is used to set
+.IR *cols .
+.SH "SEE ALSO"
+getconf(1), confstr(2), mmap(2), pathconf(2), read(2), sysconf(2), write(2)
diff --git a/usr/src/lib/libast/common/man/astsa.3 b/usr/src/lib/libast/common/man/astsa.3
new file mode 100644
index 0000000000..02c803aee6
--- /dev/null
+++ b/usr/src/lib/libast/common/man/astsa.3
@@ -0,0 +1,161 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.PP
+..
+.de Tp
+.fl
+.ne 3
+.TP
+..
+.de Ss
+.fl
+.ne 3
+.SS "\\$1"
+..
+.ta 1.0i 2.0i 3.0i 4.0i 5.0i
+.TH AST 3
+.SH NAME
+astsa \- standalone libast support
+.SH SYNOPSIS
+.EX
+#include <ast.h>
+#include <ccode.h>
+#include <error.h>
+#include <option.h>
+#include <stk.h>
+.EE
+.SH DESCRIPTION
+.B astsa
+is a standalone subset of
+.BR ast (3)
+that requires only
+.BR cdt (3)
+and
+.BR sfio (3).
+.PP
+.B <ast.h>
+includes
+.BR <ast_common.h> ,
+.B <stdarg.h>
+or
+.BR <varargs.h> ,
+.BR <sfio.h> ,
+.BR <limits.h> ,
+and
+.B <limits.h>
+and
+.B <unistd.h>
+if supported by the local system.
+.PP
+The macros and functions provided by
+.B <ast.h>
+are described below.
+The other headers are described in
+.BR ccode (3),
+.BR error (3),
+.BR optget (3),
+and
+.BR stk (3).
+.SH MACROS
+.Ss "size_t elementsof(\fIx\fP)"
+Evaluates to the number of elements in the array variable
+.IR x .
+.Ss "\fItype\fP* newof(void* old, \fItype\fP, size_t \fIelements\fP, size_t \fIextra\fP)"
+Equivalent to (\fItype\fP*)realloc((char*)\fIold\fP,sizeof(\fItype\fP)*\fIelements\fP+\fIextra\fP)
+if \fIold\fP!=0 and
+(\fItype\fP*)calloc(1,sizeof(\fItype\fP)*\fIelements\fP+\fIextra\fP)
+otherwise.
+.Ss "\fItype\fP* oldof(void* old, \fItype\fP, size_t \fIelements\fP, size_t \fIextra\fP)"
+Equivalent to (\fItype\fP*)realloc((char*)\fIold\fP,sizeof(\fItype\fP)*\fIelements\fP+\fIextra\fP)
+if \fIold\fP!=0 and
+(\fItype\fP*)malloc(1,sizeof(\fItype\fP)*\fIelements\fP+\fIextra\fP)
+otherwise.
+.Ss "size_t roundof(\fIx\fP,\fIy\fP)"
+Evaluates to \fIx\fP rounded up to the next power of 2 boundary \fIy\fP.
+.Ss "int ssizeof(\fIx\fP)"
+Equivalent to (int)sizeof(\fIx\fP).
+.Ss "int streq(\fIa\fP,\fIb\fP)"
+Equivalent to (*(\fIa\fP)==*(\fIb\fP)&&strcmp(\fIa\fP,\fIb\fP)==0).
+.Ss "int strneq(\fIa\fP,\fIb\fP,\fIn\fP)"
+Equivalent to (*(\fIa\fP)==*(\fIb\fP)&&strncmp(\fIa\fP,\fIb\fP,\fIn\fP)==0).
+.SH FUNCTIONS
+.Ss "void astwinsize(int \fIfd\fP, int* \fIplines\fP, int* \fIpcolumns\fP)"
+If \fIplines\fP!=0 then *\fIplines\fP is set to the number of lines on the
+tty device corresponding to \fIfd\fP.
+If \fIpcolumns\fP!=0 then *\fIpcolumns\fP is set to the number of columns
+on the tty device corresponding to \fIfd\fP.
+The default if \fIfd\fP is not a terminal device, or if \fIfd\fP queries fail,
+is 24 lines and 80 columns.
+.Ss "char* fmterror(int \fIerrno\fP)"
+Returns the error message text corresponding to the
+.BR errno (3)
+\fIerrno\fP.
+.Ss "char* strerror(int \fIerrno\fP)"
+Equivalent to fmterror(\fIerrno\fP).
+.Ss "int strgrpmatch(const char* \fIstring\fP, const char* \fIpattern\fP, int* \fIsub\fP, int \fInsub\fP, int \fIflags\fP)"
+Matches the null terminated \fIstring\fP against the null terminated
+.BR ksh (1)
+augmented \fIpattern\fP.
+If \fIsub\fP!=0 then \fIsub\fP[2*\fIi\fP] is set to the start offset and \fIsub\fP[2*\fIi\fP+1] is set
+to the end offset of the \fIi\fP-th parenthesized subexpression.
+\fInsub\fP is 1/2 the number of elements in \fIsub\fP.
+\fIflags\fP controls the matching:
+.Tp
+\f5STR_MAXIMAL\fP:
+Maximal match.
+The default is minimal (first) match.
+.Tp
+\f5STR_LEFT\fP:
+Implicit left anchor.
+.Tp
+\f5STR_RIGHT\fP:
+Implicit right anchor.
+.Tp
+\f5STR_ICASE\fP:
+Ignore case.
+.Tp
+\f5STR_GROUP\fP:
+(|&) inside [@|*|+{n,m}](...) only.
+.Ss "int strmatch(const char* \fIstring\fP, const char* \fIpattern\fP, int* \fIsub\fP, int \fInsub\fP, int \fIflags\fP)"
+Equivalent to strgrpmatch(\fIstring\fP,\fIpattern\fP,0,0,STR_MAXIMAL|STR_LEFT|STR_RIGHT).
+.SH "SEE ALSO"
+.BR ast (3),
+.BR ccode (3),
+.BR cdt (3),
+.BR error (3),
+.BR malloc (3),
+.BR option (3),
+.BR sfio (3),
+.BR stk (3)
diff --git a/usr/src/lib/libast/common/man/cdt.3 b/usr/src/lib/libast/common/man/cdt.3
new file mode 100644
index 0000000000..f353e3f0b1
--- /dev/null
+++ b/usr/src/lib/libast/common/man/cdt.3
@@ -0,0 +1,593 @@
+.fp 5 CW
+.TH LIBCDT 3
+.SH NAME
+\fBCdt\fR \- container data types
+.SH SYNOPSIS
+.de Tp
+.fl
+.ne 2
+.TP
+..
+.de Ss
+.fl
+.ne 2
+.SS "\\$1"
+..
+.de Cs
+.nf
+.ft 5
+..
+.de Ce
+.ft 1
+.fi
+..
+.ta 1.0i 2.0i 3.0i 4.0i 5.0i
+.Cs
+#include <cdt.h>
+.Ce
+.Ss "DICTIONARY TYPES"
+.Cs
+Void_t*;
+Dt_t;
+Dtdisc_t;
+Dtmethod_t;
+Dtlink_t;
+Dtstat_t;
+.Ce
+.Ss "DICTIONARY CONTROL"
+.Cs
+Dt_t* dtopen(const Dtdisc_t* disc, const Dtmethod_t* meth);
+int dtclose(Dt_t* dt);
+void dtclear(dt);
+Dtmethod_t* dtmethod(Dt_t* dt, const Dtmethod_t* meth);
+Dtdisc_t* dtdisc(Dt_t* dt, const Dtdisc_t* disc, int type);
+Dt_t* dtview(Dt_t* dt, Dt_t* view);
+int dttreeset(Dt_t* dt, int minp, int balance);
+.Ce
+.Ss "STORAGE METHODS"
+.Cs
+Dtmethod_t* Dtset;
+Dtmethod_t* Dtbag;
+Dtmethod_t* Dtoset;
+Dtmethod_t* Dtobag;
+Dtmethod_t* Dtlist;
+Dtmethod_t* Dtstack;
+Dtmethod_t* Dtqueue;
+.Ce
+.Ss "DISCIPLINE"
+.Cs
+#define DTOFFSET(struct_s,member)
+#define DTDISC(disc,key,size,link,makef,freef,comparf,hashf,memoryf,eventf)
+typedef Void_t* (*Dtmake_f)(Dt_t*, Void_t*, Dtdisc_t*);
+typedef void (*Dtfree_f)(Dt_t*, Void_t*, Dtdisc_t*);
+typedef int (*Dtcompar_f)(Dt_t*, Void_t*, Void_t*, Dtdisc_t*);
+typedef unsigned int (*Dthash_f)(Dt_t*, Void_t*, Dtdisc_t*);
+typedef Void_t* (*Dtmemory_f)(Dt_t*, Void_t*, size_t, Dtdisc_t*);
+typedef int (*Dtevent_f)(Dt_t*, int, Void_t*, Dtdisc_t*);
+.Ce
+.Ss "OBJECT OPERATIONS"
+.Cs
+Void_t* dtinsert(Dt_t* dt, Void_t* obj);
+Void_t* dtdelete(Dt_t* dt, Void_t* obj);
+Void_t* dtattach(Dt_t* dt, Void_t* obj);
+Void_t* dtdetach(Dt_t* dt, Void_t* obj);
+Void_t* dtsearch(Dt_t* dt, Void_t* obj);
+Void_t* dtmatch(Dt_t* dt, Void_t* key);
+Void_t* dtfirst(Dt_t* dt);
+Void_t* dtnext(Dt_t* dt, Void_t* obj);
+Void_t* dtlast(Dt_t* dt);
+Void_t* dtprev(Dt_t* dt, Void_t* obj);
+Void_t* dtfinger(Dt_t* dt);
+Void_t* dtrenew(Dt_t* dt, Void_t* obj);
+int dtwalk(Dt_t* dt, int (*userf)(Dt_t*, Void_t*, Void_t*), Void_t*);
+Dtlink_t* dtflatten(Dt_t* dt);
+Dtlink_t* dtlink(Dt_t*, Dtlink_t* link);
+Void_t* dtobj(Dt_t* dt, Dtlink_t* link);
+Dtlink_t* dtextract(Dt_t* dt);
+int dtrestore(Dt_t* dt, Dtlink_t* link);
+
+#define DTTREESEARCH(Dt_t* dt, Void_t* obj, action)
+#define DTTREEMATCH(Dt_t* dt, Void_t* key, action)
+.Ce
+.Ss "DICTIONARY STATUS"
+.Cs
+Dt_t* dtvnext(Dt_t* dt);
+int dtvcount(Dt_t* dt);
+Dt_t* dtvhere(Dt_t* dt);
+int dtsize(Dt_t* dt);
+int dtstat(Dt_t* dt, Dtstat_t*, int all);
+.Ce
+.Ss "HASH FUNCTIONS"
+.Cs
+unsigned int dtstrhash(unsigned int h, char* str, int n);
+unsigned int dtcharhash(unsigned int h, unsigned char c);
+.Ce
+.SH DESCRIPTION
+.PP
+\fICdt\fP manages run-time dictionaries using standard container data types:
+unordered set/multiset, ordered set/multiset, list, stack, and queue.
+.PP
+.Ss "DICTIONARY TYPES"
+.PP
+.Ss " Void_t*"
+This type is used to pass objects between \fICdt\fP and application code.
+\f5Void_t\fP is defined as \f5void\fP for ANSI-C and C++
+and \f5char\fP for other compilation environments.
+.PP
+.Ss " Dt_t"
+This is the type of a dictionary handle.
+.PP
+.Ss " Dtdisc_t"
+This defines the type of a discipline structure which describes
+object lay-out and manipulation functions.
+.PP
+.Ss " Dtmethod_t"
+This defines the type of a container method.
+.PP
+.Ss " Dtlink_t"
+This is the type of a dictionary object holder (see \f5dtdisc()\fP.)
+.PP
+.Ss " Dtstat_t"
+This is the type of a structure to return dictionary statistics (see \f5dtstat()\fP.)
+.PP
+.Ss "DICTIONARY CONTROL"
+.PP
+.Ss " Dt_t* dtopen(const Dtdisc_t* disc, const Dtmethod_t* meth)"
+This creates a new dictionary.
+\f5disc\fP is a discipline structure to describe object format.
+\f5meth\fP specifies a manipulation method.
+\f5dtopen()\fP returns the new dictionary or \f5NULL\fP on error.
+See also the events \f5DT_OPEN\fP and \f5DT_ENDOPEN\fP below.
+.PP
+.Ss " int dtclose(Dt_t* dt)"
+This deletes \f5dt\fP and its objects.
+Note that \f5dtclose()\fP fails if \f5dt\fP is being viewed by
+some other dictionaries (see \f5dtview()\fP).
+\f5dtclose()\fP returns \f50\fP on success and \f5-1\fP on error.
+See also the events \f5DT_CLOSE\fP and \f5DT_ENDCLOSE\fP below.
+.PP
+.Ss " void dtclear(Dt_t* dt)"
+This deletes all objects in \f5dt\fP without closing \f5dt\fP.
+.PP
+.Ss " Dtmethod_t dtmethod(Dt_t* dt, const Dtmethod_t* meth)"
+If \f5meth\fP is \f5NULL\fP, \f5dtmethod()\fP returns the current method.
+Otherwise, it changes the storage method of \f5dt\fP to \f5meth\fP.
+Object order remains the same during a
+method switch among \f5Dtlist\fP, \f5Dtstack\fP and \f5Dtqueue\fP.
+Switching to and from \f5Dtset/Dtbag\fP and \f5Dtoset/Dtobag\fP may cause
+objects to be rehashed, reordered, or removed as the case requires.
+\f5dtmethod()\fP returns the previous method or \f5NULL\fP on error.
+.PP
+.Ss " Dtdisc_t* dtdisc(Dt_t* dt, const Dtdisc_t* disc, int type)"
+If \f5disc\fP is \f5NULL\fP, \f5dtdisc()\fP returns the current discipline.
+Otherwise, it changes the discipline of \f5dt\fP to \f5disc\fP.
+Objects may be rehashed, reordered, or removed as appropriate.
+\f5type\fP can be any bit combination of \f5DT_SAMECMP\fP and \f5DT_SAMEHASH\fP.
+\f5DT_SAMECMP\fP means that objects will compare exactly the same as before
+thus obviating the need for reordering or removing new duplicates.
+\f5DT_SAMEHASH\fP means that hash values of objects remain the same
+thus obviating the need to rehash.
+\f5dtdisc()\fP returns the previous discipline on success
+and \f5NULL\fP on error.
+.PP
+.Ss " Dt_t* dtview(Dt_t* dt, Dt_t* view)"
+A viewpath allows a search or walk starting from a dictionary to continue to another.
+\f5dtview()\fP first terminates any current view from \f5dt\fP to another dictionary.
+Then, if \f5view\fP is \f5NULL\fP, \f5dtview\fP returns the terminated view dictionary.
+If \f5view\fP is not \f5NULL\fP, a viewpath from \f5dt\fP to \f5view\fP is established.
+\f5dtview()\fP returns \f5dt\fP on success and \f5NULL\fP on error.
+.PP
+If two dictionaries on the same viewpath have the same values for the discipline fields
+\f5Dtdisc_t.link\fP, \f5Dtdisc_t.key\fP, \f5Dtdisc_t.size\fP, and \f5Dtdisc_t.hashf\fP,
+it is expected that key hashing will be the same.
+If not, undefined behaviors may result during a search or a walk.
+.PP
+.Ss " int dttreeset(Dt_t* dt, int minp, int balance)"
+This function only applies to dictionaries operated under the method \f5Dtoset\fP
+which uses top-down splay trees (see below). It returns 0 on success and -1 on error.
+.Tp
+\f5minp\fP:
+This parameter defines the minimum path length before a search path is adjusted.
+For example, \f5minp\fP equal 0 would mean that search paths are always adjusted.
+If \f5minp\fP is negative, the minimum search path is internally computed based
+on a function of the current dictionary size. This computed value is such that
+if the tree is balanced, it will never require adjusting.
+.Tp
+\f5balance\fP:
+If this is non-zero, the tree will be made balanced.
+.PP
+.Ss "STORAGE METHODS"
+.PP
+Storage methods are of type \f5Dtmethod_t*\fP.
+\fICdt\fP supports the following methods:
+.PP
+.Ss " Dtoset"
+.Ss " Dtobag"
+Objects are ordered by comparisons.
+\f5Dtoset\fP keeps unique objects.
+\f5Dtobag\fP allows repeatable objects.
+.PP
+.Ss " Dtset"
+.Ss " Dtbag"
+Objects are unordered.
+\f5Dtset\fP keeps unique objects.
+\f5Dtbag\fP allows repeatable objects and always keeps them together
+(note the effect on dictionary walking.)
+These methods use a hash table with chaining to manage the objects.
+See also the event \f5DT_HASHSIZE\fP below on how to manage hash table
+resizing when objects are inserted.
+.PP
+.Ss " Dtlist"
+Objects are kept in a list.
+New objects are inserted either
+in front of \fIcurrent object\fP (see \f5dtfinger()\fP) if this is defined
+or at list front if there is no current object.
+.PP
+.Ss " Dtstack"
+Objects are kept in a stack, i.e., in reverse order of insertion.
+Thus, the last object inserted is at stack top
+and will be the first to be deleted.
+.PP
+.Ss " Dtqueue"
+Objects are kept in a queue, i.e., in order of insertion.
+Thus, the first object inserted is at queue head
+and will be the first to be deleted.
+.PP
+.Ss "DISCIPLINE"
+.PP
+Object format and associated management functions are
+defined in the type \f5Dtdisc_t\fP:
+.Cs
+ typedef struct
+ { int key, size;
+ int link;
+ Dtmake_f makef;
+ Dtfree_f freef;
+ Dtcompar_f comparf;
+ Dthash_f hashf;
+ Dtmemory_f memoryf;
+ Dtevent_f eventf;
+ } Dtdisc_t;
+.Ce
+.Ss " int key, size"
+Each object \f5obj\fP is identified by a key used for object comparison or hashing.
+\f5key\fP should be non-negative and defines an offset into \f5obj\fP.
+If \f5size\fP is negative, the key is a null-terminated
+string with starting address \f5*(Void_t**)((char*)obj+key)\fP.
+If \f5size\fP is zero, the key is a null-terminated string with starting address
+\f5(Void_t*)((char*)obj+key)\fP.
+Finally, if \f5size\fP is positive, the key is a byte array of length \f5size\fP
+starting at \f5(Void_t*)((char*)obj+key)\fP.
+.PP
+.Ss " int link"
+Let \f5obj\fP be an object to be inserted into \f5dt\fP as discussed below.
+If \f5link\fP is negative, an internally allocated object holder is used
+to hold \f5obj\fP. Otherwise, \f5obj\fP should have
+a \f5Dtlink_t\fP structure embedded \f5link\fP bytes into it,
+i.e., at address \f5(Dtlink_t*)((char*)obj+link)\fP.
+.PP
+.Ss " Void_t* (*makef)(Dt_t* dt, Void_t* obj, Dtdisc_t* disc)"
+If \f5makef\fP is not \f5NULL\fP,
+\f5dtinsert(dt,obj)\fP will call it
+to make a copy of \f5obj\fP suitable for insertion into \f5dt\fP.
+If \f5makef\fP is \f5NULL\fP, \f5obj\fP itself will be inserted into \f5dt\fP.
+.PP
+.Ss " void (*freef)(Dt_t* dt, Void_t* obj, Dtdisc_t* disc)"
+If not \f5NULL\fP,
+\f5freef\fP is used to destroy data associated with \f5obj\fP.
+.PP
+.Ss "int (*comparf)(Dt_t* dt, Void_t* key1, Void_t* key2, Dtdisc_t* disc)"
+If not \f5NULL\fP, \f5comparf\fP is used to compare two keys.
+Its return value should be \f5<0\fP, \f5=0\fP, or \f5>0\fP to indicate
+whether \f5key1\fP is smaller, equal to, or larger than \f5key2\fP.
+All three values are significant for method \f5Dtoset\fP and \f5Dtobag\fP.
+For other methods, a zero value
+indicates equality and a non-zero value indicates inequality.
+If \f5(*comparf)()\fP is \f5NULL\fP, an internal function is used
+to compare the keys as defined by the \f5Dtdisc_t.size\fP field.
+.PP
+.Ss " unsigned int (*hashf)(Dt_t* dt, Void_t* key, Dtdisc_t* disc)"
+If not \f5NULL\fP,
+\f5hashf\fP is used to compute the hash value of \f5key\fP.
+It is required that keys compared equal will also have same hash values.
+If \f5hashf\fP is \f5NULL\fP, an internal function is used to hash
+the key as defined by the \f5Dtdisc_t.size\fP field.
+.PP
+.Ss " Void_t* (*memoryf)(Dt_t* dt, Void_t* addr, size_t size, Dtdisc_t* disc)"
+If not \f5NULL\fP, \f5memoryf\fP is used to allocate and free memory.
+When \f5addr\fP is \f5NULL\fP, a memory segment of size \f5size\fP is requested.
+If \f5addr\fP is not \f5NULL\fP and \f5size\fP is zero, \f5addr\fP is to be freed.
+If \f5addr\fP is not \f5NULL\fP and \f5size\fP is positive,
+\f5addr\fP is to be resized to the given size.
+If \f5memoryf\fP is \f5NULL\fP, \fImalloc(3)\fP is used.
+When dictionaries share memory,
+a record of the first allocated memory segment should be kept
+so that it can be used to initialize other dictionaries (see below.)
+.PP
+.Ss " int (*eventf)(Dt_t* dt, int type, Void_t* data, Dtdisc_t* disc)"
+If not \f5NULL\fP, \f5eventf\fP announces various events.
+Each event may have particular handling of the return values from \f5eventf\fP.
+But a negative return value typically means failure.
+Following are the events:
+.Tp
+\f5DT_OPEN\fP:
+\f5dt\fP is being opened.
+If \f5eventf\fP returns negative, the opening process terminates with failure.
+If \f5eventf\fP returns zero, the opening process proceeds normally.
+A positive return value indicates special treatment of memory as follows.
+If \f5*(Void_t**)data\fP is set to point to some memory segment
+as discussed in \f5memoryf\fP, that segment of memory is used to start
+the dictionary. If \f5*(Void_t**)data\fP is not set, this indicates that
+\f5dtopen()\fP should allocate the dictionary handle itself with
+\f5memoryf\fP so that all memories pertained to the dictionary are allocated
+via this function.
+.Tp
+\f5DT_ENDOPEN\fP:
+This event announces that \f5dtopen()\fP has successfully opened
+a dictionary and is about to return. The \f5data\fP argument of
+\f5eventf\fP should be the new dictionary handle itself.
+.Tp
+\f5DT_CLOSE\fP:
+\f5dt\fP is about to be closed. If \f5eventf\fP returns zero,
+the closing process proceeds normally. This means that all objects
+in the dictionary will be deleted and all associated memories freed.
+If \f5eventf\fP returns a positive value, objects will not be deleted.
+However, the dictionary handle itself will still be deallocated
+unless it was allocated via \f5memoryf\fP during \f5dtopen()\fP.
+This allows shared/persistent memory dictionaries to retain
+the relevant memories across dictionary openings and closings.
+.Tp
+\f5DT_ENDCLOSE\fP:
+This event announces that \f5dtclose()\fP has successfully closed
+a dictionary and is about to return.
+.Tp
+\f5DT_DISC\fP:
+The discipline of \f5dt\fP is being changed to a new one given in
+\f5(Dtdisc_t*)data\fP.
+.Tp
+\f5DT_METH\fP:
+The method of \f5dt\fP is being changed to a new one given in
+\f5(Dtmethod_t*)data\fP.
+.Tp
+\f5DT_HASHSIZE\fP:
+The hash table (for \f5Dtset\fP and \f5Dtbag\fP) is being resized.
+In this case, \f5*(int*)data\fP has the current size of the table.
+The application can set the new table size by first changing
+\f5*(int*)data\fP to the desired size, then return a positive value.
+The application can also fix the table size at the current value
+forever by setting \f5*(int*)data\fP to a negative value, then
+again return a positive value. A non-positive return value from
+the event handling function means that Cdt will be responsible
+for choosing the hash table size.
+.PP
+.Ss "#define DTOFFSET(struct_s,member)"
+This macro function computes the offset of \f5member\fP from the start
+of structure \f5struct_s\fP. It is useful for getting the offset of
+a \f5Dtlink_t\fP embedded inside an object.
+.PP
+.Ss "#define DTDISC(disc,key,size,link,makef,freef,comparf,hashf,memoryf,eventf)"
+This macro function initializes the discipline pointed to by \f5disc\fP
+with the given values.
+.PP
+.Ss "OBJECT OPERATIONS"
+.PP
+.Ss " Void_t* dtinsert(Dt_t* dt, Void_t* obj)"
+This inserts an object prototyped by \f5obj\fP into \f5dt\fP.
+If there is an existing object in \f5dt\fP matching \f5obj\fP
+and the storage method is \f5Dtset\fP or \f5Dtoset\fP,
+\f5dtinsert()\fP will simply return the matching object.
+Otherwise, a new object is inserted according to the method in use.
+See \f5Dtdisc_t.makef\fP for object construction.
+\f5dtinsert()\fP returns the new object, a matching object as noted,
+or \f5NULL\fP on error.
+.PP
+.Ss " Void_t* dtdelete(Dt_t* dt, Void_t* obj)"
+If \f5obj\fP is \f5NULL\fP, methods \f5Dtstack\fP and \f5Dtqueue\fP
+delete respectively stack top or queue head while other methods do nothing.
+If \f5obj\fP is not \f5NULL\fP, there are two cases.
+If the method in use is not \f5Dtbag\fP or \f5Dtobag\fP,
+the first object matching \f5obj\fP is deleted.
+On the other hand, if the method in use is \f5Dtbag\fP or \f5Dtobag\fP,
+the library check to see if \f5obj\fP is in the dictionary and delete it.
+If \f5obj\fP is not in the dictionary, some object matching it will be deleted.
+See \f5Dtdisc_t.freef\fP for object destruction.
+\f5dtdelete()\fP returns the deleted object (even if it was deallocated)
+or \f5NULL\fP on error.
+.PP
+.Ss " Void_t* dtattach(Dt_t* dt, Void_t* obj)"
+This function is similar to \f5dtinsert()\fP but \f5obj\fP itself
+will be inserted into \f5dt\fP even if a discipline
+function \f5makef\fP is defined.
+.PP
+.Ss " Void_t* dtdetach(Dt_t* dt, Void_t* obj)"
+This function is similar to \f5dtdelete()\fP but the object to be deleted
+from \f5dt\fP will not be freed (via the discipline \f5freef\fP function).
+.PP
+.Ss " Void_t* dtsearch(Dt_t* dt, Void_t* obj)"
+.Ss " Void_t* dtmatch(Dt_t* dt, Void_t* key)"
+These functions find an object matching \f5obj\fP or \f5key\fP either from \f5dt\fP or
+from some dictionary accessible from \f5dt\fP via a viewpath (see \f5dtview()\fP.)
+\f5dtsearch()\fP and \f5dtmatch()\fP return the matching object or
+\f5NULL\fP on failure.
+.PP
+.Ss " Void_t* dtfirst(Dt_t* dt)"
+.Ss " Void_t* dtnext(Dt_t* dt, Void_t* obj)"
+\f5dtfirst()\fP returns the first object in \f5dt\fP.
+\f5dtnext()\fP returns the object following \f5obj\fP.
+Objects are ordered based on the storage method in use.
+For \f5Dtoset\fP and \f5Dtobag\fP, objects are ordered by object comparisons.
+For \f5Dtstack\fP, objects are ordered in reverse order of insertion.
+For \f5Dtqueue\fP, objects are ordered in order of insertion.
+For \f5Dtlist\fP, objects are ordered by list position.
+For \f5Dtset\fP and \f5Dtbag\fP,
+objects are ordered by some internal order (more below).
+Thus, objects in a dictionary or a viewpath can be walked using
+a \f5for(;;)\fP loop as below.
+.Cs
+ for(obj = dtfirst(dt); obj; obj = dtnext(dt,obj))
+.Ce
+When a dictionary uses \f5Dtset\fP or \f5Dtbag\fP,
+the object order is determined upon a call to \f5dtfirst()\fP/\f5dtlast()\fP.
+This order is frozen until a call \f5dtnext()\fP/\f5dtprev()\fP returns \f5NULL\fP
+or when these same functions are called with a \f5NULL\fP object argument.
+It is important that a \f5dtfirst()/dtlast()\fP call be
+balanced by a \f5dtnext()/dtprev()\fP call as described.
+Nested loops will require multiple balancing, once per loop.
+If loop balancing is not done carefully, either performance is degraded
+or unexpected behaviors may result.
+.Ss " Void_t* dtlast(Dt_t* dt)"
+.Ss " Void_t* dtprev(Dt_t* dt, Void_t* obj)"
+\f5dtlast()\fP and \f5dtprev()\fP are like \f5dtfirst()\fP and \f5dtnext()\fP
+but work in reverse order.
+Note that dictionaries on a viewpath are still walked in order
+but objects in each dictionary are walked in reverse order.
+.PP
+.Ss " Void_t* dtfinger(Dt_t* dt)"
+This function returns the \fIcurrent object\fP of \f5dt\fP, if any.
+The current object is defined after a successful call to one of
+\f5dtsearch()\fP, \f5dtmatch()\fP, \f5dtinsert()\fP,
+\f5dtfirst()\fP, \f5dtnext()\fP, \f5dtlast()\fP, or \f5dtprev()\fP.
+As a side effect of this implementation of \fICdt\fP,
+when a dictionary is based on \f5Dtoset\fP and \f5Dtobag\fP,
+the current object is always defined and is the root of the tree.
+.PP
+.Ss " Void_t* dtrenew(Dt_t* dt, Void_t* obj)"
+This function repositions and perhaps rehashes
+an object \f5obj\fP after its key has been changed.
+\f5dtrenew()\fP only works if \f5obj\fP is the current object (see \f5dtfinger()\fP).
+.PP
+.Ss " dtwalk(Dt_t* dt, int (*userf)(Dt_t*, Void_t*, Void_t*), Void_t* data)"
+This function calls \f5(*userf)(walk,obj,data)\fP on each object in \f5dt\fP and
+other dictionaries viewable from it.
+\f5walk\fP is the dictionary containing \f5obj\fP.
+If \f5userf()\fP returns a \f5<0\fP value,
+\f5dtwalk()\fP terminates and returns the same value.
+\f5dtwalk()\fP returns \f50\fP on completion.
+.PP
+.Ss " Dtlink_t* dtflatten(Dt_t* dt)"
+.Ss " Dtlink_t* dtlink(Dt_t* dt, Dtlink_t* link)"
+.Ss " Void_t* dtobj(Dt_t* dt, Dtlink_t* link)"
+Using \f5dtfirst()/dtnext()\fP or \f5dtlast()/dtprev()\fP
+to walk a single dictionary can incur significant cost due to function calls.
+For efficient walking of a single directory (i.e., no viewpathing),
+\f5dtflatten()\fP and \f5dtlink()\fP can be used.
+Objects in \f5dt\fP are made into a linked list and walked as follows:
+.Cs
+ for(link = dtflatten(dt); link; link = dtlink(dt,link) )
+.Ce
+.PP
+Note that \f5dtflatten()\fP returns a list of type \f5Dtlink_t*\fP,
+not \f5Void_t*\fP. That is, it returns a dictionary holder pointer,
+not a user object pointer
+(although both are the same if the discipline field \f5link\fP is zero.)
+The macro function \f5dtlink()\fP
+returns the dictionary holder object following \f5link\fP.
+The macro function \f5dtobj(dt,link)\fP
+returns the user object associated with \f5link\fP,
+Beware that the flattened object list is unflattened on any
+dictionary operations other than \f5dtlink()\fP.
+.PP
+.Ss " Dtlink_t* dtextract(Dt_t* dt)"
+.Ss " int dtrestore(Dt_t* dt, Dtlink_t* link)"
+\f5dtextract()\fP extracts all objects from \f5dt\fP and makes it appear empty.
+\f5dtrestore()\fP repopulates \f5dt\fP with
+objects previously obtained via \f5dtextract()\fP.
+\f5dtrestore()\fP will fail if \f5dt\fP is not empty.
+These functions can be used
+to share a same \f5dt\fP handle among many sets of objects.
+They are useful to reduce dictionary overhead
+in an application that creates many concurrent dictionaries.
+It is important that the same discipline and method are in use at both
+extraction and restoration. Otherwise, undefined behaviors may result.
+.PP
+.Ss " #define DTTREESEARCH(Dt_t* dt, Void_t* obj, action)"
+.Ss " #define DTTREEMATCH(Dt_t* dt, Void_t* key, action)"
+These macro functions are analogues of \f5dtsearch()\fP and \f5dtmatch()\fP
+but they can only be used on a dictionary based on a binary
+search tree, i.e., \f5Dtoset\fP or \f5Dtobag\fP.
+.Tp
+\f5obj\fP or \f5key\fP:
+These are used to find a matching object. If there is no match,
+the result is \f5NULL\fP.
+.Tp
+\f5action\fP:
+The matching object \f5o\fP (which may be \f5NULL\fP) will be processed as follow:
+
+.Cs
+ action (o);
+.Ce
+
+Since \f5action\fP is used verbatim, it can be any C code
+fragment combinable with \f5(o)\fP to form a syntactically correct C statement.
+For example, suppose that the matching object is an integer, the below code
+accumulates the integer value in a variable \f5total\fP:
+
+.Cs
+ DTTREEMATCH(dt, key, total += (int));
+.Ce
+
+.PP
+.Ss "DICTIONARY INFORMATION"
+.PP
+.Ss " Dt_t* dtvnext(Dt_t* dt)"
+This returns the dictionary that \f5dt\fP is viewing, if any.
+.Ss " int dtvcount(Dt_t* dt)"
+This returns the number of dictionaries that view \f5dt\fP.
+.Ss " Dt_t* dtvhere(Dt_t* dt)"
+This returns the dictionary \f5v\fP viewable from \f5dt\fP
+where an object was found from the most recent search or walk operation.
+.Ss " int dtsize(Dt_t* dt)"
+This function returns the number of objects stored in \f5dt\fP.
+.PP
+.Ss " int dtstat(Dt_t *dt, Dtstat_t* st, int all)"
+This function reports dictionary statistics.
+If \f5all\fP is non-zero, all fields of \f5st\fP are filled.
+Otherwise, only the \f5dt_type\fP and \f5dt_size\fP fields are filled.
+It returns \f50\fP on success and \f5-1\fP on error.
+.PP
+\f5Dtstat_t\fP contains the below fields:
+.Tp
+\f5int dt_type\fP:
+This is one of \f5DT_SET\fP, \f5DT_BAG\fP, \f5DT_OSET\fP, \f5DT_OBAG\fP,
+\f5DT_LIST\fP, \f5DT_STACK\fP, and \f5DT_QUEUE\fP.
+.Tp
+\f5int dt_size\fP:
+This contains the number of objects in the dictionary.
+.Tp
+\f5int dt_n\fP:
+For \f5Dtset\fP and \f5Dtbag\fP,
+this is the number of non-empty chains in the hash table.
+For \f5Dtoset\fP and \f5Dtobag\fP,
+this is the deepest level in the tree (counting from zero.)
+Each level in the tree contains all nodes of equal distance from the root node.
+\f5dt_n\fP and the below two fields are undefined for other methods.
+.Tp
+\f5int dt_max\fP:
+For \f5Dtbag\fP and \f5Dtset\fP, this is the size of a largest chain.
+For \f5Dtoset\fP and \f5Dtobag\fP, this is the size of a largest level.
+.Tp
+\f5int* dt_count\fP:
+For \f5Dtset\fP and \f5Dtbag\fP,
+this is the list of counts for chains of particular sizes.
+For example, \f5dt_count[1]\fP is the number of chains of size \f51\fP.
+For \f5Dtoset\fP and \f5Dtobag\fP, this is the list of sizes of the levels.
+For example, \f5dt_count[1]\fP is the size of level \f51\fP.
+.PP
+.Ss "HASH FUNCTIONS"
+.PP
+.Ss " unsigned int dtcharhash(unsigned int h, char c)"
+.Ss " unsigned int dtstrhash(unsigned int h, char* str, int n)"
+These functions compute hash values from bytes or strings.
+\f5dtcharhash()\fP computes a new hash value from byte \f5c\fP and seed value \f5h\fP.
+\f5dtstrhash()\fP computes a new hash value from string \f5str\fP and seed value \f5h\fP.
+If \f5n\fP is positive, \f5str\fP is a byte array of length \f5n\fP;
+otherwise, \f5str\fP is a null-terminated string.
+.PP
+.SH IMPLEMENTATION NOTES
+\f5Dtset\fP and \f5Dtbag\fP are based on hash tables with
+move-to-front collision chains.
+\f5Dtoset\fP and \f5Dtobag\fP are based on top-down splay trees.
+\f5Dtlist\fP, \f5Dtstack\fP and \f5Dtqueue\fP are based on doubly linked list.
+.PP
+.SH AUTHOR
+Kiem-Phong Vo, kpv@research.att.com
diff --git a/usr/src/lib/libast/common/man/chr.3 b/usr/src/lib/libast/common/man/chr.3
new file mode 100644
index 0000000000..91683ed358
--- /dev/null
+++ b/usr/src/lib/libast/common/man/chr.3
@@ -0,0 +1,126 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH CHR 3
+.SH NAME
+chr \- character constant conversion routines
+.SH SYNOPSIS
+.EX
+#include <ast.h>
+
+int chresc(const char* \fIs\fP, char** \fIe\fP);
+int chrtoi(const char* \fIs\fP);
+.EE
+.SH DESCRIPTION
+.L chresc
+converts and returns the next character constant in the 0-terminated string
+.IR s .
+If
+.I e
+is not 0 then
+.I *e
+is set to point to the next character in
+.I s
+on return.
+0 is returned and
+.I e
+is not modified when the end of
+.I s
+is reached.
+.PP
+.L chrtoi
+converts the 0-terminated string
+.I s
+to an
+.I int
+and returns the value.
+The characters in
+.I s
+are converted in order from the left and shifted into the
+.I int
+value until up to the number of characters in an
+.I int
+is reached.
+This operation is inherently machine-dependent,
+but at least its defined in one place.
+.PP
+The following
+.B \e
+escape sequences are recognized:
+.TP
+.LI \e ooo
+The character represented by the octal code
+.IR ooo .
+.TP
+.LI \ex xx
+The character represented by the hex code
+.IR xx .
+.TP
+.L \ea
+Alert (bell).
+.TP
+.L \eb
+Backspace.
+.TP
+.L \ef
+Formfeed.
+.TP
+.L \en
+Newline.
+.TP
+.L \er
+Carriage return.
+.TP
+.L \et
+Horizontal tab.
+.TP
+.L \ev
+Vertical tab.
+.TP
+.L \eE
+ESC (escape).
+.TP
+.L \e\e
+Backslash.
+.PP
+Other characters following
+.B \e
+are undefined (although for backwards compatibility they
+translate to themselves).
+.SH "SEE ALSO"
+str(3)
diff --git a/usr/src/lib/libast/common/man/compat.3 b/usr/src/lib/libast/common/man/compat.3
new file mode 100644
index 0000000000..eb5e8a7b21
--- /dev/null
+++ b/usr/src/lib/libast/common/man/compat.3
@@ -0,0 +1,103 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH COMPATIBILITY 3
+.SH NAME
+compatibility \- ast library compatibility routines
+.SH SYNOPSIS
+.EX
+#include <ast.h>
+
+int atexit(void(*)(void));
+char* confstr(int);
+int dup2(int, int);
+long fpathconf(int, int);
+int getgroups(int, int*);
+char* getwd(char*);
+int killpg(int, int);
+int link(const char*, const char*);
+int lstat(const char*, struct stat*);
+int memcmp(const char*, const char*, unsigned int);
+char* memcpy(char*, const char*, int);
+char* memset(char*, char, int);
+int mkdir(const char*, mode_t);
+int mkfifo(const char*, mode_t);
+int mknod(const char*, mode_t);
+char* mktemp(char*);
+int mount(const char*, const char*, int);
+long pathconf(const char*, int);
+int perror(const char*);
+FILE* popen(const char*, const char*);
+int readlink(const char*, char*, int);
+int remove(const char*);
+int rename(const char*, const char*);
+int rmdir(const char*);
+int setpgid(pid_t, pid_t);
+int sigmask(int);
+int sigsetmask(long);
+int sigunblock(int);
+char* strchr(const char*, int);
+char* strrchr(const char*, int);
+double strtod(const char*, char**);
+long strtol(const char*, char**, int);
+int symlink(const char*, const char*);
+long sysconf(int);
+int system(const char*);
+char* tmpnam(char*);
+int unlink(const char*);
+int vfork(void);
+int waitpid(pid_t, int*, int);
+.EE
+.SH DESCRIPTION
+These routines are described in the ANSI C, POSIX, BSD and System V manual
+sections 2 and 3.
+The interfaces are preserved and present in all libast implementations.
+Where conflicts exist the POSIX syntax and semantics are implied.
+The appropriate error value is returned and
+.I errno
+is set to
+.L EINVAL
+when emulation is either too expensive or not possible.
+.SH CAVEATS
+If you
+.L "#undef foo"
+and then call
+.L foo
+you may end up with the local implementation of
+.LR foo ,
+and then you get what you payed for.
diff --git a/usr/src/lib/libast/common/man/error.3 b/usr/src/lib/libast/common/man/error.3
new file mode 100644
index 0000000000..df47d342ba
--- /dev/null
+++ b/usr/src/lib/libast/common/man/error.3
@@ -0,0 +1,283 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH ERROR 3
+.SH NAME
+error \- error and debug trace message formatter
+.SH SYNOPSIS
+.EX
+#include <error.h>
+
+Error_info_t error_info;
+
+void error(int \fIlevel\fP, ...);
+void errorv(const char* \fIlibrary\fP, int \fIlevel\fP, va_alist \fIargs\fP);
+void liberror(const char* \fIlibrary\fP, int \fIlevel\fP, ...);
+
+#include <debug.h>
+
+debug(\fIstatement\fP)
+message((int \fIlevel\fP, ...))
+libmessage((const char* \fIlibrary\fI, int \fIlevel\fP, ...))
+.EE
+.SH DESCRIPTION
+.L error
+is the error and debug trace message formatter.
+.I level
+is the severity level.
+Messages with
+.I "level < error_info.trace"
+are suppressed.
+.I error_info.trace
+is initially
+.LR 0 .
+The remaining arguments are passed on to
+.LR printf .
+A
+.I newline
+is appended to the message text, so none should appear in the
+.L printf
+format.
+If
+.I error_info.id
+is not
+.L 0
+then messages with
+.I "level > 0"
+are prefixed by
+.IR error_info.id: .
+.PP
+Before the message text is output to standard error
+it is passed to the function
+.LR "char* ERROR_translate(const char* \fItext\fP, int \fIflag\fP)" .
+By default
+.L ERROR_translate
+returns the
+.L text
+argument, but on some systems it may do language translation via lookup
+on the original source text.
+.RL ( error
+calls
+.L ERROR_translate
+with a 0
+.L flag
+argument).
+.PP
+.I level
+may be one of:
+.TP
+.B <0
+Negative values are for debug tracing.
+Debug messages are prefixed with
+.BI debug level.
+If
+.I "errno != error_info.last_errno"
+then
+.I error_info.last_errno
+is set to
+.I errno
+and the error text for errno is appended to the message.
+.TP
+.B "ERROR_INFO [0]"
+Information only; no prefixes are added to the message.
+.TP
+.B "ERROR_WARNING [1]"
+.L "warning:"
+is added after
+.L error_info.id
+and
+.I error_info.warnings
+is incremented.
+.TP
+.I "ERROR_ERROR [2]"
+(soft error)
+.I error_info.errors
+is incremented.
+.TP
+.B ">= ERROR_FATAL [3]"
+(hard error)
+.I error_info.errors
+is incremented and
+.L exit(\fIlevel\fP\-2)
+is called after the message is emitted.
+.TP
+.B "ERROR_PANIC [77]"
+(unrecoverable internal error)
+.L "panic:"
+is added after
+.IR error_info.id .
+.PP
+The following may be inclusive-or'd into
+.I level
+for alternate behavior:
+.TP
+.L ERROR_SYSTEM
+The error text for
+.I errno
+is appended to the message.
+.TP
+.L ERROR_OUTPUT
+The next argument is the file descriptor where the error message
+should be emitted.
+.TP
+.L ERROR_SOURCE
+Then next two arguments are a file name and line number that are added
+to the message after
+.IR error_info.id .
+.TP
+.L ERROR_USAGE
+A usage message is emitted.
+.TP
+.L ERROR_PROMPT
+The trailing
+.I newline
+is suppressed.
+.TP
+.L ERROR_NOID
+The
+.I error_info.id
+prefix is suppressed.
+.TP
+.L ERROR_LIBRARY
+The message is from a library routine.
+.SH ENVIRONMENT
+The elements of the global struct
+.I error_info
+control error output and actions.
+Parts of
+.I error_info
+can be initialized from the
+.L ERROR_OPTIONS
+environment variable.
+.L ERROR_OPTIONS
+contains space separated
+.IR name [ =value ]
+options, described below.
+.TP
+.I "int core"
+If
+.I "error_info.core != 0"
+then
+.I "level >= error_info.core"
+generates a core dump.
+Initialized by
+.EX
+ERROR_OPTIONS="core=\fIlevel\fP"
+.EE
+where
+.I level
+can be a number or one of
+.LR error ,
+.LR fatal ,
+or
+.LR panic .
+.I error_info.core
+is a handy way to get a stack trace at the exact point of error.
+.TP
+.I "int error_info.trace"
+If
+.I "error_info.trace != 0"
+and
+.I "level < error_info.trace"
+then the error message text is suppressed.
+.L exit()
+may still be called if appropriate for
+.IR level .
+Initialized by
+.EX
+ERROR_OPTIONS="trace=\fIlevel\fP"
+.EE
+where
+.I error_info.trace
+is set to the negative of
+.IR level .
+.PP
+Library error messages, suppressed by default, are enabled by
+.EX
+ERROR_OPTIONS="library"
+.EE
+The system
+.I errno
+message text can be forced for each message by
+.EX
+ERROR_OPTIONS="system"
+.EE
+.SH "EXTENDED DESCRIPTION"
+.L "<debug.h>"
+provides debugging message macros when
+.L DEBUG
+or
+.L _TRACE_
+are defined
+.RL ( _TRACE_
+is defined by
+.I makerules
+when
+.L CCFLAGS
+contains
+.LR \-g ).
+All of the macros expand to nothing when both
+.L DEBUG
+and
+.L _TRACE_
+are not defined.
+Otherwise
+.L debug
+expands its arg and
+.L libmessage
+and
+.L message
+call
+.L liberror
+and
+.L error
+respectively if
+.IR "error_info.trace<0" .
+Notice that
+.L libmessage
+and
+.L message
+are macro hacks that require double parentheses ((...)) around the
+arguments.
+.SH EXAMPLE
+To enable debugging message level -3, library messages, and system
+.I errno
+text for all commands:
+.EX
+export ERROR_OPTIONS="trace=3 library system"
+.EE
diff --git a/usr/src/lib/libast/common/man/find.3 b/usr/src/lib/libast/common/man/find.3
new file mode 100644
index 0000000000..a14ceaee0f
--- /dev/null
+++ b/usr/src/lib/libast/common/man/find.3
@@ -0,0 +1,89 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH FIND 3
+.SH NAME
+find \- fastfind algorithm interface
+.SH SYNOPSIS
+.EX
+#include <find.h>
+
+void* findopen(const char* \fIpattern\fP);
+char* findnext(void* \fIhandle\fP);
+void findclose(void* \fIhandle\fP);
+.EE
+.SH DESCRIPTION
+These routines access the data generated by the
+.I fastfind
+algorithm.
+The data itself is generated by a standalone program that is run daily
+via
+.I cron
+or
+.IR at .
+.PP
+.L findopen
+returns a handle to a
+.I fastfind
+stream for the
+.I ksh
+file pattern
+.IR pattern .
+.L findnext
+returns the next pathname that matches the pattern specified by
+.IR handle .
+.L findnext
+returns
+.L 0
+when no more pathnames match the pattern.
+Finally,
+.L findclose
+closes the
+.I fastfind
+stream for
+.IR handle .
+.SH BUGS
+These rotuines are only as good as the
+.I fastfind
+information which is in the system administration domain.
+.SH "SEE ALSO"
+tw(1),
+find(1),
+strmatch(3)
+.br
+James A. Woods, \fIFast Find Algorithm\fP, Usenix ;login:, February/March, 1983, p. 8
diff --git a/usr/src/lib/libast/common/man/fmt.3 b/usr/src/lib/libast/common/man/fmt.3
new file mode 100644
index 0000000000..b71772fc92
--- /dev/null
+++ b/usr/src/lib/libast/common/man/fmt.3
@@ -0,0 +1,210 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH FMT 3
+.SH NAME
+fmt \- string formatting routines
+.SH SYNOPSIS
+#include <ast.h>
+#include <ls.h>
+
+char* fmtbase(long \fInumber\fP, int \fIbase\fP, int \fIprefix\fP);
+char* fmtdev(struct stat* \fIst\fP);
+char* fmtelapsed(unsigned long \fIcount\fP, int \fIpersec\fP)
+char* fmterror(int \fIerrno\fP);
+char* fmtesc(const char* \fIstring\fP);
+char* fmtfs(struct stat* \fIst\fP);
+char* fmtgid(int \fIgid\fP);
+char* fmtmatch(const char* \fIre\fP);
+char* fmtmode(int \fImode\fP, int \fIexternal\fP);
+char* fmtperm(int \fIperm\fP);
+char* fmtre(const char* \fIpattern\fP);
+char* fmtsignal(int \fIsig\fP);
+char* fmttime(const char* \fIformat\fP, time_t \fItm\fP);
+char* fmtuid(int \fIuid\fP);
+.EE
+.SH DESCRIPTION
+These routines return a pointer to a formatted string for various numeric
+and string entities.
+Some routines may cache information to speed up the next call.
+Most of the routines return a pointer to a private buffer, the
+contents of which are overwritten on the next call to that routine.
+Most
+.L fmt
+routines have a corresponding
+.L str
+routine that converts in the other direction.
+There is nothing spectacular about this collection other than that
+it provides a single place where the exact format is spelled out.
+.PP
+.L fmtbase
+formats a base
+.I base
+representation for
+.IR number .
+If
+.I "prefix != 0"
+then the base prefix is included in the formatted string.
+If
+.I "number == 0"
+or
+.I "base == 0"
+then the output is signed base 10.
+.PP
+.L fmtdev
+returns the device handle name specified by the
+.L stat
+structure
+.IR st .
+This is the device information displayed by
+.IR "ls \-l" .
+.PP
+.L fmtelapsed
+formats the elapsed time for
+.I (count/persec)
+seconds.
+The two largest time units are used, limiting the return value length
+to at most 6 characters.
+The units are:
+.TP
+.B s
+seconds
+.TP
+.B m
+minutes
+.TP
+.B h
+hours
+.TP
+.B days
+.TP
+.B weeks
+.TP
+.B M
+months
+.TP
+.B Y
+years
+.TP
+.B S
+scores
+.PP
+.L fmterror
+returns the system error message text for the error number
+.IR errno .
+.PP
+.L fmtesc
+formats non-ASCII characters in
+.I string
+into C-style
+.B \e
+sequences.
+These sequences are understood by
+.L chresc
+and
+.LR chrtoi .
+.PP
+.L fmtfs
+returns the file system type name corresponding to the
+.L stat
+structure
+.IR st .
+.PP
+.L fmtgid
+returns the group name for
+.IR gid .
+.PP
+.L fmtmatch
+returns the
+.L strmatch
+equivalent pattern for the regular expression pattern
+.IR re .
+0 is returned for invalid
+.IR re .
+.PP
+.L fmtmode
+returns the
+.I "ls \-l"
+mode string for the file mode bits in
+.IR mode .
+If
+.I "external != 0"
+then
+.I mode
+is
+.IR modecanon (3)
+canonical.
+.PP
+.L fmtperm
+returns the
+.I chmod
+permission string for the permission bits in
+.IR perm .
+.PP
+.L fmtre
+returns the regular expression
+equivalent pattern for the
+.L strmatch
+pattern
+.IR pattern .
+0 is returned for invalid
+.IR pattern .
+.PP
+.L fmtsignal
+returns the signal name, sans
+.LR SIG ,
+for the signal number
+.IR sig .
+If
+.I "sig < 0"
+then the description text for
+.I \-sig
+is returned.
+.PP
+.L fmttime
+returns the results of
+.I "tmfmt(buf,sizeof(buf),format,tm)"
+in the private buffer
+.IR buf .
+.PP
+.L fmtuid
+returns the user name for
+.IR uid .
+.SH "SEE ALSO"
+modecanon(3),
+str(3)
diff --git a/usr/src/lib/libast/common/man/fmtls.3 b/usr/src/lib/libast/common/man/fmtls.3
new file mode 100644
index 0000000000..7d3c099e17
--- /dev/null
+++ b/usr/src/lib/libast/common/man/fmtls.3
@@ -0,0 +1,144 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH STRLS 3
+.SH NAME
+fmtls \- format file information in buffer
+.SH SYNOPSIS
+.EX
+#include <ls.h>
+
+char* fmtls(char* \fIbuf\fP, char* \fIname\fP, struct stat* \fIst\fP,
+ char* \fIinfo\fP, char* \fIlink\fP, int \fIflags\fP);
+.EE
+.SH DESCRIPTION
+.L fmtls
+formats
+.IR ls (1)
+style file information into the buffer
+.IR buf .
+A pointer to the trailing 0 in
+.I buf
+is returned.
+.I name
+is the file name.
+.I st
+is a pointer to the
+.B "struct stat
+status information for
+.I name
+obtained from one of the
+.IR stat (2)
+routines.
+.I info
+is an additional string that will appear before
+.I name
+in
+.I buf
+and
+.I link
+is the name of the related hard or soft link file.
+Both
+.I info
+and
+.I link
+may be 0.
+.I flags
+controls the format style and may be a combination of the following:
+.PP
+.TP
+.B LS_ATIME
+Use
+.I st->st_atime
+rather than
+.I st->st_mtime
+for
+.BR LS_LONG .
+.TP
+.B LS_CTIME
+Use
+.I st->st_mtime
+rather than
+.I st->st_mtime
+for
+.BR LS_LONG .
+.TP
+.B LS_BLOCKS
+List the number of blocks.
+.TP
+.B LS_INUMBER
+List the file serial number (inode number).
+.TP
+.B LS_LONG
+List the file mode, link count, user and group name,
+size or major/minor device number, and date along with the
+file name.
+.TP
+.B LS_MARK
+The file name is appended with
+.L /
+for directories,
+.L @
+for symbolic links,
+and
+.L *
+for executable files.
+.TP
+.B LS_NOGROUP
+Omit the group name from
+.BR LS_LONG .
+.TP
+.B LS_NOUSER
+Omit the user name from
+.BR LS_LONG .
+.PP
+The user and group fields are each
+.B LS_W_NAME
+characters wide,
+the
+.B LS_INUMBER
+field is
+.B LS_W_INUMBER
+characters wide,
+and the
+.B LS_BLOCKS
+field is
+.B LS_W_BLOCKS
+characters wide.
+.SH "SEE ALSO"
+ls(1), stat(2), strmode(3)
diff --git a/usr/src/lib/libast/common/man/fs3d.3 b/usr/src/lib/libast/common/man/fs3d.3
new file mode 100644
index 0000000000..7dfd448e5e
--- /dev/null
+++ b/usr/src/lib/libast/common/man/fs3d.3
@@ -0,0 +1,92 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH FS3D 3
+.SH NAME
+fs3d \- 3D (nDFS) on/off switch
+.SH SYNOPSIS
+.EX
+#include <fs3d.h>
+
+int fs3d(int \fIop\fP);
+.EE
+.SH DESCRIPTION
+.L fs3d
+controls and queries the
+.B 3D
+file system
+.RB (aka nDFS )
+enable state.
+.L 0
+is returned if the current process cannot mount
+.B 3D
+files.
+.I op
+may be one of:
+.TP
+.B FS3D_TEST
+Returns
+.L "FS3D_ON [1]"
+if
+.B 3D
+is enabled,
+.L "FS3D_OFF [0]"
+otherwise.
+.TP
+.B FS3D_ON
+Enables
+.B 3D
+and returns the previous
+.L 3D
+state (either
+.B FS3D_ON
+or
+.BR FS3D_OFF ).
+.TP
+\fBFS3D_LIMIT(\fIlimit\fB)\fR
+Sets the viewpath level limit to
+.IR limit .
+The previous limit is returned.
+.TP
+.B FS3D_INIT
+Re-initialize the
+.B 3D
+tables.
+Used for debugging.
+.SH "SEE ALSO"
+3D(1)
diff --git a/usr/src/lib/libast/common/man/ftwalk.3 b/usr/src/lib/libast/common/man/ftwalk.3
new file mode 100644
index 0000000000..f339ab71a0
--- /dev/null
+++ b/usr/src/lib/libast/common/man/ftwalk.3
@@ -0,0 +1,235 @@
+.fp 5 CW
+.TH FTWALK 3
+.SH NAME
+\fBftwalk\fR \- file tree walker
+.SH SYNOPSIS
+.ta .75i 1.5i 2.25i 3i 3.75i 4.5i 5.25i 6i
+.PP
+.nf
+\f5
+#include <ftwalk.h>
+
+int ftwalk(char* path, int (*userf)(struct FTW* ftw), int options,
+ int (*comparf)(struct FTW* ftw1, struct FTW* ftw2));
+
+
+int ftwflags(void);
+\fR
+.fi
+.SH DESCRIPTION
+.PP
+\fIFtwalk\fR traverses a directory hierarchy using depth-first search.
+Upon visiting each file or directory in the hierarchy, it calls
+the user function \fIuserf\fP to process that file or directory.
+On a directory object, \fIuserf\fR may be called twice, once in preorder
+and once in postorder.
+On a terminal object such as a file or an unreadable directory,
+\fIuserf\fP is called only once.
+Cycles due to hard links or symbolic links are detected
+to avoid infinite loops.
+.PP
+\fIPath\fR is the starting point of the search.
+It may be an absolute path name or a path name relative to
+the current directory.
+If \fIpath\fR is a null pointer or points to an empty string, it is treated
+as if it points to the current (dot) directory.
+.PP
+\fIOptions\fR consists of zero or more of the following bits:
+.IP
+FTW_CHILDREN:
+This implies preorder calls to \fIuserf\fR on directory objects.
+On such a call to \fIuserf\fR,
+the field \fIftw->link\fR (below) points to a link list of
+the children of the respective directory.
+Upon returning from \fIuserf\fP,
+if the field \fIftw->status\fR of any child object
+is set to FTW_SKIP (below), that child is pruned from the search.
+.IP
+FTW_DELAY: When \fBFTW_CHILDREN\fP is turned on,
+the fields \fIftw->statb\fP (\fIstruct stat\fP) of children objects
+remain undefined until these objects are visited.
+.IP
+FTW_DOT: Do not use \fIchdir\fR(2) during the traversal.
+Normally \fIchdir\fR is used so that
+the base name of the object about to be processed can be used
+in accessing its data.
+This can enhance \fIftwalk\fR efficiency but certain program effects
+such as core dumps may be generated in unexpected places
+or may not even be generated at all.
+Whenever \fIchdir\fR generates an error, if possible,
+the current directory is restored to the starting directory
+(see FTW_NAME and FTW_PATH).
+.IP
+FTW_MULTIPLE: The \fIpath\fP argument is treated as a \fIchar**\fP
+pointer to a null-terminated array of path names.
+All hierarchies rooted at these paths will be searched
+.IP
+FTW_POST: Calls to the user function are issued only in postorder.
+That is, \fIuserf\fP is called on a directory only after its descendants have
+been processed.
+The absence of this bit indicates that calls to the user functions
+are issued in preorder. That is, \fIuserf\fP is
+called on a directory before its descendants are processed.
+.IP
+FTW_PHYSICAL: Use \fIlstat\fR(2) instead of \fIstat\fR(2) to get
+file status and allow detection of symbolic links.
+In addition, if each component
+of the absolute path to the starting object has search permission,
+the absolute path is used for early detection of cycles.
+.IP
+FTW_META|FTW_PHYSICAL: Use \fIstat\fR(2) for top level file status and
+\fIlstat\fR(2) for all other files.
+Used to implement the POSIX
+.B \-H
+option for commands like
+.IR ls .
+.IP
+FTW_TWICE: Calls to the user function are issued in both preorder and postorder
+for directory objects.
+.IP
+FTW_USER: The first of 6 user defined option bits.
+These bits are ignored by \fIftwalk\fP.
+.PP
+\fIUserf\fR is a user supplied function that is
+called upon different visits of an object.
+If the return value of \fIuserf\fR is non-zero,
+\fIftwalk\fR returns immediately with the same value.
+The \fIuserf\fP prototype is:
+.PP
+.nf
+ int userf(struct FTW* ftw)
+.fi
+.PP
+\fBstruct FTW\fP contains at least the following elements:
+.PP
+.nf
+ struct FTW* link; /* link list of children */
+ struct FTW* parent; /* parent object on the search path */
+ union
+ {
+ long number; /* local number */
+ void* pointer; /* local pointer */
+ } local; /* user defined */
+ struct stat statb; /* stat buffer of this object */
+ char* path; /* full pathname */
+ short pathlen; /* strlen(path) */
+ unsigned short info; /* type of object */
+ unsigned short status; /* status of object */
+ short level; /* depth of object on the search path */
+ short namelen; /* strlen(name) */
+ char name[]; /* file name of object */
+.fi
+.PP
+The \fIlink\fR field is normally NULL.
+If the option FTW_CHILDREN was turned on,
+it points to the start of the list of children
+of the directory being visited in preorder.
+Finally, if the directory being visited causes a cycle,
+\fIlink\fR points to the object on the search path that is
+identical to this directory. Note that if FTW_PHYSICAL was turned on,
+this may point to a directory that is an ancestor of the starting
+object.
+.PP
+The \fIparent\fR field points to the parent object
+on the search path. For convenience, a parent object is also supplied for
+the starting object.
+In this case, except for the \fIlocal\fR field which is initialized
+to 0 and the \fIlevel\fR field which contains a negative number,
+the rest of the structure may be undefined.
+.PP
+The \fIinfo\fR field indicates the type of the object
+being visited and the type of the visit. The types are:
+.IP
+FTW_D: A directory being visited in preorder, i.e.,
+none of its children has been visited by the search.
+.IP
+FTW_DNX: A directory being visited in preorder that does not have
+search permission.
+.IP
+FTW_DP: A directory being visited in postorder, i.e., all of its
+descendants have been completely processed.
+.IP
+FTW_DC: A directory that causes cycles. This is a terminal object.
+.IP
+FTW_DNR: A directory that cannot be opened for reading. This is a terminal object.
+.IP
+FTW_F: An ordinary file.
+.IP
+FTW_SL: A symbolic link.
+Unless FTW_FOLLOW (below) is issued by the user function,
+this object is terminal.
+.IP
+FTW_NS: \fIStat\fR failed on this object.
+The stat buffer \fIstatb\fR is undefined.
+This object is terminal.
+.PP
+The \fIstatus\fR field of \fIstruct FTW\fR is used to communicate information
+between \fIftwalk\fR and \fIuserf\fR. On calls to \fIuserf\fR, it has one of
+two values:
+.IP
+FTW_NAME: The name of the object as defined in \fIftw->name\fR should be used for
+accessing its file information. This is because \fIchdir\fR(2) has been used
+to set the current directory to a suitable place (see FTW_CHDIR).
+.IP
+FTW_PATH: The argument \fIpath\fR of \fIuserf\fR should be used
+for accessing the file information of the object.
+.PP
+Upon returning, \fIuserf\fR may set the \fIstatus\fR field
+to one of the following values:
+.IP
+FTW_AGAIN: If this is a directory object being visited in postorder,
+it will be processed \fIagain\fR as if it had not been visited.
+.IP
+FTW_NOPOST: If this is a directory object being visited in preorder,
+the user function will not be called on its postorder visit.
+.IP
+FTW_SKIP: This object and its descendants are pruned from the search.
+.IP
+FTW_FOLLOW: If this object is a symbolic link,
+follow the link to its physical counterpart.
+.PP
+\fIComparf\fR, if not NULL, is a pointer to a function
+used to define a search ordering for children of a directory.
+If FTW_CHILDREN is turned on, the ordering of the children of
+a directory is done before the preorder call to \fIuserf\fR on that directory.
+Therefore, in that case, \fIftw->link\fR will point to the smallest child.
+.PP
+The \fIcomparf\fP prototype is:
+.PP
+.nf
+ int comparf(struct FTW* ftw1, struct FTW* ftw2)
+.fi
+.PP
+\fIComparf\fR should return a value <0, 0, or >0 to indicate whether
+\fIftw1\fR is considered smaller, equal, or larger than \fIftw2\fR.
+.PP
+\fIFtwalk\fR normally returns 0.
+On hard errors such as running out of memory, it returns -1.
+\fIFtwalk\fR may also return other values as discussed with respect
+to \fIuserf\fR.
+.PP
+\fIFtwflags\fR returns a combination of \fB0, FTW_META, FTW_PHYSICAL\fR
+according to the
+preferences specified by
+\fBastconf("PATH_RESOLVE",0,0)\fR:
+.TP
+.B logical
+0
+.TP
+.B metaphysical
+.B "FTW_META|FTW_PHYSICAL"
+.TP
+.B physical
+.B FTW_PHYSICAL
+.SH HISTORY
+\fIFtwalk\fR performs similar functions as that of
+the routine \fIftw\fR provided in System V.
+However, it is more general than \fIftw\fR
+and suitable for use as a base in implementing
+popular tools such as \fIls, find, tar, du,\fR and \fIrm\fR.
+\fIFtwalk\fR also handles symbolic links and hard links gracefully.
+.SH AUTHORS
+Phong Vo, Glenn Fowler, Dave Korn
+.SH SEE ALSO
+find(1), rm(1), du(1), ls(1), tar(1), stat(2), symlink(2),
+astfeature(3), ftw(3), pathcd(3)
diff --git a/usr/src/lib/libast/common/man/getcwd.3 b/usr/src/lib/libast/common/man/getcwd.3
new file mode 100644
index 0000000000..340329690d
--- /dev/null
+++ b/usr/src/lib/libast/common/man/getcwd.3
@@ -0,0 +1,67 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH GETCWD 3
+.SH NAME
+getcwd \- return absolute path to current directory
+.SH SYNOPSIS
+.EX
+#include <ast.h>
+
+char* getcwd(char* \fIbuf\fP, size_t \fIlen\fP);
+.EE
+.SH DESCRIPTION
+.L getcwd
+copies the absolute path name of the current directory info into
+.I buf
+of length
+.IR len .
+The return path may be longer than
+.LR PATH_MAX .
+If
+.I "buff == 0"
+then space is allocated via
+.IR malloc (3)
+and
+.I len
+extra characters are reserved after the generated path name.
+A pointer to the path name is returned,
+.L 0
+on error.
+.SH "SEE ALSO"
+pathcd(3)
diff --git a/usr/src/lib/libast/common/man/hash.3 b/usr/src/lib/libast/common/man/hash.3
new file mode 100644
index 0000000000..45029280c5
--- /dev/null
+++ b/usr/src/lib/libast/common/man/hash.3
@@ -0,0 +1,644 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH HASH 3
+.SH NAME
+hash \- hash table support \- obsolete \- use \fBcdt\fP
+.SH SYNOPSIS
+.L "#include <hash.h>"
+.SH DESCRIPTION
+The
+.I hash
+routines manipulate collections of dynamic, scoped hash tables.
+.PP
+A hash table provides an association between a
+.I key
+and its
+.IR value .
+A
+.I key
+is a sequence of
+.L char
+elements and a
+.I value
+is a user supplied pointer to the value.
+Each hash table has a dynamic number of slots,
+each pointing to the head of a forward linked
+.IR "collision chain" .
+.PP
+Hashing occurs as follows:
+a
+.I "hash function"
+takes a
+.I key
+as an argument and returns a non-negative index.
+The index modulo the table size produces a
+slot that points to a
+.IR "collision chain" .
+The collision chain is sequentially searched until a match is found for
+.IR key .
+The hash tables are automatically resized as new entries are added.
+.PP
+Each hash table has one key type.
+The default key type is a pointer to a null-terminated string.
+The alternate key type is a pointer to a fixed length byte buffer,
+declared for a given table by the
+.L hashalloc()
+function described below.
+.PP
+Hash table information is partitioned into two parts for efficient scoping.
+The
+.I root
+part contains fixed information that is shared among a set of related
+hash tables.
+The remaining information is maintained on a per-table basis.
+.PP
+These basic types are defined in the header file
+.B hash.h
+(alternate names are listed in parenthesis):
+.TP
+.L "Hash_table_t (HASHTABLE)"
+The per-table information.
+The readonly public elements are:
+.RS
+.TP
+.L "int buckets"
+The number of table entries.
+.TP
+.L "char* name"
+The hash table name.
+.TP
+.L "root"
+The root information.
+The public elements are:
+.RS
+.TP
+.L "int root->accesses"
+The number of lookups.
+.TP
+.L "int root->collisions"
+The number of lookup collisions.
+.RE
+.TP
+.L "Hash_table_t* scope"
+The table that this scope covers,
+.L NULL
+if the table is not a scope.
+.TP
+.L "int size"
+The current hash table size.
+.RE
+.TP
+.L "Hash_bucket_t (HASHBUCKET)"
+A collision chain hash bucket.
+The public structure elements are:
+.RS
+.TP
+.L "char* hashname(Hash_bucket_t*)"
+Returns a pointer to the hash bucket key given the bucket pointer.
+.TP
+.L "char* value"
+The value associated with the key.
+.RE
+.TP
+.L "Hash_header_t (HASHHEADER)"
+The hash bucket header that must be the first element in all user defined
+buckets.
+.L HASH_VALUE
+may not be used with user defined buckets.
+.TP
+.L "Hash_position_t (HASHPOSITION)"
+Stores the hash table position for
+.LR hashscan .
+The public elements are:
+.RS
+.TP
+.L "Hash_bucket_t* bucket"
+The current hash bucket pointer.
+.RE
+.PP
+The routines are:
+.TP
+.L "Hash_table_t* hashalloc(Hash_table_t* ref, int op, ...)"
+Creates a new hash table and returns a pointer to the table.
+.IR malloc (3)
+is used to allocate space for the table.
+.L NULL
+is returned if the table cannot be created.
+.L ref
+is a pointer to a reference hash table that provides
+default values for unspecified information.
+The new hash table and
+.L ref
+share the same root information.
+If
+.L ref
+is
+.L NULL
+then new root information is created for the new table.
+The remaining arguments appear in
+.I op-arg
+pairs, followed by a final
+.L 0
+argument.
+The
+.I op-arg
+pairs are:
+.RS
+.TP
+.L "HASH_alloc, (char(*)()) alloc"
+.L alloc
+is a function that is called to process
+.L Hash_bucket_t
+.L value
+assignments.
+The single argument is
+.L "char* value"
+and the processed
+.L char*
+value is returned.
+.TP
+.L "HASH_clear, int flags"
+.L flags
+are the
+.L ref
+flags to be cleared in the new hash table.
+See
+.L HASH_set
+below.
+.TP
+.L "HASH_compare, (int(*)()) compare"
+Specifies an alternate
+.I key
+comparison function.
+The arguments and return value for
+.L compare
+are the same as for
+.IR strncmp (3)
+if
+.L HASH_namesize
+is specified and
+.IR strcmp (3)
+otherwise.
+The first argument is the
+.I key
+from the current hash bucket on the
+.I "collision chain"
+and the second argument is the user supplied
+.IR key .
+.TP
+.L "HASH_free, (int(*)()) free"
+.L free
+is a function that is called when a hash bucket is freed.
+If
+.L HASH_BUCKET
+was set in
+.L hashalloc
+then the hash bucket pointer is passed, otherwise the bucket
+.L value
+pointer is passed.
+.TP
+.L "HASH_hash, (int(*)()) hash"
+Specifies an alternate
+.I key
+hash function.
+A
+.L char*
+key argument (and, if
+.L HASH_namesize
+is specified, an
+.L int
+key size argument) is passed to
+.LR hash .
+The return value must be a non-negative
+.LR int .
+.TP
+.L "HASH_meanchain, int meanchain"
+Specifies the mean collision chain length.
+The hash table is automatically resized when this value is exceeded.
+The default mean chain length is 2.
+.TP
+.L "HASH_name, char* name"
+Associates
+.L name
+with the hash table.
+Used by
+.LR hashdump) .
+.TP
+.L "HASH_namesize, int namesize"
+The fixed size in bytes for
+.I keys
+in the table.
+If
+.L namesize
+is 0 (the default) then the
+.I keys
+are interpreted as null-terminated strings.
+.TP
+.L "HASH_set, int flags"
+Changes the hash table flags by
+.IR or ing
+in
+.LR flags .
+The flags, which may be
+.IR or ed
+together, are:
+.RS
+.TP
+.L HASH_ALLOCATE
+Keys for new hash table entries are to be copied to data areas obtained from
+.IR malloc (3).
+.TP
+.L HASH_FIXED
+Fixes the hash table size, disabling any automatic table resizing.
+.TP
+.L HASH_SCOPE
+The new hash table is a scope that is to be pushed on top of
+.LR ref .
+.L ref
+must be
+.RL non- NULL .
+.RE
+.TP
+.L "HASH_va_list, va_list ap"
+.L ap
+is a
+.L va_list
+variable argument list pointer
+(see
+.LR <stdarg.h> ).
+.RE
+.TP
+.L "Hash_table_t* hashfree(Hash_table_t* tab)"
+The hash table
+.L tab
+is freed.
+The scope covered table pointer is returned,
+.L NULL
+if
+.L tab
+is not a scope.
+.TP
+.L "char* hashlook(Hash_table_t* tab, char* name, int flags, char* value)"
+Operates on the key
+.L name
+in the hash table
+.L tab
+according to
+.L flags
+and
+.LR value .
+A
+.L Hash_bucket_t
+pointer is returned unless otherwise noted.
+There are three basic lookup operations:
+.RS
+.TP
+.L HASH_CREATE
+.L name
+is entered into the top level scope if it does not already exist.
+If
+.L name
+also appears in a lower scope and
+.L HASH_ALLOC
+is set for the table then the new bucket will share the
+.L name
+field value with the lower scope.
+.TP
+.L HASH_DELETE
+.L name
+is deleted from the top level scope if it exists.
+.L NULL
+is returned.
+.TP
+.L HASH_LOOKUP
+The scopes are searched in order from top to bottom for
+.L name .
+The bucket pointer for the first occurrence is returned.
+.L NULL
+is returned if
+.L name
+is not found.
+.RE
+The basic operations may be qualified by the following
+(the qualifiers are restricted to the basic operations in
+the parenthesized list):
+.RS
+.TP
+.L "HASH_BUCKET (HASH_CREATE,HASH_DELETE,HASH_LOOKUP)"
+.L name
+is a pointer to a bucket that has already been entered into the table.
+.TP
+.L "HASH_FIXED (HASH_CREATE)"
+.L value
+is taken to be the size of the hash bucket to be created for
+.L name
+in the top level scope.
+The minimum bucket size is silently restricted to
+.LR sizeof(Hash_header_t) .
+.TP
+.L "HASH_INSTALL (HASH_CREATE)"
+.L name
+is a pointer to a bucket that has not been entered into the table.
+.TP
+.L "HASH_NOSCOPE (HASH_LOOKUP)"
+The lookup is restricted to the top level scope.
+.TP
+.L "HASH_OPAQUE (HASH_CREATE,HASH_DELETE)"
+Sets
+.L (HASH_CREATE)
+or clears
+.L (HASH_DELETE)
+the
+.I opaque
+property for the bucket.
+An opaque bucket is not visible in lower scopes.
+.TP
+.L "HASH_SCOPE (HASH_CREATE,HASH_DELETE)"
+All scopes are searched for the bucket.
+If the bucket is not found for
+.L HASH_CREATE
+then a new bucket is created in the lowest scope.
+.TP
+.L "HASH_VALUE (HASH_CREATE,HASH_LOOKUP)"
+For
+.L HASH_CREATE
+the bucket
+.L value
+field is set to
+.L value
+and the bucket
+.L name
+value is returned.
+For
+.L HASH_LOOKUP
+the bucket
+.L value
+field is returned,
+.L NULL
+if the bucket is not found.
+.RE
+If
+.L name
+.L NULL
+then the name from the most recent
+.L hashlook()
+is used, avoiding recomputation of some internal parameters.
+.TP
+.L "char* hashget(Hash_table_t* tab, char* name)"
+Returns the value
+associated with the key
+.L name
+in the hash table
+.LR tab .
+If
+.L name
+is
+.L NULL
+then the name from the most recent
+.L hashget()
+is used, avoiding recomputation of some internal parameters.
+.L NULL
+is returned if
+.L name
+is not in the table.
+All scope covered tables are searched.
+.TP
+.L "Hash_bucket_t* hashlast(Hash_table_t* tab)"
+Returns a pointer to the most recent hash bucket for
+.LR tab .
+The value is set by
+.LR hashlook() ,
+.L hashscan()
+and
+.LR hashwalk() .
+.TP
+.L "char* hashput(Hash_table_t* tab, char* name, char* value)"
+Set the value of the key
+.L name
+to
+.L value
+in the top level scope of the hash table
+.LR tab .
+.L name
+is entered into the top level scope if necessary.
+The (possibly re-allocated) key name pointer is returned
+(see
+.LR HASH_ALLOCATE ).
+If
+.L name
+is 0 then the most recent lookup
+.L name
+to
+.L hashlook()
+or
+.L hashget()
+is used.
+This eliminates a re-hash and re-lookup of
+.LR name .
+.TP
+.L "int hashwalk(Hash_table_t* tab, int flags, (int(*)()) walker, char* handle)"
+The function
+.L walker
+is applied to each entry (not covered by a scope starting at
+.LR tab )
+in the hash table
+.LR tab .
+If
+.L flags
+is
+.L HASH_NOSCOPE
+then only the top level hash table is used, otherwise the walk includes
+all scope covered tables.
+.L walker
+is called with
+.L char*
+.I key
+as the first argument,
+.L char*
+.I value
+as the second argument, and
+.L char*
+.I handle
+as the third argument.
+.I handle
+may be
+.LR 0 .
+The walk terminates after the last entry or when
+.L walker
+returns a negative value.
+The return value of the last call to
+.L walker
+is returned.
+Only one walk may be active within a collection of scoped tables.
+.TP
+.L "Hash_position_t* hashscan(Hash_table_t* tab, int flags)"
+Returns a
+.L Hash_position_t
+pointer for a sequential scan on the hash table
+.LR tab .
+If
+.L flags
+is
+.L HASH_NOSCOPE
+then only the top level hash table is used, otherwise the scan includes
+all scope covered tables.
+Only one scan may be active within a collection of scoped tables.
+.L hashdone()
+must be called to terminate the scan.
+.L 0
+is returned on error.
+.TP
+.L "Hash_bucket_t* hashnext(Hash_position_t* pos)"
+Returnes a pointer to the next bucket in the sequential scan set up by
+.L hashscan()
+on
+.LR pos .
+If no elements remain then
+.L 0
+is returned.
+.TP
+.L "void hashdone(Hash_position_t* pos)"
+Completes a scan initiated by
+.L hashscan()
+on
+.LR pos .
+.TP
+.L "int hashset(Hash_table_t* tab, int flags)"
+Sets the flags for the hash table
+.L tab
+by
+.IR or ing
+in
+.LR flags .
+Only
+.L HASH_ALLOCATE
+and
+.L HASH_FIXED
+may be set.
+.TP
+.L "int hashclear(Hash_table_t* tab, int flags)"
+Clears the flags for the hash table
+.L tab
+by masking out
+.LR flags .
+Only
+.L HASH_ALLOCATE
+and
+.L HASH_FIXED
+may be cleared.
+.TP
+.L "void hashdump(Hash_table_t* tab, int flags)"
+Dumps hash table accounting info to standard error.
+If
+.L tab
+is
+.L NULL
+then all allocated hash tables are dumped, otherwise only information on
+.L tab
+is dumped.
+If
+.L flags
+is
+.L HASH_BUCKET
+then the hash bucket
+.I key-value
+pairs for each collision chain are also dumped.
+.TP
+.L "void hashsize(Hash_table_t* tab, int size)"
+Changes the size of the hash table
+.L tab
+to
+.L size
+where
+.L size
+must be a power of 2.
+Explicit calls to this routine are not necessary as hash tables
+are automatically resized.
+.TP
+.L "int strhash(char* name)"
+Hashes the null terminated character string
+.L name
+using a linear congruent pseudo-random number generator algorithm
+and returns a non-negative
+.L int
+hash value.
+.TP
+.L "int memhash(char* buf, int siz)"
+Hashes the buffer
+.L buf
+of
+.L siz
+bytes using a linear congruent pseudo-random number generator algorithm
+and returns a non-negative
+.L int
+hash value.
+.TP
+.L "long strsum(char* name, long sum)"
+Returns a running 31-bit checksum of the string
+.L name
+where
+.L sum
+is
+.L 0
+on the first call and
+the return value from a previous
+.L memsum
+or
+.L strsum
+call otherwise.
+The checksum value is consistent across all implementations.
+.TP
+.L "long memsum(char* buf, int siz, long sum)"
+Returns a running 31-bit checksum of buffer
+.L buf
+of
+.L siz
+bytes where
+.L sum
+is
+.L 0
+on the first call and
+the return value from a previous
+.L memsum
+or
+.L strsum
+call otherwise.
+The checksum value is consistent across all implementations.
+.SH "SEE ALSO"
+sum(1)
diff --git a/usr/src/lib/libast/common/man/iblocks.3 b/usr/src/lib/libast/common/man/iblocks.3
new file mode 100644
index 0000000000..0c615f86c4
--- /dev/null
+++ b/usr/src/lib/libast/common/man/iblocks.3
@@ -0,0 +1,62 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH IBLOCKS 3
+.SH NAME
+iblocks \- compute number file blocks used
+.SH SYNOPSIS
+.EX
+#include <ls.h>
+
+long _iblocks(struct stat* \fIst\fP);
+.EE
+.SH DESCRIPTION
+.L _iblocks
+returns the number of blocks used by the file whose
+.IR stat (2)
+information is pointed to by
+.IR st .
+The count includes both data and indirect blocks.
+.PP
+This routine is used by
+.B <ls.h>
+on system without the
+.LI "struct stat" st_blocks
+field.
+.SH "SEE ALSO"
+ls(1), stat(2)
diff --git a/usr/src/lib/libast/common/man/int.3 b/usr/src/lib/libast/common/man/int.3
new file mode 100644
index 0000000000..8d457c083d
--- /dev/null
+++ b/usr/src/lib/libast/common/man/int.3
@@ -0,0 +1,68 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH INT 3
+.SH NAME
+int \- integral type macros
+.SH SYNOPSIS
+.EX
+#include <int.h>
+.EE
+.SH DESCRIPTION
+This header defines macros for the local integral types.
+.LR int_1 ,
+.LR int_2
+and
+.L int_4
+are always defined to integral types with a size of
+1, 2 and 4 bytes respectively.
+The macros
+.LI int_ n
+where
+.I n
+is a power of 2 greater than 4 are defined if the type is supported.
+.L int_max
+is defined to be the largest support integral type.
+.L int_swap
+is the
+.IR swap (3)
+operation that converts a local
+.L int
+to canonical big-endian representation.
+.SH "SEE ALSO"
+swap(3)
diff --git a/usr/src/lib/libast/common/man/magic.3 b/usr/src/lib/libast/common/man/magic.3
new file mode 100644
index 0000000000..e8bf0e328f
--- /dev/null
+++ b/usr/src/lib/libast/common/man/magic.3
@@ -0,0 +1,493 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH MAGIC 3
+.SH NAME
+magic \- magic file interface
+.SH SYNOPSIS
+.EX
+#include <magic.h>
+
+Magic_t
+{
+ unsigned long flags;
+};
+
+Magic_t* magicopen(unsigned long \fIflags\fP);
+void magicclose(Magic_t* \fImagic\fP);
+
+int magicload(Magic_t* \fImagic\fP, const char* \fIpath\fP, unsigned long \fIflags\fP);
+int magiclist(Magic_t* \fImagic\fP, Sfio_t* \fIsp\fP);
+
+char* magictype(Magic_t* \fImagic\fP, const char* \fIpath\fP, struct stat* \fIst\fP);
+.EE
+.SH DESCRIPTION
+These routines provide an interface to the
+.IR file (1)
+command magic file.
+.L magicopen
+returns a magic session handle that is passed to all of the other routines.
+.I flags
+may be
+.TP
+.L MAGIC_MIME
+Return the MIME type string rather than the magic file description.
+.TP
+.L MAGIC_PHYSICAL
+Don't follow symbolic links.
+.TP
+.L MAGIC_STAT
+The stat structure
+.I st
+passed to
+.I magictype
+will contain valid
+.I stat (2)
+information.
+See
+.L magictype
+below.
+.TP
+.L MAGIC_VERBOSE
+Enable verbose error messages.
+.PP
+.L magicclose
+closes the magic session.
+.PP
+.L magicload
+loads the magic file named by
+.I path
+into the magic session.
+.I flags
+are the same as with
+.LR magicopen .
+More than one magic file can be loaded into a session;
+the files are searched in load order.
+If
+.I path
+is
+.L 0
+then the default magic file is loaded.
+.PP
+.L magiclist
+lists the magic file contents on the
+.IR sfio (3)
+stream
+.IR sp .
+This is used for debugging magic entries.
+.PP
+.L magictype
+returns the type string for
+.I path
+with optional
+.IR stat (2)
+information
+.IR st .
+If
+.I "st == 0"
+then
+.L magictype
+calls
+.L stat
+on a private stat buffer,
+else if
+.L magicopen
+was called with the
+.L MAGIC_STAT
+flag then
+.I st
+is assumed to contain valid stat information, otherwise
+.L magictype
+calls
+.L stat
+on
+.IR st .
+.L magictype
+always returns a non-null string.
+If errors are encounterd on
+.I path
+then the return value will contain information on those errors, e.g.,
+.LR "cannot stat" .
+.SH FORMAT
+The magic file format is a backwards compatible extension of an
+ancient System V file implementation.
+However, with the extended format it is possible to write a single
+magic file that works on all platforms.
+Most of the net magic files floating around work with
+.LR magic ,
+but they usually double up on
+.I le
+and
+.I be
+entries that are automatically handled by
+.LR magic .
+.PP
+A magic file entry describes a procedure for determining a single file type
+based on the file pathname,
+.I stat (2)
+information, and the file data.
+An entry is a sequence of lines, each line being a record of
+.I space
+separated fields.
+The general record format is:
+.EX
+[op]offset type [mask]expression description [mimetype]
+.EE
+.L #
+in the first column introduces a comment.
+The first record in an entry contains no
+.LR op ;
+the remaining records for an entry contain an
+.LR op .
+Integer constants are as in C:
+.L 0x*
+or
+.L 0X*
+for hexadecimal,
+.L 0*
+for octal and decimal otherwise.
+.PP
+The
+.L op
+field may be one of:
+.TP
+.L +
+The previous records must match but the current record is optional.
+.L >
+is an old-style synonym for
+.LR + .
+.TP
+.L &
+The previous and current records must match.
+.TP
+.L {
+Starts a nesting block that is terminated by
+.LR } .
+A nesting block pushes a new context for the
+.L +
+and
+.L &
+ops.
+The
+.L {
+and
+.L }
+records have no other fields.
+.TP
+\fIid\f5{\fR
+A function declaration and call for the single character identifier
+.IR id .
+The function return is a nesting block end record
+.LR } .
+Function may be redefined.
+Functions have no arguments or return value.
+.TP
+\fIid\f5()\fR
+A call to the function
+.IR id .
+.PP
+The
+.L offset
+field is either the offset into the data upon which the current entry operates
+or a file metadata identifier.
+Offsets are either integer constants or offset expressions.
+An offset expression is contained in (...) and is a combination of
+integral arithmetic operators and the
+.L @
+indirection operator.
+Indirections take the form
+.LI @ integer
+where integer is the data offset for the indirection value.
+The size of the indirection value is taken either from one of the suffixes
+.LR B (byte, 1 char),
+.LR H (short, 2 chars),
+.LR L (long, 4 chars),
+pr
+.LR Q (quead, 8 chars),
+or from the
+.L type
+field.
+Valid file metadata identifiers are:
+.TP
+.L atime
+The string representation of
+.LR stat.st_atime .
+.TP
+.L blocks
+.LR stat.st_blocks .
+.TP
+.L ctime
+The string representation of
+.LR stat.st_ctime .
+.TP
+.L fstype
+The string representation of
+.LR stat.st_fstype .
+.TP
+.L gid
+The string representation of
+.LR stat.st_gid .
+.TP
+The
+.L stat.st_mode
+file mode bits in
+.IR modecanon (3)
+canonical representation (i.e., the good old octal values).
+.TP
+.L mtime
+The string representation of
+.LR stat.st_mtime .
+.TP
+.L nlink
+.LR stat.st_nlink .
+.TP
+.L size
+.LR stat.st_size .
+.TP
+.L name
+The file path name sans directory.
+.TP
+.L uid
+The string representation of
+.LR stat.st_uid .
+.PP
+The
+.L type
+field specifies the type of the data at
+.LR offset .
+Integral types may be prefixed by
+.L le
+or
+.L be
+for specifying exact little-endian or big-endian representation,
+but the internal algorithm automatically loops through the
+standard representations to find integral matches,
+so representation prefixes are rarely used.
+However, this looping may cause some magic entry conflicts; use the
+.L le
+or
+.L be
+prefix in these cases.
+Only one representation is used for all the records in an entry.
+Valid types are:
+.TP
+.L byte
+A 1 byte integer.
+.TP
+.L short
+A 2 byte integer.
+.TP
+.L long
+A 4 byte integer.
+.TP
+.L quad
+An 8 byte integer.
+Tests on this type may fail is the local compiler does not support
+an 8 byte integral type and the corresponding value overflows 4 bytes.
+.TP
+.L date
+The data at
+.L offset
+is interpreted as a 4 byte seconds-since-the-epoch date and
+converted to a string.
+.TP
+.L edit
+The
+.L expression
+field is an
+.IR ed (1)
+style substitution expression
+\fIdel old del new del \fP [ \fI flags \fP ]
+where the substituted value is made available to the
+.L description
+field
+.L %s
+format.
+In addition to the
+.I flags
+supported by
+.IR ed (3)
+are
+.L l
+that converts the substituted value to lower case and
+.L u
+that converts the substituted value to upper case.
+If
+.I old
+does not match the string data at
+.L offset
+then the entry record fails.
+.TP
+.L match
+.L expression
+field is a
+.IR strmatch (3)
+pattern that is matched against the string data at
+.LR offset .
+.TP
+.L string
+The
+.L expression
+field is a string that is compared with the string data at
+.LR offset .
+.PP
+The optional
+.L mask
+field takes the form
+.LI & number
+where
+.I number
+is
+.I anded
+with the integral value at
+.L offset
+before the
+.L expression
+is applied.
+.PP
+The contents of the expression field depends on the
+.LR type .
+String type expression are described in the
+.L type
+field entries above.
+.L *
+means any value and applies to all types.
+Integral
+.L type
+expression take the form [\fIoperator\fP] \fIoperand\P where
+.I operand
+is compared with the data value at
+.L offset
+using
+.IR operator .
+.I operator
+may be one of
+.LR < .
+.LR <= ,
+.LR == ,
+.LR >=
+or
+.LR > .
+.I operator
+defaults to
+.L ==
+if omitted.
+.I operand
+may be an integral constant or one of the following builtin function calls:
+.TP
+.L magic()
+A recursive call to the magic algorithm starting with the data at
+.LR offset .
+.TP
+\f5loop(\fIfunction\fP,\fIoffset\fP,\fIincrement\fP)\fR
+Call
+.I function
+starting at
+.I offset
+and increment
+.I offset
+by
+.I increment
+after each iteration.
+Iteration continues until the description text does not change.
+.PP
+The
+.L description
+field is the most important because it is this field that is presented
+to the outside world.
+When constructing description
+fields one must be very careful to follow the style layed out in the
+magic file, lest yet another layer of inconsistency creep into the system.
+The description for each matching record in an entry are concatenated
+to form the complete magic type.
+If the previous matching description in the current entry does not end with
+.I space
+and the current description is not empty and does not start with
+.I comma ,
+.I dot
+or
+.I backspace
+then a
+.I space
+is placed between the descriptions
+(most optional descriptions start with
+.IR comma .)
+The data value at
+.L offset
+can be referenced in the description using
+.L %s
+for the string types and
+.L %ld
+or
+.L %lu
+for the integral types.
+.PP
+The
+.L mimetype
+field specifies the MIME type, usually in the form
+.IR a / b .
+.SH FILES
+.L ../lib/file/magic
+located on
+.L $PATH
+.SH EXAMPLES
+.EX
+0 long 0x020c0108 hp s200 executable, pure
+o{
++36 long >0 , not stripped
++4 short >0 , version %ld
+}
+
+0 long 0x020c0107 hp s200 executable
+o()
+
+0 long 0x020c010b hp s200 executable, demand-load
+o()
+.EE
+The function
+.LR o() ,
+shared by 3 entries,
+determines if the executable is stripped and also extracts the version number.
+.EX
+0 long 0407 bsd 386 executable
+&mode long &0111!=0
++16 long >0 , not stripped
+.EE
+This entry requires that the file also has execute permission.
+.SH "SEE ALSO"
+file(1), mime(4), tw(1), modecanon(3)
diff --git a/usr/src/lib/libast/common/man/mem.3 b/usr/src/lib/libast/common/man/mem.3
new file mode 100644
index 0000000000..70da0db525
--- /dev/null
+++ b/usr/src/lib/libast/common/man/mem.3
@@ -0,0 +1,98 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH MEM 3
+.SH NAME
+mem \- fixed string routines
+.SH SYNOPSIS
+.EX
+#include <ast.h>
+
+void mematoe(void* \fIout\fP, const void* \fIin\fP, size_t \fIn\fP);
+void* memdup(const void* \fIbuf\fP, size_t \fIn\fP)
+void memetoa(void* \fIout\fP, const void* \fIin\fP, size_t \fIn\fP);
+void* memzero(void* \fIbuf\fP, size_t \fIn\fP);
+.EE
+.SH DESCRIPTION
+.L mematoe
+converts
+.I n
+ASCII characters in
+.I in
+to EBCDIC characters in
+.IR out .
+.I in
+and
+.I out
+may be the same.
+.PP
+.L memdup
+copies the
+.I n
+byte buffer
+.I buf
+to a new location provided by
+.IR malloc (3)
+and returns a pointer to the new copy.
+0 is returned if
+.IR malloc (3)
+fails.
+.PP
+.L memetoa
+converts
+.I n
+EBCDIC characters in
+.I in
+to ASCII characters in
+.IR out .
+.I in
+and
+.I out
+may be the same.
+.PP
+.L memzero
+sets the first
+.I n
+bytes in
+.I buf
+to
+.IR 0 .
+.SH "SEE ALSO"
+Proposed Bell Laboratories ASCII/EBCDIC standard, April 16, 1979.
+.br
+str(3), vmalloc(3)
diff --git a/usr/src/lib/libast/common/man/mime.3 b/usr/src/lib/libast/common/man/mime.3
new file mode 100644
index 0000000000..f540b2e3f3
--- /dev/null
+++ b/usr/src/lib/libast/common/man/mime.3
@@ -0,0 +1,117 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH MIME 3
+.SH NAME
+mime \- mime/mailcap interface
+.SH SYNOPSIS
+.EX
+#include <mime.h>
+
+Mime_t
+{
+ unsigned long flags;
+};
+
+Mime_t* mimeopen(unsigned long \fIflags\fP);
+void mimeclose(Mime_t* \fImime\fP);
+
+int mimeload(Mime_t* \fImime\fP, const char* \fIpath\fP, unsigned long \fIflags\fP);
+int mimelist(Mime_t* \fImime\fP, Sfio_t* \fIsp\fP, const char* \fIpattern\fP);
+
+char* mimeview(Mime_t* \fImime\fP, const char* \fIview\fP, const char* \fIname\fP, const char* \fItype\fP, const char* \fIopts\fP);
+int mimeset(Mime_t* \fImime\fP, char* \fIline\fP, unsigned long \fIflags\fP);
+.EE
+.SH DESCRIPTION
+These routines provide an interface to the MIME type database.
+.L mimeopen
+returns a mime session handle that is passed to all of the other routines.
+The
+.I flags
+argument is currently unused.
+.PP
+.L mimeclose
+closes the mime session.
+.PP
+.L mimeload
+loads the mime file named by
+.I path
+into the mime session.
+.I flags
+may be one of:
+.TP
+.L MIME_LIST
+The
+.I path
+argument is a
+.B :
+separated list of pathnames, each of which is loaded.
+Non-existent files are ignored
+.L MIME_LIST
+set.
+.TP
+.L MIME_REPLACE
+Replace existing entries by new entries with the same type.
+Otherwise original entries take precedence.
+.PP
+More than one mime file can be loaded into a session;
+the files are searched in load order.
+If
+.I path
+is
+.L 0
+then the default mime file is loaded.
+.PP
+.L mimelist
+lists the mime file contents on the
+.IR sfio (3)
+stream
+.IR sp .
+This is used for debugging mime entries.
+.PP
+.L mimetype
+returns the type string for
+.IR path .
+.L mimetype
+always returns a non-null string.
+If errors are encounterd on
+.I path
+then the return value will be
+.LR "error" .
+.SH "SEE ALSO"
+file(1), mime(4)
diff --git a/usr/src/lib/libast/common/man/modecanon.3 b/usr/src/lib/libast/common/man/modecanon.3
new file mode 100644
index 0000000000..4a5d128f9c
--- /dev/null
+++ b/usr/src/lib/libast/common/man/modecanon.3
@@ -0,0 +1,104 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH MODECANON 3
+.SH NAME
+modecanon \- canonical file mode representation
+.SH SYNOPSIS
+#include <modex.h>
+
+int modei(int \fIexternal\fP);
+int modex(int \fIinternal\fP);
+.EE
+.SH DESCRIPTION
+POSIX threw out the file type bit macros and replaced them with
+function-like macros that test file type.
+This is bad in many ways, the worst of which is that it provides
+no way for a user program to synthesize file types in the mode bits.
+.IR pax (1),
+.IR tar (1)
+and
+.IR cpio (1)
+are examples of user programs that must convert between the internal mode
+representation and a private external representation.
+These routines provide a canonical external representation
+with macros to access and synthesize the bits in the external
+representation.
+.PP
+.L modei
+takes an external mode representation
+.I external
+and returns the equivalent internal representation.
+.PP
+.L modex
+takes an internal mode representation
+.I internal
+and returns the equivalent external representation.
+.PP
+The traditional bit access macro (\f5S_\fP prefix changes to \f5X_\fP) are:
+.L X_IFMT ,
+.L X_IFSOCK ,
+.L X_IFLNK ,
+.L X_IFCTG ,
+.L X_IFREG ,
+.L X_IFBLK ,
+.L X_IFDIR ,
+.L X_IFCHR ,
+.L X_IFIFO ,
+.L X_IPERM ,
+.L X_ISUID ,
+.L X_ISGID ,
+.L X_ISVTX ,
+.L X_IRUSR ,
+.L X_IWUSR ,
+.L X_IXUSR ,
+.L X_IRGRP ,
+.L X_IWGRP ,
+.L X_IXGRP ,
+.L X_IROTH ,
+.L X_IWOTH ,
+.L X_IXOTH ,
+.L X_IRWXU ,
+.L X_IRWXG
+and
+.L X_IRWXO .
+.LI X_ITYPE( mode )
+returns the type bits for
+.IR mode .
+.SH "SEE ALSO"
+pax(1), stat(2)
diff --git a/usr/src/lib/libast/common/man/optget.3 b/usr/src/lib/libast/common/man/optget.3
new file mode 100644
index 0000000000..90afcb8f76
--- /dev/null
+++ b/usr/src/lib/libast/common/man/optget.3
@@ -0,0 +1,68 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH OPTGET 3
+.SH NAME
+optget \- option parse assist
+.SH SYNOPSIS
+.EX
+#include <option.h>
+
+Opt_t
+{
+};
+
+Optdisc_t
+{
+ unsigned long version;
+ unsigned long flags;
+ char* catalog;
+ Optinfo_f infof;
+};
+
+Opt_t opt_info;
+
+void optinit(Optdisc_t* \fIdisc\fP, Error_f \fIerrorf\fP);
+int optget(char** \fIargv\fP, const char* \fIusage\fP);
+int optstr(const char* \fIstring\fP, const char* \fIusage\fP);
+int optjoin(char** \fIargv\fP, ... [int (*\fIoptfun\fP)(char** \fIargv\fP, int \fIlast\fP)]);
+char* optusage(const char* \fIopts\fP);
+int optesc(Sfio_t* \fIsp\fP, const char* \fIstring\fP, int \fIflags\fP);
+.EE
+.SH DESCRIPTION
+.SH "SEE ALSO"
diff --git a/usr/src/lib/libast/common/man/path.3 b/usr/src/lib/libast/common/man/path.3
new file mode 100644
index 0000000000..8721888bb5
--- /dev/null
+++ b/usr/src/lib/libast/common/man/path.3
@@ -0,0 +1,391 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH PATH 3
+.SH NAME
+path \- file path routines
+.SH SYNOPSIS
+.EX
+#include <ast.h>
+
+char* pathaccess(char* \fIpath\fP, const char* \fIdirs\fP, const char* \fIa\fP, const char* \fIb\fP, int \fImode\fP);
+char* pathbin(void);
+char* pathcanon(char* \fIpath\fP, int \fIflags\fP);
+char* pathcat(char* \fIpath\fP, const char* \fIdirs\fP, int \fIsep\fP, const char* \fIa\fP, const char* \fIb\fP);
+char* pathcd(char* \fIpath\fP, const char* \fIhome\fP);
+int pathcheck(const char* \fIpackage\fP, const char* \fItool\fP, Pathcheck_t* \fIpc\fP);
+int pathgetlink(const char* \fIname\fP, char* \fIbuf\fP, int \fIsiz\fP);
+char* pathkey(char* \fIkey\fP, char* \fIattr\fP, const char* \fIlang\fP, const char* \fIpath\fP);
+char* pathnext(char* \fIpath\fP, char* \fIextra\fP, long* \fIvisits\fP);
+char* pathpath(char* \fIpath\fP, const char* \fIp\fP, const char* \fIa\fP, int \fImode\fP);
+char* pathprobe(char* \fIpath\fP, char* \fIattr\fP, const char* \fIlang\fP, const char* \fItool\fP, const char* \fIproc\fP, int \fIop\fP);
+char* pathrepl(char* \fIpath\fP, const char* \fImatch\fP, const char* \fIreplace\fP);
+int pathsetlink(const char* \fItext\fP, char* \fIname\fP);
+char* pathshell(void);
+int pathstat(const char* \fIpath\fP, struct stat* \fIst\fP);
+char* pathtemp(char* \fIpath\fP, const char* \fIdir\fP, const char* \fIpfx\fP);
+.EE
+.SH DESCRIPTION
+These routines operate on file path names.
+Path buffers are assumed to be of size
+.LR PATH_MAX .
+.L <ast.h>
+always defines
+.LR PATH_MAX ,
+even if it indeterminant on the local system.
+Yes, this was probably a bad choice, but it was made about 10 years ago.
+We will probably move to a <stk.h> based implementation.
+.PP
+.L pathaccess
+constructs a path in
+.L path
+to the file
+.L a/b
+with access
+.L mode
+using the
+.L :
+separated directories in
+.IR dirs .
+Both
+.I a
+and
+.I b
+may be
+.LR 0 .
+.L mode
+is the inclusive-or of:
+.TP
+.L F_OK
+File exists.
+.TP
+.L R_OK
+Read permission on file.
+.TP
+.L W_OK
+Write permission on file.
+.TP
+.L X_OK
+Execute permission on file.
+.TP
+.L PATH_REGULAR
+A regular file.
+.TP
+.L PATH_ABSOLUTE
+Generated path name is rooted at
+.LR / .
+.I path
+is returned, 0 on error.
+.PP
+.L pathbin
+returns a pointer to the
+.L :
+separated list of directories to search for executable commands.
+The
+.L PATH
+environment variable is first consulted.
+If not defined then
+.L confstr(_CS_PATH,...)
+is used.
+A valid string is always returned.
+.PP
+.L pathcanon
+canonicalizes the path
+.I path
+in place.
+A pointer to the trailing 0 in the canonicalized path is returned.
+A canonical path has:
+redundant
+.L .
+and
+.L /
+removed;
+.L ..
+moved to the front;
+.L /..
+preserved for super root hacks;
+.L ...
+resolved if
+.IR fs3d (3)
+is enabled.
+.I flags is the inclusive-or of:
+.TP
+.L PATH_DOTDOT
+Each
+.L ..
+is checked for access.
+.TP
+.L PATH_EXISTS
+Path must exist at each component.
+.TP
+.L PATH_PHYSICAL
+Symbolic links are resolved at each component.
+.PP
+0 is returned on error.
+If an error occurs and either of
+.L PATH_DOTDOT
+or
+.L PATH_EXISTS
+is set then
+.I path
+will contain the components following the failure point.
+.PP
+.L pathcat
+concatenates the first
+.I sep
+separated path component in
+.I dirs
+with the path components
+.I a
+and
+.I b
+into
+.LR path .
+The path is constructed in
+.I path
+by separating each path component with
+.IR / .
+Both
+.I a
+and
+.I b
+may be
+.LR 0 .
+A pointer to the next
+.I sep
+separated component in
+.I dirs
+is returned,
+.L 0
+when there are no more components.
+.L pathcat
+is used by
+.LR pathaccess .
+.PP
+.L pathcd
+sets the current working directory to
+.I path
+via
+.IR chdir (2).
+If
+.I path
+is longer than
+.L PATH_MAX
+then it is split up into a sequence of relative paths and
+.I chdir
+is called on each of these.
+For any given system, if you got to a directory, then
+.L pathcd
+can get you back, modulo permission and link changes.
+.PP
+.L pathcheck
+is a stub for license libraries.
+See
+.IR license (3).
+.PP
+.L pathgetlink
+returns the 0-terminated symbolic link text for
+.I path
+in the buffer
+.I bu
+of size
+.IR siz .
+The link text length is returned on success, \-1 on error.
+Weird
+.I universe (1)
+interactions with dynamic symbolic links are handled
+by converting non-standard dynamic link text to
+.LI .../$( UNIVERSE )/...
+.L pathsetsymlink
+converts in the other direction.
+.PP
+.L pathkey
+generates in
+.I key
+a 14 character lookup key (plus terminating 0) for the language
+.I lang
+processor in
+.IR path .
+A poihter to the key is returned, 0 on error.
+If
+.I "key == 0"
+then space is allocated via
+.IR malloc (3).
+Key specific attribute
+.I name=value
+pairs are copied into
+.I attr
+if
+.IR "attr != 0" .
+.PP
+.L pathpath
+constructs in
+.I path
+a path to
+.I p
+with
+.IR access (2)
+mode
+.I mode
+using the directories from
+.LR pathbin() .
+If \fIa != 0\fP then
+.IR a ,
+.IR argv [0]
+(if available via
+.IR optget (3)),
+and the
+.L _
+environment variable (set by
+.IR ksh (1) )
+are used for related root searching.
+If
+.I p
+also contains a
+.L /
+then
+.I ../p
+is searched for.
+.PP
+.L pathprobe
+generates in
+.I path
+the full path name of the
+.I tool
+specific
+.IR probe (1)
+information file for the
+.I lang
+langauge processor
+.IR proc .
+If
+.I "path == 0"
+then space is allocated via
+.IR malloc (3).
+Probe attribute
+.I name=value
+pairs are copied into
+.I attr
+if
+.IR "attr != 0" .
+.I op
+may be one of:
+.TP
+.B \-1
+return the path name with no access checks or generation
+.TP
+.B 0
+message emitted information must be generated via
+.IR probe (1)
+.TP
+.B 1
+no message emitted information must be probed via
+.IR probe (1)
+.PP
+0 is returned if the information does not exist and cannot be generated.
+.PP
+.L pathrepl
+does an in-place replacement of the first occurrence of
+.I /match/
+with
+.I /replace/
+in
+.IR path .
+.PP
+.L pathsetlink
+creates a symbolic link
+.I text
+in the path
+.IR name .
+See
+.L pathgetlink
+above for weird
+.IR universe (1)
+interactions hidden by this routine.
+.PP
+.L pathshell
+returns a pointer to the pathname for the shell for the current process.
+The
+.L SHELL
+environment variable is first consulted, but is rejected under suspicious
+ownership/setuid conditions of if it seems to point to
+.IR csh (1) ;
+otherwise
+.L confstr(_CS_SHELL,...)
+is used.
+A valid string is always returned.
+.PP
+.L pathstat
+first tries
+.LI stat( path,st )
+and if that fails it tries
+.LI lstat( path,st ).
+The
+.L stat
+or
+.L lstat
+return value is returned.
+.PP
+.L pathtemp
+generates in
+.I path
+a temporary file path name of the form
+.I dir/pfx<pid>.<suf>
+where the length of
+.IR pfx ,
+if !=0, is limited to 5, the length of
+.I <pid>
+(the base 64 representation of the current process id)
+is limited to 3, and
+.I <suf>
+(an internally generated suffix that avoid file confilicts)
+is limited to 3.
+The generated path name conforms to the classic UNIX 14 char and the DOS
+.LR 8.3
+limitations.
+Both
+.I dir
+and
+.I pfx
+may be
+.LR 0 .
+.IR access (2)
+is used to avoid file conflicts but the generated path name is not created,
+so you could lose in a race.
+.SH "SEE ALSO"
+3d(1), access(2), confstr(3), fs3d(3), lstat(2), stat(2)
diff --git a/usr/src/lib/libast/common/man/preroot.3 b/usr/src/lib/libast/common/man/preroot.3
new file mode 100644
index 0000000000..025fc221c0
--- /dev/null
+++ b/usr/src/lib/libast/common/man/preroot.3
@@ -0,0 +1,151 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH PREROOT 3
+.SH NAME
+preroot \- preroot support
+.SH SYNOPSIS
+.EX
+#include <preroot.h>
+
+char* getpreroot(char* \fIpath\fP, char* \fIcmd\fP);
+int ispreroot(char* \fIdir\fP);
+int realopen(char* \fIpath\fP, int \fImode\fP, int \fIperm\fP);
+void setpreroot(char** \fIargv\fP, char* \fIdir\fP);
+.EE
+.SH DESCRIPTION
+The
+.I preroot
+routines manipulate the process preroot.
+.I preroot
+is a kernel supported per-process two level viewpath.
+All pathnames rooted at
+.L /
+are first searched for in the process preroot directory
+and then in the system root directory.
+Setting the process preroot is a priveleged operation controlled by the
+.IR /etc/preroot (1)
+command.
+.PP
+.L <preroot.h>
+defines the symbol
+.B FS_PREROOT
+for those systems that support preroot.
+The following routines are valid only when
+.B FS_PREROOT
+is defined:
+.TP
+.L getpreroot
+returns a pointer to the absolute pathname of the preroot directory
+for the executable
+.IR cmd .
+The result is placed in
+.IR path .
+If
+.I path
+is
+.B 0
+then
+.IR malloc (3)
+is used to allocate the pathname space.
+.B 0
+is returned if
+.I cmd
+has no preroot or if an error was encountered.
+In this case
+.I errno
+is set to indicate the error.
+.TP
+.L ispreroot
+Non-zero is returned if
+.I dir
+is the current process preroot.
+If
+.I dir
+is
+.B 0
+then non-zero is returned if the current process has a preroot.
+.TP
+.L realopen
+temporarily disables the process preroot and does an
+.IR open (3)
+relative to the system root directory.
+The return value from
+.I open
+is returned.
+If there is no preroot then
+.I realopen
+is equivalent to
+.IR open .
+.TP
+.L setpreroot
+calls
+.IR execvp (3)
+as
+.L "execvp(a\fIrgv\fP[0],\fIargv\fP)"
+with the process preroot set to
+.IR dir .
+.I argv
+must be a
+.BR 0 -terminated
+argument array.
+If
+.I argv
+is
+.B 0
+then the value of
+.I opt_argv
+from
+.IR optget (3)
+is used.
+.L setpreroot
+returns immediately if
+.I dir
+is already the process preroot.
+.SH "SEE ALSO"
+/etc/preroot(1)
+.SH BUGS
+Preroot semantics should be preserved when reading directories.
+The
+.I ast
+.IR directory (3)
+routines do this.
+.IR 3d (1)
+viewpathing does
+.I preroot
+the right way.
diff --git a/usr/src/lib/libast/common/man/proc.3 b/usr/src/lib/libast/common/man/proc.3
new file mode 100644
index 0000000000..64c1a6ef49
--- /dev/null
+++ b/usr/src/lib/libast/common/man/proc.3
@@ -0,0 +1,319 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH PROC 3
+.SH NAME
+proc \- process control routines
+.SH SYNOPSIS
+.EX
+#include <proc.h>
+
+Proc_t* procopen(const char* \fIcommand\fP, char** \fIargv\fP, char** \fIenvv\fP, long* \fIopv\fP, long \fIflags\fP);
+int procfree(Proc_t* \fIproc\fP);
+int procclose(Proc_t* \fIproc\fP);
+int procrun(const char* \fIcommand\fP, char** \fIargv\fP);
+.EE
+.SH DESCRIPTION
+These routines provide a portable interface to process creation and execution.
+They work on systems with
+.IR fork (2)
+and
+.IR exec (2)
+as well as on systems with only
+.IR spawnve (2)
+or
+.IR spanwveg (3).
+.PP
+.L procopen
+runs
+.I command
+with arguments
+.IR argv ,
+environment modifications in
+.IR envv ,
+file descriptor, signal and process group operations in
+.I opv
+and flags in
+.IR flags .
+.PP
+.I command
+is searched for using the
+.L PATH
+environment variable from the calling environment.
+If
+.I command
+is
+.L 0
+then the current shell is used (see
+.IR pathshell (3)).
+If
+.I envv
+is not
+.L 0
+then it is a
+.L 0
+terminated vector of
+\fIname\fP[=\fIvalue\fP]
+strings that are added to the
+.I command
+environment using
+.IR setenviron (3).
+If
+.I name
+appears in the parent environment then its value is replaced with the new
+.IR value .
+If
+.RI = value
+is omitted then
+.I name
+is removed from the child environment.
+The
+.L _
+environment variable is set to contain the pathname for
+.I command
+and will appear at the top of the child environment.
+.PP
+If
+.I opv
+is not
+.L 0
+then it is a 0 terminaled vector of operations to perform.
+In the following
+.I context
+is a combination of
+.L PROC_FD_CHILD
+and
+.L PROC_FD_PARENT
+for the child and parent process context respectively.
+Valid operations are:
+.TP
+\f5PROC_FD_CLOSE(\fIfd\fP,\fIcontext\fP)\fR
+The file descriptor
+.I fd
+is closed in
+.IR context .
+.TP
+\f5PROC_FD_DUP(\fIfrom\fP,\fIto\fP,\fIcontext\fP)\fR
+The file descriptor
+.I from
+is
+.IR dup (2)'d
+into the file descriptor
+.I to
+in
+.IR context .
+.TP
+\f5PROC_SIG_DFL(\fIsig\fP)\fR
+The signal handler for
+.I sig
+is set to
+.L SIG_DFL
+in the child context.
+.TP
+\f5PROC_SIG_IGN(\fIsig\fP)\fR
+The signal handler for
+.I sig
+is set to
+.L SIG_IGN
+in the child context.
+.TP
+\f5PROC_SYS_PGRP(\fIpgid\fP)\fR
+The child process group is set to
+.IR pgid .
+.I pgid
+may have the following values:
+.TP
+.L <0
+The child process becomes a session leader.
+.TP
+.L 0
+The child process is in the parent process group.
+.TP
+.L 1
+The child process becomes a process group leader.
+.TP
+.L >1
+The child process joins the process group
+.IR pgid .
+.TP
+\f5PROC_SYS_UMASK(\fImask\fP)\fR
+The child process group file creation mask is set to
+.IR mask .
+.PP
+.I flags
+is the inclusive-or of the following:
+.TP
+.L PROC_ARGMOD
+.I "argv[-1]"
+and
+.I "argv[0]"
+may be modified.
+This is an optimization that avoids an environment vector
+.I realloc(3)
+when
+.I command
+is a shell script.
+.TP
+.L PROC_BACKGROUND
+Standard shell
+.L &
+setup is done for the child process.
+.TP
+.L PROC_CLEANUP
+Parent process redirection file discriptors are closed on error.
+.TP
+.L PROC_DAEMON
+Standard daemon setup is done for the child process.
+.TP
+.L PROC_ENVCLEAR
+The child environment is cleared before
+.I envv
+is added.
+.TP
+.L PROC_GID
+The child effective group id is set to the real group id.
+.TP
+.L PROC_IGNORE
+Parent pipe errors are ignored.
+.TP
+.L PROC_OVERLAY
+The current process is overlayed by
+.I command
+if possible
+(i.e., the
+.IR fork (2)
+call is omitted).
+.TP
+.L PROC_PARANOID
+Paranoid:
+.I command
+is searched using the default standard
+.LR PATH ;
+the child environment variable
+.L PATH
+is set to the default standard;
+the
+.L PROC_GID
+and
+.L PROC_UID
+modes are set;
+only
+.L /bin/sh
+is used to execute
+.I command
+if it is a shell script.
+.TP
+.L PROC_PRIVELEGED
+If the effective user id is
+.L 0
+then the child real user id is set to
+.L 0
+and the child real group id is set to the effective group id.
+.TP
+.L PROC_READ
+.I proc.rfd
+is connected to
+.IR command 's
+standard output.
+.TP
+.L PROC_SESSION
+The child process becomes a session group leader.
+(Equivalent to the
+.I opv
+entry
+.LR PROC_SYS_PGRP(-1) .)
+.TP
+.L PROC_UID
+The child effective user id is set to the real user id.
+.TP
+.L PROC_WRITE
+.I proc.wfd
+is connected to
+.IR commands 's
+standard input.
+.PP
+The return value is a pointer to a structure with the following members:
+.TP
+.L "pid_t \fIpid\fP"
+The child process id.
+.TP
+.L "pid_t \fIpgrp\fP"
+The child process group.
+.TP
+.L "int \fIrfd\fP"
+A read file descriptor connected to
+.IR command 's
+standard output.
+.TP
+.L "int \fIwfd\fP"
+A write file descriptor connected to
+.IR command 's
+standard input.
+.PP
+If an error occurs then
+.L 0
+is returned.
+.PP
+.L procclose
+waits for the process
+.I proc
+to complete and then closes the command stream
+.IR proc .
+The command exit status is returned.
+.L -1
+is returned if the child portion of
+.L procopen
+failed.
+.PP
+.L procfree
+frees the process stream without waiting for
+.I command
+to complete.
+Presumably some other mechanism will be used to wait for
+.IR proc.pid .
+.PP
+.L procrun
+combines
+.L procopen
+and
+.L procclose
+with the flags
+.L PROC_GID|PROC_UID
+and returns the command exit status.
+.SH "SEE ALSO"
+popen(3), sfpopen(3), spawnveg(3), system(3)
diff --git a/usr/src/lib/libast/common/man/re.3 b/usr/src/lib/libast/common/man/re.3
new file mode 100644
index 0000000000..2e1010e434
--- /dev/null
+++ b/usr/src/lib/libast/common/man/re.3
@@ -0,0 +1,214 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH RE 3
+.SH NAME
+recomp, reexec, ressub, refree, reerror \(mi regular expression library
+.SH SYNOPSIS
+.EX
+#include <re.h>
+
+Re_program_t* recomp(char* \fIpattern\fP, int \fIflags\fP);
+int reexec(Re_program_t* \fIre\fP, char* \fIsource\fP);
+void ressub(Re_program_t* \fIre\fP, Sfio_t* \fIsp\fP, char* \fIold\fP, char* \fInew\fP, int \fIflags\fP);
+void reerror(char* \fImessage\fP);
+void refree(Re_program_t* \fIre\fP);
+.EE
+.SH DESCRIPTION
+.L recomp
+compiles a regular expression in
+.I pattern
+and returns a pointer to the compiled regular expression.
+The space is allocated by
+.IR malloc (3)
+and may be released by
+.LR refree .
+Regular expressions are as in
+.IR egrep (1)
+except that newlines are treated as ordinary
+characters and
+.L $
+matches the end of a null-terminated string.
+.I flags
+may be
+.L RE_EDSTYLE
+which specifies
+.IR ed (1)
+style special characters,
+.LR \e( ,
+.LR \e) ,
+.LR \e? ,
+.L \e+
+and
+.L \e|
+for the
+.IR egrep (1)
+.LR ( ,
+.LR ) ,
+.LR ? ,
+.L +
+and
+.LR | ,
+respectively.
+.PP
+.L reexec
+matches the null-terminated
+.I source
+string against the compiled regular expression
+.I re
+from a previous call to
+.LR recomp .
+If it matches,
+.L reexec
+returns a non-zero value.
+If
+.I flags
+is
+.L RE_MATCH
+then the array
+.I re\->match
+is filled with character pointers to the substrings of
+.I source
+that correspond to the
+parenthesized subexpressions of
+.IR pattern :
+.I re\->match[i].sp
+points to the beginning and
+.I re\->match[i].ep
+points just beyond
+the end of substring
+.IR i .
+(Subexpression
+.I i
+begins at the
+.IR i th
+matched left parenthesis, counting from 1.)
+Pointers in
+.I re\->match[0]
+pick out the substring that corresponds to
+the entire regular expression.
+Unused elements of
+.I re\->match
+are filled with zeros.
+Matches involving
+.LR * ,
+.LR + ,
+and
+.L ?
+are extended as far as possible.
+A maximum of 9 subexpressions will be matched.
+The structure of elements of
+.I re\->match
+is:
+.nf
+.ta 8n
+ typedef struct
+ {
+ char* sp;
+ char* ep;
+ } rematch;
+.fi
+.LP
+.L ressub
+places in the
+.IR sfio (3)
+stream
+.I sp
+a substitution instance of
+.I old
+to
+.I new
+in
+.I source
+in the context of the last
+.L reexec
+performed on
+.IR re\->match .
+Each instance of
+.LI \e n ,
+where
+.I n
+is a digit, is replaced by the
+string delimited by
+.LI re\->match[ n ].sp
+and
+.LI re\->match[ n ].ep .
+Each instance of
+.L &
+is replaced by the string delimited by
+.I re\->match[0].sp
+and
+.IR re\->match[0].ep .
+If
+.L RE_ALL
+is set in
+.I flags
+then all occurrences of
+.I old
+are replaced by
+.IR new .
+If
+.L RE_LOWER
+.RL [ RE_UPPER ]
+is set in
+.I flags
+then
+.I old
+is converted to lower [upper] case.
+.LP
+.L reerror,
+called whenever an error is detected in
+.L recomp,
+.L reexec,
+or
+.L ressub,
+writes the string
+.I msg
+on the standard error file and exits.
+.L reerror
+may be replaced to perform
+special error processing.
+.SH DIAGNOSTICS
+.L recomp
+returns 0 for an invalid expression or other failure.
+.L reexec
+returns 1 if
+.I source
+is accepted, 0 otherwise.
+.SH "SEE ALSO"
+ed(1), grep(1), expr(1)
diff --git a/usr/src/lib/libast/common/man/setenviron.3 b/usr/src/lib/libast/common/man/setenviron.3
new file mode 100644
index 0000000000..818f7fc0d4
--- /dev/null
+++ b/usr/src/lib/libast/common/man/setenviron.3
@@ -0,0 +1,79 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH LIBAST 3
+.SH NAME
+setenviron \- set environment value
+.SH SYNOPSIS
+.EX
+#include <ast.h>
+
+char* setenviron(const char* \fIkey\fP);
+.EE
+.SH DESCRIPTION
+.L setenviron
+controls environment
+.I name=value
+pairs.
+.L setenviron("\fIname=value\fP")
+adds
+.I name
+to the environment and returns a pointer to a
+.IR strdup (3)
+copy of
+.IR name=value .
+.L setenviron("\fIname\fP")
+removes
+.I name
+from the environment and returns the empty string.
+.L setenviron(0)
+reserves a few slots in an internal array and is usually called by
+a parent process that expects many children.
+0 is returned on error.
+.L setenviron
+preserves the
+.IR ksh (1)
+convention of
+.L _
+as the first environment variable name.
+.SH "SEE ALSO"
+env(1), exec(2)
+.SH BUGS
+POSIX will eventually settle on an interface.
+It has already picked a few of the names we did in .2 drafts.
+This is about the third name change for ours.
diff --git a/usr/src/lib/libast/common/man/sfdisc.3 b/usr/src/lib/libast/common/man/sfdisc.3
new file mode 100644
index 0000000000..d669a81217
--- /dev/null
+++ b/usr/src/lib/libast/common/man/sfdisc.3
@@ -0,0 +1,118 @@
+.fp 5 CW
+.TH SFDISC 3 "16 June 1993"
+.SH NAME
+\fBsfdisc\fR \- \fBsfio\fP disciplines
+.SH SYNOPSIS
+.de Tp
+.fl
+.ne 2
+.TP
+..
+.de Ss
+.fl
+.ne 2
+.SS "\\$1"
+..
+.ta 1.0i 2.0i 3.0i 4.0i 5.0i
+.nf
+.ft 5
+#include <sfdisc.h>
+
+extern Sfdisc_t* dcnewskable(Sfio_t* f);
+extern int dcdelskable(Sfdisc_t* disc);
+
+extern Sfdisc_t* dcnewtee(Sfio_t* tee);
+extern int dcdeltee(Sfdisc_t* disc);
+
+extern Sfdisc_t* dcnewfilter(char* cmd);
+extern int dcdelfilter(Sfdisc_t* disc);
+
+extern Sfdisc_t* dcnewsubstream(Sfio_t* f, long offset, long extent);
+extern int dcdelsubstream(Sfdisc_t* disc);
+
+extern Sfdisc_t* dcnewlzw(void);
+extern int dcdellzw(Sfdisc_t* disc);
+
+extern Sfdisc_t* dcnewunion(Sfio_t** flist, int n);
+extern int dcdelunion(Sfdisc_t* disc);
+.ft 1
+.fi
+.SH DESCRIPTION
+.PP
+I/O disciplines are used to extend the data processing power of
+\fIsfio\fP streams. The convention for using the disciplines
+in this package is to use the call \f5dcnewXXX()\fP to create
+a discipline of the type \f5XXX\fP and to use \f5dcdelXXX()\fP
+to destroy it.
+A discipline is enable by inserting it into the desired
+stream using the \f5sfdisc()\fP call. A discipline can be used on only
+one stream. It is unsafe to share a discipline on two or more streams
+since the discipline may maintain states between successive IO calls.
+For multiple uses, \f5dcnewXXX()\fP should be used
+to create a distinct discipline for each stream.
+Each discipline structure is equipped with an exception handler
+that causes self-destruction when the associated stream is closed.
+.PP
+.Ss " Sfdisc_t* dcnewskable(Sfio_t* f);"
+.Ss " int dcdelskable(Sfdisc_t* disc);"
+\f5dcnewskable()\fP creates a discipline that when inserted
+on the stream \f5f\fP will ensure that \f5f\fP is seekable.
+If \f5f\fP is originally unseekable, data will be shadowed
+in a temporary file stream to allow seekability.
+\f5dcnewskable()\fP returns the discipline on success and \f5NULL\fP on failure.
+
+.Ss " Sfdisc_t* dcnewtee(Sfio_t* tee);"
+.Ss " int dcdeltee(Sfdisc_t* disc);"
+\f5dcnewtee()\fP creates a discipline that
+when inserted into a stream \f5f\fP will duplicate to the stream \f5tee\fP
+any data written to \f5f\fP.
+\f5dcnewtee()\fP returns the discipline on success and \f5NULL\fP on failure.
+
+.Ss " Sfdisc_t* dcnewfilter(char* cmd);"
+.Ss " int dcdelfilter(Sfdisc_t* disc);"
+\f5dcnewfilter()\fP creates a discipline that
+when inserted into a stream \f5f\fP will run the command \f5cmd\fP
+to process any input data before making it available to the application.
+For example, \f5dcnewfilter("uncompress")\fP is an equivalent but slower
+alternative to the lzw discipline below.
+\f5dcnewfilter()\fP returns the discipline on success and \f5NULL\fP on failure.
+
+.Ss " Sfdisc_t* dcnewsubstream(Sfio_t* base, long offset, long extent);"
+.Ss " int dcdelsubstream(Sfdisc_t* disc);"
+\f5dcnewsubstream()\fP creates a discipline that
+reserves a portion of the stream \f5base\fP starting at \f5offset\fP
+with length \f5extent\fP and makes this portion appear as if it is
+a stream. When this discipline is inserted into a stream, it will make
+cause all IO operations on this stream to take place in the reserved
+portion of the \f5base\fP stream.
+\f5dcnewsubstream()\fP returns the discipline on success and \f5NULL\fP on failure.
+
+.Ss " Sfdisc_t* dcnewlzw(void);
+.Ss " int dcdellzw(Sfdisc_t* disc);"
+\f5dcnewlzw()\fP creates a discipline that when inserted into
+a stream \f5f\fP will run the \fBuncompress\fP algorithm
+on input data from \f5f\fP before making it available to the
+application. This is useful to allow applications to process
+data from a file packed with the UNIX \fBcompress\fP utility
+as if the data is in plain text.
+\f5dcnewlzw()\fP returns the discipline on success and \f5NULL\fP on failure.
+
+.Ss " Sfdisc_t* dcnewunion(Sfio_t** list, int n);
+.Ss " int dcdelunion(Sfdisc_t* disc);"
+\f5dcnewunion()\fP creates a discipline that concatenates
+input data from all \f5n\fP streams in \f5list\fP.
+When inserted into a stream \f5f\fP, this discipline will cause
+all input operations on \f5f\fP to come from the merged data stream.
+\f5dcnewunion()\fP returns the discipline on success and \f5NULL\fP on failure.
+
+.SH ACKNOWLEDGEMENTS
+Dave Korn contributed the substream discipline.
+Jim Arnold contributed the lzw discipline.
+
+.SH NOTES
+Since we are not sure of the legal responsibilities concerning the lzw patent,
+the lzw discipline is not currently distributed with any release of sfio
+outside of AT&T.
+
+.SH AUTHOR
+Kiem-Phong Vo, kpv@research.att.com.
diff --git a/usr/src/lib/libast/common/man/sfio.3 b/usr/src/lib/libast/common/man/sfio.3
new file mode 100644
index 0000000000..8f99e72dca
--- /dev/null
+++ b/usr/src/lib/libast/common/man/sfio.3
@@ -0,0 +1,2311 @@
+.fp 5 CW
+.TH SFIO 3 "01 February 2005"
+.SH NAME
+\fBsfio\fR \- safe/fast string/file input/output
+.SH SYNOPSIS
+.de Tp
+.fl
+.ne 3
+.TP
+..
+.de Ss
+.fl
+.ne 3
+.SS "\\$1"
+..
+.ta 1.0i 2.0i 3.0i 4.0i 5.0i
+.Ss "LIBRARIES"
+.nf
+.ft 5
+#include <sfio.h>
+
+libsfio.a -lsfio
+libstdio.a -lstdio
+libsfio-mt.a -lsfio-mt
+libstdio-mt.a -lstdio-mt
+.ft 1
+.fi
+.Ss "DATA TYPES"
+.nf
+.ft 5
+Void_t;
+Sfoff_t;
+Sflong_t;
+Sfulong_t;
+Sfdouble_t;
+
+Sfio_t;
+
+Sfdisc_t;
+ssize_t (*Sfread_f)(Sfio_t*, Void_t*, size_t, Sfdisc_t*);
+ssize_t (*Sfwrite_f)(Sfio_t*, const Void_t*, size_t, Sfdisc_t*);
+Sfoff_t (*Sfseek_f)(Sfio_t*, Sfoff_t, int, Sfdisc_t*);
+int (*Sfexcept_f)(Sfio_t*, int, Void_t*, Sfdisc_t*);
+
+Sffmt_t;
+int (*Sffmtext_f)(Sfio_t*, Void_t*, Sffmt_t*);
+int (*Sffmtevent_f)(Sfio_t*, int, Void_t*, Sffmt_t*);
+
+SFIO_VERSION
+.ft 1
+.fi
+.Ss "BIT FLAGS"
+.nf
+.ft 5
+SF_STRING
+SF_READ
+SF_WRITE
+SF_APPENDWR (SF_APPEND)
+SF_LINE
+SF_SHARE
+SF_PUBLIC
+SF_MALLOC
+SF_STATIC
+SF_IOCHECK
+SF_WHOLE
+SF_MTSAFE
+SF_IOINTR
+.ft 1
+.fi
+.Ss "OPENING/CLOSING STREAMS"
+.nf
+.ft 5
+Sfio_t* sfnew(Sfio_t* f, Void_t* buf, size_t size, int fd, int flags);
+Sfio_t* sfopen(Sfio_t* f, const char* string, const char* mode);
+Sfio_t* sfpopen(Sfio_t* f, const char* cmd, const char* mode);
+Sfio_t* sftmp(size_t size);
+int sfclose(Sfio_t* f);
+
+
+.ft 1
+.fi
+.Ss "THREAD SAFETY"
+.nf
+.ft 5
+int sfmutex(Sfio_t* f, int type);
+
+SFMTX_LOCK
+SFMTX_TRYLOCK
+SFMTX_UNLOCK
+SFMTX_CLRLOCK
+.ft 1
+.fi
+.Ss "INPUT/OUTPUT OPERATIONS"
+.nf
+.ft 5
+int sfgetc(Sfio_t* f);
+int sfputc(Sfio_t* f, int c);
+int sfnputc(Sfio_t* f, int c, int n);
+int sfungetc(Sfio_t* f, int c);
+
+Sfulong_t sfgetm(Sfio_t* f, Sfulong_t max);
+int sfputm(Sfio_t* f, Sfulong_t v, Sfulong_t max);
+Sfulong_t sfgetu(Sfio_t* f);
+int sfputu(Sfio_t* f, Sfulong_t v);
+Sflong_t sfgetl(Sfio_t* f);
+int sfputl(Sfio_t* f, Sflong_t v);
+Sfdouble_t sfgetd(Sfio_t* f);
+int sfputd(Sfio_t* f, Sfdouble_t v);
+
+char* sfgetr(Sfio_t* f, int rsc, int type);
+ssize_t sfputr(Sfio_t* f, const char* s, int rsc);
+Sfoff_t sfmove(Sfio_t* fr, Sfio_t* fw, Sfoff_t n, int rsc);
+
+ssize_t sfread(Sfio_t* f, Void_t* buf, size_t n);
+ssize_t sfwrite(Sfio_t* f, const Void_t* buf, size_t n);
+Sfoff_t sfseek(Sfio_t* f, Sfoff_t offset, int type);
+Void_t* sfreserve(Sfio_t* f, ssize_t n, int type);
+.ft 1
+.fi
+.Ss "DATA FORMATTING"
+.nf
+.ft 5
+int sfscanf(Sfio_t* f, const char* format, ...);
+int sfsscanf(const char* s, const char* format, ...);
+int sfvsscanf(const char* s, const char* format, va_list args);
+int sfvscanf(Sfio_t* f, const char* format, va_list args);
+
+int sfprintf(Sfio_t* f, const char* format, ...);
+char* sfprints(const char* format, ...);
+char* sfvprints(const char* format, va_list args);
+ssize_t sfaprints(char** sp, const char* format, ...);
+ssize_t sfvaprints(char** sp, const char* format, va_list args);
+int sfsprintf(char* s, int n, const char* format, ...);
+int sfvsprintf(char* s, int n, const char* format, va_list args);
+int sfvprintf(Sfio_t* f, const char* format, va_list args);
+
+Sffmt_t;
+
+SFFMT_LEFT
+SFFMT_SIGN
+SFFMT_BLANK
+SFFMT_ZERO
+SFFMT_THOUSAND
+SFFMT_LONG
+SFFMT_LLONG
+SFFMT_SHORT
+SFFMT_LDOUBLE
+SFFMT_IFLAG
+SFFMT_ALTER
+SFFMT_SKIP
+SFFMT_ARGPOS
+SFFMT_VALUE
+
+int (*Sffmtext_f)(Sfio_t* f, Void_t* v, Sffmt_t* fe);
+int (*Sffmtevent_f)(Sfio_t* f, int type, Void_t* v, Sffmt_t* fe);
+void va_copy(va_list to, va_list fr);
+long sffmtversion(Sffmt_t* fe, type);
+.ft 1
+.fi
+.Ss "BUFFERING, SYNCHRONIZATION"
+.nf
+.ft 5
+Void_t* sfsetbuf(Sfio_t* f, Void_t* buf, size_t size);
+int sfsync(Sfio_t* f);
+int sfpoll(Sfio_t** flist, int n, int timeout);
+Sfio_t* sfpool(Sfio_t* f, Sfio_t* poolf, int mode);
+int sfpurge(Sfio_t* f);
+.ft 1
+.fi
+.Ss "DISCIPLINE, EVENT HANDLING"
+.nf
+.ft 5
+Sfdisc_t* sfdisc(Sfio_t* f, Sfdisc_t* disc);
+int sfraise(Sfio_t* f, int type, Void_t* data);
+ssize_t sfrd(Sfio_t* f, Void_t* buf, size_t n, Sfdisc_t* disc);
+ssize_t sfwr(Sfio_t* f, const Void_t* buf, size_t n, Sfdisc_t* disc);
+Sfoff_t sfsk(Sfio_t* f, Sfoff_t offset, int type, Sfdisc_t* disc);
+
+SF_NEW
+SF_READ
+SF_WRITE
+SF_SEEK
+SF_CLOSING (SF_CLOSE)
+SF_DPUSH
+SF_DPOP
+SF_DPOLL
+SF_DBUFFER
+SF_SYNC
+SF_PURGE
+SF_FINAL
+SF_READY
+SF_LOCKED
+SF_ATEXIT
+SF_EVENT
+.ft 1
+.fi
+.Ss "STREAM CONTROL"
+.nf
+.ft 5
+int sfresize(Sfio_t* f, Sfoff_t size);
+int sfset(Sfio_t* f, int flags, int i);
+int sfsetfd(Sfio_t* f, int fd);
+Sfio_t* sfstack(Sfio_t* base, Sfio_t* top);
+Sfio_t* sfswap(Sfio_t* f1, Sfio_t* f2);
+.ft 1
+.fi
+.Ss "STREAM INFORMATION"
+.nf
+.ft 5
+Sfoff_t sfsize(Sfio_t* f);
+Sfoff_t sftell(Sfio_t* f);
+ssize_t sfvalue(Sfio_t* f);
+int sffileno(Sfio_t* f);
+
+int sfstacked(Sfio_t* f);
+int sfeof(Sfio_t* f);
+int sferror(Sfio_t* f);
+int sfclrerr(Sfio_t* f);
+int sfclrlock(Sfio_t* f);
+
+int sfnotify(void (*notify)(Sfio_t* f, int type, int fd));
+.ft 1
+.fi
+.Ss "MISCELLANEOUS FUNCTIONS"
+.nf
+.ft 5
+ssize_t sfmaxr(ssize_t maxr, int s);
+ssize_t sfslen();
+int sfulen(Sfulong_t v);
+int sfllen(Sflong_t v);
+int sfdlen(Sfdouble_t v);
+ssize_t sfpkrd(int fd, Void_t* buf, size_t n,
+ int rsc, long tm, int action);
+.ft 1
+.fi
+.Ss "FULL STRUCTURE SFIO_T"
+.nf
+.ft 5
+#include <sfio_t.h>
+#define SFNEW(buf,size,file,flags,disc)
+.ft 1
+.fi
+.Ss "EXAMPLE DISCIPLINES"
+.nf
+.ft 5
+#include <sfdisc.h>
+
+int sfdcdio(Sfio_t* f, size_t bufsize);
+int sfdcdos(Sfio_t* f);
+int sfdcfilter(Sfio_t* f, const char* cmd);
+int sfdcseekable(Sfio_t* f);
+int sfdcslow(Sfio_t* f);
+int sfdcsubstream(Sfio_t* f, Sfio_t* parent,
+ Sfoff_t offset, Sfoff_t extent);
+int sfdctee(Sfio_t* f, Sfio_t* tee);
+int sfdcunion(Sfio_t* f, Sfio_t** array, int n);
+int sfdclzw(Sfio_t* f);
+int sfdcgzip(Sfio_t* f, int flags);
+.ft 1
+.fi
+.Ss "STDIO-COMPATIBILITY"
+.nf
+.ft 5
+#include <stdio.h>
+cc ... -lstdio -lsfio
+cc ... -lstdio-mt -lsfio-mt
+.ft 1
+.fi
+.SH DESCRIPTION
+.PP
+Sfio provides I/O functions to manage buffered streams.
+Each Sfio stream is a \fIfile stream\fP, representing a file (see \f5open(2)\fP),
+or a \fIstring stream\fP, representing a memory segment.
+Beyond the usual I/O operations on streams,
+Sfio provides I/O disciplines for extended data processing,
+stream stacks for recursive stream processing, and
+stream pools for automatic data synchronization.
+Applications can extend the \f5sfprintf()/sfscanf()\fP functions
+to define their own conversion patterns as well as redefine existing ones.
+.PP
+A discipline defines analogues of
+the system calls \f5read(2), write(2)\fP and \f5lseek(2)\fP.
+Such system calls or their discipline replacements are used to process stream data.
+Henceforth, ``\fIsystem call\fP'' will refer to either a system call
+or its discipline replacement.
+.PP
+A system call is said to cause an exception if its return value is non-positive.
+Unless overridden by exception handlers (see \f5sfdisc()\fP),
+an interrupted system call (\f5errno == EINTR\fP on UNIX systems)
+will be automatically reinvoked to continue the ongoing operation.
+.PP
+The buffer of a stream is typically a memory segment allocated via \f5malloc(3)\fP
+or supplied by the application.
+File streams may also use memory mapping (\f5mmap(2)\fP) if that is more efficient.
+When memory mapping is used,
+the underlying file should not be truncated while the stream is active.
+Memory mapping can be turned off using \f5sfsetbuf()\fP.
+.PP
+There are three \fIstandard streams\fP:
+\f5sfstdin\fP for input (file descriptor \f50\fP on UNIX systems),
+\f5sfstdout\fP for normal output (file descriptor \f51\fP), and
+\f5sfstderr\fP for error output (file descriptor \f52\fP).
+
+.PP
+.Ss "LIBRARIES"
+.PP
+This version of Sfio can be built and used for both uni-threaded and multi-threaded
+environments. In the former case, streams are not protected from
+simultaneous accesses by different threads. In the latter case, a stream
+is typically locked with a mutex during access so that another thread
+trying to access the same stream will block until the mutex is released.
+
+A program that does not use multiple threads can link with \fBlibsfio.a\fP
+while a program that uses multiple threads should link with \fBlibsfio-mt.a\fP.
+The libraries \fBlibstdio.a\fP and \fBlibstdio-mt.a\fP provide
+corresponding Stdio functions to link with code already compiled using the
+native header \fBstdio.h\fP instead of the one provided by Sfio.
+
+.PP
+.Ss "DATA TYPES"
+.PP
+.Ss " Void_t*"
+This defines a type suitable to exchange
+data of unknown types between application and Sfio.
+\f5Void_t\fP is a macro defined as \f5void\fP for ANSI-C and C++ and
+\f5char\fP for other compilation environments.
+.PP
+.Ss " Sfoff_t"
+This defines an integral type suitable to address
+the largest possible file extent.
+.PP
+.Ss " Sfulong_t, Sflong_t, Sfdouble_t"
+These are respectively the largest
+unsigned integer, signed integer, and floating point value types on the local platform.
+.PP
+.Ss " Sfio_t"
+This defines the type of a stream handle.
+.PP
+.Ss " Sfdisc_t"
+.Ss " ssize_t (*Sfread_f)(Sfio_t*, Void_t*, size_t, Sfdisc_t*)"
+.Ss " ssize_t (*Sfwrite_f)(Sfio_t*, const Void_t*, size_t, Sfdisc_t*)"
+.Ss " Sfoff_t (*Sfseek_f)(Sfio_t*, Sfoff_t, int, Sfdisc_t*)"
+.Ss " int (*Sfexcept_f)(Sfio_t*, int, Void_t*, Sfdisc_t*)"
+\f5Sfdisc_t\fP defines a stream discipline structure.
+\f5Sfread_f\fP, \f5Sfwrite_f\fP and \f5Sfseek_f\fP are the types
+of discipline functions to replace the system calls:
+\f5read(2)\fP, \f5write(2)\fP and \f5lseek(2)\fP.
+\f5Sfexcept_f\fP is the type of an event-handling function.
+See \f5sfdisc()\fP for more details.
+.PP
+.Ss " Sffmt_t"
+.Ss " int (*Sffmtext_f)(Sfio_t*, Void_t*, Sffmt_t*)"
+.Ss " int (*Sffmtevent_f)(Sfio_t*, int, Void_t*, Sffmt_t*)"
+\f5Sffmt_t\fP defines a formatting environment that can be used
+to extend scanning and printing in the \f5sfprint()/sfscanf()\fP
+functions. \f5Sffmtext_f\fP and \f5Sffmtevent_f\fP define the types
+of extension functions definable in \f5Sffmt_t\fP.
+See \f5Sffmt_t\fP below for more details.
+.PP
+.Ss " SFIO_VERSION"
+This is a macro value of type \f5long int\fP that defines
+the current version number of Sfio. For example, the Sfio2000's
+version number is \f520000515L\fP
+(which also indicates its latest version date: 05/15/2000).
+
+.Ss "BIT FLAGS"
+A number of bit flags control stream operations.
+They are set either at stream initialization or by calling \f5sfset()\fP.
+Following are the flags:
+.Tp
+\f5SF_STRING\fP:
+The stream is memory-based.
+.Tp
+\f5SF_READ\fP, \f5SF_WRITE\fP, \f5SF_APPENDWR\fP (\f5SF_APPEND\fP):
+Flags \f5SF_READ\fP and \f5SF_WRITE\fP indicate readability and writability.
+Flag \f5SF_APPENDWR\fP asserts that the stream is a file opened in append mode
+(see \f5open(2)\fP and \f5fcntl(2)\fP)
+so that data is always output at the end of file.
+On systems without direct support for append mode,
+Sfio uses \f5lseek(2)\fP or its discipline replacement
+to approximate this behavior.
+.Tp
+\f5SF_LINE\fP:
+The stream is line-oriented.
+For a \f5SF_WRITE\fP stream,
+this means that buffered data is flushed
+whenever a new-line character, \f5\en\fP, is output.
+For a \f5SF_READ\fP stream, \f5SF_LINE\fP is only
+significant during calls to functions in the \f5sfscanf()\fP family.
+\f5SF_LINE\fP is set on initialization of
+any stream representing a terminal device.
+.Tp
+\f5SF_SHARE\fP, \f5SF_PUBLIC\fP:
+Flag \f5SF_SHARE\fP means that the underlying file descriptor
+is shared by independent entities (for example, multiple processes).
+
+For a seekable file stream, \f5SF_SHARE\fP means that
+the logical stream and the physical file positions will be made the same
+before a system call to perform physical I/O.
+There are different possibilities.
+If \f5SF_PUBLIC\fP is not set,
+the physical file position is made equal to the logical stream position.
+If \f5SF_PUBLIC\fP is set, there are two cases.
+If the physical file position has changed from its last known position,
+the logical stream position is made equal to the new physical file position.
+Finally, if the physical file location remains the same as its last known position,
+the physical file position is made the same as the logical stream position.
+
+For an unseekable stream (e.g., pipes or terminal devices), if possible,
+\f5SF_SHARE\fP means that
+the block and record I/O operations (\f5sfread()\fP, \f5sfwrite()\fP, \f5sfmove()\fP,
+\f5sfgetr()\fP, \f5sfputr()\fP, \f5sfreserve()\fP, \f5sfscanf()\fP
+and \f5sfvprintf()\fP) will ensure:
+(1) after each writing operation, the stream is synchronized and
+(2) each reading operation only reads the requested amount.
+Note, however, that (2) is not always possible
+without proper OS facilities such as \f5recv(2)\fP or \f5streamio(4)\fP.
+
+A standard stream that is seekable will be initialized with \f5SF_SHARE|SF_PUBLIC\fP.
+.Tp
+\f5SF_MALLOC\fP:
+The stream buffer was obtained via \f5malloc(3)\fP
+and can be reallocated or freed.
+.Tp
+\f5SF_STATIC\fP:
+The stream structure should not be freed when closed (\f5sfclose()\fP).
+This flag is used by an applications that allocate their own
+stream structures. Such applications must use the header file \f5sfio_t.h\fP
+instead of \f5sfio.h\fP.
+.Tp
+\f5SF_IOCHECK\fP:
+If the stream has a discipline exception handler,
+exceptions will be raised in \f5sfsync()\fP, \f5sfpurge()\fP
+or before a system call \f5read(2)\fP or \f5write(2)\fP (see \f5sfdisc()\fP).
+.Tp
+\f5SF_WHOLE\fP:
+This flag guarantees that data written in any single \f5sfwrite()\fP or
+\f5sfputr()\fP call will always be output as a whole to the output device.
+This is useful in certain applications (e.g., networking) where a complex object
+must be output without being split in different system calls.
+Note that the respective stream still buffers data as much as the buffer can accomodate.
+.Tp
+\f5SF_MTSAFE\fP:
+This flag indicates that the respective stream may be accessed by more than one threads.
+A mutex lock will be used to ensure that only one thread at a time can access
+the stream. Note that this flag can only be set at stream opening time
+(see \f5sfopen()\fP, \f5sfpopen()\fP and \f5sfnew()\fP).
+Certain fast macro functions such as \f5sfgetc()\fP and \f5sfputc()\fP will
+no longer behave as macros. Thus, an application that requires such fast macro functions
+should leave \f5SF_MTSAFE\fP off and performs explicit locking with \f5sfmutex()\fP.
+.Tp
+\f5SF_IOINTR\fP:
+This flag indicates that I/O system calls should not be resumed
+after being interrupted by signals. It is useful for
+aborting I/O operations on such interruptions. Note, however,
+than certain operating systems (e.g., BSD Unix systems) may automatically
+resume interrupted system calls outside the scope of the library. On such systems,
+\f5SF_IOINTR\fP will be ineffective.
+
+.PP
+.Ss "OPENING/CLOSING STREAMS"
+.PP
+.Ss " Sfio_t* sfnew(Sfio_t* f, Void_t* buf, size_t size, int fd, int flags)"
+This function creates or renews a stream.
+It returns the new stream on success and \f5NULL\fP on error.
+.Tp
+\f5f\fP:
+If \f5f\fP is \f5NULL\fP, a new stream is created.
+Otherwise, \f5f\fP is reused.
+In this case, if \f5flags\fP does not have \f5SF_EOF\fP,
+\f5f\fP shall be closed via \f5sfclose()\fP before being reused.
+During a stream renewal, buffer, pool and discipline stack are preserved.
+Note that, except for \f5SF_STATIC\fP streams,
+renewing a stream already closed will result in undefined behavior.
+.Tp
+\f5buf\fP, \f5size\fP:
+These determine a buffering scheme.
+See \f5sfsetbuf()\fP for more details.
+.Tp
+\f5fd\fP:
+If \f5SF_STRING\fP is specified in \f5flags\fP, this is ignored.
+Otherwise, \f5fd\fP is a file descriptor (e.g., from \f5open(2)\fP)
+to use for raw data I/O.
+Note that Sfio supports unseekable file descriptors
+opened for both read and write, e.g., sockets.
+.Tp
+\f5flags\fP:
+This is composed from \f5SF_EOF\fP and
+bit values defined in the \fBBIT FLAGS\fP section.
+Note, in particular, that a multi-threaded application should
+set the bit \f5SF_MTSAFE\fP to protect the new stream from
+being simultaneously accessed by multiple threads.
+
+.Ss " Sfio_t* sfopen(Sfio_t* f, const char* string, const char* mode)"
+
+If \f5string\fP is \f5NULL\fP,
+\f5f\fP is a file stream and
+\f5mode\fP does not imply a string stream,
+\f5sfopen()\fP changes the modes of \f5f\fP according to \f5mode\fP.
+In this case, \f5sfopen()\fP returns \f5f\fP on success and \f5NULL\fP on error.
+This somewhat unusual usage of \f5sfopen()\fP is good for
+resetting certain predefined modes in standard streams including
+\fItext/binary\fP and \fIappend\fP that are inherited from some parent process.
+Note also that \f5SF_READ\fP and \f5SF_WRITE\fP can only be reset if the stream
+is not yet initialized.
+
+\f5sfopen()\fP is normally used to create a new stream or renew a stream.
+In this case, it returns the new stream on success and \f5NULL\fP on error.
+Below are the meanings of the arguments:
+.Tp
+\f5f\fP:
+This is treated as in \f5sfnew()\fP.
+.Tp
+\f5string\fP:
+This is a file name or a string to perform I/O on.
+See above for when this is \f5NULL\fP.
+.Tp
+\f5mode\fP:
+This is composed from the set of letters \f5{s, r, w, +, a, b, t, x, m, u}\fP.
+When conflicting options are present in the same \f5mode\fP string,
+the last one will take effect.
+
+\f5s\fP specifies opening a string stream.
+\f5string\fP can be a null-terminated string or \f5NULL\fP.
+Specifying \f5s\fP alone is equivalent to specifying \f5sr\fP.
+If \f5s\fP is not specified, \f5string\fP defines a file name.
+
+\f5r\fP and \f5w\fP specify read and write modes.
+Write mode creates and/or truncates the given file to make an empty file.
+The \f5+\fP modifier indicates that the stream is opened for both read and write.
+
+\f5a\fP specifies append mode, i.e., data is always output at end of file.
+
+\f5b\fP and \f5t\fP specify binary and text modes.
+
+\f5x\fP specifies exclusive mode, i.e.,
+a file opened for writing should not already exist.
+
+\f5m\fP specifies that the stream needs to be protected from
+simultaneous accesses by multiple threads.
+This turns on the bit flag \f5SF_MTSAFE\fP.
+
+\f5u\fP specifies that the stream is guaranteed to be accessed
+by only one thread at a time. The bit flag \f5SF_MTSAFE\fP is left off.
+The absence of option \f5m\fP is the same as the presence of option \f5u\fP.
+
+.Ss " Sfio_t* sfpopen(Sfio_t* f, const char* cmd, const char* mode)"
+This function opens a stream that corresponds to the coprocess \f5cmd\fP.
+The argument \f5mode\fP should be composed from \f5r\fP, \f5w\fP, and \f5+\fP.
+The argument \f5f\fP, if not \f5NULL\fP, is a stream to be renewed (see \f5sfnew()\fP).
+\f5sfpopen()\fP returns the new stream or \f5NULL\fP on error.
+
+The standard input/output of \f5cmd\fP
+is connected to the application via a pipe if the stream is opened for writing/reading.
+If the stream is opened for both reading and writing,
+there will be two different associated file descriptors, one for each type of I/O
+(note the effect on \f5sffileno()\fP).
+
+On opening a coprocess for writing (i.e., \f5mode\fP contains \f5w\fP or \f5+\fP),
+the signal handler for \f5SIGPIPE\fP in the parent application
+will be set to \f5SIG_IGN\fP if it is \f5SIG_DFL\fP at that time.
+This protects the parent application from being accidentally killed
+on writing to a coprocess that closes its reading end.
+Applications that need to detect such write errors should use
+disciplines and exception handlers (see \f5sfdisc()\fP).
+
+The command \f5cmd\fP
+is executed by an \fIinterpreter\fP which is either \f5/bin/sh\fP
+or an executable command defined by the environment variable \f5SHELL\fP.
+In either case, the interpreter is invoked with 2 arguments, respectively \f5-c\fP
+and the given command \f5cmd\fP. When the interpreter is \f5/bin/sh\fP or
+\f5/bin/ksh\fP, \f5sfpopen()\fP may execute the command \f5cmd\fP itself
+if there are no shell meta-characters in \f5cmd\fP.
+
+.Ss " Sfio_t* sftmp(size_t size)"
+This function creates a stream for temporary data.
+It returns the new stream or \f5NULL\fP on error.
+
+A stream created by \f5sftmp()\fP can be completely or partially memory-resident.
+If \f5size\fP is \f5SF_UNBOUND\fP, the stream is a pure string stream.
+If \f5size\fP is zero, the stream is a pure file stream.
+Otherwise, the stream is first created as a string stream but when
+its buffer grows larger than \f5size\fP or on any attempt to change disciplines,
+a temporary file is created.
+Two environment variables, \f5TMPPATH\fP and \f5TMPDIR\fP,
+direct where temporary files are created.
+\f5TMPPATH\fP, if defined,
+specifies a colon-separated set of directories to be
+used in a round-robin fashion to create files.
+If \f5TMPPATH\fP is undefined,
+\f5TMPDIR\fP can be used to specify a single directory to create files.
+If neither of \f5TMPPATH\fP and \f5TMPDIR\fP are defined, \f5/tmp\fP is used.
+
+.Ss " int sfclose(Sfio_t* f)"
+This function closes the stream \f5f\fP and frees its resources.
+\f5SF_STATIC\fP should be used if the stream space is to be preserved.
+If \f5f\fP is the base of a stream stack (see \f5sfstack()\fP),
+all streams on the stack are closed.
+If \f5f\fP is a \f5sfpopen\fP-stream,
+\f5sfclose()\fP waits until the associated command terminates
+and returns its exit status.
+\f5sfclose()\fP returns \f5-1\fP for failure and \f50\fP for success.
+
+\f5SF_READ|SF_SHARE\fP and \f5SF_WRITE\fP streams
+are synchronized before closing (see \f5sfsync()\fP).
+If \f5f\fP has disciplines,
+their exception handlers will be called twice.
+The first exception handler call has the \f5type\fP argument as one of
+\f5SF_CLOSING\fP or \f5SF_NEW\fP (see \f5sfdisc()\fP.)
+The latter, \f5SF_NEW\fP is used when a stream is being closed via \f5sfnew()\fP
+so that it can be renewed.
+The second call uses \f5type\fP as \f5SF_FINAL\fP
+and is done after all closing operations have succeeded but before
+the stream itself is deallocated.
+In either case, if the exception handler returns a negative value,
+\f5sfclose()\fP will immediately return this value.
+If the exception handler returns a positive value,
+\f5sfclose()\fP will immediately return a zero value.
+
+.PP
+.Ss "THREAD SAFETY"
+.PP
+The libraries \f5libsfio.a\fP and \f5libstdio.a\fP (providing binary
+compatibility to Stdio-based code) only support uni-threaded code.
+Multi-threaded applications should link with
+\f5libsfio-mt.a\fP and \f5libstdio-mt.a\fP.
+When this is done, certain platforms may require additional
+thread libraries for linkage. For example, Linux, Irix and Solaris
+require \f5-lpthread\fP while HPUX requires \f5-lcma\fP.
+Aside from linkage differences, the Sfio API remains identical in all cases.
+
+Note that unlike Stdio streams which are in thread-safe mode by default.
+Sfio streams can be opened in either uni-threaded or multi-threaded mode.
+A uni-threaded stream is more efficient than a multi-threaded one.
+For example, functions such as \f5sfgetc()\fP and \f5sfputc()\fP
+remain as macro or inline functions for a uni-threaded stream while
+they will act as full function calls in a multi-threaded case.
+The three standard streams \f5sfstdin/sfstdout/sfstderr\fP
+are in multi-threaded mode by default
+(however, see \f5sfopen()\fP for how this may be changed).
+Other Sfio streams are normally opened uni-threaded unless
+the flag \f5SF_MTSAFE\fP or the option \f5m\fP were specified.
+Stdio-based code can also make a Stdio stream uni-threaded by
+using the option \f5u\fP when opening a file.
+
+.PP
+.Ss "int sfmutex(Sfio_t* f, int type)"
+This function acquires or releases a mutex
+(mutually exclusive) lock on the stream \f5f\fP.
+It can be used by a thread to delineate a sequence of I/O operations
+executed together in some critical section.
+\f5sfmutex()\fP is implicitly used by
+all Sfio operations on a stream with the flag \f5SF_MTSAFE\fP.
+\f5sfmutex()\fP returns \f50\fP on success and some non-zero value on failure.
+
+Each stream has a lock count which starts at \f50\fP.
+When the count is positive, a single thread holds the stream.
+Only this thread can further lock or unlock the stream.
+A different thread attempting to acquire such a locked stream will suspend
+until the lock count returns to \f50\fP.
+Each successful locking operation increases the lock count
+while each successful unlocking operation decreases it,
+thus, allowing nesting of matching lock/unlock operations.
+
+The \f5type\fP argument of \f5sfmutex()\fP takes on the below values:
+.Tp
+\f5SFMTX_LOCK\fP:
+Locking a stream if it is unlocked or increasing the lock count of the stream
+if it is already locked by the same thread.
+.Tp
+\f5SFMTX_TRYLOCK\fP:
+This is the non-blocking version of \f5SFMTX_LOCK\fP.
+If the stream is already locked by a different thread, \f5sfmutex()\fP will
+immediately return with an error status.
+.Tp
+\f5SFMTX_UNLOCK\fP:
+Decreasing the lock count and releasing the stream when the lock count reaches 0.
+An attempt to unlock a stream without a previously successful lock may
+result in undefined behavior in certain implementations.
+The current Sfio implementation returns an error status.
+.Tp
+\f5SFMTX_CLRLOCK\fP:
+Resetting the lock count to \f50\fP and releasing the stream.
+As with \f5SFMTX_LOCK\fP,
+an attempt to clear the lock count without a previously successful lock
+may result in undefined behavior.
+.PP
+.Ss "INPUT/OUPUT OPERATIONS"
+.PP
+.Ss " int sfgetc(Sfio_t* f)"
+.Ss " int sfputc(Sfio_t* f, int c)"
+These functions read/write a byte from/to stream \f5f\fP.
+\f5sfgetc()\fP returns the byte read or \f5-1\fP on error.
+\f5sfputc()\fP returns \f5c\fP on success and \f5-1\fP on error.
+
+.Ss " ssize_t sfnputc(Sfio_t* f, int c, size_t n)"
+This function attempts to write the byte \f5c\fP to \f5f\fP \f5n\fP times.
+It returns the number of bytes actually written or \f5-1\fP on failure.
+
+.Ss " int sfungetc(Sfio_t* f, int c)"
+This function pushes the byte \f5c\fP back into \f5f\fP.
+If \f5c\fP matches the byte immediately before the current position in buffered data,
+the current position is simply backed up (note the effect on \f5sftell()\fP and
+\f5sfseek()\fP). There is no theoretical limit on the number of bytes that
+can be pushed back into a stream. Pushed back bytes not part of
+buffered data will be discarded on any operation that implies
+buffer synchronization.
+\f5sfungetc()\fP returns \f5c\fP on success and \f5-1\fP on failure.
+
+.Ss " Sfulong_t sfgetm(Sfio_t* f, Sfulong_t max)"
+.Ss " int sfputm(Sfio_t* f, Sfulong_t v, Sfulong_t max)"
+These functions read and write \f5Sfulong_t\fP values
+encoded in a portable format given that the values are at most \f5max\fP.
+Portability across a write architecture and a read architecture
+requires that the bit order in a byte is the same on both architectures and
+the written value is storable in an \f5Sfulong_t\fP on the read architecture.
+\f5sfgetm()\fP returns the value read or \f5-1\fP on error.
+\f5sfputm()\fP returns the number of bytes written or \f5-1\fP on error.
+
+.Ss " Sfulong_t sfgetu(Sfio_t* f)"
+.Ss " int sfputu(Sfio_t* f, Sfulong_t v)"
+These functions read and write \f5Sfulong_t\fP values
+in a compact variable-length portable format.
+Portability across a write architecture and a read architecture
+requires that the bit order in a byte is the same on both architectures and
+the written value is storable in an \f5Sfulong_t\fP on the read architecture.
+\f5sfgetu()\fP returns the value read or \f5-1\fP on error.
+\f5sfputu()\fP returns the number of bytes written or \f5-1\fP on error.
+See also \f5sfulen()\fP.
+
+.Ss " Sflong_t sfgetl(Sfio_t* f)"
+.Ss " int sfputl(Sfio_t* f, Sflong_t v)"
+These functions are similar to \f5sfgetu()\fP and \f5sfputu()\fP
+but for reading and writing (signed) \f5Sflong_t\fP values.
+See also \f5sfllen()\fP.
+
+.Ss " Sfdouble_t sfgetd(Sfio_t* f)"
+.Ss " int sfputd(Sfio_t* f, Sfdouble_t v)"
+These functions read and write \f5Sfdouble_t\fP values.
+In this case, portability depends on the input and output architectures
+having the same floating point value representation.
+Values are coded and decoded using \f5ldexp(3)\fP and \f5frexp(3)\fP
+so they are constrained to the sizes supported by these functions.
+See also \f5sfdlen()\fP.
+
+.Ss " char* sfgetr(Sfio_t* f, int rsc, int type)"
+This function reads a record of data ending in the record separator \f5rsc\fP.
+After \f5sfgetr()\fP returns, the length of the record even if it is incomplete
+can be retrieved with \f5sfvalue()\fP.
+\f5sfgetr()\fP returns the record on success and \f5NULL\fP on error.
+See also \f5sfmaxr()\fP for limiting the amount of data read to construct a record.
+
+The \f5type\fP argument is composed of some subset of the below bit flags:
+.Tp
+\f5SF_STRING\fP:
+A null byte will replace the record separator to make the record into a C string.
+Otherwise, the record separator is left alone.
+.Tp
+\f5SF_LOCKR\fP:
+Upon successfully obtaining a record \f5r\fP,
+the stream will be locked from further access until it is released with
+a call \f5sfread(f,r,0)\fP.
+.Tp
+\f5SF_LASTR\fP:
+This should be used only after a failed \f5sfgetr()\fP to retrieve
+the last incomplete record. In this case, \f5rsc\fP is ignored.
+
+.Ss " ssize_t sfputr(Sfio_t* f, const char* s, int rsc)"
+This function writes the null-terminated string \f5s\fP to \f5f\fP.
+If \f5rsc\fP is non-negative, \f5(unsigned char)rsc\fP is output after the string.
+\f5sfputr()\fP returns the number of bytes written or \f5-1\fP on failure.
+
+.Ss " Sfoff_t sfmove(Sfio_t* fr, Sfio_t* fw, Sfoff_t n, int rsc)"
+This function moves objects
+from input stream \f5fr\fP to output stream \f5fw\fP.
+\f5sfmove()\fP returns the number of objects moved or \f5-1\fP on failure.
+
+An object can be either a byte if the record separator argument
+\f5rsc\fP is negative or a record of \f5rsc\fP is non-negative.
+In the latter case, a record is incomplete if it does not end in \f5rsc\fP.
+Generally speaking, a stream can have at most one incomplete record.
+If \f5n\fP is negative, all complete objects of \f5fr\fP will be moved.
+Otherwise, \f5n\fP indicates the number of objects to move.
+If either \f5fr\fP or \f5fw\fP is \f5NULL\fP, it acts
+as if it is a stream corresponding to \f5/dev/null\fP,
+the UNIX device that has no read data and throws away any write data.
+For example, the call \f5sfmove(f,(Sfio_t*)0,(Sfoff_t)(-1),'\en')\fP
+counts the number of complete lines in stream \f5f\fP.
+
+.Ss " ssize_t sfread(Sfio_t* f, Void_t* buf, size_t n)"
+This function reads up to \f5n\fP bytes from \f5f\fP into buffer \f5buf\fP.
+It returns the number of bytes actually read or \f5-1\fP on error.
+
+.Ss " ssize_t sfwrite(Sfio_t* f, const Void_t* buf, size_t n)"
+This function writes \f5n\fP bytes from \f5buf\fP to \f5f\fP.
+If \f5f\fP is \f5SF_STRING\fP, and the buffer is not large enough,
+an \f5SF_WRITE\fP exception shall be raised.
+\f5sfwrite()\fP returns the number of bytes written or \f5-1\fP on failure.
+
+.Ss " Sfoff_t sfseek(Sfio_t* f, Sfoff_t offset, int type)"
+This function sets a new I/O position for \f5f\fP.
+It returns the new position or \f5-1\fP on failure.
+
+If the stream is a \f5SF_STRING\fP stream and the new
+address is beyond the current buffer extent,
+an \f5SF_SEEK\fP exception will be raised (see \f5sfdisc()\fP).
+
+The new position is determined based on \f5offset\fP and
+\f5type\fP which is composed from the bit flags:
+.Tp
+\f50\fP or \f5SEEK_SET\fP:
+\f5offset\fP is the desired position.
+.Tp
+\f51\fP or \f5SEEK_CUR\fP:
+\f5offset\fP is relative to the current position (see \f5SF_PUBLIC\fP below).
+.Tp
+\f52\fP or \f5SEEK_END\fP:
+\f5offset\fP is relative to the physical end of file.
+.Tp
+\f5SF_SHARE\fP:
+The stream is treated as if it has the control bit \f5SF_SHARE\fP on.
+This implies that a system call seek will be done to ensure that the
+location seeking to is valid.
+.Tp
+\f5SF_PUBLIC\fP:
+The stream is treated as if it has the control bit \f5SF_PUBLIC\fP on.
+If the physical file position has changed from its last known location,
+the current position is taken as the new physical position.
+Otherwise, the current position is the logical stream position.
+
+.Ss " Void_t* sfreserve(Sfio_t* f, ssize_t n, int type)"
+This function reserves a data block from the stream \f5f\fP.
+It returns the reserved data block on success and \f5NULL\fP on failure.
+
+If \f5f\fP is a \f5SF_READ\fP stream, the data block is a segment of input data.
+If \f5f\fP is a \f5SF_WRITE\fP stream, the data block is a buffer
+suitable for writing output data.
+For consistency, if \f5f\fP is opened with \f5SF_READ|SF_WRITE\fP,
+it will normally be treated as if it is a \f5SF_READ\fP stream
+(see \f5sfset()\fP for forcing a particular mode) but the returned
+buffer can also be written into (more below).
+However, it is possible to bias to \f5SF_WRITE\fP when the \f5type\fP
+argument is non-negative by adding the \f5SF_WRITE\fP bit \f5type\fP.
+In any case, a reserved data block is guaranteed to be valid only until
+a future access to the stream \f5f\fP.
+
+When \f5f\fP is \f5SF_READ\fP, \f5SF_SHARE\fP and unseekable,
+\f5sfreserve()\fP will attempt to peek at input data without
+consuming it. This enables separate processes to share in reading
+input from unseekable file descriptors (e.g., pipes or devices).
+However, this use of \f5sfreserve()\fP may fail
+on certain platforms that do not properly support
+peeking on unseekable file descriptors.
+
+After a \f5sfreserve()\fP call, whether or not it succeeds,
+\f5sfvalue(f)\fP gives the size of the available data block.
+Any partially reserved data block after a failed \f5sfreserve()\fP
+call can be obtained in another \f5sfreserve()\fP call with the argument
+\f5type\fP being \f5SF_LASTR\fP. The second argument \f5n\fP
+to \f5sfreserve()\fP will be ignored in this case.
+
+A \f5sfreserve()\fP call is successful if it can obtain a data block
+of size at least the absolute value of \f5n\fP.
+For a \f5SF_READ\fP atream, the argument \f5n\fP is treated as follows:
+.Tp
+\f5n < 0\fP:
+\f5sfreserve()\fP attempts to get \fIat least\fP \f5|n|\fP bytes
+into the buffer.
+.Tp
+\f5n == 0\fP:
+If the argument \f5type\fP is \f50\fP,
+\f5sfreserve()\fP attempts to get \fIat least\fP \f51\fP byte into the buffer;
+otherwise, no attempt will be made to read data into the buffer.
+For example, the call \f5sfreserve(f, 0, -1)\fP only returns the buffer status,
+i.e., size of existing buffered data and pointer to such data, if any.
+The call \f5sfreserve(f, 0, SF_LOCKR)\fP is similar but also locks the stream.
+.Tp
+\f5n > 0\fP:
+\f5sfreserve()\fP will use attempt to get \fIat most\fP \f5n\fP bytes into
+the buffer. Further, if \f5type == \f5SF_LOCKR\fP (see below), read attempts
+end on a positive amount.
+
+For a successful reservation, the argument \f5type\fP dictates treatment
+as follows:
+.Tp
+\f5type == SF_LASTR\fP:
+After a \f5sfreserve()\fP call with \f5type != SF_LOCKR\fP fails,
+there may be some left over data not accessible via conventional Sfio calls.
+Immediately after such a failed call,
+another call to \f5sfreserve\fP with \f5type == SF_LASTR\fP will return any left over
+data and also advance the stream I/O position by the amount of returned data.
+.Tp
+\f5type < 0\fP:
+If \f5n > 0\fP, the stream I/O position is advanced by \f5n\fP.
+If \f5n < 0\fP, the stream I/O position is advanced by the amount
+of available data.
+For example, a successful \f5sfreserve(f, -1, -1)\fP call will return a
+buffer of data and simultanously advance the stream I/O position by the amount
+indicated by \f5sfvalue(f)\fP.
+.Tp
+\f5type == SF_LOCKR\fP:
+The stream I/O position remains unchanged.
+In addition, \f5f\fP will be locked from further access.
+As appropriate to the stream type (\f5SF_READ\fP, \f5SF_WRITE\fP or both),
+\f5f\fP can be unlocked later
+with one of \f5sfread(f,rsrv,size)\fP or \f5sfwrite(f,rsrv,size)\fP
+where \f5rsrv\fP is the reserved data block and \f5size\fP is the amount of
+data to be consumed. For example, if \f5f\fP is a locked \f5SF_READ\fP stream,
+the call \f5sfread(f,rsrv,1)\fP will reopen the stream and simultaneously
+advance the stream I/O position by \f51\fP.
+Finally, a stream opened for both reading and writing
+can release the lock with either call (with associated operational semantics!)
+For example, the below code reads 10 bytes of data from a stream
+opened with both \f5SF_READ\fP and \f5SF_WRITE\fP, modifies the data in place,
+then rewrites the new data back to the stream:
+
+.nf
+.ft 5
+ rsrv = sfreserve(f, 10, 1);
+ for(i = 0; i < 10; ++i)
+ rsrv[i] = toupper(rsrv[i]);
+ sfwrite(f, rsrv, 10);
+.ft 1
+.fi
+
+.ne 6
+.PP
+.Ss "DATA FORMATTING"
+.PP
+Data printing and scanning are done via the
+\f5sfprintf()\fP and \f5sfscanf()\fP family of functions.
+These functions are similar to their
+ANSI-C \f5fprintf()\fP and \f5fscanf()\fP counterparts.
+However, the Sfio versions have been extended for both portability and generality.
+In particular, a notion of a formatting environment stack is introduced.
+Each formatting element on the stack
+defines a separate \fIformatting pair\fP of a format specification string,
+\f5char* format\fP (the usual second argument in the formatting
+functions), and an argument list, \f5va_list args\fP (the third argument
+in functions \f5sfvprintf()\fP and \f5sfvscanf()\fP).
+A formatting environment element may also specify extension functions
+to obtain or assign arguments and to provide new semantics for pattern processing.
+To simplify the description below, whenever we talk
+about an argument list, unless noted otherwise,
+it is understood that this means either the true
+argument list when there is no extension function or the action to be taken
+by such a function in processing arguments.
+The manipulation of the formatting environment stack is done
+via the pattern \f5!\fP discussed below.
+
+.Ss "%! and Sffmt_t"
+The pattern \f5%!\fP manipulates the formatting environment stack to
+(1) change the top environment to a new environment,
+(2) stack a new environment on top of the current top,
+or (3) pop the top environment.
+The bottom of the environment stack always contains a virtual environment with the
+original formatting pair and without any extension functions.
+
+The top environment of a stack, say \f5fe\fP, is automatically popped whenever
+its format string is completely processed.
+In this case, its event-handling function (if any) is called
+as \f5(*eventf)(f,SF_FINAL,NIL(Void_t*),fe)\fP.
+The top environment
+can also be popped by giving an argument \f5NULL\fP to \f5%!\fP
+or by returning a negative value in an extension function.
+In these cases, the event-handling function is called
+as \f5(*eventf)(f,SF_DPOP,form,fe)\fP where \f5form\fP is the remainder
+of the format string. A negative return value from the event handling function
+will prevent the environment from being popped.
+
+A formatting environment is a structure of type \f5Sffmt_t\fP
+which contains the following elements:
+
+.nf
+.ft 5
+ Sffmtext_f extf; /* extension processor */
+ Sffmtevent_f eventf; /* event handler */
+
+ char* form; /* format string to stack */
+ va_list args; /* corresponding arg list */
+
+ int fmt; /* pattern being processed */
+ ssize_t size; /* object size */
+ int flags; /* formatting control flags */
+ int width; /* width of field */
+ int precis; /* precision required */
+ int base; /* conversion base */
+
+ char* t_str; /* extfdata string */
+ int n_str; /* length of t_str */
+.ft 1
+.fi
+
+The first four elements of \f5Sffmt_t\fP must be defined by the application
+before the structure is passed to a formatting function.
+The two function fields should not be changed during processing.
+Other elements of \f5Sffmt_t\fP are set by the respective formatting function
+before it calls the extension function \f5Sffmt_t.extf\fP and, subsequently,
+can be modified by this function to redirect formatting or scanning.
+For example, consider a call from a \f5sfprintf()\fP function to process an
+unknown pattern \f5%t\fP (which we may take to mean ``time'') based on a
+formatting environment \f5fe\fP.
+\f5fe->extf\fP may reset \f5fe->fmt\fP to `\f5d\fP' upon returing
+to cause \f5sfprintf()\fP to process the value being formatted as an integer.
+
+Below are the fields of \f5Sffmt_t\fP:
+.Tp
+\f5extf\fP:
+\f5extf\fP is a function to extend scanning and formatting patterns.
+Its usage is discussed below.
+.Tp
+\f5eventf\fP:
+This is a function to process events as discussed earlier.
+.Tp
+\f5form\fP and \f5args\fP:
+This is the formatting pair of a specification string and corresponding argument list.
+When an environment \f5fe\fP is being inserted into the stack,
+if \f5fe->form\fP is \f5NULL\fP, the top environment is changed to \f5fe\fP
+and its associated extension functions
+but processing of the current formatting pair continues.
+On the other hand, if \f5fe->form\fP is not \f5NULL\fP,
+the new environment is pushed onto the stack
+so that pattern processing will start with the new formatting pair as well as
+any associated extension functions.
+During processing, whenever \f5extf\fP is called,
+\f5form\fP and \f5args\fP will be set to the current values of
+the formatting pair in use.
+.Tp
+\f5fmt\fP:
+This is set to the pattern being processed or one of '.', 'I', '('.
+.Tp
+\f5size\fP:
+This is the size of the object being processed.
+.Tp
+\f5flags\fP:
+This is a collection of bits defining the formatting flags specified for the pattern.
+The bits are:
+
+\f5SFFMT_LEFT\fP: Flag \f5-\fP in \f5sfprintf()\fP.
+
+\f5SFFMT_SIGN\fP: Flag \f5+\fP in \f5sfprintf()\fP.
+
+\f5SFFMT_BLANK\fP: Flag \fIspace\fP in \f5sfprintf()\fP.
+
+\f5SFFMT_ZERO\fP: Flag \f50\fP in \f5sfprintf()\fP.
+
+\f5SFFMT_THOUSAND\fP: Flag \f5'\fP in \f5sfprintf()\fP.
+
+\f5SFFMT_LONG\fP: Flag \f5l\fP in \f5sfprintf()\fP and \f5sfscanf()\fP.
+
+\f5SFFMT_LLONG\fP: Flag \f5ll\fP in \f5sfprintf()\fP and \f5sfscanf()\fP.
+
+\f5SFFMT_SHORT\fP: Flag \f5h\fP in \f5sfprintf()\fP and \f5sfscanf()\fP.
+
+\f5SFFMT_LDOUBLE\fP: Flag \f5L\fP in \f5sfprintf()\fP and \f5sfscanf()\fP.
+
+\f5SFFMT_IFLAG\fP: flag \f5I\fP in \f5sfprintf()\fP and \f5sfscanf()\fP.
+
+\f5SFFMT_ALTER\fP: Flag \f5#\fP in \f5sfprintf()\fP and \f5sfscanf()\fP.
+
+\f5SFFMT_SKIP\fP: Flag \f5*\fP in \f5sfscanf()\fP.
+
+\f5SFFMT_ARGPOS\fP: This indicates argument processing for \f5pos$\fP.
+
+\f5SFFMT_VALUE\fP: This is set by \f5fe->extf\fP
+to indicate that it is returning a value to be formatted or
+the address of an object to be assigned.
+
+.Tp
+\f5width\fP:
+This is the field width.
+.Tp
+\f5precis\fP:
+This is the precision.
+.Tp
+\f5base\fP:
+This is the conversion base.
+.Tp
+\f5t_str\fP and \f5n_str\fP:
+This is the type string and its size.
+
+.Ss " int (*Sffmtext_f)(Sfio_t* f, Void_t* v, Sffmt_t* fe)"
+This is the type of the extension function \f5fe->extf\fP to process
+patterns and arguments.
+Arguments are always processed in order and
+\f5fe->extf\fP is called exactly once per argument.
+Note that, when \f5pos$\fP (below) is not used anywhere in a format string,
+each argument is used exactly once per a corresponding pattern.
+In that case, \f5fe->extf\fP is called
+as soon as the pattern is recognized and before any scanning or formatting.
+On the other hand, when \f5pos$\fP is used in a format string,
+an argument may be used multiple times.
+In this case, all arguments shall be processed in order
+by calling \f5fe->extf\fP exactly once per argument before any pattern processing.
+This case is signified by the flag \f5SFFMT_ARGPOS\fP in \f5fe->flags\fP.
+
+In addition to the predefined formatting patterns and other application-defined
+patterns, \f5fe->extf\fP may be called with \f5fe->fmt\fP being one
+of `\f5(\fP' (left parenthesis), `\f5.\fP' (dot), and `\f5I\fP'.
+
+The left parenthesis requests a string to be used as the \f5extfdata\fP string discussed below.
+In this case, upon returning, \f5fe->extf\fP should set the \f5fe->size\fP field
+to be the length of the string or a negative value to indicate a null-terminated string.
+
+The `\f5I\fP' requests an integer to define the object size.
+
+The dot requests an integer for width, precision, base, or a separator.
+In this case, the \f5fe->size\fP field will indicate how many dots have appeared
+in the pattern specification. Note that, if the actual conversion pattern is 'c' or 's',
+the value \f5*form\fP will be one of these characters.
+.Tp
+\f5f\fP:
+This is the input/output stream in the calling formatting function.
+During a call to \f5fe->extf\fP, the stream shall be unlocked
+so that \f5fe->extf\fP can read from or write to it as appropriate.
+.Tp
+\f5v\fP:
+For both \f5sfscanf()\fP and \f5sfprintf()\fP functions,
+\f5v\fP points to a location suitable for storing any scalars or pointers.
+On return, \f5fe->extf\fP treats \f5v\fP as discussed below.
+.Tp
+\f5fe\fP:
+This is the current formatting environment.
+.PP
+The return value \f5rv\fP of \f5fe->extf\fP directs further processing.
+There are two cases.
+When \f5pos$\fP is present, a negative return value means to ignore \f5fe\fP
+in further argument processing while a non-negative return value is treated
+as the case \f5rv == 0\fP below.
+When \f5pos$\fP is not present, \f5fe->extf\fP is called per argument
+immediately before pattern processing and its return values are treated
+as below:
+.Tp
+\f5rv < 0:\fP
+The environment stack is immediately popped.
+.Tp
+\f5rv == 0:\fP
+The extension function has not consumed (in a scanning case) or
+output (in a printing case) data out of or into the given stream \f5f\fP.
+The fields \f5fmt\fP, \f5flags\fP, \f5size\fP,
+\f5width\fP, \f5precis\fP and \f5base\fP of \f5fe\fP
+shall direct further processing.
+
+For \f5sfprintf()\fP functions, if \f5fe->flags\fP
+has the bit \f5SFFMT_VALUE\fP,
+\f5fe->extf\fP should have set \f5*v\fP to the value to be processed;
+otherwise, a value should be obtained from the argument list.
+Likewise, for \f5sfscanf()\fP functions,
+\f5SFFMT_VALUE\fP means that
+\f5*v\fP should have a suitable address; otherwise,
+an address to assign value should be obtained from the argument list.
+
+When \f5pos$\fP is present,
+if \f5fe->extf\fP changes \f5fe->fmt\fP, this pattern shall be used regardless of
+the pattern defined in the format string. On the other hand, if \f5fe->fmt\fP
+is unchanged by \f5fe->extf\fP, the pattern in the format string is used.
+In any case, the effective pattern should be one of the standardly defined pattern.
+Otherwise, it shall be treated as unmatched.
+.Tp
+\f5rv > 0:\fP
+The extension function has accessed the stream \f5f\fP
+to the extent of \f5rv\fP bytes.
+Processing of the current pattern ceases except that,
+for scanning functions, if \f5fe->flags\fP does not contain
+the bit \f5SFFMT_SKIP\fP, the assignment count shall increase by 1.
+
+.Ss "void va_copy(va_list to, va_list fr)"
+This macro function portably copies the argument list \f5fr\fP to
+the argument list \f5to\fP. It should be used to set the field \f5Sffmt_t.args\fP.
+
+.Ss "long sffmtversion(Sffmt_t* fe, int type)"
+This macro function initializes
+the formatting environment \f5fe\fP with a version number if \f5type\fP is
+non-zero. Otherwise, it returns the current value of the version number of \f5fe\fP.
+This is useful for applications to find out
+when the format of the structure \f5Sffmt_t\fP changes.
+Note that the version number corresponds to the Sfio version number
+which is defined in the macro value \f5SFIO_VERSION\fP.
+
+.Ss " int sfprintf(Sfio_t* f, const char* format, ...);"
+.Ss " char* sfprints(const char* format, ...);"
+.Ss " char* sfvprints(const char* format, va_list args);"
+.Ss " ssize_t sfaprints(char** sp, const char* format, ...);"
+.Ss " ssize_t sfvaprints(char** sp, const char* format, va_list args);"
+.Ss " int sfsprintf(char* s, int n, const char* format, ...)"
+.Ss " int sfvsprintf(char* s, int n, const char* format, va_list args);"
+.Ss " int sfvprintf(Sfio_t* f, const char* format, va_list args);"
+These functions format output data.
+\f5sfprintf()\fP and \f5sfvprintf()\fP write to output stream \f5f\fP.
+\f5sfsprintf()\fP and \f5sfvsprintf()\fP write to buffer \f5s\fP
+which is of size \f5n\fP.
+\f5sfprints()\fP and \f5sfvprints()\fP construct data in some Sfio-defined buffer.
+\f5sfaprints()\fP and \f5sfvaprints()\fP are similar to \f5sfprints()\fP
+and \f5sfvprints()\fP
+but they return a string constructed via \f5malloc()\fP in \f5*sp\fP
+and expect this string to be freed by the caller when no longer needed.
+\f5sfvprintf()\fP is the underlying primitive for the other functions.
+Except for \f5sfprints()\fP and \f5sfvprints()\fP
+which return a null-terminated string or \f5NULL\fP,
+other functions return the number of output bytes or \f5-1\fP on failure.
+
+The length of string constructed by \f5sfprints()\fP, \f5sfsprintf()\fP, or
+\f5sfvsprintf()\fP can be retrieved by \f5sfslen()\fP.
+.PP
+The standard patterns are:
+\f5n, s, c, %, h, i, d, p, u, o, x, X, g, G, e, E, f\fP and \f5!\fP.
+Except for \f5!\fP which shall be described below,
+see the ANSI-C specification of \f5fprintf(3)\fP for details on the other patterns.
+Let \f5z\fP be some pattern type. A formatting pattern is defined as below:
+
+.nf
+.ft 5
+ %[pos$][flag][width][.precision[.base]][(extfdata)]z
+.ft 1
+.fi
+
+.Tp
+\f5pos$\fP:
+A pattern can specify which argument in the argument list to use.
+This is done via \f5pos$\fP where \f5pos\fP is the argument position.
+Arguments are numbered so that the first argument after \f5format\fP is at position 1.
+If \f5pos\fP is not specified, the argument following the most recently used one
+will be used.
+The pattern \f5%!\fP (see below) cannot be used subsequent to a usage of \f5pos$\fP.
+Doing so may cause unexpected behaviors.
+.Tp
+\f5flag\fP:
+The flag characters are
+\f5h\fP, \f5hh\fP, \f5l\fP, \f5ll\fP, \f5L\fP, \f5I\fP, \f5j\fP, \f5t\fP, \f5z\fP,
+\f5\-\fP, \f5+\fP, \fIspace\fP, \f50\fP, \f5'\fP and \f5#\fP.
+
+Flag \f5I\fP defines the size or type of the object being formatted.
+There are two cases: (1) \f5I\fP by itself and (2) \f5I\fP
+followed by either a decimal number or `*'.
+
+In the first case, for integer and floating point patterns,
+the object type is taken to be the largest appropriate type
+(i.e., one of \f5Sflong_t\fP, \f5Sfulong_t\fP or \f5Sfdouble_t\fP).
+For conversion specifiers \f5s\fP and \f5c\fP, the flag is ignored.
+
+In the second case, a given decimal value would define a size while
+`*' would cause the size to be obtained from the argument list.
+Then, if the conversion specifier is \f5s\fP, this size defines the
+length of the string or strings being formatted (see the discussion of \f5base\fP below).
+For integer and floating point patterns,
+the size is used to select a type from one of the below lists as
+indicated by the conversion specifier:
+
+.nf
+.ft 5
+ Sflong_t, long, int, short
+ Sfulong_t, unsigned long, unsigned int, unsigned short
+ Sfdouble_t, double, float
+.ft 1
+.fi
+
+The selection algorithm always matches types from left to right in any given list.
+Although selection is generally based on sizes in bytes,
+for compatibility with Microsoft-C, the size 64
+is matched with an appropriate type with the same number of bits, if any.
+If the given size does not match any of the listed types,
+it shall match one of \f5int\fP, \f5unsigned int\fP, and \f5double\fP
+as defined by the formatting pattern.
+
+Below are a few examples of using the \f5I\fP flag.
+The first example prints an \f5Sflong_t\fP integer.
+This example is actually not portable and
+only works on platforms where \f5sizeof(Sflong_t)\fP is 8.
+The second example shows how to that portably.
+The third example specifies printing a string of length 16.
+This length shall be used regardless of whether or not the given string
+is shorter or longer than 16.
+The last example shows the use of the pattern \f5%n\fP to assign the amount
+of data already output into a \f5short\fP integer \f5n_output\fP.
+
+.nf
+.ft 5
+ sfprintf(sfstdout,"%I8d", Sflong_obj);
+ sfprintf(sfstdout,"%I*d", sizeof(Sflong_obj), Sflong_obj);
+ sfprintf(sfstdout,"%I*s", 16, s);
+ sfprintf(sfstdout,"%d%I*n", 1001, sizeof(short), &n_output);
+.ft 1
+.fi
+
+Flags \f5h\fP, \f5l\fP, and \f5L\fP are the ANSI-C conventions to
+select the types of input objects.
+For example, \f5%hd\fP indicates a \f5short int\fP
+while \f5%ld\fP indicates a \f5long int\fP.
+
+Flag \f5hh\fP addresses the byte value types, i.e., \f5char\fP and \f5unsigned char\fP.
+
+Flags \f5z\fP, \f5t\fP and \f5j\fP address respectively
+the types \f5size_t\fP, \f5ptrdiff_t\fP and \f5Sflong_t\fP.
+
+Flags \f5ll\fP and \f5L\fP address respectively
+the largest integer and floating value types, i.e.,
+\f5Sfulong_t\fP, \f5Sflong_t\fP, and \f5Sfdouble_t\fP.
+
+Flag \f5-\fP left-justifies data within the field (otherwise, right-justification).
+
+Flag \f5+\fP means that a signed conversion will always begin with a plus or minus sign.
+
+Flag \fIspace\fP is ignored if \f5+\fP is specified; otherwise,
+it means that if the first character of a signed conversion
+is not a sign or if the result is empty, a space will be prepended.
+
+Flag \f50\fP means padding with zeros on the left.
+
+Flag \f5'\fP outputs thousands-separator used by the current locale.
+\f5setlocale(3)\fP should have been used to set the desired locale.
+
+Flag \f5#\fP indicates an alternative format processing.
+For \f5%o\fP, the first digit is always a zero.
+For \f5%x\fP and \f5%X\fP, a non-zero result will have a prefix
+\f50x\fP or \f50X\fP. For \f5%e\fP, \f5%E\fP, \f5%f\fP, \f5%g\fP, and \f5%G\fP,
+the result always contains a decimal point. For \f5%g\fP and \f5%G\fP,
+trailing zeros will not be removed. For \f5%d\fP, \f5%i\fP and \f5%u\fP,
+the form is \fIbase#number\fP where \fIbase\fP is the conversion base
+and \fInumber\fP is represented by digits for this \fIbase\fP.
+For example, a base \f52\fP conversion with \f5%#..2d\fP for \f510\fP
+is \f52#1010\fP instead of \f51010\fP as printed with \f5%..2d\fP.
+Finally, for \f5%c\fP, bytes will be printed in the C format.
+For example, when the ASCII character set is used,
+the byte value 10 will be printed as \f5\\n\fP while 255 is printed
+as \f5\\377\fP.
+.Tp
+\f5width\fP:
+This defines the width of the printing field. A value to be printed will
+be justified and padded if necessary to fill out the field width.
+.Tp
+\f5precis\fP:
+After a first dot appears, an integral value defines a precision.
+For floating point value patterns, precision is the number of precision digits.
+For \f5%c\fP, precision defines the number of times to repeat the
+character being formatted.
+For \f5%s\fP, precision defines the maximum number of characters to output.
+.Tp
+\f5base\fP:
+This is defined after exactly two dots have appeared.
+
+For \f5%i\fP, \f5%d\fP, and \f5%u\fP,
+\f5base\fP should be an integer value in the inclusive range \f5[2,64]\fP
+and defines a conversion base.
+If \f5base\fP is not in this range, it is defined to be \f510\fP.
+The digits to represent numbers are:
+
+.nf
+.ft 5
+ 01234567890
+ abcdefghijklmnopqrstuvwxyz
+ ABCDEFGHIJKLMNOPQRSTUVWXYZ @_
+.ft 1
+.fi
+
+For \f5%s\fP and \f5%c\fP, \f5base\fP defines a separator.
+Then, for \f5%s\fP, the input argument is taken to be a NULL-terminated array of strings
+while, for \f5%c\fP, this is a null-terminated array of characters.
+The strings or characters will be formatted one of a time based
+on the usual width and precision rules.
+After each formatted string or character, except for the last one,
+the separator \f5base\fP is output if it is a non-zero.
+
+There are further restrictions on the syntax of \f5%s\fP and \f5%c\fP when
+a separator is defined.
+Below are the legitimate sequences for \f5%s\fP and \f5%c\fP after the second dot:
+
+.nf
+\f5 s c\fP
+\f5 *s *c\fP
+\f5 \fP\fIz\fP\f5s \fP\fIz\fP\f5c\fP
+.fi
+
+In the first case, no separator is defined so \f5base\fP is set to zero.
+In the second case, \f5base\fP is obtained from the argument list.
+In the third case, the character \fIz\fP
+must be non-alphanumeric and \f5base\fP will be set to this character.
+
+The below example shows both the call and the result
+of printing a \f5NULL\fP-terminated array
+of three strings \f5apple\fP, \f5orange\fP, and \f5grape\fP:
+
+.nf
+.ft 5
+ sfprintf(sfstdout,"|%8..:s|",list);
+ | apple: orange: grape|
+.ft 1
+.fi
+
+.Tp
+\f5(extfdata)\fP:
+This defines a string \f5extfdata\fP
+to be passed to the extension function \f5Sffmt_t.extf\fP.
+Parentheses shall be balanced.
+If \f5extfdata\fP is \f5*\fP, the string is obtained from the argument list.
+
+.PP
+.Ss " int sfscanf(Sfio_t* f, const char* format, ...)"
+.Ss " int sfsscanf(const char* s, const char* format, ...)"
+.Ss " int sfvsscanf(const char* s, const char* format, va_list args)"
+.Ss " int sfvscanf(Sfio_t* f, const char* format, va_list args)"
+These functions scan data items.
+\f5sfscanf()\fP scans from the input stream \f5f\fP
+while \f5sfsscanf()\fP and \f5sfvsscanf()\fP
+scan from the null-terminated string \f5s\fP.
+\f5sfvscanf()\fP is the underlying primitive that performs the actual scanning.
+Item types are determined from patterns in string \f5format\fP.
+These functions return
+the number of items successfully scanned or \f5-1\fP on error.
+.PP
+A white space character (blank, tab, or new-line) in \f5format\fP
+normally matches a maximal sequence of input white space characters.
+However, if the input stream is in \f5SF_LINE\fP mode (see \f5sfset()\fP),
+a new-line character only matches white spaces up to an input new-line character.
+This is useful to avoid blocking when scanning typed inputs.
+.PP
+The standard scan patterns are:
+\f5i, d, u, o, x, X, p, n, f, e, E, g, G, c, %, s, []\fP and \f5!\fP.
+Except for \f5!\fP which shall be described below,
+see the ANSI-C specification of \f5fscanf(3)\fP for details on other patterns.
+Let \f5z\fP be some pattern type. A formatting pattern is specified as below:
+
+.nf
+.ft 5
+ %[*][pos$][width][.width.base][(extfdata)][flag]z
+.ft 1
+.fi
+
+.Tp
+\f5pos$\fP:
+A pattern can specify which argument in the argument list to use.
+This is done via \f5pos$\fP where \f5pos\fP is the argument position.
+Arguments are numbered so that the first argument after \f5format\fP is at position 1.
+If \f5pos\fP is not specified, the argument following the most recently used one
+will be used.
+The pattern \f5%!\fP (see below) cannot be used subsequent to a usage of \f5pos$\fP.
+.Tp
+\f5*:\fP
+This discards the corresponding scanned item.
+.Tp
+\f5width\fP and \f5base\fP:
+\f5width\fP defines the maximum number of bytes to scan
+and \f5base\fP defines the base of an integral value being scanned.
+The `.' (dot) notation also allows specifying a `*' (star) to obtain
+the value from the argument list. The below example specifies scanning
+4 bytes to obtain the value of an integer in base 10. At the end of scanning,
+the variable \f5v\fP should have the value \f51234\fP.
+
+.nf
+.ft 5
+ sfsscanf("12345678","%.*.*d", 4, 10, &v);
+.ft 1
+.fi
+
+.Tp
+\f5(extfdata)\fP:
+This defines a string \f5extfdata\fP
+to be passed to the extension function \f5Sffmt_t.extf\fP.
+Parentheses shall be balanced.
+If \f5extfdata\fP is \f5*\fP, the string is obtained from the argument list.
+.Tp
+\f5flag:\fP
+This is \f5#\fP, \f5I\fP, or some sequence of \f5h\fP, \f5l\fP, and \f5L\fP.
+
+Flag \f5#\fP is significant for pattern \f5%i\fP and \f5%[\fP.
+For \f5%i\fP, it means that the \f5#\fP symbol does not have its usual
+meaning in an input sequence \f5base#value\fP.
+For example, the scanning result of \f5%#i\fP on input \f52#1001\fP is \f52\fP
+and the next \f5sfgetc()\fP call will return \f5#\fP.
+For \f5%[\fP, if the next character in the input stream does not match
+the given scan set of characters, \f5#\fP causes a match to a null string
+instead of a failure.
+
+Flag \f5I\fP defines the size or type of the object being formatted.
+There are two cases: (1) \f5I\fP by itself and (2) \f5I\fP
+followed by either a decimal number or `*'.
+
+In the first case, for integer and floating point patterns,
+the object type is taken to be the largest appropriate type
+(i.e., one of \f5Sflong_t\fP, \f5Sfulong_t\fP or \f5Sfdouble_t\fP).
+For string patterns such as \f5%s\fP, the flag is ignored.
+
+In the second case, a given decimal value would define a size while
+`*' would cause the size to be obtained from the argument list.
+For string patterns such as \f5%s\fP or \f5%[\fP, this size defines the
+length of the buffer to store scanned data.
+Specifying a buffer size only limits the amount of data copied into the buffer.
+Scanned data beyond the buffer limit will be discarded.
+For integer and floating point patterns,
+the size is used to select a type from one of the below lists as
+indicated by the conversion specifier:
+
+.nf
+.ft 5
+ Sflong_t, long, int, short
+ Sfulong_t, unsigned long, unsigned int, unsigned short
+ Sfdouble_t, double, float
+.ft 1
+.fi
+
+The selection algorithm always matches types from left to right in any given list.
+Although selection is generally based on sizes in bytes,
+for compatibility with Microsoft-C, the size 64
+is matched with an appropriate type with the same number of bits, if any.
+If the given size does not match any of the listed types,
+it shall match one of \f5int\fP, \f5unsigned int\fP, and \f5double\fP
+as indicated by the formatting pattern.
+
+Below are examples of using the \f5I\fP flag.
+The first example scans a 64-bit integer.
+The second scans some floating point value
+whose size is explicitly computed and given.
+The last example scans a string into a buffer with the given size 128.
+Note that if the scanned string is longer than 127, only the first 127
+bytes shall be copied into the buffer. The rest of the scanned data
+shall be discarded.
+
+.nf
+.ft 5
+ sfscanf(sfstdin,"%I64d", &int64_obj);
+ sfscanf(sfstdin,"%I*f", sizeof(float_obj), &float_obj);
+ sfscanf(sfstdin,"%I*s", 128, buffer);
+.ft 1
+.fi
+
+Flags \f5h\fP, \f5l\fP, and \f5L\fP are the ANSI-C conventions
+for indicating the type of a scanned element.
+For example, \f5%hd\fP means scanning a \f5short int\fP.
+The flags \f5ll\fP and \f5L\fP mean respectively scanning an
+integer or a floating point value with largest size
+(i.e, \f5Sflong_t\fP or \f5Sfdouble_t\fP).
+.PP
+The \f5%i\fP, \f5%d\fP and \f5%u\fP patterns scan numbers in bases
+from \f52\fP to \f564\fP.
+\f5%i\fP scans integral values in self-describing formats.
+Except for octal, decimal and hexadecimal numbers with the usual formats,
+numbers in general bases are assumed to be of the form: \fIbase#value\fP
+where \fIbase\fP is a number in base 10 and \fIvalue\fP
+is a number in the given base.
+For example, \f52#1001\fP is the binary representation of the decimal value \f59\fP.
+If \fIbase\fP is \f536\fP or less,
+the digits for \fIvalue\fP can be any combination of \f5[0-9], [a-z], [A-Z]\fP
+where upper and lower case digits are not distinguishable.
+If \fIbase\fP is larger than \f536\fP, the set of digits is:
+
+.nf
+.ft 5
+ 0123456789
+ abcdefghijklmnopqrstuvwxyz
+ ABCDEFGHIJKLMNOPQRSTUVWXYZ @_
+.ft 1
+.fi
+
+.PP
+.Ss "BUFFERING, SYNCHRONIZATION"
+.PP
+.Ss " Void_t* sfsetbuf(Sfio_t* f, Void_t* buf, size_t size)"
+This function changed the buffering scheme for the stream \f5f\fP.
+The stream will be synchronized before any buffer modification.
+If a new buffer is successfully set and the old buffer has not been freed,
+\f5sfsetbuf()\fP returns the old buffer. Otherwise, it returns \f5NULL\fP.
+After a \f5sfsetbuf()\fP call,
+\f5sfvalue()\fP returns the size of the returned buffer.
+
+Sfio attempts to read data in blocks likely to be serviced fast by the file system.
+This means block sizes being multiples of a suitable alignment value
+(e.g., 512, 1024 or 8192). By default, the alignment value
+is computed via some internal mechanism depending on the local platform but
+it can also be explicitly set via the call \f5sfsetbuf(f, (Void_t*)f, size)\fP.
+
+In invocations of \f5sfsetbuf()\fP other than the above case,
+the \f5size\fP argument is treated as follows:
+.Tp
+\f5size == SF_UNBOUND\fP:
+Sfio will pick a suitable buffer size.
+If \f5buf\fP is \f5NULL\fP,
+Sfio will also pick a suitable buffering scheme (such as memory mapping.)
+If \f5buf\fP is not \f5NULL\fP, its actual value is ignored
+but the buffer will be allocated via \f5malloc(3)\fP.
+This can be used to avoid memory mapping.
+.Tp
+\f5size > 0\fP:
+This is the suggested size to use for buffering or memory mapping.
+If \f5buf\fP is \f5NULL\fP,
+Sfio will pick a suitable buffering scheme as discussed above.
+If \f5buf\fP is not \f5NULL\fP, then \f5buf\fP and \f5size\fP determine
+a buffer of the given size.
+.Tp
+\f5size == 0\fP:
+If \f5buf\fP is \f5NULL\fP, the stream will be unbuffered.
+If \f5buf\fP is not \f5NULL\fP,
+\f5sfsetbuf()\fP simply returns the stream buffer.
+In this case, no attempt will be made to synchronize the stream.
+
+.Ss " int sfsync(Sfio_t* f)"
+This function synchronizes the logical and physical views of stream \f5f\fP.
+It returns a negative value for failure and \f50\fP for success.
+
+For a \f5SF_WRITE\fP stream, synchronization means to write out any buffered data.
+For a seekable \f5SF_READ\fP file stream,
+the physical file position is aligned with the logical stream position and,
+if \f5SF_SHARE\fP is on, buffered data is discarded.
+If \f5f\fP is \f5NULL\fP, all streams are synchronized.
+If \f5f\fP is the base of a stream stack (see \f5sfstack()\fP),
+all stacked streams are synchronized.
+Note that a stacked stream can only be synchronized this way.
+If \f5f\fP is in a pool (see \f5sfpool()\fP) but not being the head,
+the pool head is synchronized.
+
+If \f5f\fP has flag \f5SF_IOCHECK\fP, the \f5SF_SYNC\fP event is raised
+before and after synchronization. See \f5sfdisc()\fP for details.
+
+.Ss " int sfpoll(Sfio_t** flist, int n, int timeout)"
+This function polls a set of streams to see if I/O operations
+can be performed on them without blocking.
+This is useful for multiplexing I/O over a set of streams.
+If a stream has a discipline, the exception function may be called
+before and after the stream is polled (see \f5sfdisc()\fP for details).
+After a successful \f5sfpoll()\fP call,
+for each ready stream \f5f\fP, \f5sfvalue(f)\fP returns
+a bit combination of \f5SF_READ\fP and \f5SF_WRITE\fP to tell which I/O
+mode is available. If \f5SF_READ\fP is available, an attempt to read
+a byte will not block. If \f5SF_WRITE\fP is available,
+an attempt to flush will not block.
+\f5sfpoll()\fP returns the number of ready streams or \f5-1\fP on failure.
+.Tp
+\f5flist\fP and \f5n\fP:
+\f5flist\fP is an array of \f5n\fP streams to be polled.
+Upon return, ready streams are moved to the front
+of \f5flist\fP in the same relative order.
+.Tp
+\f5timeout\fP:
+This defines an elapse time in milliseconds
+to wait to see if any stream is ready for I/O.
+If \f5timeout\fP is negative, \f5sfpoll()\fP will block until some stream become ready.
+Note that \f5SF_STRING\fP and normal file streams never block
+and are always ready for I/O.
+If a stream with discipline is being polled and
+its readiness is as yet undetermined (e.g., empty buffer,)
+the discipline exception function will be called with \f5SF_DPOLL\fP
+before querying the operating system.
+
+.Ss " Sfio_t* sfpool(Sfio_t* f, Sfio_t* poolf, int mode)"
+This function manipulates pools of streams.
+In a pool, only one stream is at the head and can have buffered data.
+All other streams in the pool will be synchronized.
+A stream becomes head when it is used for some I/O operation.
+\f5sfpool()\fP returns \f5NULL\fP on failure.
+.Tp
+\f5f\fP and \f5poolf\fP:
+If \f5f\fP is \f5NULL\fP,
+\f5sfpool()\fP simply returns the head of the pool containing \f5poolf\fP.
+If \f5f\fP is not \f5NULL\fP and \f5poolf\fP is \f5NULL\fP,
+\f5f\fP is deleted from its pool.
+In this case, if no other stream from the same pool can become head,
+\f5sfpool()\fP will return \f5NULL\fP; otherwise, it returns some stream
+from the remainder of the pool.
+If both \f5f\fP and \f5poolf\fP are not \f5NULL\fP,
+\f5f\fP is moved from its current pool (if any)
+into the same pool with \f5poolf\fP.
+In this case, \f5poolf\fP is returned.
+.Tp
+\f5mode\fP:
+If \f5poolf\fP is already in a pool, \f5mode\fP is ignored.
+Otherwise, \f5mode\fP should be \f50\fP or \f5SF_SHARE\fP.
+A \f5SF_SHARE\fP pool contains streams with \f5SF_WRITE\fP mode.
+In addition, on change to a new head stream,
+buffered write data of the current head
+is transferred to the new head.
+
+.Ss " int sfpurge(Sfio_t* f)"
+This function discards all buffered data
+unless \f5f\fP is a \f5SF_STRING\fP stream.
+Note that if \f5f\fP is a \f5SF_READ\fP stream based on an unseekable device,
+purged data will not be recoverable.
+If \f5f\fP is a \f5sfpopen\fP-stream opened for both read and write,
+data of both the read and write pipe ends will be purged
+(see \f5sfset()\fP to selectively turn off read or write mode
+if one set of data is to be preserved.)
+After purging, if \f5f\fP has flag \f5SF_IOCHECK\fP,
+the event \f5SF_PURGE\fP is raised.
+\f5sfpurge()\fP returns \f5-1\fP for failure and \f50\fP for success.
+
+.PP
+.Ss "DISCIPLINE, EVENT-HANDLING"
+.PP
+A file stream uses the system calls \f5read(2)\fP, \f5write(2)\fP
+and \f5lseek(2)\fP to read, write and position in the underlying file.
+Disciplines enable application-defined I/O methods including exception handling and
+data pre/post-processing.
+
+.Ss " Sfdisc_t* sfdisc(Sfio_t* f, Sfdisc_t* disc)"
+Each stream has a discipline stack whose bottom is a virtual discipline
+representing the actual system calls.
+\f5sfdisc()\fP manipulates the discipline stack of stream \f5f\fP.
+\f5f\fP will be synchronized before any discipline stack manipulation.
+After a successful discipline stack manipulation,
+the stream I/O position (see \f5sfseek()\fP and \f5sftell()\fP)
+and extent (see \f5sfsize()\fP) are updated
+to reflect that defined by the top discipline.
+If \f5disc\fP is \f5SF_POPDISC\fP or \f5(Sfdisc_t*)0\fP,
+the top element of the stack, if any, is popped and its address is returned.
+Otherwise, \f5disc\fP is pushed onto the discipline stack.
+In this case, if successful, \f5sfdisc()\fP returns
+the discipline that was pushed down.
+\f5sfdisc()\fP returns \f5NULL\fP on failure.
+
+Note that a discipline can be used only on one stream at a time.
+An application should take care to allocate different discipline
+structures for use with different streams.
+A discipline structure is of the type \f5Sfdisc_t\fP which
+contains the following public fields:
+
+.nf
+.ft 5
+ Sfread_f readf;
+ Sfwrite_f writef;
+ Sfseek_f seekf;
+ Sfexcept_f exceptf;
+.ft 1
+.fi
+
+.PP
+The first three fields of \f5Sfdisc_t\fP specify alternative I/O functions.
+If any of them is \f5NULL\fP, it is inherited
+from a discipline pushed earlier on the stack.
+Note that a file stream always
+has \f5read(2)\fP, \f5write(2)\fP, \f5lseek(2)\fP and \f5NIL(Sfexcept_f)\fP
+as the \fIlogical bottom discipline\fP.
+Arguments to I/O discipline functions
+have the same meaning as that of the
+functions \f5sfrd()\fP, \f5sfwr()\fP and \f5sfsk()\fP described below.
+.PP
+The exception function, \f5(*exceptf)()\fP announces exceptional events during
+I/O operations.
+It is called as \f5(*exceptf)(Sfio_t* f, int type, Void_t* value, Sfdisc_t* disc)\fP.
+Unless noted otherwise, the return value of \f5(*exceptf)()\fP is used as follows:
+.Tp
+\f5<0\fP:
+The on-going operation shall terminate.
+.Tp
+\f5>0\fP:
+If the event was raised due to an I/O error,
+the error has been repaired and the on-going operation shall continue normally.
+For some events, e.g., \f5SF_DPOLL\fP, the return value may also have
+additional meanings.
+.Tp
+\f5=0\fP:
+The on-going operation performs default actions with respect to the raised event.
+For example, on a reading error or reaching end of file, the top stream of a stack
+will be popped and closed and the on-going operation continue with the new top
+stream.
+.PP
+The argument \f5type\fP of \f5(*exceptf)()\fP
+identifies the particular exceptional event:
+.Tp
+\f5SF_LOCKED\fP:
+The stream cannot be accessed.
+Note that this lock state is not related to the mutex lock
+that protects a stream from multiple accesses by different threads
+(see section THREAD SAFETY). Rather, the stream was frozen by
+certain operations such as \f5sfreserve()\fP or \f5sfstack()\fP.
+Thus, a stream can be in this state even if the application is uni-threaded.
+.Tp
+\f5SF_READ\fP, \f5SF_WRITE\fP:
+These events are raised around reading and writing operations.
+
+If \f5SF_IOCHECK\fP is on, \f5SF_READ\fP and \f5SF_WRITE\fP
+are raised immediately before \f5read(2) and write(2)\fP calls.
+In this case, \f5*((ssize_t*)value)\fP is the amount of data to be processed.
+The return value of \f5(*exceptf)()\fP, if negative,
+indicates that the stream is not ready for I/O
+and the calling operation will abort with failure.
+If it is positive, the stream is ready for I/O
+but the amount should be restricted to the amount specified by this value.
+If the return value is zero, the I/O operation is carried out normally.
+
+\f5SF_READ\fP and \f5SF_WRITE\fP are also raised on operation failures.
+In such a case, \f5*((ssize_t*)value)\fP
+is the return value from the failed operation.
+.Tp
+\f5SF_SEEK\fP:
+This event is raised when a seek operation fails.
+.Tp
+\f5SF_NEW\fP, \f5SF_CLOSING\fP (\f5SF_CLOSE\fP), \f5SF_FINAL\fP:
+These events are raised during a stream closing.
+\f5SF_NEW\fP is raised for a stream about to be closed to be renewed (see \f5sfnew()\fP).
+\f5SF_CLOSING\fP is raised for a stream about to be closed.
+\f5SF_FINAL\fP is raised after a stream has been closed and before
+its space is to be destroyed (see \f5sfclose()\fP).
+For these events, a non-zero return value from \f5(*exceptf)()\fP causes
+\f5sfclose()\fP to return immediately with the same value.
+.Tp
+\f5SF_DPUSH\fP, \f5SF_DPOP\fP, \f5SF_DBUFFER\fP:
+Events \f5SF_DPUSH\fP and \f5SF_DPOP\fP are raised when a
+discipline is about to be pushed or popped.
+\f5(Sfdisc_t*)value\fP is the to-be top discipline, if any.
+
+A stream buffer is always synchronized before pushing or popping a discipline.
+If this synchronization fails, \f5SF_DBUFFER\fP will be raised with
+\f5*((size_t*)value)\fP being the amount of buffered data.
+If the return value of \f5exceptf\fP is positive,
+the push or pop operation will continue normally;
+otherwise, \f5sfdisc()\fP returns failure.
+.Tp
+\f5SF_DPOLL\fP:
+This event is raised by
+\f5sfpoll()\fP to see if the stream is ready for I/O.
+\f5*((int*)value)\fP indicates a time-out interval to wait.
+A negative return value from the exception function means blocking.
+A zero return value means that \f5sfpoll()\fP should
+query the underlying file descriptor.
+A positive return value means non-blocking. In addition,
+this value will be a bit combination of \f5SF_READ\fP and \f5SF_WRITE\fP
+to indicate what I/O modes are ready.
+.Tp
+\f5SF_READY\fP:
+This event is raised by \f5sfpoll()\fP for each ready stream.
+The third argument to the event handler is an integer composed with
+the two bits \f5SF_READ\fP and \f5SF_WRITE\fP to indicate which
+I/O modes are ready.
+.Tp
+\f5SF_SYNC\fP, \f5SF_PURGE\fP:
+If \f5SF_IOCHECK\fP is set,
+these events are raised respectively for a \f5sfsync()\fP or \f5sfpurge()\fP call.
+In each case, the respective event is raised once before the appropriate
+operation (synchronization or purging) with \f5((int)value)\fP being \f51\fP
+and once after with \f5((int)value)\fP being \f50\fP.
+Note that \f5sfsync()\fP is called for each
+\f5SF_WRITE\fP or \f5SF_SHARE|SF_READ\fP stream on closing.
+
+.Tp
+\f5SF_ATEXIT\fP:
+This event is raised for each open stream before the process exits.
+
+.Ss " int sfraise(Sfio_t* f, int type, Void_t* data)"
+If \f5f\fP is non-\f5NULL\fP, \f5sfraise()\fP calls all exception handlers
+of \f5f\fP with the event \f5type\fP and associated \f5data\fP.
+If an exception handler returns a non-zero value,
+\f5sfraise()\fP immediate returns the same value.
+Application-defined events should start from the value \f5SF_EVENT\fP
+so as to avoid confusion with system-defined events,
+\f5sfraise()\fP returns \f50\fP on success and \f5-1\fP on failure.
+
+If \f5f\fP is \f5NULL\fP, \f5sfraise()\fP iterates over all streams
+and raise events as described above. In this case,
+\f5sfraise()\fP returns \f50\fP on success and a negative value
+on failure. The absolute value of the return value tells how many
+streams failed on raising the given event.
+
+.Ss " ssize_t sfrd(Sfio_t* f, Void_t* buf, size_t n, Sfdisc_t* disc)"
+.Ss " ssize_t sfwr(Sfio_t* f, const Void_t* buf, size_t n, Sfdisc_t* disc)"
+.Ss " Sfoff_t sfsk(Sfio_t* f, Sfoff_t offset, int type, Sfdisc_t* disc)"
+These functions provides safe methods for a discipline I/O function to invoke
+earlier discipline I/O functions and to properly handle exceptions.
+They should not be used in any other context.
+\f5sfrd()\fP and \f5sfwr()\fP return the number of bytes read or written.
+\f5sfsk()\fP returns the new seek position.
+On error, all three functions return a negative value which should be \f5-1\fP
+or the value returned by the exception handler.
+
+.PP
+.Ss "STREAM CONTROL"
+.PP
+.Ss " int sfresize(Sfio_t* f, Sfoff_t size)"
+This function resizes the stream \f5f\P so that its extent is \f5size\fP.
+If the stream corresponds to a file, the file size is set to \f5size\fP
+via the system call \f5ftruncate()\fP.
+When a stream is made larger, the new data space is filled with zero's.
+\f5sfresize()\fP returns \f50\fP on success and a negative value on failure.
+
+.Ss " int sfset(Sfio_t* f, int flags, int set)"
+This function sets control flags for the stream \f5f\fP.
+It returns the previous set of flags or \f50\fP on error.
+
+Settable flags are:
+\f5SF_READ\fP, \f5SF_WRITE\fP, \f5SF_IOCHECK\fP,
+\f5SF_LINE\fP, \f5SF_SHARE\fP, \f5SF_PUBLIC\fP, \f5SF_MALLOC\fP and
+\f5SF_STATIC\fP.
+Note that \f5SF_READ\fP and \f5SF_WRITE\fP can be turned on or off only
+if the stream was opened as \f5SF_READ|SF_WRITE\fP.
+Turning off one of them means that the stream is to be treated exclusively
+in the other mode. It is not possible to turn off both.
+If legal, an attempt to turn on either \f5SF_READ\fP or \f5SF_WRITE\fP
+will cause the stream to be in the given I/O mode.
+.Tp
+\f5set == 0:\fP
+If \f5flags\fP is zero, the current set of flags is simply returned.
+Note that when a stream is first opened, not
+all of its flags are initialized yet (more below). If \f5flags\fP is
+non-zero, an attempt is made to turn off the specified flags.
+.Tp
+\f5set != 0:\fP
+If \f5flags\fP is zero, the stream is initialized if not yet done so.
+Then the current set of flags is returned.
+If \f5flags\fP is non-zero, an attempt is made to turn on the
+specified flags.
+
+.Ss " int sfsetfd(Sfio_t* f, int fd)"
+This function changes the file descriptor of \f5f\fP.
+Before a change is realized,
+\f5(*notify)(f,SF_SETFD,newfd)\fP (see \f5sfnotify()\fP) is called.
+\f5sfsetfd()\fP returns \f5-1\fP on failure and the new file descriptor on success.
+.Tp
+\f5fd >= 0\fP:
+If the current file descriptor is non-negative,
+it will be changed using \f5dup(3)\fP to a value larger or equal to \f5fd\fP.
+Upon a successful change, the previous file descriptor will be closed.
+If the current file descriptor is negative, it will be set to \f5fd\fP and
+the stream will be reinitialized.
+.Tp
+\f5fd < 0\fP:
+The stream is synchronized (see \f5sfsync()\fP) and its
+file descriptor will be set to this value.
+Then, except for \f5sfclose()\fP, the stream will be inaccessible
+until a future \f5sfsetfd()\fP call resets the file descriptor to a non-negative value.
+Thus, \f5sfsetfd(f,-1)\fP can be used to avoid closing the file descriptor
+of \f5f\fP when \f5f\fP is closed.
+
+.Ss " Sfio_t* sfstack(Sfio_t* base, Sfio_t* top)"
+This function stacks or unstacks stream.
+Every stream stack is identified by a base stream
+via which all I/O operations are performed.
+However, an I/O operation always takes effect on the top stream.
+If the top stream reaches the end of file or
+has an unrecoverable error condition,
+it is automatically popped and closed
+(see also \f5sfdisc()\fP for alternative handling of these conditions).
+.Tp
+\f5base\fP:
+This is the base stream of the stack.
+If it is \f5NULL\fP, \f5sfstack()\fP does nothing and returns \f5top\fP.
+.Tp
+\f5top\fP:
+If this is \f5SF_POPSTACK\fP or \f5(Sfio_t*)0\fP,
+the stack is popped and \f5sfstack()\fP returns the popped stream.
+Otherwise, \f5top\fP is pushed on top of the stack identified by \f5base\fP
+and \f5sfstack()\fP returns the \f5base\fP stream.
+
+.Ss " Sfio_t* sfswap(Sfio_t* f1, Sfio_t* f2)"
+This function swaps contents of \f5f1\fP and \f5f2\fP.
+This fails if either stream is in a stream stack but not being a base stream.
+If \f5f2\fP is \f5NULL\fP, a new stream is constructed as a duplicate of \f5f1\fP.
+\f5sfswap()\fP returns \f5f2\fP or \f5f1\fP duplicate on success and
+\f5NULL\fP on failure.
+
+.PP
+.Ss "STREAM INFORMATION"
+.PP
+.Ss " Sfoff_t sfsize(Sfio_t* f)"
+This function returns the size of stream \f5f\fP (see \f5sfnew()\fP).
+If \f5f\fP is not seekable or if its size is not determinable,
+\f5sfsize()\fP returns \f5-1\fP.
+
+.Ss " Sfoff_t sftell(Sfio_t* f)"
+This function returns the current I/O position in stream \f5f\fP.
+Note that if \f5f\fP is \f5SF_APPEND\fP
+and a writing operation was just performed,
+the current I/O position is at the physical end of file.
+If \f5f\fP is unseekable, \f5sftell\fP returns the number of bytes
+read from or written to \f5f\fP.
+See also \f5sfungetc()\fP.
+
+.Ss " ssize_t sfvalue(Sfio_t* f)"
+This function returns the string or buffer length
+for \f5sfreserve()\fP, \f5sfsetbuf()\fP, and \f5sfgetr()\fP.
+
+.Ss " int sffileno(Sfio_t* f)"
+This function returns the file descriptor of stream \f5f\fP.
+
+.Ss " int sfstacked(Sfio_t* f)"
+This function returns a non-zero value
+if stream \f5f\fP has been stacked.
+
+.Ss " int sfeof(Sfio_t* f)"
+.Ss " int sferror(Sfio_t* f)"
+.Ss " int sfclrerr(Sfio_t* f)"
+\f5sfeof()\fP tells whether or not the stream has an end-of-file condition.
+\f5sferror()\fP tells whether or not the stream has an error condition.
+\f5sfclrerr()\fP clears both end-of-file and error conditions.
+The end-of-file and error conditions are also cleared on an I/O operation.
+
+.Ss " int sfclrlock(Sfio_t* f)"
+This function restores the stream back to a normal state.
+This means clearing locks and possibly throwing away unprocessed data.
+As such, this operation is unsafe and should be used with care.
+For example, it may be used before a long jump (\f5longjmp(3)\fP)
+out of some discipline I/O function to restore the internal stream states.
+\f5sfclrlock()\fP returns the current set of flags.
+
+.Ss " int sfnotify((void(*)notify)(Sfio_t*, int, int) )"
+This sets a function \f5(*notify)()\fP to be called
+as \f5(*notify)(f,type,file)\fP on various stream events.
+Arguments \f5f\fP and \f5file\fP are stream and related file descriptor.
+Argument \f5type\fP indicates the reason for the call:
+.Tp
+\f5SF_NEW\fP:
+\f5f\fP is being opened and \f5file\fP is the underlying file descriptor.
+.Tp
+\f5SF_CLOSING\fP (\f5SF_CLOSE\fP):
+\f5f\fP and \f5file\fP are being closed.
+.Tp
+\f5SF_SETFD\fP:
+The file descriptor of \f5f\fP is being changed to \f5file\fP (see \f5sfsetfd()\fP.)
+.Tp
+\f5SF_READ\fP:
+An attempt to change \f5f\fP to read mode failed.
+.Tp
+\f5SF_WRITE\fP:
+An attempt to change \f5f\fP to write mode failed.
+
+.PP
+.Ss "MISCELLANEOUS FUNCTIONS"
+.PP
+.Ss " ssize_t sfmaxr(ssize_t maxr, int set)"
+Certain records may require too much memory for storage, thus, causing
+undesirable side effects. Therefore, the library normally bounds the amount
+of memory used by \f5sfgetr()\fP. A different memory bound
+can be set via \f5sfmaxr()\fP. While a positive \f5maxr\fP hints to \f5sfgetr()\fP
+to use only about that much memory to construct a record, a non-positive bound
+allows \f5sfgetr()\fP to use as much memory as necessary.
+\f5sfmaxr()\fP sets the value only if \f5set\fP is non-zero.
+It returns the value before setting or the current value if not setting.
+
+.Ss " ssize_t sfslen()"
+This function returns the length of a string just constructed
+by \f5sfsprintf()\fP or \f5sfprints()\fP. See also \f5sfvalue()\fP.
+
+.Ss " int sfulen(Sfulong_t v)"
+.Ss " int sfllen(Sflong_t v)"
+.Ss " int sfdlen(Sfdouble_t v)"
+These functions return respectively the number of bytes required to code the
+\f5Sfulong_t\fP, \f5Sflong_t\fP or \f5Sfdouble_t\fP value \f5v\fP by \f5sfputu()\fP,
+\f5sfputl()\fP or \f5sfputd()\fP.
+
+.Ss " ssize_t sfpkrd(int fd, char* buf, size_t n, int rsc, long tm, int action)"
+This function acts directly on the file descriptor \f5fd\fP.
+It does a combination of peeking on incoming data and a time-out read.
+Upon success, it returns the number of bytes received.
+A return value of \f50\fP means that the end-of-file condition has been detected.
+A negative value represents an error.
+.Tp
+\f5buf\fP, \f5n\fP:
+These define a buffer and its size to read data into.
+.Tp
+\f5rsc\fP:
+If \f5>=0\fP, this defines a record separator.
+If the last returned byte is not the record separator, then
+the read data did not contain a complete record. Otherwise,
+it contains one or more records.
+See also \f5action\fP below.
+.Tp
+\f5tm\fP:
+If \f5>=0\fP, this defines a time interval in milliseconds to wait for incoming data.
+.Tp
+\f5action\fP:
+If \f5action > 0\fP, \f5sfpkrd()\fP will peek on incoming data but
+will not read past it. Therefore, a future \f5sfpkrd()\fP or \f5read(2)\fP will see
+the same data again.
+If \f5action <= 0\fP, \f5sfpkrd()\fP will not peek and there are two cases.
+If \f5rsc < 0\fP, an attempt is made to read \f5n\fP bytes.
+If \f5rsc >= 0\fP, an attempt is made to read one record.
+
+.PP
+.Ss "FULL STRUCTURE SFIO_T"
+.PP
+.Ss " #include <sfio_t.h>"
+Most applications based on Sfio only need to include
+the header file \f5sfio.h\fP which defines an abbreviated \f5Sfio_t\fP
+structure without certain fields private to Sfio.
+However, there are times (e.g., debugging)
+when an application may require more details about the full \f5Sfio_t\fP structure.
+In such cases, the header file \f5sfio_t.h\fP can be used in place of \f5sfio.h\fP.
+Note that an application doing this will become sensitive to changes
+in the internal architecture of Sfio.
+
+.Ss " #define SFNEW(buf,size,file,flags,disc)"
+This macro function is defined in \f5sfio_t.h\fP for
+use in static initialization of an \f5Sfio_t\fP structure.
+It requires five arguments:
+.Tp
+\f5buf, size\fP:
+These define a buffer and its size.
+.Tp
+\f5file\fP:
+This defines the underlying file descriptor if any.
+.Tp
+\f5flags\fP:
+This is composed from bit flags described above.
+.Tp
+\f5disc\fP:
+This defines a discipline if any.
+
+.PP
+.Ss "EXAMPLE DISCIPLINES"
+.PP
+The below functions create disciplines and insert them into
+the given streams \f5f\fP. These functions return \f50\fP
+on success and \f5-1\fP on failure.
+
+.Ss "int sfdcdio(Sfio_t* f, size_t bufsize)"
+This creates a discipline that uses the direct IO feature
+available on file systems such as SGI's XFS to speed up IO.
+The argument \f5bufsize\fP suggests a buffer size to use for data transfer.
+
+.Ss "int sfdcdos(Sfio_t* f)"
+This creates a discipline to read DOS text files.
+It basically transforms pairs of \er\en to \en.
+
+.Ss "int sfdcfilter(Sfio_t* f, const char* cmd)"
+This creates a discipline that sends data from \f5f\fP
+to the given command \f5cmd\fP to process, then reads back the processed data.
+
+.Ss "int sfdcseekable(Sfio_t* f)"
+This creates a discipline that makes an unseekable reading stream seekable.
+
+.Ss "int sfdcslow(Sfio_t* f)"
+This creates a discipline that makes all Sfio operations return immediately
+on interrupts. This is useful for dealing with slow devices.
+
+.Ss "int sfdcsubstream(Sfio_t* f, Sfio_t* parent, Sfoff_t offset, Sfoff_t extent)"
+This creates a discipline that makes \f5f\fP acts as if it
+corresponds exactly to the subsection of \f5parent\fP
+starting at \f5offset\fP with size \f5extent\fP.
+
+.Ss "int sfdctee(Sfio_t* f, Sfio_t* tee)"
+This creates a discipline that copies to the stream \f5tee\fP
+any data written to \f5f\fP.
+
+.Ss "int sfdcunion(Sfio_t* f, Sfio_t** array, int n)"
+This creates a discipline that makes \f5f\fP act as if it is
+the concatenation of the \f5n\fP streams given in \f5array\fP.
+
+.Ss "int sfdclzw(Sfio_t* f)"
+This creates a discipline that would decompress data in \f5f\fP.
+The stream \f5f\fP should have data from a source compressed by
+the Unix \fBcompress\fP program.
+
+.Ss "int sfdcgzip(Sfio_t* f, int opt)"
+This creates a discipline for reading/writing data compressed by zlib.
+The argument \f5opt\fP defines the optimization level.
+
+.PP
+.Ss "STDIO-COMPATIBILITY"
+.PP
+Sfio provides compatibility functions for all various popular
+Stdio implementations at source and binary level.
+The source Stdio-compatibility interface
+provides the header file \f5stdio.h\fP that defines
+a set of macros or inlined functions to map Stdio calls to Sfio ones.
+This mapping may benignly extend or change the meaning of certain
+original Stdio operations. For example, the Sfio's version of
+\f5popen()\fP allows a coprocess to be opened for both reading and writing
+unlike the original call which only allows a coprocess to be opened for a single mode.
+Similarly, the Sfio's \f5fopen()\fP call can be used to create
+string streams in addition to file streams.
+.PP
+The standard streams \f5stdin\fP, \f5stdout\fP and \f5stderr\fP
+are mapped via \f5#define\fP to \f5sfstdin\fP, \f5sfstdout\fP and \f5sfstderr\fP.
+The latter are typically declared of the type \f5Sfio_t*\fP.
+Certain older Stdio applications require these to be declared
+as addresses of structures so that static initializations of
+the sort ``\f5FILE*\ f\ =\ stdin;\fP'' would work.
+Such applications should use the compile time flag \f5SF_FILE_STRUCT\fP
+to achieve the desired effect.
+.PP
+The binary Stdio-compatibility libraries, \f5libstdio.a\fP and \f5libstdio-mt.a\fP,
+provide complete implementations of Stdio functions suitable
+for linking applications already compiled with native header \f5stdio.h\fP.
+These functions are also slightly altered or extended
+as discussed above.
+.PP
+Below are the supported Stdio functions:
+.PP
+.nf
+.ft 5
+FILE* fopen(const char* file, const char* mode);
+FILE* freopen(const char* file, const char* mode, FILE* stream);
+FILE* fdopen(int filedesc, const char* mode);
+FILE* popen(const char* command, const char* mode);
+FILE* tmpfile();
+int fclose(FILE* stream);
+int pclose(FILE* stream);
+
+void flockfile(FILE* stream)
+int ftrylockfile(FILE* stream)
+void funlockfile(FILE* stream)
+
+void setbuf(FILE* stream, char* buf);
+int setvbuf(FILE* stream, char* buf, int mode, size_t size);
+void setbuffer(FILE* stream, char* buf, size_t size);
+int setlinebuf(FILE* stream);
+int fflush(FILE* stream);
+int fpurge(FILE* stream);
+
+int fseek(FILE* stream, long offset, int whence);
+void rewind(FILE* stream);
+int fgetpos(FILE* stream, fpos_t* pos);
+int fsetpos(FILE* stream, fpos_t* pos);
+long ftell(FILE* stream);
+
+int getc(FILE* stream);
+int fgetc(FILE* stream);
+int getchar(void);
+int ungetc(int c, FILE* stream);
+int getw(FILE* stream);
+char* gets(char* s);
+char* fgets(char* s, int n, FILE* stream);
+size_t fread(Void_t* ptr, size_t size, size_t nelt, FILE* stream);
+
+int putc(int c, FILE* stream);
+int fputc(int c, FILE* stream);
+int putchar(int c);
+int putw(int w, FILE* stream);
+int puts(const char* s, FILE* stream);
+int fputs(const char* s, FILE* stream);
+size_t fwrite(const Void_t* ptr, size_t size, size_t nelt, FILE* stream);
+
+int fscanf(FILE* stream, const char* format, ...);
+int vfscanf(FILE* stream, const char* format, va_list args);
+int _doscan(FILE* stream, const char* format, va_list args);
+int scanf(const char* format, ...);
+int vscanf(const char* format, va_list args);
+int sscanf(const char* s, const char* format, ...);
+int vsscanf(const char* s, const char* format, va_list args);
+
+int fprintf(FILE* stream, const char* format, ...);
+int vfprintf(FILE* stream, const char* format, va_list args);
+int _doprnt(FILE* stream, const char* format, va_list args);
+int printf(const char* format, ...);
+int vprintf(const char* format, va_list args);
+int sprintf(const char* s, const char* format, ...);
+int snprintf(const char* s, int n, const char* format, ...);
+int vsprintf(const char* s, const char* format, va_list args);
+int vsnprintf(const char* s, int n, const char* format, va_list args);
+
+int feof(FILE* stream);
+int ferror(FILE* stream);
+int clearerr(FILE* stream);
+.ft 1
+.fi
+
+.PP
+.Ss "RECENT CHANGES"
+.PP
+A few exception types have been added. In particular, exception handlers shall
+be raised with \f5SF_LOCKED\fP on accessing a stream frozen either by
+an ongoing operation or a previous operation (e.g., \f5sfgetr()\fP).
+Before a process exits, the event \f5SF_ATEXIT\fP is raised for each open stream.
+.PP
+A number of disciplines were added for various processing functions.
+Of interests are disciplines to use the direct I/O feature on IRIX6.2,
+read DOS text files, and decompress files compressed by Unix \fIcompress\fP.
+.PP
+Various new stream and function flags have been added. For example,
+the third argument of \f5sfgetr()\fP is now a set of bit flags and not
+just a three-value object. However, the old semantics of this argument
+of \f5sfgetr()\fP is still supported.
+.PP
+The \f5sfopen()\fP call has been extended so that sfopen(f,NULL,mode) can be
+used to changed the mode of a file stream before any I/O operations.
+This is most useful for changing the modes of the standard streams.
+.PP
+The buffering strategy has been significantly enhanced for streams
+that perform many seek operations. Also, the handling of stream and
+file positions have been better clarified so that applications that
+share file descriptors across streams and/or processes can be sure that
+the file states will be consistent.
+.PP
+The strategy for mapping between Sfio and Stdio streams in the binary
+compatibility package has been significantly enhanced for efficiency.
+For most platforms, the mapping is now constant time per look-up.
+.PP
+The \f5SF_BUFCONST\fP flag was deleted. This is largely unused anyway.
+.PP
+The library can be built for thread-safety. This is based largely on
+Posix pthread mutexes except for on UWIN where native Windows APIs
+are used.
+.PP
+The functions \f5sfgetm()\fP and \f5sfputm()\fP were added to encode
+unsigned integer values with known ranges.
+.PP
+The flag \f5SF_APPEND\fP is identical to \f5SF_APPENDWR\fP.
+However it conflicts with a different token of the same name
+defined in the system header \f5stat.h\fP of BSDI Unix systems.
+On such systems, we shall not define \f5SF_APPEND\fP and this
+symbol may be removed in a future release.
+.PP
+Similarly, the exception \f5SF_CLOSE\fP is identical to \f5SF_CLOSING\fP.
+However it conflicts with a different token of the same name
+defined in the system header \f5socket.h\fP of AIX Unix systems.
+On such systems, we shall not define \f5SF_CLOSE\fP and this
+symbol may be removed in a future release.
+.PP
+The printing and scanning functions were extended to handle multibyte characters
+and to conform to the C99 standard.
+.PP
+The function \f5sfpoll()\fP was rehauled to make it useful
+for writing servers that must commnunicate with multiple streams
+without blocking.
+.PP
+The formatting pattern \f5%c\fP for \f5sf*printf\fP was extended
+to allow the flag \f5#\fP to print unprintable character values
+using the C convention. For example, \f5%#c\fP prints the octal value 012
+as \f5\\n\fP.
+
+.SH AUTHORS
+Kiem-Phong Vo, kpv@research.att.com,
+.br
+David G. Korn, dgk@research.att.com, and
+.br
+Glenn S. Fowler, gsf@research.att.com.
diff --git a/usr/src/lib/libast/common/man/sig.3 b/usr/src/lib/libast/common/man/sig.3
new file mode 100644
index 0000000000..db41a2b08c
--- /dev/null
+++ b/usr/src/lib/libast/common/man/sig.3
@@ -0,0 +1,75 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH SIG 3
+.SH NAME
+sig \- signal interface routines
+.SH SYNOPSIS
+.L "#include <ast.h>"
+.L "#include <sig.h>"
+.sp
+.L "int sigunblock(int sig);"
+.L "int sigcritical(int op);"
+.SH DESCRIPTION
+.L sigunblock
+is called to
+unblocks the signal
+.L sig
+from within a handler currently servicing
+.LR sig .
+.PP
+.L sigcritical
+controls a critical region for the
+.LR SIGINT ,
+.L SIGQUIT
+and
+.L SIGHUP
+signals.
+.L "op > 0"
+pushes the region,
+.L "op == 0"
+pops the region, and
+.L "op < 0"
+returns non-zero if any signals are being held in the current
+critical region.
+Signal critical regions may be nested.
+The current critical region level is returned,
+.L \-1
+on error.
+.SH "SEE ALSO"
+signal(2)
diff --git a/usr/src/lib/libast/common/man/spawnveg.3 b/usr/src/lib/libast/common/man/spawnveg.3
new file mode 100644
index 0000000000..3dfd4248cf
--- /dev/null
+++ b/usr/src/lib/libast/common/man/spawnveg.3
@@ -0,0 +1,97 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH SPAWNVEG 3
+.SH NAME
+spawnveg \- process spawn with process group and session control
+.SH SYNOPSIS
+.L "#include <ast.h>"
+.sp
+.L "int spawnveg(const char* command, char** argv, char** envv, pid_t pgid);"
+.SH DESCRIPTION
+.L spwanveg
+combines
+.IR fork (2),
+.IR exec (2),
+.IR setpgid (2)
+and
+.IR setsid (2)
+into a single call.
+.PP
+.LR command ,
+.L argv
+and
+.L envv
+are as in
+.IR execve (2).
+.L pgid
+controls the new process group and session:
+.TP
+.L <0
+The new process becomes a session leader.
+is called in the child context.
+.TP
+.L 0
+The new process is in the callers process group.
+.TP
+.L 1
+The new process becomes a process group leader.
+.TP
+.L >1
+The new process joins the process group
+.IR pgid .
+.SH COMMENTS
+It is possible to code all process creation (except for
+.IR vfork (2)
+hack like in
+.IR csh (1))
+using
+.LR spawnveg .
+The
+.IR proc (3)
+routines and
+.IR ksh (1)
+do this on systems that don't support
+.IR fork (2).
+This makes porting to NT and Windows a snap: a simple
+.IR iffe (1)
+probe provides a
+.L spawnveg
+implementation using the NT or Windows process primitives.
+.SH "SEE ALSO"
+fork(2), exec(2), setpgid(2), setsid(2), spawnve(2)
diff --git a/usr/src/lib/libast/common/man/stak.3 b/usr/src/lib/libast/common/man/stak.3
new file mode 100644
index 0000000000..dc95f39432
--- /dev/null
+++ b/usr/src/lib/libast/common/man/stak.3
@@ -0,0 +1,169 @@
+.fp 5 CW
+.TH STAK 3
+.SH NAME
+\fBstak\fR \- data stack storage library \- obsolete \- use \fBstk\fR
+.SH SYNOPSIS
+.ta .75i 1.5i 2.25i 3i 3.75i 4.5i 5.25i 6i
+.PP
+.nf
+\f5
+#include <stak.h>
+
+Stak_t *stakcreate(int \fIflags\fP);
+Stak_t *stakinstall(Stak_t *\fIstack\fP, char *(\fIoverflow\fP)(int));
+int stakdelete(Stak_t *\fIstack\fP);
+void staklink(Stak_t *\fIstack\fP)
+
+char *stakalloc(unsigned \fIsize\fP);
+char *stakcopy(const char *\fIstring\fP);
+char *stakset(char *\fIaddress\fP, unsigned \fIoffset\fP);
+
+char *stakseek(unsigned \fIoffset\fP);
+int stakputc(int \fIc\fP);
+int stakputs(const char *\fIstring\fP);
+int stakwrite(const char *\fIaddress\fP, unsigned \fIsize\fP);
+int staktell(void);
+char *stakptr(unsigned \fIoffset\fP);
+char *stakfreeze(unsigned \fIextra\fP);
+\fR
+.fi
+.SH DESCRIPTION
+.PP
+\f5stak\fP is a package of routines designed to provide efficient
+stack oriented dynamic storage.
+A stack abstraction consists of an ordered list of contiguous
+memory regions, called stack frames, that can hold objects of
+arbitrary size.
+A stack is represented by the type \f5Stak_t\fP
+defined in header \f5<stak.h>\fP.
+At any instant there is one active stack.
+Variable size objects can be
+added to the active stack
+and programs can reference these objects directly with pointers.
+In addition, the last object on the stack
+(referred to here as the current object)
+can be built incrementally.
+The current object has an associated offset that determines its
+current size.
+While the current object is being built incrementally,
+its location might
+change so that it is necessary to reference the object with
+relative offsets ranging from zero to the current offset of the object.
+.PP
+There is a preset initial active stack.
+To use an additional stack, it is necessary to create it and to
+install it as the active stack.
+A stack is created with the \f5stakcreate\fP() function.
+A \fIflags\fP argument of \f5STAK_SMALL\fP indicates that unused
+space on the stack should be freed whenever this stack ceases
+to be the active stack.
+If successful,
+\f5stakcreate\fP() returns a pointer to a stack whose reference
+count is 1.
+Otherwise, \f5stakcreate\fP() returns a null pointer.
+The \f5staklink\fP() function increases the reference count for the
+given \fIstack\fP.
+The \f5stakinstall\fP() function
+makes the specified \fIstack\fP the active stack and returns a pointer
+to the previous active stack.
+When the \fIoverflow\fP argument is not null,
+it specifies a function that will
+be called whenever \f5malloc\fP(3) fails while trying to grow the
+stack.
+The \fIoverflow\fP function will be called with the size that was passed
+to \f5malloc\fP(3).
+The \fIoverflow\fP function can call \f5exit\fP(3), call \f5longjmp\fP(3)
+or return.
+If the \f5overflow\fP function returns,
+it must return a pointer to a memory region of the given size.
+The default action is to write an error to standard error and to
+call \f5exit\fP(2) with a non-zero exit value.
+When \fIstack\fP is a null pointer,
+the active stack is not changed
+but the \fIoverflow\fP function for the active stack can be changed
+and a pointer to the active stack is returned.
+The \f5stakdelete\fP() function decrements the reference count and
+frees the memory associated with
+the specified stack
+when the reference count is zero.
+The effect of subsequent references to objects
+on the stack are undefined.
+.PP
+The
+\f5stakalloc\fP() function returns an aligned pointer to space on the
+active stack that can be used to hold any object of the given \fIsize\fP.
+\f5stakalloc\fP() is similar to \f5malloc\fP(3) except that individual
+items returned by \f5stakalloc\fP() can not be freed.
+\f5stakalloc\fP() causes the offset of the current object to be set to
+zero.
+.PP
+The
+\f5stakcopy\fP() function copies the given string onto the stack
+and returns a pointer to the \fIstring\fP on the stack.
+\f5stakcopy\fP() causes the offset of the current object to be set to
+zero.
+.PP
+The \f5stakset\fP() function finds the frame containing the given
+\fIaddress\fP, frees all frames that were created after the one containing
+the given \fIaddress\fP, and sets the current object to the given
+\fIaddress\fP.
+The top of the current object is set to \fIoffset\fP bytes from
+current object.
+If \fIaddress\fP is not the address of an object on the
+stack the result is undefined.
+.PP
+The remaining functions are used to build the current object incrementally.
+An object that is built incrementally on the stack will
+always occupy contiguous memory within a stack frame but
+until \f5stakfreeze\fP() is called,
+the location in memory for the object can change.
+There is a current offset associated with the current object that
+determines where subsequent operations apply.
+Initially, this offset is zero, and the offset changes as a result
+of the operations you specify.
+The \f5stakseek\fP() function is used set the offset for the
+current object.
+The \fIoffset\fP argument to \f5stakseek\fP() specifies the new
+offset for the current object.
+The frame will be extended or moved
+if \f5offset\fP causes the new current offset to extend beyond the
+current frame.
+\f5stakseek\fP() returns a pointer to the beginning of the current object.
+The \f5staktell\fP() function gives the offset of the current object.
+.PP
+The \f5stakputc\fP() function adds a given character to the current object
+on the stack.
+The current offset is advanced by 1.
+The \f5stakputs\fP() function appends the given \fIstring\fP onto the current
+object in the stack and returns the length of the string.
+The current offset is advanced by the length of the string.
+The \f5stakwrite\fP() function appends the given \fIsize\fP byte memory
+region starting at \fIaddress\fP onto the current
+object in the stack and advances the current offset by \fIsize\fP.
+The current offset is returned.
+.PP
+The \f5stakptr\fP() function converts the given \f5offset\fP
+for the current object into a memory address on the stack.
+This address is only valid until another stack operation is given.
+The result is not defined if \fIoffset\fP exceeds the size of the current
+object.
+The \f5stakfreeze\fP()
+function terminates the current object on the
+stack and returns a pointer to the beginning of this object.
+If \fIextra\fP is non-zero, \fIextra\fP bytes are added to the stack
+before the current object is terminated. The first added byte will
+contain zero and the contents of the remaining bytes are undefined.
+.PP
+.SH HISTORY
+The
+\f5stak\fP
+interface was derived from similar routines in the KornShell code
+that is used for building parse trees and carrying out expansions.
+It provides an efficient mechanism for grouping dynamically allocated
+objects so that they can be freed all at once rather than individually.
+.SH AUTHOR
+ David Korn
+.SH SEE ALSO
+\f5exit(2)\fP
+\f5longjmp(3)\fP
+\f5malloc(3)\fP
diff --git a/usr/src/lib/libast/common/man/stk.3 b/usr/src/lib/libast/common/man/stk.3
new file mode 100644
index 0000000000..d3b9d36376
--- /dev/null
+++ b/usr/src/lib/libast/common/man/stk.3
@@ -0,0 +1,160 @@
+.fp 5 CW
+.TH STK 3
+.SH NAME
+\fBstk\fR \- data stack storage library
+.SH SYNOPSIS
+.ta .75i 1.5i 2.25i 3i 3.75i 4.5i 5.25i 6i
+.PP
+.nf
+\f5
+#include <stk.h>
+
+Stk_t *stkopen(int \fIflags\fP);
+Stk_t *stkinstall(Stk_t *\fIstack\fP, char *(\fIoverflow\fP)(int));
+int stkclose(Stk_t *\fIstack\fP);
+void stklink(Stk_t *\fIstack\fP)
+
+char *stkalloc(Stk_t *\fIstack\fP, unsigned \fIsize\fP);
+char *stkcopy(Stk_t *\fIstack\fP, const char *\fIstring\fP);
+char *stkset(Stk_t *\fIstack\fP, char *\fIaddress\fP, unsigned \fIoffset\fP);
+
+char *stkseek(Stk_t *\fIstack\fP, unsigned \fIoffset\fP);
+int stktell(Stk_t *\fIstack\fP);
+char *stkptr(Stk_t *\fIstack\fP, unsigned \fIoffset\fP);
+char *stkfreeze(Stk_t *\fIstack\fP, unsigned \fIextra\fP);
+\fR
+.fi
+.SH DESCRIPTION
+.PP
+\f5stk\fP is a package of routines designed to provide efficient
+stack oriented dynamic storage.
+A stack abstraction consists of an ordered list of contiguous
+memory regions, called stack frames, that can hold objects of
+arbitrary size.
+A stack is represented by the type \f5Stk_t\fP
+defined in header \f5<stk.h>\fP.
+The type \f5Stk_t\fP is compatible with the type \f5Sfio_t\fP
+defined by the \f5sfio\fP(3) library.
+At any instant there is one active stack which can be referenced
+by the constant \f5stkstd\fP.
+Variable size objects can be
+added to the active stack
+and programs can reference these objects directly with pointers.
+In addition, the last object on the stack
+(referred to here as the current object)
+can be built incrementally.
+The current object has an associated offset that determines its
+current size.
+While the current object is being built incrementally,
+its location might
+change so that it is necessary to reference the object with
+relative offsets ranging from zero to the current offset of the object.
+.PP
+There is a preset initial active stack.
+To use an additional stack, it is necessary to create it and to
+install it as the active stack.
+A stack is created with the \f5stkopen\fP() function.
+A \fIflags\fP argument of \f5STK_SMALL\fP indicates that unused
+space on the stack should be freed whenever this stack ceases
+to be the active stack.
+If successful,
+\f5stkopen\fP() returns a pointer to a stack whose reference
+count is 1.
+Otherwise, \f5stkopen\fP() returns a null pointer.
+The \f5stklink\fP() function increases the reference count for the
+given \fIstack\fP.
+The \f5stkinstall\fP() function
+makes the specified \fIstack\fP the active stack and returns a pointer
+to the previous active stack.
+When the \fIoverflow\fP argument is not null,
+it specifies a function that will
+be called whenever \f5malloc\fP(3) fails while trying to grow the
+stack.
+The \fIoverflow\fP function will be called with the size that was passed
+to \f5malloc\fP(3).
+The \fIoverflow\fP function can call \f5exit\fP(3), call \f5longjmp\fP(3)
+or return.
+If the \f5overflow\fP function returns,
+it must return a pointer to a memory region of the given size.
+The default action is to write an error to standard error and to
+call \f5exit\fP(2) with a non-zero exit value.
+When \fIstack\fP is a null pointer,
+the active stack is not changed
+but the \fIoverflow\fP function for the active stack can be changed
+and a pointer to the active stack is returned.
+The \f5stkclose\fP() function decrements the reference count and
+frees the memory associated with
+the specified stack
+when the reference count is zero.
+The effect of subsequent references to objects
+on the stack are undefined.
+.PP
+The
+\f5stkalloc\fP() function returns an aligned pointer to space on the
+active stack that can be used to hold any object of the given \fIsize\fP.
+\f5stkalloc\fP() is similar to \f5malloc\fP(3) except that individual
+items returned by \f5stkalloc\fP() can not be freed.
+\f5stkalloc\fP() causes the offset of the current object to be set to
+zero.
+.PP
+The
+\f5stkcopy\fP() function copies the given string onto the stack
+and returns a pointer to the \fIstring\fP on the stack.
+\f5stkcopy\fP() causes the offset of the current object to be set to
+zero.
+.PP
+The \f5stkset\fP() function finds the frame containing the given
+\fIaddress\fP, frees all frames that were created after the one containing
+the given \fIaddress\fP, and sets the current object to the given
+\fIaddress\fP.
+The top of the current object is set to \fIoffset\fP bytes from
+current object.
+If \fIaddress\fP is not the address of an object on the
+stack the result is undefined.
+.PP
+The \f5sfio\fP(3) output functions can be used to build
+current object incrementally.
+An object that is built incrementally on the stack will
+always occupy contiguous memory within a stack frame but
+until \f5stkfreeze\fP() is called,
+the location in memory for the object can change.
+There is a current offset associated with the current object that
+determines where subsequent operations apply.
+Initially, this offset is zero, and the offset changes as a result
+of the operations you specify.
+The \f5stkseek\fP() function is used set the offset for the
+current object.
+The \fIoffset\fP argument to \f5stkseek\fP() specifies the new
+offset for the current object.
+The frame will be extended or moved
+if \f5offset\fP causes the new current offset to extend beyond the
+current frame.
+\f5stkseek\fP() returns a pointer to the beginning of the current object.
+The \f5stktell\fP() function gives the offset of the current object.
+.PP
+The \f5stkptr\fP() function converts the given \f5offset\fP
+for the current object into a memory address on the stack.
+This address is only valid until another stack operation is given.
+The result is not defined if \fIoffset\fP exceeds the size of the current
+object.
+The \f5stkfreeze\fP()
+function terminates the current object on the
+stack and returns a pointer to the beginning of this object.
+If \fIextra\fP is non-zero, \fIextra\fP bytes are added to the stack
+before the current object is terminated. The first added byte will
+contain zero and the contents of the remaining bytes are undefined.
+.PP
+.SH HISTORY
+The
+\f5stk\fP
+interface was derived from similar routines in the KornShell code
+that is used for building parse trees and carrying out expansions.
+It provides an efficient mechanism for grouping dynamically allocated
+objects so that they can be freed all at once rather than individually.
+.SH AUTHOR
+ David Korn
+.SH SEE ALSO
+\f5exit(2)\fP
+\f5longjmp(3)\fP
+\f5malloc(3)\fP
+\f5sfio(3)\fP
diff --git a/usr/src/lib/libast/common/man/strcopy.3 b/usr/src/lib/libast/common/man/strcopy.3
new file mode 100644
index 0000000000..c08d885b23
--- /dev/null
+++ b/usr/src/lib/libast/common/man/strcopy.3
@@ -0,0 +1,54 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH STRCOPY 3
+.SH NAME
+strcopy \- copy strings
+.SH SYNOPSIS
+.L "char* strcopy(char* a, char* b)"
+.SH DESCRIPTION
+.I strcopy
+copies the nul-terminated string
+.I b
+into
+.IR a .
+A pointer to the 0 character in
+.I a
+is returned.
+.SH "SEE ALSO"
+strcpy(3)
diff --git a/usr/src/lib/libast/common/man/strdup.3 b/usr/src/lib/libast/common/man/strdup.3
new file mode 100644
index 0000000000..3b26ec4f23
--- /dev/null
+++ b/usr/src/lib/libast/common/man/strdup.3
@@ -0,0 +1,55 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH STRDUP 3
+.SH NAME
+strdup \- duplicate nul-terminated string
+.SH SYNOPSIS
+.L "char* strdup(char* s)"
+.SH DESCRIPTION
+.I strdup
+copies the nul-terminated string
+.I s
+to a new location provided by
+.IR malloc (3)
+and returns a pointer to the new copy.
+0 is returned if
+.IR malloc (3)
+failed.
+.SH "SEE ALSO"
+malloc(3), memdup(3)
diff --git a/usr/src/lib/libast/common/man/strelapsed.3 b/usr/src/lib/libast/common/man/strelapsed.3
new file mode 100644
index 0000000000..8c3fa4adde
--- /dev/null
+++ b/usr/src/lib/libast/common/man/strelapsed.3
@@ -0,0 +1,77 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH STRELAPSED 3
+.SH NAME
+strelapsed \- parse elapsed time expression
+.SH SYNOPSIS
+.L "unsigned long strelapsed(char* buf, char** next, int persec)"
+.SH DESCRIPTION
+.I strelapsed
+returns a pointer to a string representation of the elapsed time for
+.L (count/persec)
+seconds.
+The two largest time units are used, limiting the return value length
+to at most 6 characters.
+The units are:
+.TP
+.B s
+seconds
+.TP
+.B m
+minutes
+.TP
+.B h
+hours
+.TP
+.B days
+.TP
+.B weeks
+.TP
+.B M
+months
+.TP
+.B Y
+years
+.TP
+.B S
+scores
+.SH "SEE ALSO"
+strelapsed(3)
+.SH CAVEATS
+The return value points to a static area that is overwritten on each call.
diff --git a/usr/src/lib/libast/common/man/strerror.3 b/usr/src/lib/libast/common/man/strerror.3
new file mode 100644
index 0000000000..0084e3aae8
--- /dev/null
+++ b/usr/src/lib/libast/common/man/strerror.3
@@ -0,0 +1,53 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH STRERROR 3
+.SH NAME
+strerror \- return error message string given error number
+.SH SYNOPSIS
+.L "char* strerror(int err)"
+.SH DESCRIPTION
+.I strerror
+returns the error message string corresponding to the error message number
+.IR err .
+.BI "Error " nnn
+is returned if
+.I err
+is invalid.
+.SH "SEE ALSO"
+error(3)
diff --git a/usr/src/lib/libast/common/man/stresc.3 b/usr/src/lib/libast/common/man/stresc.3
new file mode 100644
index 0000000000..c09a0e9fc8
--- /dev/null
+++ b/usr/src/lib/libast/common/man/stresc.3
@@ -0,0 +1,53 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH STRESC 3
+.SH NAME
+stresc \- convert character constants in string
+.SH SYNOPSIS
+.L "int stresc(char* s)"
+.SH DESCRIPTION
+.I stresc
+converts
+.L \e
+character constant expressions in the nul-terminated string
+.I s
+in place and returns the length of the converted
+.IR s .
+.SH "SEE ALSO"
+chresc(3), ctoi(3)
diff --git a/usr/src/lib/libast/common/man/streval.3 b/usr/src/lib/libast/common/man/streval.3
new file mode 100644
index 0000000000..2b491c8595
--- /dev/null
+++ b/usr/src/lib/libast/common/man/streval.3
@@ -0,0 +1,83 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH STREVAL 3
+.SH NAME
+streval \- long integer arithmetic expression evaluator
+.SH SYNOPSIS
+.L "long streval(char* s, char** e, long (*conv)(char* cs, char** ce))"
+.SH DESCRIPTION
+.I streval
+evaluates the long integer arithmetic expression in the nul-terminated string
+.I s
+and returns the result.
+If
+.I e
+is not 0 then
+.I *e
+is set to point to the first unknown character in the expression.
+.PP
+If
+.I conv
+is not 0 then it is called when an unknown token is encountered in
+.IR s .
+.I cs
+points to the beginning of the unknown token.
+The return value is the long integer value of the unknown token and
+.I ce
+must be set to point to the first character after the unknown token.
+If an expression syntax error is encountered the
+.I conv
+is called with
+.I cs
+set to 0 and
+.I *ce
+pointing to the error message text.
+.PP
+In addition to the normal C expressions and integer constant styles,
+numbers in any base
+.I b
+<= 2 <=36
+may be represented as
+.IR b # nnnn ,
+where the extra digits in
+.I nnnn
+are taken from
+.BR [A-Z] .
+.SH "SEE ALSO"
+strtol(3)
diff --git a/usr/src/lib/libast/common/man/strgid.3 b/usr/src/lib/libast/common/man/strgid.3
new file mode 100644
index 0000000000..d7a26634c2
--- /dev/null
+++ b/usr/src/lib/libast/common/man/strgid.3
@@ -0,0 +1,53 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH STRGID 3
+.SH NAME
+strgid \- return group name given group number
+.SH SYNOPSIS
+.L "char* strgid(int gid)"
+.SH DESCRIPTION
+.I strgid
+returns the group id name string given the group number
+.IR gid .
+.I strgid
+maintains an internal cache to avoid repeated password database scans
+by the low level
+.IR getgrgid (3).
+.SH "SEE ALSO"
+getgrent(3)
diff --git a/usr/src/lib/libast/common/man/strmatch.3 b/usr/src/lib/libast/common/man/strmatch.3
new file mode 100644
index 0000000000..5f5af8989e
--- /dev/null
+++ b/usr/src/lib/libast/common/man/strmatch.3
@@ -0,0 +1,101 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH STRMATCH 3
+.SH NAME
+strmatch \- match shell file patterns
+.SH SYNOPSIS
+.L "int strmatch(char* s, char* p)"
+.br
+.L "char* submatch(char* s, char* p, int m)"
+.SH DESCRIPTION
+.I strmatch
+compares the string
+.I s
+with the shell pattern
+.I p
+and returns 1 for match and 0 otherwise.
+.I submatch
+does a leading substring match of the shell pattern
+.I p
+with the string
+.IR s .
+If
+.I m
+is 0 then the match is minimal, otherwise a maximal match is done.
+A pointer to the first character after the matched substring is returned,
+.I 0
+if there is no match.
+.PP
+Except for
+.I &
+and
+.IR ! ,
+each shell pattern has an equivalent
+.IR egrep (1)
+construct.
+.EX
+ \fBsh pattern egrep RE description\fP
+ * .* 0 or more chars
+ ? . any single char
+ [.] [.] char class
+ [!.] [^.] negated char class
+ *(.) (.)* 0 or more of
+ +(.) (.)+ 1 or more of
+ ?(.) (.)? 0 or 1 of
+ (.) (.) 1 of
+ @(.) (.) 1 of
+ a|b a|b a or b
+ a&b a and b
+ !(.) none of
+.EE
+.L \e
+is used to escape *, ?, (, |, &, ), [, and \e
+outside of [...].
+.SH "SEE ALSO"
+grep(1)
+.SH BUGS
+An unbalanced
+.L )
+terminates the top level pattern.
+.br
+Nested
+.L &
+and
+.L !
+constructs are non-intuitive and are computationally intensive.
diff --git a/usr/src/lib/libast/common/man/stropt.3 b/usr/src/lib/libast/common/man/stropt.3
new file mode 100644
index 0000000000..778ab4f255
--- /dev/null
+++ b/usr/src/lib/libast/common/man/stropt.3
@@ -0,0 +1,130 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH STROPT 3
+.SH NAME
+stropt \- table driven option expression evaluator
+.SH SYNOPSIS
+.L "#include <namval.h>"
+.br
+.L "int stropt(char* s, struct namval* tab,
+.br
+.L " int (*fun)(void* a, struct namval* p, int n, char* v),"
+.br
+.L " void* a)"
+.SH DESCRIPTION
+.I stropt
+parses option expressions in the nul-terminated string
+.I s
+using the option names in
+.IR tab .
+.I tab
+is an array of
+.B "struct namval"
+name value pairs:
+.EX
+char* name;
+int value;
+.EE
+The last entry must be followed by a sentinel with
+.B name
+set to 0.
+.PP
+An option expression contains 0 or more of [\fBno\fP]\fIname\fP[=\fIvalue\fP]
+separate by
+.B space
+or
+.BR tab ,
+where
+.I name
+must be one of the option names in
+.IR tab ,
+.I value
+is an optional value, and
+.B no
+is for Boolean options.
+Each option is passed to
+.I fun
+for processing.
+.I a
+is the
+.L void*
+pointer that is passed from the
+.I stropt
+call but is otherwise not interpreted.
+.I p
+points to the option name value pair from
+.IR tab .
+.I n
+is 0 if
+.B no
+preceeded the option
+.I name
+and
+.I v
+points to the beginning of the option
+.I value
+in
+.IR s .
+and
+If
+.I name
+is not found in
+.I tab
+then
+.I fun
+is called with
+.I p
+pointing to an internal
+.I namval
+entry with
+.I p\->name
+pointing to the unknown option and
+.I p\->value
+set to the
+.I value
+of the sentinel entry in
+.IR tab .
+.PP
+If
+.I fun
+returns non-zero then this value is returned and no further
+options are processed.
+Otherwise
+.I stropt
+returns 0 after processing all options.
diff --git a/usr/src/lib/libast/common/man/strperm.3 b/usr/src/lib/libast/common/man/strperm.3
new file mode 100644
index 0000000000..9b68946f5f
--- /dev/null
+++ b/usr/src/lib/libast/common/man/strperm.3
@@ -0,0 +1,109 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH STRPERM 3
+.SH NAME
+strperm \- evaluate file permission expression
+.SH SYNOPSIS
+.L "int strperm(char* s, char** e, int p)"
+.SH DESCRIPTION
+.I strperm
+applies a file permission expression in the nul-terminated string
+.I s
+to the initial file permission mask
+.IR p .
+The new permission mask is returned.
+If
+.I e
+not 0 then
+.I *e
+is set to point to the first unrecognized character in
+.IR s .
+.PP
+A tape device specification is composed of one or more
+.I who-op-permission
+terms separated by
+.BR , .
+.I who
+selects portions of the permission bits and may be any combination of:
+.TP 3
+.B u
+the user permission bits;
+.TP
+.B g
+the group permission bits;
+.TP
+.B o
+the `other' permission bits;
+.TP
+.B a
+all permission bits.
+.PP
+If omitted, all permission bits are selected.
+.I op
+specifies how the original permission
+.I p
+is to be modified:
+.TP 3
+.B +
+.br
+.ns
+.B |
+the new bits are set in
+.IR p ;
+.TP 3
+.B \-
+the new bits are cleared in
+.IR p ;
+.TP
+.B &
+the new bits are and'd with
+.IR p ;
+.TP
+.B =
+the select bits in
+.I p
+are set equal to the new bits
+.PP
+A permission expression term may also be an octal number.
+Octal specifications are inherently non-portable.
+Refer to
+.IR chmod (1)
+for an explanation of this form.
+.SH "SEE ALSO"
+chmod(1), ls(1), strmode(3)
diff --git a/usr/src/lib/libast/common/man/strsignal.3 b/usr/src/lib/libast/common/man/strsignal.3
new file mode 100644
index 0000000000..414198087c
--- /dev/null
+++ b/usr/src/lib/libast/common/man/strsignal.3
@@ -0,0 +1,53 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH STRSIGNAL 3
+.SH NAME
+strsignal \- return signal description string given signal number
+.SH SYNOPSIS
+.L "char* strsignal(int sig)"
+.SH DESCRIPTION
+.I strsignal
+returns the signal description string corresponding to the signal number
+.IR sig .
+.BI "Signal " nnn
+is returned if
+.I sig
+is invalid.
+.SH "SEE ALSO"
+signal(2), sigvec(2)
diff --git a/usr/src/lib/libast/common/man/strsort.3 b/usr/src/lib/libast/common/man/strsort.3
new file mode 100644
index 0000000000..c48cfc26c6
--- /dev/null
+++ b/usr/src/lib/libast/common/man/strsort.3
@@ -0,0 +1,73 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH HSORT 3
+.SH NAME
+hsort \- array heap sort
+.SH SYNOPSIS
+.EX
+#include <ast.h>
+
+void strsort(char** \fIarray\fP, int \fIelements\fP, int (*\fIcompare\fP)(const char* \fIa\fP, const char* \fIb\fP));
+.EE
+.SH DESCRIPTION
+.L strsort
+does a heap sort on the array of pointers
+.I array
+with
+.I elements
+elements using the comparison function
+.IR compare .
+.I compare
+returns
+.L \-1
+if
+.I a
+is lexicographically less than
+.IR b ,
+.L 0
+if
+.I a
+is equal to
+.IR b ,
+and
+.L 1
+if
+.I a
+is lexicographically greater than
+.IR b .
diff --git a/usr/src/lib/libast/common/man/strtape.3 b/usr/src/lib/libast/common/man/strtape.3
new file mode 100644
index 0000000000..06c33ba978
--- /dev/null
+++ b/usr/src/lib/libast/common/man/strtape.3
@@ -0,0 +1,86 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH STRTAPE 3
+.SH NAME
+strtape \- convert string to tape device pathname
+.SH SYNOPSIS
+.L "char* strtape(char* s, char** e)"
+.SH DESCRIPTION
+.I strtape
+converts the generic tape device specification in the nul-terminated string
+.I s
+to a local tape device pathname.
+A pointer to the device pathname is returned.
+If
+.I e
+not 0 then
+.I *e
+is set to point to the first unrecognized character in
+.IR s .
+.PP
+A tape device specification is composed of
+.IR unit-density-rewind .
+All are optional.
+.I unit
+is a unit number in the range
+.BR [0-7] .
+The default unit is
+.BR 1 .
+Density may be one of:
+.TP 3
+.B l
+for low;
+.TP 3
+.B m
+for medium, and
+.TP
+.B h
+for high.
+.PP
+The default is
+.BR m .
+.I rewind
+is
+.B n
+for no-rewind on device close.
+The default is to rewind on device close.
+.SH "SEE ALSO"
+pax(1), tar(1)
+.SH CAVEATS
+The return value points to a static area that is overwritten on each call.
diff --git a/usr/src/lib/libast/common/man/strton.3 b/usr/src/lib/libast/common/man/strton.3
new file mode 100644
index 0000000000..bfcf8918a0
--- /dev/null
+++ b/usr/src/lib/libast/common/man/strton.3
@@ -0,0 +1,97 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH STRTON 3
+.SH NAME
+strton \- convert string to long integer
+.SH SYNOPSIS
+.L "long strton(char* s, char** e)"
+.SH DESCRIPTION
+.I strton
+converts the nul-terminated string
+.I s
+to a long integer.
+If
+.I e
+not 0 then
+.I *e
+is set to point to the first unrecognized character in
+.IR s .
+Leading spaces in
+.I s
+are ignored.
+.PP
+A number is composed of
+.IR sign-base-number-suffix .
+All but
+.I number
+are optional.
+.I sign
+may be \+ or \-.
+.I base
+may be:
+.TP
+.B 0x
+for hexadecimal;
+.TP
+.B 0
+for octal, or
+.TP
+.IR nn #
+for base
+2 \(le
+.I nn
+\(le 36.
+.PP
+For bases greater than 10 the additional digits are take from the set
+.BR [a-zA-Z] .
+The suffix multiplies the converted number and may be:
+.TP
+.B b
+block (512)
+.TP
+.B g
+giga (1024 * 1024 * 1024)
+.TP
+.B k
+kilo (1024)
+.TP
+.B m
+mega (1024 * 1024)
+.SH "SEE ALSO"
+atoi(3), scanf(3), strtod(3)
diff --git a/usr/src/lib/libast/common/man/struid.3 b/usr/src/lib/libast/common/man/struid.3
new file mode 100644
index 0000000000..522deb5b82
--- /dev/null
+++ b/usr/src/lib/libast/common/man/struid.3
@@ -0,0 +1,53 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH STRUID 3
+.SH NAME
+struid \- return user name given user number
+.SH SYNOPSIS
+.L "char* struid(int uid)"
+.SH DESCRIPTION
+.I struid
+returns the user id name string given the user number
+.IR uid .
+.I struid
+maintains an internal cache to avoid repeated password database scans
+by the low level
+.IR getpwuid (3).
+.SH "SEE ALSO"
+getpwent(3)
diff --git a/usr/src/lib/libast/common/man/swap.3 b/usr/src/lib/libast/common/man/swap.3
new file mode 100644
index 0000000000..82176de205
--- /dev/null
+++ b/usr/src/lib/libast/common/man/swap.3
@@ -0,0 +1,138 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH SWAP 3
+.SH NAME
+swap \- integral representation conversion routines
+.SH SYNOPSIS
+.L "#include <swap.h>"
+.sp
+.L "int swapop(const void* internal, const void* external, int width);
+.L "int_max swapget(int op, const void* from, int width);"
+.L "void* swapput(int op, void* to, int width, int_max value);"
+.L "void* swapmem(int op, const void* from, void* to, size_t n);"
+.SH DESCRIPTION
+These routines convert integral constants between internal and
+external representations.
+They are used to handle binary data generated by foreign programs.
+New binary data representations should use the compact canonical form
+provided by the
+.IR sfio (3)
+routines
+.L sfputu
+and
+.LR sgetu .
+.PP
+.L swapop
+returns the swap operation required to convert the
+.L width
+byte integer
+.L external
+to the
+.L width
+byte integer
+.LR internal .
+The swap operation is a bit mask:
+.TP
+.L 0
+No swapping necessary.
+.TP
+.L 1
+Swap byte
+.L 0
+with byte
+.LR 1 .
+.TP
+.L 2
+Swap bytes
+.L 0
+and
+.L 1
+with bytes
+.L 2
+and
+.LR 3 .
+.TP
+.L 4
+Swap bytes
+.L 0-3
+with bytes
+.LR 4-7 ,
+and so on.
+The largest native integral type is defined by the macro
+.L int_max
+in the header
+.L <int.h>
+described in
+.IR int (3).
+.PP
+.L swapget
+returns the
+.L width
+byte integer in the buffer
+.LR from ,
+swapped according to
+.LR op .
+.PP
+.L swapput
+copies the
+.L width
+byte integer
+.L value
+into the buffer
+.LR to ,
+swapped according to
+.LR op .
+.L to
+is returned.
+.PP
+.L swapmem
+swaps
+.L n
+bytes from the buffer
+.L from
+to the buffer
+.L to
+according to
+.LR op .
+.L to
+and
+.L from
+may be the same.
+.SH "SEE ALSO"
+int(3)
diff --git a/usr/src/lib/libast/common/man/tab.3 b/usr/src/lib/libast/common/man/tab.3
new file mode 100644
index 0000000000..e1c76f3534
--- /dev/null
+++ b/usr/src/lib/libast/common/man/tab.3
@@ -0,0 +1,74 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH TAB 3
+.SH NAME
+tab \- simple table lookup routines
+.SH SYNOPSIS
+.L "#include <ast.h>"
+.sp
+.L "int tabindex(const void* tab, int size, const char* name);"
+.L "void* tablook(const void* tab, int size, const char* name);"
+.SH DESCRIPTION
+These routines do linear lookups in
+.I small
+tables (on the order of 32 elements).
+Each table element has a size of
+.L size
+bytes and the beginning of the element points to a name that is
+matched by the lookup routines.
+.PP
+.L tabindex
+returns the index of the table element in
+.L tab
+that matches
+.LR name .
+If there is no match then
+.L \-1
+is returned.
+.PP
+.L tablook
+returns a pointer to the table element in
+.L tab
+that matches
+.LR name .
+If there is no match then
+.L 0
+is returned.
+.SH "SEE ALSO"
+hash(3)
diff --git a/usr/src/lib/libast/common/man/tm.3 b/usr/src/lib/libast/common/man/tm.3
new file mode 100644
index 0000000000..12eb4ecf4a
--- /dev/null
+++ b/usr/src/lib/libast/common/man/tm.3
@@ -0,0 +1,775 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH TM 3
+.SH NAME
+tm \- seconds resolution time conversion support
+.SH SYNOPSIS
+.L "#include <tm.h>"
+.SH DESCRIPTION
+The
+.I tm
+library supports conversion between
+string date specifications,
+seconds reolution
+.L time_t
+clock values and
+.LR Tm_t .
+.L Tm_t
+contains the elements of
+.L "struct tm"
+along with these additions:
+.TP
+.L "unsigned _ast_int4_t tm_nsec"
+The subsecond portion of the time in nanoseconds.
+.TP
+.L "Tm_zone_t* tm_zone"
+The time zone name.
+.PP
+.L localtime()
+and
+.L gmtime()
+(see
+.BR ctime (3))
+are used to determine local time zone and savings time information.
+.PP
+.L time_t
+values are the number of seconds since the epoch,
+.BR "Jan 1 00:00:00 GMT 1970" ,
+with leap seconds omitted.
+.PP
+The global variable
+.L "int tm_info.flags"
+contains flags that allow all programs using the library
+to be controlled in a consistent manner.
+.L tm_info.flags
+is initialized by the
+.L tminit()
+routine described below, and may be explicitly reset after
+.L tminit()
+is called.
+The flags are:
+.TP
+.L TM_ADJUST
+Set by
+.L tminit()
+if
+.L localtime()
+and
+.L gmtime()
+do not compensate for leap seconds.
+.TP
+.L TM_LEAP
+.L time_t
+values are interpreted as if they include leap seconds.
+Set by
+.L tminit()
+if the
+.L leap
+option is set in the
+.L TM_OPTIONS
+environment variable.
+.TP
+.L TM_UTC
+Times are relative to
+.B UTC
+(universal coordinated time, i.e.,
+.BR GMT .)
+Otherwise times are relative to the local time zone.
+Set by
+.L tminit()
+if the time zone name matches one of
+.L tm_info.format[43]
+through
+.L tm_info.format[46]
+described below.
+If the time zone name is not determined by
+.L localtime()
+then the environment variables
+.L TZNAME
+(as described in BSD 4.3) and
+.L TZ
+(as described in System V)
+are checked, in order.
+If this fails then the time zone name is constructed using
+the local time zone offset.
+.PP
+The routines are:
+.TP
+.L "time_t tmdate(const char* date, char** end, time_t* clock)"
+Parses the date specification
+.L date
+using the
+.L tm_info.format
+string table (described below)
+and returns the equivalent
+.L time_t
+value.
+If
+.RL non- NULL ,
+.L end
+is set to the position of the first unrecognized character in
+.LR date .
+.L clock
+is used to provide default values for omitted components in
+.LR date .
+If
+.L clock
+is
+.L NULL
+then the current time is used.
+.TP
+.L "Tm_t* tmfix(Tm_t* tp)"
+Corrects any out of bounds fields in
+.L tp
+and returns
+.L tp
+as its value.
+The corrections start with
+.L tp->tm_sec
+and propagate down to
+.LR tp->tm_year .
+For example, if
+.L tp->tm_sec
+were 61 then it would change to 1 and
+.L tp->tm_min
+would be incremented by 1, and so on.
+.L tp->tm_isdst
+is not changed -- call
+.L tmtime()
+to determine its proper value after the
+.L tmfix()
+adjustments.
+.TP
+.L "char* tmfmt(char* buf, size_t len, const char* format, time_t* clock)"
+Formats the date pointed to by
+.L clock
+into the buffer
+.L buf
+with size
+.L len
+bytes according to the format specification
+.LR format .
+If
+.L format
+is
+.L NULL
+or empty then the string
+.L tm_info.format[40]
+is used.
+If
+.L clock
+is
+.L NULL
+then the current time is used.
+A pointer to the end of
+.L buf
+(i.e., the terminating
+.LR "'\e0'" )
+is returned.
+.RS
+.PP
+.L format
+is in
+.BR printf (3)
+style, where
+.RI % field
+names a fixed size field, zero padded if necessary,
+and
+.I \ec
+and
+.I \ennn
+sequences are as in C. Invalid
+.RI % field
+specifications and all other characters are copied
+without change.
+.I field
+may be preceded by
+.B %-
+to turn off padding or
+.B %_
+to pad with space, otherwise numeric fields
+are padded with
+.B 0
+and string fields are padded with space.
+.I field
+may also be preceded by
+.B E
+for alternate era representation or
+.B O
+for alternate digit representation (if supported by the current locale.)
+Finally, an integral
+.I width
+preceding
+.I field
+truncates the field to
+.I width
+characters.
+sequences are interpreted as in the C language.
+String field values are taken from the
+.L tm_info.format
+string table.
+The
+.I fields
+are:
+.TP
+.PD 0
+.B %
+.B %
+character.
+.TP
+.B a
+Abbreviated weekday name.
+.TP
+.B A
+Full weekday name.
+.TP
+.B b
+Abbreviated month name.
+.TP
+.B c
+.BR ctime (3)
+style date without the trailing
+.BR newline .
+.TP
+.B C
+.BR date (1)
+style date.
+.TP
+.B d
+Day of month number.
+.TP
+.B D
+Date as
+.IR mm / dd / yy .
+.TP
+.B e
+Blank padded day of month number.
+.TP
+.B E
+Unpadded day of month number.
+.TP
+.B f
+Locale default override date format.
+.TP
+.B F
+Locale default date format
+.RL ( tm_info.format[40] .)
+.TP
+.B h
+Abbreviated month name.
+.TP
+.B H
+24-hour clock hour.
+.TP
+.B i
+International
+.BR date (1)
+date that includes the time zone type name
+.RL ( tm_info.format[107] .)
+.TP
+.B I
+12-hour clock hour.
+.TP
+.B j
+1-offset Julian date.
+.TP
+.B J
+0-offset Julian date.
+.TP
+.B k
+.BR date (1)
+style date
+.RL ( tm_info.format[106] .)
+.TP
+.B K
+Language neutral, all numeric, no embedded space date
+with larger to smaller time units from left to right,
+suitable for sorting:
+.LR '"%Y-%m-%d+%H:%M:%S"' .
+.TP
+.B l
+.BR ls (1)
+.B \-l
+date that lists recent dates with
+.L %g
+and distant dates with
+.BR %G .
+.TP
+.B m
+Month number.
+.TP
+.B M
+Minutes.
+.TP
+.B n
+.B newline
+character.
+.TP
+.B N
+The time zone type or nation code.
+.TP
+.B p
+Meridian (e.g.,
+.B AM
+or
+.BR PM .)
+.TP
+.B q
+The nanosecond part of the time.
+.TP
+\fB%Q\fP\fI<delim>recent<delim>distant<delim>\fP
+Recent dates are formatted with
+.I recent
+and distand dates are formatted with
+.IR distant ,
+where
+.I <delim>
+is any character not appearing in
+.I recent
+or
+.IR distant .
+.TP
+.B r
+12-hour time as
+.IR hh : mm : ss
+.IR meridian .
+.TP
+.B R
+24-hour time as
+.IR hh : mm .
+.TP
+.B s
+Seconds since the epoch.
+.RI . prec
+preceding
+.B s
+appends
+.I prec
+nanosecond digits,
+.B 9
+if
+.I prec
+is omitted.
+.TP
+.B S
+.I seconds.subseconds
+since the epoch.
+.TP
+.B t
+.B tab
+character.
+.TP
+.B T
+24-hour time as
+.IR hh : mm : ss .
+.TP
+.B u
+Weeday number with 1 for Monday, 7 for Sunday.
+.TP
+.B U
+Week number with Sunday as the first day.
+.TP
+.B V
+ISO week number (i18n is \fIfun\fP.)
+.TP
+.B w
+Weekday number with 0 for Sunday, 6 for Saturday.
+.TP
+.B W
+Week number with Monday as the first day.
+.TP
+.B x
+Local date style, using
+.LR tm_info.format[39] ,
+that includes the month, day and year.
+.TP
+.B X
+Local time style, using
+.LR tm_info.format[38] ,
+that includes the hours and minutes.
+.TP
+.B y
+2-digit year (you'll be sorry.)
+.TP
+.B Y
+4-digit year.
+.TP
+.B z
+Time zone
+.I SHHMM
+west of GMT offset where
+.I S
+is
+.B +
+or
+.BR - .
+.TP
+.B Z
+Time zone name.
+.TP
+=[=]][-+]]\fIflag\fP
+Set (default or +) or clear (-)
+.I flag
+in
+.L tm_info.flags
+for the remainder of
+.IR format ,
+or for the remainder of the process if
+.B ==
+is specified.
+.I flag
+may be:
+.RS
+.TP
+.B l
+.L (TM_LEAP)
+Enable leap second adjustments.
+.TP
+.B s
+.L (TM_SUBSECOND)
+Append nanosecond
+.B .%N
+to
+.BR %S .
+.TP
+.B u
+.L (TM_UTC)
+UTC time zone.
+.RE
+.TP
+.B #
+Equivalent to
+.BR %s .
+.TP
+\fP?\fP\fIalternate\fP
+Use
+.I alternate
+format is a default format override has not been specified.
+e.g.,
+.BR ls (1)
+uses
+.BR %?%l .
+Export
+\f5TM_OPTIONS="format='\fP\fIoverride\fP\f5'"\fP
+to override the default.
+.PD
+.RE
+.TP
+.L "void tminit(Tm_zone_t* zone)"
+Implicitly called by the other
+.I tm
+library routines to initialize global data, including the
+.L tm_info.format
+table and the
+.L tm_info.flags
+global flags.
+Global data should only be modified after an explicit call to
+.LR tminit .
+If
+.L "zone != 0"
+then it specifies a time zone other that the local time zone.
+.TP
+.L "void tmset(Tm_zone_t* zone);"
+.L tmset
+sets the reference timezoe to
+.LR zone .
+.L tm_info.local
+points to the local timezone and
+.L tm_info.zone
+points to the current reference timezone.
+.TP
+.L "time_t tmleap(time_t* clock)"
+Returns a
+.L time_t
+value for the time pointed to by
+.L clock
+with leap seconds adjusted for external
+routines that do not handle leap seconds.
+If
+.L clock
+is
+.L NULL
+then the current time is used.
+Adjustments are only done if the
+.L TM_ADJUST
+flag is set in
+.LR tm_info.flags .
+.TP
+.L "Tm_t* tmmake(time_t* clock)"
+Returns a pointer to the
+.L Tm_t
+struct corresponding to the time pointed to by
+.LR clock .
+If
+.L clock
+is
+.L NULL
+then the current time is used.
+.TP
+.L "time_t tmtime(Tm_t* tp, int west)"
+Returns the
+.L time_t
+value corresponding to
+.LR tp .
+If
+.L west
+is
+.L TM_LOCALZONE
+then
+.L tm
+is relative to the local time zone,
+otherwise
+.L west
+is the number of minutes west of
+.B UTC
+with daylight savings time taken into account.
+.LR tp->tm_wday ,
+.LR tp->tm_yday
+and
+.L tp->tm_isdst
+are ignored in the conversion.
+.PP
+The library routines use a table of date strings pointed to by
+.LR "char** tm_info.format" .
+The indices in
+.L tm_info.format
+are fixed by category.
+.L tm_info.format
+may be changed to point to other tables
+according to local language and date conventions.
+The contents by index (showing the USA English values) are:
+.RS
+.TP
+.PD 0
+.B 0-11
+3-character abbreviated month names.
+.TP
+.B 12-23
+Full month names.
+.TP
+.B 24-30
+3-character abbreviated weekday names.
+.TP
+.B 31-37
+Full weekday names.
+.TP
+.B 38
+.L tmfmt()
+local time format used by the
+.B %X
+field.
+.TP
+.B 39
+.L tmfmt()
+local date format used by the
+.B %x
+field.
+.TP
+.B 40
+.L tmfmt()
+format used if the
+.L format
+argument is
+.L NULL
+or empty.
+.TP
+.B 41-42
+Meridian names: AM, PM.
+.TP
+.B 43-46
+.B UTC
+time zone names: GMT, UTC, UCT, CUT.
+.TP
+.B 47-50
+Daylight savings time suffix names: DST.
+.TP
+.B 51-54
+Suffixes to be ignored when matching strings in
+.LR tmfmt() .
+.TP
+.B 55-61
+Time part names: second, hour, minute, day, week, month, year.
+.TP
+.B 62-65
+Hours of the day names: midnight, morning, noon, evening.
+.TP
+.B 66-68
+Relative day names: yesterday, today, tomorrow.
+.TP
+.B 69-71
+Past relative time references: last, ago, past.
+.TP
+.B 72-75
+Current relative time references: this, now, current.
+.TP
+.B 75-77
+Future relative time references: next, hence, coming.
+.TP
+.B 78-80
+Exact relative time references: exactly.
+.TP
+.B 81-84
+Noise words to be ignored: at, in, on.
+.TP
+.B 85-94
+Ordinal suffixes: st, nd, rd, th, th, th, th, th, th, th.
+.TP
+.B 95-104
+Digit names.
+.TP
+.B 105
+The
+.L tmfmt()
+format equivalent for
+.BR ctime (3):
+.LR '"%a %b %e %T %Y"' .
+.TP
+.B 106
+The
+.L tmfmt()
+.BR date (1)
+default format:
+.LR '"%a %b %e %T %Z %Y"' .
+.TP
+.B 107
+The
+.L tmfmt()
+.BR date (1)
+international format:
+.LR '"%a %b %e %T %z %Z %Y"' .
+.TP
+.B 108
+The
+.L tmfmt()
+.BR ls (1)
+recent date format:
+.LR '"%b %e %H:%M"' .
+.TP
+.B 109
+The
+.L tmfmt()
+.BR ls (1)
+distant date format:
+.LR '"%b %e %Y"' .
+.TP
+.B 110
+The
+.L tmfmt()
+.BR date (1)
+meridian date format:
+.LR '"%I:%M:%S %p"' .
+.TP
+.B 111
+The ERA name.
+.TP
+.B 112
+ERA alternative for
+.BR 39 .
+.TP
+.B 113
+ERA alternative for
+.BR 38 .
+.TP
+.B 114
+ERA alternative for
+.BR 40 .
+.TP
+.B 115
+The ERA year.
+.TP
+.B 116-125
+Ordinal names: first, \fIno second!\fP, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth.
+.TP
+.B 126-128
+Final time references, as in \fIthe last in the list\fP: final, ending, nth.
+.PD
+.RE
+.PP
+Low level support functions and data are described in
+.LR <tm.h> .
+.SH EXAMPLES
+.EX
+#include <tm.h>
+main() {
+ int i;
+ time_t t;
+ char buf[128];
+ struct {
+ char* date;
+ char* format;
+ } x[] = {
+ "now", "%i",
+ "2 months ago", "%C",
+ "this Wednesday noon", "%x %I:%M %p",
+ "last December 25", "%A",
+ 0, 0
+ };
+ for (i = 0; x[i].date; i++) {
+ t = tmdate(x[i].date, (char*)0, (time_t*)0);
+ (void)tmfmt(buf, sizeof(buf), x[i].format, &t);
+ puts(buf);
+ }
+}
+.EE
+produces
+.EX
+Fri Sep 30 12:10:14 USA EDT 1988
+Fri Jul 1 00:00:00 EDT 1988
+10/05/88 12:00 PM
+Friday
+.EE
+.SH "SEE ALSO"
+.BR date (1),
+.BR time (2),
+.BR ctime (3)
+.SH BUGS
+The C library static
+.L "struct tm"
+values may get clobbered by
+.I tm
+library routines as the
+.BR ctime (3)
+and
+.BR localtime (3)
+routines typically return pointers to a single static
+.L "struct tm"
+area.
+.L tmdate()
+uses an internal international time zone name table that will
+probably always be incomplete.
diff --git a/usr/src/lib/libast/common/man/tmx.3 b/usr/src/lib/libast/common/man/tmx.3
new file mode 100644
index 0000000000..268d40a9e5
--- /dev/null
+++ b/usr/src/lib/libast/common/man/tmx.3
@@ -0,0 +1,576 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH TM 3
+.SH NAME
+tm \- time conversion support
+.SH SYNOPSIS
+.L "#include <tm.h>"
+.SH DESCRIPTION
+The
+.I tm
+library supports conversion between
+string date specifications,
+.L time_t
+clock values and
+.L "struct tm"
+values.
+.L localtime()
+and
+.L gmtime()
+(see
+.IR ctime (3))
+are used to determine local time zone information.
+.PP
+.L time_t
+values are the number of seconds since the epoch,
+.BR "Jan 1 00:00:00 GMT 1970" ,
+with leap seconds omitted.
+.PP
+The global variable
+.L "int tm_info.flags"
+contains flags that allow all programs using the library
+to be controlled in a consistent manner.
+.L tm_info.flags
+is initialized by the
+.L tminit()
+routine described below, and may be explicitly reset after
+.L tminit()
+is called.
+The flags are:
+.TP
+.L TM_ADJUST
+Set by
+.L tminit()
+if
+.L localtime()
+and
+.L gmtime()
+do not compensate for leap seconds.
+.TP
+.L TM_LEAP
+.L time_t
+values are interpreted as if they include leap seconds.
+Set by
+.L tminit()
+if the
+.L leap
+option is set in the
+.L TM_OPTIONS
+environment variable.
+.TP
+.L TM_UTC
+Times are relative to
+.B UTC
+(universal coordinated time, i.e.,
+.BR GMT ).
+Otherwise times are relative to the local time zone.
+Set by
+.L tminit()
+if the time zone name matches one of
+.L tm_info.format[43]
+through
+.L tm_info.format[46]
+described below.
+If the time zone name is not determined by
+.L localtime()
+then the environment variables
+.L TZNAME
+(as described in BSD 4.3) and
+.L TZ
+(as described in System V)
+are checked, in order.
+If this fails then the time zone name is constructed using
+the local time zone offset.
+.PP
+The routines are:
+.TP
+.L "time_t tmdate(const char* date, char** end, time_t* clock)"
+Parses the date specification
+.L date
+using the
+.L tm_info.format
+string table (described below)
+and returns the equivalent
+.L time_t
+value.
+If
+.RL non- NULL ,
+.L end
+is set to the position of the first unrecognized character in
+.LR date .
+.L clock
+is used to provide default values for omitted components in
+.LR date .
+If
+.L clock
+is
+.L NULL
+then the current time is used.
+.TP
+.L "struct tm* tmfix(struct tm* tp)"
+Corrects any out of bounds fields in
+.L tp
+and returns
+.L tp
+as its value.
+The corrections start with
+.L tp->tm_sec
+and propagate down to
+.LR tp->tm_year .
+For example, if
+.L tp->tm_sec
+were 61 then it would change to 1 and
+.L tp->tm_min
+would be incremented by 1, and so on.
+.LR tp->tm_wday ,
+.LR tp->tm_yday
+and
+.L tp->tm_isdst
+are not changed as these can be computed from the other fields.
+.TP
+.L "char* tmfmt(char* buf, size_t len, const char* format, time_t* clock)"
+Formats the date pointed to by
+.L clock
+into the buffer
+.L buf
+with size
+.L len
+bytes according to the format specification
+.LR format .
+If
+.L format
+is
+.L NULL
+or empty then the string
+.L tm_info.format[40]
+is used.
+If
+.L clock
+is
+.L NULL
+then the current time is used.
+A pointer to the end of
+.L buf
+(i.e., the terminating
+.LR "'\e0'" )
+is returned.
+.RS
+.PP
+.L format
+is in the style of
+.IR printf (3),
+where
+.BI % field
+causes the corresponding fixed size field to be placed in
+.LR buf ,
+zero padded if necessary, and \e\fIc\fP and \e\fInnn\fP
+sequences are interpreted as in the C language.
+Otherwise invalid
+.BI % field
+specifications and all other characters in
+.L format
+are copied into
+.L buf
+without change.
+String field values are taken from the
+.L tm_info.format
+string table.
+The
+.I fields
+are:
+.TP
+.PD 0
+.B %
+.B %
+character.
+.TP
+.B a
+Abbreviated weekday name.
+.TP
+.B A
+Full weekday name.
+.TP
+.B b
+Abbreviated month name.
+.TP
+.B c
+.IR ctime (3)
+style date without the trailing
+.BR newline .
+.TP
+.B C
+.IR date (1)
+style date.
+.TP
+.B d
+Day of month number.
+.TP
+.B D
+Date as
+.IR mm / dd / yy .
+.TP
+.B e
+Blank padded day of month number.
+.TP
+.B E
+Unpadded day of month number.
+.TP
+.B h
+Abbreviated month name.
+.TP
+.B H
+24-hour clock hour.
+.TP
+.B i
+International
+.IR date (1)
+date that includes the time zone type name.
+.TP
+.B I
+12-hour clock hour.
+.TP
+.B j
+1-offset Julian date.
+.TP
+.B J
+0-offset Julian date.
+.TP
+.B l
+.IR ls (1)
+.B \-l
+date that lists recent dates with
+.IR hh : mm
+and distant dates with
+.IR yyyy .
+.TP
+.B m
+Month number.
+.TP
+.B M
+Minutes.
+.TP
+.B n
+.B newline
+character.
+.TP
+.B p
+Meridian (e.g.,
+.B AM
+or
+.BR PM ).
+.TP
+.B r
+12-hour time as
+.IR hh : mm : ss
+.IR meridian .
+.TP
+.B R
+24-hour time as
+.IR hh : mm .
+.TP
+.B S
+Seconds.
+.TP
+.B t
+.B tab
+character.
+.TP
+.B T
+24-hour time as
+.IR hh : mm : ss .
+.TP
+.B U
+Week number with Sunday as the first day.
+.TP
+.B w
+Weekday number.
+.TP
+.B W
+Week number with Monday as the first day.
+.TP
+.B x
+Local date style, using
+.LR tm_info.format[39] ,
+that includes the month, day and year.
+.TP
+.B X
+Local time style, using
+.LR tm_info.format[38] ,
+that includes the hours and minutes.
+.TP
+.B y
+2-digit year.
+.TP
+.B Y
+4-digit year.
+.TP
+.B z
+Time zone type name.
+.TP
+.B Z
+Time zone name.
+.TP
+.BI + flag
+.TP
+.BI \- flag
+Temporarily (until
+.L tmform()
+returns) sets (+) or clears (\-) the
+.L tm_info.flags
+flags specified by
+.IR flag :
+.RS
+.TP
+.B l
+.L TM_LEAP
+.TP
+.B u
+.L TM_UTC
+.RE
+.TP
+.B #
+Number of seconds since the epoch.
+.PD
+.RE
+.TP
+.L "void tminit(Tm_zone_t* zone)"
+Implicitly called by the other
+.I tm
+library routines to initialize global data, including the
+.L tm_info.format
+table and the
+.L tm_info.flags
+global flags.
+Global data should only be modified after an explicit call to
+.LR tminit .
+If
+.L "zone != 0"
+then it specifies a time zone other that the local time zone.
+.TP
+.L "void tmset(Tm_zone_t* zone);"
+.L tmset
+sets the reference timezoe to
+.LR zone .
+.L tm_info.local
+points to the local timezone and
+.L tm_info.zone
+points to the current reference timezone.
+.TP
+.L "time_t tmleap(time_t* clock)"
+Returns a
+.L time_t
+value for the time pointed to by
+.L clock
+with leap seconds adjusted for external
+routines that do not handle leap seconds.
+If
+.L clock
+is
+.L NULL
+then the current time is used.
+Adjustments are only done if the
+.L TM_ADJUST
+flag is set in
+.LR tm_info.flags .
+.TP
+.L "struct tm* tmmake(time_t* clock)"
+Returns a pointer to the
+.L tm
+struct corresponding to the time pointed to by
+.LR clock .
+If
+.L clock
+is
+.L NULL
+then the current time is used.
+.TP
+.L "time_t tmtime(struct tm* tp, int west)"
+Returns the
+.L time_t
+value corresponding to
+.LR tp .
+If
+.L west
+is
+.L TM_LOCALZONE
+then
+.L tm
+is relative to the local time zone,
+otherwise
+.L west
+is the number of minutes west of
+.B UTC
+with daylight savings time taken into account.
+.LR tp->tm_wday ,
+.LR tp->tm_yday
+and
+.L tp->tm_isdst
+are ignored in the conversion.
+.PP
+The library routines use a table of date strings pointed to by
+.LR "char** tm_info.format" .
+The indices in
+.L tm_info.format
+are fixed by category.
+.L tm_info.format
+may be changed to point to other tables
+according to local language and date conventions.
+The contents by index (showing the USA English values) are:
+.RS
+.TP
+.PD 0
+.B 0-11
+3-character abbreviated month names.
+.TP
+.B 12-23
+Full month names.
+.TP
+.B 24-30
+3-character abbreviated weekday names.
+.TP
+.B 31-37
+Full weekday names.
+.TP
+.B 38
+.L tmform()
+local time format used by the
+.B %X
+field.
+.TP
+.B 39
+.L tmform()
+local date format used by the
+.B %x
+field.
+.TP
+.B 40
+.L tmform()
+format used if the
+.L format
+argument is
+.L NULL
+or empty.
+.TP
+.B 41-42
+Meridian names: AM, PM.
+.TP
+.B 43-46
+.B UTC
+time zone names: GMT, UTC, UCT, CUT.
+.TP
+.B 47-50
+Daylight savings time suffix names: DST.
+.TP
+.B 51-54
+Suffixes to be ignored when matching strings in
+.LR tmform() .
+.TP
+.B 55-61
+Time part names: second, hour, minute, day, week, month, year.
+.TP
+.B 62-65
+Hours of the day names: midnight, morning, noon, evening.
+.TP
+.B 66-68
+Relative day names: yesterday, today, tomorrow.
+.TP
+.B 69-71
+Past relative time references: last, ago, past.
+.TP
+.B 72-75
+Current relative time references: this, now, current.
+.TP
+.B 75-77
+Future relative time references: next, hence, coming.
+.TP
+.B 78-80
+Exact relative time references: exactly.
+.TP
+.B 81-85
+Noise words to be ignored: at, in, on.
+.PD
+.RE
+.PP
+Low level support functions and data are described in
+.LR <tm.h> .
+.SH EXAMPLES
+.EX
+#include <tm.h>
+main() {
+ int i;
+ time_t t;
+ char buf[128];
+ struct {
+ char* date;
+ char* format;
+ } x[] = {
+ "now", "%i",
+ "2 months ago", "%C",
+ "this Wednesday noon", "%x %I:%M %p",
+ "last December 25", "%A",
+ 0, 0
+ };
+ for (i = 0; x[i].date; i++) {
+ t = tmdate(x[i].date, (char*)0, (time_t*)0);
+ (void)tmform(buf, x[i].format, &t);
+ puts(buf);
+ }
+}
+.EE
+produces
+.EX
+Fri Sep 30 12:10:14 USA EDT 1988
+Fri Jul 1 00:00:00 EDT 1988
+10/05/88 12:00 PM
+Friday
+.EE
+.SH "SEE ALSO"
+date(1), time(2), ctime(3)
+.SH BUGS
+.L "struct tm"
+values may get clobbered by the
+.I tm
+library routines as the
+.IR ctime (3)
+routines typically return pointers to a single static
+.L "struct tm"
+area.
+.L tmdate()
+uses an internal international time zone name table that will
+probably always be incomplete.
diff --git a/usr/src/lib/libast/common/man/tok.3 b/usr/src/lib/libast/common/man/tok.3
new file mode 100644
index 0000000000..46fbff9503
--- /dev/null
+++ b/usr/src/lib/libast/common/man/tok.3
@@ -0,0 +1,217 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH TOK 3
+.SH NAME
+tok \- space separated token stream routines
+.SH SYNOPSIS
+.L "#include <ast.h>"
+.sp
+.L "void* tokopen(char* string)"
+.L "char* tokread(void* tok)"
+.L "void tokclose(void* tok)"
+.sp
+.L "int tokscan(char* string, char** next, const char* format, ...);"
+.sp
+.L "Sfio_t* tokline(const char* input, int flags, int* line);"
+.SH DESCRIPTION
+.L tokopen
+returns a pointer to a space separated token stream on the 0 terminated
+string
+.LR string .
+.L tokread
+returns a pointer to the next
+space separated token in the token stream
+.L tok
+as returned by
+.LR tokopen .
+0 is returned when no tokens remain.
+.L tokread
+temporarily modifies
+.L string
+by inserting 0's to terminate each token.
+.L tokclose
+closes the token stream and restores
+.L string
+to its original state.
+.PP
+.L tokscan
+scans the string
+.L string
+for tokens specified in
+.LR format .
+It is a more forgiving
+.IR sscanf (3).
+If
+.L "next != 0"
+then it will point to the next unread character in
+.L string
+on return.
+The number of scanned tokens is returned.
+.L \-1
+is returned if
+.L string
+was not empty and
+.L format
+failed to match and tokens.
+.PP
+.I space
+in
+.L format
+matches 0 or more
+.I space
+or
+.I tab
+characters.
+.I newline
+in format eats the remainder of the current line in
+.LR string .
+"...", '...' and \e\fIcharacter\fP quotes are interpreted.
+A quoted
+.I carriage-return
+is converted to
+.IR newline .
+.I newline
+in
+.L string
+is equivalent to end of string except when quoted.
+.I \enewline
+is a line splice.
+.PP
+.L %
+in
+.L format
+prefixes format conversion characters; each conversion character
+corresponds to a
+.L tokscan
+argument following the
+.L format
+argument.
+The format conversions are:
+.TP
+.L %c
+A single
+.LR char .
+.TP
+.L "%hd %d %ld"
+[short, int, long] base 10 integer.
+.TP
+.L "%hn %n %ln"
+[short, int, long] C-style base integer.
+.TP
+.L "%ho %o %lo"
+[short, int, long] base 8 integer.
+.TP
+.L %s
+String.
+.TP
+.L "%hu %u %lu"
+[short, int, long] C-style base unsigned integer.
+.TP
+.L %v
+The next two arguments are a pointer to a
+.L char**
+argument vector and the maximum number of elements in the vector.
+.TP
+.L "%hx %x %lx"
+[short, int, long] base 16 integer.
+.PP
+.L %s
+and
+.L %v
+data may also be counted length strings of the form
+\f5(\fIcount\fP:\fIdata\fP)\fR
+where
+.I count
+is the number of characters in
+.I data
+and the terminating
+.L )
+may also be a
+.IR tab ,
+or the data may be
+.L (null)
+which represents the
+.L NULL
+string.
+.PP
+.L tokline
+returns an
+.IR sfio (3)
+stream to a file or string that splices
+.I \enewline
+into single lines,
+allows "..." and '...' to quotes to span
+.I newlines
+(done by translating quoted
+.I newline
+to
+.IR carriage-return ;
+.L tokscan
+above converts quoted
+.I carriage-return
+back to
+.IR newline ),
+and deletes
+.I "# ... newline"
+comments.
+This is done by pushing an
+.I sfio
+discipline onto a string or file stream.
+Seeks are disabled on the resulting stream.
+If
+.L "flags == SF_READ"
+then
+.L input
+is a file name;
+If
+.L "flags == SF_STRING"
+then
+.L input
+is a 0 terminated string;
+otherwise
+.L input
+is an open
+.L Sfio_t*
+stream.
+If
+.L "line != 0"
+then it points to a line count that is initialized to 0
+and is incremented for each input line.
+.SH "SEE ALSO"
+sfio(3)
diff --git a/usr/src/lib/libast/common/man/touch.3 b/usr/src/lib/libast/common/man/touch.3
new file mode 100644
index 0000000000..908a8b1e68
--- /dev/null
+++ b/usr/src/lib/libast/common/man/touch.3
@@ -0,0 +1,68 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH TOUCH 3
+.SH NAME
+touch \- set file access and modify times
+.SH SYNOPSIS
+.L "#include <ast.h>"
+.sp
+.L "int touch(const char* path, time_t atime, time_t mtime, int force);"
+.SH DESCRIPTION
+.L touch
+sets the access and modify times of the file named by
+.LR path .
+If
+.L "force != 0"
+then the file is created if it doesn't exist;
+otherwise the file is not created and
+.L \-1
+is returned.
+If
+.L "force < 0"
+then
+.L atime
+and
+.L mtime
+are taken verbatim; otherwise
+.L "(time_t)(-1)"
+retains the current value for the file and
+.L "(time_t)(0)"
+uses the current time.
+.SH CAVEATS
+By default the change time is always changed to the current time.
diff --git a/usr/src/lib/libast/common/man/tv.3 b/usr/src/lib/libast/common/man/tv.3
new file mode 100644
index 0000000000..82b0dc40c6
--- /dev/null
+++ b/usr/src/lib/libast/common/man/tv.3
@@ -0,0 +1,173 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH TM 3
+.SH NAME
+tv \- high resolution time support
+.SH SYNOPSIS
+.L "#include <tv.h>"
+.SH DESCRIPTION
+The
+.I tv
+library supports high resolution
+.B Tv_t
+time specifications.
+.SS Tv_t
+contains these elements:
+.TP
+.L unsigned
+.L _ast_int4_t
+.L tv_sec
+Seconds since the epoch.
+.TP
+.L unsigned
+.L _ast_int4_t
+.L tv_nsec
+Nanosecond resolution.
+.PP
+In practice resolution is much coarser than 1 nanosecond.
+Systems that only support 1 second resolution always set
+.L tv_nsec
+to 0.
+.SS "int tvgettime(Tv_t* tv)"
+Sets
+.L tv
+to the current time.
+.L 0
+is returned on success,
+.L -1
+on error.
+.SS "int tvsettime(const Tv_t* tv)"
+Sets the system time to
+.LR tv .
+The caller must have sufficient privilege.
+.L 0
+is returned on success,
+.L -1
+on error.
+.SS "int tvcmp(const Tv_t* av, const Tv_t* bv)"
+Compares the times
+.L av
+and
+.L bv
+and returns
+.L -1
+if
+.L av
+is less than
+.LR bv ,
+.L 0
+if
+.L av
+is equal to
+.LR bv ,
+and
+.L 1
+if
+.L av
+is greater than
+.LR bv .
+.SS "time_t tvgetatime(const struct stat* st, Tv_t* tv)"
+.SS "time_t tvgetmtime(const struct stat* st, Tv_t* tv)"
+.SS "time_t tvgetctime(const struct stat* st, Tv_t* tv)"
+These macros set
+.L tv
+to the
+.L st
+the access, modify, or change time, respectively.
+The seconds portion of
+.L tv
+is returned.
+.SS "time_t tvsetatime(struct stat* st, const Tv_t* tv)"
+.SS "time_t tvsetmtime(struct stat* st, const Tv_t* tv)"
+.SS "time_t tvsetctime(struct stat* st, const Tv_t* tv)"
+These macros set the
+.L st
+access, modify, or change time, respectively, to
+.LR tv .
+The seconds portion of
+.L tv
+is returned.
+.SS "int tvtouch(const char* path, const Tv_t* av, const Tv_t* mv, const Tv_t* cv, int copy)"
+Sets the file
+.L path
+access time from
+.LR av ,
+modify time from
+.LR mv ,
+and change time from
+.LR cv .
+Any of
+.LR av ,
+.LR mv ,
+and
+.L cv
+may be 0; the corresponding file time will retain the previous value if
+.L path
+exists and
+.L copy
+is
+.L 1 ;
+otherwise the corresponding file time will be set to the current time.
+.L 0
+is returned on success,
+.L -1
+on error.
+.SS "int tvsleep(const Tv_t* tv, Tv_t* rv)"
+Pauses execution for
+.L tv
+time.
+.L 0
+is returned if the full
+.L tv
+amount has expired.
+Otherwise
+.L -1
+is returned and
+.LR rv ,
+if not 0, is set to the sleep time remaining.
+.SH "RETURN VALUE"
+Except for
+.LR tvcmp() ,
+an error return of
+.L -1
+also sets
+.L errno
+to the corresponding error code.
+.SH "SEE ALSO"
+tm(3)
diff --git a/usr/src/lib/libast/common/man/vecargs.3 b/usr/src/lib/libast/common/man/vecargs.3
new file mode 100644
index 0000000000..29e492baf5
--- /dev/null
+++ b/usr/src/lib/libast/common/man/vecargs.3
@@ -0,0 +1,126 @@
+.fp 5 CW
+.de Af
+.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
+.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+..
+.de aF
+.ie \\$3 .ft \\$1
+.el \{\
+.ds ;G \&
+.nr ;G \\n(.f
+.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
+\\*(;G
+.ft \\n(;G \}
+..
+.de L
+.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de LR
+.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de RL
+.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH VECARGS 3
+.SH NAME
+vecargs \- command argument vector insertion routines
+.SH SYNOPSIS
+.L "#include <vecargs.h>"
+.sp
+.L "char** vecload(char* string);"
+.L "char** vecfile(const char* path);"
+.L "char** vecstring(const char* string);"
+.L "void vecfree(char**, int);"
+.L "int vecargs(char** vec, int* argcp, char*** argvp);"
+.SH DESCRIPTION
+.L vecload
+loads a string vector from lines in
+.LR string .
+.L string
+may be modified upon return.
+Each line in
+.L string
+is treated as a new vector element.
+Lines with
+.L #
+as the first character are comments.
+.I \enewline
+joins consecutive lines.
+A string vector pointer is returned, 0 on error.
+.PP
+.L vecfile
+constructs a string vector by calling
+.L vecload
+on the contents of the file named by
+.LR path .
+The string vector pointer is returned, 0 on error.
+.PP
+.L vecstring
+constructs a string vector by calling
+.L vecload
+on a copy of
+.LR string .
+The string vector pointer is returned, 0 on error.
+.PP
+.L vecfree
+frees a string vector allocated by
+.LR vecfile ,
+.L vecload
+or
+.LR vecstring .
+.PP
+.L vecargs
+inserts the string vector
+.L vec
+(as returned by
+.LR vecfile ,
+.L vecload
+or
+.LR vecstring )
+between
+.L "(*argvp)[0]"
+and
+.LR "(*argvp)[1]" ,
+sliding
+.L "(*argvp)[1] ..."
+over.
+NULL and empty string args in
+.L vec
+are not copied.
+.L "vecfree(vec)"
+is called before the return.
+.L \-1
+is returned if the insertion failed.
+.SH EXAMPLES
+.L vecargs
+is commonly used to modify command
+.L argv
+from fixed files.
+For example,
+.IR make (1)
+checks for the files
+.L ./Makeargs
+and
+.L ./makeargs
+to modify its arguments on startup.
+Its a handy way to override default options on a directory by directory basis
+without modify the standard control files
+(\f5Makefile\fP in this case.)
+.SH CAVEATS
+This paradigm is not recommended for all commands; only a few exceptions
+make sense.
diff --git a/usr/src/lib/libast/common/man/vmalloc.3 b/usr/src/lib/libast/common/man/vmalloc.3
new file mode 100644
index 0000000000..8853db4afa
--- /dev/null
+++ b/usr/src/lib/libast/common/man/vmalloc.3
@@ -0,0 +1,565 @@
+.fp 5 CW
+.de MW
+\f5\\$1\fP
+..
+.TH VMALLOC 3 "1 May 1998"
+.SH NAME
+vmalloc \- virtual memory allocation
+.SH SYNOPSIS
+.MW "#include <vmalloc.h>"
+.SS Regions
+.nf
+.MW "Vmalloc_t* vmopen(Vmdisc_t* disc, Vmethod_t* meth, int flags);"
+.MW "int vmclose(Vmalloc_t*);"
+.MW "int vmclear(Vmalloc_t*);"
+.MW "int vmcompact(Vmalloc_t* region);"
+.MW "int vmset(Vmalloc_t* region, int flags, int type);"
+.MW "Vmalloc_t* Vmheap;"
+.MW "Vmdisc_t* vmdisc(Vmalloc_t* region, Vmdisc_t* disc);"
+.MW "Vmalloc_t* vmmopen(char* file, Void_t* base, size_t round);"
+.MW "Void_t* vmmset(Vmalloc_t* vm, int key, Void_t* data, int set);"
+.fi
+.SS "Allocation functions"
+.nf
+.MW "Void_t* vmalloc(Vmalloc_t* region, size_t size);"
+.MW "Void_t* vmalign(Vmalloc_t* region, size_t size, size_t align);"
+.MW "Void_t* vmresize(Vmalloc_t* region, Void_t* addr, size_t size, int type);"
+.MW "int vmfree(Vmalloc_t* region, Void_t* addr);"
+.MW "Void_t* vmnewof(Vmalloc_t* region, Void_t* addr, type, size_t n, size_t x);"
+.MW "Void_t* vmoldof(Vmalloc_t* region, Void_t* addr, type, size_t n, size_t x);"
+.MW "Void_t* vmgetmem(Vmalloc_t* region, Void_t* addr, size_t size);"
+.fi
+.SS "Debugging"
+.nf
+.MW "int vmdebug(int);"
+.MW "int vmdbcheck(Vmalloc_t* vm);"
+.MW "int vmdbwatch(Void_t* addr);"
+.MW "static void vmdbwarn(Vmalloc_t*, char* mesg, int n);"
+.fi
+.SS "Profiling"
+.nf
+.MW "void vmprofile(Vmalloc_t* vm, int fd);"
+.fi
+.SS "Information and statistics"
+.nf
+.MW "Vmalloc_t* vmregion(Void_t* addr);"
+.MW "Void_t* vmsegment(Vmalloc_t* region, Void_t* addr);"
+.MW "int vmwalk(Vmalloc_t* region, int(*walkf)(Vmalloc_t*, Void_t*, size_t, Vmdisc_t*);"
+.MW "long vmaddr(Vmalloc_t* region, Void_t* addr);"
+.MW "long vmsize(Vmalloc_t* region, Void_t* addr);"
+.MW "int vmstat(Vmalloc_t* vm, Vmstat_t* statb);"
+.MW "int vmtrace(int fd);"
+.MW "int vmtrbusy(Vmalloc_t* vm);"
+.fi
+.SS "Malloc-compatible functions"
+.nf
+.MW "Void_t* malloc(size_t size);"
+.MW "Void_t* realloc(Void_t* addr, size_t size);"
+.MW "Void_t* calloc(size_t n_obj, size_t s_obj);"
+.MW "int cfree(Void_t* addr);"
+.MW "void free(Void_t* addr);"
+.MW "Void_t* memalign(size_t align, size_t size);"
+.MW "Void_t* valloc(size_t size);"
+.fi
+.SH DESCRIPTION
+These functions for dynamic storage allocation work in
+\fIregions\fP of memory.
+Each region has an \fIallocation method\fP
+for parceling out blocks of storage and a
+\fImemory discipline\fP for obtaining raw space.
+Automatic locking prevents interference by reentrant
+access to a region.
+.PP
+Pointers to space have type \f5Void_t*\fP
+where \f5Void_t\fP is \f5#define\fPd as \f5void\fP if possible, otherwise \f5char\fP.
+Space is counted in type \f5size_t\fP.
+
+.ne 4
+.SS Regions
+Regions have type \f5Vmalloc_t\fP.
+Two predefined regions are pointed to by:
+.TP
+.MW Vmheap
+A general-purpose region, with best-fit
+allocation, and Unix memory discipline \f5Vmdcsbrk\fP.
+.PP
+These functions manipulate regions:
+.PP
+.I vmopen
+creates a region with memory discipline \fIdisc\fP,
+allocation method \fImeth\fP,
+and a setting for control \fIflags\fP.
+It returns a pointer to the region on success and \f5NULL\fP on failure.
+The flags, represented by bit values or-ed together, are:
+.TP
+.MW VM_TRUST
+Disable locking and consistency checks, except under method \f5Vmdebug\fP.
+.TP
+.MW VM_TRACE
+Place tracing messages for each allocation event
+on the tracing file established by \fIvmtrace\fP.
+This turns off \f5VM_TRUST\fP.
+.TP
+\f5VM_DBCHECK\fP, \f5VM_DBABORT\fP
+.br
+See \fBDebugging\fP below.
+.PP
+.I vmclose
+closes a \fIregion\fP and releases all associated memory
+according to the region's discipline.
+The first segment obtained from the discipline's
+\f5memoryf\fP function (see `Disciplines' below) will be the last released.
+\fIvmclose\fP returns \-1 on failure and a non-negative value otherwise.
+.PP
+.I vmclear
+frees all allocated blocks in \fIregion\fP regardless of methods.
+It returns \-1 on failure and a non-negative value otherwise.
+.PP
+.I vmcompact
+releases as much of a \fIregion\fP's
+free space to its discipline's \f5memoryf\fP
+function as possible.
+It returns a nonnegative value on success and \-1 on failure.
+.PP
+.I vmset
+adjusts and queries a \fIregion\fP's \fIflags\fP.
+The indicated flags are turned on if \fItype\fP is nonzero, off if zero.
+\fIvmset\fP returns the previous value of all flags.
+Thus, \f5vmset(region,0,0)\fP queries the flags without changing them.
+In addition to the settable flags, one of
+\f5VM_MTBEST\fP, \f5VM_MTDEBUG\fP, \f5VM_MTPROFILE\fP,
+\f5VM_MTPOOL\fP, or \f5VM_MTLAST\fP
+is returned to indicate the method used in creating the \fIregion\fP.
+.PP
+.I vmdisc
+changes the discipline of \fIregion\fP to the given new discipline
+\fIdisc\fP if \fIdisc\fP is not \f5NULL\fP and its \f5memoryf\fP function
+is the same as the current discipline. If the current discipline
+has an \f5exceptf\fP function, it will be called with event \f5VM_DISC\fP.
+This function always returns the current discipline.
+.PP
+.I vmmopen
+creates a region to allocate memory given by the system call \fImmap(2)\fP.
+The given \fIfile\fP is the backing store for the map.
+If \fIbase\fP is not \f5NULL\fP, it is the address to map the data to.
+The \fIround\fP argument asserts that the size of the region is always
+a multiple of this value. However, note that \fIvmmopen\fP has
+an internally defined minimum round value (typically 64K) which may be
+used if the given value is too small.
+.PP
+.I vmmset
+sets a \fIdata\fP value associated with a \fIkey\fP if \f5set\fP is non-zero.
+In this case, it returns the current data (before setting)
+if \fIkey\fP is previously set; otherwise, it returns the new \fIdata\fP value.
+If the argument \fIset\fP is zero,
+the call returns the current data value associated with \fIkey\fP, if any.
+
+.SS "Allocation functions"
+.I vmalloc
+returns a pointer to a block of the requested \fIsize\fP
+in a \fIregion\fP, aligned to the \fIstrictest alignment\fP
+that is suitable for the needs of any basic data type.
+It returns \f5NULL\fP on failure.
+.PP
+.I vmalign
+works like \fIvmalloc\fP, but returns a block aligned to a common
+multiple of \fIalign\fP and the \fIstrictest alignment\fP.
+.PP
+.I vmresize
+attempts to change the length of the block pointed to by
+\fIaddr\fP to the specified \fIsize\fP.
+If that is impossible and \fItype\fP has
+at least one of \f5VM_RSMOVE\fP and \f5VM_RSCOPY\fP,
+a new block is allocated and the old block is freed.
+The bit \f5VM_RSCOPY\fP also causes
+the new block to be initialized with
+as much of the old contents as will fit.
+When a resized block gets larger, the new space will be cleared
+if \fItype\fP has the bit \f5VM_RSZERO\fP.
+\fIvmresize\fP
+returns a pointer to the final block, or \f5NULL\fP on failure.
+If \fIaddr\fP is \f5NULL\fP, \fIvmresize\fP behaves like \fIvmalloc\fP;
+otherwise, if \fIsize\fP is 0, it behaves like \fIvmfree\fP.
+.PP
+.I vmfree
+makes the currently allocated block pointed to by
+\fIaddr\fP available for future allocations in its \fIregion\fP.
+If \fIaddr\fP is \f5NULL\fP, \fIvmfree\fP does nothing.
+It returns \-1 on error, and nonnegative otherwise.
+.PP
+.I vmnewof
+is a macro function that attempts to change the length of
+the block pointed to by \fIaddr\fP to the size \f5n*sizeof(type)+x\fP.
+If the block is moved, new space will be initialized with as much of the
+old content as will fit.
+Additional space will be set to zero.
+.PP
+.I vmoldof
+is similar to \fIvmnewof\fP but it neither copies data nor clears space.
+.PP
+.I vmgetmem
+provides a handy function to creat/close regions and allocate/free memory
+based on chunks of memory obtained from the heap region \fIVmheap\fP.
+.TP
+.MW "vmgetmem(0,0,0)"
+This call opens a new region.
+.TP
+.MW "vmgetmem(region, 0, 0)"
+This call closes the given \f5region\fP.
+.TP
+.MW "vmgetmem(region,0,n)"
+This call allocates a block of length \f5n\fP and clears it to zeros.
+.TP
+.MW "vmgetmem(region,p,0)"
+This call frees the block \f5p\fP.
+.TP
+.MW "vmgetmem(region,p,n)"
+This call resizes the block \f5p\fP to length \f5n\fP
+and clears the new memory to zeros if the block grows.
+The block may be moved as deemed necessary by the allocator.
+.PP
+.SS "Memory disciplines"
+Memory disciplines have type \f5Vmdisc_t\fP,
+a structure with these members:
+.in +.5i
+.nf
+.MW "Void_t* (*memoryf)(Vmalloc_t *region, Void_t* obj,"
+.ti +.5i
+.MW "size_t csz, size_t nsz, Vmdisc_t *disc);"
+.MW "int (*exceptf)(Vmalloc_t *region, int type, Void_t* obj, Vmdisc_t *disc);"
+.MW "int round;"
+.fi
+.in -.5i
+.TP
+.MW round
+If this value is positive, all size arguments to the
+\f5memoryf\fP function will be multiples of it.
+.TP
+.MW memoryf
+Points to a function to get or release segments of space for the
+\fIregion\fP.
+.TP
+.MW exceptf
+If this pointer is not \f5NULL\fP,
+the function it points to is called to announce
+events in a \fIregion\fP.
+.PP
+There are two standard disciplines.
+In both,
+\f5round\fP is 0, and \f5exceptf\fP is \f5NULL\fP.
+.TP
+.MW Vmdcsbrk
+A discipline whose \f5memoryf\fP function gets space from \fIsbrk\fP(2).
+.br
+.ns
+.TP
+.MW Vmdcheap
+A discipline whose \f5memoryf\fP function gets space from the region \f5Vmheap\fP.
+A region with \f5Vmdcheap\fP discipline and \f5Vmlast\fP
+allocation is good for building throwaway data structures.
+.PP
+A \fImemoryf\fP
+function returns a pointer to a memory segment on success, and \f5NULL\fP on failure.
+If \fIcsz\fP is 0, the function returns a new segment of size \fInsz\fP.
+Otherwise, the function attempts to change the length of the segment
+pointed to by \fIaddr\fP from \fIcsz\fP to \fInsz\fP.
+If this is successful, \f5memoryf\fP should return \fIaddr\fP (even if \fInsz\fP is 0).
+.PP
+An \fIexceptf\fP
+function is called for events identified by \fItype\fP, which is coded thus:
+.TP
+.MW VM_OPEN
+A new region is being opened.
+If \fIexceptf\fP returns a zero value, the region opening proceeds normally.
+A negative return value causes \fIvmopen\fP to terminate with failure.
+A positive return value indicates that the new region is to manipulate memory
+already initialized by a previous \fIvmopen\fP call
+(perhaps by a different process on persistent or shared memory).
+In this case, the argument \f5(Void_t**)\fP\fIobj\fP should
+return the initial segment (which is of type \f5(Void_t*)\fP).
+\fIvmopen\fP will return failure if this segment is not returned or if it
+has not been properly initialized.
+.TP
+.MW VM_CLOSE
+The region is being closed.
+The return value of \f5exceptf\fP is significant as follows.
+If negative, \fIvmclose\fP immediately returns with failure.
+If zero, \fIvmclose\fP proceeds normally by calling \f5memoryf\fP to free
+all allocated memory segments and also freeing the region itself.
+Finally, if positive, \fIvmclose\fP will only free the region
+without deallocating the allocated segments.
+.TP
+.MW VM_NOMEM
+An attempt to extend the region by the amount
+\f5(size_t)\fP\fIobj\fP failed. The region is unlocked, so the
+\fIexceptf\fP function may free blocks.
+If the function returns a positive value the memory
+request will be repeated.
+If zero, the allocation method
+will again invoke \fImemoryf\fP to get space.
+If negative, the allocation request will fail.
+.TP
+.MW VM_BADADDR
+Address \fIobj\fP, given to \fIvmfree\fP or \fIvmresize\fP,
+does not point to an allocated block from the region.
+The respective call will fail.
+.TP
+.MW VM_ALLOC
+Announce that a memory allocation request is finished and returning.
+.TP
+.MW VM_FREE
+Announce that a memory freeing request is finished and returning.
+.TP
+.MW VM_RESIZE
+Announce that a memory resizing request is finished and returning.
+
+.SS "Allocation methods"
+There are five methods, of type \f5Vmethod_t*\fP:
+.TP
+.MW Vmbest
+An approximately best-fit allocation strategy.
+.TP
+.MW Vmlast
+A strategy for building structures that are only deleted in whole.
+Only the latest allocated block can be freed.
+This means that as soon as a block \f5a\fP is allocated,
+\fIvmfree\fP calls on blocks other than \c5a\fP are ignored.
+.TP
+.MW Vmpool
+A strategy for blocks of one size,
+set by the first \fIvmalloc\fP call after \fIvmopen\fP or \fIvmclear\fP.
+.TP
+.MW Vmdebug
+An allocation strategy with extra-stringent checking and locking
+regardless of the \f5VM_TRUST\fP flag.
+It is useful for finding misuses of dynamically allocated
+memory, such as writing beyond the boundary of a block, or
+freeing a block twice.
+.ne 3
+.TP
+.MW Vmprofile
+An allocation method that records and prints summaries of memory usage.
+
+.SS Debugging
+The method \f5Vmdebug\fP is used to debug common memory violation problems.
+When a problem is found,
+a warning message is written to file descriptor 2 (standard error).
+In addition, if flag \f5VM_DBABORT\fP is on,
+the program is terminated by calling \fIabort\fP(2).
+Each message is a line of self-explanatory fields separated by colons.
+The optional flag \f5-DVMFL\fP, if used during compilation,
+enables recording of file names and line numbers.
+The following functions work with method \f5Vmdebug\fP.
+.PP
+.I vmdebug
+resets the file descriptor to write out warnings to the given argument.
+By default, this file descriptor is 2, the standard error.
+\fIvmdebug\fP returns the previous file descriptor.
+.PP
+.I vmdbcheck
+checks a region using \f5Vmdebug\fP or \f5Vmbest\fP for integrity.
+If \f5Vmdebug\fP, this also checks for block overwriting errors.
+On errors, \fIvmdbwarn\fP is called.
+If flag \f5VM_DBCHECK\fP is on,
+\fIvmdbcheck\fP is called at each invocation of
+\fIvmalloc\fP, \fIvmfree\fP, or \fIvmresize\fP.
+.PP
+.I vmdbwatch
+causes address \fIaddr\fP
+to be watched, and reported whenever met in
+\fIvmalloc\fP, \fIvmresize\fP or \fIvmfree\fP.
+The watch list has finite size and if it becomes full,
+watches will be removed in a first-in-first-out fashion.
+If \fIaddr\fP is \f5NULL\fP,
+all current watches are canceled.
+\fIvmdbwatch\fP returns the watch bumped out due to an insertion
+into a full list or \f5NULL\fP otherwise.
+.PP
+.I vmdbwarn
+is an internal function that processes
+warning messages for discovered errors.
+It can't be called from outside the \fIvmalloc\fP package,
+but is a good place to plant debugger traps because
+control goes there at every trouble.
+
+.SS "Profiling"
+The method \f5Vmprofile\fP is used to profile memory usage.
+Profiling data are maintained in private memory of a process so
+\f5Vmprofile\fP should be avoided from regions manipulating
+persistent or shared memory.
+The optional flag \f5-DVMFL\fP, if used during compilation,
+enables recording of file names and line numbers.
+.PP
+.I vmprofile
+prints memory usage summary.
+The summary is restricted to region \fIvm\fP if \fIvm\fP is not \f5NULL\fP;
+otherwise, it is for all regions created with \f5Vmprofile\fP.
+Summary records are written to file descriptor \fIfd\fP as lines with
+colon-separated fields. Here are some of the fields:
+.TP
+.I n_alloc,n_free:
+Number of allocation and free calls respectively. Note that a resize
+operation is coded as a free and an allocation.
+.TP
+.I s_alloc,s_free:
+Total amounts allocated and freed. The difference between these numbers
+is the amount of space not yet freed.
+.TP
+.I max_busy, extent:
+These fields are only with the summary record for region.
+They show the maximum busy space at any time and the extent of the region.
+
+.SS "Information and statistics"
+.I vmregion
+returns the region to which the block pointed to by
+\fIaddr\fP belongs.
+This works only in regions that allocate with
+\f5Vmbest\fP, \f5Vmdebug\fP or \f5Vmprofile\fP.
+If multiple regions manipulate the same segment of memory,
+\fIvmregion\fP returns the region that causes the creation that memory segment.
+.PP
+.I vmsegment
+finds if some segment of memory in \fIregion\fP
+contains the address \fIaddr\fP.
+It returns the address of a found segment or \f5NULL\fP if none found.
+.PP
+.I vmwalk
+walks all segments in \fIregion\fP or if \fIregion\fP is \f5NULL\fP,
+all segments in all regions.
+At each segment, \fI(*walkf)(vm,addr,size,disc)\fP
+is called where \fIvm\fP is the region, \fIaddr\fP is the segment,
+\fIsize\fP is the size of the segment, and \fIdisc\fP is the region's discipline.
+If \fIwalkf\fP returns a negative value, the walk stops and returns the same value.
+On success, \fIvmwalk\fP returns 0; otherwise, it returns \-1.
+.PP
+.I vmaddr
+checks whether \fIaddr\fP
+points to an address within some allocated block of the given region.
+If not, it returns \-1.
+If so, it returns the offset from the beginning of the block.
+The function does not work for a \f5Vmlast\fP region except
+on the latest allocated block.
+.PP
+.I vmsize
+returns the size of the allocated block pointed to by \fIaddr\fP.
+It returns \-1 if \fIaddr\fP
+does not point to a valid block in the region.
+Sizes may be padded beyond that requested; in
+particular no block has size 0.
+The function does not work for a \f5Vmlast\fP region except
+on the latest allocated block.
+.PP
+.I vmstat
+gathers statistics on the given \fIregion\fP and returns that
+information in the \f5Vmstat_t\fP structure pointed to by \fIstatb\fP.
+A \f5Vmstat_t\fP structure has at least these members:
+.in +.5i
+.nf
+.ta \w'\f5size_t \fP'u +\w'\f5extent \fP'u
+.MW "int n_busy; /* number of busy blocks */
+.MW "int n_free; /* number of free blocks */
+.MW "size_t s_busy; /* total busy space */
+.MW "size_t s_free; /* total free space */
+.MW "size_t m_busy; /* maximum size of busy block */
+.MW "size_t m_free; /* maximum size of free block */
+.MW "int n_seg; /* number of segments in region */
+.MW "size_t extent; /* total size of the region */
+.fi
+.in -.5i
+.PP
+Bookeeping overhead is counted in \f5extent\fP,
+but not in \f5s_busy\fP or \f5s_free\fP.
+.PP
+.I vmtrace
+establishes file descriptor \fIfd\fP
+as the trace file and returns
+the previous value of the trace file descriptor.
+The trace descriptor is initially invalid.
+Output is sent to the trace file by successful allocation
+events when flag \f5VM_TRACE\fP is on.
+.PP
+Tools for analyzing traces are described in \fImtreplay\fP(1).
+The trace record for an allocation event
+is a line with colon-separated fields, four numbers and one string.
+.TP
+.I old
+Zero for a fresh allocation;
+the address argument for freeing and resizing.
+.TP
+.I new
+Zero for freeing;
+the address returned by allocation or resizing.
+.TP
+.I size
+The size argument for allocation or resizing;
+the size freed by freeing.
+Sizes may differ due to padding for alignment.
+.TP
+.I region
+The address of the affected region.
+.TP
+.I method
+A string that tells the region's method:
+\f5best\fP, \f5last\fP, \f5pool\fP, \f5profile\fP, or \f5debug\fP.
+.PP
+.I vmtrbusy
+outputs a trace of all currently busy blocks in region \f5vm\fP.
+This only works with the \f5Vmbest\fP, \f5Vmdebug\fP and \f5Vmprofile\fP methods.
+
+.SS "Malloc-compatible functions"
+Functions in this set provide the behaviors of \fImalloc\fP(3).
+The functions
+\fImemalign\fP and \fIvalloc\fP allocate aligned blocks;
+\fIvalloc\fP further restricts alignment to page boundaries.
+.PP
+The \fImalloc\fP functions are instrumented for run-time debugging,
+profiling and tracing.
+When these modes are enable, time and space performance will be affected.
+For accurate reporting of files and line numbers,
+code should include \f5vmalloc.h\fP and compile with \f5-DVMFL\fP.
+
+The following environment variables should be set before any memory allocation
+(e.g., before a process starts). They drive different modes:
+.TP
+.I VMETHOD
+This defines the method to use for allocation.
+Its value should be one of the strings:
+\fIVmbest, Vmdebug, Vmprofile, Vmlast, Vmpool\fP.
+The 'V' can be in lower case.
+.TP
+.I VMDEBUG
+This is ignored if
+a method other than \f5Vmdebug\fP has been selected with \fIVMETHOD\fP.
+\fIVMDEBUG\fP can be any combination of `a',
+a decimal number and a list of hexadecimal numbers.
+`a' causes the program to abort on any discovered allocation error.
+A hexadecimal number starts with either \fI0x\fP or \fI0X\fP
+and defines an address to watch (see \fIvmdbwatch\fP).
+Any other number is taken to be decimal and defines a period \fIp\fP
+to check the arena for integrity. The default period is 1, ie, the
+arena is checked on every call to a \fImalloc\fP function.
+Other letters not part of the defined set are ignored.
+.TP
+.I VMPROFILE
+This is ignored if a method other than \f5Vmprofile\fP
+has been selected by \fIVMETHOD\fP or \fIVMDEBUG\fP.
+\fIVMPROFILE\fP defines a file name to store profile data.
+Each instance of the pattern `%p' found in \fIVMPROFILE\fP
+is transformed to the process id of the running process.
+If the file cannot be created, file descriptor 2 (standard error)
+is used for output.
+.TP
+.I VMTRACE
+If this defines a valid writable file, trace messages of all allocation calls
+are written to the given file (see \fIvmopen()\fP and \fIvmtrace()\fP).
+Similar to \fIVMPROFILE\fP, each instance of the pattern `%p' found
+in \fIVMTRACE\fP is turned to the process id of the running process.
+
+.SH RECENT CHANGES
+\f5Vmlast\fP: allocated blocks are now allowed to be resized (09/1998).
+
+.SH SEE ALSO
+\fImtreplay\fP(1), \fImalloc\fP(3).
+
+.SH AUTHOR
+Kiem-Phong Vo, kpv@research.att.com
diff --git a/usr/src/lib/libast/common/misc/error.c b/usr/src/lib/libast/common/misc/error.c
new file mode 100644
index 0000000000..89a3378c83
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/error.c
@@ -0,0 +1,661 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * error and message formatter
+ *
+ * level is the error level
+ * level >= error_info.core!=0 dumps core
+ * level >= ERROR_FATAL calls error_info.exit
+ * level < 0 is for debug tracing
+ *
+ * NOTE: id && ERROR_NOID && !ERROR_USAGE implies format=id for errmsg()
+ */
+
+#include "lclib.h"
+
+#include <ctype.h>
+#include <ccode.h>
+#include <namval.h>
+#include <sig.h>
+#include <stk.h>
+#include <times.h>
+#include <regex.h>
+
+/*
+ * 2007-03-19 move error_info from _error_info_ to (*_error_infop_)
+ * to allow future Error_info_t growth
+ * by 2009 _error_info_ can be static
+ */
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+
+extern Error_info_t _error_info_;
+
+Error_info_t _error_info_ =
+{
+ 2, exit, write,
+ 0,0,0,0,0,0,0,0,
+ 0, /* version */
+ 0, /* auxilliary */
+ 0,0,0,0,0,0,0, /* top of old context stack */
+ 0,0,0,0,0,0,0, /* old empty context */
+ 0, /* time */
+ translate,
+ 0 /* catalog */
+};
+
+#undef extern
+
+__EXTERN__(Error_info_t, _error_info_);
+
+__EXTERN__(Error_info_t*, _error_infop_);
+
+Error_info_t* _error_infop_ = &_error_info_;
+
+/*
+ * these should probably be in error_info
+ */
+
+static struct State_s
+{
+ char* prefix;
+ Sfio_t* tty;
+ unsigned long count;
+ int breakpoint;
+ regex_t* match;
+} error_state;
+
+#undef ERROR_CATALOG
+#define ERROR_CATALOG (ERROR_LIBRARY<<1)
+
+#define OPT_BREAK 1
+#define OPT_CATALOG 2
+#define OPT_CORE 3
+#define OPT_COUNT 4
+#define OPT_FD 5
+#define OPT_LIBRARY 6
+#define OPT_MASK 7
+#define OPT_MATCH 8
+#define OPT_PREFIX 9
+#define OPT_SYSTEM 10
+#define OPT_TIME 11
+#define OPT_TRACE 12
+
+static const Namval_t options[] =
+{
+ "break", OPT_BREAK,
+ "catalog", OPT_CATALOG,
+ "core", OPT_CORE,
+ "count", OPT_COUNT,
+ "debug", OPT_TRACE,
+ "fd", OPT_FD,
+ "library", OPT_LIBRARY,
+ "mask", OPT_MASK,
+ "match", OPT_MATCH,
+ "prefix", OPT_PREFIX,
+ "system", OPT_SYSTEM,
+ "time", OPT_TIME,
+ "trace", OPT_TRACE,
+ 0, 0
+};
+
+/*
+ * called by stropt() to set options
+ */
+
+static int
+setopt(void* a, const void* p, register int n, register const char* v)
+{
+ NoP(a);
+ if (p)
+ switch (((Namval_t*)p)->value)
+ {
+ case OPT_BREAK:
+ case OPT_CORE:
+ if (n)
+ switch (*v)
+ {
+ case 'e':
+ case 'E':
+ error_state.breakpoint = ERROR_ERROR;
+ break;
+ case 'f':
+ case 'F':
+ error_state.breakpoint = ERROR_FATAL;
+ break;
+ case 'p':
+ case 'P':
+ error_state.breakpoint = ERROR_PANIC;
+ break;
+ default:
+ error_state.breakpoint = strtol(v, NiL, 0);
+ break;
+ }
+ else
+ error_state.breakpoint = 0;
+ if (((Namval_t*)p)->value == OPT_CORE)
+ error_info.core = error_state.breakpoint;
+ break;
+ case OPT_CATALOG:
+ if (n)
+ error_info.set |= ERROR_CATALOG;
+ else
+ error_info.clear |= ERROR_CATALOG;
+ break;
+ case OPT_COUNT:
+ if (n)
+ error_state.count = strtol(v, NiL, 0);
+ else
+ error_state.count = 0;
+ break;
+ case OPT_FD:
+ error_info.fd = n ? strtol(v, NiL, 0) : -1;
+ break;
+ case OPT_LIBRARY:
+ if (n)
+ error_info.set |= ERROR_LIBRARY;
+ else
+ error_info.clear |= ERROR_LIBRARY;
+ break;
+ case OPT_MASK:
+ if (n)
+ error_info.mask = strtol(v, NiL, 0);
+ else
+ error_info.mask = 0;
+ break;
+ case OPT_MATCH:
+ if (error_state.match)
+ regfree(error_state.match);
+ if (n)
+ {
+ if ((error_state.match || (error_state.match = newof(0, regex_t, 1, 0))) && regcomp(error_state.match, v, REG_EXTENDED|REG_LENIENT))
+ {
+ free(error_state.match);
+ error_state.match = 0;
+ }
+ }
+ else if (error_state.match)
+ {
+ free(error_state.match);
+ error_state.match = 0;
+ }
+ break;
+ case OPT_PREFIX:
+ if (n)
+ error_state.prefix = strdup(v);
+ else if (error_state.prefix)
+ {
+ free(error_state.prefix);
+ error_state.prefix = 0;
+ }
+ break;
+ case OPT_SYSTEM:
+ if (n)
+ error_info.set |= ERROR_SYSTEM;
+ else
+ error_info.clear |= ERROR_SYSTEM;
+ break;
+ case OPT_TIME:
+ error_info.time = n ? 1 : 0;
+ break;
+ case OPT_TRACE:
+ if (n)
+ error_info.trace = -strtol(v, NiL, 0);
+ else
+ error_info.trace = 0;
+ break;
+ }
+ return 0;
+}
+
+/*
+ * print a name with optional delimiter, converting unprintable chars
+ */
+
+static void
+print(register Sfio_t* sp, register char* name, char* delim)
+{
+ if (mbwide())
+ sfputr(sp, name, -1);
+ else
+ {
+#if CC_NATIVE != CC_ASCII
+ register int c;
+ register unsigned char* n2a;
+ register unsigned char* a2n;
+ register int aa;
+ register int as;
+
+ n2a = ccmap(CC_NATIVE, CC_ASCII);
+ a2n = ccmap(CC_ASCII, CC_NATIVE);
+ aa = n2a['A'];
+ as = n2a[' '];
+ while (c = *name++)
+ {
+ c = n2a[c];
+ if (c & 0200)
+ {
+ c &= 0177;
+ sfputc(sp, '?');
+ }
+ if (c < as)
+ {
+ c += aa - 1;
+ sfputc(sp, '^');
+ }
+ c = a2n[c];
+ sfputc(sp, c);
+ }
+#else
+ register int c;
+
+ while (c = *name++)
+ {
+ if (c & 0200)
+ {
+ c &= 0177;
+ sfputc(sp, '?');
+ }
+ if (c < ' ')
+ {
+ c += 'A' - 1;
+ sfputc(sp, '^');
+ }
+ sfputc(sp, c);
+ }
+#endif
+ }
+ if (delim)
+ sfputr(sp, delim, -1);
+}
+
+/*
+ * print error context FIFO stack
+ */
+
+#define CONTEXT(f,p) (((f)&ERROR_PUSH)?((Error_context_t*)&(p)->context->context):((Error_context_t*)(p)))
+
+static void
+context(register Sfio_t* sp, register Error_context_t* cp)
+{
+ if (cp->context)
+ context(sp, CONTEXT(cp->flags, cp->context));
+ if (!(cp->flags & ERROR_SILENT))
+ {
+ if (cp->id)
+ print(sp, cp->id, NiL);
+ if (cp->line > ((cp->flags & ERROR_INTERACTIVE) != 0))
+ {
+ if (cp->file)
+ sfprintf(sp, ": \"%s\", %s %d", cp->file, ERROR_translate(NiL, NiL, ast.id, "line"), cp->line);
+ else
+ sfprintf(sp, "[%d]", cp->line);
+ }
+ sfputr(sp, ": ", -1);
+ }
+}
+
+/*
+ * debugging breakpoint
+ */
+
+extern void
+error_break(void)
+{
+ char* s;
+
+ if (error_state.tty || (error_state.tty = sfopen(NiL, "/dev/tty", "r+")))
+ {
+ sfprintf(error_state.tty, "error breakpoint: ");
+ if (s = sfgetr(error_state.tty, '\n', 1))
+ {
+ if (streq(s, "q") || streq(s, "quit"))
+ exit(0);
+ stropt(s, options, sizeof(*options), setopt, NiL);
+ }
+ }
+}
+
+void
+error(int level, ...)
+{
+ va_list ap;
+
+ va_start(ap, level);
+ errorv(NiL, level, ap);
+ va_end(ap);
+}
+
+void
+errorv(const char* id, int level, va_list ap)
+{
+ register int n;
+ int fd;
+ int flags;
+ char* s;
+ char* t;
+ char* format;
+ char* library;
+ const char* catalog;
+
+ int line;
+ char* file;
+
+#if !_PACKAGE_astsa
+ unsigned long d;
+ struct tms us;
+#endif
+
+ if (!error_info.init)
+ {
+ error_info.init = 1;
+ stropt(getenv("ERROR_OPTIONS"), options, sizeof(*options), setopt, NiL);
+ }
+ if (level > 0)
+ {
+ flags = level & ~ERROR_LEVEL;
+ level &= ERROR_LEVEL;
+ }
+ else
+ flags = 0;
+ if ((flags & (ERROR_USAGE|ERROR_NOID)) == ERROR_NOID)
+ {
+ format = (char*)id;
+ id = 0;
+ }
+ else
+ format = 0;
+ if (id)
+ {
+ catalog = (char*)id;
+ if (!*catalog || *catalog == ':')
+ {
+ catalog = 0;
+ library = 0;
+ }
+ else if ((library = strchr(catalog, ':')) && !*++library)
+ library = 0;
+ }
+ else
+ {
+ catalog = 0;
+ library = 0;
+ }
+ if (catalog)
+ id = 0;
+ else
+ {
+ id = (const char*)error_info.id;
+ catalog = error_info.catalog;
+ }
+ if (level < error_info.trace || (flags & ERROR_LIBRARY) && !(((error_info.set | error_info.flags) ^ error_info.clear) & ERROR_LIBRARY) || level < 0 && error_info.mask && !(error_info.mask & (1<<(-level - 1))))
+ {
+ if (level >= ERROR_FATAL)
+ (*error_info.exit)(level - 1);
+ return;
+ }
+ if (error_info.trace < 0)
+ flags |= ERROR_LIBRARY|ERROR_SYSTEM;
+ flags |= error_info.set | error_info.flags;
+ flags &= ~error_info.clear;
+ if (!library)
+ flags &= ~ERROR_LIBRARY;
+ fd = (flags & ERROR_OUTPUT) ? va_arg(ap, int) : error_info.fd;
+ if (error_info.write)
+ {
+ long off;
+ char* bas;
+
+ bas = stkptr(stkstd, 0);
+ if (off = stktell(stkstd))
+ stkfreeze(stkstd, 0);
+ file = error_info.id;
+ if (error_state.prefix)
+ sfprintf(stkstd, "%s: ", error_state.prefix);
+ if (flags & ERROR_USAGE)
+ {
+ if (flags & ERROR_NOID)
+ sfprintf(stkstd, " ");
+ else
+ sfprintf(stkstd, "%s: ", ERROR_translate(NiL, NiL, ast.id, "Usage"));
+ if (file || opt_info.argv && (file = opt_info.argv[0]))
+ print(stkstd, file, " ");
+ }
+ else
+ {
+ if (level && !(flags & ERROR_NOID))
+ {
+ if (error_info.context && level > 0)
+ context(stkstd, CONTEXT(error_info.flags, error_info.context));
+ if (file)
+ print(stkstd, file, (flags & ERROR_LIBRARY) ? " " : ": ");
+ if (flags & (ERROR_CATALOG|ERROR_LIBRARY))
+ {
+ sfprintf(stkstd, "[");
+ if (flags & ERROR_CATALOG)
+ sfprintf(stkstd, "%s %s%s",
+ catalog ? catalog : ERROR_translate(NiL, NiL, ast.id, "DEFAULT"),
+ ERROR_translate(NiL, NiL, ast.id, "catalog"),
+ (flags & ERROR_LIBRARY) ? ", " : "");
+ if (flags & ERROR_LIBRARY)
+ sfprintf(stkstd, "%s %s",
+ library,
+ ERROR_translate(NiL, NiL, ast.id, "library"));
+ sfprintf(stkstd, "]: ");
+ }
+ }
+ if (level > 0 && error_info.line > ((flags & ERROR_INTERACTIVE) != 0))
+ {
+ if (error_info.file && *error_info.file)
+ sfprintf(stkstd, "\"%s\", ", error_info.file);
+ sfprintf(stkstd, "%s %d: ", ERROR_translate(NiL, NiL, ast.id, "line"), error_info.line);
+ }
+ }
+#if !_PACKAGE_astsa
+ if (error_info.time)
+ {
+ if ((d = times(&us)) < error_info.time || error_info.time == 1)
+ error_info.time = d;
+ sfprintf(stkstd, " %05lu.%05lu.%05lu ", d - error_info.time, (unsigned long)us.tms_utime, (unsigned long)us.tms_stime);
+ }
+#endif
+ switch (level)
+ {
+ case 0:
+ flags &= ~ERROR_SYSTEM;
+ break;
+ case ERROR_WARNING:
+ sfprintf(stkstd, "%s: ", ERROR_translate(NiL, NiL, ast.id, "warning"));
+ break;
+ case ERROR_PANIC:
+ sfprintf(stkstd, "%s: ", ERROR_translate(NiL, NiL, ast.id, "panic"));
+ break;
+ default:
+ if (level < 0)
+ {
+ s = ERROR_translate(NiL, NiL, ast.id, "debug");
+ if (error_info.trace < -1)
+ sfprintf(stkstd, "%s%d:%s", s, level, level > -10 ? " " : "");
+ else
+ sfprintf(stkstd, "%s: ", s);
+ for (n = 0; n < error_info.indent; n++)
+ {
+ sfputc(stkstd, ' ');
+ sfputc(stkstd, ' ');
+ }
+ }
+ break;
+ }
+ if (flags & ERROR_SOURCE)
+ {
+ /*
+ * source ([version], file, line) message
+ */
+
+ file = va_arg(ap, char*);
+ line = va_arg(ap, int);
+ s = ERROR_translate(NiL, NiL, ast.id, "line");
+ if (error_info.version)
+ sfprintf(stkstd, "(%s: \"%s\", %s %d) ", error_info.version, file, s, line);
+ else
+ sfprintf(stkstd, "(\"%s\", %s %d) ", file, s, line);
+ }
+ if (format || (format = va_arg(ap, char*)))
+ {
+ if (!(flags & ERROR_USAGE))
+ format = ERROR_translate(NiL, id, catalog, format);
+ sfvprintf(stkstd, format, ap);
+ }
+ if (!(flags & ERROR_PROMPT))
+ {
+ /*
+ * level&ERROR_OUTPUT on return means message
+ * already output
+ */
+
+ if ((flags & ERROR_SYSTEM) && errno && errno != error_info.last_errno)
+ {
+ sfprintf(stkstd, " [%s]", fmterror(errno));
+ if (error_info.set & ERROR_SYSTEM)
+ errno = 0;
+ error_info.last_errno = (level >= 0) ? 0 : errno;
+ }
+ if (error_info.auxilliary && level >= 0)
+ level = (*error_info.auxilliary)(stkstd, level, flags);
+ sfputc(stkstd, '\n');
+ }
+ if (level > 0)
+ {
+ if ((level & ~ERROR_OUTPUT) > 1)
+ error_info.errors++;
+ else
+ error_info.warnings++;
+ }
+ if (level < 0 || !(level & ERROR_OUTPUT))
+ {
+ n = stktell(stkstd);
+ s = stkptr(stkstd, 0);
+ if (t = memchr(s, '\f', n))
+ {
+ n -= ++t - s;
+ s = t;
+ }
+#if HUH_19980401 /* nasty problems if sfgetr() is in effect! */
+ sfsync(sfstdin);
+#endif
+ sfsync(sfstdout);
+ sfsync(sfstderr);
+ if (fd == sffileno(sfstderr) && error_info.write == write)
+ {
+ sfwrite(sfstderr, s, n);
+ sfsync(sfstderr);
+ }
+ else
+ (*error_info.write)(fd, s, n);
+ }
+ else
+ {
+ s = 0;
+ level &= ERROR_LEVEL;
+ }
+ stkset(stkstd, bas, off);
+ }
+ else
+ s = 0;
+ if (level >= error_state.breakpoint && error_state.breakpoint && (!error_state.match || !regexec(error_state.match, s ? s : format, 0, NiL, 0)) && (!error_state.count || !--error_state.count))
+ {
+ if (error_info.core)
+ {
+#ifndef SIGABRT
+#ifdef SIGQUIT
+#define SIGABRT SIGQUIT
+#else
+#ifdef SIGIOT
+#define SIGABRT SIGIOT
+#endif
+#endif
+#endif
+#ifdef SIGABRT
+ signal(SIGABRT, SIG_DFL);
+ kill(getpid(), SIGABRT);
+ pause();
+#else
+ abort();
+#endif
+ }
+ else
+ error_break();
+ }
+ if (level >= ERROR_FATAL)
+ (*error_info.exit)(level - ERROR_FATAL + 1);
+}
+
+/*
+ * error_info context control
+ */
+
+#include <error.h>
+
+static Error_info_t* freecontext;
+
+Error_info_t*
+errorctx(Error_info_t* p, int op, int flags)
+{
+ if (op & ERROR_POP)
+ {
+ if (!(_error_infop_ = p->context))
+ _error_infop_ = &_error_info_;
+ if (op & ERROR_FREE)
+ {
+ p->context = freecontext;
+ freecontext = p;
+ }
+ p = _error_infop_;
+ }
+ else
+ {
+ if (!p)
+ {
+ if (p = freecontext)
+ freecontext = freecontext->context;
+ else if (!(p = newof(0, Error_info_t, 1, 0)))
+ return 0;
+ *p = *_error_infop_;
+ p->errors = p->flags = p->line = p->warnings = 0;
+ p->catalog = p->file = 0;
+ }
+ if (op & ERROR_PUSH)
+ {
+ p->flags = flags;
+ p->context = _error_infop_;
+ _error_infop_ = p;
+ }
+ p->flags |= ERROR_PUSH;
+ }
+ return p;
+}
diff --git a/usr/src/lib/libast/common/misc/errorf.c b/usr/src/lib/libast/common/misc/errorf.c
new file mode 100644
index 0000000000..5230a3a6c9
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/errorf.c
@@ -0,0 +1,41 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * generic error discipline function
+ */
+
+#include <error.h>
+
+int
+errorf(void* handle, void* discipline, int level, ...)
+{
+ va_list ap;
+
+ va_start(ap, level);
+ errorv((discipline && handle) ? *((char**)handle) : (char*)handle, (discipline || level < 0) ? level : (level | ERROR_LIBRARY), ap);
+ va_end(ap);
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/misc/errormsg.c b/usr/src/lib/libast/common/misc/errormsg.c
new file mode 100644
index 0000000000..0785528dc6
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/errormsg.c
@@ -0,0 +1,41 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * error function with specific dictionary
+ */
+
+#include <error.h>
+
+int
+errormsg(const char* dictionary, int level, ...)
+{
+ va_list ap;
+
+ va_start(ap, level);
+ errorv(dictionary, level, ap);
+ va_end(ap);
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/misc/errorx.c b/usr/src/lib/libast/common/misc/errorx.c
new file mode 100644
index 0000000000..d476efab05
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/errorx.c
@@ -0,0 +1,49 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "lclib.h"
+
+/*
+ * low level for ERROR_translate()
+ * this fills in NiL arg defaults and calls error_info.translate
+ */
+
+char*
+errorx(const char* loc, const char* cmd, const char* cat, const char* msg)
+{
+ char* s;
+
+ error_info.translate = translate; /* 2007-03-19 OLD_Error_info_t workaround */
+ if (ERROR_translating())
+ {
+ if (!loc)
+ loc = (const char*)locales[AST_LC_MESSAGES]->code;
+ if (!cat)
+ cat = (const char*)error_info.catalog;
+ if (!cmd)
+ cmd = (const char*)error_info.id;
+ if (s = (*error_info.translate)(loc, cmd, cat, msg))
+ return s;
+ }
+ return (char*)msg;
+}
diff --git a/usr/src/lib/libast/common/misc/fastfind.c b/usr/src/lib/libast/common/misc/fastfind.c
new file mode 100644
index 0000000000..1602029759
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/fastfind.c
@@ -0,0 +1,1303 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * original code
+ *
+ * James A. Woods, Informatics General Corporation,
+ * NASA Ames Research Center, 6/81.
+ * Usenix ;login:, February/March, 1983, p. 8.
+ *
+ * discipline/method interface
+ *
+ * Glenn Fowler
+ * AT&T Research
+ * modified from the original BSD source
+ *
+ * 'fastfind' scans a file list for the full pathname of a file
+ * given only a piece of the name. The list is processed with
+ * with "front-compression" and bigram coding. Front compression reduces
+ * space by a factor of 4-5, bigram coding by a further 20-25%.
+ *
+ * there are 4 methods:
+ *
+ * FF_old original with 7 bit bigram encoding (no magic)
+ * FF_gnu 8 bit clean front compression (FF_gnu_magic)
+ * FF_dir FF_gnu with sfgetl/sfputl and trailing / on dirs (FF_dir_magic)
+ * FF_typ FF_dir with (mime) types (FF_typ_magic)
+ *
+ * the bigram encoding steals the eighth bit (that's why its FF_old)
+ * maybe one day we'll limit it to readonly:
+ *
+ * 0-2*FF_OFF likeliest differential counts + offset to make nonnegative
+ * FF_ESC 4 byte big-endian out-of-range count+FF_OFF follows
+ * FF_MIN-FF_MAX ascii residue
+ * >=FF_MAX bigram codes
+ *
+ * a two-tiered string search technique is employed
+ *
+ * a metacharacter-free subpattern and partial pathname is matched
+ * backwards to avoid full expansion of the pathname list
+ *
+ * then the actual shell glob-style regular expression (if in this form)
+ * is matched against the candidate pathnames using the slower regexec()
+ *
+ * The original BSD code is covered by the BSD license:
+ *
+ * Copyright (c) 1985, 1993, 1999
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+static const char id[] = "\n@(#)$Id: fastfind (AT&T Research) 2002-10-02 $\0\n";
+
+static const char lib[] = "libast:fastfind";
+
+#include "findlib.h"
+
+#define FIND_MATCH "*/(find|locate)/*"
+
+/*
+ * this db could be anywhere
+ * findcodes[] directories are checked for findnames[i]
+ */
+
+static char* findcodes[] =
+{
+ 0,
+ 0,
+ FIND_CODES,
+ "/usr/local/share/lib",
+ "/usr/local/lib",
+ "/usr/share/lib",
+ "/usr/lib",
+ "/var/spool",
+ "/usr/local/var",
+ "/var/lib",
+ "/var/lib/slocate",
+ "/var/db",
+};
+
+static char* findnames[] =
+{
+ "find/codes",
+ "find/find.codes",
+ "locate/locatedb",
+ "locatedb",
+ "locate.database",
+ "slocate.db",
+};
+
+/*
+ * convert t to lower case and drop leading x- and x- after /
+ * converted value copied to b of size n
+ */
+
+char*
+typefix(char* buf, size_t n, register const char* t)
+{
+ register int c;
+ register char* b = buf;
+
+ if ((*t == 'x' || *t == 'X') && *(t + 1) == '-')
+ t += 2;
+ while (c = *t++)
+ {
+ if (isupper(c))
+ c = tolower(c);
+ if ((*b++ = c) == '/' && (*t == 'x' || *t == 'X') && *(t + 1) == '-')
+ t += 2;
+ }
+ *b = 0;
+ return buf;
+}
+
+/*
+ * return a fastfind stream handle for pattern
+ */
+
+Find_t*
+findopen(const char* file, const char* pattern, const char* type, Finddisc_t* disc)
+{
+ register Find_t* fp;
+ register char* p;
+ register char* s;
+ register char* b;
+ register int i;
+ register int j;
+ char* path;
+ int brace = 0;
+ int paren = 0;
+ int k;
+ int q;
+ int fd;
+ int uid;
+ Vmalloc_t* vm;
+ Type_t* tp;
+ struct stat st;
+
+
+ if (!(vm = vmopen(Vmdcheap, Vmbest, 0)))
+ goto nospace;
+
+ /*
+ * NOTE: searching for FIND_CODES would be much simpler if we
+ * just stuck with our own, but we also support GNU
+ * locate codes and have to search for the one of a
+ * bazillion possible names for that file
+ */
+
+ if (!findcodes[1])
+ findcodes[1] = getenv(FIND_CODES_ENV);
+ if (disc->flags & FIND_GENERATE)
+ {
+ if (!(fp = (Find_t*)vmnewof(vm, 0, Find_t, 1, sizeof(Encode_t) - sizeof(Code_t))))
+ goto nospace;
+ fp->vm = vm;
+ fp->id = lib;
+ fp->disc = disc;
+ fp->generate = 1;
+ if (file && (!*file || streq(file, "-")))
+ file = 0;
+ uid = geteuid();
+ j = (findcodes[0] = (char*)file) && *file == '/' ? 1 : elementsof(findcodes);
+
+ /*
+ * look for the codes file, but since it may not exist yet,
+ * also look for the containing directory if i<2 or if
+ * it is sufficiently qualified (FIND_MATCH)
+ */
+
+ for (i = 0; i < j; i++)
+ if (path = findcodes[i])
+ {
+ if (*path == '/')
+ {
+ if (!stat(path, &st))
+ {
+ if (S_ISDIR(st.st_mode))
+ {
+ for (k = 0; k < elementsof(findnames); k++)
+ {
+ sfsprintf(fp->encode.file, sizeof(fp->encode.file), "%s/%s", path, findnames[k]);
+ if (!eaccess(fp->encode.file, R_OK|W_OK))
+ {
+ path = fp->encode.file;
+ break;
+ }
+ if (strchr(findnames[k], '/') && (b = strrchr(fp->encode.file, '/')))
+ {
+ *b = 0;
+ if (!stat(fp->encode.file, &st) && st.st_uid == uid && (st.st_mode & S_IWUSR))
+ {
+ *b = '/';
+ path = fp->encode.file;
+ break;
+ }
+ }
+ }
+ if (k < elementsof(findnames))
+ break;
+ }
+ else if (st.st_uid == uid && (st.st_mode & S_IWUSR))
+ {
+ sfsprintf(fp->encode.file, sizeof(fp->encode.file), "%s", path);
+ path = fp->encode.file;
+ break;
+ }
+ }
+ else if (i < 2 || strmatch(path, FIND_MATCH))
+ {
+ sfsprintf(fp->encode.file, sizeof(fp->encode.file), "%s", path);
+ if (b = strrchr(fp->encode.file, '/'))
+ {
+ *b = 0;
+ if (!stat(fp->encode.file, &st) && st.st_uid == uid && (st.st_mode & S_IWUSR))
+ {
+ *b = '/';
+ path = fp->encode.file;
+ break;
+ }
+ }
+ }
+ }
+ else if (pathpath(fp->encode.file, path, "", PATH_REGULAR|PATH_READ|PATH_WRITE))
+ {
+ path = fp->encode.file;
+ break;
+ }
+ else if (b = strrchr(path, '/'))
+ {
+ sfsprintf(fp->encode.file, sizeof(fp->encode.file), "%-.*s", b - path, path);
+ if (pathpath(fp->encode.temp, fp->encode.file, "", PATH_EXECUTE|PATH_READ|PATH_WRITE) &&
+ !stat(fp->encode.temp, &st) && st.st_uid == uid && (st.st_mode & S_IWUSR))
+ {
+ sfsprintf(fp->encode.file, sizeof(fp->encode.file), "%s%s", fp->encode.temp, b);
+ path = fp->encode.file;
+ break;
+ }
+ }
+ }
+ if (i >= j)
+ {
+ if (fp->disc->errorf)
+ (*fp->disc->errorf)(fp, fp->disc, 2, "%s: cannot locate codes", file ? file : findcodes[2]);
+ goto drop;
+ }
+ if (fp->disc->flags & FIND_OLD)
+ {
+ /*
+ * FF_old generates temp data that is read
+ * in a second pass to generate the real codes
+ */
+
+ fp->method = FF_old;
+ if (!(fp->fp = sftmp(32 * PATH_MAX)))
+ {
+ if (fp->disc->errorf)
+ (*fp->disc->errorf)(fp, fp->disc, ERROR_SYSTEM|2, "cannot create tmp file");
+ goto drop;
+ }
+ }
+ else
+ {
+ /*
+ * the rest generate into a temp file that
+ * is simply renamed on completion
+ */
+
+ if (s = strrchr(path, '/'))
+ {
+ *s = 0;
+ p = path;
+ }
+ else
+ p = ".";
+ if (!pathtemp(fp->encode.temp, sizeof(fp->encode.temp), p, "ff", &fd))
+ {
+ if (fp->disc->errorf)
+ (*fp->disc->errorf)(fp, fp->disc, ERROR_SYSTEM|2, "%s: cannot create tmp file in this directory", p ? p : ".");
+ goto drop;
+ }
+ if (s)
+ *s = '/';
+ if (!(fp->fp = sfnew(NiL, NiL, (size_t)SF_UNBOUND, fd, SF_WRITE)))
+ {
+ if (fp->disc->errorf)
+ (*fp->disc->errorf)(fp, fp->disc, ERROR_SYSTEM|2, "%s: cannot open tmp file", fp->encode.temp);
+ close(fd);
+ goto drop;
+ }
+ if (fp->disc->flags & FIND_TYPE)
+ {
+ fp->method = FF_typ;
+ fp->encode.namedisc.key = offsetof(Type_t, name);
+ fp->encode.namedisc.link = offsetof(Type_t, byname);
+ fp->encode.indexdisc.key = offsetof(Type_t, index);
+ fp->encode.indexdisc.size = sizeof(unsigned long);
+ fp->encode.indexdisc.link = offsetof(Type_t, byindex);
+ s = "system/dir";
+ if (!(fp->encode.namedict = dtopen(&fp->encode.namedisc, Dttree)) || !(fp->encode.indexdict = dtopen(&fp->encode.indexdisc, Dttree)) || !(tp = newof(0, Type_t, 1, strlen(s) + 1)))
+ {
+ if (fp->encode.namedict)
+ dtclose(fp->encode.namedict);
+ if (fp->disc->errorf)
+ (*fp->disc->errorf)(fp, fp->disc, 2, "cannot allocate type table");
+ goto drop;
+ }
+
+ /*
+ * type index 1 is always system/dir
+ */
+
+ tp->index = ++fp->types;
+ strcpy(tp->name, s);
+ dtinsert(fp->encode.namedict, tp);
+ dtinsert(fp->encode.indexdict, tp);
+ }
+ else if (fp->disc->flags & FIND_GNU)
+ {
+ fp->method = FF_gnu;
+ sfputc(fp->fp, 0);
+ sfputr(fp->fp, FF_gnu_magic, 0);
+ }
+ else
+ {
+ fp->method = FF_dir;
+ sfputc(fp->fp, 0);
+ sfputr(fp->fp, FF_dir_magic, 0);
+ }
+ }
+ }
+ else
+ {
+ i = sizeof(Decode_t) + sizeof(Code_t);
+ if (!pattern || !*pattern)
+ pattern = "*";
+ i += (j = 2 * (strlen(pattern) + 1));
+ if (!(fp = (Find_t*)vmnewof(vm, 0, Find_t, 1, i)))
+ {
+ vmclose(vm);
+ return 0;
+ }
+ fp->vm = vm;
+ fp->id = lib;
+ fp->disc = disc;
+ if (disc->flags & FIND_ICASE)
+ fp->decode.ignorecase = 1;
+ j = (findcodes[0] = (char*)file) && *file == '/' ? 1 : elementsof(findcodes);
+ for (i = 0; i < j; i++)
+ if (path = findcodes[i])
+ {
+ if (*path == '/')
+ {
+ if (!stat(path, &st))
+ {
+ if (S_ISDIR(st.st_mode))
+ {
+ for (k = 0; k < elementsof(findnames); k++)
+ {
+ sfsprintf(fp->decode.path, sizeof(fp->decode.path), "%s/%s", path, findnames[k]);
+ if (fp->fp = sfopen(NiL, fp->decode.path, "r"))
+ {
+ path = fp->decode.path;
+ break;
+ }
+ }
+ if (fp->fp)
+ break;
+ }
+ else if (fp->fp = sfopen(NiL, path, "r"))
+ break;
+ }
+ }
+ else if ((path = pathpath(fp->decode.path, path, "", PATH_REGULAR|PATH_READ)) && (fp->fp = sfopen(NiL, path, "r")))
+ break;
+ }
+ if (!fp->fp)
+ {
+ if (fp->disc->errorf)
+ (*fp->disc->errorf)(fp, fp->disc, 2, "%s: cannot locate codes", file ? file : findcodes[2]);
+ goto drop;
+ }
+ if (fstat(sffileno(fp->fp), &st))
+ {
+ if (fp->disc->errorf)
+ (*fp->disc->errorf)(fp, fp->disc, 2, "%s: cannot stat codes", path);
+ goto drop;
+ }
+ if (fp->secure = ((st.st_mode & (S_IRGRP|S_IROTH)) == S_IRGRP) && st.st_gid == getegid() && getegid() != getgid())
+ setgid(getgid());
+ fp->stamp = st.st_mtime;
+ b = (s = fp->decode.temp) + 1;
+ for (i = 0; i < elementsof(fp->decode.bigram1); i++)
+ {
+ if ((j = sfgetc(fp->fp)) == EOF)
+ goto invalid;
+ if (!(*s++ = fp->decode.bigram1[i] = j) && i)
+ {
+ i = -i;
+ break;
+ }
+ if ((j = sfgetc(fp->fp)) == EOF)
+ goto invalid;
+ if (!(*s++ = fp->decode.bigram2[i] = j) && (i || fp->decode.bigram1[0] >= '0' && fp->decode.bigram1[0] <= '1'))
+ break;
+ }
+ if (streq(b, FF_typ_magic))
+ {
+ if (type)
+ {
+ type = (const char*)typefix(fp->decode.bigram2, sizeof(fp->decode.bigram2), type);
+ memset(fp->decode.bigram1, 0, sizeof(fp->decode.bigram1));
+ }
+ fp->method = FF_typ;
+ for (j = 0, i = 1;; i++)
+ {
+ if (!(s = sfgetr(fp->fp, 0, 0)))
+ goto invalid;
+ if (!*s)
+ break;
+ if (type && strmatch(s, type))
+ {
+ FF_SET_TYPE(fp, i);
+ j++;
+ }
+ }
+ if (type && !j)
+ goto drop;
+ fp->types = j;
+ }
+ else if (streq(b, FF_dir_magic))
+ fp->method = FF_dir;
+ else if (streq(b, FF_gnu_magic))
+ fp->method = FF_gnu;
+ else if (!*b && *--b >= '0' && *b <= '1')
+ {
+ fp->method = FF_gnu;
+ while (j = sfgetc(fp->fp))
+ {
+ if (j == EOF || fp->decode.count >= sizeof(fp->decode.path))
+ goto invalid;
+ fp->decode.path[fp->decode.count++] = j;
+ }
+ }
+ else
+ {
+ fp->method = FF_old;
+ if (i < 0)
+ {
+ if ((j = sfgetc(fp->fp)) == EOF)
+ goto invalid;
+ fp->decode.bigram2[i = -i] = j;
+ }
+ while (++i < elementsof(fp->decode.bigram1))
+ {
+ if ((j = sfgetc(fp->fp)) == EOF)
+ goto invalid;
+ fp->decode.bigram1[i] = j;
+ if ((j = sfgetc(fp->fp)) == EOF)
+ goto invalid;
+ fp->decode.bigram2[i] = j;
+ }
+ if ((fp->decode.peek = sfgetc(fp->fp)) != FF_OFF)
+ goto invalid;
+ }
+
+ /*
+ * set up the physical dir table
+ */
+
+ if (disc->version >= 19980301L)
+ {
+ fp->verifyf = disc->verifyf;
+ if (disc->dirs && *disc->dirs)
+ {
+ for (k = 0; disc->dirs[k]; k++);
+ if (k == 1 && streq(disc->dirs[0], "/"))
+ k = 0;
+ if (k)
+ {
+ if (!(fp->dirs = vmnewof(fp->vm, 0, char*, 2 * k + 1, 0)))
+ goto drop;
+ if (!(fp->lens = vmnewof(fp->vm, 0, int, 2 * k, 0)))
+ goto drop;
+ p = 0;
+ b = fp->decode.temp;
+ j = fp->method == FF_old || fp->method == FF_gnu;
+
+ /*
+ * fill the dir list with logical and
+ * physical names since we don't know
+ * which way the db was encoded (it
+ * could be *both* ways)
+ */
+
+ for (i = q = 0; i < k; i++)
+ {
+ if (*(s = disc->dirs[i]) == '/')
+ sfsprintf(b, sizeof(fp->decode.temp) - 1, "%s", s);
+ else if (!p && !(p = getcwd(fp->decode.path, sizeof(fp->decode.path))))
+ goto nospace;
+ else
+ sfsprintf(b, sizeof(fp->decode.temp) - 1, "%s/%s", p, s);
+ s = pathcanon(b, 0);
+ *s = '/';
+ *(s + 1) = 0;
+ if (!(fp->dirs[q] = vmstrdup(fp->vm, b)))
+ goto nospace;
+ if (j)
+ (fp->dirs[q])[s - b] = 0;
+ q++;
+ *s = 0;
+ s = pathcanon(b, PATH_PHYSICAL);
+ *s = '/';
+ *(s + 1) = 0;
+ if (!strneq(b, fp->dirs[q - 1], s - b))
+ {
+ if (!(fp->dirs[q] = vmstrdup(fp->vm, b)))
+ goto nospace;
+ if (j)
+ (fp->dirs[q])[s - b] = 0;
+ q++;
+ }
+ }
+ strsort(fp->dirs, q, strcasecmp);
+ for (i = 0; i < q; i++)
+ fp->lens[i] = strlen(fp->dirs[i]);
+ }
+ }
+ }
+ if (fp->verifyf || (disc->flags & FIND_VERIFY))
+ {
+ if (fp->method != FF_dir && fp->method != FF_typ)
+ {
+ if (fp->disc->errorf)
+ (*fp->disc->errorf)(fp, fp->disc, 2, "%s: %s code format does not support directory verification", path, fp->method == FF_gnu ? FF_gnu_magic : "OLD-BIGRAM");
+ goto drop;
+ }
+ fp->verify = 1;
+ }
+
+ /*
+ * extract last glob-free subpattern in name for fast pre-match
+ * prepend 0 for backwards match
+ */
+
+ if (p = s = (char*)pattern)
+ {
+ b = fp->decode.pattern;
+ for (;;)
+ {
+ switch (*b++ = *p++)
+ {
+ case 0:
+ break;
+ case '\\':
+ s = p;
+ if (!*p++)
+ break;
+ continue;
+ case '[':
+ if (!brace)
+ {
+ brace++;
+ if (*p == ']')
+ p++;
+ }
+ continue;
+ case ']':
+ if (brace)
+ {
+ brace--;
+ s = p;
+ }
+ continue;
+ case '(':
+ if (!brace)
+ paren++;
+ continue;
+ case ')':
+ if (!brace && paren > 0 && !--paren)
+ s = p;
+ continue;
+ case '|':
+ case '&':
+ if (!brace && !paren)
+ {
+ s = "";
+ break;
+ }
+ continue;
+ case '*':
+ case '?':
+ s = p;
+ continue;
+ default:
+ continue;
+ }
+ break;
+ }
+ if (s != pattern && !streq(pattern, "*"))
+ {
+ fp->decode.match = 1;
+ if (i = regcomp(&fp->decode.re, pattern, REG_SHELL|REG_AUGMENTED|(fp->decode.ignorecase?REG_ICASE:0)))
+ {
+ if (disc->errorf)
+ {
+ regerror(i, &fp->decode.re, fp->decode.temp, sizeof(fp->decode.temp));
+ (*fp->disc->errorf)(fp, fp->disc, 2, "%s: %s", pattern, fp->decode.temp);
+ }
+ goto drop;
+ }
+ }
+ if (*s)
+ {
+ *b++ = 0;
+ while (i = *s++)
+ *b++ = i;
+ *b-- = 0;
+ fp->decode.end = b;
+ if (fp->decode.ignorecase)
+ for (s = fp->decode.pattern; s <= b; s++)
+ if (isupper(*s))
+ *s = tolower(*s);
+ }
+ }
+ }
+ return fp;
+ nospace:
+ if (disc->errorf)
+ (*fp->disc->errorf)(fp, fp->disc, 2, "out of space");
+ if (!vm)
+ return 0;
+ if (!fp)
+ {
+ vmclose(vm);
+ return 0;
+ }
+ goto drop;
+ invalid:
+ if (fp->disc->errorf)
+ (*fp->disc->errorf)(fp, fp->disc, 2, "%s: invalid codes", path);
+ drop:
+ if (!fp->generate && fp->decode.match)
+ regfree(&fp->decode.re);
+ if (fp->fp)
+ sfclose(fp->fp);
+ vmclose(fp->vm);
+ return 0;
+}
+
+/*
+ * return the next fastfind path
+ * 0 returned when list exhausted
+ */
+
+char*
+findread(register Find_t* fp)
+{
+ register char* p;
+ register char* q;
+ register char* s;
+ register char* b;
+ register char* e;
+ register int c;
+ register int n;
+ register int m;
+ int ignorecase;
+ int t;
+ unsigned char w[4];
+ struct stat st;
+
+ if (fp->generate)
+ return 0;
+ if (fp->decode.restore)
+ {
+ *fp->decode.restore = '/';
+ fp->decode.restore = 0;
+ }
+ ignorecase = fp->decode.ignorecase ? STR_ICASE : 0;
+ c = fp->decode.peek;
+ next:
+ for (;;)
+ {
+ switch (fp->method)
+ {
+ case FF_dir:
+ t = 0;
+ n = sfgetl(fp->fp);
+ goto grab;
+ case FF_gnu:
+ if ((c = sfgetc(fp->fp)) == EOF)
+ return 0;
+ if (c == 0x80)
+ {
+ if ((c = sfgetc(fp->fp)) == EOF)
+ return 0;
+ n = c << 8;
+ if ((c = sfgetc(fp->fp)) == EOF)
+ return 0;
+ n |= c;
+ if (n & 0x8000)
+ n = (n - 0xffff) - 1;
+ }
+ else if ((n = c) & 0x80)
+ n = (n - 0xff) - 1;
+ t = 0;
+ goto grab;
+ case FF_typ:
+ t = sfgetu(fp->fp);
+ n = sfgetl(fp->fp);
+ grab:
+ p = fp->decode.path + (fp->decode.count += n);
+ do
+ {
+ if ((c = sfgetc(fp->fp)) == EOF)
+ return 0;
+ } while (*p++ = c);
+ p -= 2;
+ break;
+ case FF_old:
+ if (c == EOF)
+ {
+ fp->decode.peek = c;
+ return 0;
+ }
+ if (c == FF_ESC)
+ {
+ if (sfread(fp->fp, w, sizeof(w)) != sizeof(w))
+ return 0;
+ if (fp->decode.swap >= 0)
+ {
+ c = (int32_t)((w[0] << 24) | (w[1] << 16) | (w[2] << 8) | w[3]);
+ if (!fp->decode.swap)
+ {
+ /*
+ * the old format uses machine
+ * byte order; this test uses
+ * the smallest magnitude of
+ * both byte orders on the
+ * first encoded path motion
+ * to determine the original
+ * byte order
+ */
+
+ m = c;
+ if (m < 0)
+ m = -m;
+ n = (int32_t)((w[3] << 24) | (w[2] << 16) | (w[1] << 8) | w[0]);
+ if (n < 0)
+ n = -n;
+ if (m < n)
+ fp->decode.swap = 1;
+ else
+ {
+ fp->decode.swap = -1;
+ c = (int32_t)((w[3] << 24) | (w[2] << 16) | (w[1] << 8) | w[0]);
+ }
+ }
+ }
+ else
+ c = (int32_t)((w[3] << 24) | (w[2] << 16) | (w[1] << 8) | w[0]);
+ }
+ fp->decode.count += c - FF_OFF;
+ for (p = fp->decode.path + fp->decode.count; (c = sfgetc(fp->fp)) > FF_ESC;)
+ if (c & (1<<(CHAR_BIT-1)))
+ {
+ *p++ = fp->decode.bigram1[c & ((1<<(CHAR_BIT-1))-1)];
+ *p++ = fp->decode.bigram2[c & ((1<<(CHAR_BIT-1))-1)];
+ }
+ else
+ *p++ = c;
+ *p-- = 0;
+ t = 0;
+ break;
+ }
+ b = fp->decode.path;
+ if (fp->decode.found)
+ fp->decode.found = 0;
+ else
+ b += fp->decode.count;
+ if (fp->dirs)
+ for (;;)
+ {
+ if (!*fp->dirs)
+ return 0;
+
+ /*
+ * use the ordering and lengths to prune
+ * comparison function calls
+ * (*fp->dirs)[*fp->lens]=='/' if its
+ * already been matched
+ */
+
+ if ((n = p - fp->decode.path + 1) > (m = *fp->lens))
+ {
+ if (!(*fp->dirs)[m])
+ goto next;
+ if (!strncasecmp(*fp->dirs, fp->decode.path, m))
+ break;
+ }
+ else if (n == m)
+ {
+ if (!(*fp->dirs)[m])
+ {
+ if (!(n = strcasecmp(*fp->dirs, fp->decode.path)) && (ignorecase || !strcmp(*fp->dirs, fp->decode.path)))
+ {
+ if (m > 0)
+ {
+ (*fp->dirs)[m] = '/';
+ if ((*fp->dirs)[m - 1] != '/')
+ (*fp->dirs)[++(*fp->lens)] = '/';
+ }
+ break;
+ }
+ if (n >= 0)
+ goto next;
+ }
+ }
+ else if (!(*fp->dirs)[m])
+ goto next;
+ fp->dirs++;
+ fp->lens++;
+ }
+ if (fp->verify && (*p == '/' || t == 1))
+ {
+ if ((n = p - fp->decode.path))
+ *p = 0;
+ else
+ n = 1;
+ if (fp->verifyf)
+ n = (*fp->verifyf)(fp, fp->decode.path, n, fp->disc);
+ else if (stat(fp->decode.path, &st))
+ n = -1;
+ else if ((unsigned long)st.st_mtime > fp->stamp)
+ n = 1;
+ else
+ n = 0;
+ *p = '/';
+
+ /*
+ * n<0 skip this subtree
+ * n==0 keep as is
+ * n>0 read this dir now
+ */
+
+ /* NOT IMPLEMENTED YET */
+ }
+ if (FF_OK_TYPE(fp, t))
+ {
+ if (fp->decode.end)
+ {
+ if (*(s = p) == '/')
+ s--;
+ if (*fp->decode.pattern == '/' && b > fp->decode.path)
+ b--;
+ for (; s >= b; s--)
+ if (*s == *fp->decode.end || ignorecase && tolower(*s) == *fp->decode.end)
+ {
+ if (ignorecase)
+ for (e = fp->decode.end - 1, q = s - 1; *e && (*q == *e || tolower(*q) == *e); e--, q--);
+ else
+ for (e = fp->decode.end - 1, q = s - 1; *e && *q == *e; e--, q--);
+ if (!*e)
+ {
+ fp->decode.found = 1;
+ if (!fp->decode.match || strgrpmatch(fp->decode.path, fp->decode.pattern, NiL, 0, STR_MAXIMAL|STR_LEFT|STR_RIGHT|ignorecase))
+ {
+ fp->decode.peek = c;
+ if (*p == '/')
+ *(fp->decode.restore = p) = 0;
+ if (!fp->secure || !access(fp->decode.path, F_OK))
+ return fp->decode.path;
+ }
+ break;
+ }
+ }
+ }
+ else if (!fp->decode.match || !(n = regexec(&fp->decode.re, fp->decode.path, 0, NiL, 0)))
+ {
+ fp->decode.peek = c;
+ if (*p == '/' && p > fp->decode.path)
+ *(fp->decode.restore = p) = 0;
+ if (!fp->secure || !access(fp->decode.path, F_OK))
+ return fp->decode.path;
+ }
+ else if (n != REG_NOMATCH)
+ {
+ if (fp->disc->errorf)
+ {
+ regerror(n, &fp->decode.re, fp->decode.temp, sizeof(fp->decode.temp));
+ (*fp->disc->errorf)(fp, fp->disc, 2, "%s: %s", fp->decode.pattern, fp->decode.temp);
+ }
+ return 0;
+ }
+ }
+ }
+}
+
+/*
+ * add path to the code table
+ * paths are assumed to be in sort order
+ */
+
+int
+findwrite(register Find_t* fp, const char* path, size_t len, const char* type)
+{
+ register unsigned char* s;
+ register unsigned char* e;
+ register unsigned char* p;
+ register int n;
+ register int d;
+ register Type_t* x;
+ register unsigned long u;
+
+ if (!fp->generate)
+ return -1;
+ if (type && fp->method == FF_dir)
+ {
+ len = sfsprintf(fp->encode.mark, sizeof(fp->encode.mark), "%-.*s/", len, path);
+ path = fp->encode.mark;
+ }
+ s = (unsigned char*)path;
+ if (len <= 0)
+ len = strlen(path);
+ if (len < sizeof(fp->encode.path))
+ e = s + len++;
+ else
+ {
+ len = sizeof(fp->encode.path) - 1;
+ e = s + len;
+ }
+ p = (unsigned char*)fp->encode.path;
+ while (s < e)
+ {
+ if (*s != *p++)
+ break;
+ s++;
+ }
+ n = s - (unsigned char*)path;
+ switch (fp->method)
+ {
+ case FF_gnu:
+ d = n - fp->encode.prefix;
+ if (d >= -127 && d <= 127)
+ sfputc(fp->fp, d & 0xff);
+ else
+ {
+ sfputc(fp->fp, 0x80);
+ sfputc(fp->fp, (d >> 8) & 0xff);
+ sfputc(fp->fp, d & 0xff);
+ }
+ fp->encode.prefix = n;
+ sfputr(fp->fp, (char*)s, 0);
+ break;
+ case FF_old:
+ sfprintf(fp->fp, "%ld", n - fp->encode.prefix + FF_OFF);
+ fp->encode.prefix = n;
+ sfputc(fp->fp, ' ');
+ p = s;
+ while (s < e)
+ {
+ n = *s++;
+ if (s >= e)
+ break;
+ fp->encode.code[n][*s++]++;
+ }
+ while (p < e)
+ {
+ if ((n = *p++) < FF_MIN || n >= FF_MAX)
+ n = '?';
+ sfputc(fp->fp, n);
+ }
+ sfputc(fp->fp, 0);
+ break;
+ case FF_typ:
+ if (type)
+ {
+ type = (const char*)typefix((char*)fp->encode.bigram, sizeof(fp->encode.bigram), type);
+ if (x = (Type_t*)dtmatch(fp->encode.namedict, type))
+ u = x->index;
+ else if (!(x = newof(0, Type_t, 1, strlen(type) + 1)))
+ u = 0;
+ else
+ {
+ u = x->index = ++fp->types;
+ strcpy(x->name, type);
+ dtinsert(fp->encode.namedict, x);
+ dtinsert(fp->encode.indexdict, x);
+ }
+ }
+ else
+ u = 0;
+ sfputu(fp->fp, u);
+ /*FALLTHROUGH...*/
+ case FF_dir:
+ d = n - fp->encode.prefix;
+ sfputl(fp->fp, d);
+ fp->encode.prefix = n;
+ sfputr(fp->fp, (char*)s, 0);
+ break;
+ }
+ memcpy(fp->encode.path, path, len);
+ return 0;
+}
+
+/*
+ * findsync() helper
+ */
+
+static int
+finddone(register Find_t* fp)
+{
+ int r;
+
+ if (sfsync(fp->fp))
+ {
+ if (fp->disc->errorf)
+ (*fp->disc->errorf)(fp, fp->disc, 2, "%s: write error [sfsync]", fp->encode.file);
+ return -1;
+ }
+ if (sferror(fp->fp))
+ {
+ if (fp->disc->errorf)
+ (*fp->disc->errorf)(fp, fp->disc, 2, "%s: write error [sferror]", fp->encode.file);
+ return -1;
+ }
+ r = sfclose(fp->fp);
+ fp->fp = 0;
+ if (r)
+ {
+ if (fp->disc->errorf)
+ (*fp->disc->errorf)(fp, fp->disc, 2, "%s: write error [sfclose]", fp->encode.file);
+ return -1;
+ }
+ return 0;
+}
+
+/*
+ * finish the code table
+ */
+
+static int
+findsync(register Find_t* fp)
+{
+ register char* s;
+ register int n;
+ register int m;
+ register int d;
+ register Type_t* x;
+ char* t;
+ int b;
+ long z;
+ Sfio_t* sp;
+
+ switch (fp->method)
+ {
+ case FF_dir:
+ case FF_gnu:
+ /*
+ * replace the real file with the temp file
+ */
+
+ if (finddone(fp))
+ goto bad;
+ remove(fp->encode.file);
+ if (rename(fp->encode.temp, fp->encode.file))
+ {
+ if (fp->disc->errorf)
+ (*fp->disc->errorf)(fp, fp->disc, ERROR_SYSTEM|2, "%s: cannot rename from tmp file %s", fp->encode.file, fp->encode.temp);
+ remove(fp->encode.temp);
+ return -1;
+ }
+ break;
+ case FF_old:
+ /*
+ * determine the top FF_MAX bigrams
+ */
+
+ for (n = 0; n < FF_MAX; n++)
+ for (m = 0; m < FF_MAX; m++)
+ fp->encode.hits[fp->encode.code[n][m]]++;
+ fp->encode.hits[0] = 0;
+ m = 1;
+ for (n = USHRT_MAX; n >= 0; n--)
+ if (d = fp->encode.hits[n])
+ {
+ fp->encode.hits[n] = m;
+ if ((m += d) > FF_MAX)
+ break;
+ }
+ while (--n >= 0)
+ fp->encode.hits[n] = 0;
+ for (n = FF_MAX - 1; n >= 0; n--)
+ for (m = FF_MAX - 1; m >= 0; m--)
+ if (fp->encode.hits[fp->encode.code[n][m]])
+ {
+ d = fp->encode.code[n][m];
+ b = fp->encode.hits[d] - 1;
+ fp->encode.code[n][m] = b + FF_MAX;
+ if (fp->encode.hits[d]++ >= FF_MAX)
+ fp->encode.hits[d] = 0;
+ fp->encode.bigram[b *= 2] = n;
+ fp->encode.bigram[b + 1] = m;
+ }
+ else
+ fp->encode.code[n][m] = 0;
+
+ /*
+ * commit the real file
+ */
+
+ if (sfseek(fp->fp, (Sfoff_t)0, SEEK_SET))
+ {
+ if (fp->disc->errorf)
+ (*fp->disc->errorf)(fp, fp->disc, ERROR_SYSTEM|2, "cannot rewind tmp file");
+ return -1;
+ }
+ if (!(sp = sfopen(NiL, fp->encode.file, "w")))
+ goto badcreate;
+
+ /*
+ * dump the bigrams
+ */
+
+ sfwrite(sp, fp->encode.bigram, sizeof(fp->encode.bigram));
+
+ /*
+ * encode the massaged paths
+ */
+
+ while (s = sfgetr(fp->fp, 0, 0))
+ {
+ z = strtol(s, &t, 0);
+ s = t;
+ if (z < 0 || z > 2 * FF_OFF)
+ {
+ sfputc(sp, FF_ESC);
+ sfputc(sp, (z >> 24));
+ sfputc(sp, (z >> 16));
+ sfputc(sp, (z >> 8));
+ sfputc(sp, z);
+ }
+ else
+ sfputc(sp, z);
+ while (n = *s++)
+ {
+ if (!(m = *s++))
+ {
+ sfputc(sp, n);
+ break;
+ }
+ if (d = fp->encode.code[n][m])
+ sfputc(sp, d);
+ else
+ {
+ sfputc(sp, n);
+ sfputc(sp, m);
+ }
+ }
+ }
+ sfclose(fp->fp);
+ fp->fp = sp;
+ if (finddone(fp))
+ goto bad;
+ break;
+ case FF_typ:
+ if (finddone(fp))
+ goto bad;
+ if (!(fp->fp = sfopen(NiL, fp->encode.temp, "r")))
+ {
+ if (fp->disc->errorf)
+ (*fp->disc->errorf)(fp, fp->disc, ERROR_SYSTEM|2, "%s: cannot read tmp file", fp->encode.temp);
+ remove(fp->encode.temp);
+ return -1;
+ }
+
+ /*
+ * commit the output file
+ */
+
+ if (!(sp = sfopen(NiL, fp->encode.file, "w")))
+ goto badcreate;
+
+ /*
+ * write the header magic
+ */
+
+ sfputc(sp, 0);
+ sfputr(sp, FF_typ_magic, 0);
+
+ /*
+ * write the type table in index order starting with 1
+ */
+
+ for (x = (Type_t*)dtfirst(fp->encode.indexdict); x; x = (Type_t*)dtnext(fp->encode.indexdict, x))
+ sfputr(sp, x->name, 0);
+ sfputc(sp, 0);
+
+ /*
+ * append the front compressed strings
+ */
+
+ if (sfmove(fp->fp, sp, SF_UNBOUND, -1) < 0 || !sfeof(fp->fp))
+ {
+ sfclose(sp);
+ if (fp->disc->errorf)
+ (*fp->disc->errorf)(fp, fp->disc, 2, "%s: cannot append codes", fp->encode.file);
+ goto bad;
+ }
+ sfclose(fp->fp);
+ fp->fp = sp;
+ if (finddone(fp))
+ goto bad;
+ remove(fp->encode.temp);
+ break;
+ }
+ return 0;
+ badcreate:
+ if (fp->disc->errorf)
+ (*fp->disc->errorf)(fp, fp->disc, 2, "%s: cannot write codes", fp->encode.file);
+ bad:
+ if (fp->fp)
+ {
+ sfclose(fp->fp);
+ fp->fp = 0;
+ }
+ remove(fp->encode.temp);
+ return -1;
+}
+
+/*
+ * close an open fastfind stream
+ */
+
+int
+findclose(register Find_t* fp)
+{
+ int n = 0;
+
+ if (!fp)
+ return -1;
+ if (fp->generate)
+ {
+ n = findsync(fp);
+ if (fp->encode.indexdict)
+ dtclose(fp->encode.indexdict);
+ if (fp->encode.namedict)
+ dtclose(fp->encode.namedict);
+ }
+ else
+ {
+ if (fp->decode.match)
+ regfree(&fp->decode.re);
+ n = 0;
+ }
+ if (fp->fp)
+ sfclose(fp->fp);
+ vmclose(fp->vm);
+ return n;
+}
diff --git a/usr/src/lib/libast/common/misc/findlib.h b/usr/src/lib/libast/common/misc/findlib.h
new file mode 100644
index 0000000000..50d977ebea
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/findlib.h
@@ -0,0 +1,123 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * fast find private interface
+ */
+
+#ifndef _FINDLIB_H
+#define _FINDLIB_H
+
+#include <ast.h>
+#include <cdt.h>
+#include <ctype.h>
+#include <error.h>
+#include <ls.h>
+#include <regex.h>
+#include <vmalloc.h>
+
+#define FF_old 1 /* old format - 7 bit bigram */
+#define FF_gnu 2 /* gnu 8 bit no bigram */
+#define FF_dir 3 /* FF_gnu, dirs have trailing / */
+#define FF_typ 4 /* FF_dir with types */
+
+#define FF_gnu_magic "LOCATE02"
+#define FF_dir_magic "FIND-DIR-02"
+#define FF_typ_magic "FIND-DIR-TYPE-03"
+
+#define FF_ESC 0036
+#define FF_MAX 0200
+#define FF_MIN 0040
+#define FF_OFF 0016
+
+#define FF_SET_TYPE(p,i) ((p)->decode.bigram1[((i)>>3)&((1<<CHAR_BIT)-1)]|=(1<<((i)&07)))
+#define FF_OK_TYPE(p,i) (!(p)->types||((p)->decode.bigram1[((i)>>3)&((1<<CHAR_BIT)-1)]&(1<<((i)&07))))
+
+typedef struct
+{
+ char* end;
+ char* type;
+ char* restore;
+ int count;
+ int found;
+ int ignorecase;
+ int match;
+ int peek;
+ int swap;
+ regex_t re;
+ char bigram1[(1<<(CHAR_BIT-1))];
+ char bigram2[(1<<(CHAR_BIT-1))];
+ char path[PATH_MAX];
+ char temp[PATH_MAX];
+ char pattern[1];
+} Decode_t;
+
+typedef struct
+{
+ Dtdisc_t namedisc;
+ Dtdisc_t indexdisc;
+ Dt_t* namedict;
+ Dt_t* indexdict;
+ int prefix;
+ unsigned char bigram[2*FF_MAX];
+ unsigned short code[FF_MAX][FF_MAX];
+ unsigned short hits[USHRT_MAX+1];
+ char path[PATH_MAX];
+ char mark[PATH_MAX];
+ char file[PATH_MAX];
+ char temp[PATH_MAX];
+} Encode_t;
+
+typedef union
+{
+ Decode_t code_decode;
+ Encode_t code_encode;
+} Code_t;
+
+typedef struct
+{
+ Dtlink_t byname;
+ Dtlink_t byindex;
+ unsigned long index;
+ char name[1];
+} Type_t;
+
+#define _FIND_PRIVATE_ \
+ Finddisc_t* disc; \
+ Vmalloc_t* vm; \
+ char** dirs; \
+ int* lens; \
+ Sfio_t* fp; \
+ Findverify_f verifyf; \
+ int generate; \
+ int method; \
+ int secure; \
+ int types; \
+ int verify; \
+ Code_t code;
+
+#define decode code.code_decode
+#define encode code.code_encode
+
+#include <find.h>
+
+#endif
diff --git a/usr/src/lib/libast/common/misc/fmtrec.c b/usr/src/lib/libast/common/misc/fmtrec.c
new file mode 100644
index 0000000000..5d3b51db1a
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/fmtrec.c
@@ -0,0 +1,102 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * return the record format string given a format descriptor
+ */
+
+#include <recfmt.h>
+#include <ctype.h>
+
+char*
+fmtrec(Recfmt_t f, int fs)
+{
+ char* b;
+ char* e;
+ char* s;
+ long n;
+ char del[2];
+
+ b = s = fmtbuf(n = 32);
+ e = b + n;
+ switch (RECTYPE(f))
+ {
+ case REC_delimited:
+ *s++ = 'd';
+ if ((del[0] = REC_D_DELIMITER(f)) != '\n')
+ {
+ del[1] = 0;
+ if (fs)
+ sfsprintf(s, e - s, "0x%02x", *(unsigned char*)del);
+ else
+ sfsprintf(s, e - s, "%s", fmtquote(del, NiL, NiL, 1, 0));
+ }
+ else
+ *s = 0;
+ break;
+ case REC_fixed:
+ if (!fs)
+ *s++ = 'f';
+ sfsprintf(s, e - s, "%lu", REC_F_SIZE(f));
+ break;
+ case REC_variable:
+ *s++ = 'v';
+ if (n = REC_V_SIZE(f))
+ s += sfsprintf(s, e - s, "%lu", n);
+ if (REC_V_HEADER(f) != 4)
+ s += sfsprintf(s, e - s, "h%u", REC_V_HEADER(f));
+ if (REC_V_OFFSET(f) != 0)
+ s += sfsprintf(s, e - s, "o%u", REC_V_OFFSET(f));
+ if (REC_V_LENGTH(f) != 2)
+ s += sfsprintf(s, e - s, "z%u", REC_V_LENGTH(f));
+ if (REC_V_LITTLE(f) != 0)
+ *s++ = 'l';
+ if (REC_V_INCLUSIVE(f) == 0)
+ *s++ = 'n';
+ *s = 0;
+ break;
+ case REC_method:
+ *s++ = 'm';
+ switch (n = REC_M_INDEX(f))
+ {
+ case REC_M_data:
+ sfsprintf(s, e - s, "data");
+ break;
+ case REC_M_path:
+ sfsprintf(s, e - s, "path");
+ break;
+ default:
+ sfsprintf(s, e - s, "%lu", n);
+ break;
+ }
+ break;
+ case REC_none:
+ *s++ = 'n';
+ *s = 0;
+ break;
+ default:
+ sfsprintf(s, e - s, "u%u.0x%07x", RECTYPE(f), REC_U_ATTRIBUTES(f));
+ break;
+ }
+ return b;
+}
diff --git a/usr/src/lib/libast/common/misc/fs3d.c b/usr/src/lib/libast/common/misc/fs3d.c
new file mode 100644
index 0000000000..3db7bb1f3f
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/fs3d.c
@@ -0,0 +1,90 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * 3d fs operations
+ * only active for non-shared 3d library
+ */
+
+#include <ast.h>
+#include <fs3d.h>
+
+int
+fs3d(register int op)
+{
+ register int cur;
+ register char* v;
+ char val[sizeof(FS3D_off) + 8];
+
+ static int fsview;
+ static char on[] = FS3D_on;
+ static char off[] = FS3D_off;
+
+ if (fsview < 0) return(0);
+
+ /*
+ * get the current setting
+ */
+
+ if (!fsview && mount("", "", 0, NiL))
+ goto nope;
+ if (FS3D_op(op) == FS3D_OP_INIT && mount(FS3D_init, NiL, FS3D_VIEW, NiL))
+ goto nope;
+ if (mount(on, val, FS3D_VIEW|FS3D_GET|FS3D_SIZE(sizeof(val)), NiL))
+ goto nope;
+ if (v = strchr(val, ' ')) v++;
+ else v = val;
+ if (!strcmp(v, on))
+ cur = FS3D_ON;
+ else if (!strncmp(v, off, sizeof(off) - 1) && v[sizeof(off)] == '=')
+ cur = FS3D_LIMIT((int)strtol(v + sizeof(off) + 1, NiL, 0));
+ else cur = FS3D_OFF;
+ if (cur != op)
+ {
+ switch (FS3D_op(op))
+ {
+ case FS3D_OP_OFF:
+ v = off;
+ break;
+ case FS3D_OP_ON:
+ v = on;
+ break;
+ case FS3D_OP_LIMIT:
+ sfsprintf(val, sizeof(val), "%s=%d", off, FS3D_arg(op));
+ v = val;
+ break;
+ default:
+ v = 0;
+ break;
+ }
+ if (v && mount(v, NiL, FS3D_VIEW, NiL))
+ goto nope;
+ }
+ fsview = 1;
+ return(cur);
+ nope:
+ fsview = -1;
+ return(0);
+}
diff --git a/usr/src/lib/libast/common/misc/fts.c b/usr/src/lib/libast/common/misc/fts.c
new file mode 100644
index 0000000000..c7fe8493cc
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/fts.c
@@ -0,0 +1,1510 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Phong Vo
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * fts implementation unwound from the kpv ftwalk() of 1988-10-30
+ */
+
+#include <ast.h>
+#include <ast_dir.h>
+#include <error.h>
+#include <fs3d.h>
+
+struct Ftsent;
+
+typedef int (*Compar_f)(struct Ftsent* const*, struct Ftsent* const*);
+typedef int (*Stat_f)(const char*, struct stat*);
+
+#define _FTS_PRIVATE_ \
+ FTSENT* parent; /* top parent */ \
+ FTSENT* todo; /* todo list */ \
+ FTSENT* top; /* top element */ \
+ FTSENT* root; \
+ FTSENT* bot; /* bottom element */ \
+ FTSENT* free; /* free element */ \
+ FTSENT* diroot; \
+ FTSENT* curdir; \
+ FTSENT* current; /* current element */ \
+ FTSENT* previous; /* previous current */ \
+ FTSENT* dotdot; \
+ FTSENT* link; /* real current fts_link*/ \
+ FTSENT* pwd; /* pwd parent */ \
+ DIR* dir; /* current dir stream */ \
+ Compar_f comparf; /* node comparison func */ \
+ int baselen; /* current strlen(base) */ \
+ int cd; /* chdir status */ \
+ int cpname; \
+ int flags; /* fts_open() flags */ \
+ int homesize; /* sizeof(home) */ \
+ int nd; \
+ unsigned char children; \
+ unsigned char fs3d; \
+ unsigned char nostat; \
+ unsigned char state; /* fts_read() state */ \
+ char* base; /* basename in path */ \
+ char* name; \
+ char* path; /* path workspace */ \
+ char* home; /* home/path buffer */ \
+ char* endbase; /* space to build paths */ \
+ char* endbuf; /* space to build paths */ \
+ char* pad;
+
+/*
+ * NOTE: <ftwalk.h> relies on status and statb being the first two elements
+ */
+
+#define _FTSENT_PRIVATE_ \
+ short status; /* internal status */ \
+ struct stat statb; /* fts_statp data */ \
+ int nd; /* popdir() count */ \
+ FTSENT* left; /* left child */ \
+ FTSENT* right; /* right child */ \
+ FTSENT* pwd; /* pwd parent */ \
+ FTSENT* stack; /* getlist() stack */ \
+ FTS* fts; /* for fts verification */ \
+ long nlink; /* FTS_D link count */ \
+ unsigned char must; /* must stat */ \
+ unsigned char type; /* DT_* type */ \
+ unsigned char symlink; /* originally a symlink */ \
+ char name[sizeof(int)]; /* fts_name data */
+
+#include <fts.h>
+
+#ifndef ENOSYS
+#define ENOSYS EINVAL
+#endif
+
+
+#if MAXNAMLEN > 16
+#define MINNAME 32
+#else
+#define MINNAME 16
+#endif
+
+#define drop(p,f) (((f)->fts_namelen < MINNAME) ? ((f)->fts_link = (p)->free, (p)->free = (f)) : (free(f), (p)->free))
+
+#define ACCESS(p,f) ((p)->cd==0?(f)->fts_name:(f)->fts_path)
+#define PATH(f,p,l) ((!((f)->flags&FTS_SEEDOTDIR)&&(l)>0&&(p)[0]=='.'&&(p)[1]=='/')?((p)+2):(p))
+#define SAME(one,two) ((one)->st_ino==(two)->st_ino&&(one)->st_dev==(two)->st_dev)
+#define SKIPLINK(p,f) ((f)->fts_parent->nlink == 0)
+
+#ifdef D_TYPE
+#define ISTYPE(f,t) ((f)->type == (t))
+#define TYPE(f,t) ((f)->type = (t))
+#define SKIP(p,f) ((f)->fts_parent->must == 0 && (((f)->type == DT_UNKNOWN) ? SKIPLINK(p,f) : ((f)->type != DT_DIR && ((f)->type != DT_LNK || ((p)->flags & FTS_PHYSICAL)))))
+#else
+#undef DT_UNKNOWN
+#define DT_UNKNOWN 0
+#undef DT_LNK
+#define DT_LNK 1
+#define ISTYPE(f,t) ((t)==DT_UNKNOWN)
+#define TYPE(f,d)
+#define SKIP(p,f) ((f)->fts_parent->must == 0 && SKIPLINK(p,f))
+#endif
+
+#ifndef D_FILENO
+#define D_FILENO(d) (1)
+#endif
+
+/*
+ * NOTE: a malicious dir rename() could change .. underfoot so we
+ * must always verify; undef verify to enable the unsafe code
+ */
+
+#define verify 1
+
+/*
+ * FTS_NOSTAT requires a dir with
+ * D_TYPE(&dirent_t)!=DT_UNKNOWN
+ * OR
+ * st_nlink>=2
+ */
+
+#define FTS_children_resume 1
+#define FTS_children_return 2
+#define FTS_error 3
+#define FTS_popstack 4
+#define FTS_popstack_resume 5
+#define FTS_popstack_return 6
+#define FTS_preorder 7
+#define FTS_preorder_resume 8
+#define FTS_preorder_return 9
+#define FTS_readdir 10
+#define FTS_terminal 11
+#define FTS_todo 12
+#define FTS_top_return 13
+
+typedef int (*Notify_f)(FTS*, FTSENT*, void*);
+
+typedef struct Notify_s
+{
+ struct Notify_s* next;
+ Notify_f notifyf;
+ void* context;
+} Notify_t;
+
+static Notify_t* notify;
+
+/*
+ * allocate an FTSENT node
+ */
+
+static FTSENT*
+node(FTS* fts, FTSENT* parent, register char* name, register int namelen)
+{
+ register FTSENT* f;
+ register int n;
+
+ if (fts->free && namelen < MINNAME)
+ {
+ f = fts->free;
+ fts->free = f->fts_link;
+ }
+ else
+ {
+ n = (namelen < MINNAME ? MINNAME : namelen + 1) - sizeof(int);
+ if (!(f = newof(0, FTSENT, 1, n)))
+ {
+ fts->fts_errno = errno;
+ fts->state = FTS_error;
+ return 0;
+ }
+ f->fts = fts;
+ }
+ TYPE(f, DT_UNKNOWN);
+ f->status = 0;
+ f->symlink = 0;
+ f->fts_level = (f->fts_parent = parent)->fts_level + 1;
+ f->fts_link = 0;
+ f->fts_pointer = 0;
+ f->fts_number = 0;
+ f->fts_errno = 0;
+ f->fts_namelen = namelen;
+ f->fts_name = f->name;
+ f->fts_statp = &f->statb;
+ memcpy(f->fts_name, name, namelen + 1);
+ return f;
+}
+
+/*
+ * compare directories by device/inode
+ */
+
+static int
+statcmp(FTSENT* const* pf1, FTSENT* const* pf2)
+{
+ register const FTSENT* f1 = *pf1;
+ register const FTSENT* f2 = *pf2;
+
+ if (f1->statb.st_ino < f2->statb.st_ino)
+ return -1;
+ if (f1->statb.st_ino > f2->statb.st_ino)
+ return 1;
+ if (f1->statb.st_dev < f2->statb.st_dev)
+ return -1;
+ if (f1->statb.st_dev > f2->statb.st_dev)
+ return 1;
+
+ /*
+ * hack for NFS where <dev,ino> may not uniquely identify objects
+ */
+
+ if (f1->statb.st_mtime < f2->statb.st_mtime)
+ return -1;
+ if (f1->statb.st_mtime > f2->statb.st_mtime)
+ return 1;
+ return 0;
+}
+
+/*
+ * search trees with top-down splaying (a la Tarjan and Sleator)
+ * when used for insertion sort, this implements a stable sort
+ */
+
+#define RROTATE(r) (t = r->left, r->left = t->right, t->right = r, r = t)
+#define LROTATE(r) (t = r->right, r->right = t->left, t->left = r, r = t)
+
+static FTSENT*
+search(FTSENT* e, FTSENT* root, int(*comparf)(FTSENT* const*, FTSENT* const*), int insert)
+{
+ register int cmp;
+ register FTSENT* t;
+ register FTSENT* left;
+ register FTSENT* right;
+ register FTSENT* lroot;
+ register FTSENT* rroot;
+
+ left = right = lroot = rroot = 0;
+ while (root)
+ {
+ if (!(cmp = (*comparf)(&e, &root)) && !insert)
+ break;
+ if (cmp < 0)
+ {
+ /*
+ * this is the left zig-zig case
+ */
+
+ if (root->left && (cmp = (*comparf)(&e, &root->left)) <= 0)
+ {
+ RROTATE(root);
+ if (!cmp && !insert)
+ break;
+ }
+
+ /*
+ * stick all things > e to the right tree
+ */
+
+ if (right)
+ right->left = root;
+ else
+ rroot = root;
+ right = root;
+ root = root->left;
+ right->left = 0;
+ }
+ else
+ {
+ /*
+ * this is the right zig-zig case
+ */
+
+ if (root->right && (cmp = (*comparf)(&e, &root->right)) >= 0)
+ {
+ LROTATE(root);
+ if (!cmp && !insert)
+ break;
+ }
+
+ /*
+ * stick all things <= e to the left tree
+ */
+
+ if (left)
+ left->right = root;
+ else
+ lroot = root;
+ left = root;
+ root = root->right;
+ left->right = 0;
+ }
+ }
+ if (!root)
+ root = e;
+ else
+ {
+ if (right)
+ right->left = root->right;
+ else
+ rroot = root->right;
+ if (left)
+ left->right = root->left;
+ else
+ lroot = root->left;
+ }
+ root->left = lroot;
+ root->right = rroot;
+ return root;
+}
+
+/*
+ * delete the root element from the tree
+ */
+
+static FTSENT*
+deleteroot(register FTSENT* root)
+{
+ register FTSENT* t;
+ register FTSENT* left;
+ register FTSENT* right;
+
+ right = root->right;
+ if (!(left = root->left))
+ root = right;
+ else
+ {
+ while (left->right)
+ LROTATE(left);
+ left->right = right;
+ root = left;
+ }
+ return root;
+}
+
+/*
+ * generate ordered fts_link list from binary tree at root
+ * FTSENT.stack instead of recursion to avoid blowing the real
+ * stack on big directories
+ */
+
+static void
+getlist(register FTSENT** top, register FTSENT** bot, register FTSENT* root)
+{
+ register FTSENT* stack = 0;
+
+ for (;;)
+ {
+ if (root->left)
+ {
+ root->stack = stack;
+ stack = root;
+ root = root->left;
+ }
+ else
+ {
+ for (;;)
+ {
+ if (*top)
+ *bot = (*bot)->fts_link = root;
+ else
+ *bot = *top = root;
+ if (root->right)
+ {
+ root = root->right;
+ break;
+ }
+ if (!(root = stack))
+ return;
+ stack = stack->stack;
+ }
+ }
+ }
+}
+
+/*
+ * set directory when curdir is lost in space
+ */
+
+static int
+setdir(register char* home, register char* path)
+{
+ register int cdrv;
+
+ if (path[0] == '/')
+ cdrv = pathcd(path, NiL);
+ else
+ {
+ /*
+ * note that path and home are in the same buffer
+ */
+
+ path[-1] = '/';
+ cdrv = pathcd(home, NiL);
+ path[-1] = 0;
+ }
+ if (cdrv < 0)
+ pathcd(home, NiL);
+ return cdrv;
+}
+
+/*
+ * set to parent dir
+ */
+
+static int
+setpdir(register char* home, register char* path, register char* base)
+{
+ register int c;
+ register int cdrv;
+
+ if (base > path)
+ {
+ c = base[0];
+ base[0] = 0;
+ cdrv = setdir(home, path);
+ base[0] = c;
+ }
+ else
+ cdrv = pathcd(home, NiL);
+ return cdrv;
+}
+
+/*
+ * pop a set of directories
+ */
+static int
+popdirs(FTS* fts)
+{
+ register FTSENT*f;
+ register char* s;
+ register char* e;
+#ifndef verify
+ register int verify;
+#endif
+ struct stat sb;
+ char buf[PATH_MAX];
+
+ if (!(f = fts->curdir) || f->fts_level < 0)
+ return -1;
+ e = buf + sizeof(buf) - 4;
+#ifndef verify
+ verify = 0;
+#endif
+ while (fts->nd > 0)
+ {
+ for (s = buf; s < e && fts->nd > 0; fts->nd--)
+ {
+ if (fts->pwd)
+ {
+#ifndef verify
+ verify |= fts->pwd->symlink;
+#endif
+ fts->pwd = fts->pwd->pwd;
+ }
+ *s++ = '.';
+ *s++ = '.';
+ *s++ = '/';
+ }
+ *s = 0;
+ if (chdir(buf))
+ return -1;
+ }
+ return (verify && (stat(".", &sb) < 0 || !SAME(&sb, f->fts_statp))) ? -1 : 0;
+}
+
+/*
+ * initialize st from path and fts_info from st
+ */
+
+static int
+info(FTS* fts, register FTSENT* f, const char* path, struct stat* sp, int flags)
+{
+ if (path)
+ {
+#ifdef S_ISLNK
+ if (!f->symlink && (ISTYPE(f, DT_UNKNOWN) || ISTYPE(f, DT_LNK)))
+ {
+ if (lstat(path, sp) < 0)
+ goto bad;
+ }
+ else
+#endif
+ if (stat(path, sp) < 0)
+ goto bad;
+ }
+#ifdef S_ISLNK
+ again:
+#endif
+ if (S_ISDIR(sp->st_mode))
+ {
+ if ((flags & FTS_NOSTAT) && !fts->fs3d)
+ {
+ f->fts_parent->nlink--;
+#ifdef D_TYPE
+ f->must = 0;
+ if ((f->nlink = sp->st_nlink) < 2)
+ f->nlink = 2;
+#else
+ if ((f->nlink = sp->st_nlink) >= 2)
+ f->must = 1;
+ else
+ f->must = 2;
+#endif
+ }
+ else
+ f->must = 2;
+ TYPE(f, DT_DIR);
+ f->fts_info = FTS_D;
+ }
+#ifdef S_ISLNK
+ else if (S_ISLNK((sp)->st_mode))
+ {
+ struct stat sb;
+
+ f->symlink = 1;
+ if (!(flags & FTS_PHYSICAL) && stat(path, &sb) >= 0)
+ {
+ *sp = sb;
+ flags = FTS_PHYSICAL;
+ goto again;
+ }
+ TYPE(f, DT_LNK);
+ f->fts_info = FTS_SL;
+ }
+#endif
+ else
+ {
+ TYPE(f, DT_REG);
+ f->fts_info = FTS_F;
+ }
+ return 0;
+ bad:
+ TYPE(f, DT_UNKNOWN);
+ f->fts_info = FTS_NS;
+ return -1;
+}
+
+/*
+ * get top list of elements to process
+ */
+
+static FTSENT*
+toplist(FTS* fts, register char* const* pathnames)
+{
+ register char* path;
+ register struct stat* sb;
+ register FTSENT* f;
+ register FTSENT* root;
+ int physical;
+ int metaphysical;
+ char* s;
+ FTSENT* top;
+ FTSENT* bot;
+ struct stat st;
+
+ if (fts->flags & FTS_NOSEEDOTDIR)
+ fts->flags &= ~FTS_SEEDOTDIR;
+ physical = (fts->flags & FTS_PHYSICAL);
+ metaphysical = (fts->flags & (FTS_META|FTS_PHYSICAL)) == (FTS_META|FTS_PHYSICAL);
+ top = bot = root = 0;
+ while (path = *pathnames++)
+ {
+ /*
+ * make elements
+ */
+
+ if (!(f = node(fts, fts->parent, path, strlen(path))))
+ break;
+ path = f->fts_name;
+ if (!physical)
+ f->fts_namelen = (fts->flags & FTS_SEEDOTDIR) ? strlen(path) : (pathcanon(path, 0) - path);
+ else if (*path != '.')
+ {
+ f->fts_namelen = strlen(path);
+ fts->flags |= FTS_SEEDOTDIR;
+ }
+ else
+ {
+ if (fts->flags & FTS_NOSEEDOTDIR)
+ {
+ fts->flags &= ~FTS_SEEDOTDIR;
+ s = path;
+ while (*s++ == '.' && *s++ == '/')
+ {
+ while (*s == '/')
+ s++;
+ if (!*s)
+ break;
+ path = f->fts_name;
+ while (*path++ = *s++);
+ path = f->fts_name;
+ }
+ }
+ else
+ fts->flags |= FTS_SEEDOTDIR;
+ for (s = path + strlen(path); s > path && *(s - 1) == '/'; s--);
+ *s = 0;
+ f->fts_namelen = s - path;
+ }
+ sb = f->fts_statp;
+ if (!*path)
+ {
+ errno = ENOENT;
+ f->fts_info = FTS_NS;
+ }
+ else
+ info(fts, f, path, sb, fts->flags);
+#ifdef S_ISLNK
+
+ /*
+ * don't let any standards committee get
+ * away with calling your idea a hack
+ */
+
+ if (metaphysical && f->fts_info == FTS_SL && stat(path, &st) >= 0)
+ {
+ *sb = st;
+ info(fts, f, NiL, sb, 0);
+ }
+#endif
+ if (fts->comparf)
+ root = search(f, root, fts->comparf, 1);
+ else if (bot)
+ {
+ bot->fts_link = f;
+ bot = f;
+ }
+ else
+ top = bot = f;
+ }
+ if (fts->comparf)
+ getlist(&top, &bot, root);
+ return top;
+}
+
+/*
+ * resize the path buffer
+ * note that free() is not used because we may need to chdir(fts->home)
+ * if there isn't enough space to continue
+ */
+
+static int
+resize(register FTS* fts, int inc)
+{
+ register char* old;
+ register char* newp;
+ register int n_old;
+
+ /*
+ * add space for "/." used in testing FTS_DNX
+ */
+
+ n_old = fts->homesize;
+ fts->homesize = ((fts->homesize + inc + 4) / PATH_MAX + 1) * PATH_MAX;
+ if (!(newp = newof(0, char, fts->homesize, 0)))
+ {
+ fts->fts_errno = errno;
+ fts->state = FTS_error;
+ return -1;
+ }
+ old = fts->home;
+ fts->home = newp;
+ memcpy(newp, old, n_old);
+ if (fts->endbuf)
+ fts->endbuf = newp + fts->homesize - 4;
+ if (fts->path)
+ fts->path = newp + (fts->path - old);
+ if (fts->base)
+ fts->base = newp + (fts->base - old);
+ free(old);
+ return 0;
+}
+
+/*
+ * open a new fts stream on pathnames
+ */
+
+FTS*
+fts_open(char* const* pathnames, int flags, int (*comparf)(FTSENT* const*, FTSENT* const*))
+{
+ register FTS* fts;
+
+ if (!(fts = newof(0, FTS, 1, sizeof(FTSENT))))
+ return 0;
+ fts->flags = flags;
+ fts->cd = (flags & FTS_NOCHDIR) ? 1 : -1;
+ fts->comparf = comparf;
+ fts->fs3d = fs3d(FS3D_TEST);
+
+ /*
+ * set up the path work buffer
+ */
+
+ fts->homesize = 2 * PATH_MAX;
+ for (;;)
+ {
+ if (!(fts->home = newof(fts->home, char, fts->homesize, 0)))
+ {
+ free(fts);
+ return 0;
+ }
+ if (fts->cd > 0 || getcwd(fts->home, fts->homesize))
+ break;
+ if (errno == ERANGE)
+ fts->homesize += PATH_MAX;
+ else
+ fts->cd = 1;
+ }
+ fts->endbuf = fts->home + fts->homesize - 4;
+
+ /*
+ * initialize the tippity-top
+ */
+
+ fts->parent = (FTSENT*)(fts + 1);
+ fts->parent->fts_info = FTS_D;
+ memcpy(fts->parent->fts_accpath = fts->parent->fts_path = fts->parent->fts_name = fts->parent->name, ".", 2);
+ fts->parent->fts_level = -1;
+ fts->parent->fts_statp = &fts->parent->statb;
+ fts->parent->must = 2;
+ fts->parent->type = DT_UNKNOWN;
+ fts->path = fts->home + strlen(fts->home) + 1;
+
+ /*
+ * make the list of top elements
+ */
+
+ if (!pathnames || (flags & FTS_ONEPATH) || !*pathnames)
+ {
+ char* v[2];
+
+ v[0] = pathnames && (flags & FTS_ONEPATH) ? (char*)pathnames : ".";
+ v[1] = 0;
+ fts->todo = toplist(fts, v);
+ }
+ else
+ fts->todo = toplist(fts, pathnames);
+ if (!fts->todo || fts->todo->fts_info == FTS_NS && !fts->todo->fts_link)
+ {
+ fts_close(fts);
+ return 0;
+ }
+ return fts;
+}
+
+/*
+ * return the next FTS entry
+ */
+
+FTSENT*
+fts_read(register FTS* fts)
+{
+ register char* s;
+ register int n;
+ register FTSENT* f;
+ struct dirent* d;
+ int i;
+ FTSENT* t;
+ Notify_t* p;
+#ifdef verify
+ struct stat sb;
+#endif
+
+ for (;;) switch (fts->state)
+ {
+
+ case FTS_top_return:
+
+ f = fts->todo;
+ t = 0;
+ while (f)
+ if (f->status == FTS_SKIP)
+ {
+ if (t)
+ {
+ t->fts_link = f->fts_link;
+ drop(fts, f);
+ f = t->fts_link;
+ }
+ else
+ {
+ fts->todo = f->fts_link;
+ drop(fts, f);
+ f = fts->todo;
+ }
+ }
+ else
+ {
+ t = f;
+ f = f->fts_link;
+ }
+ /*FALLTHROUGH*/
+
+ case 0:
+
+ if (!(f = fts->todo))
+ return 0;
+ /*FALLTHROUGH*/
+
+ case FTS_todo:
+
+ /*
+ * process the top object on the stack
+ */
+
+ fts->root = fts->top = fts->bot = 0;
+
+ /*
+ * initialize the top level
+ */
+
+ if (f->fts_level == 0)
+ {
+ fts->parent->fts_number = f->fts_number;
+ fts->parent->fts_pointer = f->fts_pointer;
+ fts->parent->fts_statp = f->fts_statp;
+ fts->parent->statb = *f->fts_statp;
+ f->fts_parent = fts->parent;
+ fts->diroot = 0;
+ if (fts->cd == 0)
+ pathcd(fts->home, NiL);
+ else if (fts->cd < 0)
+ fts->cd = 0;
+ fts->pwd = f->fts_parent;
+ fts->curdir = fts->cd ? 0 : f->fts_parent;
+ *(fts->base = fts->path) = 0;
+ }
+
+ /*
+ * chdir to parent if asked for
+ */
+
+ if (fts->cd < 0)
+ {
+ fts->cd = setdir(fts->home, fts->path);
+ fts->pwd = f->fts_parent;
+ fts->curdir = fts->cd ? 0 : f->fts_parent;
+ }
+
+ /*
+ * add object's name to the path
+ */
+
+ if ((fts->baselen = f->fts_namelen) >= (fts->endbuf - fts->base) && resize(fts, fts->baselen))
+ return 0;
+ memcpy(fts->base, f->name, fts->baselen + 1);
+ fts->name = fts->cd ? fts->path : fts->base;
+ /*FALLTHROUGH*/
+
+ case FTS_preorder:
+
+ /*
+ * check for cycle and open dir
+ */
+
+ if (f->fts_info == FTS_D)
+ {
+ if ((fts->diroot = search(f, fts->diroot, statcmp, 0)) != f || f->fts_level > 0 && (t = f) && statcmp(&t, &f->fts_parent) == 0)
+ {
+ f->fts_info = FTS_DC;
+ f->fts_cycle = fts->diroot;
+ }
+ else if (!(fts->flags & FTS_TOP) && (!(fts->flags & FTS_XDEV) || f->statb.st_dev == f->fts_parent->statb.st_dev))
+ {
+ /*
+ * buffer is known to be large enough here!
+ */
+
+ if (fts->base[fts->baselen - 1] != '/')
+ memcpy(fts->base + fts->baselen, "/.", 3);
+ if (!(fts->dir = opendir(fts->name)))
+ f->fts_info = FTS_DNX;
+ fts->base[fts->baselen] = 0;
+ if (!fts->dir && !(fts->dir = opendir(fts->name)))
+ f->fts_info = FTS_DNR;
+ }
+ }
+ f->nd = f->fts_info & ~FTS_DNX;
+ if (f->nd || !(fts->flags & FTS_NOPREORDER))
+ {
+ fts->current = f;
+ fts->link = f->fts_link;
+ f->fts_link = 0;
+ f->fts_path = PATH(fts, fts->path, f->fts_level);
+ f->fts_pathlen = (fts->base - f->fts_path) + fts->baselen;
+ f->fts_accpath = ACCESS(fts, f);
+ fts->state = FTS_preorder_return;
+ goto note;
+ }
+ /*FALLTHROUGH*/
+
+ case FTS_preorder_resume:
+
+ /*
+ * prune
+ */
+
+ if (!fts->dir || f->nd || f->status == FTS_SKIP)
+ {
+ if (fts->dir)
+ {
+ closedir(fts->dir);
+ fts->dir = 0;
+ }
+ fts->state = FTS_popstack;
+ continue;
+ }
+
+ /*
+ * FTS_D or FTS_DNX, about to read children
+ */
+
+ if (fts->cd == 0)
+ {
+ if ((fts->cd = chdir(fts->name)) < 0)
+ pathcd(fts->home, NiL);
+ else if (fts->pwd != f)
+ {
+ f->pwd = fts->pwd;
+ fts->pwd = f;
+ }
+ fts->curdir = fts->cd < 0 ? 0 : f;
+ }
+ fts->nostat = fts->children > 1 || f->fts_info == FTS_DNX;
+ fts->cpname = fts->cd && !fts->nostat || !fts->children && !fts->comparf;
+ fts->dotdot = 0;
+ fts->endbase = fts->base + fts->baselen;
+ if (fts->endbase[-1] != '/')
+ *fts->endbase++ = '/';
+ fts->current = f;
+ /*FALLTHROUGH*/
+
+ case FTS_readdir:
+
+ while (d = readdir(fts->dir))
+ {
+ s = d->d_name;
+ if (s[0] == '.')
+ {
+ if (s[1] == 0)
+ {
+ fts->current->nlink--;
+ if (!(fts->flags & FTS_SEEDOT))
+ continue;
+ n = 1;
+ }
+ else if (s[1] == '.' && s[2] == 0)
+ {
+ fts->current->nlink--;
+ if (fts->current->must == 1)
+ fts->current->must = 0;
+ if (!(fts->flags & FTS_SEEDOT))
+ continue;
+ n = 2;
+ }
+ else
+ n = 0;
+ }
+ else
+ n = 0;
+
+ /*
+ * make a new entry
+ */
+
+ i = D_NAMLEN(d);
+ if (!(f = node(fts, fts->current, s, i)))
+ return 0;
+ TYPE(f, D_TYPE(d));
+
+ /*
+ * check for space
+ */
+
+ if (i >= fts->endbuf - fts->endbase)
+ {
+ if (resize(fts, i))
+ return 0;
+ fts->endbase = fts->base + fts->baselen;
+ if (fts->endbase[-1] != '/')
+ fts->endbase++;
+ }
+ if (fts->cpname)
+ {
+ memcpy(fts->endbase, s, i + 1);
+ if (fts->cd)
+ s = fts->path;
+ }
+ if (n)
+ {
+ /*
+ * don't recurse on . and ..
+ */
+
+ if (n == 1)
+ f->fts_statp = fts->current->fts_statp;
+ else
+ {
+ if (f->fts_info != FTS_NS)
+ fts->dotdot = f;
+ if (fts->current->fts_parent->fts_level < 0)
+ {
+ f->fts_statp = &fts->current->fts_parent->statb;
+ info(fts, f, s, f->fts_statp, 0);
+ }
+ else
+ f->fts_statp = fts->current->fts_parent->fts_statp;
+ }
+ f->fts_info = FTS_DOT;
+ }
+ else if ((fts->nostat || SKIP(fts, f)) && (f->fts_info = FTS_NSOK) || info(fts, f, s, &f->statb, fts->flags))
+ f->statb.st_ino = D_FILENO(d);
+ if (fts->comparf)
+ fts->root = search(f, fts->root, fts->comparf, 1);
+ else if (fts->children || f->fts_info == FTS_D || f->fts_info == FTS_SL)
+ {
+ if (fts->top)
+ fts->bot = fts->bot->fts_link = f;
+ else
+ fts->top = fts->bot = f;
+ }
+ else
+ {
+ /*
+ * terminal node
+ */
+
+ f->fts_path = PATH(fts, fts->path, 1);
+ f->fts_pathlen = fts->endbase - f->fts_path + f->fts_namelen;
+ f->fts_accpath = ACCESS(fts, f);
+ fts->previous = fts->current;
+ fts->current = f;
+ fts->state = FTS_terminal;
+ goto note;
+ }
+ }
+
+ /*
+ * done with the directory
+ */
+
+ closedir(fts->dir);
+ fts->dir = 0;
+ if (fts->root)
+ getlist(&fts->top, &fts->bot, fts->root);
+ if (fts->children)
+ {
+ /*
+ * try moving back to parent dir
+ */
+
+ fts->base[fts->baselen] = 0;
+ if (fts->cd <= 0)
+ {
+ f = fts->current->fts_parent;
+ if (fts->cd < 0
+ || f != fts->curdir
+ || !fts->dotdot
+ || !SAME(f->fts_statp, fts->dotdot->fts_statp)
+ || fts->pwd && fts->pwd->symlink
+ || (fts->cd = chdir("..")) < 0
+#ifdef verify
+ || stat(".", &sb) < 0
+ || !SAME(&sb, fts->dotdot->fts_statp)
+#endif
+ )
+ fts->cd = setpdir(fts->home, fts->path, fts->base);
+ if (fts->pwd)
+ fts->pwd = fts->pwd->pwd;
+ fts->curdir = fts->cd ? 0 : f;
+ }
+ f = fts->current;
+ fts->link = f->fts_link;
+ f->fts_link = fts->top;
+ f->fts_path = PATH(fts, fts->path, f->fts_level);
+ f->fts_pathlen = (fts->base - f->fts_path) + f->fts_namelen;
+ f->fts_accpath = ACCESS(fts, f);
+ fts->state = FTS_children_return;
+ goto note;
+ }
+ /*FALLTHROUGH*/
+
+ case FTS_children_resume:
+
+ fts->base[fts->baselen] = 0;
+ if (fts->top)
+ {
+ fts->bot->fts_link = fts->todo;
+ fts->todo = fts->top;
+ fts->top = 0;
+ }
+ /*FALLTHROUGH*/
+
+ case FTS_popstack:
+
+ /*
+ * pop objects completely processed
+ */
+
+ fts->nd = 0;
+ f = fts->current;
+ /*FALLTHROUGH*/
+
+ case FTS_popstack_resume:
+
+ while (fts->todo && f == fts->todo)
+ {
+ t = f->fts_parent;
+ if ((f->fts_info & FTS_DP) == FTS_D)
+ {
+ /*
+ * delete from <dev,ino> tree
+ */
+
+ if (f != fts->diroot)
+ fts->diroot = search(f, fts->diroot, statcmp, 0);
+ fts->diroot = deleteroot(fts->diroot);
+ if (f == fts->curdir)
+ {
+ fts->nd++;
+ fts->curdir = t;
+ }
+
+ /*
+ * perform post-order processing
+ */
+
+ if (!(fts->flags & FTS_NOPOSTORDER) &&
+ f->status != FTS_SKIP &&
+ f->status != FTS_NOPOSTORDER)
+ {
+ /*
+ * move to parent dir
+ */
+
+ if (fts->nd > 0)
+ fts->cd = popdirs(fts);
+ if (fts->cd < 0)
+ fts->cd = setpdir(fts->home, fts->path, fts->base);
+ fts->curdir = fts->cd ? 0 : t;
+ f->fts_info = FTS_DP;
+ f->fts_path = PATH(fts, fts->path, f->fts_level);
+ f->fts_pathlen = (fts->base - f->fts_path) + f->fts_namelen;
+ f->fts_accpath = ACCESS(fts, f);
+
+ /*
+ * re-stat to update nlink/times
+ */
+
+ stat(f->fts_accpath, f->fts_statp);
+ fts->link = f->fts_link;
+ f->fts_link = 0;
+ fts->state = FTS_popstack_return;
+ goto note;
+ }
+ }
+
+ /*
+ * reset base
+ */
+
+ if (fts->base > fts->path + t->fts_namelen)
+ fts->base--;
+ *fts->base = 0;
+ fts->base -= t->fts_namelen;
+
+ /*
+ * try again or delete from top of stack
+ */
+
+ if (f->status == FTS_AGAIN)
+ {
+ f->fts_info = FTS_D;
+ f->status = 0;
+ }
+ else
+ {
+ fts->todo = fts->todo->fts_link;
+ drop(fts, f);
+ }
+ f = t;
+ }
+
+ /*
+ * reset current directory
+ */
+
+ if (fts->nd > 0 && popdirs(fts) < 0)
+ {
+ pathcd(fts->home, NiL);
+ fts->curdir = 0;
+ fts->cd = -1;
+ }
+ if (fts->todo)
+ {
+ if (*fts->base)
+ fts->base += f->fts_namelen;
+ if (*(fts->base - 1) != '/')
+ *fts->base++ = '/';
+ *fts->base = 0;
+ f = fts->todo;
+ fts->state = FTS_todo;
+ continue;
+ }
+ return 0;
+
+ case FTS_children_return:
+
+ f = fts->current;
+ f->fts_link = fts->link;
+
+ /*
+ * chdir down again
+ */
+
+ i = f->fts_info != FTS_DNX;
+ n = f->status == FTS_SKIP;
+ if (!n && fts->cd == 0)
+ {
+ if ((fts->cd = chdir(fts->base)) < 0)
+ pathcd(fts->home, NiL);
+ else if (fts->pwd != f)
+ {
+ f->pwd = fts->pwd;
+ fts->pwd = f;
+ }
+ fts->curdir = fts->cd ? 0 : f;
+ }
+
+ /*
+ * prune
+ */
+
+ if (fts->base[fts->baselen - 1] != '/')
+ fts->base[fts->baselen] = '/';
+ for (fts->bot = 0, f = fts->top; f; )
+ if (n || f->status == FTS_SKIP)
+ {
+ if (fts->bot)
+ fts->bot->fts_link = f->fts_link;
+ else
+ fts->top = f->fts_link;
+ drop(fts, f);
+ f = fts->bot ? fts->bot->fts_link : fts->top;
+ }
+ else
+ {
+ if (fts->children > 1 && i)
+ {
+ if (f->status == FTS_STAT)
+ info(fts, f, NiL, f->fts_statp, 0);
+ else if (f->fts_info == FTS_NSOK && !SKIP(fts, f))
+ {
+ s = f->fts_name;
+ if (fts->cd)
+ {
+ memcpy(fts->endbase, s, f->fts_namelen + 1);
+ s = fts->path;
+ }
+ info(fts, f, s, f->fts_statp, fts->flags);
+ }
+ }
+ fts->bot = f;
+ f = f->fts_link;
+ }
+ fts->children = 0;
+ fts->state = FTS_children_resume;
+ continue;
+
+ case FTS_popstack_return:
+
+ f = fts->todo;
+ f->fts_link = fts->link;
+ f->fts_info = f->status == FTS_AGAIN ? FTS_DP : 0;
+ fts->state = FTS_popstack_resume;
+ continue;
+
+ case FTS_preorder_return:
+
+ f = fts->current;
+ f->fts_link = fts->link;
+
+ /*
+ * follow symlink if asked to
+ */
+
+ if (f->status == FTS_FOLLOW)
+ {
+ f->status = 0;
+ if (f->fts_info == FTS_SL || ISTYPE(f, DT_LNK) || f->fts_info == FTS_NSOK)
+ {
+ info(fts, f, f->fts_accpath, f->fts_statp, 0);
+ if (f->fts_info != FTS_SL)
+ {
+ fts->state = FTS_preorder;
+ continue;
+ }
+ }
+ }
+
+ /*
+ * about to prune this f and already at home
+ */
+
+ if (fts->cd == 0 && f->fts_level == 0 && f->nd)
+ fts->cd = -1;
+ fts->state = FTS_preorder_resume;
+ continue;
+
+ case FTS_terminal:
+
+ f = fts->current;
+ if (f->status == FTS_FOLLOW)
+ {
+ f->status = 0;
+ if (f->fts_info == FTS_SL || ISTYPE(f, DT_LNK) || f->fts_info == FTS_NSOK)
+ {
+ info(fts, f, f->fts_accpath, f->fts_statp, 0);
+ if (f->symlink && f->fts_info != FTS_SL)
+ {
+ if (!(f->fts_link = fts->top))
+ fts->bot = f;
+ fts->top = f;
+ fts->current = fts->previous;
+ fts->state = FTS_readdir;
+ continue;
+ }
+ }
+ }
+ f = f->fts_parent;
+ drop(fts, fts->current);
+ fts->current = f;
+ fts->state = FTS_readdir;
+ continue;
+
+ case FTS_error:
+
+ return 0;
+
+ default:
+
+ fts->fts_errno = EINVAL;
+ fts->state = FTS_error;
+ return 0;
+
+ }
+ note:
+ for (p = notify; p; p = p->next)
+ if ((n = (*p->notifyf)(fts, f, p->context)) > 0)
+ break;
+ else if (n < 0)
+ {
+ fts->fts_errno = EINVAL;
+ fts->state = FTS_error;
+ return 0;
+ }
+ return f;
+}
+
+/*
+ * set stream or entry flags
+ */
+
+int
+fts_set(register FTS* fts, register FTSENT* f, int status)
+{
+ if (fts || !f || f->fts->current != f)
+ return -1;
+ switch (status)
+ {
+ case FTS_AGAIN:
+ break;
+ case FTS_FOLLOW:
+ if (!(f->fts_info & FTS_SL))
+ return -1;
+ break;
+ case FTS_NOPOSTORDER:
+ break;
+ case FTS_SKIP:
+ if ((f->fts_info & (FTS_D|FTS_P)) != FTS_D)
+ return -1;
+ break;
+ default:
+ return -1;
+ }
+ f->status = status;
+ return 0;
+}
+
+/*
+ * return the list of child entries
+ */
+
+FTSENT*
+fts_children(register FTS* fts, int flags)
+{
+ register FTSENT* f;
+
+ switch (fts->state)
+ {
+
+ case 0:
+
+ fts->state = FTS_top_return;
+ return fts->todo;
+
+ case FTS_preorder_return:
+
+ fts->children = ((flags | fts->flags) & FTS_NOSTAT) ? 2 : 1;
+ if (f = fts_read(fts))
+ f = f->fts_link;
+ return f;
+
+ }
+ return 0;
+}
+
+/*
+ * return default (FTS_LOGICAL|FTS_META|FTS_PHYSICAL|FTS_SEEDOTDIR) flags
+ * conditioned by astconf()
+ */
+
+int
+fts_flags(void)
+{
+ register char* s;
+
+ s = astconf("PATH_RESOLVE", NiL, NiL);
+ if (streq(s, "logical"))
+ return FTS_LOGICAL;
+ if (streq(s, "physical"))
+ return FTS_PHYSICAL|FTS_SEEDOTDIR;
+ return FTS_META|FTS_PHYSICAL|FTS_SEEDOTDIR;
+}
+
+/*
+ * close an open fts stream
+ */
+
+int
+fts_close(register FTS* fts)
+{
+ register FTSENT* f;
+ register FTSENT* x;
+
+ if (fts->dir)
+ closedir(fts->dir);
+ if (fts->cd == 0)
+ pathcd(fts->home, NiL);
+ free(fts->home);
+ if (fts->state == FTS_children_return)
+ fts->current->fts_link = fts->link;
+ if (fts->top)
+ {
+ fts->bot->fts_link = fts->todo;
+ fts->todo = fts->top;
+ }
+ for (f = fts->todo; f; f = x)
+ {
+ x = f->fts_link;
+ free(f);
+ }
+ for (f = fts->free; f; f = x)
+ {
+ x = f->fts_link;
+ free(f);
+ }
+ return 0;
+}
+
+/*
+ * register function to be called for each fts_read() entry
+ */
+
+int
+fts_notify(Notify_f notifyf, void* context)
+{
+ register Notify_t* np;
+
+ if (!(np = newof(0, Notify_t, 1, 0)))
+ return -1;
+ np->notifyf = notifyf;
+ np->context = context;
+ np->next = notify;
+ notify = np;
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/misc/ftwalk.c b/usr/src/lib/libast/common/misc/ftwalk.c
new file mode 100644
index 0000000000..d3c3dc2027
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/ftwalk.c
@@ -0,0 +1,154 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * ftwalk on top of fts
+ */
+
+#include <ast.h>
+#include <ftwalk.h>
+
+static struct
+{
+ int (*comparf)(Ftw_t*, Ftw_t*);
+} state;
+
+/*
+ * why does fts take FTSENT** instead of FTSENT*
+ */
+
+static int
+ftscompare(Ftw_t* const* pf1, Ftw_t* const* pf2)
+{
+ return (*state.comparf)(*pf1, *pf2);
+}
+
+/*
+ * the real thing -- well it used to be
+ */
+
+int
+ftwalk(const char* path, int (*userf)(Ftw_t*), int flags, int (*comparf)(Ftw_t*, Ftw_t*))
+{
+ register FTS* f;
+ register FTSENT* e;
+ register int children;
+ register int rv;
+ int oi;
+ int ns;
+ int os;
+ int nd;
+ FTSENT* x;
+ FTSENT* dd[2];
+
+ flags ^= FTS_ONEPATH;
+ if (flags & FTW_TWICE)
+ flags &= ~(FTS_NOPREORDER|FTS_NOPOSTORDER);
+ else if (flags & FTW_POST)
+ flags |= FTS_NOPREORDER;
+ else
+ flags |= FTS_NOPOSTORDER;
+ if (children = flags & FTW_CHILDREN)
+ flags |= FTS_SEEDOT;
+ state.comparf = comparf;
+ if (!(f = fts_open((char* const*)path, flags, comparf ? ftscompare : 0)))
+ {
+ if (!path || !(flags & FTS_ONEPATH) && !(path = (const char*)(*((char**)path))))
+ return -1;
+ ns = strlen(path) + 1;
+ if (!(e = newof(0, FTSENT, 1, ns)))
+ return -1;
+ e->fts_accpath = e->fts_name = e->fts_path = strcpy((char*)(e + 1), path);
+ e->fts_namelen = e->fts_pathlen = ns;
+ e->fts_info = FTS_NS;
+ e->parent = e;
+ e->parent->link = e;
+ rv = (*userf)((Ftw_t*)e);
+ free(e);
+ return rv;
+ }
+ rv = 0;
+ if (children && (e = fts_children(f, 0)))
+ {
+ nd = 0;
+ for (x = e; x; x = x->link)
+ if (x->info & FTS_DD)
+ {
+ x->statb = *x->fts_statp;
+ x->info &= ~FTS_DD;
+ dd[nd++] = x;
+ if (nd >= elementsof(dd))
+ break;
+ }
+ e->parent->link = e;
+ rv = (*userf)((Ftw_t*)e->parent);
+ e->parent->link = 0;
+ while (nd > 0)
+ dd[--nd]->info |= FTS_DD;
+ for (x = e; x; x = x->link)
+ if (!(x->info & FTS_D))
+ x->status = FTS_SKIP;
+ }
+ while (!rv && (e = fts_read(f)))
+ {
+ oi = e->info;
+ os = e->status;
+ ns = e->status = e->path == e->fts_accpath ? FTW_PATH : FTW_NAME;
+ nd = 0;
+ switch (e->info)
+ {
+ case FTS_D:
+ case FTS_DNX:
+ if (children)
+ for (x = fts_children(f, 0); x; x = x->link)
+ if (x->info & FTS_DD)
+ {
+ x->statb = *x->fts_statp;
+ x->info &= ~FTS_DD;
+ dd[nd++] = x;
+ if (nd >= elementsof(dd))
+ break;
+ }
+ break;
+ case FTS_DOT:
+ continue;
+ case FTS_ERR:
+ case FTS_SLNONE:
+ e->info = FTS_NS;
+ break;
+ case FTS_NSOK:
+ e->info = FTS_NSOK;
+ break;
+ }
+ rv = (*userf)((Ftw_t*)e);
+ e->info = oi;
+ if (e->status == ns)
+ e->status = os;
+ while (nd > 0)
+ dd[--nd]->info |= FTS_DD;
+ }
+ fts_close(f);
+ return rv;
+}
diff --git a/usr/src/lib/libast/common/misc/ftwflags.c b/usr/src/lib/libast/common/misc/ftwflags.c
new file mode 100644
index 0000000000..f13069a6b9
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/ftwflags.c
@@ -0,0 +1,35 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * return default FTW_* flags conditioned by astconf()
+ */
+
+#include <ast.h>
+#include <ftwalk.h>
+
+int
+ftwflags(void)
+{
+ return fts_flags();
+}
diff --git a/usr/src/lib/libast/common/misc/getcwd.c b/usr/src/lib/libast/common/misc/getcwd.c
new file mode 100644
index 0000000000..54a4978a66
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/getcwd.c
@@ -0,0 +1,290 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * pwd library support
+ */
+
+#include <ast.h>
+
+#if _WINIX
+
+NoN(getcwd)
+
+#else
+
+#include <ast_dir.h>
+#include <error.h>
+#include <fs3d.h>
+
+#ifndef ERANGE
+#define ERANGE E2BIG
+#endif
+
+#define ERROR(e) { errno = e; goto error; }
+
+struct dirlist /* long path chdir(2) component */
+{
+ struct dirlist* next; /* next component */
+ int index; /* index from end of buf */
+};
+
+/*
+ * pop long dir component chdir stack
+ */
+
+static int
+popdir(register struct dirlist* d, register char* end)
+{
+ register struct dirlist* dp;
+ int v;
+
+ v = 0;
+ while (dp = d)
+ {
+ d = d->next;
+ if (!v)
+ {
+ if (d) *(end - d->index - 1) = 0;
+ v = chdir(end - dp->index);
+ if (d) *(end - d->index - 1) = '/';
+ }
+ free(dp);
+ }
+ return v;
+}
+
+/*
+ * push long dir component onto stack
+ */
+
+static struct dirlist*
+pushdir(register struct dirlist* d, char* dots, char* path, char* end)
+{
+ register struct dirlist* p;
+
+ if (!(p = newof(0, struct dirlist, 1, 0)) || chdir(dots))
+ {
+ if (p) free(p);
+ if (d) popdir(d, end);
+ return 0;
+ }
+ p->index = end - path;
+ p->next = d;
+ return p;
+}
+
+/*
+ * return a pointer to the absolute path name of .
+ * this path name may be longer than PATH_MAX
+ *
+ * a few environment variables are checked before the search algorithm
+ * return value is placed in buf of len chars
+ * if buf is 0 then space is allocated via malloc() with
+ * len extra chars after the path name
+ * 0 is returned on error with errno set as appropriate
+ */
+
+char*
+getcwd(char* buf, size_t len)
+{
+ register char* d;
+ register char* p;
+ register char* s;
+ DIR* dirp = 0;
+ int n;
+ int x;
+ size_t namlen;
+ ssize_t extra = -1;
+ struct dirent* entry;
+ struct dirlist* dirstk = 0;
+ struct stat* cur;
+ struct stat* par;
+ struct stat* tmp;
+ struct stat curst;
+ struct stat parst;
+ struct stat tstst;
+ char dots[PATH_MAX];
+
+ static struct
+ {
+ char* name;
+ char* path;
+ dev_t dev;
+ ino_t ino;
+ } env[] =
+ {
+ { /*previous*/0 },
+ { "PWD" },
+ { "HOME" },
+ };
+
+ if (buf && !len) ERROR(EINVAL);
+ if (fs3d(FS3D_TEST) && (namlen = mount(".", dots, FS3D_GET|FS3D_VIEW|FS3D_SIZE(sizeof(dots)), NiL)) > 1 && namlen < sizeof(dots))
+ {
+ p = dots;
+ easy:
+ namlen++;
+ if (buf)
+ {
+ if (len < namlen) ERROR(ERANGE);
+ }
+ else if (!(buf = newof(0, char, namlen, len))) ERROR(ENOMEM);
+ return (char*)memcpy(buf, p, namlen);
+ }
+ cur = &curst;
+ par = &parst;
+ if (stat(".", par)) ERROR(errno);
+ for (n = 0; n < elementsof(env); n++)
+ {
+ if ((env[n].name && (p = getenv(env[n].name)) || (p = env[n].path)) && *p == '/' && !stat(p, cur))
+ {
+ env[n].path = p;
+ env[n].dev = cur->st_dev;
+ env[n].ino = cur->st_ino;
+ if (cur->st_ino == par->st_ino && cur->st_dev == par->st_dev)
+ {
+ namlen = strlen(p);
+ goto easy;
+ }
+ }
+ }
+ if (!buf)
+ {
+ extra = len;
+ len = PATH_MAX;
+ if (!(buf = newof(0, char, len, extra))) ERROR(ENOMEM);
+ }
+ d = dots;
+ p = buf + len - 1;
+ *p = 0;
+ n = elementsof(env);
+ for (;;)
+ {
+ tmp = cur;
+ cur = par;
+ par = tmp;
+ if ((d - dots) > (PATH_MAX - 4))
+ {
+ if (!(dirstk = pushdir(dirstk, dots, p, buf + len - 1))) ERROR(ERANGE);
+ d = dots;
+ }
+ *d++ = '.';
+ *d++ = '.';
+ *d = 0;
+ if (!(dirp = opendir(dots))) ERROR(errno);
+#if !_dir_ok || _mem_dd_fd_DIR
+ if (fstat(dirp->dd_fd, par)) ERROR(errno);
+#else
+ if (stat(dots, par)) ERROR(errno);
+#endif
+ *d++ = '/';
+ if (par->st_dev == cur->st_dev)
+ {
+ if (par->st_ino == cur->st_ino)
+ {
+ closedir(dirp);
+ *--p = '/';
+ pop:
+ if (p != buf)
+ {
+ d = buf;
+ while (*d++ = *p++);
+ len = d - buf;
+ if (extra >= 0 && !(buf = newof(buf, char, len, extra))) ERROR(ENOMEM);
+ }
+ if (dirstk && popdir(dirstk, buf + len - 1))
+ {
+ dirstk = 0;
+ ERROR(errno);
+ }
+ if (env[0].path)
+ free(env[0].path);
+ env[0].path = strdup(buf);
+ return buf;
+ }
+#ifdef D_FILENO
+ while (entry = readdir(dirp))
+ if (D_FILENO(entry) == cur->st_ino)
+ {
+ namlen = D_NAMLEN(entry);
+ goto found;
+ }
+#endif
+
+ /*
+ * this fallthrough handles logical naming
+ */
+
+ rewinddir(dirp);
+ }
+ do
+ {
+ if (!(entry = readdir(dirp))) ERROR(ENOENT);
+ namlen = D_NAMLEN(entry);
+ if ((d - dots) > (PATH_MAX - 1 - namlen))
+ {
+ *d = 0;
+ if (namlen >= PATH_MAX || !(dirstk = pushdir(dirstk, dots + 3, p, buf + len - 1))) ERROR(ERANGE);
+ d = dots + 3;
+ }
+ memcpy(d, entry->d_name, namlen + 1);
+ } while (stat(dots, &tstst) || tstst.st_ino != cur->st_ino || tstst.st_dev != cur->st_dev);
+ found:
+ if (*p) *--p = '/';
+ while ((p -= namlen) <= (buf + 1))
+ {
+ x = (buf + len - 1) - (p += namlen);
+ s = buf + len;
+ if (extra < 0 || !(buf = newof(buf, char, len += PATH_MAX, extra))) ERROR(ERANGE);
+ p = buf + len;
+ while (p > buf + len - 1 - x) *--p = *--s;
+ }
+ if (n < elementsof(env))
+ {
+ memcpy(p, env[n].path, namlen);
+ goto pop;
+ }
+ memcpy(p, entry->d_name, namlen);
+ closedir(dirp);
+ dirp = 0;
+ for (n = 0; n < elementsof(env); n++)
+ if (env[n].ino == par->st_ino && env[n].dev == par->st_dev)
+ {
+ namlen = strlen(env[n].path);
+ goto found;
+ }
+ }
+ error:
+ if (buf)
+ {
+ if (dirstk) popdir(dirstk, buf + len - 1);
+ if (extra >= 0) free(buf);
+ }
+ if (dirp) closedir(dirp);
+ return 0;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/misc/glob.c b/usr/src/lib/libast/common/misc/glob.c
new file mode 100644
index 0000000000..2849d3111c
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/glob.c
@@ -0,0 +1,813 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * file name expansion - posix.2 glob with gnu and ast extensions
+ *
+ * David Korn
+ * Glenn Fowler
+ * AT&T Research
+ */
+
+#include <ast.h>
+#include <ls.h>
+#include <stak.h>
+#include <ast_dir.h>
+#include <error.h>
+#include <ctype.h>
+#include <regex.h>
+
+#define GLOB_MAGIC 0xaaaa0000
+
+#define MATCH_RAW 1
+#define MATCH_MAKE 2
+#define MATCH_META 4
+
+#define MATCHPATH(g) (offsetof(globlist_t,gl_path)+(g)->gl_extra)
+
+typedef int (*GL_error_f)(const char*, int);
+typedef void* (*GL_opendir_f)(const char*);
+typedef struct dirent* (*GL_readdir_f)(void*);
+typedef void (*GL_closedir_f)(void*);
+typedef int (*GL_stat_f)(const char*, struct stat*);
+
+#define _GLOB_PRIVATE_ \
+ GL_error_f gl_errfn; \
+ int gl_error; \
+ char* gl_nextpath; \
+ globlist_t* gl_rescan; \
+ globlist_t* gl_match; \
+ Stak_t* gl_stak; \
+ int re_flags; \
+ regex_t* gl_ignore; \
+ regex_t* gl_ignorei; \
+ regex_t re_ignore; \
+ regex_t re_ignorei; \
+ unsigned long gl_starstar; \
+ char* gl_opt; \
+ char* gl_pat; \
+ char* gl_pad[4];
+
+#include <glob.h>
+
+/*
+ * default gl_diropen
+ */
+
+static void*
+gl_diropen(glob_t* gp, const char* path)
+{
+ return (*gp->gl_opendir)(path);
+}
+
+/*
+ * default gl_dirnext
+ */
+
+static char*
+gl_dirnext(glob_t* gp, void* handle)
+{
+ struct dirent* dp;
+
+ while (dp = (struct dirent*)(*gp->gl_readdir)(handle))
+#ifdef D_FILENO
+ if (D_FILENO(dp))
+#endif
+ {
+#ifdef D_TYPE
+ if (D_TYPE(dp) != DT_UNKNOWN && D_TYPE(dp) != DT_DIR && D_TYPE(dp) != DT_LNK)
+ gp->gl_status |= GLOB_NOTDIR;
+#endif
+ return dp->d_name;
+ }
+ return 0;
+}
+
+/*
+ * default gl_dirclose
+ */
+
+static void
+gl_dirclose(glob_t* gp, void* handle)
+{
+ (gp->gl_closedir)(handle);
+}
+
+/*
+ * default gl_type
+ */
+
+static int
+gl_type(glob_t* gp, const char* path)
+{
+ register int type;
+ struct stat st;
+
+ if ((*gp->gl_stat)(path, &st))
+ type = 0;
+ else if (S_ISDIR(st.st_mode))
+ type = GLOB_DIR;
+ else if (!S_ISREG(st.st_mode))
+ type = GLOB_DEV;
+ else if (st.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH))
+ type = GLOB_EXE;
+ else
+ type = GLOB_REG;
+ return type;
+}
+
+/*
+ * default gl_attr
+ */
+
+static int
+gl_attr(glob_t* gp, const char* path)
+{
+ return strchr(astconf("PATH_ATTRIBUTES", path, NiL), 'c') ? GLOB_ICASE : 0;
+}
+
+/*
+ * default gl_nextdir
+ */
+
+static char*
+gl_nextdir(glob_t* gp, char* dir)
+{
+ if (!(dir = gp->gl_nextpath))
+ dir = gp->gl_nextpath = stakcopy(pathbin());
+ switch (*gp->gl_nextpath)
+ {
+ case 0:
+ dir = 0;
+ break;
+ case ':':
+ while (*gp->gl_nextpath == ':')
+ gp->gl_nextpath++;
+ dir = ".";
+ break;
+ default:
+ while (*gp->gl_nextpath)
+ if (*gp->gl_nextpath++ == ':')
+ {
+ *(gp->gl_nextpath - 1) = 0;
+ break;
+ }
+ break;
+ }
+ return dir;
+}
+
+/*
+ * error intercept
+ */
+
+static int
+errorcheck(register glob_t* gp, const char* path)
+{
+ int r = 1;
+
+ if (gp->gl_errfn)
+ r = (*gp->gl_errfn)(path, errno);
+ if (gp->gl_flags & GLOB_ERR)
+ r = 0;
+ if (!r)
+ gp->gl_error = GLOB_ABORTED;
+ return r;
+}
+
+/*
+ * remove backslashes
+ */
+
+static void
+trim(register char* sp, register char* p1, int* n1, register char* p2, int* n2)
+{
+ register char* dp = sp;
+ register int c;
+ register int n;
+
+ if (p1)
+ *n1 = 0;
+ if (p2)
+ *n2 = 0;
+ do
+ {
+ if ((c = *sp++) == '\\' && (c = *sp++))
+ n++;
+ if (sp == p1)
+ {
+ p1 = 0;
+ *n1 = sp - dp - 1;
+ }
+ if (sp == p2)
+ {
+ p2 = 0;
+ *n2 = sp - dp - 1;
+ }
+ } while (*dp++ = c);
+}
+
+static void
+addmatch(register glob_t* gp, const char* dir, const char* pat, register const char* rescan, char* endslash, int meta)
+{
+ register globlist_t* ap;
+ int offset;
+ int type;
+
+ stakseek(MATCHPATH(gp));
+ if (dir)
+ {
+ stakputs(dir);
+ stakputc(gp->gl_delim);
+ }
+ if (endslash)
+ *endslash = 0;
+ stakputs(pat);
+ if (rescan)
+ {
+ if ((*gp->gl_type)(gp, stakptr(MATCHPATH(gp))) != GLOB_DIR)
+ return;
+ stakputc(gp->gl_delim);
+ offset = staktell();
+ /* if null, reserve room for . */
+ if (*rescan)
+ stakputs(rescan);
+ else
+ stakputc(0);
+ stakputc(0);
+ rescan = stakptr(offset);
+ ap = (globlist_t*)stakfreeze(0);
+ ap->gl_begin = (char*)rescan;
+ ap->gl_next = gp->gl_rescan;
+ gp->gl_rescan = ap;
+ }
+ else
+ {
+ if (!endslash && (gp->gl_flags & GLOB_MARK) && (type = (*gp->gl_type)(gp, stakptr(MATCHPATH(gp)))))
+ {
+ if ((gp->gl_flags & GLOB_COMPLETE) && type != GLOB_EXE)
+ {
+ stakseek(0);
+ return;
+ }
+ else if (type == GLOB_DIR && (gp->gl_flags & GLOB_MARK))
+ stakputc(gp->gl_delim);
+ }
+ ap = (globlist_t*)stakfreeze(1);
+ ap->gl_next = gp->gl_match;
+ gp->gl_match = ap;
+ gp->gl_pathc++;
+ }
+ ap->gl_flags = MATCH_RAW|meta;
+ if (gp->gl_flags & GLOB_COMPLETE)
+ ap->gl_flags |= MATCH_MAKE;
+}
+
+/*
+ * this routine builds a list of files that match a given pathname
+ * uses REG_SHELL of <regex> to match each component
+ * a leading . must match explicitly
+ */
+
+static void
+glob_dir(glob_t* gp, globlist_t* ap)
+{
+ register char* rescan;
+ register char* prefix;
+ register char* pat;
+ register char* name;
+ register int c;
+ char* dirname;
+ void* dirf;
+ char first;
+ regex_t* ire;
+ regex_t* pre;
+ regex_t rec;
+ regex_t rei;
+ int notdir;
+ int t1;
+ int t2;
+ int bracket;
+
+ int anymeta = ap->gl_flags & MATCH_META;
+ int complete = 0;
+ int err = 0;
+ int meta = ((gp->re_flags & REG_ICASE) && *ap->gl_begin != '/') ? MATCH_META : 0;
+ int quote = 0;
+ int savequote = 0;
+ char* restore1 = 0;
+ char* restore2 = 0;
+ regex_t* prec = 0;
+ regex_t* prei = 0;
+ char* matchdir = 0;
+ int starstar = 0;
+
+ if (*gp->gl_intr)
+ {
+ gp->gl_error = GLOB_INTR;
+ return;
+ }
+ pat = rescan = ap->gl_begin;
+ prefix = dirname = ap->gl_path + gp->gl_extra;
+ first = (rescan == prefix);
+again:
+ bracket = 0;
+ for (;;)
+ {
+ switch (c = *rescan++)
+ {
+ case 0:
+ if (meta)
+ {
+ rescan = 0;
+ break;
+ }
+ if (quote)
+ {
+ trim(ap->gl_begin, rescan, &t1, NiL, NiL);
+ rescan -= t1;
+ }
+ if (!first && !*rescan && *(rescan - 2) == gp->gl_delim)
+ {
+ *(rescan - 2) = 0;
+ c = (*gp->gl_type)(gp, prefix);
+ *(rescan - 2) = gp->gl_delim;
+ if (c == GLOB_DIR)
+ addmatch(gp, NiL, prefix, NiL, rescan - 1, anymeta);
+ }
+ else if ((anymeta || !(gp->gl_flags & GLOB_NOCHECK)) && (*gp->gl_type)(gp, prefix))
+ addmatch(gp, NiL, prefix, NiL, NiL, anymeta);
+ return;
+ case '[':
+ if (!bracket)
+ {
+ bracket = MATCH_META;
+ if (*rescan == '!' || *rescan == '^')
+ rescan++;
+ if (*rescan == ']')
+ rescan++;
+ }
+ continue;
+ case ']':
+ meta |= bracket;
+ continue;
+ case '(':
+ if (!(gp->gl_flags & GLOB_AUGMENTED))
+ continue;
+ case '*':
+ case '?':
+ meta = MATCH_META;
+ continue;
+ case '\\':
+ if (!(gp->gl_flags & GLOB_NOESCAPE))
+ {
+ quote = 1;
+ if (*rescan)
+ rescan++;
+ }
+ continue;
+ default:
+ if (c == gp->gl_delim)
+ {
+ if (meta)
+ break;
+ pat = rescan;
+ bracket = 0;
+ savequote = quote;
+ }
+ continue;
+ }
+ break;
+ }
+ anymeta |= meta;
+ if (matchdir)
+ goto skip;
+ if (pat == prefix)
+ {
+ prefix = 0;
+ if (!rescan && (gp->gl_flags & GLOB_COMPLETE))
+ {
+ complete = 1;
+ dirname = 0;
+ }
+ else
+ dirname = ".";
+ }
+ else
+ {
+ if (pat == prefix + 1)
+ dirname = "/";
+ if (savequote)
+ {
+ quote = 0;
+ trim(ap->gl_begin, pat, &t1, rescan, &t2);
+ pat -= t1;
+ if (rescan)
+ rescan -= t2;
+ }
+ *(restore1 = pat - 1) = 0;
+ }
+ if (!complete && (gp->gl_flags & GLOB_STARSTAR))
+ while (pat[0] == '*' && pat[1] == '*' && (pat[2] == '/' || pat[2]==0))
+ {
+ matchdir = pat;
+ if (pat[2])
+ {
+ pat += 3;
+ while (*pat=='/') pat++;
+ if (*pat)
+ continue;
+ }
+ rescan = *pat?0:pat;
+ pat = "*";
+ goto skip;
+ }
+ if (matchdir)
+ {
+ rescan = pat;
+ goto again;
+ }
+skip:
+ if (rescan)
+ *(restore2 = rescan - 1) = 0;
+ if (rescan && !complete && (gp->gl_flags & GLOB_STARSTAR))
+ {
+ register char *p = rescan;
+ while (p[0] == '*' && p[1] == '*' && (p[2] == '/' || p[2]==0))
+ {
+ rescan = p;
+ if (starstar = (p[2]==0))
+ break;
+ p += 3;
+ while (*p=='/')
+ p++;
+ if (*p==0)
+ {
+ starstar = 2;
+ break;
+ }
+ }
+ }
+ if (matchdir)
+ gp->gl_starstar++;
+ if (gp->gl_opt)
+ pat = strcpy(gp->gl_opt, pat);
+ for (;;)
+ {
+ if (complete)
+ {
+ if (!(dirname = (*gp->gl_nextdir)(gp, dirname)))
+ break;
+ prefix = streq(dirname, ".") ? (char*)0 : dirname;
+ }
+ if (dirf = (*gp->gl_diropen)(gp, dirname))
+ {
+ if (!(gp->re_flags & REG_ICASE) && ((*gp->gl_attr)(gp, dirname) & GLOB_ICASE))
+ {
+ if (!prei)
+ {
+ if (err = regcomp(&rei, pat, gp->re_flags|REG_ICASE))
+ break;
+ prei = &rei;
+ }
+ pre = prei;
+ if (gp->gl_ignore)
+ {
+ if (!gp->gl_ignorei)
+ {
+ if (regcomp(&gp->re_ignorei, gp->gl_fignore, gp->re_flags|REG_ICASE))
+ {
+ gp->gl_error = GLOB_APPERR;
+ break;
+ }
+ gp->gl_ignorei = &gp->re_ignorei;
+ }
+ ire = gp->gl_ignorei;
+ }
+ else
+ ire = 0;
+ }
+ else
+ {
+ if (!prec)
+ {
+ if (err = regcomp(&rec, pat, gp->re_flags))
+ break;
+ prec = &rec;
+ }
+ pre = prec;
+ ire = gp->gl_ignore;
+ }
+ if (restore2)
+ *restore2 = gp->gl_delim;
+ while ((name = (*gp->gl_dirnext)(gp, dirf)) && !*gp->gl_intr)
+ {
+ if (notdir = (gp->gl_status & GLOB_NOTDIR))
+ gp->gl_status &= ~GLOB_NOTDIR;
+ if (ire && !regexec(ire, name, 0, NiL, 0))
+ continue;
+ if (matchdir && (name[0] != '.' || name[1] && (name[1] != '.' || name[2])) && !notdir)
+ addmatch(gp, prefix, name, matchdir, NiL, anymeta);
+ if (!regexec(pre, name, 0, NiL, 0))
+ {
+ if (!rescan || !notdir)
+ addmatch(gp, prefix, name, rescan, NiL, anymeta);
+ if (starstar==1 || (starstar==2 && !notdir))
+ addmatch(gp, prefix, name, starstar==2?"":NiL, NiL, anymeta);
+ }
+ errno = 0;
+ }
+ (*gp->gl_dirclose)(gp, dirf);
+ if (err || errno && !errorcheck(gp, dirname))
+ break;
+ }
+ else if (!complete && !errorcheck(gp, dirname))
+ break;
+ if (!complete)
+ break;
+ if (*gp->gl_intr)
+ {
+ gp->gl_error = GLOB_INTR;
+ break;
+ }
+ }
+ if (restore1)
+ *restore1 = gp->gl_delim;
+ if (restore2)
+ *restore2 = gp->gl_delim;
+ if (prec)
+ regfree(prec);
+ if (prei)
+ regfree(prei);
+ if (err == REG_ESPACE)
+ gp->gl_error = GLOB_NOSPACE;
+}
+
+int
+glob(const char* pattern, int flags, int (*errfn)(const char*, int), register glob_t* gp)
+{
+ register globlist_t* ap;
+ register char* pat;
+ globlist_t* top;
+ Stak_t* oldstak;
+ char** argv;
+ char** av;
+ size_t skip;
+ unsigned long f;
+ int n;
+ int x;
+
+ const char* nocheck = pattern;
+ int optlen = 0;
+ int suflen = 0;
+ int extra = 1;
+ unsigned char intr = 0;
+
+ gp->gl_rescan = 0;
+ gp->gl_error = 0;
+ gp->gl_errfn = errfn;
+ if (flags & GLOB_APPEND)
+ {
+ if ((gp->gl_flags |= GLOB_APPEND) ^ (flags|GLOB_MAGIC))
+ return GLOB_APPERR;
+ if (((gp->gl_flags & GLOB_STACK) == 0) == (gp->gl_stak == 0))
+ return GLOB_APPERR;
+ if (gp->gl_starstar > 1)
+ gp->gl_flags |= GLOB_STARSTAR;
+ else
+ gp->gl_starstar = 0;
+ }
+ else
+ {
+ gp->gl_flags = (flags&0xffff)|GLOB_MAGIC;
+ gp->re_flags = REG_SHELL|REG_NOSUB|REG_LEFT|REG_RIGHT|((flags&GLOB_AUGMENTED)?REG_AUGMENTED:0);
+ gp->gl_pathc = 0;
+ gp->gl_ignore = 0;
+ gp->gl_ignorei = 0;
+ gp->gl_starstar = 0;
+ if (!(flags & GLOB_DISC))
+ {
+ gp->gl_fignore = 0;
+ gp->gl_suffix = 0;
+ gp->gl_intr = 0;
+ gp->gl_delim = 0;
+ gp->gl_handle = 0;
+ gp->gl_diropen = 0;
+ gp->gl_dirnext = 0;
+ gp->gl_dirclose = 0;
+ gp->gl_type = 0;
+ gp->gl_attr = 0;
+ gp->gl_nextdir = 0;
+ gp->gl_stat = 0;
+ gp->gl_extra = 0;
+ }
+ if (!(flags & GLOB_ALTDIRFUNC))
+ {
+ gp->gl_opendir = (GL_opendir_f)opendir;
+ gp->gl_readdir = (GL_readdir_f)readdir;
+ gp->gl_closedir = (GL_closedir_f)closedir;
+ if (!gp->gl_stat)
+ gp->gl_stat = (flags & GLOB_STARSTAR) ? (GL_stat_f)lstat : (GL_stat_f)pathstat;
+ }
+ if (!gp->gl_intr)
+ gp->gl_intr = &intr;
+ if (!gp->gl_delim)
+ gp->gl_delim = '/';
+ if (!gp->gl_diropen)
+ gp->gl_diropen = gl_diropen;
+ if (!gp->gl_dirnext)
+ gp->gl_dirnext = gl_dirnext;
+ if (!gp->gl_dirclose)
+ gp->gl_dirclose = gl_dirclose;
+ if (!gp->gl_type)
+ gp->gl_type = gl_type;
+ if (!gp->gl_attr)
+ gp->gl_attr = gl_attr;
+ if (flags & GLOB_ICASE)
+ gp->re_flags |= REG_ICASE;
+ if (!gp->gl_fignore)
+ gp->re_flags |= REG_SHELL_DOT;
+ else if (*gp->gl_fignore)
+ {
+ if (regcomp(&gp->re_ignore, gp->gl_fignore, gp->re_flags))
+ return GLOB_APPERR;
+ gp->gl_ignore = &gp->re_ignore;
+ }
+ if (gp->gl_flags & GLOB_STACK)
+ gp->gl_stak = 0;
+ else if (!(gp->gl_stak = stakcreate(0)))
+ return GLOB_NOSPACE;
+ if ((gp->gl_flags & GLOB_COMPLETE) && !gp->gl_nextdir)
+ gp->gl_nextdir = gl_nextdir;
+ }
+ skip = gp->gl_pathc;
+ if (gp->gl_stak)
+ oldstak = stakinstall(gp->gl_stak, 0);
+ if (flags & GLOB_DOOFFS)
+ extra += gp->gl_offs;
+ if (gp->gl_suffix)
+ suflen = strlen(gp->gl_suffix);
+ if (*(pat = (char*)pattern) == '~' && *(pat + 1) == '(')
+ {
+ f = gp->gl_flags;
+ n = 1;
+ x = 1;
+ pat += 2;
+ for (;;)
+ {
+ switch (*pat++)
+ {
+ case 0:
+ case ':':
+ break;
+ case '-':
+ n = 0;
+ continue;
+ case '+':
+ n = 1;
+ continue;
+ case 'i':
+ if (n)
+ f |= GLOB_ICASE;
+ else
+ f &= ~GLOB_ICASE;
+ continue;
+ case 'M':
+ if (n)
+ f |= GLOB_BRACE;
+ else
+ f &= ~GLOB_BRACE;
+ continue;
+ case 'N':
+ if (n)
+ f &= ~GLOB_NOCHECK;
+ else
+ f |= GLOB_NOCHECK;
+ continue;
+ case 'R':
+ if (n)
+ f |= GLOB_STARSTAR;
+ else
+ f &= ~GLOB_STARSTAR;
+ continue;
+ case ')':
+ flags = (gp->gl_flags = f) & 0xffff;
+ if (f & GLOB_ICASE)
+ gp->re_flags |= REG_ICASE;
+ else
+ gp->re_flags &= ~REG_ICASE;
+ if ((f & (GLOB_STARSTAR|GLOB_ALTDIRFUNC)) == GLOB_STARSTAR)
+ gp->gl_stat = (GL_stat_f)lstat;
+ if (x)
+ optlen = pat - (char*)pattern;
+ break;
+ default:
+ x = 0;
+ continue;
+ }
+ break;
+ }
+ }
+ top = ap = (globlist_t*)stakalloc((optlen ? 2 : 1) * strlen(pattern) + sizeof(globlist_t) + suflen + gp->gl_extra);
+ ap->gl_next = 0;
+ ap->gl_flags = 0;
+ ap->gl_begin = ap->gl_path + gp->gl_extra;
+ pat = strcopy(ap->gl_begin, pattern + optlen);
+ if (suflen)
+ pat = strcopy(pat, gp->gl_suffix);
+ gp->gl_pat = optlen ? strncpy(gp->gl_opt = pat + 1, pattern, optlen) : (char*)0;
+ suflen = 0;
+ if (!(flags & GLOB_LIST))
+ gp->gl_match = 0;
+ do
+ {
+ gp->gl_rescan = ap->gl_next;
+ glob_dir(gp, ap);
+ } while (!gp->gl_error && (ap = gp->gl_rescan));
+ if (gp->gl_pathc == skip)
+ {
+ if (flags & GLOB_NOCHECK)
+ {
+ gp->gl_pathc++;
+ top->gl_next = gp->gl_match;
+ gp->gl_match = top;
+ strcopy(top->gl_path + gp->gl_extra, nocheck);
+ }
+ else
+ gp->gl_error = GLOB_NOMATCH;
+ }
+ if (flags & GLOB_LIST)
+ gp->gl_list = gp->gl_match;
+ else
+ {
+ argv = (char**)stakalloc((gp->gl_pathc + extra) * sizeof(char*));
+ if (gp->gl_flags & GLOB_APPEND)
+ {
+ skip += --extra;
+ memcpy(argv, gp->gl_pathv, skip * sizeof(char*));
+ av = argv + skip;
+ }
+ else
+ {
+ av = argv;
+ while (--extra > 0)
+ *av++ = 0;
+ }
+ gp->gl_pathv = argv;
+ argv = av;
+ ap = gp->gl_match;
+ while (ap)
+ {
+ *argv++ = ap->gl_path + gp->gl_extra;
+ ap = ap->gl_next;
+ }
+ *argv = 0;
+ if (!(flags & GLOB_NOSORT) && (argv - av) > 1)
+ {
+ strsort(av, argv - av, strcoll);
+ if (gp->gl_starstar > 1)
+ av[gp->gl_pathc = struniq(av, argv - av)] = 0;
+ gp->gl_starstar = 0;
+ }
+ }
+ if (gp->gl_starstar > 1)
+ gp->gl_flags &= ~GLOB_STARSTAR;
+ if (gp->gl_stak)
+ stakinstall(oldstak, 0);
+ return gp->gl_error;
+}
+
+void
+globfree(glob_t* gp)
+{
+ if ((gp->gl_flags & GLOB_MAGIC) == GLOB_MAGIC)
+ {
+ gp->gl_flags &= ~GLOB_MAGIC;
+ if (gp->gl_stak)
+ stkclose(gp->gl_stak);
+ if (gp->gl_ignore)
+ regfree(gp->gl_ignore);
+ if (gp->gl_ignorei)
+ regfree(gp->gl_ignorei);
+ }
+}
diff --git a/usr/src/lib/libast/common/misc/liberror.c b/usr/src/lib/libast/common/misc/liberror.c
new file mode 100644
index 0000000000..639d4962c1
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/liberror.c
@@ -0,0 +1,40 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * OBSOLETE: use errormsg()
+ */
+
+#include <error.h>
+
+void
+liberror(const char* lib, int level, ...)
+{
+ va_list ap;
+
+ va_start(ap, level);
+ errorv(lib, level, ap);
+ va_end(ap);
+}
diff --git a/usr/src/lib/libast/common/misc/libevent.c b/usr/src/lib/libast/common/misc/libevent.c
new file mode 100644
index 0000000000..f881615f87
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/libevent.c
@@ -0,0 +1,41 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * OBSOLETE: use errormsg()
+ */
+
+#include <error.h>
+
+int
+libevent(void* handle, void* discipline, int level, ...)
+{
+ va_list ap;
+
+ va_start(ap, level);
+ errorv((level & ERROR_LIBRARY) ? *((char**)handle) : (char*)0, level, ap);
+ va_end(ap);
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/misc/magic.c b/usr/src/lib/libast/common/misc/magic.c
new file mode 100644
index 0000000000..91a9b05e00
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/magic.c
@@ -0,0 +1,2419 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * library interface to file
+ *
+ * the sum of the hacks {s5,v10,planix} is _____ than the parts
+ */
+
+static const char id[] = "\n@(#)$Id: magic library (AT&T Research) 2007-01-08 $\0\n";
+
+static const char lib[] = "libast:magic";
+
+#include <ast.h>
+#include <ctype.h>
+#include <ccode.h>
+#include <dt.h>
+#include <modex.h>
+#include <error.h>
+#include <regex.h>
+#include <swap.h>
+
+#define T(m) (*m?ERROR_translate(NiL,NiL,lib,m):m)
+
+#define match(s,p) strgrpmatch(s,p,NiL,0,STR_LEFT|STR_RIGHT|STR_ICASE)
+
+#define MAXNEST 10 /* { ... } nesting limit */
+#define MINITEM 4 /* magic buffer rounding */
+
+typedef struct /* identifier dictionary entry */
+{
+ const char name[16]; /* identifier name */
+ int value; /* identifier value */
+ Dtlink_t link; /* dictionary link */
+} Info_t;
+
+typedef struct Edit /* edit substitution */
+{
+ struct Edit* next; /* next in list */
+ regex_t* from; /* from pattern */
+} Edit_t;
+
+struct Entry;
+
+typedef struct /* loop info */
+{
+ struct Entry* lab; /* call this function */
+ int start; /* start here */
+ int size; /* increment by this amount */
+ int count; /* dynamic loop count */
+ int offset; /* dynamic offset */
+} Loop_t;
+
+typedef struct Entry /* magic file entry */
+{
+ struct Entry* next; /* next in list */
+ char* expr; /* offset expression */
+ union
+ {
+ unsigned long num;
+ char* str;
+ struct Entry* lab;
+ regex_t* sub;
+ Loop_t* loop;
+ } value; /* comparison value */
+ char* desc; /* file description */
+ char* mime; /* file mime type */
+ unsigned long offset; /* offset in bytes */
+ unsigned long mask; /* mask before compare */
+ char cont; /* continuation operation */
+ char type; /* datum type */
+ char op; /* comparison operation */
+ char nest; /* { or } nesting operation */
+ char swap; /* forced swap order */
+} Entry_t;
+
+#define CC_BIT 5
+
+#if (CC_MAPS*CC_BIT) <= (CHAR_BIT*2)
+typedef unsigned short Cctype_t;
+#else
+typedef unsigned long Cctype_t;
+#endif
+
+#define CC_text 0x01
+#define CC_control 0x02
+#define CC_latin 0x04
+#define CC_binary 0x08
+#define CC_utf_8 0x10
+
+#define CC_notext CC_text /* CC_text is flipped before checking */
+
+#define CC_MASK (CC_binary|CC_latin|CC_control|CC_text)
+
+#define CCTYPE(c) (((c)>0240)?CC_binary:((c)>=0200)?CC_latin:((c)<040&&(c)!=007&&(c)!=011&&(c)!=012&&(c)!=013&&(c)!=015)?CC_control:CC_text)
+
+#define ID_NONE 0
+#define ID_ASM 1
+#define ID_C 2
+#define ID_COBOL 3
+#define ID_COPYBOOK 4
+#define ID_CPLUSPLUS 5
+#define ID_FORTRAN 6
+#define ID_HTML 7
+#define ID_INCL1 8
+#define ID_INCL2 9
+#define ID_INCL3 10
+#define ID_MAM1 11
+#define ID_MAM2 12
+#define ID_MAM3 13
+#define ID_NOTEXT 14
+#define ID_PL1 15
+#define ID_YACC 16
+
+#define ID_MAX ID_YACC
+
+#define INFO_atime 1
+#define INFO_blocks 2
+#define INFO_ctime 3
+#define INFO_fstype 4
+#define INFO_gid 5
+#define INFO_mode 6
+#define INFO_mtime 7
+#define INFO_name 8
+#define INFO_nlink 9
+#define INFO_size 10
+#define INFO_uid 11
+
+#define _MAGIC_PRIVATE_ \
+ Magicdisc_t* disc; /* discipline */ \
+ Vmalloc_t* vm; /* vmalloc region */ \
+ Entry_t* magic; /* parsed magic table */ \
+ Entry_t* magiclast; /* last entry in magic */ \
+ char* mime; /* MIME type */ \
+ unsigned char* x2n; /* CC_ALIEN=>CC_NATIVE */ \
+ char fbuf[SF_BUFSIZE + 1]; /* file data */ \
+ char xbuf[SF_BUFSIZE + 1]; /* indirect file data */ \
+ char nbuf[256]; /* !CC_NATIVE data */ \
+ char mbuf[64]; /* mime string */ \
+ char sbuf[64]; /* type suffix string */ \
+ char tbuf[2 * PATH_MAX]; /* type string */ \
+ Cctype_t cctype[UCHAR_MAX + 1]; /* char code types */ \
+ unsigned int count[UCHAR_MAX + 1]; /* char frequency count */ \
+ unsigned int multi[UCHAR_MAX + 1]; /* muti char count */ \
+ int keep[MAXNEST]; /* ckmagic nest stack */ \
+ char* cap[MAXNEST]; /* ckmagic mime stack */ \
+ char* msg[MAXNEST]; /* ckmagic text stack */ \
+ Entry_t* ret[MAXNEST]; /* ckmagic return stack */ \
+ int fbsz; /* fbuf size */ \
+ int fbmx; /* fbuf max size */ \
+ int xbsz; /* xbuf size */ \
+ int swap; /* swap() operation */ \
+ unsigned long flags; /* disc+open flags */ \
+ long xoff; /* xbuf offset */ \
+ int identifier[ID_MAX + 1]; /* Info_t identifier */ \
+ Sfio_t* fp; /* fbuf fp */ \
+ Sfio_t* tmp; /* tmp string */ \
+ regdisc_t redisc; /* regex discipline */ \
+ Dtdisc_t dtdisc; /* dict discipline */ \
+ Dt_t* idtab; /* identifier dict */ \
+ Dt_t* infotab; /* info keyword dict */
+
+#include <magic.h>
+
+static Info_t dict[] = /* keyword dictionary */
+{
+ { "COMMON", ID_FORTRAN },
+ { "COMPUTE", ID_COBOL },
+ { "COMP", ID_COPYBOOK },
+ { "COMPUTATIONAL",ID_COPYBOOK },
+ { "DCL", ID_PL1 },
+ { "DEFINED", ID_PL1 },
+ { "DIMENSION", ID_FORTRAN },
+ { "DIVISION", ID_COBOL },
+ { "FILLER", ID_COPYBOOK },
+ { "FIXED", ID_PL1 },
+ { "FUNCTION", ID_FORTRAN },
+ { "HTML", ID_HTML },
+ { "INTEGER", ID_FORTRAN },
+ { "MAIN", ID_PL1 },
+ { "OPTIONS", ID_PL1 },
+ { "PERFORM", ID_COBOL },
+ { "PIC", ID_COPYBOOK },
+ { "REAL", ID_FORTRAN },
+ { "REDEFINES", ID_COPYBOOK },
+ { "S9", ID_COPYBOOK },
+ { "SECTION", ID_COBOL },
+ { "SELECT", ID_COBOL },
+ { "SUBROUTINE", ID_FORTRAN },
+ { "TEXT", ID_ASM },
+ { "VALUE", ID_COPYBOOK },
+ { "attr", ID_MAM3 },
+ { "binary", ID_YACC },
+ { "block", ID_FORTRAN },
+ { "bss", ID_ASM },
+ { "byte", ID_ASM },
+ { "char", ID_C },
+ { "class", ID_CPLUSPLUS },
+ { "clr", ID_NOTEXT },
+ { "comm", ID_ASM },
+ { "common", ID_FORTRAN },
+ { "data", ID_ASM },
+ { "dimension", ID_FORTRAN },
+ { "done", ID_MAM2 },
+ { "double", ID_C },
+ { "even", ID_ASM },
+ { "exec", ID_MAM3 },
+ { "extern", ID_C },
+ { "float", ID_C },
+ { "function", ID_FORTRAN },
+ { "globl", ID_ASM },
+ { "h", ID_INCL3 },
+ { "html", ID_HTML },
+ { "include", ID_INCL1 },
+ { "int", ID_C },
+ { "integer", ID_FORTRAN },
+ { "jmp", ID_NOTEXT },
+ { "left", ID_YACC },
+ { "libc", ID_INCL2 },
+ { "long", ID_C },
+ { "make", ID_MAM1 },
+ { "mov", ID_NOTEXT },
+ { "private", ID_CPLUSPLUS },
+ { "public", ID_CPLUSPLUS },
+ { "real", ID_FORTRAN },
+ { "register", ID_C },
+ { "right", ID_YACC },
+ { "sfio", ID_INCL2 },
+ { "static", ID_C },
+ { "stdio", ID_INCL2 },
+ { "struct", ID_C },
+ { "subroutine", ID_FORTRAN },
+ { "sys", ID_NOTEXT },
+ { "term", ID_YACC },
+ { "text", ID_ASM },
+ { "tst", ID_NOTEXT },
+ { "type", ID_YACC },
+ { "typedef", ID_C },
+ { "u", ID_INCL2 },
+ { "union", ID_YACC },
+ { "void", ID_C },
+};
+
+static Info_t info[] =
+{
+ { "atime", INFO_atime },
+ { "blocks", INFO_blocks },
+ { "ctime", INFO_ctime },
+ { "fstype", INFO_fstype },
+ { "gid", INFO_gid },
+ { "mode", INFO_mode },
+ { "mtime", INFO_mtime },
+ { "name", INFO_name },
+ { "nlink", INFO_nlink },
+ { "size", INFO_size },
+ { "uid", INFO_uid },
+};
+
+/*
+ * return pointer to data at offset off and size siz
+ */
+
+static char*
+getdata(register Magic_t* mp, register long off, register int siz)
+{
+ register long n;
+
+ if (off < 0)
+ return 0;
+ if (off + siz <= mp->fbsz)
+ return mp->fbuf + off;
+ if (off < mp->xoff || off + siz > mp->xoff + mp->xbsz)
+ {
+ if (off + siz > mp->fbmx)
+ return 0;
+ n = (off / (SF_BUFSIZE / 2)) * (SF_BUFSIZE / 2);
+ if (sfseek(mp->fp, n, SEEK_SET) != n)
+ return 0;
+ if ((mp->xbsz = sfread(mp->fp, mp->xbuf, sizeof(mp->xbuf) - 1)) < 0)
+ {
+ mp->xoff = 0;
+ mp->xbsz = 0;
+ return 0;
+ }
+ mp->xbuf[mp->xbsz] = 0;
+ mp->xoff = n;
+ if (off + siz > mp->xoff + mp->xbsz)
+ return 0;
+ }
+ return mp->xbuf + off - mp->xoff;
+}
+
+/*
+ * @... evaluator for strexpr()
+ */
+
+static long
+indirect(const char* cs, char** e, void* handle)
+{
+ register char* s = (char*)cs;
+ register Magic_t* mp = (Magic_t*)handle;
+ register long n = 0;
+ register char* p;
+
+ if (s)
+ {
+ if (*s == '@')
+ {
+ n = *++s == '(' ? strexpr(s, e, indirect, mp) : strtol(s, e, 0);
+ switch (*(s = *e))
+ {
+ case 'b':
+ case 'B':
+ s++;
+ if (p = getdata(mp, n, 1))
+ n = *(unsigned char*)p;
+ else
+ s = (char*)cs;
+ break;
+ case 'h':
+ case 'H':
+ s++;
+ if (p = getdata(mp, n, 2))
+ n = swapget(mp->swap, p, 2);
+ else
+ s = (char*)cs;
+ break;
+ case 'q':
+ case 'Q':
+ s++;
+ if (p = getdata(mp, n, 8))
+ n = swapget(mp->swap, p, 8);
+ else
+ s = (char*)cs;
+ break;
+ default:
+ if (isalnum(*s))
+ s++;
+ if (p = getdata(mp, n, 4))
+ n = swapget(mp->swap, p, 4);
+ else
+ s = (char*)cs;
+ break;
+ }
+ }
+ *e = s;
+ }
+ else if ((mp->flags & MAGIC_VERBOSE) && mp->disc->errorf)
+ (*mp->disc->errorf)(mp, mp->disc, 2, "%s in indirect expression", *e);
+ return n;
+}
+
+/*
+ * emit regex error message
+ */
+
+static void
+regmessage(Magic_t* mp, regex_t* re, int code)
+{
+ char buf[128];
+
+ if ((mp->flags & MAGIC_VERBOSE) && mp->disc->errorf)
+ {
+ regerror(code, re, buf, sizeof(buf));
+ (*mp->disc->errorf)(mp, mp->disc, 3, "regex: %s", buf);
+ }
+}
+
+/*
+ * decompose vcodex(3) method composition
+ */
+
+static char*
+vcdecomp(char* b, char* e, unsigned char* m, unsigned char* x)
+{
+ unsigned char* map;
+ int c;
+ int n;
+ int i;
+
+ map = CCMAP(CC_ASCII, CC_NATIVE);
+ i = 1;
+ for (;;)
+ {
+ if (i)
+ i = 0;
+ else
+ *b++ = '^';
+ while (b < e && m < x && (c = *m++))
+ {
+ if (map)
+ c = map[c];
+ *b++ = c;
+ }
+ if (b >= e)
+ break;
+ n = 0;
+ while (m < x)
+ {
+ n = (n<<7) | (*m & 0x7f);
+ if (!(*m++ & 0x80))
+ break;
+ }
+ if (n >= (x - m))
+ break;
+ m += n;
+ }
+ return b;
+}
+
+/*
+ * check for magic table match in buf
+ */
+
+static char*
+ckmagic(register Magic_t* mp, const char* file, char* buf, struct stat* st, unsigned long off)
+{
+ register Entry_t* ep;
+ register char* p;
+ register char* b;
+ register int level = 0;
+ int call = -1;
+ int c;
+ char* q;
+ char* t;
+ char* base = 0;
+ unsigned long num;
+ unsigned long mask;
+ regmatch_t matches[10];
+
+ mp->swap = 0;
+ b = mp->msg[0] = buf;
+ mp->mime = mp->cap[0] = 0;
+ mp->keep[0] = 0;
+ for (ep = mp->magic; ep; ep = ep->next)
+ {
+ fun:
+ if (ep->nest == '{')
+ {
+ if (++level >= MAXNEST)
+ {
+ call = -1;
+ level = 0;
+ mp->keep[0] = 0;
+ b = mp->msg[0];
+ mp->mime = mp->cap[0];
+ continue;
+ }
+ mp->keep[level] = mp->keep[level - 1] != 0;
+ mp->msg[level] = b;
+ mp->cap[level] = mp->mime;
+ }
+ switch (ep->cont)
+ {
+ case '#':
+ if (mp->keep[level] && b > buf)
+ {
+ *b = 0;
+ return buf;
+ }
+ mp->swap = 0;
+ b = mp->msg[0] = buf;
+ mp->mime = mp->cap[0] = 0;
+ if (ep->type == ' ')
+ continue;
+ break;
+ case '$':
+ if (mp->keep[level] && call < (MAXNEST - 1))
+ {
+ mp->ret[++call] = ep;
+ ep = ep->value.lab;
+ goto fun;
+ }
+ continue;
+ case ':':
+ ep = mp->ret[call--];
+ if (ep->op == 'l')
+ goto fun;
+ continue;
+ case '|':
+ if (mp->keep[level] > 1)
+ goto checknest;
+ /*FALLTHROUGH*/
+ default:
+ if (!mp->keep[level])
+ {
+ b = mp->msg[level];
+ mp->mime = mp->cap[level];
+ goto checknest;
+ }
+ break;
+ }
+ if (!ep->expr)
+ num = ep->offset + off;
+ else
+ switch (ep->offset)
+ {
+ case 0:
+ num = strexpr(ep->expr, NiL, indirect, mp) + off;
+ break;
+ case INFO_atime:
+ num = st->st_atime;
+ ep->type = 'D';
+ break;
+ case INFO_blocks:
+ num = iblocks(st);
+ ep->type = 'N';
+ break;
+ case INFO_ctime:
+ num = st->st_ctime;
+ ep->type = 'D';
+ break;
+ case INFO_fstype:
+ p = fmtfs(st);
+ ep->type = toupper(ep->type);
+ break;
+ case INFO_gid:
+ if (ep->type == 'e' || ep->type == 'm' || ep->type == 's')
+ {
+ p = fmtgid(st->st_gid);
+ ep->type = toupper(ep->type);
+ }
+ else
+ {
+ num = st->st_gid;
+ ep->type = 'N';
+ }
+ break;
+ case INFO_mode:
+ if (ep->type == 'e' || ep->type == 'm' || ep->type == 's')
+ {
+ p = fmtmode(st->st_mode, 0);
+ ep->type = toupper(ep->type);
+ }
+ else
+ {
+ num = modex(st->st_mode);
+ ep->type = 'N';
+ }
+ break;
+ case INFO_mtime:
+ num = st->st_ctime;
+ ep->type = 'D';
+ break;
+ case INFO_name:
+ if (!base)
+ {
+ if (base = strrchr(file, '/'))
+ base++;
+ else
+ base = (char*)file;
+ }
+ p = base;
+ ep->type = toupper(ep->type);
+ break;
+ case INFO_nlink:
+ num = st->st_nlink;
+ ep->type = 'N';
+ break;
+ case INFO_size:
+ num = st->st_size;
+ ep->type = 'N';
+ break;
+ case INFO_uid:
+ if (ep->type == 'e' || ep->type == 'm' || ep->type == 's')
+ {
+ p = fmtuid(st->st_uid);
+ ep->type = toupper(ep->type);
+ }
+ else
+ {
+ num = st->st_uid;
+ ep->type = 'N';
+ }
+ break;
+ }
+ switch (ep->type)
+ {
+
+ case 'b':
+ if (!(p = getdata(mp, num, 1)))
+ goto next;
+ num = *(unsigned char*)p;
+ break;
+
+ case 'h':
+ if (!(p = getdata(mp, num, 2)))
+ goto next;
+ num = swapget(ep->swap ? (~ep->swap ^ mp->swap) : mp->swap, p, 2);
+ break;
+
+ case 'd':
+ case 'l':
+ case 'v':
+ if (!(p = getdata(mp, num, 4)))
+ goto next;
+ num = swapget(ep->swap ? (~ep->swap ^ mp->swap) : mp->swap, p, 4);
+ break;
+
+ case 'q':
+ if (!(p = getdata(mp, num, 8)))
+ goto next;
+ num = swapget(ep->swap ? (~ep->swap ^ mp->swap) : mp->swap, p, 8);
+ break;
+
+ case 'e':
+ if (!(p = getdata(mp, num, 0)))
+ goto next;
+ /*FALLTHROUGH*/
+ case 'E':
+ if (!ep->value.sub)
+ goto next;
+ if ((c = regexec(ep->value.sub, p, elementsof(matches), matches, 0)) || (c = regsubexec(ep->value.sub, p, elementsof(matches), matches)))
+ {
+ c = mp->fbsz;
+ if (c >= sizeof(mp->nbuf))
+ c = sizeof(mp->nbuf) - 1;
+ p = (char*)memcpy(mp->nbuf, p, c);
+ p[c] = 0;
+ ccmapstr(mp->x2n, p, c);
+ if ((c = regexec(ep->value.sub, p, elementsof(matches), matches, 0)) || (c = regsubexec(ep->value.sub, p, elementsof(matches), matches)))
+ {
+ if (c != REG_NOMATCH)
+ regmessage(mp, ep->value.sub, c);
+ goto next;
+ }
+ }
+ p = ep->value.sub->re_sub->re_buf;
+ q = T(ep->desc);
+ t = *q ? q : p;
+ if (mp->keep[level]++ && b > buf && *(b - 1) != ' ' && *t && *t != ',' && *t != '.' && *t != '\b')
+ *b++ = ' ';
+ b += sfsprintf(b, PATH_MAX - (b - buf), *q ? q : "%s", p + (*p == '\b'));
+ if (ep->mime)
+ mp->mime = ep->mime;
+ goto checknest;
+
+ case 's':
+ if (!(p = getdata(mp, num, ep->mask)))
+ goto next;
+ goto checkstr;
+ case 'm':
+ if (!(p = getdata(mp, num, 0)))
+ goto next;
+ /*FALLTHROUGH*/
+ case 'M':
+ case 'S':
+ checkstr:
+ for (;;)
+ {
+ if (*ep->value.str == '*' && !*(ep->value.str + 1) && isprint(*p))
+ break;
+ if ((ep->type == 'm' || ep->type == 'M') ? strmatch(p, ep->value.str) : !memcmp(p, ep->value.str, ep->mask))
+ break;
+ if (p == mp->nbuf || ep->mask >= sizeof(mp->nbuf))
+ goto next;
+ p = (char*)memcpy(mp->nbuf, p, ep->mask);
+ p[ep->mask] = 0;
+ ccmapstr(mp->x2n, p, ep->mask);
+ }
+ q = T(ep->desc);
+ if (mp->keep[level]++ && b > buf && *(b - 1) != ' ' && *q && *q != ',' && *q != '.' && *q != '\b')
+ *b++ = ' ';
+ for (t = p; (c = *t) >= 0 && c <= 0177 && isprint(c) && c != '\n'; t++);
+ *t = 0;
+ b += sfsprintf(b, PATH_MAX - (b - buf), q + (*q == '\b'), p);
+ *t = c;
+ if (ep->mime)
+ mp->mime = ep->mime;
+ goto checknest;
+
+ }
+ if (mask = ep->mask)
+ num &= mask;
+ switch (ep->op)
+ {
+
+ case '=':
+ case '@':
+ if (num == ep->value.num)
+ break;
+ if (ep->cont != '#')
+ goto next;
+ if (!mask)
+ mask = ~mask;
+ if (ep->type == 'h')
+ {
+ if ((num = swapget(mp->swap = 1, p, 2) & mask) == ep->value.num)
+ {
+ if (!(mp->swap & (mp->swap + 1)))
+ mp->swap = 7;
+ goto swapped;
+ }
+ }
+ else if (ep->type == 'l')
+ {
+ for (c = 1; c < 4; c++)
+ if ((num = swapget(mp->swap = c, p, 4) & mask) == ep->value.num)
+ {
+ if (!(mp->swap & (mp->swap + 1)))
+ mp->swap = 7;
+ goto swapped;
+ }
+ }
+ else if (ep->type == 'q')
+ {
+ for (c = 1; c < 8; c++)
+ if ((num = swapget(mp->swap = c, p, 8) & mask) == ep->value.num)
+ goto swapped;
+ }
+ goto next;
+
+ case '!':
+ if (num != ep->value.num)
+ break;
+ goto next;
+
+ case '^':
+ if (num ^ ep->value.num)
+ break;
+ goto next;
+
+ case '>':
+ if (num > ep->value.num)
+ break;
+ goto next;
+
+ case '<':
+ if (num < ep->value.num)
+ break;
+ goto next;
+
+ case 'l':
+ if (num > 0 && mp->keep[level] && call < (MAXNEST - 1))
+ {
+ if (!ep->value.loop->count)
+ {
+ ep->value.loop->count = num;
+ ep->value.loop->offset = off;
+ off = ep->value.loop->start;
+ }
+ else if (!--ep->value.loop->count)
+ {
+ off = ep->value.loop->offset;
+ goto next;
+ }
+ else
+ off += ep->value.loop->size;
+ mp->ret[++call] = ep;
+ ep = ep->value.loop->lab;
+ goto fun;
+ }
+ goto next;
+
+ case 'm':
+ c = mp->swap;
+ t = ckmagic(mp, file, b + (b > buf), st, num);
+ mp->swap = c;
+ if (!t)
+ goto next;
+ if (b > buf)
+ *b = ' ';
+ b += strlen(b);
+ break;
+
+ case 'r':
+#if _UWIN
+ {
+ char* e;
+ Sfio_t* rp;
+ Sfio_t* gp;
+
+ if (!(t = strrchr(file, '.')))
+ goto next;
+ sfprintf(mp->tmp, "/reg/classes_root/%s", t);
+ if (!(t = sfstruse(mp->tmp)) || !(rp = sfopen(NiL, t, "r")))
+ goto next;
+ *ep->desc = 0;
+ *ep->mime = 0;
+ gp = 0;
+ while (t = sfgetr(rp, '\n', 1))
+ {
+ if (strneq(t, "Content Type=", 13))
+ {
+ ep->mime = vmnewof(mp->vm, ep->mime, char, sfvalue(rp), 0);
+ strcpy(ep->mime, t + 13);
+ if (gp)
+ break;
+ }
+ else
+ {
+ sfprintf(mp->tmp, "/reg/classes_root/%s", t);
+ if ((e = sfstruse(mp->tmp)) && (gp = sfopen(NiL, e, "r")))
+ {
+ ep->desc = vmnewof(mp->vm, ep->desc, char, strlen(t), 1);
+ strcpy(ep->desc, t);
+ if (*ep->mime)
+ break;
+ }
+ }
+ }
+ sfclose(rp);
+ if (!gp)
+ goto next;
+ if (!*ep->mime)
+ {
+ t = T(ep->desc);
+ if (!strncasecmp(t, "microsoft", 9))
+ t += 9;
+ while (isspace(*t))
+ t++;
+ e = "application/x-ms-";
+ ep->mime = vmnewof(mp->vm, ep->mime, char, strlen(t), strlen(e));
+ e = strcopy(ep->mime, e);
+ while ((c = *t++) && c != '.' && c != ' ')
+ *e++ = isupper(c) ? tolower(c) : c;
+ *e = 0;
+ }
+ while (t = sfgetr(gp, '\n', 1))
+ if (*t && !streq(t, "\"\""))
+ {
+ ep->desc = vmnewof(mp->vm, ep->desc, char, sfvalue(gp), 0);
+ strcpy(ep->desc, t);
+ break;
+ }
+ sfclose(gp);
+ if (!*ep->desc)
+ goto next;
+ if (!t)
+ for (t = T(ep->desc); *t; t++)
+ if (*t == '.')
+ *t = ' ';
+ if (!mp->keep[level])
+ mp->keep[level] = 2;
+ mp->mime = ep->mime;
+ break;
+ }
+#else
+ if (ep->cont == '#' && !mp->keep[level])
+ mp->keep[level] = 1;
+ goto next;
+#endif
+
+ case 'v':
+ if (!(p = getdata(mp, num, 4)))
+ goto next;
+ c = 0;
+ do
+ {
+ num++;
+ c = (c<<7) | (*p & 0x7f);
+ } while (*p++ & 0x80);
+ if (!(p = getdata(mp, num, c)))
+ goto next;
+ if (mp->keep[level]++ && b > buf && *(b - 1) != ' ')
+ {
+ *b++ = ',';
+ *b++ = ' ';
+ }
+ b = vcdecomp(b, buf + PATH_MAX, (unsigned char*)p, (unsigned char*)p + c);
+ goto checknest;
+
+ }
+ swapped:
+ q = T(ep->desc);
+ if (mp->keep[level]++ && b > buf && *(b - 1) != ' ' && *q && *q != ',' && *q != '.' && *q != '\b')
+ *b++ = ' ';
+ if (ep->type == 'd' || ep->type == 'D')
+ b += sfsprintf(b, PATH_MAX - (b - buf), q + (*q == '\b'), fmttime("%?%l", (time_t)num));
+ else if (ep->type == 'v')
+ b += sfsprintf(b, PATH_MAX - (b - buf), q + (*q == '\b'), fmtversion(num));
+ else
+ b += sfsprintf(b, PATH_MAX - (b - buf), q + (*q == '\b'), num);
+ if (ep->mime && *ep->mime)
+ mp->mime = ep->mime;
+ checknest:
+ if (ep->nest == '}')
+ {
+ if (!mp->keep[level])
+ {
+ b = mp->msg[level];
+ mp->mime = mp->cap[level];
+ }
+ else if (level > 0)
+ mp->keep[level - 1] = mp->keep[level];
+ if (--level < 0)
+ {
+ level = 0;
+ mp->keep[0] = 0;
+ }
+ }
+ continue;
+ next:
+ if (ep->cont == '&')
+ mp->keep[level] = 0;
+ goto checknest;
+ }
+ if (mp->keep[level] && b > buf)
+ {
+ *b = 0;
+ return buf;
+ }
+ return 0;
+}
+
+/*
+ * check english language stats
+ */
+
+static int
+ckenglish(register Magic_t* mp, int pun, int badpun)
+{
+ register char* s;
+ register int vowl = 0;
+ register int freq = 0;
+ register int rare = 0;
+
+ if (5 * badpun > pun)
+ return 0;
+ if (2 * mp->count[';'] > mp->count['E'] + mp->count['e'])
+ return 0;
+ if ((mp->count['>'] + mp->count['<'] + mp->count['/']) > mp->count['E'] + mp->count['e'])
+ return 0;
+ for (s = "aeiou"; *s; s++)
+ vowl += mp->count[toupper(*s)] + mp->count[*s];
+ for (s = "etaion"; *s; s++)
+ freq += mp->count[toupper(*s)] + mp->count[*s];
+ for (s = "vjkqxz"; *s; s++)
+ rare += mp->count[toupper(*s)] + mp->count[*s];
+ return 5 * vowl >= mp->fbsz - mp->count[' '] && freq >= 10 * rare;
+}
+
+/*
+ * check programming language stats
+ */
+
+static char*
+cklang(register Magic_t* mp, const char* file, char* buf, struct stat* st)
+{
+ register int c;
+ register unsigned char* b;
+ register unsigned char* e;
+ register int q;
+ register char* s;
+ char* t;
+ char* base;
+ char* suff;
+ char* t1;
+ char* t2;
+ char* t3;
+ int n;
+ int badpun;
+ int code;
+ int pun;
+ Cctype_t flags;
+ Info_t* ip;
+
+ b = (unsigned char*)mp->fbuf;
+ e = b + mp->fbsz;
+ memzero(mp->count, sizeof(mp->count));
+ memzero(mp->multi, sizeof(mp->multi));
+ memzero(mp->identifier, sizeof(mp->identifier));
+
+ /*
+ * check character coding
+ */
+
+ flags = 0;
+ while (b < e)
+ flags |= mp->cctype[*b++];
+ b = (unsigned char*)mp->fbuf;
+ code = 0;
+ q = CC_ASCII;
+ n = CC_MASK;
+ for (c = 0; c < CC_MAPS; c++)
+ {
+ flags ^= CC_text;
+ if ((flags & CC_MASK) < n)
+ {
+ n = flags & CC_MASK;
+ q = c;
+ }
+ flags >>= CC_BIT;
+ }
+ flags = n;
+ if (!(flags & (CC_binary|CC_notext)))
+ {
+ if (q != CC_NATIVE)
+ {
+ code = q;
+ ccmaps(mp->fbuf, mp->fbsz, q, CC_NATIVE);
+ }
+ if (b[0] == '#' && b[1] == '!')
+ {
+ for (b += 2; b < e && isspace(*b); b++);
+ for (s = (char*)b; b < e && isprint(*b); b++);
+ c = *b;
+ *b = 0;
+ if ((st->st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) || match(s, "/*bin*/*") || !access(s, F_OK))
+ {
+ if (t = strrchr(s, '/'))
+ s = t + 1;
+ for (t = s; *t; t++)
+ if (isspace(*t))
+ {
+ *t = 0;
+ break;
+ }
+ sfsprintf(mp->mbuf, sizeof(mp->mbuf), "application/x-%s", *s ? s : "sh");
+ mp->mime = mp->mbuf;
+ if (match(s, "*sh"))
+ {
+ t1 = T("command");
+ if (streq(s, "sh"))
+ *s = 0;
+ else
+ {
+ *b++ = ' ';
+ *b = 0;
+ }
+ }
+ else
+ {
+ t1 = T("interpreter");
+ *b++ = ' ';
+ *b = 0;
+ }
+ sfsprintf(mp->sbuf, sizeof(mp->sbuf), T("%s%s script"), s, t1);
+ s = mp->sbuf;
+ goto qualify;
+ }
+ *b = c;
+ b = (unsigned char*)mp->fbuf;
+ }
+ badpun = 0;
+ pun = 0;
+ q = 0;
+ s = 0;
+ t = 0;
+ while (b < e)
+ {
+ c = *b++;
+ mp->count[c]++;
+ if (c == q && (q != '*' || *b == '/' && b++))
+ {
+ mp->multi[q]++;
+ q = 0;
+ }
+ else if (c == '\\')
+ {
+ s = 0;
+ b++;
+ }
+ else if (!q)
+ {
+ if (isalpha(c) || c == '_')
+ {
+ if (!s)
+ s = (char*)b - 1;
+ }
+ else if (!isdigit(c))
+ {
+ if (s)
+ {
+ if (s > mp->fbuf)
+ switch (*(s - 1))
+ {
+ case ':':
+ if (*b == ':')
+ mp->multi[':']++;
+ break;
+ case '.':
+ if (((char*)b - s) == 3 && (s == (mp->fbuf + 1) || *(s - 2) == '\n'))
+ mp->multi['.']++;
+ break;
+ case '\n':
+ case '\\':
+ if (*b == '{')
+ t = (char*)b + 1;
+ break;
+ case '{':
+ if (s == t && *b == '}')
+ mp->multi['X']++;
+ break;
+ }
+ if (!mp->idtab)
+ {
+ if (mp->idtab = dtnew(mp->vm, &mp->dtdisc, Dthash))
+ for (q = 0; q < elementsof(dict); q++)
+ dtinsert(mp->idtab, &dict[q]);
+ else if (mp->disc->errorf)
+ (*mp->disc->errorf)(mp, mp->disc, 3, "out of space");
+ q = 0;
+ }
+ if (mp->idtab)
+ {
+ *(b - 1) = 0;
+ if (ip = (Info_t*)dtmatch(mp->idtab, s))
+ mp->identifier[ip->value]++;
+ *(b - 1) = c;
+ }
+ s = 0;
+ }
+ switch (c)
+ {
+ case '\t':
+ if (b == (unsigned char*)(mp->fbuf + 1) || *(b - 2) == '\n')
+ mp->multi['\t']++;
+ break;
+ case '"':
+ case '\'':
+ q = c;
+ break;
+ case '/':
+ if (*b == '*')
+ q = *b++;
+ else if (*b == '/')
+ q = '\n';
+ break;
+ case '$':
+ if (*b == '(' && *(b + 1) != ' ')
+ mp->multi['$']++;
+ break;
+ case '{':
+ case '}':
+ case '[':
+ case ']':
+ case '(':
+ mp->multi[c]++;
+ break;
+ case ')':
+ mp->multi[c]++;
+ goto punctuation;
+ case ':':
+ if (*b == ':' && isspace(*(b + 1)) && b > (unsigned char*)(mp->fbuf + 1) && isspace(*(b - 2)))
+ mp->multi[':']++;
+ goto punctuation;
+ case '.':
+ case ',':
+ case '%':
+ case ';':
+ case '?':
+ punctuation:
+ pun++;
+ if (*b != ' ' && *b != '\n')
+ badpun++;
+ break;
+ }
+ }
+ }
+ }
+ }
+ else
+ while (b < e)
+ mp->count[*b++]++;
+ base = (t1 = strrchr(file, '/')) ? t1 + 1 : (char*)file;
+ suff = (t1 = strrchr(base, '.')) ? t1 + 1 : "";
+ if (!flags)
+ {
+ if (match(suff, "*sh|bat|cmd"))
+ goto id_sh;
+ if (match(base, "*@(mkfile)"))
+ goto id_mk;
+ if (match(base, "*@(makefile|.mk)"))
+ goto id_make;
+ if (match(base, "*@(mamfile|.mam)"))
+ goto id_mam;
+ if (match(suff, "[cly]?(pp|xx|++)|cc|ll|yy"))
+ goto id_c;
+ if (match(suff, "f"))
+ goto id_fortran;
+ if (match(suff, "htm+(l)"))
+ goto id_html;
+ if (match(suff, "cpy"))
+ goto id_copybook;
+ if (match(suff, "cob|cbl|cb2"))
+ goto id_cobol;
+ if (match(suff, "pl[1i]"))
+ goto id_pl1;
+ if (match(suff, "tex"))
+ goto id_tex;
+ if (match(suff, "asm|s"))
+ goto id_asm;
+ if ((st->st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) && (!suff || suff != strchr(suff, '.')))
+ {
+ id_sh:
+ s = T("command script");
+ mp->mime = "application/sh";
+ goto qualify;
+ }
+ if (strmatch(mp->fbuf, "From * [0-9][0-9]:[0-9][0-9]:[0-9][0-9] *"))
+ {
+ s = T("mail message");
+ mp->mime = "message/rfc822";
+ goto qualify;
+ }
+ if (match(base, "*@(mkfile)"))
+ {
+ id_mk:
+ s = "mkfile";
+ mp->mime = "application/mk";
+ goto qualify;
+ }
+ if (match(base, "*@(makefile|.mk)") || mp->multi['\t'] >= mp->count[':'] && (mp->multi['$'] > 0 || mp->multi[':'] > 0))
+ {
+ id_make:
+ s = "makefile";
+ mp->mime = "application/make";
+ goto qualify;
+ }
+ if (mp->multi['.'] >= 3)
+ {
+ s = T("nroff input");
+ mp->mime = "application/x-troff";
+ goto qualify;
+ }
+ if (mp->multi['X'] >= 3)
+ {
+ s = T("TeX input");
+ mp->mime = "application/x-tex";
+ goto qualify;
+ }
+ if (mp->fbsz < SF_BUFSIZE &&
+ (mp->multi['('] == mp->multi[')'] &&
+ mp->multi['{'] == mp->multi['}'] &&
+ mp->multi['['] == mp->multi[']']) ||
+ mp->fbsz >= SF_BUFSIZE &&
+ (mp->multi['('] >= mp->multi[')'] &&
+ mp->multi['{'] >= mp->multi['}'] &&
+ mp->multi['['] >= mp->multi[']']))
+ {
+ c = mp->identifier[ID_INCL1];
+ if (c >= 2 && mp->identifier[ID_INCL2] >= c && mp->identifier[ID_INCL3] >= c && mp->count['.'] >= c ||
+ mp->identifier[ID_C] >= 5 && mp->count[';'] >= 5 ||
+ mp->count['='] >= 20 && mp->count[';'] >= 20)
+ {
+ id_c:
+ t1 = "";
+ t2 = "c ";
+ t3 = T("program");
+ switch (*suff)
+ {
+ case 'c':
+ case 'C':
+ mp->mime = "application/x-cc";
+ break;
+ case 'l':
+ case 'L':
+ t1 = "lex ";
+ mp->mime = "application/x-lex";
+ break;
+ default:
+ t3 = T("header");
+ if (mp->identifier[ID_YACC] < 5 || mp->count['%'] < 5)
+ {
+ mp->mime = "application/x-cc";
+ break;
+ }
+ /*FALLTHROUGH*/
+ case 'y':
+ case 'Y':
+ t1 = "yacc ";
+ mp->mime = "application/x-yacc";
+ break;
+ }
+ if (mp->identifier[ID_CPLUSPLUS] >= 3)
+ {
+ t2 = "c++ ";
+ mp->mime = "application/x-c++";
+ }
+ sfsprintf(mp->sbuf, sizeof(mp->sbuf), "%s%s%s", t1, t2, t3);
+ s = mp->sbuf;
+ goto qualify;
+ }
+ }
+ if (mp->identifier[ID_MAM1] >= 2 && mp->identifier[ID_MAM3] >= 2 &&
+ (mp->fbsz < SF_BUFSIZE && mp->identifier[ID_MAM1] == mp->identifier[ID_MAM2] ||
+ mp->fbsz >= SF_BUFSIZE && mp->identifier[ID_MAM1] >= mp->identifier[ID_MAM2]))
+ {
+ id_mam:
+ s = T("mam program");
+ mp->mime = "application/x-mam";
+ goto qualify;
+ }
+ if (mp->identifier[ID_FORTRAN] >= 8)
+ {
+ id_fortran:
+ s = T("fortran program");
+ mp->mime = "application/x-fortran";
+ goto qualify;
+ }
+ if (mp->identifier[ID_HTML] > 0 && mp->count['<'] >= 8 && (c = mp->count['<'] - mp->count['>']) >= -2 && c <= 2)
+ {
+ id_html:
+ s = T("html input");
+ mp->mime = "text/html";
+ goto qualify;
+ }
+ if (mp->identifier[ID_COPYBOOK] > 0 && mp->identifier[ID_COBOL] == 0 && (c = mp->count['('] - mp->count[')']) >= -2 && c <= 2)
+ {
+ id_copybook:
+ s = T("cobol copybook");
+ mp->mime = "application/x-cobol";
+ goto qualify;
+ }
+ if (mp->identifier[ID_COBOL] > 0 && mp->identifier[ID_COPYBOOK] > 0 && (c = mp->count['('] - mp->count[')']) >= -2 && c <= 2)
+ {
+ id_cobol:
+ s = T("cobol program");
+ mp->mime = "application/x-cobol";
+ goto qualify;
+ }
+ if (mp->identifier[ID_PL1] > 0 && (c = mp->count['('] - mp->count[')']) >= -2 && c <= 2)
+ {
+ id_pl1:
+ s = T("pl1 program");
+ mp->mime = "application/x-pl1";
+ goto qualify;
+ }
+ if (mp->count['{'] >= 6 && (c = mp->count['{'] - mp->count['}']) >= -2 && c <= 2 && mp->count['\\'] >= mp->count['{'])
+ {
+ id_tex:
+ s = T("TeX input");
+ mp->mime = "text/tex";
+ goto qualify;
+ }
+ if (mp->identifier[ID_ASM] >= 4)
+ {
+ id_asm:
+ s = T("as program");
+ mp->mime = "application/x-as";
+ goto qualify;
+ }
+ if (ckenglish(mp, pun, badpun))
+ {
+ s = T("english text");
+ mp->mime = "text/plain";
+ goto qualify;
+ }
+ }
+ else if (streq(base, "core"))
+ {
+ mp->mime = "x-system/core";
+ return T("core dump");
+ }
+ if (flags & (CC_binary|CC_notext))
+ {
+ b = (unsigned char*)mp->fbuf;
+ e = b + mp->fbsz;
+ n = 0;
+ for (;;)
+ {
+ c = *b++;
+ q = 0;
+ while (c & 0x80)
+ {
+ c <<= 1;
+ q++;
+ }
+ switch (q)
+ {
+ case 4:
+ if (b < e && (*b++ & 0xc0) != 0x80)
+ break;
+ case 3:
+ if (b < e && (*b++ & 0xc0) != 0x80)
+ break;
+ case 2:
+ if (b < e && (*b++ & 0xc0) != 0x80)
+ break;
+ n = 1;
+ case 0:
+ if (b >= e)
+ {
+ if (n)
+ {
+ flags &= ~(CC_binary|CC_notext);
+ flags |= CC_utf_8;
+ }
+ break;
+ }
+ continue;
+ }
+ break;
+ }
+ }
+ if (flags & (CC_binary|CC_notext))
+ {
+ unsigned long d = 0;
+
+ if ((q = mp->fbsz / UCHAR_MAX) >= 2)
+ {
+ /*
+ * compression/encryption via standard deviation
+ */
+
+
+ for (c = 0; c < UCHAR_MAX; c++)
+ {
+ pun = mp->count[c] - q;
+ d += pun * pun;
+ }
+ d /= mp->fbsz;
+ }
+ if (d <= 0)
+ s = T("binary");
+ else if (d < 4)
+ s = T("encrypted");
+ else if (d < 16)
+ s = T("packed");
+ else if (d < 64)
+ s = T("compressed");
+ else if (d < 256)
+ s = T("delta");
+ else
+ s = T("data");
+ mp->mime = "application/octet-stream";
+ return s;
+ }
+ mp->mime = "text/plain";
+ if (flags & CC_utf_8)
+ s = (flags & CC_control) ? T("utf-8 text with control characters") : T("utf-8 text");
+ else if (flags & CC_latin)
+ s = (flags & CC_control) ? T("latin text with control characters") : T("latin text");
+ else
+ s = (flags & CC_control) ? T("text with control characters") : T("text");
+ qualify:
+ if (!flags && mp->count['\n'] >= mp->count['\r'] && mp->count['\n'] <= (mp->count['\r'] + 1) && mp->count['\r'])
+ {
+ t = "dos ";
+ mp->mime = "text/dos";
+ }
+ else
+ t = "";
+ if (code)
+ {
+ if (code == CC_ASCII)
+ sfsprintf(buf, PATH_MAX, "ascii %s%s", t, s);
+ else
+ {
+ sfsprintf(buf, PATH_MAX, "ebcdic%d %s%s", code - 1, t, s);
+ mp->mime = "text/ebcdic";
+ }
+ s = buf;
+ }
+ else if (*t)
+ {
+ sfsprintf(buf, PATH_MAX, "%s%s", t, s);
+ s = buf;
+ }
+ return s;
+}
+
+/*
+ * return the basic magic string for file,st in buf,size
+ */
+
+static char*
+type(register Magic_t* mp, const char* file, struct stat* st, char* buf, int size)
+{
+ register char* s;
+ register char* t;
+
+ mp->mime = 0;
+ if (!S_ISREG(st->st_mode))
+ {
+ if (S_ISDIR(st->st_mode))
+ {
+ mp->mime = "x-system/dir";
+ return T("directory");
+ }
+ if (S_ISLNK(st->st_mode))
+ {
+ mp->mime = "x-system/lnk";
+ s = buf;
+ s += sfsprintf(s, PATH_MAX, T("symbolic link to "));
+ if (pathgetlink(file, s, size - (s - buf)) < 0)
+ return T("cannot read symbolic link text");
+ return buf;
+ }
+ if (S_ISBLK(st->st_mode))
+ {
+ mp->mime = "x-system/blk";
+ sfsprintf(buf, PATH_MAX, T("block special (%s)"), fmtdev(st));
+ return buf;
+ }
+ if (S_ISCHR(st->st_mode))
+ {
+ mp->mime = "x-system/chr";
+ sfsprintf(buf, PATH_MAX, T("character special (%s)"), fmtdev(st));
+ return buf;
+ }
+ if (S_ISFIFO(st->st_mode))
+ {
+ mp->mime = "x-system/fifo";
+ return "fifo";
+ }
+#ifdef S_ISSOCK
+ if (S_ISSOCK(st->st_mode))
+ {
+ mp->mime = "x-system/sock";
+ return "socket";
+ }
+#endif
+ }
+ if (!(mp->fbmx = st->st_size))
+ s = T("empty");
+ else if (!mp->fp)
+ s = T("cannot read");
+ else
+ {
+ mp->fbsz = sfread(mp->fp, mp->fbuf, sizeof(mp->fbuf) - 1);
+ if (mp->fbsz < 0)
+ s = fmterror(errno);
+ else if (mp->fbsz == 0)
+ s = T("empty");
+ else
+ {
+ mp->fbuf[mp->fbsz] = 0;
+ mp->xoff = 0;
+ mp->xbsz = 0;
+ if (!(s = ckmagic(mp, file, buf, st, 0)))
+ s = cklang(mp, file, buf, st);
+ }
+ }
+ if (!mp->mime)
+ mp->mime = "application/unknown";
+ else if ((t = strchr(mp->mime, '%')) && *(t + 1) == 's' && !*(t + 2))
+ {
+ register char* b;
+ register char* be;
+ register char* m;
+ register char* me;
+
+ b = mp->mime;
+ me = (m = mp->mime = mp->fbuf) + sizeof(mp->fbuf) - 1;
+ while (m < me && b < t)
+ *m++ = *b++;
+ b = t = s;
+ for (;;)
+ {
+ if (!(be = strchr(t, ' ')))
+ {
+ be = b + strlen(b);
+ break;
+ }
+ if (*(be - 1) == ',' || strneq(be + 1, "data", 4) || strneq(be + 1, "file", 4))
+ break;
+ b = t;
+ t = be + 1;
+ }
+ while (m < me && b < be)
+ if ((*m++ = *b++) == ' ')
+ *(m - 1) = '-';
+ *m = 0;
+ }
+ return s;
+}
+
+/*
+ * low level for magicload()
+ */
+
+static int
+load(register Magic_t* mp, char* file, register Sfio_t* fp)
+{
+ register Entry_t* ep;
+ register char* p;
+ register char* p2;
+ char* p3;
+ char* next;
+ int n;
+ int lge;
+ int lev;
+ int ent;
+ int old;
+ int cont;
+ Info_t* ip;
+ Entry_t* ret;
+ Entry_t* first;
+ Entry_t* last = 0;
+ Entry_t* fun['z' - 'a' + 1];
+
+ memzero(fun, sizeof(fun));
+ cont = '$';
+ ent = 0;
+ lev = 0;
+ old = 0;
+ ret = 0;
+ error_info.file = file;
+ error_info.line = 0;
+ first = ep = vmnewof(mp->vm, 0, Entry_t, 1, 0);
+ while (p = sfgetr(fp, '\n', 1))
+ {
+ error_info.line++;
+ for (; isspace(*p); p++);
+
+ /*
+ * nesting
+ */
+
+ switch (*p)
+ {
+ case 0:
+ case '#':
+ cont = '#';
+ continue;
+ case '{':
+ if (++lev < MAXNEST)
+ ep->nest = *p;
+ else if ((mp->flags & MAGIC_VERBOSE) && mp->disc->errorf)
+ (*mp->disc->errorf)(mp, mp->disc, 1, "{ ... } operator nesting too deep -- %d max", MAXNEST);
+ continue;
+ case '}':
+ if (!last || lev <= 0)
+ {
+ if (mp->disc->errorf)
+ (*mp->disc->errorf)(mp, mp->disc, 2, "`%c': invalid nesting", *p);
+ }
+ else if (lev-- == ent)
+ {
+ ent = 0;
+ ep->cont = ':';
+ ep->offset = ret->offset;
+ ep->nest = ' ';
+ ep->type = ' ';
+ ep->op = ' ';
+ ep->desc = "[RETURN]";
+ last = ep;
+ ep = ret->next = vmnewof(mp->vm, 0, Entry_t, 1, 0);
+ ret = 0;
+ }
+ else
+ last->nest = *p;
+ continue;
+ default:
+ if (*(p + 1) == '{' || *(p + 1) == '(' && *p != '+' && *p != '>' && *p != '&' && *p != '|')
+ {
+ n = *p++;
+ if (n >= 'a' && n <= 'z')
+ n -= 'a';
+ else
+ {
+ if (mp->disc->errorf)
+ (*mp->disc->errorf)(mp, mp->disc, 2, "%c: invalid function name", n);
+ n = 0;
+ }
+ if (ret && mp->disc->errorf)
+ (*mp->disc->errorf)(mp, mp->disc, 2, "%c: function has no return", ret->offset + 'a');
+ if (*p == '{')
+ {
+ ent = ++lev;
+ ret = ep;
+ ep->desc = "[FUNCTION]";
+ }
+ else
+ {
+ if (*(p + 1) != ')' && mp->disc->errorf)
+ (*mp->disc->errorf)(mp, mp->disc, 2, "%c: invalid function call argument list", n + 'a');
+ ep->desc = "[CALL]";
+ }
+ ep->cont = cont;
+ ep->offset = n;
+ ep->nest = ' ';
+ ep->type = ' ';
+ ep->op = ' ';
+ last = ep;
+ ep = ep->next = vmnewof(mp->vm, 0, Entry_t, 1, 0);
+ if (ret)
+ fun[n] = last->value.lab = ep;
+ else if (!(last->value.lab = fun[n]) && mp->disc->errorf)
+ (*mp->disc->errorf)(mp, mp->disc, 2, "%c: function not defined", n + 'a');
+ continue;
+ }
+ if (!ep->nest)
+ ep->nest = (lev > 0 && lev != ent) ? ('0' + lev - !!ent) : ' ';
+ break;
+ }
+
+ /*
+ * continuation
+ */
+
+ cont = '$';
+ switch (*p)
+ {
+ case '>':
+ old = 1;
+ if (*(p + 1) == *p)
+ {
+ /*
+ * old style nesting push
+ */
+
+ p++;
+ old = 2;
+ if (!lev && last)
+ {
+ lev = 1;
+ last->nest = '{';
+ if (last->cont == '>')
+ last->cont = '&';
+ ep->nest = '1';
+ }
+ }
+ /*FALLTHROUGH*/
+ case '+':
+ case '&':
+ case '|':
+ ep->cont = *p++;
+ break;
+ default:
+ if ((mp->flags & MAGIC_VERBOSE) && !isalpha(*p) && mp->disc->errorf)
+ (*mp->disc->errorf)(mp, mp->disc, 1, "`%c': invalid line continuation operator", *p);
+ /*FALLTHROUGH*/
+ case '*':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ ep->cont = (lev > 0) ? '&' : '#';
+ break;
+ }
+ switch (old)
+ {
+ case 1:
+ old = 0;
+ if (lev)
+ {
+ /*
+ * old style nesting pop
+ */
+
+ lev = 0;
+ if (last)
+ last->nest = '}';
+ ep->nest = ' ';
+ if (ep->cont == '&')
+ ep->cont = '#';
+ }
+ break;
+ case 2:
+ old = 1;
+ break;
+ }
+ if (isdigit(*p))
+ {
+ /*
+ * absolute offset
+ */
+
+ ep->offset = strton(p, &next, NiL, 0);
+ p2 = next;
+ }
+ else
+ {
+ for (p2 = p; *p2 && !isspace(*p2); p2++);
+ if (!*p2)
+ {
+ if ((mp->flags & MAGIC_VERBOSE) && mp->disc->errorf)
+ (*mp->disc->errorf)(mp, mp->disc, 1, "not enough fields: `%s'", p);
+ continue;
+ }
+
+ /*
+ * offset expression
+ */
+
+ *p2++ = 0;
+ ep->expr = vmstrdup(mp->vm, p);
+ if (isalpha(*p))
+ ep->offset = (ip = (Info_t*)dtmatch(mp->infotab, p)) ? ip->value : 0;
+ else if (*p == '(' && ep->cont == '>')
+ {
+ /*
+ * convert old style indirection to @
+ */
+
+ p = ep->expr + 1;
+ for (;;)
+ {
+ switch (*p++)
+ {
+ case 0:
+ case '@':
+ case '(':
+ break;
+ case ')':
+ break;
+ default:
+ continue;
+ }
+ break;
+ }
+ if (*--p == ')')
+ {
+ *p = 0;
+ *ep->expr = '@';
+ }
+ }
+ }
+ for (; isspace(*p2); p2++);
+ for (p = p2; *p2 && !isspace(*p2); p2++);
+ if (!*p2)
+ {
+ if ((mp->flags & MAGIC_VERBOSE) && mp->disc->errorf)
+ (*mp->disc->errorf)(mp, mp->disc, 1, "not enough fields: `%s'", p);
+ continue;
+ }
+ *p2++ = 0;
+
+ /*
+ * type
+ */
+
+ if ((*p == 'b' || *p == 'l') && *(p + 1) == 'e')
+ {
+ ep->swap = ~(*p == 'l' ? 7 : 0);
+ p += 2;
+ }
+ if (*p == 's')
+ {
+ if (*(p + 1) == 'h')
+ ep->type = 'h';
+ else
+ ep->type = 's';
+ }
+ else if (*p == 'a')
+ ep->type = 's';
+ else
+ ep->type = *p;
+ if (p = strchr(p, '&'))
+ {
+ /*
+ * old style mask
+ */
+
+ ep->mask = strton(++p, NiL, NiL, 0);
+ }
+ for (; isspace(*p2); p2++);
+ if (ep->mask)
+ *--p2 = '=';
+
+ /*
+ * comparison operation
+ */
+
+ p = p2;
+ if (p2 = strchr(p, '\t'))
+ *p2++ = 0;
+ else
+ {
+ int qe = 0;
+ int qn = 0;
+
+ /*
+ * assume balanced {}[]()\\""'' field
+ */
+
+ for (p2 = p;;)
+ {
+ switch (n = *p2++)
+ {
+ case 0:
+ break;
+ case '{':
+ if (!qe)
+ qe = '}';
+ if (qe == '}')
+ qn++;
+ continue;
+ case '(':
+ if (!qe)
+ qe = ')';
+ if (qe == ')')
+ qn++;
+ continue;
+ case '[':
+ if (!qe)
+ qe = ']';
+ if (qe == ']')
+ qn++;
+ continue;
+ case '}':
+ case ')':
+ case ']':
+ if (qe == n && qn > 0)
+ qn--;
+ continue;
+ case '"':
+ case '\'':
+ if (!qe)
+ qe = n;
+ else if (qe == n)
+ qe = 0;
+ continue;
+ case '\\':
+ if (*p2)
+ p2++;
+ continue;
+ default:
+ if (!qe && isspace(n))
+ break;
+ continue;
+ }
+ if (n)
+ *(p2 - 1) = 0;
+ else
+ p2--;
+ break;
+ }
+ }
+ lge = 0;
+ if (ep->type == 'e' || ep->type == 'm' || ep->type == 's')
+ ep->op = '=';
+ else
+ {
+ if (*p == '&')
+ {
+ ep->mask = strton(++p, &next, NiL, 0);
+ p = next;
+ }
+ switch (*p)
+ {
+ case '=':
+ case '>':
+ case '<':
+ case '*':
+ ep->op = *p++;
+ if (*p == '=')
+ {
+ p++;
+ switch (ep->op)
+ {
+ case '>':
+ lge = -1;
+ break;
+ case '<':
+ lge = 1;
+ break;
+ }
+ }
+ break;
+ case '!':
+ case '@':
+ ep->op = *p++;
+ if (*p == '=')
+ p++;
+ break;
+ case 'x':
+ p++;
+ ep->op = '*';
+ break;
+ default:
+ ep->op = '=';
+ if (ep->mask)
+ ep->value.num = ep->mask;
+ break;
+ }
+ }
+ if (ep->op != '*' && !ep->value.num)
+ {
+ if (ep->type == 'e')
+ {
+ if (ep->value.sub = vmnewof(mp->vm, 0, regex_t, 1, 0))
+ {
+ ep->value.sub->re_disc = &mp->redisc;
+ if (!(n = regcomp(ep->value.sub, p, REG_DELIMITED|REG_LENIENT|REG_NULL|REG_DISCIPLINE)))
+ {
+ p += ep->value.sub->re_npat;
+ if (!(n = regsubcomp(ep->value.sub, p, NiL, 0, 0)))
+ p += ep->value.sub->re_npat;
+ }
+ if (n)
+ {
+ regmessage(mp, ep->value.sub, n);
+ ep->value.sub = 0;
+ }
+ else if (*p && mp->disc->errorf)
+ (*mp->disc->errorf)(mp, mp->disc, 1, "invalid characters after substitution: %s", p);
+ }
+ }
+ else if (ep->type == 'm')
+ {
+ ep->mask = stresc(p) + 1;
+ ep->value.str = vmnewof(mp->vm, 0, char, ep->mask + 1, 0);
+ memcpy(ep->value.str, p, ep->mask);
+ if ((!ep->expr || !ep->offset) && !strmatch(ep->value.str, "\\!\\(*\\)"))
+ ep->value.str[ep->mask - 1] = '*';
+ }
+ else if (ep->type == 's')
+ {
+ ep->mask = stresc(p);
+ ep->value.str = vmnewof(mp->vm, 0, char, ep->mask, 0);
+ memcpy(ep->value.str, p, ep->mask);
+ }
+ else if (*p == '\'')
+ {
+ stresc(p);
+ ep->value.num = *(unsigned char*)(p + 1) + lge;
+ }
+ else if (strmatch(p, "+([a-z])\\(*\\)"))
+ {
+ char* t;
+
+ t = p;
+ ep->type = 'V';
+ ep->op = *p;
+ while (*p && *p++ != '(');
+ switch (ep->op)
+ {
+ case 'l':
+ n = *p++;
+ if (n < 'a' || n > 'z')
+ {
+ if (mp->disc->errorf)
+ (*mp->disc->errorf)(mp, mp->disc, 2, "%c: invalid function name", n);
+ }
+ else if (!fun[n -= 'a'])
+ {
+ if (mp->disc->errorf)
+ (*mp->disc->errorf)(mp, mp->disc, 2, "%c: function not defined", n + 'a');
+ }
+ else
+ {
+ ep->value.loop = vmnewof(mp->vm, 0, Loop_t, 1, 0);
+ ep->value.loop->lab = fun[n];
+ while (*p && *p++ != ',');
+ ep->value.loop->start = strton(p, &t, NiL, 0);
+ while (*t && *t++ != ',');
+ ep->value.loop->size = strton(t, &t, NiL, 0);
+ }
+ break;
+ case 'm':
+ case 'r':
+ ep->desc = vmnewof(mp->vm, 0, char, 32, 0);
+ ep->mime = vmnewof(mp->vm, 0, char, 32, 0);
+ break;
+ case 'v':
+ break;
+ default:
+ if ((mp->flags & MAGIC_VERBOSE) && mp->disc->errorf)
+ (*mp->disc->errorf)(mp, mp->disc, 1, "%-.*s: unknown function", p - t, t);
+ break;
+ }
+ }
+ else
+ {
+ ep->value.num = strton(p, NiL, NiL, 0) + lge;
+ if (ep->op == '@')
+ ep->value.num = swapget(0, (char*)&ep->value.num, sizeof(ep->value.num));
+ }
+ }
+
+ /*
+ * file description
+ */
+
+ if (p2)
+ {
+ for (; isspace(*p2); p2++);
+ if (p = strchr(p2, '\t'))
+ {
+ /*
+ * check for message catalog index
+ */
+
+ *p++ = 0;
+ if (isalpha(*p2))
+ {
+ for (p3 = p2; isalnum(*p3); p3++);
+ if (*p3++ == ':')
+ {
+ for (; isdigit(*p3); p3++);
+ if (!*p3)
+ {
+ for (p2 = p; isspace(*p2); p2++);
+ if (p = strchr(p2, '\t'))
+ *p++ = 0;
+ }
+ }
+ }
+ }
+ stresc(p2);
+ ep->desc = vmstrdup(mp->vm, p2);
+ if (p)
+ {
+ for (; isspace(*p); p++);
+ if (*p)
+ ep->mime = vmstrdup(mp->vm, p);
+ }
+ }
+ else
+ ep->desc = "";
+
+ /*
+ * get next entry
+ */
+
+ last = ep;
+ ep = ep->next = vmnewof(mp->vm, 0, Entry_t, 1, 0);
+ }
+ if (last)
+ {
+ last->next = 0;
+ if (mp->magiclast)
+ mp->magiclast->next = first;
+ else
+ mp->magic = first;
+ mp->magiclast = last;
+ }
+ vmfree(mp->vm, ep);
+ if ((mp->flags & MAGIC_VERBOSE) && mp->disc->errorf)
+ {
+ if (lev < 0)
+ (*mp->disc->errorf)(mp, mp->disc, 1, "too many } operators");
+ else if (lev > 0)
+ (*mp->disc->errorf)(mp, mp->disc, 1, "not enough } operators");
+ if (ret)
+ (*mp->disc->errorf)(mp, mp->disc, 2, "%c: function has no return", ret->offset + 'a');
+ }
+ error_info.file = 0;
+ error_info.line = 0;
+ return 0;
+}
+
+/*
+ * load a magic file into mp
+ */
+
+int
+magicload(register Magic_t* mp, const char* file, unsigned long flags)
+{
+ register char* s;
+ register char* e;
+ register char* t;
+ int n;
+ int found;
+ int list;
+ Sfio_t* fp;
+
+ mp->flags = mp->disc->flags | flags;
+ found = 0;
+ if (list = !(s = (char*)file) || !*s || (*s == '-' || *s == '.') && !*(s + 1))
+ {
+ if (!(s = getenv(MAGIC_FILE_ENV)) || !*s)
+ s = MAGIC_FILE;
+ }
+ for (;;)
+ {
+ if (!list)
+ e = 0;
+ else if (e = strchr(s, ':'))
+ {
+ /*
+ * ok, so ~ won't work for the last list element
+ * we do it for MAGIC_FILES_ENV anyway
+ */
+
+ if ((strneq(s, "~/", n = 2) || strneq(s, "$HOME/", n = 6) || strneq(s, "${HOME}/", n = 8)) && (t = getenv("HOME")))
+ {
+ sfputr(mp->tmp, t, -1);
+ s += n - 1;
+ }
+ sfwrite(mp->tmp, s, e - s);
+ if (!(s = sfstruse(mp->tmp)))
+ goto nospace;
+ }
+ if (!*s || streq(s, "-"))
+ s = MAGIC_FILE;
+ if (!(fp = sfopen(NiL, s, "r")))
+ {
+ if (list)
+ {
+ if (!(t = pathpath(mp->fbuf, s, "", PATH_REGULAR|PATH_READ)) && !strchr(s, '/'))
+ {
+ strcpy(mp->fbuf, s);
+ sfprintf(mp->tmp, "%s/%s", MAGIC_DIR, mp->fbuf);
+ if (!(s = sfstruse(mp->tmp)))
+ goto nospace;
+ if (!(t = pathpath(mp->fbuf, s, "", PATH_REGULAR|PATH_READ)))
+ goto next;
+ }
+ if (!(fp = sfopen(NiL, t, "r")))
+ goto next;
+ }
+ else
+ {
+ if (mp->disc->errorf)
+ (*mp->disc->errorf)(mp, mp->disc, 3, "%s: cannot open magic file", s);
+ return -1;
+ }
+ }
+ found = 1;
+ n = load(mp, s, fp);
+ sfclose(fp);
+ if (n && !list)
+ return -1;
+ next:
+ if (!e)
+ break;
+ s = e + 1;
+ }
+ if (!found)
+ {
+ if (mp->flags & MAGIC_VERBOSE)
+ {
+ if (mp->disc->errorf)
+ (*mp->disc->errorf)(mp, mp->disc, 2, "cannot find magic file");
+ }
+ return -1;
+ }
+ return 0;
+ nospace:
+ if (mp->disc->errorf)
+ (*mp->disc->errorf)(mp, mp->disc, 3, "out of space");
+ return -1;
+}
+
+/*
+ * open a magic session
+ */
+
+Magic_t*
+magicopen(Magicdisc_t* disc)
+{
+ register Magic_t* mp;
+ register int i;
+ register int n;
+ register int f;
+ register int c;
+ register Vmalloc_t* vm;
+ unsigned char* map[CC_MAPS + 1];
+
+ if (!(vm = vmopen(Vmdcheap, Vmbest, 0)))
+ return 0;
+ if (!(mp = vmnewof(vm, 0, Magic_t, 1, 0)))
+ {
+ vmclose(vm);
+ return 0;
+ }
+ mp->id = lib;
+ mp->disc = disc;
+ mp->vm = vm;
+ mp->flags = disc->flags;
+ mp->redisc.re_version = REG_VERSION;
+ mp->redisc.re_flags = REG_NOFREE;
+ mp->redisc.re_errorf = (regerror_t)disc->errorf;
+ mp->redisc.re_resizef = (regresize_t)vmgetmem;
+ mp->redisc.re_resizehandle = (void*)mp->vm;
+ mp->dtdisc.key = offsetof(Info_t, name);
+ mp->dtdisc.link = offsetof(Info_t, link);
+ if (!(mp->tmp = sfstropen()) || !(mp->infotab = dtnew(mp->vm, &mp->dtdisc, Dthash)))
+ goto bad;
+ for (n = 0; n < elementsof(info); n++)
+ dtinsert(mp->infotab, &info[n]);
+ for (i = 0; i < CC_MAPS; i++)
+ map[i] = ccmap(i, CC_ASCII);
+ mp->x2n = ccmap(CC_ALIEN, CC_NATIVE);
+ for (n = 0; n <= UCHAR_MAX; n++)
+ {
+ f = 0;
+ i = CC_MAPS;
+ while (--i >= 0)
+ {
+ c = ccmapchr(map[i], n);
+ f = (f << CC_BIT) | CCTYPE(c);
+ }
+ mp->cctype[n] = f;
+ }
+ return mp;
+ bad:
+ magicclose(mp);
+ return 0;
+}
+
+/*
+ * close a magicopen() session
+ */
+
+int
+magicclose(register Magic_t* mp)
+{
+ if (!mp)
+ return -1;
+ if (mp->tmp)
+ sfstrclose(mp->tmp);
+ if (mp->vm)
+ vmclose(mp->vm);
+ return 0;
+}
+
+/*
+ * return the magic string for file with optional stat info st
+ */
+
+char*
+magictype(register Magic_t* mp, Sfio_t* fp, const char* file, register struct stat* st)
+{
+ off_t off;
+ char* s;
+
+ mp->flags = mp->disc->flags;
+ mp->mime = 0;
+ if (!st)
+ s = T("cannot stat");
+ else
+ {
+ if (mp->fp = fp)
+ off = sfseek(mp->fp, (off_t)0, SEEK_CUR);
+ s = type(mp, file, st, mp->tbuf, sizeof(mp->tbuf));
+ if (mp->fp)
+ sfseek(mp->fp, off, SEEK_SET);
+ if (!(mp->flags & MAGIC_MIME))
+ {
+ if (S_ISREG(st->st_mode) && (st->st_size > 0) && (st->st_size < 128))
+ sfprintf(mp->tmp, "%s ", T("short"));
+ sfprintf(mp->tmp, "%s", s);
+ if (!mp->fp && (st->st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)))
+ sfprintf(mp->tmp, ", %s", S_ISDIR(st->st_mode) ? T("searchable") : T("executable"));
+ if (st->st_mode & S_ISUID)
+ sfprintf(mp->tmp, ", setuid=%s", fmtuid(st->st_uid));
+ if (st->st_mode & S_ISGID)
+ sfprintf(mp->tmp, ", setgid=%s", fmtgid(st->st_gid));
+ if (st->st_mode & S_ISVTX)
+ sfprintf(mp->tmp, ", sticky");
+ if (!(s = sfstruse(mp->tmp)))
+ s = T("out of space");
+ }
+ }
+ if (mp->flags & MAGIC_MIME)
+ s = mp->mime;
+ if (!s)
+ s = T("error");
+ return s;
+}
+
+/*
+ * list the magic table in mp on sp
+ */
+
+int
+magiclist(register Magic_t* mp, register Sfio_t* sp)
+{
+ register Entry_t* ep = mp->magic;
+ register Entry_t* rp = 0;
+
+ mp->flags = mp->disc->flags;
+ sfprintf(sp, "cont\toffset\ttype\top\tmask\tvalue\tmime\tdesc\n");
+ while (ep)
+ {
+ sfprintf(sp, "%c %c\t", ep->cont, ep->nest);
+ if (ep->expr)
+ sfprintf(sp, "%s", ep->expr);
+ else
+ sfprintf(sp, "%ld", ep->offset);
+ sfprintf(sp, "\t%s%c\t%c\t%lo\t", ep->swap == (char)~3 ? "L" : ep->swap == (char)~0 ? "B" : "", ep->type, ep->op, ep->mask);
+ switch (ep->type)
+ {
+ case 'm':
+ case 's':
+ sfputr(sp, fmtesc(ep->value.str), -1);
+ break;
+ case 'V':
+ switch (ep->op)
+ {
+ case 'l':
+ sfprintf(sp, "loop(%d,%d,%d,%d)", ep->value.loop->start, ep->value.loop->size, ep->value.loop->count, ep->value.loop->offset);
+ break;
+ case 'v':
+ sfprintf(sp, "vcodex()");
+ break;
+ default:
+ sfprintf(sp, "%p", ep->value.str);
+ break;
+ }
+ break;
+ default:
+ sfprintf(sp, "%lo", ep->value.num);
+ break;
+ }
+ sfprintf(sp, "\t%s\t%s\n", ep->mime ? ep->mime : "", fmtesc(ep->desc));
+ if (ep->cont == '$' && !ep->value.lab->mask)
+ {
+ rp = ep;
+ ep = ep->value.lab;
+ }
+ else
+ {
+ if (ep->cont == ':')
+ {
+ ep = rp;
+ ep->value.lab->mask = 1;
+ }
+ ep = ep->next;
+ }
+ }
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/misc/mime.c b/usr/src/lib/libast/common/misc/mime.c
new file mode 100644
index 0000000000..82064d7925
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/mime.c
@@ -0,0 +1,807 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * mime/mailcap support library
+ */
+
+static const char id[] = "\n@(#)$Id: mime library (AT&T Research) 2002-10-29 $\0\n";
+
+static const char lib[] = "libast:mime";
+
+#include "mimelib.h"
+
+typedef struct Att_s
+{
+ struct Att_s* next;
+ char* name;
+ char* value;
+} Att_t;
+
+typedef struct Cap_s
+{
+ struct Cap_s* next;
+ unsigned long flags;
+ Att_t att;
+ char* test;
+ char data[1];
+} Cap_t;
+
+typedef struct
+{
+ Dtlink_t link;
+ Cap_t* cap;
+ Cap_t* pac;
+ char name[1];
+} Ent_t;
+
+typedef struct
+{
+ char* data;
+ int size;
+} String_t;
+
+typedef struct
+{
+ char* next;
+ String_t name;
+ String_t value;
+} Parse_t;
+
+typedef struct
+{
+ const char* pattern;
+ int prefix;
+ Sfio_t* fp;
+ int hit;
+} Walk_t;
+
+/*
+ * convert c to lower case
+ */
+
+static int
+lower(register int c)
+{
+ return isupper(c) ? tolower(c) : c;
+}
+
+/*
+ * Ent_t case insensitive comparf
+ */
+
+static int
+order(Dt_t* dt, void* a, void* b, Dtdisc_t* disc)
+{
+ return strcasecmp(a, b);
+}
+
+/*
+ * Cap_t free
+ */
+
+static void
+dropcap(register Cap_t* cap)
+{
+ register Att_t* att;
+
+ while (att = cap->att.next)
+ {
+ cap->att.next = att->next;
+ free(att);
+ }
+ free(cap);
+}
+
+/*
+ * Ent_t freef
+ */
+
+static void
+drop(Dt_t* dt, void* object, Dtdisc_t* disc)
+{
+ register Ent_t* ent = (Ent_t*)object;
+ register Cap_t* cap;
+
+ while (cap = ent->cap)
+ {
+ ent->cap = cap->next;
+ dropcap(cap);
+ }
+ free(ent);
+}
+
+/*
+ * add mime type entry in s to mp
+ */
+
+int
+mimeset(Mime_t* mp, register char* s, unsigned long flags)
+{
+ register Ent_t* ent;
+ register Cap_t* cap;
+ register Att_t* att;
+ register char* t;
+ register char* v;
+ register char* k;
+ char* x;
+ Att_t* tta;
+ int q;
+
+ for (; isspace(*s); s++);
+ if (*s && *s != '#')
+ {
+ cap = 0;
+ for (v = s; *v && *v != ';'; v++)
+ if (isspace(*v) || *v == '/' && *(v + 1) == '*')
+ *v = 0;
+ if (*v)
+ {
+ *v++ = 0;
+ do
+ {
+ for (; isspace(*v); v++);
+ if (cap)
+ {
+ for (t = v; *t && !isspace(*t) && *t != '='; t++);
+ for (k = t; isspace(*t); t++);
+ if (!*t || *t == '=' || *t == ';')
+ {
+ if (*t)
+ while (isspace(*++t));
+ *k = 0;
+ k = v;
+ v = t;
+ }
+ else
+ k = 0;
+ }
+ if (*v == '"')
+ q = *v++;
+ else
+ q = 0;
+ for (t = v; *t; t++)
+ if (*t == '\\')
+ {
+ switch (*(t + 1))
+ {
+ case 0:
+ case '\\':
+ case '%':
+ *t = *(t + 1);
+ break;
+ default:
+ *t = ' ';
+ break;
+ }
+ if (!*++t)
+ break;
+ }
+ else if (*t == q)
+ {
+ *t = ' ';
+ q = 0;
+ }
+ else if (*t == ';' && !q)
+ {
+ *t = ' ';
+ break;
+ }
+ for (; t > v && isspace(*(t - 1)); t--);
+ if (t <= v && (!cap || !k))
+ break;
+ if (!cap)
+ {
+ if (!(cap = newof(0, Cap_t, 1, strlen(v) + 1)))
+ return -1;
+ if (*t)
+ *t++ = 0;
+ tta = &cap->att;
+ tta->name = "default";
+ x = strcopy(tta->value = cap->data, v) + 1;
+ }
+ else if (k)
+ {
+ if (*t)
+ *t++ = 0;
+ if (!(att = newof(0, Att_t, 1, 0)))
+ return -1;
+ x = strcopy(att->name = x, k) + 1;
+ x = strcopy(att->value = x, v) + 1;
+ tta = tta->next = att;
+ if (!strcasecmp(k, "test"))
+ cap->test = att->value;
+ }
+ } while (*(v = t));
+ }
+ ent = (Ent_t*)dtmatch(mp->cap, s);
+ if (cap)
+ {
+ if (ent)
+ {
+ register Cap_t* dup;
+ register Cap_t* pud;
+
+ for (pud = 0, dup = ent->cap; dup; pud = dup, dup = dup->next)
+ if (!cap->test && !dup->test || cap->test && dup->test && streq(cap->test, dup->test))
+ {
+ if (flags & MIME_REPLACE)
+ {
+ if (pud)
+ pud->next = cap;
+ else
+ ent->cap = cap;
+ if (!(cap->next = dup->next))
+ ent->pac = cap;
+ cap = dup;
+ }
+ dropcap(cap);
+ return 0;
+ }
+ ent->pac = ent->pac->next = cap;
+ }
+ else if (!(ent = newof(0, Ent_t, 1, strlen(s) + 1)))
+ return -1;
+ else
+ {
+ strcpy(ent->name, s);
+ ent->cap = ent->pac = cap;
+ dtinsert(mp->cap, ent);
+ }
+ }
+ else if (ent && (flags & MIME_REPLACE))
+ dtdelete(mp->cap, ent);
+ }
+ return 0;
+}
+
+/*
+ * load mime type files into mp
+ */
+
+int
+mimeload(Mime_t* mp, const char* file, unsigned long flags)
+{
+ register char* s;
+ register char* t;
+ register char* e;
+ register int n;
+ Sfio_t* fp;
+
+ if (!(s = (char*)file))
+ {
+ flags |= MIME_LIST;
+ if (!(s = getenv(MIME_FILES_ENV)))
+ s = MIME_FILES;
+ }
+ for (;;)
+ {
+ if (!(flags & MIME_LIST))
+ e = 0;
+ else if (e = strchr(s, ':'))
+ {
+ /*
+ * ok, so ~ won't work for the last list element
+ * we do it for MIME_FILES_ENV anyway
+ */
+
+ if ((strneq(s, "~/", n = 2) || strneq(s, "$HOME/", n = 6) || strneq(s, "${HOME}/", n = 8)) && (t = getenv("HOME")))
+ {
+ sfputr(mp->buf, t, -1);
+ s += n - 1;
+ }
+ sfwrite(mp->buf, s, e - s);
+ if (!(s = sfstruse(mp->buf)))
+ return -1;
+ }
+ if (fp = tokline(s, SF_READ, NiL))
+ {
+ while (t = sfgetr(fp, '\n', 1))
+ if (mimeset(mp, t, flags))
+ break;
+ sfclose(fp);
+ }
+ else if (!(flags & MIME_LIST))
+ return -1;
+ if (!e)
+ break;
+ s = e + 1;
+ }
+ return 0;
+}
+
+/*
+ * mimelist walker
+ */
+
+static int
+list(Dt_t* dt, void* object, void* context)
+{
+ register Walk_t* wp = (Walk_t*)context;
+ register Ent_t* ent = (Ent_t*)object;
+ register Cap_t* cap;
+ register Att_t* att;
+
+ if (!wp->pattern || !strncasecmp(ent->name, wp->pattern, wp->prefix) && (!ent->name[wp->prefix] || ent->name[wp->prefix] == '/'))
+ {
+ wp->hit++;
+ for (cap = ent->cap; cap; cap = cap->next)
+ {
+ sfprintf(wp->fp, "%s", ent->name);
+ for (att = &cap->att; att; att = att->next)
+ {
+ sfprintf(wp->fp, "\n\t");
+ if (att != &cap->att)
+ {
+ sfprintf(wp->fp, "%s", att->name);
+ if (*att->value)
+ sfprintf(wp->fp, " = ");
+ }
+ sfputr(wp->fp, att->value, -1);
+ }
+ sfprintf(wp->fp, "\n");
+ }
+ }
+ return 0;
+}
+
+/*
+ * find entry matching type
+ * if exact match fails then left and right x- and right version number
+ * permutations are attempted
+ */
+
+static Ent_t*
+find(Mime_t* mp, const char* type)
+{
+ register char* lp;
+ register char* rp;
+ register char* rb;
+ register char* rv;
+ register int rc;
+ register int i;
+ char* s;
+ Ent_t* ent;
+ char buf[256];
+
+ static const char* prefix[] = { "", "", "x-", "x-", "" };
+
+ if ((ent = (Ent_t*)dtmatch(mp->cap, type)) ||
+ !(rp = strchr(lp = (char*)type, '/')) ||
+ strlen(lp) >= sizeof(buf))
+ return ent;
+ strcpy(buf, type);
+ rp = buf + (rp - lp);
+ *rp++ = 0;
+ if (*rp == 'x' && *(rp + 1) == '-')
+ rp += 2;
+ lp = buf;
+ if (*lp == 'x' && *(lp + 1) == '-')
+ lp += 2;
+ rb = rp;
+ for (rv = rp + strlen(rp); rv > rp && (isdigit(*(rv - 1)) || *(rv - 1) == '.'); rv--);
+ rc = *rv;
+ do
+ {
+ rp = rb;
+ do
+ {
+ for (i = 0; i < elementsof(prefix) - 1; i++)
+ {
+ sfprintf(mp->buf, "%s%s/%s%s", prefix[i], lp, prefix[i + 1], rp);
+ if (!(s = sfstruse(mp->buf)))
+ return 0;
+ if (ent = (Ent_t*)dtmatch(mp->cap, s))
+ return ent;
+ if (rc)
+ {
+ *rv = 0;
+ sfprintf(mp->buf, "%s%s/%s%s", prefix[i], lp, prefix[i + 1], rp);
+ if (!(s = sfstruse(mp->buf)))
+ return 0;
+ if (ent = (Ent_t*)dtmatch(mp->cap, s))
+ return ent;
+ *rv = rc;
+ }
+ }
+ while (*rp && *rp++ != '-');
+ } while (*rp);
+ while (*lp && *lp++ != '-');
+ } while (*lp);
+ return (Ent_t*)dtmatch(mp->cap, buf);
+}
+
+/*
+ * list mime <type,data> for pat on fp
+ */
+
+int
+mimelist(Mime_t* mp, Sfio_t* fp, register const char* pattern)
+{
+ Ent_t* ent;
+ Walk_t ws;
+
+ ws.fp = fp;
+ ws.hit = 0;
+ ws.prefix = 0;
+ if (ws.pattern = pattern)
+ {
+ while (*pattern && *pattern++ != '/');
+ if (!*pattern || *pattern == '*' && !*(pattern + 1))
+ ws.prefix = pattern - ws.pattern;
+ else if (ent = find(mp, ws.pattern))
+ {
+ ws.pattern = 0;
+ list(mp->cap, ent, &ws);
+ return ws.hit;
+ }
+ }
+ dtwalk(mp->cap, list, &ws);
+ return ws.hit;
+}
+
+/*
+ * get next arg in pp
+ * 0 returned if no more args
+ */
+
+static int
+arg(register Parse_t* pp, int first)
+{
+ register char* s;
+ register int c;
+ register int q;
+ int x;
+
+ for (s = pp->next; isspace(*s) && *s != '\n'; s++);
+ if (!*s || *s == '\n')
+ {
+ pp->next = s;
+ return 0;
+ }
+ pp->name.data = s;
+ pp->value.data = 0;
+ q = 0;
+ x = 0;
+ while ((c = *s++) && c != ';' && c != '\n')
+ {
+ if (c == '"')
+ {
+ q = 1;
+ if (pp->value.data)
+ {
+ pp->value.data = s;
+ if (x)
+ x = -1;
+ else
+ x = 1;
+ }
+ else if (!x && pp->name.data == (s - 1))
+ {
+ x = 1;
+ pp->name.data = s;
+ }
+ do
+ {
+ if (!(c = *s++) || c == '\n')
+ {
+ s--;
+ break;
+ }
+ } while (c != '"');
+ if (first < 0 || x > 0)
+ {
+ c = ';';
+ break;
+ }
+ }
+ else if (c == '=' && !first)
+ {
+ first = 1;
+ pp->name.size = s - pp->name.data - 1;
+ pp->value.data = s;
+ }
+ else if (first >= 0 && isspace(c))
+ break;
+ }
+ pp->next = s - (c != ';');
+ if (first >= 0 || !q)
+ for (s--; s > pp->name.data && isspace(*(s - 1)); s--);
+ if (pp->value.data)
+ pp->value.size = s - pp->value.data - (q && first < 0);
+ else
+ {
+ pp->value.size = 0;
+ pp->name.size = s - pp->name.data - (q && first < 0);
+ }
+ if (first >= 0 && pp->name.size > 0 && pp->name.data[pp->name.size - 1] == ':')
+ return 0;
+ return pp->name.size > 0;
+}
+
+/*
+ * low level for mimeview()
+ */
+
+static char*
+expand(Mime_t* mp, register char* s, const char* name, const char* type, const char* opts)
+{
+ register char* t;
+ register int c;
+ Parse_t pp;
+
+ mp->disc->flags |= MIME_PIPE;
+ for (;;)
+ {
+ switch (c = *s++)
+ {
+ case 0:
+ case '\n':
+ break;
+ case '%':
+ switch (c = *s++)
+ {
+ case 's':
+ sfputr(mp->buf, (char*)name, -1);
+ mp->disc->flags &= ~MIME_PIPE;
+ continue;
+ case 't':
+ sfputr(mp->buf, (char*)type, -1);
+ continue;
+ case '{':
+ for (t = s; *s && *s != '}'; s++);
+ if (*s && (c = s++ - t) && (pp.next = (char*)opts))
+ while (arg(&pp, 0))
+ if (pp.name.size == c && !strncasecmp(pp.name.data, t, c))
+ {
+ if (pp.value.size)
+ sfwrite(mp->buf, pp.value.data, pp.value.size);
+ break;
+ }
+ continue;
+ }
+ /*FALLTHROUGH*/
+ default:
+ sfputc(mp->buf, c);
+ continue;
+ }
+ break;
+ }
+ return sfstruse(mp->buf);
+}
+
+/*
+ * return expanded command/path/value for <view,name,type,opts>
+ * return value valid until next mime*() call
+ */
+
+char*
+mimeview(Mime_t* mp, const char* view, const char* name, const char* type, const char* opts)
+{
+ register Ent_t* ent;
+ register Cap_t* cap;
+ register Att_t* att;
+ register char* s;
+ int c;
+
+ if (ent = find(mp, type))
+ {
+ cap = ent->cap;
+ if (!view || strcasecmp(view, "test"))
+ while (s = cap->test)
+ {
+ if (s = expand(mp, s, name, type, opts))
+ {
+ Parse_t a1;
+ Parse_t a2;
+ Parse_t a3;
+ Parse_t a4;
+
+ /*
+ * try to do a few common cases here
+ * mailcap consistency is a winning
+ * strategy
+ */
+
+ a1.next = s;
+ if (arg(&a1, -1))
+ {
+ if ((c = *a1.name.data == '!') && --a1.name.size <= 0 && !arg(&a1, -1))
+ goto lose;
+ if (a1.name.size == 6 && strneq(a1.name.data, "strcmp", 6) || a1.name.size == 10 && strneq(a1.name.data, "strcasecmp", 10))
+ {
+ a2.next = a1.next;
+ if (!arg(&a2, -1))
+ goto lose;
+ a3.next = a2.next;
+ if (!arg(&a3, -1))
+ goto lose;
+ if (a2.name.size != a3.name.size)
+ c ^= 0;
+ else c ^= (a1.name.size == 6 ? strncmp : strncasecmp)(a2.name.data, a3.name.data, a2.name.size) == 0;
+ if (c)
+ break;
+ goto skip;
+ }
+ else if (a1.name.size == 4 && strneq(a1.name.data, "test", 4))
+ {
+ if (!arg(&a1, -1))
+ goto lose;
+ a2.next = a1.next;
+ if (!arg(&a2, -1) || a2.name.size > 2 || a2.name.size == 1 && *a2.name.data != '=' || a2.name.size == 2 && (!strneq(a1.name.data, "!=", 2) || !strneq(a2.name.data, "==", 2)))
+ goto lose;
+ a3.next = a2.next;
+ if (!arg(&a3, -1))
+ goto lose;
+ if (*a3.name.data == '`' && *(a3.name.data + a3.name.size - 1) == '`')
+ {
+ a4 = a3;
+ a3 = a1;
+ a1 = a4;
+ }
+ if (*a1.name.data == '`' && *(a1.name.data + a1.name.size - 1) == '`')
+ {
+ a1.next = a1.name.data + 1;
+ if (!arg(&a1, -1) || a1.name.size != 4 || !strneq(a1.name.data, "echo", 4) || !arg(&a1, -1))
+ goto lose;
+ a4.next = a1.next;
+ if (!arg(&a4, 1) || a4.name.size < 21 || !strneq(a4.name.data, "| tr '[A-Z]' '[a-z]'`", 21))
+ goto lose;
+ }
+ else
+ a4.name.size = 0;
+ c = *a2.name.data == '!';
+ if (a1.name.size != a3.name.size)
+ c ^= 0;
+ else c ^= (a4.name.size ? strncasecmp : strncmp)(a1.name.data, a3.name.data, a1.name.size) == 0;
+ if (c)
+ break;
+ goto skip;
+ }
+ }
+ lose:
+ if (!system(s))
+ break;
+ }
+ skip:
+ if (!(cap = cap->next))
+ return 0;
+ }
+ att = &cap->att;
+ if (view && *view && !streq(view, "-"))
+ while (strcasecmp(view, att->name))
+ if (!(att = att->next))
+ return 0;
+ return expand(mp, att->value, name, type, opts);
+ }
+ return 0;
+}
+
+/*
+ * lower case identifier prefix strcmp
+ * if e!=0 then it will point to the next char after the match
+ */
+
+int
+mimecmp(register const char* s, register const char* v, char** e)
+{
+ register int n;
+
+ while (isalnum(*v) || *v == *s && (*v == '_' || *v == '-' || *v == '/'))
+ if (n = lower(*s++) - lower(*v++))
+ return n;
+ if (!isalnum(*s) && *s != '_' && *s != '-')
+ {
+ if (e)
+ *e = (char*)s;
+ return 0;
+ }
+ return lower(*s) - lower(*v);
+}
+
+/*
+ * parse mime headers in strsearch(tab,num,siz) from s
+ * return >0 if mime header consumed
+ */
+
+int
+mimehead(Mime_t* mp, void* tab, size_t num, size_t siz, register char* s)
+{
+ register void* p;
+ char* e;
+ Parse_t pp;
+ Mimevalue_f set;
+
+ set = mp->disc->valuef;
+ if (!strncasecmp(s, "original-", 9))
+ s += 9;
+ if (!strncasecmp(s, "content-", 8))
+ {
+ s += 8;
+ if ((p = strsearch(tab, num, siz, (Strcmp_f)mimecmp, s, &e)) && *e == ':')
+ {
+ pp.next = e + 1;
+ if (arg(&pp, 1))
+ {
+ if ((*set)(mp, p, pp.name.data, pp.name.size, mp->disc))
+ return 0;
+ while (arg(&pp, 0))
+ if (pp.value.size &&
+ (p = strsearch(tab, num, siz, (Strcmp_f)mimecmp, pp.name.data, &e)) &&
+ (*set)(mp, p, pp.value.data, pp.value.size, mp->disc))
+ return 0;
+ return 1;
+ }
+ }
+ else if (strchr(s, ':'))
+ return 1;
+ }
+ return !strncasecmp(s, "x-", 2);
+}
+
+/*
+ * open a mime library handle
+ */
+
+Mime_t*
+mimeopen(Mimedisc_t* disc)
+{
+ register Mime_t* mp;
+
+ if (!(mp = newof(0, Mime_t, 1, 0)))
+ return 0;
+ mp->id = lib;
+ mp->disc = disc;
+ mp->dict.key = offsetof(Ent_t, name);
+ mp->dict.comparf = order;
+ mp->dict.freef = drop;
+ if (!(mp->buf = sfstropen()) || !(mp->cap = dtopen(&mp->dict, Dtorder)))
+ {
+ mimeclose(mp);
+ return 0;
+ }
+ return mp;
+}
+
+/*
+ * close a mimeopen() handle
+ */
+
+int
+mimeclose(Mime_t* mp)
+{
+ if (mp)
+ {
+ if (mp->buf)
+ sfclose(mp->buf);
+ if (mp->cap)
+ dtclose(mp->cap);
+ if (mp->freef)
+ (*mp->freef)(mp);
+ free(mp);
+ }
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/misc/mimelib.h b/usr/src/lib/libast/common/misc/mimelib.h
new file mode 100644
index 0000000000..51840a0c76
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/mimelib.h
@@ -0,0 +1,52 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * mime/mailcap internal interface
+ */
+
+#ifndef _MIMELIB_H
+#define _MIMELIB_H 1
+
+#include <ast.h>
+#include <cdt.h>
+#include <magic.h>
+#include <tok.h>
+
+struct Mime_s;
+
+typedef void (*Free_f)(struct Mime_s*);
+
+#define _MIME_PRIVATE_ \
+ Mimedisc_t* disc; /* mime discipline */ \
+ Dtdisc_t dict; /* cdt discipline */ \
+ Magicdisc_t magicd; /* magic discipline */ \
+ Dt_t* cap; /* capability tree */ \
+ Sfio_t* buf; /* string buffer */ \
+ Magic_t* magic; /* mimetype() magic handle */ \
+ Free_f freef; /* avoid magic lib if possible */ \
+
+#include <mime.h>
+#include <ctype.h>
+
+#endif
diff --git a/usr/src/lib/libast/common/misc/mimetype.c b/usr/src/lib/libast/common/misc/mimetype.c
new file mode 100644
index 0000000000..5842a029b8
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/mimetype.c
@@ -0,0 +1,69 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * mime/mailcap to magic support
+ */
+
+#include "mimelib.h"
+
+/*
+ * close magic handle
+ * done this way so that magic is only pulled in
+ * if mimetype() is used
+ */
+
+static void
+drop(Mime_t* mp)
+{
+ if (mp->magic)
+ {
+ magicclose(mp->magic);
+ mp->magic = 0;
+ }
+}
+
+/*
+ * return mime type for file
+ */
+
+char*
+mimetype(Mime_t* mp, Sfio_t* fp, const char* file, struct stat* st)
+{
+ if (mp->disc->flags & MIME_NOMAGIC)
+ return 0;
+ if (!mp->magic)
+ {
+ mp->magicd.version = MAGIC_VERSION;
+ mp->magicd.flags = MAGIC_MIME;
+ mp->magicd.errorf = mp->disc->errorf;
+ if (!(mp->magic = magicopen(&mp->magicd)))
+ {
+ mp->disc->flags |= MIME_NOMAGIC;
+ return 0;
+ }
+ mp->freef = drop;
+ magicload(mp->magic, NiL, 0);
+ }
+ return magictype(mp->magic, fp, file, st);
+}
diff --git a/usr/src/lib/libast/common/misc/optesc.c b/usr/src/lib/libast/common/misc/optesc.c
new file mode 100644
index 0000000000..911ba67ae3
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/optesc.c
@@ -0,0 +1,93 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * escape optget() special chars in s and write to sp
+ * esc == '?' or ':' also escaped
+ */
+
+#include <optlib.h>
+#include <ctype.h>
+
+int
+optesc(Sfio_t* sp, register const char* s, int esc)
+{
+ register const char* m;
+ register int c;
+
+ if (*s == '[' && *(s + 1) == '+' && *(s + 2) == '?')
+ {
+ c = strlen(s);
+ if (s[c - 1] == ']')
+ {
+ sfprintf(sp, "%-.*s", c - 4, s + 3);
+ return 0;
+ }
+ }
+ if (esc != '?' && esc != ':')
+ esc = 0;
+ while (c = *s++)
+ {
+ if (isalnum(c))
+ {
+ for (m = s - 1; isalnum(*s); s++);
+ if (isalpha(c) && *s == '(' && isdigit(*(s + 1)) && *(s + 2) == ')')
+ {
+ sfputc(sp, '\b');
+ sfwrite(sp, m, s - m);
+ sfputc(sp, '\b');
+ sfwrite(sp, s, 3);
+ s += 3;
+ }
+ else
+ sfwrite(sp, m, s - m);
+ }
+ else if (c == '-' && *s == '-' || c == '<')
+ {
+ m = s - 1;
+ if (c == '-')
+ s++;
+ else if (*s == '/')
+ s++;
+ while (isalnum(*s))
+ s++;
+ if (c == '<' && *s == '>' || isspace(*s) || *s == 0 || *s == '=' || *s == ':' || *s == ';' || *s == '.' || *s == ',')
+ {
+ sfputc(sp, '\b');
+ sfwrite(sp, m, s - m);
+ sfputc(sp, '\b');
+ }
+ else
+ sfwrite(sp, m, s - m);
+ }
+ else
+ {
+ if (c == ']' || c == esc)
+ sfputc(sp, c);
+ sfputc(sp, c);
+ }
+ }
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/misc/optget.c b/usr/src/lib/libast/common/misc/optget.c
new file mode 100644
index 0000000000..d8b1f34f47
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/optget.c
@@ -0,0 +1,5176 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * command line option parser and usage formatter
+ * its a monster but its all in one place
+ * widen your window while you're at it
+ */
+
+#include <optlib.h>
+#include <debug.h>
+#include <ccode.h>
+#include <ctype.h>
+#include <errno.h>
+
+#define KEEP "*[A-Za-z][A-Za-z]*"
+#define OMIT "*@(\\[[-+]*\\?*\\]|\\@\\(#\\)|Copyright \\(c\\)|\\$\\I\\d\\: )*"
+
+#define GO '{' /* group nest open */
+#define OG '}' /* group nest close */
+
+#define OPT_WIDTH 80 /* default help text width */
+#define OPT_MARGIN 10 /* default help text margin */
+#define OPT_USAGE 7 /* usage continuation indent */
+
+#define OPT_flag 0x001 /* flag ( 0 or 1 ) */
+#define OPT_hidden 0x002 /* remaining are hidden */
+#define OPT_ignorecase 0x004 /* arg match ignores case */
+#define OPT_invert 0x008 /* flag inverts long sense */
+#define OPT_listof 0x010 /* arg is ' ' or ',' list */
+#define OPT_minus 0x021 /* '-' is an option flag */
+#define OPT_number 0x040 /* arg is strtonll() number */
+#define OPT_oneof 0x080 /* arg may be set once */
+#define OPT_optional 0x100 /* arg is optional */
+#define OPT_string 0x200 /* arg is string */
+
+#define OPT_preformat 0001 /* output preformat string */
+
+#define OPT_TYPE (OPT_flag|OPT_number|OPT_string)
+
+#define STYLE_posix 0 /* posix getopt usage */
+#define STYLE_short 1 /* [default] short usage */
+#define STYLE_long 2 /* long usage */
+#define STYLE_match 3 /* long description of matches */
+#define STYLE_options 4 /* short and long descriptions */
+#define STYLE_man 5 /* pretty details */
+#define STYLE_html 6 /* html details */
+#define STYLE_nroff 7 /* nroff details */
+#define STYLE_api 8 /* program details */
+#define STYLE_keys 9 /* translation key strings */
+#define STYLE_usage 10 /* escaped usage string */
+
+#define FONT_BOLD 1
+#define FONT_ITALIC 2
+#define FONT_LITERAL 4
+
+#define sep(c) ((c)=='-'||(c)=='_')
+
+typedef struct Attr_s
+{
+ const char* name;
+ int flag;
+} Attr_t;
+
+typedef struct Help_s
+{
+ const char* match; /* builtin help match name */
+ const char* name; /* builtin help name */
+ int style; /* STYLE_* */
+ const char* text; /* --? text */
+ unsigned int size; /* strlen text */
+} Help_t;
+
+typedef struct Font_s
+{
+ const char* html[2];
+ const char* nroff[2];
+ const char* term[2];
+} Font_t;
+
+typedef struct List_s
+{
+ int type; /* { - + : } */
+ const char* name; /* list name */
+ const char* text; /* help text */
+} List_t;
+
+typedef struct Msg_s
+{
+ const char* text; /* default message text */
+ Dtlink_t link; /* cdt link */
+} Msg_t;
+
+typedef struct Save_s
+{
+ Dtlink_t link; /* cdt link */
+ char text[1]; /* saved text text */
+} Save_t;
+
+typedef struct Push_s
+{
+ struct Push_s* next; /* next string */
+ char* ob; /* next char in old string */
+ char* oe; /* end of old string */
+ char* nb; /* next char in new string */
+ char* ne; /* end of new string */
+ int ch; /* localize() translation */
+} Push_t;
+
+typedef struct Indent_s
+{
+ int stop; /* tab column position */
+} Indent_t;
+
+static Indent_t indent[] =
+{
+ 0,2, 4,10, 12,18, 20,26, 28,34, 36,42, 44,50, 0,0
+};
+
+static const char term_off[] = {CC_esc,'[','0','m',0};
+static const char term_B_on[] = {CC_esc,'[','1','m',0};
+static const char term_I_on[] = {CC_esc,'[','1',';','4','m',0};
+
+static const Font_t fonts[] =
+{
+ "", "", "", "", "", "",
+ "</B>", "<B>", "\\fP", "\\fB", &term_off[0], &term_B_on[0],
+ "</I>", "<I>", "\\fP", "\\fI", &term_off[0], &term_I_on[0],
+ "", "", "", "", "", "",
+ "</TT>","<TT>","\\fP", "\\f5", "", "",
+};
+
+static char native[] = "";
+
+#if !_PACKAGE_astsa
+
+#define ID ast.id
+
+#define C(s) ERROR_catalog(s)
+#define D(s) (opt_info.state->msgdict && dtmatch(opt_info.state->msgdict, (s)))
+#define T(i,c,m) (X(c)?translate(i,c,C(m)):(m))
+#define X(c) (ERROR_translating()&&(c)!=native)
+#define Z(x) C(x),sizeof(x)-1
+
+/*
+ * translate with C_LC_MESSAGES_libast[] check
+ */
+
+static char*
+translate(const char* cmd, const char* cat, const char* msg)
+{
+ if (!X(cat))
+ return (char*)msg;
+ if (cat != (const char*)ID && D(msg))
+ cat = (const char*)ID;
+ return errorx(NiL, cmd, cat, msg);
+}
+
+#else
+
+static char ID[] = "ast";
+
+#define C(s) s
+#define D(s) (opt_info.state->msgdict && dtmatch(opt_info.state->msgdict, (s)))
+#define T(i,c,m) m
+#define X(c) 0
+#define Z(x) C(x),sizeof(x)-1
+
+#endif
+
+static const List_t help_head[] =
+{
+ '-', 0,
+ 0,
+ '+', C("NAME"),
+ C("options available to all \bast\b commands"),
+ '+', C("DESCRIPTION"),
+ C("\b-?\b and \b--?\b* options are the same \
+for all \bast\b commands. For any \aitem\a below, if \b--\b\aitem\a is not \
+supported by a given command then it is equivalent to \b--\?\?\b\aitem\a. The \
+\b--\?\?\b form should be used for portability. All output is written to the \
+standard error."),
+};
+
+static const Help_t styles[] =
+{
+ C("about"), "-", STYLE_match,
+ Z("List all implementation info."),
+ C("api"), "?api", STYLE_api,
+ Z("List detailed info in program readable form."),
+ C("help"), "", -1,
+ Z("List detailed help option info."),
+ C("html"), "?html", STYLE_html,
+ Z("List detailed info in html."),
+ C("keys"), "?keys", STYLE_keys,
+ Z("List the usage translation key strings with C style escapes."),
+ C("long"), "?long", STYLE_long,
+ Z("List long option usage."),
+ C("man"), "?man", STYLE_man,
+ Z("List detailed info in displayed man page form."),
+ C("nroff"), "?nroff", STYLE_nroff,
+ Z("List detailed info in nroff."),
+ C("options"), "?options", STYLE_options,
+ Z("List short and long option details."),
+ C("posix"), "?posix", STYLE_posix,
+ Z("List posix getopt usage."),
+ C("short"), "?short", STYLE_short,
+ Z("List short option usage."),
+ C("usage"), "?usage", STYLE_usage,
+ Z("List the usage string with C style escapes."),
+};
+
+static const List_t help_tail[] =
+{
+ ':', C("\?\?-\alabel\a"),
+ C("List implementation info matching \alabel\a*."),
+ ':', C("\?\?\aname\a"),
+ C("Equivalent to \b--help=\b\aname\a."),
+ ':', C("\?\?"),
+ C("Equivalent to \b--\?\?options\b."),
+ ':', C("\?\?\?\?"),
+ C("Equivalent to \b--\?\?man\b."),
+ ':', C("\?\?\?\?\?\?"),
+ C("Equivalent to \b--\?\?help\b."),
+ ':', C("\?\?\?\?\?\?\aitem\a"),
+ C("If the next argument is \b--\b\aoption\a then list \
+the \aoption\a output in the \aitem\a style. Otherwise print \
+\bversion=\b\an\a where \an\a>0 if \b--\?\?\b\aitem\a is supported, \b0\b \
+if not."),
+ ':', C("\?\?\?\?\?\?ESC"),
+ C("Emit escape codes even if output is not a terminal."),
+ ':', C("\?\?\?\?\?\?TEST"),
+ C("Massage the output for regression testing."),
+};
+
+static const Attr_t attrs[] =
+{
+ "flag", OPT_flag,
+ "hidden", OPT_hidden,
+ "ignorecase", OPT_ignorecase,
+ "invert", OPT_invert,
+ "listof", OPT_listof,
+ "number", OPT_number,
+ "oneof", OPT_oneof,
+ "optional", OPT_optional,
+ "string", OPT_string,
+};
+
+static const char unknown[] = C("unknown option or attribute");
+
+static const char* heading[] =
+{
+ C("INDEX"),
+ C("USER COMMANDS"),
+ C("SYSTEM LIBRARY"),
+ C("USER LIBRARY"),
+ C("FILE FORMATS"),
+ C("MISCELLANEOUS"),
+ C("GAMES and DEMOS"),
+ C("SPECIAL FILES"),
+ C("ADMINISTRATIVE COMMANDS"),
+ C("GUIs"),
+};
+
+/*
+ * list of common man page strings
+ * NOTE: add but do not delete from this table
+ */
+
+static Msg_t C_LC_MESSAGES_libast[] =
+{
+ { C("APPLICATION USAGE") },
+ { C("ASYNCHRONOUS EVENTS") },
+ { C("BUGS") },
+ { C("CAVEATS") },
+ { C("CONSEQUENCES OF ERRORS") },
+ { C("DESCRIPTION") },
+ { C("ENVIRONMENT VARIABLES") },
+ { C("EXAMPLES") },
+ { C("EXIT STATUS") },
+ { C("EXTENDED DESCRIPTION") },
+ { C("INPUT FILES") },
+ { C("LIBRARY") },
+ { C("NAME") },
+ { C("OPERANDS") },
+ { C("OPTIONS") },
+ { C("OUTPUT FILES") },
+ { C("SEE ALSO") },
+ { C("STDERR") },
+ { C("STDIN") },
+ { C("STDOUT") },
+ { C("SYNOPSIS") },
+ { C("author") },
+ { C("copyright") },
+ { C("license") },
+ { C("name") },
+ { C("path") },
+ { C("version") },
+};
+
+static unsigned char map[UCHAR_MAX];
+
+static Optstate_t state;
+
+/*
+ * 2007-03-19 move opt_info from _opt_info_ to (*_opt_data_)
+ * to allow future Opt_t growth
+ * by 2009 _opt_info_ can be static
+ */
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+
+extern Opt_t _opt_info_;
+
+Opt_t _opt_info_ = { 0,0,0,0,0,0,0,{0},{0},0,0,0,{0},{0},&state };
+
+#undef extern
+
+__EXTERN__(Opt_t, _opt_info_);
+
+__EXTERN__(Opt_t*, _opt_infop_);
+
+Opt_t* _opt_infop_ = &_opt_info_;
+
+#if _BLD_DEBUG
+
+/*
+ * debug usage string segment format
+ */
+
+static char*
+show(register char* s)
+{
+ register int c;
+ register char* t;
+ register char* e;
+
+ static char buf[32];
+
+ if (!s)
+ return "(null)";
+ t = buf;
+ e = buf + sizeof(buf) - 2;
+ while (t < e)
+ {
+ switch (c = *s++)
+ {
+ case 0:
+ goto done;
+ case '\a':
+ *t++ = '\\';
+ c = 'a';
+ break;
+ case '\b':
+ *t++ = '\\';
+ c = 'b';
+ break;
+ case '\f':
+ *t++ = '\\';
+ c = 'f';
+ break;
+ case '\v':
+ *t++ = '\\';
+ c = 'v';
+ break;
+ }
+ *t++ = c;
+ }
+ done:
+ *t = 0;
+ return buf;
+}
+
+#endif
+
+/*
+ * pop the push stack
+ */
+
+static Push_t*
+pop(register Push_t* psp)
+{
+ register Push_t* tsp;
+
+ while (tsp = psp)
+ {
+ psp = psp->next;
+ free(tsp);
+ }
+ return 0;
+}
+
+/*
+ * skip over line space to the next token
+ */
+
+static char*
+next(register char* s, int version)
+{
+ register char* b;
+
+ while (*s == '\t' || *s == '\r' || version >= 1 && *s == ' ')
+ s++;
+ if (*s == '\n')
+ {
+ b = s;
+ while (*++s == ' ' || *s == '\t' || *s == '\r');
+ if (*s == '\n')
+ return b;
+ }
+ return s;
+}
+
+/*
+ * skip to t1 or t2 or t3, whichever first, in s
+ * n==0 outside [...]
+ * n==1 inside [...] before ?
+ * n==2 inside [...] after ?
+ * b==0 outside {...}
+ * b==1 inside {...}
+ * past skips past the terminator to the next token
+ * otherwise a pointer to the terminator is returned
+ *
+ * ]] for ] inside [...]
+ * ?? for ? inside [...] before ?
+ * :: for : inside [...] before ?
+ */
+
+static char*
+skip(register char* s, register int t1, register int t2, register int t3, register int n, register int b, int past, int version)
+{
+ register int c;
+ register int on = n;
+ register int ob = b;
+
+ if (version < 1)
+ {
+ n = n >= 1;
+ for (;;)
+ {
+ switch (*s++)
+ {
+ case 0:
+ break;
+ case '[':
+ n++;
+ continue;
+ case ']':
+ if (--n <= 0)
+ break;
+ continue;
+ default:
+ continue;
+ }
+ break;
+ }
+ }
+ else while (c = *s++)
+ {
+ message((-22, "optget: skip t1=%c t2=%c t3=%c n=%d b=%d `%s'", t1 ? t1 : '@', t2 ? t2 : '@', t3 ? t3 : '@', n, b, show(s - 1)));
+ if (c == '[')
+ {
+ if (!n)
+ n = 1;
+ }
+ else if (c == ']')
+ {
+ if (n)
+ {
+ if (*s == ']')
+ s++;
+ else if (on == 1)
+ break;
+ else
+ n = 0;
+ }
+ }
+ else if (c == GO)
+ {
+ if (n == 0)
+ b++;
+ }
+ else if (c == OG)
+ {
+ if (n == 0 && b-- == ob)
+ break;
+ }
+ else if (c == '?')
+ {
+ if (n == 1)
+ {
+ if (*s == '?')
+ s++;
+ else
+ {
+ if (n == on && (c == t1 || c == t2 || c == t3))
+ break;
+ n = 2;
+ }
+ }
+ }
+ else if (n == on && (c == t1 || c == t2 || c == t3))
+ {
+ if (n == 1 && c == ':' && *s == c)
+ s++;
+ else
+ break;
+ }
+ }
+ return past && *(s - 1) ? next(s, version) : s - 1;
+}
+
+/*
+ * match s with t
+ * t translated if possible
+ * imbedded { - _ ' } ignored
+ * * separates required prefix from optional suffix
+ * otherwise prefix match
+ */
+
+static int
+match(char* s, char* t, int version, const char* catalog)
+{
+ register char* w;
+ register char* x;
+ char* xw;
+ char* ww;
+ int n;
+ int v;
+ int j;
+
+ for (n = 0; n < 2; n++)
+ {
+ if (n)
+ x = t;
+ else
+ {
+ if (catalog)
+ {
+ w = skip(t, ':', '?', 0, 1, 0, 0, version);
+ w = sfprints("%-.*s", w - t, t);
+ x = T(error_info.id, catalog, w);
+ if (x == w)
+ continue;
+ }
+ x = T(NiL, ID, t);
+ if (x == t)
+ continue;
+ }
+ do
+ {
+ v = 0;
+ xw = x;
+ w = ww = s;
+ while (*x && *w)
+ {
+ if (isupper(*x))
+ xw = x;
+ if (isupper(*w))
+ ww = w;
+ if (*x == '*' && !v++ || *x == '\a')
+ {
+ if (*x == '\a')
+ do
+ {
+ if (!*++x)
+ {
+ x--;
+ break;
+ }
+ } while (*x != '\a');
+ j = *(x + 1);
+ if (j == ':' || j == '|' || j == '?' || j == ']' || j == 0)
+ while (*w)
+ w++;
+ }
+ else if (sep(*x))
+ xw = ++x;
+ else if (sep(*w) && w != s)
+ ww = ++w;
+ else if (*x == *w)
+ {
+ x++;
+ w++;
+ }
+ else if (w == ww && x == xw)
+ break;
+ else
+ {
+ if (x != xw)
+ {
+ while (*x && !sep(*x) && !isupper(*x))
+ x++;
+ if (!*x)
+ break;
+ if (sep(*x))
+ x++;
+ xw = x;
+ }
+ while (w > ww && *w != *x)
+ w--;
+ }
+ }
+ if (!*w)
+ {
+ if (!v)
+ {
+ for (;;)
+ {
+ switch (*x++)
+ {
+ case 0:
+ case ':':
+ case '|':
+ case '?':
+ case ']':
+ return 1;
+ case '*':
+ break;
+ default:
+ continue;
+ }
+ break;
+ }
+ break;
+ }
+ return 1;
+ }
+ } while (*(x = skip(x, '|', 0, 0, 1, 0, 0, version)) == '|' && x++);
+ }
+ return 0;
+}
+
+/*
+ * prefix search for s in tab with num elements of size
+ * with optional translation
+ */
+
+static void*
+search(const void* tab, size_t num, size_t siz, char* s)
+{
+ register char* p;
+ register char* e;
+
+ for (e = (p = (char*)tab) + num * siz; p < e; p += siz)
+ if (match(s, *((char**)p), -1, NiL))
+ return (void*)p;
+ return 0;
+}
+
+/*
+ * save s and return the saved pointer
+ */
+
+static char*
+save(const char* s)
+{
+ Save_t* p;
+
+ static Dtdisc_t disc;
+ static Dt_t* dict;
+
+ if (!dict)
+ {
+ disc.key = offsetof(Save_t, text);
+ if (!(dict = dtopen(&disc, Dthash)))
+ return (char*)s;
+ }
+ if (!(p = (Save_t*)dtmatch(dict, s)))
+ {
+ if (!(p = newof(0, Save_t, 1, strlen(s))))
+ return (char*)s;
+ strcpy(p->text, s);
+ dtinsert(dict, p);
+ }
+ return p->text;
+}
+
+/*
+ * initialize the attributes for pass p from opt string s
+ */
+
+static int
+init(register char* s, Optpass_t* p)
+{
+ register char* t;
+ register int c;
+ register int a;
+ register int n;
+
+ if (!opt_info.state->msgdict)
+ {
+#if !_PACKAGE_astsa
+ if (!ast.locale.serial)
+ setlocale(LC_ALL, "");
+#endif
+ opt_info.state->vp = sfstropen();
+ opt_info.state->xp = sfstropen();
+ opt_info.state->msgdisc.key = offsetof(Msg_t, text);
+ opt_info.state->msgdisc.size = -1;
+ opt_info.state->msgdisc.link = offsetof(Msg_t, link);
+ if (opt_info.state->msgdict = dtopen(&opt_info.state->msgdisc, Dthash))
+ for (n = 0; n < elementsof(C_LC_MESSAGES_libast); n++)
+ dtinsert(opt_info.state->msgdict, C_LC_MESSAGES_libast + n);
+ if (!map[OPT_FLAGS[0]])
+ for (n = 0, t = OPT_FLAGS; *t; t++)
+ map[*t] = ++n;
+ }
+#if _BLD_DEBUG
+ error(-1, "optget debug");
+#endif
+ p->oopts = s;
+ p->version = 0;
+ p->prefix = 2;
+ p->section = 1;
+ p->flags = 0;
+ p->catalog = 0;
+ s = next(s, 0);
+ if (*s == ':')
+ s++;
+ if (*s == '+')
+ s++;
+ s = next(s, 0);
+ if (*s++ == '[')
+ {
+ if (*s == '+')
+ p->version = 1;
+ else if (*s++ == '-')
+ {
+ if (*s == '?' || *s == ']')
+ p->version = 1;
+ else
+ {
+ if (*s < '0' || *s > '9')
+ p->version = 1;
+ else
+ while (*s >= '0' && *s <= '9')
+ p->version = p->version * 10 + (*s++ - '0');
+ while (*s && *s != '?' && *s != ']')
+ {
+ c = *s++;
+ if (*s < '0' || *s > '9')
+ n = 1;
+ else
+ {
+ n = 0;
+ while (*s >= '0' && *s <= '9')
+ n = n * 10 + (*s++ - '0');
+ }
+ switch (c)
+ {
+ case 'c':
+ p->flags |= OPT_cache;
+ break;
+ case 'i':
+ p->flags |= OPT_ignore;
+ break;
+ case 'l':
+ p->flags |= OPT_long;
+ break;
+ case 'o':
+ p->flags |= OPT_old;
+ break;
+ case 'p':
+ p->prefix = n;
+ break;
+ case 's':
+ p->section = n;
+ if (n > 1 && n < 6)
+ {
+ p->flags |= OPT_functions;
+ p->prefix = 0;
+ }
+ break;
+ }
+ }
+ }
+ }
+ while (*s)
+ if (*s++ == ']' && *s++ == '[')
+ {
+ if (*s++ != '-')
+ {
+ if (!error_info.id && strneq(s - 1, "+NAME?", 6))
+ {
+ for (t = s += 5; *t && *t != ' ' && *t != ']'; t++);
+ error_info.id = save(sfprints("%-.*s", t - s, s));
+ }
+ break;
+ }
+ if (*s == '-')
+ s++;
+ if (strneq(s, "catalog?", 8))
+ {
+ s += 8;
+ if ((t = strchr(s, ']')) && (!error_info.id || (t - s) != strlen(error_info.id) || !strneq(s, error_info.id, t - s)))
+ p->catalog = save(sfprints("%-.*s", t - s, s));
+ if (error_info.id)
+ break;
+ }
+ }
+ }
+ if (!p->catalog)
+ {
+ if (opt_info.disc && opt_info.disc->catalog && (!error_info.id || !streq(opt_info.disc->catalog, error_info.id)))
+ p->catalog = opt_info.disc->catalog;
+ else
+ p->catalog = ID;
+ }
+ s = p->oopts;
+ if (*s == ':')
+ s++;
+ if (*s == '+')
+ {
+ s++;
+ p->flags |= OPT_plus;
+ }
+ if (*s != '[')
+ for (t = s, a = 0; *t; t++)
+ if (!a && *t == '-')
+ {
+ p->flags |= OPT_minus;
+ break;
+ }
+ else if (*t == '[')
+ a++;
+ else if (*t == ']')
+ a--;
+ if (!p->version && (t = strchr(s, '(')) && strchr(t, ')') && (opt_info.state->cp || (opt_info.state->cp = sfstropen())))
+ {
+ /*
+ * solaris long option compatibility
+ */
+
+ p->version = 1;
+ for (t = p->oopts; t < s; t++)
+ sfputc(opt_info.state->cp, *t);
+ n = t - p->oopts;
+ sfputc(opt_info.state->cp, '[');
+ sfputc(opt_info.state->cp, '-');
+ sfputc(opt_info.state->cp, ']');
+ while (c = *s++)
+ {
+ sfputc(opt_info.state->cp, '[');
+ sfputc(opt_info.state->cp, c);
+ if (a = (c = *s++) == ':')
+ c = *s++;
+ if (c == '(')
+ {
+ sfputc(opt_info.state->cp, ':');
+ for (;;)
+ {
+ while ((c = *s++) && c != ')')
+ sfputc(opt_info.state->cp, c);
+ if (!c || *s != '(')
+ break;
+ sfputc(opt_info.state->cp, '|');
+ s++;
+ }
+ }
+ sfputc(opt_info.state->cp, ']');
+ if (a)
+ sfputr(opt_info.state->cp, ":[string]", -1);
+ if (!c)
+ break;
+ }
+ if (!(p->oopts = s = sfstruse(opt_info.state->cp)))
+ return -1;
+ s += n;
+ }
+ p->opts = s;
+ return 0;
+}
+
+/*
+ * return the bold set/unset sequence for style
+ */
+
+static const char*
+font(int f, int style, int set)
+{
+ switch (style)
+ {
+ case STYLE_html:
+ return fonts[f].html[set];
+ case STYLE_nroff:
+ return fonts[f].nroff[set];
+ case STYLE_short:
+ case STYLE_long:
+ case STYLE_posix:
+ case STYLE_api:
+ break;
+ default:
+ if (opt_info.state->emphasis > 0)
+ return fonts[f].term[set];
+ break;
+ }
+ return "";
+}
+
+/*
+ * expand \f...\f info
+ * *p set to next char after second \f
+ * expanded value returned
+ */
+
+static char*
+expand(register char* s, register char* e, char** p, Sfio_t* ip)
+{
+ register int c;
+ register char* b = s;
+ int n;
+
+ message((-23, "AHA#%d expand(%s)", __LINE__, show(s)));
+ n = sfstrtell(ip);
+ c = 1;
+ while ((!e || s < e) && (c = *s++) && c != '\f');
+ sfwrite(ip, b, s - b - 1);
+ sfputc(ip, 0);
+ b = sfstrbase(ip) + n;
+ message((-23, "AHA#%d expand(%s)", __LINE__, b));
+ n = sfstrtell(ip);
+ if (!c)
+ s--;
+ if (*b == '?')
+ {
+ if (!*++b || streq(b, "NAME"))
+ {
+ if (!(b = error_info.id))
+ b = "command";
+ sfstrseek(ip, 0, SEEK_SET);
+ sfputr(ip, b, -1);
+ n = 0;
+ }
+ else
+ n = 1;
+ }
+ else if (!opt_info.disc || !opt_info.disc->infof || (*opt_info.disc->infof)(&opt_info, ip, b, opt_info.disc) < 0)
+ n = 0;
+ *p = s;
+ if (s = sfstruse(ip))
+ s += n;
+ else
+ s = "error";
+ return s;
+}
+
+/*
+ * push \f...\f info
+ */
+
+static Push_t*
+info(Push_t* psp, char* s, char* e, Sfio_t* ip)
+{
+ register char* b;
+ int n;
+ Push_t* tsp;
+
+ static Push_t push;
+
+ b = expand(s, e, &s, ip);
+ n = strlen(b);
+ if (tsp = newof(0, Push_t, 1, n + 1))
+ {
+ tsp->nb = (char*)(tsp + 1);
+ tsp->ne = tsp->nb + n;
+ strcpy(tsp->nb, b);
+ }
+ else
+ tsp = &push;
+ tsp->next = psp;
+ tsp->ob = s;
+ tsp->oe = e;
+ return tsp;
+}
+
+/*
+ * push translation
+ */
+
+static Push_t*
+localize(Push_t* psp, char* s, char* e, int term, int n, char* catalog, int version, Sfio_t* ip)
+{
+ char* t;
+ char* u;
+ Push_t* tsp;
+ int c;
+
+ t = skip(s, term, 0, 0, n, 0, 0, version);
+ if (e && t > e)
+ t = e;
+ while (s < t)
+ {
+ switch (c = *s++)
+ {
+ case ':':
+ case '?':
+ if (term && *s == c)
+ s++;
+ break;
+ case ']':
+ if (*s == c)
+ s++;
+ break;
+ }
+ sfputc(ip, c);
+ }
+ if (!(s = sfstruse(ip)) || (u = T(error_info.id, catalog, s)) == s)
+ return 0;
+ n = strlen(u);
+ if (tsp = newof(0, Push_t, 1, n + 1))
+ {
+ tsp->nb = (char*)(tsp + 1);
+ tsp->ne = tsp->nb + n;
+ strcpy(tsp->nb, u);
+ tsp->ob = t;
+ tsp->oe = e;
+ tsp->ch = 1;
+ }
+ tsp->next = psp;
+ return tsp;
+}
+
+/*
+ * output label s from [ ...label...[?...] ] to sp
+ * 1 returned if the label was translated
+ */
+
+static int
+label(register Sfio_t* sp, int sep, register char* s, int z, int level, int style, int f, Sfio_t* ip, int version, char* catalog)
+{
+ register int c;
+ register char* t;
+ register char* e;
+ int ostyle;
+ int a;
+ int i;
+ char* p;
+ char* w;
+ char* y;
+ int va;
+ Push_t* tsp;
+
+ int r = 0;
+ int n = 1;
+ Push_t* psp = 0;
+
+ if ((ostyle = style) > (STYLE_nroff - (sep <= 0)) && f != FONT_LITERAL)
+ style = 0;
+ if (z < 0)
+ e = s + strlen(s);
+ else
+ e = s + z;
+ if (sep > 0)
+ {
+ if (sep == ' ' && style == STYLE_nroff)
+ sfputc(sp, '\\');
+ sfputc(sp, sep);
+ }
+ sep = !sep || z < 0;
+ va = 0;
+ y = 0;
+ if (version < 1)
+ {
+ a = 0;
+ for (;;)
+ {
+ if (s >= e)
+ return r;
+ switch (c = *s++)
+ {
+ case '[':
+ a++;
+ break;
+ case ']':
+ if (--a < 0)
+ return r;
+ break;
+ }
+ sfputc(sp, c);
+ }
+ }
+ else if (level && (*(p = skip(s, 0, 0, 0, 1, level, 1, version)) == ':' || *p == '#'))
+ {
+ va = 0;
+ if (*++p == '?' || *p == *(p - 1))
+ {
+ p++;
+ va |= OPT_optional;
+ }
+ if (*(p = next(p, version)) == '[')
+ y = p + 1;
+ }
+ if (X(catalog) && (!level || *s == '\a' || *(s - 1) != '+') &&
+ (tsp = localize(psp, s, e, (sep || level) ? '?' : 0, sep || level, catalog, version, ip)))
+ {
+ psp= tsp;
+ s = psp->nb;
+ e = psp->ne;
+ r = psp->ch > 0;
+ }
+ switch (*s)
+ {
+ case '\a':
+ if (f == FONT_ITALIC)
+ s++;
+ f = 0;
+ break;
+ case '\b':
+ if (f == FONT_BOLD)
+ s++;
+ f = 0;
+ break;
+ case '\v':
+ if (f == FONT_LITERAL)
+ s++;
+ f = 0;
+ break;
+ default:
+ if (f)
+ sfputr(sp, font(f, style, 1), -1);
+ break;
+ }
+ for (;;)
+ {
+ if (s >= e)
+ {
+ if (!(tsp = psp))
+ goto restore;
+ s = psp->ob;
+ e = psp->oe;
+ psp = psp->next;
+ free(tsp);
+ continue;
+ }
+ switch (c = *s++)
+ {
+ case '(':
+ if (n)
+ {
+ n = 0;
+ if (f)
+ {
+ sfputr(sp, font(f, style, 0), -1);
+ f = 0;
+ }
+ }
+ break;
+ case '?':
+ case ':':
+ case ']':
+ if (psp && psp->ch)
+ break;
+ if (y)
+ {
+ if (va & OPT_optional)
+ sfputc(sp, '[');
+ sfputc(sp, '=');
+ label(sp, 0, y, -1, 0, style, FONT_ITALIC, ip, version, catalog);
+ if (va & OPT_optional)
+ sfputc(sp, ']');
+ y = 0;
+ }
+ switch (c)
+ {
+ case '?':
+ if (*s == '?')
+ s++;
+ else if (*s == ']' && *(s + 1) != ']')
+ continue;
+ else if (sep)
+ goto restore;
+ else if (X(catalog) && (tsp = localize(psp, s, e, 0, 1, catalog, version, ip)))
+ {
+ psp = tsp;
+ s = psp->nb;
+ e = psp->ne;
+ }
+ break;
+ case ']':
+ if (sep && *s++ != ']')
+ goto restore;
+ break;
+ case ':':
+ if (sep && *s++ != ':')
+ goto restore;
+ break;
+ }
+ break;
+ case '\a':
+ a = FONT_ITALIC;
+ setfont:
+ if (f & ~a)
+ {
+ sfputr(sp, font(f, style, 0), -1);
+ f = 0;
+ }
+ if (!f && style == STYLE_html)
+ {
+ for (t = s; t < e && !isspace(*t) && !iscntrl(*t); t++);
+ if (*t == c && *++t == '(')
+ {
+ w = t;
+ while (++t < e && isdigit(*t));
+ if (t < e && *t == ')' && t > w + 1)
+ {
+ sfprintf(sp, "<NOBR><A href=\"../man%-.*s/%-.*s.html\">%s%-.*s%s</A>%-.*s</NOBR>"
+ , t - w - 1, w + 1
+ , w - s - 1, s
+ , font(a, style, 1)
+ , w - s - 1, s
+ , font(a, style, 0)
+ , t - w + 1, w
+ );
+ s = t + 1;
+ continue;
+ }
+ }
+ }
+ sfputr(sp, font(a, style, !!(f ^= a)), -1);
+ continue;
+ case '\b':
+ a = FONT_BOLD;
+ goto setfont;
+ case '\f':
+ psp = info(psp, s, e, ip);
+ if (psp->nb)
+ {
+ s = psp->nb;
+ e = psp->ne;
+ }
+ else
+ {
+ s = psp->ob;
+ psp = psp->next;
+ }
+ continue;
+ case '\n':
+ sfputc(sp, c);
+ for (i = 0; i < level; i++)
+ sfputc(sp, '\t');
+ continue;
+ case '\v':
+ a = FONT_LITERAL;
+ goto setfont;
+ case '<':
+ if (style == STYLE_html)
+ {
+ sfputr(sp, "&lt;", -1);
+ c = 0;
+ for (t = s; t < e; t++)
+ if (!isalnum(*t) && *t != '_' && *t != '.' && *t != '-')
+ {
+ if (*t == '@')
+ {
+ if (c)
+ break;
+ c = 1;
+ }
+ else if (*t == '>')
+ {
+ if (c)
+ {
+ sfprintf(sp, "<A href=\"mailto:%-.*s>%-.*s</A>&gt;", t - s, s, t - s, s);
+ s = t + 1;
+ }
+ break;
+ }
+ else
+ break;
+ }
+ continue;
+ }
+ break;
+ case '>':
+ if (style == STYLE_html)
+ {
+ sfputr(sp, "&gt;", -1);
+ continue;
+ }
+ break;
+ case '&':
+ if (style == STYLE_html)
+ {
+ sfputr(sp, "&amp;", -1);
+ continue;
+ }
+ break;
+ case '-':
+ if (ostyle == STYLE_nroff)
+ sfputc(sp, '\\');
+ break;
+ case '.':
+ if (ostyle == STYLE_nroff)
+ {
+ sfputc(sp, '\\');
+ sfputc(sp, '&');
+ }
+ break;
+ case '\\':
+ if (ostyle == STYLE_nroff)
+ {
+ c = 'e';
+ sfputc(sp, '\\');
+ }
+ break;
+ case ' ':
+ if (ostyle == STYLE_nroff)
+ sfputc(sp, '\\');
+ break;
+ }
+ sfputc(sp, c);
+ }
+ restore:
+ if (f)
+ sfputr(sp, font(f, style, 0), -1);
+ if (psp)
+ pop(psp);
+ return r;
+}
+
+/*
+ * output args description to sp from p of length n
+ */
+
+static void
+args(register Sfio_t* sp, register char* p, register int n, int flags, int style, Sfio_t* ip, int version, char* catalog)
+{
+ register int i;
+ register char* t;
+ register char* o;
+ register char* a = 0;
+ char* b;
+ int sep;
+
+ if (flags & OPT_functions)
+ sep = '\t';
+ else
+ {
+ sep = ' ';
+ o = T(NiL, ID, "options");
+ b = style == STYLE_nroff ? "\\ " : " ";
+ for (;;)
+ {
+ t = (char*)memchr(p, '\n', n);
+ if (style >= STYLE_man)
+ {
+ if (!(a = error_info.id))
+ a = "...";
+ sfprintf(sp, "\t%s%s%s%s[%s%s%s%s%s]", font(FONT_BOLD, style, 1), a, font(FONT_BOLD, style, 0), b, b, font(FONT_ITALIC, style, 1), o, font(FONT_ITALIC, style, 0), b);
+ }
+ else if (a)
+ sfprintf(sp, "%*.*s%s%s%s[%s%s%s]", OPT_USAGE - 1, OPT_USAGE - 1, T(NiL, ID, "Or:"), b, a, b, b, o, b);
+ else
+ {
+ if (!(a = error_info.id))
+ a = "...";
+ if (!sfstrtell(sp))
+ sfprintf(sp, "[%s%s%s]", b, o, b);
+ }
+ if (!t)
+ break;
+ i = ++t - p;
+ if (i)
+ {
+ sfputr(sp, b, -1);
+ if (X(catalog))
+ {
+ sfwrite(ip, p, i);
+ if (b = sfstruse(ip))
+ sfputr(sp, T(error_info.id, catalog, b), -1);
+ else
+ sfwrite(sp, p, i);
+ }
+ else
+ sfwrite(sp, p, i);
+ }
+ if (style == STYLE_html)
+ sfputr(sp, "<BR>", '\n');
+ else if (style == STYLE_nroff)
+ sfputr(sp, ".br", '\n');
+ else if (style == STYLE_api)
+ sfputr(sp, ".BR", '\n');
+ p = t;
+ n -= i;
+ while (n > 0 && (*p == ' ' || *p == '\t'))
+ {
+ p++;
+ n--;
+ }
+ }
+ }
+ if (n)
+ label(sp, sep, p, n, 0, style, 0, ip, version, catalog);
+}
+
+/*
+ * output [+-...label...?...] label s to sp
+ * according to {...} level and style
+ * return 0:header 1:paragraph
+ */
+
+static int
+item(Sfio_t* sp, char* s, int level, int style, Sfio_t* ip, int version, char* catalog)
+{
+ register char* t;
+ int n;
+ int par;
+
+ sfputc(sp, '\n');
+ if (*s == '\n')
+ {
+ par = 0;
+ if (style >= STYLE_nroff)
+ sfprintf(sp, ".DS\n");
+ else
+ {
+ if (style == STYLE_html)
+ sfprintf(sp, "<PRE>\n");
+ else
+ sfputc(sp, '\n');
+ for (n = 0; n < level; n++)
+ sfputc(sp, '\t');
+ }
+ label(sp, 0, s + 1, -1, level, style, FONT_LITERAL, ip, version, catalog);
+ sfputc(sp, '\n');
+ if (style >= STYLE_nroff)
+ sfprintf(sp, ".DE");
+ else if (style == STYLE_html)
+ sfprintf(sp, "</PRE>");
+ }
+ else if (*s != ']' && (*s != '?' || *(s + 1) == '?'))
+ {
+ par = 0;
+ if (level)
+ {
+ if (style >= STYLE_nroff)
+ sfprintf(sp, ".H%d ", (level + 1) / 2);
+ else
+ for (n = 0; n < level; n++)
+ sfputc(sp, '\t');
+ }
+ if (style == STYLE_html)
+ {
+ if (!level)
+ sfputr(sp, "<H4>", -1);
+ sfputr(sp, "<A name=\"", -1);
+ if (s[-1] == '-' && s[0] == 'l' && s[1] == 'i' && s[2] == 'c' && s[3] == 'e' && s[4] == 'n' && s[5] == 's' && s[6] == 'e' && s[7] == '?')
+ for (t = s + 8; *t && *t != ']'; t++)
+ if (t[0] == 'p' && (!strncmp(t, "proprietary", 11) || !strncmp(t, "private", 7)) || t[0] == 'n' && !strncmp(t, "noncommercial", 13))
+ {
+ opt_info.state->flags |= OPT_proprietary;
+ break;
+ }
+ label(sp, 0, s, -1, level, 0, 0, ip, version, catalog);
+ sfputr(sp, "\">", -1);
+ label(sp, 0, s, -1, level, style, level ? FONT_BOLD : 0, ip, version, catalog);
+ sfputr(sp, "</A>", -1);
+ if (!level)
+ sfputr(sp, "</H4>", -1);
+ }
+ else
+ {
+ if (!level)
+ {
+ if (style >= STYLE_nroff)
+ sfprintf(sp, ".SH ");
+ else if (style == STYLE_man)
+ sfputc(sp, '\n');
+ else if (style != STYLE_options && style != STYLE_match || *s == '-' || *s == '+')
+ sfputc(sp, '\t');
+ }
+ label(sp, 0, s, -1, level, style, FONT_BOLD, ip, version, catalog);
+ }
+ }
+ else
+ {
+ par = 1;
+ if (style >= STYLE_nroff)
+ sfputr(sp, ".PP", -1);
+ }
+ if (style >= STYLE_nroff || !level)
+ sfputc(sp, '\n');
+ if (par && style < STYLE_nroff)
+ for (n = 0; n < level; n++)
+ sfputc(sp, '\t');
+ return par;
+}
+
+/*
+ * output text to sp from p according to style
+ */
+
+static char*
+textout(Sfio_t* sp, register char* p, int style, int level, int bump, Sfio_t* ip, int version, char* catalog)
+{
+#if 0
+#define textout(a,b,c,d,e,f,g,h) (sfprintf(a,"(%d)",__LINE__),textout(a,b,c,d,e,f,g,h))
+#endif
+ register char* t;
+ register int c;
+ register int n;
+ char* e;
+ int a;
+ int f;
+ int par;
+ Push_t* tsp;
+
+ int ident = 0;
+ int lev = level;
+ Push_t* psp = 0;
+
+ again:
+ if ((c = *p) == GO)
+ {
+ for (;;)
+ {
+ while (*(p = next(p + 1, version)) == '\n');
+ if (*p == GO)
+ {
+ if (level > 1)
+ level++;
+ level++;
+ }
+ else if (*p != OG)
+ {
+ if (level <= 1 || *p != '[' || *(p + 1) != '-')
+ break;
+ p = skip(p, 0, 0, 0, 1, level, 0, version);
+ }
+ else if ((level -= 2) <= lev)
+ return p + 1;
+ }
+ if (*p == '\f')
+ {
+ psp = info(psp, p + 1, NiL, ip);
+ if (psp->nb)
+ p = psp->nb;
+ else
+ {
+ p = psp->ob;
+ psp = psp->next;
+ }
+ }
+ if (*p != '[')
+ return p;
+ c = *++p;
+ if (level > 1)
+ level++;
+ level++;
+ }
+ if (c == '-' && level > 1)
+ return skip(p, 0, 0, 0, 1, level, 1, version);
+ if (c == '+' || c == '-' && (bump = 3) || c != ' ' && level > 1)
+ {
+ p = skip(t = p + 1, '?', 0, 0, 1, level, 0, version);
+ if (c == '-' && (*t == '?' || *t >= '0' && *t <= '9'))
+ {
+ if ((c = *p) != '?')
+ return skip(p, 0, 0, 0, 1, level, 1, version);
+ par = item(sp, C("version"), level, style, ip, version, ID);
+ for (;;)
+ {
+ while (isspace(*(p + 1)))
+ p++;
+ e = p;
+ if (e[1] == '@' && e[2] == '(' && e[3] == '#' && e[4] == ')')
+ p = e + 4;
+ else if (e[1] == '$' && e[2] == 'I' && e[3] == 'd' && e[4] == ':' && e[5] == ' ')
+ {
+ p = e + 5;
+ ident = 1;
+ }
+ else
+ break;
+ }
+ }
+ else
+ {
+ if (isdigit(c) && isdigit(*t))
+ {
+ while (isdigit(*t))
+ t++;
+ if (*t == ':')
+ t++;
+ }
+ else if (isalnum(c) && *t-- == ':')
+ {
+ if (X(catalog) || *t == *(t + 2))
+ t += 2;
+ else
+ {
+ sfprintf(ip, "%s", t);
+ if (e = sfstruse(ip))
+ *((t = e) + 1) = '|';
+ }
+ }
+ par = item(sp, t, level, style, ip, version, catalog);
+ c = *p;
+ }
+ if (level)
+ par = 0;
+ }
+ else
+ {
+ if (style >= STYLE_nroff)
+ sfputc(sp, '\n');
+ else if (c == '?')
+ for (n = 0; n < level; n++)
+ sfputc(sp, '\t');
+ par = 0;
+ }
+ if (c == ':')
+ c = *(p = skip(p, '?', 0, 0, 1, 0, 0, version));
+ if ((c == ']' || c == '?' && *(p + 1) == ']' && *(p + 2) != ']' && p++) && (c = *(p = next(p + 1, version))) == GO)
+ p = textout(sp, p, style, level + bump + par + 1, 0, ip, version, catalog);
+ else if (c == '?' || c == ' ')
+ {
+ p++;
+ if (c == ' ')
+ sfputc(sp, c);
+ else
+ {
+ if (X(catalog) && (tsp = localize(psp, p, NiL, 0, 1, catalog, version, ip)))
+ {
+ psp = tsp;
+ p = psp->nb;
+ }
+ if (style < STYLE_nroff)
+ for (n = 0; n < bump + 1; n++)
+ sfputc(sp, '\t');
+ }
+ f = 0;
+ for (;;)
+ {
+ switch (c = *p++)
+ {
+ case 0:
+ if (!(tsp = psp))
+ {
+ if (f)
+ sfputr(sp, font(f, style, 0), -1);
+ return p - 1;
+ }
+ p = psp->ob;
+ psp = psp->next;
+ free(tsp);
+ continue;
+ case ']':
+ if (psp && psp->ch)
+ break;
+ if (*p != ']')
+ {
+ if (f)
+ {
+ sfputr(sp, font(f, style, 0), -1);
+ f = 0;
+ }
+ for (;;)
+ {
+ if ((*p == '#' || *p == ':') && level > lev)
+ {
+ char* o;
+ char* v;
+ int j;
+ int m;
+ int ol;
+ int vl;
+
+ a = 0;
+ o = 0;
+ v = 0;
+ if (*++p == '?' || *p == *(p - 1))
+ {
+ p++;
+ a |= OPT_optional;
+ }
+ if (*(p = next(p, version)) == '[')
+ {
+ p = skip(p + 1, ':', '?', 0, 1, 0, 0, version);
+ while (*p == ':')
+ {
+ p = skip(t = p + 1, ':', '?', 0, 1, 0, 0, version);
+ m = p - t;
+ if (*t == '!')
+ {
+ o = t + 1;
+ ol = m - 1;
+ }
+ else if (*t == '=')
+ {
+ v = t + 1;
+ vl = m - 1;
+ }
+ else
+ for (j = 0; j < elementsof(attrs); j++)
+ if (strneq(t, attrs[j].name, m))
+ {
+ a |= attrs[j].flag;
+ break;
+ }
+ }
+ }
+ if (a & OPT_optional)
+ {
+ if (o)
+ {
+ sfprintf(sp, " %s ", T(NiL, ID, "If the option value is omitted then"));
+ sfputr(sp, font(FONT_BOLD, style, 1), -1);
+ t = o + ol;
+ while (o < t)
+ {
+ if (((c = *o++) == ':' || c == '?') && *o == c)
+ o++;
+ sfputc(sp, c);
+ }
+ sfputr(sp, font(FONT_BOLD, style, 0), -1);
+ sfprintf(sp, " %s.", T(NiL, ID, "is assumed"));
+ }
+ else
+ sfprintf(sp, " %s", T(NiL, ID, "The option value may be omitted."));
+ }
+ if (v)
+ {
+ sfprintf(sp, " %s ", T(NiL, ID, "The default value is"));
+ sfputr(sp, font(FONT_BOLD, style, 1), -1);
+ t = v + vl;
+ while (v < t)
+ {
+ if (((c = *v++) == ':' || c == '?') && *v == c)
+ v++;
+ sfputc(sp, c);
+ }
+ sfputr(sp, font(FONT_BOLD, style, 0), -1);
+ sfputc(sp, '.');
+ }
+ p = skip(p, 0, 0, 0, 1, 0, 1, version);
+ }
+ if (*(p = next(p, version)) == GO)
+ p = textout(sp, p, style, level + bump + !level, 0, ip, version, catalog);
+ else if (*p == '[' && level > lev)
+ {
+ p++;
+ goto again;
+ }
+ else if (*p == '\f')
+ {
+ p++;
+ if (style != STYLE_keys)
+ {
+ psp = info(psp, p, NiL, ip);
+ if (psp->nb)
+ p = psp->nb;
+ else
+ {
+ p = psp->ob;
+ psp = psp->next;
+ }
+ }
+ }
+ else if (!*p)
+ {
+ if (!(tsp = psp))
+ break;
+ p = psp->ob;
+ psp = psp->next;
+ free(tsp);
+ }
+ else if (*p != OG)
+ break;
+ else
+ {
+ p++;
+ if ((level -= 2) <= lev)
+ break;
+ }
+ }
+ return p;
+ }
+ p++;
+ break;
+ case '\a':
+ a = FONT_ITALIC;
+ setfont:
+ if (f & ~a)
+ {
+ sfputr(sp, font(f, style, 0), -1);
+ f = 0;
+ }
+ if (!f && style == STYLE_html)
+ {
+ for (t = p; *t && !isspace(*t) && !iscntrl(*t); t++);
+ if (*t == c && *++t == '(')
+ {
+ e = t;
+ while (isdigit(*++t));
+ if (*t == ')' && t > e + 1)
+ {
+ sfprintf(sp, "<NOBR><A href=\"../man%-.*s/%-.*s.html\">%s%-.*s%s</A>%-.*s</NOBR>"
+ , t - e - 1, e + 1
+ , e - p - 1, p
+ , font(a, style, 1)
+ , e - p - 1, p
+ , font(a, style, 0)
+ , t - e + 1, e
+ );
+ p = t + 1;
+ continue;
+ }
+ }
+ }
+ sfputr(sp, font(a, style, !!(f ^= a)), -1);
+ continue;
+ case '\b':
+ a = FONT_BOLD;
+ goto setfont;
+ case '\f':
+ if (style != STYLE_keys)
+ {
+ psp = info(psp, p, NiL, ip);
+ if (psp->nb)
+ p = psp->nb;
+ else
+ {
+ p = psp->ob;
+ psp = psp->next;
+ }
+ }
+ continue;
+ case '\v':
+ a = FONT_LITERAL;
+ goto setfont;
+ case ' ':
+ if (ident && *p == '$')
+ {
+ while (*++p)
+ if (*p == ']')
+ {
+ if (*(p + 1) != ']')
+ break;
+ p++;
+ }
+ continue;
+ }
+ case '\n':
+ case '\r':
+ case '\t':
+ while (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n')
+ p++;
+ if (*p == ']' && *(p + 1) != ']' && (!psp || !psp->ch))
+ continue;
+ c = ' ';
+ break;
+ case '<':
+ if (style == STYLE_html)
+ {
+ sfputr(sp, "&lt;", -1);
+ c = 0;
+ for (t = p; *t; t++)
+ if (!isalnum(*t) && *t != '_' && *t != '.' && *t != '-')
+ {
+ if (*t == '@')
+ {
+ if (c)
+ break;
+ c = 1;
+ }
+ else if (*t == '>')
+ {
+ if (c)
+ {
+ sfprintf(sp, "<A href=\"mailto:%-.*s\">%-.*s</A>&gt;", t - p, p, t - p, p);
+ p = t + 1;
+ }
+ break;
+ }
+ else
+ break;
+ }
+ continue;
+ }
+ break;
+ case '>':
+ if (style == STYLE_html)
+ {
+ sfputr(sp, "&gt;", -1);
+ continue;
+ }
+ break;
+ case '&':
+ if (style == STYLE_html)
+ {
+ sfputr(sp, "&amp;", -1);
+ continue;
+ }
+ break;
+ case '-':
+ if (style == STYLE_nroff)
+ sfputc(sp, '\\');
+ break;
+ case '.':
+ if (style == STYLE_nroff)
+ {
+ sfputc(sp, '\\');
+ sfputc(sp, '&');
+ }
+ break;
+ case '\\':
+ if (style == STYLE_nroff)
+ {
+ sfputc(sp, c);
+ c = 'e';
+ }
+ break;
+ }
+ sfputc(sp, c);
+ }
+ }
+ else if (c == '[' && level > lev)
+ {
+ p++;
+ goto again;
+ }
+ return p;
+}
+
+/*
+ * generate optget() help [...] list from lp
+ */
+
+static void
+list(Sfio_t* sp, register const List_t* lp)
+{
+ sfprintf(sp, "[%c", lp->type);
+ if (lp->name)
+ {
+ sfprintf(sp, "%s", lp->name);
+ if (lp->text)
+ sfprintf(sp, "?%s", lp->text);
+ }
+ sfputc(sp, ']');
+}
+
+/*
+ * return pointer to help message sans `Usage: command'
+ * if oopts is 0 then opt_info.state->pass is used
+ * what:
+ * 0 ?short by default, ?long if any long options used
+ * * otherwise see help_text[] (--???)
+ * external formatter:
+ * \a...\a italic
+ * \b...\b bold
+ * \f...\f discipline infof callback on ...
+ * \v...\v literal
+ * internal formatter:
+ * \t indent
+ * \n newline
+ * margin flush pops to previous indent
+ */
+
+char*
+opthelp(const char* oopts, const char* what)
+{
+ register Sfio_t* sp;
+ register Sfio_t* mp;
+ register int c;
+ register char* p;
+ register Indent_t* ip;
+ char* t;
+ char* x;
+ char* w;
+ char* u;
+ char* y;
+ char* s;
+ char* d;
+ char* v;
+ char* ov;
+ char* name;
+ char* pp;
+ char* rb;
+ char* re;
+ int f;
+ int i;
+ int j;
+ int m;
+ int n;
+ int a;
+ int sl;
+ int vl;
+ int ol;
+ int wl;
+ int xl;
+ int rm;
+ int ts;
+ int co;
+ int z;
+ int style;
+ int head;
+ int mode;
+ int mutex;
+ int prefix;
+ int version;
+ long tp;
+ char* catalog;
+ Optpass_t* o;
+ Optpass_t* q;
+ Optpass_t* e;
+ Optpass_t one;
+ Help_t* hp;
+ short ptstk[elementsof(indent) + 2];
+ short* pt;
+ Sfio_t* vp;
+ Push_t* tsp;
+
+ char* opts = (char*)oopts;
+ int flags = 0;
+ int matched = 0;
+ int paragraph = 0;
+ int section = 1;
+ Push_t* psp = 0;
+ Sfio_t* sp_help = 0;
+ Sfio_t* sp_text = 0;
+ Sfio_t* sp_plus = 0;
+ Sfio_t* sp_head = 0;
+ Sfio_t* sp_body = 0;
+ Sfio_t* sp_info = 0;
+ Sfio_t* sp_misc = 0;
+
+ if (!(mp = opt_info.state->mp) && !(mp = opt_info.state->mp = sfstropen()))
+ goto nospace;
+ if (!what)
+ style = opt_info.state->style;
+ else if (!*what)
+ style = STYLE_options;
+ else if (*what != '?')
+ style = STYLE_match;
+ else if (!*(what + 1))
+ style = STYLE_man;
+ else if ((hp = (Help_t*)search(styles, elementsof(styles), sizeof(styles[0]), (char*)what + 1)) && hp->style >= 0)
+ {
+ style = hp->style;
+ if (*hp->name != '?')
+ what = hp->name;
+ }
+ else
+ {
+ if ((style = opt_info.state->force) < STYLE_man)
+ style = STYLE_man;
+ if (!(sp_help = sfstropen()))
+ goto nospace;
+ for (i = 0; i < elementsof(help_head); i++)
+ list(sp_help, &help_head[i]);
+ for (i = 0; i < elementsof(styles); i++)
+ sfprintf(sp_help, "[:%s?%s]", styles[i].match, styles[i].text);
+ for (i = 0; i < elementsof(help_tail); i++)
+ list(sp_help, &help_tail[i]);
+ if (!(opts = sfstruse(sp_help)))
+ goto nospace;
+ }
+ message((-20, "AHA#%d style=%d", __LINE__, style));
+ again:
+ if (opts)
+ {
+ for (i = 0; i < opt_info.state->npass; i++)
+ if (opt_info.state->pass[i].oopts == opts)
+ {
+ o = &opt_info.state->pass[i];
+ break;
+ }
+ if (i >= opt_info.state->npass)
+ {
+ o = &one;
+ if (init((char*)opts, o))
+ goto nospace;
+ }
+ e = o + 1;
+ }
+ else if (opt_info.state->npass > 0)
+ {
+ o = opt_info.state->pass;
+ e = o + opt_info.state->npass;
+ }
+ else if (opt_info.state->npass < 0)
+ {
+ o = &opt_info.state->cache->pass;
+ e = o + 1;
+ }
+ else
+ return T(NiL, ID, "[* call optget() before opthelp() *]");
+ if (style < STYLE_usage)
+ {
+ if (!(sp_text = sfstropen()) || !(sp_info = sfstropen()))
+ goto nospace;
+ if (style >= STYLE_match && style < STYLE_keys && !(sp_body = sfstropen()))
+ goto nospace;
+ }
+ switch (style)
+ {
+ case STYLE_api:
+ case STYLE_html:
+ case STYLE_nroff:
+ opt_info.state->emphasis = 0;
+ break;
+ case STYLE_usage:
+ case STYLE_keys:
+ for (q = o; q < e; q++)
+ if (!(q->flags & OPT_ignore) && !streq(q->catalog, o->catalog))
+ o = q;
+ /*FALLTHROUGH*/
+ case STYLE_posix:
+ sfputc(mp, '\f');
+ break;
+ default:
+ if (!opt_info.state->emphasis)
+ {
+ if (x = getenv("ERROR_OPTIONS"))
+ {
+ if (strmatch(x, "*noemphasi*"))
+ break;
+ if (strmatch(x, "*emphasi*"))
+ {
+ opt_info.state->emphasis = 1;
+ break;
+ }
+ }
+ if ((x = getenv("TERM")) && strmatch(x, "(ansi|vt100|xterm)*") && isatty(sffileno(sfstderr)))
+ opt_info.state->emphasis = 1;
+ }
+ break;
+ }
+ x = "";
+ xl = 0;
+ for (q = o; q < e; q++)
+ {
+ if (q->flags & OPT_ignore)
+ continue;
+ if (section < q->section)
+ section = q->section;
+ section = q->section;
+ flags |= q->flags;
+ p = q->opts;
+ prefix = q->prefix;
+ version = q->version;
+ catalog = q->catalog;
+ switch (style)
+ {
+ case STYLE_usage:
+ if (xl)
+ sfputc(mp, '\n');
+ else
+ xl = 1;
+ while (c = *p++)
+ {
+ switch (c)
+ {
+ case '\a':
+ c = 'a';
+ break;
+ case '\b':
+ c = 'b';
+ break;
+ case '\f':
+ c = 'f';
+ break;
+ case '\n':
+ c = 'n';
+ break;
+ case '\r':
+ c = 'r';
+ break;
+ case '\t':
+ c = 't';
+ break;
+ case '\v':
+ c = 'v';
+ break;
+ case '"':
+ c = '"';
+ break;
+ case '\'':
+ c = '\'';
+ break;
+ case '\\':
+ c = '\\';
+ break;
+ default:
+ sfputc(mp, c);
+ continue;
+ }
+ sfputc(mp, '\\');
+ sfputc(mp, c);
+ }
+ continue;
+ case STYLE_keys:
+ a = 0;
+ psp = 0;
+ vl = 0;
+ for (;;)
+ {
+ if (!(c = *p++))
+ {
+ if (!(tsp = psp))
+ break;
+ p = psp->ob;
+ psp = psp->next;
+ free(tsp);
+ continue;
+ }
+ if (c == '\f')
+ {
+ psp = info(psp, p, NiL, sp_info);
+ if (psp->nb)
+ p = psp->nb;
+ else
+ {
+ p = psp->ob;
+ psp = psp->next;
+ }
+ continue;
+ }
+ f = z = 1;
+ t = 0;
+ if (a == 0 && (c == ' ' || c == '\n' && *p == '\n'))
+ {
+ if (c == ' ' && *p == ']')
+ {
+ p++;
+ continue;
+ }
+ if (*p == '\n')
+ p++;
+ a = c;
+ }
+ else if (c == '\n')
+ {
+ if (a == ' ')
+ a = -1;
+ else if (a == '\n' || *p == '\n')
+ {
+ a = -1;
+ p++;
+ }
+ continue;
+ }
+ else if ((c == ':' || c == '#') && (*p == '[' || *p == '?' && *(p + 1) == '[' && p++))
+ p++;
+ else if (c != '[')
+ {
+ if (c == '{')
+ vl++;
+ else if (c == '}')
+ vl--;
+ continue;
+ }
+ else if (*p == ' ')
+ {
+ p++;
+ continue;
+ }
+ else if (*p == '-')
+ {
+ z = 0;
+ if (*++p == '-')
+ {
+ p = skip(p, 0, 0, 0, 1, 0, 1, version);
+ continue;
+ }
+ }
+ else if (*p == '+')
+ {
+ p++;
+ if (vl > 0 && *p != '\a')
+ {
+ f = 0;
+ p = skip(p, '?', 0, 0, 1, 0, 0, version);
+ if (*p == '?')
+ p++;
+ }
+ }
+ else
+ {
+ if (*(p + 1) == '\f' && (vp = opt_info.state->vp))
+ p = expand(p + 2, NiL, &t, vp);
+ p = skip(p, ':', '?', 0, 1, 0, 0, version);
+ if (*p == ':')
+ p++;
+ }
+ if (f && *p == '?' && *(p + 1) != '?')
+ {
+ f = 0;
+ if (z)
+ p++;
+ else
+ p = skip(p, 0, 0, 0, 1, 0, 0, version);
+ }
+ if (*p == ']' && *(p + 1) != ']')
+ {
+ p++;
+ continue;
+ }
+ if (!*p)
+ {
+ if (!t)
+ break;
+ p = t;
+ t = 0;
+ }
+ m = sfstrtell(mp);
+ sfputc(mp, '"');
+ xl = 1;
+ /*UNDENT...*/
+
+ for (;;)
+ {
+ if (!(c = *p++))
+ {
+ if (t)
+ {
+ p = t;
+ t = 0;
+ }
+ if (!(tsp = psp))
+ {
+ p--;
+ break;
+ }
+ p = psp->ob;
+ psp = psp->next;
+ free(tsp);
+ continue;
+ }
+ if (a > 0)
+ {
+ if (c == '\n')
+ {
+ if (a == ' ')
+ {
+ a = -1;
+ break;
+ }
+ if (a == '\n' || *p == '\n')
+ {
+ a = -1;
+ p++;
+ break;
+ }
+ }
+ }
+ else if (c == ']')
+ {
+ if (*p != ']')
+ {
+ sfputc(mp, 0);
+ y = sfstrbase(mp) + m + 1;
+ if (D(y) || !strmatch(y, KEEP) || strmatch(y, OMIT))
+ {
+ sfstrseek(mp, m, SEEK_SET);
+ xl = 0;
+ }
+ else
+ sfstrseek(mp, -1, SEEK_CUR);
+ break;
+ }
+ sfputc(mp, *p++);
+ continue;
+ }
+ switch (c)
+ {
+ case '?':
+ if (f)
+ {
+ if (*p == '?')
+ {
+ p++;
+ sfputc(mp, c);
+ }
+ else
+ {
+ f = 0;
+ sfputc(mp, 0);
+ y = sfstrbase(mp) + m + 1;
+ if (D(y) || !strmatch(y, KEEP) || strmatch(y, OMIT))
+ {
+ sfstrseek(mp, m, SEEK_SET);
+ xl = 0;
+ }
+ else
+ sfstrseek(mp, -1, SEEK_CUR);
+ if (z && (*p != ']' || *(p + 1) == ']'))
+ {
+ if (xl)
+ {
+ sfputc(mp, '"');
+ sfputc(mp, '\n');
+ }
+ m = sfstrtell(mp);
+ sfputc(mp, '"');
+ xl = 1;
+ }
+ else
+ {
+ p = skip(p, 0, 0, 0, 1, 0, 0, version);
+ if (*p == '?')
+ p++;
+ }
+ }
+ }
+ else
+ sfputc(mp, c);
+ continue;
+ case ':':
+ if (f && *p == ':')
+ p++;
+ sfputc(mp, c);
+ continue;
+ case '\a':
+ c = 'a';
+ break;
+ case '\b':
+ c = 'b';
+ break;
+ case '\f':
+ c = 'f';
+ break;
+ case '\n':
+ c = 'n';
+ break;
+ case '\r':
+ c = 'r';
+ break;
+ case '\t':
+ c = 't';
+ break;
+ case '\v':
+ c = 'v';
+ break;
+ case '"':
+ c = '"';
+ break;
+ case '\\':
+ c = '\\';
+ break;
+ case CC_esc:
+ c = 'E';
+ break;
+ default:
+ sfputc(mp, c);
+ continue;
+ }
+ sfputc(mp, '\\');
+ sfputc(mp, c);
+ }
+
+ /*...INDENT*/
+ if (xl)
+ {
+ sfputc(mp, '"');
+ sfputc(mp, '\n');
+ }
+ }
+ continue;
+ }
+ z = 0;
+ head = 0;
+ mode = 0;
+ mutex = 0;
+ if (style > STYLE_short && style < STYLE_nroff && version < 1)
+ {
+ style = STYLE_short;
+ if (sp_body)
+ {
+ sfclose(sp_body);
+ sp_body = 0;
+ }
+ }
+ else if (style == STYLE_short && prefix < 2)
+ style = STYLE_long;
+ if (*p == ':')
+ p++;
+ if (*p == '+')
+ {
+ p++;
+ if (!(sp = sp_plus) && !(sp = sp_plus = sfstropen()))
+ goto nospace;
+ }
+ else if (style >= STYLE_match)
+ sp = sp_body;
+ else
+ sp = sp_text;
+ psp = 0;
+ for (;;)
+ {
+ if (!(*(p = next(p, version))))
+ {
+ if (!(tsp = psp))
+ break;
+ p = psp->ob;
+ psp = psp->next;
+ free(tsp);
+ continue;
+ }
+ if (*p == '\f')
+ {
+ psp = info(psp, p + 1, NiL, sp_info);
+ if (psp->nb)
+ p = psp->nb;
+ else
+ {
+ p = psp->ob;
+ psp = psp->next;
+ }
+ continue;
+ }
+ if (*p == '\n' || *p == ' ')
+ {
+ if (*(x = p = next(p + 1, version)))
+ while (*++p)
+ if (*p == '\n')
+ {
+ while (*++p == ' ' || *p == '\t' || *p == '\r');
+ if (*p == '\n')
+ break;
+ }
+ xl = p - x;
+ if (!*p)
+ break;
+ continue;
+ }
+ if (*p == '}')
+ {
+ p++;
+ continue;
+ }
+ message((-20, "opthelp: opt %s", show(p)));
+ if (z < 0)
+ z = 0;
+ a = 0;
+ f = 0;
+ w = 0;
+ d = 0;
+ s = 0;
+ sl = 0;
+ if (*p == '[')
+ {
+ if ((c = *(p = next(p + 1, version))) == '-')
+ {
+ if (style >= STYLE_man)
+ {
+ if (*(p + 1) != '-')
+ {
+ if (!sp_misc && !(sp_misc = sfstropen()))
+ goto nospace;
+ else
+ p = textout(sp_misc, p, style, 1, 3, sp_info, version, catalog);
+ continue;
+ }
+ }
+ else if (style == STYLE_match && *what == '-')
+ {
+ if (*(p + 1) == '?' || *(p + 1) >= '0' && *(p + 1) <= '9')
+ s = C("version");
+ else
+ s = p + 1;
+ w = (char*)what;
+ if (*s != '-' || *(w + 1) == '-')
+ {
+ if (*s == '-')
+ s++;
+ if (*(w + 1) == '-')
+ w++;
+ if (match(w + 1, s, version, catalog))
+ {
+ if (*(p + 1) == '-')
+ p++;
+ p = textout(sp, p, style, 1, 3, sp_info, version, catalog);
+ matched = -1;
+ continue;
+ }
+ }
+ }
+ if (!z)
+ z = -1;
+ }
+ else if (c == '+')
+ {
+ if (style >= STYLE_man)
+ {
+ p = textout(sp_body, p, style, 0, 0, sp_info, version, catalog);
+ if (!sp_head)
+ {
+ sp_head = sp_body;
+ if (!(sp_body = sfstropen()))
+ goto nospace;
+ }
+ continue;
+ }
+ else if (style == STYLE_match && *what == '+')
+ {
+ if (paragraph)
+ {
+ if (p[1] == '?')
+ {
+ p = textout(sp, p, style, 1, 3, sp_info, version, catalog);
+ continue;
+ }
+ paragraph = 0;
+ }
+ if (match((char*)what + 1, p + 1, version, catalog))
+ {
+ p = textout(sp, p, style, 1, 3, sp_info, version, catalog);
+ matched = -1;
+ paragraph = 1;
+ continue;
+ }
+ }
+ if (!z)
+ z = -1;
+ }
+ else if (c == '[' || version < 1)
+ {
+ mutex++;
+ continue;
+ }
+ else
+ {
+ if (c == '!')
+ {
+ a |= OPT_invert;
+ p++;
+ }
+ rb = p;
+ if (*p != ':')
+ {
+ s = p;
+ if (*(p + 1) == '|')
+ {
+ while (*++p && *p != '=' && *p != '!' && *p != ':' && *p != '?');
+ if ((p - s) > 1)
+ sl = p - s;
+ if (*p == '!')
+ a |= OPT_invert;
+ }
+ if (*(p + 1) == '\f')
+ p++;
+ else
+ p = skip(p, ':', '?', 0, 1, 0, 0, version);
+ if (sl || (p - s) == 1 || *(s + 1) == '=' || *(s + 1) == '!' && (a |= OPT_invert) || *(s + 1) == '|')
+ f = *s;
+ }
+ re = p;
+ if (style <= STYLE_short)
+ {
+ if (!z && !f)
+ z = -1;
+ }
+ else
+ {
+ if (*p == '\f' && (vp = opt_info.state->vp))
+ p = expand(p + 1, NiL, &t, vp);
+ else
+ t = 0;
+ if (*p == ':')
+ {
+ p = skip(w = p + 1, ':', '?', 0, 1, 0, 0, version);
+ if (!(wl = p - w))
+ w = 0;
+ }
+ else
+ wl = 0;
+ if (*p == ':' || *p == '?')
+ {
+ d = p;
+ p = skip(p, 0, 0, 0, 1, 0, 0, version);
+ }
+ else
+ d = 0;
+ if (style == STYLE_match)
+ {
+ if (wl && !match((char*)what, w, version, catalog))
+ wl = 0;
+ if ((!wl || *w == ':' || *w == '?') && (what[1] || sl && !memchr(s, what[0], sl) || !sl && what[0] != f))
+ {
+ w = 0;
+ if (!z)
+ z = -1;
+ }
+ else
+ matched = 1;
+ }
+ if (t)
+ {
+ p = t;
+ if (*p == ':' || *p == '?')
+ {
+ d = p;
+ p = skip(p, 0, 0, 0, 1, 0, 0, version);
+ }
+ }
+ }
+ }
+ p = skip(p, 0, 0, 0, 1, 0, 1, version);
+ if (*p == GO)
+ p = skip(p + 1, 0, 0, 0, 0, 1, 1, version);
+ }
+ else if (*p == ']')
+ {
+ if (mutex)
+ {
+ if (style >= STYLE_nroff)
+ sfputr(sp_body, "\n.OP - - anyof", '\n');
+ if (!(mutex & 1))
+ {
+ mutex--;
+ if (style <= STYLE_long)
+ {
+ sfputc(sp_body, ' ');
+ sfputc(sp_body, ']');
+ }
+ }
+ mutex--;
+ }
+ p++;
+ continue;
+ }
+ else if (*p == '?')
+ {
+ if (style < STYLE_match)
+ z = 1;
+ mode |= OPT_hidden;
+ p++;
+ continue;
+ }
+ else if (*p == '\\' && style==STYLE_posix)
+ {
+ if (*++p)
+ p++;
+ continue;
+ }
+ else
+ {
+ f = *p++;
+ s = 0;
+ if (style == STYLE_match && !z)
+ z = -1;
+ }
+ if (!z)
+ {
+ if (style == STYLE_long || prefix < 2 || (q->flags & OPT_long))
+ f = 0;
+ else if (style <= STYLE_short)
+ w = 0;
+ if (!f && !w)
+ z = -1;
+ }
+ ov = u = v = y = 0;
+ if (*p == ':' && (a |= OPT_string) || *p == '#' && (a |= OPT_number))
+ {
+ message((-21, "opthelp: arg %s", show(p)));
+ if (*++p == '?' || *p == *(p - 1))
+ {
+ p++;
+ a |= OPT_optional;
+ }
+ if (*(p = next(p, version)) == '[')
+ {
+ if (!z)
+ {
+ p = skip(y = p + 1, ':', '?', 0, 1, 0, 0, version);
+ while (*p == ':')
+ {
+ p = skip(t = p + 1, ':', '?', 0, 1, 0, 0, version);
+ m = p - t;
+ if (*t == '!')
+ {
+ ov = t + 1;
+ ol = m - 1;
+ }
+ else if (*t == '=')
+ {
+ v = t + 1;
+ vl = m - 1;
+ }
+ else
+ for (j = 0; j < elementsof(attrs); j++)
+ if (strneq(t, attrs[j].name, m))
+ {
+ a |= attrs[j].flag;
+ break;
+ }
+ }
+ if (*p == '?')
+ u = p;
+ p = skip(p, 0, 0, 0, 1, 0, 1, version);
+ }
+ else
+ p = skip(p + 1, 0, 0, 0, 1, 0, 1, version);
+ }
+ else
+ y = (a & OPT_number) ? T(NiL, ID, "#") : T(NiL, ID, "arg");
+ }
+ else
+ a |= OPT_flag;
+ if (!z)
+ {
+ if (style <= STYLE_short && !y && !mutex || style == STYLE_posix)
+ {
+ if (style != STYLE_posix && !sfstrtell(sp))
+ {
+ sfputc(sp, '[');
+ if (sp == sp_plus)
+ sfputc(sp, '+');
+ sfputc(sp, '-');
+ }
+ if (!sl)
+ sfputc(sp, f);
+ else
+ for (c = 0; c < sl; c++)
+ if (s[c] != '|')
+ sfputc(sp, s[c]);
+ if (style == STYLE_posix && y)
+ sfputc(sp, ':');
+ }
+ else
+ {
+ if (style >= STYLE_match)
+ {
+ sfputc(sp_body, '\n');
+ if (!head)
+ {
+ head = 1;
+ item(sp_body, (flags & OPT_functions) ? C("FUNCTIONS") : C("OPTIONS"), 0, style, sp_info, version, ID);
+ }
+ if (style >= STYLE_nroff)
+ {
+ if (mutex & 1)
+ {
+ mutex++;
+ sfputr(sp_body, "\n.OP - - oneof", '\n');
+ }
+ }
+ else
+ sfputc(sp_body, '\t');
+ }
+ else
+ {
+ if (sp_body)
+ sfputc(sp_body, ' ');
+ else if (!(sp_body = sfstropen()))
+ goto nospace;
+ if (mutex)
+ {
+ if (mutex & 1)
+ {
+ mutex++;
+ sfputc(sp_body, '[');
+ }
+ else
+ sfputc(sp_body, '|');
+ sfputc(sp_body, ' ');
+ }
+ else
+ sfputc(sp_body, '[');
+ }
+ if (style >= STYLE_nroff)
+ {
+ if (flags & OPT_functions)
+ {
+ sfputr(sp_body, ".FN", ' ');
+ if (re > rb)
+ sfwrite(sp_body, rb, re - rb);
+ else
+ sfputr(sp, "void", -1);
+ if (w)
+ label(sp_body, ' ', w, -1, 0, style, FONT_BOLD, sp_info, version, catalog);
+ }
+ else
+ {
+ sfputr(sp_body, ".OP", ' ');
+ if (sl)
+ sfwrite(sp_body, s, sl);
+ else
+ sfputc(sp_body, f ? f : '-');
+ sfputc(sp_body, ' ');
+ if (w)
+ {
+ if (label(sp_body, 0, w, -1, 0, style, 0, sp_info, version, catalog))
+ {
+ sfputc(sp_body, '|');
+ label(sp_body, 0, w, -1, 0, style, 0, sp_info, version, native);
+ }
+ }
+ else
+ sfputc(sp_body, '-');
+ sfputc(sp_body, ' ');
+ m = a & OPT_TYPE;
+ for (j = 0; j < elementsof(attrs); j++)
+ if (m & attrs[j].flag)
+ {
+ sfputr(sp_body, attrs[j].name, -1);
+ break;
+ }
+ if (m = (a & ~m) | mode)
+ for (j = 0; j < elementsof(attrs); j++)
+ if (m & attrs[j].flag)
+ {
+ sfputc(sp_body, ':');
+ sfputr(sp_body, attrs[j].name, -1);
+ }
+ sfputc(sp_body, ' ');
+ if (y)
+ label(sp_body, 0, y, -1, 0, style, 0, sp_info, version, catalog);
+ else
+ sfputc(sp_body, '-');
+ if (v)
+ sfprintf(sp_body, " %-.*s", vl, v);
+ }
+ }
+ else
+ {
+ if (f)
+ {
+ if (sp_body == sp_plus)
+ sfputc(sp_body, '+');
+ sfputc(sp_body, '-');
+ sfputr(sp_body, font(FONT_BOLD, style, 1), -1);
+ if (!sl)
+ {
+ sfputc(sp_body, f);
+ if (f == '-' && y)
+ {
+ y = 0;
+ sfputr(sp_body, C("long-option[=value]"), -1);
+ }
+ }
+ else
+ sfwrite(sp_body, s, sl);
+ sfputr(sp_body, font(FONT_BOLD, style, 0), -1);
+ if (w)
+ {
+ sfputc(sp_body, ',');
+ sfputc(sp_body, ' ');
+ }
+ }
+ else if ((flags & OPT_functions) && re > rb)
+ {
+ sfwrite(sp_body, rb, re - rb);
+ sfputc(sp_body, ' ');
+ }
+ if (w)
+ {
+ if (prefix > 0)
+ {
+ sfputc(sp_body, '-');
+ if (prefix > 1)
+ sfputc(sp_body, '-');
+ }
+ if (label(sp_body, 0, w, -1, 0, style, FONT_BOLD, sp_info, version, catalog))
+ {
+ sfputc(sp_body, '|');
+ label(sp_body, 0, w, -1, 0, style, FONT_BOLD, sp_info, version, native);
+ }
+ }
+ if (y)
+ {
+ if (a & OPT_optional)
+ sfputc(sp_body, '[');
+ else if (!w)
+ sfputc(sp_body, ' ');
+ if (w)
+ sfputc(sp_body, prefix == 1 ? ' ' : '=');
+ label(sp_body, 0, y, -1, 0, style, FONT_ITALIC, sp_info, version, catalog);
+ if (a & OPT_optional)
+ sfputc(sp_body, ']');
+ }
+ }
+ if (style >= STYLE_match)
+ {
+ if (d)
+ textout(sp_body, d, style, 0, 3, sp_info, version, catalog);
+ if (u)
+ textout(sp_body, u, style, 0, 3, sp_info, version, catalog);
+ if ((a & OPT_invert) && w && (d || u))
+ {
+ u = skip(w, ':', '?', 0, 1, 0, 0, version);
+ if (f)
+ sfprintf(sp_info, " %s; -\b%c\b %s --\bno%-.*s\b.", T(NiL, ID, "On by default"), f, T(NiL, ID, "means"), u - w, w);
+ else
+ sfprintf(sp_info, " %s %s\bno%-.*s\b %s.", T(NiL, ID, "On by default; use"), "--"+2-prefix, u - w, w, T(NiL, ID, "to turn off"));
+ if (!(t = sfstruse(sp_info)))
+ goto nospace;
+ textout(sp_body, t, style, 0, 0, sp_info, version, NiL);
+ }
+ if (*p == GO)
+ {
+ p = u ? skip(p + 1, 0, 0, 0, 0, 1, 1, version) : textout(sp_body, p, style, 4, 0, sp_info, version, catalog);
+ y = "+?";
+ }
+ else
+ y = " ";
+ if (a & OPT_optional)
+ {
+ if (ov)
+ {
+ sfprintf(sp_info, "%s%s \b", y, T(NiL, ID, "If the option value is omitted then"));
+ t = ov + ol;
+ while (ov < t)
+ {
+ if (((c = *ov++) == ':' || c == '?') && *ov == c)
+ ov++;
+ sfputc(sp_info, c);
+ }
+ sfprintf(sp_info, "\b %s.", T(NiL, ID, "is assumed"));
+ }
+ else
+ sfprintf(sp_info, "%s%s", y, T(NiL, ID, "The option value may be omitted."));
+ if (!(t = sfstruse(sp_info)))
+ goto nospace;
+ textout(sp_body, t, style, 4, 0, sp_info, version, NiL);
+ y = " ";
+ }
+ if (v)
+ {
+ sfprintf(sp_info, "%s%s \b", y, T(NiL, ID, "The default value is"));
+ t = v + vl;
+ while (v < t)
+ {
+ if (((c = *v++) == ':' || c == '?') && *v == c)
+ v++;
+ sfputc(sp_info, c);
+ }
+ sfputc(sp_info, '\b');
+ sfputc(sp_info, '.');
+ if (!(t = sfstruse(sp_info)))
+ goto nospace;
+ textout(sp_body, t, style, 4, 0, sp_info, version, NiL);
+ }
+ }
+ else if (!mutex)
+ sfputc(sp_body, ']');
+ }
+ if (*p == GO)
+ {
+ if (style >= STYLE_match)
+ p = textout(sp_body, p, style, 4, 0, sp_info, version, catalog);
+ else
+ p = skip(p + 1, 0, 0, 0, 0, 1, 1, version);
+ }
+ }
+ else if (*p == GO)
+ p = skip(p + 1, 0, 0, 0, 0, 1, 1, version);
+ }
+ psp = pop(psp);
+ if (sp_misc)
+ {
+ if (!(p = sfstruse(sp_misc)))
+ goto nospace;
+ for (t = p; *t == '\t' || *t == '\n'; t++);
+ if (*t)
+ {
+ item(sp_body, C("IMPLEMENTATION"), 0, style, sp_info, version, ID);
+ sfputr(sp_body, p, -1);
+ }
+ }
+ }
+ version = o->version;
+ catalog = o->catalog;
+ if (style >= STYLE_keys)
+ {
+ if (sp_info)
+ sfclose(sp_info);
+ if (style == STYLE_keys && sfstrtell(mp) > 1)
+ sfstrseek(mp, -1, SEEK_CUR);
+ if (!(p = sfstruse(mp)))
+ goto nospace;
+ return opt_info.msg = p;
+ }
+ sp = sp_text;
+ if (sfstrtell(sp) && style != STYLE_posix)
+ sfputc(sp, ']');
+ if (style == STYLE_nroff)
+ {
+ sfprintf(sp, "\
+.\\\" format with nroff|troff|groff -man\n\
+.fp 5 CW\n\
+.nr mI 0\n\
+.de mI\n\
+.if \\\\n(mI>\\\\$1 \\{\n\
+. nr mI \\\\n(mI-1\n\
+. RE\n\
+.mI \\\\$1\n\
+.\\}\n\
+.if \\\\n(mI<\\\\$1 \\{\n\
+. nr mI \\\\n(mI+1\n\
+. RS\n\
+.mI \\\\$1\n\
+.\\}\n\
+..\n\
+.de H1\n\
+.mI 1\n\
+.TP\n\
+\\fB\\\\$1\\fP\n\
+..\n\
+.de H2\n\
+.mI 2\n\
+.TP\n\
+\\fB\\\\$1\\fP\n\
+..\n\
+.de H3\n\
+.mI 3\n\
+.TP\n\
+\\fB\\\\$1\\fP\n\
+..\n\
+.de H4\n\
+.mI 4\n\
+.TP\n\
+\\fB\\\\$1\\fP\n\
+..\n\
+.de OP\n\
+.mI 0\n\
+.ie !'\\\\$1'-' \\{\n\
+.ds mO \\\\fB\\\\-\\\\$1\\\\fP\n\
+.ds mS ,\\\\0\n\
+.\\}\n\
+.el \\{\n\
+.ds mO \\\\&\n\
+.ds mS \\\\&\n\
+.\\}\n\
+.ie '\\\\$2'-' \\{\n\
+.if !'\\\\$4'-' .as mO \\\\0\\\\fI\\\\$4\\\\fP\n\
+.\\}\n\
+.el \\{\n\
+.as mO \\\\*(mS\\\\fB%s\\\\$2\\\\fP\n\
+.if !'\\\\$4'-' .as mO =\\\\fI\\\\$4\\\\fP\n\
+.\\}\n\
+.TP\n\
+\\\\*(mO\n\
+..\n\
+.de FN\n\
+.mI 0\n\
+.TP\n\
+\\\\$1 \\\\$2\n\
+..\n\
+.TH %s %d\n\
+"
+, o->prefix == 2 ? "\\\\-\\\\-" : o->prefix == 1 ? "\\\\-" : ""
+, error_info.id
+, section
+);
+ }
+ if (style == STYLE_match)
+ {
+ if (!matched)
+ {
+ if (hp = (Help_t*)search(styles, elementsof(styles), sizeof(styles[0]), (char*)what))
+ {
+ if (!sp_help && !(sp_help = sfstropen()))
+ goto nospace;
+ sfprintf(sp_help, "[-][:%s?%s]", hp->match, hp->text);
+ if (!(opts = sfstruse(sp_help)))
+ goto nospace;
+ goto again;
+ }
+ s = (char*)unknown;
+ goto nope;
+ }
+ else if (matched < 0)
+ x = 0;
+ }
+ if (sp_plus)
+ {
+ if (sfstrtell(sp_plus))
+ {
+ if (sfstrtell(sp))
+ sfputc(sp, ' ');
+ if (!(t = sfstruse(sp_plus)))
+ goto nospace;
+ sfputr(sp, t, ']');
+ }
+ sfclose(sp_plus);
+ }
+ if (style >= STYLE_man)
+ {
+ if (sp_head)
+ {
+ if (!(t = sfstruse(sp_head)))
+ goto nospace;
+ for (; *t == '\n'; t++);
+ sfputr(sp, t, '\n');
+ sfclose(sp_head);
+ sp_head = 0;
+ }
+ item(sp, C("SYNOPSIS"), 0, style, sp_info, version, ID);
+ }
+ if (x)
+ {
+ for (t = x + xl; t > x && (*(t - 1) == '\n' || *(t - 1) == '\r'); t--);
+ xl = t - x;
+ if (style >= STYLE_match)
+ {
+ args(sp, x, xl, flags, style, sp_info, version, catalog);
+ x = 0;
+ }
+ }
+ if (sp_body)
+ {
+ if (sfstrtell(sp_body))
+ {
+ if (style < STYLE_match && sfstrtell(sp))
+ sfputc(sp, ' ');
+ if (!(t = sfstruse(sp_body)))
+ goto nospace;
+ sfputr(sp, t, -1);
+ }
+ sfclose(sp_body);
+ sp_body = 0;
+ }
+ if (x && style != STYLE_posix)
+ args(sp, x, xl, flags, style, sp_info, version, catalog);
+ if (sp_info)
+ {
+ sfclose(sp_info);
+ sp_info = 0;
+ }
+ if (sp_misc)
+ {
+ sfclose(sp_misc);
+ sp_misc = 0;
+ }
+ if (!(p = sfstruse(sp)))
+ goto nospace;
+ name = error_info.id ? error_info.id : "command";
+ m = strlen(name) + 1;
+ if (!opt_info.state->width)
+ {
+ astwinsize(1, NiL, &opt_info.state->width);
+ if (opt_info.state->width < 20)
+ opt_info.state->width = OPT_WIDTH;
+ }
+ if (!(opt_info.state->flags & OPT_preformat))
+ {
+ if (style >= STYLE_man || matched < 0)
+ {
+ sfputc(mp, '\f');
+ ts = 0;
+ }
+ else
+ ts = OPT_USAGE + m;
+ if (style == STYLE_html)
+ {
+ sfprintf(mp, "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n<HTML>\n<HEAD>\n<META name=\"generator\" content=\"optget (AT&T Research) 2000-04-01\">\n%s<TITLE>%s man document</TITLE>\n</HEAD>\n<BODY bgcolor=white>\n", (opt_info.state->flags & OPT_proprietary) ? "<!--INTERNAL-->\n" : "", name);
+ sfprintf(mp, "<H4><TABLE width=100%%><TR><TH align=left>&nbsp;%s&nbsp;(&nbsp;%d&nbsp;)&nbsp;<TH align=center><A href=\".\" title=\"Index\">%s</A><TH align=right>%s&nbsp;(&nbsp;%d&nbsp;)</TR></TABLE></H4>\n<HR>\n", name, section, T(NiL, ID, heading[section % 10]), name, section);
+ sfprintf(mp, "<DL compact>\n<DT>");
+ co = 2;
+ *(pt = ptstk) = 0;
+ }
+ else
+ co = 0;
+ if ((rm = opt_info.state->width - ts - 1) < OPT_MARGIN)
+ rm = OPT_MARGIN;
+ ip = indent;
+ ip->stop = (ip+1)->stop = style >= STYLE_html ? 0 : 2;
+ tp = 0;
+ n = 0;
+ head = 1;
+ while (*p == '\n')
+ p++;
+ while (c = *p++)
+ {
+ if (c == '\n')
+ {
+ ip = indent;
+ n = 0;
+ tp = 0;
+ sfputc(mp, '\n');
+ co = 0;
+ rm = opt_info.state->width - 1;
+ ts = ip->stop;
+ if (*p == '\n')
+ {
+ while (*++p == '\n');
+ if ((style == STYLE_man || style == STYLE_html) && (!head || *p != ' ' && *p != '\t'))
+ {
+ if (style == STYLE_man)
+ p--;
+ else
+ sfprintf(mp, "<P>\n");
+ }
+ }
+ head = *p != ' ' && *p != '\t';
+ if (style == STYLE_html && (*p != '<' || !strneq(p, "<BR>", 4) && !strneq(p, "<P>", 3)))
+ {
+ y = p;
+ while (*p == '\t')
+ p++;
+ if (*p == '\n')
+ continue;
+ j = p - y;
+ if (j > *pt)
+ {
+ if (pt > ptstk)
+ sfprintf(mp, "<DL compact>\n");
+ *++pt = j;
+ sfprintf(mp, "<DL compact>\n");
+ }
+ else while (j < *pt)
+ {
+ if (--pt > ptstk)
+ sfprintf(mp, "</DL>\n");
+ sfprintf(mp, "</DL>\n");
+ }
+ co += sfprintf(mp, "<DT>");
+ }
+ }
+ else if (c == '\t')
+ {
+ if (style == STYLE_html)
+ {
+ while (*p == '\t')
+ p++;
+ if (*p != '\n')
+ co += sfprintf(mp, "<DD>");
+ }
+ else
+ {
+ if ((ip+1)->stop)
+ {
+ do
+ {
+ ip++;
+ if (*p != '\t')
+ break;
+ p++;
+ } while ((ip+1)->stop);
+ if (*p == '\n')
+ continue;
+ ts = ip->stop;
+ if (co >= ts)
+ {
+ sfputc(mp, '\n');
+ co = 0;
+ rm = opt_info.state->width - 1;
+ ts = ip->stop;
+ }
+ }
+ while (co < ts)
+ {
+ sfputc(mp, ' ');
+ co++;
+ }
+ }
+ }
+ else
+ {
+ if (c == ' ' && !n)
+ {
+ if (co >= rm)
+ tp = 0;
+ else
+ {
+ tp = sfstrtell(mp);
+ pp = p;
+ }
+ if (style == STYLE_nroff && !co)
+ continue;
+ }
+ else if (style == STYLE_html)
+ {
+ if (c == '<')
+ {
+ if (strneq(p, "NOBR>", 5))
+ n++;
+ else if (n && strneq(p, "/NOBR>", 6) && !--n)
+ {
+ for (y = p += 6; (c = *p) && c != ' ' && c != '\t' && c != '\n' && c != '<'; p++)
+ if (c == '[')
+ sfputr(mp, "&#0091;", -1);
+ else if (c == ']')
+ sfputr(mp, "&#0093;", -1);
+ else
+ sfputc(mp, c);
+ sfwrite(mp, "</NOBR", 6);
+ c = '>';
+ tp = 0;
+ co += p - y + 6;
+ }
+ }
+ else if (c == '>' && !n)
+ {
+ for (y = --p; (c = *p) && c != ' ' && c != '\t' && c != '\n' && c != '<'; p++)
+ if (c == '[')
+ sfputr(mp, "&#0091;", -1);
+ else if (c == ']')
+ sfputr(mp, "&#0093;", -1);
+ else
+ sfputc(mp, c);
+ c = *sfstrseek(mp, -1, SEEK_CUR);
+ if (p > y + 1)
+ {
+ tp = 0;
+ co += p - y - 1;
+ }
+ if (co >= rm)
+ tp = 0;
+ else
+ {
+ tp = sfstrtell(mp);
+ pp = p;
+ }
+ }
+ else if (c == '[')
+ {
+ sfputr(mp, "&#0091", -1);
+ c = ';';
+ }
+ else if (c == ']')
+ {
+ sfputr(mp, "&#0093", -1);
+ c = ';';
+ }
+ else if (c == 'h')
+ {
+ y = p;
+ if (*y++ == 't' && *y++ == 't' && *y++ == 'p' && (*y == ':' || *y++ == 's' && *y == ':') && *y++ == ':' && *y++ == '/' && *y++ == '/')
+ {
+ while (isalnum(*y) || *y == '_' || *y == '/' || *y == '-' || *y == '.')
+ y++;
+ if (*y == '?')
+ while (isalnum(*y) || *y == '_' || *y == '/' || *y == '-' || *y == '.' || *y == '?' || *y == '=' || *y == '%' || *y == '&' || *y == ';' || *y == '#')
+ y++;
+ if (*(y - 1) == '.')
+ y--;
+ p--;
+ sfprintf(mp, "<A href=\"%-.*s\">%-.*s</A", y - p, p, y - p, p);
+ p = y;
+ c = '>';
+ }
+ }
+ else if (c == 'C')
+ {
+ y = p;
+ if (*y++ == 'o' && *y++ == 'p' && *y++ == 'y' && *y++ == 'r' && *y++ == 'i' && *y++ == 'g' && *y++ == 'h' && *y++ == 't' && *y++ == ' ' && *y++ == '(' && (*y++ == 'c' || *(y - 1) == 'C') && *y++ == ')')
+ {
+ sfputr(mp, "Copyright &copy", -1);
+ p = y;
+ c = ';';
+ }
+ }
+ }
+ else if (c == ']')
+ {
+ if (n)
+ n--;
+ }
+ else if (c == '[')
+ n++;
+ if (c == CC_esc)
+ {
+ sfputc(mp, c);
+ do
+ {
+ if (!(c = *p++))
+ {
+ p--;
+ break;
+ }
+ sfputc(mp, c);
+ } while (c < 'a' || c > 'z');
+ }
+ else if (co++ >= rm && !n)
+ {
+ if (tp)
+ {
+ if (*sfstrseek(mp, tp, SEEK_SET) != ' ')
+ sfstrseek(mp, 1, SEEK_CUR);
+ tp = 0;
+ p = pp;
+ n = 0;
+ }
+ else if (c != ' ' && c != '\n')
+ sfputc(mp, c);
+ if (*p == ' ')
+ p++;
+ if (*p != '\n')
+ {
+ sfputc(mp, '\n');
+ for (co = 0; co < ts; co++)
+ sfputc(mp, ' ');
+ rm = opt_info.state->width - 1;
+ }
+ }
+ else
+ sfputc(mp, c);
+ }
+ }
+ for (d = sfstrbase(mp), t = sfstrseek(mp, 0, SEEK_CUR); t > d && ((c = *(t - 1)) == '\n' || c == '\r' || c == ' ' || c == '\t'); t--);
+ sfstrseek(mp, t - d, SEEK_SET);
+ if (style == STYLE_html)
+ {
+ while (pt > ptstk)
+ {
+ if (--pt > ptstk)
+ sfprintf(mp, "\n</DL>");
+ sfprintf(mp, "\n</DL>");
+ }
+ sfprintf(mp, "</DL>\n</BODY>\n</HTML>");
+ }
+ }
+ else
+ sfputr(mp, p, 0);
+ if (!(p = sfstruse(mp)))
+ goto nospace;
+ if (sp)
+ sfclose(sp);
+ return opt_info.msg = p;
+ nospace:
+ s = T(NiL, ID, "[* out of space *]");
+ nope:
+ if (psp)
+ pop(psp);
+ if (sp_help)
+ sfclose(sp_help);
+ if (sp_text)
+ sfclose(sp_text);
+ if (sp_plus)
+ sfclose(sp_plus);
+ if (sp_info)
+ sfclose(sp_info);
+ if (sp_head)
+ sfclose(sp_head);
+ if (sp_body)
+ sfclose(sp_body);
+ if (sp_misc)
+ sfclose(sp_misc);
+ return s;
+}
+
+/*
+ * compatibility wrapper to opthelp()
+ */
+
+char*
+optusage(const char* opts)
+{
+ return opthelp(opts, NiL);
+}
+
+/*
+ * convert number using strtonll() *except* that
+ * 0*[[:digit:]].* is treated as [[:digit:]].*
+ * i.e., it looks octal but isn't, to meet
+ * posix Utility Argument Syntax -- use
+ * 0x.* or <base>#* for alternate bases
+ */
+
+static intmax_t
+optnumber(const char* s, char** t, int* e)
+{
+ intmax_t n;
+ int oerrno;
+
+ while (*s == '0' && isdigit(*(s + 1)))
+ s++;
+ oerrno = errno;
+ errno = 0;
+ n = strtonll(s, t, NiL, 0);
+ if (e)
+ *e = errno;
+ errno = oerrno;
+ return n;
+}
+
+/*
+ * point opt_info.arg to an error/info message for opt_info.name
+ * p points to opts location for opt_info.name
+ * optget() return value is returned
+ */
+
+static int
+opterror(register char* p, int version, char* catalog, int err)
+{
+ register Sfio_t* mp;
+ register Sfio_t* tp;
+ register char* s;
+ register int c;
+
+ if (opt_info.num != LONG_MIN)
+ opt_info.num = opt_info.number = 0;
+ if (!p || !(mp = opt_info.state->mp) && !(mp = opt_info.state->mp = sfstropen()))
+ goto nospace;
+ s = *p == '-' ? p : opt_info.name;
+ if (*p == '!')
+ {
+ while (*s == '-')
+ sfputc(mp, *s++);
+ sfputc(mp, 'n');
+ sfputc(mp, 'o');
+ }
+ sfputr(mp, s, ':');
+ sfputc(mp, ' ');
+ if (*p == '#' || *p == ':')
+ {
+ if (*p == '#')
+ {
+ s = T(NiL, ID, "numeric");
+ sfputr(mp, s, ' ');
+ }
+ if (*(p = next(p + 1, version)) == '[')
+ {
+ p = skip(s = p + 1, ':', '?', 0, 1, 0, 0, version);
+ tp = X(catalog) ? opt_info.state->xp : mp;
+ while (s < p)
+ {
+ if ((c = *s++) == '?' || c == ']')
+ s++;
+ sfputc(tp, c);
+ }
+ if (!X(catalog))
+ sfputc(mp, ' ');
+ else if (p = sfstruse(tp))
+ sfputr(mp, T(error_info.id, catalog, p), ' ');
+ else
+ goto nospace;
+ }
+ p = opt_info.name[2] ? C("value expected") : C("argument expected");
+ }
+ else if (*p == '*' || *p == '&')
+ {
+ sfputr(mp, opt_info.arg, ':');
+ sfputc(mp, ' ');
+ p = *p == '&' ? C("ambiguous option argument value") : C("unknown option argument value");
+ }
+ else if (*p == '=' || *p == '!')
+ p = C("value not expected");
+ else if (*p == '?')
+ p = *(p + 1) == '?' ? C("optget: option not supported") : C("ambiguous option");
+ else if (*p == '+')
+ p = C("section not found");
+ else
+ {
+ if (opt_info.option[0] != '?' && opt_info.option[0] != '-' || opt_info.option[1] != '?' && opt_info.option[1] != '-')
+ opt_info.option[0] = 0;
+ p = C("unknown option");
+ }
+ p = T(NiL, ID, p);
+ sfputr(mp, p, -1);
+ if (err)
+ sfputr(mp, " -- out of range", -1);
+ if (opt_info.arg = sfstruse(mp))
+ return ':';
+ nospace:
+ opt_info.arg = T(NiL, ID, "[* out of space *]");
+ return ':';
+}
+
+/*
+ * argv: command line argv where argv[0] is command name
+ *
+ * opts: option control string
+ *
+ * '[' [flag][=][index][:<long-name>[|<alias-name>...]['?'description]] ']'
+ * long option name, index, description; -index returned
+ * ':' option takes string arg
+ * '#' option takes numeric arg (concat option may follow)
+ * '?' (option) following options not in usage
+ * (following # or :) optional arg
+ * '[' '[' ... ] ... '[' ... ']' ']'
+ * mutually exclusive option grouping
+ * '[' name [:attr]* [?description] ']'
+ * (following # or :) optional option arg description
+ * '\n'[' '|'\t']* ignored for legibility
+ * ' ' ... optional argument(s) description (to end of string)
+ * or after blank line
+ * ']]' literal ']' within '[' ... ']'
+ *
+ * return:
+ * 0 no more options
+ * '?' usage: opt_info.arg points to message sans
+ * `Usage: command '
+ * ':' error: opt_info.arg points to message sans `command: '
+ *
+ * '-' '+' '?' ':' '#' '[' ']' ' '
+ * invalid option chars
+ *
+ * -- terminates option list and returns 0
+ *
+ * + as first opts char makes + equivalent to -
+ *
+ * if any # option is specified then numeric options (e.g., -123)
+ * are associated with the leftmost # option in opts
+ *
+ * usage info in placed opt_info.arg when '?' returned
+ * see help_text[] (--???) for more info
+ */
+
+int
+optget(register char** argv, const char* oopts)
+{
+ register int c;
+ register char* s;
+ char* a;
+ char* b;
+ char* e;
+ char* f;
+ char* g;
+ char* v;
+ char* w;
+ char* p;
+ char* q;
+ char* t;
+ char* y;
+ char* numopt;
+ char* opts;
+ char* catalog;
+ int n;
+ int m;
+ int k;
+ int j;
+ int x;
+ int err;
+ int no;
+ int nov;
+ int num;
+ int numchr;
+ int prefix;
+ int version;
+ Help_t* hp;
+ Push_t* psp;
+ Push_t* tsp;
+ Sfio_t* vp;
+ Sfio_t* xp;
+ Optcache_t* cache;
+ Optcache_t* pcache;
+ Optpass_t* pass;
+
+#if !_YOU_FIGURED_OUT_HOW_TO_GET_ALL_DLLS_TO_DO_THIS_
+ /*
+ * these are not initialized by all dlls!
+ */
+
+ extern Error_info_t _error_info_;
+ extern Opt_t _opt_info_;
+
+ if (!_error_infop_)
+ _error_infop_ = &_error_info_;
+ if (!_opt_infop_)
+ _opt_infop_ = &_opt_info_;
+ if (!opt_info.state)
+ opt_info.state = &state;
+#endif
+ if (!oopts)
+ return 0;
+ opt_info.state->pindex = opt_info.index;
+ opt_info.state->poffset = opt_info.offset;
+ if (!opt_info.index)
+ {
+ opt_info.index = 1;
+ opt_info.offset = 0;
+ if (opt_info.state->npass)
+ {
+ opt_info.state->npass = 0;
+ opt_info.state->join = 0;
+ }
+ }
+ if (!argv)
+ cache = 0;
+ else
+ for (pcache = 0, cache = opt_info.state->cache; cache; pcache = cache, cache = cache->next)
+ if (cache->pass.oopts == (char*)oopts)
+ break;
+ if (cache)
+ {
+ if (pcache)
+ {
+ pcache->next = cache->next;
+ cache->next = opt_info.state->cache;
+ opt_info.state->cache = cache;
+ }
+ pass = &cache->pass;
+ opt_info.state->npass = -1;
+ }
+ else
+ {
+ if (!argv)
+ n = opt_info.state->npass ? opt_info.state->npass : 1;
+ else if ((n = opt_info.state->join - 1) < 0)
+ n = 0;
+ if (n >= opt_info.state->npass || opt_info.state->pass[n].oopts != (char*)oopts)
+ {
+ for (m = 0; m < opt_info.state->npass && opt_info.state->pass[m].oopts != (char*)oopts; m++);
+ if (m < opt_info.state->npass)
+ n = m;
+ else
+ {
+ if (n >= elementsof(opt_info.state->pass))
+ n = elementsof(opt_info.state->pass) - 1;
+ init((char*)oopts, &opt_info.state->pass[n]);
+ if (opt_info.state->npass <= n)
+ opt_info.state->npass = n + 1;
+ }
+ }
+ if (!argv)
+ return 0;
+ pass = &opt_info.state->pass[n];
+ }
+ opts = pass->opts;
+ prefix = pass->prefix;
+ version = pass->version;
+ if (!(xp = opt_info.state->xp) || (catalog = pass->catalog) && !X(catalog))
+ catalog = 0;
+ else /* if (!error_info.catalog) */
+ error_info.catalog = catalog;
+ again:
+ psp = 0;
+
+ /*
+ * check if any options remain and determine if the
+ * next option is short or long
+ */
+
+ opt_info.assignment = 0;
+ num = 1;
+ w = v = 0;
+ x = 0;
+ for (;;)
+ {
+ if (!opt_info.offset)
+ {
+ /*
+ * finished with the previous arg
+ */
+
+ if (opt_info.index == 1 && opt_info.argv != opt_info.state->strv)
+ {
+ opt_info.argv = 0;
+ opt_info.state->argv[0] = 0;
+ if (argv[0] && (opt_info.state->argv[0] = save(argv[0])))
+ opt_info.argv = opt_info.state->argv;
+ opt_info.state->style = STYLE_short;
+ }
+ if (!(s = argv[opt_info.index]))
+ return 0;
+ if (!prefix)
+ {
+ /*
+ * long with no prefix (dd style)
+ */
+
+ n = 2;
+ if ((c = *s) != '-' && c != '+')
+ c = '-';
+ else if (*++s == c)
+ {
+ if (!*++s)
+ {
+ opt_info.index++;
+ return 0;
+ }
+ }
+ else if (*s == '?')
+ n = 1;
+ }
+ else if ((c = *s++) != '-' && (c != '+' || !(pass->flags & OPT_plus) && (*s < '0' || *s > '9' || !strmatch(opts, version ? "*\\]#\\[*" : "*#*"))))
+ {
+ if (!(pass->flags & OPT_old) || !isalpha(c))
+ return 0;
+ s--;
+ n = 1;
+ opt_info.offset--;
+ }
+ else if (*s == c)
+ {
+ if (!*++s)
+ {
+ /*
+ * -- or ++ end of options
+ */
+
+ opt_info.index++;
+ return 0;
+ }
+ if (version || *s == '?' || !(pass->flags & OPT_minus))
+ {
+ /*
+ * long with double prefix
+ */
+
+ n = 2;
+ }
+ else
+ {
+ /*
+ * short option char '-'
+ */
+
+ s--;
+ n = 1;
+ }
+ }
+ else if (prefix == 1 && *s != '?')
+ {
+ /*
+ * long with single prefix (find style)
+ */
+
+ n = 2;
+ }
+ else
+ {
+ /*
+ * short (always with single prefix)
+ */
+
+ n = 1;
+ }
+
+ /*
+ * just a prefix is an option (e.g., `-' == stdin)
+ */
+
+ if (!*s)
+ return 0;
+ if (c == '+')
+ opt_info.arg = 0;
+ if (n == 2)
+ {
+ x = 0;
+ opt_info.state->style = STYLE_long;
+ opt_info.option[0] = opt_info.name[0] = opt_info.name[1] = c;
+ w = &opt_info.name[prefix];
+ if ((*s == 'n' || *s == 'N') && (*(s + 1) == 'o' || *(s + 1) == 'O') && *(s + 2) && *(s + 2) != '=')
+ no = *(s + 2) == '-' ? 3 : 2;
+ else
+ no = 0;
+ for (c = *s; *s; s++)
+ {
+ if (*s == '=')
+ {
+ if (*(s + 1) == '=')
+ s++;
+ if (!isalnum(*(s - 1)) && *(w - 1) == (opt_info.assignment = *(s - 1)))
+ w--;
+ v = ++s;
+ break;
+ }
+ if (w < &opt_info.name[elementsof(opt_info.name) - 1] && *s != ':' && *s != '|' && *s != '[' && *s != ']')
+ *w++ = *s;
+ }
+ *w = 0;
+ w = &opt_info.name[prefix];
+ c = *w;
+ opt_info.offset = 0;
+ opt_info.index++;
+ break;
+ }
+ opt_info.offset++;
+ }
+ if (!argv[opt_info.index])
+ return 0;
+ if (c = argv[opt_info.index][opt_info.offset++])
+ {
+ if ((k = argv[opt_info.index][0]) != '-' && k != '+')
+ k = '-';
+ opt_info.option[0] = opt_info.name[0] = k;
+ opt_info.option[1] = opt_info.name[1] = c;
+ opt_info.option[2] = opt_info.name[2] = 0;
+ break;
+ }
+ opt_info.offset = 0;
+ opt_info.index++;
+ }
+
+ /*
+ * at this point:
+ *
+ * c the first character of the option
+ * w long option name if != 0, otherwise short
+ * v long option value (via =) if w != 0
+ */
+
+ if (c == '?')
+ {
+ /*
+ * ? always triggers internal help
+ */
+
+ if (w && !v && (*(w + 1) || !(v = argv[opt_info.index]) || !++opt_info.index))
+ v = w + 1;
+ opt_info.option[1] = c;
+ opt_info.option[2] = 0;
+ if (!w)
+ {
+ opt_info.name[1] = c;
+ opt_info.name[2] = 0;
+ }
+ goto help;
+ }
+ numopt = 0;
+ f = 0;
+ s = opts;
+
+ /*
+ * no option can start with these characters
+ */
+
+ if (c == ':' || c == '#' || c == ' ' || c == '[' || c == ']')
+ {
+ if (c != *s)
+ s = "";
+ }
+ else
+ {
+ a = 0;
+ if (!w && (pass->flags & OPT_cache))
+ {
+ if (cache)
+ {
+ if (k = cache->flags[map[c]])
+ {
+ opt_info.arg = 0;
+
+ /*
+ * this is a ksh getopts workaround
+ */
+
+ if (opt_info.num != LONG_MIN)
+ opt_info.num = opt_info.number = !(k & OPT_cache_invert);
+ if (!(k & (OPT_cache_string|OPT_cache_numeric)))
+ return c;
+ if (*(opt_info.arg = &argv[opt_info.index++][opt_info.offset]))
+ {
+ if (!(k & OPT_cache_numeric))
+ {
+ opt_info.offset = 0;
+ return c;
+ }
+ opt_info.num = (long)(opt_info.number = optnumber(opt_info.arg, &e, &err));
+ if (err || e == opt_info.arg)
+ {
+ if (!err && (k & OPT_cache_optional))
+ {
+ opt_info.arg = 0;
+ opt_info.index--;
+ return c;
+ }
+ }
+ else if (*e)
+ {
+ opt_info.offset += e - opt_info.arg;
+ opt_info.index--;
+ return c;
+ }
+ else
+ {
+ opt_info.offset = 0;
+ return c;
+ }
+ }
+ else if (opt_info.arg = argv[opt_info.index])
+ {
+ opt_info.index++;
+ if ((k & OPT_cache_optional) && (*opt_info.arg == '-' || (pass->flags & OPT_plus) && *opt_info.arg == '+') && *(opt_info.arg + 1))
+ {
+ opt_info.arg = 0;
+ opt_info.index--;
+ opt_info.offset = 0;
+ return c;
+ }
+ if (k & OPT_cache_string)
+ {
+ opt_info.offset = 0;
+ return c;
+ }
+ opt_info.num = (long)(opt_info.number = optnumber(opt_info.arg, &e, &err));
+ if (!err)
+ {
+ if (!*e)
+ {
+ opt_info.offset = 0;
+ return c;
+ }
+ if (k & OPT_cache_optional)
+ {
+ opt_info.arg = 0;
+ opt_info.index--;
+ opt_info.offset = 0;
+ return c;
+ }
+ }
+ }
+ else if (k & OPT_cache_optional)
+ {
+ opt_info.offset = 0;
+ return c;
+ }
+ opt_info.index--;
+ }
+ cache = 0;
+ }
+ else if (cache = newof(0, Optcache_t, 1, 0))
+ {
+ cache->caching = c;
+ c = 0;
+ cache->pass = *pass;
+ cache->next = opt_info.state->cache;
+ opt_info.state->cache = cache;
+ }
+ }
+ else
+ cache = 0;
+ for (;;)
+ {
+ if (!(*(s = next(s, version))) || *s == '\n' || *s == ' ')
+ {
+ if (!(tsp = psp))
+ {
+ if (cache)
+ {
+ /*
+ * the first loop pass
+ * initialized the cache
+ * so one more pass to
+ * check the cache or
+ * bail for a full scan
+ */
+
+ cache->flags[0] = 0;
+ c = cache->caching;
+ cache->caching = 0;
+ cache = 0;
+ s = opts;
+ continue;
+ }
+ if (!x && catalog)
+ {
+ /*
+ * the first loop pass
+ * translated long
+ * options and there
+ * were no matches so
+ * one more pass for C
+ * locale
+ */
+
+ catalog = 0;
+ s = opts;
+ continue;
+ }
+ s = "";
+ break;
+ }
+ s = psp->ob;
+ psp = psp->next;
+ free(tsp);
+ continue;
+ }
+ if (*s == '\f')
+ {
+ psp = info(psp, s + 1, NiL, opt_info.state->xp);
+ if (psp->nb)
+ s = psp->nb;
+ else
+ {
+ s = psp->ob;
+ psp = psp->next;
+ }
+ continue;
+ }
+ message((-20, "optget: opt %s w %s num %ld", show(s), w, num));
+ if (*s == c && !w)
+ break;
+ else if (*s == '[')
+ {
+ f = s = next(s + 1, version);
+ k = *f;
+ if (k == '+' || k == '-')
+ /* ignore */;
+ else if (k == '[' || version < 1)
+ continue;
+ else if (w && !cache)
+ {
+ nov = no;
+ if (*(s + 1) == '\f' && (vp = opt_info.state->vp))
+ {
+ sfputc(vp, k);
+ s = expand(s + 2, NiL, &t, vp);
+ if (*s)
+ *(f = s - 1) = k;
+ else
+ {
+ f = sfstrbase(vp);
+ if (s = strrchr(f, ':'))
+ f = s - 1;
+ else
+ s = f + 1;
+ }
+ }
+ else
+ t = 0;
+ if (*s != ':')
+ s = skip(s, ':', '?', 0, 1, 0, 0, version);
+ if (*s == ':')
+ {
+ if (catalog)
+ {
+ p = skip(s + 1, '?', 0, 0, 1, 0, 0, version);
+ e = sfprints("%-.*s", p - (s + 1), s + 1);
+ g = T(error_info.id, catalog, e);
+ if (g == e)
+ p = 0;
+ else
+ {
+ sfprintf(xp, ":%s|%s?", g, e);
+ if (!(s = sfstruse(xp)))
+ goto nospace;
+ }
+ }
+ else
+ p = 0;
+ y = w;
+ for (;;)
+ {
+ n = m = 0;
+ e = s + 1;
+ while (*++s)
+ {
+ if (*s == '*' || *s == '\a')
+ {
+ if (*s == '\a')
+ do
+ {
+ if (!*++s)
+ {
+ s--;
+ break;
+ }
+ } while (*s != '\a');
+ j = *(s + 1);
+ if (j == ':' || j == '|' || j == '?' || j == ']' || j == 0)
+ {
+ while (*w)
+ w++;
+ m = 0;
+ break;
+ }
+ m = 1;
+ }
+ else if (*s == *w || sep(*s) && sep(*w))
+ w++;
+ else if (*w == 0)
+ break;
+ else if (!sep(*s))
+ {
+ if (sep(*w))
+ {
+ if (*++w == *s)
+ {
+ w++;
+ continue;
+ }
+ }
+ else if (w == y || sep(*(w - 1)) || isupper(*(w - 1)) && islower(*w))
+ break;
+ for (q = s; *q && !sep(*q) && *q != '|' && *q != '?' && *q != ']'; q++);
+ if (!sep(*q))
+ break;
+ for (s = q; w > y && *w != *(s + 1); w--);
+ }
+ else if (*w != *(s + 1))
+ break;
+ }
+ if (!*w)
+ {
+ nov = 0;
+ break;
+ }
+ if (n = no)
+ {
+ m = 0;
+ s = e - 1;
+ w = y + n;
+ while (*++s)
+ {
+ if (*s == '*' || *s == '\a')
+ {
+ if (*s == '\a')
+ do
+ {
+ if (!*++s)
+ {
+ s--;
+ break;
+ }
+ } while (*s != '\a');
+ j = *(s + 1);
+ if (j == ':' || j == '|' || j == '?' || j == ']' || j == 0)
+ {
+ while (*w)
+ w++;
+ m = 0;
+ break;
+ }
+ m = 1;
+ }
+ else if (*s == *w || sep(*s) && sep(*w))
+ w++;
+ else if (*w == 0)
+ break;
+ else if (!sep(*s))
+ {
+ if (sep(*w))
+ {
+ if (*++w == *s)
+ {
+ w++;
+ continue;
+ }
+ }
+ else if (w == y || sep(*(w - 1)) || isupper(*(w - 1)) && islower(*w))
+ break;
+ for (q = s; *q && !sep(*q) && *q != '|' && *q != '?' && *q != ']'; q++);
+ if (!sep(*q))
+ break;
+ for (s = q; w > y && *w != *(s + 1); w--);
+ }
+ else if (*w != *(s + 1))
+ break;
+ }
+ if (!*w)
+ break;
+ }
+ if (*(s = skip(s, ':', '|', '?', 1, 0, 0, version)) != '|')
+ break;
+ w = y;
+ }
+ if (p)
+ s = p;
+ if (!*w)
+ {
+ if (n)
+ num = 0;
+ if (!(n = (m || *s == ':' || *s == '|' || *s == '?' || *s == ']' || *s == 0)) && x)
+ {
+ psp = pop(psp);
+ return opterror("?", version, catalog, 0);
+ }
+ for (x = k; *(f + 1) == '|' && (j = *(f + 2)) && j != '!' && j != '=' && j != ':' && j != '?' && j != ']'; f += 2);
+ if (*f == ':')
+ {
+ x = -1;
+ opt_info.option[1] = '-';
+ opt_info.option[2] = 0;
+ }
+ else if (*(f + 1) == ':' || *(f + 1) == '!' && *(f + 2) == ':')
+ {
+ opt_info.option[1] = x;
+ opt_info.option[2] = 0;
+ }
+ else
+ {
+ a = f;
+ if (*a == '=')
+ a++;
+ else
+ {
+ if (*(a + 1) == '!')
+ a++;
+ if (*(a + 1) == '=')
+ a += 2;
+ }
+ x = -strtol(a, &b, 0);
+ if ((b - a) > sizeof(opt_info.option) - 2)
+ b = a + sizeof(opt_info.option) - 2;
+ memcpy(&opt_info.option[1], a, b - a);
+ opt_info.option[b - a + 1] = 0;
+ }
+ b = e;
+ if (t)
+ {
+ s = t;
+ t = 0;
+ }
+ a = s = skip(s, 0, 0, 0, 1, 0, 0, version);
+ if (n)
+ {
+ w = y;
+ break;
+ }
+ }
+ w = y;
+ }
+ else if (k == c && prefix == 1)
+ {
+ w = 0;
+ opt_info.name[1] = c;
+ opt_info.name[2] = 0;
+ opt_info.offset = 2;
+ opt_info.index--;
+ break;
+ }
+ if (t)
+ {
+ s = t;
+ if (a)
+ a = t;
+ }
+ }
+ s = skip(s, 0, 0, 0, 1, 0, 1, version);
+ if (*s == GO)
+ s = skip(s + 1, 0, 0, 0, 0, 1, 1, version);
+ if (cache)
+ {
+ m = OPT_cache_flag;
+ v = s;
+ if (*v == '#')
+ {
+ v++;
+ m |= OPT_cache_numeric;
+ }
+ else if (*v == ':')
+ {
+ v++;
+ m |= OPT_cache_string;
+ }
+ if (*v == '?')
+ {
+ v++;
+ m |= OPT_cache_optional;
+ }
+ else if (*v == *(v - 1))
+ v++;
+ if (*(v = next(v, version)) == '[')
+ v = skip(v + 1, 0, 0, 0, 1, 0, 1, version);
+ if (*v != GO)
+ {
+ v = f;
+ for (;;)
+ {
+ if (isdigit(*f) && isdigit(*(f + 1)))
+ while (isdigit(*(f + 1)))
+ f++;
+ else if (*(f + 1) == '=')
+ break;
+ else
+ cache->flags[map[*f]] = m;
+ j = 0;
+ while (*(f + 1) == '|')
+ {
+ f += 2;
+ if (!(j = *f) || j == '!' || j == '=' || j == ':' || j == '?' || j == ']')
+ break;
+ cache->flags[map[j]] = m;
+ }
+ if (j != '!' || (m & OPT_cache_invert))
+ break;
+ f = v;
+ m |= OPT_cache_invert;
+ }
+ }
+ }
+ else
+ {
+ m = 0;
+ if (!w)
+ {
+ if (isdigit(*f) && isdigit(*(f + 1)))
+ k = -1;
+ if (c == k)
+ m = 1;
+ while (*(f + 1) == '|')
+ {
+ f += 2;
+ if (!(j = *f))
+ {
+ m = 0;
+ break;
+ }
+ else if (j == c)
+ m = 1;
+ else if (j == '!' || j == '=' || j == ':' || j == '?' || j == ']')
+ break;
+ }
+ }
+ if (m)
+ {
+ s--;
+ if (*++f == '!')
+ {
+ f++;
+ num = 0;
+ }
+ if (*f == '=')
+ {
+ c = -strtol(++f, &b, 0);
+ if ((b - f) > sizeof(opt_info.option) - 2)
+ b = f + sizeof(opt_info.option) - 2;
+ memcpy(&opt_info.option[1], f, b - f);
+ opt_info.option[b - f + 1] = 0;
+ }
+ else
+ c = k;
+ break;
+ }
+ }
+ if (*s == '#')
+ {
+ if (!numopt && s > opts)
+ {
+ numopt = s - 1;
+ numchr = k;
+ if (*f == ':')
+ numchr = -1;
+ else if (*(f + 1) != ':' && *(f + 1) != '!' && *(f + 1) != ']')
+ {
+ a = f;
+ if (*a == '=')
+ a++;
+ else
+ {
+ if (*(a + 1) == '!')
+ a++;
+ if (*(a + 1) == '=')
+ a += 2;
+ }
+ numchr = -strtol(a, NiL, 0);
+ }
+ }
+ }
+ else if (*s != ':')
+ continue;
+ }
+ else if (*s == ']')
+ {
+ s++;
+ continue;
+ }
+ else if (*s == '#')
+ {
+ if (!numopt && s > opts)
+ numchr = *(numopt = s - 1);
+ }
+ else if (*s != ':')
+ {
+ if (cache)
+ {
+ m = OPT_cache_flag;
+ if (*(s + 1) == '#')
+ {
+ m |= OPT_cache_numeric;
+ if (*(s + 2) == '?')
+ m |= OPT_cache_optional;
+ }
+ else if (*(s + 1) == ':')
+ {
+ m |= OPT_cache_string;
+ if (*(s + 2) == '?')
+ m |= OPT_cache_optional;
+ }
+ cache->flags[map[*s]] = m;
+ }
+ s++;
+ continue;
+ }
+ message((-21, "optget: opt %s", show(s)));
+ if (*++s == '?' || *s == *(s - 1))
+ s++;
+ if (*(s = next(s, version)) == '[')
+ {
+ s = skip(s + 1, 0, 0, 0, 1, 0, 1, version);
+ if (*s == GO)
+ s = skip(s + 1, 0, 0, 0, 0, 1, 1, version);
+ }
+ }
+ if (w && x)
+ {
+ s = skip(b, '|', '?', 0, 1, 0, 0, version);
+ if (v && (a == 0 || *a == 0 || *(a + 1) != ':' && *(a + 1) != '#') && (*v == '0' || *v == '1') && !*(v + 1))
+ {
+ if (*v == '0')
+ num = !num;
+ v = 0;
+ }
+ if ((s - b) >= elementsof(opt_info.name))
+ s = b + elementsof(opt_info.name) - 1;
+ for (;;)
+ {
+ if (b >= s)
+ {
+ *w = 0;
+ break;
+ }
+ if (*b == '*')
+ break;
+ *w++ = *b++;
+ }
+ if (!num && v)
+ return opterror(no ? "!" : "=", version, catalog, 0);
+ w = &opt_info.name[prefix];
+ c = x;
+ s = a;
+ }
+ }
+ if (!*s)
+ {
+ if (w)
+ {
+ if (hp = (Help_t*)search(styles, elementsof(styles), sizeof(styles[0]), w))
+ {
+ if (!v)
+ v = (char*)hp->name;
+ goto help;
+ }
+ if (!v)
+ {
+ v = opt_info.name;
+ goto help;
+ }
+ }
+ if (w || c < '0' || c > '9' || !numopt)
+ {
+ pop(psp);
+ return opterror("", version, catalog, 0);
+ }
+ s = numopt;
+ c = opt_info.option[1] = numchr;
+ opt_info.offset--;
+ }
+ opt_info.arg = 0;
+
+ /*
+ * this is a ksh getopts workaround
+ */
+
+ if (opt_info.num != LONG_MIN)
+ opt_info.num = opt_info.number = num;
+ if ((n = *++s == '#') || *s == ':' || w && !nov && v && (optnumber(v, &e, NiL), n = !*e))
+ {
+ if (w)
+ {
+ if (nov)
+ {
+ if (v)
+ {
+ pop(psp);
+ return opterror("!", version, catalog, 0);
+ }
+ opt_info.num = opt_info.number = 0;
+ }
+ else
+ {
+ if (!v && *(s + 1) != '?' && (v = argv[opt_info.index]))
+ {
+ opt_info.index++;
+ opt_info.offset = 0;
+ }
+ if (!(opt_info.arg = v) || (*v == '0' || *v == '1') && !*(v + 1))
+ {
+ if (*(s + 1) != '?')
+ {
+ if (!opt_info.arg)
+ {
+ pop(psp);
+ return opterror(s, version, catalog, 0);
+ }
+ }
+ else if (*(t = next(s + 2, version)) == '[')
+ while (*(t = skip(t, ':', 0, 0, 1, 0, 0, version)) == ':')
+ if (*++t == '!')
+ {
+ if (!v || *v == '1')
+ {
+ e = skip(t, ':', '?', ']', 1, 0, 0, version);
+ opt_info.arg = sfprints("%-.*s", e - t - 1, t + 1);
+ }
+ else
+ {
+ opt_info.arg = 0;
+ opt_info.num = opt_info.number = 0;
+ }
+ break;
+ }
+ }
+ if (opt_info.arg && n)
+ {
+ opt_info.num = (long)(opt_info.number = optnumber(opt_info.arg, &e, &err));
+ if (err || e == opt_info.arg)
+ {
+ pop(psp);
+ return opterror(s, version, catalog, err);
+ }
+ }
+ }
+ goto optarg;
+ }
+ else if (*(opt_info.arg = &argv[opt_info.index++][opt_info.offset]))
+ {
+ if (*s == '#')
+ {
+ opt_info.num = (long)(opt_info.number = optnumber(opt_info.arg, &e, &err));
+ if (err || e == opt_info.arg)
+ {
+ if (!err && *(s + 1) == '?')
+ {
+ opt_info.arg = 0;
+ opt_info.index--;
+ }
+ else
+ {
+ opt_info.offset = 0;
+ c = opterror(s, version, catalog, err);
+ }
+ pop(psp);
+ return c;
+ }
+ else if (*e)
+ {
+ opt_info.offset += e - opt_info.arg;
+ opt_info.index--;
+ pop(psp);
+ return c;
+ }
+ }
+ }
+ else if (opt_info.arg = argv[opt_info.index])
+ {
+ opt_info.index++;
+ if (*(s + 1) == '?' && (*opt_info.arg == '-' || (pass->flags & OPT_plus) && *opt_info.arg == '+') && *(opt_info.arg + 1))
+ {
+ opt_info.index--;
+ opt_info.arg = 0;
+ }
+ else if (*s == '#')
+ {
+ opt_info.num = (long)(opt_info.number = optnumber(opt_info.arg, &e, &err));
+ if (err || *e)
+ {
+ if (!err && *(s + 1) == '?')
+ {
+ opt_info.arg = 0;
+ opt_info.index--;
+ }
+ else
+ {
+ pop(psp);
+ opt_info.offset = 0;
+ return opterror(s, version, catalog, err);
+ }
+ }
+ }
+ }
+ else if (*(s + 1) != '?')
+ {
+ opt_info.index--;
+ pop(psp);
+ return opterror(s, version, catalog, 0);
+ }
+ opt_info.offset = 0;
+ optarg:
+ if (*s == ':' && *(s = skip(s, 0, 0, 0, 1, 0, 1, version)) == GO && *(s = next(s + 1, version)) == '[' && isalnum(*(s + 1)))
+ {
+ x = 0;
+ if (opt_info.arg)
+ {
+ do
+ {
+ w = y = opt_info.arg;
+ f = s = next(s + 1, version);
+ k = *f;
+ if (k == *w && isalpha(k) && !*(w + 1))
+ {
+ x = k;
+ break;
+ }
+ if (*s == '+' || *s == '-')
+ continue;
+ else if (*s == '[' || version < 1)
+ continue;
+ else
+ {
+ if (*s != ':')
+ s = skip(s, ':', '?', 0, 1, 0, 0, version);
+ if (*s == ':')
+ {
+ if (catalog)
+ {
+ p = skip(s + 1, '?', 0, 0, 1, 0, 0, version);
+ e = sfprints("%-.*s", p - (s + 1), s + 1);
+ b = T(error_info.id, catalog, e);
+ if (b == e)
+ p = 0;
+ else
+ {
+ sfprintf(xp, ":%s|%s?", b, e);
+ if (!(s = sfstruse(xp)))
+ goto nospace;
+ }
+ }
+ else
+ p = 0;
+ for (;;)
+ {
+ n = m = 0;
+ e = s + 1;
+ while (*++s)
+ {
+ if (*s == '*' || *s == '\a')
+ {
+ if (*s == '\a')
+ do
+ {
+ if (!*++s)
+ {
+ s--;
+ break;
+ }
+ } while (*s != '\a');
+ j = *(s + 1);
+ if (j == ':' || j == '|' || j == '?' || j == ']' || j == 0)
+ {
+ while (*w)
+ w++;
+ m = 0;
+ break;
+ }
+ m = 1;
+ }
+ else if (*s == *w || sep(*s) && sep(*w))
+ w++;
+ else if (*w == 0)
+ break;
+ else if (!sep(*s))
+ {
+ if (sep(*w))
+ {
+ if (*++w == *s)
+ {
+ w++;
+ continue;
+ }
+ }
+ else if (w == y || sep(*(w - 1)) || isupper(*(w - 1)) && islower(*w))
+ break;
+ for (q = s; *q && !sep(*q) && *q != '|' && *q != '?' && *q != ']'; q++);
+ if (!sep(*q))
+ break;
+ for (s = q; w > y && *w != *(s + 1); w--);
+ }
+ else if (*w != *(s + 1))
+ break;
+ }
+ if (!*w)
+ {
+ nov = 0;
+ break;
+ }
+ if (*(s = skip(s, ':', '|', '?', 1, 0, 0, version)) != '|')
+ break;
+ w = y;
+ }
+ if (p)
+ s = p;
+ if (!*w)
+ {
+ if (n)
+ num = 0;
+ if (!(n = (m || *s == ':' || *s == '|' || *s == '?' || *s == ']')) && x)
+ {
+ pop(psp);
+ return opterror("&", version, catalog, 0);
+ }
+ for (x = k; *(f + 1) == '|' && (j = *(f + 2)) && j != '!' && j != '=' && j != ':' && j != '?' && j != ']'; f += 2);
+ if (*f == ':')
+ x = -1;
+ else if (*(f + 1) == ':' || *(f + 1) == '!' && *(f + 2) == ':')
+ /* ok */;
+ else
+ {
+ a = f;
+ if (*a == '=')
+ a++;
+ else
+ {
+ if (*(a + 1) == '!')
+ a++;
+ if (*(a + 1) == '=')
+ a += 2;
+ }
+ x = -strtol(a, &b, 0);
+ }
+ b = e;
+ a = s = skip(s, 0, 0, 0, 1, 0, 0, version);
+ if (n)
+ break;
+ }
+ }
+ }
+ } while (*(s = skip(s, 0, 0, 0, 1, 0, 1, version)) == '[');
+ if (!(opt_info.num = opt_info.number = x))
+ {
+ pop(psp);
+ return opterror("*", version, catalog, 0);
+ }
+ }
+ }
+ }
+ else if (w && v)
+ {
+ pop(psp);
+ return opterror("=", version, catalog, 0);
+ }
+ else
+ {
+ opt_info.num = opt_info.number = num;
+ if (!w && !argv[opt_info.index][opt_info.offset])
+ {
+ opt_info.offset = 0;
+ opt_info.index++;
+ }
+ }
+ pop(psp);
+ return c;
+ help:
+ if (v && *v == '?' && *(v + 1) == '?' && *(v + 2))
+ {
+ s = v + 2;
+ if ((s[0] == 'n' || s[0] == 'N') && (s[1] == 'o' || s[1] == 'O'))
+ {
+ s += 2;
+ n = -1;
+ }
+ else
+ n = 1;
+ if (hp = (Help_t*)search(styles, elementsof(styles), sizeof(styles[0]), s))
+ {
+ if (hp->style < STYLE_man || !(s = argv[opt_info.index]) || s[0] != '-' || s[1] != '-' || !s[2])
+ {
+ opt_info.arg = sfprints("\fversion=%d", version);
+ pop(psp);
+ return '?';
+ }
+ opt_info.state->force = hp->style;
+ }
+ else if (match(s, "ESC", -1, NiL) || match(s, "EMPHASIS", -1, NiL))
+ opt_info.state->emphasis = n;
+ else if (match(s, "PREFORMAT", -1, NiL))
+ opt_info.state->flags |= OPT_preformat;
+ else if (match(s, "TEST", -1, NiL))
+ {
+ opt_info.state->width = OPT_WIDTH;
+ opt_info.state->emphasis = 1;
+ }
+ else
+ {
+ pop(psp);
+ return opterror(v, version, catalog, 0);
+ }
+ psp = pop(psp);
+ if (argv == opt_info.state->strv)
+ return '#';
+ goto again;
+ }
+ if ((opt_info.arg = opthelp(NiL, v)) == (char*)unknown)
+ {
+ pop(psp);
+ return opterror(v, version, catalog, 0);
+ }
+ pop(psp);
+ return '?';
+ nospace:
+ pop(psp);
+ return opterror(NiL, 0, NiL, 0);
+}
+
+/*
+ * parse long options with 0,1,2 leading '-' or '+' from string and pass to optget()
+ * syntax is the unquoted
+ *
+ * <length> [-|+|--|++]<name>[[-+:|&=]=<value>\n (or \0 for the last)
+ *
+ * or the quoted
+ *
+ * [-|+|--|++][no]name[[-+:|&=]=['"{(]value[)}"']][, ]...
+ *
+ * with \x escapes passed to chresc()
+ *
+ * return '#' for `label:', with opt_info.name==label
+ * str[opt_info.offset] next arg
+ *
+ * optstr(s, 0)
+ * return '-' if arg, 0 otherwise
+ * optstr(0, opts)
+ * use previous parsed str
+ */
+
+int
+optstr(const char* str, const char* opts)
+{
+ register char* s = (char*)str;
+ register Sfio_t* mp;
+ register int c;
+ register int ql;
+ register int qr;
+ register int qc;
+ int v;
+ char* e;
+
+ again:
+ if (s)
+ {
+ if (!(mp = opt_info.state->strp) && !(mp = opt_info.state->strp = sfstropen()))
+ return 0;
+ if (opt_info.state->str != s)
+ opt_info.state->str = s;
+ else if (opt_info.index == 1)
+ s += opt_info.offset;
+ while (*s == ',' || *s == ' ' || *s == '\t' || *s == '\n' || *s == '\r')
+ s++;
+ if (!*s)
+ {
+ opt_info.state->str = 0;
+ return 0;
+ }
+ if (*s == '-' || *s == '+')
+ {
+ c = *s++;
+ sfputc(mp, c);
+ if (*s == c)
+ {
+ sfputc(mp, c);
+ s++;
+ }
+ }
+ else
+ {
+ sfputc(mp, '-');
+ sfputc(mp, '-');
+ }
+ if (isdigit(*s) && (v = (int)strtol(s, &e, 10)) > 1 && isspace(*e) && --v <= strlen(s) && (s[v] == 0 || s[v] == '\n'))
+ {
+ s += v;
+ while (isspace(*++e));
+ sfwrite(mp, e, s - e);
+ }
+ else
+ {
+ while (*s && *s != ',' && *s != ' ' && *s != '\t' && *s != '\n' && *s != '\r' && *s != '=' && *s != ':')
+ sfputc(mp, *s++);
+ if ((c = *s) == ':' && *(s + 1) != '=')
+ {
+ opt_info.index = 1;
+ opt_info.offset = ++s - (char*)str;
+ if (!(s = sfstruse(mp)))
+ goto nospace;
+ s += 2;
+ e = opt_info.name;
+ while (e < &opt_info.name[sizeof(opt_info.name)-1] && (*e++ = *s++));
+ opt_info.arg = 0;
+ opt_info.num = opt_info.number = 0;
+ opt_info.option[0] = ':';
+ opt_info.option[1] = 0;
+ return '#';
+ }
+ if (c == ':' || c == '=')
+ {
+ sfputc(mp, c);
+ ql = qr = 0;
+ while (c = *++s)
+ {
+ if (c == '\\')
+ {
+ sfputc(mp, chresc(s, &e));
+ s = e - 1;
+ }
+ else if (c == qr)
+ {
+ if (qr != ql)
+ sfputc(mp, c);
+ if (--qc <= 0)
+ qr = ql = 0;
+ }
+ else if (c == ql)
+ {
+ sfputc(mp, c);
+ qc++;
+ }
+ else if (qr)
+ sfputc(mp, c);
+ else if (c == ',' || c == ' ' || c == '\t' || c == '\n' || c == '\r')
+ break;
+ else if (c == '"' || c == '\'')
+ {
+ ql = qr = c;
+ qc = 1;
+ }
+ else
+ {
+ sfputc(mp, c);
+ if (c == GO)
+ {
+ ql = c;
+ qr = OG;
+ qc = 1;
+ }
+ else if (c == '(')
+ {
+ ql = c;
+ qr = ')';
+ qc = 1;
+ }
+ }
+ }
+ }
+ }
+ opt_info.argv = opt_info.state->strv;
+ opt_info.state->strv[0] = T(NiL, ID, "option");
+ if (!(opt_info.state->strv[1] = sfstruse(mp)))
+ goto nospace;
+ opt_info.state->strv[2] = 0;
+ opt_info.offset = s - (char*)str;
+ }
+ if (opts)
+ {
+ if (!opt_info.state->strv[1])
+ {
+ opt_info.state->str = 0;
+ return 0;
+ }
+ opt_info.index = 1;
+ v = opt_info.offset;
+ opt_info.offset = 0;
+ c = optget(opt_info.state->strv, opts);
+ opt_info.index = 1;
+ opt_info.offset = v;
+ if (c == '#')
+ {
+ s = opt_info.state->str;
+ goto again;
+ }
+ if ((c == '?' || c == ':') && (opt_info.arg[0] == '-' && opt_info.arg[1] == '-'))
+ opt_info.arg += 2;
+ s = opt_info.name;
+ if (*s++ == '-' && *s++ == '-' && *s)
+ {
+ e = opt_info.name;
+ while (*e++ = *s++);
+ }
+ }
+ else
+ c = '-';
+ return c;
+ nospace:
+ return opterror(NiL, 0, NiL, 0);
+}
diff --git a/usr/src/lib/libast/common/misc/optjoin.c b/usr/src/lib/libast/common/misc/optjoin.c
new file mode 100644
index 0000000000..6aa0903810
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/optjoin.c
@@ -0,0 +1,123 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * multi-pass commmand line option parse assist
+ *
+ * int fun(char** argv, int last)
+ *
+ * each fun() argument parses as much of argv as
+ * possible starting at (opt_info.index,opt_info.offset) using
+ * optget()
+ *
+ * if last!=0 then fun is the last pass to view
+ * the current arg, otherwise fun sets opt_info.again=1
+ * and another pass will get a crack at it
+ *
+ * 0 fun() return causes immediate optjoin() 0 return
+ *
+ * optjoin() returns non-zero if more args remain
+ * to be parsed at opt_info.index
+ */
+
+#include <optlib.h>
+
+typedef int (*Optpass_f)(char**, int);
+
+int
+optjoin(char** argv, ...)
+{
+ va_list ap;
+ register Optpass_f fun;
+ register Optpass_f rep;
+ Optpass_f err;
+ int more;
+ int user;
+ int last_index;
+ int last_offset;
+ int err_index;
+ int err_offset;
+
+ if (!opt_info.state)
+ optget(NiL, NiL);
+ err = rep = 0;
+ for (;;)
+ {
+ va_start(ap, argv);
+ opt_info.state->join = 0;
+ while (fun = va_arg(ap, Optpass_f))
+ {
+ last_index = opt_info.index;
+ last_offset = opt_info.offset;
+ opt_info.state->join++;
+ user = (*fun)(argv, 0);
+ more = argv[opt_info.index] != 0;
+ if (!opt_info.again)
+ {
+ if (!more)
+ {
+ opt_info.state->join = 0;
+ return 0;
+ }
+ if (!user)
+ {
+ if (*argv[opt_info.index] != '+')
+ {
+ opt_info.state->join = 0;
+ return 1;
+ }
+ opt_info.again = -1;
+ }
+ else
+ err = 0;
+ }
+ if (opt_info.again)
+ {
+ if (opt_info.again > 0 && (!err || err_index < opt_info.index || err_index == opt_info.index && err_offset < opt_info.offset))
+ {
+ err = fun;
+ err_index = opt_info.index;
+ err_offset = opt_info.offset;
+ }
+ opt_info.again = 0;
+ opt_info.index = opt_info.state->pindex ? opt_info.state->pindex : 1;
+ opt_info.offset = opt_info.state->poffset;
+ }
+ if (!rep || opt_info.index != last_index || opt_info.offset != last_offset)
+ rep = fun;
+ else if (fun == rep)
+ {
+ if (!err)
+ {
+ opt_info.state->join = 0;
+ return 1;
+ }
+ (*err)(argv, 1);
+ opt_info.offset = 0;
+ }
+ }
+ va_end(ap);
+ }
+}
diff --git a/usr/src/lib/libast/common/misc/optlib.h b/usr/src/lib/libast/common/misc/optlib.h
new file mode 100644
index 0000000000..afdf85398a
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/optlib.h
@@ -0,0 +1,106 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * command line option parser and usage formatter private definitions
+ */
+
+#ifndef _OPTLIB_H
+#define _OPTLIB_H
+
+#include <ast.h>
+#include <cdt.h>
+
+#define OPT_cache 0x01
+#define OPT_functions 0x02
+#define OPT_ignore 0x04
+#define OPT_long 0x08
+#define OPT_old 0x10
+#define OPT_plus 0x20
+#define OPT_proprietary 0x40
+
+#define OPT_cache_flag 0x01
+#define OPT_cache_invert 0x02
+#define OPT_cache_numeric 0x04
+#define OPT_cache_optional 0x08
+#define OPT_cache_string 0x10
+
+#define OPT_CACHE 128
+#define OPT_FLAGS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+
+struct Optdisc_s;
+
+typedef struct Optpass_s
+{
+ char* opts;
+ char* oopts;
+ char* catalog;
+ unsigned char version;
+ unsigned char prefix;
+ unsigned char flags;
+ unsigned char section;
+} Optpass_t;
+
+typedef struct Optcache_s
+{
+ struct Optcache_s* next;
+ Optpass_t pass;
+ int caching;
+ unsigned char flags[sizeof(OPT_FLAGS)];
+} Optcache_t;
+
+typedef struct Optstate_s
+{
+ Sfio_t* mp; /* opt_info.msg string stream */
+ Sfio_t* vp; /* translation string stream */
+ Sfio_t* xp; /* translation string stream */
+ Sfio_t* cp; /* compatibility string stream */
+ Optpass_t pass[8]; /* optjoin() list */
+ char* argv[2]; /* initial argv copy */
+ char* strv[3]; /* optstr() argv */
+ char* str; /* optstr() string */
+ Sfio_t* strp; /* optstr() stream */
+ int force; /* force this style */
+ int pindex; /* prev index for backup */
+ int poffset; /* prev offset for backup */
+ int npass; /* # optjoin() passes */
+ int join; /* optjoin() pass # */
+ int plus; /* + ok */
+ int style; /* default opthelp() style */
+ int width; /* format line width */
+ int flags; /* display flags */
+ int emphasis; /* ansi term emphasis ok */
+ Dtdisc_t msgdisc; /* msgdict discipline */
+ Dt_t* msgdict; /* default ast.id catalog msgs */
+ Optcache_t* cache; /* OPT_cache cache */
+} Optstate_t;
+
+#define _OPT_PRIVATE_ \
+ char pad[2*sizeof(void*)]; \
+ Optstate_t* state;
+
+#include <error.h>
+
+#endif
diff --git a/usr/src/lib/libast/common/misc/procclose.c b/usr/src/lib/libast/common/misc/procclose.c
new file mode 100644
index 0000000000..02f8b943ec
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/procclose.c
@@ -0,0 +1,91 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * close a proc opened by procopen()
+ * otherwise exit() status of process is returned
+ */
+
+#include "proclib.h"
+
+#include <wait.h>
+
+int
+procclose(register Proc_t* p)
+{
+ int pid;
+ int flags = 0;
+ int status = -1;
+
+ if (p)
+ {
+ if (p->rfd >= 0)
+ close(p->rfd);
+ if (p->wfd >= 0 && p->wfd != p->rfd)
+ close(p->wfd);
+ if (p->flags & PROC_ZOMBIE)
+ {
+ /*
+ * process may leave a zombie behind
+ * give it a chance to do that but
+ * don't hang waiting for it
+ */
+
+ flags |= WNOHANG;
+ sleep(1);
+ }
+ if (!(p->flags & PROC_FOREGROUND))
+ sigcritical(SIG_REG_EXEC|SIG_REG_PROC);
+ while ((pid = waitpid(p->pid, &status, flags)) == -1 && errno == EINTR);
+ if (pid != p->pid && (flags & WNOHANG))
+ status = 0;
+ if (!(p->flags & PROC_FOREGROUND))
+ sigcritical(0);
+ else
+ {
+ signal(SIGINT, p->sigint);
+ signal(SIGQUIT, p->sigquit);
+#if defined(SIGCHLD)
+#if _lib_sigprocmask
+ sigprocmask(SIG_SETMASK, &p->mask, NiL);
+#else
+#if _lib_sigsetmask
+ sigsetmask(p->mask);
+#endif
+#endif
+ signal(SIGCHLD, p->sigchld);
+#endif
+ }
+ status = status == -1 ?
+ EXIT_QUIT :
+ WIFSIGNALED(status) ?
+ EXIT_TERM(WTERMSIG(status)) :
+ EXIT_CODE(WEXITSTATUS(status));
+ procfree(p);
+ }
+ else
+ status = errno == ENOENT ? EXIT_NOTFOUND : EXIT_NOEXEC;
+ return status;
+}
diff --git a/usr/src/lib/libast/common/misc/procfree.c b/usr/src/lib/libast/common/misc/procfree.c
new file mode 100644
index 0000000000..36a9ce463f
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/procfree.c
@@ -0,0 +1,43 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * free a proc opened by procopen()
+ * skipping wait() and close()
+ */
+
+#include "proclib.h"
+
+int
+procfree(register Proc_t* p)
+{
+ if (!p)
+ return -1;
+ if (p == &proc_default)
+ p->pid = -1;
+ else
+ free(p);
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/misc/proclib.h b/usr/src/lib/libast/common/misc/proclib.h
new file mode 100644
index 0000000000..45749ae47a
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/proclib.h
@@ -0,0 +1,63 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * process library definitions
+ */
+
+#ifndef _PROCLIB_H
+#define _PROCLIB_H
+
+#include <ast.h>
+#include <errno.h>
+#include <sig.h>
+
+#if _lib_sigprocmask
+typedef sigset_t Sig_mask_t;
+#else
+typedef unsigned long Sig_mask_t;
+#endif
+
+struct Mods_s;
+
+#define _PROC_PRIVATE_ \
+ struct Mod_s* mods; /* process modification state */ \
+ long flags; /* original PROC_* flags */ \
+ Sig_mask_t mask; /* original blocked sig mask */ \
+ Sig_handler_t sigchld; /* PROC_FOREGROUND SIG_DFL */ \
+ Sig_handler_t sigint; /* PROC_FOREGROUND SIG_IGN */ \
+ Sig_handler_t sigquit; /* PROC_FOREGROUND SIG_IGN */
+
+#include <proc.h>
+
+#define proc_default _proc_info_ /* hide external symbol */
+
+extern Proc_t proc_default; /* first proc */
+
+#ifndef errno
+extern int errno;
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/misc/procopen.c b/usr/src/lib/libast/common/misc/procopen.c
new file mode 100644
index 0000000000..bdb845a671
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/procopen.c
@@ -0,0 +1,825 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * common process execution support with
+ * proper sfio, signal and wait() syncronization
+ *
+ * _ contains the process path name and is
+ * placed at the top of the environment
+ */
+
+#include "proclib.h"
+
+#include <ls.h>
+
+/*
+ * not quite ready for _use_spawnveg
+ */
+
+#if _use_spawnveg && _lib_fork
+#undef _use_spawnveg
+#endif
+
+#ifndef DEBUG_PROC
+#define DEBUG_PROC 1
+#endif
+
+#if _lib_socketpair
+#if _sys_socket
+#include <sys/types.h>
+#include <sys/socket.h>
+#else
+#undef _lib_socketpair
+#endif
+#endif
+
+Proc_t proc_default = { -1 };
+
+#if DEBUG_PROC
+
+#include <namval.h>
+
+#define PROC_ENV_OPTIONS "PROC_OPTIONS"
+
+#define PROC_OPT_ENVIRONMENT (1<<0)
+#define PROC_OPT_EXEC (1<<1)
+#define PROC_OPT_TRACE (1<<2)
+#define PROC_OPT_VERBOSE (1<<3)
+
+static const Namval_t options[] =
+{
+ "debug", PROC_OPT_VERBOSE,
+ "environment", PROC_OPT_ENVIRONMENT,
+ "exec", PROC_OPT_EXEC,
+ "trace", PROC_OPT_TRACE,
+ "verbose", PROC_OPT_VERBOSE,
+ 0, 0
+};
+
+/*
+ * called by stropt() to set options
+ */
+
+static int
+setopt(register void* a, register const void* p, register int n, const char* v)
+{
+ NoP(v);
+ if (p)
+ {
+ if (n)
+ *((int*)a) |= ((Namval_t*)p)->value;
+ else
+ *((int*)a) &= ~((Namval_t*)p)->value;
+ }
+ return 0;
+}
+
+#endif
+
+#if _use_spawnveg
+
+typedef struct Fd_s
+{
+ short fd;
+ short flag;
+} Fd_t;
+
+typedef struct Mod_s
+{
+ struct Mod_s* next;
+ short op;
+ short save;
+
+ union
+ {
+
+ struct
+ {
+ Fd_t parent;
+ Fd_t child;
+ } fd;
+
+ Handler_t handler;
+
+ } arg;
+
+} Modify_t;
+
+#endif
+
+#ifdef SIGPIPE
+
+/*
+ * catch but ignore sig
+ * avoids SIG_IGN being passed to children
+ */
+
+static void
+ignoresig(int sig)
+{
+ signal(sig, ignoresig);
+}
+
+#endif
+
+/*
+ * do modification op and save previous state for restore()
+ */
+
+static int
+modify(Proc_t* proc, int forked, int op, long arg1, long arg2)
+{
+#if _lib_fork
+ if (forked)
+ {
+ switch (op)
+ {
+ case PROC_fd_dup:
+ case PROC_fd_dup|PROC_FD_PARENT:
+ case PROC_fd_dup|PROC_FD_CHILD:
+ case PROC_fd_dup|PROC_FD_PARENT|PROC_FD_CHILD:
+ if (arg1 != arg2)
+ {
+ if (arg2 != PROC_ARG_NULL)
+ {
+ close(arg2);
+ if (fcntl(arg1, F_DUPFD, arg2) != arg2)
+ return -1;
+ }
+ if (op & PROC_FD_CHILD)
+ close(arg1);
+ }
+ break;
+ case PROC_sig_dfl:
+ signal(arg1, SIG_DFL);
+ break;
+ case PROC_sig_ign:
+ signal(arg1, SIG_IGN);
+ break;
+ case PROC_sys_pgrp:
+ if (arg1 < 0)
+ setsid();
+ else if (arg1 > 0)
+ {
+ if (arg1 == 1)
+ arg1 = 0;
+ if (setpgid(0, arg1) < 0 && arg1 && errno == EPERM)
+ setpgid(0, 0);
+ }
+ break;
+ case PROC_sys_umask:
+ umask(arg1);
+ break;
+ default:
+ return -1;
+ }
+ }
+#if _use_spawnveg
+ else
+#endif
+#else
+ NoP(forked);
+#endif
+#if _use_spawnveg
+ {
+ register Modify_t* m;
+
+ if (!(m = newof(NiL, Modify_t, 1, 0)))
+ return -1;
+ m->next = proc->mods;
+ proc->mods = m;
+ switch (m->op = op)
+ {
+ case PROC_fd_dup:
+ case PROC_fd_dup|PROC_FD_PARENT:
+ case PROC_fd_dup|PROC_FD_CHILD:
+ case PROC_fd_dup|PROC_FD_PARENT|PROC_FD_CHILD:
+ m->arg.fd.parent.fd = (short)arg1;
+ m->arg.fd.parent.flag = fcntl(arg1, F_GETFD, 0);
+ if ((m->arg.fd.child.fd = (short)arg2) != arg1)
+ {
+ if (arg2 != PROC_ARG_NULL)
+ {
+ m->arg.fd.child.flag = fcntl(arg2, F_GETFD, 0);
+ if ((m->save = fcntl(arg2, F_DUPFD, 3)) < 0)
+ {
+ m->op = 0;
+ return -1;
+ }
+ fcntl(m->save, F_SETFD, FD_CLOEXEC);
+ close(arg2);
+ if (fcntl(arg1, F_DUPFD, arg2) != arg2)
+ return -1;
+ if (op & PROC_FD_CHILD)
+ close(arg1);
+ }
+ else if (op & PROC_FD_CHILD)
+ {
+ if (m->arg.fd.parent.flag)
+ break;
+ fcntl(arg1, F_SETFD, FD_CLOEXEC);
+ }
+ else if (!m->arg.fd.parent.flag)
+ break;
+ else
+ fcntl(arg1, F_SETFD, 0);
+ return 0;
+ }
+ break;
+ case PROC_sig_dfl:
+ if ((m->arg.handler = signal(arg1, SIG_DFL)) == SIG_DFL)
+ break;
+ m->save = (short)arg1;
+ return 0;
+ case PROC_sig_ign:
+ if ((m->arg.handler = signal(arg1, SIG_IGN)) == SIG_IGN)
+ break;
+ m->save = (short)arg1;
+ return 0;
+ case PROC_sys_pgrp:
+ proc->pgrp = arg1;
+ break;
+ case PROC_sys_umask:
+ if ((m->save = (short)umask(arg1)) == arg1)
+ break;
+ return 0;
+ default:
+ proc->mods = m->next;
+ free(m);
+ return -1;
+ }
+ proc->mods = m->next;
+ free(m);
+ }
+#else
+ NoP(proc);
+#endif
+ return 0;
+}
+
+#if _use_spawnveg
+
+/*
+ * restore modifications
+ */
+
+static void
+restore(Proc_t* proc)
+{
+ register Modify_t* m;
+ register Modify_t* p;
+ int oerrno;
+
+ NoP(proc);
+ oerrno = errno;
+ m = proc->mods;
+ proc->mods = 0;
+ while (m)
+ {
+ switch (m->op)
+ {
+ case PROC_fd_dup:
+ case PROC_fd_dup|PROC_FD_PARENT:
+ case PROC_fd_dup|PROC_FD_CHILD:
+ case PROC_fd_dup|PROC_FD_PARENT|PROC_FD_CHILD:
+ if (m->op & PROC_FD_PARENT)
+ close(m->arg.fd.parent.fd);
+ if (m->arg.fd.child.fd != m->arg.fd.parent.fd && m->arg.fd.child.fd != PROC_ARG_NULL)
+ {
+ if (!(m->op & PROC_FD_PARENT))
+ {
+ if (m->op & PROC_FD_CHILD)
+ {
+ close(m->arg.fd.parent.fd);
+ fcntl(m->arg.fd.child.fd, F_DUPFD, m->arg.fd.parent.fd);
+ }
+ fcntl(m->arg.fd.parent.fd, F_SETFD, m->arg.fd.parent.flag);
+ }
+ close(m->arg.fd.child.fd);
+ fcntl(m->save, F_DUPFD, m->arg.fd.child.fd);
+ close(m->save);
+ if (m->arg.fd.child.flag)
+ fcntl(m->arg.fd.child.fd, F_SETFD, FD_CLOEXEC);
+ }
+ else if ((m->op & (PROC_FD_PARENT|PROC_FD_CHILD)) == PROC_FD_CHILD)
+ fcntl(m->arg.fd.parent.fd, F_SETFD, 0);
+ break;
+ case PROC_sig_dfl:
+ case PROC_sig_ign:
+ signal(m->save, m->arg.handler);
+ break;
+ case PROC_sys_umask:
+ umask(m->save);
+ break;
+ }
+ p = m;
+ m = m->next;
+ free(p);
+ }
+ errno = oerrno;
+}
+
+#else
+
+#define restore(p)
+
+#endif
+
+/*
+ * fork and exec or spawn proc(argv) and return a Proc_t handle
+ *
+ * pipe not used when PROC_READ|PROC_WRITE omitted
+ * argv==0 duplicates current process if possible
+ * cmd==0 names the current shell
+ * cmd=="" does error cleanup
+ * envv is the child environment
+ * modv is the child modification vector of PROC_*() ops
+ */
+
+Proc_t*
+procopen(const char* cmd, char** argv, char** envv, long* modv, long flags)
+{
+ register Proc_t* proc = 0;
+ register int procfd;
+ register char** p;
+ char** v;
+ int i;
+ int forked = 0;
+ long n;
+ char path[PATH_MAX];
+ char env[PATH_MAX + 2];
+ int pio[2];
+#if !_pipe_rw && !_lib_socketpair
+ int poi[2];
+#endif
+#if defined(SIGCHLD) && ( _lib_sigprocmask || _lib_sigsetmask )
+ Sig_mask_t mask;
+#endif
+#if _use_spawnveg
+ int newenv = 0;
+#endif
+#if DEBUG_PROC
+ int debug = PROC_OPT_EXEC;
+#endif
+
+#if _lib_fork
+ if (!argv && (flags & PROC_OVERLAY))
+#else
+ if (!argv)
+#endif
+ {
+ errno = ENOEXEC;
+ return 0;
+ }
+ pio[0] = pio[1] = -1;
+#if !_pipe_rw && !_lib_socketpair
+ poi[0] = poi[1] = -1;
+#endif
+ if (cmd && (!*cmd || !pathpath(path, cmd, NiL, PATH_REGULAR|PATH_EXECUTE)))
+ goto bad;
+ switch (flags & (PROC_READ|PROC_WRITE))
+ {
+ case 0:
+ procfd = -1;
+ break;
+ case PROC_READ:
+ procfd = 1;
+ break;
+ case PROC_WRITE:
+ procfd = 0;
+ break;
+ case PROC_READ|PROC_WRITE:
+ procfd = 2;
+ break;
+ }
+ if (proc_default.pid == -1)
+ proc = &proc_default;
+ else if (!(proc = newof(0, Proc_t, 1, 0)))
+ goto bad;
+ proc->pid = -1;
+ proc->pgrp = 0;
+ proc->rfd = -1;
+ proc->wfd = -1;
+ proc->flags = flags;
+ sfsync(NiL);
+ if (environ && envv != (char**)environ && (envv || (flags & PROC_PARANOID) || argv && (environ[0][0] != '_' || environ[0][1] != '=')))
+ {
+ if (!setenviron(NiL))
+ goto bad;
+#if _use_spawnveg
+ newenv = 1;
+#endif
+ }
+ if (procfd >= 0)
+ {
+#if _pipe_rw
+ if (pipe(pio))
+ goto bad;
+#else
+ if (procfd > 1)
+ {
+#if _lib_socketpair
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, pio))
+ goto bad;
+#else
+ if (pipe(pio) || pipe(poi))
+ goto bad;
+#endif
+ }
+ else if (pipe(pio))
+ goto bad;
+#endif
+ }
+ if (flags & PROC_OVERLAY)
+ {
+ proc->pid = 0;
+ forked = 1;
+ }
+#if _use_spawnveg
+ else if (argv)
+ proc->pid = 0;
+#endif
+#if _lib_fork
+ else
+ {
+ if (!(flags & PROC_FOREGROUND))
+ sigcritical(SIG_REG_EXEC|SIG_REG_PROC);
+ else
+ {
+ proc->sigint = signal(SIGINT, SIG_IGN);
+ proc->sigquit = signal(SIGQUIT, SIG_IGN);
+#if defined(SIGCHLD)
+ proc->sigchld = signal(SIGCHLD, SIG_DFL);
+#if _lib_sigprocmask
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &mask, &proc->mask);
+#else
+#if _lib_sigsetmask
+ mask = sigmask(SIGCHLD);
+ proc->mask = sigblock(mask);
+#endif
+#endif
+#endif
+ }
+ proc->pid = fork();
+ if (!(flags & PROC_FOREGROUND))
+ sigcritical(0);
+ else if (!proc->pid)
+ {
+ if (proc->sigint != SIG_IGN)
+ proc->sigint = SIG_DFL;
+ signal(SIGINT, proc->sigint);
+ if (proc->sigquit != SIG_IGN)
+ proc->sigquit = SIG_DFL;
+ signal(SIGQUIT, proc->sigquit);
+#if defined(SIGCHLD)
+ if (proc->sigchld != SIG_IGN)
+ proc->sigchld = SIG_DFL;
+ signal(SIGCHLD, proc->sigchld);
+#endif
+ }
+ if (proc->pid == -1)
+ goto bad;
+ forked = 1;
+ }
+#endif
+ if (!proc->pid)
+ {
+ char* s;
+#if _use_spawnveg
+ char** oenviron = 0;
+ char* oenviron0 = 0;
+
+ v = 0;
+#endif
+#if DEBUG_PROC
+ stropt(getenv(PROC_ENV_OPTIONS), options, sizeof(*options), setopt, &debug);
+#if _lib_fork
+ if (debug & PROC_OPT_TRACE)
+ {
+ if (!fork())
+ {
+ sfsprintf(path, sizeof(path), "%d", getppid());
+ execlp("trace", "trace", "-p", path, NiL);
+ _exit(EXIT_NOTFOUND);
+ }
+ sleep(2);
+ }
+#endif
+#endif
+ if (flags & PROC_DAEMON)
+ {
+#ifdef SIGHUP
+ modify(proc, forked, PROC_sig_ign, SIGHUP, 0);
+#endif
+ modify(proc, forked, PROC_sig_dfl, SIGTERM, 0);
+#ifdef SIGTSTP
+ modify(proc, forked, PROC_sig_ign, SIGTSTP, 0);
+#endif
+#ifdef SIGTTIN
+ modify(proc, forked, PROC_sig_ign, SIGTTIN, 0);
+#endif
+#ifdef SIGTTOU
+ modify(proc, forked, PROC_sig_ign, SIGTTOU, 0);
+#endif
+ }
+ if (flags & (PROC_BACKGROUND|PROC_DAEMON))
+ {
+ modify(proc, forked, PROC_sig_ign, SIGINT, 0);
+#ifdef SIGQUIT
+ modify(proc, forked, PROC_sig_ign, SIGQUIT, 0);
+#endif
+ }
+ if (flags & (PROC_DAEMON|PROC_SESSION))
+ modify(proc, forked, PROC_sys_pgrp, -1, 0);
+ if (forked || (flags & PROC_OVERLAY))
+ {
+ if ((flags & PROC_PRIVELEGED) && !geteuid())
+ {
+ setuid(geteuid());
+ setgid(getegid());
+ }
+ if (flags & (PROC_PARANOID|PROC_GID))
+ setgid(getgid());
+ if (flags & (PROC_PARANOID|PROC_UID))
+ setuid(getuid());
+ }
+ if (procfd > 1)
+ {
+ if (modify(proc, forked, PROC_fd_dup|PROC_FD_CHILD, pio[0], PROC_ARG_NULL))
+ goto cleanup;
+ if (modify(proc, forked, PROC_fd_dup|PROC_FD_CHILD, pio[1], 1))
+ goto cleanup;
+#if _pipe_rw || _lib_socketpair
+ if (modify(proc, forked, PROC_fd_dup, 1, 0))
+ goto cleanup;
+#else
+ if (modify(proc, forked, PROC_fd_dup|PROC_FD_CHILD, poi[0], 0))
+ goto cleanup;
+ if (poi[1] != 0 && modify(proc, forked, PROC_fd_dup|PROC_FD_CHILD, poi[1], PROC_ARG_NULL))
+ goto cleanup;
+#endif
+ }
+ else if (procfd >= 0)
+ {
+ if (modify(proc, forked, PROC_fd_dup|PROC_FD_CHILD, pio[!!procfd], !!procfd))
+ goto cleanup;
+ if (pio[!procfd] != !!procfd && modify(proc, forked, PROC_fd_dup|PROC_FD_CHILD, pio[!procfd], PROC_ARG_NULL))
+ goto cleanup;
+ }
+ if (modv)
+ for (i = 0; n = modv[i]; i++)
+ switch (PROC_OP(n))
+ {
+ case PROC_fd_dup:
+ case PROC_fd_dup|PROC_FD_PARENT:
+ case PROC_fd_dup|PROC_FD_CHILD:
+ case PROC_fd_dup|PROC_FD_PARENT|PROC_FD_CHILD:
+ if (modify(proc, forked, PROC_OP(n), PROC_ARG(n, 1), PROC_ARG(n, 2)))
+ goto cleanup;
+ break;
+ default:
+ if (modify(proc, forked, PROC_OP(n), PROC_ARG(n, 1), 0))
+ goto cleanup;
+ break;
+ }
+#if _lib_fork
+ if (forked && (flags & PROC_ENVCLEAR))
+ environ = 0;
+#if _use_spawnveg
+ else
+#endif
+#endif
+#if _use_spawnveg
+ if (newenv)
+ {
+ p = environ;
+ while (*p++);
+ if (!(oenviron = (char**)memdup(environ, (p - environ) * sizeof(char*))))
+ goto cleanup;
+ }
+#endif
+ if (argv && envv != (char**)environ)
+ {
+#if _use_spawnveg
+ if (!newenv && environ[0][0] == '_' && environ[0][1] == '=')
+ oenviron0 = environ[0];
+#endif
+ env[0] = '_';
+ env[1] = '=';
+ env[2] = 0;
+ if (!setenviron(env))
+ goto cleanup;
+ }
+ if ((flags & PROC_PARANOID) && setenv("PATH", astconf("PATH", NiL, NiL), 1))
+ goto cleanup;
+ if ((p = envv) && p != (char**)environ)
+ while (*p)
+ if (!setenviron(*p++))
+ goto cleanup;
+ p = argv;
+#if _lib_fork
+ if (forked && !p)
+ return proc;
+#endif
+#if DEBUG_PROC
+ if (!(debug & PROC_OPT_EXEC) || (debug & PROC_OPT_VERBOSE))
+ {
+ if ((debug & PROC_OPT_ENVIRONMENT) && (p = environ))
+ while (*p)
+ sfprintf(sfstderr, "%s\n", *p++);
+ sfprintf(sfstderr, "+ %s", cmd ? path : "sh");
+ if ((p = argv) && *p)
+ while (*++p)
+ sfprintf(sfstderr, " %s", *p);
+ sfprintf(sfstderr, "\n");
+sfsync(sfstderr);
+ if (!(debug & PROC_OPT_EXEC))
+ _exit(0);
+ p = argv;
+ }
+#endif
+ if (cmd)
+ {
+ strcpy(env + 2, path);
+ if (forked || (flags & PROC_OVERLAY))
+ execve(path, p, environ);
+#if _use_spawnveg
+ else if ((proc->pid = spawnveg(path, p, environ, proc->pgrp)) != -1)
+ goto cleanup;
+#endif
+ if (errno != ENOEXEC)
+ goto cleanup;
+
+ /*
+ * try cmd as a shell script
+ */
+
+ if (!(flags & PROC_ARGMOD))
+ {
+ while (*p++);
+ if (!(v = newof(0, char*, p - argv + 2, 0)))
+ goto cleanup;
+ p = v + 2;
+ if (*argv)
+ argv++;
+ while (*p++ = *argv++);
+ p = v + 1;
+ }
+ *p = path;
+ *--p = "sh";
+ }
+ strcpy(env + 2, (flags & PROC_PARANOID) ? astconf("SH", NiL, NiL) : pathshell());
+ if (forked || (flags & PROC_OVERLAY))
+ execve(env + 2, p, environ);
+#if _use_spawnveg
+ else
+ proc->pid = spawnveg(env + 2, p, environ, proc->pgrp);
+#endif
+ cleanup:
+ if (forked)
+ {
+ if (!(flags & PROC_OVERLAY))
+ _exit(errno == ENOENT ? EXIT_NOTFOUND : EXIT_NOEXEC);
+ goto bad;
+ }
+#if _use_spawnveg
+ if (v)
+ free(v);
+ if (p = oenviron)
+ {
+ environ = 0;
+ while (*p)
+ if (!setenviron(*p++))
+ goto bad;
+ free(oenviron);
+ }
+ else if (oenviron0)
+ environ[0] = oenviron0;
+ restore(proc);
+ if (flags & PROC_OVERLAY)
+ exit(0);
+#endif
+ }
+ if (proc->pid != -1)
+ {
+ if (!forked)
+ {
+ if (flags & PROC_FOREGROUND)
+ {
+ proc->sigint = signal(SIGINT, SIG_IGN);
+ proc->sigquit = signal(SIGQUIT, SIG_IGN);
+#if defined(SIGCHLD)
+ proc->sigchld = signal(SIGCHLD, SIG_DFL);
+#endif
+ }
+ }
+ else if (modv)
+ for (i = 0; n = modv[i]; i++)
+ switch (PROC_OP(n))
+ {
+ case PROC_fd_dup|PROC_FD_PARENT:
+ case PROC_fd_dup|PROC_FD_PARENT|PROC_FD_CHILD:
+ close(PROC_ARG(n, 1));
+ break;
+ case PROC_sys_pgrp:
+ if (proc->pgrp < 0)
+ proc->pgrp = proc->pid;
+ else if (proc->pgrp > 0)
+ {
+ if (proc->pgrp == 1)
+ proc->pgrp = proc->pid;
+ if (setpgid(proc->pid, proc->pgrp) < 0 && proc->pid != proc->pgrp && errno == EPERM)
+ setpgid(proc->pid, proc->pid);
+ }
+ break;
+ }
+ if (procfd >= 0)
+ {
+#ifdef SIGPIPE
+ if ((flags & (PROC_WRITE|PROC_IGNORE)) == (PROC_WRITE|PROC_IGNORE))
+ {
+ Handler_t handler;
+
+ if ((handler = signal(SIGPIPE, ignoresig)) != SIG_DFL && handler != ignoresig)
+ signal(SIGPIPE, handler);
+ }
+#endif
+ switch (procfd)
+ {
+ case 0:
+ proc->wfd = pio[1];
+ close(pio[0]);
+ break;
+ default:
+#if _pipe_rw || _lib_socketpair
+ proc->wfd = pio[0];
+#else
+ proc->wfd = poi[1];
+ close(poi[0]);
+#endif
+ /*FALLTHROUGH*/
+ case 1:
+ proc->rfd = pio[0];
+ close(pio[1]);
+ break;
+ }
+ if (proc->rfd > 2)
+ fcntl(proc->rfd, F_SETFD, FD_CLOEXEC);
+ if (proc->wfd > 2)
+ fcntl(proc->wfd, F_SETFD, FD_CLOEXEC);
+ }
+ if (!proc->pid)
+ proc->pid = getpid();
+ return proc;
+ }
+ bad:
+ if ((flags & PROC_CLEANUP) && modv)
+ for (i = 0; n = modv[i]; i++)
+ switch (PROC_OP(n))
+ {
+ case PROC_fd_dup:
+ case PROC_fd_dup|PROC_FD_PARENT:
+ case PROC_fd_dup|PROC_FD_CHILD:
+ case PROC_fd_dup|PROC_FD_PARENT|PROC_FD_CHILD:
+ if (PROC_ARG(n, 2) != PROC_ARG_NULL)
+ close(PROC_ARG(n, 1));
+ break;
+ }
+ if (pio[0] >= 0)
+ close(pio[0]);
+ if (pio[1] >= 0)
+ close(pio[1]);
+#if !_pipe_rw && !_lib_socketpair
+ if (poi[0] >= 0)
+ close(poi[0]);
+ if (poi[1] >= 0)
+ close(poi[1]);
+#endif
+ procfree(proc);
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/misc/procrun.c b/usr/src/lib/libast/common/misc/procrun.c
new file mode 100644
index 0000000000..67b07b24cc
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/procrun.c
@@ -0,0 +1,40 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * procopen() + procclose()
+ * no env changes
+ * no modifications
+ * effective=real
+ * parent ignores INT & QUIT
+ */
+
+#include "proclib.h"
+
+int
+procrun(const char* path, char** argv)
+{
+ return procclose(procopen(path, argv, NiL, NiL, PROC_FOREGROUND|PROC_GID|PROC_UID));
+}
diff --git a/usr/src/lib/libast/common/misc/recfmt.c b/usr/src/lib/libast/common/misc/recfmt.c
new file mode 100644
index 0000000000..73aa77d197
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/recfmt.c
@@ -0,0 +1,165 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * determine record format by sampling data in <buf,size>
+ * total is the total file size, <=0 if not available
+ * return r:
+ * -1 could not determine
+ * RECTYPE(r)==REC_fixed fixed length REC_F_SIZE(r)
+ * RECTYPE(r)==REC_delimited variable length delimiter=REC_D_DELIMITER(r)
+ * RECTYPE(r)==REC_variable variable length
+ */
+
+#include <recfmt.h>
+
+typedef struct
+{
+ unsigned int rep[4 * 1024];
+ unsigned int hit[UCHAR_MAX + 1];
+} Sample_t;
+
+Recfmt_t
+recfmt(const void* buf, size_t size, off_t total)
+{
+ register unsigned char* s;
+ register unsigned char* t;
+ register Sample_t* q;
+ register unsigned int* h;
+ register unsigned int i;
+ unsigned int j;
+ unsigned int k;
+ unsigned int n;
+ unsigned int m;
+ unsigned int x;
+ unsigned long f;
+ unsigned long g;
+
+ static unsigned char terminators[] = { '\n', 0x15, 0x25 };
+
+ /*
+ * check for V format
+ */
+
+ s = (unsigned char*)buf;
+ t = s + size;
+ while ((k = (t - s)) >= 4 && !s[2] && !s[3])
+ {
+ if ((i = (s[0]<<8)|s[1]) > k)
+ break;
+ s += i;
+ }
+ if (!k || size > 2 * k)
+ return REC_V_TYPE(4, 0, 2, 0, 1);
+ s = (unsigned char*)buf;
+
+ /*
+ * check for terminated records
+ */
+
+ for (i = 0; i < elementsof(terminators); i++)
+ if ((t = (unsigned char*)memchr((void*)s, k = terminators[i], size / 2)) && (n = t - s + 1) > 1 && (total <= 0 || !(total % n)))
+ {
+ for (j = n - 1; j < size; j += n)
+ if (s[j] != k)
+ {
+ n = 0;
+ break;
+ }
+ if (n)
+ return REC_D_TYPE(terminators[i]);
+ }
+
+ /*
+ * check fixed length record frequencies
+ */
+
+ if (!(q = newof(0, Sample_t, 1, 0)))
+ return REC_N_TYPE();
+ x = 0;
+ for (i = 0; i < size; i++)
+ {
+ h = q->hit + s[i];
+ m = i - *h;
+ *h = i;
+ if (m < elementsof(q->rep))
+ {
+ if (m > x)
+ x = m;
+ q->rep[m]++;
+ }
+ }
+ n = 0;
+ m = 0;
+ f = ~0;
+ for (i = x; i > 1; i--)
+ {
+ if ((total <= 0 || !(total % i)) && q->rep[i] > q->rep[n])
+ {
+ m++;
+ g = 0;
+ for (j = i; j < size - i; j += i)
+ for (k = 0; k < i; k++)
+ if (s[j + k] != s[j + k - i])
+ g++;
+ g = (((g * 100) / i) * 100) / q->rep[i];
+ if (g <= f)
+ {
+ f = g;
+ n = i;
+ }
+ }
+ }
+ if (m <= 1 && n <= 2 && total > 1 && total < 256)
+ {
+ n = 0;
+ for (i = 0; i < size; i++)
+ for (j = 0; j < elementsof(terminators); j++)
+ if (s[i] == terminators[j])
+ n++;
+ n = n ? 0 : total;
+ }
+ free(q);
+ return n ? REC_F_TYPE(n) : REC_N_TYPE();
+}
+
+#if MAIN
+
+main()
+{
+ void* s;
+ size_t size;
+ off_t total;
+
+ if (!(s = sfreserve(sfstdin, SF_UNBOUND, 0)))
+ {
+ sfprintf(sfstderr, "read error\n");
+ return 1;
+ }
+ size = sfvalue(sfstdin);
+ total = sfsize(sfstdin);
+ sfprintf(sfstdout, "%d\n", recfmt(s, size, total));
+ return 0;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/misc/reclen.c b/usr/src/lib/libast/common/misc/reclen.c
new file mode 100644
index 0000000000..fa9ffd3149
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/reclen.c
@@ -0,0 +1,71 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * return the length of the current record at b, size n, according to f
+ * -1 returned on error
+ * 0 returned if more data is required
+ */
+
+#include <recfmt.h>
+#include <ctype.h>
+
+ssize_t
+reclen(Recfmt_t f, const void* b, size_t n)
+{
+ register unsigned char* s = (unsigned char*)b;
+ register unsigned char* e;
+ size_t h;
+ size_t z;
+
+ switch (RECTYPE(f))
+ {
+ case REC_delimited:
+ if (e = (unsigned char*)memchr(s, REC_D_DELIMITER(f), n))
+ return e - s + 1;
+ return 0;
+ case REC_fixed:
+ return REC_F_SIZE(f);
+ case REC_variable:
+ h = REC_V_HEADER(f);
+ if (n < h)
+ return 0;
+ z = 0;
+ s += REC_V_OFFSET(f);
+ e = s + REC_V_LENGTH(f);
+ if (REC_V_LITTLE(f))
+ while (e > s)
+ z = (z<<8)|*--e;
+ else
+ while (s < e)
+ z = (z<<8)|*s++;
+ if (!REC_V_INCLUSIVE(f))
+ z += h;
+ else if (z < h)
+ z = h;
+ return z;
+ case REC_method:
+ return -1;
+ }
+ return -1;
+}
diff --git a/usr/src/lib/libast/common/misc/recstr.c b/usr/src/lib/libast/common/misc/recstr.c
new file mode 100644
index 0000000000..1d0c823b91
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/recstr.c
@@ -0,0 +1,203 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * return the record format descriptor given a format string
+ * e!=0 set to the first unrecognized char after the format
+ * REC_N_TYPE() returned on error
+ *
+ * d[0xNN|delimiter] (delimited, newline default)
+ * [f][+]size (fixed length)
+ * v hN oN zN b|l i|n (variable length with size header)
+ * h header size in bytes (ibm V 4)
+ * o size offset in bytes (ibm V 0)
+ * z size length in bytes (ibm V 2)
+ * l|b little-endian or big-endian size (ibm V b (0))
+ * i|n header included/not-included in size (ibm V i (1))
+ */
+
+#include <recfmt.h>
+#include <ctype.h>
+
+Recfmt_t
+recstr(register const char* s, char** e)
+{
+ char* t;
+ int n;
+ long v;
+ int a[6];
+
+ while (*s == ' ' || *s == '\t' || *s == ',')
+ s++;
+ switch (*s)
+ {
+ case 'd':
+ case 'D':
+ if (!*s)
+ n = '\n';
+ else
+ {
+ if (*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))
+ n = (int)strtol(s, &t, 0);
+ else
+ n = chresc(s, &t);
+ s = (const char*)t;
+ }
+ if (e)
+ *e = (char*)s;
+ return REC_D_TYPE(n);
+ case 'f':
+ case 'F':
+ while (*++s == ' ' || *s == '\t' || *s == ',');
+ /*FALLTHROUGH*/
+ case '+':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ n = strton(s, &t, NiL, 0);
+ if (n > 0 && t > (char*)s)
+ {
+ if (e)
+ *e = t;
+ return REC_F_TYPE(n);
+ }
+ break;
+ case 'm':
+ case 'M':
+ while (*++s == ' ' || *s == '\t' || *s == ',');
+ for (t = (char*)s; *t && *t != ' ' && *t != '\t' && *t != ','; t++);
+ if ((t - s) == 4)
+ {
+ if (strneq(s, "data", 4))
+ {
+ if (e)
+ *e = t;
+ return REC_M_TYPE(REC_M_data);
+ }
+ else if (strneq(s, "path", 4))
+ {
+ if (e)
+ *e = t;
+ return REC_M_TYPE(REC_M_path);
+ }
+ }
+
+ /*
+ * TBD: look up name in method libraries
+ * and assign an integer index
+ */
+
+ break;
+ case 'u':
+ case 'U':
+ while (*++s == ' ' || *s == '\t' || *s == ',');
+ n = strtol(s, &t, 0);
+ if (n < 0 || n > 15 || *t++ != '.')
+ break;
+ v = strtol(t, &t, 0);
+ if (*t)
+ break;
+ if (e)
+ *e = t;
+ return REC_U_TYPE(n, v);
+ case 'v':
+ case 'V':
+ a[0] = 0;
+ a[1] = 4;
+ a[2] = 0;
+ a[3] = 2;
+ a[4] = 0;
+ a[5] = 1;
+ n = 0;
+ for (;;)
+ {
+ switch (*++s)
+ {
+ case 0:
+ break;
+ case 'm':
+ case 'M':
+ n = 0;
+ continue;
+ case 'h':
+ case 'H':
+ n = 1;
+ continue;
+ case 'o':
+ case 'O':
+ n = 2;
+ continue;
+ case 'z':
+ case 'Z':
+ n = 3;
+ continue;
+ case 'b':
+ case 'B':
+ n = 4;
+ a[n++] = 0;
+ continue;
+ case 'l':
+ case 'L':
+ n = 4;
+ a[n++] = 1;
+ continue;
+ case 'n':
+ case 'N':
+ n = 0;
+ a[5] = 0;
+ continue;
+ case 'i':
+ case 'I':
+ n = 0;
+ a[5] = 1;
+ continue;
+ case ' ':
+ case '\t':
+ case ',':
+ case '-':
+ case '+':
+ continue;
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ a[n++] = strtol(s, &t, 0);
+ s = (const char*)t - 1;
+ continue;
+ }
+ break;
+ }
+ if (e)
+ *e = (char*)s;
+ return REC_V_RECORD(REC_V_TYPE(a[1], a[2], a[3], a[4], a[5]), a[0]);
+ case '%':
+ if (e)
+ *e = (char*)s + 1;
+ return REC_M_TYPE(REC_M_path);
+ case '-':
+ case '?':
+ if (e)
+ *e = (char*)s + 1;
+ return REC_M_TYPE(REC_M_data);
+ }
+ if (e)
+ *e = (char*)s;
+ return REC_N_TYPE();
+}
diff --git a/usr/src/lib/libast/common/misc/setenviron.c b/usr/src/lib/libast/common/misc/setenviron.c
new file mode 100644
index 0000000000..1bf9a57f8c
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/setenviron.c
@@ -0,0 +1,142 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * put name=value in the environment
+ * pointer to value returned
+ * environ==0 is ok
+ *
+ * setenviron("N=V") add N=V
+ * setenviron("N") delete N
+ * setenviron(0) expect more (pre-fork optimization)
+ *
+ * _ always placed at the top
+ */
+
+#include <ast.h>
+#include <fs3d.h>
+
+#define INCREMENT 16 /* environ increment */
+
+char*
+setenviron(const char* akey)
+{
+ static char** envv; /* recorded environ */
+ static char** next; /* next free slot */
+ static char** last; /* last free slot (0) */
+ static char ok[] = ""; /* delete/optimization ok return*/
+
+ char* key = (char*)akey;
+ register char** v = environ;
+ register char** p = envv;
+ register char* s;
+ register char* t;
+ int n;
+
+ ast.env_serial++;
+ if (p && !v)
+ {
+ environ = next = p;
+ *++next = 0;
+ }
+ else if (p != v || !v)
+ {
+ if (v)
+ {
+ while (*v++);
+ n = v - environ + INCREMENT;
+ v = environ;
+ }
+ else
+ n = INCREMENT;
+ if (!p || (last - p + 1) < n)
+ {
+ if (!p && fs3d(FS3D_TEST))
+ {
+ /*
+ * kick 3d initialization
+ */
+
+ close(open(".", O_RDONLY));
+ v = environ;
+ }
+ if (!(p = newof(p, char*, n, 0)))
+ return 0;
+ last = p + n - 1;
+ }
+ envv = environ = p;
+ if (v && v[0] && v[0][0] == '_' && v[0][1] == '=')
+ *p++ = *v++;
+ else
+ *p++ = "_=";
+ if (!v)
+ *p = 0;
+ else
+ while (*p = *v++)
+ if (p[0][0] == '_' && p[0][1] == '=')
+ envv[0] = *p;
+ else
+ p++;
+ next = p;
+ p = envv;
+ }
+ else if (next == last)
+ {
+ n = last - v + INCREMENT + 1;
+ if (!(p = newof(p, char*, n, 0)))
+ return 0;
+ last = p + n - 1;
+ next = last - INCREMENT;
+ envv = environ = p;
+ }
+ if (!key)
+ return ok;
+ for (; s = *p; p++)
+ {
+ t = key;
+ do
+ {
+ if (!*t || *t == '=')
+ {
+ if (*s == '=')
+ {
+ if (!*t)
+ {
+ v = p++;
+ while (*v++ = *p++);
+ next--;
+ return ok;
+ }
+ *p = key;
+ return (s = strchr(key, '=')) ? s + 1 : (char*)0;
+ }
+ break;
+ }
+ } while (*t++ == *s++);
+ }
+ if (!(s = strchr(key, '=')))
+ return ok;
+ p = next;
+ *++next = 0;
+ *p = key;
+ return s + 1;
+}
diff --git a/usr/src/lib/libast/common/misc/sigcrit.c b/usr/src/lib/libast/common/misc/sigcrit.c
new file mode 100644
index 0000000000..a51f7408a0
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/sigcrit.c
@@ -0,0 +1,199 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * signal critical region support
+ */
+
+#include <ast.h>
+#include <sig.h>
+
+static struct
+{
+ int sig;
+ int op;
+}
+signals[] = /* held inside critical region */
+{
+ SIGINT, SIG_REG_EXEC,
+#ifdef SIGPIPE
+ SIGPIPE, SIG_REG_EXEC,
+#endif
+#ifdef SIGQUIT
+ SIGQUIT, SIG_REG_EXEC,
+#endif
+#ifdef SIGHUP
+ SIGHUP, SIG_REG_EXEC,
+#endif
+#if defined(SIGCHLD) && ( !defined(SIGCLD) || SIGCHLD != SIGCLD || _lib_sigprocmask || _lib_sigsetmask )
+ SIGCHLD, SIG_REG_PROC,
+#endif
+#ifdef SIGTSTP
+ SIGTSTP, SIG_REG_TERM,
+#endif
+#ifdef SIGTTIN
+ SIGTTIN, SIG_REG_TERM,
+#endif
+#ifdef SIGTTOU
+ SIGTTOU, SIG_REG_TERM,
+#endif
+};
+
+#ifndef SIG_SETMASK
+#undef _lib_sigprocmask
+#endif
+
+#if !_lib_sigprocmask && !_lib_sigsetmask
+
+static long hold; /* held signal mask */
+
+/*
+ * hold last signal for later delivery
+ */
+
+static void
+interrupt(int sig)
+{
+ signal(sig, interrupt);
+ hold |= sigmask(sig);
+}
+
+#endif
+
+/*
+ * critical signal region handler
+ *
+ * op>0 new region according to SIG_REG_*, return region level
+ * op==0 pop region, return region level
+ * op<0 return non-zero if any signals held in current region
+ *
+ * signals[] held until region popped
+ */
+
+int
+sigcritical(int op)
+{
+ register int i;
+ static int region;
+ static int level;
+#if _lib_sigprocmask
+ static sigset_t mask;
+ sigset_t nmask;
+#else
+#if _lib_sigsetmask
+ static long mask;
+#else
+ static Sig_handler_t handler[elementsof(signals)];
+#endif
+#endif
+
+ if (op > 0)
+ {
+ if (!level++)
+ {
+ region = op;
+ if (op & SIG_REG_SET)
+ level--;
+#if _lib_sigprocmask
+ sigemptyset(&nmask);
+ for (i = 0; i < elementsof(signals); i++)
+ if (op & signals[i].op)
+ sigaddset(&nmask, signals[i].sig);
+ sigprocmask(SIG_BLOCK, &nmask, &mask);
+#else
+#if _lib_sigsetmask
+ mask = 0;
+ for (i = 0; i < elementsof(signals); i++)
+ if (op & signals[i].op)
+ mask |= sigmask(signals[i].sig);
+ mask = sigblock(mask);
+#else
+ hold = 0;
+ for (i = 0; i < elementsof(signals); i++)
+ if ((op & signals[i].op) && (handler[i] = signal(signals[i].sig, interrupt)) == SIG_IGN)
+ {
+ signal(signals[i].sig, handler[i]);
+ hold &= ~sigmask(signals[i].sig);
+ }
+#endif
+#endif
+ }
+ return level;
+ }
+ else if (op < 0)
+ {
+#if _lib_sigprocmask
+ sigpending(&nmask);
+ for (i = 0; i < elementsof(signals); i++)
+ if (region & signals[i].op)
+ {
+ if (sigismember(&nmask, signals[i].sig))
+ return 1;
+ }
+ return 0;
+#else
+#if _lib_sigsetmask
+ /* no way to get pending signals without installing handler */
+ return 0;
+#else
+ return hold != 0;
+#endif
+#endif
+ }
+ else
+ {
+ /*
+ * a vfork() may have intervened so we
+ * allow apparent nesting mismatches
+ */
+
+ if (--level <= 0)
+ {
+ level = 0;
+#if _lib_sigprocmask
+ sigprocmask(SIG_SETMASK, &mask, NiL);
+#else
+#if _lib_sigsetmask
+ sigsetmask(mask);
+#else
+ for (i = 0; i < elementsof(signals); i++)
+ if (region & signals[i].op)
+ signal(signals[i].sig, handler[i]);
+ if (hold)
+ {
+ for (i = 0; i < elementsof(signals); i++)
+ if (region & signals[i].op)
+ {
+ if (hold & sigmask(signals[i].sig))
+ kill(getpid(), signals[i].sig);
+ }
+ pause();
+ }
+#endif
+#endif
+ }
+ return level;
+ }
+}
diff --git a/usr/src/lib/libast/common/misc/sigdata.c b/usr/src/lib/libast/common/misc/sigdata.c
new file mode 100644
index 0000000000..a3e5cd6d72
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/sigdata.c
@@ -0,0 +1,40 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * signal name and text data
+ */
+
+#include <ast.h>
+#include <sig.h>
+
+#include "FEATURE/signal"
+
+Sig_info_t _sig_info_ = { (char**)sig_name, (char**)sig_text, SIG_MAX };
+
+__EXTERN__(Sig_info_t, _sig_info_);
+
+#ifdef NoF
+NoF(sigdata)
+#endif
diff --git a/usr/src/lib/libast/common/misc/signal.c b/usr/src/lib/libast/common/misc/signal.c
new file mode 100644
index 0000000000..1eddd1329e
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/signal.c
@@ -0,0 +1,126 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * signal that disables syscall restart on interrupt with clear signal mask
+ * fun==SIG_DFL also unblocks signal
+ */
+
+#if !_UWIN
+
+#undef signal
+#define signal ______signal
+
+#endif
+
+#include <ast.h>
+#include <sig.h>
+
+#if !_UWIN
+
+#undef signal
+
+#undef _def_map_ast
+#include <ast_map.h>
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+#endif
+
+#if defined(SV_ABORT)
+#undef SV_INTERRUPT
+#define SV_INTERRUPT SV_ABORT
+#endif
+
+#if !_std_signal && (_lib_sigaction && defined(SA_NOCLDSTOP) || _lib_sigvec && defined(SV_INTERRUPT))
+
+#if !defined(SA_NOCLDSTOP) || !defined(SA_INTERRUPT) && defined(SV_INTERRUPT)
+#undef SA_INTERRUPT
+#define SA_INTERRUPT SV_INTERRUPT
+#undef sigaction
+#define sigaction sigvec
+#undef sigemptyset
+#define sigemptyset(p) (*(p)=0)
+#undef sa_flags
+#define sa_flags sv_flags
+#undef sa_handler
+#define sa_handler sv_handler
+#undef sa_mask
+#define sa_mask sv_mask
+#endif
+
+extern Sig_handler_t
+signal(int sig, Sig_handler_t fun)
+{
+ struct sigaction na;
+ struct sigaction oa;
+#ifdef SIGNO_MASK
+ unsigned int flags;
+#endif
+
+#ifdef SIGNO_MASK
+ flags = sig & ~SIGNO_MASK;
+ sig &= SIGNO_MASK;
+#endif
+ if (fun == SIG_DFL)
+ sigunblock(sig);
+ memzero(&na, sizeof(na));
+ na.sa_handler = fun;
+#if defined(SA_INTERRUPT) || defined(SA_RESTART)
+ switch (sig)
+ {
+#if defined(SIGIO) || defined(SIGTSTP) || defined(SIGTTIN) || defined(SIGTTOU)
+#if defined(SIGIO)
+ case SIGIO:
+#endif
+#if defined(SIGTSTP)
+ case SIGTSTP:
+#endif
+#if defined(SIGTTIN)
+ case SIGTTIN:
+#endif
+#if defined(SIGTTOU)
+ case SIGTTOU:
+#endif
+#if defined(SA_RESTART)
+ na.sa_flags = SA_RESTART;
+#endif
+ break;
+#endif
+ default:
+#if defined(SA_INTERRUPT)
+ na.sa_flags = SA_INTERRUPT;
+#endif
+ break;
+ }
+#endif
+ return(sigaction(sig, &na, &oa) ? (Sig_handler_t)0 : oa.sa_handler);
+}
+
+#else
+
+NoN(signal)
+
+#endif
diff --git a/usr/src/lib/libast/common/misc/stack.c b/usr/src/lib/libast/common/misc/stack.c
new file mode 100644
index 0000000000..05621992b2
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/stack.c
@@ -0,0 +1,172 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * pointer stack routines
+ */
+
+static const char id_stack[] = "\n@(#)$Id: stack (AT&T Bell Laboratories) 1984-05-01 $\0\n";
+
+#include <ast.h>
+#include <stack.h>
+
+/*
+ * create a new stack
+ */
+
+STACK
+stackalloc(register int size, void* error)
+{
+ register STACK stack;
+ register struct stackblock *b;
+
+ if (size <= 0) size = 100;
+ if (!(stack = newof(0, struct stacktable, 1, 0))) return(0);
+ if (!(b = newof(0, struct stackblock, 1, 0)))
+ {
+ free(stack);
+ return(0);
+ }
+ if (!(b->stack = newof(0, void*, size, 0)))
+ {
+ free(b);
+ free(stack);
+ return(0);
+ }
+ stack->blocks = b;
+ stack->size = size;
+ stack->error = error;
+ stack->position.block = b;
+ stack->position.index = -1;
+ b->next = 0;
+ b->prev = 0;
+ return(stack);
+}
+
+/*
+ * remove a stack
+ */
+
+void
+stackfree(register STACK stack)
+{
+ register struct stackblock* b;
+ register struct stackblock* p;
+
+ b = stack->blocks;
+ while (p = b)
+ {
+ b = p->next;
+ free(p->stack);
+ free(p);
+ }
+ free(stack);
+}
+
+/*
+ * clear stack
+ */
+
+void
+stackclear(register STACK stack)
+{
+ stack->position.block = stack->blocks;
+ stack->position.index = -1;
+}
+
+/*
+ * get value on top of stack
+ */
+
+void*
+stackget(register STACK stack)
+{
+ if (stack->position.index < 0) return(stack->error);
+ else return(stack->position.block->stack[stack->position.index]);
+}
+
+/*
+ * push value on to stack
+ */
+
+int
+stackpush(register STACK stack, void* value)
+{
+ register struct stackblock *b;
+
+ if (++stack->position.index >= stack->size)
+ {
+ b = stack->position.block;
+ if (b->next) b = b->next;
+ else
+ {
+ if (!(b->next = newof(0, struct stackblock, 1, 0)))
+ return(-1);
+ b = b->next;
+ if (!(b->stack = newof(0, void*, stack->size, 0)))
+ return(-1);
+ b->prev = stack->position.block;
+ b->next = 0;
+ }
+ stack->position.block = b;
+ stack->position.index = 0;
+ }
+ stack->position.block->stack[stack->position.index] = value;
+ return(0);
+}
+
+/*
+ * pop value off stack
+ */
+
+int
+stackpop(register STACK stack)
+{
+ /*
+ * return:
+ *
+ * -1 if stack empty before pop
+ * 0 if stack empty after pop
+ * 1 if stack not empty before & after pop
+ */
+
+ if (stack->position.index < 0) return(-1);
+ else if (--stack->position.index < 0)
+ {
+ if (!stack->position.block->prev) return(0);
+ stack->position.block = stack->position.block->prev;
+ stack->position.index = stack->size - 1;
+ return(1);
+ }
+ else return(1);
+}
+
+/*
+ * set|get stack position
+ */
+
+void
+stacktell(register STACK stack, int set, STACKPOS* position)
+{
+ if (set) stack->position = *position;
+ else *position = stack->position;
+}
diff --git a/usr/src/lib/libast/common/misc/state.c b/usr/src/lib/libast/common/misc/state.c
new file mode 100644
index 0000000000..343fb3b89c
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/state.c
@@ -0,0 +1,40 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+static const char id[] = "\n@(#)$Id: ast (AT&T Research) 2005-05-01 $\0\n";
+
+#include <ast.h>
+
+#undef strcmp
+
+_Ast_info_t _ast_info =
+{
+ "libast",
+ { 0, 0 },
+ 0, 0, 0, 0, 0,
+ strcmp,
+ 0, 0,
+ 1
+};
+
+__EXTERN__(_Ast_info_t, _ast_info);
diff --git a/usr/src/lib/libast/common/misc/stk.c b/usr/src/lib/libast/common/misc/stk.c
new file mode 100644
index 0000000000..9688e4b6cd
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/stk.c
@@ -0,0 +1,508 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Routines to implement a stack-like storage library
+ *
+ * A stack consists of a link list of variable size frames
+ * The beginning of each frame is initialized with a frame structure
+ * that contains a pointer to the previous frame and a pointer to the
+ * end of the current frame.
+ *
+ * This is a rewrite of the stk library that uses sfio
+ *
+ * David Korn
+ * AT&T Research
+ * dgk@research.att.com
+ *
+ */
+
+#include <sfio_t.h>
+#include <ast.h>
+#include <align.h>
+#include <stk.h>
+
+/*
+ * A stack is a header and a linked list of frames
+ * The first frame has structure
+ * Sfio_t
+ * Sfdisc_t
+ * struct stk
+ * Frames have structure
+ * struct frame
+ * data
+ */
+
+#define STK_ALIGN ALIGN_BOUND
+#define STK_FSIZE (1024*sizeof(int))
+#define STK_HDRSIZE (sizeof(Sfio_t)+sizeof(Sfdisc_t))
+
+typedef char* (*_stk_overflow_)(int);
+
+static int stkexcept(Sfio_t*,int,void*,Sfdisc_t*);
+static Sfdisc_t stkdisc = { 0, 0, 0, stkexcept };
+
+Sfio_t _Stak_data = SFNEW((char*)0,0,-1,SF_STATIC|SF_WRITE|SF_STRING,&stkdisc,0);
+
+__EXTERN__(Sfio_t, _Stak_data);
+
+struct frame
+{
+ char *prev; /* address of previous frame */
+ char *end; /* address of end this frame */
+ char **aliases; /* address aliases */
+ int nalias; /* number of aliases */
+};
+
+struct stk
+{
+ _stk_overflow_ stkoverflow; /* called when malloc fails */
+ short stkref; /* reference count; */
+ short stkflags; /* stack attributes */
+ char *stkbase; /* beginning of current stack frame */
+ char *stkend; /* end of current stack frame */
+};
+
+static int init; /* 1 when initialized */
+static struct stk *stkcur; /* pointer to current stk */
+static char *stkgrow(Sfio_t*, unsigned);
+
+#define stream2stk(stream) ((stream)==stkstd? stkcur:\
+ ((struct stk*)(((char*)(stream))+STK_HDRSIZE)))
+#define stk2stream(sp) ((Sfio_t*)(((char*)(sp))-STK_HDRSIZE))
+#define stkleft(stream) ((stream)->_endb-(stream)->_data)
+
+
+#ifdef STKSTATS
+ static struct
+ {
+ int create;
+ int delete;
+ int install;
+ int alloc;
+ int copy;
+ int puts;
+ int seek;
+ int set;
+ int grow;
+ int addsize;
+ int delsize;
+ int movsize;
+ } _stkstats;
+# define increment(x) (_stkstats.x++)
+# define count(x,n) (_stkstats.x += (n))
+#else
+# define increment(x)
+# define count(x,n)
+#endif /* STKSTATS */
+
+static const char Omsg[] = "malloc failed while growing stack\n";
+
+/*
+ * default overflow exception
+ */
+static char *overflow(int n)
+{
+ NoP(n);
+ write(2,Omsg, sizeof(Omsg)-1);
+ exit(2);
+ /* NOTREACHED */
+ return(0);
+}
+
+/*
+ * initialize stkstd, sfio operations may have already occcured
+ */
+static void stkinit(int size)
+{
+ register Sfio_t *sp;
+ init = size;
+ sp = stkopen(0);
+ init = 1;
+ stkinstall(sp,overflow);
+}
+
+static int stkexcept(register Sfio_t *stream, int type, void* val, Sfdisc_t* dp)
+{
+ NoP(dp);
+ NoP(val);
+ switch(type)
+ {
+ case SF_CLOSING:
+ {
+ register struct stk *sp = stream2stk(stream);
+ register char *cp = sp->stkbase;
+ register struct frame *fp;
+ if(--sp->stkref<=0)
+ {
+ increment(delete);
+ if(stream==stkstd)
+ stkset(stream,(char*)0,0);
+ else
+ {
+ while(1)
+ {
+ fp = (struct frame*)cp;
+ if(fp->prev)
+ {
+ cp = fp->prev;
+ free(fp);
+ }
+ else
+ {
+ free(fp);
+ break;
+ }
+ }
+ }
+ }
+ stream->_data = stream->_next = 0;
+ }
+ return(0);
+ case SF_FINAL:
+ free(stream);
+ return(1);
+ case SF_DPOP:
+ return(-1);
+ case SF_WRITE:
+ case SF_SEEK:
+ {
+ long size = sfvalue(stream);
+ if(init)
+ {
+ Sfio_t *old = 0;
+ if(stream!=stkstd)
+ old = stkinstall(stream,NiL);
+ if(!stkgrow(stkstd,size-(stkstd->_endb-stkstd->_data)))
+ return(-1);
+ if(old)
+ stkinstall(old,NiL);
+ }
+ else
+ stkinit(size);
+ }
+ return(1);
+ case SF_NEW:
+ return(-1);
+ }
+ return(0);
+}
+
+/*
+ * create a stack
+ */
+Sfio_t *stkopen(int flags)
+{
+ register int bsize;
+ register Sfio_t *stream;
+ register struct stk *sp;
+ register struct frame *fp;
+ register Sfdisc_t *dp;
+ register char *cp;
+ if(!(stream=newof((char*)0,Sfio_t, 1, sizeof(*dp)+sizeof(*sp))))
+ return(0);
+ increment(create);
+ count(addsize,sizeof(*stream)+sizeof(*dp)+sizeof(*sp));
+ dp = (Sfdisc_t*)(stream+1);
+ dp->exceptf = stkexcept;
+ sp = (struct stk*)(dp+1);
+ sp->stkref = 1;
+ sp->stkflags = (flags&STK_SMALL);
+ if(flags&STK_NULL) sp->stkoverflow = 0;
+ else sp->stkoverflow = stkcur?stkcur->stkoverflow:overflow;
+ bsize = init+sizeof(struct frame);
+#ifndef USE_REALLOC
+ if(flags&STK_SMALL)
+ bsize = roundof(bsize,STK_FSIZE/16);
+ else
+#endif /* USE_REALLOC */
+ bsize = roundof(bsize,STK_FSIZE);
+ bsize -= sizeof(struct frame);
+ if(!(fp=newof((char*)0,struct frame, 1,bsize)))
+ {
+ free(stream);
+ return(0);
+ }
+ count(addsize,sizeof(*fp)+bsize);
+ cp = (char*)(fp+1);
+ sp->stkbase = (char*)fp;
+ fp->prev = 0;
+ fp->nalias = 0;
+ fp->aliases = 0;
+ fp->end = sp->stkend = cp+bsize;
+ if(!sfnew(stream,cp,bsize,-1,SF_STRING|SF_WRITE|SF_STATIC|SF_EOF))
+ return((Sfio_t*)0);
+ sfdisc(stream,dp);
+ return(stream);
+}
+
+/*
+ * return a pointer to the current stack
+ * if <stream> is not null, it becomes the new current stack
+ * <oflow> becomes the new overflow function
+ */
+Sfio_t *stkinstall(Sfio_t *stream, _stk_overflow_ oflow)
+{
+ Sfio_t *old;
+ register struct stk *sp;
+ if(!init)
+ {
+ stkinit(1);
+ if(oflow)
+ stkcur->stkoverflow = oflow;
+ return((Sfio_t*)0);
+ }
+ increment(install);
+ old = stkcur?stk2stream(stkcur):0;
+ if(stream)
+ {
+ sp = stream2stk(stream);
+ while(sfstack(stkstd, SF_POPSTACK));
+ if(stream!=stkstd)
+ sfstack(stkstd,stream);
+ stkcur = sp;
+#ifdef USE_REALLOC
+ /*** someday ***/
+#endif /* USE_REALLOC */
+ }
+ else
+ sp = stkcur;
+ if(oflow)
+ sp->stkoverflow = oflow;
+ return(old);
+}
+
+/*
+ * increase the reference count on the given <stack>
+ */
+int stklink(register Sfio_t* stream)
+{
+ register struct stk *sp = stream2stk(stream);
+ return(sp->stkref++);
+}
+
+/*
+ * terminate a stack and free up the space
+ * >0 returned if reference decremented but still > 0
+ * 0 returned on last close
+ * <0 returned on error
+ */
+int stkclose(Sfio_t* stream)
+{
+ register struct stk *sp = stream2stk(stream);
+ if(sp->stkref>1)
+ {
+ sp->stkref--;
+ return(1);
+ }
+ return(sfclose(stream));
+}
+
+/*
+ * reset the bottom of the current stack back to <loc>
+ * if <loc> is not in this stack, then the stack is reset to the beginning
+ * otherwise, the top of the stack is set to stkbot+<offset>
+ *
+ */
+char *stkset(register Sfio_t * stream, register char* loc, unsigned offset)
+{
+ register struct stk *sp = stream2stk(stream);
+ register char *cp;
+ register struct frame *fp;
+ register int frames = 0;
+ int n;
+ if(!init)
+ stkinit(offset+1);
+ increment(set);
+ while(1)
+ {
+ fp = (struct frame*)sp->stkbase;
+ cp = sp->stkbase + roundof(sizeof(struct frame), STK_ALIGN);
+ n = fp->nalias;
+ while(n-->0)
+ {
+ if(loc==fp->aliases[n])
+ {
+ loc = cp;
+ break;
+ }
+ }
+ /* see whether <loc> is in current stack frame */
+ if(loc>=cp && loc<=sp->stkend)
+ {
+ if(frames)
+ sfsetbuf(stream,cp,sp->stkend-cp);
+ stream->_data = (unsigned char*)(cp + roundof(loc-cp,STK_ALIGN));
+ stream->_next = (unsigned char*)loc+offset;
+ goto found;
+ }
+ if(fp->prev)
+ {
+ sp->stkbase = fp->prev;
+ sp->stkend = ((struct frame*)(fp->prev))->end;
+ free((void*)fp);
+ }
+ else
+ break;
+ frames++;
+ }
+ /* set stack back to the beginning */
+ cp = (char*)(fp+1);
+ if(frames)
+ sfsetbuf(stream,cp,sp->stkend-cp);
+ else
+ stream->_data = stream->_next = (unsigned char*)cp;
+found:
+ return((char*)stream->_data);
+}
+
+/*
+ * allocate <n> bytes on the current stack
+ */
+char *stkalloc(register Sfio_t *stream, register unsigned int n)
+{
+ register unsigned char *old;
+ if(!init)
+ stkinit(n);
+ increment(alloc);
+ n = roundof(n,STK_ALIGN);
+ if(stkleft(stream) <= (int)n && !stkgrow(stream,n))
+ return(0);
+ old = stream->_data;
+ stream->_data = stream->_next = old+n;
+ return((char*)old);
+}
+
+/*
+ * begin a new stack word of at least <n> bytes
+ */
+char *_stkseek(register Sfio_t *stream, register unsigned n)
+{
+ if(!init)
+ stkinit(n);
+ increment(seek);
+ if(stkleft(stream) <= (int)n && !stkgrow(stream,n))
+ return(0);
+ stream->_next = stream->_data+n;
+ return((char*)stream->_data);
+}
+
+/*
+ * advance the stack to the current top
+ * if extra is non-zero, first add a extra bytes and zero the first
+ */
+char *stkfreeze(register Sfio_t *stream, register unsigned extra)
+{
+ register unsigned char *old, *top;
+ if(!init)
+ stkinit(extra);
+ old = stream->_data;
+ top = stream->_next;
+ if(extra)
+ {
+ if(extra > (stream->_endb-stream->_next))
+ {
+ if (!(top = (unsigned char*)stkgrow(stream,extra)))
+ return(0);
+ old = stream->_data;
+ }
+ *top = 0;
+ top += extra;
+ }
+ stream->_next = stream->_data += roundof(top-old,STK_ALIGN);
+ return((char*)old);
+}
+
+/*
+ * copy string <str> onto the stack as a new stack word
+ */
+char *stkcopy(Sfio_t *stream, const char* str)
+{
+ register unsigned char *cp = (unsigned char*)str;
+ register int n;
+ while(*cp++);
+ n = roundof(cp-(unsigned char*)str,STK_ALIGN);
+ if(!init)
+ stkinit(n);
+ increment(copy);
+ if(stkleft(stream) <= n && !stkgrow(stream,n))
+ return(0);
+ strcpy((char*)(cp=stream->_data),str);
+ stream->_data = stream->_next = cp+n;
+ return((char*)cp);
+}
+
+/*
+ * add a new stack frame of size >= <n> to the current stack.
+ * if <n> > 0, copy the bytes from stkbot to stktop to the new stack
+ * if <n> is zero, then copy the remainder of the stack frame from stkbot
+ * to the end is copied into the new stack frame
+ */
+
+static char *stkgrow(register Sfio_t *stream, unsigned size)
+{
+ register int n = size;
+ register struct stk *sp = stream2stk(stream);
+ register struct frame *fp= (struct frame*)sp->stkbase;
+ register char *cp, *dp=0;
+ register unsigned m = stktell(stream);
+ int nn=0;
+ n += (m + sizeof(struct frame)+1);
+ if(sp->stkflags&STK_SMALL)
+#ifndef USE_REALLOC
+ n = roundof(n,STK_FSIZE/16);
+ else
+#endif /* !USE_REALLOC */
+ n = roundof(n,STK_FSIZE);
+ /* see whether current frame can be extended */
+ if(stkptr(stream,0)==sp->stkbase+sizeof(struct frame))
+ {
+ nn = fp->nalias+1;
+ dp=sp->stkbase;
+ sp->stkbase = ((struct frame*)dp)->prev;
+ }
+ cp = newof(dp, char, n, nn*sizeof(char*));
+ if(!cp && (!sp->stkoverflow || !(cp = (*sp->stkoverflow)(n))))
+ return(0);
+ increment(grow);
+ count(addsize,n - (dp?m:0));
+ if(dp && cp==dp)
+ nn--;
+ fp = (struct frame*)cp;
+ fp->prev = sp->stkbase;
+ sp->stkbase = cp;
+ sp->stkend = fp->end = cp+n;
+ cp = (char*)(fp+1);
+ cp = sp->stkbase + roundof((cp-sp->stkbase),STK_ALIGN);
+ if(fp->nalias=nn)
+ {
+ fp->aliases = (char**)fp->end;
+ fp->aliases[nn-1] = dp + roundof(sizeof(struct frame),STK_ALIGN);
+ }
+ if(m && !dp)
+ {
+ memcpy(cp,(char*)stream->_data,m);
+ count(movsize,m);
+ }
+ sfsetbuf(stream,cp,sp->stkend-cp);
+ return((char*)(stream->_next = stream->_data+m));
+}
diff --git a/usr/src/lib/libast/common/misc/systrace.c b/usr/src/lib/libast/common/misc/systrace.c
new file mode 100644
index 0000000000..87604ad422
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/systrace.c
@@ -0,0 +1,68 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * trace systems calls if possible
+ */
+
+#include <ast.h>
+#include <error.h>
+#include <proc.h>
+#include <debug.h>
+
+void
+systrace(const char* id)
+{
+ register int n;
+ register char* out;
+ char* s;
+ char buf[PATH_MAX];
+ char* av[7];
+ long ov[2];
+
+ static char* trace[] = { "trace", "truss", "strace", "traces" };
+
+ if (!(s = getenv("HOME")))
+ return;
+ if (!id && !(id = (const char*)error_info.id))
+ id = (const char*)trace[0];
+ out = buf;
+ out += sfsprintf(out, sizeof(buf), "%s/.%s/%s", s, trace[0], id);
+ if (access(buf, F_OK))
+ return;
+ av[1] = trace[0];
+ av[2] = "-o";
+ av[3] = buf;
+ av[4] = "-p";
+ av[5] = out + 1;
+ av[6] = 0;
+ ov[0] = PROC_FD_DUP(open("/dev/null", O_WRONLY), 2, PROC_FD_PARENT|PROC_FD_CHILD);
+ ov[1] = 0;
+ sfsprintf(out, &buf[sizeof(buf)] - out, ".%d", getpid());
+ for (n = 0; n < elementsof(trace); n++)
+ if (!procfree(procopen(trace[n], av + 1, NiL, ov, PROC_ARGMOD|PROC_GID|PROC_UID|(n == (elementsof(trace) - 1) ? PROC_CLEANUP : 0))))
+ {
+ sleep(1);
+ break;
+ }
+}
diff --git a/usr/src/lib/libast/common/misc/translate.c b/usr/src/lib/libast/common/misc/translate.c
new file mode 100644
index 0000000000..7db6f34850
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/translate.c
@@ -0,0 +1,418 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * AT&T Research and SCO
+ * ast i18n message translation
+ */
+
+#include "lclib.h"
+
+#include <cdt.h>
+#include <error.h>
+#include <mc.h>
+#include <nl_types.h>
+
+#ifndef DEBUG_trace
+#define DEBUG_trace 0
+#endif
+
+#define NOCAT ((nl_catd)-1)
+#define GAP 100
+
+typedef struct
+{
+ Dtlink_t link; /* dictionary link */
+ Dt_t* messages; /* message dictionary handle */
+ nl_catd cat; /* message catalog handle */
+ int debug; /* special debug locale */
+ const char* locale; /* message catalog locale */
+ char name[1]; /* catalog name */
+} Catalog_t;
+
+typedef struct
+{
+ Dtlink_t link; /* dictionary link */
+ Catalog_t* cat; /* current catalog pointer */
+ int set; /* set number */
+ int seq; /* sequence number */
+ char text[1]; /* message text */
+} Message_t;
+
+typedef struct
+{
+ Sfio_t* sp; /* temp string stream */
+ int off; /* string base offset */
+} Temp_t;
+
+typedef struct
+{
+ Dtdisc_t message_disc; /* message dict discipline */
+ Dtdisc_t catalog_disc; /* catalog dict discipline */
+ Dt_t* catalogs; /* catalog dictionary handle */
+ Sfio_t* tmp; /* temporary string stream */
+ const char* debug; /* debug locale name */
+ int error; /* no dictionaries! */
+ char null[1]; /* null string */
+} State_t;
+
+static State_t state =
+{
+ { offsetof(Message_t, text), 0, 0 },
+ { offsetof(Catalog_t, name), 0, 0 },
+};
+
+static int
+tempget(Sfio_t* sp)
+{
+ if (sfstrtell(sp) > sfstrsize(sp) / 2)
+ sfstrseek(sp, 0, SEEK_SET);
+ return sfstrtell(sp);
+}
+
+static char*
+tempuse(Sfio_t* sp, int off)
+{
+ sfputc(sp, 0);
+ return sfstrbase(sp) + off;
+}
+
+/*
+ * add msg to dict
+ */
+
+static int
+entry(Dt_t* dict, int set, int seq, const char* msg)
+{
+ Message_t* mp;
+
+ if (!(mp = newof(0, Message_t, 1, strlen(msg))))
+ return 0;
+ strcpy(mp->text, msg);
+ mp->set = set;
+ mp->seq = seq;
+ if (!dtinsert(dict, mp))
+ {
+ free(mp);
+ return 0;
+ }
+#if DEBUG_trace > 1
+sfprintf(sfstderr, "AHA#%d:%s set %d seq %d msg `%s'\n", __LINE__, __FILE__, set, seq, msg);
+#endif
+ return 1;
+}
+
+/*
+ * find catalog in locale and return catopen() descriptor
+ */
+
+static nl_catd
+find(const char* locale, const char* catalog)
+{
+ char path[PATH_MAX];
+#if DEBUG_trace
+ const char* ocatalog = catalog;
+#endif
+
+ if (mcfind(path, locale, catalog, LC_MESSAGES, 0))
+ catalog = (const char*)path;
+#if DEBUG_trace
+sfprintf(sfstderr, "AHA#%d:%s %s %s %s\n", __LINE__, __FILE__, locale, ocatalog, catalog);
+#endif
+ return catopen(catalog, NL_CAT_LOCALE);
+}
+
+/*
+ * initialize the catalog s by loading in the default locale messages
+ */
+
+static Catalog_t*
+init(register char* s)
+{
+ register Catalog_t* cp;
+ register char* u;
+ register int n;
+ register int m;
+ nl_catd d;
+
+ /*
+ * insert into the catalog dictionary
+ */
+
+ if (!(cp = newof(0, Catalog_t, 1, strlen(s))))
+ return 0;
+ strcpy(cp->name, s);
+ if (!dtinsert(state.catalogs, cp))
+ {
+ free(cp);
+ return 0;
+ }
+ cp->cat = NOCAT;
+
+ /*
+ * locate the default locale catalog
+ */
+
+ u = setlocale(LC_MESSAGES, NiL);
+ setlocale(LC_MESSAGES, "C");
+ if ((d = find("C", s)) != NOCAT)
+ {
+ /*
+ * load the default locale messages
+ * this assumes one mesage set for ast (AST_MESSAGE_SET)
+ * different packages can share the same message catalog
+ * name by using different message set numbers
+ * see <mc.h> mcindex()
+ *
+ * this method requires a scan of each catalog, and the
+ * catalogs do not advertize the max message number, so
+ * we assume there are no messages after a gap of GAP
+ * missing messages
+ */
+
+ if (cp->messages = dtopen(&state.message_disc, Dtset))
+ {
+ n = m = 0;
+ for (;;)
+ {
+ n++;
+ if ((s = catgets(d, AST_MESSAGE_SET, n, state.null)) != state.null && entry(cp->messages, AST_MESSAGE_SET, n, s))
+ m = n;
+ else if ((n - m) > GAP)
+ break;
+ }
+ if (!m)
+ {
+ dtclose(cp->messages);
+ cp->messages = 0;
+ }
+ }
+ catclose(d);
+ }
+ setlocale(LC_MESSAGES, u);
+ return cp;
+}
+
+/*
+ * return the C locale message pointer for msg in cat
+ * cat may be a : separated list of candidate names
+ */
+
+static Message_t*
+match(const char* cat, const char* msg)
+{
+ register char* s;
+ register char* t;
+ Catalog_t* cp;
+ Message_t* mp;
+ size_t n;
+
+ char buf[1024];
+
+ s = (char*)cat;
+ for (;;)
+ {
+ if (t = strchr(s, ':'))
+ {
+ if (s == (char*)cat)
+ {
+ if ((n = strlen(s)) >= sizeof(buf))
+ n = sizeof(buf) - 1;
+ s = (char*)memcpy(buf, s, n);
+ s[n] = 0;
+ t = strchr(s, ':');
+ }
+ *t = 0;
+ }
+ if (*s && ((cp = (Catalog_t*)dtmatch(state.catalogs, s)) || (cp = init(s))) && cp->messages && (mp = (Message_t*)dtmatch(cp->messages, msg)))
+ {
+ mp->cat = cp;
+ return mp;
+ }
+ if (!t)
+ break;
+ s = t + 1;
+ }
+ return 0;
+}
+
+/*
+ * translate() is called with four arguments:
+ *
+ * loc the LC_MESSAGES locale name
+ * cmd the calling command name
+ * cat the catalog name, possibly a : separated list
+ * "libFOO" FOO library messages
+ * "libshell" ksh command messages
+ * "SCRIPT" script SCRIPT application messages
+ * msg message text to be translated
+ *
+ * the translated message text is returned on success
+ * otherwise the original msg is returned
+ *
+ * The first time translate() is called (for a non-C locale)
+ * it creates the state.catalogs dictionary. A dictionary entry
+ * (Catalog_t) is made each time translate() is called with a new
+ * cmd:cat argument.
+ *
+ * The X/Open interface catgets() is used to obtain a translated
+ * message. Its arguments include the message catalog name
+ * and the set/sequence numbers within the catalog. An additional
+ * dictionary, with entries of type Message_t, is needed for
+ * mapping untranslated message strings to the set/sequence numbers
+ * needed by catgets(). A separate Message_t dictionary is maintained
+ * for each Catalog_t.
+ */
+
+char*
+translate(const char* loc, const char* cmd, const char* cat, const char* msg)
+{
+ register char* r;
+ char* t;
+ int p;
+ int oerrno;
+ Catalog_t* cp;
+ Message_t* mp;
+
+ oerrno = errno;
+ r = (char*)msg;
+
+ /*
+ * quick out
+ */
+
+ if (!cmd && !cat)
+ goto done;
+ if (cmd && (t = strrchr(cmd, '/')))
+ cmd = (const char*)(t + 1);
+
+ /*
+ * initialize the catalogs dictionary
+ */
+
+ if (!state.catalogs)
+ {
+ if (state.error)
+ goto done;
+ if (!(state.tmp = sfstropen()))
+ {
+ state.error = 1;
+ goto done;
+ }
+ if (!(state.catalogs = dtopen(&state.catalog_disc, Dtset)))
+ {
+ sfclose(state.tmp);
+ state.error = 1;
+ goto done;
+ }
+ if (streq(loc, "debug"))
+ state.debug = loc;
+ }
+
+ /*
+ * get the message
+ * or do we have to spell it out for you
+ */
+
+ if ((!cmd || !(mp = match(cmd, msg))) &&
+ (!cat || !(mp = match(cat, msg))) &&
+ (!error_info.catalog || !(mp = match(error_info.catalog, msg))) &&
+ (!ast.id || !(mp = match(ast.id, msg))) ||
+ !(cp = mp->cat))
+ {
+#if DEBUG_trace > 1
+sfprintf(sfstderr, "AHA#%d:%s cmd %s cat %s:%s id %s msg `%s'\n", __LINE__, __FILE__, cmd, cat, error_info.catalog, ast.id, msg);
+#endif
+ goto done;
+ }
+
+ /*
+ * adjust for the current locale
+ */
+
+#if DEBUG_trace
+sfprintf(sfstderr, "AHA#%d:%s cp->locale `%s' %p loc `%s' %p\n", __LINE__, __FILE__, cp->locale, cp->locale, loc, loc);
+#endif
+ if (cp->locale != loc)
+ {
+ cp->locale = loc;
+ if (cp->cat != NOCAT)
+ catclose(cp->cat);
+ if ((cp->cat = find(cp->locale, cp->name)) == NOCAT)
+ cp->debug = streq(cp->locale, "debug");
+ else
+ cp->debug = 0;
+#if DEBUG_trace
+sfprintf(sfstderr, "AHA#%d:%s cp->cat %p cp->debug %d NOCAT %p\n", __LINE__, __FILE__, cp->cat, cp->debug, NOCAT);
+#endif
+ }
+ if (cp->cat == NOCAT)
+ {
+ if (cp->debug)
+ {
+ p = tempget(state.tmp);
+ sfprintf(state.tmp, "(%s,%d,%d)", cp->name, mp->set, mp->seq);
+ r = tempuse(state.tmp, p);
+ }
+ else if (ast.locale.set & AST_LC_debug)
+ {
+ p = tempget(state.tmp);
+ sfprintf(state.tmp, "(%s,%d,%d)%s", cp->name, mp->set, mp->seq, r);
+ r = tempuse(state.tmp, p);
+ }
+ goto done;
+ }
+
+ /*
+ * get the translated message
+ */
+
+ r = catgets(cp->cat, mp->set, mp->seq, msg);
+ if (ast.locale.set & AST_LC_translate)
+ sfprintf(sfstderr, "translate locale=%s catalog=%s set=%d seq=%d \"%s\" => \"%s\"\n", cp->locale, cp->name, mp->set, mp->seq, msg, r == (char*)msg ? "NOPE" : r);
+ if (r != (char*)msg)
+ {
+ if (streq(r, (char*)msg))
+ r = (char*)msg;
+ else if (strcmp(fmtfmt(r), fmtfmt(msg)))
+ {
+ sfprintf(sfstderr, "locale %s catalog %s message %d.%d \"%s\" does not match \"%s\"\n", cp->locale, cp->name, mp->set, mp->seq, r, msg);
+ r = (char*)msg;
+ }
+ }
+ if (ast.locale.set & AST_LC_debug)
+ {
+ p = tempget(state.tmp);
+ sfprintf(state.tmp, "(%s,%d,%d)%s", cp->name, mp->set, mp->seq, r);
+ r = tempuse(state.tmp, p);
+ }
+ done:
+ if (r == (char*)msg && loc == state.debug)
+ {
+ p = tempget(state.tmp);
+ sfprintf(state.tmp, "(%s,%s,%s,\"%s\")", loc, cmd, cat, r);
+ r = tempuse(state.tmp, p);
+ }
+ errno = oerrno;
+ return r;
+}
diff --git a/usr/src/lib/libast/common/misc/univdata.c b/usr/src/lib/libast/common/misc/univdata.c
new file mode 100644
index 0000000000..2399b6ade9
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/univdata.c
@@ -0,0 +1,58 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * universe common data
+ */
+
+#include "univlib.h"
+
+#ifndef UNIV_MAX
+
+char univ_env[] = "__UNIVERSE__";
+
+#else
+
+#ifndef NUMUNIV
+
+#if !_lib_universe
+#undef U_GET
+#endif
+
+#ifdef U_GET
+char* univ_name[] = { "ucb", "att" };
+#else
+char* univ_name[] = { "att", "ucb" };
+#endif
+
+int univ_max = sizeof(univ_name) / sizeof(univ_name[0]);
+
+#endif
+
+char univ_cond[] = "$(UNIVERSE)";
+
+int univ_size = sizeof(univ_cond) - 1;
+
+#endif
diff --git a/usr/src/lib/libast/common/misc/univlib.h b/usr/src/lib/libast/common/misc/univlib.h
new file mode 100644
index 0000000000..c161eebc60
--- /dev/null
+++ b/usr/src/lib/libast/common/misc/univlib.h
@@ -0,0 +1,93 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * universe support
+ *
+ * symbolic link external representation has trailing '\0' and $(...) style
+ * conditionals where $(...) corresponds to a kernel object (i.e., probably
+ * not environ)
+ *
+ * universe symlink conditionals use $(UNIVERSE)
+ */
+
+#ifndef _UNIVLIB_H
+#define _UNIVLIB_H
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide getuniverse readlink setuniverse symlink universe
+#else
+#define getuniverse ______getuniverse
+#define readlink ______readlink
+#define setuniverse ______setuniverse
+#define symlink ______symlink
+#define universe ______universe
+#endif
+
+#include <ast.h>
+#include <ls.h>
+#include <errno.h>
+
+#define UNIV_SIZE 9
+
+#if _cmd_universe && _sys_universe
+#include <sys/universe.h>
+#endif
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide getuniverse readlink setuniverse symlink universe
+#else
+#undef getuniverse
+#undef readlink
+#undef setuniverse
+#undef symlink
+#undef universe
+#endif
+
+#if _cmd_universe
+#ifdef NUMUNIV
+#define UNIV_MAX NUMUNIV
+#else
+#define UNIV_MAX univ_max
+extern char* univ_name[];
+extern int univ_max;
+#endif
+
+extern char univ_cond[];
+extern int univ_size;
+
+#else
+
+extern char univ_env[];
+
+#endif
+
+extern int getuniverse(char*);
+extern int readlink(const char*, char*, int);
+extern int setuniverse(int);
+extern int symlink(const char*, const char*);
+extern int universe(int);
+
+#endif
diff --git a/usr/src/lib/libast/common/obsolete/spawn.c b/usr/src/lib/libast/common/obsolete/spawn.c
new file mode 100644
index 0000000000..8784224b42
--- /dev/null
+++ b/usr/src/lib/libast/common/obsolete/spawn.c
@@ -0,0 +1,152 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * OBSOLETE 20030321 -- use spawnveg()
+ */
+
+#include <ast_lib.h>
+
+#if !_lib_spawnve
+#define spawnve ______spawnve
+#endif
+#if !_lib_spawnvpe
+#define spawnvpe ______spawnvpe
+#endif
+#if !_lib_spawnvp
+#define spawnvp ______spawnvp
+#endif
+#if !_lib_spawnlp
+#define spawnlp ______spawnlp
+#endif
+
+#include <ast.h>
+#include <error.h>
+
+#if !_lib_spawnve
+#undef spawnve
+#endif
+#if !_lib_spawnvpe
+#undef spawnvpe
+#endif
+#if !_lib_spawnvp
+#undef spawnvp
+#endif
+#if !_lib_spawnlp
+#undef spawnlp
+#endif
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+#if _lib_spawnve
+
+NoN(spawnve)
+
+#else
+
+extern pid_t
+spawnve(const char* cmd, char* const argv[], char* const envv[])
+{
+ return spawnveg(cmd, argv, envv, 0);
+}
+
+#endif
+
+#if _lib_spawnvpe
+
+NoN(spawnvpe)
+
+#else
+
+extern pid_t
+spawnvpe(const char* name, char* const argv[], char* const envv[])
+{
+ register const char* path = name;
+ pid_t pid;
+ char buffer[PATH_MAX];
+
+ if (*path != '/')
+ path = pathpath(buffer, name, NULL, PATH_REGULAR|PATH_EXECUTE);
+ if ((pid = spawnve(path, argv, envv)) >= 0)
+ return pid;
+ if (errno == ENOEXEC)
+ {
+ register char** newargv;
+ register char** ov;
+ register char** nv;
+
+ for (ov = (char**)argv; *ov++;);
+ if (newargv = newof(0, char*, ov + 1 - (char**)argv, 0))
+ {
+ nv = newargv;
+ *nv++ = "sh";
+ *nv++ = (char*)path;
+ ov = (char**)argv;
+ while (*nv++ = *++ov);
+ path = pathshell();
+ pid = spawnve(path, newargv, environ);
+ free(newargv);
+ }
+ else
+ errno = ENOMEM;
+ }
+ return pid;
+}
+
+#endif
+
+#if _lib_spawnvp
+
+NoN(spawnvp)
+
+#else
+
+extern pid_t
+spawnvp(const char* name, char* const argv[])
+{
+ return spawnvpe(name, argv, environ);
+}
+
+#endif
+
+#if _lib_spawnlp
+
+NoN(spawnlp)
+
+#else
+
+extern pid_t
+spawnlp(const char* name, const char* arg, ...)
+{
+ va_list ap;
+ pid_t pid;
+
+ va_start(ap, arg);
+ pid = spawnvp(name, (char* const*)&arg);
+ va_end(ap);
+ return pid;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/path/pathaccess.c b/usr/src/lib/libast/common/path/pathaccess.c
new file mode 100644
index 0000000000..8d84e2aa2c
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathaccess.c
@@ -0,0 +1,57 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * return path to file a/b with access mode using : separated dirs
+ * both a and b may be 0
+ * if a==".." then relative paths in dirs are ignored
+ * if (mode&PATH_REGULAR) then path must not be a directory
+ * if (mode&PATH_ABSOLUTE) then path must be rooted
+ * path returned in path buffer
+ */
+
+#include <ast.h>
+
+char*
+pathaccess(register char* path, register const char* dirs, const char* a, const char* b, register int mode)
+{
+ int sib = a && a[0] == '.' && a[1] == '.' && a[2] == 0;
+ int sep = ':';
+ char cwd[PATH_MAX];
+
+ do
+ {
+ dirs = pathcat(path, dirs, sep, a, b);
+ pathcanon(path, 0);
+ if ((!sib || *path == '/') && pathexists(path, mode))
+ {
+ if (*path == '/' || !(mode & PATH_ABSOLUTE))
+ return path;
+ dirs = getcwd(cwd, sizeof(cwd));
+ sep = 0;
+ }
+ } while (dirs);
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/path/pathbin.c b/usr/src/lib/libast/common/path/pathbin.c
new file mode 100644
index 0000000000..227f1a5ffa
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathbin.c
@@ -0,0 +1,46 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * return current PATH
+ */
+
+#include <ast.h>
+
+char*
+pathbin(void)
+{
+ register char* bin;
+
+ static char* val;
+
+ if ((!(bin = getenv("PATH")) || !*bin) && !(bin = val))
+ {
+ if (!*(bin = astconf("PATH", NiL, NiL)) || !(bin = strdup(bin)))
+ bin = "/bin:/usr/bin:/usr/local/bin";
+ val = bin;
+ }
+ return bin;
+}
diff --git a/usr/src/lib/libast/common/path/pathcanon.c b/usr/src/lib/libast/common/path/pathcanon.c
new file mode 100644
index 0000000000..5f31c460b7
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathcanon.c
@@ -0,0 +1,202 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * in-place path name canonicalization -- preserves the logical view
+ * pointer to trailing 0 in path returned
+ *
+ * remove redundant .'s and /'s
+ * move ..'s to the front
+ * /.. preserved (for pdu and newcastle hacks)
+ * FS_3D handles ...
+ * if (flags&PATH_PHYSICAL) then symlinks resolved at each component
+ * if (flags&PATH_DOTDOT) then each .. checked for access
+ * if (flags&PATH_EXISTS) then path must exist at each component
+ * if (flags&PATH_VERIFIED(n)) then first n chars of path exist
+ *
+ * longer pathname possible if (flags&PATH_PHYSICAL) or FS_3D ... involved
+ * 0 returned on error and if (flags&(PATH_DOTDOT|PATH_EXISTS)) then path
+ * will contain the components following the failure point
+ */
+
+#include <ast.h>
+#include <ls.h>
+#include <fs3d.h>
+#include <error.h>
+
+char*
+pathcanon(char* path, int flags)
+{
+ register char* p;
+ register char* r;
+ register char* s;
+ register char* t;
+ register int dots;
+ char* phys;
+ char* v;
+ int loop;
+ int oerrno;
+#if defined(FS_3D)
+ long visits = 0;
+#endif
+
+ oerrno = errno;
+ dots = loop = 0;
+ phys = path;
+ v = path + ((flags >> 5) & 01777);
+ if (*path == '/' && *(path + 1) == '/' && *astconf("PATH_LEADING_SLASHES", NiL, NiL) == '1')
+ do path++; while (*path == '/' && *(path + 1) == '/');
+ p = r = s = t = path;
+ for (;;) switch (*t++ = *s++)
+ {
+ case '.':
+ dots++;
+ break;
+ case 0:
+ s--;
+ /*FALLTHROUGH*/
+ case '/':
+ while (*s == '/') s++;
+ switch (dots)
+ {
+ case 1:
+ t -= 2;
+ break;
+ case 2:
+ if ((flags & (PATH_DOTDOT|PATH_EXISTS)) == PATH_DOTDOT && (t - 2) >= v)
+ {
+ struct stat st;
+
+ *(t - 2) = 0;
+ if (stat(phys, &st))
+ {
+ strcpy(path, s);
+ return 0;
+ }
+ *(t - 2) = '.';
+ }
+#if PRESERVE_TRAILING_SLASH
+ if (t - 5 < r) r = t;
+#else
+ if (t - 5 < r)
+ {
+ if (t - 4 == r) t = r + 1;
+ else r = t;
+ }
+#endif
+ else for (t -= 5; t > r && *(t - 1) != '/'; t--);
+ break;
+ case 3:
+#if defined(FS_3D)
+ {
+ char* x;
+ char* o;
+ int c;
+
+ o = t;
+ if ((t -= 5) <= path) t = path + 1;
+ c = *t;
+ *t = 0;
+ if (x = pathnext(phys, s - (*s != 0), &visits))
+ {
+ r = path;
+ if (t == r + 1) x = r;
+ v = s = t = x;
+ }
+ else
+ {
+ *t = c;
+ t = o;
+ }
+ }
+#else
+ r = t;
+#endif
+ break;
+ default:
+ if ((flags & PATH_PHYSICAL) && loop < 32 && (t - 1) > path)
+ {
+ int c;
+ char buf[PATH_MAX];
+
+ c = *(t - 1);
+ *(t - 1) = 0;
+ dots = pathgetlink(phys, buf, sizeof(buf));
+ *(t - 1) = c;
+ if (dots > 0)
+ {
+ loop++;
+ strcpy(buf + dots, s - (*s != 0));
+ if (*buf == '/') p = r = path;
+ v = s = t = p;
+ strcpy(p, buf);
+ }
+ else if (dots < 0 && errno == ENOENT)
+ {
+ if (flags & PATH_EXISTS)
+ {
+ strcpy(path, s);
+ return 0;
+ }
+ flags &= ~(PATH_PHYSICAL|PATH_DOTDOT);
+ }
+ dots = 4;
+ }
+ break;
+ }
+ if (dots >= 4 && (flags & PATH_EXISTS) && (t - 1) >= v && (t > path + 1 || t > path && *(t - 1) && *(t - 1) != '/'))
+ {
+ struct stat st;
+
+ *(t - 1) = 0;
+ if (stat(phys, &st))
+ {
+ strcpy(path, s);
+ return 0;
+ }
+ v = t;
+ if (*s) *(t - 1) = '/';
+ }
+ if (!*s)
+ {
+ if (t > path && !*(t - 1)) t--;
+ if (t == path) *t++ = '.';
+#if DONT_PRESERVE_TRAILING_SLASH
+ else if (t > path + 1 && *(t - 1) == '/') t--;
+#else
+ else if ((s <= path || *(s - 1) != '/') && t > path + 1 && *(t - 1) == '/') t--;
+#endif
+ *t = 0;
+ errno = oerrno;
+ return t;
+ }
+ dots = 0;
+ p = t;
+ break;
+ default:
+ dots = 4;
+ break;
+ }
+}
diff --git a/usr/src/lib/libast/common/path/pathcat.c b/usr/src/lib/libast/common/path/pathcat.c
new file mode 100644
index 0000000000..b8bff4e286
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathcat.c
@@ -0,0 +1,54 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * single dir support for pathaccess()
+ */
+
+#include <ast.h>
+
+char*
+pathcat(char* path, register const char* dirs, int sep, const char* a, register const char* b)
+{
+ register char* s;
+
+ s = path;
+ while (*dirs && *dirs != sep)
+ *s++ = *dirs++;
+ if (s != path)
+ *s++ = '/';
+ if (a)
+ {
+ while (*s = *a++)
+ s++;
+ if (b)
+ *s++ = '/';
+ }
+ else if (!b)
+ b = ".";
+ if (b)
+ while (*s++ = *b++);
+ return *dirs ? (char*)++dirs : 0;
+}
diff --git a/usr/src/lib/libast/common/path/pathcd.c b/usr/src/lib/libast/common/path/pathcd.c
new file mode 100644
index 0000000000..6c48f0c9d7
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathcd.c
@@ -0,0 +1,142 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * K. P. Vo
+ * G. S. Fowler
+ * AT&T Research
+ */
+
+#include <ast.h>
+#include <error.h>
+#include <stk.h>
+
+#if DEBUG
+
+#undef PATH_MAX
+
+#define PATH_MAX 16
+
+static int
+vchdir(const char* path)
+{
+ int n;
+
+ if (strlen(path) >= PATH_MAX)
+ {
+ errno = ENAMETOOLONG;
+ n = -1;
+ }
+ else n = chdir(path);
+ return n;
+}
+
+#define chdir(p) vchdir(p)
+
+#endif
+
+/*
+ * set the current directory to path
+ * if path is long and home!=0 then pathcd(home,0)
+ * is called on intermediate chdir errors
+ */
+
+int
+pathcd(const char* path, const char* home)
+{
+ register char* p = (char*)path;
+ register char* s;
+ register int n;
+ int i;
+ int r;
+
+ r = 0;
+ for (;;)
+ {
+ /*
+ * this should work 99% of the time
+ */
+
+ if (!chdir(p))
+ return r;
+
+ /*
+ * chdir failed
+ */
+
+ if ((n = strlen(p)) < PATH_MAX)
+ return -1;
+#ifdef ENAMETOOLONG
+ if (errno != ENAMETOOLONG)
+ return -1;
+#endif
+
+ /*
+ * path is too long -- copy so it can be modified in place
+ */
+
+ i = stktell(stkstd);
+ sfputr(stkstd, p, 0);
+ stkseek(stkstd, i);
+ p = stkptr(stkstd, i);
+ for (;;)
+ {
+ /*
+ * get a short prefix component
+ */
+
+ s = p + PATH_MAX;
+ while (--s >= p && *s != '/');
+ if (s <= p)
+ break;
+
+ /*
+ * chdir to the prefix
+ */
+
+ *s++ = 0;
+ if (chdir(p))
+ break;
+
+ /*
+ * do the remainder
+ */
+
+ if ((n -= s - p) < PATH_MAX)
+ {
+ if (chdir(s))
+ break;
+ return r;
+ }
+ p = s;
+ }
+
+ /*
+ * try to recover back to home
+ */
+
+ if (!(p = (char*)home))
+ return -1;
+ home = 0;
+ r = -1;
+ }
+}
diff --git a/usr/src/lib/libast/common/path/pathcheck.c b/usr/src/lib/libast/common/path/pathcheck.c
new file mode 100644
index 0000000000..071640098a
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathcheck.c
@@ -0,0 +1,91 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * check if package+tool is ok to run
+ * a no-op here except for PARANOID packages
+ * this allows PARANOID_COMPANY to post PARANOID binaries to the www
+ *
+ * warn that the user should pay up if
+ *
+ * (1) the tool matches PARANOID
+ * (2) $_ is more than 90 days old
+ * (3) running on an PARANOID_PAY machine
+ * (4) (1)-(3) have not been defeated
+ *
+ * hows that
+ */
+
+#define PARANOID_TOOLS PARANOID
+#define PARANOID_COMPANY "Lucent Technologies"
+#define PARANOID_MAIL "stc@lucent.com"
+#define PARANOID_PAY "135.*&!(135.104.*)"
+#define PARANOID_FREE "(192|224).*"
+
+#include <ast.h>
+#include <ls.h>
+#include <error.h>
+#include <times.h>
+#include <ctype.h>
+
+int
+pathcheck(const char* package, const char* tool, Pathcheck_t* pc)
+{
+#ifdef PARANOID
+ register char* s;
+ struct stat st;
+
+ if (strmatch(tool, PARANOID) && environ && (s = *environ) && *s++ == '_' && *s++ == '=' && !stat(s, &st))
+ {
+ unsigned long n;
+ unsigned long o;
+ Sfio_t* sp;
+
+ n = time(NiL);
+ o = st.st_ctime;
+ if (n > o && (n - o) > (unsigned long)(60 * 60 * 24 * 90) && (sp = sfopen(NiL, "/etc/hosts", "r")))
+ {
+ /*
+ * this part is infallible
+ */
+
+ n = 0;
+ o = 0;
+ while (n++ < 64 && (s = sfgetr(sp, '\n', 0)))
+ if (strmatch(s, PARANOID_PAY))
+ {
+ error(1, "licensed for external use -- %s employees should contact %s for the internal license", PARANOID_COMPANY, PARANOID_MAIL);
+ break;
+ }
+ else if (*s != '#' && !isspace(*s) && !strneq(s, "127.", 4) && !strmatch(s, PARANOID_FREE) && o++ > 4)
+ break;
+ sfclose(sp);
+ }
+ }
+#else
+ NoP(tool);
+#endif
+ NoP(package);
+ if (pc) memzero(pc, sizeof(*pc));
+ return(0);
+}
diff --git a/usr/src/lib/libast/common/path/pathexists.c b/usr/src/lib/libast/common/path/pathexists.c
new file mode 100644
index 0000000000..fb13240996
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathexists.c
@@ -0,0 +1,134 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * return 1 if path exisis
+ * maintains a cache to minimize stat(2) calls
+ * path is modified in-place but restored on return
+ * path components checked in pairs to cut stat()'s
+ * in half by checking ENOTDIR vs. ENOENT
+ * case ignorance infection unavoidable here
+ */
+
+#include "lclib.h"
+
+#include <ls.h>
+#include <error.h>
+
+typedef struct Tree_s
+{
+ struct Tree_s* next;
+ struct Tree_s* tree;
+ int mode;
+ char name[1];
+} Tree_t;
+
+int
+pathexists(char* path, int mode)
+{
+ register char* s;
+ register char* e;
+ register Tree_t* p;
+ register Tree_t* t;
+ register int c;
+ char* ee;
+ int cc;
+ int x;
+ struct stat st;
+ int (*cmp)(const char*, const char*);
+
+ static Tree_t tree;
+
+ t = &tree;
+ e = (c = *path) == '/' ? path + 1 : path;
+ cmp = strchr(astconf("PATH_ATTRIBUTES", path, NiL), 'c') ? strcasecmp : strcmp;
+ if ((ast.locale.set & (AST_LC_debug|AST_LC_find)) == (AST_LC_debug|AST_LC_find))
+ sfprintf(sfstderr, "locale test %s\n", path);
+ while (c)
+ {
+ p = t;
+ for (s = e; *e && *e != '/'; e++);
+ c = *e;
+ *e = 0;
+ for (t = p->tree; t && (*cmp)(s, t->name); t = t->next);
+ if (!t)
+ {
+ if (!(t = newof(0, Tree_t, 1, strlen(s))))
+ {
+ *e = c;
+ return 0;
+ }
+ strcpy(t->name, s);
+ t->next = p->tree;
+ p->tree = t;
+ if (c)
+ {
+ *e = c;
+ for (s = ee = e + 1; *ee && *ee != '/'; ee++);
+ cc = *ee;
+ *ee = 0;
+ }
+ else
+ ee = 0;
+ if ((ast.locale.set & (AST_LC_debug|AST_LC_find)) == (AST_LC_debug|AST_LC_find))
+ sfprintf(sfstderr, "locale stat %s\n", path);
+ x = stat(path, &st);
+ if (ee)
+ {
+ e = ee;
+ c = cc;
+ if (!x || errno == ENOENT)
+ t->mode = PATH_READ|PATH_EXECUTE;
+ if (!(p = newof(0, Tree_t, 1, strlen(s))))
+ {
+ *e = c;
+ return 0;
+ }
+ strcpy(p->name, s);
+ p->next = t->tree;
+ t->tree = p;
+ t = p;
+ }
+ if (x)
+ {
+ *e = c;
+ return 0;
+ }
+ if (st.st_mode & (S_IRUSR|S_IRGRP|S_IROTH))
+ t->mode |= PATH_READ;
+ if (st.st_mode & (S_IWUSR|S_IWGRP|S_IWOTH))
+ t->mode |= PATH_WRITE;
+ if (st.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH))
+ t->mode |= PATH_EXECUTE;
+ if (!S_ISDIR(st.st_mode))
+ t->mode |= PATH_REGULAR;
+ }
+ *e++ = c;
+ if (!t->mode || c && (t->mode & PATH_REGULAR))
+ return 0;
+ }
+ mode &= (PATH_READ|PATH_WRITE|PATH_EXECUTE|PATH_REGULAR);
+ return (t->mode & mode) == mode;
+}
diff --git a/usr/src/lib/libast/common/path/pathfind.c b/usr/src/lib/libast/common/path/pathfind.c
new file mode 100644
index 0000000000..e73e7bf4d5
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathfind.c
@@ -0,0 +1,168 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * include style search support
+ */
+
+#include <ast.h>
+#include <error.h>
+#include <ls.h>
+
+#define directory(p,s) (stat((p),(s))>=0&&S_ISDIR((s)->st_mode))
+#define regular(p,s) (stat((p),(s))>=0&&(S_ISREG((s)->st_mode)||streq(p,"/dev/null")))
+
+typedef struct Dir_s /* directory list element */
+{
+ struct Dir_s* next; /* next in list */
+ char dir[1]; /* directory path */
+} Dir_t;
+
+static struct /* directory list state */
+{
+ Dir_t* head; /* directory list head */
+ Dir_t* tail; /* directory list tail */
+} state;
+
+/*
+ * append dir to pathfind() include list
+ */
+
+int
+pathinclude(const char* dir)
+{
+ register Dir_t* dp;
+ struct stat st;
+
+ if (dir && *dir && !streq(dir, ".") && directory(dir, &st))
+ {
+ for (dp = state.head; dp; dp = dp->next)
+ if (streq(dir, dp->dir))
+ return 0;
+ if (!(dp = oldof(0, Dir_t, 1, strlen(dir))))
+ return -1;
+ strcpy(dp->dir, dir);
+ dp->next = 0;
+ if (state.tail)
+ state.tail = state.tail->next = dp;
+ else
+ state.head = state.tail = dp;
+ }
+ return 0;
+}
+
+/*
+ * return path to name using pathinclude() list
+ * path placed in <buf,size>
+ * if lib!=0 then pathpath() attempted after include search
+ * if type!=0 and name has no '.' then file.type also attempted
+ * any *: prefix in lib is ignored (discipline library dictionary support)
+ */
+
+char*
+pathfind(const char* name, const char* lib, const char* type, char* buf, size_t size)
+{
+ register Dir_t* dp;
+ register char* s;
+ char tmp[PATH_MAX];
+ struct stat st;
+
+ if (((s = strrchr(name, '/')) || (s = (char*)name)) && strchr(s, '.'))
+ type = 0;
+
+ /*
+ * always check the unadorned path first
+ * this handles . and absolute paths
+ */
+
+ if (regular(name, &st))
+ {
+ strncopy(buf, name, size);
+ return buf;
+ }
+ if (type)
+ {
+ sfsprintf(buf, size, "%s.%s", name, type);
+ if (regular(buf, &st))
+ return buf;
+ }
+ if (*name == '/')
+ return 0;
+
+ /*
+ * check the directory of the including file
+ * on the assumption that error_info.file is properly stacked
+ */
+
+ if (error_info.file && (s = strrchr(error_info.file, '/')))
+ {
+ sfsprintf(buf, size, "%-.*s%s", s - error_info.file + 1, error_info.file, name);
+ if (regular(buf, &st))
+ return buf;
+ if (type)
+ {
+ sfsprintf(buf, size, "%-.*s%s%.s", s - error_info.file + 1, error_info.file, name, type);
+ if (regular(buf, &st))
+ return buf;
+ }
+ }
+
+ /*
+ * check the include dir list
+ */
+
+ for (dp = state.head; dp; dp = dp->next)
+ {
+ sfsprintf(tmp, sizeof(tmp), "%s/%s", dp->dir, name);
+ if (pathpath(buf, tmp, "", PATH_REGULAR))
+ return buf;
+ if (type)
+ {
+ sfsprintf(tmp, sizeof(tmp), "%s/%s.%s", dp->dir, name, type);
+ if (pathpath(buf, tmp, "", PATH_REGULAR))
+ return buf;
+ }
+ }
+
+ /*
+ * finally a lib related search on PATH
+ */
+
+ if (lib)
+ {
+ if (s = strrchr((char*)lib, ':'))
+ lib = (const char*)s + 1;
+ sfsprintf(tmp, sizeof(tmp), "lib/%s/%s", lib, name);
+ if (pathpath(buf, tmp, "", PATH_REGULAR))
+ return buf;
+ if (type)
+ {
+ sfsprintf(tmp, sizeof(tmp), "lib/%s/%s.%s", lib, name, type);
+ if (pathpath(buf, tmp, "", PATH_REGULAR))
+ return buf;
+ }
+ }
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/path/pathgetlink.c b/usr/src/lib/libast/common/path/pathgetlink.c
new file mode 100644
index 0000000000..1bb9dcfee1
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathgetlink.c
@@ -0,0 +1,102 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+* Glenn Fowler
+* AT&T Bell Laboratories
+*/
+
+#include "univlib.h"
+
+#ifdef UNIV_MAX
+
+#include <ctype.h>
+
+#endif
+
+/*
+ * return external representation for symbolic link text of name in buf
+ * the link text string length is returned
+ */
+
+int
+pathgetlink(const char* name, char* buf, int siz)
+{
+ int n;
+
+ if ((n = readlink(name, buf, siz)) < 0) return(-1);
+ if (n >= siz)
+ {
+ errno = EINVAL;
+ return(-1);
+ }
+ buf[n] = 0;
+#ifdef UNIV_MAX
+ if (isspace(*buf))
+ {
+ register char* s;
+ register char* t;
+ register char* u;
+ register char* v;
+ int match = 0;
+ char tmp[PATH_MAX];
+
+ s = buf;
+ t = tmp;
+ while (isalnum(*++s) || *s == '_' || *s == '.');
+ if (*s++)
+ {
+ for (;;)
+ {
+ if (!*s || isspace(*s))
+ {
+ if (match)
+ {
+ *t = 0;
+ n = t - tmp;
+ strcpy(buf, tmp);
+ }
+ break;
+ }
+ if (t >= &tmp[sizeof(tmp)]) break;
+ *t++ = *s++;
+ if (!match && t < &tmp[sizeof(tmp) - univ_size + 1]) for (n = 0; n < UNIV_MAX; n++)
+ {
+ if (*(v = s - 1) == *(u = univ_name[n]))
+ {
+ while (*u && *v++ == *u) u++;
+ if (!*u)
+ {
+ match = 1;
+ strcpy(t - 1, univ_cond);
+ t += univ_size - 1;
+ s = v;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+#endif
+ return(n);
+}
diff --git a/usr/src/lib/libast/common/path/pathkey.c b/usr/src/lib/libast/common/path/pathkey.c
new file mode 100644
index 0000000000..ddbb9e7659
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathkey.c
@@ -0,0 +1,295 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * generate 14 char lookup key for lang path in key
+ * based on 32-bit checksum on path
+ *
+ * if key==0 then space is malloc'd
+ * if attr != 0 then attribute var assignments placed here:
+ * ATTRIBUTES list of attribute names
+ */
+
+#include <ast.h>
+#include <ctype.h>
+#include <fs3d.h>
+#include <preroot.h>
+
+char*
+pathkey(char* key, char* attr, const char* lang, const char* tool, const char* apath)
+{
+ register char* path = (char*)apath;
+ register char* s;
+ register char* k;
+ char* t;
+ char* flags;
+ char** p;
+ int c;
+ unsigned long n;
+ char buf[15];
+ char* usr[16];
+ char* env[elementsof(usr) + 3];
+ char* ver[2];
+ char tmp[PATH_MAX];
+
+ static char let[] = "ABCDEFGHIJKLMNOP";
+
+ if (!key)
+ key = buf;
+ if (tool && streq(tool, "mam"))
+ {
+ for (n = 0; *path; path++)
+ n = n * 0x63c63cd9L + *path + 0x9c39c33dL;
+ k = key;
+ for (n &= 0xffffffffL; n; n >>= 4)
+ *k++ = let[n & 0xf];
+ *k = 0;
+ }
+ else
+ {
+ for (c = 0; c < elementsof(env); c++)
+ env[c] = 0;
+ n = 0;
+
+ /*
+ * trailing flags in path
+ */
+
+ if (flags = strchr(path, ' '))
+ {
+ if (flags == path)
+ flags = 0;
+ else
+ {
+ strcpy(tmp, path);
+ *(flags = tmp + (flags - path)) = 0;
+ path = tmp;
+ }
+ }
+
+ /*
+ * 3D
+ */
+
+ if (fs3d(FS3D_TEST) && (c = mount(path, tmp, FS3D_GET|FS3D_ALL|FS3D_SIZE(PATH_MAX), NiL)) > 1 && c < PATH_MAX)
+ path = tmp;
+
+ /*
+ * preroot
+ */
+
+ if (attr)
+ attr = strcopy(attr, "PREROOT='");
+#if FS_PREROOT
+ if (k = getenv(PR_BASE))
+ {
+ if (s = strrchr(k, '/'))
+ k = s + 1;
+ n = memsum(k, strlen(k), n);
+ }
+ if (attr && (getpreroot(attr, path) || getpreroot(attr, NiL)))
+ attr += strlen(attr);
+#else
+ if ((k = getenv("VIRTUAL_ROOT")) && *k == '/')
+ {
+ n = memsum(k, strlen(k), n);
+ if (attr)
+ attr = strcopy(attr, k);
+ }
+#endif
+
+ /*
+ * universe
+ */
+
+ if (attr)
+ attr = strcopy(attr, "' UNIVERSE='");
+ if (k = astconf("UNIVERSE", NiL, NiL))
+ {
+ n = memsum(k, strlen(k), n);
+ if (attr)
+ attr = strcopy(attr, k);
+ }
+
+ /*
+ * environment
+ *
+ * ${PROBE_ATTRIBUTES} || ${VERSION_ENVIRONMENT} : list of alternate env vars
+ * ${VERSION_ENVIRONMENT} : list of alternate env vars
+ * ${VERSION_<lang>}
+ * ${VERSION_<base(path)>}
+ * ${<toupper(base(path))>VER}
+ * ${OBJTYPE}
+ */
+
+ if (attr)
+ *attr++ = '\'';
+ c = 0;
+ usr[c++] = "OBJTYPE";
+ if (!(k = getenv("PROBE_ATTRIBUTES")))
+ k = getenv("VERSION_ENVIRONMENT");
+ if (k)
+ while (c < elementsof(usr))
+ {
+ while (*k && (*k == ':' || *k == ' '))
+ k++;
+ if (!*k)
+ break;
+ usr[c++] = k;
+ while (*k && *k != ':' && *k != ' ')
+ k++;
+ }
+ usr[c] = 0;
+ ver[0] = (char*)lang;
+ ver[1] = k = (s = strrchr(path, '/')) ? s + 1 : path;
+ s = buf;
+ if (isdigit(*k))
+ {
+ if (*k == '3' && *(k + 1) == 'b')
+ {
+ /*
+ * cuteness never pays
+ */
+
+ k += 2;
+ *s++ = 'B';
+ *s++ = 'B';
+ *s++ = 'B';
+ }
+ else
+ *s++ = 'U';
+ }
+ for (; (c = *k) && s < &buf[sizeof(buf) - 1]; k++)
+ {
+ if (!isalnum(c))
+ c = '_';
+ else if (islower(c))
+ c = toupper(c);
+ *s++ = c;
+ }
+ *s = 0;
+ for (p = environ; *p; p++)
+ {
+ s = "VERSION_";
+ for (k = *p; *k && *k == *s; k++, s++);
+ if (*k && !*s)
+ {
+ for (c = 0; c < elementsof(ver); c++)
+ if (!env[c] && (s = ver[c]))
+ {
+ for (t = k; *t && *t != '=' && *t++ == *s; s++);
+ if (*t == '=' && (!*s || (s - ver[c]) > 1))
+ {
+ env[c] = *p;
+ goto found;
+ }
+ }
+ }
+ if (!env[2])
+ {
+ s = buf;
+ for (k = *p; *k && *s++ == *k; k++);
+ if ((s - buf) > 2 && k[0] == 'V' && k[1] == 'E' && k[2] == 'R' && k[3] == '=')
+ {
+ env[2] = *p;
+ goto found;
+ }
+ }
+ for (c = 0; c < elementsof(usr) && (s = usr[c]); c++)
+ if (!env[c + elementsof(env) - elementsof(usr)])
+ {
+ for (k = *p; *k && *k == *s; k++, s++);
+ if (*k == '=' && (!*s || *s == ':' || *s == ' '))
+ {
+ env[c + elementsof(env) - elementsof(usr)] = *p;
+ goto found;
+ }
+ }
+ found: ;
+ }
+ for (c = 0; c < elementsof(env); c++)
+ if (k = env[c])
+ {
+ if (attr)
+ {
+ *attr++ = ' ';
+ while ((*attr++ = *k++) != '=');
+ *attr++ = '\'';
+ attr = strcopy(attr, k);
+ *attr++ = '\'';
+ }
+ else
+ while (*k && *k++ != '=');
+ n = memsum(k, strlen(k), n);
+ }
+ if (attr)
+ {
+ attr = strcopy(attr, " ATTRIBUTES='PREROOT UNIVERSE");
+ for (c = 0; c < elementsof(env); c++)
+ if (k = env[c])
+ {
+ *attr++ = ' ';
+ while ((*attr = *k++) != '=')
+ attr++;
+ }
+ *attr++ = '\'';
+ *attr = 0;
+ }
+
+ /*
+ * now the normal stuff
+ */
+
+ if (flags)
+ *flags = ' ';
+ s = path + strlen(path);
+ sfsprintf(key, 15, "%08lX", memsum(path, s - path, n));
+ k = key + 14;
+ *k = 0;
+ if (!flags)
+ t = path;
+ else if ((t = s - 4) < flags)
+ t = flags + 1;
+ for (;;)
+ {
+ if (--s < t)
+ {
+ if (t == path)
+ break;
+ s = flags - 2;
+ t = path;
+ }
+ if (*s != '/' && *s != ' ')
+ {
+ *--k = *s;
+ if (k <= key + 8)
+ break;
+ }
+ }
+ while (k > key + 8)
+ *--k = '.';
+ }
+ return key == buf ? strdup(key) : key;
+}
diff --git a/usr/src/lib/libast/common/path/pathnative.c b/usr/src/lib/libast/common/path/pathnative.c
new file mode 100644
index 0000000000..2fbd6dd74c
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathnative.c
@@ -0,0 +1,126 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * convert path to native fs representation in <buf,siz>
+ * length of converted path returned
+ * if return length >= siz then buf is indeterminate, but another call
+ * with siz=length+1 would work
+ * if buf==0 then required size is returned
+ */
+
+#include <ast.h>
+
+#if _UWIN
+
+extern int uwin_path(const char*, char*, int);
+
+size_t
+pathnative(const char* path, char* buf, size_t siz)
+{
+ return uwin_path(path, buf, siz);
+}
+
+#else
+
+#if __CYGWIN__
+
+extern void cygwin_conv_to_win32_path(const char*, char*);
+
+size_t
+pathnative(const char* path, char* buf, size_t siz)
+{
+ size_t n;
+
+ if (!buf || siz < PATH_MAX)
+ {
+ char tmp[PATH_MAX];
+
+ cygwin_conv_to_win32_path(path, tmp);
+ if ((n = strlen(tmp)) < siz && buf)
+ memcpy(buf, tmp, n + 1);
+ return n;
+ }
+ cygwin_conv_to_win32_path(path, buf);
+ return strlen(buf);
+}
+
+#else
+
+#if __EMX__
+
+size_t
+pathnative(const char* path, char* buf, size_t siz)
+{
+ char* s;
+ size_t n;
+
+ if (!_fullpath(buf, path, siz))
+ {
+ for (s = buf; *s; s++)
+ if (*s == '/')
+ *s = '\\';
+ }
+ else if ((n = strlen(path)) < siz && buf)
+ memcpy(buf, path, n + 1);
+ return n;
+}
+
+#else
+
+#if __INTERIX
+
+#include <interix/interix.h>
+
+size_t
+pathnative(const char* path, char* buf, size_t siz)
+{
+ *buf = 0;
+ if (path[1] == ':')
+ strlcpy(buf, path, siz);
+ else
+ unixpath2win(path, 0, buf, siz);
+ return strlen(buf);
+}
+
+#else
+
+size_t
+pathnative(const char* path, char* buf, size_t siz)
+{
+ size_t n;
+
+ if ((n = strlen(path)) < siz && buf)
+ memcpy(buf, path, n + 1);
+ return n;
+}
+
+#endif
+
+#endif
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/path/pathpath.c b/usr/src/lib/libast/common/path/pathpath.c
new file mode 100644
index 0000000000..520fdb9e52
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathpath.c
@@ -0,0 +1,111 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * return full path to p with mode access using $PATH
+ * a!=0 enables related root search
+ * a!=0 && a!="" searches a dir first
+ * the related root must have a bin subdir
+ * p==0 sets the cached relative dir to a
+ * full path returned in path buffer
+ * if path==0 then the space is malloc'd
+ */
+
+#include <ast.h>
+
+char*
+pathpath(register char* path, const char* p, const char* a, int mode)
+{
+ register char* s;
+ char* x;
+ char buf[PATH_MAX];
+
+ static char* cmd;
+
+ if (!path)
+ path = buf;
+ if (!p)
+ {
+ if (cmd)
+ free(cmd);
+ cmd = a ? strdup(a) : (char*)0;
+ return 0;
+ }
+ if (strlen(p) < PATH_MAX)
+ {
+ strcpy(path, p);
+ if (pathexists(path, mode))
+ {
+ if (*p != '/' && (mode & PATH_ABSOLUTE))
+ {
+ getcwd(buf, sizeof(buf));
+ s = buf + strlen(buf);
+ sfsprintf(s, sizeof(buf) - (s - buf), "/%s", p);
+ if (path != buf)
+ strcpy(path, buf);
+ }
+ return (path == buf) ? strdup(path) : path;
+ }
+ }
+ if (*p == '/')
+ a = 0;
+ else if (s = (char*)a)
+ {
+ x = s;
+ if (strchr(p, '/'))
+ {
+ a = p;
+ p = "..";
+ }
+ else
+ a = 0;
+ if ((!cmd || *cmd) && (strchr(s, '/') || (s = cmd)))
+ {
+ if (!cmd && *s == '/')
+ cmd = strdup(s);
+ if (strlen(s) < (sizeof(buf) - 6))
+ {
+ s = strcopy(path, s);
+ for (;;)
+ {
+ do if (s <= path) goto normal; while (*--s == '/');
+ do if (s <= path) goto normal; while (*--s != '/');
+ strcpy(s + 1, "bin");
+ if (pathexists(path, PATH_EXECUTE))
+ {
+ if (s = pathaccess(path, path, p, a, mode))
+ return path == buf ? strdup(s) : s;
+ goto normal;
+ }
+ }
+ normal: ;
+ }
+ }
+ }
+ x = !a && strchr(p, '/') ? "" : pathbin();
+ if (!(s = pathaccess(path, x, p, a, mode)) && !*x && (x = getenv("FPATH")))
+ s = pathaccess(path, x, p, a, mode);
+ return (s && path == buf) ? strdup(s) : s;
+}
diff --git a/usr/src/lib/libast/common/path/pathposix.c b/usr/src/lib/libast/common/path/pathposix.c
new file mode 100644
index 0000000000..1fe816dcc8
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathposix.c
@@ -0,0 +1,128 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * convert native path to posix fs representation in <buf,siz>
+ * length of converted path returned
+ * if return length >= siz then buf is indeterminate, but another call
+ * with siz=length+1 would work
+ * if buf==0 then required size is returned
+ */
+
+#include <ast.h>
+
+#if _UWIN
+
+#include <uwin.h>
+
+size_t
+pathposix(const char* path, char* buf, size_t siz)
+{
+ return uwin_unpath(path, buf, siz);
+}
+
+#else
+
+#if __CYGWIN__
+
+extern void cygwin_conv_to_posix_path(const char*, char*);
+
+size_t
+pathposix(const char* path, char* buf, size_t siz)
+{
+ size_t n;
+
+ if (!buf || siz < PATH_MAX)
+ {
+ char tmp[PATH_MAX];
+
+ cygwin_conv_to_posix_path(path, tmp);
+ if ((n = strlen(tmp)) < siz && buf)
+ memcpy(buf, tmp, n + 1);
+ return n;
+ }
+ cygwin_conv_to_posix_path(path, buf);
+ return strlen(buf);
+}
+
+#else
+
+#if __EMX__ && 0 /* show me the docs */
+
+size_t
+pathposix(const char* path, char* buf, size_t siz)
+{
+ char* s;
+ size_t n;
+
+ if (!_posixpath(buf, path, siz))
+ {
+ for (s = buf; *s; s++)
+ if (*s == '/')
+ *s = '\\';
+ }
+ else if ((n = strlen(path)) < siz && buf)
+ memcpy(buf, path, n + 1);
+ return n;
+}
+
+#else
+
+#if __INTERIX
+
+#include <interix/interix.h>
+
+size_t
+pathposix(const char* path, char *buf, size_t siz)
+{
+ static const char pfx[] = "/dev/fs";
+
+ *buf = 0;
+ if (!strncasecmp(path, pfx, sizeof(pfx) - 1))
+ strlcpy(buf, path, siz);
+ else
+ winpath2unix(path, PATH_NONSTRICT, buf, siz);
+ return strlen(buf);
+}
+
+#else
+
+size_t
+pathposix(const char* path, char* buf, size_t siz)
+{
+ size_t n;
+
+ if ((n = strlen(path)) < siz && buf)
+ memcpy(buf, path, n + 1);
+ return n;
+}
+
+#endif
+
+#endif
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/path/pathprobe.c b/usr/src/lib/libast/common/path/pathprobe.c
new file mode 100644
index 0000000000..ea19903be9
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathprobe.c
@@ -0,0 +1,300 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * return in path the full path name of the probe(1)
+ * information for lang and tool using proc
+ * if attr != 0 then path attribute assignments placed here
+ *
+ * if path==0 then the space is malloc'd
+ *
+ * op:
+ *
+ * -3 return non-writable path name with no generation
+ * -2 return path name with no generation
+ * -1 return no $HOME path name with no generation
+ * 0 verbose probe
+ * 1 silent probe
+ *
+ * 0 returned if the info does not exist and cannot be generated
+ */
+
+#include <ast.h>
+#include <error.h>
+#include <ls.h>
+#include <proc.h>
+
+#ifndef PROBE
+#define PROBE "probe"
+#endif
+
+#if defined(ST_RDONLY) || defined(ST_NOSUID)
+
+/*
+ * return non-0 if path is in a readonly or non-setuid fs
+ */
+
+static int
+rofs(const char* path)
+{
+ struct statvfs vfs;
+
+ if (!statvfs(path, &vfs))
+ {
+#if defined(ST_RDONLY)
+ if (vfs.f_flag & ST_RDONLY)
+ return 1;
+#endif
+#if defined(ST_NOSUID)
+ if (vfs.f_flag & ST_NOSUID)
+ return 1;
+#endif
+ }
+ return 0;
+}
+
+#else
+
+#define rofs(p) 0
+
+#endif
+
+char*
+pathprobe(char* path, char* attr, const char* lang, const char* tool, const char* aproc, int op)
+{
+ char* proc = (char*)aproc;
+ register char* p;
+ register char* k;
+ register char* x;
+ register char** ap;
+ int n;
+ int v;
+ int force;
+ ssize_t r;
+ char* e;
+ char* np;
+ char* nx;
+ char* probe;
+ const char* dirs;
+ const char* dir;
+ Proc_t* pp;
+ Sfio_t* sp;
+ char buf[PATH_MAX];
+ char cmd[PATH_MAX];
+ char exe[PATH_MAX];
+ char lib[PATH_MAX];
+ char ver[PATH_MAX];
+ char key[16];
+ char* arg[8];
+ long ops[2];
+ unsigned long ptime;
+ struct stat st;
+ struct stat ps;
+
+ if (*proc != '/')
+ {
+ if (p = strchr(proc, ' '))
+ {
+ strncopy(buf, proc, p - proc + 1);
+ proc = buf;
+ }
+ if (!(proc = pathpath(cmd, proc, NiL, PATH_ABSOLUTE|PATH_REGULAR|PATH_EXECUTE)))
+ proc = (char*)aproc;
+ else if (p)
+ {
+ n = strlen(proc);
+ strncopy(proc + n, p, PATH_MAX - n - 1);
+ }
+ }
+ if (!path)
+ path = buf;
+ probe = PROBE;
+ x = lib + sizeof(lib) - 1;
+ k = lib + sfsprintf(lib, x - lib, "lib/%s/", probe);
+ p = k + sfsprintf(k, x - k, "%s/%s/", lang, tool);
+ pathkey(key, attr, lang, tool, proc);
+ if (op >= -2)
+ {
+ strncopy(p, key, x - p);
+ if (pathpath(path, lib, "", PATH_ABSOLUTE) && !stat(path, &st) && (st.st_mode & S_IWUSR))
+ return path == buf ? strdup(path) : path;
+ }
+ e = strncopy(p, probe, x - p);
+ if (!pathpath(path, lib, "", PATH_ABSOLUTE|PATH_EXECUTE) || stat(path, &ps))
+ return 0;
+ for (;;)
+ {
+ ptime = ps.st_mtime;
+ n = strlen(path);
+ if (n < (PATH_MAX - 5))
+ {
+ strcpy(path + n, ".ini");
+ if (!stat(path, &st) && st.st_size && ptime < (unsigned long)st.st_mtime)
+ ptime = st.st_mtime;
+ path[n] = 0;
+ }
+ np = path + n - (e - k);
+ nx = path + PATH_MAX - 1;
+ strncopy(np, probe, nx - np);
+ if (!stat(path, &st))
+ break;
+
+ /*
+ * yes lib/probe/<lang>/<proc>/probe
+ * no lib/probe/probe
+ *
+ * do a manual pathaccess() to find a dir with both
+ */
+
+ sfsprintf(exe, sizeof(exe), "lib/%s/%s", probe, probe);
+ dirs = pathbin();
+ for (;;)
+ {
+ if (!(dir = dirs))
+ return 0;
+ dirs = pathcat(path, dir, ':', "..", exe);
+ pathcanon(path, 0);
+ if (*path == '/' && pathexists(path, PATH_REGULAR|PATH_EXECUTE))
+ {
+ pathcat(path, dir, ':', "..", lib);
+ pathcanon(path, 0);
+ if (*path == '/' && pathexists(path, PATH_REGULAR|PATH_EXECUTE) && !stat(path, &ps))
+ break;
+ }
+ }
+ }
+ strncopy(p, key, x - p);
+ p = np;
+ x = nx;
+ strcpy(exe, path);
+ if (op >= -1 && (!(st.st_mode & S_ISUID) && ps.st_uid != geteuid() || rofs(path)))
+ {
+ if (!(p = getenv("HOME")))
+ return 0;
+ p = path + sfsprintf(path, PATH_MAX - 1, "%s/.%s/%s/", p, probe, HOSTTYPE);
+ }
+ strncopy(p, k, x - p);
+ force = 0;
+ if (op >= 0 && !stat(path, &st))
+ {
+ if (ptime <= (unsigned long)st.st_mtime || ptime <= (unsigned long)st.st_ctime)
+ {
+ /*
+ * verify (<sep><name><sep><option><sep><value>)* header
+ */
+
+ if (sp = sfopen(NiL, path, "r"))
+ {
+ if (x = sfgetr(sp, '\n', 1))
+ {
+ while (*x && *x != ' ')
+ x++;
+ while (*x == ' ')
+ x++;
+ if (n = *x++)
+ for (;;)
+ {
+ for (k = x; *x && *x != n; x++);
+ if (!*x)
+ break;
+ *x++ = 0;
+ for (p = x; *x && *x != n; x++);
+ if (!*x)
+ break;
+ *x++ = 0;
+ for (e = x; *x && *x != n; x++);
+ if (!*x)
+ break;
+ *x++ = 0;
+ if (streq(k, "VERSION"))
+ {
+ ap = arg;
+ *ap++ = proc;
+ *ap++ = p;
+ *ap = 0;
+ ops[0] = PROC_FD_DUP(1, 2, 0);
+ ops[1] = 0;
+ if (pp = procopen(proc, arg, NiL, ops, PROC_READ))
+ {
+ if ((v = x - e) > sizeof(ver))
+ v = sizeof(ver);
+ for (k = p = ver;; k++)
+ {
+ if (k >= p)
+ {
+ if (v <= 0 || (r = read(pp->rfd, k, v)) <= 0)
+ break;
+ v -= r;
+ p = k + r;
+ }
+ if (*k == '\n')
+ break;
+ if (*k == n)
+ *k = ' ';
+ }
+ *k = 0;
+ if (strcmp(ver, e))
+ {
+ force = 1;
+ error(0, "probe processor %s version \"%s\" changed -- expected \"%s\"", proc, ver, e);
+ }
+ procclose(pp);
+ }
+ break;
+ }
+ }
+ }
+ sfclose(sp);
+ }
+ if (!force)
+ op = -1;
+ }
+ if (op >= 0 && (st.st_mode & S_IWUSR))
+ {
+ if (op == 0)
+ error(0, "%s probe information for %s language processor %s must be manually regenerated", tool, lang, proc);
+ op = -1;
+ force = 0;
+ }
+ }
+ if (op >= 0)
+ {
+ ap = arg;
+ *ap++ = exe;
+ if (force)
+ *ap++ = "-f";
+ if (op > 0)
+ *ap++ = "-s";
+ *ap++ = (char*)lang;
+ *ap++ = (char*)tool;
+ *ap++ = proc;
+ *ap = 0;
+ if (procrun(exe, arg))
+ return 0;
+ if (eaccess(path, R_OK))
+ return 0;
+ }
+ return path == buf ? strdup(path) : path;
+}
diff --git a/usr/src/lib/libast/common/path/pathrepl.c b/usr/src/lib/libast/common/path/pathrepl.c
new file mode 100644
index 0000000000..dcee401965
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathrepl.c
@@ -0,0 +1,77 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * in place replace of first occurrence of /match/ with /replace/ in path
+ * end of path returned
+ */
+
+#include <ast.h>
+
+char*
+pathrepl(register char* path, const char* match, register const char* replace)
+{
+ register const char* m = match;
+ register const char* r;
+ char* t;
+
+ if (!match) match = "";
+ if (!replace) replace = "";
+ if (streq(match, replace))
+ return(path + strlen(path));
+ for (;;)
+ {
+ while (*path && *path++ != '/');
+ if (!*path) break;
+ if (*path == *m)
+ {
+ t = path;
+ while (*m && *m++ == *path) path++;
+ if (!*m && *path == '/')
+ {
+ register char* p;
+
+ p = t;
+ r = replace;
+ while (p < path && *r) *p++ = *r++;
+ if (p < path) while (*p++ = *path++);
+ else if (*r && p >= path)
+ {
+ register char* u;
+
+ t = path + strlen(path);
+ u = t + strlen(r);
+ while (t >= path) *u-- = *t--;
+ while (*r) *p++ = *r++;
+ }
+ else p += strlen(p) + 1;
+ return(p - 1);
+ }
+ path = t;
+ m = match;
+ }
+ }
+ return(path);
+}
diff --git a/usr/src/lib/libast/common/path/pathsetlink.c b/usr/src/lib/libast/common/path/pathsetlink.c
new file mode 100644
index 0000000000..80787e4309
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathsetlink.c
@@ -0,0 +1,72 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+* Glenn Fowler
+* AT&T Bell Laboratories
+*/
+
+#include "univlib.h"
+
+/*
+ * create symbolic name from external representation text in buf
+ * the arg order matches link(2)
+ */
+
+int
+pathsetlink(const char* buf, const char* name)
+{
+ register char* t = (char*)buf;
+#ifdef UNIV_MAX
+ register char* s = (char*)buf;
+ register char* v;
+ int n;
+ char tmp[PATH_MAX];
+
+ while (*s)
+ {
+ if (*s++ == univ_cond[0] && !strncmp(s - 1, univ_cond, univ_size))
+ {
+ s--;
+ t = tmp;
+ for (n = 0; n < UNIV_MAX; n++)
+ if (*univ_name[n])
+ {
+ *t++ = ' ';
+#ifdef ATT_UNIV
+ *t++ = '1' + n;
+ *t++ = ':';
+#else
+ for (v = univ_name[n]; *t = *v++; t++);
+ *t++ = '%';
+#endif
+ for (v = (char*)buf; v < s; *t++ = *v++);
+ for (v = univ_name[n]; *t = *v++; t++);
+ for (v = s + univ_size; *t = *v++; t++);
+ }
+ t = tmp;
+ break;
+ }
+ }
+#endif
+ return(symlink(t, name));
+}
diff --git a/usr/src/lib/libast/common/path/pathshell.c b/usr/src/lib/libast/common/path/pathshell.c
new file mode 100644
index 0000000000..f1418f5015
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathshell.c
@@ -0,0 +1,112 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * G. S. Fowler
+ * D. G. Korn
+ * AT&T Bell Laboratories
+ *
+ * shell library support
+ */
+
+#include <ast.h>
+#include <sys/stat.h>
+
+/*
+ * return pointer to the full path name of the shell
+ *
+ * SHELL is read from the environment and must start with /
+ *
+ * if set-uid or set-gid then the executable and its containing
+ * directory must not be owned by the real user/group
+ *
+ * root/administrator has its own test
+ *
+ * astconf("SH",NiL,NiL) is returned by default
+ *
+ * NOTE: csh is rejected because the bsh/csh differentiation is
+ * not done for `csh script arg ...'
+ */
+
+char*
+pathshell(void)
+{
+ register char* sh;
+ int ru;
+ int eu;
+ int rg;
+ int eg;
+ struct stat st;
+
+ static char* val;
+
+ if ((sh = getenv("SHELL")) && *sh == '/' && strmatch(sh, "*/(sh|*[!cC]sh)*([[:digit:]])?(-+([.[:alnum:]]))?(.exe)"))
+ {
+ if (!(ru = getuid()) || !eaccess("/bin", W_OK))
+ {
+ if (stat(sh, &st))
+ goto defshell;
+ if (ru != st.st_uid && !strmatch(sh, "?(/usr)?(/local)/?([ls])bin/?([[:lower:]])sh?(.exe)"))
+ goto defshell;
+ }
+ else
+ {
+ eu = geteuid();
+ rg = getgid();
+ eg = getegid();
+ if (ru != eu || rg != eg)
+ {
+ char* s;
+ char dir[PATH_MAX];
+
+ s = sh;
+ for (;;)
+ {
+ if (stat(s, &st))
+ goto defshell;
+ if (ru != eu && st.st_uid == ru)
+ goto defshell;
+ if (rg != eg && st.st_gid == rg)
+ goto defshell;
+ if (s != sh)
+ break;
+ if (strlen(s) >= sizeof(dir))
+ goto defshell;
+ strcpy(dir, s);
+ if (!(s = strrchr(dir, '/')))
+ break;
+ *s = 0;
+ s = dir;
+ }
+ }
+ }
+ return sh;
+ }
+ defshell:
+ if (!(sh = val))
+ {
+ if (!*(sh = astconf("SH", NiL, NiL)) || *sh != '/' || eaccess(sh, X_OK) || !(sh = strdup(sh)))
+ sh = "/bin/sh";
+ val = sh;
+ }
+ return sh;
+}
diff --git a/usr/src/lib/libast/common/path/pathstat.c b/usr/src/lib/libast/common/path/pathstat.c
new file mode 100644
index 0000000000..16e5c4fc85
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathstat.c
@@ -0,0 +1,45 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+#include <ls.h>
+#include <error.h>
+
+/*
+ * physical stat if logical fails
+ */
+
+int
+pathstat(const char* path, struct stat* st)
+{
+#if _lib_lstat
+ int oerrno;
+
+ oerrno = errno;
+ if (!stat(path, st)) return(0);
+ errno = oerrno;
+ return(lstat(path, st));
+#else
+ return(stat(path, st));
+#endif
+}
diff --git a/usr/src/lib/libast/common/path/pathtemp.c b/usr/src/lib/libast/common/path/pathtemp.c
new file mode 100644
index 0000000000..88d713dc9f
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathtemp.c
@@ -0,0 +1,289 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * AT&T Research
+ *
+ * generate a temp file / name
+ *
+ * [<dir>/][<pfx>]<bas>.<suf>
+ *
+ * length(<pfx>)<=5
+ * length(<bas>)==3
+ * length(<suf>)==3
+ *
+ * pathtmp(a,b,c,d) pathtemp(a,L_tmpnam,b,c,0)
+ * tmpfile() char*p=pathtemp(0,0,0,"tf",&sp);
+ * remove(p);
+ * free(p)
+ * tmpnam(0) static char p[L_tmpnam];
+ * pathtemp(p,sizeof(p),0,"tn",0)
+ * tmpnam(p) pathtemp(p,L_tmpnam,0,"tn",0)
+ * tempnam(d,p) pathtemp(0,d,p,0)
+ *
+ * if buf==0 then space is malloc'd
+ * buf size is size
+ * dir and pfx may be 0
+ * only first 5 chars of pfx are used
+ * if fdp!=0 then the path is opened O_EXCL and *fdp is the open fd
+ * malloc'd space returned by successful pathtemp() calls
+ * must be freed by the caller
+ *
+ * generated names are pseudo-randomized to avoid both
+ * collisions and predictions (same alg in sfio/sftmp.c)
+ *
+ * / as first pfx char provides tmp file generation control
+ * 0 returned for unknown ops
+ *
+ * /cycle dir specifies TMPPATH cycle control
+ * automatic (default) cycled with each tmp file
+ * manual cycled by application with dir=(nil)
+ * (nil) cycle TMPPATH
+ * /prefix dir specifies the default prefix (default ast)
+ * /TMPPATH dir overrides the env value
+ * /TMPDIR dir overrides the env value
+ */
+
+#include <ast.h>
+#include <ls.h>
+#include <tm.h>
+
+#define ATTEMPT 10
+
+#define TMP_ENV "TMPDIR"
+#define TMP_PATH_ENV "TMPPATH"
+#define TMP1 "/tmp"
+#define TMP2 "/usr/tmp"
+
+#define VALID(d) (*(d)&&!eaccess(d,W_OK|X_OK))
+
+static struct
+{
+ mode_t mode;
+ char** vec;
+ char** dir;
+ unsigned long key;
+ unsigned long rng;
+ pid_t pid;
+ int manual;
+ char* pfx;
+ char* tmpdir;
+ char* tmppath;
+} tmp = { S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH };
+
+char*
+pathtemp(char* buf, size_t len, const char* dir, const char* pfx, int* fdp)
+{
+ register char* d;
+ register char* b;
+ register char* s;
+ register char* x;
+ char* fmt;
+ int m;
+ int n;
+ int z;
+ int attempt;
+
+ if (pfx && *pfx == '/')
+ {
+ pfx++;
+ if (streq(pfx, "cycle"))
+ {
+ if (!dir)
+ {
+ tmp.manual = 1;
+ if (tmp.dir && !*tmp.dir++)
+ tmp.dir = tmp.vec;
+ }
+ else
+ tmp.manual = streq(dir, "manual");
+ return (char*)pfx;
+ }
+ else if (streq(pfx, "prefix"))
+ {
+ if (tmp.pfx)
+ free(tmp.pfx);
+ tmp.pfx = dir ? strdup(dir) : (char*)0;
+ return (char*)pfx;
+ }
+ else if (streq(pfx, "private"))
+ tmp.mode = S_IRUSR|S_IWUSR;
+ else if (streq(pfx, "public"))
+ tmp.mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
+ else if (streq(pfx, TMP_ENV))
+ {
+ if (tmp.vec)
+ {
+ free(tmp.vec);
+ tmp.vec = 0;
+ }
+ if (tmp.tmpdir)
+ free(tmp.tmpdir);
+ tmp.tmpdir = dir ? strdup(dir) : (char*)0;
+ return (char*)pfx;
+ }
+ else if (streq(pfx, TMP_PATH_ENV))
+ {
+ if (tmp.vec)
+ {
+ free(tmp.vec);
+ tmp.vec = 0;
+ }
+ if (tmp.tmppath)
+ free(tmp.tmppath);
+ tmp.tmppath = dir ? strdup(dir) : (char*)0;
+ return (char*)pfx;
+ }
+ return 0;
+ }
+ if (!(d = (char*)dir) || *d && eaccess(d, W_OK|X_OK))
+ {
+ if (!tmp.vec)
+ {
+ if ((x = tmp.tmppath) || (x = getenv(TMP_PATH_ENV)))
+ {
+ n = 2;
+ s = x;
+ while (s = strchr(s, ':'))
+ {
+ s++;
+ n++;
+ }
+ if (!(tmp.vec = newof(0, char*, n, strlen(x) + 1)))
+ return 0;
+ tmp.dir = tmp.vec;
+ x = strcpy((char*)(tmp.dir + n), x);
+ *tmp.dir++ = x;
+ while (x = strchr(x, ':'))
+ {
+ *x++ = 0;
+ if (!VALID(*(tmp.dir - 1)))
+ tmp.dir--;
+ *tmp.dir++ = x;
+ }
+ if (!VALID(*(tmp.dir - 1)))
+ tmp.dir--;
+ *tmp.dir = 0;
+ }
+ else
+ {
+ if (((d = tmp.tmpdir) || (d = getenv(TMP_ENV))) && !VALID(d))
+ d = 0;
+ if (!(tmp.vec = newof(0, char*, 2, d ? (strlen(d) + 1) : 0)))
+ return 0;
+ if (d)
+ *tmp.vec = strcpy((char*)(tmp.vec + 2), d);
+ }
+ tmp.dir = tmp.vec;
+ }
+ if (!(d = *tmp.dir++))
+ {
+ tmp.dir = tmp.vec;
+ d = *tmp.dir++;
+ }
+ if (!d && (!*(d = astconf("TMP", NiL, NiL)) || eaccess(d, W_OK|X_OK)) && eaccess(d = TMP1, W_OK|X_OK) && eaccess(d = TMP2, W_OK|X_OK))
+ return 0;
+ }
+ if (!len)
+ len = PATH_MAX;
+ len--;
+ if (!(b = buf) && !(b = newof(0, char, len, 1)))
+ return 0;
+ if (buf && dir && pfx && (buf == (char*)dir && (buf + strlen(buf) + 1) == (char*)pfx || buf == (char*)pfx && !*dir) && !strcmp((char*)pfx + strlen(pfx) + 1, "XXXXX"))
+ {
+ z = 0;
+ d = (char*)dir;
+ len = m = strlen(d) + strlen(pfx) + 8;
+ fmt = "%03.3.32lu%03.3.32lu";
+ }
+ else
+ {
+ z = '.';
+ m = 5;
+ fmt = "%02.2.32lu.%03.3.32lu";
+ }
+ x = b + len;
+ s = b;
+ if (d)
+ {
+ while (s < x && (n = *d++))
+ *s++ = n;
+ if (s < x && s > b && *(s - 1) != '/')
+ *s++ = '/';
+ }
+ if (!pfx && !(pfx = tmp.pfx))
+ pfx = "ast";
+ if ((x - s) > m)
+ x = s + m;
+ while (s < x && (n = *pfx++))
+ {
+ if (n == '/' || n == '\\' || n == z)
+ n = '_';
+ *s++ = n;
+ }
+ *s = 0;
+ len -= (s - b);
+ for (attempt = 0; attempt < ATTEMPT; attempt++)
+ {
+ if (!tmp.rng || attempt || tmp.pid != getpid())
+ {
+ register int r;
+
+ /*
+ * get a quasi-random coefficient
+ */
+
+ tmp.pid = getpid();
+ tmp.rng = (unsigned long)tmp.pid * ((unsigned long)time(NiL) ^ (((unsigned long)(&attempt)) >> 3) ^ (((unsigned long)tmp.dir) >> 3));
+ if (!tmp.key)
+ tmp.key = (tmp.rng >> 16) | ((tmp.rng & 0xffff) << 16);
+ tmp.rng ^= tmp.key;
+
+ /*
+ * Knuth vol.2, page.16, Thm.A
+ */
+
+ if ((r = (tmp.rng - 1) & 03))
+ tmp.rng += 4 - r;
+ }
+
+ /*
+ * generate a pseudo-random name
+ */
+
+ tmp.key = tmp.rng * tmp.key + 987654321L;
+ sfsprintf(s, len, fmt, (tmp.key >> 15) & 0x7fff, tmp.key & 0x7fff);
+ if (fdp)
+ {
+ if ((n = open(b, O_CREAT|O_RDWR|O_EXCL|O_TEMPORARY, tmp.mode)) >= 0)
+ {
+ *fdp = n;
+ return b;
+ }
+ }
+ else if (access(b, F_OK))
+ return b;
+ }
+ if (!buf)
+ free(b);
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/path/pathtmp.c b/usr/src/lib/libast/common/path/pathtmp.c
new file mode 100644
index 0000000000..7ef4df6b64
--- /dev/null
+++ b/usr/src/lib/libast/common/path/pathtmp.c
@@ -0,0 +1,41 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * obsolete -- use pathtemp()
+ */
+
+#include <ast.h>
+#include <stdio.h>
+
+#ifndef L_tmpnam
+#define L_tmpnam 25
+#endif
+
+char*
+pathtmp(char* buf, const char* dir, const char* pfx, int* fdp)
+{
+ size_t len;
+
+ len = !buf ? 0 : !dir ? L_tmpnam : (strlen(dir) + 14);
+ return pathtemp(buf, len, dir, pfx, fdp);
+}
diff --git a/usr/src/lib/libast/common/port/astconf.c b/usr/src/lib/libast/common/port/astconf.c
new file mode 100644
index 0000000000..e69141fddd
--- /dev/null
+++ b/usr/src/lib/libast/common/port/astconf.c
@@ -0,0 +1,1546 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * string interface to confstr(),pathconf(),sysconf(),sysinfo()
+ * extended to allow some features to be set per-process
+ */
+
+static const char id[] = "\n@(#)$Id: getconf (AT&T Research) 2006-11-15 $\0\n";
+
+#include "univlib.h"
+
+#include <ast.h>
+#include <error.h>
+#include <fs3d.h>
+#include <ctype.h>
+#include <regex.h>
+#include <proc.h>
+
+#include "conftab.h"
+#include "FEATURE/libpath"
+
+#ifndef _pth_getconf
+#undef ASTCONF_system
+#define ASTCONF_system 0
+#endif
+
+#if _sys_systeminfo
+# if !_lib_sysinfo
+# if _lib_systeminfo
+# define _lib_sysinfo 1
+# define sysinfo(a,b,c) systeminfo(a,b,c)
+# else
+# if _lib_syscall && _sys_syscall
+# include <sys/syscall.h>
+# if defined(SYS_systeminfo)
+# define _lib_sysinfo 1
+# define sysinfo(a,b,c) syscall(SYS_systeminfo,a,b,c)
+# endif
+# endif
+# endif
+# endif
+#else
+# undef _lib_sysinfo
+#endif
+
+#define OP_conformance 1
+#define OP_fs_3d 2
+#define OP_getconf 3
+#define OP_hosttype 4
+#define OP_libpath 5
+#define OP_libprefix 6
+#define OP_libsuffix 7
+#define OP_path_attributes 8
+#define OP_path_resolve 9
+#define OP_universe 10
+
+#define CONF_ERROR (CONF_USER<<0)
+#define CONF_READONLY (CONF_USER<<1)
+#define CONF_ALLOC (CONF_USER<<2)
+
+#define INITIALIZE() do{if(!state.data)synthesize(NiL,NiL,NiL);}while(0)
+
+#define MAXVAL 256
+
+#if MAXVAL <= UNIV_SIZE
+#undef MAXVAL
+#define MAXVAL (UNIV_SIZE+1)
+#endif
+
+#ifndef _UNIV_DEFAULT
+#define _UNIV_DEFAULT "att"
+#endif
+
+static char null[1];
+static char root[2] = "/";
+
+typedef struct Feature_s
+{
+ struct Feature_s*next;
+ const char* name;
+ char* value;
+ char* strict;
+ short length;
+ short standard;
+ unsigned short flags;
+ short op;
+} Feature_t;
+
+typedef struct
+{
+ Conf_t* conf;
+ const char* name;
+ unsigned short flags;
+ short call;
+ short standard;
+ short section;
+} Lookup_t;
+
+static Feature_t dynamic[] =
+{
+ {
+ &dynamic[1],
+ "CONFORMANCE",
+ "ast",
+ "standard",
+ 11,
+ CONF_AST,
+ 0,
+ OP_conformance
+ },
+ {
+ &dynamic[2],
+ "FS_3D",
+ &null[0],
+ "0",
+ 5,
+ CONF_AST,
+ 0,
+ OP_fs_3d
+ },
+ {
+ &dynamic[3],
+ "GETCONF",
+#ifdef _pth_getconf
+ _pth_getconf,
+#else
+ &null[0],
+#endif
+ 0,
+ 7,
+ CONF_AST,
+ CONF_READONLY,
+ OP_getconf
+ },
+ {
+ &dynamic[4],
+ "HOSTTYPE",
+ HOSTTYPE,
+ 0,
+ 8,
+ CONF_AST,
+ CONF_READONLY,
+ OP_hosttype
+ },
+ {
+ &dynamic[5],
+ "LIBPATH",
+#ifdef CONF_LIBPATH
+ CONF_LIBPATH,
+#else
+ &null[0],
+#endif
+ 0,
+ 7,
+ CONF_AST,
+ 0,
+ OP_libpath
+ },
+ {
+ &dynamic[6],
+ "LIBPREFIX",
+#ifdef CONF_LIBPREFIX
+ CONF_LIBPREFIX,
+#else
+ "lib",
+#endif
+ 0,
+ 9,
+ CONF_AST,
+ 0,
+ OP_libprefix
+ },
+ {
+ &dynamic[7],
+ "LIBSUFFIX",
+#ifdef CONF_LIBSUFFIX
+ CONF_LIBSUFFIX,
+#else
+ ".so",
+#endif
+ 0,
+ 9,
+ CONF_AST,
+ 0,
+ OP_libsuffix
+ },
+ {
+ &dynamic[8],
+ "PATH_ATTRIBUTES",
+#if _WINIX
+ "c",
+#else
+ &null[0],
+#endif
+ &null[0],
+ 15,
+ CONF_AST,
+ CONF_READONLY,
+ OP_path_attributes
+ },
+ {
+ &dynamic[9],
+ "PATH_RESOLVE",
+ &null[0],
+ "metaphysical",
+ 12,
+ CONF_AST,
+ 0,
+ OP_path_resolve
+ },
+ {
+ 0,
+ "UNIVERSE",
+ &null[0],
+ "att",
+ 8,
+ CONF_AST,
+ 0,
+ OP_universe
+ },
+ {
+ 0
+ }
+};
+
+typedef struct
+{
+
+ const char* id;
+ const char* name;
+ Feature_t* features;
+
+ /* default initialization from here down */
+
+ int prefix;
+ int synthesizing;
+
+ char* data;
+ char* last;
+
+ Feature_t* recent;
+
+ Ast_confdisc_f notify;
+
+} State_t;
+
+static State_t state = { "getconf", "_AST_FEATURES", dynamic };
+
+static char* feature(const char*, const char*, const char*, int, Error_f);
+
+/*
+ * return fmtbuf() copy of s
+ */
+
+static char*
+buffer(char* s)
+{
+ return strcpy(fmtbuf(strlen(s) + 1), s);
+}
+
+/*
+ * synthesize state for fp
+ * fp==0 initializes from getenv(state.name)
+ * value==0 just does lookup
+ * otherwise state is set to value
+ */
+
+static char*
+synthesize(register Feature_t* fp, const char* path, const char* value)
+{
+ register char* s;
+ register char* d;
+ register char* v;
+ register int n;
+
+ if (state.synthesizing)
+ return null;
+ if (!state.data)
+ {
+ char* se;
+ char* de;
+ char* ve;
+
+ state.prefix = strlen(state.name) + 1;
+ n = state.prefix + 3 * MAXVAL;
+ if (s = getenv(state.name))
+ n += strlen(s) + 1;
+ n = roundof(n, 32);
+ if (!(state.data = newof(0, char, n, 0)))
+ return 0;
+ state.last = state.data + n - 1;
+ strcpy(state.data, state.name);
+ state.data += state.prefix - 1;
+ *state.data++ = '=';
+ if (s)
+ strcpy(state.data, s);
+ ve = state.data;
+ state.synthesizing = 1;
+ for (;;)
+ {
+ for (s = ve; isspace(*s); s++);
+ for (d = s; *d && !isspace(*d); d++);
+ for (se = d; isspace(*d); d++);
+ for (v = d; *v && !isspace(*v); v++);
+ for (de = v; isspace(*v); v++);
+ if (!*v)
+ break;
+ for (ve = v; *ve && !isspace(*ve); ve++);
+ if (*ve)
+ *ve = 0;
+ else
+ ve = 0;
+ *de = 0;
+ *se = 0;
+ feature(s, d, v, 0, 0);
+ *se = ' ';
+ *de = ' ';
+ if (!ve)
+ break;
+ *ve++ = ' ';
+ }
+ state.synthesizing = 0;
+ }
+ if (!fp)
+ return state.data;
+ if (!state.last)
+ {
+ if (!value)
+ return 0;
+ n = strlen(value);
+ goto ok;
+ }
+ s = (char*)fp->name;
+ n = fp->length;
+ d = state.data;
+ for (;;)
+ {
+ while (isspace(*d))
+ d++;
+ if (!*d)
+ break;
+ if (strneq(d, s, n) && isspace(d[n]))
+ {
+ if (!value)
+ {
+ for (d += n + 1; *d && !isspace(*d); d++);
+ for (; isspace(*d); d++);
+ for (s = d; *s && !isspace(*s); s++);
+ n = s - d;
+ value = (const char*)d;
+ goto ok;
+ }
+ for (s = d + n + 1; *s && !isspace(*s); s++);
+ for (; isspace(*s); s++);
+ for (v = s; *s && !isspace(*s); s++);
+ n = s - v;
+ if (strneq(v, value, n))
+ goto ok;
+ for (; isspace(*s); s++);
+ if (*s)
+ for (; *d = *s++; d++);
+ else if (d != state.data)
+ d--;
+ break;
+ }
+ for (; *d && !isspace(*d); d++);
+ for (; isspace(*d); d++);
+ for (; *d && !isspace(*d); d++);
+ for (; isspace(*d); d++);
+ for (; *d && !isspace(*d); d++);
+ }
+ if (!value)
+ {
+ if (!fp->op)
+ {
+ if (fp->flags & CONF_ALLOC)
+ fp->value[0] = 0;
+ else
+ fp->value = null;
+ }
+ return 0;
+ }
+ if (!value[0])
+ value = "0";
+ if (!path || !path[0] || path[0] == '/' && !path[1])
+ path = "-";
+ n += strlen(path) + strlen(value) + 3;
+ if (d + n >= state.last)
+ {
+ int c;
+ int i;
+
+ i = d - state.data;
+ state.data -= state.prefix;
+ c = n + state.last - state.data + 3 * MAXVAL;
+ c = roundof(c, 32);
+ if (!(state.data = newof(state.data, char, c, 0)))
+ return 0;
+ state.last = state.data + c - 1;
+ state.data += state.prefix;
+ d = state.data + i;
+ }
+ if (d != state.data)
+ *d++ = ' ';
+ for (s = (char*)fp->name; *d = *s++; d++);
+ *d++ = ' ';
+ for (s = (char*)path; *d = *s++; d++);
+ *d++ = ' ';
+ for (s = (char*)value; *d = *s++; d++);
+ setenviron(state.data - state.prefix);
+ if (state.notify)
+ (*state.notify)(NiL, NiL, state.data - state.prefix);
+ n = s - (char*)value - 1;
+ ok:
+ if (!(fp->flags & CONF_ALLOC))
+ fp->value = 0;
+ if (n == 1 && (*value == '0' || *value == '-'))
+ n = 0;
+ if (!(fp->value = newof(fp->value, char, n, 1)))
+ fp->value = null;
+ else
+ {
+ fp->flags |= CONF_ALLOC;
+ memcpy(fp->value, value, n);
+ fp->value[n] = 0;
+ }
+ return fp->value;
+}
+
+/*
+ * initialize the value for fp
+ * if command!=0 then it is checked for on $PATH
+ * synthesize(fp,path,succeed) called on success
+ * otherwise synthesize(fp,path,fail) called
+ */
+
+static void
+initialize(register Feature_t* fp, const char* path, const char* command, const char* succeed, const char* fail)
+{
+ register char* p;
+ register int ok = 1;
+
+ switch (fp->op)
+ {
+ case OP_conformance:
+ ok = getenv("POSIXLY_CORRECT") != 0;
+ break;
+ case OP_hosttype:
+ ok = 1;
+ break;
+ case OP_path_attributes:
+ ok = 1;
+ break;
+ case OP_path_resolve:
+ ok = fs3d(FS3D_TEST);
+ break;
+ case OP_universe:
+ ok = streq(_UNIV_DEFAULT, "att");
+ /*FALLTHROUGH...*/
+ default:
+ if (p = getenv("PATH"))
+ {
+ register int r = 1;
+ register char* d = p;
+ Sfio_t* tmp;
+
+ if (tmp = sfstropen())
+ {
+ for (;;)
+ {
+ switch (*p++)
+ {
+ case 0:
+ break;
+ case ':':
+ if (command && (fp->op != OP_universe || !ok))
+ {
+ if (r = p - d - 1)
+ {
+ sfwrite(tmp, d, r);
+ sfputc(tmp, '/');
+ sfputr(tmp, command, 0);
+ if ((d = sfstruse(tmp)) && !eaccess(d, X_OK))
+ {
+ ok = 1;
+ if (fp->op != OP_universe)
+ break;
+ }
+ }
+ d = p;
+ }
+ r = 1;
+ continue;
+ case '/':
+ if (r)
+ {
+ r = 0;
+ if (fp->op == OP_universe)
+ {
+ if (strneq(p, "bin:", 4) || strneq(p, "usr/bin:", 8))
+ break;
+ }
+ }
+ if (fp->op == OP_universe)
+ {
+ if (strneq(p, "5bin", 4))
+ {
+ ok = 1;
+ break;
+ }
+ if (strneq(p, "bsd", 3) || strneq(p, "ucb", 3))
+ {
+ ok = 0;
+ break;
+ }
+ }
+ continue;
+ default:
+ r = 0;
+ continue;
+ }
+ break;
+ }
+ sfclose(tmp);
+ }
+ else
+ ok = 1;
+ }
+ break;
+ }
+ synthesize(fp, path, ok ? succeed : fail);
+}
+
+/*
+ * format synthesized value
+ */
+
+static char*
+format(register Feature_t* fp, const char* path, const char* value, int flags, Error_f conferror)
+{
+ register Feature_t* sp;
+ register int n;
+
+ switch (fp->op)
+ {
+
+ case OP_conformance:
+ if (value && (streq(value, "strict") || streq(value, "posix") || streq(value, "xopen")))
+ value = fp->strict;
+ n = streq(fp->value, fp->strict);
+ if (!synthesize(fp, path, value))
+ initialize(fp, path, NiL, fp->strict, fp->value);
+ if (!n && streq(fp->value, fp->strict))
+ for (sp = state.features; sp; sp = sp->next)
+ if (sp->strict && sp->op && sp->op != OP_conformance)
+ astconf(sp->name, path, sp->strict);
+ break;
+
+ case OP_fs_3d:
+ fp->value = fs3d(value ? value[0] ? FS3D_ON : FS3D_OFF : FS3D_TEST) ? "1" : null;
+ break;
+
+ case OP_hosttype:
+ break;
+
+ case OP_path_attributes:
+#ifdef _PC_PATH_ATTRIBUTES
+ {
+ register char* s;
+ register char* e;
+ intmax_t v;
+
+ /*
+ * _PC_PATH_ATTRIBUTES is a bitmap for 'a' to 'z'
+ */
+
+ if ((v = pathconf(path, _PC_PATH_ATTRIBUTES)) == -1L)
+ return 0;
+ s = fp->value;
+ e = s + sizeof(fp->value) - 1;
+ for (n = 'a'; n <= 'z'; n++)
+ if (v & (1 << (n - 'a')))
+ {
+ *s++ = n;
+ if (s >= e)
+ break;
+ }
+ *s = 0;
+ }
+#endif
+ break;
+
+ case OP_path_resolve:
+ if (!synthesize(fp, path, value))
+ initialize(fp, path, NiL, "logical", "metaphysical");
+ break;
+
+ case OP_universe:
+#if _lib_universe
+ if (getuniverse(fp->value) < 0)
+ strcpy(fp->value, "att");
+ if (value)
+ setuniverse(value);
+#else
+#ifdef UNIV_MAX
+ n = 0;
+ if (value)
+ {
+ while (n < univ_max && !streq(value, univ_name[n])
+ n++;
+ if (n >= univ_max)
+ {
+ if (conferror)
+ (*conferror)(&state, &state, 2, "%s: %s: universe value too large", fp->name, value);
+ return 0;
+ }
+ }
+#ifdef ATT_UNIV
+ n = setuniverse(n + 1);
+ if (!value && n > 0)
+ setuniverse(n);
+#else
+ n = universe(value ? n + 1 : U_GET);
+#endif
+ if (n <= 0 || n >= univ_max)
+ n = 1;
+ strcpy(fp->value, univ_name[n - 1]);
+#else
+ if (!synthesize(fp, path, value))
+ initialize(fp, path, "echo", "att", "ucb");
+#endif
+#endif
+ break;
+
+ default:
+ synthesize(fp, path, value);
+ break;
+
+ }
+ return fp->value;
+}
+
+/*
+ * value==0 get feature name
+ * value!=0 set feature name
+ * 0 returned if error or not defined; otherwise previous value
+ */
+
+static char*
+feature(const char* name, const char* path, const char* value, int flags, Error_f conferror)
+{
+ register Feature_t* fp;
+ register int n;
+
+ if (value && (streq(value, "-") || streq(value, "0")))
+ value = null;
+ for (fp = state.features; fp && !streq(fp->name, name); fp = fp->next);
+#if DEBUG || DEBUG_astconf
+ error(-2, "astconf feature name=%s path=%s value=%s flags=%04x fp=%p", name, path, value, flags, fp);
+#endif
+ if (!fp)
+ {
+ if (!value)
+ return 0;
+ if (state.notify && !(*state.notify)(name, path, value))
+ return 0;
+ n = strlen(name);
+ if (!(fp = newof(0, Feature_t, 1, n + 1)))
+ {
+ if (conferror)
+ (*conferror)(&state, &state, 2, "%s: out of space", name);
+ return 0;
+ }
+ fp->name = (const char*)fp + sizeof(Feature_t);
+ strcpy((char*)fp->name, name);
+ fp->length = n;
+ fp->next = state.features;
+ state.features = fp;
+ }
+ else if (value)
+ {
+ if (fp->flags & CONF_READONLY)
+ {
+ if (conferror)
+ (*conferror)(&state, &state, 2, "%s: cannot set readonly symbol", fp->name);
+ return 0;
+ }
+ if (state.notify && !streq(fp->value, value) && !(*state.notify)(name, path, value))
+ return 0;
+ }
+ else
+ state.recent = fp;
+ return format(fp, path, value, flags, conferror);
+}
+
+/*
+ * binary search for name in conf[]
+ */
+
+static int
+lookup(register Lookup_t* look, const char* name, int flags)
+{
+ register Conf_t* mid = (Conf_t*)conf;
+ register Conf_t* lo = mid;
+ register Conf_t* hi = mid + conf_elements;
+ register int v;
+ register int c;
+ char* e;
+ const Prefix_t* p;
+
+ static Conf_t num;
+
+ look->flags = 0;
+ look->call = -1;
+ look->standard = (flags & ASTCONF_AST) ? CONF_AST : -1;
+ look->section = -1;
+ while (*name == '_')
+ name++;
+ again:
+ for (p = prefix; p < &prefix[prefix_elements]; p++)
+ if (strneq(name, p->name, p->length) && ((c = name[p->length] == '_' || name[p->length] == '(') || (v = isdigit(name[p->length]) && name[p->length + 1] == '_')))
+ {
+ if (p->call < 0)
+ {
+ if (look->standard >= 0)
+ break;
+ look->standard = p->standard;
+ }
+ else
+ {
+ if (look->call >= 0)
+ break;
+ look->call = p->call;
+ }
+ if (name[p->length] == '(')
+ {
+ look->conf = &num;
+ strncpy((char*)num.name, name, sizeof(num.name));
+ num.call = p->call;
+ num.flags = *name == 'C' ? CONF_STRING : 0;
+ num.op = (short)strtol(name + p->length + 1, &e, 10);
+ if (*e++ != ')' || *e)
+ break;
+ return 1;
+ }
+ name += p->length + c;
+ if (look->section < 0 && !c && v)
+ {
+ look->section = name[0] - '0';
+ name += 2;
+ }
+ goto again;
+ }
+#if HUH_2006_02_10
+ if (look->section < 0)
+ look->section = 1;
+#endif
+ look->name = name;
+#if DEBUG || DEBUG_astconf
+ error(-2, "astconf normal name=%s standard=%d section=%d call=%d flags=%04x elements=%d", look->name, look->standard, look->section, look->call, flags, conf_elements);
+#endif
+ c = *((unsigned char*)name);
+ while (lo <= hi)
+ {
+ mid = lo + (hi - lo) / 2;
+#if DEBUG || DEBUG_astconf
+ error(-3, "astconf lookup name=%s mid=%s", name, mid->name);
+#endif
+ if (!(v = c - *((unsigned char*)mid->name)) && !(v = strcmp(name, mid->name)))
+ {
+ hi = mid;
+ lo = (Conf_t*)conf;
+ do
+ {
+ if ((look->standard < 0 || look->standard == mid->standard) &&
+ (look->section < 0 || look->section == mid->section) &&
+ (look->call < 0 || look->call == mid->call))
+ goto found;
+ } while (mid-- > lo && streq(mid->name, look->name));
+ mid = hi;
+ hi = lo + conf_elements - 1;
+ while (++mid < hi && streq(mid->name, look->name))
+ {
+ if ((look->standard < 0 || look->standard == mid->standard) &&
+ (look->section < 0 || look->section == mid->section) &&
+ (look->call < 0 || look->call == mid->call))
+ goto found;
+ }
+ break;
+ }
+ else if (v > 0)
+ lo = mid + 1;
+ else
+ hi = mid - 1;
+ }
+ return 0;
+ found:
+ if (look->call < 0 && look->standard >= 0 && (look->section <= 1 || (mid->flags & CONF_MINMAX)))
+ look->flags |= CONF_MINMAX;
+ look->conf = mid;
+#if DEBUG || DEBUG_astconf
+ error(-2, "astconf lookup name=%s standard=%d:%d section=%d:%d call=%d:%d", look->name, look->standard, mid->standard, look->section, mid->section, look->call, mid->call);
+#endif
+ return 1;
+}
+
+/*
+ * return a tolower'd copy of s
+ */
+
+static char*
+fmtlower(register const char* s)
+{
+ register int c;
+ register char* t;
+ char* b;
+
+ b = t = fmtbuf(strlen(s) + 1);
+ while (c = *s++)
+ {
+ if (isupper(c))
+ c = tolower(c);
+ *t++ = c;
+ }
+ *t = 0;
+ return b;
+}
+
+/*
+ * print value line for p
+ * if !name then value prefixed by "p->name="
+ * if (flags & CONF_MINMAX) then default minmax value used
+ */
+
+static char*
+print(Sfio_t* sp, register Lookup_t* look, const char* name, const char* path, int listflags, Error_f conferror)
+{
+ register Conf_t* p = look->conf;
+ register int flags = look->flags;
+ char* call;
+ char* f;
+ const char* s;
+ int i;
+ int olderrno;
+ int drop;
+ int defined;
+ intmax_t v;
+ char buf[PATH_MAX];
+ char flg[16];
+
+ if (!name && !(p->flags & CONF_STRING) && (p->flags & (CONF_FEATURE|CONF_LIMIT|CONF_MINMAX)) && (p->flags & (CONF_LIMIT|CONF_PREFIXED)) != CONF_LIMIT)
+ flags |= CONF_PREFIXED;
+ olderrno = errno;
+ errno = 0;
+#if DEBUG || DEBUG_astconf
+ error(-1, "astconf name=%s:%s standard=%d section=%d call=%s op=%d flags=|%s%s%s%s%s:|%s%s%s%s%s%s%s%s%s%s"
+ , name , p->name, p->standard, p->section, prefix[p->call + CONF_call].name, p->op
+ , (flags & CONF_FEATURE) ? "FEATURE|" : ""
+ , (flags & CONF_LIMIT) ? "LIMIT|" : ""
+ , (flags & CONF_MINMAX) ? "MINMAX|" : ""
+ , (flags & CONF_PREFIXED) ? "PREFIXED|" : ""
+ , (flags & CONF_STRING) ? "STRING|" : ""
+ , (p->flags & CONF_DEFER_CALL) ? "DEFER_CALL|" : ""
+ , (p->flags & CONF_DEFER_MM) ? "DEFER_MM|" : ""
+ , (p->flags & CONF_FEATURE) ? "FEATURE|" : ""
+ , (p->flags & CONF_LIMIT_DEF) ? "LIMIT_DEF|" : (p->flags & CONF_LIMIT) ? "LIMIT|" : ""
+ , (p->flags & CONF_MINMAX_DEF) ? "MINMAX_DEF|" : (p->flags & CONF_MINMAX) ? "MINMAX|" : ""
+ , (p->flags & CONF_NOUNDERSCORE) ? "NOUNDERSCORE|" : ""
+ , (p->flags & CONF_PREFIXED) ? "PREFIXED|" : ""
+ , (p->flags & CONF_PREFIX_ONLY) ? "PREFIX_ONLY|" : ""
+ , (p->flags & CONF_STANDARD) ? "STANDARD|" : ""
+ , (p->flags & CONF_STRING) ? "STRING|" : ""
+ , (p->flags & CONF_UNDERSCORE) ? "UNDERSCORE|" : ""
+ );
+#endif
+ flags |= CONF_LIMIT_DEF|CONF_MINMAX_DEF;
+ if (conferror && name)
+ {
+ if ((p->flags & CONF_PREFIX_ONLY) && look->standard < 0)
+ goto bad;
+ if (!(flags & CONF_MINMAX) || !(p->flags & CONF_MINMAX))
+ {
+ switch (p->call)
+ {
+ case CONF_pathconf:
+ if (path == root)
+ {
+ (*conferror)(&state, &state, 2, "%s: path expected", name);
+ goto bad;
+ }
+ break;
+ default:
+ if (path != root)
+ {
+ (*conferror)(&state, &state, 2, "%s: path not expected", name);
+ goto bad;
+ }
+ break;
+ }
+#ifdef _pth_getconf
+ if (p->flags & CONF_DEFER_CALL)
+ goto bad;
+#endif
+ }
+ else
+ {
+ if (path != root)
+ {
+ (*conferror)(&state, &state, 2, "%s: path not expected", name);
+ goto bad;
+ }
+#ifdef _pth_getconf
+ if ((p->flags & CONF_DEFER_MM) || !(p->flags & CONF_MINMAX_DEF))
+ goto bad;
+#endif
+ }
+ if (look->standard >= 0 && (name[0] != '_' && ((p->flags & CONF_UNDERSCORE) || look->section <= 1) || name[0] == '_' && (p->flags & CONF_NOUNDERSCORE)) || look->standard < 0 && name[0] == '_')
+ goto bad;
+ }
+ s = 0;
+ defined = 1;
+ switch (i = (p->op < 0 || (flags & CONF_MINMAX) && (p->flags & CONF_MINMAX_DEF)) ? 0 : p->call)
+ {
+ case CONF_confstr:
+ call = "confstr";
+#if _lib_confstr
+ if (!(v = confstr(p->op, buf, sizeof(buf))))
+ {
+ defined = 0;
+ v = -1;
+ errno = EINVAL;
+ }
+ else if (v > 0)
+ {
+ buf[sizeof(buf) - 1] = 0;
+ s = (const char*)buf;
+ }
+ else
+ defined = 0;
+ break;
+#else
+ goto predef;
+#endif
+ case CONF_pathconf:
+ call = "pathconf";
+#if _lib_pathconf
+ if ((v = pathconf(path, p->op)) < 0)
+ defined = 0;
+ break;
+#else
+ goto predef;
+#endif
+ case CONF_sysconf:
+ call = "sysconf";
+#if _lib_sysconf
+ if ((v = sysconf(p->op)) < 0)
+ defined = 0;
+ break;
+#else
+ goto predef;
+#endif
+ case CONF_sysinfo:
+ call = "sysinfo";
+#if _lib_sysinfo
+ if ((v = sysinfo(p->op, buf, sizeof(buf))) >= 0)
+ {
+ buf[sizeof(buf) - 1] = 0;
+ s = (const char*)buf;
+ }
+ else
+ defined = 0;
+ break;
+#else
+ goto predef;
+#endif
+ default:
+ call = "synthesis";
+ errno = EINVAL;
+ v = -1;
+ defined = 0;
+ break;
+ case 0:
+ call = 0;
+ if (p->flags & CONF_MINMAX_DEF)
+ {
+ if (!((p->flags & CONF_LIMIT_DEF)))
+ flags |= CONF_MINMAX;
+ listflags &= ~ASTCONF_system;
+ }
+ predef:
+ if (look->standard == CONF_AST)
+ {
+ if (streq(look->name, "VERSION"))
+ {
+ v = _AST_VERSION;
+ break;
+ }
+ }
+ if (flags & CONF_MINMAX)
+ {
+ if ((p->flags & CONF_MINMAX_DEF) && (!(listflags & ASTCONF_system) || !(p->flags & CONF_DEFER_MM)))
+ {
+ v = p->minmax.number;
+ s = p->minmax.string;
+ break;
+ }
+ }
+ else if ((p->flags & CONF_LIMIT_DEF) && (!(listflags & ASTCONF_system) || !(p->flags & CONF_DEFER_CALL)))
+ {
+ v = p->limit.number;
+ s = p->limit.string;
+ break;
+ }
+ flags &= ~(CONF_LIMIT_DEF|CONF_MINMAX_DEF);
+ v = -1;
+ errno = EINVAL;
+ defined = 0;
+ break;
+ }
+ if (!defined)
+ {
+ if (!errno)
+ {
+ if ((p->flags & CONF_FEATURE) || !(p->flags & (CONF_LIMIT|CONF_MINMAX)))
+ flags &= ~(CONF_LIMIT_DEF|CONF_MINMAX_DEF);
+ }
+ else if (flags & CONF_PREFIXED)
+ flags &= ~(CONF_LIMIT_DEF|CONF_MINMAX_DEF);
+ else if (errno != EINVAL || !i)
+ {
+ if (!sp)
+ {
+ if (conferror)
+ {
+ if (call)
+ (*conferror)(&state, &state, ERROR_SYSTEM|2, "%s: %s error", p->name, call);
+ else if (!(listflags & ASTCONF_system))
+ (*conferror)(&state, &state, 2, "%s: unknown name", p->name);
+ }
+ goto bad;
+ }
+ else
+ {
+ flags &= ~(CONF_LIMIT_DEF|CONF_MINMAX_DEF);
+ flags |= CONF_ERROR;
+ }
+ }
+ }
+ errno = olderrno;
+ if ((listflags & ASTCONF_defined) && !(flags & (CONF_LIMIT_DEF|CONF_MINMAX_DEF)))
+ goto bad;
+ if ((drop = !sp) && !(sp = sfstropen()))
+ goto bad;
+ if (listflags & ASTCONF_table)
+ {
+ f = flg;
+ if (p->flags & CONF_DEFER_CALL)
+ *f++ = 'C';
+ if (p->flags & CONF_DEFER_MM)
+ *f++ = 'D';
+ if (p->flags & CONF_FEATURE)
+ *f++ = 'F';
+ if (p->flags & CONF_LIMIT)
+ *f++ = 'L';
+ if (p->flags & CONF_MINMAX)
+ *f++ = 'M';
+ if (p->flags & CONF_NOSECTION)
+ *f++ = 'N';
+ if (p->flags & CONF_PREFIXED)
+ *f++ = 'P';
+ if (p->flags & CONF_STANDARD)
+ *f++ = 'S';
+ if (p->flags & CONF_UNDERSCORE)
+ *f++ = 'U';
+ if (p->flags & CONF_NOUNDERSCORE)
+ *f++ = 'V';
+ if (p->flags & CONF_PREFIX_ONLY)
+ *f++ = 'W';
+ if (f == flg)
+ *f++ = 'X';
+ *f = 0;
+ sfprintf(sp, "%*s %*s %d %2s %4d %6s ", sizeof(p->name), p->name, sizeof(prefix[p->standard].name), prefix[p->standard].name, p->section, prefix[p->call + CONF_call].name, p->op, flg);
+ if (p->flags & CONF_LIMIT_DEF)
+ {
+ if (p->limit.string)
+ sfprintf(sp, "L[%s] ", (listflags & ASTCONF_quote) ? fmtquote(p->limit.string, "\"", "\"", strlen(p->limit.string), FMT_SHELL) : p->limit.string);
+ else
+ sfprintf(sp, "L[%I*d] ", sizeof(p->limit.number), p->limit.number);
+ }
+ if (p->flags & CONF_MINMAX_DEF)
+ {
+ if (p->minmax.string)
+ sfprintf(sp, "M[%s] ", (listflags & ASTCONF_quote) ? fmtquote(p->minmax.string, "\"", "\"", strlen(p->minmax.string), FMT_SHELL) : p->minmax.string);
+ else
+ sfprintf(sp, "M[%I*d] ", sizeof(p->minmax.number), p->minmax.number);
+ }
+ if (flags & CONF_ERROR)
+ sfprintf(sp, "error");
+ else if (defined)
+ {
+ if (s)
+ sfprintf(sp, "%s", (listflags & ASTCONF_quote) ? fmtquote(s, "\"", "\"", strlen(s), FMT_SHELL) : s);
+ else if (v != -1)
+ sfprintf(sp, "%I*d", sizeof(v), v);
+ else
+ sfprintf(sp, "%I*u", sizeof(v), v);
+ }
+ sfprintf(sp, "\n");
+ }
+ else
+ {
+ if (!(flags & CONF_PREFIXED) || (listflags & ASTCONF_base))
+ {
+ if (!name)
+ {
+ if ((p->flags & (CONF_PREFIXED|CONF_STRING)) == (CONF_PREFIXED|CONF_STRING) && (!(listflags & ASTCONF_base) || p->standard != CONF_POSIX))
+ {
+ if ((p->flags & CONF_UNDERSCORE) && !(listflags & ASTCONF_base))
+ sfprintf(sp, "_");
+ sfprintf(sp, "%s", (listflags & ASTCONF_lower) ? fmtlower(prefix[p->standard].name) : prefix[p->standard].name);
+ if (p->section > 1)
+ sfprintf(sp, "%d", p->section);
+ sfprintf(sp, "_");
+ }
+ sfprintf(sp, "%s=", (listflags & ASTCONF_lower) ? fmtlower(p->name) : p->name);
+ }
+ if (flags & CONF_ERROR)
+ sfprintf(sp, "error");
+ else if (defined)
+ {
+ if (s)
+ sfprintf(sp, "%s", (listflags & ASTCONF_quote) ? fmtquote(s, "\"", "\"", strlen(s), FMT_SHELL) : s);
+ else if (v != -1)
+ sfprintf(sp, "%I*d", sizeof(v), v);
+ else
+ sfprintf(sp, "%I*u", sizeof(v), v);
+ }
+ else
+ sfprintf(sp, "undefined");
+ if (!name)
+ sfprintf(sp, "\n");
+ }
+ if (!name && !(listflags & ASTCONF_base) && !(p->flags & CONF_STRING) && (p->flags & (CONF_FEATURE|CONF_MINMAX)))
+ {
+ if (p->flags & CONF_UNDERSCORE)
+ sfprintf(sp, "_");
+ sfprintf(sp, "%s", (listflags & ASTCONF_lower) ? fmtlower(prefix[p->standard].name) : prefix[p->standard].name);
+ if (p->section > 1)
+ sfprintf(sp, "%d", p->section);
+ sfprintf(sp, "_%s=", (listflags & ASTCONF_lower) ? fmtlower(p->name) : p->name);
+ if (v != -1)
+ sfprintf(sp, "%I*d", sizeof(v), v);
+ else if (defined)
+ sfprintf(sp, "%I*u", sizeof(v), v);
+ else
+ sfprintf(sp, "undefined");
+ sfprintf(sp, "\n");
+ }
+ }
+ if (drop)
+ {
+ if (call = sfstruse(sp))
+ call = buffer(call);
+ else
+ call = "[ out of space ]";
+ sfclose(sp);
+ return call;
+ }
+ bad:
+ return (listflags & ASTCONF_error) ? (char*)0 : null;
+}
+
+/*
+ * return read stream to native getconf utility
+ */
+
+static Sfio_t*
+nativeconf(Proc_t** pp, const char* operand)
+{
+#ifdef _pth_getconf
+ Sfio_t* sp;
+ char* cmd[3];
+ long ops[2];
+
+#if DEBUG || DEBUG_astconf
+ error(-2, "astconf defer %s %s", _pth_getconf, operand);
+#endif
+ cmd[0] = (char*)state.id;
+ cmd[1] = (char*)operand;
+ cmd[2] = 0;
+ ops[0] = PROC_FD_DUP(open("/dev/null",O_WRONLY,0), 2, PROC_FD_CHILD);
+ ops[1] = 0;
+ if (*pp = procopen(_pth_getconf, cmd, environ, ops, PROC_READ))
+ {
+ if (sp = sfnew(NiL, NiL, SF_UNBOUND, (*pp)->rfd, SF_READ))
+ {
+ sfdisc(sp, SF_POPDISC);
+ return sp;
+ }
+ procclose(*pp);
+ }
+#endif
+ return 0;
+}
+
+/*
+ * value==0 gets value for name
+ * value!=0 sets value for name and returns previous value
+ * path==0 implies path=="/"
+ *
+ * settable return values are in permanent store
+ * non-settable return values copied to a tmp fmtbuf() buffer
+ *
+ * if (streq(astgetconf("PATH_RESOLVE", NiL, NiL, 0, 0), "logical"))
+ * our_way();
+ *
+ * universe = astgetconf("UNIVERSE", NiL, "att", 0, 0);
+ * astgetconf("UNIVERSE", NiL, universe, 0, 0);
+ *
+ * if (flags&ASTCONF_error)!=0 then error return value is 0
+ * otherwise 0 not returned
+ */
+
+#define ALT 16
+
+char*
+astgetconf(const char* name, const char* path, const char* value, int flags, Error_f conferror)
+{
+ register char* s;
+ int n;
+ Lookup_t look;
+ Sfio_t* tmp;
+
+#if __OBSOLETE__ < 20080101
+ if (pointerof(flags) == (void*)errorf)
+ {
+ conferror = errorf;
+ flags = ASTCONF_error;
+ }
+ else if (conferror && conferror != errorf)
+ conferror = 0;
+#endif
+ if (!name)
+ {
+ if (path)
+ return null;
+ if (!(name = value))
+ {
+ if (state.data)
+ {
+ Ast_confdisc_f notify;
+
+#if _HUH20000515 /* doesn't work for shell builtins */
+ free(state.data - state.prefix);
+#endif
+ state.data = 0;
+ notify = state.notify;
+ state.notify = 0;
+ INITIALIZE();
+ state.notify = notify;
+ }
+ return null;
+ }
+ value = 0;
+ }
+ INITIALIZE();
+ if (!path)
+ path = root;
+ if (state.recent && streq(name, state.recent->name) && (s = format(state.recent, path, value, flags, conferror)))
+ return s;
+ if (lookup(&look, name, flags))
+ {
+ if (value)
+ {
+ ro:
+ errno = EINVAL;
+ if (conferror)
+ (*conferror)(&state, &state, 2, "%s: cannot set value", name);
+ return (flags & ASTCONF_error) ? (char*)0 : null;
+ }
+ return print(NiL, &look, name, path, flags, conferror);
+ }
+ if ((n = strlen(name)) > 3 && n < (ALT + 3))
+ {
+ if (streq(name + n - 3, "DEV"))
+ {
+ if (tmp = sfstropen())
+ {
+ sfprintf(tmp, "/dev/");
+ for (s = (char*)name; s < (char*)name + n - 3; s++)
+ sfputc(tmp, isupper(*s) ? tolower(*s) : *s);
+ if ((s = sfstruse(tmp)) && !access(s, F_OK))
+ {
+ if (value)
+ goto ro;
+ s = buffer(s);
+ sfclose(tmp);
+ return s;
+ }
+ sfclose(tmp);
+ }
+ }
+ else if (streq(name + n - 3, "DIR"))
+ {
+ Lookup_t altlook;
+ char altname[ALT];
+
+ static const char* dirs[] = { "/usr/lib", "/usr", null };
+
+ strcpy(altname, name);
+ altname[n - 3] = 0;
+ if (lookup(&altlook, altname, flags))
+ {
+ if (value)
+ {
+ errno = EINVAL;
+ if (conferror)
+ (*conferror)(&state, &state, 2, "%s: cannot set value", altname);
+ return (flags & ASTCONF_error) ? (char*)0 : null;
+ }
+ return print(NiL, &altlook, altname, path, flags, conferror);
+ }
+ for (s = altname; *s; s++)
+ if (isupper(*s))
+ *s = tolower(*s);
+ if (tmp = sfstropen())
+ {
+ for (n = 0; n < elementsof(dirs); n++)
+ {
+ sfprintf(tmp, "%s/%s/.", dirs[n], altname);
+ if ((s = sfstruse(tmp)) && !access(s, F_OK))
+ {
+ if (value)
+ goto ro;
+ s = buffer(s);
+ sfclose(tmp);
+ return s;
+ }
+ }
+ sfclose(tmp);
+ }
+ }
+ }
+ if ((look.standard < 0 || look.standard == CONF_AST) && look.call <= 0 && look.section <= 1 && (s = feature(look.name, path, value, flags, conferror)))
+ return s;
+ errno = EINVAL;
+ if (conferror && !(flags & ASTCONF_system))
+ (*conferror)(&state, &state, 2, "%s: unknown name", name);
+ return (flags & ASTCONF_error) ? (char*)0 : null;
+}
+
+/*
+ * astconf() never returns 0
+ */
+
+char*
+astconf(const char* name, const char* path, const char* value)
+{
+ return astgetconf(name, path, value, 0, 0);
+}
+
+/*
+ * set discipline function to be called when features change
+ * old discipline function returned
+ */
+
+Ast_confdisc_f
+astconfdisc(Ast_confdisc_f new_notify)
+{
+ Ast_confdisc_f old_notify;
+
+ INITIALIZE();
+ old_notify = state.notify;
+ state.notify = new_notify;
+ return old_notify;
+}
+
+/*
+ * list all name=value entries on sp
+ * path==0 implies path=="/"
+ */
+
+void
+astconflist(Sfio_t* sp, const char* path, int flags, const char* pattern)
+{
+ char* s;
+ char* f;
+ char* call;
+ Feature_t* fp;
+ Lookup_t look;
+ regex_t re;
+ regdisc_t redisc;
+ int olderrno;
+ char flg[8];
+#ifdef _pth_getconf_a
+ Proc_t* proc;
+ Sfio_t* pp;
+#endif
+
+ INITIALIZE();
+ if (!path)
+ path = root;
+ else if (access(path, F_OK))
+ {
+ errorf(&state, &state, 2, "%s: not found", path);
+ return;
+ }
+ olderrno = errno;
+ look.flags = 0;
+ if (!(flags & (ASTCONF_read|ASTCONF_write|ASTCONF_parse)))
+ flags |= ASTCONF_read|ASTCONF_write;
+ else if (flags & ASTCONF_parse)
+ flags |= ASTCONF_write;
+ if (!(flags & (ASTCONF_matchcall|ASTCONF_matchname|ASTCONF_matchstandard)))
+ pattern = 0;
+ if (pattern)
+ {
+ memset(&redisc, 0, sizeof(redisc));
+ redisc.re_version = REG_VERSION;
+ redisc.re_errorf = (regerror_t)errorf;
+ re.re_disc = &redisc;
+ if (regcomp(&re, pattern, REG_DISCIPLINE|REG_EXTENDED|REG_LENIENT|REG_NULL))
+ return;
+ }
+ if (flags & ASTCONF_read)
+ {
+ for (look.conf = (Conf_t*)conf; look.conf < (Conf_t*)&conf[conf_elements]; look.conf++)
+ {
+ if (pattern)
+ {
+ if (flags & ASTCONF_matchcall)
+ {
+ if (regexec(&re, prefix[look.conf->call + CONF_call].name, 0, NiL, 0))
+ continue;
+ }
+ else if (flags & ASTCONF_matchname)
+ {
+ if (regexec(&re, look.conf->name, 0, NiL, 0))
+ continue;
+ }
+ else if (flags & ASTCONF_matchstandard)
+ {
+ if (regexec(&re, prefix[look.conf->standard].name, 0, NiL, 0))
+ continue;
+ }
+ }
+ print(sp, &look, NiL, path, flags, errorf);
+ }
+#ifdef _pth_getconf_a
+ if (pp = nativeconf(&proc, _pth_getconf_a))
+ {
+ call = "GC";
+ while (f = sfgetr(pp, '\n', 1))
+ {
+ for (s = f; *s && *s != '=' && *s != ':' && !isspace(*s); s++);
+ if (*s)
+ for (*s++ = 0; isspace(*s); s++);
+ if (!lookup(&look, f, flags))
+ {
+ if (flags & ASTCONF_table)
+ {
+ if (look.standard < 0)
+ look.standard = 0;
+ if (look.section < 1)
+ look.section = 1;
+ sfprintf(sp, "%*s %*s %d %2s %4d %5s %s\n", sizeof(conf[0].name), f, sizeof(prefix[look.standard].name), prefix[look.standard].name, look.section, call, 0, "N", s);
+ }
+ else if (flags & ASTCONF_parse)
+ sfprintf(sp, "%s %s - %s\n", state.id, f, s);
+ else
+ sfprintf(sp, "%s=%s\n", f, (flags & ASTCONF_quote) ? fmtquote(s, "\"", "\"", strlen(s), FMT_SHELL) : s);
+ }
+ }
+ sfclose(pp);
+ procclose(proc);
+ }
+#endif
+ }
+ if (flags & ASTCONF_write)
+ {
+ call = "AC";
+ for (fp = state.features; fp; fp = fp->next)
+ {
+ if (pattern)
+ {
+ if (flags & ASTCONF_matchcall)
+ {
+ if (regexec(&re, call, 0, NiL, 0))
+ continue;
+ }
+ else if (flags & ASTCONF_matchname)
+ {
+ if (regexec(&re, fp->name, 0, NiL, 0))
+ continue;
+ }
+ else if (flags & ASTCONF_matchstandard)
+ {
+ if (regexec(&re, prefix[fp->standard].name, 0, NiL, 0))
+ continue;
+ }
+ }
+ if (!(s = feature(fp->name, path, NiL, 0, 0)) || !*s)
+ s = "0";
+ if (flags & ASTCONF_table)
+ {
+ f = flg;
+ if (fp->flags & CONF_ALLOC)
+ *f++ = 'A';
+ if (fp->flags & CONF_READONLY)
+ *f++ = 'R';
+ if (f == flg)
+ *f++ = 'X';
+ *f = 0;
+ sfprintf(sp, "%*s %*s %d %2s %4d %5s %s\n", sizeof(conf[0].name), fp->name, sizeof(prefix[fp->standard].name), prefix[fp->standard].name, 1, call, 0, flg, s);
+ }
+ else if (flags & ASTCONF_parse)
+ sfprintf(sp, "%s %s - %s\n", state.id, (flags & ASTCONF_lower) ? fmtlower(fp->name) : fp->name, fmtquote(s, "\"", "\"", strlen(s), FMT_SHELL));
+ else
+ sfprintf(sp, "%s=%s\n", (flags & ASTCONF_lower) ? fmtlower(fp->name) : fp->name, (flags & ASTCONF_quote) ? fmtquote(s, "\"", "\"", strlen(s), FMT_SHELL) : s);
+ }
+ }
+ if (pattern)
+ regfree(&re);
+ errno = olderrno;
+}
diff --git a/usr/src/lib/libast/common/port/astcopy.c b/usr/src/lib/libast/common/port/astcopy.c
new file mode 100644
index 0000000000..2dbf712ddc
--- /dev/null
+++ b/usr/src/lib/libast/common/port/astcopy.c
@@ -0,0 +1,90 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * copy from rfd to wfd (with conditional mmap hacks)
+ */
+
+#include <ast.h>
+#include <ast_mmap.h>
+
+#if _mmap_worthy > 1
+
+#include <ls.h>
+
+#define MAPSIZE (1024*256)
+
+#endif
+
+#undef BUFSIZ
+#define BUFSIZ 4096
+
+/*
+ * copy n bytes from rfd to wfd
+ * actual byte count returned
+ * if n<=0 then ``good'' size is used
+ */
+
+off_t
+astcopy(int rfd, int wfd, off_t n)
+{
+ register off_t c;
+#ifdef MAPSIZE
+ off_t pos;
+ off_t mapsize;
+ char* mapbuf;
+ struct stat st;
+#endif
+
+ static int bufsiz;
+ static char* buf;
+
+ if (n <= 0 || n >= BUFSIZ * 2)
+ {
+#if MAPSIZE
+ if (!fstat(rfd, &st) && S_ISREG(st.st_mode) && (pos = lseek(rfd, (off_t)0, 1)) != ((off_t)-1))
+ {
+ if (pos >= st.st_size) return(0);
+ mapsize = st.st_size - pos;
+ if (mapsize > MAPSIZE) mapsize = (mapsize > n && n > 0) ? n : MAPSIZE;
+ if (mapsize >= BUFSIZ * 2 && (mapbuf = (char*)mmap(NiL, mapsize, PROT_READ, MAP_SHARED, rfd, pos)) != ((caddr_t)-1))
+ {
+ if (write(wfd, mapbuf, mapsize) != mapsize || lseek(rfd, mapsize, 1) == ((off_t)-1)) return(-1);
+ munmap((caddr_t)mapbuf, mapsize);
+ return(mapsize);
+ }
+ }
+#endif
+ if (n <= 0) n = BUFSIZ;
+ }
+ if (n > bufsiz)
+ {
+ if (buf) free(buf);
+ bufsiz = roundof(n, BUFSIZ);
+ if (!(buf = newof(0, char, bufsiz, 0))) return(-1);
+ }
+ if ((c = read(rfd, buf, (size_t)n)) > 0 && write(wfd, buf, (size_t)c) != c) c = -1;
+ return(c);
+}
diff --git a/usr/src/lib/libast/common/port/astdynamic.c b/usr/src/lib/libast/common/port/astdynamic.c
new file mode 100644
index 0000000000..9e69dc1f9c
--- /dev/null
+++ b/usr/src/lib/libast/common/port/astdynamic.c
@@ -0,0 +1,132 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * ast dynamic data initialization
+ */
+
+#ifdef _UWIN
+
+#define _std_def_cfree 1
+
+#include <sfio_t.h>
+#include <ast.h>
+
+#undef strcoll
+
+#include <ast_windows.h>
+
+extern Sfio_t _Sfstdin;
+extern Sfio_t _Sfstdout;
+extern Sfio_t _Sfstderr;
+
+#include "sfhdr.h"
+
+#undef sfstdin
+#undef sfstdout
+#undef sfstderr
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+/*
+ * for backward compatibility with early UNIX
+ */
+
+extern void
+cfree(void* addr)
+{
+ free(addr);
+}
+
+extern void
+_ast_libinit(void* in, void* out, void* err)
+{
+ Sfio_t* sp;
+
+ sp = (Sfio_t*)in;
+ *sp = _Sfstdin;
+ sfstdin = sp;
+ sp = (Sfio_t*)out;
+ *sp = _Sfstdout;
+ sfstdout = sp;
+ sp = (Sfio_t*)err;
+ *sp = _Sfstderr;
+ sfstderr = sp;
+}
+
+extern void
+_ast_init(void)
+{
+ struct _astdll* ap = _ast_getdll();
+
+ _ast_libinit(ap->_ast_stdin,ap->_ast_stdout,ap->_ast_stderr);
+}
+
+extern void
+_ast_exit(void)
+{
+ if (_Sfcleanup)
+ (*_Sfcleanup)();
+}
+
+BOOL WINAPI
+DllMain(HINSTANCE hinst, DWORD reason, VOID* reserved)
+{
+ switch (reason)
+ {
+ case DLL_PROCESS_ATTACH:
+ break;
+ case DLL_PROCESS_DETACH:
+ _ast_exit();
+ break;
+ }
+ return 1;
+}
+
+#else
+
+#include <ast.h>
+
+#if _dll_data_intercept && ( _DLL_BLD || _BLD_DLL )
+
+#undef environ
+
+extern char** environ;
+
+struct _astdll _ast_dll = { &environ };
+
+struct _astdll*
+_ast_getdll(void)
+{
+ return &_ast_dll;
+}
+
+#else
+
+NoN(astdynamic)
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/port/astlicense.c b/usr/src/lib/libast/common/port/astlicense.c
new file mode 100644
index 0000000000..e5bab4d8c4
--- /dev/null
+++ b/usr/src/lib/libast/common/port/astlicense.c
@@ -0,0 +1,1147 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * generate a license comment -- see proto(1)
+ *
+ * NOTE: coded for minimal library dependence
+ * not so for the legal department
+ */
+
+#ifndef _PPLIB_H
+#include <ast.h>
+#include <time.h>
+#endif
+
+#undef copy
+#undef BSD /* guess who defines this */
+#undef END
+#undef INLINE
+#undef TEST
+#undef VERBOSE
+
+#define NONE 0
+#define INLINE 1
+#define TEST 2
+#define VERBOSE 3
+#define USAGE 4
+#define OPEN 5
+#define CPL 6
+#define BSD 7
+#define ZLIB 8
+#define MIT 9
+#define GPL 10
+#define SPECIAL 11
+#define NONEXCLUSIVE 12
+#define NONCOMMERCIAL 13
+#define PROPRIETARY 14
+
+#define AUTHOR 0
+#define CLASS 1
+#define COMPANY 2
+#define CONTRIBUTOR 3
+#define CORPORATION 4
+#define DOMAIN 5
+#define INCORPORATION 6
+#define LICENSE 7
+#define LOCATION 8
+#define NOTICE 9
+#define ORGANIZATION 10
+#define PACKAGE 11
+#define PARENT 12
+#define QUERY 13
+#define SINCE 14
+#define STYLE 15
+#define URL 16
+#define URLMD5 17
+#define VERSION 18
+
+#define IDS 64
+
+#define COMDATA 70
+#define COMLINE (COMDATA+4)
+#define COMLONG (COMDATA-32)
+#define COMMENT(x,b,s,u) comment(x,b,s,sizeof(s)-1,u)
+
+#define PUT(b,c) (((b)->nxt<(b)->end)?(*(b)->nxt++=(c)):((c),(-1)))
+#define BUF(b) ((b)->buf)
+#define USE(b) ((b)->siz=(b)->nxt-(b)->buf,(b)->nxt=(b)->buf,(b)->siz)
+#define SIZ(b) ((b)->nxt-(b)->buf)
+#define END(b) (*((b)->nxt>=(b)->end?((b)->nxt=(b)->end-1):(b)->nxt)=0,(b)->nxt-(b)->buf)
+
+#ifndef NiL
+#define NiL ((char*)0)
+#endif
+
+typedef struct Buffer_s
+{
+ char* buf;
+ char* nxt;
+ char* end;
+ int siz;
+} Buffer_t;
+
+typedef struct Item_s
+{
+ char* data;
+ int size;
+ int quote;
+} Item_t;
+
+typedef struct Id_s
+{
+ Item_t name;
+ Item_t value;
+} Id_t;
+
+/*
+ * NOTE: key[] element order must match the corresponding macro
+ */
+
+#define KEY(s) {s,sizeof(s)-1,0}
+
+static const Item_t key[] =
+{
+ KEY("author"),
+ KEY("class"),
+ KEY("company"),
+ KEY("contributor"),
+ KEY("corporation"),
+ KEY("domain"),
+ KEY("incorporation"),
+ KEY("license"),
+ KEY("location"),
+ KEY("notice"),
+ KEY("organization"),
+ KEY("package"),
+ KEY("parent"),
+ KEY("query"),
+ KEY("since"),
+ KEY("type"),
+ KEY("url"),
+ KEY("urlmd5"),
+ KEY("version"),
+ {0}
+};
+
+#define ITEMS (sizeof(key)/sizeof(key[0])-1)
+
+#define LIC(s,c) {s,sizeof(s)-1,c}
+
+static const Item_t lic[] =
+{
+ LIC("none", NONE),
+ LIC("inline", SPECIAL),
+ LIC("test", TEST),
+ LIC("verbose", VERBOSE),
+ LIC("usage", USAGE),
+ LIC("open", OPEN),
+ LIC("cpl", OPEN),
+ LIC("bsd", OPEN),
+ LIC("zlib", OPEN),
+ LIC("mit", OPEN),
+ LIC("gpl", GPL),
+ LIC("special", SPECIAL),
+ LIC("nonexclusive", SPECIAL),
+ LIC("noncommercial", SPECIAL),
+ LIC("proprietary", PROPRIETARY),
+ {0}
+};
+
+typedef struct Notice_s
+{
+ int test;
+ int type;
+ int verbose;
+ int ids;
+ Item_t item[ITEMS];
+ Id_t id[IDS];
+ char cc[3];
+} Notice_t;
+
+/*
+ * return index given <name,size>
+ */
+
+static int
+lookup(register const Item_t* item, const char* name, int size)
+{
+ register int c;
+ register int i;
+
+ c = name[0];
+ for (i = 0; item[i].data; i++)
+ if (c == item[i].data[0] && size == item[i].size && !strncmp(name, item[i].data, size))
+ return i;
+ return -1;
+}
+
+/*
+ * copy s of size n to b
+ * n<0 means 0 terminated string
+ */
+
+static void
+copy(register Buffer_t* b, register char* s, int n)
+{
+ if (n < 0)
+ n = strlen(s);
+ while (n--)
+ PUT(b, *s++);
+}
+
+/*
+ * center and copy comment line s to p
+ * if s==0 then
+ * n>0 first frame line
+ * n=0 blank line
+ * n<0 last frame line
+ * if u>0 then s converted to upper case
+ * if u<0 then s is left justified
+ */
+
+static void
+comment(Notice_t* notice, register Buffer_t* b, register char* s, register int n, int u)
+{
+ register int i;
+ register int m;
+ register int x;
+ int cc;
+
+ cc = notice->cc[1];
+ if (!s)
+ {
+ if (n)
+ {
+ PUT(b, notice->cc[n > 0 ? 0 : 1]);
+ for (i = 0; i < COMDATA; i++)
+ PUT(b, cc);
+ PUT(b, notice->cc[n > 0 ? 1 : 2]);
+ }
+ else
+ s = "";
+ }
+ if (s)
+ {
+ if (n > COMDATA)
+ n = COMDATA;
+ PUT(b, cc);
+ m = (u < 0) ? 1 : (COMDATA - n) / 2;
+ if ((x = COMDATA - m - n) < 0)
+ n--;
+ while (m-- > 0)
+ PUT(b, ' ');
+ while (n-- > 0)
+ {
+ i = *s++;
+ if (u > 0 && i >= 'a' && i <= 'z')
+ i = i - 'a' + 'A';
+ PUT(b, i);
+ }
+ while (x-- > 0)
+ PUT(b, ' ');
+ PUT(b, cc);
+ }
+ PUT(b, '\n');
+}
+
+/*
+ * expand simple ${...}
+ */
+
+static void
+expand(Notice_t* notice, register Buffer_t* b, const Item_t* item)
+{
+ register char* t;
+ register char* e;
+ register int q;
+ register char* x;
+ register char* z;
+ register int c;
+
+ if (t = item->data)
+ {
+ q = item->quote;
+ e = t + item->size;
+ while (t < e)
+ {
+ if (*t == '$' && t < (e + 2) && *(t + 1) == '{')
+ {
+ x = t += 2;
+ while (t < e && (c = *t++) != '}')
+ if (c == '.')
+ x = t;
+ if ((c = lookup(key, x, t - x - 1)) >= 0 && (x = notice->item[c].data))
+ {
+ z = x + notice->item[c].size;
+ while (x < z)
+ PUT(b, *x++);
+ }
+ }
+ else if (q > 0 && *t == '\\' && (*(t + 1) == q || *(t + 1) == '\\'))
+ t++;
+ else
+ PUT(b, *t++);
+ }
+ }
+}
+
+/*
+ * generate a copright notice
+ */
+
+static void
+copyright(Notice_t* notice, register Buffer_t* b)
+{
+ register char* x;
+ register char* t;
+ time_t clock;
+
+ copy(b, "Copyright (c) ", -1);
+ if (notice->test)
+ clock = (time_t)1000212300;
+ else
+ time(&clock);
+ t = ctime(&clock) + 20;
+ if ((x = notice->item[SINCE].data) && strncmp(x, t, 4))
+ {
+ expand(notice, b, &notice->item[SINCE]);
+ PUT(b, '-');
+ }
+ copy(b, t, 4);
+ if (notice->item[PARENT].data)
+ {
+ PUT(b, ' ');
+ expand(notice, b, &notice->item[PARENT]);
+ }
+ if (notice->item[CORPORATION].data)
+ {
+ PUT(b, ' ');
+ expand(notice, b, &notice->item[CORPORATION]);
+ if (notice->item[INCORPORATION].data)
+ {
+ PUT(b, ' ');
+ expand(notice, b, &notice->item[INCORPORATION]);
+ }
+ }
+ else if (notice->item[COMPANY].data)
+ {
+ PUT(b, ' ');
+ expand(notice, b, &notice->item[COMPANY]);
+ }
+}
+
+/*
+ * read the license file and generate a comment in p, length size
+ * license length in p returned, -1 on error
+ * -1 return places 0 terminated error string in p
+ */
+
+int
+astlicense(char* p, int size, char* file, char* options, int cc1, int cc2, int cc3)
+{
+ register char* s;
+ register char* v;
+ register char* x;
+ register int c;
+ int i;
+ int h;
+ int k;
+ int n;
+ int q;
+ int contributor;
+ int first;
+ int line;
+ int quote;
+ char tmpbuf[COMLINE];
+ char info[8 * 1024];
+ Notice_t notice;
+ Item_t item;
+ Buffer_t buf;
+ Buffer_t tmp;
+
+ buf.end = (buf.buf = buf.nxt = p) + size;
+ tmp.end = (tmp.buf = tmp.nxt = tmpbuf) + sizeof(tmpbuf);
+ if (file && *file)
+ {
+ if ((i = open(file, O_RDONLY)) < 0)
+ {
+ copy(&buf, file, -1);
+ copy(&buf, ": cannot open", -1);
+ PUT(&buf, 0);
+ return -1;
+ }
+ n = read(i, info, sizeof(info) - 1);
+ close(i);
+ if (n < 0)
+ {
+ copy(&buf, file, -1);
+ copy(&buf, ": cannot read", -1);
+ PUT(&buf, 0);
+ return -1;
+ }
+ s = info;
+ s[n] = 0;
+ }
+ else if (!options)
+ return 0;
+ else
+ {
+ s = options;
+ options = 0;
+ }
+ notice.test = 0;
+ notice.type = NONE;
+ notice.verbose = 0;
+ notice.ids = 0;
+ notice.cc[0] = cc1;
+ notice.cc[1] = cc2;
+ notice.cc[2] = cc3;
+ for (i = 0; i < ITEMS; i++)
+ notice.item[i].data = 0;
+ notice.item[STYLE] = notice.item[CLASS] = lic[notice.type];
+ notice.item[STYLE].quote = notice.item[CLASS].quote = 0;
+ contributor = i = k = 0;
+ line = 0;
+ for (;;)
+ {
+ for (first = 1; c = *s; first = 0)
+ {
+ while (c == ' ' || c == '\t' || c == '\n' && ++line || c == '\r' || c == ',' || c == ';' || c == ')')
+ c = *++s;
+ if (!c)
+ break;
+ if (c == '#')
+ {
+ while (*++s && *s != '\n');
+ if (*s)
+ s++;
+ line++;
+ continue;
+ }
+ if (c == '\n')
+ {
+ s++;
+ line++;
+ continue;
+ }
+ if (c == '[')
+ c = *++s;
+ x = s;
+ n = 0;
+ while (c && c != '=' && c != ']' && c != ')' && c != ',' && c != ' ' && c != '\t' && c != '\n' && c != '\r')
+ c = *++s;
+ n = s - x;
+ h = lookup(key, x, n);
+ if (c == ']')
+ c = *++s;
+ if (c == '=' || first)
+ {
+ if (c == '=')
+ {
+ q = ((c = *++s) == '"' || c == '\'') ? *s++ : 0;
+ if (c == '(')
+ {
+ s++;
+ if (h == LICENSE)
+ contributor = 0;
+ else if (h == CONTRIBUTOR)
+ contributor = 1;
+ else
+ {
+ q = 1;
+ i = 0;
+ for (;;)
+ {
+ switch (*s++)
+ {
+ case 0:
+ s--;
+ break;
+ case '(':
+ if (!i)
+ q++;
+ continue;
+ case ')':
+ if (!i && !--q)
+ break;
+ continue;
+ case '"':
+ case '\'':
+ if (!i)
+ i = *(s - 1);
+ else if (i == *(s - 1))
+ i = 0;
+ continue;
+ case '\\':
+ if (*s == i && i == '"')
+ i++;
+ continue;
+ case '\n':
+ line++;
+ continue;
+ default:
+ continue;
+ }
+ break;
+ }
+ }
+ continue;
+ }
+ quote = 0;
+ v = s;
+ while ((c = *s) && (q == '"' && (c == '\\' && (*(s + 1) == '"' || *(s + 1) == '\\') && s++ && (quote = q)) || q && c != q || !q && c != ' ' && c != '\t' && c != '\n' && c != '\r' && c != ',' && c != ';'))
+ {
+ if (c == '\n')
+ line++;
+ s++;
+ }
+ }
+ else
+ {
+ h = STYLE;
+ v = x;
+ }
+ if (c == '\n')
+ line++;
+ if (contributor)
+ {
+ for (i = 0; i < notice.ids; i++)
+ if (n == notice.id[i].name.size && !strncmp(x, notice.id[i].name.data, n))
+ break;
+ if (i < IDS)
+ {
+ notice.id[i].name.data = x;
+ notice.id[i].name.size = n;
+ notice.id[i].name.quote = 0;
+ notice.id[i].value.data = v;
+ notice.id[i].value.size = s - v;
+ notice.id[i].value.quote = quote;
+ if (notice.ids <= i)
+ notice.ids = i + 1;
+ }
+ }
+ else if (h == QUERY)
+ {
+ if ((s - v) == 3 && v[0] == 'a' && v[1] == 'l' && v[2] == 'l')
+ {
+ for (i = 0; i < ITEMS; i++)
+ if (notice.item[i].size)
+ {
+ expand(&notice, &buf, &key[i]);
+ PUT(&buf, '=');
+ for (h = 0;; h++)
+ if (h >= notice.item[i].size)
+ {
+ h = 0;
+ break;
+ }
+ else if (notice.item[i].data[h] == ' ' || notice.item[i].data[h] == '\t')
+ break;
+ if (h)
+ PUT(&buf, '\'');
+ expand(&notice, &buf, &notice.item[i]);
+ if (h)
+ PUT(&buf, '\'');
+ PUT(&buf, '\n');
+ }
+ }
+ else
+ {
+ if ((h = lookup(key, v, s - v)) < 0)
+ {
+ item.data = v;
+ item.size = s - v;
+ item.quote = 0;
+ expand(&notice, &buf, &item);
+ }
+ else
+ expand(&notice, &buf, &notice.item[h]);
+ PUT(&buf, '\n');
+ }
+ return END(&buf);
+ }
+ else
+ {
+ if (h == STYLE)
+ switch (c = lookup(lic, v, s - v))
+ {
+ case NONE:
+ return 0;
+ case TEST:
+ notice.test = 1;
+ h = -1;
+ break;
+ case VERBOSE:
+ notice.verbose = 1;
+ h = -1;
+ break;
+ case USAGE:
+ notice.type = c;
+ h = -1;
+ break;
+ case -1:
+ c = SPECIAL;
+ /*FALLTHROUGH*/
+ default:
+ notice.type = c;
+ notice.item[CLASS].data = lic[lic[c].quote].data;
+ notice.item[CLASS].size = lic[lic[c].quote].size;
+ break;
+ }
+ if (h >= 0)
+ {
+ notice.item[h].data = (notice.item[h].size = s - v) ? v : (char*)0;
+ notice.item[h].quote = quote;
+ k = 1;
+ }
+ }
+ }
+ else
+ {
+ if (file)
+ {
+ copy(&buf, "\"", -1);
+ copy(&buf, file, -1);
+ copy(&buf, "\", line ", -1);
+ x = &tmpbuf[sizeof(tmpbuf)];
+ *--x = 0;
+ line++;
+ do *--x = ("0123456789")[line % 10]; while (line /= 10);
+ copy(&buf, x, -1);
+ copy(&buf, ": ", -1);
+ }
+ copy(&buf, "option error: assignment expected", -1);
+ PUT(&buf, 0);
+ return -1;
+ }
+ if (*s)
+ s++;
+ }
+ if (!options || !*(s = options))
+ break;
+ options = 0;
+ }
+ if (!k)
+ return 0;
+ if (notice.type == INLINE && (!notice.verbose || !notice.item[NOTICE].data))
+ return 0;
+ if (notice.type != USAGE)
+ {
+ if (!notice.type)
+ notice.type = SPECIAL;
+ comment(&notice, &buf, NiL, 1, 0);
+ comment(&notice, &buf, NiL, 0, 0);
+ if (notice.item[PACKAGE].data)
+ {
+ copy(&tmp, "This software is part of the ", -1);
+ expand(&notice, &tmp, &notice.item[PACKAGE]);
+ copy(&tmp, " package", -1);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ }
+ if (notice.type >= OPEN)
+ {
+ copyright(&notice, &tmp);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ if (notice.type >= SPECIAL)
+ COMMENT(&notice, &buf, "All Rights Reserved", 0);
+ }
+ if (notice.type == CPL)
+ {
+ copy(&tmp, notice.item[PACKAGE].data ? "and" : "This software", -1);
+ copy(&tmp, " is licensed under the", -1);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ copy(&tmp, "Common Public License", -1);
+ if (notice.item[VERSION].data)
+ {
+ copy(&tmp, ", Version ", -1);
+ expand(&notice, &tmp, &notice.item[VERSION]);
+ }
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ if (notice.item[CORPORATION].data || notice.item[COMPANY].data)
+ {
+ copy(&tmp, "by ", -1);
+ if (notice.item[PARENT].data)
+ {
+ expand(&notice, &tmp, &notice.item[PARENT]);
+ copy(&tmp, " ", -1);
+ }
+ if (notice.item[CORPORATION].data)
+ {
+ expand(&notice, &tmp, &notice.item[CORPORATION]);
+ if (notice.item[INCORPORATION].data)
+ {
+ copy(&tmp, " ", -1);
+ expand(&notice, &tmp, &notice.item[INCORPORATION]);
+ }
+ }
+ else if (notice.item[COMPANY].data)
+ expand(&notice, &tmp, &notice.item[COMPANY]);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ }
+ comment(&notice, &buf, NiL, 0, 0);
+ COMMENT(&notice, &buf, "A copy of the License is available at", 0);
+ if (notice.item[URL].data)
+ {
+ expand(&notice, &tmp, &notice.item[URL]);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ if (notice.item[URLMD5].data)
+ {
+ copy(&tmp, "(with md5 checksum ", -1);
+ expand(&notice, &tmp, &notice.item[URLMD5]);
+ copy(&tmp, ")", -1);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ }
+ }
+ else
+ COMMENT(&notice, &buf, "http://www.opensource.org/licenses/cpl", 0);
+ comment(&notice, &buf, NiL, 0, 0);
+ }
+ else if (notice.type == OPEN)
+ {
+ copy(&tmp, notice.item[PACKAGE].data ? "and it" : "This software", -1);
+ copy(&tmp, " may only be used by you under license from", -1);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ if (notice.item[i = CORPORATION].data)
+ {
+ if (notice.item[PARENT].data)
+ {
+ expand(&notice, &tmp, &notice.item[i = PARENT]);
+ copy(&tmp, " ", -1);
+ }
+ expand(&notice, &tmp, &notice.item[CORPORATION]);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ }
+ else if (notice.item[i = COMPANY].data)
+ {
+ if (notice.item[PARENT].data)
+ {
+ expand(&notice, &tmp, &notice.item[i = PARENT]);
+ copy(&tmp, " ", -1);
+ }
+ expand(&notice, &tmp, &notice.item[COMPANY]);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ }
+ else
+ i = -1;
+ if (notice.item[URL].data)
+ {
+ COMMENT(&notice, &buf, "A copy of the Source Code Agreement is available", 0);
+ copy(&tmp, "at the ", -1);
+ if (i >= 0)
+ expand(&notice, &tmp, &notice.item[i]);
+ copy(&tmp, " Internet web site URL", -1);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ comment(&notice, &buf, NiL, 0, 0);
+ expand(&notice, &tmp, &notice.item[URL]);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ if (notice.item[URLMD5].data)
+ {
+ copy(&tmp, "(with an md5 checksum of ", -1);
+ expand(&notice, &tmp, &notice.item[URLMD5]);
+ copy(&tmp, ")", -1);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ }
+ comment(&notice, &buf, NiL, 0, 0);
+ }
+ COMMENT(&notice, &buf, "If you have copied or used this software without agreeing", 0);
+ COMMENT(&notice, &buf, "to the terms of the license you are infringing on", 0);
+ COMMENT(&notice, &buf, "the license and copyright and are violating", 0);
+ if (i >= 0)
+ expand(&notice, &tmp, &notice.item[i]);
+ copy(&tmp, "'s", -1);
+ if (n >= COMLONG)
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ else
+ PUT(&tmp, ' ');
+ copy(&tmp, "intellectual property rights.", -1);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ comment(&notice, &buf, NiL, 0, 0);
+ }
+ else if (notice.type == GPL)
+ {
+ comment(&notice, &buf, NiL, 0, 0);
+ COMMENT(&notice, &buf, "This is free software; you can redistribute it and/or", 0);
+ COMMENT(&notice, &buf, "modify it under the terms of the GNU General Public License", 0);
+ COMMENT(&notice, &buf, "as published by the Free Software Foundation;", 0);
+ COMMENT(&notice, &buf, "either version 2, or (at your option) any later version.", 0);
+ comment(&notice, &buf, NiL, 0, 0);
+ COMMENT(&notice, &buf, "This software is distributed in the hope that it", 0);
+ COMMENT(&notice, &buf, "will be useful, but WITHOUT ANY WARRANTY;", 0);
+ COMMENT(&notice, &buf, "without even the implied warranty of MERCHANTABILITY", 0);
+ COMMENT(&notice, &buf, "or FITNESS FOR A PARTICULAR PURPOSE.", 0);
+ COMMENT(&notice, &buf, "See the GNU General Public License for more details.", 0);
+ comment(&notice, &buf, NiL, 0, 0);
+ COMMENT(&notice, &buf, "You should have received a copy of the", 0);
+ COMMENT(&notice, &buf, "GNU General Public License", 0);
+ COMMENT(&notice, &buf, "along with this software (see the file COPYING.)", 0);
+ COMMENT(&notice, &buf, "If not, a copy is available at", 0);
+ COMMENT(&notice, &buf, "http://www.gnu.org/copyleft/gpl.html", 0);
+ comment(&notice, &buf, NiL, 0, 0);
+ }
+ else if (notice.type == BSD)
+ {
+ comment(&notice, &buf, NiL, 0, 0);
+ COMMENT(&notice, &buf, "Redistribution and use in source and binary forms, with or", -1);
+ COMMENT(&notice, &buf, "without modification, are permitted provided that the following", -1);
+ COMMENT(&notice, &buf, "conditions are met:", -1);
+ comment(&notice, &buf, NiL, 0, 0);
+ COMMENT(&notice, &buf, " 1. Redistributions of source code must retain the above", -1);
+ COMMENT(&notice, &buf, " copyright notice, this list of conditions and the", -1);
+ COMMENT(&notice, &buf, " following disclaimer.", -1);
+ comment(&notice, &buf, NiL, 0, 0);
+ COMMENT(&notice, &buf, " 2. Redistributions in binary form must reproduce the above", -1);
+ COMMENT(&notice, &buf, " copyright notice, this list of conditions and the", -1);
+ COMMENT(&notice, &buf, " following disclaimer in the documentation and/or other", -1);
+ COMMENT(&notice, &buf, " materials provided with the distribution.", -1);
+ comment(&notice, &buf, NiL, 0, 0);
+ copy(&tmp, " 3. Neither the name of ", -1);
+ if (notice.item[i = PARENT].data || notice.item[i = CORPORATION].data || notice.item[i = COMPANY].data)
+ expand(&notice, &tmp, &notice.item[i]);
+ else
+ copy(&tmp, "the copyright holder", -1);
+ copy(&tmp, " nor the", -1);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), -1);
+ COMMENT(&notice, &buf, " names of its contributors may be used to endorse or", -1);
+ COMMENT(&notice, &buf, " promote products derived from this software without", -1);
+ COMMENT(&notice, &buf, " specific prior written permission.", -1);
+ comment(&notice, &buf, NiL, 0, 0);
+ COMMENT(&notice, &buf, "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND", -1);
+ COMMENT(&notice, &buf, "CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES,", -1);
+ COMMENT(&notice, &buf, "INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF", -1);
+ COMMENT(&notice, &buf, "MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE", -1);
+ COMMENT(&notice, &buf, "DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS", -1);
+ COMMENT(&notice, &buf, "BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,", -1);
+ COMMENT(&notice, &buf, "EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED", -1);
+ COMMENT(&notice, &buf, "TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,", -1);
+ COMMENT(&notice, &buf, "DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON", -1);
+ COMMENT(&notice, &buf, "ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,", -1);
+ COMMENT(&notice, &buf, "OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY", -1);
+ COMMENT(&notice, &buf, "OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE", -1);
+ COMMENT(&notice, &buf, "POSSIBILITY OF SUCH DAMAGE.", -1);
+ comment(&notice, &buf, NiL, 0, 0);
+ }
+ else if (notice.type == ZLIB)
+ {
+ comment(&notice, &buf, NiL, 0, 0);
+ COMMENT(&notice, &buf, "This software is provided 'as-is', without any express or implied", -1);
+ COMMENT(&notice, &buf, "warranty. In no event will the authors be held liable for any", -1);
+ COMMENT(&notice, &buf, "damages arising from the use of this software.", -1);
+ comment(&notice, &buf, NiL, 0, 0);
+ COMMENT(&notice, &buf, "Permission is granted to anyone to use this software for any", -1);
+ COMMENT(&notice, &buf, "purpose, including commercial applications, and to alter it and", -1);
+ COMMENT(&notice, &buf, "redistribute it freely, subject to the following restrictions:", -1);
+ comment(&notice, &buf, NiL, 0, 0);
+ COMMENT(&notice, &buf, " 1. The origin of this software must not be misrepresented;", -1);
+ COMMENT(&notice, &buf, " you must not claim that you wrote the original software. If", -1);
+ COMMENT(&notice, &buf, " you use this software in a product, an acknowledgment in the", -1);
+ COMMENT(&notice, &buf, " product documentation would be appreciated but is not", -1);
+ COMMENT(&notice, &buf, " required.", -1);
+ comment(&notice, &buf, NiL, 0, 0);
+ COMMENT(&notice, &buf, " 2. Altered source versions must be plainly marked as such,", -1);
+ COMMENT(&notice, &buf, " and must not be misrepresented as being the original", -1);
+ COMMENT(&notice, &buf, " software.", -1);
+ comment(&notice, &buf, NiL, 0, 0);
+ COMMENT(&notice, &buf, " 3. This notice may not be removed or altered from any source", -1);
+ COMMENT(&notice, &buf, " distribution.", -1);
+ comment(&notice, &buf, NiL, 0, 0);
+ }
+ else if (notice.type == MIT)
+ {
+ comment(&notice, &buf, NiL, 0, 0);
+ COMMENT(&notice, &buf, "Permission is hereby granted, free of charge, to any person", 0);
+ COMMENT(&notice, &buf, "obtaining a copy of this software and associated", 0);
+ COMMENT(&notice, &buf, "documentation files (the \"Software\"), to deal in the", 0);
+ COMMENT(&notice, &buf, "Software without restriction, including without limitation", 0);
+ COMMENT(&notice, &buf, "the rights to use, copy, modify, merge, publish, distribute,", 0);
+ COMMENT(&notice, &buf, "sublicense, and/or sell copies of the Software, and to", 0);
+ COMMENT(&notice, &buf, "permit persons to whom the Software is furnished to do so,", 0);
+ COMMENT(&notice, &buf, "subject to the following conditions:", 0);
+ comment(&notice, &buf, NiL, 0, 0);
+ COMMENT(&notice, &buf, "The above copyright notice and this permission notice shall", 0);
+ COMMENT(&notice, &buf, "be included in all copies or substantial portions of the", 0);
+ COMMENT(&notice, &buf, "Software.", 0);
+ comment(&notice, &buf, NiL, 0, 0);
+ COMMENT(&notice, &buf, "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY", 0);
+ COMMENT(&notice, &buf, "KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE", 0);
+ COMMENT(&notice, &buf, "WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR", 0);
+ COMMENT(&notice, &buf, "PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS", 0);
+ COMMENT(&notice, &buf, "OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR", 0);
+ COMMENT(&notice, &buf, "OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR", 0);
+ COMMENT(&notice, &buf, "OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE", 0);
+ COMMENT(&notice, &buf, "SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", 0);
+ comment(&notice, &buf, NiL, 0, 0);
+ }
+ else
+ {
+ if (notice.type == PROPRIETARY)
+ {
+ if (notice.item[i = PARENT].data || notice.item[i = CORPORATION].data || notice.item[i = COMPANY].data)
+ {
+ expand(&notice, &tmp, &notice.item[i]);
+ copy(&tmp, " - ", -1);
+ }
+ else
+ i = -1;
+ copy(&tmp, "Proprietary", -1);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 1);
+ comment(&notice, &buf, NiL, 0, 0);
+ if (notice.item[URL].data)
+ {
+ copy(&tmp, "This is proprietary source code", -1);
+ if (i >= 0)
+ copy(&tmp, " licensed by", -1);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 1);
+ if (notice.item[PARENT].data)
+ {
+ expand(&notice, &tmp, &notice.item[PARENT]);
+ copy(&tmp, " ", -1);
+ }
+ if (notice.item[CORPORATION].data)
+ {
+ expand(&notice, &tmp, &notice.item[CORPORATION]);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 1);
+ }
+ else if (notice.item[COMPANY].data)
+ {
+ expand(&notice, &tmp, &notice.item[COMPANY]);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 1);
+ }
+ }
+ else
+ {
+ copy(&tmp, "This is unpublished proprietary source code", -1);
+ if (i >= 0)
+ copy(&tmp, " of", -1);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 1);
+ if (notice.item[i = PARENT].data || notice.item[i = CORPORATION].data)
+ expand(&notice, &tmp, &notice.item[i]);
+ if (notice.item[COMPANY].data)
+ {
+ if (SIZ(&tmp))
+ PUT(&tmp, ' ');
+ expand(&notice, &tmp, &notice.item[COMPANY]);
+ }
+ if (SIZ(&tmp))
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 1);
+ COMMENT(&notice, &buf, "and is not to be disclosed or used except in", 1);
+ COMMENT(&notice, &buf, "accordance with applicable agreements", 1);
+ }
+ comment(&notice, &buf, NiL, 0, 0);
+ }
+ else if (notice.type == NONEXCLUSIVE)
+ {
+ COMMENT(&notice, &buf, "For nonexclusive individual use", 1);
+ comment(&notice, &buf, NiL, 0, 0);
+ }
+ else if (notice.type == NONCOMMERCIAL)
+ {
+ COMMENT(&notice, &buf, "For noncommercial use", 1);
+ comment(&notice, &buf, NiL, 0, 0);
+ }
+ if (notice.type >= PROPRIETARY && !notice.item[URL].data)
+ {
+ COMMENT(&notice, &buf, "Unpublished & Not for Publication", 0);
+ comment(&notice, &buf, NiL, 0, 0);
+ }
+ if (notice.item[URL].data)
+ {
+ copy(&tmp, "This software is licensed", -1);
+ if (notice.item[CORPORATION].data || notice.item[COMPANY].data)
+ {
+ copy(&tmp, " by", -1);
+ if ((notice.item[PARENT].size + (notice.item[CORPORATION].data ? (notice.item[CORPORATION].size + notice.item[INCORPORATION].size) : notice.item[COMPANY].size)) >= (COMLONG - 6))
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ else
+ PUT(&tmp, ' ');
+ if (notice.item[PARENT].data)
+ {
+ expand(&notice, &tmp, &notice.item[PARENT]);
+ copy(&tmp, " ", -1);
+ }
+ if (notice.item[CORPORATION].data)
+ {
+ expand(&notice, &tmp, &notice.item[CORPORATION]);
+ if (notice.item[INCORPORATION].data)
+ {
+ copy(&tmp, " ", -1);
+ expand(&notice, &tmp, &notice.item[INCORPORATION]);
+ }
+ }
+ else if (notice.item[COMPANY].data)
+ expand(&notice, &tmp, &notice.item[COMPANY]);
+ }
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ COMMENT(&notice, &buf, "under the terms and conditions of the license in", 0);
+ expand(&notice, &tmp, &notice.item[URL]);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ if (notice.item[URLMD5].data)
+ {
+ copy(&tmp, "(with an md5 checksum of ", -1);
+ expand(&notice, &tmp, &notice.item[URLMD5]);
+ copy(&tmp, ")", -1);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ }
+ comment(&notice, &buf, NiL, 0, 0);
+ }
+ else if (notice.type == PROPRIETARY)
+ {
+ COMMENT(&notice, &buf, "The copyright notice above does not evidence any", 0);
+ COMMENT(&notice, &buf, "actual or intended publication of such source code", 0);
+ comment(&notice, &buf, NiL, 0, 0);
+ }
+ }
+ if (v = notice.item[NOTICE].data)
+ {
+ x = v + notice.item[NOTICE].size;
+ if (*v == '\n')
+ v++;
+ item.quote = notice.item[NOTICE].quote;
+ do
+ {
+ for (item.data = v; v < x && *v != '\n'; v++);
+ if ((item.size = v - item.data) && *item.data == '\t')
+ {
+ item.data++;
+ item.size--;
+ h = 0;
+ }
+ else
+ h = -1;
+ expand(&notice, &tmp, &item);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), h);
+ } while (v++ < x);
+ if (item.size)
+ comment(&notice, &buf, NiL, 0, 0);
+ }
+ if (notice.item[ORGANIZATION].data)
+ {
+ expand(&notice, &tmp, &notice.item[ORGANIZATION]);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ if (notice.item[i = PARENT].data || notice.item[i = CORPORATION].data)
+ expand(&notice, &tmp, &notice.item[i]);
+ if (notice.item[COMPANY].data)
+ {
+ if (SIZ(&tmp))
+ PUT(&tmp, ' ');
+ expand(&notice, &tmp, &notice.item[COMPANY]);
+ }
+ if (SIZ(&tmp))
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ if (notice.item[LOCATION].data)
+ {
+ expand(&notice, &tmp, &notice.item[LOCATION]);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ }
+ comment(&notice, &buf, NiL, 0, 0);
+ }
+ }
+ if (v = notice.item[AUTHOR].data)
+ {
+ x = v + notice.item[AUTHOR].size;
+ q = (x - v) == 1 && (*v == '*' || *v == '-');
+ k = q && notice.type != USAGE ? -1 : 0;
+ for (;;)
+ {
+ if (!q)
+ {
+ while (v < x && (*v == ' ' || *v == '\t' || *v == '\r' || *v == '\n' || *v == ',' || *v == '+'))
+ v++;
+ if (v >= x)
+ break;
+ item.data = v;
+ while (v < x && *v != ',' && *v != '+' && *v++ != '>');
+ item.size = v - item.data;
+ item.quote = notice.item[AUTHOR].quote;
+ }
+ h = 0;
+ for (i = 0; i < notice.ids; i++)
+ if (q || item.size == notice.id[i].name.size && !strncmp(item.data, notice.id[i].name.data, item.size))
+ {
+ h = 1;
+ if (notice.type == USAGE)
+ {
+ copy(&buf, "[-author?", -1);
+ expand(&notice, &buf, &notice.id[i].value);
+ PUT(&buf, ']');
+ }
+ else
+ {
+ if (k < 0)
+ {
+ COMMENT(&notice, &buf, "CONTRIBUTORS", 0);
+ comment(&notice, &buf, NiL, 0, 0);
+ }
+ k = 1;
+ expand(&notice, &tmp, &notice.id[i].value);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ }
+ if (!q)
+ break;
+ }
+ if (q)
+ break;
+ if (!h)
+ {
+ if (notice.type == USAGE)
+ {
+ copy(&buf, "[-author?", -1);
+ expand(&notice, &buf, &item);
+ PUT(&buf, ']');
+ }
+ else
+ {
+ if (k < 0)
+ {
+ COMMENT(&notice, &buf, "CONTRIBUTORS", 0);
+ comment(&notice, &buf, NiL, 0, 0);
+ }
+ k = 1;
+ expand(&notice, &tmp, &item);
+ comment(&notice, &buf, BUF(&tmp), USE(&tmp), 0);
+ }
+ }
+ }
+ if (k > 0)
+ comment(&notice, &buf, NiL, 0, 0);
+ }
+ if (notice.type == USAGE)
+ {
+ copy(&buf, "[-copyright?", -1);
+ copyright(&notice, &buf);
+ PUT(&buf, ']');
+ if (notice.item[URL].data)
+ {
+ copy(&buf, "[-license?", -1);
+ expand(&notice, &buf, &notice.item[URL]);
+ PUT(&buf, ']');
+ }
+ PUT(&buf, '\n');
+ }
+ else
+ comment(&notice, &buf, NiL, -1, 0);
+ return END(&buf);
+}
diff --git a/usr/src/lib/libast/common/port/astmath.c b/usr/src/lib/libast/common/port/astmath.c
new file mode 100644
index 0000000000..0722116328
--- /dev/null
+++ b/usr/src/lib/libast/common/port/astmath.c
@@ -0,0 +1,62 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * used to test if -last requires -lm
+ *
+ * arch -last -lm
+ * ---- ----- ---
+ * linux.sparc sfdlen,sfputd frexp,ldexp
+ */
+
+#include <math.h>
+
+int
+main()
+{
+#if N & 1
+ long double value = 0;
+#else
+ double value = 0;
+#endif
+#if N < 5
+ int exp = 0;
+#endif
+
+#if N == 1
+ return ldexpl(value, exp) != 0;
+#endif
+#if N == 2
+ return ldexp(value, exp) != 0;
+#endif
+#if N == 3
+ return frexpl(value, &exp) != 0;
+#endif
+#if N == 4
+ return frexp(value, &exp) != 0;
+#endif
+#if N == 5
+ return isnan(value);
+#endif
+#if N == 6
+ return isnan(value);
+#endif
+}
diff --git a/usr/src/lib/libast/common/port/astquery.c b/usr/src/lib/libast/common/port/astquery.c
new file mode 100644
index 0000000000..540a501ceb
--- /dev/null
+++ b/usr/src/lib/libast/common/port/astquery.c
@@ -0,0 +1,109 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * AT&T Research
+ *
+ * output printf prompt and read response
+ * if format==0 then verify that interaction is possible
+ *
+ * return:
+ *
+ * 0 [1yY+]
+ * -1 [qQ] or EOF
+ * 1 otherwise
+ *
+ * if (quit&ERROR_PROMPT) then tty forced for IO
+ * if quit>=0 then [qQ] or EOF calls exit(quit)
+ */
+
+#include <ast.h>
+#include <error.h>
+
+int
+astquery(int quit, const char* format, ...)
+{
+ va_list ap;
+ register int n;
+ register int c;
+ Sfio_t* ip;
+ Sfio_t* op;
+
+ static Sfio_t* rfp;
+ static Sfio_t* wfp;
+
+ va_start(ap, format);
+ if (!format)
+ return 0;
+ if (!rfp)
+ {
+ c = errno;
+ if (isatty(sffileno(sfstdin)))
+ rfp = sfstdin;
+ else if (!(rfp = sfopen(NiL, "/dev/tty", "r")))
+ return -1;
+ if (isatty(sffileno(sfstderr)))
+ wfp = sfstderr;
+ else if (!(wfp = sfopen(NiL, "/dev/tty", "w")))
+ return -1;
+ errno = c;
+ }
+ if (quit & ERROR_PROMPT)
+ {
+ quit &= ~ERROR_PROMPT;
+ ip = rfp;
+ op = wfp;
+ }
+ else
+ {
+ ip = sfstdin;
+ op = sfstderr;
+ }
+ sfsync(sfstdout);
+ sfvprintf(op, format, ap);
+ sfsync(op);
+ for (n = c = sfgetc(ip);; c = sfgetc(ip))
+ switch (c)
+ {
+ case EOF:
+ n = c;
+ /*FALLTHROUGH*/
+ case '\n':
+ switch (n)
+ {
+ case EOF:
+ case 'q':
+ case 'Q':
+ if (quit >= 0)
+ exit(quit);
+ return -1;
+ case '1':
+ case 'y':
+ case 'Y':
+ case '+':
+ return 0;
+ }
+ return 1;
+ }
+ va_end(ap);
+ /*NOTREACHED*/
+}
diff --git a/usr/src/lib/libast/common/port/aststatic.c b/usr/src/lib/libast/common/port/aststatic.c
new file mode 100644
index 0000000000..8c8975155e
--- /dev/null
+++ b/usr/src/lib/libast/common/port/aststatic.c
@@ -0,0 +1,44 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * ast static data initialization
+ */
+
+#include <ast.h>
+
+#if _dll_data_intercept && ( _DLL_BLD || _BLD_DLL )
+
+void
+_ast_init(void)
+{
+ struct _astdll* ap = _ast_getdll();
+
+ ap->_dll_environ = &environ;
+}
+
+#else
+
+NoN(aststatic)
+
+#endif
diff --git a/usr/src/lib/libast/common/port/astwinsize.c b/usr/src/lib/libast/common/port/astwinsize.c
new file mode 100644
index 0000000000..32d1bfe400
--- /dev/null
+++ b/usr/src/lib/libast/common/port/astwinsize.c
@@ -0,0 +1,143 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * AT&T Research
+ * return terminal rows and cols
+ */
+
+#include <ast.h>
+#include <ast_tty.h>
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide ioctl sleep
+#else
+#define ioctl ______ioctl
+#define sleep ______sleep
+#endif
+
+#if _sys_ioctl
+#include <sys/ioctl.h>
+#endif
+
+#if defined(TIOCGWINSZ)
+#if _sys_stream && _sys_ptem
+#include <sys/stream.h>
+#include <sys/ptem.h>
+#endif
+#else
+#if !defined(TIOCGSIZE) && !defined(TIOCGWINSZ)
+#if _hdr_jioctl
+#define jwinsize winsize
+#include <jioctl.h>
+#else
+#if _sys_jioctl
+#define jwinsize winsize
+#include <sys/jioctl.h>
+#endif
+#endif
+#endif
+#endif
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide ioctl sleep
+#else
+#undef ioctl
+#undef sleep
+#endif
+
+static int ttctl(int, int, void*);
+
+void
+astwinsize(int fd, register int* rows, register int* cols)
+{
+#ifdef TIOCGWINSZ
+#define NEED_ttctl
+ struct winsize ws;
+
+ if (!ttctl(fd, TIOCGWINSZ, &ws) && ws.ws_col > 0 && ws.ws_row > 0)
+ {
+ if (rows) *rows = ws.ws_row;
+ if (cols) *cols = ws.ws_col;
+ }
+ else
+#else
+#ifdef TIOCGSIZE
+#define NEED_ttctl
+ struct ttysize ts;
+
+ if (!ttctl(fd, TIOCGSIZE, &ts) && ts.ts_lines > 0 && ts.ts_cols > 0)
+ {
+ if (rows) *rows = ts.ts_lines;
+ if (cols) *cols = ts.ts_cols;
+ }
+ else
+#else
+#ifdef JWINSIZE
+#define NEED_ttctl
+ struct winsize ws;
+
+ if (!ttctl(fd, JWINSIZE, &ws) && ws.bytesx > 0 && ws.bytesy > 0)
+ {
+ if (rows) *rows = ws.bytesy;
+ if (cols) *cols = ws.bytesx;
+ }
+ else
+#endif
+#endif
+#endif
+ {
+ char* s;
+
+ if (rows) *rows = (s = getenv("LINES")) ? strtol(s, NiL, 0) : 0;
+ if (cols) *cols = (s = getenv("COLUMNS")) ? strtol(s, NiL, 0) : 0;
+ }
+}
+
+#ifdef NEED_ttctl
+
+/*
+ * tty ioctl() -- no cache
+ */
+
+static int
+ttctl(register int fd, int op, void* tt)
+{
+ register int v;
+
+ if (fd < 0)
+ {
+ for (fd = 0; fd <= 2; fd++)
+ if (!ioctl(fd, op, tt)) return(0);
+ if ((fd = open("/dev/tty", O_RDONLY)) >= 0)
+ {
+ v = ioctl(fd, op, tt);
+ close(fd);
+ return(v);
+ }
+ }
+ else if (!ioctl(fd, op, tt)) return(0);
+ return(-1);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/port/iblocks.c b/usr/src/lib/libast/common/port/iblocks.c
new file mode 100644
index 0000000000..7ace66c35a
--- /dev/null
+++ b/usr/src/lib/libast/common/port/iblocks.c
@@ -0,0 +1,95 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * aux function for <ls.h> iblocks() macro
+ *
+ * return number of blocks, including indirect block count
+ * given stat info
+ *
+ * mail gsf@research.att.com when you figure out the stat.st_blocks units
+ * until then we assume LS_BLOCKSIZE (512)
+ */
+
+#include <ast.h>
+#if _AIX /* XXX */
+#undef major
+#undef minor
+#undef makedev
+#endif
+#include <ast_param.h>
+#include <ls.h>
+
+#if !_mem_st_blocks_stat
+
+#ifndef B_DIRECT
+#define B_DIRECT 10
+#endif
+
+#ifdef BITFS
+
+#define B_SIZE BSIZE(st->st_dev)
+#define B_INDIRECT NINDIR(st->st_dev)
+
+#else
+
+#ifdef BSIZE
+#define B_SIZE BSIZE
+#else
+#define B_SIZE 1024
+#endif
+
+#ifdef NINDIR
+#define B_INDIRECT NINDIR
+#else
+#define B_INDIRECT 128
+#endif
+
+#endif
+
+#endif
+
+off_t
+_iblocks(register struct stat* st)
+{
+#if _mem_st_blocks_stat
+
+ return (st->st_blocks <= 0 || st->st_size <= 0) ? 0 : st->st_blocks;
+
+#else
+ unsigned long b;
+ unsigned long t;
+
+ t = b = (st->st_size + B_SIZE - 1) / B_SIZE;
+ if ((b -= B_DIRECT) > 0)
+ {
+ t += (b - 1) / B_INDIRECT + 1;
+ if ((b -= B_INDIRECT) > 0)
+ {
+ t += (b - 1) / (B_INDIRECT * B_INDIRECT) + 1;
+ if (b > B_INDIRECT * B_INDIRECT)
+ t++;
+ }
+ }
+ return t * B_SIZE / LS_BLOCKSIZE;
+#endif
+}
diff --git a/usr/src/lib/libast/common/port/lc.c b/usr/src/lib/libast/common/port/lc.c
new file mode 100644
index 0000000000..e632d00182
--- /dev/null
+++ b/usr/src/lib/libast/common/port/lc.c
@@ -0,0 +1,832 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * locale state implementation
+ */
+
+#include "lclib.h"
+
+#include <ctype.h>
+
+#if _WINIX
+
+#include <ast_windows.h>
+
+#define LANG_CHINESE_SIMPLIFIED LANG_CHINESE
+#define LANG_CHINESE_TRADITIONAL LANG_CHINESE
+#define LANG_NORWEGIAN_BOKMAL LANG_NORWEGIAN
+#define LANG_NORWEGIAN_NYNORSK LANG_NORWEGIAN
+#define LANG_SERBO_CROATIAN LANG_CROATIAN
+
+#define CTRY_CZECH_REPUBLIC CTRY_CZECH
+
+#define SUBLANG_CHINESE_SIMPLIFIED_CHINA SUBLANG_CHINESE_SIMPLIFIED
+#define SUBLANG_CHINESE_SIMPLIFIED_HONG_KONG SUBLANG_CHINESE_HONGKONG
+#define SUBLANG_CHINESE_SIMPLIFIED_SINGAPORE SUBLANG_CHINESE_SINGAPORE
+#define SUBLANG_CHINESE_TRADITIONAL_TAIWAN SUBLANG_CHINESE_TRADITIONAL
+#define SUBLANG_DUTCH_NETHERLANDS_ANTILLES SUBLANG_DUTCH
+#define SUBLANG_DUTCH_BELGIUM SUBLANG_DUTCH_BELGIAN
+#define SUBLANG_ENGLISH_AUSTRALIA SUBLANG_ENGLISH_AUS
+#define SUBLANG_ENGLISH_CANADA SUBLANG_ENGLISH_CAN
+#define SUBLANG_ENGLISH_IRELAND SUBLANG_ENGLISH_EIRE
+#define SUBLANG_ENGLISH_NEW_ZEALAND SUBLANG_ENGLISH_NZ
+#define SUBLANG_ENGLISH_TRINIDAD_TOBAGO SUBLANG_ENGLISH_CARIBBEAN
+#define SUBLANG_ENGLISH_UNITED_KINGDOM SUBLANG_ENGLISH_UK
+#define SUBLANG_ENGLISH_UNITED_STATES SUBLANG_ENGLISH_US
+#define SUBLANG_FRENCH_BELGIUM SUBLANG_FRENCH_BELGIAN
+#define SUBLANG_FRENCH_CANADA SUBLANG_FRENCH_CANADIAN
+#define SUBLANG_FRENCH_SWITZERLAND SUBLANG_FRENCH_SWISS
+#define SUBLANG_GERMAN_AUSTRIA SUBLANG_GERMAN_AUSTRIAN
+#define SUBLANG_GERMAN_SWITZERLAND SUBLANG_GERMAN_SWISS
+#define SUBLANG_ITALIAN_SWITZERLAND SUBLANG_ITALIAN_SWISS
+#define SUBLANG_NORWEGIAN_BOKMAL_NORWAY SUBLANG_NORWEGIAN_BOKMAL
+#define SUBLANG_NORWEGIAN_NORWAY SUBLANG_NORWEGIAN_BOKMAL
+#define SUBLANG_NORWEGIAN_NYNORSK_NORWAY SUBLANG_NORWEGIAN_NYNORSK
+#define SUBLANG_PORTUGUESE_BRAZIL SUBLANG_PORTUGUESE_BRAZILIAN
+
+#endif
+
+#include "lctab.h"
+
+static Lc_numeric_t default_numeric = { '.', -1 };
+
+static Lc_t default_lc =
+{
+ "C",
+ "POSIX",
+ &language[0],
+ &territory[0],
+ &charset[0],
+ 0,
+ LC_default|LC_checked|LC_local,
+ 0,
+ {
+ { &default_lc, 0, 0 },
+ { &default_lc, 0, 0 },
+ { &default_lc, 0, 0 },
+ { &default_lc, 0, 0 },
+ { &default_lc, 0, 0 },
+ { &default_lc, 0, (void*)&default_numeric },
+ { &default_lc, 0, 0 },
+ { &default_lc, 0, 0 },
+ { &default_lc, 0, 0 },
+ { &default_lc, 0, 0 },
+ { &default_lc, 0, 0 },
+ { &default_lc, 0, 0 },
+ { &default_lc, 0, 0 },
+ { &default_lc, 0, 0 }
+ }
+};
+
+static Lc_numeric_t debug_numeric = { ',', '.' };
+
+static Lc_t debug_lc =
+{
+ "debug",
+ "debug",
+ &language[1],
+ &territory[1],
+ &charset[0],
+ 0,
+ LC_debug|LC_checked|LC_local,
+ 0,
+ {
+ { &debug_lc, 0, 0 },
+ { &debug_lc, 0, 0 },
+ { &debug_lc, 0, 0 },
+ { &debug_lc, 0, 0 },
+ { &debug_lc, 0, 0 },
+ { &debug_lc, 0, (void*)&debug_numeric },
+ { &debug_lc, 0, 0 },
+ { &debug_lc, 0, 0 },
+ { &debug_lc, 0, 0 },
+ { &debug_lc, 0, 0 },
+ { &debug_lc, 0, 0 },
+ { &debug_lc, 0, 0 },
+ { &debug_lc, 0, 0 },
+ { &debug_lc, 0, 0 }
+ },
+ &default_lc
+};
+
+static Lc_t* lcs = &debug_lc;
+
+Lc_t* locales[] =
+{
+ &default_lc,
+ &default_lc,
+ &default_lc,
+ &default_lc,
+ &default_lc,
+ &default_lc,
+ &default_lc,
+ &default_lc,
+ &default_lc,
+ &default_lc,
+ &default_lc,
+ &default_lc,
+ &default_lc,
+ &default_lc
+};
+
+/*
+ * return the internal category index for category
+ */
+
+int
+lcindex(int category, int min)
+{
+ switch (category)
+ {
+ case LC_ALL: return min ? -1 : AST_LC_ALL;
+ case LC_ADDRESS: return AST_LC_ADDRESS;
+ case LC_COLLATE: return AST_LC_COLLATE;
+ case LC_CTYPE: return AST_LC_CTYPE;
+ case LC_IDENTIFICATION: return AST_LC_IDENTIFICATION;
+ case LC_MEASUREMENT: return AST_LC_MEASUREMENT;
+ case LC_MESSAGES: return AST_LC_MESSAGES;
+ case LC_MONETARY: return AST_LC_MONETARY;
+ case LC_NAME: return AST_LC_NAME;
+ case LC_NUMERIC: return AST_LC_NUMERIC;
+ case LC_PAPER: return AST_LC_PAPER;
+ case LC_TELEPHONE: return AST_LC_TELEPHONE;
+ case LC_TIME: return AST_LC_TIME;
+ case LC_XLITERATE: return AST_LC_XLITERATE;
+ }
+ return -1;
+}
+
+/*
+ * return the first category table entry
+ */
+
+Lc_category_t*
+lccategories(void)
+{
+ return &categories[0];
+}
+
+/*
+ * return the current info for category
+ */
+
+Lc_info_t*
+lcinfo(register int category)
+{
+ if ((category = lcindex(category, 0)) < 0)
+ return 0;
+ return LCINFO(category);
+}
+
+/*
+ * return 1 if s matches the alternation pattern p
+ * if minimum!=0 then at least that many chars must match
+ * if standard!=0 and s[0] is a digit leading non-digits are ignored in p
+ */
+
+static int
+match(const char* s, register const char* p, int minimum, int standard)
+{
+ register const char* t;
+ const char* x;
+ int w;
+ int z;
+
+ z = 0;
+ do
+ {
+ t = s;
+ if (standard)
+ {
+ if (isdigit(*t))
+ while (*p && !isdigit(*p))
+ p++;
+ else if (isdigit(*p))
+ while (*t && !isdigit(*t))
+ t++;
+ }
+ if (*p)
+ {
+ w = 0;
+ x = p;
+ while (*p && *p != '|')
+ {
+ if (!*t || *t == ',')
+ break;
+ else if (*t == *p)
+ /*ok*/;
+ else if (*t == '-')
+ {
+ if (standard && isdigit(*p))
+ {
+ t++;
+ continue;
+ }
+ while (*p && *p != '-')
+ p++;
+ if (!*p)
+ break;
+ }
+ else if (*p == '-')
+ {
+ if (standard && isdigit(*t))
+ {
+ p++;
+ continue;
+ }
+ w = 1;
+ while (*t && *t != '-')
+ t++;
+ if (!*t)
+ break;
+ }
+ else
+ break;
+ t++;
+ p++;
+ }
+ if ((!*t || *t == ',') && (!*p || *p == '|' || w))
+ return p - x;
+ if (minimum && z < (p - x) && (p - x) >= minimum)
+ z = p - x;
+ }
+ while (*p && *p != '|')
+ p++;
+ } while (*p++);
+ return z;
+}
+
+/*
+ * return 1 if s matches the charset names in cp
+ */
+
+static int
+match_charset(register const char* s, register const Lc_charset_t* cp)
+{
+ return match(s, cp->code, 0, 1) || match(s, cp->alternates, 3, 1) || cp->ms && match(s, cp->ms, 0, 1);
+}
+
+/*
+ * low level for lccanon
+ */
+
+static size_t
+canonical(const Lc_language_t* lp, const Lc_territory_t* tp, const Lc_charset_t* cp, const Lc_attribute_list_t* ap, unsigned long flags, char* buf, size_t siz)
+{
+ register int c;
+ register int u;
+ register char* s;
+ register char* e;
+ register const char* t;
+
+ if (!(flags & (LC_abbreviated|LC_default|LC_local|LC_qualified|LC_verbose)))
+ flags |= LC_abbreviated;
+ s = buf;
+ e = &buf[siz - 3];
+ if (lp)
+ {
+ if (lp->flags & (LC_debug|LC_default))
+ {
+ for (t = lp->code; s < e && (*s = *t++); s++);
+ *s++ = 0;
+ return s - buf;
+ }
+ if (flags & LC_verbose)
+ {
+ u = 1;
+ t = lp->name;
+ while (s < e && (c = *t++))
+ {
+ if (u)
+ {
+ u = 0;
+ c = toupper(c);
+ }
+ else if (!isalnum(c))
+ u = 1;
+ *s++ = c;
+ }
+ }
+ else
+ for (t = lp->code; s < e && (*s = *t++); s++);
+ }
+ if (s < e)
+ {
+ if (tp && tp != &territory[0] && (!(flags & (LC_abbreviated|LC_default)) || !lp || !streq(lp->code, tp->code)))
+ {
+ if (lp)
+ *s++ = '_';
+ if (flags & LC_verbose)
+ {
+ u = 1;
+ t = tp->name;
+ while (s < e && (c = *t++) && c != '|')
+ {
+ if (u)
+ {
+ u = 0;
+ c = toupper(c);
+ }
+ else if (!isalnum(c))
+ u = 1;
+ *s++ = c;
+ }
+ }
+ else
+ for (t = tp->code; s < e && (*s = toupper(*t++)); s++);
+ }
+ if (lp && (!(flags & (LC_abbreviated|LC_default)) || cp != lp->charset) && s < e)
+ {
+ *s++ = '.';
+ for (t = cp->code; s < e && (c = *t++); s++)
+ {
+ if (islower(c))
+ c = toupper(c);
+ *s = c;
+ }
+ }
+ for (c = '@'; ap && s < e; ap = ap->next)
+ if (!(flags & (LC_abbreviated|LC_default|LC_verbose)) || !(ap->attribute->flags & LC_default))
+ {
+ *s++ = c;
+ c = ',';
+ for (t = ap->attribute->name; s < e && (*s = *t++); s++);
+ }
+ }
+ *s++ = 0;
+ return s - buf;
+}
+
+/*
+ * generate a canonical locale name in buf
+ */
+
+size_t
+lccanon(Lc_t* lc, unsigned long flags, char* buf, size_t siz)
+{
+ if ((flags & LC_local) && (!lc->language || !(lc->language->flags & (LC_debug|LC_default))))
+ {
+#if _WINIX
+ char lang[64];
+ char code[64];
+ char ctry[64];
+
+ if (lc->index &&
+ GetLocaleInfo(lc->index, LOCALE_SENGLANGUAGE, lang, sizeof(lang)) &&
+ GetLocaleInfo(lc->index, LOCALE_SENGCOUNTRY, ctry, sizeof(ctry)))
+ {
+ if (!GetLocaleInfo(lc->index, LOCALE_IDEFAULTANSICODEPAGE, code, sizeof(code)))
+ code[0] = 0;
+ if (!lc->charset || !lc->charset->ms)
+ return sfsprintf(buf, siz, "%s_%s", lang, ctry);
+ else if (streq(lc->charset->ms, code))
+ return sfsprintf(buf, siz, "%s_%s.%s", lang, ctry, code);
+ else
+ return sfsprintf(buf, siz, "%s_%s.%s,%s", lang, ctry, code, lc->charset->ms);
+ }
+#endif
+ buf[0] = '-';
+ buf[1] = 0;
+ return 0;
+ }
+ return canonical(lc->language, lc->territory, lc->charset, lc->attributes, flags, buf, siz);
+}
+
+/*
+ * make an Lc_t from a locale name
+ */
+
+Lc_t*
+lcmake(const char* name)
+{
+ register int c;
+ register char* s;
+ register char* e;
+ register const char* t;
+ const char* a;
+ char* w;
+ char* language_name;
+ char* territory_name;
+ char* charset_name;
+ char* attributes_name;
+ Lc_t* lc;
+ const Lc_map_t* mp;
+ const Lc_language_t* lp;
+ const Lc_territory_t* tp;
+ const Lc_territory_t* tpb;
+ const Lc_territory_t* primary;
+ const Lc_charset_t* cp;
+ const Lc_charset_t* ppa;
+ const Lc_attribute_t* ap;
+ Lc_attribute_list_t* ai;
+ Lc_attribute_list_t* al;
+ int i;
+ int n;
+ int z;
+ char buf[PATH_MAX / 2];
+ char tmp[PATH_MAX / 2];
+
+ if (!(t = name) || !*t)
+ return &default_lc;
+ for (lc = lcs; lc; lc = lc->next)
+ if (!strcasecmp(t, lc->code) || !strcasecmp(t, lc->name))
+ return lc;
+ for (mp = map; mp->code; mp++)
+ if (streq(t, mp->code))
+ {
+ lp = mp->language;
+ tp = mp->territory;
+ cp = mp->charset;
+ if (!mp->attribute)
+ al = 0;
+ else if (al = newof(0, Lc_attribute_list_t, 1, 0))
+ al->attribute = mp->attribute;
+ goto mapped;
+ }
+ language_name = buf;
+ territory_name = charset_name = attributes_name = 0;
+ s = buf;
+ e = &buf[sizeof(buf)-2];
+ a = 0;
+ n = 0;
+ while (s < e && (c = *t++))
+ {
+ if (isspace(c) || (c == '(' || c == '-' && *t == '-') && ++n)
+ {
+ while ((c = *t++) && (isspace(c) || (c == '-' || c == '(' || c == ')') && ++n))
+ if (!c)
+ break;
+ if (isalnum(c) && !n)
+ *s++ = '-';
+ else
+ {
+ n = 0;
+ if (!a)
+ {
+ a = t - 1;
+ while (c && c != '_' && c != '.' && c != '@')
+ c = *t++;
+ if (!c)
+ break;
+ }
+ }
+ }
+ if (c == '_' && !territory_name)
+ {
+ *s++ = 0;
+ territory_name = s;
+ }
+ else if (c == '.' && !charset_name)
+ {
+ *s++ = 0;
+ charset_name = s;
+ }
+ else if (c == '@' && !attributes_name)
+ {
+ *s++ = 0;
+ attributes_name = s;
+ }
+ else
+ {
+ if (isupper(c))
+ c = tolower(c);
+ *s++ = c;
+ }
+ }
+ if ((t = a) && s < e)
+ {
+ if (attributes_name)
+ *s++ = ',';
+ else
+ {
+ *s++ = 0;
+ attributes_name = s;
+ }
+ while (s < e && (c = *t++))
+ {
+ if (isspace(c) || (c == '(' || c == ')' || c == '-' && *t == '-') && ++n)
+ {
+ while ((c = *t++) && (isspace(c) || (c == '-' || c == '(' || c == ')') && ++n))
+ if (!c)
+ break;
+ if (isalnum(c) && !n)
+ *s++ = '-';
+ else
+ n = 0;
+ }
+ if (c == '_' || c == '.' || c == '@')
+ break;
+ if (isupper(c))
+ c = tolower(c);
+ *s++ = c;
+ }
+ }
+ *s = 0;
+ tp = 0;
+ cp = ppa = 0;
+ al = 0;
+
+ /*
+ * language
+ */
+
+ n = strlen(s = language_name);
+ if (n == 2)
+ for (lp = language; lp->code && !streq(s, lp->code); lp++);
+ else if (n == 3)
+ {
+ for (lp = language; lp->code && (!lp->alternates || !match(s, lp->alternates, n, 0)); lp++);
+ if (!lp->code)
+ {
+ c = s[2];
+ s[2] = 0;
+ for (lp = language; lp->code && !streq(s, lp->code); lp++);
+ s[2] = c;
+ if (lp->code)
+ n = 1;
+ }
+ }
+ else
+ lp = 0;
+ if (!lp || !lp->code)
+ {
+ for (lp = language; lp->code && !match(s, lp->name, 0, 0); lp++);
+ if (!lp || !lp->code)
+ {
+ if (!territory_name)
+ {
+ if (n == 2)
+ for (tp = territory; tp->code && !streq(s, tp->code); tp++);
+ else
+ {
+ z = 0;
+ tpb = 0;
+ for (tp = territory; tp->name; tp++)
+ if ((i = match(s, tp->name, 3, 0)) > z)
+ {
+ tpb = tp;
+ if ((z = i) == n)
+ break;
+ }
+ if (tpb)
+ tp = tpb;
+ }
+ if (tp->code)
+ lp = tp->languages[0];
+ }
+ if (!lp || !lp->code)
+ {
+ /*
+ * name not in the tables so let
+ * _ast_setlocale() and/or setlocale()
+ * handle the validity checks
+ */
+
+ s = (char*)name;
+ z = strlen(s) + 1;
+ if (!(lp = newof(0, Lc_language_t, 1, z)))
+ return 0;
+ name = ((Lc_language_t*)lp)->code = ((Lc_language_t*)lp)->name = (const char*)(lp + 1);
+ memcpy((char*)lp->code, s, z - 1);
+ tp = &territory[0];
+ cp = ((Lc_language_t*)lp)->charset = &charset[0];
+ al = 0;
+ goto override;
+ }
+ }
+ }
+
+ /*
+ * territory
+ */
+
+ if (!tp || !tp->code)
+ {
+ if (!(s = territory_name))
+ {
+ n = 0;
+ primary = 0;
+ for (tp = territory; tp->code; tp++)
+ if (tp->languages[0] == lp)
+ {
+ if (tp->flags & LC_primary)
+ {
+ n = 1;
+ primary = tp;
+ break;
+ }
+ n++;
+ primary = tp;
+ }
+ if (n == 1)
+ tp = primary;
+ s = (char*)lp->code;
+ }
+ if (!tp || !tp->code)
+ {
+ n = strlen(s);
+ if (n == 2)
+ {
+ for (tp = territory; tp->code; tp++)
+ if (streq(s, tp->code))
+ {
+ for (i = 0; i < elementsof(tp->languages) && lp != tp->languages[i]; i++);
+ if (i >= elementsof(tp->languages))
+ tp = 0;
+ break;
+ }
+ }
+ else
+ {
+ for (tp = territory; tp->code; tp++)
+ if (match(s, tp->name, 3, 0))
+ {
+ for (i = 0; i < elementsof(tp->languages) && lp != tp->languages[i]; i++);
+ if (i < elementsof(tp->languages))
+ break;
+ }
+ }
+ if (tp && !tp->code)
+ tp = 0;
+ }
+ }
+
+ /*
+ * attributes -- done here to catch misplaced charset references
+ */
+
+ if (s = attributes_name)
+ {
+ do
+ {
+ for (w = s; *s && *s != ','; s++);
+ c = *s;
+ *s = 0;
+ if (!(cp = lp->charset) || !match_charset(w, cp))
+ for (cp = charset; cp->code; cp++)
+ if (match_charset(w, cp))
+ {
+ ppa = cp;
+ break;
+ }
+ if (!cp->code)
+ {
+ for (i = 0; i < elementsof(lp->attributes) && (ap = lp->attributes[i]); i++)
+ if (match(w, ap->name, 5, 0))
+ {
+ if (ai = newof(0, Lc_attribute_list_t, 1, 0))
+ {
+ ai->attribute = ap;
+ ai->next = al;
+ al = ai;
+ }
+ break;
+ }
+ if (i >= elementsof(lp->attributes) && (ap = newof(0, Lc_attribute_t, 1, sizeof(Lc_attribute_list_t) + s - w + 1)))
+ {
+ ai = (Lc_attribute_list_t*)(ap + 1);
+ strcpy((char*)(((Lc_attribute_t*)ap)->name = (const char*)(ai + 1)), w);
+ ai->attribute = ap;
+ ai->next = al;
+ al = ai;
+ }
+ }
+ *s = c;
+ } while (*s++);
+ }
+
+ /*
+ * charset
+ */
+
+ if (s = charset_name)
+ for (cp = charset; cp->code; cp++)
+ if (match_charset(s, cp))
+ break;
+ if (!cp || !cp->code)
+ cp = ppa ? ppa : lp->charset;
+ mapped:
+ z = canonical(lp, tp, cp, al, 0, s = tmp, sizeof(tmp));
+
+ /*
+ * add to the list of possibly active locales
+ */
+
+ override:
+ n = strlen(name) + 1;
+ if (!(lc = newof(0, Lc_t, 1, n + z)))
+ return 0;
+ strcpy((char*)(lc->name = (const char*)(lc + 1)), name);
+ strcpy((char*)(lc->code = lc->name + n), s);
+ lc->language = lp ? lp : &language[0];
+ lc->territory = tp ? tp : &territory[0];
+ lc->charset = cp ? cp : &charset[0];
+ lc->attributes = al;
+ for (i = 0; i < elementsof(lc->info); i++)
+ lc->info[i].lc = lc;
+#if _WINIX
+ n = SUBLANG_DEFAULT;
+ if (tp)
+ for (i = 0; i < elementsof(tp->languages); i++)
+ if (lp == tp->languages[i])
+ {
+ n = tp->indices[i];
+ break;
+ }
+ lc->index = MAKELCID(MAKELANGID(lp->index, n), SORT_DEFAULT);
+#endif
+ lc->next = lcs;
+ lcs = lc;
+ return lc;
+}
+
+/*
+ * return an Lc_t* for each locale in the tables
+ * one Lc_t is allocated on the first call with lc==0
+ * this is freed when 0 returned
+ * the return value is not part of the lcmake() cache
+ */
+
+typedef struct Lc_scan_s
+{
+ Lc_t lc;
+ Lc_attribute_list_t list;
+ int territory;
+ int language;
+ int attribute;
+ char buf[256];
+} Lc_scan_t;
+
+Lc_t*
+lcscan(Lc_t* lc)
+{
+ register Lc_scan_t* ls;
+
+ if (!(ls = (Lc_scan_t*)lc))
+ {
+ if (!(ls = newof(0, Lc_scan_t, 1, 0)))
+ return 0;
+ ls->lc.code = ls->lc.name = ls->buf;
+ ls->territory = -1;
+ ls->language = elementsof(ls->lc.territory->languages);
+ ls->attribute = elementsof(ls->lc.language->attributes);
+ }
+ if (++ls->attribute >= elementsof(ls->lc.language->attributes) || !(ls->list.attribute = ls->lc.language->attributes[ls->attribute]))
+ {
+ if (++ls->language >= elementsof(ls->lc.territory->languages) || !(ls->lc.language = ls->lc.territory->languages[ls->language]))
+ {
+ if (++ls->territory >= (elementsof(territory) - 1))
+ {
+ free(ls);
+ return 0;
+ }
+ ls->lc.territory = &territory[ls->territory];
+ ls->lc.language = ls->lc.territory->languages[ls->language = 0];
+ }
+ if (ls->lc.language)
+ {
+ ls->lc.charset = ls->lc.language->charset ? ls->lc.language->charset : &charset[0];
+ ls->list.attribute = ls->lc.language->attributes[ls->attribute = 0];
+ }
+ else
+ {
+ ls->lc.charset = &charset[0];
+ ls->list.attribute = 0;
+ }
+ }
+ ls->lc.attributes = ls->list.attribute ? &ls->list : (Lc_attribute_list_t*)0;
+#if _WINIX
+ if (!ls->lc.language || !ls->lc.language->index)
+ ls->lc.index = 0;
+ else
+ {
+ if ((!ls->list.attribute || !(ls->lc.index = ls->list.attribute->index)) &&
+ (!ls->lc.territory || !(ls->lc.index = ls->lc.territory->indices[ls->language])))
+ ls->lc.index = SUBLANG_DEFAULT;
+ ls->lc.index = MAKELCID(MAKELANGID(ls->lc.language->index, ls->lc.index), SORT_DEFAULT);
+ }
+#endif
+ canonical(ls->lc.language, ls->lc.territory, ls->lc.charset, ls->lc.attributes, 0, ls->buf, sizeof(ls->buf));
+ return (Lc_t*)ls;
+}
diff --git a/usr/src/lib/libast/common/port/lc.tab b/usr/src/lib/libast/common/port/lc.tab
new file mode 100644
index 0000000000..87905a10b5
--- /dev/null
+++ b/usr/src/lib/libast/common/port/lc.tab
@@ -0,0 +1,275 @@
+#
+# language_territory.charset@attribute tables
+#
+
+:charset:
+
+ iso8859-1 latin1|west-europe 1252
+ iso8859-2 latin2|east-europe 1250
+ iso8859-3 latin3|south-europe 1257
+ iso8859-4 latin4|north-europe
+ iso8859-5 cyrillic 1251
+ iso8859-6 arabic 1256
+ iso8859-7 greek 1253
+ iso8859-8 hebrew 1255
+ iso8859-9 latin5|turkish 1254
+ iso8859-10 latin6|nordic
+ iso8859-13 latin7
+ iso8859-14 latin8|celtic
+ iso8859-15 latin0
+ iso2022 japanese|korean
+ iso4873 japanese-ascii|korean-ascii
+ koi8-r russian
+ utf8 plan9
+
+:language:
+
+ aa afar
+ ab abkhazian
+ af afrikaans afr
+ am amharic
+ ar arabic ara iso8859-6
+ as assamese
+ ay aymara
+ az azerbaijani
+ ba bashkir
+ be belarusian bel
+ bg bulgarian bul iso8859-5
+ bh bihari
+ bi bislama
+ bn bengali-bangla
+ bo tibetan
+ br breton
+ ca catalan cat
+ co corsican
+ cs czech ces|cze iso8859-2
+ cy welsh
+ da danish dan
+ de german deu|ger
+ dz bhutani
+ el greek ell|gre iso8859-7
+ en english eng
+ eo esperanto
+ es spanish spa - traditional:default|modern
+ et estonian est iso8859-3
+ eu basque eus|baq
+ fa persian
+ fi finnish fin
+ fj fiji
+ fo faeroese
+ fr french fra|fre
+ fy frisian
+ ga irish - iso8859-14
+ gd scots-gaelic - iso8859-14
+ gl galician
+ gn guarani
+ gu gujarati
+ ha hausa
+ he hebrew heb iso8859-8
+ hi hindi
+ hr croatian hrv|scr iso8859-2
+ hu hungarian hun iso8859-2
+ hy armenian
+ ia interlingua
+ id indonesian ind
+ ie interlingue
+ ik inupiak
+ in indonesian
+ is icelandic isl|ice
+ it italian ita
+ iw hebrew
+ ja japanese jpn
+ ji yiddish
+ jw javanese
+ ka georgian
+ kk kazakh kaz
+ kl greenlandic
+ km cambodian
+ kn kannada
+ ko korean kor
+ ks kashmiri
+ ku kurdish
+ ky kirghiz
+ la latin
+ ln lingala
+ lo laothian
+ lt lithuanian lit iso8859-13
+ lv latvian lav iso8859-13
+ mg malagasy
+ mi maori
+ mk macedonian mkd|mac
+ ml malayalam mal
+ mn mongolian
+ mo moldavian
+ mr marathi
+ ms malay msa|may
+ mt maltese
+ my burmese
+ na nauru
+ nb norwegian-bokmal nob
+ ne nepali
+ nl dutch nld|dut
+ nn norwegian-nynorsk nno|non
+ no norwegian nor
+ oc occitan
+ om oromo
+ or oriya
+ pa punjabi
+ pl polish pol iso8859-2
+ ps pushto
+ pt portuguese por
+ qu quechua
+ rm rhaeto-romance
+ rn kirundi
+ ro romanian ron|rum iso8859-2
+ ru russian rus iso8859-5
+ rw kinyarwanda
+ sa sanskrit
+ sd sindhi
+ sg sangro
+ sh serbo-croatian
+ si singhalese
+ sk slovak slk|slo iso8859-2
+ sl slovenian slv iso8859-2
+ sm samoan
+ sn shona
+ so somali
+ sq albanian sqi|alb
+ sr serbian srp iso8859-2
+ ss siswati
+ st sesotho
+ su sudanese
+ sv swedish swe
+ sw swahili swa
+ ta tamil
+ te telugu
+ tg tajik
+ th thai tha
+ ti tigrinya
+ tk turkmen
+ tl tagalog
+ tn setswana
+ to tonga
+ tr turkish tur iso8859-9
+ ts tsonga
+ tt tatar tat
+ tw chinese-traditional cht
+ uk ukrainian ukr iso8859-5
+ ur urdu
+ uz uzbek uzb
+ vi vietnamese
+ vo volapuk
+ wo wolof
+ xh xhosa
+ yo yoruba
+ zh chinese-simplified zho|chi|chs
+ zu zulu
+
+:territory:
+
+ al albania
+ an netherlands-antilles nl
+ ar argentina es
+ at austria de
+ au australia en
+ az azerbaijan
+ be belgium nl|fr|de
+ bg bulgaria bg
+ bn brunei-darussalam ar
+ bo bolivia es
+ br brazil pt
+ bw botswana en
+ by belarus ru
+ bz belize en
+ ca canada en|fr
+ ch switzerland fr|de|it
+ cl chile es
+ cn china zh:primary
+ co colombia es
+ cr costa-rica es
+ cz czech-republic cs
+ de germany de
+ dk denmark da|en
+ do dominican-republic es
+ dz algeria
+ ec ecuador es
+ ee estonia et
+ eg egypt ar
+ es spain es|ca|eu|gl
+ fi finland sv
+ fo faroe-islands fo
+ fr france fr
+ gb united-kingdom|great-britain|england en:primary
+ gl greenland kl
+ gr greece el
+ gt guatemala es
+ hk hong-kong zh
+ hn honduras es
+ hr croatia hr
+ hu hungary hu
+ id indonesia id
+ ie ireland en|ga
+ il israel he
+ iq iraq ar
+ is iceland is
+ it italy it
+ jm jamaica en
+ jo jordan ar
+ jp japan ja
+ ke kenya
+ kr south-korea ko
+ kw kuwait ar
+ lb lebanon ar
+ li liechtenstein de|fr
+ lt lithuania lt
+ lu luxembourg de|fr
+ lv latvia lv
+ ly libya ar
+ ma morocco ar
+ mk macedonia mk
+ mo macau zh
+ mx mexico es
+ my malaysia
+ ni nicaragua es
+ nl netherlands nl
+ no norway nb|no|nn
+ nz new-zealand en
+ om oman ar
+ pa panama es
+ pe peru es
+ pl poland pl
+ pr puerto-rico es
+ pt portugal pt
+ py paraguay es
+ ro romania ro
+ ru russia ru
+ sa saudi-arabia ar
+ se sweden sv:primary
+ sg singapore zh
+ si slovenia sl
+ sk slovakia sk
+ sp serbia sr
+ sv el-salvador es
+ sy syria ar
+ th thailand th
+ tn tunisia ar
+ tr turkey tr
+ tt trinidad&tobago en
+ tw taiwan tw
+ ua ukraine uk|ru
+ uk united-kingdom en:primary
+ us united-states|usa en
+ uy uruguay es
+ ve venezuela es
+ yu yugoslavia sr
+ za south-africa af
+ zw zimbabwe en
+
+:map:
+
+ enu en us
+ enz en nz
+ esm es mx
+ esn es es - modern
+ esp es es - traditional
+ usa en us
diff --git a/usr/src/lib/libast/common/port/lcgen.c b/usr/src/lib/libast/common/port/lcgen.c
new file mode 100644
index 0000000000..bfc8656406
--- /dev/null
+++ b/usr/src/lib/libast/common/port/lcgen.c
@@ -0,0 +1,775 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * generate <lc.h> implementation tables from lc.tab
+ * this must make it through vanilla cc with no -last
+ *
+ * # comment
+ * :charset:
+ * code name ms-codepage
+ * :language:
+ * code name alt1|alt2... charset|... attr1|attr2|...
+ * ...
+ * :territory:
+ * code name lang1|lang2...
+ * :abbreviation:
+ */
+
+#include <stdio.h>
+#include <ctype.h>
+#ifdef __STDC__
+#include <stdlib.h>
+#include <string.h>
+#endif
+
+typedef struct Link_s
+{
+ struct Link_s* next;
+ char* code;
+ int index;
+} Link_t;
+
+typedef struct Table_s
+{
+ Link_t* root;
+ int count;
+} Table_t;
+
+typedef struct Abbreviation_s
+{
+ Link_t link;
+ char* value;
+} Abbreviation_t;
+
+typedef struct Attribute_s
+{
+ Link_t link;
+} Attribute_t;
+
+typedef struct Attribute_list_s
+{
+ struct Attribute_list_s*next;
+ Attribute_t* attribute;
+} Attribute_list_t;
+
+typedef struct Charset_s
+{
+ Link_t link;
+ char* alternates;
+ char* ms;
+} Charset_t;
+
+typedef struct Language_s
+{
+ Link_t link;
+ char* name;
+ char* alternates;
+ Charset_t* charset;
+ Attribute_list_t* attributes;
+} Language_t;
+
+typedef struct Language_list_s
+{
+ struct Language_list_s* next;
+ Language_t* language;
+} Language_list_t;
+
+typedef struct Territory_s
+{
+ Link_t link;
+ char* name;
+ Language_list_t* languages;
+ int primary;
+ int index;
+} Territory_t;
+
+typedef struct Map_s
+{
+ Link_t link;
+ Language_t* language;
+ Territory_t* territory;
+ Charset_t* charset;
+ Attribute_t* attribute;
+} Map_t;
+
+static struct State_s
+{
+ Table_t attribute;
+ Table_t charset;
+ Table_t language;
+ Table_t territory;
+ Table_t map;
+} state;
+
+#define INIT 0
+#define CHARSET 1
+#define LANGUAGE 2
+#define TERRITORY 3
+#define MAP 4
+
+#define elementsof(x) (sizeof(x)/sizeof(x[0]))
+#define newof(p,t,n,x) ((t*)malloc(sizeof(t)*(n)+(x)))
+
+static Link_t*
+#if defined(__STDC__) || defined(__cplusplus)
+enter(register Table_t* tab, register Link_t* v)
+#else
+enter(tab, v)
+register Table_t* tab;
+register Link_t* v;
+#endif
+{
+ register Link_t* x;
+ register Link_t* p;
+
+ for (p = 0, x = tab->root; x; p = x, x = x->next)
+ if (!strcmp(x->code, v->code))
+ return x;
+ if (p)
+ p->next = v;
+ else
+ tab->root = v;
+ v->next = 0;
+ v->index = tab->count++;
+ return v;
+}
+
+static Link_t*
+#if defined(__STDC__) || defined(__cplusplus)
+lookup(register Table_t* tab, register char* s)
+#else
+lookup(tab, s)
+register Table_t* tab;
+register char* s;
+#endif
+{
+ register Link_t* x;
+
+ for (x = tab->root; x; x = x->next)
+ if (!strcmp(x->code, s))
+ return x;
+ return 0;
+}
+
+static char*
+#if defined(__STDC__) || defined(__cplusplus)
+copy(char** p, register char* f)
+#else
+copy(p, f)
+char** p;
+register char* f;
+#endif
+{
+ register char* t;
+ char* b;
+
+ if (!f)
+ return 0;
+ b = t = *p;
+ while (*t++ = *f++);
+ *p = t;
+ return b;
+}
+
+static void
+#if defined(__STDC__) || defined(__cplusplus)
+macro(FILE* f, char* p1, char* p2, char* p3)
+#else
+macro(f, p1, p2, p3)
+FILE* f;
+char* p1;
+char* p2;
+char* p3;
+#endif
+{
+ register int c;
+ register char* s;
+ register char* b;
+ register char* e;
+ int i;
+ int m;
+ int n;
+ char* part[4];
+ char buf[128];
+
+ part[0] = p1;
+ part[1] = p2;
+ part[2] = p3;
+ part[3] = 0;
+ n = 0;
+ fprintf(f, "\n");
+ do
+ {
+ i = m = 0;
+ b = buf;
+ e = &buf[sizeof(buf)-1];
+ while (b < e)
+ {
+ if (!(s = part[i++]))
+ break;
+ if (i > 1)
+ *b++ = '_';
+ while ((c = *s++) && b < e)
+ {
+ if (c == '|')
+ {
+ part[i-1] = s;
+ m = 1;
+ break;
+ }
+ else if (islower(c))
+ c = toupper(c);
+ else if (!isalnum(c))
+ c = '_';
+ *b++ = c;
+ }
+ }
+ *b = 0;
+ fprintf(f, "#ifdef %s\n%s,\n#else\n", buf, buf);
+ n++;
+ } while (m);
+ fprintf(f, "0,\n");
+ while (n-- > 0)
+ fprintf(f, "#endif\n");
+}
+
+#if defined(__STDC__) || defined(__cplusplus)
+int
+main(int argc, char** argv)
+#else
+int
+main(argc, argv)
+int argc;
+char** argv;
+#endif
+{
+ register char* s;
+ register char** vp;
+ register char** ve;
+ Attribute_t* ap;
+ Attribute_list_t* al;
+ Attribute_list_t* az;
+ Charset_t* cp;
+ Territory_t* tp;
+ Language_t* lp;
+ Language_list_t* ll;
+ Language_list_t* lz;
+ Map_t* mp;
+ char* b;
+ char* f;
+ char* command;
+ char* hdr;
+ char* lib;
+ FILE* hf;
+ FILE* lf;
+ int c;
+ int i;
+ int line;
+ int type;
+ int language_attribute_max;
+ int territory_language_max;
+ char* arg[5];
+ char buf[1024];
+
+ command = *argv++;
+ line = 0;
+ if (!(hdr = *argv++) || !(lib = *argv++) || *argv)
+ {
+ fprintf(stderr, "%s: hdr and lib arguments expected\n", command);
+ return 1;
+ }
+ if (!(hf = fopen(hdr, "w")))
+ {
+ fprintf(stderr, "%s: %s: cannot write\n", command, hdr);
+ return 1;
+ }
+ if (!(lf = fopen(lib, "w")))
+ {
+ fprintf(stderr, "%s: %s: cannot write\n", command, lib);
+ return 1;
+ }
+ type = 0;
+ language_attribute_max = 0;
+ territory_language_max = 0;
+ state.language.count = 2;
+ state.territory.count = 2;
+ ve = &arg[elementsof(arg)];
+ fprintf(hf, "/* : : generated by %s : : */\n", command);
+ fprintf(hf, "#pragma prototyped\n");
+ fprintf(hf, "\n");
+ fprintf(hf, "#ifndef _LC_H\n");
+ fprintf(hf, "#define _LC_H\t\t\t1\n");
+ fprintf(hf, "\n");
+ fprintf(hf, "#include <ast.h>\n");
+ fprintf(hf, "\n");
+ fprintf(hf, "#define LC_abbreviated\t\t0x00001\n");
+ fprintf(hf, "#define LC_checked\t\t0x00002\n");
+ fprintf(hf, "#define LC_default\t\t0x00004\n");
+ fprintf(hf, "#define LC_defined\t\t0x00008\n");
+ fprintf(hf, "#define LC_debug\t\t0x00010\n");
+ fprintf(hf, "#define LC_local\t\t0x00020\n");
+ fprintf(hf, "#define LC_primary\t\t0x00040\n");
+ fprintf(hf, "#define LC_qualified\t\t0x00080\n");
+ fprintf(hf, "#define LC_undefined\t\t0x00100\n");
+ fprintf(hf, "#define LC_verbose\t\t0x00200\n");
+ fprintf(hf, "#define LC_user\t\t\t0x10000\n");
+ fprintf(lf, "/* : : generated by %s : : */\n", command);
+ while (s = fgets(buf, sizeof(buf), stdin))
+ {
+ line++;
+ while (isspace(*s))
+ s++;
+ if (!*s || *s == '#')
+ continue;
+ b = s;
+ vp = arg;
+ for (;;)
+ {
+ for (*vp++ = s; *s && !isspace(*s); s++);
+ if (!*s)
+ break;
+ for (*s++ = 0; isspace(*s); s++);
+ if (!strcmp(*(vp - 1), "-"))
+ *(vp - 1) = 0;
+ if (!*s || vp >= ve)
+ break;
+ }
+ while (vp < ve)
+ *vp++ = 0;
+ if (*arg[0] == ':')
+ {
+ if (!strcmp(arg[0], ":map:"))
+ {
+ if (type != TERRITORY)
+ {
+ fprintf(stderr, "%s: %d: %s: must be specified after :territory:\n", command, line, arg[0]);
+ return 1;
+ }
+ type = MAP;
+ continue;
+ }
+ else if (!strcmp(arg[0], ":charset:"))
+ {
+ if (type != INIT)
+ {
+ fprintf(stderr, "%s: %d: %s must be specified first\n", command, line, arg[0]);
+ return 1;
+ }
+ type = CHARSET;
+ continue;
+ }
+ else if (!strcmp(arg[0], ":territory:"))
+ {
+ if (type != LANGUAGE)
+ {
+ fprintf(stderr, "%s: %d: %s: must be specified after :language:\n", command, line, arg[0]);
+ return 1;
+ }
+ type = TERRITORY;
+ continue;
+ }
+ else if (!strcmp(arg[0], ":language:"))
+ {
+ if (type != CHARSET)
+ {
+ fprintf(stderr, "%s: %d: %s must be specified after :charset:\n", command, line, arg[0]);
+ return 1;
+ }
+ type = LANGUAGE;
+ continue;
+ }
+ else
+ {
+ fprintf(stderr, "%s: %d: %s invalid\n", command, line, arg[0]);
+ return 1;
+ }
+ }
+ if (!arg[1])
+ {
+ fprintf(stderr, "%s: %d: at least two arguments expected\n", command, line);
+ return 1;
+ }
+ switch (type)
+ {
+ case CHARSET:
+ if (!(cp = newof(0, Charset_t, 1, s - b + 1)))
+ {
+ fprintf(stderr, "%s: %d: out of space\n", command, line);
+ return 1;
+ }
+ b = (char*)(cp + 1);
+ cp->link.code = copy(&b, arg[0]);
+ cp->alternates = copy(&b, arg[1]);
+ cp->ms = copy(&b, arg[2]);
+ if (cp != (Charset_t*)enter(&state.charset, (Link_t*)cp))
+ {
+ fprintf(stderr, "%s: %d: %s: duplicate charset\n", command, line, cp->link.code);
+ return 1;
+ }
+ break;
+ case TERRITORY:
+ if (!(tp = newof(0, Territory_t, 1, s - b + 1)))
+ {
+ fprintf(stderr, "%s: %d: out of space\n", command, line);
+ return 1;
+ }
+ b = (char*)(tp + 1);
+ tp->link.code = copy(&b, arg[0]);
+ tp->name = copy(&b, arg[1]);
+ tp->languages = 0;
+ if (s = copy(&b, arg[2]))
+ {
+ i = 0;
+ while (*(b = s))
+ {
+ for (; *s && *s != ':' && *s != '|'; s++);
+ if (c = *s)
+ *s++ = 0;
+ if (!(lp = (Language_t*)lookup(&state.language, b)))
+ {
+ fprintf(stderr, "%s: %d: %s: unknown language\n", command, line, b);
+ return 1;
+ }
+ if (!(ll = newof(0, Language_list_t, 1, 0)))
+ {
+ fprintf(stderr, "%s: %d: out of space\n", command, line);
+ return 1;
+ }
+ if (!tp->languages)
+ tp->languages = ll;
+ else
+ lz->next = ll;
+ lz = ll;
+ ll->language = lp;
+ ll->next = 0;
+ i++;
+ if (c == ':')
+ {
+ for (b = s; *s && *s != '|'; s++);
+ if (*s)
+ *s++ = 0;
+ if (!strcmp(b, "primary"))
+ tp->primary = 1;
+ }
+ }
+ if (territory_language_max < i)
+ territory_language_max = i;
+ }
+ if (tp != (Territory_t*)enter(&state.territory, (Link_t*)tp))
+ {
+ fprintf(stderr, "%s: %d: %s: duplicate territory\n", command, line, tp->link.code);
+ return 1;
+ }
+ break;
+ case LANGUAGE:
+ if (!(lp = newof(0, Language_t, 1, s - b + 1)))
+ {
+ fprintf(stderr, "%s: %d: out of space\n", command, line);
+ return 1;
+ }
+ b = (char*)(lp + 1);
+ lp->link.code = copy(&b, arg[0]);
+ lp->name = copy(&b, arg[1]);
+ lp->alternates = copy(&b, arg[2]);
+ if (!arg[3])
+ lp->charset = 0;
+ else if (!(lp->charset = (Charset_t*)lookup(&state.charset, arg[3])))
+ {
+ fprintf(stderr, "%s: %d: %s: unknown charset\n", command, line, arg[3]);
+ return 1;
+ }
+ lp->attributes = 0;
+ if (s = copy(&b, arg[4]))
+ {
+ i = 0;
+ fprintf(lf, "\nstatic Lc_attribute_t attribute_%s[] =\n{\n", lp->link.code);
+ while (*(b = s))
+ {
+ for (f = 0; *s && *s != '|'; s++)
+ if (*s == ':')
+ {
+ *s++ = 0;
+ f = s;
+ }
+ if (*s)
+ *s++ = 0;
+ fprintf(lf, "{\"%s\",", b);
+ if (f)
+ fprintf(lf, "LC_%s,", f);
+ else
+ fprintf(lf, "0,");
+ if (!(ap = newof(0, Attribute_t, 1, 0)))
+ {
+ fprintf(stderr, "%s: %d: out of space\n", command, line);
+ return 1;
+ }
+ ap->link.code = b;
+ ap->link.index = i++;
+ if (!(al = newof(0, Attribute_list_t, 1, 0)))
+ {
+ fprintf(stderr, "%s: %d: out of space\n", command, line);
+ return 1;
+ }
+ if (!lp->attributes)
+ lp->attributes = al;
+ else
+ az->next = al;
+ az = al;
+ al->attribute = ap;
+ al->next = 0;
+ macro(lf, "SUBLANG", lp->name, b);
+ fprintf(lf, "\n},\n");
+ }
+ if (language_attribute_max < i)
+ language_attribute_max = i;
+ fprintf(lf, "};\n");
+ }
+ if (lp != (Language_t*)enter(&state.language, (Link_t*)lp))
+ {
+ fprintf(stderr, "%s: %d: %s: duplicate language\n", command, line, lp->link.code);
+ return 1;
+ }
+ break;
+ case MAP:
+ if (!(mp = newof(0, Map_t, 1, s - b + 1)))
+ {
+ fprintf(stderr, "%s: %d: out of space\n", command, line);
+ return 1;
+ }
+ b = (char*)(mp + 1);
+ mp->link.code = copy(&b, arg[0]);
+ if (!arg[2])
+ {
+ fprintf(stderr, "%s: %d: territory code expected\n", command, line);
+ return 1;
+ }
+ if (!(mp->language = (Language_t*)lookup(&state.language, arg[1])))
+ {
+ fprintf(stderr, "%s: %d: %s: unknown language\n", command, line, arg[1]);
+ return 1;
+ }
+ if (!(mp->territory = (Territory_t*)lookup(&state.territory, arg[2])))
+ {
+ fprintf(stderr, "%s: %d: %s: unknown territory\n", command, line, arg[2]);
+ return 1;
+ }
+ if (!arg[3])
+ mp->charset = 0;
+ else if (!(mp->charset = (Charset_t*)lookup(&state.charset, arg[3])))
+ {
+ fprintf(stderr, "%s: %d: %s: unknown charset\n", command, line, arg[3]);
+ return 1;
+ }
+ mp->attribute = 0;
+ if (arg[4])
+ {
+ for (al = mp->language->attributes; al; al = al->next)
+ if (!strcmp(al->attribute->link.code, arg[4]))
+ {
+ mp->attribute = al->attribute;
+ break;
+ }
+ if (!mp->attribute)
+ {
+ fprintf(stderr, "%s: %d: %s: unknown attribute\n", command, line, arg[4]);
+ return 1;
+ }
+ }
+ if (mp != (Map_t*)enter(&state.map, (Link_t*)mp))
+ {
+ fprintf(stderr, "%s: %d: %s: duplicate map\n", command, line, mp->link.code);
+ return 1;
+ }
+ break;
+ }
+ }
+ fprintf(hf, "#define LC_language_attribute_max\t\t%d\n", language_attribute_max);
+ fprintf(hf, "#define LC_territory_language_max\t\t%d\n", territory_language_max);
+ fprintf(hf, "\nstruct Lc_s;\n");
+ fprintf(hf, "\ntypedef struct Lc_info_s\n{\n");
+ fprintf(hf, "\tconst struct Lc_s*\tlc;\n");
+ fprintf(hf, "\tunsigned long\t\tnumber;\n");
+ fprintf(hf, "\tvoid*\t\t\tdata;\n");
+ fprintf(hf, "} Lc_info_t;\n");
+ fprintf(hf, "\ntypedef struct Lc_attribute_s\n{\n");
+ fprintf(hf, "\tconst char*\t\tname;\n");
+ fprintf(hf, "\tunsigned long\t\tflags;\n");
+ fprintf(hf, "\tunsigned long\t\tindex;\n");
+ fprintf(hf, "} Lc_attribute_t;\n");
+ fprintf(hf, "\ntypedef struct Lc_charset_s\n{\n");
+ fprintf(hf, "\tconst char*\t\tcode;\n");
+ fprintf(hf, "\tconst char*\t\talternates;\n");
+ fprintf(hf, "\tconst char*\t\tms;\n");
+ fprintf(hf, "\tunsigned long\t\tindex;\n");
+ fprintf(hf, "} Lc_charset_t;\n");
+ fprintf(hf, "\ntypedef struct Lc_language_s\n{\n");
+ fprintf(hf, "\tconst char*\t\tcode;\n");
+ fprintf(hf, "\tconst char*\t\tname;\n");
+ fprintf(hf, "\tconst char*\t\talternates;\n");
+ fprintf(hf, "\tconst Lc_charset_t*\tcharset;\n");
+ fprintf(hf, "\tunsigned long\t\tflags;\n");
+ fprintf(hf, "\tunsigned long\t\tindex;\n");
+ fprintf(hf, "\tconst Lc_attribute_t*\tattributes[LC_language_attribute_max];\n");
+ fprintf(hf, "} Lc_language_t;\n");
+ fprintf(hf, "\ntypedef struct Lc_territory_s\n{\n");
+ fprintf(hf, "\tconst char*\t\tcode;\n");
+ fprintf(hf, "\tconst char*\t\tname;\n");
+ fprintf(hf, "\tunsigned long\t\tflags;\n");
+ fprintf(hf, "\tunsigned long\t\tindex;\n");
+ fprintf(hf, "\tconst Lc_language_t*\tlanguages[LC_territory_language_max];\n");
+ fprintf(hf, "#ifdef _LC_TERRITORY_PRIVATE_\n");
+ fprintf(hf, "\t_LC_TERRITORY_PRIVATE_\n");
+ fprintf(hf, "#endif\n");
+ fprintf(hf, "} Lc_territory_t;\n");
+ fprintf(hf, "\ntypedef struct Lc_map_s\n{\n");
+ fprintf(hf, "\tconst char*\t\tcode;\n");
+ fprintf(hf, "\tconst Lc_language_t*\tlanguage;\n");
+ fprintf(hf, "\tconst Lc_territory_t*\tterritory;\n");
+ fprintf(hf, "\tconst Lc_charset_t*\tcharset;\n");
+ fprintf(hf, "\tconst Lc_attribute_t*\tattribute;\n");
+ fprintf(hf, "} Lc_map_t;\n");
+ fprintf(hf, "\ntypedef struct Lc_attribute_list_s\n{\n");
+ fprintf(hf, "\tstruct Lc_attribute_list_s*\tnext;\n");
+ fprintf(hf, "\tconst Lc_attribute_t*\t\tattribute;\n");
+ fprintf(hf, "} Lc_attribute_list_t;\n");
+ fprintf(hf, "\ntypedef struct Lc_s\n{\n");
+ fprintf(hf, "\tconst char*\t\tname;\n");
+ fprintf(hf, "\tconst char*\t\tcode;\n");
+ fprintf(hf, "\tconst Lc_language_t*\tlanguage;\n");
+ fprintf(hf, "\tconst Lc_territory_t*\tterritory;\n");
+ fprintf(hf, "\tconst Lc_charset_t*\tcharset;\n");
+ fprintf(hf, "\tconst Lc_attribute_list_t*\tattributes;\n");
+ fprintf(hf, "\tunsigned long\t\tflags;\n");
+ fprintf(hf, "\tunsigned long\t\tindex;\n");
+ fprintf(hf, "#ifdef _LC_PRIVATE_\n");
+ fprintf(hf, "\t_LC_PRIVATE_\n");
+ fprintf(hf, "#endif\n");
+ fprintf(hf, "} Lc_t;\n");
+ fprintf(hf, "\nstruct Lc_category_s;\n");
+ fprintf(hf, "\ntypedef int (*Lc_category_set_f)(struct Lc_category_s*);\n");
+ fprintf(hf, "\ntypedef struct Lc_category_s\n{\n");
+ fprintf(hf, "\tconst char*\t\tname;\n");
+ fprintf(hf, "\tint\t\t\texternal;\n");
+ fprintf(hf, "\tint\t\t\tinternal;\n");
+ fprintf(hf, "\tLc_category_set_f\tsetf;\n");
+ fprintf(hf, "\tLc_t*\t\t\tprev;\n");
+ fprintf(hf, "} Lc_category_t;\n");
+ fprintf(hf, "\n");
+ fprintf(hf, "#if _BLD_ast && defined(__EXPORT__)\n");
+ fprintf(hf, "#define extern\t\t__EXPORT__\n");
+ fprintf(hf, "#endif\n");
+ fprintf(hf, "\n");
+ fprintf(hf, "extern size_t\t\tlccanon(Lc_t*, unsigned long flags, char*, size_t);\n");
+ fprintf(hf, "extern Lc_category_t*\tlccategories(void);\n");
+ fprintf(hf, "extern int\t\tlcindex(int, int);\n");
+ fprintf(hf, "extern Lc_info_t*\tlcinfo(int);\n");
+ fprintf(hf, "extern Lc_t*\t\tlcmake(const char*);\n");
+ fprintf(hf, "extern Lc_t*\t\tlcscan(Lc_t*);\n");
+ fprintf(hf, "\n");
+ fprintf(hf, "#undef\textern\n");
+ fprintf(lf, "\nstatic const Lc_charset_t charset[] =\n{\n");
+ for (cp = (Charset_t*)state.charset.root; cp; cp = (Charset_t*)cp->link.next)
+ {
+ fprintf(lf, "{\"%s\",", cp->link.code);
+ if (cp->alternates)
+ fprintf(lf, "\"%s\",", cp->alternates);
+ else
+ fprintf(lf, "0,");
+ if (cp->ms)
+ fprintf(lf, "\"%s\",", cp->ms);
+ else
+ fprintf(lf, "0");
+ fprintf(lf, "},\n");
+ }
+ fprintf(lf, "\t0\n};\n");
+ fprintf(lf, "\nstatic const Lc_language_t language[] =\n{\n");
+ fprintf(lf, "{\"C\",\"C\",\"POSIX\",&charset[0],LC_default,0,");
+ for (i = 0; i < language_attribute_max; i++)
+ fprintf(lf, "0,");
+ fprintf(lf, "},\n");
+ fprintf(lf, "{\"debug\",\"debug\",0,&charset[0],LC_debug,0,");
+ for (i = 0; i < language_attribute_max; i++)
+ fprintf(lf, "0,");
+ fprintf(lf, "},\n");
+ for (lp = (Language_t*)state.language.root; lp; lp = (Language_t*)lp->link.next)
+ {
+ fprintf(lf, "{\"%s\",\"%s\",", lp->link.code, lp->name);
+ if (lp->alternates)
+ fprintf(lf, "\"%s\",", lp->alternates);
+ else
+ fprintf(lf, "0,");
+ fprintf(lf, "&charset[%d],0,", lp->charset ? lp->charset->link.index : 0);
+ macro(lf, "LANG", lp->name, (char*)0);
+ for (i = 0, al = lp->attributes; al; al = al->next, i++)
+ fprintf(lf, "&attribute_%s[%d],", lp->link.code, al->attribute->link.index);
+ for (; i < language_attribute_max; i++)
+ fprintf(lf, "0,");
+ fprintf(lf, "\n},\n");
+ }
+ fprintf(lf, "\t0\n};\n");
+ fprintf(lf, "\nstatic const Lc_territory_t territory[] =\n{\n");
+ fprintf(lf, "{\"C\",\"C\",LC_default,0,&language[0],");
+ for (i = 1; i < 2 * territory_language_max; i++)
+ fprintf(lf, "0,");
+ fprintf(lf, "},\n");
+ fprintf(lf, "{\"debug\",\"debug\",LC_debug,0,&language[1],");
+ for (i = 1; i < 2 * territory_language_max; i++)
+ fprintf(lf, "0,");
+ fprintf(lf, "},\n");
+ for (tp = (Territory_t*)state.territory.root; tp; tp = (Territory_t*)tp->link.next)
+ {
+ fprintf(lf, "{\"%s\",\"%s\",", tp->link.code, tp->name);
+ if (tp->primary)
+ fprintf(lf, "LC_primary,");
+ else
+ fprintf(lf, "0,");
+ macro(lf, "CTRY", tp->name, (char*)0);
+ for (i = 0, ll = tp->languages; ll; ll = ll->next, i++)
+ fprintf(lf, "&language[%d],", ll->language->link.index);
+ for (; i < territory_language_max; i++)
+ fprintf(lf, "0,");
+ for (i = 0, ll = tp->languages; ll; ll = ll->next, i++)
+ macro(lf, "SUBLANG", ll->language->name, tp->name);
+ for (; i < territory_language_max; i++)
+ fprintf(lf, "0,");
+ fprintf(lf, "\n},\n");
+ }
+ fprintf(lf, "\t0\n};\n");
+ fprintf(lf, "\nstatic const Lc_map_t map[] =\n{\n");
+ for (mp = (Map_t*)state.map.root; mp; mp = (Map_t*)mp->link.next)
+ {
+ fprintf(lf, "{\"%s\",", mp->link.code);
+ fprintf(lf, "&language[%d],", mp->language->link.index);
+ fprintf(lf, "&territory[%d],", mp->territory->link.index);
+ fprintf(lf, "&charset[%d],", mp->charset ? mp->charset->link.index : 0);
+ if (mp->attribute)
+ fprintf(lf, "&attribute_%s[%d]", mp->language->link.code, mp->attribute->link.index);
+ else
+ fprintf(lf, "0");
+ fprintf(lf, "},\n");
+ }
+ fprintf(lf, "\t0\n};\n");
+ fclose(lf);
+ fprintf(hf, "\n#endif\n");
+ fclose(hf);
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/port/lclib.h b/usr/src/lib/libast/common/port/lclib.h
new file mode 100644
index 0000000000..898bbe27a4
--- /dev/null
+++ b/usr/src/lib/libast/common/port/lclib.h
@@ -0,0 +1,61 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * locale state private definitions
+ */
+
+#ifndef _LCLIB_H
+#define _LCLIB_H 1
+
+#define categories _ast_categories
+#define locales _ast_locales
+#define translate _ast_translate
+
+struct Lc_info_s;
+
+#define _LC_PRIVATE_ \
+ struct Lc_info_s info[AST_LC_COUNT]; \
+ struct Lc_s* next;
+
+#define _LC_TERRITORY_PRIVATE_ \
+ unsigned char indices[LC_territory_language_max];
+
+#include <ast.h>
+#include <error.h>
+#include <lc.h>
+
+typedef struct Lc_numeric_s
+{
+ int decimal;
+ int thousand;
+} Lc_numeric_t;
+
+#define LCINFO(c) (&locales[c]->info[c])
+
+extern Lc_category_t categories[];
+extern Lc_t* locales[];
+
+extern char* translate(const char*, const char*, const char*, const char*);
+
+#endif
diff --git a/usr/src/lib/libast/common/port/mc.c b/usr/src/lib/libast/common/port/mc.c
new file mode 100644
index 0000000000..8945841ae9
--- /dev/null
+++ b/usr/src/lib/libast/common/port/mc.c
@@ -0,0 +1,677 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * machine independent binary message catalog implementation
+ */
+
+#include "sfhdr.h"
+#include "lclib.h"
+
+#include <iconv.h>
+
+#define _MC_PRIVATE_ \
+ size_t nstrs; \
+ size_t nmsgs; \
+ iconv_t cvt; \
+ Sfio_t* tmp; \
+ Vmalloc_t* vm;
+
+#include <vmalloc.h>
+#include <error.h>
+#include <mc.h>
+#include <nl_types.h>
+
+/*
+ * find the binary message catalog path for <locale,catalog>
+ * result placed in path of size PATH_MAX
+ * pointer to path returned
+ * catalog==0 tests for category directory or file
+ * nls!=0 enables NLSPATH+LANG hack (not implemented yet)
+ */
+
+char*
+mcfind(char* path, const char* locale, const char* catalog, int category, int nls)
+{
+ register int c;
+ register char* s;
+ register char* e;
+ register char* p;
+ register const char* v;
+ int i;
+ int first;
+ int next;
+ int last;
+ int oerrno;
+ Lc_t* lc;
+ char file[PATH_MAX];
+ char* paths[5];
+
+ static char lc_messages[] = "LC_MESSAGES";
+
+ if ((category = lcindex(category, 1)) < 0)
+ return 0;
+ if (!(lc = locale ? lcmake(locale) : locales[category]))
+ return 0;
+ oerrno = errno;
+ if (catalog && *catalog == '/')
+ {
+ i = eaccess(catalog, R_OK);
+ errno = oerrno;
+ if (i)
+ return 0;
+ strncpy(path, catalog, PATH_MAX-1);
+ return path;
+ }
+ i = 0;
+#if !_lib_catopen
+ if ((p = getenv("NLSPATH")) && *p)
+ paths[i++] = p;
+#endif
+ paths[i++] = "share/lib/locale/%l/%C/%N";
+ paths[i++] = "share/locale/%l/%C/%N";
+ paths[i++] = "lib/locale/%l/%C/%N";
+ paths[i] = 0;
+ next = 1;
+ for (i = 0; p = paths[i]; i += next)
+ {
+ first = 1;
+ last = 0;
+ e = &file[elementsof(file) - 1];
+ while (*p)
+ {
+ s = file;
+ for (;;)
+ {
+ switch (c = *p++)
+ {
+ case 0:
+ p--;
+ break;
+ case ':':
+ break;
+ case '%':
+ if (s < e)
+ {
+ switch (c = *p++)
+ {
+ case 0:
+ p--;
+ continue;
+ case 'N':
+ v = catalog;
+ break;
+ case 'L':
+ if (first)
+ {
+ first = 0;
+ if (next)
+ {
+ v = lc->code;
+ if (lc->code != lc->language->code)
+ next = 0;
+ }
+ else
+ {
+ next = 1;
+ v = lc->language->code;
+ }
+ }
+ break;
+ case 'l':
+ v = lc->language->code;
+ break;
+ case 't':
+ v = lc->territory->code;
+ break;
+ case 'c':
+ v = lc->charset->code;
+ break;
+ case 'C':
+ case_C:
+ if (!catalog)
+ last = 1;
+ v = categories[category].name;
+ break;
+ default:
+ *s++ = c;
+ continue;
+ }
+ if (v)
+ while (*v && s < e)
+ *s++ = *v++;
+ }
+ continue;
+ case '/':
+ if (last)
+ break;
+ if (category != AST_LC_MESSAGES && strneq(p, lc_messages, sizeof(lc_messages) - 1) && p[sizeof(lc_messages)-1] == '/')
+ {
+ p += sizeof(lc_messages) - 1;
+ goto case_C;
+ }
+ /*FALLTHROUGH*/
+ default:
+ if (s < e)
+ *s++ = c;
+ continue;
+ }
+ break;
+ }
+ if (s > file)
+ *s = 0;
+ else if (!catalog)
+ continue;
+ else
+ strncpy(file, catalog, elementsof(file));
+ if (ast.locale.set & AST_LC_find)
+ sfprintf(sfstderr, "locale find %s\n", file);
+ if (s = pathpath(path, file, "", (!catalog && category == AST_LC_MESSAGES) ? PATH_READ : (PATH_REGULAR|PATH_READ|PATH_ABSOLUTE)))
+ {
+ if (ast.locale.set & (AST_LC_find|AST_LC_setlocale))
+ sfprintf(sfstderr, "locale path %s\n", s);
+ errno = oerrno;
+ return s;
+ }
+ }
+ }
+ errno = oerrno;
+ return 0;
+}
+
+/*
+ * allocate and read the binary message catalog ip
+ * if ip==0 then space is allocated for mcput()
+ * 0 returned on any error
+ */
+
+Mc_t*
+mcopen(register Sfio_t* ip)
+{
+ register Mc_t* mc;
+ register char** mp;
+ register char* sp;
+ Vmalloc_t* vm;
+ char* rp;
+ int i;
+ int j;
+ int oerrno;
+ size_t n;
+ char buf[MC_MAGIC_SIZE];
+
+ oerrno = errno;
+ if (ip)
+ {
+ /*
+ * check the magic
+ */
+
+ if (sfread(ip, buf, MC_MAGIC_SIZE) != MC_MAGIC_SIZE)
+ {
+ errno = oerrno;
+ return 0;
+ }
+ if (memcmp(buf, MC_MAGIC, MC_MAGIC_SIZE))
+ return 0;
+ }
+
+ /*
+ * allocate the region
+ */
+
+ if (!(vm = vmopen(Vmdcheap, Vmbest, 0)) || !(mc = vmnewof(vm, 0, Mc_t, 1, 0)))
+ {
+ errno = oerrno;
+ return 0;
+ }
+ mc->vm = vm;
+ mc->cvt = (iconv_t)(-1);
+ if (ip)
+ {
+ /*
+ * read the translation record
+ */
+
+ if (!(sp = sfgetr(ip, 0, 0)) || !(mc->translation = vmstrdup(vm, sp)))
+ goto bad;
+
+ /*
+ * read the optional header records
+ */
+
+ do
+ {
+ if (!(sp = sfgetr(ip, 0, 0)))
+ goto bad;
+ } while (*sp);
+
+ /*
+ * get the component dimensions
+ */
+
+ mc->nstrs = sfgetu(ip);
+ mc->nmsgs = sfgetu(ip);
+ mc->num = sfgetu(ip);
+ if (sfeof(ip))
+ goto bad;
+ }
+ else if (!(mc->translation = vmnewof(vm, 0, char, 1, 0)))
+ goto bad;
+
+ /*
+ * allocate the remaining space
+ */
+
+ if (!(mc->set = vmnewof(vm, 0, Mcset_t, mc->num + 1, 0)))
+ goto bad;
+ if (!ip)
+ return mc;
+ if (!(mp = vmnewof(vm, 0, char*, mc->nmsgs + mc->num + 1, 0)))
+ goto bad;
+ if (!(rp = sp = vmalloc(vm, mc->nstrs + 1)))
+ goto bad;
+
+ /*
+ * get the set dimensions and initialize the msg pointers
+ */
+
+ while (i = sfgetu(ip))
+ {
+ if (i > mc->num)
+ goto bad;
+ n = sfgetu(ip);
+ mc->set[i].num = n;
+ mc->set[i].msg = mp;
+ mp += n + 1;
+ }
+
+ /*
+ * read the msg sizes and set up the msg pointers
+ */
+
+ for (i = 1; i <= mc->num; i++)
+ for (j = 1; j <= mc->set[i].num; j++)
+ if (n = sfgetu(ip))
+ {
+ mc->set[i].msg[j] = sp;
+ sp += n;
+ }
+
+ /*
+ * read the string table
+ */
+
+ if (sfread(ip, rp, mc->nstrs) != mc->nstrs || sfgetc(ip) != EOF)
+ goto bad;
+ if (!(mc->tmp = sfstropen()))
+ goto bad;
+ mc->cvt = iconv_open("", "utf");
+ errno = oerrno;
+ return mc;
+ bad:
+ vmclose(vm);
+ errno = oerrno;
+ return 0;
+}
+
+/*
+ * return the <set,num> message in mc
+ * msg returned on error
+ * utf message text converted to ucs
+ */
+
+char*
+mcget(register Mc_t* mc, int set, int num, const char* msg)
+{
+ char* s;
+ size_t n;
+ int p;
+
+ if (!mc || set < 0 || set > mc->num || num < 1 || num > mc->set[set].num || !(s = mc->set[set].msg[num]))
+ return (char*)msg;
+ if (mc->cvt == (iconv_t)(-1))
+ return s;
+ if ((p = sfstrtell(mc->tmp)) > sfstrsize(mc->tmp) / 2)
+ {
+ p = 0;
+ sfstrseek(mc->tmp, p, SEEK_SET);
+ }
+ n = strlen(s) + 1;
+ iconv_write(mc->cvt, mc->tmp, &s, &n, NiL);
+ return sfstrbase(mc->tmp) + p;
+}
+
+/*
+ * set message <set,num> to msg
+ * msg==0 deletes the message
+ * the message and set counts are adjusted
+ * 0 returned on success, -1 otherwise
+ */
+
+int
+mcput(register Mc_t* mc, int set, int num, const char* msg)
+{
+ register int i;
+ register char* s;
+ register Mcset_t* sp;
+ register char** mp;
+
+ /*
+ * validate the arguments
+ */
+
+ if (!mc || set > MC_SET_MAX || num > MC_NUM_MAX)
+ return -1;
+
+ /*
+ * deletions don't kick in allocations (duh)
+ */
+
+ if (!msg)
+ {
+ if (set <= mc->num && num <= mc->set[set].num && (s = mc->set[set].msg[num]))
+ {
+ /*
+ * decrease the string table size
+ */
+
+ mc->set[set].msg[num] = 0;
+ mc->nstrs -= strlen(s) + 1;
+ if (mc->set[set].num == num)
+ {
+ /*
+ * decrease the max msg num
+ */
+
+ mp = mc->set[set].msg + num;
+ while (num && !mp[--num]);
+ mc->nmsgs -= mc->set[set].num - num;
+ if (!(mc->set[set].num = num) && mc->num == set)
+ {
+ /*
+ * decrease the max set num
+ */
+
+ while (num && !mc->set[--num].num);
+ mc->num = num;
+ }
+ }
+ }
+ return 0;
+ }
+
+ /*
+ * keep track of the highest set and allocate if necessary
+ */
+
+ if (set > mc->num)
+ {
+ if (set > mc->gen)
+ {
+ i = MC_SET_MAX;
+ if (!(sp = vmnewof(mc->vm, 0, Mcset_t, i + 1, 0)))
+ return -1;
+ mc->gen = i;
+ for (i = 1; i <= mc->num; i++)
+ sp[i] = mc->set[i];
+ mc->set = sp;
+ }
+ mc->num = set;
+ }
+ sp = mc->set + set;
+
+ /*
+ * keep track of the highest msg and allocate if necessary
+ */
+
+ if (num > sp->num)
+ {
+ if (num > sp->gen)
+ {
+ if (!mc->gen)
+ {
+ i = (MC_NUM_MAX + 1) / 32;
+ if (i <= num)
+ i = 2 * num;
+ if (i > MC_NUM_MAX)
+ i = MC_NUM_MAX;
+ if (!(mp = vmnewof(mc->vm, 0, char*, i + 1, 0)))
+ return -1;
+ mc->gen = i;
+ sp->msg = mp;
+ for (i = 1; i <= sp->num; i++)
+ mp[i] = sp->msg[i];
+ }
+ else
+ {
+ i = 2 * mc->gen;
+ if (i > MC_NUM_MAX)
+ i = MC_NUM_MAX;
+ if (!(mp = vmnewof(mc->vm, sp->msg, char*, i + 1, 0)))
+ return -1;
+ sp->gen = i;
+ sp->msg = mp;
+ }
+ }
+ mc->nmsgs += num - sp->num;
+ sp->num = num;
+ }
+
+ /*
+ * decrease the string table size
+ */
+
+ if (s = sp->msg[num])
+ {
+ /*
+ * no-op if no change
+ */
+
+ if (streq(s, msg))
+ return 0;
+ mc->nstrs -= strlen(s) + 1;
+ }
+
+ /*
+ * allocate, add and adjust the string table size
+ */
+
+ if (!(s = vmstrdup(mc->vm, msg)))
+ return -1;
+ sp->msg[num] = s;
+ mc->nstrs += strlen(s) + 1;
+ return 0;
+}
+
+/*
+ * dump message catalog mc to op
+ * 0 returned on success, -1 otherwise
+ */
+
+int
+mcdump(register Mc_t* mc, register Sfio_t* op)
+{
+ register int i;
+ register int j;
+ register int n;
+ register char* s;
+ register Mcset_t* sp;
+
+ /*
+ * write the magic
+ */
+
+ if (sfwrite(op, MC_MAGIC, MC_MAGIC_SIZE) != MC_MAGIC_SIZE)
+ return -1;
+
+ /*
+ * write the translation record
+ */
+
+ sfputr(op, mc->translation, 0);
+
+ /* optional header records here */
+
+ /*
+ * end of optional header records
+ */
+
+ sfputu(op, 0);
+
+ /*
+ * write the global dimensions
+ */
+
+ sfputu(op, mc->nstrs);
+ sfputu(op, mc->nmsgs);
+ sfputu(op, mc->num);
+
+ /*
+ * write the set dimensions
+ */
+
+ for (i = 1; i <= mc->num; i++)
+ if (mc->set[i].num)
+ {
+ sfputu(op, i);
+ sfputu(op, mc->set[i].num);
+ }
+ sfputu(op, 0);
+
+ /*
+ * write the message sizes
+ */
+
+ for (i = 1; i <= mc->num; i++)
+ if (mc->set[i].num)
+ {
+ sp = mc->set + i;
+ for (j = 1; j <= sp->num; j++)
+ {
+ n = (s = sp->msg[j]) ? (strlen(s) + 1) : 0;
+ sfputu(op, n);
+ }
+ }
+
+ /*
+ * write the string table
+ */
+
+ for (i = 1; i <= mc->num; i++)
+ if (mc->set[i].num)
+ {
+ sp = mc->set + i;
+ for (j = 1; j <= sp->num; j++)
+ if (s = sp->msg[j])
+ sfputr(op, s, 0);
+ }
+
+ /*
+ * sync and return
+ */
+
+ return sfsync(op);
+}
+
+/*
+ * parse <set,msg> number from s
+ * e!=0 is set to the next char after the parse
+ * set!=0 is set to message set number
+ * msg!=0 is set to message number
+ * the message set number is returned
+ *
+ * the base 36 hash gives reasonable values for these:
+ *
+ * "ast" : ((((36#a^36#s^36#t)-9)&63)+1) = 3
+ * "gnu" : ((((36#g^36#n^36#u)-9)&63)+1) = 17
+ * "sgi" : ((((36#s^36#g^36#i)-9)&63)+1) = 22
+ * "sun" : ((((36#s^36#u^36#n)-9)&63)+1) = 13
+ */
+
+int
+mcindex(register const char* s, char** e, int* set, int* msg)
+{
+ register int c;
+ register int m;
+ register int n;
+ register int r;
+ register unsigned char* cv;
+ char* t;
+
+ m = 0;
+ n = strtol(s, &t, 0);
+ if (t == (char*)s)
+ {
+ SFCVINIT();
+ cv = _Sfcv36;
+ for (n = m = 0; (c = cv[*s]) < 36; s++)
+ {
+ m++;
+ n ^= c;
+ }
+ m = (m <= 3) ? 63 : ((1 << (m + 3)) - 1);
+ n = ((n - 9) & m) + 1;
+ }
+ else
+ s = (const char*)t;
+ r = n;
+ if (*s)
+ m = strtol(s + 1, e, 0);
+ else
+ {
+ if (e)
+ *e = (char*)s;
+ if (m)
+ m = 0;
+ else
+ {
+ m = n;
+ n = 1;
+ }
+ }
+ if (set)
+ *set = n;
+ if (msg)
+ *msg = m;
+ return r;
+}
+
+/*
+ * close the message catalog mc
+ */
+
+int
+mcclose(register Mc_t* mc)
+{
+ if (!mc)
+ return -1;
+ if (mc->tmp)
+ sfclose(mc->tmp);
+ if (mc->cvt != (iconv_t)(-1))
+ iconv_close(mc->cvt);
+ vmclose(mc->vm);
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/port/mnt.c b/usr/src/lib/libast/common/port/mnt.c
new file mode 100644
index 0000000000..fb8c6332fa
--- /dev/null
+++ b/usr/src/lib/libast/common/port/mnt.c
@@ -0,0 +1,792 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * mounted filesystem scan support
+ * where are the standards when you really need them
+ */
+
+#include <ast.h>
+#include <mnt.h>
+#include <ls.h>
+
+#if _lib_mntopen && _lib_mntread && _lib_mntclose
+
+NoN(mnt)
+
+#else
+
+/*
+ * the original interface just had mode
+ */
+
+#define FIXARGS(p,m,s) do { \
+ if ((p)&&*(p)!='/') { \
+ mode = p; \
+ path = 0; \
+ } \
+ if (!path) \
+ path = s; \
+ } while (0)
+typedef struct
+{
+ Mnt_t mnt;
+ char buf[128];
+#if __CYGWIN__
+ char typ[128];
+ char opt[128];
+#endif
+} Header_t;
+
+#if __CYGWIN__
+#include <ast_windows.h>
+#endif
+
+static void
+set(register Header_t* hp, const char* fs, const char* dir, const char* type, const char* options)
+{
+ const char* x;
+
+ hp->mnt.flags = 0;
+ if (x = (const char*)strchr(fs, ':'))
+ {
+ if (*++x && *x != '\\')
+ {
+ hp->mnt.flags |= MNT_REMOTE;
+ if (*x == '(')
+ {
+ fs = x;
+ type = "auto";
+ }
+ }
+ }
+ else if (x = (const char*)strchr(fs, '@'))
+ {
+ hp->mnt.flags |= MNT_REMOTE;
+ sfsprintf(hp->buf, sizeof(hp->buf) - 1, "%s:%*.*s", x + 1, x - fs, x - fs, fs);
+ fs = (const char*)hp->buf;
+ }
+ else if (strmatch(type, "[aAnN][fF][sS]*"))
+ hp->mnt.flags |= MNT_REMOTE;
+ if (streq(fs, "none"))
+ fs = dir;
+ hp->mnt.fs = (char*)fs;
+ hp->mnt.dir = (char*)dir;
+ hp->mnt.type = (char*)type;
+ hp->mnt.options = (char*)options;
+#if __CYGWIN__
+ if (streq(type, "system") || streq(type, "user"))
+ {
+ char* s;
+ int mode;
+ DWORD vser;
+ DWORD flags;
+ DWORD len;
+ char drive[4];
+
+ mode = SetErrorMode(SEM_FAILCRITICALERRORS);
+ drive[0] = fs[0];
+ drive[1] = ':';
+ drive[2] = '\\';
+ drive[3] = 0;
+ if (GetVolumeInformation(drive, 0, 0, &vser, &len, &flags, hp->typ, sizeof(hp->typ) - 1))
+ hp->mnt.type = hp->typ;
+ else
+ flags = 0;
+ SetErrorMode(mode);
+ s = strcopy(hp->mnt.options = hp->opt, type);
+ s = strcopy(s, ",ignorecase");
+ if (options)
+ {
+ *s++ = ',';
+ strcpy(s, options);
+ }
+ }
+#endif
+}
+
+#undef MNT_REMOTE
+
+#if _lib_getmntinfo && _sys_mount
+
+/*
+ * 4.4 bsd
+ *
+ * what a crappy interface
+ * data returned in static buffer -- ok
+ * big chunk of allocated memory that cannot be freed -- come on
+ * *and* netbsd changed the interface somewhere along the line
+ * private interface? my bad -- public interface? par for the bsd course
+ */
+
+#include <sys/param.h> /* expect some macro redefinitions here */
+#include <sys/mount.h>
+
+#if _lib_getmntinfo_statvfs
+#define statfs statvfs
+#define f_flags f_flag
+#endif
+
+typedef struct
+{
+ Header_t hdr;
+ struct statfs* next;
+ struct statfs* last;
+ char opt[256];
+} Handle_t;
+
+#ifdef MFSNAMELEN
+#define TYPE(f) ((f)->f_fstypename)
+#else
+#ifdef INITMOUNTNAMES
+#define TYPE(f) ((char*)type[(f)->f_type])
+static const char* type[] = INITMOUNTNAMES;
+#else
+#if _sys_fs_types
+#define TYPE(f) ((char*)mnt_names[(f)->f_type])
+#include <sys/fs_types.h>
+#else
+#define TYPE(f) (strchr((f)->f_mntfromname,':')?"nfs":"ufs")
+#endif
+#endif
+#endif
+
+static struct Mnt_options_t
+{
+ unsigned long flag;
+ const char* name;
+}
+options[] =
+{
+#ifdef MNT_RDONLY
+ MNT_RDONLY, "rdonly",
+#endif
+#ifdef MNT_SYNCHRONOUS
+ MNT_SYNCHRONOUS,"synchronous",
+#endif
+#ifdef MNT_NOEXEC
+ MNT_NOEXEC, "noexec",
+#endif
+#ifdef MNT_NOSUID
+ MNT_NOSUID, "nosuid",
+#endif
+#ifdef MNT_NODEV
+ MNT_NODEV, "nodev",
+#endif
+#ifdef MNT_UNION
+ MNT_UNION, "union",
+#endif
+#ifdef MNT_ASYNC
+ MNT_ASYNC, "async",
+#endif
+#ifdef MNT_NOCOREDUMP
+ MNT_NOCOREDUMP, "nocoredump",
+#endif
+#ifdef MNT_NOATIME
+ MNT_NOATIME, "noatime",
+#endif
+#ifdef MNT_SYMPERM
+ MNT_SYMPERM, "symperm",
+#endif
+#ifdef MNT_NODEVMTIME
+ MNT_NODEVMTIME, "nodevmtime",
+#endif
+#ifdef MNT_SOFTDEP
+ MNT_SOFTDEP, "softdep",
+#endif
+#ifdef MNT_EXRDONLY
+ MNT_EXRDONLY, "exrdonly",
+#endif
+#ifdef MNT_EXPORTED
+ MNT_EXPORTED, "exported",
+#endif
+#ifdef MNT_DEFEXPORTED
+ MNT_DEFEXPORTED,"defexported",
+#endif
+#ifdef MNT_EXPORTANON
+ MNT_EXPORTANON, "exportanon",
+#endif
+#ifdef MNT_EXKERB
+ MNT_EXKERB, "exkerb",
+#endif
+#ifdef MNT_EXNORESPORT
+ MNT_EXNORESPORT,"exnoresport",
+#endif
+#ifdef MNT_EXPUBLIC
+ MNT_EXPUBLIC, "expublic",
+#endif
+#ifdef MNT_LOCAL
+ MNT_LOCAL, "local",
+#endif
+#ifdef MNT_QUOTA
+ MNT_QUOTA, "quota",
+#endif
+#ifdef MNT_ROOTFS
+ MNT_ROOTFS, "rootfs",
+#endif
+ 0, "unknown",
+};
+
+void*
+mntopen(const char* path, const char* mode)
+{
+ register Handle_t* mp;
+ register int n;
+
+ FIXARGS(path, mode, 0);
+ if (!(mp = newof(0, Handle_t, 1, 0)))
+ return 0;
+ if ((n = getmntinfo(&mp->next, 0)) <= 0)
+ {
+ free(mp);
+ return 0;
+ }
+ mp->last = mp->next + n;
+ return (void*)mp;
+}
+
+Mnt_t*
+mntread(void* handle)
+{
+ register Handle_t* mp = (Handle_t*)handle;
+ register int i;
+ register int n;
+ register unsigned long flags;
+
+ if (mp->next < mp->last)
+ {
+ flags = mp->next->f_flags;
+ n = 0;
+ for (i = 0; i < elementsof(options); i++)
+ if (flags & options[i].flag)
+ n += sfsprintf(mp->opt + n, sizeof(mp->opt) - n - 1, ",%s", options[i].name);
+ set(&mp->hdr, mp->next->f_mntfromname, mp->next->f_mntonname, TYPE(mp->next), n ? (mp->opt + 1) : (char*)0);
+ mp->next++;
+ return &mp->hdr.mnt;
+ }
+ return 0;
+}
+
+int
+mntclose(void* handle)
+{
+ register Handle_t* mp = (Handle_t*)handle;
+
+ if (!mp)
+ return -1;
+ free(mp);
+ return 0;
+}
+
+#else
+
+#if _lib_mntctl && _sys_vmount
+
+/*
+ * aix
+ */
+
+#include <sys/vmount.h>
+
+#define SIZE (16 * 1024)
+
+static const char* type[] =
+{
+ "aix", "aix#1", "nfs", "jfs", "aix#4", "cdrom"
+};
+
+typedef struct
+{
+ Header_t hdr;
+ long count;
+ struct vmount* next;
+ char remote[128];
+ char type[16];
+ struct vmount info[1];
+} Handle_t;
+
+void*
+mntopen(const char* path, const char* mode)
+{
+ register Handle_t* mp;
+
+ FIXARGS(path, mode, 0);
+ if (!(mp = newof(0, Handle_t, 1, SIZE)))
+ return 0;
+ if ((mp->count = mntctl(MCTL_QUERY, sizeof(Handle_t) + SIZE, &mp->info)) <= 0)
+ {
+ free(mp);
+ return 0;
+ }
+ mp->next = mp->info;
+ return (void*)mp;
+}
+
+Mnt_t*
+mntread(void* handle)
+{
+ register Handle_t* mp = (Handle_t*)handle;
+ register char* s;
+ register char* t;
+ register char* o;
+
+ if (mp->count > 0)
+ {
+ if (vmt2datasize(mp->next, VMT_HOST) && (s = vmt2dataptr(mp->next, VMT_HOST)) && !streq(s, "-"))
+ {
+ sfsprintf(mp->remote, sizeof(mp->remote) - 1, "%s:%s", s, vmt2dataptr(mp->next, VMT_OBJECT));
+ s = mp->remote;
+ }
+ else
+ s = vmt2dataptr(mp->next, VMT_OBJECT);
+ if (vmt2datasize(mp->next, VMT_ARGS))
+ o = vmt2dataptr(mp->next, VMT_ARGS);
+ else
+ o = NiL;
+ switch (mp->next->vmt_gfstype)
+ {
+#ifdef MNT_AIX
+ case MNT_AIX:
+ t = "aix";
+ break;
+#endif
+#ifdef MNT_NFS
+ case MNT_NFS:
+ t = "nfs";
+ break;
+#endif
+#ifdef MNT_JFS
+ case MNT_JFS:
+ t = "jfs";
+ break;
+#endif
+#ifdef MNT_CDROM
+ case MNT_CDROM:
+ t = "cdrom";
+ break;
+#endif
+#ifdef MNT_SFS
+ case MNT_SFS:
+ t = "sfs";
+ break;
+#endif
+#ifdef MNT_CACHEFS
+ case MNT_CACHEFS:
+ t = "cachefs";
+ break;
+#endif
+#ifdef MNT_NFS3
+ case MNT_NFS3:
+ t = "nfs3";
+ break;
+#endif
+#ifdef MNT_AUTOFS
+ case MNT_AUTOFS:
+ t = "autofs";
+ break;
+#endif
+ default:
+ sfsprintf(t = mp->type, sizeof(mp->type), "aix%+d", mp->next->vmt_gfstype);
+ break;
+ }
+ set(&mp->hdr, s, vmt2dataptr(mp->next, VMT_STUB), t, o);
+ if (--mp->count > 0)
+ mp->next = (struct vmount*)((char*)mp->next + mp->next->vmt_length);
+ return &mp->hdr.mnt;
+ }
+ return 0;
+}
+
+int
+mntclose(void* handle)
+{
+ register Handle_t* mp = (Handle_t*)handle;
+
+ if (!mp)
+ return -1;
+ free(mp);
+ return 0;
+}
+
+#else
+
+#if !_lib_setmntent
+#undef _lib_getmntent
+#if !_SCO_COFF && !_SCO_ELF && !_UTS
+#undef _hdr_mnttab
+#endif
+#endif
+
+#if _lib_getmntent && ( _hdr_mntent || _sys_mntent && !_sys_mnttab )
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide endmntent getmntent
+#else
+#define endmntent ______endmntent
+#define getmntent ______getmntent
+#endif
+
+#include <stdio.h>
+#if _hdr_mntent
+#include <mntent.h>
+#else
+#include <sys/mntent.h>
+#endif
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide endmntent getmntent
+#else
+#undef endmntent
+#undef getmntent
+#endif
+
+extern int endmntent(FILE*);
+extern struct mntent* getmntent(FILE*);
+
+#else
+
+#undef _lib_getmntent
+
+#if _hdr_mnttab
+#include <mnttab.h>
+#else
+#if _sys_mnttab
+#include <sys/mnttab.h>
+#endif
+#endif
+
+#endif
+
+#ifndef MOUNTED
+#ifdef MNT_MNTTAB
+#define MOUNTED MNT_MNTTAB
+#else
+#if _hdr_mnttab || _sys_mnttab
+#define MOUNTED "/etc/mnttab"
+#else
+#define MOUNTED "/etc/mtab"
+#endif
+#endif
+#endif
+
+#ifdef __Lynx__
+#undef MOUNTED
+#define MOUNTED "/etc/fstab"
+#define SEP ':'
+#endif
+
+#if _lib_getmntent
+
+typedef struct
+#if _mem_mnt_opts_mntent
+#define OPTIONS(p) ((p)->mnt_opts)
+#else
+#define OPTIONS(p) NiL
+#endif
+
+{
+ Header_t hdr;
+ FILE* fp;
+} Handle_t;
+
+void*
+mntopen(const char* path, const char* mode)
+{
+ register Handle_t* mp;
+
+ FIXARGS(path, mode, MOUNTED);
+ if (!(mp = newof(0, Handle_t, 1, 0)))
+ return 0;
+ if (!(mp->fp = setmntent(path, mode)))
+ {
+ free(mp);
+ return 0;
+ }
+ return (void*)mp;
+}
+
+Mnt_t*
+mntread(void* handle)
+{
+ register Handle_t* mp = (Handle_t*)handle;
+ register struct mntent* mnt;
+
+ if (mnt = getmntent(mp->fp))
+ {
+ set(&mp->hdr, mnt->mnt_fsname, mnt->mnt_dir, mnt->mnt_type, OPTIONS(mnt));
+ return &mp->hdr.mnt;
+ }
+ return 0;
+}
+
+int
+mntclose(void* handle)
+{
+ register Handle_t* mp = (Handle_t*)handle;
+
+ if (!mp)
+ return -1;
+ endmntent(mp->fp);
+ free(mp);
+ return 0;
+}
+
+#else
+
+#if _sys_mntent && _lib_w_getmntent
+
+#include <sys/mntent.h>
+
+#define mntent w_mntent
+
+#define mnt_dir mnt_mountpoint
+#define mnt_type mnt_fstname
+
+#define MNTBUFSIZE (sizeof(struct w_mnth)+16*sizeof(struct w_mntent))
+
+#if _mem_mnt_opts_w_mntent
+#define OPTIONS(p) ((p)->mnt_opts)
+#else
+#define OPTIONS(p) NiL
+#endif
+
+#else
+
+#undef _lib_w_getmntent
+
+#define MNTBUFSIZE sizeof(struct mntent)
+
+#if !_mem_mt_dev_mnttab || !_mem_mt_filsys_mnttab
+#undef _hdr_mnttab
+#endif
+
+#if _hdr_mnttab
+
+#define mntent mnttab
+
+#define mnt_fsname mt_dev
+#define mnt_dir mt_filsys
+#if _mem_mt_fstyp_mnttab
+#define mnt_type mt_fstyp
+#endif
+
+#if _mem_mnt_opts_mnttab
+#define OPTIONS(p) ((p)->mnt_opts)
+#else
+#define OPTIONS(p) NiL
+#endif
+
+#else
+
+struct mntent
+{
+ char mnt_fsname[256];
+ char mnt_dir[256];
+ char mnt_type[32];
+ char mnt_opts[64];
+};
+
+#define OPTIONS(p) ((p)->mnt_opts)
+
+#endif
+
+#endif
+
+typedef struct
+{
+ Header_t hdr;
+ Sfio_t* fp;
+ struct mntent* mnt;
+#if _lib_w_getmntent
+ int count;
+#endif
+ char buf[MNTBUFSIZE];
+} Handle_t;
+
+void*
+mntopen(const char* path, const char* mode)
+{
+ register Handle_t* mp;
+
+ FIXARGS(path, mode, MOUNTED);
+ if (!(mp = newof(0, Handle_t, 1, 0)))
+ return 0;
+#if _lib_w_getmntent
+ if ((mp->count = w_getmntent(mp->buf, sizeof(mp->buf))) > 0)
+ mp->mnt = (struct mntent*)(((struct w_mnth*)mp->buf) + 1);
+ else
+#else
+ mp->mnt = (struct mntent*)mp->buf;
+ if (!(mp->fp = sfopen(NiL, path, mode)))
+#endif
+ {
+ free(mp);
+ return 0;
+ }
+ return (void*)mp;
+}
+
+Mnt_t*
+mntread(void* handle)
+{
+ register Handle_t* mp = (Handle_t*)handle;
+
+#if _lib_w_getmntent
+
+ if (mp->count-- <= 0)
+ {
+ if ((mp->count = w_getmntent(mp->buf, sizeof(mp->buf))) <= 0)
+ return 0;
+ mp->count--;
+ mp->mnt = (struct mntent*)(((struct w_mnth*)mp->buf) + 1);
+ }
+ set(&mp->hdr, mp->mnt->mnt_fsname, mp->mnt->mnt_dir, mp->mnt->mnt_type, OPTIONS(mp->mnt));
+ mp->mnt++;
+ return &mp->hdr.mnt;
+
+#else
+
+#if _hdr_mnttab
+
+ while (sfread(mp->fp, &mp->buf, sizeof(mp->buf)) == sizeof(mp->buf))
+ if (*mp->mnt->mnt_fsname && *mp->mnt->mnt_dir)
+ {
+#ifndef mnt_type
+ struct stat st;
+
+ static char typ[32];
+
+ set(&mp->hdr, mp->mnt->mnt_fsname, mp->mnt->mnt_dir, stat(mp->mnt->mnt_dir, &st) ? FS_default : strncpy(typ, fmtfs(&st), sizeof(typ) - 1), OPTIONS(mp->mnt));
+#else
+ set(&mp->hdr, mp->mnt->mnt_fsname, mp->mnt->mnt_dir, mp->mnt->mnt_type, OPTIONS(mp->mnt));
+#endif
+ return &mp->hdr.mnt;
+ }
+ return 0;
+
+#else
+
+ register int c;
+ register char* s;
+ register char* m;
+ register char* b;
+ register int q;
+ register int x;
+
+ again:
+ q = 0;
+ x = 0;
+ b = s = mp->mnt->mnt_fsname;
+ m = s + sizeof(mp->mnt->mnt_fsname) - 1;
+ for (;;) switch (c = sfgetc(mp->fp))
+ {
+ case EOF:
+ return 0;
+ case '"':
+ case '\'':
+ if (q == c)
+ q = 0;
+ else if (!q)
+ q = c;
+ break;
+#ifdef SEP
+ case SEP:
+#else
+ case ' ':
+ case '\t':
+#endif
+ if (s != b && !q) switch (++x)
+ {
+ case 1:
+ *s = 0;
+ b = s = mp->mnt->mnt_dir;
+ m = s + sizeof(mp->mnt->mnt_dir) - 1;
+ break;
+ case 2:
+ *s = 0;
+ b = s = mp->mnt->mnt_type;
+ m = s + sizeof(mp->mnt->mnt_type) - 1;
+ break;
+ case 3:
+ *s = 0;
+ b = s = mp->mnt->mnt_opts;
+ m = s + sizeof(mp->mnt->mnt_opts) - 1;
+ break;
+ case 4:
+ *s = 0;
+ b = s = m = 0;
+ break;
+ }
+ break;
+ case '\n':
+ if (x >= 3)
+ {
+ set(&mp->hdr, mp->mnt->mnt_fsname, mp->mnt->mnt_dir, mp->mnt->mnt_type, OPTIONS(mp->mnt));
+ return &mp->hdr.mnt;
+ }
+ goto again;
+ default:
+ if (s < m)
+ *s++ = c;
+ break;
+ }
+
+#endif
+
+#endif
+
+}
+
+int
+mntclose(void* handle)
+{
+ register Handle_t* mp = (Handle_t*)handle;
+
+ if (!mp)
+ return -1;
+ sfclose(mp->fp);
+ free(mp);
+ return 0;
+}
+
+#endif
+
+#endif
+
+#endif
+
+/*
+ * currently no write
+ */
+
+int
+mntwrite(void* handle, const Mnt_t* mnt)
+{
+ NoP(handle);
+ NoP(mnt);
+ return -1;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/port/touch.c b/usr/src/lib/libast/common/port/touch.c
new file mode 100644
index 0000000000..89403c80cb
--- /dev/null
+++ b/usr/src/lib/libast/common/port/touch.c
@@ -0,0 +1,74 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * touch file access and modify times of file
+ * if flags&PATH_TOUCH_CREATE then file will be created if it doesn't exist
+ * if flags&PATH_TOUCH_VERBATIM then times are taken verbatim
+ * times have one second granularity
+ *
+ * (time_t)(-1) retain old time
+ * 0 use current time
+ *
+ * the old interface flag values were:
+ * 1 PATH_TOUCH_CREATE
+ * -1 PATH_TOUCH_CREATE|PATH_TOUCH_VERBATIM
+ * PATH_TOUCH_VERBATIM -- not supported
+ */
+
+#include <ast.h>
+#include <times.h>
+#include <tv.h>
+
+int
+touch(const char* path, time_t at, time_t mt, int flags)
+{
+ Tv_t av;
+ Tv_t mv;
+ Tv_t* ap;
+ Tv_t* mp;
+
+ if (at == (time_t)(-1) && !(flags & PATH_TOUCH_VERBATIM))
+ ap = TV_TOUCH_RETAIN;
+ else if (!at && !(flags & PATH_TOUCH_VERBATIM))
+ ap = 0;
+ else
+ {
+ av.tv_sec = at;
+ av.tv_nsec = 0;
+ ap = &av;
+ }
+ if (mt == (time_t)(-1) && !(flags & PATH_TOUCH_VERBATIM))
+ mp = TV_TOUCH_RETAIN;
+ else if (!mt && !(flags & PATH_TOUCH_VERBATIM))
+ mp = 0;
+ else
+ {
+ mv.tv_sec = mt;
+ mv.tv_nsec = 0;
+ mp = &mv;
+ }
+ return tvtouch(path, ap, mp, NiL, flags & 1);
+}
diff --git a/usr/src/lib/libast/common/preroot/getpreroot.c b/usr/src/lib/libast/common/preroot/getpreroot.c
new file mode 100644
index 0000000000..a35915d52d
--- /dev/null
+++ b/usr/src/lib/libast/common/preroot/getpreroot.c
@@ -0,0 +1,165 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * AT&T Bell Laboratories
+ * return the real absolute pathname of the preroot dir for cmd
+ * if cmd==0 then current preroot path returned
+ */
+
+#include <ast.h>
+#include <preroot.h>
+
+#if FS_PREROOT
+
+#include <ast_dir.h>
+#include <ls.h>
+#include <error.h>
+#include <stdio.h>
+
+#ifndef ERANGE
+#define ERANGE E2BIG
+#endif
+
+#define ERROR(e) {errno=e;goto error;}
+
+char*
+getpreroot(char* path, const char* cmd)
+{
+ register int c;
+ register FILE* fp;
+ register char* p;
+ char buf[PATH_MAX];
+
+ if (!path) path = buf;
+ if (cmd)
+ {
+ sfsprintf(buf, sizeof(buf), "set x `%s= %s - </dev/null 2>&1`\nwhile :\ndo\nshift\ncase $# in\n[012]) break ;;\nesac\ncase \"$1 $2\" in\n\"+ %s\") echo $3; exit ;;\nesac\ndone\necho\n", PR_SILENT, cmd, PR_COMMAND);
+ if (!(fp = popen(buf, "rug"))) return(0);
+ for (p = path; (c = getc(fp)) != EOF && c != '\n'; *p++ = c);
+ *p = 0;
+ pclose(fp);
+ if (path == p) return(0);
+ return(path == buf ? strdup(path) : path);
+ }
+ else
+ {
+ char* d;
+ DIR* dirp = 0;
+ int namlen;
+ int euid;
+ int ruid;
+ struct dirent* entry;
+ struct stat* cur;
+ struct stat* par;
+ struct stat* tmp;
+ struct stat curst;
+ struct stat parst;
+ struct stat tstst;
+ char dots[PATH_MAX];
+
+ cur = &curst;
+ par = &parst;
+ if ((ruid = getuid()) != (euid = geteuid())) setuid(ruid);
+ if (stat(PR_REAL, cur) || stat("/", par) || cur->st_dev == par->st_dev && cur->st_ino == par->st_ino) ERROR(ENOTDIR);
+
+ /*
+ * like getcwd() but starting at the preroot
+ */
+
+ d = dots;
+ *d++ = '/';
+ p = path + PATH_MAX - 1;
+ *p = 0;
+ for (;;)
+ {
+ tmp = cur;
+ cur = par;
+ par = tmp;
+ if ((d - dots) > (PATH_MAX - 4)) ERROR(ERANGE);
+ *d++ = '.';
+ *d++ = '.';
+ *d = 0;
+ if (!(dirp = opendir(dots))) ERROR(errno);
+#if !_dir_ok || _mem_dd_fd_DIR
+ if (fstat(dirp->dd_fd, par)) ERROR(errno);
+#else
+ if (stat(dots, par)) ERROR(errno);
+#endif
+ *d++ = '/';
+ if (par->st_dev == cur->st_dev)
+ {
+ if (par->st_ino == cur->st_ino)
+ {
+ closedir(dirp);
+ *--p = '/';
+ if (ruid != euid) setuid(euid);
+ if (path == buf) return(strdup(p));
+ if (path != p)
+ {
+ d = path;
+ while (*d++ = *p++);
+ }
+ return(path);
+ }
+#ifdef D_FILENO
+ while (entry = readdir(dirp))
+ if (D_FILENO(entry) == cur->st_ino)
+ {
+ namlen = D_NAMLEN(entry);
+ goto found;
+ }
+#endif
+
+ /*
+ * this fallthrough handles logical naming
+ */
+
+ rewinddir(dirp);
+ }
+ do
+ {
+ if (!(entry = readdir(dirp))) ERROR(ENOENT);
+ namlen = D_NAMLEN(entry);
+ if ((d - dots) > (PATH_MAX - 1 - namlen)) ERROR(ERANGE);
+ memcpy(d, entry->d_name, namlen + 1);
+ if (stat(dots, &tstst)) ERROR(errno);
+ } while (tstst.st_ino != cur->st_ino || tstst.st_dev != cur->st_dev);
+ found:
+ if (*p) *--p = '/';
+ if ((p -= namlen) <= (path + 1)) ERROR(ERANGE);
+ memcpy(p, entry->d_name, namlen);
+ closedir(dirp);
+ dirp = 0;
+ }
+ error:
+ if (dirp) closedir(dirp);
+ if (ruid != euid) setuid(euid);
+ }
+ return(0);
+}
+
+#else
+
+NoN(getpreroot)
+
+#endif
diff --git a/usr/src/lib/libast/common/preroot/ispreroot.c b/usr/src/lib/libast/common/preroot/ispreroot.c
new file mode 100644
index 0000000000..540c42df50
--- /dev/null
+++ b/usr/src/lib/libast/common/preroot/ispreroot.c
@@ -0,0 +1,71 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * AT&T Bell Laboratories
+ * return 1 if dir [any dir] is the preroot
+ */
+
+#include <ast.h>
+#include <preroot.h>
+
+#if FS_PREROOT
+
+#include <ls.h>
+
+/*
+ * return 1 if files a and b are the same under preroot
+ *
+ * NOTE: the kernel disables preroot for set-uid processes
+ */
+
+static int
+same(const char* a, const char* b)
+{
+ int i;
+ int euid;
+ int ruid;
+
+ struct stat ast;
+ struct stat bst;
+
+ if ((ruid = getuid()) != (euid = geteuid())) setuid(ruid);
+ i = !stat(a, &ast) && !stat(b, &bst) && ast.st_dev == bst.st_dev && ast.st_ino == bst.st_ino;
+ if (ruid != euid) setuid(euid);
+ return(i);
+}
+
+int
+ispreroot(const char* dir)
+{
+ static int prerooted = -1;
+
+ if (dir) return(same("/", dir));
+ if (prerooted < 0) prerooted = !same("/", PR_REAL);
+ return(prerooted);
+}
+
+#else
+
+NoN(ispreroot)
+
+#endif
diff --git a/usr/src/lib/libast/common/preroot/realopen.c b/usr/src/lib/libast/common/preroot/realopen.c
new file mode 100644
index 0000000000..a13fb0ac22
--- /dev/null
+++ b/usr/src/lib/libast/common/preroot/realopen.c
@@ -0,0 +1,47 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * AT&T Bell Laboratories
+ * disable preroot and open path relative to the real root
+ */
+
+#include <ast.h>
+#include <preroot.h>
+
+#if FS_PREROOT
+
+int
+realopen(const char* path, int mode, int perm)
+{
+ char buf[PATH_MAX + 8];
+
+ if (*path != '/' || !ispreroot(NiL)) return(-1);
+ strcopy(strcopy(buf, PR_REAL), path);
+ return(open(buf, mode, perm));
+}
+
+#else
+
+NoN(realopen)
+
+#endif
diff --git a/usr/src/lib/libast/common/preroot/setpreroot.c b/usr/src/lib/libast/common/preroot/setpreroot.c
new file mode 100644
index 0000000000..5863d14d28
--- /dev/null
+++ b/usr/src/lib/libast/common/preroot/setpreroot.c
@@ -0,0 +1,75 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * AT&T Bell Laboratories
+ * force current command to run under dir preroot
+ */
+
+#include <ast.h>
+#include <preroot.h>
+
+#if FS_PREROOT
+
+#include <option.h>
+
+void
+setpreroot(register char** argv, const char* dir)
+{
+ register char* s;
+ register char** ap;
+ int argc;
+ char* cmd;
+ char** av;
+ char buf[PATH_MAX];
+
+ if ((argv || (argv = opt_info.argv)) && (dir || (dir = getenv(PR_BASE)) && *dir) && !ispreroot(dir) && (*(cmd = *argv++) == '/' || (cmd = pathpath(buf, cmd, NiL, PATH_ABSOLUTE|PATH_REGULAR|PATH_EXECUTE))))
+ {
+ argc = 3;
+ for (ap = argv; *ap++; argc++);
+ if (av = newof(0, char*, argc, 0))
+ {
+ ap = av;
+ *ap++ = PR_COMMAND;
+ *ap++ = dir;
+ *ap++ = cmd;
+ while (*ap++ = *argv++);
+ if (!(s = getenv(PR_SILENT)) || !*s)
+ {
+ sfprintf(sfstderr, "+");
+ ap = av;
+ while (s = *ap++)
+ sfprintf(sfstderr, " %s", s);
+ sfprintf(sfstderr, "\n");
+ sfsync(sfstderr);
+ }
+ execv(*av, av);
+ free(av);
+ }
+ }
+}
+
+#else
+
+NoN(setpreroot)
+
+#endif
diff --git a/usr/src/lib/libast/common/regex/regalloc.c b/usr/src/lib/libast/common/regex/regalloc.c
new file mode 100644
index 0000000000..76d37de427
--- /dev/null
+++ b/usr/src/lib/libast/common/regex/regalloc.c
@@ -0,0 +1,36 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * posix regex alloc control
+ */
+
+#include "reglib.h"
+
+void
+regalloc(void* handle, void*(*resize)(void*,void*,size_t), regflags_t flags)
+{
+ state.disc.re_flags = flags;
+ state.disc.re_resizef = resize;
+ state.disc.re_resizehandle = handle;
+}
diff --git a/usr/src/lib/libast/common/regex/regcache.c b/usr/src/lib/libast/common/regex/regcache.c
new file mode 100644
index 0000000000..ff9554e904
--- /dev/null
+++ b/usr/src/lib/libast/common/regex/regcache.c
@@ -0,0 +1,174 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * regcomp() regex_t cache
+ * AT&T Research
+ */
+
+#include <ast.h>
+#include <regex.h>
+
+#define CACHE 8 /* # cached re's */
+#define MAXPAT 256 /* max pattern length + 1 */
+
+#define KEEP 01
+#define DROP 02
+
+typedef struct Cache_s
+{
+ regex_t re;
+ unsigned long serial;
+ regflags_t reflags;
+ int flags;
+ char pattern[MAXPAT];
+} Cache_t;
+
+static struct State_s
+{
+ Cache_t* cache[CACHE];
+ unsigned long serial;
+ char* locale;
+} matchstate;
+
+/*
+ * flush the cache
+ */
+
+static void
+flushcache(void)
+{
+ register int i;
+
+ for (i = 0; i < elementsof(matchstate.cache); i++)
+ if (matchstate.cache[i] && matchstate.cache[i]->flags)
+ {
+ matchstate.cache[i]->flags = 0;
+ regfree(&matchstate.cache[i]->re);
+ }
+}
+
+/*
+ * return regcomp() compiled re for pattern and reflags
+ */
+
+regex_t*
+regcache(const char* pattern, regflags_t reflags, int* status)
+{
+ register Cache_t* cp;
+ register int i;
+ char* s;
+ int empty;
+ int unused;
+ int old;
+
+ /*
+ * 0 pattern flushes the cache
+ */
+
+ if (!pattern)
+ {
+ flushcache();
+ if (status)
+ *status = 0;
+ return 0;
+ }
+
+ /*
+ * flush the cache if the locale changed
+ * the ast setlocale() intercept maintains
+ * persistent setlocale() return values
+ */
+
+ if ((s = setlocale(LC_CTYPE, NiL)) != matchstate.locale)
+ {
+ matchstate.locale = s;
+ flushcache();
+ }
+
+ /*
+ * check if the pattern is in the cache
+ */
+
+ empty = unused = -1;
+ old = 0;
+ for (i = 0; i < elementsof(matchstate.cache); i++)
+ if (!matchstate.cache[i])
+ empty = i;
+ else if (!(matchstate.cache[i]->flags & KEEP))
+ {
+ if (matchstate.cache[i]->flags)
+ {
+ matchstate.cache[i]->flags = 0;
+ regfree(&matchstate.cache[i]->re);
+ }
+ unused = i;
+ }
+ else if (streq(matchstate.cache[i]->pattern, pattern) && matchstate.cache[i]->reflags == reflags)
+ break;
+ else if (!matchstate.cache[old] || matchstate.cache[old]->serial > matchstate.cache[i]->serial)
+ old = i;
+ if (i >= elementsof(matchstate.cache))
+ {
+ if (unused < 0)
+ {
+ if (empty < 0)
+ unused = old;
+ else
+ unused = empty;
+ }
+ if (!(cp = matchstate.cache[unused]) && !(cp = matchstate.cache[unused] = newof(0, Cache_t, 1, 0)))
+ {
+ if (status)
+ *status = REG_ESPACE;
+ return 0;
+ }
+ if (cp->flags)
+ {
+ cp->flags = 0;
+ regfree(&cp->re);
+ }
+ cp->reflags = reflags;
+ if (strlen(pattern) < sizeof(cp->pattern))
+ {
+ strcpy(cp->pattern, pattern);
+ pattern = (const char*)cp->pattern;
+ cp->flags = KEEP;
+ }
+ else
+ cp->flags = DROP;
+ if (i = regcomp(&cp->re, pattern, cp->reflags))
+ {
+ if (status)
+ *status = i;
+ cp->flags = 0;
+ return 0;
+ }
+ }
+ else
+ cp = matchstate.cache[i];
+ cp->serial = ++matchstate.serial;
+ if (status)
+ *status = 0;
+ return &cp->re;
+}
diff --git a/usr/src/lib/libast/common/regex/regclass.c b/usr/src/lib/libast/common/regex/regclass.c
new file mode 100644
index 0000000000..85eac41f55
--- /dev/null
+++ b/usr/src/lib/libast/common/regex/regclass.c
@@ -0,0 +1,243 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * RE character class support
+ */
+
+#include "reglib.h"
+
+struct Ctype_s; typedef struct Ctype_s Ctype_t;
+
+struct Ctype_s
+{
+ const char* name;
+ size_t size;
+ regclass_t ctype;
+ Ctype_t* next;
+#if _lib_wctype
+ wctype_t wtype;
+#endif
+};
+
+static Ctype_t* ctypes;
+
+#define CTYPES 12
+#if _lib_wctype
+#define WTYPES 8
+#else
+#define WTYPES 0
+#endif
+
+/*
+ * this stuff gets around posix failure to define isblank,
+ * and the fact that ctype functions are macros
+ * and any local extensions that may not even have functions or macros
+ */
+
+#if _need_iswblank
+
+int
+_reg_iswblank(wint_t wc)
+{
+ static int initialized;
+ static wctype_t wt;
+
+ if (!initialized)
+ {
+ initialized = 1;
+ wt = wctype("blank");
+ }
+ return iswctype(wc, wt);
+}
+
+#endif
+
+static int Isalnum(int c) { return iswalnum(c); }
+static int Isalpha(int c) { return iswalpha(c); }
+static int Isblank(int c) { return iswblank(c); }
+static int Iscntrl(int c) { return iswcntrl(c); }
+static int Isdigit(int c) { return iswdigit(c); }
+static int Notdigit(int c) { return !iswdigit(c); }
+static int Isgraph(int c) { return iswgraph(c); }
+static int Islower(int c) { return iswlower(c); }
+static int Isprint(int c) { return iswprint(c); }
+static int Ispunct(int c) { return iswpunct(c); }
+static int Isspace(int c) { return iswspace(c); }
+static int Notspace(int c) { return !iswspace(c); }
+static int Isupper(int c) { return iswupper(c); }
+static int Isword(int c) { return iswalnum(c) || c == '_'; }
+static int Notword(int c) { return !iswalnum(c) && c != '_'; }
+static int Isxdigit(int c) { return iswxdigit(c);}
+
+#if _lib_wctype
+
+static int Is_wc_1(int);
+static int Is_wc_2(int);
+static int Is_wc_3(int);
+static int Is_wc_4(int);
+static int Is_wc_5(int);
+static int Is_wc_6(int);
+static int Is_wc_7(int);
+static int Is_wc_8(int);
+
+#endif
+
+#define SZ(s) s,(sizeof(s)-1)
+
+static Ctype_t ctype[] =
+{
+ { SZ("alnum"), Isalnum },
+ { SZ("alpha"), Isalpha },
+ { SZ("blank"), Isblank },
+ { SZ("cntrl"), Iscntrl },
+ { SZ("digit"), Isdigit },
+ { SZ("graph"), Isgraph },
+ { SZ("lower"), Islower },
+ { SZ("print"), Isprint },
+ { SZ("punct"), Ispunct },
+ { SZ("space"), Isspace },
+ { SZ("upper"), Isupper },
+ { SZ("word"), Isword },
+ { SZ("xdigit"),Isxdigit},
+#if _lib_wctype
+ { 0, 0, Is_wc_1 },
+ { 0, 0, Is_wc_2 },
+ { 0, 0, Is_wc_3 },
+ { 0, 0, Is_wc_4 },
+ { 0, 0, Is_wc_5 },
+ { 0, 0, Is_wc_6 },
+ { 0, 0, Is_wc_7 },
+ { 0, 0, Is_wc_8 },
+#endif
+};
+
+#if _lib_wctype
+
+static int Is_wc_1(int c) { return iswctype(c, ctype[CTYPES+0].wtype); }
+static int Is_wc_2(int c) { return iswctype(c, ctype[CTYPES+1].wtype); }
+static int Is_wc_3(int c) { return iswctype(c, ctype[CTYPES+2].wtype); }
+static int Is_wc_4(int c) { return iswctype(c, ctype[CTYPES+3].wtype); }
+static int Is_wc_5(int c) { return iswctype(c, ctype[CTYPES+4].wtype); }
+static int Is_wc_6(int c) { return iswctype(c, ctype[CTYPES+5].wtype); }
+static int Is_wc_7(int c) { return iswctype(c, ctype[CTYPES+6].wtype); }
+static int Is_wc_8(int c) { return iswctype(c, ctype[CTYPES+7].wtype); }
+
+#endif
+
+/*
+ * return pointer to ctype function for :class:] in s
+ * s points to the first char after the initial [
+ * if e!=0 it points to next char in s
+ * 0 returned on error
+ */
+
+regclass_t
+regclass(const char* s, char** e)
+{
+ register Ctype_t* cp;
+ register int c;
+ register size_t n;
+ register const char* t;
+
+ if (c = *s++)
+ {
+ for (t = s; *t && (*t != c || *(t + 1) != ']'); t++);
+ if (*t != c)
+ return 0;
+ n = t - s;
+ for (cp = ctypes; cp; cp = cp->next)
+ if (n == cp->size && strneq(s, cp->name, n))
+ goto found;
+ for (cp = ctype; cp < &ctype[elementsof(ctype)]; cp++)
+ {
+#if _lib_wctype
+ if (!cp->size && (cp->name = (const char*)memdup(s, n + 1)))
+ {
+ *((char*)cp->name + n) = 0;
+ /* mvs.390 needs the (char*) cast -- barf */
+ if (!(cp->wtype = wctype((char*)cp->name)))
+ {
+ free((char*)cp->name);
+ return 0;
+ }
+ cp->size = n;
+ goto found;
+ }
+#endif
+ if (n == cp->size && strneq(s, cp->name, n))
+ goto found;
+ }
+ }
+ return 0;
+ found:
+ if (e)
+ *e = (char*)t + 2;
+ return cp->ctype;
+}
+
+/*
+ * associate the ctype function fun with name
+ */
+
+int
+regaddclass(const char* name, regclass_t fun)
+{
+ register Ctype_t* cp;
+ register Ctype_t* np;
+ register size_t n;
+
+ n = strlen(name);
+ for (cp = ctypes; cp; cp = cp->next)
+ if (cp->size == n && strneq(name, cp->name, n))
+ {
+ cp->ctype = fun;
+ return 0;
+ }
+ if (!(np = newof(0, Ctype_t, 1, n + 1)))
+ return REG_ESPACE;
+ np->size = n;
+ np->name = strcpy((char*)(np + 1), name);
+ np->ctype = fun;
+ np->next = ctypes;
+ ctypes = np;
+ return 0;
+}
+
+/*
+ * return pointer to ctype function for token
+ */
+
+regclass_t
+classfun(int type)
+{
+ switch (type)
+ {
+ case T_ALNUM: return Isword;
+ case T_ALNUM_NOT: return Notword;
+ case T_DIGIT: return Isdigit;
+ case T_DIGIT_NOT: return Notdigit;
+ case T_SPACE: return Isspace;
+ case T_SPACE_NOT: return Notspace;
+ }
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/regex/regcoll.c b/usr/src/lib/libast/common/regex/regcoll.c
new file mode 100644
index 0000000000..29bb85ffc0
--- /dev/null
+++ b/usr/src/lib/libast/common/regex/regcoll.c
@@ -0,0 +1,297 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * regex collation symbol support
+ */
+
+#include "reglib.h"
+
+#include <ccode.h>
+
+#ifndef UCS_BYTE
+#define UCS_BYTE 1
+#endif
+
+#include "ucs_names.h"
+
+typedef struct Ucs_map_s
+{
+ Ucs_attr_t attr[3];
+ Ucs_code_t code;
+ const char* name;
+ Dtlink_t link;
+ struct Ucs_map_s* next;
+} Ucs_map_t;
+
+#define setattr(a,i) ((a)[(i)>>5]|=(1<<((i)&((1<<5)-1))))
+#define tstattr(a,i) ((a)[(i)>>5]&(1<<((i)&((1<<5)-1))))
+#define clrattr(a,i) ((a)[(i)>>5]&=~(1<<((i)&((1<<5)-1))))
+
+static struct Local_s
+{
+ int fatal;
+ Dt_t* attrs;
+ Dt_t* names;
+ Dtdisc_t dtdisc;
+#if CC_NATIVE != CC_ASCII
+ unsigned char* a2n;
+#endif
+} local;
+
+/*
+ * initialize the writeable tables from the readonly data
+ * the tables are big enough to be concerned about text vs. data vs. bss
+ * UCS_BYTE==0 100K
+ * UCS_BYTE==1 20K
+ */
+
+static int
+initialize(void)
+{
+ register int i;
+ register Ucs_map_t* a;
+ register Ucs_map_t* w;
+
+ if (local.fatal)
+ return -1;
+ local.dtdisc.link = offsetof(Ucs_map_t, link);
+ local.dtdisc.key = offsetof(Ucs_map_t, name);
+ local.dtdisc.size = -1;
+ if (!(w = (Ucs_map_t*)malloc(sizeof(Ucs_map_t) * (elementsof(ucs_attrs) + elementsof(ucs_names)))))
+ {
+ local.fatal = 1;
+ return -1;
+ }
+ if (!(local.attrs = dtopen(&local.dtdisc, Dttree)))
+ {
+ free(w);
+ local.fatal = 1;
+ return -1;
+ }
+ if (!(local.names = dtopen(&local.dtdisc, Dttree)))
+ {
+ free(w);
+ dtclose(local.attrs);
+ local.fatal = 1;
+ return -1;
+ }
+ for (i = 0; i < elementsof(ucs_attrs); i++, w++)
+ {
+ memcpy(w, &ucs_attrs[i], offsetof(Ucs_dat_t, table));
+ w->name = ucs_strings[ucs_attrs[i].table] + ucs_attrs[i].index;
+ w->next = 0;
+ dtinsert(local.attrs, w);
+ }
+ for (i = 0; i < elementsof(ucs_names); i++, w++)
+ {
+ memcpy(w, &ucs_names[i], offsetof(Ucs_dat_t, table));
+ w->name = ucs_strings[ucs_names[i].table] + ucs_names[i].index;
+ w->next = 0;
+ if (a = (Ucs_map_t*)dtsearch(local.names, w))
+ {
+ while (a->next)
+ a = a->next;
+ a->next = w;
+ }
+ else
+ dtinsert(local.names, w);
+ }
+#if CC_NATIVE != CC_ASCII
+ local.a2n = ccmap(CC_ASCII, CC_NATIVE);
+#endif
+ return 0;
+}
+
+/*
+ * return the collating symbol delimited by [c c], where c is either '=' or '.'
+ * s points to the first char after the initial [
+ * if e!=0 it is set to point to the next char in s on return
+ *
+ * the collating symbol is converted to multibyte in <buf,size>
+ * the return value is:
+ * -1 syntax error or buf not large enough
+ * >=0 size with 0-terminated mb collation element
+ * or ligature value in buf
+ */
+
+int
+regcollate(register const char* s, char** e, char* buf, int size)
+{
+ register int c;
+ register char* u;
+ register char* b;
+ register char* x;
+ register Ucs_map_t* a;
+ Ucs_map_t* z;
+ const char* t;
+ const char* v;
+ int n;
+ int r;
+ int ul;
+ int term;
+ wchar_t w[2];
+ Ucs_attr_t attr[3];
+
+ if (size < 2)
+ r = -1;
+ else if ((term = *s++) != '.' && term != '=')
+ {
+ s--;
+ r = -1;
+ }
+ else if (*s == term && *(s + 1) == ']')
+ r = -1;
+ else
+ {
+ t = s;
+ mbchar(s);
+ if ((n = (s - t)) == 1)
+ {
+ if (*s == term && *(s + 1) == ']')
+ {
+ s += 2;
+ r = -1;
+ }
+ else
+ {
+ if (!local.attrs && initialize())
+ return -1;
+ attr[0] = attr[1] = attr[2] = 0;
+ ul = 0;
+ b = buf;
+ x = buf + size - 2;
+ r = 1;
+ s = t;
+ do
+ {
+ v = s;
+ u = b;
+ for (;;)
+ {
+ if (!(c = *s++))
+ return -1;
+ if (c == term)
+ {
+ if (!(c = *s++))
+ return -1;
+ if (c != term)
+ {
+ if (c != ']')
+ return -1;
+ r = -1;
+ break;
+ }
+ }
+ if (c == ' ' || c == '-' && u > b && *s != ' ' && *s != '-')
+ break;
+ if (isupper(c))
+ c = tolower(c);
+ if (u > x)
+ break;
+ *u++ = c;
+ }
+ *u = 0;
+ if (a = (Ucs_map_t*)dtmatch(local.attrs, b))
+ setattr(attr, a->code);
+ else
+ {
+ if (u < x)
+ *u++ = ' ';
+ if (b == buf)
+ {
+ if (isupper(*v))
+ ul = UCS_UC;
+ else if (islower(*v))
+ ul = UCS_LC;
+ }
+ b = u;
+ }
+ } while (r > 0);
+ if (b > buf && *(b - 1) == ' ')
+ b--;
+ *b = 0;
+ attr[0] &= ~((Ucs_attr_t)1);
+ if (ul)
+ {
+ if (tstattr(attr, UCS_UC) || tstattr(attr, UCS_LC))
+ ul = 0;
+ else
+ setattr(attr, ul);
+ }
+ if (z = (Ucs_map_t*)dtmatch(local.names, buf))
+ for(;;)
+ {
+ for (a = z; a; a = a->next)
+ if ((attr[0] & a->attr[0]) == attr[0] && (attr[1] & a->attr[1]) == attr[1] && (attr[2] & a->attr[2]) == attr[2])
+ {
+ if (a->code <= 0xff)
+ {
+#if CC_NATIVE != CC_ASCII
+ buf[0] = local.a2n[a->code];
+#else
+ buf[0] = a->code;
+#endif
+ buf[r = 1] = 0;
+ ul = 0;
+ break;
+ }
+ w[0] = a->code;
+ w[1] = 0;
+ if ((r = wcstombs(buf, w, size)) > 0)
+ {
+ r--;
+ ul = 0;
+ }
+ break;
+ }
+ if (!ul)
+ break;
+ clrattr(attr, ul);
+ ul = 0;
+ }
+ }
+ if (r < 0)
+ {
+ if ((r = s - t - 2) > (size - 1))
+ return -1;
+ memcpy(buf, t, r);
+ buf[r] = 0;
+ }
+ }
+ else if (*s++ != term || *s++ != ']')
+ {
+ s--;
+ r = -1;
+ }
+ else if (n > (size - 1))
+ r = -1;
+ else
+ {
+ memcpy(buf, t, n);
+ buf[r = n] = 0;
+ }
+ }
+ if (e)
+ *e = (char*)s;
+ return r;
+}
diff --git a/usr/src/lib/libast/common/regex/regcomp.c b/usr/src/lib/libast/common/regex/regcomp.c
new file mode 100644
index 0000000000..dc34df68fa
--- /dev/null
+++ b/usr/src/lib/libast/common/regex/regcomp.c
@@ -0,0 +1,3485 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * posix regex compiler
+ */
+
+#include "reglib.h"
+
+#if _PACKAGE_ast
+#include "lclib.h"
+#endif
+
+#define serialize re_serialize /* hp.ia64 <unistd.h>! */
+
+#define C_ESC (-1)
+#define C_MB (-2)
+
+#if _AST_REGEX_DEBUG
+
+#define DEBUG_TEST(f,y,n) ((debug&(debug_flag=f))?(y):(n))
+#define DEBUG_CODE(f,y,n) do if(debug&(f)){y}else{n} while(0)
+#define DEBUG_INIT() do { char* t; if (!debug) { debug = 0x80000000; if (t = getenv("_AST_regex_comp_debug")) debug |= strtoul(t, NiL, 0); } } while (0)
+
+static unsigned long debug;
+static unsigned long debug_flag;
+
+#else
+
+#define DEBUG_INIT()
+#define DEBUG_TEST(f,y,n) (n)
+#define DEBUG_CODE(f,y,n) do {n} while(0)
+
+#endif
+
+#if _PACKAGE_ast
+
+typedef struct Cchr_s
+{
+ Dtlink_t lnk;
+ unsigned char nam[2];
+ Ckey_t key;
+} Cchr_t;
+
+#endif
+
+#define eat(p) do{if ((p)->token.push)(p)->token.push=0;else (p)->cursor+=(p)->token.len;}while (0)
+
+/*
+ * determine whether greedy matching will work, i.e. produce
+ * the best match first. such expressions are "easy", and
+ * need no backtracking once a complete match is found.
+ * if an expression has backreferences or alts it's hard
+ * else if it has only one closure it's easy
+ * else if all closures are simple (i.e. one-character) it's easy
+ * else it's hard.
+ */
+
+typedef struct Stats_s
+{
+ unsigned long l; /* min length to left of x */
+ unsigned long k; /* min length to left of y */
+ unsigned long m; /* min length */
+ unsigned long n; /* max length */
+ unsigned short a; /* number of alternations */
+ unsigned short b; /* number of backrefs */
+ unsigned short c; /* number of closures */
+ unsigned short i; /* number of negations */
+ unsigned short p; /* number of named subexpressions */
+ unsigned short s; /* number of simple closures */
+ unsigned short t; /* number of tries */
+ unsigned short u; /* number of unnamed subexpressions */
+ Rex_t* x; /* max length REX_STRING */
+ Rex_t* y; /* max length REX_TRIE */
+} Stats_t;
+
+typedef struct Token_s
+{
+ unsigned long min;
+ unsigned long max;
+ short lex;
+ short len;
+ short esc;
+ short att;
+ short push;
+} Token_t;
+
+typedef struct Cenv_s
+{
+ int delimiter; /* pattern delimiter */
+ int error; /* last error */
+ int explicit; /* explicit match on this char */
+ int mappeddot; /* inverse mapped '.' */
+ int mappednewline; /* inverse mapped '\n' */
+ int mappedslash; /* inverse mapped '/' */
+ regflags_t flags; /* flags arg to regcomp */
+ int type; /* BRE,ERE,ARE,SRE,KRE */
+ unsigned char* cursor; /* curent point in re */
+ unsigned char* pattern; /* the original pattern */
+ unsigned char* literal; /* literal restart pattern */
+ int parno; /* number of last open paren */
+ int parnest; /* paren nest count */
+ int posixkludge; /* to make * nonspecial */
+ Token_t token; /* token lookahead */
+ Stats_t stats; /* RE statistics */
+ int terminator; /* pattern terminator */
+ Rex_t* paren[2*(BACK_REF_MAX+2)];
+ /* paren[i]!=0 if \i defined */
+ regex_t* regex; /* user handle */
+ regdisc_t* disc; /* user discipline */
+ unsigned char* map; /* external to native ccode map */
+ unsigned char* MAP; /* fold and/or map */
+} Cenv_t;
+
+/*
+ * allocate a new Rex_t node
+ */
+
+static Rex_t*
+node(Cenv_t* env, int type, int lo, int hi, size_t extra)
+{
+ register Rex_t* e;
+
+ if (e = (Rex_t*)alloc(env->disc, 0, sizeof(Rex_t) + extra))
+ {
+ memset(e, 0, sizeof(Rex_t) + extra);
+ e->type = type;
+ e->marked = 0;
+ e->lo = lo;
+ e->hi = hi;
+ e->flags = env->flags;
+ e->map = (e->flags & REG_ICASE) ? env->MAP : env->map;
+ e->explicit = env->explicit;
+ if (extra)
+ e->re.data = (char*)e + sizeof(Rex_t);
+ }
+ return e;
+}
+
+/*
+ * free a Trie_node_t node
+ */
+
+static void
+triedrop(regdisc_t* disc, Trie_node_t* e)
+{
+ if (e)
+ {
+ triedrop(disc, e->son);
+ triedrop(disc, e->sib);
+ alloc(disc, e, 0);
+ }
+}
+
+/*
+ * free a Rex_t node
+ */
+
+void
+drop(regdisc_t* disc, Rex_t* e)
+{
+ int i;
+ Rex_t* x;
+
+ if (e && !(disc->re_flags & REG_NOFREE))
+ do
+ {
+ switch (e->type)
+ {
+ case REX_ALT:
+ case REX_CONJ:
+ drop(disc, e->re.group.expr.binary.left);
+ drop(disc, e->re.group.expr.binary.right);
+ break;
+ case REX_GROUP:
+ case REX_GROUP_AHEAD:
+ case REX_GROUP_AHEAD_NOT:
+ case REX_GROUP_BEHIND:
+ case REX_GROUP_BEHIND_NOT:
+ case REX_GROUP_CUT:
+ case REX_NEG:
+ case REX_REP:
+ drop(disc, e->re.group.expr.rex);
+ break;
+ case REX_TRIE:
+ for (i = 0; i <= UCHAR_MAX; i++)
+ triedrop(disc, e->re.trie.root[i]);
+ break;
+ }
+ x = e->next;
+ alloc(disc, e, 0);
+ } while (e = x);
+}
+
+/*
+ * mark e and descendants minimal
+ */
+
+static void
+mark(register Rex_t* e, int set)
+{
+ if (e && !e->marked)
+ do
+ {
+ e->marked = 1;
+ if (set)
+ e->flags |= REG_MINIMAL;
+ else
+ e->flags &= ~REG_MINIMAL;
+ switch (e->type)
+ {
+ case REX_ALT:
+ case REX_CONJ:
+ case REX_GROUP_COND:
+ if (e->re.group.expr.binary.left)
+ mark(e->re.group.expr.binary.left, set);
+ if (e->re.group.expr.binary.right)
+ mark(e->re.group.expr.binary.right, set);
+ break;
+ case REX_GROUP:
+ case REX_GROUP_AHEAD:
+ case REX_GROUP_AHEAD_NOT:
+ case REX_GROUP_BEHIND:
+ case REX_GROUP_BEHIND_NOT:
+ case REX_GROUP_CUT:
+ case REX_NEG:
+ case REX_REP:
+ case REX_TRIE:
+ mark(e->re.group.expr.rex, set);
+ break;
+ }
+ } while (e = e->next);
+}
+
+/*
+ * assign subexpression numbers by a preorder tree walk
+ */
+
+static int
+serialize(Cenv_t* env, Rex_t* e, int n)
+{
+ do
+ {
+ e->serial = n++;
+ switch (e->type)
+ {
+ case REX_ALT:
+ case REX_GROUP_COND:
+ if (e->re.group.expr.binary.left)
+ n = serialize(env, e->re.group.expr.binary.left, n);
+ e->re.group.expr.binary.serial = n++;
+ if (e->re.group.expr.binary.right)
+ n = serialize(env, e->re.group.expr.binary.right, n);
+ break;
+ case REX_CONJ:
+ n = serialize(env, e->re.group.expr.binary.left, n);
+ n = serialize(env, e->re.group.expr.binary.right, n);
+ break;
+ case REX_GROUP:
+ case REX_GROUP_AHEAD:
+ case REX_GROUP_AHEAD_NOT:
+ case REX_GROUP_BEHIND:
+ case REX_GROUP_BEHIND_NOT:
+ case REX_GROUP_CUT:
+ case REX_NEG:
+ case REX_REP:
+ n = serialize(env, e->re.group.expr.rex, n);
+ break;
+ }
+ } while (e = e->next);
+ return n;
+}
+
+/*
+ * catenate e and f into a sequence, collapsing them if possible
+ */
+
+static Rex_t*
+cat(Cenv_t* env, Rex_t* e, Rex_t* f)
+{
+ Rex_t* g;
+
+ if (!f)
+ {
+ drop(env->disc, e);
+ return 0;
+ }
+ if (e->type == REX_NULL)
+ {
+ drop(env->disc, e);
+ return f;
+ }
+ if (f->type == REX_NULL)
+ {
+ g = f->next;
+ f->next = 0;
+ drop(env->disc, f);
+ f = g;
+ }
+ else if (e->type == REX_DOT && f->type == REX_DOT)
+ {
+ unsigned int m = e->lo + f->lo;
+ unsigned int n = e->hi + f->hi;
+
+ if (m <= RE_DUP_MAX)
+ {
+ if (e->hi > RE_DUP_MAX || f->hi > RE_DUP_MAX)
+ {
+ n = RE_DUP_INF;
+ goto combine;
+ }
+ else if (n <= RE_DUP_MAX)
+ {
+ combine:
+ e->lo = m;
+ e->hi = n;
+ g = f->next;
+ f->next = 0;
+ drop(env->disc, f);
+ f = g;
+ }
+ }
+ }
+ e->next = f;
+ return e;
+}
+
+/*
+ * collect re statistics
+ */
+
+static int
+stats(register Cenv_t* env, register Rex_t* e)
+{
+ register unsigned long n;
+ register unsigned long m;
+ unsigned long cm;
+ unsigned long nm;
+ unsigned long cn;
+ unsigned long nn;
+ unsigned long l;
+ unsigned long k;
+ unsigned long t;
+ Rex_t* q;
+ Rex_t* x;
+ Rex_t* y;
+ unsigned char c;
+ unsigned char b;
+
+ do
+ {
+ switch (e->type)
+ {
+ case REX_ALT:
+ x = env->stats.x;
+ l = env->stats.l;
+ y = env->stats.y;
+ k = env->stats.k;
+ t = env->stats.t;
+ if (++env->stats.a <= 0)
+ return 1;
+ cm = env->stats.m;
+ env->stats.m = 0;
+ cn = env->stats.n;
+ env->stats.n = 0;
+ if (stats(env, e->re.group.expr.binary.left))
+ return 1;
+ m = env->stats.m;
+ env->stats.m = 0;
+ n = env->stats.n;
+ env->stats.n = 0;
+ if (e->re.group.expr.binary.right && stats(env, e->re.group.expr.binary.right))
+ return 1;
+ if (env->stats.m > m)
+ env->stats.m = m;
+ else
+ m = env->stats.m;
+ if ((env->stats.m += cm) < m)
+ return 1;
+ if (env->stats.n < n)
+ env->stats.n = n;
+ else
+ n = env->stats.n;
+ if ((env->stats.n += cn) < n)
+ return 1;
+ env->stats.x = x;
+ env->stats.l = l;
+ env->stats.y = y;
+ env->stats.k = k;
+ env->stats.t = t;
+ break;
+ case REX_BACK:
+ if (++env->stats.b <= 0)
+ return 1;
+ break;
+ case REX_CLASS:
+ case REX_COLL_CLASS:
+ case REX_DOT:
+ case REX_ONECHAR:
+ n = env->stats.m;
+ if ((env->stats.m += e->lo) < n)
+ return 1;
+ if (e->hi != RE_DUP_INF)
+ {
+ n = env->stats.n;
+ if ((env->stats.n += e->hi) < n)
+ return 1;
+ }
+ if (e->lo != e->hi)
+ {
+ if (++env->stats.c <= 0)
+ return 1;
+ if (++env->stats.s <= 0)
+ return 1;
+ }
+ break;
+ case REX_CONJ:
+ cm = env->stats.m;
+ env->stats.m = 0;
+ cn = env->stats.n;
+ env->stats.n = 0;
+ if (stats(env, e->re.group.expr.binary.left))
+ return 1;
+ nm = env->stats.m;
+ env->stats.m = 0;
+ nn = env->stats.n;
+ env->stats.n = 0;
+ if (stats(env, e->re.group.expr.binary.right))
+ return 1;
+ if (env->stats.m < nm)
+ env->stats.m = nm;
+ else
+ nm = env->stats.m;
+ if ((env->stats.m += cm) < nm)
+ return 1;
+ if (env->stats.n < nn)
+ env->stats.n = nn;
+ else
+ nn = env->stats.n;
+ if ((env->stats.n += cn) < nn)
+ return 1;
+ break;
+ case REX_GROUP:
+ if (e->re.group.number && ++env->stats.p <= 0 || !e->re.group.number && ++env->stats.u <= 0)
+ return 1;
+ if (stats(env, e->re.group.expr.rex))
+ return 1;
+ break;
+ case REX_GROUP_AHEAD:
+ case REX_GROUP_AHEAD_NOT:
+ case REX_GROUP_BEHIND:
+ case REX_GROUP_BEHIND_NOT:
+ m = env->stats.m;
+ n = env->stats.n;
+ x = env->stats.x;
+ y = env->stats.y;
+ if (stats(env, e->re.group.expr.rex))
+ return 1;
+ env->stats.m = m;
+ env->stats.n = n;
+ env->stats.x = x;
+ env->stats.y = y;
+ switch (e->type)
+ {
+ case REX_GROUP_AHEAD:
+ case REX_GROUP_BEHIND:
+ if (++env->stats.u <= 0)
+ return 1;
+ break;
+ }
+ break;
+ case REX_GROUP_COND:
+ if (++env->stats.u <= 0)
+ return 1;
+ m = env->stats.m;
+ n = env->stats.n;
+ x = env->stats.x;
+ y = env->stats.y;
+ if (e->re.group.size > 0 && ++env->stats.b <= 0)
+ return 1;
+ if (e->re.group.expr.binary.left && stats(env, e->re.group.expr.binary.left))
+ return 1;
+ if (q = e->re.group.expr.binary.right)
+ {
+ if (q->re.group.expr.binary.left && stats(env, q->re.group.expr.binary.left))
+ return 1;
+ if (q->re.group.expr.binary.right && stats(env, q->re.group.expr.binary.right))
+ return 1;
+ }
+ env->stats.m = m;
+ env->stats.n = n;
+ env->stats.x = x;
+ env->stats.y = y;
+ break;
+ case REX_GROUP_CUT:
+ if (++env->stats.u <= 0)
+ return 1;
+ m = env->stats.m;
+ n = env->stats.n;
+ x = env->stats.x;
+ y = env->stats.y;
+ if (stats(env, e->re.group.expr.rex))
+ return 1;
+ env->stats.m = m;
+ env->stats.n = n;
+ env->stats.x = x;
+ env->stats.y = y;
+ break;
+ case REX_NEG:
+ env->stats.i++;
+ x = env->stats.x;
+ l = env->stats.l;
+ y = env->stats.y;
+ k = env->stats.k;
+ t = env->stats.t;
+ cm = env->stats.m;
+ env->stats.m = 0;
+ if (stats(env, e->re.group.expr.rex))
+ return 1;
+ env->stats.m = !env->stats.m;
+ if ((env->stats.m += cm) < cm)
+ return 1;
+ env->stats.x = x;
+ env->stats.l = l;
+ env->stats.y = y;
+ env->stats.k = k;
+ env->stats.t = t;
+ break;
+ case REX_REP:
+ x = env->stats.x;
+ l = env->stats.l;
+ y = env->stats.y;
+ k = env->stats.k;
+ t = env->stats.t;
+ if (++env->stats.c <= 0)
+ return 1;
+ b = env->stats.b;
+ c = env->stats.c;
+ cm = env->stats.m;
+ env->stats.m = 0;
+ if (stats(env, e->re.group.expr.rex))
+ return 1;
+ if (env->stats.m == 1 && b == env->stats.b && c == env->stats.c && ++env->stats.s <= 0)
+ return 1;
+ if (e->lo < 1)
+ {
+ env->stats.x = x;
+ env->stats.l = l;
+ env->stats.y = y;
+ env->stats.k = k;
+ env->stats.t = t;
+ env->stats.m = cm;
+ }
+ else
+ {
+ m = env->stats.m;
+ if ((env->stats.m *= e->lo) > 0 && env->stats.m < m)
+ return 1;
+ m = env->stats.m;
+ if ((env->stats.m += cm) < m)
+ return 1;
+ if (env->stats.x != x)
+ env->stats.l = cm;
+ if (env->stats.y != y)
+ env->stats.k = cm;
+ }
+ break;
+ case REX_STRING:
+ cm = env->stats.m;
+ if ((env->stats.m += e->re.string.size) < cm)
+ return 1;
+ cn = env->stats.n;
+ if ((env->stats.n += e->re.string.size) < cn)
+ return 1;
+ if (!env->stats.x || env->stats.x->re.string.size < e->re.string.size)
+ {
+ env->stats.x = e;
+ env->stats.l = cm;
+ }
+ break;
+ case REX_TRIE:
+ if (++env->stats.s <= 0)
+ return 1;
+ cm = env->stats.m;
+ if ((env->stats.m += e->re.trie.min) < cm)
+ return 1;
+ cn = env->stats.n;
+ if ((env->stats.n += e->re.trie.max) < cn)
+ return 1;
+ env->stats.t++;
+ if (!env->stats.y || env->stats.y->re.trie.min < e->re.trie.min)
+ {
+ env->stats.y = e;
+ env->stats.k = cm;
+ }
+ break;
+ }
+ } while (e = e->next);
+ return 0;
+}
+
+static int token(Cenv_t*);
+
+static int
+magic(register Cenv_t* env, register int c, int escaped)
+{
+ register char* sp;
+ register int n;
+ int o = c;
+ int e = env->error;
+ int l = env->token.len;
+ short* mp;
+ char* ep;
+
+ if (mp = state.magic[c])
+ {
+ c = mp[env->type+escaped];
+ if (c >= T_META)
+ {
+ sp = (char*)env->cursor + env->token.len;
+ switch (c)
+ {
+ case T_LEFT:
+ n = 0;
+ ep = sp;
+ while (*sp >= '0' && *sp <= '9')
+ {
+ if (n > (INT_MAX / 10))
+ {
+ env->error = REG_BADBR;
+ goto bad;
+ }
+ n = n * 10 + *sp++ - '0';
+ }
+ if (sp == ep)
+ {
+ env->error = *sp ? REG_BADBR : REG_EBRACE;
+ goto bad;
+ }
+ else if (n > RE_DUP_MAX)
+ {
+ env->error = REG_BADBR;
+ goto bad;
+ }
+ env->token.min = n;
+ if (*sp == ',')
+ {
+ n = 0;
+ ep = ++sp;
+ while (*sp >= '0' && *sp <= '9')
+ {
+ if (n > (INT_MAX / 10))
+ {
+ env->error = REG_BADBR;
+ goto bad;
+ }
+ n = n * 10 + *sp++ - '0';
+ }
+ if (sp == ep)
+ n = RE_DUP_INF;
+ else if (n < env->token.min)
+ {
+ env->error = REG_BADBR;
+ goto bad;
+ }
+ }
+ env->token.max = n;
+ switch (*sp)
+ {
+ case 0:
+ env->error = REG_EBRACE;
+ goto bad;
+ case '\\':
+ if (!escaped)
+ {
+ env->error = REG_BADBR;
+ goto bad;
+ }
+ sp++;
+ break;
+ default:
+ if (escaped)
+ {
+ env->error = REG_BADBR;
+ goto bad;
+ }
+ break;
+ }
+ switch (*sp++)
+ {
+ case 0:
+ env->error = REG_EBRACE;
+ goto bad;
+ case '}':
+ break;
+ default:
+ env->error = REG_BADBR;
+ goto bad;
+ }
+ env->token.len = sp - (char*)env->cursor;
+ break;
+ case T_RIGHT:
+ env->error = REG_EBRACE;
+ goto bad;
+ case T_OPEN:
+ if (env->type < SRE && *sp == '?')
+ {
+ env->token.len++;
+ env->token.lex = 0;
+ goto group;
+ }
+ break;
+ case T_ESCAPE:
+ c = chresc(sp - 2, &ep);
+ if (ep < sp)
+ goto bad;
+ env->token.len += ep - sp;
+ if (c >= T_META)
+ {
+ env->token.lex = c;
+ c = C_ESC;
+ }
+ return c;
+ case T_BACK+0:
+ case T_BACK+1:
+ case T_BACK+2:
+ case T_BACK+3:
+ case T_BACK+4:
+ case T_BACK+5:
+ case T_BACK+6:
+ case T_BACK+7:
+ n = chresc(sp - 2, &ep);
+ if (ep > sp + 1)
+ {
+ env->token.len += ep - sp;
+ return n;
+ }
+ /*FALLTHROUGH*/
+ case T_BACK+8:
+ case T_BACK+9:
+ if (env->type == SRE || c == T_BACK && !(env->flags & REG_LENIENT))
+ {
+ env->error = REG_BADESC;
+ goto bad;
+ }
+ if ((env->flags & REG_MULTIREF) && isdigit(*sp))
+ {
+ c = (c - T_BACK) * 10 + (*sp - '0');
+ if (c > 0 && c <= env->parno && env->paren[c])
+ c += T_BACK;
+ else
+ c = chresc(sp - 2, &ep);
+ env->token.len++;
+ }
+ if (c == T_BACK)
+ c = 0;
+ break;
+ case T_BAD:
+ if (escaped == 1 && (env->flags & REG_LENIENT) && (c = mp[env->type+escaped+2]) >= T_META)
+ return c;
+ goto bad;
+ }
+ if (env->type >= SRE)
+ {
+ if (c == T_DOT)
+ c = '.';
+ else if (c < T_OPEN)
+ {
+ if (env->type == KRE && *(env->cursor + env->token.len) == '-' && *(env->cursor + env->token.len + 1) == '(')
+ {
+ env->token.len++;
+ env->token.att = 1;
+ }
+ if (env->type == KRE && *(env->cursor + env->token.len) == '(')
+ {
+ env->token.len++;
+ switch (c)
+ {
+ case T_AT:
+ break;
+ case T_PERCENT:
+ env->token.lex = c;
+ goto group;
+ case T_TILDE:
+ env->token.lex = 0;
+ goto group;
+ default:
+ env->token.lex = c;
+ break;
+ }
+ c = T_OPEN;
+ }
+ else if (c == T_STAR)
+ c = T_DOTSTAR;
+ else if (c == T_QUES)
+ c = T_DOT;
+ else
+ {
+ c = o;
+ env->token.len = l;
+ }
+ }
+ else if (c > T_BACK)
+ {
+ c = (c - T_BACK) * 2 - 1;
+ c = (c > env->parno || !env->paren[c]) ? o : T_BACK + c;
+ }
+ else if (env->type == KRE && !env->parnest && (env->flags & REG_SHELL_GROUP))
+ {
+ if (c == T_AND)
+ c = '&';
+ else if (c == T_BAR)
+ c = '|';
+ else if (c == T_OPEN)
+ c = '(';
+ }
+ }
+ }
+ }
+ else if (escaped == 2)
+ {
+ if (env->type >= SRE && !(env->flags & REG_SHELL_ESCAPED) || (env->flags & REG_ESCAPE) && (c == '[' || c == '-' || c == ']' || env->delimiter && c == env->delimiter))
+ /*ok*/;
+ else
+ {
+ env->error = REG_BADESC;
+ goto bad;
+ }
+ }
+ else if (escaped && !(env->flags & REG_LENIENT) && c != ']')
+ {
+ env->error = REG_BADESC;
+ goto bad;
+ }
+ return c;
+ group:
+ sp = (char*)env->cursor + env->token.len;
+ switch (*sp++)
+ {
+ case ')':
+ break;
+ case '#':
+ for (;;)
+ {
+ switch (*sp++)
+ {
+ case 0:
+ env->error = REG_EPAREN;
+ return T_BAD;
+ case ')':
+ break;
+ default:
+ continue;
+ }
+ break;
+ }
+ break;
+ default:
+ return T_GROUP;
+ }
+ env->cursor = (unsigned char*)sp;
+ return token(env);
+ bad:
+ if (escaped == 2)
+ env->error = e;
+ else if (env->flags & REG_LENIENT)
+ return o;
+ else if (escaped == 1 && !env->error)
+ {
+ if (mp || o == ']')
+ return o;
+ env->error = REG_BADESC;
+ }
+ return T_BAD;
+}
+
+static int
+token(register Cenv_t* env)
+{
+ int c;
+ int posixkludge;
+
+ if (env->token.push)
+ return env->token.lex;
+ env->token.att = env->token.esc = 0;
+ if ((env->token.len = MBSIZE(env->cursor)) > 1)
+ return env->token.lex = C_MB;
+ env->token.lex = 0;
+ for (;;)
+ {
+ c = *env->cursor;
+ if (c == 0 || c == env->delimiter || c == env->terminator)
+ return T_END;
+ if (!(env->flags & REG_COMMENT))
+ break;
+ if (c == '#')
+ {
+ do
+ {
+ c = *++env->cursor;
+ if (c == 0 || c == env->delimiter)
+ return T_END;
+ } while (c != '\n');
+ }
+ else if (!isspace(c))
+ break;
+ env->cursor++;
+ }
+ if (c == '\n' && (env->flags & REG_MULTIPLE) && !env->delimiter)
+ {
+ if (env->parnest)
+ {
+ env->error = REG_EPAREN;
+ return T_BAD;
+ }
+ env->parno = 0;
+ env->pattern = env->cursor + 1;
+ return T_BAR;
+ }
+ if (env->flags & REG_LITERAL)
+ return c;
+ if (posixkludge = env->posixkludge)
+ {
+ env->posixkludge = 0;
+ if (c == '*')
+ return c;
+ }
+ if (c == '\\')
+ {
+ if (env->flags & REG_SHELL_ESCAPED)
+ return c;
+ if (!(c = *(env->cursor + 1)) || c == env->terminator)
+ {
+ if (env->flags & REG_LENIENT)
+ {
+ if (c)
+ {
+ env->token.esc = env->token.len;
+ env->token.len += MBSIZE(env->cursor + 1);
+ return c;
+ }
+ return '\\';
+ }
+ env->error = REG_EESCAPE;
+ return T_BAD;
+ }
+ env->token.esc = env->token.len;
+ env->token.len += MBSIZE(env->cursor + 1);
+ if (env->delimiter && c == 'n')
+ return '\n';
+ else if (c == env->delimiter)
+ return magic(env, c, 0);
+ else if (c == '(' && env->type == BRE)
+ env->posixkludge = 1;
+ else if (c == ')' && env->type == BRE && env->parnest <= 0)
+ {
+ env->error = REG_EPAREN;
+ return T_BAD;
+ }
+ else if (isspace(c) && (env->flags & REG_COMMENT))
+ return c;
+ return magic(env, c, 1);
+ }
+ else if (c == '$')
+ {
+ if (env->type == BRE && (*(env->cursor + 1) == 0 || *(env->cursor + 1) == env->delimiter || *(env->cursor + 1) == env->terminator || *(env->cursor + 1) == '\\' && *(env->cursor + 2) == ')') || (env->flags & REG_MULTIPLE) && *(env->cursor + 1) == '\n')
+ return T_DOLL;
+ }
+ else if (c == '^')
+ {
+ if (env->type == BRE && (env->cursor == env->pattern || posixkludge))
+ {
+ env->posixkludge = 1;
+ return T_CFLX;
+ }
+ }
+ else if (c == ')')
+ {
+ if (env->type != BRE && env->parnest <= 0)
+ return c;
+ }
+ else if (c == '/' && env->explicit == env->mappedslash)
+ {
+ while (*(env->cursor + env->token.len) == c)
+ env->token.len++;
+ return T_SLASHPLUS;
+ }
+ return magic(env, c, 0);
+}
+
+static Celt_t*
+col(Celt_t* ce, int ic, unsigned char* bp, int bw, int bc, unsigned char* ep, int ew, int ec)
+{
+ register unsigned char* s;
+ register unsigned char* k;
+ register unsigned char* e;
+ register int c;
+ register int cc;
+ int bt;
+ int et;
+ Ckey_t key;
+
+ cc = 0;
+ for (;;)
+ {
+ k = key;
+ if (bw == 1)
+ {
+ c = bc;
+ if (ic)
+ {
+ if (iswupper(c))
+ {
+ c = towlower(c);
+ cc = 1;
+ }
+ else if (iswlower(c))
+ {
+ c = towupper(c);
+ cc = 1;
+ }
+ }
+ *k++ = c;
+ }
+ else if (bw < COLL_KEY_MAX)
+ {
+ s = bp;
+ e = s + bw;
+ while (s < e)
+ {
+ c = *s++;
+ if (ic)
+ {
+ if (isupper(c))
+ {
+ c = tolower(c);
+ cc = 1;
+ }
+ else if (islower(c))
+ {
+ c = toupper(c);
+ cc = 1;
+ }
+ }
+ *k++ = c;
+ }
+ }
+ *k = 0;
+ mbxfrm(ce->beg, key, COLL_KEY_MAX);
+ if (ep)
+ {
+ k = key;
+ c = mbchar(k);
+ if (iswupper(c))
+ bt = COLL_range_uc;
+ else if (iswlower(c))
+ bt = COLL_range_lc;
+ else
+ bt = COLL_range;
+ k = key;
+ if (ew == 1)
+ {
+ c = ec;
+ if (ic)
+ {
+ if (iswupper(c))
+ {
+ c = towlower(c);
+ cc = 1;
+ }
+ else if (iswlower(c))
+ {
+ c = towupper(c);
+ cc = 1;
+ }
+ }
+ *k++ = c;
+ }
+ else if (ew < COLL_KEY_MAX)
+ {
+ s = ep;
+ e = s + ew;
+ while (s < e)
+ {
+ c = *s++;
+ if (ic)
+ {
+ if (isupper(c))
+ {
+ c = tolower(c);
+ cc = 1;
+ }
+ else if (islower(c))
+ {
+ c = toupper(c);
+ cc = 1;
+ }
+ }
+ *k++ = c;
+ }
+ }
+ *k = 0;
+ mbxfrm(ce->end, key, COLL_KEY_MAX);
+ k = key;
+ c = mbchar(k);
+ if (iswupper(c))
+ et = COLL_range_uc;
+ else if (iswlower(c))
+ et = COLL_range_lc;
+ else
+ et = COLL_range;
+ ce->typ = bt == et ? bt : COLL_range;
+ }
+ else
+ ce->typ = COLL_char;
+ ce++;
+ if (!ic || !cc)
+ break;
+ ic = 0;
+ }
+ return ce;
+}
+
+static Rex_t*
+bra(Cenv_t* env)
+{
+ Rex_t* e;
+ int c;
+ int i;
+ int w;
+ int neg;
+ int last;
+ int inrange;
+ int complicated;
+ int collate;
+ int elements;
+ unsigned char* first;
+ unsigned char* start;
+ unsigned char* begin;
+ unsigned char* s;
+ regclass_t f;
+ unsigned char buf[4 * (COLL_KEY_MAX + 1)];
+#if _PACKAGE_ast
+ int ic;
+ char mbc[COLL_KEY_MAX + 1];
+#endif
+
+ if (!(e = node(env, REX_CLASS, 1, 1, sizeof(Set_t))))
+ return 0;
+ collate = complicated = elements = 0;
+ first = env->cursor;
+ start = first + MBSIZE(first);
+ if (*env->cursor == '^' || env->type >= SRE && *env->cursor == '!')
+ {
+ env->cursor++;
+ neg = 1;
+ }
+ else
+ neg = 0;
+ if (*env->cursor == 0 || *(env->cursor + 1) == 0 || *env->cursor == env->terminator || *(env->cursor + 1) == env->terminator || (env->flags & REG_ESCAPE) && (*env->cursor == env->delimiter || *env->cursor != '\\' && *(env->cursor + 1) == env->delimiter))
+ goto error;
+ begin = env->cursor + MBSIZE(env->cursor);
+
+ /*
+ * inrange: 0=no, 1=possibly, 2=definitely
+ */
+
+ inrange = 0;
+ for (;;)
+ {
+ if (!(c = *env->cursor) || c == env->terminator || (env->flags & REG_ESCAPE) && c == env->delimiter)
+ goto error;
+ env->cursor += (w = MBSIZE(env->cursor));
+ if (c == '\\')
+ {
+ if (*env->cursor)
+ {
+ if (*env->cursor == 'n')
+ {
+ env->cursor++;
+ c = '\n';
+ }
+ else if (env->type < SRE || !(env->flags & REG_SHELL_ESCAPED))
+ {
+ env->token.len = 1;
+ w = magic(env, *env->cursor, 2);
+ if (env->token.len > 1 || w != T_BAD)
+ {
+ if (env->token.len == 1 && (f = classfun(w)))
+ {
+ if (inrange > 1)
+ {
+ if (env->type < SRE && !(env->flags & REG_LENIENT))
+ goto erange;
+ inrange = 0;
+ }
+ env->cursor++;
+ for (c = 0; c <= UCHAR_MAX; c++)
+ if ((*f)(c))
+ setadd(e->re.charclass, c);
+ complicated++;
+ elements++;
+ continue;
+ }
+ if (env->token.len > 1 || w >= 0 && w < T_META)
+ {
+ c = w;
+ if (c > UCHAR_MAX)
+ {
+ if (env->type < SRE && !(env->flags & REG_LENIENT) && !mbwide())
+ goto erange;
+ c = UCHAR_MAX;
+ }
+ env->cursor += env->token.len;
+ }
+ }
+ }
+ }
+ }
+ else if (c == ']')
+ {
+ if (env->cursor == begin)
+ {
+ last = c;
+ inrange = 1;
+ continue;
+ }
+ if (inrange != 0)
+ {
+ setadd(e->re.charclass, last);
+ elements++;
+ if (inrange == 2)
+ {
+ setadd(e->re.charclass, '-');
+ elements++;
+ }
+ }
+ break;
+ }
+ else if (c == '-')
+ {
+ if (!inrange && env->cursor != begin && *env->cursor != ']')
+ {
+ if (env->type < SRE && !(env->flags & REG_LENIENT))
+ goto erange;
+ continue;
+ }
+ else if (inrange == 1)
+ {
+ inrange = 2;
+ complicated++;
+ continue;
+ }
+ }
+ else if (c == '[')
+ {
+ switch (*env->cursor)
+ {
+ case 0:
+ goto error;
+ case ':':
+ if (inrange == 1)
+ {
+ setadd(e->re.charclass, last);
+ elements++;
+ }
+ if (!(f = regclass((char*)env->cursor, (char**)&env->cursor)))
+ {
+ if (env->cursor == start && (c = *(env->cursor + 1)))
+ {
+ s = start = env->cursor + 1;
+ while (*++s && *s != ':');
+ if (*s == ':' && *(s + 1) == ']' && *(s + 2) == ']')
+ {
+ if ((i = (s - start)) == 1)
+ {
+ switch (c)
+ {
+ case '<':
+ i = REX_WBEG;
+ break;
+ case '>':
+ i = REX_WEND;
+ break;
+ default:
+ i = 0;
+ break;
+ }
+ if (i)
+ {
+ env->cursor = s + 3;
+ drop(env->disc, e);
+ return node(env, i, 0, 0, 0);
+ }
+ }
+ }
+ }
+ env->error = REG_ECTYPE;
+ goto error;
+ }
+ for (c = 0; c <= UCHAR_MAX; c++)
+ if ((*f)(c))
+ setadd(e->re.charclass, c);
+ inrange = 0;
+ complicated++;
+ elements++;
+ continue;
+ case '=':
+ if (inrange == 2)
+ goto erange;
+ if (inrange == 1)
+ {
+ setadd(e->re.charclass, last);
+ elements++;
+ }
+ if ((c = regcollate((char*)env->cursor, (char**)&env->cursor, (char*)buf, sizeof(buf))) < 0)
+ goto ecollate;
+ if (c > 1)
+ collate++;
+ else
+ setadd(e->re.charclass, buf[0]);
+ c = buf[0];
+ inrange = 0;
+ complicated++;
+ elements++;
+ continue;
+ case '.':
+ if ((c = regcollate((char*)env->cursor, (char**)&env->cursor, (char*)buf, sizeof(buf))) < 0)
+ goto ecollate;
+ if (c > 1)
+ collate++;
+ c = buf[0];
+ complicated++;
+ break;
+ default:
+ if (*env->cursor == env->terminator || *env->cursor == env->delimiter && (env->flags & REG_ESCAPE))
+ goto error;
+ break;
+ }
+ }
+ else if (w > 1)
+ complicated++;
+ if (inrange == 2)
+ {
+ if (last > c)
+ {
+ if (env->type < SRE && !(env->flags & REG_LENIENT))
+ goto erange;
+ setadd(e->re.charclass, last);
+ setadd(e->re.charclass, c);
+ }
+ else
+ for (i = last; i <= c; i++)
+ setadd(e->re.charclass, i);
+ inrange = env->type >= SRE || (env->flags & REG_LENIENT);
+ elements += 2;
+ }
+ else if (inrange == 1)
+ {
+ setadd(e->re.charclass, last);
+ elements++;
+ }
+ else
+ inrange = 1;
+ last = c;
+ }
+#if _PACKAGE_ast
+ if (complicated && mbcoll())
+ {
+ Dt_t* dt;
+ Cchr_t* cc;
+ Cchr_t* tc;
+ Cchr_t* xc;
+ Celt_t* ce;
+ Cchr_t key;
+ int cw;
+ int rw;
+ int rc;
+ unsigned char* rp;
+ unsigned char* pp;
+
+ static Dtdisc_t disc;
+
+ static const char primary[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+
+ if (!(dt = (Dt_t*)LCINFO(AST_LC_COLLATE)->data))
+ {
+ disc.key = offsetof(Cchr_t, key);
+ if ((cc = newof(0, Cchr_t, elementsof(primary), 0)) && (dt = dtopen(&disc, Dttree)))
+ {
+ for (i = 0; i < elementsof(primary) - 1; i++, cc++)
+ {
+ cc->nam[0] = primary[i];
+ mbxfrm(cc->key, cc->nam, COLL_KEY_MAX);
+ dtinsert(dt, cc);
+ }
+ for (i = 0; i < elementsof(cc->key); i++)
+ cc->key[i] = ~0;
+ dtinsert(dt, cc);
+ LCINFO(AST_LC_COLLATE)->data = (void*)dt;
+ }
+ else
+ {
+ if (cc)
+ free(cc);
+ drop(env->disc, e);
+ return 0;
+ }
+ }
+ if (dt)
+ {
+ drop(env->disc, e);
+ if (ic = env->flags & REG_ICASE)
+ elements *= 2;
+ if (!(e = node(env, REX_COLL_CLASS, 1, 1, (elements + 1) * sizeof(Celt_t))))
+ return 0;
+ ce = (Celt_t*)e->re.data;
+ e->re.collate.invert = neg;
+ e->re.collate.elements = ce;
+ env->cursor = first;
+ inrange = 0;
+ for (;;)
+ {
+ if ((c = *env->cursor) == 0 || c == env->terminator || (env->flags & REG_ESCAPE) && c == env->delimiter)
+ goto error;
+ pp = env->cursor;
+ env->cursor += (w = MBSIZE(env->cursor));
+ if (c == '\\')
+ {
+ if (*env->cursor)
+ {
+ if (*env->cursor == 'n')
+ {
+ pp = env->cursor++;
+ c = '\n';
+ }
+ else if (env->type < SRE || !(env->flags & REG_SHELL_ESCAPED))
+ {
+ env->token.len = 1;
+ w = magic(env, *env->cursor, 2);
+ if (env->token.len > 1 || w != T_BAD)
+ {
+ if (env->token.len == 1 && (f = classfun(w)))
+ {
+ if (inrange > 1)
+ {
+ if (env->type < SRE && !(env->flags & REG_LENIENT))
+ goto erange;
+ inrange = 0;
+ }
+ env->cursor++;
+ ce->fun = f;
+ ce->typ = COLL_call;
+ ce++;
+ continue;
+ }
+ if (env->token.len > 1 || w >= 0 && w < T_META)
+ {
+ c = w;
+ w = wctomb(mbc, c);
+ pp = (unsigned char*)mbc;
+ env->cursor += env->token.len;
+ }
+ }
+ }
+ }
+ }
+ else if (c == ']')
+ {
+ if (env->cursor == begin)
+ {
+ rp = pp;
+ rw = w;
+ inrange = 1;
+ continue;
+ }
+ if (inrange != 0)
+ {
+ ce = col(ce, ic, rp, rw, rc, NiL, 0, 0);
+ if (inrange == 2)
+ ce = col(ce, ic, NiL, 1, '-', NiL, 0, 0);
+ }
+ break;
+ }
+ else if (c == '-')
+ {
+ if (!inrange && env->cursor != begin && *env->cursor != ']')
+ {
+ if (env->type < SRE && !(env->flags & REG_LENIENT))
+ goto erange;
+ continue;
+ }
+ else if (inrange == 1)
+ {
+ inrange = 2;
+ continue;
+ }
+ }
+ else if (c == '[')
+ {
+ switch (*env->cursor)
+ {
+ case 0:
+ goto error;
+ case ':':
+ if (inrange == 1)
+ ce = col(ce, ic, rp, rw, rc, NiL, 0, 0);
+ if (!(f = regclass((char*)env->cursor, (char**)&env->cursor)))
+ {
+ if (env->cursor == start && (c = *(env->cursor + 1)) && *(env->cursor + 2) == ':' && *(env->cursor + 3) == ']' && *(env->cursor + 4) == ']')
+ {
+ switch (c)
+ {
+ case '<':
+ i = REX_WBEG;
+ break;
+ case '>':
+ i = REX_WEND;
+ break;
+ default:
+ i = 0;
+ break;
+ }
+ if (i)
+ {
+ env->cursor += 5;
+ drop(env->disc, e);
+ return node(env, i, 0, 0, 0);
+ }
+ }
+ env->error = REG_ECTYPE;
+ goto error;
+ }
+ ce->fun = f;
+ ce->typ = COLL_call;
+ ce++;
+ inrange = 0;
+ continue;
+ case '=':
+ if (inrange == 2)
+ goto erange;
+ if (inrange == 1)
+ ce = col(ce, ic, rp, rw, rc, NiL, 0, 0);
+ rp = env->cursor + 1;
+ if ((rw = regcollate((char*)env->cursor, (char**)&env->cursor, (char*)buf, sizeof(buf) - 1)) < 0)
+ goto ecollate;
+ c = 0;
+ if (ic)
+ for (i = 0; i < rw; i += MBSIZE(buf+i))
+ if (isupper(buf[i]))
+ {
+ buf[i] = tolower(buf[i]);
+ c = 1;
+ }
+ else if (islower(buf[i]))
+ c = 1;
+ for (;;)
+ {
+ mbxfrm(key.key, buf, COLL_KEY_MAX);
+ if (!(cc = (Cchr_t*)dtsearch(dt, &key)))
+ {
+ if (!isalnum(buf[0]))
+ {
+ strcpy((char*)ce->beg, (char*)key.key);
+ ce->typ = COLL_char;
+ ce++;
+ break;
+ }
+ if (!(cc = (Cchr_t*)dtprev(dt, &key)))
+ goto ecollate;
+ }
+ xc = cc;
+ if (islower(buf[0]))
+ {
+ ce->typ = COLL_range_lc;
+ if ((tc = (Cchr_t*)dtprev(dt, cc)) && !strcasecmp((char*)tc->nam, (char*)cc->nam))
+ xc = tc;
+ }
+ else if (isupper(buf[0]))
+ {
+ ce->typ = COLL_range_uc;
+ if ((tc = (Cchr_t*)dtprev(dt, cc)) && !strcasecmp((char*)tc->nam, (char*)cc->nam))
+ xc = tc;
+ }
+ else
+ {
+ ce->typ = COLL_range;
+ xc = cc;
+ }
+ strcpy((char*)ce->beg, (char*)xc->key);
+ if (!(cc = (Cchr_t*)dtnext(dt, cc)))
+ goto ecollate;
+ if (!strcasecmp((char*)xc->nam, (char*)cc->nam) && (tc = (Cchr_t*)dtnext(dt, cc)))
+ cc = tc;
+ strcpy((char*)ce->end, (char*)cc->key);
+ ce->max = -1;
+ ce++;
+ if (!c)
+ break;
+ c = 0;
+ for (i = 0; i < rw; i++)
+ if (islower(buf[i]))
+ buf[i] = toupper(buf[i]);
+ }
+ inrange = 0;
+ c = buf[0];
+ continue;
+ case '.':
+ pp = env->cursor + 1;
+ if ((w = regcollate((char*)env->cursor, (char**)&env->cursor, (char*)buf, sizeof(buf) - 1)) < 0)
+ goto ecollate;
+ if (w > 1)
+ {
+ if (w > COLL_KEY_MAX)
+ goto ecollate;
+ if (ic)
+ for (i = 0; i < w; i += MBSIZE(buf+i))
+ if (isupper(buf[i]))
+ buf[i] = tolower(buf[i]);
+ cw = mbxfrm(ce->beg, buf, COLL_KEY_MAX);
+ buf[1] = 0;
+ if (mbxfrm(ce->beg, buf, COLL_KEY_MAX) < cw)
+ goto ecollate;
+ }
+ c = buf[0];
+ break;
+ default:
+ if (*env->cursor == env->terminator || *env->cursor == env->delimiter && (env->flags & REG_ESCAPE))
+ goto error;
+ break;
+ }
+ }
+ if (inrange == 2)
+ {
+ ce = col(ce, ic, rp, rw, rc, pp, w, c);
+ if (strcmp((char*)ce->beg, (char*)ce->end) > 0)
+ {
+ if (env->type < SRE && !(env->flags & REG_LENIENT))
+ goto erange;
+ (ce-1)->typ = COLL_char;
+ strcpy((char*)ce->beg, (char*)(ce-1)->end);
+ ce->typ = COLL_char;
+ ce++;
+ }
+ inrange = env->type >= SRE || (env->flags & REG_LENIENT);
+ }
+ else if (inrange == 1)
+ ce = col(ce, ic, rp, rw, rc, NiL, 0, 0);
+ else
+ inrange = 1;
+ rp = pp;
+ rw = w;
+ rc = c;
+ }
+ ce->typ = COLL_end;
+ return e;
+ }
+ }
+#endif
+ if (collate)
+ goto ecollate;
+ if (env->flags & REG_ICASE)
+ for (i = 0; i <= UCHAR_MAX; i++)
+ if (settst(e->re.charclass, i))
+ {
+ if (isupper(i))
+ c = tolower(i);
+ else if (islower(i))
+ c = toupper(i);
+ else
+ continue;
+ setadd(e->re.charclass, c);
+ }
+ if (neg)
+ {
+ for (i = 0; i < elementsof(e->re.charclass->bits); i++)
+ e->re.charclass->bits[i] ^= ~0;
+ if (env->explicit >= 0)
+ setclr(e->re.charclass, env->explicit);
+ }
+ return e;
+ ecollate:
+ env->error = REG_ECOLLATE;
+ goto error;
+ erange:
+ env->error = REG_ERANGE;
+ error:
+ drop(env->disc, e);
+ if (!env->error)
+ env->error = REG_EBRACK;
+ return 0;
+}
+
+static Rex_t*
+ccl(Cenv_t* env, int type)
+{
+ int i;
+ Rex_t* e;
+ Celt_t* ce;
+ regclass_t f;
+
+ if (!(f = classfun(type)))
+ {
+ env->error = REG_BADESC;
+ return 0;
+ }
+ if (!mbcoll())
+ {
+ if (!(e = node(env, REX_CLASS, 1, 1, sizeof(Set_t))))
+ return 0;
+ for (i = 0; i <= UCHAR_MAX; i++)
+ if ((*f)(i))
+ setadd(e->re.charclass, i);
+ if (env->explicit >= 0)
+ setclr(e->re.charclass, env->explicit);
+ }
+ else
+ {
+ if (!(e = node(env, REX_COLL_CLASS, 1, 1, 2 * sizeof(Celt_t))))
+ return 0;
+ ce = (Celt_t*)e->re.data;
+ e->re.collate.invert = 0;
+ e->re.collate.elements = ce;
+ ce->typ = COLL_call;
+ ce->fun = f;
+ ce++;
+ ce->typ = COLL_end;
+ }
+ return e;
+}
+
+static Rex_t*
+rep(Cenv_t* env, Rex_t* e, int number, int last)
+{
+ Rex_t* f;
+ unsigned long m = 0;
+ unsigned long n = RE_DUP_INF;
+ int minimal = -1;
+
+ if (!e)
+ return 0;
+ switch (token(env))
+ {
+ case T_BANG:
+ eat(env);
+ if (!(f = node(env, REX_NEG, m, n, 0)))
+ {
+ drop(env->disc, e);
+ return 0;
+ }
+ f->re.group.expr.rex = e;
+ return f;
+ case T_QUES:
+ eat(env);
+ n = 1;
+ break;
+ case T_STAR:
+ eat(env);
+ break;
+ case T_PLUS:
+ eat(env);
+ m = 1;
+ break;
+ case T_LEFT:
+ eat(env);
+ m = env->token.min;
+ n = env->token.max;
+ break;
+ default:
+ return e;
+ }
+ if (env->token.att)
+ minimal = 1;
+ else if (env->type < SRE)
+ switch (token(env))
+ {
+ case T_QUES:
+ eat(env);
+ minimal = !(env->flags & REG_MINIMAL);
+ break;
+ case T_STAR: /*AST*/
+ eat(env);
+ minimal = !!(env->flags & REG_MINIMAL);
+ break;
+ }
+ switch (e->type)
+ {
+ case REX_DOT:
+ case REX_CLASS:
+ case REX_COLL_CLASS:
+ case REX_ONECHAR:
+ e->lo = m;
+ e->hi = n;
+ if (minimal >= 0)
+ mark(e, minimal);
+ return e;
+#if HUH_2002_08_07
+ case REX_BEG:
+#endif
+ case REX_BEG_STR:
+ case REX_END_STR:
+ case REX_FIN_STR:
+ case REX_WBEG:
+ case REX_WEND:
+ case REX_WORD:
+ case REX_WORD_NOT:
+ env->error = REG_BADRPT;
+ drop(env->disc, e);
+ return 0;
+ }
+ if (m == 1 && n == 1)
+ {
+ if (minimal >= 0)
+ mark(e, minimal);
+ return e;
+ }
+ if (!(f = node(env, REX_REP, m, n, 0)))
+ {
+ drop(env->disc, e);
+ return 0;
+ }
+ f->re.group.expr.rex = e;
+ f->re.group.number = number;
+ f->re.group.last = last;
+ if (minimal >= 0)
+ mark(f, minimal);
+ if (m <= n && n)
+ {
+ for (; e && e->type >= REX_GROUP && e->type <= REX_GROUP_CUT; e = e->re.group.expr.rex);
+ if (e && e->type == REX_NEG)
+ f->type = REX_GROUP;
+ }
+ return f;
+}
+
+static int
+isstring(Rex_t* e)
+{
+ switch (e->type)
+ {
+ case REX_ONECHAR:
+ return e->lo == 1 && e->hi == 1;
+ case REX_STRING:
+ return 1;
+ }
+ return 0;
+}
+
+static Trie_node_t*
+trienode(Cenv_t* env, int c)
+{
+ Trie_node_t* t;
+
+ if (t = (Trie_node_t*)alloc(env->disc, 0, sizeof(Trie_node_t)))
+ {
+ memset(t, 0, sizeof(Trie_node_t));
+ t->c = c;
+ }
+ return t;
+}
+
+static int
+insert(Cenv_t* env, Rex_t* f, Rex_t* g)
+{
+ unsigned char* s;
+ unsigned char* e;
+ Trie_node_t* t;
+ int len;
+ unsigned char tmp[2];
+
+ switch (f->type)
+ {
+ case REX_ONECHAR:
+ *(s = tmp) = f->re.onechar;
+ e = s + 1;
+ break;
+ case REX_STRING:
+ s = f->re.string.base;
+ e = s + f->re.string.size;
+ break;
+ default:
+ return 1;
+ }
+ if (!(t = g->re.trie.root[*s]) && !(t = g->re.trie.root[*s] = trienode(env, *s)))
+ return 1;
+ for (len = 1;;)
+ {
+ if (t->c == *s)
+ {
+ if (++s >= e)
+ break;
+ if (!t->son && !(t->son = trienode(env, *s)))
+ return 1;
+ t = t->son;
+ len++;
+ }
+ else
+ {
+ if (!t->sib && !(t->sib = trienode(env, *s)))
+ return 1;
+ t = t->sib;
+ }
+ }
+ if (g->re.trie.min > len)
+ g->re.trie.min = len;
+ if (g->re.trie.max < len)
+ g->re.trie.max = len;
+ t->end = 1;
+ return 0;
+}
+
+/*
+ * trie() tries to combine nontrivial e and f into a REX_TRIE
+ * unless 0 is returned, e and f are deleted as far as possible
+ * also called by regcomb
+ */
+
+static Rex_t*
+trie(Cenv_t* env, Rex_t* e, Rex_t* f)
+{
+ Rex_t* g;
+
+ if (e->next || f->next || !isstring(e) || e->flags != f->flags)
+ return 0;
+ if (isstring(f))
+ {
+ if (!(g = node(env, REX_TRIE, 0, 0, (UCHAR_MAX + 1) * sizeof(Trie_node_t*))))
+ return 0;
+ g->re.trie.min = INT_MAX;
+ if (insert(env, f, g))
+ goto nospace;
+ drop(env->disc, f);
+ }
+ else if (f->type != REX_TRIE)
+ return 0;
+ else
+ g = f;
+ if (insert(env, e, g))
+ goto nospace;
+ drop(env->disc, e);
+ return g;
+ nospace:
+ if (g != f)
+ drop(env->disc, g);
+ return 0;
+}
+
+static Rex_t* alt(Cenv_t*, int, int);
+
+static int
+chr(register Cenv_t* env, int* escaped)
+{
+ unsigned char* p;
+ int c;
+
+ *escaped = 0;
+ if (!(c = *env->cursor))
+ return -1;
+ env->cursor++;
+ if (c == '\\')
+ {
+ if (env->flags & REG_SHELL_ESCAPED)
+ return c;
+ if (!(c = *(env->cursor + 1)) || c == env->terminator)
+ {
+ if (env->flags & REG_LENIENT)
+ return c ? c : '\\';
+ env->error = REG_EESCAPE;
+ return -1;
+ }
+ p = env->cursor;
+ c = chresc((char*)env->cursor - 1, (char**)&env->cursor);
+ *escaped = env->cursor - p;
+ }
+ return c;
+}
+
+/*
+ * open the perly gates
+ */
+
+static Rex_t*
+grp(Cenv_t* env, int parno)
+{
+ Rex_t* e;
+ Rex_t* f;
+ int c;
+ int i;
+ int n;
+ int x;
+ int esc;
+ int typ;
+ int beg;
+ unsigned char* p;
+
+ beg = env->pattern == env->cursor - env->token.len;
+ if (!(c = env->token.lex) && (c = *env->cursor))
+ env->cursor++;
+ env->token.len = 0;
+ env->parnest++;
+ typ = -1;
+ switch (c)
+ {
+ case '-':
+ case '+':
+ case 'a':
+ case 'g':
+ case 'i':
+ case 'l':
+ case 'm':
+ case 'p':
+ case 'r':
+ case 's':
+ case 'x':
+ case 'A':
+ case 'B':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'I':
+ case 'K':
+ case 'M':
+ case 'N':
+ case 'R':
+ case 'S':
+ case 'U': /* pcre */
+ case 'X': /* pcre */
+ x = REX_GROUP;
+ i = 1;
+ env->token.push = 1;
+ for (;;)
+ {
+ switch (c)
+ {
+ case 0:
+ case T_CLOSE:
+ x = 0;
+ goto done;
+ case ':':
+ eat(env);
+ if (token(env) == T_CLOSE)
+ x = 0;
+ goto done;
+ case '-':
+ i = 0;
+ break;
+ case '+':
+ i = 1;
+ break;
+ case 'a':
+ if (i)
+ env->flags |= (REG_LEFT|REG_RIGHT);
+ else
+ env->flags &= ~(REG_LEFT|REG_RIGHT);
+ break;
+ case 'g':
+ if (i)
+ env->flags &= ~REG_MINIMAL;
+ else
+ env->flags |= REG_MINIMAL;
+ break;
+ case 'i':
+ if (i)
+ env->flags |= REG_ICASE;
+ else
+ env->flags &= ~REG_ICASE;
+ break;
+ case 'l':
+ if (i)
+ env->flags |= REG_LEFT;
+ else
+ env->flags &= ~REG_LEFT;
+ break;
+ case 'm':
+ if (i)
+ env->flags |= REG_NEWLINE;
+ else
+ env->flags &= ~REG_NEWLINE;
+ env->explicit = (env->flags & (REG_NEWLINE|REG_SPAN)) == REG_NEWLINE ? env->mappednewline : -1;
+ break;
+ case 'p':
+ if (i)
+ env->flags &= ~REG_LENIENT;
+ else
+ env->flags |= REG_LENIENT;
+ break;
+ case 'r':
+ if (i)
+ env->flags |= REG_RIGHT;
+ else
+ env->flags &= ~REG_RIGHT;
+ break;
+ case 's':
+ if (i)
+ env->flags |= REG_SPAN;
+ else
+ env->flags &= ~REG_SPAN;
+ env->explicit = (env->flags & (REG_NEWLINE|REG_SPAN)) == REG_NEWLINE ? env->mappednewline : -1;
+ break;
+ case 'x':
+ if (i)
+ env->flags |= REG_COMMENT;
+ else
+ env->flags &= ~REG_COMMENT;
+ break;
+ case 'A':
+ env->flags &= ~(REG_AUGMENTED|REG_EXTENDED|REG_LITERAL|REG_SHELL|REG_LEFT|REG_RIGHT);
+ env->flags |= REG_AUGMENTED|REG_EXTENDED;
+ typ = ARE;
+ break;
+ case 'B':
+ case 'G':
+ env->flags &= ~(REG_AUGMENTED|REG_EXTENDED|REG_LITERAL|REG_SHELL|REG_LEFT|REG_RIGHT);
+ typ = BRE;
+ break;
+ case 'E':
+ env->flags &= ~(REG_AUGMENTED|REG_EXTENDED|REG_LITERAL|REG_SHELL|REG_LEFT|REG_RIGHT);
+ env->flags |= REG_EXTENDED;
+ typ = ERE;
+ break;
+ case 'F':
+ case 'L':
+ env->flags &= ~(REG_AUGMENTED|REG_EXTENDED|REG_LITERAL|REG_SHELL|REG_LEFT|REG_RIGHT);
+ env->flags |= REG_LITERAL;
+ typ = ERE;
+ break;
+ case 'K':
+ env->flags &= ~(REG_AUGMENTED|REG_EXTENDED|REG_LITERAL|REG_SHELL|REG_LEFT|REG_RIGHT);
+ env->flags |= REG_AUGMENTED|REG_SHELL|REG_LEFT|REG_RIGHT;
+ typ = KRE;
+ break;
+ case 'M':
+ /* used by caller to disable glob(3) GLOB_BRACE */
+ break;
+ case 'N':
+ /* used by caller to disable glob(3) GLOB_NOCHECK */
+ break;
+ case 'R':
+ /* used by caller to disable glob(3) GLOB_STARSTAR */
+ break;
+ case 'S':
+ env->flags &= ~(REG_AUGMENTED|REG_EXTENDED|REG_LITERAL|REG_SHELL|REG_LEFT|REG_RIGHT);
+ env->flags |= REG_SHELL|REG_LEFT|REG_RIGHT;
+ typ = SRE;
+ break;
+ case 'U': /* PCRE_UNGREEDY */
+ if (i)
+ env->flags |= REG_MINIMAL;
+ else
+ env->flags &= ~REG_MINIMAL;
+ break;
+ case 'X': /* PCRE_EXTRA */
+ break;
+ default:
+ env->error = REG_BADRPT;
+ return 0;
+ }
+ eat(env);
+ c = token(env);
+ }
+ done:
+ break;
+ case ':':
+ x = REX_GROUP;
+ break;
+ case '=':
+ x = REX_GROUP_AHEAD;
+ break;
+ case '!':
+ x = REX_GROUP_AHEAD_NOT;
+ break;
+ case '<':
+ switch (token(env))
+ {
+ case '=':
+ x = REX_GROUP_BEHIND;
+ break;
+ case '!':
+ case T_BANG:
+ x = REX_GROUP_BEHIND_NOT;
+ break;
+ default:
+ env->error = REG_BADRPT;
+ return 0;
+ }
+ eat(env);
+ break;
+ case '>':
+ x = REX_GROUP_CUT;
+ break;
+ case '%':
+ case T_PERCENT:
+ e = node(env, REX_NEST, 0, 0, (UCHAR_MAX + 1) * sizeof(unsigned short));
+ e->re.nest.primary = isalnum(*env->cursor) ? -1 : *env->cursor;
+ n = 1;
+ for (;;)
+ {
+ switch (i = chr(env, &esc))
+ {
+ case -1:
+ case 0:
+ invalid:
+ env->cursor -= esc + 1;
+ env->error = REG_EPAREN;
+ return 0;
+ case 'D':
+ x = REX_NEST_delimiter;
+ /*FALLTHROUGH*/
+ delimiter:
+ if ((i = chr(env, &esc)) < 0)
+ goto invalid;
+ if (e->re.nest.type[i] & ~x)
+ goto invalid;
+ e->re.nest.type[i] = x;
+ continue;
+ case 'E':
+ x = REX_NEST_escape;
+ goto delimiter;
+ case 'L':
+ x = REX_NEST_literal;
+ goto quote;
+ case 'O':
+ switch (i = chr(env, &esc))
+ {
+ case 'T':
+ e->re.nest.type[UCHAR_MAX+1] |= REX_NEST_terminator;
+ break;
+ default:
+ goto invalid;
+ }
+ continue;
+ case 'Q':
+ x = REX_NEST_quote;
+ /*FALLTHROUGH*/
+ quote:
+ if ((i = chr(env, &esc)) < 0)
+ goto invalid;
+ if (e->re.nest.type[i] & ~x)
+ goto invalid;
+ e->re.nest.type[i] = x|REX_NEST_open|REX_NEST_close|(i<<REX_NEST_SHIFT);
+ continue;
+ case 'S':
+ x = REX_NEST_separator;
+ goto delimiter;
+ case 'T':
+ x = REX_NEST_terminator;
+ goto delimiter;
+ case '|':
+ case '&':
+ if (!esc)
+ goto invalid;
+ goto nesting;
+ case '(':
+ if (!esc)
+ n++;
+ goto nesting;
+ case ')':
+ if (!esc && !--n)
+ break;
+ goto nesting;
+ default:
+ nesting:
+ if (isalnum(i) || (e->re.nest.type[i] & (REX_NEST_close|REX_NEST_escape|REX_NEST_literal|REX_NEST_quote|REX_NEST_delimiter|REX_NEST_separator|REX_NEST_terminator)))
+ goto invalid;
+ e->re.nest.type[i] = REX_NEST_open;
+ if ((x = chr(env, &esc)) < 0 || (e->re.nest.type[x] & (REX_NEST_close|REX_NEST_escape|REX_NEST_delimiter|REX_NEST_separator|REX_NEST_terminator)))
+ goto invalid;
+ if (!esc)
+ {
+ if (x == ')' && !--n)
+ goto invalid;
+ else if (x == '(')
+ n++;
+ }
+ e->re.nest.type[x] |= REX_NEST_close;
+ e->re.nest.type[i] |= x << REX_NEST_SHIFT;
+ continue;
+ }
+ break;
+ }
+ env->parnest--;
+ if (c == T_PERCENT)
+ for (n = 0; n < 2; n++)
+ {
+ parno = ++env->parno;
+ if (!(f = node(env, REX_GROUP, 0, 0, 0)))
+ {
+ drop(env->disc, e);
+ return 0;
+ }
+ if (parno < elementsof(env->paren))
+ env->paren[parno] = f;
+ f->re.group.back = 0;
+ f->re.group.number = parno;
+ f->re.group.expr.rex = e;
+ e = f;
+ }
+ return e;
+ case '(':
+ c = 0;
+ if (isdigit(*env->cursor))
+ {
+ f = 0;
+ do
+ {
+ if (c > (INT_MAX / 10))
+ {
+ env->error = REG_BADRPT;
+ return 0;
+ }
+ c = c * 10 + (*env->cursor++ - '0');
+ } while (isdigit(*env->cursor));
+ if (*env->cursor++ != ')')
+ {
+ env->error = REG_BADRPT;
+ return 0;
+ }
+ if (c && env->type >= SRE)
+ c = c * 2 - 1;
+ if (!c || c > env->parno || !env->paren[c])
+ {
+ if (!(env->flags & REG_LENIENT))
+ {
+ env->error = REG_ESUBREG;
+ return 0;
+ }
+ if (c)
+ c = -1;
+ }
+ }
+ else
+ {
+ if (env->type < SRE && *env->cursor++ != '?')
+ {
+ env->error = REG_BADRPT;
+ return 0;
+ }
+ if (!(f = grp(env, parno + 1)) && env->error)
+ return 0;
+ }
+ if (!(e = node(env, REX_GROUP_COND, 0, 0, 0)))
+ {
+ drop(env->disc, f);
+ return 0;
+ }
+ e->re.group.size = c;
+ e->re.group.expr.binary.left = f;
+ if (!(e->re.group.expr.binary.right = alt(env, parno, 1)))
+ {
+ drop(env->disc, e);
+ return 0;
+ }
+ if (token(env) != T_CLOSE)
+ {
+ env->error = REG_EPAREN;
+ return 0;
+ }
+ eat(env);
+ env->parnest--;
+ return rep(env, e, parno, parno);
+ case '{':
+ p = env->cursor;
+ n = 1;
+ while (c = *env->cursor)
+ {
+ if (c == '\\' && *(env->cursor + 1))
+ env->cursor++;
+ else if (c == '{')
+ n++;
+ else if (c == '}' && !--n)
+ break;
+ else if (c == env->delimiter || c == env->terminator)
+ break;
+ env->cursor++;
+ }
+ if (c != '}')
+ {
+ env->error = REG_EBRACE;
+ return 0;
+ }
+ if (*++env->cursor != ')')
+ {
+ env->error = REG_EPAREN;
+ return 0;
+ }
+ env->cursor++;
+ env->parnest--;
+ if (env->disc->re_version < REG_VERSION_EXEC)
+ {
+ env->error = REG_BADRPT;
+ return 0;
+ }
+ if (!env->disc->re_execf)
+ return 0;
+ if (!(e = node(env, REX_EXEC, 0, 0, 0)))
+ return 0;
+ e->re.exec.text = (const char*)p;
+ e->re.exec.size = env->cursor - p - 2;
+ if (!env->disc->re_compf)
+ e->re.exec.data = 0;
+ else
+ e->re.exec.data = (*env->disc->re_compf)(env->regex, e->re.exec.text, e->re.exec.size, env->disc);
+ return e;
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ c -= '0';
+ while (isdigit(*env->cursor))
+ {
+ if (c > (INT_MAX / 10))
+ {
+ env->error = REG_ESUBREG;
+ return 0;
+ }
+ c = c * 10 + *env->cursor++ - '0';
+ }
+ if (*env->cursor == ')')
+ {
+ env->cursor++;
+ env->parnest--;
+ env->token.len = 1;
+ if (c > env->parno || !env->paren[c])
+ {
+ env->error = REG_ESUBREG;
+ return 0;
+ }
+ env->paren[c]->re.group.back = 1;
+ return rep(env, node(env, REX_BACK, c, 0, 0), 0, 0);
+ }
+ /*FALLTHROUGH*/
+ default:
+ env->error = REG_BADRPT;
+ return 0;
+ }
+ if (x && !(e = alt(env, parno, 0)))
+ return 0;
+ c = token(env);
+ env->parnest--;
+ if (c != T_CLOSE)
+ {
+ env->error = REG_EPAREN;
+ return 0;
+ }
+ eat(env);
+ if (typ >= 0)
+ {
+ if (beg)
+ env->pattern = env->cursor;
+ env->type = typ;
+ }
+ if (!x)
+ return 0;
+ if (!(f = node(env, x, 0, 0, 0)))
+ {
+ drop(env->disc, e);
+ return 0;
+ }
+ f->re.group.expr.rex = e;
+ if (x == REX_GROUP_BEHIND || x == REX_GROUP_BEHIND_NOT)
+ {
+ if (stats(env, e))
+ {
+ drop(env->disc, f);
+ if (!env->error)
+ env->error = REG_ECOUNT;
+ return 0;
+ }
+ f->re.group.size = env->stats.m;
+ memset(&env->stats, 0, sizeof(env->stats));
+ }
+ switch (x)
+ {
+ case REX_GROUP:
+ case REX_GROUP_CUT:
+ f = rep(env, f, parno, env->parno);
+ break;
+ }
+ return f;
+}
+
+static Rex_t*
+seq(Cenv_t* env)
+{
+ Rex_t* e;
+ Rex_t* f;
+ Token_t tok;
+ int c;
+ int i;
+ int n;
+ int x;
+ int parno;
+ int type;
+ regflags_t flags;
+ unsigned char* s;
+ unsigned char* p;
+ unsigned char* t;
+ unsigned char* u;
+ unsigned char buf[256];
+
+ for (;;)
+ {
+ s = buf;
+ while ((c = token(env)) < T_META && s < &buf[sizeof(buf) - env->token.len])
+ {
+ x = c;
+ p = env->cursor;
+ if (c >= 0)
+ {
+ n = 1;
+ *s++ = (env->flags & REG_ICASE) ? toupper(c) : c;
+ }
+ else if (c == C_ESC)
+ {
+ if ((n = wctomb(NiL, env->token.lex)) < 0)
+ continue;
+ if (!n)
+ {
+ n = 1;
+ *s++ = 0;
+ }
+ else if (s < &buf[sizeof(buf) - n])
+ {
+ wctomb((char*)s, c);
+ s += n;
+ }
+ else
+ break;
+ }
+ else
+ {
+ n = env->token.len - env->token.esc;
+ for (t = p, u = s + n; s < u; *s++ = *t++);
+ }
+ eat(env);
+ }
+ if (c == T_BAD)
+ return 0;
+ if (s > buf)
+ switch (c)
+ {
+ case T_STAR:
+ case T_PLUS:
+ case T_LEFT:
+ case T_QUES:
+ case T_BANG:
+ if ((s -= n) == buf)
+ e = 0;
+ else
+ {
+ i = s - buf;
+ if (!(e = node(env, REX_STRING, 0, 0, i)))
+ return 0;
+ memcpy((char*)(e->re.string.base = (unsigned char*)e->re.data), (char*)buf, i);
+ e->re.string.size = i;
+ }
+ if (x >= 0)
+ {
+ if (!(f = node(env, REX_ONECHAR, 1, 1, 0)))
+ {
+ drop(env->disc, e);
+ return 0;
+ }
+ f->re.onechar = (env->flags & REG_ICASE) ? toupper(x) : x;
+ }
+ else
+ {
+ if (!(e = node(env, REX_STRING, 0, 0, n)))
+ return 0;
+ memcpy((char*)(e->re.string.base = (unsigned char*)e->re.data), (char*)p, n);
+ e->re.string.size = n;
+ }
+ if (!(f = rep(env, f, 0, 0)) || !(f = cat(env, f, seq(env))))
+ {
+ drop(env->disc, e);
+ return 0;
+ }
+ if (e)
+ f = cat(env, e, f);
+ return f;
+ default:
+ c = s - buf;
+ if (!(e = node(env, REX_STRING, 0, 0, c)))
+ return 0;
+ memcpy((char*)(e->re.string.base = (unsigned char*)e->re.data), (char*)buf, c);
+ e->re.string.size = c;
+ return cat(env, e, seq(env));
+ }
+ else if (c > T_BACK)
+ {
+ eat(env);
+ c -= T_BACK;
+ if (c > env->parno || !env->paren[c])
+ {
+ env->error = REG_ESUBREG;
+ return 0;
+ }
+ env->paren[c]->re.group.back = 1;
+ e = rep(env, node(env, REX_BACK, c, 0, 0), 0, 0);
+ }
+ else
+ switch (c)
+ {
+ case T_AND:
+ case T_CLOSE:
+ case T_BAR:
+ case T_END:
+ return node(env, REX_NULL, 0, 0, 0);
+ case T_DOLL:
+ eat(env);
+ e = rep(env, node(env, REX_END, 0, 0, 0), 0, 0);
+ break;
+ case T_CFLX:
+ eat(env);
+ if ((e = node(env, REX_BEG, 0, 0, 0)) && (env->flags & REG_EXTENDED))
+ e = rep(env, e, 0, 0);
+ break;
+ case T_OPEN:
+ tok = env->token;
+ eat(env);
+ flags = env->flags;
+ type = env->type;
+ if (env->token.att)
+ env->flags |= REG_MINIMAL;
+ env->parnest++;
+ if (env->type == KRE)
+ ++env->parno;
+ parno = ++env->parno;
+ if (!(e = alt(env, parno + 1, 0)))
+ break;
+ if (e->type == REX_NULL && env->type == ERE && !(env->flags & REG_NULL))
+ {
+ drop(env->disc, e);
+ env->error = (*env->cursor == 0 || *env->cursor == env->delimiter || *env->cursor == env->terminator) ? REG_EPAREN : REG_ENULL;
+ return 0;
+ }
+ if (token(env) != T_CLOSE)
+ {
+ drop(env->disc, e);
+ env->error = REG_EPAREN;
+ return 0;
+ }
+ env->parnest--;
+ eat(env);
+ if (!(f = node(env, REX_GROUP, 0, 0, 0)))
+ {
+ drop(env->disc, e);
+ return 0;
+ }
+ if (parno < elementsof(env->paren))
+ env->paren[parno] = f;
+ f->re.group.back = 0;
+ f->re.group.number = parno;
+ f->re.group.expr.rex = e;
+ if (tok.lex)
+ {
+ tok.push = 1;
+ env->token = tok;
+ }
+ if (!(e = rep(env, f, parno, env->parno)))
+ return 0;
+ if (env->type == KRE)
+ {
+ if (!(f = node(env, REX_GROUP, 0, 0, 0)))
+ {
+ drop(env->disc, e);
+ return 0;
+ }
+ if (--parno < elementsof(env->paren))
+ env->paren[parno] = f;
+ f->re.group.back = 0;
+ f->re.group.number = parno;
+ f->re.group.expr.rex = e;
+ e = f;
+ }
+ env->flags = flags;
+ env->type = type;
+ break;
+ case T_GROUP:
+ p = env->cursor;
+ eat(env);
+ flags = env->flags;
+ type = env->type;
+ if (!(e = grp(env, env->parno + 1)))
+ {
+ if (env->error)
+ return 0;
+ if (env->literal == env->pattern && env->literal == p)
+ env->literal = env->cursor;
+ continue;
+ }
+ env->flags = flags;
+ env->type = type;
+ break;
+ case T_BRA:
+ eat(env);
+ if (e = bra(env))
+ e = rep(env, e, 0, 0);
+ break;
+ case T_ALNUM:
+ case T_ALNUM_NOT:
+ case T_DIGIT:
+ case T_DIGIT_NOT:
+ case T_SPACE:
+ case T_SPACE_NOT:
+ eat(env);
+ if (e = ccl(env, c))
+ e = rep(env, e, 0, 0);
+ break;
+ case T_LT:
+ eat(env);
+ e = rep(env, node(env, REX_WBEG, 0, 0, 0), 0, 0);
+ break;
+ case T_GT:
+ eat(env);
+ e = rep(env, node(env, REX_WEND, 0, 0, 0), 0, 0);
+ break;
+ case T_DOT:
+ eat(env);
+ e = rep(env, node(env, REX_DOT, 1, 1, 0), 0, 0);
+ break;
+ case T_DOTSTAR:
+ eat(env);
+ env->token.lex = T_STAR;
+ env->token.push = 1;
+ e = rep(env, node(env, REX_DOT, 1, 1, 0), 0, 0);
+ break;
+ case T_SLASHPLUS:
+ eat(env);
+ env->token.lex = T_PLUS;
+ env->token.push = 1;
+ if (e = node(env, REX_ONECHAR, 1, 1, 0))
+ {
+ e->re.onechar = '/';
+ e = rep(env, e, 0, 0);
+ }
+ break;
+ case T_WORD:
+ eat(env);
+ e = rep(env, node(env, REX_WORD, 0, 0, 0), 0, 0);
+ break;
+ case T_WORD_NOT:
+ eat(env);
+ e = rep(env, node(env, REX_WORD_NOT, 0, 0, 0), 0, 0);
+ break;
+ case T_BEG_STR:
+ eat(env);
+ e = rep(env, node(env, REX_BEG_STR, 0, 0, 0), 0, 0);
+ break;
+ case T_END_STR:
+ eat(env);
+ e = rep(env, node(env, REX_END_STR, 0, 0, 0), 0, 0);
+ break;
+ case T_FIN_STR:
+ eat(env);
+ e = rep(env, node(env, REX_FIN_STR, 0, 0, 0), 0, 0);
+ break;
+ default:
+ env->error = REG_BADRPT;
+ return 0;
+ }
+ if (e && *env->cursor != 0 && *env->cursor != env->delimiter && *env->cursor != env->terminator)
+ e = cat(env, e, seq(env));
+ return e;
+ }
+}
+
+static Rex_t*
+con(Cenv_t* env)
+{
+ Rex_t* e;
+ Rex_t* f;
+ Rex_t* g;
+
+ if (!(e = seq(env)) || !(env->flags & REG_AUGMENTED) || token(env) != T_AND)
+ return e;
+ eat(env);
+ if (!(f = con(env)))
+ {
+ drop(env->disc, e);
+ return 0;
+ }
+ if (!(g = node(env, REX_CONJ, 0, 0, 0)))
+ {
+ drop(env->disc, e);
+ drop(env->disc, f);
+ return 0;
+ }
+ g->re.group.expr.binary.left = e;
+ g->re.group.expr.binary.right = f;
+ return g;
+}
+
+static Rex_t*
+alt(Cenv_t* env, int number, int cond)
+{
+ Rex_t* e;
+ Rex_t* f;
+ Rex_t* g;
+
+ if (!(e = con(env)))
+ return 0;
+ else if (token(env) != T_BAR)
+ {
+ if (!cond)
+ return e;
+ f = 0;
+ if (e->type == REX_NULL)
+ goto bad;
+ }
+ else
+ {
+ eat(env);
+ if (!(f = alt(env, number, 0)))
+ {
+ drop(env->disc, e);
+ return 0;
+ }
+ if ((e->type == REX_NULL || f->type == REX_NULL) && !(env->flags & REG_NULL))
+ goto bad;
+ if (!cond && (g = trie(env, e, f)))
+ return g;
+ }
+ if (!(g = node(env, REX_ALT, 0, 0, 0)))
+ {
+ env->error = REG_ESPACE;
+ goto bad;
+ }
+ g->re.group.number = number;
+ g->re.group.last = env->parno;
+ g->re.group.expr.binary.left = e;
+ g->re.group.expr.binary.right = f;
+ return g;
+ bad:
+ drop(env->disc, e);
+ drop(env->disc, f);
+ if (!env->error)
+ env->error = REG_ENULL;
+ return 0;
+}
+
+/*
+ * add v to REX_BM tables
+ */
+
+static void
+bmstr(Cenv_t* env, register Rex_t* a, unsigned char* v, int n, Bm_mask_t b)
+{
+ int c;
+ int m;
+ size_t z;
+
+ for (m = 0; m < n; m++)
+ {
+ if (!(z = n - m - 1))
+ z = HIT;
+ c = v[m];
+ a->re.bm.mask[m][c] |= b;
+ if (z == HIT || !a->re.bm.skip[c] || a->re.bm.skip[c] > z && a->re.bm.skip[c] < HIT)
+ a->re.bm.skip[c] = z;
+ if (a->flags & REG_ICASE)
+ {
+ if (isupper(c))
+ c = tolower(c);
+ else if (islower(c))
+ c = toupper(c);
+ else
+ continue;
+ a->re.bm.mask[m][c] |= b;
+ if (z == HIT || !a->re.bm.skip[c] || a->re.bm.skip[c] > z && a->re.bm.skip[c] < HIT)
+ a->re.bm.skip[c] = z;
+ }
+ }
+}
+
+/*
+ * set up BM table from trie
+ */
+
+static int
+bmtrie(Cenv_t* env, Rex_t* a, unsigned char* v, Trie_node_t* x, int n, int m, Bm_mask_t b)
+{
+ do
+ {
+ v[m] = x->c;
+ if (m >= (n - 1))
+ {
+ bmstr(env, a, v, n, b);
+ if (!(b <<= 1))
+ {
+ b = 1;
+ a->re.bm.complete = 0;
+ }
+ else if (x->son)
+ a->re.bm.complete = 0;
+ }
+ else if (x->son)
+ b = bmtrie(env, a, v, x->son, n, m + 1, b);
+ } while (x = x->sib);
+ return b;
+}
+
+/*
+ * rewrite the expression tree for some special cases
+ * 1. it is a null expression - illegal
+ * 2. max length fixed string found -- use BM algorithm
+ * 3. it begins with an unanchored string - use KMP algorithm
+ * 0 returned on success
+ */
+
+static int
+special(Cenv_t* env, regex_t* p)
+{
+ Rex_t* a;
+ Rex_t* e;
+ Rex_t* t;
+ Rex_t* x;
+ Rex_t* y;
+ unsigned char* s;
+ int* f;
+ int n;
+ int m;
+ int k;
+
+ DEBUG_INIT();
+ if (e = p->env->rex)
+ {
+ if ((x = env->stats.x) && x->re.string.size < 3)
+ x = 0;
+ if ((t = env->stats.y) && t->re.trie.min < 3)
+ t = 0;
+ if (x && t)
+ {
+ if (x->re.string.size >= t->re.trie.min)
+ t = 0;
+ else
+ x = 0;
+ }
+ if ((x || t) && !env->map) /* HERE: figure out map */
+ {
+ Bm_mask_t** mask;
+ Bm_mask_t* h;
+ unsigned char* v;
+ size_t* q;
+ unsigned long l;
+ int i;
+ int j;
+
+ if (x)
+ {
+ y = x;
+ n = m = x->re.string.size;
+ l = env->stats.l;
+ }
+ else
+ {
+ y = t;
+ n = t->re.trie.min;
+ m = t->re.trie.max;
+ l = env->stats.k;
+ }
+ if (!(q = (size_t*)alloc(env->disc, 0, (n + 1) * sizeof(size_t))))
+ return 1;
+ if (!(a = node(env, REX_BM, 0, 0, n * (sizeof(Bm_mask_t*) + (UCHAR_MAX + 1) * sizeof(Bm_mask_t)) + (UCHAR_MAX + n + 2) * sizeof(size_t))))
+ {
+ alloc(env->disc, q, 0);
+ return 1;
+ }
+ a->flags = y->flags;
+ a->map = y->map;
+ a->re.bm.size = n;
+ a->re.bm.back = (y == e || y == e->re.group.expr.rex) ? (m - n) : -1;
+ a->re.bm.left = l - 1;
+ a->re.bm.right = env->stats.m - l - n;
+ a->re.bm.complete = (y != e && (e->type != REX_GROUP || y != e->re.group.expr.rex) || e->next || ((a->re.bm.left + a->re.bm.right) >= 0)) ? 0 : n;
+ h = (Bm_mask_t*)&a->re.bm.mask[n];
+ a->re.bm.skip = (size_t*)(h + n * (UCHAR_MAX + 1));
+ a->re.bm.fail = &a->re.bm.skip[UCHAR_MAX + 1];
+ for (m = 0; m <= UCHAR_MAX; m++)
+ a->re.bm.skip[m] = n;
+ a->re.bm.skip[0] = a->re.bm.skip[env->mappednewline] = (y->next && y->next->type == REX_END) ? HIT : (n + a->re.bm.left);
+ for (i = 1; i <= n; i++)
+ a->re.bm.fail[i] = 2 * n - i;
+ mask = a->re.bm.mask;
+ for (m = 0; m < n; m++)
+ {
+ mask[m] = h;
+ h += UCHAR_MAX + 1;
+ }
+ if (x)
+ bmstr(env, a, x->re.string.base, n, 1);
+ else
+ {
+ v = (unsigned char*)q;
+ memset(v, 0, n);
+ m = 1;
+ for (i = 0; i <= UCHAR_MAX; i++)
+ if (t->re.trie.root[i])
+ m = bmtrie(env, a, v, t->re.trie.root[i], n, 0, m);
+ }
+ mask--;
+ memset(q, 0, n * sizeof(*q));
+ for (k = (j = n) + 1; j > 0; j--, k--)
+ {
+ DEBUG_TEST(0x0010,(sfprintf(sfstderr, "BM#0: k=%d j=%d\n", k, j)),(0));
+ for (q[j] = k; k <= n; k = q[k])
+ {
+ for (m = 0; m <= UCHAR_MAX; m++)
+ if (mask[k][m] == mask[j][m])
+ {
+ DEBUG_TEST(0x0010,sfprintf(sfstderr, "CUT1: mask[%d][%c]=mask[%d][%c]\n", k, m, j, m), (0));
+ goto cut;
+ }
+ DEBUG_TEST(0x0010,sfprintf(sfstderr, "BM#2: fail[%d]=%d => %d\n", k, a->re.bm.fail[k], (a->re.bm.fail[k] > n - j) ? (n - j) : a->re.bm.fail[k]), (0));
+ if (a->re.bm.fail[k] > n - j)
+ a->re.bm.fail[k] = n - j;
+ }
+ cut: ;
+ }
+ for (i = 1; i <= n; i++)
+ if (a->re.bm.fail[i] > n + k - i)
+ {
+ DEBUG_TEST(0x0010,sfprintf(sfstderr, "BM#4: fail[%d]=%d => %d\n", i, a->re.bm.fail[i], n + k - i), (0));
+ a->re.bm.fail[i] = n + k - i;
+ }
+#if _AST_REGEX_DEBUG
+ if (DEBUG_TEST(0x0020,(1),(0)))
+ {
+ sfprintf(sfstderr, "STAT: complete=%d n=%d k=%d l=%d r=%d y=%d:%d e=%d:%d\n", a->re.bm.complete, n, k, a->re.bm.left, a->re.bm.right, y->type, y->next ? y->next->type : 0, e->type, e->next ? e->next->type : 0);
+ for (m = 0; m < n; m++)
+ for (i = 1; i <= UCHAR_MAX; i++)
+ if (a->re.bm.mask[m][i])
+ sfprintf(sfstderr, "MASK: [%d]['%c'] = %032..2u\n", m, i, a->re.bm.mask[m][i]);
+ for (i = ' '; i <= UCHAR_MAX; i++)
+ if (a->re.bm.skip[i] >= HIT)
+ sfprintf(sfstderr, "SKIP: ['%c'] = *\n", i);
+ else if (a->re.bm.skip[i] > 0 && a->re.bm.skip[i] < n)
+ sfprintf(sfstderr, "SKIP: ['%c'] = %3d\n", i, a->re.bm.skip[i]);
+ for (j = 31; j >= 0; j--)
+ {
+ sfprintf(sfstderr, " ");
+ next:
+ for (m = 0; m < n; m++)
+ {
+ for (i = 0040; i < 0177; i++)
+ if (a->re.bm.mask[m][i] & (1 << j))
+ {
+ sfprintf(sfstderr, " %c", i);
+ break;
+ }
+ if (i >= 0177)
+ {
+ if (j > 0)
+ {
+ j--;
+ goto next;
+ }
+ sfprintf(sfstderr, " ?");
+ }
+ }
+ sfprintf(sfstderr, "\n");
+ }
+ sfprintf(sfstderr, "FAIL: ");
+ for (m = 1; m <= n; m++)
+ sfprintf(sfstderr, "%3d", a->re.bm.fail[m]);
+ sfprintf(sfstderr, "\n");
+ }
+#endif
+ alloc(env->disc, q, 0);
+ a->next = e;
+ p->env->rex = a;
+ return 0;
+ }
+ switch (e->type)
+ {
+ case REX_BEG:
+ if (env->flags & REG_NEWLINE)
+ return 0;
+ break;
+ case REX_GROUP:
+ if (env->stats.b)
+ return 0;
+ e = e->re.group.expr.rex;
+ if (e->type != REX_DOT)
+ return 0;
+ /*FALLTHROUGH*/
+ case REX_DOT:
+ if (e->lo == 0 && e->hi == RE_DUP_INF)
+ break;
+ return 0;
+ case REX_NULL:
+ if (env->flags & REG_NULL)
+ break;
+ env->error = REG_ENULL;
+ return 1;
+ case REX_STRING:
+ if (env->flags & (REG_LEFT|REG_LITERAL|REG_RIGHT))
+ return 0;
+ s = e->re.string.base;
+ n = e->re.string.size;
+ if (!(a = node(env, REX_KMP, 0, 0, n * (sizeof(int*) + 1))))
+ return 1;
+ a->flags = e->flags;
+ a->map = e->map;
+ f = a->re.string.fail;
+ memcpy((char*)(a->re.string.base = (unsigned char*)&f[n]), (char*)s, n);
+ s = a->re.string.base;
+ a->re.string.size = n;
+ f[0] = m = -1;
+ for (k = 1; k < n; k++)
+ {
+ while (m >= 0 && s[m+1] != s[k])
+ m = f[m];
+ if (s[m+1] == s[k])
+ m++;
+ f[k] = m;
+ }
+ a->next = e->next;
+ p->env->rex = a;
+ e->next = 0;
+ drop(env->disc, e);
+ break;
+ default:
+ return 0;
+ }
+ }
+ p->env->once = 1;
+ return 0;
+}
+
+int
+regcomp(regex_t* p, const char* pattern, regflags_t flags)
+{
+ Rex_t* e;
+ Rex_t* f;
+ regdisc_t* disc;
+ unsigned char* fold;
+ int i;
+ Cenv_t env;
+
+ if (!p)
+ return REG_BADPAT;
+ if (flags & REG_DISCIPLINE)
+ {
+ flags &= ~REG_DISCIPLINE;
+ disc = p->re_disc;
+ }
+ else
+ disc = &state.disc;
+ if (!disc->re_errorlevel)
+ disc->re_errorlevel = 2;
+ p->env = 0;
+ if (!pattern)
+ return fatal(disc, REG_BADPAT, pattern);
+ if (!state.initialized)
+ {
+ state.initialized = 1;
+ for (i = 0; i < elementsof(state.escape); i++)
+ state.magic[state.escape[i].key] = state.escape[i].val;
+ }
+ if (!(fold = (unsigned char*)LCINFO(AST_LC_CTYPE)->data))
+ {
+ if (!(fold = newof(0, unsigned char, UCHAR_MAX, 1)))
+ return fatal(disc, REG_ESPACE, pattern);
+ for (i = 0; i <= UCHAR_MAX; i++)
+ fold[i] = toupper(i);
+ LCINFO(AST_LC_CTYPE)->data = (void*)fold;
+ }
+ again:
+ if (!(p->env = (Env_t*)alloc(disc, 0, sizeof(Env_t))))
+ return fatal(disc, REG_ESPACE, pattern);
+ memset(p->env, 0, sizeof(*p->env));
+ memset(&env, 0, sizeof(env));
+ env.regex = p;
+ env.flags = flags;
+ env.disc = p->env->disc = disc;
+ if (env.flags & REG_AUGMENTED)
+ env.flags |= REG_EXTENDED;
+ env.mappeddot = '.';
+ env.mappednewline = '\n';
+ env.mappedslash = '/';
+ if (disc->re_version >= REG_VERSION_MAP && disc->re_map)
+ {
+ env.map = disc->re_map;
+ env.MAP = p->env->fold;
+ for (i = 0; i <= UCHAR_MAX; i++)
+ {
+ env.MAP[i] = fold[env.map[i]];
+ if (env.map[i] == '.')
+ env.mappeddot = i;
+ if (env.map[i] == '\n')
+ env.mappednewline = i;
+ if (env.map[i] == '/')
+ env.mappedslash = i;
+ }
+ }
+ else
+ env.MAP = fold;
+ env.type = (env.flags & REG_AUGMENTED) ? ARE : (env.flags & REG_EXTENDED) ? ERE : BRE;
+ env.explicit = -1;
+ if (env.flags & REG_SHELL)
+ {
+ if (env.flags & REG_SHELL_PATH)
+ env.explicit = env.mappedslash;
+ env.flags |= REG_LENIENT|REG_NULL;
+ env.type = env.type == BRE ? SRE : KRE;
+ }
+ if ((env.flags & (REG_NEWLINE|REG_SPAN)) == REG_NEWLINE)
+ env.explicit = env.mappednewline;
+ p->env->leading = (env.flags & REG_SHELL_DOT) ? env.mappeddot : -1;
+ env.posixkludge = !(env.flags & (REG_EXTENDED|REG_SHELL));
+ env.token.lex = 0;
+ env.token.push = 0;
+ if (env.flags & REG_DELIMITED)
+ {
+ switch (env.delimiter = *pattern++)
+ {
+ case 0:
+ case '\\':
+ case '\n':
+ case '\r':
+ env.error = REG_EDELIM;
+ goto bad;
+ }
+ env.terminator = '\n';
+ }
+ env.literal = env.pattern = env.cursor = (unsigned char*)pattern;
+ if (!(p->env->rex = alt(&env, 1, 0)))
+ goto bad;
+ if (env.parnest)
+ {
+ env.error = REG_EPAREN;
+ goto bad;
+ }
+ p->env->stats.re_flags = env.flags & (REG_EXTENDED|REG_AUGMENTED|REG_SHELL);
+ if (env.flags & REG_LEFT)
+ {
+ if (p->env->rex->type != REX_BEG)
+ {
+ if (p->env->rex->type == REX_ALT)
+ env.flags &= ~REG_FIRST;
+ if (!(e = node(&env, REX_BEG, 0, 0, 0)))
+ {
+ regfree(p);
+ return fatal(disc, REG_ESPACE, pattern);
+ }
+ e->next = p->env->rex;
+ p->env->rex = e;
+ p->env->once = 1;
+ }
+ p->env->stats.re_flags |= REG_LEFT;
+ }
+ for (e = p->env->rex; e->next; e = e->next);
+ p->env->done.type = REX_DONE;
+ p->env->done.flags = e->flags;
+ if (env.flags & REG_RIGHT)
+ {
+ if (e->type != REX_END)
+ {
+ if (p->env->rex->type == REX_ALT)
+ env.flags &= ~REG_FIRST;
+ if (!(f = node(&env, REX_END, 0, 0, 0)))
+ {
+ regfree(p);
+ return fatal(disc, REG_ESPACE, pattern);
+ }
+ f->flags = e->flags;
+ f->map = e->map;
+ e->next = f;
+ }
+ p->env->stats.re_flags |= REG_RIGHT;
+ }
+ if (stats(&env, p->env->rex))
+ {
+ if (!env.error)
+ env.error = REG_ECOUNT;
+ goto bad;
+ }
+ if (env.stats.b)
+ p->env->hard = p->env->separate = 1;
+ else if (!(env.flags & REG_FIRST) && (env.stats.a || env.stats.c > 1 && env.stats.c != env.stats.s || env.stats.t && (env.stats.t > 1 || env.stats.a || env.stats.c)))
+ p->env->hard = 1;
+ if (p->env->hard || env.stats.c || env.stats.i)
+ p->env->stats.re_min = p->env->stats.re_max = -1;
+ else
+ {
+ if (!(p->env->stats.re_min = env.stats.m))
+ p->env->stats.re_min = -1;
+ if (!(p->env->stats.re_max = env.stats.n))
+ p->env->stats.re_max = -1;
+ }
+ if (special(&env, p))
+ goto bad;
+ serialize(&env, p->env->rex, 1);
+ p->re_nsub = env.stats.p;
+ if (env.type == KRE)
+ p->re_nsub /= 2;
+ if (env.flags & REG_DELIMITED)
+ {
+ p->re_npat = env.cursor - env.pattern + 1;
+ if (*env.cursor == env.delimiter)
+ p->re_npat++;
+ else if (env.flags & REG_MUSTDELIM)
+ {
+ env.error = REG_EDELIM;
+ goto bad;
+ }
+ else
+ env.flags &= ~REG_DELIMITED;
+ }
+ p->env->explicit = env.explicit;
+ p->env->flags = env.flags & REG_COMP;
+ p->env->min = env.stats.m;
+ p->env->nsub = env.stats.p + env.stats.u;
+ p->env->refs = 1;
+ return 0;
+ bad:
+ regfree(p);
+ if (!env.error)
+ env.error = REG_ESPACE;
+ if (env.type >= SRE && env.error != REG_ESPACE && !(flags & REG_LITERAL))
+ {
+ flags |= REG_LITERAL;
+ pattern = (const char*)env.literal;
+ goto again;
+ }
+ return fatal(disc, env.error, pattern);
+}
+
+/*
+ * regcomp() on sized pattern
+ * the lazy way around adding and checking env.end
+ */
+
+int
+regncomp(regex_t* p, const char* pattern, size_t size, regflags_t flags)
+{
+ char* s;
+ int r;
+
+ if (!(s = malloc(size + 1)))
+ return fatal((flags & REG_DISCIPLINE) ? p->re_disc : &state.disc, REG_ESPACE, pattern);
+ memcpy(s, pattern, size);
+ s[size] = 0;
+ r = regcomp(p, s, flags);
+ free(s);
+ return r;
+}
+
+/*
+ * combine two compiled regular expressions if possible,
+ * replacing first with the combination and freeing second.
+ * return 0 on success.
+ * the only combinations handled are building a Trie
+ * from String|Kmp|Trie and String|Kmp
+ */
+
+int
+regcomb(regex_t* p, regex_t* q)
+{
+ Rex_t* e = p->env->rex;
+ Rex_t* f = q->env->rex;
+ Rex_t* g;
+ Cenv_t env;
+
+ if (!e || !f)
+ return fatal(p->env->disc, REG_BADPAT, NiL);
+ if (p->env->separate || q->env->separate)
+ return REG_ESUBREG;
+ memset(&env, 0, sizeof(env));
+ env.disc = p->env->disc;
+ if (e->type == REX_BM)
+ {
+ p->env->rex = e->next;
+ e->next = 0;
+ drop(env.disc, e);
+ e = p->env->rex;
+ }
+ if (f->type == REX_BM)
+ {
+ q->env->rex = f->next;
+ f->next = 0;
+ drop(env.disc, f);
+ f = q->env->rex;
+ }
+ if (e->type == REX_BEG && f->type == REX_BEG)
+ {
+ p->env->flags |= REG_LEFT;
+ p->env->rex = e->next;
+ e->next = 0;
+ drop(env.disc, e);
+ e = p->env->rex;
+ q->env->rex = f->next;
+ f->next = 0;
+ drop(env.disc, f);
+ f = q->env->rex;
+ }
+ if (e->next && e->next->type == REX_END && f->next && f->next->type == REX_END)
+ {
+ p->env->flags |= REG_RIGHT;
+ drop(env.disc, e->next);
+ e->next = 0;
+ drop(env.disc, f->next);
+ f->next = 0;
+ }
+ if (!(g = trie(&env, f, e)))
+ return fatal(p->env->disc, REG_BADPAT, NiL);
+ p->env->rex = g;
+ if (!q->env->once)
+ p->env->once = 0;
+ q->env->rex = 0;
+ if (p->env->flags & REG_LEFT)
+ {
+ if (!(e = node(&env, REX_BEG, 0, 0, 0)))
+ {
+ regfree(p);
+ return fatal(p->env->disc, REG_ESPACE, NiL);
+ }
+ e->next = p->env->rex;
+ p->env->rex = e;
+ p->env->once = 1;
+ }
+ if (p->env->flags & REG_RIGHT)
+ {
+ for (f = p->env->rex; f->next; f = f->next);
+ if (f->type != REX_END)
+ {
+ if (!(e = node(&env, REX_END, 0, 0, 0)))
+ {
+ regfree(p);
+ return fatal(p->env->disc, REG_ESPACE, NiL);
+ }
+ f->next = e;
+ }
+ }
+ env.explicit = p->env->explicit;
+ env.flags = p->env->flags;
+ env.disc = p->env->disc;
+ if (stats(&env, p->env->rex))
+ {
+ regfree(p);
+ return fatal(p->env->disc, env.error ? env.error : REG_ECOUNT, NiL);
+ }
+ if (special(&env, p))
+ {
+ regfree(p);
+ return fatal(p->env->disc, env.error ? env.error : REG_ESPACE, NiL);
+ }
+ p->env->min = g->re.trie.min;
+ return 0;
+}
+
+/*
+ * copy a reference of p into q
+ * p and q may then have separate regsubcomp() instantiations
+ */
+
+int
+regdup(regex_t* p, regex_t* q)
+{
+ if (!p || !q)
+ return REG_BADPAT;
+ *q = *p;
+ p->env->refs++;
+ q->re_sub = 0;
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/regex/regdecomp.c b/usr/src/lib/libast/common/regex/regdecomp.c
new file mode 100644
index 0000000000..8f5a2af04e
--- /dev/null
+++ b/usr/src/lib/libast/common/regex/regdecomp.c
@@ -0,0 +1,448 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * posix regex decompiler
+ */
+
+#include "reglib.h"
+
+#undef ismeta
+#define ismeta(c,t,e,d) (state.magic[c] && state.magic[c][(t)+(e)] >= T_META || (c) == (d))
+#define meta(f,c,t,e,d) do { if (ismeta(c,t,e,d)) sfputc(f, '\\'); sfputc(f, c); } while (0)
+
+static void
+detrie(Trie_node_t* x, Sfio_t* sp, char* b, char* p, char* e, int delimiter)
+{
+ register Trie_node_t* y;
+ char* o;
+ int k;
+
+ o = p;
+ k = 1;
+ do
+ {
+ if (k)
+ {
+ o = p;
+ if (p < e)
+ *p++ = x->c;
+ }
+ sfputc(sp, x->c);
+ for (y = x->sib; y; y = y->sib)
+ {
+ sfputc(sp, '|');
+ sfputc(sp, '<');
+ sfwrite(sp, b, p - b);
+ sfputc(sp, '>');
+ detrie(y, sp, b, p, e, delimiter);
+ }
+ if (x->end && x->son)
+ {
+ sfputc(sp, '|');
+ sfputc(sp, '{');
+ sfwrite(sp, b, p - b);
+ sfputc(sp, '}');
+ p = o;
+ }
+ } while (x = x->son);
+}
+
+static int
+decomp(register Rex_t* e, Sfio_t* sp, int type, int delimiter, regflags_t flags)
+{
+ Rex_t* q;
+ unsigned char* s;
+ unsigned char* t;
+ int c;
+ int d;
+ int cb;
+ int cd;
+ int cr;
+ int ib;
+ int ie;
+ int nb;
+ int ne;
+ unsigned char ic[2*UCHAR_MAX];
+ unsigned char nc[2*UCHAR_MAX];
+
+ do
+ {
+ switch (e->type)
+ {
+ case REX_ALT:
+ if (decomp(e->re.group.expr.binary.left, sp, type, delimiter, flags))
+ return 1;
+ sfputc(sp, '|');
+ if (e->re.group.expr.binary.right && decomp(e->re.group.expr.binary.right, sp, type, delimiter, flags))
+ return 1;
+ break;
+ case REX_BACK:
+ sfprintf(sp, "\\%d", e->lo);
+ break;
+ case REX_BEG:
+ if (type < SRE)
+ sfputc(sp, '^');
+ break;
+ case REX_END:
+ if (type < SRE)
+ sfputc(sp, '$');
+ break;
+ case REX_WBEG:
+ meta(sp, '<', type, 1, delimiter);
+ break;
+ case REX_WEND:
+ meta(sp, '<', type, 1, delimiter);
+ break;
+ case REX_WORD:
+ sfprintf(sp, "\\w");
+ break;
+ case REX_CLASS:
+ case REX_COLL_CLASS:
+ case REX_ONECHAR:
+ case REX_DOT:
+ case REX_REP:
+ if (type >= SRE)
+ {
+ c = ')';
+ if (e->hi == RE_DUP_INF)
+ {
+ if (!e->lo)
+ sfputc(sp, '*');
+ else if (e->lo == 1)
+ sfputc(sp, '+');
+ else
+ sfprintf(sp, "{%d,}", e->lo);
+ }
+ else if (e->hi != 1)
+ sfprintf(sp, "{%d,%d}", e->lo, e->hi);
+ else if (e->lo == 0)
+ sfputc(sp, '?');
+ else
+ c = 0;
+ }
+ switch (e->type)
+ {
+ case REX_REP:
+ if (decomp(e->re.group.expr.rex, sp, type, delimiter, flags))
+ return 1;
+ break;
+ case REX_CLASS:
+ sfputc(sp, '[');
+ nb = ne = ib = ie = -2;
+ cb = cd = cr = 0;
+ s = nc;
+ t = ic;
+ for (c = 0; c <= UCHAR_MAX; c++)
+ if (settst(e->re.charclass, c))
+ {
+ if (c == ']')
+ cb = 1;
+ else if (c == '-')
+ cr = 1;
+ else if (c == delimiter)
+ cd = 1;
+ else if (nb < 0)
+ ne = nb = c;
+ else if (ne == (c - 1))
+ ne = c;
+ else
+ {
+ if (ne == nb)
+ *s++ = ne;
+ else
+ {
+ *s++ = nb;
+ *s++ = '-';
+ *s++ = ne;
+ }
+ ne = nb = c;
+ }
+ }
+ else
+ {
+ if (c == ']')
+ cb = -1;
+ else if (c == '-')
+ cr = -1;
+ else if (c == delimiter)
+ cd = -1;
+ else if (ib < 0)
+ ie = ib = c;
+ else if (ie == (c - 1))
+ ie = c;
+ else
+ {
+ if (ie == ib)
+ *t++ = ie;
+ else
+ {
+ *t++ = ib;
+ *t++ = '-';
+ *t++ = ie;
+ }
+ ie = ib = c;
+ }
+ }
+ if (nb >= 0)
+ {
+ *s++ = nb;
+ if (ne != nb)
+ {
+ *s++ = '-';
+ *s++ = ne;
+ }
+ }
+ if (ib >= 0)
+ {
+ *t++ = ib;
+ if (ie != ib)
+ {
+ *t++ = '-';
+ *t++ = ie;
+ }
+ }
+ if ((t - ic + 1) < (s - nc + (nc[0] == '^')))
+ {
+ sfputc(sp, '^');
+ if (cb < 0)
+ sfputc(sp, ']');
+ if (cr < 0)
+ sfputc(sp, '-');
+ if (cd < 0)
+ {
+ if (flags & REG_ESCAPE)
+ sfputc(sp, '\\');
+ sfputc(sp, delimiter);
+ }
+ sfwrite(sp, ic, t - ic);
+ }
+ else
+ {
+ if (cb > 0)
+ sfputc(sp, ']');
+ if (cr > 0)
+ sfputc(sp, '-');
+ if (cd > 0)
+ {
+ if (flags & REG_ESCAPE)
+ sfputc(sp, '\\');
+ sfputc(sp, delimiter);
+ }
+ if (nc[0] == '^')
+ {
+ sfwrite(sp, nc + 1, s - nc - 1);
+ sfputc(sp, '^');
+ }
+ else
+ sfwrite(sp, nc, s - nc);
+ }
+ sfputc(sp, ']');
+ break;
+ case REX_COLL_CLASS:
+ break;
+ case REX_ONECHAR:
+ meta(sp, e->re.onechar, type, 0, delimiter);
+ break;
+ case REX_DOT:
+ sfputc(sp, '.');
+ break;
+ }
+ if (type < SRE)
+ {
+ if (e->hi == RE_DUP_INF)
+ {
+ if (!e->lo)
+ sfputc(sp, '*');
+ else if (e->lo == 1 && ismeta('+', type, 0, delimiter))
+ meta(sp, '+', type, 1, delimiter);
+ else
+ {
+ meta(sp, '{', type, 1, delimiter);
+ sfprintf(sp, "%d,", e->lo);
+ meta(sp, '}', type, 1, delimiter);
+ }
+ }
+ else if (e->hi != 1 || e->lo == 0 && !ismeta('?', type, 0, delimiter))
+ {
+ meta(sp, '{', type, 1, delimiter);
+ sfprintf(sp, "%d,%d", e->lo, e->hi);
+ meta(sp, '}', type, 1, delimiter);
+ }
+ else if (e->lo == 0)
+ meta(sp, '?', type, 1, delimiter);
+ }
+ else if (c)
+ sfputc(sp, c);
+ break;
+ case REX_STRING:
+ case REX_KMP:
+ t = (s = e->re.string.base) + e->re.string.size;
+ while (s < t)
+ {
+ c = *s++;
+ meta(sp, c, type, 0, delimiter);
+ }
+ break;
+ case REX_TRIE:
+ ib = 0;
+ for (c = 0; c <= UCHAR_MAX; c++)
+ if (e->re.trie.root[c])
+ {
+ char pfx[1024];
+
+ if (ib)
+ sfputc(sp, '|');
+ else
+ ib = 1;
+ detrie(e->re.trie.root[c], sp, pfx, pfx, &pfx[sizeof(pfx)], delimiter);
+ }
+ break;
+ case REX_NEG:
+ if (type >= SRE)
+ sfprintf(sp, "!(");
+ if (decomp(e->re.group.expr.rex, sp, type, delimiter, flags))
+ return 1;
+ if (type >= SRE)
+ sfputc(sp, ')');
+ else
+ sfputc(sp, '!');
+ break;
+ case REX_CONJ:
+ if (decomp(e->re.group.expr.binary.left, sp, type, delimiter, flags))
+ return 1;
+ sfputc(sp, '&');
+ if (decomp(e->re.group.expr.binary.right, sp, type, delimiter, flags))
+ return 1;
+ break;
+ case REX_GROUP:
+ if (type >= SRE)
+ sfputc(sp, '@');
+ meta(sp, '(', type, 1, delimiter);
+ if (decomp(e->re.group.expr.rex, sp, type, delimiter, flags))
+ return 1;
+ meta(sp, ')', type, 1, delimiter);
+ break;
+ case REX_GROUP_AHEAD:
+ case REX_GROUP_AHEAD_NOT:
+ case REX_GROUP_BEHIND:
+ case REX_GROUP_BEHIND_NOT:
+ meta(sp, '(', type, 1, delimiter);
+ sfputc(sp, '?');
+ if (decomp(e->re.group.expr.rex, sp, type, delimiter, flags))
+ return 1;
+ meta(sp, ')', type, 1, delimiter);
+ break;
+ case REX_GROUP_COND:
+ meta(sp, '(', type, 1, delimiter);
+ sfputc(sp, '?');
+ if (e->re.group.expr.binary.left && decomp(e->re.group.expr.binary.left, sp, type, delimiter, flags))
+ return 1;
+ if (q = e->re.group.expr.binary.right)
+ {
+ sfputc(sp, ':');
+ if (q->re.group.expr.binary.left && decomp(q->re.group.expr.binary.left, sp, type, delimiter, flags))
+ return 1;
+ sfputc(sp, ':');
+ if (q->re.group.expr.binary.right && decomp(q->re.group.expr.binary.right, sp, type, delimiter, flags))
+ return 1;
+ }
+ meta(sp, ')', type, 1, delimiter);
+ break;
+ case REX_GROUP_CUT:
+ meta(sp, '(', type, 1, delimiter);
+ sfputc(sp, '?');
+ if (decomp(e->re.group.expr.rex, sp, type, delimiter, flags))
+ return 1;
+ meta(sp, ')', type, 1, delimiter);
+ break;
+ case REX_BM:
+ break;
+ default:
+ sfprintf(sp, "<ERROR:REX_%d>", e->type);
+ break;
+ }
+ } while (e = e->next);
+ return 0;
+}
+
+/*
+ * reconstruct pattern from compiled re p into sp
+ */
+
+size_t
+regdecomp(regex_t* p, regflags_t flags, char* buf, size_t n)
+{
+ Sfio_t* sp;
+ char* s;
+ int type;
+ int delimiter;
+ size_t r;
+
+ if (!(sp = sfstropen()))
+ return 0;
+ if (flags < 0)
+ flags = p->env->flags;
+ switch (flags & (REG_AUGMENTED|REG_EXTENDED|REG_SHELL))
+ {
+ case 0:
+ type = BRE;
+ break;
+ case REG_AUGMENTED:
+ case REG_AUGMENTED|REG_EXTENDED:
+ type = ARE;
+ break;
+ case REG_EXTENDED:
+ type = ERE;
+ break;
+ case REG_SHELL:
+ type = SRE;
+ break;
+ default:
+ type = KRE;
+ break;
+ }
+ if (flags & REG_DELIMITED)
+ {
+ delimiter = '/';
+ sfputc(sp, delimiter);
+ }
+ else
+ delimiter = 0;
+ if (decomp(p->env->rex, sp, type, delimiter, flags))
+ r = 0;
+ else
+ {
+ if (delimiter)
+ sfputc(sp, delimiter);
+ if ((r = sfstrtell(sp) + 1) <= n)
+ {
+ if (!(s = sfstruse(sp)))
+ r = 0;
+ else
+ memcpy(buf, s, r);
+ }
+ }
+ sfstrclose(sp);
+ return r;
+}
diff --git a/usr/src/lib/libast/common/regex/regerror.c b/usr/src/lib/libast/common/regex/regerror.c
new file mode 100644
index 0000000000..e58d6701dc
--- /dev/null
+++ b/usr/src/lib/libast/common/regex/regerror.c
@@ -0,0 +1,95 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * posix regex error message handler
+ */
+
+static const char id[] = "\n@(#)$Id: regex (AT&T Research) 2004-05-24 $\0\n";
+
+#include "reglib.h"
+
+static const char* reg_error[] =
+{
+ /* REG_ENOSYS */ "not supported",
+ /* REG_SUCCESS */ "success",
+ /* REG_NOMATCH */ "no match",
+ /* REG_BADPAT */ "invalid regular expression",
+ /* REG_ECOLLATE */ "invalid collation element",
+ /* REG_ECTYPE */ "invalid character class",
+ /* REG_EESCAPE */ "trailing \\ in pattern",
+ /* REG_ESUBREG */ "invalid \\digit backreference",
+ /* REG_EBRACK */ "[...] imbalance",
+ /* REG_EPAREN */ "\\(...\\) or (...) imbalance",
+ /* REG_EBRACE */ "\\{...\\} or {...} imbalance",
+ /* REG_BADBR */ "invalid {...} digits",
+ /* REG_ERANGE */ "invalid [...] range endpoint",
+ /* REG_ESPACE */ "out of space",
+ /* REG_BADRPT */ "unary op not preceeded by re",
+ /* REG_ENULL */ "empty subexpr in pattern",
+ /* REG_ECOUNT */ "re component count overflow",
+ /* REG_BADESC */ "invalid \\char escape",
+ /* REG_VERSIONID*/ &id[10],
+ /* REG_EFLAGS */ "conflicting flags",
+ /* REG_EDELIM */ "invalid or omitted delimiter",
+ /* REG_PANIC */ "unrecoverable internal error",
+};
+
+size_t
+regerror(int code, const regex_t* p, char* buf, size_t size)
+{
+ const char* s;
+
+ NoP(p);
+ if (code++ == REG_VERSIONID)
+ s = (const char*)fmtident(&id[1]);
+ else if (code >= 0 && code < elementsof(reg_error))
+ s = reg_error[code];
+ else
+ s = (const char*)"unknown error";
+ if (size)
+ {
+ strncpy(buf, s, size);
+ buf[size - 1] = 0;
+ }
+ else
+ buf = (char*)s;
+ return strlen(buf) + 1;
+}
+
+/*
+ * discipline error intercept
+ */
+
+int
+fatal(regdisc_t* disc, int code, const char* pattern)
+{
+ if (disc->re_errorf)
+ {
+ if (pattern)
+ (*disc->re_errorf)(NiL, disc, disc->re_errorlevel, "regular expression: %s: %s", pattern, reg_error[code+1]);
+ else
+ (*disc->re_errorf)(NiL, disc, disc->re_errorlevel, "regular expression: %s", reg_error[code+1]);
+ }
+ return code;
+}
diff --git a/usr/src/lib/libast/common/regex/regexec.c b/usr/src/lib/libast/common/regex/regexec.c
new file mode 100644
index 0000000000..60acf41934
--- /dev/null
+++ b/usr/src/lib/libast/common/regex/regexec.c
@@ -0,0 +1,54 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * posix regex executor
+ * single unsized-string interface
+ */
+
+#include "reglib.h"
+
+/*
+ * standard wrapper for the sized-record interface
+ */
+
+int
+regexec(const regex_t* p, const char* s, size_t nmatch, regmatch_t* match, regflags_t flags)
+{
+ if (flags & REG_STARTEND)
+ {
+ int r;
+ int m = match->rm_so;
+ regmatch_t* e;
+
+ if (!(r = regnexec(p, s + m, match->rm_eo - m, nmatch, match, flags)) && m > 0)
+ for (e = match + nmatch; match < e; match++)
+ if (match->rm_so >= 0)
+ {
+ match->rm_so += m;
+ match->rm_eo += m;
+ }
+ return r;
+ }
+ return regnexec(p, s, s ? strlen(s) : 0, nmatch, match, flags);
+}
diff --git a/usr/src/lib/libast/common/regex/regfatal.c b/usr/src/lib/libast/common/regex/regfatal.c
new file mode 100644
index 0000000000..4d0b94e27a
--- /dev/null
+++ b/usr/src/lib/libast/common/regex/regfatal.c
@@ -0,0 +1,49 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * posix regex fatal error interface to error()
+ */
+
+#include "reglib.h"
+
+#include <error.h>
+
+void
+regfatalpat(regex_t* p, int level, int code, const char* pat)
+{
+ char buf[128];
+
+ regerror(code, p, buf, sizeof(buf));
+ regfree(p);
+ if (pat)
+ error(level, "regular expression: %s: %s", pat, buf);
+ else
+ error(level, "regular expression: %s", buf);
+}
+
+void
+regfatal(regex_t* p, int level, int code)
+{
+ regfatalpat(p, level, code, NiL);
+}
diff --git a/usr/src/lib/libast/common/regex/reginit.c b/usr/src/lib/libast/common/regex/reginit.c
new file mode 100644
index 0000000000..e27fd10a70
--- /dev/null
+++ b/usr/src/lib/libast/common/regex/reginit.c
@@ -0,0 +1,402 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * posix regex state and alloc
+ */
+
+#include "reglib.h"
+
+#include <ccode.h>
+
+/*
+ * state shared by all threads
+ */
+
+State_t state =
+{
+ { -1, -1 },
+
+ /*
+ * escape code table
+ * the "funny" things get special treatment at ends of BRE
+ *
+ * BRE 0:normal 1:escaped 2:escaped-char-class
+ * ERE 3:normal 4:escaped 5:escaped-char-class
+ * ARE 6:normal 7:escaped 8:escaped-char-class
+ * SRE 9:normal 10:escaped 11:escaped-char-class
+ * KRE 12:normal 13:escaped 14:escaped-char-class
+ */
+
+ '\\',
+ '\\', '\\', '\\',
+ '\\', '\\', '\\',
+ '\\', '\\', '\\',
+ '\\', '\\', '\\',
+ '\\', '\\', '\\',
+ '^', /* funny */
+ '^', '^', '^',
+ T_CFLX, '^', '^',
+ T_CFLX, '^', '^',
+ '^', '^', '^',
+ '^', '^', '^',
+ '.',
+ T_DOT, '.', T_BAD,
+ T_DOT, '.', T_BAD,
+ T_DOT, '.', T_BAD,
+ '.', '.', T_BAD,
+ '.', '.', T_BAD,
+ '$', /* funny */
+ '$', '$', T_BAD,
+ T_DOLL, '$', T_BAD,
+ T_DOLL, '$', T_BAD,
+ '$', '$', T_BAD,
+ '$', '$', T_BAD,
+ '*',
+ T_STAR, '*', T_BAD,
+ T_STAR, '*', T_BAD,
+ T_STAR, '*', T_BAD,
+ T_STAR, '*', '*',
+ T_STAR, '*', '*',
+ '[',
+ T_BRA, '[', '[',
+ T_BRA, '[', '[',
+ T_BRA, '[', '[',
+ T_BRA, '[', '[',
+ T_BRA, '[', '[',
+ '|',
+ '|', T_BAD, T_BAD,
+ T_BAR, '|', T_BAD,
+ T_BAR, '|', T_BAD,
+ '|', '|', T_BAD,
+ T_BAR, '|', T_BAD,
+ '+',
+ '+', T_BAD, T_BAD,
+ T_PLUS, '+', T_BAD,
+ T_PLUS, '+', T_BAD,
+ '+', '+', T_BAD,
+ T_PLUS, '+', T_BAD,
+ '?',
+ '?', T_BAD, T_BAD,
+ T_QUES, '?', T_BAD,
+ T_QUES, '?', T_BAD,
+ T_QUES, '?', '?',
+ T_QUES, '?', '?',
+ '(',
+ '(', T_OPEN, T_BAD,
+ T_OPEN, '(', T_BAD,
+ T_OPEN, '(', T_BAD,
+ '(', '(', '(',
+ T_OPEN, '(', '(',
+ ')',
+ ')', T_CLOSE, T_BAD,
+ T_CLOSE, ')', T_BAD,
+ T_CLOSE, ')', T_BAD,
+ ')', ')', ')',
+ T_CLOSE, ')', ')',
+ '{',
+ '{', T_LEFT, T_BAD,
+ T_LEFT, '{', T_BAD,
+ T_LEFT, '{', T_BAD,
+ '{', '{', '{',
+ T_LEFT, '{', '{',
+ '}',
+ '}', T_RIGHT, T_BAD,
+ '}', T_BAD, T_BAD,
+ '}', T_BAD, T_BAD,
+ '}', '}', '}',
+ '}', '}', '}',
+ '&',
+ '&', T_BAD, T_BAD,
+ '&', T_AND, T_BAD,
+ T_AND, '&', T_BAD,
+ '&', '&', T_BAD,
+ T_AND, '&', T_BAD,
+ '!',
+ '!', T_BAD, T_BAD,
+ '!', T_BANG, T_BAD,
+ T_BANG, '!', T_BAD,
+ '!', '!', T_BAD,
+ T_BANG, '!', T_BAD,
+ '@',
+ '@', T_BAD, T_BAD,
+ '@', T_BAD, T_BAD,
+ '@', T_BAD, T_BAD,
+ '@', '@', T_BAD,
+ T_AT, '@', T_BAD,
+ '~',
+ '~', T_BAD, T_BAD,
+ '~', T_BAD, T_BAD,
+ '~', T_BAD, T_BAD,
+ '~', '~', T_BAD,
+ T_TILDE, '~', T_BAD,
+ '%',
+ '%', T_BAD, T_BAD,
+ '%', T_BAD, T_BAD,
+ '%', T_BAD, T_BAD,
+ '%', '%', T_BAD,
+ T_PERCENT, '%', T_BAD,
+ '<',
+ '<', T_LT, T_BAD,
+ '<', T_LT, T_BAD,
+ T_LT, '<', T_BAD,
+ '<', '<', T_BAD,
+ '<', '<', T_BAD,
+ '>',
+ '>', T_GT, T_BAD,
+ '>', T_GT, T_BAD,
+ T_GT, '>', T_BAD,
+ '>', '>', T_BAD,
+ '>', '>', T_BAD,
+
+ /* backrefs */
+
+ '0',
+ '0', T_BACK+0, T_ESCAPE,
+ '0', T_BACK+0, T_ESCAPE,
+ '0', T_BACK+0, T_ESCAPE,
+ '0', T_BACK+0, T_ESCAPE,
+ '0', T_BACK+0, T_ESCAPE,
+ '1',
+ '1', T_BACK+1, T_ESCAPE,
+ '1', T_BACK+1, T_ESCAPE,
+ '1', T_BACK+1, T_ESCAPE,
+ '1', T_BACK+1, T_ESCAPE,
+ '1', T_BACK+1, T_ESCAPE,
+ '2',
+ '2', T_BACK+2, T_ESCAPE,
+ '2', T_BACK+2, T_ESCAPE,
+ '2', T_BACK+2, T_ESCAPE,
+ '2', T_BACK+2, T_ESCAPE,
+ '2', T_BACK+2, T_ESCAPE,
+ '3',
+ '3', T_BACK+3, T_ESCAPE,
+ '3', T_BACK+3, T_ESCAPE,
+ '3', T_BACK+3, T_ESCAPE,
+ '3', T_BACK+3, T_ESCAPE,
+ '3', T_BACK+3, T_ESCAPE,
+ '4',
+ '4', T_BACK+4, T_ESCAPE,
+ '4', T_BACK+4, T_ESCAPE,
+ '4', T_BACK+4, T_ESCAPE,
+ '4', T_BACK+4, T_ESCAPE,
+ '4', T_BACK+4, T_ESCAPE,
+ '5',
+ '5', T_BACK+5, T_ESCAPE,
+ '5', T_BACK+5, T_ESCAPE,
+ '5', T_BACK+5, T_ESCAPE,
+ '5', T_BACK+5, T_ESCAPE,
+ '5', T_BACK+5, T_ESCAPE,
+ '6',
+ '6', T_BACK+6, T_ESCAPE,
+ '6', T_BACK+6, T_ESCAPE,
+ '6', T_BACK+6, T_ESCAPE,
+ '6', T_BACK+6, T_ESCAPE,
+ '6', T_BACK+6, T_ESCAPE,
+ '7',
+ '7', T_BACK+7, T_ESCAPE,
+ '7', T_BACK+7, T_ESCAPE,
+ '7', T_BACK+7, T_ESCAPE,
+ '7', T_BACK+7, T_ESCAPE,
+ '7', T_BACK+7, T_ESCAPE,
+ '8',
+ '8', T_BACK+8, T_ESCAPE,
+ '8', T_BACK+8, T_ESCAPE,
+ '8', T_BACK+8, T_ESCAPE,
+ '8', '8', T_ESCAPE,
+ '8', T_BACK+8, T_ESCAPE,
+ '9',
+ '9', T_BACK+9, T_ESCAPE,
+ '9', T_BACK+9, T_ESCAPE,
+ '9', T_BACK+9, T_ESCAPE,
+ '9', '9', T_ESCAPE,
+ '9', T_BACK+9, T_ESCAPE,
+
+ /* perl */
+
+ 'A',
+ 'A', T_BEG_STR, T_BAD,
+ 'A', T_BEG_STR, T_BAD,
+ 'A', T_BEG_STR, T_BAD,
+ 'A', T_BEG_STR, T_BAD,
+ 'A', T_BEG_STR, T_BAD,
+ 'b',
+ 'b', T_WORD, '\b',
+ 'b', T_WORD, '\b',
+ 'b', T_WORD, '\b',
+ 'b', T_WORD, '\b',
+ 'b', T_WORD, '\b',
+ 'B',
+ 'B', T_WORD_NOT, T_BAD,
+ 'B', T_WORD_NOT, T_BAD,
+ 'B', T_WORD_NOT, T_BAD,
+ 'B', T_WORD_NOT, T_BAD,
+ 'B', T_WORD_NOT, T_BAD,
+ 'd',
+ 'd', T_DIGIT, T_DIGIT,
+ 'd', T_DIGIT, T_DIGIT,
+ 'd', T_DIGIT, T_DIGIT,
+ 'd', T_DIGIT, T_DIGIT,
+ 'd', T_DIGIT, T_DIGIT,
+ 'D',
+ 'D', T_DIGIT_NOT, T_DIGIT_NOT,
+ 'D', T_DIGIT_NOT, T_DIGIT_NOT,
+ 'D', T_DIGIT_NOT, T_DIGIT_NOT,
+ 'D', T_DIGIT_NOT, T_DIGIT_NOT,
+ 'D', T_DIGIT_NOT, T_DIGIT_NOT,
+ 's',
+ 's', T_SPACE, T_SPACE,
+ 's', T_SPACE, T_SPACE,
+ 's', T_SPACE, T_SPACE,
+ 's', T_SPACE, T_SPACE,
+ 's', T_SPACE, T_SPACE,
+ 'S',
+ 'S', T_SPACE_NOT, T_SPACE_NOT,
+ 'S', T_SPACE_NOT, T_SPACE_NOT,
+ 'S', T_SPACE_NOT, T_SPACE_NOT,
+ 'S', T_SPACE_NOT, T_SPACE_NOT,
+ 'S', T_SPACE_NOT, T_SPACE_NOT,
+ 'w',
+ 'w', T_ALNUM, T_ALNUM,
+ 'w', T_ALNUM, T_ALNUM,
+ 'w', T_ALNUM, T_ALNUM,
+ 'w', T_ALNUM, T_ALNUM,
+ 'w', T_ALNUM, T_ALNUM,
+ 'W',
+ 'W', T_ALNUM_NOT, T_ALNUM_NOT,
+ 'W', T_ALNUM_NOT, T_ALNUM_NOT,
+ 'W', T_ALNUM_NOT, T_ALNUM_NOT,
+ 'W', T_ALNUM_NOT, T_ALNUM_NOT,
+ 'W', T_ALNUM_NOT, T_ALNUM_NOT,
+ 'z',
+ 'z', T_FIN_STR, T_BAD,
+ 'z', T_FIN_STR, T_BAD,
+ 'z', T_FIN_STR, T_BAD,
+ 'z', T_FIN_STR, T_BAD,
+ 'z', T_FIN_STR, T_BAD,
+ 'Z',
+ 'Z', T_END_STR, T_BAD,
+ 'Z', T_END_STR, T_BAD,
+ 'Z', T_END_STR, T_BAD,
+ 'Z', T_END_STR, T_BAD,
+ 'Z', T_END_STR, T_BAD,
+
+ /* C escapes */
+
+ 'a',
+ 'a', CC_bel, CC_bel,
+ 'a', CC_bel, CC_bel,
+ 'a', CC_bel, CC_bel,
+ 'a', CC_bel, CC_bel,
+ 'a', CC_bel, CC_bel,
+ 'c',
+ 'c', T_ESCAPE, T_ESCAPE,
+ 'c', T_ESCAPE, T_ESCAPE,
+ 'c', T_ESCAPE, T_ESCAPE,
+ 'c', T_ESCAPE, T_ESCAPE,
+ 'c', T_ESCAPE, T_ESCAPE,
+ 'C',
+ 'C', T_ESCAPE, T_ESCAPE,
+ 'C', T_ESCAPE, T_ESCAPE,
+ 'C', T_ESCAPE, T_ESCAPE,
+ 'C', T_ESCAPE, T_ESCAPE,
+ 'C', T_ESCAPE, T_ESCAPE,
+ 'e',
+ 'e', CC_esc, CC_esc,
+ 'e', CC_esc, CC_esc,
+ 'e', CC_esc, CC_esc,
+ 'e', CC_esc, CC_esc,
+ 'e', CC_esc, CC_esc,
+ 'E',
+ 'E', CC_esc, CC_esc,
+ 'E', CC_esc, CC_esc,
+ 'E', CC_esc, CC_esc,
+ 'E', CC_esc, CC_esc,
+ 'E', CC_esc, CC_esc,
+ 'f',
+ 'f', '\f', '\f',
+ 'f', '\f', '\f',
+ 'f', '\f', '\f',
+ 'f', '\f', '\f',
+ 'f', '\f', '\f',
+ 'n',
+ 'n', '\n', '\n',
+ 'n', '\n', '\n',
+ 'n', '\n', '\n',
+ 'n', '\n', '\n',
+ 'n', '\n', '\n',
+ 'r',
+ 'r', '\r', '\r',
+ 'r', '\r', '\r',
+ 'r', '\r', '\r',
+ 'r', '\r', '\r',
+ 'r', '\r', '\r',
+ 't',
+ 't', '\t', '\t',
+ 't', '\t', '\t',
+ 't', '\t', '\t',
+ 't', '\t', '\t',
+ 't', '\t', '\t',
+ 'v',
+ 'v', CC_vt, CC_vt,
+ 'v', CC_vt, CC_vt,
+ 'v', CC_vt, CC_vt,
+ 'v', CC_vt, CC_vt,
+ 'v', CC_vt, CC_vt,
+ 'x',
+ 'x', T_ESCAPE, T_ESCAPE,
+ 'x', T_ESCAPE, T_ESCAPE,
+ 'x', T_ESCAPE, T_ESCAPE,
+ 'x', T_ESCAPE, T_ESCAPE,
+ 'x', T_ESCAPE, T_ESCAPE,
+};
+
+/*
+ * all allocation/free done here
+ * interface compatible with vmresize()
+ *
+ * malloc(n) alloc(0,n)
+ * realloc(p,n) alloc(p,n)
+ * free(p) alloc(p,0)
+ */
+
+void*
+alloc(register regdisc_t* disc, void* p, size_t n)
+{
+ if (disc->re_resizef)
+ {
+ if (!n && (disc->re_flags & REG_NOFREE))
+ return 0;
+ return (*disc->re_resizef)(disc->re_resizehandle, p, n);
+ }
+ else if (!n)
+ {
+ if (!(disc->re_flags & REG_NOFREE))
+ free(p);
+ return 0;
+ }
+ else if (p)
+ return realloc(p, n);
+ else
+ return malloc(n);
+}
diff --git a/usr/src/lib/libast/common/regex/reglib.h b/usr/src/lib/libast/common/regex/reglib.h
new file mode 100644
index 0000000000..e2a85fea2a
--- /dev/null
+++ b/usr/src/lib/libast/common/regex/reglib.h
@@ -0,0 +1,578 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * posix regex implementation
+ *
+ * based on Doug McIlroy's C++ implementation
+ * Knuth-Morris-Pratt adapted from Corman-Leiserson-Rivest
+ * Boyer-Moore from conversations with David Korn, Phong Vo, Andrew Hume
+ */
+
+#ifndef _REGLIB_H
+#define _REGLIB_H
+
+#define REG_VERSION_EXEC 20020509L
+#define REG_VERSION_MAP 20030916L /* regdisc_t.re_map */
+
+#define re_info env
+
+#define alloc _reg_alloc
+#define classfun _reg_classfun
+#define drop _reg_drop
+#define fatal _reg_fatal
+#define state _reg_state
+
+typedef struct regsubop_s
+{
+ int op; /* REG_SUB_LOWER,REG_SUB_UPPER */
+ int off; /* re_rhs or match[] offset */
+ int len; /* re_rhs len or len==0 match[] */
+} regsubop_t;
+
+#define _REG_SUB_PRIVATE_ \
+ char* re_cur; /* re_buf cursor */ \
+ char* re_end; /* re_buf end */ \
+ regsubop_t* re_ops; /* rhs ops */ \
+ char re_rhs[1]; /* substitution rhs */
+
+#include <ast.h>
+#include <cdt.h>
+#include <stk.h>
+
+#include "regex.h"
+
+#include <ctype.h>
+#include <errno.h>
+
+#define MBSIZE(p) ((ast.tmp_int=mbsize(p))>0?ast.tmp_int:1)
+
+#undef RE_DUP_MAX /* posix puts this in limits.h! */
+#define RE_DUP_MAX (INT_MAX/2-1) /* 2*RE_DUP_MAX won't overflow */
+#define RE_DUP_INF (RE_DUP_MAX+1) /* infinity, for * */
+#define BACK_REF_MAX 9
+
+#define REG_COMP (REG_DELIMITED|REG_ESCAPE|REG_EXTENDED|REG_FIRST|REG_ICASE|REG_NOSUB|REG_NEWLINE|REG_SHELL|REG_AUGMENTED|REG_LEFT|REG_LITERAL|REG_MINIMAL|REG_NULL|REG_RIGHT|REG_LENIENT|REG_MUSTDELIM)
+#define REG_EXEC (REG_ADVANCE|REG_INVERT|REG_NOTBOL|REG_NOTEOL|REG_STARTEND)
+
+#define REX_NULL 0 /* null string (internal) */
+#define REX_ALT 1 /* a|b */
+#define REX_ALT_CATCH 2 /* REX_ALT catcher */
+#define REX_BACK 3 /* \1, \2, etc */
+#define REX_BEG 4 /* initial ^ */
+#define REX_BEG_STR 5 /* initial ^ w/ no newline */
+#define REX_BM 6 /* Boyer-Moore */
+#define REX_CAT 7 /* catenation catcher */
+#define REX_CLASS 8 /* [...] */
+#define REX_COLL_CLASS 9 /* collation order [...] */
+#define REX_CONJ 10 /* a&b */
+#define REX_CONJ_LEFT 11 /* REX_CONJ left catcher */
+#define REX_CONJ_RIGHT 12 /* REX_CONJ right catcher */
+#define REX_DONE 13 /* completed match (internal) */
+#define REX_DOT 14 /* . */
+#define REX_END 15 /* final $ */
+#define REX_END_STR 16 /* final $ before tail newline */
+#define REX_EXEC 17 /* call re.re_exec() */
+#define REX_FIN_STR 18 /* final $ w/ no newline */
+#define REX_GROUP 19 /* \(...\) */
+#define REX_GROUP_CATCH 20 /* REX_GROUP catcher */
+#define REX_GROUP_AHEAD 21 /* 0-width lookahead */
+#define REX_GROUP_AHEAD_CATCH 22 /* REX_GROUP_AHEAD catcher */
+#define REX_GROUP_AHEAD_NOT 23 /* inverted 0-width lookahead */
+#define REX_GROUP_BEHIND 24 /* 0-width lookbehind */
+#define REX_GROUP_BEHIND_CATCH 25 /* REX_GROUP_BEHIND catcher */
+#define REX_GROUP_BEHIND_NOT 26 /* inverted 0-width lookbehind */
+#define REX_GROUP_BEHIND_NOT_CATCH 27 /* REX_GROUP_BEHIND_NOT catcher */
+#define REX_GROUP_COND 28 /* conditional group */
+#define REX_GROUP_COND_CATCH 29 /* conditional group catcher */
+#define REX_GROUP_CUT 30 /* don't backtrack over this */
+#define REX_GROUP_CUT_CATCH 31 /* REX_GROUP_CUT catcher */
+#define REX_KMP 32 /* Knuth-Morris-Pratt */
+#define REX_NEG 33 /* negation */
+#define REX_NEG_CATCH 34 /* REX_NEG catcher */
+#define REX_NEST 35 /* nested match */
+#define REX_ONECHAR 36 /* a single-character literal */
+#define REX_REP 37 /* Kleene closure */
+#define REX_REP_CATCH 38 /* REX_REP catcher */
+#define REX_STRING 39 /* some chars */
+#define REX_TRIE 40 /* alternation of strings */
+#define REX_WBEG 41 /* \< */
+#define REX_WEND 42 /* \> */
+#define REX_WORD 43 /* word boundary */
+#define REX_WORD_NOT 44 /* not word boundary */
+
+#define T_META ((int)UCHAR_MAX+1)
+#define T_STAR (T_META+0)
+#define T_PLUS (T_META+1)
+#define T_QUES (T_META+2)
+#define T_BANG (T_META+3)
+#define T_AT (T_META+4)
+#define T_TILDE (T_META+5)
+#define T_PERCENT (T_META+6)
+#define T_LEFT (T_META+7)
+#define T_OPEN (T_META+8)
+#define T_CLOSE (T_OPEN+1)
+#define T_RIGHT (T_OPEN+2)
+#define T_CFLX (T_OPEN+3)
+#define T_DOT (T_OPEN+4)
+#define T_DOTSTAR (T_OPEN+5)
+#define T_END (T_OPEN+6)
+#define T_BAD (T_OPEN+7)
+#define T_DOLL (T_OPEN+8)
+#define T_BRA (T_OPEN+9)
+#define T_BAR (T_OPEN+10)
+#define T_AND (T_OPEN+11)
+#define T_LT (T_OPEN+12)
+#define T_GT (T_OPEN+13)
+#define T_SLASHPLUS (T_OPEN+14)
+#define T_GROUP (T_OPEN+15)
+#define T_WORD (T_OPEN+16)
+#define T_WORD_NOT (T_WORD+1)
+#define T_BEG_STR (T_WORD+2)
+#define T_END_STR (T_WORD+3)
+#define T_FIN_STR (T_WORD+4)
+#define T_ESCAPE (T_WORD+5)
+#define T_ALNUM (T_WORD+6)
+#define T_ALNUM_NOT (T_ALNUM+1)
+#define T_DIGIT (T_ALNUM+2)
+#define T_DIGIT_NOT (T_ALNUM+3)
+#define T_SPACE (T_ALNUM+4)
+#define T_SPACE_NOT (T_ALNUM+5)
+#define T_BACK (T_ALNUM+6)
+
+#define BRE 0
+#define ERE 3
+#define ARE 6
+#define SRE 9
+#define KRE 12
+
+#define HIT SSIZE_MAX
+
+#define bitclr(p,c) ((p)[((c)>>3)&037]&=(~(1<<((c)&07))))
+#define bitset(p,c) ((p)[((c)>>3)&037]|=(1<<((c)&07)))
+#define bittst(p,c) ((p)[((c)>>3)&037]&(1<<((c)&07)))
+
+#define setadd(p,c) bitset((p)->bits,c)
+#define setclr(p,c) bitclr((p)->bits,c)
+#define settst(p,c) bittst((p)->bits,c)
+
+#if _hdr_wchar && _lib_wctype && _lib_iswctype
+
+#include <stdio.h> /* because <wchar.h> includes it and we generate it */
+#include <wchar.h>
+#if _hdr_wctype
+#include <wctype.h>
+#endif
+
+#if !defined(iswblank) && !_lib_iswblank
+#define _need_iswblank 1
+#define iswblank(x) _reg_iswblank(x)
+extern int _reg_iswblank(wint_t);
+#endif
+
+#if !defined(towupper) && !_lib_towupper
+#define towupper(x) toupper(x)
+#endif
+
+#if !defined(towlower) && !_lib_towlower
+#define towlower(x) tolower(x)
+#endif
+
+#else
+
+#undef _lib_wctype
+
+#ifndef iswalnum
+#define iswalnum(x) isalnum(x)
+#endif
+#ifndef iswalpha
+#define iswalpha(x) isalpha(x)
+#endif
+#ifndef iswcntrl
+#define iswcntrl(x) iscntrl(x)
+#endif
+#ifndef iswdigit
+#define iswdigit(x) isdigit(x)
+#endif
+#ifndef iswgraph
+#define iswgraph(x) isgraph(x)
+#endif
+#ifndef iswlower
+#define iswlower(x) islower(x)
+#endif
+#ifndef iswprint
+#define iswprint(x) isprint(x)
+#endif
+#ifndef iswpunct
+#define iswpunct(x) ispunct(x)
+#endif
+#ifndef iswspace
+#define iswspace(x) isspace(x)
+#endif
+#ifndef iswupper
+#define iswupper(x) isupper(x)
+#endif
+#ifndef iswxdigit
+#define iswxdigit(x) isxdigit(x)
+#endif
+
+#ifndef towlower
+#define towlower(x) tolower(x)
+#endif
+#ifndef towupper
+#define towupper(x) toupper(x)
+#endif
+
+#endif
+
+#ifndef iswblank
+#define iswblank(x) ((x)==' '||(x)=='\t')
+#endif
+
+#ifndef iswgraph
+#define iswgraph(x) (iswprint(x)&&!iswblank(x))
+#endif
+
+#define isword(x) (isalnum(x)||(x)=='_')
+
+/*
+ * collation element support
+ */
+
+#define COLL_KEY_MAX 15
+
+#if COLL_KEY_MAX < MB_LEN_MAX
+#undef COLL_KEY_MAX
+#define COLL_KEY_MAX MB_LEN_MAX
+#endif
+
+typedef unsigned char Ckey_t[COLL_KEY_MAX+1];
+
+#define COLL_end 0
+#define COLL_call 1
+#define COLL_char 2
+#define COLL_range 3
+#define COLL_range_lc 4
+#define COLL_range_uc 5
+
+typedef struct Celt_s
+{
+ short typ;
+ short min;
+ short max;
+ regclass_t fun;
+ Ckey_t beg;
+ Ckey_t end;
+} Celt_t;
+
+/*
+ * private stuff hanging off regex_t
+ */
+
+typedef struct Stk_pos_s
+{
+ off_t offset;
+ char* base;
+} Stk_pos_t;
+
+typedef struct Vector_s
+{
+ Stk_t* stk; /* stack pointer */
+ char* vec; /* the data */
+ int inc; /* growth increment */
+ int siz; /* element size */
+ int max; /* max index */
+ int cur; /* current index -- user domain */
+} Vector_t;
+
+/*
+ * Rex_t subtypes
+ */
+
+typedef struct Cond_s
+{
+ unsigned char* beg; /* beginning of next match */
+ struct Rex_s* next[2]; /* 0:no 1:yes next pattern */
+ struct Rex_s* cont; /* right catcher */
+ int yes; /* yes condition hit */
+} Cond_t;
+
+typedef struct Conj_left_s
+{
+ unsigned char* beg; /* beginning of left match */
+ struct Rex_s* right; /* right pattern */
+ struct Rex_s* cont; /* right catcher */
+} Conj_left_t;
+
+typedef struct Conj_right_s
+{
+ unsigned char* end; /* end of left match */
+ struct Rex_s* cont; /* ambient continuation */
+} Conj_right_t;
+
+typedef unsigned int Bm_mask_t;
+
+typedef struct Bm_s
+{
+ Bm_mask_t** mask;
+ size_t* skip;
+ size_t* fail;
+ size_t size;
+ ssize_t back;
+ ssize_t left;
+ ssize_t right;
+ size_t complete;
+} Bm_t;
+
+typedef struct String_s
+{
+ int* fail;
+ unsigned char* base;
+ size_t size;
+} String_t;
+
+typedef struct Set_s
+{
+ unsigned char bits[(UCHAR_MAX+1)/CHAR_BIT];
+} Set_t;
+
+typedef struct Collate_s
+{
+ int invert;
+ Celt_t* elements;
+} Collate_t;
+
+typedef struct Binary_s
+{
+ struct Rex_s* left;
+ struct Rex_s* right;
+ int serial;
+} Binary_t;
+
+typedef struct Group_s
+{
+ int number; /* group number */
+ int last; /* last contained group number */
+ int size; /* lookbehind size */
+ int back; /* backreferenced */
+ regflags_t flags; /* group flags */
+ union
+ {
+ Binary_t binary;
+ struct Rex_s* rex;
+ } expr;
+} Group_t;
+
+typedef struct Exec_s
+{
+ void* data;
+ const char* text;
+ size_t size;
+} Exec_t;
+
+#define REX_NEST_open 0x01
+#define REX_NEST_close 0x02
+#define REX_NEST_escape 0x04
+#define REX_NEST_quote 0x08
+#define REX_NEST_literal 0x10
+#define REX_NEST_delimiter 0x20
+#define REX_NEST_terminator 0x40
+#define REX_NEST_separator 0x80
+
+#define REX_NEST_SHIFT 8
+
+typedef struct Nest_s
+{
+ int primary;
+ unsigned short none; /* for Nest_t.type[-1] */
+ unsigned short type[1];
+} Nest_t;
+
+/*
+ * REX_ALT catcher, solely to get control at the end of an
+ * alternative to keep records for comparing matches.
+ */
+
+typedef struct Alt_catch_s
+{
+ struct Rex_s* cont;
+} Alt_catch_t;
+
+typedef struct Group_catch_s
+{
+ struct Rex_s* cont;
+ regoff_t* eo;
+} Group_catch_t;
+
+typedef struct Behind_catch_s
+{
+ struct Rex_s* cont;
+ unsigned char* beg;
+ unsigned char* end;
+} Behind_catch_t;
+
+/*
+ * REX_NEG catcher determines what string lengths can be matched,
+ * then Neg investigates continuations of other lengths.
+ * This is inefficient. For !POSITIONS expressions, we can do better:
+ * since matches to rex will be enumerated in decreasing order,
+ * we can investigate continuations whenever a length is skipped.
+ */
+
+typedef struct Neg_catch_s
+{
+ unsigned char* beg;
+ unsigned char* index;
+} Neg_catch_t;
+
+/*
+ * REX_REP catcher. One is created on the stack for
+ * each iteration of a complex repetition.
+ */
+
+typedef struct Rep_catch_s
+{
+ struct Rex_s* cont;
+ struct Rex_s* ref;
+ unsigned char* beg;
+ int n;
+} Rep_catch_t;
+
+/*
+ * data structure for an alternation of pure strings
+ * son points to a subtree of all strings with a common
+ * prefix ending in character c. sib links alternate
+ * letters in the same position of a word. end=1 if
+ * some word ends with c. the order of strings is
+ * irrelevant, except long words must be investigated
+ * before short ones.
+ */
+
+typedef struct Trie_node_s
+{
+ unsigned char c;
+ unsigned char end;
+ struct Trie_node_s* son;
+ struct Trie_node_s* sib;
+} Trie_node_t;
+
+typedef struct Trie_s
+{
+ Trie_node_t** root;
+ int min;
+ int max;
+} Trie_t;
+
+/*
+ * Rex_t is a node in a regular expression
+ */
+
+typedef struct Rex_s
+{
+ unsigned char type; /* node type */
+ unsigned char marked; /* already marked */
+ short serial; /* subpattern number */
+ regflags_t flags; /* scoped flags */
+ int explicit; /* scoped explicit match*/
+ struct Rex_s* next; /* remaining parts */
+ int lo; /* lo dup count */
+ int hi; /* hi dup count */
+ unsigned char* map; /* fold and/or ccode map*/
+ union
+ {
+ Alt_catch_t alt_catch; /* alt catcher */
+ Bm_t bm; /* bm */
+ Behind_catch_t behind_catch; /* behind catcher */
+ Set_t* charclass; /* char class */
+ Collate_t collate; /* collation class */
+ Cond_t cond_catch; /* cond catcher */
+ Conj_left_t conj_left; /* conj left catcher */
+ Conj_right_t conj_right; /* conj right catcher */
+ void* data; /* data after Rex_t */
+ Exec_t exec; /* re.re_exec() args */
+ Group_t group; /* a|b or rep */
+ Group_catch_t group_catch; /* group catcher */
+ Neg_catch_t neg_catch; /* neg catcher */
+ Nest_t nest; /* nested match */
+ unsigned char onechar; /* single char */
+ Rep_catch_t rep_catch; /* rep catcher */
+ String_t string; /* string/kmp */
+ Trie_t trie; /* trie */
+ } re;
+} Rex_t;
+
+typedef struct reglib_s /* library private regex_t info */
+{
+ struct Rex_s* rex; /* compiled expression */
+ regdisc_t* disc; /* REG_DISCIPLINE discipline */
+ const regex_t* regex; /* from regexec */
+ unsigned char* beg; /* beginning of string */
+ unsigned char* end; /* end of string */
+ Vector_t* pos; /* posns of certain subpatterns */
+ Vector_t* bestpos; /* ditto for best match */
+ regmatch_t* match; /* subexrs in current match */
+ regmatch_t* best; /* ditto in best match yet */
+ Stk_pos_t stk; /* exec stack pos */
+ size_t min; /* minimum match length */
+ size_t nsub; /* internal re_nsub */
+ regflags_t flags; /* flags from regcomp() */
+ int error; /* last error */
+ int explicit; /* explicit match on this char */
+ int leading; /* leading match on this char */
+ int refs; /* regcomp()+regdup() references*/
+ Rex_t done; /* the last continuation */
+ regstat_t stats; /* for regstat() */
+ unsigned char fold[UCHAR_MAX+1]; /* REG_ICASE map */
+ unsigned char hard; /* hard comp */
+ unsigned char once; /* if 1st parse fails, quit */
+ unsigned char separate; /* cannot combine */
+ unsigned char stack; /* hard comp or exec */
+ unsigned char sub; /* re_sub is valid */
+ unsigned char test; /* debug/test bitmask */
+} Env_t;
+
+typedef struct State_s /* shared state */
+{
+ regmatch_t nomatch;
+ struct
+ {
+ unsigned char key;
+ short val[15];
+ } escape[52];
+ short* magic[UCHAR_MAX+1];
+ regdisc_t disc;
+ int fatal;
+ int initialized;
+ Dt_t* attrs;
+ Dt_t* names;
+ Dtdisc_t dtdisc;
+} State_t;
+
+extern State_t state;
+
+extern void* alloc(regdisc_t*, void*, size_t);
+extern regclass_t classfun(int);
+extern void drop(regdisc_t*, Rex_t*);
+extern int fatal(regdisc_t*, int, const char*);
+
+#endif
diff --git a/usr/src/lib/libast/common/regex/regnexec.c b/usr/src/lib/libast/common/regex/regnexec.c
new file mode 100644
index 0000000000..3406e33a0a
--- /dev/null
+++ b/usr/src/lib/libast/common/regex/regnexec.c
@@ -0,0 +1,2047 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * posix regex executor
+ * single sized-record interface
+ */
+
+#include "reglib.h"
+
+#if _AST_REGEX_DEBUG
+
+#define DEBUG_TEST(f,y,n) ((debug&(debug_flag=f))?(y):(n))
+#define DEBUG_CODE(f,y,n) do if(debug&(f)){y}else{n} while(0)
+#define DEBUG_INIT() do { char* t; if (!debug) { debug = 0x80000000; if (t = getenv("_AST_regex_exec_debug")) debug |= strtoul(t, NiL, 0); } } while (0)
+
+static unsigned long debug;
+static unsigned long debug_flag;
+
+static const char* rexnames[] =
+{
+ "REX_NULL",
+ "REX_ALT",
+ "REX_ALT_CATCH",
+ "REX_BACK",
+ "REX_BEG",
+ "REX_BEG_STR",
+ "REX_BM",
+ "REX_CAT",
+ "REX_CLASS",
+ "REX_COLL_CLASS",
+ "REX_CONJ",
+ "REX_CONJ_LEFT",
+ "REX_CONJ_RIGHT",
+ "REX_DONE",
+ "REX_DOT",
+ "REX_END",
+ "REX_END_STR",
+ "REX_EXEC",
+ "REX_FIN_STR",
+ "REX_GROUP",
+ "REX_GROUP_CATCH",
+ "REX_GROUP_AHEAD",
+ "REX_GROUP_AHEAD_CATCH",
+ "REX_GROUP_AHEAD_NOT",
+ "REX_GROUP_BEHIND",
+ "REX_GROUP_BEHIND_CATCH",
+ "REX_GROUP_BEHIND_NOT",
+ "REX_GROUP_BEHIND_NOT_CATCH",
+ "REX_GROUP_COND",
+ "REX_GROUP_COND_CATCH",
+ "REX_GROUP_CUT",
+ "REX_GROUP_CUT_CATCH",
+ "REX_KMP",
+ "REX_NEG",
+ "REX_NEG_CATCH",
+ "REX_NEST",
+ "REX_ONECHAR",
+ "REX_REP",
+ "REX_REP_CATCH",
+ "REX_STRING",
+ "REX_TRIE",
+ "REX_WBEG",
+ "REX_WEND",
+ "REX_WORD",
+ "REX_WORD_NOT"
+};
+
+static const char* rexname(Rex_t* rex)
+{
+ if (!rex)
+ return "NIL";
+ if (rex->type >= elementsof(rexnames))
+ return "ERROR";
+ return rexnames[rex->type];
+}
+
+#else
+
+#define DEBUG_INIT()
+#define DEBUG_TEST(f,y,n) (n)
+#define DEBUG_CODE(f,y,n) do {n} while(0)
+
+#endif
+
+#define BEG_ALT 1 /* beginning of an alt */
+#define BEG_ONE 2 /* beginning of one iteration of a rep */
+#define BEG_REP 3 /* beginning of a repetition */
+#define BEG_SUB 4 /* beginning of a subexpression */
+#define END_ANY 5 /* end of any of above */
+
+/*
+ * returns from parse()
+ */
+
+#define NONE 0 /* no parse found */
+#define GOOD 1 /* some parse was found */
+#define CUT 2 /* no match and no backtrack */
+#define BEST 3 /* an unbeatable parse was found */
+#define BAD 4 /* error ocurred */
+
+/*
+ * REG_SHELL_DOT test
+ */
+
+#define LEADING(e,r,s) (*(s)==(e)->leading&&((s)==(e)->beg||*((s)-1)==(r)->explicit))
+
+/*
+ * Pos_t is for comparing parses. An entry is made in the
+ * array at the beginning and at the end of each Group_t,
+ * each iteration in a Group_t, and each Binary_t.
+ */
+
+typedef struct
+{
+ unsigned char* p; /* where in string */
+ size_t length; /* length in string */
+ short serial; /* preorder subpattern number */
+ short be; /* which end of pair */
+} Pos_t;
+
+/* ===== begin library support ===== */
+
+#define vector(t,v,i) (((i)<(v)->max)?(t*)((v)->vec+(i)*(v)->siz):(t*)vecseek(&(v),i))
+
+static Vector_t*
+vecopen(int inc, int siz)
+{
+ Vector_t* v;
+ Stk_t* sp;
+
+ if (inc <= 0)
+ inc = 16;
+ if (!(sp = stkopen(STK_SMALL|STK_NULL)))
+ return 0;
+ if (!(v = (Vector_t*)stkseek(sp, sizeof(Vector_t) + inc * siz)))
+ {
+ stkclose(sp);
+ return 0;
+ }
+ v->stk = sp;
+ v->vec = (char*)v + sizeof(Vector_t);
+ v->max = v->inc = inc;
+ v->siz = siz;
+ v->cur = 0;
+ return v;
+}
+
+static void*
+vecseek(Vector_t** p, int index)
+{
+ Vector_t* v = *p;
+
+ if (index >= v->max)
+ {
+ while ((v->max += v->inc) <= index);
+ if (!(v = (Vector_t*)stkseek(v->stk, sizeof(Vector_t) + v->max * v->siz)))
+ return 0;
+ *p = v;
+ v->vec = (char*)v + sizeof(Vector_t);
+ }
+ return v->vec + index * v->siz;
+}
+
+static void
+vecclose(Vector_t* v)
+{
+ if (v)
+ stkclose(v->stk);
+}
+
+typedef struct
+{
+ Stk_pos_t pos;
+ char data[1];
+} Stk_frame_t;
+
+#define stknew(s,p) ((p)->offset=stktell(s),(p)->base=stkfreeze(s,0))
+#define stkold(s,p) stkset(s,(p)->base,(p)->offset)
+
+#define stkframe(s) (*((Stk_frame_t**)stktop(s)-1))
+#define stkdata(s,t) ((t*)stkframe(s)->data)
+#define stkpop(s) stkold(s,&(stkframe(s)->pos))
+
+static void*
+stkpush(Stk_t* sp, size_t size)
+{
+ Stk_frame_t* f;
+ Stk_pos_t p;
+
+ stknew(sp, &p);
+ size = sizeof(Stk_frame_t) + sizeof(size_t) + size - 1;
+ if (!(f = (Stk_frame_t*)stkalloc(sp, sizeof(Stk_frame_t) + sizeof(Stk_frame_t*) + size - 1)))
+ return 0;
+ f->pos = p;
+ stkframe(sp) = f;
+ return f->data;
+}
+
+/* ===== end library support ===== */
+
+/*
+ * Match_frame_t is for saving and restoring match records
+ * around alternate attempts, so that fossils will not be
+ * left in the match array. These are the only entries in
+ * the match array that are not otherwise guaranteed to
+ * have current data in them when they get used.
+ */
+
+typedef struct
+{
+ size_t size;
+ regmatch_t* match;
+ regmatch_t save[1];
+} Match_frame_t;
+
+#define matchframe stkdata(stkstd,Match_frame_t)
+#define matchpush(e,x) ((x)->re.group.number?_matchpush(e,x):0)
+#define matchcopy(e,x) ((x)->re.group.number?memcpy(matchframe->match,matchframe->save,matchframe->size):(void*)0)
+#define matchpop(e,x) ((x)->re.group.number?memcpy(matchframe->match,matchframe->save,matchframe->size),stkpop(stkstd):(void*)0)
+
+#define pospop(e) (--(e)->pos->cur)
+
+/*
+ * allocate a frame and push a match onto the stack
+ */
+
+static int
+_matchpush(Env_t* env, Rex_t* rex)
+{
+ Match_frame_t* f;
+ regmatch_t* m;
+ regmatch_t* e;
+ regmatch_t* s;
+ int num;
+
+ if (rex->re.group.number <= 0 || (num = rex->re.group.last - rex->re.group.number + 1) <= 0)
+ num = 0;
+ if (!(f = (Match_frame_t*)stkpush(stkstd, sizeof(Match_frame_t) + (num - 1) * sizeof(regmatch_t))))
+ {
+ env->error = REG_ESPACE;
+ return 1;
+ }
+ f->size = num * sizeof(regmatch_t);
+ f->match = m = env->match + rex->re.group.number;
+ e = m + num;
+ s = f->save;
+ while (m < e)
+ {
+ *s++ = *m;
+ *m++ = state.nomatch;
+ }
+ return 0;
+}
+
+/*
+ * allocate a frame and push a pos onto the stack
+ */
+
+static int
+pospush(Env_t* env, Rex_t* rex, unsigned char* p, int be)
+{
+ Pos_t* pos;
+
+ if (!(pos = vector(Pos_t, env->pos, env->pos->cur)))
+ {
+ env->error = REG_ESPACE;
+ return 1;
+ }
+ pos->serial = rex->serial;
+ pos->p = p;
+ pos->be = be;
+ env->pos->cur++;
+ return 0;
+}
+
+/*
+ * two matches are known to have the same length
+ * os is start of old pos array, ns is start of new,
+ * oend and nend are end+1 pointers to ends of arrays.
+ * oe and ne are ends (not end+1) of subarrays.
+ * returns 1 if new is better, -1 if old, else 0.
+ */
+
+#if _AST_REGEX_DEBUG
+
+static void
+showmatch(regmatch_t* p)
+{
+ sfputc(sfstdout, '(');
+ if (p->rm_so < 0)
+ sfputc(sfstdout, '?');
+ else
+ sfprintf(sfstdout, "%d", p->rm_so);
+ sfputc(sfstdout, ',');
+ if (p->rm_eo < 0)
+ sfputc(sfstdout, '?');
+ else
+ sfprintf(sfstdout, "%d", p->rm_eo);
+ sfputc(sfstdout, ')');
+}
+
+static int
+better(Env_t* env, Pos_t* os, Pos_t* ns, Pos_t* oend, Pos_t* nend, int level)
+#define better _better
+{
+ int i;
+
+ DEBUG_CODE(0x0040,{sfprintf(sfstdout, "AHA better old ");for (i = 0; i <= env->nsub; i++)showmatch(&env->best[i]);sfprintf(sfstdout, "\n new ");for (i = 0; i <= env->nsub; i++)showmatch(&env->match[i]);sfprintf(sfstdout, "\n");},{0;});
+ i = better(env, os, ns, oend, nend, 0);
+ DEBUG_TEST(0x0040,(sfprintf(sfstdout, " %s\n", i <= 0 ? "OLD" : "NEW")),(0));
+ return i;
+}
+
+#endif
+
+static int
+better(Env_t* env, Pos_t* os, Pos_t* ns, Pos_t* oend, Pos_t* nend, int level)
+{
+ Pos_t* oe;
+ Pos_t* ne;
+ int k;
+ int n;
+
+ if (env->error)
+ return -1;
+ for (;;)
+ {
+ DEBUG_CODE(0x0080,{sfprintf(sfstdout, " %-*.*sold ", (level + 3) * 4, (level + 3) * 4, "");for (oe = os; oe < oend; oe++)sfprintf(sfstdout, "<%d,%d,%d>", oe->p - env->beg, oe->serial, oe->be);sfprintf(sfstdout, "\n %-*.*snew ", (level + 3) * 4, (level + 3) * 4, "");for (oe = ns; oe < nend; oe++)sfprintf(sfstdout, "<%d,%d,%d>", oe->p - env->beg, oe->serial, oe->be);sfprintf(sfstdout, "\n");},{0;});
+ if (ns >= nend)
+ return DEBUG_TEST(0x8000,(os < oend),(0));
+ if (os >= oend)
+ return DEBUG_TEST(0x8000,(-1),(1));
+ n = os->serial;
+ if (ns->serial > n)
+ return -1;
+ if (n > ns->serial)
+ {
+ env->error = REG_PANIC;
+ return -1;
+ }
+ if (ns->p > os->p)
+ return 1;
+ if (os->p > ns->p)
+ return -1;
+ oe = os;
+ k = 0;
+ for (;;)
+ if ((++oe)->serial == n)
+ {
+ if (oe->be != END_ANY)
+ k++;
+ else if (k-- <= 0)
+ break;
+ }
+ ne = ns;
+ k = 0;
+ for (;;)
+ if ((++ne)->serial == n)
+ {
+ if (ne->be != END_ANY)
+ k++;
+ else if (k-- <= 0)
+ break;
+ }
+ if (ne->p > oe->p)
+ return 1;
+ if (oe->p > ne->p)
+ return -1;
+ if (k = better(env, os + 1, ns + 1, oe, ne, level + 1))
+ return k;
+ os = oe + 1;
+ ns = ne + 1;
+ }
+}
+
+#undef better
+
+#define follow(e,r,c,s) ((r)->next?parse(e,(r)->next,c,s):(c)?parse(e,c,0,s):BEST)
+
+static int parse(Env_t*, Rex_t*, Rex_t*, unsigned char*);
+
+static int
+parserep(Env_t* env, Rex_t* rex, Rex_t* cont, unsigned char* s, int n)
+{
+ int i;
+ int r = NONE;
+ Rex_t catcher;
+
+ DEBUG_TEST(0x0010,(sfprintf(sfstdout, "AHA#%04d 0x%04x parserep %s %d %d %d `%-.*s'\n", __LINE__, debug_flag, rexname(rex->re.group.expr.rex), rex->lo, n, rex->hi, env->end - s, s)),(0));
+ if ((rex->flags & REG_MINIMAL) && n >= rex->lo && n < rex->hi)
+ {
+ if (env->stack && pospush(env, rex, s, END_ANY))
+ return BAD;
+ i = follow(env, rex, cont, s);
+ if (env->stack)
+ pospop(env);
+ switch (i)
+ {
+ case BAD:
+ return BAD;
+ case CUT:
+ return CUT;
+ case BEST:
+ case GOOD:
+ return BEST;
+ }
+ }
+ if (n < rex->hi)
+ {
+ catcher.type = REX_REP_CATCH;
+ catcher.serial = rex->serial;
+ catcher.re.rep_catch.ref = rex;
+ catcher.re.rep_catch.cont = cont;
+ catcher.re.rep_catch.beg = s;
+ catcher.re.rep_catch.n = n + 1;
+ catcher.next = rex->next;
+ if (n == 0)
+ rex->re.rep_catch.beg = s;
+ if (env->stack)
+ {
+DEBUG_TEST(0x0004,(sfprintf(sfstdout,"AHA#%04d 0x%04x PUSH (%d,%d)(%d,%d) (%d,%d)(%d,%d)\n", __LINE__, debug_flag, rex->re.group.number, env->best[0].rm_so, env->best[0].rm_eo, env->best[1].rm_so, env->best[1].rm_eo, env->match[0].rm_so, env->match[0].rm_eo, env->match[1].rm_so, env->match[1].rm_eo)),(0));
+ if (matchpush(env, rex))
+ return BAD;
+ if (pospush(env, rex, s, BEG_ONE))
+ return BAD;
+DEBUG_TEST(0x0004,(sfprintf(sfstdout,"AHA#%04d 0x%04x PUSH (%d,%d)(%d,%d) (%d,%d)(%d,%d)\n", __LINE__, debug_flag, rex->re.group.number, env->best[0].rm_so, env->best[0].rm_eo, env->best[1].rm_so, env->best[1].rm_eo, env->match[0].rm_so, env->match[0].rm_eo, env->match[1].rm_so, env->match[1].rm_eo)),(0));
+ }
+ r = parse(env, rex->re.group.expr.rex, &catcher, s);
+ DEBUG_TEST(0x0010,(sfprintf(sfstdout, "AHA#%04d 0x%04x parserep parse %d `%-.*s'\n", __LINE__, debug_flag, r, env->end - s, s)),(0));
+ if (env->stack)
+ {
+DEBUG_TEST(0x0004,(sfprintf(sfstdout,"AHA#%04d 0x%04x POP (%d,%d)(%d,%d) (%d,%d)(%d,%d)\n", __LINE__, debug_flag, rex->re.group.number, env->best[0].rm_so, env->best[0].rm_eo, env->best[1].rm_so, env->best[1].rm_eo, env->match[0].rm_so, env->match[0].rm_eo, env->match[1].rm_so, env->match[1].rm_eo)),(0));
+ pospop(env);
+ matchpop(env, rex);
+DEBUG_TEST(0x0004,(sfprintf(sfstdout,"AHA#%04d 0x%04x POP (%d,%d)(%d,%d) (%d,%d)(%d,%d)\n", __LINE__, debug_flag, rex->re.group.number, env->best[0].rm_so, env->best[0].rm_eo, env->best[1].rm_so, env->best[1].rm_eo, env->match[0].rm_so, env->match[0].rm_eo, env->match[1].rm_so, env->match[1].rm_eo)),(0));
+ }
+ switch (r)
+ {
+ case BAD:
+ return BAD;
+ case BEST:
+ return BEST;
+ case CUT:
+ r = NONE;
+ break;
+ case GOOD:
+ if (rex->flags & REG_MINIMAL)
+ return BEST;
+ r = GOOD;
+ break;
+ }
+ }
+ if (n < rex->lo)
+ return r;
+ if (!(rex->flags & REG_MINIMAL) || n >= rex->hi)
+ {
+ if (env->stack && pospush(env, rex, s, END_ANY))
+ return BAD;
+ i = follow(env, rex, cont, s);
+ if (env->stack)
+ pospop(env);
+ switch (i)
+ {
+ case BAD:
+ r = BAD;
+ break;
+ case CUT:
+ r = CUT;
+ break;
+ case BEST:
+ r = BEST;
+ break;
+ case GOOD:
+ r = (rex->flags & REG_MINIMAL) ? BEST : GOOD;
+ break;
+ }
+ }
+ return r;
+}
+
+static int
+parsetrie(Env_t* env, Trie_node_t* x, Rex_t* rex, Rex_t* cont, unsigned char* s)
+{
+ unsigned char* p;
+ int r;
+
+ if (p = rex->map)
+ {
+ for (;;)
+ {
+ if (s >= env->end)
+ return NONE;
+ while (x->c != p[*s])
+ if (!(x = x->sib))
+ return NONE;
+ if (x->end)
+ break;
+ x = x->son;
+ s++;
+ }
+ }
+ else
+ {
+ for (;;)
+ {
+ if (s >= env->end)
+ return NONE;
+ while (x->c != *s)
+ if (!(x = x->sib))
+ return NONE;
+ if (x->end)
+ break;
+ x = x->son;
+ s++;
+ }
+ }
+ s++;
+ if (rex->flags & REG_MINIMAL)
+ switch (follow(env, rex, cont, s))
+ {
+ case BAD:
+ return BAD;
+ case CUT:
+ return CUT;
+ case BEST:
+ case GOOD:
+ return BEST;
+ }
+ if (x->son)
+ switch (parsetrie(env, x->son, rex, cont, s))
+ {
+ case BAD:
+ return BAD;
+ case CUT:
+ return CUT;
+ case BEST:
+ return BEST;
+ case GOOD:
+ if (rex->flags & REG_MINIMAL)
+ return BEST;
+ r = GOOD;
+ break;
+ default:
+ r = NONE;
+ break;
+ }
+ else
+ r = NONE;
+ if (!(rex->flags & REG_MINIMAL))
+ switch (follow(env, rex, cont, s))
+ {
+ case BAD:
+ return BAD;
+ case CUT:
+ return CUT;
+ case BEST:
+ return BEST;
+ case GOOD:
+ return GOOD;
+ }
+ return r;
+}
+
+static int
+collelt(register Celt_t* ce, char* key, int c, int x)
+{
+ Ckey_t elt;
+
+ mbxfrm(elt, key, COLL_KEY_MAX);
+ for (;; ce++)
+ {
+ switch (ce->typ)
+ {
+ case COLL_call:
+ if (!x && (*ce->fun)(c))
+ return 1;
+ continue;
+ case COLL_char:
+ if (!strcmp((char*)ce->beg, (char*)elt))
+ return 1;
+ continue;
+ case COLL_range:
+ if (strcmp((char*)ce->beg, (char*)elt) <= ce->min && strcmp((char*)elt, (char*)ce->end) <= ce->max)
+ return 1;
+ continue;
+ case COLL_range_lc:
+ if (strcmp((char*)ce->beg, (char*)elt) <= ce->min && strcmp((char*)elt, (char*)ce->end) <= ce->max && (iswlower(c) || !iswupper(c)))
+ return 1;
+ continue;
+ case COLL_range_uc:
+ if (strcmp((char*)ce->beg, (char*)elt) <= ce->min && strcmp((char*)elt, (char*)ce->end) <= ce->max && (iswupper(c) || !iswlower(c)))
+ return 1;
+ continue;
+ }
+ break;
+ }
+ return 0;
+}
+
+static int
+collic(register Celt_t* ce, char* key, register char* nxt, int c, int x)
+{
+ if (!x)
+ {
+ if (collelt(ce, key, c, x))
+ return 1;
+ if (iswlower(c))
+ c = towupper(c);
+ else if (iswupper(c))
+ c = towlower(c);
+ else
+ return 0;
+ x = wctomb(key, c);
+ key[x] = 0;
+ return collelt(ce, key, c, 0);
+ }
+ while (*nxt)
+ {
+ if (collic(ce, key, nxt + 1, c, x))
+ return 1;
+ if (islower(*nxt))
+ *nxt = toupper(*nxt);
+ else if (isupper(*nxt))
+ *nxt = tolower(*nxt);
+ else
+ return 0;
+ nxt++;
+ }
+ return collelt(ce, key, c, x);
+}
+
+static int
+collmatch(Rex_t* rex, unsigned char* s, unsigned char* e, unsigned char** p)
+{
+ unsigned char* t;
+ wchar_t c;
+ int w;
+ int r;
+ int x;
+ int ic;
+ Ckey_t key;
+ Ckey_t elt;
+
+ ic = (rex->flags & REG_ICASE);
+ if ((w = MBSIZE(s)) > 1)
+ {
+ memcpy((char*)key, (char*)s, w);
+ key[w] = 0;
+ t = s;
+ c = mbchar(t);
+#if !_lib_wctype
+ c &= 0xff;
+#endif
+ x = 0;
+ }
+ else
+ {
+ c = s[0];
+ if (ic && isupper(c))
+ c = tolower(c);
+ key[0] = c;
+ key[1] = 0;
+ if (isalpha(c))
+ {
+ x = e - s;
+ if (x > COLL_KEY_MAX)
+ x = COLL_KEY_MAX;
+ while (w < x)
+ {
+ c = s[w];
+ if (!isalpha(c))
+ break;
+ r = mbxfrm(elt, key, COLL_KEY_MAX);
+ if (ic && isupper(c))
+ c = tolower(c);
+ key[w] = c;
+ key[w + 1] = 0;
+ if (mbxfrm(elt, key, COLL_KEY_MAX) != r)
+ break;
+ w++;
+ }
+ }
+ key[w] = 0;
+ c = key[0];
+ x = w - 1;
+ }
+ r = 1;
+ for (;;)
+ {
+ if (ic ? collic(rex->re.collate.elements, (char*)key, (char*)key, c, x) : collelt(rex->re.collate.elements, (char*)key, c, x))
+ break;
+ if (!x)
+ {
+ r = 0;
+ break;
+ }
+ w = x--;
+ key[w] = 0;
+ }
+ *p = s + w;
+ return rex->re.collate.invert ? !r : r;
+}
+
+static unsigned char*
+nestmatch(register unsigned char* s, register unsigned char* e, const unsigned short* type, register int co)
+{
+ register int c;
+ register int cc;
+ unsigned int n;
+ int oc;
+
+ if (type[co] & (REX_NEST_literal|REX_NEST_quote))
+ {
+ n = (type[co] & REX_NEST_literal) ? REX_NEST_terminator : (REX_NEST_escape|REX_NEST_terminator);
+ while (s < e)
+ {
+ c = *s++;
+ if (c == co)
+ return s;
+ else if (type[c] & n)
+ {
+ if (s >= e || (type[c] & REX_NEST_terminator))
+ break;
+ s++;
+ }
+ }
+ }
+ else
+ {
+ cc = type[co] >> REX_NEST_SHIFT;
+ oc = type[co] & (REX_NEST_open|REX_NEST_close);
+ n = 1;
+ while (s < e)
+ {
+ c = *s++;
+ switch (type[c] & (REX_NEST_escape|REX_NEST_open|REX_NEST_close|REX_NEST_delimiter|REX_NEST_separator|REX_NEST_terminator))
+ {
+ case REX_NEST_delimiter:
+ case REX_NEST_terminator:
+ return oc ? 0 : s;
+ case REX_NEST_separator:
+ if (!oc)
+ return s;
+ break;
+ case REX_NEST_escape:
+ if (s >= e)
+ return 0;
+ s++;
+ break;
+ case REX_NEST_open|REX_NEST_close:
+ if (c == cc)
+ {
+ if (!--n)
+ return s;
+ }
+ /*FALLTHROUGH*/
+ case REX_NEST_open:
+ if (c == co)
+ {
+ if (!++n)
+ return 0;
+ }
+ else if (!(s = nestmatch(s, e, type, c)))
+ return 0;
+ break;
+ case REX_NEST_close:
+ if (c != cc)
+ return 0;
+ if (!--n)
+ return s;
+ break;
+ }
+ }
+ return (oc || !(type[UCHAR_MAX+1] & REX_NEST_terminator)) ? 0 : s;
+ }
+ return 0;
+}
+
+static int
+parse(Env_t* env, Rex_t* rex, Rex_t* cont, unsigned char* s)
+{
+ int c;
+ int d;
+ int i;
+ int m;
+ int n;
+ int r;
+ int* f;
+ unsigned char* p;
+ unsigned char* t;
+ unsigned char* b;
+ unsigned char* e;
+ char* u;
+ regmatch_t* o;
+ Trie_node_t* x;
+ Rex_t* q;
+ Rex_t catcher;
+ Rex_t next;
+
+ for (;;)
+ {
+DEBUG_TEST(0x0008,(sfprintf(sfstdout, "AHA#%04d 0x%04x parse %s `%-.*s'\n", __LINE__, debug_flag, rexname(rex), env->end - s, s)),(0));
+ switch (rex->type)
+ {
+ case REX_ALT:
+ if (env->stack)
+ {
+ if (matchpush(env, rex))
+ return BAD;
+ if (pospush(env, rex, s, BEG_ALT))
+ return BAD;
+ catcher.type = REX_ALT_CATCH;
+ catcher.serial = rex->serial;
+ catcher.re.alt_catch.cont = cont;
+ catcher.next = rex->next;
+ r = parse(env, rex->re.group.expr.binary.left, &catcher, s);
+ if (r < BEST || (rex->flags & REG_MINIMAL))
+ {
+ matchcopy(env, rex);
+ ((Pos_t*)env->pos->vec + env->pos->cur - 1)->serial = catcher.serial = rex->re.group.expr.binary.serial;
+ n = parse(env, rex->re.group.expr.binary.right, &catcher, s);
+ if (n != NONE)
+ r = n;
+ }
+ pospop(env);
+ matchpop(env, rex);
+ }
+ else
+ {
+ if ((r = parse(env, rex->re.group.expr.binary.left, cont, s)) == NONE)
+ r = parse(env, rex->re.group.expr.binary.right, cont, s);
+ if (r == GOOD)
+ r = BEST;
+ }
+ return r;
+ case REX_ALT_CATCH:
+ if (pospush(env, rex, s, END_ANY))
+ return BAD;
+ r = follow(env, rex, rex->re.alt_catch.cont, s);
+ pospop(env);
+ return r;
+ case REX_BACK:
+ o = &env->match[rex->lo];
+ if (o->rm_so < 0)
+ return NONE;
+ i = o->rm_eo - o->rm_so;
+ e = s + i;
+ if (e > env->end)
+ return NONE;
+ t = env->beg + o->rm_so;
+ if (!(p = rex->map))
+ {
+ while (s < e)
+ if (*s++ != *t++)
+ return NONE;
+ }
+ else if (!mbwide())
+ {
+ while (s < e)
+ if (p[*s++] != p[*t++])
+ return NONE;
+ }
+ else
+ {
+ while (s < e)
+ {
+ c = mbchar(s);
+ d = mbchar(t);
+ if (towupper(c) != towupper(d))
+ return NONE;
+ }
+ }
+ break;
+ case REX_BEG:
+ if ((!(rex->flags & REG_NEWLINE) || s <= env->beg || *(s - 1) != '\n') && ((env->flags & REG_NOTBOL) || s != env->beg))
+ return NONE;
+ break;
+ case REX_CLASS:
+ if (LEADING(env, rex, s))
+ return NONE;
+ n = rex->hi;
+ if (n > env->end - s)
+ n = env->end - s;
+ m = rex->lo;
+ if (m > n)
+ return NONE;
+ r = NONE;
+ if (!(rex->flags & REG_MINIMAL))
+ {
+ for (i = 0; i < n; i++)
+ if (!settst(rex->re.charclass, s[i]))
+ {
+ n = i;
+ break;
+ }
+ for (s += n; n-- >= m; s--)
+ switch (follow(env, rex, cont, s))
+ {
+ case BAD:
+ return BAD;
+ case CUT:
+ return CUT;
+ case BEST:
+ return BEST;
+ case GOOD:
+ r = GOOD;
+ break;
+ }
+ }
+ else
+ {
+ for (e = s + m; s < e; s++)
+ if (!settst(rex->re.charclass, *s))
+ return r;
+ e += n - m;
+ for (;;)
+ {
+ switch (follow(env, rex, cont, s))
+ {
+ case BAD:
+ return BAD;
+ case CUT:
+ return CUT;
+ case BEST:
+ case GOOD:
+ return BEST;
+ }
+ if (s >= e || !settst(rex->re.charclass, *s))
+ break;
+ s++;
+ }
+ }
+ return r;
+ case REX_COLL_CLASS:
+ if (LEADING(env, rex, s))
+ return NONE;
+ n = rex->hi;
+ if (n > env->end - s)
+ n = env->end - s;
+ m = rex->lo;
+ if (m > n)
+ return NONE;
+ r = NONE;
+ e = env->end;
+ if (!(rex->flags & REG_MINIMAL))
+ {
+ if (!(b = (unsigned char*)stkpush(stkstd, n)))
+ {
+ env->error = REG_ESPACE;
+ return BAD;
+ }
+ for (i = 0; s < e && i < n && collmatch(rex, s, e, &t); i++)
+ {
+ b[i] = t - s;
+ s = t;
+ }
+ for (; i-- >= rex->lo; s -= b[i])
+ switch (follow(env, rex, cont, s))
+ {
+ case BAD:
+ stkpop(stkstd);
+ return BAD;
+ case CUT:
+ stkpop(stkstd);
+ return CUT;
+ case BEST:
+ stkpop(stkstd);
+ return BEST;
+ case GOOD:
+ r = GOOD;
+ break;
+ }
+ stkpop(stkstd);
+ }
+ else
+ {
+ for (i = 0; i < m && s < e; i++, s = t)
+ if (!collmatch(rex, s, e, &t))
+ return r;
+ while (i++ <= n)
+ {
+ switch (follow(env, rex, cont, s))
+ {
+ case BAD:
+ return BAD;
+ case CUT:
+ return CUT;
+ case BEST:
+ case GOOD:
+ return BEST;
+ }
+ if (s >= e || !collmatch(rex, s, e, &s))
+ break;
+ }
+ }
+ return r;
+ case REX_CONJ:
+ next.type = REX_CONJ_RIGHT;
+ next.re.conj_right.cont = cont;
+ next.next = rex->next;
+ catcher.type = REX_CONJ_LEFT;
+ catcher.re.conj_left.right = rex->re.group.expr.binary.right;
+ catcher.re.conj_left.cont = &next;
+ catcher.re.conj_left.beg = s;
+ catcher.next = 0;
+ return parse(env, rex->re.group.expr.binary.left, &catcher, s);
+ case REX_CONJ_LEFT:
+ rex->re.conj_left.cont->re.conj_right.end = s;
+ cont = rex->re.conj_left.cont;
+ s = rex->re.conj_left.beg;
+ rex = rex->re.conj_left.right;
+ continue;
+ case REX_CONJ_RIGHT:
+ if (rex->re.conj_right.end != s)
+ return NONE;
+ cont = rex->re.conj_right.cont;
+ break;
+ case REX_DONE:
+ if (!env->stack)
+ return BEST;
+ n = s - env->beg;
+ r = env->nsub;
+ DEBUG_TEST(0x0100,(sfprintf(sfstdout,"AHA#%04d 0x%04x %s (%d,%d)(%d,%d)(%d,%d)(%d,%d) (%d,%d)(%d,%d)\n", __LINE__, debug_flag, rexname(rex), env->best[0].rm_so, env->best[0].rm_eo, env->best[1].rm_so, env->best[1].rm_eo, env->best[2].rm_so, env->best[2].rm_eo, env->best[3].rm_so, env->best[3].rm_eo, env->match[0].rm_so, env->match[0].rm_eo, env->match[1].rm_so, env->match[1].rm_eo)),(0));
+ if ((i = env->best[0].rm_eo) >= 0)
+ {
+ if (rex->flags & REG_MINIMAL)
+ {
+ if (n > i)
+ return GOOD;
+ }
+ else
+ {
+ if (n < i)
+ return GOOD;
+ }
+ if (n == i && better(env,
+ (Pos_t*)env->bestpos->vec,
+ (Pos_t*)env->pos->vec,
+ (Pos_t*)env->bestpos->vec+env->bestpos->cur,
+ (Pos_t*)env->pos->vec+env->pos->cur,
+ 0) <= 0)
+ return GOOD;
+ }
+ env->best[0].rm_eo = n;
+ memcpy(&env->best[1], &env->match[1], r * sizeof(regmatch_t));
+ n = env->pos->cur;
+ if (!vector(Pos_t, env->bestpos, n))
+ {
+ env->error = REG_ESPACE;
+ return BAD;
+ }
+ env->bestpos->cur = n;
+ memcpy(env->bestpos->vec, env->pos->vec, n * sizeof(Pos_t));
+ DEBUG_TEST(0x0100,(sfprintf(sfstdout,"AHA#%04d 0x%04x %s (%d,%d)(%d,%d)(%d,%d)(%d,%d) (%d,%d)(%d,%d)\n", __LINE__, debug_flag, rexname(rex), env->best[0].rm_so, env->best[0].rm_eo, env->best[1].rm_so, env->best[1].rm_eo, env->best[2].rm_so, env->best[2].rm_eo, env->best[3].rm_so, env->best[3].rm_eo, env->match[0].rm_so, env->match[0].rm_eo, env->match[1].rm_so, env->match[1].rm_eo)),(0));
+ return GOOD;
+ case REX_DOT:
+ if (LEADING(env, rex, s))
+ return NONE;
+ n = rex->hi;
+ if (n > env->end - s)
+ n = env->end - s;
+ m = rex->lo;
+ if (m > n)
+ return NONE;
+ if ((c = rex->explicit) >= 0 && !mbwide())
+ for (i = 0; i < n; i++)
+ if (s[i] == c)
+ {
+ n = i;
+ break;
+ }
+ r = NONE;
+ if (!(rex->flags & REG_MINIMAL))
+ {
+ if (!mbwide())
+ {
+ for (s += n; n-- >= m; s--)
+ switch (follow(env, rex, cont, s))
+ {
+ case BAD:
+ return BAD;
+ case CUT:
+ return CUT;
+ case BEST:
+ return BEST;
+ case GOOD:
+ r = GOOD;
+ break;
+ }
+ }
+ else
+ {
+ if (!(b = (unsigned char*)stkpush(stkstd, n)))
+ {
+ env->error = REG_ESPACE;
+ return BAD;
+ }
+ e = env->end;
+ for (i = 0; s < e && i < n && *s != c; i++)
+ s += b[i] = MBSIZE(s);
+ for (; i-- >= m; s -= b[i])
+ switch (follow(env, rex, cont, s))
+ {
+ case BAD:
+ stkpop(stkstd);
+ return BAD;
+ case CUT:
+ stkpop(stkstd);
+ return CUT;
+ case BEST:
+ stkpop(stkstd);
+ return BEST;
+ case GOOD:
+ r = GOOD;
+ break;
+ }
+ stkpop(stkstd);
+ }
+ }
+ else
+ {
+ if (!mbwide())
+ {
+ e = s + n;
+ for (s += m; s <= e; s++)
+ switch (follow(env, rex, cont, s))
+ {
+ case BAD:
+ return BAD;
+ case CUT:
+ return CUT;
+ case BEST:
+ case GOOD:
+ return BEST;
+ }
+ }
+ else
+ {
+ e = env->end;
+ for (i = 0; s < e && i < m && *s != c; i++)
+ s += MBSIZE(s);
+ if (i >= m)
+ for (; s <= e && i <= n; s += MBSIZE(s), i++)
+ switch (follow(env, rex, cont, s))
+ {
+ case BAD:
+ return BAD;
+ case CUT:
+ return CUT;
+ case BEST:
+ case GOOD:
+ return BEST;
+ }
+ }
+ }
+ return r;
+ case REX_END:
+ if ((!(rex->flags & REG_NEWLINE) || *s != '\n') && ((env->flags & REG_NOTEOL) || s < env->end))
+ return NONE;
+ break;
+ case REX_GROUP:
+DEBUG_TEST(0x0200,(sfprintf(sfstdout,"AHA#%04d 0x%04x parse %s `%-.*s'\n", __LINE__, debug_flag, rexname(rex), env->end - s, s)),(0));
+ if (env->stack)
+ {
+ if (rex->re.group.number)
+ env->match[rex->re.group.number].rm_so = s - env->beg;
+ if (pospush(env, rex, s, BEG_SUB))
+ return BAD;
+ catcher.re.group_catch.eo = rex->re.group.number ? &env->match[rex->re.group.number].rm_eo : (regoff_t*)0;
+ }
+ catcher.type = REX_GROUP_CATCH;
+ catcher.serial = rex->serial;
+ catcher.re.group_catch.cont = cont;
+ catcher.next = rex->next;
+ r = parse(env, rex->re.group.expr.rex, &catcher, s);
+ if (env->stack)
+ {
+ pospop(env);
+ if (rex->re.group.number)
+ env->match[rex->re.group.number].rm_so = -1;
+ }
+ return r;
+ case REX_GROUP_CATCH:
+DEBUG_TEST(0x0200,(sfprintf(sfstdout,"AHA#%04d 0x%04x parse %s=>%s `%-.*s'\n", __LINE__, debug_flag, rexname(rex), rexname(rex->re.group_catch.cont), env->end - s, s)),(0));
+ if (env->stack)
+ {
+ if (rex->re.group_catch.eo)
+ *rex->re.group_catch.eo = s - env->beg;
+ if (pospush(env, rex, s, END_ANY))
+ return BAD;
+ }
+ r = follow(env, rex, rex->re.group_catch.cont, s);
+ if (env->stack)
+ {
+ pospop(env);
+ if (rex->re.group_catch.eo)
+ *rex->re.group_catch.eo = -1;
+ }
+ return r;
+ case REX_GROUP_AHEAD:
+ catcher.type = REX_GROUP_AHEAD_CATCH;
+ catcher.flags = rex->flags;
+ catcher.serial = rex->serial;
+ catcher.re.rep_catch.beg = s;
+ catcher.re.rep_catch.cont = cont;
+ catcher.next = rex->next;
+ return parse(env, rex->re.group.expr.rex, &catcher, s);
+ case REX_GROUP_AHEAD_CATCH:
+ return follow(env, rex, rex->re.rep_catch.cont, rex->re.rep_catch.beg);
+ case REX_GROUP_AHEAD_NOT:
+ r = parse(env, rex->re.group.expr.rex, NiL, s);
+ if (r == NONE)
+ r = follow(env, rex, cont, s);
+ else if (r != BAD)
+ r = NONE;
+ return r;
+ case REX_GROUP_BEHIND:
+ if ((s - env->beg) < rex->re.group.size)
+ return NONE;
+ catcher.type = REX_GROUP_BEHIND_CATCH;
+ catcher.flags = rex->flags;
+ catcher.serial = rex->serial;
+ catcher.re.behind_catch.beg = s;
+ catcher.re.behind_catch.end = e = env->end;
+ catcher.re.behind_catch.cont = cont;
+ catcher.next = rex->next;
+ for (t = s - rex->re.group.size; t >= env->beg; t--)
+ {
+ env->end = s;
+ r = parse(env, rex->re.group.expr.rex, &catcher, t);
+ env->end = e;
+ if (r != NONE)
+ return r;
+ }
+ return NONE;
+ case REX_GROUP_BEHIND_CATCH:
+ if (s != rex->re.behind_catch.beg)
+ return NONE;
+ env->end = rex->re.behind_catch.end;
+ return follow(env, rex, rex->re.behind_catch.cont, rex->re.behind_catch.beg);
+ case REX_GROUP_BEHIND_NOT:
+ if ((s - env->beg) < rex->re.group.size)
+ r = NONE;
+ else
+ {
+ catcher.type = REX_GROUP_BEHIND_NOT_CATCH;
+ catcher.re.neg_catch.beg = s;
+ catcher.next = 0;
+ e = env->end;
+ env->end = s;
+ for (t = s - rex->re.group.size; t >= env->beg; t--)
+ {
+ r = parse(env, rex->re.group.expr.rex, &catcher, t);
+ if (r != NONE)
+ break;
+ }
+ env->end = e;
+ }
+ if (r == NONE)
+ r = follow(env, rex, cont, s);
+ else if (r != BAD)
+ r = NONE;
+ return r;
+ case REX_GROUP_BEHIND_NOT_CATCH:
+ return s == rex->re.neg_catch.beg ? GOOD : NONE;
+ case REX_GROUP_COND:
+ if (q = rex->re.group.expr.binary.right)
+ {
+ catcher.re.cond_catch.next[0] = q->re.group.expr.binary.right;
+ catcher.re.cond_catch.next[1] = q->re.group.expr.binary.left;
+ }
+ else
+ catcher.re.cond_catch.next[0] = catcher.re.cond_catch.next[1] = 0;
+ if (q = rex->re.group.expr.binary.left)
+ {
+ catcher.type = REX_GROUP_COND_CATCH;
+ catcher.flags = rex->flags;
+ catcher.serial = rex->serial;
+ catcher.re.cond_catch.yes = 0;
+ catcher.re.cond_catch.beg = s;
+ catcher.re.cond_catch.cont = cont;
+ catcher.next = rex->next;
+ r = parse(env, q, &catcher, s);
+ if (r == BAD || catcher.re.cond_catch.yes)
+ return r;
+ }
+ else if (!rex->re.group.size || rex->re.group.size > 0 && env->match[rex->re.group.size].rm_so >= 0)
+ r = GOOD;
+ else
+ r = NONE;
+ if (q = catcher.re.cond_catch.next[r != NONE])
+ {
+ catcher.type = REX_CAT;
+ catcher.flags = q->flags;
+ catcher.serial = q->serial;
+ catcher.re.group_catch.cont = cont;
+ catcher.next = rex->next;
+ return parse(env, q, &catcher, s);
+ }
+ return follow(env, rex, cont, s);
+ case REX_GROUP_COND_CATCH:
+ rex->re.cond_catch.yes = 1;
+ catcher.type = REX_CAT;
+ catcher.flags = rex->flags;
+ catcher.serial = rex->serial;
+ catcher.re.group_catch.cont = rex->re.cond_catch.cont;
+ catcher.next = rex->next;
+ return parse(env, rex->re.cond_catch.next[1], &catcher, rex->re.cond_catch.beg);
+ case REX_CAT:
+ return follow(env, rex, rex->re.group_catch.cont, s);
+ case REX_GROUP_CUT:
+ catcher.type = REX_GROUP_CUT_CATCH;
+ catcher.flags = rex->flags;
+ catcher.serial = rex->serial;
+ catcher.re.group_catch.cont = cont;
+ catcher.next = rex->next;
+ return parse(env, rex->re.group.expr.rex, &catcher, s);
+ case REX_GROUP_CUT_CATCH:
+ switch (r = follow(env, rex, rex->re.group_catch.cont, s))
+ {
+ case GOOD:
+ r = BEST;
+ break;
+ case NONE:
+ r = CUT;
+ break;
+ }
+ return r;
+ case REX_KMP:
+ f = rex->re.string.fail;
+ b = rex->re.string.base;
+ n = rex->re.string.size;
+ t = s;
+ e = env->end;
+ if (p = rex->map)
+ {
+ while (t + n <= e)
+ {
+ for (i = -1; t < e; t++)
+ {
+ while (i >= 0 && b[i+1] != p[*t])
+ i = f[i];
+ if (b[i+1] == p[*t])
+ i++;
+ if (i + 1 == n)
+ {
+ t++;
+ if (env->stack)
+ env->best[0].rm_so = t - s - n;
+ switch (follow(env, rex, cont, t))
+ {
+ case BAD:
+ return BAD;
+ case CUT:
+ return CUT;
+ case BEST:
+ case GOOD:
+ return BEST;
+ }
+ t -= n - 1;
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ while (t + n <= e)
+ {
+ for (i = -1; t < e; t++)
+ {
+ while (i >= 0 && b[i+1] != *t)
+ i = f[i];
+ if (b[i+1] == *t)
+ i++;
+ if (i + 1 == n)
+ {
+ t++;
+ if (env->stack)
+ env->best[0].rm_so = t - s - n;
+ switch (follow(env, rex, cont, t))
+ {
+ case BAD:
+ return BAD;
+ case CUT:
+ return CUT;
+ case BEST:
+ case GOOD:
+ return BEST;
+ }
+ t -= n - 1;
+ break;
+ }
+ }
+ }
+ }
+ return NONE;
+ case REX_NEG:
+ if (LEADING(env, rex, s))
+ return NONE;
+ i = env->end - s;
+ n = ((i + 7) >> 3) + 1;
+ catcher.type = REX_NEG_CATCH;
+ catcher.re.neg_catch.beg = s;
+ if (!(p = (unsigned char*)stkpush(stkstd, n)))
+ return BAD;
+ memset(catcher.re.neg_catch.index = p, 0, n);
+ catcher.next = rex->next;
+ if (parse(env, rex->re.group.expr.rex, &catcher, s) == BAD)
+ r = BAD;
+ else
+ {
+ r = NONE;
+ for (; i >= 0; i--)
+ if (!bittst(p, i))
+ {
+ switch (follow(env, rex, cont, s + i))
+ {
+ case BAD:
+ r = BAD;
+ break;
+ case BEST:
+ r = BEST;
+ break;
+ case CUT:
+ r = CUT;
+ break;
+ case GOOD:
+ r = GOOD;
+ /*FALLTHROUGH*/
+ default:
+ continue;
+ }
+ break;
+ }
+ }
+ stkpop(stkstd);
+ return r;
+ case REX_NEG_CATCH:
+ bitset(rex->re.neg_catch.index, s - rex->re.neg_catch.beg);
+ return NONE;
+ case REX_NEST:
+ do
+ {
+ if ((c = *s++) == rex->re.nest.primary)
+ {
+ if (s >= env->end || !(s = nestmatch(s, env->end, rex->re.nest.type, c)))
+ return NONE;
+ break;
+ }
+ if (rex->re.nest.primary >= 0)
+ return NONE;
+ if (rex->re.nest.type[c] & (REX_NEST_delimiter|REX_NEST_separator|REX_NEST_terminator))
+ break;
+ if (!(s = nestmatch(s, env->end, rex->re.nest.type, c)))
+ return NONE;
+ } while (s < env->end && !(rex->re.nest.type[*(s-1)] & (REX_NEST_delimiter|REX_NEST_separator|REX_NEST_terminator)));
+ break;
+ case REX_NULL:
+ break;
+ case REX_ONECHAR:
+ n = rex->hi;
+ if (n > env->end - s)
+ n = env->end - s;
+ m = rex->lo;
+ if (m > n)
+ return NONE;
+ r = NONE;
+ c = rex->re.onechar;
+ if (!(rex->flags & REG_MINIMAL))
+ {
+ if (!mbwide())
+ {
+ if (p = rex->map)
+ {
+ for (i = 0; i < n; i++, s++)
+ if (p[*s] != c)
+ break;
+ }
+ else
+ {
+ for (i = 0; i < n; i++, s++)
+ if (*s != c)
+ break;
+ }
+ for (; i-- >= m; s--)
+ switch (follow(env, rex, cont, s))
+ {
+ case BAD:
+ return BAD;
+ case BEST:
+ return BEST;
+ case CUT:
+ return CUT;
+ case GOOD:
+ r = GOOD;
+ break;
+ }
+ }
+ else
+ {
+ if (!(b = (unsigned char*)stkpush(stkstd, n)))
+ {
+ env->error = REG_ESPACE;
+ return BAD;
+ }
+ e = env->end;
+ if (!(rex->flags & REG_ICASE))
+ {
+ for (i = 0; s < e && i < n; i++, s = t)
+ {
+ t = s;
+ if (mbchar(t) != c)
+ break;
+ b[i] = t - s;
+ }
+ }
+ else
+ {
+ for (i = 0; s < e && i < n; i++, s = t)
+ {
+ t = s;
+ if (towupper(mbchar(t)) != c)
+ break;
+ b[i] = t - s;
+ }
+ }
+ for (; i-- >= m; s -= b[i])
+ switch (follow(env, rex, cont, s))
+ {
+ case BAD:
+ stkpop(stkstd);
+ return BAD;
+ case BEST:
+ stkpop(stkstd);
+ return BEST;
+ case CUT:
+ stkpop(stkstd);
+ return CUT;
+ case GOOD:
+ r = GOOD;
+ break;
+ }
+ stkpop(stkstd);
+ }
+ }
+ else
+ {
+ if (!mbwide())
+ {
+ e = s + m;
+ if (p = rex->map)
+ {
+ for (; s < e; s++)
+ if (p[*s] != c)
+ return r;
+ e += n - m;
+ for (;;)
+ {
+ switch (follow(env, rex, cont, s))
+ {
+ case BAD:
+ return BAD;
+ case CUT:
+ return CUT;
+ case BEST:
+ case GOOD:
+ return BEST;
+ }
+ if (s >= e || p[*s++] != c)
+ break;
+ }
+ }
+ else
+ {
+ for (; s < e; s++)
+ if (*s != c)
+ return r;
+ e += n - m;
+ for (;;)
+ {
+ switch (follow(env, rex, cont, s))
+ {
+ case BAD:
+ return BAD;
+ case CUT:
+ return CUT;
+ case BEST:
+ case GOOD:
+ return BEST;
+ }
+ if (s >= e || *s++ != c)
+ break;
+ }
+ }
+ }
+ else
+ {
+ if (!(rex->flags & REG_ICASE))
+ {
+ for (i = 0; i < m && s < e; i++, s = t)
+ {
+ t = s;
+ if (mbchar(t) != c)
+ return r;
+ }
+ while (i++ <= n)
+ {
+ switch (follow(env, rex, cont, s))
+ {
+ case BAD:
+ return BAD;
+ case CUT:
+ return CUT;
+ case BEST:
+ case GOOD:
+ return BEST;
+ }
+ if (s >= e || mbchar(s) != c)
+ break;
+ }
+ }
+ else
+ {
+ for (i = 0; i < m && s < e; i++, s = t)
+ {
+ t = s;
+ if (towupper(mbchar(t)) != c)
+ return r;
+ }
+ while (i++ <= n)
+ {
+ switch (follow(env, rex, cont, s))
+ {
+ case BAD:
+ return BAD;
+ case CUT:
+ return CUT;
+ case BEST:
+ case GOOD:
+ return BEST;
+ }
+ if (s >= e || towupper(mbchar(s)) != c)
+ break;
+ }
+ }
+ }
+ }
+ return r;
+ case REX_REP:
+ if (env->stack && pospush(env, rex, s, BEG_REP))
+ return BAD;
+ r = parserep(env, rex, cont, s, 0);
+ if (env->stack)
+ pospop(env);
+ return r;
+ case REX_REP_CATCH:
+ DEBUG_TEST(0x0020,(sfprintf(sfstdout, "AHA#%04d 0x%04x %s n %d len %d s `%-.*s'\n", __LINE__, debug_flag, rexname(rex), rex->re.rep_catch.n, s - rex->re.rep_catch.beg, env->end - s, s)),(0));
+ if (env->stack && pospush(env, rex, s, END_ANY))
+ return BAD;
+ if (s == rex->re.rep_catch.beg && rex->re.rep_catch.n > rex->re.rep_catch.ref->lo)
+ {
+ /*
+ * optional empty iteration
+ */
+
+DEBUG_TEST(0x0002,(sfprintf(sfstdout, "AHA#%04d %p re.group.back=%d re.group.expr.rex=%s\n", __LINE__, rex->re.rep_catch.ref->re.group.expr.rex, rex->re.rep_catch.ref->re.group.expr.rex->re.group.back, rexname(rex->re.rep_catch.ref->re.group.expr.rex))),(0));
+ if (!env->stack || s != rex->re.rep_catch.ref->re.rep_catch.beg && !rex->re.rep_catch.ref->re.group.expr.rex->re.group.back)
+ r = NONE;
+ else if (pospush(env, rex, s, END_ANY))
+ r = BAD;
+ else
+ {
+ r = follow(env, rex, rex->re.rep_catch.cont, s);
+ pospop(env);
+ }
+ }
+ else
+ r = parserep(env, rex->re.rep_catch.ref, rex->re.rep_catch.cont, s, rex->re.rep_catch.n);
+ if (env->stack)
+ pospop(env);
+ return r;
+ case REX_STRING:
+DEBUG_TEST(0x0200,(sfprintf(sfstdout,"AHA#%04d 0x%04x parse %s \"%-.*s\" `%-.*s'\n", __LINE__, debug_flag, rexname(rex), rex->re.string.size, rex->re.string.base, env->end - s, s)),(0));
+ if (rex->re.string.size > (env->end - s))
+ return NONE;
+ t = rex->re.string.base;
+ e = t + rex->re.string.size;
+ if (!(p = rex->map))
+ {
+ while (t < e)
+ if (*s++ != *t++)
+ return NONE;
+ }
+ else if (!mbwide())
+ {
+ while (t < e)
+ if (p[*s++] != *t++)
+ return NONE;
+ }
+ else
+ {
+ while (t < e)
+ {
+ c = mbchar(s);
+ d = mbchar(t);
+ if (towupper(c) != d)
+ return NONE;
+ }
+ }
+ break;
+ case REX_TRIE:
+ if (((s + rex->re.trie.min) > env->end) || !(x = rex->re.trie.root[rex->map ? rex->map[*s] : *s]))
+ return NONE;
+ return parsetrie(env, x, rex, cont, s);
+ case REX_EXEC:
+ u = 0;
+ r = (*env->disc->re_execf)(env->regex, rex->re.exec.data, rex->re.exec.text, rex->re.exec.size, (const char*)s, env->end - s, &u, env->disc);
+ e = (unsigned char*)u;
+ if (e >= s && e <= env->end)
+ s = e;
+ switch (r)
+ {
+ case 0:
+ break;
+ case REG_NOMATCH:
+ return NONE;
+ default:
+ env->error = r;
+ return BAD;
+ }
+ break;
+ case REX_WBEG:
+ if (!isword(*s) || s > env->beg && isword(*(s - 1)))
+ return NONE;
+ break;
+ case REX_WEND:
+ if (isword(*s) || s > env->beg && !isword(*(s - 1)))
+ return NONE;
+ break;
+ case REX_WORD:
+ if (s > env->beg && isword(*(s - 1)) == isword(*s))
+ return NONE;
+ break;
+ case REX_WORD_NOT:
+ if (s == env->beg || isword(*(s - 1)) != isword(*s))
+ return NONE;
+ break;
+ case REX_BEG_STR:
+ if (s != env->beg)
+ return NONE;
+ break;
+ case REX_END_STR:
+ for (t = s; t < env->end && *t == '\n'; t++);
+ if (t < env->end)
+ return NONE;
+ break;
+ case REX_FIN_STR:
+ if (s < env->end)
+ return NONE;
+ break;
+ }
+ if (!(rex = rex->next))
+ {
+ if (!(rex = cont))
+ break;
+ cont = 0;
+ }
+ }
+ return GOOD;
+}
+
+#if _AST_REGEX_DEBUG
+
+static void
+listnode(Rex_t* e, int level)
+{
+ int i;
+
+ if (e)
+ {
+ do
+ {
+ for (i = 0; i < level; i++)
+ sfprintf(sfstderr, " ");
+ sfprintf(sfstderr, "%s\n", rexname(e));
+ switch (e->type)
+ {
+ case REX_ALT:
+ case REX_CONJ:
+ listnode(e->re.group.expr.binary.left, level + 1);
+ listnode(e->re.group.expr.binary.right, level + 1);
+ break;
+ case REX_GROUP:
+ case REX_GROUP_AHEAD:
+ case REX_GROUP_AHEAD_NOT:
+ case REX_GROUP_BEHIND:
+ case REX_GROUP_BEHIND_NOT:
+ case REX_GROUP_CUT:
+ case REX_NEG:
+ case REX_REP:
+ listnode(e->re.group.expr.rex, level + 1);
+ break;
+ }
+ } while (e = e->next);
+ }
+}
+
+static int
+list(Env_t* env, Rex_t* rex)
+{
+ sfprintf(sfstderr, "AHA regex hard=%d stack=%p\n", env->hard, env->stack);
+ if (rex)
+ listnode(rex, 1);
+ return 0;
+}
+
+#endif
+
+/*
+ * returning REG_BADPAT or REG_ESPACE is not explicitly
+ * countenanced by the standard
+ */
+
+int
+regnexec(const regex_t* p, const char* s, size_t len, size_t nmatch, regmatch_t* match, regflags_t flags)
+{
+ register int n;
+ register int i;
+ int j;
+ int k;
+ int m;
+ int advance;
+ Env_t* env;
+ Rex_t* e;
+
+ DEBUG_INIT();
+ DEBUG_TEST(0x0001,(sfprintf(sfstdout, "AHA#%04d 0x%04x regnexec %d 0x%08x `%-.*s'\n", __LINE__, debug_flag, nmatch, flags, len, s)),(0));
+ if (!p || !(env = p->env))
+ return REG_BADPAT;
+ if (!s)
+ return fatal(env->disc, REG_BADPAT, NiL);
+ if (len < env->min)
+ {
+ DEBUG_TEST(0x0080,(sfprintf(sfstdout, "AHA#%04d REG_NOMATCH %d %d\n", __LINE__, len, env->min)),(0));
+ return REG_NOMATCH;
+ }
+ env->regex = p;
+ env->beg = (unsigned char*)s;
+ env->end = env->beg + len;
+ stknew(stkstd, &env->stk);
+ env->flags &= ~REG_EXEC;
+ env->flags |= (flags & REG_EXEC);
+ advance = 0;
+ if (env->stack = env->hard || !(env->flags & REG_NOSUB) && nmatch)
+ {
+ n = env->nsub;
+ if (!(env->match = (regmatch_t*)stkpush(stkstd, 2 * (n + 1) * sizeof(regmatch_t))) ||
+ !env->pos && !(env->pos = vecopen(16, sizeof(Pos_t))) ||
+ !env->bestpos && !(env->bestpos = vecopen(16, sizeof(Pos_t))))
+ {
+ k = REG_ESPACE;
+ goto done;
+ }
+ env->pos->cur = env->bestpos->cur = 0;
+ env->best = &env->match[n + 1];
+ env->best[0].rm_so = 0;
+ env->best[0].rm_eo = -1;
+ for (i = 0; i <= n; i++)
+ env->match[i] = state.nomatch;
+ if (flags & REG_ADVANCE)
+ advance = 1;
+ }
+ DEBUG_TEST(0x1000,(list(env,env->rex)),(0));
+ k = REG_NOMATCH;
+ if ((e = env->rex)->type == REX_BM)
+ {
+ DEBUG_TEST(0x0080,(sfprintf(sfstdout, "AHA#%04d REX_BM\n", __LINE__)),(0));
+ if (len < e->re.bm.right)
+ {
+ DEBUG_TEST(0x0080,(sfprintf(sfstdout, "AHA#%04d REG_NOMATCH %d %d\n", __LINE__, len, e->re.bm.right)),(0));
+ goto done;
+ }
+ else if (!(flags & REG_LEFT))
+ {
+ register unsigned char* buf = (unsigned char*)s;
+ register size_t index = e->re.bm.left + e->re.bm.size;
+ register size_t mid = len - e->re.bm.right;
+ register size_t* skip = e->re.bm.skip;
+ register size_t* fail = e->re.bm.fail;
+ register Bm_mask_t** mask = e->re.bm.mask;
+ Bm_mask_t m;
+ size_t x;
+
+ DEBUG_TEST(0x0080,(sfprintf(sfstdout, "AHA#%04d REX_BM len=%d right=%d left=%d size=%d %d %d\n", __LINE__, len, e->re.bm.right, e->re.bm.left, e->re.bm.size, index, mid)),(0));
+ for (;;)
+ {
+ while ((index += skip[buf[index]]) < mid);
+ if (index < HIT)
+ {
+ DEBUG_TEST(0x0080,(sfprintf(sfstdout, "AHA#%04d REG_NOMATCH %d %d\n", __LINE__, index, HIT)),(0));
+ goto done;
+ }
+ index -= HIT;
+ m = mask[n = e->re.bm.size - 1][buf[index]];
+ do
+ {
+ if (!n--)
+ {
+ if (e->re.bm.back < 0)
+ goto possible;
+ if (advance)
+ {
+ i = index - e->re.bm.back;
+ s += i;
+ if (env->stack)
+ env->best[0].rm_so += i;
+ goto possible;
+ }
+ x = index;
+ if (index < e->re.bm.back)
+ index = 0;
+ else
+ index -= e->re.bm.back;
+ while (index <= x)
+ {
+ if ((i = parse(env, e->next, &env->done, buf + index)) != NONE)
+ {
+ if (env->stack)
+ env->best[0].rm_so = index;
+ n = env->nsub;
+ goto hit;
+ }
+ index++;
+ }
+ index += e->re.bm.size;
+ break;
+ }
+ } while (m &= mask[n][buf[--index]]);
+ if ((index += fail[n + 1]) >= len)
+ goto done;
+ }
+ }
+ possible:
+ n = env->nsub;
+ e = e->next;
+ }
+ j = env->once || (flags & REG_LEFT);
+ DEBUG_TEST(0x0080,(sfprintf(sfstdout, "AHA#%04d parse once=%d\n", __LINE__, j)),(0));
+ while ((i = parse(env, e, &env->done, (unsigned char*)s)) == NONE || advance && !env->best[0].rm_eo && !(advance = 0))
+ {
+ if (j)
+ goto done;
+ i = MBSIZE(s);
+ s += i;
+ if ((unsigned char*)s > env->end - env->min)
+ goto done;
+ if (env->stack)
+ env->best[0].rm_so += i;
+ }
+ if ((flags & REG_LEFT) && env->stack && env->best[0].rm_so)
+ goto done;
+ hit:
+ if (k = env->error)
+ goto done;
+ if (i == CUT)
+ {
+ k = env->error = REG_NOMATCH;
+ goto done;
+ }
+ if (!(env->flags & REG_NOSUB))
+ {
+ k = (env->flags & (REG_SHELL|REG_AUGMENTED)) == (REG_SHELL|REG_AUGMENTED);
+ for (i = j = m = 0; j < nmatch; i++)
+ if (!i || !k || (i & 1))
+ {
+ if (i > n)
+ match[j] = state.nomatch;
+ else
+ match[m = j] = env->best[i];
+ j++;
+ }
+ if (k)
+ {
+ while (m > 0 && match[m].rm_so == -1 && match[m].rm_eo == -1)
+ m--;
+ ((regex_t*)p)->re_nsub = m;
+ }
+ }
+ k = 0;
+ done:
+ stkold(stkstd, &env->stk);
+ env->stk.base = 0;
+ if (k > REG_NOMATCH)
+ fatal(p->env->disc, k, NiL);
+ return k;
+}
+
+void
+regfree(regex_t* p)
+{
+ Env_t* env;
+
+ if (p && (env = p->env))
+ {
+#if _REG_subcomp
+ if (env->sub)
+ {
+ regsubfree(p);
+ p->re_sub = 0;
+ }
+#endif
+ p->env = 0;
+ if (--env->refs <= 0 && !(env->disc->re_flags & REG_NOFREE))
+ {
+ drop(env->disc, env->rex);
+ if (env->pos)
+ vecclose(env->pos);
+ if (env->bestpos)
+ vecclose(env->bestpos);
+ if (env->stk.base)
+ stkold(stkstd, &env->stk);
+ alloc(env->disc, env, 0);
+ }
+ }
+}
diff --git a/usr/src/lib/libast/common/regex/regrecord.c b/usr/src/lib/libast/common/regex/regrecord.c
new file mode 100644
index 0000000000..b17b143a87
--- /dev/null
+++ b/usr/src/lib/libast/common/regex/regrecord.c
@@ -0,0 +1,34 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * return 1 if regrexec() can be used
+ */
+
+#include "reglib.h"
+
+int
+regrecord(const regex_t* p)
+{
+ return p && p->env && p->env->rex->type == REX_BM;
+}
diff --git a/usr/src/lib/libast/common/regex/regrexec.c b/usr/src/lib/libast/common/regex/regrexec.c
new file mode 100644
index 0000000000..cefc7bc7fb
--- /dev/null
+++ b/usr/src/lib/libast/common/regex/regrexec.c
@@ -0,0 +1,145 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * posix regex record executor
+ * multiple record sized-buffer interface
+ */
+
+#include "reglib.h"
+
+/*
+ * call regnexec() on records selected by Boyer-Moore
+ */
+
+int
+regrexec(const regex_t* p, const char* s, size_t len, size_t nmatch, regmatch_t* match, regflags_t flags, int sep, void* handle, regrecord_t record)
+{
+ register unsigned char* buf = (unsigned char*)s;
+ register unsigned char* beg;
+ register unsigned char* l;
+ register unsigned char* r;
+ register unsigned char* x;
+ register size_t* skip;
+ register size_t* fail;
+ register Bm_mask_t** mask;
+ register size_t index;
+ register int n;
+ unsigned char* end;
+ size_t mid;
+ int complete;
+ int exactlen;
+ int leftlen;
+ int rightlen;
+ int inv;
+ Bm_mask_t m;
+ Env_t* env;
+ Rex_t* e;
+
+ if (!s || !p || !(env = p->env) || (e = env->rex)->type != REX_BM)
+ return REG_BADPAT;
+ inv = (flags & REG_INVERT) != 0;
+ buf = beg = (unsigned char*)s;
+ end = buf + len;
+ mid = (len < e->re.bm.right) ? 0 : (len - e->re.bm.right);
+ skip = e->re.bm.skip;
+ fail = e->re.bm.fail;
+ mask = e->re.bm.mask;
+ complete = e->re.bm.complete && !nmatch;
+ exactlen = e->re.bm.size;
+ leftlen = e->re.bm.left + exactlen;
+ rightlen = exactlen + e->re.bm.right;
+ index = leftlen++;
+ for (;;)
+ {
+ while ((index += skip[buf[index]]) < mid);
+ if (index < HIT)
+ goto impossible;
+ index -= HIT;
+ m = mask[n = exactlen - 1][buf[index]];
+ do
+ {
+ if (!n--)
+ goto possible;
+ } while (m &= mask[n][buf[--index]]);
+ if ((index += fail[n + 1]) < len)
+ continue;
+ impossible:
+ if (inv)
+ {
+ l = r = buf + len;
+ goto invert;
+ }
+ n = 0;
+ goto done;
+ possible:
+ r = (l = buf + index) + exactlen;
+ while (l > beg)
+ if (*--l == sep)
+ {
+ l++;
+ break;
+ }
+ if ((r - l) < leftlen)
+ goto spanned;
+ while (r < end && *r != sep)
+ r++;
+ if ((r - (buf + index)) < rightlen)
+ goto spanned;
+ if (complete || (env->rex = ((r - l) > 128) ? e : e->next) && !(n = regnexec(p, (char*)l, r - l, nmatch, match, flags)))
+ {
+ if (inv)
+ {
+ invert:
+ x = beg;
+ while (beg < l)
+ {
+ while (x < l && *x != sep)
+ x++;
+ if (n = (*record)(handle, (char*)beg, x - beg))
+ goto done;
+ beg = ++x;
+ }
+ }
+ else if (n = (*record)(handle, (char*)l, r - l))
+ goto done;
+ if ((index = (r - buf) + leftlen) >= len)
+ {
+ n = (inv && (++r - buf) < len) ? (*record)(handle, (char*)r, (buf + len) - r): 0;
+ goto done;
+ }
+ beg = r + 1;
+ }
+ else if (n != REG_NOMATCH)
+ goto done;
+ else
+ {
+ spanned:
+ if ((index += exactlen) >= mid)
+ goto impossible;
+ }
+ }
+ done:
+ env->rex = e;
+ return n;
+}
diff --git a/usr/src/lib/libast/common/regex/regstat.c b/usr/src/lib/libast/common/regex/regstat.c
new file mode 100644
index 0000000000..af7a180b21
--- /dev/null
+++ b/usr/src/lib/libast/common/regex/regstat.c
@@ -0,0 +1,46 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * return p stat info
+ */
+
+#include "reglib.h"
+
+regstat_t*
+regstat(const regex_t* p)
+{
+ register Rex_t* e;
+
+ e = p->env->rex;
+ if (e && e->type == REX_BM)
+ e = e->next;
+ if (e && e->type == REX_BEG)
+ e = e->next;
+ if (e && e->type == REX_STRING)
+ e = e->next;
+ if (!e || e->type == REX_END && !e->next)
+ p->env->stats.re_flags |= REG_LITERAL;
+ p->env->stats.re_record = (p && p->env && p->env->rex->type == REX_BM) ? p->env->rex->re.bm.size : -1;
+ return &p->env->stats;
+}
diff --git a/usr/src/lib/libast/common/regex/regsub.c b/usr/src/lib/libast/common/regex/regsub.c
new file mode 100644
index 0000000000..255fd0a05d
--- /dev/null
+++ b/usr/src/lib/libast/common/regex/regsub.c
@@ -0,0 +1,268 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * OBSOLETE Sfio_t buffer interface -- use regsubcomp(),regsubexec()
+ */
+
+#include "reglib.h"
+
+/*
+ * do a single substitution
+ */
+
+static int
+subold(register Sfio_t* dp, const char* op, register const char* sp, size_t nmatch, register regmatch_t* match, register regflags_t flags, int sre)
+{
+ register int c;
+ char* s;
+ char* e;
+ const char* b;
+ regflags_t f;
+
+ f = flags &= (REG_SUB_LOWER|REG_SUB_UPPER);
+ for (;;)
+ {
+ switch (c = *sp++)
+ {
+ case 0:
+ return 0;
+ case '~':
+ if (!sre || *sp != '(')
+ {
+ sfputc(dp, c);
+ continue;
+ }
+ b = sp - 1;
+ sp++;
+ break;
+ case '\\':
+ if (sre)
+ {
+ sfputc(dp, chresc(sp - 1, &s));
+ sp = (const char*)s;
+ continue;
+ }
+ if (*sp == '&')
+ {
+ c = *sp++;
+ sfputc(dp, c);
+ continue;
+ }
+ break;
+ case '&':
+ if (sre)
+ {
+ sfputc(dp, c);
+ continue;
+ }
+ sp--;
+ break;
+ default:
+ switch (flags)
+ {
+ case REG_SUB_UPPER:
+ if (islower(c))
+ c = toupper(c);
+ break;
+ case REG_SUB_LOWER:
+ if (isupper(c))
+ c = tolower(c);
+ break;
+ case REG_SUB_UPPER|REG_SUB_LOWER:
+ if (isupper(c))
+ c = tolower(c);
+ else if (islower(c))
+ c = toupper(c);
+ break;
+ }
+ sfputc(dp, c);
+ continue;
+ }
+ switch (c = *sp++)
+ {
+ case 0:
+ sp--;
+ continue;
+ case '&':
+ c = 0;
+ break;
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ c -= '0';
+ if (sre)
+ while (isdigit(*sp))
+ c = c * 10 + *sp++ - '0';
+ break;
+ case 'l':
+ if (sre && *sp != ')')
+ {
+ c = -1;
+ break;
+ }
+ if (c = *sp)
+ {
+ sp++;
+ if (isupper(c))
+ c = tolower(c);
+ sfputc(dp, c);
+ }
+ continue;
+ case 'u':
+ if (sre)
+ {
+ if (*sp != ')')
+ {
+ c = -1;
+ break;
+ }
+ sp++;
+ }
+ if (c = *sp)
+ {
+ sp++;
+ if (islower(c))
+ c = toupper(c);
+ sfputc(dp, c);
+ }
+ continue;
+ case 'E':
+ if (sre)
+ {
+ if (*sp != ')')
+ {
+ c = -1;
+ break;
+ }
+ sp++;
+ }
+ flags = f;
+ continue;
+ case 'L':
+ if (sre)
+ {
+ if (*sp != ')')
+ {
+ c = -1;
+ break;
+ }
+ sp++;
+ }
+ f = flags;
+ flags = REG_SUB_LOWER;
+ continue;
+ case 'U':
+ if (sre)
+ {
+ if (*sp != ')')
+ {
+ c = -1;
+ break;
+ }
+ sp++;
+ }
+ f = flags;
+ flags = REG_SUB_UPPER;
+ continue;
+ default:
+ if (!sre)
+ {
+ sfputc(dp, chresc(sp - 2, &s));
+ sp = (const char*)s;
+ continue;
+ }
+ sp--;
+ c = -1;
+ break;
+ }
+ if (sre)
+ {
+ if (c < 0 || *sp != ')')
+ {
+ for (; b < sp; b++)
+ sfputc(dp, *b);
+ continue;
+ }
+ sp++;
+ }
+ if (c >= nmatch)
+ return REG_ESUBREG;
+ s = (char*)op + match[c].rm_so;
+ e = (char*)op + match[c].rm_eo;
+ while (s < e)
+ {
+ c = *s++;
+ switch (flags)
+ {
+ case REG_SUB_UPPER:
+ if (islower(c))
+ c = toupper(c);
+ break;
+ case REG_SUB_LOWER:
+ if (isupper(c))
+ c = tolower(c);
+ break;
+ case REG_SUB_UPPER|REG_SUB_LOWER:
+ if (isupper(c))
+ c = tolower(c);
+ else if (islower(c))
+ c = toupper(c);
+ break;
+ }
+ sfputc(dp, c);
+ }
+ }
+}
+
+/*
+ * ed(1) style substitute using matches from last regexec()
+ */
+
+int
+regsub(const regex_t* p, Sfio_t* dp, const char* op, const char* sp, size_t nmatch, regmatch_t* match, regflags_t flags)
+{
+ int m;
+ int r;
+ int sre;
+
+ if ((p->env->flags & REG_NOSUB) || !nmatch)
+ return fatal(p->env->disc, REG_BADPAT, NiL);
+ m = (flags >> 16) & 0x3fff;
+ sre = !!(p->env->flags & REG_SHELL);
+ do
+ {
+ if (--m > 0)
+ sfwrite(dp, op, match->rm_eo);
+ else
+ {
+ sfwrite(dp, op, match->rm_so);
+ if (r = subold(dp, op, sp, nmatch, match, flags, sre))
+ return fatal(p->env->disc, r, NiL);
+ }
+ op += match->rm_eo;
+ } while ((m > 0 || (flags & REG_SUB_ALL)) && !(r = regexec(p, op, nmatch, match, p->env->flags|(match->rm_so == match->rm_eo ? REG_ADVANCE : 0))));
+ if (r && r != REG_NOMATCH)
+ return fatal(p->env->disc, r, NiL);
+ sfputr(dp, op, -1);
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/regex/regsubcomp.c b/usr/src/lib/libast/common/regex/regsubcomp.c
new file mode 100644
index 0000000000..f8806a2544
--- /dev/null
+++ b/usr/src/lib/libast/common/regex/regsubcomp.c
@@ -0,0 +1,452 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * posix regex ed(1) style substitute compile
+ */
+
+#include "reglib.h"
+
+static const regflags_t submap[] =
+{
+ 'g', REG_SUB_ALL,
+ 'l', REG_SUB_LOWER,
+ 'n', REG_SUB_NUMBER,
+ 'p', REG_SUB_PRINT,
+ 's', REG_SUB_STOP,
+ 'u', REG_SUB_UPPER,
+ 'w', REG_SUB_WRITE|REG_SUB_LAST,
+ 0, 0
+};
+
+int
+regsubflags(regex_t* p, register const char* s, char** e, int delim, register const regflags_t* map, int* pm, regflags_t* pf)
+{
+ register int c;
+ register const regflags_t* m;
+ regflags_t flags;
+ int minmatch;
+ regdisc_t* disc;
+
+ flags = pf ? *pf : 0;
+ minmatch = pm ? *pm : 0;
+ if (!map)
+ map = submap;
+ while (!(flags & REG_SUB_LAST))
+ {
+ if (!(c = *s++) || c == delim)
+ {
+ s--;
+ break;
+ }
+ else if (c >= '0' && c <= '9')
+ {
+ if (minmatch)
+ {
+ disc = p->env->disc;
+ regfree(p);
+ return fatal(disc, REG_EFLAGS, s - 1);
+ }
+ minmatch = c - '0';
+ while (*s >= '0' && *s <= '9')
+ minmatch = minmatch * 10 + *s++ - '0';
+ }
+ else
+ {
+ for (m = map; *m; m++)
+ if (*m++ == c)
+ {
+ if (flags & *m)
+ {
+ disc = p->env->disc;
+ regfree(p);
+ return fatal(disc, REG_EFLAGS, s - 1);
+ }
+ flags |= *m--;
+ break;
+ }
+ if (!*m)
+ {
+ s--;
+ break;
+ }
+ }
+ }
+ if (pf)
+ *pf = flags;
+ if (pm)
+ *pm = minmatch;
+ if (e)
+ *e = (char*)s;
+ return 0;
+}
+
+/*
+ * compile substitute rhs and optional flags
+ */
+
+int
+regsubcomp(regex_t* p, register const char* s, const regflags_t* map, int minmatch, regflags_t flags)
+{
+ register regsub_t* sub;
+ register int c;
+ register int d;
+ register char* t;
+ register regsubop_t* op;
+ char* e;
+ const char* r;
+ int sre;
+ int f;
+ int g;
+ int n;
+ int nops;
+ const char* o;
+ regdisc_t* disc;
+
+ disc = p->env->disc;
+ if (p->env->flags & REG_NOSUB)
+ {
+ regfree(p);
+ return fatal(disc, REG_BADPAT, NiL);
+ }
+ if (!(sub = (regsub_t*)alloc(p->env->disc, 0, sizeof(regsub_t) + strlen(s))) || !(sub->re_ops = (regsubop_t*)alloc(p->env->disc, 0, (nops = 8) * sizeof(regsubop_t))))
+ {
+ if (sub)
+ alloc(p->env->disc, sub, 0);
+ regfree(p);
+ return fatal(disc, REG_ESPACE, s);
+ }
+ sub->re_buf = sub->re_end = 0;
+ p->re_sub = sub;
+ p->env->sub = 1;
+ op = sub->re_ops;
+ o = s;
+ if (!(p->env->flags & REG_DELIMITED))
+ d = 0;
+ else
+ switch (d = *(s - 1))
+ {
+ case '\\':
+ case '\n':
+ case '\r':
+ regfree(p);
+ return fatal(disc, REG_EDELIM, s);
+ }
+ sre = p->env->flags & REG_SHELL;
+ t = sub->re_rhs;
+ if (d)
+ {
+ r = s;
+ for (;;)
+ {
+ if (!*s)
+ {
+ if (p->env->flags & REG_MUSTDELIM)
+ {
+ regfree(p);
+ return fatal(disc, REG_EDELIM, r);
+ }
+ break;
+ }
+ else if (*s == d)
+ {
+ flags |= REG_SUB_FULL;
+ s++;
+ break;
+ }
+ else if (*s++ == '\\' && !*s++)
+ {
+ regfree(p);
+ return fatal(disc, REG_EESCAPE, r);
+ }
+ }
+ if (*s)
+ {
+ if (n = regsubflags(p, s, &e, d, map, &minmatch, &flags))
+ return n;
+ s = (const char*)e;
+ }
+ p->re_npat = s - o;
+ s = r;
+ }
+ else
+ p->re_npat = 0;
+ op->op = f = g = flags & (REG_SUB_LOWER|REG_SUB_UPPER);
+ op->off = 0;
+ while ((c = *s++) != d)
+ {
+ again:
+ if (!c)
+ {
+ p->re_npat = s - o - 1;
+ break;
+ }
+ else if (c == '~')
+ {
+ if (!sre || *s != '(')
+ {
+ *t++ = c;
+ continue;
+ }
+ r = s - 1;
+ s++;
+ c = *s++;
+ }
+ else if (c == '\\')
+ {
+ if (*s == c)
+ {
+ *t++ = *s++;
+ continue;
+ }
+ if ((c = *s++) == d)
+ goto again;
+ if (!c)
+ {
+ regfree(p);
+ return fatal(disc, REG_EESCAPE, s - 2);
+ }
+ if (sre)
+ {
+ *t++ = chresc(s - 2, &e);
+ s = (const char*)e;
+ continue;
+ }
+ if (c == '&')
+ {
+ *t++ = c;
+ continue;
+ }
+ }
+ else if (c == '&')
+ {
+ if (sre)
+ {
+ *t++ = c;
+ continue;
+ }
+ }
+ else
+ {
+ switch (op->op)
+ {
+ case REG_SUB_UPPER:
+ if (islower(c))
+ c = toupper(c);
+ break;
+ case REG_SUB_LOWER:
+ if (isupper(c))
+ c = tolower(c);
+ break;
+ case REG_SUB_UPPER|REG_SUB_LOWER:
+ if (isupper(c))
+ c = tolower(c);
+ else if (islower(c))
+ c = toupper(c);
+ break;
+ }
+ *t++ = c;
+ continue;
+ }
+ switch (c)
+ {
+ case 0:
+ s--;
+ continue;
+ case '&':
+ c = 0;
+ break;
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ c -= '0';
+ if (sre)
+ while (isdigit(*s))
+ c = c * 10 + *s++ - '0';
+ else if (isdigit(*s) && (p->env->flags & REG_MULTIREF))
+ c = c * 10 + *s++ - '0';
+ break;
+ case 'l':
+ if (sre)
+ {
+ if (*s != ')')
+ {
+ c = -1;
+ break;
+ }
+ s++;
+ }
+ if (c = *s)
+ {
+ s++;
+ if (isupper(c))
+ c = tolower(c);
+ *t++ = c;
+ }
+ continue;
+ case 'u':
+ if (sre)
+ {
+ if (*s != ')')
+ {
+ c = -1;
+ break;
+ }
+ s++;
+ }
+ if (c = *s)
+ {
+ s++;
+ if (islower(c))
+ c = toupper(c);
+ *t++ = c;
+ }
+ continue;
+ case 'E':
+ if (sre)
+ {
+ if (*s != ')')
+ {
+ c = -1;
+ break;
+ }
+ s++;
+ }
+ f = g;
+ set:
+ if ((op->len = (t - sub->re_rhs) - op->off) && (n = ++op - sub->re_ops) >= nops)
+ {
+ if (!(sub->re_ops = (regsubop_t*)alloc(p->env->disc, sub->re_ops, (nops *= 2) * sizeof(regsubop_t))))
+ {
+ regfree(p);
+ return fatal(disc, REG_ESPACE, NiL);
+ }
+ op = sub->re_ops + n;
+ }
+ op->op = f;
+ op->off = t - sub->re_rhs;
+ continue;
+ case 'L':
+ if (sre)
+ {
+ if (*s != ')')
+ {
+ c = -1;
+ break;
+ }
+ s++;
+ }
+ g = f;
+ f = REG_SUB_LOWER;
+ goto set;
+ case 'U':
+ if (sre)
+ {
+ if (*s != ')')
+ {
+ c = -1;
+ break;
+ }
+ s++;
+ }
+ g = f;
+ f = REG_SUB_UPPER;
+ goto set;
+ default:
+ if (!sre)
+ {
+ *t++ = chresc(s - 2, &e);
+ s = (const char*)e;
+ continue;
+ }
+ s--;
+ c = -1;
+ break;
+ }
+ if (sre)
+ {
+ if (c < 0 || *s != ')')
+ {
+ while (r < s)
+ *t++ = *r++;
+ continue;
+ }
+ s++;
+ }
+ if (c > p->re_nsub)
+ {
+ regfree(p);
+ return fatal(disc, REG_ESUBREG, s - 1);
+ }
+ if ((n = op - sub->re_ops) >= (nops - 2))
+ {
+ if (!(sub->re_ops = (regsubop_t*)alloc(p->env->disc, sub->re_ops, (nops *= 2) * sizeof(regsubop_t))))
+ {
+ regfree(p);
+ return fatal(disc, REG_ESPACE, NiL);
+ }
+ op = sub->re_ops + n;
+ }
+ if (op->len = (t - sub->re_rhs) - op->off)
+ op++;
+ op->op = f;
+ op->off = c;
+ op->len = 0;
+ op++;
+ op->op = f;
+ op->off = t - sub->re_rhs;
+ }
+ if ((op->len = (t - sub->re_rhs) - op->off) && (n = ++op - sub->re_ops) >= nops)
+ {
+ if (!(sub->re_ops = (regsubop_t*)alloc(p->env->disc, sub->re_ops, (nops *= 2) * sizeof(regsubop_t))))
+ {
+ regfree(p);
+ return fatal(disc, REG_ESPACE, NiL);
+ }
+ op = sub->re_ops + n;
+ }
+ op->len = -1;
+ sub->re_flags = flags;
+ sub->re_min = minmatch;
+ return 0;
+}
+
+void
+regsubfree(regex_t* p)
+{
+ Env_t* env;
+ regsub_t* sub;
+
+ if (p && (env = p->env) && env->sub && (sub = p->re_sub))
+ {
+ env->sub = 0;
+ p->re_sub = 0;
+ if (!(env->disc->re_flags & REG_NOFREE))
+ {
+ if (sub->re_buf)
+ alloc(env->disc, sub->re_buf, 0);
+ if (sub->re_ops)
+ alloc(env->disc, sub->re_ops, 0);
+ alloc(env->disc, sub, 0);
+ }
+ }
+}
diff --git a/usr/src/lib/libast/common/regex/regsubexec.c b/usr/src/lib/libast/common/regex/regsubexec.c
new file mode 100644
index 0000000000..9682e69f5d
--- /dev/null
+++ b/usr/src/lib/libast/common/regex/regsubexec.c
@@ -0,0 +1,190 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * posix regex ed(1) style substitute execute
+ */
+
+#include "reglib.h"
+
+#define NEED(p,b,n,r) \
+ do \
+ { \
+ if (((b)->re_end - (b)->re_cur) < (n)) \
+ { \
+ size_t o = (b)->re_cur - (b)->re_buf; \
+ size_t a = ((b)->re_end - (b)->re_buf); \
+ if (a < n) \
+ a = roundof(n, 128); \
+ a *= 2; \
+ if (!((b)->re_buf = alloc(p->env->disc, (b)->re_buf, a))) \
+ { \
+ (b)->re_buf = (b)->re_cur = (b)->re_end = 0; \
+ c = REG_ESPACE; \
+ r; \
+ } \
+ (b)->re_cur = (b)->re_buf + o; \
+ (b)->re_end = (b)->re_buf + a; \
+ } \
+ } while (0)
+
+#define PUTC(p,b,x,r) \
+ do \
+ { \
+ NEED(p, b, 1, r); \
+ *(b)->re_cur++ = (x); \
+ } while (0)
+
+#define PUTS(p,b,x,z,r) \
+ do if (z) \
+ { \
+ NEED(p, b, z, r); \
+ memcpy((b)->re_cur, x, z); \
+ (b)->re_cur += (z); \
+ } while (0)
+
+/*
+ * do a single substitution
+ */
+
+static int
+sub(const regex_t* p, register regsub_t* b, const char* ss, register regsubop_t* op, size_t nmatch, register regmatch_t* match)
+{
+ register char* s;
+ register char* e;
+ register int c;
+
+ for (;; op++)
+ {
+ switch (op->len)
+ {
+ case -1:
+ break;
+ case 0:
+ if (op->off >= nmatch)
+ return REG_ESUBREG;
+ if ((c = match[op->off].rm_so) < 0)
+ continue;
+ s = (char*)ss + c;
+ if ((c = match[op->off].rm_eo) < 0)
+ continue;
+ e = (char*)ss + c;
+ NEED(p, b, e - s, return c);
+ switch (op->op)
+ {
+ case REG_SUB_UPPER:
+ while (s < e)
+ {
+ c = *s++;
+ if (islower(c))
+ c = toupper(c);
+ *b->re_cur++ = c;
+ }
+ break;
+ case REG_SUB_LOWER:
+ while (s < e)
+ {
+ c = *s++;
+ if (isupper(c))
+ c = tolower(c);
+ *b->re_cur++ = c;
+ }
+ break;
+ case REG_SUB_UPPER|REG_SUB_LOWER:
+ while (s < e)
+ {
+ c = *s++;
+ if (isupper(c))
+ c = tolower(c);
+ else if (islower(c))
+ c = toupper(c);
+ *b->re_cur++ = c;
+ }
+ break;
+ default:
+ while (s < e)
+ *b->re_cur++ = *s++;
+ break;
+ }
+ continue;
+ default:
+ NEED(p, b, op->len, return c);
+ s = b->re_rhs + op->off;
+ e = s + op->len;
+ while (s < e)
+ *b->re_cur++ = *s++;
+ continue;
+ }
+ break;
+ }
+ return 0;
+}
+
+/*
+ * ed(1) style substitute using matches from last regexec()
+ */
+
+int
+regsubexec(const regex_t* p, const char* s, size_t nmatch, regmatch_t* match)
+{
+ register int c;
+ register regsub_t* b;
+ const char* e;
+ int m;
+
+ if (!p->env->sub || (p->env->flags & REG_NOSUB) || !nmatch)
+ return fatal(p->env->disc, REG_BADPAT, NiL);
+ b = p->re_sub;
+ m = b->re_min;
+ b->re_cur = b->re_buf;
+ e = (const char*)p->env->end;
+ for (;;)
+ {
+ if (--m > 0)
+ PUTS(p, b, s, match->rm_eo, return fatal(p->env->disc, c, NiL));
+ else
+ {
+ PUTS(p, b, s, match->rm_so, return fatal(p->env->disc, c, NiL));
+ if (c = sub(p, b, s, b->re_ops, nmatch, match))
+ return fatal(p->env->disc, c, NiL);
+ }
+ s += match->rm_eo;
+ if (m <= 0 && !(b->re_flags & REG_SUB_ALL))
+ break;
+ if (c = regnexec(p, s, e - s, nmatch, match, p->env->flags|(match->rm_so == match->rm_eo ? REG_ADVANCE : 0)))
+ {
+ if (c != REG_NOMATCH)
+ return fatal(p->env->disc, c, NiL);
+ break;
+ }
+ }
+ while (s < e)
+ {
+ c = *s++;
+ PUTC(p, b, c, return fatal(p->env->disc, c, NiL));
+ }
+ NEED(p, b, 1, return fatal(p->env->disc, c, NiL));
+ *b->re_cur = 0;
+ b->re_len = b->re_cur - b->re_buf;
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/regex/ucs_names.h b/usr/src/lib/libast/common/regex/ucs_names.h
new file mode 100644
index 0000000000..91c8a2aa91
--- /dev/null
+++ b/usr/src/lib/libast/common/regex/ucs_names.h
@@ -0,0 +1,6426 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated by ucs_names-index.c : : */
+
+/*
+ * ucs name and alias tables
+ * define UCS_BYTE for 8 bit ascii/latin only
+ */
+
+#include <ast_common.h>
+
+#define UCS_UC 1
+#define UCS_LC 2
+
+typedef uint16_t Ucs_code_t;
+typedef uint32_t Ucs_attr_t;
+
+typedef struct Ucs_dat_s
+{
+ Ucs_attr_t attr[3];
+ Ucs_code_t code;
+ Ucs_code_t table;
+ Ucs_code_t index;
+} Ucs_dat_t;
+
+static const char ucs_strings_0[] = "\
+letter\0\
+with\0\
+and\0\
+digit\0\
+form\0\
+sign\0\
+capital\0\
+uc\0\
+small\0\
+lc\0\
+above\0\
+acute\0\
+alef\0\
+alpha\0\
+arabic\0\
+below\0\
+bopomofo\0\
+box\0\
+breve\0\
+caron\0\
+cedilla\0\
+circled\0\
+circumflex\0\
+cyrillic\0\
+dasia\0\
+diaeresis\0\
+dot\0\
+double\0\
+down\0\
+drawings\0\
+eta\0\
+final\0\
+full\0\
+grave\0\
+greek\0\
+heavy\0\
+hebrew\0\
+hiragana\0\
+hook\0\
+horizontal\0\
+horn\0\
+initial\0\
+iota\0\
+isolated\0\
+katakana\0\
+latin\0\
+left\0\
+light\0\
+line\0\
+macron\0\
+mark\0\
+medial\0\
+number\0\
+numeral\0\
+omega\0\
+one\0\
+oxia\0\
+parenthesized\0\
+perispomeni\0\
+prosgegrammeni\0\
+psili\0\
+right\0\
+roman\0\
+single\0\
+tilde\0\
+to\0\
+up\0\
+upsilon\0\
+varia\0\
+vertical\0\
+white\0\
+of\0\
+stop\0\
+"
+"black\0\
+fraction\0\
+vulgar\0\
+superscript\0\
+subscript\0\
+square\0\
+ligature\0\
+space\0\
+indic\0\
+ideograph\0\
+ideographic\0\
+equal\0\
+arrow\0\
+than\0\
+suit\0\
+or\0\
+bracket\0\
+ocr\0\
+half\0\
+end\0\
+big\0\
+byelorussian\0\
+inverted\0\
+middle\0\
+ogonek\0\
+ring\0\
+short\0\
+stroke\0\
+tonos\0\
+ukrainian\0\
+upturn\0\
+null\0\
+nul\0\
+nu\0\
+start heading\0\
+soh\0\
+sh\0\
+start text\0\
+stx\0\
+sx\0\
+text\0\
+etx\0\
+ex\0\
+transmission\0\
+eot\0\
+et\0\
+enquiry\0\
+enq\0\
+eq\0\
+acknowledge\0\
+ack\0\
+ak\0\
+bell\0\
+bel\0\
+bl\0\
+alert\0\
+backspace\0\
+bs\0\
+tabulation\0\
+tab\0\
+ht\0\
+feed\0\
+lf\0\
+newline\0\
+vt\0\
+ff\0\
+carriage return\0\
+cr\0\
+shift out\0\
+so\0\
+shift in\0\
+si\0\
+data link escape\0\
+dl\0\
+dle\0\
+"
+"device control\0\
+d1\0\
+dc1\0\
+device control two\0\
+d2\0\
+dc2\0\
+device control three\0\
+d3\0\
+dc3\0\
+device control four\0\
+d4\0\
+dc4\0\
+negative acknowledge\0\
+nak\0\
+nk\0\
+synchronous idle\0\
+sy\0\
+syn\0\
+transmission block\0\
+eb\0\
+etb\0\
+cancel\0\
+can\0\
+cn\0\
+medium\0\
+em\0\
+substitute\0\
+sb\0\
+sub\0\
+escape\0\
+ec\0\
+esc\0\
+file separator\0\
+fs\0\
+is4\0\
+group separator\0\
+gs\0\
+is3\0\
+intro\0\
+record separator\0\
+is2\0\
+rs\0\
+unit separator\0\
+is1\0\
+us\0\
+\0\
+sp\0\
+exclamation\0\
+quotation\0\
+nb\0\
+h-\0\
+dollar\0\
+do\0\
+!s\0\
+percent\0\
+ampersand\0\
+apostrophe\0\
+parenthesis\0\
+asterisk\0\
+plus\0\
+comma\0\
+hyphen minus\0\
+hyphen\0\
+period\0\
+solidus\0\
+slash\0\
+zero\0\
+two\0\
+three\0\
+four\0\
+five\0\
+six\0\
+"
+"seven\0\
+eight\0\
+nine\0\
+colon\0\
+semicolon\0\
+less\0\
+equals\0\
+greater\0\
+question\0\
+commercial at\0\
+at\0\
+oa\0\
+a\0\
+b\0\
+c\0\
+d\0\
+e\0\
+f\0\
+g\0\
+h\0\
+i\0\
+j\0\
+k\0\
+l\0\
+m\0\
+n\0\
+o\0\
+p\0\
+q\0\
+r\0\
+s\0\
+t\0\
+u\0\
+v\0\
+w\0\
+x\0\
+y\0\
+z\0\
+reverse solidus\0\
+backslash\0\
+)>\0\
+accent\0\
+hat\0\
+'>\0\
+low\0\
+underscore\0\
+'!\0\
+curly\0\
+brace\0\
+(!\0\
+bar\0\
+!)\0\
+'?e\0\
+delete\0\
+del\0\
+dt\0\
+padding character\0\
+pa\0\
+pad\0\
+high octet preset\0\
+ho\0\
+hop\0\
+break permitted here\0\
+bh\0\
+bph\0\
+no break here\0\
+nh\0\
+nbh\0\
+index\0\
+in\0\
+ind\0\
+next\0\
+nl\0\
+nel\0\
+start selected area\0\
+sa\0\
+ssa\0\
+selected area\0\
+es\0\
+esa\0\
+character tabulation set\0\
+hs\0\
+"
+"hts\0\
+character tabulation justification\0\
+hj\0\
+htj\0\
+tabulation set\0\
+vs\0\
+vts\0\
+partial forward\0\
+pd\0\
+pld\0\
+partial backward\0\
+pu\0\
+plu\0\
+reverse feed\0\
+ri\0\
+shift two\0\
+s2\0\
+ss2\0\
+shift three\0\
+s3\0\
+ss3\0\
+device control string\0\
+dc\0\
+dcs\0\
+private use\0\
+p1\0\
+pu1\0\
+private use two\0\
+p2\0\
+pu2\0\
+set transmit state\0\
+ts\0\
+sts\0\
+cancel character\0\
+cc\0\
+cch\0\
+message waiting\0\
+mw\0\
+start guarded area\0\
+sg\0\
+spa\0\
+guarded area\0\
+eg\0\
+epa\0\
+start string\0\
+sos\0\
+graphic character introducer\0\
+gc\0\
+sgci\0\
+character introducer\0\
+sc\0\
+sci\0\
+control sequence introducer\0\
+ci\0\
+csi\0\
+string terminator\0\
+st\0\
+operating system command\0\
+oc\0\
+osc\0\
+privacy message\0\
+pm\0\
+application program command\0\
+"
+"ac\0\
+apc\0\
+no break\0\
+ns\0\
+!i\0\
+cent\0\
+ct\0\
+!c\0\
+pound\0\
+l-\0\
+currency\0\
+cu\0\
+xo\0\
+yen\0\
+ye\0\
+y-\0\
+broken bar\0\
+bb\0\
+!b\0\
+section\0\
+se\0\
+':\0\
+copyright\0\
+co\0\
+feminine ordinal indicator\0\
+-a\0\
+pointing angle quotation\0\
+<<\0\
+not\0\
+no\0\
+7!\0\
+soft hyphen\0\
+--\0\
+registered\0\
+rg\0\
+'m\0\
+degree\0\
+dg\0\
+plus minus\0\
++-\0\
+2s\0\
+3s\0\
+micro\0\
+my\0\
+pilcrow\0\
+pi\0\
+9i\0\
+.m\0\
+',\0\
+1s\0\
+masculine ordinal indicator\0\
+-o\0\
+>>\0\
+quarter\0\
+14\0\
+12\0\
+three quarters\0\
+34\0\
+?i\0\
+a!\0\
+a'\0\
+a>\0\
+a?\0\
+a:\0\
+aa\0\
+ae\0\
+c,\0\
+e!\0\
+e'\0\
+e>\0\
+e:\0\
+i!\0\
+i'\0\
+i>\0\
+i:\0\
+eth\0\
+d-\0\
+n?\0\
+o!\0\
+o'\0\
+o>\0\
+o?\0\
+o:\0\
+"
+"multiplication\0\
+*x\0\
+o/\0\
+u!\0\
+u'\0\
+u>\0\
+u:\0\
+y'\0\
+thorn\0\
+th\0\
+sharp s\0\
+ss\0\
+division\0\
+-:\0\
+y:\0\
+";
+
+#if !UCS_BYTE
+static const char ucs_strings_1[] = "\
+a-\0\
+a(\0\
+a;\0\
+c'\0\
+c>\0\
+c.\0\
+c<\0\
+d<\0\
+d/\0\
+e-\0\
+e(\0\
+e.\0\
+e;\0\
+e<\0\
+g>\0\
+g(\0\
+g.\0\
+g,\0\
+h>\0\
+h/\0\
+i?\0\
+i-\0\
+i(\0\
+i;\0\
+i.\0\
+dotless i\0\
+ij\0\
+j>\0\
+k,\0\
+kra\0\
+kk\0\
+l'\0\
+l,\0\
+l<\0\
+l.\0\
+l/\0\
+n'\0\
+n,\0\
+n<\0\
+n preceded by apostrophe\0\
+'n\0\
+eng\0\
+ng\0\
+o-\0\
+o(\0\
+o\"\0\
+oe\0\
+r'\0\
+r,\0\
+r<\0\
+s'\0\
+s>\0\
+s,\0\
+s<\0\
+t,\0\
+t<\0\
+t/\0\
+u?\0\
+u-\0\
+u(\0\
+u0\0\
+u\"\0\
+u;\0\
+w>\0\
+y>\0\
+z'\0\
+z.\0\
+z<\0\
+long s\0\
+s1\0\
+b/\0\
+b2\0\
+c2\0\
+f2\0\
+k2\0\
+o9\0\
+oi\0\
+yr\0\
+u9\0\
+z/\0\
+ezh\0\
+ed\0\
+dz\0\
+dz<\0\
+d z\0\
+lj\0\
+lj3\0\
+l j\0\
+nj\0\
+nj3\0\
+n j\0\
+a<\0\
+i<\0\
+o<\0\
+u<\0\
+"
+"u:-\0\
+u:'\0\
+u:<\0\
+u:!\0\
+turned e\0\
+e1\0\
+a1\0\
+a7\0\
+a3\0\
+g/\0\
+g<\0\
+k<\0\
+o;\0\
+o1\0\
+ez\0\
+j<\0\
+dz3\0\
+g'\0\
+aa'\0\
+ae'\0\
+o/'\0\
+a!!\0\
+a)\0\
+e!!\0\
+e)\0\
+i!!\0\
+i)\0\
+o!!\0\
+o)\0\
+r!!\0\
+r)\0\
+u!!\0\
+u)\0\
+r long leg\0\
+r1\0\
+modifier turned comma\0\
+;s\0\
+modifier accent\0\
+1>\0\
+'<\0\
+modifier\0\
+1-\0\
+1!\0\
+'(\0\
+'.\0\
+'0\0\
+';\0\
+1?\0\
+'\"\0\
+combining accent\0\
+\"`\0\
+\"'\0\
+'g\0\
+lower\0\
+,g\0\
+ypogegrammeni\0\
+j3\0\
+?%\0\
+'*\0\
+dialytika\0\
+'%\0\
+a%\0\
+ano teleia\0\
+.*\0\
+epsilon\0\
+e%\0\
+y%\0\
+i%\0\
+omicron\0\
+o%\0\
+u%\0\
+w%\0\
+i3\0\
+a*\0\
+beta\0\
+b*\0\
+gamma\0\
+g*\0\
+delta\0\
+d*\0\
+e*\0\
+zeta\0\
+z*\0\
+y*\0\
+theta\0\
+h*\0\
+i*\0\
+"
+"kappa\0\
+k*\0\
+lamda\0\
+l*\0\
+mu\0\
+m*\0\
+n*\0\
+xi\0\
+c*\0\
+o*\0\
+p*\0\
+rho\0\
+r*\0\
+sigma\0\
+s*\0\
+tau\0\
+t*\0\
+u*\0\
+phi\0\
+f*\0\
+chi\0\
+x*\0\
+psi\0\
+q*\0\
+w*\0\
+j*\0\
+v*\0\
+u3\0\
+*s\0\
+beta symbol\0\
+b3\0\
+stigma\0\
+t3\0\
+digamma\0\
+m3\0\
+koppa\0\
+k3\0\
+sampi\0\
+p3\0\
+io\0\
+dje\0\
+d%\0\
+gje\0\
+g%\0\
+ie\0\
+dze\0\
+ds\0\
+ii\0\
+yi\0\
+je\0\
+j%\0\
+lje\0\
+nje\0\
+tshe\0\
+kje\0\
+kj\0\
+v%\0\
+dzhe\0\
+a=\0\
+be\0\
+b=\0\
+ve\0\
+v=\0\
+ghe\0\
+g=\0\
+de\0\
+d=\0\
+e=\0\
+zhe\0\
+z%\0\
+ze\0\
+z=\0\
+i=\0\
+j=\0\
+ka\0\
+k=\0\
+el\0\
+l=\0\
+m=\0\
+en\0\
+n=\0\
+o=\0\
+pe\0\
+p=\0\
+er\0\
+r=\0\
+s=\0\
+te\0\
+t=\0\
+u=\0\
+ef\0\
+f=\0\
+ha\0\
+h=\0\
+tse\0\
+c=\0\
+"
+"che\0\
+c%\0\
+sha\0\
+s%\0\
+shcha\0\
+hard\0\
+=\"\0\
+yeru\0\
+y=\0\
+soft\0\
+%\"\0\
+yu\0\
+ju\0\
+ya\0\
+ja\0\
+='\0\
+%'\0\
+yat\0\
+y3\0\
+yus\0\
+o3\0\
+fita\0\
+f3\0\
+izhitsa\0\
+v3\0\
+c3\0\
+g3\0\
+a+\0\
+bet\0\
+b+\0\
+gimel\0\
+g+\0\
+dalet\0\
+d+\0\
+he\0\
+h+\0\
+vav\0\
+w+\0\
+zayin\0\
+z+\0\
+het\0\
+x+\0\
+tet\0\
+tj\0\
+yod\0\
+j+\0\
+kaf\0\
+k%\0\
+k+\0\
+lamed\0\
+l+\0\
+mem\0\
+m%\0\
+m+\0\
+nun\0\
+n%\0\
+n+\0\
+samekh\0\
+s+\0\
+ayin\0\
+e+\0\
+p%\0\
+p+\0\
+tsadi\0\
+zj\0\
+qof\0\
+q+\0\
+resh\0\
+r+\0\
+shin\0\
+tav\0\
+t+\0\
+,+\0\
+;+\0\
+?+\0\
+hamza\0\
+h'\0\
+madda\0\
+am\0\
+ah\0\
+waw hamza\0\
+wh\0\
+yeh hamza\0\
+yh\0\
+beh\0\
+teh marbuta\0\
+tm\0\
+teh\0\
+theh\0\
+tk\0\
+jeem\0\
+hah\0\
+"
+"hk\0\
+khah\0\
+dal\0\
+thal\0\
+dk\0\
+reh\0\
+zain\0\
+seen\0\
+sheen\0\
+sn\0\
+sad\0\
+c+\0\
+dad\0\
+dd\0\
+tah\0\
+zah\0\
+zh\0\
+ain\0\
+ghain\0\
+i+\0\
+tatweel\0\
+++\0\
+feh\0\
+f+\0\
+qaf\0\
+lam\0\
+meem\0\
+noon\0\
+heh\0\
+waw\0\
+maksura\0\
+yeh\0\
+y+\0\
+fathatan\0\
+:+\0\
+dammatan\0\
+\"+\0\
+kasratan\0\
+=+\0\
+fatha\0\
+/+\0\
+damma\0\
+'+\0\
+kasra\0\
+1+\0\
+shadda\0\
+3+\0\
+sukun\0\
+0+\0\
+0a\0\
+1a\0\
+2a\0\
+3a\0\
+4a\0\
+5a\0\
+6a\0\
+7a\0\
+8a\0\
+9a\0\
+%a\0\
+as\0\
+peh\0\
+hah hamza\0\
+hh\0\
+tcheh\0\
+tc\0\
+jeh\0\
+veh\0\
+v+\0\
+gaf\0\
+gf\0\
+a-0\0\
+b.\0\
+b-.\0\
+b_\0\
+c,'\0\
+d.\0\
+d-.\0\
+d_\0\
+d,\0\
+d->\0\
+e-!\0\
+e-'\0\
+e->\0\
+e-?\0\
+e,(\0\
+f.\0\
+g-\0\
+h.\0\
+h-.\0\
+h:\0\
+"
+"h,\0\
+h-(\0\
+i-?\0\
+i:'\0\
+k'\0\
+k-.\0\
+k_\0\
+l-.\0\
+l--.\0\
+l_\0\
+l->\0\
+m'\0\
+m.\0\
+m-.\0\
+n.\0\
+n-.\0\
+n_\0\
+n->\0\
+o?'\0\
+o?:\0\
+o-!\0\
+o-'\0\
+p'\0\
+p.\0\
+r.\0\
+r-.\0\
+r--.\0\
+r_\0\
+s.\0\
+s-.\0\
+s'.\0\
+s<.\0\
+s.-.\0\
+t.\0\
+t-.\0\
+t_\0\
+t->\0\
+u--:\0\
+u-?\0\
+u->\0\
+u?'\0\
+u-:\0\
+v?\0\
+v-.\0\
+w!\0\
+w'\0\
+w:\0\
+w.\0\
+w-.\0\
+x.\0\
+x:\0\
+y.\0\
+z>\0\
+z-.\0\
+z_\0\
+a-.\0\
+a2\0\
+a>'\0\
+a>!\0\
+a>2\0\
+a>?\0\
+a>-.\0\
+a('\0\
+a(!\0\
+a(2\0\
+a(?\0\
+a(-.\0\
+e-.\0\
+e2\0\
+e?\0\
+e>'\0\
+e>!\0\
+e>2\0\
+e>?\0\
+e>-.\0\
+i2\0\
+i-.\0\
+o-.\0\
+o2\0\
+o>'\0\
+o>!\0\
+o>2\0\
+o>?\0\
+o>-.\0\
+o9'\0\
+o9!\0\
+o92\0\
+o9?\0\
+o9-.\0\
+u-.\0\
+u2\0\
+u9'\0\
+u9!\0\
+"
+"u92\0\
+u9?\0\
+u9-.\0\
+y!\0\
+y-.\0\
+y2\0\
+y?\0\
+a*,\0\
+a*;\0\
+a*,!\0\
+a*;!\0\
+a*,'\0\
+a*;'\0\
+a*,?\0\
+a*;?\0\
+e*,\0\
+e*;\0\
+e*,!\0\
+e*;!\0\
+e*,'\0\
+e*;'\0\
+y*,\0\
+y*;\0\
+y*,!\0\
+y*;!\0\
+y*,'\0\
+y*;'\0\
+y*,?\0\
+y*;?\0\
+i*,\0\
+i*;\0\
+i*,!\0\
+i*;!\0\
+i*,'\0\
+i*;'\0\
+i*,?\0\
+i*;?\0\
+o*,\0\
+o*;\0\
+o*,!\0\
+o*;!\0\
+o*,'\0\
+o*;'\0\
+u*,\0\
+u*;\0\
+u*,!\0\
+u*;!\0\
+u*,'\0\
+u*;'\0\
+u*,?\0\
+u*;?\0\
+w*,\0\
+w*;\0\
+w*,!\0\
+w*;!\0\
+w*,'\0\
+w*;'\0\
+w*,?\0\
+w*;?\0\
+a*!\0\
+a*'\0\
+e*!\0\
+e*'\0\
+y*!\0\
+y*'\0\
+i*!\0\
+i*'\0\
+o*!\0\
+o*'\0\
+u*!\0\
+u*'\0\
+w*!\0\
+w*'\0\
+a*,j\0\
+a*;j\0\
+a*,!j\0\
+a*;!j\0\
+a*,'j\0\
+a*;'j\0\
+a*,?j\0\
+a*;?j\0\
+y*,j\0\
+y*;j\0\
+y*,!j\0\
+y*;!j\0\
+y*,'j\0\
+"
+"y*;'j\0\
+y*,?j\0\
+y*;?j\0\
+w*,j\0\
+w*;j\0\
+w*,!j\0\
+w*;!j\0\
+w*,'j\0\
+w*;'j\0\
+w*,?j\0\
+w*;?j\0\
+vrachy\0\
+a*(\0\
+a*-\0\
+a*!j\0\
+a*j\0\
+a*'j\0\
+a*?\0\
+a*?j\0\
+koronis\0\
+)*\0\
+,,\0\
+?*\0\
+?:\0\
+y*!j\0\
+y*j\0\
+y*'j\0\
+y*?\0\
+y*?j\0\
+e*!!\0\
+,!\0\
+,'\0\
+?,\0\
+i*(\0\
+i*-\0\
+i*:!\0\
+i*:'\0\
+i*?\0\
+i*:?\0\
+;!\0\
+;'\0\
+?;\0\
+u*(\0\
+u*-\0\
+u*:!\0\
+u*:'\0\
+r*,\0\
+r*;\0\
+u*?\0\
+u*:?\0\
+!:\0\
+:'\0\
+!*\0\
+w*!j\0\
+w*j\0\
+w*'j\0\
+w*?\0\
+w*?j\0\
+/*\0\
+;;\0\
+1n\0\
+1m\0\
+three per em\0\
+3m\0\
+four per em\0\
+4m\0\
+six per em\0\
+6m\0\
+thin\0\
+1t\0\
+hair\0\
+1h\0\
+lr\0\
+rl\0\
+en dash\0\
+-n\0\
+em dash\0\
+-m\0\
+-3\0\
+!2\0\
+=2\0\
+'6\0\
+'9\0\
+low-9 quotation\0\
+.9\0\
+"
+"high reversed-9 quotation\0\
+9'\0\
+\"6\0\
+\"9\0\
+:9\0\
+9\"\0\
+dagger\0\
+/-\0\
+/=\0\
+bullet\0\
+triangular bullet\0\
+3b\0\
+two leader\0\
+..\0\
+ellipsis\0\
+.3\0\
+hyphenation point\0\
+.-\0\
+separator\0\
+linesep\0\
+paragraph separator\0\
+parsep\0\
+per mille\0\
+%0\0\
+prime\0\
+1'\0\
+2'\0\
+triple prime\0\
+3'\0\
+reversed prime\0\
+1\"\0\
+2\"\0\
+reversed triple prime\0\
+3\"\0\
+caret\0\
+ca\0\
+<1\0\
+>1\0\
+reference\0\
+:x\0\
+!*2\0\
+overline\0\
+'-\0\
+hyphen bullet\0\
+-b\0\
+/f\0\
+0s\0\
+4s\0\
+5s\0\
+6s\0\
+7s\0\
+8s\0\
+9s\0\
++s\0\
+minus\0\
+-s\0\
+=s\0\
+(s\0\
+)s\0\
+french franc\0\
+lira\0\
+peseta\0\
+won\0\
+w=\0\
+euro\0\
+combining harpoon\0\
+\"7\0\
+degree celsius\0\
+care\0\
+degree fahrenheit\0\
+numero\0\
+n0\0\
+sound recording copyright\0\
+po\0\
+"
+"prescription take\0\
+rx\0\
+service\0\
+sm\0\
+trade\0\
+ohm\0\
+om\0\
+angstrom\0\
+ao\0\
+estimated symbol\0\
+est\0\
+third\0\
+13\0\
+two thirds\0\
+23\0\
+fifth\0\
+15\0\
+two fifths\0\
+25\0\
+three fifths\0\
+35\0\
+four fifths\0\
+45\0\
+sixth\0\
+16\0\
+five sixths\0\
+56\0\
+eighth\0\
+18\0\
+three eighths\0\
+38\0\
+five eighths\0\
+58\0\
+seven eighths\0\
+78\0\
+1r\0\
+2r\0\
+3r\0\
+4r\0\
+5r\0\
+6r\0\
+7r\0\
+8r\0\
+9r\0\
+ten\0\
+ar\0\
+eleven\0\
+br\0\
+twelve\0\
+fifty\0\
+50r\0\
+hundred\0\
+100r\0\
+five hundred\0\
+500r\0\
+thousand\0\
+1000r\0\
+thousand c d\0\
+1000rcd\0\
+five thousand\0\
+5000r\0\
+ten thousand\0\
+10000r\0\
+leftwards\0\
+<-\0\
+upwards\0\
+-!\0\
+rightwards\0\
+->\0\
+downwards\0\
+-v\0\
+<>\0\
+ud\0\
+north west\0\
+<!!\0\
+north east\0\
+"
+"//>\0\
+south east\0\
+!!>\0\
+south west\0\
+<//\0\
+base\0\
+ud-\0\
+rightwards harpoon barb upwards\0\
+>v\0\
+<=\0\
+=>\0\
+==\0\
+for all\0\
+fa\0\
+partial differential\0\
+dp\0\
+there exists\0\
+empty set\0\
+/0\0\
+increment\0\
+nabla\0\
+element\0\
+(-\0\
+contains as member\0\
+-)\0\
+proof\0\
+fp\0\
+n ary product\0\
+*p\0\
+n ary summation\0\
++z\0\
+-2\0\
+minus plus\0\
+-+\0\
+.+\0\
+asterisk operator\0\
+*-\0\
+operator\0\
+ob\0\
+bullet operator\0\
+root\0\
+rt\0\
+proportional\0\
+0(\0\
+infinity\0\
+00\0\
+angle\0\
+-l\0\
+parallel\0\
+pp\0\
+logical\0\
+an\0\
+intersection\0\
+(u\0\
+union\0\
+)u\0\
+integral\0\
+di\0\
+contour integral\0\
+therefore\0\
+.:\0\
+because\0\
+:.\0\
+ratio\0\
+:r\0\
+proportion\0\
+::\0\
+?1\0\
+lazy s\0\
+cg\0\
+asymptotically\0\
+"
+"?-\0\
+approximately\0\
+?=\0\
+almost\0\
+?2\0\
+all\0\
+=?\0\
+image approximately\0\
+hi\0\
+!=\0\
+identical\0\
+=3\0\
+=<\0\
+>=\0\
+much less\0\
+<*\0\
+much greater\0\
+*>\0\
+not less\0\
+!<\0\
+not greater\0\
+!>\0\
+subset\0\
+(c\0\
+superset\0\
+)c\0\
+(_\0\
+)_\0\
+0.\0\
+02\0\
+tack\0\
+-t\0\
+.p\0\
+:3\0\
+house\0\
+eh\0\
+ceiling\0\
+<7\0\
+>7\0\
+floor\0\
+7<\0\
+7>\0\
+reversed not\0\
+ni\0\
+arc\0\
+(a\0\
+telephone recorder\0\
+tr\0\
+place interest\0\
+88\0\
+top integral\0\
+iu\0\
+bottom integral\0\
+il\0\
+pointing angle\0\
+</\0\
+/>\0\
+open\0\
+chair\0\
+3h\0\
+fork\0\
+2h\0\
+4h\0\
+branch bank identification\0\
+1j\0\
+amount check\0\
+2j\0\
+dash\0\
+3j\0\
+customer account\0\
+4j\0\
+1-o\0\
+2-o\0\
+3-o\0\
+4-o\0\
+5-o\0\
+6-o\0\
+"
+"7-o\0\
+8-o\0\
+9-o\0\
+10-o\0\
+11-o\0\
+12-o\0\
+thirteen\0\
+13-o\0\
+fourteen\0\
+14-o\0\
+fifteen\0\
+15-o\0\
+sixteen\0\
+16-o\0\
+seventeen\0\
+17-o\0\
+eighteen\0\
+18-o\0\
+nineteen\0\
+19-o\0\
+twenty\0\
+20-o\0\
+(1)\0\
+(2)\0\
+(3)\0\
+(4)\0\
+(5)\0\
+(6)\0\
+(7)\0\
+(8)\0\
+(9)\0\
+(10)\0\
+(11)\0\
+(12)\0\
+(13)\0\
+(14)\0\
+(15)\0\
+(16)\0\
+(17)\0\
+(18)\0\
+(19)\0\
+(20)\0\
+1.\0\
+2.\0\
+3.\0\
+4.\0\
+5.\0\
+6.\0\
+7.\0\
+8.\0\
+9.\0\
+10.\0\
+11.\0\
+12.\0\
+13.\0\
+14.\0\
+15.\0\
+16.\0\
+17.\0\
+18.\0\
+19.\0\
+20.\0\
+(a)\0\
+(b)\0\
+(c)\0\
+(d)\0\
+(e)\0\
+(f)\0\
+(g)\0\
+(h)\0\
+(i)\0\
+(j)\0\
+(k)\0\
+(l)\0\
+(m)\0\
+(n)\0\
+(o)\0\
+(p)\0\
+(q)\0\
+(r)\0\
+(s)\0\
+(t)\0\
+(u)\0\
+(v)\0\
+(w)\0\
+(x)\0\
+(y)\0\
+"
+"(z)\0\
+a o\0\
+b o\0\
+c o\0\
+d o\0\
+e o\0\
+f o\0\
+g o\0\
+h o\0\
+i o\0\
+j o\0\
+k o\0\
+l o\0\
+m o\0\
+n o\0\
+o o\0\
+p o\0\
+q o\0\
+r o\0\
+s o\0\
+t o\0\
+u o\0\
+v o\0\
+w o\0\
+x o\0\
+y o\0\
+z o\0\
+0-o\0\
+_-\0\
+hh-\0\
+_=\0\
+vv\0\
+_!\0\
+vv-\0\
+triple dash\0\
+3-\0\
+3_\0\
+3!\0\
+3/\0\
+quadruple dash\0\
+4-\0\
+4_\0\
+4!\0\
+4/\0\
+dr\0\
+_v>\0\
+dr-\0\
+_v<w\0\
+dl-\0\
+ld-\0\
+ur\0\
+_a>\0\
+ur-\0\
+ul\0\
+_a<\0\
+ul-\0\
+vr\0\
+_!>\0\
+vr-\0\
+udr\0\
+vl\0\
+_!<\0\
+vl-\0\
+udl\0\
+dh\0\
+_v-\0\
+dlr\0\
+dh-\0\
+uh\0\
+_-a\0\
+ulr\0\
+uh-\0\
+vh\0\
+_!-\0\
+vlr\0\
+vh-\0\
+udh\0\
+udlr\0\
+ld\0\
+diagonal upper lower\0\
+fd\0\
+_>/\0\
+bd\0\
+upper block\0\
+tb\0\
+lower block\0\
+lb\0\
+block\0\
+fb\0\
+"
+"rb\0\
+shade\0\
+.s\0\
+medium shade\0\
+:s\0\
+dark shade\0\
+?s\0\
+os\0\
+rounded corners\0\
+ro\0\
+containing\0\
+rr\0\
+fill\0\
+rf\0\
+ry\0\
+orthogonal crosshatch fill\0\
+rh\0\
+upper lower fill\0\
+rz\0\
+rk\0\
+diagonal crosshatch fill\0\
+rectangle\0\
+sr\0\
+pointing triangle\0\
+ut\0\
+pointing pointer\0\
+pr\0\
+tl\0\
+pl\0\
+diamond\0\
+db\0\
+dw\0\
+lozenge\0\
+lz\0\
+circle\0\
+0m\0\
+bullseye\0\
+0o\0\
+0l\0\
+0r\0\
+inverse bullet\0\
+inverse circle\0\
+ic\0\
+lower triangle\0\
+_.>/\0\
+large circle\0\
+star\0\
+*2\0\
+*1\0\
+telephone\0\
+tel\0\
+pointing index\0\
+<h\0\
+>h\0\
+smiling face\0\
+0u\0\
+sun rays\0\
+su\0\
+female\0\
+fm\0\
+male\0\
+ml\0\
+spade\0\
+cs\0\
+heart\0\
+ch\0\
+cd\0\
+club\0\
+cs-\0\
+ch-\0\
+cd-\0\
+cc-\0\
+quarter note\0\
+"
+"md\0\
+eighth note\0\
+m8\0\
+_d!\0\
+beamed eighth notes\0\
+m2\0\
+beamed sixteenth notes\0\
+m16\0\
+music flat\0\
+mb\0\
+music natural\0\
+mx\0\
+music sharp\0\
+check\0\
+ok\0\
+ballot x\0\
+xx\0\
+maltese cross\0\
+-x\0\
+is\0\
+,_\0\
+._\0\
+ditto\0\
++\"\0\
+japanese industrial standard symbol\0\
+jis\0\
+iteration\0\
+*_\0\
+closing\0\
+;_\0\
+0_\0\
+<+\0\
+>+\0\
+corner\0\
+<'\0\
+>'\0\
+<\"\0\
+>\"\0\
+lenticular\0\
+(\"\0\
+)\"\0\
+postal\0\
+=t\0\
+geta\0\
+=_\0\
+tortoise shell\0\
+('\0\
+)'\0\
+(i\0\
+)i\0\
+wave dash\0\
+-?\0\
+postal face\0\
+=t:)\0\
+a5\0\
+i5\0\
+u5\0\
+e5\0\
+o5\0\
+ga\0\
+ki\0\
+gi\0\
+ku\0\
+gu\0\
+ke\0\
+ge\0\
+ko\0\
+go\0\
+za\0\
+zi\0\
+zu\0\
+zo\0\
+ta\0\
+da\0\
+ti\0\
+tu\0\
+du\0\
+na\0\
+ne\0\
+ba\0\
+bi\0\
+"
+"hu\0\
+bu\0\
+bo\0\
+ma\0\
+mi\0\
+me\0\
+mo\0\
+yo\0\
+ra\0\
+ru\0\
+re\0\
+wa\0\
+wi\0\
+we\0\
+wo\0\
+n5\0\
+vu\0\
+voiced sound\0\
+\"5\0\
+semi voiced sound\0\
+05\0\
+*5\0\
+voiced iteration\0\
++5\0\
+a6\0\
+i6\0\
+u6\0\
+e6\0\
+o6\0\
+n6\0\
+va\0\
+vi\0\
+vo\0\
+.6\0\
+prolonged sound\0\
+-6\0\
+*6\0\
++6\0\
+b4\0\
+p4\0\
+m4\0\
+f4\0\
+t4\0\
+n4\0\
+l4\0\
+g4\0\
+k4\0\
+h4\0\
+j4\0\
+q4\0\
+x4\0\
+r4\0\
+z4\0\
+c4\0\
+s4\0\
+a4\0\
+o4\0\
+e4\0\
+eh4\0\
+ai\0\
+ei\0\
+au\0\
+ou\0\
+ang\0\
+i4\0\
+u4\0\
+v4\0\
+gn\0\
+hangul cieuc u\0\
+(ju)\0\
+1c\0\
+2c\0\
+3c\0\
+4c\0\
+5c\0\
+6c\0\
+7c\0\
+8c\0\
+9c\0\
+10c\0\
+korean standard symbol\0\
+ksc\0\
+fi\0\
+fl\0\
+ffi\0\
+ffl\0\
+long s t\0\
+3+;\0\
+h'-\0\
+am-\0\
+"
+"am.\0\
+ah-\0\
+ah.\0\
+wh-\0\
+yh,\0\
+a+-\0\
+a+.\0\
+b+-\0\
+b+.\0\
+b+,\0\
+b+;\0\
+tm-\0\
+tm.\0\
+t+-\0\
+t+.\0\
+t+,\0\
+t+;\0\
+tk-\0\
+tk.\0\
+tk,\0\
+tk;\0\
+g+-\0\
+g+.\0\
+g+,\0\
+g+;\0\
+hk-\0\
+hk.\0\
+hk,\0\
+hk;\0\
+x+-\0\
+x+.\0\
+x+,\0\
+x+;\0\
+d+-\0\
+d+.\0\
+dk-\0\
+dk.\0\
+r+-\0\
+r+.\0\
+z+-\0\
+z+.\0\
+s+-\0\
+s+.\0\
+s+,\0\
+s+;\0\
+sn-\0\
+sn.\0\
+sn,\0\
+sn;\0\
+c+-\0\
+c+.\0\
+c+,\0\
+c+;\0\
+dd-\0\
+dd.\0\
+dd,\0\
+dd;\0\
+tj-\0\
+tj.\0\
+tj,\0\
+tj;\0\
+zh-\0\
+zh.\0\
+zh,\0\
+zh;\0\
+e+-\0\
+e+.\0\
+e+,\0\
+e+;\0\
+i+-\0\
+i+.\0\
+i+,\0\
+i+;\0\
+f+-\0\
+f+.\0\
+f+,\0\
+f+;\0\
+q+-\0\
+q+.\0\
+q+,\0\
+q+;\0\
+k+-\0\
+k+.\0\
+k+,\0\
+k+;\0\
+l+-\0\
+l+.\0\
+l+,\0\
+l+;\0\
+m+-\0\
+m+.\0\
+"
+"m+,\0\
+m+;\0\
+n+-\0\
+n+.\0\
+n+,\0\
+n+;\0\
+h+-\0\
+h+.\0\
+h+,\0\
+h+;\0\
+w+-\0\
+w+.\0\
+j+-\0\
+j+.\0\
+y+-\0\
+y+.\0\
+y+,\0\
+y+;\0\
+lam madda\0\
+lm-\0\
+lm.\0\
+lam hamza\0\
+lh-\0\
+lh.\0\
+la-\0\
+la.\0\
+";
+#endif /* UCS_BYTE */
+
+static const char* ucs_strings[] =
+{
+ &ucs_strings_0[0],
+#if !UCS_BYTE
+ &ucs_strings_1[0],
+#endif /* UCS_BYTE */
+};
+
+static const Ucs_dat_t ucs_attrs[] =
+{
+ {{0x00000001,0x00000000,0x00000000},0x0000,0,0},
+ {{0x00000001,0x00000000,0x00000000},0x0000,0,7},
+ {{0x00000001,0x00000000,0x00000000},0x0000,0,12},
+ {{0x00000001,0x00000000,0x00000000},0x0000,0,16},
+ {{0x00000001,0x00000000,0x00000000},0x0000,0,22},
+ {{0x00000001,0x00000000,0x00000000},0x0000,0,27},
+ {{0x00000002,0x00000000,0x00000000},0x0001,0,32},
+ {{0x00000002,0x00000000,0x00000000},0x0001,0,40},
+ {{0x00000004,0x00000000,0x00000000},0x0002,0,43},
+ {{0x00000004,0x00000000,0x00000000},0x0002,0,49},
+ {{0x00000008,0x00000000,0x00000000},0x0003,0,52},
+ {{0x00000010,0x00000000,0x00000000},0x0004,0,58},
+ {{0x00000020,0x00000000,0x00000000},0x0005,0,64},
+ {{0x00000040,0x00000000,0x00000000},0x0006,0,69},
+ {{0x00000080,0x00000000,0x00000000},0x0007,0,75},
+ {{0x00000100,0x00000000,0x00000000},0x0008,0,82},
+ {{0x00000200,0x00000000,0x00000000},0x0009,0,88},
+ {{0x00000400,0x00000000,0x00000000},0x000a,0,97},
+ {{0x00000800,0x00000000,0x00000000},0x000b,0,101},
+ {{0x00001000,0x00000000,0x00000000},0x000c,0,107},
+ {{0x00002000,0x00000000,0x00000000},0x000d,0,113},
+ {{0x00004000,0x00000000,0x00000000},0x000e,0,121},
+ {{0x00008000,0x00000000,0x00000000},0x000f,0,129},
+ {{0x00010000,0x00000000,0x00000000},0x0010,0,140},
+ {{0x00020000,0x00000000,0x00000000},0x0011,0,149},
+ {{0x00040000,0x00000000,0x00000000},0x0012,0,155},
+ {{0x00080000,0x00000000,0x00000000},0x0013,0,165},
+ {{0x00100000,0x00000000,0x00000000},0x0014,0,169},
+ {{0x00200000,0x00000000,0x00000000},0x0015,0,176},
+ {{0x00400000,0x00000000,0x00000000},0x0016,0,181},
+ {{0x00800000,0x00000000,0x00000000},0x0017,0,190},
+ {{0x01000000,0x00000000,0x00000000},0x0018,0,194},
+ {{0x02000000,0x00000000,0x00000000},0x0019,0,200},
+ {{0x04000000,0x00000000,0x00000000},0x001a,0,205},
+ {{0x08000000,0x00000000,0x00000000},0x001b,0,211},
+ {{0x10000000,0x00000000,0x00000000},0x001c,0,217},
+ {{0x20000000,0x00000000,0x00000000},0x001d,0,223},
+ {{0x40000000,0x00000000,0x00000000},0x001e,0,230},
+ {{0x80000000,0x00000000,0x00000000},0x001f,0,239},
+ {{0x00000000,0x00000001,0x00000000},0x0020,0,244},
+ {{0x00000000,0x00000002,0x00000000},0x0021,0,255},
+ {{0x00000000,0x00000004,0x00000000},0x0022,0,260},
+ {{0x00000000,0x00000008,0x00000000},0x0023,0,268},
+ {{0x00000000,0x00000010,0x00000000},0x0024,0,273},
+ {{0x00000000,0x00000020,0x00000000},0x0025,0,282},
+ {{0x00000000,0x00000040,0x00000000},0x0026,0,291},
+ {{0x00000000,0x00000080,0x00000000},0x0027,0,297},
+ {{0x00000000,0x00000100,0x00000000},0x0028,0,302},
+ {{0x00000000,0x00000200,0x00000000},0x0029,0,308},
+ {{0x00000000,0x00000400,0x00000000},0x002a,0,313},
+ {{0x00000000,0x00000800,0x00000000},0x002b,0,320},
+ {{0x00000000,0x00001000,0x00000000},0x002c,0,325},
+ {{0x00000000,0x00002000,0x00000000},0x002d,0,332},
+ {{0x00000000,0x00004000,0x00000000},0x002e,0,339},
+ {{0x00000000,0x00008000,0x00000000},0x002f,0,347},
+ {{0x00000000,0x00010000,0x00000000},0x0030,0,353},
+ {{0x00000000,0x00020000,0x00000000},0x0031,0,357},
+ {{0x00000000,0x00040000,0x00000000},0x0032,0,362},
+ {{0x00000000,0x00080000,0x00000000},0x0033,0,376},
+ {{0x00000000,0x00100000,0x00000000},0x0034,0,388},
+ {{0x00000000,0x00200000,0x00000000},0x0035,0,403},
+ {{0x00000000,0x00400000,0x00000000},0x0036,0,409},
+ {{0x00000000,0x00800000,0x00000000},0x0037,0,415},
+ {{0x00000000,0x01000000,0x00000000},0x0038,0,421},
+ {{0x00000000,0x02000000,0x00000000},0x0039,0,428},
+ {{0x00000000,0x04000000,0x00000000},0x003a,0,434},
+ {{0x00000000,0x08000000,0x00000000},0x003b,0,437},
+ {{0x00000000,0x10000000,0x00000000},0x003c,0,440},
+ {{0x00000000,0x20000000,0x00000000},0x003d,0,448},
+ {{0x00000000,0x40000000,0x00000000},0x003e,0,454},
+ {{0x00000000,0x80000000,0x00000000},0x003f,0,463},
+ {{0x00000000,0x00000000,0x00000001},0x0040,0,469},
+ {{0x00000000,0x00000000,0x00000002},0x0041,0,472},
+ {{0x00000000,0x00000000,0x00000004},0x0042,0,477},
+ {{0x00000000,0x00000000,0x00000008},0x0043,0,483},
+ {{0x00000000,0x00000000,0x00000010},0x0044,0,492},
+ {{0x00000000,0x00000000,0x00000020},0x0045,0,499},
+ {{0x00000000,0x00000000,0x00000040},0x0046,0,511},
+ {{0x00000000,0x00000000,0x00000080},0x0047,0,521},
+ {{0x00000000,0x00000000,0x00000100},0x0048,0,528},
+ {{0x00000000,0x00000000,0x00000200},0x0049,0,537},
+ {{0x00000000,0x00000000,0x00000400},0x004a,0,543},
+ {{0x00000000,0x00000000,0x00000800},0x004b,0,549},
+ {{0x00000000,0x00000000,0x00000800},0x004b,0,559},
+ {{0x00000000,0x00000000,0x00001000},0x004c,0,571},
+ {{0x00000000,0x00000000,0x00002000},0x004d,0,577},
+ {{0x00000000,0x00000000,0x00004000},0x004e,0,583},
+ {{0x00000000,0x00000000,0x00008000},0x004f,0,588},
+ {{0x00000000,0x00000000,0x00010000},0x0050,0,593},
+ {{0x00000000,0x00000000,0x00020000},0x0051,0,596},
+ {{0x00000000,0x00000000,0x00040000},0x0052,0,604},
+ {{0x00000000,0x00000000,0x00080000},0x0053,0,608},
+ {{0x00000000,0x00000000,0x00100000},0x0054,0,613},
+ {{0x00000000,0x00000000,0x00200000},0x0055,0,617},
+ {{0x00000000,0x00000000,0x00400000},0x0056,0,621},
+ {{0x00000000,0x00000000,0x00800000},0x0057,0,634},
+ {{0x00000000,0x00000000,0x01000000},0x0058,0,643},
+ {{0x00000000,0x00000000,0x02000000},0x0059,0,650},
+ {{0x00000000,0x00000000,0x04000000},0x005a,0,657},
+ {{0x00000000,0x00000000,0x08000000},0x005b,0,662},
+ {{0x00000000,0x00000000,0x10000000},0x005c,0,668},
+ {{0x00000000,0x00000000,0x20000000},0x005d,0,675},
+ {{0x00000000,0x00000000,0x40000000},0x005e,0,681},
+ {{0x00000000,0x00000000,0x80000000},0x005f,0,691},
+};
+
+static const Ucs_dat_t ucs_names[] =
+{
+ {{0x00000000,0x00000000,0x00000200},0x0020,0,1288},
+ {{0x00000001,0x00002000,0x00000000},0x0023,0,1288},
+ {{0x00080000,0x00000000,0x00000000},0x002e,0,1288},
+ {{0x00000001,0x00010000,0x00000000},0x0031,0,1288},
+ {{0x00008000,0x00000000,0x00000000},0x005e,0,1288},
+ {{0x00000000,0x02000000,0x00000000},0x007e,0,1288},
+ {{0x00040000,0x00000000,0x00000000},0x00a8,0,1288},
+ {{0x00000000,0x00000400,0x00000000},0x00af,0,1288},
+ {{0x00002000,0x00000000,0x00000000},0x00b8,0,1288},
+ {{0x02000000,0x00000000,0x00000002},0x002e,0,1288},
+ {{0x00000000,0x40000200,0x00000000},0x007c,0,1288},
+ {{0x00080000,0x00000000,0x01000000},0x00b7,0,1288},
+ {{0x00000000,0x00010000,0x00000020},0x00b9,0,1288},
+ {{0x00000000,0x00400000,0x00020080},0x005d,0,1288},
+ {{0x00000000,0x00010000,0x00080018},0x00bd,0,1288},
+ {{0x00000000,0x00000000,0x00000000},0x007d,0,1678},
+ {{0x00000000,0x00000000,0x00000000},0x00a6,0,2550},
+ {{0x00000000,0x00000000,0x00000000},0x00a2,0,2499},
+ {{0x00000000,0x00000000,0x00000000},0x00a1,0,2488},
+ {{0x00000000,0x00000000,0x00000000},0x0024,0,1330},
+ {{0x00000000,0x00000000,0x00000000},0x0060,0,1656},
+ {{0x00000000,0x00000000,0x00000000},0x00b8,0,2736},
+ {{0x00000000,0x00000000,0x00000000},0x00a8,0,2564},
+ {{0x00000000,0x00000000,0x00000000},0x005e,0,1638},
+ {{0x00000000,0x00000000,0x00000000},0x007e,0,1681},
+ {{0x00000000,0x00000000,0x00000000},0x00af,0,2677},
+ {{0x00000000,0x00000000,0x00000000},0x007b,0,1671},
+ {{0x00000000,0x00000000,0x00000000},0x005d,0,1624},
+ {{0x00000000,0x00000000,0x00000000},0x00d7,0,2899},
+ {{0x00000000,0x00000000,0x00000000},0x00b1,0,2701},
+ {{0x00000000,0x00000000,0x00000000},0x00ad,0,2660},
+ {{0x00000000,0x00000000,0x00000000},0x00f7,0,2949},
+ {{0x00000000,0x00000000,0x00000000},0x00aa,0,2607},
+ {{0x00000000,0x00000000,0x00000000},0x00ba,0,2770},
+ {{0x00000000,0x00000000,0x00000000},0x00b7,0,2733},
+ {{0x00000000,0x00000000,0x00000000},0x00bd,0,2787},
+ {{0x00000000,0x00000000,0x00000000},0x00bc,0,2784},
+ {{0x00000000,0x00000000,0x00000000},0x00b9,0,2739},
+ {{0x00000000,0x00000000,0x00000000},0x00b2,0,2704},
+ {{0x00000000,0x00000000,0x00000000},0x00be,0,2805},
+ {{0x00000000,0x00000000,0x00000000},0x00b3,0,2707},
+ {{0x00000000,0x00000000,0x00000000},0x00ac,0,2645},
+ {{0x00000000,0x00000000,0x00000000},0x00b6,0,2730},
+ {{0x00000000,0x00000000,0x00000000},0x00ab,0,2635},
+ {{0x00000000,0x00000000,0x00000000},0x00bb,0,2773},
+ {{0x00000000,0x00000000,0x00000000},0x00bf,0,2808},
+ {{0x00000003,0x00000040,0x00000000},0x0041,0,1546},
+ {{0x00000005,0x00000040,0x00000000},0x0061,0,1546},
+ {{0x04000003,0x00000040,0x00000000},0x00c0,0,1546},
+ {{0x00000013,0x00000040,0x00000000},0x00c1,0,1546},
+ {{0x00008003,0x00000040,0x00000000},0x00c2,0,1546},
+ {{0x00000003,0x02000040,0x00000000},0x00c3,0,1546},
+ {{0x00040003,0x00000040,0x00000000},0x00c4,0,1546},
+ {{0x04000005,0x00000040,0x00000000},0x00e0,0,1546},
+ {{0x00000015,0x00000040,0x00000000},0x00e1,0,1546},
+ {{0x00008005,0x00000040,0x00000000},0x00e2,0,1546},
+ {{0x00000005,0x02000040,0x00000000},0x00e3,0,1546},
+ {{0x00040005,0x00000040,0x00000000},0x00e4,0,1546},
+ {{0x0000000b,0x00000040,0x04000000},0x00c5,0,1546},
+ {{0x0000000d,0x00000040,0x04000000},0x00e5,0,1546},
+ {{0x00000000,0x00000000,0x00000000},0x00c0,0,2811},
+ {{0x00000000,0x00000000,0x00000000},0x00e0,0,2811},
+ {{0x00000000,0x00000000,0x00000000},0x00c1,0,2814},
+ {{0x00000000,0x00000000,0x00000000},0x00e1,0,2814},
+ {{0x00000000,0x00000000,0x00000000},0x00c4,0,2823},
+ {{0x00000000,0x00000000,0x00000000},0x00e4,0,2823},
+ {{0x00000000,0x00000000,0x00000000},0x00c2,0,2817},
+ {{0x00000000,0x00000000,0x00000000},0x00e2,0,2817},
+ {{0x00000000,0x00000000,0x00000000},0x00c3,0,2820},
+ {{0x00000000,0x00000000,0x00000000},0x00e3,0,2820},
+ {{0x00000000,0x00000000,0x00000000},0x00c5,0,2826},
+ {{0x00000000,0x00000000,0x00000000},0x00e5,0,2826},
+ {{0x00000000,0x00000000,0x00000000},0x009f,0,2469},
+ {{0x00008000,0x00000000,0x00000000},0x005e,0,1627},
+ {{0x04000000,0x00000000,0x00000000},0x0060,0,1627},
+ {{0x00000010,0x00000000,0x00000000},0x00b4,0,1627},
+ {{0x00000000,0x00000000,0x00000000},0x0006,0,808},
+ {{0x00000000,0x00000000,0x00000000},0x0006,0,796},
+ {{0x00000000,0x00000000,0x00000000},0x00c6,0,2829},
+ {{0x00000000,0x00000000,0x00000000},0x00e6,0,2829},
+ {{0x00000003,0x00000040,0x00000000},0x00c6,0,2829},
+ {{0x00000005,0x00000040,0x00000000},0x00e6,0,2829},
+ {{0x00000000,0x00000000,0x00000000},0x0006,0,812},
+ {{0x00000000,0x00000000,0x00000000},0x0007,0,827},
+ {{0x00000000,0x00000000,0x00000000},0x0026,0,1341},
+ {{0x00000000,0x00000000,0x00000000},0x009f,0,2472},
+ {{0x00000000,0x00000000,0x00000000},0x0027,0,1351},
+ {{0x00000000,0x00000000,0x00000000},0x009f,0,2441},
+ {{0x00000000,0x00000000,0x00000000},0x002a,0,1374},
+ {{0x00000000,0x00000000,0x00000000},0x0040,0,1540},
+ {{0x00000003,0x00000040,0x00000000},0x0042,0,1548},
+ {{0x00000005,0x00000040,0x00000000},0x0062,0,1548},
+ {{0x00000000,0x00000000,0x00000000},0x005c,0,1614},
+ {{0x00000000,0x00000000,0x00000000},0x0008,0,833},
+ {{0x00000000,0x00000000,0x00000000},0x007c,0,1674},
+ {{0x00000000,0x00000000,0x00000000},0x00a6,0,2547},
+ {{0x00000000,0x00000000,0x00000000},0x0007,0,820},
+ {{0x00000000,0x00000000,0x00000000},0x0007,0,815},
+ {{0x00000000,0x00000000,0x00000000},0x0082,0,1770},
+ {{0x00000000,0x00000000,0x00000000},0x0007,0,824},
+ {{0x00000000,0x00000000,0x00000000},0x0082,0,1773},
+ {{0x00000000,0x00000080,0x00000000},0x007b,0,1665},
+ {{0x00000000,0x00400000,0x00000000},0x007d,0,1665},
+ {{0x00000000,0x00000000,0x00000000},0x0082,0,1749},
+ {{0x00000000,0x00000000,0x00000000},0x00a6,0,2536},
+ {{0x00000000,0x00000000,0x00000000},0x0008,0,843},
+ {{0x00000003,0x00000040,0x00000000},0x0043,0,1550},
+ {{0x00000005,0x00000040,0x00000000},0x0063,0,1550},
+ {{0x00002003,0x00000040,0x00000000},0x00c7,0,1550},
+ {{0x00002005,0x00000040,0x00000000},0x00e7,0,1550},
+ {{0x00000000,0x00000000,0x00000000},0x00c7,0,2832},
+ {{0x00000000,0x00000000,0x00000000},0x00e7,0,2832},
+ {{0x00000000,0x00000000,0x00000000},0x0018,0,1142},
+ {{0x00000000,0x00000000,0x00000000},0x0018,0,1135},
+ {{0x00000000,0x00000000,0x00000000},0x0094,0,2163},
+ {{0x00000000,0x00000000,0x00000000},0x000d,0,886},
+ {{0x00000000,0x00000000,0x00000000},0x0094,0,2180},
+ {{0x00000000,0x00000000,0x00000000},0x0094,0,2183},
+ {{0x00000001,0x00000000,0x00000000},0x00a2,0,2491},
+ {{0x00000000,0x01000000,0x00000000},0x009a,0,2306},
+ {{0x00000001,0x00000000,0x00000000},0x0089,0,1903},
+ {{0x00000000,0x00000000,0x00000000},0x0088,0,1871},
+ {{0x00000000,0x00000000,0x00000000},0x009b,0,2362},
+ {{0x00000000,0x00000000,0x00000000},0x0018,0,1146},
+ {{0x00000000,0x00000000,0x00000000},0x00a9,0,2577},
+ {{0x00000000,0x00000000,0x00000000},0x003a,0,1481},
+ {{0x00000000,0x00000000,0x00000000},0x002c,0,1388},
+ {{0x00000000,0x00000000,0x00000000},0x0040,0,1526},
+ {{0x00000000,0x00000000,0x00000000},0x009b,0,2334},
+ {{0x00000001,0x00000000,0x00000000},0x00a9,0,2567},
+ {{0x00000000,0x00000000,0x00000000},0x000d,0,902},
+ {{0x00000000,0x00000000,0x00000000},0x009b,0,2365},
+ {{0x00000000,0x00000000,0x00000000},0x00a2,0,2496},
+ {{0x00000000,0x00000000,0x00000000},0x00a4,0,2520},
+ {{0x00000000,0x00000080,0x00020000},0x007b,0,1659},
+ {{0x00000000,0x00400000,0x00020000},0x007d,0,1659},
+ {{0x00000001,0x00000000,0x00000000},0x00a4,0,2511},
+ {{0x00000003,0x00000040,0x00000000},0x0044,0,1552},
+ {{0x00000005,0x00000040,0x00000000},0x0064,0,1552},
+ {{0x00000000,0x00000000,0x00000000},0x00d0,0,2863},
+ {{0x00000000,0x00000000,0x00000000},0x00f0,0,2863},
+ {{0x00000000,0x00000000,0x00000000},0x0011,0,969},
+ {{0x00000000,0x00000000,0x00000000},0x0012,0,995},
+ {{0x00000000,0x00000000,0x00000000},0x0013,0,1023},
+ {{0x00000000,0x00000000,0x00000000},0x0014,0,1050},
+ {{0x00000000,0x00000000,0x00000000},0x0010,0,930},
+ {{0x00000000,0x00000000,0x00000000},0x0090,0,2088},
+ {{0x00000000,0x00000000,0x00000000},0x0011,0,972},
+ {{0x00000000,0x00000000,0x00000000},0x0012,0,998},
+ {{0x00000000,0x00000000,0x00000000},0x0013,0,1026},
+ {{0x00000000,0x00000000,0x00000000},0x0014,0,1053},
+ {{0x00000000,0x00000000,0x00000000},0x0090,0,2091},
+ {{0x00000001,0x00000000,0x00000000},0x00b0,0,2680},
+ {{0x00000000,0x00000000,0x00000000},0x007f,0,1692},
+ {{0x00000000,0x00000000,0x00000000},0x007f,0,1685},
+ {{0x00000000,0x00010000,0x00000000},0x0011,0,954},
+ {{0x00000000,0x00000000,0x00000000},0x0014,0,1030},
+ {{0x00000000,0x00000000,0x00000000},0x0090,0,2066},
+ {{0x00000000,0x00000000,0x00000000},0x0013,0,1002},
+ {{0x00000000,0x00000000,0x00000000},0x0012,0,976},
+ {{0x00000000,0x00000000,0x00000000},0x00b0,0,2687},
+ {{0x00000001,0x00000000,0x00000000},0x00f7,0,2940},
+ {{0x00000000,0x00000000,0x00000000},0x0010,0,947},
+ {{0x00000000,0x00000000,0x00000000},0x0010,0,950},
+ {{0x00000000,0x00000000,0x00000000},0x0024,0,1327},
+ {{0x00000001,0x00000000,0x00000000},0x0024,0,1320},
+ {{0x00000000,0x00000000,0x00000000},0x007f,0,1696},
+ {{0x00000003,0x00000040,0x00000000},0x0045,0,1554},
+ {{0x00000005,0x00000040,0x00000000},0x0065,0,1554},
+ {{0x04000003,0x00000040,0x00000000},0x00c8,0,1554},
+ {{0x00000013,0x00000040,0x00000000},0x00c9,0,1554},
+ {{0x00008003,0x00000040,0x00000000},0x00ca,0,1554},
+ {{0x00040003,0x00000040,0x00000000},0x00cb,0,1554},
+ {{0x04000005,0x00000040,0x00000000},0x00e8,0,1554},
+ {{0x00000015,0x00000040,0x00000000},0x00e9,0,1554},
+ {{0x00008005,0x00000040,0x00000000},0x00ea,0,1554},
+ {{0x00040005,0x00000040,0x00000000},0x00eb,0,1554},
+ {{0x00000000,0x00000000,0x00000000},0x00c8,0,2835},
+ {{0x00000000,0x00000000,0x00000000},0x00e8,0,2835},
+ {{0x00000000,0x00000000,0x00000000},0x00c9,0,2838},
+ {{0x00000000,0x00000000,0x00000000},0x00e9,0,2838},
+ {{0x00000000,0x00000000,0x00000000},0x00cb,0,2844},
+ {{0x00000000,0x00000000,0x00000000},0x00eb,0,2844},
+ {{0x00000000,0x00000000,0x00000000},0x00ca,0,2841},
+ {{0x00000000,0x00000000,0x00000000},0x00ea,0,2841},
+ {{0x00000000,0x00000000,0x00000000},0x0017,0,1128},
+ {{0x00000000,0x00000000,0x00000000},0x001b,0,1184},
+ {{0x00000000,0x00000000,0x00000000},0x0097,0,2245},
+ {{0x00000001,0x00000000,0x00000000},0x0038,0,1470},
+ {{0x00000000,0x00000000,0x00000000},0x0019,0,1156},
+ {{0x00000000,0x00000000,0x00000000},0x0005,0,789},
+ {{0x00000000,0x00000000,0x00000000},0x0005,0,781},
+ {{0x00000000,0x00000000,0x00000000},0x0004,0,774},
+ {{0x00000000,0x00000000,0x00000000},0x0097,0,2248},
+ {{0x00000000,0x00000000,0x00000000},0x0005,0,793},
+ {{0x00000001,0x00000000,0x00000000},0x003d,0,1502},
+ {{0x00000000,0x00000000,0x00000000},0x0087,0,1864},
+ {{0x00000000,0x00000000,0x00000000},0x0087,0,1867},
+ {{0x00000000,0x00000000,0x00000000},0x001b,0,1187},
+ {{0x00000000,0x00000000,0x00000000},0x001b,0,1177},
+ {{0x00000000,0x00000000,0x00000000},0x0004,0,778},
+ {{0x00000000,0x00000000,0x00000000},0x0017,0,1131},
+ {{0x00000003,0x00000040,0x00000000},0x00d0,0,2859},
+ {{0x00000005,0x00000040,0x00000000},0x00f0,0,2859},
+ {{0x00000000,0x00000000,0x00000000},0x0003,0,754},
+ {{0x00000000,0x00000000,0x00000000},0x0003,0,758},
+ {{0x00000000,0x00000800,0x00000000},0x0021,0,1292},
+ {{0x00000000,0x00000800,0x00800000},0x00a1,0,1292},
+ {{0x00000003,0x00000040,0x00000000},0x0046,0,1556},
+ {{0x00000005,0x00000040,0x00000000},0x0066,0,1556},
+ {{0x00000001,0x00000000,0x00000000},0x000c,0,864},
+ {{0x00000000,0x00000200,0x00000000},0x000a,0,864},
+ {{0x00000000,0x00000000,0x00000000},0x00aa,0,2580},
+ {{0x00000000,0x00000000,0x00000000},0x000c,0,883},
+ {{0x00000000,0x00000000,0x00000000},0x001c,0,1191},
+ {{0x00000001,0x00000000,0x00000000},0x0035,0,1455},
+ {{0x00000001,0x00000000,0x00000000},0x0034,0,1450},
+ {{0x00000000,0x00000000,0x00000000},0x001c,0,1206},
+ {{0x00000003,0x00000040,0x00000000},0x0047,0,1558},
+ {{0x00000005,0x00000040,0x00000000},0x0067,0,1558},
+ {{0x00000000,0x00000000,0x00000000},0x0099,0,2298},
+ {{0x00000000,0x01000000,0x00000000},0x0099,0,2269},
+ {{0x00000001,0x00000000,0x00004000},0x003e,0,1509},
+ {{0x00000000,0x00000000,0x00000000},0x001d,0,1213},
+ {{0x00000000,0x00000000,0x00000000},0x001d,0,1229},
+ {{0x00000000,0x00000000,0x00100001},0x0097,0,2232},
+ {{0x00000003,0x00000040,0x00000000},0x0048,0,1560},
+ {{0x00000005,0x00000040,0x00000000},0x0068,0,1560},
+ {{0x00000000,0x00000000,0x00000000},0x0023,0,1317},
+ {{0x00000000,0x00000000,0x00000000},0x005e,0,1634},
+ {{0x00000000,0x00000000,0x00000000},0x0081,0,1724},
+ {{0x00000000,0x00000000,0x00000000},0x0089,0,1938},
+ {{0x00000000,0x00000000,0x00000000},0x0081,0,1742},
+ {{0x00000000,0x00000000,0x00000000},0x0081,0,1745},
+ {{0x00000000,0x00000000,0x00000000},0x0088,0,1896},
+ {{0x00000000,0x00000000,0x00000000},0x0009,0,861},
+ {{0x00000000,0x00000000,0x00000000},0x0089,0,1941},
+ {{0x00000000,0x00000000,0x00000000},0x0088,0,1899},
+ {{0x00000000,0x00000000,0x00000000},0x002d,0,1407},
+ {{0x00000000,0x00000000,0x00000000},0x002d,0,1394},
+ {{0x00000003,0x00000040,0x00000000},0x0049,0,1562},
+ {{0x00000005,0x00000040,0x00000000},0x0069,0,1562},
+ {{0x04000003,0x00000040,0x00000000},0x00cc,0,1562},
+ {{0x00000013,0x00000040,0x00000000},0x00cd,0,1562},
+ {{0x00008003,0x00000040,0x00000000},0x00ce,0,1562},
+ {{0x00040003,0x00000040,0x00000000},0x00cf,0,1562},
+ {{0x04000005,0x00000040,0x00000000},0x00ec,0,1562},
+ {{0x00000015,0x00000040,0x00000000},0x00ed,0,1562},
+ {{0x00008005,0x00000040,0x00000000},0x00ee,0,1562},
+ {{0x00040005,0x00000040,0x00000000},0x00ef,0,1562},
+ {{0x00000000,0x00000000,0x00000000},0x00cc,0,2847},
+ {{0x00000000,0x00000000,0x00000000},0x00ec,0,2847},
+ {{0x00000000,0x00000000,0x00000000},0x00cd,0,2850},
+ {{0x00000000,0x00000000,0x00000000},0x00ed,0,2850},
+ {{0x00000000,0x00000000,0x00000000},0x00cf,0,2856},
+ {{0x00000000,0x00000000,0x00000000},0x00ef,0,2856},
+ {{0x00000000,0x00000000,0x00000000},0x00ce,0,2853},
+ {{0x00000000,0x00000000,0x00000000},0x00ee,0,2853},
+ {{0x00000000,0x00000000,0x00000000},0x0084,0,1804},
+ {{0x00000000,0x00000000,0x00000000},0x0084,0,1807},
+ {{0x00000000,0x00000000,0x00000000},0x0084,0,1798},
+ {{0x00000000,0x00000000,0x00000000},0x001d,0,1236},
+ {{0x00000000,0x00000000,0x00000000},0x001f,0,1281},
+ {{0x00000000,0x00000000,0x00000000},0x001e,0,1259},
+ {{0x00000000,0x00000000,0x00000000},0x001d,0,1232},
+ {{0x00000000,0x00000000,0x00000000},0x001c,0,1209},
+ {{0x00000003,0x00000040,0x00000000},0x004a,0,1564},
+ {{0x00000005,0x00000040,0x00000000},0x006a,0,1564},
+ {{0x00000003,0x00000040,0x00000000},0x004b,0,1566},
+ {{0x00000005,0x00000040,0x00000000},0x006b,0,1566},
+ {{0x00000003,0x00000040,0x00000000},0x004c,0,1568},
+ {{0x00000005,0x00000040,0x00000000},0x006c,0,1568},
+ {{0x00000000,0x00000000,0x00000000},0x00a3,0,2508},
+ {{0x00000001,0x00000000,0x00004000},0x003c,0,1497},
+ {{0x00000000,0x00000000,0x00000000},0x000a,0,869},
+ {{0x00000000,0x00000200,0x00000000},0x005f,0,1641},
+ {{0x00000003,0x00000040,0x00000000},0x004d,0,1570},
+ {{0x00000005,0x00000040,0x00000000},0x006d,0,1570},
+ {{0x00000000,0x00000000,0x00000000},0x00ba,0,2742},
+ {{0x00000000,0x00000000,0x00100001},0x0019,0,1149},
+ {{0x00000000,0x00000000,0x00000000},0x0095,0,2187},
+ {{0x00000001,0x00000000,0x00000000},0x00b5,0,2710},
+ {{0x00000001,0x00000000,0x00000000},0x00d7,0,2884},
+ {{0x00000000,0x00000000,0x00000000},0x0095,0,2203},
+ {{0x00000000,0x00000000,0x00000000},0x00b5,0,2716},
+ {{0x00000003,0x00000040,0x00000000},0x004e,0,1572},
+ {{0x00000005,0x00000040,0x00000000},0x006e,0,1572},
+ {{0x00000003,0x02000040,0x00000000},0x00d1,0,1572},
+ {{0x00000005,0x02000040,0x00000000},0x00f1,0,1572},
+ {{0x00000000,0x00000000,0x00000000},0x00d1,0,2866},
+ {{0x00000000,0x00000000,0x00000000},0x00f1,0,2866},
+ {{0x00000000,0x00000000,0x00000000},0x0015,0,1078},
+ {{0x00000000,0x00000000,0x00000000},0x0023,0,1314},
+ {{0x00000000,0x00000000,0x00000000},0x0083,0,1794},
+ {{0x00000000,0x00000000,0x00000000},0x0015,0,1057},
+ {{0x00000000,0x00000000,0x00000000},0x0085,0,1819},
+ {{0x00000000,0x00000000,0x00000000},0x000a,0,872},
+ {{0x00000000,0x00000200,0x00000000},0x0085,0,1811},
+ {{0x00000000,0x00000000,0x00000000},0x0083,0,1791},
+ {{0x00000001,0x00000000,0x00000000},0x0039,0,1476},
+ {{0x00000000,0x00000000,0x00000000},0x0015,0,1082},
+ {{0x00000000,0x00000000,0x00000000},0x0085,0,1816},
+ {{0x00000000,0x00000000,0x00000000},0x00ac,0,2642},
+ {{0x00000000,0x00000000,0x00000200},0x00a0,0,2476},
+ {{0x00000000,0x00000000,0x00000000},0x0083,0,1777},
+ {{0x00000001,0x00000000,0x00000000},0x00ac,0,2638},
+ {{0x00000000,0x00000000,0x00000000},0x00a0,0,2485},
+ {{0x00000000,0x00000000,0x00000000},0x0000,0,707},
+ {{0x00000000,0x00000000,0x00000000},0x0000,0,703},
+ {{0x00000000,0x00000000,0x00000000},0x0000,0,698},
+ {{0x00000003,0x00000040,0x00000000},0x004f,0,1574},
+ {{0x00000005,0x00000040,0x00000000},0x006f,0,1574},
+ {{0x04000003,0x00000040,0x00000000},0x00d2,0,1574},
+ {{0x00000013,0x00000040,0x00000000},0x00d3,0,1574},
+ {{0x00008003,0x00000040,0x00000000},0x00d4,0,1574},
+ {{0x00000003,0x02000040,0x00000000},0x00d5,0,1574},
+ {{0x00040003,0x00000040,0x00000000},0x00d6,0,1574},
+ {{0x00000003,0x00000040,0x10000000},0x00d8,0,1574},
+ {{0x04000005,0x00000040,0x00000000},0x00f2,0,1574},
+ {{0x00000015,0x00000040,0x00000000},0x00f3,0,1574},
+ {{0x00008005,0x00000040,0x00000000},0x00f4,0,1574},
+ {{0x00000005,0x02000040,0x00000000},0x00f5,0,1574},
+ {{0x00040005,0x00000040,0x00000000},0x00f6,0,1574},
+ {{0x00000005,0x00000040,0x10000000},0x00f8,0,1574},
+ {{0x00000000,0x00000000,0x00000000},0x00d2,0,2869},
+ {{0x00000000,0x00000000,0x00000000},0x00f2,0,2869},
+ {{0x00000000,0x00000000,0x00000000},0x00d3,0,2872},
+ {{0x00000000,0x00000000,0x00000000},0x00f3,0,2872},
+ {{0x00000000,0x00000000,0x00000000},0x00d8,0,2902},
+ {{0x00000000,0x00000000,0x00000000},0x00f8,0,2902},
+ {{0x00000000,0x00000000,0x00000000},0x00d6,0,2881},
+ {{0x00000000,0x00000000,0x00000000},0x00f6,0,2881},
+ {{0x00000000,0x00000000,0x00000000},0x00d4,0,2875},
+ {{0x00000000,0x00000000,0x00000000},0x00f4,0,2875},
+ {{0x00000000,0x00000000,0x00000000},0x00d5,0,2878},
+ {{0x00000000,0x00000000,0x00000000},0x00f5,0,2878},
+ {{0x00000000,0x00000000,0x00000000},0x0040,0,1543},
+ {{0x00000000,0x00000000,0x00000000},0x009d,0,2415},
+ {{0x00000000,0x00000000,0x00000000},0x009d,0,2390},
+ {{0x00000000,0x00000000,0x00000000},0x009d,0,2418},
+ {{0x00000003,0x00000040,0x00000000},0x0050,0,1576},
+ {{0x00000005,0x00000040,0x00000000},0x0070,0,1576},
+ {{0x00000000,0x00000000,0x00000000},0x0091,0,2107},
+ {{0x00000000,0x00000000,0x00000000},0x0092,0,2130},
+ {{0x00000000,0x00000000,0x00000000},0x0080,0,1717},
+ {{0x00000000,0x00000000,0x00000000},0x0080,0,1720},
+ {{0x00000000,0x00000000,0x00000000},0x0080,0,1699},
+ {{0x00000000,0x00000080,0x00000000},0x0028,0,1362},
+ {{0x00000000,0x00400000,0x00000000},0x0029,0,1362},
+ {{0x00000000,0x00000200,0x00000000},0x008c,0,1990},
+ {{0x00000000,0x00000200,0x00000000},0x008b,0,1967},
+ {{0x00000000,0x00000000,0x00000000},0x008b,0,1983},
+ {{0x00000000,0x00000000,0x00000000},0x00a3,0,1983},
+ {{0x00000001,0x00000000,0x00000000},0x0025,0,1333},
+ {{0x00000000,0x00000000,0x00000000},0x002e,0,1414},
+ {{0x00000000,0x00000000,0x00000000},0x00b6,0,2727},
+ {{0x00000001,0x00000000,0x00000000},0x00b6,0,2719},
+ {{0x00000000,0x00000000,0x00000000},0x008b,0,1986},
+ {{0x00000000,0x00000000,0x00000000},0x008c,0,2010},
+ {{0x00000001,0x00000000,0x00000000},0x002b,0,1383},
+ {{0x00000001,0x00000000,0x00000000},0x00b1,0,2690},
+ {{0x00000000,0x00000000,0x00000000},0x009e,0,2438},
+ {{0x00100000,0x00000880,0x00000000},0x00ab,0,2610},
+ {{0x00100000,0x00400800,0x00000000},0x00bb,0,2610},
+ {{0x00000001,0x00000000,0x00000000},0x00a3,0,2502},
+ {{0x00000000,0x00000000,0x00000000},0x009e,0,2422},
+ {{0x00000000,0x00010000,0x00000000},0x0091,0,2095},
+ {{0x00000000,0x00000000,0x00000000},0x0092,0,2114},
+ {{0x00000000,0x00000000,0x00000000},0x008c,0,2007},
+ {{0x00000000,0x00000000,0x00000000},0x0091,0,2110},
+ {{0x00000000,0x00000000,0x00000000},0x0092,0,2133},
+ {{0x00000003,0x00000040,0x00000000},0x0051,0,1578},
+ {{0x00000005,0x00000040,0x00000000},0x0071,0,1578},
+ {{0x00000000,0x00010000,0x00000018},0x00bc,0,2776},
+ {{0x00000000,0x00000800,0x00000000},0x003f,0,1517},
+ {{0x00000000,0x00000800,0x00800000},0x00bf,0,1517},
+ {{0x00000000,0x00000800,0x00000000},0x0022,0,1304},
+ {{0x00000003,0x00000040,0x00000000},0x0052,0,1580},
+ {{0x00000005,0x00000040,0x00000000},0x0072,0,1580},
+ {{0x00000000,0x00000000,0x00000000},0x001e,0,1242},
+ {{0x00000001,0x00000000,0x00000000},0x00ae,0,2663},
+ {{0x00000000,0x00000200,0x00000000},0x008d,0,2014},
+ {{0x00000000,0x00000000,0x00000000},0x005c,0,1598},
+ {{0x00000000,0x00000000,0x00000000},0x00ae,0,2674},
+ {{0x00000000,0x00000000,0x00000000},0x008d,0,2027},
+ {{0x00000000,0x00000000,0x00000000},0x001e,0,1263},
+ {{0x00000003,0x00000040,0x00000000},0x0053,0,1582},
+ {{0x00000005,0x00000040,0x00000000},0x0073,0,1582},
+ {{0x00000000,0x00000000,0x00000000},0x008e,0,2040},
+ {{0x00000000,0x00000000,0x00000000},0x008f,0,2059},
+ {{0x00000000,0x00000000,0x00000000},0x0086,0,1843},
+ {{0x00000000,0x00000000,0x00000000},0x001a,0,1170},
+ {{0x00000000,0x00000000,0x00000000},0x009a,0,2327},
+ {{0x00000000,0x00000000,0x00000000},0x009a,0,2330},
+ {{0x00000000,0x00000000,0x00000000},0x00a7,0,2561},
+ {{0x00000001,0x00000000,0x00000000},0x00a7,0,2553},
+ {{0x00000000,0x00000000,0x00100001},0x0087,0,1850},
+ {{0x00000000,0x00000000,0x00000000},0x003b,0,1487},
+ {{0x00000000,0x00000000,0x00000000},0x0093,0,2137},
+ {{0x00000001,0x00000000,0x00000000},0x0037,0,1464},
+ {{0x00000000,0x00000000,0x00000000},0x0096,0,2225},
+ {{0x00000000,0x00000000,0x00000000},0x0099,0,2301},
+ {{0x00000000,0x00000000,0x00000000},0x0001,0,728},
+ {{0x00000005,0x00000040,0x00000000},0x00df,0,2929},
+ {{0x00000000,0x00000000,0x00000000},0x000f,0,918},
+ {{0x00000000,0x00000000,0x00000000},0x000e,0,905},
+ {{0x00000000,0x01000000,0x00000000},0x008f,0,2047},
+ {{0x00000000,0x01000000,0x00000000},0x008e,0,2030},
+ {{0x00000000,0x00000000,0x00000000},0x000f,0,927},
+ {{0x00000001,0x00000000,0x00000000},0x0036,0,1460},
+ {{0x00000000,0x00000000,0x00000000},0x002f,0,1429},
+ {{0x00000000,0x00000000,0x00000000},0x000e,0,915},
+ {{0x00000000,0x00000000,0x00000000},0x00ad,0,2648},
+ {{0x00000000,0x00000000,0x00000000},0x0001,0,724},
+ {{0x00000000,0x00000000,0x00000000},0x002f,0,1421},
+ {{0x00000000,0x00000000,0x00000000},0x0098,0,2265},
+ {{0x00000000,0x00000000,0x00000000},0x0020,0,1289},
+ {{0x00000000,0x00000000,0x00000000},0x0096,0,2228},
+ {{0x00000000,0x00000000,0x00000000},0x00df,0,2937},
+ {{0x00000000,0x00000000,0x00000000},0x008e,0,2043},
+ {{0x00000000,0x00000000,0x00000000},0x008f,0,2062},
+ {{0x00000000,0x00000000,0x00000000},0x0086,0,1846},
+ {{0x00000000,0x00000000,0x00000000},0x009c,0,2387},
+ {{0x00000000,0x00000000,0x00000001},0x0096,0,2206},
+ {{0x00000000,0x00000000,0x00000001},0x0001,0,710},
+ {{0x00000000,0x00000000,0x00000001},0x0086,0,1823},
+ {{0x00000000,0x00000000,0x00000001},0x0098,0,2252},
+ {{0x00000000,0x00000000,0x00000001},0x0002,0,731},
+ {{0x00000000,0x00000000,0x00000000},0x009c,0,2369},
+ {{0x00000000,0x00000000,0x00000000},0x0093,0,2159},
+ {{0x00000000,0x00000000,0x00000000},0x0002,0,742},
+ {{0x00000000,0x00000000,0x00000000},0x001a,0,1173},
+ {{0x00000000,0x00000000,0x00000000},0x001a,0,1159},
+ {{0x00000000,0x00000000,0x00000000},0x0002,0,746},
+ {{0x00000000,0x00000000,0x00000000},0x0016,0,1102},
+ {{0x00000000,0x00000000,0x00000000},0x0016,0,1105},
+ {{0x00000000,0x00000000,0x00000000},0x0016,0,1085},
+ {{0x00000003,0x00000040,0x00000000},0x0054,0,1584},
+ {{0x00000005,0x00000040,0x00000000},0x0074,0,1584},
+ {{0x00000000,0x00000000,0x00000000},0x0009,0,857},
+ {{0x00000000,0x00000001,0x00000000},0x0009,0,857},
+ {{0x00000000,0x40000000,0x00000000},0x000b,0,857},
+ {{0x00000000,0x00000001,0x00000000},0x0009,0,846},
+ {{0x00000000,0x40000000,0x00000000},0x000b,0,846},
+ {{0x00000000,0x00000200,0x00000000},0x008a,0,1945},
+ {{0x00000000,0x00000000,0x00100001},0x0003,0,749},
+ {{0x00000000,0x00000000,0x00000000},0x00de,0,2926},
+ {{0x00000000,0x00000000,0x00000000},0x00fe,0,2926},
+ {{0x00000003,0x00000040,0x00000000},0x00de,0,2920},
+ {{0x00000005,0x00000040,0x00000000},0x00fe,0,2920},
+ {{0x00000001,0x00000000,0x00000000},0x0033,0,1444},
+ {{0x00000000,0x00000000,0x00000020},0x00b3,0,1444},
+ {{0x00000000,0x00000000,0x00000018},0x00be,0,2790},
+ {{0x00000000,0x00000000,0x00100001},0x0004,0,761},
+ {{0x00000000,0x00000000,0x00100001},0x0017,0,1109},
+ {{0x00000000,0x00000000,0x00000000},0x0093,0,2156},
+ {{0x00000001,0x00000000,0x00000000},0x0032,0,1440},
+ {{0x00000000,0x00000000,0x00000020},0x00b2,0,1440},
+ {{0x00000003,0x00000040,0x00000000},0x0055,0,1586},
+ {{0x00000005,0x00000040,0x00000000},0x0075,0,1586},
+ {{0x04000003,0x00000040,0x00000000},0x00d9,0,1586},
+ {{0x00000013,0x00000040,0x00000000},0x00da,0,1586},
+ {{0x00008003,0x00000040,0x00000000},0x00db,0,1586},
+ {{0x00040003,0x00000040,0x00000000},0x00dc,0,1586},
+ {{0x04000005,0x00000040,0x00000000},0x00f9,0,1586},
+ {{0x00000015,0x00000040,0x00000000},0x00fa,0,1586},
+ {{0x00008005,0x00000040,0x00000000},0x00fb,0,1586},
+ {{0x00040005,0x00000040,0x00000000},0x00fc,0,1586},
+ {{0x00000000,0x00000000,0x00000000},0x00d9,0,2905},
+ {{0x00000000,0x00000000,0x00000000},0x00f9,0,2905},
+ {{0x00000000,0x00000000,0x00000000},0x00da,0,2908},
+ {{0x00000000,0x00000000,0x00000000},0x00fa,0,2908},
+ {{0x00000000,0x00000000,0x00000000},0x00dc,0,2914},
+ {{0x00000000,0x00000000,0x00000000},0x00fc,0,2914},
+ {{0x00000000,0x00000000,0x00000000},0x00db,0,2911},
+ {{0x00000000,0x00000000,0x00000000},0x00fb,0,2911},
+ {{0x00000000,0x00000000,0x00000000},0x005f,0,1645},
+ {{0x00000000,0x00000000,0x00000000},0x001f,0,1266},
+ {{0x00000000,0x00000000,0x00000000},0x001f,0,1285},
+ {{0x00000003,0x00000040,0x00000000},0x0056,0,1588},
+ {{0x00000005,0x00000040,0x00000000},0x0076,0,1588},
+ {{0x00000000,0x00000000,0x00000000},0x008a,0,1960},
+ {{0x00000000,0x00000000,0x00000000},0x000b,0,880},
+ {{0x00000000,0x00000000,0x00000000},0x008a,0,1963},
+ {{0x00000003,0x00000040,0x00000000},0x0057,0,1590},
+ {{0x00000005,0x00000040,0x00000000},0x0077,0,1590},
+ {{0x00000003,0x00000040,0x00000000},0x0058,0,1592},
+ {{0x00000005,0x00000040,0x00000000},0x0078,0,1592},
+ {{0x00000000,0x00000000,0x00000000},0x00a4,0,2523},
+ {{0x00000003,0x00000040,0x00000000},0x0059,0,1594},
+ {{0x00000005,0x00000040,0x00000000},0x0079,0,1594},
+ {{0x00000013,0x00000040,0x00000000},0x00dd,0,1594},
+ {{0x00000015,0x00000040,0x00000000},0x00fd,0,1594},
+ {{0x00040005,0x00000040,0x00000000},0x00ff,0,1594},
+ {{0x00000000,0x00000000,0x00000000},0x00dd,0,2917},
+ {{0x00000000,0x00000000,0x00000000},0x00fd,0,2917},
+ {{0x00000000,0x00000000,0x00000000},0x00a5,0,2533},
+ {{0x00000000,0x00000000,0x00000000},0x00ff,0,2952},
+ {{0x00000000,0x00000000,0x00000000},0x00a5,0,2530},
+ {{0x00000001,0x00000000,0x00000000},0x00a5,0,2526},
+ {{0x00000003,0x00000040,0x00000000},0x005a,0,1596},
+ {{0x00000005,0x00000040,0x00000000},0x007a,0,1596},
+ {{0x00000001,0x00000000,0x00000000},0x0030,0,1435},
+#if !UCS_BYTE
+ {{0x00001000,0x00000000,0x00000000},0x02c7,0,1288},
+ {{0x00000800,0x00000000,0x00000000},0x02d8,0,1288},
+ {{0x00000000,0x00000000,0x02000000},0x02db,0,1288},
+ {{0x00000000,0x00000000,0x00000001},0x2109,0,1288},
+ {{0x00000000,0x00000000,0x00010000},0x2228,0,1288},
+ {{0x00000000,0x00000000,0x00010000},0x25ad,0,1288},
+ {{0x00080008,0x00000000,0x00000000},0x02d9,0,1288},
+ {{0x00000008,0x00000000,0x04000000},0x02da,0,1288},
+ {{0x00000004,0x02000000,0x00000000},0x02dc,0,1288},
+ {{0x08000001,0x00004000,0x00000000},0x0374,0,1288},
+ {{0x08000000,0x00000000,0x20000000},0x0384,0,1288},
+ {{0x20000021,0x00000000,0x00000000},0x05d0,0,1288},
+ {{0x000000a1,0x00000000,0x00000000},0x0627,0,1288},
+ {{0x08000000,0x00100000,0x00000000},0x1fbe,0,1288},
+ {{0x08000000,0x00200000,0x00000000},0x1fbf,0,1288},
+ {{0x08000000,0x00080000,0x00000000},0x1fc0,0,1288},
+ {{0x08000000,0x20000000,0x00000000},0x1fef,0,1288},
+ {{0x08000000,0x00020000,0x00000000},0x1ffd,0,1288},
+ {{0x08020000,0x00000000,0x00000000},0x1ffe,0,1288},
+ {{0x00000000,0x00010000,0x00000040},0x2081,0,1288},
+ {{0x80000000,0x00000000,0x00040000},0x2440,0,1288},
+ {{0x00004001,0x00010000,0x00000000},0x2460,0,1288},
+ {{0x00000001,0x00050000,0x00000000},0x2474,0,1288},
+ {{0x00000000,0x00000000,0x00000084},0x25a0,0,1288},
+ {{0x00000000,0x80000000,0x00000080},0x25a1,0,1288},
+ {{0x00000000,0x00000000,0x00000a00},0x3000,0,1288},
+ {{0x40000001,0x04000000,0x00000000},0x3068,0,1288},
+ {{0x00000001,0x04000020,0x00000000},0x30c8,0,1288},
+ {{0x08000043,0x00000000,0x00000000},0x0391,0,1288},
+ {{0x08800003,0x00000000,0x00000000},0x0397,0,1288},
+ {{0x08000003,0x00000008,0x00000000},0x0399,0,1288},
+ {{0x08000003,0x10000000,0x00000000},0x03a5,0,1288},
+ {{0x08000003,0x00008000,0x00000000},0x03a9,0,1288},
+ {{0x08000045,0x00000000,0x00000000},0x03b1,0,1288},
+ {{0x08800005,0x00000000,0x00000000},0x03b7,0,1288},
+ {{0x08000005,0x00000008,0x00000000},0x03b9,0,1288},
+ {{0x08000005,0x10000000,0x00000000},0x03c5,0,1288},
+ {{0x08000005,0x00008000,0x00000000},0x03c9,0,1288},
+ {{0x00000081,0x00010000,0x00000400},0x0661,0,1288},
+ {{0x000000a1,0x00000000,0x00000020},0x0670,0,1288},
+ {{0x08000001,0x20200000,0x00000000},0x1fcd,0,1288},
+ {{0x08000001,0x00220000,0x00000000},0x1fce,0,1288},
+ {{0x08000001,0x00280000,0x00000000},0x1fcf,0,1288},
+ {{0x08020001,0x20000000,0x00000000},0x1fdd,0,1288},
+ {{0x08020001,0x00020000,0x00000000},0x1fde,0,1288},
+ {{0x08020001,0x00080000,0x00000000},0x1fdf,0,1288},
+ {{0x00100000,0x40000200,0x00000000},0x2016,0,1288},
+ {{0x00000000,0x00814000,0x00000000},0x2160,0,1288},
+ {{0x00000000,0x00400080,0x00002000},0x2194,0,1288},
+ {{0x00200000,0x08000000,0x00002000},0x2195,0,1288},
+ {{0x02000001,0x00010000,0x00000002},0x2488,0,1288},
+ {{0x00000004,0x00000000,0x00000084},0x25aa,0,1288},
+ {{0x02000000,0x00000000,0x00000802},0x3002,0,1288},
+ {{0x00080000,0x00000020,0x01000000},0x30fb,0,1288},
+ {{0x00000000,0x00050000,0x00000800},0x3220,0,1288},
+ {{0x000000a1,0x00000010,0x00000000},0xfe8d,0,1288},
+ {{0x010000a1,0x00000000,0x00000000},0xfe8e,0,1288},
+ {{0x08000043,0x00000000,0x20000000},0x0386,0,1288},
+ {{0x08800003,0x00000000,0x20000000},0x0389,0,1288},
+ {{0x08000003,0x00000008,0x20000000},0x038a,0,1288},
+ {{0x08000003,0x10000000,0x20000000},0x038e,0,1288},
+ {{0x08000003,0x00008000,0x20000000},0x038f,0,1288},
+ {{0x08000045,0x00000000,0x20000000},0x03ac,0,1288},
+ {{0x08800005,0x00000000,0x20000000},0x03ae,0,1288},
+ {{0x08000005,0x00000008,0x20000000},0x03af,0,1288},
+ {{0x08000005,0x10000000,0x20000000},0x03cd,0,1288},
+ {{0x08000005,0x00008000,0x20000000},0x03ce,0,1288},
+ {{0x08000045,0x00200000,0x00000000},0x1f00,0,1288},
+ {{0x08020045,0x00000000,0x00000000},0x1f01,0,1288},
+ {{0x08000043,0x00200000,0x00000000},0x1f08,0,1288},
+ {{0x08020043,0x00000000,0x00000000},0x1f09,0,1288},
+ {{0x08800005,0x00200000,0x00000000},0x1f20,0,1288},
+ {{0x08820005,0x00000000,0x00000000},0x1f21,0,1288},
+ {{0x08800003,0x00200000,0x00000000},0x1f28,0,1288},
+ {{0x08820003,0x00000000,0x00000000},0x1f29,0,1288},
+ {{0x08000005,0x00200008,0x00000000},0x1f30,0,1288},
+ {{0x08020005,0x00000008,0x00000000},0x1f31,0,1288},
+ {{0x08000003,0x00200008,0x00000000},0x1f38,0,1288},
+ {{0x08020003,0x00000008,0x00000000},0x1f39,0,1288},
+ {{0x08000005,0x10200000,0x00000000},0x1f50,0,1288},
+ {{0x08020005,0x10000000,0x00000000},0x1f51,0,1288},
+ {{0x08020003,0x10000000,0x00000000},0x1f59,0,1288},
+ {{0x08000005,0x00208000,0x00000000},0x1f60,0,1288},
+ {{0x08020005,0x00008000,0x00000000},0x1f61,0,1288},
+ {{0x08000003,0x00208000,0x00000000},0x1f68,0,1288},
+ {{0x08020003,0x00008000,0x00000000},0x1f69,0,1288},
+ {{0x08000045,0x20000000,0x00000000},0x1f70,0,1288},
+ {{0x08000045,0x00020000,0x00000000},0x1f71,0,1288},
+ {{0x08800005,0x20000000,0x00000000},0x1f74,0,1288},
+ {{0x08800005,0x00020000,0x00000000},0x1f75,0,1288},
+ {{0x08000005,0x20000008,0x00000000},0x1f76,0,1288},
+ {{0x08000005,0x00020008,0x00000000},0x1f77,0,1288},
+ {{0x08000005,0x30000000,0x00000000},0x1f7a,0,1288},
+ {{0x08000005,0x10020000,0x00000000},0x1f7b,0,1288},
+ {{0x08000005,0x20008000,0x00000000},0x1f7c,0,1288},
+ {{0x08000005,0x00028000,0x00000000},0x1f7d,0,1288},
+ {{0x08000045,0x00000400,0x00000000},0x1fb1,0,1288},
+ {{0x08000045,0x00080000,0x00000000},0x1fb6,0,1288},
+ {{0x08000043,0x00000400,0x00000000},0x1fb9,0,1288},
+ {{0x08000043,0x20000000,0x00000000},0x1fba,0,1288},
+ {{0x08000043,0x00020000,0x00000000},0x1fbb,0,1288},
+ {{0x08000043,0x00100000,0x00000000},0x1fbc,0,1288},
+ {{0x08800005,0x00080000,0x00000000},0x1fc6,0,1288},
+ {{0x08800003,0x20000000,0x00000000},0x1fca,0,1288},
+ {{0x08800003,0x00020000,0x00000000},0x1fcb,0,1288},
+ {{0x08800003,0x00100000,0x00000000},0x1fcc,0,1288},
+ {{0x08000005,0x00000408,0x00000000},0x1fd1,0,1288},
+ {{0x08000005,0x00080008,0x00000000},0x1fd6,0,1288},
+ {{0x08000003,0x00000408,0x00000000},0x1fd9,0,1288},
+ {{0x08000003,0x20000008,0x00000000},0x1fda,0,1288},
+ {{0x08000003,0x00020008,0x00000000},0x1fdb,0,1288},
+ {{0x08000005,0x10000400,0x00000000},0x1fe1,0,1288},
+ {{0x08000005,0x10080000,0x00000000},0x1fe6,0,1288},
+ {{0x08000003,0x10000400,0x00000000},0x1fe9,0,1288},
+ {{0x08000003,0x30000000,0x00000000},0x1fea,0,1288},
+ {{0x08000003,0x10020000,0x00000000},0x1feb,0,1288},
+ {{0x08000005,0x00088000,0x00000000},0x1ff6,0,1288},
+ {{0x08000003,0x20008000,0x00000000},0x1ffa,0,1288},
+ {{0x08000003,0x00028000,0x00000000},0x1ffb,0,1288},
+ {{0x08000003,0x00108000,0x00000000},0x1ffc,0,1288},
+ {{0x00000000,0x04400880,0x00000000},0x200e,0,1288},
+ {{0x00000000,0x04400880,0x00000000},0x200f,0,1288},
+ {{0x00000004,0x00814000,0x00000000},0x2170,0,1288},
+ {{0x00100000,0x00400080,0x00002000},0x21d4,0,1288},
+ {{0x00400400,0x00000101,0x00000000},0x2500,0,1288},
+ {{0x10400400,0x00000001,0x00000000},0x2501,0,1288},
+ {{0x00400400,0x40000100,0x00000000},0x2502,0,1288},
+ {{0x10400400,0x40000000,0x00000000},0x2503,0,1288},
+ {{0x00500400,0x00000001,0x00000000},0x2550,0,1288},
+ {{0x00500400,0x40000000,0x00000000},0x2551,0,1288},
+ {{0x08000045,0x20200000,0x00000000},0x1f02,0,1288},
+ {{0x08020045,0x20000000,0x00000000},0x1f03,0,1288},
+ {{0x08000045,0x00220000,0x00000000},0x1f04,0,1288},
+ {{0x08020045,0x00020000,0x00000000},0x1f05,0,1288},
+ {{0x08000045,0x00280000,0x00000000},0x1f06,0,1288},
+ {{0x08020045,0x00080000,0x00000000},0x1f07,0,1288},
+ {{0x08000043,0x20200000,0x00000000},0x1f0a,0,1288},
+ {{0x08020043,0x20000000,0x00000000},0x1f0b,0,1288},
+ {{0x08000043,0x00220000,0x00000000},0x1f0c,0,1288},
+ {{0x08020043,0x00020000,0x00000000},0x1f0d,0,1288},
+ {{0x08000043,0x00280000,0x00000000},0x1f0e,0,1288},
+ {{0x08020043,0x00080000,0x00000000},0x1f0f,0,1288},
+ {{0x08800005,0x20200000,0x00000000},0x1f22,0,1288},
+ {{0x08820005,0x20000000,0x00000000},0x1f23,0,1288},
+ {{0x08800005,0x00220000,0x00000000},0x1f24,0,1288},
+ {{0x08820005,0x00020000,0x00000000},0x1f25,0,1288},
+ {{0x08800005,0x00280000,0x00000000},0x1f26,0,1288},
+ {{0x08820005,0x00080000,0x00000000},0x1f27,0,1288},
+ {{0x08800003,0x20200000,0x00000000},0x1f2a,0,1288},
+ {{0x08820003,0x20000000,0x00000000},0x1f2b,0,1288},
+ {{0x08800003,0x00220000,0x00000000},0x1f2c,0,1288},
+ {{0x08820003,0x00020000,0x00000000},0x1f2d,0,1288},
+ {{0x08800003,0x00280000,0x00000000},0x1f2e,0,1288},
+ {{0x08820003,0x00080000,0x00000000},0x1f2f,0,1288},
+ {{0x08000005,0x20200008,0x00000000},0x1f32,0,1288},
+ {{0x08020005,0x20000008,0x00000000},0x1f33,0,1288},
+ {{0x08000005,0x00220008,0x00000000},0x1f34,0,1288},
+ {{0x08020005,0x00020008,0x00000000},0x1f35,0,1288},
+ {{0x08000005,0x00280008,0x00000000},0x1f36,0,1288},
+ {{0x08020005,0x00080008,0x00000000},0x1f37,0,1288},
+ {{0x08000003,0x20200008,0x00000000},0x1f3a,0,1288},
+ {{0x08020003,0x20000008,0x00000000},0x1f3b,0,1288},
+ {{0x08000003,0x00220008,0x00000000},0x1f3c,0,1288},
+ {{0x08020003,0x00020008,0x00000000},0x1f3d,0,1288},
+ {{0x08000003,0x00280008,0x00000000},0x1f3e,0,1288},
+ {{0x08020003,0x00080008,0x00000000},0x1f3f,0,1288},
+ {{0x08000005,0x30200000,0x00000000},0x1f52,0,1288},
+ {{0x08020005,0x30000000,0x00000000},0x1f53,0,1288},
+ {{0x08000005,0x10220000,0x00000000},0x1f54,0,1288},
+ {{0x08020005,0x10020000,0x00000000},0x1f55,0,1288},
+ {{0x08000005,0x10280000,0x00000000},0x1f56,0,1288},
+ {{0x08020005,0x10080000,0x00000000},0x1f57,0,1288},
+ {{0x08020003,0x30000000,0x00000000},0x1f5b,0,1288},
+ {{0x08020003,0x10020000,0x00000000},0x1f5d,0,1288},
+ {{0x08020003,0x10080000,0x00000000},0x1f5f,0,1288},
+ {{0x08000005,0x20208000,0x00000000},0x1f62,0,1288},
+ {{0x08020005,0x20008000,0x00000000},0x1f63,0,1288},
+ {{0x08000005,0x00228000,0x00000000},0x1f64,0,1288},
+ {{0x08020005,0x00028000,0x00000000},0x1f65,0,1288},
+ {{0x08000005,0x00288000,0x00000000},0x1f66,0,1288},
+ {{0x08020005,0x00088000,0x00000000},0x1f67,0,1288},
+ {{0x08000003,0x20208000,0x00000000},0x1f6a,0,1288},
+ {{0x08020003,0x20008000,0x00000000},0x1f6b,0,1288},
+ {{0x08000003,0x00228000,0x00000000},0x1f6c,0,1288},
+ {{0x08020003,0x00028000,0x00000000},0x1f6d,0,1288},
+ {{0x08000003,0x00288000,0x00000000},0x1f6e,0,1288},
+ {{0x08020003,0x00088000,0x00000000},0x1f6f,0,1288},
+ {{0x08000043,0x00300000,0x00000000},0x1f88,0,1288},
+ {{0x08020043,0x00100000,0x00000000},0x1f89,0,1288},
+ {{0x08800003,0x00300000,0x00000000},0x1f98,0,1288},
+ {{0x08820003,0x00100000,0x00000000},0x1f99,0,1288},
+ {{0x08000003,0x00308000,0x00000000},0x1fa8,0,1288},
+ {{0x08020003,0x00108000,0x00000000},0x1fa9,0,1288},
+ {{0x00600401,0x00400100,0x00000000},0x250c,0,1288},
+ {{0x10600401,0x00400000,0x00000000},0x250f,0,1288},
+ {{0x00600401,0x00000180,0x00000000},0x2510,0,1288},
+ {{0x10600401,0x00000080,0x00000000},0x2513,0,1288},
+ {{0x00400401,0x08400100,0x00000000},0x2514,0,1288},
+ {{0x10400401,0x08400000,0x00000000},0x2517,0,1288},
+ {{0x00400401,0x08000180,0x00000000},0x2518,0,1288},
+ {{0x10400401,0x08000080,0x00000000},0x251b,0,1288},
+ {{0x00400401,0x40400100,0x00000000},0x251c,0,1288},
+ {{0x10400401,0x40400000,0x00000000},0x2523,0,1288},
+ {{0x00400401,0x40000180,0x00000000},0x2524,0,1288},
+ {{0x10400401,0x40000080,0x00000000},0x252b,0,1288},
+ {{0x00600401,0x00000101,0x00000000},0x252c,0,1288},
+ {{0x10600401,0x00000001,0x00000000},0x2533,0,1288},
+ {{0x00400401,0x08000101,0x00000000},0x2534,0,1288},
+ {{0x10400401,0x08000001,0x00000000},0x253b,0,1288},
+ {{0x00400401,0x40000101,0x00000000},0x253c,0,1288},
+ {{0x10400401,0x40000001,0x00000000},0x254b,0,1288},
+ {{0x00700401,0x00400000,0x00000000},0x2554,0,1288},
+ {{0x00700401,0x00000080,0x00000000},0x2557,0,1288},
+ {{0x00500401,0x08400000,0x00000000},0x255a,0,1288},
+ {{0x00500401,0x08000080,0x00000000},0x255d,0,1288},
+ {{0x00500401,0x40400000,0x00000000},0x2560,0,1288},
+ {{0x00500401,0x40000080,0x00000000},0x2563,0,1288},
+ {{0x00700401,0x00000001,0x00000000},0x2566,0,1288},
+ {{0x00500401,0x08000001,0x00000000},0x2569,0,1288},
+ {{0x00500401,0x40000001,0x00000000},0x256c,0,1288},
+ {{0x08000043,0x20300000,0x00000000},0x1f8a,0,1288},
+ {{0x08020043,0x20100000,0x00000000},0x1f8b,0,1288},
+ {{0x08000043,0x00320000,0x00000000},0x1f8c,0,1288},
+ {{0x08020043,0x00120000,0x00000000},0x1f8d,0,1288},
+ {{0x08000043,0x00380000,0x00000000},0x1f8e,0,1288},
+ {{0x08020043,0x00180000,0x00000000},0x1f8f,0,1288},
+ {{0x08800003,0x20300000,0x00000000},0x1f9a,0,1288},
+ {{0x08820003,0x20100000,0x00000000},0x1f9b,0,1288},
+ {{0x08800003,0x00320000,0x00000000},0x1f9c,0,1288},
+ {{0x08820003,0x00120000,0x00000000},0x1f9d,0,1288},
+ {{0x08800003,0x00380000,0x00000000},0x1f9e,0,1288},
+ {{0x08820003,0x00180000,0x00000000},0x1f9f,0,1288},
+ {{0x08000003,0x20308000,0x00000000},0x1faa,0,1288},
+ {{0x08020003,0x20108000,0x00000000},0x1fab,0,1288},
+ {{0x08000003,0x00328000,0x00000000},0x1fac,0,1288},
+ {{0x08020003,0x00128000,0x00000000},0x1fad,0,1288},
+ {{0x08000003,0x00388000,0x00000000},0x1fae,0,1288},
+ {{0x08020003,0x00188000,0x00000000},0x1faf,0,1288},
+ {{0x10600401,0x00400100,0x00000000},0x250d,0,1288},
+ {{0x10600401,0x00400100,0x00000000},0x250e,0,1288},
+ {{0x10600401,0x00000180,0x00000000},0x2511,0,1288},
+ {{0x10600401,0x00000180,0x00000000},0x2512,0,1288},
+ {{0x10400401,0x08400100,0x00000000},0x2515,0,1288},
+ {{0x10400401,0x08400100,0x00000000},0x2516,0,1288},
+ {{0x10400401,0x08000180,0x00000000},0x2519,0,1288},
+ {{0x10400401,0x08000180,0x00000000},0x251a,0,1288},
+ {{0x10400401,0x40400100,0x00000000},0x251d,0,1288},
+ {{0x10400401,0x40400100,0x00000000},0x2520,0,1288},
+ {{0x10400401,0x40000180,0x00000000},0x2525,0,1288},
+ {{0x10400401,0x40000180,0x00000000},0x2528,0,1288},
+ {{0x10600401,0x00000101,0x00000000},0x252f,0,1288},
+ {{0x10600401,0x00000101,0x00000000},0x2530,0,1288},
+ {{0x10400401,0x08000101,0x00000000},0x2537,0,1288},
+ {{0x10400401,0x08000101,0x00000000},0x2538,0,1288},
+ {{0x10400401,0x40000101,0x00000000},0x253f,0,1288},
+ {{0x10400401,0x40000101,0x00000000},0x2542,0,1288},
+ {{0x00700401,0x01400000,0x00000000},0x2552,0,1288},
+ {{0x00700401,0x01400000,0x00000000},0x2553,0,1288},
+ {{0x00700401,0x01000080,0x00000000},0x2555,0,1288},
+ {{0x00700401,0x01000080,0x00000000},0x2556,0,1288},
+ {{0x00500401,0x09400000,0x00000000},0x2558,0,1288},
+ {{0x00500401,0x09400000,0x00000000},0x2559,0,1288},
+ {{0x00500401,0x09000080,0x00000000},0x255b,0,1288},
+ {{0x00500401,0x09000080,0x00000000},0x255c,0,1288},
+ {{0x00500401,0x41400000,0x00000000},0x255e,0,1288},
+ {{0x00500401,0x41400000,0x00000000},0x255f,0,1288},
+ {{0x00500401,0x41000080,0x00000000},0x2561,0,1288},
+ {{0x00500401,0x41000080,0x00000000},0x2562,0,1288},
+ {{0x00700401,0x01000001,0x00000000},0x2564,0,1288},
+ {{0x00700401,0x01000001,0x00000000},0x2565,0,1288},
+ {{0x00500401,0x09000001,0x00000000},0x2567,0,1288},
+ {{0x00500401,0x09000001,0x00000000},0x2568,0,1288},
+ {{0x00500401,0x41000001,0x00000000},0x256a,0,1288},
+ {{0x00500401,0x41000001,0x00000000},0x256b,0,1288},
+ {{0x10600401,0x08400100,0x00000000},0x251e,0,1288},
+ {{0x10600401,0x08400100,0x00000000},0x251f,0,1288},
+ {{0x10600401,0x08400100,0x00000000},0x2521,0,1288},
+ {{0x10600401,0x08400100,0x00000000},0x2522,0,1288},
+ {{0x10600401,0x08000180,0x00000000},0x2526,0,1288},
+ {{0x10600401,0x08000180,0x00000000},0x2527,0,1288},
+ {{0x10600401,0x08000180,0x00000000},0x2529,0,1288},
+ {{0x10600401,0x08000180,0x00000000},0x252a,0,1288},
+ {{0x10600401,0x00400180,0x00000000},0x252d,0,1288},
+ {{0x10600401,0x00400180,0x00000000},0x252e,0,1288},
+ {{0x10600401,0x00400180,0x00000000},0x2531,0,1288},
+ {{0x10600401,0x00400180,0x00000000},0x2532,0,1288},
+ {{0x10400401,0x08400180,0x00000000},0x2535,0,1288},
+ {{0x10400401,0x08400180,0x00000000},0x2536,0,1288},
+ {{0x10400401,0x08400180,0x00000000},0x2539,0,1288},
+ {{0x10400401,0x08400180,0x00000000},0x253a,0,1288},
+ {{0x10400401,0x40400180,0x00000000},0x253d,0,1288},
+ {{0x10400401,0x40400180,0x00000000},0x253e,0,1288},
+ {{0x10600401,0x08000101,0x00000000},0x2540,0,1288},
+ {{0x10600401,0x08000101,0x00000000},0x2541,0,1288},
+ {{0x10600401,0x08000101,0x00000000},0x2547,0,1288},
+ {{0x10600401,0x08000101,0x00000000},0x2548,0,1288},
+ {{0x10400401,0x40400180,0x00000000},0x2549,0,1288},
+ {{0x10400401,0x40400180,0x00000000},0x254a,0,1288},
+ {{0x10600401,0x08400180,0x00000000},0x2543,0,1288},
+ {{0x10600401,0x08400180,0x00000000},0x2544,0,1288},
+ {{0x10600401,0x08400180,0x00000000},0x2545,0,1288},
+ {{0x10600401,0x08400180,0x00000000},0x2546,0,1288},
+ {{0x00000000,0x00000000,0x00000000},0x2198,1,3955},
+ {{0x00000000,0x00000000,0x00000000},0x1fef,1,2787},
+ {{0x00000000,0x00000000,0x00000000},0x203c,1,3237},
+ {{0x00000000,0x00000000,0x00000000},0x2016,1,2917},
+ {{0x00000000,0x00000000,0x00000000},0x1fed,1,2781},
+ {{0x00000000,0x00000000,0x00000000},0x226e,1,4568},
+ {{0x00000000,0x00000000,0x00000000},0x2260,1,4508},
+ {{0x00000000,0x00000000,0x00000000},0x226f,1,4583},
+ {{0x00000000,0x00000000,0x00000000},0x0301,1,560},
+ {{0x00000000,0x00000000,0x00000000},0x064c,1,1587},
+ {{0x00000000,0x00000000,0x00000000},0x309b,1,6688},
+ {{0x00000000,0x00000000,0x00000000},0x201c,1,2977},
+ {{0x00000000,0x00000000,0x00000000},0x20d1,1,3370},
+ {{0x00000000,0x00000000,0x00000000},0x201d,1,2980},
+ {{0x00000000,0x00000000,0x00000000},0x0300,1,557},
+ {{0x00000000,0x00000000,0x00000000},0x042c,1,1100},
+ {{0x00000000,0x00000000,0x00000000},0x044c,1,1118},
+ {{0x00000000,0x00000000,0x00000000},0x2030,1,3132},
+ {{0x00000000,0x00000000,0x00000000},0x066a,1,1678},
+ {{0x00000000,0x00000000,0x00000000},0x02dd,1,537},
+ {{0x00000000,0x00000000,0x00000000},0x0385,1,608},
+ {{0x00000000,0x00000000,0x00000000},0x02d8,1,522},
+ {{0x00000000,0x00000000,0x00000000},0x0384,1,595},
+ {{0x00000000,0x00000000,0x00000000},0x064f,1,1617},
+ {{0x00000000,0x00000000,0x00000000},0x203e,1,3250},
+ {{0x00000000,0x00000000,0x00000000},0x02d9,1,525},
+ {{0x00000000,0x00000000,0x00000000},0x02da,1,528},
+ {{0x00000000,0x00000000,0x00000000},0x2018,1,2923},
+ {{0x00000000,0x00000000,0x00000000},0x2019,1,2926},
+ {{0x00000000,0x00000000,0x00000000},0x02db,1,531},
+ {{0x00000000,0x00000000,0x00000000},0x02c7,1,504},
+ {{0x00000000,0x00000000,0x00000000},0x0374,1,563},
+ {{0x00000000,0x00000000,0x00000000},0x0149,1,150},
+ {{0x00000000,0x00000000,0x00000000},0x3010,1,6462},
+ {{0x00000000,0x00000000,0x00000000},0x3014,1,6501},
+ {{0x00000000,0x00000000,0x00000000},0x2208,1,4112},
+ {{0x00000000,0x00000000,0x00000000},0x2474,1,5047},
+ {{0x00000000,0x00000000,0x00000000},0x247d,1,5083},
+ {{0x00000000,0x00000000,0x00000000},0x247e,1,5088},
+ {{0x00000000,0x00000000,0x00000000},0x247f,1,5093},
+ {{0x00000000,0x00000000,0x00000000},0x2480,1,5098},
+ {{0x00000000,0x00000000,0x00000000},0x2481,1,5103},
+ {{0x00000000,0x00000000,0x00000000},0x2482,1,5108},
+ {{0x00000000,0x00000000,0x00000000},0x2483,1,5113},
+ {{0x00000000,0x00000000,0x00000000},0x2484,1,5118},
+ {{0x00000000,0x00000000,0x00000000},0x2485,1,5123},
+ {{0x00000000,0x00000000,0x00000000},0x2486,1,5128},
+ {{0x00000000,0x00000000,0x00000000},0x2475,1,5051},
+ {{0x00000000,0x00000000,0x00000000},0x2487,1,5133},
+ {{0x00000000,0x00000000,0x00000000},0x2476,1,5055},
+ {{0x00000000,0x00000000,0x00000000},0x2477,1,5059},
+ {{0x00000000,0x00000000,0x00000000},0x2478,1,5063},
+ {{0x00000000,0x00000000,0x00000000},0x2479,1,5067},
+ {{0x00000000,0x00000000,0x00000000},0x247a,1,5071},
+ {{0x00000000,0x00000000,0x00000000},0x247b,1,5075},
+ {{0x00000000,0x00000000,0x00000000},0x247c,1,5079},
+ {{0x00000000,0x00000000,0x00000000},0x2286,1,4608},
+ {{0x00000000,0x00000000,0x00000000},0x2312,1,4689},
+ {{0x00000000,0x00000000,0x00000000},0x249c,1,5209},
+ {{0x00000000,0x00000000,0x00000000},0x249d,1,5213},
+ {{0x00000000,0x00000000,0x00000000},0x2282,1,4593},
+ {{0x00000000,0x00000000,0x00000000},0x249e,1,5217},
+ {{0x00000000,0x00000000,0x00000000},0x249f,1,5221},
+ {{0x00000000,0x00000000,0x00000000},0x24a0,1,5225},
+ {{0x00000000,0x00000000,0x00000000},0x24a1,1,5229},
+ {{0x00000000,0x00000000,0x00000000},0x24a2,1,5233},
+ {{0x00000000,0x00000000,0x00000000},0x24a3,1,5237},
+ {{0x00000000,0x00000000,0x00000000},0x3016,1,6507},
+ {{0x00000000,0x00000000,0x00000000},0x24a4,1,5241},
+ {{0x00000000,0x00000000,0x00000000},0x24a5,1,5245},
+ {{0x00000000,0x00000000,0x00000000},0x321c,1,6897},
+ {{0x00000000,0x00000000,0x00000000},0x24a6,1,5249},
+ {{0x00000000,0x00000000,0x00000000},0x24a7,1,5253},
+ {{0x00000000,0x00000000,0x00000000},0x24a8,1,5257},
+ {{0x00000000,0x00000000,0x00000000},0x24a9,1,5261},
+ {{0x00000000,0x00000000,0x00000000},0x24aa,1,5265},
+ {{0x00000000,0x00000000,0x00000000},0x24ab,1,5269},
+ {{0x00000000,0x00000000,0x00000000},0x24ac,1,5273},
+ {{0x00000000,0x00000000,0x00000000},0x24ad,1,5277},
+ {{0x00000000,0x00000000,0x00000000},0x207d,1,3309},
+ {{0x00000000,0x00000000,0x00000000},0x208d,1,3309},
+ {{0x00000000,0x00000000,0x00000000},0x24ae,1,5281},
+ {{0x00000000,0x00000000,0x00000000},0x24af,1,5285},
+ {{0x00000000,0x00000000,0x00000000},0x2229,1,4332},
+ {{0x00000000,0x00000000,0x00000000},0x24b0,1,5289},
+ {{0x00000000,0x00000000,0x00000000},0x24b1,1,5293},
+ {{0x00000000,0x00000000,0x00000000},0x24b2,1,5297},
+ {{0x00000000,0x00000000,0x00000000},0x24b3,1,5301},
+ {{0x00000000,0x00000000,0x00000000},0x24b4,1,5305},
+ {{0x00000000,0x00000000,0x00000000},0x24b5,1,5309},
+ {{0x00000000,0x00000000,0x00000000},0x3011,1,6465},
+ {{0x00000000,0x00000000,0x00000000},0x3015,1,6504},
+ {{0x00000000,0x00000000,0x00000000},0x1fbd,1,2661},
+ {{0x00000000,0x00000000,0x00000000},0x2287,1,4611},
+ {{0x00000000,0x00000000,0x00000000},0x2283,1,4605},
+ {{0x00000000,0x00000000,0x00000000},0x3017,1,6510},
+ {{0x00000000,0x00000000,0x00000000},0x207e,1,3312},
+ {{0x00000000,0x00000000,0x00000000},0x208e,1,3312},
+ {{0x00000000,0x00000000,0x00000000},0x222a,1,4341},
+ {{0x00000000,0x00000000,0x00000000},0x2217,1,4220},
+ {{0x00000000,0x00000000,0x00000000},0x2606,1,6049},
+ {{0x00000000,0x00000000,0x00000000},0x2605,1,6046},
+ {{0x00000000,0x00000000,0x00000000},0x309d,1,6712},
+ {{0x00000000,0x00000000,0x00000000},0x30fd,1,6784},
+ {{0x00000000,0x00000000,0x00000000},0x226b,1,4556},
+ {{0x00000000,0x00000000,0x00000000},0x3005,1,6409},
+ {{0x00000000,0x00000000,0x00000000},0x220f,1,4160},
+ {{0x00000000,0x00000000,0x00000000},0x03c2,1,818},
+ {{0x00000000,0x00000000,0x00000000},0x3003,1,6356},
+ {{0x00000000,0x00000000,0x00000000},0x0640,1,1515},
+ {{0x00000000,0x00000000,0x00000000},0x309e,1,6732},
+ {{0x00000000,0x00000000,0x00000000},0x30fe,1,6787},
+ {{0x00000000,0x00000000,0x00000000},0x207a,1,3294},
+ {{0x00000000,0x00000000,0x00000000},0x208a,1,3294},
+ {{0x00000000,0x00000000,0x00000000},0x2211,1,4179},
+ {{0x00000000,0x00000000,0x00000000},0x1fcd,1,2701},
+ {{0x00000000,0x00000000,0x00000000},0x1fce,1,2704},
+ {{0x00000000,0x00000000,0x00000000},0x060c,1,1330},
+ {{0x00000000,0x00000000,0x00000000},0x1fbf,1,2664},
+ {{0x00000000,0x00000000,0x00000000},0x3001,1,6344},
+ {{0x00000000,0x00000000,0x00000000},0x0375,1,572},
+ {{0x00000000,0x00000000,0x00000000},0x2191,1,3878},
+ {{0x00000000,0x00000000,0x00000000},0x220b,1,4134},
+ {{0x00000000,0x00000000,0x00000000},0x2213,1,4196},
+ {{0x00000000,0x00000000,0x00000000},0x2212,1,4182},
+ {{0x00000000,0x00000000,0x00000000},0x2015,1,2914},
+ {{0x00000000,0x00000000,0x00000000},0x30fc,1,6781},
+ {{0x00000000,0x00000000,0x00000000},0x2192,1,3892},
+ {{0x00000000,0x00000000,0x00000000},0x301c,1,6523},
+ {{0x00000000,0x00000000,0x00000000},0x2043,1,3267},
+ {{0x00000000,0x00000000,0x00000000},0x221f,1,4293},
+ {{0x00000000,0x00000000,0x00000000},0x2014,1,2911},
+ {{0x00000000,0x00000000,0x00000000},0x2013,1,2900},
+ {{0x00000000,0x00000000,0x00000000},0x207b,1,3303},
+ {{0x00000000,0x00000000,0x00000000},0x208b,1,3303},
+ {{0x00000000,0x00000000,0x00000000},0x22a5,1,4625},
+ {{0x00000000,0x00000000,0x00000000},0x2193,1,3905},
+ {{0x00000000,0x00000000,0x00000000},0x2220,1,3905},
+ {{0x00000000,0x00000000,0x00000000},0x2720,1,6338},
+ {{0x00000000,0x00000000,0x00000000},0x0387,1,625},
+ {{0x00000000,0x00000000,0x00000000},0x2214,1,4199},
+ {{0x00000000,0x00000000,0x00000000},0x2027,1,3074},
+ {{0x00000000,0x00000000,0x00000000},0x2025,1,3041},
+ {{0x00000000,0x00000000,0x00000000},0x2026,1,3053},
+ {{0x00000000,0x00000000,0x00000000},0x30fb,1,6762},
+ {{0x00000000,0x00000000,0x00000000},0x201a,1,2945},
+ {{0x00000000,0x00000000,0x00000000},0x2234,1,4383},
+ {{0x00000000,0x00000000,0x00000000},0x3002,1,6347},
+ {{0x00000000,0x00000000,0x00000000},0x22c5,1,4628},
+ {{0x00000000,0x00000000,0x00000000},0x2591,1,5704},
+ {{0x00000000,0x00000000,0x00000000},0x1ffd,1,2813},
+ {{0x00000000,0x00000000,0x00000000},0x064e,1,1608},
+ {{0x00000000,0x00000000,0x00000000},0x2020,1,2996},
+ {{0x00000000,0x00000000,0x00000000},0x2197,1,3940},
+ {{0x00000000,0x00000000,0x00000000},0x2205,1,4085},
+ {{0x00000000,0x00000000,0x00000000},0x2021,1,2999},
+ {{0x00000000,0x00000000,0x00000000},0x232a,1,4785},
+ {{0x00000000,0x00000000,0x00000000},0x2044,1,3270},
+ {{0x00000000,0x00000000,0x00000000},0x221d,1,4272},
+ {{0x00000000,0x00000000,0x00000000},0x0652,1,1645},
+ {{0x00000000,0x00000000,0x00000000},0x24ea,1,5417},
+ {{0x00000000,0x00000000,0x00000000},0x2299,1,4614},
+ {{0x00000000,0x00000000,0x00000000},0x221e,1,4284},
+ {{0x00000000,0x00000000,0x00000000},0x229a,1,4617},
+ {{0x00000000,0x00000000,0x00000000},0x309c,1,6709},
+ {{0x00000000,0x00000000,0x00000000},0x3007,1,6423},
+ {{0x00000000,0x00000000,0x00000000},0x0660,1,1648},
+ {{0x00000000,0x00000000,0x00000000},0x25d0,1,5969},
+ {{0x00000000,0x00000000,0x00000000},0x25cb,1,5954},
+ {{0x00000000,0x00000000,0x00000000},0x25cf,1,5954},
+ {{0x00000000,0x00000000,0x00000000},0x25ce,1,5966},
+ {{0x00000000,0x00000000,0x00000000},0x25d1,1,5972},
+ {{0x00000000,0x00000000,0x00000000},0x2070,1,3273},
+ {{0x00000000,0x00000000,0x00000000},0x2080,1,3273},
+ {{0x00000000,0x00000000,0x00000000},0x263a,1,6100},
+ {{0x00000000,0x00000000,0x00000000},0x263b,1,6100},
+ {{0x00000000,0x00000000,0x00000000},0x02cb,1,519},
+ {{0x00000000,0x00000000,0x00000000},0x2035,1,3178},
+ {{0x00000000,0x00000000,0x00000000},0x2032,1,3141},
+ {{0x00000000,0x00000000,0x00000000},0x0650,1,1626},
+ {{0x00000000,0x00000000,0x00000000},0x02c9,1,516},
+ {{0x00000000,0x00000000,0x00000000},0x2460,1,4887},
+ {{0x00000000,0x00000000,0x00000000},0x2488,1,5138},
+ {{0x00000000,0x00000000,0x00000000},0x2469,1,4923},
+ {{0x00000000,0x00000000,0x00000000},0x2491,1,5165},
+ {{0x00000000,0x00000000,0x00000000},0x2182,1,3850},
+ {{0x00000000,0x00000000,0x00000000},0x216f,1,3790},
+ {{0x00000000,0x00000000,0x00000000},0x217f,1,3790},
+ {{0x00000000,0x00000000,0x00000000},0x2180,1,3809},
+ {{0x00000000,0x00000000,0x00000000},0x216d,1,3758},
+ {{0x00000000,0x00000000,0x00000000},0x217d,1,3758},
+ {{0x00000000,0x00000000,0x00000000},0x3229,1,6929},
+ {{0x00000000,0x00000000,0x00000000},0x246a,1,4928},
+ {{0x00000000,0x00000000,0x00000000},0x2492,1,5169},
+ {{0x00000000,0x00000000,0x00000000},0x246b,1,4933},
+ {{0x00000000,0x00000000,0x00000000},0x2493,1,5173},
+ {{0x00000000,0x00000000,0x00000000},0x2153,1,3534},
+ {{0x00000000,0x00000000,0x00000000},0x246c,1,4947},
+ {{0x00000000,0x00000000,0x00000000},0x2494,1,5177},
+ {{0x00000000,0x00000000,0x00000000},0x246d,1,4961},
+ {{0x00000000,0x00000000,0x00000000},0x2495,1,5181},
+ {{0x00000000,0x00000000,0x00000000},0x2155,1,3557},
+ {{0x00000000,0x00000000,0x00000000},0x246e,1,4974},
+ {{0x00000000,0x00000000,0x00000000},0x2496,1,5185},
+ {{0x00000000,0x00000000,0x00000000},0x2159,1,3611},
+ {{0x00000000,0x00000000,0x00000000},0x246f,1,4987},
+ {{0x00000000,0x00000000,0x00000000},0x2497,1,5189},
+ {{0x00000000,0x00000000,0x00000000},0x2470,1,5002},
+ {{0x00000000,0x00000000,0x00000000},0x2498,1,5193},
+ {{0x00000000,0x00000000,0x00000000},0x215b,1,3636},
+ {{0x00000000,0x00000000,0x00000000},0x2471,1,5016},
+ {{0x00000000,0x00000000,0x00000000},0x2499,1,5197},
+ {{0x00000000,0x00000000,0x00000000},0x2472,1,5030},
+ {{0x00000000,0x00000000,0x00000000},0x249a,1,5201},
+ {{0x00000000,0x00000000,0x00000000},0x02c6,1,501},
+ {{0x00000000,0x00000000,0x00000000},0x02dc,1,534},
+ {{0x00000000,0x00000000,0x00000000},0x0661,1,1651},
+ {{0x00000000,0x00000000,0x00000000},0x3220,1,6902},
+ {{0x00000000,0x00000000,0x00000000},0x200a,1,2883},
+ {{0x00000000,0x00000000,0x00000000},0x2440,1,2883},
+ {{0x00000000,0x00000000,0x00000000},0x2446,1,4840},
+ {{0x00000000,0x00000000,0x00000000},0x2003,1,2822},
+ {{0x00000000,0x00000000,0x00000000},0x2002,1,2819},
+ {{0x00000000,0x00000000,0x00000000},0x2160,1,3689},
+ {{0x00000000,0x00000000,0x00000000},0x2170,1,3689},
+ {{0x00000000,0x00000000,0x00000000},0x2081,0,2739},
+ {{0x00000000,0x00000000,0x00000000},0x2009,1,2875},
+ {{0x00000000,0x00000000,0x00000000},0x2036,1,3181},
+ {{0x00000000,0x00000000,0x00000000},0x2033,1,3144},
+ {{0x00000000,0x00000000,0x00000000},0x2461,1,4891},
+ {{0x00000000,0x00000000,0x00000000},0x2489,1,5141},
+ {{0x00000000,0x00000000,0x00000000},0x2473,1,5042},
+ {{0x00000000,0x00000000,0x00000000},0x249b,1,5205},
+ {{0x00000000,0x00000000,0x00000000},0x2154,1,3548},
+ {{0x00000000,0x00000000,0x00000000},0x2156,1,3571},
+ {{0x00000000,0x00000000,0x00000000},0x0662,1,1654},
+ {{0x00000000,0x00000000,0x00000000},0x3221,1,6905},
+ {{0x00000000,0x00000000,0x00000000},0x2442,1,4807},
+ {{0x00000000,0x00000000,0x00000000},0x2447,1,4856},
+ {{0x00000000,0x00000000,0x00000000},0x2161,1,3692},
+ {{0x00000000,0x00000000,0x00000000},0x2171,1,3692},
+ {{0x00000000,0x00000000,0x00000000},0x2082,0,2704},
+ {{0x00000000,0x00000000,0x00000000},0x2506,1,5459},
+ {{0x00000000,0x00000000,0x00000000},0x2037,1,3206},
+ {{0x00000000,0x00000000,0x00000000},0x2034,1,3160},
+ {{0x00000000,0x00000000,0x00000000},0x0651,1,1636},
+ {{0x00000000,0x00000000,0x00000000},0xfe7d,1,6983},
+ {{0x00000000,0x00000000,0x00000000},0x2504,1,5453},
+ {{0x00000000,0x00000000,0x00000000},0x2462,1,4895},
+ {{0x00000000,0x00000000,0x00000000},0x248a,1,5144},
+ {{0x00000000,0x00000000,0x00000000},0x2507,1,5462},
+ {{0x00000000,0x00000000,0x00000000},0x2157,1,3587},
+ {{0x00000000,0x00000000,0x00000000},0x215c,1,3653},
+ {{0x00000000,0x00000000,0x00000000},0x2505,1,5456},
+ {{0x00000000,0x00000000,0x00000000},0x0663,1,1657},
+ {{0x00000000,0x00000000,0x00000000},0x2023,1,3027},
+ {{0x00000000,0x00000000,0x00000000},0x3222,1,6908},
+ {{0x00000000,0x00000000,0x00000000},0x2441,1,4799},
+ {{0x00000000,0x00000000,0x00000000},0x2448,1,4864},
+ {{0x00000000,0x00000000,0x00000000},0x2004,1,2838},
+ {{0x00000000,0x00000000,0x00000000},0x2162,1,3695},
+ {{0x00000000,0x00000000,0x00000000},0x2172,1,3695},
+ {{0x00000000,0x00000000,0x00000000},0x2083,0,2707},
+ {{0x00000000,0x00000000,0x00000000},0x250a,1,5486},
+ {{0x00000000,0x00000000,0x00000000},0x2508,1,5480},
+ {{0x00000000,0x00000000,0x00000000},0x2463,1,4899},
+ {{0x00000000,0x00000000,0x00000000},0x248b,1,5147},
+ {{0x00000000,0x00000000,0x00000000},0x250b,1,5489},
+ {{0x00000000,0x00000000,0x00000000},0x2158,1,3602},
+ {{0x00000000,0x00000000,0x00000000},0x2509,1,5483},
+ {{0x00000000,0x00000000,0x00000000},0x0664,1,1660},
+ {{0x00000000,0x00000000,0x00000000},0x3223,1,6911},
+ {{0x00000000,0x00000000,0x00000000},0x2443,1,4810},
+ {{0x00000000,0x00000000,0x00000000},0x2449,1,4884},
+ {{0x00000000,0x00000000,0x00000000},0x2005,1,2853},
+ {{0x00000000,0x00000000,0x00000000},0x2163,1,3698},
+ {{0x00000000,0x00000000,0x00000000},0x2173,1,3698},
+ {{0x00000000,0x00000000,0x00000000},0x2074,1,3276},
+ {{0x00000000,0x00000000,0x00000000},0x2084,1,3276},
+ {{0x00000000,0x00000000,0x00000000},0x2464,1,4903},
+ {{0x00000000,0x00000000,0x00000000},0x248c,1,5150},
+ {{0x00000000,0x00000000,0x00000000},0x2181,1,3831},
+ {{0x00000000,0x00000000,0x00000000},0x216e,1,3776},
+ {{0x00000000,0x00000000,0x00000000},0x217e,1,3776},
+ {{0x00000000,0x00000000,0x00000000},0x216c,1,3746},
+ {{0x00000000,0x00000000,0x00000000},0x217c,1,3746},
+ {{0x00000000,0x00000000,0x00000000},0x215a,1,3626},
+ {{0x00000000,0x00000000,0x00000000},0x215d,1,3669},
+ {{0x00000000,0x00000000,0x00000000},0x0665,1,1663},
+ {{0x00000000,0x00000000,0x00000000},0x3224,1,6914},
+ {{0x00000000,0x00000000,0x00000000},0x2164,1,3701},
+ {{0x00000000,0x00000000,0x00000000},0x2174,1,3701},
+ {{0x00000000,0x00000000,0x00000000},0x2075,1,3279},
+ {{0x00000000,0x00000000,0x00000000},0x2085,1,3279},
+ {{0x00000000,0x00000000,0x00000000},0x2465,1,4907},
+ {{0x00000000,0x00000000,0x00000000},0x248d,1,5153},
+ {{0x00000000,0x00000000,0x00000000},0x0666,1,1666},
+ {{0x00000000,0x00000000,0x00000000},0x3225,1,6917},
+ {{0x00000000,0x00000000,0x00000000},0x2006,1,2867},
+ {{0x00000000,0x00000000,0x00000000},0x2165,1,3704},
+ {{0x00000000,0x00000000,0x00000000},0x2175,1,3704},
+ {{0x00000000,0x00000000,0x00000000},0x2076,1,3282},
+ {{0x00000000,0x00000000,0x00000000},0x2086,1,3282},
+ {{0x00000000,0x00000000,0x00000000},0x2466,1,4911},
+ {{0x00000000,0x00000000,0x00000000},0x248e,1,5156},
+ {{0x00000000,0x00000000,0x00000000},0x215e,1,3686},
+ {{0x00000000,0x00000000,0x00000000},0x230a,1,4663},
+ {{0x00000000,0x00000000,0x00000000},0x230b,1,4666},
+ {{0x00000000,0x00000000,0x00000000},0x0667,1,1669},
+ {{0x00000000,0x00000000,0x00000000},0x3226,1,6920},
+ {{0x00000000,0x00000000,0x00000000},0x2166,1,3707},
+ {{0x00000000,0x00000000,0x00000000},0x2176,1,3707},
+ {{0x00000000,0x00000000,0x00000000},0x2077,1,3285},
+ {{0x00000000,0x00000000,0x00000000},0x2087,1,3285},
+ {{0x00000000,0x00000000,0x00000000},0x2467,1,4915},
+ {{0x00000000,0x00000000,0x00000000},0x248f,1,5159},
+ {{0x00000000,0x00000000,0x00000000},0x2318,1,4729},
+ {{0x00000000,0x00000000,0x00000000},0x0668,1,1672},
+ {{0x00000000,0x00000000,0x00000000},0x3227,1,6923},
+ {{0x00000000,0x00000000,0x00000000},0x2167,1,3710},
+ {{0x00000000,0x00000000,0x00000000},0x2177,1,3710},
+ {{0x00000000,0x00000000,0x00000000},0x2078,1,3288},
+ {{0x00000000,0x00000000,0x00000000},0x2088,1,3288},
+ {{0x00000000,0x00000000,0x00000000},0x201f,1,2986},
+ {{0x00000000,0x00000000,0x00000000},0x201b,1,2974},
+ {{0x00000000,0x00000000,0x00000000},0x2468,1,4919},
+ {{0x00000000,0x00000000,0x00000000},0x2490,1,5162},
+ {{0x00000000,0x00000000,0x00000000},0x0669,1,1675},
+ {{0x00000000,0x00000000,0x00000000},0x3228,1,6926},
+ {{0x00000000,0x00000000,0x00000000},0x2168,1,3713},
+ {{0x00000000,0x00000000,0x00000000},0x2178,1,3713},
+ {{0x00000000,0x00000000,0x00000000},0x2079,1,3291},
+ {{0x00000000,0x00000000,0x00000000},0x2089,1,3291},
+ {{0x00000000,0x00000000,0x00000000},0x1fee,1,2784},
+ {{0x00000000,0x00000000,0x00000000},0x064b,1,1575},
+ {{0x00000000,0x00000000,0x00000000},0x2235,1,4394},
+ {{0x00000000,0x00000000,0x00000000},0x22ee,1,4631},
+ {{0x00000000,0x00000000,0x00000000},0x201e,1,2983},
+ {{0x00000000,0x00000000,0x00000000},0x2237,1,4417},
+ {{0x00000000,0x00000000,0x00000000},0x2236,1,4403},
+ {{0x00000000,0x00000000,0x00000000},0x2592,1,5720},
+ {{0x00000000,0x00000000,0x00000000},0x203b,1,3234},
+ {{0x00000000,0x00000000,0x00000000},0x1fdd,1,2737},
+ {{0x00000000,0x00000000,0x00000000},0x1fde,1,2740},
+ {{0x00000000,0x00000000,0x00000000},0x061b,1,1333},
+ {{0x00000000,0x00000000,0x00000000},0x1ffe,1,2816},
+ {{0x00000000,0x00000000,0x00000000},0x3006,1,6420},
+ {{0x00000000,0x00000000,0x00000000},0x02bb,1,482},
+ {{0x00000000,0x00000000,0x00000000},0x2196,1,3925},
+ {{0x00000000,0x00000000,0x00000000},0x300e,1,6445},
+ {{0x00000000,0x00000000,0x00000000},0x300c,1,6439},
+ {{0x00000000,0x00000000,0x00000000},0x226a,1,4540},
+ {{0x00000000,0x00000000,0x00000000},0x300a,1,6426},
+ {{0x00000000,0x00000000,0x00000000},0x2190,1,3867},
+ {{0x00000000,0x00000000,0x00000000},0x2329,1,4782},
+ {{0x00000000,0x00000000,0x00000000},0x2199,1,3970},
+ {{0x00000000,0x00000000,0x00000000},0x2039,1,3218},
+ {{0x00000000,0x00000000,0x00000000},0x2308,1,4651},
+ {{0x00000000,0x00000000,0x00000000},0x21d0,1,4018},
+ {{0x00000000,0x00000000,0x00000000},0x2194,1,3908},
+ {{0x00000000,0x00000000,0x00000000},0x261c,1,6081},
+ {{0x00000000,0x00000000,0x00000000},0x042a,1,1084},
+ {{0x00000000,0x00000000,0x00000000},0x044a,1,1115},
+ {{0x00000000,0x00000000,0x00000000},0x064d,1,1599},
+ {{0x00000000,0x00000000,0x00000000},0x2017,1,2920},
+ {{0x00000000,0x00000000,0x00000000},0x2261,1,4521},
+ {{0x00000000,0x00000000,0x00000000},0x2264,1,4524},
+ {{0x00000000,0x00000000,0x00000000},0x21d4,1,4024},
+ {{0x00000000,0x00000000,0x00000000},0x21d2,1,4021},
+ {{0x00000000,0x00000000,0x00000000},0x224c,1,4482},
+ {{0x00000000,0x00000000,0x00000000},0x3013,1,6483},
+ {{0x00000000,0x00000000,0x00000000},0x207c,1,3306},
+ {{0x00000000,0x00000000,0x00000000},0x208c,1,3306},
+ {{0x00000000,0x00000000,0x00000000},0x3012,1,6475},
+ {{0x00000000,0x00000000,0x00000000},0x3020,1,6538},
+ {{0x00000000,0x00000000,0x00000000},0x300f,1,6448},
+ {{0x00000000,0x00000000,0x00000000},0x300d,1,6442},
+ {{0x00000000,0x00000000,0x00000000},0x300b,1,6429},
+ {{0x00000000,0x00000000,0x00000000},0x203a,1,3221},
+ {{0x00000000,0x00000000,0x00000000},0x2309,1,4654},
+ {{0x00000000,0x00000000,0x00000000},0x2265,1,4527},
+ {{0x00000000,0x00000000,0x00000000},0x261e,1,6084},
+ {{0x00000000,0x00000000,0x00000000},0x21c0,1,4015},
+ {{0x00000000,0x00000000,0x00000000},0x037e,1,592},
+ {{0x00000000,0x00000000,0x00000000},0x1fc0,1,2667},
+ {{0x00000000,0x00000000,0x00000000},0x061f,1,1336},
+ {{0x00000000,0x00000000,0x00000000},0x1fcf,1,2707},
+ {{0x00000000,0x00000000,0x00000000},0x2243,1,4448},
+ {{0x00000000,0x00000000,0x00000000},0x223c,1,4420},
+ {{0x00000000,0x00000000,0x00000000},0x2248,1,4475},
+ {{0x00000000,0x00000000,0x00000000},0x1fc1,1,2670},
+ {{0x00000000,0x00000000,0x00000000},0x1fdf,1,2743},
+ {{0x00000000,0x00000000,0x00000000},0x2245,1,4465},
+ {{0x00000000,0x00000000,0x00000000},0x2593,1,5734},
+ {{0x00000000,0x00000000,0x00000000},0x2502,1,5434},
+ {{0x00000000,0x00000000,0x00000000},0x253c,1,5601},
+ {{0x00000000,0x00000000,0x00000000},0x2524,1,5556},
+ {{0x00000000,0x00000000,0x00000000},0x251c,1,5541},
+ {{0x00000000,0x00000000,0x00000000},0x2500,1,5421},
+ {{0x00000000,0x00000000,0x00000000},0x2534,1,5586},
+ {{0x00000000,0x00000000,0x00000000},0x25e2,1,6023},
+ {{0x00000000,0x00000000,0x00000000},0x2501,1,5428},
+ {{0x00000000,0x00000000,0x00000000},0x2571,1,5649},
+ {{0x00000000,0x00000000,0x00000000},0x2518,1,5530},
+ {{0x00000000,0x00000000,0x00000000},0x2514,1,5519},
+ {{0x00000000,0x00000000,0x00000000},0x266a,1,6206},
+ {{0x00000000,0x00000000,0x00000000},0x252c,1,5571},
+ {{0x00000000,0x00000000,0x00000000},0x2510,1,5503},
+ {{0x00000000,0x00000000,0x00000000},0x250c,1,5495},
+ {{0x40000001,0x00000000,0x00000000},0x3042,0,1546},
+ {{0x00000001,0x00000020,0x00000000},0x30a2,0,1546},
+ {{0x00000201,0x00000000,0x00000000},0x311a,0,1546},
+ {{0x00010003,0x00000000,0x00000000},0x0410,0,1546},
+ {{0x00010005,0x00000000,0x00000000},0x0430,0,1546},
+ {{0x40000005,0x00000000,0x00000000},0x3041,0,1546},
+ {{0x00000005,0x00000020,0x00000000},0x30a1,0,1546},
+ {{0x00000003,0x00000440,0x00000000},0x0100,0,1546},
+ {{0x00000005,0x00000440,0x00000000},0x0101,0,1546},
+ {{0x00000803,0x00000040,0x00000000},0x0102,0,1546},
+ {{0x00000805,0x00000040,0x00000000},0x0103,0,1546},
+ {{0x00000003,0x00000040,0x02000000},0x0104,0,1546},
+ {{0x00000005,0x00000040,0x02000000},0x0105,0,1546},
+ {{0x00001003,0x00000040,0x00000000},0x01cd,0,1546},
+ {{0x00001005,0x00000040,0x00000000},0x01ce,0,1546},
+ {{0x00000005,0x00040040,0x00000000},0x249c,0,1546},
+ {{0x00004003,0x00000040,0x00000000},0x24b6,0,1546},
+ {{0x00004005,0x00000040,0x00000000},0x24d0,0,1546},
+ {{0x00040003,0x00000440,0x00000000},0x01de,0,1546},
+ {{0x00040005,0x00000440,0x00000000},0x01df,0,1546},
+ {{0x04100003,0x00000040,0x00000000},0x0200,0,1546},
+ {{0x04100005,0x00000040,0x00000000},0x0201,0,1546},
+ {{0x00000803,0x00000040,0x00800000},0x0202,0,1546},
+ {{0x00000805,0x00000040,0x00800000},0x0203,0,1546},
+ {{0x00000103,0x00000040,0x04000000},0x1e00,0,1546},
+ {{0x00000105,0x00000040,0x04000000},0x1e01,0,1546},
+ {{0x00080103,0x00000040,0x00000000},0x1ea0,0,1546},
+ {{0x00080105,0x00000040,0x00000000},0x1ea1,0,1546},
+ {{0x8000000b,0x00000040,0x00000000},0x1ea2,0,1546},
+ {{0x8000000d,0x00000040,0x00000000},0x1ea3,0,1546},
+ {{0x00008013,0x00000040,0x00000000},0x1ea4,0,1546},
+ {{0x00008015,0x00000040,0x00000000},0x1ea5,0,1546},
+ {{0x04008003,0x00000040,0x00000000},0x1ea6,0,1546},
+ {{0x04008005,0x00000040,0x00000000},0x1ea7,0,1546},
+ {{0x00008003,0x02000040,0x00000000},0x1eaa,0,1546},
+ {{0x00008005,0x02000040,0x00000000},0x1eab,0,1546},
+ {{0x00000813,0x00000040,0x00000000},0x1eae,0,1546},
+ {{0x00000815,0x00000040,0x00000000},0x1eaf,0,1546},
+ {{0x04000803,0x00000040,0x00000000},0x1eb0,0,1546},
+ {{0x04000805,0x00000040,0x00000000},0x1eb1,0,1546},
+ {{0x00000803,0x02000040,0x00000000},0x1eb4,0,1546},
+ {{0x00000805,0x02000040,0x00000000},0x1eb5,0,1546},
+ {{0x0008000b,0x00000440,0x00000000},0x01e0,0,1546},
+ {{0x0008000d,0x00000440,0x00000000},0x01e1,0,1546},
+ {{0x0000001b,0x00000040,0x04000000},0x01fa,0,1546},
+ {{0x0000001d,0x00000040,0x04000000},0x01fb,0,1546},
+ {{0x8000800b,0x00000040,0x00000000},0x1ea8,0,1546},
+ {{0x8000800d,0x00000040,0x00000000},0x1ea9,0,1546},
+ {{0x00088103,0x00000040,0x00000000},0x1eac,0,1546},
+ {{0x00088105,0x00000040,0x00000000},0x1ead,0,1546},
+ {{0x8000080b,0x00000040,0x00000000},0x1eb2,0,1546},
+ {{0x8000080d,0x00000040,0x00000000},0x1eb3,0,1546},
+ {{0x00080903,0x00000040,0x00000000},0x1eb6,0,1546},
+ {{0x00080905,0x00000040,0x00000000},0x1eb7,0,1546},
+ {{0x00000000,0x00000000,0x00000000},0x24b6,1,5313},
+ {{0x00000000,0x00000000,0x00000000},0x24d0,1,5313},
+ {{0x00000000,0x00000000,0x00000000},0x0200,1,404},
+ {{0x00000000,0x00000000,0x00000000},0x0201,1,404},
+ {{0x00000000,0x00000000,0x00000000},0x0386,1,611},
+ {{0x00000000,0x00000000,0x00000000},0x03ac,1,611},
+ {{0x00000000,0x00000000,0x00000000},0x0102,1,3},
+ {{0x00000000,0x00000000,0x00000000},0x0103,1,3},
+ {{0x00000000,0x00000000,0x00000000},0x1eb0,1,2030},
+ {{0x00000000,0x00000000,0x00000000},0x1eb1,1,2030},
+ {{0x00000000,0x00000000,0x00000000},0x1eae,1,2026},
+ {{0x00000000,0x00000000,0x00000000},0x1eaf,1,2026},
+ {{0x00000000,0x00000000,0x00000000},0x1eb6,1,2042},
+ {{0x00000000,0x00000000,0x00000000},0x1eb7,1,2042},
+ {{0x00000000,0x00000000,0x00000000},0x1eb2,1,2034},
+ {{0x00000000,0x00000000,0x00000000},0x1eb3,1,2034},
+ {{0x00000000,0x00000000,0x00000000},0x1eb4,1,2038},
+ {{0x00000000,0x00000000,0x00000000},0x1eb5,1,2038},
+ {{0x00000000,0x00000000,0x00000000},0x0202,1,408},
+ {{0x00000000,0x00000000,0x00000000},0x0203,1,408},
+ {{0x00000000,0x00000000,0x00000000},0x0391,1,665},
+ {{0x00000000,0x00000000,0x00000000},0x03b1,1,665},
+ {{0x00000000,0x00000000,0x00000000},0x1f70,1,2421},
+ {{0x00000000,0x00000000,0x00000000},0x1fba,1,2421},
+ {{0x00000000,0x00000000,0x00000000},0x1fb2,1,2630},
+ {{0x00000000,0x00000000,0x00000000},0x1f71,1,2425},
+ {{0x00000000,0x00000000,0x00000000},0x1fbb,1,2425},
+ {{0x00000000,0x00000000,0x00000000},0x1fb4,1,2639},
+ {{0x00000000,0x00000000,0x00000000},0x1fb0,1,2622},
+ {{0x00000000,0x00000000,0x00000000},0x1fb8,1,2622},
+ {{0x00000000,0x00000000,0x00000000},0x1f00,1,2175},
+ {{0x00000000,0x00000000,0x00000000},0x1f08,1,2175},
+ {{0x00000000,0x00000000,0x00000000},0x1f02,1,2183},
+ {{0x00000000,0x00000000,0x00000000},0x1f0a,1,2183},
+ {{0x00000000,0x00000000,0x00000000},0x1f82,1,2487},
+ {{0x00000000,0x00000000,0x00000000},0x1f8a,1,2487},
+ {{0x00000000,0x00000000,0x00000000},0x1f04,1,2193},
+ {{0x00000000,0x00000000,0x00000000},0x1f0c,1,2193},
+ {{0x00000000,0x00000000,0x00000000},0x1f84,1,2499},
+ {{0x00000000,0x00000000,0x00000000},0x1f8c,1,2499},
+ {{0x00000000,0x00000000,0x00000000},0x1f06,1,2203},
+ {{0x00000000,0x00000000,0x00000000},0x1f0e,1,2203},
+ {{0x00000000,0x00000000,0x00000000},0x1f86,1,2511},
+ {{0x00000000,0x00000000,0x00000000},0x1f8e,1,2511},
+ {{0x00000000,0x00000000,0x00000000},0x1f80,1,2477},
+ {{0x00000000,0x00000000,0x00000000},0x1f88,1,2477},
+ {{0x00000000,0x00000000,0x00000000},0x1fb1,1,2626},
+ {{0x00000000,0x00000000,0x00000000},0x1fb9,1,2626},
+ {{0x00000000,0x00000000,0x00000000},0x1f01,1,2179},
+ {{0x00000000,0x00000000,0x00000000},0x1f09,1,2179},
+ {{0x00000000,0x00000000,0x00000000},0x1f03,1,2188},
+ {{0x00000000,0x00000000,0x00000000},0x1f0b,1,2188},
+ {{0x00000000,0x00000000,0x00000000},0x1f83,1,2493},
+ {{0x00000000,0x00000000,0x00000000},0x1f8b,1,2493},
+ {{0x00000000,0x00000000,0x00000000},0x1f05,1,2198},
+ {{0x00000000,0x00000000,0x00000000},0x1f0d,1,2198},
+ {{0x00000000,0x00000000,0x00000000},0x1f85,1,2505},
+ {{0x00000000,0x00000000,0x00000000},0x1f8d,1,2505},
+ {{0x00000000,0x00000000,0x00000000},0x1f07,1,2208},
+ {{0x00000000,0x00000000,0x00000000},0x1f0f,1,2208},
+ {{0x00000000,0x00000000,0x00000000},0x1f87,1,2517},
+ {{0x00000000,0x00000000,0x00000000},0x1f8f,1,2517},
+ {{0x00000000,0x00000000,0x00000000},0x1f81,1,2482},
+ {{0x00000000,0x00000000,0x00000000},0x1f89,1,2482},
+ {{0x00000000,0x00000000,0x00000000},0x1fb6,1,2644},
+ {{0x00000000,0x00000000,0x00000000},0x1fb7,1,2648},
+ {{0x00000000,0x00000000,0x00000000},0x1fb3,1,2635},
+ {{0x00000000,0x00000000,0x00000000},0x1fbc,1,2635},
+ {{0x00000000,0x00000000,0x00000000},0x05d0,1,1160},
+ {{0x00000000,0x00000000,0x00000000},0x0627,1,1160},
+ {{0x00000000,0x00000000,0x00000000},0xfe8d,1,7015},
+ {{0x00000000,0x00000000,0x00000000},0xfe8e,1,7019},
+ {{0x00000000,0x00000000,0x00000000},0x0100,1,0},
+ {{0x00000000,0x00000000,0x00000000},0x0101,1,0},
+ {{0x00000000,0x00000000,0x00000000},0x1ea0,1,1998},
+ {{0x00000000,0x00000000,0x00000000},0x1ea1,1,1998},
+ {{0x00000000,0x00000000,0x00000000},0x1e00,1,1728},
+ {{0x00000000,0x00000000,0x00000000},0x1e01,1,1728},
+ {{0x00000000,0x00000000,0x00000000},0x01de,1,355},
+ {{0x00000000,0x00000000,0x00000000},0x01df,1,355},
+ {{0x00000000,0x00000000,0x00000000},0x1ea2,1,2002},
+ {{0x00000000,0x00000000,0x00000000},0x1ea3,1,2002},
+ {{0x00000000,0x00000000,0x00000000},0x01e2,1,361},
+ {{0x00000000,0x00000000,0x00000000},0x01e3,1,361},
+ {{0x00000000,0x00000000,0x00000000},0x311a,1,6841},
+ {{0x00000000,0x00000000,0x00000000},0x3041,1,6543},
+ {{0x00000000,0x00000000,0x00000000},0x3042,1,6543},
+ {{0x00000000,0x00000000,0x00000000},0x30a1,1,6735},
+ {{0x00000000,0x00000000,0x00000000},0x30a2,1,6735},
+ {{0x00000000,0x00000000,0x00000000},0x01e0,1,358},
+ {{0x00000000,0x00000000,0x00000000},0x01e1,1,358},
+ {{0x00000000,0x00000000,0x00000000},0x0104,1,6},
+ {{0x00000000,0x00000000,0x00000000},0x0105,1,6},
+ {{0x00000000,0x00000000,0x00000000},0x01cd,1,315},
+ {{0x00000000,0x00000000,0x00000000},0x01ce,1,315},
+ {{0x00000000,0x00000000,0x00000000},0x0410,1,942},
+ {{0x00000000,0x00000000,0x00000000},0x0430,1,942},
+ {{0x00000000,0x00000000,0x00000000},0x1ea6,1,2009},
+ {{0x00000000,0x00000000,0x00000000},0x1ea7,1,2009},
+ {{0x00000000,0x00000000,0x00000000},0x1ea4,1,2005},
+ {{0x00000000,0x00000000,0x00000000},0x1ea5,1,2005},
+ {{0x00000000,0x00000000,0x00000000},0x1eac,1,2021},
+ {{0x00000000,0x00000000,0x00000000},0x1ead,1,2021},
+ {{0x00000000,0x00000000,0x00000000},0x1ea8,1,2013},
+ {{0x00000000,0x00000000,0x00000000},0x1ea9,1,2013},
+ {{0x00000000,0x00000000,0x00000000},0x1eaa,1,2017},
+ {{0x00000000,0x00000000,0x00000000},0x1eab,1,2017},
+ {{0x00000000,0x00000000,0x00000000},0x01fa,1,392},
+ {{0x00000000,0x00000000,0x00000000},0x01fb,1,392},
+ {{0x00100010,0x00000000,0x00000000},0x02dd,0,1627},
+ {{0x00000003,0x00000440,0x00000000},0x01e2,0,2829},
+ {{0x00000005,0x00000440,0x00000000},0x01e3,0,2829},
+ {{0x00000013,0x00000040,0x00000000},0x01fc,0,2829},
+ {{0x00000015,0x00000040,0x00000000},0x01fd,0,2829},
+ {{0x00000000,0x00000000,0x00000000},0x01fc,1,396},
+ {{0x00000000,0x00000000,0x00000000},0x01fd,1,396},
+ {{0x00000000,0x00000000,0x00000000},0x0623,1,1357},
+ {{0x00000000,0x00000000,0x00000000},0x0625,1,1357},
+ {{0x00000000,0x00000000,0x00000000},0xfe83,1,6999},
+ {{0x00000000,0x00000000,0x00000000},0xfe84,1,7003},
+ {{0x00000000,0x00000000,0x00000000},0xfe88,1,7003},
+ {{0x00000201,0x00000000,0x00000000},0x311e,1,6854},
+ {{0x00000081,0x00000000,0x00000000},0x0639,1,1494},
+ {{0x00000081,0x00000010,0x00000000},0xfec9,1,1494},
+ {{0x01000081,0x00000000,0x00000000},0xfeca,1,1494},
+ {{0x00000081,0x00000004,0x00000000},0xfecb,1,1494},
+ {{0x00000081,0x00001000,0x00000000},0xfecc,1,1494},
+ {{0x00000000,0x04000000,0x00001000},0x224c,1,4478},
+ {{0x00000000,0x04000000,0x00001000},0x2248,1,4468},
+ {{0x00000000,0x00000000,0x00000000},0x0622,1,1354},
+ {{0x00000000,0x00000000,0x00000080},0x33c2,1,1354},
+ {{0x00000000,0x00000000,0x00000000},0xfe81,1,6991},
+ {{0x00000000,0x00000000,0x00000000},0xfe82,1,6995},
+ {{0x00000000,0x00000000,0x00040001},0x2447,1,4843},
+ {{0x00000000,0x00000000,0x00000000},0x2227,1,4316},
+ {{0x00000201,0x00000000,0x00000000},0x3122,1,4316},
+ {{0x00000201,0x00000000,0x00000000},0x3124,1,6866},
+ {{0x00000000,0x00000000,0x00000000},0x2220,1,4287},
+ {{0x00000000,0x00400000,0x00000000},0x221f,1,4287},
+ {{0x00100000,0x00000080,0x00020000},0x300a,1,4287},
+ {{0x00100000,0x00400000,0x00020000},0x300b,1,4287},
+ {{0x00000001,0x00000000,0x00000000},0x212b,1,3495},
+ {{0x08000000,0x00000000,0x00000000},0x0387,1,614},
+ {{0x00000000,0x00000000,0x00000000},0x212b,1,3504},
+ {{0x00000000,0x04000000,0x00001000},0x2245,1,4451},
+ {{0x00000000,0x00000000,0x00000000},0x2169,1,3720},
+ {{0x00000000,0x00000000,0x00000000},0x2179,1,3720},
+ {{0x00000000,0x00000000,0x00000000},0x2312,1,4685},
+ {{0x00000000,0x00000000,0x00000000},0x0670,1,1681},
+ {{0x00000000,0x00000000,0x00000000},0x2217,1,4202},
+ {{0x00000000,0x04000000,0x00001000},0x2243,1,4433},
+ {{0x00000201,0x00000000,0x00000000},0x3120,1,6860},
+ {{0x20000001,0x00000000,0x00000000},0x05e2,1,1280},
+ {{0x00000201,0x00000000,0x00000000},0x3105,0,1548},
+ {{0x00000005,0x00000040,0x10000000},0x0180,0,1548},
+ {{0x80000003,0x00000040,0x00000000},0x0181,0,1548},
+ {{0x00000005,0x00040040,0x00000000},0x249d,0,1548},
+ {{0x00004003,0x00000040,0x00000000},0x24b7,0,1548},
+ {{0x00004005,0x00000040,0x00000000},0x24d1,0,1548},
+ {{0x0008000b,0x00000040,0x00000000},0x1e02,0,1548},
+ {{0x0008000d,0x00000040,0x00000000},0x1e03,0,1548},
+ {{0x00080103,0x00000040,0x00000000},0x1e04,0,1548},
+ {{0x00080105,0x00000040,0x00000000},0x1e05,0,1548},
+ {{0x00000103,0x00000240,0x00000000},0x1e06,0,1548},
+ {{0x00000105,0x00000240,0x00000000},0x1e07,0,1548},
+ {{0x00000000,0x00000000,0x00000000},0x24b7,1,5317},
+ {{0x00000000,0x00000000,0x00000000},0x24d1,1,5317},
+ {{0x00000000,0x00000000,0x00000000},0x0392,1,673},
+ {{0x00000000,0x00000000,0x00000000},0x03b2,1,673},
+ {{0x00000000,0x00000000,0x00000000},0x05d1,1,1167},
+ {{0x00000000,0x00000000,0x00000000},0x0628,1,1167},
+ {{0x00000000,0x00000000,0x00000000},0xfe91,1,7031},
+ {{0x00000000,0x00000000,0x00000000},0xfe8f,1,7023},
+ {{0x00000000,0x00000000,0x00000000},0xfe90,1,7027},
+ {{0x00000000,0x00000000,0x00000000},0xfe92,1,7035},
+ {{0x00000000,0x00000000,0x00000000},0x1e04,1,1735},
+ {{0x00000000,0x00000000,0x00000000},0x1e05,1,1735},
+ {{0x00000000,0x00000000,0x00000000},0x1e02,1,1732},
+ {{0x00000000,0x00000000,0x00000000},0x1e03,1,1732},
+ {{0x00000000,0x00000000,0x00000000},0x0180,1,245},
+ {{0x00000000,0x00000000,0x00000000},0x0181,1,248},
+ {{0x00000000,0x00000000,0x00000000},0x03d0,1,833},
+ {{0x00000000,0x00000000,0x00000000},0x3105,1,6790},
+ {{0x00000000,0x00000000,0x00000000},0x0411,1,948},
+ {{0x00000000,0x00000000,0x00000000},0x0431,1,948},
+ {{0x00000000,0x00000000,0x00000000},0x1e06,1,1739},
+ {{0x00000000,0x00000000,0x00000000},0x1e07,1,1739},
+ {{0x40000001,0x00000000,0x00000000},0x3070,1,6618},
+ {{0x00000001,0x00000020,0x00000000},0x30d0,1,6618},
+ {{0x00000000,0x00000000,0x00000000},0x2717,1,6312},
+ {{0x00000000,0x00000001,0x00000000},0x2015,0,1674},
+ {{0x00200001,0x08000000,0x00002000},0x21a8,1,3974},
+ {{0x00000000,0x00000000,0x00000000},0x2572,1,5653},
+ {{0x00000000,0x00000000,0x00000000},0x25e3,1,5653},
+ {{0x40000001,0x00000000,0x00000000},0x3079,1,945},
+ {{0x00000001,0x00000020,0x00000000},0x30d9,1,945},
+ {{0x00010003,0x00000000,0x00000000},0x0411,1,945},
+ {{0x00010005,0x00000000,0x00000000},0x0431,1,945},
+ {{0x00000000,0x00000000,0x00000000},0x266b,1,6210},
+ {{0x00000000,0x00000000,0x00000000},0x266c,1,6233},
+ {{0x00000000,0x00000000,0x00000000},0x2235,1,4386},
+ {{0x00000081,0x00000000,0x00000000},0x0628,1,1386},
+ {{0x00000081,0x00000010,0x00000000},0xfe8f,1,1386},
+ {{0x01000081,0x00000000,0x00000000},0xfe90,1,1386},
+ {{0x00000081,0x00000004,0x00000000},0xfe91,1,1386},
+ {{0x00000081,0x00001000,0x00000000},0xfe92,1,1386},
+ {{0x20000001,0x00000000,0x00000000},0x05d1,1,1163},
+ {{0x08000003,0x00000000,0x00000000},0x0392,1,668},
+ {{0x08000005,0x00000000,0x00000000},0x03b2,1,668},
+ {{0x08000000,0x00000000,0x00000000},0x03d0,1,821},
+ {{0x40000001,0x00000000,0x00000000},0x3073,1,6621},
+ {{0x00000001,0x00000020,0x00000000},0x30d3,1,6621},
+ {{0x02000000,0x00000000,0x00000000},0x2588,1,5686},
+ {{0x00000000,0x00000080,0x00080000},0x258c,1,5686},
+ {{0x00000000,0x00400000,0x00080000},0x2590,1,5686},
+ {{0x40000001,0x00000000,0x00000000},0x307c,1,6630},
+ {{0x00000001,0x00000020,0x00000000},0x30dc,1,6630},
+ {{0x00000000,0x00000000,0x00080000},0x2321,1,4748},
+ {{0x00000000,0x00000000,0x00000000},0x216a,1,3730},
+ {{0x00000000,0x00000000,0x00000000},0x217a,1,3730},
+ {{0x00000000,0x00000000,0x00040000},0x2446,1,4813},
+ {{0x40000001,0x00000000,0x00000000},0x3076,1,6627},
+ {{0x00000001,0x00000020,0x00000000},0x30d6,1,6627},
+ {{0x00000000,0x00000000,0x00000000},0x2022,1,3002},
+ {{0x00000000,0x00000000,0x00000000},0x2219,1,4235},
+ {{0x00000000,0x00000000,0x00000000},0x25ce,1,5957},
+ {{0x00000201,0x00000000,0x00000000},0x3118,0,1550},
+ {{0x00000013,0x00000040,0x00000000},0x0106,0,1550},
+ {{0x00000015,0x00000040,0x00000000},0x0107,0,1550},
+ {{0x00008003,0x00000040,0x00000000},0x0108,0,1550},
+ {{0x00008005,0x00000040,0x00000000},0x0109,0,1550},
+ {{0x00001003,0x00000040,0x00000000},0x010c,0,1550},
+ {{0x00001005,0x00000040,0x00000000},0x010d,0,1550},
+ {{0x80000003,0x00000040,0x00000000},0x0187,0,1550},
+ {{0x80000005,0x00000040,0x00000000},0x0188,0,1550},
+ {{0x00000005,0x00040040,0x00000000},0x249e,0,1550},
+ {{0x00004003,0x00000040,0x00000000},0x24b8,0,1550},
+ {{0x00004005,0x00000040,0x00000000},0x24d2,0,1550},
+ {{0x0008000b,0x00000040,0x00000000},0x010a,0,1550},
+ {{0x0008000d,0x00000040,0x00000000},0x010b,0,1550},
+ {{0x00002013,0x00000040,0x00000000},0x1e08,0,1550},
+ {{0x00002015,0x00000040,0x00000000},0x1e09,0,1550},
+ {{0x00000000,0x00000000,0x00000000},0x24b8,1,5321},
+ {{0x00000000,0x00000000,0x00000000},0x24d2,1,5321},
+ {{0x00000000,0x00000000,0x00000000},0x0427,1,1063},
+ {{0x00000000,0x00000000,0x00000000},0x0447,1,1063},
+ {{0x00000000,0x00000000,0x00000000},0x0106,1,9},
+ {{0x00000000,0x00000000,0x00000000},0x0107,1,9},
+ {{0x00000000,0x00000000,0x00000000},0x039e,1,750},
+ {{0x00000000,0x00000000,0x00000000},0x03be,1,750},
+ {{0x00000000,0x00000000,0x00000000},0x0635,1,1473},
+ {{0x00000000,0x00000000,0x00000000},0xfebb,1,7199},
+ {{0x00000000,0x00000000,0x00000000},0xfeb9,1,7191},
+ {{0x00000000,0x00000000,0x00000000},0xfeba,1,7195},
+ {{0x00000000,0x00000000,0x00000000},0xfebc,1,7203},
+ {{0x00000000,0x00000000,0x00000000},0x1e08,1,1742},
+ {{0x00000000,0x00000000,0x00000000},0x1e09,1,1742},
+ {{0x00000000,0x00000000,0x00000000},0x010a,1,15},
+ {{0x00000000,0x00000000,0x00000000},0x010b,1,15},
+ {{0x00000000,0x00000000,0x00000000},0x0187,1,251},
+ {{0x00000000,0x00000000,0x00000000},0x0188,1,251},
+ {{0x00000000,0x00000000,0x00000000},0x0480,1,1154},
+ {{0x00000000,0x00000000,0x00000000},0x0481,1,1154},
+ {{0x00000000,0x00000000,0x00000000},0x3118,1,6835},
+ {{0x00000000,0x00000000,0x00000000},0x010c,1,18},
+ {{0x00000000,0x00000000,0x00000000},0x010d,1,18},
+ {{0x00000000,0x00000000,0x00000000},0x0426,1,1056},
+ {{0x00000000,0x00000000,0x00000000},0x0446,1,1056},
+ {{0x00000000,0x00000000,0x00000000},0x0108,1,12},
+ {{0x00000000,0x00000000,0x00000000},0x0109,1,12},
+ {{0x00000000,0x00000000,0x00000000},0x2038,1,3215},
+ {{0x00000000,0x00000000,0x00000001},0x2105,1,3388},
+ {{0x00000000,0x00000000,0x00000000},0x2038,1,3209},
+ {{0x00000000,0x00000000,0x00000000},0x2663,0,2180},
+ {{0x00000000,0x00000000,0x00000000},0x2667,1,6171},
+ {{0x00000000,0x00000000,0x00000000},0x2662,1,6151},
+ {{0x00000000,0x00000000,0x00000000},0x2666,1,6167},
+ {{0x00000000,0x00000080,0x00000000},0x2308,1,4643},
+ {{0x00000000,0x00400000,0x00000000},0x2309,1,4643},
+ {{0x00000000,0x00000000,0x00000000},0x223e,1,4430},
+ {{0x00000000,0x00000000,0x00000000},0x2661,1,6148},
+ {{0x00000201,0x00000000,0x00000000},0x3114,1,6148},
+ {{0x00000000,0x00000000,0x00000000},0x2665,1,6163},
+ {{0x00000000,0x00000000,0x00040000},0x2441,1,4793},
+ {{0x00010003,0x00000000,0x00000000},0x0427,1,1059},
+ {{0x00010005,0x00000000,0x00000000},0x0447,1,1059},
+ {{0x00000000,0x00000800,0x00000000},0x2713,1,6303},
+ {{0x08000003,0x00000000,0x00000000},0x03a7,1,792},
+ {{0x08000005,0x00000000,0x00000000},0x03c7,1,792},
+ {{0x00000000,0x00000000,0x00000000},0x25ef,0,2362},
+ {{0x00000000,0x80000000,0x00000000},0x25cb,1,5947},
+ {{0x00000000,0x00000000,0x00000004},0x25cf,1,5947},
+ {{0x00000001,0x00000080,0x00080004},0x25d0,1,5947},
+ {{0x00000001,0x00400000,0x00080004},0x25d1,1,5947},
+ {{0x00000000,0x00000800,0x00000800},0x3006,1,6412},
+ {{0x00000000,0x00000000,0x00008004},0x2663,1,6154},
+ {{0x00000000,0x80000000,0x00008000},0x2667,1,6154},
+ {{0x00000000,0x00000000,0x00000000},0x2105,0,2577},
+ {{0x04000000,0x00000000,0x00000000},0x0300,1,540},
+ {{0x00000010,0x00000000,0x00000000},0x0301,1,540},
+ {{0x00000008,0x00400000,0x00000000},0x20d1,1,3352},
+ {{0x00000080,0x00000000,0x00000000},0x060c,0,1388},
+ {{0x00000000,0x00000000,0x00000800},0x3001,0,1388},
+ {{0x00000004,0x80000000,0x00000084},0x25a3,1,5759},
+ {{0x00000000,0x00000000,0x00000000},0x220b,1,4115},
+ {{0x00000000,0x00000000,0x00000000},0x222e,1,4356},
+ {{0x00000000,0x00000080,0x00020000},0x300c,1,6432},
+ {{0x00000000,0x00400000,0x00020000},0x300d,1,6432},
+ {{0x00000000,0x80000080,0x00020000},0x300e,1,6432},
+ {{0x00000000,0x80400000,0x00020000},0x300f,1,6432},
+ {{0x00000000,0x00000000,0x00000000},0x216b,0,902},
+ {{0x00000000,0x00000000,0x00000000},0x217b,0,902},
+ {{0x00000000,0x00000000,0x00000000},0x2660,1,6139},
+ {{0x00000000,0x00000000,0x00000000},0x2664,1,6159},
+ {{0x00000000,0x00002000,0x00040000},0x2449,1,4867},
+ {{0x00000201,0x00000000,0x00000000},0x3109,0,1552},
+ {{0x00001003,0x00000040,0x00000000},0x010e,0,1552},
+ {{0x00001005,0x00000040,0x00000000},0x010f,0,1552},
+ {{0x00000003,0x00000040,0x10000000},0x0110,0,1552},
+ {{0x00000005,0x00000040,0x10000000},0x0111,0,1552},
+ {{0x00002003,0x00000040,0x00000000},0x1e10,0,1552},
+ {{0x00002005,0x00000040,0x00000000},0x1e11,0,1552},
+ {{0x00000005,0x00040040,0x00000000},0x249f,0,1552},
+ {{0x00004003,0x00000040,0x00000000},0x24b9,0,1552},
+ {{0x00004005,0x00000040,0x00000000},0x24d3,0,1552},
+ {{0x0008000b,0x00000040,0x00000000},0x1e0a,0,1552},
+ {{0x0008000d,0x00000040,0x00000000},0x1e0b,0,1552},
+ {{0x00080103,0x00000040,0x00000000},0x1e0c,0,1552},
+ {{0x00080105,0x00000040,0x00000000},0x1e0d,0,1552},
+ {{0x00000103,0x00000240,0x00000000},0x1e0e,0,1552},
+ {{0x00000105,0x00000240,0x00000000},0x1e0f,0,1552},
+ {{0x00008103,0x00000040,0x00000000},0x1e12,0,1552},
+ {{0x00008105,0x00000040,0x00000000},0x1e13,0,1552},
+ {{0x00000000,0x00000000,0x00000000},0x24b9,1,5325},
+ {{0x00000000,0x00000000,0x00000000},0x24d3,1,5325},
+ {{0x00000007,0x00000040,0x00000000},0x01f2,1,289},
+ {{0x00001007,0x00000040,0x00000000},0x01c5,1,289},
+ {{0x00000000,0x00000000,0x00000000},0x0402,1,882},
+ {{0x00000000,0x00000000,0x00000000},0x0452,1,882},
+ {{0x00000000,0x00000000,0x00000000},0x0394,1,691},
+ {{0x00000000,0x00000000,0x00000000},0x03b4,1,691},
+ {{0x00000000,0x00000000,0x00000000},0x05d3,1,1185},
+ {{0x00000000,0x00000000,0x00000000},0x062f,1,1185},
+ {{0x00000000,0x00000000,0x00000000},0xfea9,1,7127},
+ {{0x00000000,0x00000000,0x00000000},0xfeaa,1,7131},
+ {{0x00000000,0x00000000,0x00000000},0x1e10,1,1756},
+ {{0x00000000,0x00000000,0x00000000},0x1e11,1,1756},
+ {{0x00000000,0x00000000,0x00000000},0x1e0c,1,1749},
+ {{0x00000000,0x00000000,0x00000000},0x1e0d,1,1749},
+ {{0x00000000,0x00000000,0x00000000},0x1e12,1,1759},
+ {{0x00000000,0x00000000,0x00000000},0x1e13,1,1759},
+ {{0x00000000,0x00000000,0x00000000},0x1e0a,1,1746},
+ {{0x00000000,0x00000000,0x00000000},0x1e0b,1,1746},
+ {{0x00000000,0x00000000,0x00000000},0x0110,1,24},
+ {{0x00000000,0x00000000,0x00000000},0x0111,1,24},
+ {{0x00000000,0x00000000,0x00000000},0x3109,0,1050},
+ {{0x00000000,0x00000000,0x00000000},0x010e,1,21},
+ {{0x00000000,0x00000000,0x00000000},0x010f,1,21},
+ {{0x00000000,0x00000000,0x00000000},0x0414,1,967},
+ {{0x00000000,0x00000000,0x00000000},0x0434,1,967},
+ {{0x00000000,0x00000000,0x00000000},0x1e0e,1,1753},
+ {{0x00000000,0x00000000,0x00000000},0x1e0f,1,1753},
+ {{0x40000001,0x00000000,0x00000000},0x3060,1,6600},
+ {{0x00000001,0x00000020,0x00000000},0x30c0,1,6600},
+ {{0x00000081,0x00000000,0x00000000},0x0636,1,1476},
+ {{0x00000081,0x00000010,0x00000000},0xfebd,1,1476},
+ {{0x01000081,0x00000000,0x00000000},0xfebe,1,1476},
+ {{0x00000081,0x00000004,0x00000000},0xfebf,1,1476},
+ {{0x00000081,0x00001000,0x00000000},0xfec0,1,1476},
+ {{0x00000000,0x00000000,0x00000000},0x2020,1,2989},
+ {{0x00100000,0x00000000,0x00000000},0x2021,1,2989},
+ {{0x00000081,0x00000000,0x00000000},0x062f,1,1434},
+ {{0x00000081,0x00000010,0x00000000},0xfea9,1,1434},
+ {{0x01000081,0x00000000,0x00000000},0xfeaa,1,1434},
+ {{0x20000001,0x00000000,0x00000000},0x05d3,1,1179},
+ {{0x00000080,0x00000000,0x00000000},0x064f,1,1611},
+ {{0x00000080,0x00000000,0x00000000},0x064c,1,1578},
+ {{0x00000000,0x00000000,0x00000000},0x2593,1,5723},
+ {{0x00000000,0x00000000,0x00040000},0x2448,1,4859},
+ {{0x00000000,0x00000000,0x00000000},0x25c6,1,5930},
+ {{0x00000000,0x00000000,0x00000000},0x0636,1,1480},
+ {{0x00000000,0x00000000,0x00000000},0xfebf,1,7215},
+ {{0x00000000,0x00000000,0x00000000},0xfebd,1,7207},
+ {{0x00000000,0x00000000,0x00000000},0xfebe,1,7211},
+ {{0x00000000,0x00000000,0x00000000},0xfec0,1,7219},
+ {{0x00000000,0x00000000,0x00000000},0x2206,1,964},
+ {{0x40000001,0x00000000,0x00000000},0x3067,1,964},
+ {{0x00000001,0x00000020,0x00000000},0x30c7,1,964},
+ {{0x00010003,0x00000000,0x00000000},0x0414,1,964},
+ {{0x00010005,0x00000000,0x00000000},0x0434,1,964},
+ {{0x00000000,0x00000000,0x00000000},0x2103,1,3373},
+ {{0x00000000,0x00000000,0x00000000},0x2109,1,3393},
+ {{0x08000003,0x00000000,0x00000000},0x0394,1,685},
+ {{0x08000005,0x00000000,0x00000000},0x03b4,1,685},
+ {{0x00000000,0x00000000,0x00000000},0x252c,1,5568},
+ {{0x00000000,0x00000000,0x00000000},0x2564,1,5568},
+ {{0x00000000,0x00000000,0x00000000},0x2565,1,5568},
+ {{0x00000000,0x00000000,0x00000000},0x2566,1,5568},
+ {{0x00000000,0x00000000,0x00000000},0x252f,1,5579},
+ {{0x00000000,0x00000000,0x00000000},0x2530,1,5579},
+ {{0x00000000,0x00000000,0x00000000},0x2533,1,5579},
+ {{0x00000000,0x00000000,0x00000000},0x222c,1,4353},
+ {{0x40000001,0x00000000,0x00000000},0x3062,1,4353},
+ {{0x00000001,0x00000020,0x00000000},0x30c2,1,4353},
+ {{0x00000001,0x00000000,0x00000080},0x25a9,1,5837},
+ {{0x00400400,0x04400180,0x00000000},0x2571,1,5625},
+ {{0x00400400,0x04400180,0x00000000},0x2572,1,5625},
+ {{0x08000000,0x00000000,0x20000000},0x0385,1,598},
+ {{0x08000001,0x00080000,0x00000000},0x1fc1,1,598},
+ {{0x08000001,0x20000000,0x00000000},0x1fed,1,598},
+ {{0x08000001,0x00020000,0x00000000},0x1fee,1,598},
+ {{0x08000003,0x00000008,0x00000000},0x03aa,1,598},
+ {{0x08000003,0x10000000,0x00000000},0x03ab,1,598},
+ {{0x08000005,0x00000008,0x00000000},0x03ca,1,598},
+ {{0x08000005,0x10000000,0x00000000},0x03cb,1,598},
+ {{0x08000005,0x00000008,0x20000000},0x0390,1,598},
+ {{0x08000005,0x10000000,0x20000000},0x03b0,1,598},
+ {{0x08000005,0x20000008,0x00000000},0x1fd2,1,598},
+ {{0x08000005,0x00020008,0x00000000},0x1fd3,1,598},
+ {{0x08000005,0x00080008,0x00000000},0x1fd7,1,598},
+ {{0x08000005,0x30000000,0x00000000},0x1fe2,1,598},
+ {{0x08000005,0x10020000,0x00000000},0x1fe3,1,598},
+ {{0x08000005,0x10080000,0x00000000},0x1fe7,1,598},
+ {{0x00000000,0x00000000,0x00000004},0x25c6,1,5922},
+ {{0x00000000,0x80000000,0x00000000},0x25c7,1,5922},
+ {{0x00000000,0x80000000,0x00008000},0x2662,1,5922},
+ {{0x00000000,0x00000000,0x00008004},0x2666,1,5922},
+ {{0x08000001,0x00000000,0x00000000},0x03dc,1,846},
+ {{0x00000000,0x00000800,0x00000000},0x3003,1,6350},
+ {{0x00010003,0x00000000,0x00000000},0x0402,1,878},
+ {{0x00010005,0x00000000,0x00000000},0x0452,1,878},
+ {{0x00000000,0x00000000,0x00000000},0x0630,1,1443},
+ {{0x00000000,0x00000000,0x00000000},0xfeab,1,7135},
+ {{0x00000000,0x00000000,0x00000000},0xfeac,1,7139},
+ {{0x00000000,0x00000000,0x00000000},0x2510,0,947},
+ {{0x00000000,0x00000000,0x00000000},0x2555,0,947},
+ {{0x00000000,0x00000000,0x00000000},0x2556,0,947},
+ {{0x00000000,0x00000000,0x00000000},0x2511,1,5508},
+ {{0x00000000,0x00000000,0x00000000},0x2512,1,5508},
+ {{0x00000000,0x00000000,0x00000000},0x252d,1,5575},
+ {{0x00000000,0x00000000,0x00000000},0x252e,1,5575},
+ {{0x00000000,0x00000000,0x00000000},0x2531,1,5575},
+ {{0x00000000,0x00000000,0x00000000},0x2532,1,5575},
+ {{0x40000001,0x00000000,0x00000000},0x3069,0,1327},
+ {{0x00000001,0x00000020,0x00000000},0x30c9,0,1327},
+ {{0x00000005,0x00000040,0x00000000},0x0131,1,75},
+ {{0x00000000,0x00000000,0x00002000},0x2193,1,3895},
+ {{0x00000000,0x00000000,0x00000000},0x2202,1,4059},
+ {{0x00000000,0x00000000,0x00000000},0x250c,1,5492},
+ {{0x00000000,0x00000000,0x00000000},0x2552,1,5492},
+ {{0x00000000,0x00000000,0x00000000},0x2553,1,5492},
+ {{0x00000000,0x00000000,0x00000000},0x2554,1,5492},
+ {{0x00000000,0x00000000,0x00000000},0x250d,1,5499},
+ {{0x00000000,0x00000000,0x00000000},0x250e,1,5499},
+ {{0x00000000,0x00000000,0x00000000},0x250f,1,5499},
+ {{0x00000000,0x00000000,0x00000000},0x0405,1,899},
+ {{0x00000000,0x00000000,0x00000000},0x0455,1,899},
+ {{0x00000000,0x00000000,0x00000000},0x25bc,0,1696},
+ {{0x00000000,0x00000000,0x00000000},0x25bd,0,1696},
+ {{0x40000001,0x00000000,0x00000000},0x3065,1,6609},
+ {{0x00000001,0x00000020,0x00000000},0x30c5,1,6609},
+ {{0x00000000,0x00000000,0x00000000},0x25c7,1,5933},
+ {{0x00000000,0x00000000,0x00000000},0x040f,1,282},
+ {{0x00000000,0x00000000,0x00000000},0x045f,1,282},
+ {{0x00000003,0x00000040,0x00000000},0x01f1,1,282},
+ {{0x00000005,0x00000040,0x00000000},0x01f3,1,282},
+ {{0x00001003,0x00000040,0x00000000},0x01c4,1,282},
+ {{0x00001005,0x00000040,0x00000000},0x01c6,1,282},
+ {{0x00000000,0x00000000,0x00000000},0x01f1,1,385},
+ {{0x00000000,0x00000000,0x00000000},0x01f2,1,385},
+ {{0x00000000,0x00000000,0x00000000},0x01f3,1,385},
+ {{0x00000000,0x00000000,0x00000000},0x01c4,1,285},
+ {{0x00000000,0x00000000,0x00000000},0x01c5,1,285},
+ {{0x00000000,0x00000000,0x00000000},0x01c6,1,285},
+ {{0x00010003,0x00000000,0x00000000},0x0405,1,895},
+ {{0x00010005,0x00000000,0x00000000},0x0455,1,895},
+ {{0x00010003,0x00000000,0x00000000},0x040f,1,937},
+ {{0x00010005,0x00000000,0x00000000},0x045f,1,937},
+ {{0x40000001,0x00000000,0x00000000},0x3048,0,1554},
+ {{0x00000001,0x00000020,0x00000000},0x30a8,0,1554},
+ {{0x00000201,0x00000000,0x00000000},0x311c,0,1554},
+ {{0x00010003,0x00000000,0x00000000},0x042d,0,1554},
+ {{0x00010005,0x00000000,0x00000000},0x044d,0,1554},
+ {{0x40000005,0x00000000,0x00000000},0x3047,0,1554},
+ {{0x00000005,0x00000020,0x00000000},0x30a7,0,1554},
+ {{0x00000003,0x00000440,0x00000000},0x0112,0,1554},
+ {{0x00000005,0x00000440,0x00000000},0x0113,0,1554},
+ {{0x00000803,0x00000040,0x00000000},0x0114,0,1554},
+ {{0x00000805,0x00000040,0x00000000},0x0115,0,1554},
+ {{0x00000003,0x00000040,0x02000000},0x0118,0,1554},
+ {{0x00000005,0x00000040,0x02000000},0x0119,0,1554},
+ {{0x00001003,0x00000040,0x00000000},0x011a,0,1554},
+ {{0x00001005,0x00000040,0x00000000},0x011b,0,1554},
+ {{0x00000003,0x02000040,0x00000000},0x1ebc,0,1554},
+ {{0x00000005,0x02000040,0x00000000},0x1ebd,0,1554},
+ {{0x00000005,0x00040040,0x00000000},0x24a0,0,1554},
+ {{0x00004003,0x00000040,0x00000000},0x24ba,0,1554},
+ {{0x00004005,0x00000040,0x00000000},0x24d4,0,1554},
+ {{0x0008000b,0x00000040,0x00000000},0x0116,0,1554},
+ {{0x0008000d,0x00000040,0x00000000},0x0117,0,1554},
+ {{0x04100003,0x00000040,0x00000000},0x0204,0,1554},
+ {{0x04100005,0x00000040,0x00000000},0x0205,0,1554},
+ {{0x00000803,0x00000040,0x00800000},0x0206,0,1554},
+ {{0x00000805,0x00000040,0x00800000},0x0207,0,1554},
+ {{0x04000003,0x00000440,0x00000000},0x1e14,0,1554},
+ {{0x04000005,0x00000440,0x00000000},0x1e15,0,1554},
+ {{0x00000013,0x00000440,0x00000000},0x1e16,0,1554},
+ {{0x00000015,0x00000440,0x00000000},0x1e17,0,1554},
+ {{0x00008103,0x00000040,0x00000000},0x1e18,0,1554},
+ {{0x00008105,0x00000040,0x00000000},0x1e19,0,1554},
+ {{0x00000103,0x02000040,0x00000000},0x1e1a,0,1554},
+ {{0x00000105,0x02000040,0x00000000},0x1e1b,0,1554},
+ {{0x00002803,0x00000040,0x00000000},0x1e1c,0,1554},
+ {{0x00002805,0x00000040,0x00000000},0x1e1d,0,1554},
+ {{0x00080103,0x00000040,0x00000000},0x1eb8,0,1554},
+ {{0x00080105,0x00000040,0x00000000},0x1eb9,0,1554},
+ {{0x8000000b,0x00000040,0x00000000},0x1eba,0,1554},
+ {{0x8000000d,0x00000040,0x00000000},0x1ebb,0,1554},
+ {{0x00008013,0x00000040,0x00000000},0x1ebe,0,1554},
+ {{0x00008015,0x00000040,0x00000000},0x1ebf,0,1554},
+ {{0x04008003,0x00000040,0x00000000},0x1ec0,0,1554},
+ {{0x04008005,0x00000040,0x00000000},0x1ec1,0,1554},
+ {{0x00008003,0x02000040,0x00000000},0x1ec4,0,1554},
+ {{0x00008005,0x02000040,0x00000000},0x1ec5,0,1554},
+ {{0x8000800b,0x00000040,0x00000000},0x1ec2,0,1554},
+ {{0x8000800d,0x00000040,0x00000000},0x1ec3,0,1554},
+ {{0x00088103,0x00000040,0x00000000},0x1ec6,0,1554},
+ {{0x00088105,0x00000040,0x00000000},0x1ec7,0,1554},
+ {{0x00000000,0x00000000,0x00000000},0x24ba,1,5329},
+ {{0x00000000,0x00000000,0x00000000},0x24d4,1,5329},
+ {{0x00000000,0x00000000,0x00000000},0x0204,1,411},
+ {{0x00000000,0x00000000,0x00000000},0x0205,1,411},
+ {{0x00000000,0x00000000,0x00000000},0x0388,1,636},
+ {{0x00000000,0x00000000,0x00000000},0x03ad,1,636},
+ {{0x00000000,0x00000000,0x00000000},0x0114,1,30},
+ {{0x00000000,0x00000000,0x00000000},0x0115,1,30},
+ {{0x00000000,0x00000000,0x00000000},0x0206,1,415},
+ {{0x00000000,0x00000000,0x00000000},0x0207,1,415},
+ {{0x00000000,0x00000000,0x00000000},0x0395,1,694},
+ {{0x00000000,0x00000000,0x00000000},0x03b5,1,694},
+ {{0x00000000,0x00000000,0x00000000},0x1f72,1,2429},
+ {{0x00000000,0x00000000,0x00000000},0x1fc8,1,2696},
+ {{0x00000000,0x00000000,0x00000000},0x1f73,1,2433},
+ {{0x00000000,0x00000000,0x00000000},0x1fc9,1,2433},
+ {{0x00000000,0x00000000,0x00000000},0x1f10,1,2213},
+ {{0x00000000,0x00000000,0x00000000},0x1f18,1,2213},
+ {{0x00000000,0x00000000,0x00000000},0x1f12,1,2221},
+ {{0x00000000,0x00000000,0x00000000},0x1f1a,1,2221},
+ {{0x00000000,0x00000000,0x00000000},0x1f14,1,2231},
+ {{0x00000000,0x00000000,0x00000000},0x1f1c,1,2231},
+ {{0x00000000,0x00000000,0x00000000},0x1f11,1,2217},
+ {{0x00000000,0x00000000,0x00000000},0x1f19,1,2217},
+ {{0x00000000,0x00000000,0x00000000},0x1f13,1,2226},
+ {{0x00000000,0x00000000,0x00000000},0x1f1b,1,2226},
+ {{0x00000000,0x00000000,0x00000000},0x1f15,1,2236},
+ {{0x00000000,0x00000000,0x00000000},0x1f1d,1,2236},
+ {{0x00000000,0x00000000,0x00000000},0x05e2,1,1285},
+ {{0x00000000,0x00000000,0x00000000},0x0639,1,1285},
+ {{0x00000000,0x00000000,0x00000000},0xfecb,1,7263},
+ {{0x00000000,0x00000000,0x00000000},0xfec9,1,7255},
+ {{0x00000000,0x00000000,0x00000000},0xfeca,1,7259},
+ {{0x00000000,0x00000000,0x00000000},0xfecc,1,7267},
+ {{0x00000000,0x00000000,0x00000000},0x1e1c,1,1779},
+ {{0x00000000,0x00000000,0x00000000},0x1e1d,1,1779},
+ {{0x00000000,0x00000000,0x00000000},0x0112,1,27},
+ {{0x00000000,0x00000000,0x00000000},0x0113,1,27},
+ {{0x00000000,0x00000000,0x00000000},0x1e14,1,1763},
+ {{0x00000000,0x00000000,0x00000000},0x1e15,1,1763},
+ {{0x00000000,0x00000000,0x00000000},0x1e16,1,1767},
+ {{0x00000000,0x00000000,0x00000000},0x1e17,1,1767},
+ {{0x00000000,0x00000000,0x00000000},0x1eb8,1,2047},
+ {{0x00000000,0x00000000,0x00000000},0x1eb9,1,2047},
+ {{0x00000000,0x00000000,0x00000000},0x1e18,1,1771},
+ {{0x00000000,0x00000000,0x00000000},0x1e19,1,1771},
+ {{0x00000000,0x00000000,0x00000000},0x1e1a,1,1775},
+ {{0x00000000,0x00000000,0x00000000},0x1e1b,1,1775},
+ {{0x00000000,0x00000000,0x00000000},0x0116,1,33},
+ {{0x00000000,0x00000000,0x00000000},0x0117,1,33},
+ {{0x00000000,0x00000000,0x00000000},0x01dd,1,352},
+ {{0x00000000,0x00000000,0x00000000},0x1eba,1,2051},
+ {{0x00000000,0x00000000,0x00000000},0x1ebb,1,2051},
+ {{0x00000000,0x00000000,0x00000000},0x311c,1,6847},
+ {{0x00000000,0x00000000,0x00000000},0x3047,1,6552},
+ {{0x00000000,0x00000000,0x00000000},0x3048,1,6552},
+ {{0x00000000,0x00000000,0x00000000},0x30a7,1,6744},
+ {{0x00000000,0x00000000,0x00000000},0x30a8,1,6744},
+ {{0x00000000,0x00000000,0x00000000},0x0118,1,36},
+ {{0x00000000,0x00000000,0x00000000},0x0119,1,36},
+ {{0x00000000,0x00000000,0x00000000},0x011a,1,39},
+ {{0x00000000,0x00000000,0x00000000},0x011b,1,39},
+ {{0x00000000,0x00000000,0x00000000},0x0415,1,970},
+ {{0x00000000,0x00000000,0x00000000},0x0435,1,970},
+ {{0x00000000,0x00000000,0x00000000},0x1ec0,1,2061},
+ {{0x00000000,0x00000000,0x00000000},0x1ec1,1,2061},
+ {{0x00000000,0x00000000,0x00000000},0x1ebe,1,2057},
+ {{0x00000000,0x00000000,0x00000000},0x1ebf,1,2057},
+ {{0x00000000,0x00000000,0x00000000},0x1ec6,1,2073},
+ {{0x00000000,0x00000000,0x00000000},0x1ec7,1,2073},
+ {{0x00000000,0x00000000,0x00000000},0x1ec2,1,2065},
+ {{0x00000000,0x00000000,0x00000000},0x1ec3,1,2065},
+ {{0x00000000,0x00000000,0x00000000},0x1ec4,1,2069},
+ {{0x00000000,0x00000000,0x00000000},0x1ec5,1,2069},
+ {{0x00000000,0x00000000,0x00000000},0x1ebc,1,2054},
+ {{0x00000000,0x00000000,0x00000000},0x1ebd,1,2054},
+ {{0x00000000,0x00000000,0x00000000},0x01b7,1,279},
+ {{0x00000000,0x00000000,0x00000000},0x0292,1,279},
+ {{0x00010003,0x00000000,0x00000000},0x0424,1,1040},
+ {{0x00010005,0x00000000,0x00000000},0x0444,1,1040},
+ {{0x00000000,0x00000000,0x00000000},0x2302,1,4640},
+ {{0x00000201,0x00000000,0x00000000},0x311d,1,4640},
+ {{0x00000000,0x00000000,0x00000000},0x311d,1,6850},
+ {{0x00000201,0x00000000,0x00000000},0x311f,1,6857},
+ {{0x00000000,0x00000000,0x00000020},0x2078,0,1470},
+ {{0x00000000,0x00000000,0x00000040},0x2088,0,1470},
+ {{0x00004001,0x00000000,0x00000000},0x2467,0,1470},
+ {{0x00000001,0x00040000,0x00000000},0x247b,0,1470},
+ {{0x00000081,0x00000000,0x00000400},0x0668,0,1470},
+ {{0x00000000,0x00804000,0x00000000},0x2167,0,1470},
+ {{0x02000001,0x00000000,0x00000002},0x248f,0,1470},
+ {{0x00000000,0x00040000,0x00000800},0x3227,0,1470},
+ {{0x00000004,0x00804000,0x00000000},0x2177,0,1470},
+ {{0x00004000,0x00002000,0x00000000},0x2471,1,5007},
+ {{0x00000000,0x00042000,0x00000000},0x2485,1,5007},
+ {{0x02000000,0x00002000,0x00000002},0x2499,1,5007},
+ {{0x00000000,0x00010000,0x00000018},0x215b,1,3629},
+ {{0x00000000,0x00000000,0x00000000},0x266a,1,6191},
+ {{0x00010003,0x00000000,0x00000000},0x041b,1,998},
+ {{0x00010005,0x00000000,0x00000000},0x043b,1,998},
+ {{0x00000000,0x00000000,0x00000001},0x2208,1,4104},
+ {{0x00000000,0x00804000,0x00000000},0x216a,1,3723},
+ {{0x00004000,0x00002000,0x00000000},0x246a,1,3723},
+ {{0x00000000,0x00042000,0x00000000},0x247e,1,3723},
+ {{0x00000004,0x00804000,0x00000000},0x217a,1,3723},
+ {{0x02000000,0x00002000,0x00000002},0x2492,1,3723},
+ {{0x00000000,0x00000001,0x00000000},0x2026,1,3044},
+ {{0x00000000,0x40000000,0x00000000},0x22ee,1,3044},
+ {{0x00000000,0x00000000,0x00000200},0x2003,0,1156},
+ {{0x00010003,0x00000000,0x00000000},0x041c,0,1156},
+ {{0x00010005,0x00000000,0x00000000},0x043c,0,1156},
+ {{0x00000000,0x00000000,0x00000000},0x2014,1,2903},
+ {{0x00000000,0x00000000,0x00000000},0x2205,1,4075},
+ {{0x00000000,0x00000000,0x00000200},0x2002,1,1007},
+ {{0x00000201,0x00000000,0x00000000},0x3123,1,1007},
+ {{0x00010003,0x00000000,0x00000000},0x041d,1,1007},
+ {{0x00010005,0x00000000,0x00000000},0x043d,1,1007},
+ {{0x00000000,0x00000000,0x00000000},0x2013,1,2892},
+ {{0x00000201,0x00000000,0x00000000},0x3125,1,153},
+ {{0x00000003,0x00000040,0x00000000},0x014a,1,153},
+ {{0x00000005,0x00000040,0x00000000},0x014b,1,153},
+ {{0x08000003,0x00000000,0x00000000},0x0395,1,628},
+ {{0x08000005,0x00000000,0x00000000},0x03b5,1,628},
+ {{0x08000003,0x00000000,0x20000000},0x0388,1,628},
+ {{0x08000005,0x00000000,0x20000000},0x03ad,1,628},
+ {{0x08000005,0x00200000,0x00000000},0x1f10,1,628},
+ {{0x08020005,0x00000000,0x00000000},0x1f11,1,628},
+ {{0x08000003,0x00200000,0x00000000},0x1f18,1,628},
+ {{0x08020003,0x00000000,0x00000000},0x1f19,1,628},
+ {{0x08000005,0x20000000,0x00000000},0x1f72,1,628},
+ {{0x08000005,0x00020000,0x00000000},0x1f73,1,628},
+ {{0x08000003,0x20000000,0x00000000},0x1fc8,1,628},
+ {{0x08000003,0x00020000,0x00000000},0x1fc9,1,628},
+ {{0x08000005,0x20200000,0x00000000},0x1f12,1,628},
+ {{0x08020005,0x20000000,0x00000000},0x1f13,1,628},
+ {{0x08000005,0x00220000,0x00000000},0x1f14,1,628},
+ {{0x08020005,0x00020000,0x00000000},0x1f15,1,628},
+ {{0x08000003,0x20200000,0x00000000},0x1f1a,1,628},
+ {{0x08020003,0x20000000,0x00000000},0x1f1b,1,628},
+ {{0x08000003,0x00220000,0x00000000},0x1f1c,1,628},
+ {{0x08020003,0x00020000,0x00000000},0x1f1d,1,628},
+ {{0x00000001,0x00000000,0x00000020},0x207c,0,1502},
+ {{0x00000001,0x00000000,0x00000040},0x208c,0,1502},
+ {{0x00000201,0x00000000,0x00000000},0x3126,1,1022},
+ {{0x00010003,0x00000000,0x00000000},0x0420,1,1022},
+ {{0x00010005,0x00000000,0x00000000},0x0440,1,1022},
+ {{0x00010003,0x00000000,0x00000000},0x0421,0,1864},
+ {{0x00010005,0x00000000,0x00000000},0x0441,0,1864},
+ {{0x00000000,0x00000000,0x00000000},0x212e,1,3524},
+ {{0x00000000,0x00000000,0x00000000},0x212e,1,3507},
+ {{0x00000001,0x00000000,0x00000000},0x20ac,1,3347},
+ {{0x00100000,0x00000800,0x00000000},0x203c,0,1292},
+ {{0x00000000,0x00000000,0x00000000},0x01ee,1,379},
+ {{0x00000000,0x00000000,0x00000000},0x01ef,1,379},
+ {{0x00000003,0x00000040,0x00000000},0x01b7,1,275},
+ {{0x00000005,0x00000040,0x00000000},0x0292,1,275},
+ {{0x00001003,0x00000040,0x00000000},0x01ee,1,275},
+ {{0x00001005,0x00000040,0x00000000},0x01ef,1,275},
+ {{0x00000201,0x00000000,0x00000000},0x3108,0,1556},
+ {{0x80000003,0x00000040,0x00000000},0x0191,0,1556},
+ {{0x80000005,0x00000040,0x00000000},0x0192,0,1556},
+ {{0x00000005,0x00040040,0x00000000},0x24a1,0,1556},
+ {{0x00004003,0x00000040,0x00000000},0x24bb,0,1556},
+ {{0x00004005,0x00000040,0x00000000},0x24d5,0,1556},
+ {{0x0008000b,0x00000040,0x00000000},0x1e1e,0,1556},
+ {{0x0008000d,0x00000040,0x00000000},0x1e1f,0,1556},
+ {{0x00000000,0x00000000,0x00000000},0x24bb,1,5333},
+ {{0x00000000,0x00000000,0x00000000},0x24d5,1,5333},
+ {{0x00000000,0x00000000,0x00000000},0x03a6,1,789},
+ {{0x00000000,0x00000000,0x00000000},0x03c6,1,789},
+ {{0x00000000,0x00000000,0x00000000},0x0641,1,1522},
+ {{0x00000000,0x00000000,0x00000000},0xfed3,1,7295},
+ {{0x00000000,0x00000000,0x00000000},0xfed1,1,7287},
+ {{0x00000000,0x00000000,0x00000000},0xfed2,1,7291},
+ {{0x00000000,0x00000000,0x00000000},0xfed4,1,7299},
+ {{0x00000000,0x00000000,0x00000000},0x1e1e,1,1783},
+ {{0x00000000,0x00000000,0x00000000},0x1e1f,1,1783},
+ {{0x00000000,0x00000000,0x00000000},0x0191,1,254},
+ {{0x00000000,0x00000000,0x00000000},0x0192,1,254},
+ {{0x00000000,0x00000000,0x00000000},0x0472,1,1140},
+ {{0x00000000,0x00000000,0x00000000},0x0473,1,1140},
+ {{0x00000000,0x00000000,0x00000000},0x3108,1,6799},
+ {{0x00000000,0x00000000,0x00000000},0x0424,1,1043},
+ {{0x00000000,0x00000000,0x00000000},0x0444,1,1043},
+ {{0x00000000,0x00000000,0x00000000},0x2200,1,4035},
+ {{0x00000080,0x00000000,0x00000000},0x064e,1,1602},
+ {{0x00000080,0x00000000,0x00000000},0x064b,1,1566},
+ {{0x00000000,0x00000000,0x00000000},0x2588,1,5692},
+ {{0x00000000,0x00000000,0x00000000},0x2571,1,5646},
+ {{0x00000000,0x00000000,0x00000000},0x25e2,1,5646},
+ {{0x00000081,0x00000000,0x00000000},0x0641,1,1518},
+ {{0x00000081,0x00000010,0x00000000},0xfed1,1,1518},
+ {{0x01000081,0x00000000,0x00000000},0xfed2,1,1518},
+ {{0x00000081,0x00000004,0x00000000},0xfed3,1,1518},
+ {{0x00000081,0x00001000,0x00000000},0xfed4,1,1518},
+ {{0x00000001,0x00000000,0x00000000},0x2640,1,6115},
+ {{0x00000000,0x00000000,0x00000000},0xfb00,0,883},
+ {{0x00000004,0x00000040,0x00000100},0xfb00,0,883},
+ {{0x00000000,0x00000000,0x00000000},0xfb03,1,6966},
+ {{0x00000004,0x00000040,0x00000100},0xfb03,1,6966},
+ {{0x00000000,0x00000000,0x00000000},0xfb04,1,6970},
+ {{0x00000004,0x00000040,0x00000100},0xfb04,1,6970},
+ {{0x00000000,0x00000000,0x00000000},0xfb01,1,6960},
+ {{0x00000004,0x00000040,0x00000100},0xfb01,1,6960},
+ {{0x00004000,0x00002000,0x00000000},0x246e,1,4966},
+ {{0x00000000,0x00042000,0x00000000},0x2482,1,4966},
+ {{0x02000000,0x00002000,0x00000002},0x2496,1,4966},
+ {{0x00000000,0x00010000,0x00000018},0x2155,1,3551},
+ {{0x00000000,0x00804000,0x00000000},0x216c,1,3740},
+ {{0x00000004,0x00804000,0x00000000},0x217c,1,3740},
+ {{0x00000001,0x00000001,0x00000080},0x25a4,1,5773},
+ {{0x00000001,0x40000000,0x00000080},0x25a5,1,5773},
+ {{0x00010003,0x00000000,0x00000000},0x0472,1,1135},
+ {{0x00010005,0x00000000,0x00000000},0x0473,1,1135},
+ {{0x00000000,0x00000000,0x00000020},0x2075,0,1455},
+ {{0x00000000,0x00000000,0x00000040},0x2085,0,1455},
+ {{0x00004001,0x00000000,0x00000000},0x2464,0,1455},
+ {{0x00000001,0x00040000,0x00000000},0x2478,0,1455},
+ {{0x00000081,0x00000000,0x00000400},0x0665,0,1455},
+ {{0x00000000,0x00804000,0x00000000},0x2164,0,1455},
+ {{0x02000001,0x00000000,0x00000002},0x248c,0,1455},
+ {{0x00000000,0x00040000,0x00000800},0x3224,0,1455},
+ {{0x00000004,0x00804000,0x00000000},0x2174,0,1455},
+ {{0x00000000,0x00000000,0x00000018},0x215d,1,3656},
+ {{0x00000000,0x00804000,0x00000000},0x216e,1,3763},
+ {{0x00000004,0x00804000,0x00000000},0x217e,1,3763},
+ {{0x00000000,0x00000000,0x00000018},0x215a,1,3614},
+ {{0x00000000,0x00804000,0x00000000},0x2181,1,3817},
+ {{0x00000000,0x00000000,0x00000000},0xfb02,1,6963},
+ {{0x00000004,0x00000040,0x00000100},0xfb02,1,6963},
+ {{0x00000000,0x00000080,0x00000000},0x230a,1,4657},
+ {{0x00000000,0x00400000,0x00000000},0x230b,1,4657},
+ {{0x00000000,0x00000000,0x00000000},0x2640,1,6122},
+ {{0x00000000,0x00000000,0x00000000},0x2200,1,4027},
+ {{0x00000000,0x00000000,0x00040000},0x2442,1,4802},
+ {{0x00000000,0x00000000,0x00840000},0x2443,1,4802},
+ {{0x00000000,0x00000000,0x00000020},0x2074,0,1450},
+ {{0x00000000,0x00000000,0x00000040},0x2084,0,1450},
+ {{0x00004001,0x00000000,0x00000000},0x2463,0,1450},
+ {{0x00000001,0x00040000,0x00000000},0x2477,0,1450},
+ {{0x00000081,0x00000000,0x00000400},0x0664,0,1450},
+ {{0x00000000,0x00804000,0x00000000},0x2163,0,1450},
+ {{0x02000001,0x00000000,0x00000002},0x248b,0,1450},
+ {{0x00000000,0x00040000,0x00000800},0x3223,0,1450},
+ {{0x00000004,0x00804000,0x00000000},0x2173,0,1450},
+ {{0x00000000,0x00000000,0x00000018},0x2158,1,3590},
+ {{0x00000000,0x00000000,0x00000200},0x2005,1,2841},
+ {{0x00004000,0x00002000,0x00000000},0x246d,1,4952},
+ {{0x00000000,0x00042000,0x00000000},0x2481,1,4952},
+ {{0x02000000,0x00002000,0x00000002},0x2495,1,4952},
+ {{0x00000000,0x00000000,0x00000000},0x220e,1,4143},
+ {{0x00000001,0x00000000,0x00000000},0x20a3,1,3315},
+ {{0x00000000,0x00000000,0x00000000},0x25a0,0,1206},
+ {{0x00000201,0x00000000,0x00000000},0x310d,0,1558},
+ {{0x00008003,0x00000040,0x00000000},0x011c,0,1558},
+ {{0x00008005,0x00000040,0x00000000},0x011d,0,1558},
+ {{0x00000803,0x00000040,0x00000000},0x011e,0,1558},
+ {{0x00000805,0x00000040,0x00000000},0x011f,0,1558},
+ {{0x00002003,0x00000040,0x00000000},0x0122,0,1558},
+ {{0x00002005,0x00000040,0x00000000},0x0123,0,1558},
+ {{0x00000003,0x00000040,0x10000000},0x01e4,0,1558},
+ {{0x00000005,0x00000040,0x10000000},0x01e5,0,1558},
+ {{0x00001003,0x00000040,0x00000000},0x01e6,0,1558},
+ {{0x00001005,0x00000040,0x00000000},0x01e7,0,1558},
+ {{0x00000013,0x00000040,0x00000000},0x01f4,0,1558},
+ {{0x00000015,0x00000040,0x00000000},0x01f5,0,1558},
+ {{0x00000003,0x00000440,0x00000000},0x1e20,0,1558},
+ {{0x00000005,0x00000440,0x00000000},0x1e21,0,1558},
+ {{0x00000005,0x00040040,0x00000000},0x24a2,0,1558},
+ {{0x00004003,0x00000040,0x00000000},0x24bc,0,1558},
+ {{0x00004005,0x00000040,0x00000000},0x24d6,0,1558},
+ {{0x0008000b,0x00000040,0x00000000},0x0120,0,1558},
+ {{0x0008000d,0x00000040,0x00000000},0x0121,0,1558},
+ {{0x00000000,0x00000000,0x00000000},0x24bc,1,5337},
+ {{0x00000000,0x00000000,0x00000000},0x24d6,1,5337},
+ {{0x00000000,0x00000000,0x00000000},0x0403,1,889},
+ {{0x00000000,0x00000000,0x00000000},0x0453,1,889},
+ {{0x00000000,0x00000000,0x00000000},0x01f4,1,389},
+ {{0x00000000,0x00000000,0x00000000},0x01f5,1,389},
+ {{0x00000000,0x00000000,0x00000000},0x011e,1,45},
+ {{0x00000000,0x00000000,0x00000000},0x011f,1,45},
+ {{0x00000000,0x00000000,0x00000000},0x0393,1,682},
+ {{0x00000000,0x00000000,0x00000000},0x03b3,1,682},
+ {{0x00000000,0x00000000,0x00000000},0x05d2,1,1176},
+ {{0x00000000,0x00000000,0x00000000},0x062c,1,1176},
+ {{0x00000000,0x00000000,0x00000000},0xfe9f,1,7087},
+ {{0x00000000,0x00000000,0x00000000},0xfe9d,1,7079},
+ {{0x00000000,0x00000000,0x00000000},0xfe9e,1,7083},
+ {{0x00000000,0x00000000,0x00000000},0xfea0,1,7091},
+ {{0x00000000,0x00000000,0x00000000},0x0122,1,51},
+ {{0x00000000,0x00000000,0x00000000},0x0123,1,51},
+ {{0x00000000,0x00000000,0x00000000},0x1e20,1,1786},
+ {{0x00000000,0x00000000,0x00000000},0x1e21,1,1786},
+ {{0x00000000,0x00000000,0x00000000},0x0120,1,48},
+ {{0x00000000,0x00000000,0x00000000},0x0121,1,48},
+ {{0x00000000,0x00000000,0x00000000},0x01e4,1,364},
+ {{0x00000000,0x00000000,0x00000000},0x01e5,1,364},
+ {{0x00000000,0x00000000,0x00000000},0x0490,1,1157},
+ {{0x00000000,0x00000000,0x00000000},0x0491,1,1157},
+ {{0x00000000,0x00000000,0x00000000},0x310d,1,6811},
+ {{0x00000000,0x00000000,0x00000000},0x01e6,1,367},
+ {{0x00000000,0x00000000,0x00000000},0x01e7,1,367},
+ {{0x00000000,0x00000000,0x00000000},0x0413,1,961},
+ {{0x00000000,0x00000000,0x00000000},0x0433,1,961},
+ {{0x00000000,0x00000000,0x00000000},0x011c,1,42},
+ {{0x00000000,0x00000000,0x00000000},0x011d,1,42},
+ {{0x40000001,0x00000000,0x00000000},0x304c,1,6558},
+ {{0x00000001,0x00000020,0x00000000},0x30ac,1,6558},
+ {{0x00000081,0x00000000,0x00000000},0x06af,1,1721},
+ {{0x08000003,0x00000000,0x00000000},0x0393,1,676},
+ {{0x08000005,0x00000000,0x00000000},0x03b3,1,676},
+ {{0x40000001,0x00000000,0x00000000},0x3052,1,6576},
+ {{0x00000001,0x00000020,0x00000000},0x30b2,1,6576},
+ {{0x00000000,0x00000800,0x00000000},0x3013,1,6478},
+ {{0x00000000,0x00000000,0x00000000},0x06af,1,1725},
+ {{0x00000081,0x00000000,0x00000000},0x063a,1,1498},
+ {{0x00000081,0x00000010,0x00000000},0xfecd,1,1498},
+ {{0x01000081,0x00000000,0x00000000},0xfece,1,1498},
+ {{0x00000081,0x00000004,0x00000000},0xfecf,1,1498},
+ {{0x00000081,0x00001000,0x00000000},0xfed0,1,1498},
+ {{0x00010003,0x00000000,0x00000000},0x0413,1,957},
+ {{0x00010005,0x00000000,0x00000000},0x0433,1,957},
+ {{0x00010003,0x00000000,0x80000000},0x0490,1,957},
+ {{0x00010005,0x00000000,0x80000000},0x0491,1,957},
+ {{0x40000001,0x00000000,0x00000000},0x304e,1,6564},
+ {{0x00000001,0x00000020,0x00000000},0x30ae,1,6564},
+ {{0x20000001,0x00000000,0x00000000},0x05d2,1,1170},
+ {{0x00010003,0x00000000,0x00000000},0x0403,1,885},
+ {{0x00010005,0x00000000,0x00000000},0x0453,1,885},
+ {{0x00000201,0x00000000,0x00000000},0x312c,1,6879},
+ {{0x40000001,0x00000000,0x00000000},0x3054,1,6582},
+ {{0x00000001,0x00000020,0x00000000},0x30b4,1,6582},
+ {{0x00000000,0x04000000,0x00015000},0x2265,0,1509},
+ {{0x40000001,0x00000000,0x00000000},0x3050,1,6570},
+ {{0x00000001,0x00000020,0x00000000},0x30b0,1,6570},
+ {{0x00000201,0x00000000,0x00000000},0x310f,0,1560},
+ {{0x00008003,0x00000040,0x00000000},0x0124,0,1560},
+ {{0x00008005,0x00000040,0x00000000},0x0125,0,1560},
+ {{0x00000003,0x00000040,0x10000000},0x0126,0,1560},
+ {{0x00000005,0x00000040,0x10000000},0x0127,0,1560},
+ {{0x00040003,0x00000040,0x00000000},0x1e26,0,1560},
+ {{0x00040005,0x00000040,0x00000000},0x1e27,0,1560},
+ {{0x00002003,0x00000040,0x00000000},0x1e28,0,1560},
+ {{0x00002005,0x00000040,0x00000000},0x1e29,0,1560},
+ {{0x00000005,0x00040040,0x00000000},0x24a3,0,1560},
+ {{0x00004003,0x00000040,0x00000000},0x24bd,0,1560},
+ {{0x00004005,0x00000040,0x00000000},0x24d7,0,1560},
+ {{0x0008000b,0x00000040,0x00000000},0x1e22,0,1560},
+ {{0x0008000d,0x00000040,0x00000000},0x1e23,0,1560},
+ {{0x00080103,0x00000040,0x00000000},0x1e24,0,1560},
+ {{0x00080105,0x00000040,0x00000000},0x1e25,0,1560},
+ {{0x00000903,0x00000040,0x00000000},0x1e2a,0,1560},
+ {{0x00000905,0x00000040,0x00000000},0x1e2b,0,1560},
+ {{0x00000000,0x00000000,0x00000000},0x24bd,1,5341},
+ {{0x00000000,0x00000000,0x00000000},0x24d7,1,5341},
+ {{0x00000000,0x00000000,0x00000000},0x0621,1,1345},
+ {{0x00000000,0x00000000,0x00000000},0xfe80,1,6987},
+ {{0x00000000,0x00000000,0x00000000},0x0398,1,714},
+ {{0x00000000,0x00000000,0x00000000},0x03b8,1,714},
+ {{0x00000000,0x00000000,0x00000000},0x05d4,1,1191},
+ {{0x00000000,0x00000000,0x00000000},0x0647,1,1191},
+ {{0x00000000,0x00000000,0x00000000},0xfeeb,1,7391},
+ {{0x00000000,0x00000000,0x00000000},0xfee9,1,7383},
+ {{0x00000000,0x00000000,0x00000000},0xfeea,1,7387},
+ {{0x00000000,0x00000000,0x00000000},0xfeec,1,7395},
+ {{0x00000000,0x00000000,0x00000000},0x1e28,1,1799},
+ {{0x00000000,0x00000000,0x00000000},0x1e29,1,1799},
+ {{0x00000000,0x00000000,0x00000000},0x1e2a,1,1802},
+ {{0x00000000,0x00000000,0x00000000},0x1e2b,1,1802},
+ {{0x00000000,0x00000000,0x00000000},0x1e24,1,1792},
+ {{0x00000000,0x00000000,0x00000000},0x1e25,1,1792},
+ {{0x00000000,0x00000000,0x00000000},0x1e22,1,1789},
+ {{0x00000000,0x00000000,0x00000000},0x1e23,1,1789},
+ {{0x00000000,0x00000000,0x00000000},0x0126,1,57},
+ {{0x00000000,0x00000000,0x00000000},0x0127,1,57},
+ {{0x00000000,0x00000000,0x00000000},0x310f,1,6817},
+ {{0x00000000,0x00000000,0x00000000},0x1e26,1,1796},
+ {{0x00000000,0x00000000,0x00000000},0x1e27,1,1796},
+ {{0x00000000,0x00000000,0x00000000},0x0425,1,1049},
+ {{0x00000000,0x00000000,0x00000000},0x0445,1,1049},
+ {{0x00000000,0x00000000,0x00000000},0x0124,1,54},
+ {{0x00000000,0x00000000,0x00000000},0x0125,1,54},
+ {{0x40000001,0x00000000,0x00000000},0x306f,1,1046},
+ {{0x00000001,0x00000020,0x00000000},0x30cf,1,1046},
+ {{0x00010003,0x00000000,0x00000000},0x0425,1,1046},
+ {{0x00010005,0x00000000,0x00000000},0x0445,1,1046},
+ {{0x00000081,0x00000000,0x00000000},0x062d,1,1422},
+ {{0x00000081,0x00000010,0x00000000},0xfea1,1,1422},
+ {{0x01000081,0x00000000,0x00000000},0xfea2,1,1422},
+ {{0x00000081,0x00000004,0x00000000},0xfea3,1,1422},
+ {{0x00000081,0x00001000,0x00000000},0xfea4,1,1422},
+ {{0x00000089,0x00000000,0x00000000},0x0681,1,1688},
+ {{0x00000000,0x00000000,0x00000200},0x200a,1,2878},
+ {{0x00000081,0x00000000,0x00000000},0x0621,1,1339},
+ {{0x00000081,0x00000010,0x00000000},0xfe80,1,1339},
+ {{0x000000a9,0x00000000,0x00000000},0x0623,1,1339},
+ {{0x000001a1,0x00000000,0x00000000},0x0625,1,1339},
+ {{0x000000a9,0x00000010,0x00000000},0xfe83,1,1339},
+ {{0x010000a9,0x00000000,0x00000000},0xfe84,1,1339},
+ {{0x010001a1,0x00000000,0x00000000},0xfe88,1,1339},
+ {{0x00000000,0x00040000,0x00000000},0x321c,1,6882},
+ {{0x00010003,0x00000000,0x00000000},0x042a,1,1079},
+ {{0x00010005,0x00000000,0x00000000},0x044a,1,1079},
+ {{0x20000001,0x00000000,0x00000000},0x05d4,1,1188},
+ {{0x40000001,0x00000000,0x00000000},0x3078,1,1188},
+ {{0x00000001,0x00000020,0x00000000},0x30d8,1,1188},
+ {{0x00000000,0x80000000,0x00008000},0x2661,1,6142},
+ {{0x00000000,0x00000000,0x00008004},0x2665,1,6142},
+ {{0x00000081,0x00000000,0x00000000},0x0647,1,1543},
+ {{0x00000081,0x00000010,0x00000000},0xfee9,1,1543},
+ {{0x01000081,0x00000000,0x00000000},0xfeea,1,1543},
+ {{0x00000081,0x00000004,0x00000000},0xfeeb,1,1543},
+ {{0x00000081,0x00001000,0x00000000},0xfeec,1,1543},
+ {{0x20000001,0x00000000,0x00000000},0x05d7,1,1210},
+ {{0x00000000,0x00000000,0x00000000},0x0681,1,1698},
+ {{0x00000000,0x00000000,0x00000000},0x2500,1,1698},
+ {{0x00000000,0x00000000,0x00000000},0x2550,1,1698},
+ {{0x00000000,0x00000000,0x00000000},0x2501,1,5424},
+ {{0x00000000,0x00000000,0x00000000},0x2253,1,4505},
+ {{0x40000001,0x00000000,0x00000000},0x3072,1,4505},
+ {{0x00000001,0x00000020,0x00000000},0x30d2,1,4505},
+ {{0x00000000,0x01000800,0x00000000},0x201b,1,2948},
+ {{0x00100000,0x00000800,0x00000000},0x201f,1,2948},
+ {{0x00000000,0x00000000,0x00000000},0x062d,1,1426},
+ {{0x00000000,0x00000000,0x00000000},0xfea3,1,7103},
+ {{0x00000000,0x00000000,0x00000000},0xfea1,1,7095},
+ {{0x00000000,0x00000000,0x00000000},0xfea2,1,7099},
+ {{0x00000000,0x00000000,0x00000000},0xfea4,1,7107},
+ {{0x40000001,0x00000000,0x00000000},0x307b,0,1742},
+ {{0x00000001,0x00000020,0x00000000},0x30db,0,1742},
+ {{0x00000000,0x00000000,0x00000000},0x2302,1,4634},
+ {{0x40000001,0x00000000,0x00000000},0x3075,1,6624},
+ {{0x00000001,0x00000020,0x00000000},0x30d5,1,6624},
+ {{0x00000000,0x00814000,0x00000000},0x216d,1,3750},
+ {{0x00000004,0x00814000,0x00000000},0x217d,1,3750},
+ {{0x00000000,0x00000000,0x00000000},0x2010,0,1407},
+ {{0x00000000,0x00000000,0x00000000},0x2043,1,3253},
+ {{0x00000000,0x00000000,0x00000000},0x2027,1,3056},
+ {{0x40000001,0x00000000,0x00000000},0x3044,0,1562},
+ {{0x00000001,0x00000020,0x00000000},0x30a4,0,1562},
+ {{0x00000201,0x00000000,0x00000000},0x3127,0,1562},
+ {{0x00010003,0x00000000,0x00000000},0x0418,0,1562},
+ {{0x00010005,0x00000000,0x00000000},0x0438,0,1562},
+ {{0x40000005,0x00000000,0x00000000},0x3043,0,1562},
+ {{0x00000005,0x00000020,0x00000000},0x30a3,0,1562},
+ {{0x00000003,0x02000040,0x00000000},0x0128,0,1562},
+ {{0x00000005,0x02000040,0x00000000},0x0129,0,1562},
+ {{0x00000003,0x00000440,0x00000000},0x012a,0,1562},
+ {{0x00000005,0x00000440,0x00000000},0x012b,0,1562},
+ {{0x00000803,0x00000040,0x00000000},0x012c,0,1562},
+ {{0x00000805,0x00000040,0x00000000},0x012d,0,1562},
+ {{0x00000003,0x00000040,0x02000000},0x012e,0,1562},
+ {{0x00000005,0x00000040,0x02000000},0x012f,0,1562},
+ {{0x00001003,0x00000040,0x00000000},0x01cf,0,1562},
+ {{0x00001005,0x00000040,0x00000000},0x01d0,0,1562},
+ {{0x00010003,0x00000000,0x08000000},0x0419,0,1562},
+ {{0x00010005,0x00000000,0x08000000},0x0439,0,1562},
+ {{0x00000005,0x00040040,0x00000000},0x24a4,0,1562},
+ {{0x00004003,0x00000040,0x00000000},0x24be,0,1562},
+ {{0x00004005,0x00000040,0x00000000},0x24d8,0,1562},
+ {{0x0008000b,0x00000040,0x00000000},0x0130,0,1562},
+ {{0x04100003,0x00000040,0x00000000},0x0208,0,1562},
+ {{0x04100005,0x00000040,0x00000000},0x0209,0,1562},
+ {{0x00000803,0x00000040,0x00800000},0x020a,0,1562},
+ {{0x00000805,0x00000040,0x00800000},0x020b,0,1562},
+ {{0x00010003,0x00000000,0x40400000},0x0406,0,1562},
+ {{0x00010005,0x00000000,0x40400000},0x0456,0,1562},
+ {{0x00000103,0x02000040,0x00000000},0x1e2c,0,1562},
+ {{0x00000105,0x02000040,0x00000000},0x1e2d,0,1562},
+ {{0x00040013,0x00000040,0x00000000},0x1e2e,0,1562},
+ {{0x00040015,0x00000040,0x00000000},0x1e2f,0,1562},
+ {{0x8000000b,0x00000040,0x00000000},0x1ec8,0,1562},
+ {{0x8000000d,0x00000040,0x00000000},0x1ec9,0,1562},
+ {{0x00080103,0x00000040,0x00000000},0x1eca,0,1562},
+ {{0x00080105,0x00000040,0x00000000},0x1ecb,0,1562},
+ {{0x00000000,0x00000000,0x00000000},0x24be,1,5345},
+ {{0x00000000,0x00000000,0x00000000},0x24d8,1,5345},
+ {{0x00000000,0x00000000,0x00000000},0x0208,1,418},
+ {{0x00000000,0x00000000,0x00000000},0x0209,1,418},
+ {{0x00000000,0x00000000,0x00000000},0x038a,1,642},
+ {{0x00000000,0x00000000,0x00000000},0x03af,1,642},
+ {{0x00000000,0x00000000,0x00000000},0x012c,1,66},
+ {{0x00000000,0x00000000,0x00000000},0x012d,1,66},
+ {{0x00000000,0x00000000,0x00000000},0x020a,1,422},
+ {{0x00000000,0x00000000,0x00000000},0x020b,1,422},
+ {{0x00000000,0x00000000,0x00000000},0x0399,1,717},
+ {{0x00000000,0x00000000,0x00000000},0x03b9,1,717},
+ {{0x00000000,0x00000000,0x00000000},0x1f76,1,2445},
+ {{0x00000000,0x00000000,0x00000000},0x1fda,1,2445},
+ {{0x00000000,0x00000000,0x00000000},0x1f77,1,2449},
+ {{0x00000000,0x00000000,0x00000000},0x1fdb,1,2449},
+ {{0x00000000,0x00000000,0x00000000},0x1fd0,1,2710},
+ {{0x00000000,0x00000000,0x00000000},0x1fd8,1,2710},
+ {{0x00000000,0x00000000,0x00000000},0x1f30,1,2279},
+ {{0x00000000,0x00000000,0x00000000},0x1f38,1,2279},
+ {{0x00000000,0x00000000,0x00000000},0x1f32,1,2287},
+ {{0x00000000,0x00000000,0x00000000},0x1f3a,1,2287},
+ {{0x00000000,0x00000000,0x00000000},0x1f34,1,2297},
+ {{0x00000000,0x00000000,0x00000000},0x1f3c,1,2297},
+ {{0x00000000,0x00000000,0x00000000},0x1f36,1,2307},
+ {{0x00000000,0x00000000,0x00000000},0x1f3e,1,2307},
+ {{0x00000000,0x00000000,0x00000000},0x1fd1,1,2714},
+ {{0x00000000,0x00000000,0x00000000},0x1fd9,1,2714},
+ {{0x00000000,0x00000000,0x00000000},0x1fd2,1,2718},
+ {{0x00000000,0x00000000,0x00000000},0x1fd3,1,2723},
+ {{0x00000000,0x00000000,0x00000000},0x1fd7,1,2732},
+ {{0x00000000,0x00000000,0x00000000},0x1f31,1,2283},
+ {{0x00000000,0x00000000,0x00000000},0x1f39,1,2283},
+ {{0x00000000,0x00000000,0x00000000},0x1f33,1,2292},
+ {{0x00000000,0x00000000,0x00000000},0x1f3b,1,2292},
+ {{0x00000000,0x00000000,0x00000000},0x1f35,1,2302},
+ {{0x00000000,0x00000000,0x00000000},0x1f3d,1,2302},
+ {{0x00000000,0x00000000,0x00000000},0x1f37,1,2312},
+ {{0x00000000,0x00000000,0x00000000},0x1f3f,1,2312},
+ {{0x00000000,0x00000000,0x00000000},0x1fd6,1,2728},
+ {{0x00000000,0x00000000,0x00000000},0x063a,1,1504},
+ {{0x00000000,0x00000000,0x00000000},0xfecf,1,7279},
+ {{0x00000000,0x00000000,0x00000000},0xfecd,1,7271},
+ {{0x00000000,0x00000000,0x00000000},0xfece,1,7275},
+ {{0x00000000,0x00000000,0x00000000},0xfed0,1,7283},
+ {{0x00000000,0x00000000,0x00000000},0x012a,1,63},
+ {{0x00000000,0x00000000,0x00000000},0x012b,1,63},
+ {{0x00000000,0x00000000,0x00000000},0x1eca,1,2081},
+ {{0x00000000,0x00000000,0x00000000},0x1ecb,1,2081},
+ {{0x00000000,0x00000000,0x00000000},0x1e2c,1,1806},
+ {{0x00000000,0x00000000,0x00000000},0x1e2d,1,1806},
+ {{0x00000000,0x00000000,0x00000000},0x0130,1,72},
+ {{0x00000000,0x00000000,0x00000000},0x0131,1,72},
+ {{0x00000000,0x00000000,0x00000000},0x1ec8,1,2078},
+ {{0x00000000,0x00000000,0x00000000},0x1ec9,1,2078},
+ {{0x00000000,0x00000000,0x00000000},0x0390,1,662},
+ {{0x00000000,0x00000000,0x00000000},0x3127,1,6870},
+ {{0x00000000,0x00000000,0x00000000},0x3043,1,6546},
+ {{0x00000000,0x00000000,0x00000000},0x3044,1,6546},
+ {{0x00000000,0x00000000,0x00000000},0x30a3,1,6738},
+ {{0x00000000,0x00000000,0x00000000},0x30a4,1,6738},
+ {{0x00000000,0x00000000,0x00000000},0x1e2e,1,1810},
+ {{0x00000000,0x00000000,0x00000000},0x1e2f,1,1810},
+ {{0x00000000,0x00000000,0x00000000},0x012e,1,69},
+ {{0x00000000,0x00000000,0x00000000},0x012f,1,69},
+ {{0x00000000,0x00000000,0x00000000},0x01cf,1,318},
+ {{0x00000000,0x00000000,0x00000000},0x01d0,1,318},
+ {{0x00000000,0x00000000,0x00000000},0x0418,1,986},
+ {{0x00000000,0x00000000,0x00000000},0x0438,1,986},
+ {{0x00000000,0x00000000,0x00000000},0x0128,1,60},
+ {{0x00000000,0x00000000,0x00000000},0x0129,1,60},
+ {{0x00000000,0x00000000,0x00000000},0x25d9,1,6005},
+ {{0x00000000,0x04000000,0x00000000},0x2261,1,4511},
+ {{0x00000000,0x00000000,0x00000000},0x0404,1,892},
+ {{0x00000000,0x00000000,0x00000000},0x0454,1,892},
+ {{0x00010003,0x00000000,0x00000000},0x0415,1,892},
+ {{0x00010005,0x00000000,0x00000000},0x0435,1,892},
+ {{0x00010003,0x00000000,0x40000000},0x0404,1,892},
+ {{0x00010005,0x00000000,0x40000000},0x0454,1,892},
+ {{0x00000000,0x00000000,0x00000000},0x0406,1,902},
+ {{0x00000000,0x00000000,0x00000000},0x0456,1,902},
+ {{0x00000000,0x00000000,0x00000000},0x0132,1,85},
+ {{0x00000000,0x00000000,0x00000000},0x0133,1,85},
+ {{0x00000002,0x00000040,0x00000100},0x0132,1,85},
+ {{0x00000004,0x00000040,0x00000100},0x0133,1,85},
+ {{0x00000000,0x00000000,0x00000000},0x2321,1,4764},
+ {{0x00000000,0x04000000,0x00011001},0x2253,1,4485},
+ {{0x00000000,0x00000000,0x00000000},0x222b,0,1804},
+ {{0x00000000,0x00000000,0x00000000},0x2206,1,4088},
+ {{0x00000000,0x00000000,0x00000000},0x221e,1,4275},
+ {{0x00000000,0x00000000,0x00000000},0x222b,1,4344},
+ {{0x00100000,0x00000000,0x00000000},0x222c,1,4344},
+ {{0x00000000,0x00000000,0x00000000},0x2229,1,4319},
+ {{0x00000000,0x00000000,0x00000000},0x25d8,1,5975},
+ {{0x00000000,0x80000000,0x00000000},0x25d9,1,5990},
+ {{0x00000000,0x00000000,0x00000000},0x0401,1,875},
+ {{0x00000000,0x00000000,0x00000000},0x0451,1,875},
+ {{0x00000000,0x00000000,0x00000000},0x222e,1,875},
+ {{0x00010003,0x00000000,0x00000000},0x0401,1,875},
+ {{0x00010005,0x00000000,0x00000000},0x0451,1,875},
+ {{0x00000000,0x00000000,0x00000000},0x3000,1,6341},
+ {{0x00000000,0x00000800,0x00000800},0x3005,1,6399},
+ {{0x40000000,0x00000800,0x00000000},0x309d,1,6399},
+ {{0x00000000,0x00000820,0x00000000},0x30fd,1,6399},
+ {{0x00000000,0x00000000,0x00000000},0x2320,1,4745},
+ {{0x00000201,0x00000000,0x00000000},0x3129,1,4745},
+ {{0x00010003,0x00000000,0x00000000},0x0474,1,1143},
+ {{0x00010005,0x00000000,0x00000000},0x0475,1,1143},
+ {{0x00000201,0x00000000,0x00000000},0x3110,0,1564},
+ {{0x00008003,0x00000040,0x00000000},0x0134,0,1564},
+ {{0x00008005,0x00000040,0x00000000},0x0135,0,1564},
+ {{0x00001005,0x00000040,0x00000000},0x01f0,0,1564},
+ {{0x00000005,0x00040040,0x00000000},0x24a5,0,1564},
+ {{0x00004003,0x00000040,0x00000000},0x24bf,0,1564},
+ {{0x00004005,0x00000040,0x00000000},0x24d9,0,1564},
+ {{0x00000000,0x00000000,0x00000000},0x24bf,1,5349},
+ {{0x00000000,0x00000000,0x00000000},0x24d9,1,5349},
+ {{0x00000000,0x00000000,0x00000000},0x0408,1,911},
+ {{0x00000000,0x00000000,0x00000000},0x0458,1,911},
+ {{0x00000000,0x00000000,0x00000000},0x03aa,1,809},
+ {{0x00000000,0x00000000,0x00000000},0x03ca,1,809},
+ {{0x00000000,0x00000000,0x00000000},0x05d9,1,1228},
+ {{0x00000000,0x00000000,0x00000000},0x0649,1,1228},
+ {{0x00000000,0x00000000,0x00000000},0xfeef,1,7407},
+ {{0x00000000,0x00000000,0x00000000},0xfef0,1,7411},
+ {{0x00000000,0x00000000,0x00000000},0x037a,1,589},
+ {{0x00000000,0x00000000,0x00000000},0x1fbe,1,589},
+ {{0x00000000,0x00000000,0x00000000},0x3110,1,6820},
+ {{0x00000000,0x00000000,0x00000000},0x01f0,1,382},
+ {{0x00000000,0x00000000,0x00000000},0x0419,1,989},
+ {{0x00000000,0x00000000,0x00000000},0x0439,1,989},
+ {{0x00000000,0x00000000,0x00000000},0x0134,1,88},
+ {{0x00000000,0x00000000,0x00000000},0x0135,1,88},
+ {{0x00000000,0x00000000,0x00000000},0x042f,1,1112},
+ {{0x00000000,0x00000000,0x00000000},0x044f,1,1112},
+ {{0x00000000,0x00000000,0x00000000},0x3004,1,6359},
+ {{0x00000000,0x00000000,0x00000000},0x042d,1,908},
+ {{0x00000000,0x00000000,0x00000000},0x044d,1,908},
+ {{0x00010003,0x00000000,0x00000000},0x0408,1,908},
+ {{0x00010005,0x00000000,0x00000000},0x0458,1,908},
+ {{0x00000081,0x00000000,0x00000000},0x062c,1,1417},
+ {{0x00000081,0x00000010,0x00000000},0xfe9d,1,1417},
+ {{0x01000081,0x00000000,0x00000000},0xfe9e,1,1417},
+ {{0x00000081,0x00000004,0x00000000},0xfe9f,1,1417},
+ {{0x00000081,0x00001000,0x00000000},0xfea0,1,1417},
+ {{0x00000081,0x00000000,0x00000000},0x0698,1,1710},
+ {{0x00000000,0x00000000,0x00000000},0x3004,1,6395},
+ {{0x00000000,0x00000000,0x00000000},0x042e,1,1106},
+ {{0x00000000,0x00000000,0x00000000},0x044e,1,1106},
+ {{0x00000201,0x00000000,0x00000000},0x310e,0,1566},
+ {{0x00002003,0x00000040,0x00000000},0x0136,0,1566},
+ {{0x00002005,0x00000040,0x00000000},0x0137,0,1566},
+ {{0x80000003,0x00000040,0x00000000},0x0198,0,1566},
+ {{0x80000005,0x00000040,0x00000000},0x0199,0,1566},
+ {{0x00001003,0x00000040,0x00000000},0x01e8,0,1566},
+ {{0x00001005,0x00000040,0x00000000},0x01e9,0,1566},
+ {{0x00000013,0x00000040,0x00000000},0x1e30,0,1566},
+ {{0x00000015,0x00000040,0x00000000},0x1e31,0,1566},
+ {{0x00000005,0x00040040,0x00000000},0x24a6,0,1566},
+ {{0x00004003,0x00000040,0x00000000},0x24c0,0,1566},
+ {{0x00004005,0x00000040,0x00000000},0x24da,0,1566},
+ {{0x00080103,0x00000040,0x00000000},0x1e32,0,1566},
+ {{0x00080105,0x00000040,0x00000000},0x1e33,0,1566},
+ {{0x00000103,0x00000240,0x00000000},0x1e34,0,1566},
+ {{0x00000105,0x00000240,0x00000000},0x1e35,0,1566},
+ {{0x00000000,0x00000000,0x00000000},0x24c0,1,5353},
+ {{0x00000000,0x00000000,0x00000000},0x24da,1,5353},
+ {{0x00000000,0x00000000,0x00000000},0x05da,1,1235},
+ {{0x00000000,0x00000000,0x00000000},0x1e30,1,1814},
+ {{0x00000000,0x00000000,0x00000000},0x1e31,1,1814},
+ {{0x00000000,0x00000000,0x00000000},0x039a,1,726},
+ {{0x00000000,0x00000000,0x00000000},0x03ba,1,726},
+ {{0x00000000,0x00000000,0x00000000},0x05db,1,1238},
+ {{0x00000000,0x00000000,0x00000000},0x0643,1,1238},
+ {{0x00000000,0x00000000,0x00000000},0xfedb,1,7327},
+ {{0x00000000,0x00000000,0x00000000},0xfed9,1,7319},
+ {{0x00000000,0x00000000,0x00000000},0xfeda,1,7323},
+ {{0x00000000,0x00000000,0x00000000},0xfedc,1,7331},
+ {{0x00000000,0x00000000,0x00000000},0x0136,1,91},
+ {{0x00000000,0x00000000,0x00000000},0x0137,1,91},
+ {{0x00000000,0x00000000,0x00000000},0x1e32,1,1817},
+ {{0x00000000,0x00000000,0x00000000},0x1e33,1,1817},
+ {{0x00000000,0x00000000,0x00000000},0x0198,1,257},
+ {{0x00000000,0x00000000,0x00000000},0x0199,1,257},
+ {{0x00000000,0x00000000,0x00000000},0x03de,1,863},
+ {{0x00000000,0x00000000,0x00000000},0x310e,1,6814},
+ {{0x00000000,0x00000000,0x00000000},0x01e8,1,370},
+ {{0x00000000,0x00000000,0x00000000},0x01e9,1,370},
+ {{0x00000000,0x00000000,0x00000000},0x041a,1,995},
+ {{0x00000000,0x00000000,0x00000000},0x043a,1,995},
+ {{0x00000000,0x00000000,0x00000000},0x1e34,1,1821},
+ {{0x00000000,0x00000000,0x00000000},0x1e35,1,1821},
+ {{0x40000001,0x00000000,0x00000000},0x304b,1,992},
+ {{0x00000001,0x00000020,0x00000000},0x30ab,1,992},
+ {{0x00010003,0x00000000,0x00000000},0x041a,1,992},
+ {{0x00010005,0x00000000,0x00000000},0x043a,1,992},
+ {{0x00000005,0x00000020,0x00000000},0x30f5,1,992},
+ {{0x20000001,0x00000000,0x00000000},0x05db,1,1231},
+ {{0x00000081,0x00000000,0x00000000},0x0643,1,1231},
+ {{0x21000001,0x00000000,0x00000000},0x05da,1,1231},
+ {{0x00000081,0x00000010,0x00000000},0xfed9,1,1231},
+ {{0x01000081,0x00000000,0x00000000},0xfeda,1,1231},
+ {{0x00000081,0x00000004,0x00000000},0xfedb,1,1231},
+ {{0x00000081,0x00001000,0x00000000},0xfedc,1,1231},
+ {{0x08000003,0x00000000,0x00000000},0x039a,1,720},
+ {{0x08000005,0x00000000,0x00000000},0x03ba,1,720},
+ {{0x00000080,0x00000000,0x00000000},0x0650,1,1620},
+ {{0x00000080,0x00000000,0x00000000},0x064d,1,1590},
+ {{0x40000001,0x00000000,0x00000000},0x3051,1,6573},
+ {{0x00000001,0x00000020,0x00000000},0x30b1,1,6573},
+ {{0x00000005,0x00000020,0x00000000},0x30f6,1,6573},
+ {{0x00000081,0x00000000,0x00000000},0x062e,1,1429},
+ {{0x00000081,0x00000010,0x00000000},0xfea5,1,1429},
+ {{0x01000081,0x00000000,0x00000000},0xfea6,1,1429},
+ {{0x00000081,0x00000004,0x00000000},0xfea7,1,1429},
+ {{0x00000081,0x00001000,0x00000000},0xfea8,1,1429},
+ {{0x40000001,0x00000000,0x00000000},0x304d,1,6561},
+ {{0x00000001,0x00000020,0x00000000},0x30ad,1,6561},
+ {{0x00000000,0x00000000,0x00000000},0x040c,1,931},
+ {{0x00000000,0x00000000,0x00000000},0x045c,1,931},
+ {{0x00010003,0x00000000,0x00000000},0x040c,1,927},
+ {{0x00010005,0x00000000,0x00000000},0x045c,1,927},
+ {{0x00000000,0x00000000,0x00000000},0x0138,1,98},
+ {{0x40000001,0x00000000,0x00000000},0x3053,1,6579},
+ {{0x00000001,0x00000020,0x00000000},0x30b3,1,6579},
+ {{0x08000001,0x00000000,0x00000000},0x03de,1,857},
+ {{0x00010003,0x00000000,0x00000000},0x0480,1,857},
+ {{0x00010005,0x00000000,0x00000000},0x0481,1,857},
+ {{0x00000000,0x00000000,0x00000000},0x327f,1,6933},
+ {{0x08000000,0x00000000,0x00000000},0x1fbd,1,2653},
+ {{0x00000005,0x00000040,0x00000000},0x0138,1,94},
+ {{0x00000000,0x00000000,0x00000000},0x327f,1,6956},
+ {{0x40000001,0x00000000,0x00000000},0x304f,1,6567},
+ {{0x00000001,0x00000020,0x00000000},0x30af,1,6567},
+ {{0x00000201,0x00000000,0x00000000},0x310c,0,1568},
+ {{0x00000013,0x00000040,0x00000000},0x0139,0,1568},
+ {{0x00000015,0x00000040,0x00000000},0x013a,0,1568},
+ {{0x00002003,0x00000040,0x00000000},0x013b,0,1568},
+ {{0x00002005,0x00000040,0x00000000},0x013c,0,1568},
+ {{0x00001003,0x00000040,0x00000000},0x013d,0,1568},
+ {{0x00001005,0x00000040,0x00000000},0x013e,0,1568},
+ {{0x00000003,0x00000040,0x10000000},0x0141,0,1568},
+ {{0x00000005,0x00000040,0x10000000},0x0142,0,1568},
+ {{0x00000005,0x00040040,0x00000000},0x24a7,0,1568},
+ {{0x00004003,0x00000040,0x00000000},0x24c1,0,1568},
+ {{0x00004005,0x00000040,0x00000000},0x24db,0,1568},
+ {{0x00080003,0x00000040,0x01000000},0x013f,0,1568},
+ {{0x00080005,0x00000040,0x01000000},0x0140,0,1568},
+ {{0x00080103,0x00000040,0x00000000},0x1e36,0,1568},
+ {{0x00080105,0x00000040,0x00000000},0x1e37,0,1568},
+ {{0x00000103,0x00000240,0x00000000},0x1e3a,0,1568},
+ {{0x00000105,0x00000240,0x00000000},0x1e3b,0,1568},
+ {{0x00008103,0x00000040,0x00000000},0x1e3c,0,1568},
+ {{0x00008105,0x00000040,0x00000000},0x1e3d,0,1568},
+ {{0x00080103,0x00000440,0x00000000},0x1e38,0,1568},
+ {{0x00080105,0x00000440,0x00000000},0x1e39,0,1568},
+ {{0x00000007,0x00000040,0x00000000},0x01c8,1,300},
+ {{0x00000000,0x00000000,0x00000000},0x24c1,1,5357},
+ {{0x00000000,0x00000000,0x00000000},0x24db,1,5357},
+ {{0x00000000,0x00000000,0x00000000},0x0139,1,101},
+ {{0x00000000,0x00000000,0x00000000},0x013a,1,101},
+ {{0x00000000,0x00000000,0x00000000},0x039b,1,735},
+ {{0x00000000,0x00000000,0x00000000},0x03bb,1,735},
+ {{0x00000000,0x00000000,0x00000000},0x05dc,1,1247},
+ {{0x00000000,0x00000000,0x00000000},0x0644,1,1247},
+ {{0x00000000,0x00000000,0x00000000},0xfedf,1,7343},
+ {{0x00000000,0x00000000,0x00000000},0xfedd,1,7335},
+ {{0x00000000,0x00000000,0x00000000},0xfede,1,7339},
+ {{0x00000000,0x00000000,0x00000000},0xfee0,1,7347},
+ {{0x00000000,0x00000000,0x00000000},0x013b,1,104},
+ {{0x00000000,0x00000000,0x00000000},0x013c,1,104},
+ {{0x00000000,0x00000000,0x00000000},0x1e38,1,1828},
+ {{0x00000000,0x00000000,0x00000000},0x1e39,1,1828},
+ {{0x00000000,0x00000000,0x00000000},0x1e36,1,1824},
+ {{0x00000000,0x00000000,0x00000000},0x1e37,1,1824},
+ {{0x00000000,0x00000000,0x00000000},0x1e3c,1,1836},
+ {{0x00000000,0x00000000,0x00000000},0x1e3d,1,1836},
+ {{0x00000000,0x00000000,0x00000000},0x013f,1,110},
+ {{0x00000000,0x00000000,0x00000000},0x0140,1,110},
+ {{0x00000000,0x00000000,0x00000000},0x0141,1,113},
+ {{0x00000000,0x00000000,0x00000000},0x0142,1,113},
+ {{0x00000000,0x00000000,0x00000000},0x310c,1,6808},
+ {{0x00000000,0x00000000,0x00000000},0x013d,1,107},
+ {{0x00000000,0x00000000,0x00000000},0x013e,1,107},
+ {{0x00000000,0x00000000,0x00000000},0x041b,1,1001},
+ {{0x00000000,0x00000000,0x00000000},0x043b,1,1001},
+ {{0x00000000,0x00000000,0x00000000},0x1e3a,1,1833},
+ {{0x00000000,0x00000000,0x00000000},0x1e3b,1,1833},
+ {{0x00000000,0x00000000,0x00000000},0xfefb,1,7467},
+ {{0x00000000,0x00000000,0x00000000},0xfefc,1,7471},
+ {{0x00000081,0x00000000,0x00000000},0x0644,1,1529},
+ {{0x00000081,0x00000010,0x00000000},0xfedd,1,1529},
+ {{0x01000081,0x00000000,0x00000000},0xfede,1,1529},
+ {{0x00000081,0x00000004,0x00000000},0xfedf,1,1529},
+ {{0x00000081,0x00001000,0x00000000},0xfee0,1,1529},
+ {{0x000000a1,0x00000010,0x00000100},0xfefb,1,1529},
+ {{0x010000a1,0x00000000,0x00000100},0xfefc,1,1529},
+ {{0x000000a9,0x00000010,0x00000100},0xfef7,1,7449},
+ {{0x010000a9,0x00000000,0x00000100},0xfef8,1,7449},
+ {{0x000001a1,0x00000010,0x00000100},0xfef9,1,7449},
+ {{0x010001a1,0x00000000,0x00000100},0xfefa,1,7449},
+ {{0x000000a9,0x00000010,0x00000100},0xfef5,1,7431},
+ {{0x010000a9,0x00000000,0x00000100},0xfef6,1,7431},
+ {{0x08000003,0x00000000,0x00000000},0x039b,1,729},
+ {{0x08000005,0x00000000,0x00000000},0x03bb,1,729},
+ {{0x20000001,0x00000000,0x00000000},0x05dc,1,1241},
+ {{0x00000000,0x00000000,0x00000000},0x25ef,1,6028},
+ {{0x00000000,0x00000000,0x00800000},0x223e,1,4423},
+ {{0x00000000,0x00000000,0x00000000},0x2584,1,5683},
+ {{0x00000000,0x00000000,0x00000000},0x258c,1,5683},
+ {{0x00000000,0x00000000,0x00000000},0x2557,1,5622},
+ {{0x00000000,0x00000000,0x00000000},0x2513,1,5512},
+ {{0x00000000,0x00000000,0x00002000},0x2190,1,3857},
+ {{0x00100000,0x00000000,0x00002000},0x21d0,1,3857},
+ {{0x00000000,0x00000080,0x00020004},0x3010,1,6451},
+ {{0x00000000,0x00400000,0x00020004},0x3011,1,6451},
+ {{0x00000000,0x80000080,0x00020000},0x3016,1,6451},
+ {{0x00000000,0x80400000,0x00020000},0x3017,1,6451},
+ {{0x00000000,0x04000000,0x00015000},0x2264,0,1497},
+ {{0x00000000,0x00000000,0x00000000},0xfef7,1,7459},
+ {{0x00000000,0x00000000,0x00000000},0xfef9,1,7459},
+ {{0x00000000,0x00000000,0x00000000},0xfef8,1,7463},
+ {{0x00000000,0x00000000,0x00000000},0xfefa,1,7463},
+ {{0x00000000,0x00000000,0x00000000},0x2028,1,3087},
+ {{0x00000001,0x00000000,0x00000000},0x20a4,1,3328},
+ {{0x00000000,0x00000000,0x00000000},0x0409,1,293},
+ {{0x00000000,0x00000000,0x00000000},0x0459,1,293},
+ {{0x00000003,0x00000040,0x00000000},0x01c7,1,293},
+ {{0x00000005,0x00000040,0x00000000},0x01c9,1,293},
+ {{0x00000000,0x00000000,0x00000000},0x01c7,1,296},
+ {{0x00000000,0x00000000,0x00000000},0x01c8,1,296},
+ {{0x00000000,0x00000000,0x00000000},0x01c9,1,296},
+ {{0x00010003,0x00000000,0x00000000},0x0409,1,914},
+ {{0x00010005,0x00000000,0x00000000},0x0459,1,914},
+ {{0x00000000,0x00000000,0x00000000},0xfef5,1,7441},
+ {{0x00000000,0x00000000,0x00000000},0xfef6,1,7445},
+ {{0x00000001,0x00000000,0x00000000},0x2227,1,4308},
+ {{0x00000000,0x00000000,0x00010000},0x2228,1,4308},
+ {{0x00000005,0x00000040,0x00000000},0x017f,1,235},
+ {{0x00000004,0x00000040,0x00000100},0xfb05,1,6974},
+ {{0x00100000,0x00000200,0x00000000},0x2017,0,1641},
+ {{0x00000000,0x01000800,0x00000000},0x201a,1,2929},
+ {{0x00100000,0x00000800,0x00000000},0x201e,1,2929},
+ {{0x08000001,0x00004000,0x00000000},0x0375,1,566},
+ {{0x00000000,0x00000000,0x00080000},0x2584,1,5671},
+ {{0x00000000,0x00400000,0x00000004},0x25e2,1,6008},
+ {{0x00000000,0x00000080,0x00000004},0x25e3,1,6008},
+ {{0x00000000,0x00000000,0x00000000},0x25ca,1,5936},
+ {{0x00000000,0x00000000,0x00000000},0x200e,1,2886},
+ {{0x00000000,0x00000000,0x00000000},0x25ca,1,5944},
+ {{0x00000201,0x00000000,0x00000000},0x3107,0,1570},
+ {{0x00000013,0x00000040,0x00000000},0x1e3e,0,1570},
+ {{0x00000015,0x00000040,0x00000000},0x1e3f,0,1570},
+ {{0x00000005,0x00040040,0x00000000},0x24a8,0,1570},
+ {{0x00004003,0x00000040,0x00000000},0x24c2,0,1570},
+ {{0x00004005,0x00000040,0x00000000},0x24dc,0,1570},
+ {{0x0008000b,0x00000040,0x00000000},0x1e40,0,1570},
+ {{0x0008000d,0x00000040,0x00000000},0x1e41,0,1570},
+ {{0x00080103,0x00000040,0x00000000},0x1e42,0,1570},
+ {{0x00080105,0x00000040,0x00000000},0x1e43,0,1570},
+ {{0x00000000,0x00000000,0x00000000},0x24c2,1,5361},
+ {{0x00000000,0x00000000,0x00000000},0x24dc,1,5361},
+ {{0x00000000,0x00000000,0x00000000},0x05dd,1,1254},
+ {{0x00000000,0x00000000,0x00000000},0x1e3e,1,1840},
+ {{0x00000000,0x00000000,0x00000000},0x1e3f,1,1840},
+ {{0x00000000,0x00000000,0x00000000},0x039c,1,741},
+ {{0x00000000,0x00000000,0x00000000},0x03bc,1,741},
+ {{0x00000000,0x00000000,0x00000000},0x05de,1,1257},
+ {{0x00000000,0x00000000,0x00000000},0x0645,1,1257},
+ {{0x00000000,0x00000000,0x00000000},0xfee3,1,7359},
+ {{0x00000000,0x00000000,0x00000000},0xfee1,1,7351},
+ {{0x00000000,0x00000000,0x00000000},0xfee2,1,7355},
+ {{0x00000000,0x00000000,0x00000000},0xfee4,1,7363},
+ {{0x00000000,0x00000000,0x00000000},0x1e42,1,1846},
+ {{0x00000000,0x00000000,0x00000000},0x1e43,1,1846},
+ {{0x00000000,0x00000000,0x00000000},0x1e40,1,1843},
+ {{0x00000000,0x00000000,0x00000000},0x1e41,1,1843},
+ {{0x00000000,0x00000000,0x00000000},0x266c,1,6256},
+ {{0x00000000,0x00000000,0x00000000},0x266b,1,6230},
+ {{0x00000000,0x00000000,0x00000000},0x03dc,1,854},
+ {{0x00000000,0x00000000,0x00000000},0x3107,1,6796},
+ {{0x00000000,0x00000000,0x00000000},0x266a,1,6203},
+ {{0x00000000,0x00000000,0x00000000},0x041c,1,1004},
+ {{0x00000000,0x00000000,0x00000000},0x043c,1,1004},
+ {{0x40000001,0x00000000,0x00000000},0x307e,1,6633},
+ {{0x00000001,0x00000020,0x00000000},0x30de,1,6633},
+ {{0x000000a9,0x00000000,0x00000000},0x0622,1,1348},
+ {{0x000000a9,0x00000010,0x00000000},0xfe81,1,1348},
+ {{0x010000a9,0x00000000,0x00000000},0xfe82,1,1348},
+ {{0x000000a1,0x00000000,0x00000000},0x0649,1,1551},
+ {{0x000000a1,0x00000010,0x00000000},0xfeef,1,1551},
+ {{0x010000a1,0x00000000,0x00000000},0xfef0,1,1551},
+ {{0x00000001,0x00000000,0x00000000},0x2642,1,6125},
+ {{0x00000000,0x00000000,0x00000000},0x2720,1,6324},
+ {{0x00000000,0x00000000,0x00000000},0x266d,1,6271},
+ {{0x00000000,0x00000000,0x00000000},0x2669,1,6188},
+ {{0x40000001,0x00000000,0x00000000},0x3081,1,6639},
+ {{0x00000001,0x00000020,0x00000000},0x30e1,1,6639},
+ {{0x00000000,0x00000000,0x00000000},0x2592,1,5707},
+ {{0x00000081,0x00000000,0x00000000},0x0645,1,1533},
+ {{0x00000081,0x00000010,0x00000000},0xfee1,1,1533},
+ {{0x01000081,0x00000000,0x00000000},0xfee2,1,1533},
+ {{0x00000081,0x00000004,0x00000000},0xfee3,1,1533},
+ {{0x00000081,0x00001000,0x00000000},0xfee4,1,1533},
+ {{0x20000001,0x00000000,0x00000000},0x05de,1,1250},
+ {{0x21000001,0x00000000,0x00000000},0x05dd,1,1250},
+ {{0x40000001,0x00000000,0x00000000},0x307f,1,6636},
+ {{0x00000001,0x00000020,0x00000000},0x30df,1,6636},
+ {{0x00000001,0x00000000,0x00000000},0x2212,1,3297},
+ {{0x00000000,0x00000000,0x00000020},0x207b,1,3297},
+ {{0x00000000,0x00000000,0x00000040},0x208b,1,3297},
+ {{0x00000001,0x00000000,0x00010000},0x2213,1,4185},
+ {{0x00000000,0x00000000,0x00000000},0x2642,1,6130},
+ {{0x40000001,0x00000000,0x00000000},0x3082,1,6642},
+ {{0x00000001,0x00000020,0x00000000},0x30e2,1,6642},
+ {{0x00000001,0x00000400,0x00000000},0x02c9,1,507},
+ {{0x00008001,0x00000000,0x00000000},0x02c6,1,485},
+ {{0x04000001,0x00000000,0x00000000},0x02cb,1,485},
+ {{0x00000001,0x00000000,0x00000000},0x02bb,1,460},
+ {{0x40000001,0x00000000,0x00000000},0x3080,1,738},
+ {{0x00000001,0x00000020,0x00000000},0x30e0,1,738},
+ {{0x08000003,0x00000000,0x00000000},0x039c,1,738},
+ {{0x08000005,0x00000000,0x00000000},0x03bc,1,738},
+ {{0x00000000,0x00000000,0x00004000},0x226b,1,4543},
+ {{0x00000000,0x00000000,0x00004000},0x226a,1,4530},
+ {{0x00000001,0x00000000,0x00000000},0x266d,1,6260},
+ {{0x00000001,0x00000000,0x00000000},0x266e,1,6274},
+ {{0x00000001,0x00000000,0x00000000},0x266f,1,6291},
+ {{0x00000000,0x00000000,0x00000000},0x266e,1,6288},
+ {{0x00000000,0x00000000,0x00000000},0x266f,1,6288},
+ {{0x40000001,0x00000000,0x00000000},0x3093,0,1572},
+ {{0x00000001,0x00000020,0x00000000},0x30f3,0,1572},
+ {{0x00000201,0x00000000,0x00000000},0x310b,0,1572},
+ {{0x00000013,0x00000040,0x00000000},0x0143,0,1572},
+ {{0x00000015,0x00000040,0x00000000},0x0144,0,1572},
+ {{0x00002003,0x00000040,0x00000000},0x0145,0,1572},
+ {{0x00002005,0x00000040,0x00000000},0x0146,0,1572},
+ {{0x00001003,0x00000040,0x00000000},0x0147,0,1572},
+ {{0x00001005,0x00000040,0x00000000},0x0148,0,1572},
+ {{0x00000005,0x00000040,0x00000020},0x207f,0,1572},
+ {{0x00000005,0x00040040,0x00000000},0x24a9,0,1572},
+ {{0x00004003,0x00000040,0x00000000},0x24c3,0,1572},
+ {{0x00004005,0x00000040,0x00000000},0x24dd,0,1572},
+ {{0x0008000b,0x00000040,0x00000000},0x1e44,0,1572},
+ {{0x0008000d,0x00000040,0x00000000},0x1e45,0,1572},
+ {{0x00080103,0x00000040,0x00000000},0x1e46,0,1572},
+ {{0x00080105,0x00000040,0x00000000},0x1e47,0,1572},
+ {{0x00000103,0x00000240,0x00000000},0x1e48,0,1572},
+ {{0x00000105,0x00000240,0x00000000},0x1e49,0,1572},
+ {{0x00008103,0x00000040,0x00000000},0x1e4a,0,1572},
+ {{0x00008105,0x00000040,0x00000000},0x1e4b,0,1572},
+ {{0x00000000,0x00000000,0x00000000},0x220f,1,4146},
+ {{0x00000000,0x00000000,0x00000000},0x2211,1,4163},
+ {{0x00000007,0x00000040,0x00000000},0x01cb,1,311},
+ {{0x00000000,0x00000000,0x00000000},0x24c3,1,5365},
+ {{0x00000000,0x00000000,0x00000000},0x24dd,1,5365},
+ {{0x00000005,0x00000040,0x00000000},0x0149,1,125},
+ {{0x00000000,0x00000000,0x00000000},0x05df,1,1264},
+ {{0x00000000,0x00000000,0x00000000},0x0143,1,116},
+ {{0x00000000,0x00000000,0x00000000},0x0144,1,116},
+ {{0x00000000,0x00000000,0x00000000},0x039d,1,744},
+ {{0x00000000,0x00000000,0x00000000},0x03bd,1,744},
+ {{0x00000000,0x00000000,0x00000000},0x05e0,1,1267},
+ {{0x00000000,0x00000000,0x00000000},0x0646,1,1267},
+ {{0x00000000,0x00000000,0x00000000},0xfee7,1,7375},
+ {{0x00000000,0x00000000,0x00000000},0xfee5,1,7367},
+ {{0x00000000,0x00000000,0x00000000},0xfee6,1,7371},
+ {{0x00000000,0x00000000,0x00000000},0xfee8,1,7379},
+ {{0x00000000,0x00000000,0x00000000},0x0145,1,119},
+ {{0x00000000,0x00000000,0x00000000},0x0146,1,119},
+ {{0x00000000,0x00000000,0x00000000},0x1e46,1,1853},
+ {{0x00000000,0x00000000,0x00000000},0x1e47,1,1853},
+ {{0x00000000,0x00000000,0x00000000},0x1e4a,1,1860},
+ {{0x00000000,0x00000000,0x00000000},0x1e4b,1,1860},
+ {{0x00000000,0x00000000,0x00000000},0x1e44,1,1850},
+ {{0x00000000,0x00000000,0x00000000},0x1e45,1,1850},
+ {{0x00000000,0x00000000,0x00000000},0x2116,1,3418},
+ {{0x00000000,0x00000000,0x00000000},0x310b,1,6805},
+ {{0x00000000,0x00000000,0x00000000},0x3093,1,6669},
+ {{0x00000000,0x00000000,0x00000000},0x30f3,1,6750},
+ {{0x00000000,0x00000000,0x00000000},0x0147,1,122},
+ {{0x00000000,0x00000000,0x00000000},0x0148,1,122},
+ {{0x00000000,0x00000000,0x00000000},0x041d,1,1010},
+ {{0x00000000,0x00000000,0x00000000},0x043d,1,1010},
+ {{0x00000000,0x00000000,0x00000000},0x1e48,1,1857},
+ {{0x00000000,0x00000000,0x00000000},0x1e49,1,1857},
+ {{0x40000001,0x00000000,0x00000000},0x306a,1,6612},
+ {{0x00000001,0x00000020,0x00000000},0x30ca,1,6612},
+ {{0x00000000,0x00000000,0x00000000},0x2207,1,4098},
+ {{0x00000000,0x00000000,0x00000000},0x2207,0,1314},
+ {{0x40000001,0x00000000,0x00000000},0x306d,1,6615},
+ {{0x00000001,0x00000020,0x00000000},0x30cd,1,6615},
+ {{0x00000000,0x00000000,0x00000000},0x014a,1,157},
+ {{0x00000000,0x00000000,0x00000000},0x014b,1,157},
+ {{0x00000201,0x00000000,0x00000000},0x312b,1,157},
+ {{0x00000000,0x00000000,0x00000000},0x2310,1,4682},
+ {{0x40000001,0x00000000,0x00000000},0x306b,1,4682},
+ {{0x00000001,0x00000020,0x00000000},0x30cb,1,4682},
+ {{0x00000000,0x00000000,0x00000020},0x2079,0,1476},
+ {{0x00000000,0x00000000,0x00000040},0x2089,0,1476},
+ {{0x00004001,0x00000000,0x00000000},0x2468,0,1476},
+ {{0x00000001,0x00040000,0x00000000},0x247c,0,1476},
+ {{0x00000081,0x00000000,0x00000400},0x0669,0,1476},
+ {{0x00000000,0x00804000,0x00000000},0x2168,0,1476},
+ {{0x02000001,0x00000000,0x00000002},0x2490,0,1476},
+ {{0x00000000,0x00040000,0x00000800},0x3228,0,1476},
+ {{0x00000004,0x00804000,0x00000000},0x2178,0,1476},
+ {{0x00004000,0x00002000,0x00000000},0x2472,1,5021},
+ {{0x00000000,0x00042000,0x00000000},0x2486,1,5021},
+ {{0x02000000,0x00002000,0x00000002},0x249a,1,5021},
+ {{0x00000000,0x00000000,0x00000000},0x040a,1,304},
+ {{0x00000000,0x00000000,0x00000000},0x045a,1,304},
+ {{0x00000003,0x00000040,0x00000000},0x01ca,1,304},
+ {{0x00000005,0x00000040,0x00000000},0x01cc,1,304},
+ {{0x00000000,0x00000000,0x00000000},0x01ca,1,307},
+ {{0x00000000,0x00000000,0x00000000},0x01cb,1,307},
+ {{0x00000000,0x00000000,0x00000000},0x01cc,1,307},
+ {{0x00010003,0x00000000,0x00000000},0x040a,1,918},
+ {{0x00010005,0x00000000,0x00000000},0x045a,1,918},
+ {{0x40000001,0x00000000,0x00000000},0x306e,0,2642},
+ {{0x00000001,0x00000020,0x00000000},0x30ce,0,2642},
+ {{0x00000081,0x00000000,0x00000000},0x0646,1,1538},
+ {{0x00000081,0x00000010,0x00000000},0xfee5,1,1538},
+ {{0x01000081,0x00000000,0x00000000},0xfee6,1,1538},
+ {{0x00000081,0x00000004,0x00000000},0xfee7,1,1538},
+ {{0x00000081,0x00001000,0x00000000},0xfee8,1,1538},
+ {{0x00000000,0x00000000,0x00002000},0x2197,1,3929},
+ {{0x00000000,0x00000000,0x00002000},0x2196,1,3914},
+ {{0x00000000,0x04000000,0x00001000},0x2260,0,2638},
+ {{0x00000000,0x00000000,0x00004000},0x226f,1,4571},
+ {{0x00000000,0x00000000,0x00004000},0x226e,1,4559},
+ {{0x00000000,0x00000000,0x00000000},0x207f,0,2485},
+ {{0x40000001,0x00000000,0x00000000},0x306c,0,707},
+ {{0x00000001,0x00000020,0x00000000},0x30cc,0,707},
+ {{0x08000003,0x00000000,0x00000000},0x039d,0,707},
+ {{0x08000005,0x00000000,0x00000000},0x03bd,0,707},
+ {{0x00000001,0x00000000,0x00000000},0x2116,1,3411},
+ {{0x20000001,0x00000000,0x00000000},0x05e0,1,1260},
+ {{0x21000001,0x00000000,0x00000000},0x05df,1,1260},
+ {{0x40000001,0x00000000,0x00000000},0x304a,0,1574},
+ {{0x00000001,0x00000020,0x00000000},0x30aa,0,1574},
+ {{0x00000201,0x00000000,0x00000000},0x311b,0,1574},
+ {{0x00010003,0x00000000,0x00000000},0x041e,0,1574},
+ {{0x00010005,0x00000000,0x00000000},0x043e,0,1574},
+ {{0x40000005,0x00000000,0x00000000},0x3049,0,1574},
+ {{0x00000005,0x00000020,0x00000000},0x30a9,0,1574},
+ {{0x00000003,0x00000440,0x00000000},0x014c,0,1574},
+ {{0x00000005,0x00000440,0x00000000},0x014d,0,1574},
+ {{0x00000803,0x00000040,0x00000000},0x014e,0,1574},
+ {{0x00000805,0x00000040,0x00000000},0x014f,0,1574},
+ {{0x00000003,0x00000042,0x00000000},0x01a0,0,1574},
+ {{0x00000005,0x00000042,0x00000000},0x01a1,0,1574},
+ {{0x00001003,0x00000040,0x00000000},0x01d1,0,1574},
+ {{0x00001005,0x00000040,0x00000000},0x01d2,0,1574},
+ {{0x00000003,0x00000040,0x02000000},0x01ea,0,1574},
+ {{0x00000005,0x00000040,0x02000000},0x01eb,0,1574},
+ {{0x00000005,0x00040040,0x00000000},0x24aa,0,1574},
+ {{0x00004003,0x00000040,0x00000000},0x24c4,0,1574},
+ {{0x00004005,0x00000040,0x00000000},0x24de,0,1574},
+ {{0x00100013,0x00000040,0x00000000},0x0150,0,1574},
+ {{0x00100015,0x00000040,0x00000000},0x0151,0,1574},
+ {{0x00000003,0x00000440,0x02000000},0x01ec,0,1574},
+ {{0x00000005,0x00000440,0x02000000},0x01ed,0,1574},
+ {{0x00000013,0x00000040,0x10000000},0x01fe,0,1574},
+ {{0x00000015,0x00000040,0x10000000},0x01ff,0,1574},
+ {{0x04100003,0x00000040,0x00000000},0x020c,0,1574},
+ {{0x04100005,0x00000040,0x00000000},0x020d,0,1574},
+ {{0x00000803,0x00000040,0x00800000},0x020e,0,1574},
+ {{0x00000805,0x00000040,0x00800000},0x020f,0,1574},
+ {{0x00000013,0x02000040,0x00000000},0x1e4c,0,1574},
+ {{0x00000015,0x02000040,0x00000000},0x1e4d,0,1574},
+ {{0x00040003,0x02000040,0x00000000},0x1e4e,0,1574},
+ {{0x00040005,0x02000040,0x00000000},0x1e4f,0,1574},
+ {{0x04000003,0x00000440,0x00000000},0x1e50,0,1574},
+ {{0x04000005,0x00000440,0x00000000},0x1e51,0,1574},
+ {{0x00000013,0x00000440,0x00000000},0x1e52,0,1574},
+ {{0x00000015,0x00000440,0x00000000},0x1e53,0,1574},
+ {{0x00080103,0x00000040,0x00000000},0x1ecc,0,1574},
+ {{0x00080105,0x00000040,0x00000000},0x1ecd,0,1574},
+ {{0x8000000b,0x00000040,0x00000000},0x1ece,0,1574},
+ {{0x8000000d,0x00000040,0x00000000},0x1ecf,0,1574},
+ {{0x00008013,0x00000040,0x00000000},0x1ed0,0,1574},
+ {{0x00008015,0x00000040,0x00000000},0x1ed1,0,1574},
+ {{0x04008003,0x00000040,0x00000000},0x1ed2,0,1574},
+ {{0x04008005,0x00000040,0x00000000},0x1ed3,0,1574},
+ {{0x00008003,0x02000040,0x00000000},0x1ed6,0,1574},
+ {{0x00008005,0x02000040,0x00000000},0x1ed7,0,1574},
+ {{0x00000013,0x00000042,0x00000000},0x1eda,0,1574},
+ {{0x00000015,0x00000042,0x00000000},0x1edb,0,1574},
+ {{0x04000003,0x00000042,0x00000000},0x1edc,0,1574},
+ {{0x04000005,0x00000042,0x00000000},0x1edd,0,1574},
+ {{0x00000003,0x02000042,0x00000000},0x1ee0,0,1574},
+ {{0x00000005,0x02000042,0x00000000},0x1ee1,0,1574},
+ {{0x8000800b,0x00000040,0x00000000},0x1ed4,0,1574},
+ {{0x8000800d,0x00000040,0x00000000},0x1ed5,0,1574},
+ {{0x00088103,0x00000040,0x00000000},0x1ed8,0,1574},
+ {{0x00088105,0x00000040,0x00000000},0x1ed9,0,1574},
+ {{0x8000000b,0x00000042,0x00000000},0x1ede,0,1574},
+ {{0x8000000d,0x00000042,0x00000000},0x1edf,0,1574},
+ {{0x00080103,0x00000042,0x00000000},0x1ee2,0,1574},
+ {{0x00080105,0x00000042,0x00000000},0x1ee3,0,1574},
+ {{0x00000000,0x00000000,0x00000000},0x24c4,1,5369},
+ {{0x00000000,0x00000000,0x00000000},0x24de,1,5369},
+ {{0x00000000,0x00000000,0x00000000},0x020c,1,425},
+ {{0x00000000,0x00000000,0x00000000},0x020d,1,425},
+ {{0x00000000,0x00000000,0x00000000},0x0150,1,166},
+ {{0x00000000,0x00000000,0x00000000},0x0151,1,166},
+ {{0x00000000,0x00000000,0x00000000},0x038c,1,653},
+ {{0x00000000,0x00000000,0x00000000},0x03cc,1,653},
+ {{0x00000000,0x00000000,0x00000000},0x014e,1,163},
+ {{0x00000000,0x00000000,0x00000000},0x014f,1,163},
+ {{0x00000000,0x00000000,0x00000000},0x020e,1,429},
+ {{0x00000000,0x00000000,0x00000000},0x020f,1,429},
+ {{0x00000000,0x00000000,0x00000000},0x039f,1,753},
+ {{0x00000000,0x00000000,0x00000000},0x03bf,1,753},
+ {{0x00000000,0x00000000,0x00000000},0x1f78,1,2453},
+ {{0x00000000,0x00000000,0x00000000},0x1ff8,1,2453},
+ {{0x00000000,0x00000000,0x00000000},0x1f79,1,2457},
+ {{0x00000000,0x00000000,0x00000000},0x1ff9,1,2457},
+ {{0x00000000,0x00000000,0x00000000},0x1f40,1,2317},
+ {{0x00000000,0x00000000,0x00000000},0x1f48,1,2317},
+ {{0x00000000,0x00000000,0x00000000},0x1f42,1,2325},
+ {{0x00000000,0x00000000,0x00000000},0x1f4a,1,2325},
+ {{0x00000000,0x00000000,0x00000000},0x1f44,1,2335},
+ {{0x00000000,0x00000000,0x00000000},0x1f4c,1,2335},
+ {{0x00000000,0x00000000,0x00000000},0x1f41,1,2321},
+ {{0x00000000,0x00000000,0x00000000},0x1f49,1,2321},
+ {{0x00000000,0x00000000,0x00000000},0x1f43,1,2330},
+ {{0x00000000,0x00000000,0x00000000},0x1f4b,1,2330},
+ {{0x00000000,0x00000000,0x00000000},0x1f45,1,2340},
+ {{0x00000000,0x00000000,0x00000000},0x1f4d,1,2340},
+ {{0x00000000,0x00000000,0x00000000},0x014c,1,160},
+ {{0x00000000,0x00000000,0x00000000},0x014d,1,160},
+ {{0x00000000,0x00000000,0x00000000},0x1e50,1,1872},
+ {{0x00000000,0x00000000,0x00000000},0x1e51,1,1872},
+ {{0x00000000,0x00000000,0x00000000},0x1e52,1,1876},
+ {{0x00000000,0x00000000,0x00000000},0x1e53,1,1876},
+ {{0x00000000,0x00000000,0x00000000},0x1ecc,1,2085},
+ {{0x00000000,0x00000000,0x00000000},0x1ecd,1,2085},
+ {{0x00000000,0x00000000,0x00000000},0x01fe,1,400},
+ {{0x00000000,0x00000000,0x00000000},0x01ff,1,400},
+ {{0x00000000,0x00000000,0x00000000},0x01ec,1,376},
+ {{0x00000000,0x00000000,0x00000000},0x01ed,1,376},
+ {{0x00000000,0x00000000,0x00000000},0x1ece,1,2089},
+ {{0x00000000,0x00000000,0x00000000},0x1ecf,1,2089},
+ {{0x00000000,0x00000000,0x00000000},0x046a,1,1132},
+ {{0x00000000,0x00000000,0x00000000},0x046b,1,1132},
+ {{0x00000000,0x00000000,0x00000000},0x311b,1,6844},
+ {{0x00000000,0x00000000,0x00000000},0x3049,1,6555},
+ {{0x00000000,0x00000000,0x00000000},0x304a,1,6555},
+ {{0x00000000,0x00000000,0x00000000},0x30a9,1,6747},
+ {{0x00000000,0x00000000,0x00000000},0x30aa,1,6747},
+ {{0x00000000,0x00000000,0x00000000},0x01a0,1,260},
+ {{0x00000000,0x00000000,0x00000000},0x01a1,1,260},
+ {{0x00000000,0x00000000,0x00000000},0x1edc,1,2117},
+ {{0x00000000,0x00000000,0x00000000},0x1edd,1,2117},
+ {{0x00000000,0x00000000,0x00000000},0x1eda,1,2113},
+ {{0x00000000,0x00000000,0x00000000},0x1edb,1,2113},
+ {{0x00000000,0x00000000,0x00000000},0x1ee2,1,2129},
+ {{0x00000000,0x00000000,0x00000000},0x1ee3,1,2129},
+ {{0x00000000,0x00000000,0x00000000},0x1ede,1,2121},
+ {{0x00000000,0x00000000,0x00000000},0x1edf,1,2121},
+ {{0x00000000,0x00000000,0x00000000},0x1ee0,1,2125},
+ {{0x00000000,0x00000000,0x00000000},0x1ee1,1,2125},
+ {{0x00000000,0x00000000,0x00000000},0x01ea,1,373},
+ {{0x00000000,0x00000000,0x00000000},0x01eb,1,373},
+ {{0x00000000,0x00000000,0x00000000},0x01d1,1,321},
+ {{0x00000000,0x00000000,0x00000000},0x01d2,1,321},
+ {{0x00000000,0x00000000,0x00000000},0x041e,1,1013},
+ {{0x00000000,0x00000000,0x00000000},0x043e,1,1013},
+ {{0x00000000,0x00000000,0x00000000},0x1ed2,1,2096},
+ {{0x00000000,0x00000000,0x00000000},0x1ed3,1,2096},
+ {{0x00000000,0x00000000,0x00000000},0x1ed0,1,2092},
+ {{0x00000000,0x00000000,0x00000000},0x1ed1,1,2092},
+ {{0x00000000,0x00000000,0x00000000},0x1ed8,1,2108},
+ {{0x00000000,0x00000000,0x00000000},0x1ed9,1,2108},
+ {{0x00000000,0x00000000,0x00000000},0x1ed4,1,2100},
+ {{0x00000000,0x00000000,0x00000000},0x1ed5,1,2100},
+ {{0x00000000,0x00000000,0x00000000},0x1ed6,1,2104},
+ {{0x00000000,0x00000000,0x00000000},0x1ed7,1,2104},
+ {{0x00000000,0x00000000,0x00000000},0x1e4c,1,1864},
+ {{0x00000000,0x00000000,0x00000000},0x1e4d,1,1864},
+ {{0x00000000,0x00000000,0x00000000},0x1e4e,1,1868},
+ {{0x00000000,0x00000000,0x00000000},0x1e4f,1,1868},
+ {{0x00000000,0x00000000,0x00000000},0x2218,1,4232},
+ {{0x00000000,0x00000000,0x00000000},0x2103,0,2415},
+ {{0x00000000,0x00000000,0x00000000},0x0152,1,169},
+ {{0x00000000,0x00000000,0x00000000},0x0153,1,169},
+ {{0x00000002,0x00000040,0x00000100},0x0152,1,169},
+ {{0x00000004,0x00000040,0x00000100},0x0153,1,169},
+ {{0x00000001,0x00000000,0x00000000},0x2126,1,3488},
+ {{0x00000000,0x00000000,0x00000000},0x01a2,1,263},
+ {{0x00000000,0x00000000,0x00000000},0x01a3,1,263},
+ {{0x00000003,0x00000040,0x00000000},0x01a2,1,263},
+ {{0x00000005,0x00000040,0x00000000},0x01a3,1,263},
+ {{0x00000000,0x00000000,0x00000000},0x2713,1,6309},
+ {{0x00000000,0x00000000,0x00000000},0x2126,1,3492},
+ {{0x08000003,0x00000000,0x00000000},0x039f,1,645},
+ {{0x08000005,0x00000000,0x00000000},0x03bf,1,645},
+ {{0x08000003,0x00000000,0x20000000},0x038c,1,645},
+ {{0x08000005,0x00000000,0x20000000},0x03cc,1,645},
+ {{0x08000005,0x00200000,0x00000000},0x1f40,1,645},
+ {{0x08020005,0x00000000,0x00000000},0x1f41,1,645},
+ {{0x08000003,0x00200000,0x00000000},0x1f48,1,645},
+ {{0x08020003,0x00000000,0x00000000},0x1f49,1,645},
+ {{0x08000005,0x20000000,0x00000000},0x1f78,1,645},
+ {{0x08000005,0x00020000,0x00000000},0x1f79,1,645},
+ {{0x08000003,0x20000000,0x00000000},0x1ff8,1,645},
+ {{0x08000003,0x00020000,0x00000000},0x1ff9,1,645},
+ {{0x08000005,0x20200000,0x00000000},0x1f42,1,645},
+ {{0x08020005,0x20000000,0x00000000},0x1f43,1,645},
+ {{0x08000005,0x00220000,0x00000000},0x1f44,1,645},
+ {{0x08020005,0x00020000,0x00000000},0x1f45,1,645},
+ {{0x08000003,0x20200000,0x00000000},0x1f4a,1,645},
+ {{0x08020003,0x20000000,0x00000000},0x1f4b,1,645},
+ {{0x08000003,0x00220000,0x00000000},0x1f4c,1,645},
+ {{0x08020003,0x00020000,0x00000000},0x1f4d,1,645},
+ {{0x00000400,0x00000000,0x00000000},0x2423,1,4788},
+ {{0x00000000,0x00000000,0x04000000},0x2218,1,4223},
+ {{0x00000000,0x02000000,0x00000000},0x223c,1,4223},
+ {{0x00080000,0x00000000,0x00000000},0x22c5,1,4223},
+ {{0x00084000,0x00000000,0x00000000},0x2299,1,4223},
+ {{0x00004000,0x00000000,0x04000000},0x229a,1,4223},
+ {{0x00000001,0x00000000,0x00000080},0x25a6,1,5784},
+ {{0x00000000,0x00000000,0x00000000},0x25a1,1,5737},
+ {{0x00000201,0x00000000,0x00000000},0x3121,1,6863},
+ {{0x00000000,0x00000000,0x00000000},0x203e,1,3241},
+ {{0x00000201,0x00000000,0x00000000},0x3106,0,1576},
+ {{0x00000013,0x00000040,0x00000000},0x1e54,0,1576},
+ {{0x00000015,0x00000040,0x00000000},0x1e55,0,1576},
+ {{0x00000005,0x00040040,0x00000000},0x24ab,0,1576},
+ {{0x00004003,0x00000040,0x00000000},0x24c5,0,1576},
+ {{0x00004005,0x00000040,0x00000000},0x24df,0,1576},
+ {{0x0008000b,0x00000040,0x00000000},0x1e56,0,1576},
+ {{0x0008000d,0x00000040,0x00000000},0x1e57,0,1576},
+ {{0x00000000,0x00000000,0x00000000},0x24c5,1,5373},
+ {{0x00000000,0x00000000,0x00000000},0x24df,1,5373},
+ {{0x00000000,0x00000000,0x00000000},0x05e3,1,1288},
+ {{0x00000000,0x00000000,0x00000000},0x1e54,1,1880},
+ {{0x00000000,0x00000000,0x00000000},0x1e55,1,1880},
+ {{0x00000000,0x00000000,0x00000000},0x03a0,1,756},
+ {{0x00000000,0x00000000,0x00000000},0x03c0,1,756},
+ {{0x00000000,0x00000000,0x00000000},0x05e4,1,1291},
+ {{0x00000000,0x00000000,0x00000000},0x067e,1,1291},
+ {{0x00000000,0x00000000,0x00000000},0x1e56,1,1883},
+ {{0x00000000,0x00000000,0x00000000},0x1e57,1,1883},
+ {{0x00000000,0x00000000,0x00000000},0x03e0,1,872},
+ {{0x00000000,0x00000000,0x00000000},0x3106,1,6793},
+ {{0x00000000,0x00000000,0x00000000},0x041f,1,1019},
+ {{0x00000000,0x00000000,0x00000000},0x043f,1,1019},
+ {{0x40000001,0x00000000,0x00000000},0x3071,0,1717},
+ {{0x00000001,0x00000020,0x00000000},0x30d1,0,1717},
+ {{0x00000000,0x00000000,0x00000000},0x2029,1,3095},
+ {{0x00000000,0x04000000,0x00000000},0x2225,1,4296},
+ {{0x00000000,0x00000080,0x00000020},0x207d,0,1362},
+ {{0x00000000,0x00400000,0x00000020},0x207e,0,1362},
+ {{0x00000000,0x00000080,0x00000040},0x208d,0,1362},
+ {{0x00000000,0x00400000,0x00000040},0x208e,0,1362},
+ {{0x00000000,0x00000000,0x00000000},0x2029,1,3115},
+ {{0x00000000,0x00000000,0x00000000},0x2202,1,4038},
+ {{0x20000001,0x00000000,0x00000000},0x05e4,1,1016},
+ {{0x40000001,0x00000000,0x00000000},0x307a,1,1016},
+ {{0x00000001,0x00000020,0x00000000},0x30da,1,1016},
+ {{0x00010003,0x00000000,0x00000000},0x041f,1,1016},
+ {{0x00010005,0x00000000,0x00000000},0x043f,1,1016},
+ {{0x21000001,0x00000000,0x00000000},0x05e3,1,1016},
+ {{0x00000081,0x00000000,0x00000000},0x067e,1,1684},
+ {{0x00000001,0x00000000,0x00000000},0x2030,1,3122},
+ {{0x00000081,0x00000000,0x00000000},0x066a,0,1333},
+ {{0x00000001,0x00000000,0x00000000},0x20a7,1,3333},
+ {{0x08000003,0x00000000,0x00000000},0x03a6,1,785},
+ {{0x08000005,0x00000000,0x00000000},0x03c6,1,785},
+ {{0x40000001,0x00000000,0x00000000},0x3074,0,2727},
+ {{0x00000001,0x00000020,0x00000000},0x30d4,0,2727},
+ {{0x08000003,0x00000000,0x00000000},0x03a0,0,2727},
+ {{0x08000005,0x00000000,0x00000000},0x03c0,0,2727},
+ {{0x00000000,0x00000000,0x00000000},0x25c4,1,5919},
+ {{0x00000001,0x00000000,0x00000001},0x2318,1,4714},
+ {{0x00000001,0x00000000,0x00000020},0x207a,0,1383},
+ {{0x00000001,0x00000000,0x00000040},0x208a,0,1383},
+ {{0x00080000,0x00000000,0x00000000},0x2214,0,1383},
+ {{0x00000000,0x00000000,0x00000080},0x33d8,0,2438},
+ {{0x00000000,0x00000000,0x00000000},0x2117,1,3447},
+ {{0x40000001,0x00000000,0x00000000},0x307d,1,3447},
+ {{0x00000001,0x00000020,0x00000000},0x30dd,1,3447},
+ {{0x00000000,0x00000080,0x00020000},0x2329,1,4767},
+ {{0x00000000,0x00400000,0x00020000},0x232a,1,4767},
+ {{0x00000000,0x01000880,0x00000000},0x2039,0,2610},
+ {{0x00000000,0x01400800,0x00000000},0x203a,0,2610},
+ {{0x00000000,0x80000080,0x00000000},0x261c,1,6066},
+ {{0x00000000,0x80400000,0x00000000},0x261e,1,6066},
+ {{0x00000000,0x00400000,0x00000004},0x25ba,1,5896},
+ {{0x00000000,0x00000080,0x00000004},0x25c4,1,5896},
+ {{0x00000000,0x08000000,0x00000004},0x25b2,1,5875},
+ {{0x00000000,0x88000000,0x00000000},0x25b3,1,5875},
+ {{0x00000000,0x80400000,0x00000000},0x25b7,1,5875},
+ {{0x00200000,0x00000000,0x00000004},0x25bc,1,5875},
+ {{0x00200000,0x80000000,0x00000000},0x25bd,1,5875},
+ {{0x00000000,0x80000080,0x00000000},0x25c1,1,5875},
+ {{0x00000000,0x00000800,0x00000000},0x3012,1,6468},
+ {{0x00000000,0x00000800,0x00000000},0x3020,1,6526},
+ {{0x00000000,0x00000000,0x00000000},0x2225,1,4305},
+ {{0x00000000,0x00000000,0x00000000},0x25ba,1,5913},
+ {{0x00000000,0x00000000,0x00000000},0x211e,1,3450},
+ {{0x00000000,0x00000000,0x00000000},0x2032,1,3135},
+ {{0x00100000,0x00000000,0x00000000},0x2033,1,3135},
+ {{0x40000000,0x00000820,0x00000000},0x30fc,1,6765},
+ {{0x00000000,0x00000000,0x00100001},0x220e,1,4137},
+ {{0x00000000,0x00000000,0x00000000},0x2237,1,4406},
+ {{0x00000000,0x04000000,0x00000000},0x221d,1,4259},
+ {{0x08000003,0x00000000,0x00000000},0x03a8,1,799},
+ {{0x08000005,0x00000000,0x00000000},0x03c8,1,799},
+ {{0x40000001,0x00000000,0x00000000},0x3077,0,2007},
+ {{0x00000001,0x00000020,0x00000000},0x30d7,0,2007},
+ {{0x00000201,0x00000000,0x00000000},0x3111,0,1578},
+ {{0x00000005,0x00040040,0x00000000},0x24ac,0,1578},
+ {{0x00004003,0x00000040,0x00000000},0x24c6,0,1578},
+ {{0x00004005,0x00000040,0x00000000},0x24e0,0,1578},
+ {{0x00000000,0x00000000,0x00000000},0x24c6,1,5377},
+ {{0x00000000,0x00000000,0x00000000},0x24e0,1,5377},
+ {{0x00000000,0x00000000,0x00000000},0x03a8,1,803},
+ {{0x00000000,0x00000000,0x00000000},0x03c8,1,803},
+ {{0x00000000,0x00000000,0x00000000},0x05e7,1,1307},
+ {{0x00000000,0x00000000,0x00000000},0x0642,1,1307},
+ {{0x00000000,0x00000000,0x00000000},0xfed7,1,7311},
+ {{0x00000000,0x00000000,0x00000000},0xfed5,1,7303},
+ {{0x00000000,0x00000000,0x00000000},0xfed6,1,7307},
+ {{0x00000000,0x00000000,0x00000000},0xfed8,1,7315},
+ {{0x00000000,0x00000000,0x00000000},0x3111,1,6823},
+ {{0x00000081,0x00000000,0x00000000},0x0642,1,1525},
+ {{0x00000081,0x00000010,0x00000000},0xfed5,1,1525},
+ {{0x01000081,0x00000000,0x00000000},0xfed6,1,1525},
+ {{0x00000081,0x00000004,0x00000000},0xfed7,1,1525},
+ {{0x00000081,0x00001000,0x00000000},0xfed8,1,1525},
+ {{0x20000001,0x00000000,0x00000000},0x05e7,1,1303},
+ {{0x00400400,0x00000101,0x00000000},0x2508,1,5465},
+ {{0x10400400,0x00000001,0x00000000},0x2509,1,5465},
+ {{0x00400400,0x40000100,0x00000000},0x250a,1,5465},
+ {{0x10400400,0x40000000,0x00000000},0x250b,1,5465},
+ {{0x00000000,0x00000000,0x00000000},0x2669,1,6175},
+ {{0x08000000,0x00000800,0x00000000},0x037e,0,1517},
+ {{0x00000080,0x00000800,0x00000000},0x061f,0,1517},
+ {{0x00000000,0x01000880,0x00000000},0x2018,0,1304},
+ {{0x00000000,0x01400800,0x00000000},0x2019,0,1304},
+ {{0x00100000,0x00000880,0x00000000},0x201c,0,1304},
+ {{0x00100000,0x00400800,0x00000000},0x201d,0,1304},
+ {{0x00000201,0x00000000,0x00000000},0x3116,0,1580},
+ {{0x00000013,0x00000040,0x00000000},0x0154,0,1580},
+ {{0x00000015,0x00000040,0x00000000},0x0155,0,1580},
+ {{0x00002003,0x00000040,0x00000000},0x0156,0,1580},
+ {{0x00002005,0x00000040,0x00000000},0x0157,0,1580},
+ {{0x00001003,0x00000040,0x00000000},0x0158,0,1580},
+ {{0x00001005,0x00000040,0x00000000},0x0159,0,1580},
+ {{0x00000005,0x00040040,0x00000000},0x24ad,0,1580},
+ {{0x00004003,0x00000040,0x00000000},0x24c7,0,1580},
+ {{0x00004005,0x00000040,0x00000000},0x24e1,0,1580},
+ {{0x04100003,0x00000040,0x00000000},0x0210,0,1580},
+ {{0x04100005,0x00000040,0x00000000},0x0211,0,1580},
+ {{0x00000803,0x00000040,0x00800000},0x0212,0,1580},
+ {{0x00000805,0x00000040,0x00800000},0x0213,0,1580},
+ {{0x0008000b,0x00000040,0x00000000},0x1e58,0,1580},
+ {{0x0008000d,0x00000040,0x00000000},0x1e59,0,1580},
+ {{0x00080103,0x00000040,0x00000000},0x1e5a,0,1580},
+ {{0x00080105,0x00000040,0x00000000},0x1e5b,0,1580},
+ {{0x00000103,0x00000240,0x00000000},0x1e5e,0,1580},
+ {{0x00000105,0x00000240,0x00000000},0x1e5f,0,1580},
+ {{0x00080103,0x00000440,0x00000000},0x1e5c,0,1580},
+ {{0x00080105,0x00000440,0x00000000},0x1e5d,0,1580},
+ {{0x00000005,0x00000040,0x00000000},0x027c,1,446},
+ {{0x00000000,0x00000000,0x00000000},0x24c7,1,5381},
+ {{0x00000000,0x00000000,0x00000000},0x24e1,1,5381},
+ {{0x00000000,0x00000000,0x00000000},0x0210,1,432},
+ {{0x00000000,0x00000000,0x00000000},0x0211,1,432},
+ {{0x00000000,0x00000000,0x00000000},0x0154,1,172},
+ {{0x00000000,0x00000000,0x00000000},0x0155,1,172},
+ {{0x00000000,0x00000000,0x00000000},0x0212,1,436},
+ {{0x00000000,0x00000000,0x00000000},0x0213,1,436},
+ {{0x00000000,0x00000000,0x00000000},0x03a1,1,763},
+ {{0x00000000,0x00000000,0x00000000},0x03c1,1,763},
+ {{0x00000000,0x00000000,0x00000000},0x1fe4,1,2764},
+ {{0x00000000,0x00000000,0x00000000},0x1fe5,1,2768},
+ {{0x00000000,0x00000000,0x00000000},0x1fec,1,2768},
+ {{0x00000000,0x00000000,0x00000000},0x05e8,1,1315},
+ {{0x00000000,0x00000000,0x00000000},0x0631,1,1315},
+ {{0x00000000,0x00000000,0x00000000},0xfead,1,7143},
+ {{0x00000000,0x00000000,0x00000000},0xfeae,1,7147},
+ {{0x00000000,0x00000000,0x00000000},0x0156,1,175},
+ {{0x00000000,0x00000000,0x00000000},0x0157,1,175},
+ {{0x00000000,0x00000000,0x00000000},0x1e5c,1,1893},
+ {{0x00000000,0x00000000,0x00000000},0x1e5d,1,1893},
+ {{0x00000000,0x00000000,0x00000000},0x1e5a,1,1889},
+ {{0x00000000,0x00000000,0x00000000},0x1e5b,1,1889},
+ {{0x00000000,0x00000000,0x00000000},0x1e58,1,1886},
+ {{0x00000000,0x00000000,0x00000000},0x1e59,1,1886},
+ {{0x00000000,0x00000000,0x00000000},0x027c,1,457},
+ {{0x00000000,0x00000000,0x00000000},0x3116,1,6829},
+ {{0x00000000,0x00000000,0x00000000},0x0158,1,178},
+ {{0x00000000,0x00000000,0x00000000},0x0159,1,178},
+ {{0x00000000,0x00000000,0x00000000},0x0420,1,1025},
+ {{0x00000000,0x00000000,0x00000000},0x0440,1,1025},
+ {{0x00000000,0x00000000,0x00000000},0x1e5e,1,1898},
+ {{0x00000000,0x00000000,0x00000000},0x1e5f,1,1898},
+ {{0x40000001,0x00000000,0x00000000},0x3089,1,6648},
+ {{0x00000001,0x00000020,0x00000000},0x30e9,1,6648},
+ {{0x00000000,0x00000000,0x00000000},0x2236,1,4397},
+ {{0x00000000,0x00000000,0x00000000},0x2590,1,5695},
+ {{0x40000001,0x00000000,0x00000000},0x308c,1,6654},
+ {{0x00000001,0x00000020,0x00000000},0x30ec,1,6654},
+ {{0x00000000,0x00000000,0x00000004},0x25ac,1,5862},
+ {{0x00000000,0x80000000,0x00000000},0x25ad,1,5862},
+ {{0x00000000,0x00000800,0x00000000},0x203b,1,3224},
+ {{0x00000081,0x00000000,0x00000000},0x0631,1,1446},
+ {{0x00000081,0x00000010,0x00000000},0xfead,1,1446},
+ {{0x01000081,0x00000000,0x00000000},0xfeae,1,1446},
+ {{0x20000001,0x00000000,0x00000000},0x05e8,1,1310},
+ {{0x00000001,0x00000000,0x00000000},0x2310,1,4669},
+ {{0x00000000,0x00000000,0x00000000},0x2035,1,3163},
+ {{0x00100000,0x00000000,0x00000000},0x2036,1,3163},
+ {{0x00000000,0x00000000,0x00000000},0x2037,1,3184},
+ {{0x00000000,0x00000000,0x00000000},0x25a4,1,5778},
+ {{0x00000000,0x00000000,0x00000000},0x25a6,1,5811},
+ {{0x08000003,0x00000000,0x00000000},0x03a1,1,759},
+ {{0x08000005,0x00000000,0x00000000},0x03c1,1,759},
+ {{0x08000005,0x00200000,0x00000000},0x1fe4,1,759},
+ {{0x08020005,0x00000000,0x00000000},0x1fe5,1,759},
+ {{0x08020003,0x00000000,0x00000000},0x1fec,1,759},
+ {{0x40000001,0x00000000,0x00000000},0x308a,0,2027},
+ {{0x00000001,0x00000020,0x00000000},0x30ea,0,2027},
+ {{0x00000000,0x00000000,0x00002000},0x2192,1,3881},
+ {{0x00100000,0x00000000,0x00002000},0x21d2,1,3881},
+ {{0x00000001,0x00000000,0x00000000},0x21c0,1,3983},
+ {{0x00000000,0x00000000,0x00000000},0x25a8,1,5834},
+ {{0x00000000,0x00000000,0x00000000},0x200f,1,2889},
+ {{0x00000000,0x00000000,0x00000000},0x25a2,1,5756},
+ {{0x40000001,0x00000000,0x00000000},0x308d,1,5756},
+ {{0x00000001,0x00000020,0x00000000},0x30ed,1,5756},
+ {{0x00000000,0x00000000,0x00000080},0x221a,1,4251},
+ {{0x00000001,0x80000000,0x00000080},0x25a2,1,5740},
+ {{0x00000000,0x00000000,0x00000000},0x25a3,1,5770},
+ {{0x00000000,0x00000000,0x00000000},0x221a,1,4256},
+ {{0x40000001,0x00000000,0x00000000},0x308b,1,6651},
+ {{0x00000001,0x00000020,0x00000000},0x30eb,1,6651},
+ {{0x00000000,0x00000000,0x00000000},0x211e,1,3468},
+ {{0x00000000,0x00000000,0x00000000},0x25a9,1,3468},
+ {{0x00000000,0x00000000,0x00000000},0x25a5,1,5781},
+ {{0x00000000,0x00000000,0x00000000},0x25a7,1,5831},
+ {{0x00000201,0x00000000,0x00000000},0x3119,0,1582},
+ {{0x00000013,0x00000040,0x00000000},0x015a,0,1582},
+ {{0x00000015,0x00000040,0x00000000},0x015b,0,1582},
+ {{0x00008003,0x00000040,0x00000000},0x015c,0,1582},
+ {{0x00008005,0x00000040,0x00000000},0x015d,0,1582},
+ {{0x00002003,0x00000040,0x00000000},0x015e,0,1582},
+ {{0x00002005,0x00000040,0x00000000},0x015f,0,1582},
+ {{0x00001003,0x00000040,0x00000000},0x0160,0,1582},
+ {{0x00001005,0x00000040,0x00000000},0x0161,0,1582},
+ {{0x00000005,0x00040040,0x00000000},0x24ae,0,1582},
+ {{0x00004003,0x00000040,0x00000000},0x24c8,0,1582},
+ {{0x00004005,0x00000040,0x00000000},0x24e2,0,1582},
+ {{0x0008000b,0x00000040,0x00000000},0x1e60,0,1582},
+ {{0x0008000d,0x00000040,0x00000000},0x1e61,0,1582},
+ {{0x00080103,0x00000040,0x00000000},0x1e62,0,1582},
+ {{0x00080105,0x00000040,0x00000000},0x1e63,0,1582},
+ {{0x0008001b,0x00000040,0x00000000},0x1e64,0,1582},
+ {{0x0008001d,0x00000040,0x00000000},0x1e65,0,1582},
+ {{0x0008100b,0x00000040,0x00000000},0x1e66,0,1582},
+ {{0x0008100d,0x00000040,0x00000000},0x1e67,0,1582},
+ {{0x0008010b,0x00000040,0x00000000},0x1e68,0,1582},
+ {{0x0008010d,0x00000040,0x00000000},0x1e69,0,1582},
+ {{0x00000000,0x00000000,0x00000000},0x24c8,1,5385},
+ {{0x00000000,0x00000000,0x00000000},0x24e2,1,5385},
+ {{0x00000000,0x00000000,0x00000000},0x0428,1,1070},
+ {{0x00000000,0x00000000,0x00000000},0x0448,1,1070},
+ {{0x00000000,0x00000000,0x00000000},0x015a,1,181},
+ {{0x00000000,0x00000000,0x00000000},0x015b,1,181},
+ {{0x00000000,0x00000000,0x00000000},0x1e64,1,1908},
+ {{0x00000000,0x00000000,0x00000000},0x1e65,1,1908},
+ {{0x00000000,0x00000000,0x00000000},0x03a3,1,772},
+ {{0x00000000,0x00000000,0x00000000},0x03c3,1,772},
+ {{0x00000000,0x00000000,0x00000000},0x05e1,1,1277},
+ {{0x00000000,0x00000000,0x00000000},0x0633,1,1277},
+ {{0x00000000,0x00000000,0x00000000},0xfeb3,1,7167},
+ {{0x00000000,0x00000000,0x00000000},0xfeb1,1,7159},
+ {{0x00000000,0x00000000,0x00000000},0xfeb2,1,7163},
+ {{0x00000000,0x00000000,0x00000000},0xfeb4,1,7171},
+ {{0x00000000,0x00000000,0x00000000},0x015e,1,187},
+ {{0x00000000,0x00000000,0x00000000},0x015f,1,187},
+ {{0x00000000,0x00000000,0x00000000},0x1e62,1,1904},
+ {{0x00000000,0x00000000,0x00000000},0x1e63,1,1904},
+ {{0x00000000,0x00000000,0x00000000},0x1e60,1,1901},
+ {{0x00000000,0x00000000,0x00000000},0x1e61,1,1901},
+ {{0x00000000,0x00000000,0x00000000},0x1e68,1,1916},
+ {{0x00000000,0x00000000,0x00000000},0x1e69,1,1916},
+ {{0x00000000,0x00000000,0x00000000},0x017f,1,242},
+ {{0x00000000,0x00000000,0x00000000},0x3119,1,6838},
+ {{0x00000000,0x00000000,0x00000000},0x0160,1,190},
+ {{0x00000000,0x00000000,0x00000000},0x0161,1,190},
+ {{0x00000000,0x00000000,0x00000000},0x1e66,1,1912},
+ {{0x00000000,0x00000000,0x00000000},0x1e67,1,1912},
+ {{0x00000000,0x00000000,0x00000000},0x0421,1,1028},
+ {{0x00000000,0x00000000,0x00000000},0x0441,1,1028},
+ {{0x00000000,0x00000000,0x00000000},0x015c,1,184},
+ {{0x00000000,0x00000000,0x00000000},0x015d,1,184},
+ {{0x40000001,0x00000000,0x00000000},0x3055,0,1843},
+ {{0x00000001,0x00000020,0x00000000},0x30b5,0,1843},
+ {{0x00000081,0x00000000,0x00000000},0x0635,1,1469},
+ {{0x00000081,0x00000010,0x00000000},0xfeb9,1,1469},
+ {{0x01000081,0x00000000,0x00000000},0xfeba,1,1469},
+ {{0x00000081,0x00000004,0x00000000},0xfebb,1,1469},
+ {{0x00000081,0x00001000,0x00000000},0xfebc,1,1469},
+ {{0x20000001,0x00000000,0x00000000},0x05e1,1,1270},
+ {{0x08000001,0x00000000,0x00000000},0x03e0,1,866},
+ {{0x00000000,0x00000000,0x00000000},0x2022,0,1170},
+ {{0x00000000,0x00000000,0x00000000},0x2219,0,1170},
+ {{0x00000000,0x00000000,0x00000000},0x25aa,0,1170},
+ {{0x00000000,0x00000000,0x00000000},0x0429,0,2327},
+ {{0x00000000,0x00000000,0x00000000},0x0449,0,2327},
+ {{0x40000001,0x00000000,0x00000000},0x305b,0,2561},
+ {{0x00000001,0x00000020,0x00000000},0x30bb,0,2561},
+ {{0x00000081,0x00000000,0x00000000},0x0633,1,1455},
+ {{0x00000081,0x00000010,0x00000000},0xfeb1,1,1455},
+ {{0x01000081,0x00000000,0x00000000},0xfeb2,1,1455},
+ {{0x00000081,0x00000004,0x00000000},0xfeb3,1,1455},
+ {{0x00000081,0x00001000,0x00000000},0xfeb4,1,1455},
+ {{0x40000000,0x00000820,0x00000000},0x309c,1,6691},
+ {{0x00000080,0x00000000,0x00000000},0x061b,0,1487},
+ {{0x00000000,0x00000200,0x00000000},0x2028,1,3077},
+ {{0x00000000,0x00000800,0x00000000},0x2120,1,3471},
+ {{0x00000000,0x00000000,0x00000020},0x2077,0,1464},
+ {{0x00000000,0x00000000,0x00000040},0x2087,0,1464},
+ {{0x00004001,0x00000000,0x00000000},0x2466,0,1464},
+ {{0x00000001,0x00040000,0x00000000},0x247a,0,1464},
+ {{0x00000081,0x00000000,0x00000400},0x0667,0,1464},
+ {{0x00000000,0x00804000,0x00000000},0x2166,0,1464},
+ {{0x02000001,0x00000000,0x00000002},0x248e,0,1464},
+ {{0x00000000,0x00040000,0x00000800},0x3226,0,1464},
+ {{0x00000004,0x00804000,0x00000000},0x2176,0,1464},
+ {{0x00000000,0x00000000,0x00000018},0x215e,1,3672},
+ {{0x00004000,0x00002000,0x00000000},0x2470,1,4992},
+ {{0x00000000,0x00042000,0x00000000},0x2484,1,4992},
+ {{0x02000000,0x00002000,0x00000002},0x2498,1,4992},
+ {{0x00000000,0x00000000,0x00000000},0x05e9,0,728},
+ {{0x00000201,0x00000000,0x00000000},0x3115,0,728},
+ {{0x00010003,0x00000000,0x00000000},0x0428,1,1066},
+ {{0x00010005,0x00000000,0x00000000},0x0448,1,1066},
+ {{0x00000080,0x00000000,0x00000000},0x0651,1,1629},
+ {{0x00000081,0x00001000,0x00000000},0xfe7d,1,1629},
+ {{0x00000000,0x00000100,0x00000000},0x2591,1,5698},
+ {{0x00010003,0x00000000,0x00000000},0x0429,1,1073},
+ {{0x00010005,0x00000000,0x00000000},0x0449,1,1073},
+ {{0x00000081,0x00000000,0x00000000},0x0634,1,1460},
+ {{0x00000081,0x00000010,0x00000000},0xfeb5,1,1460},
+ {{0x01000081,0x00000000,0x00000000},0xfeb6,1,1460},
+ {{0x00000081,0x00000004,0x00000000},0xfeb7,1,1460},
+ {{0x00000081,0x00001000,0x00000000},0xfeb8,1,1460},
+ {{0x20000001,0x00000000,0x00000000},0x05e9,1,1318},
+ {{0x40000001,0x00000000,0x00000000},0x3057,0,927},
+ {{0x00000001,0x00000020,0x00000000},0x30b7,0,927},
+ {{0x08000003,0x00000000,0x00000000},0x03a3,1,766},
+ {{0x08000005,0x00000000,0x00000000},0x03c3,1,766},
+ {{0x09000005,0x00000000,0x00000000},0x03c2,1,766},
+ {{0x00000000,0x00000000,0x00000020},0x2076,0,1460},
+ {{0x00000000,0x00000000,0x00000040},0x2086,0,1460},
+ {{0x00004001,0x00000000,0x00000000},0x2465,0,1460},
+ {{0x00000001,0x00040000,0x00000000},0x2479,0,1460},
+ {{0x00000081,0x00000000,0x00000400},0x0666,0,1460},
+ {{0x00000000,0x00804000,0x00000000},0x2165,0,1460},
+ {{0x02000001,0x00000000,0x00000002},0x248d,0,1460},
+ {{0x00000000,0x00040000,0x00000800},0x3225,0,1460},
+ {{0x00000004,0x00804000,0x00000000},0x2175,0,1460},
+ {{0x00000000,0x00000000,0x00000200},0x2006,1,2856},
+ {{0x00004000,0x00002000,0x00000000},0x246f,1,4979},
+ {{0x00000000,0x00042000,0x00000000},0x2483,1,4979},
+ {{0x02000000,0x00002000,0x00000002},0x2497,1,4979},
+ {{0x00000000,0x00010000,0x00000018},0x2159,1,3605},
+ {{0x00000000,0x00000000,0x00000008},0x2044,0,1429},
+ {{0x00000000,0x00000000,0x00000000},0x2120,1,3479},
+ {{0x00000000,0x80000000,0x00000000},0x263a,1,6087},
+ {{0x00000000,0x00000000,0x00000004},0x263b,1,6087},
+ {{0x00000000,0x00000000,0x00000000},0x0634,1,1466},
+ {{0x00000000,0x00000000,0x00000000},0x25d8,1,1466},
+ {{0x00000000,0x00000000,0x00000000},0xfeb7,1,7183},
+ {{0x00000000,0x00000000,0x00000000},0xfeb5,1,7175},
+ {{0x00000000,0x00000000,0x00000000},0xfeb6,1,7179},
+ {{0x00000000,0x00000000,0x00000000},0xfeb8,1,7187},
+ {{0x40000001,0x00000000,0x00000000},0x305d,0,915},
+ {{0x00000001,0x00000020,0x00000000},0x30bd,0,915},
+ {{0x00010003,0x00000000,0x00000000},0x042c,1,1095},
+ {{0x00010005,0x00000000,0x00000000},0x044c,1,1095},
+ {{0x00000000,0x00000000,0x00000000},0x2117,1,3421},
+ {{0x00000000,0x00000000,0x00002000},0x2198,1,3944},
+ {{0x00000000,0x00000000,0x00002000},0x2199,1,3959},
+ {{0x00000000,0x00000000,0x00008004},0x2660,1,6133},
+ {{0x00000000,0x80000000,0x00008000},0x2664,1,6133},
+ {{0x00000000,0x00000000,0x00000000},0x25ac,1,5872},
+ {{0x00000000,0x00000000,0x00000000},0xfb05,0,2387},
+ {{0x00000000,0x00000000,0x00000000},0xfb06,0,2387},
+ {{0x00000004,0x00000040,0x00000100},0xfb06,0,2387},
+ {{0x00000000,0x00000000,0x00000004},0x2605,1,6041},
+ {{0x00000000,0x80000000,0x00000000},0x2606,1,6041},
+ {{0x08000001,0x00000000,0x00000000},0x03da,1,836},
+ {{0x00000000,0x00000000,0x00000000},0x263c,1,6112},
+ {{0x40000001,0x00000000,0x00000000},0x3059,1,6112},
+ {{0x00000001,0x00000020,0x00000000},0x30b9,1,6112},
+ {{0x00000000,0x00000000,0x00000001},0x2282,1,4586},
+ {{0x00000000,0x04000000,0x00011001},0x2286,1,4586},
+ {{0x00000080,0x00000000,0x00000000},0x0652,1,1639},
+ {{0x00000001,0x80000000,0x00000000},0x263c,1,6103},
+ {{0x00000000,0x00000000,0x00000001},0x2283,1,4596},
+ {{0x00000000,0x04000000,0x00011001},0x2287,1,4596},
+ {{0x00000201,0x00000000,0x00000000},0x310a,0,1584},
+ {{0x00002003,0x00000040,0x00000000},0x0162,0,1584},
+ {{0x00002005,0x00000040,0x00000000},0x0163,0,1584},
+ {{0x00001003,0x00000040,0x00000000},0x0164,0,1584},
+ {{0x00001005,0x00000040,0x00000000},0x0165,0,1584},
+ {{0x00000003,0x00000040,0x10000000},0x0166,0,1584},
+ {{0x00000005,0x00000040,0x10000000},0x0167,0,1584},
+ {{0x00000005,0x00040040,0x00000000},0x24af,0,1584},
+ {{0x00004003,0x00000040,0x00000000},0x24c9,0,1584},
+ {{0x00004005,0x00000040,0x00000000},0x24e3,0,1584},
+ {{0x0008000b,0x00000040,0x00000000},0x1e6a,0,1584},
+ {{0x0008000d,0x00000040,0x00000000},0x1e6b,0,1584},
+ {{0x00080103,0x00000040,0x00000000},0x1e6c,0,1584},
+ {{0x00080105,0x00000040,0x00000000},0x1e6d,0,1584},
+ {{0x00000103,0x00000240,0x00000000},0x1e6e,0,1584},
+ {{0x00000105,0x00000240,0x00000000},0x1e6f,0,1584},
+ {{0x00008103,0x00000040,0x00000000},0x1e70,0,1584},
+ {{0x00008105,0x00000040,0x00000000},0x1e71,0,1584},
+ {{0x00000000,0x00000000,0x00000000},0x24c9,1,5389},
+ {{0x00000000,0x00000000,0x00000000},0x24e3,1,5389},
+ {{0x00000000,0x00000000,0x00000000},0x03a4,1,779},
+ {{0x00000000,0x00000000,0x00000000},0x03c4,1,779},
+ {{0x00000000,0x00000000,0x00000000},0x05ea,1,1327},
+ {{0x00000000,0x00000000,0x00000000},0x062a,1,1327},
+ {{0x00000000,0x00000000,0x00000000},0xfe97,1,7055},
+ {{0x00000000,0x00000000,0x00000000},0xfe95,1,7047},
+ {{0x00000000,0x00000000,0x00000000},0xfe96,1,7051},
+ {{0x00000000,0x00000000,0x00000000},0xfe98,1,7059},
+ {{0x00000000,0x00000000,0x00000000},0x0162,1,193},
+ {{0x00000000,0x00000000,0x00000000},0x0163,1,193},
+ {{0x00000000,0x00000000,0x00000000},0x1e6c,1,1924},
+ {{0x00000000,0x00000000,0x00000000},0x1e6d,1,1924},
+ {{0x00000000,0x00000000,0x00000000},0x1e70,1,1931},
+ {{0x00000000,0x00000000,0x00000000},0x1e71,1,1931},
+ {{0x00000000,0x00000000,0x00000000},0x1e6a,1,1921},
+ {{0x00000000,0x00000000,0x00000000},0x1e6b,1,1921},
+ {{0x00000000,0x00000000,0x00000000},0x0166,1,199},
+ {{0x00000000,0x00000000,0x00000000},0x0167,1,199},
+ {{0x00000000,0x00000000,0x00000000},0x03da,1,843},
+ {{0x00000000,0x00000000,0x00000000},0x310a,1,6802},
+ {{0x00000000,0x00000000,0x00000000},0x0164,1,196},
+ {{0x00000000,0x00000000,0x00000000},0x0165,1,196},
+ {{0x00000000,0x00000000,0x00000000},0x0422,1,1034},
+ {{0x00000000,0x00000000,0x00000000},0x0442,1,1034},
+ {{0x00000000,0x00000000,0x00000000},0x1e6e,1,1928},
+ {{0x00000000,0x00000000,0x00000000},0x1e6f,1,1928},
+ {{0x40000001,0x00000000,0x00000000},0x305f,1,6597},
+ {{0x00000001,0x00000020,0x00000000},0x30bf,1,6597},
+ {{0x00000000,0x08000000,0x00000000},0x22a5,1,4620},
+ {{0x00000081,0x00000000,0x00000000},0x0637,1,1483},
+ {{0x00000081,0x00000010,0x00000000},0xfec1,1,1483},
+ {{0x01000081,0x00000000,0x00000000},0xfec2,1,1483},
+ {{0x00000081,0x00000004,0x00000000},0xfec3,1,1483},
+ {{0x00000081,0x00001000,0x00000000},0xfec4,1,1483},
+ {{0x00000080,0x00000000,0x00000000},0x0640,1,1507},
+ {{0x08000003,0x00000000,0x00000000},0x03a4,1,775},
+ {{0x08000005,0x00000000,0x00000000},0x03c4,1,775},
+ {{0x20000001,0x00000000,0x00000000},0x05ea,1,1323},
+ {{0x00000000,0x00000000,0x00000000},0x2580,1,5668},
+ {{0x00000000,0x00000000,0x00000000},0x0686,1,1707},
+ {{0x00000081,0x00000000,0x00000000},0x0686,1,1701},
+ {{0x00000000,0x00000000,0x00000000},0x2203,1,1031},
+ {{0x40000001,0x00000000,0x00000000},0x3066,1,1031},
+ {{0x00000001,0x00000020,0x00000000},0x30c6,1,1031},
+ {{0x00010003,0x00000000,0x00000000},0x0422,1,1031},
+ {{0x00010005,0x00000000,0x00000000},0x0442,1,1031},
+ {{0x00000081,0x00000000,0x00000000},0x062a,1,1405},
+ {{0x00000081,0x00000010,0x00000000},0xfe95,1,1405},
+ {{0x01000081,0x00000000,0x00000000},0xfe96,1,1405},
+ {{0x00000081,0x00000004,0x00000000},0xfe97,1,1405},
+ {{0x00000081,0x00001000,0x00000000},0xfe98,1,1405},
+ {{0x00000081,0x00000000,0x00000000},0x0629,1,1390},
+ {{0x00000081,0x00000010,0x00000000},0xfe93,1,1390},
+ {{0x01000081,0x00000000,0x00000000},0xfe94,1,1390},
+ {{0x00000000,0x00000000,0x00000000},0x260e,1,6062},
+ {{0x00000000,0x00000000,0x00000000},0x260f,1,6062},
+ {{0x00000000,0x00000000,0x00000004},0x260e,1,6052},
+ {{0x00000000,0x80000000,0x00000000},0x260f,1,6052},
+ {{0x00000000,0x00000000,0x00000000},0x2315,1,4692},
+ {{0x00000000,0x00804000,0x00000000},0x2169,1,3716},
+ {{0x00004000,0x00002000,0x00000000},0x2469,1,3716},
+ {{0x00000000,0x00042000,0x00000000},0x247d,1,3716},
+ {{0x00000000,0x00040000,0x00000800},0x3229,1,3716},
+ {{0x00000004,0x00804000,0x00000000},0x2179,1,3716},
+ {{0x02000000,0x00002000,0x00000002},0x2491,1,3716},
+ {{0x00000000,0x00804000,0x00000000},0x2182,1,3837},
+ {{0x20000001,0x00000000,0x00000000},0x05d8,1,1217},
+ {{0x00000081,0x00000000,0x00000000},0x0630,1,1438},
+ {{0x00000081,0x00000010,0x00000000},0xfeab,1,1438},
+ {{0x01000081,0x00000000,0x00000000},0xfeac,1,1438},
+ {{0x00000081,0x00000000,0x00000000},0x062b,1,1409},
+ {{0x00000081,0x00000010,0x00000000},0xfe99,1,1409},
+ {{0x01000081,0x00000000,0x00000000},0xfe9a,1,1409},
+ {{0x00000081,0x00000004,0x00000000},0xfe9b,1,1409},
+ {{0x00000081,0x00001000,0x00000000},0xfe9c,1,1409},
+ {{0x00000000,0x00000000,0x00000000},0x2203,1,4062},
+ {{0x00000000,0x00000000,0x00000000},0x2234,1,4373},
+ {{0x08000003,0x00000000,0x00000000},0x0398,1,708},
+ {{0x08000005,0x00000000,0x00000000},0x03b8,1,708},
+ {{0x00000000,0x00000000,0x00000200},0x2009,1,2870},
+ {{0x00000000,0x00010000,0x00000018},0x2153,1,3528},
+ {{0x00004000,0x00002000,0x00000000},0x246c,1,4938},
+ {{0x00000000,0x00042000,0x00000000},0x2480,1,4938},
+ {{0x02000000,0x00002000,0x00000002},0x2494,1,4938},
+ {{0x00000000,0x00814000,0x00000000},0x216f,1,3781},
+ {{0x00000004,0x00814000,0x00000000},0x217f,1,3781},
+ {{0x00000000,0x00814000,0x00000000},0x2180,1,3796},
+ {{0x00000000,0x00000000,0x00000040},0x2083,0,1444},
+ {{0x00004001,0x00000000,0x00000000},0x2462,0,1444},
+ {{0x00000001,0x00040000,0x00000000},0x2476,0,1444},
+ {{0x00000081,0x00000000,0x00000400},0x0663,0,1444},
+ {{0x00000000,0x00804000,0x00000000},0x2162,0,1444},
+ {{0x02000001,0x00000000,0x00000002},0x248a,0,1444},
+ {{0x00000000,0x00040000,0x00000800},0x3222,0,1444},
+ {{0x00000004,0x00804000,0x00000000},0x2172,0,1444},
+ {{0x00000000,0x00000000,0x00000018},0x215c,1,3639},
+ {{0x00000000,0x00000000,0x00000018},0x2157,1,3574},
+ {{0x00000000,0x00000000,0x00000200},0x2004,1,2825},
+ {{0x40000001,0x00000000,0x00000000},0x3061,1,6603},
+ {{0x00000001,0x00000020,0x00000000},0x30c1,1,6603},
+ {{0x00000000,0x00000000,0x00000000},0x05d8,1,1221},
+ {{0x00000000,0x00000000,0x00000000},0x0637,1,1221},
+ {{0x00000000,0x00000000,0x00000000},0xfec3,1,7231},
+ {{0x00000000,0x00000000,0x00000000},0xfec1,1,7223},
+ {{0x00000000,0x00000000,0x00000000},0xfec2,1,7227},
+ {{0x00000000,0x00000000,0x00000000},0xfec4,1,7235},
+ {{0x00000000,0x00000000,0x00000000},0x062b,1,1414},
+ {{0x00000000,0x00000000,0x00000000},0xfe9b,1,7071},
+ {{0x00000000,0x00000000,0x00000000},0xfe99,1,7063},
+ {{0x00000000,0x00000000,0x00000000},0xfe9a,1,7067},
+ {{0x00000000,0x00000000,0x00000000},0xfe9c,1,7075},
+ {{0x00000000,0x00000000,0x00000000},0x25c1,1,5916},
+ {{0x00000000,0x00000000,0x00000000},0x0629,1,1402},
+ {{0x00000000,0x00000000,0x00000000},0x2122,1,1402},
+ {{0x00000000,0x00000000,0x00000000},0xfe93,1,7039},
+ {{0x00000000,0x00000000,0x00000000},0xfe94,1,7043},
+ {{0x00000000,0x00000000,0x00080000},0x2320,1,4732},
+ {{0x00000000,0x00000080,0x00020000},0x3014,1,6486},
+ {{0x00000000,0x00400000,0x00020000},0x3015,1,6486},
+ {{0x00000000,0x00000000,0x00000000},0x2315,1,4711},
+ {{0x00000000,0x00000000,0x00000000},0x25b7,1,4711},
+ {{0x00000001,0x00000800,0x00000000},0x2122,1,3482},
+ {{0x00000000,0x00000000,0x00000000},0x2023,1,3009},
+ {{0x00400400,0x00000101,0x00000000},0x2504,1,5441},
+ {{0x10400400,0x00000001,0x00000000},0x2505,1,5441},
+ {{0x00400400,0x40000100,0x00000000},0x2506,1,5441},
+ {{0x10400400,0x40000000,0x00000000},0x2507,1,5441},
+ {{0x00000000,0x00000000,0x00000000},0x2034,1,3147},
+ {{0x00000000,0x00000000,0x00000000},0x040b,0,2156},
+ {{0x00000000,0x00000000,0x00000000},0x045b,0,2156},
+ {{0x20000001,0x00000000,0x00000000},0x05e6,1,1294},
+ {{0x21000001,0x00000000,0x00000000},0x05e5,1,1294},
+ {{0x00010003,0x00000000,0x00000000},0x0426,1,1052},
+ {{0x00010005,0x00000000,0x00000000},0x0446,1,1052},
+ {{0x00010003,0x00000000,0x00000000},0x040b,1,922},
+ {{0x00010005,0x00000000,0x00000000},0x045b,1,922},
+ {{0x40000001,0x00000000,0x00000000},0x3064,1,6606},
+ {{0x00000001,0x00000020,0x00000000},0x30c4,1,6606},
+ {{0x40000005,0x00000000,0x00000000},0x3063,1,6606},
+ {{0x00000005,0x00000020,0x00000000},0x30c3,1,6606},
+ {{0x00000005,0x00000040,0x00000000},0x01dd,1,343},
+ {{0x00000000,0x00804000,0x00000000},0x216b,1,3733},
+ {{0x00004000,0x00002000,0x00000000},0x246b,1,3733},
+ {{0x00000000,0x00042000,0x00000000},0x247f,1,3733},
+ {{0x00000004,0x00804000,0x00000000},0x217b,1,3733},
+ {{0x02000000,0x00002000,0x00000002},0x2493,1,3733},
+ {{0x00004000,0x00002000,0x00000000},0x2473,1,5035},
+ {{0x00000000,0x00042000,0x00000000},0x2487,1,5035},
+ {{0x02000000,0x00002000,0x00000002},0x249b,1,5035},
+ {{0x00000000,0x00000000,0x00000040},0x2082,0,1440},
+ {{0x00004001,0x00000000,0x00000000},0x2461,0,1440},
+ {{0x00000001,0x00040000,0x00000000},0x2475,0,1440},
+ {{0x00000081,0x00000000,0x00000400},0x0662,0,1440},
+ {{0x00000000,0x00804000,0x00000000},0x2161,0,1440},
+ {{0x02000001,0x00000000,0x00000002},0x2489,0,1440},
+ {{0x00000000,0x00040000,0x00000800},0x3221,0,1440},
+ {{0x00000004,0x00804000,0x00000000},0x2171,0,1440},
+ {{0x00000000,0x00000000,0x00000018},0x2156,1,3560},
+ {{0x00080000,0x00000000,0x00000000},0x2025,1,3030},
+ {{0x00000000,0x00000000,0x00000018},0x2154,1,3537},
+ {{0x40000001,0x00000000,0x00000000},0x3046,0,1586},
+ {{0x00000001,0x00000020,0x00000000},0x30a6,0,1586},
+ {{0x00000201,0x00000000,0x00000000},0x3128,0,1586},
+ {{0x00010003,0x00000000,0x00000000},0x0423,0,1586},
+ {{0x00010005,0x00000000,0x00000000},0x0443,0,1586},
+ {{0x40000005,0x00000000,0x00000000},0x3045,0,1586},
+ {{0x00000005,0x00000020,0x00000000},0x30a5,0,1586},
+ {{0x00000003,0x02000040,0x00000000},0x0168,0,1586},
+ {{0x00000005,0x02000040,0x00000000},0x0169,0,1586},
+ {{0x00000003,0x00000440,0x00000000},0x016a,0,1586},
+ {{0x00000005,0x00000440,0x00000000},0x016b,0,1586},
+ {{0x00000803,0x00000040,0x00000000},0x016c,0,1586},
+ {{0x00000805,0x00000040,0x00000000},0x016d,0,1586},
+ {{0x00000003,0x00000040,0x02000000},0x0172,0,1586},
+ {{0x00000005,0x00000040,0x02000000},0x0173,0,1586},
+ {{0x00000003,0x00000042,0x00000000},0x01af,0,1586},
+ {{0x00000005,0x00000042,0x00000000},0x01b0,0,1586},
+ {{0x00001003,0x00000040,0x00000000},0x01d3,0,1586},
+ {{0x00001005,0x00000040,0x00000000},0x01d4,0,1586},
+ {{0x00010003,0x00000000,0x08000000},0x040e,0,1586},
+ {{0x00010005,0x00000000,0x08000000},0x045e,0,1586},
+ {{0x00000005,0x00040040,0x00000000},0x24b0,0,1586},
+ {{0x00004003,0x00000040,0x00000000},0x24ca,0,1586},
+ {{0x00004005,0x00000040,0x00000000},0x24e4,0,1586},
+ {{0x0000000b,0x00000040,0x04000000},0x016e,0,1586},
+ {{0x0000000d,0x00000040,0x04000000},0x016f,0,1586},
+ {{0x00100013,0x00000040,0x00000000},0x0170,0,1586},
+ {{0x00100015,0x00000040,0x00000000},0x0171,0,1586},
+ {{0x00040003,0x00000440,0x00000000},0x01d5,0,1586},
+ {{0x00040005,0x00000440,0x00000000},0x01d6,0,1586},
+ {{0x00040013,0x00000040,0x00000000},0x01d7,0,1586},
+ {{0x00040015,0x00000040,0x00000000},0x01d8,0,1586},
+ {{0x00041003,0x00000040,0x00000000},0x01d9,0,1586},
+ {{0x00041005,0x00000040,0x00000000},0x01da,0,1586},
+ {{0x04040003,0x00000040,0x00000000},0x01db,0,1586},
+ {{0x04040005,0x00000040,0x00000000},0x01dc,0,1586},
+ {{0x04100003,0x00000040,0x00000000},0x0214,0,1586},
+ {{0x04100005,0x00000040,0x00000000},0x0215,0,1586},
+ {{0x00000803,0x00000040,0x00800000},0x0216,0,1586},
+ {{0x00000805,0x00000040,0x00800000},0x0217,0,1586},
+ {{0x00040103,0x00000040,0x00000000},0x1e72,0,1586},
+ {{0x00040105,0x00000040,0x00000000},0x1e73,0,1586},
+ {{0x00000103,0x02000040,0x00000000},0x1e74,0,1586},
+ {{0x00000105,0x02000040,0x00000000},0x1e75,0,1586},
+ {{0x00008103,0x00000040,0x00000000},0x1e76,0,1586},
+ {{0x00008105,0x00000040,0x00000000},0x1e77,0,1586},
+ {{0x00000013,0x02000040,0x00000000},0x1e78,0,1586},
+ {{0x00000015,0x02000040,0x00000000},0x1e79,0,1586},
+ {{0x00040003,0x00000440,0x00000000},0x1e7a,0,1586},
+ {{0x00040005,0x00000440,0x00000000},0x1e7b,0,1586},
+ {{0x00080103,0x00000040,0x00000000},0x1ee4,0,1586},
+ {{0x00080105,0x00000040,0x00000000},0x1ee5,0,1586},
+ {{0x8000000b,0x00000040,0x00000000},0x1ee6,0,1586},
+ {{0x8000000d,0x00000040,0x00000000},0x1ee7,0,1586},
+ {{0x00000013,0x00000042,0x00000000},0x1ee8,0,1586},
+ {{0x00000015,0x00000042,0x00000000},0x1ee9,0,1586},
+ {{0x04000003,0x00000042,0x00000000},0x1eea,0,1586},
+ {{0x04000005,0x00000042,0x00000000},0x1eeb,0,1586},
+ {{0x00000003,0x02000042,0x00000000},0x1eee,0,1586},
+ {{0x00000005,0x02000042,0x00000000},0x1eef,0,1586},
+ {{0x8000000b,0x00000042,0x00000000},0x1eec,0,1586},
+ {{0x8000000d,0x00000042,0x00000000},0x1eed,0,1586},
+ {{0x00080103,0x00000042,0x00000000},0x1ef0,0,1586},
+ {{0x00080105,0x00000042,0x00000000},0x1ef1,0,1586},
+ {{0x00000000,0x00000000,0x00000000},0x24ca,1,5393},
+ {{0x00000000,0x00000000,0x00000000},0x24e4,1,5393},
+ {{0x00000000,0x00000000,0x00000000},0x0214,1,439},
+ {{0x00000000,0x00000000,0x00000000},0x0215,1,439},
+ {{0x00000000,0x00000000,0x00000000},0x0170,1,214},
+ {{0x00000000,0x00000000,0x00000000},0x0171,1,214},
+ {{0x00000000,0x00000000,0x00000000},0x038e,1,656},
+ {{0x00000000,0x00000000,0x00000000},0x03cd,1,656},
+ {{0x00000000,0x00000000,0x00000000},0x016c,1,208},
+ {{0x00000000,0x00000000,0x00000000},0x016d,1,208},
+ {{0x00000000,0x00000000,0x00000000},0x0216,1,443},
+ {{0x00000000,0x00000000,0x00000000},0x0217,1,443},
+ {{0x00000000,0x00000000,0x00000000},0x03a5,1,782},
+ {{0x00000000,0x00000000,0x00000000},0x03c5,1,782},
+ {{0x00000000,0x00000000,0x00000000},0x1f7a,1,2461},
+ {{0x00000000,0x00000000,0x00000000},0x1fea,1,2461},
+ {{0x00000000,0x00000000,0x00000000},0x1f7b,1,2465},
+ {{0x00000000,0x00000000,0x00000000},0x1feb,1,2465},
+ {{0x00000000,0x00000000,0x00000000},0x1fe0,1,2746},
+ {{0x00000000,0x00000000,0x00000000},0x1fe8,1,2746},
+ {{0x00000000,0x00000000,0x00000000},0x1f50,1,2345},
+ {{0x00000000,0x00000000,0x00000000},0x1f52,1,2353},
+ {{0x00000000,0x00000000,0x00000000},0x1f54,1,2363},
+ {{0x00000000,0x00000000,0x00000000},0x1f56,1,2373},
+ {{0x00000000,0x00000000,0x00000000},0x1fe1,1,2750},
+ {{0x00000000,0x00000000,0x00000000},0x1fe9,1,2750},
+ {{0x00000000,0x00000000,0x00000000},0x1fe2,1,2754},
+ {{0x00000000,0x00000000,0x00000000},0x1fe3,1,2759},
+ {{0x00000000,0x00000000,0x00000000},0x1fe7,1,2776},
+ {{0x00000000,0x00000000,0x00000000},0x1f51,1,2349},
+ {{0x00000000,0x00000000,0x00000000},0x1f59,1,2349},
+ {{0x00000000,0x00000000,0x00000000},0x1f53,1,2358},
+ {{0x00000000,0x00000000,0x00000000},0x1f5b,1,2358},
+ {{0x00000000,0x00000000,0x00000000},0x1f55,1,2368},
+ {{0x00000000,0x00000000,0x00000000},0x1f5d,1,2368},
+ {{0x00000000,0x00000000,0x00000000},0x1f57,1,2378},
+ {{0x00000000,0x00000000,0x00000000},0x1f5f,1,2378},
+ {{0x00000000,0x00000000,0x00000000},0x1fe6,1,2772},
+ {{0x00000000,0x00000000,0x00000000},0x016a,1,205},
+ {{0x00000000,0x00000000,0x00000000},0x016b,1,205},
+ {{0x00000000,0x00000000,0x00000000},0x1e72,1,1935},
+ {{0x00000000,0x00000000,0x00000000},0x1e73,1,1935},
+ {{0x00000000,0x00000000,0x00000000},0x1ee4,1,2134},
+ {{0x00000000,0x00000000,0x00000000},0x1ee5,1,2134},
+ {{0x00000000,0x00000000,0x00000000},0x1e7a,1,1952},
+ {{0x00000000,0x00000000,0x00000000},0x1e7b,1,1952},
+ {{0x00000000,0x00000000,0x00000000},0x1e76,1,1944},
+ {{0x00000000,0x00000000,0x00000000},0x1e77,1,1944},
+ {{0x00000000,0x00000000,0x00000000},0x1e74,1,1940},
+ {{0x00000000,0x00000000,0x00000000},0x1e75,1,1940},
+ {{0x00000000,0x00000000,0x00000000},0x016e,1,211},
+ {{0x00000000,0x00000000,0x00000000},0x016f,1,211},
+ {{0x00000000,0x00000000,0x00000000},0x1ee6,1,2138},
+ {{0x00000000,0x00000000,0x00000000},0x1ee7,1,2138},
+ {{0x00000000,0x00000000,0x00000000},0x03b0,1,815},
+ {{0x00000000,0x00000000,0x00000000},0x3128,1,6873},
+ {{0x00000000,0x00000000,0x00000000},0x3045,1,6549},
+ {{0x00000000,0x00000000,0x00000000},0x3046,1,6549},
+ {{0x00000000,0x00000000,0x00000000},0x30a5,1,6741},
+ {{0x00000000,0x00000000,0x00000000},0x30a6,1,6741},
+ {{0x00000000,0x00000000,0x00000000},0x01af,1,269},
+ {{0x00000000,0x00000000,0x00000000},0x01b0,1,269},
+ {{0x00000000,0x00000000,0x00000000},0x1eea,1,2145},
+ {{0x00000000,0x00000000,0x00000000},0x1eeb,1,2145},
+ {{0x00000000,0x00000000,0x00000000},0x1ee8,1,2141},
+ {{0x00000000,0x00000000,0x00000000},0x1ee9,1,2141},
+ {{0x00000000,0x00000000,0x00000000},0x1ef0,1,2157},
+ {{0x00000000,0x00000000,0x00000000},0x1ef1,1,2157},
+ {{0x00000000,0x00000000,0x00000000},0x1eec,1,2149},
+ {{0x00000000,0x00000000,0x00000000},0x1eed,1,2149},
+ {{0x00000000,0x00000000,0x00000000},0x1eee,1,2153},
+ {{0x00000000,0x00000000,0x00000000},0x1eef,1,2153},
+ {{0x00000000,0x00000000,0x00000000},0x01db,1,339},
+ {{0x00000000,0x00000000,0x00000000},0x01dc,1,339},
+ {{0x00000000,0x00000000,0x00000000},0x01d7,1,331},
+ {{0x00000000,0x00000000,0x00000000},0x01d8,1,331},
+ {{0x00000000,0x00000000,0x00000000},0x01d5,1,327},
+ {{0x00000000,0x00000000,0x00000000},0x01d6,1,327},
+ {{0x00000000,0x00000000,0x00000000},0x01d9,1,335},
+ {{0x00000000,0x00000000,0x00000000},0x01da,1,335},
+ {{0x00000000,0x00000000,0x00000000},0x0172,1,217},
+ {{0x00000000,0x00000000,0x00000000},0x0173,1,217},
+ {{0x00000000,0x00000000,0x00000000},0x01d3,1,324},
+ {{0x00000000,0x00000000,0x00000000},0x01d4,1,324},
+ {{0x00000000,0x00000000,0x00000000},0x0423,1,1037},
+ {{0x00000000,0x00000000,0x00000000},0x0443,1,1037},
+ {{0x00000000,0x00000000,0x00000000},0x0168,1,202},
+ {{0x00000000,0x00000000,0x00000000},0x0169,1,202},
+ {{0x00000000,0x00000000,0x00000000},0x1e78,1,1948},
+ {{0x00000000,0x00000000,0x00000000},0x1e79,1,1948},
+ {{0x00000000,0x00000000,0x00000000},0x2195,1,3911},
+ {{0x00000000,0x00000000,0x00000000},0x21a8,1,3979},
+ {{0x00000000,0x00000000,0x00000000},0x2540,1,5613},
+ {{0x00000000,0x00000000,0x00000000},0x2541,1,5613},
+ {{0x00000000,0x00000000,0x00000000},0x2547,1,5613},
+ {{0x00000000,0x00000000,0x00000000},0x2548,1,5613},
+ {{0x00000000,0x00000000,0x00000000},0x2526,1,5564},
+ {{0x00000000,0x00000000,0x00000000},0x2527,1,5564},
+ {{0x00000000,0x00000000,0x00000000},0x2529,1,5564},
+ {{0x00000000,0x00000000,0x00000000},0x252a,1,5564},
+ {{0x00000000,0x00000000,0x00000000},0x2543,1,5617},
+ {{0x00000000,0x00000000,0x00000000},0x2544,1,5617},
+ {{0x00000000,0x00000000,0x00000000},0x2545,1,5617},
+ {{0x00000000,0x00000000,0x00000000},0x2546,1,5617},
+ {{0x00000000,0x00000000,0x00000000},0x251e,1,5549},
+ {{0x00000000,0x00000000,0x00000000},0x251f,1,5549},
+ {{0x00000000,0x00000000,0x00000000},0x2521,1,5549},
+ {{0x00000000,0x00000000,0x00000000},0x2522,1,5549},
+ {{0x00000000,0x00000000,0x00000000},0x2534,1,5583},
+ {{0x00000000,0x00000000,0x00000000},0x2567,1,5583},
+ {{0x00000000,0x00000000,0x00000000},0x2568,1,5583},
+ {{0x00000000,0x00000000,0x00000000},0x2569,1,5583},
+ {{0x00000000,0x00000000,0x00000000},0x2537,1,5594},
+ {{0x00000000,0x00000000,0x00000000},0x2538,1,5594},
+ {{0x00000000,0x00000000,0x00000000},0x253b,1,5594},
+ {{0x00000000,0x00000000,0x00000000},0x2518,1,5527},
+ {{0x00000000,0x00000000,0x00000000},0x255b,1,5527},
+ {{0x00000000,0x00000000,0x00000000},0x255c,1,5527},
+ {{0x00000000,0x00000000,0x00000000},0x255d,1,5527},
+ {{0x00000000,0x00000000,0x00000000},0x2519,1,5534},
+ {{0x00000000,0x00000000,0x00000000},0x251a,1,5534},
+ {{0x00000000,0x00000000,0x00000000},0x251b,1,5534},
+ {{0x00000000,0x00000000,0x00000000},0x2535,1,5590},
+ {{0x00000000,0x00000000,0x00000000},0x2536,1,5590},
+ {{0x00000000,0x00000000,0x00000000},0x2539,1,5590},
+ {{0x00000000,0x00000000,0x00000000},0x253a,1,5590},
+ {{0x00000000,0x00000000,0x00000000},0x222a,1,4335},
+ {{0x00000000,0x00000000,0x00080000},0x2580,1,5656},
+ {{0x00000001,0x04400080,0x00000080},0x25a7,1,5814},
+ {{0x00000001,0x04400080,0x00000080},0x25a8,1,5814},
+ {{0x00000000,0x00000000,0x00002000},0x2191,1,3870},
+ {{0x00000000,0x00000000,0x00000000},0x2514,1,5516},
+ {{0x00000000,0x00000000,0x00000000},0x2558,1,5516},
+ {{0x00000000,0x00000000,0x00000000},0x2559,1,5516},
+ {{0x00000000,0x00000000,0x00000000},0x255a,1,5516},
+ {{0x00000000,0x00000000,0x00000000},0x2515,1,5523},
+ {{0x00000000,0x00000000,0x00000000},0x2516,1,5523},
+ {{0x00000000,0x00000000,0x00000000},0x2517,1,5523},
+ {{0x00000000,0x00000000,0x00000000},0x25b2,1,5893},
+ {{0x00000000,0x00000000,0x00000000},0x25b3,1,5893},
+ {{0x00000201,0x00000000,0x00000000},0x312a,0,1588},
+ {{0x00000003,0x02000040,0x00000000},0x1e7c,0,1588},
+ {{0x00000005,0x02000040,0x00000000},0x1e7d,0,1588},
+ {{0x00000005,0x00040040,0x00000000},0x24b1,0,1588},
+ {{0x00004003,0x00000040,0x00000000},0x24cb,0,1588},
+ {{0x00004005,0x00000040,0x00000000},0x24e5,0,1588},
+ {{0x00080103,0x00000040,0x00000000},0x1e7e,0,1588},
+ {{0x00080105,0x00000040,0x00000000},0x1e7f,0,1588},
+ {{0x00000000,0x00000000,0x00000000},0x24cb,1,5397},
+ {{0x00000000,0x00000000,0x00000000},0x24e5,1,5397},
+ {{0x00000000,0x00000000,0x00000000},0x040e,1,934},
+ {{0x00000000,0x00000000,0x00000000},0x045e,1,934},
+ {{0x00000000,0x00000000,0x00000000},0x03ab,1,812},
+ {{0x00000000,0x00000000,0x00000000},0x03cb,1,812},
+ {{0x00000000,0x00000000,0x00000000},0x06a4,1,1718},
+ {{0x00000000,0x00000000,0x00000000},0x1e7e,1,1959},
+ {{0x00000000,0x00000000,0x00000000},0x1e7f,1,1959},
+ {{0x00000000,0x00000000,0x00000000},0x0474,1,1151},
+ {{0x00000000,0x00000000,0x00000000},0x0475,1,1151},
+ {{0x00000000,0x00000000,0x00000000},0x312a,1,6876},
+ {{0x00000000,0x00000000,0x00000000},0x0412,1,954},
+ {{0x00000000,0x00000000,0x00000000},0x0432,1,954},
+ {{0x00000000,0x00000000,0x00000000},0x1e7c,1,1956},
+ {{0x00000000,0x00000000,0x00000000},0x1e7d,1,1956},
+ {{0x00000001,0x00000020,0x00000000},0x30f7,1,6753},
+ {{0x20000001,0x00000000,0x00000000},0x05d5,1,1194},
+ {{0x00000001,0x00000020,0x00000000},0x30f9,1,951},
+ {{0x00010003,0x00000000,0x00000000},0x0412,1,951},
+ {{0x00010005,0x00000000,0x00000000},0x0432,1,951},
+ {{0x00000081,0x00000000,0x00000000},0x06a4,1,1714},
+ {{0x00000000,0x00000000,0x00000000},0x253c,1,5598},
+ {{0x00000000,0x00000000,0x00000000},0x256a,1,5598},
+ {{0x00000000,0x00000000,0x00000000},0x256b,1,5598},
+ {{0x00000000,0x00000000,0x00000000},0x256c,1,5598},
+ {{0x00000000,0x00000000,0x00000000},0x253f,1,5609},
+ {{0x00000000,0x00000000,0x00000000},0x2542,1,5609},
+ {{0x00000000,0x00000000,0x00000000},0x254b,1,5609},
+ {{0x00000001,0x00000020,0x00000000},0x30f8,1,6756},
+ {{0x00000000,0x00000000,0x00000000},0x2524,1,5553},
+ {{0x00000000,0x00000000,0x00000000},0x2561,1,5553},
+ {{0x00000000,0x00000000,0x00000000},0x2562,1,5553},
+ {{0x00000000,0x00000000,0x00000000},0x2563,1,5553},
+ {{0x00000000,0x00000000,0x00000000},0x2525,1,5560},
+ {{0x00000000,0x00000000,0x00000000},0x2528,1,5560},
+ {{0x00000000,0x00000000,0x00000000},0x252b,1,5560},
+ {{0x00000000,0x00000000,0x00000000},0x253d,1,5605},
+ {{0x00000000,0x00000000,0x00000000},0x253e,1,5605},
+ {{0x00000000,0x00000000,0x00000000},0x2549,1,5605},
+ {{0x00000000,0x00000000,0x00000000},0x254a,1,5605},
+ {{0x00000001,0x00000020,0x00000000},0x30fa,1,6759},
+ {{0x40000000,0x00000800,0x00000000},0x309e,1,6715},
+ {{0x00000000,0x00000820,0x00000000},0x30fe,1,6715},
+ {{0x40000000,0x00000820,0x00000000},0x309b,1,6675},
+ {{0x00000000,0x00000000,0x00000000},0x251c,1,5538},
+ {{0x00000000,0x00000000,0x00000000},0x255e,1,5538},
+ {{0x00000000,0x00000000,0x00000000},0x255f,1,5538},
+ {{0x00000000,0x00000000,0x00000000},0x2560,1,5538},
+ {{0x00000000,0x00000000,0x00000000},0x251d,1,5545},
+ {{0x00000000,0x00000000,0x00000000},0x2520,1,5545},
+ {{0x00000000,0x00000000,0x00000000},0x2523,1,5545},
+ {{0x08000045,0x00000000,0x00000000},0x1fb0,1,2615},
+ {{0x08000043,0x00000000,0x00000000},0x1fb8,1,2615},
+ {{0x08000005,0x00000008,0x00000000},0x1fd0,1,2615},
+ {{0x08000003,0x00000008,0x00000000},0x1fd8,1,2615},
+ {{0x08000005,0x10000000,0x00000000},0x1fe0,1,2615},
+ {{0x08000003,0x10000000,0x00000000},0x1fe8,1,2615},
+ {{0x00000000,0x00000000,0x00000000},0x2423,0,1960},
+ {{0x40000001,0x00000000,0x00000000},0x3094,1,6672},
+ {{0x00000001,0x00000020,0x00000000},0x30f4,1,6672},
+ {{0x00000000,0x00000000,0x00000000},0x2502,1,5431},
+ {{0x00000000,0x00000000,0x00000000},0x2551,1,5431},
+ {{0x00000000,0x00000000,0x00000000},0x2503,1,5437},
+ {{0x00008003,0x00000040,0x00000000},0x0174,0,1590},
+ {{0x00008005,0x00000040,0x00000000},0x0175,0,1590},
+ {{0x04000003,0x00000040,0x00000000},0x1e80,0,1590},
+ {{0x04000005,0x00000040,0x00000000},0x1e81,0,1590},
+ {{0x00000013,0x00000040,0x00000000},0x1e82,0,1590},
+ {{0x00000015,0x00000040,0x00000000},0x1e83,0,1590},
+ {{0x00040003,0x00000040,0x00000000},0x1e84,0,1590},
+ {{0x00040005,0x00000040,0x00000000},0x1e85,0,1590},
+ {{0x00000005,0x00040040,0x00000000},0x24b2,0,1590},
+ {{0x00004003,0x00000040,0x00000000},0x24cc,0,1590},
+ {{0x00004005,0x00000040,0x00000000},0x24e6,0,1590},
+ {{0x0008000b,0x00000040,0x00000000},0x1e86,0,1590},
+ {{0x0008000d,0x00000040,0x00000000},0x1e87,0,1590},
+ {{0x00080103,0x00000040,0x00000000},0x1e88,0,1590},
+ {{0x00080105,0x00000040,0x00000000},0x1e89,0,1590},
+ {{0x00000000,0x00000000,0x00000000},0x24cc,1,5401},
+ {{0x00000000,0x00000000,0x00000000},0x24e6,1,5401},
+ {{0x00000000,0x00000000,0x00000000},0x1e80,1,1963},
+ {{0x00000000,0x00000000,0x00000000},0x1e81,1,1963},
+ {{0x00000000,0x00000000,0x00000000},0x038f,1,659},
+ {{0x00000000,0x00000000,0x00000000},0x03ce,1,659},
+ {{0x00000000,0x00000000,0x00000000},0x1e82,1,1966},
+ {{0x00000000,0x00000000,0x00000000},0x1e83,1,1966},
+ {{0x00000000,0x00000000,0x00000000},0x03a9,1,806},
+ {{0x00000000,0x00000000,0x00000000},0x03c9,1,806},
+ {{0x00000000,0x00000000,0x00000000},0x1f7c,1,2469},
+ {{0x00000000,0x00000000,0x00000000},0x1ffa,1,2469},
+ {{0x00000000,0x00000000,0x00000000},0x1ff2,1,2790},
+ {{0x00000000,0x00000000,0x00000000},0x1f7d,1,2473},
+ {{0x00000000,0x00000000,0x00000000},0x1ffb,1,2473},
+ {{0x00000000,0x00000000,0x00000000},0x1ff4,1,2799},
+ {{0x00000000,0x00000000,0x00000000},0x1f60,1,2383},
+ {{0x00000000,0x00000000,0x00000000},0x1f68,1,2383},
+ {{0x00000000,0x00000000,0x00000000},0x1f62,1,2391},
+ {{0x00000000,0x00000000,0x00000000},0x1f6a,1,2391},
+ {{0x00000000,0x00000000,0x00000000},0x1fa2,1,2579},
+ {{0x00000000,0x00000000,0x00000000},0x1faa,1,2579},
+ {{0x00000000,0x00000000,0x00000000},0x1f64,1,2401},
+ {{0x00000000,0x00000000,0x00000000},0x1f6c,1,2401},
+ {{0x00000000,0x00000000,0x00000000},0x1fa4,1,2591},
+ {{0x00000000,0x00000000,0x00000000},0x1fac,1,2591},
+ {{0x00000000,0x00000000,0x00000000},0x1f66,1,2411},
+ {{0x00000000,0x00000000,0x00000000},0x1f6e,1,2411},
+ {{0x00000000,0x00000000,0x00000000},0x1fa6,1,2603},
+ {{0x00000000,0x00000000,0x00000000},0x1fae,1,2603},
+ {{0x00000000,0x00000000,0x00000000},0x1fa0,1,2569},
+ {{0x00000000,0x00000000,0x00000000},0x1fa8,1,2569},
+ {{0x00000000,0x00000000,0x00000000},0x1f61,1,2387},
+ {{0x00000000,0x00000000,0x00000000},0x1f69,1,2387},
+ {{0x00000000,0x00000000,0x00000000},0x1f63,1,2396},
+ {{0x00000000,0x00000000,0x00000000},0x1f6b,1,2396},
+ {{0x00000000,0x00000000,0x00000000},0x1fa3,1,2585},
+ {{0x00000000,0x00000000,0x00000000},0x1fab,1,2585},
+ {{0x00000000,0x00000000,0x00000000},0x1f65,1,2406},
+ {{0x00000000,0x00000000,0x00000000},0x1f6d,1,2406},
+ {{0x00000000,0x00000000,0x00000000},0x1fa5,1,2597},
+ {{0x00000000,0x00000000,0x00000000},0x1fad,1,2597},
+ {{0x00000000,0x00000000,0x00000000},0x1f67,1,2416},
+ {{0x00000000,0x00000000,0x00000000},0x1f6f,1,2416},
+ {{0x00000000,0x00000000,0x00000000},0x1fa7,1,2609},
+ {{0x00000000,0x00000000,0x00000000},0x1faf,1,2609},
+ {{0x00000000,0x00000000,0x00000000},0x1fa1,1,2574},
+ {{0x00000000,0x00000000,0x00000000},0x1fa9,1,2574},
+ {{0x00000000,0x00000000,0x00000000},0x1ff6,1,2804},
+ {{0x00000000,0x00000000,0x00000000},0x1ff7,1,2808},
+ {{0x00000000,0x00000000,0x00000000},0x1ff3,1,2795},
+ {{0x00000000,0x00000000,0x00000000},0x1ffc,1,2795},
+ {{0x00000000,0x00000000,0x00000000},0x05d5,1,1198},
+ {{0x00000000,0x00000000,0x00000000},0x0648,1,1198},
+ {{0x00000000,0x00000000,0x00000000},0xfeed,1,7399},
+ {{0x00000000,0x00000000,0x00000000},0xfeee,1,7403},
+ {{0x00000000,0x00000000,0x00000000},0x1e88,1,1975},
+ {{0x00000000,0x00000000,0x00000000},0x1e89,1,1975},
+ {{0x00000000,0x00000000,0x00000000},0x1e86,1,1972},
+ {{0x00000000,0x00000000,0x00000000},0x1e87,1,1972},
+ {{0x00000000,0x00000000,0x00000000},0x1e84,1,1969},
+ {{0x00000000,0x00000000,0x00000000},0x1e85,1,1969},
+ {{0x00000000,0x00000000,0x00000000},0x20a9,1,3344},
+ {{0x00000000,0x00000000,0x00000000},0x0174,1,220},
+ {{0x00000000,0x00000000,0x00000000},0x0175,1,220},
+ {{0x40000001,0x00000000,0x00000000},0x308f,1,6657},
+ {{0x00000001,0x00000020,0x00000000},0x30ef,1,6657},
+ {{0x40000005,0x00000000,0x00000000},0x308e,1,6657},
+ {{0x00000005,0x00000020,0x00000000},0x30ee,1,6657},
+ {{0x00000000,0x00000000,0x00000000},0x301c,1,6513},
+ {{0x00000081,0x00000000,0x00000000},0x0648,1,1547},
+ {{0x00000081,0x00000010,0x00000000},0xfeed,1,1547},
+ {{0x01000081,0x00000000,0x00000000},0xfeee,1,1547},
+ {{0x00000089,0x00000000,0x00000000},0x0624,1,1360},
+ {{0x00000089,0x00000010,0x00000000},0xfe85,1,1360},
+ {{0x40000001,0x00000000,0x00000000},0x3091,1,6663},
+ {{0x00000001,0x00000020,0x00000000},0x30f1,1,6663},
+ {{0x00000000,0x00000000,0x00000000},0x0624,1,1370},
+ {{0x00000000,0x00000000,0x00000000},0xfe85,1,7007},
+ {{0x40000001,0x00000000,0x00000000},0x3090,1,6660},
+ {{0x00000001,0x00000020,0x00000000},0x30f0,1,6660},
+ {{0x40000001,0x00000000,0x00000000},0x3092,1,6666},
+ {{0x00000001,0x00000020,0x00000000},0x30f2,1,6666},
+ {{0x00000001,0x00000000,0x00000000},0x20a9,1,3340},
+ {{0x00000201,0x00000000,0x00000000},0x3112,0,1592},
+ {{0x00040003,0x00000040,0x00000000},0x1e8c,0,1592},
+ {{0x00040005,0x00000040,0x00000000},0x1e8d,0,1592},
+ {{0x00000005,0x00040040,0x00000000},0x24b3,0,1592},
+ {{0x00004003,0x00000040,0x00000000},0x24cd,0,1592},
+ {{0x00004005,0x00000040,0x00000000},0x24e7,0,1592},
+ {{0x0008000b,0x00000040,0x00000000},0x1e8a,0,1592},
+ {{0x0008000d,0x00000040,0x00000000},0x1e8b,0,1592},
+ {{0x00000000,0x00000000,0x00000000},0x24cd,1,5405},
+ {{0x00000000,0x00000000,0x00000000},0x24e7,1,5405},
+ {{0x00000000,0x00000000,0x00000000},0x03a7,1,796},
+ {{0x00000000,0x00000000,0x00000000},0x03c7,1,796},
+ {{0x00000000,0x00000000,0x00000000},0x05d7,1,1214},
+ {{0x00000000,0x00000000,0x00000000},0x062e,1,1214},
+ {{0x00000000,0x00000000,0x00000000},0xfea7,1,7119},
+ {{0x00000000,0x00000000,0x00000000},0xfea5,1,7111},
+ {{0x00000000,0x00000000,0x00000000},0xfea6,1,7115},
+ {{0x00000000,0x00000000,0x00000000},0xfea8,1,7123},
+ {{0x00000000,0x00000000,0x00000000},0x1e8a,1,1979},
+ {{0x00000000,0x00000000,0x00000000},0x1e8b,1,1979},
+ {{0x00000000,0x00000000,0x00000000},0x3112,1,6826},
+ {{0x00000000,0x00000000,0x00000000},0x1e8c,1,1982},
+ {{0x00000000,0x00000000,0x00000000},0x1e8d,1,1982},
+ {{0x08000003,0x00000000,0x00000000},0x039e,1,747},
+ {{0x08000005,0x00000000,0x00000000},0x03be,1,747},
+ {{0x00000000,0x00000000,0x00000000},0x2717,1,6321},
+ {{0x00008003,0x00000040,0x00000000},0x0176,0,1594},
+ {{0x00008005,0x00000040,0x00000000},0x0177,0,1594},
+ {{0x00040003,0x00000040,0x00000000},0x0178,0,1594},
+ {{0x04000003,0x00000040,0x00000000},0x1ef2,0,1594},
+ {{0x04000005,0x00000040,0x00000000},0x1ef3,0,1594},
+ {{0x00000003,0x02000040,0x00000000},0x1ef8,0,1594},
+ {{0x00000005,0x02000040,0x00000000},0x1ef9,0,1594},
+ {{0x00000005,0x00040040,0x00000000},0x24b4,0,1594},
+ {{0x00004003,0x00000040,0x00000000},0x24ce,0,1594},
+ {{0x00004005,0x00000040,0x00000000},0x24e8,0,1594},
+ {{0x0008000b,0x00000040,0x00000000},0x1e8e,0,1594},
+ {{0x0008000d,0x00000040,0x00000000},0x1e8f,0,1594},
+ {{0x00080103,0x00000040,0x00000000},0x1ef4,0,1594},
+ {{0x00080105,0x00000040,0x00000000},0x1ef5,0,1594},
+ {{0x8000000b,0x00000040,0x00000000},0x1ef6,0,1594},
+ {{0x8000000d,0x00000040,0x00000000},0x1ef7,0,1594},
+ {{0x00000000,0x00000000,0x00000000},0x24ce,1,5409},
+ {{0x00000000,0x00000000,0x00000000},0x24e8,1,5409},
+ {{0x00000000,0x00000000,0x00000000},0x1ef2,1,2162},
+ {{0x00000000,0x00000000,0x00000000},0x1ef3,1,2162},
+ {{0x00000000,0x00000000,0x00000000},0x0389,1,639},
+ {{0x00000000,0x00000000,0x00000000},0x03ae,1,639},
+ {{0x00000000,0x00000000,0x00000000},0x0397,1,705},
+ {{0x00000000,0x00000000,0x00000000},0x03b7,1,705},
+ {{0x00000000,0x00000000,0x00000000},0x1f74,1,2437},
+ {{0x00000000,0x00000000,0x00000000},0x1fca,1,2437},
+ {{0x00000000,0x00000000,0x00000000},0x1fc2,1,2673},
+ {{0x00000000,0x00000000,0x00000000},0x1f75,1,2441},
+ {{0x00000000,0x00000000,0x00000000},0x1fcb,1,2441},
+ {{0x00000000,0x00000000,0x00000000},0x1fc4,1,2682},
+ {{0x00000000,0x00000000,0x00000000},0x1f20,1,2241},
+ {{0x00000000,0x00000000,0x00000000},0x1f28,1,2241},
+ {{0x00000000,0x00000000,0x00000000},0x1f22,1,2249},
+ {{0x00000000,0x00000000,0x00000000},0x1f2a,1,2249},
+ {{0x00000000,0x00000000,0x00000000},0x1f92,1,2533},
+ {{0x00000000,0x00000000,0x00000000},0x1f9a,1,2533},
+ {{0x00000000,0x00000000,0x00000000},0x1f24,1,2259},
+ {{0x00000000,0x00000000,0x00000000},0x1f2c,1,2259},
+ {{0x00000000,0x00000000,0x00000000},0x1f94,1,2545},
+ {{0x00000000,0x00000000,0x00000000},0x1f9c,1,2545},
+ {{0x00000000,0x00000000,0x00000000},0x1f26,1,2269},
+ {{0x00000000,0x00000000,0x00000000},0x1f2e,1,2269},
+ {{0x00000000,0x00000000,0x00000000},0x1f96,1,2557},
+ {{0x00000000,0x00000000,0x00000000},0x1f9e,1,2557},
+ {{0x00000000,0x00000000,0x00000000},0x1f90,1,2523},
+ {{0x00000000,0x00000000,0x00000000},0x1f98,1,2523},
+ {{0x00000000,0x00000000,0x00000000},0x1f21,1,2245},
+ {{0x00000000,0x00000000,0x00000000},0x1f29,1,2245},
+ {{0x00000000,0x00000000,0x00000000},0x1f23,1,2254},
+ {{0x00000000,0x00000000,0x00000000},0x1f2b,1,2254},
+ {{0x00000000,0x00000000,0x00000000},0x1f93,1,2539},
+ {{0x00000000,0x00000000,0x00000000},0x1f9b,1,2539},
+ {{0x00000000,0x00000000,0x00000000},0x1f25,1,2264},
+ {{0x00000000,0x00000000,0x00000000},0x1f2d,1,2264},
+ {{0x00000000,0x00000000,0x00000000},0x1f95,1,2551},
+ {{0x00000000,0x00000000,0x00000000},0x1f9d,1,2551},
+ {{0x00000000,0x00000000,0x00000000},0x1f27,1,2274},
+ {{0x00000000,0x00000000,0x00000000},0x1f2f,1,2274},
+ {{0x00000000,0x00000000,0x00000000},0x1f97,1,2563},
+ {{0x00000000,0x00000000,0x00000000},0x1f9f,1,2563},
+ {{0x00000000,0x00000000,0x00000000},0x1f91,1,2528},
+ {{0x00000000,0x00000000,0x00000000},0x1f99,1,2528},
+ {{0x00000000,0x00000000,0x00000000},0x1fc6,1,2687},
+ {{0x00000000,0x00000000,0x00000000},0x1fc7,1,2691},
+ {{0x00000000,0x00000000,0x00000000},0x1fc3,1,2678},
+ {{0x00000000,0x00000000,0x00000000},0x1fcc,1,2678},
+ {{0x00000000,0x00000000,0x00000000},0x064a,1,1563},
+ {{0x00000000,0x00000000,0x00000000},0xfef3,1,7423},
+ {{0x00000000,0x00000000,0x00000000},0xfef1,1,7415},
+ {{0x00000000,0x00000000,0x00000000},0xfef2,1,7419},
+ {{0x00000000,0x00000000,0x00000000},0xfef4,1,7427},
+ {{0x00000000,0x00000000,0x00000000},0x1ef4,1,2165},
+ {{0x00000000,0x00000000,0x00000000},0x1ef5,1,2165},
+ {{0x00000000,0x00000000,0x00000000},0x1e8e,1,1985},
+ {{0x00000000,0x00000000,0x00000000},0x1e8f,1,1985},
+ {{0x00000000,0x00000000,0x00000000},0x1ef6,1,2169},
+ {{0x00000000,0x00000000,0x00000000},0x1ef7,1,2169},
+ {{0x00000000,0x00000000,0x00000000},0x0462,1,1125},
+ {{0x00000000,0x00000000,0x00000000},0x0463,1,1125},
+ {{0x00000000,0x00000000,0x00000000},0x0178,0,2952},
+ {{0x00000000,0x00000000,0x00000000},0x042b,1,1092},
+ {{0x00000000,0x00000000,0x00000000},0x044b,1,1092},
+ {{0x00000000,0x00000000,0x00000000},0x0176,1,223},
+ {{0x00000000,0x00000000,0x00000000},0x0177,1,223},
+ {{0x00000000,0x00000000,0x00000000},0x1ef8,1,2172},
+ {{0x00000000,0x00000000,0x00000000},0x1ef9,1,2172},
+ {{0x40000001,0x00000000,0x00000000},0x3084,1,1109},
+ {{0x00000001,0x00000020,0x00000000},0x30e4,1,1109},
+ {{0x00010003,0x00000000,0x00000000},0x042f,1,1109},
+ {{0x00010005,0x00000000,0x00000000},0x044f,1,1109},
+ {{0x40000005,0x00000000,0x00000000},0x3083,1,1109},
+ {{0x00000005,0x00000020,0x00000000},0x30e3,1,1109},
+ {{0x00010003,0x00000000,0x00000000},0x0462,1,1121},
+ {{0x00010005,0x00000000,0x00000000},0x0463,1,1121},
+ {{0x00000081,0x00000000,0x00000000},0x064a,1,1559},
+ {{0x00000081,0x00000010,0x00000000},0xfef1,1,1559},
+ {{0x01000081,0x00000000,0x00000000},0xfef2,1,1559},
+ {{0x00000081,0x00000004,0x00000000},0xfef3,1,1559},
+ {{0x00000081,0x00001000,0x00000000},0xfef4,1,1559},
+ {{0x00000089,0x00000000,0x00000000},0x0626,1,1373},
+ {{0x00000089,0x00000004,0x00000000},0xfe8b,1,1373},
+ {{0x00010003,0x00000000,0x00000000},0x042b,1,1087},
+ {{0x00010005,0x00000000,0x00000000},0x044b,1,1087},
+ {{0x00000000,0x00000000,0x00000000},0x0626,1,1383},
+ {{0x00000000,0x00000000,0x00000000},0xfe8b,1,7011},
+ {{0x00000000,0x00000000,0x00000000},0x0407,1,905},
+ {{0x00000000,0x00000000,0x00000000},0x0457,1,905},
+ {{0x00010003,0x00000000,0x00000000},0x0407,1,905},
+ {{0x00010005,0x00000000,0x00000000},0x0457,1,905},
+ {{0x40000001,0x00000000,0x00000000},0x3088,1,6645},
+ {{0x00000001,0x00000020,0x00000000},0x30e8,1,6645},
+ {{0x40000005,0x00000000,0x00000000},0x3087,1,6645},
+ {{0x00000005,0x00000020,0x00000000},0x30e7,1,6645},
+ {{0x20000001,0x00000000,0x00000000},0x05d9,1,1224},
+ {{0x08000000,0x00000000,0x00000000},0x037a,1,575},
+ {{0x08000045,0x00000000,0x00000000},0x1fb3,1,575},
+ {{0x08800005,0x00000000,0x00000000},0x1fc3,1,575},
+ {{0x08000005,0x00008000,0x00000000},0x1ff3,1,575},
+ {{0x08000045,0x00200000,0x00000000},0x1f80,1,575},
+ {{0x08020045,0x00000000,0x00000000},0x1f81,1,575},
+ {{0x08800005,0x00200000,0x00000000},0x1f90,1,575},
+ {{0x08820005,0x00000000,0x00000000},0x1f91,1,575},
+ {{0x08000005,0x00208000,0x00000000},0x1fa0,1,575},
+ {{0x08020005,0x00008000,0x00000000},0x1fa1,1,575},
+ {{0x08000045,0x20000000,0x00000000},0x1fb2,1,575},
+ {{0x08000045,0x00020000,0x00000000},0x1fb4,1,575},
+ {{0x08000045,0x00080000,0x00000000},0x1fb7,1,575},
+ {{0x08800005,0x20000000,0x00000000},0x1fc2,1,575},
+ {{0x08800005,0x00020000,0x00000000},0x1fc4,1,575},
+ {{0x08800005,0x00080000,0x00000000},0x1fc7,1,575},
+ {{0x08000005,0x20008000,0x00000000},0x1ff2,1,575},
+ {{0x08000005,0x00028000,0x00000000},0x1ff4,1,575},
+ {{0x08000005,0x00088000,0x00000000},0x1ff7,1,575},
+ {{0x08000045,0x20200000,0x00000000},0x1f82,1,575},
+ {{0x08020045,0x20000000,0x00000000},0x1f83,1,575},
+ {{0x08000045,0x00220000,0x00000000},0x1f84,1,575},
+ {{0x08020045,0x00020000,0x00000000},0x1f85,1,575},
+ {{0x08000045,0x00280000,0x00000000},0x1f86,1,575},
+ {{0x08020045,0x00080000,0x00000000},0x1f87,1,575},
+ {{0x08800005,0x20200000,0x00000000},0x1f92,1,575},
+ {{0x08820005,0x20000000,0x00000000},0x1f93,1,575},
+ {{0x08800005,0x00220000,0x00000000},0x1f94,1,575},
+ {{0x08820005,0x00020000,0x00000000},0x1f95,1,575},
+ {{0x08800005,0x00280000,0x00000000},0x1f96,1,575},
+ {{0x08820005,0x00080000,0x00000000},0x1f97,1,575},
+ {{0x08000005,0x20208000,0x00000000},0x1fa2,1,575},
+ {{0x08020005,0x20008000,0x00000000},0x1fa3,1,575},
+ {{0x08000005,0x00228000,0x00000000},0x1fa4,1,575},
+ {{0x08020005,0x00028000,0x00000000},0x1fa5,1,575},
+ {{0x08000005,0x00288000,0x00000000},0x1fa6,1,575},
+ {{0x08020005,0x00088000,0x00000000},0x1fa7,1,575},
+ {{0x00000000,0x00000000,0x00000000},0x01a6,1,266},
+ {{0x00000001,0x00000040,0x00000000},0x01a6,1,266},
+ {{0x40000001,0x00000000,0x00000000},0x3086,1,1103},
+ {{0x00000001,0x00000020,0x00000000},0x30e6,1,1103},
+ {{0x00010003,0x00000000,0x00000000},0x042e,1,1103},
+ {{0x00010005,0x00000000,0x00000000},0x044e,1,1103},
+ {{0x40000005,0x00000000,0x00000000},0x3085,1,1103},
+ {{0x00000005,0x00000020,0x00000000},0x30e5,1,1103},
+ {{0x00010003,0x00000000,0x00200000},0x046a,1,1128},
+ {{0x00010005,0x00000000,0x00200000},0x046b,1,1128},
+ {{0x00000201,0x00000000,0x00000000},0x3117,0,1596},
+ {{0x00000013,0x00000040,0x00000000},0x0179,0,1596},
+ {{0x00000015,0x00000040,0x00000000},0x017a,0,1596},
+ {{0x00001003,0x00000040,0x00000000},0x017d,0,1596},
+ {{0x00001005,0x00000040,0x00000000},0x017e,0,1596},
+ {{0x00000003,0x00000040,0x10000000},0x01b5,0,1596},
+ {{0x00000005,0x00000040,0x10000000},0x01b6,0,1596},
+ {{0x00008003,0x00000040,0x00000000},0x1e90,0,1596},
+ {{0x00008005,0x00000040,0x00000000},0x1e91,0,1596},
+ {{0x00000005,0x00040040,0x00000000},0x24b5,0,1596},
+ {{0x00004003,0x00000040,0x00000000},0x24cf,0,1596},
+ {{0x00004005,0x00000040,0x00000000},0x24e9,0,1596},
+ {{0x0008000b,0x00000040,0x00000000},0x017b,0,1596},
+ {{0x0008000d,0x00000040,0x00000000},0x017c,0,1596},
+ {{0x00080103,0x00000040,0x00000000},0x1e92,0,1596},
+ {{0x00080105,0x00000040,0x00000000},0x1e93,0,1596},
+ {{0x00000103,0x00000240,0x00000000},0x1e94,0,1596},
+ {{0x00000105,0x00000240,0x00000000},0x1e95,0,1596},
+ {{0x00000000,0x00000000,0x00000000},0x24cf,1,5413},
+ {{0x00000000,0x00000000,0x00000000},0x24e9,1,5413},
+ {{0x00000000,0x00000000,0x00000000},0x0416,1,977},
+ {{0x00000000,0x00000000,0x00000000},0x0436,1,977},
+ {{0x00000000,0x00000000,0x00000000},0x0179,1,226},
+ {{0x00000000,0x00000000,0x00000000},0x017a,1,226},
+ {{0x00000000,0x00000000,0x00000000},0x0396,1,702},
+ {{0x00000000,0x00000000,0x00000000},0x03b6,1,702},
+ {{0x00000000,0x00000000,0x00000000},0x05d6,1,1207},
+ {{0x00000000,0x00000000,0x00000000},0x0632,1,1207},
+ {{0x00000000,0x00000000,0x00000000},0xfeaf,1,7151},
+ {{0x00000000,0x00000000,0x00000000},0xfeb0,1,7155},
+ {{0x00000000,0x00000000,0x00000000},0x1e92,1,1991},
+ {{0x00000000,0x00000000,0x00000000},0x1e93,1,1991},
+ {{0x00000000,0x00000000,0x00000000},0x017b,1,229},
+ {{0x00000000,0x00000000,0x00000000},0x017c,1,229},
+ {{0x00000000,0x00000000,0x00000000},0x01b5,1,272},
+ {{0x00000000,0x00000000,0x00000000},0x01b6,1,272},
+ {{0x00000000,0x00000000,0x00000000},0x3117,1,6832},
+ {{0x00000000,0x00000000,0x00000000},0x017d,1,232},
+ {{0x00000000,0x00000000,0x00000000},0x017e,1,232},
+ {{0x00000000,0x00000000,0x00000000},0x0417,1,983},
+ {{0x00000000,0x00000000,0x00000000},0x0437,1,983},
+ {{0x00000000,0x00000000,0x00000000},0x1e90,1,1988},
+ {{0x00000000,0x00000000,0x00000000},0x1e91,1,1988},
+ {{0x00000000,0x00000000,0x00000000},0x1e94,1,1995},
+ {{0x00000000,0x00000000,0x00000000},0x1e95,1,1995},
+ {{0x40000001,0x00000000,0x00000000},0x3056,1,6585},
+ {{0x00000001,0x00000020,0x00000000},0x30b6,1,6585},
+ {{0x00000081,0x00000000,0x00000000},0x0638,1,1487},
+ {{0x00000081,0x00000010,0x00000000},0xfec5,1,1487},
+ {{0x01000081,0x00000000,0x00000000},0xfec6,1,1487},
+ {{0x00000081,0x00000004,0x00000000},0xfec7,1,1487},
+ {{0x00000081,0x00001000,0x00000000},0xfec8,1,1487},
+ {{0x00000081,0x00000000,0x00000000},0x0632,1,1450},
+ {{0x00000081,0x00000010,0x00000000},0xfeaf,1,1450},
+ {{0x01000081,0x00000000,0x00000000},0xfeb0,1,1450},
+ {{0x20000001,0x00000000,0x00000000},0x05d6,1,1201},
+ {{0x40000001,0x00000000,0x00000000},0x305c,1,980},
+ {{0x00000001,0x00000020,0x00000000},0x30bc,1,980},
+ {{0x00010003,0x00000000,0x00000000},0x0417,1,980},
+ {{0x00010005,0x00000000,0x00000000},0x0437,1,980},
+ {{0x00000000,0x00000000,0x00000020},0x2070,0,1435},
+ {{0x00000000,0x00000000,0x00000040},0x2080,0,1435},
+ {{0x00004001,0x00000000,0x00000000},0x24ea,0,1435},
+ {{0x00000081,0x00000000,0x00000400},0x0660,0,1435},
+ {{0x00000000,0x00002000,0x00000800},0x3007,0,1435},
+ {{0x08000003,0x00000000,0x00000000},0x0396,1,697},
+ {{0x08000005,0x00000000,0x00000000},0x03b6,1,697},
+ {{0x00000000,0x00000000,0x00000000},0x0638,1,1491},
+ {{0x00000201,0x00000000,0x00000000},0x3113,1,1491},
+ {{0x00000000,0x00000000,0x00000000},0xfec7,1,7247},
+ {{0x00000000,0x00000000,0x00000000},0xfec5,1,7239},
+ {{0x00000000,0x00000000,0x00000000},0xfec6,1,7243},
+ {{0x00000000,0x00000000,0x00000000},0xfec8,1,7251},
+ {{0x00010003,0x00000000,0x00000000},0x0416,1,973},
+ {{0x00010005,0x00000000,0x00000000},0x0436,1,973},
+ {{0x40000001,0x00000000,0x00000000},0x3058,1,6588},
+ {{0x00000001,0x00000020,0x00000000},0x30b8,1,6588},
+ {{0x00000000,0x00000000,0x00000000},0x05e5,1,1300},
+ {{0x00000000,0x00000000,0x00000000},0x05e6,1,1300},
+ {{0x00000000,0x00000000,0x00000000},0x0698,1,1300},
+ {{0x40000001,0x00000000,0x00000000},0x305e,1,6594},
+ {{0x00000001,0x00000020,0x00000000},0x30be,1,6594},
+ {{0x40000001,0x00000000,0x00000000},0x305a,1,6591},
+ {{0x00000001,0x00000020,0x00000000},0x30ba,1,6591},
+#endif /* UCS_BYTE */
+};
diff --git a/usr/src/lib/libast/common/sfio/_sfclrerr.c b/usr/src/lib/libast/common/sfio/_sfclrerr.c
new file mode 100644
index 0000000000..a500392cd8
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sfclrerr.c
@@ -0,0 +1,34 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+#undef sfclrerr
+
+#if __STD_C
+int sfclrerr(reg Sfio_t* f)
+#else
+int sfclrerr(f)
+reg Sfio_t* f;
+#endif
+{
+ return __sf_clrerr(f);
+}
diff --git a/usr/src/lib/libast/common/sfio/_sfdlen.c b/usr/src/lib/libast/common/sfio/_sfdlen.c
new file mode 100644
index 0000000000..76db0f8d73
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sfdlen.c
@@ -0,0 +1,34 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+#undef sfdlen
+
+#if __STD_C
+int sfdlen(reg Sfdouble_t v)
+#else
+int sfdlen(v)
+reg Sfdouble_t v;
+#endif
+{
+ return __sf_dlen(v);
+}
diff --git a/usr/src/lib/libast/common/sfio/_sfeof.c b/usr/src/lib/libast/common/sfio/_sfeof.c
new file mode 100644
index 0000000000..8f6b809b1c
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sfeof.c
@@ -0,0 +1,34 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+#undef sfeof
+
+#if __STD_C
+int sfeof(reg Sfio_t* f)
+#else
+int sfeof(f)
+reg Sfio_t* f;
+#endif
+{
+ return __sf_eof(f);
+}
diff --git a/usr/src/lib/libast/common/sfio/_sferror.c b/usr/src/lib/libast/common/sfio/_sferror.c
new file mode 100644
index 0000000000..1f898d816e
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sferror.c
@@ -0,0 +1,34 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+#undef sferror
+
+#if __STD_C
+int sferror(reg Sfio_t* f)
+#else
+int sferror(f)
+reg Sfio_t* f;
+#endif
+{
+ return __sf_error(f);
+}
diff --git a/usr/src/lib/libast/common/sfio/_sffileno.c b/usr/src/lib/libast/common/sfio/_sffileno.c
new file mode 100644
index 0000000000..c8e369b734
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sffileno.c
@@ -0,0 +1,34 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+#undef sffileno
+
+#if __STD_C
+int sffileno(reg Sfio_t* f)
+#else
+int sffileno(f)
+reg Sfio_t* f;
+#endif
+{
+ return __sf_fileno(f);
+}
diff --git a/usr/src/lib/libast/common/sfio/_sfgetc.c b/usr/src/lib/libast/common/sfio/_sfgetc.c
new file mode 100644
index 0000000000..ddf07dbd71
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sfgetc.c
@@ -0,0 +1,34 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+#undef sfgetc
+
+#if __STD_C
+int sfgetc(reg Sfio_t* f)
+#else
+int sfgetc(f)
+reg Sfio_t* f;
+#endif
+{
+ return __sf_getc(f);
+}
diff --git a/usr/src/lib/libast/common/sfio/_sfgetl.c b/usr/src/lib/libast/common/sfio/_sfgetl.c
new file mode 100644
index 0000000000..6c8ade54e5
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sfgetl.c
@@ -0,0 +1,42 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/*
+ * for backwards compatibility with pre-threaded sfgetl() inline
+ */
+
+#ifdef __EXPORT__
+#define extern __EXPORT__
+#endif
+
+extern
+#if __STD_C
+Sflong_t _sfgetl(reg Sfio_t* f)
+#else
+Sflong_t _sfgetl(f)
+reg Sfio_t* f;
+#endif
+{
+ sfungetc(f, (unsigned char)_SF_(f)->val);
+ return sfgetl(f);
+}
diff --git a/usr/src/lib/libast/common/sfio/_sfgetl2.c b/usr/src/lib/libast/common/sfio/_sfgetl2.c
new file mode 100644
index 0000000000..d55a3d3a8d
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sfgetl2.c
@@ -0,0 +1,50 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* OBSOLETE 19961031 -- for shared library compatibility */
+
+#include "sfhdr.h"
+
+#undef _sfgetl2
+
+_BEGIN_EXTERNS_
+#if _BLD_sfio && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern long _sfgetl2 _ARG_((Sfio_t*, long));
+
+#undef extern
+_END_EXTERNS_
+
+#if __STD_C
+long _sfgetl2(reg Sfio_t* f, long v)
+#else
+long _sfgetl2(f, v)
+reg Sfio_t* f;
+long v;
+#endif
+{
+ if (v < 0)
+ return -1;
+ sfungetc(f, v);
+ return sfgetl(f);
+}
diff --git a/usr/src/lib/libast/common/sfio/_sfgetu.c b/usr/src/lib/libast/common/sfio/_sfgetu.c
new file mode 100644
index 0000000000..bccb6fbe8a
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sfgetu.c
@@ -0,0 +1,42 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/*
+ * for backwards compatibility with pre-threaded sfgetl() inline
+ */
+
+#ifdef __EXPORT__
+#define extern __EXPORT__
+#endif
+
+extern
+#if __STD_C
+Sfulong_t _sfgetu(reg Sfio_t* f)
+#else
+Sfulong_t _sfgetu(f)
+reg Sfio_t* f;
+#endif
+{
+ sfungetc(f, (unsigned char)_SF_(f)->val);
+ return sfgetu(f);
+}
diff --git a/usr/src/lib/libast/common/sfio/_sfgetu2.c b/usr/src/lib/libast/common/sfio/_sfgetu2.c
new file mode 100644
index 0000000000..96d62d0a6d
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sfgetu2.c
@@ -0,0 +1,50 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* OBSOLETE 19961031 -- for shared library compatibility */
+
+#include "sfhdr.h"
+
+#undef _sfgetu2
+
+_BEGIN_EXTERNS_
+#if _BLD_sfio && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern long _sfgetu2 _ARG_((Sfio_t*, long));
+
+#undef extern
+_END_EXTERNS_
+
+#if __STD_C
+long _sfgetu2(reg Sfio_t* f, long v)
+#else
+long _sfgetu2(f, v)
+reg Sfio_t* f;
+long v;
+#endif
+{
+ if (v < 0)
+ return -1;
+ sfungetc(f, v);
+ return sfgetu(f);
+}
diff --git a/usr/src/lib/libast/common/sfio/_sfllen.c b/usr/src/lib/libast/common/sfio/_sfllen.c
new file mode 100644
index 0000000000..dbfc40e18e
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sfllen.c
@@ -0,0 +1,34 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+#undef sfllen
+
+#if __STD_C
+int sfllen(reg Sflong_t v)
+#else
+int sfllen(v)
+reg Sflong_t v;
+#endif
+{
+ return __sf_llen(v);
+}
diff --git a/usr/src/lib/libast/common/sfio/_sfopen.c b/usr/src/lib/libast/common/sfio/_sfopen.c
new file mode 100644
index 0000000000..67528f0f9e
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sfopen.c
@@ -0,0 +1,215 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Open a file/string for IO.
+** If f is not nil, it is taken as an existing stream that should be
+** closed and its structure reused for the new stream.
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if _BLD_sfio && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+extern
+#undef extern
+
+#if __STD_C
+Sfio_t* _sfopen(reg Sfio_t* f, const char* file, const char* mode)
+#else
+Sfio_t* _sfopen(f,file,mode)
+reg Sfio_t* f; /* old stream structure */
+char* file; /* file/string to be opened */
+reg char* mode; /* mode of the stream */
+#endif
+{
+ int fd, oldfd, oflags, sflags;
+
+ /* get the control flags */
+ if((sflags = _sftype(mode,&oflags,NIL(int*))) == 0)
+ return NIL(Sfio_t*);
+
+ /* changing the control flags */
+ if(f && !file && !((f->flags|sflags)&SF_STRING) )
+ { SFMTXSTART(f, NIL(Sfio_t*));
+
+ if(f->mode&SF_INIT ) /* stream uninitialized, ok to set flags */
+ { f->flags |= (sflags & (SF_FLAGS & ~SF_RDWR));
+
+ if((sflags &= SF_RDWR) != 0) /* reset read/write modes */
+ { f->flags = (f->flags & ~SF_RDWR) | sflags;
+
+ if((f->flags&SF_RDWR) == SF_RDWR)
+ f->bits |= SF_BOTH;
+ else f->bits &= ~SF_BOTH;
+
+ if(f->flags&SF_READ)
+ f->mode = (f->mode&~SF_WRITE)|SF_READ;
+ else f->mode = (f->mode&~SF_READ)|SF_WRITE;
+ }
+ }
+ else /* make sure there is no buffered data */
+ { if(sfsync(f) < 0)
+ SFMTXRETURN(f,NIL(Sfio_t*));
+ }
+
+ if(f->file >= 0 && (oflags &= (O_TEXT|O_BINARY|O_APPEND)) != 0 )
+ { /* set file access control */
+ int ctl = sysfcntlf(f->file, F_GETFL, 0);
+ ctl = (ctl & ~(O_TEXT|O_BINARY|O_APPEND)) | oflags;
+ sysfcntlf(f->file, F_SETFL, ctl);
+ }
+
+ SFMTXRETURN(f,f);
+ }
+
+ if(sflags&SF_STRING)
+ { f = sfnew(f,(char*)file,
+ file ? (size_t)strlen((char*)file) : (size_t)SF_UNBOUND,
+ -1,sflags);
+ }
+ else
+ { if(!file)
+ return NIL(Sfio_t*);
+
+#if _has_oflags /* open the file */
+ while((fd = sysopenf((char*)file,oflags,SF_CREATMODE)) < 0 && errno == EINTR)
+ errno = 0;
+#else
+ while((fd = sysopenf(file,oflags&O_ACCMODE)) < 0 && errno == EINTR)
+ errno = 0;
+ if(fd >= 0)
+ { if((oflags&(O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL) )
+ { CLOSE(fd); /* error: file already exists */
+ return NIL(Sfio_t*);
+ }
+ if(oflags&O_TRUNC ) /* truncate file */
+ { reg int tf;
+ while((tf = syscreatf(file,SF_CREATMODE)) < 0 &&
+ errno == EINTR)
+ errno = 0;
+ CLOSE(tf);
+ }
+ }
+ else if(oflags&O_CREAT)
+ { while((fd = syscreatf(file,SF_CREATMODE)) < 0 && errno == EINTR)
+ errno = 0;
+ if((oflags&O_ACCMODE) != O_WRONLY)
+ { /* the file now exists, reopen it for read/write */
+ CLOSE(fd);
+ while((fd = sysopenf(file,oflags&O_ACCMODE)) < 0 &&
+ errno == EINTR)
+ errno = 0;
+ }
+ }
+#endif
+ if(fd < 0)
+ return NIL(Sfio_t*);
+
+ /* we may have to reset the file descriptor to its old value */
+ oldfd = f ? f->file : -1;
+ if((f = sfnew(f,NIL(char*),(size_t)SF_UNBOUND,fd,sflags)) && oldfd >= 0)
+ (void)sfsetfd(f,oldfd);
+ }
+
+ return f;
+}
+
+#if __STD_C
+int _sftype(reg const char* mode, int* oflagsp, int* uflagp)
+#else
+int _sftype(mode, oflagsp, uflagp)
+reg char* mode;
+int* oflagsp;
+int* uflagp;
+#endif
+{
+ reg int sflags, oflags, uflag;
+
+ if(!mode)
+ return 0;
+
+ /* construct the open flags */
+ sflags = oflags = uflag = 0;
+ while(1) switch(*mode++)
+ {
+ case 'w' :
+ sflags |= SF_WRITE;
+ oflags |= O_WRONLY | O_CREAT;
+ if(!(sflags&SF_READ))
+ oflags |= O_TRUNC;
+ continue;
+ case 'a' :
+ sflags |= SF_WRITE | SF_APPENDWR;
+ oflags |= O_WRONLY | O_APPEND | O_CREAT;
+ continue;
+ case 'r' :
+ sflags |= SF_READ;
+ oflags |= O_RDONLY;
+ continue;
+ case 's' :
+ sflags |= SF_STRING;
+ continue;
+ case 'b' :
+ oflags |= O_BINARY;
+ continue;
+ case 't' :
+ oflags |= O_TEXT;
+ continue;
+ case 'x' :
+ oflags |= O_EXCL;
+ continue;
+ case '+' :
+ if(sflags)
+ sflags |= SF_READ|SF_WRITE;
+ continue;
+ case 'm' :
+ sflags |= SF_MTSAFE;
+ uflag = 0;
+ continue;
+ case 'u' :
+ sflags &= ~SF_MTSAFE;
+ uflag = 1;
+ continue;
+ case 'W' :
+ sflags |= SF_WCWIDTH;
+ uflag = 0;
+ continue;
+ default :
+ if(!(oflags&O_CREAT) )
+ oflags &= ~O_EXCL;
+#if _WIN32 && !_WINIX
+ if(!(oflags&(O_BINARY|O_TEXT)))
+ oflags |= O_BINARY;
+#endif
+ if((sflags&SF_RDWR) == SF_RDWR)
+ oflags = (oflags&~O_ACCMODE)|O_RDWR;
+ if(oflagsp)
+ *oflagsp = oflags;
+ if(uflagp)
+ *uflagp = uflag;
+ if((sflags&(SF_STRING|SF_RDWR)) == SF_STRING)
+ sflags |= SF_READ;
+ return sflags;
+ }
+}
diff --git a/usr/src/lib/libast/common/sfio/_sfputc.c b/usr/src/lib/libast/common/sfio/_sfputc.c
new file mode 100644
index 0000000000..596d0a9a29
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sfputc.c
@@ -0,0 +1,35 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+#undef sfputc
+
+#if __STD_C
+int sfputc(reg Sfio_t* f, reg int c)
+#else
+int sfputc(f,c)
+reg Sfio_t* f;
+reg int c;
+#endif
+{
+ return __sf_putc(f,c);
+}
diff --git a/usr/src/lib/libast/common/sfio/_sfputd.c b/usr/src/lib/libast/common/sfio/_sfputd.c
new file mode 100644
index 0000000000..0a830635cb
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sfputd.c
@@ -0,0 +1,95 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Write out a floating point value in a portable format
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+int _sfputd(Sfio_t* f, Sfdouble_t v)
+#else
+int _sfputd(f,v)
+Sfio_t* f;
+Sfdouble_t v;
+#endif
+{
+#define N_ARRAY (16*sizeof(Sfdouble_t))
+ reg ssize_t n, w;
+ reg uchar *s, *ends;
+ int exp;
+ uchar c[N_ARRAY];
+ Sfdouble_t x;
+
+ SFMTXSTART(f,-1);
+
+ if(f->mode != SF_WRITE && _sfmode(f,SF_WRITE,0) < 0)
+ SFMTXRETURN(f, -1);
+ SFLOCK(f,0);
+
+ /* get the sign of v */
+ if(v < 0.)
+ { v = -v;
+ n = 1;
+ }
+ else n = 0;
+
+ /* make the magnitude of v < 1 */
+ if(v != 0.)
+ v = frexpl(v,&exp);
+ else exp = 0;
+
+ /* code the sign of v and exp */
+ if((w = exp) < 0)
+ { n |= 02;
+ w = -w;
+ }
+
+ /* write out the signs and the exp */
+ SFOPEN(f,0);
+ if(sfputc(f,n) < 0 || (w = sfputu(f,w)) < 0)
+ SFMTXRETURN(f, -1);
+ SFLOCK(f,0);
+ w += 1;
+
+ s = (ends = &c[0])+sizeof(c);
+ while(s > ends)
+ { /* get 2^SF_PRECIS precision at a time */
+ n = (int)(x = ldexpl(v,SF_PRECIS));
+ *--s = n|SF_MORE;
+ v = x-n;
+ if(v <= 0.)
+ break;
+ }
+
+ /* last byte is not SF_MORE */
+ ends = &c[0] + sizeof(c) -1;
+ *ends &= ~SF_MORE;
+
+ /* write out coded bytes */
+ n = ends - s + 1;
+ w = SFWRITE(f,(Void_t*)s,n) == n ? w+n : -1;
+
+ SFOPEN(f,0);
+ SFMTXRETURN(f,w);
+}
diff --git a/usr/src/lib/libast/common/sfio/_sfputl.c b/usr/src/lib/libast/common/sfio/_sfputl.c
new file mode 100644
index 0000000000..80ccf682bd
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sfputl.c
@@ -0,0 +1,81 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Write out a long value in a portable format
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+int _sfputl(reg Sfio_t* f, Sflong_t v)
+#else
+int _sfputl(f,v)
+reg Sfio_t* f; /* write a portable long to this stream */
+Sflong_t v; /* the value to be written */
+#endif
+{
+#define N_ARRAY (2*sizeof(Sflong_t))
+ reg uchar *s, *ps;
+ reg ssize_t n, p;
+ uchar c[N_ARRAY];
+
+ SFMTXSTART(f,-1);
+ if(f->mode != SF_WRITE && _sfmode(f,SF_WRITE,0) < 0)
+ SFMTXRETURN(f, -1);
+ SFLOCK(f,0);
+
+ s = ps = &(c[N_ARRAY-1]);
+ if(v < 0)
+ { /* add 1 to avoid 2-complement problems with -SF_MAXINT */
+ v = -(v+1);
+ *s = (uchar)(SFSVALUE(v) | SF_SIGN);
+ }
+ else *s = (uchar)(SFSVALUE(v));
+ v = (Sfulong_t)v >> SF_SBITS;
+
+ while(v > 0)
+ { *--s = (uchar)(SFUVALUE(v) | SF_MORE);
+ v = (Sfulong_t)v >> SF_UBITS;
+ }
+ n = (ps-s)+1;
+
+ if(n > 8 || SFWPEEK(f,ps,p) < n)
+ n = SFWRITE(f,(Void_t*)s,n); /* write the hard way */
+ else
+ { switch(n)
+ {
+ case 8 : *ps++ = *s++;
+ case 7 : *ps++ = *s++;
+ case 6 : *ps++ = *s++;
+ case 5 : *ps++ = *s++;
+ case 4 : *ps++ = *s++;
+ case 3 : *ps++ = *s++;
+ case 2 : *ps++ = *s++;
+ case 1 : *ps++ = *s++;
+ }
+ f->next = ps;
+ }
+
+ SFOPEN(f,0);
+ SFMTXRETURN(f, n);
+}
diff --git a/usr/src/lib/libast/common/sfio/_sfputm.c b/usr/src/lib/libast/common/sfio/_sfputm.c
new file mode 100644
index 0000000000..23ff83cd73
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sfputm.c
@@ -0,0 +1,77 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Write out an unsigned long value in a portable format.
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+int _sfputm(reg Sfio_t* f, Sfulong_t v, Sfulong_t m)
+#else
+int _sfputm(f,v,m)
+reg Sfio_t* f; /* write a portable ulong to this stream */
+Sfulong_t v; /* the unsigned value to be written */
+Sfulong_t m; /* the max value of the range */
+#endif
+{
+#define N_ARRAY (2*sizeof(Sfulong_t))
+ reg uchar *s, *ps;
+ reg ssize_t n, p;
+ uchar c[N_ARRAY];
+
+ SFMTXSTART(f, -1);
+
+ if(v > m || (f->mode != SF_WRITE && _sfmode(f,SF_WRITE,0) < 0) )
+ SFMTXRETURN(f, -1);
+ SFLOCK(f,0);
+
+ /* code v as integers in base SF_UBASE */
+ s = ps = &(c[N_ARRAY-1]);
+ *s = (uchar)SFBVALUE(v);
+ while((m >>= SF_BBITS) > 0 )
+ { v >>= SF_BBITS;
+ *--s = (uchar)SFBVALUE(v);
+ }
+ n = (ps-s)+1;
+
+ if(n > 8 || SFWPEEK(f,ps,p) < n)
+ n = SFWRITE(f,(Void_t*)s,n); /* write the hard way */
+ else
+ { switch(n)
+ {
+ case 8 : *ps++ = *s++;
+ case 7 : *ps++ = *s++;
+ case 6 : *ps++ = *s++;
+ case 5 : *ps++ = *s++;
+ case 4 : *ps++ = *s++;
+ case 3 : *ps++ = *s++;
+ case 2 : *ps++ = *s++;
+ case 1 : *ps++ = *s++;
+ }
+ f->next = ps;
+ }
+
+ SFOPEN(f,0);
+ SFMTXRETURN(f, (int)n);
+}
diff --git a/usr/src/lib/libast/common/sfio/_sfputu.c b/usr/src/lib/libast/common/sfio/_sfputu.c
new file mode 100644
index 0000000000..5620948ac3
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sfputu.c
@@ -0,0 +1,74 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Write out an unsigned long value in a portable format.
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+int _sfputu(reg Sfio_t* f, Sfulong_t v)
+#else
+int _sfputu(f,v)
+reg Sfio_t* f; /* write a portable ulong to this stream */
+Sfulong_t v; /* the unsigned value to be written */
+#endif
+{
+#define N_ARRAY (2*sizeof(Sfulong_t))
+ reg uchar *s, *ps;
+ reg ssize_t n, p;
+ uchar c[N_ARRAY];
+
+ SFMTXSTART(f, -1);
+
+ if(f->mode != SF_WRITE && _sfmode(f,SF_WRITE,0) < 0)
+ SFMTXRETURN(f, -1);
+ SFLOCK(f,0);
+
+ /* code v as integers in base SF_UBASE */
+ s = ps = &(c[N_ARRAY-1]);
+ *s = (uchar)SFUVALUE(v);
+ while((v >>= SF_UBITS) )
+ *--s = (uchar)(SFUVALUE(v) | SF_MORE);
+ n = (ps-s)+1;
+
+ if(n > 8 || SFWPEEK(f,ps,p) < n)
+ n = SFWRITE(f,(Void_t*)s,n); /* write the hard way */
+ else
+ { switch(n)
+ {
+ case 8 : *ps++ = *s++;
+ case 7 : *ps++ = *s++;
+ case 6 : *ps++ = *s++;
+ case 5 : *ps++ = *s++;
+ case 4 : *ps++ = *s++;
+ case 3 : *ps++ = *s++;
+ case 2 : *ps++ = *s++;
+ case 1 : *ps++ = *s++;
+ }
+ f->next = ps;
+ }
+
+ SFOPEN(f,0);
+ SFMTXRETURN(f, (int)n);
+}
diff --git a/usr/src/lib/libast/common/sfio/_sfslen.c b/usr/src/lib/libast/common/sfio/_sfslen.c
new file mode 100644
index 0000000000..08f9ac6bf1
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sfslen.c
@@ -0,0 +1,33 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+#undef sfslen
+
+#if __STD_C
+ssize_t sfslen(void)
+#else
+ssize_t sfslen()
+#endif
+{
+ return __sf_slen();
+}
diff --git a/usr/src/lib/libast/common/sfio/_sfstacked.c b/usr/src/lib/libast/common/sfio/_sfstacked.c
new file mode 100644
index 0000000000..ebb00952db
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sfstacked.c
@@ -0,0 +1,34 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+#undef sfstacked
+
+#if __STD_C
+int sfstacked(reg Sfio_t* f)
+#else
+int sfstacked(f)
+reg Sfio_t* f;
+#endif
+{
+ return __sf_stacked(f);
+}
diff --git a/usr/src/lib/libast/common/sfio/_sfulen.c b/usr/src/lib/libast/common/sfio/_sfulen.c
new file mode 100644
index 0000000000..e7f09bdf20
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sfulen.c
@@ -0,0 +1,34 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+#undef sfulen
+
+#if __STD_C
+int sfulen(reg Sfulong_t v)
+#else
+int sfulen(v)
+reg Sfulong_t v;
+#endif
+{
+ return __sf_ulen(v);
+}
diff --git a/usr/src/lib/libast/common/sfio/_sfvalue.c b/usr/src/lib/libast/common/sfio/_sfvalue.c
new file mode 100644
index 0000000000..c9aba31cab
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/_sfvalue.c
@@ -0,0 +1,34 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+#undef sfvalue
+
+#if __STD_C
+ssize_t sfvalue(reg Sfio_t* f)
+#else
+ssize_t sfvalue(f)
+reg Sfio_t* f;
+#endif
+{
+ return __sf_value(f);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfclose.c b/usr/src/lib/libast/common/sfio/sfclose.c
new file mode 100644
index 0000000000..fdfa271228
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfclose.c
@@ -0,0 +1,168 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Close a stream. A file stream is synced before closing.
+**
+** Written by Kiem-Phong Vo
+*/
+
+#if __STD_C
+int sfclose(reg Sfio_t* f)
+#else
+int sfclose(f)
+reg Sfio_t* f;
+#endif
+{
+ reg int local, ex, rv;
+ Void_t* data = NIL(Void_t*);
+
+ SFMTXSTART(f, -1);
+
+ GETLOCAL(f,local);
+
+ if(!(f->mode&SF_INIT) &&
+ SFMODE(f,local) != (f->mode&SF_RDWR) &&
+ SFMODE(f,local) != (f->mode&(SF_READ|SF_SYNCED)) &&
+ _sfmode(f,SF_SYNCED,local) < 0)
+ SFMTXRETURN(f,-1);
+
+ /* closing a stack of streams */
+ while(f->push)
+ { reg Sfio_t* pop;
+
+ if(!(pop = (*_Sfstack)(f,NIL(Sfio_t*))) )
+ SFMTXRETURN(f,-1);
+ if(sfclose(pop) < 0)
+ { (*_Sfstack)(f,pop);
+ SFMTXRETURN(f,-1);
+ }
+ }
+
+ rv = 0;
+ if(f->disc == _Sfudisc) /* closing the ungetc stream */
+ f->disc = NIL(Sfdisc_t*);
+ else if(f->file >= 0) /* sync file pointer */
+ { f->bits |= SF_ENDING;
+ rv = sfsync(f);
+ }
+
+ SFLOCK(f,0);
+
+ /* raise discipline exceptions */
+ if(f->disc && (ex = SFRAISE(f,local ? SF_NEW : SF_CLOSING,NIL(Void_t*))) != 0)
+ SFMTXRETURN(f,ex);
+
+ if(!local && f->pool)
+ { /* remove from pool */
+ if(f->pool == &_Sfpool)
+ { reg int n;
+
+ POOLMTXLOCK(&_Sfpool);
+ for(n = 0; n < _Sfpool.n_sf; ++n)
+ { if(_Sfpool.sf[n] != f)
+ continue;
+ /* found it */
+ _Sfpool.n_sf -= 1;
+ for(; n < _Sfpool.n_sf; ++n)
+ _Sfpool.sf[n] = _Sfpool.sf[n+1];
+ break;
+ }
+ POOLMTXUNLOCK(&_Sfpool);
+ }
+ else
+ { f->mode &= ~SF_LOCK; /**/ASSERT(_Sfpmove);
+ if((*_Sfpmove)(f,-1) < 0)
+ { SFOPEN(f,0);
+ SFMTXRETURN(f,-1);
+ }
+ f->mode |= SF_LOCK;
+ }
+ f->pool = NIL(Sfpool_t*);
+ }
+
+ if(f->data && (!local || (f->flags&SF_STRING) || (f->bits&SF_MMAP) ) )
+ { /* free buffer */
+#ifdef MAP_TYPE
+ if(f->bits&SF_MMAP)
+ SFMUNMAP(f,f->data,f->endb-f->data);
+ else
+#endif
+ if(f->flags&SF_MALLOC)
+ data = (Void_t*)f->data;
+
+ f->data = NIL(uchar*);
+ f->size = -1;
+ }
+
+ /* zap the file descriptor */
+ if(_Sfnotify)
+ (*_Sfnotify)(f,SF_CLOSING,f->file);
+ if(f->file >= 0 && !(f->flags&SF_STRING))
+ CLOSE(f->file);
+ f->file = -1;
+
+ SFKILL(f);
+ f->flags &= SF_STATIC;
+ f->here = 0;
+ f->extent = -1;
+ f->endb = f->endr = f->endw = f->next = f->data;
+
+ /* zap any associated auxiliary buffer */
+ if(f->rsrv)
+ { free(f->rsrv);
+ f->rsrv = NIL(Sfrsrv_t*);
+ }
+
+ /* delete any associated sfpopen-data */
+ if(f->proc)
+ rv = _sfpclose(f);
+
+ /* destroy the mutex */
+ if(f->mutex)
+ { (void)vtmtxclrlock(f->mutex);
+ if(f != sfstdin && f != sfstdout && f != sfstderr)
+ { (void)vtmtxclose(f->mutex);
+ f->mutex = NIL(Vtmutex_t*);
+ }
+ }
+
+ if(!local)
+ { if(f->disc && (ex = SFRAISE(f,SF_FINAL,NIL(Void_t*))) != 0 )
+ { rv = ex;
+ goto done;
+ }
+
+ if(!(f->flags&SF_STATIC) )
+ free(f);
+ else
+ { f->disc = NIL(Sfdisc_t*);
+ f->stdio = NIL(Void_t*);
+ f->mode = SF_AVAIL;
+ }
+ }
+
+done:
+ if(data)
+ free(data);
+ return rv;
+}
diff --git a/usr/src/lib/libast/common/sfio/sfclrlock.c b/usr/src/lib/libast/common/sfio/sfclrlock.c
new file mode 100644
index 0000000000..3f0a61e7fc
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfclrlock.c
@@ -0,0 +1,62 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Function to clear a locked stream.
+** This is useful for programs that longjmp from the mid of an sfio function.
+** There is no guarantee on data integrity in such a case.
+**
+** Written by Kiem-Phong Vo
+*/
+#if __STD_C
+int sfclrlock(reg Sfio_t* f)
+#else
+int sfclrlock(f)
+reg Sfio_t *f;
+#endif
+{
+ int rv;
+
+ /* already closed */
+ if(f && (f->mode&SF_AVAIL))
+ return 0;
+
+ SFMTXSTART(f,0);
+
+ /* clear error bits */
+ f->flags &= ~(SF_ERROR|SF_EOF);
+
+ /* clear peek locks */
+ if(f->mode&SF_PKRD)
+ { f->here -= f->endb-f->next;
+ f->endb = f->next;
+ }
+
+ SFCLRBITS(f);
+
+ /* throw away all lock bits except for stacking state SF_PUSH */
+ f->mode &= (SF_RDWR|SF_INIT|SF_POOL|SF_PUSH|SF_SYNCED|SF_STDIO);
+
+ rv = (f->mode&SF_PUSH) ? 0 : (f->flags&SF_FLAGS);
+
+ SFMTXRETURN(f, rv);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfcvt.c b/usr/src/lib/libast/common/sfio/sfcvt.c
new file mode 100644
index 0000000000..93f91931ae
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfcvt.c
@@ -0,0 +1,396 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Convert a floating point value to ASCII.
+**
+** Written by Kiem-Phong Vo and Glenn Fowler (SFFMT_AFORMAT)
+*/
+
+static char *lc_inf = "inf", *uc_inf = "INF";
+static char *lc_nan = "nan", *uc_nan = "NAN";
+static char *Zero = "0";
+#define SF_INF ((_Sfi = 3), strncpy(buf, (format & SFFMT_UPPER) ? uc_inf : lc_inf, size))
+#define SF_NAN ((_Sfi = 3), strncpy(buf, (format & SFFMT_UPPER) ? uc_nan : lc_nan, size))
+#define SF_ZERO ((_Sfi = 1), strncpy(buf, Zero, size))
+#define SF_INTPART (SF_IDIGITS/2)
+
+#if ! _lib_isnan
+#if _lib_fpclassify
+#define isnan(n) (fpclassify(n)==FP_NAN)
+#define isnanl(n) (fpclassify(n)==FP_NAN)
+#else
+#define isnan(n) (memcmp((void*)&n,(void*)&_Sfdnan,sizeof(n))==0)
+#define isnanl(n) (memcmp((void*)&n,(void*)&_Sflnan,sizeof(n))==0)
+#endif
+#else
+#if ! _lib_isnanl
+#define isnanl(n) isnan(n)
+#endif
+#endif
+
+#if __STD_C
+char* _sfcvt(Sfdouble_t dv, char* buf, size_t size, int n_digit,
+ int* decpt, int* sign, int* len, int format)
+#else
+char* _sfcvt(dv,buf,size,n_digit,decpt,sign,len,format)
+Sfdouble_t dv; /* value to convert */
+char* buf; /* conversion goes here */
+size_t size; /* size of buf */
+int n_digit; /* number of digits wanted */
+int* decpt; /* to return decimal point */
+int* sign; /* to return sign */
+int* len; /* return string length */
+int format; /* conversion format */
+#endif
+{
+ reg char *sp;
+ reg long n, v;
+ reg char *ep, *b, *endsp;
+ _ast_flt_unsigned_max_t m;
+
+ static char lx[] = "0123456789abcdef";
+ static char ux[] = "0123456789ABCDEF";
+
+ *sign = *decpt = 0;
+
+ if(isnanl(dv))
+ return SF_NAN;
+#if _lib_isinf
+ if (n = isinf(dv))
+ { if (n < 0)
+ *sign = 1;
+ return SF_INF;
+ }
+#endif
+#if !_ast_fltmax_double
+ if(format&SFFMT_LDOUBLE)
+ { Sfdouble_t f = dv;
+#if _c99_in_the_wild
+#if _lib_signbit
+ if (signbit(f))
+#else
+#if _lib_copysignl
+ if (copysignl(1.0, f) < 0.0)
+#else
+#if _lib_copysign
+ if (copysign(1.0, (double)f) < 0.0)
+#else
+ if (f < 0.0)
+#endif
+#endif
+#endif
+ { f = -f;
+ *sign = 1;
+ }
+#if _lib_fpclassify
+ switch (fpclassify(f))
+ {
+ case FP_INFINITE:
+ return SF_INF;
+ case FP_NAN:
+ return SF_NAN;
+ case FP_ZERO:
+ return SF_ZERO;
+ }
+#endif
+#else
+ if (f < 0.0)
+ { f = -f;
+ *sign = 1;
+ }
+#endif
+ if(f < LDBL_MIN)
+ return SF_ZERO;
+ if(f > LDBL_MAX)
+ return SF_INF;
+
+ if(format & SFFMT_AFORMAT)
+ { Sfdouble_t g;
+ int x;
+ b = sp = buf;
+ ep = (format & SFFMT_UPPER) ? ux : lx;
+ if(n_digit <= 0 || n_digit >= (size - 9))
+ n_digit = size - 9;
+ endsp = sp + n_digit + 1;
+
+ g = frexpl(f, &x);
+ *decpt = x;
+ f = ldexpl(g, 8 * sizeof(m) - 3);
+
+ for (;;)
+ { m = f;
+ x = 8 * sizeof(m);
+ while ((x -= 4) >= 0)
+ { *sp++ = ep[(m >> x) & 0xf];
+ if (sp >= endsp)
+ { ep = sp + 1;
+ goto done;
+ }
+ }
+ f -= m;
+ f = ldexpl(f, 8 * sizeof(m));
+ }
+ }
+
+ n = 0;
+ if(f >= (Sfdouble_t)SF_MAXLONG)
+ { /* scale to a small enough number to fit an int */
+ v = SF_MAXEXP10-1;
+ do
+ { if(f < _Sfpos10[v])
+ v -= 1;
+ else
+ {
+ f *= _Sfneg10[v];
+ if((n += (1<<v)) >= SF_IDIGITS)
+ return SF_INF;
+ }
+ } while(f >= (Sfdouble_t)SF_MAXLONG);
+ }
+ *decpt = (int)n;
+
+ b = sp = buf + SF_INTPART;
+ if((v = (long)f) != 0)
+ { /* translate the integer part */
+ f -= (Sfdouble_t)v;
+
+ sfucvt(v,sp,n,ep,long,ulong);
+
+ n = b-sp;
+ if((*decpt += (int)n) >= SF_IDIGITS)
+ return SF_INF;
+ b = sp;
+ sp = buf + SF_INTPART;
+ }
+ else n = 0;
+
+ /* remaining number of digits to compute; add 1 for later rounding */
+ n = (((format&SFFMT_EFORMAT) || *decpt <= 0) ? 1 : *decpt+1) - n;
+ if(n_digit > 0)
+ { if(n_digit > LDBL_DIG)
+ n_digit = LDBL_DIG;
+ n += n_digit;
+ }
+
+ if((ep = (sp+n)) > (endsp = buf+(size-2)))
+ ep = endsp;
+ if(sp > ep)
+ sp = ep;
+ else
+ {
+ if((format&SFFMT_EFORMAT) && *decpt == 0 && f > 0.)
+ { Sfdouble_t d;
+ while((long)(d = f*10.) == 0)
+ { f = d;
+ *decpt -= 1;
+ }
+ }
+
+ while(sp < ep)
+ { /* generate fractional digits */
+ if(f <= 0.)
+ { /* fill with 0's */
+ do { *sp++ = '0'; } while(sp < ep);
+ goto done;
+ }
+ else if((n = (long)(f *= 10.)) < 10)
+ { *sp++ = '0' + n;
+ f -= n;
+ }
+ else /* n == 10 */
+ { do { *sp++ = '9'; } while(sp < ep);
+ }
+ }
+ }
+ } else
+#endif
+ { double f = (double)dv;
+
+#if _lib_isinf
+ if (n = isinf(f))
+ { if (n < 0)
+ *sign = 1;
+ return SF_INF;
+ }
+#endif
+#if _c99_in_the_wild
+#if _lib_signbit
+ if (signbit(f))
+#else
+#if _lib_copysign
+ if (copysign(1.0, f) < 0.0)
+#else
+ if (f < 0.0)
+#endif
+#endif
+ { f = -f;
+ *sign = 1;
+ }
+#if _lib_fpclassify
+ switch (fpclassify(f))
+ {
+ case FP_INFINITE:
+ return SF_INF;
+ case FP_NAN:
+ return SF_NAN;
+ case FP_ZERO:
+ return SF_ZERO;
+ }
+#endif
+#else
+ if (f < 0.0)
+ { f = -f;
+ *sign = 1;
+ }
+#endif
+ if(f < DBL_MIN)
+ return SF_ZERO;
+ if(f > DBL_MAX)
+ return SF_INF;
+
+ if(format & SFFMT_AFORMAT)
+ { double g;
+ int x;
+ b = sp = buf;
+ ep = (format & SFFMT_UPPER) ? ux : lx;
+ if(n_digit <= 0 || n_digit >= (size - 9))
+ n_digit = size - 9;
+ endsp = sp + n_digit;
+
+ g = frexp(f, &x);
+ *decpt = x;
+ f = ldexp(g, 8 * sizeof(m) - 3);
+
+ for (;;)
+ { m = f;
+ x = 8 * sizeof(m);
+ while ((x -= 4) >= 0)
+ { *sp++ = ep[(m >> x) & 0xf];
+ if (sp >= endsp)
+ { ep = sp + 1;
+ goto done;
+ }
+ }
+ f -= m;
+ f = ldexp(f, 8 * sizeof(m));
+ }
+ }
+ n = 0;
+ if(f >= (double)SF_MAXLONG)
+ { /* scale to a small enough number to fit an int */
+ v = SF_MAXEXP10-1;
+ do
+ { if(f < _Sfpos10[v])
+ v -= 1;
+ else
+ { f *= _Sfneg10[v];
+ if((n += (1<<v)) >= SF_IDIGITS)
+ return SF_INF;
+ }
+ } while(f >= (double)SF_MAXLONG);
+ }
+ *decpt = (int)n;
+
+ b = sp = buf + SF_INTPART;
+ if((v = (long)f) != 0)
+ { /* translate the integer part */
+ f -= (double)v;
+
+ sfucvt(v,sp,n,ep,long,ulong);
+
+ n = b-sp;
+ if((*decpt += (int)n) >= SF_IDIGITS)
+ return SF_INF;
+ b = sp;
+ sp = buf + SF_INTPART;
+ }
+ else n = 0;
+
+ /* remaining number of digits to compute; add 1 for later rounding */
+ n = (((format&SFFMT_EFORMAT) || *decpt <= 0) ? 1 : *decpt+1) - n;
+ if(n_digit > 0)
+ { if(n_digit > DBL_DIG)
+ n_digit = DBL_DIG;
+ n += n_digit;
+ }
+
+ if((ep = (sp+n)) > (endsp = buf+(size-2)))
+ ep = endsp;
+ if(sp > ep)
+ sp = ep;
+ else
+ {
+ if((format&SFFMT_EFORMAT) && *decpt == 0 && f > 0.)
+ { reg double d;
+ while((long)(d = f*10.) == 0)
+ { f = d;
+ *decpt -= 1;
+ }
+ }
+
+ while(sp < ep)
+ { /* generate fractional digits */
+ if(f <= 0.)
+ { /* fill with 0's */
+ do { *sp++ = '0'; } while(sp < ep);
+ goto done;
+ }
+ else if((n = (long)(f *= 10.)) < 10)
+ { *sp++ = (char)('0' + n);
+ f -= n;
+ }
+ else /* n == 10 */
+ { do { *sp++ = '9'; } while(sp < ep);
+ }
+ }
+ }
+ }
+
+ if(ep <= b)
+ ep = b+1;
+ else if(ep < endsp)
+ { /* round the last digit */
+ *--sp += 5;
+ while(*sp > '9')
+ { *sp = '0';
+ if(sp > b)
+ *--sp += 1;
+ else
+ { /* next power of 10 */
+ *sp = '1';
+ *decpt += 1;
+ if(!(format&SFFMT_EFORMAT))
+ { /* add one more 0 for %f precision */
+ ep[-1] = '0';
+ ep += 1;
+ }
+ }
+ }
+ }
+
+done:
+ *--ep = '\0';
+ if(len)
+ *len = ep-b;
+ return b;
+}
diff --git a/usr/src/lib/libast/common/sfio/sfdisc.c b/usr/src/lib/libast/common/sfio/sfdisc.c
new file mode 100644
index 0000000000..34e9f47c45
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfdisc.c
@@ -0,0 +1,265 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Add a new discipline to the discipline stack. Each discipline
+** provides alternative I/O functions that are analogues of the
+** system calls.
+**
+** When the application fills or flushes the stream buffer, data
+** will be processed through discipline functions. A case deserving
+** consideration is stacking a discipline onto a read stream. Each
+** discipline operation implies buffer synchronization so the stream
+** buffer should be empty. However, a read stream representing an
+** unseekable device (eg, a pipe) may not be synchronizable. In that
+** case, any buffered data must then be fed to the new discipline
+** to preserve data processing semantics. This is done by creating
+** a temporary discipline to cache such buffered data and feed
+** them to the new discipline when its readf() asks for new data.
+** Care must then be taken to remove this temporary discipline
+** when it runs out of cached data.
+**
+** Written by Kiem-Phong Vo
+*/
+
+typedef struct _dccache_s
+{ Sfdisc_t disc;
+ uchar* data;
+ uchar* endb;
+} Dccache_t;
+
+#if __STD_C
+static int _dccaexcept(Sfio_t* f, int type, Void_t* val, Sfdisc_t* disc)
+#else
+static int _dccaexcept(f,type,val,disc)
+Sfio_t* f;
+int type;
+Void_t* val;
+Sfdisc_t* disc;
+#endif
+{
+ if(disc && type == SF_FINAL)
+ free(disc);
+ return 0;
+}
+
+#if __STD_C
+static ssize_t _dccaread(Sfio_t* f, Void_t* buf, size_t size, Sfdisc_t* disc)
+#else
+static ssize_t _dccaread(f, buf, size, disc)
+Sfio_t* f;
+Void_t* buf;
+size_t size;
+Sfdisc_t* disc;
+#endif
+{
+ ssize_t sz;
+ Sfdisc_t *prev;
+ Dccache_t *dcca;
+
+ if(!f) /* bad stream */
+ return -1;
+
+ /* make sure that this is on the discipline stack */
+ for(prev = f->disc; prev; prev = prev->disc)
+ if(prev->disc == disc)
+ break;
+ if(!prev)
+ return -1;
+
+ if(size <= 0) /* nothing to do */
+ return size;
+
+ /* read from available data */
+ dcca = (Dccache_t*)disc;
+ if((sz = dcca->endb - dcca->data) > (ssize_t)size)
+ sz = (ssize_t)size;
+ memcpy(buf, dcca->data, sz);
+
+ if((dcca->data += sz) >= dcca->endb) /* free empty cache */
+ { prev->disc = disc->disc;
+ free(disc);
+ }
+
+ return sz;
+}
+
+#if __STD_C
+Sfdisc_t* sfdisc(reg Sfio_t* f, reg Sfdisc_t* disc)
+#else
+Sfdisc_t* sfdisc(f,disc)
+reg Sfio_t* f;
+reg Sfdisc_t* disc;
+#endif
+{
+ reg Sfdisc_t *d, *rdisc;
+ reg Sfread_f oreadf;
+ reg Sfwrite_f owritef;
+ reg Sfseek_f oseekf;
+ ssize_t n;
+ reg Dccache_t *dcca = NIL(Dccache_t*);
+
+ SFMTXSTART(f, NIL(Sfdisc_t*));
+
+ if((f->flags&SF_READ) && f->proc && (f->mode&SF_WRITE) )
+ { /* make sure in read mode to check for read-ahead data */
+ if(_sfmode(f,SF_READ,0) < 0)
+ SFMTXRETURN(f, NIL(Sfdisc_t*));
+ }
+ else if((f->mode&SF_RDWR) != f->mode && _sfmode(f,0,0) < 0)
+ SFMTXRETURN(f, NIL(Sfdisc_t*));
+
+ SFLOCK(f,0);
+ rdisc = NIL(Sfdisc_t*);
+
+ /* disallow popping while there is cached data */
+ if(!disc && f->disc && f->disc->disc && f->disc->disc->readf == _dccaread )
+ goto done;
+
+ /* synchronize before switching to a new discipline */
+ if(!(f->flags&SF_STRING))
+ { (void)SFSYNC(f); /* do a silent buffer synch */
+ if((f->mode&SF_READ) && (f->mode&SF_SYNCED) )
+ { f->mode &= ~SF_SYNCED;
+ f->endb = f->next = f->endr = f->endw = f->data;
+ }
+
+ /* if there is buffered data, ask app before proceeding */
+ if(((f->mode&SF_WRITE) && (n = f->next-f->data) > 0) ||
+ ((f->mode&SF_READ) && (n = f->endb-f->next) > 0) )
+ { int rv = 0;
+ if(rv == 0 && f->disc && f->disc->exceptf) /* ask current discipline */
+ { SFOPEN(f,0);
+ rv = (*f->disc->exceptf)(f, SF_DBUFFER, &n, f->disc);
+ SFLOCK(f,0);
+ }
+ if(rv == 0 && disc && disc->exceptf) /* ask discipline being pushed */
+ { SFOPEN(f,0);
+ rv = (*disc->exceptf)(f, SF_DBUFFER, &n, disc);
+ SFLOCK(f,0);
+ }
+ if(rv < 0)
+ goto done;
+ }
+
+ /* trick the new discipline into processing already buffered data */
+ if((f->mode&SF_READ) && n > 0 && disc && disc->readf )
+ { if(!(dcca = (Dccache_t*)malloc(sizeof(Dccache_t)+n)) )
+ goto done;
+ memclear(dcca, sizeof(Dccache_t));
+
+ dcca->disc.readf = _dccaread;
+ dcca->disc.exceptf = _dccaexcept;
+
+ /* move buffered data into the temp discipline */
+ dcca->data = ((uchar*)dcca) + sizeof(Dccache_t);
+ dcca->endb = dcca->data + n;
+ memcpy(dcca->data, f->next, n);
+ f->endb = f->next = f->endr = f->endw = f->data;
+ }
+ }
+
+ /* save old readf, writef, and seekf to see if stream need reinit */
+#define GETDISCF(func,iof,type) \
+ { for(d = f->disc; d && !d->iof; d = d->disc) ; \
+ func = d ? d->iof : NIL(type); \
+ }
+ GETDISCF(oreadf,readf,Sfread_f);
+ GETDISCF(owritef,writef,Sfwrite_f);
+ GETDISCF(oseekf,seekf,Sfseek_f);
+
+ if(disc == SF_POPDISC)
+ { /* popping, warn the being popped discipline */
+ if(!(d = f->disc) )
+ goto done;
+ disc = d->disc;
+ if(d->exceptf)
+ { SFOPEN(f,0);
+ if((*(d->exceptf))(f,SF_DPOP,(Void_t*)disc,d) < 0 )
+ goto done;
+ SFLOCK(f,0);
+ }
+ f->disc = disc;
+ rdisc = d;
+ }
+ else
+ { /* pushing, warn being pushed discipline */
+ do
+ { /* loop to handle the case where d may pop itself */
+ d = f->disc;
+ if(d && d->exceptf)
+ { SFOPEN(f,0);
+ if( (*(d->exceptf))(f,SF_DPUSH,(Void_t*)disc,d) < 0 )
+ goto done;
+ SFLOCK(f,0);
+ }
+ } while(d != f->disc);
+
+ /* make sure we are not creating an infinite loop */
+ for(; d; d = d->disc)
+ if(d == disc)
+ goto done;
+
+ /* set new disc */
+ if(dcca) /* insert the discipline with cached data */
+ { dcca->disc.disc = f->disc;
+ disc->disc = &dcca->disc;
+ }
+ else disc->disc = f->disc;
+ f->disc = disc;
+ rdisc = disc;
+ }
+
+ if(!(f->flags&SF_STRING) )
+ { /* this stream may have to be reinitialized */
+ reg int reinit = 0;
+#define DISCF(dst,iof,type) (dst ? dst->iof : NIL(type))
+#define REINIT(oiof,iof,type) \
+ if(!reinit) \
+ { for(d = f->disc; d && !d->iof; d = d->disc) ; \
+ if(DISCF(d,iof,type) != oiof) \
+ reinit = 1; \
+ }
+
+ REINIT(oreadf,readf,Sfread_f);
+ REINIT(owritef,writef,Sfwrite_f);
+ REINIT(oseekf,seekf,Sfseek_f);
+
+ if(reinit)
+ { SETLOCAL(f);
+ f->bits &= ~SF_NULL; /* turn off /dev/null handling */
+ if((f->bits&SF_MMAP) || (f->mode&SF_INIT))
+ sfsetbuf(f,NIL(Void_t*),(size_t)SF_UNBOUND);
+ else if(f->data == f->tiny)
+ sfsetbuf(f,NIL(Void_t*),0);
+ else
+ { int flags = f->flags;
+ sfsetbuf(f,(Void_t*)f->data,f->size);
+ f->flags |= (flags&SF_MALLOC);
+ }
+ }
+ }
+
+done :
+ SFOPEN(f,0);
+ SFMTXRETURN(f, rdisc);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfdlen.c b/usr/src/lib/libast/common/sfio/sfdlen.c
new file mode 100644
index 0000000000..8865b2d453
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfdlen.c
@@ -0,0 +1,58 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Return the length of a double value if coded in a portable format
+**
+** Written by Kiem-Phong Vo
+*/
+
+#if __STD_C
+int _sfdlen(Sfdouble_t v)
+#else
+int _sfdlen(v)
+Sfdouble_t v;
+#endif
+{
+#define N_ARRAY (16*sizeof(Sfdouble_t))
+ reg int n, w;
+ Sfdouble_t x;
+ int exp;
+
+ if(v < 0)
+ v = -v;
+
+ /* make the magnitude of v < 1 */
+ if(v != 0.)
+ v = frexpl(v,&exp);
+ else exp = 0;
+
+ for(w = 1; w <= N_ARRAY; ++w)
+ { /* get 2^SF_PRECIS precision at a time */
+ n = (int)(x = ldexpl(v,SF_PRECIS));
+ v = x-n;
+ if(v <= 0.)
+ break;
+ }
+
+ return 1 + sfulen(exp) + w;
+}
diff --git a/usr/src/lib/libast/common/sfio/sfecvt.c b/usr/src/lib/libast/common/sfio/sfecvt.c
new file mode 100644
index 0000000000..d02eb749ad
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfecvt.c
@@ -0,0 +1,38 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+#if __STD_C
+char* sfecvt(double dval, int n_digit, int* decpt, int* sign)
+#else
+char* sfecvt(dval,n_digit,decpt,sign)
+double dval; /* value to convert */
+int n_digit; /* number of digits wanted */
+int* decpt; /* to return decimal point */
+int* sign; /* to return sign */
+#endif
+{
+ int len;
+ static char buf[SF_MAXDIGITS];
+
+ return _sfcvt((Sfdouble_t)dval,buf,sizeof(buf),n_digit,decpt,sign,&len,SFFMT_EFORMAT);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfexcept.c b/usr/src/lib/libast/common/sfio/sfexcept.c
new file mode 100644
index 0000000000..bc7c32717e
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfexcept.c
@@ -0,0 +1,132 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Function to handle io exceptions.
+** Written by Kiem-Phong Vo
+*/
+
+#if __STD_C
+int _sfexcept(Sfio_t* f, int type, ssize_t io, Sfdisc_t* disc)
+#else
+int _sfexcept(f,type,io,disc)
+Sfio_t* f; /* stream where the exception happened */
+int type; /* io type that was performed */
+ssize_t io; /* the io return value that indicated exception */
+Sfdisc_t* disc; /* discipline in use */
+#endif
+{
+ reg int ev, local, lock;
+ reg ssize_t size;
+ reg uchar* data;
+
+ SFMTXSTART(f,-1);
+
+ GETLOCAL(f,local);
+ lock = f->mode&SF_LOCK;
+
+ if(local && io <= 0)
+ f->flags |= io < 0 ? SF_ERROR : SF_EOF;
+
+ if(disc && disc->exceptf)
+ { /* let the stream be generally accessible for this duration */
+ if(local && lock)
+ SFOPEN(f,0);
+
+ /* so that exception handler knows what we are asking for */
+ _Sfi = f->val = io;
+ ev = (*(disc->exceptf))(f,type,&io,disc);
+
+ /* relock if necessary */
+ if(local && lock)
+ SFLOCK(f,0);
+
+ if(io > 0 && !(f->flags&SF_STRING) )
+ SFMTXRETURN(f, ev);
+ if(ev < 0)
+ SFMTXRETURN(f, SF_EDONE);
+ if(ev > 0)
+ SFMTXRETURN(f, SF_EDISC);
+ }
+
+ if(f->flags&SF_STRING)
+ { if(type == SF_READ)
+ goto chk_stack;
+ else if(type != SF_WRITE && type != SF_SEEK)
+ SFMTXRETURN(f, SF_EDONE);
+ if(local && io >= 0)
+ { if(f->size >= 0 && !(f->flags&SF_MALLOC))
+ goto chk_stack;
+ /* extend buffer */
+ if((size = f->size) < 0)
+ size = 0;
+ if((io -= size) <= 0)
+ io = SF_GRAIN;
+ size = ((size+io+SF_GRAIN-1)/SF_GRAIN)*SF_GRAIN;
+ if(f->size > 0)
+ data = (uchar*)realloc((char*)f->data,size);
+ else data = (uchar*)malloc(size);
+ if(!data)
+ goto chk_stack;
+ f->endb = data + size;
+ f->next = data + (f->next - f->data);
+ f->endr = f->endw = f->data = data;
+ f->size = size;
+ }
+ SFMTXRETURN(f, SF_EDISC);
+ }
+
+ if(errno == EINTR)
+ { if(_Sfexiting || (f->bits&SF_ENDING) || /* stop being a hero */
+ (f->flags&SF_IOINTR) ) /* application requests to return */
+ SFMTXRETURN(f, SF_EDONE);
+
+ /* a normal interrupt, we can continue */
+ errno = 0;
+ f->flags &= ~(SF_EOF|SF_ERROR);
+ SFMTXRETURN(f, SF_ECONT);
+ }
+
+chk_stack:
+ if(local && f->push &&
+ ((type == SF_READ && f->next >= f->endb) ||
+ (type == SF_WRITE && f->next <= f->data)))
+ { /* pop the stack */
+ reg Sfio_t *pf;
+
+ if(lock)
+ SFOPEN(f,0);
+
+ /* pop and close */
+ pf = (*_Sfstack)(f,NIL(Sfio_t*));
+ if((ev = sfclose(pf)) < 0) /* can't close, restack */
+ (*_Sfstack)(f,pf);
+
+ if(lock)
+ SFLOCK(f,0);
+
+ ev = ev < 0 ? SF_EDONE : SF_ESTACK;
+ }
+ else ev = SF_EDONE;
+
+ SFMTXRETURN(f, ev);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfextern.c b/usr/src/lib/libast/common/sfio/sfextern.c
new file mode 100644
index 0000000000..36ca0a0836
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfextern.c
@@ -0,0 +1,101 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* External variables and functions used only by Sfio
+** Written by Kiem-Phong Vo
+*/
+
+/* code to initialize mutexes */
+static Vtmutex_t Sfmutex;
+static Vtonce_t Sfonce = VTONCE_INITDATA;
+static void _sfoncef()
+{ (void)vtmtxopen(_Sfmutex, VT_INIT);
+ (void)vtmtxopen(&_Sfpool.mutex, VT_INIT);
+ (void)vtmtxopen(sfstdin->mutex, VT_INIT);
+ (void)vtmtxopen(sfstdout->mutex, VT_INIT);
+ (void)vtmtxopen(sfstderr->mutex, VT_INIT);
+ _Sfdone = 1;
+}
+
+/* global variables used internally to the package */
+Sfextern_t _Sfextern =
+{ 0, /* _Sfpage */
+ { NIL(Sfpool_t*), 0, 0, 0, NIL(Sfio_t**) }, /* _Sfpool */
+ NIL(int(*)_ARG_((Sfio_t*,int))), /* _Sfpmove */
+ NIL(Sfio_t*(*)_ARG_((Sfio_t*, Sfio_t*))), /* _Sfstack */
+ NIL(void(*)_ARG_((Sfio_t*, int, int))), /* _Sfnotify */
+ NIL(int(*)_ARG_((Sfio_t*))), /* _Sfstdsync */
+ { NIL(Sfread_f), /* _Sfudisc */
+ NIL(Sfwrite_f),
+ NIL(Sfseek_f),
+ NIL(Sfexcept_f),
+ NIL(Sfdisc_t*)
+ },
+ NIL(void(*)_ARG_((void)) ), /* _Sfcleanup */
+ 0, /* _Sfexiting */
+ 0, /* _Sfdone */
+ &Sfonce, /* _Sfonce */
+ _sfoncef, /* _Sfoncef */
+ &Sfmutex /* _Sfmutex */
+};
+
+ssize_t _Sfi = -1; /* value for a few fast macro functions */
+#if INT_MAX == LONG_MAX
+ssize_t _Sfmaxr = 64*1024; /* default maximum size for a record */
+#else
+ssize_t _Sfmaxr = 16*1024; /* default maximum size for a record */
+#endif
+
+#if vt_threaded
+static Vtmutex_t _Sfmtxin, _Sfmtxout, _Sfmtxerr;
+#define SFMTXIN (&_Sfmtxin)
+#define SFMTXOUT (&_Sfmtxout)
+#define SFMTXERR (&_Sfmtxerr)
+#else
+#define SFMTXIN (0)
+#define SFMTXOUT (0)
+#define SFMTXERR (0)
+#endif
+
+Sfio_t _Sfstdin = SFNEW(NIL(char*),-1,0,
+ (SF_READ |SF_STATIC|SF_MTSAFE),NIL(Sfdisc_t*),SFMTXIN);
+Sfio_t _Sfstdout = SFNEW(NIL(char*),-1,1,
+ (SF_WRITE|SF_STATIC|SF_MTSAFE),NIL(Sfdisc_t*),SFMTXOUT);
+Sfio_t _Sfstderr = SFNEW(NIL(char*),-1,2,
+ (SF_WRITE|SF_STATIC|SF_MTSAFE),NIL(Sfdisc_t*),SFMTXERR);
+
+#undef sfstdin
+#undef sfstdout
+#undef sfstderr
+
+Sfio_t* sfstdin = &_Sfstdin;
+Sfio_t* sfstdout = &_Sfstdout;
+Sfio_t* sfstderr = &_Sfstderr;
+
+__EXTERN__(ssize_t,_Sfi);
+__EXTERN__(Sfio_t,_Sfstdin);
+__EXTERN__(Sfio_t,_Sfstdout);
+__EXTERN__(Sfio_t,_Sfstderr);
+__EXTERN__(Sfio_t*,sfstdin);
+__EXTERN__(Sfio_t*,sfstdout);
+__EXTERN__(Sfio_t*,sfstderr);
diff --git a/usr/src/lib/libast/common/sfio/sffcvt.c b/usr/src/lib/libast/common/sfio/sffcvt.c
new file mode 100644
index 0000000000..bb133590a4
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sffcvt.c
@@ -0,0 +1,38 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+#if __STD_C
+char *sffcvt(double dval, int n_digit, int* decpt, int* sign)
+#else
+char *sffcvt(dval,n_digit,decpt,sign)
+double dval; /* value to convert */
+int n_digit; /* number of digits wanted */
+int* decpt; /* to return decimal point */
+int* sign; /* to return sign */
+#endif
+{
+ int len;
+ static char buf[SF_MAXDIGITS];
+
+ return _sfcvt((Sfdouble_t)dval,buf,sizeof(buf),n_digit,decpt,sign,&len,0);
+}
diff --git a/usr/src/lib/libast/common/sfio/sffilbuf.c b/usr/src/lib/libast/common/sfio/sffilbuf.c
new file mode 100644
index 0000000000..9e0d2b8e7b
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sffilbuf.c
@@ -0,0 +1,115 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Fill the buffer of a stream with data.
+** If n < 0, sffilbuf() attempts to fill the buffer if it's empty.
+** If n == 0, if the buffer is not empty, just return the first byte;
+** otherwise fill the buffer and return the first byte.
+** If n > 0, even if the buffer is not empty, try a read to get as
+** close to n as possible. n is reset to -1 if stack pops.
+**
+** Written by Kiem-Phong Vo
+*/
+
+#if __STD_C
+int _sffilbuf(Sfio_t* f, reg int n)
+#else
+int _sffilbuf(f,n)
+Sfio_t* f; /* fill the read buffer of this stream */
+reg int n; /* see above */
+#endif
+{
+ reg ssize_t r;
+ reg int first, local, rcrv, rc, justseek;
+
+ SFMTXSTART(f,-1);
+
+ GETLOCAL(f,local);
+
+ /* any peek data must be preserved across stacked streams */
+ rcrv = f->mode&(SF_RC|SF_RV|SF_LOCK);
+ rc = f->getr;
+
+ justseek = f->bits&SF_JUSTSEEK; f->bits &= ~SF_JUSTSEEK;
+
+ for(first = 1;; first = 0, (f->mode &= ~SF_LOCK) )
+ { /* check mode */
+ if(SFMODE(f,local) != SF_READ && _sfmode(f,SF_READ,local) < 0)
+ SFMTXRETURN(f,-1);
+ SFLOCK(f,local);
+
+ /* current extent of available data */
+ if((r = f->endb-f->next) > 0)
+ { /* on first iteration, n is amount beyond current buffer;
+ afterward, n is the exact amount requested */
+ if((first && n <= 0) || (!first && n <= r) ||
+ (f->flags&SF_STRING))
+ break;
+
+ /* try shifting left to make room for new data */
+ if(!(f->bits&SF_MMAP) && f->next > f->data &&
+ n > (f->size - (f->endb-f->data)) )
+ { ssize_t s = r;
+
+ /* try to maintain block alignment */
+ if(f->blksz > 0 && (f->here%f->blksz) == 0 )
+ { s = ((r + f->blksz-1)/f->blksz)*f->blksz;
+ if(s+n > f->size)
+ s = r;
+ }
+
+ memcpy(f->data, f->endb-s, s);
+ f->next = f->data + (s-r);
+ f->endb = f->data + s;
+ }
+ }
+ else if(!(f->flags&SF_STRING) && !(f->bits&SF_MMAP) )
+ f->next = f->endb = f->endr = f->data;
+
+ if(f->bits&SF_MMAP)
+ r = n > 0 ? n : f->size;
+ else if(!(f->flags&SF_STRING) )
+ { r = f->size - (f->endb - f->data); /* available buffer */
+ if(n > 0)
+ { if(r > n && f->extent < 0 && (f->flags&SF_SHARE) )
+ r = n; /* read only as much as requested */
+ else if(justseek && n <= f->iosz && f->iosz <= f->size)
+ r = f->iosz; /* limit buffer filling */
+ }
+ }
+
+ /* SFRD takes care of discipline read and stack popping */
+ f->mode |= rcrv;
+ f->getr = rc;
+ if((r = SFRD(f,f->endb,r,f->disc)) >= 0)
+ { r = f->endb - f->next;
+ break;
+ }
+ }
+
+ SFOPEN(f,local);
+
+ rcrv = (n == 0) ? (r > 0 ? (int)(*f->next++) : EOF) : (int)r;
+
+ SFMTXRETURN(f,rcrv);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfflsbuf.c b/usr/src/lib/libast/common/sfio/sfflsbuf.c
new file mode 100644
index 0000000000..fb7dc3b61d
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfflsbuf.c
@@ -0,0 +1,116 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Write a buffer out to a file descriptor or
+** extending a buffer for a SF_STRING stream.
+**
+** Written by Kiem-Phong Vo
+*/
+
+#if __STD_C
+int _sfflsbuf(reg Sfio_t* f, reg int c)
+#else
+int _sfflsbuf(f,c)
+reg Sfio_t* f; /* write out the buffered content of this stream */
+reg int c; /* if c>=0, c is also written out */
+#endif
+{
+ reg ssize_t n, w;
+ reg uchar* data;
+ uchar outc;
+ reg int local, isall;
+ int inpc = c;
+
+ SFMTXSTART(f,-1);
+
+ GETLOCAL(f,local);
+
+ for(;; f->mode &= ~SF_LOCK)
+ { /* check stream mode */
+ if(SFMODE(f,local) != SF_WRITE && _sfmode(f,SF_WRITE,local) < 0)
+ SFMTXRETURN(f, -1);
+ SFLOCK(f,local);
+
+ /* current data extent */
+ n = f->next - (data = f->data);
+
+ if(n == (f->endb-data) && (f->flags&SF_STRING))
+ { /* extend string stream buffer */
+ (void)SFWR(f,data,1,f->disc);
+
+ /* !(f->flags&SF_STRING) is required because exception
+ handlers may turn a string stream to a file stream */
+ if(f->next < f->endb || !(f->flags&SF_STRING) )
+ n = f->next - (data = f->data);
+ else
+ { SFOPEN(f,local);
+ SFMTXRETURN(f, -1);
+ }
+ }
+
+ if(c >= 0)
+ { /* write into buffer */
+ if(n < (f->endb - (data = f->data)))
+ { *f->next++ = c;
+ if(c == '\n' &&
+ (f->flags&SF_LINE) && !(f->flags&SF_STRING))
+ { c = -1;
+ n += 1;
+ }
+ else break;
+ }
+ else if(n == 0)
+ { /* unbuffered io */
+ outc = (uchar)c;
+ data = &outc;
+ c = -1;
+ n = 1;
+ }
+ }
+
+ if(n == 0 || (f->flags&SF_STRING))
+ break;
+
+ isall = SFISALL(f,isall);
+ if((w = SFWR(f,data,n,f->disc)) > 0)
+ { if((n -= w) > 0) /* save unwritten data, then resume */
+ memcpy((char*)f->data,(char*)data+w,n);
+ f->next = f->data+n;
+ if(c < 0 && (!isall || n == 0))
+ break;
+ }
+ else if(w == 0)
+ { SFOPEN(f,local);
+ SFMTXRETURN(f, -1);
+ }
+ else if(c < 0)
+ break;
+ }
+
+ SFOPEN(f,local);
+
+ if(inpc < 0)
+ inpc = f->endb-f->next;
+
+ SFMTXRETURN(f,inpc);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfgetd.c b/usr/src/lib/libast/common/sfio/sfgetd.c
new file mode 100644
index 0000000000..da72cf7796
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfgetd.c
@@ -0,0 +1,78 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Read a portably coded double value
+**
+** Written by Kiem-Phong Vo
+*/
+
+#if __STD_C
+Sfdouble_t sfgetd(Sfio_t* f)
+#else
+Sfdouble_t sfgetd(f)
+Sfio_t* f;
+#endif
+{
+ reg uchar *s, *ends, c;
+ reg int p, sign, exp;
+ Sfdouble_t v;
+
+ SFMTXSTART(f,-1.);
+
+ if((sign = sfgetc(f)) < 0 || (exp = (int)sfgetu(f)) < 0)
+ SFMTXRETURN(f, -1.);
+
+ if(f->mode != SF_READ && _sfmode(f,SF_READ,0) < 0)
+ SFMTXRETURN(f, -1.);
+
+ SFLOCK(f,0);
+
+ v = 0.;
+ for(;;)
+ { /* fast read for data */
+ if(SFRPEEK(f,s,p) <= 0)
+ { f->flags |= SF_ERROR;
+ v = -1.;
+ goto done;
+ }
+
+ for(ends = s+p; s < ends; )
+ { c = *s++;
+ v += SFUVALUE(c);
+ v = ldexpl(v,-SF_PRECIS);
+ if(!(c&SF_MORE))
+ { f->next = s;
+ goto done;
+ }
+ }
+ f->next = s;
+ }
+
+done:
+ v = ldexpl(v,(sign&02) ? -exp : exp);
+ if(sign&01)
+ v = -v;
+
+ SFOPEN(f,0);
+ SFMTXRETURN(f, v);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfgetl.c b/usr/src/lib/libast/common/sfio/sfgetl.c
new file mode 100644
index 0000000000..6e49f4f023
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfgetl.c
@@ -0,0 +1,69 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Read a long value coded in a portable format.
+**
+** Written by Kiem-Phong Vo
+*/
+
+#if __STD_C
+Sflong_t sfgetl(reg Sfio_t* f)
+#else
+Sflong_t sfgetl(f)
+reg Sfio_t* f;
+#endif
+{
+ Sflong_t v;
+ reg uchar *s, *ends, c;
+ reg int p;
+
+ SFMTXSTART(f,(Sflong_t)(-1));
+
+ if(f->mode != SF_READ && _sfmode(f,SF_READ,0) < 0)
+ SFMTXRETURN(f, (Sflong_t)(-1));
+ SFLOCK(f,0);
+
+ for(v = 0;;)
+ { if(SFRPEEK(f,s,p) <= 0)
+ { f->flags |= SF_ERROR;
+ v = (Sflong_t)(-1);
+ goto done;
+ }
+ for(ends = s+p; s < ends;)
+ { c = *s++;
+ if(c&SF_MORE)
+ v = ((Sfulong_t)v << SF_UBITS) | SFUVALUE(c);
+ else
+ { /* special translation for this byte */
+ v = ((Sfulong_t)v << SF_SBITS) | SFSVALUE(c);
+ f->next = s;
+ v = (c&SF_SIGN) ? -v-1 : v;
+ goto done;
+ }
+ }
+ f->next = s;
+ }
+done :
+ SFOPEN(f,0);
+ SFMTXRETURN(f, v);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfgetm.c b/usr/src/lib/libast/common/sfio/sfgetm.c
new file mode 100644
index 0000000000..275b0144e4
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfgetm.c
@@ -0,0 +1,67 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Read an unsigned long value coded portably for a given range.
+**
+** Written by Kiem-Phong Vo
+*/
+
+#if __STD_C
+Sfulong_t sfgetm(reg Sfio_t* f, Sfulong_t m)
+#else
+Sfulong_t sfgetm(f, m)
+reg Sfio_t* f;
+Sfulong_t m;
+#endif
+{
+ Sfulong_t v;
+ reg uchar *s, *ends, c;
+ reg int p;
+
+ SFMTXSTART(f, (Sfulong_t)(-1));
+
+ if(f->mode != SF_READ && _sfmode(f,SF_READ,0) < 0)
+ SFMTXRETURN(f, (Sfulong_t)(-1));
+
+ SFLOCK(f,0);
+
+ for(v = 0;; )
+ { if(SFRPEEK(f,s,p) <= 0)
+ { f->flags |= SF_ERROR;
+ v = (Sfulong_t)(-1);
+ goto done;
+ }
+ for(ends = s+p; s < ends;)
+ { c = *s++;
+ v = (v << SF_BBITS) | SFBVALUE(c);
+ if((m >>= SF_BBITS) <= 0)
+ { f->next = s;
+ goto done;
+ }
+ }
+ f->next = s;
+ }
+done:
+ SFOPEN(f,0);
+ SFMTXRETURN(f, v);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfgetr.c b/usr/src/lib/libast/common/sfio/sfgetr.c
new file mode 100644
index 0000000000..a3df6757a9
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfgetr.c
@@ -0,0 +1,163 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Read a record delineated by a character.
+** The record length can be accessed via sfvalue(f).
+**
+** Written by Kiem-Phong Vo
+*/
+
+#if __STD_C
+char* sfgetr(reg Sfio_t *f, reg int rc, int type)
+#else
+char* sfgetr(f,rc,type)
+reg Sfio_t* f; /* stream to read from */
+reg int rc; /* record separator */
+int type;
+#endif
+{
+ reg ssize_t n, un;
+ reg uchar *s, *ends, *us;
+ reg int found;
+ reg Sfrsrv_t* rsrv;
+
+ SFMTXSTART(f, NIL(char*));
+
+ if(rc < 0 || (f->mode != SF_READ && _sfmode(f,SF_READ,0) < 0) )
+ SFMTXRETURN(f, NIL(char*));
+ SFLOCK(f,0);
+
+ /* buffer to be returned */
+ rsrv = NIL(Sfrsrv_t*);
+ us = NIL(uchar*);
+ un = 0;
+ found = 0;
+
+ /* compatibility mode */
+ type = type < 0 ? SF_LASTR : type == 1 ? SF_STRING : type;
+
+ if(type&SF_LASTR) /* return the broken record */
+ { if((rsrv = f->rsrv) && (un = -rsrv->slen) > 0)
+ { us = rsrv->data;
+ found = 1;
+ }
+ goto done;
+ }
+
+ while(!found)
+ { /* fill buffer if necessary */
+ if((n = (ends = f->endb) - (s = f->next)) <= 0)
+ { /* for unseekable devices, peek-read 1 record */
+ f->getr = rc;
+ f->mode |= SF_RC;
+
+ /* fill buffer the conventional way */
+ if(SFRPEEK(f,s,n) <= 0)
+ { us = NIL(uchar*);
+ goto done;
+ }
+ else
+ { ends = s+n;
+ if(f->mode&SF_RC)
+ { s = ends[-1] == rc ? ends-1 : ends;
+ goto do_copy;
+ }
+ }
+ }
+
+#if _lib_memchr
+ if(!(s = (uchar*)memchr((char*)s,rc,n)))
+ s = ends;
+#else
+ while(*s != rc)
+ if((s += 1) == ends)
+ break;
+#endif
+ do_copy:
+ if(s < ends) /* found separator */
+ { s += 1; /* include the separator */
+ found = 1;
+
+ if(!us &&
+ (!(type&SF_STRING) || !(f->flags&SF_STRING) ||
+ ((f->flags&SF_STRING) && (f->bits&SF_BOTH) ) ) )
+ { /* returning data in buffer */
+ us = f->next;
+ un = s - f->next;
+ f->next = s;
+ goto done;
+ }
+ }
+
+ /* amount to be read */
+ n = s - f->next;
+
+ if(!found && _Sfmaxr > 0 && un+n+1 >= _Sfmaxr) /* already exceed limit */
+ { us = NIL(uchar*);
+ goto done;
+ }
+
+ /* get internal buffer */
+ if(!rsrv || rsrv->size < un+n+1)
+ { if(rsrv)
+ rsrv->slen = un;
+ if((rsrv = _sfrsrv(f,un+n+1)) != NIL(Sfrsrv_t*))
+ us = rsrv->data;
+ else
+ { us = NIL(uchar*);
+ goto done;
+ }
+ }
+
+ /* now copy data */
+ s = us+un;
+ un += n;
+ ends = f->next;
+ f->next += n;
+ MEMCPY(s,ends,n);
+ }
+
+done:
+ _Sfi = f->val = un;
+ f->getr = 0;
+ if(found && rc != 0 && (type&SF_STRING) )
+ { us[un-1] = '\0';
+ if(us >= f->data && us < f->endb)
+ { f->getr = rc;
+ f->mode |= SF_GETR;
+ }
+ }
+
+ /* prepare for a call to get the broken record */
+ if(rsrv)
+ rsrv->slen = found ? 0 : -un;
+
+ SFOPEN(f,0);
+
+ if(us && (type&SF_LOCKR) )
+ { f->mode |= SF_PEEK|SF_GETR;
+ f->endr = f->data;
+ }
+
+ SFMTXRETURN(f, (char*)us);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfgetu.c b/usr/src/lib/libast/common/sfio/sfgetu.c
new file mode 100644
index 0000000000..788ac2965c
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfgetu.c
@@ -0,0 +1,66 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Read an unsigned long value coded in a portable format.
+**
+** Written by Kiem-Phong Vo
+*/
+
+#if __STD_C
+Sfulong_t sfgetu(reg Sfio_t* f)
+#else
+Sfulong_t sfgetu(f)
+reg Sfio_t* f;
+#endif
+{
+ Sfulong_t v;
+ reg uchar *s, *ends, c;
+ reg int p;
+
+ SFMTXSTART(f, (Sfulong_t)(-1));
+
+ if(f->mode != SF_READ && _sfmode(f,SF_READ,0) < 0)
+ SFMTXRETURN(f, (Sfulong_t)(-1));
+
+ SFLOCK(f,0);
+
+ for(v = 0;;)
+ { if(SFRPEEK(f,s,p) <= 0)
+ { f->flags |= SF_ERROR;
+ v = (Sfulong_t)(-1);
+ goto done;
+ }
+ for(ends = s+p; s < ends;)
+ { c = *s++;
+ v = (v << SF_UBITS) | SFUVALUE(c);
+ if(!(c&SF_MORE))
+ { f->next = s;
+ goto done;
+ }
+ }
+ f->next = s;
+ }
+done:
+ SFOPEN(f,0);
+ SFMTXRETURN(f, v);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfhdr.h b/usr/src/lib/libast/common/sfio/sfhdr.h
new file mode 100644
index 0000000000..9d2a121865
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfhdr.h
@@ -0,0 +1,1257 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _SFHDR_H
+#define _SFHDR_H 1
+#if !defined(_BLD_sfio) && !defined(_BLD_stdio)
+#define _BLD_sfio 1
+#endif
+
+/* Internal definitions for sfio.
+** Written by Kiem-Phong Vo
+*/
+
+#define _next next
+#define _endw endw
+#define _endr endr
+#define _endb endb
+#define _push push
+#define _flags flags
+#define _file file
+#define _data data
+#define _size size
+#define _val val
+
+#include "FEATURE/sfio"
+#include "FEATURE/mmap"
+
+/* define va_list, etc. before including sfio_t.h (sfio.h) */
+#if !_PACKAGE_ast
+
+/* some systems don't know large files */
+#if defined(_NO_LARGEFILE64_SOURCE) || _mips == 2 /* || __hppa */
+#undef _NO_LARGEFILE64_SOURCE
+#define _NO_LARGEFILE64_SOURCE 1
+#undef _LARGEFILE64_SOURCE
+#undef _LARGEFILE_SOURCE
+#endif
+
+#if !_NO_LARGEFILE64_SOURCE && _typ_off64_t && _lib_lseek64 && _lib_stat64
+#undef _LARGEFILE64_SOURCE
+#undef _LARGEFILE_SOURCE
+#undef _FILE_OFFSET_BITS
+#define _LARGEFILE64_SOURCE 1 /* enabling the *64 stuff */
+#define _LARGEFILE_SOURCE 1
+#endif
+
+#if _hdr_stdarg
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#include "FEATURE/common"
+#if !__STD_C
+#define const
+#endif
+#endif /* !_PACKAGE_ast */
+
+#include "sfio_t.h"
+
+/* note that the macro vt_threaded has effect on vthread.h */
+#include <vthread.h>
+
+/* file system info */
+#if _PACKAGE_ast
+
+#include <ast.h>
+#include <ast_time.h>
+#include <ast_tty.h>
+#include <ls.h>
+
+/* ast always provides multibyte handling */
+#undef _hdr_wchar
+#undef _lib_mbrtowc
+#undef _lib_wcrtomb
+#define _hdr_wchar 1
+#define _lib_mbrtowc 1
+#define _lib_wcrtomb 1
+
+#if _mem_st_blksize_stat
+#define _stat_blksize 1
+#endif
+
+#if _lib_localeconv && _hdr_locale
+#define _lib_locale 1
+#endif
+
+#define sfoff_t off_t
+#define sfstat_t struct stat
+#define sysclosef close
+#define syscreatf creat
+#define sysdupf dup
+#define sysfcntlf fcntl
+#define sysfstatf fstat
+#define sysftruncatef ftruncate
+#define syslseekf lseek
+#define sysmmapf mmap
+#define sysmunmapf munmap
+#define sysopenf open
+#define syspipef pipe
+#define sysreadf read
+#define sysremovef remove
+#define sysstatf stat
+#define syswritef write
+
+#else /*!_PACKAGE_ast*/
+
+/* when building the binary compatibility package, a number of header files
+ are not needed and they may get in the way so we remove them here.
+*/
+#if _SFBINARY_H
+#undef _hdr_time
+#undef _sys_time
+#undef _sys_stat
+#undef _hdr_stat
+#undef _hdr_filio
+#undef _sys_filio
+#undef _lib_poll
+#undef _stream_peek
+#undef _socket_peek
+#undef _hdr_vfork
+#undef _sys_vfork
+#undef _lib_vfork
+#undef _hdr_values
+#undef _hdr_math
+#undef _sys_mman
+#undef _hdr_mman
+#undef _sys_ioctl
+#endif
+
+#if _hdr_stdlib
+#include <stdlib.h>
+#endif
+
+#if _hdr_string
+#include <string.h>
+#endif
+
+#if _hdr_time
+#include <time.h>
+#endif
+#if _sys_time
+#include <sys/time.h>
+#endif
+
+#if _sys_stat
+#include <sys/stat.h>
+#else
+#if _hdr_stat
+#include <stat.h>
+#ifndef _sys_stat
+#define _sys_stat 1
+#endif
+#endif
+#endif /*_sys_stat*/
+
+#ifndef _sys_stat
+#define _sys_stat 0
+#endif
+
+#include <fcntl.h>
+
+#ifndef F_SETFD
+#ifndef FIOCLEX
+#if _hdr_filio
+#include <filio.h>
+#else
+#if _sys_filio
+#include <sys/filio.h>
+#endif /*_sys_filio*/
+#endif /*_hdr_filio*/
+#endif /*_FIOCLEX*/
+#endif /*F_SETFD*/
+
+#if _hdr_unistd
+#include <unistd.h>
+#endif
+
+#if !_LARGEFILE64_SOURCE /* turn off the *64 stuff */
+#undef _typ_off64_t
+#undef _typ_struct_stat64
+#undef _lib_creat64
+#undef _lib_open64
+#undef _lib_close64
+#undef _lib_stat64
+#undef _lib_fstat64
+#undef _lib_ftruncate64
+#undef _lib_lseek64
+#undef _lib_mmap64
+#undef _lib_munmap64
+#endif /*!_LARGEFILE64_SOURCE */
+
+/* see if we can use memory mapping for io */
+#if _LARGEFILE64_SOURCE && !_lib_mmap64
+#undef _mmap_worthy
+#endif
+#if !_mmap_worthy
+#undef _hdr_mman
+#undef _sys_mman
+#endif
+#if _hdr_mman
+#include <mman.h>
+#endif
+#if _sys_mman
+#include <sys/mman.h>
+#endif
+
+/* standardize system calls and types dealing with files */
+#if _typ_off64_t
+#define sfoff_t off64_t
+#else
+#define sfoff_t off_t
+#endif
+#if _typ_struct_stat64
+#define sfstat_t struct stat64
+#else
+#define sfstat_t struct stat
+#endif
+#if _lib_lseek64
+#define syslseekf lseek64
+#else
+#define syslseekf lseek
+#endif
+#if _lib_stat64
+#define sysstatf stat64
+#else
+#define sysstatf stat
+#endif
+#if _lib_fstat64
+#define sysfstatf fstat64
+#else
+#define sysfstatf fstat
+#endif
+#if _lib_mmap64
+#define sysmmapf mmap64
+#else
+#define sysmmapf mmap
+#endif
+#if _lib_munmap64
+#define sysmunmapf munmap64
+#else
+#define sysmunmapf munmap
+#endif
+#if _lib_open64
+#define sysopenf open64
+#else
+#define sysopenf open
+#endif
+#if _lib_creat64
+#define syscreatf creat64
+#else
+#define syscreatf creat
+#endif
+#if _lib_close64
+#define sysclosef close64
+#else
+#define sysclosef close
+#endif
+#if _lib_ftruncate64
+#undef _lib_ftruncate
+#define _lib_ftruncate 1
+#define sysftruncatef ftruncate64
+#endif
+#if !_lib_ftruncate64 && _lib_ftruncate
+#define sysftruncatef ftruncate
+#endif
+#if _lib_remove
+#define sysremovef remove
+#else
+#define sysremovef unlink
+#endif
+
+#define sysreadf read
+#define syswritef write
+#define syspipef pipe
+#define sysdupf dup
+#define sysfcntlf fcntl
+
+#endif /*_PACKAGE_ast*/
+
+#if !_mmap_worthy
+#undef MAP_TYPE
+#endif
+
+#include "FEATURE/float"
+
+#include <errno.h>
+#include <ctype.h>
+
+/* deal with multi-byte character and string conversions */
+#if _PACKAGE_ast
+
+#include <wchar.h>
+
+#define _has_multibyte 1
+
+#define SFMBMAX mbmax()
+#define SFMBCPY(to,fr) memcpy((to), (fr), sizeof(mbstate_t))
+#define SFMBCLR(mb) memset((mb), 0, sizeof(mbstate_t))
+#define SFMBSET(lhs,v) (lhs = (v))
+#define SFMBLEN(s,mb) mbsize(s)
+#define SFMBDCL(ms) mbstate_t ms;
+
+#else
+
+#if _hdr_wchar && _typ_mbstate_t && _lib_wcrtomb && _lib_mbrtowc
+#define _has_multibyte 1 /* Xopen-compliant */
+#include <wchar.h>
+#define SFMBCPY(to,fr) memcpy((to), (fr), sizeof(mbstate_t))
+#define SFMBCLR(mb) memset((mb), 0, sizeof(mbstate_t))
+#define SFMBSET(lhs,v) (lhs = (v))
+#define SFMBDCL(mb) mbstate_t mb;
+#define SFMBLEN(s,mb) mbrtowc(NIL(wchar_t*), (s), SFMBMAX, (mb) )
+#endif /*_hdr_wchar && _typ_mbstate_t && _lib_wcrtomb && _lib_mbrtowc*/
+
+#if !_has_multibyte && _hdr_wchar && _lib_mbtowc && _lib_wctomb
+#define _has_multibyte 2 /* no shift states */
+#include <wchar.h>
+#undef mbrtowc
+#define mbrtowc(wp,s,n,mb) mbtowc(wp, s, n)
+#undef wcrtomb
+#define wcrtomb(s,wc,mb) wctomb(s, wc)
+#define SFMBCPY(to,fr)
+#define SFMBCLR(mb)
+#define SFMBSET(lhs,v)
+#define SFMBDCL(mb)
+#define SFMBLEN(s,mb) mbrtowc(NIL(wchar_t*), (s), SFMBMAX, (mb) )
+#endif /*!_has_multibyte && _hdr_wchar && _lib_mbtowc && _lib_wctomb*/
+
+#ifdef MB_CUR_MAX
+#define SFMBMAX MB_CUR_MAX
+#else
+#define SFMBMAX sizeof(Sflong_t)
+#endif
+
+#endif /* _PACKAGE_ast */
+
+#if !_has_multibyte
+#define _has_multibyte 0 /* no multibyte support */
+#define SFMBCPY(to,fr)
+#define SFMBCLR(mb)
+#define SFMBSET(lhs,v)
+#define SFMBLEN(s,mb) (*(s) ? 1 : 0)
+#define SFMBDCL(mb)
+#endif /* _has_multibyte */
+
+#if vt_threaded
+
+/* initialization */
+#define SFONCE() (_Sfdone ? 0 : vtonce(_Sfonce,_Sfoncef))
+
+/* to lock/unlock a stream on entering and returning from some function */
+#define SFMTXLOCK(f) (((f)->flags&SF_MTSAFE) ? sfmutex(f,SFMTX_LOCK) : 0)
+#define SFMTXUNLOCK(f) (((f)->flags&SF_MTSAFE) ? sfmutex(f,SFMTX_UNLOCK) : 0)
+#define SFMTXSTART(f,v) { if(!f || SFMTXLOCK(f) != 0) return(v); }
+#define SFMTXRETURN(f,v) { SFMTXUNLOCK(f); return(v); }
+
+/* start and end critical region for a pool */
+#define POOLMTXLOCK(p) ( vtmtxlock(&(p)->mutex) )
+#define POOLMTXUNLOCK(p) ( vtmtxunlock(&(p)->mutex) )
+#define POOLMTXSTART(p) { POOLMTXLOCK(p); }
+#define POOLMTXRETURN(p,v) { POOLMTXUNLOCK(p); return(v); }
+
+#else /*!vt_threaded*/
+
+#undef SF_MTSAFE /* no need to worry about thread-safety */
+#define SF_MTSAFE 0
+
+#define SFONCE() /*(0)*/
+
+#define SFMTXLOCK(f) /*(0)*/
+#define SFMTXUNLOCK(f) /*(0)*/
+#define SFMTXSTART(f,v) { if(!f) return(v); }
+#define SFMTXRETURN(f,v) { return(v); }
+
+#define POOLMTXLOCK(p)
+#define POOLMTXUNLOCK(p)
+#define POOLMTXSTART(p)
+#define POOLMTXRETURN(p,v) { return(v); }
+
+#endif /*vt_threaded*/
+
+
+/* functions for polling readiness of streams */
+#if _lib_select
+#undef _lib_poll
+#else
+#if _lib_poll_fd_1 || _lib_poll_fd_2
+#define _lib_poll 1
+#endif
+#endif /*_lib_select_*/
+
+#if _lib_poll
+#include <poll.h>
+
+#if _lib_poll_fd_1
+#define SFPOLL(pfd,n,tm) poll((pfd),(ulong)(n),(tm))
+#else
+#define SFPOLL(pfd,n,tm) poll((ulong)(n),(pfd),(tm))
+#endif
+#endif /*_lib_poll*/
+
+#if _stream_peek
+#include <stropts.h>
+#endif
+
+#if _socket_peek
+#include <sys/socket.h>
+#endif
+
+/* to test for executable access mode of a file */
+#ifndef X_OK
+#define X_OK 01
+#endif
+
+/* alternative process forking */
+#if _lib_vfork && !defined(fork) && !defined(sparc) && !defined(__sparc)
+#if _hdr_vfork
+#include <vfork.h>
+#endif
+#if _sys_vfork
+#include <sys/vfork.h>
+#endif
+#define fork vfork
+#endif
+
+/* to get rid of pesky compiler warnings */
+#if __STD_C
+#define NOTUSED(x) (void)(x)
+#else
+#define NOTUSED(x) (&x,1)
+#endif
+
+/* Private flags in the "bits" field */
+#define SF_MMAP 00000001 /* in memory mapping mode */
+#define SF_BOTH 00000002 /* both read/write */
+#define SF_HOLE 00000004 /* a hole of zero's was created */
+#define SF_NULL 00000010 /* stream is /dev/null */
+#define SF_SEQUENTIAL 00000020 /* sequential access */
+#define SF_JUSTSEEK 00000040 /* just did a sfseek */
+#define SF_PRIVATE 00000100 /* private stream to Sfio, no mutex */
+#define SF_ENDING 00000200 /* no re-io on interrupts at closing */
+#define SF_WIDE 00000400 /* in wide mode - stdio only */
+
+/* "bits" flags that must be cleared in sfclrlock */
+#define SF_TMPBITS 00170000
+#define SF_DCDOWN 00010000 /* recurse down the discipline stack */
+
+#define SF_WCFORMAT 00020000 /* wchar_t formatting - stdio only */
+#if _has_multibyte
+#define SFWCSET(f) ((f)->bits |= SF_WCFORMAT)
+#define SFWCGET(f,v) (((v) = (f)->bits & SF_WCFORMAT), ((f)->bits &= ~SF_WCFORMAT) )
+#else
+#define SFWCSET(f)
+#define SFWCGET(f,v)
+#endif
+
+#define SF_MVSIZE 00040000 /* f->size was reset in sfmove() */
+#define SFMVSET(f) (((f)->size *= SF_NMAP), ((f)->bits |= SF_MVSIZE) )
+#define SFMVUNSET(f) (!((f)->bits&SF_MVSIZE) ? 0 : \
+ (((f)->bits &= ~SF_MVSIZE), ((f)->size /= SF_NMAP)) )
+
+#define SFCLRBITS(f) (SFMVUNSET(f), ((f)->bits &= ~SF_TMPBITS) )
+
+
+/* bits for the mode field, SF_INIT defined in sfio_t.h */
+#define SF_RC 00000010 /* peeking for a record */
+#define SF_RV 00000020 /* reserve without read or most write */
+#define SF_LOCK 00000040 /* stream is locked for io op */
+#define SF_PUSH 00000100 /* stream has been pushed */
+#define SF_POOL 00000200 /* stream is in a pool but not current */
+#define SF_PEEK 00000400 /* there is a pending peek */
+#define SF_PKRD 00001000 /* did a peek read */
+#define SF_GETR 00002000 /* did a getr on this stream */
+#define SF_SYNCED 00004000 /* stream was synced */
+#define SF_STDIO 00010000 /* given up the buffer to stdio */
+#define SF_AVAIL 00020000 /* was closed, available for reuse */
+#define SF_LOCAL 00100000 /* sentinel for a local call */
+
+#ifdef DEBUG
+#define ASSERT(p) ((p) ? 0 : (abort(),0) )
+#else
+#define ASSERT(p)
+#endif
+
+/* short-hands */
+#define NIL(t) ((t)0)
+#define reg register
+#ifndef uchar
+#define uchar unsigned char
+#endif
+#ifndef ulong
+#define ulong unsigned long
+#endif
+#ifndef uint
+#define uint unsigned int
+#endif
+#ifndef ushort
+#define ushort unsigned short
+#endif
+
+#define SECOND 1000 /* millisecond units */
+
+/* macros do determine stream types from sfstat_t data */
+#ifndef S_IFMT
+#define S_IFMT 0
+#endif
+#ifndef S_IFDIR
+#define S_IFDIR 0
+#endif
+#ifndef S_IFREG
+#define S_IFREG 0
+#endif
+#ifndef S_IFCHR
+#define S_IFCHR 0
+#endif
+#ifndef S_IFIFO
+#define S_IFIFO 0
+#endif
+
+#ifndef S_ISDIR
+#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
+#endif
+#ifndef S_ISREG
+#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
+#endif
+#ifndef S_ISCHR
+#define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR)
+#endif
+
+#ifndef S_ISFIFO
+# ifdef S_IFIFO
+# define S_ISFIFO(m) (((m)&S_IFIFO) == S_IFIFO)
+# else
+# define S_ISFIFO(m) (0)
+# endif
+#endif
+
+#ifdef S_IRUSR
+#define SF_CREATMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
+#else
+#define SF_CREATMODE 0666
+#endif
+
+/* set close-on-exec */
+#ifdef F_SETFD
+# ifndef FD_CLOEXEC
+# define FD_CLOEXEC 1
+# endif /*FD_CLOEXEC*/
+# define SETCLOEXEC(fd) ((void)fcntl((fd),F_SETFD,FD_CLOEXEC))
+#else
+# ifdef FIOCLEX
+# define SETCLOEXEC(fd) ((void)ioctl((fd),FIOCLEX,0))
+# else
+# define SETCLOEXEC(fd)
+# endif /*FIOCLEX*/
+#endif /*F_SETFD*/
+
+/* a couple of error number that we use, default values are like Linux */
+#ifndef EINTR
+#define EINTR 4
+#endif
+#ifndef EBADF
+#define EBADF 9
+#endif
+#ifndef EAGAIN
+#define EAGAIN 11
+#endif
+#ifndef ENOMEM
+#define ENOMEM 12
+#endif
+#ifndef EINVAL
+#define EINVAL 22
+#endif
+#ifndef ESPIPE
+#define ESPIPE 29
+#endif
+
+/* function to get the decimal point for local environment */
+#if !defined(SFSETLOCALE) && _PACKAGE_ast
+#include "lclib.h"
+#define SFSETLOCALE(dp,tp) \
+ do if (*(dp) == 0) { \
+ Lc_numeric_t* lv = (Lc_numeric_t*)LCINFO(AST_LC_NUMERIC)->data; \
+ *(dp) = lv->decimal; \
+ if (tp) *(tp) = lv->thousand; \
+ } while (0)
+#endif /*!defined(SFSETLOCALE) && _PACKAGE_ast*/
+
+#if !defined(SFSETLOCALE) && _lib_locale
+#include <locale.h>
+#define SFSETLOCALE(decimal,thousand) \
+ do { struct lconv* lv; \
+ if(*(decimal) == 0) \
+ { *(decimal) = '.'; \
+ if (thousand) *(thousand) = -1; \
+ if((lv = localeconv())) \
+ { if(lv->decimal_point && *lv->decimal_point) \
+ *(decimal) = *(unsigned char*)lv->decimal_point; \
+ if(thousand && lv->thousands_sep && *lv->thousands_sep) \
+ *(thousand) = *(unsigned char*)lv->thousands_sep; \
+ } \
+ } \
+ } while (0)
+#endif /*!defined(SFSETLOCALE) && _lib_locale*/
+
+#if !defined(SFSETLOCALE)
+#define SFSETLOCALE(decimal,thousand) (*(decimal)='.')
+#endif
+
+/* stream pool structure. */
+typedef struct _sfpool_s Sfpool_t;
+struct _sfpool_s
+{ Sfpool_t* next;
+ int mode; /* type of pool */
+ int s_sf; /* size of pool array */
+ int n_sf; /* number currently in pool */
+ Sfio_t** sf; /* array of streams */
+ Sfio_t* array[3]; /* start with 3 */
+ Vtmutex_t mutex; /* mutex lock object */
+};
+
+/* reserve buffer structure */
+typedef struct _sfrsrv_s Sfrsrv_t;
+struct _sfrsrv_s
+{ ssize_t slen; /* last string length */
+ ssize_t size; /* buffer size */
+ uchar data[1]; /* data buffer */
+};
+
+/* co-process structure */
+typedef struct _sfproc_s Sfproc_t;
+struct _sfproc_s
+{ int pid; /* process id */
+ uchar* rdata; /* read data being cached */
+ int ndata; /* size of cached data */
+ int size; /* buffer size */
+ int file; /* saved file descriptor */
+ int sigp; /* sigpipe protection needed */
+};
+
+/* extensions to sfvprintf/sfvscanf */
+#define FP_SET(fp,fn) (fp < 0 ? (fn += 1) : (fn = fp) )
+#define FP_WIDTH 0
+#define FP_PRECIS 1
+#define FP_BASE 2
+#define FP_STR 3
+#define FP_SIZE 4
+#define FP_INDEX 5 /* index size */
+
+typedef struct _fmt_s Fmt_t;
+typedef struct _fmtpos_s Fmtpos_t;
+typedef union
+{ int i, *ip;
+ long l, *lp;
+ short h, *hp;
+ uint ui;
+ ulong ul;
+ ushort uh;
+ Sflong_t ll, *llp;
+ Sfulong_t lu;
+ Sfdouble_t ld;
+ double d;
+ float f;
+#if _has_multibyte
+ wchar_t wc;
+ wchar_t *ws, **wsp;
+#endif
+ char c, *s, **sp;
+ uchar uc, *us, **usp;
+ Void_t *vp;
+ Sffmt_t *ft;
+} Argv_t;
+
+struct _fmt_s
+{ char* form; /* format string */
+ va_list args; /* corresponding arglist */
+ SFMBDCL(mbs) /* multibyte parsing state */
+
+ char* oform; /* original format string */
+ va_list oargs; /* original arg list */
+ int argn; /* number of args already used */
+ Fmtpos_t* fp; /* position list */
+
+ Sffmt_t* ft; /* formatting environment */
+ Sffmtevent_f eventf; /* event function */
+ Fmt_t* next; /* stack frame pointer */
+};
+
+struct _fmtpos_s
+{ Sffmt_t ft; /* environment */
+ Argv_t argv; /* argument value */
+ int fmt; /* original format */
+ int need[FP_INDEX]; /* positions depending on */
+};
+
+#define LEFTP '('
+#define RIGHTP ')'
+#define QUOTE '\''
+
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+
+#define FMTSET(ft, frm,ags, fv, sz, flgs, wid,pr,bs, ts,ns) \
+ ((ft->form = (char*)frm), va_copy(ft->args,ags), \
+ (ft->fmt = fv), (ft->size = sz), \
+ (ft->flags = (flgs&SFFMT_SET)), \
+ (ft->width = wid), (ft->precis = pr), (ft->base = bs), \
+ (ft->t_str = ts), (ft->n_str = ns) )
+#define FMTGET(ft, frm,ags, fv, sz, flgs, wid,pr,bs) \
+ ((frm = ft->form), va_copy(ags,ft->args), \
+ (fv = ft->fmt), (sz = ft->size), \
+ (flgs = (flgs&~(SFFMT_SET))|(ft->flags&SFFMT_SET)), \
+ (wid = ft->width), (pr = ft->precis), (bs = ft->base) )
+
+/* format flags&types, must coexist with those in sfio.h */
+#define SFFMT_FORBIDDEN 000077777777 /* for sfio.h only */
+#define SFFMT_EFORMAT 001000000000 /* sfcvt converting %e */
+#define SFFMT_MINUS 002000000000 /* minus sign */
+#define SFFMT_AFORMAT 004000000000 /* sfcvt converting %a */
+#define SFFMT_UPPER 010000000000 /* sfcvt converting upper */
+
+#define SFFMT_TYPES (SFFMT_SHORT|SFFMT_SSHORT | SFFMT_LONG|SFFMT_LLONG|\
+ SFFMT_LDOUBLE | SFFMT_IFLAG|SFFMT_JFLAG| \
+ SFFMT_TFLAG | SFFMT_ZFLAG )
+
+/* type of elements to be converted */
+#define SFFMT_INT 001 /* %d,%i */
+#define SFFMT_UINT 002 /* %u,o,x etc. */
+#define SFFMT_FLOAT 004 /* %f,e,g etc. */
+#define SFFMT_CHAR 010 /* %c,C */
+#define SFFMT_POINTER 020 /* %p,n,s,S */
+#define SFFMT_CLASS 040 /* %[ */
+
+/* local variables used across sf-functions */
+#define _Sfpage (_Sfextern.sf_page)
+#define _Sfpool (_Sfextern.sf_pool)
+#define _Sfpmove (_Sfextern.sf_pmove)
+#define _Sfstack (_Sfextern.sf_stack)
+#define _Sfnotify (_Sfextern.sf_notify)
+#define _Sfstdsync (_Sfextern.sf_stdsync)
+#define _Sfudisc (&(_Sfextern.sf_udisc))
+#define _Sfcleanup (_Sfextern.sf_cleanup)
+#define _Sfexiting (_Sfextern.sf_exiting)
+#define _Sfdone (_Sfextern.sf_done)
+#define _Sfonce (_Sfextern.sf_once)
+#define _Sfoncef (_Sfextern.sf_oncef)
+#define _Sfmutex (_Sfextern.sf_mutex)
+typedef struct _sfextern_s
+{ ssize_t sf_page;
+ struct _sfpool_s sf_pool;
+ int (*sf_pmove)_ARG_((Sfio_t*, int));
+ Sfio_t* (*sf_stack)_ARG_((Sfio_t*, Sfio_t*));
+ void (*sf_notify)_ARG_((Sfio_t*, int, int));
+ int (*sf_stdsync)_ARG_((Sfio_t*));
+ struct _sfdisc_s sf_udisc;
+ void (*sf_cleanup)_ARG_((void));
+ int sf_exiting;
+ int sf_done;
+ Vtonce_t* sf_once;
+ void (*sf_oncef)_ARG_((void));
+ Vtmutex_t* sf_mutex;
+} Sfextern_t;
+
+/* get the real value of a byte in a coded long or ulong */
+#define SFUVALUE(v) (((ulong)(v))&(SF_MORE-1))
+#define SFSVALUE(v) ((( long)(v))&(SF_SIGN-1))
+#define SFBVALUE(v) (((ulong)(v))&(SF_BYTE-1))
+
+/* pick this many bits in each iteration of double encoding */
+#define SF_PRECIS 7
+
+/* grain size for buffer increment */
+#define SF_GRAIN 1024
+#define SF_PAGE ((ssize_t)(SF_GRAIN*sizeof(int)*2))
+
+/* when the buffer is empty, certain io requests may be better done directly
+ on the given application buffers. The below condition determines when.
+*/
+#define SFDIRECT(f,n) (((ssize_t)(n) >= (f)->size) || \
+ ((n) >= SF_GRAIN && (ssize_t)(n) >= (f)->size/16 ) )
+
+/* number of pages to memory map at a time */
+#define SF_NMAP 4
+
+#ifndef MAP_VARIABLE
+#define MAP_VARIABLE 0
+#endif
+#ifndef _mmap_fixed
+#define _mmap_fixed 0
+#endif
+
+/* set/unset sequential states for mmap */
+#if _lib_madvise && defined(MADV_SEQUENTIAL) && defined(MADV_NORMAL)
+#define SFMMSEQON(f,a,s) \
+ do { int oerrno = errno; \
+ (void)madvise((caddr_t)(a),(size_t)(s),MADV_SEQUENTIAL); \
+ errno = oerrno; \
+ } while(0)
+#define SFMMSEQOFF(f,a,s) \
+ do { int oerrno = errno; \
+ (void)madvise((caddr_t)(a),(size_t)(s),MADV_NORMAL); \
+ errno = oerrno; \
+ } while(0)
+#else
+#define SFMMSEQON(f,a,s)
+#define SFMMSEQOFF(f,a,s)
+#endif
+
+#define SFMUNMAP(f,a,s) (sysmunmapf((caddr_t)(a),(size_t)(s)), \
+ ((f)->endb = (f)->endr = (f)->endw = (f)->next = \
+ (f)->data = NIL(uchar*)) )
+
+/* safe closing function */
+#define CLOSE(f) { while(sysclosef(f) < 0 && errno == EINTR) errno = 0; }
+
+/* the bottomless bit bucket */
+#define DEVNULL "/dev/null"
+#define SFSETNULL(f) ((f)->extent = (Sfoff_t)(-1), (f)->bits |= SF_NULL)
+#define SFISNULL(f) ((f)->extent < 0 && ((f)->bits&SF_NULL) )
+
+#define SFKILL(f) ((f)->mode = (SF_AVAIL|SF_LOCK) )
+#define SFKILLED(f) (((f)->mode&(SF_AVAIL|SF_LOCK)) == (SF_AVAIL|SF_LOCK) )
+
+/* exception types */
+#define SF_EDONE 0 /* stop this operation and return */
+#define SF_EDISC 1 /* discipline says it's ok */
+#define SF_ESTACK 2 /* stack was popped */
+#define SF_ECONT 3 /* can continue normally */
+
+#define SETLOCAL(f) ((f)->mode |= SF_LOCAL)
+#define GETLOCAL(f,v) ((v) = ((f)->mode&SF_LOCAL), (f)->mode &= ~SF_LOCAL, (v))
+#define SFWRALL(f) ((f)->mode |= SF_RV)
+#define SFISALL(f,v) ((((v) = (f)->mode&SF_RV) ? ((f)->mode &= ~SF_RV) : 0), \
+ ((v) || (f)->extent < 0 || \
+ ((f)->flags&(SF_SHARE|SF_APPENDWR|SF_WHOLE)) ) )
+#define SFSK(f,a,o,d) (SETLOCAL(f),sfsk(f,(Sfoff_t)a,o,d))
+#define SFRD(f,b,n,d) (SETLOCAL(f),sfrd(f,(Void_t*)b,n,d))
+#define SFWR(f,b,n,d) (SETLOCAL(f),sfwr(f,(Void_t*)b,n,d))
+#define SFSYNC(f) (SETLOCAL(f),sfsync(f))
+#define SFCLOSE(f) (SETLOCAL(f),sfclose(f))
+#define SFFLSBUF(f,n) (SETLOCAL(f),_sfflsbuf(f,n))
+#define SFFILBUF(f,n) (SETLOCAL(f),_sffilbuf(f,n))
+#define SFSETBUF(f,s,n) (SETLOCAL(f),sfsetbuf(f,s,n))
+#define SFWRITE(f,s,n) (SETLOCAL(f),sfwrite(f,s,n))
+#define SFREAD(f,s,n) (SETLOCAL(f),sfread(f,s,n))
+#define SFSEEK(f,p,t) (SETLOCAL(f),sfseek(f,p,t))
+#define SFNPUTC(f,c,n) (SETLOCAL(f),sfnputc(f,c,n))
+#define SFRAISE(f,e,d) (SETLOCAL(f),sfraise(f,e,d))
+
+/* lock/open a stream */
+#define SFMODE(f,l) ((f)->mode & ~(SF_RV|SF_RC|((l) ? SF_LOCK : 0)) )
+#define SFLOCK(f,l) (void)((f)->mode |= SF_LOCK, (f)->endr = (f)->endw = (f)->data)
+#define _SFOPENRD(f) ((f)->endr = ((f)->flags&SF_MTSAFE) ? (f)->data : (f)->endb)
+#define _SFOPENWR(f) ((f)->endw = ((f)->flags&(SF_MTSAFE|SF_LINE)) ? (f)->data : (f)->endb)
+#define _SFOPEN(f) ((f)->mode == SF_READ ? _SFOPENRD(f) : \
+ (f)->mode == SF_WRITE ? _SFOPENWR(f) : \
+ ((f)->endw = (f)->endr = (f)->data) )
+#define SFOPEN(f,l) (void)((l) ? 0 : \
+ ((f)->mode &= ~(SF_LOCK|SF_RC|SF_RV), _SFOPEN(f), 0) )
+
+/* check to see if the stream can be accessed */
+#define SFFROZEN(f) (((f)->mode&(SF_PUSH|SF_LOCK|SF_PEEK)) ? 1 : \
+ !((f)->mode&SF_STDIO) ? 0 : \
+ _Sfstdsync ? (*_Sfstdsync)(f) : (((f)->mode &= ~SF_STDIO),0) )
+
+
+/* set discipline code */
+#define SFDISC(f,dc,iof) \
+ { Sfdisc_t* d; \
+ if(!(dc)) \
+ d = (dc) = (f)->disc; \
+ else d = (f->bits&SF_DCDOWN) ? ((dc) = (dc)->disc) : (dc); \
+ while(d && !(d->iof)) d = d->disc; \
+ if(d) (dc) = d; \
+ }
+#define SFDCRD(f,buf,n,dc,rv) \
+ { int dcdown = f->bits&SF_DCDOWN; f->bits |= SF_DCDOWN; \
+ rv = (*dc->readf)(f,buf,n,dc); \
+ if(!dcdown) f->bits &= ~SF_DCDOWN; \
+ }
+#define SFDCWR(f,buf,n,dc,rv) \
+ { int dcdown = f->bits&SF_DCDOWN; f->bits |= SF_DCDOWN; \
+ rv = (*dc->writef)(f,buf,n,dc); \
+ if(!dcdown) f->bits &= ~SF_DCDOWN; \
+ }
+#define SFDCSK(f,addr,type,dc,rv) \
+ { int dcdown = f->bits&SF_DCDOWN; f->bits |= SF_DCDOWN; \
+ rv = (*dc->seekf)(f,addr,type,dc); \
+ if(!dcdown) f->bits &= ~SF_DCDOWN; \
+ }
+
+/* fast peek of a stream */
+#define _SFAVAIL(f,s,n) ((n) = (f)->endb - ((s) = (f)->next) )
+#define SFRPEEK(f,s,n) (_SFAVAIL(f,s,n) > 0 ? (n) : \
+ ((n) = SFFILBUF(f,-1), (s) = (f)->next, (n)) )
+#define SFWPEEK(f,s,n) (_SFAVAIL(f,s,n) > 0 ? (n) : \
+ ((n) = SFFLSBUF(f,-1), (s) = (f)->next, (n)) )
+
+/* more than this for a line buffer, we might as well flush */
+#define HIFORLINE 128
+
+/* string stream extent */
+#define SFSTRSIZE(f) { Sfoff_t s = (f)->next - (f)->data; \
+ if(s > (f)->here) \
+ { (f)->here = s; if(s > (f)->extent) (f)->extent = s; } \
+ }
+
+/* control flags for open() */
+#ifdef O_CREAT
+#define _has_oflags 1
+#else /* for example, research UNIX */
+#define _has_oflags 0
+#define O_CREAT 004
+#define O_TRUNC 010
+#define O_APPEND 020
+#define O_EXCL 040
+
+#ifndef O_RDONLY
+#define O_RDONLY 000
+#endif
+#ifndef O_WRONLY
+#define O_WRONLY 001
+#endif
+#ifndef O_RDWR
+#define O_RDWR 002
+#endif
+#endif /*O_CREAT*/
+
+#ifndef O_BINARY
+#define O_BINARY 000
+#endif
+#ifndef O_TEXT
+#define O_TEXT 000
+#endif
+#ifndef O_TEMPORARY
+#define O_TEMPORARY 000
+#endif
+
+#define SF_RADIX 64 /* maximum integer conversion base */
+
+#if _PACKAGE_ast
+#define SF_MAXINT INT_MAX
+#define SF_MAXLONG LONG_MAX
+#else
+#define SF_MAXINT ((int)(((uint)~0) >> 1))
+#define SF_MAXLONG ((long)(((ulong)~0L) >> 1))
+#endif
+
+#define SF_MAXCHAR ((uchar)(~0))
+
+/* floating point to ascii conversion */
+#define SF_MAXEXP10 6
+#define SF_MAXPOW10 (1 << SF_MAXEXP10)
+#if !_ast_fltmax_double
+#define SF_FDIGITS 1024 /* max allowed fractional digits */
+#define SF_IDIGITS (8*1024) /* max number of digits in int part */
+#else
+#define SF_FDIGITS 256 /* max allowed fractional digits */
+#define SF_IDIGITS 1024 /* max number of digits in int part */
+#endif
+#define SF_MAXDIGITS (((SF_FDIGITS+SF_IDIGITS)/sizeof(int) + 1)*sizeof(int))
+
+/* tables for numerical translation */
+#define _Sfpos10 (_Sftable.sf_pos10)
+#define _Sfneg10 (_Sftable.sf_neg10)
+#define _Sfdec (_Sftable.sf_dec)
+#define _Sfdigits (_Sftable.sf_digits)
+#define _Sfcvinitf (_Sftable.sf_cvinitf)
+#define _Sfcvinit (_Sftable.sf_cvinit)
+#define _Sffmtposf (_Sftable.sf_fmtposf)
+#define _Sffmtintf (_Sftable.sf_fmtintf)
+#define _Sfcv36 (_Sftable.sf_cv36)
+#define _Sfcv64 (_Sftable.sf_cv64)
+#define _Sftype (_Sftable.sf_type)
+#define _Sfieee (&_Sftable.sf_ieee)
+#define _Sffinf (_Sftable.sf_ieee.fltinf)
+#define _Sfdinf (_Sftable.sf_ieee.dblinf)
+#define _Sflinf (_Sftable.sf_ieee.ldblinf)
+#define _Sffnan (_Sftable.sf_ieee.fltnan)
+#define _Sfdnan (_Sftable.sf_ieee.dblnan)
+#define _Sflnan (_Sftable.sf_ieee.ldblnan)
+#define _Sffpow10 (_Sftable.sf_flt_pow10)
+#define _Sfdpow10 (_Sftable.sf_dbl_pow10)
+#define _Sflpow10 (_Sftable.sf_ldbl_pow10)
+typedef struct _sfieee_s Sfieee_t;
+struct _sfieee_s
+{ float fltnan; /* float NAN */
+ float fltinf; /* float INF */
+ double dblnan; /* double NAN */
+ double dblinf; /* double INF */
+ Sfdouble_t ldblnan; /* Sfdouble_t NAN */
+ Sfdouble_t ldblinf; /* Sfdouble_t INF */
+};
+typedef struct _sftab_
+{ Sfdouble_t sf_pos10[SF_MAXEXP10]; /* positive powers of 10 */
+ Sfdouble_t sf_neg10[SF_MAXEXP10]; /* negative powers of 10 */
+ uchar sf_dec[200]; /* ascii reps of values < 100 */
+ char* sf_digits; /* digits for general bases */
+ int (*sf_cvinitf)(); /* initialization function */
+ int sf_cvinit; /* initialization state */
+ Fmtpos_t* (*sf_fmtposf)_ARG_((Sfio_t*,const char*,va_list,Sffmt_t*,int));
+ char* (*sf_fmtintf)_ARG_((const char*,int*));
+ float* sf_flt_pow10; /* float powers of 10 */
+ double* sf_dbl_pow10; /* double powers of 10 */
+ Sfdouble_t* sf_ldbl_pow10; /* Sfdouble_t powers of 10 */
+ uchar sf_cv36[SF_MAXCHAR+1]; /* conversion for base [2-36] */
+ uchar sf_cv64[SF_MAXCHAR+1]; /* conversion for base [37-64] */
+ uchar sf_type[SF_MAXCHAR+1]; /* conversion formats&types */
+ Sfieee_t sf_ieee; /* IEEE floating point constants*/
+} Sftab_t;
+
+/* thread-safe macro/function to initialize _Sfcv* conversion tables */
+#define SFCVINIT() (_Sfcvinit ? 1 : (_Sfcvinit = (*_Sfcvinitf)()) )
+
+/* sfucvt() converts decimal integers to ASCII */
+#define SFDIGIT(v,scale,digit) \
+ { if(v < 5*scale) \
+ if(v < 2*scale) \
+ if(v < 1*scale) \
+ { digit = '0'; } \
+ else { digit = '1'; v -= 1*scale; } \
+ else if(v < 3*scale) \
+ { digit = '2'; v -= 2*scale; } \
+ else if(v < 4*scale) \
+ { digit = '3'; v -= 3*scale; } \
+ else { digit = '4'; v -= 4*scale; } \
+ else if(v < 7*scale) \
+ if(v < 6*scale) \
+ { digit = '5'; v -= 5*scale; } \
+ else { digit = '6'; v -= 6*scale; } \
+ else if(v < 8*scale) \
+ { digit = '7'; v -= 7*scale; } \
+ else if(v < 9*scale) \
+ { digit = '8'; v -= 8*scale; } \
+ else { digit = '9'; v -= 9*scale; } \
+ }
+#define sfucvt(v,s,n,list,type,utype) \
+ { while((utype)v >= 10000) \
+ { n = v; v = (type)(((utype)v)/10000); \
+ n = (type)((utype)n - ((utype)v)*10000); \
+ s -= 4; SFDIGIT(n,1000,s[0]); SFDIGIT(n,100,s[1]); \
+ s[2] = *(list = (char*)_Sfdec + (n <<= 1)); s[3] = *(list+1); \
+ } \
+ if(v < 100) \
+ { if(v < 10) \
+ { s -= 1; s[0] = (char)('0'+v); \
+ } else \
+ { s -= 2; s[0] = *(list = (char*)_Sfdec + (v <<= 1)); s[1] = *(list+1); \
+ } \
+ } else \
+ { if(v < 1000) \
+ { s -= 3; SFDIGIT(v,100,s[0]); \
+ s[1] = *(list = (char*)_Sfdec + (v <<= 1)); s[2] = *(list+1); \
+ } else \
+ { s -= 4; SFDIGIT(v,1000,s[0]); SFDIGIT(v,100,s[1]); \
+ s[2] = *(list = (char*)_Sfdec + (v <<= 1)); s[3] = *(list+1); \
+ } \
+ } \
+ }
+
+/* handy functions */
+#undef min
+#undef max
+#define min(x,y) ((x) < (y) ? (x) : (y))
+#define max(x,y) ((x) > (y) ? (x) : (y))
+
+/* fast functions for memory copy and memory clear */
+#if _PACKAGE_ast
+#define memclear(s,n) memzero(s,n)
+#else
+#if _lib_bcopy && !_lib_memcpy
+#define memcpy(to,fr,n) bcopy((fr),(to),(n))
+#endif
+#if _lib_bzero && !_lib_memset
+#define memclear(s,n) bzero((s),(n))
+#else
+#define memclear(s,n) memset((s),'\0',(n))
+#endif
+#endif /*_PACKAGE_ast*/
+
+/* note that MEMCPY advances the associated pointers */
+#define MEMCPY(to,fr,n) \
+ switch(n) \
+ { default : memcpy((Void_t*)to,(Void_t*)fr,n); to += n; fr += n; break; \
+ case 7 : *to++ = *fr++; \
+ case 6 : *to++ = *fr++; \
+ case 5 : *to++ = *fr++; \
+ case 4 : *to++ = *fr++; \
+ case 3 : *to++ = *fr++; \
+ case 2 : *to++ = *fr++; \
+ case 1 : *to++ = *fr++; \
+ }
+#define MEMSET(s,c,n) \
+ switch(n) \
+ { default : memset((Void_t*)s,(int)c,n); s += n; break; \
+ case 7 : *s++ = c; \
+ case 6 : *s++ = c; \
+ case 5 : *s++ = c; \
+ case 4 : *s++ = c; \
+ case 3 : *s++ = c; \
+ case 2 : *s++ = c; \
+ case 1 : *s++ = c; \
+ }
+
+_BEGIN_EXTERNS_
+
+extern Sftab_t _Sftable;
+
+extern int _sfpopen _ARG_((Sfio_t*, int, int, int));
+extern int _sfpclose _ARG_((Sfio_t*));
+extern int _sfexcept _ARG_((Sfio_t*, int, ssize_t, Sfdisc_t*));
+extern Sfrsrv_t* _sfrsrv _ARG_((Sfio_t*, ssize_t));
+extern int _sfsetpool _ARG_((Sfio_t*));
+extern char* _sfcvt _ARG_((Sfdouble_t,char*,size_t,int,int*,int*,int*,int));
+extern char** _sfgetpath _ARG_((char*));
+
+#if _BLD_sfio && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+#if !_BLD_sfio && defined(__IMPORT__)
+#define extern extern __IMPORT__
+#endif
+
+extern Sfextern_t _Sfextern;
+
+extern int _sfmode _ARG_((Sfio_t*, int, int));
+extern int _sftype _ARG_((const char*, int*, int*));
+
+#undef extern
+
+#ifndef errno
+extern int errno;
+#endif
+
+/* for portable encoding of double values */
+#ifndef frexpl
+#if _ast_fltmax_double
+#define frexpl frexp
+#endif
+#if !__STDC__
+extern Sfdouble_t frexpl _ARG_((Sfdouble_t, int*));
+#endif
+#endif
+#ifndef ldexpl
+#if _ast_fltmax_double
+#define ldexpl ldexp
+#endif
+#if !__STDC__
+extern Sfdouble_t ldexpl _ARG_((Sfdouble_t, int));
+#endif
+#endif
+
+#if !_PACKAGE_ast
+
+#if !__STDC__ && !_hdr_stdlib
+extern void abort _ARG_((void));
+extern int atexit _ARG_((void(*)(void)));
+extern char* getenv _ARG_((const char*));
+extern void* malloc _ARG_((size_t));
+extern void* realloc _ARG_((void*, size_t));
+extern void free _ARG_((void*));
+extern size_t strlen _ARG_((const char*));
+extern char* strcpy _ARG_((char*, const char*));
+
+extern Void_t* memset _ARG_((void*, int, size_t));
+extern Void_t* memchr _ARG_((const void*, int, size_t));
+extern Void_t* memccpy _ARG_((void*, const void*, int, size_t));
+#ifndef memcpy
+extern Void_t* memcpy _ARG_((void*, const void*, size_t));
+#endif
+#if !defined(strtod)
+extern double strtod _ARG_((const char*, char**));
+#endif
+#if !defined(remove)
+extern int sysremovef _ARG_((const char*));
+#endif
+#endif /* !__STDC__ && !_hdr_stdlib */
+
+#if !_hdr_unistd
+#if _proto_open && __cplusplus
+extern int sysopenf _ARG_((const char*, int, ...));
+#endif
+extern int sysclosef _ARG_((int));
+extern ssize_t sysreadf _ARG_((int, void*, size_t));
+extern ssize_t syswritef _ARG_((int, const void*, size_t));
+extern sfoff_t syslseekf _ARG_((int, sfoff_t, int));
+extern int sysdupf _ARG_((int));
+extern int syspipef _ARG_((int*));
+extern int sysaccessf _ARG_((const char*, int));
+extern int sysremovef _ARG_((const char*));
+extern int sysfstatf _ARG_((int, sfstat_t*));
+extern int sysstatf _ARG_((const char*, sfstat_t*));
+
+extern int isatty _ARG_((int));
+
+extern int wait _ARG_((int*));
+extern uint sleep _ARG_((uint));
+extern int execl _ARG_((const char*, const char*,...));
+extern int execv _ARG_((const char*, char**));
+#if !defined(fork)
+extern int fork _ARG_((void));
+#endif
+#if _lib_unlink
+extern int unlink _ARG_((const char*));
+#endif
+
+#endif /*_hdr_unistd*/
+
+#if _lib_bcopy && !_proto_bcopy
+extern void bcopy _ARG_((const void*, void*, size_t));
+#endif
+#if _lib_bzero && !_proto_bzero
+extern void bzero _ARG_((void*, size_t));
+#endif
+
+extern time_t time _ARG_((time_t*));
+extern int waitpid _ARG_((int,int*,int));
+extern void _exit _ARG_((int));
+typedef int(* Onexit_f)_ARG_((void));
+extern Onexit_f onexit _ARG_((Onexit_f));
+
+#if _lib_vfork && !_hdr_vfork && !_sys_vfork
+extern pid_t vfork _ARG_((void));
+#endif /*_lib_vfork*/
+
+#if _lib_poll
+#if _lib_poll_fd_1
+extern int poll _ARG_((struct pollfd*, ulong, int));
+#else
+extern int poll _ARG_((ulong, struct pollfd*, int));
+#endif
+#endif /*_lib_poll*/
+
+#endif /* _PACKAGE_ast */
+
+_END_EXTERNS_
+
+#endif /*_SFHDR_H*/
diff --git a/usr/src/lib/libast/common/sfio/sfllen.c b/usr/src/lib/libast/common/sfio/sfllen.c
new file mode 100644
index 0000000000..18087b3de5
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfllen.c
@@ -0,0 +1,39 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Get size of a long value coded in a portable format
+**
+** Written by Kiem-Phong Vo
+*/
+#if __STD_C
+int _sfllen(Sflong_t v)
+#else
+int _sfllen(v)
+Sflong_t v;
+#endif
+{
+ if(v < 0)
+ v = -(v+1);
+ v = (Sfulong_t)v >> SF_SBITS;
+ return 1 + (v > 0 ? sfulen(v) : 0);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfmode.c b/usr/src/lib/libast/common/sfio/sfmode.c
new file mode 100644
index 0000000000..99b920a144
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfmode.c
@@ -0,0 +1,593 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+static char* Version = "\n@(#)$Id: sfio (AT&T Research) 2006-02-07 $\0\n";
+
+/* Functions to set a given stream to some desired mode
+**
+** Written by Kiem-Phong Vo.
+**
+** Modifications:
+** 06/27/1990 (first version)
+** 01/06/1991
+** 07/08/1991
+** 06/18/1992
+** 02/02/1993
+** 05/25/1993
+** 02/07/1994
+** 05/21/1996
+** 08/01/1997
+** 08/01/1998 (extended formatting)
+** 09/09/1999 (thread-safe)
+** 02/01/2001 (adaptive buffering)
+** 05/31/2002 (multi-byte handling in sfvprintf/vscanf)
+** 09/06/2002 (SF_IOINTR flag)
+** 11/15/2002 (%#c for sfvprintf)
+** 05/31/2003 (sfsetbuf(f,f,align_size) to set alignment for data)
+** (%I1d is fixed to handle "signed char" correctly)
+** 01/01/2004 Porting issues to various platforms resolved.
+*/
+
+/* the below is for protecting the application from SIGPIPE */
+#if _PACKAGE_ast
+#include <sig.h>
+#include <wait.h>
+#define Sfsignal_f Sig_handler_t
+#else
+#include <signal.h>
+typedef void(* Sfsignal_f)_ARG_((int));
+#endif
+static int _Sfsigp = 0; /* # of streams needing SIGPIPE protection */
+
+/* done at exiting time */
+#if __STD_C
+static void _sfcleanup(void)
+#else
+static void _sfcleanup()
+#endif
+{
+ reg Sfpool_t* p;
+ reg Sfio_t* f;
+ reg int n;
+ reg int pool;
+
+ f = (Sfio_t*)Version; /* shut compiler warning */
+
+ /* set this so that no more buffering is allowed for write streams */
+ _Sfexiting = 1001;
+
+ sfsync(NIL(Sfio_t*));
+
+ for(p = &_Sfpool; p; p = p->next)
+ { for(n = 0; n < p->n_sf; ++n)
+ { if(!(f = p->sf[n]) || SFFROZEN(f) )
+ continue;
+
+ SFLOCK(f,0);
+ SFMTXLOCK(f);
+
+ /* let application know that we are leaving */
+ (void)SFRAISE(f, SF_ATEXIT, NIL(Void_t*));
+
+ if(f->flags&SF_STRING)
+ continue;
+
+ /* from now on, write streams are unbuffered */
+ pool = f->mode&SF_POOL;
+ f->mode &= ~SF_POOL;
+ if((f->flags&SF_WRITE) && !(f->mode&SF_WRITE))
+ (void)_sfmode(f,SF_WRITE,1);
+ if(((f->bits&SF_MMAP) && f->data) ||
+ ((f->mode&SF_WRITE) && f->next == f->data) )
+ (void)SFSETBUF(f,NIL(Void_t*),0);
+ f->mode |= pool;
+
+ SFMTXUNLOCK(f);
+ SFOPEN(f,0);
+ }
+ }
+}
+
+/* put into discrete pool */
+#if __STD_C
+int _sfsetpool(Sfio_t* f)
+#else
+int _sfsetpool(f)
+Sfio_t* f;
+#endif
+{
+ reg Sfpool_t* p;
+ reg Sfio_t** array;
+ reg int n, rv;
+
+ if(!_Sfcleanup)
+ { _Sfcleanup = _sfcleanup;
+ (void)atexit(_sfcleanup);
+ }
+
+ if(!(p = f->pool) )
+ p = f->pool = &_Sfpool;
+
+ POOLMTXSTART(p);
+
+ rv = -1;
+
+ if(p->n_sf >= p->s_sf)
+ { if(p->s_sf == 0) /* initialize pool array */
+ { p->s_sf = sizeof(p->array)/sizeof(p->array[0]);
+ p->sf = p->array;
+ }
+ else /* allocate a larger array */
+ { n = (p->sf != p->array ? p->s_sf : (p->s_sf/4 + 1)*4) + 4;
+ if(!(array = (Sfio_t**)malloc(n*sizeof(Sfio_t*))) )
+ goto done;
+
+ /* move old array to new one */
+ memcpy((Void_t*)array,(Void_t*)p->sf,p->n_sf*sizeof(Sfio_t*));
+ if(p->sf != p->array)
+ free((Void_t*)p->sf);
+
+ p->sf = array;
+ p->s_sf = n;
+ }
+ }
+
+ /* always add at end of array because if this was done during some sort
+ of walk thru all streams, we'll want the new stream to be seen.
+ */
+ p->sf[p->n_sf++] = f;
+ rv = 0;
+
+done:
+ POOLMTXRETURN(p, rv);
+}
+
+/* create an auxiliary buffer for sfgetr/sfreserve/sfputr */
+#if __STD_C
+Sfrsrv_t* _sfrsrv(reg Sfio_t* f, reg ssize_t size)
+#else
+Sfrsrv_t* _sfrsrv(f,size)
+reg Sfio_t* f;
+reg ssize_t size;
+#endif
+{
+ Sfrsrv_t *rsrv, *rs;
+
+ /* make buffer if nothing yet */
+ size = ((size + SF_GRAIN-1)/SF_GRAIN)*SF_GRAIN;
+ if(!(rsrv = f->rsrv) || size > rsrv->size)
+ { if(!(rs = (Sfrsrv_t*)malloc(size+sizeof(Sfrsrv_t))))
+ size = -1;
+ else
+ { if(rsrv)
+ { if(rsrv->slen > 0)
+ memcpy(rs,rsrv,sizeof(Sfrsrv_t)+rsrv->slen);
+ free(rsrv);
+ }
+ f->rsrv = rsrv = rs;
+ rsrv->size = size;
+ rsrv->slen = 0;
+ }
+ }
+
+ if(rsrv && size > 0)
+ rsrv->slen = 0;
+
+ return size >= 0 ? rsrv : NIL(Sfrsrv_t*);
+}
+
+#ifdef SIGPIPE
+#if __STD_C
+static void ignoresig(int sig)
+#else
+static void ignoresig(sig)
+int sig;
+#endif
+{
+ signal(sig, ignoresig);
+}
+#endif
+
+#if __STD_C
+int _sfpopen(reg Sfio_t* f, int fd, int pid, int stdio)
+#else
+int _sfpopen(f, fd, pid, stdio)
+reg Sfio_t* f;
+int fd;
+int pid;
+int stdio; /* stdio popen() does not reset SIGPIPE handler */
+#endif
+{
+ reg Sfproc_t* p;
+
+ if(f->proc)
+ return 0;
+
+ if(!(p = f->proc = (Sfproc_t*)malloc(sizeof(Sfproc_t))) )
+ return -1;
+
+ p->pid = pid;
+ p->size = p->ndata = 0;
+ p->rdata = NIL(uchar*);
+ p->file = fd;
+ p->sigp = (!stdio && pid >= 0 && (f->flags&SF_WRITE)) ? 1 : 0;
+
+#ifdef SIGPIPE /* protect from broken pipe signal */
+ if(p->sigp)
+ { Sfsignal_f handler;
+
+ (void)vtmtxlock(_Sfmutex);
+ if((handler = signal(SIGPIPE, ignoresig)) != SIG_DFL &&
+ handler != ignoresig)
+ signal(SIGPIPE, handler); /* honor user handler */
+ _Sfsigp += 1;
+ (void)vtmtxunlock(_Sfmutex);
+ }
+#endif
+
+ return 0;
+}
+
+#if __STD_C
+int _sfpclose(reg Sfio_t* f)
+#else
+int _sfpclose(f)
+reg Sfio_t* f; /* stream to close */
+#endif
+{
+ Sfproc_t* p;
+ int pid, status;
+
+ if(!(p = f->proc))
+ return -1;
+ f->proc = NIL(Sfproc_t*);
+
+ if(p->rdata)
+ free(p->rdata);
+
+ if(p->pid < 0)
+ status = 0;
+ else
+ { /* close the associated stream */
+ if(p->file >= 0)
+ CLOSE(p->file);
+
+ /* wait for process termination */
+#if _PACKAGE_ast
+ sigcritical(SIG_REG_EXEC|SIG_REG_PROC);
+#endif
+ while ((pid = waitpid(p->pid,&status,0)) == -1 && errno == EINTR)
+ ;
+ if(pid == -1)
+ status = -1;
+#if _PACKAGE_ast
+ sigcritical(0);
+#endif
+
+#ifdef SIGPIPE
+ (void)vtmtxlock(_Sfmutex);
+ if(p->sigp && (_Sfsigp -= 1) <= 0)
+ { Sfsignal_f handler;
+ if((handler = signal(SIGPIPE,SIG_DFL)) != SIG_DFL &&
+ handler != ignoresig)
+ signal(SIGPIPE,handler); /* honor user handler */
+ _Sfsigp = 0;
+ }
+ (void)vtmtxunlock(_Sfmutex);
+#endif
+ }
+
+ free(p);
+ return status;
+}
+
+#if __STD_C
+static int _sfpmode(Sfio_t* f, int type)
+#else
+static int _sfpmode(f,type)
+Sfio_t* f;
+int type;
+#endif
+{
+ Sfproc_t* p;
+
+ if(!(p = f->proc) )
+ return -1;
+
+ if(type == SF_WRITE)
+ { /* save unread data */
+ p->ndata = f->endb-f->next;
+ if(p->ndata > p->size)
+ { if(p->rdata)
+ free((char*)p->rdata);
+ if((p->rdata = (uchar*)malloc(p->ndata)) )
+ p->size = p->ndata;
+ else
+ { p->size = 0;
+ return -1;
+ }
+ }
+ if(p->ndata > 0)
+ memcpy((Void_t*)p->rdata,(Void_t*)f->next,p->ndata);
+ f->endb = f->data;
+ }
+ else
+ { /* restore read data */
+ if(p->ndata > f->size) /* may lose data!!! */
+ p->ndata = f->size;
+ if(p->ndata > 0)
+ { memcpy((Void_t*)f->data,(Void_t*)p->rdata,p->ndata);
+ f->endb = f->data+p->ndata;
+ p->ndata = 0;
+ }
+ }
+
+ /* switch file descriptor */
+ if(p->pid >= 0)
+ { type = f->file;
+ f->file = p->file;
+ p->file = type;
+ }
+
+ return 0;
+}
+
+#if __STD_C
+int _sfmode(reg Sfio_t* f, reg int wanted, reg int local)
+#else
+int _sfmode(f, wanted, local)
+reg Sfio_t* f; /* change r/w mode and sync file pointer for this stream */
+reg int wanted; /* desired mode */
+reg int local; /* a local call */
+#endif
+{
+ reg int n;
+ Sfoff_t addr;
+ reg int rv = 0;
+
+ SFONCE(); /* initialize mutexes */
+
+ if(wanted&SF_SYNCED) /* for (SF_SYNCED|SF_READ) stream, just junk data */
+ { wanted &= ~SF_SYNCED;
+ if((f->mode&(SF_SYNCED|SF_READ)) == (SF_SYNCED|SF_READ) )
+ { f->next = f->endb = f->endr = f->data;
+ f->mode &= ~SF_SYNCED;
+ }
+ }
+
+ if((!local && SFFROZEN(f)) || (!(f->flags&SF_STRING) && f->file < 0))
+ { if(local || !f->disc || !f->disc->exceptf)
+ { local = 1;
+ goto err_notify;
+ }
+
+ for(;;)
+ { if((rv = (*f->disc->exceptf)(f,SF_LOCKED,0,f->disc)) < 0)
+ return rv;
+ if((!local && SFFROZEN(f)) ||
+ (!(f->flags&SF_STRING) && f->file < 0) )
+ { if(rv == 0)
+ { local = 1;
+ goto err_notify;
+ }
+ else continue;
+ }
+ else break;
+ }
+ }
+
+ if(f->mode&SF_GETR)
+ { f->mode &= ~SF_GETR;
+#ifdef MAP_TYPE
+ if((f->bits&SF_MMAP) && (f->tiny[0] += 1) >= (4*SF_NMAP) )
+ { /* turn off mmap to avoid page faulting */
+ sfsetbuf(f,(Void_t*)f->tiny,(size_t)SF_UNBOUND);
+ f->tiny[0] = 0;
+ }
+ else
+#endif
+ if(f->getr)
+ { f->next[-1] = f->getr;
+ f->getr = 0;
+ }
+ }
+
+ if(f->mode&SF_STDIO) /* synchronizing with stdio pointers */
+ (*_Sfstdsync)(f);
+
+ if(f->disc == _Sfudisc && wanted == SF_WRITE &&
+ sfclose((*_Sfstack)(f,NIL(Sfio_t*))) < 0 )
+ { local = 1;
+ goto err_notify;
+ }
+
+ if(f->mode&SF_POOL)
+ { /* move to head of pool */
+ if(f == f->pool->sf[0] || (*_Sfpmove)(f,0) < 0 )
+ { local = 1;
+ goto err_notify;
+ }
+ f->mode &= ~SF_POOL;
+ }
+
+ SFLOCK(f,local);
+
+ /* buffer initialization */
+ wanted &= SF_RDWR;
+ if(f->mode&SF_INIT)
+ {
+ if(!f->pool && _sfsetpool(f) < 0)
+ { rv = -1;
+ goto done;
+ }
+
+ if(wanted == 0)
+ goto done;
+
+ if(wanted != (int)(f->mode&SF_RDWR) && !(f->flags&wanted) )
+ goto err_notify;
+
+ if((f->flags&SF_STRING) && f->size >= 0 && f->data)
+ { f->mode &= ~SF_INIT;
+ f->extent = ((f->flags&SF_READ) || (f->bits&SF_BOTH)) ?
+ f->size : 0;
+ f->here = 0;
+ f->endb = f->data + f->size;
+ f->next = f->endr = f->endw = f->data;
+ if(f->mode&SF_READ)
+ f->endr = f->endb;
+ else f->endw = f->endb;
+ }
+ else
+ { n = f->flags;
+ (void)SFSETBUF(f,f->data,f->size);
+ f->flags |= (n&SF_MALLOC);
+ }
+ }
+
+ if(wanted == (int)SFMODE(f,1))
+ goto done;
+
+ switch(SFMODE(f,1))
+ {
+ case SF_WRITE: /* switching to SF_READ */
+ if(wanted == 0 || wanted == SF_WRITE)
+ break;
+ if(!(f->flags&SF_READ) )
+ goto err_notify;
+ else if(f->flags&SF_STRING)
+ { SFSTRSIZE(f);
+ f->endb = f->data+f->extent;
+ f->mode = SF_READ;
+ break;
+ }
+
+ /* reset buffer */
+ if(f->next > f->data && SFFLSBUF(f,-1) < 0)
+ goto err_notify;
+
+ if(f->size == 0)
+ { /* unbuffered */
+ f->data = f->tiny;
+ f->size = sizeof(f->tiny);
+ }
+ f->next = f->endr = f->endw = f->endb = f->data;
+ f->mode = SF_READ|SF_LOCK;
+
+ /* restore saved read data for coprocess */
+ if(f->proc && _sfpmode(f,wanted) < 0)
+ goto err_notify;
+
+ break;
+
+ case (SF_READ|SF_SYNCED): /* a previously sync-ed read stream */
+ if(wanted != SF_WRITE)
+ { /* just reset the pointers */
+ f->mode = SF_READ|SF_LOCK;
+
+ /* see if must go with new physical location */
+ if((f->flags&(SF_SHARE|SF_PUBLIC)) == (SF_SHARE|SF_PUBLIC) &&
+ (addr = SFSK(f,0,SEEK_CUR,f->disc)) != f->here)
+ {
+#ifdef MAP_TYPE
+ if((f->bits&SF_MMAP) && f->data)
+ { SFMUNMAP(f,f->data,f->endb-f->data);
+ f->data = NIL(uchar*);
+ }
+#endif
+ f->endb = f->endr = f->endw = f->next = f->data;
+ f->here = addr;
+ }
+ else
+ { addr = f->here + (f->endb - f->next);
+ if(SFSK(f,addr,SEEK_SET,f->disc) < 0)
+ goto err_notify;
+ f->here = addr;
+ }
+
+ break;
+ }
+ /* fall thru */
+
+ case SF_READ: /* switching to SF_WRITE */
+ if(wanted != SF_WRITE)
+ break;
+ else if(!(f->flags&SF_WRITE))
+ goto err_notify;
+ else if(f->flags&SF_STRING)
+ { f->endb = f->data+f->size;
+ f->mode = SF_WRITE|SF_LOCK;
+ break;
+ }
+
+ /* save unread data before switching mode */
+ if(f->proc && _sfpmode(f,wanted) < 0)
+ goto err_notify;
+
+ /* reset buffer and seek pointer */
+ if(!(f->mode&SF_SYNCED) )
+ { n = f->endb - f->next;
+ if(f->extent >= 0 && (n > 0 || (f->data && (f->bits&SF_MMAP))) )
+ { /* reset file pointer */
+ addr = f->here - n;
+ if(SFSK(f,addr,SEEK_SET,f->disc) < 0)
+ goto err_notify;
+ f->here = addr;
+ }
+ }
+
+ f->mode = SF_WRITE|SF_LOCK;
+#ifdef MAP_TYPE
+ if(f->bits&SF_MMAP)
+ { if(f->data)
+ SFMUNMAP(f,f->data,f->endb-f->data);
+ (void)SFSETBUF(f,(Void_t*)f->tiny,(size_t)SF_UNBOUND);
+ }
+#endif
+ if(f->data == f->tiny)
+ { f->endb = f->data = f->next = NIL(uchar*);
+ f->size = 0;
+ }
+ else f->endb = (f->next = f->data) + f->size;
+
+ break;
+
+ default: /* unknown case */
+ err_notify:
+ if((wanted &= SF_RDWR) == 0 && (wanted = f->flags&SF_RDWR) == SF_RDWR)
+ wanted = SF_READ;
+
+ /* set errno for operations that access wrong stream type */
+ if(wanted != (f->mode&SF_RDWR) && f->file >= 0)
+ errno = EBADF;
+
+ if(_Sfnotify) /* notify application of the error */
+ (*_Sfnotify)(f,wanted,f->file);
+
+ rv = -1;
+ break;
+ }
+
+done:
+ SFOPEN(f,local);
+ return rv;
+}
diff --git a/usr/src/lib/libast/common/sfio/sfmove.c b/usr/src/lib/libast/common/sfio/sfmove.c
new file mode 100644
index 0000000000..11431bd57b
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfmove.c
@@ -0,0 +1,240 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Move data from one stream to another.
+** This code is written so that it'll work even in the presence
+** of stacking streams, pool, and discipline.
+** If you must change it, be gentle.
+**
+** Written by Kiem-Phong Vo.
+*/
+#define MAX_SSIZE ((ssize_t)((~((size_t)0)) >> 1))
+
+#if __STD_C
+Sfoff_t sfmove(Sfio_t* fr, Sfio_t* fw, Sfoff_t n, reg int rc)
+#else
+Sfoff_t sfmove(fr,fw,n,rc)
+Sfio_t* fr; /* moving data from this stream */
+Sfio_t* fw; /* moving data to this stream */
+Sfoff_t n; /* number of bytes/records to move. <0 for unbounded move */
+reg int rc; /* record separator */
+#endif
+{
+ reg uchar *cp, *next;
+ reg ssize_t r, w;
+ reg uchar *endb;
+ reg int direct;
+ Sfoff_t n_move, sk, cur;
+ uchar *rbuf = NIL(uchar*);
+ ssize_t rsize = 0;
+
+ SFMTXSTART(fr, (Sfoff_t)0);
+ if(fw)
+ SFMTXLOCK(fw);
+
+ for(n_move = 0; n != 0; )
+ {
+ if(rc >= 0) /* moving records, let sfgetr() deal with record reading */
+ { if(!(cp = (uchar*)sfgetr(fr,rc,0)) )
+ n = 0;
+ else
+ { r = sfvalue(fr);
+ if(fw && (w = SFWRITE(fw, cp, r)) != r)
+ { if(fr->extent >= 0 )
+ (void)SFSEEK(fr,(Sfoff_t)(-r),SEEK_CUR);
+ if(fw->extent >= 0 && w > 0)
+ (void)SFSEEK(fw,(Sfoff_t)(-w),SEEK_CUR);
+ n = 0;
+ }
+ else
+ { n_move += 1;
+ if(n > 0)
+ n -= 1;
+ }
+ }
+ continue;
+ }
+
+ /* get the streams into the right mode */
+ if(fr->mode != SF_READ && _sfmode(fr,SF_READ,0) < 0)
+ break;
+
+ SFLOCK(fr,0);
+
+ /* flush the write buffer as necessary to make room */
+ if(fw)
+ { if(fw->mode != SF_WRITE && _sfmode(fw,SF_WRITE,0) < 0 )
+ break;
+ SFLOCK(fw,0);
+ if(fw->next >= fw->endb ||
+ (fw->next > fw->data && fr->extent < 0 &&
+ (fw->extent < 0 || (fw->flags&SF_SHARE)) ) )
+ if(SFFLSBUF(fw,-1) < 0 )
+ break;
+ }
+ else if((cur = SFSEEK(fr, (Sfoff_t)0, SEEK_CUR)) >= 0 )
+ { sk = n > 0 ? SFSEEK(fr, n, SEEK_CUR) : SFSEEK(fr, 0, SEEK_END);
+ if(sk > cur) /* safe to skip over data in current stream */
+ { n_move += sk - cur;
+ if(n > 0)
+ n -= sk - cur;
+ continue;
+ }
+ /* else: stream unstacking may happen below */
+ }
+
+ /* about to move all, set map to a large amount */
+ if(n < 0 && (fr->bits&SF_MMAP) && !(fr->bits&SF_MVSIZE) )
+ { SFMVSET(fr);
+ fr->bits |= SF_SEQUENTIAL; /* sequentially access data */
+ }
+
+ /* try reading a block of data */
+ direct = 0;
+ if((r = fr->endb - (next = fr->next)) <= 0)
+ { /* amount of data remained to be read */
+ if((w = n > MAX_SSIZE ? MAX_SSIZE : (ssize_t)n) < 0)
+ { if(fr->extent < 0)
+ w = fr->data == fr->tiny ? SF_GRAIN : fr->size;
+ else if((fr->extent-fr->here) > SF_NMAP*SF_PAGE)
+ w = SF_NMAP*SF_PAGE;
+ else w = (ssize_t)(fr->extent-fr->here);
+ }
+
+ /* use a decent buffer for data transfer but make sure
+ that if we overread, the left over can be retrieved
+ */
+ if(!(fr->flags&SF_STRING) && !(fr->bits&SF_MMAP) &&
+ (n < 0 || fr->extent >= 0) )
+ { reg ssize_t maxw = 4*(_Sfpage > 0 ? _Sfpage : SF_PAGE);
+
+ /* direct transfer to a seekable write stream */
+ if(fw && fw->extent >= 0 && w <= (fw->endb-fw->next) )
+ { w = fw->endb - (next = fw->next);
+ direct = SF_WRITE;
+ }
+ else if(w > fr->size && maxw > fr->size)
+ { /* making our own buffer */
+ if(w >= maxw)
+ w = maxw;
+ else w = ((w+fr->size-1)/fr->size)*fr->size;
+ if(rsize <= 0 && (rbuf = (uchar*)malloc(w)) )
+ rsize = w;
+ if(rbuf)
+ { next = rbuf;
+ w = rsize;
+ direct = SF_STRING;
+ }
+ }
+ }
+
+ if(!direct)
+ { /* make sure we don't read too far ahead */
+ if(n > 0 && fr->extent < 0 && (fr->flags&SF_SHARE) )
+ { if((Sfoff_t)(r = fr->size) > n)
+ r = (ssize_t)n;
+ }
+ else r = -1;
+ if((r = SFFILBUF(fr,r)) <= 0)
+ break;
+ next = fr->next;
+ }
+ else
+ { /* actual amount to be read */
+ if(n > 0 && n < w)
+ w = (ssize_t)n;
+
+ if((r = SFRD(fr,next,w,fr->disc)) > 0)
+ fr->next = fr->endb = fr->endr = fr->data;
+ else if(r == 0)
+ break; /* eof */
+ else goto again; /* popped stack */
+ }
+ }
+
+ /* compute the extent of data to be moved */
+ endb = next+r;
+ if(n > 0)
+ { if(r > n)
+ r = (ssize_t)n;
+ n -= r;
+ }
+ n_move += r;
+ cp = next+r;
+
+ if(!direct)
+ fr->next += r;
+ else if((w = endb-cp) > 0)
+ { /* move left-over to read stream */
+ if(w > fr->size)
+ w = fr->size;
+ memcpy((Void_t*)fr->data,(Void_t*)cp,w);
+ fr->endb = fr->data+w;
+ if((w = endb - (cp+w)) > 0)
+ (void)SFSK(fr,(Sfoff_t)(-w),SEEK_CUR,fr->disc);
+ }
+
+ if(fw)
+ { if(direct == SF_WRITE)
+ fw->next += r;
+ else if(r <= (fw->endb-fw->next) )
+ { memcpy((Void_t*)fw->next,(Void_t*)next,r);
+ fw->next += r;
+ }
+ else if((w = SFWRITE(fw,(Void_t*)next,r)) != r)
+ { /* a write error happened */
+ if(w > 0)
+ { r -= w;
+ n_move -= r;
+ }
+ if(fr->extent >= 0)
+ (void)SFSEEK(fr,(Sfoff_t)(-r),SEEK_CUR);
+ break;
+ }
+ }
+
+ again:
+ SFOPEN(fr,0);
+ if(fw)
+ SFOPEN(fw,0);
+ }
+
+ if(n < 0 && (fr->bits&SF_MMAP) && (fr->bits&SF_MVSIZE))
+ { /* back to normal access mode */
+ SFMVUNSET(fr);
+ if((fr->bits&SF_SEQUENTIAL) && (fr->data))
+ SFMMSEQOFF(fr,fr->data,fr->endb-fr->data);
+ fr->bits &= ~SF_SEQUENTIAL;
+ }
+
+ if(rbuf)
+ free(rbuf);
+
+ SFOPEN(fr,0);
+ if(fw)
+ { SFOPEN(fw,0);
+ SFMTXUNLOCK(fw);
+ }
+
+ SFMTXRETURN(fr, n_move);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfmutex.c b/usr/src/lib/libast/common/sfio/sfmutex.c
new file mode 100644
index 0000000000..7c36a54f10
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfmutex.c
@@ -0,0 +1,69 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Obtain/release exclusive use of a stream.
+**
+** Written by Kiem-Phong Vo.
+*/
+
+/* the main locking/unlocking interface */
+#if __STD_C
+int sfmutex(Sfio_t* f, int type)
+#else
+int sfmutex(f, type)
+Sfio_t* f;
+int type;
+#endif
+{
+#if !vt_threaded
+ NOTUSED(f); NOTUSED(type);
+ return 0;
+#else
+
+ SFONCE();
+
+ if(!f)
+ return -1;
+
+ if(!f->mutex)
+ { if(f->bits&SF_PRIVATE)
+ return 0;
+
+ vtmtxlock(_Sfmutex);
+ f->mutex = vtmtxopen(NIL(Vtmutex_t*), VT_INIT);
+ vtmtxunlock(_Sfmutex);
+ if(!f->mutex)
+ return -1;
+ }
+
+ if(type == SFMTX_LOCK)
+ return vtmtxlock(f->mutex);
+ else if(type == SFMTX_TRYLOCK)
+ return vtmtxtrylock(f->mutex);
+ else if(type == SFMTX_UNLOCK)
+ return vtmtxunlock(f->mutex);
+ else if(type == SFMTX_CLRLOCK)
+ return vtmtxclrlock(f->mutex);
+ else return -1;
+#endif /*vt_threaded*/
+}
diff --git a/usr/src/lib/libast/common/sfio/sfnew.c b/usr/src/lib/libast/common/sfio/sfnew.c
new file mode 100644
index 0000000000..caa631e4db
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfnew.c
@@ -0,0 +1,129 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Fundamental function to create a new stream.
+** The argument flags defines the type of stream and the scheme
+** of buffering.
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+Sfio_t* sfnew(Sfio_t* oldf, Void_t* buf, size_t size, int file, int flags)
+#else
+Sfio_t* sfnew(oldf,buf,size,file,flags)
+Sfio_t* oldf; /* old stream to be reused */
+Void_t* buf; /* a buffer to read/write, if NULL, will be allocated */
+size_t size; /* buffer size if buf is given or desired buffer size */
+int file; /* file descriptor to read/write from */
+int flags; /* type of file stream */
+#endif
+{
+ reg Sfio_t* f;
+ reg int sflags;
+
+ SFONCE(); /* initialize mutexes */
+
+ if(!(flags&SF_RDWR))
+ return NIL(Sfio_t*);
+
+ sflags = 0;
+ if((f = oldf) )
+ { if(flags&SF_EOF)
+ { if(f != sfstdin && f != sfstdout && f != sfstderr)
+ f->mutex = NIL(Vtmutex_t*);
+ SFCLEAR(f, f->mutex);
+ oldf = NIL(Sfio_t*);
+ }
+ else if(f->mode&SF_AVAIL)
+ { /* only allow SF_STATIC to be already closed */
+ if(!(f->flags&SF_STATIC) )
+ return NIL(Sfio_t*);
+ sflags = f->flags;
+ oldf = NIL(Sfio_t*);
+ }
+ else
+ { /* reopening an open stream, close it first */
+ sflags = f->flags;
+
+ if(((f->mode&SF_RDWR) != f->mode && _sfmode(f,0,0) < 0) ||
+ SFCLOSE(f) < 0 )
+ return NIL(Sfio_t*);
+
+ if(f->data && ((flags&SF_STRING) || size != (size_t)SF_UNBOUND) )
+ { if(sflags&SF_MALLOC)
+ free((Void_t*)f->data);
+ f->data = NIL(uchar*);
+ }
+ if(!f->data)
+ sflags &= ~SF_MALLOC;
+ }
+ }
+
+ if(!f)
+ { /* reuse a standard stream structure if possible */
+ if(!(flags&SF_STRING) && file >= 0 && file <= 2)
+ { f = file == 0 ? sfstdin : file == 1 ? sfstdout : sfstderr;
+ if(f)
+ { if(f->mode&SF_AVAIL)
+ { sflags = f->flags;
+ SFCLEAR(f, f->mutex);
+ }
+ else f = NIL(Sfio_t*);
+ }
+ }
+
+ if(!f)
+ { if(!(f = (Sfio_t*)malloc(sizeof(Sfio_t))) )
+ return NIL(Sfio_t*);
+ SFCLEAR(f, NIL(Vtmutex_t*));
+ }
+ }
+
+ /* create a mutex */
+ if(!f->mutex)
+ f->mutex = vtmtxopen(NIL(Vtmutex_t*), VT_INIT);
+
+ /* stream type */
+ f->mode = (flags&SF_READ) ? SF_READ : SF_WRITE;
+ f->flags = (flags&SF_FLAGS) | (sflags&(SF_MALLOC|SF_STATIC));
+ f->bits = (flags&SF_RDWR) == SF_RDWR ? SF_BOTH : 0;
+ f->file = file;
+ f->here = f->extent = 0;
+ f->getr = f->tiny[0] = 0;
+
+ f->mode |= SF_INIT;
+ if(size != (size_t)SF_UNBOUND)
+ { f->size = size;
+ f->data = size <= 0 ? NIL(uchar*) : (uchar*)buf;
+ }
+ f->endb = f->endr = f->endw = f->next = f->data;
+
+ if(_Sfnotify)
+ (*_Sfnotify)(f,SF_NEW,f->file);
+
+ if(f->flags&SF_STRING)
+ (void)_sfmode(f,f->mode&SF_RDWR,0);
+
+ return f;
+}
diff --git a/usr/src/lib/libast/common/sfio/sfnotify.c b/usr/src/lib/libast/common/sfio/sfnotify.c
new file mode 100644
index 0000000000..011f306145
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfnotify.c
@@ -0,0 +1,38 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+
+/* Set the function to be called when a stream is opened or closed
+**
+** Written by Kiem-Phong Vo.
+*/
+#if __STD_C
+int sfnotify(void (*notify)(Sfio_t*, int, int))
+#else
+int sfnotify(notify)
+void (*notify)();
+#endif
+{
+ _Sfnotify = notify;
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/sfio/sfnputc.c b/usr/src/lib/libast/common/sfio/sfnputc.c
new file mode 100644
index 0000000000..74e63aafe5
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfnputc.c
@@ -0,0 +1,80 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Write out a character n times
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+ssize_t sfnputc(reg Sfio_t* f, reg int c, reg size_t n)
+#else
+ssize_t sfnputc(f,c,n)
+reg Sfio_t* f; /* file to write */
+reg int c; /* char to be written */
+reg size_t n; /* number of time to repeat */
+#endif
+{
+ reg uchar* ps;
+ reg ssize_t p, w;
+ uchar buf[128];
+ reg int local;
+
+ SFMTXSTART(f,-1);
+
+ GETLOCAL(f,local);
+ if(SFMODE(f,local) != SF_WRITE && _sfmode(f,SF_WRITE,local) < 0)
+ SFMTXRETURN(f, -1);
+
+ SFLOCK(f,local);
+
+ /* write into a suitable buffer */
+ if((size_t)(p = (f->endb-(ps = f->next))) < n)
+ { ps = buf; p = sizeof(buf); }
+ if((size_t)p > n)
+ p = n;
+ MEMSET(ps,c,p);
+ ps -= p;
+
+ w = n;
+ if(ps == f->next)
+ { /* simple sfwrite */
+ f->next += p;
+ if(c == '\n')
+ (void)SFFLSBUF(f,-1);
+ goto done;
+ }
+
+ for(;;)
+ { /* hard write of data */
+ if((p = SFWRITE(f,(Void_t*)ps,p)) <= 0 || (n -= p) <= 0)
+ { w -= n;
+ goto done;
+ }
+ if((size_t)p > n)
+ p = n;
+ }
+done :
+ SFOPEN(f,local);
+ SFMTXRETURN(f, w);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfopen.c b/usr/src/lib/libast/common/sfio/sfopen.c
new file mode 100644
index 0000000000..04d55073f8
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfopen.c
@@ -0,0 +1,40 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/*
+ * _sfopen() wrapper to allow user sfopen() intercept
+ */
+
+extern Sfio_t* _sfopen _ARG_((Sfio_t*, const char*, const char*));
+
+#if __STD_C
+Sfio_t* sfopen(Sfio_t* f, const char* file, const char* mode)
+#else
+Sfio_t* sfopen(f,file,mode)
+Sfio_t* f; /* old stream structure */
+char* file; /* file/string to be opened */
+reg char* mode; /* mode of the stream */
+#endif
+{
+ return _sfopen(f, file, mode);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfpeek.c b/usr/src/lib/libast/common/sfio/sfpeek.c
new file mode 100644
index 0000000000..9a2d3ef36b
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfpeek.c
@@ -0,0 +1,89 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Safe access to the internal stream buffer.
+** This function is obsolete. sfreserve() should be used.
+**
+** Written by Kiem-Phong Vo (06/27/90).
+*/
+
+#if _BLD_sfio && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+#if __STD_C
+extern ssize_t sfpeek(reg Sfio_t* f, Void_t** bp, reg size_t size)
+#else
+extern ssize_t sfpeek(f,bp,size)
+reg Sfio_t* f; /* file to peek */
+Void_t** bp; /* start of data area */
+reg size_t size; /* size of peek */
+#endif
+{ reg ssize_t n, sz;
+ reg int mode;
+
+ /* query for the extent of the remainder of the buffer */
+ if((sz = size) == 0 || !bp)
+ { if(f->mode&SF_INIT)
+ (void)_sfmode(f,0,0);
+
+ if((f->flags&SF_RDWRSTR) == SF_RDWRSTR)
+ { SFSTRSIZE(f);
+ n = (f->data+f->here) - f->next;
+ }
+ else n = f->endb - f->next;
+
+ if(!bp)
+ return n;
+ else if(n > 0) /* size == 0 */
+ { *bp = (Void_t*)f->next;
+ return 0;
+ }
+ /* else fall down and fill buffer */
+ }
+
+ if(!(mode = f->flags&SF_READ) )
+ mode = SF_WRITE;
+ if((int)f->mode != mode && _sfmode(f,mode,0) < 0)
+ return -1;
+
+ *bp = sfreserve(f, sz <= 0 ? 0 : sz > f->size ? f->size : sz, 0);
+
+ if(*bp && sz >= 0)
+ return sz;
+
+ if((n = sfvalue(f)) > 0)
+ { *bp = (Void_t*)f->next;
+ if(sz < 0)
+ { f->mode |= SF_PEEK;
+ f->endr = f->endw = f->data;
+ }
+ else
+ { if(sz > n)
+ sz = n;
+ f->next += sz;
+ }
+ }
+
+ return (sz >= 0 && n >= sz) ? sz : n;
+}
diff --git a/usr/src/lib/libast/common/sfio/sfpkrd.c b/usr/src/lib/libast/common/sfio/sfpkrd.c
new file mode 100644
index 0000000000..10ab826f87
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfpkrd.c
@@ -0,0 +1,290 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+#if !_PACKAGE_ast
+#ifndef FIONREAD
+#if _sys_ioctl
+#include <sys/ioctl.h>
+#endif
+#endif
+#endif
+
+/* Read/Peek a record from an unseekable device
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#define STREAM_PEEK 001
+#define SOCKET_PEEK 002
+
+#if __STD_C
+ssize_t sfpkrd(int fd, Void_t* argbuf, size_t n, int rc, long tm, int action)
+#else
+ssize_t sfpkrd(fd, argbuf, n, rc, tm, action)
+int fd; /* file descriptor */
+Void_t* argbuf; /* buffer to read data */
+size_t n; /* buffer size */
+int rc; /* record character */
+long tm; /* time-out */
+int action; /* >0: peeking, if rc>=0, get action records,
+ <0: no peeking, if rc>=0, get -action records,
+ =0: no peeking, if rc>=0, must get a single record
+ */
+#endif
+{
+ reg ssize_t r;
+ reg int ntry, t;
+ reg char *buf = (char*)argbuf, *endbuf;
+
+ if(rc < 0 && tm < 0 && action <= 0)
+ return sysreadf(fd,buf,n);
+
+ t = (action > 0 || rc >= 0) ? (STREAM_PEEK|SOCKET_PEEK) : 0;
+#if !_stream_peek
+ t &= ~STREAM_PEEK;
+#endif
+#if !_socket_peek
+ t &= ~SOCKET_PEEK;
+#endif
+
+ for(ntry = 0; ntry < 2; ++ntry)
+ {
+ r = -1;
+#if _stream_peek
+ if((t&STREAM_PEEK) && (ntry == 1 || tm < 0) )
+ {
+ struct strpeek pbuf;
+ pbuf.flags = 0;
+ pbuf.ctlbuf.maxlen = -1;
+ pbuf.ctlbuf.len = 0;
+ pbuf.ctlbuf.buf = NIL(char*);
+ pbuf.databuf.maxlen = n;
+ pbuf.databuf.buf = buf;
+ pbuf.databuf.len = 0;
+
+ if((r = ioctl(fd,I_PEEK,&pbuf)) < 0)
+ { if(errno == EINTR)
+ return -1;
+ t &= ~STREAM_PEEK;
+ }
+ else
+ { t &= ~SOCKET_PEEK;
+ if(r > 0 && (r = pbuf.databuf.len) <= 0)
+ { if(action <= 0) /* read past eof */
+ r = sysreadf(fd,buf,1);
+ return r;
+ }
+ if(r == 0)
+ r = -1;
+ else if(r > 0)
+ break;
+ }
+ }
+#endif /* stream_peek */
+
+ if(ntry == 1)
+ break;
+
+ /* poll or select to see if data is present. */
+ while(tm >= 0 || action > 0 ||
+ /* block until there is data before peeking again */
+ ((t&STREAM_PEEK) && rc >= 0) ||
+ /* let select be interrupted instead of recv which autoresumes */
+ (t&SOCKET_PEEK) )
+ { r = -2;
+#if _lib_poll
+ if(r == -2)
+ {
+ struct pollfd po;
+ po.fd = fd;
+ po.events = POLLIN;
+ po.revents = 0;
+
+ if((r = SFPOLL(&po,1,tm)) < 0)
+ { if(errno == EINTR)
+ return -1;
+ else if(errno == EAGAIN)
+ { errno = 0;
+ continue;
+ }
+ else r = -2;
+ }
+ else r = (po.revents&POLLIN) ? 1 : -1;
+ }
+#endif /*_lib_poll*/
+#if _lib_select
+ if(r == -2)
+ {
+#if _hpux_threads && vt_threaded
+#define fd_set int
+#endif
+ fd_set rd;
+ struct timeval tmb, *tmp;
+ FD_ZERO(&rd);
+ FD_SET(fd,&rd);
+ if(tm < 0)
+ tmp = NIL(struct timeval*);
+ else
+ { tmp = &tmb;
+ tmb.tv_sec = tm/SECOND;
+ tmb.tv_usec = (tm%SECOND)*SECOND;
+ }
+ r = select(fd+1,&rd,NIL(fd_set*),NIL(fd_set*),tmp);
+ if(r < 0)
+ { if(errno == EINTR)
+ return -1;
+ else if(errno == EAGAIN)
+ { errno = 0;
+ continue;
+ }
+ else r = -2;
+ }
+ else r = FD_ISSET(fd,&rd) ? 1 : -1;
+ }
+#endif /*_lib_select*/
+ if(r == -2)
+ {
+#if !_lib_poll && !_lib_select /* both poll and select cann't be used */
+#ifdef FIONREAD /* quick and dirty check for availability */
+ long nsec = tm < 0 ? 0 : (tm+999)/1000;
+ while(nsec > 0 && r < 0)
+ { long avail = -1;
+ if((r = ioctl(fd,FIONREAD,&avail)) < 0)
+ { if(errno == EINTR)
+ return -1;
+ else if(errno == EAGAIN)
+ { errno = 0;
+ continue;
+ }
+ else /* ioctl failed completely */
+ { r = -2;
+ break;
+ }
+ }
+ else r = avail <= 0 ? -1 : (ssize_t)avail;
+
+ if(r < 0 && nsec-- > 0)
+ sleep(1);
+ }
+#endif
+#endif
+ }
+
+ if(r > 0) /* there is data now */
+ { if(action <= 0 && rc < 0)
+ return sysreadf(fd,buf,n);
+ else r = -1;
+ }
+ else if(tm >= 0) /* timeout exceeded */
+ return -1;
+ else r = -1;
+ break;
+ }
+
+#if _socket_peek
+ if(t&SOCKET_PEEK)
+ {
+#if __MACH__ && __APPLE__
+ /*
+ * work around macos 10.4 recv(MSG_PEEK) bug that consumes pipe() data
+ */
+
+ static int recv_peek_ok;
+ if (!recv_peek_ok)
+ {
+ int fds[2];
+ char tst[2];
+ tst[0] = 'a';
+ tst[1] = 'z';
+ recv_peek_ok = (!pipe(fds) && write(fds[1], tst, 2) && recv(fds[0], tst, 1, MSG_PEEK) == 1 && tst[0] == 'a' && recv(fds[0], tst, 1, MSG_PEEK) == 1 && tst[0] == 'a') ? 1 : -1;
+ close(fds[0]);
+ close(fds[1]);
+ }
+ if (recv_peek_ok < 0)
+ {
+ r = -1;
+ t &= ~SOCKET_PEEK;
+ }
+ else
+#endif
+ while((r = recv(fd,(char*)buf,n,MSG_PEEK)) < 0)
+ { if(errno == EINTR)
+ return -1;
+ else if(errno == EAGAIN)
+ { errno = 0;
+ continue;
+ }
+ t &= ~SOCKET_PEEK;
+ break;
+ }
+ if(r >= 0)
+ { t &= ~STREAM_PEEK;
+ if(r > 0)
+ break;
+ else /* read past eof */
+ { if(action <= 0)
+ r = sysreadf(fd,buf,1);
+ return r;
+ }
+ }
+ }
+#endif
+ }
+
+ if(r < 0)
+ { if(tm >= 0 || action > 0)
+ return -1;
+ else /* get here means: tm < 0 && action <= 0 && rc >= 0 */
+ { /* number of records read at a time */
+ if((action = action ? -action : 1) > (int)n)
+ action = n;
+ r = 0;
+ while((t = sysreadf(fd,buf,action)) > 0)
+ { r += t;
+ for(endbuf = buf+t; buf < endbuf;)
+ if(*buf++ == rc)
+ action -= 1;
+ if(action == 0 || (int)(n-r) < action)
+ break;
+ }
+ return r == 0 ? t : r;
+ }
+ }
+
+ /* successful peek, find the record end */
+ if(rc >= 0)
+ { reg char* sp;
+
+ t = action == 0 ? 1 : action < 0 ? -action : action;
+ for(endbuf = (sp = buf)+r; sp < endbuf; )
+ if(*sp++ == rc)
+ if((t -= 1) == 0)
+ break;
+ r = sp - buf;
+ }
+
+ /* advance */
+ if(action <= 0)
+ r = sysreadf(fd,buf,r);
+
+ return r;
+}
diff --git a/usr/src/lib/libast/common/sfio/sfpoll.c b/usr/src/lib/libast/common/sfio/sfpoll.c
new file mode 100644
index 0000000000..642da85217
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfpoll.c
@@ -0,0 +1,245 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Poll a set of streams to see if any is available for I/O.
+** Ready streams are moved to front of array but retain the
+** same relative order.
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+int sfpoll(Sfio_t** fa, reg int n, int tm)
+#else
+int sfpoll(fa, n, tm)
+Sfio_t** fa; /* array of streams to poll */
+reg int n; /* number of streams in array */
+int tm; /* time in millisecs for select/poll */
+#endif
+{
+ reg int r, c, m, np;
+ reg Sfio_t* f;
+ reg int *status, *check;
+
+ if(n <= 0 || !fa)
+ return -1;
+
+ if(!(status = (int*)malloc(2*n*sizeof(int))) )
+ return -1;
+ check = status+n; /* streams that need polling */
+
+ /* a SF_READ stream is ready if there is buffered read data */
+#define RDREADY(f) (((f->mode&SF_READ) && f->next < f->endb) || \
+ ((f->mode&SF_WRITE) && f->proc && f->proc->ndata > 0) )
+
+ /* a SF_WRITE stream is ready if there is no write data */
+#define WRREADY(f) (!(f->mode&SF_WRITE) || f->next == f->data)
+
+#define HASAUXFD(f) (f->proc && f->proc->file >= 0 && f->proc->file != f->file)
+
+ for(r = c = 0; r < n; ++r) /* compute streams that must be checked */
+ { f = fa[r];
+ status[r] = 0;
+
+ /* check accessibility */
+ m = f->mode&SF_RDWR;
+ if((int)f->mode != m && _sfmode(f,m,0) < 0)
+ continue;
+
+ if((f->flags&SF_READ) && RDREADY(f))
+ status[r] |= SF_READ;
+
+ if((f->flags&SF_WRITE) && WRREADY(f))
+ status[r] |= SF_WRITE;
+
+ if((f->flags&SF_RDWR) == status[r])
+ continue;
+
+ /* has discipline, ask its opinion */
+ if(f->disc && f->disc->exceptf)
+ { if((m = (*f->disc->exceptf)(f,SF_DPOLL,&tm,f->disc)) < 0)
+ continue;
+ else if(m > 0)
+ { status[r] = m&SF_RDWR;
+ continue;
+ }
+ }
+
+ if(f->extent < 0) /* unseekable stream, must poll/select */
+ check[c++] = r;
+ else /* seekable streams are always ready */
+ { if(f->flags&SF_READ)
+ status[r] |= SF_READ;
+ if(f->flags&SF_WRITE)
+ status[r] |= SF_WRITE;
+ }
+ }
+
+ np = -1;
+#if _lib_poll
+ if(c > 0)
+ { struct pollfd* fds;
+
+ /* construct the poll array */
+ for(m = 0, r = 0; r < c; ++r, ++m)
+ { f = fa[check[r]];
+ if(HASAUXFD(f))
+ m += 1;
+ }
+ if(!(fds = (struct pollfd*)malloc(m*sizeof(struct pollfd))) )
+ return -1;
+
+ for(m = 0, r = 0; r < c; ++r, ++m)
+ { f = fa[check[r]];
+
+ fds[m].fd = f->file;
+ fds[m].events = fds[m].revents = 0;
+
+ if((f->flags&SF_WRITE) && !WRREADY(f) )
+ fds[m].events |= POLLOUT;
+
+ if((f->flags&SF_READ) && !RDREADY(f) )
+ { /* a sfpopen situation with two file descriptors */
+ if((f->mode&SF_WRITE) && HASAUXFD(f))
+ { m += 1;
+ fds[m].fd = f->proc->file;
+ fds[m].revents = 0;
+ }
+
+ fds[m].events |= POLLIN;
+ }
+ }
+
+ while((np = SFPOLL(fds,m,tm)) < 0 )
+ { if(errno == EINTR || errno == EAGAIN)
+ errno = 0;
+ else break;
+ }
+ if(np > 0) /* poll succeeded */
+ np = c;
+
+ for(m = 0, r = 0; r < np; ++r, ++m)
+ { f = fa[check[r]];
+
+ if((f->flags&SF_WRITE) && !WRREADY(f) )
+ { if(fds[m].revents&POLLOUT)
+ status[check[r]] |= SF_WRITE;
+ }
+
+ if((f->flags&SF_READ) && !RDREADY(f))
+ { if((f->mode&SF_WRITE) && HASAUXFD(f))
+ m += 1;
+ if(fds[m].revents&POLLIN)
+ status[check[r]] |= SF_READ;
+ }
+ }
+
+ free((Void_t*)fds);
+ }
+#endif /*_lib_poll*/
+
+#if _lib_select
+ if(np < 0 && c > 0)
+ { fd_set rd, wr;
+ struct timeval tmb, *tmp;
+
+ FD_ZERO(&rd);
+ FD_ZERO(&wr);
+ m = 0;
+ for(r = 0; r < c; ++r)
+ { f = fa[check[r]];
+
+ if(f->file > m)
+ m = f->file;
+
+ if((f->flags&SF_WRITE) && !WRREADY(f))
+ FD_SET(f->file,&wr);
+
+ if((f->flags&SF_READ) && !RDREADY(f))
+ { if((f->mode&SF_WRITE) && HASAUXFD(f))
+ { if(f->proc->file > m)
+ m = f->proc->file;
+ FD_SET(f->proc->file, &rd);
+ }
+ else FD_SET(f->file,&rd);
+ }
+ }
+ if(tm < 0)
+ tmp = NIL(struct timeval*);
+ else
+ { tmp = &tmb;
+ tmb.tv_sec = tm/SECOND;
+ tmb.tv_usec = (tm%SECOND)*SECOND;
+ }
+
+ while((np = select(m+1,&rd,&wr,NIL(fd_set*),tmp)) < 0 )
+ { if(errno == EINTR)
+ errno = 0;
+ else break;
+ }
+ if(np > 0)
+ np = c;
+
+ for(r = 0; r < np; ++r)
+ { f = fa[check[r]];
+
+ if((f->flags&SF_WRITE) && !WRREADY(f) )
+ { if(FD_ISSET(f->file,&wr) )
+ status[check[r]] |= SF_WRITE;
+ }
+
+ if((f->flags&SF_READ) && !RDREADY(f) )
+ { if((f->mode&SF_WRITE) && HASAUXFD(f) )
+ { if(FD_ISSET(f->proc->file, &rd) )
+ status[check[r]] |= SF_READ;
+ }
+ else
+ { if(FD_ISSET(f->file,&rd) )
+ status[check[r]] |= SF_READ;
+ }
+ }
+ }
+ }
+#endif /*_lib_select*/
+
+ for(r = c = 0; c < n; ++c)
+ { if(status[c] == 0)
+ continue;
+
+ f = fa[c];
+ f->val = (ssize_t)status[c];
+
+ /* announce status */
+ if(f->disc && f->disc->exceptf)
+ (*f->disc->exceptf)(f,SF_READY,(Void_t*)(long)status[c],f->disc);
+
+ if(c > r) /* move to front of list */
+ { fa[c] = fa[r];
+ fa[r] = f;
+ }
+ r += 1;
+ }
+
+ free((Void_t*)status);
+ return r;
+}
diff --git a/usr/src/lib/libast/common/sfio/sfpool.c b/usr/src/lib/libast/common/sfio/sfpool.c
new file mode 100644
index 0000000000..67cfd04979
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfpool.c
@@ -0,0 +1,360 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Management of pools of streams.
+** If pf is not nil, f is pooled with pf and f becomes current;
+** otherwise, f is isolated from its pool. flag can be one of
+** 0 or SF_SHARE.
+**
+** Written by Kiem-Phong Vo.
+*/
+
+/* Note that we do not free the space for a pool once it is allocated.
+** This is to prevent memory faults in calls such as sfsync(NULL) that walk the pool
+** link list and during such walks may free up streams&pools. Free pools will be
+** reused in newpool().
+*/
+#if __STD_C
+static int delpool(reg Sfpool_t* p)
+#else
+static int delpool(p)
+reg Sfpool_t* p;
+#endif
+{
+ POOLMTXSTART(p);
+
+ if(p->s_sf && p->sf != p->array)
+ free((Void_t*)p->sf);
+ p->mode = SF_AVAIL;
+
+ POOLMTXRETURN(p,0);
+}
+
+#if __STD_C
+static Sfpool_t* newpool(reg int mode)
+#else
+static Sfpool_t* newpool(mode)
+reg int mode;
+#endif
+{
+ reg Sfpool_t *p, *last = &_Sfpool;
+
+ /* look to see if there is a free pool */
+ for(last = &_Sfpool, p = last->next; p; last = p, p = p->next)
+ { if(p->mode == SF_AVAIL )
+ { p->mode = 0;
+ break;
+ }
+ }
+
+ if(!p)
+ { POOLMTXLOCK(last);
+
+ if(!(p = (Sfpool_t*) malloc(sizeof(Sfpool_t))) )
+ { POOLMTXUNLOCK(last);
+ return NIL(Sfpool_t*);
+ }
+
+ (void)vtmtxopen(&p->mutex, VT_INIT); /* initialize mutex */
+
+ p->mode = 0;
+ p->n_sf = 0;
+ p->next = NIL(Sfpool_t*);
+ last->next = p;
+
+ POOLMTXUNLOCK(last);
+ }
+
+ POOLMTXSTART(p);
+
+ p->mode = mode&SF_SHARE;
+ p->s_sf = sizeof(p->array)/sizeof(p->array[0]);
+ p->sf = p->array;
+
+ POOLMTXRETURN(p,p);
+}
+
+/* move a stream to head */
+#if __STD_C
+static int _sfphead(Sfpool_t* p, Sfio_t* f, int n)
+#else
+static int _sfphead(p, f, n)
+Sfpool_t* p; /* the pool */
+Sfio_t* f; /* the stream */
+int n; /* current position in pool */
+#endif
+{
+ reg Sfio_t* head;
+ reg ssize_t k, w, v;
+ reg int rv;
+
+ POOLMTXSTART(p);
+
+ if(n == 0)
+ POOLMTXRETURN(p,0);
+
+ head = p->sf[0];
+ if(SFFROZEN(head) )
+ POOLMTXRETURN(p,-1);
+
+ SFLOCK(head,0);
+ rv = -1;
+
+ if(!(p->mode&SF_SHARE) || (head->mode&SF_READ) || (f->mode&SF_READ) )
+ { if(SFSYNC(head) < 0)
+ goto done;
+ }
+ else /* shared pool of write-streams, data can be moved among streams */
+ { if(SFMODE(head,1) != SF_WRITE && _sfmode(head,SF_WRITE,1) < 0)
+ goto done;
+ /**/ASSERT(f->next == f->data);
+
+ v = head->next - head->data; /* pending data */
+ if((k = v - (f->endb-f->data)) <= 0)
+ k = 0;
+ else /* try to write out amount exceeding f's capacity */
+ { if((w = SFWR(head,head->data,k,head->disc)) == k)
+ v -= k;
+ else /* write failed, recover buffer then quit */
+ { if(w > 0)
+ { v -= w;
+ memcpy(head->data,(head->data+w),v);
+ }
+ head->next = head->data+v;
+ goto done;
+ }
+ }
+
+ /* move data from head to f */
+ if((head->data+k) != f->data )
+ memcpy(f->data,(head->data+k),v);
+ f->next = f->data+v;
+ }
+
+ f->mode &= ~SF_POOL;
+ head->mode |= SF_POOL;
+ head->next = head->endr = head->endw = head->data; /* clear write buffer */
+
+ p->sf[n] = head;
+ p->sf[0] = f;
+ rv = 0;
+
+done:
+ head->mode &= ~SF_LOCK; /* partially unlock because it's no longer head */
+
+ POOLMTXRETURN(p,rv);
+}
+
+/* delete a stream from its pool */
+#if __STD_C
+static int _sfpdelete(Sfpool_t* p, Sfio_t* f, int n)
+#else
+static int _sfpdelete(p, f, n)
+Sfpool_t* p; /* the pool */
+Sfio_t* f; /* the stream */
+int n; /* position in pool */
+#endif
+{
+ POOLMTXSTART(p);
+
+ p->n_sf -= 1;
+ for(; n < p->n_sf; ++n)
+ p->sf[n] = p->sf[n+1];
+
+ f->pool = NIL(Sfpool_t*);
+ f->mode &= ~SF_POOL;
+
+ if(p->n_sf == 0 || p == &_Sfpool)
+ { if(p != &_Sfpool)
+ delpool(p);
+ goto done;
+ }
+
+ /* !_Sfpool, make sure head stream is an open stream */
+ for(n = 0; n < p->n_sf; ++n)
+ if(!SFFROZEN(p->sf[n]))
+ break;
+ if(n < p->n_sf && n > 0)
+ { f = p->sf[n];
+ p->sf[n] = p->sf[0];
+ p->sf[0] = f;
+ }
+
+ /* head stream has SF_POOL off */
+ f = p->sf[0];
+ f->mode &= ~SF_POOL;
+ if(!SFFROZEN(f))
+ _SFOPEN(f);
+
+ /* if only one stream left, delete pool */
+ if(p->n_sf == 1 )
+ { _sfpdelete(p,f,0);
+ _sfsetpool(f);
+ }
+
+done:
+ POOLMTXRETURN(p,0);
+}
+
+#if __STD_C
+static int _sfpmove(reg Sfio_t* f, reg int type)
+#else
+static int _sfpmove(f,type)
+reg Sfio_t* f;
+reg int type; /* <0 : deleting, 0: move-to-front, >0: inserting */
+#endif
+{
+ reg Sfpool_t* p;
+ reg int n;
+
+ if(type > 0)
+ return _sfsetpool(f);
+ else
+ { if(!(p = f->pool) )
+ return -1;
+ for(n = p->n_sf-1; n >= 0; --n)
+ if(p->sf[n] == f)
+ break;
+ if(n < 0)
+ return -1;
+
+ return type == 0 ? _sfphead(p,f,n) : _sfpdelete(p,f,n);
+ }
+}
+
+#if __STD_C
+Sfio_t* sfpool(reg Sfio_t* f, reg Sfio_t* pf, reg int mode)
+#else
+Sfio_t* sfpool(f,pf,mode)
+reg Sfio_t* f;
+reg Sfio_t* pf;
+reg int mode;
+#endif
+{
+ reg Sfpool_t* p;
+ reg Sfio_t* rv;
+
+ _Sfpmove = _sfpmove;
+
+ if(!f) /* return head of pool of pf regardless of lock states */
+ { if(!pf)
+ return NIL(Sfio_t*);
+ else if(!pf->pool || pf->pool == &_Sfpool)
+ return pf;
+ else return pf->pool->sf[0];
+ }
+
+ if(f) /* check for permissions */
+ { SFMTXLOCK(f);
+ if((f->mode&SF_RDWR) != f->mode && _sfmode(f,0,0) < 0)
+ { SFMTXUNLOCK(f);
+ return NIL(Sfio_t*);
+ }
+ if(f->disc == _Sfudisc)
+ (void)sfclose((*_Sfstack)(f,NIL(Sfio_t*)));
+ }
+ if(pf)
+ { SFMTXLOCK(pf);
+ if((pf->mode&SF_RDWR) != pf->mode && _sfmode(pf,0,0) < 0)
+ { if(f)
+ SFMTXUNLOCK(f);
+ SFMTXUNLOCK(pf);
+ return NIL(Sfio_t*);
+ }
+ if(pf->disc == _Sfudisc)
+ (void)sfclose((*_Sfstack)(pf,NIL(Sfio_t*)));
+ }
+
+ /* f already in the same pool with pf */
+ if(f == pf || (pf && f->pool == pf->pool && f->pool != &_Sfpool) )
+ { if(f)
+ SFMTXUNLOCK(f);
+ if(pf)
+ SFMTXUNLOCK(pf);
+ return pf;
+ }
+
+ /* lock streams before internal manipulations */
+ rv = NIL(Sfio_t*);
+ SFLOCK(f,0);
+ if(pf)
+ SFLOCK(pf,0);
+
+ if(!pf) /* deleting f from its current pool */
+ { if(!(p = f->pool) || p == &_Sfpool ||
+ _sfpmove(f,-1) < 0 || _sfsetpool(f) < 0)
+ goto done;
+
+ if((p = f->pool) == &_Sfpool || p->n_sf <= 0)
+ rv = f;
+ else rv = p->sf[0]; /* return head of pool */
+ goto done;
+ }
+
+ if(pf->pool && pf->pool != &_Sfpool) /* always use current mode */
+ mode = pf->pool->mode;
+
+ if(mode&SF_SHARE) /* can only have write streams */
+ { if(SFMODE(f,1) != SF_WRITE && _sfmode(f,SF_WRITE,1) < 0)
+ goto done;
+ if(SFMODE(pf,1) != SF_WRITE && _sfmode(pf,SF_WRITE,1) < 0)
+ goto done;
+ if(f->next > f->data && SFSYNC(f) < 0) /* start f clean */
+ goto done;
+ }
+
+ if(_sfpmove(f,-1) < 0) /* isolate f from current pool */
+ goto done;
+
+ if(!(p = pf->pool) || p == &_Sfpool) /* making a new pool */
+ { if(!(p = newpool(mode)) )
+ goto done;
+ if(_sfpmove(pf,-1) < 0) /* isolate pf from its current pool */
+ goto done;
+ pf->pool = p;
+ p->sf[0] = pf;
+ p->n_sf += 1;
+ }
+
+ f->pool = p; /* add f to pf's pool */
+ if(_sfsetpool(f) < 0)
+ goto done;
+
+ /**/ASSERT(p->sf[0] == pf && p->sf[p->n_sf-1] == f);
+ SFOPEN(pf,0);
+ SFOPEN(f,0);
+ if(_sfpmove(f,0) < 0) /* make f head of pool */
+ goto done;
+ rv = pf;
+
+done:
+ if(f)
+ { SFOPEN(f,0);
+ SFMTXUNLOCK(f);
+ }
+ if(pf)
+ { SFOPEN(pf,0);
+ SFMTXUNLOCK(pf);
+ }
+ return rv;
+}
diff --git a/usr/src/lib/libast/common/sfio/sfpopen.c b/usr/src/lib/libast/common/sfio/sfpopen.c
new file mode 100644
index 0000000000..2ee4b50cd1
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfpopen.c
@@ -0,0 +1,293 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Create a coprocess.
+** Written by Kiem-Phong Vo.
+*/
+
+#if _PACKAGE_ast
+#include <proc.h>
+#else
+
+#define EXIT_NOTFOUND 127
+
+#define READ 0
+#define WRITE 1
+
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+static char Meta[1<<CHAR_BIT], **Path;
+
+/* execute command directly if possible; else use the shell */
+#if __STD_C
+static void execute(const char* argcmd)
+#else
+static void execute(argcmd)
+char* argcmd;
+#endif
+{
+ reg char *s, *cmd, **argv, **p, *interp;
+ reg int n;
+
+ /* define interpreter */
+ if(!(interp = getenv("SHELL")) || !interp[0])
+ interp = "/bin/sh";
+
+ if(strcmp(interp,"/bin/sh") != 0 && strcmp(interp,"/bin/ksh") != 0 )
+ { if(access(interp,X_OK) == 0)
+ goto do_interp;
+ else interp = "/bin/sh";
+ }
+
+ /* if there is a meta character, let the shell do it */
+ for(s = (char*)argcmd; *s; ++s)
+ if(Meta[(uchar)s[0]])
+ goto do_interp;
+
+ /* try to construct argv */
+ if(!(cmd = (char*)malloc(strlen(argcmd)+1)) )
+ goto do_interp;
+ strcpy(cmd,argcmd);
+ if(!(argv = (char**)malloc(16*sizeof(char*))) )
+ goto do_interp;
+ for(n = 0, s = cmd;; )
+ { while(isspace(s[0]))
+ s += 1;
+ if(s[0] == 0)
+ break;
+
+ /* new argument */
+ argv[n++] = s;
+ if((n%16) == 0 && !(argv = (char**)realloc(argv,(n+16)*sizeof(char*))) )
+ goto do_interp;
+
+ /* make this into a C string */
+ while(s[0] && !isspace(s[0]))
+ s += 1;
+ if(!s[0])
+ *s++ = 0;
+ }
+ if(n == 0)
+ goto do_interp;
+ argv[n] = NIL(char*);
+
+ /* get the command name */
+ cmd = argv[0];
+ for(s = cmd+strlen(cmd)-1; s >= cmd; --s)
+ if(*s == '/')
+ break;
+ argv[0] = s+1;
+
+ /* Non-standard pathnames as in nDFS should be handled by the shell */
+ for(s = cmd+strlen(cmd)-1; s >= cmd+2; --s)
+ if(s[0] == '.' && s[-1] == '.' && s[-2] == '.')
+ goto do_interp;
+
+ if(cmd[0] == '/' ||
+ (cmd[0] == '.' && cmd[1] == '/') ||
+ (cmd[0] == '.' && cmd[1] == '.' && cmd[2] == '/') )
+ { if(access(cmd,X_OK) != 0)
+ goto do_interp;
+ else execv(cmd,argv);
+ }
+ else
+ { for(p = Path; *p; ++p)
+ { s = sfprints("%s/%s", *p, cmd);
+ if(access(s,X_OK) == 0)
+ execv(s,argv);
+ }
+ }
+
+ /* if get here, let the interpreter do it */
+do_interp:
+ for(s = interp+strlen(interp)-1; s >= interp; --s)
+ if(*s == '/')
+ break;
+ execl(interp, s+1, "-c", argcmd, NIL(char*));
+ _exit(EXIT_NOTFOUND);
+}
+
+#endif /*_PACKAGE_ast*/
+
+#if __STD_C
+Sfio_t* sfpopen(Sfio_t* f, const char* command, const char* mode)
+#else
+Sfio_t* sfpopen(f,command,mode)
+Sfio_t* f;
+char* command; /* command to execute */
+char* mode; /* mode of the stream */
+#endif
+{
+#if _PACKAGE_ast
+ reg Proc_t* proc;
+ reg int sflags;
+ reg long flags;
+ reg int pflags;
+ char* av[4];
+
+ if (!command || !command[0] || !mode)
+ return 0;
+ sflags = _sftype(mode, NiL, NiL);
+
+ if(f == (Sfio_t*)(-1))
+ { /* stdio compatibility mode */
+ f = NIL(Sfio_t*);
+ pflags = 1;
+ }
+ else pflags = 0;
+
+ flags = 0;
+ if (sflags & SF_READ)
+ flags |= PROC_READ;
+ if (sflags & SF_WRITE)
+ flags |= PROC_WRITE;
+ av[0] = "sh";
+ av[1] = "-c";
+ av[2] = (char*)command;
+ av[3] = 0;
+ if (!(proc = procopen(0, av, 0, 0, flags)))
+ return 0;
+ if (!(f = sfnew(f, NIL(Void_t*), (size_t)SF_UNBOUND,
+ (sflags&SF_READ) ? proc->rfd : proc->wfd, sflags|((sflags&SF_RDWR)?0:SF_READ))) ||
+ _sfpopen(f, (sflags&SF_READ) ? proc->wfd : -1, proc->pid, pflags) < 0)
+ {
+ if (f) sfclose(f);
+ procclose(proc);
+ return 0;
+ }
+ procfree(proc);
+ return f;
+#else
+ reg int pid, fd, pkeep, ckeep, sflags;
+ int stdio, parent[2], child[2];
+ Sfio_t sf;
+
+ /* set shell meta characters */
+ if(Meta[0] == 0)
+ { reg char* s;
+ Meta[0] = 1;
+ for(s = "!@#$%&*(){}[]:;<>~`'|\"\\"; *s; ++s)
+ Meta[(uchar)s[0]] = 1;
+ }
+ if(!Path)
+ Path = _sfgetpath("PATH");
+
+ /* sanity check */
+ if(!command || !command[0] || !mode)
+ return NIL(Sfio_t*);
+ sflags = _sftype(mode,NIL(int*),NIL(int*));
+
+ /* make pipes */
+ parent[0] = parent[1] = child[0] = child[1] = -1;
+ if(sflags&SF_RDWR)
+ { if(syspipef(parent) < 0)
+ goto error;
+ if((sflags&SF_RDWR) == SF_RDWR && syspipef(child) < 0)
+ goto error;
+ }
+
+ switch((pid = fork()) )
+ {
+ default : /* in parent process */
+ if(sflags&SF_READ)
+ { pkeep = READ; ckeep = WRITE; }
+ else { pkeep = WRITE; ckeep = READ; }
+
+ if(f == (Sfio_t*)(-1))
+ { /* stdio compatibility mode */
+ f = NIL(Sfio_t*);
+ stdio = 1;
+ }
+ else stdio = 0;
+
+ /* make the streams */
+ if(!(f = sfnew(f,NIL(Void_t*),(size_t)SF_UNBOUND,parent[pkeep],sflags|((sflags&SF_RDWR)?0:SF_READ))))
+ goto error;
+ if(sflags&SF_RDWR)
+ { CLOSE(parent[!pkeep]);
+ SETCLOEXEC(parent[pkeep]);
+ if((sflags&SF_RDWR) == SF_RDWR)
+ { CLOSE(child[!ckeep]);
+ SETCLOEXEC(child[ckeep]);
+ }
+ }
+
+ /* save process info */
+ fd = (sflags&SF_RDWR) == SF_RDWR ? child[ckeep] : -1;
+ if(_sfpopen(f,fd,pid,stdio) < 0)
+ { (void)sfclose(f);
+ goto error;
+ }
+
+ return f;
+
+ case 0 : /* in child process */
+ /* determine what to keep */
+ if(sflags&SF_READ)
+ { pkeep = WRITE; ckeep = READ; }
+ else { pkeep = READ; ckeep = WRITE; }
+
+ /* zap fd that we don't need */
+ if(sflags&SF_RDWR)
+ { CLOSE(parent[!pkeep]);
+ if((sflags&SF_RDWR) == SF_RDWR)
+ CLOSE(child[!ckeep]);
+ }
+
+ /* use sfsetfd to make these descriptors the std-ones */
+ SFCLEAR(&sf,NIL(Vtmutex_t*));
+
+ /* must be careful so not to close something useful */
+ if((sflags&SF_RDWR) == SF_RDWR && pkeep == child[ckeep])
+ if((child[ckeep] = sysdupf(pkeep)) < 0)
+ _exit(EXIT_NOTFOUND);
+
+ if(sflags&SF_RDWR)
+ { if (parent[pkeep] != pkeep)
+ { sf.file = parent[pkeep];
+ CLOSE(pkeep);
+ if(sfsetfd(&sf,pkeep) != pkeep)
+ _exit(EXIT_NOTFOUND);
+ }
+ if((sflags&SF_RDWR) == SF_RDWR && child[ckeep] != ckeep)
+ { sf.file = child[ckeep];
+ CLOSE(ckeep);
+ if(sfsetfd(&sf,ckeep) != ckeep)
+ _exit(EXIT_NOTFOUND);
+ }
+ }
+
+ execute(command);
+ return NIL(Sfio_t*);
+
+ case -1 : /* error */
+ error:
+ if(parent[0] >= 0)
+ { CLOSE(parent[0]); CLOSE(parent[1]); }
+ if(child[0] >= 0)
+ { CLOSE(child[0]); CLOSE(child[1]); }
+ return NIL(Sfio_t*);
+ }
+#endif /*_PACKAGE_ast*/
+}
diff --git a/usr/src/lib/libast/common/sfio/sfprintf.c b/usr/src/lib/libast/common/sfio/sfprintf.c
new file mode 100644
index 0000000000..0fa85d6069
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfprintf.c
@@ -0,0 +1,116 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Print data with a given format
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+int sfprintf(Sfio_t* f, const char* form, ...)
+#else
+int sfprintf(va_alist)
+va_dcl
+#endif
+{
+ va_list args;
+ reg int rv;
+
+#if __STD_C
+ va_start(args,form);
+#else
+ reg Sfio_t* f;
+ reg char* form;
+ va_start(args);
+ f = va_arg(args,Sfio_t*);
+ form = va_arg(args,char*);
+#endif
+ rv = sfvprintf(f,form,args);
+
+ va_end(args);
+ return rv;
+}
+
+#if __STD_C
+ssize_t sfvsprintf(char* s, size_t n, const char* form, va_list args)
+#else
+ssize_t sfvsprintf(s, n, form, args)
+char* s;
+size_t n;
+char* form;
+va_list args;
+#endif
+{
+ Sfio_t *f;
+ ssize_t rv;
+
+ /* make a temp stream */
+ if(!(f = sfnew(NIL(Sfio_t*),NIL(char*),(size_t)SF_UNBOUND,
+ -1,SF_WRITE|SF_STRING)) )
+ return -1;
+
+ if((rv = sfvprintf(f,form,args)) < 0 )
+ return -1;
+ if(s && n > 0)
+ { if((rv+1) >= n)
+ n--;
+ else
+ n = rv;
+ memcpy(s, f->data, n);
+ s[n] = 0;
+ }
+
+ sfclose(f);
+
+ _Sfi = rv;
+
+ return rv;
+}
+
+#if __STD_C
+ssize_t sfsprintf(char* s, size_t n, const char* form, ...)
+#else
+ssize_t sfsprintf(va_alist)
+va_dcl
+#endif
+{
+ va_list args;
+ ssize_t rv;
+
+#if __STD_C
+ va_start(args,form);
+#else
+ reg char* s;
+ reg size_t n;
+ reg char* form;
+ va_start(args);
+ s = va_arg(args,char*);
+ n = va_arg(args,size_t);
+ form = va_arg(args,char*);
+#endif
+
+ rv = sfvsprintf(s,n,form,args);
+ va_end(args);
+
+ return rv;
+}
diff --git a/usr/src/lib/libast/common/sfio/sfprints.c b/usr/src/lib/libast/common/sfio/sfprints.c
new file mode 100644
index 0000000000..35f0f6017e
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfprints.c
@@ -0,0 +1,125 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Construct a string with the given format and data.
+** These functions allocate space as necessary to store the string.
+** This avoids overflow problems typical with sprintf() in stdio.
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+char* sfvprints(const char* form, va_list args)
+#else
+char* sfvprints(form, args)
+char* form;
+va_list args;
+#endif
+{
+ reg int rv;
+ static Sfio_t* f;
+
+ /* make a fake stream */
+ if(!f &&
+ !(f = sfnew(NIL(Sfio_t*),NIL(char*),(size_t)SF_UNBOUND,
+ -1,SF_WRITE|SF_STRING)) )
+ return NIL(char*);
+
+ sfseek(f,(Sfoff_t)0,SEEK_SET);
+ rv = sfvprintf(f,form,args);
+
+ if(rv < 0 || sfputc(f,'\0') < 0)
+ return NIL(char*);
+
+ _Sfi = (f->next - f->data) - 1;
+ return (char*)f->data;
+}
+
+#if __STD_C
+char* sfprints(const char* form, ...)
+#else
+char* sfprints(va_alist)
+va_dcl
+#endif
+{
+ char* s;
+ va_list args;
+
+#if __STD_C
+ va_start(args,form);
+#else
+ char *form;
+ va_start(args);
+ form = va_arg(args,char*);
+#endif
+ s = sfvprints(form, args);
+ va_end(args);
+
+ return s;
+}
+
+#if __STD_C
+ssize_t sfvaprints(char** sp, const char* form, va_list args)
+#else
+ssize_t sfvaprints(sp, form, args)
+char** sp;
+char* form;
+va_list args;
+#endif
+{
+ char *s;
+ ssize_t n;
+
+ if(!sp || !(s = sfvprints(form,args)) )
+ return -1;
+ else
+ { if(!(*sp = (char*)malloc(n = strlen(s)+1)) )
+ return -1;
+ memcpy(*sp, s, n);
+ return n;
+ }
+}
+
+#if __STD_C
+ssize_t sfaprints(char** sp, const char* form, ...)
+#else
+ssize_t sfaprints(va_alist)
+va_dcl
+#endif
+{
+ ssize_t n;
+ va_list args;
+
+#if __STD_C
+ va_start(args,form);
+#else
+ char **sp, *form;
+ va_start(args);
+ sp = va_arg(args, char**);
+ form = va_arg(args, char*);
+#endif
+ n = sfvaprints(sp, form, args);
+ va_end(args);
+
+ return n;
+}
diff --git a/usr/src/lib/libast/common/sfio/sfpurge.c b/usr/src/lib/libast/common/sfio/sfpurge.c
new file mode 100644
index 0000000000..4c1716bcee
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfpurge.c
@@ -0,0 +1,97 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Delete all pending data in the buffer
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+int sfpurge(reg Sfio_t* f)
+#else
+int sfpurge(f)
+reg Sfio_t* f;
+#endif
+{
+ reg int mode;
+
+ SFMTXSTART(f,-1);
+
+ if((mode = f->mode&SF_RDWR) != (int)f->mode && _sfmode(f,mode|SF_SYNCED,0) < 0)
+ SFMTXRETURN(f, -1);
+
+ if((f->flags&SF_IOCHECK) && f->disc && f->disc->exceptf)
+ (void)(*f->disc->exceptf)(f,SF_PURGE,(Void_t*)((int)1),f->disc);
+
+ if(f->disc == _Sfudisc)
+ (void)sfclose((*_Sfstack)(f,NIL(Sfio_t*)));
+
+ /* cannot purge read string streams */
+ if((f->flags&SF_STRING) && (f->mode&SF_READ) )
+ goto done;
+
+ SFLOCK(f,0);
+
+ /* if memory map must be a read stream, pretend data is gone */
+#ifdef MAP_TYPE
+ if(f->bits&SF_MMAP)
+ { f->here -= f->endb - f->next;
+ if(f->data)
+ { SFMUNMAP(f,f->data,f->endb-f->data);
+ SFSK(f,f->here,SEEK_SET,f->disc);
+ }
+ SFOPEN(f,0);
+ SFMTXRETURN(f, 0);
+ }
+#endif
+
+ switch(f->mode&~SF_LOCK)
+ {
+ default :
+ SFOPEN(f,0);
+ SFMTXRETURN(f, -1);
+ case SF_WRITE :
+ f->next = f->data;
+ if(!f->proc || !(f->flags&SF_READ) || !(f->mode&SF_WRITE) )
+ break;
+
+ /* 2-way pipe, must clear read buffer */
+ (void)_sfmode(f,SF_READ,1);
+ /* fall through */
+ case SF_READ:
+ if(f->extent >= 0 && f->endb > f->next)
+ { f->here -= f->endb-f->next;
+ SFSK(f,f->here,SEEK_SET,f->disc);
+ }
+ f->endb = f->next = f->data;
+ break;
+ }
+
+ SFOPEN(f,0);
+
+done:
+ if((f->flags&SF_IOCHECK) && f->disc && f->disc->exceptf)
+ (void)(*f->disc->exceptf)(f,SF_PURGE,(Void_t*)((int)0),f->disc);
+
+ SFMTXRETURN(f, 0);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfputd.c b/usr/src/lib/libast/common/sfio/sfputd.c
new file mode 100644
index 0000000000..08a03ecdba
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfputd.c
@@ -0,0 +1,35 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+#undef sfputd
+
+#if __STD_C
+int sfputd(reg Sfio_t* f, Sfdouble_t d)
+#else
+int sfputd(f,d)
+reg Sfio_t* f;
+reg Sfdouble_t d;
+#endif
+{
+ return __sf_putd(f,d);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfputl.c b/usr/src/lib/libast/common/sfio/sfputl.c
new file mode 100644
index 0000000000..3a77764505
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfputl.c
@@ -0,0 +1,35 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+#undef sfputl
+
+#if __STD_C
+int sfputl(reg Sfio_t* f, Sflong_t l)
+#else
+int sfputl(f,l)
+reg Sfio_t* f;
+reg Sflong_t l;
+#endif
+{
+ return __sf_putl(f,l);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfputm.c b/usr/src/lib/libast/common/sfio/sfputm.c
new file mode 100644
index 0000000000..c48700e7d3
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfputm.c
@@ -0,0 +1,36 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+#undef sfputm
+
+#if __STD_C
+int sfputm(Sfio_t* f, Sfulong_t u, Sfulong_t m)
+#else
+int sfputm(f,u,m)
+Sfio_t* f;
+Sfulong_t u;
+Sfulong_t m;
+#endif
+{
+ return __sf_putm(f, u, m);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfputr.c b/usr/src/lib/libast/common/sfio/sfputr.c
new file mode 100644
index 0000000000..7f2da997a5
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfputr.c
@@ -0,0 +1,121 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Put out a null-terminated string
+**
+** Written by Kiem-Phong Vo.
+*/
+#if __STD_C
+ssize_t sfputr(reg Sfio_t* f, const char* s, reg int rc)
+#else
+ssize_t sfputr(f,s,rc)
+reg Sfio_t* f; /* write to this stream */
+char* s; /* string to write */
+reg int rc; /* record separator. */
+#endif
+{
+ reg ssize_t p, n, w;
+ reg uchar* ps;
+
+ SFMTXSTART(f,-1);
+
+ if(f->mode != SF_WRITE && _sfmode(f,SF_WRITE,0) < 0)
+ SFMTXRETURN(f, -1);
+
+ SFLOCK(f,0);
+
+ for(w = 0; (*s || rc >= 0); )
+ { SFWPEEK(f,ps,p);
+
+ if(p == 0 || (f->flags&SF_WHOLE) )
+ { n = strlen(s);
+ if(p >= (n + (rc < 0 ? 0 : 1)) )
+ { /* buffer can hold everything */
+ if(n > 0)
+ { memcpy(ps, s, n);
+ ps += n;
+ w += n;
+ }
+ if(rc >= 0)
+ { *ps++ = rc;
+ w += 1;
+ }
+ f->next = ps;
+ }
+ else
+ { /* create a reserve buffer to hold data */
+ Sfrsrv_t* rsrv;
+
+ p = n + (rc >= 0 ? 1 : 0);
+ if(!(rsrv = _sfrsrv(f, p)) )
+ n = 0;
+ else
+ { if(n > 0)
+ memcpy(rsrv->data, s, n);
+ if(rc >= 0)
+ rsrv->data[n] = rc;
+ if((n = SFWRITE(f,rsrv->data,p)) < 0 )
+ n = 0;
+ }
+
+ w += n;
+ }
+ break;
+ }
+
+ if(*s == 0)
+ { *ps++ = rc;
+ f->next = ps;
+ w += 1;
+ break;
+ }
+
+#if _lib_memccpy && !__ia64 /* these guys may never get it right */
+ if((ps = (uchar*)memccpy(ps,s,'\0',p)) != NIL(uchar*))
+ ps -= 1;
+ else ps = f->next+p;
+ s += ps - f->next;
+#else
+ for(; p > 0; --p, ++ps, ++s)
+ if((*ps = *s) == 0)
+ break;
+#endif
+ w += ps - f->next;
+ f->next = ps;
+ }
+
+ /* sync unseekable shared streams */
+ if(f->extent < 0 && (f->flags&SF_SHARE) )
+ (void)SFFLSBUF(f,-1);
+
+ /* check for line buffering */
+ else if((f->flags&SF_LINE) && !(f->flags&SF_STRING) && (n = f->next-f->data) > 0)
+ { if(n > w)
+ n = w;
+ f->next -= n;
+ (void)SFWRITE(f,(Void_t*)f->next,n);
+ }
+
+ SFOPEN(f,0);
+ SFMTXRETURN(f, w);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfputu.c b/usr/src/lib/libast/common/sfio/sfputu.c
new file mode 100644
index 0000000000..28061e6e43
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfputu.c
@@ -0,0 +1,35 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+#undef sfputu
+
+#if __STD_C
+int sfputu(reg Sfio_t* f, Sfulong_t u)
+#else
+int sfputu(f,u)
+reg Sfio_t* f;
+reg Sfulong_t u;
+#endif
+{
+ return __sf_putu(f,u);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfraise.c b/usr/src/lib/libast/common/sfio/sfraise.c
new file mode 100644
index 0000000000..bf37338e0d
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfraise.c
@@ -0,0 +1,106 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Invoke event handlers for a stream
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+static int _sfraiseall(int type, Void_t* data)
+#else
+static int _sfraiseall(type, data)
+int type; /* type of event */
+Void_t* data; /* associated data */
+#endif
+{
+ Sfio_t *f;
+ Sfpool_t *p, *next;
+ int n, rv;
+
+ rv = 0;
+ for(p = &_Sfpool; p; p = next)
+ {
+ for(next = p->next; next; next = next->next)
+ if(next->n_sf > 0)
+ break;
+ for(n = 0; n < p->n_sf; ++n)
+ { f = p->sf[n];
+ if(sfraise(f, type, data) < 0)
+ rv -= 1;
+ }
+ }
+ return rv;
+}
+
+#if __STD_C
+int sfraise(Sfio_t* f, int type, Void_t* data)
+#else
+int sfraise(f, type, data)
+Sfio_t* f; /* stream */
+int type; /* type of event */
+Void_t* data; /* associated data */
+#endif
+{
+ reg Sfdisc_t *disc, *next, *d;
+ reg int local, rv;
+
+ if(!f)
+ return _sfraiseall(type,data);
+
+ SFMTXSTART(f, -1);
+
+ GETLOCAL(f,local);
+ if(!SFKILLED(f) &&
+ !(local &&
+ (type == SF_NEW || type == SF_CLOSING ||
+ type == SF_FINAL || type == SF_ATEXIT)) &&
+ SFMODE(f,local) != (f->mode&SF_RDWR) && _sfmode(f,0,local) < 0)
+ SFMTXRETURN(f, -1);
+ SFLOCK(f,local);
+
+ for(disc = f->disc; disc; )
+ { next = disc->disc;
+ if(type == SF_FINAL)
+ f->disc = next;
+
+ if(disc->exceptf)
+ { SFOPEN(f,0);
+ if((rv = (*disc->exceptf)(f,type,data,disc)) != 0 )
+ SFMTXRETURN(f, rv);
+ SFLOCK(f,0);
+ }
+
+ if((disc = next) )
+ { /* make sure that "next" hasn't been popped */
+ for(d = f->disc; d; d = d->disc)
+ if(d == disc)
+ break;
+ if(!d)
+ disc = f->disc;
+ }
+ }
+
+ SFOPEN(f,local);
+ SFMTXRETURN(f, 0);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfrd.c b/usr/src/lib/libast/common/sfio/sfrd.c
new file mode 100644
index 0000000000..6ad4c5fb3d
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfrd.c
@@ -0,0 +1,316 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Internal function to do a hard read.
+** This knows about discipline and memory mapping, peek read.
+**
+** Written by Kiem-Phong Vo.
+*/
+
+/* synchronize unseekable write streams */
+#if __STD_C
+static void _sfwrsync(void)
+#else
+static void _sfwrsync()
+#endif
+{ reg Sfpool_t* p;
+ reg Sfio_t* f;
+ reg int n;
+
+ /* sync all pool heads */
+ for(p = _Sfpool.next; p; p = p->next)
+ { if(p->n_sf <= 0)
+ continue;
+ f = p->sf[0];
+ if(!SFFROZEN(f) && f->next > f->data &&
+ (f->mode&SF_WRITE) && f->extent < 0 )
+ (void)_sfflsbuf(f,-1);
+ }
+
+ /* and all the ones in the discrete pool */
+ for(n = 0; n < _Sfpool.n_sf; ++n)
+ { f = _Sfpool.sf[n];
+
+ if(!SFFROZEN(f) && f->next > f->data &&
+ (f->mode&SF_WRITE) && f->extent < 0 )
+ (void)_sfflsbuf(f,-1);
+ }
+}
+
+#if __STD_C
+ssize_t sfrd(reg Sfio_t* f, reg Void_t* buf, reg size_t n, Sfdisc_t* disc)
+#else
+ssize_t sfrd(f,buf,n,disc)
+reg Sfio_t* f;
+reg Void_t* buf;
+reg size_t n;
+Sfdisc_t* disc;
+#endif
+{
+ Sfoff_t r;
+ reg Sfdisc_t* dc;
+ reg int local, rcrv, dosync, oerrno;
+
+ SFMTXSTART(f,-1);
+
+ GETLOCAL(f,local);
+ if((rcrv = f->mode & (SF_RC|SF_RV)) )
+ f->mode &= ~(SF_RC|SF_RV);
+ f->bits &= ~SF_JUSTSEEK;
+
+ if(f->mode&SF_PKRD)
+ SFMTXRETURN(f, -1);
+
+ if(!local && !(f->bits&SF_DCDOWN)) /* an external user's call */
+ { if(f->mode != SF_READ && _sfmode(f,SF_READ,0) < 0)
+ SFMTXRETURN(f, -1);
+ if(f->next < f->endb)
+ { if(SFSYNC(f) < 0)
+ SFMTXRETURN(f, -1);
+ if((f->mode&(SF_SYNCED|SF_READ)) == (SF_SYNCED|SF_READ) )
+ { f->endb = f->next = f->endr = f->data;
+ f->mode &= ~SF_SYNCED;
+ }
+#ifdef MAP_TYPE
+ if((f->bits&SF_MMAP) && f->data)
+ { SFMUNMAP(f, f->data, f->endb-f->data);
+ f->data = NIL(uchar*);
+ }
+#endif
+ f->next = f->endb = f->endr = f->endw = f->data;
+ }
+ }
+
+ for(dosync = 0;;)
+ { /* stream locked by sfsetfd() */
+ if(!(f->flags&SF_STRING) && f->file < 0)
+ SFMTXRETURN(f, 0);
+
+ f->flags &= ~(SF_EOF|SF_ERROR);
+
+ dc = disc;
+ if(f->flags&SF_STRING)
+ { if((r = (f->data+f->extent) - f->next) < 0)
+ r = 0;
+ if(r <= 0)
+ goto do_except;
+ SFMTXRETURN(f, (ssize_t)r);
+ }
+
+ /* warn that a read is about to happen */
+ SFDISC(f,dc,readf);
+ if(dc && dc->exceptf && (f->flags&SF_IOCHECK) )
+ { reg int rv;
+ if(local)
+ SETLOCAL(f);
+ if((rv = _sfexcept(f,SF_READ,n,dc)) > 0)
+ n = rv;
+ else if(rv < 0)
+ { f->flags |= SF_ERROR;
+ SFMTXRETURN(f, (ssize_t)rv);
+ }
+ }
+
+#ifdef MAP_TYPE
+ if(f->bits&SF_MMAP)
+ { reg ssize_t a, round;
+ sfstat_t st;
+
+ /* determine if we have to copy data to buffer */
+ if((uchar*)buf >= f->data && (uchar*)buf <= f->endb)
+ { n += f->endb - f->next;
+ buf = NIL(char*);
+ }
+
+ /* actual seek location */
+ if((f->flags&(SF_SHARE|SF_PUBLIC)) == (SF_SHARE|SF_PUBLIC) &&
+ (r = SFSK(f,(Sfoff_t)0,SEEK_CUR,dc)) != f->here)
+ f->here = r;
+ else f->here -= f->endb-f->next;
+
+ /* before mapping, make sure we have data to map */
+ if((f->flags&SF_SHARE) || (size_t)(r = f->extent-f->here) < n)
+ { if((r = sysfstatf(f->file,&st)) < 0)
+ goto do_except;
+ if((r = (f->extent = st.st_size) - f->here) <= 0 )
+ { r = 0; /* eof */
+ goto do_except;
+ }
+ }
+
+ /* make sure current position is page aligned */
+ if((a = (size_t)(f->here%_Sfpage)) != 0)
+ { f->here -= a;
+ r += a;
+ }
+
+ /* map minimal requirement */
+ if(r > (round = (1 + (n+a)/f->size)*f->size) )
+ r = round;
+
+ if(f->data)
+ SFMUNMAP(f, f->data, f->endb-f->data);
+
+ for(;;)
+ { f->data = (uchar*) sysmmapf((caddr_t)0, (size_t)r,
+ (PROT_READ|PROT_WRITE),
+ MAP_PRIVATE,
+ f->file, (sfoff_t)f->here);
+ if(f->data && (caddr_t)f->data != (caddr_t)(-1))
+ break;
+ else
+ { f->data = NIL(uchar*);
+ if((r >>= 1) < (_Sfpage*SF_NMAP) ||
+ (errno != EAGAIN && errno != ENOMEM) )
+ break;
+ }
+ }
+
+ if(f->data)
+ { if(f->bits&SF_SEQUENTIAL)
+ SFMMSEQON(f,f->data,r);
+ f->next = f->data+a;
+ f->endr = f->endb = f->data+r;
+ f->endw = f->data;
+ f->here += r;
+
+ /* make known our seek location */
+ (void)SFSK(f,f->here,SEEK_SET,dc);
+
+ if(buf)
+ { if(n > (size_t)(r-a))
+ n = (ssize_t)(r-a);
+ memcpy(buf,f->next,n);
+ f->next += n;
+ }
+ else n = f->endb - f->next;
+
+ SFMTXRETURN(f, n);
+ }
+ else
+ { r = -1;
+ f->here += a;
+
+ /* reset seek pointer to its physical location */
+ (void)SFSK(f,f->here,SEEK_SET,dc);
+
+ /* make a buffer */
+ (void)SFSETBUF(f,(Void_t*)f->tiny,(size_t)SF_UNBOUND);
+
+ if(!buf)
+ { buf = (Void_t*)f->data;
+ n = f->size;
+ }
+ }
+ }
+#endif
+
+ /* sync unseekable write streams to prevent deadlock */
+ if(!dosync && f->extent < 0)
+ { dosync = 1;
+ _sfwrsync();
+ }
+
+ /* make sure file pointer is right */
+ if(f->extent >= 0 && (f->flags&SF_SHARE) )
+ { if(!(f->flags&SF_PUBLIC) )
+ f->here = SFSK(f,f->here,SEEK_SET,dc);
+ else f->here = SFSK(f,(Sfoff_t)0,SEEK_CUR,dc);
+ }
+
+ oerrno = errno;
+ errno = 0;
+
+ if(dc && dc->readf)
+ { int share = f->flags&SF_SHARE;
+
+ if(rcrv) /* pass on rcrv for possible continuations */
+ f->mode |= rcrv;
+ /* tell readf that no peeking necessary */
+ else f->flags &= ~SF_SHARE;
+
+ SFDCRD(f,buf,n,dc,r);
+
+ /* reset flags */
+ if(rcrv)
+ f->mode &= ~rcrv;
+ else f->flags |= share;
+ }
+ else if(SFISNULL(f))
+ r = 0;
+ else if(f->extent < 0 && (f->flags&SF_SHARE) && rcrv)
+ { /* try peek read */
+ r = sfpkrd(f->file, (char*)buf, n,
+ (rcrv&SF_RC) ? (int)f->getr : -1,
+ -1L, (rcrv&SF_RV) ? 1 : 0);
+ if(r > 0)
+ { if(rcrv&SF_RV)
+ f->mode |= SF_PKRD;
+ else f->mode |= SF_RC;
+ }
+ }
+ else r = sysreadf(f->file,buf,n);
+
+ if(errno == 0 )
+ errno = oerrno;
+
+ if(r > 0 )
+ { if(!(f->bits&SF_DCDOWN) ) /* not a continuation call */
+ { if(!(f->mode&SF_PKRD) )
+ { f->here += r;
+ if(f->extent >= 0 && f->extent < f->here)
+ f->extent = f->here;
+ }
+ if((uchar*)buf >= f->data &&
+ (uchar*)buf < f->data+f->size)
+ f->endb = f->endr = ((uchar*)buf) + r;
+ }
+
+ SFMTXRETURN(f, (ssize_t)r);
+ }
+
+ do_except:
+ if(local)
+ SETLOCAL(f);
+ switch(_sfexcept(f,SF_READ,(ssize_t)r,dc))
+ {
+ case SF_ECONT :
+ goto do_continue;
+ case SF_EDONE :
+ n = local ? 0 : (ssize_t)r;
+ SFMTXRETURN(f,n);
+ case SF_EDISC :
+ if(!local && !(f->flags&SF_STRING))
+ goto do_continue;
+ /* else fall thru */
+ case SF_ESTACK :
+ SFMTXRETURN(f, -1);
+ }
+
+ do_continue:
+ for(dc = f->disc; dc; dc = dc->disc)
+ if(dc == disc)
+ break;
+ disc = dc;
+ }
+}
diff --git a/usr/src/lib/libast/common/sfio/sfread.c b/usr/src/lib/libast/common/sfio/sfread.c
new file mode 100644
index 0000000000..945491d836
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfread.c
@@ -0,0 +1,139 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Read n bytes from a stream into a buffer
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+ssize_t sfread(reg Sfio_t* f, Void_t* buf, reg size_t n)
+#else
+ssize_t sfread(f,buf,n)
+reg Sfio_t* f; /* read from this stream. */
+Void_t* buf; /* buffer to read into */
+reg size_t n; /* number of bytes to be read. */
+#endif
+{
+ reg uchar *s, *begs;
+ reg ssize_t r;
+ reg int local, justseek;
+
+ SFMTXSTART(f, (ssize_t)(-1));
+
+ GETLOCAL(f,local);
+ justseek = f->bits&SF_JUSTSEEK; f->bits &= ~SF_JUSTSEEK;
+
+ if(!buf)
+ SFMTXRETURN(f, (ssize_t)(n == 0 ? 0 : -1) );
+
+ /* release peek lock */
+ if(f->mode&SF_PEEK)
+ { if(!(f->mode&SF_READ) )
+ SFMTXRETURN(f, (ssize_t)(-1));
+
+ if(f->mode&SF_GETR)
+ { if(((uchar*)buf + f->val) != f->next &&
+ (!f->rsrv || f->rsrv->data != (uchar*)buf) )
+ SFMTXRETURN(f, (ssize_t)(-1));
+ f->mode &= ~SF_PEEK;
+ SFMTXRETURN(f, 0);
+ }
+ else
+ { if((uchar*)buf != f->next)
+ SFMTXRETURN(f, (ssize_t)(-1));
+ f->mode &= ~SF_PEEK;
+ if(f->mode&SF_PKRD)
+ { /* actually read the data now */
+ f->mode &= ~SF_PKRD;
+ if(n > 0)
+ n = (r = sysreadf(f->file,f->data,n)) < 0 ? 0 : r;
+ f->endb = f->data+n;
+ f->here += n;
+ }
+ f->next += n;
+ f->endr = f->endb;
+ SFMTXRETURN(f, n);
+ }
+ }
+
+ s = begs = (uchar*)buf;
+ for(;; f->mode &= ~SF_LOCK)
+ { /* check stream mode */
+ if(SFMODE(f,local) != SF_READ && _sfmode(f,SF_READ,local) < 0)
+ { n = s > begs ? s-begs : (size_t)(-1);
+ SFMTXRETURN(f, (ssize_t)n);
+ }
+
+ SFLOCK(f,local);
+
+ if((r = f->endb - f->next) > 0) /* has buffered data */
+ { if(r > (ssize_t)n)
+ r = (ssize_t)n;
+ if(s != f->next)
+ memcpy(s, f->next, r);
+ f->next += r;
+ s += r;
+ n -= r;
+ }
+
+ if(n <= 0) /* all done */
+ break;
+
+ if(!(f->flags&SF_STRING) && !(f->bits&SF_MMAP) )
+ { f->next = f->endb = f->data;
+
+ /* exact IO is desirable for these cases */
+ if(SFDIRECT(f,n) ||
+ ((f->flags&SF_SHARE) && f->extent < 0) )
+ r = (ssize_t)n;
+ else if(justseek && n <= f->iosz && f->iosz <= f->size)
+ r = f->iosz; /* limit buffering */
+ else r = f->size; /* full buffering */
+
+ /* if read almost full size, then just do it direct */
+ if(r > (ssize_t)n && (r - r/8) <= (ssize_t)n)
+ r = (ssize_t)n;
+
+ /* read directly to user's buffer */
+ if(r == (ssize_t)n && (r = SFRD(f,s,r,f->disc)) >= 0)
+ { s += r;
+ n -= r;
+ if(r == 0 || n == 0) /* eof or eob */
+ break;
+ }
+ else goto do_filbuf;
+ }
+ else
+ { do_filbuf:
+ if(justseek)
+ f->bits |= SF_JUSTSEEK;
+ if(SFFILBUF(f,-1) <= 0)
+ break;
+ }
+ }
+
+ SFOPEN(f,local);
+ r = s-begs;
+ SFMTXRETURN(f, r);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfreserve.c b/usr/src/lib/libast/common/sfio/sfreserve.c
new file mode 100644
index 0000000000..27e7749618
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfreserve.c
@@ -0,0 +1,197 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Reserve a segment of data or buffer.
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+Void_t* sfreserve(reg Sfio_t* f, ssize_t size, int type)
+#else
+Void_t* sfreserve(f,size,type)
+reg Sfio_t* f; /* file to peek */
+ssize_t size; /* size of peek */
+int type; /* LOCKR: lock stream, LASTR: last record */
+#endif
+{
+ reg ssize_t n, now, sz, iosz;
+ reg Sfrsrv_t* rsrv;
+ reg Void_t* data;
+ reg int mode, local;
+
+ SFMTXSTART(f,NIL(Void_t*));
+
+ sz = size < 0 ? -size : size;
+
+ /* see if we need to bias toward SF_WRITE instead of the default SF_READ */
+ if(type < 0)
+ mode = 0;
+ else if((mode = type&SF_WRITE) )
+ type &= ~SF_WRITE;
+
+ /* return the last record */
+ if(type == SF_LASTR )
+ { if((n = f->endb - f->next) > 0 && n == f->val )
+ { data = (Void_t*)f->next;
+ f->next += n;
+ }
+ else if((rsrv = f->rsrv) && (n = -rsrv->slen) > 0)
+ { rsrv->slen = 0;
+ _Sfi = f->val = n;
+ data = (Void_t*)rsrv->data;
+ }
+ else
+ { _Sfi = f->val = -1;
+ data = NIL(Void_t*);
+ }
+
+ SFMTXRETURN(f, data);
+ }
+
+ if(type > 0)
+ { if(type == 1 ) /* upward compatibility mode */
+ type = SF_LOCKR;
+ else if(type != SF_LOCKR)
+ SFMTXRETURN(f, NIL(Void_t*));
+ }
+
+ if(size == 0 && (type < 0 || type == SF_LOCKR) )
+ { if((f->mode&SF_RDWR) != f->mode && _sfmode(f,0,0) < 0)
+ SFMTXRETURN(f, NIL(Void_t*));
+
+ SFLOCK(f,0);
+ if((n = f->endb - f->next) < 0)
+ n = 0;
+
+ goto done;
+ }
+
+ /* iterate until get to a stream that has data or buffer space */
+ for(local = 0;; local = SF_LOCAL)
+ { _Sfi = f->val = -1;
+
+ if(!mode && !(mode = f->flags&SF_READ) )
+ mode = SF_WRITE;
+ if((int)f->mode != mode && _sfmode(f,mode,local) < 0)
+ { SFOPEN(f,0);
+ SFMTXRETURN(f, NIL(Void_t*));
+ }
+
+ SFLOCK(f,local);
+
+ if((n = now = f->endb - f->next) < 0)
+ n = 0;
+ if(n > 0 && n >= sz) /* all done */
+ break;
+
+ /* amount to perform IO */
+ if(size == 0 || (f->mode&SF_WRITE) )
+ iosz = -1;
+ else
+ { iosz = sz - n;
+ if(type != SF_LOCKR && size < 0 && iosz < (f->size - n) )
+ iosz = f->size - n;
+ if(iosz <= 0)
+ break;
+ }
+
+ /* do a buffer refill or flush */
+ now = n;
+ if(f->mode&SF_WRITE)
+ (void)SFFLSBUF(f, iosz);
+ else if(type == SF_LOCKR && f->extent < 0 && (f->flags&SF_SHARE) )
+ { if(n == 0) /* peek-read only if there is no buffered data */
+ { f->mode |= SF_RV;
+ (void)SFFILBUF(f, iosz );
+ }
+ if((n = f->endb - f->next) < sz)
+ { if(f->mode&SF_PKRD)
+ { f->endb = f->endr = f->next;
+ f->mode &= ~SF_PKRD;
+ }
+ break;
+ }
+ }
+ else (void)SFFILBUF(f, iosz );
+
+ if((n = f->endb - f->next) <= 0)
+ n = 0;
+
+ if(n >= sz) /* got it */
+ break;
+
+ if(n == now || sferror(f) || sfeof(f)) /* no progress */
+ break;
+
+ /* request was only to assess data availability */
+ if(type == SF_LOCKR && size > 0 && n > 0 )
+ break;
+ }
+
+done: /* compute the buffer to be returned */
+ data = NIL(Void_t*);
+ if(size == 0 || n == 0)
+ { if(n > 0) /* got data */
+ data = (Void_t*)f->next;
+ else if(type == SF_LOCKR && size == 0 && (rsrv = _sfrsrv(f,0)) )
+ data = (Void_t*)rsrv->data;
+ }
+ else if(n >= sz) /* got data */
+ data = (Void_t*)f->next;
+ else if(f->flags&SF_STRING) /* try extending string buffer */
+ { if((f->mode&SF_WRITE) && (f->flags&SF_MALLOC) )
+ { (void)SFWR(f,f->next,sz,f->disc);
+ if((n = f->endb - f->next) >= sz )
+ data = (Void_t*)f->next;
+ }
+ }
+ else if(f->mode&SF_WRITE) /* allocate side buffer */
+ { if(type == SF_LOCKR && (rsrv = _sfrsrv(f, sz)) )
+ data = (Void_t*)rsrv->data;
+ }
+ else if(type != SF_LOCKR && sz > f->size && (rsrv = _sfrsrv(f,sz)) )
+ { if((n = SFREAD(f,(Void_t*)rsrv->data,sz)) >= sz) /* read side buffer */
+ data = (Void_t*)rsrv->data;
+ else rsrv->slen = -n;
+ }
+
+ SFOPEN(f,0);
+
+ if(data)
+ { if(type == SF_LOCKR)
+ { f->mode |= SF_PEEK;
+ if((f->mode & SF_READ) && size == 0 && data != f->next)
+ f->mode |= SF_GETR; /* so sfread() will unlock */
+ f->endr = f->endw = f->data;
+ }
+ else
+ { if(data == (Void_t*)f->next)
+ f->next += (size >= 0 ? size : n);
+ }
+ }
+
+ _Sfi = f->val = n; /* return true buffer size */
+
+ SFMTXRETURN(f, data);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfresize.c b/usr/src/lib/libast/common/sfio/sfresize.c
new file mode 100644
index 0000000000..170e2363ac
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfresize.c
@@ -0,0 +1,81 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Resize a stream.
+ Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+int sfresize(Sfio_t* f, Sfoff_t size)
+#else
+int sfresize(f, size)
+Sfio_t* f;
+Sfoff_t size;
+#endif
+{
+ SFMTXSTART(f, -1);
+
+ if(size < 0 || f->extent < 0 ||
+ (f->mode != SF_WRITE && _sfmode(f,SF_WRITE,0) < 0) )
+ SFMTXRETURN(f, -1);
+
+ SFLOCK(f,0);
+
+ if(f->flags&SF_STRING)
+ { SFSTRSIZE(f);
+
+ if(f->extent >= size)
+ { if((f->flags&SF_MALLOC) && (f->next - f->data) <= size)
+ { size_t s = (((size_t)size + 1023)/1024)*1024;
+ Void_t* d;
+ if(s < f->size && (d = realloc(f->data, s)) )
+ { f->data = d;
+ f->size = s;
+ f->extent = s;
+ }
+ }
+ memclear((char*)(f->data+size), (int)(f->extent-size));
+ }
+ else
+ { if(SFSK(f, size, SEEK_SET, f->disc) != size)
+ SFMTXRETURN(f, -1);
+ memclear((char*)(f->data+f->extent), (int)(size-f->extent));
+ }
+ }
+ else
+ { if(f->next > f->data)
+ SFSYNC(f);
+#if _lib_ftruncate
+ if(ftruncate(f->file, (sfoff_t)size) < 0)
+ SFMTXRETURN(f, -1);
+#else
+ SFMTXRETURN(f, -1);
+#endif
+ }
+
+ f->extent = size;
+
+ SFOPEN(f, 0);
+
+ SFMTXRETURN(f, 0);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfscanf.c b/usr/src/lib/libast/common/sfio/sfscanf.c
new file mode 100644
index 0000000000..322e540c89
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfscanf.c
@@ -0,0 +1,102 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Read formated data from a stream
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+int sfscanf(Sfio_t* f, const char* form, ...)
+#else
+int sfscanf(va_alist)
+va_dcl
+#endif
+{
+ va_list args;
+ reg int rv;
+
+#if __STD_C
+ va_start(args,form);
+#else
+ reg Sfio_t* f;
+ reg char* form;
+ va_start(args);
+ f = va_arg(args,Sfio_t*);
+ form = va_arg(args,char*);
+#endif
+
+ rv = (f && form) ? sfvscanf(f,form,args) : -1;
+ va_end(args);
+ return rv;
+}
+
+#if __STD_C
+int sfvsscanf(const char* s, const char* form, va_list args)
+#else
+int sfvsscanf(s, form, args)
+char* s;
+char* form;
+va_list args;
+#endif
+{
+ Sfio_t f;
+
+ if(!s || !form)
+ return -1;
+
+ /* make a fake stream */
+ SFCLEAR(&f,NIL(Vtmutex_t*));
+ f.flags = SF_STRING|SF_READ;
+ f.bits = SF_PRIVATE;
+ f.mode = SF_READ;
+ f.size = strlen((char*)s);
+ f.data = f.next = f.endw = (uchar*)s;
+ f.endb = f.endr = f.data+f.size;
+
+ return sfvscanf(&f,form,args);
+}
+
+#if __STD_C
+int sfsscanf(const char* s, const char* form,...)
+#else
+int sfsscanf(va_alist)
+va_dcl
+#endif
+{
+ va_list args;
+ reg int rv;
+#if __STD_C
+ va_start(args,form);
+#else
+ reg char* s;
+ reg char* form;
+ va_start(args);
+ s = va_arg(args,char*);
+ form = va_arg(args,char*);
+#endif
+
+ rv = (s && form) ? sfvsscanf(s,form,args) : -1;
+ va_end(args);
+ return rv;
+}
diff --git a/usr/src/lib/libast/common/sfio/sfseek.c b/usr/src/lib/libast/common/sfio/sfseek.c
new file mode 100644
index 0000000000..b330338cc6
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfseek.c
@@ -0,0 +1,280 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Set the IO pointer to a specific location in the stream
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+static void newpos(Sfio_t* f, Sfoff_t p)
+#else
+static void newpos(f, p)
+Sfio_t* f;
+Sfoff_t p;
+#endif
+{
+#ifdef MAP_TYPE
+ if((f->bits&SF_MMAP) && f->data)
+ { SFMUNMAP(f, f->data, f->endb-f->data);
+ f->data = NIL(uchar*);
+ }
+#endif
+ f->next = f->endr = f->endw = f->data;
+ f->endb = (f->mode&SF_WRITE) ? f->data+f->size : f->data;
+ if((f->here = p) < 0)
+ { f->extent = -1;
+ f->here = 0;
+ }
+}
+
+#if __STD_C
+Sfoff_t sfseek(Sfio_t* f, Sfoff_t p, int type)
+#else
+Sfoff_t sfseek(f,p,type)
+Sfio_t* f; /* seek to a new location in this stream */
+Sfoff_t p; /* place to seek to */
+int type; /* 0: from org, 1: from here, 2: from end */
+#endif
+{
+ Sfoff_t r, s;
+ int mode, local, hardseek, mustsync;
+
+ SFMTXSTART(f, (Sfoff_t)(-1));
+
+ GETLOCAL(f,local);
+
+ hardseek = (type|f->flags)&(SF_SHARE|SF_PUBLIC);
+
+ if(hardseek && f->mode == (SF_READ|SF_SYNCED) )
+ { newpos(f,f->here);
+ f->mode = SF_READ;
+ }
+
+ /* set and initialize the stream to a definite mode */
+ if((int)SFMODE(f,local) != (mode = f->mode&SF_RDWR))
+ { int flags = f->flags;
+
+ if(hardseek&SF_PUBLIC) /* seek ptr must follow file descriptor */
+ f->flags |= SF_SHARE|SF_PUBLIC;
+ mode = _sfmode(f,mode,local);
+ if(hardseek&SF_PUBLIC)
+ f->flags = flags;
+
+ if(mode < 0)
+ SFMTXRETURN(f, (Sfoff_t)(-1));
+ }
+
+ mustsync = (type&SF_SHARE) && !(type&SF_PUBLIC) &&
+ (f->mode&SF_READ) && !(f->flags&SF_STRING);
+
+ /* Xopen-compliant */
+ if((type &= (SEEK_SET|SEEK_CUR|SEEK_END)) != SEEK_SET &&
+ type != SEEK_CUR && type != SEEK_END )
+ { errno = EINVAL;
+ SFMTXRETURN(f, (Sfoff_t)(-1));
+ }
+
+ if(f->extent < 0)
+ { /* let system call set errno */
+ (void)SFSK(f,(Sfoff_t)0,SEEK_CUR,f->disc);
+ SFMTXRETURN(f, (Sfoff_t)(-1));
+ }
+
+ /* throw away ungetc data */
+ if(f->disc == _Sfudisc)
+ (void)sfclose((*_Sfstack)(f,NIL(Sfio_t*)));
+
+ /* lock the stream for internal manipulations */
+ SFLOCK(f,local);
+
+ /* clear error and eof bits */
+ f->flags &= ~(SF_EOF|SF_ERROR);
+
+ while(f->flags&SF_STRING)
+ { SFSTRSIZE(f);
+
+ if(type == SEEK_CUR)
+ r = p + (f->next - f->data);
+ else if(type == SEEK_END)
+ r = p + f->extent;
+ else r = p;
+
+ if(r >= 0 && r <= f->size)
+ { p = r;
+ f->next = f->data+p;
+ f->here = p;
+ if(p > f->extent)
+ memclear((char*)(f->data+f->extent),(int)(p-f->extent));
+ goto done;
+ }
+
+ /* check exception handler, note that this may pop stream */
+ if(SFSK(f,r,SEEK_SET,f->disc) != r)
+ { p = -1;
+ goto done;
+ }
+ else if(!(f->flags&SF_STRING))
+ { p = r;
+ goto done;
+ }
+ }
+
+ if(f->mode&SF_WRITE)
+ { /* see if we can avoid flushing buffer */
+ if(!hardseek && type < SEEK_END && !(f->flags&SF_APPENDWR) )
+ { s = f->here + (f->next - f->data);
+ r = p + (type == SEEK_SET ? 0 : s);
+ if(r == s)
+ { p = r;
+ goto done;
+ }
+ }
+
+ if(f->next > f->data && SFSYNC(f) < 0)
+ { p = -1;
+ goto done;
+ }
+ }
+
+ if(type == SEEK_END || (f->mode&SF_WRITE) )
+ { if((hardseek&SF_PUBLIC) || type == SEEK_END)
+ p = SFSK(f, p, type, f->disc);
+ else
+ { r = p + (type == SEEK_CUR ? f->here : 0);
+ p = (hardseek || r != f->here) ? SFSK(f,r,SEEK_SET,f->disc) : r;
+ }
+ if(p >= 0)
+ newpos(f,p);
+
+ goto done;
+ }
+
+ /* if get here, must be a read stream */
+ s = f->here - (f->endb - f->next);
+ r = p + (type == SEEK_CUR ? s : 0);
+ if(r <= f->here && r >= (f->here - (f->endb-f->data)) )
+ { if((hardseek || (type == SEEK_CUR && p == 0)) )
+ { if((s = SFSK(f, (Sfoff_t)0, SEEK_CUR, f->disc)) == f->here ||
+ (s >= 0 && !(hardseek&SF_PUBLIC) &&
+ (s = SFSK(f, f->here, SEEK_SET, f->disc)) == f->here) )
+ goto near_done;
+ else if(s < 0)
+ { p = -1;
+ goto done;
+ }
+ else
+ { newpos(f,s);
+ hardseek = 0;
+ }
+ }
+ else
+ { near_done:
+ f->next = f->endb - (f->here - r);
+ p = r;
+ goto done;
+ }
+ }
+
+ /* desired position */
+ if((p += type == SEEK_CUR ? s : 0) < 0)
+ goto done;
+
+#ifdef MAP_TYPE
+ if(f->bits&SF_MMAP)
+ { /* if mmap is not great, stop mmaping if moving around too much */
+#if _mmap_worthy < 2
+ if((f->next - f->data) < ((f->endb - f->data)/4) )
+ { SFSETBUF(f,(Void_t*)f->tiny,(size_t)SF_UNBOUND);
+ hardseek = 1; /* this forces a hard seek below */
+ }
+ else
+#endif
+ { /* for mmap, f->here can be virtual except for hardseek */
+ newpos(f,p);
+ if(!hardseek)
+ goto done;
+ }
+ }
+#endif
+
+ if(f->endb > f->next)
+ { /* reduce wastage in future buffer fillings */
+ f->iosz = (f->next - f->data) + (f->endb - f->next)/2;
+ f->iosz = ((f->iosz + f->blksz-1)/f->blksz)*f->blksz;
+ }
+ if(f->iosz >= f->size)
+ f->iosz = 0;
+
+ /* buffer is now considered empty */
+ f->next = f->endr = f->endb = f->data;
+
+ /* small backseeks often come in bunches, so seek back as far as possible */
+ if(p < f->lpos && f->size > f->blksz && (p + f->blksz) > s)
+ { if((r = s - f->size) < 0)
+ r = 0;
+ }
+ /* try to align buffer to block boundary to enhance I/O speed */
+ else if(f->blksz > 0 && f->size >= 2*f->blksz)
+ r = p - (p%f->blksz);
+ else
+ { r = p;
+
+ /* seeking around and wasting data, be conservative */
+ if(f->iosz > 0 && (p > f->lpos || p < f->lpos-f->size) )
+ f->bits |= SF_JUSTSEEK;
+ }
+
+ if((hardseek || r != f->here) && (f->here = SFSK(f,r,SEEK_SET,f->disc)) != r)
+ { if(r < p) /* now try to just get to p */
+ f->here = SFSK(f,p,SEEK_SET,f->disc);
+ if(f->here != p)
+ p = -1;
+ goto done;
+ }
+
+ if(r < p) /* read to cover p */
+ { (void)SFRD(f, f->data, f->size, f->disc);
+ if(p <= f->here && p >= (f->here - (f->endb - f->data)) )
+ f->next = f->endb - (size_t)(f->here-p);
+ else /* recover from read failure by just seeking to p */
+ { f->next = f->endb = f->data;
+ if((f->here = SFSK(f,p,SEEK_SET,f->disc)) != p)
+ p = -1;
+ }
+ }
+
+done :
+ if(f->here < 0) /* hasn't been the best of time */
+ { f->extent = -1;
+ f->here = 0;
+ }
+
+ f->lpos = p;
+
+ SFOPEN(f,local);
+
+ if(mustsync)
+ sfsync(f);
+ SFMTXRETURN(f, p);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfset.c b/usr/src/lib/libast/common/sfio/sfset.c
new file mode 100644
index 0000000000..2618ba60b4
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfset.c
@@ -0,0 +1,88 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Set some control flags or file descript for the stream
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+int sfset(reg Sfio_t* f, reg int flags, reg int set)
+#else
+int sfset(f,flags,set)
+reg Sfio_t* f;
+reg int flags;
+reg int set;
+#endif
+{
+ reg int oflags;
+
+ SFMTXSTART(f,0);
+
+ if(flags == 0 && set == 0)
+ SFMTXRETURN(f, (f->flags&SF_FLAGS));
+
+ if((oflags = (f->mode&SF_RDWR)) != (int)f->mode && _sfmode(f,oflags,0) < 0)
+ SFMTXRETURN(f, 0);
+
+ if(flags == 0)
+ SFMTXRETURN(f, (f->flags&SF_FLAGS));
+
+ SFLOCK(f,0);
+
+ /* preserve at least one rd/wr flag */
+ oflags = f->flags;
+ if(!(f->bits&SF_BOTH) || (flags&SF_RDWR) == SF_RDWR )
+ flags &= ~SF_RDWR;
+
+ /* set the flag */
+ if(set)
+ f->flags |= (flags&SF_SETS);
+ else f->flags &= ~(flags&SF_SETS);
+
+ /* must have at least one of read/write */
+ if(!(f->flags&SF_RDWR))
+ f->flags |= (oflags&SF_RDWR);
+
+ if(f->extent < 0)
+ f->flags &= ~SF_APPENDWR;
+
+ /* turn to appropriate mode as necessary */
+ if((flags &= SF_RDWR) )
+ { if(!set)
+ { if(flags == SF_READ)
+ flags = SF_WRITE;
+ else flags = SF_READ;
+ }
+ if((flags == SF_WRITE && !(f->mode&SF_WRITE)) ||
+ (flags == SF_READ && !(f->mode&(SF_READ|SF_SYNCED))) )
+ (void)_sfmode(f,flags,1);
+ }
+
+ /* if not shared or unseekable, public means nothing */
+ if(!(f->flags&SF_SHARE) || f->extent < 0)
+ f->flags &= ~SF_PUBLIC;
+
+ SFOPEN(f,0);
+ SFMTXRETURN(f, (oflags&SF_FLAGS));
+}
diff --git a/usr/src/lib/libast/common/sfio/sfsetbuf.c b/usr/src/lib/libast/common/sfio/sfsetbuf.c
new file mode 100644
index 0000000000..79748507fe
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfsetbuf.c
@@ -0,0 +1,403 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide getpagesize
+#else
+#define getpagesize ______getpagesize
+#endif
+
+#include "sfhdr.h"
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide getpagesize
+#else
+#undef getpagesize
+#endif
+
+#if _lib_getpagesize
+_BEGIN_EXTERNS_
+extern int getpagesize _ARG_((void));
+_END_EXTERNS_
+#endif
+
+/* Set a (new) buffer for a stream.
+** If size < 0, it is assigned a suitable value depending on the
+** kind of stream. The actual buffer size allocated is dependent
+** on how much memory is available.
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if !_sys_stat
+struct stat
+{ int st_mode;
+ int st_size;
+};
+#undef sysfstatf
+#define sysfstatf(fd,st) (-1)
+#endif /*_sys_stat*/
+
+static int setlinemode()
+{ char* astsfio;
+ char* endw;
+
+ static int modes = -1;
+ static const char sf_line[] = "SF_LINE";
+ static const char sf_wcwidth[] = "SF_WCWIDTH";
+
+#define ISSEPAR(c) ((c) == ',' || (c) == ' ' || (c) == '\t')
+ if (modes < 0)
+ { modes = 0;
+ if(astsfio = getenv("_AST_SFIO_OPTIONS"))
+ { for(; *astsfio != 0; astsfio = endw)
+ { while(ISSEPAR(*astsfio) )
+ *astsfio++;
+ for(endw = astsfio; *endw && !ISSEPAR(*endw); ++endw)
+ ;
+ if((endw-astsfio) == (sizeof(sf_line)-1) &&
+ strncmp(astsfio,sf_line,endw-astsfio) == 0)
+ { if ((modes |= SF_LINE) == (SF_LINE|SF_WCWIDTH))
+ break;
+ }
+ else if((endw-astsfio) == (sizeof(sf_wcwidth)-1) &&
+ strncmp(astsfio,sf_wcwidth,endw-astsfio) == 0)
+ { if ((modes |= SF_WCWIDTH) == (SF_LINE|SF_WCWIDTH))
+ break;
+ }
+ }
+ }
+ }
+ return modes;
+}
+
+#if __STD_C
+Void_t* sfsetbuf(reg Sfio_t* f, reg Void_t* buf, reg size_t size)
+#else
+Void_t* sfsetbuf(f,buf,size)
+reg Sfio_t* f; /* stream to be buffered */
+reg Void_t* buf; /* new buffer */
+reg size_t size; /* buffer size, -1 for default size */
+#endif
+{
+ int sf_malloc, oflags, init, okmmap, local;
+ ssize_t bufsize, blksz;
+ Sfdisc_t* disc;
+ sfstat_t st;
+ uchar* obuf = NIL(uchar*);
+ ssize_t osize = 0;
+
+ SFONCE();
+
+ SFMTXSTART(f,NIL(Void_t*));
+
+ GETLOCAL(f,local);
+
+ if(size == 0 && buf)
+ { /* special case to get buffer info */
+ _Sfi = f->val = (f->bits&SF_MMAP) ? (f->endb-f->data) : f->size;
+ SFMTXRETURN(f, (Void_t*)f->data);
+ }
+
+ /* cleanup actions already done, don't allow write buffering any more */
+ if(_Sfexiting && !(f->flags&SF_STRING) && (f->mode&SF_WRITE))
+ { buf = NIL(Void_t*);
+ size = 0;
+ }
+
+ if((init = f->mode&SF_INIT) )
+ { if(!f->pool && _sfsetpool(f) < 0)
+ SFMTXRETURN(f, NIL(Void_t*));
+ }
+ else if((f->mode&SF_RDWR) != SFMODE(f,local) && _sfmode(f,0,local) < 0)
+ SFMTXRETURN(f, NIL(Void_t*));
+
+ if(init)
+ f->mode = (f->mode&SF_RDWR)|SF_LOCK;
+ else
+ { int rv;
+
+ /* make sure there is no hidden read data */
+ if(f->proc && (f->flags&SF_READ) && (f->mode&SF_WRITE) &&
+ _sfmode(f,SF_READ,local) < 0)
+ SFMTXRETURN(f, NIL(Void_t*));
+
+ /* synchronize first */
+ SFLOCK(f,local); rv = SFSYNC(f); SFOPEN(f,local);
+ if(rv < 0)
+ SFMTXRETURN(f, NIL(Void_t*));
+
+ /* turn off the SF_SYNCED bit because buffer is changing */
+ f->mode &= ~SF_SYNCED;
+ }
+
+ SFLOCK(f,local);
+
+ if((Sfio_t*)buf != f)
+ blksz = -1;
+ else /* setting alignment size only */
+ { blksz = (ssize_t)size;
+
+ if(!init) /* stream already initialized */
+ { obuf = f->data;
+ osize = f->size;
+ goto done;
+ }
+ else /* initialize stream as if in the default case */
+ { buf = NIL(Void_t*);
+ size = (size_t)SF_UNBOUND;
+ }
+ }
+
+ bufsize = 0;
+ oflags = f->flags;
+
+ /* see if memory mapping is possible (see sfwrite for SF_BOTH) */
+ okmmap = (buf || (f->flags&SF_STRING) || (f->flags&SF_RDWR) == SF_RDWR) ? 0 : 1;
+
+ /* save old buffer info */
+#ifdef MAP_TYPE
+ if(f->bits&SF_MMAP)
+ { if(f->data)
+ { SFMUNMAP(f,f->data,f->endb-f->data);
+ f->data = NIL(uchar*);
+ }
+ } else
+#endif
+ if(f->data == f->tiny)
+ { f->data = NIL(uchar*);
+ f->size = 0;
+ }
+ obuf = f->data;
+ osize = f->size;
+
+ f->flags &= ~SF_MALLOC;
+ f->bits &= ~SF_MMAP;
+
+ /* pure read/string streams must have a valid string */
+ if((f->flags&(SF_RDWR|SF_STRING)) == SF_RDSTR &&
+ (size == (size_t)SF_UNBOUND || !buf))
+ size = 0;
+
+ /* set disc to the first discipline with a seekf */
+ for(disc = f->disc; disc; disc = disc->disc)
+ if(disc->seekf)
+ break;
+
+ if((init || local) && !(f->flags&SF_STRING))
+ { /* ASSERT(f->file >= 0) */
+ st.st_mode = 0;
+
+ /* if has discipline, set size by discipline if possible */
+ if(!_sys_stat || disc)
+ { if((f->here = SFSK(f,(Sfoff_t)0,SEEK_CUR,disc)) < 0)
+ goto unseekable;
+ else
+ { Sfoff_t e;
+ if((e = SFSK(f,(Sfoff_t)0,SEEK_END,disc)) >= 0)
+ f->extent = e > f->here ? e : f->here;
+ (void)SFSK(f,f->here,SEEK_SET,disc);
+ goto setbuf;
+ }
+ }
+
+ /* get file descriptor status */
+ if(sysfstatf((int)f->file,&st) < 0)
+ f->here = -1;
+ else
+ {
+#if _sys_stat && _stat_blksize /* preferred io block size */
+ f->blksz = (size_t)st.st_blksize;
+#endif
+ bufsize = 64 * 1024;
+ if(S_ISDIR(st.st_mode) || (Sfoff_t)st.st_size < (Sfoff_t)SF_GRAIN)
+ okmmap = 0;
+ if(S_ISREG(st.st_mode) || S_ISDIR(st.st_mode))
+ f->here = SFSK(f,(Sfoff_t)0,SEEK_CUR,f->disc);
+ else f->here = -1;
+
+#if O_TEXT /* no memory mapping with O_TEXT because read()/write() alter data stream */
+ if(okmmap && f->here >= 0 &&
+ (sysfcntlf((int)f->file,F_GETFL,0) & O_TEXT) )
+ okmmap = 0;
+#endif
+ }
+
+ if(init)
+ f->flags |= setlinemode();
+
+ if(f->here >= 0)
+ { f->extent = (Sfoff_t)st.st_size;
+
+ /* seekable std-devices are share-public by default */
+ if(f == sfstdin || f == sfstdout || f == sfstderr)
+ f->flags |= SF_SHARE|SF_PUBLIC;
+ }
+ else
+ {
+ unseekable:
+ f->extent = -1;
+ f->here = 0;
+
+ if(init)
+ { if(S_ISCHR(st.st_mode) )
+ { int oerrno = errno;
+
+ bufsize = SF_GRAIN;
+
+ /* set line mode for terminals */
+ if(!(f->flags&(SF_LINE|SF_WCWIDTH)) && isatty(f->file))
+ f->flags |= SF_LINE|SF_WCWIDTH;
+#if _sys_stat
+ else /* special case /dev/null */
+ { reg int dev, ino;
+ dev = (int)st.st_dev;
+ ino = (int)st.st_ino;
+ if(sysstatf(DEVNULL,&st) >= 0 &&
+ dev == (int)st.st_dev &&
+ ino == (int)st.st_ino)
+ SFSETNULL(f);
+ }
+#endif
+ errno = oerrno;
+ }
+
+ /* initialize side buffer for r+w unseekable streams */
+ if(!f->proc && (f->bits&SF_BOTH) )
+ (void)_sfpopen(f,-1,-1,1);
+ }
+ }
+
+ /* set page size, this is also the desired default buffer size */
+ if(_Sfpage <= 0)
+ {
+#if _lib_getpagesize
+ if((_Sfpage = (size_t)getpagesize()) <= 0)
+#endif
+ _Sfpage = SF_PAGE;
+ }
+ }
+
+#ifdef MAP_TYPE
+ if(okmmap && size && (f->mode&SF_READ) && f->extent >= 0 )
+ { /* see if we can try memory mapping */
+ if(!disc)
+ for(disc = f->disc; disc; disc = disc->disc)
+ if(disc->readf)
+ break;
+ if(!disc)
+ { f->bits |= SF_MMAP;
+ if(size == (size_t)SF_UNBOUND)
+ { if(bufsize > _Sfpage)
+ size = bufsize * SF_NMAP;
+ else size = _Sfpage * SF_NMAP;
+ if(size > 256*1024)
+ size = 256*1024;
+ }
+ }
+ }
+#endif
+
+ /* get buffer space */
+setbuf:
+ if(size == (size_t)SF_UNBOUND)
+ { /* define a default size suitable for block transfer */
+ if(init && osize > 0)
+ size = osize;
+ else if(f == sfstderr && (f->mode&SF_WRITE))
+ size = 0;
+ else if(f->flags&SF_STRING )
+ size = SF_GRAIN;
+ else if((f->flags&SF_READ) && !(f->bits&SF_BOTH) &&
+ f->extent > 0 && f->extent < (Sfoff_t)_Sfpage )
+ size = (((size_t)f->extent + SF_GRAIN-1)/SF_GRAIN)*SF_GRAIN;
+ else if((ssize_t)(size = _Sfpage) < bufsize)
+ size = bufsize;
+
+ buf = NIL(Void_t*);
+ }
+
+ sf_malloc = 0;
+ if(size > 0 && !buf && !(f->bits&SF_MMAP))
+ { /* try to allocate a buffer */
+ if(obuf && size == (size_t)osize && init)
+ { buf = (Void_t*)obuf;
+ obuf = NIL(uchar*);
+ sf_malloc = (oflags&SF_MALLOC);
+ }
+ if(!buf)
+ { /* do allocation */
+ while(!buf && size > 0)
+ { if((buf = (Void_t*)malloc(size)) )
+ break;
+ else size /= 2;
+ }
+ if(size > 0)
+ sf_malloc = SF_MALLOC;
+ }
+ }
+
+ if(size == 0 && !(f->flags&SF_STRING) && !(f->bits&SF_MMAP) && (f->mode&SF_READ))
+ { /* use the internal buffer */
+ size = sizeof(f->tiny);
+ buf = (Void_t*)f->tiny;
+ }
+
+ /* set up new buffer */
+ f->size = size;
+ f->next = f->data = f->endr = f->endw = (uchar*)buf;
+ f->endb = (f->mode&SF_READ) ? f->data : f->data+size;
+ if(f->flags&SF_STRING)
+ { /* these fields are used to test actual size - see sfseek() */
+ f->extent = (!sf_malloc &&
+ ((f->flags&SF_READ) || (f->bits&SF_BOTH)) ) ? size : 0;
+ f->here = 0;
+
+ /* read+string stream should have all data available */
+ if((f->mode&SF_READ) && !sf_malloc)
+ f->endb = f->data+size;
+ }
+
+ f->flags = (f->flags & ~SF_MALLOC)|sf_malloc;
+
+ if(obuf && obuf != f->data && osize > 0 && (oflags&SF_MALLOC))
+ { free((Void_t*)obuf);
+ obuf = NIL(uchar*);
+ }
+
+done:
+ _Sfi = f->val = obuf ? osize : 0;
+
+ /* blksz is used for aligning disk block boundary while reading data to
+ ** optimize data transfer from disk (eg, via direct I/O). blksz can be
+ ** at most f->size/2 so that data movement in buffer can be optimized.
+ ** blksz should also be a power-of-2 for optimal disk seeks.
+ */
+ if(blksz <= 0 || (blksz & (blksz-1)) != 0 )
+ blksz = SF_GRAIN;
+ while(blksz > f->size/2)
+ blksz /= 2;
+ f->blksz = blksz;
+
+ SFOPEN(f,local);
+
+ SFMTXRETURN(f, (Void_t*)obuf);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfsetfd.c b/usr/src/lib/libast/common/sfio/sfsetfd.c
new file mode 100644
index 0000000000..f3a10b1473
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfsetfd.c
@@ -0,0 +1,135 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Change the file descriptor
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+static int _sfdup(reg int fd, reg int newfd)
+#else
+static int _sfdup(fd,newfd)
+reg int fd;
+reg int newfd;
+#endif
+{
+ reg int dupfd;
+
+#ifdef F_DUPFD /* the simple case */
+ while((dupfd = sysfcntlf(fd,F_DUPFD,newfd)) < 0 && errno == EINTR)
+ errno = 0;
+ return dupfd;
+
+#else /* do it the hard way */
+ if((dupfd = sysdupf(fd)) < 0 || dupfd >= newfd)
+ return dupfd;
+
+ /* dup() succeeded but didn't get the right number, recurse */
+ newfd = _sfdup(fd,newfd);
+
+ /* close the one that didn't match */
+ CLOSE(dupfd);
+
+ return newfd;
+#endif
+}
+
+#if __STD_C
+int sfsetfd(reg Sfio_t* f, reg int newfd)
+#else
+int sfsetfd(f,newfd)
+reg Sfio_t *f;
+reg int newfd;
+#endif
+{
+ reg int oldfd;
+
+ SFMTXSTART(f, -1);
+
+ if(f->flags&SF_STRING)
+ SFMTXRETURN(f, -1);
+
+ if((f->mode&SF_INIT) && f->file < 0)
+ { /* restoring file descriptor after a previous freeze */
+ if(newfd < 0)
+ SFMTXRETURN(f, -1);
+ }
+ else
+ { /* change file descriptor */
+ if((f->mode&SF_RDWR) != f->mode && _sfmode(f,0,0) < 0)
+ SFMTXRETURN(f, -1);
+ SFLOCK(f,0);
+
+ oldfd = f->file;
+ if(oldfd >= 0)
+ { if(newfd >= 0)
+ { if((newfd = _sfdup(oldfd,newfd)) < 0)
+ { SFOPEN(f,0);
+ SFMTXRETURN(f, -1);
+ }
+ CLOSE(oldfd);
+ }
+ else
+ { /* sync stream if necessary */
+ if(((f->mode&SF_WRITE) && f->next > f->data) ||
+ (f->mode&SF_READ) || f->disc == _Sfudisc)
+ { if(SFSYNC(f) < 0)
+ { SFOPEN(f,0);
+ SFMTXRETURN(f, -1);
+ }
+ }
+
+ if(((f->mode&SF_WRITE) && f->next > f->data) ||
+ ((f->mode&SF_READ) && f->extent < 0 &&
+ f->next < f->endb) )
+ { SFOPEN(f,0);
+ SFMTXRETURN(f, -1);
+ }
+
+#ifdef MAP_TYPE
+ if((f->bits&SF_MMAP) && f->data)
+ { SFMUNMAP(f,f->data,f->endb-f->data);
+ f->data = NIL(uchar*);
+ }
+#endif
+
+ /* make stream appears uninitialized */
+ f->endb = f->endr = f->endw = f->data;
+ f->extent = f->here = 0;
+ f->mode = (f->mode&SF_RDWR)|SF_INIT;
+ f->bits &= ~SF_NULL; /* off /dev/null handling */
+ }
+ }
+
+ SFOPEN(f,0);
+ }
+
+ /* notify changes */
+ if(_Sfnotify)
+ (*_Sfnotify)(f,SF_SETFD,newfd);
+
+ f->file = newfd;
+
+ SFMTXRETURN(f,newfd);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfsize.c b/usr/src/lib/libast/common/sfio/sfsize.c
new file mode 100644
index 0000000000..fbfcbb8c75
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfsize.c
@@ -0,0 +1,108 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Get the size of a stream.
+**
+** Written by Kiem-Phong Vo.
+*/
+#if __STD_C
+Sfoff_t sfsize(reg Sfio_t* f)
+#else
+Sfoff_t sfsize(f)
+reg Sfio_t* f;
+#endif
+{
+ Sfdisc_t* disc;
+ reg int mode;
+ Sfoff_t s;
+
+ SFMTXSTART(f, (Sfoff_t)(-1));
+
+ if((mode = f->mode&SF_RDWR) != (int)f->mode && _sfmode(f,mode,0) < 0)
+ SFMTXRETURN(f, (Sfoff_t)(-1));
+
+ if(f->flags&SF_STRING)
+ { SFSTRSIZE(f);
+ SFMTXRETURN(f, f->extent);
+ }
+
+ SFLOCK(f,0);
+
+ s = f->here;
+
+ if(f->extent >= 0)
+ { if(f->flags&(SF_SHARE|SF_APPENDWR))
+ { for(disc = f->disc; disc; disc = disc->disc)
+ if(disc->seekf)
+ break;
+ if(!_sys_stat || disc)
+ { Sfoff_t e;
+ if((e = SFSK(f,0,SEEK_END,disc)) >= 0)
+ f->extent = e;
+ if(SFSK(f,f->here,SEEK_SET,disc) != f->here)
+ f->here = SFSK(f,(Sfoff_t)0,SEEK_CUR,disc);
+ }
+#if _sys_stat
+ else
+ { sfstat_t st;
+ if(sysfstatf(f->file,&st) < 0)
+ f->extent = -1;
+ else if((f->extent = st.st_size) < f->here)
+ f->here = SFSK(f,(Sfoff_t)0,SEEK_CUR,disc);
+ }
+#endif
+ }
+
+ if((f->flags&(SF_SHARE|SF_PUBLIC)) == (SF_SHARE|SF_PUBLIC))
+ f->here = SFSK(f,(Sfoff_t)0,SEEK_CUR,f->disc);
+ }
+
+ if(f->here != s && (f->mode&SF_READ) )
+ { /* buffered data is known to be invalid */
+#ifdef MAP_TYPE
+ if((f->bits&SF_MMAP) && f->data)
+ { SFMUNMAP(f,f->data,f->endb-f->data);
+ f->data = NIL(uchar*);
+ }
+#endif
+ f->next = f->endb = f->endr = f->endw = f->data;
+ }
+
+ if(f->here < 0)
+ f->extent = -1;
+ else if(f->extent < f->here)
+ f->extent = f->here;
+
+ if((s = f->extent) >= 0)
+ { if(f->flags&SF_APPENDWR)
+ s += (f->next - f->data);
+ else if(f->mode&SF_WRITE)
+ { s = f->here + (f->next - f->data);
+ if(s < f->extent)
+ s = f->extent;
+ }
+ }
+
+ SFOPEN(f,0);
+ SFMTXRETURN(f, s);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfsk.c b/usr/src/lib/libast/common/sfio/sfsk.c
new file mode 100644
index 0000000000..e59cb5167d
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfsk.c
@@ -0,0 +1,105 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Seek function that knows discipline
+**
+** Written by Kiem-Phong Vo.
+*/
+#if __STD_C
+Sfoff_t sfsk(reg Sfio_t* f, Sfoff_t addr, reg int type, Sfdisc_t* disc)
+#else
+Sfoff_t sfsk(f,addr,type,disc)
+reg Sfio_t* f;
+Sfoff_t addr;
+reg int type;
+Sfdisc_t* disc;
+#endif
+{
+ Sfoff_t p;
+ reg Sfdisc_t* dc;
+ reg ssize_t s;
+ reg int local, mode;
+
+ SFMTXSTART(f, (Sfoff_t)(-1));
+
+ GETLOCAL(f,local);
+ if(!local && !(f->bits&SF_DCDOWN))
+ { if((mode = f->mode&SF_RDWR) != (int)f->mode && _sfmode(f,mode,0) < 0)
+ SFMTXRETURN(f, (Sfoff_t)(-1));
+ if(SFSYNC(f) < 0)
+ SFMTXRETURN(f, (Sfoff_t)(-1));
+#ifdef MAP_TYPE
+ if(f->mode == SF_READ && (f->bits&SF_MMAP) && f->data)
+ { SFMUNMAP(f, f->data, f->endb-f->data);
+ f->data = NIL(uchar*);
+ }
+#endif
+ f->next = f->endb = f->endr = f->endw = f->data;
+ }
+
+ if((type &= (SEEK_SET|SEEK_CUR|SEEK_END)) > SEEK_END)
+ SFMTXRETURN(f, (Sfoff_t)(-1));
+
+ for(;;)
+ { dc = disc;
+ if(f->flags&SF_STRING)
+ { SFSTRSIZE(f);
+ if(type == SEEK_SET)
+ s = (ssize_t)addr;
+ else if(type == SEEK_CUR)
+ s = (ssize_t)(addr + f->here);
+ else s = (ssize_t)(addr + f->extent);
+ }
+ else
+ { SFDISC(f,dc,seekf);
+ if(dc && dc->seekf)
+ { SFDCSK(f,addr,type,dc,p);
+ }
+ else
+ { p = syslseekf(f->file,(sfoff_t)addr,type);
+ }
+ if(p >= 0)
+ SFMTXRETURN(f,p);
+ s = -1;
+ }
+
+ if(local)
+ SETLOCAL(f);
+ switch(_sfexcept(f,SF_SEEK,s,dc))
+ {
+ case SF_EDISC:
+ case SF_ECONT:
+ if(f->flags&SF_STRING)
+ SFMTXRETURN(f, (Sfoff_t)s);
+ goto do_continue;
+ default:
+ SFMTXRETURN(f, (Sfoff_t)(-1));
+ }
+
+ do_continue:
+ for(dc = f->disc; dc; dc = dc->disc)
+ if(dc == disc)
+ break;
+ disc = dc;
+ }
+}
diff --git a/usr/src/lib/libast/common/sfio/sfstack.c b/usr/src/lib/libast/common/sfio/sfstack.c
new file mode 100644
index 0000000000..27012aa23c
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfstack.c
@@ -0,0 +1,115 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+
+/* Push/pop streams
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#define STKMTXLOCK(f1,f2) \
+ { if(f1) SFMTXLOCK(f1); \
+ if(f2) SFMTXLOCK(f2); \
+ }
+#define STKMTXRETURN(f1,f2,rv) \
+ { if(f1) SFMTXUNLOCK(f1); \
+ if(f2) SFMTXUNLOCK(f2); \
+ return(rv); \
+ }
+
+#if __STD_C
+Sfio_t* sfstack(Sfio_t* f1, Sfio_t* f2)
+#else
+Sfio_t* sfstack(f1,f2)
+Sfio_t* f1; /* base of stack */
+Sfio_t* f2; /* top of stack */
+#endif
+{
+ reg int n;
+ reg Sfio_t* rf;
+ reg Sfrsrv_t* rsrv;
+ reg Void_t* mtx;
+
+ STKMTXLOCK(f1,f2);
+
+ if(f1 && (f1->mode&SF_RDWR) != f1->mode && _sfmode(f1,0,0) < 0)
+ STKMTXRETURN(f1,f2, NIL(Sfio_t*));
+ if(f2 && (f2->mode&SF_RDWR) != f2->mode && _sfmode(f2,0,0) < 0)
+ STKMTXRETURN(f1,f2, NIL(Sfio_t*));
+ if(!f1)
+ STKMTXRETURN(f1,f2, f2);
+
+ /* give access to other internal functions */
+ _Sfstack = sfstack;
+
+ if(f2 == SF_POPSTACK)
+ { if(!(f2 = f1->push))
+ STKMTXRETURN(f1,f2, NIL(Sfio_t*));
+ f2->mode &= ~SF_PUSH;
+ }
+ else
+ { if(f2->push)
+ STKMTXRETURN(f1,f2, NIL(Sfio_t*));
+ if(f1->pool && f1->pool != &_Sfpool && f1->pool != f2->pool &&
+ f1 == f1->pool->sf[0])
+ { /* get something else to pool front since f1 will be locked */
+ for(n = 1; n < f1->pool->n_sf; ++n)
+ { if(SFFROZEN(f1->pool->sf[n]) )
+ continue;
+ (*_Sfpmove)(f1->pool->sf[n],0);
+ break;
+ }
+ }
+ }
+
+ if(f2->pool && f2->pool != &_Sfpool && f2 != f2->pool->sf[0])
+ (*_Sfpmove)(f2,0);
+
+ /* swap streams */
+ sfswap(f1,f2);
+
+ /* but the reserved buffer and mutex must remain the same */
+ rsrv = f1->rsrv; f1->rsrv = f2->rsrv; f2->rsrv = rsrv;
+ mtx = f1->mutex; f1->mutex = f2->mutex; f2->mutex = mtx;
+
+ SFLOCK(f1,0);
+ SFLOCK(f2,0);
+
+ if(f2->push != f2)
+ { /* freeze the pushed stream */
+ f2->mode |= SF_PUSH;
+ f1->push = f2;
+ rf = f1;
+ }
+ else
+ { /* unfreeze the just exposed stream */
+ f1->mode &= ~SF_PUSH;
+ f2->push = NIL(Sfio_t*);
+ rf = f2;
+ }
+
+ SFOPEN(f1,0);
+ SFOPEN(f2,0);
+
+ STKMTXRETURN(f1,f2, rf);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfstrtod.c b/usr/src/lib/libast/common/sfio/sfstrtod.c
new file mode 100644
index 0000000000..87941e342f
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfstrtod.c
@@ -0,0 +1,157 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Convert a Sfdouble_t value represented in an ASCII format into
+** the internal Sfdouble_t representation.
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#define BATCH (2*sizeof(int)) /* accumulate this many digits at a time */
+#define IPART 0 /* doing integer part */
+#define FPART 1 /* doing fractional part */
+#define EPART 2 /* doing exponent part */
+
+#if __STD_C
+static Sfdouble_t sfpow10(reg int n)
+#else
+static Sfdouble_t sfpow10(n)
+reg int n;
+#endif
+{
+ Sfdouble_t dval;
+
+ switch(n)
+ { case -3: return .001;
+ case -2: return .01;
+ case -1: return .1;
+ case 0: return 1.;
+ case 1: return 10.;
+ case 2: return 100.;
+ case 3: return 1000.;
+ }
+
+ if(n < 0)
+ { dval = .0001;
+ for(n += 4; n < 0; n += 1)
+ dval /= 10.;
+ }
+ else
+ { dval = 10000.;
+ for(n -= 4; n > 0; n -= 1)
+ dval *= 10.;
+ }
+
+ return dval;
+}
+
+#if __STD_C
+Sfdouble_t _sfstrtod(reg const char* s, char** retp)
+#else
+Sfdouble_t _sfstrtod(s,retp)
+reg char* s; /* string to convert */
+char** retp; /* to return the remainder of string */
+#endif
+{
+ reg int n, c, m;
+ reg int mode, fexp, sign, expsign;
+ Sfdouble_t dval;
+#if _lib_locale
+ int decpoint = 0;
+ int thousand = 0;
+ SFSETLOCALE(&decpoint,&thousand);
+#else
+#define decpoint '.'
+#endif
+
+ /* skip initial blanks */
+ while(isspace(*s))
+ ++s;
+
+ /* get the sign */
+ if((sign = (*s == '-')) || *s == '+')
+ s += 1;
+
+ mode = IPART;
+ fexp = expsign = 0;
+ dval = 0.;
+ while(*s)
+ { /* accumulate a handful of the digits */
+ for(m = BATCH, n = 0; m > 0; --m, ++s)
+ { /* get and process a char */
+ c = *s;
+ if(isdigit(c))
+ n = 10*n + (c - '0');
+ else break;
+ }
+
+ /* number of digits accumulated */
+ m = BATCH-m;
+
+ if(mode == IPART)
+ { /* doing the integer part */
+ if(dval == 0.)
+ dval = (Sfdouble_t)n;
+ else dval = dval*sfpow10(m) + (Sfdouble_t)n;
+ }
+ else if(mode == FPART)
+ { /* doing the fractional part */
+ fexp -= m;
+ if(n > 0)
+ dval += n*sfpow10(fexp);
+ }
+ else if(n)
+ { /* doing the exponent part */
+ if(expsign)
+ n = -n;
+ dval *= sfpow10(n);
+ }
+
+ if(!c)
+ break;
+
+ if(m < BATCH)
+ { /* detected a non-digit */
+ if(c == decpoint)
+ { /* start the fractional part or no match */
+ if(mode != IPART)
+ break;
+ mode = FPART;
+ s += 1;
+ }
+ else if(c == 'e' || c == 'E')
+ { if(mode == EPART)
+ break;
+ mode = EPART;
+ c = *++s;
+ if((expsign = (c == '-')) || c == '+')
+ s += 1;
+ }
+ else break;
+ }
+ }
+
+ if(retp)
+ *retp = (char*)s;
+ return sign ? -dval : dval;
+}
diff --git a/usr/src/lib/libast/common/sfio/sfstrtof.h b/usr/src/lib/libast/common/sfio/sfstrtof.h
new file mode 100644
index 0000000000..2402c8c202
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfstrtof.h
@@ -0,0 +1,544 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * AT&T Research
+ * Glenn Fowler & Phong Vo
+ *
+ * common header and implementation for
+ *
+ * strtof strtod strtold _sfdscan
+ * strntof strntod strntold
+ *
+ * define these macros to instantiate an implementation:
+ *
+ * S2F_function the function name
+ * S2F_static <0:export =0:extern >0:static
+ * S2F_type 0:float 1:double 2:long.double
+ * S2F_size 1 for interface with size_t second arg
+ * S2F_scan 1 for alternate interface with these arguments:
+ * void* handle
+ * int (*getchar)(void* handle, int flag)
+ * exactly one extra (*getchar)() is done, i.e.,
+ * the caller must do the pushback
+ * flag==0 get next char
+ * flag==1 no number seen
+ * return 0 on error or EOF
+ */
+
+#include "sfhdr.h"
+#include "FEATURE/float"
+
+/*
+ * the default is _sfdscan for standalone sfio compatibility
+ */
+
+#if !defined(S2F_function)
+#define S2F_function _sfdscan
+#define S2F_static 1
+#define S2F_type 2
+#define S2F_scan 1
+#ifndef elementsof
+#define elementsof(a) (sizeof(a)/sizeof(a[0]))
+#endif
+#endif
+
+#if S2F_type == 2 && _ast_fltmax_double
+#undef S2F_type
+#define S2F_type 1
+#endif
+
+#if S2F_type == 0
+#define S2F_number float
+#define S2F_ldexp ldexp
+#define S2F_pow10 _Sffpow10
+#define S2F_inf _Sffinf
+#define S2F_nan _Sffnan
+#define S2F_min (FLT_MIN)
+#define S2F_max (FLT_MAX)
+#define S2F_exp_10_min (FLT_MIN_10_EXP)
+#define S2F_exp_10_max (FLT_MAX_10_EXP)
+#define S2F_exp_2_min (FLT_MIN_EXP)
+#define S2F_exp_2_max (FLT_MAX_EXP)
+#endif
+#if S2F_type == 1
+#define S2F_number double
+#define S2F_ldexp ldexp
+#define S2F_pow10 _Sfdpow10
+#define S2F_inf _Sfdinf
+#define S2F_nan _Sfdnan
+#define S2F_min (DBL_MIN)
+#define S2F_max (DBL_MAX)
+#define S2F_exp_10_min (DBL_MIN_10_EXP)
+#define S2F_exp_10_max (DBL_MAX_10_EXP)
+#define S2F_exp_2_min (DBL_MIN_EXP)
+#define S2F_exp_2_max (DBL_MAX_EXP)
+#endif
+#if S2F_type == 2
+#define S2F_number long double
+#define S2F_ldexp ldexpl
+#define S2F_pow10 _Sflpow10
+#define S2F_inf _Sflinf
+#define S2F_nan _Sflnan
+#define S2F_min (LDBL_MIN)
+#define S2F_max (LDBL_MAX)
+#define S2F_exp_10_min (LDBL_MIN_10_EXP)
+#define S2F_exp_10_max (LDBL_MAX_10_EXP)
+#define S2F_exp_2_min (LDBL_MIN_EXP)
+#define S2F_exp_2_max (LDBL_MAX_EXP)
+#endif
+
+#if -S2F_exp_10_min < S2F_exp_10_max
+#define S2F_exp_10_abs (-S2F_exp_10_min)
+#else
+#define S2F_exp_10_abs S2F_exp_10_max
+#endif
+
+#define S2F_batch _ast_flt_unsigned_max_t
+
+#undef ERR /* who co-opted this namespace? */
+
+#if S2F_scan
+
+typedef int (*S2F_get_f)_ARG_((void*, int));
+
+#define ERR(e)
+#define GET(p) (*get)(p,0)
+#define NON(p) (*get)(p,1)
+#define PUT(p)
+#define REV(p,t,b)
+#define SET(p,t,b)
+
+#else
+
+#define ERR(e) (errno=(e))
+#define NON(p)
+
+#if S2F_size
+#define GET(p) (((p)<(z))?(*p++):(back=0))
+#define PUT(p) (end?(*end=(char*)p-back):(char*)0)
+#define REV(p,t,b) (p=t,back=b)
+#define SET(p,t,b) (t=p,b=back)
+#else
+#define GET(p) (*p++)
+#define PUT(p) (end?(*end=(char*)p-1):(char*)0)
+#define REV(p,t,b) (p=t)
+#define SET(p,t,b) (t=p)
+#endif
+
+#endif
+
+typedef struct S2F_part_s
+{
+ S2F_batch batch;
+ int digits;
+} S2F_part_t;
+
+#if !defined(ERANGE)
+#define ERANGE EINVAL
+#endif
+
+#if S2F_static > 0
+static
+#else
+#if S2F_static < 0 || !defined(S2F_static)
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+extern
+#undef extern
+#endif
+#endif
+S2F_number
+#if S2F_scan
+#if __STD_C
+S2F_function(void* s, S2F_get_f get)
+#else
+S2F_function(s, get) void* s; S2F_get_f get;
+#endif
+#else
+#if S2F_size
+#if __STD_C
+S2F_function(const char* str, size_t size, char** end)
+#else
+S2F_function(str, size, end) char* str; size_t size; char** end;
+#endif
+#else
+#if __STD_C
+S2F_function(const char* str, char** end)
+#else
+S2F_function(str, end) char* str; char** end;
+#endif
+#endif
+#endif
+{
+#if !S2F_scan
+ register unsigned char* s = (unsigned char*)str;
+#if S2F_size
+ register unsigned char* z = s + size;
+ int back = 1;
+ int b;
+#endif
+ unsigned char* t;
+#endif
+ register S2F_batch n;
+ register int c;
+ register int digits;
+ register int m;
+ register unsigned char* cv;
+ int negative;
+ int enegative;
+ int fraction;
+ int decimal = 0;
+ int thousand = 0;
+ int part = 0;
+ S2F_number v;
+ S2F_number p;
+ S2F_part_t parts[16];
+
+ /*
+ * radix char and thousands separator are locale specific
+ */
+
+ SFSETLOCALE(&decimal, &thousand);
+ SFCVINIT();
+
+ /*
+ * skip initial blanks
+ */
+
+ do c = GET(s); while (isspace(c));
+ SET(s, t, b);
+
+ /*
+ * get the sign
+ */
+
+ if ((negative = (c == '-')) || c == '+')
+ c = GET(s);
+
+ /*
+ * drop leading 0's
+ */
+
+ digits = 0;
+ fraction = -1;
+ if (c == '0')
+ {
+ c = GET(s);
+ if (c == 'x' || c == 'X')
+ {
+ /*
+ * hex floating point -- easy
+ */
+
+ cv = _Sfcv36;
+ v = 0;
+ for (;;)
+ {
+ c = GET(s);
+ if ((part = cv[c]) < 16)
+ {
+ digits++;
+ v *= 16;
+ v += part;
+ }
+ else if (c == decimal)
+ {
+ decimal = -1;
+ fraction = digits;
+ }
+ else
+ break;
+ }
+ m = 0;
+ if (c == 'p' || c == 'P')
+ {
+ c = GET(s);
+ if ((enegative = c == '-') || c == '+')
+ c = GET(s);
+ while (c >= '0' && c <= '9')
+ {
+ m = (m << 3) + (m << 1) + (c - '0');
+ c = GET(s);
+ }
+ if (enegative)
+ m = -m;
+ }
+
+ /*
+ * consume the optional suffix
+ */
+
+ switch (c)
+ {
+ case 'f':
+ case 'F':
+ case 'l':
+ case 'L':
+ c = GET(s);
+ break;
+ }
+ PUT(s);
+ if (v == 0)
+ return v;
+ if (fraction >= 0)
+ m -= 4 * (digits - fraction);
+ if (m < S2F_exp_2_min)
+ {
+ if ((m -= S2F_exp_2_min) < S2F_exp_2_min)
+ {
+ ERR(ERANGE);
+ return 0;
+ }
+ v = S2F_ldexp(v, S2F_exp_2_min);
+ }
+ else if (m > S2F_exp_2_max)
+ {
+ ERR(ERANGE);
+ return negative ? -S2F_inf : S2F_inf;
+ }
+ v = S2F_ldexp(v, m);
+ goto check;
+ }
+ while (c == '0')
+ c = GET(s);
+ }
+ else if (c == decimal)
+ {
+ decimal = -1;
+ fraction = 0;
+ for (;;)
+ {
+ c = GET(s);
+ if (c != '0')
+ break;
+ digits++;
+ }
+ }
+ else if (c == 'i' || c == 'I')
+ {
+ if ((c = GET(s)) != 'n' && c != 'N' ||
+ (c = GET(s)) != 'f' && c != 'F')
+ {
+ REV(s, t, b);
+ PUT(s);
+ return 0;
+ }
+ c = GET(s);
+ SET(s, t, b);
+ if (((c) == 'i' || c == 'I') &&
+ ((c = GET(s)) == 'n' || c == 'N') &&
+ ((c = GET(s)) == 'i' || c == 'I') &&
+ ((c = GET(s)) == 't' || c == 'T') &&
+ ((c = GET(s)) == 'y' || c == 'Y'))
+ {
+ c = GET(s);
+ SET(s, t, b);
+ }
+ REV(s, t, b);
+ PUT(s);
+ return negative ? -S2F_inf : S2F_inf;
+ }
+ else if (c == 'n' || c == 'N')
+ {
+ if ((c = GET(s)) != 'a' && c != 'A' ||
+ (c = GET(s)) != 'n' && c != 'N')
+ {
+ REV(s, t, b);
+ PUT(s);
+ return 0;
+ }
+ do c = GET(s); while (c && !isspace(c));
+ PUT(s);
+ return S2F_nan;
+ }
+ else if (c < '1' || c > '9')
+ {
+ REV(s, t, b);
+ PUT(s);
+ NON(s);
+ return 0;
+ }
+
+ /*
+ * consume the integral and fractional parts
+ */
+
+ n = 0;
+ m = 0;
+ for (;;)
+ {
+ if (c >= '0' && c <= '9')
+ {
+ digits++;
+ n = (n << 3) + (n << 1) + (c - '0');
+ if (n >= ((~((S2F_batch)0)) / 10) && part < elementsof(parts))
+ {
+ parts[part].batch = n;
+ n = 0;
+ parts[part].digits = digits;
+ part++;
+ }
+ }
+ else if (m && (digits - m) != 3)
+ break;
+ else if (c == decimal)
+ {
+ decimal = -1;
+ thousand = -1;
+ m = 0;
+ fraction = digits;
+ }
+ else if (c != thousand)
+ break;
+ else if (!(m = digits))
+ break;
+ c = GET(s);
+ }
+
+ /*
+ * don't forget the last part
+ */
+
+ if (n && part < elementsof(parts))
+ {
+ parts[part].batch = n;
+ parts[part].digits = digits;
+ part++;
+ }
+
+ /*
+ * consume the exponent
+ */
+
+ if (fraction >= 0)
+ digits = fraction;
+ if (c == 'e' || c == 'E')
+ {
+ c = GET(s);
+ if ((enegative = (c == '-')) || c == '+')
+ c = GET(s);
+ n = 0;
+ while (c >= '0' && c <= '9')
+ {
+ n = (n << 3) + (n << 1) + (c - '0');
+ c = GET(s);
+ }
+ if (enegative)
+ digits -= n;
+ else
+ digits += n;
+ }
+
+ /*
+ * consume the optional suffix
+ */
+
+ switch (c)
+ {
+ case 'f':
+ case 'F':
+ case 'l':
+ case 'L':
+ c = GET(s);
+ break;
+ }
+ PUT(s);
+
+ /*
+ * adjust for at most one multiply per part
+ * and at most one divide overall
+ */
+
+ if (!part)
+ return 0;
+ else if ((m = parts[part-1].digits - digits) > 0)
+ digits += m;
+ else
+ m = 0;
+
+ /*
+ * combine the parts
+ */
+
+ v = 0;
+ while (part--)
+ {
+ p = parts[part].batch;
+ c = digits - parts[part].digits;
+ if (c > S2F_exp_10_max)
+ {
+ ERR(ERANGE);
+ return negative ? -S2F_inf : S2F_inf;
+ }
+ if (c > 0)
+ {
+#if _ast_mpy_overflow_fpe
+ if ((S2F_max / p) < S2F_pow10[c])
+ {
+ ERR(ERANGE);
+ return negative ? -S2F_inf : S2F_inf;
+ }
+#endif
+ p *= S2F_pow10[c];
+ }
+ v += p;
+ }
+ if (m)
+ {
+ while (m > S2F_exp_10_max)
+ {
+ m -= S2F_exp_10_max;
+ v /= S2F_pow10[S2F_exp_10_max];
+ }
+#if _ast_div_underflow_fpe
+ if ((S2F_min * p) > S2F_pow10[c])
+ {
+ ERR(ERANGE);
+ return negative ? -S2F_inf : S2F_inf;
+ }
+#endif
+ v /= S2F_pow10[m];
+ }
+
+ /*
+ * check the range
+ */
+
+ check:
+ if (v < S2F_min)
+ {
+ ERR(ERANGE);
+ v = 0;
+ }
+ else if (v > S2F_max)
+ {
+ ERR(ERANGE);
+ v = S2F_inf;
+ }
+
+ /*
+ * done
+ */
+
+ return negative ? -v : v;
+}
diff --git a/usr/src/lib/libast/common/sfio/sfswap.c b/usr/src/lib/libast/common/sfio/sfswap.c
new file mode 100644
index 0000000000..b4523e927b
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfswap.c
@@ -0,0 +1,119 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Swap two streams. If the second argument is NULL,
+** a new stream will be created. Always return the second argument
+** or the new stream. Note that this function will always work
+** unless streams are locked by SF_PUSH.
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+Sfio_t* sfswap(reg Sfio_t* f1, reg Sfio_t* f2)
+#else
+Sfio_t* sfswap(f1,f2)
+reg Sfio_t* f1;
+reg Sfio_t* f2;
+#endif
+{
+ Sfio_t tmp;
+ int f1pool, f2pool, f1mode, f2mode, f1flags, f2flags;
+
+ if(!f1 || (f1->mode&SF_AVAIL) || (SFFROZEN(f1) && (f1->mode&SF_PUSH)) )
+ return NIL(Sfio_t*);
+ if(f2 && SFFROZEN(f2) && (f2->mode&SF_PUSH) )
+ return NIL(Sfio_t*);
+ if(f1 == f2)
+ return f2;
+
+ f1mode = f1->mode;
+ SFLOCK(f1,0);
+ f1->mode |= SF_PUSH; /* make sure there is no recursion on f1 */
+
+ if(f2)
+ { f2mode = f2->mode;
+ SFLOCK(f2,0);
+ f2->mode |= SF_PUSH; /* make sure there is no recursion on f2 */
+ }
+ else
+ { f2 = f1->file == 0 ? sfstdin :
+ f1->file == 1 ? sfstdout :
+ f1->file == 2 ? sfstderr : NIL(Sfio_t*);
+ if((!f2 || !(f2->mode&SF_AVAIL)) )
+ { if(!(f2 = (Sfio_t*)malloc(sizeof(Sfio_t))) )
+ { f1->mode = f1mode;
+ SFOPEN(f1,0);
+ return NIL(Sfio_t*);
+ }
+
+ SFCLEAR(f2,NIL(Vtmutex_t*));
+ }
+ f2->mode = SF_AVAIL|SF_LOCK;
+ f2mode = SF_AVAIL;
+ }
+
+ if(!f1->pool)
+ f1pool = -1;
+ else for(f1pool = f1->pool->n_sf-1; f1pool >= 0; --f1pool)
+ if(f1->pool->sf[f1pool] == f1)
+ break;
+ if(!f2->pool)
+ f2pool = -1;
+ else for(f2pool = f2->pool->n_sf-1; f2pool >= 0; --f2pool)
+ if(f2->pool->sf[f2pool] == f2)
+ break;
+
+ f1flags = f1->flags;
+ f2flags = f2->flags;
+
+ /* swap image and pool entries */
+ memcpy((Void_t*)(&tmp),(Void_t*)f1,sizeof(Sfio_t));
+ memcpy((Void_t*)f1,(Void_t*)f2,sizeof(Sfio_t));
+ memcpy((Void_t*)f2,(Void_t*)(&tmp),sizeof(Sfio_t));
+ if(f2pool >= 0)
+ f1->pool->sf[f2pool] = f1;
+ if(f1pool >= 0)
+ f2->pool->sf[f1pool] = f2;
+
+ if(f2flags&SF_STATIC)
+ f2->flags |= SF_STATIC;
+ else f2->flags &= ~SF_STATIC;
+
+ if(f1flags&SF_STATIC)
+ f1->flags |= SF_STATIC;
+ else f1->flags &= ~SF_STATIC;
+
+ if(f2mode&SF_AVAIL) /* swapping to a closed stream */
+ { if(!(f1->flags&SF_STATIC) )
+ free(f1);
+ }
+ else
+ { f1->mode = f2mode;
+ SFOPEN(f1,0);
+ }
+
+ f2->mode = f1mode;
+ SFOPEN(f2,0);
+ return f2;
+}
diff --git a/usr/src/lib/libast/common/sfio/sfsync.c b/usr/src/lib/libast/common/sfio/sfsync.c
new file mode 100644
index 0000000000..2d02f32242
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfsync.c
@@ -0,0 +1,171 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Synchronize data in buffers with the file system.
+** If f is nil, all streams are sync-ed
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+static int _sfall(void)
+#else
+static int _sfall()
+#endif
+{
+ reg Sfpool_t *p, *next;
+ reg Sfio_t* f;
+ reg int n, rv;
+ reg int nsync, count, loop;
+#define MAXLOOP 3
+
+ for(loop = 0; loop < MAXLOOP; ++loop)
+ { rv = nsync = count = 0;
+ for(p = &_Sfpool; p; p = next)
+ { /* find the next legitimate pool */
+ for(next = p->next; next; next = next->next)
+ if(next->n_sf > 0)
+ break;
+
+ /* walk the streams for _Sfpool only */
+ for(n = 0; n < ((p == &_Sfpool) ? p->n_sf : 1); ++n)
+ { count += 1;
+ f = p->sf[n];
+
+ if(f->flags&SF_STRING )
+ goto did_sync;
+ if(SFFROZEN(f))
+ continue;
+ if((f->mode&SF_READ) && (f->mode&SF_SYNCED) )
+ goto did_sync;
+ if((f->mode&SF_READ) && !(f->bits&SF_MMAP) &&
+ f->next == f->endb)
+ goto did_sync;
+ if((f->mode&SF_WRITE) && !(f->bits&SF_HOLE) &&
+ f->next == f->data)
+ goto did_sync;
+
+ if(sfsync(f) < 0)
+ rv = -1;
+
+ did_sync:
+ nsync += 1;
+ }
+ }
+
+ if(nsync == count)
+ break;
+ }
+ return rv;
+}
+
+#if __STD_C
+int sfsync(reg Sfio_t* f)
+#else
+int sfsync(f)
+reg Sfio_t* f; /* stream to be synchronized */
+#endif
+{
+ int local, rv, mode, lock;
+ Sfio_t* origf;
+
+ if(!(origf = f) )
+ return _sfall();
+
+ SFMTXSTART(origf,-1);
+
+ GETLOCAL(origf,local);
+
+ if(origf->disc == _Sfudisc) /* throw away ungetc */
+ (void)sfclose((*_Sfstack)(origf,NIL(Sfio_t*)));
+
+ rv = 0;
+
+ lock = origf->mode&SF_LOCK;
+ if(origf->mode == (SF_SYNCED|SF_READ) ) /* already synced */
+ goto done;
+
+ if((origf->mode&SF_RDWR) != SFMODE(origf,local) && _sfmode(origf,0,local) < 0)
+ { rv = -1;
+ goto done;
+ }
+
+ for(; f; f = f->push)
+ {
+ if((f->flags&SF_IOCHECK) && f->disc && f->disc->exceptf)
+ (void)(*f->disc->exceptf)(f,SF_SYNC,(Void_t*)((int)1),f->disc);
+
+ SFLOCK(f,local);
+
+ /* pretend that this stream is not on a stack */
+ mode = f->mode&SF_PUSH;
+ f->mode &= ~SF_PUSH;
+
+ /* these streams do not need synchronization */
+ if((f->flags&SF_STRING) || (f->mode&SF_SYNCED))
+ goto next;
+
+ if((f->mode&SF_WRITE) && (f->next > f->data || (f->bits&SF_HOLE)) )
+ { /* sync the buffer, make sure pool don't move */
+ reg int pool = f->mode&SF_POOL;
+ f->mode &= ~SF_POOL;
+ if(f->next > f->data && (SFWRALL(f), SFFLSBUF(f,-1)) < 0)
+ rv = -1;
+ if(!SFISNULL(f) && (f->bits&SF_HOLE) )
+ { /* realize a previously created hole of 0's */
+ if(SFSK(f,(Sfoff_t)(-1),SEEK_CUR,f->disc) >= 0)
+ (void)SFWR(f,"",1,f->disc);
+ f->bits &= ~SF_HOLE;
+ }
+ f->mode |= pool;
+ }
+
+ if((f->mode&SF_READ) && f->extent >= 0 &&
+ ((f->bits&SF_MMAP) || f->next < f->endb) )
+ { /* make sure the file pointer is at the right place */
+ f->here -= (f->endb-f->next);
+ f->endr = f->endw = f->data;
+ f->mode = SF_READ|SF_SYNCED|lock;
+ (void)SFSK(f,f->here,SEEK_SET,f->disc);
+
+ if((f->flags&SF_SHARE) && !(f->flags&SF_PUBLIC) &&
+ !(f->bits&SF_MMAP) )
+ { f->endb = f->next = f->data;
+ f->mode &= ~SF_SYNCED;
+ }
+ }
+
+ next:
+ f->mode |= mode;
+ SFOPEN(f,local);
+
+ if((f->flags&SF_IOCHECK) && f->disc && f->disc->exceptf)
+ (void)(*f->disc->exceptf)(f,SF_SYNC,(Void_t*)((int)0),f->disc);
+ }
+
+done:
+ if(!local && f && (f->mode&SF_POOL) && f->pool && f != f->pool->sf[0])
+ SFSYNC(f->pool->sf[0]);
+
+ SFMTXRETURN(origf, rv);
+}
diff --git a/usr/src/lib/libast/common/sfio/sftable.c b/usr/src/lib/libast/common/sfio/sftable.c
new file mode 100644
index 0000000000..6ea7b3b2a3
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sftable.c
@@ -0,0 +1,541 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+#include "FEATURE/float"
+
+/* Dealing with $ argument addressing stuffs.
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+static char* sffmtint(const char* str, int* v)
+#else
+static char* sffmtint(str, v)
+char* str;
+int* v;
+#endif
+{
+ for(*v = 0; isdigit(*str); ++str)
+ *v = *v * 10 + (*str - '0');
+ *v -= 1;
+ return (char*)str;
+}
+
+#if __STD_C
+static Fmtpos_t* sffmtpos(Sfio_t* f,const char* form,va_list args,Sffmt_t* ft,int type)
+#else
+static Fmtpos_t* sffmtpos(f,form,args,ft,type)
+Sfio_t* f;
+char* form;
+va_list args;
+Sffmt_t* ft;
+int type; /* >0: scanf, =0: printf, -1: internal */
+#endif
+{
+ int base, fmt, flags, dot, width, precis;
+ ssize_t n_str, size;
+ char *t_str, *sp;
+ int v, n, skip, dollar, decimal, thousand;
+ Sffmt_t savft;
+ Fmtpos_t* fp; /* position array of arguments */
+ int argp, argn, maxp, need[FP_INDEX];
+#if _has_multibyte
+ SFMBDCL(fmbs)
+#endif
+
+ if(type < 0)
+ fp = NIL(Fmtpos_t*);
+ else if(!(fp = sffmtpos(f,form,args,ft,-1)) )
+ return NIL(Fmtpos_t*);
+
+ dollar = decimal = thousand = 0; argn = maxp = -1;
+ SFMBCLR(&fmbs);
+ while((n = *form) )
+ { if(n != '%') /* collect the non-pattern chars */
+ { sp = (char*)form;
+ for(;;)
+ { form += SFMBLEN(form, &fmbs);
+ if(*form == 0 || *form == '%')
+ break;
+ }
+ continue;
+ }
+ else form += 1;
+ if(*form == 0)
+ break;
+ else if(*form == '%')
+ { form += 1;
+ continue;
+ }
+
+ if(*form == '*' && type > 0) /* skip in scanning */
+ { skip = 1;
+ form += 1;
+ argp = -1;
+ }
+ else /* get the position of this argument */
+ { skip = 0;
+ sp = sffmtint(form,&argp);
+ if(*sp == '$')
+ { dollar = 1;
+ form = sp+1;
+ }
+ else argp = -1;
+ }
+
+ flags = dot = 0;
+ t_str = NIL(char*); n_str = 0;
+ size = width = precis = base = -1;
+ for(n = 0; n < FP_INDEX; ++n)
+ need[n] = -1;
+
+ loop_flags: /* LOOP FOR \0, %, FLAGS, WIDTH, PRECISION, BASE, TYPE */
+ switch((fmt = *form++) )
+ {
+ case LEFTP : /* get the type enclosed in balanced parens */
+ t_str = (char*)form;
+ for(v = 1;;)
+ { switch(*form++)
+ {
+ case 0 : /* not balancable, retract */
+ form = t_str;
+ t_str = NIL(char*);
+ n_str = 0;
+ goto loop_flags;
+ case LEFTP : /* increasing nested level */
+ v += 1;
+ continue;
+ case RIGHTP : /* decreasing nested level */
+ if((v -= 1) != 0)
+ continue;
+ n_str = form-t_str;
+ if(*t_str == '*')
+ { t_str = sffmtint(t_str+1,&n);
+ if(*t_str == '$')
+ dollar = 1;
+ else n = -1;
+ if((n = FP_SET(n,argn)) > maxp)
+ maxp = n;
+ if(fp && fp[n].ft.fmt == 0)
+ { fp[n].ft.fmt = LEFTP;
+ fp[n].ft.form = (char*)form;
+ }
+ need[FP_STR] = n;
+ }
+ goto loop_flags;
+ }
+ }
+
+ case '-' :
+ flags |= SFFMT_LEFT;
+ flags &= ~SFFMT_ZERO;
+ goto loop_flags;
+ case '0' :
+ if(!(flags&SFFMT_LEFT) )
+ flags |= SFFMT_ZERO;
+ goto loop_flags;
+ case ' ' :
+ if(!(flags&SFFMT_SIGN) )
+ flags |= SFFMT_BLANK;
+ goto loop_flags;
+ case '+' :
+ flags |= SFFMT_SIGN;
+ flags &= ~SFFMT_BLANK;
+ goto loop_flags;
+ case '#' :
+ flags |= SFFMT_ALTER;
+ goto loop_flags;
+ case QUOTE:
+ SFSETLOCALE(&decimal,&thousand);
+ if(thousand > 0)
+ flags |= SFFMT_THOUSAND;
+ goto loop_flags;
+
+ case '.' :
+ if((dot += 1) == 2)
+ base = 0; /* for %s,%c */
+ if(isdigit(*form))
+ { fmt = *form++;
+ goto dot_size;
+ }
+ else if(*form != '*')
+ goto loop_flags;
+ else form += 1; /* drop thru below */
+
+ case '*' :
+ form = sffmtint(form,&n);
+ if(*form == '$' )
+ { dollar = 1;
+ form += 1;
+ }
+ else n = -1;
+ if((n = FP_SET(n,argn)) > maxp)
+ maxp = n;
+ if(fp && fp[n].ft.fmt == 0)
+ { fp[n].ft.fmt = '.';
+ fp[n].ft.size = dot;
+ fp[n].ft.form = (char*)form;
+ }
+ if(dot <= 2)
+ need[dot] = n;
+ goto loop_flags;
+
+ case '1' : case '2' : case '3' :
+ case '4' : case '5' : case '6' :
+ case '7' : case '8' : case '9' :
+ dot_size :
+ for(v = fmt - '0', fmt = *form; isdigit(fmt); fmt = *++form)
+ v = v*10 + (fmt - '0');
+ if(dot == 0)
+ width = v;
+ else if(dot == 1)
+ precis = v;
+ else if(dot == 2)
+ base = v;
+ goto loop_flags;
+
+ case 'I' : /* object length */
+ size = -1; flags = (flags & ~SFFMT_TYPES) | SFFMT_IFLAG;
+ if(isdigit(*form) )
+ { for(size = 0, n = *form; isdigit(n); n = *++form)
+ size = size*10 + (n - '0');
+ }
+ else if(*form == '*')
+ { form = sffmtint(form+1,&n);
+ if(*form == '$' )
+ { dollar = 1;
+ form += 1;
+ }
+ else n = -1;
+ if((n = FP_SET(n,argn)) > maxp)
+ maxp = n;
+ if(fp && fp[n].ft.fmt == 0)
+ { fp[n].ft.fmt = 'I';
+ fp[n].ft.size = sizeof(int);
+ fp[n].ft.form = (char*)form;
+ }
+ need[FP_SIZE] = n;
+ }
+ goto loop_flags;
+
+ case 'l' :
+ size = -1; flags &= ~SFFMT_TYPES;
+ if(*form == 'l')
+ { form += 1;
+ flags |= SFFMT_LLONG;
+ }
+ else flags |= SFFMT_LONG;
+ goto loop_flags;
+ case 'h' :
+ size = -1; flags &= ~SFFMT_TYPES;
+ if(*form == 'h')
+ { form += 1;
+ flags |= SFFMT_SSHORT;
+ }
+ else flags |= SFFMT_SHORT;
+ goto loop_flags;
+ case 'L' :
+ size = -1; flags = (flags & ~SFFMT_TYPES) | SFFMT_LDOUBLE;
+ goto loop_flags;
+ }
+
+ /* set object size for scalars */
+ if(flags & SFFMT_TYPES)
+ { if((_Sftype[fmt]&(SFFMT_INT|SFFMT_UINT)) || fmt == 'n')
+ { if(flags&SFFMT_LONG)
+ size = sizeof(long);
+ else if(flags&SFFMT_SHORT)
+ size = sizeof(short);
+ else if(flags&SFFMT_SSHORT)
+ size = sizeof(char);
+ else if(flags&SFFMT_TFLAG)
+ size = sizeof(ptrdiff_t);
+ else if(flags&SFFMT_ZFLAG)
+ size = sizeof(size_t);
+ else if(flags&(SFFMT_LLONG|SFFMT_JFLAG) )
+ size = sizeof(Sflong_t);
+ else if(flags&SFFMT_IFLAG)
+ { if(size <= 0 ||
+ size == sizeof(Sflong_t)*CHAR_BIT )
+ size = sizeof(Sflong_t);
+ }
+ else if(size < 0)
+ size = sizeof(int);
+ }
+ else if(_Sftype[fmt]&SFFMT_FLOAT)
+ { if(flags&(SFFMT_LONG|SFFMT_LLONG))
+ size = sizeof(double);
+ else if(flags&SFFMT_LDOUBLE)
+ size = sizeof(Sfdouble_t);
+ else if(flags&SFFMT_IFLAG)
+ { if(size <= 0)
+ size = sizeof(Sfdouble_t);
+ }
+ else if(size < 0)
+ size = sizeof(float);
+ }
+ else if(_Sftype[fmt]&SFFMT_CHAR)
+ {
+#if _has_multibyte
+ if((flags&SFFMT_LONG) || fmt == 'C')
+ { size = sizeof(wchar_t) > sizeof(int) ?
+ sizeof(wchar_t) : sizeof(int);
+ } else
+#endif
+ if(size < 0)
+ size = sizeof(int);
+ }
+ }
+
+ if(skip)
+ continue;
+
+ if((argp = FP_SET(argp,argn)) > maxp)
+ maxp = argp;
+
+ if(dollar && fmt == '!')
+ return NIL(Fmtpos_t*);
+
+ if(fp && fp[argp].ft.fmt == 0)
+ { fp[argp].ft.form = (char*)form;
+ fp[argp].ft.fmt = fp[argp].fmt = fmt;
+ fp[argp].ft.size = size;
+ fp[argp].ft.flags = flags;
+ fp[argp].ft.width = width;
+ fp[argp].ft.precis = precis;
+ fp[argp].ft.base = base;
+ fp[argp].ft.t_str = t_str;
+ fp[argp].ft.n_str = n_str;
+ for(n = 0; n < FP_INDEX; ++n)
+ fp[argp].need[n] = need[n];
+ }
+ }
+
+ if(!fp) /* constructing position array only */
+ { if(!dollar || !(fp = (Fmtpos_t*)malloc((maxp+1)*sizeof(Fmtpos_t))) )
+ return NIL(Fmtpos_t*);
+ for(n = 0; n <= maxp; ++n)
+ fp[n].ft.fmt = 0;
+ return fp;
+ }
+
+ /* get value for positions */
+ for(n = 0; n <= maxp; ++n)
+ { if(fp[n].ft.fmt == 0) /* gap: pretend it's a 'd' pattern */
+ { fp[n].ft.fmt = 'd';
+ fp[n].ft.width = 0;
+ fp[n].ft.precis = 0;
+ fp[n].ft.base = 0;
+ fp[n].ft.size = 0;
+ fp[n].ft.t_str = 0;
+ fp[n].ft.n_str = 0;
+ fp[n].ft.flags = 0;
+ for(v = 0; v < FP_INDEX; ++v)
+ fp[n].need[v] = -1;
+ }
+
+ if(ft && ft->extf)
+ { fp[n].ft.version = ft->version;
+ fp[n].ft.extf = ft->extf;
+ fp[n].ft.eventf = ft->eventf;
+ if((v = fp[n].need[FP_WIDTH]) >= 0 && v < n)
+ fp[n].ft.width = fp[v].argv.i;
+ if((v = fp[n].need[FP_PRECIS]) >= 0 && v < n)
+ fp[n].ft.precis = fp[v].argv.i;
+ if((v = fp[n].need[FP_BASE]) >= 0 && v < n)
+ fp[n].ft.base = fp[v].argv.i;
+ if((v = fp[n].need[FP_STR]) >= 0 && v < n)
+ fp[n].ft.t_str = fp[v].argv.s;
+ if((v = fp[n].need[FP_SIZE]) >= 0 && v < n)
+ fp[n].ft.size = fp[v].argv.i;
+
+ memcpy(ft,&fp[n].ft,sizeof(Sffmt_t));
+ va_copy(ft->args,args);
+ ft->flags |= SFFMT_ARGPOS;
+ v = (*ft->extf)(f, (Void_t*)(&fp[n].argv), ft);
+ va_copy(args,ft->args);
+ memcpy(&fp[n].ft,ft,sizeof(Sffmt_t));
+ if(v < 0)
+ { memcpy(ft,&savft,sizeof(Sffmt_t));
+ ft = NIL(Sffmt_t*);
+ }
+
+ if(!(fp[n].ft.flags&SFFMT_VALUE) )
+ goto arg_list;
+ else if(_Sftype[fp[n].ft.fmt]&(SFFMT_INT|SFFMT_UINT) )
+ { if(fp[n].ft.size == sizeof(short))
+ { if(_Sftype[fp[n].ft.fmt]&SFFMT_INT)
+ fp[n].argv.i = fp[n].argv.h;
+ else fp[n].argv.i = fp[n].argv.uh;
+ }
+ else if(fp[n].ft.size == sizeof(char))
+ { if(_Sftype[fp[n].ft.fmt]&SFFMT_INT)
+ fp[n].argv.i = fp[n].argv.c;
+ else fp[n].argv.i = fp[n].argv.uc;
+ }
+ }
+ else if(_Sftype[fp[n].ft.fmt]&SFFMT_FLOAT )
+ { if(fp[n].ft.size == sizeof(float) )
+ fp[n].argv.d = fp[n].argv.f;
+ }
+ }
+ else
+ { arg_list:
+ if(fp[n].ft.fmt == LEFTP)
+ { fp[n].argv.s = va_arg(args, char*);
+ fp[n].ft.size = strlen(fp[n].argv.s);
+ }
+ else if(fp[n].ft.fmt == '.' || fp[n].ft.fmt == 'I')
+ fp[n].argv.i = va_arg(args, int);
+ else if(fp[n].ft.fmt == '!')
+ { if(ft)
+ memcpy(ft,&savft,sizeof(Sffmt_t));
+ fp[n].argv.ft = ft = va_arg(args, Sffmt_t*);
+ if(ft->form)
+ ft = NIL(Sffmt_t*);
+ if(ft)
+ memcpy(&savft,ft,sizeof(Sffmt_t));
+ }
+ else if(type > 0) /* from sfvscanf */
+ fp[n].argv.vp = va_arg(args, Void_t*);
+ else switch(_Sftype[fp[n].ft.fmt])
+ { case SFFMT_INT:
+ case SFFMT_UINT:
+#if !_ast_intmax_long
+ if(size == sizeof(Sflong_t) )
+ fp[n].argv.ll = va_arg(args, Sflong_t);
+ else
+#endif
+ if(size == sizeof(long) )
+ fp[n].argv.l = va_arg(args, long);
+ else fp[n].argv.i = va_arg(args, int);
+ break;
+ case SFFMT_FLOAT:
+#if !_ast_fltmax_double
+ if(size == sizeof(Sfdouble_t) )
+ fp[n].argv.ld = va_arg(args,Sfdouble_t);
+ else
+#endif
+ fp[n].argv.d = va_arg(args,double);
+ break;
+ case SFFMT_POINTER:
+ fp[n].argv.vp = va_arg(args,Void_t*);
+ break;
+ case SFFMT_CHAR:
+ if(fp[n].ft.base >= 0)
+ fp[n].argv.s = va_arg(args,char*);
+#if _has_multibyte
+ else if((fp[n].ft.flags & SFFMT_LONG) ||
+ fp[n].ft.fmt == 'C' )
+ { if(sizeof(wchar_t) <= sizeof(int) )
+ fp[n].argv.wc = (wchar_t)va_arg(args,int);
+ else fp[n].argv.wc = va_arg(args,wchar_t);
+ }
+#endif
+ /* observe promotion rule */
+ else fp[n].argv.i = va_arg(args,int);
+ break;
+ default: /* unknown pattern */
+ break;
+ }
+ }
+ }
+
+ if(ft)
+ memcpy(ft,&savft,sizeof(Sffmt_t));
+ return fp;
+}
+
+static const unsigned char flt_nan[] = { _ast_flt_nan_init };
+static const unsigned char flt_inf[] = { _ast_flt_inf_init };
+static const unsigned char dbl_nan[] = { _ast_dbl_nan_init };
+static const unsigned char dbl_inf[] = { _ast_dbl_inf_init };
+#ifdef _ast_ldbl_nan_init
+static const unsigned char ldbl_nan[] = { _ast_ldbl_nan_init };
+static const unsigned char ldbl_inf[] = { _ast_ldbl_inf_init };
+#endif
+
+/* function to initialize conversion tables */
+static int sfcvinit()
+{ reg int d, l;
+
+ for(d = 0; d <= SF_MAXCHAR; ++d)
+ { _Sfcv36[d] = SF_RADIX;
+ _Sfcv64[d] = SF_RADIX;
+ }
+
+ /* [0-9] */
+ for(d = 0; d < 10; ++d)
+ { _Sfcv36[(uchar)_Sfdigits[d]] = d;
+ _Sfcv64[(uchar)_Sfdigits[d]] = d;
+ }
+
+ /* [a-z] */
+ for(; d < 36; ++d)
+ { _Sfcv36[(uchar)_Sfdigits[d]] = d;
+ _Sfcv64[(uchar)_Sfdigits[d]] = d;
+ }
+
+ /* [A-Z] */
+ for(l = 10; d < 62; ++l, ++d)
+ { _Sfcv36[(uchar)_Sfdigits[d]] = l;
+ _Sfcv64[(uchar)_Sfdigits[d]] = d;
+ }
+
+ /* remaining digits */
+ for(; d < SF_RADIX; ++d)
+ { _Sfcv36[(uchar)_Sfdigits[d]] = d;
+ _Sfcv64[(uchar)_Sfdigits[d]] = d;
+ }
+
+ _Sftype['d'] = _Sftype['i'] = SFFMT_INT;
+ _Sftype['u'] = _Sftype['o'] = _Sftype['x'] = _Sftype['X'] = SFFMT_UINT;
+ _Sftype['e'] = _Sftype['E'] = _Sftype['a'] = _Sftype['A'] =
+ _Sftype['g'] = _Sftype['G'] = _Sftype['f'] = SFFMT_FLOAT;
+ _Sftype['s'] = _Sftype['n'] = _Sftype['p'] = _Sftype['!'] = SFFMT_POINTER;
+ _Sftype['c'] = SFFMT_CHAR;
+ _Sftype['['] = SFFMT_CLASS;
+#if _has_multibyte
+ _Sftype['S'] = SFFMT_POINTER;
+ _Sftype['C'] = SFFMT_CHAR;
+#endif
+
+ /* IEEE floating point computed constants */
+
+ memcpy((char*)&_Sffnan, (char*)flt_nan, sizeof(_Sffnan));
+ memcpy((char*)&_Sffinf, (char*)flt_inf, sizeof(_Sffinf));
+ memcpy((char*)&_Sfdnan, (char*)dbl_nan, sizeof(_Sfdnan));
+ memcpy((char*)&_Sfdinf, (char*)dbl_inf, sizeof(_Sfdinf));
+#ifdef _ast_ldbl_nan_init
+ memcpy((char*)&_Sflnan, (char*)ldbl_nan, sizeof(_Sflnan));
+ memcpy((char*)&_Sflinf, (char*)ldbl_inf, sizeof(_Sflinf));
+#else
+ memcpy((char*)&_Sflnan, (char*)dbl_nan, sizeof(_Sfdnan));
+ memcpy((char*)&_Sflinf, (char*)dbl_inf, sizeof(_Sfdinf));
+#endif
+
+ return 1;
+}
+
+/* table for floating point and integer conversions */
+#include "FEATURE/sfinit"
diff --git a/usr/src/lib/libast/common/sfio/sftell.c b/usr/src/lib/libast/common/sfio/sftell.c
new file mode 100644
index 0000000000..0f067d68c2
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sftell.c
@@ -0,0 +1,58 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Tell the current location in a given stream
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+Sfoff_t sftell(reg Sfio_t* f)
+#else
+Sfoff_t sftell(f)
+reg Sfio_t *f;
+#endif
+{
+ reg int mode;
+ Sfoff_t p;
+
+ SFMTXSTART(f, (Sfoff_t)(-1));
+
+ /* set the stream to the right mode */
+ if((mode = f->mode&SF_RDWR) != (int)f->mode && _sfmode(f,mode,0) < 0)
+ SFMTXRETURN(f, (Sfoff_t)(-1));
+
+ /* throw away ungetc data */
+ if(f->disc == _Sfudisc)
+ (void)sfclose((*_Sfstack)(f,NIL(Sfio_t*)));
+
+ if(f->flags&SF_STRING)
+ SFMTXRETURN(f, (Sfoff_t)(f->next-f->data));
+
+ /* let sfseek() handle the hard case */
+ if(f->extent >= 0 && (f->flags&(SF_SHARE|SF_APPENDWR)) )
+ p = sfseek(f,(Sfoff_t)0,SEEK_CUR);
+ else p = f->here + ((f->mode&SF_WRITE) ? f->next-f->data : f->next-f->endb);
+
+ SFMTXRETURN(f,p);
+}
diff --git a/usr/src/lib/libast/common/sfio/sftmp.c b/usr/src/lib/libast/common/sfio/sftmp.c
new file mode 100644
index 0000000000..845826ba80
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sftmp.c
@@ -0,0 +1,402 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Create a temporary stream for read/write.
+** The stream is originally created as a memory-resident stream.
+** When this memory is exceeded, a real temp file will be created.
+** The temp file creation sequence is somewhat convoluted so that
+** pool/stack/discipline will work correctly.
+**
+** Written by David Korn and Kiem-Phong Vo.
+*/
+
+#if _tmp_rmfail
+
+/* File not removable while there is an open file descriptor.
+** To ensure that temp files are properly removed, we need:
+** 1. A discipline to remove a file when the corresponding stream is closed.
+** Care must be taken to close the file descriptor before removing the
+** file because systems such as NT do not allow file removal while
+** there is an open file handle.
+** 2. An atexit() function is set up to close temp files when process exits.
+** 3. On systems with O_TEMPORARY (e.g., NT), this is used to further ensure
+** that temp files will be removed after the last handle is closed.
+*/
+
+typedef struct _file_s File_t;
+struct _file_s
+{ File_t* next; /* link list */
+ Sfio_t* f; /* associated stream */
+ char name[1]; /* temp file name */
+};
+
+static File_t* File; /* list pf temp files */
+
+#if __STD_C
+static int _tmprmfile(Sfio_t* f, int type, Void_t* val, Sfdisc_t* disc)
+#else
+static int _tmprmfile(f, type, val, disc)
+Sfio_t* f;
+int type;
+Void_t* val;
+Sfdisc_t* disc;
+#endif
+{
+ reg File_t *ff, *last;
+
+ NOTUSED(val);
+
+ if(type == SF_DPOP) /* don't allow this to pop */
+ return -1;
+
+ if(type == SF_CLOSING)
+ {
+ (void)vtmtxlock(_Sfmutex);
+ for(last = NIL(File_t*), ff = File; ff; last = ff, ff = ff->next)
+ if(ff->f == f)
+ break;
+ if(ff)
+ { if(!last)
+ File = ff->next;
+ else last->next = ff->next;
+
+ if(_Sfnotify)
+ (*_Sfnotify)(f,SF_CLOSING,f->file);
+ CLOSE(f->file);
+ f->file = -1;
+ while(sysremovef(ff->name) < 0 && errno == EINTR)
+ errno = 0;
+
+ free((Void_t*)ff);
+ }
+ (void)vtmtxunlock(_Sfmutex);
+ }
+
+ return 0;
+}
+
+#if __STD_C
+static void _rmfiles(void)
+#else
+static void _rmfiles()
+#endif
+{ reg File_t *ff, *next;
+
+ (void)vtmtxlock(_Sfmutex);
+ for(ff = File; ff; ff = next)
+ { next = ff->next;
+ _tmprmfile(ff->f, SF_CLOSING, NIL(Void_t*), ff->f->disc);
+ }
+ (void)vtmtxunlock(_Sfmutex);
+}
+
+static Sfdisc_t Rmdisc =
+ { NIL(Sfread_f), NIL(Sfwrite_f), NIL(Sfseek_f), _tmprmfile, NIL(Sfdisc_t*) };
+
+#endif /*_tmp_rmfail*/
+
+#if __STD_C
+static int _rmtmp(Sfio_t* f, char* file)
+#else
+static int _rmtmp(f, file)
+Sfio_t* f;
+char* file;
+#endif
+{
+#if _tmp_rmfail /* remove only when stream is closed */
+ reg File_t* ff;
+
+ if(!File)
+ atexit(_rmfiles);
+
+ if(!(ff = (File_t*)malloc(sizeof(File_t)+strlen(file))) )
+ return -1;
+ (void)vtmtxlock(_Sfmutex);
+ ff->f = f;
+ strcpy(ff->name,file);
+ ff->next = File;
+ File = ff;
+ (void)vtmtxunlock(_Sfmutex);
+
+#else /* can remove now */
+ while(sysremovef(file) < 0 && errno == EINTR)
+ errno = 0;
+#endif
+
+ return 0;
+}
+
+#if !_PACKAGE_ast
+#define TMPDFLT "/tmp"
+static char **Tmppath, **Tmpcur;
+
+#if __STD_C
+char** _sfgetpath(char* path)
+#else
+char** _sfgetpath(path)
+char* path;
+#endif
+{ reg char *p, **dirs;
+ reg int n;
+
+ if(!(path = getenv(path)) )
+ return NIL(char**);
+
+ for(p = path, n = 0;;) /* count number of directories */
+ { while(*p == ':')
+ ++p;
+ if(*p == 0)
+ break;
+ n += 1;
+ while(*p && *p != ':') /* skip dir name */
+ ++p;
+ }
+ if(n == 0 || !(dirs = (char**)malloc((n+1)*sizeof(char*))) )
+ return NIL(char**);
+ if(!(p = (char*)malloc(strlen(path)+1)) )
+ { free(dirs);
+ return NIL(char**);
+ }
+ strcpy(p,path);
+ for(n = 0;; ++n)
+ { while(*p == ':')
+ ++p;
+ if(*p == 0)
+ break;
+ dirs[n] = p;
+ while(*p && *p != ':')
+ ++p;
+ if(*p == ':')
+ *p++ = 0;
+ }
+ dirs[n] = NIL(char*);
+
+ return dirs;
+}
+
+#endif /*!_PACKAGE_ast*/
+
+#if __STD_C
+static int _tmpfd(Sfio_t* f)
+#else
+static int _tmpfd(f)
+Sfio_t* f;
+#endif
+{
+ reg char* file;
+ int fd;
+
+#if _PACKAGE_ast
+ if(!(file = pathtemp(NiL,PATH_MAX,NiL,"sf",&fd)))
+ return -1;
+ _rmtmp(f, file);
+ free(file);
+#else
+ int t;
+
+ /* set up path of dirs to create temp files */
+ if(!Tmppath && !(Tmppath = _sfgetpath("TMPPATH")) )
+ { if(!(Tmppath = (char**)malloc(2*sizeof(char*))) )
+ return -1;
+ if(!(file = getenv("TMPDIR")) )
+ file = TMPDFLT;
+ if(!(Tmppath[0] = (char*)malloc(strlen(file)+1)) )
+ { free(Tmppath);
+ Tmppath = NIL(char**);
+ return -1;
+ }
+ strcpy(Tmppath[0],file);
+ Tmppath[1] = NIL(char*);
+ }
+
+ /* set current directory to create this temp file */
+ if(Tmpcur)
+ Tmpcur += 1;
+ if(!Tmpcur || !Tmpcur[0])
+ Tmpcur = Tmppath;
+
+ fd = -1;
+ for(t = 0; t < 10; ++t)
+ { /* compute a random name */
+ static ulong Key, A;
+ if(A == 0 || t > 0) /* get a quasi-random coefficient */
+ { reg int r;
+ A = (ulong)time(NIL(time_t*)) ^ (((ulong)(&t)) >> 3);
+ if(Key == 0)
+ Key = (A >> 16) | ((A&0xffff)<<16);
+ A ^= Key;
+ if((r = (A-1) & 03) != 0) /* Knuth vol.2, page.16, Thm.A */
+ A += 4-r;
+ }
+
+ Key = A*Key + 987654321;
+ file = sfprints("%s/sf%3.3.32lu.%3.3.32lu",
+ Tmpcur[0], (Key>>15)&0x7fff, Key&0x7fff);
+ if(!file)
+ return -1;
+#if _has_oflags
+ if((fd = sysopenf(file,O_RDWR|O_CREAT|O_EXCL|O_TEMPORARY,SF_CREATMODE)) >= 0)
+ break;
+#else
+ if((fd = sysopenf(file,O_RDONLY)) >= 0)
+ { /* file already exists */
+ CLOSE(fd);
+ fd = -1;
+ }
+ else if((fd = syscreatf(file,SF_CREATMODE)) >= 0)
+ { /* reopen for read and write */
+ CLOSE(fd);
+ if((fd = sysopenf(file,O_RDWR)) >= 0)
+ break;
+
+ /* don't know what happened but must remove file */
+ while(sysremovef(file) < 0 && errno == EINTR)
+ errno = 0;
+ }
+#endif /* _has_oflags */
+ }
+ if(fd >= 0)
+ _rmtmp(f, file);
+#endif /* _PACKAGE_ast */
+ return fd;
+}
+
+#if __STD_C
+static int _tmpexcept(Sfio_t* f, int type, Void_t* val, Sfdisc_t* disc)
+#else
+static int _tmpexcept(f,type,val,disc)
+Sfio_t* f;
+int type;
+Void_t* val;
+Sfdisc_t* disc;
+#endif
+{
+ reg int fd, m;
+ reg Sfio_t* sf;
+ Sfio_t newf, savf;
+ void (*notifyf)_ARG_((Sfio_t*, int, int));
+
+ NOTUSED(val);
+
+ /* the discipline needs to change only under the following exceptions */
+ if(type != SF_WRITE && type != SF_SEEK &&
+ type != SF_DPUSH && type != SF_DPOP && type != SF_DBUFFER)
+ return 0;
+
+ /* notify function */
+ notifyf = _Sfnotify;
+
+ /* try to create the temp file */
+ SFCLEAR(&newf,NIL(Vtmutex_t*));
+ newf.flags = SF_STATIC;
+ newf.mode = SF_AVAIL;
+
+ if((fd = _tmpfd(f)) < 0 )
+ return -1;
+
+ /* make sure that the notify function won't be called here since
+ we are only interested in creating the file, not the stream */
+ _Sfnotify = 0;
+ sf = sfnew(&newf,NIL(Void_t*),(size_t)SF_UNBOUND,fd,SF_READ|SF_WRITE);
+ _Sfnotify = notifyf;
+ if(!sf)
+ return -1;
+
+ if(newf.mutex) /* don't need a mutex for this stream */
+ { (void)vtmtxclrlock(newf.mutex);
+ (void)vtmtxclose(newf.mutex);
+ newf.mutex = NIL(Vtmutex_t*);
+ }
+
+ /* make sure that new stream has the same mode */
+ if((m = f->flags&(SF_READ|SF_WRITE)) != (SF_READ|SF_WRITE))
+ sfset(sf, ((~m)&(SF_READ|SF_WRITE)), 0);
+ sfset(sf, (f->mode&(SF_READ|SF_WRITE)), 1);
+
+ /* now remake the old stream into the new image */
+ memcpy((Void_t*)(&savf), (Void_t*)f, sizeof(Sfio_t));
+ memcpy((Void_t*)f, (Void_t*)sf, sizeof(Sfio_t));
+ f->push = savf.push;
+ f->pool = savf.pool;
+ f->rsrv = savf.rsrv;
+ f->proc = savf.proc;
+ f->mutex = savf.mutex;
+ f->stdio = savf.stdio;
+
+ if(savf.data)
+ { SFSTRSIZE(&savf);
+ if(!(savf.flags&SF_MALLOC) )
+ (void)sfsetbuf(f,(Void_t*)savf.data,savf.size);
+ if(savf.extent > 0)
+ (void)sfwrite(f,(Void_t*)savf.data,(size_t)savf.extent);
+ (void)sfseek(f,(Sfoff_t)(savf.next - savf.data),SEEK_SET);
+ if((savf.flags&SF_MALLOC) )
+ free((Void_t*)savf.data);
+ }
+
+ /* announce change of status */
+ if(notifyf)
+ (*notifyf)(f,SF_NEW,f->file);
+
+ f->disc = disc->disc;
+
+ /* erase all traces of newf */
+ newf.data = newf.endb = newf.endr = newf.endw = NIL(uchar*);
+ newf.file = -1;
+ sfclose(&newf);
+
+ return 1;
+}
+
+#if __STD_C
+Sfio_t* sftmp(reg size_t s)
+#else
+Sfio_t* sftmp(s)
+reg size_t s;
+#endif
+{
+ reg Sfio_t* f;
+ static Sfdisc_t Tmpdisc =
+ { NIL(Sfread_f), NIL(Sfwrite_f), NIL(Sfseek_f), _tmpexcept,
+#if _tmp_rmfail
+ &Rmdisc
+#else
+ NIL(Sfdisc_t*)
+#endif
+ };
+
+ /* start with a memory resident stream */
+ if(!(f = sfnew(NIL(Sfio_t*),NIL(char*),s,-1,SF_STRING|SF_READ|SF_WRITE)) )
+ return NIL(Sfio_t*);
+
+ if(s != (size_t)SF_UNBOUND) /* set up a discipline for out-of-bound, etc. */
+ f->disc = &Tmpdisc;
+
+ /* make the file now */
+ if(s == 0 && _tmpexcept(f,SF_DPOP,NIL(Void_t*),f->disc) < 0)
+ { sfclose(f);
+ return NIL(Sfio_t*);
+ }
+
+ return f;
+}
diff --git a/usr/src/lib/libast/common/sfio/sfungetc.c b/usr/src/lib/libast/common/sfio/sfungetc.c
new file mode 100644
index 0000000000..7dfbda4af4
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfungetc.c
@@ -0,0 +1,107 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Push back one byte to a given SF_READ stream
+**
+** Written by Kiem-Phong Vo.
+*/
+#if __STD_C
+static int _uexcept(reg Sfio_t* f, reg int type, Void_t* val, reg Sfdisc_t* disc)
+#else
+static int _uexcept(f,type,val,disc)
+reg Sfio_t *f;
+reg int type;
+Void_t* val;
+reg Sfdisc_t *disc;
+#endif
+{
+ NOTUSED(val);
+
+ /* hmm! This should never happen */
+ if(disc != _Sfudisc)
+ return -1;
+
+ /* close the unget stream */
+ if(type != SF_CLOSING)
+ (void)sfclose((*_Sfstack)(f,NIL(Sfio_t*)));
+
+ return 1;
+}
+
+#if __STD_C
+int sfungetc(reg Sfio_t* f, reg int c)
+#else
+int sfungetc(f,c)
+reg Sfio_t* f; /* push back one byte to this stream */
+reg int c; /* the value to be pushed back */
+#endif
+{
+ reg Sfio_t* uf;
+
+ SFMTXSTART(f, -1)
+
+ if(c < 0 || (f->mode != SF_READ && _sfmode(f,SF_READ,0) < 0))
+ SFMTXRETURN(f, -1);
+ SFLOCK(f,0);
+
+ /* fast handling of the typical unget */
+ if(f->next > f->data && f->next[-1] == (uchar)c)
+ { f->next -= 1;
+ goto done;
+ }
+
+ /* make a string stream for unget characters */
+ if(f->disc != _Sfudisc)
+ { if(!(uf = sfnew(NIL(Sfio_t*),NIL(char*),(size_t)SF_UNBOUND,
+ -1,SF_STRING|SF_READ)))
+ { c = -1;
+ goto done;
+ }
+ _Sfudisc->exceptf = _uexcept;
+ sfdisc(uf,_Sfudisc);
+ SFOPEN(f,0); (void)sfstack(f,uf); SFLOCK(f,0);
+ }
+
+ /* space for data */
+ if(f->next == f->data)
+ { reg uchar* data;
+ if(f->size < 0)
+ f->size = 0;
+ if(!(data = (uchar*)malloc(f->size+16)))
+ { c = -1;
+ goto done;
+ }
+ f->flags |= SF_MALLOC;
+ if(f->data)
+ memcpy((char*)(data+16),(char*)f->data,f->size);
+ f->size += 16;
+ f->data = data;
+ f->next = data+16;
+ f->endb = data+f->size;
+ }
+
+ *--f->next = (uchar)c;
+done:
+ SFOPEN(f,0);
+ SFMTXRETURN(f, c);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfvprintf.c b/usr/src/lib/libast/common/sfio/sfvprintf.c
new file mode 100644
index 0000000000..d73538e6fd
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfvprintf.c
@@ -0,0 +1,1377 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* The engine for formatting data.
+** 1. Argument positioning is done in sftable.c so any changes
+** made here should be reflected in sftable.c as well.
+** 2. For internationalization, Sfio only supports I/O of multibyte strings.
+** However, this code does provide minimal support so that Stdio functions
+** such as fwprintf/swprintf can be emulated (see stdvwprintf()).
+**
+** Written by Kiem-Phong Vo.
+*/
+#define HIGHBITI (~((~((uint)0)) >> 1))
+#define HIGHBITL (~((~((Sfulong_t)0)) >> 1))
+
+#define SFFMT_PREFIX (SFFMT_MINUS|SFFMT_SIGN|SFFMT_BLANK)
+
+#define FPRECIS 6 /* default precision for floats */
+
+#if _PACKAGE_ast
+#include <ccode.h>
+#else
+/* characters when using ebcdic or ascii */
+#if _chr_ebcdic
+#define CC_vt 013 /* vertical tab */
+#define CC_esc 047 /* escape */
+#define CC_bel 057 /* bell */
+#else
+#define CC_vt 013 /* vertical tab */
+#define CC_esc 033 /* escape */
+#define CC_bel 007 /* bell */
+#endif /* _chr_ebcdic */
+#endif /* _PACKAGE_ast */
+
+#if __STD_C
+static int chr2str(char* buf, int v)
+#else
+static int chr2str(buf, v)
+char* buf;
+int v;
+#endif
+{
+ if(isprint(v) && v != '\\')
+ { *buf++ = v;
+ return 1;
+ }
+ else
+ { *buf++ = '\\';
+ switch(v)
+ { case CC_bel: *buf++ = 'a'; return 2;
+ case CC_vt: *buf++ = 'v'; return 2;
+ case CC_esc: *buf++ = 'E'; return 2;
+ case '\b': *buf++ = 'b'; return 2;
+ case '\f': *buf++ = 'f'; return 2;
+ case '\n': *buf++ = 'n'; return 2;
+ case '\r': *buf++ = 'r'; return 2;
+ case '\t': *buf++ = 't'; return 2;
+ case '\\': *buf++ = '\\'; return 2;
+ default: *buf++ = '0' + ((v >> 6) & 03);
+ *buf++ = '0' + ((v >> 3) & 07);
+ *buf++ = '0' + ((v >> 0) & 07);
+ return 4;
+ }
+ }
+}
+
+/* On some platform(s), large functions are not compilable.
+** In such a case, the below macro should be defined non-zero so that
+** some in-lined macros will be made smaller, trading time for space.
+*/
+#if !defined(_sffmt_small) && defined(_UTS)
+#define _sffmt_small 1
+#endif
+
+#if __STD_C
+int sfvprintf(Sfio_t* f, const char* form, va_list args)
+#else
+int sfvprintf(f,form,args)
+Sfio_t* f; /* file to print to */
+char* form; /* format to use */
+va_list args; /* arg list if !argf */
+#endif
+{
+ int n, v, w, k, n_s, base, fmt, flags;
+ Sflong_t lv;
+ char *sp, *ssp, *endsp, *ep, *endep;
+ int dot, width, precis, sign, decpt;
+#if _PACKAGE_ast
+ int scale;
+#endif
+ ssize_t size;
+ Sfdouble_t dval;
+ char *tls[2], **ls; /* for %..[separ]s */
+ char* t_str; /* stuff between () */
+ ssize_t n_str; /* its length */
+
+ Argv_t argv; /* for extf to return value */
+ Sffmt_t *ft; /* format environment */
+ Fmt_t *fm, *fmstk; /* stack contexts */
+
+ char* oform; /* original format string */
+ va_list oargs; /* original arg list */
+ Fmtpos_t* fp; /* arg position list */
+ int argp, argn; /* arg position and number */
+
+#define SLACK 1024
+ char buf[SF_MAXDIGITS+SLACK], tmp[SF_MAXDIGITS+1], data[SF_GRAIN];
+ int decimal = 0, thousand = 0;
+
+#if _has_multibyte
+ wchar_t* wsp;
+ SFMBDCL(fmbs) /* state of format string */
+ SFMBDCL(mbs) /* state of some string */
+#ifdef mbwidth
+ char* osp;
+ int n_w, sf_wcwidth;
+#endif
+#endif
+
+ /* local io system */
+ int o, n_output;
+#define SMputc(f,c) { if((o = SFFLSBUF(f,c)) >= 0 ) n_output += 1; \
+ else { SFBUF(f); goto done; } \
+ }
+#define SMnputc(f,c,n) { if((o = SFNPUTC(f,c,n)) > 0 ) n_output += 1; \
+ if(o != n) { SFBUF(f); goto done; } \
+ }
+#define SMwrite(f,s,n) { if((o = SFWRITE(f,(Void_t*)s,n)) > 0 ) n_output += o; \
+ if(o != n) { SFBUF(f); goto done; } \
+ }
+#if _sffmt_small /* these macros are made smaller at some performance cost */
+#define SFBUF(f)
+#define SFINIT(f) (n_output = 0)
+#define SFEND(f)
+#define SFputc(f,c) SMputc(f,c)
+#define SFnputc(f,c,n) SMnputc(f,c,n)
+#define SFwrite(f,s,n) SMwrite(f,s,n)
+#else
+ uchar *d, *endd;
+#define SFBUF(f) (d = f->next, endd = f->endb)
+#define SFINIT(f) (SFBUF(f), n_output = 0)
+#define SFEND(f) ((n_output += d - f->next), (f->next = d))
+#define SFputc(f,c) { if(d < endd) { *d++ = (uchar)c; } \
+ else { SFEND(f); SMputc(f,c); SFBUF(f); } \
+ }
+#define SFnputc(f,c,n) { if(d+n <= endd) { while(n--) *d++ = (uchar)(c); } \
+ else { SFEND(f); SMnputc(f,c,n); SFBUF(f); } \
+ }
+#define SFwrite(f,s,n) { if(d+n <= endd) { while(n--) *d++ = (uchar)(*s++); } \
+ else { SFEND(f); SMwrite(f,s,n); SFBUF(f); } \
+ }
+#endif /* _sffmt_small */
+
+ SFCVINIT(); /* initialize conversion tables */
+
+ SFMTXSTART(f,-1);
+
+ if(!form)
+ SFMTXRETURN(f, -1);
+
+ /* make sure stream is in write mode and buffer is not NULL */
+ if(f->mode != SF_WRITE && _sfmode(f,SF_WRITE,0) < 0)
+ SFMTXRETURN(f, -1);
+
+ SFLOCK(f,0);
+
+ if(!f->data && !(f->flags&SF_STRING))
+ { f->data = f->next = (uchar*)data;
+ f->endb = f->data+sizeof(data);
+ }
+ SFINIT(f);
+#if _has_multibyte && defined(mbwidth)
+ sf_wcwidth = f->flags & SF_WCWIDTH;
+#endif
+
+ tls[1] = NIL(char*);
+
+ fmstk = NIL(Fmt_t*);
+ ft = NIL(Sffmt_t*);
+
+ oform = (char*)form;
+ va_copy(oargs,args);
+ argn = -1;
+ fp = NIL(Fmtpos_t*);
+
+loop_fmt :
+ SFMBCLR(&fmbs); /* clear multibyte states to parse the format string */
+ while((n = *form) )
+ { if(n != '%') /* collect the non-pattern chars */
+ { sp = (char*)form;
+ do
+ { if((n = SFMBLEN(form, &fmbs)) <= 0)
+ { n = 1;
+ SFMBCLR(&fmbs);
+ }
+ } while(*(form += n) && *form != '%');
+
+ n = form-sp;
+ SFwrite(f,sp,n);
+ continue;
+ }
+ else form += 1;
+
+ flags = 0;
+#if _PACKAGE_ast
+ scale = 0;
+#endif
+ size = width = precis = base = n_s = argp = -1;
+ ssp = _Sfdigits;
+ endep = ep = NIL(char*);
+ endsp = sp = buf+(sizeof(buf)-1);
+ t_str = NIL(char*);
+ n_str = dot = 0;
+
+ loop_flags: /* LOOP FOR \0, %, FLAGS, WIDTH, PRECISION, BASE, TYPE */
+ switch((fmt = *form++) )
+ {
+ case '\0':
+ SFputc(f,'%');
+ goto pop_fmt;
+ case '%' :
+ SFputc(f,'%');
+ continue;
+
+ case LEFTP : /* get the type enclosed in balanced parens */
+ t_str = (char*)form;
+ for(v = 1;;)
+ { switch(*form++)
+ {
+ case 0 : /* not balancable, retract */
+ form = t_str;
+ t_str = NIL(char*);
+ n_str = 0;
+ goto loop_flags;
+ case LEFTP : /* increasing nested level */
+ v += 1;
+ continue;
+ case RIGHTP : /* decreasing nested level */
+ if((v -= 1) != 0)
+ continue;
+ if(*t_str != '*' )
+ n_str = (form-1)-t_str;
+ else
+ { t_str = (*_Sffmtintf)(t_str+1,&n);
+ if(*t_str == '$')
+ { if(!fp &&
+ !(fp = (*_Sffmtposf)
+ (f,oform,oargs,ft,0)) )
+ goto pop_fmt;
+ n = FP_SET(n,argn);
+ }
+ else n = FP_SET(-1,argn);
+
+ if(fp)
+ { t_str = fp[n].argv.s;
+ n_str = fp[n].ft.size;
+ }
+ else if(ft && ft->extf )
+ { FMTSET(ft, form,args,
+ LEFTP, 0, 0, 0,0,0,
+ NIL(char*),0);
+ n = (*ft->extf)
+ (f,(Void_t*)&argv,ft);
+ if(n < 0)
+ goto pop_fmt;
+ if(!(ft->flags&SFFMT_VALUE) )
+ goto t_arg;
+ if((t_str = argv.s) &&
+ (n_str = (int)ft->size) < 0)
+ n_str = strlen(t_str);
+ }
+ else
+ { t_arg:
+ if((t_str = va_arg(args,char*)) )
+ n_str = strlen(t_str);
+ }
+ }
+ goto loop_flags;
+ }
+ }
+
+ case '-' :
+ flags = (flags & ~(SFFMT_CENTER|SFFMT_ZERO)) | SFFMT_LEFT;
+ goto loop_flags;
+ case '0' :
+ if(!(flags&(SFFMT_LEFT|SFFMT_CENTER)) )
+ flags |= SFFMT_ZERO;
+ goto loop_flags;
+ case ' ' :
+ if(!(flags&SFFMT_SIGN) )
+ flags |= SFFMT_BLANK;
+ goto loop_flags;
+ case '+' :
+ flags = (flags & ~SFFMT_BLANK) | SFFMT_SIGN;
+ goto loop_flags;
+ case '=' :
+ flags = (flags & ~(SFFMT_LEFT|SFFMT_ZERO)) | SFFMT_CENTER;
+ goto loop_flags;
+ case '#' :
+ flags |= SFFMT_ALTER;
+ goto loop_flags;
+ case QUOTE:
+ SFSETLOCALE(&decimal,&thousand);
+ if(thousand > 0)
+ flags |= SFFMT_THOUSAND;
+ goto loop_flags;
+
+ case '.' :
+ dot += 1;
+ if(dot == 1)
+ { /* so base can be defined without setting precis */
+ if(*form != '.')
+ precis = 0;
+ }
+ else if(dot == 2)
+ { base = 0; /* for %s,%c */
+ v = form[0] == 'l' ? form[1] : form[0];
+ if(v == 'c' || v == 'C' || v == 's' || v == 'S')
+ goto loop_flags;
+ if(*form && !isalnum(*form))
+ { v = form[1] == 'l' ? form[2] : form[1];
+ if(v == 'c' || v == 'C' || v == 's' || v == 'S')
+ { if(*form == '*')
+ goto do_star;
+ else
+ { base = *form++;
+ goto loop_flags;
+ }
+ }
+ }
+ }
+
+ if(isdigit(*form) )
+ { fmt = *form++;
+ goto dot_size;
+ }
+ else if(*form != '*')
+ goto loop_flags;
+ do_star:
+ form += 1; /* fall thru for '*' */
+ case '*' :
+ form = (*_Sffmtintf)(form,&n);
+ if(*form == '$')
+ { form += 1;
+ if(!fp && !(fp = (*_Sffmtposf)(f,oform,oargs,ft,0)) )
+ goto pop_fmt;
+ n = FP_SET(n,argn);
+ }
+ else n = FP_SET(-1,argn);
+
+ if(fp)
+ v = fp[n].argv.i;
+ else if(ft && ft->extf)
+ { FMTSET(ft, form,args, '.',dot, 0, 0,0,0, NIL(char*), 0);
+ if((*ft->extf)(f, (Void_t*)(&argv), ft) < 0)
+ goto pop_fmt;
+ fmt = ft->fmt;
+ flags = (flags&~SFFMT_TYPES) | (ft->flags&SFFMT_TYPES);
+ if(ft->flags&SFFMT_VALUE)
+ v = argv.i;
+ else v = (dot <= 2) ? va_arg(args,int) : 0;
+ }
+ else v = dot <= 2 ? va_arg(args,int) : 0;
+ goto dot_set;
+
+ case '1' : case '2' : case '3' :
+ case '4' : case '5' : case '6' :
+ case '7' : case '8' : case '9' :
+ dot_size :
+ for(v = fmt - '0'; isdigit(*form); ++form)
+ v = v*10 + (*form - '0');
+ if(*form == '$')
+ { form += 1;
+ if(!fp && !(fp = (*_Sffmtposf)(f,oform,oargs,ft,0)) )
+ goto pop_fmt;
+ argp = v-1;
+ goto loop_flags;
+ }
+ dot_set :
+ if(dot == 0)
+ { if((width = v) < 0)
+ { width = -width;
+ flags = (flags & ~(SFFMT_CENTER|SFFMT_ZERO)) | SFFMT_LEFT;
+ }
+ }
+ else if(dot == 1)
+ precis = v;
+ else if(dot == 2)
+ base = v;
+ goto loop_flags;
+
+ case 'I' : /* object length */
+ size = -1; flags = (flags & ~SFFMT_TYPES) | SFFMT_IFLAG;
+ if(isdigit(*form) )
+ { for(size = 0, n = *form; isdigit(n); n = *++form)
+ size = size*10 + (n - '0');
+ }
+ else if(*form == '*')
+ { form = (*_Sffmtintf)(form+1,&n);
+ if(*form == '$')
+ { form += 1;
+ if(!fp &&
+ !(fp = (*_Sffmtposf)(f,oform,oargs,ft,0)))
+ goto pop_fmt;
+ n = FP_SET(n,argn);
+ }
+ else n = FP_SET(-1,argn);
+
+ if(fp) /* use position list */
+ size = fp[n].argv.i;
+ else if(ft && ft->extf)
+ { FMTSET(ft, form,args, 'I',sizeof(int), 0, 0,0,0,
+ NIL(char*), 0);
+ if((*ft->extf)(f, (Void_t*)(&argv), ft) < 0)
+ goto pop_fmt;
+ if(ft->flags&SFFMT_VALUE)
+ size = argv.i;
+ else size = va_arg(args,int);
+ }
+ else size = va_arg(args,int);
+ }
+ goto loop_flags;
+
+ case 'l' :
+ size = -1; flags &= ~SFFMT_TYPES;
+ if(*form == 'l')
+ { form += 1;
+ flags |= SFFMT_LLONG;
+ }
+ else flags |= SFFMT_LONG;
+ goto loop_flags;
+ case 'h' :
+ size = -1; flags &= ~SFFMT_TYPES;
+ if(*form == 'h')
+ { form += 1;
+ flags |= SFFMT_SSHORT;
+ }
+ else flags |= SFFMT_SHORT;
+ goto loop_flags;
+ case 'L' :
+ size = -1; flags = (flags & ~SFFMT_TYPES) | SFFMT_LDOUBLE;
+ goto loop_flags;
+
+ case 'j' :
+ size = -1; flags = (flags&~SFFMT_TYPES) | SFFMT_JFLAG;
+ goto loop_flags;
+ case 'z' :
+ size = -1; flags = (flags&~SFFMT_TYPES) | SFFMT_ZFLAG;
+ goto loop_flags;
+ case 't' :
+ size = -1; flags = (flags&~SFFMT_TYPES) | SFFMT_TFLAG;
+ goto loop_flags;
+ default:
+ break;
+ }
+
+ /* set object size for scalars */
+ if(flags & SFFMT_TYPES)
+ { if((_Sftype[fmt]&(SFFMT_INT|SFFMT_UINT)) || fmt == 'n')
+ { if(flags&SFFMT_LONG)
+ size = sizeof(long);
+ else if(flags&SFFMT_SHORT)
+ size = sizeof(short);
+ else if(flags&SFFMT_SSHORT)
+ size = sizeof(char);
+ else if(flags&SFFMT_TFLAG)
+ size = sizeof(ptrdiff_t);
+ else if(flags&SFFMT_ZFLAG)
+ size = sizeof(size_t);
+ else if(flags&(SFFMT_LLONG|SFFMT_JFLAG) )
+ size = sizeof(Sflong_t);
+ else if(flags&SFFMT_IFLAG)
+ { if(size <= 0 ||
+ size == sizeof(Sflong_t)*CHAR_BIT )
+ size = sizeof(Sflong_t);
+ }
+ else if(size < 0)
+ size = sizeof(int);
+ }
+ else if(_Sftype[fmt]&SFFMT_FLOAT)
+ { if(flags&SFFMT_LDOUBLE)
+ size = sizeof(Sfdouble_t);
+ else if(flags&(SFFMT_LONG|SFFMT_LLONG))
+ size = sizeof(double);
+ else if(flags&SFFMT_IFLAG)
+ { if(size <= 0)
+ size = sizeof(Sfdouble_t);
+ }
+ else if(size < 0)
+ size = sizeof(float);
+ }
+ else if(_Sftype[fmt]&SFFMT_CHAR)
+ {
+#if _has_multibyte
+ if((flags&SFFMT_LONG) || fmt == 'C')
+ { size = sizeof(wchar_t) > sizeof(int) ?
+ sizeof(wchar_t) : sizeof(int);
+ } else
+#endif
+ if(size < 0)
+ size = sizeof(int);
+ }
+ }
+
+ argp = FP_SET(argp,argn);
+ if(fp)
+ { if(ft && ft->extf && fp[argp].ft.fmt != fp[argp].fmt)
+ fmt = fp[argp].ft.fmt;
+ argv = fp[argp].argv;
+ size = fp[argp].ft.size;
+ }
+ else if(ft && ft->extf ) /* extended processing */
+ { FMTSET(ft, form,args, fmt, size,flags, width,precis,base,
+ t_str,n_str);
+ SFEND(f); SFOPEN(f,0);
+ v = (*ft->extf)(f, (Void_t*)(&argv), ft);
+ SFLOCK(f,0); SFBUF(f);
+
+ if(v < 0) /* no further processing */
+ goto pop_fmt;
+ else if(v > 0) /* extf output v bytes */
+ { n_output += v;
+ continue;
+ }
+ else /* extf did not output */
+ { FMTGET(ft, form,args, fmt, size,flags, width,precis,base);
+
+ if(!(ft->flags&SFFMT_VALUE))
+ goto arg_list;
+ else if(_Sftype[fmt]&(SFFMT_INT|SFFMT_UINT) )
+ { if(size == sizeof(short))
+ { if(_Sftype[fmt]&SFFMT_INT)
+ argv.i = argv.h;
+ else argv.i = argv.uh;
+ }
+ else if(size == sizeof(char))
+ { if(_Sftype[fmt]&SFFMT_INT)
+ argv.i = argv.c;
+ else argv.i = argv.uc;
+ }
+ }
+ else if(_Sftype[fmt]&SFFMT_FLOAT )
+ { if(size == sizeof(float) )
+ argv.d = argv.f;
+ }
+ else if(_Sftype[fmt]&SFFMT_CHAR)
+ { if(base < 0)
+ argv.i = (int)argv.c;
+ }
+ }
+ }
+ else
+ { arg_list:
+ switch(_Sftype[fmt])
+ { case SFFMT_INT:
+ case SFFMT_UINT:
+#if !_ast_intmax_long
+ if(size == sizeof(Sflong_t))
+ argv.ll = va_arg(args, Sflong_t);
+ else
+#endif
+ if(size == sizeof(long) )
+ argv.l = va_arg(args, long);
+ else argv.i = va_arg(args, int);
+ break;
+ case SFFMT_FLOAT:
+#if !_ast_fltmax_double
+ if(size == sizeof(Sfdouble_t))
+ argv.ld = va_arg(args,Sfdouble_t);
+ else
+#endif
+ argv.d = va_arg(args,double);
+ break;
+ case SFFMT_POINTER:
+ argv.vp = va_arg(args,Void_t*);
+ break;
+ case SFFMT_CHAR:
+ if(base >= 0)
+ argv.s = va_arg(args,char*);
+#if _has_multibyte
+ else if((flags & SFFMT_LONG) || fmt == 'C')
+ { if(sizeof(wchar_t) <= sizeof(uint) )
+ argv.wc = (wchar_t)va_arg(args,uint);
+ else argv.wc = va_arg(args,wchar_t);
+ }
+#endif
+ else argv.i = va_arg(args,int);
+ break;
+ default: /* unknown pattern */
+ break;
+ }
+ }
+
+ switch(fmt) /* PRINTF DIRECTIVES */
+ {
+ default : /* unknown directive */
+ form -= 1;
+ argn -= 1;
+ continue;
+
+ case '!' : /* stacking a new environment */
+ if(!fp)
+ fp = (*_Sffmtposf)(f,oform,oargs,ft,0);
+ else goto pop_fmt;
+
+ if(!argv.ft)
+ goto pop_fmt;
+ if(!argv.ft->form && ft ) /* change extension functions */
+ { if(ft->eventf &&
+ (*ft->eventf)(f,SF_DPOP,(Void_t*)form,ft) < 0)
+ continue;
+ fmstk->ft = ft = argv.ft;
+ }
+ else /* stack a new environment */
+ { if(!(fm = (Fmt_t*)malloc(sizeof(Fmt_t))) )
+ goto done;
+
+ ft = fm->ft = argv.ft;
+ SFMBSET(ft->mbs, &fmbs);
+ if(ft->form)
+ { fm->form = (char*)form; SFMBCPY(&fm->mbs,&fmbs);
+ va_copy(fm->args,args);
+
+ fm->oform = oform;
+ va_copy(fm->oargs,oargs);
+ fm->argn = argn;
+ fm->fp = fp;
+
+ form = ft->form; SFMBCLR(ft->mbs);
+ va_copy(args,ft->args);
+ argn = -1;
+ fp = NIL(Fmtpos_t*);
+ oform = (char*)form;
+ va_copy(oargs,args);
+ }
+ else fm->form = NIL(char*);
+
+ fm->eventf = ft->eventf;
+ fm->next = fmstk;
+ fmstk = fm;
+ }
+ continue;
+
+ case 'S':
+ flags = (flags & ~SFFMT_TYPES) | SFFMT_LONG;
+ case 's':
+ if(base >= 0) /* list of strings */
+ { if(!(ls = argv.sp) || !ls[0])
+ continue;
+ }
+ else
+ { if(!(sp = argv.s))
+ { sp = "(null)";
+ flags &= ~SFFMT_LONG;
+ }
+#if _PACKAGE_ast
+ str_cvt:
+ if(scale)
+ { size = base = -1;
+ flags &= ~SFFMT_LONG;
+ }
+#endif
+ ls = tls; tls[0] = sp;
+ }
+ for(sp = *ls;;)
+ { /* v: number of bytes w: print width of those v bytes */
+#if _has_multibyte
+ if(flags & SFFMT_LONG)
+ { v = 0;
+#ifdef mbwidth
+ w = 0;
+#endif
+ SFMBCLR(&mbs);
+ for(n = 0, wsp = (wchar_t*)sp;; ++wsp, ++n)
+ { if((size >= 0 && n >= size) ||
+ (size < 0 && *wsp == 0) )
+ break;
+ if((n_s = wcrtomb(buf, *wsp, &mbs)) <= 0)
+ break;
+#ifdef mbwidth
+ if(sf_wcwidth )
+ { n_w = mbwidth(*wsp);
+ if(precis >= 0 && (w+n_w) > precis )
+ break;
+ w += n_w;
+ }
+ else
+#endif
+ if(precis >= 0 && (v+n_s) > precis )
+ break;
+ v += n_s;
+ }
+#ifdef mbwidth
+ if(!sf_wcwidth )
+ w = v;
+#endif
+ }
+#if defined(mbwide) && defined(mbchar) && defined(mbwidth)
+ else if (mbwide())
+ { w = 0;
+ SFMBCLR(&mbs);
+ ssp = sp;
+ for(;;)
+ { if((size >= 0 && w >= size) ||
+ (size < 0 && *ssp == 0) )
+ break;
+ osp = ssp;
+ n = mbchar(osp);
+ n_w = sf_wcwidth ? mbwidth(n) : 1;
+ if(precis >= 0 && (w+n_w) > precis )
+ break;
+ w += n_w;
+ ssp = osp;
+ }
+ v = ssp - sp;
+ }
+#endif
+ else
+#endif
+ { if((v = size) < 0)
+ for(v = 0; sp[v]; ++v)
+ if(v == precis)
+ break;
+ if(precis >= 0 && v > precis)
+ v = precis;
+ w = v;
+ }
+
+ if((n = width - w) > 0 && !(flags&SFFMT_LEFT) )
+ { if(flags&SFFMT_CENTER)
+ { n -= (k = n/2);
+ SFnputc(f, ' ', k);
+ }
+ else
+ {
+ SFnputc(f, ' ', n);
+ n = 0;
+ }
+ }
+#if _has_multibyte
+ if(flags & SFFMT_LONG)
+ { SFMBCLR(&mbs);
+ for(wsp = (wchar_t*)sp; w > 0; ++wsp, --w)
+ { if((n_s = wcrtomb(buf, *wsp, &mbs)) <= 0)
+ break;
+ sp = buf; SFwrite(f, sp, n_s);
+ }
+ }
+ else
+#endif
+ { SFwrite(f,sp,v); }
+ if(n > 0)
+ { SFnputc(f,' ',n); }
+ if(!(sp = *++ls))
+ break;
+ else if(base > 0)
+ { SFputc(f,base); }
+ }
+ continue;
+
+ case 'C':
+ flags = (flags & ~SFFMT_TYPES) | SFFMT_LONG;
+ case 'c':
+ if(precis <= 0) /* # of times to repeat a character */
+ precis = 1;
+#if _has_multibyte
+ if(flags & SFFMT_LONG)
+ { if(base >= 0)
+ { if(!(wsp = (wchar_t*)argv.s) )
+ continue;
+ for(size = 0; wsp[size]; ++size)
+ ;
+ }
+ else
+ { wsp = &argv.wc;
+ size = 1;
+ }
+ }
+ else
+#endif
+ { if(base >= 0)
+ { if(!(sp = argv.s) )
+ continue;
+ size = strlen(sp);
+ }
+ else
+ { argv.c = (char)(argv.i);
+ sp = &argv.c;
+ size = 1;
+ }
+ }
+
+ while(size > 0)
+ {
+#if _has_multibyte
+ if(flags&SFFMT_LONG)
+ { SFMBCLR(&mbs);
+ if((n_s = wcrtomb(buf, *wsp++, &mbs)) <= 0)
+ break;
+#ifdef mbwidth
+ if(sf_wcwidth)
+ n_s = mbwidth(*(wsp - 1));
+#endif
+ n = width - precis*n_s; /* padding amount */
+ }
+ else
+#endif
+ if(flags&SFFMT_ALTER)
+ { n_s = chr2str(buf, *sp++);
+ n = width - precis*n_s;
+ }
+ else
+ { fmt = *sp++;
+ n = width - precis;
+ }
+
+ if(n > 0 && !(flags&SFFMT_LEFT) )
+ { if(flags&SFFMT_CENTER)
+ { n -= (k = n/2);
+ SFnputc(f, ' ', k);
+ }
+ else
+ { SFnputc(f, ' ', n);
+ n = 0;
+ }
+ }
+
+ v = precis; /* need this because SFnputc may clear it */
+#if _has_multibyte
+ if(flags&SFFMT_LONG)
+ { for(; v > 0; --v)
+ { ssp = buf; k = n_s; SFwrite(f,ssp,k); }
+ }
+ else
+#endif
+ if(flags&SFFMT_ALTER)
+ { for(; v > 0; --v)
+ { ssp = buf; k = n_s; SFwrite(f,ssp,k); }
+ }
+ else
+ { SFnputc(f, fmt, v);
+ }
+
+ if(n > 0)
+ { SFnputc(f,' ',n); };
+
+ if((size -= 1) > 0 && base > 0)
+ { SFputc(f,base); }
+ }
+ continue;
+
+ case 'n': /* return current output length */
+ SFEND(f);
+#if !_ast_intmax_long
+ if(size == sizeof(Sflong_t) )
+ *((Sflong_t*)argv.vp) = (Sflong_t)n_output;
+ else
+#endif
+ if(size == sizeof(long))
+ *((long*)argv.vp) = (long)n_output;
+ else if(size == sizeof(short) )
+ *((short*)argv.vp) = (short)n_output;
+ else if(size == sizeof(uchar) )
+ *((uchar*)argv.vp) = (uchar)n_output;
+ else *((int*)argv.vp) = (int)n_output;
+
+ continue;
+
+ case 'p': /* pointer value */
+ fmt = 'x';
+ base = 16; n_s = 15; n = 4;
+ flags = (flags&~(SFFMT_SIGN|SFFMT_BLANK|SFFMT_ZERO))|SFFMT_ALTER;
+#if _more_void_int
+ lv = (Sflong_t)((Sfulong_t)argv.vp);
+ goto long_cvt;
+#else
+ v = (int)((uint)argv.vp);
+ goto int_cvt;
+#endif
+ case 'o':
+ base = 8; n_s = 7; n = 3;
+ flags &= ~(SFFMT_SIGN|SFFMT_BLANK);
+ goto int_arg;
+ case 'X':
+ ssp = "0123456789ABCDEF";
+ case 'x':
+ base = 16; n_s = 15; n = 4;
+ flags &= ~(SFFMT_SIGN|SFFMT_BLANK);
+ goto int_arg;
+ case 'i':
+#if _PACKAGE_ast
+ if((flags&SFFMT_ALTER) && base < 0)
+ { flags &= ~SFFMT_ALTER;
+ scale = 1024;
+ }
+#endif
+ fmt = 'd';
+ goto d_format;
+ case 'u':
+ flags &= ~(SFFMT_SIGN|SFFMT_BLANK);
+ case 'd':
+ d_format:
+#if _PACKAGE_ast
+ if((flags&SFFMT_ALTER) && base < 0)
+ { flags &= ~SFFMT_ALTER;
+ scale = 1000;
+ }
+#endif
+ if(base < 2 || base > SF_RADIX)
+ base = 10;
+ if((base&(n_s = base-1)) == 0)
+ { if(base < 8)
+ n = base < 4 ? 1 : 2;
+ else if(base < 32)
+ n = base < 16 ? 3 : 4;
+ else n = base < 64 ? 5 : 6;
+ }
+ else n_s = base == 10 ? -1 : 0;
+
+ int_arg:
+#if !_ast_intmax_long || _more_long_int || _more_void_int
+ if(size == sizeof(Sflong_t))
+ { lv = argv.ll;
+ goto long_cvt;
+ }
+ else if(sizeof(long) < sizeof(Sflong_t) && size == sizeof(long))
+ { if(fmt == 'd')
+ lv = (Sflong_t)argv.l;
+ else lv = (Sflong_t)argv.ul;
+ long_cvt:
+#if _PACKAGE_ast
+ if(scale)
+ { sp = fmtscale(lv, scale);
+ goto str_cvt;
+ }
+#endif
+ if(lv == 0 && precis == 0)
+ break;
+ if(lv < 0 && fmt == 'd' )
+ { flags |= SFFMT_MINUS;
+ if(lv == HIGHBITL) /* avoid overflow */
+ { lv = (Sflong_t)(HIGHBITL/base);
+ *--sp = _Sfdigits[HIGHBITL -
+ ((Sfulong_t)lv)*base];
+ }
+ else lv = -lv;
+ }
+ if(n_s < 0) /* base 10 */
+ { Sflong_t nv;
+ sfucvt(lv,sp,nv,ssp,Sflong_t,Sfulong_t);
+ }
+ else if(n_s > 0) /* base power-of-2 */
+ { do
+ { *--sp = ssp[lv&n_s];
+ } while((lv = ((Sfulong_t)lv) >> n) );
+ }
+ else /* general base */
+ { do
+ { *--sp = ssp[((Sfulong_t)lv)%base];
+ } while((lv = ((Sfulong_t)lv)/base) );
+ }
+ } else
+#endif
+ if(sizeof(short) < sizeof(int) && size == sizeof(short) )
+ { if(fmt == 'd')
+ v = (int)((short)argv.i);
+ else v = (int)((ushort)argv.i);
+ goto int_cvt;
+ }
+ else if(size == sizeof(char))
+ { if(fmt != 'd')
+ v = (int)((uchar)argv.i);
+ else
+ {
+#if _key_signed
+ v = (int)((signed char)argv.i);
+#else
+ if(argv.i < 0)
+ v = -((int)((char)(-argv.i)));
+ else v = ((int)((char)( argv.i)));
+#endif
+ }
+ goto int_cvt;
+ }
+ else
+ { v = argv.i;
+ int_cvt:
+#if _PACKAGE_ast
+ if(scale)
+ { sp = fmtscale(v, scale);
+ goto str_cvt;
+ }
+#endif
+ if(v == 0 && precis == 0)
+ break;
+ if(v < 0 && fmt == 'd' )
+ { flags |= SFFMT_MINUS;
+ if(v == HIGHBITI) /* avoid overflow */
+ { v = (int)(HIGHBITI/base);
+ *--sp = _Sfdigits[HIGHBITI -
+ ((uint)v)*base];
+ }
+ else v = -v;
+ }
+ if(n_s < 0) /* base 10 */
+ { sfucvt(v,sp,n,ssp,int,uint);
+ }
+ else if(n_s > 0) /* base power-of-2 */
+ { do
+ { *--sp = ssp[v&n_s];
+ } while((v = ((uint)v) >> n) );
+ }
+ else /* n_s == 0, general base */
+ { do
+ { *--sp = ssp[((uint)v)%base];
+ } while((v = ((uint)v)/base) );
+ }
+ }
+
+ if(n_s < 0 && (flags&SFFMT_THOUSAND) && (n = endsp-sp) > 3)
+ { if((n %= 3) == 0)
+ n = 3;
+ for(ep = buf+SLACK, endep = ep + n; ; )
+ { while(ep < endep)
+ *ep++ = *sp++;
+ if(sp == endsp)
+ break;
+ if(sp <= endsp-3)
+ *ep++ = thousand;
+ endep = ep+3;
+ }
+ sp = buf+SLACK;
+ endsp = ep;
+ }
+
+ /* zero padding for precision if have room in buffer */
+ if(precis > 0 && (precis -= (endsp-sp)) < (sp-buf)-64)
+ while(precis-- > 0)
+ *--sp = '0';
+
+ if(flags&SFFMT_ALTER) /* prefix */
+ { if(fmt == 'o')
+ { if(*sp != '0')
+ *--sp = '0';
+ }
+ else
+ { if(width > 0 && (flags&SFFMT_ZERO))
+ { /* do 0 padding first */
+ if(fmt == 'x' || fmt == 'X')
+ n = 0;
+ else if(dot < 2)
+ n = width;
+ else n = base < 10 ? 2 : 3;
+ n += (flags&(SFFMT_MINUS|SFFMT_SIGN)) ?
+ 1 : 0;
+ n = width - (n + (endsp-sp));
+ while(n-- > 0)
+ *--sp = '0';
+ }
+ if(fmt == 'x' || fmt == 'X')
+ { *--sp = (char)fmt;
+ *--sp = '0';
+ }
+ else if(dot >= 2)
+ { /* base#value notation */
+ *--sp = '#';
+ if(base < 10)
+ *--sp = (char)('0'+base);
+ else
+ { *--sp = _Sfdec[(base <<= 1)+1];
+ *--sp = _Sfdec[base];
+ }
+ }
+ }
+ }
+
+ break;
+
+ case 'g': case 'G': /* these ultimately become %e or %f */
+ case 'a': case 'A':
+ case 'e': case 'E':
+ case 'f': case 'F':
+#if !_ast_fltmax_double
+ if(size == sizeof(Sfdouble_t) )
+ { v = SFFMT_LDOUBLE;
+ dval = argv.ld;
+ }
+ else
+#endif
+ { v = 0;
+ dval = argv.d;
+ }
+
+ if(fmt == 'e' || fmt == 'E' && (v |= SFFMT_UPPER))
+ { v |= SFFMT_EFORMAT;
+ n = (precis = precis < 0 ? FPRECIS : precis)+1;
+ ep = _sfcvt(dval,tmp+1,sizeof(tmp)-1, min(n,SF_FDIGITS),
+ &decpt, &sign, &n_s, v);
+ goto e_format;
+ }
+ else if(fmt == 'f' || fmt == 'F' && (v |= SFFMT_UPPER))
+ { precis = precis < 0 ? FPRECIS : precis;
+ ep = _sfcvt(dval,tmp+1,sizeof(tmp)-1, min(precis,SF_FDIGITS),
+ &decpt, &sign, &n_s, v);
+ goto f_format;
+ }
+ else if(fmt == 'a' || fmt == 'A' && (v |= SFFMT_UPPER))
+ { v |= SFFMT_AFORMAT;
+ if(precis < 0)
+ { if(v & SFFMT_LDOUBLE)
+ precis = 2*(sizeof(Sfdouble_t) - 2);
+ else precis = 2*(sizeof(double) - 2);
+ }
+ n = precis + 1;
+ ep = _sfcvt(dval,tmp+1,sizeof(tmp)-1, min(n,SF_FDIGITS),
+ &decpt, &sign, &n_s, v);
+
+ sp = endsp = buf+1; /* reserve space for sign */
+ *endsp++ = '0';
+ *endsp++ = fmt == 'a' ? 'x' : 'X';
+ if (!isxdigit(*ep))
+ goto infinite;
+ goto a_format;
+ }
+ else /* 'g' or 'G' format */
+ { precis = precis < 0 ? FPRECIS : precis == 0 ? 1 : precis;
+ if(fmt == 'G')
+ v |= SFFMT_UPPER;
+ v |= SFFMT_EFORMAT;
+ ep = _sfcvt(dval,tmp+1,sizeof(tmp)-1, min(precis,SF_FDIGITS),
+ &decpt, &sign, &n_s, v);
+ if(dval == 0.)
+ decpt = 1;
+ else if(*ep == 'I')
+ goto infinite;
+
+ if(!(flags&SFFMT_ALTER))
+ { /* zap trailing 0s */
+ if((n = n_s) > precis)
+ n = precis;
+ while((n -= 1) >= 1 && ep[n] == '0')
+ ;
+ n += 1;
+ }
+ else n = precis;
+
+ if(decpt < -3 || decpt > precis)
+ { precis = n-1;
+ goto e_format;
+ }
+ else
+ { precis = n - decpt;
+ goto f_format;
+ }
+ }
+
+ e_format: /* build the x.yyyy string */
+ if(isalpha(*ep))
+ goto infinite;
+ sp = endsp = buf+1; /* reserve space for sign */
+ a_format:
+ *endsp++ = *ep ? *ep++ : '0';
+
+ SFSETLOCALE(&decimal,&thousand);
+ if(precis > 0 || (flags&SFFMT_ALTER))
+ *endsp++ = decimal;
+ ssp = endsp;
+ endep = ep+precis;
+ while((*endsp++ = *ep++) && ep <= endep)
+ ;
+ precis -= (endsp -= 1) - ssp;
+
+ /* build the exponent */
+ ep = endep = buf+(sizeof(buf)-1);
+ if(dval != 0.)
+ { if((n = decpt - 1) < 0)
+ n = -n;
+ while(n > 9)
+ { v = n; n /= 10;
+ *--ep = (char)('0' + (v - n*10));
+ }
+ }
+ else n = 0;
+ *--ep = (char)('0' + n);
+ if(endep-ep <= 1) /* at least 2 digits */
+ *--ep = '0';
+
+ /* the e/Exponent separator and sign */
+ *--ep = (decpt > 0 || dval == 0.) ? '+' : '-';
+ *--ep = fmt == 'a' ? 'p' : fmt == 'A' ? 'P' :
+ isupper(fmt) ? 'E' : 'e';
+
+ goto end_aefg;
+
+ f_format: /* data before the decimal point */
+ if(isalpha(*ep))
+ {
+ infinite:
+ flags &= ~SFFMT_ZERO;
+ endsp = (sp = ep)+sfslen();
+ ep = endep;
+ precis = 0;
+ goto end_aefg;
+ }
+
+ SFSETLOCALE(&decimal,&thousand);
+ endsp = sp = buf+1; /* save a space for sign */
+ endep = ep+decpt;
+ if(decpt > 3 && (flags&SFFMT_THOUSAND) )
+ { if((n = decpt%3) == 0)
+ n = 3;
+ while(ep < endep && (*endsp++ = *ep++) )
+ { if(--n == 0 && (ep <= endep-3) )
+ { *endsp++ = thousand;
+ n = 3;
+ }
+ }
+ }
+ else
+ { while(ep < endep && (*endsp++ = *ep++))
+ ;
+ }
+ if(endsp == sp)
+ *endsp++ = '0';
+
+ if(precis > 0 || (flags&SFFMT_ALTER))
+ *endsp++ = decimal;
+
+ if((n = -decpt) > 0)
+ { /* output zeros for negative exponent */
+ ssp = endsp + min(n,precis);
+ precis -= n;
+ while(endsp < ssp)
+ *endsp++ = '0';
+ }
+
+ ssp = endsp;
+ endep = ep+precis;
+ while((*endsp++ = *ep++) && ep <= endep)
+ ;
+ precis -= (endsp -= 1) - ssp;
+ ep = endep;
+ end_aefg:
+ flags |= SFFMT_FLOAT;
+ if(sign)
+ flags |= SFFMT_MINUS;
+ break;
+ }
+
+ if(flags == 0 && width <= 0)
+ goto do_output;
+
+ if(flags&SFFMT_PREFIX)
+ fmt = (flags&SFFMT_MINUS) ? '-' : (flags&SFFMT_SIGN) ? '+' : ' ';
+
+ n = (endsp-sp) + (endep-ep) + (precis <= 0 ? 0 : precis) +
+ ((flags&SFFMT_PREFIX) ? 1 : 0);
+ if((v = width-n) <= 0)
+ v = 0;
+ else if(!(flags&SFFMT_ZERO)) /* right padding */
+ { if(flags&SFFMT_LEFT)
+ v = -v;
+ else if(flags&SFFMT_PREFIX) /* blank padding, output prefix now */
+ { *--sp = fmt;
+ flags &= ~SFFMT_PREFIX;
+ }
+ }
+
+ if(flags&SFFMT_PREFIX) /* put out the prefix */
+ { SFputc(f,fmt);
+ if(fmt != ' ')
+ flags |= SFFMT_ZERO;
+ }
+
+ if((n = v) > 0) /* left padding */
+ { v = (flags&SFFMT_ZERO) ? '0' : ' ';
+ SFnputc(f,v,n);
+ }
+
+ if((n = precis) > 0 && !(flags&SFFMT_FLOAT))
+ { /* padding for integer precision */
+ SFnputc(f,'0',n);
+ precis = 0;
+ }
+
+ do_output:
+ if((n = endsp-sp) > 0)
+ SFwrite(f,sp,n);
+
+ if(flags&(SFFMT_FLOAT|SFFMT_LEFT))
+ { /* SFFMT_FLOAT: right padding for float precision */
+ if((n = precis) > 0)
+ SFnputc(f,'0',n);
+
+ /* SFFMT_FLOAT: the exponent of %eE */
+ if((n = endep - (sp = ep)) > 0)
+ SFwrite(f,sp,n);
+
+ /* SFFMT_LEFT: right padding */
+ if((n = -v) > 0)
+ { SFnputc(f,' ',n); }
+ }
+ }
+
+pop_fmt:
+ if(fp)
+ { free(fp);
+ fp = NIL(Fmtpos_t*);
+ }
+ while((fm = fmstk) ) /* pop the format stack and continue */
+ { if(fm->eventf)
+ { if(!form || !form[0])
+ (*fm->eventf)(f,SF_FINAL,NIL(Void_t*),ft);
+ else if((*fm->eventf)(f,SF_DPOP,(Void_t*)form,ft) < 0)
+ goto loop_fmt;
+ }
+
+ fmstk = fm->next;
+ if((form = fm->form) )
+ { SFMBCPY(&fmbs,&fm->mbs);
+ va_copy(args, fm->args);
+ oform = fm->oform;
+ va_copy(oargs,fm->oargs);
+ argn = fm->argn;
+ fp = fm->fp;
+ }
+ ft = fm->ft;
+ free(fm);
+ if(form && form[0])
+ goto loop_fmt;
+ }
+
+done:
+ if(fp)
+ free(fp);
+ while((fm = fmstk) )
+ { if(fm->eventf)
+ (*fm->eventf)(f,SF_FINAL,NIL(Void_t*),fm->ft);
+ fmstk = fm->next;
+ free(fm);
+ }
+
+ SFEND(f);
+
+ n = f->next - f->data;
+ if((sp = (char*)f->data) == data)
+ f->endw = f->endr = f->endb = f->data = NIL(uchar*);
+ f->next = f->data;
+
+ if((((flags = f->flags)&SF_SHARE) && !(flags&SF_PUBLIC) ) ||
+ (n > 0 && (sp == data || (flags&SF_LINE) ) ) )
+ (void)SFWRITE(f,(Void_t*)sp,n);
+ else f->next += n;
+
+ SFOPEN(f,0);
+ SFMTXRETURN(f, n_output);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfvscanf.c b/usr/src/lib/libast/common/sfio/sfvscanf.c
new file mode 100644
index 0000000000..6314bdc79f
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfvscanf.c
@@ -0,0 +1,1097 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* The main engine for reading formatted data
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#define MAXWIDTH (int)(((uint)~0)>>1) /* max amount to scan */
+
+/*
+ * pull in a private strtold()
+ */
+
+#include "sfstrtof.h"
+
+/* refresh stream buffer - taking care of unseekable/share streams too */
+#if __STD_C
+static void _sfbuf(Sfio_t* f, int* peek)
+#else
+static void _sfbuf(f, peek)
+Sfio_t* f;
+int* peek;
+#endif
+{
+ if(f->next >= f->endb)
+ { if(*peek) /* try peeking for a share stream if possible */
+ { f->mode |= SF_RV;
+ if(SFFILBUF(f,-1) > 0)
+ { f->mode |= SF_PEEK;
+ return;
+ }
+ *peek = 0; /* can't peek, back to normal reads */
+ }
+ (void)SFFILBUF(f,-1);
+ }
+}
+
+/* buffer used during scanning of a double value or a multi-byte
+ character. the fields mirror certain local variables in sfvscanf. */
+typedef struct _scan_s
+{ int error; /* get set by _sfdscan if no value specified */
+ int inp; /* last input character read */
+ int width; /* field width */
+ Sfio_t *f; /* stream being scanned */
+ uchar *d, *endd, *data; /* local buffering system */
+ int peek; /* != 0 if unseekable/share stream */
+ int n_input;/* number of input bytes processed */
+} Scan_t;
+
+/* ds != 0 for scanning double values */
+#define SCinit(sc,ds) ((sc)->inp = (sc)->error = -1, (sc)->f = f, \
+ ((sc)->width = (ds) ? width : -1), \
+ (sc)->d = d, (sc)->endd = endd, (sc)->data = data, \
+ (sc)->peek = peek, (sc)->n_input = n_input)
+#define SCend(sc,ds) (inp = (sc)->inp, f = (sc)->f, \
+ (width = (ds) ? (sc)->width : width), \
+ d = (sc)->d, endd = (sc)->endd, data = (sc)->data, \
+ peek = (sc)->peek, n_input = (sc)->n_input)
+
+#if __STD_C
+static int _scgetc(void* arg, int flag)
+#else
+static int _scgetc(arg, flag)
+void* arg;
+int flag;
+#endif
+{
+ Scan_t *sc = (Scan_t*)arg;
+
+ if (flag)
+ { sc->error = flag;
+ return 0;
+ }
+
+ /* if width >= 0, do not allow to exceed width number of bytes */
+ if(sc->width == 0)
+ { sc->inp = -1;
+ return 0;
+ }
+
+ if(sc->d >= sc->endd) /* refresh local buffer */
+ { sc->n_input += sc->d - sc->data;
+ if(sc->peek)
+ SFREAD(sc->f, sc->data, sc->d - sc->data);
+ else sc->f->next = sc->d;
+
+ _sfbuf(sc->f, &sc->peek);
+ sc->data = sc->d = sc->f->next;
+ sc->endd = sc->f->endb;
+
+ if(sc->d >= sc->endd)
+ { sc->inp = -1;
+ return 0;
+ }
+ }
+
+ if((sc->width -= 1) >= 0) /* from _sfdscan */
+ return (sc->inp = (int)(*sc->d++));
+ else return ((int)(*sc->d++));
+}
+
+/* structure to match characters in a character class */
+typedef struct _accept_s
+{ char ok[SF_MAXCHAR];
+ int yes;
+ char *form, *endf;
+#if _has_multibyte
+ wchar_t wc;
+#endif
+} Accept_t;
+
+#if __STD_C
+static char* _sfsetclass(const char* form, Accept_t* ac, int flags)
+#else
+static char* _sfsetclass(form, ac, flags)
+char* form; /* format string */
+Accept_t* ac; /* values of accepted characters */
+int flags; /* SFFMT_LONG for wchar_t */
+#endif
+{
+ int c, endc, n;
+#if _has_multibyte
+ SFMBDCL(mbs)
+#endif
+
+ if(*form == '^') /* complementing this set */
+ { ac->yes = 0;
+ form += 1;
+ }
+ else ac->yes = 1;
+
+ for(c = 0; c <= SF_MAXCHAR; ++c)
+ ac->ok[c] = !ac->yes;
+
+ if(*form == ']' || *form == '-') /* special first char */
+ { ac->ok[*form] = ac->yes;
+ form += 1;
+ }
+ ac->form = (char*)form;
+
+ if(flags&SFFMT_LONG)
+ SFMBCLR(&mbs);
+ for(n = 1; *form != ']'; form += n)
+ { if((c = *((uchar*)form)) == 0)
+ return NIL(char*);
+
+ if(*(form+1) == '-')
+ { endc = *((uchar*)(form+2));
+#if _has_multibyte
+ if(c >= 128 || endc >= 128 ) /* range must be ascii */
+ goto one_char;
+#endif
+ for(; c <= endc; ++c)
+ ac->ok[c] = ac->yes;
+ n = 3;
+ }
+ else
+ { one_char:
+#if _has_multibyte /* true multi-byte chars must be checked differently */
+ if((flags&SFFMT_LONG) && (n = (int)SFMBLEN(form,&mbs)) <= 0)
+ return NIL(char*);
+ if(n == 1)
+#endif
+ ac->ok[c] = ac->yes;
+ }
+ }
+
+ ac->endf = (char*)form;
+ return (char*)(form+1);
+}
+
+#if _has_multibyte
+#if __STD_C
+static int _sfwaccept(wchar_t wc, Accept_t* ac)
+#else
+static int _sfwaccept(wc, ac)
+wchar_t wc;
+Accept_t* ac;
+#endif
+{
+ int endc, c, n;
+ wchar_t fwc;
+ char *form = ac->form;
+ SFMBDCL(mbs)
+
+ SFMBCLR(&mbs);
+ for(n = 1; *form != ']'; form += n)
+ { if((c = *((uchar*)form)) == 0)
+ return 0;
+
+ if(*(form+1) == '-')
+ { endc = *((uchar*)(form+2));
+ if(c >= 128 || endc >= 128 ) /* range must be ascii */
+ goto one_char;
+ n = 3;
+ }
+ else
+ { one_char:
+ if((n = mbrtowc(&fwc, form, ac->endf-form, &mbs)) > 1 &&
+ wc == fwc )
+ return ac->yes;
+ }
+ }
+
+ return !ac->yes;
+}
+
+#if _has_multibyte == 1
+#define SFgetwc(sc,wc,fmt,ac,mbs) _sfgetwc(sc,wc,fmt,ac,(Void_t*)(mbs))
+#else
+#define SFgetwc(sc,wc,fmt,ac,mbs) _sfgetwc(sc,wc,fmt,ac,NIL(Void_t*))
+#endif
+
+#if __STD_C
+static int _sfgetwc(Scan_t* sc, wchar_t* wc, int fmt, Accept_t* ac, Void_t *mbs)
+#else
+static int _sfgetwc(sc, wc, fmt, ac, mbs)
+Scan_t* sc; /* the scanning handle */
+wchar_t* wc; /* to return a scanned wchar_t */
+int fmt; /* %s, %c, %[ */
+Accept_t* ac; /* accept handle for %[ */
+Void_t* mbs; /* multibyte parsing state */
+#endif
+{
+ int n, v;
+ char b[16]; /* assuming that SFMBMAX <= 16! */
+
+ /* shift left data so that there will be more room to back up on error.
+ this won't help streams with small buffers - c'est la vie! */
+ if(sc->d > sc->f->data && (n = sc->endd - sc->d) > 0 && n < SFMBMAX)
+ { memcpy(sc->f->data, sc->d, n);
+ if(sc->f->endr == sc->f->endb)
+ sc->f->endr = sc->f->data+n;
+ if(sc->f->endw == sc->f->endb)
+ sc->f->endw = sc->f->data+n;
+ sc->f->endb = sc->f->data+n;
+ sc->d = sc->data = sc->f->data;
+ sc->endd = sc->f->endb;
+ if(!mbs) sc->f->endb = sc->endd; /* stop cc's "unused mbs" warning */
+ }
+
+ for(n = 0; n < SFMBMAX; )
+ { if((v = _scgetc((Void_t*)sc, 0)) <= 0)
+ goto no_match;
+ else b[n++] = v;
+
+ if(mbrtowc(wc, b, n, (mbstate_t*)mbs) == (size_t)(-1))
+ goto no_match; /* malformed multi-byte char */
+ else
+ { /* multi-byte char converted successfully */
+ if(fmt == 'c')
+ return 1;
+ else if(fmt == 's')
+ { if(n > 1 || (n == 1 && !isspace(b[0]) ) )
+ return 1;
+ else goto no_match;
+ }
+ else if(fmt == '[')
+ { if((n == 1 && ac->ok[b[0]]) ||
+ (n > 1 && _sfwaccept(*wc,ac)) )
+ return 1;
+ else goto no_match;
+ }
+ else /* if(fmt == '1') match a single wchar_t */
+ { if(*wc == ac->wc)
+ return 1;
+ else goto no_match;
+ }
+ }
+ }
+
+no_match: /* this unget is lossy on a stream with small buffer */
+ if((sc->d -= n) < sc->data)
+ sc->d = sc->data;
+ return 0;
+}
+#endif /*_has_multibyte*/
+
+
+#if __STD_C
+int sfvscanf(Sfio_t* f, reg const char* form, va_list args)
+#else
+int sfvscanf(f,form,args)
+Sfio_t* f; /* file to be scanned */
+reg char* form; /* scanning format */
+va_list args;
+#endif
+{
+ reg int inp, shift, base, width;
+ ssize_t size;
+ int fmt, flags, dot, n_assign, v, n, n_input;
+ char *sp;
+
+ Accept_t acc;
+
+ Argv_t argv;
+ Sffmt_t *ft;
+ Fmt_t *fm, *fmstk;
+
+ Fmtpos_t* fp;
+ char *oform;
+ va_list oargs;
+ int argp, argn;
+
+ int decimal = 0, thousand = 0;
+
+#if _has_multibyte
+ wchar_t wc;
+ SFMBDCL(fmbs)
+ SFMBDCL(mbs)
+#endif
+
+ Void_t* value; /* location to assign scanned value */
+ char* t_str;
+ ssize_t n_str;
+
+ /* local buffering system */
+ Scan_t scd;
+ uchar *d, *endd, *data;
+ int peek;
+#define SFbuf(f) (_sfbuf(f,&peek), (data = d = f->next), (endd = f->endb) )
+#define SFlen(f) (d - data)
+#define SFinit(f) ((peek = f->extent < 0 && (f->flags&SF_SHARE)), SFbuf(f) )
+#define SFend(f) ((n_input += SFlen(f)), \
+ (peek ? SFREAD(f,(Void_t*)data,SFlen(f)) : ((f->next = d),0)) )
+#define SFgetc(f,c) ((c) = (d < endd || (SFend(f), SFbuf(f), d < endd)) ? \
+ (int)(*d++) : -1 )
+#define SFungetc(f,c) (d -= 1)
+
+ SFCVINIT(); /* initialize conversion tables */
+
+ SFMTXSTART(f,-1);
+
+ if(!form || f->mode != SF_READ && _sfmode(f,SF_READ,0) < 0)
+ SFMTXRETURN(f, -1);
+ SFLOCK(f,0);
+
+ SFinit(f); /* initialize local buffering system */
+
+ n_assign = n_input = 0; inp = -1;
+
+ fmstk = NIL(Fmt_t*);
+ ft = NIL(Sffmt_t*);
+
+ fp = NIL(Fmtpos_t*);
+ argn = -1;
+ oform = (char*)form;
+ va_copy(oargs,args);
+
+ SFSETLOCALE(&decimal, &thousand);
+
+loop_fmt:
+ SFMBCLR(&fmbs);
+ while((fmt = *form++))
+ { if(fmt != '%')
+ { if(isspace(fmt))
+ { if(fmt != '\n' || !(f->flags&SF_LINE))
+ fmt = -1;
+ for(;;)
+ { if(SFgetc(f,inp) < 0 || inp == fmt)
+ goto loop_fmt;
+ else if(!isspace(inp))
+ { SFungetc(f,inp);
+ goto loop_fmt;
+ }
+ }
+ }
+ else
+ { match_1:
+#if _has_multibyte
+ if((n = (int)mbrtowc(&wc,form-1,SFMBMAX,&fmbs)) <= 0)
+ goto pop_fmt;
+ if(n > 1)
+ { acc.wc = wc;
+ SCinit(&scd,0); SFMBCLR(&mbs);
+ v = SFgetwc(&scd, &wc, '1', &acc, &mbs);
+ SCend(&scd,0);
+ if(v == 0)
+ goto pop_fmt;
+ form += n-1;
+ }
+ else
+#endif
+ if(SFgetc(f,inp) != fmt)
+ { if(inp < 0)
+ goto done;
+ SFungetc(f,inp);
+ goto pop_fmt;
+ }
+ }
+ continue;
+ }
+
+ if(*form == '%')
+ { form += 1;
+ goto match_1;
+ }
+
+ if(*form == '\0')
+ goto pop_fmt;
+
+ if(*form == '*')
+ { flags = SFFMT_SKIP;
+ form += 1;
+ }
+ else flags = 0;
+
+ /* matching some pattern */
+ base = 10; size = -1;
+ width = dot = 0;
+ t_str = NIL(char*); n_str = 0;
+ value = NIL(Void_t*);
+ argp = -1;
+
+ loop_flags: /* LOOP FOR FLAGS, WIDTH, BASE, TYPE */
+ switch((fmt = *form++) )
+ {
+ case LEFTP : /* get the type which is enclosed in balanced () */
+ t_str = (char*)form;
+ for(v = 1;;)
+ { switch(*form++)
+ {
+ case 0 : /* not balanceable, retract */
+ form = t_str;
+ t_str = NIL(char*);
+ n_str = 0;
+ goto loop_flags;
+ case LEFTP : /* increasing nested level */
+ v += 1;
+ continue;
+ case RIGHTP : /* decreasing nested level */
+ if((v -= 1) != 0)
+ continue;
+ if(*t_str != '*' )
+ n_str = (form-1) - t_str;
+ else
+ { t_str = (*_Sffmtintf)(t_str+1,&n);
+ if(*t_str == '$')
+ { if(!fp &&
+ !(fp = (*_Sffmtposf)
+ (f,oform,oargs,ft,1)) )
+ goto pop_fmt;
+ n = FP_SET(n,argn);
+ }
+ else n = FP_SET(-1,argn);
+
+ if(fp)
+ { t_str = fp[n].argv.s;
+ n_str = fp[n].ft.size;
+ }
+ else if(ft && ft->extf )
+ { FMTSET(ft, form,args,
+ LEFTP, 0, 0, 0,0,0,
+ NIL(char*),0);
+ n = (*ft->extf)
+ (f,(Void_t*)&argv,ft);
+ if(n < 0)
+ goto pop_fmt;
+ if(!(ft->flags&SFFMT_VALUE) )
+ goto t_arg;
+ if((t_str = argv.s) &&
+ (n_str = (int)ft->size) < 0)
+ n_str = strlen(t_str);
+ }
+ else
+ { t_arg:
+ if((t_str = va_arg(args,char*)) )
+ n_str = strlen(t_str);
+ }
+ }
+ goto loop_flags;
+ }
+ }
+
+ case '#' : /* alternative format */
+ flags |= SFFMT_ALTER;
+ goto loop_flags;
+
+ case '.' : /* width & base */
+ dot += 1;
+ if(isdigit(*form))
+ { fmt = *form++;
+ goto dot_size;
+ }
+ else if(*form == '*')
+ { form = (*_Sffmtintf)(form+1,&n);
+ if(*form == '$')
+ { form += 1;
+ if(!fp &&
+ !(fp = (*_Sffmtposf)(f,oform,oargs,ft,1)) )
+ goto pop_fmt;
+ n = FP_SET(n,argn);
+ }
+ else n = FP_SET(-1,argn);
+
+ if(fp)
+ v = fp[n].argv.i;
+ else if(ft && ft->extf )
+ { FMTSET(ft, form,args, '.',dot, 0, 0,0,0,
+ NIL(char*), 0);
+ if((*ft->extf)(f, (Void_t*)(&argv), ft) < 0)
+ goto pop_fmt;
+ if(ft->flags&SFFMT_VALUE)
+ v = argv.i;
+ else v = (dot <= 2) ? va_arg(args,int) : 0;
+ }
+ else v = (dot <= 2) ? va_arg(args,int) : 0;
+ if(v < 0)
+ v = 0;
+ goto dot_set;
+ }
+ else goto loop_flags;
+
+ case '0' : case '1' : case '2' : case '3' : case '4' :
+ case '5' : case '6' : case '7' : case '8' : case '9' :
+ dot_size :
+ for(v = fmt-'0'; isdigit(*form); ++form)
+ v = v*10 + (*form - '0');
+
+ if(*form == '$')
+ { form += 1;
+ if(!fp && !(fp = (*_Sffmtposf)(f,oform,oargs,ft,1)) )
+ goto pop_fmt;
+ argp = v-1;
+ goto loop_flags;
+ }
+
+ dot_set :
+ if(dot == 0 || dot == 1)
+ width = v;
+ else if(dot == 2)
+ base = v;
+ goto loop_flags;
+
+ case 'I' : /* object size */
+ size = -1; flags = (flags & ~SFFMT_TYPES) | SFFMT_IFLAG;
+ if(isdigit(*form))
+ { for(size = 0, n = *form; isdigit(n); n = *++form)
+ size = size*10 + (n - '0');
+ }
+ else if(*form == '*')
+ { form = (*_Sffmtintf)(form+1,&n);
+ if(*form == '$')
+ { form += 1;
+ if(!fp &&
+ !(fp = (*_Sffmtposf)(f,oform,oargs,ft,1)))
+ goto pop_fmt;
+ n = FP_SET(n,argn);
+ }
+ else n = FP_SET(-1,argn);
+
+ if(fp) /* use position list */
+ size = fp[n].argv.i;
+ else if(ft && ft->extf )
+ { FMTSET(ft, form,args, 'I',sizeof(int), 0, 0,0,0,
+ NIL(char*), 0);
+ if((*ft->extf)(f, (Void_t*)(&argv), ft) < 0)
+ goto pop_fmt;
+ if(ft->flags&SFFMT_VALUE)
+ size = argv.i;
+ else size = va_arg(args,int);
+ }
+ else size = va_arg(args,int);
+ }
+ goto loop_flags;
+
+ case 'l' :
+ size = -1; flags &= ~SFFMT_TYPES;
+ if(*form == 'l')
+ { form += 1;
+ flags |= SFFMT_LLONG;
+ }
+ else flags |= SFFMT_LONG;
+ goto loop_flags;
+ case 'h' :
+ size = -1; flags &= ~SFFMT_TYPES;
+ if(*form == 'h')
+ { form += 1;
+ flags |= SFFMT_SSHORT;
+ }
+ else flags |= SFFMT_SHORT;
+ goto loop_flags;
+ case 'L' :
+ size = -1; flags = (flags&~SFFMT_TYPES) | SFFMT_LDOUBLE;
+ goto loop_flags;
+ case 'j' :
+ size = -1; flags = (flags&~SFFMT_TYPES) | SFFMT_JFLAG;
+ goto loop_flags;
+ case 'z' :
+ size = -1; flags = (flags&~SFFMT_TYPES) | SFFMT_ZFLAG;
+ goto loop_flags;
+ case 't' :
+ size = -1; flags = (flags&~SFFMT_TYPES) | SFFMT_TFLAG;
+ goto loop_flags;
+ case QUOTE :
+ if(thousand > 0)
+ flags |= SFFMT_THOUSAND;
+ goto loop_flags;
+ }
+
+ /* set object size for scalars */
+ if(flags & SFFMT_TYPES)
+ { if((_Sftype[fmt]&(SFFMT_INT|SFFMT_UINT)) || fmt == 'n')
+ { if(flags&SFFMT_LONG)
+ size = sizeof(long);
+ else if(flags&SFFMT_SHORT)
+ size = sizeof(short);
+ else if(flags&SFFMT_SSHORT)
+ size = sizeof(char);
+ else if(flags&SFFMT_TFLAG)
+ size = sizeof(ptrdiff_t);
+ else if(flags&SFFMT_ZFLAG)
+ size = sizeof(size_t);
+ else if(flags&(SFFMT_LLONG|SFFMT_JFLAG) )
+ size = sizeof(Sflong_t);
+ else if(flags&SFFMT_IFLAG)
+ { if(size <= 0 ||
+ size == sizeof(Sflong_t)*CHAR_BIT )
+ size = sizeof(Sflong_t);
+ }
+ else if(size < 0)
+ size = sizeof(int);
+ }
+ else if(_Sftype[fmt]&SFFMT_FLOAT)
+ { if(flags&(SFFMT_LONG|SFFMT_LLONG))
+ size = sizeof(double);
+ else if(flags&SFFMT_LDOUBLE)
+ size = sizeof(Sfdouble_t);
+ else if(flags&SFFMT_IFLAG)
+ { if(size <= 0)
+ size = sizeof(Sfdouble_t);
+ }
+ else if(size < 0)
+ size = sizeof(float);
+ }
+ else if(_Sftype[fmt]&SFFMT_CHAR)
+ {
+#if _has_multibyte
+ if((flags&SFFMT_LONG) || fmt == 'C')
+ { size = sizeof(wchar_t) > sizeof(int) ?
+ sizeof(wchar_t) : sizeof(int);
+ } else
+#endif
+ if(size < 0)
+ size = sizeof(int);
+ }
+ }
+
+ argp = FP_SET(argp,argn);
+ if(fp)
+ { if(!(fp[argp].ft.flags&SFFMT_SKIP) )
+ { n_assign += 1;
+ value = fp[argp].argv.vp;
+ size = fp[argp].ft.size;
+ if(ft && ft->extf && fp[argp].ft.fmt != fp[argp].fmt)
+ fmt = fp[argp].ft.fmt;
+ }
+ else flags |= SFFMT_SKIP;
+ }
+ else if(ft && ft->extf)
+ { FMTSET(ft, form,args, fmt, size,flags, width,0,base, t_str,n_str);
+ SFend(f); SFOPEN(f,0);
+ v = (*ft->extf)(f, (Void_t*)&argv, ft);
+ SFLOCK(f,0); SFbuf(f);
+
+ if(v < 0)
+ goto pop_fmt;
+ else if(v > 0) /* extf comsumed v input bytes */
+ { n_input += v;
+ if(!(ft->flags&SFFMT_SKIP) )
+ n_assign += 1;
+ continue;
+ }
+ else /* if(v == 0): extf did not use input stream */
+ { FMTGET(ft, form,args, fmt, size, flags, width,n,base);
+
+ if((ft->flags&SFFMT_VALUE) && !(ft->flags&SFFMT_SKIP) )
+ value = argv.vp;
+ }
+ }
+
+ if(_Sftype[fmt] == 0) /* unknown pattern */
+ goto pop_fmt;
+
+ if(fmt == '!')
+ { if(!fp)
+ fp = (*_Sffmtposf)(f,oform,oargs,ft,1);
+ else goto pop_fmt;
+
+ if(!(argv.ft = va_arg(args,Sffmt_t*)) )
+ continue;
+ if(!argv.ft->form && ft ) /* change extension functions */
+ { if(ft->eventf &&
+ (*ft->eventf)(f,SF_DPOP,(Void_t*)form,ft) < 0)
+ continue;
+ fmstk->ft = ft = argv.ft;
+ }
+ else /* stack a new environment */
+ { if(!(fm = (Fmt_t*)malloc(sizeof(Fmt_t))) )
+ goto done;
+
+ ft = fm->ft = argv.ft;
+ SFMBSET(ft->mbs, &fmbs);
+ if(ft->form)
+ { fm->form = (char*)form; SFMBCPY(&fm->mbs,&fmbs);
+ va_copy(fm->args,args);
+
+ fm->oform = oform;
+ va_copy(fm->oargs,oargs);
+ fm->argn = argn;
+ fm->fp = fp;
+
+ form = ft->form; SFMBCLR(ft->mbs);
+ va_copy(args,ft->args);
+ argn = -1;
+ fp = NIL(Fmtpos_t*);
+ oform = (char*)form;
+ va_copy(oargs,args);
+ }
+ else fm->form = NIL(char*);
+
+ fm->eventf = ft->eventf;
+ fm->next = fmstk;
+ fmstk = fm;
+ }
+ continue;
+ }
+
+ /* get the address to assign value */
+ if(!value && !(flags&SFFMT_SKIP) )
+ value = va_arg(args,Void_t*);
+
+ if(fmt == 'n') /* return length of consumed input */
+ {
+#if !_ast_intmax_long
+ if(size == sizeof(Sflong_t) )
+ *((Sflong_t*)value) = (Sflong_t)(n_input+SFlen(f));
+ else
+#endif
+ if(size == sizeof(long) )
+ *((long*)value) = (long)(n_input+SFlen(f));
+ else if(size == sizeof(short) )
+ *((short*)value) = (short)(n_input+SFlen(f));
+ else if(size == sizeof(uchar))
+ *((uchar*)value) = (uchar)(n_input+SFlen(f));
+ else *((int*)value) = (int)(n_input+SFlen(f));
+ continue;
+ }
+
+ /* if get here, start scanning input */
+ if(width == 0)
+ width = fmt == 'c' ? 1 : MAXWIDTH;
+
+ /* define the first input character */
+ if(fmt == 'c' || fmt == '[' || fmt == 'C' )
+ SFgetc(f,inp);
+ else
+ { do { SFgetc(f,inp); }
+ while(isspace(inp)); /* skip starting blanks */
+ }
+ if(inp < 0)
+ goto done;
+
+ if(_Sftype[fmt] == SFFMT_FLOAT)
+ { SFungetc(f,inp); SCinit(&scd,1);
+ argv.ld = _sfdscan((Void_t*)(&scd), _scgetc);
+ SCend(&scd,1);
+
+ if(scd.error >= 0)
+ { if(inp >= 0)
+ SFungetc(f, inp);
+ goto pop_fmt;
+ }
+
+ if(value)
+ {
+#if !_ast_fltmax_double
+ if(size == sizeof(Sfdouble_t))
+ *((Sfdouble_t*)value) = argv.ld;
+ else
+#endif
+ if(size == sizeof(double))
+ *((double*)value) = (double)argv.ld;
+ else *((float*)value) = (float)argv.ld;
+
+ n_assign += 1;
+ }
+ }
+ else if(_Sftype[fmt] == SFFMT_UINT || fmt == 'p')
+ { if(inp == '-')
+ { SFungetc(f,inp);
+ goto pop_fmt;
+ }
+ else goto int_cvt;
+ }
+ else if(_Sftype[fmt] == SFFMT_INT)
+ { int_cvt:
+ if(inp == '-' || inp == '+')
+ { if(inp == '-')
+ flags |= SFFMT_MINUS;
+ while(--width > 0 && SFgetc(f,inp) >= 0)
+ if(!isspace(inp))
+ break;
+ }
+ if(inp < 0)
+ goto done;
+
+ if(fmt == 'o')
+ base = 8;
+ else if(fmt == 'x' || fmt == 'X' || fmt == 'p')
+ base = 16;
+ else if(fmt == 'i' && inp == '0') /* self-described data */
+ { base = 8;
+ if(width > 1) /* peek to see if it's a base-16 */
+ { if(SFgetc(f,inp) >= 0)
+ { if(inp == 'x' || inp == 'X')
+ base = 16;
+ SFungetc(f,inp);
+ }
+ inp = '0';
+ }
+ }
+
+ /* now convert */
+ argv.lu = 0;
+ if(base == 16)
+ { sp = (char*)_Sfcv36;
+ shift = 4;
+ if(sp[inp] >= 16)
+ { SFungetc(f,inp);
+ goto pop_fmt;
+ }
+ if(inp == '0' && --width > 0)
+ { /* skip leading 0x or 0X */
+ if(SFgetc(f,inp) >= 0 &&
+ (inp == 'x' || inp == 'X') && --width > 0)
+ SFgetc(f,inp);
+ }
+ if(inp >= 0 && sp[inp] < 16)
+ goto base_shift;
+ }
+ else if(base == 10)
+ { for(n = v = 0;; )
+ { /* fast base 10 conversion */
+#define TEN(x) (((x) << 3) + ((x) << 1) )
+ if (inp >= '0' && inp <= '9')
+ { argv.lu = TEN(argv.lu) + (inp-'0');
+ n += 1;
+ }
+ else if(inp == thousand)
+ { if((v && n != 3) || (!v && n > 3) )
+ break;
+ v = 1; n = 0;
+ }
+ else break;
+ if((width -= 1) <= 0 || SFgetc(f,inp) < 0)
+ break;
+ }
+ if (!n && !v)
+ { SFungetc(f,inp);
+ goto pop_fmt;
+ }
+
+ if(fmt == 'i' && inp == '#' && !(flags&SFFMT_ALTER) )
+ { base = (int)argv.lu;
+ if(base < 2 || base > SF_RADIX)
+ goto pop_fmt;
+ argv.lu = 0;
+ sp = (char*)(base <= 36 ? _Sfcv36 : _Sfcv64);
+ if(--width > 0 &&
+ SFgetc(f,inp) >= 0 && sp[inp] < base)
+ goto base_conv;
+ }
+ }
+ else
+ { /* other bases */
+ sp = (char*)(base <= 36 ? _Sfcv36 : _Sfcv64);
+ if(base < 2 || base > SF_RADIX || sp[inp] >= base)
+ { SFungetc(f,inp);
+ goto pop_fmt;
+ }
+
+ base_conv: /* check for power of 2 conversions */
+ if((base & ~(base-1)) == base)
+ { if(base < 8)
+ shift = base < 4 ? 1 : 2;
+ else if(base < 32)
+ shift = base < 16 ? 3 : 4;
+ else shift = base < 64 ? 5 : 6;
+
+ base_shift: do
+ { argv.lu = (argv.lu << shift) + sp[inp];
+ } while(--width > 0 &&
+ SFgetc(f,inp) >= 0 && sp[inp] < base);
+ }
+ else
+ { do
+ { argv.lu = (argv.lu * base) + sp[inp];
+ } while(--width > 0 &&
+ SFgetc(f,inp) >= 0 && sp[inp] < base);
+ }
+ }
+
+ if(flags&SFFMT_MINUS)
+ argv.ll = -argv.ll;
+
+ if(value)
+ { n_assign += 1;
+
+ if(fmt == 'p')
+#if _more_void_int
+ *((Void_t**)value) = (Void_t*)((ulong)argv.lu);
+#else
+ *((Void_t**)value) = (Void_t*)((uint)argv.lu);
+#endif
+#if !_ast_intmax_long
+ else if(size == sizeof(Sflong_t))
+ *((Sflong_t*)value) = argv.ll;
+#endif
+ else if(size == sizeof(long))
+ { if(fmt == 'd' || fmt == 'i')
+ *((long*)value) = (long)argv.ll;
+ else *((ulong*)value) = (ulong)argv.lu;
+ }
+ else if(size == sizeof(short))
+ { if(fmt == 'd' || fmt == 'i')
+ *((short*)value) = (short)argv.ll;
+ else *((ushort*)value) = (ushort)argv.lu;
+ }
+ else if(size == sizeof(char) )
+ { if(fmt == 'd' || fmt == 'i')
+ *((char*)value) = (char)argv.ll;
+ else *((uchar*)value) = (uchar)argv.lu;
+ }
+ else
+ { if(fmt == 'd' || fmt == 'i')
+ *((int*)value) = (int)argv.ll;
+ else *((uint*)value) = (uint)argv.lu;
+ }
+ }
+ }
+ else if(fmt == 'C' || fmt == 'S')
+ { fmt = fmt == 'C' ? 'c' : 's';
+ flags = (flags & ~SFFMT_TYPES) | SFFMT_LONG;
+ goto do_string;
+ }
+ else if(fmt == 's' || fmt == 'c' || fmt == '[' )
+ { do_string:
+ if(value)
+ { if(size < 0)
+ size = MAXWIDTH;
+ if(fmt != 'c')
+ size -= 1;
+#if _has_multibyte
+ if(flags&SFFMT_LONG)
+ argv.ws = (wchar_t*)value;
+ else
+#endif
+ argv.s = (char*)value;
+ }
+ else size = 0;
+
+ if(fmt == '[' && !(form = _sfsetclass(form,&acc,flags)) )
+ { SFungetc(f,inp);
+ goto pop_fmt;
+ }
+
+ n = 0; /* count number of scanned characters */
+#if _has_multibyte
+ if(flags&SFFMT_LONG)
+ { SFungetc(f,inp); SCinit(&scd,0); SFMBCLR(&mbs);
+ for(; width > 0; --width)
+ { if(SFgetwc(&scd,&wc,fmt,&acc,&mbs) == 0)
+ break;
+ if((n += 1) <= size)
+ *argv.ws++ = wc;
+ }
+ SCend(&scd,0);
+ }
+ else
+#endif
+
+ if(fmt == 's')
+ { do
+ { if(isspace(inp))
+ break;
+ if((n += 1) <= size)
+ *argv.s++ = inp;
+ } while(--width > 0 && SFgetc(f,inp) >= 0);
+ }
+ else if(fmt == 'c')
+ { do
+ { if((n += 1) <= size)
+ *argv.s++ = inp;
+ } while(--width > 0 && SFgetc(f,inp) >= 0);
+ }
+ else /* if(fmt == '[') */
+ { do
+ { if(!acc.ok[inp])
+ { if(n > 0 || (flags&SFFMT_ALTER) )
+ break;
+ else
+ { SFungetc(f,inp);
+ goto pop_fmt;
+ }
+ }
+ if((n += 1) <= size)
+ *argv.s++ = inp;
+ } while(--width > 0 && SFgetc(f,inp) >= 0);
+ }
+
+ if(value && (n > 0 || fmt == '[') )
+ { n_assign += 1;
+ if(fmt != 'c' && size >= 0)
+ {
+#if _has_multibyte
+ if(flags&SFFMT_LONG)
+ *argv.ws = 0;
+ else
+#endif
+ *argv.s = 0;
+ }
+ }
+ }
+
+ if(width > 0 && inp >= 0)
+ SFungetc(f,inp);
+ }
+
+pop_fmt:
+ if(fp)
+ { free(fp);
+ fp = NIL(Fmtpos_t*);
+ }
+ while((fm = fmstk) ) /* pop the format stack and continue */
+ { if(fm->eventf)
+ { if(!form || !form[0])
+ (*fm->eventf)(f,SF_FINAL,NIL(Void_t*),ft);
+ else if((*fm->eventf)(f,SF_DPOP,(Void_t*)form,ft) < 0)
+ goto loop_fmt;
+ }
+
+ fmstk = fm->next;
+ if((form = fm->form) )
+ { SFMBCPY(&fmbs,&fm->mbs);
+ va_copy(args, fm->args);
+ oform = fm->oform;
+ va_copy(oargs,fm->oargs);
+ argn = fm->argn;
+ fp = fm->fp;
+ }
+ ft = fm->ft;
+ free(fm);
+ if(form && form[0])
+ goto loop_fmt;
+ }
+
+done:
+ if(fp)
+ free(fp);
+ while((fm = fmstk) )
+ { if(fm->eventf)
+ (*fm->eventf)(f,SF_FINAL,NIL(Void_t*),fm->ft);
+ fmstk = fm->next;
+ free(fm);
+ }
+
+ SFend(f);
+
+ SFOPEN(f,0);
+
+ if(n_assign == 0 && inp < 0)
+ n_assign = -1;
+
+ SFMTXRETURN(f,n_assign);
+}
diff --git a/usr/src/lib/libast/common/sfio/sfwr.c b/usr/src/lib/libast/common/sfio/sfwr.c
new file mode 100644
index 0000000000..5c44c1596f
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfwr.c
@@ -0,0 +1,248 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Write with discipline.
+**
+** Written by Kiem-Phong Vo.
+*/
+
+/* hole preserving writes */
+#if __STD_C
+static ssize_t sfoutput(Sfio_t* f, reg char* buf, reg size_t n)
+#else
+static ssize_t sfoutput(f,buf,n)
+Sfio_t* f;
+reg char* buf;
+reg size_t n;
+#endif
+{ reg char *sp, *wbuf, *endbuf;
+ reg ssize_t s, w, wr;
+
+ s = w = 0;
+ wbuf = buf;
+ endbuf = buf+n;
+ while(n > 0)
+ { if((ssize_t)n < _Sfpage) /* no hole possible */
+ { buf += n;
+ s = n = 0;
+ }
+ else while((ssize_t)n >= _Sfpage)
+ { /* see if a hole of 0's starts here */
+ sp = buf+1;
+ if(buf[0] == 0 && buf[_Sfpage-1] == 0)
+ { /* check byte at a time until int-aligned */
+ while(((ulong)sp)%sizeof(int))
+ { if(*sp != 0)
+ goto chk_hole;
+ sp += 1;
+ }
+
+ /* check using int to speed up */
+ while(sp < endbuf)
+ { if(*((int*)sp) != 0)
+ goto chk_hole;
+ sp += sizeof(int);
+ }
+
+ /* check the remaining bytes */
+ if(sp > endbuf)
+ { sp -= sizeof(int);
+ while(sp < endbuf)
+ { if(*sp != 0)
+ goto chk_hole;
+ sp += 1;
+ }
+ }
+ }
+
+ chk_hole:
+ if((s = sp-buf) >= _Sfpage) /* found a hole */
+ break;
+
+ /* skip a dirty page */
+ n -= _Sfpage;
+ buf += _Sfpage;
+ }
+
+ /* write out current dirty pages */
+ if(buf > wbuf)
+ { if((ssize_t)n < _Sfpage)
+ { buf = endbuf;
+ n = s = 0;
+ }
+ if((wr = syswritef(f->file,wbuf,buf-wbuf)) > 0)
+ { w += wr;
+ f->bits &= ~SF_HOLE;
+ }
+ if(wr != (buf-wbuf))
+ break;
+ wbuf = buf;
+ }
+
+ /* seek to a rounded boundary within the hole */
+ if(s >= _Sfpage)
+ { s = (s/_Sfpage)*_Sfpage;
+ if(SFSK(f,(Sfoff_t)s,SEEK_CUR,NIL(Sfdisc_t*)) < 0)
+ break;
+ w += s;
+ n -= s;
+ wbuf = (buf += s);
+ f->bits |= SF_HOLE;
+
+ if(n > 0)
+ { /* next page must be dirty */
+ s = (ssize_t)n <= _Sfpage ? 1 : _Sfpage;
+ buf += s;
+ n -= s;
+ }
+ }
+ }
+
+ return w > 0 ? w : -1;
+}
+
+#if __STD_C
+ssize_t sfwr(reg Sfio_t* f, reg const Void_t* buf, reg size_t n, reg Sfdisc_t* disc)
+#else
+ssize_t sfwr(f,buf,n,disc)
+reg Sfio_t* f;
+reg Void_t* buf;
+reg size_t n;
+reg Sfdisc_t* disc;
+#endif
+{
+ reg ssize_t w;
+ reg Sfdisc_t* dc;
+ reg int local, oerrno;
+
+ SFMTXSTART(f,(ssize_t)(-1));
+
+ GETLOCAL(f,local);
+ if(!local && !(f->bits&SF_DCDOWN)) /* an external user's call */
+ { if(f->mode != SF_WRITE && _sfmode(f,SF_WRITE,0) < 0 )
+ SFMTXRETURN(f, (ssize_t)(-1));
+ if(f->next > f->data && SFSYNC(f) < 0 )
+ SFMTXRETURN(f, (ssize_t)(-1));
+ }
+
+ for(;;)
+ { /* stream locked by sfsetfd() */
+ if(!(f->flags&SF_STRING) && f->file < 0)
+ SFMTXRETURN(f,(ssize_t)0);
+
+ /* clear current error states */
+ f->flags &= ~(SF_EOF|SF_ERROR);
+
+ dc = disc;
+ if(f->flags&SF_STRING) /* total required buffer */
+ w = n + (f->next - f->data);
+ else
+ { /* warn that a write is about to happen */
+ SFDISC(f,dc,writef);
+ if(dc && dc->exceptf && (f->flags&SF_IOCHECK) )
+ { reg int rv;
+ if(local)
+ SETLOCAL(f);
+ if((rv = _sfexcept(f,SF_WRITE,n,dc)) > 0)
+ n = rv;
+ else if(rv < 0)
+ { f->flags |= SF_ERROR;
+ SFMTXRETURN(f, rv);
+ }
+ }
+
+ if(f->extent >= 0)
+ { /* make sure we are at the right place to write */
+ if(f->flags&SF_APPENDWR)
+ { if(f->here != f->extent || (f->flags&SF_SHARE))
+ { f->here = SFSK(f,(Sfoff_t)0,SEEK_END,dc);
+ f->extent = f->here;
+ }
+ }
+ else if((f->flags&SF_SHARE) && !(f->flags&SF_PUBLIC))
+ f->here = SFSK(f,f->here,SEEK_SET,dc);
+ }
+
+ oerrno = errno;
+ errno = 0;
+
+ if(dc && dc->writef)
+ { SFDCWR(f,buf,n,dc,w);
+ }
+ else if(SFISNULL(f))
+ w = n;
+ else if(f->flags&SF_WHOLE)
+ goto do_write;
+ else if((ssize_t)n >= _Sfpage &&
+ !(f->flags&(SF_SHARE|SF_APPENDWR)) &&
+ f->here == f->extent && (f->here%_Sfpage) == 0)
+ { if((w = sfoutput(f,(char*)buf,n)) <= 0)
+ goto do_write;
+ }
+ else
+ {
+ do_write:
+ if((w = syswritef(f->file,buf,n)) > 0)
+ f->bits &= ~SF_HOLE;
+ }
+
+ if(errno == 0)
+ errno = oerrno;
+
+ if(w > 0)
+ { if(!(f->bits&SF_DCDOWN) )
+ { if((f->flags&(SF_APPENDWR|SF_PUBLIC)) && f->extent >= 0 )
+ f->here = SFSK(f,(Sfoff_t)0,SEEK_CUR,dc);
+ else f->here += w;
+ if(f->extent >= 0 && f->here > f->extent)
+ f->extent = f->here;
+ }
+
+ SFMTXRETURN(f, (ssize_t)w);
+ }
+ }
+
+ if(local)
+ SETLOCAL(f);
+ switch(_sfexcept(f,SF_WRITE,w,dc))
+ {
+ case SF_ECONT :
+ goto do_continue;
+ case SF_EDONE :
+ w = local ? 0 : w;
+ SFMTXRETURN(f, (ssize_t)w);
+ case SF_EDISC :
+ if(!local && !(f->flags&SF_STRING))
+ goto do_continue;
+ /* else fall thru */
+ case SF_ESTACK :
+ SFMTXRETURN(f, (ssize_t)(-1));
+ }
+
+ do_continue:
+ for(dc = f->disc; dc; dc = dc->disc)
+ if(dc == disc)
+ break;
+ disc = dc;
+ }
+}
diff --git a/usr/src/lib/libast/common/sfio/sfwrite.c b/usr/src/lib/libast/common/sfio/sfwrite.c
new file mode 100644
index 0000000000..be7241ade8
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/sfwrite.c
@@ -0,0 +1,170 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "sfhdr.h"
+
+/* Write data out to the file system
+**
+** Written by Kiem-Phong Vo.
+*/
+
+#if __STD_C
+ssize_t sfwrite(reg Sfio_t* f, const Void_t* buf, reg size_t n)
+#else
+ssize_t sfwrite(f,buf,n)
+reg Sfio_t* f; /* write to this stream. */
+Void_t* buf; /* buffer to be written. */
+reg size_t n; /* number of bytes. */
+#endif
+{
+ reg uchar *s, *begs, *next;
+ reg ssize_t w;
+ reg int local;
+
+ SFMTXSTART(f, (ssize_t)(-1));
+
+ GETLOCAL(f,local);
+
+ if(!buf)
+ SFMTXRETURN(f, (ssize_t)(n == 0 ? 0 : -1) );
+
+ /* release peek lock */
+ if(f->mode&SF_PEEK)
+ { if(!(f->mode&SF_WRITE) && (f->flags&SF_RDWR) != SF_RDWR)
+ SFMTXRETURN(f, (ssize_t)(-1));
+
+ if((uchar*)buf != f->next &&
+ (!f->rsrv || f->rsrv->data != (uchar*)buf) )
+ SFMTXRETURN(f, (ssize_t)(-1));
+
+ f->mode &= ~SF_PEEK;
+
+ if(f->mode&SF_PKRD)
+ { /* read past peeked data */
+ char buf[16];
+ reg ssize_t r;
+
+ for(w = n; w > 0; )
+ { if((r = w) > sizeof(buf))
+ r = sizeof(buf);
+ if((r = sysreadf(f->file,buf,r)) <= 0)
+ { n -= w;
+ break;
+ }
+ else w -= r;
+ }
+
+ f->mode &= ~SF_PKRD;
+ f->endb = f->data + n;
+ f->here += n;
+ }
+
+ if((f->mode&SF_READ) && f->proc)
+ f->next += n;
+ }
+
+ s = begs = (uchar*)buf;
+ for(;; f->mode &= ~SF_LOCK)
+ { /* check stream mode */
+ if(SFMODE(f,local) != SF_WRITE && _sfmode(f,SF_WRITE,local) < 0 )
+ { w = s > begs ? s-begs : -1;
+ SFMTXRETURN(f,w);
+ }
+
+ SFLOCK(f,local);
+
+ w = f->endb - f->next;
+
+ if(s == f->next) /* after sfreserve */
+ { if(w > (ssize_t)n)
+ w = (ssize_t)n;
+ f->next = (s += w);
+ n -= w;
+ break;
+ }
+
+ /* attempt to create space in buffer */
+ if(w == 0 || ((f->flags&SF_WHOLE) && w < (ssize_t)n) )
+ { if(f->flags&SF_STRING) /* extend buffer */
+ { (void)SFWR(f, s, n-w, f->disc);
+ if((w = f->endb - f->next) < (ssize_t)n)
+ { if(!(f->flags&SF_STRING)) /* maybe sftmp */
+ { if(f->next > f->data)
+ goto fls_buf;
+ }
+ else if(w == 0)
+ break;
+ }
+ }
+ else if(f->next > f->data)
+ { fls_buf:
+ (void)SFFLSBUF(f, -1);
+ if((w = f->endb - f->next) < (ssize_t)n &&
+ (f->flags&SF_WHOLE) && f->next > f->data )
+ break;
+ }
+ }
+
+ if(!(f->flags&SF_STRING) && f->next == f->data &&
+ (((f->flags&SF_WHOLE) && w <= n) || SFDIRECT(f,n)) )
+ { /* bypass buffering */
+ if((w = SFWR(f,s,n,f->disc)) <= 0 )
+ break;
+ }
+ else
+ { if(w > (ssize_t)n)
+ w = (ssize_t)n;
+ if(w <= 0) /* no forward progress possible */
+ break;
+ memcpy(f->next, s, w);
+ f->next += w;
+ }
+
+ s += w;
+ if((n -= w) <= 0)
+ break;
+ }
+
+ /* always flush buffer for share streams */
+ if(f->extent < 0 && (f->flags&SF_SHARE) && !(f->flags&SF_PUBLIC) )
+ (void)SFFLSBUF(f,-1);
+
+ /* check to see if buffer should be flushed */
+ else if(n == 0 && (f->flags&SF_LINE) && !(f->flags&SF_STRING))
+ { if((ssize_t)(n = f->next-f->data) > (w = s-begs))
+ n = w;
+ if(n > 0 && n < HIFORLINE)
+ { for(next = f->next-1; n > 0; --n, --next)
+ { if(*next == '\n')
+ { n = HIFORLINE;
+ break;
+ }
+ }
+ }
+ if(n >= HIFORLINE)
+ (void)SFFLSBUF(f,-1);
+ }
+
+ SFOPEN(f,local);
+
+ w = s-begs;
+ SFMTXRETURN(f,w);
+}
diff --git a/usr/src/lib/libast/common/sfio/vthread.h b/usr/src/lib/libast/common/sfio/vthread.h
new file mode 100644
index 0000000000..cd2f7625ae
--- /dev/null
+++ b/usr/src/lib/libast/common/sfio/vthread.h
@@ -0,0 +1,219 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _VTHREAD_H
+#define _VTHREAD_H 1
+
+#define VTHREAD_VERSION 20001201L
+
+/* Header for the Vthread library.
+** Note that the macro vt_threaded may be defined
+** outside of vthread.h to suppress threading.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com
+*/
+
+#include <ast_common.h>
+#include <errno.h>
+
+/* ast doesn't do threads yet */
+#if _PACKAGE_ast && !defined(vt_threaded)
+#define vt_threaded 0
+#endif
+
+#if !defined(vt_threaded) || (defined(vt_threaded) && vt_threaded == 1)
+#define _may_use_threads 1
+#else
+#define _may_use_threads 0
+#endif
+#undef vt_threaded
+
+#if _may_use_threads && !defined(vt_threaded) && _hdr_pthread
+#define vt_threaded 1
+#include <pthread.h>
+typedef pthread_mutex_t _vtmtx_t;
+typedef pthread_once_t _vtonce_t;
+typedef pthread_t _vtself_t;
+typedef pthread_t _vtid_t;
+typedef pthread_attr_t _vtattr_t;
+
+#if !defined(PTHREAD_ONCE_INIT) && defined(pthread_once_init)
+#define PTHREAD_ONCE_INIT pthread_once_init
+#endif
+
+#endif
+
+#if _may_use_threads && !defined(vt_threaded) && _WIN32
+#define vt_threaded 1
+#include <windows.h>
+typedef CRITICAL_SECTION _vtmtx_t;
+typedef int _vtonce_t;
+typedef HANDLE _vtself_t;
+typedef DWORD _vtid_t;
+typedef SECURITY_ATTRIBUTES _vtattr_t;
+#endif
+
+#ifndef vt_threaded
+#define vt_threaded 0
+#endif
+
+/* common attributes for various structures */
+#define VT_RUNNING 000000001 /* thread is running */
+#define VT_SUSPENDED 000000002 /* thread is suspended */
+#define VT_WAITED 000000004 /* thread has been waited */
+#define VT_FREE 000010000 /* object can be freed */
+#define VT_INIT 000020000 /* object was initialized */
+#define VT_BITS 000030007 /* bits that we care about */
+
+/* directives for vtset() */
+#define VT_STACK 1 /* set stack size */
+
+typedef struct _vtmutex_s Vtmutex_t;
+typedef struct _vtonce_s Vtonce_t;
+typedef struct _vthread_s Vthread_t;
+
+#ifndef EINVAL
+#define EINVAL 22
+#endif
+#ifndef EBUSY
+#define EBUSY 16
+#endif
+#ifndef EDEADLK
+#define EDEADLK 45
+#endif
+#ifndef EPERM
+#define EPERM 1
+#endif
+
+_BEGIN_EXTERNS_
+
+extern Vthread_t* vtopen _ARG_((Vthread_t*, int));
+extern int vtclose _ARG_((Vthread_t*));
+extern int vtset _ARG_((Vthread_t*, int, Void_t*));
+extern int vtrun _ARG_((Vthread_t*, void*(*)(void*), void*));
+extern int vtkill _ARG_((Vthread_t*));
+extern int vtwait _ARG_((Vthread_t*));
+
+extern int vtonce _ARG_((Vtonce_t*, void(*)() ));
+
+extern Vtmutex_t* vtmtxopen _ARG_((Vtmutex_t*, int));
+extern int vtmtxclose _ARG_((Vtmutex_t*));
+extern int vtmtxlock _ARG_((Vtmutex_t*));
+extern int vtmtxtrylock _ARG_((Vtmutex_t*));
+extern int vtmtxunlock _ARG_((Vtmutex_t*));
+extern int vtmtxclrlock _ARG_((Vtmutex_t*));
+
+extern Void_t* vtstatus _ARG_((Vthread_t*));
+extern int vterror _ARG_((Vthread_t*));
+extern int vtmtxerror _ARG_((Vtmutex_t*));
+extern int vtonceerror _ARG_((Vtonce_t*));
+
+_END_EXTERNS_
+
+#if vt_threaded
+
+/* mutex structure */
+struct _vtmutex_s
+{ _vtmtx_t lock;
+ int count;
+ _vtid_t owner;
+ int state;
+ int error;
+};
+
+/* structure for states of thread */
+struct _vthread_s
+{ _vtself_t self; /* self-handle */
+ _vtid_t id; /* thread id */
+ _vtattr_t attrs; /* attributes */
+ size_t stack; /* stack size */
+ int state; /* execution state */
+ int error; /* error status */
+ Void_t* exit; /* exit value */
+};
+
+/* structure for exactly once execution */
+struct _vtonce_s
+{ int done;
+ _vtonce_t once;
+ int error;
+};
+
+#if _WIN32
+#define VTONCE_INITDATA {0, 0}
+#else
+#define VTONCE_INITDATA {0, PTHREAD_ONCE_INIT }
+#endif
+
+#define vtstatus(vt) ((vt)->exit)
+#define vterror(vt) ((vt)->error)
+#define vtmtxerror(mtx) ((mtx)->error)
+#define vtonceerror(once) ((once)->error)
+
+#endif /*vt_threaded*/
+
+/* fake structures and functions */
+#if !vt_threaded
+struct _vtmutex_s
+{ int error;
+};
+struct _vtattr_s
+{ int error;
+};
+struct _vthread_s
+{ int error;
+};
+struct _vtonce_s
+{ int error;
+};
+
+typedef int _vtmtx_t;
+typedef int _vtonce_t;
+typedef int _vtself_t;
+typedef int _vtid_t;
+typedef int _vtattr_t;
+
+#define VTONCE_INITDATA {0}
+
+#define vtopen(vt,flgs) ((Vthread_t*)0)
+#define vtclose(vt) (-1)
+#define vtkill(vt) (-1)
+#define vtwait(vt) (-1)
+#define vtrun(vt,fn,arg) (-1)
+
+#define vtset(vt,t,v) (-1)
+#define vtonce(on,fu) (-1)
+
+#define vtmtxopen(mtx,flgs) ((Vtmutex_t*)0)
+#define vtmtxclose(mtx) (-1)
+#define vtmtxlock(mtx) (-1)
+#define vtmtxtrylock(mtx) (-1)
+#define vtmtxunlock(mtx) (-1)
+#define vtmtxclrlock(mtx) (-1)
+
+#define vtstatus(vt) ((Void_t*)0)
+#define vterror(vt) (0)
+#define vtmtxerror(mtx) (0)
+#define vtonceerror(once) (0)
+
+#endif /*!vt_threaded*/
+
+#endif /*_VTHREAD_H*/
diff --git a/usr/src/lib/libast/common/std/bytesex.h b/usr/src/lib/libast/common/std/bytesex.h
new file mode 100644
index 0000000000..2bf2022afb
--- /dev/null
+++ b/usr/src/lib/libast/common/std/bytesex.h
@@ -0,0 +1,43 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * linux/gnu compatibility
+ */
+
+#ifndef _BYTESEX_H
+#define _BYTESEX_H
+
+#include <ast_common.h>
+
+#undef __BYTE_ORDER
+
+#if ( _ast_intswap & 3 ) == 3
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#else
+#if ( _ast_intswap & 3 ) == 1
+#define __BYTE_ORDER __PDP_ENDIAN
+#else
+#define __BYTE_ORDER __BIG_ENDIAN
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/std/dirent.h b/usr/src/lib/libast/common/std/dirent.h
new file mode 100644
index 0000000000..32f33800b5
--- /dev/null
+++ b/usr/src/lib/libast/common/std/dirent.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_dirent.h>
diff --git a/usr/src/lib/libast/common/std/endian.h b/usr/src/lib/libast/common/std/endian.h
new file mode 100644
index 0000000000..2299b5a3bc
--- /dev/null
+++ b/usr/src/lib/libast/common/std/endian.h
@@ -0,0 +1,54 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * linux/gnu compatibility
+ */
+
+#ifndef _ENDIAN_H
+#define _ENDIAN_H
+
+#include <bytesex.h>
+
+#define __LITTLE_ENDIAN 1234
+#define __BIG_ENDIAN 4321
+#define __PDP_ENDIAN 3412
+
+#if defined (__USE_BSD) && !defined(__STRICT_ANSI__)
+
+#ifndef LITTLE_ENDIAN
+#define LITTLE_ENDIAN __LITTLE_ENDIAN
+#endif
+
+#ifndef BIG_ENDIAN
+#define BIG_ENDIAN __BIG_ENDIAN
+#endif
+
+#ifndef PDP_ENDIAN
+#define PDP_ENDIAN __PDP_ENDIAN
+#endif
+
+#undef BYTE_ORDER
+#define BYTE_ORDER __BYTE_ORDER
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/std/iconv.h b/usr/src/lib/libast/common/std/iconv.h
new file mode 100644
index 0000000000..e63b3f0fcd
--- /dev/null
+++ b/usr/src/lib/libast/common/std/iconv.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_iconv.h>
diff --git a/usr/src/lib/libast/common/std/nl_types.h b/usr/src/lib/libast/common/std/nl_types.h
new file mode 100644
index 0000000000..db7383c626
--- /dev/null
+++ b/usr/src/lib/libast/common/std/nl_types.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_nl_types.h>
diff --git a/usr/src/lib/libast/common/std/stdio.h b/usr/src/lib/libast/common/std/stdio.h
new file mode 100644
index 0000000000..7e137c5712
--- /dev/null
+++ b/usr/src/lib/libast/common/std/stdio.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_stdio.h>
diff --git a/usr/src/lib/libast/common/std/wchar.h b/usr/src/lib/libast/common/std/wchar.h
new file mode 100644
index 0000000000..557a403adc
--- /dev/null
+++ b/usr/src/lib/libast/common/std/wchar.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_wchar.h>
diff --git a/usr/src/lib/libast/common/stdio/_doprnt.c b/usr/src/lib/libast/common/stdio/_doprnt.c
new file mode 100644
index 0000000000..b1b7cc68ee
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/_doprnt.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+_doprnt(const char* fmt, va_list args, Sfio_t* f)
+{
+ STDIO_INT(f, "_doprnt", int, (const char*, va_list, Sfio_t*), (fmt, args, f))
+
+ return sfvprintf(f, fmt, args);
+}
diff --git a/usr/src/lib/libast/common/stdio/_doscan.c b/usr/src/lib/libast/common/stdio/_doscan.c
new file mode 100644
index 0000000000..1072ca4b42
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/_doscan.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+_doscan(Sfio_t* f, const char* fmt, va_list args)
+{
+ STDIO_INT(f, "_doscan", int, (Sfio_t*, const char*, va_list), (f, fmt, args))
+
+ return sfvscanf(f, fmt, args);
+}
diff --git a/usr/src/lib/libast/common/stdio/_filbuf.c b/usr/src/lib/libast/common/stdio/_filbuf.c
new file mode 100644
index 0000000000..eb8306000a
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/_filbuf.c
@@ -0,0 +1,36 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int
+_filbuf(Sfio_t* f)
+{
+ STDIO_INT(f, "_filbuf", int, (Sfio_t*), (f))
+
+ return _sffilbuf(f, 0);
+}
diff --git a/usr/src/lib/libast/common/stdio/_flsbuf.c b/usr/src/lib/libast/common/stdio/_flsbuf.c
new file mode 100644
index 0000000000..27ae6c1007
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/_flsbuf.c
@@ -0,0 +1,44 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+#if !STDIO_TRANSFER
+
+NoN(_flsbuf)
+
+#else
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int
+_flsbuf(int c, Sfio_t* f)
+{
+ STDIO_INT(f, "_flsbuf", int, (int, Sfio_t*), (c, f))
+
+ return _sfflsbuf(f, c);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/stdio/_stdfun.c b/usr/src/lib/libast/common/stdio/_stdfun.c
new file mode 100644
index 0000000000..9db057bf8b
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/_stdfun.c
@@ -0,0 +1,78 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if !_UWIN
+
+void _STUB_stdfun(){}
+
+#else
+
+#include <ast_windows.h>
+#include <uwin.h>
+#include <dlfcn.h>
+#include "FEATURE/uwin"
+
+#if _lib___iob_func
+#define IOB ((char*)__iob_func())
+#elif _dat__iob
+#define IOB ((char*)_iob)
+#else
+#define IOB ((char*)__p__iob())
+#endif
+
+#define IOBMAX (512*32)
+
+#include "stdhdr.h"
+
+int
+_stdfun(Sfio_t* f, Funvec_t* vp)
+{
+ static char* iob;
+ static int init;
+ static void* bp;
+ static void* np;
+
+ if (!iob && !(iob = IOB))
+ return 0;
+ if (f && ((char*)f < iob || (char*)f > iob+IOBMAX))
+ return 0;
+ if (!vp->vec[1])
+ {
+ if (!init)
+ {
+ init = 1;
+ bp = dlopen("/usr/bin/stdio.dll", 0);
+ }
+ if (bp && (vp->vec[1] = (Fun_f)dlsym(bp, vp->name)))
+ return 1;
+ if (!np && !(np = dlopen("/sys/msvcrt.dll", 0)))
+ return -1;
+ if (!(vp->vec[1] = (Fun_f)dlsym(np, vp->name)))
+ return -1;
+ }
+ return 1;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/stdio/_stdopen.c b/usr/src/lib/libast/common/stdio/_stdopen.c
new file mode 100644
index 0000000000..73cbbc7dbf
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/_stdopen.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/* OBSOLETE 20010101 -- use fdopen */
+
+#include "stdhdr.h"
+
+extern Sfio_t*
+_stdopen(int fd, const char* mode)
+{
+ return fdopen(fd, mode);
+}
diff --git a/usr/src/lib/libast/common/stdio/_stdprintf.c b/usr/src/lib/libast/common/stdio/_stdprintf.c
new file mode 100644
index 0000000000..fed31a2bf9
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/_stdprintf.c
@@ -0,0 +1,38 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/* OBSOLETE 20010101 -- use printf */
+
+#include "stdhdr.h"
+
+extern int
+_stdprintf(const char* fmt, ...)
+{
+ va_list args;
+ int v;
+
+ va_start(args, fmt);
+ v = sfvprintf(sfstdout, fmt, args);
+ va_end(args);
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/_stdscanf.c b/usr/src/lib/libast/common/stdio/_stdscanf.c
new file mode 100644
index 0000000000..210455e56c
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/_stdscanf.c
@@ -0,0 +1,38 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/* OBSOLETE 20010101 -- use scanf */
+
+#include "stdhdr.h"
+
+extern int
+_stdscanf(const char* fmt, ...)
+{
+ va_list args;
+ int v;
+
+ va_start(args, fmt);
+ v = sfvscanf(sfstdin, fmt, args);
+ va_end(args);
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/_stdsprnt.c b/usr/src/lib/libast/common/stdio/_stdsprnt.c
new file mode 100644
index 0000000000..3b35d404d4
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/_stdsprnt.c
@@ -0,0 +1,38 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/* OBSOLETE 20010101 -- use sprintf */
+
+#include "stdhdr.h"
+
+extern int
+_stdsprintf(char* s, const char* fmt, ...)
+{
+ va_list args;
+ int v;
+
+ va_start(args, fmt);
+ v = s ? sfvsprintf(s, SF_BUFSIZE, fmt, args) : -1;
+ va_end(args);
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/_stdvbuf.c b/usr/src/lib/libast/common/stdio/_stdvbuf.c
new file mode 100644
index 0000000000..b057072bcc
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/_stdvbuf.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/* OBSOLETE 20010101 -- use setvbuf */
+
+#include "stdhdr.h"
+
+extern int
+_stdsetvbuf(Sfio_t* f, char* buf, int type, size_t size)
+{
+ return setvbuf(f, buf, type, size);
+}
diff --git a/usr/src/lib/libast/common/stdio/_stdvsnprnt.c b/usr/src/lib/libast/common/stdio/_stdvsnprnt.c
new file mode 100644
index 0000000000..fdcd5e97a1
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/_stdvsnprnt.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/* OBSOLETE 20010101 -- use vsnprintf */
+
+#include "stdhdr.h"
+
+extern int
+_stdvsnprintf(char* s, int n, const char* fmt, va_list args)
+{
+ return vsnprintf(s, n, fmt, args);
+}
diff --git a/usr/src/lib/libast/common/stdio/_stdvsprnt.c b/usr/src/lib/libast/common/stdio/_stdvsprnt.c
new file mode 100644
index 0000000000..4ac5bc09e3
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/_stdvsprnt.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/* OBSOLETE 20010101 -- use vsprintf */
+
+#include "stdhdr.h"
+
+extern int
+_stdvsprintf(char* s, const char* fmt, va_list args)
+{
+ return vsprintf(s, fmt, args);
+}
diff --git a/usr/src/lib/libast/common/stdio/_stdvsscn.c b/usr/src/lib/libast/common/stdio/_stdvsscn.c
new file mode 100644
index 0000000000..1eb7dd6065
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/_stdvsscn.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/* OBSOLETE 20010101 -- use vsscanf */
+
+#include "stdhdr.h"
+
+extern int
+_stdvsscanf(char* s, const char* fmt, va_list args)
+{
+ return vsscanf(s, fmt, args);
+}
diff --git a/usr/src/lib/libast/common/stdio/asprintf.c b/usr/src/lib/libast/common/stdio/asprintf.c
new file mode 100644
index 0000000000..59fcf7bfb2
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/asprintf.c
@@ -0,0 +1,36 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+asprintf(char** s, const char* fmt, ...)
+{
+ va_list args;
+ int v;
+
+ va_start(args, fmt);
+ v = vasprintf(s, fmt, args);
+ va_end(args);
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/clearerr.c b/usr/src/lib/libast/common/stdio/clearerr.c
new file mode 100644
index 0000000000..694ba8cccf
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/clearerr.c
@@ -0,0 +1,33 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+clearerr(Sfio_t* f)
+{
+ STDIO_INT(f, "clearerr", int, (Sfio_t*), (f))
+
+ sfclrerr(f);
+ return sfclrlock(f);
+}
diff --git a/usr/src/lib/libast/common/stdio/fclose.c b/usr/src/lib/libast/common/stdio/fclose.c
new file mode 100644
index 0000000000..7b5932612b
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fclose.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+fclose(Sfio_t* f)
+{
+ STDIO_INT(f, "fclose", int, (Sfio_t*), (f))
+
+ return sfclose(f);
+}
diff --git a/usr/src/lib/libast/common/stdio/fdopen.c b/usr/src/lib/libast/common/stdio/fdopen.c
new file mode 100644
index 0000000000..2b773bb948
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fdopen.c
@@ -0,0 +1,34 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+Sfio_t*
+fdopen(int fd, const char* mode)
+{
+ int flags;
+
+ if (fd < 0 || !(flags = _sftype(mode, NiL, NiL)))
+ return 0;
+ return sfnew(NiL, NiL, (size_t)SF_UNBOUND, fd, flags);
+}
diff --git a/usr/src/lib/libast/common/stdio/feof.c b/usr/src/lib/libast/common/stdio/feof.c
new file mode 100644
index 0000000000..506df65e64
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/feof.c
@@ -0,0 +1,42 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+#if !_UWIN
+
+NoN(feof)
+
+#else
+
+#undef feof
+
+int
+feof(Sfio_t* f)
+{
+ STDIO_INT(f, "feof", int, (Sfio_t*), (f))
+
+ return sfeof(f);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/stdio/ferror.c b/usr/src/lib/libast/common/stdio/ferror.c
new file mode 100644
index 0000000000..b04748b41a
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/ferror.c
@@ -0,0 +1,42 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+#if !_UWIN
+
+NoN(ferror)
+
+#else
+
+#undef ferror
+
+int
+ferror(Sfio_t* f)
+{
+ STDIO_INT(f, "ferror", int, (Sfio_t*), (f))
+
+ return sferror(f);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/stdio/fflush.c b/usr/src/lib/libast/common/stdio/fflush.c
new file mode 100644
index 0000000000..6f56b3e2ae
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fflush.c
@@ -0,0 +1,37 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+fflush(Sfio_t* f)
+{
+ if (!f)
+ return sfsync(NiL);
+
+ STDIO_INT(f, "fflush", int, (Sfio_t*), (f))
+
+ if (f->extent > 0)
+ sfseek(f, (Sfoff_t)0, SEEK_CUR|SF_PUBLIC);
+ return (sfsync(f) < 0 || sfpurge(f) < 0) ? -1 : 0;
+}
diff --git a/usr/src/lib/libast/common/stdio/fgetc.c b/usr/src/lib/libast/common/stdio/fgetc.c
new file mode 100644
index 0000000000..411ca510d8
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fgetc.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+fgetc(Sfio_t* f)
+{
+ STDIO_INT(f, "fgetc", int, (Sfio_t*), (f))
+
+ return sfgetc(f);
+}
diff --git a/usr/src/lib/libast/common/stdio/fgetpos.c b/usr/src/lib/libast/common/stdio/fgetpos.c
new file mode 100644
index 0000000000..dc7f8d16e9
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fgetpos.c
@@ -0,0 +1,48 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#ifndef _NO_LARGEFILE64_SOURCE
+#define _NO_LARGEFILE64_SOURCE 1
+#endif
+
+#include "stdhdr.h"
+
+int
+fgetpos(Sfio_t* f, fpos_t* pos)
+{
+ STDIO_INT(f, "fgetpos", int, (Sfio_t*, fpos_t*), (f, pos))
+
+ return (pos->_sf_offset = sfseek(f, (Sfoff_t)0, SEEK_CUR)) >= 0 ? 0 : -1;
+}
+
+#ifdef _typ_int64_t
+
+int
+fgetpos64(Sfio_t* f, fpos64_t* pos)
+{
+ STDIO_INT(f, "fgetpos64", int, (Sfio_t*, fpos64_t*), (f, pos))
+
+ return (pos->_sf_offset = sfseek(f, (Sfoff_t)0, SEEK_CUR)) >= 0 ? 0 : -1;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/stdio/fgets.c b/usr/src/lib/libast/common/stdio/fgets.c
new file mode 100644
index 0000000000..2b3f9d309f
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fgets.c
@@ -0,0 +1,110 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+extern char*
+_stdgets(Sfio_t* f, char* us, int n, int isgets)
+{
+ int p;
+ unsigned char* is;
+ unsigned char* ps;
+
+ if(n <= 0 || !us || (f->mode != SF_READ && _sfmode(f,SF_READ,0) < 0))
+ return NIL(char*);
+
+ SFLOCK(f,0);
+
+ n -= 1;
+ is = (uchar*)us;
+
+ while(n)
+ { /* peek the read buffer for data */
+ if((p = f->endb - (ps = f->next)) <= 0 )
+ { f->getr = '\n';
+ f->mode |= SF_RC;
+ if(SFRPEEK(f,ps,p) <= 0)
+ break;
+ }
+
+ if(p > n)
+ p = n;
+
+#if _lib_memccpy
+ if((ps = (uchar*)memccpy((char*)is,(char*)ps,'\n',p)) != NIL(uchar*))
+ p = ps-is;
+ is += p;
+ ps = f->next+p;
+#else
+ if(!(f->flags&(SF_BOTH|SF_MALLOC)))
+ { while(p-- && (*is++ = *ps++) != '\n')
+ ;
+ p = ps-f->next;
+ }
+ else
+ { reg int c = ps[p-1];
+ if(c != '\n')
+ ps[p-1] = '\n';
+ while((*is++ = *ps++) != '\n')
+ ;
+ if(c != '\n')
+ { f->next[p-1] = c;
+ if((ps-f->next) >= p)
+ is[-1] = c;
+ }
+ }
+#endif
+
+ /* gobble up read data and continue */
+ f->next = ps;
+ if(is[-1] == '\n')
+ break;
+ else if(n > 0)
+ n -= p;
+ }
+
+ if((_Sfi = is - ((uchar*)us)) <= 0)
+ us = NIL(char*);
+ else if(isgets && is[-1] == '\n')
+ { is[-1] = '\0';
+ _Sfi -= 1;
+ }
+ else *is = '\0';
+
+ SFOPEN(f,0);
+ return us;
+}
+
+char*
+fgets(char* s, int n, Sfio_t* f)
+{
+ STDIO_PTR(f, "fgets", char*, (char*, int, Sfio_t*), (s, n, f))
+
+ return _stdgets(f, s, n, 0);
+}
+
+char*
+gets(char* s)
+{
+ return _stdgets(sfstdin, s, BUFSIZ, 1);
+}
diff --git a/usr/src/lib/libast/common/stdio/fgetwc.c b/usr/src/lib/libast/common/stdio/fgetwc.c
new file mode 100644
index 0000000000..acf98c8a16
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fgetwc.c
@@ -0,0 +1,35 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+wint_t
+fgetwc(Sfio_t* f)
+{
+ wchar_t c;
+
+ STDIO_INT(f, "fgetwc", wint_t, (Sfio_t*), (f))
+
+ FWIDE(f, WEOF);
+ return (sfread(f, &c, sizeof(c)) == sizeof(c)) ? c : WEOF;
+}
diff --git a/usr/src/lib/libast/common/stdio/fgetws.c b/usr/src/lib/libast/common/stdio/fgetws.c
new file mode 100644
index 0000000000..e065eb45b0
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fgetws.c
@@ -0,0 +1,52 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+wchar_t*
+fgetws(wchar_t* s, int n, Sfio_t* f)
+{
+ register wchar_t* p = s;
+ register wchar_t* e = s + n - 1;
+ register wint_t c;
+
+ STDIO_PTR(f, "fgets", wchar_t*, (wchar_t*, int, Sfio_t*), (s, n, f))
+
+ FWIDE(f, 0);
+ while (p < e && (c = fgetwc(f)) != WEOF && (*p++ = c) != '\n');
+ *p = 0;
+ return s;
+}
+
+wchar_t*
+getws(wchar_t* s)
+{
+ register wchar_t* p = s;
+ register wchar_t* e = s + BUFSIZ - 1;
+ register wint_t c;
+
+ FWIDE(sfstdin, 0);
+ while (p < e && (c = fgetwc(sfstdin)) != WEOF && (*p++ = c) != '\n');
+ *p = 0;
+ return s;
+}
diff --git a/usr/src/lib/libast/common/stdio/fileno.c b/usr/src/lib/libast/common/stdio/fileno.c
new file mode 100644
index 0000000000..ab4eca5b67
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fileno.c
@@ -0,0 +1,42 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+#if !_UWIN
+
+NoN(fileno)
+
+#else
+
+#undef fileno
+
+int
+fileno(Sfio_t* f)
+{
+ STDIO_INT(f, "fileno", int, (Sfio_t*), (f))
+
+ return sffileno(f);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/stdio/fopen.c b/usr/src/lib/libast/common/stdio/fopen.c
new file mode 100644
index 0000000000..c926cee610
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fopen.c
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+Sfio_t*
+fopen(const char* path, const char* mode)
+{
+ return sfopen(NiL, path, mode);
+}
diff --git a/usr/src/lib/libast/common/stdio/fprintf.c b/usr/src/lib/libast/common/stdio/fprintf.c
new file mode 100644
index 0000000000..a1260375b1
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fprintf.c
@@ -0,0 +1,39 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+fprintf(Sfio_t* f, const char* fmt, ...)
+{
+ va_list args;
+ int v;
+
+ va_start(args, fmt);
+
+ STDIO_INT(f, "vfprintf", int, (Sfio_t*, const char*, va_list), (f, fmt, args))
+
+ v = sfvprintf(f, fmt, args);
+ va_end(args);
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/fpurge.c b/usr/src/lib/libast/common/stdio/fpurge.c
new file mode 100644
index 0000000000..96e6118baf
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fpurge.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+fpurge(Sfio_t* f)
+{
+ STDIO_INT(f, "fpurge", int, (Sfio_t*), (f))
+
+ return sfpurge(f);
+}
diff --git a/usr/src/lib/libast/common/stdio/fputc.c b/usr/src/lib/libast/common/stdio/fputc.c
new file mode 100644
index 0000000000..eee99dc127
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fputc.c
@@ -0,0 +1,42 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+#if !_UWIN
+
+NoN(fputc)
+
+#else
+
+#undef fputc
+
+int
+fputc(int c, Sfio_t* f)
+{
+ STDIO_INT(f, "fputc", int, (int, Sfio_t*), (c, f))
+
+ return sfputc(f, c);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/stdio/fputs.c b/usr/src/lib/libast/common/stdio/fputs.c
new file mode 100644
index 0000000000..9ac183531f
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fputs.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+fputs(const char* s, Sfio_t* f)
+{
+ STDIO_INT(f, "fputs", int, (const char*, Sfio_t*), (s, f))
+
+ return sfputr(f, s, -1);
+}
diff --git a/usr/src/lib/libast/common/stdio/fputwc.c b/usr/src/lib/libast/common/stdio/fputwc.c
new file mode 100644
index 0000000000..31745fe836
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fputwc.c
@@ -0,0 +1,33 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+wint_t
+fputwc(wchar_t c, Sfio_t* f)
+{
+ STDIO_INT(f, "fputc", wint_t, (wchar_t, Sfio_t*), (c, f))
+
+ FWIDE(f, WEOF);
+ return (sfwrite(f, &c, sizeof(c)) == sizeof(c)) ? c : WEOF;
+}
diff --git a/usr/src/lib/libast/common/stdio/fputws.c b/usr/src/lib/libast/common/stdio/fputws.c
new file mode 100644
index 0000000000..9b3bf6897a
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fputws.c
@@ -0,0 +1,36 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+fputws(const wchar_t* s, Sfio_t* f)
+{
+ size_t n;
+
+ STDIO_INT(f, "fputws", int, (const wchar_t*, Sfio_t*), (s, f))
+
+ FWIDE(f, WEOF);
+ n = wcslen(s) * sizeof(wchar_t);
+ return (sfwrite(f, s, n) == n) ? 0 : -1;
+}
diff --git a/usr/src/lib/libast/common/stdio/fread.c b/usr/src/lib/libast/common/stdio/fread.c
new file mode 100644
index 0000000000..5ef44d15d8
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fread.c
@@ -0,0 +1,34 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+ssize_t
+fread(void* p, size_t s, size_t n, Sfio_t* f)
+{
+ ssize_t v;
+
+ STDIO_INT(f, "fread", ssize_t, (void*, size_t, size_t, Sfio_t*), (p, s, n, f))
+
+ return ((v = sfread(f, p, s * n)) <= 0) ? 0 : (v / s);
+}
diff --git a/usr/src/lib/libast/common/stdio/freopen.c b/usr/src/lib/libast/common/stdio/freopen.c
new file mode 100644
index 0000000000..d66b8a2bc8
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/freopen.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+Sfio_t*
+freopen(const char* path, const char* mode, Sfio_t* f)
+{
+ STDIO_PTR(f, "freopen", Sfio_t*, (const char*, const char*, Sfio_t*), (path, mode, f))
+
+ return sfopen(f, path, mode);
+}
diff --git a/usr/src/lib/libast/common/stdio/fscanf.c b/usr/src/lib/libast/common/stdio/fscanf.c
new file mode 100644
index 0000000000..50c0f627f7
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fscanf.c
@@ -0,0 +1,39 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+fscanf(Sfio_t* f, const char* fmt, ...)
+{
+ va_list args;
+ int v;
+
+ va_start(args, fmt);
+
+ STDIO_INT(f, "vfscanf", int, (Sfio_t*, const char*, va_list), (f, fmt, args))
+
+ v = sfvscanf(f, fmt, args);
+ va_end(args);
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/fseek.c b/usr/src/lib/libast/common/stdio/fseek.c
new file mode 100644
index 0000000000..952beaf67a
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fseek.c
@@ -0,0 +1,48 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#ifndef _NO_LARGEFILE64_SOURCE
+#define _NO_LARGEFILE64_SOURCE 1
+#endif
+
+#include "stdhdr.h"
+
+int
+fseek(Sfio_t* f, long off, int op)
+{
+ STDIO_INT(f, "fseek", int, (Sfio_t*, long, int), (f, off, op))
+
+ return sfseek(f, (Sfoff_t)off, op|SF_SHARE) >= 0 ? 0 : -1;
+}
+
+#ifdef _typ_int64_t
+
+int
+fseek64(Sfio_t* f, int64_t off, int op)
+{
+ STDIO_INT(f, "fseek64", int, (Sfio_t*, int64_t, int), (f, off, op))
+
+ return sfseek(f, (Sfoff_t)off, op|SF_SHARE) >= 0 ? 0 : -1;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/stdio/fseeko.c b/usr/src/lib/libast/common/stdio/fseeko.c
new file mode 100644
index 0000000000..b6d74272b3
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fseeko.c
@@ -0,0 +1,48 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#ifndef _NO_LARGEFILE64_SOURCE
+#define _NO_LARGEFILE64_SOURCE 1
+#endif
+
+#include "stdhdr.h"
+
+int
+fseeko(Sfio_t* f, off_t off, int op)
+{
+ STDIO_INT(f, "fseeko", int, (Sfio_t*, off_t, int), (f, off, op))
+
+ return sfseek(f, (Sfoff_t)off, op|SF_SHARE) >= 0 ? 0 : -1;
+}
+
+#ifdef _typ_int64_t
+
+int
+fseeko64(Sfio_t* f, int64_t off, int op)
+{
+ STDIO_INT(f, "fseeko64", int, (Sfio_t*, int64_t, int), (f, off, op))
+
+ return sfseek(f, (Sfoff_t)off, op|SF_SHARE) >= 0 ? 0 : -1;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/stdio/fsetpos.c b/usr/src/lib/libast/common/stdio/fsetpos.c
new file mode 100644
index 0000000000..a39f11fa54
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fsetpos.c
@@ -0,0 +1,48 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#ifndef _NO_LARGEFILE64_SOURCE
+#define _NO_LARGEFILE64_SOURCE 1
+#endif
+
+#include "stdhdr.h"
+
+int
+fsetpos(Sfio_t* f, const fpos_t* pos)
+{
+ STDIO_INT(f, "fsetpos", int, (Sfio_t*, const fpos_t*), (f, pos))
+
+ return sfseek(f, (Sfoff_t)pos->_sf_offset, SF_PUBLIC) == (Sfoff_t)pos->_sf_offset ? 0 : -1;
+}
+
+#ifdef _typ_int64_t
+
+int
+fsetpos64(Sfio_t* f, const fpos64_t* pos)
+{
+ STDIO_INT(f, "fsetpos64", int, (Sfio_t*, const fpos64_t*), (f, pos))
+
+ return sfseek(f, (Sfoff_t)pos->_sf_offset, SF_PUBLIC) == (Sfoff_t)pos->_sf_offset ? 0 : -1;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/stdio/ftell.c b/usr/src/lib/libast/common/stdio/ftell.c
new file mode 100644
index 0000000000..665b1f087a
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/ftell.c
@@ -0,0 +1,48 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#ifndef _NO_LARGEFILE64_SOURCE
+#define _NO_LARGEFILE64_SOURCE 1
+#endif
+
+#include "stdhdr.h"
+
+long
+ftell(Sfio_t* f)
+{
+ STDIO_INT(f, "ftell", long, (Sfio_t*), (f))
+
+ return (long)sfseek(f, (Sfoff_t)0, SEEK_CUR);
+}
+
+#if _typ_int64_t
+
+int64_t
+ftell64(Sfio_t* f)
+{
+ STDIO_INT(f, "ftell64", int64_t, (Sfio_t*), (f))
+
+ return (int64_t)sfseek(f, (Sfoff_t)0, SEEK_CUR);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/stdio/ftello.c b/usr/src/lib/libast/common/stdio/ftello.c
new file mode 100644
index 0000000000..b03f182d75
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/ftello.c
@@ -0,0 +1,48 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#ifndef _NO_LARGEFILE64_SOURCE
+#define _NO_LARGEFILE64_SOURCE 1
+#endif
+
+#include "stdhdr.h"
+
+off_t
+ftello(Sfio_t* f)
+{
+ STDIO_INT(f, "ftello", off_t, (Sfio_t*), (f))
+
+ return sfseek(f, (Sfoff_t)0, SEEK_CUR);
+}
+
+#ifdef _typ_int64_t
+
+int64_t
+ftello64(Sfio_t* f)
+{
+ STDIO_INT(f, "ftello64", int64_t, (Sfio_t*), (f))
+
+ return sfseek(f, (Sfoff_t)0, SEEK_CUR) >= 0 ? 0 : -1;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/stdio/fwide.c b/usr/src/lib/libast/common/stdio/fwide.c
new file mode 100644
index 0000000000..a07ec9a196
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fwide.c
@@ -0,0 +1,51 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+fwide(Sfio_t* f, int mode)
+{
+ STDIO_INT(f, "fwide", int, (Sfio_t*, int), (f, mode))
+
+ if (mode > 0)
+ {
+ f->bits &= ~SF_MB;
+ f->bits |= SF_WC;
+ }
+ else if (mode < 0)
+ {
+ f->bits &= ~SF_WC;
+ f->bits |= SF_MB;
+ }
+ if (f->bits & SF_MB)
+ return -1;
+ if (f->bits & SF_WC)
+ return 1;
+ if ((f->flags & SF_SYNCED) || f->next > f->data)
+ {
+ f->bits |= SF_MB;
+ return -1;
+ }
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/stdio/fwprintf.c b/usr/src/lib/libast/common/stdio/fwprintf.c
new file mode 100644
index 0000000000..3573e66678
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fwprintf.c
@@ -0,0 +1,36 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+fwprintf(Sfio_t* f, const wchar_t* fmt, ...)
+{
+ va_list args;
+ int v;
+
+ va_start(args, fmt);
+ v = vfwprintf(f, fmt, args);
+ va_end(args);
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/fwrite.c b/usr/src/lib/libast/common/stdio/fwrite.c
new file mode 100644
index 0000000000..1e7aace404
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fwrite.c
@@ -0,0 +1,34 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+ssize_t
+fwrite(const void* p, size_t s, size_t n, Sfio_t* f)
+{
+ ssize_t v;
+
+ STDIO_INT(f, "fwrite", ssize_t, (const void*, size_t, size_t, Sfio_t*), (p, s, n, f))
+
+ return ((v = sfwrite(f, p, s * n)) <= 0) ? 0 : (v / s);
+}
diff --git a/usr/src/lib/libast/common/stdio/fwscanf.c b/usr/src/lib/libast/common/stdio/fwscanf.c
new file mode 100644
index 0000000000..7ebd2fc4f6
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/fwscanf.c
@@ -0,0 +1,39 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+fwscanf(Sfio_t* f, const wchar_t* fmt, ...)
+{
+ va_list args;
+ int v;
+
+ va_start(args, fmt);
+
+ STDIO_INT(f, "vfwscanf", int, (Sfio_t*, const wchar_t*, va_list), (f, fmt, args))
+
+ v = vfwscanf(f, fmt, args);
+ va_end(args);
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/getc.c b/usr/src/lib/libast/common/stdio/getc.c
new file mode 100644
index 0000000000..901b897859
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/getc.c
@@ -0,0 +1,42 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+#if !_UWIN
+
+NoN(getc)
+
+#else
+
+#undef getc
+
+int
+getc(Sfio_t* f)
+{
+ STDIO_INT(f, "getc", int, (Sfio_t*), (f))
+
+ return sfgetc(f);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/stdio/getchar.c b/usr/src/lib/libast/common/stdio/getchar.c
new file mode 100644
index 0000000000..18e1f2d413
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/getchar.c
@@ -0,0 +1,40 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+#if !_UWIN
+
+NoN(getchar)
+
+#else
+
+#undef getchar
+
+int
+getchar(void)
+{
+ return sfgetc(sfstdin);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/stdio/getw.c b/usr/src/lib/libast/common/stdio/getw.c
new file mode 100644
index 0000000000..e65358a2d8
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/getw.c
@@ -0,0 +1,34 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+getw(Sfio_t* f)
+{
+ int v;
+
+ STDIO_INT(f, "getw", int, (Sfio_t*), (f))
+
+ return sfread(f, &v, sizeof(v)) == sizeof(v) ? v : -1;
+}
diff --git a/usr/src/lib/libast/common/stdio/getwc.c b/usr/src/lib/libast/common/stdio/getwc.c
new file mode 100644
index 0000000000..5cce3c7aa8
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/getwc.c
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+wint_t
+getwc(Sfio_t* f)
+{
+ return fgetwc(f);
+}
diff --git a/usr/src/lib/libast/common/stdio/getwchar.c b/usr/src/lib/libast/common/stdio/getwchar.c
new file mode 100644
index 0000000000..d7ea812b7b
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/getwchar.c
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+wint_t
+getwchar(void)
+{
+ return fgetwc(sfstdin);
+}
diff --git a/usr/src/lib/libast/common/stdio/pclose.c b/usr/src/lib/libast/common/stdio/pclose.c
new file mode 100644
index 0000000000..647bb5ebb6
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/pclose.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+pclose(Sfio_t* f)
+{
+ STDIO_INT(f, "pclose", int, (Sfio_t*), (f))
+
+ return sfclose(f);
+}
diff --git a/usr/src/lib/libast/common/stdio/popen.c b/usr/src/lib/libast/common/stdio/popen.c
new file mode 100644
index 0000000000..47ffc3bb69
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/popen.c
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+Sfio_t*
+popen(const char* cmd, const char* mode)
+{
+ return sfpopen((Sfio_t*)(-1), cmd, mode);
+}
diff --git a/usr/src/lib/libast/common/stdio/printf.c b/usr/src/lib/libast/common/stdio/printf.c
new file mode 100644
index 0000000000..031f3fcda6
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/printf.c
@@ -0,0 +1,36 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+printf(const char* fmt, ...)
+{
+ va_list args;
+ int v;
+
+ va_start(args, fmt);
+ v = sfvprintf(sfstdout, fmt, args);
+ va_end(args);
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/putc.c b/usr/src/lib/libast/common/stdio/putc.c
new file mode 100644
index 0000000000..5b6f3f7f13
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/putc.c
@@ -0,0 +1,42 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+#if !_UWIN
+
+NoN(putc)
+
+#else
+
+#undef putc
+
+int
+putc(int c, Sfio_t* f)
+{
+ STDIO_INT(f, "putc", int, (int, Sfio_t*), (c, f))
+
+ return sfputc(f, c);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/stdio/putchar.c b/usr/src/lib/libast/common/stdio/putchar.c
new file mode 100644
index 0000000000..b318339a45
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/putchar.c
@@ -0,0 +1,40 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+#if !_UWIN
+
+NoN(putchar)
+
+#else
+
+#undef putchar
+
+int
+putchar(int c)
+{
+ return sfputc(sfstdout, c);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/stdio/puts.c b/usr/src/lib/libast/common/stdio/puts.c
new file mode 100644
index 0000000000..95c50464fe
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/puts.c
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+puts(const char* s)
+{
+ return sfputr(sfstdout, s, '\n');
+}
diff --git a/usr/src/lib/libast/common/stdio/putw.c b/usr/src/lib/libast/common/stdio/putw.c
new file mode 100644
index 0000000000..0bb83e0d12
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/putw.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+putw(int v, Sfio_t* f)
+{
+ STDIO_INT(f, "putw", int, (int, Sfio_t*), (v, f))
+
+ return sfwrite(f, &v, sizeof(v)) == sizeof(v) ? 0 : -1;
+}
diff --git a/usr/src/lib/libast/common/stdio/putwc.c b/usr/src/lib/libast/common/stdio/putwc.c
new file mode 100644
index 0000000000..7d3a709886
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/putwc.c
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+wint_t
+putwc(wchar_t c, Sfio_t* f)
+{
+ return fputwc(c, f);
+}
diff --git a/usr/src/lib/libast/common/stdio/putwchar.c b/usr/src/lib/libast/common/stdio/putwchar.c
new file mode 100644
index 0000000000..005cfe62ad
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/putwchar.c
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+wint_t
+putwchar(wchar_t c)
+{
+ return fputwc(c, sfstdout);
+}
diff --git a/usr/src/lib/libast/common/stdio/rewind.c b/usr/src/lib/libast/common/stdio/rewind.c
new file mode 100644
index 0000000000..813594245d
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/rewind.c
@@ -0,0 +1,33 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+void
+rewind(Sfio_t* f)
+{
+ STDIO_VOID(f, "rewind", void, (Sfio_t*), (f))
+
+ sfseek(f, (Sfoff_t)0, SEEK_SET|SF_PUBLIC);
+ sfclrlock(f);
+}
diff --git a/usr/src/lib/libast/common/stdio/scanf.c b/usr/src/lib/libast/common/stdio/scanf.c
new file mode 100644
index 0000000000..69344d4f3a
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/scanf.c
@@ -0,0 +1,36 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+scanf(const char* fmt, ...)
+{
+ va_list args;
+ int v;
+
+ va_start(args, fmt);
+ v = sfvscanf(sfstdin, fmt, args);
+ va_end(args);
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/setbuf.c b/usr/src/lib/libast/common/stdio/setbuf.c
new file mode 100644
index 0000000000..a82142376a
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/setbuf.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+void
+setbuf(Sfio_t* f, char* b)
+{
+ STDIO_VOID(f, "setbuf", void, (Sfio_t*, char*), (f, b))
+
+ sfsetbuf(f, b, b ? BUFSIZ : 0);
+}
diff --git a/usr/src/lib/libast/common/stdio/setbuffer.c b/usr/src/lib/libast/common/stdio/setbuffer.c
new file mode 100644
index 0000000000..09ab19933f
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/setbuffer.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+setbuffer(Sfio_t* f, char* b, int n)
+{
+ STDIO_INT(f, "setbuffer", int, (Sfio_t*, char*, int), (f, b, n))
+
+ return sfsetbuf(f, b, n) ? 0 : -1;
+}
diff --git a/usr/src/lib/libast/common/stdio/setlinebuf.c b/usr/src/lib/libast/common/stdio/setlinebuf.c
new file mode 100644
index 0000000000..e677985a92
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/setlinebuf.c
@@ -0,0 +1,33 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+setlinebuf(Sfio_t* f)
+{
+ STDIO_INT(f, "setlinebuf", int, (Sfio_t*), (f))
+
+ sfset(f, SF_LINE, 1);
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/stdio/setvbuf.c b/usr/src/lib/libast/common/stdio/setvbuf.c
new file mode 100644
index 0000000000..f271557138
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/setvbuf.c
@@ -0,0 +1,48 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+setvbuf(Sfio_t* f, char* buf, int type, size_t size)
+{
+ STDIO_INT(f, "setvbuf", int, (Sfio_t*, char*, int, size_t), (f, buf, type, size))
+
+ if (type == _IOLBF)
+ sfset(f, SF_LINE, 1);
+ else if (f->flags & SF_STRING)
+ return -1;
+ else if (type == _IONBF)
+ {
+ sfsync(f);
+ sfsetbuf(f, NiL, 0);
+ }
+ else if (type == _IOFBF)
+ {
+ if (size == 0)
+ size = SF_BUFSIZE;
+ sfsync(f);
+ sfsetbuf(f, (Void_t*)buf, size);
+ }
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/stdio/snprintf.c b/usr/src/lib/libast/common/stdio/snprintf.c
new file mode 100644
index 0000000000..15092692bd
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/snprintf.c
@@ -0,0 +1,36 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+snprintf(char* s, int n, const char* fmt, ...)
+{
+ va_list args;
+ int v;
+
+ va_start(args, fmt);
+ v = s ? sfvsprintf(s, n, fmt, args) : -1;
+ va_end(args);
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/sprintf.c b/usr/src/lib/libast/common/stdio/sprintf.c
new file mode 100644
index 0000000000..4503b71c0b
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/sprintf.c
@@ -0,0 +1,36 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+sprintf(char* s, const char* fmt, ...)
+{
+ va_list args;
+ int v;
+
+ va_start(args, fmt);
+ v = s ? sfvsprintf(s, INT_MAX, fmt, args) : -1;
+ va_end(args);
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/sscanf.c b/usr/src/lib/libast/common/stdio/sscanf.c
new file mode 100644
index 0000000000..4055b413e9
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/sscanf.c
@@ -0,0 +1,36 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+sscanf(const char* s, const char* fmt, ...)
+{
+ va_list args;
+ int v;
+
+ va_start(args, fmt);
+ v = sfvsscanf(s, fmt, args);
+ va_end(args);
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/stdhdr.h b/usr/src/lib/libast/common/stdio/stdhdr.h
new file mode 100644
index 0000000000..d62ce91955
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/stdhdr.h
@@ -0,0 +1,115 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#ifndef _STDHDR_H
+#define _STDHDR_H 1
+
+#ifndef _NO_LARGEFILE64_SOURCE
+#define _NO_LARGEFILE64_SOURCE 1
+#endif
+#undef _LARGEFILE64_SOURCE
+
+#define _ast_fseeko ______fseeko
+#define _ast_ftello ______ftello
+#include "sfhdr.h"
+#undef _ast_fseeko
+#undef _ast_ftello
+
+#include "stdio.h"
+
+#define SF_MB 010000
+#define SF_WC 020000
+
+#if _UWIN
+
+#define STDIO_TRANSFER 1
+
+typedef int (*Fun_f)();
+
+typedef struct Funvec_s
+{
+ const char* name;
+ Fun_f vec[2];
+} Funvec_t;
+
+extern int _stdfun(Sfio_t*, Funvec_t*);
+
+#define STDIO_INT(p,n,t,f,a) \
+ { \
+ typedef t (*_s_f)f; \
+ int _i; \
+ static Funvec_t _v = { n }; \
+ if ((_i = _stdfun(p, &_v)) < 0) \
+ return -1; \
+ else if (_i > 0) \
+ return ((_s_f)_v.vec[_i])a; \
+ }
+
+#define STDIO_PTR(p,n,t,f,a) \
+ { \
+ typedef t (*_s_f)f; \
+ int _i; \
+ static Funvec_t _v = { n }; \
+ if ((_i = _stdfun(p, &_v)) < 0) \
+ return 0; \
+ else if (_i > 0) \
+ return ((_s_f)_v.vec[_i])a; \
+ }
+
+#define STDIO_VOID(p,n,t,f,a) \
+ { \
+ typedef t (*_s_f)f; \
+ int _i; \
+ static Funvec_t _v = { n }; \
+ if ((_i = _stdfun(p, &_v)) < 0) \
+ return; \
+ else if (_i > 0) \
+ { \
+ ((_s_f)_v.vec[_i])a; \
+ return; \
+ } \
+ }
+
+#else
+
+#define STDIO_INT(p,n,t,f,a)
+#define STDIO_PTR(p,n,t,f,a)
+#define STDIO_VOID(p,n,t,f,a)
+
+#endif
+
+#define FWIDE(f,r) \
+ do \
+ { \
+ if (fwide(f, 0) < 0) \
+ return r; \
+ f->bits |= SF_WC; \
+ } while (0)
+
+#ifdef __EXPORT__
+#define extern __EXPORT__
+#endif
+
+extern int sfdcwide(Sfio_t*);
+
+#endif
diff --git a/usr/src/lib/libast/common/stdio/stdio_c99.c b/usr/src/lib/libast/common/stdio/stdio_c99.c
new file mode 100644
index 0000000000..6fe0d2c409
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/stdio_c99.c
@@ -0,0 +1,118 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * C99 stdio extensions
+ */
+
+#include "stdhdr.h"
+
+void
+clearerr_unlocked(Sfio_t* sp)
+{
+ clearerr(sp);
+}
+
+int
+feof_unlocked(Sfio_t* sp)
+{
+ return feof(sp);
+}
+
+int
+ferror_unlocked(Sfio_t* sp)
+{
+ return ferror(sp);
+}
+
+int
+fflush_unlocked(Sfio_t* sp)
+{
+ return fflush(sp);
+}
+
+int
+fgetc_unlocked(Sfio_t* sp)
+{
+ return fgetc(sp);
+}
+
+char*
+fgets_unlocked(char* buf, int size, Sfio_t* sp)
+{
+ return fgets(buf, size, sp);
+}
+
+int
+fileno_unlocked(Sfio_t* sp)
+{
+ return fileno(sp);
+}
+
+int
+fputc_unlocked(int c, Sfio_t* sp)
+{
+ return fputc(c, sp);
+}
+
+int
+fputs_unlocked(char* buf, Sfio_t* sp)
+{
+ return fputs(buf, sp);
+}
+
+size_t
+fread_unlocked(void* buf, size_t size, size_t n, Sfio_t* sp)
+{
+ return fread(buf, size, n, sp);
+}
+
+size_t
+fwrite_unlocked(void* buf, size_t size, size_t n, Sfio_t* sp)
+{
+ return fwrite(buf, size, n, sp);
+}
+
+int
+getc_unlocked(Sfio_t* sp)
+{
+ return getc(sp);
+}
+
+int
+getchar_unlocked(void)
+{
+ return getchar();
+}
+
+int
+putc_unlocked(int c, Sfio_t* sp)
+{
+ return putc(c, sp);
+}
+
+int
+putchar_unlocked(int c)
+{
+ return putchar(c);
+}
diff --git a/usr/src/lib/libast/common/stdio/stdio_gnu.c b/usr/src/lib/libast/common/stdio/stdio_gnu.c
new file mode 100644
index 0000000000..3db96d6748
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/stdio_gnu.c
@@ -0,0 +1,74 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * gnu stdio extensions
+ */
+
+#include "stdhdr.h"
+
+int
+fcloseall(void)
+{
+ return sfsync(NiL) < 0 ? -1 : 0;
+}
+
+Sfio_t*
+fmemopen(void* buf, size_t size, const char* mode)
+{
+ return sfnew(NiL, buf, size, -1, SF_STRING|_sftype(mode, NiL, NiL));
+}
+
+ssize_t
+__getdelim(char** pbuf, size_t* psize, int del, Sfio_t* sp)
+{
+ char* s;
+ size_t n;
+ size_t m;
+
+ if (!(s = sfgetr(sp, del, 1)))
+ return -1;
+ n = sfsize(sp);
+ m = n + 1;
+ if (!*pbuf || m > *psize)
+ {
+ m = roundof(m, 1024);
+ if (!(*pbuf = newof(*pbuf, char, m, 0)))
+ return -1;
+ *psize = m;
+ }
+ memcpy(*pbuf, s, n);
+ return n;
+}
+
+ssize_t
+getdelim(char** pbuf, size_t* psize, int del, Sfio_t* sp)
+{
+ return __getdelim(pbuf, psize, del, sp);
+}
+
+ssize_t
+getline(char** pbuf, size_t* psize, Sfio_t* sp)
+{
+ return __getdelim(pbuf, psize, '\n', sp);
+}
diff --git a/usr/src/lib/libast/common/stdio/swprintf.c b/usr/src/lib/libast/common/stdio/swprintf.c
new file mode 100644
index 0000000000..93da9590d2
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/swprintf.c
@@ -0,0 +1,36 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+swprintf(wchar_t* s, size_t size, const wchar_t* fmt, ...)
+{
+ va_list args;
+ int v;
+
+ va_start(args, fmt);
+ v = vswprintf(s, size, fmt, args);
+ va_end(args);
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/swscanf.c b/usr/src/lib/libast/common/stdio/swscanf.c
new file mode 100644
index 0000000000..957d2ccebf
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/swscanf.c
@@ -0,0 +1,36 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+swscanf(const wchar_t* s, const wchar_t* fmt, ...)
+{
+ va_list args;
+ int v;
+
+ va_start(args, fmt);
+ v = vswscanf(s, fmt, args);
+ va_end(args);
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/tmpfile.c b/usr/src/lib/libast/common/stdio/tmpfile.c
new file mode 100644
index 0000000000..d07fe0f642
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/tmpfile.c
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+Sfio_t*
+tmpfile(void)
+{
+ return sftmp(0);
+}
diff --git a/usr/src/lib/libast/common/stdio/ungetc.c b/usr/src/lib/libast/common/stdio/ungetc.c
new file mode 100644
index 0000000000..2cc349a44c
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/ungetc.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+ungetc(int c, Sfio_t* f)
+{
+ STDIO_INT(f, "ungetc", int, (int, Sfio_t*), (c, f))
+
+ return sfungetc(f, c);
+}
diff --git a/usr/src/lib/libast/common/stdio/ungetwc.c b/usr/src/lib/libast/common/stdio/ungetwc.c
new file mode 100644
index 0000000000..0b95324f4f
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/ungetwc.c
@@ -0,0 +1,39 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+wint_t
+ungetwc(wint_t c, Sfio_t* f)
+{
+ register unsigned char* s = (unsigned char*)&c;
+ register unsigned char* e = s + sizeof(c);
+
+ STDIO_INT(f, "ungetwc", wint_t, (wint_t, Sfio_t*), (c, f))
+
+ FWIDE(f, WEOF);
+ while (s < e)
+ if (sfungetc(f, *s++) == EOF)
+ return WEOF;
+ return c;
+}
diff --git a/usr/src/lib/libast/common/stdio/vasprintf.c b/usr/src/lib/libast/common/stdio/vasprintf.c
new file mode 100644
index 0000000000..1031f52da4
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/vasprintf.c
@@ -0,0 +1,45 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+vasprintf(char** s, const char* fmt, va_list args)
+{
+ Sfio_t* f;
+ int v;
+
+ if (f = sfstropen())
+ {
+ v = sfvprintf(f, fmt, args);
+ if (!(*s = strdup(sfstruse(f))))
+ v = -1;
+ sfstrclose(f);
+ }
+ else
+ {
+ *s = 0;
+ v = -1;
+ }
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/vfprintf.c b/usr/src/lib/libast/common/stdio/vfprintf.c
new file mode 100644
index 0000000000..768d6f1c7c
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/vfprintf.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+vfprintf(Sfio_t* f, const char* fmt, va_list args)
+{
+ STDIO_INT(f, "vfprintf", int, (Sfio_t*, const char*, va_list), (f, fmt, args))
+
+ return sfvprintf(f, fmt, args);
+}
diff --git a/usr/src/lib/libast/common/stdio/vfscanf.c b/usr/src/lib/libast/common/stdio/vfscanf.c
new file mode 100644
index 0000000000..c458925d7f
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/vfscanf.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+vfscanf(Sfio_t* f, const char* fmt, va_list args)
+{
+ STDIO_INT(f, "vfscanf", int, (Sfio_t*, const char*, va_list), (f, fmt, args))
+
+ return sfvscanf(f, fmt, args);
+}
diff --git a/usr/src/lib/libast/common/stdio/vfwprintf.c b/usr/src/lib/libast/common/stdio/vfwprintf.c
new file mode 100644
index 0000000000..f3b8622bf8
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/vfwprintf.c
@@ -0,0 +1,65 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+vfwprintf(Sfio_t* f, const wchar_t* fmt, va_list args)
+{
+ char* m;
+ char* x;
+ wchar_t*w;
+ size_t n;
+ int v;
+ Sfio_t* t;
+
+ STDIO_INT(f, "vfwprintf", int, (Sfio_t*, const wchar_t*, va_list), (f, fmt, args))
+
+ FWIDE(f, WEOF);
+ n = wcstombs(NiL, fmt, 0);
+ if (m = malloc(n + 1))
+ {
+ if (t = sfstropen())
+ {
+ wcstombs(m, fmt, n + 1);
+ sfvprintf(t, m, args);
+ free(m);
+ if (!(x = sfstruse(t)))
+ v = -1;
+ else
+ {
+ n = mbstowcs(NiL, x, 0);
+ if (w = (wchar_t*)sfreserve(f, n * sizeof(wchar_t) + 1, 0))
+ v = mbstowcs(w, x, n + 1);
+ else
+ v = -1;
+ }
+ sfstrclose(t);
+ }
+ else
+ v = -1;
+ }
+ else
+ v = -1;
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/vfwscanf.c b/usr/src/lib/libast/common/stdio/vfwscanf.c
new file mode 100644
index 0000000000..2bdda90546
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/vfwscanf.c
@@ -0,0 +1,129 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+typedef struct
+{
+ Sfdisc_t sfdisc; /* sfio discipline */
+ Sfio_t* f; /* original wide stream */
+ char fmt[1]; /* mb fmt */
+} Wide_t;
+
+/*
+ * wide exception handler
+ * free on close
+ */
+
+static int
+wideexcept(Sfio_t* f, int op, void* val, Sfdisc_t* dp)
+{
+ if (sffileno(f) >= 0)
+ return -1;
+ switch (op)
+ {
+ case SF_ATEXIT:
+ sfdisc(f, SF_POPDISC);
+ break;
+ case SF_CLOSING:
+ case SF_DPOP:
+ case SF_FINAL:
+ if (op != SF_CLOSING)
+ free(dp);
+ break;
+ }
+ return 0;
+}
+
+/*
+ * sfio wide discipline read
+ * 1 wchar_t at a time
+ * go pure multibyte for best performance
+ */
+
+static ssize_t
+wideread(Sfio_t* f, Void_t* buf, size_t size, Sfdisc_t* dp)
+{
+ register Wide_t* w = (Wide_t*)dp;
+ wchar_t wuf[2];
+
+#if 0
+ if (sfread(w->f, wuf, sizeof(wuf[0])) != sizeof(wuf[0]))
+ return -1;
+ wuf[1] = 0;
+ return wcstombs(buf, wuf, size);
+#else
+ ssize_t r;
+
+ r = sfread(w->f, wuf, sizeof(wuf[0]));
+ if (r != sizeof(wuf[0]))
+ return -1;
+ wuf[1] = 0;
+ r = wcstombs(buf, wuf, size);
+ return r;
+#endif
+}
+
+int
+vfwscanf(Sfio_t* f, const wchar_t* fmt, va_list args)
+{
+ size_t n;
+ int v;
+ Sfio_t* t;
+ Wide_t* w;
+ char buf[1024];
+
+ STDIO_INT(f, "vfwscanf", int, (Sfio_t*, const wchar_t*, va_list), (f, fmt, args))
+
+ FWIDE(f, WEOF);
+ n = wcstombs(NiL, fmt, 0);
+ if (w = newof(0, Wide_t, 1, n))
+ {
+ if (t = sfnew(NiL, buf, sizeof(buf), OPEN_MAX+1, SF_READ))
+ {
+ w->sfdisc.exceptf = wideexcept;
+ w->sfdisc.readf = wideread;
+ w->f = f;
+ if (sfdisc(t, &w->sfdisc) == &w->sfdisc)
+ {
+ wcstombs(w->fmt, fmt, n + 1);
+ v = sfvscanf(t, w->fmt, args);
+ }
+ else
+ {
+ free(w);
+ v = -1;
+ }
+ sfsetfd(t, -1);
+ sfclose(t);
+ }
+ else
+ {
+ free(w);
+ v = -1;
+ }
+ }
+ else
+ v = -1;
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/vprintf.c b/usr/src/lib/libast/common/stdio/vprintf.c
new file mode 100644
index 0000000000..fef547d589
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/vprintf.c
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+vprintf(const char* fmt, va_list args)
+{
+ return sfvprintf(sfstdout, fmt, args);
+}
diff --git a/usr/src/lib/libast/common/stdio/vscanf.c b/usr/src/lib/libast/common/stdio/vscanf.c
new file mode 100644
index 0000000000..468bb0d02b
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/vscanf.c
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+vscanf(const char* fmt, va_list args)
+{
+ return sfvscanf(sfstdin, fmt, args);
+}
diff --git a/usr/src/lib/libast/common/stdio/vsnprintf.c b/usr/src/lib/libast/common/stdio/vsnprintf.c
new file mode 100644
index 0000000000..b551a07a16
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/vsnprintf.c
@@ -0,0 +1,55 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+vsnprintf(char* s, int n, const char* fmt, va_list args)
+{
+ Sfio_t f;
+ int v;
+
+ if (!s)
+ return -1;
+
+ /*
+ * make a fake stream
+ */
+
+ SFCLEAR(&f, NiL);
+ f.flags = SF_STRING|SF_WRITE;
+ f.bits = SF_PRIVATE;
+ f.mode = SF_WRITE;
+ f.size = n - 1;
+ f.data = f.next = f.endr = (uchar*)s;
+ f.endb = f.endw = f.data + f.size;
+
+ /*
+ * call and fix up
+ */
+
+ v = sfvprintf(&f, fmt, args);
+ *f.next = 0;
+ _Sfi = f.next - f.data;
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/vsprintf.c b/usr/src/lib/libast/common/stdio/vsprintf.c
new file mode 100644
index 0000000000..f47d75a6e0
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/vsprintf.c
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+vsprintf(char* s, const char* fmt, va_list args)
+{
+ return vsnprintf(s, 4 * SF_BUFSIZE, fmt, args);
+}
diff --git a/usr/src/lib/libast/common/stdio/vsscanf.c b/usr/src/lib/libast/common/stdio/vsscanf.c
new file mode 100644
index 0000000000..5815aacb31
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/vsscanf.c
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+vsscanf(const char* s, const char* fmt, va_list args)
+{
+ return sfvsscanf(s, fmt, args);
+}
diff --git a/usr/src/lib/libast/common/stdio/vswprintf.c b/usr/src/lib/libast/common/stdio/vswprintf.c
new file mode 100644
index 0000000000..47fc724bd6
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/vswprintf.c
@@ -0,0 +1,55 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+vswprintf(wchar_t* s, size_t n, const wchar_t* fmt, va_list args)
+{
+ Sfio_t f;
+ int v;
+
+ if (!s)
+ return -1;
+
+ /*
+ * make a fake stream
+ */
+
+ SFCLEAR(&f, NiL);
+ f.flags = SF_STRING|SF_WRITE;
+ f.bits = SF_PRIVATE;
+ f.mode = SF_WRITE;
+ f.size = n - 1;
+ f.data = f.next = f.endr = (uchar*)s;
+ f.endb = f.endw = f.data + f.size;
+
+ /*
+ * call and adjust
+ */
+
+ v = vfwprintf(&f, fmt, args);
+ *f.next = 0;
+ _Sfi = f.next - f.data;
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/vswscanf.c b/usr/src/lib/libast/common/stdio/vswscanf.c
new file mode 100644
index 0000000000..9458930b93
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/vswscanf.c
@@ -0,0 +1,51 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+vswscanf(const wchar_t* s, const wchar_t* fmt, va_list args)
+{
+ Sfio_t f;
+
+ if (!s)
+ return -1;
+
+ /*
+ * make a fake stream
+ */
+
+ SFCLEAR(&f, NiL);
+ f.flags = SF_STRING|SF_READ;
+ f.bits = SF_PRIVATE;
+ f.mode = SF_READ;
+ f.size = wcslen(s) * sizeof(wchar_t);
+ f.data = f.next = f.endw = (uchar*)s;
+ f.endb = f.endr = f.data + f.size;
+
+ /*
+ * sfio does the rest
+ */
+
+ return vfwscanf(&f, fmt, args);
+}
diff --git a/usr/src/lib/libast/common/stdio/vwprintf.c b/usr/src/lib/libast/common/stdio/vwprintf.c
new file mode 100644
index 0000000000..68dec6c7b9
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/vwprintf.c
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+vwprintf(const wchar_t* fmt, va_list args)
+{
+ return vfwprintf(sfstdout, fmt, args);
+}
diff --git a/usr/src/lib/libast/common/stdio/vwscanf.c b/usr/src/lib/libast/common/stdio/vwscanf.c
new file mode 100644
index 0000000000..ba58fb38b4
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/vwscanf.c
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+vwscanf(const wchar_t* fmt, va_list args)
+{
+ return vfwscanf(sfstdin, fmt, args);
+}
diff --git a/usr/src/lib/libast/common/stdio/wprintf.c b/usr/src/lib/libast/common/stdio/wprintf.c
new file mode 100644
index 0000000000..d710c83d34
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/wprintf.c
@@ -0,0 +1,36 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+wprintf(const wchar_t* fmt, ...)
+{
+ va_list args;
+ int v;
+
+ va_start(args, fmt);
+ v = vfwprintf(sfstdout, fmt, args);
+ va_end(args);
+ return v;
+}
diff --git a/usr/src/lib/libast/common/stdio/wscanf.c b/usr/src/lib/libast/common/stdio/wscanf.c
new file mode 100644
index 0000000000..985af725af
--- /dev/null
+++ b/usr/src/lib/libast/common/stdio/wscanf.c
@@ -0,0 +1,36 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "stdhdr.h"
+
+int
+wscanf(const wchar_t* fmt, ...)
+{
+ va_list args;
+ int v;
+
+ va_start(args, fmt);
+ v = vfwscanf(sfstdin, fmt, args);
+ va_end(args);
+ return v;
+}
diff --git a/usr/src/lib/libast/common/string/base64.c b/usr/src/lib/libast/common/string/base64.c
new file mode 100644
index 0000000000..407213cba4
--- /dev/null
+++ b/usr/src/lib/libast/common/string/base64.c
@@ -0,0 +1,302 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * mime base64 encode/decode
+ *
+ * Glenn Fowler
+ * David Korn
+ * AT&T Research
+ */
+
+#include <ast.h>
+
+#define PAD '='
+
+#define B64_UC 3
+#define B64_EC 4
+#define B64_CHUNK 15
+#define B64_PAD 64
+#define B64_SPC 65
+#define B64_IGN 66
+
+static unsigned char map[UCHAR_MAX+1];
+
+static const char alp[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+/*
+ * mime base64 encode
+ */
+
+ssize_t
+base64encode(const void* fb, size_t fz, void** fn, void* tb, size_t tz, void** tn)
+{
+ register unsigned char* fp;
+ register unsigned char* tp;
+ register unsigned char* fe;
+ register unsigned char* te;
+ register unsigned char* tc;
+ register unsigned char* m;
+ register unsigned long b;
+ size_t n;
+ unsigned char tmp[B64_EC * B64_CHUNK];
+
+ m = (unsigned char*)alp;
+ fp = fe = (unsigned char*)fb;
+ if (fz >= 3)
+ {
+ n = fz % 3;
+ fe += fz - n;
+ fz = n;
+ }
+ if (tp = (unsigned char*)tb)
+ {
+ te = tp + tz - B64_EC + 1;
+ n = 0;
+ }
+ else
+ {
+ if (fn)
+ *fn = fp;
+ if (tn)
+ *tn = 0;
+ tp = tmp;
+ te = tp + sizeof(tmp) - B64_EC + 1;
+ n = 1;
+ }
+ for (;;)
+ {
+ tc = tp + B64_EC * B64_CHUNK;
+ do
+ {
+ if (fp >= fe)
+ goto done;
+ if (tp >= te)
+ {
+ if (fn)
+ *fn = fp;
+ if (tn)
+ *tn = tp;
+ n = tp - (unsigned char*)tb + 1;
+ tp = tmp;
+ te = tp + sizeof(tmp) - B64_EC + 1;
+ }
+ b = *fp++ << 16;
+ b |= *fp++ << 8;
+ b |= *fp++;
+ *tp++ = m[b >> 18];
+ *tp++ = m[(b >> 12) & 077];
+ *tp++ = m[(b >> 6) & 077];
+ *tp++ = m[b & 077];
+ } while (tp < tc);
+ if (n)
+ {
+ n += tp - tmp + (fp < fe);
+ tp = tmp;
+ }
+ else
+ *tp++ = '\n';
+ }
+ done:
+ if (fz)
+ {
+ b = *fp++ << 16;
+ if (fz == 2)
+ b |= *fp++ << 8;
+ *tp++ = m[b >> 18];
+ *tp++ = m[(b >> 12) & 077];
+ *tp++ = (fz == 2) ? m[(b >> 6) & 077] : PAD;
+ *tp++ = PAD;
+ }
+ if (n)
+ n += (tp - tmp) - 1;
+ else
+ {
+ if (tp > (unsigned char*)tb && *(tp - 1) == '\n')
+ tp--;
+ if (tp < te)
+ *tp = 0;
+ n = tp - (unsigned char*)tb;
+ if (tn)
+ *tn = tp;
+ if (fn)
+ *fn = fp;
+ }
+ return n;
+}
+
+/*
+ * mime base64 decode
+ */
+
+ssize_t
+base64decode(const void* fb, size_t fz, void** fn, void* tb, size_t tz, void** tn)
+{
+ register unsigned char* fp;
+ register unsigned char* tp;
+ register unsigned char* fe;
+ register unsigned char* te;
+ register unsigned char* tx;
+ register unsigned char* m;
+ register int c;
+ register int state;
+ register unsigned long v;
+ unsigned char* fc;
+ ssize_t n;
+
+ if (!(m = map)[0])
+ {
+ memset(m, B64_IGN, sizeof(map));
+ for (tp = (unsigned char*)alp; c = *tp; tp++)
+ m[c] = tp - (unsigned char*)alp;
+ m[PAD] = B64_PAD;
+ m[' '] = m['\t'] = m['\n'] = B64_SPC;
+ }
+ fp = (unsigned char*)fb;
+ fe = fp + fz;
+ if (tp = (unsigned char*)tb)
+ {
+ te = tp + tz;
+ if (tz > 2)
+ tz = 2;
+ tx = te - tz;
+ n = 0;
+ }
+ else
+ {
+ te = tx = tp;
+ n = 1;
+ }
+ for (;;)
+ {
+ fc = fp;
+ state = 0;
+ v = 0;
+ while (fp < fe)
+ {
+ if ((c = m[*fp++]) < 64)
+ {
+ v = (v << 6) | c;
+ if (++state == 4)
+ {
+ if (tp >= tx)
+ {
+ if (n)
+ n += 3;
+ else
+ {
+ n = tp - (unsigned char*)tb + 4;
+ if (tp < te)
+ {
+ *tp++ = (v >> 16);
+ if (tp < te)
+ {
+ *tp++ = (v >> 8);
+ if (tp < te)
+ *tp++ = (v);
+ }
+ }
+ if (tn)
+ *tn = tp;
+ if (fn)
+ *fn = fc;
+ }
+ }
+ else
+ {
+ *tp++ = (v >> 16);
+ *tp++ = (v >> 8);
+ *tp++ = (v);
+ }
+ fc = fp;
+ state = 0;
+ v = 0;
+ }
+ }
+ else if (c == B64_PAD)
+ break;
+ }
+ switch (state)
+ {
+ case 0:
+ goto done;
+ case 2:
+ if (tp < te)
+ *tp++ = v >> 4;
+ else if (n)
+ n++;
+ else
+ {
+ n = tp - (unsigned char*)tb + 2;
+ if (tn)
+ *tn = tp;
+ if (fn)
+ *fn = fc;
+ }
+ break;
+ case 3:
+ if (tp < te)
+ {
+ *tp++ = v >> 10;
+ if (tp < te)
+ *tp++ = v >> 2;
+ else
+ {
+ n = tp - (unsigned char*)tb + 2;
+ if (tn)
+ *tn = tp;
+ if (fn)
+ *fn = fc;
+ }
+ }
+ else if (n)
+ n += 2;
+ else
+ {
+ n = tp - (unsigned char*)tb + 3;
+ if (tn)
+ *tn = tp;
+ if (fn)
+ *fn = fc;
+ }
+ break;
+ }
+ while (fp < fe && ((c = m[*fp++]) == B64_PAD || c == B64_SPC));
+ if (fp >= fe || c >= 64)
+ break;
+ fp--;
+ }
+ done:
+ if (n)
+ n--;
+ else
+ {
+ if (tp < te)
+ *tp = 0;
+ n = tp - (unsigned char*)tb;
+ if (fn)
+ *fn = fp;
+ if (tn)
+ *tn = tp;
+ }
+ return n;
+}
diff --git a/usr/src/lib/libast/common/string/ccmap.c b/usr/src/lib/libast/common/string/ccmap.c
new file mode 100644
index 0000000000..aae6d9ee83
--- /dev/null
+++ b/usr/src/lib/libast/common/string/ccmap.c
@@ -0,0 +1,746 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * dynamic single byte character code maps
+ */
+
+#include <ast.h>
+#include <ccode.h>
+
+#if !GENERATE
+
+/*
+ * catenated CC_ASCII to CC_* character code map table
+ * order determined by CC_* index definitions
+ * old definition values/indices must not change!
+ * each table is followed by its inverse
+ */
+
+static const unsigned char tab[] =
+{
+
+ /* ascii => ascii */
+
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
+ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
+ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
+ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
+
+ /* ascii => ascii */
+
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
+ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
+ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
+ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
+
+ /* ascii => ebcdic */
+
+ 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f,
+ 0x16, 0x05, 0x25, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26,
+ 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d,
+ 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61,
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f,
+ 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
+ 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
+ 0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x9a, 0x6d,
+ 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
+ 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
+ 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0x5f, 0x07,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x1b,
+ 0x30, 0x31, 0x1a, 0x33, 0x34, 0x35, 0x36, 0x08,
+ 0x38, 0x39, 0x3a, 0x3b, 0x04, 0x14, 0x3e, 0xe1,
+ 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
+ 0x49, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
+ 0x58, 0x59, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75,
+ 0x76, 0x77, 0x78, 0x80, 0x8a, 0x8b, 0x8c, 0x8d,
+ 0x8e, 0x8f, 0x90, 0x6a, 0x9b, 0x9c, 0x9d, 0x9e,
+ 0x9f, 0xa0, 0xaa, 0xab, 0xac, 0x4a, 0xae, 0xaf,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xa1, 0xbe, 0xbf,
+ 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xda, 0xdb,
+ 0xdc, 0xdd, 0xde, 0xdf, 0xea, 0xeb, 0xec, 0xed,
+ 0xee, 0xef, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
+
+ /* ebcdic => ascii */
+
+ 0x00, 0x01, 0x02, 0x03, 0x9c, 0x09, 0x86, 0x7f,
+ 0x97, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x9d, 0x85, 0x08, 0x87,
+ 0x18, 0x19, 0x92, 0x8f, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x0a, 0x17, 0x1b,
+ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07,
+ 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
+ 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a,
+ 0x20, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
+ 0xa7, 0xa8, 0xd5, 0x2e, 0x3c, 0x28, 0x2b, 0x7c,
+ 0x26, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+ 0xb0, 0xb1, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x7e,
+ 0x2d, 0x2f, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+ 0xb8, 0xb9, 0xcb, 0x2c, 0x25, 0x5f, 0x3e, 0x3f,
+ 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1,
+ 0xc2, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22,
+ 0xc3, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9,
+ 0xca, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
+ 0x71, 0x72, 0x5e, 0xcc, 0xcd, 0xce, 0xcf, 0xd0,
+ 0xd1, 0xe5, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
+ 0x79, 0x7a, 0xd2, 0xd3, 0xd4, 0x5b, 0xd6, 0xd7,
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0x5d, 0xe6, 0xe7,
+ 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed,
+ 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
+ 0x51, 0x52, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3,
+ 0x5c, 0x9f, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+ 0x59, 0x5a, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
+
+ /* ascii => ebcdic-i */
+
+ 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f,
+ 0x16, 0x05, 0x25, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26,
+ 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d,
+ 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61,
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f,
+ 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
+ 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
+ 0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d,
+ 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
+ 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
+ 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x1b,
+ 0x30, 0x31, 0x1a, 0x33, 0x34, 0x35, 0x36, 0x08,
+ 0x38, 0x39, 0x3a, 0x3b, 0x04, 0x14, 0x3e, 0xe1,
+ 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
+ 0x49, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
+ 0x58, 0x59, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75,
+ 0x76, 0x77, 0x78, 0x80, 0x8a, 0x8b, 0x8c, 0x8d,
+ 0x8e, 0x8f, 0x90, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e,
+ 0x9f, 0xa0, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+ 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xda, 0xdb,
+ 0xdc, 0xdd, 0xde, 0xdf, 0xea, 0xeb, 0xec, 0xed,
+ 0xee, 0xef, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
+
+ /* ebcdic-i => ascii */
+
+ 0x00, 0x01, 0x02, 0x03, 0x9c, 0x09, 0x86, 0x7f,
+ 0x97, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x9d, 0x85, 0x08, 0x87,
+ 0x18, 0x19, 0x92, 0x8f, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x0a, 0x17, 0x1b,
+ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07,
+ 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
+ 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a,
+ 0x20, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
+ 0xa7, 0xa8, 0x4a, 0x2e, 0x3c, 0x28, 0x2b, 0x7c,
+ 0x26, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+ 0xb0, 0xb1, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x5e,
+ 0x2d, 0x2f, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+ 0xb8, 0xb9, 0x6a, 0x2c, 0x25, 0x5f, 0x3e, 0x3f,
+ 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1,
+ 0xc2, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22,
+ 0xc3, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9,
+ 0xca, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
+ 0x71, 0x72, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0,
+ 0xd1, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
+ 0x79, 0x7a, 0xd2, 0xd3, 0xd4, 0x5b, 0xd6, 0xd7,
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0x5d, 0xe6, 0xe7,
+ 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed,
+ 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
+ 0x51, 0x52, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3,
+ 0x5c, 0x9f, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+ 0x59, 0x5a, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
+
+ /* ascii => ebcdic-o */
+
+ 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f,
+ 0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26,
+ 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d,
+ 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61,
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f,
+ 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
+ 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
+ 0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d,
+ 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
+ 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
+ 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x06, 0x17,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x1b,
+ 0x30, 0x31, 0x1a, 0x33, 0x34, 0x35, 0x36, 0x08,
+ 0x38, 0x39, 0x3a, 0x3b, 0x04, 0x14, 0x3e, 0xff,
+ 0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5,
+ 0xbb, 0xb4, 0x9a, 0x8a, 0xb0, 0xca, 0xaf, 0xbc,
+ 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3,
+ 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab,
+ 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68,
+ 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77,
+ 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf,
+ 0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xba, 0xae, 0x59,
+ 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48,
+ 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57,
+ 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1,
+ 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf,
+
+ /* ebcdic-o => ascii */
+
+ 0x00, 0x01, 0x02, 0x03, 0x9c, 0x09, 0x86, 0x7f,
+ 0x97, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x9d, 0x0a, 0x08, 0x87,
+ 0x18, 0x19, 0x92, 0x8f, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x17, 0x1b,
+ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07,
+ 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
+ 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a,
+ 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
+ 0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c,
+ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
+ 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x5e,
+ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
+ 0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f,
+ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
+ 0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22,
+ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1,
+ 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
+ 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4,
+ 0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
+ 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0x5b, 0xde, 0xae,
+ 0xac, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
+ 0xbd, 0xbe, 0xdd, 0xa8, 0xaf, 0x5d, 0xb4, 0xd7,
+ 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5,
+ 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
+ 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff,
+ 0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+ 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x9f,
+
+ /* ascii => ebcdic-s */
+
+ 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f,
+ 0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26,
+ 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d,
+ 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61,
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f,
+ 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
+ 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
+ 0xe7, 0xe8, 0xe9, 0xbb, 0xbc, 0xbd, 0x6a, 0x6d,
+ 0x4a, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
+ 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
+ 0xa7, 0xa8, 0xa9, 0xfb, 0x4f, 0xfd, 0xff, 0x07,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x06, 0x17,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x1b,
+ 0x30, 0x31, 0x1a, 0x33, 0x34, 0x35, 0x36, 0x08,
+ 0x38, 0x39, 0x3a, 0x3b, 0x04, 0x14, 0x3e, 0x5f,
+ 0x41, 0xaa, 0xb0, 0xb1, 0x9f, 0xb2, 0xd0, 0xb5,
+ 0x79, 0xb4, 0x9a, 0x8a, 0xba, 0xca, 0xaf, 0xa1,
+ 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3,
+ 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab,
+ 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68,
+ 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77,
+ 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf,
+ 0x80, 0xe0, 0xfe, 0xdd, 0xfc, 0xad, 0xae, 0x59,
+ 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48,
+ 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57,
+ 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1,
+ 0x70, 0xc0, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf,
+
+ /* ebcdic-s => ascii */
+
+ 0x00, 0x01, 0x02, 0x03, 0x9c, 0x09, 0x86, 0x7f,
+ 0x97, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x9d, 0x0a, 0x08, 0x87,
+ 0x18, 0x19, 0x92, 0x8f, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x17, 0x1b,
+ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07,
+ 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
+ 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a,
+ 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
+ 0xe7, 0xf1, 0x60, 0x2e, 0x3c, 0x28, 0x2b, 0x7c,
+ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
+ 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x9f,
+ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
+ 0xc7, 0xd1, 0x5e, 0x2c, 0x25, 0x5f, 0x3e, 0x3f,
+ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
+ 0xcc, 0xa8, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22,
+ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1,
+ 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
+ 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4,
+ 0xb5, 0xaf, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
+ 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae,
+ 0xa2, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
+ 0xbd, 0xbe, 0xac, 0x5b, 0x5c, 0x5d, 0xb4, 0xd7,
+ 0xf9, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5,
+ 0xa6, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
+ 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xdb, 0xfa, 0xff,
+ 0xd9, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+ 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0xb3, 0x7b, 0xdc, 0x7d, 0xda, 0x7e,
+
+ /* ascii => ebcdic-h */
+
+ 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f,
+ 0x16, 0x05, 0x25, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26,
+ 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d,
+ 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61,
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f,
+ 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
+ 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
+ 0xe7, 0xe8, 0xe9, 0xba, 0xe0, 0xbb, 0xb0, 0x6d,
+ 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
+ 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
+ 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x1b,
+ 0x30, 0x31, 0x1a, 0x33, 0x34, 0x35, 0x36, 0x08,
+ 0x38, 0x39, 0x3a, 0x3b, 0x04, 0x14, 0x3e, 0xff,
+ 0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5,
+ 0xbd, 0xb4, 0x9a, 0x8a, 0x5f, 0xca, 0xaf, 0xbc,
+ 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3,
+ 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab,
+ 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68,
+ 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77,
+ 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf,
+ 0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xad, 0xae, 0x59,
+ 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48,
+ 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57,
+ 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1,
+ 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf,
+
+ /* ebcdic-h => ascii */
+
+ 0x00, 0x01, 0x02, 0x03, 0x9c, 0x09, 0x86, 0x7f,
+ 0x97, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x9d, 0x85, 0x08, 0x87,
+ 0x18, 0x19, 0x92, 0x8f, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x0a, 0x17, 0x1b,
+ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07,
+ 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
+ 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a,
+ 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
+ 0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c,
+ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
+ 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0xac,
+ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
+ 0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f,
+ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
+ 0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22,
+ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1,
+ 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
+ 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4,
+ 0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
+ 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae,
+ 0x5e, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
+ 0xbd, 0xbe, 0x5b, 0x5d, 0xaf, 0xa8, 0xb4, 0xd7,
+ 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5,
+ 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
+ 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff,
+ 0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+ 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x9f,
+
+ /* ascii => ebcdic-m */
+
+ 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f,
+ 0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26,
+ 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d,
+ 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61,
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f,
+ 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
+ 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
+ 0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d,
+ 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
+ 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
+ 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x06, 0x17,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x1b,
+ 0x30, 0x31, 0x1a, 0x33, 0x34, 0x35, 0x36, 0x08,
+ 0x38, 0x39, 0x3a, 0x3b, 0x04, 0x14, 0x3e, 0xdf,
+ 0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5,
+ 0xbb, 0xb4, 0x9a, 0x8a, 0xb0, 0xca, 0xaf, 0xbc,
+ 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3,
+ 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab,
+ 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68,
+ 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77,
+ 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf,
+ 0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xba, 0xae, 0x59,
+ 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48,
+ 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57,
+ 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1,
+ 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xff,
+
+ /* ebcdic-m => ascii */
+
+ 0x00, 0x01, 0x02, 0x03, 0x9c, 0x09, 0x86, 0x7f,
+ 0x97, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x9d, 0x0a, 0x08, 0x87,
+ 0x18, 0x19, 0x92, 0x8f, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x17, 0x1b,
+ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07,
+ 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
+ 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a,
+ 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
+ 0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c,
+ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
+ 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x5e,
+ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
+ 0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f,
+ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
+ 0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22,
+ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1,
+ 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
+ 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4,
+ 0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
+ 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0x5b, 0xde, 0xae,
+ 0xac, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
+ 0xbd, 0xbe, 0xdd, 0xa8, 0xaf, 0x5d, 0xb4, 0xd7,
+ 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5,
+ 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
+ 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0x9f,
+ 0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+ 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0xff,
+
+ /* ascii => ebcdic-u */
+
+ 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f,
+ 0x16, 0x05, 0x25, 0x0b, 0x0c, 0x0d, 0x0e, 0x9f,
+ 0x10, 0x11, 0x12, 0x13, 0xb6, 0xb5, 0x32, 0x26,
+ 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d,
+ 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61,
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f,
+ 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
+ 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
+ 0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d,
+ 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
+ 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
+ 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07,
+ 0x68, 0xdc, 0x51, 0x42, 0x43, 0x44, 0x47, 0x48,
+ 0x52, 0x53, 0x54, 0x57, 0x56, 0x58, 0x63, 0x67,
+ 0x71, 0x9c, 0x9e, 0xcb, 0xcc, 0xcd, 0xdb, 0xdd,
+ 0xdf, 0xec, 0xfc, 0xb0, 0xb1, 0xb2, 0x3e, 0xb4,
+ 0x45, 0x55, 0xce, 0xde, 0x49, 0x69, 0x9a, 0x9b,
+ 0xab, 0x0f, 0xba, 0xb8, 0xb7, 0xaa, 0x8a, 0x8b,
+ 0x3c, 0x3d, 0x62, 0x6a, 0x64, 0x65, 0x66, 0x20,
+ 0x21, 0x22, 0x70, 0x23, 0x72, 0x73, 0x74, 0xbe,
+ 0x76, 0x77, 0x78, 0x80, 0x24, 0x15, 0x8c, 0x8d,
+ 0x8e, 0x41, 0x06, 0x17, 0x28, 0x29, 0x9d, 0x2a,
+ 0x2b, 0x2c, 0x09, 0x0a, 0xac, 0x4a, 0xae, 0xaf,
+ 0x1b, 0x30, 0x31, 0xfa, 0x1a, 0x33, 0x34, 0x35,
+ 0x36, 0x59, 0x08, 0x38, 0xbc, 0x39, 0xa0, 0xbf,
+ 0xca, 0x3a, 0xfe, 0x3b, 0x04, 0xcf, 0xda, 0x14,
+ 0xe1, 0x8f, 0x46, 0x75, 0xfd, 0xeb, 0xee, 0xed,
+ 0x90, 0xef, 0xb3, 0xfb, 0xb9, 0xea, 0xbb, 0xff,
+
+ /* ebcdic-u => ascii */
+
+ 0x00, 0x01, 0x02, 0x03, 0xec, 0x09, 0xca, 0x7f,
+ 0xe2, 0xd2, 0xd3, 0x0b, 0x0c, 0x0d, 0x0e, 0xa9,
+ 0x10, 0x11, 0x12, 0x13, 0xef, 0xc5, 0x08, 0xcb,
+ 0x18, 0x19, 0xdc, 0xd8, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0xb7, 0xb8, 0xb9, 0xbb, 0xc4, 0x0a, 0x17, 0x1b,
+ 0xcc, 0xcd, 0xcf, 0xd0, 0xd1, 0x05, 0x06, 0x07,
+ 0xd9, 0xda, 0x16, 0xdd, 0xde, 0xdf, 0xe0, 0x04,
+ 0xe3, 0xe5, 0xe9, 0xeb, 0xb0, 0xb1, 0x9e, 0x1a,
+ 0x20, 0xc9, 0x83, 0x84, 0x85, 0xa0, 0xf2, 0x86,
+ 0x87, 0xa4, 0xd5, 0x2e, 0x3c, 0x28, 0x2b, 0x7c,
+ 0x26, 0x82, 0x88, 0x89, 0x8a, 0xa1, 0x8c, 0x8b,
+ 0x8d, 0xe1, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x5e,
+ 0x2d, 0x2f, 0xb2, 0x8e, 0xb4, 0xb5, 0xb6, 0x8f,
+ 0x80, 0xa5, 0xb3, 0x2c, 0x25, 0x5f, 0x3e, 0x3f,
+ 0xba, 0x90, 0xbc, 0xbd, 0xbe, 0xf3, 0xc0, 0xc1,
+ 0xc2, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22,
+ 0xc3, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0xae, 0xaf, 0xc6, 0xc7, 0xc8, 0xf1,
+ 0xf8, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
+ 0x71, 0x72, 0xa6, 0xa7, 0x91, 0xce, 0x92, 0x0f,
+ 0xe6, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
+ 0x79, 0x7a, 0xad, 0xa8, 0xd4, 0x5b, 0xd6, 0xd7,
+ 0x9b, 0x9c, 0x9d, 0xfa, 0x9f, 0x15, 0x14, 0xac,
+ 0xab, 0xfc, 0xaa, 0xfe, 0xe4, 0x5d, 0xbf, 0xe7,
+ 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0xe8, 0x93, 0x94, 0x95, 0xa2, 0xed,
+ 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
+ 0x51, 0x52, 0xee, 0x96, 0x81, 0x97, 0xa3, 0x98,
+ 0x5c, 0xf0, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+ 0x59, 0x5a, 0xfd, 0xf5, 0x99, 0xf7, 0xf6, 0xf9,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0xdb, 0xfb, 0x9a, 0xf4, 0xea, 0xff,
+
+};
+
+#define MAP 256
+#define MAPS (sizeof(tab)/MAP)
+
+struct Map_s; typedef struct Map_s Map_t;
+
+struct Map_s
+{
+ Map_t* next;
+ int op;
+ unsigned char map[MAP];
+};
+
+static Map_t* maps;
+
+/*
+ * generate and return ccode map from i to o
+ */
+
+unsigned char*
+_ccmap(int i, int o)
+{
+ register unsigned char* a;
+ register unsigned char* m;
+ register unsigned char* z;
+ register Map_t* map;
+ register int n;
+ int op;
+
+ if (!i && !o)
+ return (unsigned char*)tab;
+ if (CCCONVERT(i))
+ {
+ o = CCOUT(i);
+ i = CCIN(i);
+ }
+ else if (CCCONVERT(o))
+ {
+ i = CCIN(o);
+ o = CCOUT(o);
+ }
+ else
+ {
+ if (i == 0)
+ i = CC_NATIVE;
+ if (o == 0)
+ o = CC_NATIVE;
+ }
+ if (i == o || i < 1 || i > MAPS || o < 1 || o > MAPS)
+ return 0;
+ if (i == CC_ASCII)
+ return (unsigned char*)tab + MAP * (2 * (o - 1));
+ if (o == CC_ASCII)
+ return (unsigned char*)tab + MAP * (2 * (i - 1) + 1);
+ op = CCOP(i, o);
+ for (map = maps; map; map = map->next)
+ if (map->op == op)
+ return map->map;
+ if (!(map = newof(0, Map_t, 1, 0)))
+ return 0;
+ map->op = op;
+ a = (unsigned char*)tab + MAP * (2 * (o - 1));
+ z = (unsigned char*)tab + MAP * (2 * (i - 1) + 1);
+ m = map->map;
+ for (n = 0; n < MAP; n++)
+ m[n] = n;
+ for (n = MAP - 1; n >= 0; n--)
+ m[n] = a[z[n]];
+ map->next = maps;
+ maps = map;
+ return m;
+}
+
+void*
+_ccmapcpy(register unsigned char* m, void* b, const void* a, size_t n)
+{
+ register unsigned char* ub;
+ register unsigned char* ue;
+ register unsigned char* ua;
+
+ if (m)
+ {
+ ub = (unsigned char*)b;
+ ue = ub + n;
+ ua = (unsigned char*)a;
+ while (ub < ue)
+ *ub++ = m[*ua++];
+ }
+ else
+ memcpy(b, a, n);
+ return b;
+}
+
+void*
+_ccmapstr(register unsigned char* m, void* b, size_t n)
+{
+ register unsigned char* s;
+ register unsigned char* e;
+
+ if (m)
+ for (e = (s = (unsigned char*)b) + n; s < e; s++)
+ *s = m[*s];
+ return b;
+}
+
+#else
+
+static void
+dump(int from, int to)
+{
+ register const unsigned char* m;
+ register int c;
+ register int i;
+
+ m = ccmap(from, to);
+ sfprintf(sfstdout, "\n /* %s => %s */\n\n", ccmapname(from), ccmapname(to));
+ for (c = i = 0; c <= UCHAR_MAX; c++)
+ {
+ sfprintf(sfstdout, " 0x%02x,", m ? m[c] : c);
+ if (!(++i & 0x7))
+ {
+ i = 0;
+ sfprintf(sfstdout, "\n");
+ }
+ }
+}
+
+main(int argc, char** argv)
+{
+ register int i;
+
+ for (i = 1; i <= CC_MAPS; i++)
+ {
+ dump(CC_ASCII, i);
+ dump(i, CC_ASCII);
+ }
+ return 0;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/string/ccmapid.c b/usr/src/lib/libast/common/string/ccmapid.c
new file mode 100644
index 0000000000..946a283013
--- /dev/null
+++ b/usr/src/lib/libast/common/string/ccmapid.c
@@ -0,0 +1,173 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * 8 bit character code map name/id lookup support
+ */
+
+#include <ast.h>
+#include <ccode.h>
+#include <ctype.h>
+
+static const Ccmap_t maps[] =
+{
+ {
+ "ascii",
+ "a|ascii|?(iso)?(-)646|?(iso)?(-)8859|latin",
+ "8 bit ascii",
+ "ISO-8859-%s",
+ "1",
+ CC_ASCII,
+ },
+
+ {
+ "ebcdic",
+ "e|ebcdic?(-)?([1e])",
+ "X/Open ebcdic",
+ "EBCDIC",
+ 0,
+ CC_EBCDIC_E,
+ },
+
+ {
+ "ebcdic-o",
+ "o|ebcdic?(-)[3o]|?(cp|ibm)1047|open?(-)edition",
+ "mvs OpenEdition ebcdic",
+ "EBCDIC-O",
+ 0,
+ CC_EBCDIC_O,
+ },
+
+ {
+ "ebcdic-h",
+ "h|ebcdic?(-)h|?(cp|ibm)?(00)37|[oa]s?(/-)400",
+ "ibm OS/400 AS/400 ebcdic",
+ "EBCDIC-H",
+ 0,
+ CC_EBCDIC_H,
+ },
+
+ {
+ "ebcdic-s",
+ "s|ebcdic?(-)s|siemens|posix-bc",
+ "siemens posix-bc ebcdic",
+ "EBCDIC-S",
+ 0,
+ CC_EBCDIC_S,
+ },
+
+ {
+ "ebcdic-i",
+ "i|ebcdic?(-)[2i]|ibm",
+ "X/Open ibm ebcdic (not idempotent)",
+ "EBCDIC-I",
+ 0,
+ CC_EBCDIC_I,
+ },
+
+ {
+ "ebcdic-m",
+ "m|ebcdic?(-)m|mvs",
+ "mvs ebcdic",
+ "EBCDIC-M",
+ 0,
+ CC_EBCDIC_M,
+ },
+
+ {
+ "ebcdic-u",
+ "u|ebcdic?(-)(u|mf)|microfocus",
+ "microfocus cobol ebcdic",
+ "EBCDIC-U",
+ 0,
+ CC_EBCDIC_U,
+ },
+
+ {
+ "native",
+ "n|native|local",
+ "native code set",
+ 0,
+ 0,
+ CC_NATIVE,
+ },
+
+ { 0 },
+};
+
+/*
+ * ccode map list iterator
+ */
+
+Ccmap_t*
+ccmaplist(Ccmap_t* mp)
+{
+ return !mp ? (Ccmap_t*)maps : (++mp)->name ? mp : (Ccmap_t*)0;
+}
+
+/*
+ * return ccode map id given name
+ */
+
+int
+ccmapid(const char* name)
+{
+ register const Ccmap_t* mp;
+ register int c;
+ const Ccmap_t* bp;
+ int n;
+ int sub[2];
+
+ bp = 0;
+ n = 0;
+ for (mp = maps; mp->name; mp++)
+ if (strgrpmatch(name, mp->match, sub, elementsof(sub) / 2, STR_MAXIMAL|STR_LEFT|STR_ICASE))
+ {
+ if (!(c = name[sub[1]]))
+ return mp->ccode;
+ if (sub[1] > n && !isalpha(c))
+ {
+ n = sub[1];
+ bp = mp;
+ }
+ }
+ return bp ? bp->ccode : -1;
+}
+
+/*
+ * return ccode map name given id
+ */
+
+char*
+ccmapname(register int id)
+{
+ register const Ccmap_t* mp;
+
+ for (mp = maps; mp->name; mp++)
+ if (id == mp->ccode)
+ return (char*)mp->name;
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/string/ccnative.c b/usr/src/lib/libast/common/string/ccnative.c
new file mode 100644
index 0000000000..fbdc6f8037
--- /dev/null
+++ b/usr/src/lib/libast/common/string/ccnative.c
@@ -0,0 +1,56 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * copy table with element size n
+ * indexed by CC_ASCII to table
+ * indexed by CC_NATIVE
+ */
+
+#include <ast.h>
+#include <ccode.h>
+
+void*
+ccnative(void* b, const void* a, size_t n)
+{
+#if CC_ASCII == CC_NATIVE
+ return memcpy(b, a, n * (UCHAR_MAX + 1));
+#else
+ register int c;
+ register const unsigned char* m;
+ register unsigned char* cb = (unsigned char*)b;
+ register unsigned char* ca = (unsigned char*)a;
+
+ m = CCMAP(CC_ASCII, CC_NATIVE);
+ if (n == sizeof(char))
+ for (c = 0; c <= UCHAR_MAX; c++)
+ cb[c] = ca[m[c]];
+ else
+ for (c = 0; c <= UCHAR_MAX; c++)
+ memcpy(cb + n * c, ca + n * m[c], n);
+ return b;
+#endif
+}
diff --git a/usr/src/lib/libast/common/string/chresc.c b/usr/src/lib/libast/common/string/chresc.c
new file mode 100644
index 0000000000..669ecfdf3a
--- /dev/null
+++ b/usr/src/lib/libast/common/string/chresc.c
@@ -0,0 +1,181 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * return the next character in the string s
+ * \ character constants are converted
+ * p is updated to point to the next character in s
+ */
+
+#include <ast.h>
+#include <ctype.h>
+
+#include <ccode.h>
+#if !_PACKAGE_astsa
+#include <regex.h>
+#endif
+
+int
+chresc(register const char* s, char** p)
+{
+ register const char* q;
+ register int c;
+ const char* e;
+#if !_PACKAGE_astsa
+ int n;
+ char buf[64];
+#endif
+
+ switch (c = mbchar(s))
+ {
+ case 0:
+ s--;
+ break;
+ case '\\':
+ switch (c = *s++)
+ {
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ c -= '0';
+ q = s + 2;
+ while (s < q)
+ switch (*s)
+ {
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ c = (c << 3) + *s++ - '0';
+ break;
+ default:
+ q = s;
+ break;
+ }
+ break;
+ case 'a':
+ c = CC_bel;
+ break;
+ case 'b':
+ c = '\b';
+ break;
+ case 'c':
+ control:
+ if (c = *s)
+ {
+ s++;
+ if (islower(c))
+ c = toupper(c);
+ }
+ c = ccmapc(c, CC_NATIVE, CC_ASCII);
+ c ^= 0x40;
+ c = ccmapc(c, CC_ASCII, CC_NATIVE);
+ break;
+ case 'C':
+ if (*s == '-' && *(s + 1))
+ {
+ s++;
+ goto control;
+ }
+#if !_PACKAGE_astsa
+ if (*s == '[' && (n = regcollate(s + 1, (char**)&e, buf, sizeof(buf))) >= 0)
+ {
+ if (n == 1)
+ c = buf[0];
+ s = e;
+ }
+#endif
+ break;
+ case 'e':
+ case 'E':
+ c = CC_esc;
+ break;
+ case 'f':
+ c = '\f';
+ break;
+ case 'M':
+ if (*s == '-')
+ {
+ s++;
+ c = CC_esc;
+ }
+ break;
+ case 'n':
+ c = '\n';
+ break;
+ case 'r':
+ c = '\r';
+ break;
+ case 't':
+ c = '\t';
+ break;
+ case 'v':
+ c = CC_vt;
+ break;
+ case 'u':
+ case 'U':
+ case 'x':
+ c = 0;
+ q = c == 'u' ? (s + 4) : c == 'U' ? (s + 8) : (char*)0;
+ e = s;
+ while (!e || !q || s < q)
+ {
+ switch (*s)
+ {
+ case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+ c = (c << 4) + *s++ - 'a' + 10;
+ continue;
+ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+ c = (c << 4) + *s++ - 'A' + 10;
+ continue;
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ c = (c << 4) + *s++ - '0';
+ continue;
+ case '{':
+ case '[':
+ if (s != e)
+ break;
+ e = 0;
+ s++;
+ continue;
+ case '}':
+ case ']':
+ if (!e)
+ s++;
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+ break;
+ case 0:
+ s--;
+ break;
+ }
+ break;
+ }
+ if (p)
+ *p = (char*)s;
+ return c;
+}
diff --git a/usr/src/lib/libast/common/string/chrtoi.c b/usr/src/lib/libast/common/string/chrtoi.c
new file mode 100644
index 0000000000..c42a775264
--- /dev/null
+++ b/usr/src/lib/libast/common/string/chrtoi.c
@@ -0,0 +1,55 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * convert a 0 terminated character constant string to an int
+ */
+
+#include <ast.h>
+
+int
+chrtoi(register const char* s)
+{
+ register int c;
+ register int n;
+ register int x;
+ char* p;
+
+ c = 0;
+ for (n = 0; n < sizeof(int) * CHAR_BIT; n += CHAR_BIT)
+ {
+ switch (x = *((unsigned char*)s++))
+ {
+ case '\\':
+ x = chresc(s - 1, &p);
+ s = (const char*)p;
+ break;
+ case 0:
+ return(c);
+ }
+ c = (c << CHAR_BIT) | x;
+ }
+ return(c);
+}
diff --git a/usr/src/lib/libast/common/string/fmtbase.c b/usr/src/lib/libast/common/string/fmtbase.c
new file mode 100644
index 0000000000..7ff155e650
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtbase.c
@@ -0,0 +1,56 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * return base b representation for n
+ * if p!=0 then base prefix is included
+ * otherwise if n==0 or b==0 then output is signed base 10
+ */
+
+#include <ast.h>
+
+#undef fmtbasell
+
+char*
+fmtbasell(register intmax_t n, register int b, int p)
+{
+ char* buf;
+ int z;
+
+ buf = fmtbuf(z = 72);
+ if (!p && (n == 0 || b == 0))
+ sfsprintf(buf, z, "%I*d", sizeof(n), n);
+ else
+ sfsprintf(buf, z, p ? "%#..*I*u" : "%..*I*u", b, sizeof(n), n);
+ return buf;
+}
+
+#undef fmtbase
+
+char*
+fmtbase(long n, int b, int p)
+{
+ return fmtbasell((intmax_t)n, b, p);
+}
diff --git a/usr/src/lib/libast/common/string/fmtbuf.c b/usr/src/lib/libast/common/string/fmtbuf.c
new file mode 100644
index 0000000000..3035fb5612
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtbuf.c
@@ -0,0 +1,69 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+/*
+ * return small format buffer chunk of size n
+ * spin lock for thread access
+ * format buffers are short lived
+ * only one concurrent buffer with size > sizeof(buf)
+ */
+
+static char buf[16 * 1024];
+static char* nxt = buf;
+static int lck = -1;
+
+static char* big;
+static size_t bigsiz;
+
+char*
+fmtbuf(size_t n)
+{
+ register char* cur;
+
+ while (++lck)
+ lck--;
+ if (n > (&buf[elementsof(buf)] - nxt))
+ {
+ if (n > elementsof(buf))
+ {
+ if (n > bigsiz)
+ {
+ bigsiz = roundof(n, 8 * 1024);
+ if (!(big = newof(big, char, bigsiz, 0)))
+ {
+ lck--;
+ return 0;
+ }
+ }
+ lck--;
+ return big;
+ }
+ nxt = buf;
+ }
+ cur = nxt;
+ nxt += n;
+ lck--;
+ return cur;
+}
diff --git a/usr/src/lib/libast/common/string/fmtclock.c b/usr/src/lib/libast/common/string/fmtclock.c
new file mode 100644
index 0000000000..3caaeeafe7
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtclock.c
@@ -0,0 +1,56 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * return pointer to formatted clock() tics t
+ * return value length is at most 6
+ */
+
+#include <ast.h>
+#include <tm.h>
+
+char*
+fmtclock(register Sfulong_t t)
+{
+ register int u;
+ char* buf;
+ int z;
+
+ static unsigned int clk_tck;
+
+ if (!clk_tck && !(clk_tck = (unsigned int)strtoul(astconf("CLK_TCK", NiL, NiL), NiL, 10)))
+ clk_tck = 60;
+ if (t == 0)
+ return "0";
+ if (t == ((Sfulong_t)~0))
+ return "%";
+ t = (t * 1000000) / clk_tck;
+ if (t < 1000)
+ u = 'u';
+ else if ((t /= 1000) < 1000)
+ u = 'm';
+ else
+ return fmtelapsed(t / 10, 100);
+ buf = fmtbuf(z = 7);
+ sfsprintf(buf, z, "%I*u%cs", sizeof(t), t, u);
+ return buf;
+}
diff --git a/usr/src/lib/libast/common/string/fmtdev.c b/usr/src/lib/libast/common/string/fmtdev.c
new file mode 100644
index 0000000000..1e0cb29326
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtdev.c
@@ -0,0 +1,57 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * idevice() formatter
+ */
+
+#include <ast.h>
+#include <ctype.h>
+#include <ls.h>
+
+char*
+fmtdev(struct stat* st)
+{
+ char* buf;
+ int z;
+
+ unsigned int ma = major(idevice(st));
+ unsigned int mi = minor(idevice(st));
+
+ buf = fmtbuf(z = 17);
+ if (ma == '#' && isalnum(mi))
+ {
+ /*
+ * Plan? Nein!
+ */
+
+ buf[0] = ma;
+ buf[1] = mi;
+ buf[2] = 0;
+ }
+ else
+ sfsprintf(buf, z, "%03d,%03d", ma, mi);
+ return buf;
+}
diff --git a/usr/src/lib/libast/common/string/fmtelapsed.c b/usr/src/lib/libast/common/string/fmtelapsed.c
new file mode 100644
index 0000000000..6c940f1b6b
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtelapsed.c
@@ -0,0 +1,61 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * return pointer to formatted elapsed time for u 1/n secs
+ * compatible with strelapsed()
+ * return value length is at most 7
+ */
+
+#include <ast.h>
+
+char*
+fmtelapsed(register unsigned long u, register int n)
+{
+ register unsigned long t;
+ char* buf;
+ int z;
+
+ if (u == 0L)
+ return "0";
+ if (u == ~0L)
+ return "%";
+ buf = fmtbuf(z = 8);
+ t = u / n;
+ if (t < 60)
+ sfsprintf(buf, z, "%lu.%02lus", t, (u * 100 / n) % 100);
+ else if (t < 60*60)
+ sfsprintf(buf, z, "%lum%02lus", t / 60, t - (t / 60) * 60);
+ else if (t < 24*60*60)
+ sfsprintf(buf, z, "%luh%02lum", t / (60*60), (t - (t / (60*60)) * (60*60)) / 60);
+ else if (t < 7*24*60*60)
+ sfsprintf(buf, z, "%lud%02luh", t / (24*60*60), (t - (t / (24*60*60)) * (24*60*60)) / (60*60));
+ else if (t < 31*24*60*60)
+ sfsprintf(buf, z, "%luw%02lud", t / (7*24*60*60), (t - (t / (7*24*60*60)) * (7*24*60*60)) / (24*60*60));
+ else if (t < 365*24*60*60)
+ sfsprintf(buf, z, "%luM%02lud", (t * 12) / (365*24*60*60), ((t * 12) - ((t * 12) / (365*24*60*60)) * (365*24*60*60)) / (12*24*60*60));
+ else if (t < (365UL*4UL+1UL)*24UL*60UL*60UL)
+ sfsprintf(buf, z, "%luY%02luM", t / (365*24*60*60), ((t - (t / (365*24*60*60)) * (365*24*60*60)) * 5) / (152 * 24 * 60 * 60));
+ else
+ sfsprintf(buf, z, "%luY%02luM", (t * 4) / ((365UL*4UL+1UL)*24UL*60UL*60UL), (((t * 4) - ((t * 4) / ((365UL*4UL+1UL)*24UL*60UL*60UL)) * ((365UL*4UL+1UL)*24UL*60UL*60UL)) * 5) / ((4 * 152 + 1) * 24 * 60 * 60));
+ return buf;
+}
diff --git a/usr/src/lib/libast/common/string/fmterror.c b/usr/src/lib/libast/common/string/fmterror.c
new file mode 100644
index 0000000000..738dae50ff
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmterror.c
@@ -0,0 +1,37 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * return error message string given errno
+ */
+
+#include <ast.h>
+
+char*
+fmterror(int err)
+{
+ return strerror(err);
+}
diff --git a/usr/src/lib/libast/common/string/fmtesc.c b/usr/src/lib/libast/common/string/fmtesc.c
new file mode 100644
index 0000000000..76b850d596
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtesc.c
@@ -0,0 +1,237 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * return string with expanded escape chars
+ */
+
+#include <ast.h>
+#include <ccode.h>
+#include <ctype.h>
+
+/*
+ * quote string as of length n with qb...qe
+ * (flags&FMT_ALWAYS) always quotes, otherwise quote output only if necessary
+ * qe and the usual suspects are \... escaped
+ * (flags&FMT_WIDE) doesn't escape 8 bit chars
+ * (flags&FMT_ESCAPED) doesn't \... escape the usual suspects
+ * (flags&FMT_SHELL) escape $`"#;~&|()<>[]*?
+ */
+
+char*
+fmtquote(const char* as, const char* qb, const char* qe, size_t n, int flags)
+{
+ register unsigned char* s = (unsigned char*)as;
+ register unsigned char* e = s + n;
+ register char* b;
+ register int c;
+ register int escaped;
+ register int spaced;
+ register int doublequote;
+ register int singlequote;
+ int shell;
+ char* f;
+ char* buf;
+
+ c = 4 * (n + 1);
+ if (qb)
+ c += strlen((char*)qb);
+ if (qe)
+ c += strlen((char*)qe);
+ b = buf = fmtbuf(c);
+ shell = 0;
+ doublequote = 0;
+ singlequote = 0;
+ if (qb)
+ {
+ if (qb[0] == '$' && qb[1] == '\'' && qb[2] == 0)
+ shell = 1;
+ else if ((flags & FMT_SHELL) && qb[1] == 0)
+ {
+ if (qb[0] == '"')
+ doublequote = 1;
+ else if (qb[0] == '\'')
+ singlequote = 1;
+ }
+ while (*b = *qb++)
+ b++;
+ }
+ else if (flags & FMT_SHELL)
+ doublequote = 1;
+ f = b;
+ escaped = spaced = !!(flags & FMT_ALWAYS);
+ while (s < e)
+ {
+ if ((c = mbsize(s)) > 1)
+ {
+ while (c-- && s < e)
+ *b++ = *s++;
+ }
+ else
+ {
+ c = *s++;
+ if (!(flags & FMT_ESCAPED) && (iscntrl(c) || !isprint(c) || c == '\\'))
+ {
+ escaped = 1;
+ *b++ = '\\';
+ switch (c)
+ {
+ case CC_bel:
+ c = 'a';
+ break;
+ case '\b':
+ c = 'b';
+ break;
+ case '\f':
+ c = 'f';
+ break;
+ case '\n':
+ c = 'n';
+ break;
+ case '\r':
+ c = 'r';
+ break;
+ case '\t':
+ c = 't';
+ break;
+ case CC_vt:
+ c = 'v';
+ break;
+ case CC_esc:
+ c = 'E';
+ break;
+ case '\\':
+ break;
+ default:
+ if (!(flags & FMT_WIDE) || !(c & 0200))
+ {
+ *b++ = '0' + ((c >> 6) & 07);
+ *b++ = '0' + ((c >> 3) & 07);
+ c = '0' + (c & 07);
+ }
+ else
+ b--;
+ break;
+ }
+ }
+ else if (c == '\\')
+ {
+ escaped = 1;
+ *b++ = c;
+ if (*s)
+ c = *s++;
+ }
+ else if (qe && strchr(qe, c))
+ {
+ if (singlequote && c == '\'')
+ {
+ spaced = 1;
+ *b++ = '\'';
+ *b++ = '\\';
+ *b++ = '\'';
+ c = '\'';
+ }
+ else
+ {
+ escaped = 1;
+ *b++ = '\\';
+ }
+ }
+ else if (c == '$' || c == '`')
+ {
+ if (c == '$' && (flags & FMT_PARAM) && (*s == '{' || *s == '('))
+ {
+ if (singlequote || shell)
+ {
+ escaped = 1;
+ *b++ = '\'';
+ *b++ = c;
+ *b++ = *s++;
+ if (shell)
+ {
+ spaced = 1;
+ *b++ = '$';
+ }
+ c = '\'';
+ }
+ else
+ {
+ escaped = 1;
+ *b++ = c;
+ c = *s++;
+ }
+ }
+ else if (doublequote)
+ *b++ = '\\';
+ else if (singlequote || (flags & FMT_SHELL))
+ spaced = 1;
+ }
+ else if (!spaced && !escaped && (isspace(c) || ((flags & FMT_SHELL) || shell) && (strchr("\";~&|()<>[]*?", c) || c == '#' && (b == f || isspace(*(b - 1))))))
+ spaced = 1;
+ *b++ = c;
+ }
+ }
+ if (qb)
+ {
+ if (!escaped)
+ buf += shell + !spaced;
+ if (qe && (escaped || spaced))
+ while (*b = *qe++)
+ b++;
+ }
+ *b = 0;
+ return buf;
+}
+
+/*
+ * escape the usual suspects and quote chars in qs
+ * in length n string as
+ */
+
+char*
+fmtnesq(const char* as, const char* qs, size_t n)
+{
+ return fmtquote(as, NiL, qs, n, 0);
+}
+
+/*
+ * escape the usual suspects and quote chars in qs
+ */
+
+char*
+fmtesq(const char* as, const char* qs)
+{
+ return fmtquote(as, NiL, qs, strlen((char*)as), 0);
+}
+
+/*
+ * escape the usual suspects
+ */
+
+char*
+fmtesc(const char* as)
+{
+ return fmtquote(as, NiL, NiL, strlen((char*)as), 0);
+}
diff --git a/usr/src/lib/libast/common/string/fmtfmt.c b/usr/src/lib/libast/common/string/fmtfmt.c
new file mode 100644
index 0000000000..b4ec90ed54
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtfmt.c
@@ -0,0 +1,205 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * return printf(3) format signature given format string
+ * the format signature contains one char per format optionally preceded
+ * by the number of `*' args
+ * c char
+ * d double
+ * D long double
+ * f float
+ * h short
+ * i int
+ * j long long
+ * l long
+ * p void*
+ * s string
+ * t ptrdiff_t
+ * z size_t
+ * ? unknown
+ */
+
+#include <ast.h>
+#include <ctype.h>
+
+char*
+fmtfmt(const char* as)
+{
+ register char* s = (char*)as;
+ char* buf;
+ int i;
+ int c;
+ int a;
+ int q;
+ int x;
+ int t;
+ int m;
+ int n;
+ int z;
+ char formats[256];
+ unsigned int extra[elementsof(formats)];
+
+ z = 1;
+ i = m = 0;
+ for (;;)
+ {
+ switch (*s++)
+ {
+ case 0:
+ break;
+ case '%':
+ if (*s == '%')
+ continue;
+ n = 0;
+ a = 0;
+ q = 0;
+ t = '?';
+ x = 0;
+ for (;;)
+ {
+ switch (c = *s++)
+ {
+ case 0:
+ s--;
+ break;
+ case '(':
+ q++;
+ continue;
+ case ')':
+ if (--q <= 0)
+ n = 0;
+ continue;
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ case '8': case '9':
+ n = n * 10 + (c - '0');
+ continue;
+ case '$':
+ a = n;
+ n = 0;
+ continue;
+ case '*':
+ x++;
+ n = 0;
+ continue;
+ case 'h':
+ if (!q)
+ t = t == 'h' ? 'c' : 'h';
+ continue;
+ case 'l':
+ if (!q)
+ t = t == 'l' ? 'j' : 'l';
+ continue;
+ case 'j':
+ case 't':
+ case 'z':
+ if (!q)
+ t = c;
+ continue;
+ case 'c':
+ case 'p':
+ case 's':
+ if (!q)
+ {
+ t = c;
+ break;
+ }
+ continue;
+ case 'e':
+ case 'g':
+ if (!q)
+ {
+ switch (t)
+ {
+ case 'j':
+ t = 'D';
+ break;
+ default:
+ t = 'd';
+ break;
+ }
+ break;
+ }
+ continue;
+ case 'f':
+ if (!q)
+ {
+ switch (t)
+ {
+ case 'j':
+ t = 'D';
+ break;
+ case 'l':
+ t = 'd';
+ break;
+ default:
+ t = c;
+ break;
+ }
+ break;
+ }
+ continue;
+ default:
+ if (!q && isalpha(c))
+ {
+ if (t == '?')
+ t = 'i';
+ break;
+ }
+ n = 0;
+ continue;
+ }
+ break;
+ }
+ if (a)
+ i = a;
+ else
+ i++;
+ if (i < elementsof(formats))
+ {
+ formats[i] = t;
+ if (extra[i] = x)
+ do z++; while (x /= 10);
+ if (m < i)
+ m = i;
+ }
+ continue;
+ default:
+ continue;
+ }
+ break;
+ }
+ s = buf = fmtbuf(m + z);
+ for (i = 1; i <= m; i++)
+ {
+ if (extra[i])
+ s += sfsprintf(s, 10, "%d", extra[m]);
+ *s++ = formats[i];
+ }
+ *s = 0;
+ return buf;
+}
diff --git a/usr/src/lib/libast/common/string/fmtfs.c b/usr/src/lib/libast/common/string/fmtfs.c
new file mode 100644
index 0000000000..b4c275f5f9
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtfs.c
@@ -0,0 +1,100 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * return fs type string given stat
+ */
+
+#include <ast.h>
+#include <ls.h>
+#include <mnt.h>
+
+#include "FEATURE/fs"
+
+#if _str_st_fstype
+
+char*
+fmtfs(struct stat* st)
+{
+ return st->st_fstype;
+}
+
+#else
+
+#include <cdt.h>
+
+typedef struct Id_s
+{
+ Dtlink_t link;
+ dev_t id;
+ char name[1];
+} Id_t;
+
+char*
+fmtfs(struct stat* st)
+{
+ register Id_t* ip;
+ register void* mp;
+ register Mnt_t* mnt;
+ register char* s;
+ struct stat rt;
+ char* buf;
+
+ static Dt_t* dict;
+ static Dtdisc_t disc;
+
+ if (!dict)
+ {
+ disc.key = offsetof(Id_t, id);
+ disc.size = sizeof(dev_t);
+ dict = dtopen(&disc, Dthash);
+ }
+ else if (ip = (Id_t*)dtmatch(dict, &st->st_dev))
+ return ip->name;
+ s = FS_default;
+ if (mp = mntopen(NiL, "r"))
+ {
+ while ((mnt = mntread(mp)) && (stat(mnt->dir, &rt) || rt.st_dev != st->st_dev));
+ if (mnt && mnt->type)
+ s = mnt->type;
+ }
+ if (!dict || !(ip = newof(0, Id_t, 1, strlen(s))))
+ {
+ if (!mp)
+ return s;
+ buf = fmtbuf(strlen(s) + 1);
+ strcpy(buf, s);
+ mntclose(mp);
+ return buf;
+ }
+ strcpy(ip->name, s);
+ if (mp)
+ mntclose(mp);
+ dtinsert(dict, ip);
+ return ip->name;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/string/fmtgid.c b/usr/src/lib/libast/common/string/fmtgid.c
new file mode 100644
index 0000000000..eff0c87c66
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtgid.c
@@ -0,0 +1,101 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * cached gid number -> name
+ */
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide getgrgid
+#else
+#define getgrgid ______getgrgid
+#endif
+
+#include <ast.h>
+#include <cdt.h>
+#include <grp.h>
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide getgrgid
+#else
+#undef getgrgid
+#endif
+
+extern struct group* getgrgid(gid_t);
+
+typedef struct Id_s
+{
+ Dtlink_t link;
+ int id;
+ char name[1];
+} Id_t;
+
+/*
+ * return gid name given gid number
+ */
+
+char*
+fmtgid(int gid)
+{
+ register Id_t* ip;
+ register char* name;
+ register struct group* gr;
+ int z;
+
+ static Dt_t* dict;
+ static Dtdisc_t disc;
+
+ if (!dict)
+ {
+ disc.key = offsetof(Id_t, id);
+ disc.size = sizeof(int);
+ dict = dtopen(&disc, Dthash);
+ }
+ else if (ip = (Id_t*)dtmatch(dict, &gid))
+ return ip->name;
+ if (gr = getgrgid(gid))
+ {
+ name = gr->gr_name;
+#if _WINIX
+ if (streq(name, "Administrators"))
+ name = "sys";
+#endif
+ }
+ else if (gid == 0)
+ name = "sys";
+ else
+ {
+ name = fmtbuf(z = sizeof(gid) * 3 + 1);
+ sfsprintf(name, z, "%I*d", sizeof(gid), gid);
+ }
+ if (dict && (ip = newof(0, Id_t, 1, strlen(name))))
+ {
+ ip->id = gid;
+ strcpy(ip->name, name);
+ dtinsert(dict, ip);
+ return ip->name;
+ }
+ return name;
+}
diff --git a/usr/src/lib/libast/common/string/fmtident.c b/usr/src/lib/libast/common/string/fmtident.c
new file mode 100644
index 0000000000..f20c2be497
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtident.c
@@ -0,0 +1,77 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+#include <ctype.h>
+
+#define IDENT 01
+#define USAGE 02
+
+/*
+ * format what(1) and/or ident(1) string a
+ */
+
+char*
+fmtident(const char* a)
+{
+ register char* s = (char*)a;
+ register char* t;
+ char* buf;
+ int i;
+
+ i = 0;
+ for (;;)
+ {
+ while (isspace(*s))
+ s++;
+ if (s[0] == '[')
+ {
+ while (*++s && *s != '\n');
+ i |= USAGE;
+ }
+ else if (s[0] == '@' && s[1] == '(' && s[2] == '#' && s[3] == ')')
+ s += 4;
+ else if (s[0] == '$' && s[1] == 'I' && s[2] == 'd' && s[3] == ':' && isspace(s[4]))
+ {
+ s += 5;
+ i |= IDENT;
+ }
+ else
+ break;
+ }
+ if (i)
+ {
+ i &= IDENT;
+ for (t = s; isprint(*t) && *t != '\n'; t++)
+ if (i && t[0] == ' ' && t[1] == '$')
+ break;
+ while (t > s && isspace(t[-1]))
+ t--;
+ i = t - s;
+ buf = fmtbuf(i + 1);
+ memcpy(buf, s, i);
+ s = buf;
+ s[i] = 0;
+ }
+ return s;
+}
diff --git a/usr/src/lib/libast/common/string/fmtip4.c b/usr/src/lib/libast/common/string/fmtip4.c
new file mode 100644
index 0000000000..37750d2b77
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtip4.c
@@ -0,0 +1,43 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+/*
+ * format 4 byte local byte order ip address
+ * and optional prefix bits (if 0 <= bits <= 32)
+ */
+
+char*
+fmtip4(register uint32_t addr, int bits)
+{
+ char* buf;
+ int z;
+ int i;
+
+ buf = fmtbuf(z = 20);
+ i = sfsprintf(buf, z, "%d.%d.%d.%d", (addr>>24)&0xff, (addr>>16)&0xff, (addr>>8)&0xff, (addr)&0xff);
+ if (bits >= 0 && bits <= 32)
+ sfsprintf(buf + i, z - i, "/%d", bits);
+ return buf;
+}
diff --git a/usr/src/lib/libast/common/string/fmtls.c b/usr/src/lib/libast/common/string/fmtls.c
new file mode 100644
index 0000000000..ea00c00ffc
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtls.c
@@ -0,0 +1,120 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * ls formatter
+ */
+
+#include <ast.h>
+#include <ls.h>
+#include <tm.h>
+
+#ifndef LS_W_MAX
+#define LS_W_MAX 128
+#endif
+
+/*
+ * ls formatter
+ *
+ * buf results placed here
+ * name file name
+ * st file stat buffer
+ * info optional info
+ * link link text if != 0
+ * flags LS_* flags
+ *
+ * return end of formatted buf
+ */
+
+char*
+fmtls(char* buf, const char* name, register struct stat* st, const char* info, const char* link, register int flags)
+{
+ register char* s;
+ time_t tm;
+ Sfoff_t n;
+
+ s = buf;
+ if (flags & LS_INUMBER)
+ s += sfsprintf(s, LS_W_MAX, "%*I*u ", LS_W_INUMBER - 1, sizeof(st->st_ino), st->st_ino);
+ if (flags & LS_BLOCKS)
+ {
+ n = iblocks(st);
+ s += sfsprintf(s, LS_W_MAX, "%*I*u ", LS_W_BLOCKS - 1, sizeof(n), n);
+ }
+ if (flags & LS_LONG)
+ {
+ s += sfsprintf(s, LS_W_MAX, "%s%3u", fmtmode(st->st_mode, flags & LS_EXTERNAL), (unsigned int)st->st_nlink);
+ if (!(flags & LS_NOUSER))
+ {
+ if (flags & LS_NUMBER)
+ s += sfsprintf(s, LS_W_MAX, " %-*I*d", LS_W_NAME - 1, sizeof(st->st_uid), st->st_uid);
+ else
+ s += sfsprintf(s, LS_W_MAX, " %-*s", LS_W_NAME - 1, fmtuid(st->st_uid));
+ }
+ if (!(flags & LS_NOGROUP))
+ {
+ if (flags & LS_NUMBER)
+ s += sfsprintf(s, LS_W_MAX, " %-*I*d", LS_W_NAME - 1, sizeof(st->st_gid), st->st_gid);
+ else
+ s += sfsprintf(s, LS_W_MAX, " %-*s", LS_W_NAME - 1, fmtgid(st->st_gid));
+ }
+ if (S_ISBLK(st->st_mode) || S_ISCHR(st->st_mode))
+ s += sfsprintf(s, LS_W_MAX, "%8s ", fmtdev(st));
+ else
+ s += sfsprintf(s, LS_W_MAX, "%8I*u ", sizeof(st->st_size), st->st_size);
+ tm = (flags & LS_ATIME) ? st->st_atime : (flags & LS_CTIME) ? st->st_ctime : st->st_mtime;
+ s = tmfmt(s, LS_W_LONG / 2, "%?%l", &tm);
+ *s++ = ' ';
+ }
+ if (info)
+ {
+ while (*s = *info++)
+ s++;
+ *s++ = ' ';
+ }
+ while (*s = *name++)
+ s++;
+ if (flags & LS_MARK)
+ {
+ if (S_ISDIR(st->st_mode))
+ *s++ = '/';
+#ifdef S_ISLNK
+ else if (S_ISLNK(st->st_mode))
+ *s++ = '@';
+#endif
+ else if (st->st_mode & (S_IXUSR|S_IXGRP|S_IXOTH))
+ *s++ = '*';
+ }
+ if (link)
+ {
+ s += sfsprintf(s, LS_W_MAX, " %s %s",
+#ifdef S_ISLNK
+ S_ISLNK(st->st_mode) ? "->" :
+#endif
+ "==", link);
+ }
+ *s = 0;
+ return s;
+}
diff --git a/usr/src/lib/libast/common/string/fmtmatch.c b/usr/src/lib/libast/common/string/fmtmatch.c
new file mode 100644
index 0000000000..f5b27c71bd
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtmatch.c
@@ -0,0 +1,286 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * return strmatch() expression given REG_AUGMENTED RE
+ * 0 returned for invalid RE
+ */
+
+#include <ast.h>
+
+char*
+fmtmatch(const char* as)
+{
+ register char* s = (char*)as;
+ register int c;
+ register char* t;
+ register char** p;
+ register char* b;
+ char* x;
+ char* y;
+ char* z;
+ int a;
+ int e;
+ int n;
+ char* buf;
+ char* stack[32];
+
+ c = 3 * (strlen(s) + 1);
+ buf = fmtbuf(c);
+ t = b = buf + 3;
+ p = stack;
+ if (a = *s == '^')
+ s++;
+ e = 0;
+ for (;;)
+ {
+ switch (c = *s++)
+ {
+ case 0:
+ break;
+ case '\\':
+ if (!(c = *s++))
+ return 0;
+ switch (*s)
+ {
+ case '*':
+ case '+':
+ case '?':
+ *t++ = *s++;
+ *t++ = '(';
+ *t++ = '\\';
+ *t++ = c;
+ c = ')';
+ break;
+ case '|':
+ case '&':
+ if (c == '(')
+ {
+ *t++ = c;
+ c = *s++;
+ goto logical;
+ }
+ break;
+ case '{':
+ case '}':
+ break;
+ default:
+ *t++ = '\\';
+ break;
+ }
+ *t++ = c;
+ continue;
+ case '[':
+ x = t;
+ *t++ = c;
+ if ((c = *s++) == '^')
+ {
+ *t++ = '!';
+ c = *s++;
+ }
+ else if (c == '!')
+ {
+ *t++ = '\\';
+ *t++ = c;
+ c = *s++;
+ }
+ for (;;)
+ {
+ if (!(*t++ = c))
+ return 0;
+ if (c == '\\')
+ *t++ = c;
+ if ((c = *s++) == ']')
+ {
+ *t++ = c;
+ break;
+ }
+ }
+ switch (*s)
+ {
+ case '*':
+ case '+':
+ case '?':
+ for (y = t + 2, t--; t >= x; t--)
+ *(t + 2) = *t;
+ *++t = *s++;
+ *++t = '(';
+ t = y;
+ *t++ = ')';
+ break;
+ }
+ continue;
+ case '(':
+ if (p >= &stack[elementsof(stack)])
+ return 0;
+ *p++ = t;
+ if (*s == '?')
+ {
+ s++;
+ if (*s == 'K' && *(s + 1) == ')')
+ {
+ s += 2;
+ p--;
+ while (*t = *s)
+ t++, s++;
+ continue;
+ }
+ *t++ = '~';
+ }
+ else
+ *t++ = '@';
+ *t++ = '(';
+ continue;
+ case ')':
+ if (p == stack)
+ return 0;
+ p--;
+ *t++ = c;
+ switch (*s)
+ {
+ case 0:
+ break;
+ case '*':
+ case '+':
+ case '?':
+ case '!':
+ **p = *s++;
+ if (*s == '?')
+ {
+ s++;
+ x = *p + 1;
+ for (y = ++t; y > x; y--)
+ *y = *(y - 1);
+ *x = '-';
+ }
+ continue;
+ case '{':
+ for (z = s; *z != '}'; z++)
+ if (!*z)
+ return 0;
+ n = z - s;
+ if (*++z == '?')
+ n++;
+ x = *p + n;
+ for (y = t += n; y > x; y--)
+ *y = *(y - n);
+ for (x = *p; s < z; *x++ = *s++);
+ if (*s == '?')
+ {
+ s++;
+ *x++ = '-';
+ }
+ continue;
+ default:
+ continue;
+ }
+ break;
+ case '.':
+ switch (*s)
+ {
+ case 0:
+ *t++ = '?';
+ break;
+ case '*':
+ s++;
+ *t++ = '*';
+ e = !*s;
+ continue;
+ case '+':
+ s++;
+ *t++ = '?';
+ *t++ = '*';
+ continue;
+ case '?':
+ s++;
+ *t++ = '?';
+ *t++ = '(';
+ *t++ = '?';
+ *t++ = ')';
+ continue;
+ default:
+ *t++ = '?';
+ continue;
+ }
+ break;
+ case '*':
+ case '+':
+ case '?':
+ case '{':
+ n = *(t - 1);
+ if (t == b || n == '(' || n == '|')
+ return 0;
+ *(t - 1) = c;
+ if (c == '{')
+ {
+ for (z = s; *z != '}'; z++)
+ if (!*z)
+ return 0;
+ for (; s <= z; *t++ = *s++);
+ }
+ if (*s == '?')
+ {
+ s++;
+ *t++ = '-';
+ }
+ *t++ = '(';
+ *t++ = n;
+ *t++ = ')';
+ continue;
+ case '|':
+ case '&':
+ if (t == b || *(t - 1) == '(')
+ return 0;
+ logical:
+ if (!*s || *s == ')')
+ return 0;
+ if (p == stack && b == buf + 3)
+ {
+ *--b = '(';
+ *--b = '@';
+ }
+ *t++ = c;
+ continue;
+ case '$':
+ if (e = !*s)
+ break;
+ /*FALLTHROUGH*/
+ default:
+ *t++ = c;
+ continue;
+ }
+ break;
+ }
+ if (p != stack)
+ return 0;
+ if (b != buf + 3)
+ *t++ = ')';
+ if (!a && (*b != '*' || *(b + 1) == '(' || (*(b + 1) == '-' || *(b + 1) == '~') && *(b + 2) == '('))
+ *--b = '*';
+ if (!e)
+ *t++ = '*';
+ *t = 0;
+ return b;
+}
diff --git a/usr/src/lib/libast/common/string/fmtmode.c b/usr/src/lib/libast/common/string/fmtmode.c
new file mode 100644
index 0000000000..ae1dcaa8ec
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtmode.c
@@ -0,0 +1,47 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * return ls -l style file mode string given file mode bits
+ * if external!=0 then mode is modex canonical
+ */
+
+#include "modelib.h"
+
+char*
+fmtmode(register int mode, int external)
+{
+ register char* s;
+ register struct modeop* p;
+ char* buf;
+
+ if (!external)
+ mode = modex(mode);
+ s = buf = fmtbuf(MODELEN + 1);
+ for (p = modetab; p < &modetab[MODELEN]; p++)
+ *s++ = p->name[((mode & p->mask1) >> p->shift1) | ((mode & p->mask2) >> p->shift2)];
+ *s = 0;
+ return buf;
+}
diff --git a/usr/src/lib/libast/common/string/fmtnum.c b/usr/src/lib/libast/common/string/fmtnum.c
new file mode 100644
index 0000000000..a5410492e3
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtnum.c
@@ -0,0 +1,92 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * return scaled number n
+ * string width is 5 chars or less
+ * if m>1 then n divided by m before scaling
+ */
+
+#include <ast.h>
+
+char*
+fmtnum(register unsigned long n, int m)
+{
+ register int i;
+ register unsigned long r;
+ char* buf;
+ int z;
+
+ char suf[2];
+
+ if (m > 1)
+ {
+ r = n;
+ n /= m;
+ r -= n;
+ }
+ else
+ r = 0;
+ suf[1] = 0;
+ if (n < 1024)
+ suf[0] = 0;
+ else if (n < 1024 * 1024)
+ {
+ suf[0] = 'k';
+ r = ((n % 1024) * 100) / 1024;
+ n /= 1024;
+ }
+ else if (n < 1024 * 1024 * 1024)
+ {
+ suf[0] = 'm';
+ r = ((n % (1024 * 1024)) * 100) / (1024 * 1024);
+ n /= 1024 * 1024;
+ }
+ else
+ {
+ suf[0] = 'g';
+ r = ((n % (1024 * 1024 * 1024)) * 100) / (1024 * 1024 * 1024);
+ n /= 1024 * 1024 * 1024;
+ }
+ if (r)
+ {
+ if (n >= 100)
+ r = 0;
+ else if (n >= 10)
+ {
+ i = 1;
+ if (r >= 10)
+ r /= 10;
+ }
+ else
+ i = 2;
+ }
+ buf = fmtbuf(z = 8);
+ if (r)
+ sfsprintf(buf, z, "%lu.%0*lu%s", n, i, r, suf);
+ else
+ sfsprintf(buf, z, "%lu%s", n, suf);
+ return buf;
+}
diff --git a/usr/src/lib/libast/common/string/fmtperm.c b/usr/src/lib/libast/common/string/fmtperm.c
new file mode 100644
index 0000000000..187c43559e
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtperm.c
@@ -0,0 +1,91 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * return strperm() expression for perm
+ */
+
+#include <ast.h>
+#include <ls.h>
+
+char*
+fmtperm(register int perm)
+{
+ register char* s;
+ char* buf;
+
+ s = buf = fmtbuf(32);
+
+ /*
+ * u
+ */
+
+ *s++ = 'u';
+ *s++ = '=';
+ if (perm & S_ISVTX)
+ *s++ = 't';
+ if (perm & S_ISUID)
+ *s++ = 's';
+ if (perm & S_IRUSR)
+ *s++ = 'r';
+ if (perm & S_IWUSR)
+ *s++ = 'w';
+ if (perm & S_IXUSR)
+ *s++ = 'x';
+ if ((perm & (S_ISGID|S_IXGRP)) == S_ISGID)
+ *s++ = 'l';
+
+ /*
+ * g
+ */
+
+ *s++ = ',';
+ *s++ = 'g';
+ *s++ = '=';
+ if ((perm & (S_ISGID|S_IXGRP)) == (S_ISGID|S_IXGRP))
+ *s++ = 's';
+ if (perm & S_IRGRP)
+ *s++ = 'r';
+ if (perm & S_IWGRP)
+ *s++ = 'w';
+ if (perm & S_IXGRP)
+ *s++ = 'x';
+
+ /*
+ * o
+ */
+
+ *s++ = ',';
+ *s++ = 'o';
+ *s++ = '=';
+ if (perm & S_IROTH)
+ *s++ = 'r';
+ if (perm & S_IWOTH)
+ *s++ = 'w';
+ if (perm & S_IXOTH)
+ *s++ = 'x';
+ *s = 0;
+ return buf;
+}
diff --git a/usr/src/lib/libast/common/string/fmtre.c b/usr/src/lib/libast/common/string/fmtre.c
new file mode 100644
index 0000000000..7f90074109
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtre.c
@@ -0,0 +1,225 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * return RE expression given strmatch() pattern
+ * 0 returned for invalid RE
+ */
+
+#include <ast.h>
+
+typedef struct Stack_s
+{
+ char* beg;
+ short len;
+ short min;
+} Stack_t;
+
+char*
+fmtre(const char* as)
+{
+ register char* s = (char*)as;
+ register int c;
+ register char* t;
+ register Stack_t* p;
+ char* x;
+ int n;
+ int end;
+ char* buf;
+ Stack_t stack[32];
+
+ end = 1;
+ c = 2 * strlen(s) + 1;
+ t = buf = fmtbuf(c);
+ p = stack;
+ if (*s != '*' || *(s + 1) == '(' || *(s + 1) == '-' && *(s + 2) == '(')
+ *t++ = '^';
+ else
+ s++;
+ for (;;)
+ {
+ switch (c = *s++)
+ {
+ case 0:
+ break;
+ case '\\':
+ if (!(c = *s++) || c == '{' || c == '}')
+ return 0;
+ *t++ = '\\';
+ if ((*t++ = c) == '(' && *s == '|')
+ {
+ *t++ = *s++;
+ goto logical;
+ }
+ continue;
+ case '[':
+ *t++ = c;
+ n = 0;
+ if ((c = *s++) == '!')
+ {
+ *t++ = '^';
+ c = *s++;
+ }
+ else if (c == '^')
+ {
+ if ((c = *s++) == ']')
+ {
+ *(t - 1) = '\\';
+ *t++ = '^';
+ continue;
+ }
+ n = '^';
+ }
+ for (;;)
+ {
+ if (!(*t++ = c))
+ return 0;
+ if ((c = *s++) == ']')
+ {
+ if (n)
+ *t++ = n;
+ *t++ = c;
+ break;
+ }
+ }
+ continue;
+ case '{':
+ for (x = s; *x && *x != '}'; x++);
+ if (*x++ && (*x == '(' || *x == '-' && *(x + 1) == '('))
+ {
+ if (p >= &stack[elementsof(stack)])
+ return 0;
+ p->beg = s - 1;
+ s = x;
+ p->len = s - p->beg;
+ if (p->min = *s == '-')
+ s++;
+ p++;
+ *t++ = *s++;
+ }
+ else
+ *t++ = c;
+ continue;
+ case '*':
+ if (!*s)
+ {
+ end = 0;
+ break;
+ }
+ /*FALLTHROUGH*/
+ case '?':
+ case '+':
+ case '@':
+ case '!':
+ case '~':
+ if (*s == '(' || c != '~' && *s == '-' && *(s + 1) == '(')
+ {
+ if (p >= &stack[elementsof(stack)])
+ return 0;
+ p->beg = s - 1;
+ if (c == '~')
+ {
+ if (*(s + 1) == 'E' && *(s + 2) == ')')
+ {
+ for (s += 3; *t = *s; t++, s++);
+ continue;
+ }
+ p->len = 0;
+ *t++ = *s++;
+ *t++ = '?';
+ }
+ else
+ {
+ p->len = c != '@';
+ if (p->min = *s == '-')
+ s++;
+ *t++ = *s++;
+ }
+ p++;
+ }
+ else
+ {
+ switch (c)
+ {
+ case '*':
+ *t++ = '.';
+ break;
+ case '?':
+ c = '.';
+ break;
+ case '+':
+ case '!':
+ *t++ = '\\';
+ break;
+ }
+ *t++ = c;
+ }
+ continue;
+ case '(':
+ if (p >= &stack[elementsof(stack)])
+ return 0;
+ p->beg = s - 1;
+ p->len = 0;
+ p->min = 0;
+ p++;
+ *t++ = c;
+ continue;
+ case ')':
+ if (p == stack)
+ return 0;
+ *t++ = c;
+ p--;
+ for (c = 0; c < p->len; c++)
+ *t++ = p->beg[c];
+ if (p->min)
+ *t++ = '?';
+ continue;
+ case '^':
+ case '.':
+ case '$':
+ *t++ = '\\';
+ *t++ = c;
+ continue;
+ case '|':
+ if (t == buf || *(t - 1) == '(')
+ return 0;
+ logical:
+ if (!*s || *s == ')')
+ return 0;
+ /*FALLTHROUGH*/
+ default:
+ *t++ = c;
+ continue;
+ }
+ break;
+ }
+ if (p != stack)
+ return 0;
+ if (end)
+ *t++ = '$';
+ *t = 0;
+ return buf;
+}
diff --git a/usr/src/lib/libast/common/string/fmtscale.c b/usr/src/lib/libast/common/string/fmtscale.c
new file mode 100644
index 0000000000..1c012b4c0d
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtscale.c
@@ -0,0 +1,94 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * return number n scaled to metric multiples of k { 1000 1024 }
+ * return string length is at most 5 chars + terminating nul
+ */
+
+#include <ast.h>
+#include <lclib.h>
+
+char*
+fmtscale(register Sfulong_t n, int k)
+{
+ register Sfulong_t m;
+ int r;
+ int z;
+ const char* u;
+ char suf[3];
+ char* s;
+ char* buf;
+ Lc_numeric_t* p = (Lc_numeric_t*)LCINFO(AST_LC_NUMERIC)->data;
+
+ static const char scale[] = "bkMGTPE";
+
+ u = scale;
+ if (n < 1000)
+ r = 0;
+ else
+ {
+ m = 0;
+ while (n >= k && *(u + 1))
+ {
+ m = n;
+ n /= k;
+ u++;
+ }
+ if ((r = (10 * (m % k) + (k / 2)) / k) > 9)
+ {
+ r = 0;
+ n++;
+ }
+ if (k == 1024 && n >= 1000)
+ {
+ n = 1;
+ r = 0;
+ u++;
+ }
+ }
+ buf = fmtbuf(z = 8);
+ s = suf;
+ if (u > scale)
+ {
+ if (k == 1024)
+ {
+ *s++ = *u == 'k' ? 'K' : *u;
+ *s++ = 'i';
+ }
+ else
+ *s++ = *u;
+ }
+ *s = 0;
+ if (n > 0 && n < 10)
+ sfsprintf(buf, z, "%I*u%c%d%s", sizeof(n), n, p->decimal >= 0 ? p->decimal : '.', r, suf);
+ else
+ {
+ if (r >= 5)
+ n++;
+ sfsprintf(buf, z, "%I*u%s", sizeof(n), n, suf);
+ }
+ return buf;
+}
diff --git a/usr/src/lib/libast/common/string/fmtsignal.c b/usr/src/lib/libast/common/string/fmtsignal.c
new file mode 100644
index 0000000000..a555f0f522
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtsignal.c
@@ -0,0 +1,62 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * if sig>=0 then return signal text for signal sig
+ * otherwise return signal name for signal -sig
+ */
+
+#include <ast.h>
+#include <sig.h>
+
+char*
+fmtsignal(register int sig)
+{
+ char* buf;
+ int z;
+
+ if (sig >= 0)
+ {
+ if (sig <= sig_info.sigmax)
+ buf = sig_info.text[sig];
+ else
+ {
+ buf = fmtbuf(z = 20);
+ sfsprintf(buf, z, "Signal %d", sig);
+ }
+ }
+ else
+ {
+ sig = -sig;
+ if (sig <= sig_info.sigmax)
+ buf = sig_info.name[sig];
+ else
+ {
+ buf = fmtbuf(z = 20);
+ sfsprintf(buf, z, "%d", sig);
+ }
+ }
+ return buf;
+}
diff --git a/usr/src/lib/libast/common/string/fmttime.c b/usr/src/lib/libast/common/string/fmttime.c
new file mode 100644
index 0000000000..a8094007c4
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmttime.c
@@ -0,0 +1,41 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * return tmfmt() formatted time
+ */
+
+#include "tm.h"
+
+char*
+fmttime(const char* format, time_t clock)
+{
+ char* buf;
+ int z;
+
+ buf = fmtbuf(z = 80);
+ tmfmt(buf, z, format, &clock);
+ return buf;
+}
diff --git a/usr/src/lib/libast/common/string/fmttmx.c b/usr/src/lib/libast/common/string/fmttmx.c
new file mode 100644
index 0000000000..c2c785ab21
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmttmx.c
@@ -0,0 +1,45 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <tmx.h>
+#include <tv.h>
+
+/*
+ * Time_t fmttime()
+ */
+
+char*
+fmttmx(const char* fmt, Time_t t)
+{
+ char* b;
+ char* e;
+ int z;
+
+ z = 0;
+ do
+ {
+ b = fmtbuf(z += 80);
+ e = tmxfmt(b, z, fmt, t);
+ } while (e == b + z);
+ return b;
+}
diff --git a/usr/src/lib/libast/common/string/fmttv.c b/usr/src/lib/libast/common/string/fmttv.c
new file mode 100644
index 0000000000..083d4f77d6
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmttv.c
@@ -0,0 +1,44 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <tv.h>
+#include <tm.h>
+
+/*
+ * Tv_t fmttime()
+ */
+
+char*
+fmttv(const char* fmt, Tv_t* tv)
+{
+ char* s;
+ char* t;
+ int n;
+
+ s = fmttime(fmt, (time_t)tv->tv_sec);
+ if (!tv->tv_nsec || tv->tv_nsec == TV_NSEC_IGNORE)
+ return s;
+ t = fmtbuf(n = strlen(s) + 11);
+ sfsprintf(t, n, "%s.%09lu", s, (unsigned long)tv->tv_nsec);
+ return t;
+}
diff --git a/usr/src/lib/libast/common/string/fmtuid.c b/usr/src/lib/libast/common/string/fmtuid.c
new file mode 100644
index 0000000000..8561ca426d
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtuid.c
@@ -0,0 +1,101 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * uid number -> name
+ */
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide getpwuid
+#else
+#define getpwuid ______getpwuid
+#endif
+
+#include <ast.h>
+#include <cdt.h>
+#include <pwd.h>
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide getpwuid
+#else
+#undef getpwuid
+#endif
+
+extern struct passwd* getpwuid(uid_t);
+
+typedef struct Id_s
+{
+ Dtlink_t link;
+ int id;
+ char name[1];
+} Id_t;
+
+/*
+ * return uid name given uid number
+ */
+
+char*
+fmtuid(int uid)
+{
+ register Id_t* ip;
+ register char* name;
+ register struct passwd* pw;
+ int z;
+
+ static Dt_t* dict;
+ static Dtdisc_t disc;
+
+ if (!dict)
+ {
+ disc.key = offsetof(Id_t, id);
+ disc.size = sizeof(int);
+ dict = dtopen(&disc, Dthash);
+ }
+ else if (ip = (Id_t*)dtmatch(dict, &uid))
+ return ip->name;
+ if (pw = getpwuid(uid))
+ {
+ name = pw->pw_name;
+#if _WINIX
+ if (streq(name, "Administrator"))
+ name = "root";
+#endif
+ }
+ else if (uid == 0)
+ name = "root";
+ else
+ {
+ name = fmtbuf(z = sizeof(uid) * 3 + 1);
+ sfsprintf(name, z, "%I*d", sizeof(uid), uid);
+ }
+ if (dict && (ip = newof(0, Id_t, 1, strlen(name))))
+ {
+ ip->id = uid;
+ strcpy(ip->name, name);
+ dtinsert(dict, ip);
+ return ip->name;
+ }
+ return name;
+}
diff --git a/usr/src/lib/libast/common/string/fmtversion.c b/usr/src/lib/libast/common/string/fmtversion.c
new file mode 100644
index 0000000000..7ef6a6ed62
--- /dev/null
+++ b/usr/src/lib/libast/common/string/fmtversion.c
@@ -0,0 +1,53 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * return formatted <magicid.h> version string
+ */
+
+#include <ast.h>
+
+char*
+fmtversion(register unsigned long v)
+{
+ register char* cur;
+ register char* end;
+ char* buf;
+ int n;
+
+ buf = cur = fmtbuf(n = 18);
+ end = cur + n;
+ if (v >= 19700101L)
+ sfsprintf(cur, end - cur, "%04lu-%02lu-%02lu", (v / 10000) % 10000, (v / 100) % 100, v % 100);
+ else
+ {
+ if (n = (v >> 24) & 0xff)
+ cur += sfsprintf(cur, end - cur, "%d.", n);
+ if (n = (v >> 16) & 0xff)
+ cur += sfsprintf(cur, end - cur, "%d.", n);
+ sfsprintf(cur, end - cur, "%ld.%ld", (v >> 8) & 0xff, v & 0xff);
+ }
+ return buf;
+}
diff --git a/usr/src/lib/libast/common/string/memdup.c b/usr/src/lib/libast/common/string/memdup.c
new file mode 100644
index 0000000000..98f8087fa6
--- /dev/null
+++ b/usr/src/lib/libast/common/string/memdup.c
@@ -0,0 +1,44 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#if _lib_memdup
+
+NoN(memdup)
+
+#else
+
+/*
+ * return a copy of s of n chars using malloc
+ */
+
+void*
+memdup(register const void* s, register size_t n)
+{
+ register void* t;
+
+ return((t = (void*)newof(0, char, n, 0)) ? memcpy(t, s, n) : 0);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/string/modedata.c b/usr/src/lib/libast/common/string/modedata.c
new file mode 100644
index 0000000000..d24fd99392
--- /dev/null
+++ b/usr/src/lib/libast/common/string/modedata.c
@@ -0,0 +1,69 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * fmtmode() and strperm() readonly data
+ * for external format modes
+ */
+
+#include "modelib.h"
+
+struct modeop modetab[MODELEN] =
+{
+ 0170000, 12, 0000000, 0, "-pc?d?b?-Cl?sDw?",
+ 0000400, 8, 0000000, 0, "-r",
+ 0000200, 7, 0000000, 0, "-w",
+ 0004000, 10, 0000100, 6, "-xSs",
+ 0000040, 5, 0000000, 0, "-r",
+ 0000020, 4, 0000000, 0, "-w",
+#ifdef S_ICCTYP
+ 0003000, 8, 0000010, 3, "-x-xSs-x",
+#else
+ 0002000, 9, 0000010, 3, "-xls",
+#endif
+ 0000004, 2, 0000000, 0, "-r",
+ 0000002, 1, 0000000, 0, "-w",
+#ifdef S_ICCTYP
+ 0003000, 8, 0000001, 0, "-xyY-xeE",
+#else
+ 0001000, 8, 0000001, 0, "-xTt",
+#endif
+};
+
+int permmap[PERMLEN] =
+{
+ S_ISUID, X_ISUID,
+ S_ISGID, X_ISGID,
+ S_ISVTX, X_ISVTX,
+ S_IRUSR, X_IRUSR,
+ S_IWUSR, X_IWUSR,
+ S_IXUSR, X_IXUSR,
+ S_IRGRP, X_IRGRP,
+ S_IWGRP, X_IWGRP,
+ S_IXGRP, X_IXGRP,
+ S_IROTH, X_IROTH,
+ S_IWOTH, X_IWOTH,
+ S_IXOTH, X_IXOTH
+};
diff --git a/usr/src/lib/libast/common/string/modei.c b/usr/src/lib/libast/common/string/modei.c
new file mode 100644
index 0000000000..61b351493f
--- /dev/null
+++ b/usr/src/lib/libast/common/string/modei.c
@@ -0,0 +1,55 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * mode_t representation support
+ */
+
+#include "modelib.h"
+
+/*
+ * convert external mode to internal
+ *
+ * NOTE: X_IFMT ignored
+ */
+
+#undef modei
+
+int
+modei(register int x)
+{
+#if _S_IDPERM
+ return(x & X_IPERM);
+#else
+ register int i;
+ register int c;
+
+ i = 0;
+ for (c = 0; c < PERMLEN; c += 2)
+ if (x & permmap[c + 1])
+ i |= permmap[c];
+ return(i);
+#endif
+}
diff --git a/usr/src/lib/libast/common/string/modelib.h b/usr/src/lib/libast/common/string/modelib.h
new file mode 100644
index 0000000000..12a67200f7
--- /dev/null
+++ b/usr/src/lib/libast/common/string/modelib.h
@@ -0,0 +1,55 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * mode_t common definitions
+ */
+
+#ifndef _MODELIB_H
+#define _MODELIB_H
+
+#include <ast.h>
+#include <ls.h>
+#include <modex.h>
+
+#define MODELEN 10
+#define PERMLEN 24
+
+#define modetab _mode_table_ /* data hiding */
+#define permmap _mode_permmap_ /* data hiding */
+
+struct modeop /* ops for each char in mode string */
+{
+ int mask1; /* first mask */
+ int shift1; /* first shift count */
+ int mask2; /* second mask */
+ int shift2; /* second shift count */
+ char* name; /* mode char using mask/shift as index */
+};
+
+extern struct modeop modetab[];
+extern int permmap[];
+
+#endif
diff --git a/usr/src/lib/libast/common/string/modex.c b/usr/src/lib/libast/common/string/modex.c
new file mode 100644
index 0000000000..6c1e0f1604
--- /dev/null
+++ b/usr/src/lib/libast/common/string/modex.c
@@ -0,0 +1,75 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * mode_t representation support
+ */
+
+#include "modelib.h"
+
+/*
+ * convert internal mode to external
+ */
+
+#undef modex
+
+int
+modex(register int i)
+{
+#if _S_IDPERM && _S_IDTYPE
+ return(i);
+#else
+ register int x;
+ register int c;
+
+ x = 0;
+#if _S_IDPERM
+ x |= (i & 07777);
+#else
+ for (c = 0; c < PERMLEN; c++)
+ if (i & permmap[c++])
+ x |= permmap[c];
+#endif
+#if _S_IDTYPE
+ x |= (i & X_IFMT);
+#else
+ if (S_ISREG(i)) x |= X_IFREG;
+ else if (S_ISDIR(i)) x |= X_IFDIR;
+#ifdef S_ISLNK
+ else if (S_ISLNK(i)) x |= X_IFLNK;
+#endif
+ else if (S_ISBLK(i)) x |= X_IFBLK;
+ else if (S_ISCHR(i)) x |= X_IFCHR;
+#ifdef S_ISCTG
+ else if (S_ISCTG(i)) x |= X_IFCTG;
+#endif
+ else if (S_ISFIFO(i)) x |= X_IFIFO;
+#ifdef S_ISSOCK
+ else if (S_ISSOCK(i)) x |= X_IFSOCK;
+#endif
+#endif
+ return(x);
+#endif
+}
diff --git a/usr/src/lib/libast/common/string/stracmp.c b/usr/src/lib/libast/common/string/stracmp.c
new file mode 100644
index 0000000000..330b7655cc
--- /dev/null
+++ b/usr/src/lib/libast/common/string/stracmp.c
@@ -0,0 +1,62 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * ccmapchr(ccmap(CC_NATIVE,CC_ASCII),c) and strcmp
+ */
+
+#include <ast.h>
+#include <ccode.h>
+
+#if _lib_stracmp
+
+NoN(stracmp)
+
+#else
+
+#include <ctype.h>
+
+int
+stracmp(const char* aa, const char* ab)
+{
+ register unsigned char* a;
+ register unsigned char* b;
+ register unsigned char* m;
+ register int c;
+ register int d;
+
+ if (!(m = ccmap(CC_NATIVE, CC_ASCII)))
+ return strcmp(aa, ab);
+ a = (unsigned char*)aa;
+ b = (unsigned char*)ab;
+ for (;;)
+ {
+ c = m[*a++];
+ if (d = c - m[*b++])
+ return d;
+ if (!c)
+ return 0;
+ }
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/string/strcopy.c b/usr/src/lib/libast/common/string/strcopy.c
new file mode 100644
index 0000000000..d14cd37940
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strcopy.c
@@ -0,0 +1,36 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+/*
+ * copy t into s, return a pointer to the end of s ('\0')
+ */
+
+char*
+strcopy(register char* s, register const char* t)
+{
+ if (!t) return(s);
+ while (*s++ = *t++);
+ return(--s);
+}
diff --git a/usr/src/lib/libast/common/string/strdup.c b/usr/src/lib/libast/common/string/strdup.c
new file mode 100644
index 0000000000..96b0ec4114
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strdup.c
@@ -0,0 +1,44 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#undef VMDEBUG
+#define VMDEBUG 0
+
+#include <ast.h>
+
+/*
+ * return a copy of s using malloc
+ */
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern char*
+strdup(register const char* s)
+{
+ register char* t;
+ register int n;
+
+ return (s && (t = newof(0, char, n = strlen(s) + 1, 0))) ? (char*)memcpy(t, s, n) : (char*)0;
+}
diff --git a/usr/src/lib/libast/common/string/strelapsed.c b/usr/src/lib/libast/common/string/strelapsed.c
new file mode 100644
index 0000000000..a64719fa12
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strelapsed.c
@@ -0,0 +1,142 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * parse elapsed time in 1/n secs from s
+ * compatible with fmtelapsed()
+ * also handles ps [day-][hour:]min:sec
+ * also handles coshell % for 'infinity'
+ * if e!=0 then it is set to first unrecognized char
+ */
+
+#include <ast.h>
+#include <ctype.h>
+
+unsigned long
+strelapsed(register const char* s, char** e, int n)
+{
+ register int c;
+ register unsigned long v;
+ unsigned long t = 0;
+ int f = 0;
+ int p = 0;
+ int m;
+ const char* last;
+
+ for (;;)
+ {
+ while (isspace(*s) || *s == '_')
+ s++;
+ if (!*(last = s))
+ break;
+ v = 0;
+ while ((c = *s++) >= '0' && c <= '9')
+ v = v * 10 + c - '0';
+ v *= n;
+ if (c == '.')
+ for (m = n; (c = *s++) >= '0' && c <= '9';)
+ f += (m /= 10) * (c - '0');
+ if (c == '%')
+ {
+ t = ~t;
+ last = s;
+ break;
+ }
+ if (s == last + 1)
+ break;
+ if (!p)
+ while (isspace(c) || c == '_')
+ c = *s++;
+ switch (c)
+ {
+ case 'S':
+ if (*s == 'E' || *s == 'e')
+ {
+ v += f;
+ f = 0;
+ }
+ else
+ v *= 20 * 12 * 4 * 7 * 24 * 60 * 60;
+ break;
+ case 'y':
+ case 'Y':
+ v *= 12 * 4 * 7 * 24 * 60 * 60;
+ break;
+ case 'M':
+ if (*s == 'I' || *s == 'i')
+ v *= 60;
+ else
+ v *= 4 * 7 * 24 * 60 * 60;
+ break;
+ case 'w':
+ v *= 7 * 24 * 60 * 60;
+ break;
+ case '-':
+ p = 1;
+ /*FALLTHROUGH*/
+ case 'd':
+ v *= 24 * 60 * 60;
+ break;
+ case 'h':
+ v *= 60 * 60;
+ break;
+ case ':':
+ p = 1;
+ v *= strchr(s, ':') ? (60 * 60) : 60;
+ break;
+ case 'm':
+ if (*s == 'o')
+ v *= 4 * 7 * 24 * 60 * 60;
+ else
+ v *= 60;
+ break;
+ case 's':
+ if (*s == 'c')
+ {
+ v *= 20 * 12 * 4 * 7 * 24 * 60 * 60;
+ break;
+ }
+ /*FALLTHROUGH*/
+ case 0:
+ v += f;
+ f = 0;
+ break;
+ default:
+ if (p)
+ {
+ last = s - 1;
+ t += v + f;
+ }
+ goto done;
+ }
+ t += v;
+ while (isalpha(*s))
+ s++;
+ }
+ done:
+ if (e)
+ *e = (char*)last;
+ return t;
+}
diff --git a/usr/src/lib/libast/common/string/strerror.c b/usr/src/lib/libast/common/string/strerror.c
new file mode 100644
index 0000000000..d053683052
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strerror.c
@@ -0,0 +1,147 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * return error message string given errno
+ */
+
+#include <ast.h>
+#include <error.h>
+
+#include "FEATURE/errno"
+
+#undef strerror
+
+#if !defined(sys_errlist) && !_def_errno_sys_errlist
+#if _dat_sys_errlist
+extern char* sys_errlist[];
+#else
+#undef _dat_sys_nerr
+char* sys_errlist[] = { 0 };
+#endif
+#endif
+
+#if !defined(sys_nerr) && !_def_errno_sys_nerr
+#if _dat_sys_nerr
+extern int sys_nerr;
+#else
+#undef _dat_sys_nerr
+int sys_nerr = 0;
+#endif
+#endif
+
+#if _lib_strerror
+extern char* strerror(int);
+#endif
+
+#if _PACKAGE_astsa
+
+#define fmtbuf(n) ((n),tmp)
+
+static char tmp[32];
+
+#endif
+
+char*
+_ast_strerror(int err)
+{
+ char* msg;
+ int z;
+
+#if _lib_strerror
+ z = errno;
+ msg = strerror(err);
+ errno = z;
+#else
+ if (err > 0 && err <= sys_nerr)
+ msg = (char*)sys_errlist[err];
+ else
+ msg = 0;
+#endif
+ if (msg)
+ {
+#if !_PACKAGE_astsa
+ if (ERROR_translating())
+ {
+#if _lib_strerror
+ static int sys;
+
+ if (!sys)
+ {
+ char* s;
+ char* t;
+ char* p;
+
+#if _lib_strerror
+ /*
+ * stash the pending strerror() msg
+ */
+
+ msg = strcpy(fmtbuf(strlen(msg) + 1), msg);
+#endif
+
+ /*
+ * make sure that strerror() translates
+ */
+
+ if (!(s = strerror(1)))
+ sys = -1;
+ else
+ {
+ t = fmtbuf(z = strlen(s) + 1);
+ strcpy(t, s);
+ p = setlocale(LC_MESSAGES, NiL);
+ setlocale(LC_MESSAGES, "C");
+ sys = (s = strerror(1)) && strcmp(s, t) ? 1 : -1;
+ setlocale(LC_MESSAGES, p);
+ }
+ }
+ if (sys > 0)
+ return msg;
+#endif
+ return ERROR_translate(NiL, NiL, "errlist", msg);
+ }
+#endif
+ return msg;
+ }
+ msg = fmtbuf(z = 32);
+ sfsprintf(msg, z, ERROR_translate(NiL, NiL, "errlist", "Error %d"), err);
+ return msg;
+}
+
+#if !_lib_strerror
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern char*
+strerror(int err)
+{
+ return _ast_strerror(err);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/string/stresc.c b/usr/src/lib/libast/common/string/stresc.c
new file mode 100644
index 0000000000..f6f0026eb9
--- /dev/null
+++ b/usr/src/lib/libast/common/string/stresc.c
@@ -0,0 +1,58 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * convert \X character constants in s in place
+ * the length of the converted s is returned (may have embedded \0's)
+ */
+
+#include <ast.h>
+
+int
+stresc(register char* s)
+{
+ register char* t;
+ register unsigned int c;
+ char* b;
+ char* e;
+
+ b = t = s;
+ while (c = *s++)
+ {
+ if (c == '\\')
+ {
+ c = chresc(s - 1, &e);
+ s = e;
+ if (c > UCHAR_MAX)
+ {
+ t += wctomb(t, c);
+ continue;
+ }
+ }
+ *t++ = c;
+ }
+ *t = 0;
+ return t - b;
+}
diff --git a/usr/src/lib/libast/common/string/streval.c b/usr/src/lib/libast/common/string/streval.c
new file mode 100644
index 0000000000..adc8000f2d
--- /dev/null
+++ b/usr/src/lib/libast/common/string/streval.c
@@ -0,0 +1,50 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * obsolete streval() interface to strexpr()
+ */
+
+#include <ast.h>
+
+typedef long (*Old_convert_t)(const char*, char**);
+
+typedef long (*Convert_t)(const char*, char**, void*);
+
+typedef struct
+{
+ Old_convert_t convert;
+} Handle_t;
+
+static long
+userconv(const char* s, char** end, void* handle)
+{
+ return((*((Handle_t*)handle)->convert)(s, end));
+}
+
+long
+streval(const char* s, char** end, Old_convert_t convert)
+{
+ Handle_t handle;
+
+ return((handle.convert = convert) ? strexpr(s, end, userconv, &handle) : strexpr(s, end, (Convert_t)0, NiL));
+}
diff --git a/usr/src/lib/libast/common/string/strexpr.c b/usr/src/lib/libast/common/string/strexpr.c
new file mode 100644
index 0000000000..bd4fa6aa76
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strexpr.c
@@ -0,0 +1,294 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * G. S. Fowler
+ * D. G. Korn
+ * AT&T Bell Laboratories
+ *
+ * long integer arithmetic expression evaluator
+ * long constants may be represented as:
+ *
+ * 0ooo octal
+ * 0[xX]hhh hexadecimal
+ * ddd decimal
+ * n#ccc base n, 2 <= b <= 36
+ *
+ * NOTE: all operands are evaluated as both the parse
+ * and evaluation are done on the fly
+ */
+
+#include <ast.h>
+#include <ctype.h>
+
+#define getchr(ex) (*(ex)->nextchr++)
+#define peekchr(ex) (*(ex)->nextchr)
+#define ungetchr(ex) ((ex)->nextchr--)
+
+#define error(ex,msg) return(seterror(ex,msg))
+
+typedef struct /* expression handle */
+{
+ char* nextchr; /* next expression char */
+ char* errchr; /* next char after error */
+ char* errmsg; /* error message text */
+ long (*convert)(const char*, char**, void*);
+ void* handle; /* user convert handle */
+} Expr_t;
+
+/*
+ * set error message string
+ */
+
+static long
+seterror(register Expr_t* ex, char* msg)
+{
+ if (!ex->errmsg) ex->errmsg = msg;
+ ex->errchr = ex->nextchr;
+ ex->nextchr = "";
+ return(0);
+}
+
+/*
+ * evaluate a subexpression with precedence
+ */
+
+static long
+expr(register Expr_t* ex, register int precedence)
+{
+ register int c;
+ register long n;
+ register long x;
+ char* pos;
+ int operand = 1;
+
+ while (c = getchr(ex), isspace(c));
+ switch (c)
+ {
+ case 0:
+ ungetchr(ex);
+ if (!precedence) return(0);
+ error(ex, "more tokens expected");
+ case '-':
+ n = -expr(ex, 13);
+ break;
+ case '+':
+ n = expr(ex, 13);
+ break;
+ case '!':
+ n = !expr(ex, 13);
+ break;
+ case '~':
+ n = ~expr(ex, 13);
+ break;
+ default:
+ ungetchr(ex);
+ n = 0;
+ operand = 0;
+ break;
+ }
+ for (;;)
+ {
+ switch (c = getchr(ex))
+ {
+ case 0:
+ goto done;
+ case ')':
+ if (!precedence) error(ex, "too many )'s");
+ goto done;
+ case '(':
+ n = expr(ex, 1);
+ if (getchr(ex) != ')')
+ {
+ ungetchr(ex);
+ error(ex, "closing ) expected");
+ }
+ gotoperand:
+ if (operand) error(ex, "operator expected");
+ operand = 1;
+ continue;
+ case '?':
+ if (precedence > 1) goto done;
+ if (peekchr(ex) == ':')
+ {
+ getchr(ex);
+ x = expr(ex, 2);
+ if (!n) n = x;
+ }
+ else
+ {
+ x = expr(ex, 2);
+ if (getchr(ex) != ':')
+ {
+ ungetchr(ex);
+ error(ex, ": expected for ? operator");
+ }
+ if (n)
+ {
+ n = x;
+ expr(ex, 2);
+ }
+ else n = expr(ex, 2);
+ }
+ break;
+ case ':':
+ goto done;
+ case '|':
+ if (peekchr(ex) == '|')
+ {
+ if (precedence > 2) goto done;
+ getchr(ex);
+ x = expr(ex, 3);
+ n = n || x;
+ }
+ else
+ {
+ if (precedence > 4) goto done;
+ x = expr(ex, 5);
+ n |= x;
+ }
+ break;
+ case '^':
+ if (precedence > 5) goto done;
+ x = expr(ex, 6);
+ n ^= x;
+ break;
+ case '&':
+ if (peekchr(ex) == '&')
+ {
+ if (precedence > 3) goto done;
+ getchr(ex);
+ x = expr(ex, 4);
+ n = n && x;
+ }
+ else
+ {
+ if (precedence > 6) goto done;
+ x = expr(ex, 7);
+ n &= x;
+ }
+ break;
+ case '=':
+ case '!':
+ if (peekchr(ex) != '=') error(ex, "operator syntax error");
+ if (precedence > 7) goto done;
+ getchr(ex);
+ x = expr(ex, 8);
+ if (c == '=') n = n == x;
+ else n = n != x;
+ break;
+ case '<':
+ case '>':
+ if (peekchr(ex) == c)
+ {
+ if (precedence > 9) goto done;
+ getchr(ex);
+ x = expr(ex, 10);
+ if (c == '<') n <<= x;
+ else n >>= x;
+ }
+ else
+ {
+ if (precedence > 8) goto done;
+ if (peekchr(ex) == '=')
+ {
+ getchr(ex);
+ x = expr(ex, 9);
+ if (c == '<') n = n <= x;
+ else n = n >= x;
+ }
+ else
+ {
+ x = expr(ex, 9);
+ if (c == '<') n = n < x;
+ else n = n > x;
+ }
+ }
+ break;
+ case '+':
+ case '-':
+ if (precedence > 10) goto done;
+ x = expr(ex, 11);
+ if (c == '+') n += x;
+ else n -= x;
+ break;
+ case '*':
+ case '/':
+ case '%':
+ if (precedence > 11) goto done;
+ x = expr(ex, 12);
+ if (c == '*') n *= x;
+ else if (x == 0) error(ex, "divide by zero");
+ else if (c == '/') n /= x;
+ else n %= x;
+ break;
+ default:
+ if (isspace(c)) continue;
+ pos = --ex->nextchr;
+ if (isdigit(c)) n = strton(ex->nextchr, &ex->nextchr, NiL, 0);
+ else if (ex->convert) n = (*ex->convert)(ex->nextchr, &ex->nextchr, ex->handle);
+ if (ex->nextchr == pos) error(ex, "syntax error");
+ goto gotoperand;
+ }
+ if (ex->errmsg) return(0);
+ if (!operand) error(ex, "operand expected");
+ }
+ done:
+ ungetchr(ex);
+ if (!operand) error(ex, "operand expected");
+ return(n);
+}
+
+/*
+ * evaluate an integer arithmetic expression in s
+ *
+ * (long)(*convert)(const char* string, char** end, void* handle)
+ * is a user supplied conversion routine that is called when unknown
+ * chars are encountered; string points to the part to be
+ * converted and end is adjusted to point to the next non-converted
+ * character; if string is 0 then end points to an error message string
+ *
+ * NOTE: (*convert)() may call strexpr(ex, )
+ */
+
+long
+strexpr(const char* s, char** end, long(*convert)(const char*, char**, void*), void* handle)
+{
+ long n;
+ Expr_t ex;
+
+ ex.nextchr = (char*)s;
+ ex.errmsg = 0;
+ ex.convert = convert;
+ ex.handle = handle;
+ n = expr(&ex, 0);
+ if (peekchr(&ex) == ':')
+ seterror(&ex, "invalid use of :");
+ if (ex.errmsg)
+ {
+ if (convert) (*convert)(NiL, &ex.errmsg, handle);
+ ex.nextchr = ex.errchr;
+ n = 0;
+ }
+ if (end) *end = ex.nextchr;
+ return(n);
+}
diff --git a/usr/src/lib/libast/common/string/strgid.c b/usr/src/lib/libast/common/string/strgid.c
new file mode 100644
index 0000000000..10efdbdb99
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strgid.c
@@ -0,0 +1,121 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * gid name -> number
+ */
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide getgrgid getgrnam getpwnam
+#else
+#define getgrgid ______getgrgid
+#define getgrnam ______getgrnam
+#define getpwnam ______getpwnam
+#endif
+
+#include <ast.h>
+#include <cdt.h>
+#include <pwd.h>
+#include <grp.h>
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide getgrgid getgrnam getpwnam
+#else
+#undef getgrgid
+#undef getgrnam
+#undef getpwnam
+#endif
+
+extern struct group* getgrgid(gid_t);
+extern struct group* getgrnam(const char*);
+extern struct passwd* getpwnam(const char*);
+
+typedef struct Id_s
+{
+ Dtlink_t link;
+ int id;
+ char name[1];
+} Id_t;
+
+/*
+ * return gid number given gid/uid name
+ * gid attempted first, then uid->pw_gid
+ * -1 on first error for a given name
+ * -2 on subsequent errors for a given name
+ */
+
+int
+strgid(const char* name)
+{
+ register Id_t* ip;
+ register struct group* gr;
+ register struct passwd* pw;
+ int id;
+ char* e;
+
+ static Dt_t* dict;
+ static Dtdisc_t disc;
+
+ if (!dict)
+ {
+ disc.key = offsetof(Id_t, name);
+ dict = dtopen(&disc, Dthash);
+ }
+ else if (ip = (Id_t*)dtmatch(dict, name))
+ return ip->id;
+ if (gr = getgrnam(name))
+ id = gr->gr_gid;
+ else if (pw = getpwnam(name))
+ id = pw->pw_gid;
+ else
+ {
+ id = strtol(name, &e, 0);
+#if _WINIX
+ if (!*e)
+ {
+ if (!getgrgid(id))
+ id = -1;
+ }
+ else if (!streq(name, "sys"))
+ id = -1;
+ else if (gr = getgrnam("Administrators"))
+ id = gr->gr_gid;
+ else if (pw = getpwnam("Administrator"))
+ id = pw->pw_gid;
+ else
+ id = -1;
+#else
+ if (*e || !getgrgid(id))
+ id = -1;
+#endif
+ }
+ if (dict && (ip = newof(0, Id_t, 1, strlen(name))))
+ {
+ strcpy(ip->name, name);
+ ip->id = id >= 0 ? id : -2;
+ dtinsert(dict, ip);
+ }
+ return id;
+}
diff --git a/usr/src/lib/libast/common/string/strlcat.c b/usr/src/lib/libast/common/string/strlcat.c
new file mode 100644
index 0000000000..05dda0fcbe
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strlcat.c
@@ -0,0 +1,78 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * strlcat implementation
+ */
+
+#define strlcat ______strlcat
+
+#include <ast.h>
+
+#undef strlcat
+
+#undef _def_map_ast
+#include <ast_map.h>
+
+#if _lib_strlcat
+
+NoN(strlcat)
+
+#else
+
+/*
+ * append at t onto s limiting total size of s to n
+ * s 0 terminated if n>0
+ * min(n,strlen(s))+strlen(t) returned
+ */
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern size_t
+strlcat(register char* s, register const char* t, register size_t n)
+{
+ const char* o = t;
+
+ if (n)
+ {
+ while (--n && *s)
+ s++;
+ if (n)
+ do
+ {
+ if (!--n)
+ {
+ *s = 0;
+ break;
+ }
+ } while (*s++ = *t++);
+ else
+ *s = 0;
+ }
+ if (!n)
+ while (*t++);
+ return t - o - 1;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/string/strlcpy.c b/usr/src/lib/libast/common/string/strlcpy.c
new file mode 100644
index 0000000000..7849db81b6
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strlcpy.c
@@ -0,0 +1,71 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * strlcpy implementation
+ */
+
+#define strlcpy ______strlcpy
+
+#include <ast.h>
+
+#undef strlcpy
+
+#undef _def_map_ast
+#include <ast_map.h>
+
+#if _lib_strlcpy
+
+NoN(strlcpy)
+
+#else
+
+/*
+ * copy at most n chars from t into s
+ * result 0 terminated if n>0
+ * strlen(t) returned
+ */
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern size_t
+strlcpy(register char* s, register const char* t, register size_t n)
+{
+ const char* o = t;
+
+ if (n)
+ do
+ {
+ if (!--n)
+ {
+ *s = 0;
+ break;
+ }
+ } while (*s++ = *t++);
+ if (!n)
+ while (*t++);
+ return t - o - 1;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/string/strlook.c b/usr/src/lib/libast/common/string/strlook.c
new file mode 100644
index 0000000000..43df592ea6
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strlook.c
@@ -0,0 +1,50 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ */
+
+#include <ast.h>
+
+/*
+ * return pointer to name in tab with element size siz
+ * where the first member of each element is a char*
+ *
+ * the last name in tab must be 0
+ *
+ * 0 returned if name not found
+ */
+
+void*
+strlook(const void* tab, size_t siz, register const char* name)
+{
+ register char* t = (char*)tab;
+ register char* s;
+ register int c = *name;
+
+ for (; s = *((char**)t); t += siz)
+ if (*s == c && !strcmp(s, name))
+ return (void*)t;
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/string/strmatch.c b/usr/src/lib/libast/common/string/strmatch.c
new file mode 100644
index 0000000000..169cf84ebf
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strmatch.c
@@ -0,0 +1,167 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * D. G. Korn
+ * G. S. Fowler
+ * AT&T Research
+ *
+ * match shell file patterns
+ * this interface is a wrapper on regex
+ *
+ * sh pattern egrep RE description
+ * ---------- -------- -----------
+ * * .* 0 or more chars
+ * ? . any single char
+ * [.] [.] char class
+ * [!.] [^.] negated char class
+ * [[:.:]] [[:.:]] ctype class
+ * [[=.=]] [[=.=]] equivalence class
+ * [[...]] [[...]] collation element
+ * *(.) (.)* 0 or more of
+ * +(.) (.)+ 1 or more of
+ * ?(.) (.)? 0 or 1 of
+ * (.) (.) 1 of
+ * @(.) (.) 1 of
+ * a|b a|b a or b
+ * \# () subgroup back reference [1-9]
+ * a&b a and b
+ * !(.) none of
+ *
+ * \ used to escape metacharacters
+ *
+ * *, ?, (, |, &, ), [, \ must be \'d outside of [...]
+ * only ] must be \'d inside [...]
+ *
+ */
+
+#include <ast.h>
+#include <regex.h>
+
+static struct State_s
+{
+ regmatch_t* match;
+ int nmatch;
+} matchstate;
+
+/*
+ * subgroup match
+ * 0 returned if no match
+ * otherwise number of subgroups matched returned
+ * match group begin offsets are even elements of sub
+ * match group end offsets are odd elements of sub
+ * the matched string is from s+sub[0] up to but not
+ * including s+sub[1]
+ */
+
+int
+strgrpmatch(const char* b, const char* p, int* sub, int n, register int flags)
+{
+ register regex_t* re;
+ register int* end;
+ register int i;
+ register regflags_t reflags;
+
+ /*
+ * 0 and empty patterns are special
+ */
+
+ if (!p || !b)
+ {
+ if (!p && !b)
+ regcache(NiL, 0, NiL);
+ return 0;
+ }
+ if (!*p)
+ return *b == 0;
+
+ /*
+ * convert flags
+ */
+
+ if (flags & REG_ADVANCE)
+ reflags = flags & ~REG_ADVANCE;
+ else
+ {
+ reflags = REG_SHELL|REG_AUGMENTED;
+ if (!(flags & STR_MAXIMAL))
+ reflags |= REG_MINIMAL;
+ if (flags & STR_GROUP)
+ reflags |= REG_SHELL_GROUP;
+ if (flags & STR_LEFT)
+ reflags |= REG_LEFT;
+ if (flags & STR_RIGHT)
+ reflags |= REG_RIGHT;
+ if (flags & STR_ICASE)
+ reflags |= REG_ICASE;
+ }
+ if (!sub || n <= 0)
+ reflags |= REG_NOSUB;
+ if (!(re = regcache(p, reflags, NiL)))
+ return 0;
+ if (n > matchstate.nmatch)
+ {
+ if (!(matchstate.match = newof(matchstate.match, regmatch_t, n, 0)))
+ return 0;
+ matchstate.nmatch = n;
+ }
+ if (regexec(re, b, n, matchstate.match, reflags & ~(REG_MINIMAL|REG_SHELL_GROUP|REG_LEFT|REG_RIGHT|REG_ICASE)))
+ return 0;
+ if (!sub || n <= 0)
+ return 1;
+ i = re->re_nsub;
+ end = sub + n * 2;
+ for (n = 0; sub < end && n <= i; n++)
+ {
+ *sub++ = matchstate.match[n].rm_so;
+ *sub++ = matchstate.match[n].rm_eo;
+ }
+ return i + 1;
+}
+
+/*
+ * compare the string s with the shell pattern p
+ * returns 1 for match 0 otherwise
+ */
+
+int
+strmatch(const char* s, const char* p)
+{
+ return strgrpmatch(s, p, NiL, 0, STR_MAXIMAL|STR_LEFT|STR_RIGHT);
+}
+
+/*
+ * leading substring match
+ * first char after end of substring returned
+ * 0 returned if no match
+ *
+ * OBSOLETE: use strgrpmatch()
+ */
+
+char*
+strsubmatch(const char* s, const char* p, int flags)
+{
+ int match[2];
+
+ return strgrpmatch(s, p, match, 1, (flags ? STR_MAXIMAL : 0)|STR_LEFT) ? (char*)s + match[1] : (char*)0;
+}
diff --git a/usr/src/lib/libast/common/string/strmode.c b/usr/src/lib/libast/common/string/strmode.c
new file mode 100644
index 0000000000..ba33716bc8
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strmode.c
@@ -0,0 +1,51 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * G. S. Fowler
+ * AT&T Bell Laboratories
+ *
+ * return modex canonical representation of file mode bits
+ * given ls -l style file mode string
+ */
+
+#include "modelib.h"
+
+int
+strmode(register const char* s)
+{
+ register int c;
+ register char* t;
+ register struct modeop* p;
+ int mode;
+
+ mode = 0;
+ for (p = modetab; (c = *s++) && p < &modetab[MODELEN]; p++)
+ for (t = p->name; *t; t++)
+ if (*t == c)
+ {
+ c = t - p->name;
+ mode |= (p->mask1 & (c << p->shift1)) | (p->mask2 & (c << p->shift2));
+ break;
+ }
+ return(mode);
+}
diff --git a/usr/src/lib/libast/common/string/strnacmp.c b/usr/src/lib/libast/common/string/strnacmp.c
new file mode 100644
index 0000000000..a77d33074e
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strnacmp.c
@@ -0,0 +1,66 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * ccmapc(c, CC_NATIVE, CC_ASCII) and strncmp
+ */
+
+#include <ast.h>
+#include <ccode.h>
+
+#if _lib_strnacmp
+
+NoN(strnacmp)
+
+#else
+
+#include <ctype.h>
+
+int
+strnacmp(const char* a, const char* b, size_t n)
+{
+#if CC_NATIVE == CC_ASCII
+ return strncmp(a, b, n);
+#else
+ register unsigned char* ua = (unsigned char*)a;
+ register unsigned char* ub = (unsigned char*)b;
+ register unsigned char* ue;
+ register unsigned char* m;
+ register int c;
+ register int d;
+
+ m = ccmap(CC_NATIVE, CC_ASCII);
+ ue = ua + n;
+ while (ua < ue)
+ {
+ c = m[*ua++];
+ if (d = c - m[*ub++])
+ return d;
+ if (!c)
+ return 0;
+ }
+ return 0;
+#endif
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/string/strncopy.c b/usr/src/lib/libast/common/string/strncopy.c
new file mode 100644
index 0000000000..c25142f391
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strncopy.c
@@ -0,0 +1,46 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+/*
+ * copy up to n bytes of string f into t
+ * trailing 0 always added to t, even if n==0
+ * pointer to the copied 0 returned
+ */
+
+char*
+strncopy(register char* t, register const char* f, size_t n)
+{
+ register char* e = t + n - 1;
+
+ do
+ {
+ if (t >= e)
+ {
+ *t = 0;
+ return t;
+ }
+ } while (*t++ = *f++);
+ return t - 1;
+}
diff --git a/usr/src/lib/libast/common/string/strntod.c b/usr/src/lib/libast/common/string/strntod.c
new file mode 100644
index 0000000000..29ea63403f
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strntod.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * strntod() implementation
+ */
+
+#include <ast.h>
+
+#define S2F_function strntod
+#define S2F_type 1
+#define S2F_size 1
+
+#include "sfstrtof.h"
diff --git a/usr/src/lib/libast/common/string/strntol.c b/usr/src/lib/libast/common/string/strntol.c
new file mode 100644
index 0000000000..59a6f50536
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strntol.c
@@ -0,0 +1,31 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * strntol() implementation
+ */
+
+#define S2I_function strntol
+#define S2I_number long
+#define S2I_unumber unsigned long
+#define S2I_size 1
+
+#include "strtoi.h"
diff --git a/usr/src/lib/libast/common/string/strntold.c b/usr/src/lib/libast/common/string/strntold.c
new file mode 100644
index 0000000000..525ed5929b
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strntold.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * strntold() implementation
+ */
+
+#include <ast.h>
+
+#define S2F_function strntold
+#define S2F_type 2
+#define S2F_size 1
+
+#include "sfstrtof.h"
diff --git a/usr/src/lib/libast/common/string/strntoll.c b/usr/src/lib/libast/common/string/strntoll.c
new file mode 100644
index 0000000000..158fbb34ac
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strntoll.c
@@ -0,0 +1,31 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * strntoll() implementation
+ */
+
+#define S2I_function strntoll
+#define S2I_number intmax_t
+#define S2I_unumber uintmax_t
+#define S2I_size 1
+
+#include "strtoi.h"
diff --git a/usr/src/lib/libast/common/string/strntoul.c b/usr/src/lib/libast/common/string/strntoul.c
new file mode 100644
index 0000000000..ff98a61c88
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strntoul.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * strntoul() implementation
+ */
+
+#define S2I_function strntoul
+#define S2I_number long
+#define S2I_unumber unsigned long
+#define S2I_size 1
+#define S2I_unsigned 1
+
+#include "strtoi.h"
diff --git a/usr/src/lib/libast/common/string/strntoull.c b/usr/src/lib/libast/common/string/strntoull.c
new file mode 100644
index 0000000000..19f2b25717
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strntoull.c
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * strntoull() implementation
+ */
+
+#define S2I_function strntoull
+#define S2I_number intmax_t
+#define S2I_unumber uintmax_t
+#define S2I_size 1
+#define S2I_unsigned 1
+
+#include "strtoi.h"
diff --git a/usr/src/lib/libast/common/string/stropt.c b/usr/src/lib/libast/common/string/stropt.c
new file mode 100644
index 0000000000..9f28e9fb40
--- /dev/null
+++ b/usr/src/lib/libast/common/string/stropt.c
@@ -0,0 +1,188 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ */
+
+#include <ast.h>
+#include <ctype.h>
+
+/*
+ * parse option expression in s using options in tab with element size siz
+ * first element in tab must be a char*
+ * options match
+ *
+ * [no]name[[:]=['"]value["']][, ]...
+ *
+ * f is called for each option
+ *
+ * (*f)(void* a, char* p, int n, char* v)
+ *
+ * a from stropt
+ * p matching tab entry, or name if no table
+ * n 0 if option had ``no'' prefix, -1 if :=, 1 otherwise
+ * v option value pointer
+ *
+ * for unmatched options p is 0 and v is the offending option
+ *
+ * names in s may be shorter than tab names
+ * longer names must have a prefix that matches a tab name
+ * the first match is returned
+ * \ escapes value using chresc()
+ */
+
+int
+stropt(const char* as, const void* tab, int siz, int(*f)(void*, const void*, int, const char*), void* a)
+{
+ register int c;
+ register char* s;
+ register char* v;
+ register char* t;
+ char** p;
+ char* u;
+ char* x;
+ char* e;
+ int n;
+ int ql;
+ int qr;
+ int qc;
+
+ if (!as) n = 0;
+ else if (!(x = s = strdup(as))) n = -1;
+ else
+ {
+ for (;;)
+ {
+ while (isspace(*s) || *s == ',') s++;
+ if (*s == 'n' && *(s + 1) == 'o')
+ {
+ s += 2;
+ n = 0;
+ }
+ else n = 1;
+ if (!*s)
+ {
+ n = 0;
+ break;
+ }
+ if (tab)
+ {
+ for (p = (char**)tab; t = *p; p = (char**)((char*)p + siz))
+ {
+ for (v = s; *t && *t++ == *v; v++);
+ if (!*t || isspace(*v) || *v == ',' || *v == '=')
+ break;
+ if (*v == ':' && *(v + 1) == '=')
+ {
+ v++;
+ n = -1;
+ break;
+ }
+ }
+ if (!t)
+ {
+ u = v = s;
+ p = 0;
+ }
+ }
+ else
+ {
+ p = (char**)(v = s);
+ t = 0;
+ }
+ while (*v && !isspace(*v) && *v != '=' && *v != ',')
+ if (*v++ == ':' && *v == '=')
+ {
+ if (!t)
+ *(v - 1) = 0;
+ n = -n;
+ break;
+ }
+ if (*v == '=')
+ {
+ if (!t)
+ *v = 0;
+ t = s = ++v;
+ ql = qr = 0;
+ while (c = *s++)
+ {
+ if (c == '\\')
+ {
+ *t++ = chresc(s - 1, &e);
+ s = e;
+ }
+ else if (c == qr)
+ {
+ if (qr != ql)
+ *t++ = c;
+ if (--qc <= 0)
+ qr = ql = 0;
+ }
+ else if (c == ql)
+ {
+ *t++ = c;
+ qc++;
+ }
+ else if (qr)
+ *t++ = c;
+ else if (c == ',' || isspace(c))
+ break;
+ else if (c == '"' || c == '\'')
+ {
+ ql = qr = c;
+ qc = 1;
+ }
+ else
+ {
+ *t++ = c;
+ if (c == '{')
+ {
+ ql = c;
+ qr = '}';
+ qc = 1;
+ }
+ else if (c == '(')
+ {
+ ql = c;
+ qr = ')';
+ qc = 1;
+ }
+ }
+ }
+ *t = 0;
+ }
+ else
+ {
+ s = v;
+ c = *s;
+ *s++ = 0;
+ }
+ n = p ? (*f)(a, p, n, v) : (*f)(a, p, v - u, u);
+ if (n || !c)
+ break;
+ }
+ free(x);
+ }
+ return n;
+}
diff --git a/usr/src/lib/libast/common/string/strperm.c b/usr/src/lib/libast/common/string/strperm.c
new file mode 100644
index 0000000000..b54b193186
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strperm.c
@@ -0,0 +1,267 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * apply file permission expression expr to perm
+ *
+ * each expression term must match
+ *
+ * [ugoa]*[-&+|^=]?[rwxst0-7]*
+ *
+ * terms may be combined using ,
+ *
+ * if non-null, e points to the first unrecognized char in expr
+ */
+
+#include <ast.h>
+#include <ls.h>
+#include <modex.h>
+
+int
+strperm(const char* aexpr, char** e, register int perm)
+{
+ register char* expr = (char*)aexpr;
+ register int c;
+ register int typ;
+ register int who;
+ int num;
+ int op;
+ int mask;
+ int masked;
+
+ if (perm == -1)
+ {
+ perm = 0;
+ masked = 1;
+ mask = ~0;
+ }
+ else
+ masked = 0;
+ for (;;)
+ {
+ op = num = who = typ = 0;
+ for (;;)
+ {
+ switch (c = *expr++)
+ {
+ case 'u':
+ who |= S_ISVTX|S_ISUID|S_IRWXU;
+ continue;
+ case 'g':
+ who |= S_ISVTX|S_ISGID|S_IRWXG;
+ continue;
+ case 'o':
+ who |= S_ISVTX|S_IRWXO;
+ continue;
+ case 'a':
+ who = S_ISVTX|S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO;
+ continue;
+ default:
+ if (c >= '0' && c <= '7')
+ {
+ if (!who)
+ who = S_ISVTX|S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO;
+ c = '=';
+ }
+ expr--;
+ /*FALLTHROUGH*/
+ case '=':
+ if (who)
+ perm &= ~who;
+ else
+ perm = 0;
+ /*FALLTHROUGH*/
+ case '+':
+ case '|':
+ case '-':
+ case '&':
+ case '^':
+ op = c;
+ for (;;)
+ {
+ switch (c = *expr++)
+ {
+ case 'r':
+ typ |= S_IRUSR|S_IRGRP|S_IROTH;
+ continue;
+ case 'w':
+ typ |= S_IWUSR|S_IWGRP|S_IWOTH;
+ continue;
+ case 'X':
+ if (!S_ISDIR(perm) && !(perm & (S_IXUSR|S_IXGRP|S_IXOTH)))
+ continue;
+ /*FALLTHROUGH*/
+ case 'x':
+ typ |= S_IXUSR|S_IXGRP|S_IXOTH;
+ continue;
+ case 's':
+ typ |= S_ISUID|S_ISGID;
+ continue;
+ case 't':
+ typ |= S_ISVTX;
+ continue;
+ case 'l':
+ if (perm & S_IXGRP)
+ {
+ if (e)
+ *e = expr - 1;
+ return perm & S_IPERM;
+ }
+ typ |= S_ISGID;
+ continue;
+ case '=':
+ case '+':
+ case '|':
+ case '-':
+ case '&':
+ case '^':
+ case ',':
+ case 0:
+ if (who)
+ typ &= who;
+ else
+ switch (op)
+ {
+ case '=':
+ case '+':
+ case '|':
+ case '-':
+ case '&':
+ if (!masked)
+ {
+ masked = 1;
+ umask(mask = umask(0));
+ mask = ~mask;
+ }
+ typ &= mask;
+ break;
+ }
+ switch (op)
+ {
+ default:
+ if (who)
+ perm &= ~who;
+ else
+ perm = 0;
+ /*FALLTHROUGH*/
+ case '+':
+ case '|':
+ perm |= typ;
+ typ = 0;
+ break;
+ case '-':
+ perm &= ~typ;
+ typ = 0;
+ break;
+ case '&':
+ perm &= typ;
+ typ = 0;
+ break;
+ case '^':
+ if (typ &= perm)
+ {
+ /*
+ * propagate least restrictive to most restrictive
+ */
+
+ if (typ & S_IXOTH)
+ perm |= who & (S_IXUSR|S_IXGRP);
+ if (typ & S_IWOTH)
+ perm |= who & (S_IWUSR|S_IWGRP);
+ if (typ & S_IROTH)
+ perm |= who & (S_IRUSR|S_IRGRP);
+ if (typ & S_IXGRP)
+ perm |= who & S_IXUSR;
+ if (typ & S_IWGRP)
+ perm |= who & S_IWUSR;
+ if (typ & S_IRGRP)
+ perm |= who & S_IRUSR;
+
+ /*
+ * if any execute then read => execute
+ */
+
+ if ((typ |= perm) & (S_IXUSR|S_IXGRP|S_IXOTH))
+ {
+ if (typ & S_IRUSR)
+ perm |= who & S_IXUSR;
+ if (typ & S_IRGRP)
+ perm |= who & S_IXGRP;
+ if (typ & S_IROTH)
+ perm |= who & S_IXOTH;
+ }
+ typ = 0;
+ }
+ break;
+ }
+ switch (c)
+ {
+ case '=':
+ case '+':
+ case '|':
+ case '-':
+ case '&':
+ case '^':
+ op = c;
+ typ = 0;
+ continue;
+ }
+ if (c)
+ break;
+ /*FALLTHROUGH*/
+ default:
+ if (c < '0' || c > '7')
+ {
+ if (e)
+ *e = expr - 1;
+ if (typ)
+ {
+ if (who)
+ {
+ typ &= who;
+ perm &= ~who;
+ }
+ perm |= typ;
+ }
+ return perm & S_IPERM;
+ }
+ num = (num << 3) | (c - '0');
+ if (!who && (op == '+' || op == '-'))
+ who = S_ISVTX|S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO;
+ if (*expr < '0' || *expr > '7')
+ {
+ typ |= modei(num);
+ num = 0;
+ }
+ continue;
+ }
+ break;
+ }
+ break;
+ }
+ break;
+ }
+ }
+}
diff --git a/usr/src/lib/libast/common/string/strpsearch.c b/usr/src/lib/libast/common/string/strpsearch.c
new file mode 100644
index 0000000000..e627a5981c
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strpsearch.c
@@ -0,0 +1,125 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ */
+
+#include <ast.h>
+#include <ccode.h>
+#include <ctype.h>
+
+#if CC_NATIVE == CC_ASCII
+#define MAP(m,c) (c)
+#else
+#define MAP(m,c) m[c]
+#endif
+
+/*
+ * return a pointer to the isalpha() identifier matching
+ * name in the CC_ASCII sorted tab of num elements of
+ * size siz where the first member of each
+ * element is a char*
+ *
+ * [xxx] brackets optional identifier characters
+ * * starts optional identifier characters
+ *
+ * 0 returned if name not found
+ * otherwise if next!=0 then it points to the next
+ * unmatched char in name
+ */
+
+void*
+strpsearch(const void* tab, size_t num, size_t siz, const char* name, char** next)
+{
+ register char* lo = (char*)tab;
+ register char* hi = lo + (num - 1) * siz;
+ register char* mid;
+#if CC_NATIVE != CC_ASCII
+ register unsigned char* m;
+#endif
+ register unsigned char* s;
+ register unsigned char* t;
+ register int c;
+ register int v;
+ int sequential = 0;
+
+#if CC_NATIVE != CC_ASCII
+ m = ccmap(CC_NATIVE, CC_ASCII);
+#endif
+ c = MAP(m, *((unsigned char*)name));
+ while (lo <= hi)
+ {
+ mid = lo + (sequential ? 0 : (((hi - lo) / siz) / 2) * siz);
+ if (!(v = c - MAP(m, *(s = *((unsigned char**)mid)))) || *s == '[' && !(v = c - MAP(m, *++s)) && (v = 1))
+ {
+ t = (unsigned char*)name;
+ for (;;)
+ {
+ if (!v && (*s == '[' || *s == '*'))
+ {
+ v = 1;
+ s++;
+ }
+ else if (v && *s == ']')
+ {
+ v = 0;
+ s++;
+ }
+ else if (!isalpha(*t))
+ {
+ if (v || !*s)
+ {
+ if (next)
+ *next = (char*)t;
+ return (void*)mid;
+ }
+ if (!sequential)
+ {
+ while ((mid -= siz) >= lo && (s = *((unsigned char**)mid)) && ((c == MAP(m, *s)) || *s == '[' && c == MAP(m, *(s + 1))));
+ sequential = 1;
+ }
+ v = 1;
+ break;
+ }
+ else if (*t != *s)
+ {
+ v = MAP(m, *t) - MAP(m, *s);
+ break;
+ }
+ else
+ {
+ t++;
+ s++;
+ }
+ }
+ }
+ else if (sequential)
+ break;
+ if (v > 0)
+ lo = mid + siz;
+ else
+ hi = mid - siz;
+ }
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/string/strsearch.c b/usr/src/lib/libast/common/string/strsearch.c
new file mode 100644
index 0000000000..da5c9d7833
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strsearch.c
@@ -0,0 +1,57 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ */
+
+#include <ast.h>
+
+/*
+ * return a pointer to the element matching
+ * name in the (*comparf*)() sorted tab of num elements of
+ * size siz where the first member of each
+ * element is a char*
+ *
+ * 0 returned if name not found
+ */
+
+void*
+strsearch(const void* tab, size_t num, size_t siz, Strcmp_f comparf, const char* name, void* context)
+{
+ register char* lo = (char*)tab;
+ register char* hi = lo + (num - 1) * siz;
+ register char* mid;
+ register int v;
+
+ while (lo <= hi)
+ {
+ mid = lo + (((hi - lo) / siz) / 2) * siz;
+ if (!(v = context ? (*(Strcmp_context_f)comparf)(name, *((char**)mid), context) : (*comparf)(name, *((char**)mid))))
+ return (void*)mid;
+ else if (v > 0)
+ lo = mid + siz;
+ else hi = mid - siz;
+ }
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/string/strsort.c b/usr/src/lib/libast/common/string/strsort.c
new file mode 100644
index 0000000000..daae6393cc
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strsort.c
@@ -0,0 +1,57 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * strsort - sort an array pointers using fn
+ *
+ * fn follows strcmp(3) conventions
+ *
+ * David Korn
+ * AT&T Bell Laboratories
+ *
+ * derived from Bourne Shell
+ */
+
+#include <ast.h>
+
+void
+strsort(char** argv, int n, int(*fn)(const char*, const char*))
+{
+ register int i;
+ register int j;
+ register int m;
+ register char** ap;
+ char* s;
+ int k;
+
+ for (j = 1; j <= n; j *= 2);
+ for (m = 2 * j - 1; m /= 2;)
+ for (j = 0, k = n - m; j < k; j++)
+ for (i = j; i >= 0; i -= m)
+ {
+ ap = &argv[i];
+ if ((*fn)(ap[m], ap[0]) >= 0) break;
+ s = ap[m];
+ ap[m] = ap[0];
+ ap[0] = s;
+ }
+}
diff --git a/usr/src/lib/libast/common/string/strtape.c b/usr/src/lib/libast/common/string/strtape.c
new file mode 100644
index 0000000000..4f3d258a7e
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strtape.c
@@ -0,0 +1,148 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * local device pathname for portable tape unit specification is returned
+ * if e is non-null then it is set to the next unused char in s
+ *
+ * <unit><density>[<no-rewind>]
+ * {0-7}[l,m,h,u,c][n]
+ */
+
+#include <ast.h>
+
+char*
+strtape(register const char* s, register char** e)
+{
+ int mtunit = '0';
+ int mtdensity = 0;
+ char mtrewind[2];
+ char mtbehavior[2];
+
+ static char tapefile[sizeof("/dev/Xrmt/123456789")];
+
+ mtrewind[0] = mtrewind[1] = mtbehavior[0] = mtbehavior[1] = 0;
+ for (;;)
+ {
+ switch (*s)
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ mtunit = *s++;
+ continue;
+ case 'b':
+ case 'v':
+ mtbehavior[0] = *s++;
+ continue;
+ case 'l':
+ case 'm':
+ case 'h':
+ case 'u':
+ case 'c':
+ mtdensity = *s++;
+ continue;
+ case 'n':
+ mtrewind[0] = *s++;
+ continue;
+ }
+ break;
+ }
+ if (e) *e = (char*)s;
+ if (!access("/dev/rmt/.", F_OK))
+ {
+ /*
+ * system V
+ */
+
+ if (!mtdensity) mtdensity = 'm';
+ sfsprintf(tapefile, sizeof(tapefile), "/dev/rmt/ctape%c%s", mtunit, mtrewind);
+ if (!access(tapefile, F_OK)) return(tapefile);
+ for (;;)
+ {
+ sfsprintf(tapefile, sizeof(tapefile), "/dev/rmt/%c%c%s%s", mtunit, mtdensity, mtbehavior, mtrewind);
+ if (!access(tapefile, F_OK)) return(tapefile);
+ if (!mtbehavior[0]) break;
+ mtbehavior[0] = 0;
+ }
+ }
+ else if (!access("/dev/nst0", F_OK))
+ {
+ /*
+ * linux
+ */
+
+ sfsprintf(tapefile, sizeof(tapefile), "/dev/%sst%c", mtrewind, mtunit);
+ }
+ else if (!access("/dev/nrmt0", F_OK))
+ {
+ /*
+ * 9th edition
+ */
+
+ switch (mtdensity)
+ {
+ case 'l':
+ mtunit = '0';
+ break;
+ case 'm':
+ mtunit = '1';
+ break;
+ case 'h':
+ mtunit = '2';
+ break;
+ }
+ sfsprintf(tapefile, sizeof(tapefile), "/dev/%srmt%c", mtrewind, mtunit);
+ }
+ else
+ {
+ /*
+ * BSD
+ */
+
+ mtunit -= '0';
+ switch (mtdensity)
+ {
+ case 'l':
+ break;
+ case 'h':
+ mtunit |= 020;
+ break;
+ default:
+ mtunit |= 010;
+ break;
+ }
+ switch (mtrewind[0])
+ {
+ case 'n':
+ mtunit |= 040;
+ break;
+ }
+ sfsprintf(tapefile, sizeof(tapefile), "/dev/rmt%d", mtunit);
+ }
+ return(tapefile);
+}
diff --git a/usr/src/lib/libast/common/string/strtoi.h b/usr/src/lib/libast/common/string/strtoi.h
new file mode 100644
index 0000000000..0f233d9ae5
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strtoi.h
@@ -0,0 +1,610 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * AT&T Research
+ * Glenn Fowler
+ * Phong Vo
+ *
+ * common header and implementation for
+ *
+ * strtol strtoul strton
+ * strtoll strtoull strtonll
+ * strntol strntoul strnton
+ * strntoll strntoull strntonll
+ *
+ * define these macros to instantiate an implementation:
+ *
+ * S2I_function the function name
+ * S2I_number the signed number type
+ * S2I_unumber the unsigned number type
+ * S2I_unsigned 1 for unsigned, 0 for signed
+ * S2I_multiplier 1 for optional multiplier suffix, 0 otherwise
+ * S2I_size the second argument is the input string size
+ *
+ * convert string to number
+ * errno=ERANGE on overflow (LONG_MAX) or underflow (LONG_MIN)
+ * if non-null e will point to first unrecognized char in s
+ * if basep!=0 it points to the default base on input and
+ * will point to the explicit base on return
+ * a default base of 0 will determine the base from the input
+ * a default base of 1 will determine the base from the input using bb#*
+ * a base prefix in the string overrides *b
+ * *b will not be set if the string has no base prefix
+ * if m>1 and no multipler was specified then the result is multiplied by m
+ * if m<0 then multipliers are not consumed
+ * if a base arg or prefix is specified then multiplier is not consumed
+ *
+ * integer numbers are of the form:
+ *
+ * [sign][base][number[qualifier]][multiplier]
+ *
+ * base: nnn# base nnn
+ * 0[xX] hex
+ * 0 octal
+ * [1-9] decimal
+ *
+ * number: [0-9a-zA-Z]*
+ *
+ * qualifier: [lL]
+ * [uU]
+ * [uU][lL]
+ * [lL][uU]
+ * [lL][lL][uU]
+ * [uU][lL][lL]
+ *
+ * multiplier: . pseudo-float if m>1
+ * [bB] block (512)
+ * [cC] char (1)
+ * [gG] giga (1024*1024*1024)
+ * [kK] kilo (1024)
+ * [mM] mega (1024*1024)
+ */
+
+#include <ast.h>
+#include <ctype.h>
+
+#include "sfhdr.h"
+
+#if !__STD_C && !defined(const)
+#define const
+#endif
+
+#ifndef ERANGE
+#define ERANGE EINVAL
+#endif
+
+#define QL 01
+#define QU 02
+
+#define S2I_umax (~((S2I_unumber)0))
+
+#if S2I_unsigned
+#define S2I_type S2I_unumber
+#define S2I_min 0
+#define S2I_max S2I_umax
+#else
+#define S2I_type S2I_number
+#define S2I_min (-S2I_max-1)
+#define S2I_max (S2I_umax>>1)
+#endif
+
+#if S2I_size
+#define S2I_valid(s) ((s)<(z))
+#else
+#define S2I_valid(s) 1
+#endif
+
+#define ADDOVER(n,c,s) ((S2I_umax-(n))<((S2I_unumber)((c)+(s))))
+#define MPYOVER(n,c) (((S2I_unumber)(n))>(S2I_umax/(c)))
+
+static const S2I_unumber mm[] =
+{
+ 0,
+ S2I_umax / 1,
+ S2I_umax / 2,
+ S2I_umax / 3,
+ S2I_umax / 4,
+ S2I_umax / 5,
+ S2I_umax / 6,
+ S2I_umax / 7,
+ S2I_umax / 8,
+ S2I_umax / 9,
+ S2I_umax / 10,
+ S2I_umax / 11,
+ S2I_umax / 12,
+ S2I_umax / 13,
+ S2I_umax / 14,
+ S2I_umax / 15,
+ S2I_umax / 16,
+ S2I_umax / 17,
+ S2I_umax / 18,
+ S2I_umax / 19,
+ S2I_umax / 20,
+ S2I_umax / 21,
+ S2I_umax / 22,
+ S2I_umax / 23,
+ S2I_umax / 24,
+ S2I_umax / 25,
+ S2I_umax / 26,
+ S2I_umax / 27,
+ S2I_umax / 28,
+ S2I_umax / 29,
+ S2I_umax / 30,
+ S2I_umax / 31,
+ S2I_umax / 32,
+ S2I_umax / 33,
+ S2I_umax / 34,
+ S2I_umax / 35,
+ S2I_umax / 36,
+ S2I_umax / 37,
+ S2I_umax / 38,
+ S2I_umax / 39,
+ S2I_umax / 40,
+ S2I_umax / 41,
+ S2I_umax / 42,
+ S2I_umax / 43,
+ S2I_umax / 44,
+ S2I_umax / 45,
+ S2I_umax / 46,
+ S2I_umax / 47,
+ S2I_umax / 48,
+ S2I_umax / 49,
+ S2I_umax / 50,
+ S2I_umax / 51,
+ S2I_umax / 52,
+ S2I_umax / 53,
+ S2I_umax / 54,
+ S2I_umax / 55,
+ S2I_umax / 56,
+ S2I_umax / 57,
+ S2I_umax / 58,
+ S2I_umax / 59,
+ S2I_umax / 60,
+ S2I_umax / 61,
+ S2I_umax / 62,
+ S2I_umax / 63,
+ S2I_umax / 64,
+};
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+extern S2I_type
+#undef extern
+#if S2I_size
+#if S2I_multiplier
+#if __STD_C
+S2I_function(const char* a, size_t size, char** e, char* basep, int m)
+#else
+S2I_function(a, size, e, basep, m) const char* a; size_t size; char** e; char* basep; int m;
+#endif
+#else
+#if __STD_C
+S2I_function(const char* a, size_t size, char** e, int base)
+#else
+S2I_function(a, size, e, base) const char* a; size_t size; char** e; int base;
+#endif
+#endif
+#else
+#if S2I_multiplier
+#if __STD_C
+S2I_function(const char* a, char** e, char* basep, int m)
+#else
+S2I_function(a, e, basep, m) const char* a; char** e; char* basep; int m;
+#endif
+#else
+#if __STD_C
+S2I_function(const char* a, char** e, int base)
+#else
+S2I_function(a, e, base) const char* a; char** e; int base;
+#endif
+#endif
+#endif
+{
+ register unsigned char* s = (unsigned char*)a;
+#if S2I_size
+ register unsigned char* z = s + size;
+#endif
+ register S2I_unumber n;
+ register S2I_unumber x;
+ register int c;
+ register int shift;
+ register unsigned char* p;
+ register unsigned char* cv;
+ unsigned char* b;
+ unsigned char* k;
+ S2I_unumber v;
+#if S2I_multiplier
+ register int base;
+#endif
+ int negative;
+ int overflow = 0;
+ int decimal = 0;
+ int thousand = 0;
+#if !S2I_unsigned
+ int qualifier = 0;
+#endif
+
+#if S2I_multiplier
+ base = basep ? *((unsigned char*)basep) : 0;
+#else
+ if (base > 36 && base <= SF_RADIX)
+ {
+ static int conformance = -1;
+
+ if (conformance < 0)
+ conformance = !strcmp(astconf("CONFORMANCE", NiL, NiL), "standard");
+ if (conformance)
+ base = 1;
+ }
+#endif
+ if (base && (base < 2 || base > SF_RADIX))
+ {
+ errno = EINVAL;
+ return 0;
+ }
+ while (S2I_valid(s) && isspace(*s))
+ s++;
+ if ((negative = S2I_valid(s) && (*s == '-')) || S2I_valid(s) && *s == '+')
+ k = ++s;
+ else
+ k = 0;
+ p = s;
+ if (!base)
+ {
+ if (S2I_valid(p) && (c = *p++) >= '0' && c <= '9')
+ {
+ n = c - '0';
+ if (S2I_valid(p) && (c = *p) >= '0' && c <= '9')
+ {
+ n = (n << 3) + (n << 1) + c - '0';
+ p++;
+ }
+ if (S2I_valid(p) && *p == '#')
+ {
+ if (n >= 2 && n <= 64)
+ {
+ k = s = p + 1;
+ base = n;
+ }
+ }
+ else if (base)
+ base = 0;
+ else if (S2I_valid(s) && *s == '0' && S2I_valid(s + 1))
+ {
+ if ((c = *(s + 1)) == 'x' || c == 'X')
+ {
+ k = s += 2;
+ base = 16;
+ }
+ else if (c >= '0' && c <= '7')
+ {
+ s++;
+ base = 8;
+ }
+ }
+ }
+ if (!base)
+ base = 10;
+ else if (base < 2 || base > SF_RADIX)
+ {
+ errno = EINVAL;
+ return 0;
+ }
+#if S2I_multiplier
+ else
+ {
+ if (basep)
+ *basep = base;
+ m = -1;
+ }
+#endif
+ }
+#if S2I_multiplier
+ else
+ m = -1;
+#endif
+
+ /*
+ * this part transcribed from sfvscanf()
+ */
+
+ SFSETLOCALE(&decimal, &thousand);
+ x = mm[base];
+ n = 0;
+ if (base == 10)
+ {
+ b = s;
+ p = 0;
+ for (;;)
+ {
+ if (S2I_valid(s) && (c = *s++) >= '0' && c <= '9')
+ {
+ if (n > x)
+ overflow = 1;
+ else
+ {
+ n = (n << 3) + (n << 1);
+ c -= '0';
+ if (ADDOVER(n, c, negative))
+ overflow = 1;
+ n += c;
+ }
+ }
+ else if (p && (s - p) != (3 + S2I_valid(s)))
+ {
+ s = p;
+ n = v;
+ c = 0;
+ break;
+ }
+ else if (c != thousand || !S2I_valid(s))
+ break;
+ else if (!p && (s - b) > 4)
+ {
+ if (e)
+ *e = (char*)s - 1;
+ if (overflow)
+ {
+ errno = ERANGE;
+#if S2I_unsigned
+ n = S2I_max;
+#else
+ n = negative ? S2I_min : S2I_max;
+#endif
+ }
+ return n;
+ }
+ else
+ {
+ p = s;
+ v = n;
+ }
+ }
+ }
+ else
+ {
+ SFCVINIT();
+ cv = base <= 36 ? _Sfcv36 : _Sfcv64;
+ if ((base & ~(base - 1)) == base)
+ {
+#if !S2I_unsigned
+ qualifier |= QU;
+#endif
+ if (base < 8)
+ shift = base < 4 ? 1 : 2;
+ else if (base < 32)
+ shift = base < 16 ? 3 : 4;
+ else
+ shift = base < 64 ? 5 : 6;
+ while (S2I_valid(s) && (c = cv[*s++]) < base)
+ {
+ if (n > x)
+ overflow = 1;
+ else
+ {
+ n <<= shift;
+ if (ADDOVER(n, c, negative))
+ overflow = 1;
+ n += c;
+ }
+ }
+ }
+ else
+ while (S2I_valid(s) && (c = cv[*s++]) < base)
+ {
+ if (n > x)
+ overflow = 1;
+ else
+ {
+ n *= base;
+ if (ADDOVER(n, c, negative))
+ overflow = 1;
+ n += c;
+ }
+ }
+ c = *(s - 1);
+ }
+
+ /*
+ * optional qualifier suffix
+ */
+
+ if (S2I_valid(s) && s > (unsigned char*)(a + 1))
+ {
+ base = 0;
+ for (;;)
+ {
+ if (!(base & QL) && (c == 'l' || c == 'L'))
+ {
+ base |= QL;
+ if (!S2I_valid(s))
+ break;
+ c = *s++;
+ if (c == 'l' || c == 'L')
+ {
+ if (!S2I_valid(s))
+ break;
+ c = *s++;
+ }
+ }
+ else if (!(base & QU) && (c == 'u' || c == 'U'))
+ {
+ base |= QU;
+#if !S2I_unsigned
+ qualifier |= QU;
+#endif
+ if (!S2I_valid(s))
+ break;
+ c = *s++;
+ }
+ else
+ break;
+ }
+ }
+ if (S2I_valid(s))
+ {
+#if S2I_multiplier
+ /*
+ * optional multiplier suffix
+ */
+
+ if (m < 0 || s == (unsigned char*)(a + 1))
+ s--;
+ else
+ {
+ switch (c)
+ {
+ case 'b':
+ case 'B':
+ shift = 9;
+ break;
+ case 'k':
+ case 'K':
+ shift = 10;
+ break;
+ case 'm':
+ case 'M':
+ shift = 20;
+ break;
+ case 'g':
+ case 'G':
+ shift = 30;
+ break;
+ case 't':
+ case 'T':
+ shift = 40;
+ break;
+ case 'p':
+ case 'P':
+ shift = 50;
+ break;
+ case 'e':
+ case 'E':
+ shift = 60;
+ break;
+ default:
+ if (m <= 1)
+ v = 0;
+ else if (c == decimal && S2I_valid(s))
+ {
+ if (MPYOVER(n, m))
+ overflow = 1;
+ n *= m;
+ v = 0;
+ while (S2I_valid(s) && (c = *s++) >= '0' && c <= '9')
+ v += (m /= 10) * (c - '0');
+ if (ADDOVER(n, v, negative))
+ overflow = 1;
+ n += v;
+ v = 0;
+ }
+ else
+ v = m;
+ s--;
+ shift = 0;
+ break;
+ }
+ if (shift)
+ {
+ if (S2I_valid(s))
+ switch (*s)
+ {
+ case 'b':
+ case 'B':
+ case 'i':
+ case 'I':
+ s++;
+ break;
+ }
+#if S2I_unsigned
+ if (shift >= (sizeof(S2I_type) * CHAR_BIT))
+#else
+ if (shift >= (sizeof(S2I_type) * CHAR_BIT - 1))
+#endif
+ {
+ v = 0;
+ overflow = 1;
+ }
+ else
+ v = ((S2I_unumber)1) << shift;
+ }
+ if (v)
+ {
+ if (MPYOVER(n, v))
+ overflow = 1;
+ n *= v;
+ }
+ }
+#else
+ s--;
+#endif
+ }
+ if (s == k)
+ {
+ s--;
+#if S2I_multiplier
+ if (basep)
+ *basep = 10;
+#endif
+ }
+#if !S2I_unsigned
+ else if (!(qualifier & QU))
+ {
+ if (negative)
+ {
+ if (!n)
+ {
+ b = k;
+ do
+ {
+ if (b >= s)
+ {
+ negative = 0;
+ break;
+ }
+ } while (*b++ == '0');
+ }
+ if (negative && (n - 1) > S2I_max)
+ overflow = 1;
+ }
+ else if (n > S2I_max)
+ overflow = 1;
+ }
+#endif
+ if (e)
+ *e = (char*)s;
+ if (overflow)
+ {
+#if !S2I_unsigned
+ if (negative)
+ {
+ if (x << 1)
+ errno = ERANGE;
+ return (S2I_type)S2I_min;
+ }
+#endif
+ errno = ERANGE;
+ return (S2I_type)S2I_max;
+ }
+ return negative ? -n : n;
+}
diff --git a/usr/src/lib/libast/common/string/strtoip4.c b/usr/src/lib/libast/common/string/strtoip4.c
new file mode 100644
index 0000000000..3b00020af5
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strtoip4.c
@@ -0,0 +1,150 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+#include <ctype.h>
+
+/*
+ * convert string to 4 byte local byte order ip address
+ * with optional prefix bits
+ * pointer to first unused char placed in *e, even on error
+ * return 0:ok <0:error
+ *
+ * valid addresses match the egrep RE:
+ *
+ * [0-9]{1,3}(\.[0-9]{1,3})*|0[xX][0-9a-fA-Z]+
+ *
+ * valid bits/masks match the egrep RE:
+ *
+ * (/([0-9]+|[0-9]{1,3}(\.[0-9]{1,3})*))?
+ *
+ * if pbits!=0 and no bits/mask specified then trailing 0's in addr
+ * are used to compute the mask
+ */
+
+int
+strtoip4(register const char* s, char** e, uint32_t* paddr, unsigned char* pbits)
+{
+ register int c;
+ register unsigned int n;
+ register uint32_t addr;
+ register int part;
+ register unsigned char bits;
+ uint32_t z;
+ int old;
+ int r;
+ const char* b;
+
+ r = -1;
+ while (isspace(*s))
+ s++;
+ b = s;
+ addr = 0;
+ bits = 0;
+ part = 0;
+ do
+ {
+ n = 0;
+ while ((c = *s++) >= '0' && c <= '9')
+ n = n * 10 + (c - '0');
+ if ((c == 'x' || c == 'X') && !part)
+ {
+ addr = n;
+ for (;;)
+ {
+ if ((c = *s++) >= '0' && c <= '9')
+ c -= '0';
+ else if (c >= 'a' && c <= 'f')
+ c -= 'a' - 10;
+ else if (c >= 'A' && c <= 'F')
+ c -= 'F' - 10;
+ else
+ break;
+ addr = addr * 16 + c;
+ }
+ part = 4;
+ break;
+ }
+ if (n > 0xff)
+ goto done;
+ addr = (addr << 8) | n;
+ part++;
+ } while (c == '.');
+ if ((s - b) == 1 && c != '/' || part > 4)
+ goto done;
+ if (old = part < 4)
+ while (part++ < 4)
+ addr <<= 8;
+ if (pbits)
+ {
+ if (c == '/')
+ {
+ part = 0;
+ z = 0;
+ for (;;)
+ {
+ n = 0;
+ while ((c = *s++) >= '0' && c <= '9')
+ n = n * 10 + (c - '0');
+ z = (z << 8) | n;
+ part++;
+ if (c != '.')
+ break;
+ old = 1;
+ }
+ if (part > 4)
+ goto done;
+ if (z <= 32 && (!old || part < 2))
+ bits = z;
+ else if (z)
+ {
+ if (part == 4 && (z & 0x8000001) == 1)
+ z = ~z;
+ while (!(z & 1))
+ z >>= 1;
+ while (z & 1)
+ {
+ z >>= 1;
+ bits++;
+ }
+ }
+ }
+ else if ((z = (addr >> 24)) < 128)
+ bits = 8;
+ else if (z < 192)
+ bits = 16;
+ else
+ bits = 24;
+ if (*pbits = bits)
+ addr &= ~((((uint32_t)1)<<(32-bits))-1);
+ else
+ addr = 0;
+ }
+ if (paddr)
+ *paddr = addr;
+ r = 0;
+ done:
+ if (e)
+ *e = (char*)(s - 1);
+ return r;
+}
diff --git a/usr/src/lib/libast/common/string/strton.c b/usr/src/lib/libast/common/string/strton.c
new file mode 100644
index 0000000000..6b62fcff6d
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strton.c
@@ -0,0 +1,31 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * strton() implementation
+ */
+
+#define S2I_function strton
+#define S2I_number long
+#define S2I_unumber unsigned long
+#define S2I_multiplier 1
+
+#include "strtoi.h"
diff --git a/usr/src/lib/libast/common/string/strtonll.c b/usr/src/lib/libast/common/string/strtonll.c
new file mode 100644
index 0000000000..eae3c43502
--- /dev/null
+++ b/usr/src/lib/libast/common/string/strtonll.c
@@ -0,0 +1,31 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * strtonll() implementation
+ */
+
+#define S2I_function strtonll
+#define S2I_number intmax_t
+#define S2I_unumber uintmax_t
+#define S2I_multiplier 1
+
+#include "strtoi.h"
diff --git a/usr/src/lib/libast/common/string/struid.c b/usr/src/lib/libast/common/string/struid.c
new file mode 100644
index 0000000000..851d49b5e5
--- /dev/null
+++ b/usr/src/lib/libast/common/string/struid.c
@@ -0,0 +1,109 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * uid name -> number
+ */
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide getpwnam getpwuid
+#else
+#define getpwnam ______getpwnam
+#define getpwuid ______getpwuid
+#endif
+
+#include <ast.h>
+#include <cdt.h>
+#include <pwd.h>
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide getpwnam getpwuid
+#else
+#undef getpwnam
+#undef getpwuid
+#endif
+
+extern struct passwd* getpwnam(const char*);
+extern struct passwd* getpwuid(uid_t);
+
+typedef struct Id_s
+{
+ Dtlink_t link;
+ int id;
+ char name[1];
+} Id_t;
+
+/*
+ * return uid number given uid name
+ * -1 on first error for a given name
+ * -2 on subsequent errors for a given name
+ */
+
+int
+struid(const char* name)
+{
+ register Id_t* ip;
+ register struct passwd* pw;
+ int id;
+ char* e;
+
+ static Dt_t* dict;
+ static Dtdisc_t disc;
+
+ if (!dict)
+ {
+ disc.key = offsetof(Id_t, name);
+ dict = dtopen(&disc, Dthash);
+ }
+ else if (ip = (Id_t*)dtmatch(dict, name))
+ return ip->id;
+ if (pw = getpwnam(name))
+ id = pw->pw_uid;
+ else
+ {
+ id = strtol(name, &e, 0);
+#if _WINIX
+ if (!*e)
+ {
+ if (!getpwuid(id))
+ id = -1;
+ }
+ else if (streq(name, "root") && (pw = getpwnam("Administrator")))
+ id = pw->pw_uid;
+ else
+ id = -1;
+#else
+ if (*e || !getpwuid(id))
+ id = -1;
+#endif
+ }
+ if (dict && (ip = newof(0, Id_t, 1, strlen(name))))
+ {
+ strcpy(ip->name, name);
+ ip->id = id >= 0 ? id : -2;
+ dtinsert(dict, ip);
+ }
+ return id;
+}
diff --git a/usr/src/lib/libast/common/string/struniq.c b/usr/src/lib/libast/common/string/struniq.c
new file mode 100644
index 0000000000..906533e658
--- /dev/null
+++ b/usr/src/lib/libast/common/string/struniq.c
@@ -0,0 +1,51 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * struniq - uniq a sorted argv
+ * 0 sentinel is neither expected nor restored
+ *
+ * Glenn Fowler
+ * David Korn
+ * AT&T Research
+ */
+
+#include <ast.h>
+
+int
+struniq(char** argv, int n)
+{
+ register char** ao;
+ register char** an;
+ register char** ae;
+
+ ao = an = argv;
+ ae = ao + n;
+ while (++an < ae)
+ {
+ while (streq(*ao, *an))
+ if (++an >= ae)
+ return ao - argv + 1;
+ *++ao = *an;
+ }
+ return ao - argv + 1;
+}
diff --git a/usr/src/lib/libast/common/string/swapget.c b/usr/src/lib/libast/common/string/swapget.c
new file mode 100644
index 0000000000..04a58d0743
--- /dev/null
+++ b/usr/src/lib/libast/common/string/swapget.c
@@ -0,0 +1,57 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * internal representation conversion support
+ */
+
+#include <ast.h>
+#include <swap.h>
+
+/*
+ * get int_n from b according to op
+ */
+
+intmax_t
+swapget(int op, const void* b, int n)
+{
+ register unsigned char* p;
+ register unsigned char* d;
+ intmax_t v;
+ unsigned char tmp[sizeof(intmax_t)];
+
+ if (n > sizeof(intmax_t))
+ n = sizeof(intmax_t);
+ if (op) swapmem(op, b, d = tmp, n);
+ else d = (unsigned char*)b;
+ p = d + n;
+ v = 0;
+ while (d < p)
+ {
+ v <<= CHAR_BIT;
+ v |= *d++;
+ }
+ return v;
+}
diff --git a/usr/src/lib/libast/common/string/swapmem.c b/usr/src/lib/libast/common/string/swapmem.c
new file mode 100644
index 0000000000..29184f32dc
--- /dev/null
+++ b/usr/src/lib/libast/common/string/swapmem.c
@@ -0,0 +1,109 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * internal representation conversion support
+ */
+
+#include <ast.h>
+#include <swap.h>
+
+/*
+ * swap n bytes according to op
+ * from==to is ok
+ */
+
+void*
+swapmem(int op, const void* from, void* to, register size_t n)
+{
+ register char* f = (char*)from;
+ register char* t = (char*)to;
+ register int c;
+
+ switch (op & (n - 1))
+ {
+ case 0:
+ if (t != f)
+ memcpy(t, f, n);
+ break;
+ case 1:
+ for (n >>= 1; n--; f += 2, t += 2)
+ {
+ c = f[0]; t[0] = f[1]; t[1] = c;
+ }
+ break;
+ case 2:
+ for (n >>= 2; n--; f += 4, t += 4)
+ {
+ c = f[0]; t[0] = f[2]; t[2] = c;
+ c = f[1]; t[1] = f[3]; t[3] = c;
+ }
+ break;
+ case 3:
+ for (n >>= 2; n--; f += 4, t += 4)
+ {
+ c = f[0]; t[0] = f[3]; t[3] = c;
+ c = f[1]; t[1] = f[2]; t[2] = c;
+ }
+ break;
+ case 4:
+ for (n >>= 3; n--; f += 8, t += 8)
+ {
+ c = f[0]; t[0] = f[4]; t[4] = c;
+ c = f[1]; t[1] = f[5]; t[5] = c;
+ c = f[2]; t[2] = f[6]; t[6] = c;
+ c = f[3]; t[3] = f[7]; t[7] = c;
+ }
+ break;
+ case 5:
+ for (n >>= 3; n--; f += 8, t += 8)
+ {
+ c = f[0]; t[0] = f[5]; t[5] = c;
+ c = f[1]; t[1] = f[4]; t[4] = c;
+ c = f[2]; t[2] = f[7]; t[7] = c;
+ c = f[3]; t[3] = f[6]; t[6] = c;
+ }
+ break;
+ case 6:
+ for (n >>= 3; n--; f += 8, t += 8)
+ {
+ c = f[0]; t[0] = f[6]; t[6] = c;
+ c = f[1]; t[1] = f[7]; t[7] = c;
+ c = f[2]; t[2] = f[4]; t[4] = c;
+ c = f[3]; t[3] = f[5]; t[5] = c;
+ }
+ break;
+ case 7:
+ for (n >>= 3; n--; f += 8, t += 8)
+ {
+ c = f[0]; t[0] = f[7]; t[7] = c;
+ c = f[1]; t[1] = f[6]; t[6] = c;
+ c = f[2]; t[2] = f[5]; t[5] = c;
+ c = f[3]; t[3] = f[4]; t[4] = c;
+ }
+ break;
+ }
+ return to;
+}
diff --git a/usr/src/lib/libast/common/string/swapop.c b/usr/src/lib/libast/common/string/swapop.c
new file mode 100644
index 0000000000..a7910a5783
--- /dev/null
+++ b/usr/src/lib/libast/common/string/swapop.c
@@ -0,0 +1,59 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * internal representation conversion support
+ */
+
+#include <ast.h>
+#include <swap.h>
+
+/*
+ * return the swap operation for external to internal conversion
+ * if size<0 then (-size) used and (-size==4)&&(op==3) => op=7
+ * this is a workaround for 4 byte magic predicting 8 byte swap
+ */
+
+int
+swapop(const void* internal, const void* external, int size)
+{
+ register int op;
+ register int z;
+ char tmp[sizeof(intmax_t)];
+
+ if ((z = size) < 0)
+ z = -z;
+ if (z <= 1)
+ return 0;
+ if (z <= sizeof(intmax_t))
+ for (op = 0; op < z; op++)
+ if (!memcmp(internal, swapmem(op, external, tmp, z), z))
+ {
+ if (size < 0 && z == 4 && op == 3)
+ op = 7;
+ return op;
+ }
+ return -1;
+}
diff --git a/usr/src/lib/libast/common/string/swapput.c b/usr/src/lib/libast/common/string/swapput.c
new file mode 100644
index 0000000000..7d98b4d181
--- /dev/null
+++ b/usr/src/lib/libast/common/string/swapput.c
@@ -0,0 +1,50 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * internal representation conversion support
+ */
+
+#include <ast.h>
+#include <swap.h>
+
+/*
+ * put v of n chars into b according to op
+ */
+
+void*
+swapput(int op, void* b, int n, intmax_t v)
+{
+ register char* p = (char*)b + n;
+
+ while (p > (char*)b)
+ {
+ *--p = v;
+ v >>= CHAR_BIT;
+ }
+ if (op)
+ swapmem(op, p, p, n);
+ return b;
+}
diff --git a/usr/src/lib/libast/common/string/tok.c b/usr/src/lib/libast/common/string/tok.c
new file mode 100644
index 0000000000..7bf89ca30c
--- /dev/null
+++ b/usr/src/lib/libast/common/string/tok.c
@@ -0,0 +1,190 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * token stream routines
+ */
+
+#include <ast.h>
+#include <tok.h>
+
+#define FLG_RESTORE 01 /* restore string on close */
+#define FLG_NEWLINE 02 /* return newline token next */
+
+typedef struct Tok_s /* token stream state */
+{
+ union
+ {
+ char* end; /* end ('\0') of last token */
+ struct Tok_s* nxt; /* next in free list */
+ } ptr;
+ char chr; /* replace *end with this */
+ char flg; /* FLG_* */
+} Tok_t;
+
+static Tok_t* freelist;
+
+/*
+ * open a new token stream on s
+ * if f==0 then string is not restored
+ */
+
+char*
+tokopen(register char* s, int f)
+{
+ register Tok_t* p;
+
+ if (p = freelist)
+ freelist = freelist->ptr.nxt;
+ else if (!(p = newof(0, Tok_t, 1, 0)))
+ return 0;
+ p->chr = *(p->ptr.end = s);
+ p->flg = f ? FLG_RESTORE : 0;
+ return (char*)p;
+}
+
+/*
+ * close a token stream
+ * restore the string to its original state
+ */
+
+void
+tokclose(char* u)
+{
+ register Tok_t* p = (Tok_t*)u;
+
+ if (p->flg == FLG_RESTORE && *p->ptr.end != p->chr)
+ *p->ptr.end = p->chr;
+ p->ptr.nxt = freelist;
+ freelist = p;
+}
+
+/*
+ * return next space separated token
+ * "\n" is returned as a token
+ * 0 returned when no tokens remain
+ * "..." and '...' quotes are honored with \ escapes
+ */
+
+char*
+tokread(char* u)
+{
+ register Tok_t* p = (Tok_t*)u;
+ register char* s;
+ register char* r;
+ register int q;
+ register int c;
+
+ /*
+ * restore string on each call
+ */
+
+ if (!p->chr)
+ return 0;
+ s = p->ptr.end;
+ switch (p->flg)
+ {
+ case FLG_NEWLINE:
+ p->flg = 0;
+ return "\n";
+ case FLG_RESTORE:
+ if (*s != p->chr)
+ *s = p->chr;
+ break;
+ default:
+ if (!*s)
+ s++;
+ break;
+ }
+
+ /*
+ * skip leading space
+ */
+
+ while (*s == ' ' || *s == '\t')
+ s++;
+ if (!*s)
+ {
+ p->ptr.end = s;
+ p->chr = 0;
+ return 0;
+ }
+
+ /*
+ * find the end of this token
+ */
+
+ r = s;
+ q = 0;
+ for (;;)
+ switch (c = *r++)
+ {
+ case '\n':
+ if (!q)
+ {
+ if (s == (r - 1))
+ {
+ if (!p->flg)
+ {
+ p->ptr.end = r;
+ return "\n";
+ }
+ r++;
+ }
+ else if (!p->flg)
+ p->flg = FLG_NEWLINE;
+ }
+ /*FALLTHROUGH*/
+ case ' ':
+ case '\t':
+ if (q)
+ break;
+ /*FALLTHROUGH*/
+ case 0:
+ if (s == --r)
+ {
+ p->ptr.end = r;
+ p->chr = 0;
+ }
+ else
+ {
+ p->chr = *(p->ptr.end = r);
+ if (*r)
+ *r = 0;
+ }
+ return s;
+ case '\\':
+ if (*r)
+ r++;
+ break;
+ case '"':
+ case '\'':
+ if (c == q)
+ q = 0;
+ else if (!q)
+ q = c;
+ break;
+ }
+}
diff --git a/usr/src/lib/libast/common/string/tokline.c b/usr/src/lib/libast/common/string/tokline.c
new file mode 100644
index 0000000000..06ddb983b5
--- /dev/null
+++ b/usr/src/lib/libast/common/string/tokline.c
@@ -0,0 +1,193 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * return an Sfio_t* to a file or string that
+ *
+ * splices \\n to single lines
+ * checks for "..." and '...' spanning newlines
+ * drops #...\n comments
+ *
+ * if <arg> is a file and first line matches
+ * #!!! <level> <message> !!!
+ * then error(<lev>,"%s: %s",<arg>,<msg>) called
+ *
+ * NOTE: seek disabled and string disciplines cannot be composed
+ * quoted \n translated to \r
+ */
+
+#include <ast.h>
+#include <error.h>
+#include <tok.h>
+
+typedef struct
+{
+ Sfdisc_t disc;
+ Sfio_t* sp;
+ int quote;
+ int* line;
+} Splice_t;
+
+/*
+ * the splicer
+ */
+
+static int
+spliceline(Sfio_t* s, int op, void* val, Sfdisc_t* ad)
+{
+ Splice_t* d = (Splice_t*)ad;
+ register char* b;
+ register int c;
+ register int n;
+ register int q;
+ register int j;
+ register char* e;
+ char* buf;
+
+ NoP(val);
+ switch (op)
+ {
+ case SF_CLOSING:
+ sfclose(d->sp);
+ return 0;
+ case SF_DPOP:
+ free(d);
+ return 0;
+ case SF_READ:
+ do
+ {
+ if (!(buf = sfgetr(d->sp, '\n', 0)) && !(buf = sfgetr(d->sp, '\n', -1)))
+ return 0;
+ n = sfvalue(d->sp);
+ q = d->quote;
+ j = 0;
+ (*d->line)++;
+ if (n > 1 && buf[n - 2] == '\\')
+ {
+ j = 1;
+ n -= 2;
+ if (q == '#')
+ {
+ n = 0;
+ continue;
+ }
+ }
+ else if (q == '#')
+ {
+ q = 0;
+ n = 0;
+ continue;
+ }
+ if (n > 0)
+ {
+ e = (b = buf) + n;
+ while (b < e)
+ {
+ if ((c = *b++) == '\\')
+ b++;
+ else if (c == q)
+ q = 0;
+ else if (!q)
+ {
+ if (c == '\'' || c == '"')
+ q = c;
+ else if (c == '#' && (b == (buf + 1) || (c = *(b - 2)) == ' ' || c == '\t'))
+ {
+ if (buf[n - 1] != '\n')
+ {
+ q = '#';
+ n = b - buf - 2;
+ }
+ else if (n = b - buf - 1)
+ buf[n - 1] = '\n';
+ break;
+ }
+ }
+ }
+ if (n > 0)
+ {
+ if (!j && buf[n - 1] != '\n' && (s->_flags & SF_STRING))
+ buf[n++] = '\n';
+ if (q && buf[n - 1] == '\n')
+ buf[n - 1] = '\r';
+ }
+ }
+ } while (n <= 0);
+ sfsetbuf(s, buf, n);
+ d->quote = q;
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+/*
+ * open a stream to parse lines
+ *
+ * flags: 0 arg: open Sfio_t*
+ * flags: SF_READ arg: file name
+ * flags: SF_STRING arg: null terminated char*
+ *
+ * if line!=0 then it points to a line count that starts at 0
+ * and is incremented for each input line
+ */
+
+Sfio_t*
+tokline(const char* arg, int flags, int* line)
+{
+ Sfio_t* f;
+ Sfio_t* s;
+ Splice_t* d;
+ char* p;
+ char* e;
+
+ static int hidden;
+
+ if (!(d = newof(0, Splice_t, 1, 0)))
+ return 0;
+ if (!(s = sfopen(NiL, NiL, "s")))
+ {
+ free(d);
+ return 0;
+ }
+ if (!(flags & (SF_STRING|SF_READ)))
+ f = (Sfio_t*)arg;
+ else if (!(f = sfopen(NiL, arg, (flags & SF_STRING) ? "s" : "r")))
+ {
+ free(d);
+ sfclose(s);
+ return 0;
+ }
+ else if ((p = sfreserve(f, 0, 0)) && sfvalue(f) > 11 && strmatch(p, "#!!! +([-0-9]) *([!\n]) !!!\n*") && (e = strchr(p, '\n')))
+ {
+ flags = strtol(p + 5, &p, 10);
+ error(flags, "%s:%-.*s", arg, e - p - 4, p);
+ }
+ d->disc.exceptf = spliceline;
+ d->sp = f;
+ *(d->line = line ? line : &hidden) = 0;
+ sfdisc(s, (Sfdisc_t*)d);
+ return s;
+}
diff --git a/usr/src/lib/libast/common/string/tokscan.c b/usr/src/lib/libast/common/string/tokscan.c
new file mode 100644
index 0000000000..f415c6709a
--- /dev/null
+++ b/usr/src/lib/libast/common/string/tokscan.c
@@ -0,0 +1,360 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * scan s for tokens in fmt
+ * s modified in place and not restored
+ * if nxt!=0 then it will point to the first unread char in s
+ * the number of scanned tokens is returned
+ * -1 returned if s was not empty and fmt failed to match
+ *
+ * ' ' in fmt matches 0 or more {space,tab}
+ * '\n' in fmt eats remainder of current line
+ * "..." and '...' quotes interpreted
+ * newline is equivalent to end of buf except when quoted
+ * \\ quotes following char
+ *
+ * message support for %s and %v data
+ *
+ * (5:12345) fixed length strings, ) may be \t
+ * (null) NiL
+ *
+ * "..." and '...' may span \n, and \\n is the line splice
+ * quoted '\r' translated to '\n'
+ * otherwise tokenizing is unconditionally terminated by '\n'
+ *
+ * a null arg pointer skips that arg
+ *
+ * %c char
+ * %[hl]d [short|int|long] base 10
+ * %f double
+ * %g double
+ * %[hl]n [short|int|long] C-style base
+ * %[hl]o [short|int|long] base 8
+ * %s string
+ * %[hl]u same as %[hl]n
+ * %v argv, elements
+ * %[hl]x [short|int|long] base 16
+ *
+ * unmatched char args are set to "", int args to 0
+ */
+
+#include <ast.h>
+#include <tok.h>
+
+static char empty[1];
+
+/*
+ * get one string token into p
+ */
+
+static char*
+lextok(register char* s, register int c, char** p, int* n)
+{
+ register char* t;
+ register int q;
+ char* b;
+ char* u;
+
+ if (*s == '(' && (!c || c == ' ' || c == '\n'))
+ {
+ q = strtol(s + 1, &b, 10);
+ if (*b == ':')
+ {
+ if (*(t = ++b + q) == ')' || *t == '\t')
+ {
+ s = t;
+ *s++ = 0;
+ goto end;
+ }
+ }
+ else if (strneq(b, "null)", 5))
+ {
+ s = b + 5;
+ b = 0;
+ goto end;
+ }
+ }
+ b = s;
+ q = 0;
+ t = 0;
+ for (;;)
+ {
+ if (!*s || !q && *s == '\n')
+ {
+ if (!q)
+ {
+ if (!c || c == ' ' || c == '\n') (*n)++;
+ else
+ {
+ s = b;
+ b = empty;
+ break;
+ }
+ }
+ if (t) *t = 0;
+ break;
+ }
+ else if (*s == '\\')
+ {
+ u = s;
+ if (!*++s || *s == '\n' && (!*++s || *s == '\n')) continue;
+ if (p)
+ {
+ if (b == u) b = s;
+ else if (!t) t = u;
+ }
+ }
+ else if (q)
+ {
+ if (*s == q)
+ {
+ q = 0;
+ if (!t) t = s;
+ s++;
+ continue;
+ }
+ else if (*s == '\r') *s = '\n';
+ }
+ else if (*s == '"' || *s == '\'')
+ {
+ q = *s++;
+ if (p)
+ {
+ if (b == (s - 1)) b = s;
+ else if (!t) t = s - 1;
+ }
+ continue;
+ }
+ else if (*s == c || c == ' ' && *s == '\t')
+ {
+ *s++ = 0;
+ if (t) *t = 0;
+ end:
+ if (c == ' ') while (*s == ' ' || *s == '\t') s++;
+ (*n)++;
+ break;
+ }
+ if (t) *t++ = *s;
+ s++;
+ }
+ if (p) *p = b;
+ return(s);
+}
+
+/*
+ * scan entry
+ */
+
+int
+tokscan(register char* s, char** nxt, const char* fmt, ...)
+{
+ register int c;
+ register char* f;
+ int num = 0;
+ char* skip = 0;
+ int q;
+ int onum;
+ long val;
+ double dval;
+ va_list ap;
+ char* p_char;
+ double* p_double;
+ int* p_int;
+ long* p_long;
+ short* p_short;
+ char** p_string;
+ char* prv_f = 0;
+ va_list prv_ap;
+
+ va_start(ap, fmt);
+ if (!*s || *s == '\n')
+ {
+ skip = s;
+ s = empty;
+ }
+ f = (char*)fmt;
+ for (;;) switch (c = *f++)
+ {
+ case 0:
+ if (f = prv_f)
+ {
+ prv_f = 0;
+ /* prv_ap value is guarded by prv_f */
+ va_copy(ap, prv_ap);
+ continue;
+ }
+ goto done;
+ case ' ':
+ while (*s == ' ' || *s == '\t') s++;
+ break;
+ case '%':
+ onum = num;
+ switch (c = *f++)
+ {
+ case 'h':
+ case 'l':
+ q = c;
+ c = *f++;
+ break;
+ default:
+ q = 0;
+ break;
+ }
+ switch (c)
+ {
+ case 0:
+ case '%':
+ f--;
+ continue;
+ case ':':
+ prv_f = f;
+ f = va_arg(ap, char*);
+ va_copy(prv_ap, ap);
+ va_copy(ap, va_listval(va_arg(ap, va_listarg)));
+ continue;
+ case 'c':
+ p_char = va_arg(ap, char*);
+ if (!(c = *s) || c == '\n')
+ {
+ if (p_char) *p_char = 0;
+ }
+ else
+ {
+ if (p_char) *p_char = c;
+ s++;
+ num++;
+ }
+ break;
+ case 'd':
+ case 'n':
+ case 'o':
+ case 'u':
+ case 'x':
+ switch (c)
+ {
+ case 'd':
+ c = 10;
+ break;
+ case 'n':
+ case 'u':
+ c = 0;
+ break;
+ case 'o':
+ c = 8;
+ break;
+ case 'x':
+ c = 16;
+ break;
+ }
+ if (!*s || *s == '\n')
+ {
+ val = 0;
+ p_char = s;
+ }
+ else val = strtol(s, &p_char, c);
+ switch (q)
+ {
+ case 'h':
+ if (p_short = va_arg(ap, short*)) *p_short = (short)val;
+ break;
+ case 'l':
+ if (p_long = va_arg(ap, long*)) *p_long = val;
+ break;
+ default:
+ if (p_int = va_arg(ap, int*)) *p_int = (int)val;
+ break;
+ }
+ if (s != p_char)
+ {
+ s = p_char;
+ num++;
+ }
+ break;
+ case 'f':
+ case 'g':
+ if (!*s || *s == '\n')
+ {
+ dval = 0;
+ p_char = s;
+ }
+ else dval = strtod(s, &p_char);
+ if (p_double = va_arg(ap, double*)) *p_double = dval;
+ if (s != p_char)
+ {
+ s = p_char;
+ num++;
+ }
+ break;
+ case 's':
+ p_string = va_arg(ap, char**);
+ if (q = *f) f++;
+ if (!*s || *s == '\n')
+ {
+ if (p_string) *p_string = s;
+ }
+ else s = lextok(s, q, p_string, &num);
+ break;
+ case 'v':
+ p_string = va_arg(ap, char**);
+ c = va_arg(ap, int);
+ if (q = *f) f++;
+ if ((!*s || *s == '\n') && p_string)
+ {
+ *p_string = 0;
+ p_string = 0;
+ }
+ while (*s && *s != '\n' && --c > 0)
+ {
+ s = lextok(s, q, p_string, &num);
+ if (p_string) p_string++;
+ }
+ if (p_string) *p_string = 0;
+ break;
+ }
+ if (skip) num = onum;
+ else if (num == onum)
+ {
+ if (!num) num = -1;
+ skip = s;
+ s = empty;
+ }
+ break;
+ case '\n':
+ goto done;
+ default:
+ if ((*s++ != c) && !skip)
+ {
+ skip = s - 1;
+ s = empty;
+ }
+ break;
+ }
+ done:
+ va_end(ap);
+ if (*s == '\n') *s++ = 0;
+ if (nxt) *nxt = skip ? skip : s;
+ return(num);
+}
diff --git a/usr/src/lib/libast/common/tm/tmdata.c b/usr/src/lib/libast/common/tm/tmdata.c
new file mode 100644
index 0000000000..76e4431a44
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmdata.c
@@ -0,0 +1,282 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * time conversion support readonly data
+ */
+
+#include <ast.h>
+#include <tm.h>
+
+/*
+ * default format strings -- must agree with TM_* indices
+ */
+
+static char* format[] =
+{
+ "Jan", "Feb", "Mar", "Apr",
+ "May", "Jun", "Jul", "Aug",
+ "Sep", "Oct", "Nov", "Dec",
+
+ "January", "February", "March", "April",
+ "May", "June", "July", "August",
+ "September", "October", "November", "December",
+
+ "Sun", "Mon", "Tue", "Wed",
+ "Thu", "Fri", "Sat",
+
+ "Sunday", "Monday", "Tuesday", "Wednesday",
+ "Thursday", "Friday", "Saturday",
+
+ "%H:%M:%S", "%m/%d/%y", "%a %b %e %T %Z %Y",
+
+ "AM", "PM",
+
+ "GMT", "UTC", "UCT", "CUT",
+
+ "DST", "", "", "",
+
+ "s", "es", "", "",
+
+ "second", "minute", "hour", "day",
+ "week", "month", "year",
+
+ "midnight", "morning", "noon", "evening",
+
+ "yesterday", "today", "tomorrow",
+
+ "last", "ago", "past",
+ "this", "now", "current",
+ "in", "next", "hence",
+ "exactly", "", "",
+
+ "at", "on", "", "",
+
+ "st", "nd", "rd", "th", "th",
+ "th", "th", "th", "th", "th",
+
+ "", "", "", "", "",
+ "", "", "", "", "",
+
+ "%a %b %e %T %Y",
+ "%a %b %e %T %Z %Y",
+ "%a %b %e %T %z %Z %Y",
+ "%b %e %H:%M",
+ "%b %e %Y",
+ "%I:%M:%S %p",
+
+ "", "", "", "", "",
+
+ "first", "", "third", "fourth", "fifth",
+ "sixth", "seventh", "eighth", "ninth", "tenth",
+
+ "final", "ending", "nth",
+};
+
+/*
+ * format[] lex type classes
+ */
+
+static char lex[] =
+{
+ TM_MONTH_ABBREV,TM_MONTH_ABBREV,TM_MONTH_ABBREV,TM_MONTH_ABBREV,
+ TM_MONTH_ABBREV,TM_MONTH_ABBREV,TM_MONTH_ABBREV,TM_MONTH_ABBREV,
+ TM_MONTH_ABBREV,TM_MONTH_ABBREV,TM_MONTH_ABBREV,TM_MONTH_ABBREV,
+
+ TM_MONTH, TM_MONTH, TM_MONTH, TM_MONTH,
+ TM_MONTH, TM_MONTH, TM_MONTH, TM_MONTH,
+ TM_MONTH, TM_MONTH, TM_MONTH, TM_MONTH,
+
+ TM_DAY_ABBREV, TM_DAY_ABBREV, TM_DAY_ABBREV, TM_DAY_ABBREV,
+ TM_DAY_ABBREV, TM_DAY_ABBREV, TM_DAY_ABBREV,
+
+ TM_DAY, TM_DAY, TM_DAY, TM_DAY,
+ TM_DAY, TM_DAY, TM_DAY,
+
+ 0, 0, 0,
+
+ TM_MERIDIAN, TM_MERIDIAN,
+
+ TM_UT, TM_UT, TM_UT, TM_UT,
+ TM_DT, TM_DT, TM_DT, TM_DT,
+
+ TM_SUFFIXES, TM_SUFFIXES, TM_SUFFIXES, TM_SUFFIXES,
+
+ TM_PARTS, TM_PARTS, TM_PARTS, TM_PARTS,
+ TM_PARTS, TM_PARTS, TM_PARTS,
+
+ TM_HOURS, TM_HOURS, TM_HOURS, TM_HOURS,
+
+ TM_DAYS, TM_DAYS, TM_DAYS,
+
+ TM_LAST, TM_LAST, TM_LAST,
+ TM_THIS, TM_THIS, TM_THIS,
+ TM_NEXT, TM_NEXT, TM_NEXT,
+ TM_EXACT, TM_EXACT, TM_EXACT,
+
+ TM_NOISE, TM_NOISE, TM_NOISE, TM_NOISE,
+
+ TM_ORDINAL, TM_ORDINAL, TM_ORDINAL, TM_ORDINAL, TM_ORDINAL,
+ TM_ORDINAL, TM_ORDINAL, TM_ORDINAL, TM_ORDINAL, TM_ORDINAL,
+
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+
+ 0, 0, 0,
+ 0, 0, 0,
+
+ 0, 0, 0, 0, 0,
+
+ TM_ORDINALS, TM_ORDINALS, TM_ORDINALS, TM_ORDINALS, TM_ORDINALS,
+ TM_ORDINALS, TM_ORDINALS, TM_ORDINALS, TM_ORDINALS, TM_ORDINALS,
+
+ TM_FINAL, TM_FINAL, TM_FINAL,
+};
+
+/*
+ * output format digits
+ */
+
+static char digit[] = "0123456789";
+
+/*
+ * number of days in month i
+ */
+
+static short days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+
+/*
+ * sum of days in months before month i
+ */
+
+static short sum[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
+
+/*
+ * leap second time_t and accumulated adjustments
+ * (reverse order -- biased for recent dates)
+ *
+ * tl.time is the seconds since the epoch for the leap event
+ *
+ * adding: the first additional second
+ * subtracting: the first dissappearing second
+ */
+
+static Tm_leap_t leap[] =
+{
+ 946684822, 23, /* 1999-12-31+23:59:60 UTC*/
+ 915148821, 22, /* 1998-12-31+23:59:60 UTC */
+ 867715220, 21, /* 1997-06-30+23:59:60 UTC */
+ 820454419, 20, /* 1995-12-31+23:59:60 UTC */
+ 773020818, 19, /* 1994-06-30+23:59:60 UTC */
+ 741484817, 18, /* 1993-06-30+23:59:60 UTC */
+ 709948816, 17, /* 1992-06-30+23:59:60 UTC */
+ 662688015, 16, /* 1990-12-31+23:59:60 UTC */
+ 631152014, 15, /* 1989-12-31+23:59:60 UTC */
+ 567993613, 14, /* 1987-12-31+23:59:60 UTC */
+ 489024012, 13, /* 1985-06-30+23:59:60 UTC */
+ 425865611, 12, /* 1983-06-30+23:59:60 UTC */
+ 394329610, 11, /* 1982-06-30+23:59:60 UTC */
+ 362793609, 10, /* 1981-06-30+23:59:60 UTC */
+ 315532808, 9, /* 1979-12-31+23:59:60 UTC */
+ 283996807, 8, /* 1978-12-31+23:59:60 UTC */
+ 252460806, 7, /* 1977-12-31+23:59:60 UTC */
+ 220924805, 6, /* 1976-12-31+23:59:60 UTC */
+ 189302404, 5, /* 1975-12-31+23:59:60 UTC */
+ 157766403, 4, /* 1974-12-31+23:59:60 UTC */
+ 126230402, 3, /* 1973-12-31+23:59:60 UTC */
+ 94694401, 2, /* 1972-12-31+23:59:60 UTC */
+ 78796800, 1, /* 1972-06-30+23:59:60 UTC */
+ 0, 0, /* can reference (tl+1) */
+ 0, 0
+};
+
+/*
+ * time zones
+ *
+ * the UTC entries must be first
+ *
+ * zones with the same type are contiguous with all but the
+ * first entry for the type having a null type
+ *
+ * tz.standard is the sentinel
+ */
+
+static Tm_zone_t zone[] =
+{
+ 0, "GMT", 0, ( 0 * 60), 0, /* UTC */
+ 0, "UCT", 0, ( 0 * 60), 0, /* UTC */
+ 0, "UTC", 0, ( 0 * 60), 0, /* UTC */
+ 0, "CUT", 0, ( 0 * 60), 0, /* UTC */
+ "USA", "HST", 0, (10 * 60), 0, /* Hawaii */
+ 0, "YST", "YDT", ( 9 * 60), TM_DST, /* Yukon */
+ 0, "PST", "PDT", ( 8 * 60), TM_DST, /* Pacific */
+ 0, "PST", "PPET", ( 8 * 60), TM_DST, /* Pacific pres elect */
+ 0, "MST", "MDT", ( 7 * 60), TM_DST, /* Mountain */
+ 0, "CST", "CDT", ( 6 * 60), TM_DST, /* Central */
+ 0, "EST", "EDT", ( 5 * 60), TM_DST, /* Eastern */
+ "CAN", "AST", "ADT", ( 4 * 60), TM_DST, /* Atlantic */
+ 0, "NST", 0, ( 3 * 60 + 30), 0, /* Newfoundland */
+ "GBR", "", "BST", ( 0 * 60), TM_DST, /* British Summer */
+ "EUR", "WET", 0, ( 0 * 60), TM_DST, /* Western Eurpoean */
+ 0, "CET", 0, -( 1 * 60), TM_DST, /* Central European */
+ 0, "MET", 0, -( 1 * 60), TM_DST, /* Middle European */
+ 0, "EET", 0, -( 2 * 60), TM_DST, /* Eastern Eurpoean */
+ "ISR", "IST", "IDT", -( 3 * 60), TM_DST, /* Israel */
+ "IND", "IST", 0, -( 5 * 60 + 30 ), 0, /* India */
+ "CHN", "HKT", 0, -( 8 * 60), 0, /* Hong Kong */
+ "KOR", "KST", "KDT", -( 8 * 60), TM_DST, /* Korea */
+ "SNG", "SST", 0, -( 8 * 60), 0, /* Singapore */
+ "JPN", "JST", 0, -( 9 * 60), 0, /* Japan */
+ "AUS", "AWST", 0, -( 8 * 60), 0, /* Australia Western */
+ 0, "WST", 0, -( 8 * 60), 0, /* Australia Western */
+ 0, "ACST", 0, -( 9 * 60 + 30),TM_DST, /* Australia Central */
+ 0, "CST", 0, -( 9 * 60 + 30),TM_DST, /* Australia Central */
+ 0, "AEST", 0, -(10 * 60), TM_DST, /* Australia Eastern */
+ 0, "EST", 0, -(10 * 60), TM_DST, /* Australia Eastern */
+ "NZL", "NZST", "NZDT", -(12 * 60), TM_DST, /* New Zealand */
+ 0, 0, 0, 0, 0
+};
+
+/*
+ * 2007-03-19 move tm_data from _tm_data_ to (*_tm_datap_)
+ * to allow future Tm_data_t growth
+ * by 2009 _tm_data_ can be static
+ */
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+
+extern Tm_data_t _tm_data_;
+
+#undef extern
+
+Tm_data_t _tm_data_ = { format, lex, digit, days, sum, leap, zone };
+
+__EXTERN__(Tm_data_t, _tm_data_);
+
+__EXTERN__(Tm_data_t*, _tm_datap_);
+
+Tm_data_t* _tm_datap_ = &_tm_data_;
diff --git a/usr/src/lib/libast/common/tm/tmdate.c b/usr/src/lib/libast/common/tm/tmdate.c
new file mode 100644
index 0000000000..f5d1095d3c
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmdate.c
@@ -0,0 +1,41 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * time conversion support
+ */
+
+#include <tmx.h>
+
+/*
+ * parse date expression in s and return time_t value
+ * see tmxdate() for details
+ */
+
+time_t
+tmdate(const char* s, char** e, time_t* clock)
+{
+ return tmxsec(tmxdate(s, e, tmxclock(clock)));
+}
diff --git a/usr/src/lib/libast/common/tm/tmequiv.c b/usr/src/lib/libast/common/tm/tmequiv.c
new file mode 100644
index 0000000000..58c25b73c7
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmequiv.c
@@ -0,0 +1,57 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * time_t conversion support
+ */
+
+#include <tm.h>
+
+/*
+ * use one of the 14 equivalent calendar years to determine
+ * daylight savings time for future years beyond the range
+ * of the local system (via tmxmake())
+ */
+
+static const short equiv[] =
+{
+ 2006, 2012,
+ 2001, 2024,
+ 2002, 2008,
+ 2003, 2020,
+ 2009, 2004,
+ 2010, 2016,
+ 2005, 2000,
+};
+
+/*
+ * return the circa 2000 equivalent calendar year for tm
+ */
+
+int
+tmequiv(Tm_t* tm)
+{
+ return tm->tm_year < (2038 - 1900) ? (tm->tm_year + 1900) : equiv[tm->tm_wday + tmisleapyear(tm->tm_year)];
+}
diff --git a/usr/src/lib/libast/common/tm/tmfix.c b/usr/src/lib/libast/common/tm/tmfix.c
new file mode 100644
index 0000000000..234bf56b9e
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmfix.c
@@ -0,0 +1,163 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * time conversion support
+ */
+
+#include <ast.h>
+#include <tm.h>
+
+#define DAYS(p) (tm_data.days[(p)->tm_mon]+((p)->tm_mon==1&&LEAP(p)))
+#define LEAP(p) (tmisleapyear((p)->tm_year))
+
+/*
+ * correct out of bounds fields in tm
+ *
+ * tm_isdst is not changed -- call tmxmake() to get that
+ *
+ * tm is the return value
+ */
+
+Tm_t*
+tmfix(register Tm_t* tm)
+{
+ register int n;
+ register int w;
+ Tm_t* p;
+ time_t t;
+
+ /*
+ * check for special case that adjusts tm_wday at the end
+ * this happens during
+ * nl_langinfo() => strftime() => tmfmt()
+ */
+
+ if (w = !tm->tm_sec && !tm->tm_min && !tm->tm_mday && !tm->tm_year && !tm->tm_yday && !tm->tm_isdst)
+ {
+ tm->tm_year = 99;
+ tm->tm_mday = 2;
+ }
+
+ /*
+ * adjust from shortest to longest units
+ */
+
+ if ((n = tm->tm_sec) < 0)
+ {
+ tm->tm_min -= (60 - n) / 60;
+ tm->tm_sec = 60 - (-n) % 60;
+ }
+ else if (n > (59 + TM_MAXLEAP))
+ {
+ tm->tm_min += n / 60;
+ tm->tm_sec %= 60;
+ }
+ if ((n = tm->tm_min) < 0)
+ {
+ tm->tm_hour -= (60 - n) / 60;
+ n = tm->tm_min = 60 - (-n) % 60;
+ }
+ if (n > 59)
+ {
+ tm->tm_hour += n / 60;
+ tm->tm_min %= 60;
+ }
+ if ((n = tm->tm_hour) < 0)
+ {
+ tm->tm_mday -= (23 - n) / 24;
+ tm->tm_hour = 24 - (-n) % 24;
+ }
+ else if (n >= 24)
+ {
+ tm->tm_mday += n / 24;
+ tm->tm_hour %= 24;
+ }
+ if (tm->tm_mon >= 12)
+ {
+ tm->tm_year += tm->tm_mon / 12;
+ tm->tm_mon %= 12;
+ }
+ else if (tm->tm_mon < 0)
+ {
+ tm->tm_year--;
+ if ((tm->tm_mon += 12) < 0)
+ {
+ tm->tm_year += tm->tm_mon / 12;
+ tm->tm_mon = (-tm->tm_mon) % 12;
+ }
+ }
+ while (tm->tm_mday < -365)
+ {
+ tm->tm_year--;
+ tm->tm_mday += 365 + LEAP(tm);
+ }
+ while (tm->tm_mday > 365)
+ {
+ tm->tm_mday -= 365 + LEAP(tm);
+ tm->tm_year++;
+ }
+ while (tm->tm_mday < 1)
+ {
+ if (--tm->tm_mon < 0)
+ {
+ tm->tm_mon = 11;
+ tm->tm_year--;
+ }
+ tm->tm_mday += DAYS(tm);
+ }
+ while (tm->tm_mday > (n = DAYS(tm)))
+ {
+ tm->tm_mday -= n;
+ if (++tm->tm_mon > 11)
+ {
+ tm->tm_mon = 0;
+ tm->tm_year++;
+ }
+ }
+ if (w)
+ {
+ w = tm->tm_wday;
+ t = tmtime(tm, TM_LOCALZONE);
+ p = tmmake(&t);
+ if (w = (w - p->tm_wday))
+ {
+ if (w < 0)
+ w += 7;
+ tm->tm_wday += w;
+ if ((tm->tm_mday += w) > DAYS(tm))
+ tm->tm_mday -= 7;
+ }
+ }
+ tm->tm_yday = tm_data.sum[tm->tm_mon] + (tm->tm_mon > 1 && LEAP(tm)) + tm->tm_mday - 1;
+ n = tm->tm_year + 1900 - 1;
+ tm->tm_wday = (n + n / 4 - n / 100 + n / 400 + tm->tm_yday + 1) % 7;
+
+ /*
+ * tm_isdst is adjusted by tmtime()
+ */
+
+ return tm;
+}
diff --git a/usr/src/lib/libast/common/tm/tmfmt.c b/usr/src/lib/libast/common/tm/tmfmt.c
new file mode 100644
index 0000000000..58a9ed1ccb
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmfmt.c
@@ -0,0 +1,41 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * time conversion support
+ */
+
+#include <tmx.h>
+
+/*
+ * format date given clock into buf of length len
+ * see tmxfmt() for details
+ */
+
+char*
+tmfmt(char* buf, size_t len, const char* format, time_t* clock)
+{
+ return tmxfmt(buf, len, format, tmxclock(clock));
+}
diff --git a/usr/src/lib/libast/common/tm/tmform.c b/usr/src/lib/libast/common/tm/tmform.c
new file mode 100644
index 0000000000..f4054a2c34
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmform.c
@@ -0,0 +1,44 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * OBSOLETE: use tmfmt() instead
+ *
+ * time conversion support
+ */
+
+#include <ast.h>
+#include <tm.h>
+
+/*
+ * format date given clock
+ * end of buf is returned
+ */
+
+char*
+tmform(char* buf, const char* format, time_t* clock)
+{
+ return tmfmt(buf, 256, format, clock);
+}
diff --git a/usr/src/lib/libast/common/tm/tmgoff.c b/usr/src/lib/libast/common/tm/tmgoff.c
new file mode 100644
index 0000000000..ac6cfca89d
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmgoff.c
@@ -0,0 +1,77 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * time conversion support
+ */
+
+#include <ast.h>
+#include <tm.h>
+#include <ctype.h>
+
+/*
+ * return minutes offset from absolute timezone expression
+ *
+ * [[-+]hh[:mm[:ss]]]
+ * [-+]hhmm
+ *
+ * if e is non-null then it points to the first unrecognized char in s
+ * d returned if no offset in s
+ */
+
+int
+tmgoff(register const char* s, char** e, int d)
+{
+ register int n = d;
+ int east;
+ const char* t = s;
+
+ if ((east = *s == '+') || *s == '-')
+ {
+ s++;
+ if (isdigit(*s) && isdigit(*(s + 1)))
+ {
+ n = ((*s - '0') * 10 + (*(s + 1) - '0')) * 60;
+ s += 2;
+ if (*s == ':')
+ s++;
+ if (isdigit(*s) && isdigit(*(s + 1)))
+ {
+ n += ((*s - '0') * 10 + (*(s + 1) - '0'));
+ s += 2;
+ if (*s == ':')
+ s++;
+ if (isdigit(*s) && isdigit(*(s + 1)))
+ s += 2;
+ }
+ if (east)
+ n = -n;
+ t = s;
+ }
+ }
+ if (e)
+ *e = (char*)t;
+ return n;
+}
diff --git a/usr/src/lib/libast/common/tm/tminit.c b/usr/src/lib/libast/common/tm/tminit.c
new file mode 100644
index 0000000000..6ccab8c24e
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tminit.c
@@ -0,0 +1,454 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * time conversion support
+ */
+
+#include <tm.h>
+#include <ctype.h>
+#include <namval.h>
+
+#include "FEATURE/tmlib"
+
+#ifndef tzname
+# if defined(__DYNAMIC__)
+# define tzname __DYNAMIC__(tzname)
+# else
+# if !_dat_tzname
+# if _dat__tzname
+# undef _dat_tzname
+# define _dat_tzname 1
+# define tzname _tzname
+# endif
+# endif
+# endif
+# if _dat_tzname
+ extern char* tzname[];
+# endif
+#endif
+
+#define TM_type (-1)
+
+static const Namval_t options[] =
+{
+ "adjust", TM_ADJUST,
+ "format", TM_DEFAULT,
+ "leap", TM_LEAP,
+ "subsecond", TM_SUBSECOND,
+ "type", TM_type,
+ "utc", TM_UTC,
+ 0, 0
+};
+
+/*
+ * 2007-03-19 move tm_info from _tm_info_ to (*_tm_infop_)
+ * to allow future Tm_info_t growth
+ * by 2009 _tm_info_ can be static
+ */
+
+#if _BLD_ast && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+
+extern Tm_info_t _tm_info_;
+
+#undef extern
+
+Tm_info_t _tm_info_ = { 0 };
+
+__EXTERN__(Tm_info_t, _tm_info_);
+
+__EXTERN__(Tm_info_t*, _tm_infop_);
+
+Tm_info_t* _tm_infop_ = &_tm_info_;
+
+#if _tzset_environ
+
+static char TZ[256];
+static char* TE[2];
+
+struct tm*
+_tm_localtime(const time_t* t)
+{
+ struct tm* r;
+ char* e;
+
+ if (TZ[0])
+ {
+ if (!environ || !*environ)
+ environ = TE;
+ else
+ e = environ[0];
+ environ[0] = TZ;
+ }
+ r = localtime(t);
+ if (TZ[0])
+ {
+ if (environ == TE)
+ environ = 0;
+ else
+ environ[0] = e;
+ }
+ return r;
+}
+
+#endif
+
+/*
+ * return minutes west of GMT for local time clock
+ *
+ * isdst will point to non-zero if DST is in effect
+ * this routine also kicks in the local initialization
+ */
+
+static int
+tzwest(time_t* clock, int* isdst)
+{
+ register struct tm* tp;
+ register int n;
+ register int m;
+ int h;
+ time_t epoch;
+
+ /*
+ * convert to GMT assuming local time
+ */
+
+ if (!(tp = gmtime(clock)))
+ {
+ /*
+ * some systems return 0 for negative time_t
+ */
+
+ epoch = 0;
+ clock = &epoch;
+ tp = gmtime(clock);
+ }
+ n = tp->tm_yday;
+ h = tp->tm_hour;
+ m = tp->tm_min;
+
+ /*
+ * tmlocaltime() handles DST and GMT offset
+ */
+
+ tp = tmlocaltime(clock);
+ if (n = tp->tm_yday - n)
+ {
+ if (n > 1)
+ n = -1;
+ else if (n < -1)
+ n = 1;
+ }
+ *isdst = tp->tm_isdst;
+ return (h - tp->tm_hour - n * 24) * 60 + m - tp->tm_min;
+}
+
+/*
+ * stropt() option handler
+ */
+
+static int
+tmopt(void* a, const void* p, int n, const char* v)
+{
+ Tm_zone_t* zp;
+
+ NoP(a);
+ if (p)
+ switch (((Namval_t*)p)->value)
+ {
+ case TM_DEFAULT:
+ tm_info.deformat = (n && (n = strlen(v)) > 0 && (n < 2 || v[n-2] != '%' || v[n-1] != '?')) ? strdup(v) : tm_info.format[TM_DEFAULT];
+ break;
+ case TM_type:
+ tm_info.local->type = (n && *v) ? ((zp = tmtype(v, NiL)) ? zp->type : strdup(v)) : 0;
+ break;
+ default:
+ if (n)
+ tm_info.flags |= ((Namval_t*)p)->value;
+ else
+ tm_info.flags &= ~((Namval_t*)p)->value;
+ break;
+ }
+ return 0;
+}
+
+/*
+ * initialize the local timezone
+ */
+
+static void
+tmlocal(void)
+{
+ register Tm_zone_t* zp;
+ register int n;
+ register char* s;
+ register char* e;
+ int i;
+ int m;
+ int isdst;
+ char* t;
+ struct tm* tp;
+ time_t now;
+ char buf[16];
+
+ static Tm_zone_t local;
+
+#if _lib_tzset
+#if _tzset_environ
+ if (s = getenv("TZ"))
+ {
+ sfsprintf(TZ, sizeof(TZ), "TZ=%s", s);
+ if (!environ || !*environ)
+ environ = TE;
+ else
+ e = environ[0];
+ environ[0] = TZ;
+ }
+ else
+ {
+ TZ[0] = 0;
+ e = 0;
+ }
+#endif
+ tzset();
+#if _tzset_environ
+ if (environ == TE)
+ environ = 0;
+ else if (e)
+ environ[0] = e;
+#endif
+#endif
+#if _dat_tzname
+ local.standard = strdup(tzname[0]);
+ local.daylight = strdup(tzname[1]);
+#endif
+ tmlocale();
+
+ /*
+ * tm_info.local
+ */
+
+ tm_info.zone = tm_info.local = &local;
+ time(&now);
+ n = tzwest(&now, &isdst);
+
+ /*
+ * compute local DST offset by roaming
+ * through the last 12 months until tzwest() changes
+ */
+
+ for (i = 0; i < 12; i++)
+ {
+ now -= 31 * 24 * 60 * 60;
+ if ((m = tzwest(&now, &isdst)) != n)
+ {
+ if (!isdst)
+ {
+ isdst = n;
+ n = m;
+ m = isdst;
+ }
+ m -= n;
+ break;
+ }
+ }
+ local.west = n;
+ local.dst = m;
+
+ /*
+ * now get the time zone names
+ */
+
+#if _dat_tzname
+ if (tzname[0])
+ {
+ /*
+ * POSIX
+ */
+
+ if (!local.standard)
+ local.standard = strdup(tzname[0]);
+ if (!local.daylight)
+ local.daylight = strdup(tzname[1]);
+ }
+ else
+#endif
+ if ((s = getenv("TZNAME")) && *s && (s = strdup(s)))
+ {
+ /*
+ * BSD
+ */
+
+ local.standard = s;
+ if (s = strchr(s, ','))
+ *s++ = 0;
+ else
+ s = "";
+ local.daylight = s;
+ }
+ else if ((s = getenv("TZ")) && *s && *s != ':' && (s = strdup(s)))
+ {
+ /*
+ * POSIX style but skipped by tmlocaltime()
+ */
+
+ local.standard = s;
+ if (*++s && *++s && *++s)
+ {
+ *s++ = 0;
+ tmgoff(s, &t, 0);
+ for (s = t; isalpha(*t); t++);
+ *t = 0;
+ }
+ else
+ s = "";
+ local.daylight = s;
+ }
+ else
+ {
+ /*
+ * tm_data.zone table lookup
+ */
+
+ t = 0;
+ for (zp = tm_data.zone; zp->standard; zp++)
+ {
+ if (zp->type)
+ t = zp->type;
+ if (zp->west == n && zp->dst == m)
+ {
+ local.type = t;
+ local.standard = zp->standard;
+ if (!(s = zp->daylight))
+ {
+ e = (s = buf) + sizeof(buf);
+ s = tmpoff(s, e - s, zp->standard, 0, 0);
+ if (s < e - 1)
+ {
+ *s++ = ' ';
+ tmpoff(s, e - s, tm_info.format[TM_DT], m, TM_DST);
+ }
+ s = strdup(buf);
+ }
+ local.daylight = s;
+ break;
+ }
+ }
+ if (!zp->standard)
+ {
+ /*
+ * not in the table
+ */
+
+ e = (s = buf) + sizeof(buf);
+ s = tmpoff(s, e - s, tm_info.format[TM_UT], n, 0);
+ local.standard = strdup(buf);
+ if (s < e - 1)
+ {
+ *s++ = ' ';
+ tmpoff(s, e - s, tm_info.format[TM_UT], m, TM_DST);
+ local.daylight = strdup(buf);
+ }
+ }
+ }
+
+ /*
+ * set the options
+ */
+
+ stropt(getenv("TM_OPTIONS"), options, sizeof(*options), tmopt, NiL);
+
+ /*
+ * the time zone type is probably related to the locale
+ */
+
+ if (!local.type)
+ {
+ s = local.standard;
+ t = 0;
+ for (zp = tm_data.zone; zp->standard; zp++)
+ {
+ if (zp->type)
+ t = zp->type;
+ if (tmword(s, NiL, zp->standard, NiL, 0))
+ {
+ local.type = t;
+ break;
+ }
+ }
+ }
+
+ /*
+ * tm_info.flags
+ */
+
+ if (!(tm_info.flags & TM_ADJUST))
+ {
+ now = (time_t)78811200; /* Jun 30 1972 23:59:60 */
+ tp = tmlocaltime(&now);
+ if (tp->tm_sec != 60)
+ tm_info.flags |= TM_ADJUST;
+ }
+ if (!(tm_info.flags & TM_UTC))
+ {
+ s = local.standard;
+ zp = tm_data.zone;
+ if (local.daylight)
+ zp++;
+ for (; !zp->type && zp->standard; zp++)
+ if (tmword(s, NiL, zp->standard, NiL, 0))
+ {
+ tm_info.flags |= TM_UTC;
+ break;
+ }
+ }
+}
+
+/*
+ * initialize tm data
+ */
+
+void
+tminit(register Tm_zone_t* zp)
+{
+ static uint32_t serial = ~(uint32_t)0;
+
+ if (serial != ast.env_serial)
+ {
+ serial = ast.env_serial;
+ if (tm_info.local)
+ {
+ memset(tm_info.local, 0, sizeof(*tm_info.local));
+ tm_info.local = 0;
+ }
+ }
+ if (!tm_info.local)
+ tmlocal();
+ if (!zp)
+ zp = tm_info.local;
+ tm_info.zone = zp;
+}
diff --git a/usr/src/lib/libast/common/tm/tmleap.c b/usr/src/lib/libast/common/tm/tmleap.c
new file mode 100644
index 0000000000..0aa3d00b64
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmleap.c
@@ -0,0 +1,41 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * time conversion support
+ */
+
+#include <tmx.h>
+
+/*
+ * return clock with leap seconds adjusted
+ * see tmxleap() for details
+ */
+
+time_t
+tmleap(register time_t* clock)
+{
+ return tmxsec(tmxleap(tmxclock(clock)));
+}
diff --git a/usr/src/lib/libast/common/tm/tmlex.c b/usr/src/lib/libast/common/tm/tmlex.c
new file mode 100644
index 0000000000..13339833c6
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmlex.c
@@ -0,0 +1,67 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * time conversion support
+ */
+
+#include <ast.h>
+#include <tm.h>
+#include <ctype.h>
+
+/*
+ * return the tab table index that matches s ignoring case and .'s
+ * tm_data.format checked if tminfo.format!=tm_data.format
+ *
+ * ntab and nsuf are the number of elements in tab and suf,
+ * -1 for 0 sentinel
+ *
+ * all isalpha() chars in str must match
+ * suf is a table of nsuf valid str suffixes
+ * if e is non-null then it will point to first unmatched char in str
+ * which will always be non-isalpha()
+ */
+
+int
+tmlex(register const char* s, char** e, char** tab, int ntab, char** suf, int nsuf)
+{
+ register char** p;
+ register char* x;
+ register int n;
+
+ for (p = tab, n = ntab; n-- && (x = *p); p++)
+ if (*x && *x != '%' && tmword(s, e, x, suf, nsuf))
+ return p - tab;
+ if (tm_info.format != tm_data.format && tab >= tm_info.format && tab < tm_info.format + TM_NFORM)
+ {
+ tab = tm_data.format + (tab - tm_info.format);
+ if (suf && tab >= tm_info.format && tab < tm_info.format + TM_NFORM)
+ suf = tm_data.format + (suf - tm_info.format);
+ for (p = tab, n = ntab; n-- && (x = *p); p++)
+ if (*x && *x != '%' && tmword(s, e, x, suf, nsuf))
+ return p - tab;
+ }
+ return -1;
+}
diff --git a/usr/src/lib/libast/common/tm/tmlocale.c b/usr/src/lib/libast/common/tm/tmlocale.c
new file mode 100644
index 0000000000..9d88e6e273
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmlocale.c
@@ -0,0 +1,619 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * time conversion translation support
+ */
+
+#include <ast.h>
+#include <cdt.h>
+#include <iconv.h>
+#include <mc.h>
+#include <tm.h>
+
+#include "lclib.h"
+
+static struct
+{
+ char* format;
+ Lc_info_t* locale;
+ char null[1];
+} state;
+
+/*
+ * this is unix dadgummit
+ */
+
+static int
+standardized(Lc_info_t* li, register char** b)
+{
+ if ((li->lc->language->flags & (LC_debug|LC_default)) || streq(li->lc->language->code, "en"))
+ {
+ b[TM_TIME] = "%H:%M:%S";
+ b[TM_DATE] = "%m/%d/%y";
+ b[TM_DEFAULT] = "%a %b %e %T %Z %Y";
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ * fix up LC_TIME data after loading
+ */
+
+static void
+fixup(Lc_info_t* li, register char** b)
+{
+ register char** v;
+ register char** e;
+ register int n;
+
+ static int must[] =
+ {
+ TM_TIME,
+ TM_DATE,
+ TM_DEFAULT,
+ TM_CTIME,
+ TM_DATE_1,
+ TM_INTERNATIONAL,
+ TM_RECENT,
+ TM_DISTANT,
+ TM_MERIDIAN_TIME,
+ };
+
+ standardized(li, b);
+ for (v = b, e = b + TM_NFORM; v < e; v++)
+ if (!*v)
+ *v = state.null;
+ for (n = 0; n < elementsof(must); n++)
+ if (!*b[must[n]])
+ b[must[n]] = tm_data.format[must[n]];
+ if (li->lc->flags & LC_default)
+ for (n = 0; n < TM_NFORM; n++)
+ if (!*b[n])
+ b[n] = tm_data.format[n];
+ if (strchr(b[TM_UT], '%'))
+ {
+ tm_info.deformat = b[TM_UT];
+ for (n = TM_UT; n < TM_DT; n++)
+ b[n] = state.null;
+ }
+ else
+ tm_info.deformat = b[TM_DEFAULT];
+ tm_info.format = b;
+ if (!(tm_info.deformat = state.format))
+ tm_info.deformat = tm_info.format[TM_DEFAULT];
+ li->data = (void*)b;
+}
+
+#if _WINIX
+
+#include <ast_windows.h>
+
+typedef struct Map_s
+{
+ LCID native;
+ int local;
+} Map_t;
+
+static const Map_t map[] =
+{
+ LOCALE_S1159, (TM_MERIDIAN+0),
+ LOCALE_S2359, (TM_MERIDIAN+1),
+ LOCALE_SABBREVDAYNAME1, (TM_DAY_ABBREV+1),
+ LOCALE_SABBREVDAYNAME2, (TM_DAY_ABBREV+2),
+ LOCALE_SABBREVDAYNAME3, (TM_DAY_ABBREV+3),
+ LOCALE_SABBREVDAYNAME4, (TM_DAY_ABBREV+4),
+ LOCALE_SABBREVDAYNAME5, (TM_DAY_ABBREV+5),
+ LOCALE_SABBREVDAYNAME6, (TM_DAY_ABBREV+6),
+ LOCALE_SABBREVDAYNAME7, (TM_DAY_ABBREV+0),
+ LOCALE_SABBREVMONTHNAME1, (TM_MONTH_ABBREV+0),
+ LOCALE_SABBREVMONTHNAME2, (TM_MONTH_ABBREV+1),
+ LOCALE_SABBREVMONTHNAME3, (TM_MONTH_ABBREV+2),
+ LOCALE_SABBREVMONTHNAME4, (TM_MONTH_ABBREV+3),
+ LOCALE_SABBREVMONTHNAME5, (TM_MONTH_ABBREV+4),
+ LOCALE_SABBREVMONTHNAME6, (TM_MONTH_ABBREV+5),
+ LOCALE_SABBREVMONTHNAME7, (TM_MONTH_ABBREV+6),
+ LOCALE_SABBREVMONTHNAME8, (TM_MONTH_ABBREV+7),
+ LOCALE_SABBREVMONTHNAME9, (TM_MONTH_ABBREV+8),
+ LOCALE_SABBREVMONTHNAME10, (TM_MONTH_ABBREV+9),
+ LOCALE_SABBREVMONTHNAME11, (TM_MONTH_ABBREV+10),
+ LOCALE_SABBREVMONTHNAME12, (TM_MONTH_ABBREV+11),
+ LOCALE_SDAYNAME1, (TM_DAY+1),
+ LOCALE_SDAYNAME2, (TM_DAY+2),
+ LOCALE_SDAYNAME3, (TM_DAY+3),
+ LOCALE_SDAYNAME4, (TM_DAY+4),
+ LOCALE_SDAYNAME5, (TM_DAY+5),
+ LOCALE_SDAYNAME6, (TM_DAY+6),
+ LOCALE_SDAYNAME7, (TM_DAY+0),
+ LOCALE_SMONTHNAME1, (TM_MONTH+0),
+ LOCALE_SMONTHNAME2, (TM_MONTH+1),
+ LOCALE_SMONTHNAME3, (TM_MONTH+2),
+ LOCALE_SMONTHNAME4, (TM_MONTH+3),
+ LOCALE_SMONTHNAME5, (TM_MONTH+4),
+ LOCALE_SMONTHNAME6, (TM_MONTH+5),
+ LOCALE_SMONTHNAME7, (TM_MONTH+6),
+ LOCALE_SMONTHNAME8, (TM_MONTH+7),
+ LOCALE_SMONTHNAME9, (TM_MONTH+8),
+ LOCALE_SMONTHNAME10, (TM_MONTH+9),
+ LOCALE_SMONTHNAME11, (TM_MONTH+10),
+ LOCALE_SMONTHNAME12, (TM_MONTH+11),
+};
+
+#undef extern
+
+/*
+ * convert ms word date spec w to posix strftime format f
+ * next char after f returned
+ * the caller already made sure f is big enough
+ */
+
+static char*
+word2posix(register char* f, register char* w, int alternate)
+{
+ register char* r;
+ register int c;
+ register int p;
+ register int n;
+
+ while (*w)
+ {
+ p = 0;
+ r = w;
+ while (*++w == *r);
+ if ((n = w - r) > 3 && alternate)
+ n--;
+ switch (*r)
+ {
+ case 'a':
+ case 'A':
+ if (!strncasecmp(w, "am/pm", 5))
+ w += 5;
+ else if (!strncasecmp(w, "a/p", 3))
+ w += 3;
+ c = 'p';
+ break;
+ case 'd':
+ switch (n)
+ {
+ case 1:
+ p = '-';
+ /*FALLTHROUGH*/
+ case 2:
+ c = 'd';
+ break;
+ case 3:
+ c = 'a';
+ break;
+ default:
+ c = 'A';
+ break;
+ }
+ break;
+ case 'h':
+ switch (n)
+ {
+ case 1:
+ p = '-';
+ /*FALLTHROUGH*/
+ default:
+ c = 'I';
+ break;
+ }
+ break;
+ case 'H':
+ switch (n)
+ {
+ case 1:
+ p = '-';
+ /*FALLTHROUGH*/
+ default:
+ c = 'H';
+ break;
+ }
+ break;
+ case 'M':
+ switch (n)
+ {
+ case 1:
+ p = '-';
+ /*FALLTHROUGH*/
+ case 2:
+ c = 'm';
+ break;
+ case 3:
+ c = 'b';
+ break;
+ default:
+ c = 'B';
+ break;
+ }
+ break;
+ case 'm':
+ switch (n)
+ {
+ case 1:
+ p = '-';
+ /*FALLTHROUGH*/
+ default:
+ c = 'M';
+ break;
+ }
+ break;
+ case 's':
+ switch (n)
+ {
+ case 1:
+ p = '-';
+ /*FALLTHROUGH*/
+ default:
+ c = 'S';
+ break;
+ }
+ break;
+ case 'y':
+ switch (n)
+ {
+ case 1:
+ p = '-';
+ /*FALLTHROUGH*/
+ case 2:
+ c = 'y';
+ break;
+ default:
+ c = 'Y';
+ break;
+ }
+ break;
+ case '\'':
+ if (n & 1)
+ for (w = r + 1; *w; *f++ = *w++)
+ if (*w == '\'')
+ {
+ w++;
+ break;
+ }
+ continue;
+ case '%':
+ while (r < w)
+ {
+ *f++ = *r++;
+ *f++ = *r++;
+ }
+ continue;
+ default:
+ while (r < w)
+ *f++ = *r++;
+ continue;
+ }
+ *f++ = '%';
+ if (p)
+ *f++ = '-';
+ *f++ = c;
+ }
+ *f++ = 0;
+ return f;
+}
+
+/*
+ * load the native LC_TIME data for the current locale
+ */
+
+static void
+native_lc_time(Lc_info_t* li)
+{
+ register char* s;
+ register char* t;
+ register char** b;
+ register int n;
+ register int m;
+ register int i;
+ LCID lcid;
+ int nt;
+ int ns;
+ int nl;
+ int clock_24;
+ int leading_0;
+ char buf[256];
+
+ lcid = li->lc->index;
+ nt = 2 * GetLocaleInfo(lcid, LOCALE_STIME, 0, 0) + 7; /* HH:MM:SS */
+ ns = 3 * GetLocaleInfo(lcid, LOCALE_SSHORTDATE, 0, 0);
+ nl = 3 * GetLocaleInfo(lcid, LOCALE_SLONGDATE, 0, 0);
+ n = nt + ns + nl;
+ for (i = 0; i < elementsof(map); i++)
+ n += GetLocaleInfo(lcid, map[i].native, 0, 0);
+ if (!(b = newof(0, char*, TM_NFORM, n)))
+ return;
+ s = (char*)(b + TM_NFORM);
+ for (i = 0; i < elementsof(map); i++)
+ {
+ if (!(m = GetLocaleInfo(lcid, map[i].native, s, n)))
+ goto bad;
+ b[map[i].local] = s;
+ s += m;
+ }
+ if (!standardized(li, b))
+ {
+ /*
+ * synthesize TM_TIME format from the ms word template
+ */
+
+ if (!GetLocaleInfo(lcid, LOCALE_ITIME, buf, sizeof(buf)))
+ goto bad;
+ clock_24 = atoi(buf);
+ if (!GetLocaleInfo(lcid, LOCALE_ITLZERO, buf, sizeof(buf)))
+ goto bad;
+ leading_0 = atoi(buf);
+ if (!GetLocaleInfo(lcid, LOCALE_STIME, buf, sizeof(buf)))
+ goto bad;
+ b[TM_TIME] = s;
+ *s++ = '%';
+ if (!leading_0)
+ *s++ = '-';
+ *s++ = clock_24 ? 'H' : 'I';
+ for (t = buf; *s = *t++; s++);
+ *s++ = '%';
+ if (!leading_0)
+ *s++ = '-';
+ *s++ = 'M';
+ for (t = buf; *s = *t++; s++);
+ *s++ = '%';
+ if (!leading_0)
+ *s++ = '-';
+ *s++ = 'S';
+ *s++ = 0;
+
+ /*
+ * synthesize TM_DATE format
+ */
+
+ if (!GetLocaleInfo(lcid, LOCALE_SSHORTDATE, buf, sizeof(buf)))
+ goto bad;
+ b[TM_DATE] = s;
+ s = word2posix(s, buf, 1);
+
+ /*
+ * synthesize TM_DEFAULT format
+ */
+
+ if (!GetLocaleInfo(lcid, LOCALE_SLONGDATE, buf, sizeof(buf)))
+ goto bad;
+ b[TM_DEFAULT] = s;
+ s = word2posix(s, buf, 1);
+ strcpy(s - 1, " %X");
+ }
+
+ /*
+ * done
+ */
+
+ fixup(li, b);
+ return;
+ bad:
+ free(b);
+}
+
+#else
+
+#if _lib_nl_langinfo && _hdr_langinfo
+
+#if _hdr_nl_types
+#include <nl_types.h>
+#endif
+
+#include <langinfo.h>
+
+typedef struct Map_s
+{
+ int native;
+ int local;
+} Map_t;
+
+static const Map_t map[] =
+{
+ AM_STR, (TM_MERIDIAN+0),
+ PM_STR, (TM_MERIDIAN+1),
+ ABDAY_1, (TM_DAY_ABBREV+0),
+ ABDAY_2, (TM_DAY_ABBREV+1),
+ ABDAY_3, (TM_DAY_ABBREV+2),
+ ABDAY_4, (TM_DAY_ABBREV+3),
+ ABDAY_5, (TM_DAY_ABBREV+4),
+ ABDAY_6, (TM_DAY_ABBREV+5),
+ ABDAY_7, (TM_DAY_ABBREV+6),
+ ABMON_1, (TM_MONTH_ABBREV+0),
+ ABMON_2, (TM_MONTH_ABBREV+1),
+ ABMON_3, (TM_MONTH_ABBREV+2),
+ ABMON_4, (TM_MONTH_ABBREV+3),
+ ABMON_5, (TM_MONTH_ABBREV+4),
+ ABMON_6, (TM_MONTH_ABBREV+5),
+ ABMON_7, (TM_MONTH_ABBREV+6),
+ ABMON_8, (TM_MONTH_ABBREV+7),
+ ABMON_9, (TM_MONTH_ABBREV+8),
+ ABMON_10, (TM_MONTH_ABBREV+9),
+ ABMON_11, (TM_MONTH_ABBREV+10),
+ ABMON_12, (TM_MONTH_ABBREV+11),
+ DAY_1, (TM_DAY+0),
+ DAY_2, (TM_DAY+1),
+ DAY_3, (TM_DAY+2),
+ DAY_4, (TM_DAY+3),
+ DAY_5, (TM_DAY+4),
+ DAY_6, (TM_DAY+5),
+ DAY_7, (TM_DAY+6),
+ MON_1, (TM_MONTH+0),
+ MON_2, (TM_MONTH+1),
+ MON_3, (TM_MONTH+2),
+ MON_4, (TM_MONTH+3),
+ MON_5, (TM_MONTH+4),
+ MON_6, (TM_MONTH+5),
+ MON_7, (TM_MONTH+6),
+ MON_8, (TM_MONTH+7),
+ MON_9, (TM_MONTH+8),
+ MON_10, (TM_MONTH+9),
+ MON_11, (TM_MONTH+10),
+ MON_12, (TM_MONTH+11),
+ D_T_FMT, TM_DEFAULT,
+ D_FMT, TM_DATE,
+ T_FMT, TM_TIME,
+#ifdef ERA
+ ERA, TM_ERA,
+ ERA_D_T_FMT, TM_ERA_DEFAULT,
+ ERA_D_FMT, TM_ERA_DATE,
+ ERA_T_FMT, TM_ERA_TIME,
+#endif
+#ifdef ALT_DIGITS
+ ALT_DIGITS, TM_DIGITS,
+#endif
+};
+
+static void
+native_lc_time(Lc_info_t* li)
+{
+ register char* s;
+ register char* t;
+ register char** b;
+ register int n;
+ register int m;
+ register int i;
+
+ n = 0;
+ for (i = 0; i < elementsof(map); i++)
+ n += strlen(nl_langinfo(map[i].native)) + 1;
+ if (!(b = newof(0, char*, TM_NFORM, n)))
+ return;
+ s = (char*)(b + TM_NFORM);
+ for (i = 0; i < elementsof(map); i++)
+ {
+ b[map[i].local] = s;
+ t = nl_langinfo(map[i].native);
+ while (*s++ = *t++);
+ }
+ fixup(li, b);
+}
+
+#else
+
+#define native_lc_time(li) ((li->data=(void*)(tm_info.format=tm_data.format)),(tm_info.deformat=tm_info.format[TM_DEFAULT]))
+
+#endif
+
+#endif
+
+/*
+ * load the LC_TIME data for the current locale
+ */
+
+static void
+load(Lc_info_t* li)
+{
+ register char* s;
+ register char** b;
+ register char** v;
+ register char** e;
+ unsigned char* u;
+ ssize_t n;
+ iconv_t cvt;
+ Sfio_t* sp;
+ Sfio_t* tp;
+ char path[PATH_MAX];
+
+ if (b = (char**)li->data)
+ {
+ tm_info.format = b;
+ if (!(tm_info.deformat = state.format))
+ tm_info.deformat = tm_info.format[TM_DEFAULT];
+ return;
+ }
+ tm_info.format = tm_data.format;
+ if (!(tm_info.deformat = state.format))
+ tm_info.deformat = tm_info.format[TM_DEFAULT];
+ if (mcfind(path, NiL, NiL, LC_TIME, 0) && (sp = sfopen(NiL, path, "r")))
+ {
+ n = sfsize(sp);
+ tp = 0;
+ if (u = (unsigned char*)sfreserve(sp, 3, 1))
+ {
+ if (u[0] == 0xef && u[1] == 0xbb && u[2] == 0xbf && (cvt = iconv_open("", "utf")) != (iconv_t)(-1))
+ {
+ if (tp = sfstropen())
+ {
+ sfread(sp, u, 3);
+ n = iconv_move(cvt, sp, tp, SF_UNBOUND, NiL);
+ }
+ iconv_close(cvt);
+ }
+ if (!tp)
+ sfread(sp, u, 0);
+ }
+ if (b = newof(0, char*, TM_NFORM, n + 2))
+ {
+ v = b;
+ e = b + TM_NFORM;
+ s = (char*)e;
+ if (tp && memcpy(s, sfstrbase(tp), n) || !tp && sfread(sp, s, n) == n)
+ {
+ s[n] = '\n';
+ while (v < e)
+ {
+ *v++ = s;
+ if (!(s = strchr(s, '\n')))
+ break;
+ *s++ = 0;
+ }
+ fixup(li, b);
+ }
+ else
+ free(b);
+ }
+ if (tp)
+ sfclose(tp);
+ sfclose(sp);
+ }
+ else
+ native_lc_time(li);
+}
+
+/*
+ * check that tm_info.format matches the current locale
+ */
+
+char**
+tmlocale(void)
+{
+ Lc_info_t* li;
+
+ if (!tm_info.format)
+ {
+ tm_info.format = tm_data.format;
+ if (!tm_info.deformat)
+ tm_info.deformat = tm_info.format[TM_DEFAULT];
+ else if (tm_info.deformat != tm_info.format[TM_DEFAULT])
+ state.format = tm_info.deformat;
+ }
+ li = LCINFO(AST_LC_TIME);
+ if (!li->data)
+ load(li);
+ return tm_info.format;
+}
diff --git a/usr/src/lib/libast/common/tm/tmmake.c b/usr/src/lib/libast/common/tm/tmmake.c
new file mode 100644
index 0000000000..f8d39ca3fa
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmmake.c
@@ -0,0 +1,41 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * time conversion support
+ */
+
+#include <tmx.h>
+
+/*
+ * return Tm_t for clock
+ * see tmxmake() for details
+ */
+
+Tm_t*
+tmmake(time_t* clock)
+{
+ return tmxmake(tmxclock(clock));
+}
diff --git a/usr/src/lib/libast/common/tm/tmpoff.c b/usr/src/lib/libast/common/tm/tmpoff.c
new file mode 100644
index 0000000000..442568574a
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmpoff.c
@@ -0,0 +1,62 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * time conversion support
+ */
+
+#include <ast.h>
+#include <tm.h>
+
+/*
+ * n is minutes west of UTC
+ *
+ * append p and SHHMM part of n to s
+ * where S is + or -
+ *
+ * n ignored if n==d
+ * end of s is returned
+ */
+
+char*
+tmpoff(register char* s, size_t z, register const char* p, register int n, int d)
+{
+ register char* e = s + z;
+
+ while (s < e && (*s = *p++))
+ s++;
+ if (n != d && s < e)
+ {
+ if (n < 0)
+ {
+ n = -n;
+ *s++ = '+';
+ }
+ else
+ *s++ = '-';
+ s += sfsprintf(s, e - s, "%02d%02d", n / 60, n % 60);
+ }
+ return s;
+}
diff --git a/usr/src/lib/libast/common/tm/tmscan.c b/usr/src/lib/libast/common/tm/tmscan.c
new file mode 100644
index 0000000000..928adb7612
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmscan.c
@@ -0,0 +1,41 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * time conversion support
+ */
+
+#include <tmx.h>
+
+/*
+ * scan date expression in s using format
+ * see tmxscan() for details
+ */
+
+time_t
+tmscan(const char* s, char** e, const char* format, char** f, time_t* clock, long flags)
+{
+ return tmxsec(tmxscan(s, e, format, f, tmxclock(clock), flags));
+}
diff --git a/usr/src/lib/libast/common/tm/tmsleep.c b/usr/src/lib/libast/common/tm/tmsleep.c
new file mode 100644
index 0000000000..6158190dfd
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmsleep.c
@@ -0,0 +1,42 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * nanosecond resolution sleep
+ */
+
+#include <ast.h>
+#include <tm.h>
+#include <tv.h>
+
+int
+tmsleep(time_t sec, time_t nsec)
+{
+ Tv_t tv;
+
+ tv.tv_sec = sec;
+ tv.tv_nsec = nsec;
+ return tvsleep(&tv, NiL);
+}
diff --git a/usr/src/lib/libast/common/tm/tmtime.c b/usr/src/lib/libast/common/tm/tmtime.c
new file mode 100644
index 0000000000..a57dcc00cb
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmtime.c
@@ -0,0 +1,41 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * time conversion support
+ */
+
+#include <tmx.h>
+
+/*
+ * convert Tm_t to time_t
+ * see tmxtime() for details
+ */
+
+time_t
+tmtime(register Tm_t* tm, int west)
+{
+ return tmxsec(tmxtime(tm, west));
+}
diff --git a/usr/src/lib/libast/common/tm/tmtype.c b/usr/src/lib/libast/common/tm/tmtype.c
new file mode 100644
index 0000000000..29a0a8c77e
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmtype.c
@@ -0,0 +1,57 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * time conversion support
+ */
+
+#include <ast.h>
+#include <tm.h>
+
+/*
+ * return the tm_data.zone[] time zone entry for type s
+ *
+ * if e is non-null then it will point to the first
+ * unmatched char in s
+ *
+ * 0 returned for no match
+ */
+
+Tm_zone_t*
+tmtype(register const char* s, char** e)
+{
+ register Tm_zone_t* zp;
+ register char* t;
+
+ tmset(tm_info.zone);
+ zp = tm_info.local;
+ do
+ {
+ if ((t = zp->type) && tmword(s, e, t, NiL, 0)) return(zp);
+ if (zp == tm_info.local) zp = tm_data.zone;
+ else zp++;
+ } while (zp->standard);
+ return(0);
+}
diff --git a/usr/src/lib/libast/common/tm/tmweek.c b/usr/src/lib/libast/common/tm/tmweek.c
new file mode 100644
index 0000000000..7618bd4cde
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmweek.c
@@ -0,0 +1,87 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * Time_t conversion support
+ */
+
+#include <tmx.h>
+
+static unsigned char offset[7][3] =
+{
+ { 7, 6, 6 },
+ { 1, 7, 7 },
+ { 2, 1, 8 },
+ { 3, 2, 9 },
+ { 4, 3, 10},
+ { 5, 4, 4 },
+ { 6, 5, 5 },
+};
+
+/*
+ * type is week type
+ * 0 sunday first day of week
+ * 1 monday first day of week
+ * 2 monday first day of iso week
+ * if week<0 then return week for tm
+ * if day<0 then set tm to first day of week
+ * otherwise set tm to day in week
+ * and return tm->tm_yday
+ */
+
+int
+tmweek(Tm_t* tm, int type, int week, int day)
+{
+ int d;
+
+ if (week < 0)
+ {
+ if ((day = tm->tm_wday - tm->tm_yday % 7) < 0)
+ day += 7;
+ week = (tm->tm_yday + offset[day][type]) / 7;
+ if (type == 2)
+ {
+ if (!week)
+ week = (day > 0 && day < 6 || tmisleapyear(tm->tm_year - 1)) ? 53 : 52;
+ else if (week == 53 && (tm->tm_wday + (31 - tm->tm_mday)) < 4)
+ week = 1;
+ }
+ return week;
+ }
+ if (day < 0)
+ day = type != 0;
+ tm->tm_mon = 0;
+ tm->tm_mday = 1;
+ tmfix(tm);
+ d = tm->tm_wday;
+ tm->tm_mday = week * 7 - offset[d][type] + ((day || type != 2) ? day : 7);
+ tmfix(tm);
+ if (d = tm->tm_wday - day)
+ {
+ tm->tm_mday -= d;
+ tmfix(tm);
+ }
+ return tm->tm_yday;
+}
diff --git a/usr/src/lib/libast/common/tm/tmword.c b/usr/src/lib/libast/common/tm/tmword.c
new file mode 100644
index 0000000000..8333322856
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmword.c
@@ -0,0 +1,89 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * time conversion support
+ */
+
+#include <ast.h>
+#include <tm.h>
+#include <ctype.h>
+
+/*
+ * match s against t ignoring case and .'s
+ *
+ * suf is an n element table of suffixes that may trail s
+ * if all isalpha() chars in s match then 1 is returned
+ * and if e is non-null it will point to the first unmatched
+ * char in s, otherwise 0 is returned
+ */
+
+int
+tmword(register const char* s, char** e, register const char* t, char** suf, int n)
+{
+ register int c;
+ const char* b;
+
+ if (*s && *t)
+ {
+ b = s;
+ while (c = *s++)
+ {
+ if (c != '.')
+ {
+ if (!isalpha(c) || c != *t && (islower(c) ? toupper(c) : tolower(c)) != *t)
+ break;
+ t++;
+ }
+ }
+ s--;
+ if (!isalpha(c))
+ {
+ if (c == '_')
+ s++;
+ if (e)
+ *e = (char*)s;
+ return s > b;
+ }
+ if (!*t && s > (b + 1))
+ {
+ b = s;
+ while (n-- && (t = *suf++))
+ {
+ s = b;
+ while (isalpha(c = *s++) && (c == *t || (islower(c) ? toupper(c) : tolower(c)) == *t)) t++;
+ if (!*t && !isalpha(c))
+ {
+ if (c != '_')
+ s--;
+ if (e)
+ *e = (char*)s;
+ return 1;
+ }
+ }
+ }
+ }
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/tm/tmxdate.c b/usr/src/lib/libast/common/tm/tmxdate.c
new file mode 100644
index 0000000000..72a260459e
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmxdate.c
@@ -0,0 +1,1226 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * Time_t conversion support
+ *
+ * relative times inspired by Steve Bellovin's netnews getdate(3)
+ */
+
+#include <tmx.h>
+#include <ctype.h>
+
+#define dig1(s,n) ((n)=((*(s)++)-'0'))
+#define dig2(s,n) ((n)=((*(s)++)-'0')*10,(n)+=(*(s)++)-'0')
+#define dig3(s,n) ((n)=((*(s)++)-'0')*100,(n)+=((*(s)++)-'0')*10,(n)+=(*(s)++)-'0')
+#define dig4(s,n) ((n)=((*(s)++)-'0')*1000,(n)+=((*(s)++)-'0')*100,(n)+=((*(s)++)-'0')*10,(n)+=(*(s)++)-'0')
+
+#define BREAK (1<<0)
+#define CCYYMMDDHHMMSS (1<<1)
+#define CRON (1<<2)
+#define DAY (1<<3)
+#define EXACT (1<<4)
+#define FINAL (1<<5)
+#define HOLD (1<<6)
+#define HOUR (1<<7)
+#define LAST (1<<8)
+#define MDAY (1<<9)
+#define MINUTE (1<<10)
+#define MONTH (1<<11)
+#define NEXT (1<<12)
+#define NSEC (1<<13)
+#define SECOND (1<<14)
+#define THIS (1L<<15)
+#define WDAY (1L<<16)
+#define YEAR (1L<<17)
+#define ZONE (1L<<18)
+
+/*
+ * parse cron range into set
+ * return: -1:error 0:* 1:some
+ */
+
+static int
+range(register char* s, char** e, char* set, int lo, int hi)
+{
+ int n;
+ int m;
+ int i;
+ char* t;
+
+ while (isspace(*s) || *s == '_')
+ s++;
+ if (*s == '*')
+ {
+ *e = s + 1;
+ return 0;
+ }
+ memset(set, 0, hi + 1);
+ for (;;)
+ {
+ n = strtol(s, &t, 10);
+ if (s == t || n < lo || n > hi)
+ return -1;
+ i = 1;
+ if (*(s = t) == '-')
+ {
+ m = strtol(++s, &t, 10);
+ if (s == t || m < n || m > hi)
+ return -1;
+ if (*(s = t) == '/')
+ {
+ i = strtol(++s, &t, 10);
+ if (s == t || i < 1)
+ return -1;
+ s = t;
+ }
+ }
+ else
+ m = n;
+ for (; n <= m; n += i)
+ set[n] = 1;
+ if (*s != ',')
+ break;
+ s++;
+ }
+ *e = s;
+ return 1;
+}
+
+/*
+ * parse date expression in s and return Time_t value
+ *
+ * if non-null, e points to the first invalid sequence in s
+ * now provides default values
+ */
+
+Time_t
+tmxdate(register const char* s, char** e, Time_t now)
+{
+ register Tm_t* tm;
+ register long n;
+ register int w;
+ unsigned long set;
+ unsigned long state;
+ unsigned long flags;
+ Time_t fix;
+ char* t;
+ char* u;
+ const char* x;
+ char* last;
+ char* type;
+ int day;
+ int dir;
+ int dst;
+ int zone;
+ int c;
+ int f;
+ int i;
+ int j;
+ int k;
+ int l;
+ long m;
+ long p;
+ long q;
+ Tm_zone_t* zp;
+ char skip[UCHAR_MAX + 1];
+
+ /*
+ * check DATEMSK first
+ */
+
+ fix = tmxscan(s, &last, NiL, &t, now, 0);
+ if (t && !*last)
+ {
+ if (e)
+ *e = last;
+ return fix;
+ }
+
+ reset:
+
+ /*
+ * use now for defaults
+ */
+
+ tm = tmxmake(now);
+ tm_info.date = tm_info.zone;
+ day = -1;
+ dst = TM_DST;
+ set = state = 0;
+ type = 0;
+ zone = TM_LOCALZONE;
+ skip[0] = 0;
+ for (n = 1; n <= UCHAR_MAX; n++)
+ skip[n] = isspace(n) || strchr("_,;@=|!^()[]{}", n);
+
+ /*
+ * get <weekday year month day hour minutes seconds ?[ds]t [ap]m>
+ */
+
+ for (;;)
+ {
+ state &= (state & HOLD) ? ~(HOLD) : ~(EXACT|LAST|NEXT|THIS);
+ if ((set|state) & (YEAR|MONTH|DAY))
+ skip['/'] = 1;
+ for (;;)
+ {
+ if (*s == '.' || *s == '-' || *s == '+')
+ {
+ if (((set|state) & (YEAR|MONTH|HOUR|MINUTE|ZONE)) == (YEAR|MONTH|HOUR|MINUTE) && (i = tmgoff(s, &t, TM_LOCALZONE)) != TM_LOCALZONE)
+ {
+ zone = i;
+ state |= ZONE;
+ if (!*(s = t))
+ break;
+ }
+ else if (*s == '+')
+ break;
+ }
+ else if (!skip[*s])
+ break;
+ s++;
+ }
+ if (!*(last = (char*)s))
+ break;
+ if (*s == '#')
+ {
+ if (isdigit(*++s))
+ {
+ now = strtoull(s, &t, 0);
+ sns:
+ if (*(s = t) == '.')
+ {
+ fix = 0;
+ m = 1000000000;
+ while (isdigit(*++s))
+ fix += (*s - '0') * (m /= 10);
+ now = tmxsns(now, fix);
+ }
+ else if (now <= 0x7fffffff)
+ now = tmxsns(now, 0);
+ goto reset;
+ }
+ else if (*s++ == '#')
+ {
+ now = tmxtime(tm, zone);
+ goto reset;
+ }
+ break;
+ }
+ f = -1;
+ if (*s == '+')
+ {
+ while (isspace(*++s) || *s == '_');
+ n = strtol(s, &t, 0);
+ if (w = t - s)
+ {
+ for (s = t; skip[*s]; s++);
+ state |= (f = n) ? NEXT : THIS;
+ set &= ~(EXACT|LAST|NEXT|THIS);
+ set |= state & (EXACT|LAST|NEXT|THIS);
+ }
+ else
+ s = last;
+ }
+ if (!(state & CRON))
+ {
+ /*
+ * check for cron date
+ *
+ * min hour day-of-month month day-of-week
+ *
+ * if it's cron then determine the next time
+ * that satisfies the specification
+ *
+ * NOTE: the only spacing is ' '||'_'||';'
+ */
+
+ i = 0;
+ n = *(t = (char*)s);
+ for (;;)
+ {
+ if (n == '*')
+ n = *++s;
+ else if (!isdigit(n))
+ break;
+ else
+ while ((n = *++s) == ',' || n == '-' || n == '/' || isdigit(n));
+ if (n != ' ' && n != '_' && n != ';')
+ {
+ if (!n)
+ i++;
+ break;
+ }
+ i++;
+ while ((n = *++s) == ' ' || n == '_');
+ }
+ if (i == 5)
+ {
+ Time_t tt;
+ char hit[60];
+ char mon[12];
+ char day[7];
+
+ state |= CRON;
+ flags = 0;
+ tm->tm_sec = 0;
+ tm->tm_min++;
+ tmfix(tm);
+
+ /*
+ * minute
+ */
+
+ if ((k = range(t, &t, hit, 0, 59)) < 0)
+ break;
+ if (k && !hit[i = tm->tm_min])
+ {
+ hit[i] = 1;
+ do if (++i > 59)
+ {
+ i = 0;
+ if (++tm->tm_hour > 59)
+ {
+ tm->tm_min = i;
+ tmfix(tm);
+ }
+ } while (!hit[i]);
+ tm->tm_min = i;
+ }
+
+ /*
+ * hour
+ */
+
+ if ((k = range(t, &t, hit, 0, 23)) < 0)
+ break;
+ if (k && !hit[i = tm->tm_hour])
+ {
+ hit[i] = 1;
+ do if (++i > 23)
+ {
+ i = 0;
+ if (++tm->tm_mday > 28)
+ {
+ tm->tm_hour = i;
+ tmfix(tm);
+ }
+ } while (!hit[i]);
+ tm->tm_hour = i;
+ }
+
+ /*
+ * day of month
+ */
+
+ if ((k = range(t, &t, hit, 1, 31)) < 0)
+ break;
+ if (k)
+ flags |= DAY|MDAY;
+
+ /*
+ * month
+ */
+
+ if ((k = range(t, &t, mon, 1, 12)) < 0)
+ break;
+ if (k)
+ flags |= MONTH;
+ else
+ for (i = 1; i <= 12; i++)
+ mon[i] = 1;
+
+ /*
+ * day of week
+ */
+
+ if ((k = range(t, &t, day, 0, 6)) < 0)
+ break;
+ if (k)
+ flags |= WDAY;
+ s = t;
+ if (flags & (MONTH|MDAY|WDAY))
+ {
+ fix = tmxtime(tm, zone);
+ tm = tmxmake(fix);
+ i = tm->tm_mon + 1;
+ j = tm->tm_mday;
+ k = tm->tm_wday;
+ for (;;)
+ {
+ if (!mon[i])
+ {
+ if (++i > 12)
+ {
+ i = 1;
+ tm->tm_year++;
+ }
+ tm->tm_mon = i - 1;
+ tm->tm_mday = 1;
+ tt = tmxtime(tm, zone);
+ if (tt < fix)
+ goto done;
+ tm = tmxmake(tt);
+ i = tm->tm_mon + 1;
+ j = tm->tm_mday;
+ k = tm->tm_wday;
+ continue;
+ }
+ if (flags & (MDAY|WDAY))
+ {
+ if ((flags & (MDAY|WDAY)) == (MDAY|WDAY))
+ {
+ if (hit[j] && day[k])
+ break;
+ }
+ else if ((flags & MDAY) && hit[j])
+ break;
+ else if ((flags & WDAY) && day[k])
+ break;
+ if (++j > 28)
+ {
+ tm->tm_mon = i - 1;
+ tm->tm_mday = j;
+ tm = tmxmake(tmxtime(tm, zone));
+ i = tm->tm_mon + 1;
+ j = tm->tm_mday;
+ k = tm->tm_wday;
+ }
+ else if ((flags & WDAY) && ++k > 6)
+ k = 0;
+ }
+ else if (flags & MONTH)
+ break;
+ }
+ tm->tm_mon = i - 1;
+ tm->tm_mday = j;
+ tm->tm_wday = k;
+ }
+ continue;
+ }
+ s = t;
+ }
+ n = -1;
+ if (isdigit(*s))
+ {
+ n = strtol(s, &t, 10);
+ if ((w = t - s) && *t == '.' && isdigit(*(t + 1)) && isdigit(*(t + 2)) && isdigit(*(t + 3)))
+ {
+ now = n;
+ goto sns;
+ }
+ u = t + (*t == '-');
+ if ((w == 2 || w == 4) && (*u == 'W' || *u == 'w') && isdigit(*(u + 1)))
+ {
+ t = u;
+ if (w == 4)
+ {
+ if ((n -= 1900) < TM_WINDOW)
+ break;
+ }
+ else if (n < TM_WINDOW)
+ n += 100;
+ m = n;
+ n = strtol(s = t + 1, &t, 0);
+ if ((i = (t - s)) < 2 || i > 3)
+ break;
+ if (dig2(s, j) < 0 || j > 53)
+ break;
+ if (!(t - s) && *t == '-')
+ n = strtol(s = t + 1, &t, 0);
+ if (!(i = (t - s)))
+ k = 1;
+ else if (i != 1 || dig1(s, k) < 1 || k > 7)
+ break;
+ else if (k == 7)
+ k = 0;
+ tm->tm_year = m;
+ tmweek(tm, 2, j, k);
+ set |= YEAR|MONTH|DAY;
+ continue;
+ }
+ else if ((w == 6 || w == 8) && (*u == 'T' || *u == 't') && isdigit(*(u + 1)))
+ {
+ t = u;
+ flags = 0;
+ if (w == 8)
+ {
+ dig4(s, m);
+ if ((m -= 1900) < TM_WINDOW)
+ break;
+ }
+ else
+ {
+ dig2(s, m);
+ if (m < TM_WINDOW)
+ m += 100;
+ }
+ flags |= YEAR;
+ if (dig2(s, l) <= 0 || l > 12)
+ break;
+ flags |= MONTH;
+ if (dig2(s, k) < 1 || k > 31)
+ break;
+ n = strtol(s = t + 1, &t, 0);
+ if ((t - s) < 2)
+ break;
+ if (dig2(s, j) > 24)
+ break;
+ if ((t - s) < 2)
+ {
+ if ((t - s) == 1 || *t++ != '-')
+ break;
+ n = strtol(s = t, &t, 0);
+ if ((t - s) < 2)
+ break;
+ }
+ if (dig2(s, i) > 59)
+ break;
+ flags |= HOUR|MINUTE;
+ if ((t - s) == 2)
+ {
+ if (dig2(s, n) > (59 + TM_MAXLEAP))
+ break;
+ flags |= SECOND;
+ }
+ else if (t - s)
+ break;
+ else
+ n = 0;
+ p = 0;
+ if (*t == '.')
+ {
+ q = 1000000000;
+ while (isdigit(*++t))
+ p += (*t - '0') * (q /= 10);
+ set |= NSEC;
+ }
+ if (n > (59 + TM_MAXLEAP))
+ break;
+ goto save;
+ }
+ else if (f == -1 && isalpha(*t) && tmlex(t, &t, tm_info.format + TM_ORDINAL, TM_ORDINALS - TM_ORDINAL, NiL, 0) >= 0)
+ {
+ ordinal:
+ state |= (f = n) ? NEXT : THIS;
+ set &= ~(EXACT|LAST|NEXT|THIS);
+ set |= state & (EXACT|LAST|NEXT|THIS);
+ for (s = t; skip[*s]; s++);
+ if (isdigit(*s))
+ {
+ n = strtol(s, &t, 10);
+ s = t;
+ if (*s == '_')
+ s++;
+ }
+ else
+ n = -1;
+ }
+ else
+ {
+ if (!(state & (LAST|NEXT|THIS)) && ((i = t - s) == 4 && (*t == '.' && isdigit(*(t + 1)) && isdigit(*(t + 2)) && *(t + 3) != '.' || (!*t || isspace(*t) || *t == '_' || isalnum(*t)) && n >= 0 && (n % 100) < 60 && ((m = (n / 100)) < 20 || m < 24 && !((set|state) & (YEAR|MONTH|HOUR|MINUTE)))) || i > 4 && i <= 12))
+ {
+ /*
+ * various { date(1) touch(1) } formats
+ *
+ * [[cc]yy[mm]]ddhhmm[.ss[.nn...]]
+ * [cc]yyjjj
+ * hhmm[.ss[.nn...]]
+ */
+
+ flags = 0;
+ if (state & CCYYMMDDHHMMSS)
+ break;
+ state |= CCYYMMDDHHMMSS;
+ p = 0;
+ if ((i == 7 || i == 5) && !*t)
+ {
+ if (i == 7)
+ {
+ dig4(s, m);
+ if ((m -= 1900) < TM_WINDOW)
+ break;
+ }
+ else if (dig2(s, m) < TM_WINDOW)
+ m += 100;
+ dig3(s, k);
+ l = 1;
+ j = 0;
+ i = 0;
+ n = 0;
+ flags |= MONTH;
+ }
+ else if (i & 1)
+ break;
+ else
+ {
+ u = t;
+ if (i == 12)
+ {
+ x = s;
+ dig2(x, m);
+ if (m <= 12)
+ {
+ u -= 4;
+ i -= 4;
+ x = s + 8;
+ dig4(x, m);
+ }
+ else
+ dig4(s, m);
+ m -= 1900;
+ }
+ else if (i == 10)
+ {
+ x = s;
+ if (!dig2(x, m) || m > 12 || !dig2(x, m) || m > 31 || dig2(x, m) > 24 || dig2(x, m) > 60 || dig2(x, m) <= 60 && !(tm_info.flags & TM_DATESTYLE))
+ dig2(s, m);
+ else
+ {
+ u -= 2;
+ i -= 2;
+ x = s + 8;
+ dig2(x, m);
+ }
+ if (m < TM_WINDOW)
+ m += 100;
+ }
+ else
+ m = tm->tm_year;
+ if ((u - s) < 8)
+ l = tm->tm_mon + 1;
+ else if (dig2(s, l) <= 0 || l > 12)
+ break;
+ else
+ flags |= MONTH;
+ if ((u - s) < 6)
+ k = tm->tm_mday;
+ else if (dig2(s, k) < 1 || k > 31)
+ break;
+ else
+ flags |= DAY;
+ if ((u - s) < 4)
+ break;
+ if (dig2(s, j) > 24)
+ break;
+ if (dig2(s, i) > 59)
+ break;
+ flags |= HOUR|MINUTE;
+ if ((u - s) == 2)
+ {
+ dig2(s, n);
+ flags |= SECOND;
+ }
+ else if (u - s)
+ break;
+ else if (*t != '.')
+ n = 0;
+ else
+ {
+ n = strtol(t + 1, &t, 10);
+ flags |= SECOND;
+ if (*t == '.')
+ {
+ q = 1000000000;
+ while (isdigit(*++t))
+ p += (*t - '0') * (q /= 10);
+ set |= NSEC;
+ }
+ }
+ if (n > (59 + TM_MAXLEAP))
+ break;
+ }
+ save:
+ tm->tm_year = m;
+ tm->tm_mon = l - 1;
+ tm->tm_mday = k;
+ tm->tm_hour = j;
+ tm->tm_min = i;
+ tm->tm_sec = n;
+ tm->tm_nsec = p;
+ s = t;
+ set |= flags;
+ continue;
+ }
+ for (s = t; skip[*s]; s++);
+ if (*s == ':' || *s == '.' && ((set|state) & (YEAR|MONTH|DAY|HOUR)) == (YEAR|MONTH|DAY))
+ {
+ c = *s;
+ if ((state & HOUR) || n > 24)
+ break;
+ while (isspace(*++s) || *s == '_');
+ if (!isdigit(*s))
+ break;
+ i = n;
+ n = strtol(s, &t, 10);
+ for (s = t; isspace(*s) || *s == '_'; s++);
+ if (n > 59)
+ break;
+ j = n;
+ m = 0;
+ if (*s == c)
+ {
+ while (isspace(*++s) || *s == '_');
+ if (!isdigit(*s))
+ break;
+ n = strtol(s, &t, 10);
+ s = t;
+ if (n > (59 + TM_MAXLEAP))
+ break;
+ set |= SECOND;
+ while (isspace(*s))
+ s++;
+ if (*s == '.')
+ {
+ q = 1000000000;
+ while (isdigit(*++s))
+ m += (*s - '0') * (q /= 10);
+ set |= NSEC;
+ }
+ }
+ else
+ n = 0;
+ set |= HOUR|MINUTE;
+ skip[':'] = 1;
+ k = tm->tm_hour;
+ tm->tm_hour = i;
+ l = tm->tm_min;
+ tm->tm_min = j;
+ tm->tm_sec = n;
+ tm->tm_nsec = m;
+ while (isspace(*s))
+ s++;
+ switch (tmlex(s, &t, tm_info.format, TM_NFORM, tm_info.format + TM_MERIDIAN, 2))
+ {
+ case TM_MERIDIAN:
+ s = t;
+ if (i == 12)
+ tm->tm_hour = i = 0;
+ break;
+ case TM_MERIDIAN+1:
+ if (i < 12)
+ tm->tm_hour = i += 12;
+ break;
+ }
+ if (f >= 0 || (state & (LAST|NEXT)))
+ {
+ state &= ~HOLD;
+ if (f < 0)
+ {
+ if (state & LAST)
+ f = -1;
+ else if (state & NEXT)
+ f = 1;
+ else
+ f = 0;
+ }
+ if (f > 0)
+ {
+ if (i > k || i == k && j > l)
+ f--;
+ }
+ else if (i < k || i == k && j < l)
+ f++;
+ if (f > 0)
+ {
+ tm->tm_hour += f * 24;
+ while (tm->tm_hour >= 24)
+ {
+ tm->tm_hour -= 24;
+ tm->tm_mday++;
+ }
+ }
+ else if (f < 0)
+ {
+ tm->tm_hour += f * 24;
+ while (tm->tm_hour < 24)
+ {
+ tm->tm_hour += 24;
+ tm->tm_mday--;
+ }
+ }
+ }
+ continue;
+ }
+ }
+ }
+ for (;;)
+ {
+ if (*s == '-' || *s == '+')
+ {
+ if (((set|state) & (MONTH|DAY|HOUR|MINUTE)) == (MONTH|DAY|HOUR|MINUTE) || *s == '+' && (!isdigit(s[1]) || !isdigit(s[2]) || s[3] != ':' && (s[3] != '.' || ((set|state) & (YEAR|MONTH)) != (YEAR|MONTH))))
+ break;
+ s++;
+ }
+ else if (skip[*s])
+ s++;
+ else
+ break;
+ }
+ if (isalpha(*s) && n < 1000)
+ {
+ if ((j = tmlex(s, &t, tm_info.format, TM_NFORM, tm_info.format + TM_SUFFIXES, TM_PARTS - TM_SUFFIXES)) >= 0)
+ {
+ s = t;
+ switch (tm_data.lex[j])
+ {
+ case TM_EXACT:
+ state |= HOLD|EXACT;
+ set &= ~(EXACT|LAST|NEXT|THIS);
+ set |= state & (EXACT|LAST|NEXT|THIS);
+ continue;
+ case TM_LAST:
+ state |= HOLD|LAST;
+ set &= ~(EXACT|LAST|NEXT|THIS);
+ set |= state & (EXACT|LAST|NEXT|THIS);
+ continue;
+ case TM_THIS:
+ state |= HOLD|THIS;
+ set &= ~(EXACT|LAST|NEXT|THIS);
+ set |= state & (EXACT|LAST|NEXT|THIS);
+ n = 0;
+ continue;
+ case TM_NEXT:
+ /*
+ * disambiguate english "last ... in"
+ */
+
+ if (!((state|set) & LAST))
+ {
+ state |= HOLD|NEXT;
+ set &= ~(EXACT|LAST|NEXT|THIS);
+ set |= state & (EXACT|LAST|NEXT|THIS);
+ continue;
+ }
+ /*FALLTHROUGH*/
+ case TM_FINAL:
+ state |= HOLD|THIS|FINAL;
+ set &= ~(EXACT|LAST|NEXT|THIS);
+ set |= state & (EXACT|LAST|NEXT|THIS|FINAL);
+ continue;
+ case TM_ORDINAL:
+ j += TM_ORDINALS - TM_ORDINAL;
+ /*FALLTHROUGH*/
+ case TM_ORDINALS:
+ n = j - TM_ORDINALS + 1;
+ goto ordinal;
+ case TM_MERIDIAN:
+ if (f >= 0)
+ f++;
+ else if (state & LAST)
+ f = -1;
+ else if (state & THIS)
+ f = 1;
+ else if (state & NEXT)
+ f = 2;
+ else
+ f = 0;
+ if (n > 0)
+ {
+ if (n > 24)
+ goto done;
+ tm->tm_hour = n;
+ }
+ for (k = tm->tm_hour; k < 0; k += 24);
+ k %= 24;
+ if (j == TM_MERIDIAN)
+ {
+ if (k == 12)
+ tm->tm_hour -= 12;
+ }
+ else if (k < 12)
+ tm->tm_hour += 12;
+ if (n > 0)
+ goto clear_min;
+ continue;
+ case TM_DAY_ABBREV:
+ j += TM_DAY - TM_DAY_ABBREV;
+ /*FALLTHROUGH*/
+ case TM_DAY:
+ case TM_PARTS:
+ case TM_HOURS:
+ state |= set & (EXACT|LAST|NEXT|THIS);
+ if (!(state & (LAST|NEXT|THIS)))
+ for (;;)
+ {
+ while (skip[*s])
+ s++;
+ if ((k = tmlex(s, &t, tm_info.format + TM_LAST, TM_NOISE - TM_LAST, NiL, 0)) >= 0)
+ {
+ s = t;
+ if (k <= 2)
+ state |= LAST;
+ else if (k <= 5)
+ state |= THIS;
+ else if (k <= 8)
+ state |= NEXT;
+ else
+ state |= EXACT;
+ }
+ else
+ {
+ state |= (n > 0) ? NEXT : THIS;
+ break;
+ }
+ set &= ~(EXACT|LAST|NEXT|THIS);
+ set |= state & (EXACT|LAST|NEXT|THIS);
+ }
+ /*FALLTHROUGH*/
+ case TM_DAYS:
+ if (n == -1)
+ {
+ /*
+ * disambiguate english "second"
+ */
+
+ if (j == TM_PARTS && f == -1)
+ {
+ n = 2;
+ goto ordinal;
+ }
+ n = 1;
+ }
+ if (state & LAST)
+ n = -n;
+ else if (!(state & NEXT))
+ n--;
+ m = (f > 0) ? f * n : n;
+ switch (j)
+ {
+ case TM_DAYS+0:
+ tm->tm_mday--;
+ set |= DAY;
+ goto clear_hour;
+ case TM_DAYS+1:
+ set |= DAY;
+ goto clear_hour;
+ case TM_DAYS+2:
+ tm->tm_mday++;
+ set |= DAY;
+ goto clear_hour;
+ case TM_PARTS+0:
+ set |= SECOND;
+ if ((m < 0 ? -m : m) > (365L*24L*60L*60L))
+ {
+ now = tmxtime(tm, zone) + tmxsns(m, 0);
+ goto reset;
+ }
+ tm->tm_sec += m;
+ goto clear_nsec;
+ case TM_PARTS+1:
+ tm->tm_min += m;
+ set |= MINUTE;
+ goto clear_sec;
+ case TM_PARTS+2:
+ tm->tm_hour += m;
+ set |= MINUTE;
+ goto clear_min;
+ case TM_PARTS+3:
+ tm->tm_mday += m;
+ if (!(set & FINAL))
+ set |= HOUR;
+ goto clear_hour;
+ case TM_PARTS+4:
+ tm = tmxmake(tmxtime(tm, zone));
+ tm->tm_mday += 7 * m - tm->tm_wday + 1;
+ set |= DAY;
+ goto clear_hour;
+ case TM_PARTS+5:
+ tm->tm_mon += m;
+ set |= MONTH;
+ goto clear_mday;
+ case TM_PARTS+6:
+ tm->tm_year += m;
+ goto clear_mon;
+ case TM_HOURS+0:
+ tm->tm_mday += m;
+ set |= DAY;
+ goto clear_hour;
+ case TM_HOURS+1:
+ tm->tm_mday += m;
+ tm->tm_hour = 6;
+ set |= HOUR;
+ goto clear_min;
+ case TM_HOURS+2:
+ tm->tm_mday += m;
+ tm->tm_hour = 12;
+ set |= HOUR;
+ goto clear_min;
+ case TM_HOURS+3:
+ tm->tm_mday += m;
+ tm->tm_hour = 18;
+ set |= HOUR;
+ goto clear_min;
+ }
+ tm = tmxmake(tmxtime(tm, zone));
+ day = j -= TM_DAY;
+ dir = m;
+ j -= tm->tm_wday;
+ if (state & (LAST|NEXT|THIS))
+ {
+ if (j < 0)
+ j += 7;
+ }
+ else if (j > 0)
+ j -= 7;
+ tm->tm_mday += j + m * 7;
+ set |= DAY;
+ if (state & (LAST|NEXT|THIS))
+ goto clear_hour;
+ continue;
+ case TM_MONTH_ABBREV:
+ j += TM_MONTH - TM_MONTH_ABBREV;
+ /*FALLTHROUGH*/
+ case TM_MONTH:
+ if (state & MONTH)
+ goto done;
+ state |= MONTH;
+ i = tm->tm_mon;
+ tm->tm_mon = j - TM_MONTH;
+ if (n < 0)
+ {
+ while (skip[*s])
+ s++;
+ if (isdigit(*s))
+ {
+ n = strtol(s, &t, 10);
+ if (n <= 31 && *t != ':')
+ s = t;
+ else
+ n = -1;
+ }
+ }
+ if (n >= 0)
+ {
+ if (n > 31)
+ goto done;
+ state |= DAY|MDAY;
+ tm->tm_mday = n;
+ if (f > 0)
+ tm->tm_year += f;
+ }
+ if (state & (LAST|NEXT|THIS))
+ {
+ n = i;
+ goto rel_month;
+ }
+ continue;
+ case TM_UT:
+ if (state & ZONE)
+ goto done;
+ state |= ZONE;
+ zone = tmgoff(s, &t, 0);
+ s = t;
+ continue;
+ case TM_DT:
+ if (!dst)
+ goto done;
+ if (!(state & ZONE))
+ {
+ dst = tm_info.zone->dst;
+ zone = tm_info.zone->west;
+ }
+ zone += tmgoff(s, &t, dst);
+ s = t;
+ dst = 0;
+ state |= ZONE;
+ continue;
+ case TM_NOISE:
+ continue;
+ }
+ }
+ if (!(state & ZONE) && (zp = tmzone(s, &t, type, &dst)))
+ {
+ s = t;
+ zone = zp->west + dst;
+ tm_info.date = zp;
+ state |= ZONE;
+ continue;
+ }
+ if (!type && (zp = tmtype(s, &t)))
+ {
+ s = t;
+ type = zp->type;
+ continue;
+ }
+ state |= BREAK;
+ }
+ else if (*s == '/')
+ {
+ if (!(state & (YEAR|MONTH)) && n >= 1900 && n < 3000 && (i = strtol(s + 1, &t, 10)) > 0 && i <= 12)
+ {
+ state |= YEAR;
+ tm->tm_year = n - 1900;
+ s = t;
+ i--;
+ }
+ else
+ {
+ if ((state & MONTH) || n <= 0 || n > 31)
+ break;
+ if (isalpha(*++s))
+ {
+ if ((i = tmlex(s, &t, tm_info.format, TM_DAY_ABBREV, NiL, 0)) < 0)
+ break;
+ if (i >= TM_MONTH)
+ i -= TM_MONTH;
+ s = t;
+ }
+ else
+ {
+ i = n - 1;
+ n = strtol(s, &t, 10);
+ s = t;
+ if (n <= 0 || n > 31)
+ break;
+ if (*s == '/' && !isdigit(*(s + 1)))
+ break;
+ }
+ state |= DAY;
+ tm->tm_mday = n;
+ }
+ state |= MONTH;
+ n = tm->tm_mon;
+ tm->tm_mon = i;
+ if (*s == '/')
+ {
+ n = strtol(++s, &t, 10);
+ w = t - s;
+ s = t;
+ if (*s == '/' || *s == ':' || *s == '-' || *s == '_')
+ s++;
+ }
+ else
+ {
+ if (state & (LAST|NEXT|THIS))
+ {
+ rel_month:
+ if (state & LAST)
+ tm->tm_year -= (tm->tm_mon < n) ? 0 : 1;
+ else
+ tm->tm_year += ((state & NEXT) ? 1 : 0) + ((tm->tm_mon < n) ? 1 : 0);
+ if (state & MDAY)
+ goto clear_hour;
+ goto clear_mday;
+ }
+ continue;
+ }
+ }
+ if (n < 0 || w > 4)
+ break;
+ if (w == 4)
+ {
+ if ((state & YEAR) || n < 1900 || n >= 3000)
+ break;
+ state |= YEAR;
+ tm->tm_year = n - 1900;
+ }
+ else if (w == 3)
+ {
+ if (state & (MONTH|MDAY|WDAY))
+ break;
+ state |= MONTH|DAY|MDAY;
+ tm->tm_mon = 0;
+ tm->tm_mday = n;
+ }
+ else if (w == 2 && !(state & YEAR))
+ {
+ state |= YEAR;
+ if (n < TM_WINDOW)
+ n += 100;
+ tm->tm_year = n;
+ }
+ else if (!(state & MONTH) && n >= 1 && n <= 12)
+ {
+ state |= MONTH;
+ tm->tm_mon = n - 1;
+ }
+ else if (!(state & (MDAY|WDAY)) && n >= 1 && n <= 31)
+ {
+ state |= DAY|MDAY|WDAY;
+ tm->tm_mday = n;
+ }
+ else
+ break;
+ if (state & BREAK)
+ {
+ last = t;
+ break;
+ }
+ continue;
+ clear_mon:
+ if ((set|state) & (EXACT|MONTH))
+ continue;
+ tm->tm_mon = 0;
+ clear_mday:
+ set |= MONTH;
+ if ((set|state) & (EXACT|DAY|HOUR))
+ continue;
+ tm->tm_mday = 1;
+ clear_hour:
+ set |= DAY;
+ if ((set|state) & (EXACT|HOUR))
+ continue;
+ tm->tm_hour = 0;
+ clear_min:
+ set |= HOUR;
+ if ((set|state) & (EXACT|MINUTE))
+ continue;
+ tm->tm_min = 0;
+ clear_sec:
+ set |= MINUTE;
+ if ((set|state) & (EXACT|SECOND))
+ continue;
+ tm->tm_sec = 0;
+ clear_nsec:
+ set |= SECOND;
+ if ((set|state) & (EXACT|NSEC))
+ continue;
+ tm->tm_nsec = 0;
+ }
+ done:
+ if (day >= 0 && !(state & (MDAY|WDAY)))
+ {
+ if ((m = dir) > 0)
+ m--;
+ if (state & MONTH)
+ tm->tm_mday = 1;
+ else if (m < 0)
+ m++;
+ tm = tmxmake(tmxtime(tm, zone));
+ j = day - tm->tm_wday;
+ if (j < 0)
+ j += 7;
+ tm->tm_mday += j + m * 7;
+ if (state & FINAL)
+ for (n = tm_data.days[tm->tm_mon] + (tm->tm_mon == 1 && tmisleapyear(tm->tm_year)); (tm->tm_mday + 7) <= n; tm->tm_mday += 7);
+ }
+ else if (day < 0 && (state & FINAL) && (set & DAY))
+ tm->tm_mday = tm_data.days[tm->tm_mon] + (tm->tm_mon == 1 && tmisleapyear(tm->tm_year));
+ if (e)
+ *e = last;
+ return tmxtime(tm, zone);
+}
diff --git a/usr/src/lib/libast/common/tm/tmxfmt.c b/usr/src/lib/libast/common/tm/tmxfmt.c
new file mode 100644
index 0000000000..3019a8d7b9
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmxfmt.c
@@ -0,0 +1,541 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * Time_t conversion support
+ */
+
+#include <tmx.h>
+#include <ctype.h>
+
+#define warped(t,n) ((t)<((n)-tmxsns(6L*30L*24L*60L*60L,0))||(t)>((n)+tmxsns(24L*60L*60L,0)))
+
+/*
+ * format n with padding p into s
+ * return end of s
+ *
+ * p: <0 blank padding
+ * 0 no padding
+ * >0 0 padding
+ */
+
+static char*
+number(register char* s, register char* e, register long n, register int p, int w, int pad)
+{
+ char* b;
+
+ if (w && w > p)
+ p = w;
+ switch (pad)
+ {
+ case '-':
+ p = 0;
+ break;
+ case '_':
+ if (p > 0)
+ p = -p;
+ break;
+ case '0':
+ if (p < 0)
+ p = -p;
+ break;
+ }
+ b = s;
+ if (p > 0)
+ s += sfsprintf(s, e - s, "%0*lu", p, n);
+ else if (p < 0)
+ s += sfsprintf(s, e - s, "%*lu", -p, n);
+ else
+ s += sfsprintf(s, e - s, "%lu", n);
+ if (w && (s - b) > w)
+ *(s = b + w) = 0;
+ return s;
+}
+
+typedef struct Stack_s
+{
+ char* format;
+ int delimiter;
+} Stack_t;
+
+/*
+ * format t into buf of length len
+ * end of buf is returned
+ */
+
+char*
+tmxfmt(char* buf, size_t len, const char* format, Time_t t)
+{
+ register char* cp;
+ register char* ep;
+ register char* p;
+ register int n;
+ int c;
+ int i;
+ int flags;
+ int pad;
+ int delimiter;
+ int width;
+ int prec;
+ int parts;
+ char* f;
+ const char* oformat;
+ Tm_t* tp;
+ Tm_zone_t* zp;
+ Time_t now;
+ Stack_t* sp;
+ Stack_t stack[8];
+ char fmt[32];
+
+ tmlocale();
+ tp = tmxmake(t);
+ if (!format || !*format)
+ format = tm_info.deformat;
+ oformat = format;
+ flags = tm_info.flags;
+ sp = &stack[0];
+ cp = buf;
+ ep = buf + len;
+ delimiter = 0;
+ for (;;)
+ {
+ if ((c = *format++) == delimiter)
+ {
+ delimiter = 0;
+ if (sp <= &stack[0])
+ break;
+ sp--;
+ format = sp->format;
+ delimiter = sp->delimiter;
+ continue;
+ }
+ if (c != '%')
+ {
+ if (cp < ep)
+ *cp++ = c;
+ continue;
+ }
+ pad = 0;
+ width = 0;
+ prec = 0;
+ parts = 0;
+ for (;;)
+ {
+ switch (c = *format++)
+ {
+ case '_':
+ case '-':
+ pad = c;
+ continue;
+ case 'E':
+ case 'O':
+ if (!isalpha(*format))
+ break;
+ continue;
+ case '0':
+ if (!parts)
+ {
+ pad = c;
+ continue;
+ }
+ /*FALLTHROUGH*/
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ switch (parts)
+ {
+ case 0:
+ parts++;
+ /*FALLTHROUGH*/
+ case 1:
+ width = width * 10 + (c - '0');
+ break;
+ case 2:
+ prec = prec * 10 + (c - '0');
+ break;
+ }
+ continue;
+ case '.':
+ if (!parts++)
+ parts++;
+ continue;
+ default:
+ break;
+ }
+ break;
+ }
+ switch (c)
+ {
+ case 0:
+ format--;
+ continue;
+ case '%':
+ if (cp < ep)
+ *cp++ = '%';
+ continue;
+ case '?':
+ if (tm_info.deformat != tm_info.format[TM_DEFAULT])
+ format = tm_info.deformat;
+ else if (!*format)
+ format = tm_info.format[TM_DEFAULT];
+ continue;
+ case 'a': /* abbreviated day of week name */
+ n = TM_DAY_ABBREV + tp->tm_wday;
+ goto index;
+ case 'A': /* day of week name */
+ n = TM_DAY + tp->tm_wday;
+ goto index;
+ case 'b': /* abbreviated month name */
+ case 'h':
+ n = TM_MONTH_ABBREV + tp->tm_mon;
+ goto index;
+ case 'B': /* month name */
+ n = TM_MONTH + tp->tm_mon;
+ goto index;
+ case 'c': /* `ctime(3)' date sans newline */
+ p = tm_info.format[TM_CTIME];
+ goto push;
+ case 'C': /* 2 digit century */
+ cp = number(cp, ep, (long)(1900 + tp->tm_year) / 100, 2, width, pad);
+ continue;
+ case 'd': /* day of month */
+ cp = number(cp, ep, (long)tp->tm_mday, 2, width, pad);
+ continue;
+ case 'D': /* date */
+ p = tm_info.format[TM_DATE];
+ goto push;
+ case 'E': /* OBSOLETE no pad day of month */
+ cp = number(cp, ep, (long)tp->tm_mday, 0, width, pad);
+ continue;
+ case 'e': /* blank padded day of month */
+ cp = number(cp, ep, (long)tp->tm_mday, -2, width, pad);
+ continue;
+ case 'f': /* TM_DEFAULT override */
+ case 'o': /* OBSOLETE */
+ p = tm_info.deformat;
+ goto push;
+ case 'F': /* TM_DEFAULT */
+ case 'O': /* OBSOLETE */
+ p = tm_info.format[TM_DEFAULT];
+ goto push;
+ case 'g': /* %V 2 digit year */
+ case 'G': /* %V 4 digit year */
+ n = tp->tm_year + 1900;
+ if (tp->tm_yday < 7)
+ {
+ if (tmweek(tp, 2, -1, -1) >= 52)
+ n--;
+ }
+ else if (tp->tm_yday > 358)
+ {
+ if (tmweek(tp, 2, -1, -1) <= 1)
+ n++;
+ }
+ if (c == 'g')
+ {
+ n %= 100;
+ c = 2;
+ }
+ else
+ c = 4;
+ cp = number(cp, ep, (long)n, c, width, pad);
+ continue;
+ case 'H': /* hour (0 - 23) */
+ cp = number(cp, ep, (long)tp->tm_hour, 2, width, pad);
+ continue;
+ case 'i': /* international `date(1)' date */
+ p = tm_info.format[TM_INTERNATIONAL];
+ goto push;
+ case 'I': /* hour (0 - 12) */
+ if ((n = tp->tm_hour) > 12) n -= 12;
+ else if (n == 0) n = 12;
+ cp = number(cp, ep, (long)n, 2, width, pad);
+ continue;
+ case 'J': /* Julian date (0 offset) */
+ cp = number(cp, ep, (long)tp->tm_yday, 3, width, pad);
+ continue;
+ case 'j': /* Julian date (1 offset) */
+ cp = number(cp, ep, (long)(tp->tm_yday + 1), 3, width, pad);
+ continue;
+ case 'k': /* `date(1)' date */
+ p = tm_info.format[TM_DATE_1];
+ goto push;
+ case 'K':
+ p = "%Y-%m-%d+%H:%M:%S";
+ goto push;
+ case 'l': /* `ls -l' date */
+ if (t)
+ {
+ now = tmxgettime();
+ if (warped(t, now))
+ {
+ p = tm_info.format[TM_DISTANT];
+ goto push;
+ }
+ }
+ p = tm_info.format[TM_RECENT];
+ goto push;
+ case 'm': /* month number */
+ cp = number(cp, ep, (long)(tp->tm_mon + 1), 2, width, pad);
+ continue;
+ case 'M': /* minutes */
+ cp = number(cp, ep, (long)tp->tm_min, 2, width, pad);
+ continue;
+ case 'n':
+ if (cp < ep)
+ *cp++ = '\n';
+ continue;
+ case 'N': /* nanosecond part */
+ cp = number(cp, ep, (long)tp->tm_nsec, 9, width, pad);
+ continue;
+ case 'p': /* meridian */
+ n = TM_MERIDIAN + (tp->tm_hour >= 12);
+ goto index;
+ case 'q': /* time zone type (nation code) */
+ if (!(flags & TM_UTC))
+ {
+ if ((zp = tm_info.zone) != tm_info.local)
+ for (; zp >= tm_data.zone; zp--)
+ if (p = zp->type)
+ goto string;
+ else if (p = zp->type)
+ goto string;
+ }
+ continue;
+ case 'Q': /* %Q<alpha> or %Q<delim>recent<delim>distant<delim> */
+ if (c = *format)
+ {
+ format++;
+ if (isalpha(c))
+ {
+ switch (c)
+ {
+ case 'd': /* `ls -l' distant date */
+ p = tm_info.format[TM_DISTANT];
+ goto push;
+ case 'r': /* `ls -l' recent date */
+ p = tm_info.format[TM_RECENT];
+ goto push;
+ default:
+ format--;
+ break;
+ }
+ }
+ else
+ {
+ if (t)
+ {
+ now = tmxgettime();
+ p = warped(t, now) ? (char*)0 : (char*)format;
+ }
+ else
+ p = (char*)format;
+ i = 0;
+ while (n = *format)
+ {
+ format++;
+ if (n == c)
+ {
+ if (!p)
+ p = (char*)format;
+ if (++i == 2)
+ goto push_delimiter;
+ }
+ }
+ }
+ }
+ continue;
+ case 'r':
+ p = tm_info.format[TM_MERIDIAN_TIME];
+ goto push;
+ case 'R':
+ p = "%H:%M";
+ goto push;
+ case 's': /* seconds[.nanoseconds] since the epoch */
+ case '#':
+ if (t)
+ now = t;
+ else
+ now = tmxgettime();
+ f = fmt;
+ *f++ = '%';
+ if (pad == '0')
+ *f++ = pad;
+ if (width)
+ f += sfsprintf(f, &fmt[sizeof(fmt)] - f, "%d", width);
+ f += sfsprintf(f, &fmt[sizeof(fmt)] - f, "I%du", sizeof(Tmxsec_t));
+ cp += sfsprintf(cp, ep - cp, fmt, tmxsec(now));
+ if (parts > 1)
+ {
+ n = sfsprintf(cp, ep - cp, ".%09I*u", sizeof(Tmxnsec_t), tmxnsec(now));
+ if (prec && n >= prec)
+ n = prec + 1;
+ cp += n;
+ }
+ continue;
+ case 'S': /* seconds */
+ cp = number(cp, ep, (long)tp->tm_sec, 2, width, pad);
+ if ((flags & TM_SUBSECOND) && (format - 2) != oformat)
+ {
+ p = ".%N";
+ goto push;
+ }
+ continue;
+ case 't':
+ if (cp < ep)
+ *cp++ = '\t';
+ continue;
+ case 'T':
+ p = tm_info.format[TM_TIME];
+ goto push;
+ case 'u': /* weekday number [1(Monday)-7] */
+ if (!(i = tp->tm_wday))
+ i = 7;
+ cp = number(cp, ep, (long)i, 0, width, pad);
+ continue;
+ case 'U': /* week number, Sunday as first day */
+ cp = number(cp, ep, (long)tmweek(tp, 0, -1, -1), 2, width, pad);
+ continue;
+ case 'V': /* ISO week number */
+ cp = number(cp, ep, (long)tmweek(tp, 2, -1, -1), 2, width, pad);
+ continue;
+ case 'W': /* week number, Monday as first day */
+ cp = number(cp, ep, (long)tmweek(tp, 1, -1, -1), 2, width, pad);
+ continue;
+ case 'w': /* weekday number [0(Sunday)-6] */
+ cp = number(cp, ep, (long)tp->tm_wday, 0, width, pad);
+ continue;
+ case 'x':
+ p = tm_info.format[TM_DATE];
+ goto push;
+ case 'X':
+ p = tm_info.format[TM_TIME];
+ goto push;
+ case 'y': /* year in the form yy */
+ cp = number(cp, ep, (long)(tp->tm_year % 100), 2, width, pad);
+ continue;
+ case 'Y': /* year in the form ccyy */
+ cp = number(cp, ep, (long)(1900 + tp->tm_year), 4, width, pad);
+ continue;
+ case 'z': /* time zone west offset */
+ if ((ep - cp) >= 16)
+ cp = tmpoff(cp, ep - cp, "", (flags & TM_UTC) ? 0 : tm_info.zone->west, 24 * 60);
+ continue;
+ case 'Z': /* time zone */
+ p = (flags & TM_UTC) ? tm_info.format[TM_UT] : tp->tm_isdst && tm_info.zone->daylight ? tm_info.zone->daylight : tm_info.zone->standard;
+ goto string;
+ case '+': /* old %+flag */
+ case '!': /* old %!flag */
+ format--;
+ /*FALLTHROUGH*/
+ case '=': /* %=[=][+-]flag */
+ if (i = *format == '=')
+ format++;
+ if (*format == '+' || *format == '-' || *format == '!')
+ c = *format++;
+ else
+ c = '+';
+ switch (*format++)
+ {
+ case 0:
+ format--;
+ continue;
+ case 'l':
+ n = TM_LEAP;
+ break;
+ case 'n':
+ case 's':
+ n = TM_SUBSECOND;
+ break;
+ case 'u':
+ n = TM_UTC;
+ break;
+ }
+ if (n)
+ {
+ /*
+ * right, the global state stinks
+ * but we respect its locale-like status
+ */
+
+ if (c == '+')
+ {
+ if (!(flags & n))
+ {
+ flags |= n;
+ tm_info.flags |= n;
+ tp = tmxmake(t);
+ if (!i)
+ tm_info.flags &= ~n;
+ }
+ }
+ else if (flags & n)
+ {
+ flags &= ~n;
+ tm_info.flags &= ~n;
+ tp = tmxmake(t);
+ if (!i)
+ tm_info.flags |= n;
+ }
+ }
+ continue;
+ default:
+ if (cp < ep)
+ *cp++ = '%';
+ if (cp < ep)
+ *cp++ = c;
+ continue;
+ }
+ index:
+ p = tm_info.format[n];
+ string:
+ while (cp < ep && (*cp = *p++))
+ cp++;
+ continue;
+ push:
+ c = 0;
+ push_delimiter:
+ if (sp < &stack[elementsof(stack)])
+ {
+ sp->format = (char*)format;
+ format = p;
+ sp->delimiter = delimiter;
+ delimiter = c;
+ sp++;
+ }
+ continue;
+ }
+ tm_info.flags = flags;
+ if (cp >= ep)
+ cp = ep - 1;
+ *cp = 0;
+ return cp;
+}
diff --git a/usr/src/lib/libast/common/tm/tmxgettime.c b/usr/src/lib/libast/common/tm/tmxgettime.c
new file mode 100644
index 0000000000..06f476d117
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmxgettime.c
@@ -0,0 +1,44 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * Time_t conversion support
+ */
+
+#include <tmx.h>
+#include <tv.h>
+
+/*
+ * return current Time_t
+ */
+
+Time_t
+tmxgettime(void)
+{
+ Tv_t tv;
+
+ tvgettime(&tv);
+ return tmxsns(tv.tv_sec, tv.tv_nsec);
+}
diff --git a/usr/src/lib/libast/common/tm/tmxleap.c b/usr/src/lib/libast/common/tm/tmxleap.c
new file mode 100644
index 0000000000..23f13bafd3
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmxleap.c
@@ -0,0 +1,51 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * Time_t conversion support
+ */
+
+#include <tmx.h>
+
+/*
+ * return t with leap seconds adjusted
+ * for direct localtime() access
+ */
+
+Time_t
+tmxleap(Time_t t)
+{
+ register Tm_leap_t* lp;
+ uint32_t sec;
+
+ tmset(tm_info.zone);
+ if (tm_info.flags & TM_ADJUST)
+ {
+ sec = tmxsec(t);
+ for (lp = &tm_data.leap[0]; sec < (lp->time - lp->total); lp++);
+ t = tmxsns(sec + lp->total, tmxnsec(t));
+ }
+ return t;
+}
diff --git a/usr/src/lib/libast/common/tm/tmxmake.c b/usr/src/lib/libast/common/tm/tmxmake.c
new file mode 100644
index 0000000000..5c49499b96
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmxmake.c
@@ -0,0 +1,134 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * Time_t conversion support
+ */
+
+#include <tmx.h>
+
+#include "FEATURE/tmlib"
+
+/*
+ * return Tm_t for t
+ * time zone and leap seconds accounted for in return value
+ */
+
+Tm_t*
+tmxmake(Time_t t)
+{
+ register struct tm* tp;
+ register Tm_leap_t* lp;
+ Time_t x;
+ time_t now;
+ int leapsec;
+ int y;
+ uint32_t n;
+ int32_t o;
+#if TMX_FLOAT
+ Time_t z;
+ uint32_t i;
+#endif
+ Tm_t tm;
+
+ static Tm_t ts;
+
+ tmset(tm_info.zone);
+ leapsec = 0;
+ if ((tm_info.flags & (TM_ADJUST|TM_LEAP)) == (TM_ADJUST|TM_LEAP) && (n = tmxsec(t)))
+ {
+ for (lp = &tm_data.leap[0]; n < lp->time; lp++);
+ if (lp->total)
+ {
+ if (n == lp->time && (leapsec = (lp->total - (lp+1)->total)) < 0)
+ leapsec = 0;
+ t = tmxsns(n - lp->total, tmxnsec(t));
+ }
+ }
+ x = tmxsec(t);
+ if (tm_info.flags & TM_UTC)
+ {
+ tm.tm_zone = &tm_data.zone[2];
+ o = 0;
+ }
+ else
+ {
+ tm.tm_zone = tm_info.zone;
+ o = 60 * tm.tm_zone->west;
+ if (x > o)
+ {
+ x -= o;
+ o = 0;
+ }
+ }
+#if TMX_FLOAT
+ i = x / (24 * 60 * 60);
+ z = i;
+ n = x - z * (24 * 60 * 60);
+ tm.tm_sec = n % 60 + leapsec;
+ n /= 60;
+ tm.tm_min = n % 60;
+ n /= 60;
+ tm.tm_hour = n % 24;
+#define x i
+#else
+ tm.tm_sec = x % 60 + leapsec;
+ x /= 60;
+ tm.tm_min = x % 60;
+ x /= 60;
+ tm.tm_hour = x % 24;
+ x /= 24;
+#endif
+ tm.tm_wday = (x + 4) % 7;
+ tm.tm_year = (400 * (x + 25202)) / 146097 + 1;
+ n = tm.tm_year - 1;
+ x -= n * 365 + n / 4 - n / 100 + (n + (1900 - 1600)) / 400 - (1970 - 1901) * 365 - (1970 - 1901) / 4;
+ tm.tm_mon = 0;
+ tm.tm_mday = x + 1;
+ tmfix(&tm);
+ n += 1900;
+ tm.tm_isdst = 0;
+ if (tm.tm_zone->daylight)
+ {
+ if ((y = tmequiv(&tm) - 1900) == tm.tm_year)
+ now = tmxsec(t);
+ else
+ {
+ Tm_t te;
+
+ te = tm;
+ te.tm_year = y;
+ now = tmxsec(tmxtime(&te, tm.tm_zone->west));
+ }
+ if ((tp = tmlocaltime(&now)) && ((tm.tm_isdst = tp->tm_isdst) || o))
+ {
+ tm.tm_min -= o / 60 + (tm.tm_isdst ? tm.tm_zone->dst : 0);
+ tmfix(&tm);
+ }
+ }
+ tm.tm_nsec = tmxnsec(t);
+ ts = tm;
+ return &ts;
+}
diff --git a/usr/src/lib/libast/common/tm/tmxscan.c b/usr/src/lib/libast/common/tm/tmxscan.c
new file mode 100644
index 0000000000..5feafe7f67
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmxscan.c
@@ -0,0 +1,523 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * Time_t conversion support
+ *
+ * scan date expression in s using format
+ * if non-null, e points to the first invalid sequence in s
+ * if non-null, f points to the first unused format char
+ * t provides default values
+ */
+
+#include <tmx.h>
+#include <ctype.h>
+
+typedef struct
+{
+ int32_t nsec;
+ int year;
+ int mon;
+ int week;
+ int weektype;
+ int yday;
+ int mday;
+ int wday;
+ int hour;
+ int min;
+ int sec;
+ int meridian;
+ int zone;
+} Set_t;
+
+#define CLEAR(s) (s.year=s.mon=s.week=s.weektype=s.yday=s.mday=s.wday=s.hour=s.min=s.sec=s.meridian=(-1),s.nsec=1000000000L,s.zone=TM_LOCALZONE)
+
+#define INDEX(m,x) (((n)>=((x)-(m)))?((n)-=((x)-(m))):(n))
+
+#define NUMBER(d,m,x) do \
+ { \
+ n = 0; \
+ u = (char*)s; \
+ while (s < (const char*)(u + d) && *s >= '0' && *s <= '9') \
+ n = n * 10 + *s++ - '0'; \
+ if (u == (char*)s || n < m || n > x) \
+ goto next; \
+ } while (0)
+
+/*
+ * generate a Time_t from tm + set
+ */
+
+static Time_t
+gen(register Tm_t* tm, register Set_t* set)
+{
+ register int n;
+ Time_t t;
+
+ if (set->year >= 0)
+ tm->tm_year = set->year;
+ if (set->mon >= 0)
+ {
+ if (set->year < 0 && set->mon < tm->tm_mon)
+ tm->tm_year++;
+ tm->tm_mon = set->mon;
+ if (set->yday < 0 && set->mday < 0)
+ tm->tm_mday = set->mday = 1;
+ }
+ if (set->week >= 0)
+ {
+ if (set->mon < 0)
+ {
+ tmweek(tm, set->weektype, set->week, set->wday);
+ set->wday = -1;
+ }
+ }
+ else if (set->yday >= 0)
+ {
+ if (set->mon < 0)
+ {
+ tm->tm_mon = 0;
+ tm->tm_mday = set->yday + 1;
+ }
+ }
+ else if (set->mday >= 0)
+ tm->tm_mday = set->mday;
+ if (set->hour >= 0)
+ {
+ if (set->hour < tm->tm_hour && set->yday < 0 && set->mday < 0 && set->wday < 0)
+ tm->tm_mday++;
+ tm->tm_hour = set->hour;
+ tm->tm_min = (set->min >= 0) ? set->min : 0;
+ tm->tm_sec = (set->sec >= 0) ? set->sec : 0;
+ }
+ else if (set->min >= 0)
+ {
+ tm->tm_min = set->min;
+ tm->tm_sec = (set->sec >= 0) ? set->sec : 0;
+ }
+ else if (set->sec >= 0)
+ tm->tm_sec = set->sec;
+ if (set->nsec < 1000000000L)
+ tm->tm_nsec = set->nsec;
+ if (set->meridian > 0)
+ {
+ if (tm->tm_hour < 12)
+ tm->tm_hour += 12;
+ }
+ else if (set->meridian == 0)
+ {
+ if (tm->tm_hour >= 12)
+ tm->tm_hour -= 12;
+ }
+ t = tmxtime(tm, set->zone);
+ tm = 0;
+ if (set->yday >= 0)
+ {
+ tm = tmxmake(t);
+ tm->tm_mday += set->yday - tm->tm_yday;
+ }
+ else if (set->wday >= 0)
+ {
+ tm = tmxmake(t);
+ if ((n = set->wday - tm->tm_wday) < 0)
+ n += 7;
+ tm->tm_mday += n;
+ }
+ if (set->nsec < 1000000000L)
+ {
+ if (!tm)
+ tm = tmxmake(t);
+ tm->tm_nsec = set->nsec;
+ }
+ return tm ? tmxtime(tm, set->zone) : t;
+}
+
+/*
+ * the format scan workhorse
+ */
+
+static Time_t
+scan(register const char* s, char** e, const char* format, char** f, Time_t t, long flags)
+{
+ register int d;
+ register int n;
+ register char* p;
+ register Tm_t* tm;
+ const char* b;
+ char* u;
+ char* stack[4];
+ int m;
+ int hi;
+ int lo;
+ int pedantic;
+ Time_t x;
+ Set_t set;
+ Tm_zone_t* zp;
+
+ char** sp = &stack[0];
+
+ while (isspace(*s))
+ s++;
+ b = s;
+ again:
+ CLEAR(set);
+ tm = tmxmake(t);
+ tm_info.date = tm_info.zone;
+ pedantic = (flags & TM_PEDANTIC) != 0;
+ for (;;)
+ {
+ if (!(d = *format++))
+ {
+ if (sp <= &stack[0])
+ {
+ format--;
+ break;
+ }
+ format = (const char*)*--sp;
+ }
+ else if (!*s)
+ {
+ format--;
+ break;
+ }
+ else if (d == '%' && (d = *format) && format++ && d != '%')
+ {
+ more:
+ switch (d)
+ {
+ case 'a':
+ lo = TM_DAY_ABBREV;
+ hi = pedantic ? TM_DAY : TM_TIME;
+ goto get_wday;
+ case 'A':
+ lo = pedantic ? TM_DAY : TM_DAY_ABBREV;
+ hi = TM_TIME;
+ get_wday:
+ if ((n = tmlex(s, &u, tm_info.format + lo, hi - lo, NiL, 0)) < 0)
+ goto next;
+ s = u;
+ INDEX(TM_DAY_ABBREV, TM_DAY);
+ set.wday = n;
+ continue;
+ case 'b':
+ case 'h':
+ lo = TM_MONTH_ABBREV;
+ hi = pedantic ? TM_MONTH : TM_DAY_ABBREV;
+ goto get_mon;
+ case 'B':
+ lo = pedantic ? TM_MONTH : TM_MONTH_ABBREV;
+ hi = TM_DAY_ABBREV;
+ get_mon:
+ if ((n = tmlex(s, &u, tm_info.format + lo, hi - lo, NiL, 0)) < 0)
+ goto next;
+ s = u;
+ INDEX(TM_MONTH_ABBREV, TM_MONTH);
+ set.mon = n;
+ continue;
+ case 'c':
+ p = "%a %b %e %T %Y";
+ break;
+ case 'C':
+ NUMBER(2, 19, 99);
+ set.year = (n - 19) * 100 + tm->tm_year % 100;
+ continue;
+ case 'd':
+ if (pedantic && !isdigit(*s))
+ goto next;
+ /*FALLTHROUGH*/
+ case 'e':
+ NUMBER(2, 1, 31);
+ set.mday = n;
+ continue;
+ case 'D':
+ p = "%m/%d/%y";
+ break;
+ case 'E':
+ case 'O':
+ if (*format)
+ {
+ d = *format++;
+ goto more;
+ }
+ continue;
+ case 'H':
+ case 'k':
+ NUMBER(2, 0, 23);
+ set.hour = n;
+ continue;
+ case 'I':
+ case 'l':
+ NUMBER(2, 1, 12);
+ set.hour = n;
+ continue;
+ case 'j':
+ NUMBER(3, 1, 366);
+ set.yday = n - 1;
+ continue;
+ case 'm':
+ NUMBER(2, 1, 12);
+ set.mon = n - 1;
+ continue;
+ case 'M':
+ NUMBER(2, 0, 59);
+ set.min = n;
+ continue;
+ case 'n':
+ if (pedantic)
+ while (*s == '\n')
+ s++;
+ else
+ while (isspace(*s))
+ s++;
+ continue;
+ case 'N':
+ NUMBER(9, 0, 999999999L);
+ set.nsec = n;
+ continue;
+ case 'p':
+ if ((n = tmlex(s, &u, tm_info.format + TM_MERIDIAN, TM_UT - TM_MERIDIAN, NiL, 0)) < 0)
+ goto next;
+ set.meridian = n;
+ s = u;
+ continue;
+ case 'r':
+ p = "%I:%M:%S %p";
+ break;
+ case 'R':
+ p = "%H:%M:%S";
+ break;
+ case 's':
+ x = strtoul(s, &u, 0);
+ if (s == u)
+ goto next;
+ tm = tmxmake(tmxsns(x, 0));
+ s = u;
+ CLEAR(set);
+ continue;
+ case 'S':
+ NUMBER(2, 0, 61);
+ set.sec = n;
+ continue;
+ case 'u':
+ NUMBER(2, 1, 7);
+ set.wday = n % 7;
+ continue;
+ case 'U':
+ NUMBER(2, 0, 52);
+ set.week = n;
+ set.weektype = 0;
+ continue;
+ case 'V':
+ NUMBER(2, 1, 53);
+ set.week = n;
+ set.weektype = 2;
+ continue;
+ case 'w':
+ NUMBER(2, 0, 6);
+ set.wday = n;
+ continue;
+ case 'W':
+ NUMBER(2, 0, 52);
+ set.week = n;
+ set.weektype = 1;
+ continue;
+ case 'x':
+ p = tm_info.format[TM_DATE];
+ break;
+ case 'X':
+ p = tm_info.format[TM_TIME];
+ break;
+ case 'y':
+ NUMBER(2, 0, 99);
+ if (n < TM_WINDOW)
+ n += 100;
+ set.year = n;
+ continue;
+ case 'Y':
+ NUMBER(4, 1969, 2100);
+ set.year = n - 1900;
+ continue;
+ case 'Z':
+ case 'q':
+ if (zp = tmtype(s, &u))
+ {
+ s = u;
+ u = zp->type;
+ }
+ else
+ u = 0;
+ if (d == 'q')
+ continue;
+ case 'z':
+ if ((zp = tmzone(s, &u, u, &m)))
+ {
+ s = u;
+ set.zone = zp->west + m;
+ tm_info.date = zp;
+ }
+ continue;
+ case '|':
+ s = b;
+ goto again;
+ case '&':
+ x = gen(tm, &set);
+ x = tmxdate(s, e, t);
+ if (s == (const char*)*e)
+ goto next;
+ t = x;
+ s = (const char*)*e;
+ if (!*format || *format == '%' && *(format + 1) == '|')
+ goto done;
+ goto again;
+ default:
+ goto next;
+ }
+ if (sp >= &stack[elementsof(stack)])
+ goto next;
+ *sp++ = (char*)format;
+ format = (const char*)p;
+ }
+ else if (isspace(d))
+ while (isspace(*s))
+ s++;
+ else if (*s != d)
+ break;
+ else
+ s++;
+ }
+ next:
+ if (sp > &stack[0])
+ format = (const char*)stack[0];
+ if (*format)
+ {
+ p = (char*)format;
+ if (!*s && *p == '%' && *(p + 1) == '|')
+ format += strlen(format);
+ else
+ while (*p)
+ if (*p++ == '%' && *p && *p++ == '|' && *p)
+ {
+ format = (const char*)p;
+ s = b;
+ goto again;
+ }
+ }
+ t = gen(tm, &set);
+ done:
+ if (e)
+ {
+ while (isspace(*s))
+ s++;
+ *e = (char*)s;
+ }
+ if (f)
+ {
+ while (isspace(*format))
+ format++;
+ *f = (char*)format;
+ }
+ return t;
+}
+
+/*
+ * format==0 DATEMSK
+ * *format==0 DATEMSK and tmxdate()
+ * *format!=0 format
+ */
+
+Time_t
+tmxscan(const char* s, char** e, const char* format, char** f, Time_t t, long flags)
+{
+ register char* v;
+ register char** p;
+ char* q;
+ char* r;
+ Time_t x;
+
+ static int initialized;
+ static char** datemask;
+
+ tmlocale();
+ if (!format || !*format)
+ {
+ if (!initialized)
+ {
+ register Sfio_t* sp;
+ register int n;
+ off_t m;
+
+ initialized = 1;
+ if ((v = getenv("DATEMSK")) && *v && (sp = sfopen(NiL, v, "r")))
+ {
+ for (n = 1; sfgetr(sp, '\n', 0); n++);
+ m = sfseek(sp, 0L, SEEK_CUR);
+ if (p = newof(0, char*, n, m))
+ {
+ sfseek(sp, 0L, SEEK_SET);
+ v = (char*)(p + n);
+ if (sfread(sp, v, m) != m)
+ {
+ free(p);
+ p = 0;
+ }
+ else
+ {
+ datemask = p;
+ v[m] = 0;
+ while (*v)
+ {
+ *p++ = v;
+ if (!(v = strchr(v, '\n')))
+ break;
+ *v++ = 0;
+ }
+ *p = 0;
+ }
+ }
+ }
+ }
+ if (p = datemask)
+ while (v = *p++)
+ {
+ x = scan(s, &q, v, &r, t, flags);
+ if (!*q && !*r)
+ {
+ if (e)
+ *e = q;
+ if (f)
+ *f = r;
+ return x;
+ }
+ }
+ if (f)
+ *f = (char*)format;
+ if (format)
+ return tmxdate(s, e, t);
+ if (e)
+ *e = (char*)s;
+ return 0;
+ }
+ return scan(s, e, format, f, t, flags);
+}
diff --git a/usr/src/lib/libast/common/tm/tmxsettime.c b/usr/src/lib/libast/common/tm/tmxsettime.c
new file mode 100644
index 0000000000..25cf6b2c66
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmxsettime.c
@@ -0,0 +1,45 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * Time_t conversion support
+ */
+
+#include <tmx.h>
+#include <tv.h>
+
+/*
+ * return current current time to t
+ */
+
+int
+tmxsettime(Time_t t)
+{
+ Tv_t tv;
+
+ tv.tv_sec = tmxsec(t);
+ tv.tv_nsec = tmxnsec(t);
+ return tvsettime(&tv);
+}
diff --git a/usr/src/lib/libast/common/tm/tmxsleep.c b/usr/src/lib/libast/common/tm/tmxsleep.c
new file mode 100644
index 0000000000..da87478f83
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmxsleep.c
@@ -0,0 +1,41 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * Time_t sleep
+ */
+
+#include <tmx.h>
+#include <tv.h>
+
+int
+tmxsleep(Time_t t)
+{
+ Tv_t tv;
+
+ tv.tv_sec = tmxsec(t);
+ tv.tv_nsec = tmxnsec(t);
+ return tvsleep(&tv, NiL);
+}
diff --git a/usr/src/lib/libast/common/tm/tmxtime.c b/usr/src/lib/libast/common/tm/tmxtime.c
new file mode 100644
index 0000000000..262d893317
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmxtime.c
@@ -0,0 +1,137 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * Time_t conversion support
+ */
+
+#include <tmx.h>
+
+#include "FEATURE/tmlib"
+
+/*
+ * convert Tm_t to Time_t
+ *
+ * if west==TM_LOCALZONE then the local timezone is used
+ * otherwise west is the number of minutes west
+ * of GMT with DST taken into account
+ *
+ * this routine works with a copy of Tm_t to avoid clashes
+ * with other tm*() that may return static Tm_t*
+ */
+
+Time_t
+tmxtime(register Tm_t* tm, int west)
+{
+ register Time_t t;
+ register Tm_leap_t* lp;
+ register int32_t y;
+ int n;
+ int sec;
+ time_t now;
+ struct tm* tl;
+ Tm_t* to;
+ Tm_t ts;
+
+ ts = *tm;
+ to = tm;
+ tm = &ts;
+ tmset(tm_info.zone);
+ tmfix(tm);
+ y = tm->tm_year;
+ if (y < 69 || y > (TMX_MAXYEAR - 1900))
+ return TMX_NOTIME;
+ y--;
+ t = y * 365 + y / 4 - y / 100 + (y + (1900 - 1600)) / 400 - (1970 - 1901) * 365 - (1970 - 1901) / 4;
+ if ((n = tm->tm_mon) > 11)
+ n = 11;
+ y += 1901;
+ if (n > 1 && tmisleapyear(y))
+ t++;
+ t += tm_data.sum[n] + tm->tm_mday - 1;
+ t *= 24;
+ t += tm->tm_hour;
+ t *= 60;
+ t += tm->tm_min;
+ t *= 60;
+ t += sec = tm->tm_sec;
+ if (west != TM_UTCZONE && !(tm_info.flags & TM_UTC))
+ {
+ /*
+ * time zone adjustments
+ */
+
+ if (west == TM_LOCALZONE)
+ {
+ t += tm_info.zone->west * 60;
+ if (!tm_info.zone->daylight)
+ tm->tm_isdst = 0;
+ else
+ {
+ y = tm->tm_year;
+ tm->tm_year = tmequiv(tm) - 1900;
+ now = tmxsec(tmxtime(tm, tm_info.zone->west));
+ tm->tm_year = y;
+ if (!(tl = tmlocaltime(&now)))
+ return TMX_NOTIME;
+ if (tm->tm_isdst = tl->tm_isdst)
+ t += tm_info.zone->dst * 60;
+ }
+ }
+ else
+ {
+ t += west * 60;
+ if (!tm_info.zone->daylight)
+ tm->tm_isdst = 0;
+ else if (tm->tm_isdst < 0)
+ {
+ y = tm->tm_year;
+ tm->tm_year = tmequiv(tm) - 1900;
+ tm->tm_isdst = 0;
+ now = tmxsec(tmxtime(tm, tm_info.zone->west));
+ tm->tm_year = y;
+ if (!(tl = tmlocaltime(&now)))
+ return TMX_NOTIME;
+ tm->tm_isdst = tl->tm_isdst;
+ }
+ }
+ }
+ else if (tm->tm_isdst)
+ tm->tm_isdst = 0;
+ *to = *tm;
+ if (tm_info.flags & TM_LEAP)
+ {
+ /*
+ * leap second adjustments
+ */
+
+ for (lp = &tm_data.leap[0]; t < lp->time - (lp+1)->total; lp++);
+ t += lp->total;
+ n = lp->total - (lp+1)->total;
+ if (t <= (lp->time + n) && (n > 0 && sec > 59 || n < 0 && sec > (59 + n) && sec <= 59))
+ t -= n;
+ }
+ return tmxsns(t, tm->tm_nsec);
+}
diff --git a/usr/src/lib/libast/common/tm/tmxtouch.c b/usr/src/lib/libast/common/tm/tmxtouch.c
new file mode 100644
index 0000000000..67d84fecd2
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmxtouch.c
@@ -0,0 +1,81 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * Time_t conversion support
+ */
+
+#include <tmx.h>
+#include <tv.h>
+
+/*
+ * touch path <atime,mtime,ctime>
+ * (flags&PATH_TOUCH_VERBATIM) treats times verbatim, otherwise:
+ * Time_t==0 current time
+ * Time_t==TMX_NOTIME retains path value
+ */
+
+int
+tmxtouch(const char* path, Time_t at, Time_t mt, Time_t ct, int flags)
+{
+ Tv_t av;
+ Tv_t mv;
+ Tv_t cv;
+ Tv_t* ap;
+ Tv_t* mp;
+ Tv_t* cp;
+
+ if (at == TMX_NOTIME && !(flags & PATH_TOUCH_VERBATIM))
+ ap = TV_TOUCH_RETAIN;
+ else if (!at && !(flags & PATH_TOUCH_VERBATIM))
+ ap = 0;
+ else
+ {
+ av.tv_sec = tmxsec(at);
+ av.tv_nsec = tmxnsec(at);
+ ap = &av;
+ }
+ if (mt == TMX_NOTIME && !(flags & PATH_TOUCH_VERBATIM))
+ mp = TV_TOUCH_RETAIN;
+ else if (!mt && !(flags & PATH_TOUCH_VERBATIM))
+ mp = 0;
+ else
+ {
+ mv.tv_sec = tmxsec(mt);
+ mv.tv_nsec = tmxnsec(mt);
+ mp = &mv;
+ }
+ if (ct == TMX_NOTIME && !(flags & PATH_TOUCH_VERBATIM))
+ cp = TV_TOUCH_RETAIN;
+ else if (!ct && !(flags & PATH_TOUCH_VERBATIM))
+ cp = 0;
+ else
+ {
+ cv.tv_sec = tmxsec(ct);
+ cv.tv_nsec = tmxnsec(ct);
+ cp = &cv;
+ }
+ return tvtouch(path, ap, mp, cp, flags & 1);
+}
diff --git a/usr/src/lib/libast/common/tm/tmzone.c b/usr/src/lib/libast/common/tm/tmzone.c
new file mode 100644
index 0000000000..784668d589
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tmzone.c
@@ -0,0 +1,95 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * time conversion support
+ */
+
+#include <ast.h>
+#include <tm.h>
+
+/*
+ * return timezone pointer given name and type
+ *
+ * if type==0 then all time zone types match
+ * otherwise type must be one of tm_info.zone[].type
+ *
+ * if end is non-null then it will point to the next
+ * unmatched char in name
+ *
+ * if dst!=0 then it will point to 0 for standard zones
+ * and the offset for daylight zones
+ *
+ * 0 returned for no match
+ */
+
+Tm_zone_t*
+tmzone(register const char* name, char** end, const char* type, int* dst)
+{
+ register Tm_zone_t* zp;
+ register char* prev;
+ char* e;
+
+ static Tm_zone_t fixed;
+ static char off[16];
+
+ tmset(tm_info.zone);
+ if ((*name == '+' || *name == '-') && (fixed.west = tmgoff(name, &e, TM_LOCALZONE)) != TM_LOCALZONE && !*e)
+ {
+ fixed.standard = fixed.daylight = strncpy(off, name, sizeof(off) - 1);
+ if (end)
+ *end = e;
+ if (dst)
+ *dst = 0;
+ return &fixed;
+ }
+ zp = tm_info.local;
+ prev = 0;
+ do
+ {
+ if (zp->type)
+ prev = zp->type;
+ if (!type || type == prev || !prev)
+ {
+ if (tmword(name, end, zp->standard, NiL, 0))
+ {
+ if (dst)
+ *dst = 0;
+ return zp;
+ }
+ if (zp->dst && zp->daylight && tmword(name, end, zp->daylight, NiL, 0))
+ {
+ if (dst)
+ *dst = zp->dst;
+ return zp;
+ }
+ }
+ if (zp == tm_info.local)
+ zp = tm_data.zone;
+ else
+ zp++;
+ } while (zp->standard);
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/tm/tvcmp.c b/usr/src/lib/libast/common/tm/tvcmp.c
new file mode 100644
index 0000000000..39ce1631c4
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tvcmp.c
@@ -0,0 +1,46 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <tv.h>
+
+/*
+ * compare a with b
+ * strcmp semantics
+ */
+
+int
+tvcmp(register const Tv_t* a, register const Tv_t* b)
+{
+ if (a->tv_sec < b->tv_sec)
+ return 1;
+ if (a->tv_sec > b->tv_sec)
+ return -1;
+ if (a->tv_nsec != TV_NSEC_IGNORE && b->tv_nsec != TV_NSEC_IGNORE)
+ {
+ if (a->tv_nsec < b->tv_nsec)
+ return 1;
+ if (a->tv_nsec > b->tv_nsec)
+ return -1;
+ }
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/tm/tvgettime.c b/usr/src/lib/libast/common/tm/tvgettime.c
new file mode 100644
index 0000000000..c20706beb2
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tvgettime.c
@@ -0,0 +1,70 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <tv.h>
+#include <tm.h>
+
+#include "FEATURE/tvlib"
+
+int
+tvgettime(Tv_t* tv)
+{
+
+#if _lib_clock_gettime && defined(CLOCK_REALTIME)
+
+ struct timespec s;
+
+ clock_gettime(CLOCK_REALTIME, &s);
+ tv->tv_sec = s.tv_sec;
+ tv->tv_nsec = s.tv_nsec;
+
+#else
+
+#if defined(tmgettimeofday)
+
+ struct timeval v;
+
+ tmgettimeofday(&v);
+ tv->tv_sec = v.tv_sec;
+ tv->tv_nsec = v.tv_usec * 1000;
+
+#else
+
+ static time_t s;
+ static uint32_t n;
+
+ if ((tv->tv_sec = time(NiL)) != s)
+ {
+ s = tv->tv_sec;
+ n = 0;
+ }
+ else
+ n += 1000;
+ tv->tv_nsec = n;
+
+#endif
+
+#endif
+
+ return 0;
+}
diff --git a/usr/src/lib/libast/common/tm/tvsettime.c b/usr/src/lib/libast/common/tm/tvsettime.c
new file mode 100644
index 0000000000..7cb46ae93a
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tvsettime.c
@@ -0,0 +1,72 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <tv.h>
+#include <tm.h>
+#include <errno.h>
+
+#include "FEATURE/tvlib"
+
+int
+tvsettime(const Tv_t* tv)
+{
+
+#if _lib_clock_settime && defined(CLOCK_REALTIME)
+
+ struct timespec s;
+
+ s.tv_sec = tv->tv_sec;
+ s.tv_nsec = tv->tv_nsec;
+ return clock_settime(CLOCK_REALTIME, &s);
+
+#else
+
+#if defined(tmsettimeofday)
+
+ struct timeval v;
+
+ v.tv_sec = tv->tv_sec;
+ v.tv_usec = tv->tv_nsec / 1000;
+ return tmsettimeofday(&v);
+
+#else
+
+#if _lib_stime
+
+ static time_t s;
+
+ s = tv->tv_sec + (tv->tv_nsec != 0);
+ return stime(s);
+
+#else
+
+ errno = EPERM;
+ return -1;
+
+#endif
+
+#endif
+
+#endif
+
+}
diff --git a/usr/src/lib/libast/common/tm/tvsleep.c b/usr/src/lib/libast/common/tm/tvsleep.c
new file mode 100644
index 0000000000..6c5e31e634
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tvsleep.c
@@ -0,0 +1,144 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <tv.h>
+#include <tm.h>
+
+#include "FEATURE/tvlib"
+
+#if !_lib_nanosleep
+# if _lib_select
+# if _sys_select
+# include <sys/select.h>
+# else
+# include <sys/socket.h>
+# endif
+# else
+# if !_lib_usleep
+# if _lib_poll_notimer
+# undef _lib_poll
+# endif
+# if _lib_poll
+# include <poll.h>
+# endif
+# endif
+# endif
+#endif
+
+/*
+ * sleep for tv
+ * non-zero exit if sleep did not complete
+ * with remaining time in rv
+ */
+
+int
+tvsleep(register const Tv_t* tv, register Tv_t* rv)
+{
+
+#if _lib_nanosleep
+
+ struct timespec stv;
+ struct timespec srv;
+ int r;
+
+ stv.tv_sec = tv->tv_sec;
+ stv.tv_nsec = tv->tv_nsec;
+ if ((r = nanosleep(&stv, &srv)) && rv)
+ {
+ rv->tv_sec = srv.tv_sec;
+ rv->tv_nsec = srv.tv_nsec;
+ }
+ return r;
+
+#else
+
+#if _lib_select
+
+ struct timeval stv;
+
+ stv.tv_sec = tv->tv_sec;
+ stv.tv_usec = tv->tv_nsec / 1000;
+ if (select(0, NiL, NiL, NiL, &stv) < 0)
+ {
+ if (rv)
+ *rv = *tv;
+ return -1;
+ }
+ if (rv)
+ {
+ rv->tv_sec = stv.tv_sec;
+ rv->tv_nsec = stv.tv_usec * 1000;
+ }
+ return 0;
+
+#else
+
+ unsigned int s = tv->tv_sec;
+ uint32_t n = tv->tv_nsec;
+
+#if _lib_usleep
+
+
+ unsigned long t;
+
+ if (t = (n + 999L) / 1000L)
+ {
+ usleep(t);
+ s -= t / 1000000L;
+ n = 0;
+ }
+
+#else
+
+#if _lib_poll
+
+ struct pollfd pfd;
+ int t;
+
+ if ((t = (n + 999999L) / 1000000L) > 0)
+ {
+ poll(&pfd, 0, t);
+ s -= t / 1000L;
+ n = 0;
+ }
+
+#endif
+
+#endif
+
+ if ((s += (n + 999999999L) / 1000000000L) && (s = sleep(s)))
+ {
+ if (rv)
+ {
+ rv->tv_sec = s;
+ rv->tv_nsec = 0;
+ }
+ return -1;
+ }
+ return 0;
+
+#endif
+
+#endif
+
+}
diff --git a/usr/src/lib/libast/common/tm/tvtouch.c b/usr/src/lib/libast/common/tm/tvtouch.c
new file mode 100644
index 0000000000..78ed01839a
--- /dev/null
+++ b/usr/src/lib/libast/common/tm/tvtouch.c
@@ -0,0 +1,232 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * Tv_t conversion support
+ */
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide utime
+#else
+#define utime ______utime
+#endif
+
+#include <ast.h>
+#include <ls.h>
+#include <tv.h>
+#include <times.h>
+#include <error.h>
+
+#include "FEATURE/tvlib"
+
+#if _hdr_utime && _lib_utime
+#include <utime.h>
+#endif
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide utime
+#else
+#undef utime
+#endif
+
+#if _lib_utime
+#if _hdr_utime
+extern int utime(const char*, const struct utimbuf*);
+#else
+extern int utime(const char*, const time_t*);
+#endif
+#endif
+
+#define NS(n) (((uint32_t)(n))<1000000000L?(n):0)
+
+/*
+ * touch path <atime,mtime,ctime>
+ * Tv_t==0 uses current time
+ * Tv_t==TV_TOUCH_RETAIN retains path value if it exists, current time otherwise
+ * otherwise it is exact time
+ * file created if it doesn't exist and (flags&1)
+ * cv most likely ignored on most implementations
+ */
+
+int
+tvtouch(const char* path, register const Tv_t* av, register const Tv_t* mv, const Tv_t* cv, int flags)
+{
+ struct stat st;
+ Tv_t now;
+ int fd;
+ int mode;
+ int oerrno;
+#if _lib_utimets
+ struct timespec am[2];
+#else
+#if _lib_utimes
+ struct timeval am[2];
+#else
+#if _hdr_utime
+ struct utimbuf am;
+#else
+ time_t am[2];
+#endif
+#endif
+#endif
+
+ oerrno = errno;
+ if ((av == TV_TOUCH_RETAIN || mv == TV_TOUCH_RETAIN) && stat(path, &st))
+ {
+ errno = oerrno;
+ if (av == TV_TOUCH_RETAIN)
+ av = 0;
+ if (mv == TV_TOUCH_RETAIN)
+ mv = 0;
+ }
+ if (!av || !mv)
+ {
+ tvgettime(&now);
+ if (!av)
+ av = (const Tv_t*)&now;
+ if (!mv)
+ mv = (const Tv_t*)&now;
+ }
+#if _lib_utimets
+ if (av == TV_TOUCH_RETAIN)
+ {
+ am[0].tv_sec = st.st_atime;
+ am[0].tv_nsec = ST_ATIME_NSEC_GET(&st);
+ }
+ else
+ {
+ am[0].tv_sec = av->tv_sec;
+ am[0].tv_nsec = NS(av->tv_nsec);
+ }
+ if (mv == TV_TOUCH_RETAIN)
+ {
+ am[1].tv_sec = st.st_mtime;
+ am[1].tv_nsec = ST_MTIME_NSEC_GET(&st);
+ }
+ else
+ {
+ am[1].tv_sec = mv->tv_sec;
+ am[1].tv_nsec = NS(mv->tv_nsec);
+ }
+ if (!utimets(path, am))
+ return 0;
+ if (errno != ENOENT && av == (const Tv_t*)&now && mv == (const Tv_t*)&now && !utimets(path, NiL))
+ {
+ errno = oerrno;
+ return 0;
+ }
+#else
+#if _lib_utimes
+ if (av == TV_TOUCH_RETAIN)
+ {
+ am[0].tv_sec = st.st_atime;
+ am[0].tv_usec = ST_ATIME_NSEC_GET(&st) / 1000;
+ }
+ else
+ {
+ am[0].tv_sec = av->tv_sec;
+ am[0].tv_usec = NS(av->tv_nsec) / 1000;
+ }
+ if (mv == TV_TOUCH_RETAIN)
+ {
+ am[1].tv_sec = st.st_mtime;
+ am[1].tv_usec = ST_MTIME_NSEC_GET(&st) / 1000;
+ }
+ else
+ {
+ am[1].tv_sec = mv->tv_sec;
+ am[1].tv_usec = NS(mv->tv_nsec) / 1000;
+ }
+ if (!utimes(path, am))
+ return 0;
+ if (errno != ENOENT && av == (const Tv_t*)&now && mv == (const Tv_t*)&now && !utimes(path, NiL))
+ {
+ errno = oerrno;
+ return 0;
+ }
+#else
+#if _lib_utime
+ am.actime = (av == TV_TOUCH_RETAIN) ? st.st_atime : av->tv_sec;
+ am.modtime = (mv == TV_TOUCH_RETAIN) ? st.st_mtime : mv->tv_sec;
+ if (!utime(path, &am))
+ return 0;
+#if _lib_utime_now
+ if (errno != ENOENT && av == (const Tv_t*)&now && mv == (const Tv_t*)&now && !utime(path, NiL))
+ {
+ errno = oerrno;
+ return 0;
+ }
+#endif
+#endif
+#endif
+ if (!access(path, F_OK))
+ {
+ if (av != (const Tv_t*)&now || mv != (const Tv_t*)&now)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ if ((fd = open(path, O_RDWR)) >= 0)
+ {
+ char c;
+
+ if (read(fd, &c, 1) == 1)
+ {
+ if (c = (lseek(fd, 0L, 0) == 0L && write(fd, &c, 1) == 1))
+ errno = oerrno;
+ close(fd);
+ if (c)
+ return 0;
+ }
+ close(fd);
+ }
+ }
+#endif
+ if (errno != ENOENT || !(flags & 1))
+ return -1;
+ umask(mode = umask(0));
+ mode = (~mode) & (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
+ if ((fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)) < 0)
+ return -1;
+ close(fd);
+ errno = oerrno;
+ if (av == (const Tv_t*)&now && mv == (const Tv_t*)&now)
+ return 0;
+#if _lib_utimets
+ return utimets(path, am);
+#else
+#if _lib_utimes
+ return utimes(path, am);
+#else
+#if _lib_utime
+ return utime(path, &am);
+#else
+ errno = EINVAL;
+ return -1;
+#endif
+#endif
+#endif
+
+}
diff --git a/usr/src/lib/libast/common/uwin/a64l.c b/usr/src/lib/libast/common/uwin/a64l.c
new file mode 100644
index 0000000000..3142d2c6ef
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/a64l.c
@@ -0,0 +1,76 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "FEATURE/uwin"
+
+#if !_UWIN || _lib_a64l
+
+void _STUB_a64l(){}
+
+#else
+
+#define a64l ______a64l
+#define l64a ______l64a
+
+#include <stdlib.h>
+#include <string.h>
+
+#undef a64l
+#undef l64a
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+static char letter[65] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+extern long a64l(const char *str)
+{
+ register unsigned long ul = 0;
+ register int n = 6;
+ register int c;
+ register char *cp;
+ for(n=0; n <6; n++)
+ {
+ if((c= *str++)==0)
+ break;
+ if(!(cp=strchr(letter,c)))
+ break;
+ ul |= (cp-letter)<< (6*n);
+ }
+ return((long)ul);
+}
+
+extern char *l64a(long l)
+{
+ static char buff[7];
+ unsigned ul = ((unsigned long)l & 0xffffffff);
+ register char *cp = buff;
+ while(ul>0)
+ {
+ *cp++ = letter[ul&077];
+ ul >>= 6;
+ }
+ *cp = 0;
+ return(buff);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/acosh.c b/usr/src/lib/libast/common/uwin/acosh.c
new file mode 100644
index 0000000000..9248e915de
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/acosh.c
@@ -0,0 +1,108 @@
+#include "FEATURE/uwin"
+
+#if !_UWIN || _lib_acosh
+
+void _STUB_acosh(){}
+
+#else
+
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)acosh.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* ACOSH(X)
+ * RETURN THE INVERSE HYPERBOLIC COSINE OF X
+ * DOUBLE PRECISION (VAX D FORMAT 56 BITS, IEEE DOUBLE 53 BITS)
+ * CODED IN C BY K.C. NG, 2/16/85;
+ * REVISED BY K.C. NG on 3/6/85, 3/24/85, 4/16/85, 8/17/85.
+ *
+ * Required system supported functions :
+ * sqrt(x)
+ *
+ * Required kernel function:
+ * log1p(x) ...return log(1+x)
+ *
+ * Method :
+ * Based on
+ * acosh(x) = log [ x + sqrt(x*x-1) ]
+ * we have
+ * acosh(x) := log1p(x)+ln2, if (x > 1.0E20); else
+ * acosh(x) := log1p( sqrt(x-1) * (sqrt(x-1) + sqrt(x+1)) ) .
+ * These formulae avoid the over/underflow complication.
+ *
+ * Special cases:
+ * acosh(x) is NaN with signal if x<1.
+ * acosh(NaN) is NaN without signal.
+ *
+ * Accuracy:
+ * acosh(x) returns the exact inverse hyperbolic cosine of x nearly
+ * rounded. In a test run with 512,000 random arguments on a VAX, the
+ * maximum observed error was 3.30 ulps (units of the last place) at
+ * x=1.0070493753568216 .
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+
+#include "mathimpl.h"
+
+vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000)
+vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC)
+
+ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000)
+ic(ln2lo, 1.9082149292705877000E-10,-33, 1.A39EF35793C76)
+
+#ifdef vccast
+#define ln2hi vccast(ln2hi)
+#define ln2lo vccast(ln2lo)
+#endif
+
+extern double acosh(x)
+double x;
+{
+ double t,big=1.E20; /* big+1==big */
+
+#if !defined(vax)&&!defined(tahoe)
+ if(x!=x) return(x); /* x is NaN */
+#endif /* !defined(vax)&&!defined(tahoe) */
+
+ /* return log1p(x) + log(2) if x is large */
+ if(x>big) {t=log1p(x)+ln2lo; return(t+ln2hi);}
+
+ t=sqrt(x-1.0);
+ return(log1p(t*(t+sqrt(x+1.0))));
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/asinh.c b/usr/src/lib/libast/common/uwin/asinh.c
new file mode 100644
index 0000000000..6c8f54cabc
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/asinh.c
@@ -0,0 +1,107 @@
+#include "FEATURE/uwin"
+
+#if !_UWIN || _lib_asinh
+
+void _STUB_asinh(){}
+
+#else
+
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)asinh.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* ASINH(X)
+ * RETURN THE INVERSE HYPERBOLIC SINE OF X
+ * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS)
+ * CODED IN C BY K.C. NG, 2/16/85;
+ * REVISED BY K.C. NG on 3/7/85, 3/24/85, 4/16/85.
+ *
+ * Required system supported functions :
+ * copysign(x,y)
+ * sqrt(x)
+ *
+ * Required kernel function:
+ * log1p(x) ...return log(1+x)
+ *
+ * Method :
+ * Based on
+ * asinh(x) = sign(x) * log [ |x| + sqrt(x*x+1) ]
+ * we have
+ * asinh(x) := x if 1+x*x=1,
+ * := sign(x)*(log1p(x)+ln2)) if sqrt(1+x*x)=x, else
+ * := sign(x)*log1p(|x| + |x|/(1/|x| + sqrt(1+(1/|x|)^2)) )
+ *
+ * Accuracy:
+ * asinh(x) returns the exact inverse hyperbolic sine of x nearly rounded.
+ * In a test run with 52,000 random arguments on a VAX, the maximum
+ * observed error was 1.58 ulps (units in the last place).
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+#include "mathimpl.h"
+
+vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000)
+vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC)
+
+ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000)
+ic(ln2lo, 1.9082149292705877000E-10, -33, 1.A39EF35793C76)
+
+#ifdef vccast
+#define ln2hi vccast(ln2hi)
+#define ln2lo vccast(ln2lo)
+#endif
+
+extern double asinh(x)
+double x;
+{
+ double t,s;
+ const static double small=1.0E-10, /* fl(1+small*small) == 1 */
+ big =1.0E20, /* fl(1+big) == big */
+ one =1.0 ;
+
+#if !defined(vax)&&!defined(tahoe)
+ if(x!=x) return(x); /* x is NaN */
+#endif /* !defined(vax)&&!defined(tahoe) */
+ if((t=copysign(x,one))>small)
+ if(t<big) {
+ s=one/t; return(copysign(log1p(t+t/(s+sqrt(one+s*s))),x)); }
+ else /* if |x| > big */
+ {s=log1p(t)+ln2lo; return(copysign(s+ln2hi,x));}
+ else /* if |x| < small */
+ return(x);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/atanh.c b/usr/src/lib/libast/common/uwin/atanh.c
new file mode 100644
index 0000000000..b5e9a78b94
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/atanh.c
@@ -0,0 +1,89 @@
+#include "FEATURE/uwin"
+
+#if !_UWIN || _lib_atanh
+
+void _STUB_atanh(){}
+
+#else
+
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)atanh.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* ATANH(X)
+ * RETURN THE HYPERBOLIC ARC TANGENT OF X
+ * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS)
+ * CODED IN C BY K.C. NG, 1/8/85;
+ * REVISED BY K.C. NG on 2/7/85, 3/7/85, 8/18/85.
+ *
+ * Required kernel function:
+ * log1p(x) ...return log(1+x)
+ *
+ * Method :
+ * Return
+ * 1 2x x
+ * atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------)
+ * 2 1 - x 1 - x
+ *
+ * Special cases:
+ * atanh(x) is NaN if |x| > 1 with signal;
+ * atanh(NaN) is that NaN with no signal;
+ * atanh(+-1) is +-INF with signal.
+ *
+ * Accuracy:
+ * atanh(x) returns the exact hyperbolic arc tangent of x nearly rounded.
+ * In a test run with 512,000 random arguments on a VAX, the maximum
+ * observed error was 1.87 ulps (units in the last place) at
+ * x= -3.8962076028810414000e-03.
+ */
+#include "mathimpl.h"
+
+#if defined(vax)||defined(tahoe)
+#include <errno.h>
+#endif /* defined(vax)||defined(tahoe) */
+
+extern double atanh(x)
+double x;
+{
+ double z;
+ z = copysign(0.5,x);
+ x = copysign(x,1.0);
+#if defined(vax)||defined(tahoe)
+ if (x == 1.0) {
+ return(copysign(1.0,z)*infnan(ERANGE)); /* sign(x)*INF */
+ }
+#endif /* defined(vax)||defined(tahoe) */
+ x = x/(1.0-x);
+ return( z*log1p(x+x) );
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/cbrt.c b/usr/src/lib/libast/common/uwin/cbrt.c
new file mode 100644
index 0000000000..8c8c32c1b9
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/cbrt.c
@@ -0,0 +1,38 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "FEATURE/uwin"
+
+#if !_UWIN || _lib_cbrt
+
+void _STUB_cbrt(){}
+
+#else
+
+#include "mathimpl.h"
+
+extern double cbrt(double x)
+{
+ return(exp(log(x)/3.0));
+}
+
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/crypt.c b/usr/src/lib/libast/common/uwin/crypt.c
new file mode 100644
index 0000000000..5d9569e053
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/crypt.c
@@ -0,0 +1,959 @@
+#include "FEATURE/uwin"
+
+#if !_UWIN || _lib_crypt
+
+void _STUB_crypt(){}
+
+#else
+
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Tom Truscott.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)crypt.c 8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+
+#define crypt ______crypt
+#define encrypt ______encrypt
+#define setkey ______setkey
+
+/* #include <unistd.h> */
+#include <stdio.h>
+#include <limits.h>
+#include <pwd.h>
+
+#undef crypt
+#undef encrypt
+#undef setkey
+
+#ifndef _PASSWORD_EFMT1
+#define _PASSWORD_EFMT1 '-'
+#endif
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+/*
+ * UNIX password, and DES, encryption.
+ * By Tom Truscott, trt@rti.rti.org,
+ * from algorithms by Robert W. Baldwin and James Gillogly.
+ *
+ * References:
+ * "Mathematical Cryptology for Computer Scientists and Mathematicians,"
+ * by Wayne Patterson, 1987, ISBN 0-8476-7438-X.
+ *
+ * "Password Security: A Case History," R. Morris and Ken Thompson,
+ * Communications of the ACM, vol. 22, pp. 594-597, Nov. 1979.
+ *
+ * "DES will be Totally Insecure within Ten Years," M.E. Hellman,
+ * IEEE Spectrum, vol. 16, pp. 32-39, July 1979.
+ */
+
+/* ===== Configuration ==================== */
+
+/*
+ * define "MUST_ALIGN" if your compiler cannot load/store
+ * long integers at arbitrary (e.g. odd) memory locations.
+ * (Either that or never pass unaligned addresses to des_cipher!)
+ */
+#if !defined(vax)
+#define MUST_ALIGN
+#endif
+
+#ifdef CHAR_BITS
+#if CHAR_BITS != 8
+ #error C_block structure assumes 8 bit characters
+#endif
+#endif
+
+/*
+ * define "LONG_IS_32_BITS" only if sizeof(long)==4.
+ * This avoids use of bit fields (your compiler may be sloppy with them).
+ */
+#if !defined(cray)
+#define LONG_IS_32_BITS
+#endif
+
+/*
+ * define "B64" to be the declaration for a 64 bit integer.
+ * XXX this feature is currently unused, see "endian" comment below.
+ */
+#if defined(cray)
+#define B64 long
+#endif
+#if defined(convex)
+#define B64 long long
+#endif
+
+/*
+ * define "LARGEDATA" to get faster permutations, by using about 72 kilobytes
+ * of lookup tables. This speeds up des_setkey() and des_cipher(), but has
+ * little effect on crypt().
+ */
+#if defined(notdef)
+#define LARGEDATA
+#endif
+
+/* ==================================== */
+
+/*
+ * Cipher-block representation (Bob Baldwin):
+ *
+ * DES operates on groups of 64 bits, numbered 1..64 (sigh). One
+ * representation is to store one bit per byte in an array of bytes. Bit N of
+ * the NBS spec is stored as the LSB of the Nth byte (index N-1) in the array.
+ * Another representation stores the 64 bits in 8 bytes, with bits 1..8 in the
+ * first byte, 9..16 in the second, and so on. The DES spec apparently has
+ * bit 1 in the MSB of the first byte, but that is particularly noxious so we
+ * bit-reverse each byte so that bit 1 is the LSB of the first byte, bit 8 is
+ * the MSB of the first byte. Specifically, the 64-bit input data and key are
+ * converted to LSB format, and the output 64-bit block is converted back into
+ * MSB format.
+ *
+ * DES operates internally on groups of 32 bits which are expanded to 48 bits
+ * by permutation E and shrunk back to 32 bits by the S boxes. To speed up
+ * the computation, the expansion is applied only once, the expanded
+ * representation is maintained during the encryption, and a compression
+ * permutation is applied only at the end. To speed up the S-box lookups,
+ * the 48 bits are maintained as eight 6 bit groups, one per byte, which
+ * directly feed the eight S-boxes. Within each byte, the 6 bits are the
+ * most significant ones. The low two bits of each byte are zero. (Thus,
+ * bit 1 of the 48 bit E expansion is stored as the "4"-valued bit of the
+ * first byte in the eight byte representation, bit 2 of the 48 bit value is
+ * the "8"-valued bit, and so on.) In fact, a combined "SPE"-box lookup is
+ * used, in which the output is the 64 bit result of an S-box lookup which
+ * has been permuted by P and expanded by E, and is ready for use in the next
+ * iteration. Two 32-bit wide tables, SPE[0] and SPE[1], are used for this
+ * lookup. Since each byte in the 48 bit path is a multiple of four, indexed
+ * lookup of SPE[0] and SPE[1] is simple and fast. The key schedule and
+ * "salt" are also converted to this 8*(6+2) format. The SPE table size is
+ * 8*64*8 = 4K bytes.
+ *
+ * To speed up bit-parallel operations (such as XOR), the 8 byte
+ * representation is "union"ed with 32 bit values "i0" and "i1", and, on
+ * machines which support it, a 64 bit value "b64". This data structure,
+ * "C_block", has two problems. First, alignment restrictions must be
+ * honored. Second, the byte-order (e.g. little-endian or big-endian) of
+ * the architecture becomes visible.
+ *
+ * The byte-order problem is unfortunate, since on the one hand it is good
+ * to have a machine-independent C_block representation (bits 1..8 in the
+ * first byte, etc.), and on the other hand it is good for the LSB of the
+ * first byte to be the LSB of i0. We cannot have both these things, so we
+ * currently use the "little-endian" representation and avoid any multi-byte
+ * operations that depend on byte order. This largely precludes use of the
+ * 64-bit datatype since the relative order of i0 and i1 are unknown. It
+ * also inhibits grouping the SPE table to look up 12 bits at a time. (The
+ * 12 bits can be stored in a 16-bit field with 3 low-order zeroes and 1
+ * high-order zero, providing fast indexing into a 64-bit wide SPE.) On the
+ * other hand, 64-bit datatypes are currently rare, and a 12-bit SPE lookup
+ * requires a 128 kilobyte table, so perhaps this is not a big loss.
+ *
+ * Permutation representation (Jim Gillogly):
+ *
+ * A transformation is defined by its effect on each of the 8 bytes of the
+ * 64-bit input. For each byte we give a 64-bit output that has the bits in
+ * the input distributed appropriately. The transformation is then the OR
+ * of the 8 sets of 64-bits. This uses 8*256*8 = 16K bytes of storage for
+ * each transformation. Unless LARGEDATA is defined, however, a more compact
+ * table is used which looks up 16 4-bit "chunks" rather than 8 8-bit chunks.
+ * The smaller table uses 16*16*8 = 2K bytes for each transformation. This
+ * is slower but tolerable, particularly for password encryption in which
+ * the SPE transformation is iterated many times. The small tables total 9K
+ * bytes, the large tables total 72K bytes.
+ *
+ * The transformations used are:
+ * IE3264: MSB->LSB conversion, initial permutation, and expansion.
+ * This is done by collecting the 32 even-numbered bits and applying
+ * a 32->64 bit transformation, and then collecting the 32 odd-numbered
+ * bits and applying the same transformation. Since there are only
+ * 32 input bits, the IE3264 transformation table is half the size of
+ * the usual table.
+ * CF6464: Compression, final permutation, and LSB->MSB conversion.
+ * This is done by two trivial 48->32 bit compressions to obtain
+ * a 64-bit block (the bit numbering is given in the "CIFP" table)
+ * followed by a 64->64 bit "cleanup" transformation. (It would
+ * be possible to group the bits in the 64-bit block so that 2
+ * identical 32->32 bit transformations could be used instead,
+ * saving a factor of 4 in space and possibly 2 in time, but
+ * byte-ordering and other complications rear their ugly head.
+ * Similar opportunities/problems arise in the key schedule
+ * transforms.)
+ * PC1ROT: MSB->LSB, PC1 permutation, rotate, and PC2 permutation.
+ * This admittedly baroque 64->64 bit transformation is used to
+ * produce the first code (in 8*(6+2) format) of the key schedule.
+ * PC2ROT[0]: Inverse PC2 permutation, rotate, and PC2 permutation.
+ * It would be possible to define 15 more transformations, each
+ * with a different rotation, to generate the entire key schedule.
+ * To save space, however, we instead permute each code into the
+ * next by using a transformation that "undoes" the PC2 permutation,
+ * rotates the code, and then applies PC2. Unfortunately, PC2
+ * transforms 56 bits into 48 bits, dropping 8 bits, so PC2 is not
+ * invertible. We get around that problem by using a modified PC2
+ * which retains the 8 otherwise-lost bits in the unused low-order
+ * bits of each byte. The low-order bits are cleared when the
+ * codes are stored into the key schedule.
+ * PC2ROT[1]: Same as PC2ROT[0], but with two rotations.
+ * This is faster than applying PC2ROT[0] twice,
+ *
+ * The Bell Labs "salt" (Bob Baldwin):
+ *
+ * The salting is a simple permutation applied to the 48-bit result of E.
+ * Specifically, if bit i (1 <= i <= 24) of the salt is set then bits i and
+ * i+24 of the result are swapped. The salt is thus a 24 bit number, with
+ * 16777216 possible values. (The original salt was 12 bits and could not
+ * swap bits 13..24 with 36..48.)
+ *
+ * It is possible, but ugly, to warp the SPE table to account for the salt
+ * permutation. Fortunately, the conditional bit swapping requires only
+ * about four machine instructions and can be done on-the-fly with about an
+ * 8% performance penalty.
+ */
+
+typedef union {
+ unsigned char b[8];
+ struct {
+#if defined(LONG_IS_32_BITS)
+ /* long is often faster than a 32-bit bit field */
+ long i0;
+ long i1;
+#else
+ long i0: 32;
+ long i1: 32;
+#endif
+ } b32;
+#if defined(B64)
+ B64 b64;
+#endif
+} C_block;
+
+/*
+ * Convert twenty-four-bit long in host-order
+ * to six bits (and 2 low-order zeroes) per char little-endian format.
+ */
+#define TO_SIX_BIT(rslt, src) { \
+ C_block cvt; \
+ cvt.b[0] = (unsigned char) src; src >>= 6; \
+ cvt.b[1] = (unsigned char) src; src >>= 6; \
+ cvt.b[2] = (unsigned char) src; src >>= 6; \
+ cvt.b[3] = (unsigned char) src; \
+ rslt = (cvt.b32.i0 & 0x3f3f3f3fL) << 2; \
+ }
+
+/*
+ * These macros may someday permit efficient use of 64-bit integers.
+ */
+#define ZERO(d,d0,d1) d0 = 0, d1 = 0
+#define LOAD(d,d0,d1,bl) d0 = (bl).b32.i0, d1 = (bl).b32.i1
+#define LOADREG(d,d0,d1,s,s0,s1) d0 = s0, d1 = s1
+#define OR(d,d0,d1,bl) d0 |= (bl).b32.i0, d1 |= (bl).b32.i1
+#define STORE(s,s0,s1,bl) (bl).b32.i0 = s0, (bl).b32.i1 = s1
+#define DCL_BLOCK(d,d0,d1) long d0, d1
+/* proto(1) workarounds -- barf */
+#define DCL_BLOCK_D DCL_BLOCK(D,D0,D1)
+#define DCL_BLOCK_K DCL_BLOCK(K,K0,K1)
+
+#if defined(LARGEDATA)
+ /* Waste memory like crazy. Also, do permutations in line */
+#define LGCHUNKBITS 3
+#define CHUNKBITS (1<<LGCHUNKBITS)
+#define PERM6464(d,d0,d1,cpp,p) \
+ LOAD(d,d0,d1,(p)[(0<<CHUNKBITS)+(cpp)[0]]); \
+ OR (d,d0,d1,(p)[(1<<CHUNKBITS)+(cpp)[1]]); \
+ OR (d,d0,d1,(p)[(2<<CHUNKBITS)+(cpp)[2]]); \
+ OR (d,d0,d1,(p)[(3<<CHUNKBITS)+(cpp)[3]]); \
+ OR (d,d0,d1,(p)[(4<<CHUNKBITS)+(cpp)[4]]); \
+ OR (d,d0,d1,(p)[(5<<CHUNKBITS)+(cpp)[5]]); \
+ OR (d,d0,d1,(p)[(6<<CHUNKBITS)+(cpp)[6]]); \
+ OR (d,d0,d1,(p)[(7<<CHUNKBITS)+(cpp)[7]]);
+#define PERM3264(d,d0,d1,cpp,p) \
+ LOAD(d,d0,d1,(p)[(0<<CHUNKBITS)+(cpp)[0]]); \
+ OR (d,d0,d1,(p)[(1<<CHUNKBITS)+(cpp)[1]]); \
+ OR (d,d0,d1,(p)[(2<<CHUNKBITS)+(cpp)[2]]); \
+ OR (d,d0,d1,(p)[(3<<CHUNKBITS)+(cpp)[3]]);
+#else
+ /* "small data" */
+#define LGCHUNKBITS 2
+#define CHUNKBITS (1<<LGCHUNKBITS)
+#define PERM6464(d,d0,d1,cpp,p) \
+ { C_block tblk; permute(cpp,&tblk,p,8); LOAD (d,d0,d1,tblk); }
+#define PERM3264(d,d0,d1,cpp,p) \
+ { C_block tblk; permute(cpp,&tblk,p,4); LOAD (d,d0,d1,tblk); }
+
+static void permute(unsigned char *cp, C_block *out, register C_block *p, int chars_in) {
+ register DCL_BLOCK_D;
+ register C_block *tp;
+ register int t;
+
+ ZERO(D,D0,D1);
+ do {
+ t = *cp++;
+ tp = &p[t&0xf]; OR(D,D0,D1,*tp); p += (1<<CHUNKBITS);
+ tp = &p[t>>4]; OR(D,D0,D1,*tp); p += (1<<CHUNKBITS);
+ } while (--chars_in > 0);
+ STORE(D,D0,D1,*out);
+}
+#endif /* LARGEDATA */
+
+
+/* ===== (mostly) Standard DES Tables ==================== */
+
+static unsigned char IP[] = { /* initial permutation */
+ 58, 50, 42, 34, 26, 18, 10, 2,
+ 60, 52, 44, 36, 28, 20, 12, 4,
+ 62, 54, 46, 38, 30, 22, 14, 6,
+ 64, 56, 48, 40, 32, 24, 16, 8,
+ 57, 49, 41, 33, 25, 17, 9, 1,
+ 59, 51, 43, 35, 27, 19, 11, 3,
+ 61, 53, 45, 37, 29, 21, 13, 5,
+ 63, 55, 47, 39, 31, 23, 15, 7,
+};
+
+/* The final permutation is the inverse of IP - no table is necessary */
+
+static unsigned char ExpandTr[] = { /* expansion operation */
+ 32, 1, 2, 3, 4, 5,
+ 4, 5, 6, 7, 8, 9,
+ 8, 9, 10, 11, 12, 13,
+ 12, 13, 14, 15, 16, 17,
+ 16, 17, 18, 19, 20, 21,
+ 20, 21, 22, 23, 24, 25,
+ 24, 25, 26, 27, 28, 29,
+ 28, 29, 30, 31, 32, 1,
+};
+
+static unsigned char PC1[] = { /* permuted choice table 1 */
+ 57, 49, 41, 33, 25, 17, 9,
+ 1, 58, 50, 42, 34, 26, 18,
+ 10, 2, 59, 51, 43, 35, 27,
+ 19, 11, 3, 60, 52, 44, 36,
+
+ 63, 55, 47, 39, 31, 23, 15,
+ 7, 62, 54, 46, 38, 30, 22,
+ 14, 6, 61, 53, 45, 37, 29,
+ 21, 13, 5, 28, 20, 12, 4,
+};
+
+static unsigned char Rotates[] = { /* PC1 rotation schedule */
+ 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1,
+};
+
+/* note: each "row" of PC2 is left-padded with bits that make it invertible */
+static unsigned char PC2[] = { /* permuted choice table 2 */
+ 9, 18, 14, 17, 11, 24, 1, 5,
+ 22, 25, 3, 28, 15, 6, 21, 10,
+ 35, 38, 23, 19, 12, 4, 26, 8,
+ 43, 54, 16, 7, 27, 20, 13, 2,
+
+ 0, 0, 41, 52, 31, 37, 47, 55,
+ 0, 0, 30, 40, 51, 45, 33, 48,
+ 0, 0, 44, 49, 39, 56, 34, 53,
+ 0, 0, 46, 42, 50, 36, 29, 32,
+};
+
+static unsigned char S[8][64] = { /* 48->32 bit substitution tables */
+ /* S[1] */
+ 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
+ 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
+ 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
+ 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13,
+ /* S[2] */
+ 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
+ 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5,
+ 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
+ 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9,
+ /* S[3] */
+ 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
+ 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1,
+ 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
+ 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12,
+ /* S[4] */
+ 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
+ 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9,
+ 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
+ 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14,
+ /* S[5] */
+ 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
+ 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6,
+ 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
+ 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3,
+ /* S[6] */
+ 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
+ 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8,
+ 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
+ 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13,
+ /* S[7] */
+ 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
+ 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6,
+ 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
+ 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12,
+ /* S[8] */
+ 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
+ 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2,
+ 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
+ 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11,
+};
+
+static unsigned char P32Tr[] = { /* 32-bit permutation function */
+ 16, 7, 20, 21,
+ 29, 12, 28, 17,
+ 1, 15, 23, 26,
+ 5, 18, 31, 10,
+ 2, 8, 24, 14,
+ 32, 27, 3, 9,
+ 19, 13, 30, 6,
+ 22, 11, 4, 25,
+};
+
+static unsigned char CIFP[] = { /* compressed/interleaved permutation */
+ 1, 2, 3, 4, 17, 18, 19, 20,
+ 5, 6, 7, 8, 21, 22, 23, 24,
+ 9, 10, 11, 12, 25, 26, 27, 28,
+ 13, 14, 15, 16, 29, 30, 31, 32,
+
+ 33, 34, 35, 36, 49, 50, 51, 52,
+ 37, 38, 39, 40, 53, 54, 55, 56,
+ 41, 42, 43, 44, 57, 58, 59, 60,
+ 45, 46, 47, 48, 61, 62, 63, 64,
+};
+
+static unsigned char itoa64[] = /* 0..63 => ascii-64 */
+ "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+
+/* ===== Tables that are initialized at run time ==================== */
+
+
+static unsigned char a64toi[128]; /* ascii-64 => 0..63 */
+
+/* Initial key schedule permutation */
+static C_block PC1ROT[64/CHUNKBITS][1<<CHUNKBITS];
+
+/* Subsequent key schedule rotation permutations */
+static C_block PC2ROT[2][64/CHUNKBITS][1<<CHUNKBITS];
+
+/* Initial permutation/expansion table */
+static C_block IE3264[32/CHUNKBITS][1<<CHUNKBITS];
+
+/* Table that combines the S, P, and E operations. */
+static long SPE[2][8][64];
+
+/* compressed/interleaved => final permutation table */
+static C_block CF6464[64/CHUNKBITS][1<<CHUNKBITS];
+
+
+/* ==================================== */
+
+static C_block constdatablock; /* encryption constant */
+static char cryptresult[1+4+4+11+1]; /* encrypted result */
+
+/*
+ * Initialize "perm" to represent transformation "p", which rearranges
+ * (perhaps with expansion and/or contraction) one packed array of bits
+ * (of size "chars_in" characters) into another array (of size "chars_out"
+ * characters).
+ *
+ * "perm" must be all-zeroes on entry to this routine.
+ */
+static void init_perm(C_block perm[64/CHUNKBITS][1<<CHUNKBITS],
+ unsigned char p[64], int chars_in, int chars_out) {
+ register int i, j, k, l;
+
+ for (k = 0; k < chars_out*8; k++) { /* each output bit position */
+ l = p[k] - 1; /* where this bit comes from */
+ if (l < 0)
+ continue; /* output bit is always 0 */
+ i = l>>LGCHUNKBITS; /* which chunk this bit comes from */
+ l = 1<<(l&(CHUNKBITS-1)); /* mask for this bit */
+ for (j = 0; j < (1<<CHUNKBITS); j++) { /* each chunk value */
+ if ((j & l) != 0)
+ perm[i][j].b[k>>3] |= 1<<(k&07);
+ }
+ }
+}
+
+/*
+ * Initialize various tables. This need only be done once. It could even be
+ * done at compile time, if the compiler were capable of that sort of thing.
+ */
+static void init_des(void) {
+ register int i, j;
+ register long k;
+ register int tableno;
+ static unsigned char perm[64], tmp32[32]; /* "static" for speed */
+
+ /*
+ * table that converts chars "./0-9A-Za-z"to integers 0-63.
+ */
+ for (i = 0; i < 64; i++)
+ a64toi[itoa64[i]] = i;
+
+ /*
+ * PC1ROT - bit reverse, then PC1, then Rotate, then PC2.
+ */
+ for (i = 0; i < 64; i++)
+ perm[i] = 0;
+ for (i = 0; i < 64; i++) {
+ if ((k = PC2[i]) == 0)
+ continue;
+ k += Rotates[0]-1;
+ if ((k%28) < Rotates[0]) k -= 28;
+ k = PC1[k];
+ if (k > 0) {
+ k--;
+ k = (k|07) - (k&07);
+ k++;
+ }
+ perm[i] = (unsigned char) k;
+ }
+#ifdef DEBUG
+ prtab("pc1tab", perm, 8);
+#endif
+ init_perm(PC1ROT, perm, 8, 8);
+
+ /*
+ * PC2ROT - PC2 inverse, then Rotate (once or twice), then PC2.
+ */
+ for (j = 0; j < 2; j++) {
+ unsigned char pc2inv[64];
+ for (i = 0; i < 64; i++)
+ perm[i] = pc2inv[i] = 0;
+ for (i = 0; i < 64; i++) {
+ if ((k = PC2[i]) == 0)
+ continue;
+ pc2inv[k-1] = i+1;
+ }
+ for (i = 0; i < 64; i++) {
+ if ((k = PC2[i]) == 0)
+ continue;
+ k += j;
+ if ((k%28) <= j) k -= 28;
+ perm[i] = pc2inv[k];
+ }
+#ifdef DEBUG
+ prtab("pc2tab", perm, 8);
+#endif
+ init_perm(PC2ROT[j], perm, 8, 8);
+ }
+
+ /*
+ * Bit reverse, then initial permutation, then expansion.
+ */
+ for (i = 0; i < 8; i++) {
+ for (j = 0; j < 8; j++) {
+ k = (j < 2)? 0: IP[ExpandTr[i*6+j-2]-1];
+ if (k > 32)
+ k -= 32;
+ else if (k > 0)
+ k--;
+ if (k > 0) {
+ k--;
+ k = (k|07) - (k&07);
+ k++;
+ }
+ perm[i*8+j] = (unsigned char) k;
+ }
+ }
+#ifdef DEBUG
+ prtab("ietab", perm, 8);
+#endif
+ init_perm(IE3264, perm, 4, 8);
+
+ /*
+ * Compression, then final permutation, then bit reverse.
+ */
+ for (i = 0; i < 64; i++) {
+ k = IP[CIFP[i]-1];
+ if (k > 0) {
+ k--;
+ k = (k|07) - (k&07);
+ k++;
+ }
+ perm[k-1] = i+1;
+ }
+#ifdef DEBUG
+ prtab("cftab", perm, 8);
+#endif
+ init_perm(CF6464, perm, 8, 8);
+
+ /*
+ * SPE table
+ */
+ for (i = 0; i < 48; i++)
+ perm[i] = P32Tr[ExpandTr[i]-1];
+ for (tableno = 0; tableno < 8; tableno++) {
+ for (j = 0; j < 64; j++) {
+ k = (((j >> 0) &01) << 5)|
+ (((j >> 1) &01) << 3)|
+ (((j >> 2) &01) << 2)|
+ (((j >> 3) &01) << 1)|
+ (((j >> 4) &01) << 0)|
+ (((j >> 5) &01) << 4);
+ k = S[tableno][k];
+ k = (((k >> 3)&01) << 0)|
+ (((k >> 2)&01) << 1)|
+ (((k >> 1)&01) << 2)|
+ (((k >> 0)&01) << 3);
+ for (i = 0; i < 32; i++)
+ tmp32[i] = 0;
+ for (i = 0; i < 4; i++)
+ tmp32[4 * tableno + i] = (k >> i) & 01;
+ k = 0;
+ for (i = 24; --i >= 0; )
+ k = (k<<1) | tmp32[perm[i]-1];
+ TO_SIX_BIT(SPE[0][tableno][j], k);
+ k = 0;
+ for (i = 24; --i >= 0; )
+ k = (k<<1) | tmp32[perm[i+24]-1];
+ TO_SIX_BIT(SPE[1][tableno][j], k);
+ }
+ }
+}
+
+/*
+ * The Key Schedule, filled in by des_setkey() or setkey().
+ */
+#define KS_SIZE 16
+static C_block KS[KS_SIZE];
+
+/*
+ * Set up the key schedule from the key.
+ */
+static int des_setkey(register const char *key) {
+ register DCL_BLOCK_K;
+ register C_block *ptabp;
+ register int i;
+ static int des_ready = 0;
+
+ if (!des_ready) {
+ init_des();
+ des_ready = 1;
+ }
+
+ PERM6464(K,K0,K1,(unsigned char *)key,(C_block *)PC1ROT);
+ key = (char *)&KS[0];
+ STORE(K&~0x03030303L, K0&~0x03030303L, K1, *(C_block *)key);
+ for (i = 1; i < 16; i++) {
+ key += sizeof(C_block);
+ STORE(K,K0,K1,*(C_block *)key);
+ ptabp = (C_block *)PC2ROT[Rotates[i]-1];
+ PERM6464(K,K0,K1,(unsigned char *)key,ptabp);
+ STORE(K&~0x03030303L, K0&~0x03030303L, K1, *(C_block *)key);
+ }
+ return (0);
+}
+
+/*
+ * Encrypt (or decrypt if num_iter < 0) the 8 chars at "in" with abs(num_iter)
+ * iterations of DES, using the the given 24-bit salt and the pre-computed key
+ * schedule, and store the resulting 8 chars at "out" (in == out is permitted).
+ *
+ * NOTE: the performance of this routine is critically dependent on your
+ * compiler and machine architecture.
+ */
+static int des_cipher(const char *in, char *out, long salt, int num_iter) {
+ /* variables that we want in registers, most important first */
+#if defined(pdp11)
+ register int j;
+#endif
+ register long L0, L1, R0, R1, k;
+ register C_block *kp;
+ register int ks_inc, loop_count;
+ C_block B;
+
+ L0 = salt;
+ TO_SIX_BIT(salt, L0); /* convert to 4*(6+2) format */
+
+#if defined(vax) || defined(pdp11)
+ salt = ~salt; /* "x &~ y" is faster than "x & y". */
+#define SALT (~salt)
+#else
+#define SALT salt
+#endif
+
+#if defined(MUST_ALIGN)
+ B.b[0] = in[0]; B.b[1] = in[1]; B.b[2] = in[2]; B.b[3] = in[3];
+ B.b[4] = in[4]; B.b[5] = in[5]; B.b[6] = in[6]; B.b[7] = in[7];
+ LOAD(L,L0,L1,B);
+#else
+ LOAD(L,L0,L1,*(C_block *)in);
+#endif
+ LOADREG(R,R0,R1,L,L0,L1);
+ L0 &= 0x55555555L;
+ L1 &= 0x55555555L;
+ L0 = (L0 << 1) | L1; /* L0 is the even-numbered input bits */
+ R0 &= 0xaaaaaaaaL;
+ R1 = (R1 >> 1) & 0x55555555L;
+ L1 = R0 | R1; /* L1 is the odd-numbered input bits */
+ STORE(L,L0,L1,B);
+ PERM3264(L,L0,L1,B.b, (C_block *)IE3264); /* even bits */
+ PERM3264(R,R0,R1,B.b+4,(C_block *)IE3264); /* odd bits */
+
+ if (num_iter >= 0)
+ { /* encryption */
+ kp = &KS[0];
+ ks_inc = sizeof(*kp);
+ }
+ else
+ { /* decryption */
+ num_iter = -num_iter;
+ kp = &KS[KS_SIZE-1];
+ ks_inc = -((int) sizeof(*kp));
+ }
+
+ while (--num_iter >= 0) {
+ loop_count = 8;
+ do {
+
+#define SPTAB(t, i) (*(long *)((unsigned char *)t + i*(sizeof(long)/4)))
+#if defined(gould)
+ /* use this if B.b[i] is evaluated just once ... */
+#define DOXOR(x,y,i) x^=SPTAB(SPE[0][i],B.b[i]); y^=SPTAB(SPE[1][i],B.b[i]);
+#else
+#if defined(pdp11)
+ /* use this if your "long" int indexing is slow */
+#define DOXOR(x,y,i) j=B.b[i]; x^=SPTAB(SPE[0][i],j); y^=SPTAB(SPE[1][i],j);
+#else
+ /* use this if "k" is allocated to a register ... */
+#define DOXOR(x,y,i) k=B.b[i]; x^=SPTAB(SPE[0][i],k); y^=SPTAB(SPE[1][i],k);
+#endif
+#endif
+
+#define CRUNCH(p0, p1, q0, q1) \
+ k = (q0 ^ q1) & SALT; \
+ B.b32.i0 = k ^ q0 ^ kp->b32.i0; \
+ B.b32.i1 = k ^ q1 ^ kp->b32.i1; \
+ kp = (C_block *)((char *)kp+ks_inc); \
+ \
+ DOXOR(p0, p1, 0); \
+ DOXOR(p0, p1, 1); \
+ DOXOR(p0, p1, 2); \
+ DOXOR(p0, p1, 3); \
+ DOXOR(p0, p1, 4); \
+ DOXOR(p0, p1, 5); \
+ DOXOR(p0, p1, 6); \
+ DOXOR(p0, p1, 7);
+
+ CRUNCH(L0, L1, R0, R1);
+ CRUNCH(R0, R1, L0, L1);
+ } while (--loop_count != 0);
+ kp = (C_block *)((char *)kp-(ks_inc*KS_SIZE));
+
+
+ /* swap L and R */
+ L0 ^= R0; L1 ^= R1;
+ R0 ^= L0; R1 ^= L1;
+ L0 ^= R0; L1 ^= R1;
+ }
+
+ /* store the encrypted (or decrypted) result */
+ L0 = ((L0 >> 3) & 0x0f0f0f0fL) | ((L1 << 1) & 0xf0f0f0f0L);
+ L1 = ((R0 >> 3) & 0x0f0f0f0fL) | ((R1 << 1) & 0xf0f0f0f0L);
+ STORE(L,L0,L1,B);
+ PERM6464(L,L0,L1,B.b, (C_block *)CF6464);
+#if defined(MUST_ALIGN)
+ STORE(L,L0,L1,B);
+ out[0] = B.b[0]; out[1] = B.b[1]; out[2] = B.b[2]; out[3] = B.b[3];
+ out[4] = B.b[4]; out[5] = B.b[5]; out[6] = B.b[6]; out[7] = B.b[7];
+#else
+ STORE(L,L0,L1,*(C_block *)out);
+#endif
+ return (0);
+}
+
+/*
+ * "setkey" routine (for backwards compatibility)
+ */
+extern int setkey(register const char *key) {
+ register int i, j, k;
+ C_block keyblock;
+
+ for (i = 0; i < 8; i++) {
+ k = 0;
+ for (j = 0; j < 8; j++) {
+ k <<= 1;
+ k |= (unsigned char)*key++;
+ }
+ keyblock.b[i] = k;
+ }
+ return (des_setkey((char *)keyblock.b));
+}
+
+/*
+ * "encrypt" routine (for backwards compatibility)
+ */
+extern int encrypt(register char *block, int flag) {
+ register int i, j, k;
+ C_block cblock;
+
+ for (i = 0; i < 8; i++) {
+ k = 0;
+ for (j = 0; j < 8; j++) {
+ k <<= 1;
+ k |= (unsigned char)*block++;
+ }
+ cblock.b[i] = k;
+ }
+ if (des_cipher((char *)&cblock, (char *)&cblock, 0L, (flag ? -1: 1)))
+ return (1);
+ for (i = 7; i >= 0; i--) {
+ k = cblock.b[i];
+ for (j = 7; j >= 0; j--) {
+ *--block = k&01;
+ k >>= 1;
+ }
+ }
+ return (0);
+}
+
+/*
+ * Return a pointer to static data consisting of the "setting"
+ * followed by an encryption produced by the "key" and "setting".
+ */
+extern char * crypt(register const char *key, register const char *setting) {
+ register char *encp;
+ register long i;
+ register int t;
+ long salt;
+ int num_iter, salt_size;
+ C_block keyblock, rsltblock;
+
+#ifdef HL_NOENCRYPTION
+ char buff[1024];
+ strncpy(buff, key, 1024);
+ buff[1023] = 0;
+ return buff;
+#endif
+
+ for (i = 0; i < 8; i++) {
+ if ((t = 2*(unsigned char)(*key)) != 0)
+ key++;
+ keyblock.b[i] = t;
+ }
+ if (des_setkey((char *)keyblock.b)) /* also initializes "a64toi" */
+ return (NULL);
+
+ encp = &cryptresult[0];
+ switch (*setting) {
+ case _PASSWORD_EFMT1:
+ /*
+ * Involve the rest of the password 8 characters at a time.
+ */
+ while (*key) {
+ if (des_cipher((char *)&keyblock,
+ (char *)&keyblock, 0L, 1))
+ return (NULL);
+ for (i = 0; i < 8; i++) {
+ if ((t = 2*(unsigned char)(*key)) != 0)
+ key++;
+ keyblock.b[i] ^= t;
+ }
+ if (des_setkey((char *)keyblock.b))
+ return (NULL);
+ }
+
+ *encp++ = *setting++;
+
+ /* get iteration count */
+ num_iter = 0;
+ for (i = 4; --i >= 0; ) {
+ if ((t = (unsigned char)setting[i]) == '\0')
+ t = '.';
+ encp[i] = t;
+ num_iter = (num_iter<<6) | a64toi[t];
+ }
+ setting += 4;
+ encp += 4;
+ salt_size = 4;
+ break;
+ default:
+ num_iter = 25;
+ salt_size = 2;
+ }
+
+ salt = 0;
+ for (i = salt_size; --i >= 0; ) {
+ if ((t = (unsigned char)setting[i]) == '\0')
+ t = '.';
+ encp[i] = t;
+ salt = (salt<<6) | a64toi[t];
+ }
+ encp += salt_size;
+ if (des_cipher((char *)&constdatablock, (char *)&rsltblock,
+ salt, num_iter))
+ return (NULL);
+
+ /*
+ * Encode the 64 cipher bits as 11 ascii characters.
+ */
+ i = ((long)((rsltblock.b[0]<<8) | rsltblock.b[1])<<8) | rsltblock.b[2];
+ encp[3] = itoa64[i&0x3f]; i >>= 6;
+ encp[2] = itoa64[i&0x3f]; i >>= 6;
+ encp[1] = itoa64[i&0x3f]; i >>= 6;
+ encp[0] = itoa64[i]; encp += 4;
+ i = ((long)((rsltblock.b[3]<<8) | rsltblock.b[4])<<8) | rsltblock.b[5];
+ encp[3] = itoa64[i&0x3f]; i >>= 6;
+ encp[2] = itoa64[i&0x3f]; i >>= 6;
+ encp[1] = itoa64[i&0x3f]; i >>= 6;
+ encp[0] = itoa64[i]; encp += 4;
+ i = ((long)((rsltblock.b[6])<<8) | rsltblock.b[7])<<2;
+ encp[2] = itoa64[i&0x3f]; i >>= 6;
+ encp[1] = itoa64[i&0x3f]; i >>= 6;
+ encp[0] = itoa64[i];
+
+ encp[3] = 0;
+
+ return (cryptresult);
+}
+
+#ifdef DEBUG
+STATIC
+prtab(s, t, num_rows)
+ char *s;
+ unsigned char *t;
+ int num_rows;
+{
+ register int i, j;
+
+ (void)printf("%s:\n", s);
+ for (i = 0; i < num_rows; i++) {
+ for (j = 0; j < 8; j++) {
+ (void)printf("%3d", t[i*8+j]);
+ }
+ (void)printf("\n");
+ }
+ (void)printf("\n");
+}
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/erf.c b/usr/src/lib/libast/common/uwin/erf.c
new file mode 100644
index 0000000000..4a61f78658
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/erf.c
@@ -0,0 +1,403 @@
+#include "FEATURE/uwin"
+
+#if !_UWIN || _lib_erf
+
+void _STUB_erf(){}
+
+#else
+
+/*-
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)erf.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* Modified Nov 30, 1992 P. McILROY:
+ * Replaced expansions for x >= 1.25 (error 1.7ulp vs ~6ulp)
+ * Replaced even+odd with direct calculation for x < .84375,
+ * to avoid destructive cancellation.
+ *
+ * Performance of erfc(x):
+ * In 300000 trials in the range [.83, .84375] the
+ * maximum observed error was 3.6ulp.
+ *
+ * In [.84735,1.25] the maximum observed error was <2.5ulp in
+ * 100000 runs in the range [1.2, 1.25].
+ *
+ * In [1.25,26] (Not including subnormal results)
+ * the error is < 1.7ulp.
+ */
+
+/* double erf(double x)
+ * double erfc(double x)
+ * x
+ * 2 |\
+ * erf(x) = --------- | exp(-t*t)dt
+ * sqrt(pi) \|
+ * 0
+ *
+ * erfc(x) = 1-erf(x)
+ *
+ * Method:
+ * 1. Reduce x to |x| by erf(-x) = -erf(x)
+ * 2. For x in [0, 0.84375]
+ * erf(x) = x + x*P(x^2)
+ * erfc(x) = 1 - erf(x) if x<=0.25
+ * = 0.5 + ((0.5-x)-x*P) if x in [0.25,0.84375]
+ * where
+ * 2 2 4 20
+ * P = P(x ) = (p0 + p1 * x + p2 * x + ... + p10 * x )
+ * is an approximation to (erf(x)-x)/x with precision
+ *
+ * -56.45
+ * | P - (erf(x)-x)/x | <= 2
+ *
+ *
+ * Remark. The formula is derived by noting
+ * erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....)
+ * and that
+ * 2/sqrt(pi) = 1.128379167095512573896158903121545171688
+ * is close to one. The interval is chosen because the fixed
+ * point of erf(x) is near 0.6174 (i.e., erf(x)=x when x is
+ * near 0.6174), and by some experiment, 0.84375 is chosen to
+ * guarantee the error is less than one ulp for erf.
+ *
+ * 3. For x in [0.84375,1.25], let s = x - 1, and
+ * c = 0.84506291151 rounded to single (24 bits)
+ * erf(x) = c + P1(s)/Q1(s)
+ * erfc(x) = (1-c) - P1(s)/Q1(s)
+ * |P1/Q1 - (erf(x)-c)| <= 2**-59.06
+ * Remark: here we use the taylor series expansion at x=1.
+ * erf(1+s) = erf(1) + s*Poly(s)
+ * = 0.845.. + P1(s)/Q1(s)
+ * That is, we use rational approximation to approximate
+ * erf(1+s) - (c = (single)0.84506291151)
+ * Note that |P1/Q1|< 0.078 for x in [0.84375,1.25]
+ * where
+ * P1(s) = degree 6 poly in s
+ * Q1(s) = degree 6 poly in s
+ *
+ * 4. For x in [1.25, 2]; [2, 4]
+ * erf(x) = 1.0 - tiny
+ * erfc(x) = (1/x)exp(-x*x-(.5*log(pi) -.5z + R(z)/S(z))
+ *
+ * Where z = 1/(x*x), R is degree 9, and S is degree 3;
+ *
+ * 5. For x in [4,28]
+ * erf(x) = 1.0 - tiny
+ * erfc(x) = (1/x)exp(-x*x-(.5*log(pi)+eps + zP(z))
+ *
+ * Where P is degree 14 polynomial in 1/(x*x).
+ *
+ * Notes:
+ * Here 4 and 5 make use of the asymptotic series
+ * exp(-x*x)
+ * erfc(x) ~ ---------- * ( 1 + Poly(1/x^2) );
+ * x*sqrt(pi)
+ *
+ * where for z = 1/(x*x)
+ * P(z) ~ z/2*(-1 + z*3/2*(1 + z*5/2*(-1 + z*7/2*(1 +...))))
+ *
+ * Thus we use rational approximation to approximate
+ * erfc*x*exp(x*x) ~ 1/sqrt(pi);
+ *
+ * The error bound for the target function, G(z) for
+ * the interval
+ * [4, 28]:
+ * |eps + 1/(z)P(z) - G(z)| < 2**(-56.61)
+ * for [2, 4]:
+ * |R(z)/S(z) - G(z)| < 2**(-58.24)
+ * for [1.25, 2]:
+ * |R(z)/S(z) - G(z)| < 2**(-58.12)
+ *
+ * 6. For inf > x >= 28
+ * erf(x) = 1 - tiny (raise inexact)
+ * erfc(x) = tiny*tiny (raise underflow)
+ *
+ * 7. Special cases:
+ * erf(0) = 0, erf(inf) = 1, erf(-inf) = -1,
+ * erfc(0) = 1, erfc(inf) = 0, erfc(-inf) = 2,
+ * erfc/erf(NaN) is NaN
+ */
+
+#if defined(vax) || defined(tahoe)
+#define _IEEE 0
+#define TRUNC(x) (double) (float) (x)
+#else
+#define _IEEE 1
+#define TRUNC(x) *(((int *) &x) + 1) &= 0xf8000000
+#define infnan(x) 0.0
+#endif
+
+#ifdef _IEEE_LIBM
+/*
+ * redefining "___function" to "function" in _IEEE_LIBM mode
+ */
+#include "ieee_libm.h"
+#endif
+#include "mathimpl.h"
+
+static double
+tiny = 1e-300,
+half = 0.5,
+one = 1.0,
+two = 2.0,
+c = 8.45062911510467529297e-01, /* (float)0.84506291151 */
+/*
+ * Coefficients for approximation to erf in [0,0.84375]
+ */
+p0t8 = 1.02703333676410051049867154944018394163280,
+p0 = 1.283791670955125638123339436800229927041e-0001,
+p1 = -3.761263890318340796574473028946097022260e-0001,
+p2 = 1.128379167093567004871858633779992337238e-0001,
+p3 = -2.686617064084433642889526516177508374437e-0002,
+p4 = 5.223977576966219409445780927846432273191e-0003,
+p5 = -8.548323822001639515038738961618255438422e-0004,
+p6 = 1.205520092530505090384383082516403772317e-0004,
+p7 = -1.492214100762529635365672665955239554276e-0005,
+p8 = 1.640186161764254363152286358441771740838e-0006,
+p9 = -1.571599331700515057841960987689515895479e-0007,
+p10= 1.073087585213621540635426191486561494058e-0008;
+/*
+ * Coefficients for approximation to erf in [0.84375,1.25]
+ */
+static double
+pa0 = -2.362118560752659485957248365514511540287e-0003,
+pa1 = 4.148561186837483359654781492060070469522e-0001,
+pa2 = -3.722078760357013107593507594535478633044e-0001,
+pa3 = 3.183466199011617316853636418691420262160e-0001,
+pa4 = -1.108946942823966771253985510891237782544e-0001,
+pa5 = 3.547830432561823343969797140537411825179e-0002,
+pa6 = -2.166375594868790886906539848893221184820e-0003,
+qa1 = 1.064208804008442270765369280952419863524e-0001,
+qa2 = 5.403979177021710663441167681878575087235e-0001,
+qa3 = 7.182865441419627066207655332170665812023e-0002,
+qa4 = 1.261712198087616469108438860983447773726e-0001,
+qa5 = 1.363708391202905087876983523620537833157e-0002,
+qa6 = 1.198449984679910764099772682882189711364e-0002;
+/*
+ * log(sqrt(pi)) for large x expansions.
+ * The tail (lsqrtPI_lo) is included in the rational
+ * approximations.
+*/
+static double
+ lsqrtPI_hi = .5723649429247000819387380943226;
+/*
+ * lsqrtPI_lo = .000000000000000005132975581353913;
+ *
+ * Coefficients for approximation to erfc in [2, 4]
+*/
+static double
+rb0 = -1.5306508387410807582e-010, /* includes lsqrtPI_lo */
+rb1 = 2.15592846101742183841910806188e-008,
+rb2 = 6.24998557732436510470108714799e-001,
+rb3 = 8.24849222231141787631258921465e+000,
+rb4 = 2.63974967372233173534823436057e+001,
+rb5 = 9.86383092541570505318304640241e+000,
+rb6 = -7.28024154841991322228977878694e+000,
+rb7 = 5.96303287280680116566600190708e+000,
+rb8 = -4.40070358507372993983608466806e+000,
+rb9 = 2.39923700182518073731330332521e+000,
+rb10 = -6.89257464785841156285073338950e-001,
+sb1 = 1.56641558965626774835300238919e+001,
+sb2 = 7.20522741000949622502957936376e+001,
+sb3 = 9.60121069770492994166488642804e+001;
+/*
+ * Coefficients for approximation to erfc in [1.25, 2]
+*/
+static double
+rc0 = -2.47925334685189288817e-007, /* includes lsqrtPI_lo */
+rc1 = 1.28735722546372485255126993930e-005,
+rc2 = 6.24664954087883916855616917019e-001,
+rc3 = 4.69798884785807402408863708843e+000,
+rc4 = 7.61618295853929705430118701770e+000,
+rc5 = 9.15640208659364240872946538730e-001,
+rc6 = -3.59753040425048631334448145935e-001,
+rc7 = 1.42862267989304403403849619281e-001,
+rc8 = -4.74392758811439801958087514322e-002,
+rc9 = 1.09964787987580810135757047874e-002,
+rc10 = -1.28856240494889325194638463046e-003,
+sc1 = 9.97395106984001955652274773456e+000,
+sc2 = 2.80952153365721279953959310660e+001,
+sc3 = 2.19826478142545234106819407316e+001;
+/*
+ * Coefficients for approximation to erfc in [4,28]
+ */
+static double
+rd0 = -2.1491361969012978677e-016, /* includes lsqrtPI_lo */
+rd1 = -4.99999999999640086151350330820e-001,
+rd2 = 6.24999999772906433825880867516e-001,
+rd3 = -1.54166659428052432723177389562e+000,
+rd4 = 5.51561147405411844601985649206e+000,
+rd5 = -2.55046307982949826964613748714e+001,
+rd6 = 1.43631424382843846387913799845e+002,
+rd7 = -9.45789244999420134263345971704e+002,
+rd8 = 6.94834146607051206956384703517e+003,
+rd9 = -5.27176414235983393155038356781e+004,
+rd10 = 3.68530281128672766499221324921e+005,
+rd11 = -2.06466642800404317677021026611e+006,
+rd12 = 7.78293889471135381609201431274e+006,
+rd13 = -1.42821001129434127360582351685e+007;
+
+extern double erf(x)
+ double x;
+{
+ double R,S,P,Q,ax,s,y,z,r,fabs(),exp();
+ if(!finite(x)) { /* erf(nan)=nan */
+ if (isnan(x))
+ return(x);
+ return (x > 0 ? one : -one); /* erf(+/-inf)= +/-1 */
+ }
+ if ((ax = x) < 0)
+ ax = - ax;
+ if (ax < .84375) {
+ if (ax < 3.7e-09) {
+ if (ax < 1.0e-308)
+ return 0.125*(8.0*x+p0t8*x); /*avoid underflow */
+ return x + p0*x;
+ }
+ y = x*x;
+ r = y*(p1+y*(p2+y*(p3+y*(p4+y*(p5+
+ y*(p6+y*(p7+y*(p8+y*(p9+y*p10)))))))));
+ return x + x*(p0+r);
+ }
+ if (ax < 1.25) { /* 0.84375 <= |x| < 1.25 */
+ s = fabs(x)-one;
+ P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
+ Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
+ if (x>=0)
+ return (c + P/Q);
+ else
+ return (-c - P/Q);
+ }
+ if (ax >= 6.0) { /* inf>|x|>=6 */
+ if (x >= 0.0)
+ return (one-tiny);
+ else
+ return (tiny-one);
+ }
+ /* 1.25 <= |x| < 6 */
+ z = -ax*ax;
+ s = -one/z;
+ if (ax < 2.0) {
+ R = rc0+s*(rc1+s*(rc2+s*(rc3+s*(rc4+s*(rc5+
+ s*(rc6+s*(rc7+s*(rc8+s*(rc9+s*rc10)))))))));
+ S = one+s*(sc1+s*(sc2+s*sc3));
+ } else {
+ R = rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(rb5+
+ s*(rb6+s*(rb7+s*(rb8+s*(rb9+s*rb10)))))))));
+ S = one+s*(sb1+s*(sb2+s*sb3));
+ }
+ y = (R/S -.5*s) - lsqrtPI_hi;
+ z += y;
+ z = exp(z)/ax;
+ if (x >= 0)
+ return (one-z);
+ else
+ return (z-one);
+}
+
+extern double erfc(x)
+ double x;
+{
+ double R,S,P,Q,s,ax,y,z,r,fabs(),__exp__D();
+ if (!finite(x)) {
+ if (isnan(x)) /* erfc(NaN) = NaN */
+ return(x);
+ else if (x > 0) /* erfc(+-inf)=0,2 */
+ return 0.0;
+ else
+ return 2.0;
+ }
+ if ((ax = x) < 0)
+ ax = -ax;
+ if (ax < .84375) { /* |x|<0.84375 */
+ if (ax < 1.38777878078144568e-17) /* |x|<2**-56 */
+ return one-x;
+ y = x*x;
+ r = y*(p1+y*(p2+y*(p3+y*(p4+y*(p5+
+ y*(p6+y*(p7+y*(p8+y*(p9+y*p10)))))))));
+ if (ax < .0625) { /* |x|<2**-4 */
+ return (one-(x+x*(p0+r)));
+ } else {
+ r = x*(p0+r);
+ r += (x-half);
+ return (half - r);
+ }
+ }
+ if (ax < 1.25) { /* 0.84375 <= |x| < 1.25 */
+ s = ax-one;
+ P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
+ Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
+ if (x>=0) {
+ z = one-c; return z - P/Q;
+ } else {
+ z = c+P/Q; return one+z;
+ }
+ }
+ if (ax >= 28) /* Out of range */
+ if (x>0)
+ return (tiny*tiny);
+ else
+ return (two-tiny);
+ z = ax;
+ TRUNC(z);
+ y = z - ax; y *= (ax+z);
+ z *= -z; /* Here z + y = -x^2 */
+ s = one/(-z-y); /* 1/(x*x) */
+ if (ax >= 4) { /* 6 <= ax */
+ R = s*(rd1+s*(rd2+s*(rd3+s*(rd4+s*(rd5+
+ s*(rd6+s*(rd7+s*(rd8+s*(rd9+s*(rd10
+ +s*(rd11+s*(rd12+s*rd13))))))))))));
+ y += rd0;
+ } else if (ax >= 2) {
+ R = rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(rb5+
+ s*(rb6+s*(rb7+s*(rb8+s*(rb9+s*rb10)))))))));
+ S = one+s*(sb1+s*(sb2+s*sb3));
+ y += R/S;
+ R = -.5*s;
+ } else {
+ R = rc0+s*(rc1+s*(rc2+s*(rc3+s*(rc4+s*(rc5+
+ s*(rc6+s*(rc7+s*(rc8+s*(rc9+s*rc10)))))))));
+ S = one+s*(sc1+s*(sc2+s*sc3));
+ y += R/S;
+ R = -.5*s;
+ }
+ /* return exp(-x^2 - lsqrtPI_hi + R + y)/x; */
+ s = ((R + y) - lsqrtPI_hi) + z;
+ y = (((z-s) - lsqrtPI_hi) + R) + y;
+ r = __exp__D(s, y)/x;
+ if (x>0)
+ return r;
+ else
+ return two-r;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/err.c b/usr/src/lib/libast/common/uwin/err.c
new file mode 100644
index 0000000000..f84599a2dd
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/err.c
@@ -0,0 +1,124 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "FEATURE/uwin"
+
+#if !_UWIN
+
+void _STUB_err(){}
+
+#else
+
+#pragma prototyped
+
+/*
+ * bsd 4.4 compatibility
+ *
+ * NOTE: errorv(ERROR_NOID) => the first arg is the printf format
+ */
+
+#include <ast.h>
+#include <error.h>
+
+#include <windows.h>
+
+#ifdef __EXPORT__
+#define extern __EXPORT__
+#endif
+
+static void
+errmsg(int level, int code, const char* fmt, va_list ap)
+{
+ if (!error_info.id)
+ {
+ struct _astdll* dp = _ast_getdll();
+ char* s;
+ char* t;
+
+ if (s = dp->_ast__argv[0])
+ {
+ if (t = strrchr(s, '/'))
+ s = t + 1;
+ error_info.id = s;
+ }
+ }
+ errorv(fmt, level|ERROR_NOID, ap);
+ if ((level & ERROR_LEVEL) >= ERROR_ERROR)
+ exit(code);
+}
+
+extern void verr(int code, const char* fmt, va_list ap)
+{
+ errmsg(ERROR_ERROR|ERROR_SYSTEM, code, fmt, ap);
+}
+
+extern void err(int code, const char* fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ errmsg(ERROR_ERROR|ERROR_SYSTEM, code, fmt, ap);
+ va_end(ap);
+}
+
+extern void verrx(int code, const char* fmt, va_list ap)
+{
+ errmsg(ERROR_ERROR, code, fmt, ap);
+}
+
+extern void errx(int code, const char* fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ errmsg(ERROR_ERROR, code, fmt, ap);
+ va_end(ap);
+}
+
+extern void vwarn(const char* fmt, va_list ap)
+{
+ errmsg(ERROR_WARNING|ERROR_SYSTEM, 0, fmt, ap);
+}
+
+extern void warn(const char* fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ errmsg(ERROR_WARNING|ERROR_SYSTEM, 0, fmt, ap);
+ va_end(ap);
+}
+
+extern void vwarnx(const char* fmt, va_list ap)
+{
+ errmsg(ERROR_WARNING, 0, fmt, ap);
+}
+
+extern void warnx(const char* fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ errmsg(ERROR_WARNING, 0, fmt, ap);
+ va_end(ap);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/exp.c b/usr/src/lib/libast/common/uwin/exp.c
new file mode 100644
index 0000000000..d1e15bda15
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/exp.c
@@ -0,0 +1,213 @@
+#include "FEATURE/uwin"
+
+#if !_UWIN
+
+void _STUB_exp(){}
+
+#else
+
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)exp.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* EXP(X)
+ * RETURN THE EXPONENTIAL OF X
+ * DOUBLE PRECISION (IEEE 53 bits, VAX D FORMAT 56 BITS)
+ * CODED IN C BY K.C. NG, 1/19/85;
+ * REVISED BY K.C. NG on 2/6/85, 2/15/85, 3/7/85, 3/24/85, 4/16/85, 6/14/86.
+ *
+ * Required system supported functions:
+ * scalb(x,n)
+ * copysign(x,y)
+ * finite(x)
+ *
+ * Method:
+ * 1. Argument Reduction: given the input x, find r and integer k such
+ * that
+ * x = k*ln2 + r, |r| <= 0.5*ln2 .
+ * r will be represented as r := z+c for better accuracy.
+ *
+ * 2. Compute exp(r) by
+ *
+ * exp(r) = 1 + r + r*R1/(2-R1),
+ * where
+ * R1 = x - x^2*(p1+x^2*(p2+x^2*(p3+x^2*(p4+p5*x^2)))).
+ *
+ * 3. exp(x) = 2^k * exp(r) .
+ *
+ * Special cases:
+ * exp(INF) is INF, exp(NaN) is NaN;
+ * exp(-INF)= 0;
+ * for finite argument, only exp(0)=1 is exact.
+ *
+ * Accuracy:
+ * exp(x) returns the exponential of x nearly rounded. In a test run
+ * with 1,156,000 random arguments on a VAX, the maximum observed
+ * error was 0.869 ulps (units in the last place).
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+
+#include "mathimpl.h"
+
+vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000)
+vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC)
+vc(lnhuge, 9.4961163736712506989E1 ,ec1d,43bd,9010,a73e, 7, .BDEC1DA73E9010)
+vc(lntiny,-9.5654310917272452386E1 ,4f01,c3bf,33af,d72e, 7,-.BF4F01D72E33AF)
+vc(invln2, 1.4426950408889634148E0 ,aa3b,40b8,17f1,295c, 1, .B8AA3B295C17F1)
+vc(p1, 1.6666666666666602251E-1 ,aaaa,3f2a,a9f1,aaaa, -2, .AAAAAAAAAAA9F1)
+vc(p2, -2.7777777777015591216E-3 ,0b60,bc36,ec94,b5f5, -8,-.B60B60B5F5EC94)
+vc(p3, 6.6137563214379341918E-5 ,b355,398a,f15f,792e, -13, .8AB355792EF15F)
+vc(p4, -1.6533902205465250480E-6 ,ea0e,b6dd,5f84,2e93, -19,-.DDEA0E2E935F84)
+vc(p5, 4.1381367970572387085E-8 ,bb4b,3431,2683,95f5, -24, .B1BB4B95F52683)
+
+#ifdef vccast
+#define ln2hi vccast(ln2hi)
+#define ln2lo vccast(ln2lo)
+#define lnhuge vccast(lnhuge)
+#define lntiny vccast(lntiny)
+#define invln2 vccast(invln2)
+#define p1 vccast(p1)
+#define p2 vccast(p2)
+#define p3 vccast(p3)
+#define p4 vccast(p4)
+#define p5 vccast(p5)
+#endif
+
+ic(p1, 1.6666666666666601904E-1, -3, 1.555555555553E)
+ic(p2, -2.7777777777015593384E-3, -9, -1.6C16C16BEBD93)
+ic(p3, 6.6137563214379343612E-5, -14, 1.1566AAF25DE2C)
+ic(p4, -1.6533902205465251539E-6, -20, -1.BBD41C5D26BF1)
+ic(p5, 4.1381367970572384604E-8, -25, 1.6376972BEA4D0)
+ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000)
+ic(ln2lo, 1.9082149292705877000E-10,-33, 1.A39EF35793C76)
+ic(lnhuge, 7.1602103751842355450E2, 9, 1.6602B15B7ECF2)
+ic(lntiny,-7.5137154372698068983E2, 9, -1.77AF8EBEAE354)
+ic(invln2, 1.4426950408889633870E0, 0, 1.71547652B82FE)
+
+#if !_lib_exp
+
+extern double exp(x)
+double x;
+{
+ double z,hi,lo,c;
+ int k;
+
+#if !defined(vax)&&!defined(tahoe)
+ if(x!=x) return(x); /* x is NaN */
+#endif /* !defined(vax)&&!defined(tahoe) */
+ if( x <= lnhuge ) {
+ if( x >= lntiny ) {
+
+ /* argument reduction : x --> x - k*ln2 */
+
+ k=invln2*x+copysign(0.5,x); /* k=NINT(x/ln2) */
+
+ /* express x-k*ln2 as hi-lo and let x=hi-lo rounded */
+
+ hi=x-k*ln2hi;
+ x=hi-(lo=k*ln2lo);
+
+ /* return 2^k*[1+x+x*c/(2+c)] */
+ z=x*x;
+ c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5))));
+ return scalb(1.0+(hi-(lo-(x*c)/(2.0-c))),k);
+
+ }
+ /* end of x > lntiny */
+
+ else
+ /* exp(-big#) underflows to zero */
+ if(finite(x)) return(scalb(1.0,-5000));
+
+ /* exp(-INF) is zero */
+ else return(0.0);
+ }
+ /* end of x < lnhuge */
+
+ else
+ /* exp(INF) is INF, exp(+big#) overflows to INF */
+ return( finite(x) ? scalb(1.0,5000) : x);
+}
+
+#endif
+
+/* returns exp(r = x + c) for |c| < |x| with no overlap. */
+
+double __exp__D(x, c)
+double x, c;
+{
+ double z,hi,lo;
+ int k;
+
+#if !defined(vax)&&!defined(tahoe)
+ if (x!=x) return(x); /* x is NaN */
+#endif /* !defined(vax)&&!defined(tahoe) */
+ if ( x <= lnhuge ) {
+ if ( x >= lntiny ) {
+
+ /* argument reduction : x --> x - k*ln2 */
+ z = invln2*x;
+ k = (int)z + copysign(.5, x);
+
+ /* express (x+c)-k*ln2 as hi-lo and let x=hi-lo rounded */
+
+ hi=(x-k*ln2hi); /* Exact. */
+ x= hi - (lo = k*ln2lo-c);
+ /* return 2^k*[1+x+x*c/(2+c)] */
+ z=x*x;
+ c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5))));
+ c = (x*c)/(2.0-c);
+
+ return scalb(1.+(hi-(lo - c)), k);
+ }
+ /* end of x > lntiny */
+
+ else
+ /* exp(-big#) underflows to zero */
+ if(finite(x)) return(scalb(1.0,-5000));
+
+ /* exp(-INF) is zero */
+ else return(0.0);
+ }
+ /* end of x < lnhuge */
+
+ else
+ /* exp(INF) is INF, exp(+big#) overflows to INF */
+ return( finite(x) ? scalb(1.0,5000) : x);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/exp__E.c b/usr/src/lib/libast/common/uwin/exp__E.c
new file mode 100644
index 0000000000..5c131a8e40
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/exp__E.c
@@ -0,0 +1,142 @@
+#include "FEATURE/uwin"
+
+#if !_UWIN
+
+void _STUB_exp__E(){}
+
+#else
+
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)exp__E.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* exp__E(x,c)
+ * ASSUMPTION: c << x SO THAT fl(x+c)=x.
+ * (c is the correction term for x)
+ * exp__E RETURNS
+ *
+ * / exp(x+c) - 1 - x , 1E-19 < |x| < .3465736
+ * exp__E(x,c) = |
+ * \ 0 , |x| < 1E-19.
+ *
+ * DOUBLE PRECISION (IEEE 53 bits, VAX D FORMAT 56 BITS)
+ * KERNEL FUNCTION OF EXP, EXPM1, POW FUNCTIONS
+ * CODED IN C BY K.C. NG, 1/31/85;
+ * REVISED BY K.C. NG on 3/16/85, 4/16/85.
+ *
+ * Required system supported function:
+ * copysign(x,y)
+ *
+ * Method:
+ * 1. Rational approximation. Let r=x+c.
+ * Based on
+ * 2 * sinh(r/2)
+ * exp(r) - 1 = ---------------------- ,
+ * cosh(r/2) - sinh(r/2)
+ * exp__E(r) is computed using
+ * x*x (x/2)*W - ( Q - ( 2*P + x*P ) )
+ * --- + (c + x*[---------------------------------- + c ])
+ * 2 1 - W
+ * where P := p1*x^2 + p2*x^4,
+ * Q := q1*x^2 + q2*x^4 (for 56 bits precision, add q3*x^6)
+ * W := x/2-(Q-x*P),
+ *
+ * (See the listing below for the values of p1,p2,q1,q2,q3. The poly-
+ * nomials P and Q may be regarded as the approximations to sinh
+ * and cosh :
+ * sinh(r/2) = r/2 + r * P , cosh(r/2) = 1 + Q . )
+ *
+ * The coefficients were obtained by a special Remez algorithm.
+ *
+ * Approximation error:
+ *
+ * | exp(x) - 1 | 2**(-57), (IEEE double)
+ * | ------------ - (exp__E(x,0)+x)/x | <=
+ * | x | 2**(-69). (VAX D)
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+
+#include "mathimpl.h"
+
+vc(p1, 1.5150724356786683059E-2 ,3abe,3d78,066a,67e1, -6, .F83ABE67E1066A)
+vc(p2, 6.3112487873718332688E-5 ,5b42,3984,0173,48cd, -13, .845B4248CD0173)
+vc(q1, 1.1363478204690669916E-1 ,b95a,3ee8,ec45,44a2, -3, .E8B95A44A2EC45)
+vc(q2, 1.2624568129896839182E-3 ,7905,3ba5,f5e7,72e4, -9, .A5790572E4F5E7)
+vc(q3, 1.5021856115869022674E-6 ,9eb4,36c9,c395,604a, -19, .C99EB4604AC395)
+
+ic(p1, 1.3887401997267371720E-2, -7, 1.C70FF8B3CC2CF)
+ic(p2, 3.3044019718331897649E-5, -15, 1.15317DF4526C4)
+ic(q1, 1.1110813732786649355E-1, -4, 1.C719538248597)
+ic(q2, 9.9176615021572857300E-4, -10, 1.03FC4CB8C98E8)
+
+#ifdef vccast
+#define p1 vccast(p1)
+#define p2 vccast(p2)
+#define q1 vccast(q1)
+#define q2 vccast(q2)
+#define q3 vccast(q3)
+#endif
+
+double __exp__E(x,c)
+double x,c;
+{
+ const static double zero=0.0, one=1.0, half=1.0/2.0, small=1.0E-19;
+ double z,p,q,xp,xh,w;
+ if(copysign(x,one)>small) {
+ z = x*x ;
+ p = z*( p1 +z* p2 );
+#if defined(vax)||defined(tahoe)
+ q = z*( q1 +z*( q2 +z* q3 ));
+#else /* defined(vax)||defined(tahoe) */
+ q = z*( q1 +z* q2 );
+#endif /* defined(vax)||defined(tahoe) */
+ xp= x*p ;
+ xh= x*half ;
+ w = xh-(q-xp) ;
+ p = p+p;
+ c += x*((xh*w-(q-(p+xp)))/(one-w)+c);
+ return(z*half+c);
+ }
+ /* end of |x| > small */
+
+ else {
+ if(x!=zero) one+small; /* raise the inexact flag */
+ return(copysign(zero,x));
+ }
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/expm1.c b/usr/src/lib/libast/common/uwin/expm1.c
new file mode 100644
index 0000000000..1e7f694b35
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/expm1.c
@@ -0,0 +1,173 @@
+#include "FEATURE/uwin"
+
+#if !_UWIN || _lib_expm1
+
+void _STUB_expm1(){}
+
+#else
+
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)expm1.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* EXPM1(X)
+ * RETURN THE EXPONENTIAL OF X MINUS ONE
+ * DOUBLE PRECISION (IEEE 53 BITS, VAX D FORMAT 56 BITS)
+ * CODED IN C BY K.C. NG, 1/19/85;
+ * REVISED BY K.C. NG on 2/6/85, 3/7/85, 3/21/85, 4/16/85.
+ *
+ * Required system supported functions:
+ * scalb(x,n)
+ * copysign(x,y)
+ * finite(x)
+ *
+ * Kernel function:
+ * exp__E(x,c)
+ *
+ * Method:
+ * 1. Argument Reduction: given the input x, find r and integer k such
+ * that
+ * x = k*ln2 + r, |r| <= 0.5*ln2 .
+ * r will be represented as r := z+c for better accuracy.
+ *
+ * 2. Compute EXPM1(r)=exp(r)-1 by
+ *
+ * EXPM1(r=z+c) := z + exp__E(z,c)
+ *
+ * 3. EXPM1(x) = 2^k * ( EXPM1(r) + 1-2^-k ).
+ *
+ * Remarks:
+ * 1. When k=1 and z < -0.25, we use the following formula for
+ * better accuracy:
+ * EXPM1(x) = 2 * ( (z+0.5) + exp__E(z,c) )
+ * 2. To avoid rounding error in 1-2^-k where k is large, we use
+ * EXPM1(x) = 2^k * { [z+(exp__E(z,c)-2^-k )] + 1 }
+ * when k>56.
+ *
+ * Special cases:
+ * EXPM1(INF) is INF, EXPM1(NaN) is NaN;
+ * EXPM1(-INF)= -1;
+ * for finite argument, only EXPM1(0)=0 is exact.
+ *
+ * Accuracy:
+ * EXPM1(x) returns the exact (exp(x)-1) nearly rounded. In a test run with
+ * 1,166,000 random arguments on a VAX, the maximum observed error was
+ * .872 ulps (units of the last place).
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+
+#include "mathimpl.h"
+
+vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000)
+vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC)
+vc(lnhuge, 9.4961163736712506989E1 ,ec1d,43bd,9010,a73e, 7, .BDEC1DA73E9010)
+vc(invln2, 1.4426950408889634148E0 ,aa3b,40b8,17f1,295c, 1, .B8AA3B295C17F1)
+
+ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000)
+ic(ln2lo, 1.9082149292705877000E-10, -33, 1.A39EF35793C76)
+ic(lnhuge, 7.1602103751842355450E2, 9, 1.6602B15B7ECF2)
+ic(invln2, 1.4426950408889633870E0, 0, 1.71547652B82FE)
+
+#ifdef vccast
+#define ln2hi vccast(ln2hi)
+#define ln2lo vccast(ln2lo)
+#define lnhuge vccast(lnhuge)
+#define invln2 vccast(invln2)
+#endif
+
+extern double expm1(x)
+double x;
+{
+ const static double one=1.0, half=1.0/2.0;
+ double z,hi,lo,c;
+ int k;
+#if defined(vax)||defined(tahoe)
+ static prec=56;
+#else /* defined(vax)||defined(tahoe) */
+ static prec=53;
+#endif /* defined(vax)||defined(tahoe) */
+
+#if !defined(vax)&&!defined(tahoe)
+ if(x!=x) return(x); /* x is NaN */
+#endif /* !defined(vax)&&!defined(tahoe) */
+
+ if( x <= lnhuge ) {
+ if( x >= -40.0 ) {
+
+ /* argument reduction : x - k*ln2 */
+ k= (int)(invln2*x)+copysign(0.5,x); /* k=NINT(x/ln2) */
+ hi=x-k*ln2hi ;
+ z=hi-(lo=k*ln2lo);
+ c=(hi-z)-lo;
+
+ if(k==0) return(z+__exp__E(z,c));
+ if(k==1)
+ if(z< -0.25)
+ {x=z+half;x +=__exp__E(z,c); return(x+x);}
+ else
+ {z+=__exp__E(z,c); x=half+z; return(x+x);}
+ /* end of k=1 */
+
+ else {
+ if(k<=prec)
+ { x=one-scalb(one,-k); z += __exp__E(z,c);}
+ else if(k<100)
+ { x = __exp__E(z,c)-scalb(one,-k); x+=z; z=one;}
+ else
+ { x = __exp__E(z,c)+z; z=one;}
+
+ return (scalb(x+z,k));
+ }
+ }
+ /* end of x > lnunfl */
+
+ else
+ /* expm1(-big#) rounded to -1 (inexact) */
+ if(finite(x))
+ { ln2hi+ln2lo; return(-one);}
+
+ /* expm1(-INF) is -1 */
+ else return(-one);
+ }
+ /* end of x < lnhuge */
+
+ else
+ /* expm1(INF) is INF, expm1(+big#) overflows to INF */
+ return( finite(x) ? scalb(one,5000) : x);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/gamma.c b/usr/src/lib/libast/common/uwin/gamma.c
new file mode 100644
index 0000000000..0cb1d1fac9
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/gamma.c
@@ -0,0 +1,343 @@
+#include "FEATURE/uwin"
+
+#if !_UWIN || _lib_gamma
+
+void _STUB_gamma(){}
+
+#else
+
+/*-
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)gamma.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/*
+ * This code by P. McIlroy, Oct 1992;
+ *
+ * The financial support of UUNET Communications Services is greatfully
+ * acknowledged.
+ */
+
+#define gamma ______gamma
+
+#include <math.h>
+#include <errno.h>
+#include "mathimpl.h"
+
+#undef gamma
+
+/* METHOD:
+ * x < 0: Use reflection formula, G(x) = pi/(sin(pi*x)*x*G(x))
+ * At negative integers, return +Inf, and set errno.
+ *
+ * x < 6.5:
+ * Use argument reduction G(x+1) = xG(x) to reach the
+ * range [1.066124,2.066124]. Use a rational
+ * approximation centered at the minimum (x0+1) to
+ * ensure monotonicity.
+ *
+ * x >= 6.5: Use the asymptotic approximation (Stirling's formula)
+ * adjusted for equal-ripples:
+ *
+ * log(G(x)) ~= (x-.5)*(log(x)-1) + .5(log(2*pi)-1) + 1/x*P(1/(x*x))
+ *
+ * Keep extra precision in multiplying (x-.5)(log(x)-1), to
+ * avoid premature round-off.
+ *
+ * Special values:
+ * non-positive integer: Set overflow trap; return +Inf;
+ * x > 171.63: Set overflow trap; return +Inf;
+ * NaN: Set invalid trap; return NaN
+ *
+ * Accuracy: Gamma(x) is accurate to within
+ * x > 0: error provably < 0.9ulp.
+ * Maximum observed in 1,000,000 trials was .87ulp.
+ * x < 0:
+ * Maximum observed error < 4ulp in 1,000,000 trials.
+ */
+
+static double neg_gam __P((double));
+static double small_gam __P((double));
+static double smaller_gam __P((double));
+static struct Double large_gam __P((double));
+static struct Double ratfun_gam __P((double, double));
+
+/*
+ * Rational approximation, A0 + x*x*P(x)/Q(x), on the interval
+ * [1.066.., 2.066..] accurate to 4.25e-19.
+ */
+#define LEFT -.3955078125 /* left boundary for rat. approx */
+#define x0 .461632144968362356785 /* xmin - 1 */
+
+#define a0_hi 0.88560319441088874992
+#define a0_lo -.00000000000000004996427036469019695
+#define P0 6.21389571821820863029017800727e-01
+#define P1 2.65757198651533466104979197553e-01
+#define P2 5.53859446429917461063308081748e-03
+#define P3 1.38456698304096573887145282811e-03
+#define P4 2.40659950032711365819348969808e-03
+#define Q0 1.45019531250000000000000000000e+00
+#define Q1 1.06258521948016171343454061571e+00
+#define Q2 -2.07474561943859936441469926649e-01
+#define Q3 -1.46734131782005422506287573015e-01
+#define Q4 3.07878176156175520361557573779e-02
+#define Q5 5.12449347980666221336054633184e-03
+#define Q6 -1.76012741431666995019222898833e-03
+#define Q7 9.35021023573788935372153030556e-05
+#define Q8 6.13275507472443958924745652239e-06
+/*
+ * Constants for large x approximation (x in [6, Inf])
+ * (Accurate to 2.8*10^-19 absolute)
+ */
+#define lns2pi_hi 0.418945312500000
+#define lns2pi_lo -.000006779295327258219670263595
+#define Pa0 8.33333333333333148296162562474e-02
+#define Pa1 -2.77777777774548123579378966497e-03
+#define Pa2 7.93650778754435631476282786423e-04
+#define Pa3 -5.95235082566672847950717262222e-04
+#define Pa4 8.41428560346653702135821806252e-04
+#define Pa5 -1.89773526463879200348872089421e-03
+#define Pa6 5.69394463439411649408050664078e-03
+#define Pa7 -1.44705562421428915453880392761e-02
+
+static const double zero = 0., one = 1.0, tiny = 1e-300;
+static int endian;
+/*
+ * TRUNC sets trailing bits in a floating-point number to zero.
+ * is a temporary variable.
+ */
+#if defined(vax) || defined(tahoe)
+#define _IEEE 0
+#define TRUNC(x) x = (double) (float) (x)
+#else
+#define _IEEE 1
+#define TRUNC(x) *(((int *) &x) + endian) &= 0xf8000000
+#define infnan(x) 0.0
+#endif
+
+extern double gamma(x)
+ double x;
+{
+ struct Double u;
+ endian = (*(int *) &one) ? 1 : 0;
+
+ if (x >= 6) {
+ if(x > 171.63)
+ return(one/zero);
+ u = large_gam(x);
+ return(__exp__D(u.a, u.b));
+ } else if (x >= 1.0 + LEFT + x0)
+ return (small_gam(x));
+ else if (x > 1.e-17)
+ return (smaller_gam(x));
+ else if (x > -1.e-17) {
+ if (x == 0.0)
+ if (!_IEEE) return (infnan(ERANGE));
+ else return (one/x);
+ one+1e-20; /* Raise inexact flag. */
+ return (one/x);
+ } else if (!finite(x)) {
+ if (_IEEE) /* x = NaN, -Inf */
+ return (x*x);
+ else
+ return (infnan(EDOM));
+ } else
+ return (neg_gam(x));
+}
+/*
+ * Accurate to max(ulp(1/128) absolute, 2^-66 relative) error.
+ */
+static struct Double
+large_gam(x)
+ double x;
+{
+ double z, p;
+ struct Double t, u, v;
+
+ z = one/(x*x);
+ p = Pa0+z*(Pa1+z*(Pa2+z*(Pa3+z*(Pa4+z*(Pa5+z*(Pa6+z*Pa7))))));
+ p = p/x;
+
+ u = __log__D(x);
+ u.a -= one;
+ v.a = (x -= .5);
+ TRUNC(v.a);
+ v.b = x - v.a;
+ t.a = v.a*u.a; /* t = (x-.5)*(log(x)-1) */
+ t.b = v.b*u.a + x*u.b;
+ /* return t.a + t.b + lns2pi_hi + lns2pi_lo + p */
+ t.b += lns2pi_lo; t.b += p;
+ u.a = lns2pi_hi + t.b; u.a += t.a;
+ u.b = t.a - u.a;
+ u.b += lns2pi_hi; u.b += t.b;
+ return (u);
+}
+/*
+ * Good to < 1 ulp. (provably .90 ulp; .87 ulp on 1,000,000 runs.)
+ * It also has correct monotonicity.
+ */
+static double
+small_gam(x)
+ double x;
+{
+ double y, ym1, t;
+ struct Double yy, r;
+ y = x - one;
+ ym1 = y - one;
+ if (y <= 1.0 + (LEFT + x0)) {
+ yy = ratfun_gam(y - x0, 0);
+ return (yy.a + yy.b);
+ }
+ r.a = y;
+ TRUNC(r.a);
+ yy.a = r.a - one;
+ y = ym1;
+ yy.b = r.b = y - yy.a;
+ /* Argument reduction: G(x+1) = x*G(x) */
+ for (ym1 = y-one; ym1 > LEFT + x0; y = ym1--, yy.a--) {
+ t = r.a*yy.a;
+ r.b = r.a*yy.b + y*r.b;
+ r.a = t;
+ TRUNC(r.a);
+ r.b += (t - r.a);
+ }
+ /* Return r*gamma(y). */
+ yy = ratfun_gam(y - x0, 0);
+ y = r.b*(yy.a + yy.b) + r.a*yy.b;
+ y += yy.a*r.a;
+ return (y);
+}
+/*
+ * Good on (0, 1+x0+LEFT]. Accurate to 1ulp.
+ */
+static double
+smaller_gam(x)
+ double x;
+{
+ double t, d;
+ struct Double r, xx;
+ if (x < x0 + LEFT) {
+ t = x, TRUNC(t);
+ d = (t+x)*(x-t);
+ t *= t;
+ xx.a = (t + x), TRUNC(xx.a);
+ xx.b = x - xx.a; xx.b += t; xx.b += d;
+ t = (one-x0); t += x;
+ d = (one-x0); d -= t; d += x;
+ x = xx.a + xx.b;
+ } else {
+ xx.a = x, TRUNC(xx.a);
+ xx.b = x - xx.a;
+ t = x - x0;
+ d = (-x0 -t); d += x;
+ }
+ r = ratfun_gam(t, d);
+ d = r.a/x, TRUNC(d);
+ r.a -= d*xx.a; r.a -= d*xx.b; r.a += r.b;
+ return (d + r.a/x);
+}
+/*
+ * returns (z+c)^2 * P(z)/Q(z) + a0
+ */
+static struct Double
+ratfun_gam(z, c)
+ double z, c;
+{
+ double p, q;
+ struct Double r, t;
+
+ q = Q0 +z*(Q1+z*(Q2+z*(Q3+z*(Q4+z*(Q5+z*(Q6+z*(Q7+z*Q8)))))));
+ p = P0 + z*(P1 + z*(P2 + z*(P3 + z*P4)));
+
+ /* return r.a + r.b = a0 + (z+c)^2*p/q, with r.a truncated to 26 bits. */
+ p = p/q;
+ t.a = z, TRUNC(t.a); /* t ~= z + c */
+ t.b = (z - t.a) + c;
+ t.b *= (t.a + z);
+ q = (t.a *= t.a); /* t = (z+c)^2 */
+ TRUNC(t.a);
+ t.b += (q - t.a);
+ r.a = p, TRUNC(r.a); /* r = P/Q */
+ r.b = p - r.a;
+ t.b = t.b*p + t.a*r.b + a0_lo;
+ t.a *= r.a; /* t = (z+c)^2*(P/Q) */
+ r.a = t.a + a0_hi, TRUNC(r.a);
+ r.b = ((a0_hi-r.a) + t.a) + t.b;
+ return (r); /* r = a0 + t */
+}
+
+static double
+neg_gam(x)
+ double x;
+{
+ int sgn = 1;
+ struct Double lg, lsine;
+ double y, z;
+
+ y = floor(x + .5);
+ if (y == x) /* Negative integer. */
+ if(!_IEEE)
+ return (infnan(ERANGE));
+ else
+ return (one/zero);
+ z = fabs(x - y);
+ y = .5*ceil(x);
+ if (y == ceil(y))
+ sgn = -1;
+ if (z < .25)
+ z = sin(M_PI*z);
+ else
+ z = cos(M_PI*(0.5-z));
+ /* Special case: G(1-x) = Inf; G(x) may be nonzero. */
+ if (x < -170) {
+ if (x < -190)
+ return ((double)sgn*tiny*tiny);
+ y = one - x; /* exact: 128 < |x| < 255 */
+ lg = large_gam(y);
+ lsine = __log__D(M_PI/z); /* = TRUNC(log(u)) + small */
+ lg.a -= lsine.a; /* exact (opposite signs) */
+ lg.b -= lsine.b;
+ y = -(lg.a + lg.b);
+ z = (y + lg.a) + lg.b;
+ y = __exp__D(y, z);
+ if (sgn < 0) y = -y;
+ return (y);
+ }
+ y = one-x;
+ if (one-y == x)
+ y = gamma(y);
+ else /* 1-x is inexact */
+ y = -x*gamma(-x);
+ if (sgn < 0) y = -y;
+ return (M_PI / (y*z));
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/getpass.c b/usr/src/lib/libast/common/uwin/getpass.c
new file mode 100644
index 0000000000..4d74eef5c4
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/getpass.c
@@ -0,0 +1,79 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "FEATURE/uwin"
+
+#if !_UWIN || _lib_getpass
+
+void _STUB_getpass(){}
+
+#else
+
+#pragma prototyped
+
+#define getpass ______getpass
+
+#include <ast.h>
+#include <termios.h>
+#include <signal.h>
+
+#undef getpass
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+static int interrupt;
+static void handler(int sig)
+{
+ interrupt++;
+}
+
+extern char* getpass(const char *prompt)
+{
+ struct termios told,tnew;
+ Sfio_t *iop;
+ static char *cp, passwd[32];
+ void (*savesig)(int);
+ if(!(iop = sfopen((Sfio_t*)0, "/dev/tty", "r")))
+ return(0);
+ if(tcgetattr(sffileno(iop),&told) < 0)
+ return(0);
+ interrupt = 0;
+ tnew = told;
+ tnew.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL);
+ if(tcsetattr(sffileno(iop),TCSANOW,&tnew) < 0)
+ return(0);
+ savesig = signal(SIGINT, handler);
+ sfputr(sfstderr,prompt,-1);
+ if(cp = sfgetr(iop,'\n',1))
+ strncpy(passwd,cp,sizeof(passwd)-1);
+ tcsetattr(sffileno(iop),TCSANOW,&told);
+ sfputc(sfstderr,'\n');
+ sfclose(iop);
+ signal(SIGINT, savesig);
+ if(interrupt)
+ kill(getpid(),SIGINT);
+ return(cp?passwd:0);
+}
+
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/lgamma.c b/usr/src/lib/libast/common/uwin/lgamma.c
new file mode 100644
index 0000000000..d37357d35f
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/lgamma.c
@@ -0,0 +1,316 @@
+#include "FEATURE/uwin"
+
+#if !_UWIN || _lib_lgamma
+
+void _STUB_lgamma(){}
+
+#else
+
+/*-
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)lgamma.c 8.2 (Berkeley) 11/30/93";
+#endif /* not lint */
+
+/*
+ * Coded by Peter McIlroy, Nov 1992;
+ *
+ * The financial support of UUNET Communications Services is greatfully
+ * acknowledged.
+ */
+
+#define gamma ______gamma
+#define lgamma ______lgamma
+
+#include <math.h>
+#include <errno.h>
+#include "mathimpl.h"
+
+#undef gamma
+#undef lgamma
+
+/* Log gamma function.
+ * Error: x > 0 error < 1.3ulp.
+ * x > 4, error < 1ulp.
+ * x > 9, error < .6ulp.
+ * x < 0, all bets are off. (When G(x) ~ 1, log(G(x)) ~ 0)
+ * Method:
+ * x > 6:
+ * Use the asymptotic expansion (Stirling's Formula)
+ * 0 < x < 6:
+ * Use gamma(x+1) = x*gamma(x) for argument reduction.
+ * Use rational approximation in
+ * the range 1.2, 2.5
+ * Two approximations are used, one centered at the
+ * minimum to ensure monotonicity; one centered at 2
+ * to maintain small relative error.
+ * x < 0:
+ * Use the reflection formula,
+ * G(1-x)G(x) = PI/sin(PI*x)
+ * Special values:
+ * non-positive integer returns +Inf.
+ * NaN returns NaN
+*/
+static int endian;
+#if defined(vax) || defined(tahoe)
+#define _IEEE 0
+/* double and float have same size exponent field */
+#define TRUNC(x) x = (double) (float) (x)
+#else
+#define _IEEE 1
+#define TRUNC(x) *(((int *) &x) + endian) &= 0xf8000000
+#define infnan(x) 0.0
+#endif
+
+static double small_lgam(double);
+static double large_lgam(double);
+static double neg_lgam(double);
+static double zero = 0.0, one = 1.0;
+int signgam;
+
+#define UNDERFL (1e-1020 * 1e-1020)
+
+#define LEFT (1.0 - (x0 + .25))
+#define RIGHT (x0 - .218)
+/*
+ * Constants for approximation in [1.244,1.712]
+*/
+#define x0 0.461632144968362356785
+#define x0_lo -.000000000000000015522348162858676890521
+#define a0_hi -0.12148629128932952880859
+#define a0_lo .0000000007534799204229502
+#define r0 -2.771227512955130520e-002
+#define r1 -2.980729795228150847e-001
+#define r2 -3.257411333183093394e-001
+#define r3 -1.126814387531706041e-001
+#define r4 -1.129130057170225562e-002
+#define r5 -2.259650588213369095e-005
+#define s0 1.714457160001714442e+000
+#define s1 2.786469504618194648e+000
+#define s2 1.564546365519179805e+000
+#define s3 3.485846389981109850e-001
+#define s4 2.467759345363656348e-002
+/*
+ * Constants for approximation in [1.71, 2.5]
+*/
+#define a1_hi 4.227843350984671344505727574870e-01
+#define a1_lo 4.670126436531227189e-18
+#define p0 3.224670334241133695662995251041e-01
+#define p1 3.569659696950364669021382724168e-01
+#define p2 1.342918716072560025853732668111e-01
+#define p3 1.950702176409779831089963408886e-02
+#define p4 8.546740251667538090796227834289e-04
+#define q0 1.000000000000000444089209850062e+00
+#define q1 1.315850076960161985084596381057e+00
+#define q2 6.274644311862156431658377186977e-01
+#define q3 1.304706631926259297049597307705e-01
+#define q4 1.102815279606722369265536798366e-02
+#define q5 2.512690594856678929537585620579e-04
+#define q6 -1.003597548112371003358107325598e-06
+/*
+ * Stirling's Formula, adjusted for equal-ripple. x in [6,Inf].
+*/
+#define lns2pi .418938533204672741780329736405
+#define pb0 8.33333333333333148296162562474e-02
+#define pb1 -2.77777777774548123579378966497e-03
+#define pb2 7.93650778754435631476282786423e-04
+#define pb3 -5.95235082566672847950717262222e-04
+#define pb4 8.41428560346653702135821806252e-04
+#define pb5 -1.89773526463879200348872089421e-03
+#define pb6 5.69394463439411649408050664078e-03
+#define pb7 -1.44705562421428915453880392761e-02
+
+extern __pure double lgamma(double x)
+{
+ double r;
+
+ signgam = 1;
+ endian = ((*(int *) &one)) ? 1 : 0;
+
+ if (!finite(x))
+ if (_IEEE)
+ return (x+x);
+ else return (infnan(EDOM));
+
+ if (x > 6 + RIGHT) {
+ r = large_lgam(x);
+ return (r);
+ } else if (x > 1e-16)
+ return (small_lgam(x));
+ else if (x > -1e-16) {
+ if (x < 0)
+ signgam = -1, x = -x;
+ return (-log(x));
+ } else
+ return (neg_lgam(x));
+}
+
+static double
+large_lgam(double x)
+{
+ double z, p, x1;
+ struct Double t, u, v;
+ u = __log__D(x);
+ u.a -= 1.0;
+ if (x > 1e15) {
+ v.a = x - 0.5;
+ TRUNC(v.a);
+ v.b = (x - v.a) - 0.5;
+ t.a = u.a*v.a;
+ t.b = x*u.b + v.b*u.a;
+ if (_IEEE == 0 && !finite(t.a))
+ return(infnan(ERANGE));
+ return(t.a + t.b);
+ }
+ x1 = 1./x;
+ z = x1*x1;
+ p = pb0+z*(pb1+z*(pb2+z*(pb3+z*(pb4+z*(pb5+z*(pb6+z*pb7))))));
+ /* error in approximation = 2.8e-19 */
+
+ p = p*x1; /* error < 2.3e-18 absolute */
+ /* 0 < p < 1/64 (at x = 5.5) */
+ v.a = x = x - 0.5;
+ TRUNC(v.a); /* truncate v.a to 26 bits. */
+ v.b = x - v.a;
+ t.a = v.a*u.a; /* t = (x-.5)*(log(x)-1) */
+ t.b = v.b*u.a + x*u.b;
+ t.b += p; t.b += lns2pi; /* return t + lns2pi + p */
+ return (t.a + t.b);
+}
+
+static double
+small_lgam(double x)
+{
+ int x_int;
+ double y, z, t, r = 0, p, q, hi, lo;
+ struct Double rr;
+ x_int = (int)(x + .5);
+ y = x - x_int;
+ if (x_int <= 2 && y > RIGHT) {
+ t = y - x0;
+ y--; x_int++;
+ goto CONTINUE;
+ } else if (y < -LEFT) {
+ t = y +(1.0-x0);
+CONTINUE:
+ z = t - x0_lo;
+ p = r0+z*(r1+z*(r2+z*(r3+z*(r4+z*r5))));
+ q = s0+z*(s1+z*(s2+z*(s3+z*s4)));
+ r = t*(z*(p/q) - x0_lo);
+ t = .5*t*t;
+ z = 1.0;
+ switch (x_int) {
+ case 6: z = (y + 5);
+ case 5: z *= (y + 4);
+ case 4: z *= (y + 3);
+ case 3: z *= (y + 2);
+ rr = __log__D(z);
+ rr.b += a0_lo; rr.a += a0_hi;
+ return(((r+rr.b)+t+rr.a));
+ case 2: return(((r+a0_lo)+t)+a0_hi);
+ case 0: r -= log1p(x);
+ default: rr = __log__D(x);
+ rr.a -= a0_hi; rr.b -= a0_lo;
+ return(((r - rr.b) + t) - rr.a);
+ }
+ } else {
+ p = p0+y*(p1+y*(p2+y*(p3+y*p4)));
+ q = q0+y*(q1+y*(q2+y*(q3+y*(q4+y*(q5+y*q6)))));
+ p = p*(y/q);
+ t = (double)(float) y;
+ z = y-t;
+ hi = (double)(float) (p+a1_hi);
+ lo = a1_hi - hi; lo += p; lo += a1_lo;
+ r = lo*y + z*hi; /* q + r = y*(a0+p/q) */
+ q = hi*t;
+ z = 1.0;
+ switch (x_int) {
+ case 6: z = (y + 5);
+ case 5: z *= (y + 4);
+ case 4: z *= (y + 3);
+ case 3: z *= (y + 2);
+ rr = __log__D(z);
+ r += rr.b; r += q;
+ return(rr.a + r);
+ case 2: return (q+ r);
+ case 0: rr = __log__D(x);
+ r -= rr.b; r -= log1p(x);
+ r += q; r-= rr.a;
+ return(r);
+ default: rr = __log__D(x);
+ r -= rr.b;
+ q -= rr.a;
+ return (r+q);
+ }
+ }
+}
+
+static double
+neg_lgam(double x)
+{
+ int xi;
+ double y, z, one = 1.0, zero = 0.0;
+ extern double gamma();
+
+ /* avoid destructive cancellation as much as possible */
+ if (x > -170) {
+ xi = (int)x;
+ if (xi == x)
+ if (_IEEE)
+ return(one/zero);
+ else
+ return(infnan(ERANGE));
+ y = gamma(x);
+ if (y < 0)
+ y = -y, signgam = -1;
+ return (log(y));
+ }
+ z = floor(x + .5);
+ if (z == x) { /* convention: G(-(integer)) -> +Inf */
+ if (_IEEE)
+ return (one/zero);
+ else
+ return (infnan(ERANGE));
+ }
+ y = .5*ceil(x);
+ if (y == ceil(y))
+ signgam = -1;
+ x = -x;
+ z = fabs(x + z); /* 0 < z <= .5 */
+ if (z < .25)
+ z = sin(M_PI*z);
+ else
+ z = cos(M_PI*(0.5-z));
+ z = log(M_PI/(z*x));
+ y = large_lgam(x);
+ return (z - y);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/log.c b/usr/src/lib/libast/common/uwin/log.c
new file mode 100644
index 0000000000..e9365a3363
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/log.c
@@ -0,0 +1,496 @@
+#include "FEATURE/uwin"
+
+#if !_UWIN
+
+void _STUB_log(){}
+
+#else
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)log.c 8.2 (Berkeley) 11/30/93";
+#endif /* not lint */
+
+#include <math.h>
+#include <errno.h>
+
+#include "mathimpl.h"
+
+/* Table-driven natural logarithm.
+ *
+ * This code was derived, with minor modifications, from:
+ * Peter Tang, "Table-Driven Implementation of the
+ * Logarithm in IEEE Floating-Point arithmetic." ACM Trans.
+ * Math Software, vol 16. no 4, pp 378-400, Dec 1990).
+ *
+ * Calculates log(2^m*F*(1+f/F)), |f/j| <= 1/256,
+ * where F = j/128 for j an integer in [0, 128].
+ *
+ * log(2^m) = log2_hi*m + log2_tail*m
+ * since m is an integer, the dominant term is exact.
+ * m has at most 10 digits (for subnormal numbers),
+ * and log2_hi has 11 trailing zero bits.
+ *
+ * log(F) = logF_hi[j] + logF_lo[j] is in tabular form in log_table.h
+ * logF_hi[] + 512 is exact.
+ *
+ * log(1+f/F) = 2*f/(2*F + f) + 1/12 * (2*f/(2*F + f))**3 + ...
+ * the leading term is calculated to extra precision in two
+ * parts, the larger of which adds exactly to the dominant
+ * m and F terms.
+ * There are two cases:
+ * 1. when m, j are non-zero (m | j), use absolute
+ * precision for the leading term.
+ * 2. when m = j = 0, |1-x| < 1/256, and log(x) ~= (x-1).
+ * In this case, use a relative precision of 24 bits.
+ * (This is done differently in the original paper)
+ *
+ * Special cases:
+ * 0 return signalling -Inf
+ * neg return signalling NaN
+ * +Inf return +Inf
+*/
+
+#if defined(vax) || defined(tahoe)
+#define _IEEE 0
+#define TRUNC(x) x = (double) (float) (x)
+#else
+#define _IEEE 1
+#define endian (((*(int *) &one)) ? 1 : 0)
+#define TRUNC(x) *(((int *) &x) + endian) &= 0xf8000000
+#define infnan(x) 0.0
+#endif
+
+#define N 128
+
+/* Table of log(Fj) = logF_head[j] + logF_tail[j], for Fj = 1+j/128.
+ * Used for generation of extend precision logarithms.
+ * The constant 35184372088832 is 2^45, so the divide is exact.
+ * It ensures correct reading of logF_head, even for inaccurate
+ * decimal-to-binary conversion routines. (Everybody gets the
+ * right answer for integers less than 2^53.)
+ * Values for log(F) were generated using error < 10^-57 absolute
+ * with the bc -l package.
+*/
+static double A1 = .08333333333333178827;
+static double A2 = .01250000000377174923;
+static double A3 = .002232139987919447809;
+static double A4 = .0004348877777076145742;
+
+static double logF_head[N+1] = {
+ 0.,
+ .007782140442060381246,
+ .015504186535963526694,
+ .023167059281547608406,
+ .030771658666765233647,
+ .038318864302141264488,
+ .045809536031242714670,
+ .053244514518837604555,
+ .060624621816486978786,
+ .067950661908525944454,
+ .075223421237524235039,
+ .082443669210988446138,
+ .089612158689760690322,
+ .096729626458454731618,
+ .103796793681567578460,
+ .110814366340264314203,
+ .117783035656430001836,
+ .124703478501032805070,
+ .131576357788617315236,
+ .138402322859292326029,
+ .145182009844575077295,
+ .151916042025732167530,
+ .158605030176659056451,
+ .165249572895390883786,
+ .171850256926518341060,
+ .178407657472689606947,
+ .184922338493834104156,
+ .191394852999565046047,
+ .197825743329758552135,
+ .204215541428766300668,
+ .210564769107350002741,
+ .216873938300523150246,
+ .223143551314024080056,
+ .229374101064877322642,
+ .235566071312860003672,
+ .241719936886966024758,
+ .247836163904594286577,
+ .253915209980732470285,
+ .259957524436686071567,
+ .265963548496984003577,
+ .271933715484010463114,
+ .277868451003087102435,
+ .283768173130738432519,
+ .289633292582948342896,
+ .295464212893421063199,
+ .301261330578199704177,
+ .307025035294827830512,
+ .312755710004239517729,
+ .318453731118097493890,
+ .324119468654316733591,
+ .329753286372579168528,
+ .335355541920762334484,
+ .340926586970454081892,
+ .346466767346100823488,
+ .351976423156884266063,
+ .357455888922231679316,
+ .362905493689140712376,
+ .368325561158599157352,
+ .373716409793814818840,
+ .379078352934811846353,
+ .384411698910298582632,
+ .389716751140440464951,
+ .394993808240542421117,
+ .400243164127459749579,
+ .405465108107819105498,
+ .410659924985338875558,
+ .415827895143593195825,
+ .420969294644237379543,
+ .426084395310681429691,
+ .431173464818130014464,
+ .436236766774527495726,
+ .441274560805140936281,
+ .446287102628048160113,
+ .451274644139630254358,
+ .456237433481874177232,
+ .461175715122408291790,
+ .466089729924533457960,
+ .470979715219073113985,
+ .475845904869856894947,
+ .480688529345570714212,
+ .485507815781602403149,
+ .490303988045525329653,
+ .495077266798034543171,
+ .499827869556611403822,
+ .504556010751912253908,
+ .509261901790523552335,
+ .513945751101346104405,
+ .518607764208354637958,
+ .523248143765158602036,
+ .527867089620485785417,
+ .532464798869114019908,
+ .537041465897345915436,
+ .541597282432121573947,
+ .546132437597407260909,
+ .550647117952394182793,
+ .555141507540611200965,
+ .559615787935399566777,
+ .564070138285387656651,
+ .568504735352689749561,
+ .572919753562018740922,
+ .577315365035246941260,
+ .581691739635061821900,
+ .586049045003164792433,
+ .590387446602107957005,
+ .594707107746216934174,
+ .599008189645246602594,
+ .603290851438941899687,
+ .607555250224322662688,
+ .611801541106615331955,
+ .616029877215623855590,
+ .620240409751204424537,
+ .624433288012369303032,
+ .628608659422752680256,
+ .632766669570628437213,
+ .636907462236194987781,
+ .641031179420679109171,
+ .645137961373620782978,
+ .649227946625615004450,
+ .653301272011958644725,
+ .657358072709030238911,
+ .661398482245203922502,
+ .665422632544505177065,
+ .669430653942981734871,
+ .673422675212350441142,
+ .677398823590920073911,
+ .681359224807238206267,
+ .685304003098281100392,
+ .689233281238557538017,
+ .693147180560117703862
+};
+
+static double logF_tail[N+1] = {
+ 0.,
+ -.00000000000000543229938420049,
+ .00000000000000172745674997061,
+ -.00000000000001323017818229233,
+ -.00000000000001154527628289872,
+ -.00000000000000466529469958300,
+ .00000000000005148849572685810,
+ -.00000000000002532168943117445,
+ -.00000000000005213620639136504,
+ -.00000000000001819506003016881,
+ .00000000000006329065958724544,
+ .00000000000008614512936087814,
+ -.00000000000007355770219435028,
+ .00000000000009638067658552277,
+ .00000000000007598636597194141,
+ .00000000000002579999128306990,
+ -.00000000000004654729747598444,
+ -.00000000000007556920687451336,
+ .00000000000010195735223708472,
+ -.00000000000017319034406422306,
+ -.00000000000007718001336828098,
+ .00000000000010980754099855238,
+ -.00000000000002047235780046195,
+ -.00000000000008372091099235912,
+ .00000000000014088127937111135,
+ .00000000000012869017157588257,
+ .00000000000017788850778198106,
+ .00000000000006440856150696891,
+ .00000000000016132822667240822,
+ -.00000000000007540916511956188,
+ -.00000000000000036507188831790,
+ .00000000000009120937249914984,
+ .00000000000018567570959796010,
+ -.00000000000003149265065191483,
+ -.00000000000009309459495196889,
+ .00000000000017914338601329117,
+ -.00000000000001302979717330866,
+ .00000000000023097385217586939,
+ .00000000000023999540484211737,
+ .00000000000015393776174455408,
+ -.00000000000036870428315837678,
+ .00000000000036920375082080089,
+ -.00000000000009383417223663699,
+ .00000000000009433398189512690,
+ .00000000000041481318704258568,
+ -.00000000000003792316480209314,
+ .00000000000008403156304792424,
+ -.00000000000034262934348285429,
+ .00000000000043712191957429145,
+ -.00000000000010475750058776541,
+ -.00000000000011118671389559323,
+ .00000000000037549577257259853,
+ .00000000000013912841212197565,
+ .00000000000010775743037572640,
+ .00000000000029391859187648000,
+ -.00000000000042790509060060774,
+ .00000000000022774076114039555,
+ .00000000000010849569622967912,
+ -.00000000000023073801945705758,
+ .00000000000015761203773969435,
+ .00000000000003345710269544082,
+ -.00000000000041525158063436123,
+ .00000000000032655698896907146,
+ -.00000000000044704265010452446,
+ .00000000000034527647952039772,
+ -.00000000000007048962392109746,
+ .00000000000011776978751369214,
+ -.00000000000010774341461609578,
+ .00000000000021863343293215910,
+ .00000000000024132639491333131,
+ .00000000000039057462209830700,
+ -.00000000000026570679203560751,
+ .00000000000037135141919592021,
+ -.00000000000017166921336082431,
+ -.00000000000028658285157914353,
+ -.00000000000023812542263446809,
+ .00000000000006576659768580062,
+ -.00000000000028210143846181267,
+ .00000000000010701931762114254,
+ .00000000000018119346366441110,
+ .00000000000009840465278232627,
+ -.00000000000033149150282752542,
+ -.00000000000018302857356041668,
+ -.00000000000016207400156744949,
+ .00000000000048303314949553201,
+ -.00000000000071560553172382115,
+ .00000000000088821239518571855,
+ -.00000000000030900580513238244,
+ -.00000000000061076551972851496,
+ .00000000000035659969663347830,
+ .00000000000035782396591276383,
+ -.00000000000046226087001544578,
+ .00000000000062279762917225156,
+ .00000000000072838947272065741,
+ .00000000000026809646615211673,
+ -.00000000000010960825046059278,
+ .00000000000002311949383800537,
+ -.00000000000058469058005299247,
+ -.00000000000002103748251144494,
+ -.00000000000023323182945587408,
+ -.00000000000042333694288141916,
+ -.00000000000043933937969737844,
+ .00000000000041341647073835565,
+ .00000000000006841763641591466,
+ .00000000000047585534004430641,
+ .00000000000083679678674757695,
+ -.00000000000085763734646658640,
+ .00000000000021913281229340092,
+ -.00000000000062242842536431148,
+ -.00000000000010983594325438430,
+ .00000000000065310431377633651,
+ -.00000000000047580199021710769,
+ -.00000000000037854251265457040,
+ .00000000000040939233218678664,
+ .00000000000087424383914858291,
+ .00000000000025218188456842882,
+ -.00000000000003608131360422557,
+ -.00000000000050518555924280902,
+ .00000000000078699403323355317,
+ -.00000000000067020876961949060,
+ .00000000000016108575753932458,
+ .00000000000058527188436251509,
+ -.00000000000035246757297904791,
+ -.00000000000018372084495629058,
+ .00000000000088606689813494916,
+ .00000000000066486268071468700,
+ .00000000000063831615170646519,
+ .00000000000025144230728376072,
+ -.00000000000017239444525614834
+};
+
+#if !_lib_log
+
+extern double
+#ifdef _ANSI_SOURCE
+log(double x)
+#else
+log(x) double x;
+#endif
+{
+ int m, j;
+ double F, f, g, q, u, u2, v, zero = 0.0, one = 1.0;
+ volatile double u1;
+
+ /* Catch special cases */
+ if (x <= 0)
+ if (_IEEE && x == zero) /* log(0) = -Inf */
+ return (-one/zero);
+ else if (_IEEE) /* log(neg) = NaN */
+ return (zero/zero);
+ else if (x == zero) /* NOT REACHED IF _IEEE */
+ return (infnan(-ERANGE));
+ else
+ return (infnan(EDOM));
+ else if (!finite(x))
+ if (_IEEE) /* x = NaN, Inf */
+ return (x+x);
+ else
+ return (infnan(ERANGE));
+
+ /* Argument reduction: 1 <= g < 2; x/2^m = g; */
+ /* y = F*(1 + f/F) for |f| <= 2^-8 */
+
+ m = logb(x);
+ g = ldexp(x, -m);
+ if (_IEEE && m == -1022) {
+ j = logb(g), m += j;
+ g = ldexp(g, -j);
+ }
+ j = N*(g-1) + .5;
+ F = (1.0/N) * j + 1; /* F*128 is an integer in [128, 512] */
+ f = g - F;
+
+ /* Approximate expansion for log(1+f/F) ~= u + q */
+ g = 1/(2*F+f);
+ u = 2*f*g;
+ v = u*u;
+ q = u*v*(A1 + v*(A2 + v*(A3 + v*A4)));
+
+ /* case 1: u1 = u rounded to 2^-43 absolute. Since u < 2^-8,
+ * u1 has at most 35 bits, and F*u1 is exact, as F has < 8 bits.
+ * It also adds exactly to |m*log2_hi + log_F_head[j] | < 750
+ */
+ if (m | j)
+ u1 = u + 513, u1 -= 513;
+
+ /* case 2: |1-x| < 1/256. The m- and j- dependent terms are zero;
+ * u1 = u to 24 bits.
+ */
+ else
+ u1 = u, TRUNC(u1);
+ u2 = (2.0*(f - F*u1) - u1*f) * g;
+ /* u1 + u2 = 2f/(2F+f) to extra precision. */
+
+ /* log(x) = log(2^m*F*(1+f/F)) = */
+ /* (m*log2_hi+logF_head[j]+u1) + (m*log2_lo+logF_tail[j]+q); */
+ /* (exact) + (tiny) */
+
+ u1 += m*logF_head[N] + logF_head[j]; /* exact */
+ u2 = (u2 + logF_tail[j]) + q; /* tiny */
+ u2 += logF_tail[N]*m;
+ return (u1 + u2);
+}
+
+#endif
+
+/*
+ * Extra precision variant, returning struct {double a, b;};
+ * log(x) = a+b to 63 bits, with a is rounded to 26 bits.
+ */
+struct Double
+#ifdef _ANSI_SOURCE
+__log__D(double x)
+#else
+__log__D(x) double x;
+#endif
+{
+ int m, j;
+ double F, f, g, q, u, v, u2, one = 1.0;
+ volatile double u1;
+ struct Double r;
+
+ /* Argument reduction: 1 <= g < 2; x/2^m = g; */
+ /* y = F*(1 + f/F) for |f| <= 2^-8 */
+
+ m = (int)logb(x);
+ g = ldexp(x, -m);
+ if (_IEEE && m == -1022) {
+ j = (int)logb(g), m += j;
+ g = ldexp(g, -j);
+ }
+ j = (int)(N*(g-1) + .5);
+ F = (1.0/N) * j + 1;
+ f = g - F;
+
+ g = 1/(2*F+f);
+ u = 2*f*g;
+ v = u*u;
+ q = u*v*(A1 + v*(A2 + v*(A3 + v*A4)));
+ if (m | j)
+ u1 = u + 513, u1 -= 513;
+ else
+ u1 = u, TRUNC(u1);
+ u2 = (2.0*(f - F*u1) - u1*f) * g;
+
+ u1 += m*logF_head[N] + logF_head[j];
+
+ u2 += logF_tail[j]; u2 += q;
+ u2 += logF_tail[N]*m;
+ r.a = u1 + u2; /* Only difference is here */
+ TRUNC(r.a);
+ r.b = (u1 - r.a) + u2;
+ return (r);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/log1p.c b/usr/src/lib/libast/common/uwin/log1p.c
new file mode 100644
index 0000000000..1fad21f312
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/log1p.c
@@ -0,0 +1,176 @@
+#include "FEATURE/uwin"
+
+#if !_UWIN || _lib_log1p
+
+void _STUB_log1p(){}
+
+#else
+
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)log1p.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* LOG1P(x)
+ * RETURN THE LOGARITHM OF 1+x
+ * DOUBLE PRECISION (VAX D FORMAT 56 bits, IEEE DOUBLE 53 BITS)
+ * CODED IN C BY K.C. NG, 1/19/85;
+ * REVISED BY K.C. NG on 2/6/85, 3/7/85, 3/24/85, 4/16/85.
+ *
+ * Required system supported functions:
+ * scalb(x,n)
+ * copysign(x,y)
+ * logb(x)
+ * finite(x)
+ *
+ * Required kernel function:
+ * log__L(z)
+ *
+ * Method :
+ * 1. Argument Reduction: find k and f such that
+ * 1+x = 2^k * (1+f),
+ * where sqrt(2)/2 < 1+f < sqrt(2) .
+ *
+ * 2. Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
+ * = 2s + 2/3 s**3 + 2/5 s**5 + .....,
+ * log(1+f) is computed by
+ *
+ * log(1+f) = 2s + s*log__L(s*s)
+ * where
+ * log__L(z) = z*(L1 + z*(L2 + z*(... (L6 + z*L7)...)))
+ *
+ * See log__L() for the values of the coefficients.
+ *
+ * 3. Finally, log(1+x) = k*ln2 + log(1+f).
+ *
+ * Remarks 1. In step 3 n*ln2 will be stored in two floating point numbers
+ * n*ln2hi + n*ln2lo, where ln2hi is chosen such that the last
+ * 20 bits (for VAX D format), or the last 21 bits ( for IEEE
+ * double) is 0. This ensures n*ln2hi is exactly representable.
+ * 2. In step 1, f may not be representable. A correction term c
+ * for f is computed. It follows that the correction term for
+ * f - t (the leading term of log(1+f) in step 2) is c-c*x. We
+ * add this correction term to n*ln2lo to attenuate the error.
+ *
+ *
+ * Special cases:
+ * log1p(x) is NaN with signal if x < -1; log1p(NaN) is NaN with no signal;
+ * log1p(INF) is +INF; log1p(-1) is -INF with signal;
+ * only log1p(0)=0 is exact for finite argument.
+ *
+ * Accuracy:
+ * log1p(x) returns the exact log(1+x) nearly rounded. In a test run
+ * with 1,536,000 random arguments on a VAX, the maximum observed
+ * error was .846 ulps (units in the last place).
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+
+#include <errno.h>
+#include "mathimpl.h"
+
+vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000)
+vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC)
+vc(sqrt2, 1.4142135623730950622E0 ,04f3,40b5,de65,33f9, 1, .B504F333F9DE65)
+
+ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000)
+ic(ln2lo, 1.9082149292705877000E-10, -33, 1.A39EF35793C76)
+ic(sqrt2, 1.4142135623730951455E0, 0, 1.6A09E667F3BCD)
+
+#ifdef vccast
+#define ln2hi vccast(ln2hi)
+#define ln2lo vccast(ln2lo)
+#define sqrt2 vccast(sqrt2)
+#endif
+
+extern double log1p(x)
+double x;
+{
+ const static double zero=0.0, negone= -1.0, one=1.0,
+ half=1.0/2.0, small=1.0E-20; /* 1+small == 1 */
+ double z,s,t,c;
+ int k;
+
+#if !defined(vax)&&!defined(tahoe)
+ if(x!=x) return(x); /* x is NaN */
+#endif /* !defined(vax)&&!defined(tahoe) */
+
+ if(finite(x)) {
+ if( x > negone ) {
+
+ /* argument reduction */
+ if(copysign(x,one)<small) return(x);
+ k=(int)logb(one+x); z=scalb(x,-k); t=scalb(one,-k);
+ if(z+t >= sqrt2 )
+ { k += 1 ; z *= half; t *= half; }
+ t += negone; x = z + t;
+ c = (t-x)+z ; /* correction term for x */
+
+ /* compute log(1+x) */
+ s = x/(2+x); t = x*x*half;
+ c += (k*ln2lo-c*x);
+ z = c+s*(t+__log__L(s*s));
+ x += (z - t) ;
+
+ return(k*ln2hi+x);
+ }
+ /* end of if (x > negone) */
+
+ else {
+#if defined(vax)||defined(tahoe)
+ if ( x == negone )
+ return (infnan(-ERANGE)); /* -INF */
+ else
+ return (infnan(EDOM)); /* NaN */
+#else /* defined(vax)||defined(tahoe) */
+ /* x = -1, return -INF with signal */
+ if ( x == negone ) return( negone/zero );
+
+ /* negative argument for log, return NaN with signal */
+ else return ( zero / zero );
+#endif /* defined(vax)||defined(tahoe) */
+ }
+ }
+ /* end of if (finite(x)) */
+
+ /* log(-INF) is NaN */
+ else if(x<0)
+ return(zero/zero);
+
+ /* log(+INF) is INF */
+ else return(x);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/log__L.c b/usr/src/lib/libast/common/uwin/log__L.c
new file mode 100644
index 0000000000..3276e694bc
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/log__L.c
@@ -0,0 +1,116 @@
+#include "FEATURE/uwin"
+
+#if !_UWIN
+
+void _STUB_log__L(){}
+
+#else
+
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)log__L.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* log__L(Z)
+ * LOG(1+X) - 2S X
+ * RETURN --------------- WHERE Z = S*S, S = ------- , 0 <= Z <= .0294...
+ * S 2 + X
+ *
+ * DOUBLE PRECISION (VAX D FORMAT 56 bits or IEEE DOUBLE 53 BITS)
+ * KERNEL FUNCTION FOR LOG; TO BE USED IN LOG1P, LOG, AND POW FUNCTIONS
+ * CODED IN C BY K.C. NG, 1/19/85;
+ * REVISED BY K.C. Ng, 2/3/85, 4/16/85.
+ *
+ * Method :
+ * 1. Polynomial approximation: let s = x/(2+x).
+ * Based on log(1+x) = log(1+s) - log(1-s)
+ * = 2s + 2/3 s**3 + 2/5 s**5 + .....,
+ *
+ * (log(1+x) - 2s)/s is computed by
+ *
+ * z*(L1 + z*(L2 + z*(... (L7 + z*L8)...)))
+ *
+ * where z=s*s. (See the listing below for Lk's values.) The
+ * coefficients are obtained by a special Remez algorithm.
+ *
+ * Accuracy:
+ * Assuming no rounding error, the maximum magnitude of the approximation
+ * error (absolute) is 2**(-58.49) for IEEE double, and 2**(-63.63)
+ * for VAX D format.
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+
+#include "mathimpl.h"
+
+vc(L1, 6.6666666666666703212E-1 ,aaaa,402a,aac5,aaaa, 0, .AAAAAAAAAAAAC5)
+vc(L2, 3.9999999999970461961E-1 ,cccc,3fcc,2684,cccc, -1, .CCCCCCCCCC2684)
+vc(L3, 2.8571428579395698188E-1 ,4924,3f92,5782,92f8, -1, .92492492F85782)
+vc(L4, 2.2222221233634724402E-1 ,8e38,3f63,af2c,39b7, -2, .E38E3839B7AF2C)
+vc(L5, 1.8181879517064680057E-1 ,2eb4,3f3a,655e,cc39, -2, .BA2EB4CC39655E)
+vc(L6, 1.5382888777946145467E-1 ,8551,3f1d,781d,e8c5, -2, .9D8551E8C5781D)
+vc(L7, 1.3338356561139403517E-1 ,95b3,3f08,cd92,907f, -2, .8895B3907FCD92)
+vc(L8, 1.2500000000000000000E-1 ,0000,3f00,0000,0000, -2, .80000000000000)
+
+ic(L1, 6.6666666666667340202E-1, -1, 1.5555555555592)
+ic(L2, 3.9999999999416702146E-1, -2, 1.999999997FF24)
+ic(L3, 2.8571428742008753154E-1, -2, 1.24924941E07B4)
+ic(L4, 2.2222198607186277597E-1, -3, 1.C71C52150BEA6)
+ic(L5, 1.8183562745289935658E-1, -3, 1.74663CC94342F)
+ic(L6, 1.5314087275331442206E-1, -3, 1.39A1EC014045B)
+ic(L7, 1.4795612545334174692E-1, -3, 1.2F039F0085122)
+
+#ifdef vccast
+#define L1 vccast(L1)
+#define L2 vccast(L2)
+#define L3 vccast(L3)
+#define L4 vccast(L4)
+#define L5 vccast(L5)
+#define L6 vccast(L6)
+#define L7 vccast(L7)
+#define L8 vccast(L8)
+#endif
+
+double __log__L(z)
+double z;
+{
+#if defined(vax)||defined(tahoe)
+ return(z*(L1+z*(L2+z*(L3+z*(L4+z*(L5+z*(L6+z*(L7+z*L8))))))));
+#else /* defined(vax)||defined(tahoe) */
+ return(z*(L1+z*(L2+z*(L3+z*(L4+z*(L5+z*(L6+z*L7)))))));
+#endif /* defined(vax)||defined(tahoe) */
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/rand48.c b/usr/src/lib/libast/common/uwin/rand48.c
new file mode 100644
index 0000000000..06c6ec5f02
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/rand48.c
@@ -0,0 +1,177 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "FEATURE/uwin"
+
+#if !_UWIN || _lib_srand48
+
+void _STUB_srand48(){}
+
+#else
+
+#define drand48 ______drand48
+#define erand48 ______erand48
+#define jrand48 ______jrand48
+#define lcong48 ______lcong48
+#define lrand48 ______lrand48
+#define mrand48 ______mrand48
+#define nrand48 ______nrand48
+#define seed48 ______seed48
+#define srand48 ______srand48
+
+#include <stdlib.h>
+
+#undef drand48
+#undef erand48
+#undef jrand48
+#undef lcong48
+#undef lrand48
+#undef mrand48
+#undef nrand48
+#undef seed48
+#undef srand48
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+#define A 0x5DEECE66D
+#define A0 0X5
+#define A1 0xDEEC
+#define A2 0xE66D
+#define C 0xB
+#define XINIT 0x330E
+#define SCALE 3.55271e-15
+
+static unsigned short oldval[3];
+static unsigned short X[3] = { 0, 0, XINIT};
+static unsigned short a[3] = { A0, A1, A2};
+static unsigned short c = C;
+
+static void multadd(unsigned short x[3], unsigned short a[3], unsigned short c)
+{
+ register unsigned long r = c;
+ unsigned short x2 = x[2];
+ unsigned short x1 = x[1];
+ r += a[2]*x2;
+ x[2] = (unsigned short)r;
+ r >>= 16;
+ r += a[1]*x2;
+ r += a[2]*x1;
+ x[1] = (unsigned short)r;
+ r >>= 16;
+ r += a[2]*x[0];
+ r += a[1]*x1;
+ r += a[0]*x2;
+ x[0] = (unsigned short)r;
+}
+
+extern double drand48(void)
+{
+ double d;
+ unsigned long u;
+ multadd(X,a,c);
+ u = (X[0]<<16) + X[1];
+ d = (u*65536.) + X[2];
+ return(d*SCALE);
+}
+
+extern double erand48(unsigned short xsubi[3])
+{
+ double d;
+ unsigned long u;
+ multadd(xsubi,a,c);
+ u = (xsubi[0]<<16) + xsubi[1];
+ d = (u*65536.) + xsubi[2];
+ return(d*SCALE);
+}
+
+extern long jrand48(unsigned short xsubi[3])
+{
+ long u;
+ multadd(xsubi,a,c);
+ u = (xsubi[0]<<16) | xsubi[1];
+ return((long)u);
+}
+
+extern void lcong48(unsigned short param[7])
+{
+ X[0] = param[0];
+ X[1] = param[1];
+ X[2] = param[2];
+ a[0] = param[3];
+ a[1] = param[4];
+ a[2] = param[5];
+ c = param[6];
+}
+
+extern long lrand48(void)
+{
+ long l;
+ multadd(X,a,c);
+ l = (X[0]<<15)|(X[1]>>1);
+ return(l);
+}
+
+extern long mrand48(void)
+{
+ unsigned long u;
+ multadd(X,a,c);
+ u = (X[0]<<16) | X[1];
+ return((long)u);
+}
+
+extern long nrand48(unsigned short xsubi[3])
+{
+ long l;
+ multadd(xsubi,a,c);
+ l = (xsubi[0]<<15)|(xsubi[1]>>1);
+ return(l);
+}
+
+extern unsigned short *seed48(unsigned short seed[3])
+{
+ unsigned short *sp = (unsigned short*)&X;
+ a[0] = A0;
+ a[1] = A1;
+ a[2] = A2;
+ c = C;
+ oldval[0] = X[2];
+ oldval[1] = X[1];
+ oldval[2] = X[0];
+ X[0] = seed[2];
+ X[1] = seed[1];
+ X[2] = seed[0];
+ return(oldval);
+}
+
+extern void srand48(long seedval)
+{
+ a[0] = A0;
+ a[1] = A1;
+ a[2] = A2;
+ c = C;
+ X[0] = (unsigned short)(((unsigned long)seedval) >> 16);
+ X[1] = (unsigned short)seedval;
+ X[2] = XINIT;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/random.c b/usr/src/lib/libast/common/uwin/random.c
new file mode 100644
index 0000000000..6b46d631d9
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/random.c
@@ -0,0 +1,381 @@
+#include "FEATURE/uwin"
+
+#if !_UWIN || _lib_random
+
+void _STUB_random(){}
+
+#else
+
+/*
+ * Copyright (c) 1983
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * This is derived from the Berkeley source:
+ * @(#)random.c 5.5 (Berkeley) 7/6/88
+ * It was reworked for the GNU C Library by Roland McGrath.
+ */
+
+#define initstate ______initstate
+#define random ______random
+#define setstate ______setstate
+#define srandom ______srandom
+
+#include <errno.h>
+#include <limits.h>
+#include <stddef.h>
+#include <stdlib.h>
+
+#undef initstate
+#undef random
+#undef setstate
+#undef srandom
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern long int random();
+
+#define PTR char*
+
+/* An improved random number generation package. In addition to the standard
+ rand()/srand() like interface, this package also has a special state info
+ interface. The initstate() routine is called with a seed, an array of
+ bytes, and a count of how many bytes are being passed in; this array is
+ then initialized to contain information for random number generation with
+ that much state information. Good sizes for the amount of state
+ information are 32, 64, 128, and 256 bytes. The state can be switched by
+ calling the setstate() function with the same array as was initiallized
+ with initstate(). By default, the package runs with 128 bytes of state
+ information and generates far better random numbers than a linear
+ congruential generator. If the amount of state information is less than
+ 32 bytes, a simple linear congruential R.N.G. is used. Internally, the
+ state information is treated as an array of longs; the zeroeth element of
+ the array is the type of R.N.G. being used (small integer); the remainder
+ of the array is the state information for the R.N.G. Thus, 32 bytes of
+ state information will give 7 longs worth of state information, which will
+ allow a degree seven polynomial. (Note: The zeroeth word of state
+ information also has some other information stored in it; see setstate
+ for details). The random number generation technique is a linear feedback
+ shift register approach, employing trinomials (since there are fewer terms
+ to sum up that way). In this approach, the least significant bit of all
+ the numbers in the state table will act as a linear feedback shift register,
+ and will have period 2^deg - 1 (where deg is the degree of the polynomial
+ being used, assuming that the polynomial is irreducible and primitive).
+ The higher order bits will have longer periods, since their values are
+ also influenced by pseudo-random carries out of the lower bits. The
+ total period of the generator is approximately deg*(2**deg - 1); thus
+ doubling the amount of state information has a vast influence on the
+ period of the generator. Note: The deg*(2**deg - 1) is an approximation
+ only good for large deg, when the period of the shift register is the
+ dominant factor. With deg equal to seven, the period is actually much
+ longer than the 7*(2**7 - 1) predicted by this formula. */
+
+
+
+/* For each of the currently supported random number generators, we have a
+ break value on the amount of state information (you need at least thi
+ bytes of state info to support this random number generator), a degree for
+ the polynomial (actually a trinomial) that the R.N.G. is based on, and
+ separation between the two lower order coefficients of the trinomial. */
+
+/* Linear congruential. */
+#define TYPE_0 0
+#define BREAK_0 8
+#define DEG_0 0
+#define SEP_0 0
+
+/* x**7 + x**3 + 1. */
+#define TYPE_1 1
+#define BREAK_1 32
+#define DEG_1 7
+#define SEP_1 3
+
+/* x**15 + x + 1. */
+#define TYPE_2 2
+#define BREAK_2 64
+#define DEG_2 15
+#define SEP_2 1
+
+/* x**31 + x**3 + 1. */
+#define TYPE_3 3
+#define BREAK_3 128
+#define DEG_3 31
+#define SEP_3 3
+
+/* x**63 + x + 1. */
+#define TYPE_4 4
+#define BREAK_4 256
+#define DEG_4 63
+#define SEP_4 1
+
+
+/* Array versions of the above information to make code run faster.
+ Relies on fact that TYPE_i == i. */
+
+#define MAX_TYPES 5 /* Max number of types above. */
+
+static int degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 };
+static int seps[MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 };
+
+
+
+/* Initially, everything is set up as if from:
+ initstate(1, randtbl, 128);
+ Note that this initialization takes advantage of the fact that srandom
+ advances the front and rear pointers 10*rand_deg times, and hence the
+ rear pointer which starts at 0 will also end up at zero; thus the zeroeth
+ element of the state information, which contains info about the current
+ position of the rear pointer is just
+ (MAX_TYPES * (rptr - state)) + TYPE_3 == TYPE_3. */
+
+static long int randtbl[DEG_3 + 1] =
+ {
+ TYPE_3,
+ -851904987, -43806228, -2029755270, 1390239686, -1912102820,
+ -485608943, 1969813258, -1590463333, -1944053249, 455935928, 508023712,
+ -1714531963, 1800685987, -2015299881, 654595283, -1149023258,
+ -1470005550, -1143256056, -1325577603, -1568001885, 1275120390,
+ -607508183, -205999574, -1696891592, 1492211999, -1528267240,
+ -952028296, -189082757, 362343714, 1424981831, 2039449641,
+ };
+
+/* FPTR and RPTR are two pointers into the state info, a front and a rear
+ pointer. These two pointers are always rand_sep places aparts, as they
+ cycle through the state information. (Yes, this does mean we could get
+ away with just one pointer, but the code for random is more efficient
+ this way). The pointers are left positioned as they would be from the call:
+ initstate(1, randtbl, 128);
+ (The position of the rear pointer, rptr, is really 0 (as explained above
+ in the initialization of randtbl) because the state table pointer is set
+ to point to randtbl[1] (as explained below).) */
+
+static long int *fptr = &randtbl[SEP_3 + 1];
+static long int *rptr = &randtbl[1];
+
+
+
+/* The following things are the pointer to the state information table,
+ the type of the current generator, the degree of the current polynomial
+ being used, and the separation between the two pointers.
+ Note that for efficiency of random, we remember the first location of
+ the state information, not the zeroeth. Hence it is valid to access
+ state[-1], which is used to store the type of the R.N.G.
+ Also, we remember the last location, since this is more efficient than
+ indexing every time to find the address of the last element to see if
+ the front and rear pointers have wrapped. */
+
+static long int *state = &randtbl[1];
+
+static int rand_type = TYPE_3;
+static int rand_deg = DEG_3;
+static int rand_sep = SEP_3;
+
+static long int *end_ptr = &randtbl[sizeof(randtbl) / sizeof(randtbl[0])];
+
+/* Initialize the random number generator based on the given seed. If the
+ type is the trivial no-state-information type, just remember the seed.
+ Otherwise, initializes state[] based on the given "seed" via a linear
+ congruential generator. Then, the pointers are set to known locations
+ that are exactly rand_sep places apart. Lastly, it cycles the state
+ information a given number of times to get rid of any initial dependencies
+ introduced by the L.C.R.N.G. Note that the initialization of randtbl[]
+ for default usage relies on values produced by this routine. */
+extern void srandom(unsigned int x)
+{
+ state[0] = x;
+ if (rand_type != TYPE_0)
+ {
+ register long int i;
+ for (i = 1; i < rand_deg; ++i)
+ state[i] = (1103515145 * state[i - 1]) + 12345;
+ fptr = &state[rand_sep];
+ rptr = &state[0];
+ for (i = 0; i < 10 * rand_deg; ++i)
+ (void) random();
+ }
+}
+
+/* Initialize the state information in the given array of N bytes for
+ future random number generation. Based on the number of bytes we
+ are given, and the break values for the different R.N.G.'s, we choose
+ the best (largest) one we can and set things up for it. srandom is
+ then called to initialize the state information. Note that on return
+ from srandom, we set state[-1] to be the type multiplexed with the current
+ value of the rear pointer; this is so successive calls to initstate won't
+ lose this information and will be able to restart with setstate.
+ Note: The first thing we do is save the current state, if any, just like
+ setstate so that it doesn't matter when initstate is called.
+ Returns a pointer to the old state. */
+extern char* initstate(unsigned int seed, char* arg_state, size_t n)
+{
+ PTR ostate = (PTR) &state[-1];
+
+ if (rand_type == TYPE_0)
+ state[-1] = rand_type;
+ else
+ state[-1] = (MAX_TYPES * (rptr - state)) + rand_type;
+ if (n < BREAK_1)
+ {
+ if (n < BREAK_0)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+ rand_type = TYPE_0;
+ rand_deg = DEG_0;
+ rand_sep = SEP_0;
+ }
+ else if (n < BREAK_2)
+ {
+ rand_type = TYPE_1;
+ rand_deg = DEG_1;
+ rand_sep = SEP_1;
+ }
+ else if (n < BREAK_3)
+ {
+ rand_type = TYPE_2;
+ rand_deg = DEG_2;
+ rand_sep = SEP_2;
+ }
+ else if (n < BREAK_4)
+ {
+ rand_type = TYPE_3;
+ rand_deg = DEG_3;
+ rand_sep = SEP_3;
+ }
+ else
+ {
+ rand_type = TYPE_4;
+ rand_deg = DEG_4;
+ rand_sep = SEP_4;
+ }
+
+ state = &((long int *) arg_state)[1]; /* First location. */
+ /* Must set END_PTR before srandom. */
+ end_ptr = &state[rand_deg];
+ srandom(seed);
+ if (rand_type == TYPE_0)
+ state[-1] = rand_type;
+ else
+ state[-1] = (MAX_TYPES * (rptr - state)) + rand_type;
+
+ return ostate;
+}
+
+/* Restore the state from the given state array.
+ Note: It is important that we also remember the locations of the pointers
+ in the current state information, and restore the locations of the pointers
+ from the old state information. This is done by multiplexing the pointer
+ location into the zeroeth word of the state information. Note that due
+ to the order in which things are done, it is OK to call setstate with the
+ same state as the current state
+ Returns a pointer to the old state information. */
+extern char *setstate(const char *arg_state)
+{
+ register long int *new_state = (long int *) arg_state;
+ register int type = new_state[0] % MAX_TYPES;
+ register int rear = new_state[0] / MAX_TYPES;
+ PTR ostate = (PTR) &state[-1];
+
+ if (rand_type == TYPE_0)
+ state[-1] = rand_type;
+ else
+ state[-1] = (MAX_TYPES * (rptr - state)) + rand_type;
+
+ switch (type)
+ {
+ case TYPE_0:
+ case TYPE_1:
+ case TYPE_2:
+ case TYPE_3:
+ case TYPE_4:
+ rand_type = type;
+ rand_deg = degrees[type];
+ rand_sep = seps[type];
+ break;
+ default:
+ /* State info munged. */
+ errno = EINVAL;
+ return NULL;
+ }
+
+ state = &new_state[1];
+ if (rand_type != TYPE_0)
+ {
+ rptr = &state[rear];
+ fptr = &state[(rear + rand_sep) % rand_deg];
+ }
+ /* Set end_ptr too. */
+ end_ptr = &state[rand_deg];
+
+ return ostate;
+}
+
+/* If we are using the trivial TYPE_0 R.N.G., just do the old linear
+ congruential bit. Otherwise, we do our fancy trinomial stuff, which is the
+ same in all ther other cases due to all the global variables that have been
+ set up. The basic operation is to add the number at the rear pointer into
+ the one at the front pointer. Then both pointers are advanced to the next
+ location cyclically in the table. The value returned is the sum generated,
+ reduced to 31 bits by throwing away the "least random" low bit.
+ Note: The code takes advantage of the fact that both the front and
+ rear pointers can't wrap on the same call by not testing the rear
+ pointer if the front one has wrapped. Returns a 31-bit random number. */
+
+extern long int random()
+{
+ if (rand_type == TYPE_0)
+ {
+ state[0] = ((state[0] * 1103515245) + 12345) & LONG_MAX;
+ return state[0];
+ }
+ else
+ {
+ long int i;
+ *fptr += *rptr;
+ /* Chucking least random bit. */
+ i = (*fptr >> 1) & LONG_MAX;
+ ++fptr;
+ if (fptr >= end_ptr)
+ {
+ fptr = state;
+ ++rptr;
+ }
+ else
+ {
+ ++rptr;
+ if (rptr >= end_ptr)
+ rptr = state;
+ }
+ return i;
+ }
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/rcmd.c b/usr/src/lib/libast/common/uwin/rcmd.c
new file mode 100644
index 0000000000..af296840f6
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/rcmd.c
@@ -0,0 +1,571 @@
+#include "FEATURE/uwin"
+
+#if !_UWIN || _lib_rcmd
+
+void _STUB_rcmd(){}
+
+#else
+
+/*
+ * Copyright (c) 1983
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)rcmd.c 5.17 (Berkeley) 6/27/88";
+#endif /* LIBC_SCCS and not lint */
+
+#include "rlib.h"
+#include <pwd.h>
+#include <sys/file.h>
+#include <sys/signal.h>
+#if 1
+#define _PATH_HEQUIV "/etc/hosts.equiv"
+#endif
+#include <sys/stat.h>
+
+#if NLS
+#include "nl_types.h"
+#endif
+
+#ifdef YP
+#include <rpcsvc/ypclnt.h>
+extern void setnetgrent(const char *);
+extern void endnetgrent(void);
+extern int getnetgrent(char **, char **, char **);
+static char *nisdomain = NULL;
+static int _checknetgrouphost(const char *, const char *, int);
+static int _checknetgroupuser(const char *, const char *);
+#endif
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern int rresvport(int *alport)
+{
+ struct sockaddr_in sin;
+ int s;
+
+ sin.sin_family = AF_INET;
+ sin.sin_addr.s_addr = INADDR_ANY;
+ s = socket(AF_INET, SOCK_STREAM, 0);
+ if (s < 0)
+ return (-1);
+ for (;;) {
+ sin.sin_port = htons((u_short)*alport);
+ if (bind(s, (struct sockaddr *)&sin, sizeof (sin)) >= 0)
+ return (s);
+ if (errno != EADDRINUSE) {
+ (void) close(s);
+ return (-1);
+ }
+ (*alport)--;
+ if (*alport == IPPORT_RESERVED/2) {
+ (void) close(s);
+ errno = EAGAIN; /* close */
+ return (-1);
+ }
+ }
+}
+
+extern int rcmd(char **ahost, unsigned short rport, const char *locuser, const char *remuser, const char *cmd, int *fd2p)
+{
+ int s, timo = 1;
+#ifdef F_SETOWN
+ pid_t pid;
+#endif
+#ifdef _POSIX_SOURCE
+ sigset_t set, oset;
+#else
+ long oldmask;
+#endif
+ struct sockaddr_in sin, from;
+ char c;
+ int lport = IPPORT_RESERVED - 1;
+ struct hostent *hp;
+
+#if NLS
+ libc_nls_init();
+#endif
+
+#ifdef F_SETOWN
+ pid = getpid();
+#endif
+ hp = gethostbyname(*ahost);
+ if (hp == 0) {
+#if NLS
+ fprintf(stderr, "%s: %s\n", *ahost,
+ catgets(_libc_cat, HerrorListSet,
+ 2, "unknown host"));
+#else
+ fprintf(stderr, "%s: unknown host\n", *ahost);
+#endif
+ return (-1);
+ }
+ *ahost = hp->h_name;
+#ifdef SIGURG
+#ifdef _POSIX_SOURCE
+ sigemptyset (&set);
+ sigaddset (&set, SIGURG);
+ sigprocmask (SIG_BLOCK, &set, &oset);
+#else
+ oldmask = sigblock(sigmask(SIGURG));
+#endif
+#endif
+ for (;;) {
+ s = rresvport(&lport);
+ if (s < 0) {
+ if (errno == EAGAIN)
+#if NLS
+ fprintf(stderr, "socket: %s\n",
+ catgets(_libc_cat, NetMiscSet,
+ NetMiscAllPortsInUse,
+ "All ports in use"));
+#else
+ fprintf(stderr, "socket: All ports in use\n");
+#endif
+ else
+#if NLS
+ perror(catgets(_libc_cat, NetMiscSet,
+ NetMiscRcmdSocket,
+ "rcmd: socket"));
+#else
+perror("rcmd: socket");
+#endif
+#ifdef SIGURG
+#ifdef _POSIX_SOURCE
+sigprocmask (SIG_SETMASK, &oset,
+(sigset_t *)NULL);
+#else
+sigsetmask(oldmask);
+#endif
+#endif
+return (-1);
+ }
+#ifdef F_SETOWN
+ fcntl(s, F_SETOWN, pid);
+#endif
+ sin.sin_family = hp->h_addrtype;
+ bcopy(hp->h_addr_list[0], (caddr_t)&sin.sin_addr, hp->h_length);
+ sin.sin_port = rport;
+ if (connect(s, (struct sockaddr *)&sin, sizeof (sin)) >= 0)
+ break;
+ (void) close(s);
+ if (errno == EADDRINUSE) {
+ lport--;
+ continue;
+ }
+ if (errno == ECONNREFUSED && timo <= 16) {
+ sleep(timo);
+ timo *= 2;
+ continue;
+ }
+ if (hp->h_addr_list[1] != NULL) {
+ int oerrno = errno;
+
+ fprintf(stderr,
+#if NLS
+ "%s %s: ", catgets(_libc_cat, NetMiscSet,
+ NetMiscAllPortsInUse,
+ "connect to address"),
+ inet_ntoa(sin.sin_addr));
+
+#else
+
+ "connect to address %s: ", inet_ntoa(sin.sin_addr));
+#endif
+ errno = oerrno;
+ perror(0);
+ hp->h_addr_list++;
+ bcopy(hp->h_addr_list[0], (caddr_t)&sin.sin_addr,
+ hp->h_length);
+
+#if NLS
+ fprintf(stderr, catgets(_libc_cat, NetMiscSet,
+ NetMiscTrying,
+ "Trying %s...\n"),
+#else
+ fprintf(stderr, "Trying %s...\n",
+#endif
+ inet_ntoa(sin.sin_addr));
+ continue;
+ }
+ perror(hp->h_name);
+#ifdef SIGURG
+#ifdef _POSIX_SOURCE
+ sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL);
+#else
+ sigsetmask(oldmask);
+#endif
+#endif
+ return (-1);
+ }
+ lport--;
+ if (fd2p == 0) {
+ write(s, "", 1);
+ lport = 0;
+ } else {
+ char num[8];
+ int s2 = rresvport(&lport), s3;
+ int len = sizeof (from);
+
+ if (s2 < 0)
+ goto bad;
+ listen(s2, 1);
+ (void) snprintf(num, sizeof(num), "%d", lport);
+ if (write(s, num, strlen(num)+1) != strlen(num)+1) {
+#if NLS
+ perror(catgets(_libc_cat, NetMiscSet,
+ NetMiscSettingUpStderr,
+ "write: setting up stderr"));
+#else
+ perror("write: setting up stderr");
+#endif
+ (void) close(s2);
+ goto bad;
+ }
+ s3 = accept(s2, (struct sockaddr *)&from, &len);
+ (void) close(s2);
+ if (s3 < 0) {
+#if NLS
+ perror(catgets(_libc_cat, NetMiscSet,
+ NetMiscAccept,
+ "accept"));
+#else
+ perror("accept");
+#endif
+ lport = 0;
+ goto bad;
+ }
+ *fd2p = s3;
+ from.sin_port = ntohs((u_short)from.sin_port);
+ if (from.sin_family != AF_INET ||
+ from.sin_port >= IPPORT_RESERVED) {
+ fprintf(stderr,
+#if NLS
+ "%s\n",
+ catgets(_libc_cat, NetMiscSet,
+ NetMiscProtocolFailure,
+ "socket: protocol failure in circuit setup."));
+#else
+ "socket: protocol failure in circuit setup.\n");
+#endif
+ goto bad2;
+ }
+ }
+ (void) write(s, locuser, strlen(locuser)+1);
+ (void) write(s, remuser, strlen(remuser)+1);
+ (void) write(s, cmd, strlen(cmd)+1);
+ if (read(s, &c, 1) != 1) {
+ perror(*ahost);
+ goto bad2;
+ }
+ if (c != 0) {
+ while (read(s, &c, 1) == 1) {
+ (void) write(2, &c, 1);
+ if (c == '\n')
+ break;
+ }
+ goto bad2;
+ }
+#ifdef SIGURG
+#ifdef _POSIX_SOURCE
+ sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL);
+#else
+ sigsetmask(oldmask);
+#endif
+#endif
+ return (s);
+bad2:
+ if (lport)
+ (void) close(*fd2p);
+bad:
+ (void) close(s);
+#ifdef SIGURG
+#ifdef _POSIX_SOURCE
+ sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL);
+#else
+ sigsetmask(oldmask);
+#endif
+#endif
+ return (-1);
+}
+
+extern int ruserok(const char *rhost, int superuser, const char *ruser, const char *luser)
+{
+ FILE *hostf;
+ char fhost[MAXHOSTNAMELEN];
+ int first = 1;
+ register const char *sp;
+ register char *p;
+ int baselen = -1;
+ uid_t saveuid;
+
+ saveuid = geteuid();
+ sp = rhost;
+ p = fhost;
+ while (*sp) {
+ if (*sp == '.') {
+ if (baselen == -1)
+ baselen = sp - rhost;
+ *p++ = *sp++;
+ } else {
+ *p++ = isupper(*sp) ? tolower(*sp++) : *sp++;
+ }
+ }
+ *p = '\0';
+ hostf = superuser ? (FILE *)0 : fopen(_PATH_HEQUIV, "r");
+again:
+ if (hostf) {
+ if (!_validuser(hostf, fhost, luser, ruser, baselen)) {
+ (void) fclose(hostf);
+ seteuid(saveuid);
+ return(0);
+ }
+ (void) fclose(hostf);
+ }
+ if (first == 1) {
+ struct stat sbuf;
+ struct passwd *pwd;
+ char pbuf[MAXPATHLEN];
+
+ first = 0;
+ if ((pwd = getpwnam(luser)) == NULL)
+ return(-1);
+ (void)strcpy(pbuf, pwd->pw_dir);
+ (void)strcat(pbuf, "/.rhosts");
+ (void)seteuid(pwd->pw_uid);
+ if ((hostf = fopen(pbuf, "r")) == NULL) {
+ seteuid(saveuid);
+ return(-1);
+ }
+ (void)fstat(fileno(hostf), &sbuf);
+ if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid) {
+ fclose(hostf);
+ seteuid(saveuid);
+ return(-1);
+ }
+ goto again;
+ }
+ seteuid(saveuid);
+ return (-1);
+}
+
+int
+_validuser(FILE *hostf, const char *rhost, const char *luser,
+const char *ruser, int baselen)
+{
+ char *user;
+ char ahost[MAXHOSTNAMELEN];
+ register char *p;
+ int hostvalid = 0;
+ int uservalid = 0;
+
+ while (fgets(ahost, sizeof (ahost), hostf)) {
+ /* We need to get rid of all comments. */
+ p = strchr (ahost, '#');
+ if (p) *p = '\0';
+ p = ahost;
+ while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') {
+ *p = isupper(*p) ? tolower(*p) : *p;
+ p++;
+ }
+ if (*p == ' ' || *p == '\t') {
+ *p++ = '\0';
+ while (*p == ' ' || *p == '\t')
+ p++;
+ user = p;
+ while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0')
+ p++;
+ } else
+ user = p;
+ *p = '\0';
+ /* Adding new authentication -Nilendu */
+
+ /* enable all host for + entry */
+ if ('+' == ahost[0] && '\0' == ahost[1] )
+ hostvalid = 1;
+
+ /* enable all user for + entry */
+ if ('+' == user[0] && '\0' == user[1] )
+ uservalid = 1;
+
+ /* disable all host for - entry */
+ if ('-' == ahost[0] && '\0' == ahost[1] )
+ hostvalid = 0;
+
+ /* disable all user for - entry */
+ if ('-' == user[0] && '\0' == user[1] )
+ uservalid = 0;
+
+
+#ifdef YP
+ /* disable host from -hostname entry */
+ if ('-' == ahost[0] && '@' != ahost[1]
+ && _checkhost(rhost, &ahost[1], baselen))
+ return -1;
+ /* disable host from -@netgroup entry for host */
+ if ('-' == ahost[0] && '@' == ahost[1] && '\0' != ahost[2]
+ && _checknetgrouphost(rhost, &ahost[2], baselen))
+ return -1;
+ /* disable user from -user entry */
+ if ('\0' != *user && user[0] == '-' && user[1] != '@'
+ && !strcmp(&user[1], ruser))
+ return -1;
+ /* disable user from -@netgroup entry for user */
+ if ('\0' != *user && user[0] == '-' && user[1] == '@'
+ && user[2] != '\0' && _checknetgroupuser(ruser, &user[2]))
+ return -1;
+ /* enable host from +@netgroup entry for host */
+ if ('+' == ahost[0] && '@' == ahost[1] && '\0' != ahost[2])
+ hostvalid = _checknetgrouphost(rhost, &ahost[2], baselen);
+ else
+ hostvalid = _checkhost(rhost, ahost, baselen);
+ /* enable user from +@netgroup entry for user */
+ if ('\0' != *user && user[0] == '+'
+ && user[1] == '@' && user[2] != '\0')
+ uservalid = _checknetgroupuser(ruser, &user[2]);
+ else
+ uservalid = !strcmp(ruser, *user ? user : luser);
+
+ if (hostvalid && uservalid)
+ return 0;
+#else
+ hostvalid = hostvalid ? 1 : _checkhost(rhost, ahost, baselen);
+ uservalid = uservalid ? 1 : !stricmp(ruser,*user ? user : luser);
+ if (hostvalid && uservalid)
+ return 0;
+
+#endif /* YP */
+ hostvalid = uservalid = 0;
+ }
+ return (-1);
+}
+
+int
+_checkhost(const char *rhost, const char *lhost, int len)
+{
+ static char ldomain[MAXHOSTNAMELEN + 1];
+ static char *domainp = NULL;
+ static int nodomain = 0;
+ register char *cp;
+
+ if (len == -1)
+ return(!strcmp(rhost, lhost));
+ if (strncmp(rhost, lhost, len))
+ return(0);
+ if (!strcmp(rhost, lhost))
+ return(1);
+ if (*(lhost + len) != '\0')
+ return(0);
+ if (nodomain)
+ return(0);
+ if (!domainp) {
+ if (gethostname(ldomain, sizeof(ldomain)) == -1) {
+ nodomain = 1;
+ return(0);
+ }
+ ldomain[MAXHOSTNAMELEN] = (char) 0;
+ if ((domainp = index(ldomain, '.')) == (char *)NULL) {
+ nodomain = 1;
+ return(0);
+ }
+ for (cp = ++domainp; *cp; ++cp)
+ if (isupper(*cp))
+ *cp = tolower(*cp);
+ }
+ return(!strcmp(domainp, rhost + len +1));
+}
+
+#ifdef YP
+static int
+_checknetgrouphost(const char *rhost, const char *netgr, int baselen)
+{
+ char *host, *user, *domain;
+ int status;
+
+ if (NULL == nisdomain)
+ yp_get_default_domain(&nisdomain);
+
+ setnetgrent(netgr);
+ while (1)
+ {
+ while (1 == (status = getnetgrent(&host, &user, &domain))
+ && NULL == host
+ && NULL != domain
+ && 0 != strcmp(domain, nisdomain))
+ ; /* find valid host entry */
+
+ if (0 == status || NULL == host)
+ {
+ endnetgrent();
+ return 0;
+ }
+
+ if(1 == _checkhost(rhost, host, baselen))
+ {
+ endnetgrent();
+ return 1;
+ }
+ }
+}
+
+static int
+_checknetgroupuser(const char *ruser, const char *netgr)
+{
+ char *host, *user, *domain;
+ int status;
+
+ if (NULL == nisdomain)
+ yp_get_default_domain(&nisdomain);
+
+ setnetgrent(netgr);
+ while (1)
+ {
+ while (1 == (status = getnetgrent(&host, &user, &domain))
+ && NULL == user
+ && NULL != domain
+ && 0 != strcmp(domain, nisdomain))
+ ; /* find valid user entry */
+
+ if (0 == status || NULL == user)
+ {
+ endnetgrent();
+ return 0;
+ }
+
+ if(0 == strcmp(ruser, user))
+ {
+ endnetgrent();
+ return 1;
+ }
+ }
+}
+#endif /* YP */
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/rint.c b/usr/src/lib/libast/common/uwin/rint.c
new file mode 100644
index 0000000000..3a16fb5013
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/rint.c
@@ -0,0 +1,41 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "FEATURE/uwin"
+
+#if !_UWIN || _lib_ceil && _lib_floor && _lib_rint
+
+void _STUB_rint(){}
+
+#else
+
+#include <math.h>
+
+extern double rint(x)
+double x;
+{
+ double d = floor((x+=.5));
+ if(d==x && d/2.!=floor(d/2))
+ d = d-1;
+ return(d);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/uwin/support.c b/usr/src/lib/libast/common/uwin/support.c
new file mode 100644
index 0000000000..769444e358
--- /dev/null
+++ b/usr/src/lib/libast/common/uwin/support.c
@@ -0,0 +1,605 @@
+#include "FEATURE/uwin"
+
+#if !_UWIN || (_lib__copysign||_lib_copysign) && _lib_logb && (_lib__finite||_lib_finite) && (_lib_drem||_lib_remainder) && _lib_sqrt && _lib_ilogb && (_lib__scalb||_lib_scalb)
+
+void _STUB_support(){}
+
+#else
+
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)support.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/*
+ * Some IEEE standard 754 recommended functions and remainder and sqrt for
+ * supporting the C elementary functions.
+ ******************************************************************************
+ * WARNING:
+ * These codes are developed (in double) to support the C elementary
+ * functions temporarily. They are not universal, and some of them are very
+ * slow (in particular, drem and sqrt is extremely inefficient). Each
+ * computer system should have its implementation of these functions using
+ * its own assembler.
+ ******************************************************************************
+ *
+ * IEEE 754 required operations:
+ * drem(x,p)
+ * returns x REM y = x - [x/y]*y , where [x/y] is the integer
+ * nearest x/y; in half way case, choose the even one.
+ * sqrt(x)
+ * returns the square root of x correctly rounded according to
+ * the rounding mod.
+ *
+ * IEEE 754 recommended functions:
+ * (a) copysign(x,y)
+ * returns x with the sign of y.
+ * (b) scalb(x,N)
+ * returns x * (2**N), for integer values N.
+ * (c) logb(x)
+ * returns the unbiased exponent of x, a signed integer in
+ * double precision, except that logb(0) is -INF, logb(INF)
+ * is +INF, and logb(NAN) is that NAN.
+ * (d) finite(x)
+ * returns the value TRUE if -INF < x < +INF and returns
+ * FALSE otherwise.
+ *
+ *
+ * CODED IN C BY K.C. NG, 11/25/84;
+ * REVISED BY K.C. NG on 1/22/85, 2/13/85, 3/24/85.
+ */
+
+#include "mathimpl.h"
+
+#if defined(vax)||defined(tahoe) /* VAX D format */
+#include <errno.h>
+ static const unsigned short msign=0x7fff , mexp =0x7f80 ;
+ static const short prep1=57, gap=7, bias=129 ;
+ static const double novf=1.7E38, nunf=3.0E-39, zero=0.0 ;
+#else /* defined(vax)||defined(tahoe) */
+ static const unsigned short msign=0x7fff, mexp =0x7ff0 ;
+ static const short prep1=54, gap=4, bias=1023 ;
+ static const double novf=1.7E308, nunf=3.0E-308,zero=0.0;
+#endif /* defined(vax)||defined(tahoe) */
+
+#if !_lib__scalb || !_lib_scalb
+
+extern double _scalb(x,N)
+double x; double N;
+{
+ int k;
+
+#ifdef national
+ unsigned short *px=(unsigned short *) &x + 3;
+#else /* national */
+ unsigned short *px=(unsigned short *) &x;
+#endif /* national */
+
+ if( x == zero ) return(x);
+
+#if defined(vax)||defined(tahoe)
+ if( (k= *px & mexp ) != ~msign ) {
+ if (N < -260)
+ return(nunf*nunf);
+ else if (N > 260) {
+ return(copysign(infnan(ERANGE),x));
+ }
+#else /* defined(vax)||defined(tahoe) */
+ if( (k= *px & mexp ) != mexp ) {
+ if( N<-2100) return(nunf*nunf); else if(N>2100) return(novf+novf);
+ if( k == 0 ) {
+ x *= scalb(1.0,prep1); N -= prep1; return(scalb(x,N));}
+#endif /* defined(vax)||defined(tahoe) */
+
+ if((k = (k>>gap)+ N) > 0 )
+ if( k < (mexp>>gap) ) *px = (*px&~mexp) | (k<<gap);
+ else x=novf+novf; /* overflow */
+ else
+ if( k > -prep1 )
+ /* gradual underflow */
+ {*px=(*px&~mexp)|(short)(1<<gap); x *= scalb(1.0,k-1);}
+ else
+ return(nunf*nunf);
+ }
+ return(x);
+}
+
+#endif
+
+#if !_lib_scalb
+
+extern double scalb(x,N)
+double x; double N;
+{
+ return _scalb(x, N);
+}
+
+#endif
+
+#if !_lib__copysign
+
+extern double _copysign(x,y)
+double x,y;
+{
+#ifdef national
+ unsigned short *px=(unsigned short *) &x+3,
+ *py=(unsigned short *) &y+3;
+#else /* national */
+ unsigned short *px=(unsigned short *) &x,
+ *py=(unsigned short *) &y;
+#endif /* national */
+
+#if defined(vax)||defined(tahoe)
+ if ( (*px & mexp) == 0 ) return(x);
+#endif /* defined(vax)||defined(tahoe) */
+
+ *px = ( *px & msign ) | ( *py & ~msign );
+ return(x);
+}
+
+#endif
+
+#if !_lib_copysign
+
+extern double copysign(x,y)
+double x,y;
+{
+ return _copysign(x,y);
+}
+
+#endif
+
+#if !_lib_logb
+
+extern double logb(x)
+double x;
+{
+
+#ifdef national
+ short *px=(short *) &x+3, k;
+#else /* national */
+ short *px=(short *) &x, k;
+#endif /* national */
+
+#if defined(vax)||defined(tahoe)
+ return (int)(((*px&mexp)>>gap)-bias);
+#else /* defined(vax)||defined(tahoe) */
+ if( (k= *px & mexp ) != mexp )
+ if ( k != 0 )
+ return ( (k>>gap) - bias );
+ else if( x != zero)
+ return ( -1022.0 );
+ else
+ return(-(1.0/zero));
+ else if(x != x)
+ return(x);
+ else
+ {*px &= msign; return(x);}
+#endif /* defined(vax)||defined(tahoe) */
+}
+
+#endif
+
+#if !_lib__finite
+
+extern int _finite(x)
+double x;
+{
+#if defined(vax)||defined(tahoe)
+ return(1);
+#else /* defined(vax)||defined(tahoe) */
+#ifdef national
+ return( (*((short *) &x+3 ) & mexp ) != mexp );
+#else /* national */
+ return( (*((short *) &x ) & mexp ) != mexp );
+#endif /* national */
+#endif /* defined(vax)||defined(tahoe) */
+}
+
+#endif
+
+#if !_lib_finite
+
+extern int finite(x)
+double x;
+{
+ return _finite(x);
+}
+
+#endif
+
+#if !_lib_drem
+
+extern double drem(x,p)
+double x,p;
+{
+#if _lib_remainder
+ return remainder(x,p);
+#else
+ short sign;
+ double hp,dp,tmp;
+ unsigned short k;
+#ifdef national
+ unsigned short
+ *px=(unsigned short *) &x +3,
+ *pp=(unsigned short *) &p +3,
+ *pd=(unsigned short *) &dp +3,
+ *pt=(unsigned short *) &tmp+3;
+#else /* national */
+ unsigned short
+ *px=(unsigned short *) &x ,
+ *pp=(unsigned short *) &p ,
+ *pd=(unsigned short *) &dp ,
+ *pt=(unsigned short *) &tmp;
+#endif /* national */
+
+ *pp &= msign ;
+
+#if defined(vax)||defined(tahoe)
+ if( ( *px & mexp ) == ~msign ) /* is x a reserved operand? */
+#else /* defined(vax)||defined(tahoe) */
+ if( ( *px & mexp ) == mexp )
+#endif /* defined(vax)||defined(tahoe) */
+ return (x-p)-(x-p); /* create nan if x is inf */
+ if (p == zero) {
+#if defined(vax)||defined(tahoe)
+ return(infnan(EDOM));
+#else /* defined(vax)||defined(tahoe) */
+ return zero/zero;
+#endif /* defined(vax)||defined(tahoe) */
+ }
+
+#if defined(vax)||defined(tahoe)
+ if( ( *pp & mexp ) == ~msign ) /* is p a reserved operand? */
+#else /* defined(vax)||defined(tahoe) */
+ if( ( *pp & mexp ) == mexp )
+#endif /* defined(vax)||defined(tahoe) */
+ { if (p != p) return p; else return x;}
+
+ else if ( ((*pp & mexp)>>gap) <= 1 )
+ /* subnormal p, or almost subnormal p */
+ { double b; b=scalb(1.0,(int)prep1);
+ p *= b; x = drem(x,p); x *= b; return(drem(x,p)/b);}
+ else if ( p >= novf/2)
+ { p /= 2 ; x /= 2; return(drem(x,p)*2);}
+ else
+ {
+ dp=p+p; hp=p/2;
+ sign= *px & ~msign ;
+ *px &= msign ;
+ while ( x > dp )
+ {
+ k=(*px & mexp) - (*pd & mexp) ;
+ tmp = dp ;
+ *pt += k ;
+
+#if defined(vax)||defined(tahoe)
+ if( x < tmp ) *pt -= 128 ;
+#else /* defined(vax)||defined(tahoe) */
+ if( x < tmp ) *pt -= 16 ;
+#endif /* defined(vax)||defined(tahoe) */
+
+ x -= tmp ;
+ }
+ if ( x > hp )
+ { x -= p ; if ( x >= hp ) x -= p ; }
+
+#if defined(vax)||defined(tahoe)
+ if (x)
+#endif /* defined(vax)||defined(tahoe) */
+ *px ^= sign;
+ return( x);
+
+ }
+#endif
+}
+
+#endif
+
+#if !_lib_remainder
+
+extern double remainder(x,p)
+double x,p;
+{
+ return drem(x,p);
+}
+
+#endif
+
+#if !_lib_sqrt
+
+extern double sqrt(x)
+double x;
+{
+ double q,s,b,r;
+ double t;
+ double const zero=0.0;
+ int m,n,i;
+#if defined(vax)||defined(tahoe)
+ int k=54;
+#else /* defined(vax)||defined(tahoe) */
+ int k=51;
+#endif /* defined(vax)||defined(tahoe) */
+
+ /* sqrt(NaN) is NaN, sqrt(+-0) = +-0 */
+ if(x!=x||x==zero) return(x);
+
+ /* sqrt(negative) is invalid */
+ if(x<zero) {
+#if defined(vax)||defined(tahoe)
+ return (infnan(EDOM)); /* NaN */
+#else /* defined(vax)||defined(tahoe) */
+ return(zero/zero);
+#endif /* defined(vax)||defined(tahoe) */
+ }
+
+ /* sqrt(INF) is INF */
+ if(!finite(x)) return(x);
+
+ /* scale x to [1,4) */
+ n=logb(x);
+ x=scalb(x,-n);
+ if((m=logb(x))!=0) x=scalb(x,-m); /* subnormal number */
+ m += n;
+ n = m/2;
+ if((n+n)!=m) {x *= 2; m -=1; n=m/2;}
+
+ /* generate sqrt(x) bit by bit (accumulating in q) */
+ q=1.0; s=4.0; x -= 1.0; r=1;
+ for(i=1;i<=k;i++) {
+ t=s+1; x *= 4; r /= 2;
+ if(t<=x) {
+ s=t+t+2, x -= t; q += r;}
+ else
+ s *= 2;
+ }
+
+ /* generate the last bit and determine the final rounding */
+ r/=2; x *= 4;
+ if(x==zero) goto end; 100+r; /* trigger inexact flag */
+ if(s<x) {
+ q+=r; x -=s; s += 2; s *= 2; x *= 4;
+ t = (x-s)-5;
+ b=1.0+3*r/4; if(b==1.0) goto end; /* b==1 : Round-to-zero */
+ b=1.0+r/4; if(b>1.0) t=1; /* b>1 : Round-to-(+INF) */
+ if(t>=0) q+=r; } /* else: Round-to-nearest */
+ else {
+ s *= 2; x *= 4;
+ t = (x-s)-1;
+ b=1.0+3*r/4; if(b==1.0) goto end;
+ b=1.0+r/4; if(b>1.0) t=1;
+ if(t>=0) q+=r; }
+
+end: return(scalb(q,n));
+}
+
+#endif
+
+#if 0
+/* DREM(X,Y)
+ * RETURN X REM Y =X-N*Y, N=[X/Y] ROUNDED (ROUNDED TO EVEN IN THE HALF WAY CASE)
+ * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS)
+ * INTENDED FOR ASSEMBLY LANGUAGE
+ * CODED IN C BY K.C. NG, 3/23/85, 4/8/85.
+ *
+ * Warning: this code should not get compiled in unless ALL of
+ * the following machine-dependent routines are supplied.
+ *
+ * Required machine dependent functions (not on a VAX):
+ * swapINX(i): save inexact flag and reset it to "i"
+ * swapENI(e): save inexact enable and reset it to "e"
+ */
+
+extern double drem(x,y)
+double x,y;
+{
+
+#ifdef national /* order of words in floating point number */
+ static const n0=3,n1=2,n2=1,n3=0;
+#else /* VAX, SUN, ZILOG, TAHOE */
+ static const n0=0,n1=1,n2=2,n3=3;
+#endif
+
+ static const unsigned short mexp =0x7ff0, m25 =0x0190, m57 =0x0390;
+ static const double zero=0.0;
+ double hy,y1,t,t1;
+ short k;
+ long n;
+ int i,e;
+ unsigned short xexp,yexp, *px =(unsigned short *) &x ,
+ nx,nf, *py =(unsigned short *) &y ,
+ sign, *pt =(unsigned short *) &t ,
+ *pt1 =(unsigned short *) &t1 ;
+
+ xexp = px[n0] & mexp ; /* exponent of x */
+ yexp = py[n0] & mexp ; /* exponent of y */
+ sign = px[n0] &0x8000; /* sign of x */
+
+/* return NaN if x is NaN, or y is NaN, or x is INF, or y is zero */
+ if(x!=x) return(x); if(y!=y) return(y); /* x or y is NaN */
+ if( xexp == mexp ) return(zero/zero); /* x is INF */
+ if(y==zero) return(y/y);
+
+/* save the inexact flag and inexact enable in i and e respectively
+ * and reset them to zero
+ */
+ i=swapINX(0); e=swapENI(0);
+
+/* subnormal number */
+ nx=0;
+ if(yexp==0) {t=1.0,pt[n0]+=m57; y*=t; nx=m57;}
+
+/* if y is tiny (biased exponent <= 57), scale up y to y*2**57 */
+ if( yexp <= m57 ) {py[n0]+=m57; nx+=m57; yexp+=m57;}
+
+ nf=nx;
+ py[n0] &= 0x7fff;
+ px[n0] &= 0x7fff;
+
+/* mask off the least significant 27 bits of y */
+ t=y; pt[n3]=0; pt[n2]&=0xf800; y1=t;
+
+/* LOOP: argument reduction on x whenever x > y */
+loop:
+ while ( x > y )
+ {
+ t=y;
+ t1=y1;
+ xexp=px[n0]&mexp; /* exponent of x */
+ k=xexp-yexp-m25;
+ if(k>0) /* if x/y >= 2**26, scale up y so that x/y < 2**26 */
+ {pt[n0]+=k;pt1[n0]+=k;}
+ n=x/t; x=(x-n*t1)-n*(t-t1);
+ }
+ /* end while (x > y) */
+
+ if(nx!=0) {t=1.0; pt[n0]+=nx; x*=t; nx=0; goto loop;}
+
+/* final adjustment */
+
+ hy=y/2.0;
+ if(x>hy||((x==hy)&&n%2==1)) x-=y;
+ px[n0] ^= sign;
+ if(nf!=0) { t=1.0; pt[n0]-=nf; x*=t;}
+
+/* restore inexact flag and inexact enable */
+ swapINX(i); swapENI(e);
+
+ return(x);
+}
+#endif
+
+#if 0
+/* SQRT
+ * RETURN CORRECTLY ROUNDED (ACCORDING TO THE ROUNDING MODE) SQRT
+ * FOR IEEE DOUBLE PRECISION ONLY, INTENDED FOR ASSEMBLY LANGUAGE
+ * CODED IN C BY K.C. NG, 3/22/85.
+ *
+ * Warning: this code should not get compiled in unless ALL of
+ * the following machine-dependent routines are supplied.
+ *
+ * Required machine dependent functions:
+ * swapINX(i) ...return the status of INEXACT flag and reset it to "i"
+ * swapRM(r) ...return the current Rounding Mode and reset it to "r"
+ * swapENI(e) ...return the status of inexact enable and reset it to "e"
+ * addc(t) ...perform t=t+1 regarding t as a 64 bit unsigned integer
+ * subc(t) ...perform t=t-1 regarding t as a 64 bit unsigned integer
+ */
+
+static const unsigned long table[] = {
+0, 1204, 3062, 5746, 9193, 13348, 18162, 23592, 29598, 36145, 43202, 50740,
+58733, 67158, 75992, 85215, 83599, 71378, 60428, 50647, 41945, 34246, 27478,
+21581, 16499, 12183, 8588, 5674, 3403, 1742, 661, 130, };
+
+extern double newsqrt(x)
+double x;
+{
+ double y,z,t,addc(),subc()
+ double const b54=134217728.*134217728.; /* b54=2**54 */
+ long mx,scalx;
+ long const mexp=0x7ff00000;
+ int i,j,r,e,swapINX(),swapRM(),swapENI();
+ unsigned long *py=(unsigned long *) &y ,
+ *pt=(unsigned long *) &t ,
+ *px=(unsigned long *) &x ;
+#ifdef national /* ordering of word in a floating point number */
+ const int n0=1, n1=0;
+#else
+ const int n0=0, n1=1;
+#endif
+/* Rounding Mode: RN ...round-to-nearest
+ * RZ ...round-towards 0
+ * RP ...round-towards +INF
+ * RM ...round-towards -INF
+ */
+ const int RN=0,RZ=1,RP=2,RM=3;
+ /* machine dependent: work on a Zilog Z8070
+ * and a National 32081 & 16081
+ */
+
+/* exceptions */
+ if(x!=x||x==0.0) return(x); /* sqrt(NaN) is NaN, sqrt(+-0) = +-0 */
+ if(x<0) return((x-x)/(x-x)); /* sqrt(negative) is invalid */
+ if((mx=px[n0]&mexp)==mexp) return(x); /* sqrt(+INF) is +INF */
+
+/* save, reset, initialize */
+ e=swapENI(0); /* ...save and reset the inexact enable */
+ i=swapINX(0); /* ...save INEXACT flag */
+ r=swapRM(RN); /* ...save and reset the Rounding Mode to RN */
+ scalx=0;
+
+/* subnormal number, scale up x to x*2**54 */
+ if(mx==0) {x *= b54 ; scalx-=0x01b00000;}
+
+/* scale x to avoid intermediate over/underflow:
+ * if (x > 2**512) x=x/2**512; if (x < 2**-512) x=x*2**512 */
+ if(mx>0x5ff00000) {px[n0] -= 0x20000000; scalx+= 0x10000000;}
+ if(mx<0x1ff00000) {px[n0] += 0x20000000; scalx-= 0x10000000;}
+
+/* magic initial approximation to almost 8 sig. bits */
+ py[n0]=(px[n0]>>1)+0x1ff80000;
+ py[n0]=py[n0]-table[(py[n0]>>15)&31];
+
+/* Heron's rule once with correction to improve y to almost 18 sig. bits */
+ t=x/y; y=y+t; py[n0]=py[n0]-0x00100006; py[n1]=0;
+
+/* triple to almost 56 sig. bits; now y approx. sqrt(x) to within 1 ulp */
+ t=y*y; z=t; pt[n0]+=0x00100000; t+=z; z=(x-z)*y;
+ t=z/(t+x) ; pt[n0]+=0x00100000; y+=t;
+
+/* twiddle last bit to force y correctly rounded */
+ swapRM(RZ); /* ...set Rounding Mode to round-toward-zero */
+ swapINX(0); /* ...clear INEXACT flag */
+ swapENI(e); /* ...restore inexact enable status */
+ t=x/y; /* ...chopped quotient, possibly inexact */
+ j=swapINX(i); /* ...read and restore inexact flag */
+ if(j==0) { if(t==y) goto end; else t=subc(t); } /* ...t=t-ulp */
+ b54+0.1; /* ..trigger inexact flag, sqrt(x) is inexact */
+ if(r==RN) t=addc(t); /* ...t=t+ulp */
+ else if(r==RP) { t=addc(t);y=addc(y);}/* ...t=t+ulp;y=y+ulp; */
+ y=y+t; /* ...chopped sum */
+ py[n0]=py[n0]-0x00100000; /* ...correctly rounded sqrt(x) */
+end: py[n0]=py[n0]+scalx; /* ...scale back y */
+ swapRM(r); /* ...restore Rounding Mode */
+ return(y);
+}
+#endif
+
+#if !_lib_ilogb
+
+extern int ilogb(double x)
+{
+ return((int)logb(x));
+}
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/vec/vecargs.c b/usr/src/lib/libast/common/vec/vecargs.c
new file mode 100644
index 0000000000..e30cd3b689
--- /dev/null
+++ b/usr/src/lib/libast/common/vec/vecargs.c
@@ -0,0 +1,76 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * string vector argv insertion
+ */
+
+#include <ast.h>
+#include <vecargs.h>
+#include <ctype.h>
+
+/*
+ * insert the string vector vec between
+ * (*argvp)[0] and (*argvp)[1], sliding (*argvp)[1] ... over
+ * null and blank args are deleted
+ *
+ * vecfree always called
+ *
+ * -1 returned if insertion failed
+ */
+
+int
+vecargs(register char** vec, int* argcp, char*** argvp)
+{
+ register char** argv;
+ register char** oargv;
+ char** ovec;
+ char* s;
+ int num;
+
+ if (!vec) return(-1);
+ if ((num = (char**)(*(vec - 1)) - vec) > 0)
+ {
+ if (!(argv = newof(0, char*, num + *argcp + 1, 0)))
+ {
+ vecfree(vec, 0);
+ return(-1);
+ }
+ oargv = *argvp;
+ *argvp = argv;
+ *argv++ = *oargv++;
+ ovec = vec;
+ while (s = *argv = *vec++)
+ {
+ while (isspace(*s)) s++;
+ if (*s) argv++;
+ }
+ vecfree(ovec, 1);
+ while (*argv = *oargv++) argv++;
+ *argcp = argv - *argvp;
+ }
+ else vecfree(vec, 0);
+ return(0);
+}
diff --git a/usr/src/lib/libast/common/vec/vecfile.c b/usr/src/lib/libast/common/vec/vecfile.c
new file mode 100644
index 0000000000..0a81b31b1a
--- /dev/null
+++ b/usr/src/lib/libast/common/vec/vecfile.c
@@ -0,0 +1,62 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * string vector load support
+ */
+
+#include <ast.h>
+#include <ls.h>
+#include <vecargs.h>
+
+/*
+ * load a string vector from lines in file
+ */
+
+char**
+vecfile(const char* file)
+{
+ register int n;
+ register char* buf;
+ register char** vec;
+ int fd;
+ struct stat st;
+
+ vec = 0;
+ if ((fd = open(file, O_RDONLY)) >= 0)
+ {
+ if (!fstat(fd, &st) && S_ISREG(st.st_mode) && (n = st.st_size) > 0 && (buf = newof(0, char, n + 1, 0)))
+ {
+ if (read(fd, buf, n) == n)
+ {
+ buf[n] = 0;
+ vec = vecload(buf);
+ }
+ if (!vec) free(buf);
+ }
+ close(fd);
+ }
+ return(vec);
+}
diff --git a/usr/src/lib/libast/common/vec/vecfree.c b/usr/src/lib/libast/common/vec/vecfree.c
new file mode 100644
index 0000000000..474fbc98d2
--- /dev/null
+++ b/usr/src/lib/libast/common/vec/vecfree.c
@@ -0,0 +1,48 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * file to string vector support
+ */
+
+#include <ast.h>
+#include <vecargs.h>
+
+/*
+ * free a string vector generated by vecload()
+ *
+ * retain!=0 frees the string pointers but retains the string data
+ * in this case the data is permanently allocated
+ */
+
+void
+vecfree(register char** vec, int retain)
+{
+ if (vec)
+ {
+ if (*(vec -= 2) && !retain) free(*vec);
+ free(vec);
+ }
+}
diff --git a/usr/src/lib/libast/common/vec/vecload.c b/usr/src/lib/libast/common/vec/vecload.c
new file mode 100644
index 0000000000..6439ae1091
--- /dev/null
+++ b/usr/src/lib/libast/common/vec/vecload.c
@@ -0,0 +1,96 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * string vector load support
+ */
+
+#include <ast.h>
+#include <vecargs.h>
+
+/*
+ * load a string vector from lines in buf
+ * buf may be modified on return
+ *
+ * each line in buf is treated as a new vector element
+ * lines with # as first char are comments
+ * \ as the last char joins consecutive lines
+ *
+ * the vector ends with a 0 sentinel
+ *
+ * the string array pointer is returned
+ */
+
+char**
+vecload(char* buf)
+{
+ register char* s;
+ register int n;
+ register char** p;
+ char** vec;
+
+ vec = 0;
+ n = (*buf == '#') ? -1 : 0;
+ for (s = buf;; s++)
+ {
+ if (*s == '\n')
+ {
+ if (s > buf && *(s - 1) == '\\') *(s - 1) = *s = ' ';
+ else
+ {
+ *s = 0;
+ if (*(s + 1) != '#')
+ {
+ n++;
+ if (!*(s + 1)) break;
+ }
+ }
+ }
+ else if (!*s)
+ {
+ n++;
+ break;
+ }
+ }
+ if (n < 0) n = 0;
+ if (p = newof(0, char*, n + 3, 0))
+ {
+ *p++ = s = buf;
+ vec = ++p;
+ if (n > 0) for (;;)
+ {
+ if (*s != '#')
+ {
+ *p++ = s;
+ if (--n <= 0) break;
+ }
+ while (*s) s++;
+ s++;
+ }
+ *p = 0;
+ *(vec - 1) = (char*)p;
+ }
+ return(vec);
+}
diff --git a/usr/src/lib/libast/common/vec/vecstring.c b/usr/src/lib/libast/common/vec/vecstring.c
new file mode 100644
index 0000000000..a4be2a9e0a
--- /dev/null
+++ b/usr/src/lib/libast/common/vec/vecstring.c
@@ -0,0 +1,46 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * string vector load support
+ */
+
+#include <ast.h>
+#include <vecargs.h>
+
+/*
+ * load a string vector from lines in str
+ */
+
+char**
+vecstring(const char* str)
+{
+ register char* buf;
+ register char** vec;
+
+ if (!str || !*str || !(buf = strdup(str))) vec = 0;
+ else if (!(vec = vecload(buf))) free(buf);
+ return(vec);
+}
diff --git a/usr/src/lib/libast/common/vmalloc/malloc.c b/usr/src/lib/libast/common/vmalloc/malloc.c
new file mode 100644
index 0000000000..24241d7b46
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/malloc.c
@@ -0,0 +1,919 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_malloc(){}
+
+#else
+
+#if _UWIN
+
+#define calloc ______calloc
+#define _ast_free ______free
+#define malloc ______malloc
+#define mallinfo ______mallinfo
+#define mallopt ______mallopt
+#define mstats ______mstats
+#define realloc ______realloc
+
+#define _STDLIB_H_ 1
+
+extern int atexit(void(*)(void));
+extern char* getenv(const char*);
+
+#endif
+
+#include "vmhdr.h"
+
+#if _UWIN
+
+#include <malloc.h>
+
+#define _map_malloc 1
+#define _mal_alloca 1
+
+#undef calloc
+#define calloc _ast_calloc
+#undef _ast_free
+#define free _ast_free
+#undef malloc
+#define malloc _ast_malloc
+#undef mallinfo
+typedef struct ______mallinfo Mallinfo_t;
+#undef mallopt
+#undef mstats
+typedef struct ______mstats Mstats_t;
+#undef realloc
+#define realloc _ast_realloc
+
+#endif
+
+#if __STD_C
+#define F0(f,t0) f(t0)
+#define F1(f,t1,a1) f(t1 a1)
+#define F2(f,t1,a1,t2,a2) f(t1 a1, t2 a2)
+#else
+#define F0(f,t0) f()
+#define F1(f,t1,a1) f(a1) t1 a1;
+#define F2(f,t1,a1,t2,a2) f(a1, a2) t1 a1; t2 a2;
+#endif
+
+/*
+ * define _AST_std_malloc=1 to force the standard malloc
+ * if _map_malloc is also defined then _ast_malloc etc.
+ * will simply call malloc etc.
+ */
+
+#if !defined(_AST_std_malloc) && __CYGWIN__
+#define _AST_std_malloc 1
+#endif
+
+#if ( !_std_malloc || !_BLD_ast ) && !_AST_std_malloc
+
+/* malloc compatibility functions.
+** These are aware of debugging/profiling and driven by the environment variables:
+** VMETHOD: select an allocation method by name.
+**
+** VMPROFILE: if is a file name, write profile data to it.
+** VMTRACE: if is a file name, write trace data to it.
+** The pattern %p in a file name will be replaced by the process ID.
+**
+** VMDEBUG:
+** a: abort on any warning.
+** w[decimal]: file descriptor for warnings.
+** [decimal]: period to check arena.
+** 0x[hexadecimal]: address to watch.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+
+#if _sys_stat
+#include <sys/stat.h>
+#endif
+#include <fcntl.h>
+
+#ifdef S_IRUSR
+#define CREAT_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
+#else
+#define CREAT_MODE 0644
+#endif
+
+#if !_map_malloc
+#undef calloc
+#undef cfree
+#undef free
+#undef mallinfo
+#undef malloc
+#undef mallopt
+#undef memalign
+#undef mstats
+#undef realloc
+#undef valloc
+#endif
+
+#if _WINIX
+
+#include <ast_windows.h>
+
+#if _UWIN
+
+#define VMRECORD(p) _vmrecord(p)
+#define VMBLOCK { int _vmblock = _sigblock();
+#define VMUNBLOCK _sigunblock(_vmblock); }
+
+extern int _sigblock(void);
+extern void _sigunblock(int);
+extern unsigned long _record[2048];
+
+__inline Void_t* _vmrecord(Void_t* p)
+{
+ register unsigned long v = ((unsigned long)p)>>16;
+
+ _record[v>>5] |= 1<<((v&0x1f));
+ return p;
+}
+
+#else
+
+#define getenv(s) lcl_getenv(s)
+
+static char*
+lcl_getenv(const char* s)
+{
+ int n;
+ static char buf[512];
+
+ if (!(n = GetEnvironmentVariable(s, buf, sizeof(buf))) || n > sizeof(buf))
+ return 0;
+ return buf;
+}
+
+#endif /* _UWIN */
+
+#endif /* _WINIX */
+
+#ifndef VMRECORD
+#define VMRECORD(p) (p)
+#define VMBLOCK
+#define VMUNBLOCK
+#endif
+
+#if defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+
+#if __STD_C
+static Vmulong_t atou(char** sp)
+#else
+static Vmulong_t atou(sp)
+char** sp;
+#endif
+{
+ char* s = *sp;
+ Vmulong_t v = 0;
+
+ if(s[0] == '0' && (s[1] == 'x' || s[1] == 'X') )
+ { for(s += 2; *s; ++s)
+ { if(*s >= '0' && *s <= '9')
+ v = (v << 4) + (*s - '0');
+ else if(*s >= 'a' && *s <= 'f')
+ v = (v << 4) + (*s - 'a') + 10;
+ else if(*s >= 'A' && *s <= 'F')
+ v = (v << 4) + (*s - 'A') + 10;
+ else break;
+ }
+ }
+ else
+ { for(; *s; ++s)
+ { if(*s >= '0' && *s <= '9')
+ v = v*10 + (*s - '0');
+ else break;
+ }
+ }
+
+ *sp = s;
+ return v;
+}
+
+static int _Vmflinit = 0;
+static Vmulong_t _Vmdbstart = 0;
+static Vmulong_t _Vmdbcheck = 0;
+static Vmulong_t _Vmdbtime = 0;
+static int _Vmpffd = -1;
+#define VMFLINIT() \
+ { if(!_Vmflinit) vmflinit(); \
+ if(_Vmdbcheck) \
+ { if(_Vmdbtime < _Vmdbstart) _Vmdbtime += 1; \
+ else if((_Vmdbtime += 1) < _Vmdbstart) _Vmdbtime = _Vmdbstart; \
+ if(_Vmdbtime >= _Vmdbstart && (_Vmdbtime % _Vmdbcheck) == 0 && \
+ Vmregion->meth.meth == VM_MTDEBUG) \
+ vmdbcheck(Vmregion); \
+ } \
+ }
+
+#if __STD_C
+static char* insertpid(char* begs, char* ends)
+#else
+static char* insertpid(begs,ends)
+char* begs;
+char* ends;
+#endif
+{ int pid;
+ char* s;
+
+ if((pid = getpid()) < 0)
+ return NIL(char*);
+
+ s = ends;
+ do
+ { if(s == begs)
+ return NIL(char*);
+ *--s = '0' + pid%10;
+ } while((pid /= 10) > 0);
+ while(s < ends)
+ *begs++ = *s++;
+
+ return begs;
+}
+
+#if __STD_C
+static int createfile(char* file)
+#else
+static int createfile(file)
+char* file;
+#endif
+{
+ char buf[1024];
+ char *next, *endb;
+
+ next = buf;
+ endb = buf + sizeof(buf);
+ while(*file)
+ { if(*file == '%')
+ { switch(file[1])
+ {
+ case 'p' :
+ if(!(next = insertpid(next,endb)) )
+ return -1;
+ file += 2;
+ break;
+ default :
+ goto copy;
+ }
+ }
+ else
+ { copy:
+ *next++ = *file++;
+ }
+
+ if(next >= endb)
+ return -1;
+ }
+
+ *next = '\0';
+#if _PACKAGE_ast
+ { int fd;
+ fd = open(buf,O_WRONLY|O_CREAT|O_TRUNC,CREAT_MODE);
+#ifdef FD_CLOEXEC
+ if (fd >= 0)
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
+#endif
+ return fd;
+ }
+#else
+ return creat(buf,CREAT_MODE);
+#endif
+}
+
+#if __STD_C
+static void pfprint(void)
+#else
+static void pfprint()
+#endif
+{
+ if(Vmregion->meth.meth == VM_MTPROFILE)
+ vmprofile(Vmregion,_Vmpffd);
+}
+
+#if __STD_C
+static int vmflinit(void)
+#else
+static int vmflinit()
+#endif
+{
+ char* env;
+ Vmalloc_t* vm;
+ int fd;
+ Vmulong_t addr;
+ char* file;
+ int line;
+ Void_t* func;
+
+ /* this must be done now to avoid any inadvertent recursion (more below) */
+ _Vmflinit = 1;
+ VMFLF(Vmregion,file,line,func);
+
+ /* if getenv() calls malloc(), the eventual region may not see this */
+ vm = NIL(Vmalloc_t*);
+ if((env = getenv("VMETHOD")) )
+ { if(strcmp(env,"Vmdebug") == 0 || strcmp(env,"vmdebug") == 0)
+ vm = vmopen(Vmdcsbrk,Vmdebug,0);
+ else if(strcmp(env,"Vmprofile") == 0 || strcmp(env,"vmprofile") == 0 )
+ vm = vmopen(Vmdcsbrk,Vmprofile,0);
+ else if(strcmp(env,"Vmlast") == 0 || strcmp(env,"vmlast") == 0 )
+ vm = vmopen(Vmdcsbrk,Vmlast,0);
+ else if(strcmp(env,"Vmbest") == 0 || strcmp(env,"vmbest") == 0 )
+ vm = Vmheap;
+ }
+
+ if((!vm || vm->meth.meth == VM_MTDEBUG) &&
+ (env = getenv("VMDEBUG")) && env[0] )
+ { if(vm || (vm = vmopen(Vmdcsbrk,Vmdebug,0)) )
+ { reg int setcheck = 0;
+
+ while(*env)
+ { if(*env == 'a')
+ { vmset(vm,VM_DBABORT,1);
+ env += 1;
+ }
+ else if(*env =='w')
+ { env += 1;
+ if((fd = atou(&env)) >= 0 )
+ vmdebug(fd);
+ }
+ else if(*env < '0' || *env > '9')
+ env += 1;
+ else if(env[0] == '0' && (env[1] == 'x' || env[1] == 'X') )
+ { if((addr = atou(&env)) != 0)
+ vmdbwatch((Void_t*)addr);
+ }
+ else
+ { _Vmdbcheck = atou(&env);
+ setcheck = 1;
+ if(*env == ',')
+ { env += 1;
+ _Vmdbstart = atou(&env);
+ }
+ }
+ }
+ if(!setcheck)
+ _Vmdbcheck = 1;
+ }
+ }
+
+ if((!vm || vm->meth.meth == VM_MTPROFILE) &&
+ (env = getenv("VMPROFILE")) && env[0] )
+ { _Vmpffd = createfile(env);
+ if(!vm)
+ vm = vmopen(Vmdcsbrk,Vmprofile,0);
+ }
+
+ /* slip in the new region now so that malloc() will work fine */
+ if(vm)
+ Vmregion = vm;
+
+ /* turn on tracing if requested */
+ if((env = getenv("VMTRACE")) && env[0] && (fd = createfile(env)) >= 0)
+ { vmset(Vmregion,VM_TRACE,1);
+ vmtrace(fd);
+ }
+
+ /* make sure that profile data is output upon exiting */
+ if(vm && vm->meth.meth == VM_MTPROFILE)
+ { if(_Vmpffd < 0)
+ _Vmpffd = 2;
+ /* this may wind up calling malloc(), but region is ok now */
+ atexit(pfprint);
+ }
+ else if(_Vmpffd >= 0)
+ { close(_Vmpffd);
+ _Vmpffd = -1;
+ }
+
+ /* reset file and line number to correct values for the call */
+ Vmregion->file = file;
+ Vmregion->line = line;
+ Vmregion->func = func;
+
+ return 0;
+}
+
+#if __STD_C
+extern Void_t* calloc(reg size_t n_obj, reg size_t s_obj)
+#else
+extern Void_t* calloc(n_obj, s_obj)
+reg size_t n_obj;
+reg size_t s_obj;
+#endif
+{
+ VMFLINIT();
+ return VMRECORD((*Vmregion->meth.resizef)(Vmregion,NIL(Void_t*),n_obj*s_obj,VM_RSZERO));
+}
+
+#if __STD_C
+extern Void_t* malloc(reg size_t size)
+#else
+extern Void_t* malloc(size)
+reg size_t size;
+#endif
+{
+ VMFLINIT();
+ return VMRECORD((*Vmregion->meth.allocf)(Vmregion,size));
+}
+
+#if __STD_C
+extern Void_t* realloc(reg Void_t* data, reg size_t size)
+#else
+extern Void_t* realloc(data,size)
+reg Void_t* data; /* block to be reallocated */
+reg size_t size; /* new size */
+#endif
+{
+#if USE_NATIVE
+#undef realloc
+#if __STD_C
+ extern Void_t* realloc(Void_t*, size_t);
+#else
+ extern Void_t* realloc();
+#endif
+#endif
+
+ VMFLINIT();
+
+#if _PACKAGE_ast
+ if(data && Vmregion->meth.meth != VM_MTDEBUG &&
+#if !USE_NATIVE
+ !(Vmregion->data->mode&VM_TRUST) &&
+#endif
+ (*Vmregion->meth.addrf)(Vmregion,data) != 0 )
+ {
+#if USE_NATIVE
+ return realloc(data, size);
+#else
+ Void_t* newdata;
+ if((newdata = (*Vmregion->meth.allocf)(Vmregion,size)) )
+ memcpy(newdata,data,size);
+ return VMRECORD(newdata);
+#endif
+ }
+#endif
+
+#if USE_NATIVE
+ { Void_t* newdata;
+ if (newdata = (*Vmregion->meth.resizef)(Vmregion,data,size,VM_RSCOPY|VM_RSMOVE))
+ return newdata;
+ return VMRECORD(realloc(data, size));
+ }
+#else
+ return VMRECORD((*Vmregion->meth.resizef)(Vmregion,data,size,VM_RSCOPY|VM_RSMOVE));
+#endif
+}
+
+#if __STD_C
+extern void free(reg Void_t* data)
+#else
+extern void free(data)
+reg Void_t* data;
+#endif
+{
+#if USE_NATIVE
+#undef free
+#if __STD_C
+ extern void free(Void_t*);
+#else
+ extern void free();
+#endif
+#endif
+
+ VMFLINIT();
+
+#if _PACKAGE_ast
+ if(data && Vmregion->meth.meth != VM_MTDEBUG &&
+#if !USE_NATIVE
+ !(Vmregion->data->mode&VM_TRUST) &&
+#endif
+ (*Vmregion->meth.addrf)(Vmregion,data) != 0)
+ {
+#if USE_NATIVE
+ free(data);
+#endif
+ return;
+ }
+#endif
+
+#if USE_NATIVE
+ if ((*Vmregion->meth.freef)(Vmregion,data) != 0)
+ free(data);
+#else
+ (void)(*Vmregion->meth.freef)(Vmregion,data);
+#endif
+}
+
+#if __STD_C
+extern void cfree(reg Void_t* data)
+#else
+extern void cfree(data)
+reg Void_t* data;
+#endif
+{
+ free(data);
+}
+
+#if __STD_C
+extern Void_t* memalign(reg size_t align, reg size_t size)
+#else
+extern Void_t* memalign(align, size)
+reg size_t align;
+reg size_t size;
+#endif
+{
+ Void_t* addr;
+
+ VMFLINIT();
+ VMBLOCK
+ addr = VMRECORD((*Vmregion->meth.alignf)(Vmregion,size,align));
+ VMUNBLOCK
+ return addr;
+}
+
+#if __STD_C
+extern Void_t* valloc(reg size_t size)
+#else
+extern Void_t* valloc(size)
+reg size_t size;
+#endif
+{
+ VMFLINIT();
+ GETPAGESIZE(_Vmpagesize);
+ return VMRECORD((*Vmregion->meth.alignf)(Vmregion,size,_Vmpagesize));
+}
+
+#if __STD_C
+extern Void_t* pvalloc(reg size_t size)
+#else
+extern Void_t* pvalloc(size)
+reg size_t size;
+#endif
+{
+ VMFLINIT();
+ GETPAGESIZE(_Vmpagesize);
+ return VMRECORD((*Vmregion->meth.alignf)(Vmregion,ROUND(size,_Vmpagesize),_Vmpagesize));
+}
+
+#if !_PACKAGE_ast
+#if __STD_C
+char* strdup(const char* s)
+#else
+char* strdup(s)
+char* s;
+#endif
+{
+ char *ns;
+ size_t n;
+
+ if(!s)
+ return NIL(char*);
+ else
+ { n = strlen(s);
+ if((ns = malloc(n+1)) )
+ memcpy(ns,s,n+1);
+ return ns;
+ }
+}
+#endif /* _PACKAGE_ast */
+
+#if !_lib_alloca || _mal_alloca
+#ifndef _stk_down
+#define _stk_down 0
+#endif
+typedef struct _alloca_s Alloca_t;
+union _alloca_u
+{ struct
+ { char* addr;
+ Alloca_t* next;
+ } head;
+ char array[ALIGN];
+};
+struct _alloca_s
+{ union _alloca_u head;
+ Vmuchar_t data[1];
+};
+
+#if __STD_C
+extern Void_t* alloca(size_t size)
+#else
+extern Void_t* alloca(size)
+size_t size;
+#endif
+{ char array[ALIGN];
+ char* file;
+ int line;
+ Void_t* func;
+ reg Alloca_t* f;
+ static Alloca_t* Frame;
+
+ VMFLINIT();
+ VMFLF(Vmregion,file,line,func);
+ while(Frame)
+ { if(( _stk_down && &array[0] > Frame->head.head.addr) ||
+ (!_stk_down && &array[0] < Frame->head.head.addr) )
+ { f = Frame;
+ Frame = f->head.head.next;
+ (void)(*Vmregion->meth.freef)(Vmregion,f);
+ }
+ else break;
+ }
+
+ Vmregion->file = file;
+ Vmregion->line = line;
+ Vmregion->func = func;
+ f = (Alloca_t*)(*Vmregion->meth.allocf)(Vmregion,size+sizeof(Alloca_t)-1);
+
+ f->head.head.addr = &array[0];
+ f->head.head.next = Frame;
+ Frame = f;
+
+ return (Void_t*)f->data;
+}
+#endif /*!_lib_alloca || _mal_alloca*/
+
+#if _map_malloc
+
+/* not sure of all the implications -- 0 is conservative for now */
+#define USE_NATIVE 0 /* native free/realloc on non-vmalloc ptrs */
+
+#else
+
+/* intercept _* __* __libc_* variants */
+
+#if __lib__malloc
+extern Void_t* F2(_calloc, size_t,n, size_t,m) { return calloc(n, m); }
+extern Void_t F1(_cfree, Void_t*,p) { free(p); }
+extern Void_t F1(_free, Void_t*,p) { free(p); }
+extern Void_t* F1(_malloc, size_t,n) { return malloc(n); }
+#if _lib_memalign
+extern Void_t* F2(_memalign, size_t,a, size_t,n) { return memalign(a, n); }
+#endif
+#if _lib_pvalloc
+extern Void_t* F1(_pvalloc, size_t,n) { return pvalloc(n); }
+#endif
+extern Void_t* F2(_realloc, Void_t*,p, size_t,n) { return realloc(p, n); }
+#if _lib_valloc
+extern Void_t* F1(_valloc, size_t,n) { return valloc(n); }
+#endif
+#endif
+
+#if _lib___malloc
+extern Void_t* F2(__calloc, size_t,n, size_t,m) { return calloc(n, m); }
+extern Void_t F1(__cfree, Void_t*,p) { free(p); }
+extern Void_t F1(__free, Void_t*,p) { free(p); }
+extern Void_t* F1(__malloc, size_t,n) { return malloc(n); }
+#if _lib_memalign
+extern Void_t* F2(__memalign, size_t,a, size_t,n) { return memalign(a, n); }
+#endif
+#if _lib_pvalloc
+extern Void_t* F1(__pvalloc, size_t,n) { return pvalloc(n); }
+#endif
+extern Void_t* F2(__realloc, Void_t*,p, size_t,n) { return realloc(p, n); }
+#if _lib_valloc
+extern Void_t* F1(__valloc, size_t,n) { return valloc(n); }
+#endif
+#endif
+
+#if _lib___libc_malloc
+extern Void_t* F2(__libc_calloc, size_t,n, size_t,m) { return calloc(n, m); }
+extern Void_t F1(__libc_cfree, Void_t*,p) { free(p); }
+extern Void_t F1(__libc_free, Void_t*,p) { free(p); }
+extern Void_t* F1(__libc_malloc, size_t,n) { return malloc(n); }
+#if _lib_memalign
+extern Void_t* F2(__libc_memalign, size_t,a, size_t,n) { return memalign(a, n); }
+#endif
+#if _lib_pvalloc
+extern Void_t* F1(__libc_pvalloc, size_t,n) { return pvalloc(n); }
+#endif
+extern Void_t* F2(__libc_realloc, Void_t*,p, size_t,n) { return realloc(p, n); }
+#if _lib_valloc
+extern Void_t* F1(__libc_valloc, size_t,n) { return valloc(n); }
+#endif
+#endif
+
+#endif /* _map_malloc */
+
+#undef extern
+
+#if _hdr_malloc /* need the mallint interface for statistics, etc. */
+
+#undef calloc
+#define calloc ______calloc
+#undef cfree
+#define cfree ______cfree
+#undef free
+#define free ______free
+#undef malloc
+#define malloc ______malloc
+#undef pvalloc
+#define pvalloc ______pvalloc
+#undef realloc
+#define realloc ______realloc
+#undef valloc
+#define valloc ______valloc
+
+#if !_UWIN
+
+#include <malloc.h>
+
+typedef struct mallinfo Mallinfo_t;
+typedef struct mstats Mstats_t;
+
+#endif
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+#if _lib_mallopt
+#if __STD_C
+extern int mallopt(int cmd, int value)
+#else
+extern int mallopt(cmd, value)
+int cmd;
+int value;
+#endif
+{
+ VMFLINIT();
+ return 0;
+}
+#endif /*_lib_mallopt*/
+
+#if _lib_mallinfo && _mem_arena_mallinfo
+#if __STD_C
+extern Mallinfo_t mallinfo(void)
+#else
+extern Mallinfo_t mallinfo()
+#endif
+{
+ Vmstat_t sb;
+ Mallinfo_t mi;
+
+ VMFLINIT();
+ memset(&mi,0,sizeof(mi));
+ if(vmstat(Vmregion,&sb) >= 0)
+ { mi.arena = sb.extent;
+ mi.ordblks = sb.n_busy+sb.n_free;
+ mi.uordblks = sb.s_busy;
+ mi.fordblks = sb.s_free;
+ }
+ return mi;
+}
+#endif /* _lib_mallinfo */
+
+#if _lib_mstats && _mem_bytes_total_mstats
+#if __STD_C
+extern Mstats_t mstats(void)
+#else
+extern Mstats_t mstats()
+#endif
+{
+ Vmstat_t sb;
+ Mstats_t ms;
+
+ VMFLINIT();
+ memset(&ms,0,sizeof(ms));
+ if(vmstat(Vmregion,&sb) >= 0)
+ { ms.bytes_total = sb.extent;
+ ms.chunks_used = sb.n_busy;
+ ms.bytes_used = sb.s_busy;
+ ms.chunks_free = sb.n_free;
+ ms.bytes_free = sb.s_free;
+ }
+ return ms;
+}
+#endif /*_lib_mstats*/
+
+#undef extern
+
+#endif/*_hdr_malloc*/
+
+#else
+
+/*
+ * even though there is no malloc override, still provide
+ * _ast_* counterparts for object compatibility
+ */
+
+#undef calloc
+extern Void_t* calloc _ARG_((size_t, size_t));
+
+#undef cfree
+extern void cfree _ARG_((Void_t*));
+
+#undef free
+extern void free _ARG_((Void_t*));
+
+#undef malloc
+extern Void_t* malloc _ARG_((size_t));
+
+#if _lib_memalign
+#undef memalign
+extern Void_t* memalign _ARG_((size_t, size_t));
+#endif
+
+#if _lib_pvalloc
+#undef pvalloc
+extern Void_t* pvalloc _ARG_((size_t));
+#endif
+
+#undef realloc
+extern Void_t* realloc _ARG_((Void_t*, size_t));
+
+#if _lib_valloc
+#undef valloc
+extern Void_t* valloc _ARG_((size_t));
+#endif
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Void_t* F2(_ast_calloc, size_t,n, size_t,m) { return calloc(n, m); }
+extern Void_t F1(_ast_cfree, Void_t*,p) { free(p); }
+extern Void_t F1(_ast_free, Void_t*,p) { free(p); }
+extern Void_t* F1(_ast_malloc, size_t,n) { return malloc(n); }
+#if _lib_memalign
+extern Void_t* F2(_ast_memalign, size_t,a, size_t,n) { return memalign(a, n); }
+#endif
+#if _lib_pvalloc
+extern Void_t* F1(_ast_pvalloc, size_t,n) { return pvalloc(n); }
+#endif
+extern Void_t* F2(_ast_realloc, Void_t*,p, size_t,n) { return realloc(p, n); }
+#if _lib_valloc
+extern Void_t* F1(_ast_valloc, size_t,n) { return valloc(n); }
+#endif
+
+#undef extern
+
+#if _hdr_malloc
+
+#undef mallinfo
+#undef mallopt
+#undef mstats
+
+#define calloc ______calloc
+#define cfree ______cfree
+#define free ______free
+#define malloc ______malloc
+#define pvalloc ______pvalloc
+#define realloc ______realloc
+#define valloc ______valloc
+
+#if !_UWIN
+
+#include <malloc.h>
+
+typedef struct mallinfo Mallinfo_t;
+typedef struct mstats Mstats_t;
+
+#endif
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+#if _lib_mallopt
+extern int F2(_ast_mallopt, int,cmd, int,value) { return mallopt(cmd, value); }
+#endif
+
+#if _lib_mallinfo && _mem_arena_mallinfo
+extern Mallinfo_t F0(_ast_mallinfo, void) { return mallinfo(); }
+#endif
+
+#if _lib_mstats && _mem_bytes_total_mstats
+extern Mstats_t F0(_ast_mstats, void) { return mstats(); }
+#endif
+
+#undef extern
+
+#endif /*_hdr_malloc*/
+
+#endif /*!_std_malloc*/
+
+#endif /*_UWIN*/
diff --git a/usr/src/lib/libast/common/vmalloc/vmbest.c b/usr/src/lib/libast/common/vmalloc/vmbest.c
new file mode 100644
index 0000000000..a84e3dfe0c
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmbest.c
@@ -0,0 +1,1465 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmbest(){}
+
+#else
+
+#include "vmhdr.h"
+
+/* Best-fit allocation method. This is based on a best-fit strategy
+** using a splay tree for storage of lists of free blocks of the same
+** size. Recent free blocks may be cached for fast reuse.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+
+#ifdef DEBUG
+static int N_free; /* # of free calls */
+static int N_alloc; /* # of alloc calls */
+static int N_resize; /* # of resize calls */
+static int N_wild; /* # allocated from the wild block */
+static int N_last; /* # allocated from last free block */
+static int N_reclaim; /* # of bestreclaim calls */
+
+#undef VM_TRUST /* always check for locking, etc.s */
+#define VM_TRUST 0
+#endif /*DEBUG*/
+
+#define COMPACT 8 /* factor to decide when to compact */
+
+/* Check to see if a block is in the free tree */
+#if __STD_C
+static int vmintree(Block_t* node, Block_t* b)
+#else
+static int vmintree(node,b)
+Block_t* node;
+Block_t* b;
+#endif
+{ Block_t* t;
+
+ for(t = node; t; t = LINK(t))
+ if(t == b)
+ return 1;
+ if(LEFT(node) && vmintree(LEFT(node),b))
+ return 1;
+ if(RIGHT(node) && vmintree(RIGHT(node),b))
+ return 1;
+ return 0;
+}
+
+#if __STD_C
+static int vmonlist(Block_t* list, Block_t* b)
+#else
+static int vmonlist(list,b)
+Block_t* list;
+Block_t* b;
+#endif
+{
+ for(; list; list = LINK(list))
+ if(list == b)
+ return 1;
+ return 0;
+}
+
+/* Check to see if a block is known to be free */
+#if __STD_C
+static int vmisfree(Vmdata_t* vd, Block_t* b)
+#else
+static int vmisfree(vd,b)
+Vmdata_t* vd;
+Block_t* b;
+#endif
+{
+ if(SIZE(b) & (BUSY|JUNK|PFREE))
+ return 0;
+
+ if(b == vd->wild)
+ return 1;
+
+ if(SIZE(b) < MAXTINY)
+ return vmonlist(TINY(vd)[INDEX(SIZE(b))], b);
+
+ if(vd->root)
+ return vmintree(vd->root, b);
+
+ return 0;
+}
+
+/* Check to see if a block is known to be junked */
+#if __STD_C
+static int vmisjunk(Vmdata_t* vd, Block_t* b)
+#else
+static int vmisjunk(vd,b)
+Vmdata_t* vd;
+Block_t* b;
+#endif
+{
+ Block_t* t;
+
+ if((SIZE(b)&BUSY) == 0 || (SIZE(b)&JUNK) == 0)
+ return 0;
+
+ if(b == vd->free) /* recently freed */
+ return 1;
+
+ /* check the list that b is supposed to be in */
+ for(t = CACHE(vd)[C_INDEX(SIZE(b))]; t; t = LINK(t))
+ if(t == b)
+ return 1;
+
+ /* on occasions, b may be put onto the catch-all list */
+ if(C_INDEX(SIZE(b)) < S_CACHE)
+ for(t = CACHE(vd)[S_CACHE]; t; t = LINK(t))
+ if(t == b)
+ return 1;
+
+ return 0;
+}
+
+/* check to see if the free tree is in good shape */
+#if __STD_C
+static int vmchktree(Block_t* node)
+#else
+static int vmchktree(node)
+Block_t* node;
+#endif
+{ Block_t* t;
+
+ if(SIZE(node) & BITS)
+ { /**/ASSERT(0); return -1; }
+
+ for(t = LINK(node); t; t = LINK(t))
+ if(SIZE(t) != SIZE(node))
+ { /**/ASSERT(0); return -1; }
+
+ if((t = LEFT(node)) )
+ { if(SIZE(t) >= SIZE(node) )
+ { /**/ASSERT(0); return -1; }
+ else return vmchktree(t);
+ }
+ if((t = RIGHT(node)) )
+ { if(SIZE(t) <= SIZE(node) )
+ { /**/ASSERT(0); return -1; }
+ else return vmchktree(t);
+ }
+
+ return 0;
+}
+
+#if __STD_C
+int _vmbestcheck(Vmdata_t* vd, Block_t* freeb)
+#else
+int _vmbestcheck(vd, freeb)
+Vmdata_t* vd;
+Block_t* freeb; /* known to be free but not on any free list */
+#endif
+{
+ reg Seg_t *seg;
+ reg Block_t *b, *endb, *nextb;
+ int rv = 0;
+
+ if(!CHECK())
+ return 0;
+
+ /* make sure the free tree is still in shape */
+ if(vd->root && vmchktree(vd->root) < 0 )
+ { rv = -1; /**/ASSERT(0); }
+
+ for(seg = vd->seg; seg && rv == 0; seg = seg->next)
+ { b = SEGBLOCK(seg);
+ endb = (Block_t*)(seg->baddr - sizeof(Head_t));
+ for(; b < endb && rv == 0; b = nextb)
+ { nextb = (Block_t*)((Vmuchar_t*)DATA(b) + (SIZE(b)&~BITS) );
+
+ if(!ISBUSY(SIZE(b)) ) /* a completely free block */
+ { /* there should be no marked bits of any type */
+ if(SIZE(b) & (BUSY|JUNK|PFREE) )
+ { rv = -1; /**/ASSERT(0); }
+
+ /* next block must be busy and marked PFREE */
+ if(!ISBUSY(SIZE(nextb)) || !ISPFREE(SIZE(nextb)) )
+ { rv = -1; /**/ASSERT(0); }
+
+ /* must have a self-reference pointer */
+ if(*SELF(b) != b)
+ { rv = -1; /**/ASSERT(0); }
+
+ /* segment pointer should be well-defined */
+ if(!TINIEST(b) && SEG(b) != seg)
+ { rv = -1; /**/ASSERT(0); }
+
+ /* must be on a free list */
+ if(b != freeb && !vmisfree(vd, b) )
+ { rv = -1; /**/ASSERT(0); }
+ }
+ else
+ { /* segment pointer should be well-defined */
+ if(SEG(b) != seg)
+ { rv = -1; /**/ASSERT(0); }
+
+ /* next block should not be marked PFREE */
+ if(ISPFREE(SIZE(nextb)) )
+ { rv = -1; /**/ASSERT(0); }
+
+ /* if PFREE, last block should be free */
+ if(ISPFREE(SIZE(b)) && LAST(b) != freeb &&
+ !vmisfree(vd, LAST(b)) )
+ { rv = -1; /**/ASSERT(0); }
+
+ /* if free but unreclaimed, should be junk */
+ if(ISJUNK(SIZE(b)) && !vmisjunk(vd, b))
+ { rv = -1; /**/ASSERT(0); }
+ }
+ }
+ }
+
+ return rv;
+}
+
+/* Tree rotation functions */
+#define RROTATE(x,y) (LEFT(x) = RIGHT(y), RIGHT(y) = (x), (x) = (y))
+#define LROTATE(x,y) (RIGHT(x) = LEFT(y), LEFT(y) = (x), (x) = (y))
+#define RLINK(s,x) ((s) = LEFT(s) = (x))
+#define LLINK(s,x) ((s) = RIGHT(s) = (x))
+
+/* Find and delete a suitable element in the free tree. */
+#if __STD_C
+static Block_t* bestsearch(Vmdata_t* vd, reg size_t size, Block_t* wanted)
+#else
+static Block_t* bestsearch(vd, size, wanted)
+Vmdata_t* vd;
+reg size_t size;
+Block_t* wanted;
+#endif
+{
+ reg size_t s;
+ reg Block_t *t, *root, *l, *r;
+ Block_t link;
+
+ /* extracting a tiniest block from its list */
+ if((root = wanted) && size == TINYSIZE)
+ { reg Seg_t* seg;
+
+ l = TLEFT(root);
+ if((r = LINK(root)) )
+ TLEFT(r) = l;
+ if(l)
+ LINK(l) = r;
+ else TINY(vd)[0] = r;
+
+ seg = vd->seg;
+ if(!seg->next)
+ SEG(root) = seg;
+ else for(;; seg = seg->next)
+ { if((Vmuchar_t*)root > (Vmuchar_t*)seg->addr &&
+ (Vmuchar_t*)root < seg->baddr)
+ { SEG(root) = seg;
+ break;
+ }
+ }
+
+ return root;
+ }
+
+ /**/ASSERT(!vd->root || vmchktree(vd->root) == 0);
+
+ /* find the right one to delete */
+ l = r = &link;
+ if((root = vd->root) ) do
+ { /**/ ASSERT(!ISBITS(size) && !ISBITS(SIZE(root)));
+ if(size == (s = SIZE(root)) )
+ break;
+ if(size < s)
+ { if((t = LEFT(root)) )
+ { if(size <= (s = SIZE(t)) )
+ { RROTATE(root,t);
+ if(size == s)
+ break;
+ t = LEFT(root);
+ }
+ else
+ { LLINK(l,t);
+ t = RIGHT(t);
+ }
+ }
+ RLINK(r,root);
+ }
+ else
+ { if((t = RIGHT(root)) )
+ { if(size >= (s = SIZE(t)) )
+ { LROTATE(root,t);
+ if(size == s)
+ break;
+ t = RIGHT(root);
+ }
+ else
+ { RLINK(r,t);
+ t = LEFT(t);
+ }
+ }
+ LLINK(l,root);
+ }
+ /**/ ASSERT(root != t);
+ } while((root = t) );
+
+ if(root) /* found it, now isolate it */
+ { RIGHT(l) = LEFT(root);
+ LEFT(r) = RIGHT(root);
+ }
+ else /* nothing exactly fit */
+ { LEFT(r) = NIL(Block_t*);
+ RIGHT(l) = NIL(Block_t*);
+
+ /* grab the least one from the right tree */
+ if((root = LEFT(&link)) )
+ { while((t = LEFT(root)) )
+ RROTATE(root,t);
+ LEFT(&link) = RIGHT(root);
+ }
+ }
+
+ if(root && (r = LINK(root)) )
+ { /* head of a link list, use next one for root */
+ LEFT(r) = RIGHT(&link);
+ RIGHT(r) = LEFT(&link);
+ }
+ else if(!(r = LEFT(&link)) )
+ r = RIGHT(&link);
+ else /* graft left tree to right tree */
+ { while((t = LEFT(r)) )
+ RROTATE(r,t);
+ LEFT(r) = RIGHT(&link);
+ }
+ vd->root = r; /**/ASSERT(!r || !ISBITS(SIZE(r)));
+
+ /**/ASSERT(!vd->root || vmchktree(vd->root) == 0);
+ /**/ASSERT(!wanted || wanted == root);
+
+ return root;
+}
+
+/* Reclaim all delayed free blocks into the free tree */
+#if __STD_C
+static int bestreclaim(reg Vmdata_t* vd, Block_t* wanted, int c)
+#else
+static int bestreclaim(vd, wanted, c)
+reg Vmdata_t* vd;
+Block_t* wanted;
+int c;
+#endif
+{
+ reg size_t size, s;
+ reg Block_t *fp, *np, *t, *list;
+ reg int n, saw_wanted;
+ reg Seg_t *seg;
+
+ /**/COUNT(N_reclaim);
+ /**/ASSERT(_vmbestcheck(vd, NIL(Block_t*)) == 0);
+
+ if((fp = vd->free) )
+ { LINK(fp) = CACHE(vd)[S_CACHE]; CACHE(vd)[S_CACHE] = fp;
+ vd->free = NIL(Block_t*);
+ }
+
+ saw_wanted = wanted ? 0 : 1;
+ for(n = S_CACHE; n >= c; --n)
+ { list = CACHE(vd)[n]; CACHE(vd)[n] = NIL(Block_t*);
+ while((fp = list) )
+ { /* Note that below here we allow ISJUNK blocks to be
+ ** forward-merged even though they are not removed from
+ ** the list immediately. In this way, the list is
+ ** scanned only once. It works because the LINK and SIZE
+ ** fields are not destroyed during the merging. This can
+ ** be seen by observing that a tiniest block has a 2-word
+ ** header and a 2-word body. Merging a tiniest block
+ ** (1seg) and the next block (2seg) looks like this:
+ ** 1seg size link left 2seg size link left ....
+ ** 1seg size link left rite xxxx xxxx .... self
+ ** After the merge, the 2seg word is replaced by the RIGHT
+ ** pointer of the new block and somewhere beyond the
+ ** two xxxx fields, the SELF pointer will replace some
+ ** other word. The important part is that the two xxxx
+ ** fields are kept intact.
+ */
+ list = LINK(list); /**/ASSERT(!vmonlist(list,fp));
+
+ size = SIZE(fp);
+ if(!ISJUNK(size)) /* already done */
+ continue;
+
+ if(_Vmassert & VM_region)
+ { /* see if this address is from region */
+ for(seg = vd->seg; seg; seg = seg->next)
+ if(fp >= SEGBLOCK(seg) && fp < (Block_t*)seg->baddr )
+ break;
+ if(!seg) /* must be a bug in application code! */
+ { /**/ ASSERT(seg != NIL(Seg_t*));
+ continue;
+ }
+ }
+
+ if(ISPFREE(size)) /* backward merge */
+ { fp = LAST(fp);
+ s = SIZE(fp); /**/ASSERT(!(s&BITS));
+ REMOVE(vd,fp,INDEX(s),t,bestsearch);
+ size = (size&~BITS) + s + sizeof(Head_t);
+ }
+ else size &= ~BITS;
+
+ for(;;) /* forward merge */
+ { np = (Block_t*)((Vmuchar_t*)fp+size+sizeof(Head_t));
+ s = SIZE(np); /**/ASSERT(s > 0);
+ if(!ISBUSY(s))
+ { /**/ASSERT((s&BITS) == 0);
+ if(np == vd->wild)
+ vd->wild = NIL(Block_t*);
+ else REMOVE(vd,np,INDEX(s),t,bestsearch);
+ }
+ else if(ISJUNK(s))
+ { /* reclaim any touched junk list */
+ if((int)C_INDEX(s) < c)
+ c = C_INDEX(s);
+ SIZE(np) = 0;
+ CLRBITS(s);
+ }
+ else break;
+ size += s + sizeof(Head_t);
+ }
+ SIZE(fp) = size;
+
+ /* tell next block that this one is free */
+ np = NEXT(fp); /**/ASSERT(ISBUSY(SIZE(np)));
+ /**/ASSERT(!ISJUNK(SIZE(np)));
+ SETPFREE(SIZE(np));
+ *(SELF(fp)) = fp;
+
+ if(fp == wanted) /* to be consumed soon */
+ { /**/ASSERT(!saw_wanted); /* should be seen just once */
+ saw_wanted = 1;
+ continue;
+ }
+
+ /* wilderness preservation */
+ if(np->body.data >= vd->seg->baddr)
+ { vd->wild = fp;
+ continue;
+ }
+
+ /* tiny block goes to tiny list */
+ if(size < MAXTINY)
+ { s = INDEX(size);
+ np = LINK(fp) = TINY(vd)[s];
+ if(s == 0) /* TINIEST block */
+ { if(np)
+ TLEFT(np) = fp;
+ TLEFT(fp) = NIL(Block_t*);
+ }
+ else
+ { if(np)
+ LEFT(np) = fp;
+ LEFT(fp) = NIL(Block_t*);
+ SETLINK(fp);
+ }
+ TINY(vd)[s] = fp;
+ continue;
+ }
+
+ LEFT(fp) = RIGHT(fp) = LINK(fp) = NIL(Block_t*);
+ if(!(np = vd->root) ) /* inserting into an empty tree */
+ { vd->root = fp;
+ continue;
+ }
+
+ size = SIZE(fp);
+ while(1) /* leaf insertion */
+ { /**/ASSERT(np != fp);
+ if((s = SIZE(np)) > size)
+ { if((t = LEFT(np)) )
+ { /**/ ASSERT(np != t);
+ np = t;
+ }
+ else
+ { LEFT(np) = fp;
+ break;
+ }
+ }
+ else if(s < size)
+ { if((t = RIGHT(np)) )
+ { /**/ ASSERT(np != t);
+ np = t;
+ }
+ else
+ { RIGHT(np) = fp;
+ break;
+ }
+ }
+ else /* s == size */
+ { if((t = LINK(np)) )
+ { LINK(fp) = t;
+ LEFT(t) = fp;
+ }
+ LINK(np) = fp;
+ LEFT(fp) = np;
+ SETLINK(fp);
+ break;
+ }
+ }
+ }
+ }
+
+ /**/ASSERT(!wanted || saw_wanted == 1);
+ /**/ASSERT(_vmbestcheck(vd, wanted) == 0);
+ return saw_wanted;
+}
+
+#if __STD_C
+static int bestcompact(Vmalloc_t* vm)
+#else
+static int bestcompact(vm)
+Vmalloc_t* vm;
+#endif
+{
+ reg Seg_t *seg, *next;
+ reg Block_t *bp, *t;
+ reg size_t size, segsize, round;
+ reg int local;
+ reg Vmdata_t* vd = vm->data;
+
+ if(!(local = vd->mode&VM_TRUST) )
+ { GETLOCAL(vd,local);
+ if(ISLOCK(vd,local))
+ return -1;
+ SETLOCK(vd,local);
+ }
+
+ bestreclaim(vd,NIL(Block_t*),0);
+
+ for(seg = vd->seg; seg; seg = next)
+ { next = seg->next;
+
+ bp = BLOCK(seg->baddr);
+ if(!ISPFREE(SIZE(bp)) )
+ continue;
+
+ bp = LAST(bp); /**/ASSERT(vmisfree(vd,bp));
+ size = SIZE(bp);
+ if(bp == vd->wild)
+ { /* During large block allocations, _Vmextend might
+ ** have been enlarged the rounding factor. Reducing
+ ** it a bit help avoiding getting large raw memory.
+ */
+ if((round = vm->disc->round) == 0)
+ round = _Vmpagesize;
+ if(size > COMPACT*vd->incr && vd->incr > round)
+ vd->incr /= 2;
+
+ /* for the bottom segment, we don't necessarily want
+ ** to return raw memory too early. vd->pool has an
+ ** approximation of the average size of recently freed
+ ** blocks. If this is large, the application is managing
+ ** large blocks so we throttle back memory chopping
+ ** to avoid thrashing the underlying memory system.
+ */
+ if(size <= COMPACT*vd->incr || size <= COMPACT*vd->pool)
+ continue;
+
+ vd->wild = NIL(Block_t*);
+ vd->pool = 0;
+ }
+ else REMOVE(vd,bp,INDEX(size),t,bestsearch);
+ CLRPFREE(SIZE(NEXT(bp)));
+
+ if(size < (segsize = seg->size))
+ size += sizeof(Head_t);
+
+ if((size = (*_Vmtruncate)(vm,seg,size,0)) > 0)
+ { if(size >= segsize) /* entire segment deleted */
+ continue;
+ /**/ASSERT(SEG(BLOCK(seg->baddr)) == seg);
+
+ if((size = (seg->baddr - ((Vmuchar_t*)bp) - sizeof(Head_t))) > 0)
+ SIZE(bp) = size - sizeof(Head_t);
+ else bp = NIL(Block_t*);
+ }
+
+ if(bp)
+ { /**/ ASSERT(SIZE(bp) >= BODYSIZE);
+ /**/ ASSERT(SEGWILD(bp));
+ /**/ ASSERT(!vd->root || !vmintree(vd->root,bp));
+ SIZE(bp) |= BUSY|JUNK;
+ LINK(bp) = CACHE(vd)[C_INDEX(SIZE(bp))];
+ CACHE(vd)[C_INDEX(SIZE(bp))] = bp;
+ }
+ }
+
+ if(!local && _Vmtrace && (vd->mode&VM_TRACE) && VMETHOD(vd) == VM_MTBEST)
+ (*_Vmtrace)(vm, (Vmuchar_t*)0, (Vmuchar_t*)0, 0, 0);
+
+ CLRLOCK(vd,local); /**/ASSERT(_vmbestcheck(vd, NIL(Block_t*)) == 0);
+
+ return 0;
+}
+
+#if __STD_C
+static Void_t* bestalloc(Vmalloc_t* vm, reg size_t size )
+#else
+static Void_t* bestalloc(vm,size)
+Vmalloc_t* vm; /* region allocating from */
+reg size_t size; /* desired block size */
+#endif
+{
+ reg Vmdata_t* vd = vm->data;
+ reg size_t s;
+ reg int n;
+ reg Block_t *tp, *np;
+ reg int local;
+ size_t orgsize = 0;
+
+ if(!(_Vmassert & VM_init))
+ { char *chk = getenv("VMCHECK");
+ _Vmassert = VM_init|VM_primary|VM_secondary;
+ if(chk)
+ { int set = 1;
+ for(;; set ? (_Vmassert |= n) : (_Vmassert &= ~n))
+ {
+ switch (*chk++)
+ {
+ case 0:
+ break;
+ case '-':
+ case '!':
+ set = 0;
+ n = 0;
+ continue;
+ case '+':
+ set = 1;
+ n = 0;
+ continue;
+ case '1':
+ n = VM_check;
+ continue;
+ case '2':
+ n = VM_abort;
+ continue;
+ case '3':
+ n = VM_check|VM_abort;
+ continue;
+ case 'a':
+ case 'A':
+ n = VM_abort;
+ continue;
+ case 'c':
+ case 'C':
+ n = VM_check;
+ continue;
+ case 'p':
+ case 'P':
+ n = VM_primary;
+ continue;
+ case 'r':
+ case 'R':
+ n = VM_region;
+ continue;
+ case 's':
+ case 'S':
+ n = VM_secondary;
+ continue;
+ default:
+ n = 0;
+ continue;
+ }
+ break;
+ }
+ }
+ }
+ /**/COUNT(N_alloc);
+
+ if(!(local = vd->mode&VM_TRUST))
+ { GETLOCAL(vd,local); /**/ASSERT(!ISLOCK(vd,local));
+ if(ISLOCK(vd,local) )
+ return NIL(Void_t*);
+ SETLOCK(vd,local);
+ orgsize = size;
+ }
+
+ /**/ASSERT(_vmbestcheck(vd, NIL(Block_t*)) == 0);
+ /**/ ASSERT(HEADSIZE == sizeof(Head_t));
+ /**/ ASSERT(BODYSIZE == sizeof(Body_t));
+ /**/ ASSERT((ALIGN%(BITS+1)) == 0 );
+ /**/ ASSERT((sizeof(Head_t)%ALIGN) == 0 );
+ /**/ ASSERT((sizeof(Body_t)%ALIGN) == 0 );
+ /**/ ASSERT((BODYSIZE%ALIGN) == 0 );
+ /**/ ASSERT(sizeof(Block_t) == (sizeof(Body_t)+sizeof(Head_t)) );
+
+ /* for ANSI requirement that malloc(0) returns non-NULL pointer */
+ size = size <= BODYSIZE ? BODYSIZE : ROUND(size,ALIGN);
+
+ if((tp = vd->free) ) /* reuse last free piece if appropriate */
+ { /**/ASSERT(ISBUSY(SIZE(tp)) );
+ /**/ASSERT(ISJUNK(SIZE(tp)) );
+ /**/COUNT(N_last);
+
+ vd->free = NIL(Block_t*);
+ if((s = SIZE(tp)) >= size && s < (size << 1) )
+ { if(s >= size + (sizeof(Head_t)+BODYSIZE) )
+ { SIZE(tp) = size;
+ np = NEXT(tp);
+ SEG(np) = SEG(tp);
+ SIZE(np) = ((s&~BITS) - (size+sizeof(Head_t)))|JUNK|BUSY;
+ vd->free = np;
+ SIZE(tp) |= s&BITS;
+ }
+ CLRJUNK(SIZE(tp));
+ goto done;
+ }
+
+ LINK(tp) = CACHE(vd)[S_CACHE];
+ CACHE(vd)[S_CACHE] = tp;
+ }
+
+ for(;;)
+ { for(n = S_CACHE; n >= 0; --n) /* best-fit except for coalescing */
+ { bestreclaim(vd,NIL(Block_t*),n);
+ if(vd->root && (tp = bestsearch(vd,size,NIL(Block_t*))) )
+ goto got_block;
+ }
+
+ /**/ASSERT(!vd->free);
+ if((tp = vd->wild) && SIZE(tp) >= size)
+ { /**/COUNT(N_wild);
+ vd->wild = NIL(Block_t*);
+ goto got_block;
+ }
+
+ KPVCOMPACT(vm,bestcompact);
+ if((tp = (*_Vmextend)(vm,size,bestsearch)) )
+ goto got_block;
+ else if(vd->mode&VM_AGAIN)
+ vd->mode &= ~VM_AGAIN;
+ else
+ { CLRLOCK(vd,local);
+ return NIL(Void_t*);
+ }
+ }
+
+got_block:
+ /**/ ASSERT(!ISBITS(SIZE(tp)));
+ /**/ ASSERT(SIZE(tp) >= size);
+ /**/ ASSERT((SIZE(tp)%ALIGN) == 0);
+ /**/ ASSERT(!vd->free);
+
+ /* tell next block that we are no longer a free block */
+ CLRPFREE(SIZE(NEXT(tp))); /**/ ASSERT(ISBUSY(SIZE(NEXT(tp))));
+
+ if((s = SIZE(tp)-size) >= (sizeof(Head_t)+BODYSIZE) )
+ { SIZE(tp) = size;
+
+ np = NEXT(tp);
+ SEG(np) = SEG(tp);
+ SIZE(np) = (s - sizeof(Head_t)) | BUSY|JUNK;
+
+ if(VMWILD(vd,np))
+ { SIZE(np) &= ~BITS;
+ *SELF(np) = np; /**/ASSERT(ISBUSY(SIZE(NEXT(np))));
+ SETPFREE(SIZE(NEXT(np)));
+ vd->wild = np;
+ }
+ else vd->free = np;
+ }
+
+ SETBUSY(SIZE(tp));
+
+done:
+ if(!local && (vd->mode&VM_TRACE) && _Vmtrace && VMETHOD(vd) == VM_MTBEST)
+ (*_Vmtrace)(vm,NIL(Vmuchar_t*),(Vmuchar_t*)DATA(tp),orgsize,0);
+
+ /**/ASSERT(_vmbestcheck(vd, NIL(Block_t*)) == 0);
+ CLRLOCK(vd,local);
+ ANNOUNCE(local, vm, VM_ALLOC, DATA(tp), vm->disc);
+
+ return DATA(tp);
+}
+
+#if __STD_C
+static long bestaddr(Vmalloc_t* vm, Void_t* addr )
+#else
+static long bestaddr(vm, addr)
+Vmalloc_t* vm; /* region allocating from */
+Void_t* addr; /* address to check */
+#endif
+{
+ reg Seg_t* seg;
+ reg Block_t *b, *endb;
+ reg long offset;
+ reg Vmdata_t* vd = vm->data;
+ reg int local;
+
+ if(!(local = vd->mode&VM_TRUST) )
+ { GETLOCAL(vd,local); /**/ASSERT(!ISLOCK(vd,local));
+ if(ISLOCK(vd,local))
+ return -1L;
+ SETLOCK(vd,local);
+ }
+
+ offset = -1L; b = endb = NIL(Block_t*);
+ for(seg = vd->seg; seg; seg = seg->next)
+ { b = SEGBLOCK(seg);
+ endb = (Block_t*)(seg->baddr - sizeof(Head_t));
+ if((Vmuchar_t*)addr > (Vmuchar_t*)b &&
+ (Vmuchar_t*)addr < (Vmuchar_t*)endb)
+ break;
+ }
+
+ if(local && !(vd->mode&VM_TRUST) ) /* from bestfree or bestresize */
+ { b = BLOCK(addr);
+ if(seg && SEG(b) == seg && ISBUSY(SIZE(b)) && !ISJUNK(SIZE(b)) )
+ offset = 0;
+ if(offset != 0 && vm->disc->exceptf)
+ (void)(*vm->disc->exceptf)(vm,VM_BADADDR,addr,vm->disc);
+ }
+ else if(seg)
+ { while(b < endb)
+ { reg Vmuchar_t* data = (Vmuchar_t*)DATA(b);
+ reg size_t size = SIZE(b)&~BITS;
+
+ if((Vmuchar_t*)addr >= data && (Vmuchar_t*)addr < data+size)
+ { if(ISJUNK(SIZE(b)) || !ISBUSY(SIZE(b)))
+ offset = -1L;
+ else offset = (Vmuchar_t*)addr - data;
+ goto done;
+ }
+
+ b = (Block_t*)((Vmuchar_t*)DATA(b) + size);
+ }
+ }
+
+done:
+ CLRLOCK(vd,local);
+ return offset;
+}
+
+#if __STD_C
+static int bestfree(Vmalloc_t* vm, Void_t* data )
+#else
+static int bestfree(vm, data )
+Vmalloc_t* vm;
+Void_t* data;
+#endif
+{
+ reg Vmdata_t* vd = vm->data;
+ reg Block_t *bp;
+ reg size_t s;
+ reg int local;
+
+#ifdef DEBUG
+ if((local = (int)data) >= 0 && local <= 0xf)
+ { int vmassert = _Vmassert;
+ _Vmassert = local ? local : vmassert ? vmassert : (VM_check|VM_abort);
+ _vmbestcheck(vd, NIL(Block_t*));
+ _Vmassert = local ? local : vmassert;
+ return 0;
+ }
+#endif
+
+ if(!data) /* ANSI-ism */
+ return 0;
+
+ /**/COUNT(N_free);
+
+ if(!(local = vd->mode&VM_TRUST) )
+ { GETLOCAL(vd,local); /**/ASSERT(!ISLOCK(vd,local));
+ if(ISLOCK(vd,local) )
+ return -1;
+ if(KPVADDR(vm,data,bestaddr) != 0 )
+ return -1;
+ SETLOCK(vd,local);
+ }
+
+ /**/ASSERT(_vmbestcheck(vd, NIL(Block_t*)) == 0);
+ bp = BLOCK(data); s = SIZE(bp);
+
+ /* Keep an approximate average free block size.
+ ** This is used in bestcompact() to decide when to release
+ ** raw memory back to the underlying memory system.
+ */
+ vd->pool = (vd->pool + (s&~BITS))/2;
+
+ if(ISBUSY(s) && !ISJUNK(s))
+ { SETJUNK(SIZE(bp));
+ if(s < MAXCACHE)
+ { /**/ASSERT(!vmonlist(CACHE(vd)[INDEX(s)], bp) );
+ LINK(bp) = CACHE(vd)[INDEX(s)];
+ CACHE(vd)[INDEX(s)] = bp;
+ }
+ else if(!vd->free)
+ vd->free = bp;
+ else
+ { /**/ASSERT(!vmonlist(CACHE(vd)[S_CACHE], bp) );
+ LINK(bp) = CACHE(vd)[S_CACHE];
+ CACHE(vd)[S_CACHE] = bp;
+ }
+
+ /* coalesce on freeing large blocks to avoid fragmentation */
+ if(SIZE(bp) >= 2*vd->incr)
+ { bestreclaim(vd,NIL(Block_t*),0);
+ if(vd->wild && SIZE(vd->wild) >= COMPACT*vd->incr)
+ KPVCOMPACT(vm,bestcompact);
+ }
+ }
+
+ if(!local && _Vmtrace && (vd->mode&VM_TRACE) && VMETHOD(vd) == VM_MTBEST )
+ (*_Vmtrace)(vm,(Vmuchar_t*)data,NIL(Vmuchar_t*), (s&~BITS), 0);
+
+ /**/ASSERT(_vmbestcheck(vd, NIL(Block_t*)) == 0);
+ CLRLOCK(vd,local);
+ ANNOUNCE(local, vm, VM_FREE, data, vm->disc);
+
+ return 0;
+}
+
+#if __STD_C
+static Void_t* bestresize(Vmalloc_t* vm, Void_t* data, reg size_t size, int type)
+#else
+static Void_t* bestresize(vm,data,size,type)
+Vmalloc_t* vm; /* region allocating from */
+Void_t* data; /* old block of data */
+reg size_t size; /* new size */
+int type; /* !=0 to move, <0 for not copy */
+#endif
+{
+ reg Block_t *rp, *np, *t;
+ int local;
+ size_t s, bs, oldsize = 0, orgsize = 0;
+ Void_t *oldd, *orgdata = NIL(Void_t*);
+ Vmdata_t *vd = vm->data;
+
+ /**/COUNT(N_resize);
+
+ if(!data)
+ { if((data = bestalloc(vm,size)) )
+ { oldsize = 0;
+ size = size <= BODYSIZE ? BODYSIZE : ROUND(size,ALIGN);
+ }
+ goto done;
+ }
+ if(size == 0)
+ { (void)bestfree(vm,data);
+ return NIL(Void_t*);
+ }
+
+ if(!(local = vd->mode&VM_TRUST) )
+ { GETLOCAL(vd,local); /**/ASSERT(!ISLOCK(vd,local));
+ if(ISLOCK(vd,local) )
+ return NIL(Void_t*);
+ if(!local && KPVADDR(vm,data,bestaddr) != 0 )
+ return NIL(Void_t*);
+ SETLOCK(vd,local);
+
+ orgdata = data; /* for tracing */
+ orgsize = size;
+ }
+
+ /**/ASSERT(_vmbestcheck(vd, NIL(Block_t*)) == 0);
+ size = size <= BODYSIZE ? BODYSIZE : ROUND(size,ALIGN);
+ rp = BLOCK(data); /**/ASSERT(ISBUSY(SIZE(rp)) && !ISJUNK(SIZE(rp)));
+ oldsize = SIZE(rp); CLRBITS(oldsize);
+ if(oldsize < size)
+ { np = (Block_t*)((Vmuchar_t*)rp + oldsize + sizeof(Head_t));
+ do /* forward merge as much as possible */
+ { s = SIZE(np); /**/ASSERT(!ISPFREE(s));
+ if(np == vd->free)
+ { vd->free = NIL(Block_t*);
+ CLRBITS(s);
+ }
+ else if(ISJUNK(s) )
+ { if(!bestreclaim(vd,np,C_INDEX(s)) )
+ /**/ASSERT(0); /* oops: did not see np! */
+ s = SIZE(np); /**/ASSERT(s%ALIGN == 0);
+ }
+ else if(!ISBUSY(s) )
+ { if(np == vd->wild)
+ vd->wild = NIL(Block_t*);
+ else REMOVE(vd,np,INDEX(s),t,bestsearch);
+ }
+ else break;
+
+ SIZE(rp) += (s += sizeof(Head_t)); /**/ASSERT((s%ALIGN) == 0);
+ np = (Block_t*)((Vmuchar_t*)np + s);
+ CLRPFREE(SIZE(np));
+ } while(SIZE(rp) < size);
+
+ if(SIZE(rp) < size && size > vd->incr && SEGWILD(rp) )
+ { reg Seg_t* seg;
+
+ s = (size - SIZE(rp)) + sizeof(Head_t); s = ROUND(s,vd->incr);
+ seg = SEG(rp);
+ if((*vm->disc->memoryf)(vm,seg->addr,seg->extent,seg->extent+s,
+ vm->disc) == seg->addr )
+ { SIZE(rp) += s;
+ seg->extent += s;
+ seg->size += s;
+ seg->baddr += s;
+ s = (SIZE(rp)&~BITS) + sizeof(Head_t);
+ np = (Block_t*)((Vmuchar_t*)rp + s);
+ SEG(np) = seg;
+ SIZE(np) = BUSY;
+ }
+ }
+ }
+
+ if((s = SIZE(rp)) >= (size + (BODYSIZE+sizeof(Head_t))) )
+ { SIZE(rp) = size;
+ np = NEXT(rp);
+ SEG(np) = SEG(rp);
+ SIZE(np) = (((s&~BITS)-size) - sizeof(Head_t))|BUSY|JUNK;
+ CPYBITS(SIZE(rp),s);
+ rp = np;
+ goto do_free;
+ }
+ else if((bs = s&~BITS) < size)
+ { if(!(type&(VM_RSMOVE|VM_RSCOPY)) )
+ data = NIL(Void_t*); /* old data is not moveable */
+ else
+ { oldd = data;
+ if((data = KPVALLOC(vm,size,bestalloc)) )
+ { if(type&VM_RSCOPY)
+ memcpy(data, oldd, bs);
+
+ do_free: /* reclaim these right away */
+ SETJUNK(SIZE(rp));
+ LINK(rp) = CACHE(vd)[S_CACHE];
+ CACHE(vd)[S_CACHE] = rp;
+ bestreclaim(vd, NIL(Block_t*), S_CACHE);
+ }
+ }
+ }
+
+ if(!local && _Vmtrace && data && (vd->mode&VM_TRACE) && VMETHOD(vd) == VM_MTBEST)
+ (*_Vmtrace)(vm, (Vmuchar_t*)orgdata, (Vmuchar_t*)data, orgsize, 0);
+
+ /**/ASSERT(_vmbestcheck(vd, NIL(Block_t*)) == 0);
+ CLRLOCK(vd,local);
+ ANNOUNCE(local, vm, VM_RESIZE, data, vm->disc);
+
+done: if(data && (type&VM_RSZERO) && (size = SIZE(BLOCK(data))&~BITS) > oldsize )
+ memset((Void_t*)((Vmuchar_t*)data + oldsize), 0, size-oldsize);
+
+ return data;
+}
+
+#if __STD_C
+static long bestsize(Vmalloc_t* vm, Void_t* addr )
+#else
+static long bestsize(vm, addr)
+Vmalloc_t* vm; /* region allocating from */
+Void_t* addr; /* address to check */
+#endif
+{
+ reg Seg_t* seg;
+ reg Block_t *b, *endb;
+ reg long size;
+ reg Vmdata_t* vd = vm->data;
+
+ if(!(vd->mode&VM_TRUST) )
+ { if(ISLOCK(vd,0))
+ return -1L;
+ SETLOCK(vd,0);
+ }
+
+ size = -1L;
+ for(seg = vd->seg; seg; seg = seg->next)
+ { b = SEGBLOCK(seg);
+ endb = (Block_t*)(seg->baddr - sizeof(Head_t));
+ if((Vmuchar_t*)addr <= (Vmuchar_t*)b ||
+ (Vmuchar_t*)addr >= (Vmuchar_t*)endb)
+ continue;
+ while(b < endb)
+ { if(addr == DATA(b))
+ { if(!ISBUSY(SIZE(b)) || ISJUNK(SIZE(b)) )
+ size = -1L;
+ else size = (long)SIZE(b)&~BITS;
+ goto done;
+ }
+ else if((Vmuchar_t*)addr <= (Vmuchar_t*)b)
+ break;
+
+ b = (Block_t*)((Vmuchar_t*)DATA(b) + (SIZE(b)&~BITS) );
+ }
+ }
+
+done:
+ CLRLOCK(vd,0);
+ return size;
+}
+
+#if __STD_C
+static Void_t* bestalign(Vmalloc_t* vm, size_t size, size_t align)
+#else
+static Void_t* bestalign(vm, size, align)
+Vmalloc_t* vm;
+size_t size;
+size_t align;
+#endif
+{
+ reg Vmuchar_t *data;
+ reg Block_t *tp, *np;
+ reg Seg_t* seg;
+ reg int local;
+ reg size_t s, extra, orgsize = 0, orgalign = 0;
+ reg Vmdata_t* vd = vm->data;
+
+ if(size <= 0 || align <= 0)
+ return NIL(Void_t*);
+
+ if(!(local = vd->mode&VM_TRUST) )
+ { GETLOCAL(vd,local); /**/ASSERT(!ISLOCK(vd,local));
+ if(ISLOCK(vd,local) )
+ return NIL(Void_t*);
+ SETLOCK(vd,local);
+ orgsize = size;
+ orgalign = align;
+ }
+
+ /**/ASSERT(_vmbestcheck(vd, NIL(Block_t*)) == 0);
+ size = size <= BODYSIZE ? BODYSIZE : ROUND(size,ALIGN);
+ align = MULTIPLE(align,ALIGN);
+
+ /* hack so that dbalign() can store header data */
+ if(VMETHOD(vd) != VM_MTDEBUG)
+ extra = 0;
+ else
+ { extra = DB_HEAD;
+ while(align < extra || (align - extra) < sizeof(Block_t))
+ align *= 2;
+ }
+
+ /* reclaim all free blocks now to avoid fragmentation */
+ bestreclaim(vd,NIL(Block_t*),0);
+
+ s = size + 2*(align+sizeof(Head_t)+extra);
+ if(!(data = (Vmuchar_t*)KPVALLOC(vm,s,bestalloc)) )
+ goto done;
+
+ tp = BLOCK(data);
+ seg = SEG(tp);
+
+ /* get an aligned address that we can live with */
+ if((s = (size_t)((VLONG(data)+extra)%align)) != 0)
+ data += align-s; /**/ASSERT(((VLONG(data)+extra)%align) == 0);
+
+ if((np = BLOCK(data)) != tp ) /* need to free left part */
+ { if(((Vmuchar_t*)np - (Vmuchar_t*)tp) < (ssize_t)(sizeof(Block_t)+extra) )
+ { data += align;
+ np = BLOCK(data);
+ } /**/ASSERT(((VLONG(data)+extra)%align) == 0);
+
+ s = (Vmuchar_t*)np - (Vmuchar_t*)tp;
+ SIZE(np) = ((SIZE(tp)&~BITS) - s)|BUSY;
+ SEG(np) = seg;
+
+ SIZE(tp) = (s - sizeof(Head_t)) | (SIZE(tp)&BITS) | JUNK;
+ /**/ ASSERT(SIZE(tp) >= sizeof(Body_t) );
+ LINK(tp) = CACHE(vd)[C_INDEX(SIZE(tp))];
+ CACHE(vd)[C_INDEX(SIZE(tp))] = tp;
+ }
+
+ /* free left-over if too big */
+ if((s = SIZE(np) - size) >= sizeof(Block_t))
+ { SIZE(np) = size;
+
+ tp = NEXT(np);
+ SIZE(tp) = ((s & ~BITS) - sizeof(Head_t)) | BUSY | JUNK;
+ SEG(tp) = seg;
+ LINK(tp) = CACHE(vd)[C_INDEX(SIZE(tp))];
+ CACHE(vd)[C_INDEX(SIZE(tp))] = tp;
+
+ SIZE(np) |= s&BITS;
+ }
+
+ bestreclaim(vd,NIL(Block_t*),0); /* coalesce all free blocks */
+
+ if(!local && !(vd->mode&VM_TRUST) && _Vmtrace && (vd->mode&VM_TRACE) )
+ (*_Vmtrace)(vm,NIL(Vmuchar_t*),data,orgsize,orgalign);
+
+done:
+ /**/ASSERT(_vmbestcheck(vd, NIL(Block_t*)) == 0);
+ CLRLOCK(vd,local);
+ ANNOUNCE(local, vm, VM_ALLOC, (Void_t*)data, vm->disc);
+
+ return (Void_t*)data;
+}
+
+
+#if _mem_win32
+#if _PACKAGE_ast
+#include <ast_windows.h>
+#else
+#include <windows.h>
+#endif
+#endif /* _lib_win32 */
+
+#if _mem_mmap_anon
+#include <sys/mman.h>
+#ifndef MAP_ANON
+#define MAP_ANON MAP_ANONYMOUS
+#endif
+#endif /* _mem_mmap_anon */
+
+#if _mem_mmap_zero
+#include <sys/fcntl.h>
+#include <sys/mman.h>
+typedef struct _mmapdisc_s
+{ Vmdisc_t disc;
+ int fd;
+ off_t offset;
+} Mmapdisc_t;
+
+#ifndef OPEN_MAX
+#define OPEN_MAX 64
+#endif
+#define OPEN_PRIVATE (3*OPEN_MAX/4)
+#endif /* _mem_mmap_zero */
+
+/* failure mode of mmap, sbrk and brk */
+#ifndef MAP_FAILED
+#define MAP_FAILED ((Void_t*)(-1))
+#endif
+#define BRK_FAILED ((Void_t*)(-1))
+
+/* A discipline to get raw memory using sbrk/VirtualAlloc/mmap */
+#if __STD_C
+static Void_t* sbrkmem(Vmalloc_t* vm, Void_t* caddr,
+ size_t csize, size_t nsize, Vmdisc_t* disc)
+#else
+static Void_t* sbrkmem(vm, caddr, csize, nsize, disc)
+Vmalloc_t* vm; /* region doing allocation from */
+Void_t* caddr; /* current address */
+size_t csize; /* current size */
+size_t nsize; /* new size */
+Vmdisc_t* disc; /* discipline structure */
+#endif
+{
+#undef _done_sbrkmem
+
+#if !defined(_done_sbrkmem) && defined(_mem_win32)
+#define _done_sbrkmem 1
+ NOTUSED(vm);
+ NOTUSED(disc);
+ if(csize == 0)
+ return (Void_t*)VirtualAlloc(0,nsize,MEM_COMMIT,PAGE_READWRITE);
+ else if(nsize == 0)
+ return VirtualFree((LPVOID)caddr,0,MEM_RELEASE) ? caddr : NIL(Void_t*);
+ else return NIL(Void_t*);
+#endif /* MUST_WIN32 */
+
+#if !defined(_done_sbrkmem) && (_mem_sbrk || _mem_mmap_zero || _mem_mmap_anon)
+#define _done_sbrkmem 1
+ Vmuchar_t *addr;
+#if _mem_mmap_zero
+ Mmapdisc_t *mmdc = (Mmapdisc_t*)disc;
+#else
+ NOTUSED(disc);
+#endif
+ NOTUSED(vm);
+
+ if(csize == 0) /* allocating new memory */
+ {
+#if ( _mem_sbrk || _mem_mmap_anon || _mem_mmap_zero )
+#define ALTERNATES VM_primary
+#endif
+#if _mem_sbrk /* try using sbrk() and brk() */
+#if ALTERNATES
+ if (_Vmassert & ALTERNATES)
+#undef ALTERNATES
+#define ALTERNATES VM_secondary
+#endif
+ {
+ addr = (Vmuchar_t*)sbrk(0); /* old break value */
+ if(addr && addr != (Vmuchar_t*)BRK_FAILED )
+ if(brk(addr+nsize) == 0 )
+ return addr;
+ }
+#endif /* _mem_sbrk */
+
+#if _mem_mmap_anon /* anonymous mmap */
+#if ALTERNATES
+ if (_Vmassert & ALTERNATES)
+#undef ALTERNATES
+#define ALTERNATES VM_secondary
+#endif
+ {
+ addr = (Vmuchar_t*)mmap(0, nsize, PROT_READ|PROT_WRITE,
+ MAP_ANON|MAP_PRIVATE, -1, 0);
+ if(addr && addr != (Vmuchar_t*)MAP_FAILED)
+ return addr;
+ }
+#endif /* _mem_mmap_anon */
+
+#if _mem_mmap_zero /* mmap from /dev/zero */
+#if ALTERNATES
+ if (_Vmassert & ALTERNATES)
+#undef ALTERNATES
+#define ALTERNATES VM_secondary
+#endif
+ {
+ if(mmdc->fd < 0)
+ { int fd;
+ if(mmdc->fd != -1)
+ return NIL(Void_t*);
+ if((fd = open("/dev/zero", O_RDONLY)) < 0 )
+ { mmdc->fd = -2;
+ return NIL(Void_t*);
+ }
+ if(fd >= OPEN_PRIVATE || (mmdc->fd = dup2(fd,OPEN_PRIVATE)) < 0 )
+ mmdc->fd = fd;
+ else close(fd);
+#ifdef FD_CLOEXEC
+ fcntl(mmdc->fd, F_SETFD, FD_CLOEXEC);
+#endif
+ }
+ addr = (Vmuchar_t*)mmap(0, nsize, PROT_READ|PROT_WRITE,
+ MAP_PRIVATE, mmdc->fd, mmdc->offset);
+ if(addr && addr != (Vmuchar_t*)MAP_FAILED)
+ { mmdc->offset += nsize;
+ return addr;
+ }
+ }
+#endif /* _mem_mmap_zero */
+
+ return NIL(Void_t*);
+ }
+ else
+ { addr = caddr; /* in case !_mem_sbrk */
+#if ( _mem_sbrk || _mem_mmap_anon || _mem_mmap_zero )
+#undef ALTERNATES
+#define ALTERNATES VM_primary
+#endif
+#if _mem_sbrk
+#if ALTERNATES
+ if (_Vmassert & ALTERNATES)
+#undef ALTERNATES
+#define ALTERNATES VM_secondary
+#endif
+ {
+ addr = (Vmuchar_t*)sbrk(0);
+ if(!addr || addr == (Vmuchar_t*)BRK_FAILED)
+ addr = caddr;
+ else if(((Vmuchar_t*)caddr+csize) == addr) /* in sbrk-space */
+ { if(nsize > csize)
+ addr += nsize-csize;
+ else addr -= csize-nsize;
+ return brk(addr) == 0 ? caddr : NIL(Void_t*);
+ }
+ }
+#endif /* _mem_sbrk */
+
+#if _mem_mmap_zero || _mem_mmap_anon
+#if ALTERNATES
+ if (_Vmassert & ALTERNATES)
+#undef ALTERNATES
+#define ALTERNATES VM_secondary
+#endif
+ {
+ if(((Vmuchar_t*)caddr+csize) > addr) /* in mmap-space */
+ if(nsize == 0 && munmap(caddr,csize) == 0)
+ return caddr;
+ }
+#endif /* _mem_mmap_zero || _mem_mmap_anon */
+
+ return NIL(Void_t*);
+ }
+#endif /*_done_sbrkmem*/
+
+#if !_done_sbrkmem /* use native malloc/free as a last resource */
+ /**/ASSERT(_std_malloc); /* _std_malloc should be well-defined */
+ NOTUSED(vm);
+ NOTUSED(disc);
+ if(csize == 0)
+ return (Void_t*)malloc(nsize);
+ else if(nsize == 0)
+ { free(caddr);
+ return caddr;
+ }
+ else return NIL(Void_t*);
+#endif /* _done_sbrkmem */
+}
+
+#if _mem_mmap_zero
+static Mmapdisc_t _Vmdcsbrk = { { sbrkmem, NIL(Vmexcept_f), 64*1024 }, -1, 0 };
+#else
+static Vmdisc_t _Vmdcsbrk = { sbrkmem, NIL(Vmexcept_f), 0 };
+#endif
+
+static Vmethod_t _Vmbest =
+{
+ bestalloc,
+ bestresize,
+ bestfree,
+ bestaddr,
+ bestsize,
+ bestcompact,
+ bestalign,
+ VM_MTBEST
+};
+
+/* The heap region */
+static Vmdata_t _Vmdata =
+{
+ VM_MTBEST|VM_TRUST, /* mode */
+ 0, /* incr */
+ 0, /* pool */
+ NIL(Seg_t*), /* seg */
+ NIL(Block_t*), /* free */
+ NIL(Block_t*), /* wild */
+ NIL(Block_t*), /* root */
+};
+Vmalloc_t _Vmheap =
+{
+ { bestalloc,
+ bestresize,
+ bestfree,
+ bestaddr,
+ bestsize,
+ bestcompact,
+ bestalign,
+ VM_MTBEST
+ },
+ NIL(char*), /* file */
+ 0, /* line */
+ 0, /* func */
+ (Vmdisc_t*)(&_Vmdcsbrk), /* disc */
+ &_Vmdata, /* data */
+ NIL(Vmalloc_t*) /* next */
+};
+
+__DEFINE__(Vmalloc_t*, Vmheap, &_Vmheap);
+__DEFINE__(Vmalloc_t*, Vmregion, &_Vmheap);
+__DEFINE__(Vmethod_t*, Vmbest, &_Vmbest);
+__DEFINE__(Vmdisc_t*, Vmdcsbrk, (Vmdisc_t*)(&_Vmdcsbrk) );
+
+#ifdef NoF
+NoF(vmbest)
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmclear.c b/usr/src/lib/libast/common/vmalloc/vmclear.c
new file mode 100644
index 0000000000..3aaee44694
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmclear.c
@@ -0,0 +1,89 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmclear(){}
+
+#else
+
+#include "vmhdr.h"
+
+/* Clear out all allocated space.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+#if __STD_C
+int vmclear(Vmalloc_t* vm)
+#else
+int vmclear(vm)
+Vmalloc_t* vm;
+#endif
+{
+ reg Seg_t* seg;
+ reg Seg_t* next;
+ reg Block_t* tp;
+ reg size_t size, s;
+ reg Vmdata_t* vd = vm->data;
+
+ if(!(vd->mode&VM_TRUST) )
+ { if(ISLOCK(vd,0))
+ return -1;
+ SETLOCK(vd,0);
+ }
+
+ vd->free = vd->wild = NIL(Block_t*);
+ vd->pool = 0;
+
+ if(vd->mode&(VM_MTBEST|VM_MTDEBUG|VM_MTPROFILE) )
+ { vd->root = NIL(Block_t*);
+ for(s = 0; s < S_TINY; ++s)
+ TINY(vd)[s] = NIL(Block_t*);
+ for(s = 0; s <= S_CACHE; ++s)
+ CACHE(vd)[s] = NIL(Block_t*);
+ }
+
+ for(seg = vd->seg; seg; seg = next)
+ { next = seg->next;
+
+ tp = SEGBLOCK(seg);
+ size = seg->baddr - ((Vmuchar_t*)tp) - 2*sizeof(Head_t);
+
+ SEG(tp) = seg;
+ SIZE(tp) = size;
+ if((vd->mode&(VM_MTLAST|VM_MTPOOL)) )
+ seg->free = tp;
+ else
+ { SIZE(tp) |= BUSY|JUNK;
+ LINK(tp) = CACHE(vd)[C_INDEX(SIZE(tp))];
+ CACHE(vd)[C_INDEX(SIZE(tp))] = tp;
+ }
+
+ tp = BLOCK(seg->baddr);
+ SEG(tp) = seg;
+ SIZE(tp) = BUSY;
+ }
+
+ CLRLOCK(vd,0);
+ return 0;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmclose.c b/usr/src/lib/libast/common/vmalloc/vmclose.c
new file mode 100644
index 0000000000..9ad1a0719d
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmclose.c
@@ -0,0 +1,89 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmclose(){}
+
+#else
+
+#include "vmhdr.h"
+
+/* Close down a region.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+#if __STD_C
+int vmclose(Vmalloc_t* vm)
+#else
+int vmclose(vm)
+Vmalloc_t* vm;
+#endif
+{
+ Seg_t *seg, *vmseg, *next;
+ Vmalloc_t *v, *last;
+ Vmdata_t* vd = vm->data;
+ int ev = 0;
+
+ if(vm == Vmheap)
+ return -1;
+
+ if(!(vd->mode&VM_TRUST) && ISLOCK(vd,0))
+ return -1;
+
+ if(vm->disc->exceptf &&
+ (ev = (*vm->disc->exceptf)(vm,VM_CLOSE,NIL(Void_t*),vm->disc)) < 0 )
+ return -1;
+
+ /* make this region inaccessible until it disappears */
+ vd->mode &= ~VM_TRUST;
+ SETLOCK(vd,0);
+
+ if((vd->mode&VM_MTPROFILE) && _Vmpfclose)
+ (*_Vmpfclose)(vm);
+
+ /* remove from linked list of regions */
+ for(last = Vmheap, v = last->next; v; last = v, v = v->next)
+ { if(v == vm)
+ { last->next = v->next;
+ break;
+ }
+ }
+
+ if(ev == 0)
+ { vmseg = NIL(Seg_t*);
+ for(seg = vd->seg; seg; seg = next)
+ { next = seg->next;
+ if(seg->extent == seg->size)
+ vmseg = seg;
+ else (*vm->disc->memoryf)(vm,seg->addr,seg->extent,0,vm->disc);
+ }
+ if(vmseg)
+ (*vm->disc->memoryf)(vm,vmseg->addr,vmseg->extent,0,vm->disc);
+ }
+ else CLRLOCK(vd,0);
+
+ vmfree(Vmheap,vm);
+
+ return 0;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmdcheap.c b/usr/src/lib/libast/common/vmalloc/vmdcheap.c
new file mode 100644
index 0000000000..c4697c7536
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmdcheap.c
@@ -0,0 +1,64 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmdcheap(){}
+
+#else
+
+#include "vmhdr.h"
+
+/* A discipline to get memory from the heap.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+#if __STD_C
+static Void_t* heapmem(Vmalloc_t* vm, Void_t* caddr,
+ size_t csize, size_t nsize,
+ Vmdisc_t* disc)
+#else
+static Void_t* heapmem(vm, caddr, csize, nsize, disc)
+Vmalloc_t* vm; /* region doing allocation from */
+Void_t* caddr; /* current low address */
+size_t csize; /* current size */
+size_t nsize; /* new size */
+Vmdisc_t* disc; /* discipline structure */
+#endif
+{
+ NOTUSED(vm);
+ NOTUSED(disc);
+
+ if(csize == 0)
+ return vmalloc(Vmheap,nsize);
+ else if(nsize == 0)
+ return vmfree(Vmheap,caddr) >= 0 ? caddr : NIL(Void_t*);
+ else return vmresize(Vmheap,caddr,nsize,0);
+}
+
+static Vmdisc_t _Vmdcheap = { heapmem, NIL(Vmexcept_f), 0 };
+__DEFINE__(Vmdisc_t*,Vmdcheap,&_Vmdcheap);
+
+#ifdef NoF
+NoF(vmdcheap)
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmdebug.c b/usr/src/lib/libast/common/vmalloc/vmdebug.c
new file mode 100644
index 0000000000..61eb8fedb0
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmdebug.c
@@ -0,0 +1,732 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmdebug(){}
+
+#else
+
+#include "vmhdr.h"
+
+/* Method to help with debugging. This does rigorous checks on
+** addresses and arena integrity.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+
+/* structure to keep track of file names */
+typedef struct _dbfile_s Dbfile_t;
+struct _dbfile_s
+{ Dbfile_t* next;
+ char file[1];
+};
+static Dbfile_t* Dbfile;
+
+/* global watch list */
+#define S_WATCH 32
+static int Dbnwatch;
+static Void_t* Dbwatch[S_WATCH];
+
+/* types of warnings reported by dbwarn() */
+#define DB_CHECK 0
+#define DB_ALLOC 1
+#define DB_FREE 2
+#define DB_RESIZE 3
+#define DB_WATCH 4
+#define DB_RESIZED 5
+
+#define LONGV(x) ((Vmulong_t)(x))
+
+static int Dbinit = 0;
+#define DBINIT() (Dbinit ? 0 : (dbinit(), Dbinit=1) )
+static void dbinit()
+{ int fd;
+ if((fd = vmtrace(-1)) >= 0)
+ vmtrace(fd);
+}
+
+static int Dbfd = 2; /* default warning file descriptor */
+#if __STD_C
+int vmdebug(int fd)
+#else
+int vmdebug(fd)
+int fd;
+#endif
+{
+ int old = Dbfd;
+ Dbfd = fd;
+ return old;
+}
+
+/* just an entry point to make it easy to set break point */
+#if __STD_C
+static void vmdbwarn(Vmalloc_t* vm, char* mesg, int n)
+#else
+static void vmdbwarn(vm, mesg, n)
+Vmalloc_t* vm;
+char* mesg;
+int n;
+#endif
+{
+ reg Vmdata_t* vd = vm->data;
+
+ write(Dbfd,mesg,n);
+ if(vd->mode&VM_DBABORT)
+ abort();
+}
+
+/* issue a warning of some type */
+#if __STD_C
+static void dbwarn(Vmalloc_t* vm, Void_t* data, int where,
+ const char* file, int line, const Void_t* func, int type)
+#else
+static void dbwarn(vm, data, where, file, line, func, type)
+Vmalloc_t* vm; /* region holding the block */
+Void_t* data; /* data block */
+int where; /* byte that was corrupted */
+const char* file; /* file where call originates */
+int line; /* line number of call */
+const Void_t* func; /* function called from */
+int type; /* operation being done */
+#endif
+{
+ char buf[1024], *bufp, *endbuf, *s;
+#define SLOP 64 /* enough for a message and an int */
+
+ DBINIT();
+
+ bufp = buf;
+ endbuf = buf + sizeof(buf);
+
+ if(type == DB_ALLOC)
+ bufp = (*_Vmstrcpy)(bufp, "alloc error", ':');
+ else if(type == DB_FREE)
+ bufp = (*_Vmstrcpy)(bufp, "free error", ':');
+ else if(type == DB_RESIZE)
+ bufp = (*_Vmstrcpy)(bufp, "resize error", ':');
+ else if(type == DB_CHECK)
+ bufp = (*_Vmstrcpy)(bufp, "corrupted data", ':');
+ else if(type == DB_WATCH)
+ bufp = (*_Vmstrcpy)(bufp, "alert", ':');
+
+ /* region info */
+ bufp = (*_Vmstrcpy)(bufp, "region", '=');
+ bufp = (*_Vmstrcpy)(bufp, (*_Vmitoa)(VLONG(vm), 0), ':');
+
+ if(data)
+ { bufp = (*_Vmstrcpy)(bufp,"block",'=');
+ bufp = (*_Vmstrcpy)(bufp,(*_Vmitoa)(VLONG(data),0),':');
+ }
+
+ if(!data)
+ { if(where == DB_ALLOC)
+ bufp = (*_Vmstrcpy)(bufp, "can't get memory", ':');
+ else bufp = (*_Vmstrcpy)(bufp, "region is locked", ':');
+ }
+ else if(type == DB_FREE || type == DB_RESIZE)
+ { if(where == 0)
+ bufp = (*_Vmstrcpy)(bufp, "unallocated block", ':');
+ else bufp = (*_Vmstrcpy)(bufp, "already freed", ':');
+ }
+ else if(type == DB_WATCH)
+ { bufp = (*_Vmstrcpy)(bufp, "size", '=');
+ bufp = (*_Vmstrcpy)(bufp, (*_Vmitoa)(DBSIZE(data),-1), ':');
+ if(where == DB_ALLOC)
+ bufp = (*_Vmstrcpy)(bufp,"just allocated", ':');
+ else if(where == DB_FREE)
+ bufp = (*_Vmstrcpy)(bufp,"being freed", ':');
+ else if(where == DB_RESIZE)
+ bufp = (*_Vmstrcpy)(bufp,"being resized", ':');
+ else if(where == DB_RESIZED)
+ bufp = (*_Vmstrcpy)(bufp,"just resized", ':');
+ }
+ else if(type == DB_CHECK)
+ { bufp = (*_Vmstrcpy)(bufp, "bad byte at", '=');
+ bufp = (*_Vmstrcpy)(bufp, (*_Vmitoa)(LONGV(where),-1), ':');
+ if((s = DBFILE(data)) && (bufp + strlen(s) + SLOP) < endbuf)
+ { bufp = (*_Vmstrcpy)(bufp,"allocated at", '=');
+ bufp = (*_Vmstrcpy)(bufp, s, ',');
+ bufp = (*_Vmstrcpy)(bufp,(*_Vmitoa)(LONGV(DBLINE(data)),-1),':');
+ }
+ }
+
+ /* location where offending call originates from */
+ if(file && file[0] && line > 0 && (bufp + strlen(file) + SLOP) < endbuf)
+ { bufp = (*_Vmstrcpy)(bufp, "detected at", '=');
+ bufp = (*_Vmstrcpy)(bufp, file, ',');
+ bufp = (*_Vmstrcpy)(bufp, (*_Vmitoa)(LONGV(line),-1), ',');
+ bufp = (*_Vmstrcpy)(bufp, (*_Vmitoa)(VLONG(func),-1), ':');
+ }
+
+ *bufp++ = '\n';
+ *bufp = '\0';
+
+ vmdbwarn(vm,buf,(bufp-buf));
+}
+
+/* check for watched address and issue warnings */
+#if __STD_C
+static void dbwatch(Vmalloc_t* vm, Void_t* data,
+ const char* file, int line, const Void_t* func, int type)
+#else
+static void dbwatch(vm, data, file, line, func, type)
+Vmalloc_t* vm;
+Void_t* data;
+const char* file;
+int line;
+const Void_t* func;
+int type;
+#endif
+{
+ reg int n;
+
+ for(n = Dbnwatch; n >= 0; --n)
+ { if(Dbwatch[n] == data)
+ { dbwarn(vm,data,type,file,line,func,DB_WATCH);
+ return;
+ }
+ }
+}
+
+/* record information about the block */
+#if __STD_C
+static void dbsetinfo(Vmuchar_t* data, size_t size, const char* file, int line)
+#else
+static void dbsetinfo(data, size, file, line)
+Vmuchar_t* data; /* real address not the one from Vmbest */
+size_t size; /* the actual requested size */
+const char* file; /* file where the request came from */
+int line; /* and line number */
+#endif
+{
+ reg Vmuchar_t *begp, *endp;
+ reg Dbfile_t *last, *db;
+
+ DBINIT();
+
+ /* find the file structure */
+ if(!file || !file[0])
+ db = NIL(Dbfile_t*);
+ else
+ { for(last = NIL(Dbfile_t*), db = Dbfile; db; last = db, db = db->next)
+ if(strcmp(db->file,file) == 0)
+ break;
+ if(!db)
+ { db = (Dbfile_t*)vmalloc(Vmheap,sizeof(Dbfile_t)+strlen(file));
+ if(db)
+ { (*_Vmstrcpy)(db->file,file,0);
+ db->next = Dbfile;
+ Dbfile = db->next;
+ }
+ }
+ else if(last) /* move-to-front heuristic */
+ { last->next = db->next;
+ db->next = Dbfile;
+ Dbfile = db->next;
+ }
+ }
+
+ DBSETFL(data,(db ? db->file : NIL(char*)),line);
+ DBSIZE(data) = size;
+ DBSEG(data) = SEG(DBBLOCK(data));
+
+ DBHEAD(data,begp,endp);
+ while(begp < endp)
+ *begp++ = DB_MAGIC;
+ DBTAIL(data,begp,endp);
+ while(begp < endp)
+ *begp++ = DB_MAGIC;
+}
+
+/* Check to see if an address is in some data block of a region.
+** This returns -(offset+1) if block is already freed, +(offset+1)
+** if block is live, 0 if no match.
+*/
+#if __STD_C
+static long dbaddr(Vmalloc_t* vm, Void_t* addr)
+#else
+static long dbaddr(vm, addr)
+Vmalloc_t* vm;
+Void_t* addr;
+#endif
+{
+ reg Block_t *b, *endb;
+ reg Seg_t* seg;
+ reg Vmuchar_t* data;
+ reg long offset = -1L;
+ reg Vmdata_t* vd = vm->data;
+ reg int local;
+
+ GETLOCAL(vd,local);
+ if(ISLOCK(vd,local) || !addr)
+ return -1L;
+ SETLOCK(vd,local);
+
+ b = endb = NIL(Block_t*);
+ for(seg = vd->seg; seg; seg = seg->next)
+ { b = SEGBLOCK(seg);
+ endb = (Block_t*)(seg->baddr - sizeof(Head_t));
+ if((Vmuchar_t*)addr > (Vmuchar_t*)b &&
+ (Vmuchar_t*)addr < (Vmuchar_t*)endb)
+ break;
+ }
+ if(!seg)
+ goto done;
+
+ if(local) /* must be vmfree or vmresize checking address */
+ { if(DBSEG(addr) == seg)
+ { b = DBBLOCK(addr);
+ if(ISBUSY(SIZE(b)) && !ISJUNK(SIZE(b)) )
+ offset = 0;
+ else offset = -2L;
+ }
+ goto done;
+ }
+
+ while(b < endb)
+ { data = (Vmuchar_t*)DATA(b);
+ if((Vmuchar_t*)addr >= data && (Vmuchar_t*)addr < data+SIZE(b))
+ { if(ISBUSY(SIZE(b)) && !ISJUNK(SIZE(b)) )
+ { data = DB2DEBUG(data);
+ if((Vmuchar_t*)addr >= data &&
+ (Vmuchar_t*)addr < data+DBSIZE(data))
+ offset = (Vmuchar_t*)addr - data;
+ }
+ goto done;
+ }
+
+ b = (Block_t*)((Vmuchar_t*)DATA(b) + (SIZE(b)&~BITS) );
+ }
+
+done:
+ CLRLOCK(vd,local);
+ return offset;
+}
+
+
+#if __STD_C
+static long dbsize(Vmalloc_t* vm, Void_t* addr)
+#else
+static long dbsize(vm, addr)
+Vmalloc_t* vm;
+Void_t* addr;
+#endif
+{
+ reg Block_t *b, *endb;
+ reg Seg_t* seg;
+ reg long size;
+ reg Vmdata_t* vd = vm->data;
+
+ if(ISLOCK(vd,0))
+ return -1L;
+ SETLOCK(vd,0);
+
+ size = -1L;
+ for(seg = vd->seg; seg; seg = seg->next)
+ { b = SEGBLOCK(seg);
+ endb = (Block_t*)(seg->baddr - sizeof(Head_t));
+ if((Vmuchar_t*)addr <= (Vmuchar_t*)b ||
+ (Vmuchar_t*)addr >= (Vmuchar_t*)endb)
+ continue;
+ while(b < endb)
+ { if(addr == (Void_t*)DB2DEBUG(DATA(b)))
+ { if(ISBUSY(SIZE(b)) && !ISJUNK(SIZE(b)) )
+ size = (long)DBSIZE(addr);
+ goto done;
+ }
+
+ b = (Block_t*)((Vmuchar_t*)DATA(b) + (SIZE(b)&~BITS) );
+ }
+ }
+done:
+ CLRLOCK(vd,0);
+ return size;
+}
+
+#if __STD_C
+static Void_t* dballoc(Vmalloc_t* vm, size_t size)
+#else
+static Void_t* dballoc(vm, size)
+Vmalloc_t* vm;
+size_t size;
+#endif
+{
+ reg size_t s;
+ reg Vmuchar_t* data;
+ reg char* file;
+ reg int line;
+ reg Void_t* func;
+ reg Vmdata_t* vd = vm->data;
+
+ VMFLF(vm,file,line,func);
+
+ if(ISLOCK(vd,0) )
+ { dbwarn(vm,NIL(Vmuchar_t*),0,file,line,func,DB_ALLOC);
+ return NIL(Void_t*);
+ }
+ SETLOCK(vd,0);
+
+ if(vd->mode&VM_DBCHECK)
+ vmdbcheck(vm);
+
+ s = ROUND(size,ALIGN) + DB_EXTRA;
+ if(s < sizeof(Body_t)) /* no tiny blocks during Vmdebug */
+ s = sizeof(Body_t);
+
+ if(!(data = (Vmuchar_t*)KPVALLOC(vm,s,(*(Vmbest->allocf))) ) )
+ { dbwarn(vm,NIL(Vmuchar_t*),DB_ALLOC,file,line,func,DB_ALLOC);
+ goto done;
+ }
+
+ data = DB2DEBUG(data);
+ dbsetinfo(data,size,file,line);
+
+ if((vd->mode&VM_TRACE) && _Vmtrace)
+ { vm->file = file; vm->line = line; vm->func = func;
+ (*_Vmtrace)(vm,NIL(Vmuchar_t*),data,size,0);
+ }
+
+ if(Dbnwatch > 0 )
+ dbwatch(vm,data,file,line,func,DB_ALLOC);
+
+done:
+ CLRLOCK(vd,0);
+ ANNOUNCE(0, vm, VM_ALLOC, (Void_t*)data, vm->disc);
+ return (Void_t*)data;
+}
+
+
+#if __STD_C
+static int dbfree(Vmalloc_t* vm, Void_t* data )
+#else
+static int dbfree(vm, data )
+Vmalloc_t* vm;
+Void_t* data;
+#endif
+{
+ char* file;
+ int line;
+ Void_t* func;
+ reg long offset;
+ reg int rv, *ip, *endip;
+ reg Vmdata_t* vd = vm->data;
+
+ VMFLF(vm,file,line,func);
+
+ if(!data)
+ return 0;
+
+ if(ISLOCK(vd,0) )
+ { dbwarn(vm,NIL(Vmuchar_t*),0,file,line,func,DB_FREE);
+ return -1;
+ }
+ SETLOCK(vd,0);
+
+ if(vd->mode&VM_DBCHECK)
+ vmdbcheck(vm);
+
+ if((offset = KPVADDR(vm,data,dbaddr)) != 0)
+ { if(vm->disc->exceptf)
+ (void)(*vm->disc->exceptf)(vm,VM_BADADDR,data,vm->disc);
+ dbwarn(vm,(Vmuchar_t*)data,offset == -1L ? 0 : 1,file,line,func,DB_FREE);
+ CLRLOCK(vd,0);
+ return -1;
+ }
+
+ if(Dbnwatch > 0)
+ dbwatch(vm,data,file,line,func,DB_FREE);
+
+ if((vd->mode&VM_TRACE) && _Vmtrace)
+ { vm->file = file; vm->line = line; vm->func = func;
+ (*_Vmtrace)(vm,(Vmuchar_t*)data,NIL(Vmuchar_t*),DBSIZE(data),0);
+ }
+
+ /* clear free space */
+ ip = (int*)data;
+ endip = ip + (DBSIZE(data)+sizeof(int)-1)/sizeof(int);
+ while(ip < endip)
+ *ip++ = 0;
+
+ rv = KPVFREE((vm), (Void_t*)DB2BEST(data), (*Vmbest->freef));
+ CLRLOCK(vd,0);
+ ANNOUNCE(0, vm, VM_FREE, data, vm->disc);
+ return rv;
+}
+
+/* Resizing an existing block */
+#if __STD_C
+static Void_t* dbresize(Vmalloc_t* vm, Void_t* addr, reg size_t size, int type)
+#else
+static Void_t* dbresize(vm,addr,size,type)
+Vmalloc_t* vm; /* region allocating from */
+Void_t* addr; /* old block of data */
+reg size_t size; /* new size */
+int type; /* !=0 for movable, >0 for copy */
+#endif
+{
+ reg Vmuchar_t* data;
+ reg size_t s, oldsize;
+ reg long offset;
+ char *file, *oldfile;
+ int line, oldline;
+ Void_t* func;
+ reg Vmdata_t* vd = vm->data;
+
+ if(!addr)
+ { oldsize = 0;
+ data = (Vmuchar_t*)dballoc(vm,size);
+ goto done;
+ }
+ if(size == 0)
+ { (void)dbfree(vm,addr);
+ return NIL(Void_t*);
+ }
+
+ VMFLF(vm,file,line,func);
+
+ if(ISLOCK(vd,0) )
+ { dbwarn(vm,NIL(Vmuchar_t*),0,file,line,func,DB_RESIZE);
+ return NIL(Void_t*);
+ }
+ SETLOCK(vd,0);
+
+ if(vd->mode&VM_DBCHECK)
+ vmdbcheck(vm);
+
+ if((offset = KPVADDR(vm,addr,dbaddr)) != 0)
+ { if(vm->disc->exceptf)
+ (void)(*vm->disc->exceptf)(vm,VM_BADADDR,addr,vm->disc);
+ dbwarn(vm,(Vmuchar_t*)addr,offset == -1L ? 0 : 1,file,line,func,DB_RESIZE);
+ CLRLOCK(vd,0);
+ return NIL(Void_t*);
+ }
+
+ if(Dbnwatch > 0)
+ dbwatch(vm,addr,file,line,func,DB_RESIZE);
+
+ /* Vmbest data block */
+ data = DB2BEST(addr);
+ oldsize = DBSIZE(addr);
+ oldfile = DBFILE(addr);
+ oldline = DBLINE(addr);
+
+ /* do the resize */
+ s = ROUND(size,ALIGN) + DB_EXTRA;
+ if(s < sizeof(Body_t))
+ s = sizeof(Body_t);
+ data = (Vmuchar_t*)KPVRESIZE(vm,(Void_t*)data,s,
+ (type&~VM_RSZERO),(*(Vmbest->resizef)) );
+ if(!data) /* failed, reset data for old block */
+ { dbwarn(vm,NIL(Vmuchar_t*),DB_ALLOC,file,line,func,DB_RESIZE);
+ dbsetinfo((Vmuchar_t*)addr,oldsize,oldfile,oldline);
+ }
+ else
+ { data = DB2DEBUG(data);
+ dbsetinfo(data,size,file,line);
+
+ if((vd->mode&VM_TRACE) && _Vmtrace)
+ { vm->file = file; vm->line = line;
+ (*_Vmtrace)(vm,(Vmuchar_t*)addr,data,size,0);
+ }
+ if(Dbnwatch > 0)
+ dbwatch(vm,data,file,line,func,DB_RESIZED);
+ }
+
+ CLRLOCK(vd,0);
+ ANNOUNCE(0, vm, VM_RESIZE, (Void_t*)data, vm->disc);
+
+done: if(data && (type&VM_RSZERO) && size > oldsize)
+ { reg Vmuchar_t *d = data+oldsize, *ed = data+size;
+ do { *d++ = 0; } while(d < ed);
+ }
+ return (Void_t*)data;
+}
+
+/* compact any residual free space */
+#if __STD_C
+static int dbcompact(Vmalloc_t* vm)
+#else
+static int dbcompact(vm)
+Vmalloc_t* vm;
+#endif
+{
+ return (*(Vmbest->compactf))(vm);
+}
+
+/* check for memory overwrites over all live blocks */
+#if __STD_C
+int vmdbcheck(Vmalloc_t* vm)
+#else
+int vmdbcheck(vm)
+Vmalloc_t* vm;
+#endif
+{
+ reg Block_t *b, *endb;
+ reg Seg_t* seg;
+ int rv;
+ reg Vmdata_t* vd = vm->data;
+
+ /* check the meta-data of this region */
+ if(vd->mode & (VM_MTDEBUG|VM_MTBEST|VM_MTPROFILE))
+ { if(_vmbestcheck(vd, NIL(Block_t*)) < 0)
+ return -1;
+ if(!(vd->mode&VM_MTDEBUG))
+ return 0;
+ }
+ else return -1;
+
+ rv = 0;
+ for(seg = vd->seg; seg; seg = seg->next)
+ { b = SEGBLOCK(seg);
+ endb = (Block_t*)(seg->baddr - sizeof(Head_t));
+ while(b < endb)
+ { reg Vmuchar_t *data, *begp, *endp;
+
+ if(ISJUNK(SIZE(b)) || !ISBUSY(SIZE(b)))
+ goto next;
+
+ data = DB2DEBUG(DATA(b));
+ if(DBISBAD(data)) /* seen this before */
+ { rv += 1;
+ goto next;
+ }
+
+ DBHEAD(data,begp,endp);
+ for(; begp < endp; ++begp)
+ if(*begp != DB_MAGIC)
+ goto set_bad;
+
+ DBTAIL(data,begp,endp);
+ for(; begp < endp; ++begp)
+ { if(*begp == DB_MAGIC)
+ continue;
+ set_bad:
+ dbwarn(vm,data,begp-data,NIL(char*),0,0,DB_CHECK);
+ DBSETBAD(data);
+ rv += 1;
+ goto next;
+ }
+
+ next: b = (Block_t*)((Vmuchar_t*)DATA(b) + (SIZE(b)&~BITS));
+ }
+ }
+
+ return rv;
+}
+
+/* set/delete an address to watch */
+#if __STD_C
+Void_t* vmdbwatch(Void_t* addr)
+#else
+Void_t* vmdbwatch(addr)
+Void_t* addr; /* address to insert */
+#endif
+{
+ reg int n;
+ reg Void_t* out;
+
+ out = NIL(Void_t*);
+ if(!addr)
+ Dbnwatch = 0;
+ else
+ { for(n = Dbnwatch - 1; n >= 0; --n)
+ if(Dbwatch[n] == addr)
+ break;
+ if(n < 0) /* insert */
+ { if(Dbnwatch == S_WATCH)
+ { /* delete left-most */
+ out = Dbwatch[0];
+ Dbnwatch -= 1;
+ for(n = 0; n < Dbnwatch; ++n)
+ Dbwatch[n] = Dbwatch[n+1];
+ }
+ Dbwatch[Dbnwatch] = addr;
+ Dbnwatch += 1;
+ }
+ }
+ return out;
+}
+
+#if __STD_C
+static Void_t* dbalign(Vmalloc_t* vm, size_t size, size_t align)
+#else
+static Void_t* dbalign(vm, size, align)
+Vmalloc_t* vm;
+size_t size;
+size_t align;
+#endif
+{
+ reg Vmuchar_t* data;
+ reg size_t s;
+ reg char* file;
+ reg int line;
+ reg Void_t* func;
+ reg Vmdata_t* vd = vm->data;
+
+ VMFLF(vm,file,line,func);
+
+ if(size <= 0 || align <= 0)
+ return NIL(Void_t*);
+
+ if(ISLOCK(vd,0) )
+ return NIL(Void_t*);
+ SETLOCK(vd,0);
+
+ if((s = ROUND(size,ALIGN) + DB_EXTRA) < sizeof(Body_t))
+ s = sizeof(Body_t);
+
+ if(!(data = (Vmuchar_t*)KPVALIGN(vm,s,align,(*(Vmbest->alignf)))) )
+ goto done;
+
+ data += DB_HEAD;
+ dbsetinfo(data,size,file,line);
+
+ if((vd->mode&VM_TRACE) && _Vmtrace)
+ { vm->file = file; vm->line = line; vm->func = func;
+ (*_Vmtrace)(vm,NIL(Vmuchar_t*),data,size,align);
+ }
+
+done:
+ CLRLOCK(vd,0);
+ ANNOUNCE(0, vm, VM_ALLOC, (Void_t*)data, vm->disc);
+ return (Void_t*)data;
+}
+
+static Vmethod_t _Vmdebug =
+{
+ dballoc,
+ dbresize,
+ dbfree,
+ dbaddr,
+ dbsize,
+ dbcompact,
+ dbalign,
+ VM_MTDEBUG
+};
+
+__DEFINE__(Vmethod_t*,Vmdebug,&_Vmdebug);
+
+#ifdef NoF
+NoF(vmdebug)
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmdisc.c b/usr/src/lib/libast/common/vmalloc/vmdisc.c
new file mode 100644
index 0000000000..78393c3136
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmdisc.c
@@ -0,0 +1,57 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmdisc(){}
+
+#else
+
+#include "vmhdr.h"
+
+/* Change the discipline for a region. The old discipline
+** is returned. If the new discipline is NIL then the
+** discipline is not changed.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+#if __STD_C
+Vmdisc_t* vmdisc(Vmalloc_t* vm, Vmdisc_t* disc)
+#else
+Vmdisc_t* vmdisc(vm, disc)
+Vmalloc_t* vm;
+Vmdisc_t* disc;
+#endif
+{
+ Vmdisc_t* old = vm->disc;
+
+ if(disc)
+ { if(disc->memoryf != old->memoryf)
+ return NIL(Vmdisc_t*);
+ if(old->exceptf &&
+ (*old->exceptf)(vm,VM_DISC,(Void_t*)disc,old) != 0 )
+ return NIL(Vmdisc_t*);
+ vm->disc = disc;
+ }
+ return old;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmexit.c b/usr/src/lib/libast/common/vmalloc/vmexit.c
new file mode 100644
index 0000000000..29a169393b
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmexit.c
@@ -0,0 +1,100 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN)
+
+void _STUB_vmexit(){}
+
+#else
+
+#include "vmhdr.h"
+
+/*
+** Any required functions for process exiting.
+** Written by Kiem-Phong Vo, kpv@research.att.com (05/25/93).
+*/
+#if _PACKAGE_ast || _lib_atexit
+
+void _STUB_vmexit(){}
+
+#else
+
+#if _lib_onexit
+
+#if __STD_C
+int atexit(void (*exitf)(void))
+#else
+int atexit(exitf)
+void (*exitf)();
+#endif
+{
+ return onexit(exitf);
+}
+
+#else /*!_lib_onexit*/
+
+typedef struct _exit_s
+{ struct _exit_s* next;
+ void(* exitf)_ARG_((void));
+} Exit_t;
+static Exit_t* Exit;
+
+#if __STD_C
+atexit(void (*exitf)(void))
+#else
+atexit(exitf)
+void (*exitf)();
+#endif
+{ Exit_t* e;
+
+ if(!(e = (Exit_t*)malloc(sizeof(Exit_t))) )
+ return -1;
+ e->exitf = exitf;
+ e->next = Exit;
+ Exit = e;
+ return 0;
+}
+
+#if __STD_C
+void exit(int type)
+#else
+void exit(type)
+int type;
+#endif
+{
+ Exit_t* e;
+
+ for(e = Exit; e; e = e->next)
+ (*e->exitf)();
+
+#if _exit_cleanup
+ _cleanup();
+#endif
+
+ _exit(type);
+ return type;
+}
+
+#endif /* _lib_onexit || _lib_on_exit */
+
+#endif /*!PACKAGE_ast*/
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmgetmem.c b/usr/src/lib/libast/common/vmalloc/vmgetmem.c
new file mode 100644
index 0000000000..2ed647f732
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmgetmem.c
@@ -0,0 +1,57 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmgetmem(){}
+
+#else
+
+#include "vmhdr.h"
+
+/*
+ * vm open/close/resize - a handy default for discipline memory functions
+ *
+ * vmgetmem(0,0,0) open new region
+ * vmgetmem(r,0,0) free region
+ * vmgetmem(r,0,n) allocate n bytes initialized to 0
+ * vmgetmem(r,p,0) free p
+ * vmgetmem(r,p,n) realloc p to n bytes
+ */
+
+#if __STD_C
+Void_t* vmgetmem(Vmalloc_t* vm, Void_t* data, size_t size)
+#else
+Void_t* vmgetmem(vm, data, size)
+Vmalloc_t* vm;
+Void_t* data;
+size_t size;
+#endif
+{
+ if (!vm)
+ return vmopen(Vmdcheap, Vmbest, 0);
+ if (data || size)
+ return vmresize(vm, data, size, VM_RSMOVE|VM_RSCOPY|VM_RSZERO);
+ vmclose(vm);
+ return 0;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmhdr.h b/usr/src/lib/libast/common/vmalloc/vmhdr.h
new file mode 100644
index 0000000000..ac322a93a6
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmhdr.h
@@ -0,0 +1,549 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _VMHDR_H
+#define _VMHDR_H 1
+#ifndef _BLD_vmalloc
+#define _BLD_vmalloc 1
+#endif
+
+/* Common types, and macros for vmalloc functions.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+
+#ifndef __STD_C /* this is normally in vmalloc.h but it's included late here */
+#ifdef __STDC__
+#define __STD_C 1
+#else
+#if __cplusplus || c_plusplus
+#define __STD_C 1
+#else
+#define __STD_C 0
+#endif /*__cplusplus*/
+#endif /*__STDC__*/
+#endif /*__STD_C*/
+
+#if _PACKAGE_ast
+
+#if !_UWIN
+#define getpagesize ______getpagesize
+#define _npt_getpagesize 1
+#define brk ______brk
+#define sbrk ______sbrk
+#define _npt_sbrk 1
+#endif
+
+#include <ast.h>
+
+#if _npt_getpagesize
+#undef getpagesize
+#endif
+#if _npt_sbrk
+#undef brk
+#undef sbrk
+#endif
+
+#else
+
+#include <ast_common.h>
+
+#if !_UWIN
+#define _npt_getpagesize 1
+#define _npt_sbrk 1
+#endif
+
+#endif /*_PACKAGE_ast*/
+
+#include "FEATURE/vmalloc"
+
+#include <setjmp.h>
+
+/* the below macros decide which combinations of sbrk() or mmap() to used */
+#if defined(_WIN32)
+#define _mem_win32 1
+#undef _mem_sbrk
+#undef _mem_mmap_anon
+#undef _mem_mmap_zero
+#endif
+
+#if _mem_mmap_anon
+#undef _mem_mmap_zero
+#endif
+
+#if !_mem_win32 && !_mem_sbrk && !_mem_mmap_anon && !_mem_mmap_zero
+#undef _std_malloc
+#define _std_malloc 1 /* do not define malloc/free/realloc */
+#endif
+
+typedef unsigned char Vmuchar_t;
+typedef unsigned long Vmulong_t;
+
+typedef union _head_u Head_t;
+typedef union _body_u Body_t;
+typedef struct _block_s Block_t;
+typedef struct _seg_s Seg_t;
+typedef struct _pfobj_s Pfobj_t;
+
+#if !_typ_ssize_t
+typedef int ssize_t;
+#endif
+
+#define NIL(t) ((t)0)
+#define reg register
+#if __STD_C
+#define NOTUSED(x) (void)(x)
+#else
+#define NOTUSED(x) (&x,1)
+#endif
+
+/* convert an address to an integral value */
+#define VLONG(addr) ((Vmulong_t)((char*)(addr) - (char*)0) )
+
+/* Round x up to a multiple of y. ROUND2 does powers-of-2 and ROUNDX does others */
+#define ROUND2(x,y) (((x) + ((y)-1)) & ~((y)-1))
+#define ROUNDX(x,y) ((((x) + ((y)-1)) / (y)) * (y))
+#define ROUND(x,y) (((y)&((y)-1)) ? ROUNDX((x),(y)) : ROUND2((x),(y)) )
+
+/* compute a value that is a common multiple of x and y */
+#define MULTIPLE(x,y) ((x)%(y) == 0 ? (x) : (y)%(x) == 0 ? (y) : (y)*(x))
+
+#define VM_check 0x0001 /* enable detailed checks */
+#define VM_abort 0x0002 /* abort() on assertion failure */
+#define VM_primary 0x0004 /* enable primary native allocation */
+#define VM_region 0x0008 /* enable region segment checks */
+#define VM_secondary 0x0010 /* enable secondary native allocation */
+#define VM_init 0x8000 /* VMCHECK env var checked */
+
+#if _UWIN
+#include <ast_windows.h>
+#endif
+
+#ifndef DEBUG
+#ifdef _BLD_DEBUG
+#define DEBUG 1
+#endif /*_BLD_DEBUG*/
+#endif /*DEBUG*/
+#if DEBUG
+extern void _vmmessage _ARG_((const char*, long, const char*, long));
+#define ABORT() (_Vmassert & VM_abort)
+#define CHECK() (_Vmassert & VM_check)
+#define ASSERT(p) ((p) ? 0 : (MESSAGE("Assertion failed"), ABORT() ? (abort(),0) : 0))
+#define COUNT(n) ((n) += 1)
+#define MESSAGE(s) _vmmessage(__FILE__,__LINE__,s,0)
+#else
+#define ABORT() (0)
+#define ASSERT(p)
+#define CHECK() (0)
+#define COUNT(n)
+#define MESSAGE(s) (0)
+#endif /*DEBUG*/
+
+#define VMPAGESIZE 8192
+#if _AST_PAGESIZE > VMPAGESIZE
+#undef VMPAGESIZE
+#define VMPAGESIZE _AST_PAGESIZE
+#endif
+#if _lib_getpagesize
+#define GETPAGESIZE(x) ((x) ? (x) : \
+ (((x)=getpagesize()) < VMPAGESIZE ? ((x)=VMPAGESIZE) : (x)) )
+#else
+#define GETPAGESIZE(x) ((x) = VMPAGESIZE)
+#endif
+
+/* Blocks are allocated such that their sizes are 0%(BITS+1)
+** This frees up enough low order bits to store state information
+*/
+#define BUSY (01) /* block is busy */
+#define PFREE (02) /* preceding block is free */
+#define JUNK (04) /* marked as freed but not yet processed */
+#define BITS (07) /* (BUSY|PFREE|JUNK) */
+#define ALIGNB (8) /* size must be a multiple of BITS+1 */
+
+#define ISBITS(w) ((w) & BITS)
+#define CLRBITS(w) ((w) &= ~BITS)
+#define CPYBITS(w,f) ((w) |= ((f)&BITS) )
+
+#define ISBUSY(w) ((w) & BUSY)
+#define SETBUSY(w) ((w) |= BUSY)
+#define CLRBUSY(w) ((w) &= ~BUSY)
+
+#define ISPFREE(w) ((w) & PFREE)
+#define SETPFREE(w) ((w) |= PFREE)
+#define CLRPFREE(w) ((w) &= ~PFREE)
+
+#define ISJUNK(w) ((w) & JUNK)
+#define SETJUNK(w) ((w) |= JUNK)
+#define CLRJUNK(w) ((w) &= ~JUNK)
+
+#define OFFSET(t,e) ((size_t)(&(((t*)0)->e)) )
+
+/* these bits share the "mode" field with the public bits */
+#define VM_AGAIN 0010000 /* research the arena for space */
+#define VM_LOCK 0020000 /* region is locked */
+#define VM_LOCAL 0040000 /* local call, bypass lock */
+#define VM_UNUSED 0104060
+#define VMETHOD(vd) ((vd)->mode&VM_METHODS)
+
+/* test/set/clear lock state */
+#define SETLOCAL(vd) ((vd)->mode |= VM_LOCAL)
+#define GETLOCAL(vd,l) (((l) = (vd)->mode&VM_LOCAL), ((vd)->mode &= ~VM_LOCAL) )
+#define ISLOCK(vd,l) ((l) ? 0 : ((vd)->mode & VM_LOCK) )
+#define SETLOCK(vd,l) ((l) ? 0 : ((vd)->mode |= VM_LOCK) )
+#define CLRLOCK(vd,l) ((l) ? 0 : ((vd)->mode &= ~VM_LOCK) )
+
+/* announcing entry/exit of allocation calls */
+#define ANNOUNCE(lc, vm,ev,dt,dc) \
+ (( ((lc)&VM_LOCAL) || !(dc) || !(dc)->exceptf ) ? 0 : \
+ (*(dc)->exceptf)((vm), (ev), (Void_t*)(dt), (dc)) )
+
+
+/* local calls */
+#define KPVALLOC(vm,sz,func) (SETLOCAL((vm)->data), func((vm),(sz)) )
+#define KPVALIGN(vm,sz,al,func) (SETLOCAL((vm)->data), func((vm),(sz),(al)) )
+#define KPVFREE(vm,d,func) (SETLOCAL((vm)->data), func((vm),(d)) )
+#define KPVRESIZE(vm,d,sz,mv,func) (SETLOCAL((vm)->data), func((vm),(d),(sz),(mv)) )
+#define KPVADDR(vm,addr,func) (SETLOCAL((vm)->data), func((vm),(addr)) )
+#define KPVCOMPACT(vm,func) (SETLOCAL((vm)->data), func((vm)) )
+
+/* ALIGN is chosen so that a block can store all primitive types.
+** It should also be a multiple of ALIGNB==(BITS+1) so the size field
+** of Block_t will always be 0%(BITS+1) as noted above.
+** Of paramount importance is the ALIGNA macro below. If the local compile
+** environment is strange enough that the below method does not calculate
+** ALIGNA right, then the code below should be commented out and ALIGNA
+** redefined to the appropriate requirement.
+*/
+union _align_u
+{ char c, *cp;
+ int i, *ip;
+ long l, *lp;
+ double d, *dp, ***dppp[8];
+ size_t s, *sp;
+ void(* fn)();
+ union _align_u* align;
+ Head_t* head;
+ Body_t* body;
+ Block_t* block;
+ Vmuchar_t a[ALIGNB];
+ _ast_fltmax_t ld, *ldp;
+ jmp_buf jmp;
+};
+struct _a_s
+{ char c;
+ union _align_u a;
+};
+#define ALIGNA (sizeof(struct _a_s) - sizeof(union _align_u))
+struct _align_s
+{ char data[MULTIPLE(ALIGNA,ALIGNB)];
+};
+#undef ALIGN /* bsd sys/param.h defines this */
+#define ALIGN sizeof(struct _align_s)
+
+/* make sure that the head of a block is a multiple of ALIGN */
+struct _head_s
+{ union
+ { Seg_t* seg; /* the containing segment */
+ Block_t* link; /* possible link list usage */
+ Pfobj_t* pf; /* profile structure pointer */
+ char* file; /* for file name in Vmdebug */
+ } seg;
+ union
+ { size_t size; /* size of data area in bytes */
+ Block_t* link; /* possible link list usage */
+ int line; /* for line number in Vmdebug */
+ } size;
+};
+#define HEADSIZE ROUND(sizeof(struct _head_s),ALIGN)
+union _head_u
+{ Vmuchar_t data[HEADSIZE]; /* to standardize size */
+ struct _head_s head;
+};
+
+/* now make sure that the body of a block is a multiple of ALIGN */
+struct _body_s
+{ Block_t* link; /* next in link list */
+ Block_t* left; /* left child in free tree */
+ Block_t* right; /* right child in free tree */
+ Block_t** self; /* self pointer when free */
+};
+#define BODYSIZE ROUND(sizeof(struct _body_s),ALIGN)
+union _body_u
+{ Vmuchar_t data[BODYSIZE]; /* to standardize size */
+ struct _body_s body;
+};
+
+/* After all the songs and dances, we should now have:
+** sizeof(Head_t)%ALIGN == 0
+** sizeof(Body_t)%ALIGN == 0
+** and sizeof(Block_t) = sizeof(Head_t)+sizeof(Body_t)
+*/
+struct _block_s
+{ Head_t head;
+ Body_t body;
+};
+
+/* requirements for smallest block type */
+struct _tiny_s
+{ Block_t* link;
+ Block_t* self;
+};
+#define TINYSIZE ROUND(sizeof(struct _tiny_s),ALIGN)
+#define S_TINY 1 /* # of tiny blocks */
+#define MAXTINY (S_TINY*ALIGN + TINYSIZE)
+#define TLEFT(b) ((b)->head.head.seg.link) /* instead of LEFT */
+#define TINIEST(b) (SIZE(b) == TINYSIZE) /* this type uses TLEFT */
+
+#define DIV(x,y) ((y) == 8 ? ((x)>>3) : (x)/(y) )
+#define INDEX(s) DIV((s)-TINYSIZE,ALIGN)
+
+/* small block types kept in separate caches for quick allocation */
+#define S_CACHE 6 /* # of types of small blocks to be cached */
+#define N_CACHE 32 /* on allocation, create this many at a time */
+#define MAXCACHE (S_CACHE*ALIGN + TINYSIZE)
+#define C_INDEX(s) (s < MAXCACHE ? INDEX(s) : S_CACHE)
+
+#define TINY(vd) ((vd)->tiny)
+#define CACHE(vd) ((vd)->cache)
+
+typedef struct _vmdata_s
+{ int mode; /* current mode for region */
+ size_t incr; /* allocate in multiple of this */
+ size_t pool; /* size of an elt in a Vmpool region */
+ Seg_t* seg; /* list of segments */
+ Block_t* free; /* most recent free block */
+ Block_t* wild; /* wilderness block */
+ Block_t* root; /* root of free tree */
+ Block_t* tiny[S_TINY]; /* small blocks */
+ Block_t* cache[S_CACHE+1]; /* delayed free blocks */
+} Vmdata_t;
+
+/* private parts of Vmalloc_t */
+#define _VM_PRIVATE_ \
+ Vmdisc_t* disc; /* discipline to get space */ \
+ Vmdata_t* data; /* the real region data */ \
+ Vmalloc_t* next; /* linked list of regions */
+
+#include "vmalloc.h"
+
+#if !_PACKAGE_ast
+/* we don't use these here and they interfere with some local names */
+#undef malloc
+#undef free
+#undef realloc
+#endif
+
+/* segment structure */
+struct _seg_s
+{ Vmalloc_t* vm; /* the region that holds this */
+ Seg_t* next; /* next segment */
+ Void_t* addr; /* starting segment address */
+ size_t extent; /* extent of segment */
+ Vmuchar_t* baddr; /* bottom of usable memory */
+ size_t size; /* allocable size */
+ Block_t* free; /* recent free blocks */
+ Block_t* last; /* Vmlast last-allocated block */
+};
+
+/* starting block of a segment */
+#define SEGBLOCK(s) ((Block_t*)(((Vmuchar_t*)(s)) + ROUND(sizeof(Seg_t),ALIGN)))
+
+/* short-hands for block data */
+#define SEG(b) ((b)->head.head.seg.seg)
+#define SEGLINK(b) ((b)->head.head.seg.link)
+#define SIZE(b) ((b)->head.head.size.size)
+#define SIZELINK(b) ((b)->head.head.size.link)
+#define LINK(b) ((b)->body.body.link)
+#define LEFT(b) ((b)->body.body.left)
+#define RIGHT(b) ((b)->body.body.right)
+#define VM(b) (SEG(b)->vm)
+
+#define DATA(b) ((Void_t*)((b)->body.data) )
+#define BLOCK(d) ((Block_t*)((char*)(d) - sizeof(Head_t)) )
+#define SELF(b) ((Block_t**)((b)->body.data + SIZE(b) - sizeof(Block_t*)) )
+#define LAST(b) (*((Block_t**)(((char*)(b)) - sizeof(Block_t*)) ) )
+#define NEXT(b) ((Block_t*)((b)->body.data + SIZE(b)) )
+
+/* functions to manipulate link lists of elts of the same size */
+#define SETLINK(b) (RIGHT(b) = (b) )
+#define ISLINK(b) (RIGHT(b) == (b) )
+#define UNLINK(vd,b,i,t) \
+ ((((t) = LINK(b)) ? (LEFT(t) = LEFT(b)) : NIL(Block_t*) ), \
+ (((t) = LEFT(b)) ? (LINK(t) = LINK(b)) : (TINY(vd)[i] = LINK(b)) ) )
+
+/* delete a block from a link list or the free tree.
+** The test in the below macro is worth scratching your head a bit.
+** Even though tiny blocks (size < BODYSIZE) are kept in separate lists,
+** only the TINIEST ones require TLEFT(b) for the back link. Since this
+** destroys the SEG(b) pointer, it must be carefully restored in bestsearch().
+** Other tiny blocks have enough space to use the usual LEFT(b).
+** In this case, I have also carefully arranged so that RIGHT(b) and
+** SELF(b) can be overlapped and the test ISLINK() will go through.
+*/
+#define REMOVE(vd,b,i,t,func) \
+ ((!TINIEST(b) && ISLINK(b)) ? UNLINK((vd),(b),(i),(t)) : \
+ func((vd),SIZE(b),(b)) )
+
+/* see if a block is the wilderness block */
+#define SEGWILD(b) (((b)->body.data+SIZE(b)+sizeof(Head_t)) >= SEG(b)->baddr)
+#define VMWILD(vd,b) (((b)->body.data+SIZE(b)+sizeof(Head_t)) >= vd->seg->baddr)
+
+#define VMFLF(vm,fi,ln,fn) ((fi) = (vm)->file, (vm)->file = NIL(char*), \
+ (ln) = (vm)->line, (vm)->line = 0 , \
+ (fn) = (vm)->func, (vm)->func = NIL(Void_t*) )
+
+/* The lay-out of a Vmprofile block is this:
+** seg_ size ----data---- _pf_ size
+** _________ ____________ _________
+** seg_, size: header required by Vmbest.
+** data: actual data block.
+** _pf_: pointer to the corresponding Pfobj_t struct
+** size: the true size of the block.
+** So each block requires an extra Head_t.
+*/
+#define PF_EXTRA sizeof(Head_t)
+#define PFDATA(d) ((Head_t*)((Vmuchar_t*)(d)+(SIZE(BLOCK(d))&~BITS)-sizeof(Head_t)) )
+#define PFOBJ(d) (PFDATA(d)->head.seg.pf)
+#define PFSIZE(d) (PFDATA(d)->head.size.size)
+
+/* The lay-out of a block allocated by Vmdebug is this:
+** seg_ size file size seg_ magi ----data---- --magi-- magi line
+** --------- --------- --------- ------------ -------- ---------
+** seg_,size: header required by Vmbest management.
+** file: the file where it was created.
+** size: the true byte count of the block
+** seg_: should be the same as the previous seg_.
+** This allows the function vmregion() to work.
+** magi: magic bytes to detect overwrites.
+** data: the actual data block.
+** magi: more magic bytes.
+** line: the line number in the file where it was created.
+** So for each allocated block, we'll need 3 extra Head_t.
+*/
+
+/* convenient macros for accessing the above fields */
+#define DB_HEAD (2*sizeof(Head_t))
+#define DB_TAIL (2*sizeof(Head_t))
+#define DB_EXTRA (DB_HEAD+DB_TAIL)
+#define DBBLOCK(d) ((Block_t*)((Vmuchar_t*)(d) - 3*sizeof(Head_t)) )
+#define DBBSIZE(d) (SIZE(DBBLOCK(d)) & ~BITS)
+#define DBSEG(d) (((Head_t*)((Vmuchar_t*)(d) - sizeof(Head_t)))->head.seg.seg )
+#define DBSIZE(d) (((Head_t*)((Vmuchar_t*)(d) - 2*sizeof(Head_t)))->head.size.size )
+#define DBFILE(d) (((Head_t*)((Vmuchar_t*)(d) - 2*sizeof(Head_t)))->head.seg.file )
+#define DBLN(d) (((Head_t*)((Vmuchar_t*)DBBLOCK(d)+DBBSIZE(d)))->head.size.line )
+#define DBLINE(d) (DBLN(d) < 0 ? -DBLN(d) : DBLN(d))
+
+/* forward/backward translation for addresses between Vmbest and Vmdebug */
+#define DB2BEST(d) ((Vmuchar_t*)(d) - 2*sizeof(Head_t))
+#define DB2DEBUG(b) ((Vmuchar_t*)(b) + 2*sizeof(Head_t))
+
+/* set file and line number, note that DBLN > 0 so that DBISBAD will work */
+#define DBSETFL(d,f,l) (DBFILE(d) = (f), DBLN(d) = (f) ? (l) : 1)
+
+/* set and test the state of known to be corrupted */
+#define DBSETBAD(d) (DBLN(d) > 0 ? (DBLN(d) = -DBLN(d)) : -1)
+#define DBISBAD(d) (DBLN(d) <= 0)
+
+#define DB_MAGIC 0255 /* 10101101 */
+
+/* compute the bounds of the magic areas */
+#define DBHEAD(d,begp,endp) \
+ (((begp) = (Vmuchar_t*)(&DBSEG(d)) + sizeof(Seg_t*)), ((endp) = (d)) )
+#define DBTAIL(d,begp,endp) \
+ (((begp) = (Vmuchar_t*)(d)+DBSIZE(d)), ((endp) = (Vmuchar_t*)(&DBLN(d))) )
+
+/* external symbols for internal use by vmalloc */
+typedef Block_t* (*Vmsearch_f)_ARG_((Vmdata_t*, size_t, Block_t*));
+typedef struct _vmextern_
+{ Block_t* (*vm_extend)_ARG_((Vmalloc_t*, size_t, Vmsearch_f ));
+ ssize_t (*vm_truncate)_ARG_((Vmalloc_t*, Seg_t*, size_t, int));
+ size_t vm_pagesize;
+ char* (*vm_strcpy)_ARG_((char*, const char*, int));
+ char* (*vm_itoa)_ARG_((Vmulong_t, int));
+ void (*vm_trace)_ARG_((Vmalloc_t*,
+ Vmuchar_t*, Vmuchar_t*, size_t, size_t));
+ void (*vm_pfclose)_ARG_((Vmalloc_t*));
+ int vm_assert;
+} Vmextern_t;
+
+#define _Vmextend (_Vmextern.vm_extend)
+#define _Vmtruncate (_Vmextern.vm_truncate)
+#define _Vmpagesize (_Vmextern.vm_pagesize)
+#define _Vmstrcpy (_Vmextern.vm_strcpy)
+#define _Vmitoa (_Vmextern.vm_itoa)
+#define _Vmtrace (_Vmextern.vm_trace)
+#define _Vmpfclose (_Vmextern.vm_pfclose)
+#define _Vmassert (_Vmextern.vm_assert)
+
+extern int _vmbestcheck _ARG_((Vmdata_t*, Block_t*));
+
+_BEGIN_EXTERNS_
+
+extern Vmextern_t _Vmextern;
+
+#if _PACKAGE_ast
+
+#if _npt_getpagesize
+extern int getpagesize _ARG_((void));
+#endif
+#if _npt_sbrk
+extern int brk _ARG_(( void* ));
+extern Void_t* sbrk _ARG_(( ssize_t ));
+#endif
+
+#else
+
+#if _hdr_unistd
+#include <unistd.h>
+#else
+extern void abort _ARG_(( void ));
+extern ssize_t write _ARG_(( int, const void*, size_t ));
+extern int getpagesize _ARG_((void));
+extern Void_t* sbrk _ARG_((ssize_t));
+#endif
+
+#if !__STDC__ && !_hdr_stdlib
+extern size_t strlen _ARG_(( const char* ));
+extern char* strcpy _ARG_(( char*, const char* ));
+extern int strcmp _ARG_(( const char*, const char* ));
+extern int atexit _ARG_(( void(*)(void) ));
+extern char* getenv _ARG_(( const char* ));
+extern Void_t* memcpy _ARG_(( Void_t*, const Void_t*, size_t ));
+extern Void_t* memset _ARG_(( Void_t*, int, size_t ));
+#else
+#include <stdlib.h>
+#include <string.h>
+#endif
+
+/* for vmexit.c */
+extern int onexit _ARG_(( void(*)(void) ));
+extern void _exit _ARG_(( int ));
+extern void _cleanup _ARG_(( void ));
+
+#endif /*_PACKAGE_ast*/
+
+_END_EXTERNS_
+
+#if _UWIN
+#define abort() (DebugBreak(),abort())
+#endif
+
+#endif /* _VMHDR_H */
diff --git a/usr/src/lib/libast/common/vmalloc/vmlast.c b/usr/src/lib/libast/common/vmalloc/vmlast.c
new file mode 100644
index 0000000000..056e30ce59
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmlast.c
@@ -0,0 +1,453 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmlast(){}
+
+#else
+
+#include "vmhdr.h"
+
+/* Allocation with freeing and reallocing of last allocated block only.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+
+#if __STD_C
+static Void_t* lastalloc(Vmalloc_t* vm, size_t size)
+#else
+static Void_t* lastalloc(vm, size)
+Vmalloc_t* vm;
+size_t size;
+#endif
+{
+ reg Block_t *tp, *next;
+ reg Seg_t *seg, *last;
+ reg size_t s;
+ reg Vmdata_t* vd = vm->data;
+ reg int local;
+ size_t orgsize = 0;
+
+ if(!(local = vd->mode&VM_TRUST))
+ { GETLOCAL(vd,local);
+ if(ISLOCK(vd,local))
+ return NIL(Void_t*);
+ SETLOCK(vd,local);
+ orgsize = size;
+ }
+
+ size = size < ALIGN ? ALIGN : ROUND(size,ALIGN);
+ for(;;)
+ { for(last = NIL(Seg_t*), seg = vd->seg; seg; last = seg, seg = seg->next)
+ { if(!(tp = seg->free) || (SIZE(tp)+sizeof(Head_t)) < size)
+ continue;
+ if(last)
+ { last->next = seg->next;
+ seg->next = vd->seg;
+ vd->seg = seg;
+ }
+ goto got_block;
+ }
+
+ /* there is no usable free space in region, try extending */
+ if((tp = (*_Vmextend)(vm,size,NIL(Vmsearch_f))) )
+ { seg = SEG(tp);
+ goto got_block;
+ }
+ else if(vd->mode&VM_AGAIN)
+ vd->mode &= ~VM_AGAIN;
+ else goto done;
+ }
+
+got_block:
+ if((s = SIZE(tp)) >= size)
+ { next = (Block_t*)((Vmuchar_t*)tp+size);
+ SIZE(next) = s - size;
+ SEG(next) = seg;
+ seg->free = next;
+ }
+ else seg->free = NIL(Block_t*);
+
+ vd->free = seg->last = tp;
+
+ if(!local && (vd->mode&VM_TRACE) && _Vmtrace)
+ (*_Vmtrace)(vm, NIL(Vmuchar_t*), (Vmuchar_t*)tp, orgsize, 0);
+
+done:
+ CLRLOCK(vd,local);
+ ANNOUNCE(local, vm, VM_ALLOC, (Void_t*)tp, vm->disc);
+ return (Void_t*)tp;
+}
+
+#if __STD_C
+static int lastfree(Vmalloc_t* vm, reg Void_t* data )
+#else
+static int lastfree(vm, data)
+Vmalloc_t* vm;
+reg Void_t* data;
+#endif
+{
+ reg Seg_t* seg;
+ reg Block_t* fp;
+ reg size_t s;
+ reg Vmdata_t* vd = vm->data;
+ reg int local;
+
+ if(!data)
+ return 0;
+ if(!(local = vd->mode&VM_TRUST) )
+ { GETLOCAL(vd, local);
+ if(ISLOCK(vd, local))
+ return -1;
+ SETLOCK(vd, local);
+ }
+ if(data != (Void_t*)vd->free)
+ { if(!local && vm->disc->exceptf)
+ (void)(*vm->disc->exceptf)(vm,VM_BADADDR,data,vm->disc);
+ CLRLOCK(vd, local);
+ return -1;
+ }
+
+ seg = vd->seg;
+ if(!local && (vd->mode&VM_TRACE) && _Vmtrace)
+ { if(seg->free )
+ s = (Vmuchar_t*)(seg->free) - (Vmuchar_t*)data;
+ else s = (Vmuchar_t*)BLOCK(seg->baddr) - (Vmuchar_t*)data;
+ (*_Vmtrace)(vm, (Vmuchar_t*)data, NIL(Vmuchar_t*), s, 0);
+ }
+
+ vd->free = NIL(Block_t*);
+ fp = (Block_t*)data;
+ SEG(fp) = seg;
+ SIZE(fp) = ((Vmuchar_t*)BLOCK(seg->baddr) - (Vmuchar_t*)data) - sizeof(Head_t);
+ seg->free = fp;
+ seg->last = NIL(Block_t*);
+
+ CLRLOCK(vd, local);
+ ANNOUNCE(local, vm, VM_FREE, data, vm->disc);
+ return 0;
+}
+
+#if __STD_C
+static Void_t* lastresize(Vmalloc_t* vm, reg Void_t* data, size_t size, int type )
+#else
+static Void_t* lastresize(vm, data, size, type )
+Vmalloc_t* vm;
+reg Void_t* data;
+size_t size;
+int type;
+#endif
+{
+ reg Block_t* tp;
+ reg Seg_t *seg;
+ reg size_t oldsize;
+ reg ssize_t s, ds;
+ reg Vmdata_t* vd = vm->data;
+ reg int local;
+ reg Void_t* addr;
+ Void_t* orgdata = NIL(Void_t*);
+ size_t orgsize = 0;
+
+ if(!data)
+ { oldsize = 0;
+ data = lastalloc(vm,size);
+ goto done;
+ }
+ if(size <= 0)
+ { (void)lastfree(vm,data);
+ return NIL(Void_t*);
+ }
+
+ if(!(local = vd->mode&VM_TRUST))
+ { GETLOCAL(vd, local);
+ if(ISLOCK(vd, local))
+ return NIL(Void_t*);
+ SETLOCK(vd, local);
+ orgdata = data;
+ orgsize = size;
+ }
+
+ if(data == (Void_t*)vd->free)
+ seg = vd->seg;
+ else
+ { /* see if it was one of ours */
+ for(seg = vd->seg; seg; seg = seg->next)
+ if(data >= seg->addr && data < (Void_t*)seg->baddr)
+ break;
+ if(!seg || (VLONG(data)%ALIGN) != 0 ||
+ (seg->last && (Vmuchar_t*)data > (Vmuchar_t*)seg->last) )
+ { CLRLOCK(vd,0);
+ return NIL(Void_t*);
+ }
+ }
+
+ /* set 's' to be the current available space */
+ if(data != seg->last)
+ { if(seg->last && (Vmuchar_t*)data < (Vmuchar_t*)seg->last)
+ oldsize = (Vmuchar_t*)seg->last - (Vmuchar_t*)data;
+ else oldsize = (Vmuchar_t*)BLOCK(seg->baddr) - (Vmuchar_t*)data;
+ s = -1;
+ }
+ else
+ { s = (Vmuchar_t*)BLOCK(seg->baddr) - (Vmuchar_t*)data;
+ if(!(tp = seg->free) )
+ oldsize = s;
+ else
+ { oldsize = (Vmuchar_t*)tp - (Vmuchar_t*)data;
+ seg->free = NIL(Block_t*);
+ }
+ }
+
+ size = size < ALIGN ? ALIGN : ROUND(size,ALIGN);
+ if(s < 0 || (ssize_t)size > s)
+ { if(s >= 0) /* amount to extend */
+ { ds = size-s; ds = ROUND(ds,vd->incr);
+ addr = (*vm->disc->memoryf)(vm, seg->addr, seg->extent,
+ seg->extent+ds, vm->disc);
+ if(addr == seg->addr)
+ { s += ds;
+ seg->size += ds;
+ seg->extent += ds;
+ seg->baddr += ds;
+ SIZE(BLOCK(seg->baddr)) = BUSY;
+ }
+ else goto do_alloc;
+ }
+ else
+ { do_alloc:
+ if(!(type&(VM_RSMOVE|VM_RSCOPY)) )
+ data = NIL(Void_t*);
+ else
+ { tp = vd->free;
+ if(!(addr = KPVALLOC(vm,size,lastalloc)) )
+ { vd->free = tp;
+ data = NIL(Void_t*);
+ }
+ else
+ { if(type&VM_RSCOPY)
+ { ds = oldsize < size ? oldsize : size;
+ memcpy(addr, data, ds);
+ }
+
+ if(s >= 0 && seg != vd->seg)
+ { tp = (Block_t*)data;
+ SEG(tp) = seg;
+ SIZE(tp) = s - sizeof(Head_t);
+ seg->free = tp;
+ }
+
+ /* new block and size */
+ data = addr;
+ seg = vd->seg;
+ s = (Vmuchar_t*)BLOCK(seg->baddr) -
+ (Vmuchar_t*)data;
+ seg->free = NIL(Block_t*);
+ }
+ }
+ }
+ }
+
+ if(data)
+ { if(s >= (ssize_t)(size+sizeof(Head_t)) )
+ { tp = (Block_t*)((Vmuchar_t*)data + size);
+ SEG(tp) = seg;
+ SIZE(tp) = (s - size) - sizeof(Head_t);
+ seg->free = tp;
+ }
+
+ vd->free = seg->last = (Block_t*)data;
+
+ if(!local && (vd->mode&VM_TRACE) && _Vmtrace)
+ (*_Vmtrace)(vm,(Vmuchar_t*)orgdata,(Vmuchar_t*)data,orgsize,0);
+ }
+
+ CLRLOCK(vd, local);
+ ANNOUNCE(local, vm, VM_RESIZE, data, vm->disc);
+
+done: if(data && (type&VM_RSZERO) && size > oldsize)
+ memset((Void_t*)((Vmuchar_t*)data + oldsize), 0, size-oldsize);
+
+ return data;
+}
+
+
+#if __STD_C
+static long lastaddr(Vmalloc_t* vm, Void_t* addr)
+#else
+static long lastaddr(vm, addr)
+Vmalloc_t* vm;
+Void_t* addr;
+#endif
+{
+ reg Vmdata_t* vd = vm->data;
+
+ if(!(vd->mode&VM_TRUST) && ISLOCK(vd,0))
+ return -1L;
+ if(!vd->free || addr < (Void_t*)vd->free || addr >= (Void_t*)vd->seg->baddr)
+ return -1L;
+ else return (Vmuchar_t*)addr - (Vmuchar_t*)vd->free;
+}
+
+#if __STD_C
+static long lastsize(Vmalloc_t* vm, Void_t* addr)
+#else
+static long lastsize(vm, addr)
+Vmalloc_t* vm;
+Void_t* addr;
+#endif
+{
+ reg Vmdata_t* vd = vm->data;
+
+ if(!(vd->mode&VM_TRUST) && ISLOCK(vd,0))
+ return -1L;
+ if(!vd->free || addr != (Void_t*)vd->free )
+ return -1L;
+ else if(vd->seg->free)
+ return (Vmuchar_t*)vd->seg->free - (Vmuchar_t*)addr;
+ else return (Vmuchar_t*)vd->seg->baddr - (Vmuchar_t*)addr - sizeof(Head_t);
+}
+
+#if __STD_C
+static int lastcompact(Vmalloc_t* vm)
+#else
+static int lastcompact(vm)
+Vmalloc_t* vm;
+#endif
+{
+ reg Block_t* fp;
+ reg Seg_t *seg, *next;
+ reg size_t s;
+ reg Vmdata_t* vd = vm->data;
+
+ if(!(vd->mode&VM_TRUST))
+ { if(ISLOCK(vd,0))
+ return -1;
+ SETLOCK(vd,0);
+ }
+
+ for(seg = vd->seg; seg; seg = next)
+ { next = seg->next;
+
+ if(!(fp = seg->free))
+ continue;
+
+ seg->free = NIL(Block_t*);
+ if(seg->size == (s = SIZE(fp)&~BITS))
+ s = seg->extent;
+ else s += sizeof(Head_t);
+
+ if((*_Vmtruncate)(vm,seg,s,1) == s)
+ seg->free = fp;
+ }
+
+ if((vd->mode&VM_TRACE) && _Vmtrace)
+ (*_Vmtrace)(vm,(Vmuchar_t*)0,(Vmuchar_t*)0,0,0);
+
+ CLRLOCK(vd,0);
+ return 0;
+}
+
+#if __STD_C
+static Void_t* lastalign(Vmalloc_t* vm, size_t size, size_t align)
+#else
+static Void_t* lastalign(vm, size, align)
+Vmalloc_t* vm;
+size_t size;
+size_t align;
+#endif
+{
+ reg Vmuchar_t* data;
+ reg Seg_t* seg;
+ reg Block_t* next;
+ reg int local;
+ reg size_t s, orgsize = 0, orgalign = 0;
+ reg Vmdata_t* vd = vm->data;
+
+ if(size <= 0 || align <= 0)
+ return NIL(Void_t*);
+
+ if(!(local = vd->mode&VM_TRUST) )
+ { GETLOCAL(vd,local);
+ if(ISLOCK(vd,local) )
+ return NIL(Void_t*);
+ SETLOCK(vd,local);
+ orgsize = size;
+ orgalign = align;
+ }
+
+ size = size <= TINYSIZE ? TINYSIZE : ROUND(size,ALIGN);
+ align = MULTIPLE(align,ALIGN);
+
+ s = size + align;
+ if(!(data = (Vmuchar_t*)KPVALLOC(vm,s,lastalloc)) )
+ goto done;
+
+ /* find the segment containing this block */
+ for(seg = vd->seg; seg; seg = seg->next)
+ if(seg->last == (Block_t*)data)
+ break;
+ /**/ASSERT(seg);
+
+ /* get a suitably aligned address */
+ if((s = (size_t)(VLONG(data)%align)) != 0)
+ data += align-s; /**/ASSERT((VLONG(data)%align) == 0);
+
+ /* free the unused tail */
+ next = (Block_t*)(data+size);
+ if((s = (seg->baddr - (Vmuchar_t*)next)) >= sizeof(Block_t))
+ { SEG(next) = seg;
+ SIZE(next) = s - sizeof(Head_t);
+ seg->free = next;
+ }
+
+ vd->free = seg->last = (Block_t*)data;
+
+ if(!local && !(vd->mode&VM_TRUST) && _Vmtrace && (vd->mode&VM_TRACE) )
+ (*_Vmtrace)(vm,NIL(Vmuchar_t*),data,orgsize,orgalign);
+
+done:
+ CLRLOCK(vd,local);
+ ANNOUNCE(local, vm, VM_ALLOC, (Void_t*)data, vm->disc);
+
+ return (Void_t*)data;
+}
+
+/* Public method for free-1 allocation */
+static Vmethod_t _Vmlast =
+{
+ lastalloc,
+ lastresize,
+ lastfree,
+ lastaddr,
+ lastsize,
+ lastcompact,
+ lastalign,
+ VM_MTLAST
+};
+
+__DEFINE__(Vmethod_t*,Vmlast,&_Vmlast);
+
+#ifdef NoF
+NoF(vmlast)
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmmopen.c b/usr/src/lib/libast/common/vmalloc/vmmopen.c
new file mode 100644
index 0000000000..90692ae744
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmmopen.c
@@ -0,0 +1,324 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmmopen(){}
+
+#else
+
+#include "vmhdr.h"
+
+#if _sys_stat
+#include <sys/stat.h>
+#endif
+#include <fcntl.h>
+
+#ifdef S_IRUSR
+#define CREAT_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
+#else
+#define CREAT_MODE 0644
+#endif
+
+#if _lib_mmap
+#include <sys/mman.h>
+#else
+#define mmap(a,b,c,d,e,f) MAP_FAILED
+#define munmap(a,b) MAP_FAILED
+#endif
+
+/* Create a region to allocate based on mmap()
+**
+** Written by Kiem-Phong Vo (kpv@research.att.com)
+*/
+
+#ifndef MAP_FAILED
+#define MAP_FAILED (void*)(-1)
+#endif
+
+#define MM_MAGIC (('V'<<24) | ('M'<<16) | ('A'<<8) | ('P'))
+#define MM_ROUND (64*1024)
+#define MM_START ROUND(sizeof(Mmvm_t),ALIGN)
+
+typedef struct _user_s
+{ struct _user_s* next; /* link list */
+ int key; /* identifying key */
+ Void_t* data; /* data to be returned */
+} User_t;
+
+typedef struct _mmvm_s
+{
+ Vmulong_t magic; /* magic bytes */
+ Void_t* base; /* base of the map */
+ size_t size; /* current size */
+ size_t busy; /* amount in use */
+ size_t round; /* amount to round to */
+ User_t* user; /* some user data */
+} Mmvm_t;
+
+typedef struct _mmvmdisc_s
+{
+ Vmdisc_t disc; /* Vmalloc discipline */
+ int fd; /* file descriptor */
+ Mmvm_t* mm; /* mmap data */
+} Mmvmdisc_t;
+
+#if __STD_C
+static int mmvminit(char* file, Void_t* addr, size_t round, Mmvm_t* mm)
+#else
+static int mmvminit(file, addr, round, mm)
+char* file; /* file to map data from */
+Void_t* addr; /* desired starting address */
+size_t round; /* amount to round requests */
+Mmvm_t* mm; /* to return some mapped info */
+#endif
+{
+ int fd;
+ off_t size;
+ Void_t *base;
+ Mmvm_t *hdr;
+
+ base = NIL(Void_t*);
+ if((fd = open(file, O_RDWR, CREAT_MODE)) >= 0)
+ { if((size = lseek(fd, (off_t)0, 2)) < 0)
+ goto done;
+ else if(size == 0)
+ goto new_f;
+
+ /* read the header */
+ if(lseek(fd, (off_t)0, 0) != (off_t)0)
+ goto done;
+ if(read(fd, mm, sizeof(Mmvm_t)) != sizeof(Mmvm_t))
+ goto done;
+ if(mm->magic != MM_MAGIC || !mm->base ||
+ (off_t)mm->size != size || mm->busy > mm->size )
+ goto done;
+ base = (Void_t*)mmap(mm->base, mm->size, PROT_READ|PROT_WRITE,
+ MAP_FIXED|MAP_SHARED, fd, (off_t)0 );
+ if(base == (Void_t*)MAP_FAILED)
+ base = NIL(Void_t*);
+ }
+ else
+ { if((fd = open(file, O_RDWR|O_CREAT, CREAT_MODE)) < 0)
+ goto done;
+
+ new_f: /* create an initial set of data */
+ size = round;
+ if(lseek(fd, size-1, 0) != (size-1) || write(fd, "", 1) != 1 )
+ goto done;
+
+ base = (Void_t*)mmap(addr, (size_t)size, PROT_READ|PROT_WRITE,
+ (addr ? MAP_FIXED : 0)|MAP_SHARED, fd, (off_t)0 );
+ if(base == (Void_t*)MAP_FAILED)
+ base = NIL(Void_t*);
+ if(!base)
+ goto done;
+
+ /* write magic number */
+ hdr = (Mmvm_t*)base;
+ hdr->magic = MM_MAGIC;
+ hdr->base = base;
+ hdr->size = size;
+ hdr->busy = MM_START;
+ hdr->round = round;
+ hdr->user = NIL(User_t*);
+ memcpy(mm, hdr, sizeof(Mmvm_t));
+ }
+
+done:
+ if(!base)
+ { if(fd >= 0)
+ close(fd);
+ fd = -1;
+ }
+
+ return fd;
+}
+
+
+#if __STD_C
+static Void_t* mmvmmemory(Vmalloc_t* vm, Void_t* caddr,
+ size_t csize, size_t nsize, Vmdisc_t* disc)
+#else
+static Void_t* mmvmmemory(vm, caddr, csize, nsize, disc)
+Vmalloc_t* vm;
+Void_t* caddr;
+size_t csize;
+size_t nsize;
+Vmdisc_t* disc;
+#endif
+{
+ Mmvmdisc_t *mmdc = (Mmvmdisc_t*)disc;
+
+ if(mmdc->fd < 0 || !mmdc->mm)
+ return NIL(Void_t*);
+
+#define MMADDR(b) ((Void_t*)(((Vmuchar_t*)b) + MM_START) )
+ if(caddr && caddr != MMADDR(mmdc->mm->base) )
+ return NIL(Void_t*);
+ if(nsize < csize)
+ return NIL(Void_t*);
+
+ if(nsize > mmdc->mm->size-MM_START)
+ { /* base and size of new map */
+ caddr = mmdc->mm->base;
+ csize = MM_START + nsize +
+ ((nsize % disc->round) < (disc->round/2) ? disc->round/2 : 0);
+ csize = ROUND(csize, disc->round);
+
+ /* make room for new space */
+ if(lseek(mmdc->fd, (off_t)(csize-1), 0) != (off_t)(csize-1) ||
+ write(mmdc->fd, "", 1) != 1 )
+ return NIL(Void_t*);
+
+ /* remap the space */
+ (void)munmap(caddr, mmdc->mm->size);
+ caddr = (Void_t*)mmap(caddr, csize, PROT_READ|PROT_WRITE,
+ MAP_FIXED|MAP_SHARED, mmdc->fd, (off_t)0 );
+ if(caddr == (Void_t*)MAP_FAILED)
+ caddr = NIL(Void_t*);
+ if(caddr)
+ mmdc->mm->size = csize;
+ else /* bad problem */
+ { close(mmdc->fd);
+ mmdc->fd = -1;
+ mmdc->mm = NIL(Mmvm_t*);
+ return NIL(Void_t*);
+ }
+ }
+
+ mmdc->mm->busy = nsize+MM_START;
+ return (Void_t*)(((Vmuchar_t*)mmdc->mm->base) + MM_START);
+}
+
+
+#if __STD_C
+static int mmvmexcept(Vmalloc_t* vm, int type, Void_t* data, Vmdisc_t* disc)
+#else
+static int mmvmexcept(vm, type, data, disc)
+Vmalloc_t* vm;
+int type;
+Void_t* data;
+Vmdisc_t* disc;
+#endif
+{
+ Mmvmdisc_t *mmdc = (Mmvmdisc_t*)disc;
+ Vmuchar_t *base;
+
+ if(type == VM_OPEN)
+ { if(mmdc->mm->busy > MM_START)
+ { base = ((Vmuchar_t*)mmdc->mm->base) + MM_START;
+ *((Void_t**)data) = (Void_t*)base;
+ return 1;
+ }
+ else return 0;
+ }
+ else if(type == VM_CLOSE)
+ { (void)munmap(mmdc->mm->base, mmdc->mm->size);
+ (void)close(mmdc->fd);
+ vmfree(Vmheap, mmdc);
+ return 1; /* freeing of mapped data is already done */
+ }
+ else return 0;
+}
+
+
+#if __STD_C
+Vmalloc_t* vmmopen(char* file, Void_t* base, size_t round)
+#else
+Vmalloc_t* vmmopen(file, base, round)
+char* file; /* file mapping data from */
+Void_t* base; /* desired starting address */
+size_t round; /* amount to round requests */
+#endif
+{
+ Vmalloc_t *vm;
+ Mmvmdisc_t *mmdc;
+ Mmvm_t mm;
+ int fd;
+
+ if(!file)
+ return NIL(Vmalloc_t*);
+
+ /* set the amount to round up to on each memory request */
+ GETPAGESIZE(_Vmpagesize);
+ if(round < MM_ROUND)
+ round = MM_ROUND;
+ round = ROUND(round, _Vmpagesize);
+
+ if((fd = mmvminit(file, base, round, &mm)) < 0)
+ return NIL(Vmalloc_t*);
+
+ if(!(mmdc = (Mmvmdisc_t*)vmalloc(Vmheap, sizeof(Mmvmdisc_t))) )
+ { close(fd);
+ return NIL(Vmalloc_t*);
+ }
+
+ mmdc->disc.memoryf = mmvmmemory;
+ mmdc->disc.exceptf = mmvmexcept;
+ mmdc->disc.round = mm.round;
+ mmdc->fd = fd;
+ mmdc->mm = (Mmvm_t*)mm.base;
+
+ if(!(vm = vmopen(&mmdc->disc, Vmbest, VM_TRUST)) )
+ { mmvmexcept(NIL(Vmalloc_t*), VM_CLOSE, NIL(Void_t*), &mmdc->disc);
+ return NIL(Vmalloc_t*);
+ }
+
+ return vm;
+}
+
+
+#if __STD_C
+Void_t* vmmset(Vmalloc_t* vm, int key, Void_t* data, int set)
+#else
+Void_t* vmmset(vm, data, key, set)
+Vmalloc_t* vm; /* a region based on vmmmopen */
+int key; /* key of data to be set */
+Void_t* data; /* data to be set */
+int set; /* 1 for setting, 0 for getting */
+#endif
+{
+ User_t *u;
+ Mmvm_t *mmvm = ((Mmvmdisc_t*)vm->disc)->mm;
+
+ for(u = mmvm->user; u; u = u->next)
+ if(u->key == key)
+ break;
+ if(!set)
+ return u ? u->data : NIL(Void_t*);
+ else if(u)
+ { Void_t* old = u->data;
+ u->data = data;
+ return old;
+ }
+ else if(!(u = (User_t*)vmalloc(vm, sizeof(User_t))) )
+ return NIL(Void_t*);
+ else
+ { u->data = data;
+ u->key = key;
+ u->next = mmvm->user;
+ mmvm->user = u;
+ return data;
+ }
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmopen.c b/usr/src/lib/libast/common/vmalloc/vmopen.c
new file mode 100644
index 0000000000..d441410906
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmopen.c
@@ -0,0 +1,176 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmopen(){}
+
+#else
+
+#include "vmhdr.h"
+
+/* Opening a new region of allocation.
+** Note that because of possible exotic memory types,
+** all region data must be stored within the space given
+** by the discipline.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+
+typedef struct _vminit_
+{
+ Vmdata_t vd; /* space for the region itself */
+ Seg_t seg; /* space for segment */
+ Block_t block; /* space for a block */
+ Head_t head; /* space for the fake header */
+ char a[3*ALIGN]; /* extra to fuss with alignment */
+} Vminit_t;
+
+#if __STD_C
+Vmalloc_t* vmopen(Vmdisc_t* disc, Vmethod_t* meth, int mode)
+#else
+Vmalloc_t* vmopen(disc, meth, mode)
+Vmdisc_t* disc; /* discipline to get segments */
+Vmethod_t* meth; /* method to manage space */
+int mode; /* type of region */
+#endif
+{
+ reg Vmalloc_t* vm;
+ reg Vmdata_t* vd;
+ reg size_t s, a, incr;
+ reg Block_t* b;
+ reg Seg_t* seg;
+ Vmuchar_t* addr;
+ reg Vmemory_f memoryf;
+ reg int e;
+
+ if(!meth || !disc || !(memoryf = disc->memoryf) )
+ return NIL(Vmalloc_t*);
+
+ GETPAGESIZE(_Vmpagesize);
+
+ /* note that Vmalloc_t space must be local to process since that's
+ where the meth&disc function addresses are going to be stored */
+ if(!(vm = (Vmalloc_t*)vmalloc(Vmheap,sizeof(Vmalloc_t))) )
+ return NIL(Vmalloc_t*);
+ vm->meth = *meth;
+ vm->disc = disc;
+ vm->file = NIL(char*);
+ vm->line = 0;
+
+ if(disc->exceptf)
+ { addr = NIL(Vmuchar_t*);
+ if((e = (*disc->exceptf)(vm,VM_OPEN,(Void_t*)(&addr),disc)) != 0)
+ { if(e < 0 || !addr)
+ goto open_error;
+
+ /* align this address */
+ if((a = (size_t)(VLONG(addr)%ALIGN)) != 0)
+ addr += ALIGN-a;
+
+ /* see if it's a valid region */
+ vd = (Vmdata_t*)addr;
+ if((vd->mode&meth->meth) != 0)
+ { vm->data = vd;
+ return vm;
+ }
+ else
+ { open_error:
+ vmfree(Vmheap,vm);
+ return NIL(Vmalloc_t*);
+ }
+ }
+ }
+
+ /* make sure vd->incr is properly rounded */
+ incr = disc->round <= 0 ? _Vmpagesize : disc->round;
+ incr = MULTIPLE(incr,ALIGN);
+
+ /* get space for region data */
+ s = ROUND(sizeof(Vminit_t),incr);
+ if(!(addr = (Vmuchar_t*)(*memoryf)(vm,NIL(Void_t*),0,s,disc)) )
+ { vmfree(Vmheap,vm);
+ return NIL(Vmalloc_t*);
+ }
+
+ /* make sure that addr is aligned */
+ if((a = (size_t)(VLONG(addr)%ALIGN)) != 0)
+ addr += ALIGN-a;
+
+ /* initialize region */
+ vd = (Vmdata_t*)addr;
+ vd->mode = (mode&VM_FLAGS) | meth->meth;
+ vd->incr = incr;
+ vd->pool = 0;
+ vd->free = vd->wild = NIL(Block_t*);
+
+ if(vd->mode&(VM_TRACE|VM_MTDEBUG))
+ vd->mode &= ~VM_TRUST;
+
+ if(vd->mode&(VM_MTBEST|VM_MTDEBUG|VM_MTPROFILE))
+ { vd->root = NIL(Block_t*);
+ for(e = S_TINY-1; e >= 0; --e)
+ TINY(vd)[e] = NIL(Block_t*);
+ for(e = S_CACHE; e >= 0; --e)
+ CACHE(vd)[e] = NIL(Block_t*);
+ incr = sizeof(Vmdata_t);
+ }
+ else incr = OFFSET(Vmdata_t,root);
+
+ vd->seg = (Seg_t*)(addr + ROUND(incr,ALIGN));
+ /**/ ASSERT(VLONG(vd->seg)%ALIGN == 0);
+
+ seg = vd->seg;
+ seg->next = NIL(Seg_t*);
+ seg->vm = vm;
+ seg->addr = (Void_t*)(addr - (a ? ALIGN-a : 0));
+ seg->extent = s;
+ seg->baddr = addr + s - (a ? ALIGN : 0);
+ seg->size = s; /* this size is larger than usual so that the segment
+ will not be freed until the region is closed. */
+ seg->free = NIL(Block_t*);
+
+ /* make a data block out of the remainder */
+ b = SEGBLOCK(seg);
+ SEG(b) = seg;
+ SIZE(b) = seg->baddr - (Vmuchar_t*)b - 2*sizeof(Head_t);
+ *SELF(b) = b;
+ /**/ ASSERT(SIZE(b)%ALIGN == 0);
+ /**/ ASSERT(VLONG(b)%ALIGN == 0);
+
+ /* make a fake header for next block in case of noncontiguous segments */
+ SEG(NEXT(b)) = seg;
+ SIZE(NEXT(b)) = BUSY|PFREE;
+
+ if(vd->mode&(VM_MTLAST|VM_MTPOOL))
+ seg->free = b;
+ else vd->wild = b;
+
+ vm->data = vd;
+
+ /* put into linked list of regions */
+ vm->next = Vmheap->next;
+ Vmheap->next = vm;
+
+ return vm;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmpool.c b/usr/src/lib/libast/common/vmalloc/vmpool.c
new file mode 100644
index 0000000000..62ffb17cff
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmpool.c
@@ -0,0 +1,345 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmpool(){}
+
+#else
+
+#include "vmhdr.h"
+
+#define POOLFREE 0x55555555L /* block free indicator */
+
+/* Method for pool allocation.
+** All elements in a pool have the same size.
+** The following fields of Vmdata_t are used as:
+** pool: size of a block.
+** free: list of free blocks.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+
+#if __STD_C
+static Void_t* poolalloc(Vmalloc_t* vm, reg size_t size)
+#else
+static Void_t* poolalloc(vm, size )
+Vmalloc_t* vm;
+reg size_t size;
+#endif
+{
+ reg Vmdata_t* vd = vm->data;
+ reg Block_t *tp, *next;
+ reg size_t s;
+ reg Seg_t* seg;
+ reg int local;
+
+ if(size <= 0)
+ return NIL(Void_t*);
+ else if(size != vd->pool)
+ { if(vd->pool <= 0)
+ vd->pool = size;
+ else return NIL(Void_t*);
+ }
+
+ if(!(local = vd->mode&VM_TRUST) )
+ { GETLOCAL(vd,local);
+ if(ISLOCK(vd, local))
+ return NIL(Void_t*);
+ SETLOCK(vd, local);
+ }
+
+ if((tp = vd->free) ) /* there is a ready free block */
+ { vd->free = SEGLINK(tp);
+ goto done;
+ }
+
+ size = ROUND(size,ALIGN);
+
+ /* look thru all segments for a suitable free block */
+ for(tp = NIL(Block_t*), seg = vd->seg; seg; seg = seg->next)
+ { if((tp = seg->free) &&
+ (s = (SIZE(tp) & ~BITS) + sizeof(Head_t)) >= size )
+ goto has_blk;
+ }
+
+ for(;;) /* must extend region */
+ { if((tp = (*_Vmextend)(vm,ROUND(size,vd->incr),NIL(Vmsearch_f))) )
+ { s = (SIZE(tp) & ~BITS) + sizeof(Head_t);
+ seg = SEG(tp);
+ goto has_blk;
+ }
+ else if(vd->mode&VM_AGAIN)
+ vd->mode &= ~VM_AGAIN;
+ else goto done;
+ }
+
+has_blk: /* if get here, (tp, s, seg) must be well-defined */
+ next = (Block_t*)((Vmuchar_t*)tp+size);
+ if((s -= size) <= (size + sizeof(Head_t)) )
+ { for(; s >= size; s -= size)
+ { SIZE(next) = POOLFREE;
+ SEGLINK(next) = vd->free;
+ vd->free = next;
+ next = (Block_t*)((Vmuchar_t*)next + size);
+ }
+ seg->free = NIL(Block_t*);
+ }
+ else
+ { SIZE(next) = s - sizeof(Head_t);
+ SEG(next) = seg;
+ seg->free = next;
+ }
+
+done:
+ if(!local && (vd->mode&VM_TRACE) && _Vmtrace && tp)
+ (*_Vmtrace)(vm,NIL(Vmuchar_t*),(Vmuchar_t*)tp,vd->pool,0);
+
+ CLRLOCK(vd, local);
+ ANNOUNCE(local, vm, VM_ALLOC, (Void_t*)tp, vm->disc);
+ return (Void_t*)tp;
+}
+
+#if __STD_C
+static long pooladdr(Vmalloc_t* vm, reg Void_t* addr)
+#else
+static long pooladdr(vm, addr)
+Vmalloc_t* vm;
+reg Void_t* addr;
+#endif
+{
+ reg Block_t *bp, *tp;
+ reg Vmuchar_t *laddr, *baddr;
+ reg size_t size;
+ reg Seg_t* seg;
+ reg long offset;
+ reg Vmdata_t* vd = vm->data;
+ reg int local;
+
+ if(!(local = vd->mode&VM_TRUST))
+ { GETLOCAL(vd,local);
+ if(ISLOCK(vd,local))
+ return -1L;
+ SETLOCK(vd,local);
+ }
+
+ offset = -1L;
+ for(seg = vd->seg; seg; seg = seg->next)
+ { laddr = (Vmuchar_t*)SEGBLOCK(seg);
+ baddr = seg->baddr-sizeof(Head_t);
+ if((Vmuchar_t*)addr < laddr || (Vmuchar_t*)addr >= baddr)
+ continue;
+
+ /* the block that has this address */
+ size = ROUND(vd->pool,ALIGN);
+ tp = (Block_t*)(laddr + (((Vmuchar_t*)addr-laddr)/size)*size );
+
+ /* see if this block has been freed */
+ if(SIZE(tp) == POOLFREE) /* may be a coincidence - make sure */
+ for(bp = vd->free; bp; bp = SEGLINK(bp))
+ if(bp == tp)
+ goto done;
+
+ offset = (Vmuchar_t*)addr - (Vmuchar_t*)tp;
+ goto done;
+ }
+
+done :
+ CLRLOCK(vd,local);
+ return offset;
+}
+
+#if __STD_C
+static int poolfree(reg Vmalloc_t* vm, reg Void_t* data )
+#else
+static int poolfree(vm, data)
+reg Vmalloc_t* vm;
+reg Void_t* data;
+#endif
+{
+ reg Block_t* bp;
+ reg Vmdata_t* vd = vm->data;
+ reg int local;
+
+ if(!data)
+ return 0;
+
+ if(!(local = vd->mode&VM_TRUST))
+ { GETLOCAL(vd, local);
+
+ if(ISLOCK(vd, local) || vd->pool <= 0)
+ return -1;
+
+ if(KPVADDR(vm,data,pooladdr) != 0)
+ { if(vm->disc->exceptf)
+ (void)(*vm->disc->exceptf)(vm,VM_BADADDR,data,vm->disc);
+ return -1;
+ }
+
+ SETLOCK(vd, local);
+ }
+
+ bp = (Block_t*)data;
+ SIZE(bp) = POOLFREE;
+ SEGLINK(bp) = vd->free;
+ vd->free = bp;
+
+ if(!local && (vd->mode&VM_TRACE) && _Vmtrace)
+ (*_Vmtrace)(vm, (Vmuchar_t*)data, NIL(Vmuchar_t*), vd->pool, 0);
+
+ CLRLOCK(vd,local);
+ ANNOUNCE(local, vm, VM_FREE, data, vm->disc);
+ return 0;
+}
+
+#if __STD_C
+static Void_t* poolresize(Vmalloc_t* vm, Void_t* data, size_t size, int type )
+#else
+static Void_t* poolresize(vm, data, size, type )
+Vmalloc_t* vm;
+Void_t* data;
+size_t size;
+int type;
+#endif
+{
+ int local;
+ reg Vmdata_t* vd = vm->data;
+
+ NOTUSED(type);
+
+ if(!data)
+ { if((data = poolalloc(vm,size)) && (type&VM_RSZERO) )
+ { reg int *d = (int*)data, *ed = (int*)((char*)data+size);
+ do { *d++ = 0;} while(d < ed);
+ }
+ return data;
+ }
+ if(size == 0)
+ { (void)poolfree(vm,data);
+ return NIL(Void_t*);
+ }
+
+ if(!(local = vd->mode&VM_TRUST) )
+ { GETLOCAL(vd, local);
+
+ if(ISLOCK(vd, local) )
+ return NIL(Void_t*);
+
+ if(size != vd->pool || KPVADDR(vm,data,pooladdr) != 0)
+ { if(vm->disc->exceptf)
+ (void)(*vm->disc->exceptf)(vm,VM_BADADDR,data,vm->disc);
+ return NIL(Void_t*);
+ }
+
+ if((vd->mode&VM_TRACE) && _Vmtrace)
+ (*_Vmtrace)(vm, (Vmuchar_t*)data, (Vmuchar_t*)data, size, 0);
+ }
+
+ ANNOUNCE(local, vm, VM_RESIZE, data, vm->disc);
+ return data;
+}
+
+#if __STD_C
+static long poolsize(Vmalloc_t* vm, Void_t* addr)
+#else
+static long poolsize(vm, addr)
+Vmalloc_t* vm;
+Void_t* addr;
+#endif
+{
+ return pooladdr(vm,addr) == 0 ? (long)vm->data->pool : -1L;
+}
+
+#if __STD_C
+static int poolcompact(Vmalloc_t* vm)
+#else
+static int poolcompact(vm)
+Vmalloc_t* vm;
+#endif
+{
+ reg Block_t* fp;
+ reg Seg_t *seg, *next;
+ reg size_t s;
+ reg Vmdata_t* vd = vm->data;
+
+ if(!(vd->mode&VM_TRUST))
+ { if(ISLOCK(vd,0))
+ return -1;
+ SETLOCK(vd,0);
+ }
+
+ for(seg = vd->seg; seg; seg = next)
+ { next = seg->next;
+
+ if(!(fp = seg->free))
+ continue;
+
+ seg->free = NIL(Block_t*);
+ if(seg->size == (s = SIZE(fp)&~BITS))
+ s = seg->extent;
+ else s += sizeof(Head_t);
+
+ if((*_Vmtruncate)(vm,seg,s,1) == s)
+ seg->free = fp;
+ }
+
+ if((vd->mode&VM_TRACE) && _Vmtrace)
+ (*_Vmtrace)(vm, (Vmuchar_t*)0, (Vmuchar_t*)0, 0, 0);
+
+ CLRLOCK(vd,0);
+ return 0;
+}
+
+#if __STD_C
+static Void_t* poolalign(Vmalloc_t* vm, size_t size, size_t align)
+#else
+static Void_t* poolalign(vm, size, align)
+Vmalloc_t* vm;
+size_t size;
+size_t align;
+#endif
+{
+ NOTUSED(vm);
+ NOTUSED(size);
+ NOTUSED(align);
+ return NIL(Void_t*);
+}
+
+/* Public interface */
+static Vmethod_t _Vmpool =
+{
+ poolalloc,
+ poolresize,
+ poolfree,
+ pooladdr,
+ poolsize,
+ poolcompact,
+ poolalign,
+ VM_MTPOOL
+};
+
+__DEFINE__(Vmethod_t*,Vmpool,&_Vmpool);
+
+#ifdef NoF
+NoF(vmpool)
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmprivate.c b/usr/src/lib/libast/common/vmalloc/vmprivate.c
new file mode 100644
index 0000000000..74e9dcf565
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmprivate.c
@@ -0,0 +1,307 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmprivate(){}
+
+#else
+
+#include "vmhdr.h"
+
+static char* Version = "\n@(#)$Id: Vmalloc (AT&T Research) 2005-09-28 $\0\n";
+
+#if _sys_stat
+#include <sys/stat.h>
+#endif
+#include <fcntl.h>
+
+#ifdef S_IRUSR
+#define CREAT_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
+#else
+#define CREAT_MODE 0644
+#endif
+
+/* Private code used in the vmalloc library
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+
+/* Get more memory for a region */
+#if __STD_C
+static Block_t* vmextend(reg Vmalloc_t* vm, size_t size, Vmsearch_f searchf )
+#else
+static Block_t* vmextend(vm, size, searchf )
+reg Vmalloc_t* vm; /* region to increase in size */
+size_t size; /* desired amount of space */
+Vmsearch_f searchf; /* tree search function */
+#endif
+{
+ reg size_t s;
+ reg Seg_t* seg;
+ reg Block_t *bp, *t;
+ reg Vmuchar_t* addr = (Vmuchar_t*)Version; /* shut compiler warning */
+ reg Vmdata_t* vd = vm->data;
+ reg Vmemory_f memoryf = vm->disc->memoryf;
+ reg Vmexcept_f exceptf = vm->disc->exceptf;
+
+ GETPAGESIZE(_Vmpagesize);
+
+#if DEBUG /* trace all allocation calls through the heap */
+ if(!_Vmtrace && vm == Vmheap && (vd->mode&VM_TRUST) )
+ { char *env;
+ int fd;
+ vd->mode = (vd->mode&~VM_TRUST)|VM_TRACE;
+ if((fd = vmtrace(-1)) >= 0 ||
+ ((env = getenv("VMTRACE")) && (fd = creat(env, CREAT_MODE)) >= 0 ) )
+ vmtrace(fd);
+ }
+#endif
+
+ if(vd->incr <= 0) /* this is just _Vmheap on the first call */
+ vd->incr = _Vmpagesize;
+
+ /* Get slightly more for administrative data */
+ s = size + sizeof(Seg_t) + sizeof(Block_t) + sizeof(Head_t) + 2*ALIGN;
+ if(s <= size) /* size was too large and we have wrapped around */
+ return NIL(Block_t*);
+ if((size = ROUND(s,vd->incr)) < s)
+ return NIL(Block_t*);
+
+ /* increase the rounding factor to reduce # of future extensions */
+ if(size > 2*vd->incr && vm->disc->round < vd->incr)
+ vd->incr *= 2;
+
+ /* see if we can extend the current segment */
+ if(!(seg = vd->seg) )
+ addr = NIL(Vmuchar_t*);
+ else
+ { if(!vd->wild || SEG(vd->wild) != seg)
+ s = 0;
+ else
+ { s = SIZE(vd->wild) + sizeof(Head_t);
+ if((s = (s/vd->incr)*vd->incr) == size)
+ size += vd->incr;
+ }
+ addr = (Vmuchar_t*)(*memoryf)(vm,seg->addr,seg->extent,
+ seg->extent+size-s,vm->disc);
+ if(!addr)
+ seg = NIL(Seg_t*);
+ else
+ { /**/ASSERT(addr == (Vmuchar_t*)seg->addr);
+ addr += seg->extent;
+ size -= s;
+ }
+ }
+
+ while(!addr) /* try to get space */
+ { if((addr = (Vmuchar_t*)(*memoryf)(vm,NIL(Void_t*),0,size,vm->disc)) )
+ break;
+
+ /* check with exception handler to see if we should continue */
+ if(!exceptf)
+ return NIL(Block_t*);
+ else
+ { int rv, lock;
+ lock = vd->mode&VM_LOCK;
+ vd->mode &= ~VM_LOCK;
+ rv = (*exceptf)(vm,VM_NOMEM,(Void_t*)size,vm->disc);
+ vd->mode |= lock;
+ if(rv <= 0)
+ { if(rv == 0)
+ vd->mode |= VM_AGAIN;
+ return NIL(Block_t*);
+ }
+ }
+ }
+
+ if(seg)
+ { /* extending current segment */
+ bp = BLOCK(seg->baddr); /**/ ASSERT((SIZE(bp)&~BITS) == 0);
+ /**/ ASSERT(SEG(bp) == seg);
+
+ if(vd->mode&(VM_MTBEST|VM_MTDEBUG|VM_MTPROFILE) )
+ { if(!ISPFREE(SIZE(bp)) )
+ SIZE(bp) = size - sizeof(Head_t);
+ else
+ { /**/ ASSERT(searchf);
+ bp = LAST(bp);
+ if(bp == vd->wild)
+ vd->wild = NIL(Block_t*);
+ else REMOVE(vd,bp,INDEX(SIZE(bp)),t,(*searchf));
+ SIZE(bp) += size;
+ }
+ }
+ else
+ { if(seg->free)
+ { bp = seg->free;
+ seg->free = NIL(Block_t*);
+ SIZE(bp) += size;
+ }
+ else SIZE(bp) = size - sizeof(Head_t);
+ }
+
+ seg->size += size;
+ seg->extent += size;
+ seg->baddr += size;
+ }
+ else
+ { /* creating a new segment */
+ reg Seg_t *sp, *lastsp;
+
+ if((s = (size_t)(VLONG(addr)%ALIGN)) != 0)
+ addr += ALIGN-s;
+
+ seg = (Seg_t*)addr;
+ seg->vm = vm;
+ seg->addr = (Void_t*)(addr - (s ? ALIGN-s : 0));
+ seg->extent = size;
+ seg->baddr = addr + size - (s ? 2*ALIGN : 0);
+ seg->free = NIL(Block_t*);
+ bp = SEGBLOCK(seg);
+ SEG(bp) = seg;
+ SIZE(bp) = seg->baddr - (Vmuchar_t*)bp - 2*sizeof(Head_t);
+
+ /* NOTE: for Vmbest, Vmdebug and Vmprofile the region's segment list
+ is reversely ordered by addresses. This is so that we can easily
+ check for the wild block.
+ */
+ lastsp = NIL(Seg_t*);
+ sp = vd->seg;
+ if(vd->mode&(VM_MTBEST|VM_MTDEBUG|VM_MTPROFILE))
+ for(; sp; lastsp = sp, sp = sp->next)
+ if(seg->addr > sp->addr)
+ break;
+ seg->next = sp;
+ if(lastsp)
+ lastsp->next = seg;
+ else vd->seg = seg;
+
+ seg->size = SIZE(bp);
+ }
+
+ /* make a fake header for possible segmented memory */
+ t = NEXT(bp);
+ SEG(t) = seg;
+ SIZE(t) = BUSY;
+
+ /* see if the wild block is still wild */
+ if((t = vd->wild) && (seg = SEG(t)) != vd->seg)
+ { CLRPFREE(SIZE(NEXT(t)));
+ if(vd->mode&(VM_MTBEST|VM_MTDEBUG|VM_MTPROFILE) )
+ { SIZE(t) |= BUSY|JUNK;
+ LINK(t) = CACHE(vd)[C_INDEX(SIZE(t))];
+ CACHE(vd)[C_INDEX(SIZE(t))] = t;
+ }
+ else seg->free = t;
+
+ vd->wild = NIL(Block_t*);
+ }
+
+ return bp;
+}
+
+/* Truncate a segment if possible */
+#if __STD_C
+static ssize_t vmtruncate(Vmalloc_t* vm, Seg_t* seg, size_t size, int exact)
+#else
+static ssize_t vmtruncate(vm, seg, size, exact)
+Vmalloc_t* vm; /* containing region */
+Seg_t* seg; /* the one to be truncated */
+size_t size; /* amount of free space */
+int exact;
+#endif
+{
+ reg Void_t* caddr;
+ reg Seg_t* last;
+ reg Vmdata_t* vd = vm->data;
+ reg Vmemory_f memoryf = vm->disc->memoryf;
+
+ caddr = seg->addr;
+
+ if(size < seg->size)
+ { reg ssize_t less;
+
+ if(exact)
+ less = size;
+ else /* keep truncated amount to discipline requirements */
+ { if((less = vm->disc->round) <= 0)
+ less = _Vmpagesize;
+ less = (size/less)*less;
+ less = (less/vd->incr)*vd->incr;
+ if(less > 0 && size > less && (size-less) < sizeof(Block_t) )
+ less = less <= vd->incr ? 0 : less - vd->incr;
+ }
+
+ if(less <= 0 ||
+ (*memoryf)(vm,caddr,seg->extent,seg->extent-less,vm->disc) != caddr)
+ return 0;
+
+ seg->extent -= less;
+ seg->size -= less;
+ seg->baddr -= less;
+ SEG(BLOCK(seg->baddr)) = seg;
+ SIZE(BLOCK(seg->baddr)) = BUSY;
+
+ return less;
+ }
+ else
+ { /* unlink segment from region */
+ if(seg == vd->seg)
+ { vd->seg = seg->next;
+ last = NIL(Seg_t*);
+ }
+ else
+ { for(last = vd->seg; last->next != seg; last = last->next)
+ ;
+ last->next = seg->next;
+ }
+
+ /* now delete it */
+ if((*memoryf)(vm,caddr,seg->extent,0,vm->disc) == caddr)
+ return size;
+
+ /* space reduction failed, reinsert segment */
+ if(last)
+ { seg->next = last->next;
+ last->next = seg;
+ }
+ else
+ { seg->next = vd->seg;
+ vd->seg = seg;
+ }
+ return 0;
+ }
+}
+
+/* Externally visible names but local to library */
+Vmextern_t _Vmextern =
+{ vmextend, /* _Vmextend */
+ vmtruncate, /* _Vmtruncate */
+ 0, /* _Vmpagesize */
+ NIL(char*(*)_ARG_((char*,const char*,int))), /* _Vmstrcpy */
+ NIL(char*(*)_ARG_((Vmulong_t,int))), /* _Vmitoa */
+ NIL(void(*)_ARG_((Vmalloc_t*,
+ Vmuchar_t*,Vmuchar_t*,size_t,size_t))), /* _Vmtrace */
+ NIL(void(*)_ARG_((Vmalloc_t*))) /* _Vmpfclose */
+};
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmprofile.c b/usr/src/lib/libast/common/vmalloc/vmprofile.c
new file mode 100644
index 0000000000..bead2b5be2
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmprofile.c
@@ -0,0 +1,734 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmprofile(){}
+
+#else
+
+#include "vmhdr.h"
+
+/* Method to profile space usage.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 03/23/94.
+*/
+
+#define PFHASH(pf) ((pf)->data.data.hash)
+#define PFVM(pf) ((pf)->data.data.vm)
+#define PFFILE(pf) ((pf)->data.data.fm.file)
+#define PFLINE(pf) ((pf)->line)
+#define PFNAME(pf) ((pf)->data.f)
+#define PFNALLOC(pf) ((pf)->data.data.nalloc)
+#define PFALLOC(pf) ((pf)->data.data.alloc)
+#define PFNFREE(pf) ((pf)->data.data.nfree)
+#define PFFREE(pf) ((pf)->data.data.free)
+#define PFREGION(pf) ((pf)->data.data.region)
+#define PFMAX(pf) ((pf)->data.data.fm.max)
+
+typedef struct _pfdata_s Pfdata_t;
+struct _pfdata_s
+{ Vmulong_t hash; /* hash value */
+ union
+ { char* file; /* file name */
+ Vmulong_t max; /* max busy space for region */
+ } fm;
+ Vmalloc_t* vm; /* region alloc from */
+ Pfobj_t* region; /* pointer to region record */
+ Vmulong_t nalloc; /* number of alloc calls */
+ Vmulong_t alloc; /* amount allocated */
+ Vmulong_t nfree; /* number of free calls */
+ Vmulong_t free; /* amount freed */
+};
+struct _pfobj_s
+{ Pfobj_t* next; /* next in linked list */
+ int line; /* line #, 0 for name holder */
+ union
+ {
+ Pfdata_t data;
+ char f[1]; /* actual file name */
+ } data;
+};
+
+static Pfobj_t** Pftable; /* hash table */
+#define PFTABLE 1019 /* table size */
+static Vmalloc_t* Vmpf; /* heap for our own use */
+
+#if __STD_C
+static Pfobj_t* pfsearch(Vmalloc_t* vm, const char* file, int line)
+#else
+static Pfobj_t* pfsearch(vm, file, line)
+Vmalloc_t* vm; /* region allocating from */
+const char* file; /* the file issuing the allocation request */
+int line; /* line number */
+#endif
+{
+ reg Pfobj_t *pf, *last;
+ reg Vmulong_t h;
+ reg int n;
+ reg const char* cp;
+
+ if(!Vmpf && !(Vmpf = vmopen(Vmdcheap,Vmpool,0)) )
+ return NIL(Pfobj_t*);
+
+ /* make hash table; PFTABLE'th slot hold regions' records */
+ if(!Pftable)
+ { if(!(Pftable = (Pfobj_t**)vmalloc(Vmheap,(PFTABLE+1)*sizeof(Pfobj_t*))) )
+ return NIL(Pfobj_t*);
+ for(n = PFTABLE; n >= 0; --n)
+ Pftable[n] = NIL(Pfobj_t*);
+ }
+
+ /* see if it's there with a combined hash value of vm,file,line */
+ h = line + (((Vmulong_t)vm)>>4);
+ for(cp = file; *cp; ++cp)
+ h += (h<<7) + ((*cp)&0377) + 987654321L;
+ n = (int)(h%PFTABLE);
+ for(last = NIL(Pfobj_t*), pf = Pftable[n]; pf; last = pf, pf = pf->next)
+ if(PFLINE(pf) == line && PFVM(pf) == vm && strcmp(PFFILE(pf),file) == 0)
+ break;
+
+ /* insert if not there yet */
+ if(!pf)
+ { reg Pfobj_t* fn;
+ reg Pfobj_t* pfvm;
+ reg Vmulong_t hn;
+
+ /* first get/construct the file name slot */
+ hn = 0;
+ for(cp = file; *cp; ++cp)
+ hn += (hn<<7) + ((*cp)&0377) + 987654321L;
+ n = (int)(hn%PFTABLE);
+ for(fn = Pftable[n]; fn; fn = fn->next)
+ if(PFLINE(fn) < 0 && strcmp(PFNAME(fn),file) == 0)
+ break;
+ if(!fn)
+ { reg size_t s;
+ s = sizeof(Pfobj_t) - sizeof(Pfdata_t) + strlen(file) + 1;
+ if(!(fn = (Pfobj_t*)vmalloc(Vmheap,s)) )
+ return NIL(Pfobj_t*);
+ fn->next = Pftable[n];
+ Pftable[n] = fn;
+ PFLINE(fn) = -1;
+ strcpy(PFNAME(fn),file);
+ }
+
+ /* get region record; note that these are ordered by vm */
+ last = NIL(Pfobj_t*);
+ for(pfvm = Pftable[PFTABLE]; pfvm; last = pfvm, pfvm = pfvm->next)
+ if(vm >= PFVM(pfvm))
+ break;
+ if(!pfvm || PFVM(pfvm) > vm)
+ { if(!(pfvm = (Pfobj_t*)vmalloc(Vmpf,sizeof(Pfobj_t))) )
+ return NIL(Pfobj_t*);
+ if(last)
+ { pfvm->next = last->next;
+ last->next = pfvm;
+ }
+ else
+ { pfvm->next = Pftable[PFTABLE];
+ Pftable[PFTABLE] = pfvm;
+ }
+ PFNALLOC(pfvm) = PFALLOC(pfvm) = 0;
+ PFNFREE(pfvm) = PFFREE(pfvm) = 0;
+ PFMAX(pfvm) = 0;
+ PFVM(pfvm) = vm;
+ PFLINE(pfvm) = 0;
+ }
+
+ if(!(pf = (Pfobj_t*)vmalloc(Vmpf,sizeof(Pfobj_t))) )
+ return NIL(Pfobj_t*);
+ n = (int)(h%PFTABLE);
+ pf->next = Pftable[n];
+ Pftable[n] = pf;
+ PFLINE(pf) = line;
+ PFFILE(pf) = PFNAME(fn);
+ PFREGION(pf) = pfvm;
+ PFVM(pf) = vm;
+ PFNALLOC(pf) = 0;
+ PFALLOC(pf) = 0;
+ PFNFREE(pf) = 0;
+ PFFREE(pf) = 0;
+ PFHASH(pf) = h;
+ }
+ else if(last) /* do a move-to-front */
+ { last->next = pf->next;
+ pf->next = Pftable[n];
+ Pftable[n] = pf;
+ }
+
+ return pf;
+}
+
+#if __STD_C
+static void pfclose(Vmalloc_t* vm)
+#else
+static void pfclose(vm)
+Vmalloc_t* vm;
+#endif
+{
+ reg int n;
+ reg Pfobj_t *pf, *next, *last;
+
+ /* free all records related to region vm */
+ for(n = PFTABLE; n >= 0; --n)
+ { for(last = NIL(Pfobj_t*), pf = Pftable[n]; pf; )
+ { next = pf->next;
+
+ if(PFLINE(pf) >= 0 && PFVM(pf) == vm)
+ { if(last)
+ last->next = next;
+ else Pftable[n] = next;
+ vmfree(Vmpf,pf);
+ }
+ else last = pf;
+
+ pf = next;
+ }
+ }
+}
+
+#if __STD_C
+static void pfsetinfo(Vmalloc_t* vm, Vmuchar_t* data, size_t size, const char* file, int line)
+#else
+static void pfsetinfo(vm, data, size, file, line)
+Vmalloc_t* vm;
+Vmuchar_t* data;
+size_t size;
+const char* file;
+int line;
+#endif
+{
+ reg Pfobj_t* pf;
+ reg Vmulong_t s;
+
+ /* let vmclose knows that there are records for region vm */
+ _Vmpfclose = pfclose;
+
+ if(!file || line <= 0)
+ { file = "";
+ line = 0;
+ }
+
+ if((pf = pfsearch(vm,file,line)) )
+ { PFALLOC(pf) += size;
+ PFNALLOC(pf) += 1;
+ }
+ PFOBJ(data) = pf;
+ PFSIZE(data) = size;
+
+ if(pf)
+ { /* update region statistics */
+ pf = PFREGION(pf);
+ PFALLOC(pf) += size;
+ PFNALLOC(pf) += 1;
+ if((s = PFALLOC(pf) - PFFREE(pf)) > PFMAX(pf) )
+ PFMAX(pf) = s;
+ }
+}
+
+/* sort by file names and line numbers */
+#if __STD_C
+static Pfobj_t* pfsort(Pfobj_t* pf)
+#else
+static Pfobj_t* pfsort(pf)
+Pfobj_t* pf;
+#endif
+{
+ reg Pfobj_t *one, *two, *next;
+ reg int cmp;
+
+ if(!pf->next)
+ return pf;
+
+ /* partition to two equal size lists */
+ one = two = NIL(Pfobj_t*);
+ while(pf)
+ { next = pf->next;
+ pf->next = one;
+ one = pf;
+
+ if((pf = next) )
+ { next = pf->next;
+ pf->next = two;
+ two = pf;
+ pf = next;
+ }
+ }
+
+ /* sort and merge the lists */
+ one = pfsort(one);
+ two = pfsort(two);
+ for(pf = next = NIL(Pfobj_t*);; )
+ { /* make sure that the "<>" file comes first */
+ if(PFLINE(one) == 0 && PFLINE(two) == 0)
+ cmp = PFVM(one) > PFVM(two) ? 1 : -1;
+ else if(PFLINE(one) == 0)
+ cmp = -1;
+ else if(PFLINE(two) == 0)
+ cmp = 1;
+ else if((cmp = strcmp(PFFILE(one),PFFILE(two))) == 0)
+ { cmp = PFLINE(one) - PFLINE(two);
+ if(cmp == 0)
+ cmp = PFVM(one) > PFVM(two) ? 1 : -1;
+ }
+
+ if(cmp < 0)
+ { if(!pf)
+ pf = one;
+ else next->next = one;
+ next = one;
+ if(!(one = one->next) )
+ { if(two)
+ next->next = two;
+ return pf;
+ }
+ }
+ else
+ { if(!pf)
+ pf = two;
+ else next->next = two;
+ next = two;
+ if(!(two = two->next) )
+ { if(one)
+ next->next = one;
+ return pf;
+ }
+ }
+ }
+}
+
+#if __STD_C
+static char* pfsummary(char* buf, Vmulong_t na, Vmulong_t sa,
+ Vmulong_t nf, Vmulong_t sf, Vmulong_t max, Vmulong_t size)
+#else
+static char* pfsummary(buf, na, sa, nf, sf, max, size)
+char* buf;
+Vmulong_t na;
+Vmulong_t sa;
+Vmulong_t nf;
+Vmulong_t sf;
+Vmulong_t max;
+Vmulong_t size;
+#endif
+{
+ buf = (*_Vmstrcpy)(buf,"n_alloc", '=');
+ buf = (*_Vmstrcpy)(buf, (*_Vmitoa)(na,-1), ':');
+ buf = (*_Vmstrcpy)(buf,"n_free", '=');
+ buf = (*_Vmstrcpy)(buf, (*_Vmitoa)(nf,-1), ':');
+ buf = (*_Vmstrcpy)(buf,"s_alloc", '=');
+ buf = (*_Vmstrcpy)(buf, (*_Vmitoa)(sa,-1), ':');
+ buf = (*_Vmstrcpy)(buf,"s_free", '=');
+ buf = (*_Vmstrcpy)(buf, (*_Vmitoa)(sf,-1), ':');
+ if(max > 0)
+ { buf = (*_Vmstrcpy)(buf,"max_busy", '=');
+ buf = (*_Vmstrcpy)(buf, (*_Vmitoa)(max,-1), ':');
+ buf = (*_Vmstrcpy)(buf,"extent", '=');
+ buf = (*_Vmstrcpy)(buf, (*_Vmitoa)(size,-1), ':');
+ }
+ *buf++ = '\n';
+
+ return buf;
+}
+
+/* print profile data */
+#if __STD_C
+int vmprofile(Vmalloc_t* vm, int fd)
+#else
+int vmprofile(vm, fd)
+Vmalloc_t* vm;
+int fd;
+#endif
+{
+ reg Pfobj_t *pf, *list, *next, *last;
+ reg int n;
+ reg Vmulong_t nalloc, alloc, nfree, free;
+ reg Seg_t* seg;
+ char buf[1024], *bufp, *endbuf;
+#define INITBUF() (bufp = buf, endbuf = buf+sizeof(buf)-128)
+#define CHKBUF() (bufp >= endbuf ? (write(fd,buf,bufp-buf), bufp=buf) : bufp)
+#define FLSBUF() (bufp > buf ? write(fd,buf,bufp-buf) : 0)
+
+ if(fd < 0)
+ return -1;
+
+ /* initialize functions from vmtrace.c that we use below */
+ if((n = vmtrace(-1)) >= 0)
+ vmtrace(n);
+
+ alloc = free = nalloc = nfree = 0;
+ list = NIL(Pfobj_t*);
+ for(n = PFTABLE-1; n >= 0; --n)
+ { for(pf = Pftable[n], last = NIL(Pfobj_t*); pf; )
+ { next = pf->next;
+
+ if(PFLINE(pf) < 0 || (vm && vm != PFVM(pf)) )
+ { last = pf;
+ goto next_pf;
+ }
+
+ /* remove from hash table */
+ if(last)
+ last->next = next;
+ else Pftable[n] = next;
+
+ /* put on output list */
+ pf->next = list;
+ list = pf;
+ nalloc += PFNALLOC(pf);
+ alloc += PFALLOC(pf);
+ nfree += PFNFREE(pf);
+ free += PFFREE(pf);
+
+ next_pf:
+ pf = next;
+ }
+ }
+
+ INITBUF();
+ bufp = (*_Vmstrcpy)(bufp,"ALLOCATION USAGE SUMMARY", ':');
+ bufp = pfsummary(bufp,nalloc,alloc,nfree,free,0,0);
+
+ /* print regions' summary data */
+ for(pf = Pftable[PFTABLE]; pf; pf = pf->next)
+ { if(vm && PFVM(pf) != vm)
+ continue;
+ alloc = 0;
+ for(seg = PFVM(pf)->data->seg; seg; seg = seg->next)
+ alloc += seg->extent;
+ bufp = (*_Vmstrcpy)(bufp,"region", '=');
+ bufp = (*_Vmstrcpy)(bufp, (*_Vmitoa)(VLONG(PFVM(pf)),0), ':');
+ bufp = pfsummary(bufp,PFNALLOC(pf),PFALLOC(pf),
+ PFNFREE(pf),PFFREE(pf),PFMAX(pf),alloc);
+ }
+
+ /* sort then output detailed profile */
+ list = pfsort(list);
+ for(pf = list; pf; )
+ { /* compute summary for file */
+ alloc = free = nalloc = nfree = 0;
+ for(last = pf; last; last = last->next)
+ { if(strcmp(PFFILE(last),PFFILE(pf)) != 0)
+ break;
+ nalloc += PFNALLOC(pf);
+ alloc += PFALLOC(last);
+ nfree += PFNFREE(last);
+ free += PFFREE(last);
+ }
+ CHKBUF();
+ bufp = (*_Vmstrcpy)(bufp,"file",'=');
+ bufp = (*_Vmstrcpy)(bufp,PFFILE(pf)[0] ? PFFILE(pf) : "<>" ,':');
+ bufp = pfsummary(bufp,nalloc,alloc,nfree,free,0,0);
+
+ while(pf != last) /* detailed data */
+ { CHKBUF();
+ bufp = (*_Vmstrcpy)(bufp,"\tline",'=');
+ bufp = (*_Vmstrcpy)(bufp, (*_Vmitoa)(PFLINE(pf),-1), ':');
+ bufp = (*_Vmstrcpy)(bufp, "region", '=');
+ bufp = (*_Vmstrcpy)(bufp, (*_Vmitoa)(VLONG(PFVM(pf)),0), ':');
+ bufp = pfsummary(bufp,PFNALLOC(pf),PFALLOC(pf),
+ PFNFREE(pf),PFFREE(pf),0,0);
+
+ /* reinsert into hash table */
+ next = pf->next;
+ n = (int)(PFHASH(pf)%PFTABLE);
+ pf->next = Pftable[n];
+ Pftable[n] = pf;
+ pf = next;
+ }
+ }
+
+ FLSBUF();
+ return 0;
+}
+
+#if __STD_C
+static Void_t* pfalloc(Vmalloc_t* vm, size_t size)
+#else
+static Void_t* pfalloc(vm, size)
+Vmalloc_t* vm;
+size_t size;
+#endif
+{
+ reg size_t s;
+ reg Void_t* data;
+ reg char* file;
+ reg int line, local;
+ reg Void_t* func;
+ reg Vmdata_t* vd = vm->data;
+
+ VMFLF(vm,file,line,func);
+ if(!(local = vd->mode&VM_TRUST) )
+ { GETLOCAL(vd, local);
+ if(ISLOCK(vd, local))
+ return NIL(Void_t*);
+ SETLOCK(vd, local);
+ }
+
+ s = ROUND(size,ALIGN) + PF_EXTRA;
+ if(!(data = KPVALLOC(vm,s,(*(Vmbest->allocf))) ) )
+ goto done;
+
+ pfsetinfo(vm,(Vmuchar_t*)data,size,file,line);
+
+ if(!local && (vd->mode&VM_TRACE) && _Vmtrace)
+ { vm->file = file; vm->line = line; vm->func = func;
+ (*_Vmtrace)(vm,NIL(Vmuchar_t*),(Vmuchar_t*)data,size,0);
+ }
+done:
+ CLRLOCK(vd, local);
+ ANNOUNCE(local, vm, VM_ALLOC, (Void_t*)data, vm->disc);
+ return data;
+}
+
+#if __STD_C
+static int pffree(Vmalloc_t* vm, Void_t* data)
+#else
+static int pffree(vm, data)
+Vmalloc_t* vm;
+Void_t* data;
+#endif
+{
+ reg Pfobj_t* pf;
+ reg size_t s;
+ reg char* file;
+ reg int line, rv, local;
+ reg Void_t* func;
+ reg Vmdata_t* vd = vm->data;
+
+ VMFLF(vm,file,line,func);
+
+ if(!data)
+ return 0;
+
+ if(!(local = vd->mode&VM_TRUST) )
+ { GETLOCAL(vd,local);
+ if(ISLOCK(vd,local))
+ return -1;
+ SETLOCK(vd,local);
+ }
+
+ if(KPVADDR(vm,data,Vmbest->addrf) != 0 )
+ { if(vm->disc->exceptf)
+ (void)(*vm->disc->exceptf)(vm,VM_BADADDR,data,vm->disc);
+ CLRLOCK(vd,0);
+ return -1;
+ }
+
+ pf = PFOBJ(data);
+ s = PFSIZE(data);
+ if(pf)
+ { PFNFREE(pf) += 1;
+ PFFREE(pf) += s;
+ pf = PFREGION(pf);
+ PFNFREE(pf) += 1;
+ PFFREE(pf) += s;
+ }
+
+ if(!local && (vd->mode&VM_TRACE) && _Vmtrace)
+ { vm->file = file; vm->line = line; vm->func = func;
+ (*_Vmtrace)(vm,(Vmuchar_t*)data,NIL(Vmuchar_t*),s,0);
+ }
+
+ rv = KPVFREE((vm), (Void_t*)data, (*Vmbest->freef));
+ CLRLOCK(vd,local);
+ ANNOUNCE(local, vm, VM_FREE, data, vm->disc);
+ return rv;
+}
+
+#if __STD_C
+static Void_t* pfresize(Vmalloc_t* vm, Void_t* data, size_t size, int type)
+#else
+static Void_t* pfresize(vm, data, size, type)
+Vmalloc_t* vm;
+Void_t* data;
+size_t size;
+int type;
+#endif
+{
+ reg Pfobj_t* pf;
+ reg size_t s;
+ reg size_t news;
+ reg Void_t* addr;
+ reg char* file;
+ reg int line, local;
+ reg Void_t* func;
+ reg size_t oldsize;
+ reg Vmdata_t* vd = vm->data;
+
+ if(!data)
+ { oldsize = 0;
+ addr = pfalloc(vm,size);
+ goto done;
+ }
+ if(size == 0)
+ { (void)pffree(vm,data);
+ return NIL(Void_t*);
+ }
+
+ VMFLF(vm,file,line,func);
+ if(!(local = vd->mode&VM_TRUST))
+ { GETLOCAL(vd, local);
+ if(ISLOCK(vd, local))
+ return NIL(Void_t*);
+ SETLOCK(vd, local);
+ }
+
+ if(KPVADDR(vm,data,Vmbest->addrf) != 0 )
+ { if(vm->disc->exceptf)
+ (void)(*vm->disc->exceptf)(vm,VM_BADADDR,data,vm->disc);
+ CLRLOCK(vd, local);
+ return NIL(Void_t*);
+ }
+
+ pf = PFOBJ(data);
+ s = oldsize = PFSIZE(data);
+
+ news = ROUND(size,ALIGN) + PF_EXTRA;
+ if((addr = KPVRESIZE(vm,data,news,(type&~VM_RSZERO),Vmbest->resizef)) )
+ { if(pf)
+ { PFFREE(pf) += s;
+ PFNFREE(pf) += 1;
+ pf = PFREGION(pf);
+ PFFREE(pf) += s;
+ PFNFREE(pf) += 1;
+ pfsetinfo(vm,(Vmuchar_t*)addr,size,file,line);
+ }
+
+ if(!local && (vd->mode&VM_TRACE) && _Vmtrace)
+ { vm->file = file; vm->line = line; vm->func = func;
+ (*_Vmtrace)(vm,(Vmuchar_t*)data,(Vmuchar_t*)addr,size,0);
+ }
+ }
+ else if(pf) /* reset old info */
+ { PFALLOC(pf) -= s;
+ PFNALLOC(pf) -= 1;
+ pf = PFREGION(pf);
+ PFALLOC(pf) -= s;
+ PFNALLOC(pf) -= 1;
+ file = PFFILE(pf);
+ line = PFLINE(pf);
+ pfsetinfo(vm,(Vmuchar_t*)data,s,file,line);
+ }
+
+ CLRLOCK(vd, local);
+ ANNOUNCE(local, vm, VM_RESIZE, (Void_t*)addr, vm->disc);
+
+done: if(addr && (type&VM_RSZERO) && oldsize < size)
+ { reg Vmuchar_t *d = (Vmuchar_t*)addr+oldsize, *ed = (Vmuchar_t*)addr+size;
+ do { *d++ = 0; } while(d < ed);
+ }
+
+ return addr;
+}
+
+#if __STD_C
+static long pfsize(Vmalloc_t* vm, Void_t* addr)
+#else
+static long pfsize(vm, addr)
+Vmalloc_t* vm;
+Void_t* addr;
+#endif
+{
+ return (*Vmbest->addrf)(vm,addr) != 0 ? -1L : (long)PFSIZE(addr);
+}
+
+#if __STD_C
+static long pfaddr(Vmalloc_t* vm, Void_t* addr)
+#else
+static long pfaddr(vm, addr)
+Vmalloc_t* vm;
+Void_t* addr;
+#endif
+{
+ return (*Vmbest->addrf)(vm,addr);
+}
+
+#if __STD_C
+static int pfcompact(Vmalloc_t* vm)
+#else
+static int pfcompact(vm)
+Vmalloc_t* vm;
+#endif
+{
+ return (*Vmbest->compactf)(vm);
+}
+
+#if __STD_C
+static Void_t* pfalign(Vmalloc_t* vm, size_t size, size_t align)
+#else
+static Void_t* pfalign(vm, size, align)
+Vmalloc_t* vm;
+size_t size;
+size_t align;
+#endif
+{
+ reg size_t s;
+ reg Void_t* data;
+ reg char* file;
+ reg int line, local;
+ reg Void_t* func;
+ reg Vmdata_t* vd = vm->data;
+
+ VMFLF(vm,file,line,func);
+
+ if(!(local = vd->mode&VM_TRUST) )
+ { GETLOCAL(vd,local);
+ if(ISLOCK(vd, local))
+ return NIL(Void_t*);
+ SETLOCK(vd, local);
+ }
+
+ s = (size <= TINYSIZE ? TINYSIZE : ROUND(size,ALIGN)) + PF_EXTRA;
+ if(!(data = KPVALIGN(vm,s,align,Vmbest->alignf)) )
+ goto done;
+
+ pfsetinfo(vm,(Vmuchar_t*)data,size,file,line);
+
+ if(!local && (vd->mode&VM_TRACE) && _Vmtrace)
+ { vm->file = file; vm->line = line; vm->func = func;
+ (*_Vmtrace)(vm,NIL(Vmuchar_t*),(Vmuchar_t*)data,size,align);
+ }
+done:
+ CLRLOCK(vd, local);
+ ANNOUNCE(local, vm, VM_ALLOC, data, vm->disc);
+ return data;
+}
+
+static Vmethod_t _Vmprofile =
+{
+ pfalloc,
+ pfresize,
+ pffree,
+ pfaddr,
+ pfsize,
+ pfcompact,
+ pfalign,
+ VM_MTPROFILE
+};
+
+__DEFINE__(Vmethod_t*,Vmprofile,&_Vmprofile);
+
+#ifdef NoF
+NoF(vmprofile)
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmregion.c b/usr/src/lib/libast/common/vmalloc/vmregion.c
new file mode 100644
index 0000000000..43ba0785f8
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmregion.c
@@ -0,0 +1,44 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmregion(){}
+
+#else
+
+#include "vmhdr.h"
+
+/* Return the containing region of an allocated piece of memory.
+** Beware: this only works with Vmbest and Vmtrace.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+#if __STD_C
+Vmalloc_t* vmregion(reg Void_t* addr)
+#else
+Vmalloc_t* vmregion(addr)
+reg Void_t* addr;
+#endif
+{ return addr ? VM(BLOCK(addr)) : NIL(Vmalloc_t*);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmsegment.c b/usr/src/lib/libast/common/vmalloc/vmsegment.c
new file mode 100644
index 0000000000..8e2453e50a
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmsegment.c
@@ -0,0 +1,61 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmsegment(){}
+
+#else
+
+#include "vmhdr.h"
+
+/* Get the segment containing this address
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 02/07/95
+*/
+
+#if __STD_C
+Void_t* vmsegment(Vmalloc_t* vm, Void_t* addr)
+#else
+Void_t* vmsegment(vm, addr)
+Vmalloc_t* vm; /* region */
+Void_t* addr; /* address */
+#endif
+{
+ reg Seg_t* seg;
+ reg Vmdata_t* vd = vm->data;
+
+ if(!(vd->mode&VM_TRUST))
+ { if(ISLOCK(vd,0))
+ return NIL(Void_t*);
+ SETLOCK(vd,0);
+ }
+
+ for(seg = vd->seg; seg; seg = seg->next)
+ if((Vmuchar_t*)addr >= (Vmuchar_t*)seg->addr &&
+ (Vmuchar_t*)addr < (Vmuchar_t*)seg->baddr )
+ break;
+
+ CLRLOCK(vd,0);
+ return seg ? (Void_t*)seg->addr : NIL(Void_t*);
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmset.c b/usr/src/lib/libast/common/vmalloc/vmset.c
new file mode 100644
index 0000000000..0a6a1a5efd
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmset.c
@@ -0,0 +1,70 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmset(){}
+
+#else
+
+#include "vmhdr.h"
+
+
+/* Set the control flags for a region.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+#if __STD_C
+int vmset(reg Vmalloc_t* vm, int flags, int on)
+#else
+int vmset(vm, flags, on)
+reg Vmalloc_t* vm; /* region being worked on */
+int flags; /* flags must be in VM_FLAGS */
+int on; /* !=0 if turning on, else turning off */
+#endif
+{
+ reg int mode;
+ reg Vmdata_t* vd = vm->data;
+
+ if(flags == 0 && on == 0)
+ return vd->mode;
+
+ if(!(vd->mode&VM_TRUST) )
+ { if(ISLOCK(vd,0))
+ return 0;
+ SETLOCK(vd,0);
+ }
+
+ mode = vd->mode;
+
+ if(on)
+ vd->mode |= (flags&VM_FLAGS);
+ else vd->mode &= ~(flags&VM_FLAGS);
+
+ if(vd->mode&(VM_TRACE|VM_MTDEBUG))
+ vd->mode &= ~VM_TRUST;
+
+ CLRLOCK(vd,0);
+
+ return mode;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmstat.c b/usr/src/lib/libast/common/vmalloc/vmstat.c
new file mode 100644
index 0000000000..21a3f2b5a1
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmstat.c
@@ -0,0 +1,128 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmstat(){}
+
+#else
+
+#include "vmhdr.h"
+
+/* Get statistics from a region.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+
+#if __STD_C
+int vmstat(Vmalloc_t* vm, Vmstat_t* st)
+#else
+int vmstat(vm, st)
+Vmalloc_t* vm;
+Vmstat_t* st;
+#endif
+{
+ reg Seg_t* seg;
+ reg Block_t *b, *endb;
+ reg size_t s = 0;
+ reg Vmdata_t* vd = vm->data;
+
+ if(!st)
+ return -1;
+ if(!(vd->mode&VM_TRUST))
+ { if(ISLOCK(vd,0))
+ return -1;
+ SETLOCK(vd,0);
+ }
+
+ st->n_busy = st->n_free = 0;
+ st->s_busy = st->s_free = st->m_busy = st->m_free = 0;
+ st->n_seg = 0;
+ st->extent = 0;
+
+ if(vd->mode&VM_MTLAST)
+ st->n_busy = 0;
+ else if((vd->mode&VM_MTPOOL) && (s = vd->pool) > 0)
+ { s = ROUND(s,ALIGN);
+ for(b = vd->free; b; b = SEGLINK(b))
+ st->n_free += 1;
+ }
+
+ for(seg = vd->seg; seg; seg = seg->next)
+ { st->n_seg += 1;
+ st->extent += seg->extent;
+
+ b = SEGBLOCK(seg);
+ endb = BLOCK(seg->baddr);
+
+ if(vd->mode&(VM_MTDEBUG|VM_MTBEST|VM_MTPROFILE))
+ { while(b < endb)
+ { s = SIZE(b)&~BITS;
+ if(ISJUNK(SIZE(b)) || !ISBUSY(SIZE(b)))
+ { if(s > st->m_free)
+ st->m_free = s;
+ st->s_free += s;
+ st->n_free += 1;
+ }
+ else /* get the real size */
+ { if(vd->mode&VM_MTDEBUG)
+ s = DBSIZE(DB2DEBUG(DATA(b)));
+ else if(vd->mode&VM_MTPROFILE)
+ s = PFSIZE(DATA(b));
+ if(s > st->m_busy)
+ st->m_busy = s;
+ st->s_busy += s;
+ st->n_busy += 1;
+ }
+
+ b = (Block_t*)((Vmuchar_t*)DATA(b) + (SIZE(b)&~BITS) );
+ }
+ }
+ else if(vd->mode&VM_MTLAST)
+ { if((s = seg->free ? (SIZE(seg->free) + sizeof(Head_t)) : 0) > 0)
+ { st->s_free += s;
+ st->n_free += 1;
+ }
+ if((s = ((char*)endb - (char*)b) - s) > 0)
+ { st->s_busy += s;
+ st->n_busy += 1;
+ }
+ }
+ else if((vd->mode&VM_MTPOOL) && s > 0)
+ { if(seg->free)
+ st->n_free += (SIZE(seg->free)+sizeof(Head_t))/s;
+ st->n_busy += ((seg->baddr - (Vmuchar_t*)b) - sizeof(Head_t))/s;
+ }
+ }
+
+ if((vd->mode&VM_MTPOOL) && s > 0)
+ { st->n_busy -= st->n_free;
+ if(st->n_busy > 0)
+ st->s_busy = (st->m_busy = vd->pool)*st->n_busy;
+ if(st->n_free > 0)
+ st->s_free = (st->m_free = vd->pool)*st->n_free;
+ }
+
+ CLRLOCK(vd,0);
+ return 0;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmstrdup.c b/usr/src/lib/libast/common/vmalloc/vmstrdup.c
new file mode 100644
index 0000000000..3d4f77a551
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmstrdup.c
@@ -0,0 +1,48 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmstrdup(){}
+
+#else
+
+#include "vmhdr.h"
+
+/*
+ * return a copy of s using vmalloc
+ */
+
+#if __STD_C
+char* vmstrdup(Vmalloc_t* v, register const char* s)
+#else
+char* vmstrdup(v, s)
+Vmalloc_t* v;
+register char* s;
+#endif
+{
+ register char* t;
+ register int n;
+
+ return (s && (t = vmalloc(v, n = strlen(s) + 1))) ? (char*)memcpy(t, s, n) : (char*)0;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmtrace.c b/usr/src/lib/libast/common/vmalloc/vmtrace.c
new file mode 100644
index 0000000000..e6f46abb44
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmtrace.c
@@ -0,0 +1,285 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmtrace(){}
+
+#else
+
+#include "vmhdr.h"
+
+/* Turn on tracing for regions
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+
+static int Trfile = -1;
+static char Trbuf[128];
+
+#if __STD_C
+static char* trstrcpy(char* to, const char* from, int endc)
+#else
+static char* trstrcpy(to, from, endc)
+char* to;
+const char* from;
+int endc;
+#endif
+{ reg int n;
+
+ n = strlen(from);
+ memcpy(to,from,n);
+ to += n;
+ if((*to = endc) )
+ to += 1;
+ return to;
+}
+
+/* convert a long value to an ascii representation */
+#if __STD_C
+static char* tritoa(Vmulong_t v, int type)
+#else
+static char* tritoa(v, type)
+Vmulong_t v; /* value to convert */
+int type; /* =0 base-16, >0: unsigned base-10, <0: signed base-10 */
+#endif
+{
+ char* s;
+
+ s = &Trbuf[sizeof(Trbuf) - 1];
+ *s-- = '\0';
+
+ if(type == 0) /* base-16 */
+ { reg char* digit = "0123456789abcdef";
+ do
+ { *s-- = digit[v&0xf];
+ v >>= 4;
+ } while(v);
+ }
+ else if(type > 0) /* unsigned base-10 */
+ { do
+ { *s-- = (char)('0' + (v%10));
+ v /= 10;
+ } while(v);
+ }
+ else /* signed base-10 */
+ { int sign = ((long)v < 0);
+ if(sign)
+ v = (Vmulong_t)(-((long)v));
+ do
+ { *s-- = (char)('0' + (v%10));
+ v /= 10;
+ } while(v);
+ if(sign)
+ *s-- = '-';
+ }
+
+ return s+1;
+}
+
+/* generate a trace of some call */
+#if __STD_C
+static void trtrace(Vmalloc_t* vm,
+ Vmuchar_t* oldaddr, Vmuchar_t* newaddr, size_t size, size_t align )
+#else
+static void trtrace(vm, oldaddr, newaddr, size, align)
+Vmalloc_t* vm; /* region call was made from */
+Vmuchar_t* oldaddr; /* old data address */
+Vmuchar_t* newaddr; /* new data address */
+size_t size; /* size of piece */
+size_t align; /* alignment */
+#endif
+{
+ char buf[1024], *bufp, *endbuf;
+ Vmdata_t* vd = vm->data;
+ const char* file = 0;
+ int line = 0;
+ const Void_t* func = 0;
+ int comma;
+ int n;
+ int m;
+
+ int type;
+#define SLOP 64
+
+ if(oldaddr == (Vmuchar_t*)(-1)) /* printing busy blocks */
+ { type = 0;
+ oldaddr = NIL(Vmuchar_t*);
+ }
+ else
+ { type = vd->mode&VM_METHODS;
+ VMFLF(vm,file,line,func);
+ }
+
+ if(Trfile < 0)
+ return;
+
+ bufp = buf; endbuf = buf+sizeof(buf);
+ bufp = trstrcpy(bufp, tritoa(oldaddr ? VLONG(oldaddr) : 0L, 0), ':');
+ bufp = trstrcpy(bufp, tritoa(newaddr ? VLONG(newaddr) : 0L, 0), ':');
+ bufp = trstrcpy(bufp, tritoa((Vmulong_t)size, 1), ':');
+ bufp = trstrcpy(bufp, tritoa((Vmulong_t)align, 1), ':');
+ bufp = trstrcpy(bufp, tritoa(VLONG(vm), 0), ':');
+ if(type&VM_MTBEST)
+ bufp = trstrcpy(bufp, "b", ':');
+ else if(type&VM_MTLAST)
+ bufp = trstrcpy(bufp, "l", ':');
+ else if(type&VM_MTPOOL)
+ bufp = trstrcpy(bufp, "p", ':');
+ else if(type&VM_MTPROFILE)
+ bufp = trstrcpy(bufp, "s", ':');
+ else if(type&VM_MTDEBUG)
+ bufp = trstrcpy(bufp, "d", ':');
+ else bufp = trstrcpy(bufp, "u", ':');
+
+ comma = 0;
+ if(file && file[0] && line > 0)
+ { if((bufp + strlen(file) + SLOP) >= endbuf)
+ { char* f;
+ for(f = bufp + strlen(file); f > file; --f)
+ if(f[-1] == '/' || f[-1] == '\\')
+ break;
+ file = f;
+ }
+
+ bufp = trstrcpy(bufp, "file", '=');
+ n = endbuf - bufp - SLOP - 3;
+ m = strlen(file);
+ if(m > n)
+ { file += (m - n);
+ bufp = trstrcpy(bufp, "..", '.');
+ }
+ bufp = trstrcpy(bufp, file, ',');
+ bufp = trstrcpy(bufp, "line", '=');
+ bufp = trstrcpy(bufp, tritoa((Vmulong_t)line,1), 0);
+ comma = 1;
+ }
+ if(func)
+ { if(comma)
+ *bufp++ = ',';
+ bufp = trstrcpy(bufp, "func", '=');
+#if _PACKAGE_ast
+ bufp = trstrcpy(bufp, (const char*)func, 0);
+#else
+ bufp = trstrcpy(bufp, tritoa((Vmulong_t)func,0), 0);
+#endif
+ comma = 1;
+ }
+ if(comma)
+ *bufp++ = ':';
+
+ *bufp++ = '\n';
+ *bufp = '\0';
+
+ write(Trfile,buf,(bufp-buf));
+}
+
+#if DEBUG
+#if __STD_C
+void _vmmessage(const char* s1, long n1, const char* s2, long n2)
+#else
+void _vmmessage(s1, n1, s2, n2)
+const char* s1;
+long n1;
+const char* s2;
+long n2;
+#endif
+{
+ char buf[1024], *bufp;
+
+ bufp = buf;
+ bufp = trstrcpy(bufp, "vmalloc", ':');
+ if (s1)
+ {
+ bufp = trstrcpy(bufp, s1, ':');
+ if (n1)
+ bufp = trstrcpy(bufp, tritoa(n1, 1), ':');
+ }
+ if (s2)
+ {
+ bufp = trstrcpy(bufp, s2, ':');
+ if (n2)
+ bufp = trstrcpy(bufp, tritoa(n2, 0), ':');
+ }
+ *bufp++ = '\n';
+ write(2,buf,(bufp-buf));
+}
+#endif
+
+#if __STD_C
+int vmtrace(int file)
+#else
+int vmtrace(file)
+int file;
+#endif
+{
+ int fd;
+
+ _Vmstrcpy = trstrcpy;
+ _Vmitoa = tritoa;
+ _Vmtrace = trtrace;
+
+ fd = Trfile;
+ Trfile = file;
+ return fd;
+}
+
+#if __STD_C
+int vmtrbusy(Vmalloc_t* vm)
+#else
+int vmtrbusy(vm)
+Vmalloc_t* vm;
+#endif
+{
+ Seg_t* seg;
+ Vmdata_t* vd = vm->data;
+
+ if(Trfile < 0 || !(vd->mode&(VM_MTBEST|VM_MTDEBUG|VM_MTPROFILE)))
+ return -1;
+
+ for(seg = vd->seg; seg; seg = seg->next)
+ { Block_t *b, *endb;
+ Vmuchar_t* data;
+ size_t s;
+
+ for(b = SEGBLOCK(seg), endb = BLOCK(seg->baddr); b < endb; )
+ { if(ISJUNK(SIZE(b)) || !ISBUSY(SIZE(b)))
+ continue;
+
+ data = DATA(b);
+ if(vd->mode&VM_MTDEBUG)
+ { data = DB2DEBUG(data);
+ s = DBSIZE(data);
+ }
+ else if(vd->mode&VM_MTPROFILE)
+ s = PFSIZE(data);
+ else s = SIZE(b)&~BITS;
+
+ trtrace(vm, (Vmuchar_t*)(-1), data, s, 0);
+
+ b = (Block_t*)((Vmuchar_t*)DATA(b) + (SIZE(b)&~BITS) );
+ }
+ }
+
+ return 0;
+}
+
+#endif
diff --git a/usr/src/lib/libast/common/vmalloc/vmwalk.c b/usr/src/lib/libast/common/vmalloc/vmwalk.c
new file mode 100644
index 0000000000..b401d79902
--- /dev/null
+++ b/usr/src/lib/libast/common/vmalloc/vmwalk.c
@@ -0,0 +1,76 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#if defined(_UWIN) && defined(_BLD_ast)
+
+void _STUB_vmwalk(){}
+
+#else
+
+#include "vmhdr.h"
+
+/* Walks all segments created in region(s)
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com (02/08/96)
+*/
+
+#if __STD_C
+int vmwalk(Vmalloc_t* vm, int(*segf)(Vmalloc_t*, Void_t*, size_t, Vmdisc_t*) )
+#else
+int vmwalk(vm, segf)
+Vmalloc_t* vm;
+int(* segf)(/* Vmalloc_t*, Void_t*, size_t, Vmdisc_t* */);
+#endif
+{
+ reg Seg_t* seg;
+ reg int rv;
+
+ if(!vm)
+ { for(vm = Vmheap; vm; vm = vm->next)
+ { if(!(vm->data->mode&VM_TRUST) && ISLOCK(vm->data,0) )
+ continue;
+
+ SETLOCK(vm->data,0);
+ for(seg = vm->data->seg; seg; seg = seg->next)
+ { rv = (*segf)(vm, seg->addr, seg->extent, vm->disc);
+ if(rv < 0)
+ return rv;
+ }
+ CLRLOCK(vm->data,0);
+ }
+ }
+ else
+ { if(!(vm->data->mode&VM_TRUST) && ISLOCK(vm->data,0) )
+ return -1;
+
+ SETLOCK(vm->data,0);
+ for(seg = vm->data->seg; seg; seg = seg->next)
+ { rv = (*segf)(vm, seg->addr, seg->extent, vm->disc);
+ if(rv < 0)
+ return rv;
+ }
+ CLRLOCK(vm->data,0);
+ }
+
+ return 0;
+}
+
+#endif
diff --git a/usr/src/lib/libast/i386/Makefile b/usr/src/lib/libast/i386/Makefile
new file mode 100644
index 0000000000..c19736e711
--- /dev/null
+++ b/usr/src/lib/libast/i386/Makefile
@@ -0,0 +1,47 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+# Fetch minor version from RELEASE, e.g. "10" for "5.10", "11" for "5.11" etc.
+GETRELEASEMINOR = /usr/bin/ksh -c 'x=$(RELEASE) ; print "$${x$(POUND_SIGN)$(POUND_SIGN)*.}"'
+
+# Platform-specific config
+# Note that "HOSTTYPE" matches the value used by AT&T upstream.
+ASTPLATFORMCPPFLAGS = '-DHOSTTYPE="sol$(GETRELEASEMINOR:sh).i386"'
+
+# platform-specific sources
+OBJECTS = \
+ i386/src/lib/libast/conftab.o
+OBJDIRS = \
+ i386/src/lib/libast
+
+include ../Makefile.com
+
+# Use -KPIC since libast is too big for -Kpic on 64bit
+# (and on 32bit it is close to the barrier)
+i386_C_PICFLAGS = $(C_BIGPICFLAGS)
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/usr/src/lib/libast/i386/include/ast/align.h b/usr/src/lib/libast/i386/include/ast/align.h
new file mode 100644
index 0000000000..a6c8d77177
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/align.h
@@ -0,0 +1,54 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/align.c by iffe version 2007-04-04 : : */
+#ifndef _def_align_ast
+#define _def_align_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+typedef unsigned long ALIGN_INTEGRAL;
+
+#define ALIGN_CHUNK 8192
+#define ALIGN_INTEGRAL long
+#define ALIGN_INTEGER(x) ((ALIGN_INTEGRAL)(x))
+#define ALIGN_POINTER(x) ((char*)(x))
+#define ALIGN_ROUND(x,y) ALIGN_POINTER(ALIGN_INTEGER((x)+(y)-1)&~((y)-1))
+
+#define ALIGN_BOUND ALIGN_BOUND2
+#define ALIGN_ALIGN(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC(x) ALIGN_TRUNC2(x)
+
+#define ALIGN_BIT1 0x1
+#define ALIGN_BOUND1 ALIGN_BOUND2
+#define ALIGN_ALIGN1(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC1(x) ALIGN_TRUNC2(x)
+#define ALIGN_CLRBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffe)
+#define ALIGN_SETBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x1)
+#define ALIGN_TSTBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x1)
+
+#define ALIGN_BIT2 0x2
+#define ALIGN_BOUND2 4
+#define ALIGN_ALIGN2(x) ALIGN_TRUNC2((x)+3)
+#define ALIGN_TRUNC2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffc)
+#define ALIGN_CLRBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffd)
+#define ALIGN_SETBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x2)
+#define ALIGN_TSTBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x2)
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast.h b/usr/src/lib/libast/i386/include/ast/ast.h
new file mode 100644
index 0000000000..ea1569f946
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast.h
@@ -0,0 +1,381 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Advanced Software Technology Library
+ * AT&T Research
+ *
+ * std + posix + ast
+ */
+
+#ifndef _AST_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_H
+
+#include <ast_version.h>
+
+#ifndef _AST_STD_H
+#include <ast_std.h>
+#endif
+
+#ifndef _SFIO_H
+#include <sfio.h>
+#endif
+
+#ifndef ast
+#define ast _ast_info
+#endif
+
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif
+
+/*
+ * workaround botched headers that assume <stdio.h>
+ */
+
+#ifndef FILE
+#ifndef _SFIO_H
+struct _sfio_s;
+#endif
+#define FILE struct _sfio_s
+#ifndef __FILE_typedef
+#define __FILE_typedef 1
+#endif
+#ifndef _FILEDEFED
+#define _FILEDEFED 1
+#endif
+#endif
+
+/*
+ * exit() support -- this matches shell exit codes
+ */
+
+#define EXIT_BITS 8 /* # exit status bits */
+
+#define EXIT_USAGE 2 /* usage exit code */
+#define EXIT_QUIT ((1<<(EXIT_BITS))-1) /* parent should quit */
+#define EXIT_NOTFOUND ((1<<(EXIT_BITS-1))-1) /* command not found */
+#define EXIT_NOEXEC ((1<<(EXIT_BITS-1))-2) /* other exec error */
+
+#define EXIT_CODE(x) ((x)&((1<<EXIT_BITS)-1))
+#define EXIT_CORE(x) (EXIT_CODE(x)|(1<<EXIT_BITS)|(1<<(EXIT_BITS-1)))
+#define EXIT_TERM(x) (EXIT_CODE(x)|(1<<EXIT_BITS))
+
+/*
+ * NOTE: for compatibility the following work for EXIT_BITS={7,8}
+ */
+
+#define EXIT_STATUS(x) (((x)&((1<<(EXIT_BITS-2))-1))?(x):EXIT_CODE((x)>>EXIT_BITS))
+
+#define EXITED_CORE(x) (((x)&((1<<EXIT_BITS)|(1<<(EXIT_BITS-1))))==((1<<EXIT_BITS)|(1<<(EXIT_BITS-1)))||((x)&((1<<(EXIT_BITS-1))|(1<<(EXIT_BITS-2))))==((1<<(EXIT_BITS-1))|(1<<(EXIT_BITS-2))))
+#define EXITED_TERM(x) ((x)&((1<<EXIT_BITS)|(1<<(EXIT_BITS-1))))
+
+/*
+ * astconflist() flags
+ */
+
+#define ASTCONF_parse 0x0001
+#define ASTCONF_write 0x0002
+#define ASTCONF_read 0x0004
+#define ASTCONF_lower 0x0008
+#define ASTCONF_base 0x0010
+#define ASTCONF_defined 0x0020
+#define ASTCONF_quote 0x0040
+#define ASTCONF_table 0x0080
+#define ASTCONF_matchcall 0x0100
+#define ASTCONF_matchname 0x0200
+#define ASTCONF_matchstandard 0x0400
+#define ASTCONF_error 0x0800
+#define ASTCONF_system 0x1000
+#define ASTCONF_AST 0x2000
+
+/*
+ * pathcanon() flags
+ */
+
+#define PATH_PHYSICAL 01
+#define PATH_DOTDOT 02
+#define PATH_EXISTS 04
+#define PATH_VERIFIED(n) (((n)&01777)<<5)
+
+/*
+ * pathaccess() flags
+ */
+
+#define PATH_READ 004
+#define PATH_WRITE 002
+#define PATH_EXECUTE 001
+#define PATH_REGULAR 010
+#define PATH_ABSOLUTE 020
+
+/*
+ * touch() flags
+ */
+
+#define PATH_TOUCH_CREATE 01
+#define PATH_TOUCH_VERBATIM 02
+
+/*
+ * pathcheck() info
+ */
+
+typedef struct
+{
+ unsigned long date;
+ char* feature;
+ char* host;
+ char* user;
+} Pathcheck_t;
+
+/*
+ * strgrpmatch() flags
+ */
+
+#define STR_MAXIMAL 01 /* maximal match */
+#define STR_LEFT 02 /* implicit left anchor */
+#define STR_RIGHT 04 /* implicit right anchor */
+#define STR_ICASE 010 /* ignore case */
+#define STR_GROUP 020 /* (|&) inside [@|&](...) only */
+
+/*
+ * fmtquote() flags
+ */
+
+#define FMT_ALWAYS 0x01 /* always quote */
+#define FMT_ESCAPED 0x02 /* already escaped */
+#define FMT_SHELL 0x04 /* escape $ ` too */
+#define FMT_WIDE 0x08 /* don't escape 8 bit chars */
+#define FMT_PARAM 0x10 /* disable FMT_SHELL ${$( quote */
+
+/*
+ * multibyte macros
+ */
+
+#define mbmax() (ast.mb_cur_max)
+#define mberr() (ast.tmp_int<0)
+
+#define mbcoll() (ast.mb_xfrm!=0)
+#define mbwide() (mbmax()>1)
+
+#define mbchar(p) (mbwide()?((ast.tmp_int=(*ast.mb_towc)(&ast.tmp_wchar,(char*)(p),mbmax()))>0?((p+=ast.tmp_int),ast.tmp_wchar):(p++,ast.tmp_int)):(*(unsigned char*)(p++)))
+#define mbinit() (mbwide()?(*ast.mb_towc)((wchar_t*)0,(char*)0,mbmax()):0)
+#define mbsize(p) (mbwide()?(*ast.mb_len)((char*)(p),mbmax()):((p),1))
+#define mbconv(s,w) (ast.mb_conv?(*ast.mb_conv)(s,w):((*(s)=(w)),1))
+#define mbwidth(w) (ast.mb_width&&((ast.tmp_int=(*ast.mb_width)(w))>=0||(w)>UCHAR_MAX)?ast.tmp_int:1)
+#define mbxfrm(t,f,n) (mbcoll()?(*ast.mb_xfrm)((char*)(t),(char*)(f),n):0)
+
+/*
+ * common macros
+ */
+
+#define elementsof(x) (sizeof(x)/sizeof(x[0]))
+#define integralof(x) (((char*)(x))-((char*)0))
+#define newof(p,t,n,x) ((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)calloc(1,sizeof(t)*(n)+(x)))
+#define oldof(p,t,n,x) ((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)malloc(sizeof(t)*(n)+(x)))
+#define pointerof(x) ((__V_*)((char*)0+(x)))
+#define roundof(x,y) (((x)+(y)-1)&~((y)-1))
+#define ssizeof(x) ((int)sizeof(x))
+
+#define streq(a,b) (*(a)==*(b)&&!strcmp(a,b))
+#define strneq(a,b,n) (*(a)==*(b)&&!strncmp(a,b,n))
+#define strsignal(s) fmtsignal(s)
+
+#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
+#define NiL 0
+#define NoP(x) (void)(x)
+#else
+#define NiL ((char*)0)
+#define NoP(x) (&x,1)
+#endif
+
+#if !defined(NoF)
+#if defined(__STDC__) || defined(__STDPP__)
+#define NoF(x) void _DATA_ ## x () {}
+#else
+#define NoF(x) void _DATA_/**/x () {}
+#endif
+#if !defined(_DATA_)
+#define _DATA_
+#endif
+#endif
+
+#if !defined(NoN)
+#if defined(__STDC__) || defined(__STDPP__)
+#define NoN(x) void _STUB_ ## x () {}
+#else
+#define NoN(x) void _STUB_/**/x () {}
+#endif
+#if !defined(_STUB_)
+#define _STUB_
+#endif
+#endif
+
+#define NOT_USED(x) NoP(x)
+
+typedef int (*Error_f) __PROTO__((__V_*, __V_*, int, ...));
+
+typedef int (*Ast_confdisc_f) __PROTO__((const char*, const char*, const char*));
+typedef int (*Strcmp_context_f) __PROTO__((const char*, const char*, __V_*));
+typedef int (*Strcmp_f) __PROTO__((const char*, const char*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ char* astgetconf __PROTO__((const char*, const char*, const char*, int, Error_f));
+extern __MANGLE__ char* astconf __PROTO__((const char*, const char*, const char*));
+extern __MANGLE__ Ast_confdisc_f astconfdisc __PROTO__((Ast_confdisc_f));
+extern __MANGLE__ void astconflist __PROTO__((Sfio_t*, const char*, int, const char*));
+extern __MANGLE__ off_t astcopy __PROTO__((int, int, off_t));
+extern __MANGLE__ int astlicense __PROTO__((char*, int, char*, char*, int, int, int));
+extern __MANGLE__ int astquery __PROTO__((int, const char*, ...));
+extern __MANGLE__ void astwinsize __PROTO__((int, int*, int*));
+
+extern __MANGLE__ ssize_t base64encode __PROTO__((const __V_*, size_t, __V_**, __V_*, size_t, __V_**));
+extern __MANGLE__ ssize_t base64decode __PROTO__((const __V_*, size_t, __V_**, __V_*, size_t, __V_**));
+extern __MANGLE__ int chresc __PROTO__((const char*, char**));
+extern __MANGLE__ int chrtoi __PROTO__((const char*));
+extern __MANGLE__ int eaccess __PROTO__((const char*, int));
+extern __MANGLE__ char* fmtbase __PROTO__((long, int, int));
+extern __MANGLE__ char* fmtbasell __PROTO__((intmax_t, int, int));
+#define fmtbase(a,b,c) fmtbasell((intmax_t)(a),b,c) /* until 2003-09-01 */
+extern __MANGLE__ char* fmtbuf __PROTO__((size_t));
+extern __MANGLE__ char* fmtclock __PROTO__((Sfulong_t));
+extern __MANGLE__ char* fmtelapsed __PROTO__((unsigned long, int));
+extern __MANGLE__ char* fmterror __PROTO__((int));
+extern __MANGLE__ char* fmtesc __PROTO__((const char*));
+extern __MANGLE__ char* fmtesq __PROTO__((const char*, const char*));
+extern __MANGLE__ char* fmtident __PROTO__((const char*));
+extern __MANGLE__ char* fmtip4 __PROTO__((uint32_t, int));
+extern __MANGLE__ char* fmtfmt __PROTO__((const char*));
+extern __MANGLE__ char* fmtgid __PROTO__((int));
+extern __MANGLE__ char* fmtmatch __PROTO__((const char*));
+extern __MANGLE__ char* fmtmode __PROTO__((int, int));
+extern __MANGLE__ char* fmtnesq __PROTO__((const char*, const char*, size_t));
+extern __MANGLE__ char* fmtnum __PROTO__((unsigned long, int));
+extern __MANGLE__ char* fmtperm __PROTO__((int));
+extern __MANGLE__ char* fmtquote __PROTO__((const char*, const char*, const char*, size_t, int));
+extern __MANGLE__ char* fmtre __PROTO__((const char*));
+extern __MANGLE__ char* fmtscale __PROTO__((Sfulong_t, int));
+extern __MANGLE__ char* fmtsignal __PROTO__((int));
+extern __MANGLE__ char* fmttime __PROTO__((const char*, time_t));
+extern __MANGLE__ char* fmtuid __PROTO__((int));
+extern __MANGLE__ char* fmtversion __PROTO__((unsigned long));
+extern __MANGLE__ __V_* memdup __PROTO__((const __V_*, size_t));
+extern __MANGLE__ void memfatal __PROTO__((void));
+extern __MANGLE__ unsigned int memhash __PROTO__((const __V_*, int));
+extern __MANGLE__ unsigned long memsum __PROTO__((const __V_*, int, unsigned long));
+extern __MANGLE__ char* pathaccess __PROTO__((char*, const char*, const char*, const char*, int));
+extern __MANGLE__ char* pathbin __PROTO__((void));
+extern __MANGLE__ char* pathcanon __PROTO__((char*, int));
+extern __MANGLE__ char* pathcat __PROTO__((char*, const char*, int, const char*, const char*));
+extern __MANGLE__ int pathcd __PROTO__((const char*, const char*));
+extern __MANGLE__ int pathcheck __PROTO__((const char*, const char*, Pathcheck_t*));
+extern __MANGLE__ int pathexists __PROTO__((char*, int));
+extern __MANGLE__ char* pathfind __PROTO__((const char*, const char*, const char*, char*, size_t));
+extern __MANGLE__ int pathgetlink __PROTO__((const char*, char*, int));
+extern __MANGLE__ int pathinclude __PROTO__((const char*));
+extern __MANGLE__ char* pathkey __PROTO__((char*, char*, const char*, const char*, const char*));
+extern __MANGLE__ size_t pathnative __PROTO__((const char*, char*, size_t));
+extern __MANGLE__ char* pathpath __PROTO__((char*, const char*, const char*, int));
+extern __MANGLE__ size_t pathposix __PROTO__((const char*, char*, size_t));
+extern __MANGLE__ char* pathprobe __PROTO__((char*, char*, const char*, const char*, const char*, int));
+extern __MANGLE__ char* pathrepl __PROTO__((char*, const char*, const char*));
+extern __MANGLE__ int pathsetlink __PROTO__((const char*, const char*));
+extern __MANGLE__ char* pathshell __PROTO__((void));
+extern __MANGLE__ char* pathtemp __PROTO__((char*, size_t, const char*, const char*, int*));
+extern __MANGLE__ char* pathtmp __PROTO__((char*, const char*, const char*, int*));
+extern __MANGLE__ char* setenviron __PROTO__((const char*));
+extern __MANGLE__ int stracmp __PROTO__((const char*, const char*));
+extern __MANGLE__ char* strcopy __PROTO__((char*, const char*));
+extern __MANGLE__ unsigned long strelapsed __PROTO__((const char*, char**, int));
+extern __MANGLE__ int stresc __PROTO__((char*));
+extern __MANGLE__ long streval __PROTO__((const char*, char**, long(*)(const char*, char**)));
+extern __MANGLE__ long strexpr __PROTO__((const char*, char**, long(*)(const char*, char**, __V_*), __V_*));
+extern __MANGLE__ int strgid __PROTO__((const char*));
+extern __MANGLE__ int strgrpmatch __PROTO__((const char*, const char*, int*, int, int));
+extern __MANGLE__ unsigned int strhash __PROTO__((const char*));
+extern __MANGLE__ __V_* strlook __PROTO__((const __V_*, size_t, const char*));
+extern __MANGLE__ int strmatch __PROTO__((const char*, const char*));
+extern __MANGLE__ int strmode __PROTO__((const char*));
+extern __MANGLE__ int strnacmp __PROTO__((const char*, const char*, size_t));
+extern __MANGLE__ char* strncopy __PROTO__((char*, const char*, size_t));
+extern __MANGLE__ double strntod __PROTO__((const char*, size_t, char**));
+extern __MANGLE__ _ast_fltmax_t strntold __PROTO__((const char*, size_t, char**));
+extern __MANGLE__ long strntol __PROTO__((const char*, size_t, char**, int));
+extern __MANGLE__ intmax_t strntoll __PROTO__((const char*, size_t, char**, int));
+extern __MANGLE__ unsigned long strntoul __PROTO__((const char*, size_t, char**, int));
+extern __MANGLE__ uintmax_t strntoull __PROTO__((const char*, size_t, char**, int));
+extern __MANGLE__ int stropt __PROTO__((const char*, const __V_*, int, int(*)(__V_*, const __V_*, int, const char*), __V_*));
+extern __MANGLE__ int strperm __PROTO__((const char*, char**, int));
+extern __MANGLE__ __V_* strpsearch __PROTO__((const __V_*, size_t, size_t, const char*, char**));
+extern __MANGLE__ __V_* strsearch __PROTO__((const __V_*, size_t, size_t, Strcmp_f, const char*, __V_*));
+extern __MANGLE__ void strsort __PROTO__((char**, int, int(*)(const char*, const char*)));
+extern __MANGLE__ char* strsubmatch __PROTO__((const char*, const char*, int));
+extern __MANGLE__ unsigned long strsum __PROTO__((const char*, unsigned long));
+extern __MANGLE__ char* strtape __PROTO__((const char*, char**));
+extern __MANGLE__ int strtoip4 __PROTO__((const char*, char**, uint32_t*, unsigned char*));
+extern __MANGLE__ long strton __PROTO__((const char*, char**, char*, int));
+extern __MANGLE__ intmax_t strtonll __PROTO__((const char*, char**, char*, int));
+extern __MANGLE__ int struid __PROTO__((const char*));
+extern __MANGLE__ int struniq __PROTO__((char**, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+/*
+ * C library global data symbols not prototyped by <unistd.h>
+ */
+
+#if !defined(environ) && defined(__DYNAMIC__)
+#define environ __DYNAMIC__(environ)
+#else
+extern __MANGLE__ char** environ;
+#endif
+
+/*
+ * really handy malloc()/free() (__FILE__,__LINE__,__FUNCTION__) tracing
+ * make with VMDEBUG==1 or debug=1 or CCFLAGS=$(CC.DEBUG)
+ * VMDEBUG==0 disables
+ * at runtime export VMDEBUG or VMTRACE per vmalloc.3
+ * to list originating call locations
+ */
+
+#if !_std_malloc && !defined(VMFL) && !defined(_VMHDR_H) && \
+ (!defined(VMDEBUG) || VMDEBUG) && (VMDEBUG || _BLD_DEBUG)
+
+#define VMFL 1
+#include <vmalloc.h>
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_botch.h b/usr/src/lib/libast/i386/include/ast/ast_botch.h
new file mode 100644
index 0000000000..8c100aac74
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_botch.h
@@ -0,0 +1,26 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/botch.c by iffe version 2007-04-04 : : */
+#ifndef _def_botch_ast
+#define _def_botch_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_ccode.h b/usr/src/lib/libast/i386/include/ast/ast_ccode.h
new file mode 100644
index 0000000000..0b46e34c38
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_ccode.h
@@ -0,0 +1,50 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/ccode by iffe version 2007-04-04 : : */
+#ifndef _def_ccode_ast
+#define _def_ccode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define CC_ASCII 1 /* ISO-8859-1 */
+#define CC_EBCDIC_E 2 /* Xopen dd(1) EBCDIC */
+#define CC_EBCDIC_I 3 /* Xopen dd(1) IBM */
+#define CC_EBCDIC_O 4 /* IBM-1047 mvs OpenEdition */
+#define CC_EBCDIC_S 5 /* Siemens posix-bc */
+#define CC_EBCDIC_H 6 /* IBM-37 AS/400 */
+#define CC_EBCDIC_M 7 /* IBM mvs cobol */
+#define CC_EBCDIC_U 8 /* microfocus cobol */
+
+#define CC_MAPS 8 /* number of code maps */
+
+#define CC_EBCDIC CC_EBCDIC_E
+#define CC_EBCDIC1 CC_EBCDIC_E
+#define CC_EBCDIC2 CC_EBCDIC_I
+#define CC_EBCDIC3 CC_EBCDIC_O
+
+#define CC_NATIVE CC_ASCII /* native character code */
+#define CC_ALIEN CC_EBCDIC /* alien character code */
+
+#define CC_bel 0007 /* bel character */
+#define CC_esc 0033 /* esc character */
+#define CC_sub 0032 /* sub character */
+#define CC_vt 0013 /* vt character */
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_common.h b/usr/src/lib/libast/i386/include/ast/ast_common.h
new file mode 100644
index 0000000000..b32e1ed12b
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_common.h
@@ -0,0 +1,219 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/common by iffe version 2007-04-04 : : */
+#ifndef _AST_COMMON_H
+#define _AST_COMMON_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_pthread 1 /* #include <pthread.h> ok */
+#define _hdr_stdarg 1 /* #include <stdarg.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdint 1 /* #include <stdint.h> ok */
+#define _hdr_inttypes 1 /* #include <inttypes.h> ok */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_long_double 1 /* long double is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _std_proto 1 /* standard C prototypes ok */
+#define _ptr_void 1 /* standard C void* ok */
+/* disable non-standard linux/gnu inlines */
+#ifdef __GNUC__
+# undef __OPTIMIZE_SIZE__
+# define __OPTIMIZE_SIZE__ 1
+#endif
+
+/* __STD_C indicates that the language is ANSI-C or C++ */
+#if !defined(__STD_C) && __STDC__
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && (__cplusplus || c_plusplus)
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && _std_proto
+# define __STD_C 1
+#endif
+#if !defined(__STD_C)
+# define __STD_C 0
+#endif
+
+/* extern symbols must be protected against C++ name mangling */
+#ifndef _BEGIN_EXTERNS_
+# if __cplusplus || c_plusplus
+# define _BEGIN_EXTERNS_ extern "C" {
+# define _END_EXTERNS_ }
+# else
+# define _BEGIN_EXTERNS_
+# define _END_EXTERNS_
+# endif
+#endif
+
+/* _ARG_ simplifies function prototyping among flavors of C */
+#ifndef _ARG_
+# if __STD_C
+# define _ARG_(x) x
+# else
+# define _ARG_(x) ()
+# endif
+#endif
+
+/* _NIL_ simplifies defining nil pointers to a given type */
+#ifndef _NIL_
+# define _NIL_(x) ((x)0)
+#endif
+
+/* __INLINE__ is the inline keyword */
+#if !defined(__INLINE__) && defined(__cplusplus)
+# define __INLINE__ inline
+#endif
+#if !defined(__INLINE__) && defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+#endif
+
+/* Void_t is defined so that Void_t* can address any type */
+#ifndef Void_t
+# if __STD_C
+# define Void_t void
+# else
+# define Void_t char
+# endif
+#endif
+
+/* windows variants and veneers */
+#if !defined(_WINIX) && (_UWIN || __CYGWIN__ || __EMX__)
+# define _WINIX 1
+#endif
+
+/* dynamic linked library external scope handling */
+#ifdef __DYNAMIC__
+# undef __DYNAMIC__
+# ifndef _DLL
+# define _DLL 1
+# endif
+#endif
+#if _dll_import
+# if _BLD_STATIC && !_BLD_DLL
+# undef _DLL
+# else
+# if !_UWIN && !defined(_DLL)
+# define _DLL 1
+# endif
+# endif
+# if !defined(__EXPORT__) && _BLD_DLL
+# define __EXPORT__ __declspec(dllexport)
+# endif
+# if !defined(__IMPORT__) && ( _BLD_DLL || defined(_DLL) )
+# define __IMPORT__ __declspec(dllimport)
+# endif
+# if _BLD_DLL && _UWIN
+# define __DYNAMIC__(v) (_ast_getdll()->_ast_ ## v)
+# endif
+#endif
+#if !defined(_astimport)
+# if defined(__IMPORT__) && defined(_DLL)
+# define _astimport __IMPORT__
+# else
+# define _astimport extern
+# endif
+#endif
+#if _dll_import && ( !_BLD_DLL || _WINIX && !_UWIN )
+# ifdef __STDC__
+# define __EXTERN__(T,obj) extern T obj; T* _imp__ ## obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__ ## obj = &obj
+# else
+# define __EXTERN__(T,obj) extern T obj; T* _imp__/**/obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__/**/obj = &obj
+# endif
+#else
+# define __EXTERN__(T,obj) extern T obj
+# define __DEFINE__(T,obj,val) T obj = val
+#endif
+
+#define _ast_LL 1 /* LL numeric suffix supported */
+#define _ast_int1_t char
+#define _ast_int2_t short
+#define _ast_int4_t int
+#define _ast_int8_t long long
+#define _ast_intmax_t _ast_int8_t
+#define _ast_intswap 7
+
+#define _ast_flt4_t float
+#define _ast_flt8_t double
+#define _ast_flt12_t long double
+#define _ast_fltmax_t _ast_flt12_t
+#define _typ_int8_t 1 /* int8_t is a type */
+#define _typ_uint8_t 1 /* uint8_t is a type */
+#define _typ_int16_t 1 /* int16_t is a type */
+#define _typ_uint16_t 1 /* uint16_t is a type */
+#define _typ_int32_t 1 /* int32_t is a type */
+#define _typ_uint32_t 1 /* uint32_t is a type */
+#define _typ_int64_t 1 /* int64_t is a type */
+#define _typ_uint64_t 1 /* uint64_t is a type */
+#define _typ_intmax_t 1 /* intmax_t is a type */
+#define _typ_uintmax_t 1 /* uintmax_t is a type */
+
+#ifndef va_listref
+#define va_listref(p) (p) /* pass va_list to varargs function */
+#define va_listval(p) (p) /* retrieve va_list from va_arg(ap,va_listarg) */
+#define va_listarg va_list /* va_arg() va_list type */
+#ifndef va_start
+#if __STD_C
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+#endif
+#ifndef _AST_STD_H
+# if __STD_C && _hdr_stddef
+# include <stddef.h>
+# endif
+# if _sys_types
+# include <sys/types.h>
+# endif
+# if _hdr_stdint
+# include <stdint.h>
+# else
+# if _hdr_inttypes
+# include <inttypes.h>
+# endif
+# endif
+#endif
+#if !_typ_size_t
+# define _typ_size_t 1
+ typedef int size_t;
+#endif
+#if !_typ_ssize_t
+# define _typ_ssize_t 1
+ typedef int ssize_t;
+#endif
+#ifndef _AST_STD_H
+# if !_def_map_ast
+# include <ast_map.h>
+# endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_dir.h b/usr/src/lib/libast/i386/include/ast/ast_dir.h
new file mode 100644
index 0000000000..336b7f38a6
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_dir.h
@@ -0,0 +1,86 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * AT&T Research
+ *
+ * common dirent maintenance interface
+ */
+
+#ifndef _AST_DIR_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_DIR_H
+
+#include <ast_lib.h>
+
+#if _mem_d_fileno_dirent || _mem_d_ino_dirent
+#if !_mem_d_fileno_dirent
+#undef _mem_d_fileno_dirent
+#define _mem_d_fileno_dirent 1
+#define d_fileno d_ino
+#endif
+#endif
+
+#if _BLD_ast
+#include "dirlib.h"
+#else
+#include <dirent.h>
+#endif
+
+#if _mem_d_fileno_dirent
+#define D_FILENO(d) ((d)->d_fileno)
+#endif
+
+#if _mem_d_namlen_dirent
+#define D_NAMLEN(d) ((d)->d_namlen)
+#else
+#define D_NAMLEN(d) (strlen((d)->d_name))
+#endif
+
+#if _mem_d_reclen_dirent
+#define D_RECLEN(d) ((d)->d_reclen)
+#else
+#define D_RECLEN(d) D_RECSIZ(d,D_NAMLEN(d))
+#endif
+
+#define D_RECSIZ(d,n) (sizeof(*(d))-sizeof((d)->d_name)+((n)+sizeof(char*))&~(sizeof(char*)-1))
+
+/*
+ * NOTE: 2003-03-27 mac osx bug symlink==DT_REG bug discovered;
+ * the kernel *and* all directories must be fixed, so d_type
+ * is summarily disabled until we see that happen
+ */
+
+#if _mem_d_type_dirent && defined(DT_UNKNOWN) && defined(DT_REG) && defined(DT_DIR) && defined(DT_LNK) && ! ( __APPLE__ || __MACH__ )
+#define D_TYPE(d) ((d)->d_type)
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_dirent.h b/usr/src/lib/libast/i386/include/ast/ast_dirent.h
new file mode 100644
index 0000000000..c0723a1fde
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_dirent.h
@@ -0,0 +1,127 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/dirent by iffe version 2007-04-04 : : */
+
+#ifndef _def_dirent_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dirent_ast 1
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _nxt_dirent <../include/dirent.h> /* include path for the native <dirent.h> */
+#define _nxt_dirent_str "../include/dirent.h" /* include string for the native <dirent.h> */
+/*
+ * <dirent.h> for [fl]stat64 and off64_t
+ */
+
+#ifndef _AST_STD_H
+
+#include <../include/dirent.h> /* the native <dirent.h> */
+
+#else
+
+#ifndef _DIR64_H
+#define _DIR64_H
+
+#include <ast_std.h>
+
+#if _typ_off64_t
+#undef off_t
+#endif
+
+#include <../include/dirent.h> /* the native <dirent.h> */
+
+#if _typ_off64_t
+#define off_t off64_t
+#endif
+
+#if _lib_readdir64 && _typ_struct_dirent64
+#ifndef dirent
+#define dirent dirent64
+#endif
+#ifndef readdir
+#define readdir readdir64
+#endif
+#endif
+
+#endif
+
+#endif
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_fcntl.h b/usr/src/lib/libast/i386/include/ast/ast_fcntl.h
new file mode 100644
index 0000000000..c9a69f9c0d
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_fcntl.h
@@ -0,0 +1,135 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/fcntl.c by iffe version 2007-04-04 : : */
+#ifndef _def_fcntl_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fcntl_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <ast_fs.h>
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#define O_BINARY 0
+#define O_TEMPORARY 0
+#define O_TEXT 0
+
+#include <ast_fs.h>
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_fstat64
+#define fstat fstat64
+#endif
+#if _lib_lstat64
+#define lstat lstat64
+#endif
+#if _lib_stat64
+#define stat stat64
+#endif
+#if _lib_creat64
+#define creat creat64
+#endif
+#if _lib_mmap64
+#define mmap mmap64
+#endif
+#if _lib_open64
+#undef open
+#define open open64
+#endif
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_float.h b/usr/src/lib/libast/i386/include/ast/ast_float.h
new file mode 100644
index 0000000000..0c4a8ba62f
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_float.h
@@ -0,0 +1,234 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/float by iffe version 2007-04-04 : : */
+
+#ifndef _def_float_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_float_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_float 1 /* #include <float.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _hdr_values 1 /* #include <values.h> ok */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_frexp 1 /* frexp() in default lib(s) */
+#define _lib_frexpl 1 /* frexpl() in default lib(s) */
+#define _lib_ldexp 1 /* ldexp() in default lib(s) */
+#define _lib_ldexpl 1 /* ldexpl() in default lib(s) */
+#define _lib_finite 1 /* finite() in default lib(s) */
+#define _lib_isnan 1 /* isnan() in default lib(s) */
+#define _lib_isnanl 1 /* isnanl() in default lib(s) */
+#define _lib_copysign 1 /* copysign() in default lib(s) */
+#define _lib_copysignl 1 /* copysignl() in default lib(s) */
+#include <ast_common.h>
+#include <float.h>
+#include <math.h>
+#ifndef FLT_DIG
+#define FLT_DIG 6
+#endif
+#ifndef FLT_MAX
+#define FLT_MAX 3.4028234663852885981170E+38F
+#endif
+#ifndef FLT_MAX_10_EXP
+#define FLT_MAX_10_EXP ( + 38 )
+#endif
+#ifndef FLT_MAX_EXP
+#define FLT_MAX_EXP ( + 128 )
+#endif
+#ifndef FLT_MIN
+#define FLT_MIN 1.1754943508222875079688E-38F
+#endif
+#ifndef FLT_MIN_10_EXP
+#define FLT_MIN_10_EXP ( - 37 )
+#endif
+#ifndef FLT_MIN_EXP
+#define FLT_MIN_EXP ( - 125 )
+#endif
+#ifndef DBL_DIG
+#define DBL_DIG 15
+#endif
+#ifndef DBL_MAX
+#define DBL_MAX 1.7976931348623157081452E+308
+#endif
+#ifndef DBL_MAX_10_EXP
+#define DBL_MAX_10_EXP ( + 308 )
+#endif
+#ifndef DBL_MAX_EXP
+#define DBL_MAX_EXP ( + 1024 )
+#endif
+#ifndef DBL_MIN
+#define DBL_MIN 2.2250738585072013830903E-308
+#endif
+#ifndef DBL_MIN_10_EXP
+#define DBL_MIN_10_EXP ( - 307 )
+#endif
+#ifndef DBL_MIN_EXP
+#define DBL_MIN_EXP ( - 1021 )
+#endif
+#ifndef LDBL_DIG
+#define LDBL_DIG 18
+#endif
+#ifndef LDBL_MAX
+#define LDBL_MAX 1.1897314953572317650213E+4932L
+#endif
+#ifndef LDBL_MAX_10_EXP
+#define LDBL_MAX_10_EXP ( + 4932 )
+#endif
+#ifndef LDBL_MAX_EXP
+#define LDBL_MAX_EXP ( + 16384 )
+#endif
+#ifndef LDBL_MIN
+#define LDBL_MIN 3.3621031431120935062627E-4932L
+#endif
+#ifndef LDBL_MIN_10_EXP
+#define LDBL_MIN_10_EXP ( - 4931 )
+#endif
+#ifndef LDBL_MIN_EXP
+#define LDBL_MIN_EXP ( - 16381 )
+#endif
+
+
+#define USHRT_DIG 4
+#define UINT_DIG 9
+#define ULONG_DIG 9
+#define ULLONG_DIG 19
+#define UINTMAX_DIG ULLONG_DIG
+
+#define FLT_ULONG_MAX 4294967295.0F
+#define FLT_ULLONG_MAX 18446744073709551615.0F
+#define FLT_UINTMAX_MAX FLT_ULLONG_MAX
+#define FLT_LONG_MAX 2147483647.0F
+#define FLT_LLONG_MAX 9223372036854775807.0F
+#define FLT_INTMAX_MAX FLT_LLONG_MAX
+#define FLT_LONG_MIN (-2147483648.0F)
+#define FLT_LLONG_MIN (-9223372036854775808.0F)
+#define FLT_INTMAX_MIN FLT_LLONG_MIN
+
+#define DBL_ULONG_MAX 4294967295.0
+#define DBL_ULLONG_MAX 18446744073709551615.0
+#define DBL_UINTMAX_MAX DBL_ULLONG_MAX
+#define DBL_LONG_MAX 2147483647.0
+#define DBL_LLONG_MAX 9223372036854775807.0
+#define DBL_INTMAX_MAX DBL_LLONG_MAX
+#define DBL_LONG_MIN (-2147483648.0)
+#define DBL_LLONG_MIN (-9223372036854775808.0)
+#define DBL_INTMAX_MIN DBL_LLONG_MIN
+
+#define LDBL_ULONG_MAX 4294967295.0L
+#define LDBL_ULLONG_MAX 18446744073709551615.0L
+#define LDBL_UINTMAX_MAX LDBL_ULLONG_MAX
+#define LDBL_LONG_MAX 2147483647.0L
+#define LDBL_LLONG_MAX 9223372036854775807.0L
+#define LDBL_INTMAX_MAX LDBL_LLONG_MAX
+#define LDBL_LONG_MIN (-2147483648.0L)
+#define LDBL_LLONG_MIN (-9223372036854775808.0L)
+#define LDBL_INTMAX_MIN LDBL_LLONG_MIN
+
+#define FLTMAX_UINTMAX_MAX LDBL_UINTMAX_MAX
+#define FLTMAX_INTMAX_MAX LDBL_INTMAX_MAX
+#define FLTMAX_INTMAX_MIN LDBL_INTMAX_MIN
+
+typedef union _ast_dbl_exp_u
+{
+ uint32_t e[sizeof(double)/4];
+ double f;
+} _ast_dbl_exp_t;
+
+#define _ast_dbl_exp_index 1
+#define _ast_dbl_exp_shift 20
+
+typedef union _fltmax_exp_u
+{
+ uint32_t e[sizeof(_ast_fltmax_t)/4];
+ _ast_fltmax_t f;
+} _ast_fltmax_exp_t;
+
+#define _ast_fltmax_exp_index 2
+#define _ast_fltmax_exp_shift 0
+
+#define _ast_flt_unsigned_max_t unsigned long long
+#define _ast_flt_nan_init 0xff,0xff,0xff,0x7f
+#define _ast_flt_inf_init 0x00,0x00,0x80,0x7f
+#define _ast_dbl_nan_init 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f
+#define _ast_dbl_inf_init 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x7f
+#define _ast_ldbl_nan_init 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xf0,0x7f
+#define _ast_ldbl_inf_init 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x7f,0xf0,0x7f
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_fs.h b/usr/src/lib/libast/i386/include/ast/ast_fs.h
new file mode 100644
index 0000000000..0d0e39f6b0
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_fs.h
@@ -0,0 +1,179 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/fs by iffe version 2007-04-04 : : */
+
+#ifndef _def_fs_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fs_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _lib__fxstat 1 /* _fxstat() in default lib(s) */
+#define _lib__lxstat 1 /* _lxstat() in default lib(s) */
+#define _lib__xmknod 1 /* _xmknod() in default lib(s) */
+#define _lib__xstat 1 /* _xstat() in default lib(s) */
+#define _lib_lstat 1 /* lstat() in default lib(s) */
+#define _lib_mknod 1 /* mknod() in default lib(s) */
+#define _lib_sync 1 /* sync() in default lib(s) */
+#include <sys/stat.h>
+#define FS_default "ufs"
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef major
+#define major(x) ( major_t ) ( ( ( ( unsigned ) ( ( x ) ) ) >> 8 ) & 0x7f )
+#endif
+#ifndef minor
+#define minor(x) ( minor_t ) ( ( ( x ) ) & 0xff )
+#endif
+#ifndef makedev
+#define makedev(x,y) ( unsigned short ) ( ( ( ( x ) ) << 8 ) | ( ( ( y ) ) & 0xff ) )
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _sys_mntent 1 /* #include <sys/mntent.h> ok */
+#define _sys_mnttab 1 /* #include <sys/mnttab.h> ok */
+#define _mem_st_blocks_stat 1 /* st_blocks is a member of struct stat */
+#define _mem_st_blksize_stat 1 /* st_blksize is a member of struct stat */
+#define _mem_st_rdev_stat 1 /* st_rdev is a member of struct stat */
+#define _sys_statfs 1 /* #include <sys/statfs.h> ok */
+#define _mem_f_files_statfs 1 /* f_files is a member of struct statfs */
+#define _sys_vfs 1 /* #include <sys/vfs.h> ok */
+#define _sys_param 1 /* #include <sys/param.h> ok */
+#define _sys_mount 1 /* #include <sys/mount.h> ok */
+#define _sys_statvfs 1 /* #include <sys/statvfs.h> ok */
+#define _mem_f_basetype_statvfs 1 /* f_basetype is a member of struct statvfs */
+#define _mem_f_frsize_statvfs 1 /* f_frsize is a member of struct statvfs */
+#define _lib_getmntent 1 /* getmntent() in default lib(s) */
+#define _lib_statfs 1 /* statfs() in default lib(s) */
+#define _lib_statvfs 1 /* statvfs() in default lib(s) */
+#define _lib_statfs4 1 /* compile{\ passed */
+#if _sys_statvfs
+#include <sys/statvfs.h>
+#if !_mem_statvfs_f_basetype
+#if _ary_f_reserved7
+#define f_basetype f_reserved7
+#endif
+#endif
+#else
+#define _mem_f_basetype_statvfs 1
+#define _mem_f_frsize_statvfs 1
+struct statvfs
+{
+unsigned long f_bsize; /* fundamental file system block size */
+unsigned long f_frsize; /* fragment size */
+unsigned long f_blocks; /* total # of blocks of f_frsize on fs */
+unsigned long f_bfree; /* total # of free blocks of f_frsize */
+unsigned long f_bavail; /* # of free blocks avail to non-superuser */
+unsigned long f_files; /* total # of file nodes (inodes) */
+unsigned long f_ffree; /* total # of free file nodes */
+unsigned long f_favail; /* # of free nodes avail to non-superuser */
+unsigned long f_fsid; /* file system id (dev for now) */
+char f_basetype[16]; /* target fs type name, null-terminated */
+unsigned long f_flag; /* bit-mask of flags */
+unsigned long f_namemax; /* maximum file name length */
+char f_fstr[32]; /* filesystem-specific string */
+unsigned long f_filler[16]; /* reserved for future expansion */
+};
+extern __MANGLE__ int fstatvfs __PROTO__((int, struct statvfs*));
+extern __MANGLE__ int statvfs __PROTO__((const char*, struct statvfs*));
+#endif
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_statvfs64 && !defined(statvfs)
+#define statvfs statvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int statvfs64 __PROTO__((const char*, struct statvfs64*));
+#endif
+#endif
+#if _lib_fstatvfs64 && !defined(fstatvfs)
+#define fstatvfs fstatvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int fstatvfs64 __PROTO__((int, struct statvfs64*));
+#endif
+#endif
+
+#define _str_st_fstype 1 /* stat.st_fstype is a string */
+#define _ary_st_pad4 1 /* stat.st_pad4 is an array */
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_getopt.h b/usr/src/lib/libast/i386/include/ast/ast_getopt.h
new file mode 100644
index 0000000000..0de85c6172
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_getopt.h
@@ -0,0 +1,51 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * legacy standard getopt interface
+ */
+
+#ifndef _AST_GETOPT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_GETOPT_H 1
+
+extern __MANGLE__ int opterr;
+extern __MANGLE__ int optind;
+extern __MANGLE__ int optopt;
+extern __MANGLE__ char* optarg;
+
+#ifndef NULL /* in case <stdlib.h> or <stdio.h> got here first */
+
+extern __MANGLE__ int getopt __PROTO__((int, char* const*, const char*));
+extern __MANGLE__ int getsubopt __PROTO__((char**, char* const*, char**));
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_iconv.h b/usr/src/lib/libast/i386/include/ast/ast_iconv.h
new file mode 100644
index 0000000000..001a08e992
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_iconv.h
@@ -0,0 +1,153 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/iconv by iffe version 2007-04-04 : : */
+
+#ifndef _def_iconv_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_iconv_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_iconv 1 /* #include <iconv.h> ok */
+#define _lib_iconv_open 1 /* iconv_open() in default lib(s) */
+#define _lib_iconv_close 1 /* iconv_close() in default lib(s) */
+#define _lib_iconv 1 /* iconv() in default lib(s) */
+#define _nxt_iconv <../include/iconv.h> /* include path for the native <iconv.h> */
+#define _nxt_iconv_str "../include/iconv.h" /* include string for the native <iconv.h> */
+#include <ast_common.h>
+#include <ccode.h>
+#include <../include/iconv.h> /* the native iconv.h */
+
+#define CC_ICONV (-1)
+#define CC_UCS (-2)
+#define CC_SCU (-3)
+#define CC_UTF (-4)
+#define CC_UME (-5)
+
+#ifndef _ICONV_LIST_PRIVATE_
+#undef iconv_t
+#define iconv_t _ast_iconv_t
+#undef iconv_f
+#define iconv_f _ast_iconv_f
+#undef iconv_list_t
+#define iconv_list_t _ast_iconv_list_t
+#undef iconv_open
+#define iconv_open _ast_iconv_open
+#undef iconv
+#define iconv _ast_iconv
+#undef iconv_close
+#define iconv_close _ast_iconv_close
+#undef iconv_list
+#define iconv_list _ast_iconv_list
+#undef iconv_move
+#define iconv_move _ast_iconv_move
+#undef iconv_name
+#define iconv_name _ast_iconv_name
+#undef iconv_write
+#define iconv_write _ast_iconv_write
+#endif
+
+typedef Ccmap_t _ast_iconv_list_t;
+typedef __V_* _ast_iconv_t;
+typedef size_t (*_ast_iconv_f) __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ _ast_iconv_t _ast_iconv_open __PROTO__((const char*, const char*));
+extern __MANGLE__ size_t _ast_iconv __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+extern __MANGLE__ int _ast_iconv_close __PROTO__((_ast_iconv_t));
+extern __MANGLE__ _ast_iconv_list_t* _ast_iconv_list __PROTO__((_ast_iconv_list_t*));
+extern __MANGLE__ int _ast_iconv_name __PROTO__((const char*, char*, size_t));
+#if _SFIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, Sfio_t*, Sfio_t*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, Sfio_t*, char**, size_t*, size_t*));
+#else
+#if _SFSTDIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, FILE*, FILE*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, FILE*, char**, size_t*, size_t*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_lib.h b/usr/src/lib/libast/i386/include/ast/ast_lib.h
new file mode 100644
index 0000000000..7826d47485
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_lib.h
@@ -0,0 +1,192 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/lib by iffe version 2007-04-04 : : */
+#ifndef _def_lib_ast
+#define _def_lib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _hdr_fmtmsg 1 /* #include <fmtmsg.h> ok */
+#define _hdr_fnmatch 1 /* #include <fnmatch.h> ok */
+#define _hdr_libgen 1 /* #include <libgen.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_locale 1 /* #include <locale.h> ok */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_spawn 1 /* #include <spawn.h> ok */
+#define _hdr_syslog 1 /* #include <syslog.h> ok */
+#define _hdr_utime 1 /* #include <utime.h> ok */
+#define _hdr_wctype 1 /* #include <wctype.h> ok */
+#define _hdr_wchar 1 /* <wchar.h> and isw*() really work */
+#define _dat__tzname 1 /* _tzname in default lib(s) */
+#define _dat_tzname 1 /* tzname in default lib(s) */
+#define _lib__cleanup 1 /* _cleanup() in default lib(s) */
+#define _lib_atexit 1 /* atexit() in default lib(s) */
+#define _lib_bcopy 1 /* bcopy() in default lib(s) */
+#define _lib_bzero 1 /* bzero() in default lib(s) */
+#define _lib_catclose 1 /* catclose() in default lib(s) */
+#define _lib_catgets 1 /* catgets() in default lib(s) */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_confstr 1 /* confstr() in default lib(s) */
+#define _lib_dup2 1 /* dup2() in default lib(s) */
+#define _lib_execlp 1 /* execlp() in default lib(s) */
+#define _lib_execve 1 /* execve() in default lib(s) */
+#define _lib_execvp 1 /* execvp() in default lib(s) */
+#define _lib_fchmod 1 /* fchmod() in default lib(s) */
+#define _lib_fcntl 1 /* fcntl() in default lib(s) */
+#define _lib_fmtmsg 1 /* fmtmsg() in default lib(s) */
+#define _lib_fnmatch 1 /* fnmatch() in default lib(s) */
+#define _lib_fork 1 /* fork() in default lib(s) */
+#define _lib_fsync 1 /* fsync() in default lib(s) */
+#define _lib_getdents 1 /* getdents() in default lib(s) */
+#define _lib_getdtablesize 1 /* getdtablesize() in default lib(s) */
+#define _lib_getdate 1 /* getdate() in default lib(s) */
+#define _lib_getgroups 1 /* getgroups() in default lib(s) */
+#define _lib_gethostname 1 /* gethostname() in default lib(s) */
+#define _lib_getlogin 1 /* getlogin() in default lib(s) */
+#define _lib_getpagesize 1 /* getpagesize() in default lib(s) */
+#define _lib_getrlimit 1 /* getrlimit() in default lib(s) */
+#define _lib_getopt 1 /* getopt() in default lib(s) */
+#define _lib_getsubopt 1 /* getsubopt() in default lib(s) */
+#define _lib_getopt_long 1 /* getopt_long() in default lib(s) */
+#define _lib_getopt_long_only 1 /* getopt_long_only() in default lib(s) */
+#define _lib_glob 1 /* glob() in default lib(s) */
+#define _lib_index 1 /* index() in default lib(s) */
+#define _lib_iswblank 1 /* iswblank() in default lib(s) */
+#define _lib_iswctype 1 /* iswctype() in default lib(s) */
+#define _lib_killpg 1 /* killpg() in default lib(s) */
+#define _lib_link 1 /* link() in default lib(s) */
+#define _lib_localeconv 1 /* localeconv() in default lib(s) */
+#define _lib_madvise 1 /* madvise() in default lib(s) */
+#define _lib_mbtowc 1 /* mbtowc() in default lib(s) */
+#define _lib_mbrtowc 1 /* mbrtowc() in default lib(s) */
+#define _lib_memalign 1 /* memalign() in default lib(s) */
+#define _lib_memchr 1 /* memchr() in default lib(s) */
+#define _lib_memcpy 1 /* memcpy() in default lib(s) */
+#define _lib_memmove 1 /* memmove() in default lib(s) */
+#define _lib_memset 1 /* memset() in default lib(s) */
+#define _lib_mkdir 1 /* mkdir() in default lib(s) */
+#define _lib_mkfifo 1 /* mkfifo() in default lib(s) */
+#define _lib_mktemp 1 /* mktemp() in default lib(s) */
+#define _lib_mktime 1 /* mktime() in default lib(s) */
+#define _lib_mount 1 /* mount() in default lib(s) */
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _lib_pathconf 1 /* pathconf() in default lib(s) */
+#define _lib_readlink 1 /* readlink() in default lib(s) */
+#define _lib_remove 1 /* remove() in default lib(s) */
+#define _lib_rename 1 /* rename() in default lib(s) */
+#define _lib_rewinddir 1 /* rewinddir() in default lib(s) */
+#define _lib_rindex 1 /* rindex() in default lib(s) */
+#define _lib_rmdir 1 /* rmdir() in default lib(s) */
+#define _lib_setlocale 1 /* setlocale() in default lib(s) */
+#define _lib_setpgid 1 /* setpgid() in default lib(s) */
+#define _lib_setpgrp 1 /* setpgrp() in default lib(s) */
+#define _lib_setreuid 1 /* setreuid() in default lib(s) */
+#define _lib_setsid 1 /* setsid() in default lib(s) */
+#define _lib_setuid 1 /* setuid() in default lib(s) */
+#define _lib_sigaction 1 /* sigaction() in default lib(s) */
+#define _lib_sigprocmask 1 /* sigprocmask() in default lib(s) */
+#define _lib_socketpair 1 /* socketpair() in default lib(s) */
+#define _lib_strchr 1 /* strchr() in default lib(s) */
+#define _lib_strcoll 1 /* strcoll() in default lib(s) */
+#define _lib_strdup 1 /* strdup() in default lib(s) */
+#define _lib_strerror 1 /* strerror() in default lib(s) */
+#define _lib_strcasecmp 1 /* strcasecmp() in default lib(s) */
+#define _lib_strncasecmp 1 /* strncasecmp() in default lib(s) */
+#define _lib_strrchr 1 /* strrchr() in default lib(s) */
+#define _lib_strstr 1 /* strstr() in default lib(s) */
+#define _lib_strxfrm 1 /* strxfrm() in default lib(s) */
+#define _lib_strftime 1 /* strftime() in default lib(s) */
+#define _lib_swab 1 /* swab() in default lib(s) */
+#define _lib_symlink 1 /* symlink() in default lib(s) */
+#define _lib_sysconf 1 /* sysconf() in default lib(s) */
+#define _lib_sysinfo 1 /* sysinfo() in default lib(s) */
+#define _lib_syslog 1 /* syslog() in default lib(s) */
+#define _lib_telldir 1 /* telldir() in default lib(s) */
+#define _lib_tmpnam 1 /* tmpnam() in default lib(s) */
+#define _lib_tzset 1 /* tzset() in default lib(s) */
+#define _lib_unlink 1 /* unlink() in default lib(s) */
+#define _lib_utime 1 /* utime() in default lib(s) */
+#define _lib_wctype 1 /* wctype() in default lib(s) */
+#define _lib_ftruncate 1 /* ftruncate() in default lib(s) */
+#define _lib_truncate 1 /* truncate() in default lib(s) */
+#define _lib_creat64 1 /* creat64() in default lib(s) */
+#define _lib_fstat64 1 /* fstat64() in default lib(s) */
+#define _lib_fstatvfs64 1 /* fstatvfs64() in default lib(s) */
+#define _lib_ftruncate64 1 /* ftruncate64() in default lib(s) */
+#define _lib_lseek64 1 /* lseek64() in default lib(s) */
+#define _lib_lstat64 1 /* lstat64() in default lib(s) */
+#define _lib_open64 1 /* open64() in default lib(s) */
+#define _lib_readdir64 1 /* readdir64() in default lib(s) */
+#define _lib_stat64 1 /* stat64() in default lib(s) */
+#define _lib_statvfs64 1 /* statvfs64() in default lib(s) */
+#define _lib_truncate64 1 /* truncate64() in default lib(s) */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _lib_strtod 1 /* strtod() in default lib(s) */
+#define _lib_strtold 1 /* strtold() in default lib(s) */
+#define _lib_strtol 1 /* strtol() in default lib(s) */
+#define _lib_strtoll 1 /* strtoll() in default lib(s) */
+#define _lib_strtoul 1 /* strtoul() in default lib(s) */
+#define _lib_strtoull 1 /* strtoull() in default lib(s) */
+#define _mem_d_ino_dirent 1 /* d_ino is a member of struct dirent */
+#define _mem_d_off_dirent 1 /* d_off is a member of struct dirent */
+#define _mem_d_reclen_dirent 1 /* d_reclen is a member of struct dirent */
+#define _mem_DIR 1 /* DIR is a non-opaque struct */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _sys_jioctl 1 /* #include <sys/jioctl.h> ok */
+#define _sys_localedef 1 /* #include <sys/localedef.h> ok */
+#define _sys_ptem 1 /* #include <sys/ptem.h> ok */
+#define _sys_resource 1 /* #include <sys/resource.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _sys_stream 1 /* #include <sys/stream.h> ok */
+#define _sys_systeminfo 1 /* #include <sys/systeminfo.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_off64_t 1 /* off64_t is a type */
+#define _typ_struct_dirent64 1 /* struct dirent64 is a type */
+#define _tst_errno 1 /* errno can be assigned */
+#define _lib_poll_fd_1 1 /* fd is first arg to poll() */
+#define _lib_poll 1 /* _lib_poll_fd_1||_lib_poll_fd_2 is true */
+#define _lib_select 1 /* select() has standard 5 arg interface */
+#define _pipe_rw 1 /* full duplex pipes */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _lib_vfork 1 /* vfork exists and it works */
+#define _real_vfork 1 /* vfork child shares data with parent */
+#define _lib_posix_spawn 1 /* posix_spawn exists and it works and its worth using */
+#define _stream_peek 1 /* ioctl(I_PEEK) works */
+#define _socket_peek 1 /* recv(MSG_PEEK) works */
+#define _hdr_string 1 /* #include <string.h> ok */
+#define _lib_memcmp 1 /* standard memcmp interface that works */
+#define _hdr_fcntl 1 /* #include <fcntl.h> ok */
+#define _hdr_signal 1 /* #include <signal.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_memccpy 1 /* standard memccpy interface that works */
+#define _lib_utime_now 1 /* utime works with 0 time vector */
+#define _UNIV_DEFAULT "att" /* default universe name */
+#define _std_cleanup 1 /* stuck with standard _cleanup */
+#define _std_strcoll 1 /* standard strcoll works */
+#if !_AST_no_spawnveg
+#define _use_spawnveg 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_limits.h b/usr/src/lib/libast/i386/include/ast/ast_limits.h
new file mode 100644
index 0000000000..a75dc78d31
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_limits.h
@@ -0,0 +1,128 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/limits.c by iffe version 2007-04-04 : : */
+#ifndef _def_limits_ast
+#define _def_limits_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+#ifndef CHAR_MAX
+#define CHAR_MAX 127
+#endif
+#ifndef CHAR_MIN
+#define CHAR_MIN -128
+#endif
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC 1000000
+#endif
+#ifndef INT_MIN
+#define INT_MIN -2147483648
+#endif
+#ifndef LLONG_MAX
+#define LLONG_MAX 9223372036854775807
+#endif
+#ifndef LLONG_MIN
+#define LLONG_MIN -9223372036854775808
+#endif
+#ifndef LONG_MAX
+#define LONG_MAX 2147483647
+#endif
+#ifndef LONG_MIN
+#define LONG_MIN -2147483648
+#endif
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 5
+#endif
+#ifndef OPEN_MAX_CEIL
+#ifndef OPEN_MAX
+#define OPEN_MAX 256
+#endif
+#define OPEN_MAX_CEIL OPEN_MAX
+#endif
+#ifndef PTHREAD_STACK_MIN
+#define PTHREAD_STACK_MIN 4096
+#endif
+#ifndef PTRDIFF_MAX
+#define PTRDIFF_MAX 2147483647
+#endif
+#ifndef PTRDIFF_MIN
+#define PTRDIFF_MIN -2147483648
+#endif
+#ifndef SCHAR_MAX
+#define SCHAR_MAX 127
+#endif
+#ifndef SCHAR_MIN
+#define SCHAR_MIN -128
+#endif
+#ifndef SHRT_MIN
+#define SHRT_MIN -32768
+#endif
+#ifndef SIG_ATOMIC_MAX
+#define SIG_ATOMIC_MAX 2147483647
+#endif
+#ifndef SIG_ATOMIC_MIN
+#define SIG_ATOMIC_MIN -2147483648
+#endif
+#ifndef SIZE_MAX
+#ifndef UINT_MAX
+#define UINT_MAX 4294967295
+#endif
+#define SIZE_MAX UINT_MAX
+#endif
+#ifndef SSIZE_MAX
+#ifndef INT_MAX
+#define INT_MAX 2147483647
+#endif
+#define SSIZE_MAX INT_MAX
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+#ifndef UCHAR_MAX
+#define UCHAR_MAX 255
+#endif
+#ifndef ULLONG_MAX
+#define ULLONG_MAX 18446744073709551615
+#endif
+#ifndef ULONG_MAX
+#define ULONG_MAX 4294967295
+#endif
+#ifndef USHRT_MAX
+#define USHRT_MAX 65535
+#endif
+#ifndef WCHAR_MAX
+#define WCHAR_MAX 2147483647
+#endif
+#ifndef WCHAR_MIN
+#define WCHAR_MIN -2147483648
+#endif
+#ifndef WINT_MAX
+#define WINT_MAX 2147483647
+#endif
+#ifndef WINT_MIN
+#define WINT_MIN -2147483648
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_map.h b/usr/src/lib/libast/i386/include/ast/ast_map.h
new file mode 100644
index 0000000000..ef22364fbb
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_map.h
@@ -0,0 +1,459 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/map.c by iffe version 2007-04-04 : : */
+#ifndef _def_map_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_map_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+/*
+ * prototypes provided for standard interfaces hijacked
+ * by ast and mapped to _ast_* but already prototyped
+ * unmapped in native headers included by <ast_std.h>
+ */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+
+#define _map_libc 1
+#undef basename
+#define basename _ast_basename
+#undef dirname
+#define dirname _ast_dirname
+#undef eaccess
+#define eaccess _ast_eaccess
+#undef execvpe
+#define execvpe _ast_execvpe
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+#undef fnmatch
+#define fnmatch _ast_fnmatch
+#undef fts_children
+#define fts_children _ast_fts_children
+#undef fts_close
+#define fts_close _ast_fts_close
+#undef fts_flags
+#define fts_flags _ast_fts_flags
+#undef fts_notify
+#define fts_notify _ast_fts_notify
+#undef fts_open
+#define fts_open _ast_fts_open
+#undef fts_read
+#define fts_read _ast_fts_read
+#undef fts_set
+#define fts_set _ast_fts_set
+#undef ftw
+#define ftw _ast_ftw
+#undef ftwalk
+#define ftwalk _ast_ftwalk
+#undef ftwflags
+#define ftwflags _ast_ftwflags
+#undef getcwd
+#define getcwd _ast_getcwd
+extern __MANGLE__ char* getcwd __PROTO__((char*, size_t));
+#undef getdate
+#define getdate _ast_getdate
+#undef getopt
+#define getopt _ast_getopt
+#undef getsubopt
+#define getsubopt _ast_getsubopt
+#undef getopt_long
+#define getopt_long _ast_getopt_long
+#undef getopt_long_only
+#define getopt_long_only _ast_getopt_long_only
+#undef getwd
+#define getwd _ast_getwd
+extern __MANGLE__ char* getwd __PROTO__((char*));
+#undef glob
+#define glob _ast_glob
+#undef globfree
+#define globfree _ast_globfree
+#undef memdup
+#define memdup _ast_memdup
+#undef memfatal
+#define memfatal _ast_memfatal
+#undef memhash
+#define memhash _ast_memhash
+#undef memsum
+#define memsum _ast_memsum
+#undef mkstemp
+#define mkstemp _ast_mkstemp
+extern __MANGLE__ int mkstemp __PROTO__((char*));
+#undef mktemp
+#define mktemp _ast_mktemp
+extern __MANGLE__ char* mktemp __PROTO__((char*));
+#undef mktime
+#define mktime _ast_mktime
+#undef nftw
+#define nftw _ast_nftw
+#undef optesc
+#define optesc _ast_optesc
+#undef optget
+#define optget _ast_optget
+#undef opthelp
+#define opthelp _ast_opthelp
+#undef optjoin
+#define optjoin _ast_optjoin
+#undef optstr
+#define optstr _ast_optstr
+#undef optusage
+#define optusage _ast_optusage
+#undef pathaccess
+#define pathaccess _ast_pathaccess
+#undef pathbin
+#define pathbin _ast_pathbin
+#undef pathcanon
+#define pathcanon _ast_pathcanon
+#undef pathcat
+#define pathcat _ast_pathcat
+#undef pathcd
+#define pathcd _ast_pathcd
+#undef pathcheck
+#define pathcheck _ast_pathcheck
+#undef pathexists
+#define pathexists _ast_pathexists
+#undef pathfind
+#define pathfind _ast_pathfind
+#undef pathgetlink
+#define pathgetlink _ast_pathgetlink
+#undef pathinclude
+#define pathinclude _ast_pathinclude
+#undef pathkey
+#define pathkey _ast_pathkey
+#undef pathnative
+#define pathnative _ast_pathnative
+#undef pathpath
+#define pathpath _ast_pathpath
+#undef pathposix
+#define pathposix _ast_pathposix
+#undef pathprobe
+#define pathprobe _ast_pathprobe
+#undef pathrepl
+#define pathrepl _ast_pathrepl
+#undef pathsetlink
+#define pathsetlink _ast_pathsetlink
+#undef pathshell
+#define pathshell _ast_pathshell
+#undef pathstat
+#define pathstat _ast_pathstat
+#undef pathtemp
+#define pathtemp _ast_pathtemp
+#undef pathtmp
+#define pathtmp _ast_pathtmp
+#undef procclose
+#define procclose _ast_procclose
+#undef procfree
+#define procfree _ast_procfree
+#undef procopen
+#define procopen _ast_procopen
+#undef procrun
+#define procrun _ast_procrun
+#undef putenv
+#define putenv _ast_putenv
+#undef re_comp
+#define re_comp _ast_re_comp
+#undef re_exec
+#define re_exec _ast_re_exec
+#undef realpath
+#define realpath _ast_realpath
+extern __MANGLE__ char* realpath __PROTO__((const char*, char*));
+#undef regaddclass
+#define regaddclass _ast_regaddclass
+#undef regalloc
+#define regalloc _ast_regalloc
+#undef regcache
+#define regcache _ast_regcache
+#undef regclass
+#define regclass _ast_regclass
+#undef regcmp
+#define regcmp _ast_regcmp
+#undef regcollate
+#define regcollate _ast_regcollate
+#undef regcomb
+#define regcomb _ast_regcomb
+#undef regcomp
+#define regcomp _ast_regcomp
+#undef regdecomp
+#define regdecomp _ast_regdecomp
+#undef regdup
+#define regdup _ast_regdup
+#undef regerror
+#define regerror _ast_regerror
+#undef regex
+#define regex _ast_regex
+#undef regexec
+#define regexec _ast_regexec
+#undef regfatal
+#define regfatal _ast_regfatal
+#undef regfatalpat
+#define regfatalpat _ast_regfatalpat
+#undef regfree
+#define regfree _ast_regfree
+#undef regncomp
+#define regncomp _ast_regncomp
+#undef regnexec
+#define regnexec _ast_regnexec
+#undef regrecord
+#define regrecord _ast_regrecord
+#undef regrexec
+#define regrexec _ast_regrexec
+#undef regstat
+#define regstat _ast_regstat
+#undef regsub
+#define regsub _ast_regsub
+#undef regsubcomp
+#define regsubcomp _ast_regsubcomp
+#undef regsubexec
+#define regsubexec _ast_regsubexec
+#undef regsubflags
+#define regsubflags _ast_regsubflags
+#undef regsubfree
+#define regsubfree _ast_regsubfree
+#undef remove
+#define remove _ast_remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#undef resolvepath
+#define resolvepath _ast_resolvepath
+extern __MANGLE__ char* resolvepath __PROTO__((const char*, char*, size_t));
+#undef setenv
+#define setenv _ast_setenv
+extern __MANGLE__ int setenv __PROTO__((const char*, const char*, int));
+#undef setenviron
+#define setenviron _ast_setenviron
+#undef sigcritical
+#define sigcritical _ast_sigcritical
+#undef signal
+#define signal _ast_signal
+#undef sigunblock
+#define sigunblock _ast_sigunblock
+#undef stracmp
+#define stracmp _ast_stracmp
+#undef strcopy
+#define strcopy _ast_strcopy
+#undef strelapsed
+#define strelapsed _ast_strelapsed
+#undef stresc
+#define stresc _ast_stresc
+#undef streval
+#define streval _ast_streval
+#undef strexpr
+#define strexpr _ast_strexpr
+#undef strftime
+#define strftime _ast_strftime
+#undef strgid
+#define strgid _ast_strgid
+#undef strgrpmatch
+#define strgrpmatch _ast_strgrpmatch
+#undef strhash
+#define strhash _ast_strhash
+#undef strkey
+#define strkey _ast_strkey
+#undef strlcat
+#define strlcat _ast_strlcat
+extern __MANGLE__ size_t strlcat __PROTO__((char*, const char*, size_t));
+#undef strlcpy
+#define strlcpy _ast_strlcpy
+extern __MANGLE__ size_t strlcpy __PROTO__((char*, const char*, size_t));
+#undef strlook
+#define strlook _ast_strlook
+#undef strmatch
+#define strmatch _ast_strmatch
+#undef strmode
+#define strmode _ast_strmode
+#undef strnacmp
+#define strnacmp _ast_strnacmp
+#undef strncopy
+#define strncopy _ast_strncopy
+#undef strntod
+#define strntod _ast_strntod
+#undef strntol
+#define strntol _ast_strntol
+#undef strntold
+#define strntold _ast_strntold
+#undef strntoll
+#define strntoll _ast_strntoll
+#undef strntoul
+#define strntoul _ast_strntoul
+#undef strntoull
+#define strntoull _ast_strntoull
+#undef stropt
+#define stropt _ast_stropt
+#undef strperm
+#define strperm _ast_strperm
+#undef strpsearch
+#define strpsearch _ast_strpsearch
+#undef strptime
+#define strptime _ast_strptime
+#undef strsearch
+#define strsearch _ast_strsearch
+#undef strsort
+#define strsort _ast_strsort
+#undef strsubmatch
+#define strsubmatch _ast_strsubmatch
+#undef strsum
+#define strsum _ast_strsum
+#undef strtape
+#define strtape _ast_strtape
+#undef strtoip4
+#define strtoip4 _ast_strtoip4
+#undef strton
+#define strton _ast_strton
+#undef strtonll
+#define strtonll _ast_strtonll
+#undef struid
+#define struid _ast_struid
+#undef struniq
+#define struniq _ast_struniq
+#undef system
+#define system _ast_system
+extern __MANGLE__ int system __PROTO__((const char*));
+#undef tempnam
+#define tempnam _ast_tempnam
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+#undef tmpnam
+#define tmpnam _ast_tmpnam
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+#undef touch
+#define touch _ast_touch
+#undef wordexp
+#define wordexp _ast_wordexp
+#undef wordfree
+#define wordfree _ast_wordfree
+#undef unsetenv
+#define unsetenv _ast_unsetenv
+
+/* cannot override local malloc */
+#define _map_malloc 1
+#undef calloc
+#define calloc _ast_calloc
+extern __MANGLE__ __V_* calloc __PROTO__((size_t, size_t));
+#undef cfree
+#define cfree _ast_cfree
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+#undef free
+#define free _ast_free
+extern __MANGLE__ void free __PROTO__((__V_*));
+#undef malloc
+#define malloc _ast_malloc
+extern __MANGLE__ __V_* malloc __PROTO__((size_t));
+#undef memalign
+#define memalign _ast_memalign
+extern __MANGLE__ __V_* memalign __PROTO__((size_t, size_t));
+#undef realloc
+#define realloc _ast_realloc
+extern __MANGLE__ __V_* realloc __PROTO__((__V_*, size_t));
+#undef strdup
+#define strdup _ast_strdup
+extern __MANGLE__ char* strdup __PROTO__((const char*));
+#undef valloc
+#define valloc _ast_valloc
+extern __MANGLE__ __V_* valloc __PROTO__((size_t));
+#undef strtol
+#define strtol _ast_strtol
+#undef strtoul
+#define strtoul _ast_strtoul
+#undef strtoll
+#define strtoll _ast_strtoll
+#undef strtoull
+#define strtoull _ast_strtoull
+#undef strtod
+#define strtod _ast_strtod
+#undef strtold
+#define strtold _ast_strtold
+extern __MANGLE__ long strtol __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned long strtoul __PROTO__((const char*, char**, int));
+extern __MANGLE__ double strtod __PROTO__((const char*, char**));
+#if !_UWIN
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
+extern __MANGLE__ _ast_fltmax_t strtold __PROTO__((const char*, char**));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+extern __MANGLE__ _ast_intmax_t strtoll __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned _ast_intmax_t strtoull __PROTO__((const char*, char**, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_mmap.h b/usr/src/lib/libast/i386/include/ast/ast_mmap.h
new file mode 100644
index 0000000000..0759029a5e
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_mmap.h
@@ -0,0 +1,47 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/mmap by iffe version 2007-04-04 : : */
+#ifndef _def_mmap_ast
+#define _def_mmap_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_mmap 1 /* standard mmap interface that works */
+#define _lib_mmap64 1 /* mmap64 interface and implementation work */
+#define _mmap_anon 1 /* use mmap MAP_ANON to get raw memory */
+#define _mmap_devzero 1 /* use mmap on /dev/zero to get raw memory */
+
+/* some systems get it wrong but escape concise detection */
+#ifndef _NO_MMAP
+#if __CYGWIN__
+#define _NO_MMAP 1
+#endif
+#endif
+
+#if _NO_MMAP
+#undef _lib_mmap
+#undef _lib_mmap64
+#undef _mmap_anon
+#undef _mmap_devzero
+#undef _mmap_worthy
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_mode.h b/usr/src/lib/libast/i386/include/ast/ast_mode.h
new file mode 100644
index 0000000000..6e666a5ff3
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_mode.h
@@ -0,0 +1,35 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/mode.c by iffe version 2007-04-04 : : */
+#ifndef _def_mode_ast
+#define _def_mode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define S_ITYPE(m) ((m)&S_IFMT)
+
+#define S_IPERM (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
+
+#define _S_IDPERM 1
+#define _S_IDTYPE 1
+
+#define BUFFERSIZE 8192
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_nl_types.h b/usr/src/lib/libast/i386/include/ast/ast_nl_types.h
new file mode 100644
index 0000000000..edaed7184d
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_nl_types.h
@@ -0,0 +1,123 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/nl_types by iffe version 2007-04-04 : : */
+
+#ifndef _def_nl_types_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_nl_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_nl_langinfo 1 /* nl_langinfo() in default lib(s) */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_langinfo 1 /* #include <langinfo.h> ok */
+#define _nxt_nl_types <../include/nl_types.h> /* include path for the native <nl_types.h> */
+#define _nxt_nl_types_str "../include/nl_types.h" /* include string for the native <nl_types.h> */
+#include <limits.h>
+#include <../include/nl_types.h> /* the native nl_types.h */
+
+#undef NL_SETMAX
+#define NL_SETMAX 1023
+#undef NL_MSGMAX
+#define NL_MSGMAX 32767
+#undef nl_catd
+#define nl_catd _ast_nl_catd
+#undef catopen
+#define catopen _ast_catopen
+#undef catgets
+#define catgets _ast_catgets
+#undef catclose
+#define catclose _ast_catclose
+
+typedef __V_* nl_catd;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ nl_catd catopen __PROTO__((const char*, int));
+extern __MANGLE__ char* catgets __PROTO__((nl_catd, int, int, const char*));
+extern __MANGLE__ int catclose __PROTO__((nl_catd));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_param.h b/usr/src/lib/libast/i386/include/ast/ast_param.h
new file mode 100644
index 0000000000..dd71ec8a02
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_param.h
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/param.sh by iffe version 2007-04-04 : : */
+#ifndef _def_param_ast
+#define _def_param_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#include <sys/param.h>
+#ifndef S_IFDIR
+#include <sys/stat.h>
+#endif
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_standards.h b/usr/src/lib/libast/i386/include/ast/ast_standards.h
new file mode 100644
index 0000000000..836beb8e9e
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_standards.h
@@ -0,0 +1,49 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/standards by iffe version 2007-04-04 : : */
+#ifndef _def_standards_ast
+#define _def_standards_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* _ALL_SOURCE & _ISOC99_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works */
+#ifndef _ALL_SOURCE
+#define _ALL_SOURCE 1
+#endif
+#ifndef _ISOC99_SOURCE
+#define _ISOC99_SOURCE 1
+#endif
+#ifndef _POSIX_SOURCE
+#define _POSIX_SOURCE 1
+#endif
+#ifndef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 21000101L
+#endif
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 9900
+#endif
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#ifndef __EXTENSIONS__
+#define __EXTENSIONS__ 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_std.h b/usr/src/lib/libast/i386/include/ast/ast_std.h
new file mode 100644
index 0000000000..68e7984670
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_std.h
@@ -0,0 +1,343 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Advanced Software Technology Library
+ * AT&T Research
+ *
+ * a union of standard headers that works
+ * with local extensions enabled
+ * and local omission compensation
+ */
+
+#ifndef _AST_STD_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_STD_H 1
+#define _AST_STD_I 1
+
+#include <ast_common.h>
+
+#if _BLD_ast
+#define _BLD_cdt 1
+#define _BLD_sfio 1
+#if !_UWIN
+#define _BLD_vmalloc 1
+#endif
+#endif
+
+#ifdef _SFSTDIO_H
+#define _SKIP_SFSTDIO_H
+#else
+#define _SFSTDIO_H
+#ifndef FILE
+#ifndef _SFIO_H
+struct _sfio_s;
+#endif
+#define FILE struct _sfio_s
+#ifndef __FILE_typedef
+#define __FILE_typedef 1
+#endif
+#ifndef _FILEDEFED
+#define _FILEDEFED 1
+#endif
+#endif
+#endif
+
+#include <ast_lib.h>
+#include <ast_sys.h>
+#include <ast_getopt.h> /* <stdlib.h> does this */
+#include <ast_fcntl.h>
+#include <ast_limits.h>
+#include <ast_botch.h>
+
+#ifdef _SKIP_SFSTDIO_H
+#undef _SKIP_SFSTDIO_H
+#else
+#undef _SFSTDIO_H
+#undef FILE
+#endif
+
+/* locale stuff */
+
+#if !_hdr_locale
+
+struct lconv
+{
+ char* decimal_point;
+ char* thousands_sep;
+ char* grouping;
+ char* int_curr_symbol;
+ char* currency_symbol;
+ char* mon_decimal_point;
+ char* mon_thousands_sep;
+ char* mon_grouping;
+ char* positive_sign;
+ char* negative_sign;
+ char int_frac_digits;
+ char frac_digits;
+ char p_cs_precedes;
+ char p_sep_by_space;
+ char n_cs_precedes;
+ char n_sep_by_space;
+ char p_sign_posn;
+ char n_sign_posn;
+};
+
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#undef localeconv
+#define localeconv _ast_localeconv
+
+#undef setlocale
+#define setlocale _ast_setlocale
+
+#undef strerror
+#define strerror _ast_strerror
+
+extern __MANGLE__ struct lconv* localeconv __PROTO__((void));
+extern __MANGLE__ char* setlocale __PROTO__((int, const char*));
+extern __MANGLE__ char* strerror __PROTO__((int));
+
+#define AST_MESSAGE_SET 3 /* see <mc.h> mcindex() */
+
+/*
+ * maintain this order when adding categories
+ */
+
+#define AST_LC_ALL 0
+#define AST_LC_COLLATE 1
+#define AST_LC_CTYPE 2
+#define AST_LC_MESSAGES 3
+#define AST_LC_MONETARY 4
+#define AST_LC_NUMERIC 5
+#define AST_LC_TIME 6
+#define AST_LC_IDENTIFICATION 7
+#define AST_LC_ADDRESS 8
+#define AST_LC_NAME 9
+#define AST_LC_TELEPHONE 10
+#define AST_LC_XLITERATE 11
+#define AST_LC_MEASUREMENT 12
+#define AST_LC_PAPER 13
+#define AST_LC_COUNT 14
+
+#define AST_LC_find (1L<<28)
+#define AST_LC_debug (1L<<29)
+#define AST_LC_setlocale (1L<<30)
+#define AST_LC_translate (1L<<31)
+
+#ifndef LC_ALL
+#define LC_ALL (-AST_LC_ALL)
+#endif
+#ifndef LC_COLLATE
+#define LC_COLLATE (-AST_LC_COLLATE)
+#endif
+#ifndef LC_CTYPE
+#define LC_CTYPE (-AST_LC_CTYPE)
+#endif
+#ifndef LC_MESSAGES
+#define LC_MESSAGES (-AST_LC_MESSAGES)
+#endif
+#ifndef LC_MONETARY
+#define LC_MONETARY (-AST_LC_MONETARY)
+#endif
+#ifndef LC_NUMERIC
+#define LC_NUMERIC (-AST_LC_NUMERIC)
+#endif
+#ifndef LC_TIME
+#define LC_TIME (-AST_LC_TIME)
+#endif
+#ifndef LC_ADDRESS
+#define LC_ADDRESS (-AST_LC_ADDRESS)
+#endif
+#ifndef LC_IDENTIFICATION
+#define LC_IDENTIFICATION (-AST_LC_IDENTIFICATION)
+#endif
+#ifndef LC_NAME
+#define LC_NAME (-AST_LC_NAME)
+#endif
+#ifndef LC_TELEPHONE
+#define LC_TELEPHONE (-AST_LC_TELEPHONE)
+#endif
+#ifndef LC_XLITERATE
+#define LC_XLITERATE (-AST_LC_XLITERATE)
+#endif
+#ifndef LC_MEASUREMENT
+#define LC_MEASUREMENT (-AST_LC_MEASUREMENT)
+#endif
+#ifndef LC_PAPER
+#define LC_PAPER (-AST_LC_PAPER)
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#undef strcoll
+#if _std_strcoll
+#define strcoll _ast_info.collate
+#else
+#define strcoll strcmp
+#endif
+
+typedef struct
+{
+
+ char* id;
+
+ struct
+ {
+ uint32_t serial;
+ uint32_t set;
+ } locale;
+
+ long tmp_long;
+ size_t tmp_size;
+ short tmp_short;
+ char tmp_char;
+ wchar_t tmp_wchar;
+
+ int (*collate) __PROTO__((const char*, const char*));
+
+ int tmp_int;
+ __V_* tmp_pointer;
+
+ int mb_cur_max;
+ int (*mb_len) __PROTO__((const char*, size_t));
+ int (*mb_towc) __PROTO__((wchar_t*, const char*, size_t));
+ size_t (*mb_xfrm) __PROTO__((char*, const char*, size_t));
+ int (*mb_width) __PROTO__((wchar_t));
+ int (*mb_conv) __PROTO__((char*, wchar_t));
+
+ uint32_t env_serial;
+
+ char pad[944];
+
+} _Ast_info_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ _Ast_info_t _ast_info;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+/* largefile hackery -- ast uses the large versions by default */
+
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if !defined(ftruncate) && _lib_ftruncate64
+#define ftruncate ftruncate64
+extern __MANGLE__ int ftruncate64 __PROTO__((int, off64_t));
+#endif
+#if !defined(lseek) && _lib_lseek64
+#define lseek lseek64
+extern __MANGLE__ off64_t lseek64 __PROTO__((int, off64_t, int));
+#endif
+#if !defined(truncate) && _lib_truncate64
+#define truncate truncate64
+extern __MANGLE__ int truncate64 __PROTO__((const char*, off64_t));
+#endif
+
+/* direct macro access for bsd crossover */
+
+#if !defined(__cplusplus)
+
+#if !defined(memcpy) && !defined(_lib_memcpy) && defined(_lib_bcopy)
+#define memcpy(t,f,n) (bcopy(f,t,n),(t))
+#endif
+
+#if !defined(memzero) && !defined(_lib_memzero)
+#if defined(_lib_memset) || !defined(_lib_bzero)
+#define memzero(b,n) memset(b,0,n)
+#else
+#define memzero(b,n) (bzero(b,n),(b))
+#endif
+#endif
+
+#endif
+
+#if !defined(remove)
+extern __MANGLE__ int remove __PROTO__((const char*));
+#endif
+
+#if !defined(rename)
+extern __MANGLE__ int rename __PROTO__((const char*, const char*));
+#endif
+
+#if !defined(strchr) && !defined(_lib_strchr) && defined(_lib_index)
+#define strchr(s,c) index(s,c)
+#endif
+
+#if !defined(strrchr) && !defined(_lib_strrchr) && defined(_lib_rindex)
+#define strrchr(s,c) rindex(s,c)
+#endif
+
+/* and now introducing prototypes botched by the standard(s) */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#undef getpgrp
+#define getpgrp() _ast_getpgrp()
+extern __MANGLE__ int _ast_getpgrp __PROTO__((void));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+/*
+ * and finally, standard interfaces hijacked by ast
+ * _ATS_STD_I delays headers that require <ast_map.h>
+ */
+
+#include <ast_map.h>
+
+#undef _AST_STD_I
+
+#if _REGEX_H < 0
+#undef _REGEX_H
+#include <regex.h>
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_stdio.h b/usr/src/lib/libast/i386/include/ast/ast_stdio.h
new file mode 100644
index 0000000000..a02241c624
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_stdio.h
@@ -0,0 +1,600 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/stdio by iffe version 2007-04-04 : : */
+
+#ifndef _SFSTDIO_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SFSTDIO_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define __FILE_typedef 1
+#define _FILE_DEFINED 1
+#define _FILE_defined 1
+#define _FILEDEFED 1
+
+#ifndef __FILE_TAG
+#define __FILE_TAG _sfio_s
+#endif
+
+#undef FILE
+#undef _FILE
+#undef fpos_t
+#undef fpos64_t
+
+typedef struct _sfio_s _sfio_FILE;
+
+#define FILE _sfio_FILE
+#define _FILE FILE
+
+#if !defined(__FILE) && !__CYGWIN__
+#undef __FILE
+#define __FILE FILE
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define BUFSIZ SF_BUFSIZE
+
+#else
+
+#ifndef BUFSIZ
+#define BUFSIZ 8192
+#endif
+
+#ifndef EOF
+#define EOF (-1)
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+#include <ast_std.h>
+
+#include <sfio_s.h>
+
+#if __cplusplus
+#define _sf_(f) (f)
+#else
+#define _sf_(f) ((struct _sfio_s*)(f))
+#endif
+
+#define _SF_EOF 0000200
+#define _SF_ERROR 0000400
+
+#endif
+
+#ifdef _NO_LARGEFILE64_SOURCE
+#undef _LARGEFILE64_SOURCE
+#endif
+
+#ifdef _LARGEFILE64_SOURCE
+#undef off_t
+#endif
+
+#define fpos_t _ast_fpos_t
+#if _typ_int64_t
+#define fpos64_t _ast_fpos_t
+#endif
+
+typedef struct _ast_fpos_s
+{
+ intmax_t _sf_offset;
+ unsigned char _sf_state[64 - sizeof(intmax_t)];
+} _ast_fpos_t;
+
+#define _base _data
+#define _ptr _next
+#define _IOFBF 0
+#define _IONBF 1
+#define _IOLBF 2
+
+#if defined(__cplusplus) && defined(__THROW) && !defined(_UWIN)
+
+#undef FILE
+#define FILE FILE
+typedef struct _sfio_s FILE;
+
+#undef strerror
+extern __MANGLE__ char* strerror(int) __THROW;
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#endif
+
+#ifndef FILENAME_MAX
+#define FILENAME_MAX 1024
+#endif
+#ifndef FOPEN_MAX
+#define FOPEN_MAX 60
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+
+#define _doprnt _ast_doprnt
+#define _doscan _ast_doscan
+#define asprintf _ast_asprintf
+#define clearerr _ast_clearerr
+#define fclose _ast_fclose
+#define fdopen _ast_fdopen
+#define fflush _ast_fflush
+#define fgetc _ast_fgetc
+#define fgetpos _ast_fgetpos
+#define fgetpos64 _ast_fgetpos64
+#define fgets _ast_fgets
+#define fopen _ast_fopen
+#define fprintf _ast_fprintf
+#define fpurge _ast_fpurge
+#define fputs _ast_fputs
+#define fread _ast_fread
+#define freopen _ast_freopen
+#define fscanf _ast_fscanf
+#define fseek _ast_fseek
+#define fseek64 _ast_fseek64
+#define fseeko _ast_fseeko
+#define fseeko64 _ast_fseeko64
+#define fsetpos _ast_fsetpos
+#define fsetpos64 _ast_fsetpos64
+#define ftell _ast_ftell
+#define ftell64 _ast_ftell64
+#define ftello _ast_ftello
+#define ftello64 _ast_ftello64
+#define fwrite _ast_fwrite
+#define gets _ast_gets
+#define getw _ast_getw
+#define pclose _ast_pclose
+#define popen _ast_popen
+#define printf _ast_printf
+#define puts _ast_puts
+#define putw _ast_putw
+#define rewind _ast_rewind
+#define scanf _ast_scanf
+#define setbuf _ast_setbuf
+#undef setbuffer
+#define setbuffer _ast_setbuffer
+#define setlinebuf _ast_setlinebuf
+#define setvbuf _ast_setvbuf
+#define snprintf _ast_snprintf
+#define sprintf _ast_sprintf
+#define sscanf _ast_sscanf
+#define tmpfile _ast_tmpfile
+#define ungetc _ast_ungetc
+#define vasprintf _ast_vasprintf
+#define vfprintf _ast_vfprintf
+#define vfscanf _ast_vfscanf
+#define vprintf _ast_vprintf
+#define vscanf _ast_vscanf
+#define vsnprintf _ast_vsnprintf
+#define vsprintf _ast_vsprintf
+#define vsscanf _ast_vsscanf
+#define fcloseall _ast_fcloseall
+#define fmemopen _ast_fmemopen
+#define __getdelim _ast___getdelim
+#define getdelim _ast_getdelim
+#define getline _ast_getline
+#define clearerr_unlocked _ast_clearerr_unlocked
+#define feof_unlocked _ast_feof_unlocked
+#define ferror_unlocked _ast_ferror_unlocked
+#define fflush_unlocked _ast_fflush_unlocked
+#define fgetc_unlocked _ast_fgetc_unlocked
+#define fgets_unlocked _ast_fgets_unlocked
+#define fileno_unlocked _ast_fileno_unlocked
+#define fputc_unlocked _ast_fputc_unlocked
+#define fputs_unlocked _ast_fputs_unlocked
+#define fread_unlocked _ast_fread_unlocked
+#define fwrite_unlocked _ast_fwrite_unlocked
+#define getc_unlocked _ast_getc_unlocked
+#define getchar_unlocked _ast_getchar_unlocked
+#define putc_unlocked _ast_putc_unlocked
+#define putchar_unlocked _ast_putchar_unlocked
+
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef P_tmpdir
+#define P_tmpdir "/var/tmp/" /*NOCATLITERAL*/
+#endif
+#ifndef L_ctermid
+#define L_ctermid 9
+#endif
+#ifndef L_tmpnam
+#define L_tmpnam 25
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#if defined(__cplusplus) && defined(__THROW)
+extern __MANGLE__ char* ctermid(char*) __THROW;
+#else
+extern __MANGLE__ char* ctermid __PROTO__((char*));
+#endif
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+extern __MANGLE__ void perror __PROTO__((const char*));
+#ifndef _AST_STD_H
+#ifndef remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#endif
+#ifndef rename
+extern __MANGLE__ int rename __PROTO__((const char*, const char*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#ifdef _LARGEFILE64_SOURCE
+
+#undef fpos_t
+#undef off_t
+#undef fgetpos
+#undef fsetpos
+#undef fseek
+#undef fseeko
+#undef ftell
+#undef ftello
+
+#define fpos_t fpos64_t
+#if _typ_off64_t
+#define off_t off64_t
+#else
+#define off_t int64_t
+#endif
+
+#define fgetpos fgetpos64
+#define fsetpos fsetpos64
+#define fseek fseek64
+#define fseeko fseeko64
+#define ftell ftell64
+#define ftello ftello64
+
+#endif
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_DLL && _DLL_INDIRECT_DATA
+
+#define stdin ((FILE*)_ast_dll->_ast_stdin)
+#define stdout ((FILE*)_ast_dll->_ast_stdout)
+#define stderr ((FILE*)_ast_dll->_ast_stderr)
+
+#else
+
+#define stdin (&_Sfstdin)
+#define stdout (&_Sfstdout)
+#define stderr (&_Sfstderr)
+
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define feof(f) sfeof(f)
+#define ferror(f) sferror(f)
+#define fileno(f) sffileno(f)
+#define fputc(c,f) sfputc(f,c)
+#define getc(f) sfgetc(f)
+#define getchar() sfgetc(sfstdin)
+#define putc(c,f) sfputc(f,c)
+#define putchar(c) sfputc(sfstdout,c)
+
+#else
+
+#if !_UWIN
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+#endif
+
+extern __MANGLE__ FILE _Sfstdin;
+extern __MANGLE__ FILE _Sfstdout;
+extern __MANGLE__ FILE _Sfstderr;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define feof(f) (_sf_(f)->_flags&_SF_EOF)
+#define ferror(f) (_sf_(f)->_flags&_SF_ERROR)
+#define fileno(f) (_sf_(f)->_file)
+#define fputc(c,f) (_sf_(f)->_next>=_sf_(f)->_endw?_sfflsbuf(_sf_(f),(int)((unsigned char)(c))):(int)(*_sf_(f)->_next++=(unsigned char)(c)))
+#define getc(f) (_sf_(f)->_next>=_sf_(f)->_endr?_sffilbuf(_sf_(f),0):(int)(*_sf_(f)->_next++))
+#define getchar() getc(stdin)
+#define putc(c,f) fputc(c,f)
+#define putchar(c) fputc(c,stdout)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _sffilbuf __PROTO__((FILE*, int));
+extern __MANGLE__ int _sfflsbuf __PROTO__((FILE*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_sys.h b/usr/src/lib/libast/i386/include/ast/ast_sys.h
new file mode 100644
index 0000000000..e9d4d677ef
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_sys.h
@@ -0,0 +1,172 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/sys by iffe version 2007-04-04 : : */
+
+#ifndef _AST_SYS_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_SYS_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#if __mips == 2 && !defined(_NO_LARGEFILE64_SOURCE)
+#define _NO_LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_NO_LARGEFILE64_SOURCE) && _typ_off64_t && _lib_lseek64 && _lib_stat64
+#if !defined(_LARGEFILE64_SOURCE)
+#define _LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_LARGEFILE_SOURCE)
+#define _LARGEFILE_SOURCE 1
+#endif
+#else
+#undef _LARGEFILE64_SOURCE
+#undef _LARGEFILE_SOURCE
+#undef _typ_off64_t
+#undef _typ_struct_dirent64
+#undef _lib_creat64
+#undef _lib_fstat64
+#undef _lib_fstatvfs64
+#undef _lib_ftruncate64
+#undef _lib_lseek64
+#undef _lib_lstat64
+#undef _lib_mmap64
+#undef _lib_open64
+#undef _lib_readdir64
+#undef _lib_stat64
+#undef _lib_statvfs64
+#undef _lib_truncate64
+#endif
+#if defined(__STDC__) && !defined(__USE_FIXED_PROTOTYPES__)
+#define __USE_FIXED_PROTOTYPES__ 1 /* kick gcc out of the past */
+#endif
+#include <stdlib.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <locale.h>
+#include <sys/localedef.h>
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _typ_dev_t 1 /* dev_t is a type */
+#define _typ_nlink_t 1 /* nlink_t is a type */
+#define _typ_gid_t 1 /* gid_t is a type */
+#define _typ_mode_t 1 /* mode_t is a type */
+#define _typ_uid_t 1 /* uid_t is a type */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _typ_wchar_t 1 /* wchar_t is a type */
+#define _typ_pid_t 1 /* pid_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _typ_wint_t 1 /* wint_t is a type */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _typ_socklen_t 1 /* socklen_t is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_ino_t 1 /* ino_t is a type */
+#define _typ_off_t 1 /* off_t is a type */
+#define _typ_ptrdiff_t 1 /* ptrdiff_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#define _typ_div_t 1 /* div_t is a type */
+#define _typ_ldiv_t 1 /* ldiv_t is a type */
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+extern __MANGLE__ int eaccess __PROTO__((const char*, int));
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+extern __MANGLE__ __V_* pvalloc __PROTO__((size_t));
+extern __MANGLE__ pid_t spawnveg __PROTO__((const char*, char* const[], char* const[], pid_t));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#if !defined(va_start)
+#if defined(__STDARG__)
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_time.h b/usr/src/lib/libast/i386/include/ast/ast_time.h
new file mode 100644
index 0000000000..173ffea355
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_time.h
@@ -0,0 +1,104 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/time by iffe version 2007-04-04 : : */
+
+#ifndef _def_time_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_time_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_nanosleep 1 /* nanosleep() in default lib(s) */
+#define _lib_usleep 1 /* usleep() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#include <sys/time.h>
+
+#include <sys/times.h>
+
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC CLK_TCK
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_tty.h b/usr/src/lib/libast/i386/include/ast/ast_tty.h
new file mode 100644
index 0000000000..aa7e5746a7
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_tty.h
@@ -0,0 +1,155 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/tty by iffe version 2007-04-04 : : */
+#ifndef _def_tty_ast
+#define _def_tty_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_termios 1 /* #include <termios.h> ok */
+#define _hdr_termio 1 /* #include <termio.h> ok */
+#define _hdr_sgtty 1 /* #include <sgtty.h> ok */
+#define _sys_termios 1 /* #include <sys/termios.h> ok */
+#define _sys_termio 1 /* #include <sys/termio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _lib_tcgetattr 1 /* tcgetattr() in default lib(s) */
+#define _lib_tcgetpgrp 1 /* tcgetpgrp() in default lib(s) */
+#define _mac__POSIX_VDISABLE 1 /* _POSIX_VDISABLE is a macro */
+
+#ifdef _hdr_termios
+# if _mac__POSIX_VDISABLE
+# undef _POSIX_VDISABLE
+# endif
+# include <termios.h>
+#else
+# if defined(_sys_termios) && defined(_lib_tcgetattr)
+# include <sys/termios.h>
+# define _hdr_termios 1
+# else
+# undef _sys_termios
+# endif /* _sys_termios */
+#endif /* _hdr_termios */
+
+#ifdef _hdr_termios
+# undef _hdr_sgtty
+# undef tcgetattr
+# undef tcsetattr
+# undef tcgetpgrp
+# undef tcsetpgrp
+# undef cfgetospeed
+# ifndef TCSANOW
+# define TCSANOW TCSETS
+# define TCSADRAIN TCSETSW
+# define TCSAFLUSH TCSETSF
+# endif /* TCSANOW */
+ /* The following corrects bugs in some implementations */
+# if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
+# define TCSAFLUSH TCSADFLUSH
+# endif /* TCSADFLUSH */
+# ifndef _lib_tcgetattr
+# undef tcgetattr
+# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
+# undef tcsetattr
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# undef cfgetospeed
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# endif /* _lib_tcgetattr */
+# undef TIOCGETC
+#else
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfgetispeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfsetispeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# define cfsetospeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# ifdef _hdr_termio
+# include <termio.h>
+# else
+# ifdef _sys_termio
+# include <sys/termio.h>
+# define _hdr_termio 1
+# endif /* _sys_termio */
+# endif /* _hdr_termio */
+# ifdef _hdr_termio
+# define termios termio
+# undef TIOCGETC
+# define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+
+# ifdef _sys_bsdtty
+# include <sys/bsdtty.h>
+# endif /* _sys_bsdtty */
+# else
+# ifdef _hdr_sgtty
+# include <sgtty.h>
+# ifndef LPENDIN
+# ifdef _sys_nttyio
+# include <sys/nttyio.h>
+# endif /* _sys_nttyio */
+# endif /* LPENDIN */
+# define termios sgttyb
+# ifdef TIOCSETN
+# undef TCSETAW
+# endif /* TIOCSETN */
+# ifdef TIOCGETP
+# define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# else
+# define tcgetattr(fd,tty) gtty(fd, tty)
+# define tcsetattr(fd,action,tty) stty(fd, tty)
+# endif /* TIOCGETP */
+# else
+# ifdef _sys_ttyio
+# include <sys/ttyio.h>
+# endif
+# endif /* _hdr_sgtty */
+# endif /* hdr_termio */
+
+# ifndef TCSANOW
+# ifdef TCSETAW
+# define TCSANOW TCSETA
+# define TCSAFLUSH TCSETAF
+# else
+# ifdef TIOCSETN
+# define TCSANOW TIOCSETN
+# define TCSADRAIN TIOCSETN
+# define TCSAFLUSH TIOCSETP
+# endif /* TIOCSETN */
+# endif /* TCSETAW */
+# endif /* TCSANOW */
+#endif /* _hdr_termios */
+
+/* set ECHOCTL if driver can echo control charaters as ^c */
+#ifdef LCTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LCTLECH
+# endif /* !ECHOCTL */
+#endif /* LCTLECH */
+#ifdef LNEW_CTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LNEW_CTLECH
+# endif /* !ECHOCTL */
+#endif /* LNEW_CTLECH */
+#ifdef LNEW_PENDIN
+# ifndef PENDIN
+# define PENDIN LNEW_PENDIN
+# endif /* !PENDIN */
+#endif /* LNEW_PENDIN */
+
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_types.h b/usr/src/lib/libast/i386/include/ast/ast_types.h
new file mode 100644
index 0000000000..6449f59df8
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_types.h
@@ -0,0 +1,26 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_types_ast
+#define _def_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_version.h b/usr/src/lib/libast/i386/include/ast/ast_version.h
new file mode 100644
index 0000000000..0e586f9555
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_version.h
@@ -0,0 +1,10 @@
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+#define _AST_VERSION 20061111L
diff --git a/usr/src/lib/libast/i386/include/ast/ast_vfork.h b/usr/src/lib/libast/i386/include/ast/ast_vfork.h
new file mode 100644
index 0000000000..7a0a8620be
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_vfork.h
@@ -0,0 +1,88 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/vfork by iffe version 2007-04-04 : : */
+
+#ifndef _def_vfork_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_vfork_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+extern __MANGLE__ pid_t vfork __PROTO__((void));
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_wait.h b/usr/src/lib/libast/i386/include/ast/ast_wait.h
new file mode 100644
index 0000000000..220157ea87
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_wait.h
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/wait by iffe version 2007-04-04 : : */
+#ifndef _def_wait_ast
+#define _def_wait_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_wait 1 /* wait() in default lib(s) */
+#define _lib_wait3 1 /* wait3() in default lib(s) */
+#define _lib_wait4 1 /* wait4() in default lib(s) */
+#define _lib_waitpid 1 /* waitpid() in default lib(s) */
+#define _sys_wait 1 /* #include <sys/wait.h> ok */
+#define _ok_wif 1 /* posix wait macros ok */
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_wchar.h b/usr/src/lib/libast/i386/include/ast/ast_wchar.h
new file mode 100644
index 0000000000..3a4322c182
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_wchar.h
@@ -0,0 +1,208 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/wchar by iffe version 2007-04-04 : : */
+
+#ifndef _def_wchar_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_wchar_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _lib_mbstowcs 1 /* mbstowcs() in default lib(s) */
+#define _lib_wctomb 1 /* wctomb() in default lib(s) */
+#define _lib_wcrtomb 1 /* wcrtomb() in default lib(s) */
+#define _lib_wcslen 1 /* wcslen() in default lib(s) */
+#define _lib_wcstombs 1 /* wcstombs() in default lib(s) */
+#define _lib_wcwidth 1 /* wcwidth() in default lib(s) */
+#define _lib_towlower 1 /* towlower() in default lib(s) */
+#define _lib_towupper 1 /* towupper() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_mbstate_t 1 /* mbstate_t is a type */
+#define _nxt_wchar <../include/wchar.h> /* include path for the native <wchar.h> */
+#define _nxt_wchar_str "../include/wchar.h" /* include string for the native <wchar.h> */
+#ifndef _SFSTDIO_H
+#include <ast_common.h>
+#include <stdio.h>
+#endif
+#if _hdr_wchar && defined(_nxt_wchar)
+#include <../include/wchar.h> /* the native wchar.h */
+#endif
+#if _hdr_wctype
+#include <wctype.h>
+#endif
+
+#ifndef WEOF
+#define WEOF (-1)
+#endif
+
+#undef fgetwc
+#undef fgetws
+#undef fputwc
+#undef fputws
+#undef getwc
+#undef getwchar
+#undef getws
+#undef putwc
+#undef putwchar
+#undef ungetwc
+
+#define fgetwc _ast_fgetwc
+#define fgetws _ast_fgetws
+#define fputwc _ast_fputwc
+#define fputws _ast_fputws
+#define fwide _ast_fwide
+#define fwprintf _ast_fwprintf
+#define fwscanf _ast_fwscanf
+#define getwc _ast_getwc
+#define getwchar _ast_getwchar
+#define getws _ast_getws
+#define putwc _ast_putwc
+#define putwchar _ast_putwchar
+#define swprintf _ast_swprintf
+#define swscanf _ast_swscanf
+#define ungetwc _ast_ungetwc
+#define vfwprintf _ast_vfwprintf
+#define vfwscanf _ast_vfwscanf
+#define vswprintf _ast_vswprintf
+#define vswscanf _ast_vswscanf
+#define vwprintf _ast_vwprintf
+#define vwscanf _ast_vwscanf
+#define wprintf _ast_wprintf
+#define wscanf _ast_wscanf
+
+#if !_typ_mbstate_t
+#undef _typ_mbstate_t
+#define _typ_mbstate_t 1
+typedef char mbstate_t;
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#if !_lib_mbstowcs
+extern __MANGLE__ size_t mbstowcs __PROTO__((wchar_t*, const char*, size_t));
+#endif
+#if !_lib_wctomb
+extern __MANGLE__ int wctomb __PROTO__((char*, wchar_t));
+#endif
+#if !_lib_wcrtomb
+extern __MANGLE__ size_t wcrtomb __PROTO__((char*, wchar_t, mbstate_t*));
+#endif
+#if !_lib_wcslen
+extern __MANGLE__ size_t wcslen __PROTO__((const wchar_t*));
+#endif
+#if !_lib_wcstombs
+extern __MANGLE__ size_t wcstombs __PROTO__((char*, const wchar_t*, size_t));
+#endif
+
+extern __MANGLE__ int fwprintf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ int fwscanf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ wint_t fgetwc __PROTO__((FILE*));
+extern __MANGLE__ wchar_t* fgetws __PROTO__((wchar_t*, int, FILE*));
+extern __MANGLE__ wint_t fputwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ int fputws __PROTO__((const wchar_t*, FILE*));
+extern __MANGLE__ int fwide __PROTO__((FILE*, int));
+extern __MANGLE__ wint_t getwc __PROTO__((FILE*));
+extern __MANGLE__ wint_t getwchar __PROTO__((void));
+extern __MANGLE__ wchar_t* getws __PROTO__((wchar_t*));
+extern __MANGLE__ wint_t putwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ wint_t putwchar __PROTO__((wchar_t));
+extern __MANGLE__ int swprintf __PROTO__((wchar_t*, size_t, const wchar_t*, ...));
+extern __MANGLE__ int swscanf __PROTO__((const wchar_t*, const wchar_t*, ...));
+extern __MANGLE__ wint_t ungetwc __PROTO__((wint_t, FILE*));
+extern __MANGLE__ int vfwprintf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vfwscanf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vwprintf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vwscanf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vswprintf __PROTO__((wchar_t*, size_t, const wchar_t*, va_list));
+extern __MANGLE__ int vswscanf __PROTO__((const wchar_t*, const wchar_t*, va_list));
+extern __MANGLE__ int wprintf __PROTO__((const wchar_t*, ...));
+extern __MANGLE__ int wscanf __PROTO__((const wchar_t*, ...));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ast_windows.h b/usr/src/lib/libast/i386/include/ast/ast_windows.h
new file mode 100644
index 0000000000..90e0260f59
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ast_windows.h
@@ -0,0 +1,48 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * AT&T Research
+ *
+ * ast <windows.h> wrapper
+ * for libast only
+ * include after ast headers
+ */
+
+#ifndef _AST_WINDOWS_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_WINDOWS_H 1
+
+#undef SF_ERROR /* clash in <oaidl.h> */
+
+#include <windows.h>
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/bytesex.h b/usr/src/lib/libast/i386/include/ast/bytesex.h
new file mode 100644
index 0000000000..2bf2022afb
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/bytesex.h
@@ -0,0 +1,43 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * linux/gnu compatibility
+ */
+
+#ifndef _BYTESEX_H
+#define _BYTESEX_H
+
+#include <ast_common.h>
+
+#undef __BYTE_ORDER
+
+#if ( _ast_intswap & 3 ) == 3
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#else
+#if ( _ast_intswap & 3 ) == 1
+#define __BYTE_ORDER __PDP_ENDIAN
+#else
+#define __BYTE_ORDER __BIG_ENDIAN
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ccode.h b/usr/src/lib/libast/i386/include/ast/ccode.h
new file mode 100644
index 0000000000..d26926ebc4
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ccode.h
@@ -0,0 +1,101 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * character code map interface
+ *
+ * NOTE: used for mapping between 8-bit character encodings
+ * ISO character sets are handled by sfio
+ */
+
+#ifndef _CHARCODE_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _CHARCODE_H 1
+
+#include <ast.h>
+#include <ast_ccode.h>
+
+typedef struct Ccmap_s
+{
+ const char* name; /* code set name */
+ const char* match; /* strmatch() pattern */
+ const char* desc; /* code set description */
+ const char* canon; /* canonical name format */
+ const char* index; /* default index */
+ int ccode; /* <ccode.h> code index */
+ __V_* data; /* map specific data */
+} Ccmap_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ unsigned char* _ccmap __PROTO__((int, int));
+extern __MANGLE__ __V_* _ccmapcpy __PROTO__((unsigned char*, __V_*, const __V_*, size_t));
+extern __MANGLE__ __V_* _ccmapstr __PROTO__((unsigned char*, __V_*, size_t));
+
+extern __MANGLE__ int ccmapid __PROTO__((const char*));
+extern __MANGLE__ char* ccmapname __PROTO__((int));
+extern __MANGLE__ __V_* ccnative __PROTO__((__V_*, const __V_*, size_t));
+extern __MANGLE__ Ccmap_t* ccmaplist __PROTO__((Ccmap_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define CCOP(i,o) ((i)==(o)?0:(((o)<<8)|(i)))
+#define CCIN(x) ((x)&0xFF)
+#define CCOUT(x) (((x)>>8)&0xFF)
+#define CCCONVERT(x) ((x)&0xFF00)
+
+#define CCCVT(x) CCMAP(x,0)
+#define CCMAP(i,o) ((i)==(o)?(unsigned char*)0:_ccmap(i,o))
+#define CCMAPCHR(m,c) ((m)?(m)[c]:(c))
+#define CCMAPCPY(m,t,f,n) ((m)?_ccmapcpy(m,t,f,n):memcpy(t,f,n))
+#define CCMAPSTR(m,s,n) ((m)?_ccmapstr(m,s,n):(__V_*)(s))
+
+#define ccmap(i,o) CCMAP(i,o)
+#define ccmapchr(m,c) CCMAPCHR(m,c)
+#define ccmapcpy(m,t,f,n) CCMAPCPY(m,t,f,n)
+#define ccmapstr(m,s,n) CCMAPSTR(m,s,n)
+
+#define CCMAPC(c,i,o) ((i)==(o)?(c):CCMAP(i,o)[c])
+#define CCMAPM(t,f,n,i,o) ((i)==(o)?memcpy(t,f,n):_ccmapcpy(CCMAP(i,o),t,f,n))
+#define CCMAPS(s,n,i,o) ((i)==(o)?(__V_*)(s):_ccmapstr(CCMAP(i,o),s,n))
+
+#define ccmapc(c,i,o) CCMAPC(c,i,o)
+#define ccmapm(t,f,n,i,o) CCMAPM(t,f,n,i,o)
+#define ccmaps(s,n,i,o) CCMAPS(s,n,i,o)
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/cdt.h b/usr/src/lib/libast/i386/include/ast/cdt.h
new file mode 100644
index 0000000000..f6274cef92
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/cdt.h
@@ -0,0 +1,311 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _CDT_H
+#define _CDT_H 1
+
+/* Public interface for the dictionary library
+**
+** Written by Kiem-Phong Vo
+*/
+
+#define CDT_VERSION 20050420L
+
+#if _PACKAGE_ast
+#include <ast_std.h>
+#else
+#include <ast_common.h>
+#endif
+
+typedef struct _dtlink_s Dtlink_t;
+typedef struct _dthold_s Dthold_t;
+typedef struct _dtdisc_s Dtdisc_t;
+typedef struct _dtmethod_s Dtmethod_t;
+typedef struct _dtdata_s Dtdata_t;
+typedef struct _dt_s Dt_t;
+typedef struct _dt_s Dict_t; /* for libdict compatibility */
+typedef struct _dtstat_s Dtstat_t;
+typedef Void_t* (*Dtsearch_f)_ARG_((Dt_t*,Void_t*,int));
+typedef Void_t* (*Dtmake_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*));
+typedef void (*Dtfree_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*));
+typedef int (*Dtcompar_f)_ARG_((Dt_t*,Void_t*,Void_t*,Dtdisc_t*));
+typedef unsigned int (*Dthash_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*));
+typedef Void_t* (*Dtmemory_f)_ARG_((Dt_t*,Void_t*,size_t,Dtdisc_t*));
+typedef int (*Dtevent_f)_ARG_((Dt_t*,int,Void_t*,Dtdisc_t*));
+
+struct _dtlink_s
+{ Dtlink_t* right; /* right child */
+ union
+ { unsigned int _hash; /* hash value */
+ Dtlink_t* _left; /* left child */
+ } hl;
+};
+
+/* private structure to hold an object */
+struct _dthold_s
+{ Dtlink_t hdr; /* header */
+ Void_t* obj; /* user object */
+};
+
+/* method to manipulate dictionary structure */
+struct _dtmethod_s
+{ Dtsearch_f searchf; /* search function */
+ int type; /* type of operation */
+};
+
+/* stuff that may be in shared memory */
+struct _dtdata_s
+{ int type; /* type of dictionary */
+ Dtlink_t* here; /* finger to last search element */
+ union
+ { Dtlink_t** _htab; /* hash table */
+ Dtlink_t* _head; /* linked list */
+ } hh;
+ int ntab; /* number of hash slots */
+ int size; /* number of objects */
+ int loop; /* number of nested loops */
+ int minp; /* min path before splay, always even */
+ /* for hash dt, > 0: fixed table size */
+};
+
+/* structure to hold methods that manipulate an object */
+struct _dtdisc_s
+{ int key; /* where the key begins in an object */
+ int size; /* key size and type */
+ int link; /* offset to Dtlink_t field */
+ Dtmake_f makef; /* object constructor */
+ Dtfree_f freef; /* object destructor */
+ Dtcompar_f comparf;/* to compare two objects */
+ Dthash_f hashf; /* to compute hash value of an object */
+ Dtmemory_f memoryf;/* to allocate/free memory */
+ Dtevent_f eventf; /* to process events */
+};
+
+#define DTDISC(dc,ky,sz,lk,mkf,frf,cmpf,hshf,memf,evf) \
+ ( (dc)->key = (ky), (dc)->size = (sz), (dc)->link = (lk), \
+ (dc)->makef = (mkf), (dc)->freef = (frf), \
+ (dc)->comparf = (cmpf), (dc)->hashf = (hshf), \
+ (dc)->memoryf = (memf), (dc)->eventf = (evf) )
+
+#ifdef offsetof
+#define DTOFFSET(struct_s, member) offsetof(struct_s, member)
+#else
+#define DTOFFSET(struct_s, member) ((int)(&((struct_s*)0)->member))
+#endif
+
+/* the dictionary structure itself */
+struct _dt_s
+{ Dtsearch_f searchf;/* search function */
+ Dtdisc_t* disc; /* method to manipulate objs */
+ Dtdata_t* data; /* sharable data */
+ Dtmemory_f memoryf;/* function to alloc/free memory */
+ Dtmethod_t* meth; /* dictionary method */
+ int type; /* type information */
+ int nview; /* number of parent view dictionaries */
+ Dt_t* view; /* next on viewpath */
+ Dt_t* walk; /* dictionary being walked */
+ Void_t* user; /* for user's usage */
+};
+
+/* structure to get status of a dictionary */
+struct _dtstat_s
+{ int dt_meth; /* method type */
+ int dt_size; /* number of elements */
+ int dt_n; /* number of chains or levels */
+ int dt_max; /* max size of a chain or a level */
+ int* dt_count; /* counts of chains or levels by size */
+};
+
+/* flag set if the last search operation actually found the object */
+#define DT_FOUND 0100000
+
+/* supported storage methods */
+#define DT_SET 0000001 /* set with unique elements */
+#define DT_BAG 0000002 /* multiset */
+#define DT_OSET 0000004 /* ordered set (self-adjusting tree) */
+#define DT_OBAG 0000010 /* ordered multiset */
+#define DT_LIST 0000020 /* linked list */
+#define DT_STACK 0000040 /* stack */
+#define DT_QUEUE 0000100 /* queue */
+#define DT_METHODS 0000177 /* all currently supported methods */
+
+/* asserts to dtdisc() */
+#define DT_SAMECMP 0000001 /* compare methods equivalent */
+#define DT_SAMEHASH 0000002 /* hash methods equivalent */
+
+/* types of search */
+#define DT_INSERT 0000001 /* insert object if not found */
+#define DT_DELETE 0000002 /* delete object if found */
+#define DT_SEARCH 0000004 /* look for an object */
+#define DT_NEXT 0000010 /* look for next element */
+#define DT_PREV 0000020 /* find previous element */
+#define DT_RENEW 0000040 /* renewing an object */
+#define DT_CLEAR 0000100 /* clearing all objects */
+#define DT_FIRST 0000200 /* get first object */
+#define DT_LAST 0000400 /* get last object */
+#define DT_MATCH 0001000 /* find object matching key */
+#define DT_VSEARCH 0002000 /* search using internal representation */
+#define DT_ATTACH 0004000 /* attach an object to the dictionary */
+#define DT_DETACH 0010000 /* detach an object from the dictionary */
+
+/* events */
+#define DT_OPEN 1 /* a dictionary is being opened */
+#define DT_CLOSE 2 /* a dictionary is being closed */
+#define DT_DISC 3 /* discipline is about to be changed */
+#define DT_METH 4 /* method is about to be changed */
+#define DT_ENDOPEN 5 /* dtopen() is done */
+#define DT_ENDCLOSE 6 /* dtclose() is done */
+#define DT_HASHSIZE 7 /* setting hash table size */
+
+_BEGIN_EXTERNS_ /* public data */
+#if _BLD_cdt && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+#if !_BLD_cdt && defined(__IMPORT__)
+#define extern __IMPORT__
+#endif
+
+extern Dtmethod_t* Dtset;
+extern Dtmethod_t* Dtbag;
+extern Dtmethod_t* Dtoset;
+extern Dtmethod_t* Dtobag;
+extern Dtmethod_t* Dtlist;
+extern Dtmethod_t* Dtstack;
+extern Dtmethod_t* Dtqueue;
+
+/* compatibility stuff; will go away */
+#ifndef KPVDEL
+extern Dtmethod_t* Dtorder;
+extern Dtmethod_t* Dttree;
+extern Dtmethod_t* Dthash;
+extern Dtmethod_t _Dttree;
+extern Dtmethod_t _Dthash;
+extern Dtmethod_t _Dtlist;
+extern Dtmethod_t _Dtqueue;
+extern Dtmethod_t _Dtstack;
+#endif
+
+#undef extern
+_END_EXTERNS_
+
+_BEGIN_EXTERNS_ /* public functions */
+#if _BLD_cdt && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Dt_t* dtopen _ARG_((Dtdisc_t*, Dtmethod_t*));
+extern int dtclose _ARG_((Dt_t*));
+extern Dt_t* dtview _ARG_((Dt_t*, Dt_t*));
+extern Dtdisc_t* dtdisc _ARG_((Dt_t* dt, Dtdisc_t*, int));
+extern Dtmethod_t* dtmethod _ARG_((Dt_t*, Dtmethod_t*));
+
+extern Dtlink_t* dtflatten _ARG_((Dt_t*));
+extern Dtlink_t* dtextract _ARG_((Dt_t*));
+extern int dtrestore _ARG_((Dt_t*, Dtlink_t*));
+
+extern int dttreeset _ARG_((Dt_t*, int, int));
+
+extern int dtwalk _ARG_((Dt_t*, int(*)(Dt_t*,Void_t*,Void_t*), Void_t*));
+
+extern Void_t* dtrenew _ARG_((Dt_t*, Void_t*));
+
+extern int dtsize _ARG_((Dt_t*));
+extern int dtstat _ARG_((Dt_t*, Dtstat_t*, int));
+extern unsigned int dtstrhash _ARG_((unsigned int, Void_t*, int));
+
+#if !_PACKAGE_ast
+extern int memcmp _ARG_((const Void_t*, const Void_t*, size_t));
+extern int strcmp _ARG_((const char*, const char*));
+#endif
+
+#undef extern
+_END_EXTERNS_
+
+/* internal functions for translating among holder, object and key */
+#define _DT(dt) ((Dt_t*)(dt))
+#define _DTDSC(dc,ky,sz,lk,cmpf) \
+ (ky = (dc)->key, sz = (dc)->size, lk = (dc)->link, cmpf = (dc)->comparf)
+#define _DTLNK(o,lk) ((Dtlink_t*)((char*)(o) + lk) )
+#define _DTOBJ(e,lk) ((lk) < 0 ? ((Dthold_t*)(e))->obj : (Void_t*)((char*)(e) - (lk)) )
+#define _DTKEY(o,ky,sz) (Void_t*)((sz) < 0 ? *((char**)((char*)(o)+(ky))) : ((char*)(o)+(ky)))
+
+#define _DTCMP(dt,k1,k2,dc,cmpf,sz) \
+ ((cmpf) ? (*cmpf)(dt,k1,k2,dc) : \
+ ((sz) <= 0 ? strcmp(k1,k2) : memcmp(k1,k2,sz)) )
+#define _DTHSH(dt,ky,dc,sz) ((dc)->hashf ? (*(dc)->hashf)(dt,ky,dc) : dtstrhash(0,ky,sz) )
+
+/* special search function for tree structure only */
+#define _DTMTCH(dt,key,action) \
+ do { Dtlink_t* _e; Void_t *_o, *_k, *_key; Dtdisc_t* _dc; \
+ int _ky, _sz, _lk, _cmp; Dtcompar_f _cmpf; \
+ _dc = (dt)->disc; _DTDSC(_dc, _ky, _sz, _lk, _cmpf); \
+ _key = (key); \
+ for(_e = (dt)->data->here; _e; _e = _cmp < 0 ? _e->hl._left : _e->right) \
+ { _o = _DTOBJ(_e, _lk); _k = _DTKEY(_o, _ky, _sz); \
+ if((_cmp = _DTCMP((dt), _key, _k, _dc, _cmpf, _sz)) == 0) \
+ break; \
+ } \
+ action (_e ? _o : (Void_t*)0); \
+ } while(0)
+
+#define _DTSRCH(dt,obj,action) \
+ do { Dtlink_t* _e; Void_t *_o, *_k, *_key; Dtdisc_t* _dc; \
+ int _ky, _sz, _lk, _cmp; Dtcompar_f _cmpf; \
+ _dc = (dt)->disc; _DTDSC(_dc, _ky, _sz, _lk, _cmpf); \
+ _key = _DTKEY(obj, _ky, _sz); \
+ for(_e = (dt)->data->here; _e; _e = _cmp < 0 ? _e->hl._left : _e->right) \
+ { _o = _DTOBJ(_e, _lk); _k = _DTKEY(_o, _ky, _sz); \
+ if((_cmp = _DTCMP((dt), _key, _k, _dc, _cmpf, _sz)) == 0) \
+ break; \
+ } \
+ action (_e ? _o : (Void_t*)0); \
+ } while(0)
+
+#define DTTREEMATCH(dt,key,action) _DTMTCH(_DT(dt),(Void_t*)(key),action)
+#define DTTREESEARCH(dt,obj,action) _DTSRCH(_DT(dt),(Void_t*)(obj),action)
+
+#define dtvnext(d) (_DT(d)->view)
+#define dtvcount(d) (_DT(d)->nview)
+#define dtvhere(d) (_DT(d)->walk)
+
+#define dtlink(d,e) (((Dtlink_t*)(e))->right)
+#define dtobj(d,e) _DTOBJ((e), _DT(d)->disc->link)
+#define dtfinger(d) (_DT(d)->data->here ? dtobj((d),_DT(d)->data->here):(Void_t*)(0))
+
+#define dtfirst(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_FIRST)
+#define dtnext(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_NEXT)
+#define dtleast(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH|DT_NEXT)
+#define dtlast(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_LAST)
+#define dtprev(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_PREV)
+#define dtmost(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH|DT_PREV)
+#define dtsearch(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH)
+#define dtmatch(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_MATCH)
+#define dtinsert(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_INSERT)
+#define dtdelete(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_DELETE)
+#define dtattach(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_ATTACH)
+#define dtdetach(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_DETACH)
+#define dtclear(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_CLEAR)
+#define dtfound(d) (_DT(d)->type & DT_FOUND)
+
+#define DT_PRIME 17109811 /* 2#00000001 00000101 00010011 00110011 */
+#define dtcharhash(h,c) (((unsigned int)(h) + (unsigned int)(c)) * DT_PRIME )
+
+#endif /* _CDT_H */
diff --git a/usr/src/lib/libast/i386/include/ast/debug.h b/usr/src/lib/libast/i386/include/ast/debug.h
new file mode 100644
index 0000000000..ad7ecb7a54
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/debug.h
@@ -0,0 +1,63 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * common ast debug definitions
+ * include after the ast headers
+ */
+
+#ifndef _DEBUG_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _DEBUG_H
+
+#include <ast.h>
+#include <error.h>
+
+#if DEBUG || _BLD_DEBUG
+#define debug(x) x
+#define message(x) do if (error_info.trace < 0) { error x; } while (0)
+#define messagef(x) do if (error_info.trace < 0) { errorf x; } while (0)
+#else
+#define debug(x)
+#define message(x)
+#define messagef(x)
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ void systrace __PROTO__((const char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/dirent.h b/usr/src/lib/libast/i386/include/ast/dirent.h
new file mode 100644
index 0000000000..32f33800b5
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/dirent.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_dirent.h>
diff --git a/usr/src/lib/libast/i386/include/ast/dt.h b/usr/src/lib/libast/i386/include/ast/dt.h
new file mode 100644
index 0000000000..0b7c331577
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/dt.h
@@ -0,0 +1,49 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+#ifndef _DT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _DT_H 1
+
+#include <cdt.h>
+#include <vmalloc.h>
+
+#if _BLD_cdt && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Dt_t* dtnew __PROTO__((Vmalloc_t*, Dtdisc_t*, Dtmethod_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/endian.h b/usr/src/lib/libast/i386/include/ast/endian.h
new file mode 100644
index 0000000000..2299b5a3bc
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/endian.h
@@ -0,0 +1,54 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * linux/gnu compatibility
+ */
+
+#ifndef _ENDIAN_H
+#define _ENDIAN_H
+
+#include <bytesex.h>
+
+#define __LITTLE_ENDIAN 1234
+#define __BIG_ENDIAN 4321
+#define __PDP_ENDIAN 3412
+
+#if defined (__USE_BSD) && !defined(__STRICT_ANSI__)
+
+#ifndef LITTLE_ENDIAN
+#define LITTLE_ENDIAN __LITTLE_ENDIAN
+#endif
+
+#ifndef BIG_ENDIAN
+#define BIG_ENDIAN __BIG_ENDIAN
+#endif
+
+#ifndef PDP_ENDIAN
+#define PDP_ENDIAN __PDP_ENDIAN
+#endif
+
+#undef BYTE_ORDER
+#define BYTE_ORDER __BYTE_ORDER
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/error.h b/usr/src/lib/libast/i386/include/ast/error.h
new file mode 100644
index 0000000000..d6d171a15e
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/error.h
@@ -0,0 +1,196 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * option, error and message formatter external definitions
+ */
+
+#ifndef _ERROR_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _ERROR_H
+
+#include <ast.h>
+#include <option.h>
+#include <errno.h>
+
+#define ERROR_VERSION 20070319L
+
+#if !defined(errno) && defined(__DYNAMIC__)
+#define errno __DYNAMIC__(errno)
+#endif
+
+#define ERROR_debug(n) (-(n))
+#define ERROR_exit(n) ((n)+ERROR_ERROR)
+#define ERROR_system(n) (((n)+ERROR_ERROR)|ERROR_SYSTEM)
+#define ERROR_usage(n) ((((n)?2:0)+ERROR_ERROR)|ERROR_USAGE)
+#define ERROR_warn(n) (ERROR_WARNING)
+
+#ifndef ERROR_catalog
+#define ERROR_catalog(t) t
+#endif
+#ifndef ERROR_dictionary
+#define ERROR_dictionary(t) t
+#endif
+
+#ifndef ERROR_translate
+#define ERROR_translating() (error_info.translate&&(ast.locale.set&(1<<AST_LC_MESSAGES)))
+#define ERROR_translate(l,i,d,m) (ERROR_translating()?errorx((const char*)l,(const char*)i,(const char*)d,(const char*)m):(m))
+#endif
+
+#define ERROR_INFO 0 /* info message -- no err_id */
+#define ERROR_WARNING 1 /* warning message */
+#define ERROR_ERROR 2 /* error message -- no err_exit */
+#define ERROR_FATAL 3 /* error message with err_exit */
+#define ERROR_NOEXEC EXIT_NOEXEC /* shell convention */
+#define ERROR_NOENT EXIT_NOTFOUND /* shell convention */
+#define ERROR_PANIC ERROR_LEVEL /* panic message with err_exit */
+
+#define ERROR_LEVEL 0x00ff /* level portion of status */
+#define ERROR_SYSTEM 0x0100 /* report system errno message */
+#define ERROR_OUTPUT 0x0200 /* next arg is error fd */
+#define ERROR_SOURCE 0x0400 /* next 2 args are FILE,LINE */
+#define ERROR_USAGE 0x0800 /* usage message */
+#define ERROR_PROMPT 0x1000 /* omit trailing newline */
+#define ERROR_NOID 0x2000 /* omit err_id */
+#define ERROR_LIBRARY 0x4000 /* library routine error */
+
+#define ERROR_INTERACTIVE 0x0001 /* context is interactive */
+#define ERROR_SILENT 0x0002 /* context is silent */
+#define ERROR_NOTIFY 0x0004 /* main(-sig,0,ctx) on signal */
+
+#define ERROR_FREE 0x0010 /* free context on pop */
+#define ERROR_POP 0x0020 /* pop context */
+#define ERROR_PUSH 0x0040 /* push context */
+#define ERROR_SET 0x0080 /* set context */
+
+/*
+ * errorpush()/errorpop() are obsolete -- use errorctx() instead
+ */
+
+#ifndef ERROR_CONTEXT_T
+#define ERROR_CONTEXT_T Error_info_t
+#endif
+
+#define ERROR_CONTEXT_BASE ((Error_context_t*)&error_info.context)
+
+#define errorpush(p,f) (*(p)= *ERROR_CONTEXT_BASE,*ERROR_CONTEXT_BASE=error_info.empty,error_info.context=(Error_context_t*)(p),error_info.flags=(f))
+#define errorpop(p) (*ERROR_CONTEXT_BASE= *(p))
+
+typedef struct Error_info_s Error_info_t;
+typedef struct Error_context_s Error_context_t;
+
+#define ERROR_CONTEXT \
+ ERROR_CONTEXT_T* context; /* prev context stack element */ \
+ int errors; /* >= ERROR_ERROR count */ \
+ int flags; /* context flags */ \
+ int line; /* input|output line number */ \
+ int warnings; /* ERROR_WARNING count */ \
+ char* file; /* input|output file name */ \
+ char* id; /* command id */
+
+struct Error_context_s /* context stack element */
+{
+ ERROR_CONTEXT
+};
+
+struct Error_info_s /* error state */
+{
+ int fd; /* write(2) fd */
+
+ void (*exit) __PROTO__((int)); /* error exit */
+ ssize_t (*write) __PROTO__((int, const __V_*, size_t)); /* error output */
+
+ /* the rest are implicitly initialized */
+
+ int clear; /* default clear ERROR_* flags */
+ int core; /* level>=core -> core dump */
+ int indent; /* debug trace indent level */
+ int init; /* initialized */
+ int last_errno; /* last reported errno */
+ int mask; /* multi level debug trace mask */
+ int set; /* default set ERROR_* flags */
+ int trace; /* debug trace level */
+
+ char* version; /* ERROR_SOURCE command version */
+
+ int (*auxilliary) __PROTO__((Sfio_t*, int, int)); /* aux info to append */
+
+ ERROR_CONTEXT /* top of context stack */
+
+ Error_context_t empty; /* empty context stack element */
+
+ unsigned long time; /* debug time trace */
+
+ char* (*translate) __PROTO__((const char*, const char*, const char*, const char*)); /* format translator */
+
+ const char* catalog; /* message catalog */
+};
+
+#ifndef errno
+extern __MANGLE__ int errno; /* system call error status */
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Error_info_t* _error_infop_;
+
+#define error_info (*_error_infop_)
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ void error __PROTO__((int, ...));
+extern __MANGLE__ int errormsg __PROTO__((const char*, int, ...));
+extern __MANGLE__ int errorf __PROTO__((__V_*, __V_*, int, ...));
+extern __MANGLE__ void errorv __PROTO__((const char*, int, va_list));
+#ifndef errorx
+extern __MANGLE__ char* errorx __PROTO__((const char*, const char*, const char*, const char*));
+#endif
+extern __MANGLE__ Error_info_t* errorctx __PROTO__((Error_info_t*, int, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/find.h b/usr/src/lib/libast/i386/include/ast/find.h
new file mode 100644
index 0000000000..0caf2019cf
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/find.h
@@ -0,0 +1,97 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * fast find interface definitions
+ */
+
+#ifndef _FIND_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FIND_H
+
+#define FIND_VERSION 19980301L
+
+#ifndef FIND_CODES
+#define FIND_CODES "lib/find/codes"
+#endif
+
+#define FIND_CODES_ENV "FINDCODES"
+
+#define FIND_GENERATE (1<<0) /* generate new codes */
+#define FIND_ICASE (1<<1) /* ignore case in match */
+#define FIND_GNU (1<<2) /* generate gnu format codes */
+#define FIND_OLD (1<<3) /* generate old format codes */
+#define FIND_TYPE (1<<4) /* generate type with codes */
+#define FIND_VERIFY (1<<5) /* verify the dir hierarchy */
+
+#define FIND_USER (1L<<16) /* first user flag bit */
+
+struct Find_s;
+struct Finddisc_s;
+
+typedef int (*Findverify_f) __PROTO__((struct Find_s*, const char*, size_t, struct Finddisc_s*));
+
+typedef struct Finddisc_s
+{
+ unsigned long version; /* interface version */
+ unsigned long flags; /* FIND_* flags */
+ Error_f errorf; /* error function */
+ Findverify_f verifyf; /* dir verify function */
+ char** dirs; /* dir prefixes to search */
+} Finddisc_t;
+
+typedef struct Find_s
+{
+ const char* id; /* library id string */
+ unsigned long stamp; /* codes time stamp */
+
+#ifdef _FIND_PRIVATE_
+ _FIND_PRIVATE_
+#endif
+
+} Find_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Find_t* findopen __PROTO__((const char*, const char*, const char*, Finddisc_t*));
+extern __MANGLE__ char* findread __PROTO__((Find_t*));
+extern __MANGLE__ int findwrite __PROTO__((Find_t*, const char*, size_t, const char*));
+extern __MANGLE__ int findclose __PROTO__((Find_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/fnmatch.h b/usr/src/lib/libast/i386/include/ast/fnmatch.h
new file mode 100644
index 0000000000..83e2dd9943
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/fnmatch.h
@@ -0,0 +1,71 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * posix fnmatch interface definitions
+ */
+
+#ifndef _FNMATCH_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FNMATCH_H
+
+#include <ast_common.h>
+
+/* fnmatch flags */
+
+#define FNM_NOESCAPE 0x0001 /* \ is literal */
+#define FNM_PATHNAME 0x0002 /* explicit match for / */
+#define FNM_PERIOD 0x0004 /* explicit match for leading . */
+#define FNM_NOSYS 0x0010 /* not implemented */
+
+/* nonstandard fnmatch() flags */
+
+#define FNM_AUGMENTED 0x0008 /* enable ! & ( | ) */
+#define FNM_ICASE 0x0020 /* ignore case in match */
+#define FNM_LEADING_DIR 0x0040 /* match up to implicit / */
+
+#define FNM_CASEFOLD FNM_ICASE /* gnu compatibility */
+#define FNM_FILE_NAME FNM_PATHNAME /* gnu compatibility */
+
+/* fnmatch error codes -- other non-zero values from <regex.h> */
+
+#define FNM_NOMATCH 1 /* == REG_NOMATCH */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int fnmatch __PROTO__((const char*, const char*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/fnv.h b/usr/src/lib/libast/i386/include/ast/fnv.h
new file mode 100644
index 0000000000..6af5c1489c
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/fnv.h
@@ -0,0 +1,81 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * Landon Kurt Knoll
+ * Phong Vo
+ *
+ * FNV-1 linear congruent checksum/hash/PRNG
+ * see http://www.isthe.com/chongo/tech/comp/fnv/
+ */
+
+#ifndef _FNV_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FNV_H
+
+#include <ast_common.h>
+
+#define FNV_INIT 0x811c9dc5L
+#define FNV_MULT 0x01000193L
+
+#define FNVINIT(h) (h = FNV_INIT)
+#define FNVPART(h,c) (h = (h) * FNV_MULT ^ (c))
+#define FNVSUM(h,s,n) do { \
+ register size_t _i_ = 0; \
+ while (_i_ < n) \
+ FNVPART(h, ((unsigned char*)s)[_i_++]); \
+ } while (0)
+
+#if _typ_int64_t
+
+#ifdef _ast_LL
+
+#define FNV_INIT64 0xcbf29ce484222325LL
+#define FNV_MULT64 0x00000100000001b3LL
+
+#else
+
+#define FNV_INIT64 ((int64_t)0xcbf29ce484222325)
+#define FNV_MULT64 ((int64_t)0x00000100000001b3)
+
+#endif
+
+#define FNVINIT64(h) (h = FNV_INIT64)
+#define FNVPART64(h,c) (h = (h) * FNV_MULT64 ^ (c))
+#define FNVSUM64(h,s,n) do { \
+ register int _i_ = 0; \
+ while (_i_ < n) \
+ FNVPART64(h, ((unsigned char*)s)[_i_++]); \
+ } while (0)
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/fs3d.h b/usr/src/lib/libast/i386/include/ast/fs3d.h
new file mode 100644
index 0000000000..a16099d7ae
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/fs3d.h
@@ -0,0 +1,120 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * 3d fs interface definitions
+ */
+
+#ifndef _FS3D_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FS3D_H
+
+#include <ast_fs.h>
+
+#if _int_st_spare1
+#define iview(p) ((p)->st_spare1)
+#define IVIEW(p,v) ((p)->st_spare1=(v))
+#else
+#if _ary_st_spare4
+#define iview(p) ((p)->st_spare4[0])
+#define IVIEW(p,v) ((p)->st_spare4[0]=(v))
+#else
+#if _ary_st_pad4
+#define iview(p) ((p)->st_pad4[0])
+#define IVIEW(p,v) ((p)->st_pad4[0]=(v))
+#else
+#if _mem_st_rdev_stat
+#define iview(p) ((S_ISBLK((p)->st_mode)||S_ISCHR((p)->st_mode))?0:(p)->st_rdev)
+#define IVIEW(p,v) do{if(!S_ISBLK((p)->st_mode)&&!S_ISCHR((p)->st_mode))(p)->st_rdev=(v);}while(0)
+#else
+#define iview(p) 0
+#define IVIEW(p,v)
+#endif
+#endif
+#endif
+#endif
+
+/*
+ * special options
+ */
+
+#define FS3D_init "/#option/init"
+#define FS3D_on "/#option/3d"
+#define FS3D_off "/#option/2d"
+
+/*
+ * fs3d(3) ops
+ */
+
+#define FS3D_OP(o,a) (((a)<<3)|(o))
+
+#define FS3D_INIT FS3D_OP_INIT /* re-initialize tables */
+#define FS3D_OFF FS3D_OP_OFF
+#define FS3D_ON FS3D_OP_ON
+#define FS3D_TEST FS3D_OP_TEST
+#define FS3D_LIMIT(n) FS3D_OP(FS3D_OP_LIMIT,n)
+
+#define FS3D_op(x) ((x)&07)
+#define FS3D_arg(x) (((x)>>3)&07777)
+
+#define FS3D_OP_OFF 0
+#define FS3D_OP_ON 1
+#define FS3D_OP_TEST 2
+#define FS3D_OP_LIMIT 3
+#define FS3D_OP_INIT 7
+
+/*
+ * mount(2) ops
+ */
+
+#define FS3D_ALL (FS3D_VIEW|FS3D_VERSION)
+#define FS3D_VIEW 002
+#define FS3D_VERSION 004
+#define FS3D_GET 010
+#define FS3D_SIZE(n) ((n)<<4)
+#define FS3D_SIZEOF(n) ((n)>>4)
+
+extern __MANGLE__ int mount __PROTO__((const char*, char*, int, __V_*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int fs3d __PROTO__((int));
+extern __MANGLE__ char* pathnext __PROTO__((char*, char*, long*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/fts.h b/usr/src/lib/libast/i386/include/ast/fts.h
new file mode 100644
index 0000000000..081fe2a712
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/fts.h
@@ -0,0 +1,160 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * David Korn
+ * Phong Vo
+ * AT&T Research
+ *
+ * fts interface definitions
+ */
+
+#ifndef _FTS_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FTS_H
+
+#include <ls.h>
+
+/*
+ * fts_open flags
+ */
+
+#define FTS_LOGICAL 0 /* logical traversal, follow symlinks */
+#define FTS_META (1<<0) /* follow top dir symlinks even if phys */
+#define FTS_NOCHDIR (1<<1) /* don't chdir */
+#define FTS_NOPOSTORDER (1<<2) /* no postorder visits */
+#define FTS_NOPREORDER (1<<3) /* no preorder visits */
+#define FTS_NOSEEDOTDIR (1<<11) /* never retain leading . dir */
+#define FTS_NOSTAT (1<<4) /* don't stat children */
+#define FTS_ONEPATH (1<<5) /* pathnames arg is one const char* */
+#define FTS_PHYSICAL (1<<6) /* physical traversal, don't follow */
+#define FTS_SEEDOT (1<<7) /* return . and .. */
+#define FTS_SEEDOTDIR (1<<10) /* always retain leading . dir */
+#define FTS_TOP (1<<8) /* don't traverse subdirectories */
+#define FTS_XDEV (1<<9) /* don't cross mount points */
+
+#define FTS_USER (1<<12) /* first user flag bit */
+
+#define FTS_COMFOLLOW FTS_META
+
+/*
+ * fts_info flags
+ */
+
+#define FTS_DEFAULT 0 /* ok, someone must have wanted this */
+
+#define FTS_NS (1<<0) /* stat failed */
+#define FTS_F (1<<1) /* file - not directory or symbolic link*/
+#define FTS_SL (1<<2) /* symbolic link */
+#define FTS_D (1<<3) /* directory - pre-order visit */
+
+#define FTS_C (1<<4) /* causes cycle */
+#define FTS_ERR (1<<5) /* some other error */
+#define FTS_DD (1<<6) /* . or .. */
+#define FTS_NR (1<<7) /* cannot read */
+#define FTS_NX (1<<8) /* cannot search */
+#define FTS_OK (1<<9) /* no info but otherwise ok */
+#define FTS_P (1<<10) /* post-order visit */
+
+#define FTS_DC (FTS_D|FTS_C) /* dir - would cause cycle */
+#define FTS_DNR (FTS_D|FTS_NR) /* dir - no read permission */
+#define FTS_DNX (FTS_D|FTS_NX) /* dir - no search permission */
+#define FTS_DOT (FTS_D|FTS_DD) /* . or .. */
+#define FTS_DP (FTS_D|FTS_P) /* dir - post-order visit */
+#define FTS_NSOK (FTS_NS|FTS_OK) /* no stat (because you asked) */
+#define FTS_SLNONE (FTS_SL|FTS_NS) /* symlink - to nowhere */
+
+/*
+ * fts_set flags
+ */
+
+#define FTS_AGAIN FTS_TOP /* process entry again */
+#define FTS_FOLLOW FTS_META /* follow FTS_SL symlink */
+#define FTS_SKIP FTS_NOSTAT /* skip FTS_D directory */
+#define FTS_STAT FTS_PHYSICAL /* stat() done by user */
+
+typedef struct Fts FTS;
+typedef struct Ftsent FTSENT;
+
+struct Ftsent
+{
+ char* fts_accpath; /* path relative to . */
+ char* fts_name; /* file name */
+ char* fts_path; /* path relative to top dir */
+ FTSENT* fts_cycle; /* offender if cycle */
+ FTSENT* fts_link; /* next child */
+ FTSENT* fts_parent; /* parent directory */
+ struct stat* fts_statp; /* stat info */
+#ifdef _FTSENT_LOCAL_PRIVATE_
+ _FTSENT_LOCAL_PRIVATE_
+#else
+ __V_* fts_pointer; /* local pointer value */
+#endif
+ long fts_number; /* local numeric value */
+ int fts_errno; /* errno for this entry */
+ unsigned short fts_info; /* info flags */
+ unsigned short fts_namelen; /* strlen(fts_name) */
+ unsigned short fts_pathlen; /* strlen(fts_path) */
+ short fts_level; /* file tree depth, 0 at top */
+
+#ifdef _FTSENT_PRIVATE_
+ _FTSENT_PRIVATE_
+#endif
+
+};
+
+struct Fts
+{
+ int fts_errno; /* last errno */
+
+#ifdef _FTS_PRIVATE_
+ _FTS_PRIVATE_
+#endif
+
+};
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ FTSENT* fts_children __PROTO__((FTS*, int));
+extern __MANGLE__ int fts_close __PROTO__((FTS*));
+extern __MANGLE__ int fts_flags __PROTO__((void));
+extern __MANGLE__ int fts_notify __PROTO__((int(*)(FTS*, FTSENT*, __V_*), __V_*));
+extern __MANGLE__ FTS* fts_open __PROTO__((char* const*, int, int(*)(FTSENT* const*, FTSENT* const*)));
+extern __MANGLE__ FTSENT* fts_read __PROTO__((FTS*));
+extern __MANGLE__ int fts_set __PROTO__((FTS*, FTSENT*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ftw.h b/usr/src/lib/libast/i386/include/ast/ftw.h
new file mode 100644
index 0000000000..bd39851cbc
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ftw.h
@@ -0,0 +1,71 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * ftw,nftw over ftwalk
+ */
+
+#ifndef _FTW_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FTW_H
+
+#define FTW FTWALK
+#include <ftwalk.h>
+#undef FTW
+
+#define FTW_SLN (FTW_SL|FTW_NR)
+
+#define FTW_PHYS (FTW_PHYSICAL)
+#define FTW_CHDIR (FTW_DOT)
+#define FTW_DEPTH (FTW_POST)
+#define FTW_OPEN (0)
+
+struct FTW
+{
+ int quit;
+ int base;
+ int level;
+};
+
+#define FTW_SKD FTW_SKIP
+#define FTW_PRUNE FTW_SKIP
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int ftw __PROTO__((const char*, int(*)(const char*, const struct stat*, int), int));
+extern __MANGLE__ int nftw __PROTO__((const char*, int(*)(const char*, const struct stat*, int, struct FTW*), int, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ftwalk.h b/usr/src/lib/libast/i386/include/ast/ftwalk.h
new file mode 100644
index 0000000000..1ee713a37a
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ftwalk.h
@@ -0,0 +1,137 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Phong Vo
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * ast ftwalk interface definitions
+ * ftwalk was the initial improvement on ftw and nftw
+ * which formed the basis for the POSIX fts proposal
+ *
+ * NOTE: this file is in cahoots with the fts implementation
+ */
+
+#ifndef _FTWALK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FTWALK_H
+
+#define fts_info info
+#define fts_level level
+#define fts_link link
+#define fts_name name
+#define fts_namelen namelen
+#define fts_parent parent
+#define fts_path path
+#define fts_pathlen pathlen
+
+#define FTSENT Ftw_t /* <fts.h> internal */
+#define Ftsent FTW /* <fts.h> internal */
+
+#define _FTSENT_LOCAL_PRIVATE_ /* <fts.h> internal */ \
+ union \
+ { \
+ long number; /* local numeric value */ \
+ __V_* pointer; /* local pointer value */ \
+ } local;
+
+#define _FTSENT_PRIVATE_ /* fts internal */ \
+ short status; /* internal status */ \
+ struct stat statb; /* fts_statp data */
+
+#include <fts.h>
+
+/*
+ * ftwalk() argument flags
+ */
+
+#define FTW_CANON FTS_CANON
+#define FTW_CHILDREN (FTS_USER<<0)
+#define FTW_DELAY FTS_NOSTAT
+#define FTW_DOT FTS_NOCHDIR
+#define FTW_META FTS_META
+#define FTW_MOUNT FTS_XDEV
+#define FTW_MULTIPLE FTS_ONEPATH
+#define FTW_NOSEEDOTDIR FTS_NOSEEDOTDIR
+#define FTW_PHYSICAL FTS_PHYSICAL
+#define FTW_POST (FTS_USER<<1)
+#define FTW_SEEDOTDIR FTS_SEEDOTDIR
+#define FTW_TOP FTS_TOP
+#define FTW_TWICE (FTS_USER<<2)
+#define FTW_USER (FTS_USER<<3)
+
+/*
+ * Ftw_t.info type bits
+ */
+
+#define FTW_C FTS_C
+#define FTW_D FTS_D
+#define FTW_DC FTS_DC
+#define FTW_DNR FTS_DNR
+#define FTW_DNX FTS_DNX
+#define FTW_DP FTS_DP
+#define FTW_F FTS_F
+#define FTW_NR FTS_NR
+#define FTW_NS FTS_NS
+#define FTW_NSOK FTS_NSOK
+#define FTW_NX FTS_NX
+#define FTW_P FTS_P
+#define FTW_SL FTS_SL
+
+/*
+ * Ftw_t.status entry values
+ */
+
+#define FTW_NAME FTS_DOT /* access by Ftw_t.name */
+#define FTW_PATH FTS_NOCHDIR /* access by Ftw_t.path */
+
+/*
+ * Ftw_t.status return values
+ */
+
+#define FTW_AGAIN FTS_AGAIN
+#define FTW_FOLLOW FTS_FOLLOW
+#define FTW_NOPOST FTS_NOPOSTORDER
+#define FTW_SKIP FTS_SKIP
+#define FTW_STAT FTS_STAT
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int ftwalk __PROTO__((const char*, int(*)(Ftw_t*), int, int(*)(Ftw_t*, Ftw_t*)));
+extern __MANGLE__ int ftwflags __PROTO__((void));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/getopt.h b/usr/src/lib/libast/i386/include/ast/getopt.h
new file mode 100644
index 0000000000..01348b6402
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/getopt.h
@@ -0,0 +1,31 @@
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+#include <ast_getopt.h>
+
+#if !defined(_GETOPT_H) && !defined(_AST_STD_I)
+
+#define _GETOPT_H 1
+
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+struct option
+{
+ const char* name;
+ int has_arg;
+ int* flag;
+ int val;
+};
+
+extern __MANGLE__ int getopt_long __PROTO__((int, char* const*, const char*, const struct option*, int*));
+extern __MANGLE__ int getopt_long_only __PROTO__((int, char* const*, const char*, const struct option*, int*));
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/glob.h b/usr/src/lib/libast/i386/include/ast/glob.h
new file mode 100644
index 0000000000..e02733177d
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/glob.h
@@ -0,0 +1,155 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * posix glob interface definitions with gnu extensions
+ */
+
+#ifndef _GLOB_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _GLOB_H
+
+#define GLOB_VERSION 20060717L
+
+#include <stdlib.h>
+
+struct dirent;
+struct stat;
+
+struct _glob_;
+struct _globlist_;
+
+typedef struct _glob_ glob_t;
+typedef struct _globlist_ globlist_t;
+
+struct _globlist_
+{
+ globlist_t* gl_next;
+ char* gl_begin;
+ unsigned char gl_flags;
+ char gl_path[1];
+};
+
+struct _glob_
+{
+ size_t gl_pathc;
+ char** gl_pathv;
+ size_t gl_offs;
+ globlist_t* gl_list;
+ int gl_flags;
+
+ /* GLOB_DISC data -- memset(&gl,0,sizeof(gl)) before using! */
+
+ const char* gl_fignore;
+ const char* gl_suffix;
+ unsigned char* gl_intr;
+
+ int gl_delim;
+
+ __V_* gl_handle;
+ __V_* (*gl_diropen) __PROTO__((glob_t*, const char*));
+ char* (*gl_dirnext) __PROTO__((glob_t*, __V_*));
+ void (*gl_dirclose) __PROTO__((glob_t*, __V_*));
+ int (*gl_type) __PROTO__((glob_t*, const char*));
+ int (*gl_attr) __PROTO__((glob_t*, const char*));
+
+ /* gnu extensions -- but how do you synthesize dirent and stat? */
+
+ __V_* (*gl_opendir) __PROTO__((const char*));
+ struct dirent* (*gl_readdir) __PROTO__((__V_*));
+ void (*gl_closedir) __PROTO__((__V_*));
+ int (*gl_stat) __PROTO__((const char*, struct stat*));
+ int (*gl_lstat) __PROTO__((const char*, struct stat*));
+
+ /* ast additions */
+
+ char* (*gl_nextdir) __PROTO__((glob_t*, char*));
+ unsigned long gl_status;
+ unsigned long gl_version;
+ unsigned short gl_extra;
+
+#ifdef _GLOB_PRIVATE_
+ _GLOB_PRIVATE_
+#else
+ char* gl_pad[23];
+#endif
+
+};
+
+/* standard interface */
+#define GLOB_APPEND 0x0001 /* append to previous */
+#define GLOB_DOOFFS 0x0002 /* gl_offs defines argv offset */
+#define GLOB_ERR 0x0004 /* abort on error */
+#define GLOB_MARK 0x0008 /* append / to directories */
+#define GLOB_NOCHECK 0x0010 /* nomatch is original pattern */
+#define GLOB_NOESCAPE 0x0020 /* don't treat \ specially */
+#define GLOB_NOSORT 0x0040 /* don't sort the list */
+
+/* extended interface */
+#define GLOB_STARSTAR 0x0080 /* enable [/]**[/] expansion */
+#define GLOB_BRACE 0x0100 /* enable {...} expansion */
+#define GLOB_ICASE 0x0200 /* ignore case on match */
+#define GLOB_COMPLETE 0x0400 /* shell file completeion */
+#define GLOB_AUGMENTED 0x0800 /* augmented shell patterns */
+#define GLOB_STACK 0x1000 /* allocate on current stack */
+#define GLOB_LIST 0x2000 /* just create gl_list */
+#define GLOB_ALTDIRFUNC 0x4000 /* gnu discipline functions */
+#define GLOB_DISC 0x8000 /* discipline initialized */
+
+/* gl_status */
+#define GLOB_NOTDIR 0x0001 /* last gl_dirnext() not a dir */
+
+/* gl_type return */
+#define GLOB_NOTFOUND 0 /* does not exist */
+#define GLOB_DEV 1 /* exists but not DIR EXE REG */
+#define GLOB_DIR 2 /* directory */
+#define GLOB_EXE 3 /* executable regular file */
+#define GLOB_REG 4 /* regular file */
+
+/* error return values */
+#define GLOB_ABORTED 1
+#define GLOB_NOMATCH 2
+#define GLOB_NOSPACE 3
+#define GLOB_INTR 4
+#define GLOB_APPERR 5
+#define GLOB_NOSYS 6
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int glob __PROTO__((const char*, int, int(*)(const char*,int), glob_t*));
+extern __MANGLE__ void globfree __PROTO__((glob_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif /* _GLOB_H */
diff --git a/usr/src/lib/libast/i386/include/ast/hash.h b/usr/src/lib/libast/i386/include/ast/hash.h
new file mode 100644
index 0000000000..4050612983
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/hash.h
@@ -0,0 +1,213 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * hash table library interface definitions
+ *
+ * NOTE: new code should use the more general <cdt.h>
+ */
+
+#ifndef _HASH_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _HASH_H
+
+#define HASH_ALLOCATE (1L<<0) /* allocate new key names */
+#define HASH_FIXED (1L<<1) /* fixed table size */
+#define HASH_HASHED (1L<<6) /* key names already hashed */
+#define HASH_RESIZE (1L<<2) /* table has been resized */
+#define HASH_SCANNING (1L<<3) /* currently scanning scope */
+#define HASH_SCOPE (1L<<4) /* push scope / create in bot */
+#define HASH_STATIC (1L<<5) /* static table allocation */
+
+#define HASH_CREATE (1L<<8) /* create bucket if not found */
+#define HASH_DELETE (1L<<9) /* delete bucket if found */
+#define HASH_LOOKUP 0 /* default op */
+#define HASH_RENAME (1L<<7) /* rename bucket if found */
+
+#define HASH_BUCKET (1L<<11) /* name is installed bucket */
+#define HASH_INSTALL (1L<<12) /* install allocated bucket */
+#define HASH_NOSCOPE (1L<<13) /* top scope only */
+#define HASH_OPAQUE (1L<<14) /* opaque bucket */
+#define HASH_VALUE (1L<<15) /* value bucket field used */
+
+#define HASH_SIZE(n) (((long)(n))<<16) /* fixed bucket size */
+#define HASH_SIZEOF(f) ((((long)(f))>>16)&0xffff) /* extract size */
+
+#define HASH_DELETED ((unsigned long)1<<(8*sizeof(int)-1)) /* deleted placeholder */
+#define HASH_KEEP (1L<<(8*sizeof(int)-2)) /* no free on bucket */
+#define HASH_HIDDEN (1L<<(8*sizeof(int)-3)) /* hidden by scope */
+#define HASH_HIDES (1L<<(8*sizeof(int)-4)) /* hides lower scope */
+#define HASH_OPAQUED (1L<<(8*sizeof(int)-5)) /* opaqued placeholder */
+#define HASH_FREENAME (1L<<(8*sizeof(int)-6)) /* free bucket name */
+
+#define HASH_RESET (HASH_RESIZE|HASH_SCOPE|HASH_STATIC|HASH_VALUE)
+#define HASH_INTERNAL (HASH_BUCKET|HASH_RESIZE|HASH_SCANNING|HASH_STATIC)
+#define HASH_FLAGS (HASH_DELETED|HASH_FREENAME|HASH_HIDDEN|HASH_HIDES|HASH_KEEP|HASH_OPAQUED)
+
+#define HASH_alloc 1
+#define HASH_clear 2
+#define HASH_compare 3
+#define HASH_free 4
+#define HASH_hash 5
+#define HASH_meanchain 6
+#define HASH_name 7
+#define HASH_namesize 8
+#define HASH_set 9
+#define HASH_size 10
+#define HASH_table 11
+#define HASH_va_list 12
+
+#define HASH_bucketsize 13
+
+#define HASH_region 14
+
+#include <hashpart.h>
+
+#define hashclear(t,f) ((t)->flags &= ~((f) & ~HASH_INTERNAL))
+#define hashcover(b) (((b)->hash&HASH_HIDES)?(Hash_bucket_t*)((b)->name):(Hash_bucket_t*)0)
+#define hashdel(t,n) hashlook(t, (char*)(n), HASH_DELETE, (char*)0)
+#define hashget(t,n) hashlook(t, (char*)(n), HASH_LOOKUP|HASH_VALUE, (char*)0)
+#define hashgetbucket(s) ((Hash_bucket_t*)((s)-((sizeof(Hash_bucket_t)+sizeof(char*)-1)/sizeof(char*))*sizeof(char*)))
+#define hashkeep(b) ((b)->hash|=HASH_KEEP)
+#define hashname(b) ((((b)->hash&HASH_HIDES)?((Hash_bucket_t*)((b)->name)):(b))->name)
+#define hashput(t,n,v) hashlook(t, (char*)(n), HASH_CREATE|HASH_VALUE, (char*)(v))
+#define hashref(t,n) hashlook(t, (char*)(n), HASH_LOOKUP|HASH_INTERNAL|HASH_VALUE, (char*)0)
+#define hashscope(t) ((t)->scope)
+#define hashset(t,f) ((t)->flags |= ((f) & ~HASH_INTERNAL))
+
+/*
+ * DEPRECATED renames for compatibility
+ */
+
+#define Hashbin_t Hash_bucket_t
+#define HASHBUCKET Hash_bucket_t
+#define Hashhdr_t Hash_header_t
+#define HASHHEADER Hash_header_t
+#define Hashpos_t Hash_position_t
+#define HASHPOSITION Hash_position_t
+#define Hashtab_t Hash_table_t
+#define HASHTABLE Hash_table_t
+
+#define vhashalloc hashvalloc
+#define hashvalloc(t,a) hashalloc(t,HASH_va_list,a,0)
+
+/*
+ * the #define's avoid union tags
+ */
+
+typedef struct Hash_bucket Hash_bucket_t;
+typedef struct Hash_root Hash_root_t;
+typedef struct Hash_table Hash_table_t;
+
+#define HASH_HEADER /* common bucket header */ \
+ Hash_bucket_t* next; /* next in collision chain */ \
+ unsigned int hash; /* hash flags and value */ \
+ char* name /* key name */
+
+#define HASH_DEFAULT /* HASH_VALUE bucket elements */ \
+ char* value /* key value */
+
+typedef struct /* bucket header */
+{
+ HASH_HEADER;
+} Hash_header_t;
+
+struct Hash_bucket /* prototype bucket */
+{
+ HASH_HEADER;
+ HASH_DEFAULT;
+};
+
+typedef struct /* hash scan bucket position */
+{
+ Hash_bucket_t* bucket; /* bucket */
+#ifdef _HASH_POSITION_PRIVATE_
+ _HASH_POSITION_PRIVATE_
+#endif
+} Hash_position_t;
+
+typedef struct /* last lookup cache */
+{
+ Hash_table_t* table; /* last lookup table */
+ Hash_bucket_t* bucket; /* last lookup bucket */
+#ifdef _HASH_LAST_PRIVATE_
+ _HASH_LAST_PRIVATE_
+#endif
+} Hash_last_t;
+
+struct Hash_root /* root hash table information */
+{
+ int accesses; /* number of accesses */
+ int collisions; /* number of collisions */
+ int flags; /* flags: see HASH_[A-Z]* */
+ Hash_last_t last; /* last lookup cache */
+ __V_* context; /* user defined context */
+#ifdef _HASH_ROOT_PRIVATE_
+ _HASH_ROOT_PRIVATE_
+#endif
+};
+
+struct Hash_table /* hash table information */
+{
+ Hash_root_t* root; /* root hash table information */
+ int size; /* table size */
+ int buckets; /* active bucket count */
+ char* name; /* table name */
+ Hash_table_t* scope; /* scope covered table */
+ short flags; /* flags: see HASH_[A-Z]* */
+#ifdef _HASH_TABLE_PRIVATE_
+ _HASH_TABLE_PRIVATE_
+#endif
+};
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Hash_table_t* hashalloc __PROTO__((Hash_table_t*, ...));
+extern __MANGLE__ void hashdone __PROTO__((Hash_position_t*));
+extern __MANGLE__ void hashdump __PROTO__((Hash_table_t*, int));
+extern __MANGLE__ Hash_table_t* hashfree __PROTO__((Hash_table_t*));
+extern __MANGLE__ Hash_bucket_t* hashlast __PROTO__((Hash_table_t*));
+extern __MANGLE__ char* hashlook __PROTO__((Hash_table_t*, const char*, long, const char*));
+extern __MANGLE__ Hash_bucket_t* hashnext __PROTO__((Hash_position_t*));
+extern __MANGLE__ Hash_position_t* hashscan __PROTO__((Hash_table_t*, int));
+extern __MANGLE__ void hashsize __PROTO__((Hash_table_t*, int));
+extern __MANGLE__ Hash_table_t* hashview __PROTO__((Hash_table_t*, Hash_table_t*));
+extern __MANGLE__ int hashwalk __PROTO__((Hash_table_t*, int, int (*)(const char*, char*, __V_*), __V_*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/hashkey.h b/usr/src/lib/libast/i386/include/ast/hashkey.h
new file mode 100644
index 0000000000..1ce051ff26
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/hashkey.h
@@ -0,0 +1,73 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * 1-6 char lower-case keyword -> long hash
+ * digit args passed as HASHKEYN('2')
+ */
+
+#ifndef _HASHKEY_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _HASHKEY_H
+
+#define HASHKEYMAX 6
+#define HASHKEYBIT 5
+#define HASHKEYOFF ('a'-1)
+#define HASHKEYPART(h,c) (((h)<<HASHKEYBIT)+HASHKEY1(c))
+
+#define HASHKEYN(n) ((n)-'0'+'z'+1)
+
+#define HASHKEY1(c1) ((c1)-HASHKEYOFF)
+#define HASHKEY2(c1,c2) HASHKEYPART(HASHKEY1(c1),c2)
+#define HASHKEY3(c1,c2,c3) HASHKEYPART(HASHKEY2(c1,c2),c3)
+#define HASHKEY4(c1,c2,c3,c4) HASHKEYPART(HASHKEY3(c1,c2,c3),c4)
+#define HASHKEY5(c1,c2,c3,c4,c5) HASHKEYPART(HASHKEY4(c1,c2,c3,c4),c5)
+#define HASHKEY6(c1,c2,c3,c4,c5,c6) HASHKEYPART(HASHKEY5(c1,c2,c3,c4,c5),c6)
+
+#define HASHNKEY1(n,c1) HASHKEY2((n)+HASHKEYOFF,c1)
+#define HASHNKEY2(n,c2,c1) HASHKEY3((n)+HASHKEYOFF,c2,c1)
+#define HASHNKEY3(n,c3,c2,c1) HASHKEY4((n)+HASHKEYOFF,c3,c2,c1)
+#define HASHNKEY4(n,c4,c3,c2,c1) HASHKEY5((n)+'a',c4,c3,c2,c1)
+#define HASHNKEY5(n,c5,c4,c3,c2,c1) HASHKEY6((n)+'a',c5,c4,c3,c2,c1)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ long strkey __PROTO__((const char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/hashpart.h b/usr/src/lib/libast/i386/include/ast/hashpart.h
new file mode 100644
index 0000000000..b2aa79649a
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/hashpart.h
@@ -0,0 +1,60 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * K. P. Vo
+ * G. S. Fowler
+ * AT&T Research
+ *
+ * ``the best'' combined linear congruent checksum/hash/PRNG
+ */
+
+#ifndef _HASHPART_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _HASHPART_H
+
+#define HASH_ADD(h) (0x9c39c33dL)
+
+#if __sparc__ || __sparc || sparc
+
+#define HASH_A(h,n) ((((h) << 2) - (h)) << (n))
+#define HASH_B(h,n) ((((h) << 4) - (h)) << (n))
+#define HASH_C(h,n) ((HASH_A(h,7) + HASH_B(h,0)) << (n))
+#define HASH_MPY(h) (HASH_C(h,22)+HASH_C(h,10)+HASH_A(h,6)+HASH_A(h,3)+(h))
+
+#else
+
+#define HASH_MPY(h) ((h)*0x63c63cd9L)
+
+#endif
+
+#define HASHPART(h,c) (h = HASH_MPY(h) + HASH_ADD(h) + (c))
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/iconv.h b/usr/src/lib/libast/i386/include/ast/iconv.h
new file mode 100644
index 0000000000..e63b3f0fcd
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/iconv.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_iconv.h>
diff --git a/usr/src/lib/libast/i386/include/ast/lc.h b/usr/src/lib/libast/i386/include/ast/lc.h
new file mode 100644
index 0000000000..fdd804f36e
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/lc.h
@@ -0,0 +1,158 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated by ./lcgen : : */
+
+
+#ifndef _LC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _LC_H 1
+
+#include <ast.h>
+
+#define LC_abbreviated 0x00001
+#define LC_checked 0x00002
+#define LC_default 0x00004
+#define LC_defined 0x00008
+#define LC_debug 0x00010
+#define LC_local 0x00020
+#define LC_primary 0x00040
+#define LC_qualified 0x00080
+#define LC_undefined 0x00100
+#define LC_verbose 0x00200
+#define LC_user 0x10000
+#define LC_language_attribute_max 2
+#define LC_territory_language_max 4
+
+struct Lc_s;
+
+typedef struct Lc_info_s
+{
+ const struct Lc_s* lc;
+ unsigned long number;
+ __V_* data;
+} Lc_info_t;
+
+typedef struct Lc_attribute_s
+{
+ const char* name;
+ unsigned long flags;
+ unsigned long index;
+} Lc_attribute_t;
+
+typedef struct Lc_charset_s
+{
+ const char* code;
+ const char* alternates;
+ const char* ms;
+ unsigned long index;
+} Lc_charset_t;
+
+typedef struct Lc_language_s
+{
+ const char* code;
+ const char* name;
+ const char* alternates;
+ const Lc_charset_t* charset;
+ unsigned long flags;
+ unsigned long index;
+ const Lc_attribute_t* attributes[LC_language_attribute_max];
+} Lc_language_t;
+
+typedef struct Lc_territory_s
+{
+ const char* code;
+ const char* name;
+ unsigned long flags;
+ unsigned long index;
+ const Lc_language_t* languages[LC_territory_language_max];
+#ifdef _LC_TERRITORY_PRIVATE_
+ _LC_TERRITORY_PRIVATE_
+#endif
+} Lc_territory_t;
+
+typedef struct Lc_map_s
+{
+ const char* code;
+ const Lc_language_t* language;
+ const Lc_territory_t* territory;
+ const Lc_charset_t* charset;
+ const Lc_attribute_t* attribute;
+} Lc_map_t;
+
+typedef struct Lc_attribute_list_s
+{
+ struct Lc_attribute_list_s* next;
+ const Lc_attribute_t* attribute;
+} Lc_attribute_list_t;
+
+typedef struct Lc_s
+{
+ const char* name;
+ const char* code;
+ const Lc_language_t* language;
+ const Lc_territory_t* territory;
+ const Lc_charset_t* charset;
+ const Lc_attribute_list_t* attributes;
+ unsigned long flags;
+ unsigned long index;
+#ifdef _LC_PRIVATE_
+ _LC_PRIVATE_
+#endif
+} Lc_t;
+
+struct Lc_category_s;
+
+typedef int (*Lc_category_set_f) __PROTO__((struct Lc_category_s*));
+
+typedef struct Lc_category_s
+{
+ const char* name;
+ int external;
+ int internal;
+ Lc_category_set_f setf;
+ Lc_t* prev;
+} Lc_category_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ size_t lccanon __PROTO__((Lc_t*, unsigned long flags, char*, size_t));
+extern __MANGLE__ Lc_category_t* lccategories __PROTO__((void));
+extern __MANGLE__ int lcindex __PROTO__((int, int));
+extern __MANGLE__ Lc_info_t* lcinfo __PROTO__((int));
+extern __MANGLE__ Lc_t* lcmake __PROTO__((const char*));
+extern __MANGLE__ Lc_t* lcscan __PROTO__((Lc_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/ls.h b/usr/src/lib/libast/i386/include/ast/ls.h
new file mode 100644
index 0000000000..cce1771b3f
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/ls.h
@@ -0,0 +1,99 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * ls formatter interface definitions
+ */
+
+#ifndef _LS_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _LS_H
+
+#include <ast_std.h>
+#include <ast_fs.h>
+#include <ast_mode.h>
+
+/*
+ * some systems (could it beee AIX) pollute the std name space
+ */
+
+#undef fileid
+#define fileid fileID
+
+#define LS_BLOCKSIZE 512
+
+#define iblocks(p) _iblocks(p)
+
+#if _mem_st_rdev_stat
+#define idevice(p) ((p)->st_rdev)
+#define IDEVICE(p,v) ((p)->st_rdev=(v))
+#else
+#define idevice(p) 0
+#define IDEVICE(p,v)
+#endif
+
+#define LS_ATIME (1<<0) /* list st_atime */
+#define LS_BLOCKS (1<<1) /* list blocks used by file */
+#define LS_CTIME (1<<2) /* list st_ctime */
+#define LS_EXTERNAL (1<<3) /* st_mode is modex canonical */
+#define LS_INUMBER (1<<4) /* list st_ino */
+#define LS_LONG (1<<5) /* long listing */
+#define LS_MARK (1<<6) /* append file name marks */
+#define LS_NOGROUP (1<<7) /* omit group name for LS_LONG */
+#define LS_NOUSER (1<<8) /* omit user name for LS_LONG */
+#define LS_NUMBER (1<<9) /* number instead of name */
+
+#define LS_USER (1<<10) /* first user flag bit */
+
+#define LS_W_BLOCKS 6 /* LS_BLOCKS field width */
+#define LS_W_INUMBER 7 /* LS_INUMBER field width */
+#define LS_W_LONG 55 /* LS_LONG width (w/o names) */
+#define LS_W_LINK 4 /* link text width (w/o names) */
+#define LS_W_MARK 1 /* LS_MARK field width */
+#define LS_W_NAME 9 /* group|user name field width */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ off_t _iblocks __PROTO__((struct stat*));
+extern __MANGLE__ char* fmtdev __PROTO__((struct stat*));
+extern __MANGLE__ char* fmtfs __PROTO__((struct stat*));
+extern __MANGLE__ char* fmtls __PROTO__((char*, const char*, struct stat*, const char*, const char*, int));
+extern __MANGLE__ int pathstat __PROTO__((const char*, struct stat*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/magic.h b/usr/src/lib/libast/i386/include/ast/magic.h
new file mode 100644
index 0000000000..f484f2b20d
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/magic.h
@@ -0,0 +1,96 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * magic interface definitions
+ */
+
+#ifndef _MAGIC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MAGIC_H
+
+#include <sfio.h>
+#include <ls.h>
+
+#define MAGIC_VERSION 19961031L
+
+#ifndef MAGIC_FILE
+#define MAGIC_FILE "lib/file/magic"
+#endif
+
+#ifndef MAGIC_DIR
+#define MAGIC_DIR "lib/file"
+#endif
+
+#define MAGIC_FILE_ENV "MAGICFILE"
+
+#define MAGIC_MIME (1<<0) /* magictype returns MIME type */
+#define MAGIC_VERBOSE (1<<1) /* verbose magic file errors */
+
+#define MAGIC_USER (1L<<16) /* first user flag bit */
+
+struct Magic_s;
+struct Magicdisc_s;
+
+typedef struct Magicdisc_s
+{
+ unsigned long version; /* interface version */
+ unsigned long flags; /* MAGIC_* flags */
+ Error_f errorf; /* error function */
+} Magicdisc_t;
+
+typedef struct Magic_s
+{
+ const char* id; /* library id string */
+
+#ifdef _MAGIC_PRIVATE_
+ _MAGIC_PRIVATE_
+#endif
+
+} Magic_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Magic_t* magicopen __PROTO__((Magicdisc_t*));
+extern __MANGLE__ int magicload __PROTO__((Magic_t*, const char*, unsigned long));
+extern __MANGLE__ int magiclist __PROTO__((Magic_t*, Sfio_t*));
+extern __MANGLE__ char* magictype __PROTO__((Magic_t*, Sfio_t*, const char*, struct stat*));
+extern __MANGLE__ int magicclose __PROTO__((Magic_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/magicid.h b/usr/src/lib/libast/i386/include/ast/magicid.h
new file mode 100644
index 0000000000..ceadff2653
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/magicid.h
@@ -0,0 +1,55 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * generic binary magic id definitions
+ */
+
+#ifndef _MAGICID_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MAGICID_H 1
+
+#include <ast_common.h>
+
+#define MAGICID 0x00010203
+
+typedef uint32_t Magicid_data_t;
+
+typedef struct Magicid_s
+{
+ Magicid_data_t magic; /* magic number */
+ char name[8]; /* generic data/application name*/
+ char type[12]; /* specific data type */
+ Magicid_data_t version; /* YYYYMMDD or 0xWWXXYYZZ */
+ Magicid_data_t size;
+} Magicid_t;
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/mc.h b/usr/src/lib/libast/i386/include/ast/mc.h
new file mode 100644
index 0000000000..4b55665b3b
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/mc.h
@@ -0,0 +1,107 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * machine independent binary message catalog interface
+ *
+ * file layout
+ * all numbers are sfputu() format
+ *
+ * 4 char magic (^M^S^G0)
+ * <method locale YYYY-MM-DD>\0
+ * (<optional strings>\0)*
+ * \0
+ * string table size
+ * #msgs total
+ * #max set number
+ * #set-id 1
+ * #msgs in set 1
+ * ...
+ * #set-id #sets
+ * #msgs in set #sets
+ * end of sets (0)
+ * msg(1,1) size
+ * ...
+ * msg(#sets,#msgs) size
+ * string table
+ */
+
+#ifndef _MC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MC_H
+
+#include <ast.h>
+
+#define MC_MAGIC "\015\023\007\000"
+#define MC_MAGIC_SIZE 4
+
+#define MC_SET_MAX 1023
+#define MC_NUM_MAX 32767
+
+#define MC_NLS (1<<10)
+
+#define MC_MESSAGE_SET(s) mcindex(s,NiL,NiL,NiL)
+
+typedef struct
+{
+ char** msg;
+ int num;
+ int gen;
+} Mcset_t;
+
+typedef struct
+{
+ Mcset_t* set;
+ int num;
+ int gen;
+ char* translation;
+#ifdef _MC_PRIVATE_
+ _MC_PRIVATE_
+#endif
+} Mc_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ char* mcfind __PROTO__((char*, const char*, const char*, int, int));
+extern __MANGLE__ Mc_t* mcopen __PROTO__((Sfio_t*));
+extern __MANGLE__ char* mcget __PROTO__((Mc_t*, int, int, const char*));
+extern __MANGLE__ int mcput __PROTO__((Mc_t*, int, int, const char*));
+extern __MANGLE__ int mcdump __PROTO__((Mc_t*, Sfio_t*));
+extern __MANGLE__ int mcindex __PROTO__((const char*, char**, int*, int*));
+extern __MANGLE__ int mcclose __PROTO__((Mc_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/mime.h b/usr/src/lib/libast/i386/include/ast/mime.h
new file mode 100644
index 0000000000..b018b68c9a
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/mime.h
@@ -0,0 +1,102 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * mime/mailcap interface
+ */
+
+#ifndef _MIMETYPE_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MIMETYPE_H 1
+
+#include <sfio.h>
+#include <ls.h>
+
+#define MIME_VERSION 19970717L
+
+#ifndef MIME_FILES
+#define MIME_FILES "~/.mailcap:/usr/local/etc/mailcap:/usr/etc/mailcap:/etc/mailcap:/etc/mail/mailcap:/usr/public/lib/mailcap"
+#endif
+
+#define MIME_FILES_ENV "MAILCAP"
+
+#define MIME_LIST (1<<0) /* mimeload arg is : list */
+#define MIME_NOMAGIC (1<<1) /* no magic for mimetype() */
+#define MIME_PIPE (1<<2) /* mimeview() io is piped */
+#define MIME_REPLACE (1<<3) /* replace existing definition */
+
+#define MIME_USER (1L<<16) /* first user flag bit */
+
+struct Mime_s;
+typedef struct Mime_s Mime_t;
+
+struct Mimedisc_s;
+typedef struct Mimedisc_s Mimedisc_t;
+
+typedef int (*Mimevalue_f) __PROTO__((Mime_t*, __V_*, char*, size_t, Mimedisc_t*));
+
+struct Mimedisc_s
+{
+ unsigned long version; /* interface version */
+ unsigned long flags; /* MIME_* flags */
+ Error_f errorf; /* error function */
+ Mimevalue_f valuef; /* value extraction function */
+};
+
+struct Mime_s
+{
+ const char* id; /* library id string */
+
+#ifdef _MIME_PRIVATE_
+ _MIME_PRIVATE_
+#endif
+
+};
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Mime_t* mimeopen __PROTO__((Mimedisc_t*));
+extern __MANGLE__ int mimeload __PROTO__((Mime_t*, const char*, unsigned long));
+extern __MANGLE__ int mimelist __PROTO__((Mime_t*, Sfio_t*, const char*));
+extern __MANGLE__ int mimeclose __PROTO__((Mime_t*));
+extern __MANGLE__ int mimeset __PROTO__((Mime_t*, char*, unsigned long));
+extern __MANGLE__ char* mimetype __PROTO__((Mime_t*, Sfio_t*, const char*, struct stat*));
+extern __MANGLE__ char* mimeview __PROTO__((Mime_t*, const char*, const char*, const char*, const char*));
+extern __MANGLE__ int mimehead __PROTO__((Mime_t*, __V_*, size_t, size_t, char*));
+extern __MANGLE__ int mimecmp __PROTO__((const char*, const char*, char**));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/mnt.h b/usr/src/lib/libast/i386/include/ast/mnt.h
new file mode 100644
index 0000000000..d877416642
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/mnt.h
@@ -0,0 +1,69 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * mounted filesystem scan interface
+ */
+
+#ifndef _MNT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MNT_H 1
+
+#undef MNT_REMOTE /* aix clash */
+#define MNT_REMOTE (1<<0) /* remote mount */
+
+typedef struct
+{
+ char* fs; /* filesystem name */
+ char* dir; /* mounted dir */
+ char* type; /* filesystem type */
+ char* options; /* options */
+ int freq; /* backup frequency */
+ int npass; /* number of parallel passes */
+ int flags; /* MNT_* flags */
+} Mnt_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ __V_* mntopen __PROTO__((const char*, const char*));
+extern __MANGLE__ Mnt_t* mntread __PROTO__((__V_*));
+extern __MANGLE__ int mntwrite __PROTO__((__V_*, const Mnt_t*));
+extern __MANGLE__ int mntclose __PROTO__((__V_*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/modecanon.h b/usr/src/lib/libast/i386/include/ast/modecanon.h
new file mode 100644
index 0000000000..ce107238e3
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/modecanon.h
@@ -0,0 +1,74 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * canonical mode_t representation
+ */
+
+#ifndef _MODECANON_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MODECANON_H
+
+#define X_ITYPE(m) ((m)&X_IFMT)
+
+#define X_IFMT 0170000
+#define X_IFWHT 0160000
+#define X_IFDOOR 0150000
+#define X_IFSOCK 0140000
+#define X_IFLNK 0120000
+#define X_IFCTG 0110000
+#define X_IFREG 0100000
+#define X_IFBLK 0060000
+#define X_IFDIR 0040000
+#define X_IFCHR 0020000
+#define X_IFIFO 0010000
+
+#define X_IPERM 0007777
+#define X_ISUID 0004000
+#define X_ISGID 0002000
+#define X_ISVTX 0001000
+#define X_IRUSR 0000400
+#define X_IWUSR 0000200
+#define X_IXUSR 0000100
+#define X_IRGRP 0000040
+#define X_IWGRP 0000020
+#define X_IXGRP 0000010
+#define X_IROTH 0000004
+#define X_IWOTH 0000002
+#define X_IXOTH 0000001
+
+#define X_IRWXU (X_IRUSR|X_IWUSR|X_IXUSR)
+#define X_IRWXG (X_IRGRP|X_IWGRP|X_IXGRP)
+#define X_IRWXO (X_IROTH|X_IWOTH|X_IXOTH)
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/modex.h b/usr/src/lib/libast/i386/include/ast/modex.h
new file mode 100644
index 0000000000..458ad18ac1
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/modex.h
@@ -0,0 +1,62 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * AT&T Research
+ *
+ * external mode_t representation support
+ */
+
+#ifndef _MODEX_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MODEX_H
+
+#include <ast_fs.h>
+#include <modecanon.h>
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int modei __PROTO__((int));
+extern __MANGLE__ int modex __PROTO__((int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _S_IDPERM
+#define modei(m) ((m)&X_IPERM)
+#if _S_IDTYPE
+#define modex(m) (m)
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/namval.h b/usr/src/lib/libast/i386/include/ast/namval.h
new file mode 100644
index 0000000000..d746970d58
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/namval.h
@@ -0,0 +1,51 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * common name-value struct support
+ */
+
+#ifndef _NAMVAL_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _NAMVAL_H
+
+typedef struct
+{
+ char* name;
+ int value;
+#ifdef _NAMVAL_PRIVATE_
+ _NAMVAL_PRIVATE_
+#endif
+} Namval_t;
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/nl_types.h b/usr/src/lib/libast/i386/include/ast/nl_types.h
new file mode 100644
index 0000000000..db7383c626
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/nl_types.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_nl_types.h>
diff --git a/usr/src/lib/libast/i386/include/ast/option.h b/usr/src/lib/libast/i386/include/ast/option.h
new file mode 100644
index 0000000000..7204047891
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/option.h
@@ -0,0 +1,119 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * command line option parse interface
+ */
+
+#ifndef _OPTION_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _OPTION_H
+
+#include <ast.h>
+
+#define OPT_VERSION 20070319L
+
+#define OPT_USER (1L<<16) /* first user flag bit */
+
+struct Opt_s;
+struct Optdisc_s;
+
+typedef int (*Optinfo_f) __PROTO__((struct Opt_s*, Sfio_t*, const char*, struct Optdisc_s*));
+
+typedef struct Optdisc_s
+{
+ unsigned long version; /* OPT_VERSION */
+ unsigned long flags; /* OPT_* flags */
+ char* catalog; /* error catalog id */
+ Optinfo_f infof; /* runtime info function */
+} Optdisc_t;
+
+/* NOTE: Opt_t member order fixed by a previous binary release */
+
+#ifndef _OPT_PRIVATE_
+#define _OPT_PRIVATE_ \
+ char pad[3*sizeof(__V_*)];
+#endif
+
+typedef struct Opt_s
+{
+ int again; /* see optjoin() */
+ char* arg; /* {:,#} string argument */
+ char** argv; /* most recent argv */
+ int index; /* argv index */
+ char* msg; /* error/usage message buffer */
+ long num; /* OBSOLETE -- use number */
+ int offset; /* char offset in argv[index] */
+ char option[8]; /* current flag {-,+} + option */
+ char name[64]; /* current long name or flag */
+ Optdisc_t* disc; /* user discipline */
+ intmax_t number; /* # numeric argument */
+ unsigned char assignment; /* option arg assigment op */
+ unsigned char pads[sizeof(__V_*)-1];
+ _OPT_PRIVATE_
+} Opt_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Opt_t* _opt_infop_;
+
+#define opt_info (*_opt_infop_)
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define optinit(d,f) (memset(d,0,sizeof(*(d))),(d)->version=OPT_VERSION,(d)->infof=(f),opt_info.disc=(d))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int optget __PROTO__((char**, const char*));
+extern __MANGLE__ int optjoin __PROTO__((char**, ...));
+extern __MANGLE__ char* opthelp __PROTO__((const char*, const char*));
+extern __MANGLE__ char* optusage __PROTO__((const char*));
+extern __MANGLE__ int optstr __PROTO__((const char*, const char*));
+extern __MANGLE__ int optesc __PROTO__((Sfio_t*, const char*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/preroot.h b/usr/src/lib/libast/i386/include/ast/preroot.h
new file mode 100644
index 0000000000..5cd0efce61
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/preroot.h
@@ -0,0 +1,27 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/preroot.sh by iffe version 2007-04-04 : : */
+#ifndef _def_preroot_ast
+#define _def_preroot_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* preroot not enabled */
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/proc.h b/usr/src/lib/libast/i386/include/ast/proc.h
new file mode 100644
index 0000000000..1196fc5b3f
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/proc.h
@@ -0,0 +1,113 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * process library interface
+ */
+
+#ifndef _PROC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _PROC_H
+
+#include <ast.h>
+
+#define PROC_ARGMOD (1<<0) /* argv[-1],argv[0] can be modified */
+#define PROC_BACKGROUND (1<<1) /* shell background (&) setup */
+#define PROC_CLEANUP (1<<2) /* close parent redirect fds on error */
+#define PROC_DAEMON (1<<3) /* daemon setup */
+#define PROC_ENVCLEAR (1<<4) /* clear environment */
+#define PROC_FOREGROUND (1<<14) /* system(3) setup */
+#define PROC_GID (1<<5) /* setgid(getgid()) */
+#define PROC_IGNORE (1<<6) /* ignore parent pipe errors */
+#define PROC_OVERLAY (1<<7) /* overlay current process if possible */
+#define PROC_PARANOID (1<<8) /* restrict everything */
+#define PROC_PRIVELEGED (1<<9) /* setuid(0), setgid(getegid()) */
+#define PROC_READ (1<<10) /* proc pipe fd 1 returned */
+#define PROC_SESSION (1<<11) /* session leader */
+#define PROC_UID (1<<12) /* setuid(getuid()) */
+#define PROC_WRITE (1<<13) /* proc pipe fd 0 returned */
+#define PROC_ZOMBIE (1<<15) /* proc may leave a zombie behind */
+
+#define PROC_ARG_BIT 14 /* bits per op arg */
+#define PROC_OP_BIT 4 /* bits per op */
+
+#define PROC_ARG_NULL ((1<<PROC_ARG_BIT)-1)
+
+#define PROC_fd_dup 0x4
+#define PROC_FD_CHILD 0x1
+#define PROC_FD_PARENT 0x2
+
+#define PROC_sig_dfl 0x8
+#define PROC_sig_ign 0x9
+
+#define PROC_sys_pgrp 0xa
+#define PROC_sys_umask 0xb
+
+#define PROC_op1(o,a) (((o)<<(2*PROC_ARG_BIT))|((a)&((PROC_ARG_NULL<<PROC_ARG_BIT)|PROC_ARG_NULL)))
+#define PROC_op2(o,a,b) (((o)<<(2*PROC_ARG_BIT))|(((b)&PROC_ARG_NULL)<<PROC_ARG_BIT)|((a)&PROC_ARG_NULL))
+
+#define PROC_FD_CLOSE(p,f) PROC_op2(PROC_fd_dup|(f),p,PROC_ARG_NULL)
+#define PROC_FD_DUP(p,c,f) PROC_op2(PROC_fd_dup|(f),p,c)
+#define PROC_SIG_DFL(s) PROC_op1(PROC_sig_dfl,s,0)
+#define PROC_SIG_IGN(s) PROC_op1(PROC_sig_ign,s,0)
+#define PROC_SYS_PGRP(g) PROC_op1(PROC_sys_pgrp,g)
+#define PROC_SYS_UMASK(m) PROC_op1(PROC_sys_umask,m,0)
+
+#define PROC_OP(x) (((x)>>(2*PROC_ARG_BIT))&((1<<PROC_OP_BIT)-1))
+#define PROC_ARG(x,n) ((n)?(((x)>>(((n)-1)*PROC_ARG_BIT))&PROC_ARG_NULL):(((x)&~((1<<(2*PROC_ARG_BIT))-1))==~((1<<(2*PROC_ARG_BIT))-1))?(-1):((x)&~((1<<(2*PROC_ARG_BIT))-1)))
+
+typedef struct
+{
+ pid_t pid; /* process id */
+ pid_t pgrp; /* process group id */
+ int rfd; /* read fd if applicable */
+ int wfd; /* write fd if applicable */
+
+#ifdef _PROC_PRIVATE_
+_PROC_PRIVATE_
+#endif
+
+} Proc_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int procclose __PROTO__((Proc_t*));
+extern __MANGLE__ int procfree __PROTO__((Proc_t*));
+extern __MANGLE__ Proc_t* procopen __PROTO__((const char*, char**, char**, long*, long));
+extern __MANGLE__ int procrun __PROTO__((const char*, char**));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/prototyped.h b/usr/src/lib/libast/i386/include/ast/prototyped.h
new file mode 100644
index 0000000000..113fb94d24
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/prototyped.h
@@ -0,0 +1,59 @@
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/re_comp.h b/usr/src/lib/libast/i386/include/ast/re_comp.h
new file mode 100644
index 0000000000..5da565e880
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/re_comp.h
@@ -0,0 +1,52 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * re_comp interface definitions
+ *
+ * OBSOLETE: use <regex.h>
+ */
+
+#ifndef _RE_COMP_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _RE_COMP_H
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ char* re_comp __PROTO__((const char*));
+extern __MANGLE__ int re_exec __PROTO__((const char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/recfmt.h b/usr/src/lib/libast/i386/include/ast/recfmt.h
new file mode 100644
index 0000000000..1a66761ec2
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/recfmt.h
@@ -0,0 +1,94 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * record format interface
+ */
+
+#ifndef _RECFMT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _RECFMT_H 1
+
+#include <ast.h>
+
+typedef uint32_t Recfmt_t;
+
+#define REC_delimited 0
+#define REC_fixed 1
+#define REC_variable 2
+#define REC_method 14
+#define REC_none 15
+
+#define REC_M_path 0
+#define REC_M_data 1
+
+#define RECTYPE(f) (((f)>>28)&((1<<4)-1))
+
+#define REC_D_TYPE(d) ((REC_delimited<<28)|((d)&((1<<8)-1)))
+#define REC_D_DELIMITER(f) ((f)&((1<<8)-1))
+
+#define REC_F_TYPE(s) ((REC_fixed<<28)|((s)&((1<<28)-1)))
+#define REC_F_SIZE(f) ((f)&((1<<28)-1))
+
+#define REC_U_TYPE(t,a) (((t)<<28)|((a)&((1<<28)-1)))
+#define REC_U_ATTRIBUTES(f) ((f)&~((1<<28)-1))
+
+#define REC_V_TYPE(h,o,z,l,i) ((REC_variable<<28)|((h)<<23)|((o)<<19)|(((z)-1)<<18)|((l)<<17)|((i)<<16))
+#define REC_V_RECORD(f,s) (((f)&(((1<<16)-1)<<16))|(s))
+#define REC_V_HEADER(f) (((f)>>23)&((1<<5)-1))
+#define REC_V_OFFSET(f) (((f)>>19)&((1<<4)-1))
+#define REC_V_LENGTH(f) ((((f)>>18)&1)+1)
+#define REC_V_LITTLE(f) (((f)>>17)&1)
+#define REC_V_INCLUSIVE(f) (((f)>>16)&1)
+#define REC_V_SIZE(f) ((f)&((1<<16)-1))
+#define REC_V_ATTRIBUTES(f) ((f)&~((1<<16)-1))
+
+#define REC_M_TYPE(i) ((REC_method<<28)|(i))
+#define REC_M_INDEX(f) ((f)&((1<<28)-1))
+
+#define REC_N_TYPE() 0xffffffff
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ char* fmtrec __PROTO__((Recfmt_t, int));
+extern __MANGLE__ Recfmt_t recfmt __PROTO__((const __V_*, size_t, off_t));
+extern __MANGLE__ Recfmt_t recstr __PROTO__((const char*, char**));
+extern __MANGLE__ ssize_t reclen __PROTO__((Recfmt_t, const __V_*, size_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/regex.h b/usr/src/lib/libast/i386/include/ast/regex.h
new file mode 100644
index 0000000000..b1a8976991
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/regex.h
@@ -0,0 +1,227 @@
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+#ifdef _AST_STD_I
+#define _REGEX_H -1
+#define regex_t int
+#define regmatch_t int
+#endif
+#ifndef _REGEX_H
+#define _REGEX_H 1
+#undef regex_t
+#undef regmatch_t
+
+#include <ast_common.h>
+
+#define REG_VERSION 20030916L
+
+/* regcomp flags */
+
+#define REG_AUGMENTED 0x00000001 /* enable ! & < > */
+#define REG_EXTENDED 0x00000002 /* enable ( | ) */
+#define REG_ICASE 0x00000004 /* ignore case in match */
+#define REG_NEWLINE 0x00000008 /* ^/$ match embedded \n */
+#define REG_NOSUB 0x00000010 /* don't report subexp matches */
+#define REG_SHELL 0x00000020 /* shell pattern syntax */
+
+/* nonstandard regcomp flags */
+
+#define REG_LEFT 0x00000100 /* implicit ^... */
+#define REG_LITERAL 0x00000200 /* no operators */
+#define REG_MINIMAL 0x00000400 /* minimal match */
+#define REG_NULL 0x00000800 /* allow null patterns */
+#define REG_RIGHT 0x00001000 /* implicit ...$ */
+#define REG_LENIENT 0x00002000 /* look the other way */
+#define REG_ESCAPE 0x00004000 /* \ escapes delimiter in [...] */
+#define REG_FIRST 0x00008000 /* first match found will do */
+#define REG_MULTIPLE 0x00010000 /* multiple \n sep patterns */
+#define REG_DISCIPLINE 0x00020000 /* regex_t.re_disc is valid */
+#define REG_SPAN 0x00040000 /* . matches \n */
+#define REG_COMMENT 0x00080000 /* ignore pattern space & #...\n*/
+#define REG_MULTIREF 0x00100000 /* multiple digit backrefs */
+#define REG_MUSTDELIM 0x08000000 /* all delimiters required */
+#define REG_DELIMITED 0x10000000 /* pattern[0] is delimiter */
+#define REG_SHELL_GROUP 0x20000000 /* (|&) inside [@|&](...) only */
+
+#define REG_SHELL_DOT 0x00200000 /* explicit leading . match */
+#define REG_SHELL_ESCAPED 0x00400000 /* \ not special */
+#define REG_SHELL_PATH 0x00800000 /* explicit / match */
+
+/* regexec flags */
+
+#define REG_NOTBOL 0x00000040 /* ^ is not a special char */
+#define REG_NOTEOL 0x00000080 /* $ is not a special char */
+
+/* nonstandard regexec flags */
+
+#define REG_INVERT 0x01000000 /* invert regrexec match sense */
+#define REG_STARTEND 0x02000000 /* subject==match[0].rm_{so,eo} */
+#define REG_ADVANCE 0x04000000 /* advance match[0].rm_{so,eo} */
+
+/* regalloc flags */
+
+#define REG_NOFREE 0x00000001 /* don't free */
+
+/* regsub flags */
+
+#define REG_SUB_ALL 0x00000001 /* substitute all occurrences */
+#define REG_SUB_LOWER 0x00000002 /* substitute to lower case */
+#define REG_SUB_UPPER 0x00000004 /* substitute to upper case */
+#define REG_SUB_PRINT 0x00000010 /* internal no-op */
+#define REG_SUB_NUMBER 0x00000020 /* internal no-op */
+#define REG_SUB_STOP 0x00000040 /* internal no-op */
+#define REG_SUB_WRITE 0x00000080 /* internal no-op */
+#define REG_SUB_LAST 0x00000100 /* last substitution option */
+#define REG_SUB_FULL 0x00000200 /* fully delimited */
+#define REG_SUB_USER 0x00001000 /* first user flag bit */
+
+/* regex error codes */
+
+#define REG_ENOSYS (-1) /* not supported */
+#define REG_NOMATCH 1 /* regexec didn't match */
+#define REG_BADPAT 2 /* invalid regular expression */
+#define REG_ECOLLATE 3 /* invalid collation element */
+#define REG_ECTYPE 4 /* invalid character class */
+#define REG_EESCAPE 5 /* trailing \ in pattern */
+#define REG_ESUBREG 6 /* invalid \digit backreference */
+#define REG_EBRACK 7 /* [...] imbalance */
+#define REG_EPAREN 8 /* \(...\) or (...) imbalance */
+#define REG_EBRACE 9 /* \{...\} or {...} imbalance */
+#define REG_BADBR 10 /* invalid {...} digits */
+#define REG_ERANGE 11 /* invalid [...] range endpoint */
+#define REG_ESPACE 12 /* out of space */
+#define REG_BADRPT 13 /* unary op not preceeded by re */
+#define REG_ENULL 14 /* empty subexpr in pattern */
+#define REG_ECOUNT 15 /* re component count overflow */
+#define REG_BADESC 16 /* invalid \char escape */
+#define REG_VERSIONID 17 /* version id (pseudo error) */
+#define REG_EFLAGS 18 /* flags conflict */
+#define REG_EDELIM 19 /* invalid or omitted delimiter */
+#define REG_PANIC 20 /* unrecoverable internal error */
+
+struct regex_s; typedef struct regex_s regex_t;
+struct regdisc_s; typedef struct regdisc_s regdisc_t;
+
+typedef int (*regclass_t) __PROTO__((int));
+typedef int32_t regflags_t;
+typedef int regoff_t;
+typedef int (*regerror_t) __PROTO__((const regex_t*, regdisc_t*, int, ...));
+typedef __V_* (*regcomp_t) __PROTO__((const regex_t*, const char*, size_t, regdisc_t*));
+typedef int (*regexec_t) __PROTO__((const regex_t*, __V_*, const char*, size_t, const char*, size_t, char**, regdisc_t*));
+typedef __V_* (*regresize_t) __PROTO__((__V_*, __V_*, size_t));
+typedef int (*regrecord_t) __PROTO__((__V_*, const char*, size_t));
+
+typedef struct regmatch_s
+{
+ regoff_t rm_so; /* offset of start */
+ regoff_t rm_eo; /* offset of end */
+} regmatch_t;
+
+typedef struct regsub_s
+{
+ regflags_t re_flags; /* regsubcomp() flags */
+ char* re_buf; /* regsubexec() output buffer */
+ size_t re_len; /* re_buf length */
+ int re_min; /* regsubcomp() min matches */
+#ifdef _REG_SUB_PRIVATE_
+ _REG_SUB_PRIVATE_
+#endif
+} regsub_t;
+
+struct regdisc_s
+{
+ unsigned long re_version; /* discipline version */
+ regflags_t re_flags; /* discipline flags */
+ regerror_t re_errorf; /* error function */
+ int re_errorlevel; /* errorf level */
+ regresize_t re_resizef; /* alloc/free function */
+ __V_* re_resizehandle;/* resizef handle */
+ regcomp_t re_compf; /* (?{...}) compile function */
+ regexec_t re_execf; /* (?{...}) execute function */
+ unsigned char* re_map; /* external to native ccode map */
+};
+
+typedef struct regstat_s
+{
+ regflags_t re_flags; /* REG_LEFT|REG_RIGHT */
+ ssize_t re_min; /* min anchored match length */
+ ssize_t re_max; /* max anchored match length */
+ ssize_t re_record; /* regrexec() match length */
+} regstat_t;
+
+struct regex_s
+{
+ size_t re_nsub; /* number of subexpressions */
+ struct reglib_s*re_info; /* library private info */
+ size_t re_npat; /* number of pattern chars used */
+ regdisc_t* re_disc; /* REG_DISCIPLINE discipline */
+ regsub_t* re_sub; /* regsubcomp() data */
+};
+
+#define reginit(disc) (memset(disc,0,sizeof(*(disc))),(disc)->re_version=REG_VERSION)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int regcomp __PROTO__((regex_t*, const char*, regflags_t));
+extern __MANGLE__ size_t regerror __PROTO__((int, const regex_t*, char*, size_t));
+extern __MANGLE__ int regexec __PROTO__((const regex_t*, const char*, size_t, regmatch_t*, regflags_t));
+extern __MANGLE__ void regfree __PROTO__((regex_t*));
+
+/* nonstandard hooks */
+
+#define _REG_cache 1 /* have regcache() */
+#define _REG_class 1 /* have regclass() */
+#define _REG_collate 1 /* have regcollate(), regclass() */
+#define _REG_comb 1 /* have regcomb() */
+#define _REG_decomp 1 /* have regdecomp() */
+#define _REG_dup 1 /* have regdup() */
+#define _REG_fatal 1 /* have regfatal(), regfatalpat() */
+#define _REG_ncomp 1 /* have regncomp() */
+#define _REG_nexec 1 /* have regnexec() */
+#define _REG_rexec 1 /* have regrexec(), regrecord() */
+#define _REG_stat 1 /* have regstat() */
+#define _REG_subcomp 1 /* have regsubcomp(), regsubexec() */
+
+extern __MANGLE__ regclass_t regclass __PROTO__((const char*, char**));
+extern __MANGLE__ int regaddclass __PROTO__((const char*, regclass_t));
+extern __MANGLE__ int regcollate __PROTO__((const char*, char**, char*, int));
+extern __MANGLE__ int regcomb __PROTO__((regex_t*, regex_t*));
+extern __MANGLE__ size_t regdecomp __PROTO__((regex_t*, regflags_t, char*, size_t));
+extern __MANGLE__ int regdup __PROTO__((regex_t*, regex_t*));
+extern __MANGLE__ int regncomp __PROTO__((regex_t*, const char*, size_t, regflags_t));
+extern __MANGLE__ int regnexec __PROTO__((const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t));
+extern __MANGLE__ void regfatal __PROTO__((regex_t*, int, int));
+extern __MANGLE__ void regfatalpat __PROTO__((regex_t*, int, int, const char*));
+extern __MANGLE__ int regrecord __PROTO__((const regex_t*));
+extern __MANGLE__ int regrexec __PROTO__((const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t, int, __V_*, regrecord_t));
+extern __MANGLE__ regstat_t* regstat __PROTO__((const regex_t*));
+
+extern __MANGLE__ regex_t* regcache __PROTO__((const char*, regflags_t, int*));
+
+extern __MANGLE__ int regsubcomp __PROTO__((regex_t*, const char*, const regflags_t*, int, regflags_t));
+extern __MANGLE__ int regsubexec __PROTO__((const regex_t*, const char*, size_t, regmatch_t*));
+extern __MANGLE__ int regsubflags __PROTO__((regex_t*, const char*, char**, int, const regflags_t*, int*, regflags_t*));
+extern __MANGLE__ void regsubfree __PROTO__((regex_t*));
+
+/* obsolete hooks */
+
+#ifndef _SFIO_H
+struct _sfio_s;
+#endif
+
+extern __MANGLE__ void regalloc __PROTO__((__V_*, regresize_t, regflags_t));
+extern __MANGLE__ int regsub __PROTO__((const regex_t*, struct _sfio_s*, const char*, const char*, size_t, regmatch_t*, regflags_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/regexp.h b/usr/src/lib/libast/i386/include/ast/regexp.h
new file mode 100644
index 0000000000..b7f3ed6313
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/regexp.h
@@ -0,0 +1,139 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * regexp interface and partial implementation
+ * what a novel approach
+ * don't do it again
+ *
+ * OBSOLETE: use <regex.h>
+ */
+
+#ifndef _REGEXP_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _REGEXP_H
+
+#define NBRA 9
+
+typedef struct
+{
+ char* re_braslist[NBRA];
+ char* re_braelist[NBRA];
+ char* re_loc1;
+ char* re_loc2;
+ char* re_locs;
+ int re_circf;
+ int re_nbra;
+ int re_nodelim;
+ int re_sed;
+} regexp_t;
+
+#define braslist _re_info.re_braslist
+#define braelist _re_info.re_braelist
+#define circf _re_info.re_circf
+#define loc1 _re_info.re_loc1
+#define loc2 _re_info.re_loc2
+#define locs _re_info.re_locs
+#define nbra _re_info.re_nbra
+#define nodelim _re_info.re_nodelim
+#define sed _re_info.re_sed
+
+#define advance(a,b) _re_exec(&_re_info,a,b,1)
+#define compile(a,b,c,d) _re_read(&_re_info,a,b,c,d)
+#define step(a,b) _re_exec(&_re_info,a,b,0)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _re_comp __PROTO__((regexp_t*, const char*, char*, unsigned int));
+extern __MANGLE__ int _re_exec __PROTO__((regexp_t*, const char*, const char*, int));
+extern __MANGLE__ char* _re_putc __PROTO__((int));
+extern __MANGLE__ char* _re_read __PROTO__((regexp_t*, const char*, char*, const char*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#ifndef _REGEXP_DECLARE
+
+regexp_t _re_info;
+
+char*
+_re_read __PARAM__((register regexp_t* re, const char* instring, char* ep, const char* endbuf, int seof), (re, instring, ep, endbuf, seof)) __OTORP__(register regexp_t* re; const char* instring; char* ep; const char* endbuf; int seof;){
+ register int c;
+
+ static const char* prev;
+
+#ifdef INIT
+ INIT;
+#endif
+
+ re->re_nodelim = 0;
+ if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0)
+ {
+ if (c != seof)
+ {
+ UNGETC(c);
+ re->re_nodelim = 1;
+ }
+ if (!re->re_sed && !prev)
+ { ERROR(41); }
+ RETURN((char*)endbuf);
+ }
+ UNGETC(c);
+ prev = 0;
+ for (;;)
+ {
+ if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0)
+ {
+ if (re->re_sed)
+ { ERROR(36); }
+ UNGETC(c);
+ re->re_nodelim = 1;
+ break;
+ }
+ if (c == '\\')
+ {
+ _re_putc(c);
+ if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0)
+ { ERROR(36); }
+ }
+ _re_putc(c);
+ }
+ if (c = _re_comp(re, _re_putc(0), ep, (char*)endbuf - ep))
+ { ERROR(c); }
+ prev = endbuf;
+ RETURN((char*)prev);
+}
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/sfdisc.h b/usr/src/lib/libast/i386/include/ast/sfdisc.h
new file mode 100644
index 0000000000..9e657f045b
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/sfdisc.h
@@ -0,0 +1,82 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * AT&T Research
+ *
+ * sfio discipline interface definitions
+ */
+
+#ifndef _SFDISC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SFDISC_H
+
+#include <ast.h>
+
+#define SFDCEVENT(a,b,n) ((((a)-'A'+1)<<11)^(((b)-'A'+1)<<6)^(n))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#define SFSK_DISCARD SFDCEVENT('S','K',1)
+
+/*
+ * %(...) printf support
+ */
+
+typedef int (*Sf_key_lookup_t) __PROTO__((__V_*, Sffmt_t*, const char*, char**, Sflong_t*));
+typedef char* (*Sf_key_convert_t) __PROTO__((__V_*, Sffmt_t*, const char*, char*, Sflong_t));
+
+extern __MANGLE__ int sfkeyprintf __PROTO__((Sfio_t*, __V_*, const char*, Sf_key_lookup_t, Sf_key_convert_t));
+#define sfkeyprintf sfkeyprintf_20000308 /* Sffmt_t* callback args */
+extern __MANGLE__ int sfkeyprintf __PROTO__((Sfio_t*, __V_*, const char*, Sf_key_lookup_t, Sf_key_convert_t));
+
+/*
+ * pure sfio read and/or write disciplines
+ */
+
+extern __MANGLE__ int sfdcdio __PROTO__((Sfio_t*, size_t));
+extern __MANGLE__ int sfdcdos __PROTO__((Sfio_t*));
+extern __MANGLE__ int sfdcfilter __PROTO__((Sfio_t*, const char*));
+extern __MANGLE__ int sfdcmore __PROTO__((Sfio_t*, const char*, int, int));
+extern __MANGLE__ int sfdcprefix __PROTO__((Sfio_t*, const char*));
+extern __MANGLE__ int sfdcseekable __PROTO__((Sfio_t*));
+extern __MANGLE__ int sfdcslow __PROTO__((Sfio_t*));
+extern __MANGLE__ int sfdctee __PROTO__((Sfio_t*, Sfio_t*));
+extern __MANGLE__ int sfdcunion __PROTO__((Sfio_t*, Sfio_t**, int));
+
+extern __MANGLE__ Sfio_t* sfdcsubstream __PROTO__((Sfio_t*, Sfio_t*, Sfoff_t, Sfoff_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/sfio.h b/usr/src/lib/libast/i386/include/ast/sfio.h
new file mode 100644
index 0000000000..9feba3043e
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/sfio.h
@@ -0,0 +1,452 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _SFIO_H
+#define _SFIO_H 1
+
+#define SFIO_VERSION 20050202L
+
+/* Public header file for the sfio library
+**
+** Written by Kiem-Phong Vo
+*/
+
+typedef struct _sfio_s Sfio_t;
+typedef struct _sfdisc_s Sfdisc_t;
+
+#if defined(_AST_STD_H) || defined(_PACKAGE_ast) && defined(_SFIO_PRIVATE)
+#include <ast_std.h>
+#else
+#include <ast_common.h>
+#endif /* _PACKAGE_ast */
+
+/* Sfoff_t should be large enough for largest file address */
+#define Sfoff_t intmax_t
+#define Sflong_t intmax_t
+#define Sfulong_t uintmax_t
+#define Sfdouble_t _ast_fltmax_t
+
+typedef ssize_t (*Sfread_f)_ARG_((Sfio_t*, Void_t*, size_t, Sfdisc_t*));
+typedef ssize_t (*Sfwrite_f)_ARG_((Sfio_t*, const Void_t*, size_t, Sfdisc_t*));
+typedef Sfoff_t (*Sfseek_f)_ARG_((Sfio_t*, Sfoff_t, int, Sfdisc_t*));
+typedef int (*Sfexcept_f)_ARG_((Sfio_t*, int, Void_t*, Sfdisc_t*));
+
+/* discipline structure */
+struct _sfdisc_s
+{ Sfread_f readf; /* read function */
+ Sfwrite_f writef; /* write function */
+ Sfseek_f seekf; /* seek function */
+ Sfexcept_f exceptf; /* to handle exceptions */
+ Sfdisc_t* disc; /* the continuing discipline */
+};
+
+#include <sfio_s.h>
+
+/* formatting environment */
+typedef struct _sffmt_s Sffmt_t;
+typedef int (*Sffmtext_f)_ARG_((Sfio_t*, Void_t*, Sffmt_t*));
+typedef int (*Sffmtevent_f)_ARG_((Sfio_t*, int, Void_t*, Sffmt_t*));
+struct _sffmt_s
+{ long version;/* version of this structure */
+ Sffmtext_f extf; /* function to process arguments */
+ Sffmtevent_f eventf; /* process events */
+
+ char* form; /* format string to stack */
+ va_list args; /* corresponding arg list */
+
+ int fmt; /* format character */
+ ssize_t size; /* object size */
+ int flags; /* formatting flags */
+ int width; /* width of field */
+ int precis; /* precision required */
+ int base; /* conversion base */
+
+ char* t_str; /* type string */
+ ssize_t n_str; /* length of t_str */
+
+ Void_t* mbs; /* multibyte state for format string */
+
+ Void_t* none; /* unused for now */
+};
+#define sffmtversion(fe,type) \
+ ((type) ? ((fe)->version = SFIO_VERSION) : (fe)->version)
+
+#define SFFMT_SSHORT 000000010 /* 'hh' flag, char */
+#define SFFMT_TFLAG 000000020 /* 't' flag, ptrdiff_t */
+#define SFFMT_ZFLAG 000000040 /* 'z' flag, size_t */
+
+#define SFFMT_LEFT 000000100 /* left-justification */
+#define SFFMT_SIGN 000000200 /* must have a sign */
+#define SFFMT_BLANK 000000400 /* if not signed, prepend a blank */
+#define SFFMT_ZERO 000001000 /* zero-padding on the left */
+#define SFFMT_ALTER 000002000 /* alternate formatting */
+#define SFFMT_THOUSAND 000004000 /* thousand grouping */
+#define SFFMT_SKIP 000010000 /* skip assignment in scanf() */
+#define SFFMT_SHORT 000020000 /* 'h' flag */
+#define SFFMT_LONG 000040000 /* 'l' flag */
+#define SFFMT_LLONG 000100000 /* 'll' flag */
+#define SFFMT_LDOUBLE 000200000 /* 'L' flag */
+#define SFFMT_VALUE 000400000 /* value is returned */
+#define SFFMT_ARGPOS 001000000 /* getting arg for $ patterns */
+#define SFFMT_IFLAG 002000000 /* 'I' flag */
+#define SFFMT_JFLAG 004000000 /* 'j' flag, intmax_t */
+#define SFFMT_CENTER 010000000 /* '=' flag, center justification */
+#define SFFMT_SET 017777770 /* flags settable on calling extf */
+
+/* for sfmutex() call */
+#define SFMTX_LOCK 0 /* up mutex count */
+#define SFMTX_TRYLOCK 1 /* try to up mutex count */
+#define SFMTX_UNLOCK 2 /* down mutex count */
+#define SFMTX_CLRLOCK 3 /* clear mutex count */
+
+/* various constants */
+#ifndef NULL
+#define NULL 0
+#endif
+#ifndef EOF
+#define EOF (-1)
+#endif
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+/* bits for various types of files */
+#define SF_READ 0000001 /* open for reading */
+#define SF_WRITE 0000002 /* open for writing */
+#define SF_STRING 0000004 /* a string stream */
+#define SF_APPENDWR 0000010 /* file is in append mode only */
+#define SF_MALLOC 0000020 /* buffer is malloc-ed */
+#define SF_LINE 0000040 /* line buffering */
+#define SF_SHARE 0000100 /* stream with shared file descriptor */
+#define SF_EOF 0000200 /* eof was detected */
+#define SF_ERROR 0000400 /* an error happened */
+#define SF_STATIC 0001000 /* a stream that cannot be freed */
+#define SF_IOCHECK 0002000 /* call exceptf before doing IO */
+#define SF_PUBLIC 0004000 /* SF_SHARE and follow physical seek */
+#define SF_MTSAFE 0010000 /* need thread safety */
+#define SF_WHOLE 0020000 /* preserve wholeness of sfwrite/sfputr */
+#define SF_IOINTR 0040000 /* return on interrupts */
+#define SF_WCWIDTH 0100000 /* wcwidth display stream */
+
+#define SF_FLAGS 0177177 /* PUBLIC FLAGS PASSABLE TO SFNEW() */
+#define SF_SETS 0177163 /* flags passable to sfset() */
+
+#ifndef _SF_NO_OBSOLETE
+#define SF_BUFCONST 0400000 /* unused flag - for compatibility only */
+#endif
+
+/* for sfgetr/sfreserve to hold a record */
+#define SF_LOCKR 0000010 /* lock record, stop access to stream */
+#define SF_LASTR 0000020 /* get the last incomplete record */
+
+/* exception events: SF_NEW(0), SF_READ(1), SF_WRITE(2) and the below */
+#define SF_SEEK 3 /* seek error */
+#define SF_CLOSING 4 /* when stream is about to be closed */
+#define SF_DPUSH 5 /* when discipline is being pushed */
+#define SF_DPOP 6 /* when discipline is being popped */
+#define SF_DPOLL 7 /* see if stream is ready for I/O */
+#define SF_DBUFFER 8 /* buffer not empty during push or pop */
+#define SF_SYNC 9 /* announcing start/end synchronization */
+#define SF_PURGE 10 /* a sfpurge() call was issued */
+#define SF_FINAL 11 /* closing is done except stream free */
+#define SF_READY 12 /* a polled stream is ready */
+#define SF_LOCKED 13 /* stream is in a locked state */
+#define SF_ATEXIT 14 /* process is exiting */
+#define SF_EVENT 100 /* start of user-defined events */
+
+/* for stack and disciplines */
+#define SF_POPSTACK ((Sfio_t*)0) /* pop the stream stack */
+#define SF_POPDISC ((Sfdisc_t*)0) /* pop the discipline stack */
+
+/* for the notify function and discipline exception */
+#define SF_NEW 0 /* new stream */
+#define SF_SETFD (-1) /* about to set the file descriptor */
+
+#define SF_BUFSIZE 8192 /* default buffer size */
+#define SF_UNBOUND (-1) /* unbounded buffer size */
+
+/* namespace incursion workarounds -- migrate to the new names */
+#if !_mac_SF_APPEND
+#define SF_APPEND SF_APPENDWR /* BSDI sys/stat.h */
+#endif
+#if !_mac_SF_CLOSE
+#define SF_CLOSE SF_CLOSING /* AIX sys/socket.h */
+#endif
+
+_BEGIN_EXTERNS_
+
+/* standard in/out/err streams */
+
+#if _BLD_sfio && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+#if !_BLD_sfio && defined(__IMPORT__)
+#define extern extern __IMPORT__
+#endif
+
+extern ssize_t _Sfi;
+extern ssize_t _Sfmaxr;
+
+extern Sfio_t* sfstdin;
+extern Sfio_t* sfstdout;
+extern Sfio_t* sfstderr;
+
+#if _UWIN
+#undef extern
+#endif
+
+extern Sfio_t _Sfstdin;
+extern Sfio_t _Sfstdout;
+extern Sfio_t _Sfstderr;
+
+#undef extern
+
+#if _BLD_sfio && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Sfio_t* sfnew _ARG_((Sfio_t*, Void_t*, size_t, int, int));
+extern Sfio_t* sfopen _ARG_((Sfio_t*, const char*, const char*));
+extern Sfio_t* sfpopen _ARG_((Sfio_t*, const char*, const char*));
+extern Sfio_t* sfstack _ARG_((Sfio_t*, Sfio_t*));
+extern Sfio_t* sfswap _ARG_((Sfio_t*, Sfio_t*));
+extern Sfio_t* sftmp _ARG_((size_t));
+extern int sfpurge _ARG_((Sfio_t*));
+extern int sfpoll _ARG_((Sfio_t**, int, int));
+extern Void_t* sfreserve _ARG_((Sfio_t*, ssize_t, int));
+extern int sfresize _ARG_((Sfio_t*, Sfoff_t));
+extern int sfsync _ARG_((Sfio_t*));
+extern int sfclrlock _ARG_((Sfio_t*));
+extern Void_t* sfsetbuf _ARG_((Sfio_t*, Void_t*, size_t));
+extern Sfdisc_t* sfdisc _ARG_((Sfio_t*,Sfdisc_t*));
+extern int sfraise _ARG_((Sfio_t*, int, Void_t*));
+extern int sfnotify _ARG_((void(*)(Sfio_t*, int, int)));
+extern int sfset _ARG_((Sfio_t*, int, int));
+extern int sfsetfd _ARG_((Sfio_t*, int));
+extern Sfio_t* sfpool _ARG_((Sfio_t*, Sfio_t*, int));
+extern ssize_t sfread _ARG_((Sfio_t*, Void_t*, size_t));
+extern ssize_t sfwrite _ARG_((Sfio_t*, const Void_t*, size_t));
+extern Sfoff_t sfmove _ARG_((Sfio_t*, Sfio_t*, Sfoff_t, int));
+extern int sfclose _ARG_((Sfio_t*));
+extern Sfoff_t sftell _ARG_((Sfio_t*));
+extern Sfoff_t sfseek _ARG_((Sfio_t*, Sfoff_t, int));
+extern ssize_t sfputr _ARG_((Sfio_t*, const char*, int));
+extern char* sfgetr _ARG_((Sfio_t*, int, int));
+extern ssize_t sfnputc _ARG_((Sfio_t*, int, size_t));
+extern int sfungetc _ARG_((Sfio_t*, int));
+extern int sfprintf _ARG_((Sfio_t*, const char*, ...));
+extern char* sfprints _ARG_((const char*, ...));
+extern ssize_t sfsprintf _ARG_((char*, size_t, const char*, ...));
+extern ssize_t sfvsprintf _ARG_((char*, size_t, const char*, va_list));
+extern int sfvprintf _ARG_((Sfio_t*, const char*, va_list));
+extern int sfscanf _ARG_((Sfio_t*, const char*, ...));
+extern int sfsscanf _ARG_((const char*, const char*, ...));
+extern int sfvsscanf _ARG_((const char*, const char*, va_list));
+extern int sfvscanf _ARG_((Sfio_t*, const char*, va_list));
+
+/* mutex locking for thread-safety */
+extern int sfmutex _ARG_((Sfio_t*, int));
+
+/* io functions with discipline continuation */
+extern ssize_t sfrd _ARG_((Sfio_t*, Void_t*, size_t, Sfdisc_t*));
+extern ssize_t sfwr _ARG_((Sfio_t*, const Void_t*, size_t, Sfdisc_t*));
+extern Sfoff_t sfsk _ARG_((Sfio_t*, Sfoff_t, int, Sfdisc_t*));
+extern ssize_t sfpkrd _ARG_((int, Void_t*, size_t, int, long, int));
+
+/* portable handling of primitive types */
+extern int sfdlen _ARG_((Sfdouble_t));
+extern int sfllen _ARG_((Sflong_t));
+extern int sfulen _ARG_((Sfulong_t));
+
+extern int sfputd _ARG_((Sfio_t*, Sfdouble_t));
+extern int sfputl _ARG_((Sfio_t*, Sflong_t));
+extern int sfputu _ARG_((Sfio_t*, Sfulong_t));
+extern int sfputm _ARG_((Sfio_t*, Sfulong_t, Sfulong_t));
+extern int sfputc _ARG_((Sfio_t*, int));
+
+extern Sfdouble_t sfgetd _ARG_((Sfio_t*));
+extern Sflong_t sfgetl _ARG_((Sfio_t*));
+extern Sfulong_t sfgetu _ARG_((Sfio_t*));
+extern Sfulong_t sfgetm _ARG_((Sfio_t*, Sfulong_t));
+extern int sfgetc _ARG_((Sfio_t*));
+
+extern int _sfputd _ARG_((Sfio_t*, Sfdouble_t));
+extern int _sfputl _ARG_((Sfio_t*, Sflong_t));
+extern int _sfputu _ARG_((Sfio_t*, Sfulong_t));
+extern int _sfputm _ARG_((Sfio_t*, Sfulong_t, Sfulong_t));
+extern int _sfflsbuf _ARG_((Sfio_t*, int));
+
+extern int _sffilbuf _ARG_((Sfio_t*, int));
+
+extern int _sfdlen _ARG_((Sfdouble_t));
+extern int _sfllen _ARG_((Sflong_t));
+extern int _sfulen _ARG_((Sfulong_t));
+
+/* miscellaneous function analogues of fast in-line functions */
+extern Sfoff_t sfsize _ARG_((Sfio_t*));
+extern int sfclrerr _ARG_((Sfio_t*));
+extern int sfeof _ARG_((Sfio_t*));
+extern int sferror _ARG_((Sfio_t*));
+extern int sffileno _ARG_((Sfio_t*));
+extern int sfstacked _ARG_((Sfio_t*));
+extern ssize_t sfvalue _ARG_((Sfio_t*));
+extern ssize_t sfslen _ARG_((void));
+extern ssize_t sfmaxr _ARG_((ssize_t, int));
+
+#undef extern
+_END_EXTERNS_
+
+/* coding long integers in a portable and compact fashion */
+#define SF_SBITS 6
+#define SF_UBITS 7
+#define SF_BBITS 8
+#define SF_SIGN (1 << SF_SBITS)
+#define SF_MORE (1 << SF_UBITS)
+#define SF_BYTE (1 << SF_BBITS)
+#define SF_U1 SF_MORE
+#define SF_U2 (SF_U1*SF_U1)
+#define SF_U3 (SF_U2*SF_U1)
+#define SF_U4 (SF_U3*SF_U1)
+
+#if __cplusplus
+#define _SF_(f) (f)
+#else
+#define _SF_(f) ((Sfio_t*)(f))
+#endif
+
+#define __sf_putd(f,v) (_sfputd(_SF_(f),(Sfdouble_t)(v)))
+#define __sf_putl(f,v) (_sfputl(_SF_(f),(Sflong_t)(v)))
+#define __sf_putu(f,v) (_sfputu(_SF_(f),(Sfulong_t)(v)))
+#define __sf_putm(f,v,m) (_sfputm(_SF_(f),(Sfulong_t)(v),(Sfulong_t)(m)))
+
+#define __sf_putc(f,c) (_SF_(f)->_next >= _SF_(f)->_endw ? \
+ _sfflsbuf(_SF_(f),(int)((unsigned char)(c))) : \
+ (int)(*_SF_(f)->_next++ = (unsigned char)(c)) )
+#define __sf_getc(f) (_SF_(f)->_next >= _SF_(f)->_endr ? _sffilbuf(_SF_(f),0) : \
+ (int)(*_SF_(f)->_next++) )
+
+#define __sf_dlen(v) (_sfdlen((Sfdouble_t)(v)) )
+#define __sf_llen(v) (_sfllen((Sflong_t)(v)) )
+#define __sf_ulen(v) ((Sfulong_t)(v) < SF_U1 ? 1 : (Sfulong_t)(v) < SF_U2 ? 2 : \
+ (Sfulong_t)(v) < SF_U3 ? 3 : (Sfulong_t)(v) < SF_U4 ? 4 : 5)
+
+#define __sf_fileno(f) (_SF_(f)->_file)
+#define __sf_eof(f) (_SF_(f)->_flags&SF_EOF)
+#define __sf_error(f) (_SF_(f)->_flags&SF_ERROR)
+#define __sf_clrerr(f) (_SF_(f)->_flags &= ~(SF_ERROR|SF_EOF))
+#define __sf_stacked(f) (_SF_(f)->_push != (Sfio_t*)0)
+#define __sf_value(f) (_SF_(f)->_val)
+#define __sf_slen() (_Sfi)
+#define __sf_maxr(n,s) ((s)?((_Sfi=_Sfmaxr),(_Sfmaxr=(n)),_Sfi):_Sfmaxr)
+
+#if defined(__INLINE__) && !_BLD_sfio
+
+__INLINE__ int sfputd(Sfio_t* f, Sfdouble_t v) { return __sf_putd(f,v); }
+__INLINE__ int sfputl(Sfio_t* f, Sflong_t v) { return __sf_putl(f,v); }
+__INLINE__ int sfputu(Sfio_t* f, Sfulong_t v) { return __sf_putu(f,v); }
+__INLINE__ int sfputm(Sfio_t* f, Sfulong_t v, Sfulong_t m)
+ { return __sf_putm(f,v,m); }
+
+__INLINE__ int sfputc(Sfio_t* f, int c) { return __sf_putc(f,c); }
+__INLINE__ int sfgetc(Sfio_t* f) { return __sf_getc(f); }
+
+__INLINE__ int sfdlen(Sfdouble_t v) { return __sf_dlen(v); }
+__INLINE__ int sfllen(Sflong_t v) { return __sf_llen(v); }
+__INLINE__ int sfulen(Sfulong_t v) { return __sf_ulen(v); }
+
+__INLINE__ int sffileno(Sfio_t* f) { return __sf_fileno(f); }
+__INLINE__ int sfeof(Sfio_t* f) { return __sf_eof(f); }
+__INLINE__ int sferror(Sfio_t* f) { return __sf_error(f); }
+__INLINE__ int sfclrerr(Sfio_t* f) { return __sf_clrerr(f); }
+__INLINE__ int sfstacked(Sfio_t* f) { return __sf_stacked(f); }
+__INLINE__ ssize_t sfvalue(Sfio_t* f) { return __sf_value(f); }
+__INLINE__ ssize_t sfslen() { return __sf_slen(); }
+__INLINE__ ssize_t sfmaxr(ssize_t n, int s) { return __sf_maxr(n,s); }
+
+#else
+
+#define sfputd(f,v) ( __sf_putd((f),(v)) )
+#define sfputl(f,v) ( __sf_putl((f),(v)) )
+#define sfputu(f,v) ( __sf_putu((f),(v)) )
+#define sfputm(f,v,m) ( __sf_putm((f),(v),(m)) )
+
+#define sfputc(f,c) ( __sf_putc((f),(c)) )
+#define sfgetc(f) ( __sf_getc(f) )
+
+#define sfdlen(v) ( __sf_dlen(v) )
+#define sfllen(v) ( __sf_llen(v) )
+#define sfulen(v) ( __sf_ulen(v) )
+
+#define sffileno(f) ( __sf_fileno(f) )
+#define sfeof(f) ( __sf_eof(f) )
+#define sferror(f) ( __sf_error(f) )
+#define sfclrerr(f) ( __sf_clrerr(f) )
+#define sfstacked(f) ( __sf_stacked(f) )
+#define sfvalue(f) ( __sf_value(f) )
+#define sfslen() ( __sf_slen() )
+#define sfmaxr(n,s) ( __sf_maxr(n,s) )
+
+#endif /*__INLINE__*/
+
+#ifndef _SFSTR_H /* GSF's string manipulation stuff */
+#define _SFSTR_H 1
+
+#define sfstropen() sfnew(0, 0, -1, -1, SF_READ|SF_WRITE|SF_STRING)
+#define sfstrclose(f) sfclose(f)
+
+#define sfstrseek(f,p,m) \
+ ( (m) == SEEK_SET ? \
+ (((p) < 0 || (p) > (f)->_size) ? (char*)0 : \
+ (char*)((f)->_next = (f)->_data+(p)) ) \
+ : (m) == SEEK_CUR ? \
+ ((f)->_next += (p), \
+ (((f)->_next < (f)->_data || (f)->_next > (f)->_data+(f)->_size) ? \
+ ((f)->_next -= (p), (char*)0) : (char*)(f)->_next ) ) \
+ : (m) == SEEK_END ? \
+ ( ((p) > 0 || (f)->_size+(p) < 0) ? (char*)0 : \
+ (char*)((f)->_next = (f)->_data+(f)->_size+(p)) ) \
+ : (char*)0 \
+ )
+
+#define sfstrsize(f) ((f)->_size)
+#define sfstrtell(f) ((f)->_next - (f)->_data)
+#define sfstrpend(f) ((f)->_size - sfstrtell())
+#define sfstrbase(f) ((char*)(f)->_data)
+
+#define sfstruse(f) \
+ (sfputc((f),0) < 0 ? (char*)0 : (char*)((f)->_next = (f)->_data) \
+ )
+
+#define sfstrrsrv(f,n) \
+ (sfreserve((f),(n),SF_WRITE|SF_LOCKR), sfwrite((f),(f)->_next,0), \
+ ((f)->_next+(n) <= (f)->_data+(f)->_size ? (char*)(f)->_next : (char*)0) \
+ )
+
+#define sfstrbuf(f,b,n,m) \
+ (sfsetbuf((f),(b),(n)), ((f)->_flags |= (m) ? SF_MALLOC : 0), \
+ ((f)->_data == (unsigned char*)(b) ? 0 : -1) \
+ )
+
+#endif /* _SFSTR_H */
+
+#endif /* _SFIO_H */
diff --git a/usr/src/lib/libast/i386/include/ast/sfio_s.h b/usr/src/lib/libast/i386/include/ast/sfio_s.h
new file mode 100644
index 0000000000..27936a16b1
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/sfio_s.h
@@ -0,0 +1,51 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _SFIO_S_H
+#define _SFIO_S_H 1
+
+/*
+ * sfio file structure used by sfio and the stdio source compatibility library
+ */
+
+#if !defined(_SFHDR_H) && defined(_SFIO_H) && SFIO_VERSION < 20020214L
+#define _data data
+#define _endb endb
+#define _next next
+#endif
+
+struct _sfio_s
+{ unsigned char* _next; /* next position to read/write from */
+ unsigned char* _endw; /* end of write buffer */
+ unsigned char* _endr; /* end of read buffer */
+ unsigned char* _endb; /* end of buffer */
+ struct _sfio_s* _push; /* the stream that was pushed on */
+ unsigned short _flags; /* type of stream */
+ short _file; /* file descriptor */
+ unsigned char* _data; /* base of data buffer */
+ ssize_t _size; /* buffer size */
+ ssize_t _val; /* values or string lengths */
+#ifdef _SFIO_PRIVATE
+ _SFIO_PRIVATE
+#endif
+};
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/sfio_t.h b/usr/src/lib/libast/i386/include/ast/sfio_t.h
new file mode 100644
index 0000000000..36be6ecc94
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/sfio_t.h
@@ -0,0 +1,126 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _SFIO_T_H
+#define _SFIO_T_H 1
+
+/* This header file is for library writers who need to know certain
+** internal info concerning the full Sfio_t structure. Including this
+** file means that you agree to track closely with sfio development
+** in case its internal architecture is changed.
+**
+** Written by Kiem-Phong Vo
+*/
+
+/* the parts of Sfio_t private to sfio functions */
+#define _SFIO_PRIVATE \
+ Sfoff_t extent; /* current file size */ \
+ Sfoff_t here; /* current physical location */ \
+ unsigned char getr; /* the last sfgetr separator */ \
+ unsigned char tiny[1];/* for unbuffered read stream */ \
+ unsigned short bits; /* private flags */ \
+ unsigned int mode; /* current io mode */ \
+ struct _sfdisc_s* disc; /* discipline */ \
+ struct _sfpool_s* pool; /* the pool containing this */ \
+ struct _sfrsrv_s* rsrv; /* reserved buffer */ \
+ struct _sfproc_s* proc; /* coprocess id, etc. */ \
+ Void_t* mutex; /* mutex for thread-safety */ \
+ Void_t* stdio; /* stdio FILE if any */ \
+ Sfoff_t lpos; /* last seek position */ \
+ size_t iosz; /* preferred size for I/O */ \
+ size_t blksz; /* preferred block size */ \
+ Void_t* fill[1];/* modest expansion */
+
+#include "sfio.h"
+
+/* mode bit to indicate that the structure hasn't been initialized */
+#define SF_INIT 0000004
+#define SF_DCDOWN 00010000
+
+/* short-hand for common stream types */
+#define SF_RDWR (SF_READ|SF_WRITE)
+#define SF_RDSTR (SF_READ|SF_STRING)
+#define SF_WRSTR (SF_WRITE|SF_STRING)
+#define SF_RDWRSTR (SF_RDWR|SF_STRING)
+
+/* for static initialization of an Sfio_t structure */
+#define SFNEW(data,size,file,type,disc,mutex) \
+ { (unsigned char*)(data), /* next */ \
+ (unsigned char*)(data), /* endw */ \
+ (unsigned char*)(data), /* endr */ \
+ (unsigned char*)(data), /* endb */ \
+ (Sfio_t*)0, /* push */ \
+ (unsigned short)((type)&SF_FLAGS), /* flags */ \
+ (short)(file), /* file */ \
+ (unsigned char*)(data), /* data */ \
+ (ssize_t)(size), /* size */ \
+ (ssize_t)(-1), /* val */ \
+ (Sfoff_t)0, /* extent */ \
+ (Sfoff_t)0, /* here */ \
+ 0, /* getr */ \
+ {0}, /* tiny */ \
+ 0, /* bits */ \
+ (unsigned int)(((type)&(SF_RDWR))|SF_INIT), /* mode */ \
+ (struct _sfdisc_s*)(disc), /* disc */ \
+ (struct _sfpool_s*)0, /* pool */ \
+ (struct _sfrsrv_s*)0, /* rsrv */ \
+ (struct _sfproc_s*)0, /* proc */ \
+ (mutex), /* mutex */ \
+ (Void_t*)0, /* stdio */ \
+ (Sfoff_t)0, /* lpos */ \
+ (size_t)0 /* iosz */ \
+ }
+
+/* function to clear an Sfio_t structure */
+#define SFCLEAR(f,mtx) \
+ ( (f)->next = (unsigned char*)0, /* next */ \
+ (f)->endw = (unsigned char*)0, /* endw */ \
+ (f)->endr = (unsigned char*)0, /* endr */ \
+ (f)->endb = (unsigned char*)0, /* endb */ \
+ (f)->push = (Sfio_t*)0, /* push */ \
+ (f)->flags = (unsigned short)0, /* flags */ \
+ (f)->file = -1, /* file */ \
+ (f)->data = (unsigned char*)0, /* data */ \
+ (f)->size = (ssize_t)(-1), /* size */ \
+ (f)->val = (ssize_t)(-1), /* val */ \
+ (f)->extent = (Sfoff_t)(-1), /* extent */ \
+ (f)->here = (Sfoff_t)0, /* here */ \
+ (f)->getr = 0, /* getr */ \
+ (f)->tiny[0] = 0, /* tiny */ \
+ (f)->bits = 0, /* bits */ \
+ (f)->mode = 0, /* mode */ \
+ (f)->disc = (struct _sfdisc_s*)0, /* disc */ \
+ (f)->pool = (struct _sfpool_s*)0, /* pool */ \
+ (f)->rsrv = (struct _sfrsrv_s*)0, /* rsrv */ \
+ (f)->proc = (struct _sfproc_s*)0, /* proc */ \
+ (f)->mutex = (mtx), /* mutex */ \
+ (f)->stdio = (Void_t*)0, /* stdio */ \
+ (f)->lpos = (Sfoff_t)0, /* lpos */ \
+ (f)->iosz = (size_t)0 /* iosz */ \
+ )
+
+/* expose next stream inside discipline function; state saved in int f */
+#define SFDCNEXT(sp,f) (((f)=(sp)->bits&SF_DCDOWN),(sp)->bits|=SF_DCDOWN)
+
+/* restore SFDCNEXT() state from int f */
+#define SFDCPREV(sp,f) ((f)?(0):((sp)->bits&=~SF_DCDOWN))
+
+#endif /* _SFIO_T_H */
diff --git a/usr/src/lib/libast/i386/include/ast/sig.h b/usr/src/lib/libast/i386/include/ast/sig.h
new file mode 100644
index 0000000000..267f3b5959
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/sig.h
@@ -0,0 +1,152 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/sig.sh by iffe version 2007-04-04 : : */
+#ifndef _def_sig_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_sig_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define sig_info _sig_info_
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide kill killpg
+#else
+#define kill ______kill
+#define killpg ______killpg
+#endif
+#include <signal.h>
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide kill killpg
+#else
+#undef kill
+#undef killpg
+#endif
+#ifndef sigmask
+#define sigmask(s) (1<<((s)-1))
+#endif
+typedef void (*Sig_handler_t) __PROTO__((int));
+
+
+#define Handler_t Sig_handler_t
+
+#define SIG_REG_PENDING (-1)
+#define SIG_REG_POP 0
+#define SIG_REG_EXEC 00001
+#define SIG_REG_PROC 00002
+#define SIG_REG_TERM 00004
+#define SIG_REG_ALL 00777
+#define SIG_REG_SET 01000
+
+typedef struct
+{
+ char** name;
+ char** text;
+ int sigmax;
+} Sig_info_t;
+
+extern __MANGLE__ int kill __PROTO__((pid_t, int));
+extern __MANGLE__ int killpg __PROTO__((pid_t, int));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Sig_info_t sig_info;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int sigcritical __PROTO__((int));
+extern __MANGLE__ int sigunblock __PROTO__((int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/stack.h b/usr/src/lib/libast/i386/include/ast/stack.h
new file mode 100644
index 0000000000..ad32ebb8ab
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/stack.h
@@ -0,0 +1,94 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * homogenous stack routine definitions
+ */
+
+#ifndef _STACK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _STACK_H
+
+typedef struct stacktable* STACK; /* stack pointer */
+typedef struct stackposition STACKPOS; /* stack position */
+
+struct stackblock /* stack block cell */
+{
+ __V_** stack; /* actual stack */
+ struct stackblock* prev; /* previous block in list */
+ struct stackblock* next; /* next block in list */
+};
+
+struct stackposition /* stack position */
+{
+ struct stackblock* block; /* current block pointer */
+ int index; /* index within current block */
+};
+
+struct stacktable /* stack information */
+{
+ struct stackblock* blocks; /* stack table blocks */
+ __V_* error; /* error return value */
+ int size; /* size of each block */
+ STACKPOS position; /* current stack position */
+};
+
+/*
+ * map old names to new
+ */
+
+#define mkstack stackalloc
+#define rmstack stackfree
+#define clrstack stackclear
+#define getstack stackget
+#define pushstack stackpush
+#define popstack stackpop
+#define posstack stacktell
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ STACK stackalloc __PROTO__((int, __V_*));
+extern __MANGLE__ void stackfree __PROTO__((STACK));
+extern __MANGLE__ void stackclear __PROTO__((STACK));
+extern __MANGLE__ __V_* stackget __PROTO__((STACK));
+extern __MANGLE__ int stackpush __PROTO__((STACK, __V_*));
+extern __MANGLE__ int stackpop __PROTO__((STACK));
+extern __MANGLE__ void stacktell __PROTO__((STACK, int, STACKPOS*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/stak.h b/usr/src/lib/libast/i386/include/ast/stak.h
new file mode 100644
index 0000000000..e0e707b0e5
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/stak.h
@@ -0,0 +1,64 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * David Korn
+ * AT&T Research
+ *
+ * Interface definitions for a stack-like storage library
+ *
+ */
+
+#ifndef _STAK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _STAK_H
+
+#include <stk.h>
+
+#define Stak_t Sfio_t
+#define staksp stkstd
+#define STAK_SMALL STK_SMALL
+
+#define stakptr(n) stkptr(stkstd,n)
+#define staktell() stktell(stkstd)
+#define stakputc(c) sfputc(stkstd,(c))
+#define stakwrite(b,n) sfwrite(stkstd,(b),(n))
+#define stakputs(s) (sfputr(stkstd,(s),0),--stkstd->_next)
+#define stakseek(n) stkseek(stkstd,n)
+#define stakcreate(n) stkopen(n)
+#define stakinstall(s,f) stkinstall(s,f)
+#define stakdelete(s) stkclose(s)
+#define staklink(s) stklink(s)
+#define stakalloc(n) stkalloc(stkstd,n)
+#define stakcopy(s) stkcopy(stkstd,s)
+#define stakset(c,n) stkset(stkstd,c,n)
+#define stakfreeze(n) stkfreeze(stkstd,n)
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/stdio.h b/usr/src/lib/libast/i386/include/ast/stdio.h
new file mode 100644
index 0000000000..7e137c5712
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/stdio.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_stdio.h>
diff --git a/usr/src/lib/libast/i386/include/ast/stk.h b/usr/src/lib/libast/i386/include/ast/stk.h
new file mode 100644
index 0000000000..24947d24f1
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/stk.h
@@ -0,0 +1,91 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * David Korn
+ * AT&T Research
+ *
+ * Interface definitions for a stack-like storage library
+ *
+ */
+
+#ifndef _STK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _STK_H
+
+#include <sfio.h>
+
+#define _Stk_data _Stak_data
+
+#define stkstd (&_Stk_data)
+
+#define Stk_t Sfio_t
+
+#define STK_SMALL 1 /* small stkopen stack */
+#define STK_NULL 2 /* return NULL on overflow */
+
+#define stkptr(sp,n) ((char*)((sp)->_data)+(n))
+#define stktop(sp) ((char*)(sp)->_next)
+#define stktell(sp) ((sp)->_next-(sp)->_data)
+#define stkseek(sp,n) ((n)==0?(char*)((sp)->_next=(sp)->_data):_stkseek(sp,n))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Sfio_t _Stk_data;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Stk_t* stkopen __PROTO__((int));
+extern __MANGLE__ Stk_t* stkinstall __PROTO__((Stk_t*, char*(*)(int)));
+extern __MANGLE__ int stkclose __PROTO__((Stk_t*));
+extern __MANGLE__ int stklink __PROTO__((Stk_t*));
+extern __MANGLE__ char* stkalloc __PROTO__((Stk_t*, unsigned));
+extern __MANGLE__ char* stkcopy __PROTO__((Stk_t*,const char*));
+extern __MANGLE__ char* stkset __PROTO__((Stk_t*, char*, unsigned));
+extern __MANGLE__ char* _stkseek __PROTO__((Stk_t*, unsigned));
+extern __MANGLE__ char* stkfreeze __PROTO__((Stk_t*, unsigned));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/swap.h b/usr/src/lib/libast/i386/include/ast/swap.h
new file mode 100644
index 0000000000..d89248d12b
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/swap.h
@@ -0,0 +1,64 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * integral representation conversion support definitions
+ * supports sizeof(integral_type)<=sizeof(intmax_t)
+ */
+
+#ifndef _SWAP_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SWAP_H
+
+#include <ast_common.h>
+
+#define int_swap _ast_intswap
+
+#define SWAP_MAX 8
+
+#define SWAPOP(n) (((n)&int_swap)^(n))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ __V_* swapmem __PROTO__((int, const __V_*, __V_*, size_t));
+extern __MANGLE__ intmax_t swapget __PROTO__((int, const __V_*, int));
+extern __MANGLE__ __V_* swapput __PROTO__((int, __V_*, int, intmax_t));
+extern __MANGLE__ int swapop __PROTO__((const __V_*, const __V_*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/tar.h b/usr/src/lib/libast/i386/include/ast/tar.h
new file mode 100644
index 0000000000..910b6e8612
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/tar.h
@@ -0,0 +1,127 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Standard Archive Format
+ * USTAR - Uniform Standard Tape ARchive
+ */
+
+#ifndef _TAR_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TAR_H
+
+#define TBLOCK 512
+#define NAMSIZ 100
+#define PFXSIZ 155
+
+#define TMODLEN 8
+#define TUIDLEN 8
+#define TGIDLEN 8
+#define TSIZLEN 12
+#define TMTMLEN 12
+#define TCKSLEN 8
+
+#define TMAGIC "ustar" /* ustar and a null */
+#define TMAGLEN 6
+#define TVERSION "00" /* 00 and no null */
+#define TVERSLEN 2
+#define TUNMLEN 32
+#define TGNMLEN 32
+#define TDEVLEN 8
+
+/*
+ * values used in typeflag field
+ */
+
+#define REGTYPE '0' /* regular file */
+#define AREGTYPE 0 /* alternate REGTYPE */
+#define LNKTYPE '1' /* hard link */
+#define SYMTYPE '2' /* soft link */
+#define CHRTYPE '3' /* character special */
+#define BLKTYPE '4' /* block special */
+#define DIRTYPE '5' /* directory */
+#define FIFOTYPE '6' /* FIFO special */
+#define CONTTYPE '7' /* reserved */
+#define SOKTYPE '8' /* socket */
+#define EXTTYPE 'x' /* extended header */
+#define GLBTYPE 'g' /* global extended header */
+#define LLNKTYPE 'K' /* long link path */
+#define LREGTYPE 'L' /* long file path */
+#define VERTYPE 'V' /* version */
+
+/*
+ * bits used in mode field
+ */
+
+#define TSUID 04000 /* set uid on exec */
+#define TSGID 02000 /* set gid on exec */
+#define TSVTX 01000 /* sticky bit -- reserved */
+
+/*
+ * file permissions
+ */
+
+#define TUREAD 00400 /* read by owner */
+#define TUWRITE 00200 /* write by owner */
+#define TUEXEC 00100 /* execute by owner */
+#define TGREAD 00040 /* read by group */
+#define TGWRITE 00020 /* execute by group */
+#define TGEXEC 00010 /* write by group */
+#define TOREAD 00004 /* read by other */
+#define TOWRITE 00002 /* write by other */
+#define TOEXEC 00001 /* execute by other */
+
+struct header
+{
+ char name[NAMSIZ];
+ char mode[TMODLEN];
+ char uid[TUIDLEN];
+ char gid[TGIDLEN];
+ char size[TSIZLEN];
+ char mtime[TMTMLEN];
+ char chksum[TCKSLEN];
+ char typeflag;
+ char linkname[NAMSIZ];
+ char magic[TMAGLEN];
+ char version[TVERSLEN];
+ char uname[TUNMLEN];
+ char gname[TGNMLEN];
+ char devmajor[TDEVLEN];
+ char devminor[TDEVLEN];
+ char prefix[PFXSIZ];
+};
+
+union hblock
+{
+ char dummy[TBLOCK];
+ struct header dbuf;
+};
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/times.h b/usr/src/lib/libast/i386/include/ast/times.h
new file mode 100644
index 0000000000..25e81662be
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/times.h
@@ -0,0 +1,65 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * -last clock_t,time_t interface definitions plus
+ *
+ * <ast.h>
+ * <time.h>
+ * <sys/time.h>
+ * <sys/times.h>
+ */
+
+#ifndef _TIMES_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TIMES_H
+
+#include <ast.h>
+
+#undef _TIMES_H
+#include <ast_time.h>
+#ifndef _TIMES_H
+#define _TIMES_H
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int touch __PROTO__((const char*, time_t, time_t, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/tm.h b/usr/src/lib/libast/i386/include/ast/tm.h
new file mode 100644
index 0000000000..f790a9a66e
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/tm.h
@@ -0,0 +1,205 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * time conversion support definitions
+ */
+
+#ifndef _TM_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TM_H
+
+#define TM_VERSION 20070319L
+
+#include <ast.h>
+#include <times.h>
+
+#undef daylight
+
+#define tmset(z) tminit(z)
+#define tmisleapyear(y) (!((y)%4)&&(((y)%100)||!((((y)<1900)?((y)+1900):(y))%400)))
+
+#define TM_ADJUST (1<<0) /* local doesn't do leap secs */
+#define TM_LEAP (1<<1) /* do leap seconds */
+#define TM_UTC (1<<2) /* universal coordinated ref */
+
+#define TM_PEDANTIC (1<<3) /* pedantic date parse */
+#define TM_DATESTYLE (1<<4) /* date(1) style mmddHHMMccyy */
+#define TM_SUBSECOND (1<<5) /* <something>%S => ...%S.%P */
+
+#define TM_DST (-60) /* default minutes for DST */
+#define TM_LOCALZONE (25 * 60) /* use local time zone offset */
+#define TM_UTCZONE (26 * 60) /* UTC "time zone" */
+#define TM_MAXLEAP 1 /* max leap secs per leap */
+#define TM_WINDOW 69 /* century windowing guard year */
+
+/*
+ * these indices must agree with tm_dform[]
+ */
+
+#define TM_MONTH_ABBREV 0
+#define TM_MONTH 12
+#define TM_DAY_ABBREV 24
+#define TM_DAY 31
+#define TM_TIME 38
+#define TM_DATE 39
+#define TM_DEFAULT 40
+#define TM_MERIDIAN 41
+
+#define TM_UT 43
+#define TM_DT 47
+#define TM_SUFFIXES 51
+#define TM_PARTS 55
+#define TM_HOURS 62
+#define TM_DAYS 66
+#define TM_LAST 69
+#define TM_THIS 72
+#define TM_NEXT 75
+#define TM_EXACT 78
+#define TM_NOISE 81
+#define TM_ORDINAL 85
+#define TM_DIGITS 95
+#define TM_CTIME 105
+#define TM_DATE_1 106
+#define TM_INTERNATIONAL 107
+#define TM_RECENT 108
+#define TM_DISTANT 109
+#define TM_MERIDIAN_TIME 110
+#define TM_ERA 111
+#define TM_ERA_DATE 112
+#define TM_ERA_TIME 113
+#define TM_ERA_DEFAULT 114
+#define TM_ERA_YEAR 115
+#define TM_ORDINALS 116
+#define TM_FINAL 126
+
+#define TM_NFORM 129
+
+typedef struct /* leap second info */
+{
+ time_t time; /* the leap second event */
+ int total; /* inclusive total since epoch */
+} Tm_leap_t;
+
+typedef struct /* time zone info */
+{
+ char* type; /* type name */
+ char* standard; /* standard time name */
+ char* daylight; /* daylight or summertime name */
+ short west; /* minutes west of GMT */
+ short dst; /* add to tz.west for DST */
+} Tm_zone_t;
+
+typedef struct /* tm library readonly data */
+{
+ char** format; /* default TM_* format strings */
+ char* lex; /* format lex type classes */
+ char* digit; /* output digits */
+ short* days; /* days in month i */
+ short* sum; /* days in months before i */
+ Tm_leap_t* leap; /* leap second table */
+ Tm_zone_t* zone; /* alternate timezone table */
+} Tm_data_t;
+
+typedef struct /* tm library global info */
+{
+ char* deformat; /* TM_DEFAULT override */
+ int flags; /* flags */
+ char** format; /* current format strings */
+ Tm_zone_t* date; /* timezone from last tmdate() */
+ Tm_zone_t* local; /* local timezone */
+ Tm_zone_t* zone; /* current timezone */
+} Tm_info_t;
+
+typedef struct Tm_s
+{
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+ uint32_t tm_nsec;
+ Tm_zone_t* tm_zone;
+} Tm_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Tm_data_t* _tm_datap_;
+extern __MANGLE__ Tm_info_t* _tm_infop_;
+
+#define tm_data (*_tm_datap_)
+#define tm_info (*_tm_infop_)
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ time_t tmdate __PROTO__((const char*, char**, time_t*));
+extern __MANGLE__ int tmequiv __PROTO__((Tm_t*));
+extern __MANGLE__ Tm_t* tmfix __PROTO__((Tm_t*));
+extern __MANGLE__ char* tmfmt __PROTO__((char*, size_t, const char*, time_t*));
+extern __MANGLE__ char* tmform __PROTO__((char*, const char*, time_t*));
+extern __MANGLE__ int tmgoff __PROTO__((const char*, char**, int));
+extern __MANGLE__ void tminit __PROTO__((Tm_zone_t*));
+extern __MANGLE__ time_t tmleap __PROTO__((time_t*));
+extern __MANGLE__ int tmlex __PROTO__((const char*, char**, char**, int, char**, int));
+extern __MANGLE__ char** tmlocale __PROTO__((void));
+extern __MANGLE__ Tm_t* tmmake __PROTO__((time_t*));
+extern __MANGLE__ char* tmpoff __PROTO__((char*, size_t, const char*, int, int));
+extern __MANGLE__ time_t tmscan __PROTO__((const char*, char**, const char*, char**, time_t*, long));
+extern __MANGLE__ int tmsleep __PROTO__((time_t, time_t));
+extern __MANGLE__ time_t tmtime __PROTO__((Tm_t*, int));
+extern __MANGLE__ Tm_zone_t* tmtype __PROTO__((const char*, char**));
+extern __MANGLE__ int tmweek __PROTO__((Tm_t*, int, int, int));
+extern __MANGLE__ int tmword __PROTO__((const char*, char**, const char*, char**, int));
+extern __MANGLE__ Tm_zone_t* tmzone __PROTO__((const char*, char**, const char*, int*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/tmx.h b/usr/src/lib/libast/i386/include/ast/tmx.h
new file mode 100644
index 0000000000..bf5f3094c9
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/tmx.h
@@ -0,0 +1,149 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/tmx by iffe version 2007-04-04 : : */
+
+#ifndef _TMX_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TMX_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Time_t support
+ */
+
+#include <tm.h>
+#include <tv.h>
+
+#define TMX_MAXDATE "2554-07-21+23:34:33.709551614 UTC"
+#define TMX_MAXYEAR 2554
+#define TMX_MAXSEC ((Time_t)18446744073)
+#define TMX_MAXNSEC 709551614
+#define TMX_RESOLUTION 1000000000
+
+typedef uint64_t Time_t;
+typedef uint64_t Tmxsec_t;
+typedef uint32_t Tmxnsec_t;
+
+#define tmxsec(t) ((Tmxsec_t)((t)/1000000000))
+#define tmxnsec(t) ((Tmxnsec_t)((t)%1000000000))
+#define tmxsns(s,n) (((((Time_t)(s))*1000000000))+((Time_t)(n)))
+
+#define TMX_NOTIME ((Time_t)(-1))
+#define TMX_NOW tmxgettime()
+#define TMX_MAXTIME tmxsns(TMX_MAXSEC,TMX_MAXNSEC)
+
+#define tmx2tv(t,v) ((v)->tv_nsec=tmxnsec(t),(v)->tv_sec=tmxsec(t))
+#define tv2tmx(v) tmxsns((v)->tv_sec,(v)->tv_nsec)
+
+#define tmxclock(p) tmxsns(((p)?*(p):time(NiL)),0)
+
+#define tmxgetatime(s) tmxsns((s)->st_atime,ST_ATIME_NSEC_GET(s))
+#define tmxgetctime(s) tmxsns((s)->st_ctime,ST_CTIME_NSEC_GET(s))
+#define tmxgetmtime(s) tmxsns((s)->st_mtime,ST_MTIME_NSEC_GET(s))
+
+#define tmxsetatime(s,t) ((s)->st_atime=tmxsec(t),ST_ATIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetctime(s,t) ((s)->st_ctime=tmxsec(t),ST_CTIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetmtime(s,t) ((s)->st_mtime=tmxsec(t),ST_MTIME_NSEC_SET(s,tmxnsec(t)))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Time_t tmxdate __PROTO__((const char*, char**, Time_t));
+extern __MANGLE__ char* tmxfmt __PROTO__((char*, size_t, const char*, Time_t));
+extern __MANGLE__ Time_t tmxleap __PROTO__((Time_t));
+extern __MANGLE__ Tm_t* tmxmake __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxscan __PROTO__((const char*, char**, const char*, char**, Time_t, long));
+extern __MANGLE__ int tmxsleep __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxtime __PROTO__((Tm_t*, int));
+
+extern __MANGLE__ Time_t tmxgettime __PROTO__((void));
+extern __MANGLE__ int tmxsettime __PROTO__((Time_t));
+
+extern __MANGLE__ int tmxtouch __PROTO__((const char*, Time_t, Time_t, Time_t, int));
+
+extern __MANGLE__ char* fmttmx __PROTO__((const char*, Time_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/tok.h b/usr/src/lib/libast/i386/include/ast/tok.h
new file mode 100644
index 0000000000..3637489918
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/tok.h
@@ -0,0 +1,58 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * token stream interface definitions
+ */
+
+#ifndef _TOK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TOK_H
+
+#include <ast.h>
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Sfio_t* tokline __PROTO__((const char*, int, int*));
+extern __MANGLE__ int tokscan __PROTO__((char*, char**, const char*, ...));
+extern __MANGLE__ char* tokopen __PROTO__((char*, int));
+extern __MANGLE__ void tokclose __PROTO__((char*));
+extern __MANGLE__ char* tokread __PROTO__((char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/tv.h b/usr/src/lib/libast/i386/include/ast/tv.h
new file mode 100644
index 0000000000..21ab4abdbf
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/tv.h
@@ -0,0 +1,132 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/tv by iffe version 2007-04-04 : : */
+
+#ifndef _TV_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TV_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Tv_t interface definitions
+ */
+
+#include <ast.h>
+
+#define TV_NSEC_IGNORE (1000000000L)
+#define TV_TOUCH_RETAIN ((Tv_t*)1)
+
+typedef struct Tv_s
+{
+ uint32_t tv_sec;
+ uint32_t tv_nsec;
+} Tv_t;
+
+#define ST_ATIME_NSEC_GET(st) ((st)->st_atim.tv_nsec)
+#define ST_CTIME_NSEC_GET(st) ((st)->st_ctim.tv_nsec)
+#define ST_MTIME_NSEC_GET(st) ((st)->st_mtim.tv_nsec)
+
+#define ST_ATIME_NSEC_SET(st,n) (ST_ATIME_NSEC_GET(st)=(n))
+#define ST_CTIME_NSEC_SET(st,n) (ST_CTIME_NSEC_GET(st)=(n))
+#define ST_MTIME_NSEC_SET(st,n) (ST_MTIME_NSEC_GET(st)=(n))
+
+#define tvgetatime(t,s) ((t)->tv_nsec=ST_ATIME_NSEC_GET(s),(t)->tv_sec=(s)->st_atime)
+#define tvgetmtime(t,s) ((t)->tv_nsec=ST_MTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_mtime)
+#define tvgetctime(t,s) ((t)->tv_nsec=ST_CTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_ctime)
+
+#define tvsetatime(t,s) (ST_ATIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_atime=(t)->tv_sec)
+#define tvsetmtime(t,s) (ST_MTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_mtime=(t)->tv_sec)
+#define tvsetctime(t,s) (ST_CTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_ctime=(t)->tv_sec)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int tvgettime __PROTO__((Tv_t*));
+extern __MANGLE__ int tvsettime __PROTO__((const Tv_t*));
+extern __MANGLE__ int tvcmp __PROTO__((const Tv_t*, const Tv_t*));
+extern __MANGLE__ int tvtouch __PROTO__((const char*, const Tv_t*, const Tv_t*, const Tv_t*, int));
+extern __MANGLE__ int tvsleep __PROTO__((const Tv_t*, Tv_t*));
+
+extern __MANGLE__ char* fmttv __PROTO__((const char*, Tv_t*));
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/usage.h b/usr/src/lib/libast/i386/include/ast/usage.h
new file mode 100644
index 0000000000..81b59e1aca
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/usage.h
@@ -0,0 +1,37 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * error catalog and usage defaults
+ */
+
+#ifndef _USAGE_H
+#define _USAGE_H
+
+#ifndef ERROR_CATALOG
+#define ERROR_CATALOG 0
+#endif
+
+#ifndef USAGE_LICENSE
+#define USAGE_LICENSE "[-license?THIS IS AN UNLICENSED COPY]"
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/vdb.h b/usr/src/lib/libast/i386/include/ast/vdb.h
new file mode 100644
index 0000000000..63e310c724
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/vdb.h
@@ -0,0 +1,55 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * virtual db file directory entry constants
+ */
+
+#ifndef VDB_MAGIC
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+
+#define VDB_MAGIC "vdb"
+
+#define VDB_DIRECTORY "DIRECTORY"
+#define VDB_UNION "UNION"
+#define VDB_DATE "DATE"
+#define VDB_MODE "MODE"
+
+#define VDB_DELIMITER ';'
+#define VDB_IGNORE '_'
+#define VDB_FIXED 10
+#define VDB_LENGTH ((int)sizeof(VDB_DIRECTORY)+2*(VDB_FIXED+1))
+#define VDB_OFFSET ((int)sizeof(VDB_DIRECTORY))
+#define VDB_SIZE (VDB_OFFSET+VDB_FIXED+1)
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/vecargs.h b/usr/src/lib/libast/i386/include/ast/vecargs.h
new file mode 100644
index 0000000000..4d329cd154
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/vecargs.h
@@ -0,0 +1,56 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * vector argument interface definitions
+ */
+
+#ifndef _VECARGS_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _VECARGS_H
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int vecargs __PROTO__((char**, int*, char***));
+extern __MANGLE__ char** vecfile __PROTO__((const char*));
+extern __MANGLE__ void vecfree __PROTO__((char**, int));
+extern __MANGLE__ char** vecload __PROTO__((char*));
+extern __MANGLE__ char** vecstring __PROTO__((const char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/vmalloc.h b/usr/src/lib/libast/i386/include/ast/vmalloc.h
new file mode 100644
index 0000000000..f0a8114c6a
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/vmalloc.h
@@ -0,0 +1,315 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _VMALLOC_H
+#define _VMALLOC_H 1
+
+/* Public header file for the virtual malloc package.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+
+#define VMALLOC_VERSION 20050928L
+
+#if _PACKAGE_ast
+#include <ast_std.h>
+#else
+#include <ast_common.h>
+#endif
+
+typedef struct _vmalloc_s Vmalloc_t;
+typedef struct _vmstat_s Vmstat_t;
+typedef struct _vmdisc_s Vmdisc_t;
+typedef struct _vmethod_s Vmethod_t;
+typedef Void_t* (*Vmemory_f)_ARG_((Vmalloc_t*, Void_t*, size_t, size_t, Vmdisc_t*));
+typedef int (*Vmexcept_f)_ARG_((Vmalloc_t*, int, Void_t*, Vmdisc_t*));
+
+struct _vmstat_s
+{ int n_busy; /* number of busy blocks */
+ int n_free; /* number of free blocks */
+ size_t s_busy; /* total amount of busy space */
+ size_t s_free; /* total amount of free space */
+ size_t m_busy; /* largest busy piece */
+ size_t m_free; /* largest free piece */
+ int n_seg; /* number of segments */
+ size_t extent; /* total size of region */
+};
+
+struct _vmdisc_s
+{ Vmemory_f memoryf; /* memory manipulator */
+ Vmexcept_f exceptf; /* exception handler */
+ size_t round; /* rounding requirement */
+};
+
+struct _vmethod_s
+{ Void_t* (*allocf)_ARG_((Vmalloc_t*,size_t));
+ Void_t* (*resizef)_ARG_((Vmalloc_t*,Void_t*,size_t,int));
+ int (*freef)_ARG_((Vmalloc_t*,Void_t*));
+ long (*addrf)_ARG_((Vmalloc_t*,Void_t*));
+ long (*sizef)_ARG_((Vmalloc_t*,Void_t*));
+ int (*compactf)_ARG_((Vmalloc_t*));
+ Void_t* (*alignf)_ARG_((Vmalloc_t*,size_t,size_t));
+ unsigned short meth;
+};
+
+struct _vmalloc_s
+{ Vmethod_t meth; /* method for allocation */
+ char* file; /* file name */
+ int line; /* line number */
+ Void_t* func; /* calling function */
+#ifdef _VM_PRIVATE_
+ _VM_PRIVATE_
+#endif
+};
+
+#undef VM_FLAGS /* solaris sys kernel clash */
+
+#define VM_TRUST 0000001 /* forgo some security checks */
+#define VM_TRACE 0000002 /* generate trace */
+#define VM_DBCHECK 0000004 /* check for boundary overwrite */
+#define VM_DBABORT 0000010 /* abort on any warning */
+#define VM_FLAGS 0000017 /* user-settable flags */
+
+#define VM_MTBEST 0000100 /* Vmbest method */
+#define VM_MTPOOL 0000200 /* Vmpool method */
+#define VM_MTLAST 0000400 /* Vmlast method */
+#define VM_MTDEBUG 0001000 /* Vmdebug method */
+#define VM_MTPROFILE 0002000 /* Vmdebug method */
+#define VM_METHODS 0003700 /* available allocation methods */
+
+#define VM_RSCOPY 0000001 /* copy old contents */
+#define VM_RSMOVE 0000002 /* old contents is moveable */
+#define VM_RSZERO 0000004 /* clear new space */
+
+/* exception types */
+#define VM_OPEN 0 /* region being opened */
+#define VM_CLOSE 1 /* announce being closed */
+#define VM_NOMEM 2 /* can't obtain memory */
+#define VM_BADADDR 3 /* bad addr in vmfree/vmresize */
+#define VM_DISC 4 /* discipline being changed */
+#define VM_ALLOC 5 /* announcement from vmalloc() */
+#define VM_FREE 6 /* announcement from vmfree() */
+#define VM_RESIZE 7 /* announcement from vmresize() */
+
+_BEGIN_EXTERNS_ /* public data */
+#if _BLD_vmalloc && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+#if !_BLD_vmalloc && defined(__IMPORT__)
+#define extern extern __IMPORT__
+#endif
+
+extern Vmethod_t* Vmbest; /* best allocation */
+extern Vmethod_t* Vmlast; /* last-block allocation */
+extern Vmethod_t* Vmpool; /* pool allocation */
+extern Vmethod_t* Vmdebug; /* allocation with debugging */
+extern Vmethod_t* Vmprofile; /* profiling memory usage */
+
+extern Vmdisc_t* Vmdcheap; /* heap discipline */
+extern Vmdisc_t* Vmdcsbrk; /* sbrk discipline */
+
+extern Vmalloc_t* Vmheap; /* heap region */
+extern Vmalloc_t* Vmregion; /* malloc region */
+
+#undef extern
+_END_EXTERNS_
+
+_BEGIN_EXTERNS_ /* public functions */
+#if _BLD_vmalloc && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Vmalloc_t* vmopen _ARG_(( Vmdisc_t*, Vmethod_t*, int ));
+extern int vmclose _ARG_(( Vmalloc_t* ));
+extern int vmclear _ARG_(( Vmalloc_t* ));
+extern int vmcompact _ARG_(( Vmalloc_t* ));
+
+extern Vmdisc_t* vmdisc _ARG_(( Vmalloc_t*, Vmdisc_t* ));
+
+extern Vmalloc_t* vmmopen _ARG_(( char*, Void_t*, size_t ));
+extern Void_t* vmmset _ARG_((Vmalloc_t*, int, Void_t*, int));
+
+extern Void_t* vmalloc _ARG_(( Vmalloc_t*, size_t ));
+extern Void_t* vmalign _ARG_(( Vmalloc_t*, size_t, size_t ));
+extern Void_t* vmresize _ARG_(( Vmalloc_t*, Void_t*, size_t, int ));
+extern Void_t* vmgetmem _ARG_(( Vmalloc_t*, Void_t*, size_t ));
+extern int vmfree _ARG_(( Vmalloc_t*, Void_t* ));
+
+extern long vmaddr _ARG_(( Vmalloc_t*, Void_t* ));
+extern long vmsize _ARG_(( Vmalloc_t*, Void_t* ));
+
+extern Vmalloc_t* vmregion _ARG_(( Void_t* ));
+extern Void_t* vmsegment _ARG_(( Vmalloc_t*, Void_t* ));
+extern int vmset _ARG_(( Vmalloc_t*, int, int ));
+
+extern Void_t* vmdbwatch _ARG_(( Void_t* ));
+extern int vmdbcheck _ARG_(( Vmalloc_t* ));
+extern int vmdebug _ARG_(( int ));
+
+extern int vmprofile _ARG_(( Vmalloc_t*, int ));
+
+extern int vmtrace _ARG_(( int ));
+extern int vmtrbusy _ARG_((Vmalloc_t*));
+
+extern int vmstat _ARG_((Vmalloc_t*, Vmstat_t*));
+
+extern int vmwalk _ARG_((Vmalloc_t*,
+ int(*)(Vmalloc_t*,Void_t*,size_t,Vmdisc_t*)));
+extern char* vmstrdup _ARG_((Vmalloc_t*, const char*));
+
+#if !defined(_BLD_vmalloc) && !defined(_AST_STD_H) && \
+ !defined(__stdlib_h) && !defined(__STDLIB_H) && \
+ !defined(_STDLIB_INCLUDED) && !defined(_INC_STDLIB)
+extern Void_t* malloc _ARG_(( size_t ));
+extern Void_t* realloc _ARG_(( Void_t*, size_t ));
+extern void free _ARG_(( Void_t* ));
+extern void cfree _ARG_(( Void_t* ));
+extern Void_t* calloc _ARG_(( size_t, size_t ));
+extern Void_t* memalign _ARG_(( size_t, size_t ));
+extern Void_t* valloc _ARG_(( size_t ));
+#endif
+
+#undef extern
+_END_EXTERNS_
+
+/* to coerce any value to a Vmalloc_t*, make ANSI happy */
+#define _VM_(vm) ((Vmalloc_t*)(vm))
+
+/* enable recording of where a call originates from */
+#ifdef VMFL
+
+#if defined(__FILE__)
+#define _VMFILE_(vm) (_VM_(vm)->file = (char*)__FILE__)
+#else
+#define _VMFILE_(vm) (_VM_(vm)->file = 0)
+#endif
+
+#if defined(__LINE__)
+#define _VMLINE_(vm) (_VM_(vm)->line = __LINE__)
+#else
+#define _VMLINE_(vm) (_VM_(vm)->line = 0)
+#endif
+
+#if defined(__FUNCTION__)
+#define _VMFUNC_(vm) (_VM_(vm)->func = (Void_t*)__FUNCTION__)
+#else
+#define _VMFUNC_(vm) (_VM_(vm)->func = 0)
+#endif
+
+#define _VMFL_(vm) (_VMFILE_(vm), _VMLINE_(vm), _VMFUNC_(vm))
+
+#define vmalloc(vm,sz) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.allocf))((vm),(sz)) )
+#define vmresize(vm,d,sz,type) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.resizef))\
+ ((vm),(Void_t*)(d),(sz),(type)) )
+#define vmfree(vm,d) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.freef))((vm),(Void_t*)(d)) )
+#define vmalign(vm,sz,align) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.alignf))((vm),(sz),(align)) )
+
+#undef malloc
+#undef realloc
+#undef calloc
+#undef free
+#undef memalign
+#undef valloc
+
+#if _map_malloc
+
+#define malloc(s) (_VMFL_(Vmregion), _ast_malloc((size_t)(s)) )
+#define realloc(d,s) (_VMFL_(Vmregion), _ast_realloc((Void_t*)(d),(size_t)(s)) )
+#define calloc(n,s) (_VMFL_(Vmregion), _ast_calloc((size_t)n, (size_t)(s)) )
+#define free(d) (_VMFL_(Vmregion), _ast_free((Void_t*)(d)) )
+#define memalign(a,s) (_VMFL_(Vmregion), _ast_memalign((size_t)(a),(size_t)(s)) )
+#define valloc(s) (_VMFL_(Vmregion), _ast_valloc((size_t)(s) )
+
+#else
+
+#if !_std_malloc
+
+#if __STD_C || defined(__STDPP__) || defined(__GNUC__)
+#define malloc(s) ( _VMFL_(Vmregion), (malloc)((size_t)(s)) )
+#define realloc(d,s) ( _VMFL_(Vmregion), (realloc)((Void_t*)(d),(size_t)(s)) )
+#define calloc(n,s) ( _VMFL_(Vmregion), (calloc)((size_t)n, (size_t)(s)) )
+#define free(d) ( _VMFL_(Vmregion), (free)((Void_t*)(d)) )
+#define memalign(a,s) ( _VMFL_(Vmregion), (memalign)((size_t)(a),(size_t)(s)) )
+#define valloc(s) ( _VMFL_(Vmregion), (valloc)((size_t)(s)) )
+#ifndef strdup
+#define strdup(s) ( _VMFL_(Vmregion), (strdup)((char*)(s)) )
+#endif
+
+#else
+
+#define _VMNM_(a,b,c,d,e,f) a/**/b/**/c/**/d/**/e/**/f
+#define malloc(s) ( _VMFL_(Vmregion), _VMNM_(mallo,/,*,*,/,c)\
+ ( (size_t)(s)) )
+#define realloc(d,s) ( _VMFL_(Vmregion), _VMNM_(reallo,/,*,*,/,c)\
+ ( (Void_t*)(d),(size_t)(s)) )
+#define calloc(n,s) ( _VMFL_(Vmregion), _VMNM_(callo,/,*,*,/,c)\
+ ( (size_t)n, (size_t)(s)) )
+#define free(d) ( _VMFL_(Vmregion), _VMNM_(fre,/,*,*,/,e)((Void_t*)(d)) )
+#define memalign(a,s) ( _VMFL_(Vmregion), _VMNM_(memalig,/,*,*,/,n)\
+ ( (size_t)(a),(size_t)(s)) )
+#define valloc(s) ( _VMFL_(Vmregion), _VMNM_(vallo,/,*,*,/,c)\
+ ( (size_t)(s)) )
+#ifndef strdup
+#define strdup(s) ( _VMFL_(Vmregion), _VMNM_(strdu,/,*,*,/,p)\
+ ((char*)(s)) )
+#endif
+
+#endif /*__STD_C || defined(__STDPP__) || defined(__GNUC__)*/
+
+#define cfree(d) free(d)
+
+#endif /* !_std_malloc */
+
+#endif /* _map_malloc */
+
+#endif /*VMFL*/
+
+/* non-debugging/profiling allocation calls */
+#ifndef vmalloc
+#define vmalloc(vm,sz) (*(_VM_(vm)->meth.allocf))((vm),(sz))
+#endif
+
+#ifndef vmresize
+#define vmresize(vm,d,sz,type) (*(_VM_(vm)->meth.resizef))\
+ ((vm),(Void_t*)(d),(sz),(type))
+#endif
+
+#ifndef vmfree
+#define vmfree(vm,d) (*(_VM_(vm)->meth.freef))((vm),(Void_t*)(d))
+#endif
+
+#ifndef vmalign
+#define vmalign(vm,sz,align) (*(_VM_(vm)->meth.alignf))((vm),(sz),(align))
+#endif
+
+#define vmaddr(vm,addr) (*(_VM_(vm)->meth.addrf))((vm),(Void_t*)(addr))
+#define vmsize(vm,addr) (*(_VM_(vm)->meth.sizef))((vm),(Void_t*)(addr))
+#define vmcompact(vm) (*(_VM_(vm)->meth.compactf))((vm))
+#define vmoldof(v,p,t,n,x) (t*)vmresize((v), (p), sizeof(t)*(n)+(x), \
+ (VM_RSMOVE) )
+#define vmnewof(v,p,t,n,x) (t*)vmresize((v), (p), sizeof(t)*(n)+(x), \
+ (VM_RSMOVE|VM_RSCOPY|VM_RSZERO) )
+
+#endif /* _VMALLOC_H */
diff --git a/usr/src/lib/libast/i386/include/ast/wait.h b/usr/src/lib/libast/i386/include/ast/wait.h
new file mode 100644
index 0000000000..6910081961
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/wait.h
@@ -0,0 +1,107 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * ast POSIX wait/exit support
+ */
+
+#ifndef _WAIT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _WAIT_H
+
+#include <ast.h>
+#include <ast_wait.h>
+
+#if _sys_wait
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide wait waitpid
+#else
+#define wait ______wait
+#define waitpid ______waitpid
+#endif
+#include <sys/wait.h>
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide wait waitpid
+#else
+#undef wait
+#undef waitpid
+#endif
+#endif
+
+#ifndef WNOHANG
+#define WNOHANG 1
+#endif
+
+#ifndef WUNTRACED
+#define WUNTRACED 2
+#endif
+
+#if !_ok_wif
+#undef WIFEXITED
+#undef WEXITSTATUS
+#undef WIFSIGNALED
+#undef WTERMSIG
+#undef WIFSTOPPED
+#undef WSTOPSIG
+#undef WTERMCORE
+#endif
+
+#ifndef WIFEXITED
+#define WIFEXITED(x) (!((x)&((1<<(EXIT_BITS-1))-1)))
+#endif
+
+#ifndef WEXITSTATUS
+#define WEXITSTATUS(x) (((x)>>EXIT_BITS)&((1<<EXIT_BITS)-1))
+#endif
+
+#ifndef WIFSIGNALED
+#define WIFSIGNALED(x) (((x)&((1<<(EXIT_BITS-1))-1))!=0)
+#endif
+
+#ifndef WTERMSIG
+#define WTERMSIG(x) ((x)&((1<<(EXIT_BITS-1))-1))
+#endif
+
+#ifndef WIFSTOPPED
+#define WIFSTOPPED(x) (((x)&((1<<EXIT_BITS)-1))==((1<<(EXIT_BITS-1))-1))
+#endif
+
+#ifndef WSTOPSIG
+#define WSTOPSIG(x) WEXITSTATUS(x)
+#endif
+
+#ifndef WTERMCORE
+#define WTERMCORE(x) ((x)&(1<<(EXIT_BITS-1)))
+#endif
+
+extern __MANGLE__ pid_t wait __PROTO__((int*));
+extern __MANGLE__ pid_t waitpid __PROTO__((pid_t, int*, int));
+
+#endif
diff --git a/usr/src/lib/libast/i386/include/ast/wchar.h b/usr/src/lib/libast/i386/include/ast/wchar.h
new file mode 100644
index 0000000000..557a403adc
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/wchar.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_wchar.h>
diff --git a/usr/src/lib/libast/i386/include/ast/wordexp.h b/usr/src/lib/libast/i386/include/ast/wordexp.h
new file mode 100644
index 0000000000..b2e80d9f35
--- /dev/null
+++ b/usr/src/lib/libast/i386/include/ast/wordexp.h
@@ -0,0 +1,74 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * posix wordexp interface definitions
+ */
+
+#ifndef _WORDEXP_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _WORDEXP_H
+
+#include <ast_common.h>
+
+#define WRDE_APPEND 01
+#define WRDE_DOOFFS 02
+#define WRDE_NOCMD 04
+#define WRDE_NOSYS 0100
+#define WRDE_REUSE 010
+#define WRDE_SHOWERR 020
+#define WRDE_UNDEF 040
+
+#define WRDE_BADCHAR 1
+#define WRDE_BADVAL 2
+#define WRDE_CMDSUB 3
+#define WRDE_NOSPACE 4
+#define WRDE_SYNTAX 5
+#define WRDE_NOSHELL 6
+
+typedef struct _wdarg
+{
+ size_t we_wordc;
+ char **we_wordv;
+ size_t we_offs;
+} wordexp_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int wordexp __PROTO__((const char*, wordexp_t*, int));
+extern __MANGLE__ int wordfree __PROTO__((wordexp_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif /* _WORDEXP_H */
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/align b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/align
new file mode 100644
index 0000000000..23ab6030ef
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/align
@@ -0,0 +1,33 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/align.c by iffe version 2007-04-04 : : */
+#ifndef _def_align_ast
+#define _def_align_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+typedef unsigned long ALIGN_INTEGRAL;
+
+#define ALIGN_CHUNK 8192
+#define ALIGN_INTEGRAL long
+#define ALIGN_INTEGER(x) ((ALIGN_INTEGRAL)(x))
+#define ALIGN_POINTER(x) ((char*)(x))
+#define ALIGN_ROUND(x,y) ALIGN_POINTER(ALIGN_INTEGER((x)+(y)-1)&~((y)-1))
+
+#define ALIGN_BOUND ALIGN_BOUND2
+#define ALIGN_ALIGN(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC(x) ALIGN_TRUNC2(x)
+
+#define ALIGN_BIT1 0x1
+#define ALIGN_BOUND1 ALIGN_BOUND2
+#define ALIGN_ALIGN1(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC1(x) ALIGN_TRUNC2(x)
+#define ALIGN_CLRBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffe)
+#define ALIGN_SETBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x1)
+#define ALIGN_TSTBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x1)
+
+#define ALIGN_BIT2 0x2
+#define ALIGN_BOUND2 4
+#define ALIGN_ALIGN2(x) ALIGN_TRUNC2((x)+3)
+#define ALIGN_TRUNC2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffc)
+#define ALIGN_CLRBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffd)
+#define ALIGN_SETBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x2)
+#define ALIGN_TSTBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x2)
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/botch b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/botch
new file mode 100644
index 0000000000..f622454838
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/botch
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/botch.c by iffe version 2007-04-04 : : */
+#ifndef _def_botch_ast
+#define _def_botch_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/ccode b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/ccode
new file mode 100644
index 0000000000..26e608f1d0
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/ccode
@@ -0,0 +1,29 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/ccode by iffe version 2007-04-04 : : */
+#ifndef _def_ccode_ast
+#define _def_ccode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define CC_ASCII 1 /* ISO-8859-1 */
+#define CC_EBCDIC_E 2 /* Xopen dd(1) EBCDIC */
+#define CC_EBCDIC_I 3 /* Xopen dd(1) IBM */
+#define CC_EBCDIC_O 4 /* IBM-1047 mvs OpenEdition */
+#define CC_EBCDIC_S 5 /* Siemens posix-bc */
+#define CC_EBCDIC_H 6 /* IBM-37 AS/400 */
+#define CC_EBCDIC_M 7 /* IBM mvs cobol */
+#define CC_EBCDIC_U 8 /* microfocus cobol */
+
+#define CC_MAPS 8 /* number of code maps */
+
+#define CC_EBCDIC CC_EBCDIC_E
+#define CC_EBCDIC1 CC_EBCDIC_E
+#define CC_EBCDIC2 CC_EBCDIC_I
+#define CC_EBCDIC3 CC_EBCDIC_O
+
+#define CC_NATIVE CC_ASCII /* native character code */
+#define CC_ALIEN CC_EBCDIC /* alien character code */
+
+#define CC_bel 0007 /* bel character */
+#define CC_esc 0033 /* esc character */
+#define CC_sub 0032 /* sub character */
+#define CC_vt 0013 /* vt character */
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/common b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/common
new file mode 100644
index 0000000000..9727c082e0
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/common
@@ -0,0 +1,199 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/common by iffe version 2007-04-04 : : */
+#ifndef _AST_COMMON_H
+#define _AST_COMMON_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_pthread 1 /* #include <pthread.h> ok */
+#define _hdr_stdarg 1 /* #include <stdarg.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdint 1 /* #include <stdint.h> ok */
+#define _hdr_inttypes 1 /* #include <inttypes.h> ok */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_long_double 1 /* long double is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _std_proto 1 /* standard C prototypes ok */
+#define _ptr_void 1 /* standard C void* ok */
+/* disable non-standard linux/gnu inlines */
+#ifdef __GNUC__
+# undef __OPTIMIZE_SIZE__
+# define __OPTIMIZE_SIZE__ 1
+#endif
+
+/* __STD_C indicates that the language is ANSI-C or C++ */
+#if !defined(__STD_C) && __STDC__
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && (__cplusplus || c_plusplus)
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && _std_proto
+# define __STD_C 1
+#endif
+#if !defined(__STD_C)
+# define __STD_C 0
+#endif
+
+/* extern symbols must be protected against C++ name mangling */
+#ifndef _BEGIN_EXTERNS_
+# if __cplusplus || c_plusplus
+# define _BEGIN_EXTERNS_ extern "C" {
+# define _END_EXTERNS_ }
+# else
+# define _BEGIN_EXTERNS_
+# define _END_EXTERNS_
+# endif
+#endif
+
+/* _ARG_ simplifies function prototyping among flavors of C */
+#ifndef _ARG_
+# if __STD_C
+# define _ARG_(x) x
+# else
+# define _ARG_(x) ()
+# endif
+#endif
+
+/* _NIL_ simplifies defining nil pointers to a given type */
+#ifndef _NIL_
+# define _NIL_(x) ((x)0)
+#endif
+
+/* __INLINE__ is the inline keyword */
+#if !defined(__INLINE__) && defined(__cplusplus)
+# define __INLINE__ inline
+#endif
+#if !defined(__INLINE__) && defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+#endif
+
+/* Void_t is defined so that Void_t* can address any type */
+#ifndef Void_t
+# if __STD_C
+# define Void_t void
+# else
+# define Void_t char
+# endif
+#endif
+
+/* windows variants and veneers */
+#if !defined(_WINIX) && (_UWIN || __CYGWIN__ || __EMX__)
+# define _WINIX 1
+#endif
+
+/* dynamic linked library external scope handling */
+#ifdef __DYNAMIC__
+# undef __DYNAMIC__
+# ifndef _DLL
+# define _DLL 1
+# endif
+#endif
+#if _dll_import
+# if _BLD_STATIC && !_BLD_DLL
+# undef _DLL
+# else
+# if !_UWIN && !defined(_DLL)
+# define _DLL 1
+# endif
+# endif
+# if !defined(__EXPORT__) && _BLD_DLL
+# define __EXPORT__ __declspec(dllexport)
+# endif
+# if !defined(__IMPORT__) && ( _BLD_DLL || defined(_DLL) )
+# define __IMPORT__ __declspec(dllimport)
+# endif
+# if _BLD_DLL && _UWIN
+# define __DYNAMIC__(v) (_ast_getdll()->_ast_ ## v)
+# endif
+#endif
+#if !defined(_astimport)
+# if defined(__IMPORT__) && defined(_DLL)
+# define _astimport __IMPORT__
+# else
+# define _astimport extern
+# endif
+#endif
+#if _dll_import && ( !_BLD_DLL || _WINIX && !_UWIN )
+# ifdef __STDC__
+# define __EXTERN__(T,obj) extern T obj; T* _imp__ ## obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__ ## obj = &obj
+# else
+# define __EXTERN__(T,obj) extern T obj; T* _imp__/**/obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__/**/obj = &obj
+# endif
+#else
+# define __EXTERN__(T,obj) extern T obj
+# define __DEFINE__(T,obj,val) T obj = val
+#endif
+
+#define _ast_LL 1 /* LL numeric suffix supported */
+#define _ast_int1_t char
+#define _ast_int2_t short
+#define _ast_int4_t int
+#define _ast_int8_t long long
+#define _ast_intmax_t _ast_int8_t
+#define _ast_intswap 7
+
+#define _ast_flt4_t float
+#define _ast_flt8_t double
+#define _ast_flt12_t long double
+#define _ast_fltmax_t _ast_flt12_t
+#define _typ_int8_t 1 /* int8_t is a type */
+#define _typ_uint8_t 1 /* uint8_t is a type */
+#define _typ_int16_t 1 /* int16_t is a type */
+#define _typ_uint16_t 1 /* uint16_t is a type */
+#define _typ_int32_t 1 /* int32_t is a type */
+#define _typ_uint32_t 1 /* uint32_t is a type */
+#define _typ_int64_t 1 /* int64_t is a type */
+#define _typ_uint64_t 1 /* uint64_t is a type */
+#define _typ_intmax_t 1 /* intmax_t is a type */
+#define _typ_uintmax_t 1 /* uintmax_t is a type */
+
+#ifndef va_listref
+#define va_listref(p) (p) /* pass va_list to varargs function */
+#define va_listval(p) (p) /* retrieve va_list from va_arg(ap,va_listarg) */
+#define va_listarg va_list /* va_arg() va_list type */
+#ifndef va_start
+#if __STD_C
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+#endif
+#ifndef _AST_STD_H
+# if __STD_C && _hdr_stddef
+# include <stddef.h>
+# endif
+# if _sys_types
+# include <sys/types.h>
+# endif
+# if _hdr_stdint
+# include <stdint.h>
+# else
+# if _hdr_inttypes
+# include <inttypes.h>
+# endif
+# endif
+#endif
+#if !_typ_size_t
+# define _typ_size_t 1
+ typedef int size_t;
+#endif
+#if !_typ_ssize_t
+# define _typ_ssize_t 1
+ typedef int ssize_t;
+#endif
+#ifndef _AST_STD_H
+# define _def_map_ast 1
+# if !_def_map_ast
+# include <ast_map.h>
+# endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/dirent b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/dirent
new file mode 100644
index 0000000000..0cdf633a20
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/dirent
@@ -0,0 +1,106 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/dirent by iffe version 2007-04-04 : : */
+
+#ifndef _def_dirent_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dirent_ast 1
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _nxt_dirent <../include/dirent.h> /* include path for the native <dirent.h> */
+#define _nxt_dirent_str "../include/dirent.h" /* include string for the native <dirent.h> */
+/*
+ * <dirent.h> for [fl]stat64 and off64_t
+ */
+
+#ifndef _AST_STD_H
+
+#include <../include/dirent.h> /* the native <dirent.h> */
+
+#else
+
+#ifndef _DIR64_H
+#define _DIR64_H
+
+#include <ast_std.h>
+
+#if _typ_off64_t
+#undef off_t
+#endif
+
+#include <../include/dirent.h> /* the native <dirent.h> */
+
+#if _typ_off64_t
+#define off_t off64_t
+#endif
+
+#if _lib_readdir64 && _typ_struct_dirent64
+#ifndef dirent
+#define dirent dirent64
+#endif
+#ifndef readdir
+#define readdir readdir64
+#endif
+#endif
+
+#endif
+
+#endif
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/eaccess b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/eaccess
new file mode 100644
index 0000000000..1a75e5905b
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/eaccess
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/eaccess by iffe version 2007-04-04 : : */
+#ifndef _def_eaccess_ast
+#define _def_eaccess_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/errno b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/errno
new file mode 100644
index 0000000000..6af7dde98e
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/errno
@@ -0,0 +1,7 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/errno by iffe version 2007-04-04 : : */
+#ifndef _def_errno_ast
+#define _def_errno_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _dat_sys_nerr 1 /* sys_nerr in default libs */
+#define _dat_sys_errlist 1 /* sys_errlist in default libs */
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/fcntl b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/fcntl
new file mode 100644
index 0000000000..78510ec979
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/fcntl
@@ -0,0 +1,114 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/fcntl.c by iffe version 2007-04-04 : : */
+#ifndef _def_fcntl_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fcntl_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <ast_fs.h>
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#define O_BINARY 0
+#define O_TEMPORARY 0
+#define O_TEXT 0
+
+#include <ast_fs.h>
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_fstat64
+#define fstat fstat64
+#endif
+#if _lib_lstat64
+#define lstat lstat64
+#endif
+#if _lib_stat64
+#define stat stat64
+#endif
+#if _lib_creat64
+#define creat creat64
+#endif
+#if _lib_mmap64
+#define mmap mmap64
+#endif
+#if _lib_open64
+#undef open
+#define open open64
+#endif
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/float b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/float
new file mode 100644
index 0000000000..9afe6e6ff8
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/float
@@ -0,0 +1,213 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/float by iffe version 2007-04-04 : : */
+
+#ifndef _def_float_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_float_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_float 1 /* #include <float.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _hdr_values 1 /* #include <values.h> ok */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_frexp 1 /* frexp() in default lib(s) */
+#define _lib_frexpl 1 /* frexpl() in default lib(s) */
+#define _lib_ldexp 1 /* ldexp() in default lib(s) */
+#define _lib_ldexpl 1 /* ldexpl() in default lib(s) */
+#define _lib_finite 1 /* finite() in default lib(s) */
+#define _lib_isnan 1 /* isnan() in default lib(s) */
+#define _lib_isnanl 1 /* isnanl() in default lib(s) */
+#define _lib_copysign 1 /* copysign() in default lib(s) */
+#define _lib_copysignl 1 /* copysignl() in default lib(s) */
+#include <ast_common.h>
+#include <float.h>
+#include <math.h>
+#ifndef FLT_DIG
+#define FLT_DIG 6
+#endif
+#ifndef FLT_MAX
+#define FLT_MAX 3.4028234663852885981170E+38F
+#endif
+#ifndef FLT_MAX_10_EXP
+#define FLT_MAX_10_EXP ( + 38 )
+#endif
+#ifndef FLT_MAX_EXP
+#define FLT_MAX_EXP ( + 128 )
+#endif
+#ifndef FLT_MIN
+#define FLT_MIN 1.1754943508222875079688E-38F
+#endif
+#ifndef FLT_MIN_10_EXP
+#define FLT_MIN_10_EXP ( - 37 )
+#endif
+#ifndef FLT_MIN_EXP
+#define FLT_MIN_EXP ( - 125 )
+#endif
+#ifndef DBL_DIG
+#define DBL_DIG 15
+#endif
+#ifndef DBL_MAX
+#define DBL_MAX 1.7976931348623157081452E+308
+#endif
+#ifndef DBL_MAX_10_EXP
+#define DBL_MAX_10_EXP ( + 308 )
+#endif
+#ifndef DBL_MAX_EXP
+#define DBL_MAX_EXP ( + 1024 )
+#endif
+#ifndef DBL_MIN
+#define DBL_MIN 2.2250738585072013830903E-308
+#endif
+#ifndef DBL_MIN_10_EXP
+#define DBL_MIN_10_EXP ( - 307 )
+#endif
+#ifndef DBL_MIN_EXP
+#define DBL_MIN_EXP ( - 1021 )
+#endif
+#ifndef LDBL_DIG
+#define LDBL_DIG 18
+#endif
+#ifndef LDBL_MAX
+#define LDBL_MAX 1.1897314953572317650213E+4932L
+#endif
+#ifndef LDBL_MAX_10_EXP
+#define LDBL_MAX_10_EXP ( + 4932 )
+#endif
+#ifndef LDBL_MAX_EXP
+#define LDBL_MAX_EXP ( + 16384 )
+#endif
+#ifndef LDBL_MIN
+#define LDBL_MIN 3.3621031431120935062627E-4932L
+#endif
+#ifndef LDBL_MIN_10_EXP
+#define LDBL_MIN_10_EXP ( - 4931 )
+#endif
+#ifndef LDBL_MIN_EXP
+#define LDBL_MIN_EXP ( - 16381 )
+#endif
+
+
+#define USHRT_DIG 4
+#define UINT_DIG 9
+#define ULONG_DIG 9
+#define ULLONG_DIG 19
+#define UINTMAX_DIG ULLONG_DIG
+
+#define FLT_ULONG_MAX 4294967295.0F
+#define FLT_ULLONG_MAX 18446744073709551615.0F
+#define FLT_UINTMAX_MAX FLT_ULLONG_MAX
+#define FLT_LONG_MAX 2147483647.0F
+#define FLT_LLONG_MAX 9223372036854775807.0F
+#define FLT_INTMAX_MAX FLT_LLONG_MAX
+#define FLT_LONG_MIN (-2147483648.0F)
+#define FLT_LLONG_MIN (-9223372036854775808.0F)
+#define FLT_INTMAX_MIN FLT_LLONG_MIN
+
+#define DBL_ULONG_MAX 4294967295.0
+#define DBL_ULLONG_MAX 18446744073709551615.0
+#define DBL_UINTMAX_MAX DBL_ULLONG_MAX
+#define DBL_LONG_MAX 2147483647.0
+#define DBL_LLONG_MAX 9223372036854775807.0
+#define DBL_INTMAX_MAX DBL_LLONG_MAX
+#define DBL_LONG_MIN (-2147483648.0)
+#define DBL_LLONG_MIN (-9223372036854775808.0)
+#define DBL_INTMAX_MIN DBL_LLONG_MIN
+
+#define LDBL_ULONG_MAX 4294967295.0L
+#define LDBL_ULLONG_MAX 18446744073709551615.0L
+#define LDBL_UINTMAX_MAX LDBL_ULLONG_MAX
+#define LDBL_LONG_MAX 2147483647.0L
+#define LDBL_LLONG_MAX 9223372036854775807.0L
+#define LDBL_INTMAX_MAX LDBL_LLONG_MAX
+#define LDBL_LONG_MIN (-2147483648.0L)
+#define LDBL_LLONG_MIN (-9223372036854775808.0L)
+#define LDBL_INTMAX_MIN LDBL_LLONG_MIN
+
+#define FLTMAX_UINTMAX_MAX LDBL_UINTMAX_MAX
+#define FLTMAX_INTMAX_MAX LDBL_INTMAX_MAX
+#define FLTMAX_INTMAX_MIN LDBL_INTMAX_MIN
+
+typedef union _ast_dbl_exp_u
+{
+ uint32_t e[sizeof(double)/4];
+ double f;
+} _ast_dbl_exp_t;
+
+#define _ast_dbl_exp_index 1
+#define _ast_dbl_exp_shift 20
+
+typedef union _fltmax_exp_u
+{
+ uint32_t e[sizeof(_ast_fltmax_t)/4];
+ _ast_fltmax_t f;
+} _ast_fltmax_exp_t;
+
+#define _ast_fltmax_exp_index 2
+#define _ast_fltmax_exp_shift 0
+
+#define _ast_flt_unsigned_max_t unsigned long long
+#define _ast_flt_nan_init 0xff,0xff,0xff,0x7f
+#define _ast_flt_inf_init 0x00,0x00,0x80,0x7f
+#define _ast_dbl_nan_init 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f
+#define _ast_dbl_inf_init 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x7f
+#define _ast_ldbl_nan_init 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xf0,0x7f
+#define _ast_ldbl_inf_init 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x7f,0xf0,0x7f
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/fs b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/fs
new file mode 100644
index 0000000000..34eb5498d2
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/fs
@@ -0,0 +1,158 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/fs by iffe version 2007-04-04 : : */
+
+#ifndef _def_fs_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fs_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _lib__fxstat 1 /* _fxstat() in default lib(s) */
+#define _lib__lxstat 1 /* _lxstat() in default lib(s) */
+#define _lib__xmknod 1 /* _xmknod() in default lib(s) */
+#define _lib__xstat 1 /* _xstat() in default lib(s) */
+#define _lib_lstat 1 /* lstat() in default lib(s) */
+#define _lib_mknod 1 /* mknod() in default lib(s) */
+#define _lib_sync 1 /* sync() in default lib(s) */
+#include <sys/stat.h>
+#define FS_default "ufs"
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef major
+#define major(x) ( major_t ) ( ( ( ( unsigned ) ( ( x ) ) ) >> 8 ) & 0x7f )
+#endif
+#ifndef minor
+#define minor(x) ( minor_t ) ( ( ( x ) ) & 0xff )
+#endif
+#ifndef makedev
+#define makedev(x,y) ( unsigned short ) ( ( ( ( x ) ) << 8 ) | ( ( ( y ) ) & 0xff ) )
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _sys_mntent 1 /* #include <sys/mntent.h> ok */
+#define _sys_mnttab 1 /* #include <sys/mnttab.h> ok */
+#define _mem_st_blocks_stat 1 /* st_blocks is a member of struct stat */
+#define _mem_st_blksize_stat 1 /* st_blksize is a member of struct stat */
+#define _mem_st_rdev_stat 1 /* st_rdev is a member of struct stat */
+#define _sys_statfs 1 /* #include <sys/statfs.h> ok */
+#define _mem_f_files_statfs 1 /* f_files is a member of struct statfs */
+#define _sys_vfs 1 /* #include <sys/vfs.h> ok */
+#define _sys_param 1 /* #include <sys/param.h> ok */
+#define _sys_mount 1 /* #include <sys/mount.h> ok */
+#define _sys_statvfs 1 /* #include <sys/statvfs.h> ok */
+#define _mem_f_basetype_statvfs 1 /* f_basetype is a member of struct statvfs */
+#define _mem_f_frsize_statvfs 1 /* f_frsize is a member of struct statvfs */
+#define _lib_getmntent 1 /* getmntent() in default lib(s) */
+#define _lib_statfs 1 /* statfs() in default lib(s) */
+#define _lib_statvfs 1 /* statvfs() in default lib(s) */
+#define _lib_statfs4 1 /* compile{\ passed */
+#if _sys_statvfs
+#include <sys/statvfs.h>
+#if !_mem_statvfs_f_basetype
+#if _ary_f_reserved7
+#define f_basetype f_reserved7
+#endif
+#endif
+#else
+#define _mem_f_basetype_statvfs 1
+#define _mem_f_frsize_statvfs 1
+struct statvfs
+{
+unsigned long f_bsize; /* fundamental file system block size */
+unsigned long f_frsize; /* fragment size */
+unsigned long f_blocks; /* total # of blocks of f_frsize on fs */
+unsigned long f_bfree; /* total # of free blocks of f_frsize */
+unsigned long f_bavail; /* # of free blocks avail to non-superuser */
+unsigned long f_files; /* total # of file nodes (inodes) */
+unsigned long f_ffree; /* total # of free file nodes */
+unsigned long f_favail; /* # of free nodes avail to non-superuser */
+unsigned long f_fsid; /* file system id (dev for now) */
+char f_basetype[16]; /* target fs type name, null-terminated */
+unsigned long f_flag; /* bit-mask of flags */
+unsigned long f_namemax; /* maximum file name length */
+char f_fstr[32]; /* filesystem-specific string */
+unsigned long f_filler[16]; /* reserved for future expansion */
+};
+extern __MANGLE__ int fstatvfs __PROTO__((int, struct statvfs*));
+extern __MANGLE__ int statvfs __PROTO__((const char*, struct statvfs*));
+#endif
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_statvfs64 && !defined(statvfs)
+#define statvfs statvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int statvfs64 __PROTO__((const char*, struct statvfs64*));
+#endif
+#endif
+#if _lib_fstatvfs64 && !defined(fstatvfs)
+#define fstatvfs fstatvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int fstatvfs64 __PROTO__((int, struct statvfs64*));
+#endif
+#endif
+
+#define _str_st_fstype 1 /* stat.st_fstype is a string */
+#define _ary_st_pad4 1 /* stat.st_pad4 is an array */
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/hack b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/hack
new file mode 100644
index 0000000000..dfa4fd2d63
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/hack
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/hack by iffe version 2007-04-04 : : */
+#ifndef _def_hack_ast
+#define _def_hack_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/iconv b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/iconv
new file mode 100644
index 0000000000..b8aee7e488
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/iconv
@@ -0,0 +1,132 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/iconv by iffe version 2007-04-04 : : */
+
+#ifndef _def_iconv_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_iconv_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_iconv 1 /* #include <iconv.h> ok */
+#define _lib_iconv_open 1 /* iconv_open() in default lib(s) */
+#define _lib_iconv_close 1 /* iconv_close() in default lib(s) */
+#define _lib_iconv 1 /* iconv() in default lib(s) */
+#define _nxt_iconv <../include/iconv.h> /* include path for the native <iconv.h> */
+#define _nxt_iconv_str "../include/iconv.h" /* include string for the native <iconv.h> */
+#include <ast_common.h>
+#include <ccode.h>
+#include <../include/iconv.h> /* the native iconv.h */
+
+#define CC_ICONV (-1)
+#define CC_UCS (-2)
+#define CC_SCU (-3)
+#define CC_UTF (-4)
+#define CC_UME (-5)
+
+#ifndef _ICONV_LIST_PRIVATE_
+#undef iconv_t
+#define iconv_t _ast_iconv_t
+#undef iconv_f
+#define iconv_f _ast_iconv_f
+#undef iconv_list_t
+#define iconv_list_t _ast_iconv_list_t
+#undef iconv_open
+#define iconv_open _ast_iconv_open
+#undef iconv
+#define iconv _ast_iconv
+#undef iconv_close
+#define iconv_close _ast_iconv_close
+#undef iconv_list
+#define iconv_list _ast_iconv_list
+#undef iconv_move
+#define iconv_move _ast_iconv_move
+#undef iconv_name
+#define iconv_name _ast_iconv_name
+#undef iconv_write
+#define iconv_write _ast_iconv_write
+#endif
+
+typedef Ccmap_t _ast_iconv_list_t;
+typedef __V_* _ast_iconv_t;
+typedef size_t (*_ast_iconv_f) __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ _ast_iconv_t _ast_iconv_open __PROTO__((const char*, const char*));
+extern __MANGLE__ size_t _ast_iconv __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+extern __MANGLE__ int _ast_iconv_close __PROTO__((_ast_iconv_t));
+extern __MANGLE__ _ast_iconv_list_t* _ast_iconv_list __PROTO__((_ast_iconv_list_t*));
+extern __MANGLE__ int _ast_iconv_name __PROTO__((const char*, char*, size_t));
+#if _SFIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, Sfio_t*, Sfio_t*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, Sfio_t*, char**, size_t*, size_t*));
+#else
+#if _SFSTDIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, FILE*, FILE*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, FILE*, char**, size_t*, size_t*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/lib b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/lib
new file mode 100644
index 0000000000..c7bfb927c9
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/lib
@@ -0,0 +1,171 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/lib by iffe version 2007-04-04 : : */
+#ifndef _def_lib_ast
+#define _def_lib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _hdr_fmtmsg 1 /* #include <fmtmsg.h> ok */
+#define _hdr_fnmatch 1 /* #include <fnmatch.h> ok */
+#define _hdr_libgen 1 /* #include <libgen.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_locale 1 /* #include <locale.h> ok */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_spawn 1 /* #include <spawn.h> ok */
+#define _hdr_syslog 1 /* #include <syslog.h> ok */
+#define _hdr_utime 1 /* #include <utime.h> ok */
+#define _hdr_wctype 1 /* #include <wctype.h> ok */
+#define _hdr_wchar 1 /* <wchar.h> and isw*() really work */
+#define _dat__tzname 1 /* _tzname in default lib(s) */
+#define _dat_tzname 1 /* tzname in default lib(s) */
+#define _lib__cleanup 1 /* _cleanup() in default lib(s) */
+#define _lib_atexit 1 /* atexit() in default lib(s) */
+#define _lib_bcopy 1 /* bcopy() in default lib(s) */
+#define _lib_bzero 1 /* bzero() in default lib(s) */
+#define _lib_catclose 1 /* catclose() in default lib(s) */
+#define _lib_catgets 1 /* catgets() in default lib(s) */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_confstr 1 /* confstr() in default lib(s) */
+#define _lib_dup2 1 /* dup2() in default lib(s) */
+#define _lib_execlp 1 /* execlp() in default lib(s) */
+#define _lib_execve 1 /* execve() in default lib(s) */
+#define _lib_execvp 1 /* execvp() in default lib(s) */
+#define _lib_fchmod 1 /* fchmod() in default lib(s) */
+#define _lib_fcntl 1 /* fcntl() in default lib(s) */
+#define _lib_fmtmsg 1 /* fmtmsg() in default lib(s) */
+#define _lib_fnmatch 1 /* fnmatch() in default lib(s) */
+#define _lib_fork 1 /* fork() in default lib(s) */
+#define _lib_fsync 1 /* fsync() in default lib(s) */
+#define _lib_getdents 1 /* getdents() in default lib(s) */
+#define _lib_getdtablesize 1 /* getdtablesize() in default lib(s) */
+#define _lib_getdate 1 /* getdate() in default lib(s) */
+#define _lib_getgroups 1 /* getgroups() in default lib(s) */
+#define _lib_gethostname 1 /* gethostname() in default lib(s) */
+#define _lib_getlogin 1 /* getlogin() in default lib(s) */
+#define _lib_getpagesize 1 /* getpagesize() in default lib(s) */
+#define _lib_getrlimit 1 /* getrlimit() in default lib(s) */
+#define _lib_getopt 1 /* getopt() in default lib(s) */
+#define _lib_getsubopt 1 /* getsubopt() in default lib(s) */
+#define _lib_getopt_long 1 /* getopt_long() in default lib(s) */
+#define _lib_getopt_long_only 1 /* getopt_long_only() in default lib(s) */
+#define _lib_glob 1 /* glob() in default lib(s) */
+#define _lib_index 1 /* index() in default lib(s) */
+#define _lib_iswblank 1 /* iswblank() in default lib(s) */
+#define _lib_iswctype 1 /* iswctype() in default lib(s) */
+#define _lib_killpg 1 /* killpg() in default lib(s) */
+#define _lib_link 1 /* link() in default lib(s) */
+#define _lib_localeconv 1 /* localeconv() in default lib(s) */
+#define _lib_madvise 1 /* madvise() in default lib(s) */
+#define _lib_mbtowc 1 /* mbtowc() in default lib(s) */
+#define _lib_mbrtowc 1 /* mbrtowc() in default lib(s) */
+#define _lib_memalign 1 /* memalign() in default lib(s) */
+#define _lib_memchr 1 /* memchr() in default lib(s) */
+#define _lib_memcpy 1 /* memcpy() in default lib(s) */
+#define _lib_memmove 1 /* memmove() in default lib(s) */
+#define _lib_memset 1 /* memset() in default lib(s) */
+#define _lib_mkdir 1 /* mkdir() in default lib(s) */
+#define _lib_mkfifo 1 /* mkfifo() in default lib(s) */
+#define _lib_mktemp 1 /* mktemp() in default lib(s) */
+#define _lib_mktime 1 /* mktime() in default lib(s) */
+#define _lib_mount 1 /* mount() in default lib(s) */
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _lib_pathconf 1 /* pathconf() in default lib(s) */
+#define _lib_readlink 1 /* readlink() in default lib(s) */
+#define _lib_remove 1 /* remove() in default lib(s) */
+#define _lib_rename 1 /* rename() in default lib(s) */
+#define _lib_rewinddir 1 /* rewinddir() in default lib(s) */
+#define _lib_rindex 1 /* rindex() in default lib(s) */
+#define _lib_rmdir 1 /* rmdir() in default lib(s) */
+#define _lib_setlocale 1 /* setlocale() in default lib(s) */
+#define _lib_setpgid 1 /* setpgid() in default lib(s) */
+#define _lib_setpgrp 1 /* setpgrp() in default lib(s) */
+#define _lib_setreuid 1 /* setreuid() in default lib(s) */
+#define _lib_setsid 1 /* setsid() in default lib(s) */
+#define _lib_setuid 1 /* setuid() in default lib(s) */
+#define _lib_sigaction 1 /* sigaction() in default lib(s) */
+#define _lib_sigprocmask 1 /* sigprocmask() in default lib(s) */
+#define _lib_socketpair 1 /* socketpair() in default lib(s) */
+#define _lib_strchr 1 /* strchr() in default lib(s) */
+#define _lib_strcoll 1 /* strcoll() in default lib(s) */
+#define _lib_strdup 1 /* strdup() in default lib(s) */
+#define _lib_strerror 1 /* strerror() in default lib(s) */
+#define _lib_strcasecmp 1 /* strcasecmp() in default lib(s) */
+#define _lib_strncasecmp 1 /* strncasecmp() in default lib(s) */
+#define _lib_strrchr 1 /* strrchr() in default lib(s) */
+#define _lib_strstr 1 /* strstr() in default lib(s) */
+#define _lib_strxfrm 1 /* strxfrm() in default lib(s) */
+#define _lib_strftime 1 /* strftime() in default lib(s) */
+#define _lib_swab 1 /* swab() in default lib(s) */
+#define _lib_symlink 1 /* symlink() in default lib(s) */
+#define _lib_sysconf 1 /* sysconf() in default lib(s) */
+#define _lib_sysinfo 1 /* sysinfo() in default lib(s) */
+#define _lib_syslog 1 /* syslog() in default lib(s) */
+#define _lib_telldir 1 /* telldir() in default lib(s) */
+#define _lib_tmpnam 1 /* tmpnam() in default lib(s) */
+#define _lib_tzset 1 /* tzset() in default lib(s) */
+#define _lib_unlink 1 /* unlink() in default lib(s) */
+#define _lib_utime 1 /* utime() in default lib(s) */
+#define _lib_wctype 1 /* wctype() in default lib(s) */
+#define _lib_ftruncate 1 /* ftruncate() in default lib(s) */
+#define _lib_truncate 1 /* truncate() in default lib(s) */
+#define _lib_creat64 1 /* creat64() in default lib(s) */
+#define _lib_fstat64 1 /* fstat64() in default lib(s) */
+#define _lib_fstatvfs64 1 /* fstatvfs64() in default lib(s) */
+#define _lib_ftruncate64 1 /* ftruncate64() in default lib(s) */
+#define _lib_lseek64 1 /* lseek64() in default lib(s) */
+#define _lib_lstat64 1 /* lstat64() in default lib(s) */
+#define _lib_open64 1 /* open64() in default lib(s) */
+#define _lib_readdir64 1 /* readdir64() in default lib(s) */
+#define _lib_stat64 1 /* stat64() in default lib(s) */
+#define _lib_statvfs64 1 /* statvfs64() in default lib(s) */
+#define _lib_truncate64 1 /* truncate64() in default lib(s) */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _lib_strtod 1 /* strtod() in default lib(s) */
+#define _lib_strtold 1 /* strtold() in default lib(s) */
+#define _lib_strtol 1 /* strtol() in default lib(s) */
+#define _lib_strtoll 1 /* strtoll() in default lib(s) */
+#define _lib_strtoul 1 /* strtoul() in default lib(s) */
+#define _lib_strtoull 1 /* strtoull() in default lib(s) */
+#define _mem_d_ino_dirent 1 /* d_ino is a member of struct dirent */
+#define _mem_d_off_dirent 1 /* d_off is a member of struct dirent */
+#define _mem_d_reclen_dirent 1 /* d_reclen is a member of struct dirent */
+#define _mem_DIR 1 /* DIR is a non-opaque struct */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _sys_jioctl 1 /* #include <sys/jioctl.h> ok */
+#define _sys_localedef 1 /* #include <sys/localedef.h> ok */
+#define _sys_ptem 1 /* #include <sys/ptem.h> ok */
+#define _sys_resource 1 /* #include <sys/resource.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _sys_stream 1 /* #include <sys/stream.h> ok */
+#define _sys_systeminfo 1 /* #include <sys/systeminfo.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_off64_t 1 /* off64_t is a type */
+#define _typ_struct_dirent64 1 /* struct dirent64 is a type */
+#define _tst_errno 1 /* errno can be assigned */
+#define _lib_poll_fd_1 1 /* fd is first arg to poll() */
+#define _lib_poll 1 /* _lib_poll_fd_1||_lib_poll_fd_2 is true */
+#define _lib_select 1 /* select() has standard 5 arg interface */
+#define _pipe_rw 1 /* full duplex pipes */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _lib_vfork 1 /* vfork exists and it works */
+#define _real_vfork 1 /* vfork child shares data with parent */
+#define _lib_posix_spawn 1 /* posix_spawn exists and it works and its worth using */
+#define _stream_peek 1 /* ioctl(I_PEEK) works */
+#define _socket_peek 1 /* recv(MSG_PEEK) works */
+#define _hdr_string 1 /* #include <string.h> ok */
+#define _lib_memcmp 1 /* standard memcmp interface that works */
+#define _hdr_fcntl 1 /* #include <fcntl.h> ok */
+#define _hdr_signal 1 /* #include <signal.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_memccpy 1 /* standard memccpy interface that works */
+#define _lib_utime_now 1 /* utime works with 0 time vector */
+#define _UNIV_DEFAULT "att" /* default universe name */
+#define _std_cleanup 1 /* stuck with standard _cleanup */
+#define _std_strcoll 1 /* standard strcoll works */
+#if !_AST_no_spawnveg
+#define _use_spawnveg 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/libpath b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/libpath
new file mode 100644
index 0000000000..75420108a9
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/libpath
@@ -0,0 +1,6 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/libpath.sh by iffe version 2007-04-04 : : */
+#ifndef _def_libpath_ast
+#define _def_libpath_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define CONF_LIBPATH "lib/64:LD_LIBRARY_PATH_64:sol.*64*,lib/32:LD_LIBRARY_PATH_32,lib:LD_LIBRARY_PATH"
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/limits b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/limits
new file mode 100644
index 0000000000..dc1593a119
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/limits
@@ -0,0 +1,107 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/limits.c by iffe version 2007-04-04 : : */
+#ifndef _def_limits_ast
+#define _def_limits_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+#ifndef CHAR_MAX
+#define CHAR_MAX 127
+#endif
+#ifndef CHAR_MIN
+#define CHAR_MIN -128
+#endif
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC 1000000
+#endif
+#ifndef INT_MIN
+#define INT_MIN -2147483648
+#endif
+#ifndef LLONG_MAX
+#define LLONG_MAX 9223372036854775807
+#endif
+#ifndef LLONG_MIN
+#define LLONG_MIN -9223372036854775808
+#endif
+#ifndef LONG_MAX
+#define LONG_MAX 2147483647
+#endif
+#ifndef LONG_MIN
+#define LONG_MIN -2147483648
+#endif
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 5
+#endif
+#ifndef OPEN_MAX_CEIL
+#ifndef OPEN_MAX
+#define OPEN_MAX 256
+#endif
+#define OPEN_MAX_CEIL OPEN_MAX
+#endif
+#ifndef PTHREAD_STACK_MIN
+#define PTHREAD_STACK_MIN 4096
+#endif
+#ifndef PTRDIFF_MAX
+#define PTRDIFF_MAX 2147483647
+#endif
+#ifndef PTRDIFF_MIN
+#define PTRDIFF_MIN -2147483648
+#endif
+#ifndef SCHAR_MAX
+#define SCHAR_MAX 127
+#endif
+#ifndef SCHAR_MIN
+#define SCHAR_MIN -128
+#endif
+#ifndef SHRT_MIN
+#define SHRT_MIN -32768
+#endif
+#ifndef SIG_ATOMIC_MAX
+#define SIG_ATOMIC_MAX 2147483647
+#endif
+#ifndef SIG_ATOMIC_MIN
+#define SIG_ATOMIC_MIN -2147483648
+#endif
+#ifndef SIZE_MAX
+#ifndef UINT_MAX
+#define UINT_MAX 4294967295
+#endif
+#define SIZE_MAX UINT_MAX
+#endif
+#ifndef SSIZE_MAX
+#ifndef INT_MAX
+#define INT_MAX 2147483647
+#endif
+#define SSIZE_MAX INT_MAX
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+#ifndef UCHAR_MAX
+#define UCHAR_MAX 255
+#endif
+#ifndef ULLONG_MAX
+#define ULLONG_MAX 18446744073709551615
+#endif
+#ifndef ULONG_MAX
+#define ULONG_MAX 4294967295
+#endif
+#ifndef USHRT_MAX
+#define USHRT_MAX 65535
+#endif
+#ifndef WCHAR_MAX
+#define WCHAR_MAX 2147483647
+#endif
+#ifndef WCHAR_MIN
+#define WCHAR_MIN -2147483648
+#endif
+#ifndef WINT_MAX
+#define WINT_MAX 2147483647
+#endif
+#ifndef WINT_MIN
+#define WINT_MIN -2147483648
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/map b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/map
new file mode 100644
index 0000000000..5ae49fb0a6
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/map
@@ -0,0 +1,438 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/map.c by iffe version 2007-04-04 : : */
+#ifndef _def_map_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_map_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+/*
+ * prototypes provided for standard interfaces hijacked
+ * by ast and mapped to _ast_* but already prototyped
+ * unmapped in native headers included by <ast_std.h>
+ */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+
+#define _map_libc 1
+#undef basename
+#define basename _ast_basename
+#undef dirname
+#define dirname _ast_dirname
+#undef eaccess
+#define eaccess _ast_eaccess
+#undef execvpe
+#define execvpe _ast_execvpe
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+#undef fnmatch
+#define fnmatch _ast_fnmatch
+#undef fts_children
+#define fts_children _ast_fts_children
+#undef fts_close
+#define fts_close _ast_fts_close
+#undef fts_flags
+#define fts_flags _ast_fts_flags
+#undef fts_notify
+#define fts_notify _ast_fts_notify
+#undef fts_open
+#define fts_open _ast_fts_open
+#undef fts_read
+#define fts_read _ast_fts_read
+#undef fts_set
+#define fts_set _ast_fts_set
+#undef ftw
+#define ftw _ast_ftw
+#undef ftwalk
+#define ftwalk _ast_ftwalk
+#undef ftwflags
+#define ftwflags _ast_ftwflags
+#undef getcwd
+#define getcwd _ast_getcwd
+extern __MANGLE__ char* getcwd __PROTO__((char*, size_t));
+#undef getdate
+#define getdate _ast_getdate
+#undef getopt
+#define getopt _ast_getopt
+#undef getsubopt
+#define getsubopt _ast_getsubopt
+#undef getopt_long
+#define getopt_long _ast_getopt_long
+#undef getopt_long_only
+#define getopt_long_only _ast_getopt_long_only
+#undef getwd
+#define getwd _ast_getwd
+extern __MANGLE__ char* getwd __PROTO__((char*));
+#undef glob
+#define glob _ast_glob
+#undef globfree
+#define globfree _ast_globfree
+#undef memdup
+#define memdup _ast_memdup
+#undef memfatal
+#define memfatal _ast_memfatal
+#undef memhash
+#define memhash _ast_memhash
+#undef memsum
+#define memsum _ast_memsum
+#undef mkstemp
+#define mkstemp _ast_mkstemp
+extern __MANGLE__ int mkstemp __PROTO__((char*));
+#undef mktemp
+#define mktemp _ast_mktemp
+extern __MANGLE__ char* mktemp __PROTO__((char*));
+#undef mktime
+#define mktime _ast_mktime
+#undef nftw
+#define nftw _ast_nftw
+#undef optesc
+#define optesc _ast_optesc
+#undef optget
+#define optget _ast_optget
+#undef opthelp
+#define opthelp _ast_opthelp
+#undef optjoin
+#define optjoin _ast_optjoin
+#undef optstr
+#define optstr _ast_optstr
+#undef optusage
+#define optusage _ast_optusage
+#undef pathaccess
+#define pathaccess _ast_pathaccess
+#undef pathbin
+#define pathbin _ast_pathbin
+#undef pathcanon
+#define pathcanon _ast_pathcanon
+#undef pathcat
+#define pathcat _ast_pathcat
+#undef pathcd
+#define pathcd _ast_pathcd
+#undef pathcheck
+#define pathcheck _ast_pathcheck
+#undef pathexists
+#define pathexists _ast_pathexists
+#undef pathfind
+#define pathfind _ast_pathfind
+#undef pathgetlink
+#define pathgetlink _ast_pathgetlink
+#undef pathinclude
+#define pathinclude _ast_pathinclude
+#undef pathkey
+#define pathkey _ast_pathkey
+#undef pathnative
+#define pathnative _ast_pathnative
+#undef pathpath
+#define pathpath _ast_pathpath
+#undef pathposix
+#define pathposix _ast_pathposix
+#undef pathprobe
+#define pathprobe _ast_pathprobe
+#undef pathrepl
+#define pathrepl _ast_pathrepl
+#undef pathsetlink
+#define pathsetlink _ast_pathsetlink
+#undef pathshell
+#define pathshell _ast_pathshell
+#undef pathstat
+#define pathstat _ast_pathstat
+#undef pathtemp
+#define pathtemp _ast_pathtemp
+#undef pathtmp
+#define pathtmp _ast_pathtmp
+#undef procclose
+#define procclose _ast_procclose
+#undef procfree
+#define procfree _ast_procfree
+#undef procopen
+#define procopen _ast_procopen
+#undef procrun
+#define procrun _ast_procrun
+#undef putenv
+#define putenv _ast_putenv
+#undef re_comp
+#define re_comp _ast_re_comp
+#undef re_exec
+#define re_exec _ast_re_exec
+#undef realpath
+#define realpath _ast_realpath
+extern __MANGLE__ char* realpath __PROTO__((const char*, char*));
+#undef regaddclass
+#define regaddclass _ast_regaddclass
+#undef regalloc
+#define regalloc _ast_regalloc
+#undef regcache
+#define regcache _ast_regcache
+#undef regclass
+#define regclass _ast_regclass
+#undef regcmp
+#define regcmp _ast_regcmp
+#undef regcollate
+#define regcollate _ast_regcollate
+#undef regcomb
+#define regcomb _ast_regcomb
+#undef regcomp
+#define regcomp _ast_regcomp
+#undef regdecomp
+#define regdecomp _ast_regdecomp
+#undef regdup
+#define regdup _ast_regdup
+#undef regerror
+#define regerror _ast_regerror
+#undef regex
+#define regex _ast_regex
+#undef regexec
+#define regexec _ast_regexec
+#undef regfatal
+#define regfatal _ast_regfatal
+#undef regfatalpat
+#define regfatalpat _ast_regfatalpat
+#undef regfree
+#define regfree _ast_regfree
+#undef regncomp
+#define regncomp _ast_regncomp
+#undef regnexec
+#define regnexec _ast_regnexec
+#undef regrecord
+#define regrecord _ast_regrecord
+#undef regrexec
+#define regrexec _ast_regrexec
+#undef regstat
+#define regstat _ast_regstat
+#undef regsub
+#define regsub _ast_regsub
+#undef regsubcomp
+#define regsubcomp _ast_regsubcomp
+#undef regsubexec
+#define regsubexec _ast_regsubexec
+#undef regsubflags
+#define regsubflags _ast_regsubflags
+#undef regsubfree
+#define regsubfree _ast_regsubfree
+#undef remove
+#define remove _ast_remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#undef resolvepath
+#define resolvepath _ast_resolvepath
+extern __MANGLE__ char* resolvepath __PROTO__((const char*, char*, size_t));
+#undef setenv
+#define setenv _ast_setenv
+extern __MANGLE__ int setenv __PROTO__((const char*, const char*, int));
+#undef setenviron
+#define setenviron _ast_setenviron
+#undef sigcritical
+#define sigcritical _ast_sigcritical
+#undef signal
+#define signal _ast_signal
+#undef sigunblock
+#define sigunblock _ast_sigunblock
+#undef stracmp
+#define stracmp _ast_stracmp
+#undef strcopy
+#define strcopy _ast_strcopy
+#undef strelapsed
+#define strelapsed _ast_strelapsed
+#undef stresc
+#define stresc _ast_stresc
+#undef streval
+#define streval _ast_streval
+#undef strexpr
+#define strexpr _ast_strexpr
+#undef strftime
+#define strftime _ast_strftime
+#undef strgid
+#define strgid _ast_strgid
+#undef strgrpmatch
+#define strgrpmatch _ast_strgrpmatch
+#undef strhash
+#define strhash _ast_strhash
+#undef strkey
+#define strkey _ast_strkey
+#undef strlcat
+#define strlcat _ast_strlcat
+extern __MANGLE__ size_t strlcat __PROTO__((char*, const char*, size_t));
+#undef strlcpy
+#define strlcpy _ast_strlcpy
+extern __MANGLE__ size_t strlcpy __PROTO__((char*, const char*, size_t));
+#undef strlook
+#define strlook _ast_strlook
+#undef strmatch
+#define strmatch _ast_strmatch
+#undef strmode
+#define strmode _ast_strmode
+#undef strnacmp
+#define strnacmp _ast_strnacmp
+#undef strncopy
+#define strncopy _ast_strncopy
+#undef strntod
+#define strntod _ast_strntod
+#undef strntol
+#define strntol _ast_strntol
+#undef strntold
+#define strntold _ast_strntold
+#undef strntoll
+#define strntoll _ast_strntoll
+#undef strntoul
+#define strntoul _ast_strntoul
+#undef strntoull
+#define strntoull _ast_strntoull
+#undef stropt
+#define stropt _ast_stropt
+#undef strperm
+#define strperm _ast_strperm
+#undef strpsearch
+#define strpsearch _ast_strpsearch
+#undef strptime
+#define strptime _ast_strptime
+#undef strsearch
+#define strsearch _ast_strsearch
+#undef strsort
+#define strsort _ast_strsort
+#undef strsubmatch
+#define strsubmatch _ast_strsubmatch
+#undef strsum
+#define strsum _ast_strsum
+#undef strtape
+#define strtape _ast_strtape
+#undef strtoip4
+#define strtoip4 _ast_strtoip4
+#undef strton
+#define strton _ast_strton
+#undef strtonll
+#define strtonll _ast_strtonll
+#undef struid
+#define struid _ast_struid
+#undef struniq
+#define struniq _ast_struniq
+#undef system
+#define system _ast_system
+extern __MANGLE__ int system __PROTO__((const char*));
+#undef tempnam
+#define tempnam _ast_tempnam
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+#undef tmpnam
+#define tmpnam _ast_tmpnam
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+#undef touch
+#define touch _ast_touch
+#undef wordexp
+#define wordexp _ast_wordexp
+#undef wordfree
+#define wordfree _ast_wordfree
+#undef unsetenv
+#define unsetenv _ast_unsetenv
+
+/* cannot override local malloc */
+#define _map_malloc 1
+#undef calloc
+#define calloc _ast_calloc
+extern __MANGLE__ __V_* calloc __PROTO__((size_t, size_t));
+#undef cfree
+#define cfree _ast_cfree
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+#undef free
+#define free _ast_free
+extern __MANGLE__ void free __PROTO__((__V_*));
+#undef malloc
+#define malloc _ast_malloc
+extern __MANGLE__ __V_* malloc __PROTO__((size_t));
+#undef memalign
+#define memalign _ast_memalign
+extern __MANGLE__ __V_* memalign __PROTO__((size_t, size_t));
+#undef realloc
+#define realloc _ast_realloc
+extern __MANGLE__ __V_* realloc __PROTO__((__V_*, size_t));
+#undef strdup
+#define strdup _ast_strdup
+extern __MANGLE__ char* strdup __PROTO__((const char*));
+#undef valloc
+#define valloc _ast_valloc
+extern __MANGLE__ __V_* valloc __PROTO__((size_t));
+#undef strtol
+#define strtol _ast_strtol
+#undef strtoul
+#define strtoul _ast_strtoul
+#undef strtoll
+#define strtoll _ast_strtoll
+#undef strtoull
+#define strtoull _ast_strtoull
+#undef strtod
+#define strtod _ast_strtod
+#undef strtold
+#define strtold _ast_strtold
+extern __MANGLE__ long strtol __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned long strtoul __PROTO__((const char*, char**, int));
+extern __MANGLE__ double strtod __PROTO__((const char*, char**));
+#if !_UWIN
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
+extern __MANGLE__ _ast_fltmax_t strtold __PROTO__((const char*, char**));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+extern __MANGLE__ _ast_intmax_t strtoll __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned _ast_intmax_t strtoull __PROTO__((const char*, char**, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/mmap b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/mmap
new file mode 100644
index 0000000000..957987b8aa
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/mmap
@@ -0,0 +1,26 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/mmap by iffe version 2007-04-04 : : */
+#ifndef _def_mmap_ast
+#define _def_mmap_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_mmap 1 /* standard mmap interface that works */
+#define _lib_mmap64 1 /* mmap64 interface and implementation work */
+#define _mmap_anon 1 /* use mmap MAP_ANON to get raw memory */
+#define _mmap_devzero 1 /* use mmap on /dev/zero to get raw memory */
+
+/* some systems get it wrong but escape concise detection */
+#ifndef _NO_MMAP
+#if __CYGWIN__
+#define _NO_MMAP 1
+#endif
+#endif
+
+#if _NO_MMAP
+#undef _lib_mmap
+#undef _lib_mmap64
+#undef _mmap_anon
+#undef _mmap_devzero
+#undef _mmap_worthy
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/mode b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/mode
new file mode 100644
index 0000000000..d9e489168f
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/mode
@@ -0,0 +1,14 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/mode.c by iffe version 2007-04-04 : : */
+#ifndef _def_mode_ast
+#define _def_mode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define S_ITYPE(m) ((m)&S_IFMT)
+
+#define S_IPERM (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
+
+#define _S_IDPERM 1
+#define _S_IDTYPE 1
+
+#define BUFFERSIZE 8192
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/nl_types b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/nl_types
new file mode 100644
index 0000000000..088c1c0cb2
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/nl_types
@@ -0,0 +1,102 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/nl_types by iffe version 2007-04-04 : : */
+
+#ifndef _def_nl_types_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_nl_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_nl_langinfo 1 /* nl_langinfo() in default lib(s) */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_langinfo 1 /* #include <langinfo.h> ok */
+#define _nxt_nl_types <../include/nl_types.h> /* include path for the native <nl_types.h> */
+#define _nxt_nl_types_str "../include/nl_types.h" /* include string for the native <nl_types.h> */
+#include <limits.h>
+#include <../include/nl_types.h> /* the native nl_types.h */
+
+#undef NL_SETMAX
+#define NL_SETMAX 1023
+#undef NL_MSGMAX
+#define NL_MSGMAX 32767
+#undef nl_catd
+#define nl_catd _ast_nl_catd
+#undef catopen
+#define catopen _ast_catopen
+#undef catgets
+#define catgets _ast_catgets
+#undef catclose
+#define catclose _ast_catclose
+
+typedef __V_* nl_catd;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ nl_catd catopen __PROTO__((const char*, int));
+extern __MANGLE__ char* catgets __PROTO__((nl_catd, int, int, const char*));
+extern __MANGLE__ int catclose __PROTO__((nl_catd));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/omitted b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/omitted
new file mode 100644
index 0000000000..28602542f8
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/omitted
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/omitted by iffe version 2007-04-04 : : */
+#ifndef _def_omitted_ast
+#define _def_omitted_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/param b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/param
new file mode 100644
index 0000000000..74a6367a3a
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/param
@@ -0,0 +1,9 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/param.sh by iffe version 2007-04-04 : : */
+#ifndef _def_param_ast
+#define _def_param_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#include <sys/param.h>
+#ifndef S_IFDIR
+#include <sys/stat.h>
+#endif
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/preroot b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/preroot
new file mode 100644
index 0000000000..5180fe4be7
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/preroot
@@ -0,0 +1,6 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/preroot.sh by iffe version 2007-04-04 : : */
+#ifndef _def_preroot_ast
+#define _def_preroot_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* preroot not enabled */
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/sfinit b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/sfinit
new file mode 100644
index 0000000000..42331943d1
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/sfinit
@@ -0,0 +1,5332 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/sfinit.c by iffe version 2007-04-04 : : */
+#ifndef _def_sfinit_ast
+#define _def_sfinit_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+static const float sf_flt_pow10[] =
+{
+ 1E0F,
+ 1E1F,
+ 1E2F,
+ 1E3F,
+ 1E4F,
+ 1E5F,
+ 1E6F,
+ 1E7F,
+ 1E8F,
+ 1E9F,
+ 1E10F,
+ 1E11F,
+ 1E12F,
+ 1E13F,
+ 1E14F,
+ 1E15F,
+ 1E16F,
+ 1E17F,
+ 1E18F,
+ 1E19F,
+ 1E20F,
+ 1E21F,
+ 1E22F,
+ 1E23F,
+ 1E24F,
+ 1E25F,
+ 1E26F,
+ 1E27F,
+ 1E28F,
+ 1E29F,
+ 1E30F,
+ 1E31F,
+ 1E32F,
+ 1E33F,
+ 1E34F,
+ 1E35F,
+ 1E36F,
+ 1E37F,
+ 1E38F,
+};
+
+static const double sf_dbl_pow10[] =
+{
+ 1E0,
+ 1E1,
+ 1E2,
+ 1E3,
+ 1E4,
+ 1E5,
+ 1E6,
+ 1E7,
+ 1E8,
+ 1E9,
+ 1E10,
+ 1E11,
+ 1E12,
+ 1E13,
+ 1E14,
+ 1E15,
+ 1E16,
+ 1E17,
+ 1E18,
+ 1E19,
+ 1E20,
+ 1E21,
+ 1E22,
+ 1E23,
+ 1E24,
+ 1E25,
+ 1E26,
+ 1E27,
+ 1E28,
+ 1E29,
+ 1E30,
+ 1E31,
+ 1E32,
+ 1E33,
+ 1E34,
+ 1E35,
+ 1E36,
+ 1E37,
+ 1E38,
+ 1E39,
+ 1E40,
+ 1E41,
+ 1E42,
+ 1E43,
+ 1E44,
+ 1E45,
+ 1E46,
+ 1E47,
+ 1E48,
+ 1E49,
+ 1E50,
+ 1E51,
+ 1E52,
+ 1E53,
+ 1E54,
+ 1E55,
+ 1E56,
+ 1E57,
+ 1E58,
+ 1E59,
+ 1E60,
+ 1E61,
+ 1E62,
+ 1E63,
+ 1E64,
+ 1E65,
+ 1E66,
+ 1E67,
+ 1E68,
+ 1E69,
+ 1E70,
+ 1E71,
+ 1E72,
+ 1E73,
+ 1E74,
+ 1E75,
+ 1E76,
+ 1E77,
+ 1E78,
+ 1E79,
+ 1E80,
+ 1E81,
+ 1E82,
+ 1E83,
+ 1E84,
+ 1E85,
+ 1E86,
+ 1E87,
+ 1E88,
+ 1E89,
+ 1E90,
+ 1E91,
+ 1E92,
+ 1E93,
+ 1E94,
+ 1E95,
+ 1E96,
+ 1E97,
+ 1E98,
+ 1E99,
+ 1E100,
+ 1E101,
+ 1E102,
+ 1E103,
+ 1E104,
+ 1E105,
+ 1E106,
+ 1E107,
+ 1E108,
+ 1E109,
+ 1E110,
+ 1E111,
+ 1E112,
+ 1E113,
+ 1E114,
+ 1E115,
+ 1E116,
+ 1E117,
+ 1E118,
+ 1E119,
+ 1E120,
+ 1E121,
+ 1E122,
+ 1E123,
+ 1E124,
+ 1E125,
+ 1E126,
+ 1E127,
+ 1E128,
+ 1E129,
+ 1E130,
+ 1E131,
+ 1E132,
+ 1E133,
+ 1E134,
+ 1E135,
+ 1E136,
+ 1E137,
+ 1E138,
+ 1E139,
+ 1E140,
+ 1E141,
+ 1E142,
+ 1E143,
+ 1E144,
+ 1E145,
+ 1E146,
+ 1E147,
+ 1E148,
+ 1E149,
+ 1E150,
+ 1E151,
+ 1E152,
+ 1E153,
+ 1E154,
+ 1E155,
+ 1E156,
+ 1E157,
+ 1E158,
+ 1E159,
+ 1E160,
+ 1E161,
+ 1E162,
+ 1E163,
+ 1E164,
+ 1E165,
+ 1E166,
+ 1E167,
+ 1E168,
+ 1E169,
+ 1E170,
+ 1E171,
+ 1E172,
+ 1E173,
+ 1E174,
+ 1E175,
+ 1E176,
+ 1E177,
+ 1E178,
+ 1E179,
+ 1E180,
+ 1E181,
+ 1E182,
+ 1E183,
+ 1E184,
+ 1E185,
+ 1E186,
+ 1E187,
+ 1E188,
+ 1E189,
+ 1E190,
+ 1E191,
+ 1E192,
+ 1E193,
+ 1E194,
+ 1E195,
+ 1E196,
+ 1E197,
+ 1E198,
+ 1E199,
+ 1E200,
+ 1E201,
+ 1E202,
+ 1E203,
+ 1E204,
+ 1E205,
+ 1E206,
+ 1E207,
+ 1E208,
+ 1E209,
+ 1E210,
+ 1E211,
+ 1E212,
+ 1E213,
+ 1E214,
+ 1E215,
+ 1E216,
+ 1E217,
+ 1E218,
+ 1E219,
+ 1E220,
+ 1E221,
+ 1E222,
+ 1E223,
+ 1E224,
+ 1E225,
+ 1E226,
+ 1E227,
+ 1E228,
+ 1E229,
+ 1E230,
+ 1E231,
+ 1E232,
+ 1E233,
+ 1E234,
+ 1E235,
+ 1E236,
+ 1E237,
+ 1E238,
+ 1E239,
+ 1E240,
+ 1E241,
+ 1E242,
+ 1E243,
+ 1E244,
+ 1E245,
+ 1E246,
+ 1E247,
+ 1E248,
+ 1E249,
+ 1E250,
+ 1E251,
+ 1E252,
+ 1E253,
+ 1E254,
+ 1E255,
+ 1E256,
+ 1E257,
+ 1E258,
+ 1E259,
+ 1E260,
+ 1E261,
+ 1E262,
+ 1E263,
+ 1E264,
+ 1E265,
+ 1E266,
+ 1E267,
+ 1E268,
+ 1E269,
+ 1E270,
+ 1E271,
+ 1E272,
+ 1E273,
+ 1E274,
+ 1E275,
+ 1E276,
+ 1E277,
+ 1E278,
+ 1E279,
+ 1E280,
+ 1E281,
+ 1E282,
+ 1E283,
+ 1E284,
+ 1E285,
+ 1E286,
+ 1E287,
+ 1E288,
+ 1E289,
+ 1E290,
+ 1E291,
+ 1E292,
+ 1E293,
+ 1E294,
+ 1E295,
+ 1E296,
+ 1E297,
+ 1E298,
+ 1E299,
+ 1E300,
+ 1E301,
+ 1E302,
+ 1E303,
+ 1E304,
+ 1E305,
+ 1E306,
+ 1E307,
+ 1E308,
+};
+
+static const _ast_fltmax_t sf_ldbl_pow10[] =
+{
+ 1E0L,
+ 1E1L,
+ 1E2L,
+ 1E3L,
+ 1E4L,
+ 1E5L,
+ 1E6L,
+ 1E7L,
+ 1E8L,
+ 1E9L,
+ 1E10L,
+ 1E11L,
+ 1E12L,
+ 1E13L,
+ 1E14L,
+ 1E15L,
+ 1E16L,
+ 1E17L,
+ 1E18L,
+ 1E19L,
+ 1E20L,
+ 1E21L,
+ 1E22L,
+ 1E23L,
+ 1E24L,
+ 1E25L,
+ 1E26L,
+ 1E27L,
+ 1E28L,
+ 1E29L,
+ 1E30L,
+ 1E31L,
+ 1E32L,
+ 1E33L,
+ 1E34L,
+ 1E35L,
+ 1E36L,
+ 1E37L,
+ 1E38L,
+ 1E39L,
+ 1E40L,
+ 1E41L,
+ 1E42L,
+ 1E43L,
+ 1E44L,
+ 1E45L,
+ 1E46L,
+ 1E47L,
+ 1E48L,
+ 1E49L,
+ 1E50L,
+ 1E51L,
+ 1E52L,
+ 1E53L,
+ 1E54L,
+ 1E55L,
+ 1E56L,
+ 1E57L,
+ 1E58L,
+ 1E59L,
+ 1E60L,
+ 1E61L,
+ 1E62L,
+ 1E63L,
+ 1E64L,
+ 1E65L,
+ 1E66L,
+ 1E67L,
+ 1E68L,
+ 1E69L,
+ 1E70L,
+ 1E71L,
+ 1E72L,
+ 1E73L,
+ 1E74L,
+ 1E75L,
+ 1E76L,
+ 1E77L,
+ 1E78L,
+ 1E79L,
+ 1E80L,
+ 1E81L,
+ 1E82L,
+ 1E83L,
+ 1E84L,
+ 1E85L,
+ 1E86L,
+ 1E87L,
+ 1E88L,
+ 1E89L,
+ 1E90L,
+ 1E91L,
+ 1E92L,
+ 1E93L,
+ 1E94L,
+ 1E95L,
+ 1E96L,
+ 1E97L,
+ 1E98L,
+ 1E99L,
+ 1E100L,
+ 1E101L,
+ 1E102L,
+ 1E103L,
+ 1E104L,
+ 1E105L,
+ 1E106L,
+ 1E107L,
+ 1E108L,
+ 1E109L,
+ 1E110L,
+ 1E111L,
+ 1E112L,
+ 1E113L,
+ 1E114L,
+ 1E115L,
+ 1E116L,
+ 1E117L,
+ 1E118L,
+ 1E119L,
+ 1E120L,
+ 1E121L,
+ 1E122L,
+ 1E123L,
+ 1E124L,
+ 1E125L,
+ 1E126L,
+ 1E127L,
+ 1E128L,
+ 1E129L,
+ 1E130L,
+ 1E131L,
+ 1E132L,
+ 1E133L,
+ 1E134L,
+ 1E135L,
+ 1E136L,
+ 1E137L,
+ 1E138L,
+ 1E139L,
+ 1E140L,
+ 1E141L,
+ 1E142L,
+ 1E143L,
+ 1E144L,
+ 1E145L,
+ 1E146L,
+ 1E147L,
+ 1E148L,
+ 1E149L,
+ 1E150L,
+ 1E151L,
+ 1E152L,
+ 1E153L,
+ 1E154L,
+ 1E155L,
+ 1E156L,
+ 1E157L,
+ 1E158L,
+ 1E159L,
+ 1E160L,
+ 1E161L,
+ 1E162L,
+ 1E163L,
+ 1E164L,
+ 1E165L,
+ 1E166L,
+ 1E167L,
+ 1E168L,
+ 1E169L,
+ 1E170L,
+ 1E171L,
+ 1E172L,
+ 1E173L,
+ 1E174L,
+ 1E175L,
+ 1E176L,
+ 1E177L,
+ 1E178L,
+ 1E179L,
+ 1E180L,
+ 1E181L,
+ 1E182L,
+ 1E183L,
+ 1E184L,
+ 1E185L,
+ 1E186L,
+ 1E187L,
+ 1E188L,
+ 1E189L,
+ 1E190L,
+ 1E191L,
+ 1E192L,
+ 1E193L,
+ 1E194L,
+ 1E195L,
+ 1E196L,
+ 1E197L,
+ 1E198L,
+ 1E199L,
+ 1E200L,
+ 1E201L,
+ 1E202L,
+ 1E203L,
+ 1E204L,
+ 1E205L,
+ 1E206L,
+ 1E207L,
+ 1E208L,
+ 1E209L,
+ 1E210L,
+ 1E211L,
+ 1E212L,
+ 1E213L,
+ 1E214L,
+ 1E215L,
+ 1E216L,
+ 1E217L,
+ 1E218L,
+ 1E219L,
+ 1E220L,
+ 1E221L,
+ 1E222L,
+ 1E223L,
+ 1E224L,
+ 1E225L,
+ 1E226L,
+ 1E227L,
+ 1E228L,
+ 1E229L,
+ 1E230L,
+ 1E231L,
+ 1E232L,
+ 1E233L,
+ 1E234L,
+ 1E235L,
+ 1E236L,
+ 1E237L,
+ 1E238L,
+ 1E239L,
+ 1E240L,
+ 1E241L,
+ 1E242L,
+ 1E243L,
+ 1E244L,
+ 1E245L,
+ 1E246L,
+ 1E247L,
+ 1E248L,
+ 1E249L,
+ 1E250L,
+ 1E251L,
+ 1E252L,
+ 1E253L,
+ 1E254L,
+ 1E255L,
+ 1E256L,
+ 1E257L,
+ 1E258L,
+ 1E259L,
+ 1E260L,
+ 1E261L,
+ 1E262L,
+ 1E263L,
+ 1E264L,
+ 1E265L,
+ 1E266L,
+ 1E267L,
+ 1E268L,
+ 1E269L,
+ 1E270L,
+ 1E271L,
+ 1E272L,
+ 1E273L,
+ 1E274L,
+ 1E275L,
+ 1E276L,
+ 1E277L,
+ 1E278L,
+ 1E279L,
+ 1E280L,
+ 1E281L,
+ 1E282L,
+ 1E283L,
+ 1E284L,
+ 1E285L,
+ 1E286L,
+ 1E287L,
+ 1E288L,
+ 1E289L,
+ 1E290L,
+ 1E291L,
+ 1E292L,
+ 1E293L,
+ 1E294L,
+ 1E295L,
+ 1E296L,
+ 1E297L,
+ 1E298L,
+ 1E299L,
+ 1E300L,
+ 1E301L,
+ 1E302L,
+ 1E303L,
+ 1E304L,
+ 1E305L,
+ 1E306L,
+ 1E307L,
+ 1E308L,
+ 1E309L,
+ 1E310L,
+ 1E311L,
+ 1E312L,
+ 1E313L,
+ 1E314L,
+ 1E315L,
+ 1E316L,
+ 1E317L,
+ 1E318L,
+ 1E319L,
+ 1E320L,
+ 1E321L,
+ 1E322L,
+ 1E323L,
+ 1E324L,
+ 1E325L,
+ 1E326L,
+ 1E327L,
+ 1E328L,
+ 1E329L,
+ 1E330L,
+ 1E331L,
+ 1E332L,
+ 1E333L,
+ 1E334L,
+ 1E335L,
+ 1E336L,
+ 1E337L,
+ 1E338L,
+ 1E339L,
+ 1E340L,
+ 1E341L,
+ 1E342L,
+ 1E343L,
+ 1E344L,
+ 1E345L,
+ 1E346L,
+ 1E347L,
+ 1E348L,
+ 1E349L,
+ 1E350L,
+ 1E351L,
+ 1E352L,
+ 1E353L,
+ 1E354L,
+ 1E355L,
+ 1E356L,
+ 1E357L,
+ 1E358L,
+ 1E359L,
+ 1E360L,
+ 1E361L,
+ 1E362L,
+ 1E363L,
+ 1E364L,
+ 1E365L,
+ 1E366L,
+ 1E367L,
+ 1E368L,
+ 1E369L,
+ 1E370L,
+ 1E371L,
+ 1E372L,
+ 1E373L,
+ 1E374L,
+ 1E375L,
+ 1E376L,
+ 1E377L,
+ 1E378L,
+ 1E379L,
+ 1E380L,
+ 1E381L,
+ 1E382L,
+ 1E383L,
+ 1E384L,
+ 1E385L,
+ 1E386L,
+ 1E387L,
+ 1E388L,
+ 1E389L,
+ 1E390L,
+ 1E391L,
+ 1E392L,
+ 1E393L,
+ 1E394L,
+ 1E395L,
+ 1E396L,
+ 1E397L,
+ 1E398L,
+ 1E399L,
+ 1E400L,
+ 1E401L,
+ 1E402L,
+ 1E403L,
+ 1E404L,
+ 1E405L,
+ 1E406L,
+ 1E407L,
+ 1E408L,
+ 1E409L,
+ 1E410L,
+ 1E411L,
+ 1E412L,
+ 1E413L,
+ 1E414L,
+ 1E415L,
+ 1E416L,
+ 1E417L,
+ 1E418L,
+ 1E419L,
+ 1E420L,
+ 1E421L,
+ 1E422L,
+ 1E423L,
+ 1E424L,
+ 1E425L,
+ 1E426L,
+ 1E427L,
+ 1E428L,
+ 1E429L,
+ 1E430L,
+ 1E431L,
+ 1E432L,
+ 1E433L,
+ 1E434L,
+ 1E435L,
+ 1E436L,
+ 1E437L,
+ 1E438L,
+ 1E439L,
+ 1E440L,
+ 1E441L,
+ 1E442L,
+ 1E443L,
+ 1E444L,
+ 1E445L,
+ 1E446L,
+ 1E447L,
+ 1E448L,
+ 1E449L,
+ 1E450L,
+ 1E451L,
+ 1E452L,
+ 1E453L,
+ 1E454L,
+ 1E455L,
+ 1E456L,
+ 1E457L,
+ 1E458L,
+ 1E459L,
+ 1E460L,
+ 1E461L,
+ 1E462L,
+ 1E463L,
+ 1E464L,
+ 1E465L,
+ 1E466L,
+ 1E467L,
+ 1E468L,
+ 1E469L,
+ 1E470L,
+ 1E471L,
+ 1E472L,
+ 1E473L,
+ 1E474L,
+ 1E475L,
+ 1E476L,
+ 1E477L,
+ 1E478L,
+ 1E479L,
+ 1E480L,
+ 1E481L,
+ 1E482L,
+ 1E483L,
+ 1E484L,
+ 1E485L,
+ 1E486L,
+ 1E487L,
+ 1E488L,
+ 1E489L,
+ 1E490L,
+ 1E491L,
+ 1E492L,
+ 1E493L,
+ 1E494L,
+ 1E495L,
+ 1E496L,
+ 1E497L,
+ 1E498L,
+ 1E499L,
+ 1E500L,
+ 1E501L,
+ 1E502L,
+ 1E503L,
+ 1E504L,
+ 1E505L,
+ 1E506L,
+ 1E507L,
+ 1E508L,
+ 1E509L,
+ 1E510L,
+ 1E511L,
+ 1E512L,
+ 1E513L,
+ 1E514L,
+ 1E515L,
+ 1E516L,
+ 1E517L,
+ 1E518L,
+ 1E519L,
+ 1E520L,
+ 1E521L,
+ 1E522L,
+ 1E523L,
+ 1E524L,
+ 1E525L,
+ 1E526L,
+ 1E527L,
+ 1E528L,
+ 1E529L,
+ 1E530L,
+ 1E531L,
+ 1E532L,
+ 1E533L,
+ 1E534L,
+ 1E535L,
+ 1E536L,
+ 1E537L,
+ 1E538L,
+ 1E539L,
+ 1E540L,
+ 1E541L,
+ 1E542L,
+ 1E543L,
+ 1E544L,
+ 1E545L,
+ 1E546L,
+ 1E547L,
+ 1E548L,
+ 1E549L,
+ 1E550L,
+ 1E551L,
+ 1E552L,
+ 1E553L,
+ 1E554L,
+ 1E555L,
+ 1E556L,
+ 1E557L,
+ 1E558L,
+ 1E559L,
+ 1E560L,
+ 1E561L,
+ 1E562L,
+ 1E563L,
+ 1E564L,
+ 1E565L,
+ 1E566L,
+ 1E567L,
+ 1E568L,
+ 1E569L,
+ 1E570L,
+ 1E571L,
+ 1E572L,
+ 1E573L,
+ 1E574L,
+ 1E575L,
+ 1E576L,
+ 1E577L,
+ 1E578L,
+ 1E579L,
+ 1E580L,
+ 1E581L,
+ 1E582L,
+ 1E583L,
+ 1E584L,
+ 1E585L,
+ 1E586L,
+ 1E587L,
+ 1E588L,
+ 1E589L,
+ 1E590L,
+ 1E591L,
+ 1E592L,
+ 1E593L,
+ 1E594L,
+ 1E595L,
+ 1E596L,
+ 1E597L,
+ 1E598L,
+ 1E599L,
+ 1E600L,
+ 1E601L,
+ 1E602L,
+ 1E603L,
+ 1E604L,
+ 1E605L,
+ 1E606L,
+ 1E607L,
+ 1E608L,
+ 1E609L,
+ 1E610L,
+ 1E611L,
+ 1E612L,
+ 1E613L,
+ 1E614L,
+ 1E615L,
+ 1E616L,
+ 1E617L,
+ 1E618L,
+ 1E619L,
+ 1E620L,
+ 1E621L,
+ 1E622L,
+ 1E623L,
+ 1E624L,
+ 1E625L,
+ 1E626L,
+ 1E627L,
+ 1E628L,
+ 1E629L,
+ 1E630L,
+ 1E631L,
+ 1E632L,
+ 1E633L,
+ 1E634L,
+ 1E635L,
+ 1E636L,
+ 1E637L,
+ 1E638L,
+ 1E639L,
+ 1E640L,
+ 1E641L,
+ 1E642L,
+ 1E643L,
+ 1E644L,
+ 1E645L,
+ 1E646L,
+ 1E647L,
+ 1E648L,
+ 1E649L,
+ 1E650L,
+ 1E651L,
+ 1E652L,
+ 1E653L,
+ 1E654L,
+ 1E655L,
+ 1E656L,
+ 1E657L,
+ 1E658L,
+ 1E659L,
+ 1E660L,
+ 1E661L,
+ 1E662L,
+ 1E663L,
+ 1E664L,
+ 1E665L,
+ 1E666L,
+ 1E667L,
+ 1E668L,
+ 1E669L,
+ 1E670L,
+ 1E671L,
+ 1E672L,
+ 1E673L,
+ 1E674L,
+ 1E675L,
+ 1E676L,
+ 1E677L,
+ 1E678L,
+ 1E679L,
+ 1E680L,
+ 1E681L,
+ 1E682L,
+ 1E683L,
+ 1E684L,
+ 1E685L,
+ 1E686L,
+ 1E687L,
+ 1E688L,
+ 1E689L,
+ 1E690L,
+ 1E691L,
+ 1E692L,
+ 1E693L,
+ 1E694L,
+ 1E695L,
+ 1E696L,
+ 1E697L,
+ 1E698L,
+ 1E699L,
+ 1E700L,
+ 1E701L,
+ 1E702L,
+ 1E703L,
+ 1E704L,
+ 1E705L,
+ 1E706L,
+ 1E707L,
+ 1E708L,
+ 1E709L,
+ 1E710L,
+ 1E711L,
+ 1E712L,
+ 1E713L,
+ 1E714L,
+ 1E715L,
+ 1E716L,
+ 1E717L,
+ 1E718L,
+ 1E719L,
+ 1E720L,
+ 1E721L,
+ 1E722L,
+ 1E723L,
+ 1E724L,
+ 1E725L,
+ 1E726L,
+ 1E727L,
+ 1E728L,
+ 1E729L,
+ 1E730L,
+ 1E731L,
+ 1E732L,
+ 1E733L,
+ 1E734L,
+ 1E735L,
+ 1E736L,
+ 1E737L,
+ 1E738L,
+ 1E739L,
+ 1E740L,
+ 1E741L,
+ 1E742L,
+ 1E743L,
+ 1E744L,
+ 1E745L,
+ 1E746L,
+ 1E747L,
+ 1E748L,
+ 1E749L,
+ 1E750L,
+ 1E751L,
+ 1E752L,
+ 1E753L,
+ 1E754L,
+ 1E755L,
+ 1E756L,
+ 1E757L,
+ 1E758L,
+ 1E759L,
+ 1E760L,
+ 1E761L,
+ 1E762L,
+ 1E763L,
+ 1E764L,
+ 1E765L,
+ 1E766L,
+ 1E767L,
+ 1E768L,
+ 1E769L,
+ 1E770L,
+ 1E771L,
+ 1E772L,
+ 1E773L,
+ 1E774L,
+ 1E775L,
+ 1E776L,
+ 1E777L,
+ 1E778L,
+ 1E779L,
+ 1E780L,
+ 1E781L,
+ 1E782L,
+ 1E783L,
+ 1E784L,
+ 1E785L,
+ 1E786L,
+ 1E787L,
+ 1E788L,
+ 1E789L,
+ 1E790L,
+ 1E791L,
+ 1E792L,
+ 1E793L,
+ 1E794L,
+ 1E795L,
+ 1E796L,
+ 1E797L,
+ 1E798L,
+ 1E799L,
+ 1E800L,
+ 1E801L,
+ 1E802L,
+ 1E803L,
+ 1E804L,
+ 1E805L,
+ 1E806L,
+ 1E807L,
+ 1E808L,
+ 1E809L,
+ 1E810L,
+ 1E811L,
+ 1E812L,
+ 1E813L,
+ 1E814L,
+ 1E815L,
+ 1E816L,
+ 1E817L,
+ 1E818L,
+ 1E819L,
+ 1E820L,
+ 1E821L,
+ 1E822L,
+ 1E823L,
+ 1E824L,
+ 1E825L,
+ 1E826L,
+ 1E827L,
+ 1E828L,
+ 1E829L,
+ 1E830L,
+ 1E831L,
+ 1E832L,
+ 1E833L,
+ 1E834L,
+ 1E835L,
+ 1E836L,
+ 1E837L,
+ 1E838L,
+ 1E839L,
+ 1E840L,
+ 1E841L,
+ 1E842L,
+ 1E843L,
+ 1E844L,
+ 1E845L,
+ 1E846L,
+ 1E847L,
+ 1E848L,
+ 1E849L,
+ 1E850L,
+ 1E851L,
+ 1E852L,
+ 1E853L,
+ 1E854L,
+ 1E855L,
+ 1E856L,
+ 1E857L,
+ 1E858L,
+ 1E859L,
+ 1E860L,
+ 1E861L,
+ 1E862L,
+ 1E863L,
+ 1E864L,
+ 1E865L,
+ 1E866L,
+ 1E867L,
+ 1E868L,
+ 1E869L,
+ 1E870L,
+ 1E871L,
+ 1E872L,
+ 1E873L,
+ 1E874L,
+ 1E875L,
+ 1E876L,
+ 1E877L,
+ 1E878L,
+ 1E879L,
+ 1E880L,
+ 1E881L,
+ 1E882L,
+ 1E883L,
+ 1E884L,
+ 1E885L,
+ 1E886L,
+ 1E887L,
+ 1E888L,
+ 1E889L,
+ 1E890L,
+ 1E891L,
+ 1E892L,
+ 1E893L,
+ 1E894L,
+ 1E895L,
+ 1E896L,
+ 1E897L,
+ 1E898L,
+ 1E899L,
+ 1E900L,
+ 1E901L,
+ 1E902L,
+ 1E903L,
+ 1E904L,
+ 1E905L,
+ 1E906L,
+ 1E907L,
+ 1E908L,
+ 1E909L,
+ 1E910L,
+ 1E911L,
+ 1E912L,
+ 1E913L,
+ 1E914L,
+ 1E915L,
+ 1E916L,
+ 1E917L,
+ 1E918L,
+ 1E919L,
+ 1E920L,
+ 1E921L,
+ 1E922L,
+ 1E923L,
+ 1E924L,
+ 1E925L,
+ 1E926L,
+ 1E927L,
+ 1E928L,
+ 1E929L,
+ 1E930L,
+ 1E931L,
+ 1E932L,
+ 1E933L,
+ 1E934L,
+ 1E935L,
+ 1E936L,
+ 1E937L,
+ 1E938L,
+ 1E939L,
+ 1E940L,
+ 1E941L,
+ 1E942L,
+ 1E943L,
+ 1E944L,
+ 1E945L,
+ 1E946L,
+ 1E947L,
+ 1E948L,
+ 1E949L,
+ 1E950L,
+ 1E951L,
+ 1E952L,
+ 1E953L,
+ 1E954L,
+ 1E955L,
+ 1E956L,
+ 1E957L,
+ 1E958L,
+ 1E959L,
+ 1E960L,
+ 1E961L,
+ 1E962L,
+ 1E963L,
+ 1E964L,
+ 1E965L,
+ 1E966L,
+ 1E967L,
+ 1E968L,
+ 1E969L,
+ 1E970L,
+ 1E971L,
+ 1E972L,
+ 1E973L,
+ 1E974L,
+ 1E975L,
+ 1E976L,
+ 1E977L,
+ 1E978L,
+ 1E979L,
+ 1E980L,
+ 1E981L,
+ 1E982L,
+ 1E983L,
+ 1E984L,
+ 1E985L,
+ 1E986L,
+ 1E987L,
+ 1E988L,
+ 1E989L,
+ 1E990L,
+ 1E991L,
+ 1E992L,
+ 1E993L,
+ 1E994L,
+ 1E995L,
+ 1E996L,
+ 1E997L,
+ 1E998L,
+ 1E999L,
+ 1E1000L,
+ 1E1001L,
+ 1E1002L,
+ 1E1003L,
+ 1E1004L,
+ 1E1005L,
+ 1E1006L,
+ 1E1007L,
+ 1E1008L,
+ 1E1009L,
+ 1E1010L,
+ 1E1011L,
+ 1E1012L,
+ 1E1013L,
+ 1E1014L,
+ 1E1015L,
+ 1E1016L,
+ 1E1017L,
+ 1E1018L,
+ 1E1019L,
+ 1E1020L,
+ 1E1021L,
+ 1E1022L,
+ 1E1023L,
+ 1E1024L,
+ 1E1025L,
+ 1E1026L,
+ 1E1027L,
+ 1E1028L,
+ 1E1029L,
+ 1E1030L,
+ 1E1031L,
+ 1E1032L,
+ 1E1033L,
+ 1E1034L,
+ 1E1035L,
+ 1E1036L,
+ 1E1037L,
+ 1E1038L,
+ 1E1039L,
+ 1E1040L,
+ 1E1041L,
+ 1E1042L,
+ 1E1043L,
+ 1E1044L,
+ 1E1045L,
+ 1E1046L,
+ 1E1047L,
+ 1E1048L,
+ 1E1049L,
+ 1E1050L,
+ 1E1051L,
+ 1E1052L,
+ 1E1053L,
+ 1E1054L,
+ 1E1055L,
+ 1E1056L,
+ 1E1057L,
+ 1E1058L,
+ 1E1059L,
+ 1E1060L,
+ 1E1061L,
+ 1E1062L,
+ 1E1063L,
+ 1E1064L,
+ 1E1065L,
+ 1E1066L,
+ 1E1067L,
+ 1E1068L,
+ 1E1069L,
+ 1E1070L,
+ 1E1071L,
+ 1E1072L,
+ 1E1073L,
+ 1E1074L,
+ 1E1075L,
+ 1E1076L,
+ 1E1077L,
+ 1E1078L,
+ 1E1079L,
+ 1E1080L,
+ 1E1081L,
+ 1E1082L,
+ 1E1083L,
+ 1E1084L,
+ 1E1085L,
+ 1E1086L,
+ 1E1087L,
+ 1E1088L,
+ 1E1089L,
+ 1E1090L,
+ 1E1091L,
+ 1E1092L,
+ 1E1093L,
+ 1E1094L,
+ 1E1095L,
+ 1E1096L,
+ 1E1097L,
+ 1E1098L,
+ 1E1099L,
+ 1E1100L,
+ 1E1101L,
+ 1E1102L,
+ 1E1103L,
+ 1E1104L,
+ 1E1105L,
+ 1E1106L,
+ 1E1107L,
+ 1E1108L,
+ 1E1109L,
+ 1E1110L,
+ 1E1111L,
+ 1E1112L,
+ 1E1113L,
+ 1E1114L,
+ 1E1115L,
+ 1E1116L,
+ 1E1117L,
+ 1E1118L,
+ 1E1119L,
+ 1E1120L,
+ 1E1121L,
+ 1E1122L,
+ 1E1123L,
+ 1E1124L,
+ 1E1125L,
+ 1E1126L,
+ 1E1127L,
+ 1E1128L,
+ 1E1129L,
+ 1E1130L,
+ 1E1131L,
+ 1E1132L,
+ 1E1133L,
+ 1E1134L,
+ 1E1135L,
+ 1E1136L,
+ 1E1137L,
+ 1E1138L,
+ 1E1139L,
+ 1E1140L,
+ 1E1141L,
+ 1E1142L,
+ 1E1143L,
+ 1E1144L,
+ 1E1145L,
+ 1E1146L,
+ 1E1147L,
+ 1E1148L,
+ 1E1149L,
+ 1E1150L,
+ 1E1151L,
+ 1E1152L,
+ 1E1153L,
+ 1E1154L,
+ 1E1155L,
+ 1E1156L,
+ 1E1157L,
+ 1E1158L,
+ 1E1159L,
+ 1E1160L,
+ 1E1161L,
+ 1E1162L,
+ 1E1163L,
+ 1E1164L,
+ 1E1165L,
+ 1E1166L,
+ 1E1167L,
+ 1E1168L,
+ 1E1169L,
+ 1E1170L,
+ 1E1171L,
+ 1E1172L,
+ 1E1173L,
+ 1E1174L,
+ 1E1175L,
+ 1E1176L,
+ 1E1177L,
+ 1E1178L,
+ 1E1179L,
+ 1E1180L,
+ 1E1181L,
+ 1E1182L,
+ 1E1183L,
+ 1E1184L,
+ 1E1185L,
+ 1E1186L,
+ 1E1187L,
+ 1E1188L,
+ 1E1189L,
+ 1E1190L,
+ 1E1191L,
+ 1E1192L,
+ 1E1193L,
+ 1E1194L,
+ 1E1195L,
+ 1E1196L,
+ 1E1197L,
+ 1E1198L,
+ 1E1199L,
+ 1E1200L,
+ 1E1201L,
+ 1E1202L,
+ 1E1203L,
+ 1E1204L,
+ 1E1205L,
+ 1E1206L,
+ 1E1207L,
+ 1E1208L,
+ 1E1209L,
+ 1E1210L,
+ 1E1211L,
+ 1E1212L,
+ 1E1213L,
+ 1E1214L,
+ 1E1215L,
+ 1E1216L,
+ 1E1217L,
+ 1E1218L,
+ 1E1219L,
+ 1E1220L,
+ 1E1221L,
+ 1E1222L,
+ 1E1223L,
+ 1E1224L,
+ 1E1225L,
+ 1E1226L,
+ 1E1227L,
+ 1E1228L,
+ 1E1229L,
+ 1E1230L,
+ 1E1231L,
+ 1E1232L,
+ 1E1233L,
+ 1E1234L,
+ 1E1235L,
+ 1E1236L,
+ 1E1237L,
+ 1E1238L,
+ 1E1239L,
+ 1E1240L,
+ 1E1241L,
+ 1E1242L,
+ 1E1243L,
+ 1E1244L,
+ 1E1245L,
+ 1E1246L,
+ 1E1247L,
+ 1E1248L,
+ 1E1249L,
+ 1E1250L,
+ 1E1251L,
+ 1E1252L,
+ 1E1253L,
+ 1E1254L,
+ 1E1255L,
+ 1E1256L,
+ 1E1257L,
+ 1E1258L,
+ 1E1259L,
+ 1E1260L,
+ 1E1261L,
+ 1E1262L,
+ 1E1263L,
+ 1E1264L,
+ 1E1265L,
+ 1E1266L,
+ 1E1267L,
+ 1E1268L,
+ 1E1269L,
+ 1E1270L,
+ 1E1271L,
+ 1E1272L,
+ 1E1273L,
+ 1E1274L,
+ 1E1275L,
+ 1E1276L,
+ 1E1277L,
+ 1E1278L,
+ 1E1279L,
+ 1E1280L,
+ 1E1281L,
+ 1E1282L,
+ 1E1283L,
+ 1E1284L,
+ 1E1285L,
+ 1E1286L,
+ 1E1287L,
+ 1E1288L,
+ 1E1289L,
+ 1E1290L,
+ 1E1291L,
+ 1E1292L,
+ 1E1293L,
+ 1E1294L,
+ 1E1295L,
+ 1E1296L,
+ 1E1297L,
+ 1E1298L,
+ 1E1299L,
+ 1E1300L,
+ 1E1301L,
+ 1E1302L,
+ 1E1303L,
+ 1E1304L,
+ 1E1305L,
+ 1E1306L,
+ 1E1307L,
+ 1E1308L,
+ 1E1309L,
+ 1E1310L,
+ 1E1311L,
+ 1E1312L,
+ 1E1313L,
+ 1E1314L,
+ 1E1315L,
+ 1E1316L,
+ 1E1317L,
+ 1E1318L,
+ 1E1319L,
+ 1E1320L,
+ 1E1321L,
+ 1E1322L,
+ 1E1323L,
+ 1E1324L,
+ 1E1325L,
+ 1E1326L,
+ 1E1327L,
+ 1E1328L,
+ 1E1329L,
+ 1E1330L,
+ 1E1331L,
+ 1E1332L,
+ 1E1333L,
+ 1E1334L,
+ 1E1335L,
+ 1E1336L,
+ 1E1337L,
+ 1E1338L,
+ 1E1339L,
+ 1E1340L,
+ 1E1341L,
+ 1E1342L,
+ 1E1343L,
+ 1E1344L,
+ 1E1345L,
+ 1E1346L,
+ 1E1347L,
+ 1E1348L,
+ 1E1349L,
+ 1E1350L,
+ 1E1351L,
+ 1E1352L,
+ 1E1353L,
+ 1E1354L,
+ 1E1355L,
+ 1E1356L,
+ 1E1357L,
+ 1E1358L,
+ 1E1359L,
+ 1E1360L,
+ 1E1361L,
+ 1E1362L,
+ 1E1363L,
+ 1E1364L,
+ 1E1365L,
+ 1E1366L,
+ 1E1367L,
+ 1E1368L,
+ 1E1369L,
+ 1E1370L,
+ 1E1371L,
+ 1E1372L,
+ 1E1373L,
+ 1E1374L,
+ 1E1375L,
+ 1E1376L,
+ 1E1377L,
+ 1E1378L,
+ 1E1379L,
+ 1E1380L,
+ 1E1381L,
+ 1E1382L,
+ 1E1383L,
+ 1E1384L,
+ 1E1385L,
+ 1E1386L,
+ 1E1387L,
+ 1E1388L,
+ 1E1389L,
+ 1E1390L,
+ 1E1391L,
+ 1E1392L,
+ 1E1393L,
+ 1E1394L,
+ 1E1395L,
+ 1E1396L,
+ 1E1397L,
+ 1E1398L,
+ 1E1399L,
+ 1E1400L,
+ 1E1401L,
+ 1E1402L,
+ 1E1403L,
+ 1E1404L,
+ 1E1405L,
+ 1E1406L,
+ 1E1407L,
+ 1E1408L,
+ 1E1409L,
+ 1E1410L,
+ 1E1411L,
+ 1E1412L,
+ 1E1413L,
+ 1E1414L,
+ 1E1415L,
+ 1E1416L,
+ 1E1417L,
+ 1E1418L,
+ 1E1419L,
+ 1E1420L,
+ 1E1421L,
+ 1E1422L,
+ 1E1423L,
+ 1E1424L,
+ 1E1425L,
+ 1E1426L,
+ 1E1427L,
+ 1E1428L,
+ 1E1429L,
+ 1E1430L,
+ 1E1431L,
+ 1E1432L,
+ 1E1433L,
+ 1E1434L,
+ 1E1435L,
+ 1E1436L,
+ 1E1437L,
+ 1E1438L,
+ 1E1439L,
+ 1E1440L,
+ 1E1441L,
+ 1E1442L,
+ 1E1443L,
+ 1E1444L,
+ 1E1445L,
+ 1E1446L,
+ 1E1447L,
+ 1E1448L,
+ 1E1449L,
+ 1E1450L,
+ 1E1451L,
+ 1E1452L,
+ 1E1453L,
+ 1E1454L,
+ 1E1455L,
+ 1E1456L,
+ 1E1457L,
+ 1E1458L,
+ 1E1459L,
+ 1E1460L,
+ 1E1461L,
+ 1E1462L,
+ 1E1463L,
+ 1E1464L,
+ 1E1465L,
+ 1E1466L,
+ 1E1467L,
+ 1E1468L,
+ 1E1469L,
+ 1E1470L,
+ 1E1471L,
+ 1E1472L,
+ 1E1473L,
+ 1E1474L,
+ 1E1475L,
+ 1E1476L,
+ 1E1477L,
+ 1E1478L,
+ 1E1479L,
+ 1E1480L,
+ 1E1481L,
+ 1E1482L,
+ 1E1483L,
+ 1E1484L,
+ 1E1485L,
+ 1E1486L,
+ 1E1487L,
+ 1E1488L,
+ 1E1489L,
+ 1E1490L,
+ 1E1491L,
+ 1E1492L,
+ 1E1493L,
+ 1E1494L,
+ 1E1495L,
+ 1E1496L,
+ 1E1497L,
+ 1E1498L,
+ 1E1499L,
+ 1E1500L,
+ 1E1501L,
+ 1E1502L,
+ 1E1503L,
+ 1E1504L,
+ 1E1505L,
+ 1E1506L,
+ 1E1507L,
+ 1E1508L,
+ 1E1509L,
+ 1E1510L,
+ 1E1511L,
+ 1E1512L,
+ 1E1513L,
+ 1E1514L,
+ 1E1515L,
+ 1E1516L,
+ 1E1517L,
+ 1E1518L,
+ 1E1519L,
+ 1E1520L,
+ 1E1521L,
+ 1E1522L,
+ 1E1523L,
+ 1E1524L,
+ 1E1525L,
+ 1E1526L,
+ 1E1527L,
+ 1E1528L,
+ 1E1529L,
+ 1E1530L,
+ 1E1531L,
+ 1E1532L,
+ 1E1533L,
+ 1E1534L,
+ 1E1535L,
+ 1E1536L,
+ 1E1537L,
+ 1E1538L,
+ 1E1539L,
+ 1E1540L,
+ 1E1541L,
+ 1E1542L,
+ 1E1543L,
+ 1E1544L,
+ 1E1545L,
+ 1E1546L,
+ 1E1547L,
+ 1E1548L,
+ 1E1549L,
+ 1E1550L,
+ 1E1551L,
+ 1E1552L,
+ 1E1553L,
+ 1E1554L,
+ 1E1555L,
+ 1E1556L,
+ 1E1557L,
+ 1E1558L,
+ 1E1559L,
+ 1E1560L,
+ 1E1561L,
+ 1E1562L,
+ 1E1563L,
+ 1E1564L,
+ 1E1565L,
+ 1E1566L,
+ 1E1567L,
+ 1E1568L,
+ 1E1569L,
+ 1E1570L,
+ 1E1571L,
+ 1E1572L,
+ 1E1573L,
+ 1E1574L,
+ 1E1575L,
+ 1E1576L,
+ 1E1577L,
+ 1E1578L,
+ 1E1579L,
+ 1E1580L,
+ 1E1581L,
+ 1E1582L,
+ 1E1583L,
+ 1E1584L,
+ 1E1585L,
+ 1E1586L,
+ 1E1587L,
+ 1E1588L,
+ 1E1589L,
+ 1E1590L,
+ 1E1591L,
+ 1E1592L,
+ 1E1593L,
+ 1E1594L,
+ 1E1595L,
+ 1E1596L,
+ 1E1597L,
+ 1E1598L,
+ 1E1599L,
+ 1E1600L,
+ 1E1601L,
+ 1E1602L,
+ 1E1603L,
+ 1E1604L,
+ 1E1605L,
+ 1E1606L,
+ 1E1607L,
+ 1E1608L,
+ 1E1609L,
+ 1E1610L,
+ 1E1611L,
+ 1E1612L,
+ 1E1613L,
+ 1E1614L,
+ 1E1615L,
+ 1E1616L,
+ 1E1617L,
+ 1E1618L,
+ 1E1619L,
+ 1E1620L,
+ 1E1621L,
+ 1E1622L,
+ 1E1623L,
+ 1E1624L,
+ 1E1625L,
+ 1E1626L,
+ 1E1627L,
+ 1E1628L,
+ 1E1629L,
+ 1E1630L,
+ 1E1631L,
+ 1E1632L,
+ 1E1633L,
+ 1E1634L,
+ 1E1635L,
+ 1E1636L,
+ 1E1637L,
+ 1E1638L,
+ 1E1639L,
+ 1E1640L,
+ 1E1641L,
+ 1E1642L,
+ 1E1643L,
+ 1E1644L,
+ 1E1645L,
+ 1E1646L,
+ 1E1647L,
+ 1E1648L,
+ 1E1649L,
+ 1E1650L,
+ 1E1651L,
+ 1E1652L,
+ 1E1653L,
+ 1E1654L,
+ 1E1655L,
+ 1E1656L,
+ 1E1657L,
+ 1E1658L,
+ 1E1659L,
+ 1E1660L,
+ 1E1661L,
+ 1E1662L,
+ 1E1663L,
+ 1E1664L,
+ 1E1665L,
+ 1E1666L,
+ 1E1667L,
+ 1E1668L,
+ 1E1669L,
+ 1E1670L,
+ 1E1671L,
+ 1E1672L,
+ 1E1673L,
+ 1E1674L,
+ 1E1675L,
+ 1E1676L,
+ 1E1677L,
+ 1E1678L,
+ 1E1679L,
+ 1E1680L,
+ 1E1681L,
+ 1E1682L,
+ 1E1683L,
+ 1E1684L,
+ 1E1685L,
+ 1E1686L,
+ 1E1687L,
+ 1E1688L,
+ 1E1689L,
+ 1E1690L,
+ 1E1691L,
+ 1E1692L,
+ 1E1693L,
+ 1E1694L,
+ 1E1695L,
+ 1E1696L,
+ 1E1697L,
+ 1E1698L,
+ 1E1699L,
+ 1E1700L,
+ 1E1701L,
+ 1E1702L,
+ 1E1703L,
+ 1E1704L,
+ 1E1705L,
+ 1E1706L,
+ 1E1707L,
+ 1E1708L,
+ 1E1709L,
+ 1E1710L,
+ 1E1711L,
+ 1E1712L,
+ 1E1713L,
+ 1E1714L,
+ 1E1715L,
+ 1E1716L,
+ 1E1717L,
+ 1E1718L,
+ 1E1719L,
+ 1E1720L,
+ 1E1721L,
+ 1E1722L,
+ 1E1723L,
+ 1E1724L,
+ 1E1725L,
+ 1E1726L,
+ 1E1727L,
+ 1E1728L,
+ 1E1729L,
+ 1E1730L,
+ 1E1731L,
+ 1E1732L,
+ 1E1733L,
+ 1E1734L,
+ 1E1735L,
+ 1E1736L,
+ 1E1737L,
+ 1E1738L,
+ 1E1739L,
+ 1E1740L,
+ 1E1741L,
+ 1E1742L,
+ 1E1743L,
+ 1E1744L,
+ 1E1745L,
+ 1E1746L,
+ 1E1747L,
+ 1E1748L,
+ 1E1749L,
+ 1E1750L,
+ 1E1751L,
+ 1E1752L,
+ 1E1753L,
+ 1E1754L,
+ 1E1755L,
+ 1E1756L,
+ 1E1757L,
+ 1E1758L,
+ 1E1759L,
+ 1E1760L,
+ 1E1761L,
+ 1E1762L,
+ 1E1763L,
+ 1E1764L,
+ 1E1765L,
+ 1E1766L,
+ 1E1767L,
+ 1E1768L,
+ 1E1769L,
+ 1E1770L,
+ 1E1771L,
+ 1E1772L,
+ 1E1773L,
+ 1E1774L,
+ 1E1775L,
+ 1E1776L,
+ 1E1777L,
+ 1E1778L,
+ 1E1779L,
+ 1E1780L,
+ 1E1781L,
+ 1E1782L,
+ 1E1783L,
+ 1E1784L,
+ 1E1785L,
+ 1E1786L,
+ 1E1787L,
+ 1E1788L,
+ 1E1789L,
+ 1E1790L,
+ 1E1791L,
+ 1E1792L,
+ 1E1793L,
+ 1E1794L,
+ 1E1795L,
+ 1E1796L,
+ 1E1797L,
+ 1E1798L,
+ 1E1799L,
+ 1E1800L,
+ 1E1801L,
+ 1E1802L,
+ 1E1803L,
+ 1E1804L,
+ 1E1805L,
+ 1E1806L,
+ 1E1807L,
+ 1E1808L,
+ 1E1809L,
+ 1E1810L,
+ 1E1811L,
+ 1E1812L,
+ 1E1813L,
+ 1E1814L,
+ 1E1815L,
+ 1E1816L,
+ 1E1817L,
+ 1E1818L,
+ 1E1819L,
+ 1E1820L,
+ 1E1821L,
+ 1E1822L,
+ 1E1823L,
+ 1E1824L,
+ 1E1825L,
+ 1E1826L,
+ 1E1827L,
+ 1E1828L,
+ 1E1829L,
+ 1E1830L,
+ 1E1831L,
+ 1E1832L,
+ 1E1833L,
+ 1E1834L,
+ 1E1835L,
+ 1E1836L,
+ 1E1837L,
+ 1E1838L,
+ 1E1839L,
+ 1E1840L,
+ 1E1841L,
+ 1E1842L,
+ 1E1843L,
+ 1E1844L,
+ 1E1845L,
+ 1E1846L,
+ 1E1847L,
+ 1E1848L,
+ 1E1849L,
+ 1E1850L,
+ 1E1851L,
+ 1E1852L,
+ 1E1853L,
+ 1E1854L,
+ 1E1855L,
+ 1E1856L,
+ 1E1857L,
+ 1E1858L,
+ 1E1859L,
+ 1E1860L,
+ 1E1861L,
+ 1E1862L,
+ 1E1863L,
+ 1E1864L,
+ 1E1865L,
+ 1E1866L,
+ 1E1867L,
+ 1E1868L,
+ 1E1869L,
+ 1E1870L,
+ 1E1871L,
+ 1E1872L,
+ 1E1873L,
+ 1E1874L,
+ 1E1875L,
+ 1E1876L,
+ 1E1877L,
+ 1E1878L,
+ 1E1879L,
+ 1E1880L,
+ 1E1881L,
+ 1E1882L,
+ 1E1883L,
+ 1E1884L,
+ 1E1885L,
+ 1E1886L,
+ 1E1887L,
+ 1E1888L,
+ 1E1889L,
+ 1E1890L,
+ 1E1891L,
+ 1E1892L,
+ 1E1893L,
+ 1E1894L,
+ 1E1895L,
+ 1E1896L,
+ 1E1897L,
+ 1E1898L,
+ 1E1899L,
+ 1E1900L,
+ 1E1901L,
+ 1E1902L,
+ 1E1903L,
+ 1E1904L,
+ 1E1905L,
+ 1E1906L,
+ 1E1907L,
+ 1E1908L,
+ 1E1909L,
+ 1E1910L,
+ 1E1911L,
+ 1E1912L,
+ 1E1913L,
+ 1E1914L,
+ 1E1915L,
+ 1E1916L,
+ 1E1917L,
+ 1E1918L,
+ 1E1919L,
+ 1E1920L,
+ 1E1921L,
+ 1E1922L,
+ 1E1923L,
+ 1E1924L,
+ 1E1925L,
+ 1E1926L,
+ 1E1927L,
+ 1E1928L,
+ 1E1929L,
+ 1E1930L,
+ 1E1931L,
+ 1E1932L,
+ 1E1933L,
+ 1E1934L,
+ 1E1935L,
+ 1E1936L,
+ 1E1937L,
+ 1E1938L,
+ 1E1939L,
+ 1E1940L,
+ 1E1941L,
+ 1E1942L,
+ 1E1943L,
+ 1E1944L,
+ 1E1945L,
+ 1E1946L,
+ 1E1947L,
+ 1E1948L,
+ 1E1949L,
+ 1E1950L,
+ 1E1951L,
+ 1E1952L,
+ 1E1953L,
+ 1E1954L,
+ 1E1955L,
+ 1E1956L,
+ 1E1957L,
+ 1E1958L,
+ 1E1959L,
+ 1E1960L,
+ 1E1961L,
+ 1E1962L,
+ 1E1963L,
+ 1E1964L,
+ 1E1965L,
+ 1E1966L,
+ 1E1967L,
+ 1E1968L,
+ 1E1969L,
+ 1E1970L,
+ 1E1971L,
+ 1E1972L,
+ 1E1973L,
+ 1E1974L,
+ 1E1975L,
+ 1E1976L,
+ 1E1977L,
+ 1E1978L,
+ 1E1979L,
+ 1E1980L,
+ 1E1981L,
+ 1E1982L,
+ 1E1983L,
+ 1E1984L,
+ 1E1985L,
+ 1E1986L,
+ 1E1987L,
+ 1E1988L,
+ 1E1989L,
+ 1E1990L,
+ 1E1991L,
+ 1E1992L,
+ 1E1993L,
+ 1E1994L,
+ 1E1995L,
+ 1E1996L,
+ 1E1997L,
+ 1E1998L,
+ 1E1999L,
+ 1E2000L,
+ 1E2001L,
+ 1E2002L,
+ 1E2003L,
+ 1E2004L,
+ 1E2005L,
+ 1E2006L,
+ 1E2007L,
+ 1E2008L,
+ 1E2009L,
+ 1E2010L,
+ 1E2011L,
+ 1E2012L,
+ 1E2013L,
+ 1E2014L,
+ 1E2015L,
+ 1E2016L,
+ 1E2017L,
+ 1E2018L,
+ 1E2019L,
+ 1E2020L,
+ 1E2021L,
+ 1E2022L,
+ 1E2023L,
+ 1E2024L,
+ 1E2025L,
+ 1E2026L,
+ 1E2027L,
+ 1E2028L,
+ 1E2029L,
+ 1E2030L,
+ 1E2031L,
+ 1E2032L,
+ 1E2033L,
+ 1E2034L,
+ 1E2035L,
+ 1E2036L,
+ 1E2037L,
+ 1E2038L,
+ 1E2039L,
+ 1E2040L,
+ 1E2041L,
+ 1E2042L,
+ 1E2043L,
+ 1E2044L,
+ 1E2045L,
+ 1E2046L,
+ 1E2047L,
+ 1E2048L,
+ 1E2049L,
+ 1E2050L,
+ 1E2051L,
+ 1E2052L,
+ 1E2053L,
+ 1E2054L,
+ 1E2055L,
+ 1E2056L,
+ 1E2057L,
+ 1E2058L,
+ 1E2059L,
+ 1E2060L,
+ 1E2061L,
+ 1E2062L,
+ 1E2063L,
+ 1E2064L,
+ 1E2065L,
+ 1E2066L,
+ 1E2067L,
+ 1E2068L,
+ 1E2069L,
+ 1E2070L,
+ 1E2071L,
+ 1E2072L,
+ 1E2073L,
+ 1E2074L,
+ 1E2075L,
+ 1E2076L,
+ 1E2077L,
+ 1E2078L,
+ 1E2079L,
+ 1E2080L,
+ 1E2081L,
+ 1E2082L,
+ 1E2083L,
+ 1E2084L,
+ 1E2085L,
+ 1E2086L,
+ 1E2087L,
+ 1E2088L,
+ 1E2089L,
+ 1E2090L,
+ 1E2091L,
+ 1E2092L,
+ 1E2093L,
+ 1E2094L,
+ 1E2095L,
+ 1E2096L,
+ 1E2097L,
+ 1E2098L,
+ 1E2099L,
+ 1E2100L,
+ 1E2101L,
+ 1E2102L,
+ 1E2103L,
+ 1E2104L,
+ 1E2105L,
+ 1E2106L,
+ 1E2107L,
+ 1E2108L,
+ 1E2109L,
+ 1E2110L,
+ 1E2111L,
+ 1E2112L,
+ 1E2113L,
+ 1E2114L,
+ 1E2115L,
+ 1E2116L,
+ 1E2117L,
+ 1E2118L,
+ 1E2119L,
+ 1E2120L,
+ 1E2121L,
+ 1E2122L,
+ 1E2123L,
+ 1E2124L,
+ 1E2125L,
+ 1E2126L,
+ 1E2127L,
+ 1E2128L,
+ 1E2129L,
+ 1E2130L,
+ 1E2131L,
+ 1E2132L,
+ 1E2133L,
+ 1E2134L,
+ 1E2135L,
+ 1E2136L,
+ 1E2137L,
+ 1E2138L,
+ 1E2139L,
+ 1E2140L,
+ 1E2141L,
+ 1E2142L,
+ 1E2143L,
+ 1E2144L,
+ 1E2145L,
+ 1E2146L,
+ 1E2147L,
+ 1E2148L,
+ 1E2149L,
+ 1E2150L,
+ 1E2151L,
+ 1E2152L,
+ 1E2153L,
+ 1E2154L,
+ 1E2155L,
+ 1E2156L,
+ 1E2157L,
+ 1E2158L,
+ 1E2159L,
+ 1E2160L,
+ 1E2161L,
+ 1E2162L,
+ 1E2163L,
+ 1E2164L,
+ 1E2165L,
+ 1E2166L,
+ 1E2167L,
+ 1E2168L,
+ 1E2169L,
+ 1E2170L,
+ 1E2171L,
+ 1E2172L,
+ 1E2173L,
+ 1E2174L,
+ 1E2175L,
+ 1E2176L,
+ 1E2177L,
+ 1E2178L,
+ 1E2179L,
+ 1E2180L,
+ 1E2181L,
+ 1E2182L,
+ 1E2183L,
+ 1E2184L,
+ 1E2185L,
+ 1E2186L,
+ 1E2187L,
+ 1E2188L,
+ 1E2189L,
+ 1E2190L,
+ 1E2191L,
+ 1E2192L,
+ 1E2193L,
+ 1E2194L,
+ 1E2195L,
+ 1E2196L,
+ 1E2197L,
+ 1E2198L,
+ 1E2199L,
+ 1E2200L,
+ 1E2201L,
+ 1E2202L,
+ 1E2203L,
+ 1E2204L,
+ 1E2205L,
+ 1E2206L,
+ 1E2207L,
+ 1E2208L,
+ 1E2209L,
+ 1E2210L,
+ 1E2211L,
+ 1E2212L,
+ 1E2213L,
+ 1E2214L,
+ 1E2215L,
+ 1E2216L,
+ 1E2217L,
+ 1E2218L,
+ 1E2219L,
+ 1E2220L,
+ 1E2221L,
+ 1E2222L,
+ 1E2223L,
+ 1E2224L,
+ 1E2225L,
+ 1E2226L,
+ 1E2227L,
+ 1E2228L,
+ 1E2229L,
+ 1E2230L,
+ 1E2231L,
+ 1E2232L,
+ 1E2233L,
+ 1E2234L,
+ 1E2235L,
+ 1E2236L,
+ 1E2237L,
+ 1E2238L,
+ 1E2239L,
+ 1E2240L,
+ 1E2241L,
+ 1E2242L,
+ 1E2243L,
+ 1E2244L,
+ 1E2245L,
+ 1E2246L,
+ 1E2247L,
+ 1E2248L,
+ 1E2249L,
+ 1E2250L,
+ 1E2251L,
+ 1E2252L,
+ 1E2253L,
+ 1E2254L,
+ 1E2255L,
+ 1E2256L,
+ 1E2257L,
+ 1E2258L,
+ 1E2259L,
+ 1E2260L,
+ 1E2261L,
+ 1E2262L,
+ 1E2263L,
+ 1E2264L,
+ 1E2265L,
+ 1E2266L,
+ 1E2267L,
+ 1E2268L,
+ 1E2269L,
+ 1E2270L,
+ 1E2271L,
+ 1E2272L,
+ 1E2273L,
+ 1E2274L,
+ 1E2275L,
+ 1E2276L,
+ 1E2277L,
+ 1E2278L,
+ 1E2279L,
+ 1E2280L,
+ 1E2281L,
+ 1E2282L,
+ 1E2283L,
+ 1E2284L,
+ 1E2285L,
+ 1E2286L,
+ 1E2287L,
+ 1E2288L,
+ 1E2289L,
+ 1E2290L,
+ 1E2291L,
+ 1E2292L,
+ 1E2293L,
+ 1E2294L,
+ 1E2295L,
+ 1E2296L,
+ 1E2297L,
+ 1E2298L,
+ 1E2299L,
+ 1E2300L,
+ 1E2301L,
+ 1E2302L,
+ 1E2303L,
+ 1E2304L,
+ 1E2305L,
+ 1E2306L,
+ 1E2307L,
+ 1E2308L,
+ 1E2309L,
+ 1E2310L,
+ 1E2311L,
+ 1E2312L,
+ 1E2313L,
+ 1E2314L,
+ 1E2315L,
+ 1E2316L,
+ 1E2317L,
+ 1E2318L,
+ 1E2319L,
+ 1E2320L,
+ 1E2321L,
+ 1E2322L,
+ 1E2323L,
+ 1E2324L,
+ 1E2325L,
+ 1E2326L,
+ 1E2327L,
+ 1E2328L,
+ 1E2329L,
+ 1E2330L,
+ 1E2331L,
+ 1E2332L,
+ 1E2333L,
+ 1E2334L,
+ 1E2335L,
+ 1E2336L,
+ 1E2337L,
+ 1E2338L,
+ 1E2339L,
+ 1E2340L,
+ 1E2341L,
+ 1E2342L,
+ 1E2343L,
+ 1E2344L,
+ 1E2345L,
+ 1E2346L,
+ 1E2347L,
+ 1E2348L,
+ 1E2349L,
+ 1E2350L,
+ 1E2351L,
+ 1E2352L,
+ 1E2353L,
+ 1E2354L,
+ 1E2355L,
+ 1E2356L,
+ 1E2357L,
+ 1E2358L,
+ 1E2359L,
+ 1E2360L,
+ 1E2361L,
+ 1E2362L,
+ 1E2363L,
+ 1E2364L,
+ 1E2365L,
+ 1E2366L,
+ 1E2367L,
+ 1E2368L,
+ 1E2369L,
+ 1E2370L,
+ 1E2371L,
+ 1E2372L,
+ 1E2373L,
+ 1E2374L,
+ 1E2375L,
+ 1E2376L,
+ 1E2377L,
+ 1E2378L,
+ 1E2379L,
+ 1E2380L,
+ 1E2381L,
+ 1E2382L,
+ 1E2383L,
+ 1E2384L,
+ 1E2385L,
+ 1E2386L,
+ 1E2387L,
+ 1E2388L,
+ 1E2389L,
+ 1E2390L,
+ 1E2391L,
+ 1E2392L,
+ 1E2393L,
+ 1E2394L,
+ 1E2395L,
+ 1E2396L,
+ 1E2397L,
+ 1E2398L,
+ 1E2399L,
+ 1E2400L,
+ 1E2401L,
+ 1E2402L,
+ 1E2403L,
+ 1E2404L,
+ 1E2405L,
+ 1E2406L,
+ 1E2407L,
+ 1E2408L,
+ 1E2409L,
+ 1E2410L,
+ 1E2411L,
+ 1E2412L,
+ 1E2413L,
+ 1E2414L,
+ 1E2415L,
+ 1E2416L,
+ 1E2417L,
+ 1E2418L,
+ 1E2419L,
+ 1E2420L,
+ 1E2421L,
+ 1E2422L,
+ 1E2423L,
+ 1E2424L,
+ 1E2425L,
+ 1E2426L,
+ 1E2427L,
+ 1E2428L,
+ 1E2429L,
+ 1E2430L,
+ 1E2431L,
+ 1E2432L,
+ 1E2433L,
+ 1E2434L,
+ 1E2435L,
+ 1E2436L,
+ 1E2437L,
+ 1E2438L,
+ 1E2439L,
+ 1E2440L,
+ 1E2441L,
+ 1E2442L,
+ 1E2443L,
+ 1E2444L,
+ 1E2445L,
+ 1E2446L,
+ 1E2447L,
+ 1E2448L,
+ 1E2449L,
+ 1E2450L,
+ 1E2451L,
+ 1E2452L,
+ 1E2453L,
+ 1E2454L,
+ 1E2455L,
+ 1E2456L,
+ 1E2457L,
+ 1E2458L,
+ 1E2459L,
+ 1E2460L,
+ 1E2461L,
+ 1E2462L,
+ 1E2463L,
+ 1E2464L,
+ 1E2465L,
+ 1E2466L,
+ 1E2467L,
+ 1E2468L,
+ 1E2469L,
+ 1E2470L,
+ 1E2471L,
+ 1E2472L,
+ 1E2473L,
+ 1E2474L,
+ 1E2475L,
+ 1E2476L,
+ 1E2477L,
+ 1E2478L,
+ 1E2479L,
+ 1E2480L,
+ 1E2481L,
+ 1E2482L,
+ 1E2483L,
+ 1E2484L,
+ 1E2485L,
+ 1E2486L,
+ 1E2487L,
+ 1E2488L,
+ 1E2489L,
+ 1E2490L,
+ 1E2491L,
+ 1E2492L,
+ 1E2493L,
+ 1E2494L,
+ 1E2495L,
+ 1E2496L,
+ 1E2497L,
+ 1E2498L,
+ 1E2499L,
+ 1E2500L,
+ 1E2501L,
+ 1E2502L,
+ 1E2503L,
+ 1E2504L,
+ 1E2505L,
+ 1E2506L,
+ 1E2507L,
+ 1E2508L,
+ 1E2509L,
+ 1E2510L,
+ 1E2511L,
+ 1E2512L,
+ 1E2513L,
+ 1E2514L,
+ 1E2515L,
+ 1E2516L,
+ 1E2517L,
+ 1E2518L,
+ 1E2519L,
+ 1E2520L,
+ 1E2521L,
+ 1E2522L,
+ 1E2523L,
+ 1E2524L,
+ 1E2525L,
+ 1E2526L,
+ 1E2527L,
+ 1E2528L,
+ 1E2529L,
+ 1E2530L,
+ 1E2531L,
+ 1E2532L,
+ 1E2533L,
+ 1E2534L,
+ 1E2535L,
+ 1E2536L,
+ 1E2537L,
+ 1E2538L,
+ 1E2539L,
+ 1E2540L,
+ 1E2541L,
+ 1E2542L,
+ 1E2543L,
+ 1E2544L,
+ 1E2545L,
+ 1E2546L,
+ 1E2547L,
+ 1E2548L,
+ 1E2549L,
+ 1E2550L,
+ 1E2551L,
+ 1E2552L,
+ 1E2553L,
+ 1E2554L,
+ 1E2555L,
+ 1E2556L,
+ 1E2557L,
+ 1E2558L,
+ 1E2559L,
+ 1E2560L,
+ 1E2561L,
+ 1E2562L,
+ 1E2563L,
+ 1E2564L,
+ 1E2565L,
+ 1E2566L,
+ 1E2567L,
+ 1E2568L,
+ 1E2569L,
+ 1E2570L,
+ 1E2571L,
+ 1E2572L,
+ 1E2573L,
+ 1E2574L,
+ 1E2575L,
+ 1E2576L,
+ 1E2577L,
+ 1E2578L,
+ 1E2579L,
+ 1E2580L,
+ 1E2581L,
+ 1E2582L,
+ 1E2583L,
+ 1E2584L,
+ 1E2585L,
+ 1E2586L,
+ 1E2587L,
+ 1E2588L,
+ 1E2589L,
+ 1E2590L,
+ 1E2591L,
+ 1E2592L,
+ 1E2593L,
+ 1E2594L,
+ 1E2595L,
+ 1E2596L,
+ 1E2597L,
+ 1E2598L,
+ 1E2599L,
+ 1E2600L,
+ 1E2601L,
+ 1E2602L,
+ 1E2603L,
+ 1E2604L,
+ 1E2605L,
+ 1E2606L,
+ 1E2607L,
+ 1E2608L,
+ 1E2609L,
+ 1E2610L,
+ 1E2611L,
+ 1E2612L,
+ 1E2613L,
+ 1E2614L,
+ 1E2615L,
+ 1E2616L,
+ 1E2617L,
+ 1E2618L,
+ 1E2619L,
+ 1E2620L,
+ 1E2621L,
+ 1E2622L,
+ 1E2623L,
+ 1E2624L,
+ 1E2625L,
+ 1E2626L,
+ 1E2627L,
+ 1E2628L,
+ 1E2629L,
+ 1E2630L,
+ 1E2631L,
+ 1E2632L,
+ 1E2633L,
+ 1E2634L,
+ 1E2635L,
+ 1E2636L,
+ 1E2637L,
+ 1E2638L,
+ 1E2639L,
+ 1E2640L,
+ 1E2641L,
+ 1E2642L,
+ 1E2643L,
+ 1E2644L,
+ 1E2645L,
+ 1E2646L,
+ 1E2647L,
+ 1E2648L,
+ 1E2649L,
+ 1E2650L,
+ 1E2651L,
+ 1E2652L,
+ 1E2653L,
+ 1E2654L,
+ 1E2655L,
+ 1E2656L,
+ 1E2657L,
+ 1E2658L,
+ 1E2659L,
+ 1E2660L,
+ 1E2661L,
+ 1E2662L,
+ 1E2663L,
+ 1E2664L,
+ 1E2665L,
+ 1E2666L,
+ 1E2667L,
+ 1E2668L,
+ 1E2669L,
+ 1E2670L,
+ 1E2671L,
+ 1E2672L,
+ 1E2673L,
+ 1E2674L,
+ 1E2675L,
+ 1E2676L,
+ 1E2677L,
+ 1E2678L,
+ 1E2679L,
+ 1E2680L,
+ 1E2681L,
+ 1E2682L,
+ 1E2683L,
+ 1E2684L,
+ 1E2685L,
+ 1E2686L,
+ 1E2687L,
+ 1E2688L,
+ 1E2689L,
+ 1E2690L,
+ 1E2691L,
+ 1E2692L,
+ 1E2693L,
+ 1E2694L,
+ 1E2695L,
+ 1E2696L,
+ 1E2697L,
+ 1E2698L,
+ 1E2699L,
+ 1E2700L,
+ 1E2701L,
+ 1E2702L,
+ 1E2703L,
+ 1E2704L,
+ 1E2705L,
+ 1E2706L,
+ 1E2707L,
+ 1E2708L,
+ 1E2709L,
+ 1E2710L,
+ 1E2711L,
+ 1E2712L,
+ 1E2713L,
+ 1E2714L,
+ 1E2715L,
+ 1E2716L,
+ 1E2717L,
+ 1E2718L,
+ 1E2719L,
+ 1E2720L,
+ 1E2721L,
+ 1E2722L,
+ 1E2723L,
+ 1E2724L,
+ 1E2725L,
+ 1E2726L,
+ 1E2727L,
+ 1E2728L,
+ 1E2729L,
+ 1E2730L,
+ 1E2731L,
+ 1E2732L,
+ 1E2733L,
+ 1E2734L,
+ 1E2735L,
+ 1E2736L,
+ 1E2737L,
+ 1E2738L,
+ 1E2739L,
+ 1E2740L,
+ 1E2741L,
+ 1E2742L,
+ 1E2743L,
+ 1E2744L,
+ 1E2745L,
+ 1E2746L,
+ 1E2747L,
+ 1E2748L,
+ 1E2749L,
+ 1E2750L,
+ 1E2751L,
+ 1E2752L,
+ 1E2753L,
+ 1E2754L,
+ 1E2755L,
+ 1E2756L,
+ 1E2757L,
+ 1E2758L,
+ 1E2759L,
+ 1E2760L,
+ 1E2761L,
+ 1E2762L,
+ 1E2763L,
+ 1E2764L,
+ 1E2765L,
+ 1E2766L,
+ 1E2767L,
+ 1E2768L,
+ 1E2769L,
+ 1E2770L,
+ 1E2771L,
+ 1E2772L,
+ 1E2773L,
+ 1E2774L,
+ 1E2775L,
+ 1E2776L,
+ 1E2777L,
+ 1E2778L,
+ 1E2779L,
+ 1E2780L,
+ 1E2781L,
+ 1E2782L,
+ 1E2783L,
+ 1E2784L,
+ 1E2785L,
+ 1E2786L,
+ 1E2787L,
+ 1E2788L,
+ 1E2789L,
+ 1E2790L,
+ 1E2791L,
+ 1E2792L,
+ 1E2793L,
+ 1E2794L,
+ 1E2795L,
+ 1E2796L,
+ 1E2797L,
+ 1E2798L,
+ 1E2799L,
+ 1E2800L,
+ 1E2801L,
+ 1E2802L,
+ 1E2803L,
+ 1E2804L,
+ 1E2805L,
+ 1E2806L,
+ 1E2807L,
+ 1E2808L,
+ 1E2809L,
+ 1E2810L,
+ 1E2811L,
+ 1E2812L,
+ 1E2813L,
+ 1E2814L,
+ 1E2815L,
+ 1E2816L,
+ 1E2817L,
+ 1E2818L,
+ 1E2819L,
+ 1E2820L,
+ 1E2821L,
+ 1E2822L,
+ 1E2823L,
+ 1E2824L,
+ 1E2825L,
+ 1E2826L,
+ 1E2827L,
+ 1E2828L,
+ 1E2829L,
+ 1E2830L,
+ 1E2831L,
+ 1E2832L,
+ 1E2833L,
+ 1E2834L,
+ 1E2835L,
+ 1E2836L,
+ 1E2837L,
+ 1E2838L,
+ 1E2839L,
+ 1E2840L,
+ 1E2841L,
+ 1E2842L,
+ 1E2843L,
+ 1E2844L,
+ 1E2845L,
+ 1E2846L,
+ 1E2847L,
+ 1E2848L,
+ 1E2849L,
+ 1E2850L,
+ 1E2851L,
+ 1E2852L,
+ 1E2853L,
+ 1E2854L,
+ 1E2855L,
+ 1E2856L,
+ 1E2857L,
+ 1E2858L,
+ 1E2859L,
+ 1E2860L,
+ 1E2861L,
+ 1E2862L,
+ 1E2863L,
+ 1E2864L,
+ 1E2865L,
+ 1E2866L,
+ 1E2867L,
+ 1E2868L,
+ 1E2869L,
+ 1E2870L,
+ 1E2871L,
+ 1E2872L,
+ 1E2873L,
+ 1E2874L,
+ 1E2875L,
+ 1E2876L,
+ 1E2877L,
+ 1E2878L,
+ 1E2879L,
+ 1E2880L,
+ 1E2881L,
+ 1E2882L,
+ 1E2883L,
+ 1E2884L,
+ 1E2885L,
+ 1E2886L,
+ 1E2887L,
+ 1E2888L,
+ 1E2889L,
+ 1E2890L,
+ 1E2891L,
+ 1E2892L,
+ 1E2893L,
+ 1E2894L,
+ 1E2895L,
+ 1E2896L,
+ 1E2897L,
+ 1E2898L,
+ 1E2899L,
+ 1E2900L,
+ 1E2901L,
+ 1E2902L,
+ 1E2903L,
+ 1E2904L,
+ 1E2905L,
+ 1E2906L,
+ 1E2907L,
+ 1E2908L,
+ 1E2909L,
+ 1E2910L,
+ 1E2911L,
+ 1E2912L,
+ 1E2913L,
+ 1E2914L,
+ 1E2915L,
+ 1E2916L,
+ 1E2917L,
+ 1E2918L,
+ 1E2919L,
+ 1E2920L,
+ 1E2921L,
+ 1E2922L,
+ 1E2923L,
+ 1E2924L,
+ 1E2925L,
+ 1E2926L,
+ 1E2927L,
+ 1E2928L,
+ 1E2929L,
+ 1E2930L,
+ 1E2931L,
+ 1E2932L,
+ 1E2933L,
+ 1E2934L,
+ 1E2935L,
+ 1E2936L,
+ 1E2937L,
+ 1E2938L,
+ 1E2939L,
+ 1E2940L,
+ 1E2941L,
+ 1E2942L,
+ 1E2943L,
+ 1E2944L,
+ 1E2945L,
+ 1E2946L,
+ 1E2947L,
+ 1E2948L,
+ 1E2949L,
+ 1E2950L,
+ 1E2951L,
+ 1E2952L,
+ 1E2953L,
+ 1E2954L,
+ 1E2955L,
+ 1E2956L,
+ 1E2957L,
+ 1E2958L,
+ 1E2959L,
+ 1E2960L,
+ 1E2961L,
+ 1E2962L,
+ 1E2963L,
+ 1E2964L,
+ 1E2965L,
+ 1E2966L,
+ 1E2967L,
+ 1E2968L,
+ 1E2969L,
+ 1E2970L,
+ 1E2971L,
+ 1E2972L,
+ 1E2973L,
+ 1E2974L,
+ 1E2975L,
+ 1E2976L,
+ 1E2977L,
+ 1E2978L,
+ 1E2979L,
+ 1E2980L,
+ 1E2981L,
+ 1E2982L,
+ 1E2983L,
+ 1E2984L,
+ 1E2985L,
+ 1E2986L,
+ 1E2987L,
+ 1E2988L,
+ 1E2989L,
+ 1E2990L,
+ 1E2991L,
+ 1E2992L,
+ 1E2993L,
+ 1E2994L,
+ 1E2995L,
+ 1E2996L,
+ 1E2997L,
+ 1E2998L,
+ 1E2999L,
+ 1E3000L,
+ 1E3001L,
+ 1E3002L,
+ 1E3003L,
+ 1E3004L,
+ 1E3005L,
+ 1E3006L,
+ 1E3007L,
+ 1E3008L,
+ 1E3009L,
+ 1E3010L,
+ 1E3011L,
+ 1E3012L,
+ 1E3013L,
+ 1E3014L,
+ 1E3015L,
+ 1E3016L,
+ 1E3017L,
+ 1E3018L,
+ 1E3019L,
+ 1E3020L,
+ 1E3021L,
+ 1E3022L,
+ 1E3023L,
+ 1E3024L,
+ 1E3025L,
+ 1E3026L,
+ 1E3027L,
+ 1E3028L,
+ 1E3029L,
+ 1E3030L,
+ 1E3031L,
+ 1E3032L,
+ 1E3033L,
+ 1E3034L,
+ 1E3035L,
+ 1E3036L,
+ 1E3037L,
+ 1E3038L,
+ 1E3039L,
+ 1E3040L,
+ 1E3041L,
+ 1E3042L,
+ 1E3043L,
+ 1E3044L,
+ 1E3045L,
+ 1E3046L,
+ 1E3047L,
+ 1E3048L,
+ 1E3049L,
+ 1E3050L,
+ 1E3051L,
+ 1E3052L,
+ 1E3053L,
+ 1E3054L,
+ 1E3055L,
+ 1E3056L,
+ 1E3057L,
+ 1E3058L,
+ 1E3059L,
+ 1E3060L,
+ 1E3061L,
+ 1E3062L,
+ 1E3063L,
+ 1E3064L,
+ 1E3065L,
+ 1E3066L,
+ 1E3067L,
+ 1E3068L,
+ 1E3069L,
+ 1E3070L,
+ 1E3071L,
+ 1E3072L,
+ 1E3073L,
+ 1E3074L,
+ 1E3075L,
+ 1E3076L,
+ 1E3077L,
+ 1E3078L,
+ 1E3079L,
+ 1E3080L,
+ 1E3081L,
+ 1E3082L,
+ 1E3083L,
+ 1E3084L,
+ 1E3085L,
+ 1E3086L,
+ 1E3087L,
+ 1E3088L,
+ 1E3089L,
+ 1E3090L,
+ 1E3091L,
+ 1E3092L,
+ 1E3093L,
+ 1E3094L,
+ 1E3095L,
+ 1E3096L,
+ 1E3097L,
+ 1E3098L,
+ 1E3099L,
+ 1E3100L,
+ 1E3101L,
+ 1E3102L,
+ 1E3103L,
+ 1E3104L,
+ 1E3105L,
+ 1E3106L,
+ 1E3107L,
+ 1E3108L,
+ 1E3109L,
+ 1E3110L,
+ 1E3111L,
+ 1E3112L,
+ 1E3113L,
+ 1E3114L,
+ 1E3115L,
+ 1E3116L,
+ 1E3117L,
+ 1E3118L,
+ 1E3119L,
+ 1E3120L,
+ 1E3121L,
+ 1E3122L,
+ 1E3123L,
+ 1E3124L,
+ 1E3125L,
+ 1E3126L,
+ 1E3127L,
+ 1E3128L,
+ 1E3129L,
+ 1E3130L,
+ 1E3131L,
+ 1E3132L,
+ 1E3133L,
+ 1E3134L,
+ 1E3135L,
+ 1E3136L,
+ 1E3137L,
+ 1E3138L,
+ 1E3139L,
+ 1E3140L,
+ 1E3141L,
+ 1E3142L,
+ 1E3143L,
+ 1E3144L,
+ 1E3145L,
+ 1E3146L,
+ 1E3147L,
+ 1E3148L,
+ 1E3149L,
+ 1E3150L,
+ 1E3151L,
+ 1E3152L,
+ 1E3153L,
+ 1E3154L,
+ 1E3155L,
+ 1E3156L,
+ 1E3157L,
+ 1E3158L,
+ 1E3159L,
+ 1E3160L,
+ 1E3161L,
+ 1E3162L,
+ 1E3163L,
+ 1E3164L,
+ 1E3165L,
+ 1E3166L,
+ 1E3167L,
+ 1E3168L,
+ 1E3169L,
+ 1E3170L,
+ 1E3171L,
+ 1E3172L,
+ 1E3173L,
+ 1E3174L,
+ 1E3175L,
+ 1E3176L,
+ 1E3177L,
+ 1E3178L,
+ 1E3179L,
+ 1E3180L,
+ 1E3181L,
+ 1E3182L,
+ 1E3183L,
+ 1E3184L,
+ 1E3185L,
+ 1E3186L,
+ 1E3187L,
+ 1E3188L,
+ 1E3189L,
+ 1E3190L,
+ 1E3191L,
+ 1E3192L,
+ 1E3193L,
+ 1E3194L,
+ 1E3195L,
+ 1E3196L,
+ 1E3197L,
+ 1E3198L,
+ 1E3199L,
+ 1E3200L,
+ 1E3201L,
+ 1E3202L,
+ 1E3203L,
+ 1E3204L,
+ 1E3205L,
+ 1E3206L,
+ 1E3207L,
+ 1E3208L,
+ 1E3209L,
+ 1E3210L,
+ 1E3211L,
+ 1E3212L,
+ 1E3213L,
+ 1E3214L,
+ 1E3215L,
+ 1E3216L,
+ 1E3217L,
+ 1E3218L,
+ 1E3219L,
+ 1E3220L,
+ 1E3221L,
+ 1E3222L,
+ 1E3223L,
+ 1E3224L,
+ 1E3225L,
+ 1E3226L,
+ 1E3227L,
+ 1E3228L,
+ 1E3229L,
+ 1E3230L,
+ 1E3231L,
+ 1E3232L,
+ 1E3233L,
+ 1E3234L,
+ 1E3235L,
+ 1E3236L,
+ 1E3237L,
+ 1E3238L,
+ 1E3239L,
+ 1E3240L,
+ 1E3241L,
+ 1E3242L,
+ 1E3243L,
+ 1E3244L,
+ 1E3245L,
+ 1E3246L,
+ 1E3247L,
+ 1E3248L,
+ 1E3249L,
+ 1E3250L,
+ 1E3251L,
+ 1E3252L,
+ 1E3253L,
+ 1E3254L,
+ 1E3255L,
+ 1E3256L,
+ 1E3257L,
+ 1E3258L,
+ 1E3259L,
+ 1E3260L,
+ 1E3261L,
+ 1E3262L,
+ 1E3263L,
+ 1E3264L,
+ 1E3265L,
+ 1E3266L,
+ 1E3267L,
+ 1E3268L,
+ 1E3269L,
+ 1E3270L,
+ 1E3271L,
+ 1E3272L,
+ 1E3273L,
+ 1E3274L,
+ 1E3275L,
+ 1E3276L,
+ 1E3277L,
+ 1E3278L,
+ 1E3279L,
+ 1E3280L,
+ 1E3281L,
+ 1E3282L,
+ 1E3283L,
+ 1E3284L,
+ 1E3285L,
+ 1E3286L,
+ 1E3287L,
+ 1E3288L,
+ 1E3289L,
+ 1E3290L,
+ 1E3291L,
+ 1E3292L,
+ 1E3293L,
+ 1E3294L,
+ 1E3295L,
+ 1E3296L,
+ 1E3297L,
+ 1E3298L,
+ 1E3299L,
+ 1E3300L,
+ 1E3301L,
+ 1E3302L,
+ 1E3303L,
+ 1E3304L,
+ 1E3305L,
+ 1E3306L,
+ 1E3307L,
+ 1E3308L,
+ 1E3309L,
+ 1E3310L,
+ 1E3311L,
+ 1E3312L,
+ 1E3313L,
+ 1E3314L,
+ 1E3315L,
+ 1E3316L,
+ 1E3317L,
+ 1E3318L,
+ 1E3319L,
+ 1E3320L,
+ 1E3321L,
+ 1E3322L,
+ 1E3323L,
+ 1E3324L,
+ 1E3325L,
+ 1E3326L,
+ 1E3327L,
+ 1E3328L,
+ 1E3329L,
+ 1E3330L,
+ 1E3331L,
+ 1E3332L,
+ 1E3333L,
+ 1E3334L,
+ 1E3335L,
+ 1E3336L,
+ 1E3337L,
+ 1E3338L,
+ 1E3339L,
+ 1E3340L,
+ 1E3341L,
+ 1E3342L,
+ 1E3343L,
+ 1E3344L,
+ 1E3345L,
+ 1E3346L,
+ 1E3347L,
+ 1E3348L,
+ 1E3349L,
+ 1E3350L,
+ 1E3351L,
+ 1E3352L,
+ 1E3353L,
+ 1E3354L,
+ 1E3355L,
+ 1E3356L,
+ 1E3357L,
+ 1E3358L,
+ 1E3359L,
+ 1E3360L,
+ 1E3361L,
+ 1E3362L,
+ 1E3363L,
+ 1E3364L,
+ 1E3365L,
+ 1E3366L,
+ 1E3367L,
+ 1E3368L,
+ 1E3369L,
+ 1E3370L,
+ 1E3371L,
+ 1E3372L,
+ 1E3373L,
+ 1E3374L,
+ 1E3375L,
+ 1E3376L,
+ 1E3377L,
+ 1E3378L,
+ 1E3379L,
+ 1E3380L,
+ 1E3381L,
+ 1E3382L,
+ 1E3383L,
+ 1E3384L,
+ 1E3385L,
+ 1E3386L,
+ 1E3387L,
+ 1E3388L,
+ 1E3389L,
+ 1E3390L,
+ 1E3391L,
+ 1E3392L,
+ 1E3393L,
+ 1E3394L,
+ 1E3395L,
+ 1E3396L,
+ 1E3397L,
+ 1E3398L,
+ 1E3399L,
+ 1E3400L,
+ 1E3401L,
+ 1E3402L,
+ 1E3403L,
+ 1E3404L,
+ 1E3405L,
+ 1E3406L,
+ 1E3407L,
+ 1E3408L,
+ 1E3409L,
+ 1E3410L,
+ 1E3411L,
+ 1E3412L,
+ 1E3413L,
+ 1E3414L,
+ 1E3415L,
+ 1E3416L,
+ 1E3417L,
+ 1E3418L,
+ 1E3419L,
+ 1E3420L,
+ 1E3421L,
+ 1E3422L,
+ 1E3423L,
+ 1E3424L,
+ 1E3425L,
+ 1E3426L,
+ 1E3427L,
+ 1E3428L,
+ 1E3429L,
+ 1E3430L,
+ 1E3431L,
+ 1E3432L,
+ 1E3433L,
+ 1E3434L,
+ 1E3435L,
+ 1E3436L,
+ 1E3437L,
+ 1E3438L,
+ 1E3439L,
+ 1E3440L,
+ 1E3441L,
+ 1E3442L,
+ 1E3443L,
+ 1E3444L,
+ 1E3445L,
+ 1E3446L,
+ 1E3447L,
+ 1E3448L,
+ 1E3449L,
+ 1E3450L,
+ 1E3451L,
+ 1E3452L,
+ 1E3453L,
+ 1E3454L,
+ 1E3455L,
+ 1E3456L,
+ 1E3457L,
+ 1E3458L,
+ 1E3459L,
+ 1E3460L,
+ 1E3461L,
+ 1E3462L,
+ 1E3463L,
+ 1E3464L,
+ 1E3465L,
+ 1E3466L,
+ 1E3467L,
+ 1E3468L,
+ 1E3469L,
+ 1E3470L,
+ 1E3471L,
+ 1E3472L,
+ 1E3473L,
+ 1E3474L,
+ 1E3475L,
+ 1E3476L,
+ 1E3477L,
+ 1E3478L,
+ 1E3479L,
+ 1E3480L,
+ 1E3481L,
+ 1E3482L,
+ 1E3483L,
+ 1E3484L,
+ 1E3485L,
+ 1E3486L,
+ 1E3487L,
+ 1E3488L,
+ 1E3489L,
+ 1E3490L,
+ 1E3491L,
+ 1E3492L,
+ 1E3493L,
+ 1E3494L,
+ 1E3495L,
+ 1E3496L,
+ 1E3497L,
+ 1E3498L,
+ 1E3499L,
+ 1E3500L,
+ 1E3501L,
+ 1E3502L,
+ 1E3503L,
+ 1E3504L,
+ 1E3505L,
+ 1E3506L,
+ 1E3507L,
+ 1E3508L,
+ 1E3509L,
+ 1E3510L,
+ 1E3511L,
+ 1E3512L,
+ 1E3513L,
+ 1E3514L,
+ 1E3515L,
+ 1E3516L,
+ 1E3517L,
+ 1E3518L,
+ 1E3519L,
+ 1E3520L,
+ 1E3521L,
+ 1E3522L,
+ 1E3523L,
+ 1E3524L,
+ 1E3525L,
+ 1E3526L,
+ 1E3527L,
+ 1E3528L,
+ 1E3529L,
+ 1E3530L,
+ 1E3531L,
+ 1E3532L,
+ 1E3533L,
+ 1E3534L,
+ 1E3535L,
+ 1E3536L,
+ 1E3537L,
+ 1E3538L,
+ 1E3539L,
+ 1E3540L,
+ 1E3541L,
+ 1E3542L,
+ 1E3543L,
+ 1E3544L,
+ 1E3545L,
+ 1E3546L,
+ 1E3547L,
+ 1E3548L,
+ 1E3549L,
+ 1E3550L,
+ 1E3551L,
+ 1E3552L,
+ 1E3553L,
+ 1E3554L,
+ 1E3555L,
+ 1E3556L,
+ 1E3557L,
+ 1E3558L,
+ 1E3559L,
+ 1E3560L,
+ 1E3561L,
+ 1E3562L,
+ 1E3563L,
+ 1E3564L,
+ 1E3565L,
+ 1E3566L,
+ 1E3567L,
+ 1E3568L,
+ 1E3569L,
+ 1E3570L,
+ 1E3571L,
+ 1E3572L,
+ 1E3573L,
+ 1E3574L,
+ 1E3575L,
+ 1E3576L,
+ 1E3577L,
+ 1E3578L,
+ 1E3579L,
+ 1E3580L,
+ 1E3581L,
+ 1E3582L,
+ 1E3583L,
+ 1E3584L,
+ 1E3585L,
+ 1E3586L,
+ 1E3587L,
+ 1E3588L,
+ 1E3589L,
+ 1E3590L,
+ 1E3591L,
+ 1E3592L,
+ 1E3593L,
+ 1E3594L,
+ 1E3595L,
+ 1E3596L,
+ 1E3597L,
+ 1E3598L,
+ 1E3599L,
+ 1E3600L,
+ 1E3601L,
+ 1E3602L,
+ 1E3603L,
+ 1E3604L,
+ 1E3605L,
+ 1E3606L,
+ 1E3607L,
+ 1E3608L,
+ 1E3609L,
+ 1E3610L,
+ 1E3611L,
+ 1E3612L,
+ 1E3613L,
+ 1E3614L,
+ 1E3615L,
+ 1E3616L,
+ 1E3617L,
+ 1E3618L,
+ 1E3619L,
+ 1E3620L,
+ 1E3621L,
+ 1E3622L,
+ 1E3623L,
+ 1E3624L,
+ 1E3625L,
+ 1E3626L,
+ 1E3627L,
+ 1E3628L,
+ 1E3629L,
+ 1E3630L,
+ 1E3631L,
+ 1E3632L,
+ 1E3633L,
+ 1E3634L,
+ 1E3635L,
+ 1E3636L,
+ 1E3637L,
+ 1E3638L,
+ 1E3639L,
+ 1E3640L,
+ 1E3641L,
+ 1E3642L,
+ 1E3643L,
+ 1E3644L,
+ 1E3645L,
+ 1E3646L,
+ 1E3647L,
+ 1E3648L,
+ 1E3649L,
+ 1E3650L,
+ 1E3651L,
+ 1E3652L,
+ 1E3653L,
+ 1E3654L,
+ 1E3655L,
+ 1E3656L,
+ 1E3657L,
+ 1E3658L,
+ 1E3659L,
+ 1E3660L,
+ 1E3661L,
+ 1E3662L,
+ 1E3663L,
+ 1E3664L,
+ 1E3665L,
+ 1E3666L,
+ 1E3667L,
+ 1E3668L,
+ 1E3669L,
+ 1E3670L,
+ 1E3671L,
+ 1E3672L,
+ 1E3673L,
+ 1E3674L,
+ 1E3675L,
+ 1E3676L,
+ 1E3677L,
+ 1E3678L,
+ 1E3679L,
+ 1E3680L,
+ 1E3681L,
+ 1E3682L,
+ 1E3683L,
+ 1E3684L,
+ 1E3685L,
+ 1E3686L,
+ 1E3687L,
+ 1E3688L,
+ 1E3689L,
+ 1E3690L,
+ 1E3691L,
+ 1E3692L,
+ 1E3693L,
+ 1E3694L,
+ 1E3695L,
+ 1E3696L,
+ 1E3697L,
+ 1E3698L,
+ 1E3699L,
+ 1E3700L,
+ 1E3701L,
+ 1E3702L,
+ 1E3703L,
+ 1E3704L,
+ 1E3705L,
+ 1E3706L,
+ 1E3707L,
+ 1E3708L,
+ 1E3709L,
+ 1E3710L,
+ 1E3711L,
+ 1E3712L,
+ 1E3713L,
+ 1E3714L,
+ 1E3715L,
+ 1E3716L,
+ 1E3717L,
+ 1E3718L,
+ 1E3719L,
+ 1E3720L,
+ 1E3721L,
+ 1E3722L,
+ 1E3723L,
+ 1E3724L,
+ 1E3725L,
+ 1E3726L,
+ 1E3727L,
+ 1E3728L,
+ 1E3729L,
+ 1E3730L,
+ 1E3731L,
+ 1E3732L,
+ 1E3733L,
+ 1E3734L,
+ 1E3735L,
+ 1E3736L,
+ 1E3737L,
+ 1E3738L,
+ 1E3739L,
+ 1E3740L,
+ 1E3741L,
+ 1E3742L,
+ 1E3743L,
+ 1E3744L,
+ 1E3745L,
+ 1E3746L,
+ 1E3747L,
+ 1E3748L,
+ 1E3749L,
+ 1E3750L,
+ 1E3751L,
+ 1E3752L,
+ 1E3753L,
+ 1E3754L,
+ 1E3755L,
+ 1E3756L,
+ 1E3757L,
+ 1E3758L,
+ 1E3759L,
+ 1E3760L,
+ 1E3761L,
+ 1E3762L,
+ 1E3763L,
+ 1E3764L,
+ 1E3765L,
+ 1E3766L,
+ 1E3767L,
+ 1E3768L,
+ 1E3769L,
+ 1E3770L,
+ 1E3771L,
+ 1E3772L,
+ 1E3773L,
+ 1E3774L,
+ 1E3775L,
+ 1E3776L,
+ 1E3777L,
+ 1E3778L,
+ 1E3779L,
+ 1E3780L,
+ 1E3781L,
+ 1E3782L,
+ 1E3783L,
+ 1E3784L,
+ 1E3785L,
+ 1E3786L,
+ 1E3787L,
+ 1E3788L,
+ 1E3789L,
+ 1E3790L,
+ 1E3791L,
+ 1E3792L,
+ 1E3793L,
+ 1E3794L,
+ 1E3795L,
+ 1E3796L,
+ 1E3797L,
+ 1E3798L,
+ 1E3799L,
+ 1E3800L,
+ 1E3801L,
+ 1E3802L,
+ 1E3803L,
+ 1E3804L,
+ 1E3805L,
+ 1E3806L,
+ 1E3807L,
+ 1E3808L,
+ 1E3809L,
+ 1E3810L,
+ 1E3811L,
+ 1E3812L,
+ 1E3813L,
+ 1E3814L,
+ 1E3815L,
+ 1E3816L,
+ 1E3817L,
+ 1E3818L,
+ 1E3819L,
+ 1E3820L,
+ 1E3821L,
+ 1E3822L,
+ 1E3823L,
+ 1E3824L,
+ 1E3825L,
+ 1E3826L,
+ 1E3827L,
+ 1E3828L,
+ 1E3829L,
+ 1E3830L,
+ 1E3831L,
+ 1E3832L,
+ 1E3833L,
+ 1E3834L,
+ 1E3835L,
+ 1E3836L,
+ 1E3837L,
+ 1E3838L,
+ 1E3839L,
+ 1E3840L,
+ 1E3841L,
+ 1E3842L,
+ 1E3843L,
+ 1E3844L,
+ 1E3845L,
+ 1E3846L,
+ 1E3847L,
+ 1E3848L,
+ 1E3849L,
+ 1E3850L,
+ 1E3851L,
+ 1E3852L,
+ 1E3853L,
+ 1E3854L,
+ 1E3855L,
+ 1E3856L,
+ 1E3857L,
+ 1E3858L,
+ 1E3859L,
+ 1E3860L,
+ 1E3861L,
+ 1E3862L,
+ 1E3863L,
+ 1E3864L,
+ 1E3865L,
+ 1E3866L,
+ 1E3867L,
+ 1E3868L,
+ 1E3869L,
+ 1E3870L,
+ 1E3871L,
+ 1E3872L,
+ 1E3873L,
+ 1E3874L,
+ 1E3875L,
+ 1E3876L,
+ 1E3877L,
+ 1E3878L,
+ 1E3879L,
+ 1E3880L,
+ 1E3881L,
+ 1E3882L,
+ 1E3883L,
+ 1E3884L,
+ 1E3885L,
+ 1E3886L,
+ 1E3887L,
+ 1E3888L,
+ 1E3889L,
+ 1E3890L,
+ 1E3891L,
+ 1E3892L,
+ 1E3893L,
+ 1E3894L,
+ 1E3895L,
+ 1E3896L,
+ 1E3897L,
+ 1E3898L,
+ 1E3899L,
+ 1E3900L,
+ 1E3901L,
+ 1E3902L,
+ 1E3903L,
+ 1E3904L,
+ 1E3905L,
+ 1E3906L,
+ 1E3907L,
+ 1E3908L,
+ 1E3909L,
+ 1E3910L,
+ 1E3911L,
+ 1E3912L,
+ 1E3913L,
+ 1E3914L,
+ 1E3915L,
+ 1E3916L,
+ 1E3917L,
+ 1E3918L,
+ 1E3919L,
+ 1E3920L,
+ 1E3921L,
+ 1E3922L,
+ 1E3923L,
+ 1E3924L,
+ 1E3925L,
+ 1E3926L,
+ 1E3927L,
+ 1E3928L,
+ 1E3929L,
+ 1E3930L,
+ 1E3931L,
+ 1E3932L,
+ 1E3933L,
+ 1E3934L,
+ 1E3935L,
+ 1E3936L,
+ 1E3937L,
+ 1E3938L,
+ 1E3939L,
+ 1E3940L,
+ 1E3941L,
+ 1E3942L,
+ 1E3943L,
+ 1E3944L,
+ 1E3945L,
+ 1E3946L,
+ 1E3947L,
+ 1E3948L,
+ 1E3949L,
+ 1E3950L,
+ 1E3951L,
+ 1E3952L,
+ 1E3953L,
+ 1E3954L,
+ 1E3955L,
+ 1E3956L,
+ 1E3957L,
+ 1E3958L,
+ 1E3959L,
+ 1E3960L,
+ 1E3961L,
+ 1E3962L,
+ 1E3963L,
+ 1E3964L,
+ 1E3965L,
+ 1E3966L,
+ 1E3967L,
+ 1E3968L,
+ 1E3969L,
+ 1E3970L,
+ 1E3971L,
+ 1E3972L,
+ 1E3973L,
+ 1E3974L,
+ 1E3975L,
+ 1E3976L,
+ 1E3977L,
+ 1E3978L,
+ 1E3979L,
+ 1E3980L,
+ 1E3981L,
+ 1E3982L,
+ 1E3983L,
+ 1E3984L,
+ 1E3985L,
+ 1E3986L,
+ 1E3987L,
+ 1E3988L,
+ 1E3989L,
+ 1E3990L,
+ 1E3991L,
+ 1E3992L,
+ 1E3993L,
+ 1E3994L,
+ 1E3995L,
+ 1E3996L,
+ 1E3997L,
+ 1E3998L,
+ 1E3999L,
+ 1E4000L,
+ 1E4001L,
+ 1E4002L,
+ 1E4003L,
+ 1E4004L,
+ 1E4005L,
+ 1E4006L,
+ 1E4007L,
+ 1E4008L,
+ 1E4009L,
+ 1E4010L,
+ 1E4011L,
+ 1E4012L,
+ 1E4013L,
+ 1E4014L,
+ 1E4015L,
+ 1E4016L,
+ 1E4017L,
+ 1E4018L,
+ 1E4019L,
+ 1E4020L,
+ 1E4021L,
+ 1E4022L,
+ 1E4023L,
+ 1E4024L,
+ 1E4025L,
+ 1E4026L,
+ 1E4027L,
+ 1E4028L,
+ 1E4029L,
+ 1E4030L,
+ 1E4031L,
+ 1E4032L,
+ 1E4033L,
+ 1E4034L,
+ 1E4035L,
+ 1E4036L,
+ 1E4037L,
+ 1E4038L,
+ 1E4039L,
+ 1E4040L,
+ 1E4041L,
+ 1E4042L,
+ 1E4043L,
+ 1E4044L,
+ 1E4045L,
+ 1E4046L,
+ 1E4047L,
+ 1E4048L,
+ 1E4049L,
+ 1E4050L,
+ 1E4051L,
+ 1E4052L,
+ 1E4053L,
+ 1E4054L,
+ 1E4055L,
+ 1E4056L,
+ 1E4057L,
+ 1E4058L,
+ 1E4059L,
+ 1E4060L,
+ 1E4061L,
+ 1E4062L,
+ 1E4063L,
+ 1E4064L,
+ 1E4065L,
+ 1E4066L,
+ 1E4067L,
+ 1E4068L,
+ 1E4069L,
+ 1E4070L,
+ 1E4071L,
+ 1E4072L,
+ 1E4073L,
+ 1E4074L,
+ 1E4075L,
+ 1E4076L,
+ 1E4077L,
+ 1E4078L,
+ 1E4079L,
+ 1E4080L,
+ 1E4081L,
+ 1E4082L,
+ 1E4083L,
+ 1E4084L,
+ 1E4085L,
+ 1E4086L,
+ 1E4087L,
+ 1E4088L,
+ 1E4089L,
+ 1E4090L,
+ 1E4091L,
+ 1E4092L,
+ 1E4093L,
+ 1E4094L,
+ 1E4095L,
+ 1E4096L,
+ 1E4097L,
+ 1E4098L,
+ 1E4099L,
+ 1E4100L,
+ 1E4101L,
+ 1E4102L,
+ 1E4103L,
+ 1E4104L,
+ 1E4105L,
+ 1E4106L,
+ 1E4107L,
+ 1E4108L,
+ 1E4109L,
+ 1E4110L,
+ 1E4111L,
+ 1E4112L,
+ 1E4113L,
+ 1E4114L,
+ 1E4115L,
+ 1E4116L,
+ 1E4117L,
+ 1E4118L,
+ 1E4119L,
+ 1E4120L,
+ 1E4121L,
+ 1E4122L,
+ 1E4123L,
+ 1E4124L,
+ 1E4125L,
+ 1E4126L,
+ 1E4127L,
+ 1E4128L,
+ 1E4129L,
+ 1E4130L,
+ 1E4131L,
+ 1E4132L,
+ 1E4133L,
+ 1E4134L,
+ 1E4135L,
+ 1E4136L,
+ 1E4137L,
+ 1E4138L,
+ 1E4139L,
+ 1E4140L,
+ 1E4141L,
+ 1E4142L,
+ 1E4143L,
+ 1E4144L,
+ 1E4145L,
+ 1E4146L,
+ 1E4147L,
+ 1E4148L,
+ 1E4149L,
+ 1E4150L,
+ 1E4151L,
+ 1E4152L,
+ 1E4153L,
+ 1E4154L,
+ 1E4155L,
+ 1E4156L,
+ 1E4157L,
+ 1E4158L,
+ 1E4159L,
+ 1E4160L,
+ 1E4161L,
+ 1E4162L,
+ 1E4163L,
+ 1E4164L,
+ 1E4165L,
+ 1E4166L,
+ 1E4167L,
+ 1E4168L,
+ 1E4169L,
+ 1E4170L,
+ 1E4171L,
+ 1E4172L,
+ 1E4173L,
+ 1E4174L,
+ 1E4175L,
+ 1E4176L,
+ 1E4177L,
+ 1E4178L,
+ 1E4179L,
+ 1E4180L,
+ 1E4181L,
+ 1E4182L,
+ 1E4183L,
+ 1E4184L,
+ 1E4185L,
+ 1E4186L,
+ 1E4187L,
+ 1E4188L,
+ 1E4189L,
+ 1E4190L,
+ 1E4191L,
+ 1E4192L,
+ 1E4193L,
+ 1E4194L,
+ 1E4195L,
+ 1E4196L,
+ 1E4197L,
+ 1E4198L,
+ 1E4199L,
+ 1E4200L,
+ 1E4201L,
+ 1E4202L,
+ 1E4203L,
+ 1E4204L,
+ 1E4205L,
+ 1E4206L,
+ 1E4207L,
+ 1E4208L,
+ 1E4209L,
+ 1E4210L,
+ 1E4211L,
+ 1E4212L,
+ 1E4213L,
+ 1E4214L,
+ 1E4215L,
+ 1E4216L,
+ 1E4217L,
+ 1E4218L,
+ 1E4219L,
+ 1E4220L,
+ 1E4221L,
+ 1E4222L,
+ 1E4223L,
+ 1E4224L,
+ 1E4225L,
+ 1E4226L,
+ 1E4227L,
+ 1E4228L,
+ 1E4229L,
+ 1E4230L,
+ 1E4231L,
+ 1E4232L,
+ 1E4233L,
+ 1E4234L,
+ 1E4235L,
+ 1E4236L,
+ 1E4237L,
+ 1E4238L,
+ 1E4239L,
+ 1E4240L,
+ 1E4241L,
+ 1E4242L,
+ 1E4243L,
+ 1E4244L,
+ 1E4245L,
+ 1E4246L,
+ 1E4247L,
+ 1E4248L,
+ 1E4249L,
+ 1E4250L,
+ 1E4251L,
+ 1E4252L,
+ 1E4253L,
+ 1E4254L,
+ 1E4255L,
+ 1E4256L,
+ 1E4257L,
+ 1E4258L,
+ 1E4259L,
+ 1E4260L,
+ 1E4261L,
+ 1E4262L,
+ 1E4263L,
+ 1E4264L,
+ 1E4265L,
+ 1E4266L,
+ 1E4267L,
+ 1E4268L,
+ 1E4269L,
+ 1E4270L,
+ 1E4271L,
+ 1E4272L,
+ 1E4273L,
+ 1E4274L,
+ 1E4275L,
+ 1E4276L,
+ 1E4277L,
+ 1E4278L,
+ 1E4279L,
+ 1E4280L,
+ 1E4281L,
+ 1E4282L,
+ 1E4283L,
+ 1E4284L,
+ 1E4285L,
+ 1E4286L,
+ 1E4287L,
+ 1E4288L,
+ 1E4289L,
+ 1E4290L,
+ 1E4291L,
+ 1E4292L,
+ 1E4293L,
+ 1E4294L,
+ 1E4295L,
+ 1E4296L,
+ 1E4297L,
+ 1E4298L,
+ 1E4299L,
+ 1E4300L,
+ 1E4301L,
+ 1E4302L,
+ 1E4303L,
+ 1E4304L,
+ 1E4305L,
+ 1E4306L,
+ 1E4307L,
+ 1E4308L,
+ 1E4309L,
+ 1E4310L,
+ 1E4311L,
+ 1E4312L,
+ 1E4313L,
+ 1E4314L,
+ 1E4315L,
+ 1E4316L,
+ 1E4317L,
+ 1E4318L,
+ 1E4319L,
+ 1E4320L,
+ 1E4321L,
+ 1E4322L,
+ 1E4323L,
+ 1E4324L,
+ 1E4325L,
+ 1E4326L,
+ 1E4327L,
+ 1E4328L,
+ 1E4329L,
+ 1E4330L,
+ 1E4331L,
+ 1E4332L,
+ 1E4333L,
+ 1E4334L,
+ 1E4335L,
+ 1E4336L,
+ 1E4337L,
+ 1E4338L,
+ 1E4339L,
+ 1E4340L,
+ 1E4341L,
+ 1E4342L,
+ 1E4343L,
+ 1E4344L,
+ 1E4345L,
+ 1E4346L,
+ 1E4347L,
+ 1E4348L,
+ 1E4349L,
+ 1E4350L,
+ 1E4351L,
+ 1E4352L,
+ 1E4353L,
+ 1E4354L,
+ 1E4355L,
+ 1E4356L,
+ 1E4357L,
+ 1E4358L,
+ 1E4359L,
+ 1E4360L,
+ 1E4361L,
+ 1E4362L,
+ 1E4363L,
+ 1E4364L,
+ 1E4365L,
+ 1E4366L,
+ 1E4367L,
+ 1E4368L,
+ 1E4369L,
+ 1E4370L,
+ 1E4371L,
+ 1E4372L,
+ 1E4373L,
+ 1E4374L,
+ 1E4375L,
+ 1E4376L,
+ 1E4377L,
+ 1E4378L,
+ 1E4379L,
+ 1E4380L,
+ 1E4381L,
+ 1E4382L,
+ 1E4383L,
+ 1E4384L,
+ 1E4385L,
+ 1E4386L,
+ 1E4387L,
+ 1E4388L,
+ 1E4389L,
+ 1E4390L,
+ 1E4391L,
+ 1E4392L,
+ 1E4393L,
+ 1E4394L,
+ 1E4395L,
+ 1E4396L,
+ 1E4397L,
+ 1E4398L,
+ 1E4399L,
+ 1E4400L,
+ 1E4401L,
+ 1E4402L,
+ 1E4403L,
+ 1E4404L,
+ 1E4405L,
+ 1E4406L,
+ 1E4407L,
+ 1E4408L,
+ 1E4409L,
+ 1E4410L,
+ 1E4411L,
+ 1E4412L,
+ 1E4413L,
+ 1E4414L,
+ 1E4415L,
+ 1E4416L,
+ 1E4417L,
+ 1E4418L,
+ 1E4419L,
+ 1E4420L,
+ 1E4421L,
+ 1E4422L,
+ 1E4423L,
+ 1E4424L,
+ 1E4425L,
+ 1E4426L,
+ 1E4427L,
+ 1E4428L,
+ 1E4429L,
+ 1E4430L,
+ 1E4431L,
+ 1E4432L,
+ 1E4433L,
+ 1E4434L,
+ 1E4435L,
+ 1E4436L,
+ 1E4437L,
+ 1E4438L,
+ 1E4439L,
+ 1E4440L,
+ 1E4441L,
+ 1E4442L,
+ 1E4443L,
+ 1E4444L,
+ 1E4445L,
+ 1E4446L,
+ 1E4447L,
+ 1E4448L,
+ 1E4449L,
+ 1E4450L,
+ 1E4451L,
+ 1E4452L,
+ 1E4453L,
+ 1E4454L,
+ 1E4455L,
+ 1E4456L,
+ 1E4457L,
+ 1E4458L,
+ 1E4459L,
+ 1E4460L,
+ 1E4461L,
+ 1E4462L,
+ 1E4463L,
+ 1E4464L,
+ 1E4465L,
+ 1E4466L,
+ 1E4467L,
+ 1E4468L,
+ 1E4469L,
+ 1E4470L,
+ 1E4471L,
+ 1E4472L,
+ 1E4473L,
+ 1E4474L,
+ 1E4475L,
+ 1E4476L,
+ 1E4477L,
+ 1E4478L,
+ 1E4479L,
+ 1E4480L,
+ 1E4481L,
+ 1E4482L,
+ 1E4483L,
+ 1E4484L,
+ 1E4485L,
+ 1E4486L,
+ 1E4487L,
+ 1E4488L,
+ 1E4489L,
+ 1E4490L,
+ 1E4491L,
+ 1E4492L,
+ 1E4493L,
+ 1E4494L,
+ 1E4495L,
+ 1E4496L,
+ 1E4497L,
+ 1E4498L,
+ 1E4499L,
+ 1E4500L,
+ 1E4501L,
+ 1E4502L,
+ 1E4503L,
+ 1E4504L,
+ 1E4505L,
+ 1E4506L,
+ 1E4507L,
+ 1E4508L,
+ 1E4509L,
+ 1E4510L,
+ 1E4511L,
+ 1E4512L,
+ 1E4513L,
+ 1E4514L,
+ 1E4515L,
+ 1E4516L,
+ 1E4517L,
+ 1E4518L,
+ 1E4519L,
+ 1E4520L,
+ 1E4521L,
+ 1E4522L,
+ 1E4523L,
+ 1E4524L,
+ 1E4525L,
+ 1E4526L,
+ 1E4527L,
+ 1E4528L,
+ 1E4529L,
+ 1E4530L,
+ 1E4531L,
+ 1E4532L,
+ 1E4533L,
+ 1E4534L,
+ 1E4535L,
+ 1E4536L,
+ 1E4537L,
+ 1E4538L,
+ 1E4539L,
+ 1E4540L,
+ 1E4541L,
+ 1E4542L,
+ 1E4543L,
+ 1E4544L,
+ 1E4545L,
+ 1E4546L,
+ 1E4547L,
+ 1E4548L,
+ 1E4549L,
+ 1E4550L,
+ 1E4551L,
+ 1E4552L,
+ 1E4553L,
+ 1E4554L,
+ 1E4555L,
+ 1E4556L,
+ 1E4557L,
+ 1E4558L,
+ 1E4559L,
+ 1E4560L,
+ 1E4561L,
+ 1E4562L,
+ 1E4563L,
+ 1E4564L,
+ 1E4565L,
+ 1E4566L,
+ 1E4567L,
+ 1E4568L,
+ 1E4569L,
+ 1E4570L,
+ 1E4571L,
+ 1E4572L,
+ 1E4573L,
+ 1E4574L,
+ 1E4575L,
+ 1E4576L,
+ 1E4577L,
+ 1E4578L,
+ 1E4579L,
+ 1E4580L,
+ 1E4581L,
+ 1E4582L,
+ 1E4583L,
+ 1E4584L,
+ 1E4585L,
+ 1E4586L,
+ 1E4587L,
+ 1E4588L,
+ 1E4589L,
+ 1E4590L,
+ 1E4591L,
+ 1E4592L,
+ 1E4593L,
+ 1E4594L,
+ 1E4595L,
+ 1E4596L,
+ 1E4597L,
+ 1E4598L,
+ 1E4599L,
+ 1E4600L,
+ 1E4601L,
+ 1E4602L,
+ 1E4603L,
+ 1E4604L,
+ 1E4605L,
+ 1E4606L,
+ 1E4607L,
+ 1E4608L,
+ 1E4609L,
+ 1E4610L,
+ 1E4611L,
+ 1E4612L,
+ 1E4613L,
+ 1E4614L,
+ 1E4615L,
+ 1E4616L,
+ 1E4617L,
+ 1E4618L,
+ 1E4619L,
+ 1E4620L,
+ 1E4621L,
+ 1E4622L,
+ 1E4623L,
+ 1E4624L,
+ 1E4625L,
+ 1E4626L,
+ 1E4627L,
+ 1E4628L,
+ 1E4629L,
+ 1E4630L,
+ 1E4631L,
+ 1E4632L,
+ 1E4633L,
+ 1E4634L,
+ 1E4635L,
+ 1E4636L,
+ 1E4637L,
+ 1E4638L,
+ 1E4639L,
+ 1E4640L,
+ 1E4641L,
+ 1E4642L,
+ 1E4643L,
+ 1E4644L,
+ 1E4645L,
+ 1E4646L,
+ 1E4647L,
+ 1E4648L,
+ 1E4649L,
+ 1E4650L,
+ 1E4651L,
+ 1E4652L,
+ 1E4653L,
+ 1E4654L,
+ 1E4655L,
+ 1E4656L,
+ 1E4657L,
+ 1E4658L,
+ 1E4659L,
+ 1E4660L,
+ 1E4661L,
+ 1E4662L,
+ 1E4663L,
+ 1E4664L,
+ 1E4665L,
+ 1E4666L,
+ 1E4667L,
+ 1E4668L,
+ 1E4669L,
+ 1E4670L,
+ 1E4671L,
+ 1E4672L,
+ 1E4673L,
+ 1E4674L,
+ 1E4675L,
+ 1E4676L,
+ 1E4677L,
+ 1E4678L,
+ 1E4679L,
+ 1E4680L,
+ 1E4681L,
+ 1E4682L,
+ 1E4683L,
+ 1E4684L,
+ 1E4685L,
+ 1E4686L,
+ 1E4687L,
+ 1E4688L,
+ 1E4689L,
+ 1E4690L,
+ 1E4691L,
+ 1E4692L,
+ 1E4693L,
+ 1E4694L,
+ 1E4695L,
+ 1E4696L,
+ 1E4697L,
+ 1E4698L,
+ 1E4699L,
+ 1E4700L,
+ 1E4701L,
+ 1E4702L,
+ 1E4703L,
+ 1E4704L,
+ 1E4705L,
+ 1E4706L,
+ 1E4707L,
+ 1E4708L,
+ 1E4709L,
+ 1E4710L,
+ 1E4711L,
+ 1E4712L,
+ 1E4713L,
+ 1E4714L,
+ 1E4715L,
+ 1E4716L,
+ 1E4717L,
+ 1E4718L,
+ 1E4719L,
+ 1E4720L,
+ 1E4721L,
+ 1E4722L,
+ 1E4723L,
+ 1E4724L,
+ 1E4725L,
+ 1E4726L,
+ 1E4727L,
+ 1E4728L,
+ 1E4729L,
+ 1E4730L,
+ 1E4731L,
+ 1E4732L,
+ 1E4733L,
+ 1E4734L,
+ 1E4735L,
+ 1E4736L,
+ 1E4737L,
+ 1E4738L,
+ 1E4739L,
+ 1E4740L,
+ 1E4741L,
+ 1E4742L,
+ 1E4743L,
+ 1E4744L,
+ 1E4745L,
+ 1E4746L,
+ 1E4747L,
+ 1E4748L,
+ 1E4749L,
+ 1E4750L,
+ 1E4751L,
+ 1E4752L,
+ 1E4753L,
+ 1E4754L,
+ 1E4755L,
+ 1E4756L,
+ 1E4757L,
+ 1E4758L,
+ 1E4759L,
+ 1E4760L,
+ 1E4761L,
+ 1E4762L,
+ 1E4763L,
+ 1E4764L,
+ 1E4765L,
+ 1E4766L,
+ 1E4767L,
+ 1E4768L,
+ 1E4769L,
+ 1E4770L,
+ 1E4771L,
+ 1E4772L,
+ 1E4773L,
+ 1E4774L,
+ 1E4775L,
+ 1E4776L,
+ 1E4777L,
+ 1E4778L,
+ 1E4779L,
+ 1E4780L,
+ 1E4781L,
+ 1E4782L,
+ 1E4783L,
+ 1E4784L,
+ 1E4785L,
+ 1E4786L,
+ 1E4787L,
+ 1E4788L,
+ 1E4789L,
+ 1E4790L,
+ 1E4791L,
+ 1E4792L,
+ 1E4793L,
+ 1E4794L,
+ 1E4795L,
+ 1E4796L,
+ 1E4797L,
+ 1E4798L,
+ 1E4799L,
+ 1E4800L,
+ 1E4801L,
+ 1E4802L,
+ 1E4803L,
+ 1E4804L,
+ 1E4805L,
+ 1E4806L,
+ 1E4807L,
+ 1E4808L,
+ 1E4809L,
+ 1E4810L,
+ 1E4811L,
+ 1E4812L,
+ 1E4813L,
+ 1E4814L,
+ 1E4815L,
+ 1E4816L,
+ 1E4817L,
+ 1E4818L,
+ 1E4819L,
+ 1E4820L,
+ 1E4821L,
+ 1E4822L,
+ 1E4823L,
+ 1E4824L,
+ 1E4825L,
+ 1E4826L,
+ 1E4827L,
+ 1E4828L,
+ 1E4829L,
+ 1E4830L,
+ 1E4831L,
+ 1E4832L,
+ 1E4833L,
+ 1E4834L,
+ 1E4835L,
+ 1E4836L,
+ 1E4837L,
+ 1E4838L,
+ 1E4839L,
+ 1E4840L,
+ 1E4841L,
+ 1E4842L,
+ 1E4843L,
+ 1E4844L,
+ 1E4845L,
+ 1E4846L,
+ 1E4847L,
+ 1E4848L,
+ 1E4849L,
+ 1E4850L,
+ 1E4851L,
+ 1E4852L,
+ 1E4853L,
+ 1E4854L,
+ 1E4855L,
+ 1E4856L,
+ 1E4857L,
+ 1E4858L,
+ 1E4859L,
+ 1E4860L,
+ 1E4861L,
+ 1E4862L,
+ 1E4863L,
+ 1E4864L,
+ 1E4865L,
+ 1E4866L,
+ 1E4867L,
+ 1E4868L,
+ 1E4869L,
+ 1E4870L,
+ 1E4871L,
+ 1E4872L,
+ 1E4873L,
+ 1E4874L,
+ 1E4875L,
+ 1E4876L,
+ 1E4877L,
+ 1E4878L,
+ 1E4879L,
+ 1E4880L,
+ 1E4881L,
+ 1E4882L,
+ 1E4883L,
+ 1E4884L,
+ 1E4885L,
+ 1E4886L,
+ 1E4887L,
+ 1E4888L,
+ 1E4889L,
+ 1E4890L,
+ 1E4891L,
+ 1E4892L,
+ 1E4893L,
+ 1E4894L,
+ 1E4895L,
+ 1E4896L,
+ 1E4897L,
+ 1E4898L,
+ 1E4899L,
+ 1E4900L,
+ 1E4901L,
+ 1E4902L,
+ 1E4903L,
+ 1E4904L,
+ 1E4905L,
+ 1E4906L,
+ 1E4907L,
+ 1E4908L,
+ 1E4909L,
+ 1E4910L,
+ 1E4911L,
+ 1E4912L,
+ 1E4913L,
+ 1E4914L,
+ 1E4915L,
+ 1E4916L,
+ 1E4917L,
+ 1E4918L,
+ 1E4919L,
+ 1E4920L,
+ 1E4921L,
+ 1E4922L,
+ 1E4923L,
+ 1E4924L,
+ 1E4925L,
+ 1E4926L,
+ 1E4927L,
+ 1E4928L,
+ 1E4929L,
+ 1E4930L,
+ 1E4931L,
+ 1E4932L,
+};
+
+Sftab_t _Sftable =
+{
+ { 1E1L, 1E2L, 1E4L, 1E8L, 1E16L, 1E32L },
+ { 1E-1L, 1E-2L, 1E-4L, 1E-8L, 1E-16L, 1E-32L },
+ { '0','0', '0','1', '0','2', '0','3', '0','4',
+ '0','5', '0','6', '0','7', '0','8', '0','9',
+ '1','0', '1','1', '1','2', '1','3', '1','4',
+ '1','5', '1','6', '1','7', '1','8', '1','9',
+ '2','0', '2','1', '2','2', '2','3', '2','4',
+ '2','5', '2','6', '2','7', '2','8', '2','9',
+ '3','0', '3','1', '3','2', '3','3', '3','4',
+ '3','5', '3','6', '3','7', '3','8', '3','9',
+ '4','0', '4','1', '4','2', '4','3', '4','4',
+ '4','5', '4','6', '4','7', '4','8', '4','9',
+ '5','0', '5','1', '5','2', '5','3', '5','4',
+ '5','5', '5','6', '5','7', '5','8', '5','9',
+ '6','0', '6','1', '6','2', '6','3', '6','4',
+ '6','5', '6','6', '6','7', '6','8', '6','9',
+ '7','0', '7','1', '7','2', '7','3', '7','4',
+ '7','5', '7','6', '7','7', '7','8', '7','9',
+ '8','0', '8','1', '8','2', '8','3', '8','4',
+ '8','5', '8','6', '8','7', '8','8', '8','9',
+ '9','0', '9','1', '9','2', '9','3', '9','4',
+ '9','5', '9','6', '9','7', '9','8', '9','9',
+ },
+ "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@_",
+ sfcvinit, 0,
+ sffmtpos,
+ sffmtint,
+ (float*)&sf_flt_pow10[0],
+ (double*)&sf_dbl_pow10[0],
+ (_ast_fltmax_t*)&sf_ldbl_pow10[0],
+};
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/sfio b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/sfio
new file mode 100644
index 0000000000..75b71e2e22
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/sfio
@@ -0,0 +1,14 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/sfio by iffe version 2007-04-04 : : */
+#ifndef _def_sfio_ast
+#define _def_sfio_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_float 1 /* #include <float.h> ok */
+#define _hdr_floatingpoint 1 /* #include <floatingpoint.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _hdr_values 1 /* #include <values.h> ok */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _key_signed 1 /* signed is a reserved keyword */
+#define _lib_cvt 1 /* native floating point conversions ok */
+#define _xopen_stdio 1 /* Stdio fseek/fflush are X/Open-compliant */
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/sig b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/sig
new file mode 100644
index 0000000000..32bdf7dd50
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/sig
@@ -0,0 +1,131 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/sig.sh by iffe version 2007-04-04 : : */
+#ifndef _def_sig_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_sig_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define sig_info _sig_info_
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide kill killpg
+#else
+#define kill ______kill
+#define killpg ______killpg
+#endif
+#include <signal.h>
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide kill killpg
+#else
+#undef kill
+#undef killpg
+#endif
+#ifndef sigmask
+#define sigmask(s) (1<<((s)-1))
+#endif
+typedef void (*Sig_handler_t) __PROTO__((int));
+
+
+#define Handler_t Sig_handler_t
+
+#define SIG_REG_PENDING (-1)
+#define SIG_REG_POP 0
+#define SIG_REG_EXEC 00001
+#define SIG_REG_PROC 00002
+#define SIG_REG_TERM 00004
+#define SIG_REG_ALL 00777
+#define SIG_REG_SET 01000
+
+typedef struct
+{
+ char** name;
+ char** text;
+ int sigmax;
+} Sig_info_t;
+
+extern __MANGLE__ int kill __PROTO__((pid_t, int));
+extern __MANGLE__ int killpg __PROTO__((pid_t, int));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Sig_info_t sig_info;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int sigcritical __PROTO__((int));
+extern __MANGLE__ int sigunblock __PROTO__((int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/signal b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/signal
new file mode 100644
index 0000000000..f39542f08c
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/signal
@@ -0,0 +1,175 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/signal.c by iffe version 2007-04-04 : : */
+#ifndef _def_signal_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_signal_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define SIG_MAX 48
+
+static const char* const sig_name[] =
+{
+ "0",
+ "HUP",
+ "INT",
+ "QUIT",
+ "ILL",
+ "TRAP",
+ "IOT",
+ "EMT",
+ "FPE",
+ "KILL",
+ "BUS",
+ "SEGV",
+ "SYS",
+ "PIPE",
+ "ALRM",
+ "TERM",
+ "USR1",
+ "USR2",
+ "CHLD",
+ "PWR",
+ "WINCH",
+ "URG",
+ "IO",
+ "STOP",
+ "TSTP",
+ "CONT",
+ "TTIN",
+ "TTOU",
+ "VTALRM",
+ "PROF",
+ "XCPU",
+ "XFSZ",
+ "WAITING",
+ "LWP",
+ "FREEZE",
+ "THAW",
+ "36",
+ "LOST",
+ "38",
+ "39",
+ "40",
+ "RTMIN",
+ "RT1",
+ "RT2",
+ "RT3",
+ "RT4",
+ "RT5",
+ "RT6",
+ "RTMAX",
+ 0
+};
+
+static const char* const sig_text[] =
+{
+ "Signal 0",
+ "Hangup",
+ "Interrupt",
+ "Quit",
+ "Illegal instruction",
+ "Trace trap",
+ "IOT trap",
+ "EMT trap",
+ "Floating exception",
+ "Killed",
+ "Bus error",
+ "Memory fault",
+ "Bad system call",
+ "Broken pipe",
+ "Alarm call",
+ "Terminated",
+ "User signal 1",
+ "User signal 2",
+ "Child status change",
+ "Power fail",
+ "Window change",
+ "Urgent IO",
+ "IO possible",
+ "Stopped (signal)",
+ "Stopped",
+ "Stopped process continued",
+ "Stopped (tty input)",
+ "Stopped (tty output)",
+ "Virtual timer alarm",
+ "Profile timer alarm",
+ "CPU time limit",
+ "File size limit",
+ "All threads blocked",
+ "Thread event",
+ "CPR freeze",
+ "CPR thaw",
+ "Signal 36",
+ "Resources lost",
+ "Signal 38",
+ "Signal 39",
+ "Signal 40",
+ "Realtime priority 0 (lo)",
+ "Realtime priority 1",
+ "Realtime priority 2",
+ "Realtime priority 3",
+ "Realtime priority 4",
+ "Realtime priority 5",
+ "Realtime priority 6",
+ "Realtime priority 7 (hi)",
+ 0
+};
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/standards b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/standards
new file mode 100644
index 0000000000..186cf1c635
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/standards
@@ -0,0 +1,28 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/standards by iffe version 2007-04-04 : : */
+#ifndef _def_standards_ast
+#define _def_standards_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* _ALL_SOURCE & _ISOC99_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works */
+#ifndef _ALL_SOURCE
+#define _ALL_SOURCE 1
+#endif
+#ifndef _ISOC99_SOURCE
+#define _ISOC99_SOURCE 1
+#endif
+#ifndef _POSIX_SOURCE
+#define _POSIX_SOURCE 1
+#endif
+#ifndef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 21000101L
+#endif
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 9900
+#endif
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#ifndef __EXTENSIONS__
+#define __EXTENSIONS__ 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/stdio b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/stdio
new file mode 100644
index 0000000000..6c72b2d2f4
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/stdio
@@ -0,0 +1,579 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/stdio by iffe version 2007-04-04 : : */
+
+#ifndef _SFSTDIO_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SFSTDIO_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define __FILE_typedef 1
+#define _FILE_DEFINED 1
+#define _FILE_defined 1
+#define _FILEDEFED 1
+
+#ifndef __FILE_TAG
+#define __FILE_TAG _sfio_s
+#endif
+
+#undef FILE
+#undef _FILE
+#undef fpos_t
+#undef fpos64_t
+
+typedef struct _sfio_s _sfio_FILE;
+
+#define FILE _sfio_FILE
+#define _FILE FILE
+
+#if !defined(__FILE) && !__CYGWIN__
+#undef __FILE
+#define __FILE FILE
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define BUFSIZ SF_BUFSIZE
+
+#else
+
+#ifndef BUFSIZ
+#define BUFSIZ 8192
+#endif
+
+#ifndef EOF
+#define EOF (-1)
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+#include <ast_std.h>
+
+#include <sfio_s.h>
+
+#if __cplusplus
+#define _sf_(f) (f)
+#else
+#define _sf_(f) ((struct _sfio_s*)(f))
+#endif
+
+#define _SF_EOF 0000200
+#define _SF_ERROR 0000400
+
+#endif
+
+#ifdef _NO_LARGEFILE64_SOURCE
+#undef _LARGEFILE64_SOURCE
+#endif
+
+#ifdef _LARGEFILE64_SOURCE
+#undef off_t
+#endif
+
+#define fpos_t _ast_fpos_t
+#if _typ_int64_t
+#define fpos64_t _ast_fpos_t
+#endif
+
+typedef struct _ast_fpos_s
+{
+ intmax_t _sf_offset;
+ unsigned char _sf_state[64 - sizeof(intmax_t)];
+} _ast_fpos_t;
+
+#define _base _data
+#define _ptr _next
+#define _IOFBF 0
+#define _IONBF 1
+#define _IOLBF 2
+
+#if defined(__cplusplus) && defined(__THROW) && !defined(_UWIN)
+
+#undef FILE
+#define FILE FILE
+typedef struct _sfio_s FILE;
+
+#undef strerror
+extern __MANGLE__ char* strerror(int) __THROW;
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#endif
+
+#ifndef FILENAME_MAX
+#define FILENAME_MAX 1024
+#endif
+#ifndef FOPEN_MAX
+#define FOPEN_MAX 60
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+
+#define _doprnt _ast_doprnt
+#define _doscan _ast_doscan
+#define asprintf _ast_asprintf
+#define clearerr _ast_clearerr
+#define fclose _ast_fclose
+#define fdopen _ast_fdopen
+#define fflush _ast_fflush
+#define fgetc _ast_fgetc
+#define fgetpos _ast_fgetpos
+#define fgetpos64 _ast_fgetpos64
+#define fgets _ast_fgets
+#define fopen _ast_fopen
+#define fprintf _ast_fprintf
+#define fpurge _ast_fpurge
+#define fputs _ast_fputs
+#define fread _ast_fread
+#define freopen _ast_freopen
+#define fscanf _ast_fscanf
+#define fseek _ast_fseek
+#define fseek64 _ast_fseek64
+#define fseeko _ast_fseeko
+#define fseeko64 _ast_fseeko64
+#define fsetpos _ast_fsetpos
+#define fsetpos64 _ast_fsetpos64
+#define ftell _ast_ftell
+#define ftell64 _ast_ftell64
+#define ftello _ast_ftello
+#define ftello64 _ast_ftello64
+#define fwrite _ast_fwrite
+#define gets _ast_gets
+#define getw _ast_getw
+#define pclose _ast_pclose
+#define popen _ast_popen
+#define printf _ast_printf
+#define puts _ast_puts
+#define putw _ast_putw
+#define rewind _ast_rewind
+#define scanf _ast_scanf
+#define setbuf _ast_setbuf
+#undef setbuffer
+#define setbuffer _ast_setbuffer
+#define setlinebuf _ast_setlinebuf
+#define setvbuf _ast_setvbuf
+#define snprintf _ast_snprintf
+#define sprintf _ast_sprintf
+#define sscanf _ast_sscanf
+#define tmpfile _ast_tmpfile
+#define ungetc _ast_ungetc
+#define vasprintf _ast_vasprintf
+#define vfprintf _ast_vfprintf
+#define vfscanf _ast_vfscanf
+#define vprintf _ast_vprintf
+#define vscanf _ast_vscanf
+#define vsnprintf _ast_vsnprintf
+#define vsprintf _ast_vsprintf
+#define vsscanf _ast_vsscanf
+#define fcloseall _ast_fcloseall
+#define fmemopen _ast_fmemopen
+#define __getdelim _ast___getdelim
+#define getdelim _ast_getdelim
+#define getline _ast_getline
+#define clearerr_unlocked _ast_clearerr_unlocked
+#define feof_unlocked _ast_feof_unlocked
+#define ferror_unlocked _ast_ferror_unlocked
+#define fflush_unlocked _ast_fflush_unlocked
+#define fgetc_unlocked _ast_fgetc_unlocked
+#define fgets_unlocked _ast_fgets_unlocked
+#define fileno_unlocked _ast_fileno_unlocked
+#define fputc_unlocked _ast_fputc_unlocked
+#define fputs_unlocked _ast_fputs_unlocked
+#define fread_unlocked _ast_fread_unlocked
+#define fwrite_unlocked _ast_fwrite_unlocked
+#define getc_unlocked _ast_getc_unlocked
+#define getchar_unlocked _ast_getchar_unlocked
+#define putc_unlocked _ast_putc_unlocked
+#define putchar_unlocked _ast_putchar_unlocked
+
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef P_tmpdir
+#define P_tmpdir "/var/tmp/" /*NOCATLITERAL*/
+#endif
+#ifndef L_ctermid
+#define L_ctermid 9
+#endif
+#ifndef L_tmpnam
+#define L_tmpnam 25
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#if defined(__cplusplus) && defined(__THROW)
+extern __MANGLE__ char* ctermid(char*) __THROW;
+#else
+extern __MANGLE__ char* ctermid __PROTO__((char*));
+#endif
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+extern __MANGLE__ void perror __PROTO__((const char*));
+#ifndef _AST_STD_H
+#ifndef remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#endif
+#ifndef rename
+extern __MANGLE__ int rename __PROTO__((const char*, const char*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#ifdef _LARGEFILE64_SOURCE
+
+#undef fpos_t
+#undef off_t
+#undef fgetpos
+#undef fsetpos
+#undef fseek
+#undef fseeko
+#undef ftell
+#undef ftello
+
+#define fpos_t fpos64_t
+#if _typ_off64_t
+#define off_t off64_t
+#else
+#define off_t int64_t
+#endif
+
+#define fgetpos fgetpos64
+#define fsetpos fsetpos64
+#define fseek fseek64
+#define fseeko fseeko64
+#define ftell ftell64
+#define ftello ftello64
+
+#endif
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_DLL && _DLL_INDIRECT_DATA
+
+#define stdin ((FILE*)_ast_dll->_ast_stdin)
+#define stdout ((FILE*)_ast_dll->_ast_stdout)
+#define stderr ((FILE*)_ast_dll->_ast_stderr)
+
+#else
+
+#define stdin (&_Sfstdin)
+#define stdout (&_Sfstdout)
+#define stderr (&_Sfstderr)
+
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define feof(f) sfeof(f)
+#define ferror(f) sferror(f)
+#define fileno(f) sffileno(f)
+#define fputc(c,f) sfputc(f,c)
+#define getc(f) sfgetc(f)
+#define getchar() sfgetc(sfstdin)
+#define putc(c,f) sfputc(f,c)
+#define putchar(c) sfputc(sfstdout,c)
+
+#else
+
+#if !_UWIN
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+#endif
+
+extern __MANGLE__ FILE _Sfstdin;
+extern __MANGLE__ FILE _Sfstdout;
+extern __MANGLE__ FILE _Sfstderr;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define feof(f) (_sf_(f)->_flags&_SF_EOF)
+#define ferror(f) (_sf_(f)->_flags&_SF_ERROR)
+#define fileno(f) (_sf_(f)->_file)
+#define fputc(c,f) (_sf_(f)->_next>=_sf_(f)->_endw?_sfflsbuf(_sf_(f),(int)((unsigned char)(c))):(int)(*_sf_(f)->_next++=(unsigned char)(c)))
+#define getc(f) (_sf_(f)->_next>=_sf_(f)->_endr?_sffilbuf(_sf_(f),0):(int)(*_sf_(f)->_next++))
+#define getchar() getc(stdin)
+#define putc(c,f) fputc(c,f)
+#define putchar(c) fputc(c,stdout)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _sffilbuf __PROTO__((FILE*, int));
+extern __MANGLE__ int _sfflsbuf __PROTO__((FILE*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/sys b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/sys
new file mode 100644
index 0000000000..9e024f86e7
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/sys
@@ -0,0 +1,151 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/sys by iffe version 2007-04-04 : : */
+
+#ifndef _AST_SYS_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_SYS_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#if __mips == 2 && !defined(_NO_LARGEFILE64_SOURCE)
+#define _NO_LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_NO_LARGEFILE64_SOURCE) && _typ_off64_t && _lib_lseek64 && _lib_stat64
+#if !defined(_LARGEFILE64_SOURCE)
+#define _LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_LARGEFILE_SOURCE)
+#define _LARGEFILE_SOURCE 1
+#endif
+#else
+#undef _LARGEFILE64_SOURCE
+#undef _LARGEFILE_SOURCE
+#undef _typ_off64_t
+#undef _typ_struct_dirent64
+#undef _lib_creat64
+#undef _lib_fstat64
+#undef _lib_fstatvfs64
+#undef _lib_ftruncate64
+#undef _lib_lseek64
+#undef _lib_lstat64
+#undef _lib_mmap64
+#undef _lib_open64
+#undef _lib_readdir64
+#undef _lib_stat64
+#undef _lib_statvfs64
+#undef _lib_truncate64
+#endif
+#if defined(__STDC__) && !defined(__USE_FIXED_PROTOTYPES__)
+#define __USE_FIXED_PROTOTYPES__ 1 /* kick gcc out of the past */
+#endif
+#include <stdlib.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <locale.h>
+#include <sys/localedef.h>
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _typ_dev_t 1 /* dev_t is a type */
+#define _typ_nlink_t 1 /* nlink_t is a type */
+#define _typ_gid_t 1 /* gid_t is a type */
+#define _typ_mode_t 1 /* mode_t is a type */
+#define _typ_uid_t 1 /* uid_t is a type */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _typ_wchar_t 1 /* wchar_t is a type */
+#define _typ_pid_t 1 /* pid_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _typ_wint_t 1 /* wint_t is a type */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _typ_socklen_t 1 /* socklen_t is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_ino_t 1 /* ino_t is a type */
+#define _typ_off_t 1 /* off_t is a type */
+#define _typ_ptrdiff_t 1 /* ptrdiff_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#define _typ_div_t 1 /* div_t is a type */
+#define _typ_ldiv_t 1 /* ldiv_t is a type */
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+extern __MANGLE__ int eaccess __PROTO__((const char*, int));
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+extern __MANGLE__ __V_* pvalloc __PROTO__((size_t));
+extern __MANGLE__ pid_t spawnveg __PROTO__((const char*, char* const[], char* const[], pid_t));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#if !defined(va_start)
+#if defined(__STDARG__)
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/time b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/time
new file mode 100644
index 0000000000..fd36809299
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/time
@@ -0,0 +1,83 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/time by iffe version 2007-04-04 : : */
+
+#ifndef _def_time_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_time_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_nanosleep 1 /* nanosleep() in default lib(s) */
+#define _lib_usleep 1 /* usleep() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#include <sys/time.h>
+
+#include <sys/times.h>
+
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC CLK_TCK
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/tmlib b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/tmlib
new file mode 100644
index 0000000000..d6a8ab2888
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/tmlib
@@ -0,0 +1,68 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/tmlib by iffe version 2007-04-04 : : */
+
+#ifndef _def_tmlib_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_tmlib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define tmlocaltime(p) localtime(p)
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/tmx b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/tmx
new file mode 100644
index 0000000000..567ee89369
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/tmx
@@ -0,0 +1,128 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/tmx by iffe version 2007-04-04 : : */
+
+#ifndef _TMX_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TMX_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Time_t support
+ */
+
+#include <tm.h>
+#include <tv.h>
+
+#define TMX_MAXDATE "2554-07-21+23:34:33.709551614 UTC"
+#define TMX_MAXYEAR 2554
+#define TMX_MAXSEC ((Time_t)18446744073)
+#define TMX_MAXNSEC 709551614
+#define TMX_RESOLUTION 1000000000
+
+typedef uint64_t Time_t;
+typedef uint64_t Tmxsec_t;
+typedef uint32_t Tmxnsec_t;
+
+#define tmxsec(t) ((Tmxsec_t)((t)/1000000000))
+#define tmxnsec(t) ((Tmxnsec_t)((t)%1000000000))
+#define tmxsns(s,n) (((((Time_t)(s))*1000000000))+((Time_t)(n)))
+
+#define TMX_NOTIME ((Time_t)(-1))
+#define TMX_NOW tmxgettime()
+#define TMX_MAXTIME tmxsns(TMX_MAXSEC,TMX_MAXNSEC)
+
+#define tmx2tv(t,v) ((v)->tv_nsec=tmxnsec(t),(v)->tv_sec=tmxsec(t))
+#define tv2tmx(v) tmxsns((v)->tv_sec,(v)->tv_nsec)
+
+#define tmxclock(p) tmxsns(((p)?*(p):time(NiL)),0)
+
+#define tmxgetatime(s) tmxsns((s)->st_atime,ST_ATIME_NSEC_GET(s))
+#define tmxgetctime(s) tmxsns((s)->st_ctime,ST_CTIME_NSEC_GET(s))
+#define tmxgetmtime(s) tmxsns((s)->st_mtime,ST_MTIME_NSEC_GET(s))
+
+#define tmxsetatime(s,t) ((s)->st_atime=tmxsec(t),ST_ATIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetctime(s,t) ((s)->st_ctime=tmxsec(t),ST_CTIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetmtime(s,t) ((s)->st_mtime=tmxsec(t),ST_MTIME_NSEC_SET(s,tmxnsec(t)))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Time_t tmxdate __PROTO__((const char*, char**, Time_t));
+extern __MANGLE__ char* tmxfmt __PROTO__((char*, size_t, const char*, Time_t));
+extern __MANGLE__ Time_t tmxleap __PROTO__((Time_t));
+extern __MANGLE__ Tm_t* tmxmake __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxscan __PROTO__((const char*, char**, const char*, char**, Time_t, long));
+extern __MANGLE__ int tmxsleep __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxtime __PROTO__((Tm_t*, int));
+
+extern __MANGLE__ Time_t tmxgettime __PROTO__((void));
+extern __MANGLE__ int tmxsettime __PROTO__((Time_t));
+
+extern __MANGLE__ int tmxtouch __PROTO__((const char*, Time_t, Time_t, Time_t, int));
+
+extern __MANGLE__ char* fmttmx __PROTO__((const char*, Time_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/tty b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/tty
new file mode 100644
index 0000000000..e645095122
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/tty
@@ -0,0 +1,134 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/tty by iffe version 2007-04-04 : : */
+#ifndef _def_tty_ast
+#define _def_tty_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_termios 1 /* #include <termios.h> ok */
+#define _hdr_termio 1 /* #include <termio.h> ok */
+#define _hdr_sgtty 1 /* #include <sgtty.h> ok */
+#define _sys_termios 1 /* #include <sys/termios.h> ok */
+#define _sys_termio 1 /* #include <sys/termio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _lib_tcgetattr 1 /* tcgetattr() in default lib(s) */
+#define _lib_tcgetpgrp 1 /* tcgetpgrp() in default lib(s) */
+#define _mac__POSIX_VDISABLE 1 /* _POSIX_VDISABLE is a macro */
+
+#ifdef _hdr_termios
+# if _mac__POSIX_VDISABLE
+# undef _POSIX_VDISABLE
+# endif
+# include <termios.h>
+#else
+# if defined(_sys_termios) && defined(_lib_tcgetattr)
+# include <sys/termios.h>
+# define _hdr_termios 1
+# else
+# undef _sys_termios
+# endif /* _sys_termios */
+#endif /* _hdr_termios */
+
+#ifdef _hdr_termios
+# undef _hdr_sgtty
+# undef tcgetattr
+# undef tcsetattr
+# undef tcgetpgrp
+# undef tcsetpgrp
+# undef cfgetospeed
+# ifndef TCSANOW
+# define TCSANOW TCSETS
+# define TCSADRAIN TCSETSW
+# define TCSAFLUSH TCSETSF
+# endif /* TCSANOW */
+ /* The following corrects bugs in some implementations */
+# if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
+# define TCSAFLUSH TCSADFLUSH
+# endif /* TCSADFLUSH */
+# ifndef _lib_tcgetattr
+# undef tcgetattr
+# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
+# undef tcsetattr
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# undef cfgetospeed
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# endif /* _lib_tcgetattr */
+# undef TIOCGETC
+#else
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfgetispeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfsetispeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# define cfsetospeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# ifdef _hdr_termio
+# include <termio.h>
+# else
+# ifdef _sys_termio
+# include <sys/termio.h>
+# define _hdr_termio 1
+# endif /* _sys_termio */
+# endif /* _hdr_termio */
+# ifdef _hdr_termio
+# define termios termio
+# undef TIOCGETC
+# define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+
+# ifdef _sys_bsdtty
+# include <sys/bsdtty.h>
+# endif /* _sys_bsdtty */
+# else
+# ifdef _hdr_sgtty
+# include <sgtty.h>
+# ifndef LPENDIN
+# ifdef _sys_nttyio
+# include <sys/nttyio.h>
+# endif /* _sys_nttyio */
+# endif /* LPENDIN */
+# define termios sgttyb
+# ifdef TIOCSETN
+# undef TCSETAW
+# endif /* TIOCSETN */
+# ifdef TIOCGETP
+# define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# else
+# define tcgetattr(fd,tty) gtty(fd, tty)
+# define tcsetattr(fd,action,tty) stty(fd, tty)
+# endif /* TIOCGETP */
+# else
+# ifdef _sys_ttyio
+# include <sys/ttyio.h>
+# endif
+# endif /* _hdr_sgtty */
+# endif /* hdr_termio */
+
+# ifndef TCSANOW
+# ifdef TCSETAW
+# define TCSANOW TCSETA
+# define TCSAFLUSH TCSETAF
+# else
+# ifdef TIOCSETN
+# define TCSANOW TIOCSETN
+# define TCSADRAIN TIOCSETN
+# define TCSAFLUSH TIOCSETP
+# endif /* TIOCSETN */
+# endif /* TCSETAW */
+# endif /* TCSANOW */
+#endif /* _hdr_termios */
+
+/* set ECHOCTL if driver can echo control charaters as ^c */
+#ifdef LCTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LCTLECH
+# endif /* !ECHOCTL */
+#endif /* LCTLECH */
+#ifdef LNEW_CTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LNEW_CTLECH
+# endif /* !ECHOCTL */
+#endif /* LNEW_CTLECH */
+#ifdef LNEW_PENDIN
+# ifndef PENDIN
+# define PENDIN LNEW_PENDIN
+# endif /* !PENDIN */
+#endif /* LNEW_PENDIN */
+
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/tv b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/tv
new file mode 100644
index 0000000000..272ec802d8
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/tv
@@ -0,0 +1,111 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/tv by iffe version 2007-04-04 : : */
+
+#ifndef _TV_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TV_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Tv_t interface definitions
+ */
+
+#include <ast.h>
+
+#define TV_NSEC_IGNORE (1000000000L)
+#define TV_TOUCH_RETAIN ((Tv_t*)1)
+
+typedef struct Tv_s
+{
+ uint32_t tv_sec;
+ uint32_t tv_nsec;
+} Tv_t;
+
+#define ST_ATIME_NSEC_GET(st) ((st)->st_atim.tv_nsec)
+#define ST_CTIME_NSEC_GET(st) ((st)->st_ctim.tv_nsec)
+#define ST_MTIME_NSEC_GET(st) ((st)->st_mtim.tv_nsec)
+
+#define ST_ATIME_NSEC_SET(st,n) (ST_ATIME_NSEC_GET(st)=(n))
+#define ST_CTIME_NSEC_SET(st,n) (ST_CTIME_NSEC_GET(st)=(n))
+#define ST_MTIME_NSEC_SET(st,n) (ST_MTIME_NSEC_GET(st)=(n))
+
+#define tvgetatime(t,s) ((t)->tv_nsec=ST_ATIME_NSEC_GET(s),(t)->tv_sec=(s)->st_atime)
+#define tvgetmtime(t,s) ((t)->tv_nsec=ST_MTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_mtime)
+#define tvgetctime(t,s) ((t)->tv_nsec=ST_CTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_ctime)
+
+#define tvsetatime(t,s) (ST_ATIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_atime=(t)->tv_sec)
+#define tvsetmtime(t,s) (ST_MTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_mtime=(t)->tv_sec)
+#define tvsetctime(t,s) (ST_CTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_ctime=(t)->tv_sec)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int tvgettime __PROTO__((Tv_t*));
+extern __MANGLE__ int tvsettime __PROTO__((const Tv_t*));
+extern __MANGLE__ int tvcmp __PROTO__((const Tv_t*, const Tv_t*));
+extern __MANGLE__ int tvtouch __PROTO__((const char*, const Tv_t*, const Tv_t*, const Tv_t*, int));
+extern __MANGLE__ int tvsleep __PROTO__((const Tv_t*, Tv_t*));
+
+extern __MANGLE__ char* fmttv __PROTO__((const char*, Tv_t*));
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/tvlib b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/tvlib
new file mode 100644
index 0000000000..bb0bc14537
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/tvlib
@@ -0,0 +1,17 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/tvlib by iffe version 2007-04-04 : : */
+#ifndef _def_tvlib_ast
+#define _def_tvlib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _lib_clock_settime 1 /* clock_settime() in default lib(s) */
+#define _lib_gettimeofday 1 /* gettimeofday() in default lib(s) */
+#define _lib_settimeofday 1 /* settimeofday() in default lib(s) */
+#define _lib_stime 1 /* stime() in default lib(s) */
+#define _lib_utimes 1 /* utimes() in default lib(s) */
+#define _lib_nanosleep 1 /* nanosleep() in default lib(s) */
+#define _lib_usleep 1 /* usleep() in default lib(s) */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _lib_clock_gettime 1 /* execute{\ passed */
+#define tmgettimeofday(p) gettimeofday(p,(struct timezone*)0)
+#define tmsettimeofday(p) settimeofday(p,(struct timezone*)0)
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/types b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/types
new file mode 100644
index 0000000000..343b5954a0
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/types
@@ -0,0 +1,5 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_types_ast
+#define _def_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/uwin b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/uwin
new file mode 100644
index 0000000000..7e594f3dd6
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/uwin
@@ -0,0 +1,17 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/uwin by iffe version 2007-04-04 : : */
+#ifndef _def_uwin_ast
+#define _def_uwin_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_a64l 1 /* a64l() in default lib(s) */
+#define _lib_crypt 1 /* crypt() in default lib(s) */
+#define _lib_getpass 1 /* getpass() in default lib(s) */
+#define _lib_random 1 /* random() in default lib(s) */
+#define _lib_rcmd 1 /* rcmd() in default lib(s) */
+#define _lib_srand48 1 /* srand48() in default lib(s) */
+#define _lib_logb 1 /* logb() in default lib(s) */
+#define _lib_finite 1 /* finite() in default lib(s) */
+#define _lib_scalb 1 /* scalb() in default lib(s) */
+#define _lib__finite 1 /* _finite() in default lib(s) */
+#define _lib__scalb 1 /* _scalb() in default lib(s) */
+#define _dat__iob 1 /* _iob in default lib(s) */
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/vfork b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/vfork
new file mode 100644
index 0000000000..f1993151cc
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/vfork
@@ -0,0 +1,67 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/vfork by iffe version 2007-04-04 : : */
+
+#ifndef _def_vfork_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_vfork_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+extern __MANGLE__ pid_t vfork __PROTO__((void));
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/vmalloc b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/vmalloc
new file mode 100644
index 0000000000..95c5564ae6
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/vmalloc
@@ -0,0 +1,36 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/vmalloc by iffe version 2007-04-04 : : */
+#ifndef _def_vmalloc_ast
+#define _def_vmalloc_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_atexit 1 /* atexit() in default lib(s) */
+#define _lib_getpagesize 1 /* getpagesize() in default lib(s) */
+#define _lib_memalign 1 /* memalign() in default lib(s) */
+#define _lib_strdup 1 /* strdup() in default lib(s) */
+#define _lib_valloc 1 /* valloc() in default lib(s) */
+#define _hdr_alloca 1 /* #include <alloca.h> ok */
+#define _hdr_malloc 1 /* #include <malloc.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _mem_arena_mallinfo 1 /* arena is a member of struct mallinfo */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _mem_sbrk 1 /* brk()/sbrk() work as expected */
+#define _lib_alloca 1 /* alloca exists */
+#define _stk_down 1 /* stack grows downward */
+#include "FEATURE/mmap"
+#if _BLD_INSTRUMENT || cray || _UWIN && _BLD_ast
+#undef _map_malloc
+#define _std_malloc 1 /* defer to standard malloc */
+#endif
+#if _mmap_anon
+#define _mem_mmap_anon 1
+#endif
+#if _mmap_devzero
+#define _mem_mmap_zero 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/wait b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/wait
new file mode 100644
index 0000000000..9ed6722037
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/wait
@@ -0,0 +1,11 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/wait by iffe version 2007-04-04 : : */
+#ifndef _def_wait_ast
+#define _def_wait_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_wait 1 /* wait() in default lib(s) */
+#define _lib_wait3 1 /* wait3() in default lib(s) */
+#define _lib_wait4 1 /* wait4() in default lib(s) */
+#define _lib_waitpid 1 /* waitpid() in default lib(s) */
+#define _sys_wait 1 /* #include <sys/wait.h> ok */
+#define _ok_wif 1 /* posix wait macros ok */
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/FEATURE/wchar b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/wchar
new file mode 100644
index 0000000000..a3f8a10eff
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/FEATURE/wchar
@@ -0,0 +1,187 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/wchar by iffe version 2007-04-04 : : */
+
+#ifndef _def_wchar_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_wchar_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _lib_mbstowcs 1 /* mbstowcs() in default lib(s) */
+#define _lib_wctomb 1 /* wctomb() in default lib(s) */
+#define _lib_wcrtomb 1 /* wcrtomb() in default lib(s) */
+#define _lib_wcslen 1 /* wcslen() in default lib(s) */
+#define _lib_wcstombs 1 /* wcstombs() in default lib(s) */
+#define _lib_wcwidth 1 /* wcwidth() in default lib(s) */
+#define _lib_towlower 1 /* towlower() in default lib(s) */
+#define _lib_towupper 1 /* towupper() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_mbstate_t 1 /* mbstate_t is a type */
+#define _nxt_wchar <../include/wchar.h> /* include path for the native <wchar.h> */
+#define _nxt_wchar_str "../include/wchar.h" /* include string for the native <wchar.h> */
+#ifndef _SFSTDIO_H
+#include <ast_common.h>
+#include <stdio.h>
+#endif
+#if _hdr_wchar && defined(_nxt_wchar)
+#include <../include/wchar.h> /* the native wchar.h */
+#endif
+#if _hdr_wctype
+#include <wctype.h>
+#endif
+
+#ifndef WEOF
+#define WEOF (-1)
+#endif
+
+#undef fgetwc
+#undef fgetws
+#undef fputwc
+#undef fputws
+#undef getwc
+#undef getwchar
+#undef getws
+#undef putwc
+#undef putwchar
+#undef ungetwc
+
+#define fgetwc _ast_fgetwc
+#define fgetws _ast_fgetws
+#define fputwc _ast_fputwc
+#define fputws _ast_fputws
+#define fwide _ast_fwide
+#define fwprintf _ast_fwprintf
+#define fwscanf _ast_fwscanf
+#define getwc _ast_getwc
+#define getwchar _ast_getwchar
+#define getws _ast_getws
+#define putwc _ast_putwc
+#define putwchar _ast_putwchar
+#define swprintf _ast_swprintf
+#define swscanf _ast_swscanf
+#define ungetwc _ast_ungetwc
+#define vfwprintf _ast_vfwprintf
+#define vfwscanf _ast_vfwscanf
+#define vswprintf _ast_vswprintf
+#define vswscanf _ast_vswscanf
+#define vwprintf _ast_vwprintf
+#define vwscanf _ast_vwscanf
+#define wprintf _ast_wprintf
+#define wscanf _ast_wscanf
+
+#if !_typ_mbstate_t
+#undef _typ_mbstate_t
+#define _typ_mbstate_t 1
+typedef char mbstate_t;
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#if !_lib_mbstowcs
+extern __MANGLE__ size_t mbstowcs __PROTO__((wchar_t*, const char*, size_t));
+#endif
+#if !_lib_wctomb
+extern __MANGLE__ int wctomb __PROTO__((char*, wchar_t));
+#endif
+#if !_lib_wcrtomb
+extern __MANGLE__ size_t wcrtomb __PROTO__((char*, wchar_t, mbstate_t*));
+#endif
+#if !_lib_wcslen
+extern __MANGLE__ size_t wcslen __PROTO__((const wchar_t*));
+#endif
+#if !_lib_wcstombs
+extern __MANGLE__ size_t wcstombs __PROTO__((char*, const wchar_t*, size_t));
+#endif
+
+extern __MANGLE__ int fwprintf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ int fwscanf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ wint_t fgetwc __PROTO__((FILE*));
+extern __MANGLE__ wchar_t* fgetws __PROTO__((wchar_t*, int, FILE*));
+extern __MANGLE__ wint_t fputwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ int fputws __PROTO__((const wchar_t*, FILE*));
+extern __MANGLE__ int fwide __PROTO__((FILE*, int));
+extern __MANGLE__ wint_t getwc __PROTO__((FILE*));
+extern __MANGLE__ wint_t getwchar __PROTO__((void));
+extern __MANGLE__ wchar_t* getws __PROTO__((wchar_t*));
+extern __MANGLE__ wint_t putwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ wint_t putwchar __PROTO__((wchar_t));
+extern __MANGLE__ int swprintf __PROTO__((wchar_t*, size_t, const wchar_t*, ...));
+extern __MANGLE__ int swscanf __PROTO__((const wchar_t*, const wchar_t*, ...));
+extern __MANGLE__ wint_t ungetwc __PROTO__((wint_t, FILE*));
+extern __MANGLE__ int vfwprintf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vfwscanf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vwprintf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vwscanf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vswprintf __PROTO__((wchar_t*, size_t, const wchar_t*, va_list));
+extern __MANGLE__ int vswscanf __PROTO__((const wchar_t*, const wchar_t*, va_list));
+extern __MANGLE__ int wprintf __PROTO__((const wchar_t*, ...));
+extern __MANGLE__ int wscanf __PROTO__((const wchar_t*, ...));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/align.h b/usr/src/lib/libast/i386/src/lib/libast/align.h
new file mode 100644
index 0000000000..23ab6030ef
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/align.h
@@ -0,0 +1,33 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/align.c by iffe version 2007-04-04 : : */
+#ifndef _def_align_ast
+#define _def_align_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+typedef unsigned long ALIGN_INTEGRAL;
+
+#define ALIGN_CHUNK 8192
+#define ALIGN_INTEGRAL long
+#define ALIGN_INTEGER(x) ((ALIGN_INTEGRAL)(x))
+#define ALIGN_POINTER(x) ((char*)(x))
+#define ALIGN_ROUND(x,y) ALIGN_POINTER(ALIGN_INTEGER((x)+(y)-1)&~((y)-1))
+
+#define ALIGN_BOUND ALIGN_BOUND2
+#define ALIGN_ALIGN(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC(x) ALIGN_TRUNC2(x)
+
+#define ALIGN_BIT1 0x1
+#define ALIGN_BOUND1 ALIGN_BOUND2
+#define ALIGN_ALIGN1(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC1(x) ALIGN_TRUNC2(x)
+#define ALIGN_CLRBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffe)
+#define ALIGN_SETBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x1)
+#define ALIGN_TSTBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x1)
+
+#define ALIGN_BIT2 0x2
+#define ALIGN_BOUND2 4
+#define ALIGN_ALIGN2(x) ALIGN_TRUNC2((x)+3)
+#define ALIGN_TRUNC2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffc)
+#define ALIGN_CLRBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffd)
+#define ALIGN_SETBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x2)
+#define ALIGN_TSTBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x2)
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_botch.h b/usr/src/lib/libast/i386/src/lib/libast/ast_botch.h
new file mode 100644
index 0000000000..f622454838
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_botch.h
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/botch.c by iffe version 2007-04-04 : : */
+#ifndef _def_botch_ast
+#define _def_botch_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_ccode.h b/usr/src/lib/libast/i386/src/lib/libast/ast_ccode.h
new file mode 100644
index 0000000000..26e608f1d0
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_ccode.h
@@ -0,0 +1,29 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/ccode by iffe version 2007-04-04 : : */
+#ifndef _def_ccode_ast
+#define _def_ccode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define CC_ASCII 1 /* ISO-8859-1 */
+#define CC_EBCDIC_E 2 /* Xopen dd(1) EBCDIC */
+#define CC_EBCDIC_I 3 /* Xopen dd(1) IBM */
+#define CC_EBCDIC_O 4 /* IBM-1047 mvs OpenEdition */
+#define CC_EBCDIC_S 5 /* Siemens posix-bc */
+#define CC_EBCDIC_H 6 /* IBM-37 AS/400 */
+#define CC_EBCDIC_M 7 /* IBM mvs cobol */
+#define CC_EBCDIC_U 8 /* microfocus cobol */
+
+#define CC_MAPS 8 /* number of code maps */
+
+#define CC_EBCDIC CC_EBCDIC_E
+#define CC_EBCDIC1 CC_EBCDIC_E
+#define CC_EBCDIC2 CC_EBCDIC_I
+#define CC_EBCDIC3 CC_EBCDIC_O
+
+#define CC_NATIVE CC_ASCII /* native character code */
+#define CC_ALIEN CC_EBCDIC /* alien character code */
+
+#define CC_bel 0007 /* bel character */
+#define CC_esc 0033 /* esc character */
+#define CC_sub 0032 /* sub character */
+#define CC_vt 0013 /* vt character */
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_common.h b/usr/src/lib/libast/i386/src/lib/libast/ast_common.h
new file mode 100644
index 0000000000..f9ed8fb491
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_common.h
@@ -0,0 +1,198 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/common by iffe version 2007-04-04 : : */
+#ifndef _AST_COMMON_H
+#define _AST_COMMON_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_pthread 1 /* #include <pthread.h> ok */
+#define _hdr_stdarg 1 /* #include <stdarg.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdint 1 /* #include <stdint.h> ok */
+#define _hdr_inttypes 1 /* #include <inttypes.h> ok */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_long_double 1 /* long double is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _std_proto 1 /* standard C prototypes ok */
+#define _ptr_void 1 /* standard C void* ok */
+/* disable non-standard linux/gnu inlines */
+#ifdef __GNUC__
+# undef __OPTIMIZE_SIZE__
+# define __OPTIMIZE_SIZE__ 1
+#endif
+
+/* __STD_C indicates that the language is ANSI-C or C++ */
+#if !defined(__STD_C) && __STDC__
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && (__cplusplus || c_plusplus)
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && _std_proto
+# define __STD_C 1
+#endif
+#if !defined(__STD_C)
+# define __STD_C 0
+#endif
+
+/* extern symbols must be protected against C++ name mangling */
+#ifndef _BEGIN_EXTERNS_
+# if __cplusplus || c_plusplus
+# define _BEGIN_EXTERNS_ extern "C" {
+# define _END_EXTERNS_ }
+# else
+# define _BEGIN_EXTERNS_
+# define _END_EXTERNS_
+# endif
+#endif
+
+/* _ARG_ simplifies function prototyping among flavors of C */
+#ifndef _ARG_
+# if __STD_C
+# define _ARG_(x) x
+# else
+# define _ARG_(x) ()
+# endif
+#endif
+
+/* _NIL_ simplifies defining nil pointers to a given type */
+#ifndef _NIL_
+# define _NIL_(x) ((x)0)
+#endif
+
+/* __INLINE__ is the inline keyword */
+#if !defined(__INLINE__) && defined(__cplusplus)
+# define __INLINE__ inline
+#endif
+#if !defined(__INLINE__) && defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+#endif
+
+/* Void_t is defined so that Void_t* can address any type */
+#ifndef Void_t
+# if __STD_C
+# define Void_t void
+# else
+# define Void_t char
+# endif
+#endif
+
+/* windows variants and veneers */
+#if !defined(_WINIX) && (_UWIN || __CYGWIN__ || __EMX__)
+# define _WINIX 1
+#endif
+
+/* dynamic linked library external scope handling */
+#ifdef __DYNAMIC__
+# undef __DYNAMIC__
+# ifndef _DLL
+# define _DLL 1
+# endif
+#endif
+#if _dll_import
+# if _BLD_STATIC && !_BLD_DLL
+# undef _DLL
+# else
+# if !_UWIN && !defined(_DLL)
+# define _DLL 1
+# endif
+# endif
+# if !defined(__EXPORT__) && _BLD_DLL
+# define __EXPORT__ __declspec(dllexport)
+# endif
+# if !defined(__IMPORT__) && ( _BLD_DLL || defined(_DLL) )
+# define __IMPORT__ __declspec(dllimport)
+# endif
+# if _BLD_DLL && _UWIN
+# define __DYNAMIC__(v) (_ast_getdll()->_ast_ ## v)
+# endif
+#endif
+#if !defined(_astimport)
+# if defined(__IMPORT__) && defined(_DLL)
+# define _astimport __IMPORT__
+# else
+# define _astimport extern
+# endif
+#endif
+#if _dll_import && ( !_BLD_DLL || _WINIX && !_UWIN )
+# ifdef __STDC__
+# define __EXTERN__(T,obj) extern T obj; T* _imp__ ## obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__ ## obj = &obj
+# else
+# define __EXTERN__(T,obj) extern T obj; T* _imp__/**/obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__/**/obj = &obj
+# endif
+#else
+# define __EXTERN__(T,obj) extern T obj
+# define __DEFINE__(T,obj,val) T obj = val
+#endif
+
+#define _ast_LL 1 /* LL numeric suffix supported */
+#define _ast_int1_t char
+#define _ast_int2_t short
+#define _ast_int4_t int
+#define _ast_int8_t long long
+#define _ast_intmax_t _ast_int8_t
+#define _ast_intswap 7
+
+#define _ast_flt4_t float
+#define _ast_flt8_t double
+#define _ast_flt12_t long double
+#define _ast_fltmax_t _ast_flt12_t
+#define _typ_int8_t 1 /* int8_t is a type */
+#define _typ_uint8_t 1 /* uint8_t is a type */
+#define _typ_int16_t 1 /* int16_t is a type */
+#define _typ_uint16_t 1 /* uint16_t is a type */
+#define _typ_int32_t 1 /* int32_t is a type */
+#define _typ_uint32_t 1 /* uint32_t is a type */
+#define _typ_int64_t 1 /* int64_t is a type */
+#define _typ_uint64_t 1 /* uint64_t is a type */
+#define _typ_intmax_t 1 /* intmax_t is a type */
+#define _typ_uintmax_t 1 /* uintmax_t is a type */
+
+#ifndef va_listref
+#define va_listref(p) (p) /* pass va_list to varargs function */
+#define va_listval(p) (p) /* retrieve va_list from va_arg(ap,va_listarg) */
+#define va_listarg va_list /* va_arg() va_list type */
+#ifndef va_start
+#if __STD_C
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+#endif
+#ifndef _AST_STD_H
+# if __STD_C && _hdr_stddef
+# include <stddef.h>
+# endif
+# if _sys_types
+# include <sys/types.h>
+# endif
+# if _hdr_stdint
+# include <stdint.h>
+# else
+# if _hdr_inttypes
+# include <inttypes.h>
+# endif
+# endif
+#endif
+#if !_typ_size_t
+# define _typ_size_t 1
+ typedef int size_t;
+#endif
+#if !_typ_ssize_t
+# define _typ_ssize_t 1
+ typedef int ssize_t;
+#endif
+#ifndef _AST_STD_H
+# if !_def_map_ast
+# include <ast_map.h>
+# endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_dirent.h b/usr/src/lib/libast/i386/src/lib/libast/ast_dirent.h
new file mode 100644
index 0000000000..0cdf633a20
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_dirent.h
@@ -0,0 +1,106 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/dirent by iffe version 2007-04-04 : : */
+
+#ifndef _def_dirent_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dirent_ast 1
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _nxt_dirent <../include/dirent.h> /* include path for the native <dirent.h> */
+#define _nxt_dirent_str "../include/dirent.h" /* include string for the native <dirent.h> */
+/*
+ * <dirent.h> for [fl]stat64 and off64_t
+ */
+
+#ifndef _AST_STD_H
+
+#include <../include/dirent.h> /* the native <dirent.h> */
+
+#else
+
+#ifndef _DIR64_H
+#define _DIR64_H
+
+#include <ast_std.h>
+
+#if _typ_off64_t
+#undef off_t
+#endif
+
+#include <../include/dirent.h> /* the native <dirent.h> */
+
+#if _typ_off64_t
+#define off_t off64_t
+#endif
+
+#if _lib_readdir64 && _typ_struct_dirent64
+#ifndef dirent
+#define dirent dirent64
+#endif
+#ifndef readdir
+#define readdir readdir64
+#endif
+#endif
+
+#endif
+
+#endif
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_fcntl.h b/usr/src/lib/libast/i386/src/lib/libast/ast_fcntl.h
new file mode 100644
index 0000000000..78510ec979
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_fcntl.h
@@ -0,0 +1,114 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/fcntl.c by iffe version 2007-04-04 : : */
+#ifndef _def_fcntl_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fcntl_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <ast_fs.h>
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#define O_BINARY 0
+#define O_TEMPORARY 0
+#define O_TEXT 0
+
+#include <ast_fs.h>
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_fstat64
+#define fstat fstat64
+#endif
+#if _lib_lstat64
+#define lstat lstat64
+#endif
+#if _lib_stat64
+#define stat stat64
+#endif
+#if _lib_creat64
+#define creat creat64
+#endif
+#if _lib_mmap64
+#define mmap mmap64
+#endif
+#if _lib_open64
+#undef open
+#define open open64
+#endif
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_float.h b/usr/src/lib/libast/i386/src/lib/libast/ast_float.h
new file mode 100644
index 0000000000..9afe6e6ff8
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_float.h
@@ -0,0 +1,213 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/float by iffe version 2007-04-04 : : */
+
+#ifndef _def_float_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_float_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_float 1 /* #include <float.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _hdr_values 1 /* #include <values.h> ok */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_frexp 1 /* frexp() in default lib(s) */
+#define _lib_frexpl 1 /* frexpl() in default lib(s) */
+#define _lib_ldexp 1 /* ldexp() in default lib(s) */
+#define _lib_ldexpl 1 /* ldexpl() in default lib(s) */
+#define _lib_finite 1 /* finite() in default lib(s) */
+#define _lib_isnan 1 /* isnan() in default lib(s) */
+#define _lib_isnanl 1 /* isnanl() in default lib(s) */
+#define _lib_copysign 1 /* copysign() in default lib(s) */
+#define _lib_copysignl 1 /* copysignl() in default lib(s) */
+#include <ast_common.h>
+#include <float.h>
+#include <math.h>
+#ifndef FLT_DIG
+#define FLT_DIG 6
+#endif
+#ifndef FLT_MAX
+#define FLT_MAX 3.4028234663852885981170E+38F
+#endif
+#ifndef FLT_MAX_10_EXP
+#define FLT_MAX_10_EXP ( + 38 )
+#endif
+#ifndef FLT_MAX_EXP
+#define FLT_MAX_EXP ( + 128 )
+#endif
+#ifndef FLT_MIN
+#define FLT_MIN 1.1754943508222875079688E-38F
+#endif
+#ifndef FLT_MIN_10_EXP
+#define FLT_MIN_10_EXP ( - 37 )
+#endif
+#ifndef FLT_MIN_EXP
+#define FLT_MIN_EXP ( - 125 )
+#endif
+#ifndef DBL_DIG
+#define DBL_DIG 15
+#endif
+#ifndef DBL_MAX
+#define DBL_MAX 1.7976931348623157081452E+308
+#endif
+#ifndef DBL_MAX_10_EXP
+#define DBL_MAX_10_EXP ( + 308 )
+#endif
+#ifndef DBL_MAX_EXP
+#define DBL_MAX_EXP ( + 1024 )
+#endif
+#ifndef DBL_MIN
+#define DBL_MIN 2.2250738585072013830903E-308
+#endif
+#ifndef DBL_MIN_10_EXP
+#define DBL_MIN_10_EXP ( - 307 )
+#endif
+#ifndef DBL_MIN_EXP
+#define DBL_MIN_EXP ( - 1021 )
+#endif
+#ifndef LDBL_DIG
+#define LDBL_DIG 18
+#endif
+#ifndef LDBL_MAX
+#define LDBL_MAX 1.1897314953572317650213E+4932L
+#endif
+#ifndef LDBL_MAX_10_EXP
+#define LDBL_MAX_10_EXP ( + 4932 )
+#endif
+#ifndef LDBL_MAX_EXP
+#define LDBL_MAX_EXP ( + 16384 )
+#endif
+#ifndef LDBL_MIN
+#define LDBL_MIN 3.3621031431120935062627E-4932L
+#endif
+#ifndef LDBL_MIN_10_EXP
+#define LDBL_MIN_10_EXP ( - 4931 )
+#endif
+#ifndef LDBL_MIN_EXP
+#define LDBL_MIN_EXP ( - 16381 )
+#endif
+
+
+#define USHRT_DIG 4
+#define UINT_DIG 9
+#define ULONG_DIG 9
+#define ULLONG_DIG 19
+#define UINTMAX_DIG ULLONG_DIG
+
+#define FLT_ULONG_MAX 4294967295.0F
+#define FLT_ULLONG_MAX 18446744073709551615.0F
+#define FLT_UINTMAX_MAX FLT_ULLONG_MAX
+#define FLT_LONG_MAX 2147483647.0F
+#define FLT_LLONG_MAX 9223372036854775807.0F
+#define FLT_INTMAX_MAX FLT_LLONG_MAX
+#define FLT_LONG_MIN (-2147483648.0F)
+#define FLT_LLONG_MIN (-9223372036854775808.0F)
+#define FLT_INTMAX_MIN FLT_LLONG_MIN
+
+#define DBL_ULONG_MAX 4294967295.0
+#define DBL_ULLONG_MAX 18446744073709551615.0
+#define DBL_UINTMAX_MAX DBL_ULLONG_MAX
+#define DBL_LONG_MAX 2147483647.0
+#define DBL_LLONG_MAX 9223372036854775807.0
+#define DBL_INTMAX_MAX DBL_LLONG_MAX
+#define DBL_LONG_MIN (-2147483648.0)
+#define DBL_LLONG_MIN (-9223372036854775808.0)
+#define DBL_INTMAX_MIN DBL_LLONG_MIN
+
+#define LDBL_ULONG_MAX 4294967295.0L
+#define LDBL_ULLONG_MAX 18446744073709551615.0L
+#define LDBL_UINTMAX_MAX LDBL_ULLONG_MAX
+#define LDBL_LONG_MAX 2147483647.0L
+#define LDBL_LLONG_MAX 9223372036854775807.0L
+#define LDBL_INTMAX_MAX LDBL_LLONG_MAX
+#define LDBL_LONG_MIN (-2147483648.0L)
+#define LDBL_LLONG_MIN (-9223372036854775808.0L)
+#define LDBL_INTMAX_MIN LDBL_LLONG_MIN
+
+#define FLTMAX_UINTMAX_MAX LDBL_UINTMAX_MAX
+#define FLTMAX_INTMAX_MAX LDBL_INTMAX_MAX
+#define FLTMAX_INTMAX_MIN LDBL_INTMAX_MIN
+
+typedef union _ast_dbl_exp_u
+{
+ uint32_t e[sizeof(double)/4];
+ double f;
+} _ast_dbl_exp_t;
+
+#define _ast_dbl_exp_index 1
+#define _ast_dbl_exp_shift 20
+
+typedef union _fltmax_exp_u
+{
+ uint32_t e[sizeof(_ast_fltmax_t)/4];
+ _ast_fltmax_t f;
+} _ast_fltmax_exp_t;
+
+#define _ast_fltmax_exp_index 2
+#define _ast_fltmax_exp_shift 0
+
+#define _ast_flt_unsigned_max_t unsigned long long
+#define _ast_flt_nan_init 0xff,0xff,0xff,0x7f
+#define _ast_flt_inf_init 0x00,0x00,0x80,0x7f
+#define _ast_dbl_nan_init 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f
+#define _ast_dbl_inf_init 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x7f
+#define _ast_ldbl_nan_init 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xf0,0x7f
+#define _ast_ldbl_inf_init 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x7f,0xf0,0x7f
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_fs.h b/usr/src/lib/libast/i386/src/lib/libast/ast_fs.h
new file mode 100644
index 0000000000..34eb5498d2
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_fs.h
@@ -0,0 +1,158 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/fs by iffe version 2007-04-04 : : */
+
+#ifndef _def_fs_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fs_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _lib__fxstat 1 /* _fxstat() in default lib(s) */
+#define _lib__lxstat 1 /* _lxstat() in default lib(s) */
+#define _lib__xmknod 1 /* _xmknod() in default lib(s) */
+#define _lib__xstat 1 /* _xstat() in default lib(s) */
+#define _lib_lstat 1 /* lstat() in default lib(s) */
+#define _lib_mknod 1 /* mknod() in default lib(s) */
+#define _lib_sync 1 /* sync() in default lib(s) */
+#include <sys/stat.h>
+#define FS_default "ufs"
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef major
+#define major(x) ( major_t ) ( ( ( ( unsigned ) ( ( x ) ) ) >> 8 ) & 0x7f )
+#endif
+#ifndef minor
+#define minor(x) ( minor_t ) ( ( ( x ) ) & 0xff )
+#endif
+#ifndef makedev
+#define makedev(x,y) ( unsigned short ) ( ( ( ( x ) ) << 8 ) | ( ( ( y ) ) & 0xff ) )
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _sys_mntent 1 /* #include <sys/mntent.h> ok */
+#define _sys_mnttab 1 /* #include <sys/mnttab.h> ok */
+#define _mem_st_blocks_stat 1 /* st_blocks is a member of struct stat */
+#define _mem_st_blksize_stat 1 /* st_blksize is a member of struct stat */
+#define _mem_st_rdev_stat 1 /* st_rdev is a member of struct stat */
+#define _sys_statfs 1 /* #include <sys/statfs.h> ok */
+#define _mem_f_files_statfs 1 /* f_files is a member of struct statfs */
+#define _sys_vfs 1 /* #include <sys/vfs.h> ok */
+#define _sys_param 1 /* #include <sys/param.h> ok */
+#define _sys_mount 1 /* #include <sys/mount.h> ok */
+#define _sys_statvfs 1 /* #include <sys/statvfs.h> ok */
+#define _mem_f_basetype_statvfs 1 /* f_basetype is a member of struct statvfs */
+#define _mem_f_frsize_statvfs 1 /* f_frsize is a member of struct statvfs */
+#define _lib_getmntent 1 /* getmntent() in default lib(s) */
+#define _lib_statfs 1 /* statfs() in default lib(s) */
+#define _lib_statvfs 1 /* statvfs() in default lib(s) */
+#define _lib_statfs4 1 /* compile{\ passed */
+#if _sys_statvfs
+#include <sys/statvfs.h>
+#if !_mem_statvfs_f_basetype
+#if _ary_f_reserved7
+#define f_basetype f_reserved7
+#endif
+#endif
+#else
+#define _mem_f_basetype_statvfs 1
+#define _mem_f_frsize_statvfs 1
+struct statvfs
+{
+unsigned long f_bsize; /* fundamental file system block size */
+unsigned long f_frsize; /* fragment size */
+unsigned long f_blocks; /* total # of blocks of f_frsize on fs */
+unsigned long f_bfree; /* total # of free blocks of f_frsize */
+unsigned long f_bavail; /* # of free blocks avail to non-superuser */
+unsigned long f_files; /* total # of file nodes (inodes) */
+unsigned long f_ffree; /* total # of free file nodes */
+unsigned long f_favail; /* # of free nodes avail to non-superuser */
+unsigned long f_fsid; /* file system id (dev for now) */
+char f_basetype[16]; /* target fs type name, null-terminated */
+unsigned long f_flag; /* bit-mask of flags */
+unsigned long f_namemax; /* maximum file name length */
+char f_fstr[32]; /* filesystem-specific string */
+unsigned long f_filler[16]; /* reserved for future expansion */
+};
+extern __MANGLE__ int fstatvfs __PROTO__((int, struct statvfs*));
+extern __MANGLE__ int statvfs __PROTO__((const char*, struct statvfs*));
+#endif
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_statvfs64 && !defined(statvfs)
+#define statvfs statvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int statvfs64 __PROTO__((const char*, struct statvfs64*));
+#endif
+#endif
+#if _lib_fstatvfs64 && !defined(fstatvfs)
+#define fstatvfs fstatvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int fstatvfs64 __PROTO__((int, struct statvfs64*));
+#endif
+#endif
+
+#define _str_st_fstype 1 /* stat.st_fstype is a string */
+#define _ary_st_pad4 1 /* stat.st_pad4 is an array */
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_iconv.h b/usr/src/lib/libast/i386/src/lib/libast/ast_iconv.h
new file mode 100644
index 0000000000..b8aee7e488
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_iconv.h
@@ -0,0 +1,132 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/iconv by iffe version 2007-04-04 : : */
+
+#ifndef _def_iconv_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_iconv_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_iconv 1 /* #include <iconv.h> ok */
+#define _lib_iconv_open 1 /* iconv_open() in default lib(s) */
+#define _lib_iconv_close 1 /* iconv_close() in default lib(s) */
+#define _lib_iconv 1 /* iconv() in default lib(s) */
+#define _nxt_iconv <../include/iconv.h> /* include path for the native <iconv.h> */
+#define _nxt_iconv_str "../include/iconv.h" /* include string for the native <iconv.h> */
+#include <ast_common.h>
+#include <ccode.h>
+#include <../include/iconv.h> /* the native iconv.h */
+
+#define CC_ICONV (-1)
+#define CC_UCS (-2)
+#define CC_SCU (-3)
+#define CC_UTF (-4)
+#define CC_UME (-5)
+
+#ifndef _ICONV_LIST_PRIVATE_
+#undef iconv_t
+#define iconv_t _ast_iconv_t
+#undef iconv_f
+#define iconv_f _ast_iconv_f
+#undef iconv_list_t
+#define iconv_list_t _ast_iconv_list_t
+#undef iconv_open
+#define iconv_open _ast_iconv_open
+#undef iconv
+#define iconv _ast_iconv
+#undef iconv_close
+#define iconv_close _ast_iconv_close
+#undef iconv_list
+#define iconv_list _ast_iconv_list
+#undef iconv_move
+#define iconv_move _ast_iconv_move
+#undef iconv_name
+#define iconv_name _ast_iconv_name
+#undef iconv_write
+#define iconv_write _ast_iconv_write
+#endif
+
+typedef Ccmap_t _ast_iconv_list_t;
+typedef __V_* _ast_iconv_t;
+typedef size_t (*_ast_iconv_f) __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ _ast_iconv_t _ast_iconv_open __PROTO__((const char*, const char*));
+extern __MANGLE__ size_t _ast_iconv __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+extern __MANGLE__ int _ast_iconv_close __PROTO__((_ast_iconv_t));
+extern __MANGLE__ _ast_iconv_list_t* _ast_iconv_list __PROTO__((_ast_iconv_list_t*));
+extern __MANGLE__ int _ast_iconv_name __PROTO__((const char*, char*, size_t));
+#if _SFIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, Sfio_t*, Sfio_t*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, Sfio_t*, char**, size_t*, size_t*));
+#else
+#if _SFSTDIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, FILE*, FILE*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, FILE*, char**, size_t*, size_t*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_lib.h b/usr/src/lib/libast/i386/src/lib/libast/ast_lib.h
new file mode 100644
index 0000000000..c7bfb927c9
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_lib.h
@@ -0,0 +1,171 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/lib by iffe version 2007-04-04 : : */
+#ifndef _def_lib_ast
+#define _def_lib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _hdr_fmtmsg 1 /* #include <fmtmsg.h> ok */
+#define _hdr_fnmatch 1 /* #include <fnmatch.h> ok */
+#define _hdr_libgen 1 /* #include <libgen.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_locale 1 /* #include <locale.h> ok */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_spawn 1 /* #include <spawn.h> ok */
+#define _hdr_syslog 1 /* #include <syslog.h> ok */
+#define _hdr_utime 1 /* #include <utime.h> ok */
+#define _hdr_wctype 1 /* #include <wctype.h> ok */
+#define _hdr_wchar 1 /* <wchar.h> and isw*() really work */
+#define _dat__tzname 1 /* _tzname in default lib(s) */
+#define _dat_tzname 1 /* tzname in default lib(s) */
+#define _lib__cleanup 1 /* _cleanup() in default lib(s) */
+#define _lib_atexit 1 /* atexit() in default lib(s) */
+#define _lib_bcopy 1 /* bcopy() in default lib(s) */
+#define _lib_bzero 1 /* bzero() in default lib(s) */
+#define _lib_catclose 1 /* catclose() in default lib(s) */
+#define _lib_catgets 1 /* catgets() in default lib(s) */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_confstr 1 /* confstr() in default lib(s) */
+#define _lib_dup2 1 /* dup2() in default lib(s) */
+#define _lib_execlp 1 /* execlp() in default lib(s) */
+#define _lib_execve 1 /* execve() in default lib(s) */
+#define _lib_execvp 1 /* execvp() in default lib(s) */
+#define _lib_fchmod 1 /* fchmod() in default lib(s) */
+#define _lib_fcntl 1 /* fcntl() in default lib(s) */
+#define _lib_fmtmsg 1 /* fmtmsg() in default lib(s) */
+#define _lib_fnmatch 1 /* fnmatch() in default lib(s) */
+#define _lib_fork 1 /* fork() in default lib(s) */
+#define _lib_fsync 1 /* fsync() in default lib(s) */
+#define _lib_getdents 1 /* getdents() in default lib(s) */
+#define _lib_getdtablesize 1 /* getdtablesize() in default lib(s) */
+#define _lib_getdate 1 /* getdate() in default lib(s) */
+#define _lib_getgroups 1 /* getgroups() in default lib(s) */
+#define _lib_gethostname 1 /* gethostname() in default lib(s) */
+#define _lib_getlogin 1 /* getlogin() in default lib(s) */
+#define _lib_getpagesize 1 /* getpagesize() in default lib(s) */
+#define _lib_getrlimit 1 /* getrlimit() in default lib(s) */
+#define _lib_getopt 1 /* getopt() in default lib(s) */
+#define _lib_getsubopt 1 /* getsubopt() in default lib(s) */
+#define _lib_getopt_long 1 /* getopt_long() in default lib(s) */
+#define _lib_getopt_long_only 1 /* getopt_long_only() in default lib(s) */
+#define _lib_glob 1 /* glob() in default lib(s) */
+#define _lib_index 1 /* index() in default lib(s) */
+#define _lib_iswblank 1 /* iswblank() in default lib(s) */
+#define _lib_iswctype 1 /* iswctype() in default lib(s) */
+#define _lib_killpg 1 /* killpg() in default lib(s) */
+#define _lib_link 1 /* link() in default lib(s) */
+#define _lib_localeconv 1 /* localeconv() in default lib(s) */
+#define _lib_madvise 1 /* madvise() in default lib(s) */
+#define _lib_mbtowc 1 /* mbtowc() in default lib(s) */
+#define _lib_mbrtowc 1 /* mbrtowc() in default lib(s) */
+#define _lib_memalign 1 /* memalign() in default lib(s) */
+#define _lib_memchr 1 /* memchr() in default lib(s) */
+#define _lib_memcpy 1 /* memcpy() in default lib(s) */
+#define _lib_memmove 1 /* memmove() in default lib(s) */
+#define _lib_memset 1 /* memset() in default lib(s) */
+#define _lib_mkdir 1 /* mkdir() in default lib(s) */
+#define _lib_mkfifo 1 /* mkfifo() in default lib(s) */
+#define _lib_mktemp 1 /* mktemp() in default lib(s) */
+#define _lib_mktime 1 /* mktime() in default lib(s) */
+#define _lib_mount 1 /* mount() in default lib(s) */
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _lib_pathconf 1 /* pathconf() in default lib(s) */
+#define _lib_readlink 1 /* readlink() in default lib(s) */
+#define _lib_remove 1 /* remove() in default lib(s) */
+#define _lib_rename 1 /* rename() in default lib(s) */
+#define _lib_rewinddir 1 /* rewinddir() in default lib(s) */
+#define _lib_rindex 1 /* rindex() in default lib(s) */
+#define _lib_rmdir 1 /* rmdir() in default lib(s) */
+#define _lib_setlocale 1 /* setlocale() in default lib(s) */
+#define _lib_setpgid 1 /* setpgid() in default lib(s) */
+#define _lib_setpgrp 1 /* setpgrp() in default lib(s) */
+#define _lib_setreuid 1 /* setreuid() in default lib(s) */
+#define _lib_setsid 1 /* setsid() in default lib(s) */
+#define _lib_setuid 1 /* setuid() in default lib(s) */
+#define _lib_sigaction 1 /* sigaction() in default lib(s) */
+#define _lib_sigprocmask 1 /* sigprocmask() in default lib(s) */
+#define _lib_socketpair 1 /* socketpair() in default lib(s) */
+#define _lib_strchr 1 /* strchr() in default lib(s) */
+#define _lib_strcoll 1 /* strcoll() in default lib(s) */
+#define _lib_strdup 1 /* strdup() in default lib(s) */
+#define _lib_strerror 1 /* strerror() in default lib(s) */
+#define _lib_strcasecmp 1 /* strcasecmp() in default lib(s) */
+#define _lib_strncasecmp 1 /* strncasecmp() in default lib(s) */
+#define _lib_strrchr 1 /* strrchr() in default lib(s) */
+#define _lib_strstr 1 /* strstr() in default lib(s) */
+#define _lib_strxfrm 1 /* strxfrm() in default lib(s) */
+#define _lib_strftime 1 /* strftime() in default lib(s) */
+#define _lib_swab 1 /* swab() in default lib(s) */
+#define _lib_symlink 1 /* symlink() in default lib(s) */
+#define _lib_sysconf 1 /* sysconf() in default lib(s) */
+#define _lib_sysinfo 1 /* sysinfo() in default lib(s) */
+#define _lib_syslog 1 /* syslog() in default lib(s) */
+#define _lib_telldir 1 /* telldir() in default lib(s) */
+#define _lib_tmpnam 1 /* tmpnam() in default lib(s) */
+#define _lib_tzset 1 /* tzset() in default lib(s) */
+#define _lib_unlink 1 /* unlink() in default lib(s) */
+#define _lib_utime 1 /* utime() in default lib(s) */
+#define _lib_wctype 1 /* wctype() in default lib(s) */
+#define _lib_ftruncate 1 /* ftruncate() in default lib(s) */
+#define _lib_truncate 1 /* truncate() in default lib(s) */
+#define _lib_creat64 1 /* creat64() in default lib(s) */
+#define _lib_fstat64 1 /* fstat64() in default lib(s) */
+#define _lib_fstatvfs64 1 /* fstatvfs64() in default lib(s) */
+#define _lib_ftruncate64 1 /* ftruncate64() in default lib(s) */
+#define _lib_lseek64 1 /* lseek64() in default lib(s) */
+#define _lib_lstat64 1 /* lstat64() in default lib(s) */
+#define _lib_open64 1 /* open64() in default lib(s) */
+#define _lib_readdir64 1 /* readdir64() in default lib(s) */
+#define _lib_stat64 1 /* stat64() in default lib(s) */
+#define _lib_statvfs64 1 /* statvfs64() in default lib(s) */
+#define _lib_truncate64 1 /* truncate64() in default lib(s) */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _lib_strtod 1 /* strtod() in default lib(s) */
+#define _lib_strtold 1 /* strtold() in default lib(s) */
+#define _lib_strtol 1 /* strtol() in default lib(s) */
+#define _lib_strtoll 1 /* strtoll() in default lib(s) */
+#define _lib_strtoul 1 /* strtoul() in default lib(s) */
+#define _lib_strtoull 1 /* strtoull() in default lib(s) */
+#define _mem_d_ino_dirent 1 /* d_ino is a member of struct dirent */
+#define _mem_d_off_dirent 1 /* d_off is a member of struct dirent */
+#define _mem_d_reclen_dirent 1 /* d_reclen is a member of struct dirent */
+#define _mem_DIR 1 /* DIR is a non-opaque struct */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _sys_jioctl 1 /* #include <sys/jioctl.h> ok */
+#define _sys_localedef 1 /* #include <sys/localedef.h> ok */
+#define _sys_ptem 1 /* #include <sys/ptem.h> ok */
+#define _sys_resource 1 /* #include <sys/resource.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _sys_stream 1 /* #include <sys/stream.h> ok */
+#define _sys_systeminfo 1 /* #include <sys/systeminfo.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_off64_t 1 /* off64_t is a type */
+#define _typ_struct_dirent64 1 /* struct dirent64 is a type */
+#define _tst_errno 1 /* errno can be assigned */
+#define _lib_poll_fd_1 1 /* fd is first arg to poll() */
+#define _lib_poll 1 /* _lib_poll_fd_1||_lib_poll_fd_2 is true */
+#define _lib_select 1 /* select() has standard 5 arg interface */
+#define _pipe_rw 1 /* full duplex pipes */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _lib_vfork 1 /* vfork exists and it works */
+#define _real_vfork 1 /* vfork child shares data with parent */
+#define _lib_posix_spawn 1 /* posix_spawn exists and it works and its worth using */
+#define _stream_peek 1 /* ioctl(I_PEEK) works */
+#define _socket_peek 1 /* recv(MSG_PEEK) works */
+#define _hdr_string 1 /* #include <string.h> ok */
+#define _lib_memcmp 1 /* standard memcmp interface that works */
+#define _hdr_fcntl 1 /* #include <fcntl.h> ok */
+#define _hdr_signal 1 /* #include <signal.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_memccpy 1 /* standard memccpy interface that works */
+#define _lib_utime_now 1 /* utime works with 0 time vector */
+#define _UNIV_DEFAULT "att" /* default universe name */
+#define _std_cleanup 1 /* stuck with standard _cleanup */
+#define _std_strcoll 1 /* standard strcoll works */
+#if !_AST_no_spawnveg
+#define _use_spawnveg 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_limits.h b/usr/src/lib/libast/i386/src/lib/libast/ast_limits.h
new file mode 100644
index 0000000000..dc1593a119
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_limits.h
@@ -0,0 +1,107 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/limits.c by iffe version 2007-04-04 : : */
+#ifndef _def_limits_ast
+#define _def_limits_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+#ifndef CHAR_MAX
+#define CHAR_MAX 127
+#endif
+#ifndef CHAR_MIN
+#define CHAR_MIN -128
+#endif
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC 1000000
+#endif
+#ifndef INT_MIN
+#define INT_MIN -2147483648
+#endif
+#ifndef LLONG_MAX
+#define LLONG_MAX 9223372036854775807
+#endif
+#ifndef LLONG_MIN
+#define LLONG_MIN -9223372036854775808
+#endif
+#ifndef LONG_MAX
+#define LONG_MAX 2147483647
+#endif
+#ifndef LONG_MIN
+#define LONG_MIN -2147483648
+#endif
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 5
+#endif
+#ifndef OPEN_MAX_CEIL
+#ifndef OPEN_MAX
+#define OPEN_MAX 256
+#endif
+#define OPEN_MAX_CEIL OPEN_MAX
+#endif
+#ifndef PTHREAD_STACK_MIN
+#define PTHREAD_STACK_MIN 4096
+#endif
+#ifndef PTRDIFF_MAX
+#define PTRDIFF_MAX 2147483647
+#endif
+#ifndef PTRDIFF_MIN
+#define PTRDIFF_MIN -2147483648
+#endif
+#ifndef SCHAR_MAX
+#define SCHAR_MAX 127
+#endif
+#ifndef SCHAR_MIN
+#define SCHAR_MIN -128
+#endif
+#ifndef SHRT_MIN
+#define SHRT_MIN -32768
+#endif
+#ifndef SIG_ATOMIC_MAX
+#define SIG_ATOMIC_MAX 2147483647
+#endif
+#ifndef SIG_ATOMIC_MIN
+#define SIG_ATOMIC_MIN -2147483648
+#endif
+#ifndef SIZE_MAX
+#ifndef UINT_MAX
+#define UINT_MAX 4294967295
+#endif
+#define SIZE_MAX UINT_MAX
+#endif
+#ifndef SSIZE_MAX
+#ifndef INT_MAX
+#define INT_MAX 2147483647
+#endif
+#define SSIZE_MAX INT_MAX
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+#ifndef UCHAR_MAX
+#define UCHAR_MAX 255
+#endif
+#ifndef ULLONG_MAX
+#define ULLONG_MAX 18446744073709551615
+#endif
+#ifndef ULONG_MAX
+#define ULONG_MAX 4294967295
+#endif
+#ifndef USHRT_MAX
+#define USHRT_MAX 65535
+#endif
+#ifndef WCHAR_MAX
+#define WCHAR_MAX 2147483647
+#endif
+#ifndef WCHAR_MIN
+#define WCHAR_MIN -2147483648
+#endif
+#ifndef WINT_MAX
+#define WINT_MAX 2147483647
+#endif
+#ifndef WINT_MIN
+#define WINT_MIN -2147483648
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_map.h b/usr/src/lib/libast/i386/src/lib/libast/ast_map.h
new file mode 100644
index 0000000000..5ae49fb0a6
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_map.h
@@ -0,0 +1,438 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/map.c by iffe version 2007-04-04 : : */
+#ifndef _def_map_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_map_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+/*
+ * prototypes provided for standard interfaces hijacked
+ * by ast and mapped to _ast_* but already prototyped
+ * unmapped in native headers included by <ast_std.h>
+ */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+
+#define _map_libc 1
+#undef basename
+#define basename _ast_basename
+#undef dirname
+#define dirname _ast_dirname
+#undef eaccess
+#define eaccess _ast_eaccess
+#undef execvpe
+#define execvpe _ast_execvpe
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+#undef fnmatch
+#define fnmatch _ast_fnmatch
+#undef fts_children
+#define fts_children _ast_fts_children
+#undef fts_close
+#define fts_close _ast_fts_close
+#undef fts_flags
+#define fts_flags _ast_fts_flags
+#undef fts_notify
+#define fts_notify _ast_fts_notify
+#undef fts_open
+#define fts_open _ast_fts_open
+#undef fts_read
+#define fts_read _ast_fts_read
+#undef fts_set
+#define fts_set _ast_fts_set
+#undef ftw
+#define ftw _ast_ftw
+#undef ftwalk
+#define ftwalk _ast_ftwalk
+#undef ftwflags
+#define ftwflags _ast_ftwflags
+#undef getcwd
+#define getcwd _ast_getcwd
+extern __MANGLE__ char* getcwd __PROTO__((char*, size_t));
+#undef getdate
+#define getdate _ast_getdate
+#undef getopt
+#define getopt _ast_getopt
+#undef getsubopt
+#define getsubopt _ast_getsubopt
+#undef getopt_long
+#define getopt_long _ast_getopt_long
+#undef getopt_long_only
+#define getopt_long_only _ast_getopt_long_only
+#undef getwd
+#define getwd _ast_getwd
+extern __MANGLE__ char* getwd __PROTO__((char*));
+#undef glob
+#define glob _ast_glob
+#undef globfree
+#define globfree _ast_globfree
+#undef memdup
+#define memdup _ast_memdup
+#undef memfatal
+#define memfatal _ast_memfatal
+#undef memhash
+#define memhash _ast_memhash
+#undef memsum
+#define memsum _ast_memsum
+#undef mkstemp
+#define mkstemp _ast_mkstemp
+extern __MANGLE__ int mkstemp __PROTO__((char*));
+#undef mktemp
+#define mktemp _ast_mktemp
+extern __MANGLE__ char* mktemp __PROTO__((char*));
+#undef mktime
+#define mktime _ast_mktime
+#undef nftw
+#define nftw _ast_nftw
+#undef optesc
+#define optesc _ast_optesc
+#undef optget
+#define optget _ast_optget
+#undef opthelp
+#define opthelp _ast_opthelp
+#undef optjoin
+#define optjoin _ast_optjoin
+#undef optstr
+#define optstr _ast_optstr
+#undef optusage
+#define optusage _ast_optusage
+#undef pathaccess
+#define pathaccess _ast_pathaccess
+#undef pathbin
+#define pathbin _ast_pathbin
+#undef pathcanon
+#define pathcanon _ast_pathcanon
+#undef pathcat
+#define pathcat _ast_pathcat
+#undef pathcd
+#define pathcd _ast_pathcd
+#undef pathcheck
+#define pathcheck _ast_pathcheck
+#undef pathexists
+#define pathexists _ast_pathexists
+#undef pathfind
+#define pathfind _ast_pathfind
+#undef pathgetlink
+#define pathgetlink _ast_pathgetlink
+#undef pathinclude
+#define pathinclude _ast_pathinclude
+#undef pathkey
+#define pathkey _ast_pathkey
+#undef pathnative
+#define pathnative _ast_pathnative
+#undef pathpath
+#define pathpath _ast_pathpath
+#undef pathposix
+#define pathposix _ast_pathposix
+#undef pathprobe
+#define pathprobe _ast_pathprobe
+#undef pathrepl
+#define pathrepl _ast_pathrepl
+#undef pathsetlink
+#define pathsetlink _ast_pathsetlink
+#undef pathshell
+#define pathshell _ast_pathshell
+#undef pathstat
+#define pathstat _ast_pathstat
+#undef pathtemp
+#define pathtemp _ast_pathtemp
+#undef pathtmp
+#define pathtmp _ast_pathtmp
+#undef procclose
+#define procclose _ast_procclose
+#undef procfree
+#define procfree _ast_procfree
+#undef procopen
+#define procopen _ast_procopen
+#undef procrun
+#define procrun _ast_procrun
+#undef putenv
+#define putenv _ast_putenv
+#undef re_comp
+#define re_comp _ast_re_comp
+#undef re_exec
+#define re_exec _ast_re_exec
+#undef realpath
+#define realpath _ast_realpath
+extern __MANGLE__ char* realpath __PROTO__((const char*, char*));
+#undef regaddclass
+#define regaddclass _ast_regaddclass
+#undef regalloc
+#define regalloc _ast_regalloc
+#undef regcache
+#define regcache _ast_regcache
+#undef regclass
+#define regclass _ast_regclass
+#undef regcmp
+#define regcmp _ast_regcmp
+#undef regcollate
+#define regcollate _ast_regcollate
+#undef regcomb
+#define regcomb _ast_regcomb
+#undef regcomp
+#define regcomp _ast_regcomp
+#undef regdecomp
+#define regdecomp _ast_regdecomp
+#undef regdup
+#define regdup _ast_regdup
+#undef regerror
+#define regerror _ast_regerror
+#undef regex
+#define regex _ast_regex
+#undef regexec
+#define regexec _ast_regexec
+#undef regfatal
+#define regfatal _ast_regfatal
+#undef regfatalpat
+#define regfatalpat _ast_regfatalpat
+#undef regfree
+#define regfree _ast_regfree
+#undef regncomp
+#define regncomp _ast_regncomp
+#undef regnexec
+#define regnexec _ast_regnexec
+#undef regrecord
+#define regrecord _ast_regrecord
+#undef regrexec
+#define regrexec _ast_regrexec
+#undef regstat
+#define regstat _ast_regstat
+#undef regsub
+#define regsub _ast_regsub
+#undef regsubcomp
+#define regsubcomp _ast_regsubcomp
+#undef regsubexec
+#define regsubexec _ast_regsubexec
+#undef regsubflags
+#define regsubflags _ast_regsubflags
+#undef regsubfree
+#define regsubfree _ast_regsubfree
+#undef remove
+#define remove _ast_remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#undef resolvepath
+#define resolvepath _ast_resolvepath
+extern __MANGLE__ char* resolvepath __PROTO__((const char*, char*, size_t));
+#undef setenv
+#define setenv _ast_setenv
+extern __MANGLE__ int setenv __PROTO__((const char*, const char*, int));
+#undef setenviron
+#define setenviron _ast_setenviron
+#undef sigcritical
+#define sigcritical _ast_sigcritical
+#undef signal
+#define signal _ast_signal
+#undef sigunblock
+#define sigunblock _ast_sigunblock
+#undef stracmp
+#define stracmp _ast_stracmp
+#undef strcopy
+#define strcopy _ast_strcopy
+#undef strelapsed
+#define strelapsed _ast_strelapsed
+#undef stresc
+#define stresc _ast_stresc
+#undef streval
+#define streval _ast_streval
+#undef strexpr
+#define strexpr _ast_strexpr
+#undef strftime
+#define strftime _ast_strftime
+#undef strgid
+#define strgid _ast_strgid
+#undef strgrpmatch
+#define strgrpmatch _ast_strgrpmatch
+#undef strhash
+#define strhash _ast_strhash
+#undef strkey
+#define strkey _ast_strkey
+#undef strlcat
+#define strlcat _ast_strlcat
+extern __MANGLE__ size_t strlcat __PROTO__((char*, const char*, size_t));
+#undef strlcpy
+#define strlcpy _ast_strlcpy
+extern __MANGLE__ size_t strlcpy __PROTO__((char*, const char*, size_t));
+#undef strlook
+#define strlook _ast_strlook
+#undef strmatch
+#define strmatch _ast_strmatch
+#undef strmode
+#define strmode _ast_strmode
+#undef strnacmp
+#define strnacmp _ast_strnacmp
+#undef strncopy
+#define strncopy _ast_strncopy
+#undef strntod
+#define strntod _ast_strntod
+#undef strntol
+#define strntol _ast_strntol
+#undef strntold
+#define strntold _ast_strntold
+#undef strntoll
+#define strntoll _ast_strntoll
+#undef strntoul
+#define strntoul _ast_strntoul
+#undef strntoull
+#define strntoull _ast_strntoull
+#undef stropt
+#define stropt _ast_stropt
+#undef strperm
+#define strperm _ast_strperm
+#undef strpsearch
+#define strpsearch _ast_strpsearch
+#undef strptime
+#define strptime _ast_strptime
+#undef strsearch
+#define strsearch _ast_strsearch
+#undef strsort
+#define strsort _ast_strsort
+#undef strsubmatch
+#define strsubmatch _ast_strsubmatch
+#undef strsum
+#define strsum _ast_strsum
+#undef strtape
+#define strtape _ast_strtape
+#undef strtoip4
+#define strtoip4 _ast_strtoip4
+#undef strton
+#define strton _ast_strton
+#undef strtonll
+#define strtonll _ast_strtonll
+#undef struid
+#define struid _ast_struid
+#undef struniq
+#define struniq _ast_struniq
+#undef system
+#define system _ast_system
+extern __MANGLE__ int system __PROTO__((const char*));
+#undef tempnam
+#define tempnam _ast_tempnam
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+#undef tmpnam
+#define tmpnam _ast_tmpnam
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+#undef touch
+#define touch _ast_touch
+#undef wordexp
+#define wordexp _ast_wordexp
+#undef wordfree
+#define wordfree _ast_wordfree
+#undef unsetenv
+#define unsetenv _ast_unsetenv
+
+/* cannot override local malloc */
+#define _map_malloc 1
+#undef calloc
+#define calloc _ast_calloc
+extern __MANGLE__ __V_* calloc __PROTO__((size_t, size_t));
+#undef cfree
+#define cfree _ast_cfree
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+#undef free
+#define free _ast_free
+extern __MANGLE__ void free __PROTO__((__V_*));
+#undef malloc
+#define malloc _ast_malloc
+extern __MANGLE__ __V_* malloc __PROTO__((size_t));
+#undef memalign
+#define memalign _ast_memalign
+extern __MANGLE__ __V_* memalign __PROTO__((size_t, size_t));
+#undef realloc
+#define realloc _ast_realloc
+extern __MANGLE__ __V_* realloc __PROTO__((__V_*, size_t));
+#undef strdup
+#define strdup _ast_strdup
+extern __MANGLE__ char* strdup __PROTO__((const char*));
+#undef valloc
+#define valloc _ast_valloc
+extern __MANGLE__ __V_* valloc __PROTO__((size_t));
+#undef strtol
+#define strtol _ast_strtol
+#undef strtoul
+#define strtoul _ast_strtoul
+#undef strtoll
+#define strtoll _ast_strtoll
+#undef strtoull
+#define strtoull _ast_strtoull
+#undef strtod
+#define strtod _ast_strtod
+#undef strtold
+#define strtold _ast_strtold
+extern __MANGLE__ long strtol __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned long strtoul __PROTO__((const char*, char**, int));
+extern __MANGLE__ double strtod __PROTO__((const char*, char**));
+#if !_UWIN
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
+extern __MANGLE__ _ast_fltmax_t strtold __PROTO__((const char*, char**));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+extern __MANGLE__ _ast_intmax_t strtoll __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned _ast_intmax_t strtoull __PROTO__((const char*, char**, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_mmap.h b/usr/src/lib/libast/i386/src/lib/libast/ast_mmap.h
new file mode 100644
index 0000000000..957987b8aa
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_mmap.h
@@ -0,0 +1,26 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/mmap by iffe version 2007-04-04 : : */
+#ifndef _def_mmap_ast
+#define _def_mmap_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_mmap 1 /* standard mmap interface that works */
+#define _lib_mmap64 1 /* mmap64 interface and implementation work */
+#define _mmap_anon 1 /* use mmap MAP_ANON to get raw memory */
+#define _mmap_devzero 1 /* use mmap on /dev/zero to get raw memory */
+
+/* some systems get it wrong but escape concise detection */
+#ifndef _NO_MMAP
+#if __CYGWIN__
+#define _NO_MMAP 1
+#endif
+#endif
+
+#if _NO_MMAP
+#undef _lib_mmap
+#undef _lib_mmap64
+#undef _mmap_anon
+#undef _mmap_devzero
+#undef _mmap_worthy
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_mode.h b/usr/src/lib/libast/i386/src/lib/libast/ast_mode.h
new file mode 100644
index 0000000000..d9e489168f
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_mode.h
@@ -0,0 +1,14 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/mode.c by iffe version 2007-04-04 : : */
+#ifndef _def_mode_ast
+#define _def_mode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define S_ITYPE(m) ((m)&S_IFMT)
+
+#define S_IPERM (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
+
+#define _S_IDPERM 1
+#define _S_IDTYPE 1
+
+#define BUFFERSIZE 8192
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_nl_types.h b/usr/src/lib/libast/i386/src/lib/libast/ast_nl_types.h
new file mode 100644
index 0000000000..088c1c0cb2
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_nl_types.h
@@ -0,0 +1,102 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/nl_types by iffe version 2007-04-04 : : */
+
+#ifndef _def_nl_types_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_nl_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_nl_langinfo 1 /* nl_langinfo() in default lib(s) */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_langinfo 1 /* #include <langinfo.h> ok */
+#define _nxt_nl_types <../include/nl_types.h> /* include path for the native <nl_types.h> */
+#define _nxt_nl_types_str "../include/nl_types.h" /* include string for the native <nl_types.h> */
+#include <limits.h>
+#include <../include/nl_types.h> /* the native nl_types.h */
+
+#undef NL_SETMAX
+#define NL_SETMAX 1023
+#undef NL_MSGMAX
+#define NL_MSGMAX 32767
+#undef nl_catd
+#define nl_catd _ast_nl_catd
+#undef catopen
+#define catopen _ast_catopen
+#undef catgets
+#define catgets _ast_catgets
+#undef catclose
+#define catclose _ast_catclose
+
+typedef __V_* nl_catd;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ nl_catd catopen __PROTO__((const char*, int));
+extern __MANGLE__ char* catgets __PROTO__((nl_catd, int, int, const char*));
+extern __MANGLE__ int catclose __PROTO__((nl_catd));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_param.h b/usr/src/lib/libast/i386/src/lib/libast/ast_param.h
new file mode 100644
index 0000000000..74a6367a3a
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_param.h
@@ -0,0 +1,9 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/param.sh by iffe version 2007-04-04 : : */
+#ifndef _def_param_ast
+#define _def_param_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#include <sys/param.h>
+#ifndef S_IFDIR
+#include <sys/stat.h>
+#endif
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_standards.h b/usr/src/lib/libast/i386/src/lib/libast/ast_standards.h
new file mode 100644
index 0000000000..186cf1c635
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_standards.h
@@ -0,0 +1,28 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/standards by iffe version 2007-04-04 : : */
+#ifndef _def_standards_ast
+#define _def_standards_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* _ALL_SOURCE & _ISOC99_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works */
+#ifndef _ALL_SOURCE
+#define _ALL_SOURCE 1
+#endif
+#ifndef _ISOC99_SOURCE
+#define _ISOC99_SOURCE 1
+#endif
+#ifndef _POSIX_SOURCE
+#define _POSIX_SOURCE 1
+#endif
+#ifndef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 21000101L
+#endif
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 9900
+#endif
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#ifndef __EXTENSIONS__
+#define __EXTENSIONS__ 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_stdio.h b/usr/src/lib/libast/i386/src/lib/libast/ast_stdio.h
new file mode 100644
index 0000000000..6c72b2d2f4
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_stdio.h
@@ -0,0 +1,579 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/stdio by iffe version 2007-04-04 : : */
+
+#ifndef _SFSTDIO_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SFSTDIO_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define __FILE_typedef 1
+#define _FILE_DEFINED 1
+#define _FILE_defined 1
+#define _FILEDEFED 1
+
+#ifndef __FILE_TAG
+#define __FILE_TAG _sfio_s
+#endif
+
+#undef FILE
+#undef _FILE
+#undef fpos_t
+#undef fpos64_t
+
+typedef struct _sfio_s _sfio_FILE;
+
+#define FILE _sfio_FILE
+#define _FILE FILE
+
+#if !defined(__FILE) && !__CYGWIN__
+#undef __FILE
+#define __FILE FILE
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define BUFSIZ SF_BUFSIZE
+
+#else
+
+#ifndef BUFSIZ
+#define BUFSIZ 8192
+#endif
+
+#ifndef EOF
+#define EOF (-1)
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+#include <ast_std.h>
+
+#include <sfio_s.h>
+
+#if __cplusplus
+#define _sf_(f) (f)
+#else
+#define _sf_(f) ((struct _sfio_s*)(f))
+#endif
+
+#define _SF_EOF 0000200
+#define _SF_ERROR 0000400
+
+#endif
+
+#ifdef _NO_LARGEFILE64_SOURCE
+#undef _LARGEFILE64_SOURCE
+#endif
+
+#ifdef _LARGEFILE64_SOURCE
+#undef off_t
+#endif
+
+#define fpos_t _ast_fpos_t
+#if _typ_int64_t
+#define fpos64_t _ast_fpos_t
+#endif
+
+typedef struct _ast_fpos_s
+{
+ intmax_t _sf_offset;
+ unsigned char _sf_state[64 - sizeof(intmax_t)];
+} _ast_fpos_t;
+
+#define _base _data
+#define _ptr _next
+#define _IOFBF 0
+#define _IONBF 1
+#define _IOLBF 2
+
+#if defined(__cplusplus) && defined(__THROW) && !defined(_UWIN)
+
+#undef FILE
+#define FILE FILE
+typedef struct _sfio_s FILE;
+
+#undef strerror
+extern __MANGLE__ char* strerror(int) __THROW;
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#endif
+
+#ifndef FILENAME_MAX
+#define FILENAME_MAX 1024
+#endif
+#ifndef FOPEN_MAX
+#define FOPEN_MAX 60
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+
+#define _doprnt _ast_doprnt
+#define _doscan _ast_doscan
+#define asprintf _ast_asprintf
+#define clearerr _ast_clearerr
+#define fclose _ast_fclose
+#define fdopen _ast_fdopen
+#define fflush _ast_fflush
+#define fgetc _ast_fgetc
+#define fgetpos _ast_fgetpos
+#define fgetpos64 _ast_fgetpos64
+#define fgets _ast_fgets
+#define fopen _ast_fopen
+#define fprintf _ast_fprintf
+#define fpurge _ast_fpurge
+#define fputs _ast_fputs
+#define fread _ast_fread
+#define freopen _ast_freopen
+#define fscanf _ast_fscanf
+#define fseek _ast_fseek
+#define fseek64 _ast_fseek64
+#define fseeko _ast_fseeko
+#define fseeko64 _ast_fseeko64
+#define fsetpos _ast_fsetpos
+#define fsetpos64 _ast_fsetpos64
+#define ftell _ast_ftell
+#define ftell64 _ast_ftell64
+#define ftello _ast_ftello
+#define ftello64 _ast_ftello64
+#define fwrite _ast_fwrite
+#define gets _ast_gets
+#define getw _ast_getw
+#define pclose _ast_pclose
+#define popen _ast_popen
+#define printf _ast_printf
+#define puts _ast_puts
+#define putw _ast_putw
+#define rewind _ast_rewind
+#define scanf _ast_scanf
+#define setbuf _ast_setbuf
+#undef setbuffer
+#define setbuffer _ast_setbuffer
+#define setlinebuf _ast_setlinebuf
+#define setvbuf _ast_setvbuf
+#define snprintf _ast_snprintf
+#define sprintf _ast_sprintf
+#define sscanf _ast_sscanf
+#define tmpfile _ast_tmpfile
+#define ungetc _ast_ungetc
+#define vasprintf _ast_vasprintf
+#define vfprintf _ast_vfprintf
+#define vfscanf _ast_vfscanf
+#define vprintf _ast_vprintf
+#define vscanf _ast_vscanf
+#define vsnprintf _ast_vsnprintf
+#define vsprintf _ast_vsprintf
+#define vsscanf _ast_vsscanf
+#define fcloseall _ast_fcloseall
+#define fmemopen _ast_fmemopen
+#define __getdelim _ast___getdelim
+#define getdelim _ast_getdelim
+#define getline _ast_getline
+#define clearerr_unlocked _ast_clearerr_unlocked
+#define feof_unlocked _ast_feof_unlocked
+#define ferror_unlocked _ast_ferror_unlocked
+#define fflush_unlocked _ast_fflush_unlocked
+#define fgetc_unlocked _ast_fgetc_unlocked
+#define fgets_unlocked _ast_fgets_unlocked
+#define fileno_unlocked _ast_fileno_unlocked
+#define fputc_unlocked _ast_fputc_unlocked
+#define fputs_unlocked _ast_fputs_unlocked
+#define fread_unlocked _ast_fread_unlocked
+#define fwrite_unlocked _ast_fwrite_unlocked
+#define getc_unlocked _ast_getc_unlocked
+#define getchar_unlocked _ast_getchar_unlocked
+#define putc_unlocked _ast_putc_unlocked
+#define putchar_unlocked _ast_putchar_unlocked
+
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef P_tmpdir
+#define P_tmpdir "/var/tmp/" /*NOCATLITERAL*/
+#endif
+#ifndef L_ctermid
+#define L_ctermid 9
+#endif
+#ifndef L_tmpnam
+#define L_tmpnam 25
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#if defined(__cplusplus) && defined(__THROW)
+extern __MANGLE__ char* ctermid(char*) __THROW;
+#else
+extern __MANGLE__ char* ctermid __PROTO__((char*));
+#endif
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+extern __MANGLE__ void perror __PROTO__((const char*));
+#ifndef _AST_STD_H
+#ifndef remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#endif
+#ifndef rename
+extern __MANGLE__ int rename __PROTO__((const char*, const char*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#ifdef _LARGEFILE64_SOURCE
+
+#undef fpos_t
+#undef off_t
+#undef fgetpos
+#undef fsetpos
+#undef fseek
+#undef fseeko
+#undef ftell
+#undef ftello
+
+#define fpos_t fpos64_t
+#if _typ_off64_t
+#define off_t off64_t
+#else
+#define off_t int64_t
+#endif
+
+#define fgetpos fgetpos64
+#define fsetpos fsetpos64
+#define fseek fseek64
+#define fseeko fseeko64
+#define ftell ftell64
+#define ftello ftello64
+
+#endif
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_DLL && _DLL_INDIRECT_DATA
+
+#define stdin ((FILE*)_ast_dll->_ast_stdin)
+#define stdout ((FILE*)_ast_dll->_ast_stdout)
+#define stderr ((FILE*)_ast_dll->_ast_stderr)
+
+#else
+
+#define stdin (&_Sfstdin)
+#define stdout (&_Sfstdout)
+#define stderr (&_Sfstderr)
+
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define feof(f) sfeof(f)
+#define ferror(f) sferror(f)
+#define fileno(f) sffileno(f)
+#define fputc(c,f) sfputc(f,c)
+#define getc(f) sfgetc(f)
+#define getchar() sfgetc(sfstdin)
+#define putc(c,f) sfputc(f,c)
+#define putchar(c) sfputc(sfstdout,c)
+
+#else
+
+#if !_UWIN
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+#endif
+
+extern __MANGLE__ FILE _Sfstdin;
+extern __MANGLE__ FILE _Sfstdout;
+extern __MANGLE__ FILE _Sfstderr;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define feof(f) (_sf_(f)->_flags&_SF_EOF)
+#define ferror(f) (_sf_(f)->_flags&_SF_ERROR)
+#define fileno(f) (_sf_(f)->_file)
+#define fputc(c,f) (_sf_(f)->_next>=_sf_(f)->_endw?_sfflsbuf(_sf_(f),(int)((unsigned char)(c))):(int)(*_sf_(f)->_next++=(unsigned char)(c)))
+#define getc(f) (_sf_(f)->_next>=_sf_(f)->_endr?_sffilbuf(_sf_(f),0):(int)(*_sf_(f)->_next++))
+#define getchar() getc(stdin)
+#define putc(c,f) fputc(c,f)
+#define putchar(c) fputc(c,stdout)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _sffilbuf __PROTO__((FILE*, int));
+extern __MANGLE__ int _sfflsbuf __PROTO__((FILE*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_sys.h b/usr/src/lib/libast/i386/src/lib/libast/ast_sys.h
new file mode 100644
index 0000000000..9e024f86e7
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_sys.h
@@ -0,0 +1,151 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/sys by iffe version 2007-04-04 : : */
+
+#ifndef _AST_SYS_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_SYS_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#if __mips == 2 && !defined(_NO_LARGEFILE64_SOURCE)
+#define _NO_LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_NO_LARGEFILE64_SOURCE) && _typ_off64_t && _lib_lseek64 && _lib_stat64
+#if !defined(_LARGEFILE64_SOURCE)
+#define _LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_LARGEFILE_SOURCE)
+#define _LARGEFILE_SOURCE 1
+#endif
+#else
+#undef _LARGEFILE64_SOURCE
+#undef _LARGEFILE_SOURCE
+#undef _typ_off64_t
+#undef _typ_struct_dirent64
+#undef _lib_creat64
+#undef _lib_fstat64
+#undef _lib_fstatvfs64
+#undef _lib_ftruncate64
+#undef _lib_lseek64
+#undef _lib_lstat64
+#undef _lib_mmap64
+#undef _lib_open64
+#undef _lib_readdir64
+#undef _lib_stat64
+#undef _lib_statvfs64
+#undef _lib_truncate64
+#endif
+#if defined(__STDC__) && !defined(__USE_FIXED_PROTOTYPES__)
+#define __USE_FIXED_PROTOTYPES__ 1 /* kick gcc out of the past */
+#endif
+#include <stdlib.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <locale.h>
+#include <sys/localedef.h>
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _typ_dev_t 1 /* dev_t is a type */
+#define _typ_nlink_t 1 /* nlink_t is a type */
+#define _typ_gid_t 1 /* gid_t is a type */
+#define _typ_mode_t 1 /* mode_t is a type */
+#define _typ_uid_t 1 /* uid_t is a type */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _typ_wchar_t 1 /* wchar_t is a type */
+#define _typ_pid_t 1 /* pid_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _typ_wint_t 1 /* wint_t is a type */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _typ_socklen_t 1 /* socklen_t is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_ino_t 1 /* ino_t is a type */
+#define _typ_off_t 1 /* off_t is a type */
+#define _typ_ptrdiff_t 1 /* ptrdiff_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#define _typ_div_t 1 /* div_t is a type */
+#define _typ_ldiv_t 1 /* ldiv_t is a type */
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+extern __MANGLE__ int eaccess __PROTO__((const char*, int));
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+extern __MANGLE__ __V_* pvalloc __PROTO__((size_t));
+extern __MANGLE__ pid_t spawnveg __PROTO__((const char*, char* const[], char* const[], pid_t));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#if !defined(va_start)
+#if defined(__STDARG__)
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_time.h b/usr/src/lib/libast/i386/src/lib/libast/ast_time.h
new file mode 100644
index 0000000000..fd36809299
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_time.h
@@ -0,0 +1,83 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/time by iffe version 2007-04-04 : : */
+
+#ifndef _def_time_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_time_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_nanosleep 1 /* nanosleep() in default lib(s) */
+#define _lib_usleep 1 /* usleep() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#include <sys/time.h>
+
+#include <sys/times.h>
+
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC CLK_TCK
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_tty.h b/usr/src/lib/libast/i386/src/lib/libast/ast_tty.h
new file mode 100644
index 0000000000..e645095122
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_tty.h
@@ -0,0 +1,134 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/tty by iffe version 2007-04-04 : : */
+#ifndef _def_tty_ast
+#define _def_tty_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_termios 1 /* #include <termios.h> ok */
+#define _hdr_termio 1 /* #include <termio.h> ok */
+#define _hdr_sgtty 1 /* #include <sgtty.h> ok */
+#define _sys_termios 1 /* #include <sys/termios.h> ok */
+#define _sys_termio 1 /* #include <sys/termio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _lib_tcgetattr 1 /* tcgetattr() in default lib(s) */
+#define _lib_tcgetpgrp 1 /* tcgetpgrp() in default lib(s) */
+#define _mac__POSIX_VDISABLE 1 /* _POSIX_VDISABLE is a macro */
+
+#ifdef _hdr_termios
+# if _mac__POSIX_VDISABLE
+# undef _POSIX_VDISABLE
+# endif
+# include <termios.h>
+#else
+# if defined(_sys_termios) && defined(_lib_tcgetattr)
+# include <sys/termios.h>
+# define _hdr_termios 1
+# else
+# undef _sys_termios
+# endif /* _sys_termios */
+#endif /* _hdr_termios */
+
+#ifdef _hdr_termios
+# undef _hdr_sgtty
+# undef tcgetattr
+# undef tcsetattr
+# undef tcgetpgrp
+# undef tcsetpgrp
+# undef cfgetospeed
+# ifndef TCSANOW
+# define TCSANOW TCSETS
+# define TCSADRAIN TCSETSW
+# define TCSAFLUSH TCSETSF
+# endif /* TCSANOW */
+ /* The following corrects bugs in some implementations */
+# if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
+# define TCSAFLUSH TCSADFLUSH
+# endif /* TCSADFLUSH */
+# ifndef _lib_tcgetattr
+# undef tcgetattr
+# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
+# undef tcsetattr
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# undef cfgetospeed
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# endif /* _lib_tcgetattr */
+# undef TIOCGETC
+#else
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfgetispeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfsetispeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# define cfsetospeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# ifdef _hdr_termio
+# include <termio.h>
+# else
+# ifdef _sys_termio
+# include <sys/termio.h>
+# define _hdr_termio 1
+# endif /* _sys_termio */
+# endif /* _hdr_termio */
+# ifdef _hdr_termio
+# define termios termio
+# undef TIOCGETC
+# define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+
+# ifdef _sys_bsdtty
+# include <sys/bsdtty.h>
+# endif /* _sys_bsdtty */
+# else
+# ifdef _hdr_sgtty
+# include <sgtty.h>
+# ifndef LPENDIN
+# ifdef _sys_nttyio
+# include <sys/nttyio.h>
+# endif /* _sys_nttyio */
+# endif /* LPENDIN */
+# define termios sgttyb
+# ifdef TIOCSETN
+# undef TCSETAW
+# endif /* TIOCSETN */
+# ifdef TIOCGETP
+# define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# else
+# define tcgetattr(fd,tty) gtty(fd, tty)
+# define tcsetattr(fd,action,tty) stty(fd, tty)
+# endif /* TIOCGETP */
+# else
+# ifdef _sys_ttyio
+# include <sys/ttyio.h>
+# endif
+# endif /* _hdr_sgtty */
+# endif /* hdr_termio */
+
+# ifndef TCSANOW
+# ifdef TCSETAW
+# define TCSANOW TCSETA
+# define TCSAFLUSH TCSETAF
+# else
+# ifdef TIOCSETN
+# define TCSANOW TIOCSETN
+# define TCSADRAIN TIOCSETN
+# define TCSAFLUSH TIOCSETP
+# endif /* TIOCSETN */
+# endif /* TCSETAW */
+# endif /* TCSANOW */
+#endif /* _hdr_termios */
+
+/* set ECHOCTL if driver can echo control charaters as ^c */
+#ifdef LCTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LCTLECH
+# endif /* !ECHOCTL */
+#endif /* LCTLECH */
+#ifdef LNEW_CTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LNEW_CTLECH
+# endif /* !ECHOCTL */
+#endif /* LNEW_CTLECH */
+#ifdef LNEW_PENDIN
+# ifndef PENDIN
+# define PENDIN LNEW_PENDIN
+# endif /* !PENDIN */
+#endif /* LNEW_PENDIN */
+
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_types.h b/usr/src/lib/libast/i386/src/lib/libast/ast_types.h
new file mode 100644
index 0000000000..343b5954a0
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_types.h
@@ -0,0 +1,5 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_types_ast
+#define _def_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_vfork.h b/usr/src/lib/libast/i386/src/lib/libast/ast_vfork.h
new file mode 100644
index 0000000000..f1993151cc
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_vfork.h
@@ -0,0 +1,67 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/vfork by iffe version 2007-04-04 : : */
+
+#ifndef _def_vfork_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_vfork_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+extern __MANGLE__ pid_t vfork __PROTO__((void));
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_wait.h b/usr/src/lib/libast/i386/src/lib/libast/ast_wait.h
new file mode 100644
index 0000000000..9ed6722037
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_wait.h
@@ -0,0 +1,11 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/wait by iffe version 2007-04-04 : : */
+#ifndef _def_wait_ast
+#define _def_wait_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_wait 1 /* wait() in default lib(s) */
+#define _lib_wait3 1 /* wait3() in default lib(s) */
+#define _lib_wait4 1 /* wait4() in default lib(s) */
+#define _lib_waitpid 1 /* waitpid() in default lib(s) */
+#define _sys_wait 1 /* #include <sys/wait.h> ok */
+#define _ok_wif 1 /* posix wait macros ok */
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/ast_wchar.h b/usr/src/lib/libast/i386/src/lib/libast/ast_wchar.h
new file mode 100644
index 0000000000..a3f8a10eff
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/ast_wchar.h
@@ -0,0 +1,187 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/wchar by iffe version 2007-04-04 : : */
+
+#ifndef _def_wchar_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_wchar_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _lib_mbstowcs 1 /* mbstowcs() in default lib(s) */
+#define _lib_wctomb 1 /* wctomb() in default lib(s) */
+#define _lib_wcrtomb 1 /* wcrtomb() in default lib(s) */
+#define _lib_wcslen 1 /* wcslen() in default lib(s) */
+#define _lib_wcstombs 1 /* wcstombs() in default lib(s) */
+#define _lib_wcwidth 1 /* wcwidth() in default lib(s) */
+#define _lib_towlower 1 /* towlower() in default lib(s) */
+#define _lib_towupper 1 /* towupper() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_mbstate_t 1 /* mbstate_t is a type */
+#define _nxt_wchar <../include/wchar.h> /* include path for the native <wchar.h> */
+#define _nxt_wchar_str "../include/wchar.h" /* include string for the native <wchar.h> */
+#ifndef _SFSTDIO_H
+#include <ast_common.h>
+#include <stdio.h>
+#endif
+#if _hdr_wchar && defined(_nxt_wchar)
+#include <../include/wchar.h> /* the native wchar.h */
+#endif
+#if _hdr_wctype
+#include <wctype.h>
+#endif
+
+#ifndef WEOF
+#define WEOF (-1)
+#endif
+
+#undef fgetwc
+#undef fgetws
+#undef fputwc
+#undef fputws
+#undef getwc
+#undef getwchar
+#undef getws
+#undef putwc
+#undef putwchar
+#undef ungetwc
+
+#define fgetwc _ast_fgetwc
+#define fgetws _ast_fgetws
+#define fputwc _ast_fputwc
+#define fputws _ast_fputws
+#define fwide _ast_fwide
+#define fwprintf _ast_fwprintf
+#define fwscanf _ast_fwscanf
+#define getwc _ast_getwc
+#define getwchar _ast_getwchar
+#define getws _ast_getws
+#define putwc _ast_putwc
+#define putwchar _ast_putwchar
+#define swprintf _ast_swprintf
+#define swscanf _ast_swscanf
+#define ungetwc _ast_ungetwc
+#define vfwprintf _ast_vfwprintf
+#define vfwscanf _ast_vfwscanf
+#define vswprintf _ast_vswprintf
+#define vswscanf _ast_vswscanf
+#define vwprintf _ast_vwprintf
+#define vwscanf _ast_vwscanf
+#define wprintf _ast_wprintf
+#define wscanf _ast_wscanf
+
+#if !_typ_mbstate_t
+#undef _typ_mbstate_t
+#define _typ_mbstate_t 1
+typedef char mbstate_t;
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#if !_lib_mbstowcs
+extern __MANGLE__ size_t mbstowcs __PROTO__((wchar_t*, const char*, size_t));
+#endif
+#if !_lib_wctomb
+extern __MANGLE__ int wctomb __PROTO__((char*, wchar_t));
+#endif
+#if !_lib_wcrtomb
+extern __MANGLE__ size_t wcrtomb __PROTO__((char*, wchar_t, mbstate_t*));
+#endif
+#if !_lib_wcslen
+extern __MANGLE__ size_t wcslen __PROTO__((const wchar_t*));
+#endif
+#if !_lib_wcstombs
+extern __MANGLE__ size_t wcstombs __PROTO__((char*, const wchar_t*, size_t));
+#endif
+
+extern __MANGLE__ int fwprintf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ int fwscanf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ wint_t fgetwc __PROTO__((FILE*));
+extern __MANGLE__ wchar_t* fgetws __PROTO__((wchar_t*, int, FILE*));
+extern __MANGLE__ wint_t fputwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ int fputws __PROTO__((const wchar_t*, FILE*));
+extern __MANGLE__ int fwide __PROTO__((FILE*, int));
+extern __MANGLE__ wint_t getwc __PROTO__((FILE*));
+extern __MANGLE__ wint_t getwchar __PROTO__((void));
+extern __MANGLE__ wchar_t* getws __PROTO__((wchar_t*));
+extern __MANGLE__ wint_t putwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ wint_t putwchar __PROTO__((wchar_t));
+extern __MANGLE__ int swprintf __PROTO__((wchar_t*, size_t, const wchar_t*, ...));
+extern __MANGLE__ int swscanf __PROTO__((const wchar_t*, const wchar_t*, ...));
+extern __MANGLE__ wint_t ungetwc __PROTO__((wint_t, FILE*));
+extern __MANGLE__ int vfwprintf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vfwscanf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vwprintf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vwscanf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vswprintf __PROTO__((wchar_t*, size_t, const wchar_t*, va_list));
+extern __MANGLE__ int vswscanf __PROTO__((const wchar_t*, const wchar_t*, va_list));
+extern __MANGLE__ int wprintf __PROTO__((const wchar_t*, ...));
+extern __MANGLE__ int wscanf __PROTO__((const wchar_t*, ...));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/conftab.c b/usr/src/lib/libast/i386/src/lib/libast/conftab.c
new file mode 100644
index 0000000000..fc8c45b7a2
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/conftab.c
@@ -0,0 +1,451 @@
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+#include "FEATURE/standards"
+#include "FEATURE/common"
+#include <sys/types.h>
+#include <limits.h>
+#include <unistd.h>
+#if !defined(SYS_NMLEN)
+#define SYS_NMLEN 9
+#endif
+#include <sys/systeminfo.h>
+#include "FEATURE/param"
+#include "conftab.h"
+
+/* : : generated by conf from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/comp/conf.tab : : */
+
+/*
+ * prefix strings -- the first few are indexed by Conf_t.standard
+ */
+
+const Prefix_t prefix[] =
+{
+ "C", 1, CONF_C, -1,
+ "POSIX", 5, CONF_POSIX, -1,
+ "SVID", 4, CONF_SVID, -1,
+ "XOPEN", 5, CONF_XOPEN, -1,
+ "SUN", 3, CONF_SUN, -1,
+ "XBS5", 4, CONF_XBS5, -1,
+ "SCO", 3, CONF_SCO, -1,
+ "AST", 3, CONF_AST, -1,
+ "AES", 3, CONF_AES, -1,
+ "XPG", 3, CONF_XPG, -1,
+ "GNU", 3, CONF_GNU, -1,
+ "TRUSTEDBSD", 10, CONF_TRUSTEDBSD, -1,
+ "XX", 2, CONF_POSIX, CONF_nop,
+ "CS", 2, CONF_POSIX, CONF_confstr,
+ "PC", 2, CONF_POSIX, CONF_pathconf,
+ "SC", 2, CONF_POSIX, CONF_sysconf,
+ "SI", 2, CONF_SVID, CONF_sysinfo,
+};
+
+int prefix_elements = (int)sizeof(prefix) / (int)sizeof(prefix[0]);
+
+/*
+ * conf strings sorted in ascending order
+ */
+
+const Conf_t conf[] =
+{
+{ "ABI_AIO_XFER_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ABI_ASYNCHRONOUS_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ABI_ASYNC_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ADVISORY_INFO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_ADVISORY_INFO },
+{ "AIO_LISTIO_MAX", { 0, 0 }, { _POSIX_AIO_LISTIO_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_AIO_LISTIO_MAX },
+{ "AIO_MAX", { 0, 0 }, { _POSIX_AIO_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_AIO_MAX },
+{ "AIO_PRIO_DELTA_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, _SC_AIO_PRIO_DELTA_MAX },
+{ "ALLOC_SIZE_MIN", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_ALLOC_SIZE_MIN },
+{ "ARCHITECTURE", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "ARG_MAX", { 0, 0 }, { _POSIX_ARG_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_ARG_MAX },
+{ "ASYNCHRONOUS_IO", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_ASYNCHRONOUS_IO },
+{ "ASYNC_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_ASYNC_IO },
+{ "ATEXIT_MAX", { 0, 0 }, { 32, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_XOPEN, 1, CONF_sysconf, _SC_ATEXIT_MAX },
+{ "AUDIT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "AVAIL_PROCESSORS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "AVPHYS_PAGES", { 0, 0 }, { 0, 0 }, 0, CONF_SUN, 1, CONF_sysconf, _SC_AVPHYS_PAGES },
+{ "BARRIERS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_BARRIERS },
+{ "BC_BASE_MAX", { 0, 0 }, { _POSIX2_BC_BASE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_BC_BASE_MAX },
+{ "BC_DIM_MAX", { 0, 0 }, { _POSIX2_BC_DIM_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_BC_DIM_MAX },
+{ "BC_SCALE_MAX", { 0, 0 }, { _POSIX2_BC_SCALE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_BC_SCALE_MAX },
+{ "BC_STRING_MAX", { 0, 0 }, { _POSIX2_BC_STRING_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_BC_STRING_MAX },
+{ "BUSTYPES", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "CHARCLASS_NAME_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "CHAR_BIT", { 8, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "CHAR_MAX", { 127, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "CHAR_MIN", { -128, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "CHAR_TERM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_CHAR_TERM },
+{ "CHILD_MAX", { 0, 0 }, { _POSIX_CHILD_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_CHILD_MAX },
+{ "CHOWN_RESTRICTED", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_CHOWN_RESTRICTED },
+{ "CKPT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "CLK_TCK", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_POSIX, 1, CONF_sysconf, _SC_CLK_TCK },
+{ "CLOCKRES_MIN", { 0, 0 }, { _POSIX_CLOCKRES_MIN, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_PREFIX_ONLY|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "CLOCKS_PER_SEC", { 1000000, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_LIMIT|CONF_LIMIT_DEF, CONF_POSIX, 1, CONF_nop, -1 },
+{ "CLOCK_SELECTION", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_CLOCK_SELECTION },
+{ "COLL_WEIGHTS_MAX", { 0, 0 }, { _POSIX2_COLL_WEIGHTS_MAX, 0 }, CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_COLL_WEIGHTS_MAX },
+{ "CPUTIME", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_CPUTIME },
+{ "CPU_KEYBITS1", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "CPU_VERSION", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "CRYPT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_CRYPT },
+{ "C_BIND", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 2, CONF_sysconf, _SC_2_C_BIND },
+{ "C_DEV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 2, CONF_sysconf, _SC_2_C_DEV },
+{ "C_VERSION", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 2, CONF_sysconf, _SC_2_C_VERSION },
+{ "DATAKEYS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "DELAYTIMER_MAX", { 0, 0 }, { _POSIX_DELAYTIMER_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_DELAYTIMER_MAX },
+{ "ENH_I18N", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_ENH_I18N },
+{ "EQUIV_CLASS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "EXEC_INTERPRETER_LENGTH", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "EXPR_NEST_MAX", { 0, 0 }, { _POSIX2_EXPR_NEST_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_EXPR_NEST_MAX },
+{ "FCHR_MAX", { 0, 0 }, { LONG_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "FILESIZEBITS", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_FILESIZEBITS },
+{ "FILE_LOCKING", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "FORT_DEV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_FORT_DEV },
+{ "FORT_RUN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_FORT_RUN },
+{ "FSYNC", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_FSYNC },
+{ "GETGR_R_SIZE_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_sysconf, _SC_GETGR_R_SIZE_MAX },
+{ "GETPW_R_SIZE_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_sysconf, _SC_GETPW_R_SIZE_MAX },
+{ "HOSTID", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "HOSTNAME", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "HOST_NAME_MAX", { 0, 0 }, { _POSIX_HOST_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_HOST_NAME_MAX },
+{ "HW_PROVIDER", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "HW_SERIAL", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ILP32_OFF32", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XBS5, 1, CONF_sysconf, -1 },
+{ "ILP32_OFF32_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFF32_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFF32_LIBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFF32_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFFBIG", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XBS5, 1, CONF_sysconf, -1 },
+{ "ILP32_OFFBIG_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFFBIG_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFFBIG_LIBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFFBIG_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "INITTAB_NAME", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "INT_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "INT_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "IOV_MAX", { 0, 0 }, { _XOPEN_IOV_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_XOPEN, 1, CONF_sysconf, _SC_IOV_MAX },
+{ "IO_TYPE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "IPV6", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_IPV6 },
+{ "IP_SECOPTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "JOB_CONTROL", { 0, 0 }, { 1, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_JOB_CONTROL },
+{ "KERNEL_CLIST", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_CLIST_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_DISK", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_DISK_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_DMABUF", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_DMABUF_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_FILE", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_FILE_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_FLCKREC", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_FLCKREC_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_INODE", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_INODE_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_MOUNT", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_MOUNT_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_PINODE", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_PINODE_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_PROC", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_PROC_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_REGION", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_REGION_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_S5INODE", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_S5INODE_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_STAMP", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "KERN_POINTERS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "KERN_SIM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "LEGACY", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, -1 },
+{ "LFS64_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS64_CFLAGS },
+{ "LFS64_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS64_LDFLAGS },
+{ "LFS64_LIBS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS64_LIBS },
+{ "LFS64_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS64_LINTFLAGS },
+{ "LFS_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_CFLAGS },
+{ "LFS_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_LDFLAGS },
+{ "LFS_LIBS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_LIBS },
+{ "LFS_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_LINTFLAGS },
+{ "LINE_MAX", { 0, 0 }, { _POSIX2_LINE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_LINE_MAX },
+{ "LINK_MAX", { 0, 0 }, { _POSIX_LINK_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_LINK_MAX },
+{ "LLONG_MAX", { 9223372036854775807LL, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "LLONG_MIN", { (-9223372036854775807LL-1LL), 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "LOCALEDEF", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_LOCALEDEF },
+{ "LOGIN_NAME_MAX", { 0, 0 }, { _POSIX_LOGIN_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_LOGIN_NAME_MAX },
+{ "LOGNAME_MAX", { 0, 0 }, { 8, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, _SC_LOGNAME_MAX },
+{ "LONG_BIT", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "LONG_MAX", { 2147483647, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "LONG_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "LP64_OFF64", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XBS5, 1, CONF_sysconf, -1 },
+{ "LP64_OFF64_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LP64_OFF64_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LP64_OFF64_LIBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LP64_OFF64_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LPBIG_OFFBIG", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XBS5, 1, CONF_sysconf, -1 },
+{ "LPBIG_OFFBIG_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LPBIG_OFFBIG_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LPBIG_OFFBIG_LIBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LPBIG_OFFBIG_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "MACHINE", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "MAPPED_FILES", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MAPPED_FILES },
+{ "MAX_CANON", { 0, 0 }, { _POSIX_MAX_CANON, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_MAX_CANON },
+{ "MAX_INPUT", { 0, 0 }, { _POSIX_MAX_INPUT, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_MAX_INPUT },
+{ "MB_LEN_MAX", { 5, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "MCAS_OFFSET", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "MEMLOCK", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MEMLOCK },
+{ "MEMLOCK_RANGE", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MEMLOCK_RANGE },
+{ "MEMORY_PROTECTION", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MEMORY_PROTECTION },
+{ "MESSAGE_PASSING", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MESSAGE_PASSING },
+{ "MMAP_FIXED_ALIGNMENT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "MONOTONIC_CLOCK", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MONOTONIC_CLOCK },
+{ "MQ_OPEN_MAX", { 0, 0 }, { _POSIX_MQ_OPEN_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_MQ_OPEN_MAX },
+{ "MQ_PRIO_MAX", { 0, 0 }, { _POSIX_MQ_PRIO_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_MQ_PRIO_MAX },
+{ "MSEM_LOCKID", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "MULTI_PROCESS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "NACLS_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "NAME_MAX", { 0, 0 }, { _POSIX_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_NAME_MAX },
+{ "NGROUPS_MAX", { 0, 0 }, { _POSIX_NGROUPS_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_NGROUPS_MAX },
+{ "NL_ARGMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_LANGMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NL_MSGMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_NMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_SETMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_SPECMAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NL_TEXTMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NO_TRUNC", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_NO_TRUNC },
+{ "NPROCESSORS_CONF", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, _SC_NPROCESSORS_CONF },
+{ "NPROCESSORS_ONLN", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, _SC_NPROCESSORS_ONLN },
+{ "NPROC_CONF", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NPROC_ONLN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NSS_BUFLEN_GROUP", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NSS_BUFLEN_PASSWD", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NUM_PROCESSORS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NZERO", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "OPEN_MAX", { 0, 0 }, { _POSIX_OPEN_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_OPEN_MAX },
+{ "OPEN_MAX_CEIL", { OPEN_MAX, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_AST, 1, CONF_nop, -1 },
+{ "OSREL_MAJ", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "OSREL_MIN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "OSREL_PATCH", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "OS_BASE", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "OS_PROVIDER", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "OS_VERSION", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE, CONF_AES, 1, CONF_sysconf, -1 },
+{ "PAGESIZE", { 0, 0 }, { 4096, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_PAGESIZE },
+{ "PAGE_SIZE", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, _SC_PAGE_SIZE },
+{ "PASS_MAX", { 0, 0 }, { 8, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, _SC_PASS_MAX },
+{ "PATH", { 0, 0 }, { 0, "/bin:/usr/bin" }, CONF_DEFER_CALL|CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_confstr, _CS_PATH },
+{ "PATH_MAX", { 0, 0 }, { _POSIX_PATH_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_PATH_MAX },
+{ "PBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS },
+{ "PBS_ACCOUNTING", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_ACCOUNTING },
+{ "PBS_CHECKPOINT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_CHECKPOINT },
+{ "PBS_LOCATE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_LOCATE },
+{ "PBS_MESSAGE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_MESSAGE },
+{ "PBS_TRACK", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_TRACK },
+{ "PHYS_PAGES", { 0, 0 }, { 0, 0 }, 0, CONF_SUN, 1, CONF_sysconf, _SC_PHYS_PAGES },
+{ "PID_MAX", { 0, 0 }, { 30000, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "PII", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_INTERNET", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_INTERNET_DGRAM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_INTERNET_STREAM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_OSI", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_OSI_CLTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_OSI_COTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_OSI_M", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_SOCKET", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_XTI", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PIPE_BUF", { 0, 0 }, { _POSIX_PIPE_BUF, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_PIPE_BUF },
+{ "POLL", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PRIORITIZED_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_PRIORITIZED_IO },
+{ "PRIORITY_SCHEDULING", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_PRIORITY_SCHEDULING },
+{ "PRIO_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_PRIO_IO },
+{ "PROC_RSRC_MGR", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTHREAD_DESTRUCTOR_ITERATIONS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTHREAD_KEYS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTHREAD_STACK_MIN", { 4096, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_LIMIT|CONF_LIMIT_DEF, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTHREAD_THREADS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTRDIFF_MAX", { 2147483647, 0 }, { 65535, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "PTRDIFF_MIN", { -2147483648, 0 }, { -65535, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "RAW_SOCKETS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_RAW_SOCKETS },
+{ "READER_WRITER_LOCKS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_READER_WRITER_LOCKS },
+{ "REALTIME", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, -1 },
+{ "REALTIME_SIGNALS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_REALTIME_SIGNALS },
+{ "REALTIME_THREADS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, -1 },
+{ "REC_INCR_XFER_SIZE", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_REC_INCR_XFER_SIZE },
+{ "REC_MAX_XFER_SIZE", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_REC_MAX_XFER_SIZE },
+{ "REC_MIN_XFER_SIZE", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_REC_MIN_XFER_SIZE },
+{ "REC_XFER_ALIGN", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_REC_XFER_ALIGN },
+{ "REENTRANT_FUNCTIONS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "REGEXP", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_REGEXP },
+{ "REGEX_VERSION", { 0, 0 }, { 20030916, 0 }, CONF_FEATURE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "RELEASE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "RESOURCE_LIMITS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "RE_DUP_MAX", { 0, 0 }, { _POSIX2_RE_DUP_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_RE_DUP_MAX },
+{ "RTSIG_MAX", { 0, 0 }, { _POSIX_RTSIG_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_RTSIG_MAX },
+{ "SAVED_IDS", { 0, 0 }, { 1, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SAVED_IDS },
+{ "SCHAR_MAX", { 127, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SCHAR_MIN", { -128, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SECURITY_CLASS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SELECT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "SEMAPHORES", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SEMAPHORES },
+{ "SEM_NSEMS_MAX", { 0, 0 }, { _POSIX_SEM_NSEMS_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_SEM_NSEMS_MAX },
+{ "SEM_VALUE_MAX", { 0, 0 }, { _POSIX_SEM_VALUE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_SEM_VALUE_MAX },
+{ "SH", { 0, 0 }, { 0, "/bin/sh" }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING|CONF_MINMAX_DEF, CONF_AST, 1, CONF_confstr, -1 },
+{ "SHARED_MEMORY_OBJECTS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SHARED_MEMORY_OBJECTS },
+{ "SHELL", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SHELL },
+{ "SHM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_SHM },
+{ "SHRT_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "SHRT_MIN", { -32768, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SIGQUEUE_MAX", { 0, 0 }, { _POSIX_SIGQUEUE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_SIGQUEUE_MAX },
+{ "SIGRT_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, _SC_SIGRT_MAX },
+{ "SIGRT_MIN", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, _SC_SIGRT_MIN },
+{ "SIG_ATOMIC_MAX", { 2147483647, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SIG_ATOMIC_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SIZE_MAX", { UINT_MAX, 0 }, { 65535, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SLVM_MAXNODES", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SOCK_MAXBUF", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SOFTPOWER", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SPAWN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SPAWN },
+{ "SPIN_LOCKS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SPIN_LOCKS },
+{ "SPORADIC_SERVER", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SPORADIC_SERVER },
+{ "SRPC_DOMAIN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SSIZE_MAX", { INT_MAX, 0 }, { _POSIX_SSIZE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SS_REPL_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SS_REPL_MAX },
+{ "STD_BLK", { 0, 0 }, { 1024, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "STREAMS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_STREAMS },
+{ "STREAM_MAX", { 0, 0 }, { _POSIX_STREAM_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_STREAM_MAX },
+{ "SW_DEV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_SW_DEV },
+{ "SYMLINKS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_pathconf, _PC_2_SYMLINKS },
+{ "SYMLINK_MAX", { 0, 0 }, { _POSIX_SYMLINK_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_SYMLINK_MAX },
+{ "SYMLOOP_MAX", { 0, 0 }, { _POSIX_SYMLOOP_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_SYMLOOP_MAX },
+{ "SYNCHRONIZED_IO", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SYNCHRONIZED_IO },
+{ "SYNC_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_SYNC_IO },
+{ "SYSNAME", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "SYSPID_MAX", { 0, 0 }, { 2, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "THREADS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREADS },
+{ "THREADS_PRIO_CEILING", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "THREADS_PRIO_INHERIT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "THREAD_ATTR_STACKADDR", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_ATTR_STACKADDR },
+{ "THREAD_ATTR_STACKSIZE", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_ATTR_STACKSIZE },
+{ "THREAD_CPUTIME", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_CPUTIME },
+{ "THREAD_DESTRUCTOR_ITERATIONS", { 0, 0 }, { _POSIX_THREAD_DESTRUCTOR_ITERATIONS, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_PREFIX_ONLY|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_DESTRUCTOR_ITERATIONS },
+{ "THREAD_KEYS_MAX", { 0, 0 }, { _POSIX_THREAD_KEYS_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_PREFIX_ONLY|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_KEYS_MAX },
+{ "THREAD_PRIORITY_SCHEDULING", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_PRIORITY_SCHEDULING },
+{ "THREAD_PRIO_INHERIT", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_PRIO_INHERIT },
+{ "THREAD_PRIO_PROTECT", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_PRIO_PROTECT },
+{ "THREAD_PROCESS_SHARED", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_PROCESS_SHARED },
+{ "THREAD_SAFE_FUNCTIONS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_SAFE_FUNCTIONS },
+{ "THREAD_SPORADIC_SERVER", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_SPORADIC_SERVER },
+{ "THREAD_STACK_MIN", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_STACK_MIN },
+{ "THREAD_THREADS_MAX", { 0, 0 }, { _POSIX_THREAD_THREADS_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_PREFIX_ONLY|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_THREADS_MAX },
+{ "TIMEOUTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TIMEOUTS },
+{ "TIMERS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TIMERS },
+{ "TIMER_MAX", { 0, 0 }, { _POSIX_TIMER_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_TIMER_MAX },
+{ "TMP", { 0, 0 }, { 0, "/tmp" }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING|CONF_MINMAX_DEF, CONF_AST, 1, CONF_confstr, -1 },
+{ "TMP_MAX", { 17576, 0 }, { 10000, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_C, 1, CONF_sysconf, -1 },
+{ "TRACE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE },
+{ "TRACE_EVENT_FILTER", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_EVENT_FILTER },
+{ "TRACE_EVENT_NAME_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_EVENT_NAME_MAX },
+{ "TRACE_INHERIT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_INHERIT },
+{ "TRACE_LOG", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_LOG },
+{ "TRACE_NAME_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_NAME_MAX },
+{ "TRACE_SYS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_SYS_MAX },
+{ "TRACE_USER_EVENT_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_USER_EVENT_MAX },
+{ "TTY_NAME_MAX", { 0, 0 }, { _POSIX_TTY_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_TTY_NAME_MAX },
+{ "TYPED_MEMORY_OBJECTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TYPED_MEMORY_OBJECTS },
+{ "TZNAME_MAX", { 0, 0 }, { _POSIX_TZNAME_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_TZNAME_MAX },
+{ "T_IOV_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_C, 1, CONF_sysconf, _SC_T_IOV_MAX },
+{ "UCHAR_MAX", { 255, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "UCHAR_MIN", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "UID_MAX", { 0, 0 }, { 60002, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "UINT_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "UIO_MAXIOV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ULLONG_MAX", { 18446744073709551615ULL, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "ULONG_MAX", { 4294967295, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "UNIX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_UNIX },
+{ "UPE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_UPE },
+{ "USER_LIMIT", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "USHRT_MAX", { 65535, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "V6_ILP32_OFF32", { 0, 0 }, { 0, 0 }, CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_V6_ILP32_OFF32 },
+{ "V6_ILP32_OFFBIG", { 0, 0 }, { 0, 0 }, CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_V6_ILP32_OFFBIG },
+{ "V6_LP64_OFF64", { 0, 0 }, { 0, 0 }, CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_V6_LP64_OFF64 },
+{ "V6_LPBIG_OFFBIG", { 0, 0 }, { 0, 0 }, CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_V6_LPBIG_OFFBIG },
+{ "VDISABLE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_VDISABLE },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_PREFIXED|CONF_STANDARD|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "VERSION", { 0, 0 }, { 200112, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "VERSION", { 0, 0 }, { 200112, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 2, CONF_sysconf, -1 },
+{ "VERSION", { 0, 0 }, { 600, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_VERSION },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_XPG, 3, CONF_sysconf, -1 },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_XPG, 4, CONF_sysconf, -1 },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_PREFIXED|CONF_STANDARD, CONF_AST, 1, CONF_nop, -1 },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_PREFIXED|CONF_STANDARD, CONF_GNU, 1, CONF_nop, -1 },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_PREFIXED|CONF_STANDARD, CONF_TRUSTEDBSD, 1, CONF_nop, -1 },
+{ "VERSION_88", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_LIMIT|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "VERSION_88", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "VERSION_90", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_LIMIT|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "VERSION_90", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "VERSION_93", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_LIMIT|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "VERSION_93", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "WCHAR_MAX", { 2147483647, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "WCHAR_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "WINT_MAX", { 2147483647, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "WINT_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "WORD_BIT", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "XCU_VERSION", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_XCU_VERSION },
+{ "XPG2", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "XPG3", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "XPG4", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_nop, -1 },
+};
+
+int conf_elements = (int)sizeof(conf) / (int)sizeof(conf[0]);
diff --git a/usr/src/lib/libast/i386/src/lib/libast/conftab.h b/usr/src/lib/libast/i386/src/lib/libast/conftab.h
new file mode 100644
index 0000000000..24843afa7d
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/conftab.h
@@ -0,0 +1,154 @@
+
+/* : : generated by proto : : */
+
+
+#ifndef _CONFTAB_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _CONFTAB_H
+
+#if !defined(SYS_NMLEN)
+#define SYS_NMLEN 9
+#endif
+#include <sys/systeminfo.h>
+
+/* : : generated by conf from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/comp/conf.tab : : */
+
+#define conf _ast_conf_data
+#define conf_elements _ast_conf_ndata
+
+#define prefix _ast_conf_prefix
+#define prefix_elements _ast_conf_nprefix
+
+#define CONF_nop 0
+#define CONF_confstr 1
+#define CONF_pathconf 2
+#define CONF_sysconf 3
+#define CONF_sysinfo 4
+
+#define CONF_C 0
+#define CONF_POSIX 1
+#define CONF_SVID 2
+#define CONF_XOPEN 3
+#define CONF_SUN 4
+#define CONF_XBS5 5
+#define CONF_SCO 6
+#define CONF_AST 7
+#define CONF_AES 8
+#define CONF_XPG 9
+#define CONF_GNU 10
+#define CONF_TRUSTEDBSD 11
+#define CONF_call 12
+
+#define _pth_getconf "/usr/bin/getconf"
+#define _pth_getconf_a "-a"
+
+#define CONF_DEFER_CALL 0x0001
+#define CONF_DEFER_MM 0x0002
+#define CONF_FEATURE 0x0004
+#define CONF_LIMIT 0x0008
+#define CONF_LIMIT_DEF 0x0010
+#define CONF_MINMAX 0x0020
+#define CONF_MINMAX_DEF 0x0040
+#define CONF_NOSECTION 0x0080
+#define CONF_NOUNDERSCORE 0x0100
+#define CONF_PREFIX_ONLY 0x0200
+#define CONF_PREFIXED 0x0400
+#define CONF_STANDARD 0x0800
+#define CONF_STRING 0x1000
+#define CONF_UNDERSCORE 0x2000
+#define CONF_USER 0x4000
+
+struct Conf_s; typedef struct Conf_s Conf_t;
+
+typedef int (*Conf_f) __PROTO__((Conf_t*, intmax_t*, char**));
+
+typedef struct Value_s
+{
+ intmax_t number;
+ const char* string;
+} Value_t;
+
+struct Conf_s
+{
+ const char name[32];
+ Value_t limit;
+ Value_t minmax;
+ short flags;
+ short standard;
+ short section;
+ short call;
+ short op;
+};
+
+typedef struct Prefix_s
+{
+ const char name[16];
+ short length;
+ short standard;
+ short call;
+} Prefix_t;
+
+extern __MANGLE__ const Conf_t conf[];
+extern __MANGLE__ int conf_elements;
+
+extern __MANGLE__ const Prefix_t prefix[];
+extern __MANGLE__ int prefix_elements;
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/lc.h b/usr/src/lib/libast/i386/src/lib/libast/lc.h
new file mode 100644
index 0000000000..fdd804f36e
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/lc.h
@@ -0,0 +1,158 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated by ./lcgen : : */
+
+
+#ifndef _LC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _LC_H 1
+
+#include <ast.h>
+
+#define LC_abbreviated 0x00001
+#define LC_checked 0x00002
+#define LC_default 0x00004
+#define LC_defined 0x00008
+#define LC_debug 0x00010
+#define LC_local 0x00020
+#define LC_primary 0x00040
+#define LC_qualified 0x00080
+#define LC_undefined 0x00100
+#define LC_verbose 0x00200
+#define LC_user 0x10000
+#define LC_language_attribute_max 2
+#define LC_territory_language_max 4
+
+struct Lc_s;
+
+typedef struct Lc_info_s
+{
+ const struct Lc_s* lc;
+ unsigned long number;
+ __V_* data;
+} Lc_info_t;
+
+typedef struct Lc_attribute_s
+{
+ const char* name;
+ unsigned long flags;
+ unsigned long index;
+} Lc_attribute_t;
+
+typedef struct Lc_charset_s
+{
+ const char* code;
+ const char* alternates;
+ const char* ms;
+ unsigned long index;
+} Lc_charset_t;
+
+typedef struct Lc_language_s
+{
+ const char* code;
+ const char* name;
+ const char* alternates;
+ const Lc_charset_t* charset;
+ unsigned long flags;
+ unsigned long index;
+ const Lc_attribute_t* attributes[LC_language_attribute_max];
+} Lc_language_t;
+
+typedef struct Lc_territory_s
+{
+ const char* code;
+ const char* name;
+ unsigned long flags;
+ unsigned long index;
+ const Lc_language_t* languages[LC_territory_language_max];
+#ifdef _LC_TERRITORY_PRIVATE_
+ _LC_TERRITORY_PRIVATE_
+#endif
+} Lc_territory_t;
+
+typedef struct Lc_map_s
+{
+ const char* code;
+ const Lc_language_t* language;
+ const Lc_territory_t* territory;
+ const Lc_charset_t* charset;
+ const Lc_attribute_t* attribute;
+} Lc_map_t;
+
+typedef struct Lc_attribute_list_s
+{
+ struct Lc_attribute_list_s* next;
+ const Lc_attribute_t* attribute;
+} Lc_attribute_list_t;
+
+typedef struct Lc_s
+{
+ const char* name;
+ const char* code;
+ const Lc_language_t* language;
+ const Lc_territory_t* territory;
+ const Lc_charset_t* charset;
+ const Lc_attribute_list_t* attributes;
+ unsigned long flags;
+ unsigned long index;
+#ifdef _LC_PRIVATE_
+ _LC_PRIVATE_
+#endif
+} Lc_t;
+
+struct Lc_category_s;
+
+typedef int (*Lc_category_set_f) __PROTO__((struct Lc_category_s*));
+
+typedef struct Lc_category_s
+{
+ const char* name;
+ int external;
+ int internal;
+ Lc_category_set_f setf;
+ Lc_t* prev;
+} Lc_category_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ size_t lccanon __PROTO__((Lc_t*, unsigned long flags, char*, size_t));
+extern __MANGLE__ Lc_category_t* lccategories __PROTO__((void));
+extern __MANGLE__ int lcindex __PROTO__((int, int));
+extern __MANGLE__ Lc_info_t* lcinfo __PROTO__((int));
+extern __MANGLE__ Lc_t* lcmake __PROTO__((const char*));
+extern __MANGLE__ Lc_t* lcscan __PROTO__((Lc_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/lctab.h b/usr/src/lib/libast/i386/src/lib/libast/lctab.h
new file mode 100644
index 0000000000..6abbd72c65
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/lctab.h
@@ -0,0 +1,2630 @@
+/* : : generated by ./lcgen : : */
+
+static Lc_attribute_t attribute_es[] =
+{
+{"traditional",LC_default,
+#ifdef SUBLANG_SPANISH_TRADITIONAL
+SUBLANG_SPANISH_TRADITIONAL,
+#else
+0,
+#endif
+
+},
+{"modern",0,
+#ifdef SUBLANG_SPANISH_MODERN
+SUBLANG_SPANISH_MODERN,
+#else
+0,
+#endif
+
+},
+};
+
+static const Lc_charset_t charset[] =
+{
+{"iso8859-1","latin1|west-europe","1252",},
+{"iso8859-2","latin2|east-europe","1250",},
+{"iso8859-3","latin3|south-europe","1257",},
+{"iso8859-4","latin4|north-europe",0},
+{"iso8859-5","cyrillic","1251",},
+{"iso8859-6","arabic","1256",},
+{"iso8859-7","greek","1253",},
+{"iso8859-8","hebrew","1255",},
+{"iso8859-9","latin5|turkish","1254",},
+{"iso8859-10","latin6|nordic",0},
+{"iso8859-13","latin7",0},
+{"iso8859-14","latin8|celtic",0},
+{"iso8859-15","latin0",0},
+{"iso2022","japanese|korean",0},
+{"iso4873","japanese-ascii|korean-ascii",0},
+{"koi8-r","russian",0},
+{"utf8","plan9",0},
+ 0
+};
+
+static const Lc_language_t language[] =
+{
+{"C","C","POSIX",&charset[0],LC_default,0,0,0,},
+{"debug","debug",0,&charset[0],LC_debug,0,0,0,},
+{"aa","afar",0,&charset[0],0,
+#ifdef LANG_AFAR
+LANG_AFAR,
+#else
+0,
+#endif
+0,0,
+},
+{"ab","abkhazian",0,&charset[0],0,
+#ifdef LANG_ABKHAZIAN
+LANG_ABKHAZIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"af","afrikaans","afr",&charset[0],0,
+#ifdef LANG_AFRIKAANS
+LANG_AFRIKAANS,
+#else
+0,
+#endif
+0,0,
+},
+{"am","amharic",0,&charset[0],0,
+#ifdef LANG_AMHARIC
+LANG_AMHARIC,
+#else
+0,
+#endif
+0,0,
+},
+{"ar","arabic","ara",&charset[5],0,
+#ifdef LANG_ARABIC
+LANG_ARABIC,
+#else
+0,
+#endif
+0,0,
+},
+{"as","assamese",0,&charset[0],0,
+#ifdef LANG_ASSAMESE
+LANG_ASSAMESE,
+#else
+0,
+#endif
+0,0,
+},
+{"ay","aymara",0,&charset[0],0,
+#ifdef LANG_AYMARA
+LANG_AYMARA,
+#else
+0,
+#endif
+0,0,
+},
+{"az","azerbaijani",0,&charset[0],0,
+#ifdef LANG_AZERBAIJANI
+LANG_AZERBAIJANI,
+#else
+0,
+#endif
+0,0,
+},
+{"ba","bashkir",0,&charset[0],0,
+#ifdef LANG_BASHKIR
+LANG_BASHKIR,
+#else
+0,
+#endif
+0,0,
+},
+{"be","belarusian","bel",&charset[0],0,
+#ifdef LANG_BELARUSIAN
+LANG_BELARUSIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"bg","bulgarian","bul",&charset[4],0,
+#ifdef LANG_BULGARIAN
+LANG_BULGARIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"bh","bihari",0,&charset[0],0,
+#ifdef LANG_BIHARI
+LANG_BIHARI,
+#else
+0,
+#endif
+0,0,
+},
+{"bi","bislama",0,&charset[0],0,
+#ifdef LANG_BISLAMA
+LANG_BISLAMA,
+#else
+0,
+#endif
+0,0,
+},
+{"bn","bengali-bangla",0,&charset[0],0,
+#ifdef LANG_BENGALI_BANGLA
+LANG_BENGALI_BANGLA,
+#else
+0,
+#endif
+0,0,
+},
+{"bo","tibetan",0,&charset[0],0,
+#ifdef LANG_TIBETAN
+LANG_TIBETAN,
+#else
+0,
+#endif
+0,0,
+},
+{"br","breton",0,&charset[0],0,
+#ifdef LANG_BRETON
+LANG_BRETON,
+#else
+0,
+#endif
+0,0,
+},
+{"ca","catalan","cat",&charset[0],0,
+#ifdef LANG_CATALAN
+LANG_CATALAN,
+#else
+0,
+#endif
+0,0,
+},
+{"co","corsican",0,&charset[0],0,
+#ifdef LANG_CORSICAN
+LANG_CORSICAN,
+#else
+0,
+#endif
+0,0,
+},
+{"cs","czech","ces|cze",&charset[1],0,
+#ifdef LANG_CZECH
+LANG_CZECH,
+#else
+0,
+#endif
+0,0,
+},
+{"cy","welsh",0,&charset[0],0,
+#ifdef LANG_WELSH
+LANG_WELSH,
+#else
+0,
+#endif
+0,0,
+},
+{"da","danish","dan",&charset[0],0,
+#ifdef LANG_DANISH
+LANG_DANISH,
+#else
+0,
+#endif
+0,0,
+},
+{"de","german","deu|ger",&charset[0],0,
+#ifdef LANG_GERMAN
+LANG_GERMAN,
+#else
+0,
+#endif
+0,0,
+},
+{"dz","bhutani",0,&charset[0],0,
+#ifdef LANG_BHUTANI
+LANG_BHUTANI,
+#else
+0,
+#endif
+0,0,
+},
+{"el","greek","ell|gre",&charset[6],0,
+#ifdef LANG_GREEK
+LANG_GREEK,
+#else
+0,
+#endif
+0,0,
+},
+{"en","english","eng",&charset[0],0,
+#ifdef LANG_ENGLISH
+LANG_ENGLISH,
+#else
+0,
+#endif
+0,0,
+},
+{"eo","esperanto",0,&charset[0],0,
+#ifdef LANG_ESPERANTO
+LANG_ESPERANTO,
+#else
+0,
+#endif
+0,0,
+},
+{"es","spanish","spa",&charset[0],0,
+#ifdef LANG_SPANISH
+LANG_SPANISH,
+#else
+0,
+#endif
+&attribute_es[0],&attribute_es[1],
+},
+{"et","estonian","est",&charset[2],0,
+#ifdef LANG_ESTONIAN
+LANG_ESTONIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"eu","basque","eus|baq",&charset[0],0,
+#ifdef LANG_BASQUE
+LANG_BASQUE,
+#else
+0,
+#endif
+0,0,
+},
+{"fa","persian",0,&charset[0],0,
+#ifdef LANG_PERSIAN
+LANG_PERSIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"fi","finnish","fin",&charset[0],0,
+#ifdef LANG_FINNISH
+LANG_FINNISH,
+#else
+0,
+#endif
+0,0,
+},
+{"fj","fiji",0,&charset[0],0,
+#ifdef LANG_FIJI
+LANG_FIJI,
+#else
+0,
+#endif
+0,0,
+},
+{"fo","faeroese",0,&charset[0],0,
+#ifdef LANG_FAEROESE
+LANG_FAEROESE,
+#else
+0,
+#endif
+0,0,
+},
+{"fr","french","fra|fre",&charset[0],0,
+#ifdef LANG_FRENCH
+LANG_FRENCH,
+#else
+0,
+#endif
+0,0,
+},
+{"fy","frisian",0,&charset[0],0,
+#ifdef LANG_FRISIAN
+LANG_FRISIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ga","irish",0,&charset[11],0,
+#ifdef LANG_IRISH
+LANG_IRISH,
+#else
+0,
+#endif
+0,0,
+},
+{"gd","scots-gaelic",0,&charset[11],0,
+#ifdef LANG_SCOTS_GAELIC
+LANG_SCOTS_GAELIC,
+#else
+0,
+#endif
+0,0,
+},
+{"gl","galician",0,&charset[0],0,
+#ifdef LANG_GALICIAN
+LANG_GALICIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"gn","guarani",0,&charset[0],0,
+#ifdef LANG_GUARANI
+LANG_GUARANI,
+#else
+0,
+#endif
+0,0,
+},
+{"gu","gujarati",0,&charset[0],0,
+#ifdef LANG_GUJARATI
+LANG_GUJARATI,
+#else
+0,
+#endif
+0,0,
+},
+{"ha","hausa",0,&charset[0],0,
+#ifdef LANG_HAUSA
+LANG_HAUSA,
+#else
+0,
+#endif
+0,0,
+},
+{"he","hebrew","heb",&charset[7],0,
+#ifdef LANG_HEBREW
+LANG_HEBREW,
+#else
+0,
+#endif
+0,0,
+},
+{"hi","hindi",0,&charset[0],0,
+#ifdef LANG_HINDI
+LANG_HINDI,
+#else
+0,
+#endif
+0,0,
+},
+{"hr","croatian","hrv|scr",&charset[1],0,
+#ifdef LANG_CROATIAN
+LANG_CROATIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"hu","hungarian","hun",&charset[1],0,
+#ifdef LANG_HUNGARIAN
+LANG_HUNGARIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"hy","armenian",0,&charset[0],0,
+#ifdef LANG_ARMENIAN
+LANG_ARMENIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ia","interlingua",0,&charset[0],0,
+#ifdef LANG_INTERLINGUA
+LANG_INTERLINGUA,
+#else
+0,
+#endif
+0,0,
+},
+{"id","indonesian","ind",&charset[0],0,
+#ifdef LANG_INDONESIAN
+LANG_INDONESIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ie","interlingue",0,&charset[0],0,
+#ifdef LANG_INTERLINGUE
+LANG_INTERLINGUE,
+#else
+0,
+#endif
+0,0,
+},
+{"ik","inupiak",0,&charset[0],0,
+#ifdef LANG_INUPIAK
+LANG_INUPIAK,
+#else
+0,
+#endif
+0,0,
+},
+{"in","indonesian",0,&charset[0],0,
+#ifdef LANG_INDONESIAN
+LANG_INDONESIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"is","icelandic","isl|ice",&charset[0],0,
+#ifdef LANG_ICELANDIC
+LANG_ICELANDIC,
+#else
+0,
+#endif
+0,0,
+},
+{"it","italian","ita",&charset[0],0,
+#ifdef LANG_ITALIAN
+LANG_ITALIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"iw","hebrew",0,&charset[0],0,
+#ifdef LANG_HEBREW
+LANG_HEBREW,
+#else
+0,
+#endif
+0,0,
+},
+{"ja","japanese","jpn",&charset[0],0,
+#ifdef LANG_JAPANESE
+LANG_JAPANESE,
+#else
+0,
+#endif
+0,0,
+},
+{"ji","yiddish",0,&charset[0],0,
+#ifdef LANG_YIDDISH
+LANG_YIDDISH,
+#else
+0,
+#endif
+0,0,
+},
+{"jw","javanese",0,&charset[0],0,
+#ifdef LANG_JAVANESE
+LANG_JAVANESE,
+#else
+0,
+#endif
+0,0,
+},
+{"ka","georgian",0,&charset[0],0,
+#ifdef LANG_GEORGIAN
+LANG_GEORGIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"kk","kazakh","kaz",&charset[0],0,
+#ifdef LANG_KAZAKH
+LANG_KAZAKH,
+#else
+0,
+#endif
+0,0,
+},
+{"kl","greenlandic",0,&charset[0],0,
+#ifdef LANG_GREENLANDIC
+LANG_GREENLANDIC,
+#else
+0,
+#endif
+0,0,
+},
+{"km","cambodian",0,&charset[0],0,
+#ifdef LANG_CAMBODIAN
+LANG_CAMBODIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"kn","kannada",0,&charset[0],0,
+#ifdef LANG_KANNADA
+LANG_KANNADA,
+#else
+0,
+#endif
+0,0,
+},
+{"ko","korean","kor",&charset[0],0,
+#ifdef LANG_KOREAN
+LANG_KOREAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ks","kashmiri",0,&charset[0],0,
+#ifdef LANG_KASHMIRI
+LANG_KASHMIRI,
+#else
+0,
+#endif
+0,0,
+},
+{"ku","kurdish",0,&charset[0],0,
+#ifdef LANG_KURDISH
+LANG_KURDISH,
+#else
+0,
+#endif
+0,0,
+},
+{"ky","kirghiz",0,&charset[0],0,
+#ifdef LANG_KIRGHIZ
+LANG_KIRGHIZ,
+#else
+0,
+#endif
+0,0,
+},
+{"la","latin",0,&charset[0],0,
+#ifdef LANG_LATIN
+LANG_LATIN,
+#else
+0,
+#endif
+0,0,
+},
+{"ln","lingala",0,&charset[0],0,
+#ifdef LANG_LINGALA
+LANG_LINGALA,
+#else
+0,
+#endif
+0,0,
+},
+{"lo","laothian",0,&charset[0],0,
+#ifdef LANG_LAOTHIAN
+LANG_LAOTHIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"lt","lithuanian","lit",&charset[10],0,
+#ifdef LANG_LITHUANIAN
+LANG_LITHUANIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"lv","latvian","lav",&charset[10],0,
+#ifdef LANG_LATVIAN
+LANG_LATVIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"mg","malagasy",0,&charset[0],0,
+#ifdef LANG_MALAGASY
+LANG_MALAGASY,
+#else
+0,
+#endif
+0,0,
+},
+{"mi","maori",0,&charset[0],0,
+#ifdef LANG_MAORI
+LANG_MAORI,
+#else
+0,
+#endif
+0,0,
+},
+{"mk","macedonian","mkd|mac",&charset[0],0,
+#ifdef LANG_MACEDONIAN
+LANG_MACEDONIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ml","malayalam","mal",&charset[0],0,
+#ifdef LANG_MALAYALAM
+LANG_MALAYALAM,
+#else
+0,
+#endif
+0,0,
+},
+{"mn","mongolian",0,&charset[0],0,
+#ifdef LANG_MONGOLIAN
+LANG_MONGOLIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"mo","moldavian",0,&charset[0],0,
+#ifdef LANG_MOLDAVIAN
+LANG_MOLDAVIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"mr","marathi",0,&charset[0],0,
+#ifdef LANG_MARATHI
+LANG_MARATHI,
+#else
+0,
+#endif
+0,0,
+},
+{"ms","malay","msa|may",&charset[0],0,
+#ifdef LANG_MALAY
+LANG_MALAY,
+#else
+0,
+#endif
+0,0,
+},
+{"mt","maltese",0,&charset[0],0,
+#ifdef LANG_MALTESE
+LANG_MALTESE,
+#else
+0,
+#endif
+0,0,
+},
+{"my","burmese",0,&charset[0],0,
+#ifdef LANG_BURMESE
+LANG_BURMESE,
+#else
+0,
+#endif
+0,0,
+},
+{"na","nauru",0,&charset[0],0,
+#ifdef LANG_NAURU
+LANG_NAURU,
+#else
+0,
+#endif
+0,0,
+},
+{"nb","norwegian-bokmal","nob",&charset[0],0,
+#ifdef LANG_NORWEGIAN_BOKMAL
+LANG_NORWEGIAN_BOKMAL,
+#else
+0,
+#endif
+0,0,
+},
+{"ne","nepali",0,&charset[0],0,
+#ifdef LANG_NEPALI
+LANG_NEPALI,
+#else
+0,
+#endif
+0,0,
+},
+{"nl","dutch","nld|dut",&charset[0],0,
+#ifdef LANG_DUTCH
+LANG_DUTCH,
+#else
+0,
+#endif
+0,0,
+},
+{"nn","norwegian-nynorsk","nno|non",&charset[0],0,
+#ifdef LANG_NORWEGIAN_NYNORSK
+LANG_NORWEGIAN_NYNORSK,
+#else
+0,
+#endif
+0,0,
+},
+{"no","norwegian","nor",&charset[0],0,
+#ifdef LANG_NORWEGIAN
+LANG_NORWEGIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"oc","occitan",0,&charset[0],0,
+#ifdef LANG_OCCITAN
+LANG_OCCITAN,
+#else
+0,
+#endif
+0,0,
+},
+{"om","oromo",0,&charset[0],0,
+#ifdef LANG_OROMO
+LANG_OROMO,
+#else
+0,
+#endif
+0,0,
+},
+{"or","oriya",0,&charset[0],0,
+#ifdef LANG_ORIYA
+LANG_ORIYA,
+#else
+0,
+#endif
+0,0,
+},
+{"pa","punjabi",0,&charset[0],0,
+#ifdef LANG_PUNJABI
+LANG_PUNJABI,
+#else
+0,
+#endif
+0,0,
+},
+{"pl","polish","pol",&charset[1],0,
+#ifdef LANG_POLISH
+LANG_POLISH,
+#else
+0,
+#endif
+0,0,
+},
+{"ps","pushto",0,&charset[0],0,
+#ifdef LANG_PUSHTO
+LANG_PUSHTO,
+#else
+0,
+#endif
+0,0,
+},
+{"pt","portuguese","por",&charset[0],0,
+#ifdef LANG_PORTUGUESE
+LANG_PORTUGUESE,
+#else
+0,
+#endif
+0,0,
+},
+{"qu","quechua",0,&charset[0],0,
+#ifdef LANG_QUECHUA
+LANG_QUECHUA,
+#else
+0,
+#endif
+0,0,
+},
+{"rm","rhaeto-romance",0,&charset[0],0,
+#ifdef LANG_RHAETO_ROMANCE
+LANG_RHAETO_ROMANCE,
+#else
+0,
+#endif
+0,0,
+},
+{"rn","kirundi",0,&charset[0],0,
+#ifdef LANG_KIRUNDI
+LANG_KIRUNDI,
+#else
+0,
+#endif
+0,0,
+},
+{"ro","romanian","ron|rum",&charset[1],0,
+#ifdef LANG_ROMANIAN
+LANG_ROMANIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ru","russian","rus",&charset[4],0,
+#ifdef LANG_RUSSIAN
+LANG_RUSSIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"rw","kinyarwanda",0,&charset[0],0,
+#ifdef LANG_KINYARWANDA
+LANG_KINYARWANDA,
+#else
+0,
+#endif
+0,0,
+},
+{"sa","sanskrit",0,&charset[0],0,
+#ifdef LANG_SANSKRIT
+LANG_SANSKRIT,
+#else
+0,
+#endif
+0,0,
+},
+{"sd","sindhi",0,&charset[0],0,
+#ifdef LANG_SINDHI
+LANG_SINDHI,
+#else
+0,
+#endif
+0,0,
+},
+{"sg","sangro",0,&charset[0],0,
+#ifdef LANG_SANGRO
+LANG_SANGRO,
+#else
+0,
+#endif
+0,0,
+},
+{"sh","serbo-croatian",0,&charset[0],0,
+#ifdef LANG_SERBO_CROATIAN
+LANG_SERBO_CROATIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"si","singhalese",0,&charset[0],0,
+#ifdef LANG_SINGHALESE
+LANG_SINGHALESE,
+#else
+0,
+#endif
+0,0,
+},
+{"sk","slovak","slk|slo",&charset[1],0,
+#ifdef LANG_SLOVAK
+LANG_SLOVAK,
+#else
+0,
+#endif
+0,0,
+},
+{"sl","slovenian","slv",&charset[1],0,
+#ifdef LANG_SLOVENIAN
+LANG_SLOVENIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"sm","samoan",0,&charset[0],0,
+#ifdef LANG_SAMOAN
+LANG_SAMOAN,
+#else
+0,
+#endif
+0,0,
+},
+{"sn","shona",0,&charset[0],0,
+#ifdef LANG_SHONA
+LANG_SHONA,
+#else
+0,
+#endif
+0,0,
+},
+{"so","somali",0,&charset[0],0,
+#ifdef LANG_SOMALI
+LANG_SOMALI,
+#else
+0,
+#endif
+0,0,
+},
+{"sq","albanian","sqi|alb",&charset[0],0,
+#ifdef LANG_ALBANIAN
+LANG_ALBANIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"sr","serbian","srp",&charset[1],0,
+#ifdef LANG_SERBIAN
+LANG_SERBIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ss","siswati",0,&charset[0],0,
+#ifdef LANG_SISWATI
+LANG_SISWATI,
+#else
+0,
+#endif
+0,0,
+},
+{"st","sesotho",0,&charset[0],0,
+#ifdef LANG_SESOTHO
+LANG_SESOTHO,
+#else
+0,
+#endif
+0,0,
+},
+{"su","sudanese",0,&charset[0],0,
+#ifdef LANG_SUDANESE
+LANG_SUDANESE,
+#else
+0,
+#endif
+0,0,
+},
+{"sv","swedish","swe",&charset[0],0,
+#ifdef LANG_SWEDISH
+LANG_SWEDISH,
+#else
+0,
+#endif
+0,0,
+},
+{"sw","swahili","swa",&charset[0],0,
+#ifdef LANG_SWAHILI
+LANG_SWAHILI,
+#else
+0,
+#endif
+0,0,
+},
+{"ta","tamil",0,&charset[0],0,
+#ifdef LANG_TAMIL
+LANG_TAMIL,
+#else
+0,
+#endif
+0,0,
+},
+{"te","telugu",0,&charset[0],0,
+#ifdef LANG_TELUGU
+LANG_TELUGU,
+#else
+0,
+#endif
+0,0,
+},
+{"tg","tajik",0,&charset[0],0,
+#ifdef LANG_TAJIK
+LANG_TAJIK,
+#else
+0,
+#endif
+0,0,
+},
+{"th","thai","tha",&charset[0],0,
+#ifdef LANG_THAI
+LANG_THAI,
+#else
+0,
+#endif
+0,0,
+},
+{"ti","tigrinya",0,&charset[0],0,
+#ifdef LANG_TIGRINYA
+LANG_TIGRINYA,
+#else
+0,
+#endif
+0,0,
+},
+{"tk","turkmen",0,&charset[0],0,
+#ifdef LANG_TURKMEN
+LANG_TURKMEN,
+#else
+0,
+#endif
+0,0,
+},
+{"tl","tagalog",0,&charset[0],0,
+#ifdef LANG_TAGALOG
+LANG_TAGALOG,
+#else
+0,
+#endif
+0,0,
+},
+{"tn","setswana",0,&charset[0],0,
+#ifdef LANG_SETSWANA
+LANG_SETSWANA,
+#else
+0,
+#endif
+0,0,
+},
+{"to","tonga",0,&charset[0],0,
+#ifdef LANG_TONGA
+LANG_TONGA,
+#else
+0,
+#endif
+0,0,
+},
+{"tr","turkish","tur",&charset[8],0,
+#ifdef LANG_TURKISH
+LANG_TURKISH,
+#else
+0,
+#endif
+0,0,
+},
+{"ts","tsonga",0,&charset[0],0,
+#ifdef LANG_TSONGA
+LANG_TSONGA,
+#else
+0,
+#endif
+0,0,
+},
+{"tt","tatar","tat",&charset[0],0,
+#ifdef LANG_TATAR
+LANG_TATAR,
+#else
+0,
+#endif
+0,0,
+},
+{"tw","chinese-traditional","cht",&charset[0],0,
+#ifdef LANG_CHINESE_TRADITIONAL
+LANG_CHINESE_TRADITIONAL,
+#else
+0,
+#endif
+0,0,
+},
+{"uk","ukrainian","ukr",&charset[4],0,
+#ifdef LANG_UKRAINIAN
+LANG_UKRAINIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ur","urdu",0,&charset[0],0,
+#ifdef LANG_URDU
+LANG_URDU,
+#else
+0,
+#endif
+0,0,
+},
+{"uz","uzbek","uzb",&charset[0],0,
+#ifdef LANG_UZBEK
+LANG_UZBEK,
+#else
+0,
+#endif
+0,0,
+},
+{"vi","vietnamese",0,&charset[0],0,
+#ifdef LANG_VIETNAMESE
+LANG_VIETNAMESE,
+#else
+0,
+#endif
+0,0,
+},
+{"vo","volapuk",0,&charset[0],0,
+#ifdef LANG_VOLAPUK
+LANG_VOLAPUK,
+#else
+0,
+#endif
+0,0,
+},
+{"wo","wolof",0,&charset[0],0,
+#ifdef LANG_WOLOF
+LANG_WOLOF,
+#else
+0,
+#endif
+0,0,
+},
+{"xh","xhosa",0,&charset[0],0,
+#ifdef LANG_XHOSA
+LANG_XHOSA,
+#else
+0,
+#endif
+0,0,
+},
+{"yo","yoruba",0,&charset[0],0,
+#ifdef LANG_YORUBA
+LANG_YORUBA,
+#else
+0,
+#endif
+0,0,
+},
+{"zh","chinese-simplified","zho|chi|chs",&charset[0],0,
+#ifdef LANG_CHINESE_SIMPLIFIED
+LANG_CHINESE_SIMPLIFIED,
+#else
+0,
+#endif
+0,0,
+},
+{"zu","zulu",0,&charset[0],0,
+#ifdef LANG_ZULU
+LANG_ZULU,
+#else
+0,
+#endif
+0,0,
+},
+ 0
+};
+
+static const Lc_territory_t territory[] =
+{
+{"C","C",LC_default,0,&language[0],0,0,0,0,0,0,0,},
+{"debug","debug",LC_debug,0,&language[1],0,0,0,0,0,0,0,},
+{"al","albania",0,
+#ifdef CTRY_ALBANIA
+CTRY_ALBANIA,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"an","netherlands-antilles",0,
+#ifdef CTRY_NETHERLANDS_ANTILLES
+CTRY_NETHERLANDS_ANTILLES,
+#else
+0,
+#endif
+&language[86],0,0,0,
+#ifdef SUBLANG_DUTCH_NETHERLANDS_ANTILLES
+SUBLANG_DUTCH_NETHERLANDS_ANTILLES,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ar","argentina",0,
+#ifdef CTRY_ARGENTINA
+CTRY_ARGENTINA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_ARGENTINA
+SUBLANG_SPANISH_ARGENTINA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"at","austria",0,
+#ifdef CTRY_AUSTRIA
+CTRY_AUSTRIA,
+#else
+0,
+#endif
+&language[23],0,0,0,
+#ifdef SUBLANG_GERMAN_AUSTRIA
+SUBLANG_GERMAN_AUSTRIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"au","australia",0,
+#ifdef CTRY_AUSTRALIA
+CTRY_AUSTRALIA,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_AUSTRALIA
+SUBLANG_ENGLISH_AUSTRALIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"az","azerbaijan",0,
+#ifdef CTRY_AZERBAIJAN
+CTRY_AZERBAIJAN,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"be","belgium",0,
+#ifdef CTRY_BELGIUM
+CTRY_BELGIUM,
+#else
+0,
+#endif
+&language[86],&language[35],&language[23],0,
+#ifdef SUBLANG_DUTCH_BELGIUM
+SUBLANG_DUTCH_BELGIUM,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_FRENCH_BELGIUM
+SUBLANG_FRENCH_BELGIUM,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_GERMAN_BELGIUM
+SUBLANG_GERMAN_BELGIUM,
+#else
+0,
+#endif
+0,
+},
+{"bg","bulgaria",0,
+#ifdef CTRY_BULGARIA
+CTRY_BULGARIA,
+#else
+0,
+#endif
+&language[12],0,0,0,
+#ifdef SUBLANG_BULGARIAN_BULGARIA
+SUBLANG_BULGARIAN_BULGARIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"bn","brunei-darussalam",0,
+#ifdef CTRY_BRUNEI_DARUSSALAM
+CTRY_BRUNEI_DARUSSALAM,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_BRUNEI_DARUSSALAM
+SUBLANG_ARABIC_BRUNEI_DARUSSALAM,
+#else
+0,
+#endif
+0,0,0,
+},
+{"bo","bolivia",0,
+#ifdef CTRY_BOLIVIA
+CTRY_BOLIVIA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_BOLIVIA
+SUBLANG_SPANISH_BOLIVIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"br","brazil",0,
+#ifdef CTRY_BRAZIL
+CTRY_BRAZIL,
+#else
+0,
+#endif
+&language[95],0,0,0,
+#ifdef SUBLANG_PORTUGUESE_BRAZIL
+SUBLANG_PORTUGUESE_BRAZIL,
+#else
+0,
+#endif
+0,0,0,
+},
+{"bw","botswana",0,
+#ifdef CTRY_BOTSWANA
+CTRY_BOTSWANA,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_BOTSWANA
+SUBLANG_ENGLISH_BOTSWANA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"by","belarus",0,
+#ifdef CTRY_BELARUS
+CTRY_BELARUS,
+#else
+0,
+#endif
+&language[100],0,0,0,
+#ifdef SUBLANG_RUSSIAN_BELARUS
+SUBLANG_RUSSIAN_BELARUS,
+#else
+0,
+#endif
+0,0,0,
+},
+{"bz","belize",0,
+#ifdef CTRY_BELIZE
+CTRY_BELIZE,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_BELIZE
+SUBLANG_ENGLISH_BELIZE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ca","canada",0,
+#ifdef CTRY_CANADA
+CTRY_CANADA,
+#else
+0,
+#endif
+&language[26],&language[35],0,0,
+#ifdef SUBLANG_ENGLISH_CANADA
+SUBLANG_ENGLISH_CANADA,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_FRENCH_CANADA
+SUBLANG_FRENCH_CANADA,
+#else
+0,
+#endif
+0,0,
+},
+{"ch","switzerland",0,
+#ifdef CTRY_SWITZERLAND
+CTRY_SWITZERLAND,
+#else
+0,
+#endif
+&language[35],&language[23],&language[54],0,
+#ifdef SUBLANG_FRENCH_SWITZERLAND
+SUBLANG_FRENCH_SWITZERLAND,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_GERMAN_SWITZERLAND
+SUBLANG_GERMAN_SWITZERLAND,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_ITALIAN_SWITZERLAND
+SUBLANG_ITALIAN_SWITZERLAND,
+#else
+0,
+#endif
+0,
+},
+{"cl","chile",0,
+#ifdef CTRY_CHILE
+CTRY_CHILE,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_CHILE
+SUBLANG_SPANISH_CHILE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"cn","china",LC_primary,
+#ifdef CTRY_CHINA
+CTRY_CHINA,
+#else
+0,
+#endif
+&language[140],0,0,0,
+#ifdef SUBLANG_CHINESE_SIMPLIFIED_CHINA
+SUBLANG_CHINESE_SIMPLIFIED_CHINA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"co","colombia",0,
+#ifdef CTRY_COLOMBIA
+CTRY_COLOMBIA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_COLOMBIA
+SUBLANG_SPANISH_COLOMBIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"cr","costa-rica",0,
+#ifdef CTRY_COSTA_RICA
+CTRY_COSTA_RICA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_COSTA_RICA
+SUBLANG_SPANISH_COSTA_RICA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"cz","czech-republic",0,
+#ifdef CTRY_CZECH_REPUBLIC
+CTRY_CZECH_REPUBLIC,
+#else
+0,
+#endif
+&language[20],0,0,0,
+#ifdef SUBLANG_CZECH_CZECH_REPUBLIC
+SUBLANG_CZECH_CZECH_REPUBLIC,
+#else
+0,
+#endif
+0,0,0,
+},
+{"de","germany",0,
+#ifdef CTRY_GERMANY
+CTRY_GERMANY,
+#else
+0,
+#endif
+&language[23],0,0,0,
+#ifdef SUBLANG_GERMAN_GERMANY
+SUBLANG_GERMAN_GERMANY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"dk","denmark",0,
+#ifdef CTRY_DENMARK
+CTRY_DENMARK,
+#else
+0,
+#endif
+&language[22],&language[26],0,0,
+#ifdef SUBLANG_DANISH_DENMARK
+SUBLANG_DANISH_DENMARK,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_ENGLISH_DENMARK
+SUBLANG_ENGLISH_DENMARK,
+#else
+0,
+#endif
+0,0,
+},
+{"do","dominican-republic",0,
+#ifdef CTRY_DOMINICAN_REPUBLIC
+CTRY_DOMINICAN_REPUBLIC,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
+SUBLANG_SPANISH_DOMINICAN_REPUBLIC,
+#else
+0,
+#endif
+0,0,0,
+},
+{"dz","algeria",0,
+#ifdef CTRY_ALGERIA
+CTRY_ALGERIA,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"ec","ecuador",0,
+#ifdef CTRY_ECUADOR
+CTRY_ECUADOR,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_ECUADOR
+SUBLANG_SPANISH_ECUADOR,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ee","estonia",0,
+#ifdef CTRY_ESTONIA
+CTRY_ESTONIA,
+#else
+0,
+#endif
+&language[29],0,0,0,
+#ifdef SUBLANG_ESTONIAN_ESTONIA
+SUBLANG_ESTONIAN_ESTONIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"eg","egypt",0,
+#ifdef CTRY_EGYPT
+CTRY_EGYPT,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_EGYPT
+SUBLANG_ARABIC_EGYPT,
+#else
+0,
+#endif
+0,0,0,
+},
+{"es","spain",0,
+#ifdef CTRY_SPAIN
+CTRY_SPAIN,
+#else
+0,
+#endif
+&language[28],&language[18],&language[30],&language[39],
+#ifdef SUBLANG_SPANISH_SPAIN
+SUBLANG_SPANISH_SPAIN,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_CATALAN_SPAIN
+SUBLANG_CATALAN_SPAIN,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_BASQUE_SPAIN
+SUBLANG_BASQUE_SPAIN,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_GALICIAN_SPAIN
+SUBLANG_GALICIAN_SPAIN,
+#else
+0,
+#endif
+
+},
+{"fi","finland",0,
+#ifdef CTRY_FINLAND
+CTRY_FINLAND,
+#else
+0,
+#endif
+&language[117],0,0,0,
+#ifdef SUBLANG_SWEDISH_FINLAND
+SUBLANG_SWEDISH_FINLAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"fo","faroe-islands",0,
+#ifdef CTRY_FAROE_ISLANDS
+CTRY_FAROE_ISLANDS,
+#else
+0,
+#endif
+&language[34],0,0,0,
+#ifdef SUBLANG_FAEROESE_FAROE_ISLANDS
+SUBLANG_FAEROESE_FAROE_ISLANDS,
+#else
+0,
+#endif
+0,0,0,
+},
+{"fr","france",0,
+#ifdef CTRY_FRANCE
+CTRY_FRANCE,
+#else
+0,
+#endif
+&language[35],0,0,0,
+#ifdef SUBLANG_FRENCH_FRANCE
+SUBLANG_FRENCH_FRANCE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"gb","united-kingdom|great-britain|england",LC_primary,
+#ifdef CTRY_UNITED_KINGDOM
+CTRY_UNITED_KINGDOM,
+#else
+#ifdef CTRY_GREAT_BRITAIN
+CTRY_GREAT_BRITAIN,
+#else
+#ifdef CTRY_ENGLAND
+CTRY_ENGLAND,
+#else
+0,
+#endif
+#endif
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_UNITED_KINGDOM
+SUBLANG_ENGLISH_UNITED_KINGDOM,
+#else
+#ifdef SUBLANG_ENGLISH_GREAT_BRITAIN
+SUBLANG_ENGLISH_GREAT_BRITAIN,
+#else
+#ifdef SUBLANG_ENGLISH_ENGLAND
+SUBLANG_ENGLISH_ENGLAND,
+#else
+0,
+#endif
+#endif
+#endif
+0,0,0,
+},
+{"gl","greenland",0,
+#ifdef CTRY_GREENLAND
+CTRY_GREENLAND,
+#else
+0,
+#endif
+&language[61],0,0,0,
+#ifdef SUBLANG_GREENLANDIC_GREENLAND
+SUBLANG_GREENLANDIC_GREENLAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"gr","greece",0,
+#ifdef CTRY_GREECE
+CTRY_GREECE,
+#else
+0,
+#endif
+&language[25],0,0,0,
+#ifdef SUBLANG_GREEK_GREECE
+SUBLANG_GREEK_GREECE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"gt","guatemala",0,
+#ifdef CTRY_GUATEMALA
+CTRY_GUATEMALA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_GUATEMALA
+SUBLANG_SPANISH_GUATEMALA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"hk","hong-kong",0,
+#ifdef CTRY_HONG_KONG
+CTRY_HONG_KONG,
+#else
+0,
+#endif
+&language[140],0,0,0,
+#ifdef SUBLANG_CHINESE_SIMPLIFIED_HONG_KONG
+SUBLANG_CHINESE_SIMPLIFIED_HONG_KONG,
+#else
+0,
+#endif
+0,0,0,
+},
+{"hn","honduras",0,
+#ifdef CTRY_HONDURAS
+CTRY_HONDURAS,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_HONDURAS
+SUBLANG_SPANISH_HONDURAS,
+#else
+0,
+#endif
+0,0,0,
+},
+{"hr","croatia",0,
+#ifdef CTRY_CROATIA
+CTRY_CROATIA,
+#else
+0,
+#endif
+&language[45],0,0,0,
+#ifdef SUBLANG_CROATIAN_CROATIA
+SUBLANG_CROATIAN_CROATIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"hu","hungary",0,
+#ifdef CTRY_HUNGARY
+CTRY_HUNGARY,
+#else
+0,
+#endif
+&language[46],0,0,0,
+#ifdef SUBLANG_HUNGARIAN_HUNGARY
+SUBLANG_HUNGARIAN_HUNGARY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"id","indonesia",0,
+#ifdef CTRY_INDONESIA
+CTRY_INDONESIA,
+#else
+0,
+#endif
+&language[49],0,0,0,
+#ifdef SUBLANG_INDONESIAN_INDONESIA
+SUBLANG_INDONESIAN_INDONESIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ie","ireland",0,
+#ifdef CTRY_IRELAND
+CTRY_IRELAND,
+#else
+0,
+#endif
+&language[26],&language[37],0,0,
+#ifdef SUBLANG_ENGLISH_IRELAND
+SUBLANG_ENGLISH_IRELAND,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_IRISH_IRELAND
+SUBLANG_IRISH_IRELAND,
+#else
+0,
+#endif
+0,0,
+},
+{"il","israel",0,
+#ifdef CTRY_ISRAEL
+CTRY_ISRAEL,
+#else
+0,
+#endif
+&language[43],0,0,0,
+#ifdef SUBLANG_HEBREW_ISRAEL
+SUBLANG_HEBREW_ISRAEL,
+#else
+0,
+#endif
+0,0,0,
+},
+{"iq","iraq",0,
+#ifdef CTRY_IRAQ
+CTRY_IRAQ,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_IRAQ
+SUBLANG_ARABIC_IRAQ,
+#else
+0,
+#endif
+0,0,0,
+},
+{"is","iceland",0,
+#ifdef CTRY_ICELAND
+CTRY_ICELAND,
+#else
+0,
+#endif
+&language[53],0,0,0,
+#ifdef SUBLANG_ICELANDIC_ICELAND
+SUBLANG_ICELANDIC_ICELAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"it","italy",0,
+#ifdef CTRY_ITALY
+CTRY_ITALY,
+#else
+0,
+#endif
+&language[54],0,0,0,
+#ifdef SUBLANG_ITALIAN_ITALY
+SUBLANG_ITALIAN_ITALY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"jm","jamaica",0,
+#ifdef CTRY_JAMAICA
+CTRY_JAMAICA,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_JAMAICA
+SUBLANG_ENGLISH_JAMAICA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"jo","jordan",0,
+#ifdef CTRY_JORDAN
+CTRY_JORDAN,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_JORDAN
+SUBLANG_ARABIC_JORDAN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"jp","japan",0,
+#ifdef CTRY_JAPAN
+CTRY_JAPAN,
+#else
+0,
+#endif
+&language[56],0,0,0,
+#ifdef SUBLANG_JAPANESE_JAPAN
+SUBLANG_JAPANESE_JAPAN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ke","kenya",0,
+#ifdef CTRY_KENYA
+CTRY_KENYA,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"kr","south-korea",0,
+#ifdef CTRY_SOUTH_KOREA
+CTRY_SOUTH_KOREA,
+#else
+0,
+#endif
+&language[64],0,0,0,
+#ifdef SUBLANG_KOREAN_SOUTH_KOREA
+SUBLANG_KOREAN_SOUTH_KOREA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"kw","kuwait",0,
+#ifdef CTRY_KUWAIT
+CTRY_KUWAIT,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_KUWAIT
+SUBLANG_ARABIC_KUWAIT,
+#else
+0,
+#endif
+0,0,0,
+},
+{"lb","lebanon",0,
+#ifdef CTRY_LEBANON
+CTRY_LEBANON,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_LEBANON
+SUBLANG_ARABIC_LEBANON,
+#else
+0,
+#endif
+0,0,0,
+},
+{"li","liechtenstein",0,
+#ifdef CTRY_LIECHTENSTEIN
+CTRY_LIECHTENSTEIN,
+#else
+0,
+#endif
+&language[23],&language[35],0,0,
+#ifdef SUBLANG_GERMAN_LIECHTENSTEIN
+SUBLANG_GERMAN_LIECHTENSTEIN,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_FRENCH_LIECHTENSTEIN
+SUBLANG_FRENCH_LIECHTENSTEIN,
+#else
+0,
+#endif
+0,0,
+},
+{"lt","lithuania",0,
+#ifdef CTRY_LITHUANIA
+CTRY_LITHUANIA,
+#else
+0,
+#endif
+&language[71],0,0,0,
+#ifdef SUBLANG_LITHUANIAN_LITHUANIA
+SUBLANG_LITHUANIAN_LITHUANIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"lu","luxembourg",0,
+#ifdef CTRY_LUXEMBOURG
+CTRY_LUXEMBOURG,
+#else
+0,
+#endif
+&language[23],&language[35],0,0,
+#ifdef SUBLANG_GERMAN_LUXEMBOURG
+SUBLANG_GERMAN_LUXEMBOURG,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_FRENCH_LUXEMBOURG
+SUBLANG_FRENCH_LUXEMBOURG,
+#else
+0,
+#endif
+0,0,
+},
+{"lv","latvia",0,
+#ifdef CTRY_LATVIA
+CTRY_LATVIA,
+#else
+0,
+#endif
+&language[72],0,0,0,
+#ifdef SUBLANG_LATVIAN_LATVIA
+SUBLANG_LATVIAN_LATVIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ly","libya",0,
+#ifdef CTRY_LIBYA
+CTRY_LIBYA,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_LIBYA
+SUBLANG_ARABIC_LIBYA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ma","morocco",0,
+#ifdef CTRY_MOROCCO
+CTRY_MOROCCO,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_MOROCCO
+SUBLANG_ARABIC_MOROCCO,
+#else
+0,
+#endif
+0,0,0,
+},
+{"mk","macedonia",0,
+#ifdef CTRY_MACEDONIA
+CTRY_MACEDONIA,
+#else
+0,
+#endif
+&language[75],0,0,0,
+#ifdef SUBLANG_MACEDONIAN_MACEDONIA
+SUBLANG_MACEDONIAN_MACEDONIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"mo","macau",0,
+#ifdef CTRY_MACAU
+CTRY_MACAU,
+#else
+0,
+#endif
+&language[140],0,0,0,
+#ifdef SUBLANG_CHINESE_SIMPLIFIED_MACAU
+SUBLANG_CHINESE_SIMPLIFIED_MACAU,
+#else
+0,
+#endif
+0,0,0,
+},
+{"mx","mexico",0,
+#ifdef CTRY_MEXICO
+CTRY_MEXICO,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_MEXICO
+SUBLANG_SPANISH_MEXICO,
+#else
+0,
+#endif
+0,0,0,
+},
+{"my","malaysia",0,
+#ifdef CTRY_MALAYSIA
+CTRY_MALAYSIA,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"ni","nicaragua",0,
+#ifdef CTRY_NICARAGUA
+CTRY_NICARAGUA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_NICARAGUA
+SUBLANG_SPANISH_NICARAGUA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"nl","netherlands",0,
+#ifdef CTRY_NETHERLANDS
+CTRY_NETHERLANDS,
+#else
+0,
+#endif
+&language[86],0,0,0,
+#ifdef SUBLANG_DUTCH_NETHERLANDS
+SUBLANG_DUTCH_NETHERLANDS,
+#else
+0,
+#endif
+0,0,0,
+},
+{"no","norway",0,
+#ifdef CTRY_NORWAY
+CTRY_NORWAY,
+#else
+0,
+#endif
+&language[84],&language[88],&language[87],0,
+#ifdef SUBLANG_NORWEGIAN_BOKMAL_NORWAY
+SUBLANG_NORWEGIAN_BOKMAL_NORWAY,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_NORWEGIAN_NORWAY
+SUBLANG_NORWEGIAN_NORWAY,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_NORWEGIAN_NYNORSK_NORWAY
+SUBLANG_NORWEGIAN_NYNORSK_NORWAY,
+#else
+0,
+#endif
+0,
+},
+{"nz","new-zealand",0,
+#ifdef CTRY_NEW_ZEALAND
+CTRY_NEW_ZEALAND,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_NEW_ZEALAND
+SUBLANG_ENGLISH_NEW_ZEALAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"om","oman",0,
+#ifdef CTRY_OMAN
+CTRY_OMAN,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_OMAN
+SUBLANG_ARABIC_OMAN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pa","panama",0,
+#ifdef CTRY_PANAMA
+CTRY_PANAMA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_PANAMA
+SUBLANG_SPANISH_PANAMA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pe","peru",0,
+#ifdef CTRY_PERU
+CTRY_PERU,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_PERU
+SUBLANG_SPANISH_PERU,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pl","poland",0,
+#ifdef CTRY_POLAND
+CTRY_POLAND,
+#else
+0,
+#endif
+&language[93],0,0,0,
+#ifdef SUBLANG_POLISH_POLAND
+SUBLANG_POLISH_POLAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pr","puerto-rico",0,
+#ifdef CTRY_PUERTO_RICO
+CTRY_PUERTO_RICO,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_PUERTO_RICO
+SUBLANG_SPANISH_PUERTO_RICO,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pt","portugal",0,
+#ifdef CTRY_PORTUGAL
+CTRY_PORTUGAL,
+#else
+0,
+#endif
+&language[95],0,0,0,
+#ifdef SUBLANG_PORTUGUESE_PORTUGAL
+SUBLANG_PORTUGUESE_PORTUGAL,
+#else
+0,
+#endif
+0,0,0,
+},
+{"py","paraguay",0,
+#ifdef CTRY_PARAGUAY
+CTRY_PARAGUAY,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_PARAGUAY
+SUBLANG_SPANISH_PARAGUAY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ro","romania",0,
+#ifdef CTRY_ROMANIA
+CTRY_ROMANIA,
+#else
+0,
+#endif
+&language[99],0,0,0,
+#ifdef SUBLANG_ROMANIAN_ROMANIA
+SUBLANG_ROMANIAN_ROMANIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ru","russia",0,
+#ifdef CTRY_RUSSIA
+CTRY_RUSSIA,
+#else
+0,
+#endif
+&language[100],0,0,0,
+#ifdef SUBLANG_RUSSIAN_RUSSIA
+SUBLANG_RUSSIAN_RUSSIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sa","saudi-arabia",0,
+#ifdef CTRY_SAUDI_ARABIA
+CTRY_SAUDI_ARABIA,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_SAUDI_ARABIA
+SUBLANG_ARABIC_SAUDI_ARABIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"se","sweden",LC_primary,
+#ifdef CTRY_SWEDEN
+CTRY_SWEDEN,
+#else
+0,
+#endif
+&language[117],0,0,0,
+#ifdef SUBLANG_SWEDISH_SWEDEN
+SUBLANG_SWEDISH_SWEDEN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sg","singapore",0,
+#ifdef CTRY_SINGAPORE
+CTRY_SINGAPORE,
+#else
+0,
+#endif
+&language[140],0,0,0,
+#ifdef SUBLANG_CHINESE_SIMPLIFIED_SINGAPORE
+SUBLANG_CHINESE_SIMPLIFIED_SINGAPORE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"si","slovenia",0,
+#ifdef CTRY_SLOVENIA
+CTRY_SLOVENIA,
+#else
+0,
+#endif
+&language[108],0,0,0,
+#ifdef SUBLANG_SLOVENIAN_SLOVENIA
+SUBLANG_SLOVENIAN_SLOVENIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sk","slovakia",0,
+#ifdef CTRY_SLOVAKIA
+CTRY_SLOVAKIA,
+#else
+0,
+#endif
+&language[107],0,0,0,
+#ifdef SUBLANG_SLOVAK_SLOVAKIA
+SUBLANG_SLOVAK_SLOVAKIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sp","serbia",0,
+#ifdef CTRY_SERBIA
+CTRY_SERBIA,
+#else
+0,
+#endif
+&language[113],0,0,0,
+#ifdef SUBLANG_SERBIAN_SERBIA
+SUBLANG_SERBIAN_SERBIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sv","el-salvador",0,
+#ifdef CTRY_EL_SALVADOR
+CTRY_EL_SALVADOR,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_EL_SALVADOR
+SUBLANG_SPANISH_EL_SALVADOR,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sy","syria",0,
+#ifdef CTRY_SYRIA
+CTRY_SYRIA,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_SYRIA
+SUBLANG_ARABIC_SYRIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"th","thailand",0,
+#ifdef CTRY_THAILAND
+CTRY_THAILAND,
+#else
+0,
+#endif
+&language[122],0,0,0,
+#ifdef SUBLANG_THAI_THAILAND
+SUBLANG_THAI_THAILAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"tn","tunisia",0,
+#ifdef CTRY_TUNISIA
+CTRY_TUNISIA,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_TUNISIA
+SUBLANG_ARABIC_TUNISIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"tr","turkey",0,
+#ifdef CTRY_TURKEY
+CTRY_TURKEY,
+#else
+0,
+#endif
+&language[128],0,0,0,
+#ifdef SUBLANG_TURKISH_TURKEY
+SUBLANG_TURKISH_TURKEY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"tt","trinidad&tobago",0,
+#ifdef CTRY_TRINIDAD_TOBAGO
+CTRY_TRINIDAD_TOBAGO,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_TRINIDAD_TOBAGO
+SUBLANG_ENGLISH_TRINIDAD_TOBAGO,
+#else
+0,
+#endif
+0,0,0,
+},
+{"tw","taiwan",0,
+#ifdef CTRY_TAIWAN
+CTRY_TAIWAN,
+#else
+0,
+#endif
+&language[131],0,0,0,
+#ifdef SUBLANG_CHINESE_TRADITIONAL_TAIWAN
+SUBLANG_CHINESE_TRADITIONAL_TAIWAN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ua","ukraine",0,
+#ifdef CTRY_UKRAINE
+CTRY_UKRAINE,
+#else
+0,
+#endif
+&language[132],&language[100],0,0,
+#ifdef SUBLANG_UKRAINIAN_UKRAINE
+SUBLANG_UKRAINIAN_UKRAINE,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_RUSSIAN_UKRAINE
+SUBLANG_RUSSIAN_UKRAINE,
+#else
+0,
+#endif
+0,0,
+},
+{"uk","united-kingdom",LC_primary,
+#ifdef CTRY_UNITED_KINGDOM
+CTRY_UNITED_KINGDOM,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_UNITED_KINGDOM
+SUBLANG_ENGLISH_UNITED_KINGDOM,
+#else
+0,
+#endif
+0,0,0,
+},
+{"us","united-states|usa",0,
+#ifdef CTRY_UNITED_STATES
+CTRY_UNITED_STATES,
+#else
+#ifdef CTRY_USA
+CTRY_USA,
+#else
+0,
+#endif
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_UNITED_STATES
+SUBLANG_ENGLISH_UNITED_STATES,
+#else
+#ifdef SUBLANG_ENGLISH_USA
+SUBLANG_ENGLISH_USA,
+#else
+0,
+#endif
+#endif
+0,0,0,
+},
+{"uy","uruguay",0,
+#ifdef CTRY_URUGUAY
+CTRY_URUGUAY,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_URUGUAY
+SUBLANG_SPANISH_URUGUAY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ve","venezuela",0,
+#ifdef CTRY_VENEZUELA
+CTRY_VENEZUELA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_VENEZUELA
+SUBLANG_SPANISH_VENEZUELA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"yu","yugoslavia",0,
+#ifdef CTRY_YUGOSLAVIA
+CTRY_YUGOSLAVIA,
+#else
+0,
+#endif
+&language[113],0,0,0,
+#ifdef SUBLANG_SERBIAN_YUGOSLAVIA
+SUBLANG_SERBIAN_YUGOSLAVIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"za","south-africa",0,
+#ifdef CTRY_SOUTH_AFRICA
+CTRY_SOUTH_AFRICA,
+#else
+0,
+#endif
+&language[4],0,0,0,
+#ifdef SUBLANG_AFRIKAANS_SOUTH_AFRICA
+SUBLANG_AFRIKAANS_SOUTH_AFRICA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"zw","zimbabwe",0,
+#ifdef CTRY_ZIMBABWE
+CTRY_ZIMBABWE,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_ZIMBABWE
+SUBLANG_ENGLISH_ZIMBABWE,
+#else
+0,
+#endif
+0,0,0,
+},
+ 0
+};
+
+static const Lc_map_t map[] =
+{
+{"enu",&language[26],&territory[93],&charset[0],0},
+{"enz",&language[26],&territory[68],&charset[0],0},
+{"esm",&language[28],&territory[63],&charset[0],0},
+{"esn",&language[28],&territory[30],&charset[0],&attribute_es[1]},
+{"esp",&language[28],&territory[30],&charset[0],&attribute_es[0]},
+{"usa",&language[26],&territory[93],&charset[0],0},
+ 0
+};
diff --git a/usr/src/lib/libast/i386/src/lib/libast/preroot.h b/usr/src/lib/libast/i386/src/lib/libast/preroot.h
new file mode 100644
index 0000000000..5180fe4be7
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/preroot.h
@@ -0,0 +1,6 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/preroot.sh by iffe version 2007-04-04 : : */
+#ifndef _def_preroot_ast
+#define _def_preroot_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* preroot not enabled */
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/sig.h b/usr/src/lib/libast/i386/src/lib/libast/sig.h
new file mode 100644
index 0000000000..32bdf7dd50
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/sig.h
@@ -0,0 +1,131 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/sig.sh by iffe version 2007-04-04 : : */
+#ifndef _def_sig_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_sig_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define sig_info _sig_info_
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide kill killpg
+#else
+#define kill ______kill
+#define killpg ______killpg
+#endif
+#include <signal.h>
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide kill killpg
+#else
+#undef kill
+#undef killpg
+#endif
+#ifndef sigmask
+#define sigmask(s) (1<<((s)-1))
+#endif
+typedef void (*Sig_handler_t) __PROTO__((int));
+
+
+#define Handler_t Sig_handler_t
+
+#define SIG_REG_PENDING (-1)
+#define SIG_REG_POP 0
+#define SIG_REG_EXEC 00001
+#define SIG_REG_PROC 00002
+#define SIG_REG_TERM 00004
+#define SIG_REG_ALL 00777
+#define SIG_REG_SET 01000
+
+typedef struct
+{
+ char** name;
+ char** text;
+ int sigmax;
+} Sig_info_t;
+
+extern __MANGLE__ int kill __PROTO__((pid_t, int));
+extern __MANGLE__ int killpg __PROTO__((pid_t, int));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Sig_info_t sig_info;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int sigcritical __PROTO__((int));
+extern __MANGLE__ int sigunblock __PROTO__((int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/tmx.h b/usr/src/lib/libast/i386/src/lib/libast/tmx.h
new file mode 100644
index 0000000000..567ee89369
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/tmx.h
@@ -0,0 +1,128 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/tmx by iffe version 2007-04-04 : : */
+
+#ifndef _TMX_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TMX_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Time_t support
+ */
+
+#include <tm.h>
+#include <tv.h>
+
+#define TMX_MAXDATE "2554-07-21+23:34:33.709551614 UTC"
+#define TMX_MAXYEAR 2554
+#define TMX_MAXSEC ((Time_t)18446744073)
+#define TMX_MAXNSEC 709551614
+#define TMX_RESOLUTION 1000000000
+
+typedef uint64_t Time_t;
+typedef uint64_t Tmxsec_t;
+typedef uint32_t Tmxnsec_t;
+
+#define tmxsec(t) ((Tmxsec_t)((t)/1000000000))
+#define tmxnsec(t) ((Tmxnsec_t)((t)%1000000000))
+#define tmxsns(s,n) (((((Time_t)(s))*1000000000))+((Time_t)(n)))
+
+#define TMX_NOTIME ((Time_t)(-1))
+#define TMX_NOW tmxgettime()
+#define TMX_MAXTIME tmxsns(TMX_MAXSEC,TMX_MAXNSEC)
+
+#define tmx2tv(t,v) ((v)->tv_nsec=tmxnsec(t),(v)->tv_sec=tmxsec(t))
+#define tv2tmx(v) tmxsns((v)->tv_sec,(v)->tv_nsec)
+
+#define tmxclock(p) tmxsns(((p)?*(p):time(NiL)),0)
+
+#define tmxgetatime(s) tmxsns((s)->st_atime,ST_ATIME_NSEC_GET(s))
+#define tmxgetctime(s) tmxsns((s)->st_ctime,ST_CTIME_NSEC_GET(s))
+#define tmxgetmtime(s) tmxsns((s)->st_mtime,ST_MTIME_NSEC_GET(s))
+
+#define tmxsetatime(s,t) ((s)->st_atime=tmxsec(t),ST_ATIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetctime(s,t) ((s)->st_ctime=tmxsec(t),ST_CTIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetmtime(s,t) ((s)->st_mtime=tmxsec(t),ST_MTIME_NSEC_SET(s,tmxnsec(t)))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Time_t tmxdate __PROTO__((const char*, char**, Time_t));
+extern __MANGLE__ char* tmxfmt __PROTO__((char*, size_t, const char*, Time_t));
+extern __MANGLE__ Time_t tmxleap __PROTO__((Time_t));
+extern __MANGLE__ Tm_t* tmxmake __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxscan __PROTO__((const char*, char**, const char*, char**, Time_t, long));
+extern __MANGLE__ int tmxsleep __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxtime __PROTO__((Tm_t*, int));
+
+extern __MANGLE__ Time_t tmxgettime __PROTO__((void));
+extern __MANGLE__ int tmxsettime __PROTO__((Time_t));
+
+extern __MANGLE__ int tmxtouch __PROTO__((const char*, Time_t, Time_t, Time_t, int));
+
+extern __MANGLE__ char* fmttmx __PROTO__((const char*, Time_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/i386/src/lib/libast/tv.h b/usr/src/lib/libast/i386/src/lib/libast/tv.h
new file mode 100644
index 0000000000..272ec802d8
--- /dev/null
+++ b/usr/src/lib/libast/i386/src/lib/libast/tv.h
@@ -0,0 +1,111 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libast/features/tv by iffe version 2007-04-04 : : */
+
+#ifndef _TV_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TV_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Tv_t interface definitions
+ */
+
+#include <ast.h>
+
+#define TV_NSEC_IGNORE (1000000000L)
+#define TV_TOUCH_RETAIN ((Tv_t*)1)
+
+typedef struct Tv_s
+{
+ uint32_t tv_sec;
+ uint32_t tv_nsec;
+} Tv_t;
+
+#define ST_ATIME_NSEC_GET(st) ((st)->st_atim.tv_nsec)
+#define ST_CTIME_NSEC_GET(st) ((st)->st_ctim.tv_nsec)
+#define ST_MTIME_NSEC_GET(st) ((st)->st_mtim.tv_nsec)
+
+#define ST_ATIME_NSEC_SET(st,n) (ST_ATIME_NSEC_GET(st)=(n))
+#define ST_CTIME_NSEC_SET(st,n) (ST_CTIME_NSEC_GET(st)=(n))
+#define ST_MTIME_NSEC_SET(st,n) (ST_MTIME_NSEC_GET(st)=(n))
+
+#define tvgetatime(t,s) ((t)->tv_nsec=ST_ATIME_NSEC_GET(s),(t)->tv_sec=(s)->st_atime)
+#define tvgetmtime(t,s) ((t)->tv_nsec=ST_MTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_mtime)
+#define tvgetctime(t,s) ((t)->tv_nsec=ST_CTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_ctime)
+
+#define tvsetatime(t,s) (ST_ATIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_atime=(t)->tv_sec)
+#define tvsetmtime(t,s) (ST_MTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_mtime=(t)->tv_sec)
+#define tvsetctime(t,s) (ST_CTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_ctime=(t)->tv_sec)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int tvgettime __PROTO__((Tv_t*));
+extern __MANGLE__ int tvsettime __PROTO__((const Tv_t*));
+extern __MANGLE__ int tvcmp __PROTO__((const Tv_t*, const Tv_t*));
+extern __MANGLE__ int tvtouch __PROTO__((const char*, const Tv_t*, const Tv_t*, const Tv_t*, int));
+extern __MANGLE__ int tvsleep __PROTO__((const Tv_t*, Tv_t*));
+
+extern __MANGLE__ char* fmttv __PROTO__((const char*, Tv_t*));
+
+#endif
diff --git a/usr/src/lib/libast/mapfile-vers b/usr/src/lib/libast/mapfile-vers
new file mode 100644
index 0000000000..d4818d7a61
--- /dev/null
+++ b/usr/src/lib/libast/mapfile-vers
@@ -0,0 +1,727 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+# functions
+SUNWprivate_1.1 {
+ global:
+ _Sfextern;
+ _Sfi;
+ _Sfmaxr;
+ _Sftable;
+ _Vmextern;
+ _Vmheap;
+ _ast___getdelim;
+ _ast_asprintf;
+ _ast_basename;
+ _ast_calloc;
+ _ast_catclose;
+ _ast_categories;
+ _ast_catgets;
+ _ast_catopen;
+ _ast_cfree;
+ _ast_clearerr;
+ _ast_clearerr_unlocked;
+ _ast_dirname;
+ _ast_doprnt;
+ _ast_doscan;
+ _ast_eaccess;
+ _ast_execvpe;
+ _ast_fclose;
+ _ast_fcloseall;
+ _ast_fdopen;
+ _ast_feof_unlocked;
+ _ast_ferror_unlocked;
+ _ast_fflush;
+ _ast_fflush_unlocked;
+ _ast_fgetc;
+ _ast_fgetc_unlocked;
+ _ast_fgetpos64;
+ _ast_fgetpos;
+ _ast_fgets;
+ _ast_fgets_unlocked;
+ _ast_fgetwc;
+ _ast_fgetws;
+ _ast_fileno_unlocked;
+ _ast_fmemopen;
+ _ast_fnmatch;
+ _ast_fopen;
+ _ast_fprintf;
+ _ast_fpurge;
+ _ast_fputc_unlocked;
+ _ast_fputs;
+ _ast_fputs_unlocked;
+ _ast_fputwc;
+ _ast_fputws;
+ _ast_fread;
+ _ast_fread_unlocked;
+ _ast_free;
+ _ast_freopen;
+ _ast_fscanf;
+ _ast_fseek64;
+ _ast_fseek;
+ _ast_fseeko64;
+ _ast_fseeko;
+ _ast_fsetpos64;
+ _ast_fsetpos;
+ _ast_ftell64;
+ _ast_ftell;
+ _ast_ftello64;
+ _ast_ftello;
+ _ast_fts_children;
+ _ast_fts_close;
+ _ast_fts_flags;
+ _ast_fts_notify;
+ _ast_fts_open;
+ _ast_fts_read;
+ _ast_fts_set;
+ _ast_ftw;
+ _ast_ftwalk;
+ _ast_ftwflags;
+ _ast_fwide;
+ _ast_fwprintf;
+ _ast_fwrite;
+ _ast_fwrite_unlocked;
+ _ast_fwscanf;
+ _ast_getc_unlocked;
+ _ast_getchar_unlocked;
+ _ast_getcwd;
+ _ast_getdate;
+ _ast_getdelim;
+ _ast_getline;
+ _ast_getopt;
+ _ast_getopt_long;
+ _ast_getopt_long_only;
+ _ast_getpgrp;
+ _ast_gets;
+ _ast_getw;
+ _ast_getwc;
+ _ast_getwchar;
+ _ast_getwd;
+ _ast_getws;
+ _ast_glob;
+ _ast_globfree;
+ _ast_iconv;
+ _ast_iconv_close;
+ _ast_iconv_list;
+ _ast_iconv_move;
+ _ast_iconv_name;
+ _ast_iconv_open;
+ _ast_iconv_write;
+ _ast_info;
+ _ast_localeconv;
+ _ast_locales;
+ _ast_malloc;
+ _ast_memalign;
+ _ast_memdup;
+ _ast_memfatal;
+ _ast_memhash;
+ _ast_memsum;
+ _ast_mkstemp;
+ _ast_mktemp;
+ _ast_mktime;
+ _ast_nftw;
+ _ast_optesc;
+ _ast_optget;
+ _ast_opthelp;
+ _ast_optjoin;
+ _ast_optstr;
+ _ast_optusage;
+ _ast_pathaccess;
+ _ast_pathbin;
+ _ast_pathcanon;
+ _ast_pathcat;
+ _ast_pathcd;
+ _ast_pathcheck;
+ _ast_pathexists;
+ _ast_pathfind;
+ _ast_pathgetlink;
+ _ast_pathinclude;
+ _ast_pathkey;
+ _ast_pathnative;
+ _ast_pathpath;
+ _ast_pathposix;
+ _ast_pathprobe;
+ _ast_pathrepl;
+ _ast_pathsetlink;
+ _ast_pathshell;
+ _ast_pathstat;
+ _ast_pathtemp;
+ _ast_pathtmp;
+ _ast_pclose;
+ _ast_popen;
+ _ast_printf;
+ _ast_procclose;
+ _ast_procfree;
+ _ast_procopen;
+ _ast_procrun;
+ _ast_putc_unlocked;
+ _ast_putchar_unlocked;
+ _ast_putenv;
+ _ast_puts;
+ _ast_putw;
+ _ast_putwc;
+ _ast_putwchar;
+ _ast_re_comp;
+ _ast_re_exec;
+ _ast_realloc;
+ _ast_realpath;
+ _ast_regaddclass;
+ _ast_regalloc;
+ _ast_regcache;
+ _ast_regclass;
+ _ast_regcmp;
+ _ast_regcollate;
+ _ast_regcomb;
+ _ast_regcomp;
+ _ast_regdup;
+ _ast_regerror;
+ _ast_regex;
+ _ast_regexec;
+ _ast_regfatal;
+ _ast_regfatalpat;
+ _ast_regfree;
+ _ast_regncomp;
+ _ast_regnexec;
+ _ast_regrecord;
+ _ast_regrexec;
+ _ast_regstat;
+ _ast_regsub;
+ _ast_regsubcomp;
+ _ast_regsubexec;
+ _ast_regsubflags;
+ _ast_regsubfree;
+ _ast_remove;
+ _ast_resolvepath;
+ _ast_rewind;
+ _ast_scanf;
+ _ast_setbuf;
+ _ast_setbuffer;
+ _ast_setenv;
+ _ast_setenviron;
+ _ast_setlinebuf;
+ _ast_setlocale;
+ _ast_setvbuf;
+ _ast_sigcritical;
+ _ast_signal;
+ _ast_sigunblock;
+ _ast_snprintf;
+ _ast_sprintf;
+ _ast_sscanf;
+ _ast_stracmp;
+ _ast_strcopy;
+ _ast_strdup;
+ _ast_strelapsed;
+ _ast_strerror;
+ _ast_stresc;
+ _ast_streval;
+ _ast_strexpr;
+ _ast_strftime;
+ _ast_strgid;
+ _ast_strgrpmatch;
+ _ast_strhash;
+ _ast_strkey;
+ _ast_strlcat;
+ _ast_strlcpy;
+ _ast_strlook;
+ _ast_strmatch;
+ _ast_strmode;
+ _ast_strnacmp;
+ _ast_strncopy;
+ _ast_strntod;
+ _ast_strntol;
+ _ast_strntold;
+ _ast_strntoll;
+ _ast_strntoul;
+ _ast_strntoull;
+ _ast_stropt;
+ _ast_strperm;
+ _ast_strpsearch;
+ _ast_strptime;
+ _ast_strsearch;
+ _ast_strsort;
+ _ast_strsubmatch;
+ _ast_strsum;
+ _ast_strtape;
+ _ast_strtod;
+ _ast_strtoip4;
+ _ast_strtol;
+ _ast_strtold;
+ _ast_strtoll;
+ _ast_strton;
+ _ast_strtonll;
+ _ast_strtoul;
+ _ast_strtoull;
+ _ast_struid;
+ _ast_struniq;
+ _ast_swprintf;
+ _ast_swscanf;
+ _ast_system;
+ _ast_tempnam;
+ _ast_tmpfile;
+ _ast_tmpnam;
+ _ast_touch;
+ _ast_translate;
+ _ast_ungetc;
+ _ast_ungetwc;
+ _ast_unsetenv;
+ _ast_valloc;
+ _ast_vasprintf;
+ _ast_vfprintf;
+ _ast_vfscanf;
+ _ast_vfwprintf;
+ _ast_vfwscanf;
+ _ast_vprintf;
+ _ast_vscanf;
+ _ast_vsnprintf;
+ _ast_vsprintf;
+ _ast_vsscanf;
+ _ast_vswprintf;
+ _ast_vswscanf;
+ _ast_vwprintf;
+ _ast_vwscanf;
+ _ast_wordexp;
+ _ast_wordfree;
+ _ast_wprintf;
+ _ast_wscanf;
+ _ccmapcpy;
+ _ccmapstr;
+ _error_info_;
+ _filbuf;
+ _fini;
+ _hash_info_;
+ _iblocks;
+ _init;
+ _lib_version;
+ _mode_permmap_;
+ _mode_table_;
+ _opt_info_;
+ _proc_info_;
+ _re_comp;
+ _re_exec;
+ _re_putc;
+ _reg_alloc;
+ _reg_classfun;
+ _reg_drop;
+ _reg_fatal;
+ _reg_state;
+ _sfcvt;
+ _sfdlen;
+ _sfexcept;
+ _sffilbuf;
+ _sfflsbuf;
+ _sfgetl2;
+ _sfgetl;
+ _sfgetu2;
+ _sfgetu;
+ _sfllen;
+ _sfmode;
+ _sfopen;
+ _sfpclose;
+ _sfpopen;
+ _sfputd;
+ _sfputl;
+ _sfputm;
+ _sfputu;
+ _sfrsrv;
+ _sfsetpool;
+ _sfstrtod;
+ _sftype;
+ _sig_info_;
+ _stdgets;
+ _stdopen;
+ _stdprintf;
+ _stdscanf;
+ _stdsetvbuf;
+ _stdsprintf;
+ _stdvsnprintf;
+ _stdvsprintf;
+ _stdvsscanf;
+ _stkseek;
+ _vmbestcheck;
+ astconf;
+ astconfdisc;
+ astconflist;
+ astcopy;
+ astgetconf;
+ astlicense;
+ astquery;
+ astwinsize;
+ base64decode;
+ base64encode;
+ ccmapid;
+ ccmaplist;
+ ccmapname;
+ ccnative;
+ chresc;
+ chrtoi;
+ dtclose;
+ dtdisc;
+ dtextract;
+ dtflatten;
+ dtmethod;
+ dtnew;
+ dtopen;
+ dtrenew;
+ dtrestore;
+ dtsize;
+ dtstat;
+ dtstrhash;
+ dttreeset;
+ dtview;
+ dtwalk;
+ error;
+ error_break;
+ errorf;
+ errormsg;
+ errorv;
+ errorx;
+ findclose;
+ findopen;
+ findread;
+ findwrite;
+ fmtbase;
+ fmtbasell;
+ fmtbuf;
+ fmtclock;
+ fmtdev;
+ fmtelapsed;
+ fmterror;
+ fmtesc;
+ fmtesq;
+ fmtfmt;
+ fmtfs;
+ fmtgid;
+ fmtident;
+ fmtip4;
+ fmtls;
+ fmtmatch;
+ fmtmode;
+ fmtnesq;
+ fmtnum;
+ fmtperm;
+ fmtquote;
+ fmtre;
+ fmtrec;
+ fmtscale;
+ fmtsignal;
+ fmttime;
+ fmttmx;
+ fmttv;
+ fmtuid;
+ fmtversion;
+ fs3d;
+ getsubopt;
+ hashalloc;
+ hashdone;
+ hashdump;
+ hashfree;
+ hashlast;
+ hashlook;
+ hashnext;
+ hashscan;
+ hashsize;
+ hashview;
+ hashwalk;
+ lccanon;
+ lccategories;
+ lcindex;
+ lcinfo;
+ lcmake;
+ lcscan;
+ liberror;
+ libevent;
+ magicclose;
+ magiclist;
+ magicload;
+ magicopen;
+ magictype;
+ mcclose;
+ mcdump;
+ mcfind;
+ mcget;
+ mcindex;
+ mcopen;
+ mcput;
+ mimeclose;
+ mimecmp;
+ mimehead;
+ mimelist;
+ mimeload;
+ mimeopen;
+ mimeset;
+ mimetype;
+ mimeview;
+ mntclose;
+ mntopen;
+ mntread;
+ mntwrite;
+ modei;
+ modex;
+ optarg;
+ opterr;
+ optind;
+ optopt;
+ pvalloc;
+ recfmt;
+ reclen;
+ recstr;
+ sfaprints;
+ sfclose;
+ sfclrerr;
+ sfclrlock;
+ sfdcdio;
+ sfdcdos;
+ sfdcfilter;
+ sfdcmore;
+ sfdcprefix;
+ sfdcseekable;
+ sfdcslow;
+ sfdcsubstream;
+ sfdctee;
+ sfdcunion;
+ sfdisc;
+ sfdlen;
+ sfecvt;
+ sfeof;
+ sferror;
+ sffcvt;
+ sffileno;
+ sfgetc;
+ sfgetd;
+ sfgetl;
+ sfgetm;
+ sfgetr;
+ sfgetu;
+ sfkeyprintf;
+ sfkeyprintf_20000308;
+ sfllen;
+ sfmove;
+ sfmutex;
+ sfnew;
+ sfnotify;
+ sfnputc;
+ sfopen;
+ sfpeek;
+ sfpkrd;
+ sfpoll;
+ sfpool;
+ sfpopen;
+ sfprintf;
+ sfprints;
+ sfpurge;
+ sfputc;
+ sfputd;
+ sfputl;
+ sfputm;
+ sfputr;
+ sfputu;
+ sfraise;
+ sfrd;
+ sfread;
+ sfreserve;
+ sfresize;
+ sfscanf;
+ sfseek;
+ sfset;
+ sfsetbuf;
+ sfsetfd;
+ sfsize;
+ sfsk;
+ sfslen;
+ sfsprintf;
+ sfsscanf;
+ sfstack;
+ sfstacked;
+ sfstrtmp;
+ sfswap;
+ sfsync;
+ sftell;
+ sftmp;
+ sfulen;
+ sfungetc;
+ sfvalue;
+ sfvaprints;
+ sfvprintf;
+ sfvprints;
+ sfvscanf;
+ sfvsprintf;
+ sfvsscanf;
+ sfwr;
+ sfwrite;
+ spawnlp;
+ spawnve;
+ spawnveg;
+ spawnvp;
+ spawnvpe;
+ stackalloc;
+ stackclear;
+ stackfree;
+ stackget;
+ stackpop;
+ stackpush;
+ stacktell;
+ stkalloc;
+ stkclose;
+ stkcopy;
+ stkfreeze;
+ stkinstall;
+ stklink;
+ stkopen;
+ stkset;
+ swapget;
+ swapmem;
+ swapop;
+ swapput;
+ systrace;
+ tmdate;
+ tmequiv;
+ tmfix;
+ tmfmt;
+ tmform;
+ tmgoff;
+ tminit;
+ tmleap;
+ tmlex;
+ tmlocale;
+ tmmake;
+ tmpoff;
+ tmscan;
+ tmsleep;
+ tmtime;
+ tmtype;
+ tmweek;
+ tmword;
+ tmxdate;
+ tmxfmt;
+ tmxgettime;
+ tmxleap;
+ tmxmake;
+ tmxscan;
+ tmxsettime;
+ tmxsleep;
+ tmxtime;
+ tmxtouch;
+ tmzone;
+ tokclose;
+ tokline;
+ tokopen;
+ tokread;
+ tokscan;
+ tvcmp;
+ tvgettime;
+ tvsettime;
+ tvsleep;
+ tvtouch;
+ typefix;
+ univ_env;
+ vecargs;
+ vecfile;
+ vecfree;
+ vecload;
+ vecstring;
+ vmclear;
+ vmclose;
+ vmdbcheck;
+ vmdbwatch;
+ vmdebug;
+ vmdisc;
+ vmgetmem;
+ vmmopen;
+ vmmset;
+ vmopen;
+ vmprofile;
+ vmregion;
+ vmsegment;
+ vmset;
+ vmstat;
+ vmstrdup;
+ vmtrace;
+ vmtrbusy;
+ vmwalk;
+ local:
+ *;
+};
+
+# data
+SUNWprivate_1.1 {
+ global:
+ Dtbag;
+ Dthash;
+ Dtlist;
+ Dtobag;
+ Dtorder;
+ Dtoset;
+ Dtqueue;
+ Dtset;
+ Dtstack;
+ Dttree;
+ Vmbest;
+ Vmdcheap;
+ Vmdcsbrk;
+ Vmdebug;
+ Vmheap;
+ Vmlast;
+ Vmpool;
+ Vmprofile;
+ Vmregion;
+ _DATA_dthash;
+ _DATA_dtlist;
+ _DATA_dttree;
+ _DATA_sigdata;
+ _DATA_vmbest;
+ _DATA_vmdcheap;
+ _DATA_vmdebug;
+ _DATA_vmlast;
+ _DATA_vmpool;
+ _DATA_vmprofile;
+ _Dthash;
+ _Dtlist;
+ _Dtqueue;
+ _Dtstack;
+ _Dttree;
+ _Sfstderr;
+ _Sfstdin;
+ _Sfstdout;
+ _Stak_data;
+ _ast_conf_data;
+ _ast_conf_ndata;
+ _ast_conf_nprefix;
+ _ast_conf_prefix;
+ _ccmap;
+ _error_infop_;
+ _opt_infop_;
+ _tm_data_;
+ _tm_datap_;
+ _tm_info_;
+ _tm_infop_;
+ sfstderr;
+ sfstdin;
+ sfstdout;
+ local:
+ *;
+};
diff --git a/usr/src/lib/libast/sparc/Makefile b/usr/src/lib/libast/sparc/Makefile
new file mode 100644
index 0000000000..aa4e2edd78
--- /dev/null
+++ b/usr/src/lib/libast/sparc/Makefile
@@ -0,0 +1,47 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+# Fetch minor version from RELEASE, e.g. "10" for "5.10", "11" for "5.11" etc.
+GETRELEASEMINOR = /usr/bin/ksh -c 'x=$(RELEASE) ; print "$${x$(POUND_SIGN)$(POUND_SIGN)*.}"'
+
+# Platform-specific config
+# Note that "HOSTTYPE" matches the value used by AT&T upstream.
+ASTPLATFORMCPPFLAGS = '-DHOSTTYPE="sol$(GETRELEASEMINOR:sh).sun4"'
+
+# platform-specific sources
+OBJECTS = \
+ sparc/src/lib/libast/conftab.o
+OBJDIRS = \
+ sparc/src/lib/libast
+
+include ../Makefile.com
+
+# Use -KPIC since libast is too big for -Kpic on 64bit
+# (and on 32bit it is close to the barrier)
+sparc_C_PICFLAGS = $(C_BIGPICFLAGS)
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/usr/src/lib/libast/sparc/include/ast/align.h b/usr/src/lib/libast/sparc/include/ast/align.h
new file mode 100644
index 0000000000..2d8d7edd3d
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/align.h
@@ -0,0 +1,54 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/align.c by iffe version 2007-04-04 : : */
+#ifndef _def_align_ast
+#define _def_align_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+typedef unsigned long ALIGN_INTEGRAL;
+
+#define ALIGN_CHUNK 8192
+#define ALIGN_INTEGRAL long
+#define ALIGN_INTEGER(x) ((ALIGN_INTEGRAL)(x))
+#define ALIGN_POINTER(x) ((char*)(x))
+#define ALIGN_ROUND(x,y) ALIGN_POINTER(ALIGN_INTEGER((x)+(y)-1)&~((y)-1))
+
+#define ALIGN_BOUND ALIGN_BOUND2
+#define ALIGN_ALIGN(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC(x) ALIGN_TRUNC2(x)
+
+#define ALIGN_BIT1 0x1
+#define ALIGN_BOUND1 ALIGN_BOUND2
+#define ALIGN_ALIGN1(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC1(x) ALIGN_TRUNC2(x)
+#define ALIGN_CLRBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffe)
+#define ALIGN_SETBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x1)
+#define ALIGN_TSTBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x1)
+
+#define ALIGN_BIT2 0x2
+#define ALIGN_BOUND2 8
+#define ALIGN_ALIGN2(x) ALIGN_TRUNC2((x)+7)
+#define ALIGN_TRUNC2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffff8)
+#define ALIGN_CLRBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffd)
+#define ALIGN_SETBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x2)
+#define ALIGN_TSTBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x2)
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast.h b/usr/src/lib/libast/sparc/include/ast/ast.h
new file mode 100644
index 0000000000..ea1569f946
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast.h
@@ -0,0 +1,381 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Advanced Software Technology Library
+ * AT&T Research
+ *
+ * std + posix + ast
+ */
+
+#ifndef _AST_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_H
+
+#include <ast_version.h>
+
+#ifndef _AST_STD_H
+#include <ast_std.h>
+#endif
+
+#ifndef _SFIO_H
+#include <sfio.h>
+#endif
+
+#ifndef ast
+#define ast _ast_info
+#endif
+
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif
+
+/*
+ * workaround botched headers that assume <stdio.h>
+ */
+
+#ifndef FILE
+#ifndef _SFIO_H
+struct _sfio_s;
+#endif
+#define FILE struct _sfio_s
+#ifndef __FILE_typedef
+#define __FILE_typedef 1
+#endif
+#ifndef _FILEDEFED
+#define _FILEDEFED 1
+#endif
+#endif
+
+/*
+ * exit() support -- this matches shell exit codes
+ */
+
+#define EXIT_BITS 8 /* # exit status bits */
+
+#define EXIT_USAGE 2 /* usage exit code */
+#define EXIT_QUIT ((1<<(EXIT_BITS))-1) /* parent should quit */
+#define EXIT_NOTFOUND ((1<<(EXIT_BITS-1))-1) /* command not found */
+#define EXIT_NOEXEC ((1<<(EXIT_BITS-1))-2) /* other exec error */
+
+#define EXIT_CODE(x) ((x)&((1<<EXIT_BITS)-1))
+#define EXIT_CORE(x) (EXIT_CODE(x)|(1<<EXIT_BITS)|(1<<(EXIT_BITS-1)))
+#define EXIT_TERM(x) (EXIT_CODE(x)|(1<<EXIT_BITS))
+
+/*
+ * NOTE: for compatibility the following work for EXIT_BITS={7,8}
+ */
+
+#define EXIT_STATUS(x) (((x)&((1<<(EXIT_BITS-2))-1))?(x):EXIT_CODE((x)>>EXIT_BITS))
+
+#define EXITED_CORE(x) (((x)&((1<<EXIT_BITS)|(1<<(EXIT_BITS-1))))==((1<<EXIT_BITS)|(1<<(EXIT_BITS-1)))||((x)&((1<<(EXIT_BITS-1))|(1<<(EXIT_BITS-2))))==((1<<(EXIT_BITS-1))|(1<<(EXIT_BITS-2))))
+#define EXITED_TERM(x) ((x)&((1<<EXIT_BITS)|(1<<(EXIT_BITS-1))))
+
+/*
+ * astconflist() flags
+ */
+
+#define ASTCONF_parse 0x0001
+#define ASTCONF_write 0x0002
+#define ASTCONF_read 0x0004
+#define ASTCONF_lower 0x0008
+#define ASTCONF_base 0x0010
+#define ASTCONF_defined 0x0020
+#define ASTCONF_quote 0x0040
+#define ASTCONF_table 0x0080
+#define ASTCONF_matchcall 0x0100
+#define ASTCONF_matchname 0x0200
+#define ASTCONF_matchstandard 0x0400
+#define ASTCONF_error 0x0800
+#define ASTCONF_system 0x1000
+#define ASTCONF_AST 0x2000
+
+/*
+ * pathcanon() flags
+ */
+
+#define PATH_PHYSICAL 01
+#define PATH_DOTDOT 02
+#define PATH_EXISTS 04
+#define PATH_VERIFIED(n) (((n)&01777)<<5)
+
+/*
+ * pathaccess() flags
+ */
+
+#define PATH_READ 004
+#define PATH_WRITE 002
+#define PATH_EXECUTE 001
+#define PATH_REGULAR 010
+#define PATH_ABSOLUTE 020
+
+/*
+ * touch() flags
+ */
+
+#define PATH_TOUCH_CREATE 01
+#define PATH_TOUCH_VERBATIM 02
+
+/*
+ * pathcheck() info
+ */
+
+typedef struct
+{
+ unsigned long date;
+ char* feature;
+ char* host;
+ char* user;
+} Pathcheck_t;
+
+/*
+ * strgrpmatch() flags
+ */
+
+#define STR_MAXIMAL 01 /* maximal match */
+#define STR_LEFT 02 /* implicit left anchor */
+#define STR_RIGHT 04 /* implicit right anchor */
+#define STR_ICASE 010 /* ignore case */
+#define STR_GROUP 020 /* (|&) inside [@|&](...) only */
+
+/*
+ * fmtquote() flags
+ */
+
+#define FMT_ALWAYS 0x01 /* always quote */
+#define FMT_ESCAPED 0x02 /* already escaped */
+#define FMT_SHELL 0x04 /* escape $ ` too */
+#define FMT_WIDE 0x08 /* don't escape 8 bit chars */
+#define FMT_PARAM 0x10 /* disable FMT_SHELL ${$( quote */
+
+/*
+ * multibyte macros
+ */
+
+#define mbmax() (ast.mb_cur_max)
+#define mberr() (ast.tmp_int<0)
+
+#define mbcoll() (ast.mb_xfrm!=0)
+#define mbwide() (mbmax()>1)
+
+#define mbchar(p) (mbwide()?((ast.tmp_int=(*ast.mb_towc)(&ast.tmp_wchar,(char*)(p),mbmax()))>0?((p+=ast.tmp_int),ast.tmp_wchar):(p++,ast.tmp_int)):(*(unsigned char*)(p++)))
+#define mbinit() (mbwide()?(*ast.mb_towc)((wchar_t*)0,(char*)0,mbmax()):0)
+#define mbsize(p) (mbwide()?(*ast.mb_len)((char*)(p),mbmax()):((p),1))
+#define mbconv(s,w) (ast.mb_conv?(*ast.mb_conv)(s,w):((*(s)=(w)),1))
+#define mbwidth(w) (ast.mb_width&&((ast.tmp_int=(*ast.mb_width)(w))>=0||(w)>UCHAR_MAX)?ast.tmp_int:1)
+#define mbxfrm(t,f,n) (mbcoll()?(*ast.mb_xfrm)((char*)(t),(char*)(f),n):0)
+
+/*
+ * common macros
+ */
+
+#define elementsof(x) (sizeof(x)/sizeof(x[0]))
+#define integralof(x) (((char*)(x))-((char*)0))
+#define newof(p,t,n,x) ((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)calloc(1,sizeof(t)*(n)+(x)))
+#define oldof(p,t,n,x) ((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)malloc(sizeof(t)*(n)+(x)))
+#define pointerof(x) ((__V_*)((char*)0+(x)))
+#define roundof(x,y) (((x)+(y)-1)&~((y)-1))
+#define ssizeof(x) ((int)sizeof(x))
+
+#define streq(a,b) (*(a)==*(b)&&!strcmp(a,b))
+#define strneq(a,b,n) (*(a)==*(b)&&!strncmp(a,b,n))
+#define strsignal(s) fmtsignal(s)
+
+#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
+#define NiL 0
+#define NoP(x) (void)(x)
+#else
+#define NiL ((char*)0)
+#define NoP(x) (&x,1)
+#endif
+
+#if !defined(NoF)
+#if defined(__STDC__) || defined(__STDPP__)
+#define NoF(x) void _DATA_ ## x () {}
+#else
+#define NoF(x) void _DATA_/**/x () {}
+#endif
+#if !defined(_DATA_)
+#define _DATA_
+#endif
+#endif
+
+#if !defined(NoN)
+#if defined(__STDC__) || defined(__STDPP__)
+#define NoN(x) void _STUB_ ## x () {}
+#else
+#define NoN(x) void _STUB_/**/x () {}
+#endif
+#if !defined(_STUB_)
+#define _STUB_
+#endif
+#endif
+
+#define NOT_USED(x) NoP(x)
+
+typedef int (*Error_f) __PROTO__((__V_*, __V_*, int, ...));
+
+typedef int (*Ast_confdisc_f) __PROTO__((const char*, const char*, const char*));
+typedef int (*Strcmp_context_f) __PROTO__((const char*, const char*, __V_*));
+typedef int (*Strcmp_f) __PROTO__((const char*, const char*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ char* astgetconf __PROTO__((const char*, const char*, const char*, int, Error_f));
+extern __MANGLE__ char* astconf __PROTO__((const char*, const char*, const char*));
+extern __MANGLE__ Ast_confdisc_f astconfdisc __PROTO__((Ast_confdisc_f));
+extern __MANGLE__ void astconflist __PROTO__((Sfio_t*, const char*, int, const char*));
+extern __MANGLE__ off_t astcopy __PROTO__((int, int, off_t));
+extern __MANGLE__ int astlicense __PROTO__((char*, int, char*, char*, int, int, int));
+extern __MANGLE__ int astquery __PROTO__((int, const char*, ...));
+extern __MANGLE__ void astwinsize __PROTO__((int, int*, int*));
+
+extern __MANGLE__ ssize_t base64encode __PROTO__((const __V_*, size_t, __V_**, __V_*, size_t, __V_**));
+extern __MANGLE__ ssize_t base64decode __PROTO__((const __V_*, size_t, __V_**, __V_*, size_t, __V_**));
+extern __MANGLE__ int chresc __PROTO__((const char*, char**));
+extern __MANGLE__ int chrtoi __PROTO__((const char*));
+extern __MANGLE__ int eaccess __PROTO__((const char*, int));
+extern __MANGLE__ char* fmtbase __PROTO__((long, int, int));
+extern __MANGLE__ char* fmtbasell __PROTO__((intmax_t, int, int));
+#define fmtbase(a,b,c) fmtbasell((intmax_t)(a),b,c) /* until 2003-09-01 */
+extern __MANGLE__ char* fmtbuf __PROTO__((size_t));
+extern __MANGLE__ char* fmtclock __PROTO__((Sfulong_t));
+extern __MANGLE__ char* fmtelapsed __PROTO__((unsigned long, int));
+extern __MANGLE__ char* fmterror __PROTO__((int));
+extern __MANGLE__ char* fmtesc __PROTO__((const char*));
+extern __MANGLE__ char* fmtesq __PROTO__((const char*, const char*));
+extern __MANGLE__ char* fmtident __PROTO__((const char*));
+extern __MANGLE__ char* fmtip4 __PROTO__((uint32_t, int));
+extern __MANGLE__ char* fmtfmt __PROTO__((const char*));
+extern __MANGLE__ char* fmtgid __PROTO__((int));
+extern __MANGLE__ char* fmtmatch __PROTO__((const char*));
+extern __MANGLE__ char* fmtmode __PROTO__((int, int));
+extern __MANGLE__ char* fmtnesq __PROTO__((const char*, const char*, size_t));
+extern __MANGLE__ char* fmtnum __PROTO__((unsigned long, int));
+extern __MANGLE__ char* fmtperm __PROTO__((int));
+extern __MANGLE__ char* fmtquote __PROTO__((const char*, const char*, const char*, size_t, int));
+extern __MANGLE__ char* fmtre __PROTO__((const char*));
+extern __MANGLE__ char* fmtscale __PROTO__((Sfulong_t, int));
+extern __MANGLE__ char* fmtsignal __PROTO__((int));
+extern __MANGLE__ char* fmttime __PROTO__((const char*, time_t));
+extern __MANGLE__ char* fmtuid __PROTO__((int));
+extern __MANGLE__ char* fmtversion __PROTO__((unsigned long));
+extern __MANGLE__ __V_* memdup __PROTO__((const __V_*, size_t));
+extern __MANGLE__ void memfatal __PROTO__((void));
+extern __MANGLE__ unsigned int memhash __PROTO__((const __V_*, int));
+extern __MANGLE__ unsigned long memsum __PROTO__((const __V_*, int, unsigned long));
+extern __MANGLE__ char* pathaccess __PROTO__((char*, const char*, const char*, const char*, int));
+extern __MANGLE__ char* pathbin __PROTO__((void));
+extern __MANGLE__ char* pathcanon __PROTO__((char*, int));
+extern __MANGLE__ char* pathcat __PROTO__((char*, const char*, int, const char*, const char*));
+extern __MANGLE__ int pathcd __PROTO__((const char*, const char*));
+extern __MANGLE__ int pathcheck __PROTO__((const char*, const char*, Pathcheck_t*));
+extern __MANGLE__ int pathexists __PROTO__((char*, int));
+extern __MANGLE__ char* pathfind __PROTO__((const char*, const char*, const char*, char*, size_t));
+extern __MANGLE__ int pathgetlink __PROTO__((const char*, char*, int));
+extern __MANGLE__ int pathinclude __PROTO__((const char*));
+extern __MANGLE__ char* pathkey __PROTO__((char*, char*, const char*, const char*, const char*));
+extern __MANGLE__ size_t pathnative __PROTO__((const char*, char*, size_t));
+extern __MANGLE__ char* pathpath __PROTO__((char*, const char*, const char*, int));
+extern __MANGLE__ size_t pathposix __PROTO__((const char*, char*, size_t));
+extern __MANGLE__ char* pathprobe __PROTO__((char*, char*, const char*, const char*, const char*, int));
+extern __MANGLE__ char* pathrepl __PROTO__((char*, const char*, const char*));
+extern __MANGLE__ int pathsetlink __PROTO__((const char*, const char*));
+extern __MANGLE__ char* pathshell __PROTO__((void));
+extern __MANGLE__ char* pathtemp __PROTO__((char*, size_t, const char*, const char*, int*));
+extern __MANGLE__ char* pathtmp __PROTO__((char*, const char*, const char*, int*));
+extern __MANGLE__ char* setenviron __PROTO__((const char*));
+extern __MANGLE__ int stracmp __PROTO__((const char*, const char*));
+extern __MANGLE__ char* strcopy __PROTO__((char*, const char*));
+extern __MANGLE__ unsigned long strelapsed __PROTO__((const char*, char**, int));
+extern __MANGLE__ int stresc __PROTO__((char*));
+extern __MANGLE__ long streval __PROTO__((const char*, char**, long(*)(const char*, char**)));
+extern __MANGLE__ long strexpr __PROTO__((const char*, char**, long(*)(const char*, char**, __V_*), __V_*));
+extern __MANGLE__ int strgid __PROTO__((const char*));
+extern __MANGLE__ int strgrpmatch __PROTO__((const char*, const char*, int*, int, int));
+extern __MANGLE__ unsigned int strhash __PROTO__((const char*));
+extern __MANGLE__ __V_* strlook __PROTO__((const __V_*, size_t, const char*));
+extern __MANGLE__ int strmatch __PROTO__((const char*, const char*));
+extern __MANGLE__ int strmode __PROTO__((const char*));
+extern __MANGLE__ int strnacmp __PROTO__((const char*, const char*, size_t));
+extern __MANGLE__ char* strncopy __PROTO__((char*, const char*, size_t));
+extern __MANGLE__ double strntod __PROTO__((const char*, size_t, char**));
+extern __MANGLE__ _ast_fltmax_t strntold __PROTO__((const char*, size_t, char**));
+extern __MANGLE__ long strntol __PROTO__((const char*, size_t, char**, int));
+extern __MANGLE__ intmax_t strntoll __PROTO__((const char*, size_t, char**, int));
+extern __MANGLE__ unsigned long strntoul __PROTO__((const char*, size_t, char**, int));
+extern __MANGLE__ uintmax_t strntoull __PROTO__((const char*, size_t, char**, int));
+extern __MANGLE__ int stropt __PROTO__((const char*, const __V_*, int, int(*)(__V_*, const __V_*, int, const char*), __V_*));
+extern __MANGLE__ int strperm __PROTO__((const char*, char**, int));
+extern __MANGLE__ __V_* strpsearch __PROTO__((const __V_*, size_t, size_t, const char*, char**));
+extern __MANGLE__ __V_* strsearch __PROTO__((const __V_*, size_t, size_t, Strcmp_f, const char*, __V_*));
+extern __MANGLE__ void strsort __PROTO__((char**, int, int(*)(const char*, const char*)));
+extern __MANGLE__ char* strsubmatch __PROTO__((const char*, const char*, int));
+extern __MANGLE__ unsigned long strsum __PROTO__((const char*, unsigned long));
+extern __MANGLE__ char* strtape __PROTO__((const char*, char**));
+extern __MANGLE__ int strtoip4 __PROTO__((const char*, char**, uint32_t*, unsigned char*));
+extern __MANGLE__ long strton __PROTO__((const char*, char**, char*, int));
+extern __MANGLE__ intmax_t strtonll __PROTO__((const char*, char**, char*, int));
+extern __MANGLE__ int struid __PROTO__((const char*));
+extern __MANGLE__ int struniq __PROTO__((char**, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+/*
+ * C library global data symbols not prototyped by <unistd.h>
+ */
+
+#if !defined(environ) && defined(__DYNAMIC__)
+#define environ __DYNAMIC__(environ)
+#else
+extern __MANGLE__ char** environ;
+#endif
+
+/*
+ * really handy malloc()/free() (__FILE__,__LINE__,__FUNCTION__) tracing
+ * make with VMDEBUG==1 or debug=1 or CCFLAGS=$(CC.DEBUG)
+ * VMDEBUG==0 disables
+ * at runtime export VMDEBUG or VMTRACE per vmalloc.3
+ * to list originating call locations
+ */
+
+#if !_std_malloc && !defined(VMFL) && !defined(_VMHDR_H) && \
+ (!defined(VMDEBUG) || VMDEBUG) && (VMDEBUG || _BLD_DEBUG)
+
+#define VMFL 1
+#include <vmalloc.h>
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_botch.h b/usr/src/lib/libast/sparc/include/ast/ast_botch.h
new file mode 100644
index 0000000000..5109e1ce1c
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_botch.h
@@ -0,0 +1,26 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/botch.c by iffe version 2007-04-04 : : */
+#ifndef _def_botch_ast
+#define _def_botch_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_ccode.h b/usr/src/lib/libast/sparc/include/ast/ast_ccode.h
new file mode 100644
index 0000000000..c42fb2d6c7
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_ccode.h
@@ -0,0 +1,50 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/ccode by iffe version 2007-04-04 : : */
+#ifndef _def_ccode_ast
+#define _def_ccode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define CC_ASCII 1 /* ISO-8859-1 */
+#define CC_EBCDIC_E 2 /* Xopen dd(1) EBCDIC */
+#define CC_EBCDIC_I 3 /* Xopen dd(1) IBM */
+#define CC_EBCDIC_O 4 /* IBM-1047 mvs OpenEdition */
+#define CC_EBCDIC_S 5 /* Siemens posix-bc */
+#define CC_EBCDIC_H 6 /* IBM-37 AS/400 */
+#define CC_EBCDIC_M 7 /* IBM mvs cobol */
+#define CC_EBCDIC_U 8 /* microfocus cobol */
+
+#define CC_MAPS 8 /* number of code maps */
+
+#define CC_EBCDIC CC_EBCDIC_E
+#define CC_EBCDIC1 CC_EBCDIC_E
+#define CC_EBCDIC2 CC_EBCDIC_I
+#define CC_EBCDIC3 CC_EBCDIC_O
+
+#define CC_NATIVE CC_ASCII /* native character code */
+#define CC_ALIEN CC_EBCDIC /* alien character code */
+
+#define CC_bel 0007 /* bel character */
+#define CC_esc 0033 /* esc character */
+#define CC_sub 0032 /* sub character */
+#define CC_vt 0013 /* vt character */
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_common.h b/usr/src/lib/libast/sparc/include/ast/ast_common.h
new file mode 100644
index 0000000000..a74cd0efdf
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_common.h
@@ -0,0 +1,219 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/common by iffe version 2007-04-04 : : */
+#ifndef _AST_COMMON_H
+#define _AST_COMMON_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_pthread 1 /* #include <pthread.h> ok */
+#define _hdr_stdarg 1 /* #include <stdarg.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdint 1 /* #include <stdint.h> ok */
+#define _hdr_inttypes 1 /* #include <inttypes.h> ok */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_long_double 1 /* long double is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _std_proto 1 /* standard C prototypes ok */
+#define _ptr_void 1 /* standard C void* ok */
+/* disable non-standard linux/gnu inlines */
+#ifdef __GNUC__
+# undef __OPTIMIZE_SIZE__
+# define __OPTIMIZE_SIZE__ 1
+#endif
+
+/* __STD_C indicates that the language is ANSI-C or C++ */
+#if !defined(__STD_C) && __STDC__
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && (__cplusplus || c_plusplus)
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && _std_proto
+# define __STD_C 1
+#endif
+#if !defined(__STD_C)
+# define __STD_C 0
+#endif
+
+/* extern symbols must be protected against C++ name mangling */
+#ifndef _BEGIN_EXTERNS_
+# if __cplusplus || c_plusplus
+# define _BEGIN_EXTERNS_ extern "C" {
+# define _END_EXTERNS_ }
+# else
+# define _BEGIN_EXTERNS_
+# define _END_EXTERNS_
+# endif
+#endif
+
+/* _ARG_ simplifies function prototyping among flavors of C */
+#ifndef _ARG_
+# if __STD_C
+# define _ARG_(x) x
+# else
+# define _ARG_(x) ()
+# endif
+#endif
+
+/* _NIL_ simplifies defining nil pointers to a given type */
+#ifndef _NIL_
+# define _NIL_(x) ((x)0)
+#endif
+
+/* __INLINE__ is the inline keyword */
+#if !defined(__INLINE__) && defined(__cplusplus)
+# define __INLINE__ inline
+#endif
+#if !defined(__INLINE__) && defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+#endif
+
+/* Void_t is defined so that Void_t* can address any type */
+#ifndef Void_t
+# if __STD_C
+# define Void_t void
+# else
+# define Void_t char
+# endif
+#endif
+
+/* windows variants and veneers */
+#if !defined(_WINIX) && (_UWIN || __CYGWIN__ || __EMX__)
+# define _WINIX 1
+#endif
+
+/* dynamic linked library external scope handling */
+#ifdef __DYNAMIC__
+# undef __DYNAMIC__
+# ifndef _DLL
+# define _DLL 1
+# endif
+#endif
+#if _dll_import
+# if _BLD_STATIC && !_BLD_DLL
+# undef _DLL
+# else
+# if !_UWIN && !defined(_DLL)
+# define _DLL 1
+# endif
+# endif
+# if !defined(__EXPORT__) && _BLD_DLL
+# define __EXPORT__ __declspec(dllexport)
+# endif
+# if !defined(__IMPORT__) && ( _BLD_DLL || defined(_DLL) )
+# define __IMPORT__ __declspec(dllimport)
+# endif
+# if _BLD_DLL && _UWIN
+# define __DYNAMIC__(v) (_ast_getdll()->_ast_ ## v)
+# endif
+#endif
+#if !defined(_astimport)
+# if defined(__IMPORT__) && defined(_DLL)
+# define _astimport __IMPORT__
+# else
+# define _astimport extern
+# endif
+#endif
+#if _dll_import && ( !_BLD_DLL || _WINIX && !_UWIN )
+# ifdef __STDC__
+# define __EXTERN__(T,obj) extern T obj; T* _imp__ ## obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__ ## obj = &obj
+# else
+# define __EXTERN__(T,obj) extern T obj; T* _imp__/**/obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__/**/obj = &obj
+# endif
+#else
+# define __EXTERN__(T,obj) extern T obj
+# define __DEFINE__(T,obj,val) T obj = val
+#endif
+
+#define _ast_LL 1 /* LL numeric suffix supported */
+#define _ast_int1_t char
+#define _ast_int2_t short
+#define _ast_int4_t int
+#define _ast_int8_t long long
+#define _ast_intmax_t _ast_int8_t
+#define _ast_intswap 0
+
+#define _ast_flt4_t float
+#define _ast_flt8_t double
+#define _ast_flt16_t long double
+#define _ast_fltmax_t _ast_flt16_t
+#define _typ_int8_t 1 /* int8_t is a type */
+#define _typ_uint8_t 1 /* uint8_t is a type */
+#define _typ_int16_t 1 /* int16_t is a type */
+#define _typ_uint16_t 1 /* uint16_t is a type */
+#define _typ_int32_t 1 /* int32_t is a type */
+#define _typ_uint32_t 1 /* uint32_t is a type */
+#define _typ_int64_t 1 /* int64_t is a type */
+#define _typ_uint64_t 1 /* uint64_t is a type */
+#define _typ_intmax_t 1 /* intmax_t is a type */
+#define _typ_uintmax_t 1 /* uintmax_t is a type */
+
+#ifndef va_listref
+#define va_listref(p) (p) /* pass va_list to varargs function */
+#define va_listval(p) (p) /* retrieve va_list from va_arg(ap,va_listarg) */
+#define va_listarg va_list /* va_arg() va_list type */
+#ifndef va_start
+#if __STD_C
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+#endif
+#ifndef _AST_STD_H
+# if __STD_C && _hdr_stddef
+# include <stddef.h>
+# endif
+# if _sys_types
+# include <sys/types.h>
+# endif
+# if _hdr_stdint
+# include <stdint.h>
+# else
+# if _hdr_inttypes
+# include <inttypes.h>
+# endif
+# endif
+#endif
+#if !_typ_size_t
+# define _typ_size_t 1
+ typedef int size_t;
+#endif
+#if !_typ_ssize_t
+# define _typ_ssize_t 1
+ typedef int ssize_t;
+#endif
+#ifndef _AST_STD_H
+# if !_def_map_ast
+# include <ast_map.h>
+# endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_dir.h b/usr/src/lib/libast/sparc/include/ast/ast_dir.h
new file mode 100644
index 0000000000..336b7f38a6
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_dir.h
@@ -0,0 +1,86 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * AT&T Research
+ *
+ * common dirent maintenance interface
+ */
+
+#ifndef _AST_DIR_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_DIR_H
+
+#include <ast_lib.h>
+
+#if _mem_d_fileno_dirent || _mem_d_ino_dirent
+#if !_mem_d_fileno_dirent
+#undef _mem_d_fileno_dirent
+#define _mem_d_fileno_dirent 1
+#define d_fileno d_ino
+#endif
+#endif
+
+#if _BLD_ast
+#include "dirlib.h"
+#else
+#include <dirent.h>
+#endif
+
+#if _mem_d_fileno_dirent
+#define D_FILENO(d) ((d)->d_fileno)
+#endif
+
+#if _mem_d_namlen_dirent
+#define D_NAMLEN(d) ((d)->d_namlen)
+#else
+#define D_NAMLEN(d) (strlen((d)->d_name))
+#endif
+
+#if _mem_d_reclen_dirent
+#define D_RECLEN(d) ((d)->d_reclen)
+#else
+#define D_RECLEN(d) D_RECSIZ(d,D_NAMLEN(d))
+#endif
+
+#define D_RECSIZ(d,n) (sizeof(*(d))-sizeof((d)->d_name)+((n)+sizeof(char*))&~(sizeof(char*)-1))
+
+/*
+ * NOTE: 2003-03-27 mac osx bug symlink==DT_REG bug discovered;
+ * the kernel *and* all directories must be fixed, so d_type
+ * is summarily disabled until we see that happen
+ */
+
+#if _mem_d_type_dirent && defined(DT_UNKNOWN) && defined(DT_REG) && defined(DT_DIR) && defined(DT_LNK) && ! ( __APPLE__ || __MACH__ )
+#define D_TYPE(d) ((d)->d_type)
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_dirent.h b/usr/src/lib/libast/sparc/include/ast/ast_dirent.h
new file mode 100644
index 0000000000..08cebaf71a
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_dirent.h
@@ -0,0 +1,127 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/dirent by iffe version 2007-04-04 : : */
+
+#ifndef _def_dirent_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dirent_ast 1
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _nxt_dirent <../include/dirent.h> /* include path for the native <dirent.h> */
+#define _nxt_dirent_str "../include/dirent.h" /* include string for the native <dirent.h> */
+/*
+ * <dirent.h> for [fl]stat64 and off64_t
+ */
+
+#ifndef _AST_STD_H
+
+#include <../include/dirent.h> /* the native <dirent.h> */
+
+#else
+
+#ifndef _DIR64_H
+#define _DIR64_H
+
+#include <ast_std.h>
+
+#if _typ_off64_t
+#undef off_t
+#endif
+
+#include <../include/dirent.h> /* the native <dirent.h> */
+
+#if _typ_off64_t
+#define off_t off64_t
+#endif
+
+#if _lib_readdir64 && _typ_struct_dirent64
+#ifndef dirent
+#define dirent dirent64
+#endif
+#ifndef readdir
+#define readdir readdir64
+#endif
+#endif
+
+#endif
+
+#endif
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_fcntl.h b/usr/src/lib/libast/sparc/include/ast/ast_fcntl.h
new file mode 100644
index 0000000000..81b9c10bdf
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_fcntl.h
@@ -0,0 +1,135 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/fcntl.c by iffe version 2007-04-04 : : */
+#ifndef _def_fcntl_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fcntl_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <ast_fs.h>
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#define O_BINARY 0
+#define O_TEMPORARY 0
+#define O_TEXT 0
+
+#include <ast_fs.h>
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_fstat64
+#define fstat fstat64
+#endif
+#if _lib_lstat64
+#define lstat lstat64
+#endif
+#if _lib_stat64
+#define stat stat64
+#endif
+#if _lib_creat64
+#define creat creat64
+#endif
+#if _lib_mmap64
+#define mmap mmap64
+#endif
+#if _lib_open64
+#undef open
+#define open open64
+#endif
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_float.h b/usr/src/lib/libast/sparc/include/ast/ast_float.h
new file mode 100644
index 0000000000..c6cf96cce5
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_float.h
@@ -0,0 +1,234 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/float by iffe version 2007-04-04 : : */
+
+#ifndef _def_float_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_float_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_float 1 /* #include <float.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _hdr_values 1 /* #include <values.h> ok */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_frexp 1 /* frexp() in default lib(s) */
+#define _lib_frexpl 1 /* frexpl() in default lib(s) */
+#define _lib_ldexp 1 /* ldexp() in default lib(s) */
+#define _lib_ldexpl 1 /* ldexpl() in default lib(s) */
+#define _lib_finite 1 /* finite() in default lib(s) */
+#define _lib_isnan 1 /* isnan() in default lib(s) */
+#define _lib_isnanl 1 /* isnanl() in default lib(s) */
+#define _lib_copysign 1 /* copysign() in default lib(s) */
+#define _lib_copysignl 1 /* copysignl() in default lib(s) */
+#include <ast_common.h>
+#include <float.h>
+#include <math.h>
+#ifndef FLT_DIG
+#define FLT_DIG 6
+#endif
+#ifndef FLT_MAX
+#define FLT_MAX 3.4028234663852885981170E+38F
+#endif
+#ifndef FLT_MAX_10_EXP
+#define FLT_MAX_10_EXP ( + 38 )
+#endif
+#ifndef FLT_MAX_EXP
+#define FLT_MAX_EXP ( + 128 )
+#endif
+#ifndef FLT_MIN
+#define FLT_MIN 1.1754943508222875079688E-38F
+#endif
+#ifndef FLT_MIN_10_EXP
+#define FLT_MIN_10_EXP ( - 37 )
+#endif
+#ifndef FLT_MIN_EXP
+#define FLT_MIN_EXP ( - 125 )
+#endif
+#ifndef DBL_DIG
+#define DBL_DIG 15
+#endif
+#ifndef DBL_MAX
+#define DBL_MAX 1.7976931348623157081452E+308
+#endif
+#ifndef DBL_MAX_10_EXP
+#define DBL_MAX_10_EXP ( + 308 )
+#endif
+#ifndef DBL_MAX_EXP
+#define DBL_MAX_EXP ( + 1024 )
+#endif
+#ifndef DBL_MIN
+#define DBL_MIN 2.2250738585072013830903E-308
+#endif
+#ifndef DBL_MIN_10_EXP
+#define DBL_MIN_10_EXP ( - 307 )
+#endif
+#ifndef DBL_MIN_EXP
+#define DBL_MIN_EXP ( - 1021 )
+#endif
+#ifndef LDBL_DIG
+#define LDBL_DIG 33
+#endif
+#ifndef LDBL_MAX
+#define LDBL_MAX 1.189731495357231765085759326628007016E+4932L
+#endif
+#ifndef LDBL_MAX_10_EXP
+#define LDBL_MAX_10_EXP ( + 4932 )
+#endif
+#ifndef LDBL_MAX_EXP
+#define LDBL_MAX_EXP ( + 16384 )
+#endif
+#ifndef LDBL_MIN
+#define LDBL_MIN 3.362103143112093506262677817321752603E-4932L
+#endif
+#ifndef LDBL_MIN_10_EXP
+#define LDBL_MIN_10_EXP ( - 4931 )
+#endif
+#ifndef LDBL_MIN_EXP
+#define LDBL_MIN_EXP ( - 16381 )
+#endif
+
+
+#define USHRT_DIG 4
+#define UINT_DIG 9
+#define ULONG_DIG 9
+#define ULLONG_DIG 19
+#define UINTMAX_DIG ULLONG_DIG
+
+#define FLT_ULONG_MAX 4294967295.0F
+#define FLT_ULLONG_MAX 18446744073709551615.0F
+#define FLT_UINTMAX_MAX FLT_ULLONG_MAX
+#define FLT_LONG_MAX 2147483647.0F
+#define FLT_LLONG_MAX 9223372036854775807.0F
+#define FLT_INTMAX_MAX FLT_LLONG_MAX
+#define FLT_LONG_MIN (-2147483648.0F)
+#define FLT_LLONG_MIN (-9223372036854775808.0F)
+#define FLT_INTMAX_MIN FLT_LLONG_MIN
+
+#define DBL_ULONG_MAX 4294967295.0
+#define DBL_ULLONG_MAX 18446744073709551615.0
+#define DBL_UINTMAX_MAX DBL_ULLONG_MAX
+#define DBL_LONG_MAX 2147483647.0
+#define DBL_LLONG_MAX 9223372036854775807.0
+#define DBL_INTMAX_MAX DBL_LLONG_MAX
+#define DBL_LONG_MIN (-2147483648.0)
+#define DBL_LLONG_MIN (-9223372036854775808.0)
+#define DBL_INTMAX_MIN DBL_LLONG_MIN
+
+#define LDBL_ULONG_MAX 4294967295.0L
+#define LDBL_ULLONG_MAX 18446744073709551615.0L
+#define LDBL_UINTMAX_MAX LDBL_ULLONG_MAX
+#define LDBL_LONG_MAX 2147483647.0L
+#define LDBL_LLONG_MAX 9223372036854775807.0L
+#define LDBL_INTMAX_MAX LDBL_LLONG_MAX
+#define LDBL_LONG_MIN (-2147483648.0L)
+#define LDBL_LLONG_MIN (-9223372036854775808.0L)
+#define LDBL_INTMAX_MIN LDBL_LLONG_MIN
+
+#define FLTMAX_UINTMAX_MAX LDBL_UINTMAX_MAX
+#define FLTMAX_INTMAX_MAX LDBL_INTMAX_MAX
+#define FLTMAX_INTMAX_MIN LDBL_INTMAX_MIN
+
+typedef union _ast_dbl_exp_u
+{
+ uint32_t e[sizeof(double)/4];
+ double f;
+} _ast_dbl_exp_t;
+
+#define _ast_dbl_exp_index 0
+#define _ast_dbl_exp_shift 20
+
+typedef union _fltmax_exp_u
+{
+ uint32_t e[sizeof(_ast_fltmax_t)/4];
+ _ast_fltmax_t f;
+} _ast_fltmax_exp_t;
+
+#define _ast_fltmax_exp_index 0
+#define _ast_fltmax_exp_shift 16
+
+#define _ast_flt_unsigned_max_t unsigned long long
+#define _ast_flt_nan_init 0x7f,0xff,0xff,0xff
+#define _ast_flt_inf_init 0x7f,0x80,0x00,0x00
+#define _ast_dbl_nan_init 0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff
+#define _ast_dbl_inf_init 0x7f,0xf0,0x00,0x00,0x00,0x00,0x00,0x00
+#define _ast_ldbl_nan_init 0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
+#define _ast_ldbl_inf_init 0x7f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_fs.h b/usr/src/lib/libast/sparc/include/ast/ast_fs.h
new file mode 100644
index 0000000000..af7984f100
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_fs.h
@@ -0,0 +1,175 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/fs by iffe version 2007-04-04 : : */
+
+#ifndef _def_fs_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fs_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _lib_lstat 1 /* lstat() in default lib(s) */
+#define _lib_mknod 1 /* mknod() in default lib(s) */
+#define _lib_sync 1 /* sync() in default lib(s) */
+#include <sys/stat.h>
+#define FS_default "ufs"
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef major
+#define major(x) ( major_t ) ( ( ( ( unsigned ) ( ( x ) ) ) >> 8 ) & 0x7f )
+#endif
+#ifndef minor
+#define minor(x) ( minor_t ) ( ( ( x ) ) & 0xff )
+#endif
+#ifndef makedev
+#define makedev(x,y) ( unsigned short ) ( ( ( ( x ) ) << 8 ) | ( ( ( y ) ) & 0xff ) )
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _sys_mntent 1 /* #include <sys/mntent.h> ok */
+#define _sys_mnttab 1 /* #include <sys/mnttab.h> ok */
+#define _mem_st_blocks_stat 1 /* st_blocks is a member of struct stat */
+#define _mem_st_blksize_stat 1 /* st_blksize is a member of struct stat */
+#define _mem_st_rdev_stat 1 /* st_rdev is a member of struct stat */
+#define _sys_statfs 1 /* #include <sys/statfs.h> ok */
+#define _mem_f_files_statfs 1 /* f_files is a member of struct statfs */
+#define _sys_vfs 1 /* #include <sys/vfs.h> ok */
+#define _sys_param 1 /* #include <sys/param.h> ok */
+#define _sys_mount 1 /* #include <sys/mount.h> ok */
+#define _sys_statvfs 1 /* #include <sys/statvfs.h> ok */
+#define _mem_f_basetype_statvfs 1 /* f_basetype is a member of struct statvfs */
+#define _mem_f_frsize_statvfs 1 /* f_frsize is a member of struct statvfs */
+#define _lib_getmntent 1 /* getmntent() in default lib(s) */
+#define _lib_statfs 1 /* statfs() in default lib(s) */
+#define _lib_statvfs 1 /* statvfs() in default lib(s) */
+#define _lib_statfs4 1 /* compile{\ passed */
+#if _sys_statvfs
+#include <sys/statvfs.h>
+#if !_mem_statvfs_f_basetype
+#if _ary_f_reserved7
+#define f_basetype f_reserved7
+#endif
+#endif
+#else
+#define _mem_f_basetype_statvfs 1
+#define _mem_f_frsize_statvfs 1
+struct statvfs
+{
+unsigned long f_bsize; /* fundamental file system block size */
+unsigned long f_frsize; /* fragment size */
+unsigned long f_blocks; /* total # of blocks of f_frsize on fs */
+unsigned long f_bfree; /* total # of free blocks of f_frsize */
+unsigned long f_bavail; /* # of free blocks avail to non-superuser */
+unsigned long f_files; /* total # of file nodes (inodes) */
+unsigned long f_ffree; /* total # of free file nodes */
+unsigned long f_favail; /* # of free nodes avail to non-superuser */
+unsigned long f_fsid; /* file system id (dev for now) */
+char f_basetype[16]; /* target fs type name, null-terminated */
+unsigned long f_flag; /* bit-mask of flags */
+unsigned long f_namemax; /* maximum file name length */
+char f_fstr[32]; /* filesystem-specific string */
+unsigned long f_filler[16]; /* reserved for future expansion */
+};
+extern __MANGLE__ int fstatvfs __PROTO__((int, struct statvfs*));
+extern __MANGLE__ int statvfs __PROTO__((const char*, struct statvfs*));
+#endif
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_statvfs64 && !defined(statvfs)
+#define statvfs statvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int statvfs64 __PROTO__((const char*, struct statvfs64*));
+#endif
+#endif
+#if _lib_fstatvfs64 && !defined(fstatvfs)
+#define fstatvfs fstatvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int fstatvfs64 __PROTO__((int, struct statvfs64*));
+#endif
+#endif
+
+#define _str_st_fstype 1 /* stat.st_fstype is a string */
+#define _ary_st_pad4 1 /* stat.st_pad4 is an array */
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_getopt.h b/usr/src/lib/libast/sparc/include/ast/ast_getopt.h
new file mode 100644
index 0000000000..0de85c6172
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_getopt.h
@@ -0,0 +1,51 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * legacy standard getopt interface
+ */
+
+#ifndef _AST_GETOPT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_GETOPT_H 1
+
+extern __MANGLE__ int opterr;
+extern __MANGLE__ int optind;
+extern __MANGLE__ int optopt;
+extern __MANGLE__ char* optarg;
+
+#ifndef NULL /* in case <stdlib.h> or <stdio.h> got here first */
+
+extern __MANGLE__ int getopt __PROTO__((int, char* const*, const char*));
+extern __MANGLE__ int getsubopt __PROTO__((char**, char* const*, char**));
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_iconv.h b/usr/src/lib/libast/sparc/include/ast/ast_iconv.h
new file mode 100644
index 0000000000..b064ed1706
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_iconv.h
@@ -0,0 +1,153 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/iconv by iffe version 2007-04-04 : : */
+
+#ifndef _def_iconv_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_iconv_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_iconv 1 /* #include <iconv.h> ok */
+#define _lib_iconv_open 1 /* iconv_open() in default lib(s) */
+#define _lib_iconv_close 1 /* iconv_close() in default lib(s) */
+#define _lib_iconv 1 /* iconv() in default lib(s) */
+#define _nxt_iconv <../include/iconv.h> /* include path for the native <iconv.h> */
+#define _nxt_iconv_str "../include/iconv.h" /* include string for the native <iconv.h> */
+#include <ast_common.h>
+#include <ccode.h>
+#include <../include/iconv.h> /* the native iconv.h */
+
+#define CC_ICONV (-1)
+#define CC_UCS (-2)
+#define CC_SCU (-3)
+#define CC_UTF (-4)
+#define CC_UME (-5)
+
+#ifndef _ICONV_LIST_PRIVATE_
+#undef iconv_t
+#define iconv_t _ast_iconv_t
+#undef iconv_f
+#define iconv_f _ast_iconv_f
+#undef iconv_list_t
+#define iconv_list_t _ast_iconv_list_t
+#undef iconv_open
+#define iconv_open _ast_iconv_open
+#undef iconv
+#define iconv _ast_iconv
+#undef iconv_close
+#define iconv_close _ast_iconv_close
+#undef iconv_list
+#define iconv_list _ast_iconv_list
+#undef iconv_move
+#define iconv_move _ast_iconv_move
+#undef iconv_name
+#define iconv_name _ast_iconv_name
+#undef iconv_write
+#define iconv_write _ast_iconv_write
+#endif
+
+typedef Ccmap_t _ast_iconv_list_t;
+typedef __V_* _ast_iconv_t;
+typedef size_t (*_ast_iconv_f) __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ _ast_iconv_t _ast_iconv_open __PROTO__((const char*, const char*));
+extern __MANGLE__ size_t _ast_iconv __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+extern __MANGLE__ int _ast_iconv_close __PROTO__((_ast_iconv_t));
+extern __MANGLE__ _ast_iconv_list_t* _ast_iconv_list __PROTO__((_ast_iconv_list_t*));
+extern __MANGLE__ int _ast_iconv_name __PROTO__((const char*, char*, size_t));
+#if _SFIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, Sfio_t*, Sfio_t*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, Sfio_t*, char**, size_t*, size_t*));
+#else
+#if _SFSTDIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, FILE*, FILE*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, FILE*, char**, size_t*, size_t*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_lib.h b/usr/src/lib/libast/sparc/include/ast/ast_lib.h
new file mode 100644
index 0000000000..b0ba266538
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_lib.h
@@ -0,0 +1,192 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/lib by iffe version 2007-04-04 : : */
+#ifndef _def_lib_ast
+#define _def_lib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _hdr_fmtmsg 1 /* #include <fmtmsg.h> ok */
+#define _hdr_fnmatch 1 /* #include <fnmatch.h> ok */
+#define _hdr_libgen 1 /* #include <libgen.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_locale 1 /* #include <locale.h> ok */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_spawn 1 /* #include <spawn.h> ok */
+#define _hdr_syslog 1 /* #include <syslog.h> ok */
+#define _hdr_utime 1 /* #include <utime.h> ok */
+#define _hdr_wctype 1 /* #include <wctype.h> ok */
+#define _hdr_wchar 1 /* <wchar.h> and isw*() really work */
+#define _dat__tzname 1 /* _tzname in default lib(s) */
+#define _dat_tzname 1 /* tzname in default lib(s) */
+#define _lib__cleanup 1 /* _cleanup() in default lib(s) */
+#define _lib_atexit 1 /* atexit() in default lib(s) */
+#define _lib_bcopy 1 /* bcopy() in default lib(s) */
+#define _lib_bzero 1 /* bzero() in default lib(s) */
+#define _lib_catclose 1 /* catclose() in default lib(s) */
+#define _lib_catgets 1 /* catgets() in default lib(s) */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_confstr 1 /* confstr() in default lib(s) */
+#define _lib_dup2 1 /* dup2() in default lib(s) */
+#define _lib_execlp 1 /* execlp() in default lib(s) */
+#define _lib_execve 1 /* execve() in default lib(s) */
+#define _lib_execvp 1 /* execvp() in default lib(s) */
+#define _lib_fchmod 1 /* fchmod() in default lib(s) */
+#define _lib_fcntl 1 /* fcntl() in default lib(s) */
+#define _lib_fmtmsg 1 /* fmtmsg() in default lib(s) */
+#define _lib_fnmatch 1 /* fnmatch() in default lib(s) */
+#define _lib_fork 1 /* fork() in default lib(s) */
+#define _lib_fsync 1 /* fsync() in default lib(s) */
+#define _lib_getdents 1 /* getdents() in default lib(s) */
+#define _lib_getdtablesize 1 /* getdtablesize() in default lib(s) */
+#define _lib_getdate 1 /* getdate() in default lib(s) */
+#define _lib_getgroups 1 /* getgroups() in default lib(s) */
+#define _lib_gethostname 1 /* gethostname() in default lib(s) */
+#define _lib_getlogin 1 /* getlogin() in default lib(s) */
+#define _lib_getpagesize 1 /* getpagesize() in default lib(s) */
+#define _lib_getrlimit 1 /* getrlimit() in default lib(s) */
+#define _lib_getopt 1 /* getopt() in default lib(s) */
+#define _lib_getsubopt 1 /* getsubopt() in default lib(s) */
+#define _lib_getopt_long 1 /* getopt_long() in default lib(s) */
+#define _lib_getopt_long_only 1 /* getopt_long_only() in default lib(s) */
+#define _lib_glob 1 /* glob() in default lib(s) */
+#define _lib_index 1 /* index() in default lib(s) */
+#define _lib_iswblank 1 /* iswblank() in default lib(s) */
+#define _lib_iswctype 1 /* iswctype() in default lib(s) */
+#define _lib_killpg 1 /* killpg() in default lib(s) */
+#define _lib_link 1 /* link() in default lib(s) */
+#define _lib_localeconv 1 /* localeconv() in default lib(s) */
+#define _lib_madvise 1 /* madvise() in default lib(s) */
+#define _lib_mbtowc 1 /* mbtowc() in default lib(s) */
+#define _lib_mbrtowc 1 /* mbrtowc() in default lib(s) */
+#define _lib_memalign 1 /* memalign() in default lib(s) */
+#define _lib_memchr 1 /* memchr() in default lib(s) */
+#define _lib_memcpy 1 /* memcpy() in default lib(s) */
+#define _lib_memmove 1 /* memmove() in default lib(s) */
+#define _lib_memset 1 /* memset() in default lib(s) */
+#define _lib_mkdir 1 /* mkdir() in default lib(s) */
+#define _lib_mkfifo 1 /* mkfifo() in default lib(s) */
+#define _lib_mktemp 1 /* mktemp() in default lib(s) */
+#define _lib_mktime 1 /* mktime() in default lib(s) */
+#define _lib_mount 1 /* mount() in default lib(s) */
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _lib_pathconf 1 /* pathconf() in default lib(s) */
+#define _lib_readlink 1 /* readlink() in default lib(s) */
+#define _lib_remove 1 /* remove() in default lib(s) */
+#define _lib_rename 1 /* rename() in default lib(s) */
+#define _lib_rewinddir 1 /* rewinddir() in default lib(s) */
+#define _lib_rindex 1 /* rindex() in default lib(s) */
+#define _lib_rmdir 1 /* rmdir() in default lib(s) */
+#define _lib_setlocale 1 /* setlocale() in default lib(s) */
+#define _lib_setpgid 1 /* setpgid() in default lib(s) */
+#define _lib_setpgrp 1 /* setpgrp() in default lib(s) */
+#define _lib_setreuid 1 /* setreuid() in default lib(s) */
+#define _lib_setsid 1 /* setsid() in default lib(s) */
+#define _lib_setuid 1 /* setuid() in default lib(s) */
+#define _lib_sigaction 1 /* sigaction() in default lib(s) */
+#define _lib_sigprocmask 1 /* sigprocmask() in default lib(s) */
+#define _lib_socketpair 1 /* socketpair() in default lib(s) */
+#define _lib_strchr 1 /* strchr() in default lib(s) */
+#define _lib_strcoll 1 /* strcoll() in default lib(s) */
+#define _lib_strdup 1 /* strdup() in default lib(s) */
+#define _lib_strerror 1 /* strerror() in default lib(s) */
+#define _lib_strcasecmp 1 /* strcasecmp() in default lib(s) */
+#define _lib_strncasecmp 1 /* strncasecmp() in default lib(s) */
+#define _lib_strrchr 1 /* strrchr() in default lib(s) */
+#define _lib_strstr 1 /* strstr() in default lib(s) */
+#define _lib_strxfrm 1 /* strxfrm() in default lib(s) */
+#define _lib_strftime 1 /* strftime() in default lib(s) */
+#define _lib_swab 1 /* swab() in default lib(s) */
+#define _lib_symlink 1 /* symlink() in default lib(s) */
+#define _lib_sysconf 1 /* sysconf() in default lib(s) */
+#define _lib_sysinfo 1 /* sysinfo() in default lib(s) */
+#define _lib_syslog 1 /* syslog() in default lib(s) */
+#define _lib_telldir 1 /* telldir() in default lib(s) */
+#define _lib_tmpnam 1 /* tmpnam() in default lib(s) */
+#define _lib_tzset 1 /* tzset() in default lib(s) */
+#define _lib_unlink 1 /* unlink() in default lib(s) */
+#define _lib_utime 1 /* utime() in default lib(s) */
+#define _lib_wctype 1 /* wctype() in default lib(s) */
+#define _lib_ftruncate 1 /* ftruncate() in default lib(s) */
+#define _lib_truncate 1 /* truncate() in default lib(s) */
+#define _lib_creat64 1 /* creat64() in default lib(s) */
+#define _lib_fstat64 1 /* fstat64() in default lib(s) */
+#define _lib_fstatvfs64 1 /* fstatvfs64() in default lib(s) */
+#define _lib_ftruncate64 1 /* ftruncate64() in default lib(s) */
+#define _lib_lseek64 1 /* lseek64() in default lib(s) */
+#define _lib_lstat64 1 /* lstat64() in default lib(s) */
+#define _lib_open64 1 /* open64() in default lib(s) */
+#define _lib_readdir64 1 /* readdir64() in default lib(s) */
+#define _lib_stat64 1 /* stat64() in default lib(s) */
+#define _lib_statvfs64 1 /* statvfs64() in default lib(s) */
+#define _lib_truncate64 1 /* truncate64() in default lib(s) */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _lib_strtod 1 /* strtod() in default lib(s) */
+#define _lib_strtold 1 /* strtold() in default lib(s) */
+#define _lib_strtol 1 /* strtol() in default lib(s) */
+#define _lib_strtoll 1 /* strtoll() in default lib(s) */
+#define _lib_strtoul 1 /* strtoul() in default lib(s) */
+#define _lib_strtoull 1 /* strtoull() in default lib(s) */
+#define _mem_d_ino_dirent 1 /* d_ino is a member of struct dirent */
+#define _mem_d_off_dirent 1 /* d_off is a member of struct dirent */
+#define _mem_d_reclen_dirent 1 /* d_reclen is a member of struct dirent */
+#define _mem_DIR 1 /* DIR is a non-opaque struct */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _sys_jioctl 1 /* #include <sys/jioctl.h> ok */
+#define _sys_localedef 1 /* #include <sys/localedef.h> ok */
+#define _sys_ptem 1 /* #include <sys/ptem.h> ok */
+#define _sys_resource 1 /* #include <sys/resource.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _sys_stream 1 /* #include <sys/stream.h> ok */
+#define _sys_systeminfo 1 /* #include <sys/systeminfo.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_off64_t 1 /* off64_t is a type */
+#define _typ_struct_dirent64 1 /* struct dirent64 is a type */
+#define _tst_errno 1 /* errno can be assigned */
+#define _lib_poll_fd_1 1 /* fd is first arg to poll() */
+#define _lib_poll 1 /* _lib_poll_fd_1||_lib_poll_fd_2 is true */
+#define _lib_select 1 /* select() has standard 5 arg interface */
+#define _pipe_rw 1 /* full duplex pipes */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _lib_vfork 1 /* vfork exists and it works */
+#define _real_vfork 1 /* vfork child shares data with parent */
+#define _lib_posix_spawn 1 /* posix_spawn exists and it works and its worth using */
+#define _stream_peek 1 /* ioctl(I_PEEK) works */
+#define _socket_peek 1 /* recv(MSG_PEEK) works */
+#define _hdr_string 1 /* #include <string.h> ok */
+#define _lib_memcmp 1 /* standard memcmp interface that works */
+#define _hdr_fcntl 1 /* #include <fcntl.h> ok */
+#define _hdr_signal 1 /* #include <signal.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_memccpy 1 /* standard memccpy interface that works */
+#define _lib_utime_now 1 /* utime works with 0 time vector */
+#define _UNIV_DEFAULT "att" /* default universe name */
+#define _std_cleanup 1 /* stuck with standard _cleanup */
+#define _std_strcoll 1 /* standard strcoll works */
+#if !_AST_no_spawnveg
+#define _use_spawnveg 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_limits.h b/usr/src/lib/libast/sparc/include/ast/ast_limits.h
new file mode 100644
index 0000000000..3a8a7804d8
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_limits.h
@@ -0,0 +1,128 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/limits.c by iffe version 2007-04-04 : : */
+#ifndef _def_limits_ast
+#define _def_limits_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+#ifndef CHAR_MAX
+#define CHAR_MAX 127
+#endif
+#ifndef CHAR_MIN
+#define CHAR_MIN -128
+#endif
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC 1000000
+#endif
+#ifndef INT_MIN
+#define INT_MIN -2147483648
+#endif
+#ifndef LLONG_MAX
+#define LLONG_MAX 9223372036854775807
+#endif
+#ifndef LLONG_MIN
+#define LLONG_MIN -9223372036854775808
+#endif
+#ifndef LONG_MAX
+#define LONG_MAX 2147483647
+#endif
+#ifndef LONG_MIN
+#define LONG_MIN -2147483648
+#endif
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 5
+#endif
+#ifndef OPEN_MAX_CEIL
+#ifndef OPEN_MAX
+#define OPEN_MAX 256
+#endif
+#define OPEN_MAX_CEIL OPEN_MAX
+#endif
+#ifndef PTHREAD_STACK_MIN
+#define PTHREAD_STACK_MIN 4096
+#endif
+#ifndef PTRDIFF_MAX
+#define PTRDIFF_MAX 2147483647
+#endif
+#ifndef PTRDIFF_MIN
+#define PTRDIFF_MIN -2147483648
+#endif
+#ifndef SCHAR_MAX
+#define SCHAR_MAX 127
+#endif
+#ifndef SCHAR_MIN
+#define SCHAR_MIN -128
+#endif
+#ifndef SHRT_MIN
+#define SHRT_MIN -32768
+#endif
+#ifndef SIG_ATOMIC_MAX
+#define SIG_ATOMIC_MAX 2147483647
+#endif
+#ifndef SIG_ATOMIC_MIN
+#define SIG_ATOMIC_MIN -2147483648
+#endif
+#ifndef SIZE_MAX
+#ifndef UINT_MAX
+#define UINT_MAX 4294967295
+#endif
+#define SIZE_MAX UINT_MAX
+#endif
+#ifndef SSIZE_MAX
+#ifndef INT_MAX
+#define INT_MAX 2147483647
+#endif
+#define SSIZE_MAX INT_MAX
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+#ifndef UCHAR_MAX
+#define UCHAR_MAX 255
+#endif
+#ifndef ULLONG_MAX
+#define ULLONG_MAX 18446744073709551615
+#endif
+#ifndef ULONG_MAX
+#define ULONG_MAX 4294967295
+#endif
+#ifndef USHRT_MAX
+#define USHRT_MAX 65535
+#endif
+#ifndef WCHAR_MAX
+#define WCHAR_MAX 2147483647
+#endif
+#ifndef WCHAR_MIN
+#define WCHAR_MIN -2147483648
+#endif
+#ifndef WINT_MAX
+#define WINT_MAX 2147483647
+#endif
+#ifndef WINT_MIN
+#define WINT_MIN -2147483648
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_map.h b/usr/src/lib/libast/sparc/include/ast/ast_map.h
new file mode 100644
index 0000000000..247eba135d
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_map.h
@@ -0,0 +1,459 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/map.c by iffe version 2007-04-04 : : */
+#ifndef _def_map_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_map_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+/*
+ * prototypes provided for standard interfaces hijacked
+ * by ast and mapped to _ast_* but already prototyped
+ * unmapped in native headers included by <ast_std.h>
+ */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+
+#define _map_libc 1
+#undef basename
+#define basename _ast_basename
+#undef dirname
+#define dirname _ast_dirname
+#undef eaccess
+#define eaccess _ast_eaccess
+#undef execvpe
+#define execvpe _ast_execvpe
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+#undef fnmatch
+#define fnmatch _ast_fnmatch
+#undef fts_children
+#define fts_children _ast_fts_children
+#undef fts_close
+#define fts_close _ast_fts_close
+#undef fts_flags
+#define fts_flags _ast_fts_flags
+#undef fts_notify
+#define fts_notify _ast_fts_notify
+#undef fts_open
+#define fts_open _ast_fts_open
+#undef fts_read
+#define fts_read _ast_fts_read
+#undef fts_set
+#define fts_set _ast_fts_set
+#undef ftw
+#define ftw _ast_ftw
+#undef ftwalk
+#define ftwalk _ast_ftwalk
+#undef ftwflags
+#define ftwflags _ast_ftwflags
+#undef getcwd
+#define getcwd _ast_getcwd
+extern __MANGLE__ char* getcwd __PROTO__((char*, size_t));
+#undef getdate
+#define getdate _ast_getdate
+#undef getopt
+#define getopt _ast_getopt
+#undef getsubopt
+#define getsubopt _ast_getsubopt
+#undef getopt_long
+#define getopt_long _ast_getopt_long
+#undef getopt_long_only
+#define getopt_long_only _ast_getopt_long_only
+#undef getwd
+#define getwd _ast_getwd
+extern __MANGLE__ char* getwd __PROTO__((char*));
+#undef glob
+#define glob _ast_glob
+#undef globfree
+#define globfree _ast_globfree
+#undef memdup
+#define memdup _ast_memdup
+#undef memfatal
+#define memfatal _ast_memfatal
+#undef memhash
+#define memhash _ast_memhash
+#undef memsum
+#define memsum _ast_memsum
+#undef mkstemp
+#define mkstemp _ast_mkstemp
+extern __MANGLE__ int mkstemp __PROTO__((char*));
+#undef mktemp
+#define mktemp _ast_mktemp
+extern __MANGLE__ char* mktemp __PROTO__((char*));
+#undef mktime
+#define mktime _ast_mktime
+#undef nftw
+#define nftw _ast_nftw
+#undef optesc
+#define optesc _ast_optesc
+#undef optget
+#define optget _ast_optget
+#undef opthelp
+#define opthelp _ast_opthelp
+#undef optjoin
+#define optjoin _ast_optjoin
+#undef optstr
+#define optstr _ast_optstr
+#undef optusage
+#define optusage _ast_optusage
+#undef pathaccess
+#define pathaccess _ast_pathaccess
+#undef pathbin
+#define pathbin _ast_pathbin
+#undef pathcanon
+#define pathcanon _ast_pathcanon
+#undef pathcat
+#define pathcat _ast_pathcat
+#undef pathcd
+#define pathcd _ast_pathcd
+#undef pathcheck
+#define pathcheck _ast_pathcheck
+#undef pathexists
+#define pathexists _ast_pathexists
+#undef pathfind
+#define pathfind _ast_pathfind
+#undef pathgetlink
+#define pathgetlink _ast_pathgetlink
+#undef pathinclude
+#define pathinclude _ast_pathinclude
+#undef pathkey
+#define pathkey _ast_pathkey
+#undef pathnative
+#define pathnative _ast_pathnative
+#undef pathpath
+#define pathpath _ast_pathpath
+#undef pathposix
+#define pathposix _ast_pathposix
+#undef pathprobe
+#define pathprobe _ast_pathprobe
+#undef pathrepl
+#define pathrepl _ast_pathrepl
+#undef pathsetlink
+#define pathsetlink _ast_pathsetlink
+#undef pathshell
+#define pathshell _ast_pathshell
+#undef pathstat
+#define pathstat _ast_pathstat
+#undef pathtemp
+#define pathtemp _ast_pathtemp
+#undef pathtmp
+#define pathtmp _ast_pathtmp
+#undef procclose
+#define procclose _ast_procclose
+#undef procfree
+#define procfree _ast_procfree
+#undef procopen
+#define procopen _ast_procopen
+#undef procrun
+#define procrun _ast_procrun
+#undef putenv
+#define putenv _ast_putenv
+#undef re_comp
+#define re_comp _ast_re_comp
+#undef re_exec
+#define re_exec _ast_re_exec
+#undef realpath
+#define realpath _ast_realpath
+extern __MANGLE__ char* realpath __PROTO__((const char*, char*));
+#undef regaddclass
+#define regaddclass _ast_regaddclass
+#undef regalloc
+#define regalloc _ast_regalloc
+#undef regcache
+#define regcache _ast_regcache
+#undef regclass
+#define regclass _ast_regclass
+#undef regcmp
+#define regcmp _ast_regcmp
+#undef regcollate
+#define regcollate _ast_regcollate
+#undef regcomb
+#define regcomb _ast_regcomb
+#undef regcomp
+#define regcomp _ast_regcomp
+#undef regdecomp
+#define regdecomp _ast_regdecomp
+#undef regdup
+#define regdup _ast_regdup
+#undef regerror
+#define regerror _ast_regerror
+#undef regex
+#define regex _ast_regex
+#undef regexec
+#define regexec _ast_regexec
+#undef regfatal
+#define regfatal _ast_regfatal
+#undef regfatalpat
+#define regfatalpat _ast_regfatalpat
+#undef regfree
+#define regfree _ast_regfree
+#undef regncomp
+#define regncomp _ast_regncomp
+#undef regnexec
+#define regnexec _ast_regnexec
+#undef regrecord
+#define regrecord _ast_regrecord
+#undef regrexec
+#define regrexec _ast_regrexec
+#undef regstat
+#define regstat _ast_regstat
+#undef regsub
+#define regsub _ast_regsub
+#undef regsubcomp
+#define regsubcomp _ast_regsubcomp
+#undef regsubexec
+#define regsubexec _ast_regsubexec
+#undef regsubflags
+#define regsubflags _ast_regsubflags
+#undef regsubfree
+#define regsubfree _ast_regsubfree
+#undef remove
+#define remove _ast_remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#undef resolvepath
+#define resolvepath _ast_resolvepath
+extern __MANGLE__ char* resolvepath __PROTO__((const char*, char*, size_t));
+#undef setenv
+#define setenv _ast_setenv
+extern __MANGLE__ int setenv __PROTO__((const char*, const char*, int));
+#undef setenviron
+#define setenviron _ast_setenviron
+#undef sigcritical
+#define sigcritical _ast_sigcritical
+#undef signal
+#define signal _ast_signal
+#undef sigunblock
+#define sigunblock _ast_sigunblock
+#undef stracmp
+#define stracmp _ast_stracmp
+#undef strcopy
+#define strcopy _ast_strcopy
+#undef strelapsed
+#define strelapsed _ast_strelapsed
+#undef stresc
+#define stresc _ast_stresc
+#undef streval
+#define streval _ast_streval
+#undef strexpr
+#define strexpr _ast_strexpr
+#undef strftime
+#define strftime _ast_strftime
+#undef strgid
+#define strgid _ast_strgid
+#undef strgrpmatch
+#define strgrpmatch _ast_strgrpmatch
+#undef strhash
+#define strhash _ast_strhash
+#undef strkey
+#define strkey _ast_strkey
+#undef strlcat
+#define strlcat _ast_strlcat
+extern __MANGLE__ size_t strlcat __PROTO__((char*, const char*, size_t));
+#undef strlcpy
+#define strlcpy _ast_strlcpy
+extern __MANGLE__ size_t strlcpy __PROTO__((char*, const char*, size_t));
+#undef strlook
+#define strlook _ast_strlook
+#undef strmatch
+#define strmatch _ast_strmatch
+#undef strmode
+#define strmode _ast_strmode
+#undef strnacmp
+#define strnacmp _ast_strnacmp
+#undef strncopy
+#define strncopy _ast_strncopy
+#undef strntod
+#define strntod _ast_strntod
+#undef strntol
+#define strntol _ast_strntol
+#undef strntold
+#define strntold _ast_strntold
+#undef strntoll
+#define strntoll _ast_strntoll
+#undef strntoul
+#define strntoul _ast_strntoul
+#undef strntoull
+#define strntoull _ast_strntoull
+#undef stropt
+#define stropt _ast_stropt
+#undef strperm
+#define strperm _ast_strperm
+#undef strpsearch
+#define strpsearch _ast_strpsearch
+#undef strptime
+#define strptime _ast_strptime
+#undef strsearch
+#define strsearch _ast_strsearch
+#undef strsort
+#define strsort _ast_strsort
+#undef strsubmatch
+#define strsubmatch _ast_strsubmatch
+#undef strsum
+#define strsum _ast_strsum
+#undef strtape
+#define strtape _ast_strtape
+#undef strtoip4
+#define strtoip4 _ast_strtoip4
+#undef strton
+#define strton _ast_strton
+#undef strtonll
+#define strtonll _ast_strtonll
+#undef struid
+#define struid _ast_struid
+#undef struniq
+#define struniq _ast_struniq
+#undef system
+#define system _ast_system
+extern __MANGLE__ int system __PROTO__((const char*));
+#undef tempnam
+#define tempnam _ast_tempnam
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+#undef tmpnam
+#define tmpnam _ast_tmpnam
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+#undef touch
+#define touch _ast_touch
+#undef wordexp
+#define wordexp _ast_wordexp
+#undef wordfree
+#define wordfree _ast_wordfree
+#undef unsetenv
+#define unsetenv _ast_unsetenv
+
+/* cannot override local malloc */
+#define _map_malloc 1
+#undef calloc
+#define calloc _ast_calloc
+extern __MANGLE__ __V_* calloc __PROTO__((size_t, size_t));
+#undef cfree
+#define cfree _ast_cfree
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+#undef free
+#define free _ast_free
+extern __MANGLE__ void free __PROTO__((__V_*));
+#undef malloc
+#define malloc _ast_malloc
+extern __MANGLE__ __V_* malloc __PROTO__((size_t));
+#undef memalign
+#define memalign _ast_memalign
+extern __MANGLE__ __V_* memalign __PROTO__((size_t, size_t));
+#undef realloc
+#define realloc _ast_realloc
+extern __MANGLE__ __V_* realloc __PROTO__((__V_*, size_t));
+#undef strdup
+#define strdup _ast_strdup
+extern __MANGLE__ char* strdup __PROTO__((const char*));
+#undef valloc
+#define valloc _ast_valloc
+extern __MANGLE__ __V_* valloc __PROTO__((size_t));
+#undef strtol
+#define strtol _ast_strtol
+#undef strtoul
+#define strtoul _ast_strtoul
+#undef strtoll
+#define strtoll _ast_strtoll
+#undef strtoull
+#define strtoull _ast_strtoull
+#undef strtod
+#define strtod _ast_strtod
+#undef strtold
+#define strtold _ast_strtold
+extern __MANGLE__ long strtol __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned long strtoul __PROTO__((const char*, char**, int));
+extern __MANGLE__ double strtod __PROTO__((const char*, char**));
+#if !_UWIN
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
+extern __MANGLE__ _ast_fltmax_t strtold __PROTO__((const char*, char**));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+extern __MANGLE__ _ast_intmax_t strtoll __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned _ast_intmax_t strtoull __PROTO__((const char*, char**, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_mmap.h b/usr/src/lib/libast/sparc/include/ast/ast_mmap.h
new file mode 100644
index 0000000000..01528ff7cc
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_mmap.h
@@ -0,0 +1,47 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/mmap by iffe version 2007-04-04 : : */
+#ifndef _def_mmap_ast
+#define _def_mmap_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_mmap 1 /* standard mmap interface that works */
+#define _lib_mmap64 1 /* mmap64 interface and implementation work */
+#define _mmap_anon 1 /* use mmap MAP_ANON to get raw memory */
+#define _mmap_devzero 1 /* use mmap on /dev/zero to get raw memory */
+
+/* some systems get it wrong but escape concise detection */
+#ifndef _NO_MMAP
+#if __CYGWIN__
+#define _NO_MMAP 1
+#endif
+#endif
+
+#if _NO_MMAP
+#undef _lib_mmap
+#undef _lib_mmap64
+#undef _mmap_anon
+#undef _mmap_devzero
+#undef _mmap_worthy
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_mode.h b/usr/src/lib/libast/sparc/include/ast/ast_mode.h
new file mode 100644
index 0000000000..90b763b151
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_mode.h
@@ -0,0 +1,35 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/mode.c by iffe version 2007-04-04 : : */
+#ifndef _def_mode_ast
+#define _def_mode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define S_ITYPE(m) ((m)&S_IFMT)
+
+#define S_IPERM (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
+
+#define _S_IDPERM 1
+#define _S_IDTYPE 1
+
+#define BUFFERSIZE 8192
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_nl_types.h b/usr/src/lib/libast/sparc/include/ast/ast_nl_types.h
new file mode 100644
index 0000000000..15e008c056
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_nl_types.h
@@ -0,0 +1,123 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/nl_types by iffe version 2007-04-04 : : */
+
+#ifndef _def_nl_types_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_nl_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_nl_langinfo 1 /* nl_langinfo() in default lib(s) */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_langinfo 1 /* #include <langinfo.h> ok */
+#define _nxt_nl_types <../include/nl_types.h> /* include path for the native <nl_types.h> */
+#define _nxt_nl_types_str "../include/nl_types.h" /* include string for the native <nl_types.h> */
+#include <limits.h>
+#include <../include/nl_types.h> /* the native nl_types.h */
+
+#undef NL_SETMAX
+#define NL_SETMAX 1023
+#undef NL_MSGMAX
+#define NL_MSGMAX 32767
+#undef nl_catd
+#define nl_catd _ast_nl_catd
+#undef catopen
+#define catopen _ast_catopen
+#undef catgets
+#define catgets _ast_catgets
+#undef catclose
+#define catclose _ast_catclose
+
+typedef __V_* nl_catd;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ nl_catd catopen __PROTO__((const char*, int));
+extern __MANGLE__ char* catgets __PROTO__((nl_catd, int, int, const char*));
+extern __MANGLE__ int catclose __PROTO__((nl_catd));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_param.h b/usr/src/lib/libast/sparc/include/ast/ast_param.h
new file mode 100644
index 0000000000..810684662f
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_param.h
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/param.sh by iffe version 2007-04-04 : : */
+#ifndef _def_param_ast
+#define _def_param_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#include <sys/param.h>
+#ifndef S_IFDIR
+#include <sys/stat.h>
+#endif
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_standards.h b/usr/src/lib/libast/sparc/include/ast/ast_standards.h
new file mode 100644
index 0000000000..3571b54431
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_standards.h
@@ -0,0 +1,49 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/standards by iffe version 2007-04-04 : : */
+#ifndef _def_standards_ast
+#define _def_standards_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* _ALL_SOURCE & _ISOC99_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works */
+#ifndef _ALL_SOURCE
+#define _ALL_SOURCE 1
+#endif
+#ifndef _ISOC99_SOURCE
+#define _ISOC99_SOURCE 1
+#endif
+#ifndef _POSIX_SOURCE
+#define _POSIX_SOURCE 1
+#endif
+#ifndef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 21000101L
+#endif
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 9900
+#endif
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#ifndef __EXTENSIONS__
+#define __EXTENSIONS__ 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_std.h b/usr/src/lib/libast/sparc/include/ast/ast_std.h
new file mode 100644
index 0000000000..68e7984670
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_std.h
@@ -0,0 +1,343 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Advanced Software Technology Library
+ * AT&T Research
+ *
+ * a union of standard headers that works
+ * with local extensions enabled
+ * and local omission compensation
+ */
+
+#ifndef _AST_STD_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_STD_H 1
+#define _AST_STD_I 1
+
+#include <ast_common.h>
+
+#if _BLD_ast
+#define _BLD_cdt 1
+#define _BLD_sfio 1
+#if !_UWIN
+#define _BLD_vmalloc 1
+#endif
+#endif
+
+#ifdef _SFSTDIO_H
+#define _SKIP_SFSTDIO_H
+#else
+#define _SFSTDIO_H
+#ifndef FILE
+#ifndef _SFIO_H
+struct _sfio_s;
+#endif
+#define FILE struct _sfio_s
+#ifndef __FILE_typedef
+#define __FILE_typedef 1
+#endif
+#ifndef _FILEDEFED
+#define _FILEDEFED 1
+#endif
+#endif
+#endif
+
+#include <ast_lib.h>
+#include <ast_sys.h>
+#include <ast_getopt.h> /* <stdlib.h> does this */
+#include <ast_fcntl.h>
+#include <ast_limits.h>
+#include <ast_botch.h>
+
+#ifdef _SKIP_SFSTDIO_H
+#undef _SKIP_SFSTDIO_H
+#else
+#undef _SFSTDIO_H
+#undef FILE
+#endif
+
+/* locale stuff */
+
+#if !_hdr_locale
+
+struct lconv
+{
+ char* decimal_point;
+ char* thousands_sep;
+ char* grouping;
+ char* int_curr_symbol;
+ char* currency_symbol;
+ char* mon_decimal_point;
+ char* mon_thousands_sep;
+ char* mon_grouping;
+ char* positive_sign;
+ char* negative_sign;
+ char int_frac_digits;
+ char frac_digits;
+ char p_cs_precedes;
+ char p_sep_by_space;
+ char n_cs_precedes;
+ char n_sep_by_space;
+ char p_sign_posn;
+ char n_sign_posn;
+};
+
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#undef localeconv
+#define localeconv _ast_localeconv
+
+#undef setlocale
+#define setlocale _ast_setlocale
+
+#undef strerror
+#define strerror _ast_strerror
+
+extern __MANGLE__ struct lconv* localeconv __PROTO__((void));
+extern __MANGLE__ char* setlocale __PROTO__((int, const char*));
+extern __MANGLE__ char* strerror __PROTO__((int));
+
+#define AST_MESSAGE_SET 3 /* see <mc.h> mcindex() */
+
+/*
+ * maintain this order when adding categories
+ */
+
+#define AST_LC_ALL 0
+#define AST_LC_COLLATE 1
+#define AST_LC_CTYPE 2
+#define AST_LC_MESSAGES 3
+#define AST_LC_MONETARY 4
+#define AST_LC_NUMERIC 5
+#define AST_LC_TIME 6
+#define AST_LC_IDENTIFICATION 7
+#define AST_LC_ADDRESS 8
+#define AST_LC_NAME 9
+#define AST_LC_TELEPHONE 10
+#define AST_LC_XLITERATE 11
+#define AST_LC_MEASUREMENT 12
+#define AST_LC_PAPER 13
+#define AST_LC_COUNT 14
+
+#define AST_LC_find (1L<<28)
+#define AST_LC_debug (1L<<29)
+#define AST_LC_setlocale (1L<<30)
+#define AST_LC_translate (1L<<31)
+
+#ifndef LC_ALL
+#define LC_ALL (-AST_LC_ALL)
+#endif
+#ifndef LC_COLLATE
+#define LC_COLLATE (-AST_LC_COLLATE)
+#endif
+#ifndef LC_CTYPE
+#define LC_CTYPE (-AST_LC_CTYPE)
+#endif
+#ifndef LC_MESSAGES
+#define LC_MESSAGES (-AST_LC_MESSAGES)
+#endif
+#ifndef LC_MONETARY
+#define LC_MONETARY (-AST_LC_MONETARY)
+#endif
+#ifndef LC_NUMERIC
+#define LC_NUMERIC (-AST_LC_NUMERIC)
+#endif
+#ifndef LC_TIME
+#define LC_TIME (-AST_LC_TIME)
+#endif
+#ifndef LC_ADDRESS
+#define LC_ADDRESS (-AST_LC_ADDRESS)
+#endif
+#ifndef LC_IDENTIFICATION
+#define LC_IDENTIFICATION (-AST_LC_IDENTIFICATION)
+#endif
+#ifndef LC_NAME
+#define LC_NAME (-AST_LC_NAME)
+#endif
+#ifndef LC_TELEPHONE
+#define LC_TELEPHONE (-AST_LC_TELEPHONE)
+#endif
+#ifndef LC_XLITERATE
+#define LC_XLITERATE (-AST_LC_XLITERATE)
+#endif
+#ifndef LC_MEASUREMENT
+#define LC_MEASUREMENT (-AST_LC_MEASUREMENT)
+#endif
+#ifndef LC_PAPER
+#define LC_PAPER (-AST_LC_PAPER)
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#undef strcoll
+#if _std_strcoll
+#define strcoll _ast_info.collate
+#else
+#define strcoll strcmp
+#endif
+
+typedef struct
+{
+
+ char* id;
+
+ struct
+ {
+ uint32_t serial;
+ uint32_t set;
+ } locale;
+
+ long tmp_long;
+ size_t tmp_size;
+ short tmp_short;
+ char tmp_char;
+ wchar_t tmp_wchar;
+
+ int (*collate) __PROTO__((const char*, const char*));
+
+ int tmp_int;
+ __V_* tmp_pointer;
+
+ int mb_cur_max;
+ int (*mb_len) __PROTO__((const char*, size_t));
+ int (*mb_towc) __PROTO__((wchar_t*, const char*, size_t));
+ size_t (*mb_xfrm) __PROTO__((char*, const char*, size_t));
+ int (*mb_width) __PROTO__((wchar_t));
+ int (*mb_conv) __PROTO__((char*, wchar_t));
+
+ uint32_t env_serial;
+
+ char pad[944];
+
+} _Ast_info_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ _Ast_info_t _ast_info;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+/* largefile hackery -- ast uses the large versions by default */
+
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if !defined(ftruncate) && _lib_ftruncate64
+#define ftruncate ftruncate64
+extern __MANGLE__ int ftruncate64 __PROTO__((int, off64_t));
+#endif
+#if !defined(lseek) && _lib_lseek64
+#define lseek lseek64
+extern __MANGLE__ off64_t lseek64 __PROTO__((int, off64_t, int));
+#endif
+#if !defined(truncate) && _lib_truncate64
+#define truncate truncate64
+extern __MANGLE__ int truncate64 __PROTO__((const char*, off64_t));
+#endif
+
+/* direct macro access for bsd crossover */
+
+#if !defined(__cplusplus)
+
+#if !defined(memcpy) && !defined(_lib_memcpy) && defined(_lib_bcopy)
+#define memcpy(t,f,n) (bcopy(f,t,n),(t))
+#endif
+
+#if !defined(memzero) && !defined(_lib_memzero)
+#if defined(_lib_memset) || !defined(_lib_bzero)
+#define memzero(b,n) memset(b,0,n)
+#else
+#define memzero(b,n) (bzero(b,n),(b))
+#endif
+#endif
+
+#endif
+
+#if !defined(remove)
+extern __MANGLE__ int remove __PROTO__((const char*));
+#endif
+
+#if !defined(rename)
+extern __MANGLE__ int rename __PROTO__((const char*, const char*));
+#endif
+
+#if !defined(strchr) && !defined(_lib_strchr) && defined(_lib_index)
+#define strchr(s,c) index(s,c)
+#endif
+
+#if !defined(strrchr) && !defined(_lib_strrchr) && defined(_lib_rindex)
+#define strrchr(s,c) rindex(s,c)
+#endif
+
+/* and now introducing prototypes botched by the standard(s) */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#undef getpgrp
+#define getpgrp() _ast_getpgrp()
+extern __MANGLE__ int _ast_getpgrp __PROTO__((void));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+/*
+ * and finally, standard interfaces hijacked by ast
+ * _ATS_STD_I delays headers that require <ast_map.h>
+ */
+
+#include <ast_map.h>
+
+#undef _AST_STD_I
+
+#if _REGEX_H < 0
+#undef _REGEX_H
+#include <regex.h>
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_stdio.h b/usr/src/lib/libast/sparc/include/ast/ast_stdio.h
new file mode 100644
index 0000000000..3e85be0e7e
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_stdio.h
@@ -0,0 +1,600 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/stdio by iffe version 2007-04-04 : : */
+
+#ifndef _SFSTDIO_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SFSTDIO_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define __FILE_typedef 1
+#define _FILE_DEFINED 1
+#define _FILE_defined 1
+#define _FILEDEFED 1
+
+#ifndef __FILE_TAG
+#define __FILE_TAG _sfio_s
+#endif
+
+#undef FILE
+#undef _FILE
+#undef fpos_t
+#undef fpos64_t
+
+typedef struct _sfio_s _sfio_FILE;
+
+#define FILE _sfio_FILE
+#define _FILE FILE
+
+#if !defined(__FILE) && !__CYGWIN__
+#undef __FILE
+#define __FILE FILE
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define BUFSIZ SF_BUFSIZE
+
+#else
+
+#ifndef BUFSIZ
+#define BUFSIZ 8192
+#endif
+
+#ifndef EOF
+#define EOF (-1)
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+#include <ast_std.h>
+
+#include <sfio_s.h>
+
+#if __cplusplus
+#define _sf_(f) (f)
+#else
+#define _sf_(f) ((struct _sfio_s*)(f))
+#endif
+
+#define _SF_EOF 0000200
+#define _SF_ERROR 0000400
+
+#endif
+
+#ifdef _NO_LARGEFILE64_SOURCE
+#undef _LARGEFILE64_SOURCE
+#endif
+
+#ifdef _LARGEFILE64_SOURCE
+#undef off_t
+#endif
+
+#define fpos_t _ast_fpos_t
+#if _typ_int64_t
+#define fpos64_t _ast_fpos_t
+#endif
+
+typedef struct _ast_fpos_s
+{
+ intmax_t _sf_offset;
+ unsigned char _sf_state[64 - sizeof(intmax_t)];
+} _ast_fpos_t;
+
+#define _base _data
+#define _ptr _next
+#define _IOFBF 0
+#define _IONBF 1
+#define _IOLBF 2
+
+#if defined(__cplusplus) && defined(__THROW) && !defined(_UWIN)
+
+#undef FILE
+#define FILE FILE
+typedef struct _sfio_s FILE;
+
+#undef strerror
+extern __MANGLE__ char* strerror(int) __THROW;
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#endif
+
+#ifndef FILENAME_MAX
+#define FILENAME_MAX 1024
+#endif
+#ifndef FOPEN_MAX
+#define FOPEN_MAX 20
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+
+#define _doprnt _ast_doprnt
+#define _doscan _ast_doscan
+#define asprintf _ast_asprintf
+#define clearerr _ast_clearerr
+#define fclose _ast_fclose
+#define fdopen _ast_fdopen
+#define fflush _ast_fflush
+#define fgetc _ast_fgetc
+#define fgetpos _ast_fgetpos
+#define fgetpos64 _ast_fgetpos64
+#define fgets _ast_fgets
+#define fopen _ast_fopen
+#define fprintf _ast_fprintf
+#define fpurge _ast_fpurge
+#define fputs _ast_fputs
+#define fread _ast_fread
+#define freopen _ast_freopen
+#define fscanf _ast_fscanf
+#define fseek _ast_fseek
+#define fseek64 _ast_fseek64
+#define fseeko _ast_fseeko
+#define fseeko64 _ast_fseeko64
+#define fsetpos _ast_fsetpos
+#define fsetpos64 _ast_fsetpos64
+#define ftell _ast_ftell
+#define ftell64 _ast_ftell64
+#define ftello _ast_ftello
+#define ftello64 _ast_ftello64
+#define fwrite _ast_fwrite
+#define gets _ast_gets
+#define getw _ast_getw
+#define pclose _ast_pclose
+#define popen _ast_popen
+#define printf _ast_printf
+#define puts _ast_puts
+#define putw _ast_putw
+#define rewind _ast_rewind
+#define scanf _ast_scanf
+#define setbuf _ast_setbuf
+#undef setbuffer
+#define setbuffer _ast_setbuffer
+#define setlinebuf _ast_setlinebuf
+#define setvbuf _ast_setvbuf
+#define snprintf _ast_snprintf
+#define sprintf _ast_sprintf
+#define sscanf _ast_sscanf
+#define tmpfile _ast_tmpfile
+#define ungetc _ast_ungetc
+#define vasprintf _ast_vasprintf
+#define vfprintf _ast_vfprintf
+#define vfscanf _ast_vfscanf
+#define vprintf _ast_vprintf
+#define vscanf _ast_vscanf
+#define vsnprintf _ast_vsnprintf
+#define vsprintf _ast_vsprintf
+#define vsscanf _ast_vsscanf
+#define fcloseall _ast_fcloseall
+#define fmemopen _ast_fmemopen
+#define __getdelim _ast___getdelim
+#define getdelim _ast_getdelim
+#define getline _ast_getline
+#define clearerr_unlocked _ast_clearerr_unlocked
+#define feof_unlocked _ast_feof_unlocked
+#define ferror_unlocked _ast_ferror_unlocked
+#define fflush_unlocked _ast_fflush_unlocked
+#define fgetc_unlocked _ast_fgetc_unlocked
+#define fgets_unlocked _ast_fgets_unlocked
+#define fileno_unlocked _ast_fileno_unlocked
+#define fputc_unlocked _ast_fputc_unlocked
+#define fputs_unlocked _ast_fputs_unlocked
+#define fread_unlocked _ast_fread_unlocked
+#define fwrite_unlocked _ast_fwrite_unlocked
+#define getc_unlocked _ast_getc_unlocked
+#define getchar_unlocked _ast_getchar_unlocked
+#define putc_unlocked _ast_putc_unlocked
+#define putchar_unlocked _ast_putchar_unlocked
+
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef P_tmpdir
+#define P_tmpdir "/var/tmp/" /*NOCATLITERAL*/
+#endif
+#ifndef L_ctermid
+#define L_ctermid 9
+#endif
+#ifndef L_tmpnam
+#define L_tmpnam 25
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#if defined(__cplusplus) && defined(__THROW)
+extern __MANGLE__ char* ctermid(char*) __THROW;
+#else
+extern __MANGLE__ char* ctermid __PROTO__((char*));
+#endif
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+extern __MANGLE__ void perror __PROTO__((const char*));
+#ifndef _AST_STD_H
+#ifndef remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#endif
+#ifndef rename
+extern __MANGLE__ int rename __PROTO__((const char*, const char*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#ifdef _LARGEFILE64_SOURCE
+
+#undef fpos_t
+#undef off_t
+#undef fgetpos
+#undef fsetpos
+#undef fseek
+#undef fseeko
+#undef ftell
+#undef ftello
+
+#define fpos_t fpos64_t
+#if _typ_off64_t
+#define off_t off64_t
+#else
+#define off_t int64_t
+#endif
+
+#define fgetpos fgetpos64
+#define fsetpos fsetpos64
+#define fseek fseek64
+#define fseeko fseeko64
+#define ftell ftell64
+#define ftello ftello64
+
+#endif
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_DLL && _DLL_INDIRECT_DATA
+
+#define stdin ((FILE*)_ast_dll->_ast_stdin)
+#define stdout ((FILE*)_ast_dll->_ast_stdout)
+#define stderr ((FILE*)_ast_dll->_ast_stderr)
+
+#else
+
+#define stdin (&_Sfstdin)
+#define stdout (&_Sfstdout)
+#define stderr (&_Sfstderr)
+
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define feof(f) sfeof(f)
+#define ferror(f) sferror(f)
+#define fileno(f) sffileno(f)
+#define fputc(c,f) sfputc(f,c)
+#define getc(f) sfgetc(f)
+#define getchar() sfgetc(sfstdin)
+#define putc(c,f) sfputc(f,c)
+#define putchar(c) sfputc(sfstdout,c)
+
+#else
+
+#if !_UWIN
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+#endif
+
+extern __MANGLE__ FILE _Sfstdin;
+extern __MANGLE__ FILE _Sfstdout;
+extern __MANGLE__ FILE _Sfstderr;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define feof(f) (_sf_(f)->_flags&_SF_EOF)
+#define ferror(f) (_sf_(f)->_flags&_SF_ERROR)
+#define fileno(f) (_sf_(f)->_file)
+#define fputc(c,f) (_sf_(f)->_next>=_sf_(f)->_endw?_sfflsbuf(_sf_(f),(int)((unsigned char)(c))):(int)(*_sf_(f)->_next++=(unsigned char)(c)))
+#define getc(f) (_sf_(f)->_next>=_sf_(f)->_endr?_sffilbuf(_sf_(f),0):(int)(*_sf_(f)->_next++))
+#define getchar() getc(stdin)
+#define putc(c,f) fputc(c,f)
+#define putchar(c) fputc(c,stdout)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _sffilbuf __PROTO__((FILE*, int));
+extern __MANGLE__ int _sfflsbuf __PROTO__((FILE*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_sys.h b/usr/src/lib/libast/sparc/include/ast/ast_sys.h
new file mode 100644
index 0000000000..eb8ae4221f
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_sys.h
@@ -0,0 +1,172 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/sys by iffe version 2007-04-04 : : */
+
+#ifndef _AST_SYS_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_SYS_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#if __mips == 2 && !defined(_NO_LARGEFILE64_SOURCE)
+#define _NO_LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_NO_LARGEFILE64_SOURCE) && _typ_off64_t && _lib_lseek64 && _lib_stat64
+#if !defined(_LARGEFILE64_SOURCE)
+#define _LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_LARGEFILE_SOURCE)
+#define _LARGEFILE_SOURCE 1
+#endif
+#else
+#undef _LARGEFILE64_SOURCE
+#undef _LARGEFILE_SOURCE
+#undef _typ_off64_t
+#undef _typ_struct_dirent64
+#undef _lib_creat64
+#undef _lib_fstat64
+#undef _lib_fstatvfs64
+#undef _lib_ftruncate64
+#undef _lib_lseek64
+#undef _lib_lstat64
+#undef _lib_mmap64
+#undef _lib_open64
+#undef _lib_readdir64
+#undef _lib_stat64
+#undef _lib_statvfs64
+#undef _lib_truncate64
+#endif
+#if defined(__STDC__) && !defined(__USE_FIXED_PROTOTYPES__)
+#define __USE_FIXED_PROTOTYPES__ 1 /* kick gcc out of the past */
+#endif
+#include <stdlib.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <locale.h>
+#include <sys/localedef.h>
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _typ_dev_t 1 /* dev_t is a type */
+#define _typ_nlink_t 1 /* nlink_t is a type */
+#define _typ_gid_t 1 /* gid_t is a type */
+#define _typ_mode_t 1 /* mode_t is a type */
+#define _typ_uid_t 1 /* uid_t is a type */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _typ_wchar_t 1 /* wchar_t is a type */
+#define _typ_pid_t 1 /* pid_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _typ_wint_t 1 /* wint_t is a type */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _typ_socklen_t 1 /* socklen_t is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_ino_t 1 /* ino_t is a type */
+#define _typ_off_t 1 /* off_t is a type */
+#define _typ_ptrdiff_t 1 /* ptrdiff_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#define _typ_div_t 1 /* div_t is a type */
+#define _typ_ldiv_t 1 /* ldiv_t is a type */
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+extern __MANGLE__ int eaccess __PROTO__((const char*, int));
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+extern __MANGLE__ __V_* pvalloc __PROTO__((size_t));
+extern __MANGLE__ pid_t spawnveg __PROTO__((const char*, char* const[], char* const[], pid_t));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#if !defined(va_start)
+#if defined(__STDARG__)
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_time.h b/usr/src/lib/libast/sparc/include/ast/ast_time.h
new file mode 100644
index 0000000000..1171a4e1b5
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_time.h
@@ -0,0 +1,104 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/time by iffe version 2007-04-04 : : */
+
+#ifndef _def_time_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_time_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_nanosleep 1 /* nanosleep() in default lib(s) */
+#define _lib_usleep 1 /* usleep() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#include <sys/time.h>
+
+#include <sys/times.h>
+
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC CLK_TCK
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_tty.h b/usr/src/lib/libast/sparc/include/ast/ast_tty.h
new file mode 100644
index 0000000000..430c3305c4
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_tty.h
@@ -0,0 +1,155 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/tty by iffe version 2007-04-04 : : */
+#ifndef _def_tty_ast
+#define _def_tty_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_termios 1 /* #include <termios.h> ok */
+#define _hdr_termio 1 /* #include <termio.h> ok */
+#define _hdr_sgtty 1 /* #include <sgtty.h> ok */
+#define _sys_termios 1 /* #include <sys/termios.h> ok */
+#define _sys_termio 1 /* #include <sys/termio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _lib_tcgetattr 1 /* tcgetattr() in default lib(s) */
+#define _lib_tcgetpgrp 1 /* tcgetpgrp() in default lib(s) */
+#define _mac__POSIX_VDISABLE 1 /* _POSIX_VDISABLE is a macro */
+
+#ifdef _hdr_termios
+# if _mac__POSIX_VDISABLE
+# undef _POSIX_VDISABLE
+# endif
+# include <termios.h>
+#else
+# if defined(_sys_termios) && defined(_lib_tcgetattr)
+# include <sys/termios.h>
+# define _hdr_termios 1
+# else
+# undef _sys_termios
+# endif /* _sys_termios */
+#endif /* _hdr_termios */
+
+#ifdef _hdr_termios
+# undef _hdr_sgtty
+# undef tcgetattr
+# undef tcsetattr
+# undef tcgetpgrp
+# undef tcsetpgrp
+# undef cfgetospeed
+# ifndef TCSANOW
+# define TCSANOW TCSETS
+# define TCSADRAIN TCSETSW
+# define TCSAFLUSH TCSETSF
+# endif /* TCSANOW */
+ /* The following corrects bugs in some implementations */
+# if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
+# define TCSAFLUSH TCSADFLUSH
+# endif /* TCSADFLUSH */
+# ifndef _lib_tcgetattr
+# undef tcgetattr
+# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
+# undef tcsetattr
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# undef cfgetospeed
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# endif /* _lib_tcgetattr */
+# undef TIOCGETC
+#else
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfgetispeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfsetispeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# define cfsetospeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# ifdef _hdr_termio
+# include <termio.h>
+# else
+# ifdef _sys_termio
+# include <sys/termio.h>
+# define _hdr_termio 1
+# endif /* _sys_termio */
+# endif /* _hdr_termio */
+# ifdef _hdr_termio
+# define termios termio
+# undef TIOCGETC
+# define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+
+# ifdef _sys_bsdtty
+# include <sys/bsdtty.h>
+# endif /* _sys_bsdtty */
+# else
+# ifdef _hdr_sgtty
+# include <sgtty.h>
+# ifndef LPENDIN
+# ifdef _sys_nttyio
+# include <sys/nttyio.h>
+# endif /* _sys_nttyio */
+# endif /* LPENDIN */
+# define termios sgttyb
+# ifdef TIOCSETN
+# undef TCSETAW
+# endif /* TIOCSETN */
+# ifdef TIOCGETP
+# define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# else
+# define tcgetattr(fd,tty) gtty(fd, tty)
+# define tcsetattr(fd,action,tty) stty(fd, tty)
+# endif /* TIOCGETP */
+# else
+# ifdef _sys_ttyio
+# include <sys/ttyio.h>
+# endif
+# endif /* _hdr_sgtty */
+# endif /* hdr_termio */
+
+# ifndef TCSANOW
+# ifdef TCSETAW
+# define TCSANOW TCSETA
+# define TCSAFLUSH TCSETAF
+# else
+# ifdef TIOCSETN
+# define TCSANOW TIOCSETN
+# define TCSADRAIN TIOCSETN
+# define TCSAFLUSH TIOCSETP
+# endif /* TIOCSETN */
+# endif /* TCSETAW */
+# endif /* TCSANOW */
+#endif /* _hdr_termios */
+
+/* set ECHOCTL if driver can echo control charaters as ^c */
+#ifdef LCTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LCTLECH
+# endif /* !ECHOCTL */
+#endif /* LCTLECH */
+#ifdef LNEW_CTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LNEW_CTLECH
+# endif /* !ECHOCTL */
+#endif /* LNEW_CTLECH */
+#ifdef LNEW_PENDIN
+# ifndef PENDIN
+# define PENDIN LNEW_PENDIN
+# endif /* !PENDIN */
+#endif /* LNEW_PENDIN */
+
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_types.h b/usr/src/lib/libast/sparc/include/ast/ast_types.h
new file mode 100644
index 0000000000..6449f59df8
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_types.h
@@ -0,0 +1,26 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_types_ast
+#define _def_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_version.h b/usr/src/lib/libast/sparc/include/ast/ast_version.h
new file mode 100644
index 0000000000..0e586f9555
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_version.h
@@ -0,0 +1,10 @@
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+#define _AST_VERSION 20061111L
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_vfork.h b/usr/src/lib/libast/sparc/include/ast/ast_vfork.h
new file mode 100644
index 0000000000..24e96c3105
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_vfork.h
@@ -0,0 +1,89 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/vfork by iffe version 2007-04-04 : : */
+
+#ifndef _def_vfork_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_vfork_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+extern __MANGLE__ pid_t vfork __PROTO__((void));
+#pragma unknown_control_flow(vfork)
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_wait.h b/usr/src/lib/libast/sparc/include/ast/ast_wait.h
new file mode 100644
index 0000000000..f875aa1ad5
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_wait.h
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/wait by iffe version 2007-04-04 : : */
+#ifndef _def_wait_ast
+#define _def_wait_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_wait 1 /* wait() in default lib(s) */
+#define _lib_wait3 1 /* wait3() in default lib(s) */
+#define _lib_wait4 1 /* wait4() in default lib(s) */
+#define _lib_waitpid 1 /* waitpid() in default lib(s) */
+#define _sys_wait 1 /* #include <sys/wait.h> ok */
+#define _ok_wif 1 /* posix wait macros ok */
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_wchar.h b/usr/src/lib/libast/sparc/include/ast/ast_wchar.h
new file mode 100644
index 0000000000..d637e9e18a
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_wchar.h
@@ -0,0 +1,208 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/wchar by iffe version 2007-04-04 : : */
+
+#ifndef _def_wchar_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_wchar_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _lib_mbstowcs 1 /* mbstowcs() in default lib(s) */
+#define _lib_wctomb 1 /* wctomb() in default lib(s) */
+#define _lib_wcrtomb 1 /* wcrtomb() in default lib(s) */
+#define _lib_wcslen 1 /* wcslen() in default lib(s) */
+#define _lib_wcstombs 1 /* wcstombs() in default lib(s) */
+#define _lib_wcwidth 1 /* wcwidth() in default lib(s) */
+#define _lib_towlower 1 /* towlower() in default lib(s) */
+#define _lib_towupper 1 /* towupper() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_mbstate_t 1 /* mbstate_t is a type */
+#define _nxt_wchar <../include/wchar.h> /* include path for the native <wchar.h> */
+#define _nxt_wchar_str "../include/wchar.h" /* include string for the native <wchar.h> */
+#ifndef _SFSTDIO_H
+#include <ast_common.h>
+#include <stdio.h>
+#endif
+#if _hdr_wchar && defined(_nxt_wchar)
+#include <../include/wchar.h> /* the native wchar.h */
+#endif
+#if _hdr_wctype
+#include <wctype.h>
+#endif
+
+#ifndef WEOF
+#define WEOF (-1)
+#endif
+
+#undef fgetwc
+#undef fgetws
+#undef fputwc
+#undef fputws
+#undef getwc
+#undef getwchar
+#undef getws
+#undef putwc
+#undef putwchar
+#undef ungetwc
+
+#define fgetwc _ast_fgetwc
+#define fgetws _ast_fgetws
+#define fputwc _ast_fputwc
+#define fputws _ast_fputws
+#define fwide _ast_fwide
+#define fwprintf _ast_fwprintf
+#define fwscanf _ast_fwscanf
+#define getwc _ast_getwc
+#define getwchar _ast_getwchar
+#define getws _ast_getws
+#define putwc _ast_putwc
+#define putwchar _ast_putwchar
+#define swprintf _ast_swprintf
+#define swscanf _ast_swscanf
+#define ungetwc _ast_ungetwc
+#define vfwprintf _ast_vfwprintf
+#define vfwscanf _ast_vfwscanf
+#define vswprintf _ast_vswprintf
+#define vswscanf _ast_vswscanf
+#define vwprintf _ast_vwprintf
+#define vwscanf _ast_vwscanf
+#define wprintf _ast_wprintf
+#define wscanf _ast_wscanf
+
+#if !_typ_mbstate_t
+#undef _typ_mbstate_t
+#define _typ_mbstate_t 1
+typedef char mbstate_t;
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#if !_lib_mbstowcs
+extern __MANGLE__ size_t mbstowcs __PROTO__((wchar_t*, const char*, size_t));
+#endif
+#if !_lib_wctomb
+extern __MANGLE__ int wctomb __PROTO__((char*, wchar_t));
+#endif
+#if !_lib_wcrtomb
+extern __MANGLE__ size_t wcrtomb __PROTO__((char*, wchar_t, mbstate_t*));
+#endif
+#if !_lib_wcslen
+extern __MANGLE__ size_t wcslen __PROTO__((const wchar_t*));
+#endif
+#if !_lib_wcstombs
+extern __MANGLE__ size_t wcstombs __PROTO__((char*, const wchar_t*, size_t));
+#endif
+
+extern __MANGLE__ int fwprintf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ int fwscanf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ wint_t fgetwc __PROTO__((FILE*));
+extern __MANGLE__ wchar_t* fgetws __PROTO__((wchar_t*, int, FILE*));
+extern __MANGLE__ wint_t fputwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ int fputws __PROTO__((const wchar_t*, FILE*));
+extern __MANGLE__ int fwide __PROTO__((FILE*, int));
+extern __MANGLE__ wint_t getwc __PROTO__((FILE*));
+extern __MANGLE__ wint_t getwchar __PROTO__((void));
+extern __MANGLE__ wchar_t* getws __PROTO__((wchar_t*));
+extern __MANGLE__ wint_t putwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ wint_t putwchar __PROTO__((wchar_t));
+extern __MANGLE__ int swprintf __PROTO__((wchar_t*, size_t, const wchar_t*, ...));
+extern __MANGLE__ int swscanf __PROTO__((const wchar_t*, const wchar_t*, ...));
+extern __MANGLE__ wint_t ungetwc __PROTO__((wint_t, FILE*));
+extern __MANGLE__ int vfwprintf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vfwscanf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vwprintf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vwscanf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vswprintf __PROTO__((wchar_t*, size_t, const wchar_t*, va_list));
+extern __MANGLE__ int vswscanf __PROTO__((const wchar_t*, const wchar_t*, va_list));
+extern __MANGLE__ int wprintf __PROTO__((const wchar_t*, ...));
+extern __MANGLE__ int wscanf __PROTO__((const wchar_t*, ...));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ast_windows.h b/usr/src/lib/libast/sparc/include/ast/ast_windows.h
new file mode 100644
index 0000000000..90e0260f59
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ast_windows.h
@@ -0,0 +1,48 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * AT&T Research
+ *
+ * ast <windows.h> wrapper
+ * for libast only
+ * include after ast headers
+ */
+
+#ifndef _AST_WINDOWS_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_WINDOWS_H 1
+
+#undef SF_ERROR /* clash in <oaidl.h> */
+
+#include <windows.h>
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/bytesex.h b/usr/src/lib/libast/sparc/include/ast/bytesex.h
new file mode 100644
index 0000000000..2bf2022afb
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/bytesex.h
@@ -0,0 +1,43 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * linux/gnu compatibility
+ */
+
+#ifndef _BYTESEX_H
+#define _BYTESEX_H
+
+#include <ast_common.h>
+
+#undef __BYTE_ORDER
+
+#if ( _ast_intswap & 3 ) == 3
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#else
+#if ( _ast_intswap & 3 ) == 1
+#define __BYTE_ORDER __PDP_ENDIAN
+#else
+#define __BYTE_ORDER __BIG_ENDIAN
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ccode.h b/usr/src/lib/libast/sparc/include/ast/ccode.h
new file mode 100644
index 0000000000..d26926ebc4
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ccode.h
@@ -0,0 +1,101 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * character code map interface
+ *
+ * NOTE: used for mapping between 8-bit character encodings
+ * ISO character sets are handled by sfio
+ */
+
+#ifndef _CHARCODE_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _CHARCODE_H 1
+
+#include <ast.h>
+#include <ast_ccode.h>
+
+typedef struct Ccmap_s
+{
+ const char* name; /* code set name */
+ const char* match; /* strmatch() pattern */
+ const char* desc; /* code set description */
+ const char* canon; /* canonical name format */
+ const char* index; /* default index */
+ int ccode; /* <ccode.h> code index */
+ __V_* data; /* map specific data */
+} Ccmap_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ unsigned char* _ccmap __PROTO__((int, int));
+extern __MANGLE__ __V_* _ccmapcpy __PROTO__((unsigned char*, __V_*, const __V_*, size_t));
+extern __MANGLE__ __V_* _ccmapstr __PROTO__((unsigned char*, __V_*, size_t));
+
+extern __MANGLE__ int ccmapid __PROTO__((const char*));
+extern __MANGLE__ char* ccmapname __PROTO__((int));
+extern __MANGLE__ __V_* ccnative __PROTO__((__V_*, const __V_*, size_t));
+extern __MANGLE__ Ccmap_t* ccmaplist __PROTO__((Ccmap_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define CCOP(i,o) ((i)==(o)?0:(((o)<<8)|(i)))
+#define CCIN(x) ((x)&0xFF)
+#define CCOUT(x) (((x)>>8)&0xFF)
+#define CCCONVERT(x) ((x)&0xFF00)
+
+#define CCCVT(x) CCMAP(x,0)
+#define CCMAP(i,o) ((i)==(o)?(unsigned char*)0:_ccmap(i,o))
+#define CCMAPCHR(m,c) ((m)?(m)[c]:(c))
+#define CCMAPCPY(m,t,f,n) ((m)?_ccmapcpy(m,t,f,n):memcpy(t,f,n))
+#define CCMAPSTR(m,s,n) ((m)?_ccmapstr(m,s,n):(__V_*)(s))
+
+#define ccmap(i,o) CCMAP(i,o)
+#define ccmapchr(m,c) CCMAPCHR(m,c)
+#define ccmapcpy(m,t,f,n) CCMAPCPY(m,t,f,n)
+#define ccmapstr(m,s,n) CCMAPSTR(m,s,n)
+
+#define CCMAPC(c,i,o) ((i)==(o)?(c):CCMAP(i,o)[c])
+#define CCMAPM(t,f,n,i,o) ((i)==(o)?memcpy(t,f,n):_ccmapcpy(CCMAP(i,o),t,f,n))
+#define CCMAPS(s,n,i,o) ((i)==(o)?(__V_*)(s):_ccmapstr(CCMAP(i,o),s,n))
+
+#define ccmapc(c,i,o) CCMAPC(c,i,o)
+#define ccmapm(t,f,n,i,o) CCMAPM(t,f,n,i,o)
+#define ccmaps(s,n,i,o) CCMAPS(s,n,i,o)
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/cdt.h b/usr/src/lib/libast/sparc/include/ast/cdt.h
new file mode 100644
index 0000000000..f6274cef92
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/cdt.h
@@ -0,0 +1,311 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _CDT_H
+#define _CDT_H 1
+
+/* Public interface for the dictionary library
+**
+** Written by Kiem-Phong Vo
+*/
+
+#define CDT_VERSION 20050420L
+
+#if _PACKAGE_ast
+#include <ast_std.h>
+#else
+#include <ast_common.h>
+#endif
+
+typedef struct _dtlink_s Dtlink_t;
+typedef struct _dthold_s Dthold_t;
+typedef struct _dtdisc_s Dtdisc_t;
+typedef struct _dtmethod_s Dtmethod_t;
+typedef struct _dtdata_s Dtdata_t;
+typedef struct _dt_s Dt_t;
+typedef struct _dt_s Dict_t; /* for libdict compatibility */
+typedef struct _dtstat_s Dtstat_t;
+typedef Void_t* (*Dtsearch_f)_ARG_((Dt_t*,Void_t*,int));
+typedef Void_t* (*Dtmake_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*));
+typedef void (*Dtfree_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*));
+typedef int (*Dtcompar_f)_ARG_((Dt_t*,Void_t*,Void_t*,Dtdisc_t*));
+typedef unsigned int (*Dthash_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*));
+typedef Void_t* (*Dtmemory_f)_ARG_((Dt_t*,Void_t*,size_t,Dtdisc_t*));
+typedef int (*Dtevent_f)_ARG_((Dt_t*,int,Void_t*,Dtdisc_t*));
+
+struct _dtlink_s
+{ Dtlink_t* right; /* right child */
+ union
+ { unsigned int _hash; /* hash value */
+ Dtlink_t* _left; /* left child */
+ } hl;
+};
+
+/* private structure to hold an object */
+struct _dthold_s
+{ Dtlink_t hdr; /* header */
+ Void_t* obj; /* user object */
+};
+
+/* method to manipulate dictionary structure */
+struct _dtmethod_s
+{ Dtsearch_f searchf; /* search function */
+ int type; /* type of operation */
+};
+
+/* stuff that may be in shared memory */
+struct _dtdata_s
+{ int type; /* type of dictionary */
+ Dtlink_t* here; /* finger to last search element */
+ union
+ { Dtlink_t** _htab; /* hash table */
+ Dtlink_t* _head; /* linked list */
+ } hh;
+ int ntab; /* number of hash slots */
+ int size; /* number of objects */
+ int loop; /* number of nested loops */
+ int minp; /* min path before splay, always even */
+ /* for hash dt, > 0: fixed table size */
+};
+
+/* structure to hold methods that manipulate an object */
+struct _dtdisc_s
+{ int key; /* where the key begins in an object */
+ int size; /* key size and type */
+ int link; /* offset to Dtlink_t field */
+ Dtmake_f makef; /* object constructor */
+ Dtfree_f freef; /* object destructor */
+ Dtcompar_f comparf;/* to compare two objects */
+ Dthash_f hashf; /* to compute hash value of an object */
+ Dtmemory_f memoryf;/* to allocate/free memory */
+ Dtevent_f eventf; /* to process events */
+};
+
+#define DTDISC(dc,ky,sz,lk,mkf,frf,cmpf,hshf,memf,evf) \
+ ( (dc)->key = (ky), (dc)->size = (sz), (dc)->link = (lk), \
+ (dc)->makef = (mkf), (dc)->freef = (frf), \
+ (dc)->comparf = (cmpf), (dc)->hashf = (hshf), \
+ (dc)->memoryf = (memf), (dc)->eventf = (evf) )
+
+#ifdef offsetof
+#define DTOFFSET(struct_s, member) offsetof(struct_s, member)
+#else
+#define DTOFFSET(struct_s, member) ((int)(&((struct_s*)0)->member))
+#endif
+
+/* the dictionary structure itself */
+struct _dt_s
+{ Dtsearch_f searchf;/* search function */
+ Dtdisc_t* disc; /* method to manipulate objs */
+ Dtdata_t* data; /* sharable data */
+ Dtmemory_f memoryf;/* function to alloc/free memory */
+ Dtmethod_t* meth; /* dictionary method */
+ int type; /* type information */
+ int nview; /* number of parent view dictionaries */
+ Dt_t* view; /* next on viewpath */
+ Dt_t* walk; /* dictionary being walked */
+ Void_t* user; /* for user's usage */
+};
+
+/* structure to get status of a dictionary */
+struct _dtstat_s
+{ int dt_meth; /* method type */
+ int dt_size; /* number of elements */
+ int dt_n; /* number of chains or levels */
+ int dt_max; /* max size of a chain or a level */
+ int* dt_count; /* counts of chains or levels by size */
+};
+
+/* flag set if the last search operation actually found the object */
+#define DT_FOUND 0100000
+
+/* supported storage methods */
+#define DT_SET 0000001 /* set with unique elements */
+#define DT_BAG 0000002 /* multiset */
+#define DT_OSET 0000004 /* ordered set (self-adjusting tree) */
+#define DT_OBAG 0000010 /* ordered multiset */
+#define DT_LIST 0000020 /* linked list */
+#define DT_STACK 0000040 /* stack */
+#define DT_QUEUE 0000100 /* queue */
+#define DT_METHODS 0000177 /* all currently supported methods */
+
+/* asserts to dtdisc() */
+#define DT_SAMECMP 0000001 /* compare methods equivalent */
+#define DT_SAMEHASH 0000002 /* hash methods equivalent */
+
+/* types of search */
+#define DT_INSERT 0000001 /* insert object if not found */
+#define DT_DELETE 0000002 /* delete object if found */
+#define DT_SEARCH 0000004 /* look for an object */
+#define DT_NEXT 0000010 /* look for next element */
+#define DT_PREV 0000020 /* find previous element */
+#define DT_RENEW 0000040 /* renewing an object */
+#define DT_CLEAR 0000100 /* clearing all objects */
+#define DT_FIRST 0000200 /* get first object */
+#define DT_LAST 0000400 /* get last object */
+#define DT_MATCH 0001000 /* find object matching key */
+#define DT_VSEARCH 0002000 /* search using internal representation */
+#define DT_ATTACH 0004000 /* attach an object to the dictionary */
+#define DT_DETACH 0010000 /* detach an object from the dictionary */
+
+/* events */
+#define DT_OPEN 1 /* a dictionary is being opened */
+#define DT_CLOSE 2 /* a dictionary is being closed */
+#define DT_DISC 3 /* discipline is about to be changed */
+#define DT_METH 4 /* method is about to be changed */
+#define DT_ENDOPEN 5 /* dtopen() is done */
+#define DT_ENDCLOSE 6 /* dtclose() is done */
+#define DT_HASHSIZE 7 /* setting hash table size */
+
+_BEGIN_EXTERNS_ /* public data */
+#if _BLD_cdt && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+#if !_BLD_cdt && defined(__IMPORT__)
+#define extern __IMPORT__
+#endif
+
+extern Dtmethod_t* Dtset;
+extern Dtmethod_t* Dtbag;
+extern Dtmethod_t* Dtoset;
+extern Dtmethod_t* Dtobag;
+extern Dtmethod_t* Dtlist;
+extern Dtmethod_t* Dtstack;
+extern Dtmethod_t* Dtqueue;
+
+/* compatibility stuff; will go away */
+#ifndef KPVDEL
+extern Dtmethod_t* Dtorder;
+extern Dtmethod_t* Dttree;
+extern Dtmethod_t* Dthash;
+extern Dtmethod_t _Dttree;
+extern Dtmethod_t _Dthash;
+extern Dtmethod_t _Dtlist;
+extern Dtmethod_t _Dtqueue;
+extern Dtmethod_t _Dtstack;
+#endif
+
+#undef extern
+_END_EXTERNS_
+
+_BEGIN_EXTERNS_ /* public functions */
+#if _BLD_cdt && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Dt_t* dtopen _ARG_((Dtdisc_t*, Dtmethod_t*));
+extern int dtclose _ARG_((Dt_t*));
+extern Dt_t* dtview _ARG_((Dt_t*, Dt_t*));
+extern Dtdisc_t* dtdisc _ARG_((Dt_t* dt, Dtdisc_t*, int));
+extern Dtmethod_t* dtmethod _ARG_((Dt_t*, Dtmethod_t*));
+
+extern Dtlink_t* dtflatten _ARG_((Dt_t*));
+extern Dtlink_t* dtextract _ARG_((Dt_t*));
+extern int dtrestore _ARG_((Dt_t*, Dtlink_t*));
+
+extern int dttreeset _ARG_((Dt_t*, int, int));
+
+extern int dtwalk _ARG_((Dt_t*, int(*)(Dt_t*,Void_t*,Void_t*), Void_t*));
+
+extern Void_t* dtrenew _ARG_((Dt_t*, Void_t*));
+
+extern int dtsize _ARG_((Dt_t*));
+extern int dtstat _ARG_((Dt_t*, Dtstat_t*, int));
+extern unsigned int dtstrhash _ARG_((unsigned int, Void_t*, int));
+
+#if !_PACKAGE_ast
+extern int memcmp _ARG_((const Void_t*, const Void_t*, size_t));
+extern int strcmp _ARG_((const char*, const char*));
+#endif
+
+#undef extern
+_END_EXTERNS_
+
+/* internal functions for translating among holder, object and key */
+#define _DT(dt) ((Dt_t*)(dt))
+#define _DTDSC(dc,ky,sz,lk,cmpf) \
+ (ky = (dc)->key, sz = (dc)->size, lk = (dc)->link, cmpf = (dc)->comparf)
+#define _DTLNK(o,lk) ((Dtlink_t*)((char*)(o) + lk) )
+#define _DTOBJ(e,lk) ((lk) < 0 ? ((Dthold_t*)(e))->obj : (Void_t*)((char*)(e) - (lk)) )
+#define _DTKEY(o,ky,sz) (Void_t*)((sz) < 0 ? *((char**)((char*)(o)+(ky))) : ((char*)(o)+(ky)))
+
+#define _DTCMP(dt,k1,k2,dc,cmpf,sz) \
+ ((cmpf) ? (*cmpf)(dt,k1,k2,dc) : \
+ ((sz) <= 0 ? strcmp(k1,k2) : memcmp(k1,k2,sz)) )
+#define _DTHSH(dt,ky,dc,sz) ((dc)->hashf ? (*(dc)->hashf)(dt,ky,dc) : dtstrhash(0,ky,sz) )
+
+/* special search function for tree structure only */
+#define _DTMTCH(dt,key,action) \
+ do { Dtlink_t* _e; Void_t *_o, *_k, *_key; Dtdisc_t* _dc; \
+ int _ky, _sz, _lk, _cmp; Dtcompar_f _cmpf; \
+ _dc = (dt)->disc; _DTDSC(_dc, _ky, _sz, _lk, _cmpf); \
+ _key = (key); \
+ for(_e = (dt)->data->here; _e; _e = _cmp < 0 ? _e->hl._left : _e->right) \
+ { _o = _DTOBJ(_e, _lk); _k = _DTKEY(_o, _ky, _sz); \
+ if((_cmp = _DTCMP((dt), _key, _k, _dc, _cmpf, _sz)) == 0) \
+ break; \
+ } \
+ action (_e ? _o : (Void_t*)0); \
+ } while(0)
+
+#define _DTSRCH(dt,obj,action) \
+ do { Dtlink_t* _e; Void_t *_o, *_k, *_key; Dtdisc_t* _dc; \
+ int _ky, _sz, _lk, _cmp; Dtcompar_f _cmpf; \
+ _dc = (dt)->disc; _DTDSC(_dc, _ky, _sz, _lk, _cmpf); \
+ _key = _DTKEY(obj, _ky, _sz); \
+ for(_e = (dt)->data->here; _e; _e = _cmp < 0 ? _e->hl._left : _e->right) \
+ { _o = _DTOBJ(_e, _lk); _k = _DTKEY(_o, _ky, _sz); \
+ if((_cmp = _DTCMP((dt), _key, _k, _dc, _cmpf, _sz)) == 0) \
+ break; \
+ } \
+ action (_e ? _o : (Void_t*)0); \
+ } while(0)
+
+#define DTTREEMATCH(dt,key,action) _DTMTCH(_DT(dt),(Void_t*)(key),action)
+#define DTTREESEARCH(dt,obj,action) _DTSRCH(_DT(dt),(Void_t*)(obj),action)
+
+#define dtvnext(d) (_DT(d)->view)
+#define dtvcount(d) (_DT(d)->nview)
+#define dtvhere(d) (_DT(d)->walk)
+
+#define dtlink(d,e) (((Dtlink_t*)(e))->right)
+#define dtobj(d,e) _DTOBJ((e), _DT(d)->disc->link)
+#define dtfinger(d) (_DT(d)->data->here ? dtobj((d),_DT(d)->data->here):(Void_t*)(0))
+
+#define dtfirst(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_FIRST)
+#define dtnext(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_NEXT)
+#define dtleast(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH|DT_NEXT)
+#define dtlast(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_LAST)
+#define dtprev(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_PREV)
+#define dtmost(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH|DT_PREV)
+#define dtsearch(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH)
+#define dtmatch(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_MATCH)
+#define dtinsert(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_INSERT)
+#define dtdelete(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_DELETE)
+#define dtattach(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_ATTACH)
+#define dtdetach(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_DETACH)
+#define dtclear(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_CLEAR)
+#define dtfound(d) (_DT(d)->type & DT_FOUND)
+
+#define DT_PRIME 17109811 /* 2#00000001 00000101 00010011 00110011 */
+#define dtcharhash(h,c) (((unsigned int)(h) + (unsigned int)(c)) * DT_PRIME )
+
+#endif /* _CDT_H */
diff --git a/usr/src/lib/libast/sparc/include/ast/debug.h b/usr/src/lib/libast/sparc/include/ast/debug.h
new file mode 100644
index 0000000000..ad7ecb7a54
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/debug.h
@@ -0,0 +1,63 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * common ast debug definitions
+ * include after the ast headers
+ */
+
+#ifndef _DEBUG_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _DEBUG_H
+
+#include <ast.h>
+#include <error.h>
+
+#if DEBUG || _BLD_DEBUG
+#define debug(x) x
+#define message(x) do if (error_info.trace < 0) { error x; } while (0)
+#define messagef(x) do if (error_info.trace < 0) { errorf x; } while (0)
+#else
+#define debug(x)
+#define message(x)
+#define messagef(x)
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ void systrace __PROTO__((const char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/dirent.h b/usr/src/lib/libast/sparc/include/ast/dirent.h
new file mode 100644
index 0000000000..32f33800b5
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/dirent.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_dirent.h>
diff --git a/usr/src/lib/libast/sparc/include/ast/dt.h b/usr/src/lib/libast/sparc/include/ast/dt.h
new file mode 100644
index 0000000000..0b7c331577
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/dt.h
@@ -0,0 +1,49 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+#ifndef _DT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _DT_H 1
+
+#include <cdt.h>
+#include <vmalloc.h>
+
+#if _BLD_cdt && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Dt_t* dtnew __PROTO__((Vmalloc_t*, Dtdisc_t*, Dtmethod_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/endian.h b/usr/src/lib/libast/sparc/include/ast/endian.h
new file mode 100644
index 0000000000..2299b5a3bc
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/endian.h
@@ -0,0 +1,54 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * linux/gnu compatibility
+ */
+
+#ifndef _ENDIAN_H
+#define _ENDIAN_H
+
+#include <bytesex.h>
+
+#define __LITTLE_ENDIAN 1234
+#define __BIG_ENDIAN 4321
+#define __PDP_ENDIAN 3412
+
+#if defined (__USE_BSD) && !defined(__STRICT_ANSI__)
+
+#ifndef LITTLE_ENDIAN
+#define LITTLE_ENDIAN __LITTLE_ENDIAN
+#endif
+
+#ifndef BIG_ENDIAN
+#define BIG_ENDIAN __BIG_ENDIAN
+#endif
+
+#ifndef PDP_ENDIAN
+#define PDP_ENDIAN __PDP_ENDIAN
+#endif
+
+#undef BYTE_ORDER
+#define BYTE_ORDER __BYTE_ORDER
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/error.h b/usr/src/lib/libast/sparc/include/ast/error.h
new file mode 100644
index 0000000000..d6d171a15e
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/error.h
@@ -0,0 +1,196 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * option, error and message formatter external definitions
+ */
+
+#ifndef _ERROR_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _ERROR_H
+
+#include <ast.h>
+#include <option.h>
+#include <errno.h>
+
+#define ERROR_VERSION 20070319L
+
+#if !defined(errno) && defined(__DYNAMIC__)
+#define errno __DYNAMIC__(errno)
+#endif
+
+#define ERROR_debug(n) (-(n))
+#define ERROR_exit(n) ((n)+ERROR_ERROR)
+#define ERROR_system(n) (((n)+ERROR_ERROR)|ERROR_SYSTEM)
+#define ERROR_usage(n) ((((n)?2:0)+ERROR_ERROR)|ERROR_USAGE)
+#define ERROR_warn(n) (ERROR_WARNING)
+
+#ifndef ERROR_catalog
+#define ERROR_catalog(t) t
+#endif
+#ifndef ERROR_dictionary
+#define ERROR_dictionary(t) t
+#endif
+
+#ifndef ERROR_translate
+#define ERROR_translating() (error_info.translate&&(ast.locale.set&(1<<AST_LC_MESSAGES)))
+#define ERROR_translate(l,i,d,m) (ERROR_translating()?errorx((const char*)l,(const char*)i,(const char*)d,(const char*)m):(m))
+#endif
+
+#define ERROR_INFO 0 /* info message -- no err_id */
+#define ERROR_WARNING 1 /* warning message */
+#define ERROR_ERROR 2 /* error message -- no err_exit */
+#define ERROR_FATAL 3 /* error message with err_exit */
+#define ERROR_NOEXEC EXIT_NOEXEC /* shell convention */
+#define ERROR_NOENT EXIT_NOTFOUND /* shell convention */
+#define ERROR_PANIC ERROR_LEVEL /* panic message with err_exit */
+
+#define ERROR_LEVEL 0x00ff /* level portion of status */
+#define ERROR_SYSTEM 0x0100 /* report system errno message */
+#define ERROR_OUTPUT 0x0200 /* next arg is error fd */
+#define ERROR_SOURCE 0x0400 /* next 2 args are FILE,LINE */
+#define ERROR_USAGE 0x0800 /* usage message */
+#define ERROR_PROMPT 0x1000 /* omit trailing newline */
+#define ERROR_NOID 0x2000 /* omit err_id */
+#define ERROR_LIBRARY 0x4000 /* library routine error */
+
+#define ERROR_INTERACTIVE 0x0001 /* context is interactive */
+#define ERROR_SILENT 0x0002 /* context is silent */
+#define ERROR_NOTIFY 0x0004 /* main(-sig,0,ctx) on signal */
+
+#define ERROR_FREE 0x0010 /* free context on pop */
+#define ERROR_POP 0x0020 /* pop context */
+#define ERROR_PUSH 0x0040 /* push context */
+#define ERROR_SET 0x0080 /* set context */
+
+/*
+ * errorpush()/errorpop() are obsolete -- use errorctx() instead
+ */
+
+#ifndef ERROR_CONTEXT_T
+#define ERROR_CONTEXT_T Error_info_t
+#endif
+
+#define ERROR_CONTEXT_BASE ((Error_context_t*)&error_info.context)
+
+#define errorpush(p,f) (*(p)= *ERROR_CONTEXT_BASE,*ERROR_CONTEXT_BASE=error_info.empty,error_info.context=(Error_context_t*)(p),error_info.flags=(f))
+#define errorpop(p) (*ERROR_CONTEXT_BASE= *(p))
+
+typedef struct Error_info_s Error_info_t;
+typedef struct Error_context_s Error_context_t;
+
+#define ERROR_CONTEXT \
+ ERROR_CONTEXT_T* context; /* prev context stack element */ \
+ int errors; /* >= ERROR_ERROR count */ \
+ int flags; /* context flags */ \
+ int line; /* input|output line number */ \
+ int warnings; /* ERROR_WARNING count */ \
+ char* file; /* input|output file name */ \
+ char* id; /* command id */
+
+struct Error_context_s /* context stack element */
+{
+ ERROR_CONTEXT
+};
+
+struct Error_info_s /* error state */
+{
+ int fd; /* write(2) fd */
+
+ void (*exit) __PROTO__((int)); /* error exit */
+ ssize_t (*write) __PROTO__((int, const __V_*, size_t)); /* error output */
+
+ /* the rest are implicitly initialized */
+
+ int clear; /* default clear ERROR_* flags */
+ int core; /* level>=core -> core dump */
+ int indent; /* debug trace indent level */
+ int init; /* initialized */
+ int last_errno; /* last reported errno */
+ int mask; /* multi level debug trace mask */
+ int set; /* default set ERROR_* flags */
+ int trace; /* debug trace level */
+
+ char* version; /* ERROR_SOURCE command version */
+
+ int (*auxilliary) __PROTO__((Sfio_t*, int, int)); /* aux info to append */
+
+ ERROR_CONTEXT /* top of context stack */
+
+ Error_context_t empty; /* empty context stack element */
+
+ unsigned long time; /* debug time trace */
+
+ char* (*translate) __PROTO__((const char*, const char*, const char*, const char*)); /* format translator */
+
+ const char* catalog; /* message catalog */
+};
+
+#ifndef errno
+extern __MANGLE__ int errno; /* system call error status */
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Error_info_t* _error_infop_;
+
+#define error_info (*_error_infop_)
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ void error __PROTO__((int, ...));
+extern __MANGLE__ int errormsg __PROTO__((const char*, int, ...));
+extern __MANGLE__ int errorf __PROTO__((__V_*, __V_*, int, ...));
+extern __MANGLE__ void errorv __PROTO__((const char*, int, va_list));
+#ifndef errorx
+extern __MANGLE__ char* errorx __PROTO__((const char*, const char*, const char*, const char*));
+#endif
+extern __MANGLE__ Error_info_t* errorctx __PROTO__((Error_info_t*, int, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/find.h b/usr/src/lib/libast/sparc/include/ast/find.h
new file mode 100644
index 0000000000..0caf2019cf
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/find.h
@@ -0,0 +1,97 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * fast find interface definitions
+ */
+
+#ifndef _FIND_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FIND_H
+
+#define FIND_VERSION 19980301L
+
+#ifndef FIND_CODES
+#define FIND_CODES "lib/find/codes"
+#endif
+
+#define FIND_CODES_ENV "FINDCODES"
+
+#define FIND_GENERATE (1<<0) /* generate new codes */
+#define FIND_ICASE (1<<1) /* ignore case in match */
+#define FIND_GNU (1<<2) /* generate gnu format codes */
+#define FIND_OLD (1<<3) /* generate old format codes */
+#define FIND_TYPE (1<<4) /* generate type with codes */
+#define FIND_VERIFY (1<<5) /* verify the dir hierarchy */
+
+#define FIND_USER (1L<<16) /* first user flag bit */
+
+struct Find_s;
+struct Finddisc_s;
+
+typedef int (*Findverify_f) __PROTO__((struct Find_s*, const char*, size_t, struct Finddisc_s*));
+
+typedef struct Finddisc_s
+{
+ unsigned long version; /* interface version */
+ unsigned long flags; /* FIND_* flags */
+ Error_f errorf; /* error function */
+ Findverify_f verifyf; /* dir verify function */
+ char** dirs; /* dir prefixes to search */
+} Finddisc_t;
+
+typedef struct Find_s
+{
+ const char* id; /* library id string */
+ unsigned long stamp; /* codes time stamp */
+
+#ifdef _FIND_PRIVATE_
+ _FIND_PRIVATE_
+#endif
+
+} Find_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Find_t* findopen __PROTO__((const char*, const char*, const char*, Finddisc_t*));
+extern __MANGLE__ char* findread __PROTO__((Find_t*));
+extern __MANGLE__ int findwrite __PROTO__((Find_t*, const char*, size_t, const char*));
+extern __MANGLE__ int findclose __PROTO__((Find_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/fnmatch.h b/usr/src/lib/libast/sparc/include/ast/fnmatch.h
new file mode 100644
index 0000000000..83e2dd9943
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/fnmatch.h
@@ -0,0 +1,71 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * posix fnmatch interface definitions
+ */
+
+#ifndef _FNMATCH_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FNMATCH_H
+
+#include <ast_common.h>
+
+/* fnmatch flags */
+
+#define FNM_NOESCAPE 0x0001 /* \ is literal */
+#define FNM_PATHNAME 0x0002 /* explicit match for / */
+#define FNM_PERIOD 0x0004 /* explicit match for leading . */
+#define FNM_NOSYS 0x0010 /* not implemented */
+
+/* nonstandard fnmatch() flags */
+
+#define FNM_AUGMENTED 0x0008 /* enable ! & ( | ) */
+#define FNM_ICASE 0x0020 /* ignore case in match */
+#define FNM_LEADING_DIR 0x0040 /* match up to implicit / */
+
+#define FNM_CASEFOLD FNM_ICASE /* gnu compatibility */
+#define FNM_FILE_NAME FNM_PATHNAME /* gnu compatibility */
+
+/* fnmatch error codes -- other non-zero values from <regex.h> */
+
+#define FNM_NOMATCH 1 /* == REG_NOMATCH */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int fnmatch __PROTO__((const char*, const char*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/fnv.h b/usr/src/lib/libast/sparc/include/ast/fnv.h
new file mode 100644
index 0000000000..6af5c1489c
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/fnv.h
@@ -0,0 +1,81 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * Landon Kurt Knoll
+ * Phong Vo
+ *
+ * FNV-1 linear congruent checksum/hash/PRNG
+ * see http://www.isthe.com/chongo/tech/comp/fnv/
+ */
+
+#ifndef _FNV_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FNV_H
+
+#include <ast_common.h>
+
+#define FNV_INIT 0x811c9dc5L
+#define FNV_MULT 0x01000193L
+
+#define FNVINIT(h) (h = FNV_INIT)
+#define FNVPART(h,c) (h = (h) * FNV_MULT ^ (c))
+#define FNVSUM(h,s,n) do { \
+ register size_t _i_ = 0; \
+ while (_i_ < n) \
+ FNVPART(h, ((unsigned char*)s)[_i_++]); \
+ } while (0)
+
+#if _typ_int64_t
+
+#ifdef _ast_LL
+
+#define FNV_INIT64 0xcbf29ce484222325LL
+#define FNV_MULT64 0x00000100000001b3LL
+
+#else
+
+#define FNV_INIT64 ((int64_t)0xcbf29ce484222325)
+#define FNV_MULT64 ((int64_t)0x00000100000001b3)
+
+#endif
+
+#define FNVINIT64(h) (h = FNV_INIT64)
+#define FNVPART64(h,c) (h = (h) * FNV_MULT64 ^ (c))
+#define FNVSUM64(h,s,n) do { \
+ register int _i_ = 0; \
+ while (_i_ < n) \
+ FNVPART64(h, ((unsigned char*)s)[_i_++]); \
+ } while (0)
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/fs3d.h b/usr/src/lib/libast/sparc/include/ast/fs3d.h
new file mode 100644
index 0000000000..a16099d7ae
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/fs3d.h
@@ -0,0 +1,120 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * 3d fs interface definitions
+ */
+
+#ifndef _FS3D_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FS3D_H
+
+#include <ast_fs.h>
+
+#if _int_st_spare1
+#define iview(p) ((p)->st_spare1)
+#define IVIEW(p,v) ((p)->st_spare1=(v))
+#else
+#if _ary_st_spare4
+#define iview(p) ((p)->st_spare4[0])
+#define IVIEW(p,v) ((p)->st_spare4[0]=(v))
+#else
+#if _ary_st_pad4
+#define iview(p) ((p)->st_pad4[0])
+#define IVIEW(p,v) ((p)->st_pad4[0]=(v))
+#else
+#if _mem_st_rdev_stat
+#define iview(p) ((S_ISBLK((p)->st_mode)||S_ISCHR((p)->st_mode))?0:(p)->st_rdev)
+#define IVIEW(p,v) do{if(!S_ISBLK((p)->st_mode)&&!S_ISCHR((p)->st_mode))(p)->st_rdev=(v);}while(0)
+#else
+#define iview(p) 0
+#define IVIEW(p,v)
+#endif
+#endif
+#endif
+#endif
+
+/*
+ * special options
+ */
+
+#define FS3D_init "/#option/init"
+#define FS3D_on "/#option/3d"
+#define FS3D_off "/#option/2d"
+
+/*
+ * fs3d(3) ops
+ */
+
+#define FS3D_OP(o,a) (((a)<<3)|(o))
+
+#define FS3D_INIT FS3D_OP_INIT /* re-initialize tables */
+#define FS3D_OFF FS3D_OP_OFF
+#define FS3D_ON FS3D_OP_ON
+#define FS3D_TEST FS3D_OP_TEST
+#define FS3D_LIMIT(n) FS3D_OP(FS3D_OP_LIMIT,n)
+
+#define FS3D_op(x) ((x)&07)
+#define FS3D_arg(x) (((x)>>3)&07777)
+
+#define FS3D_OP_OFF 0
+#define FS3D_OP_ON 1
+#define FS3D_OP_TEST 2
+#define FS3D_OP_LIMIT 3
+#define FS3D_OP_INIT 7
+
+/*
+ * mount(2) ops
+ */
+
+#define FS3D_ALL (FS3D_VIEW|FS3D_VERSION)
+#define FS3D_VIEW 002
+#define FS3D_VERSION 004
+#define FS3D_GET 010
+#define FS3D_SIZE(n) ((n)<<4)
+#define FS3D_SIZEOF(n) ((n)>>4)
+
+extern __MANGLE__ int mount __PROTO__((const char*, char*, int, __V_*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int fs3d __PROTO__((int));
+extern __MANGLE__ char* pathnext __PROTO__((char*, char*, long*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/fts.h b/usr/src/lib/libast/sparc/include/ast/fts.h
new file mode 100644
index 0000000000..081fe2a712
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/fts.h
@@ -0,0 +1,160 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * David Korn
+ * Phong Vo
+ * AT&T Research
+ *
+ * fts interface definitions
+ */
+
+#ifndef _FTS_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FTS_H
+
+#include <ls.h>
+
+/*
+ * fts_open flags
+ */
+
+#define FTS_LOGICAL 0 /* logical traversal, follow symlinks */
+#define FTS_META (1<<0) /* follow top dir symlinks even if phys */
+#define FTS_NOCHDIR (1<<1) /* don't chdir */
+#define FTS_NOPOSTORDER (1<<2) /* no postorder visits */
+#define FTS_NOPREORDER (1<<3) /* no preorder visits */
+#define FTS_NOSEEDOTDIR (1<<11) /* never retain leading . dir */
+#define FTS_NOSTAT (1<<4) /* don't stat children */
+#define FTS_ONEPATH (1<<5) /* pathnames arg is one const char* */
+#define FTS_PHYSICAL (1<<6) /* physical traversal, don't follow */
+#define FTS_SEEDOT (1<<7) /* return . and .. */
+#define FTS_SEEDOTDIR (1<<10) /* always retain leading . dir */
+#define FTS_TOP (1<<8) /* don't traverse subdirectories */
+#define FTS_XDEV (1<<9) /* don't cross mount points */
+
+#define FTS_USER (1<<12) /* first user flag bit */
+
+#define FTS_COMFOLLOW FTS_META
+
+/*
+ * fts_info flags
+ */
+
+#define FTS_DEFAULT 0 /* ok, someone must have wanted this */
+
+#define FTS_NS (1<<0) /* stat failed */
+#define FTS_F (1<<1) /* file - not directory or symbolic link*/
+#define FTS_SL (1<<2) /* symbolic link */
+#define FTS_D (1<<3) /* directory - pre-order visit */
+
+#define FTS_C (1<<4) /* causes cycle */
+#define FTS_ERR (1<<5) /* some other error */
+#define FTS_DD (1<<6) /* . or .. */
+#define FTS_NR (1<<7) /* cannot read */
+#define FTS_NX (1<<8) /* cannot search */
+#define FTS_OK (1<<9) /* no info but otherwise ok */
+#define FTS_P (1<<10) /* post-order visit */
+
+#define FTS_DC (FTS_D|FTS_C) /* dir - would cause cycle */
+#define FTS_DNR (FTS_D|FTS_NR) /* dir - no read permission */
+#define FTS_DNX (FTS_D|FTS_NX) /* dir - no search permission */
+#define FTS_DOT (FTS_D|FTS_DD) /* . or .. */
+#define FTS_DP (FTS_D|FTS_P) /* dir - post-order visit */
+#define FTS_NSOK (FTS_NS|FTS_OK) /* no stat (because you asked) */
+#define FTS_SLNONE (FTS_SL|FTS_NS) /* symlink - to nowhere */
+
+/*
+ * fts_set flags
+ */
+
+#define FTS_AGAIN FTS_TOP /* process entry again */
+#define FTS_FOLLOW FTS_META /* follow FTS_SL symlink */
+#define FTS_SKIP FTS_NOSTAT /* skip FTS_D directory */
+#define FTS_STAT FTS_PHYSICAL /* stat() done by user */
+
+typedef struct Fts FTS;
+typedef struct Ftsent FTSENT;
+
+struct Ftsent
+{
+ char* fts_accpath; /* path relative to . */
+ char* fts_name; /* file name */
+ char* fts_path; /* path relative to top dir */
+ FTSENT* fts_cycle; /* offender if cycle */
+ FTSENT* fts_link; /* next child */
+ FTSENT* fts_parent; /* parent directory */
+ struct stat* fts_statp; /* stat info */
+#ifdef _FTSENT_LOCAL_PRIVATE_
+ _FTSENT_LOCAL_PRIVATE_
+#else
+ __V_* fts_pointer; /* local pointer value */
+#endif
+ long fts_number; /* local numeric value */
+ int fts_errno; /* errno for this entry */
+ unsigned short fts_info; /* info flags */
+ unsigned short fts_namelen; /* strlen(fts_name) */
+ unsigned short fts_pathlen; /* strlen(fts_path) */
+ short fts_level; /* file tree depth, 0 at top */
+
+#ifdef _FTSENT_PRIVATE_
+ _FTSENT_PRIVATE_
+#endif
+
+};
+
+struct Fts
+{
+ int fts_errno; /* last errno */
+
+#ifdef _FTS_PRIVATE_
+ _FTS_PRIVATE_
+#endif
+
+};
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ FTSENT* fts_children __PROTO__((FTS*, int));
+extern __MANGLE__ int fts_close __PROTO__((FTS*));
+extern __MANGLE__ int fts_flags __PROTO__((void));
+extern __MANGLE__ int fts_notify __PROTO__((int(*)(FTS*, FTSENT*, __V_*), __V_*));
+extern __MANGLE__ FTS* fts_open __PROTO__((char* const*, int, int(*)(FTSENT* const*, FTSENT* const*)));
+extern __MANGLE__ FTSENT* fts_read __PROTO__((FTS*));
+extern __MANGLE__ int fts_set __PROTO__((FTS*, FTSENT*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ftw.h b/usr/src/lib/libast/sparc/include/ast/ftw.h
new file mode 100644
index 0000000000..bd39851cbc
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ftw.h
@@ -0,0 +1,71 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * ftw,nftw over ftwalk
+ */
+
+#ifndef _FTW_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FTW_H
+
+#define FTW FTWALK
+#include <ftwalk.h>
+#undef FTW
+
+#define FTW_SLN (FTW_SL|FTW_NR)
+
+#define FTW_PHYS (FTW_PHYSICAL)
+#define FTW_CHDIR (FTW_DOT)
+#define FTW_DEPTH (FTW_POST)
+#define FTW_OPEN (0)
+
+struct FTW
+{
+ int quit;
+ int base;
+ int level;
+};
+
+#define FTW_SKD FTW_SKIP
+#define FTW_PRUNE FTW_SKIP
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int ftw __PROTO__((const char*, int(*)(const char*, const struct stat*, int), int));
+extern __MANGLE__ int nftw __PROTO__((const char*, int(*)(const char*, const struct stat*, int, struct FTW*), int, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ftwalk.h b/usr/src/lib/libast/sparc/include/ast/ftwalk.h
new file mode 100644
index 0000000000..1ee713a37a
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ftwalk.h
@@ -0,0 +1,137 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Phong Vo
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * ast ftwalk interface definitions
+ * ftwalk was the initial improvement on ftw and nftw
+ * which formed the basis for the POSIX fts proposal
+ *
+ * NOTE: this file is in cahoots with the fts implementation
+ */
+
+#ifndef _FTWALK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FTWALK_H
+
+#define fts_info info
+#define fts_level level
+#define fts_link link
+#define fts_name name
+#define fts_namelen namelen
+#define fts_parent parent
+#define fts_path path
+#define fts_pathlen pathlen
+
+#define FTSENT Ftw_t /* <fts.h> internal */
+#define Ftsent FTW /* <fts.h> internal */
+
+#define _FTSENT_LOCAL_PRIVATE_ /* <fts.h> internal */ \
+ union \
+ { \
+ long number; /* local numeric value */ \
+ __V_* pointer; /* local pointer value */ \
+ } local;
+
+#define _FTSENT_PRIVATE_ /* fts internal */ \
+ short status; /* internal status */ \
+ struct stat statb; /* fts_statp data */
+
+#include <fts.h>
+
+/*
+ * ftwalk() argument flags
+ */
+
+#define FTW_CANON FTS_CANON
+#define FTW_CHILDREN (FTS_USER<<0)
+#define FTW_DELAY FTS_NOSTAT
+#define FTW_DOT FTS_NOCHDIR
+#define FTW_META FTS_META
+#define FTW_MOUNT FTS_XDEV
+#define FTW_MULTIPLE FTS_ONEPATH
+#define FTW_NOSEEDOTDIR FTS_NOSEEDOTDIR
+#define FTW_PHYSICAL FTS_PHYSICAL
+#define FTW_POST (FTS_USER<<1)
+#define FTW_SEEDOTDIR FTS_SEEDOTDIR
+#define FTW_TOP FTS_TOP
+#define FTW_TWICE (FTS_USER<<2)
+#define FTW_USER (FTS_USER<<3)
+
+/*
+ * Ftw_t.info type bits
+ */
+
+#define FTW_C FTS_C
+#define FTW_D FTS_D
+#define FTW_DC FTS_DC
+#define FTW_DNR FTS_DNR
+#define FTW_DNX FTS_DNX
+#define FTW_DP FTS_DP
+#define FTW_F FTS_F
+#define FTW_NR FTS_NR
+#define FTW_NS FTS_NS
+#define FTW_NSOK FTS_NSOK
+#define FTW_NX FTS_NX
+#define FTW_P FTS_P
+#define FTW_SL FTS_SL
+
+/*
+ * Ftw_t.status entry values
+ */
+
+#define FTW_NAME FTS_DOT /* access by Ftw_t.name */
+#define FTW_PATH FTS_NOCHDIR /* access by Ftw_t.path */
+
+/*
+ * Ftw_t.status return values
+ */
+
+#define FTW_AGAIN FTS_AGAIN
+#define FTW_FOLLOW FTS_FOLLOW
+#define FTW_NOPOST FTS_NOPOSTORDER
+#define FTW_SKIP FTS_SKIP
+#define FTW_STAT FTS_STAT
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int ftwalk __PROTO__((const char*, int(*)(Ftw_t*), int, int(*)(Ftw_t*, Ftw_t*)));
+extern __MANGLE__ int ftwflags __PROTO__((void));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/getopt.h b/usr/src/lib/libast/sparc/include/ast/getopt.h
new file mode 100644
index 0000000000..01348b6402
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/getopt.h
@@ -0,0 +1,31 @@
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+#include <ast_getopt.h>
+
+#if !defined(_GETOPT_H) && !defined(_AST_STD_I)
+
+#define _GETOPT_H 1
+
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+struct option
+{
+ const char* name;
+ int has_arg;
+ int* flag;
+ int val;
+};
+
+extern __MANGLE__ int getopt_long __PROTO__((int, char* const*, const char*, const struct option*, int*));
+extern __MANGLE__ int getopt_long_only __PROTO__((int, char* const*, const char*, const struct option*, int*));
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/glob.h b/usr/src/lib/libast/sparc/include/ast/glob.h
new file mode 100644
index 0000000000..e02733177d
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/glob.h
@@ -0,0 +1,155 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * posix glob interface definitions with gnu extensions
+ */
+
+#ifndef _GLOB_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _GLOB_H
+
+#define GLOB_VERSION 20060717L
+
+#include <stdlib.h>
+
+struct dirent;
+struct stat;
+
+struct _glob_;
+struct _globlist_;
+
+typedef struct _glob_ glob_t;
+typedef struct _globlist_ globlist_t;
+
+struct _globlist_
+{
+ globlist_t* gl_next;
+ char* gl_begin;
+ unsigned char gl_flags;
+ char gl_path[1];
+};
+
+struct _glob_
+{
+ size_t gl_pathc;
+ char** gl_pathv;
+ size_t gl_offs;
+ globlist_t* gl_list;
+ int gl_flags;
+
+ /* GLOB_DISC data -- memset(&gl,0,sizeof(gl)) before using! */
+
+ const char* gl_fignore;
+ const char* gl_suffix;
+ unsigned char* gl_intr;
+
+ int gl_delim;
+
+ __V_* gl_handle;
+ __V_* (*gl_diropen) __PROTO__((glob_t*, const char*));
+ char* (*gl_dirnext) __PROTO__((glob_t*, __V_*));
+ void (*gl_dirclose) __PROTO__((glob_t*, __V_*));
+ int (*gl_type) __PROTO__((glob_t*, const char*));
+ int (*gl_attr) __PROTO__((glob_t*, const char*));
+
+ /* gnu extensions -- but how do you synthesize dirent and stat? */
+
+ __V_* (*gl_opendir) __PROTO__((const char*));
+ struct dirent* (*gl_readdir) __PROTO__((__V_*));
+ void (*gl_closedir) __PROTO__((__V_*));
+ int (*gl_stat) __PROTO__((const char*, struct stat*));
+ int (*gl_lstat) __PROTO__((const char*, struct stat*));
+
+ /* ast additions */
+
+ char* (*gl_nextdir) __PROTO__((glob_t*, char*));
+ unsigned long gl_status;
+ unsigned long gl_version;
+ unsigned short gl_extra;
+
+#ifdef _GLOB_PRIVATE_
+ _GLOB_PRIVATE_
+#else
+ char* gl_pad[23];
+#endif
+
+};
+
+/* standard interface */
+#define GLOB_APPEND 0x0001 /* append to previous */
+#define GLOB_DOOFFS 0x0002 /* gl_offs defines argv offset */
+#define GLOB_ERR 0x0004 /* abort on error */
+#define GLOB_MARK 0x0008 /* append / to directories */
+#define GLOB_NOCHECK 0x0010 /* nomatch is original pattern */
+#define GLOB_NOESCAPE 0x0020 /* don't treat \ specially */
+#define GLOB_NOSORT 0x0040 /* don't sort the list */
+
+/* extended interface */
+#define GLOB_STARSTAR 0x0080 /* enable [/]**[/] expansion */
+#define GLOB_BRACE 0x0100 /* enable {...} expansion */
+#define GLOB_ICASE 0x0200 /* ignore case on match */
+#define GLOB_COMPLETE 0x0400 /* shell file completeion */
+#define GLOB_AUGMENTED 0x0800 /* augmented shell patterns */
+#define GLOB_STACK 0x1000 /* allocate on current stack */
+#define GLOB_LIST 0x2000 /* just create gl_list */
+#define GLOB_ALTDIRFUNC 0x4000 /* gnu discipline functions */
+#define GLOB_DISC 0x8000 /* discipline initialized */
+
+/* gl_status */
+#define GLOB_NOTDIR 0x0001 /* last gl_dirnext() not a dir */
+
+/* gl_type return */
+#define GLOB_NOTFOUND 0 /* does not exist */
+#define GLOB_DEV 1 /* exists but not DIR EXE REG */
+#define GLOB_DIR 2 /* directory */
+#define GLOB_EXE 3 /* executable regular file */
+#define GLOB_REG 4 /* regular file */
+
+/* error return values */
+#define GLOB_ABORTED 1
+#define GLOB_NOMATCH 2
+#define GLOB_NOSPACE 3
+#define GLOB_INTR 4
+#define GLOB_APPERR 5
+#define GLOB_NOSYS 6
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int glob __PROTO__((const char*, int, int(*)(const char*,int), glob_t*));
+extern __MANGLE__ void globfree __PROTO__((glob_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif /* _GLOB_H */
diff --git a/usr/src/lib/libast/sparc/include/ast/hash.h b/usr/src/lib/libast/sparc/include/ast/hash.h
new file mode 100644
index 0000000000..4050612983
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/hash.h
@@ -0,0 +1,213 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * hash table library interface definitions
+ *
+ * NOTE: new code should use the more general <cdt.h>
+ */
+
+#ifndef _HASH_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _HASH_H
+
+#define HASH_ALLOCATE (1L<<0) /* allocate new key names */
+#define HASH_FIXED (1L<<1) /* fixed table size */
+#define HASH_HASHED (1L<<6) /* key names already hashed */
+#define HASH_RESIZE (1L<<2) /* table has been resized */
+#define HASH_SCANNING (1L<<3) /* currently scanning scope */
+#define HASH_SCOPE (1L<<4) /* push scope / create in bot */
+#define HASH_STATIC (1L<<5) /* static table allocation */
+
+#define HASH_CREATE (1L<<8) /* create bucket if not found */
+#define HASH_DELETE (1L<<9) /* delete bucket if found */
+#define HASH_LOOKUP 0 /* default op */
+#define HASH_RENAME (1L<<7) /* rename bucket if found */
+
+#define HASH_BUCKET (1L<<11) /* name is installed bucket */
+#define HASH_INSTALL (1L<<12) /* install allocated bucket */
+#define HASH_NOSCOPE (1L<<13) /* top scope only */
+#define HASH_OPAQUE (1L<<14) /* opaque bucket */
+#define HASH_VALUE (1L<<15) /* value bucket field used */
+
+#define HASH_SIZE(n) (((long)(n))<<16) /* fixed bucket size */
+#define HASH_SIZEOF(f) ((((long)(f))>>16)&0xffff) /* extract size */
+
+#define HASH_DELETED ((unsigned long)1<<(8*sizeof(int)-1)) /* deleted placeholder */
+#define HASH_KEEP (1L<<(8*sizeof(int)-2)) /* no free on bucket */
+#define HASH_HIDDEN (1L<<(8*sizeof(int)-3)) /* hidden by scope */
+#define HASH_HIDES (1L<<(8*sizeof(int)-4)) /* hides lower scope */
+#define HASH_OPAQUED (1L<<(8*sizeof(int)-5)) /* opaqued placeholder */
+#define HASH_FREENAME (1L<<(8*sizeof(int)-6)) /* free bucket name */
+
+#define HASH_RESET (HASH_RESIZE|HASH_SCOPE|HASH_STATIC|HASH_VALUE)
+#define HASH_INTERNAL (HASH_BUCKET|HASH_RESIZE|HASH_SCANNING|HASH_STATIC)
+#define HASH_FLAGS (HASH_DELETED|HASH_FREENAME|HASH_HIDDEN|HASH_HIDES|HASH_KEEP|HASH_OPAQUED)
+
+#define HASH_alloc 1
+#define HASH_clear 2
+#define HASH_compare 3
+#define HASH_free 4
+#define HASH_hash 5
+#define HASH_meanchain 6
+#define HASH_name 7
+#define HASH_namesize 8
+#define HASH_set 9
+#define HASH_size 10
+#define HASH_table 11
+#define HASH_va_list 12
+
+#define HASH_bucketsize 13
+
+#define HASH_region 14
+
+#include <hashpart.h>
+
+#define hashclear(t,f) ((t)->flags &= ~((f) & ~HASH_INTERNAL))
+#define hashcover(b) (((b)->hash&HASH_HIDES)?(Hash_bucket_t*)((b)->name):(Hash_bucket_t*)0)
+#define hashdel(t,n) hashlook(t, (char*)(n), HASH_DELETE, (char*)0)
+#define hashget(t,n) hashlook(t, (char*)(n), HASH_LOOKUP|HASH_VALUE, (char*)0)
+#define hashgetbucket(s) ((Hash_bucket_t*)((s)-((sizeof(Hash_bucket_t)+sizeof(char*)-1)/sizeof(char*))*sizeof(char*)))
+#define hashkeep(b) ((b)->hash|=HASH_KEEP)
+#define hashname(b) ((((b)->hash&HASH_HIDES)?((Hash_bucket_t*)((b)->name)):(b))->name)
+#define hashput(t,n,v) hashlook(t, (char*)(n), HASH_CREATE|HASH_VALUE, (char*)(v))
+#define hashref(t,n) hashlook(t, (char*)(n), HASH_LOOKUP|HASH_INTERNAL|HASH_VALUE, (char*)0)
+#define hashscope(t) ((t)->scope)
+#define hashset(t,f) ((t)->flags |= ((f) & ~HASH_INTERNAL))
+
+/*
+ * DEPRECATED renames for compatibility
+ */
+
+#define Hashbin_t Hash_bucket_t
+#define HASHBUCKET Hash_bucket_t
+#define Hashhdr_t Hash_header_t
+#define HASHHEADER Hash_header_t
+#define Hashpos_t Hash_position_t
+#define HASHPOSITION Hash_position_t
+#define Hashtab_t Hash_table_t
+#define HASHTABLE Hash_table_t
+
+#define vhashalloc hashvalloc
+#define hashvalloc(t,a) hashalloc(t,HASH_va_list,a,0)
+
+/*
+ * the #define's avoid union tags
+ */
+
+typedef struct Hash_bucket Hash_bucket_t;
+typedef struct Hash_root Hash_root_t;
+typedef struct Hash_table Hash_table_t;
+
+#define HASH_HEADER /* common bucket header */ \
+ Hash_bucket_t* next; /* next in collision chain */ \
+ unsigned int hash; /* hash flags and value */ \
+ char* name /* key name */
+
+#define HASH_DEFAULT /* HASH_VALUE bucket elements */ \
+ char* value /* key value */
+
+typedef struct /* bucket header */
+{
+ HASH_HEADER;
+} Hash_header_t;
+
+struct Hash_bucket /* prototype bucket */
+{
+ HASH_HEADER;
+ HASH_DEFAULT;
+};
+
+typedef struct /* hash scan bucket position */
+{
+ Hash_bucket_t* bucket; /* bucket */
+#ifdef _HASH_POSITION_PRIVATE_
+ _HASH_POSITION_PRIVATE_
+#endif
+} Hash_position_t;
+
+typedef struct /* last lookup cache */
+{
+ Hash_table_t* table; /* last lookup table */
+ Hash_bucket_t* bucket; /* last lookup bucket */
+#ifdef _HASH_LAST_PRIVATE_
+ _HASH_LAST_PRIVATE_
+#endif
+} Hash_last_t;
+
+struct Hash_root /* root hash table information */
+{
+ int accesses; /* number of accesses */
+ int collisions; /* number of collisions */
+ int flags; /* flags: see HASH_[A-Z]* */
+ Hash_last_t last; /* last lookup cache */
+ __V_* context; /* user defined context */
+#ifdef _HASH_ROOT_PRIVATE_
+ _HASH_ROOT_PRIVATE_
+#endif
+};
+
+struct Hash_table /* hash table information */
+{
+ Hash_root_t* root; /* root hash table information */
+ int size; /* table size */
+ int buckets; /* active bucket count */
+ char* name; /* table name */
+ Hash_table_t* scope; /* scope covered table */
+ short flags; /* flags: see HASH_[A-Z]* */
+#ifdef _HASH_TABLE_PRIVATE_
+ _HASH_TABLE_PRIVATE_
+#endif
+};
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Hash_table_t* hashalloc __PROTO__((Hash_table_t*, ...));
+extern __MANGLE__ void hashdone __PROTO__((Hash_position_t*));
+extern __MANGLE__ void hashdump __PROTO__((Hash_table_t*, int));
+extern __MANGLE__ Hash_table_t* hashfree __PROTO__((Hash_table_t*));
+extern __MANGLE__ Hash_bucket_t* hashlast __PROTO__((Hash_table_t*));
+extern __MANGLE__ char* hashlook __PROTO__((Hash_table_t*, const char*, long, const char*));
+extern __MANGLE__ Hash_bucket_t* hashnext __PROTO__((Hash_position_t*));
+extern __MANGLE__ Hash_position_t* hashscan __PROTO__((Hash_table_t*, int));
+extern __MANGLE__ void hashsize __PROTO__((Hash_table_t*, int));
+extern __MANGLE__ Hash_table_t* hashview __PROTO__((Hash_table_t*, Hash_table_t*));
+extern __MANGLE__ int hashwalk __PROTO__((Hash_table_t*, int, int (*)(const char*, char*, __V_*), __V_*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/hashkey.h b/usr/src/lib/libast/sparc/include/ast/hashkey.h
new file mode 100644
index 0000000000..1ce051ff26
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/hashkey.h
@@ -0,0 +1,73 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * 1-6 char lower-case keyword -> long hash
+ * digit args passed as HASHKEYN('2')
+ */
+
+#ifndef _HASHKEY_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _HASHKEY_H
+
+#define HASHKEYMAX 6
+#define HASHKEYBIT 5
+#define HASHKEYOFF ('a'-1)
+#define HASHKEYPART(h,c) (((h)<<HASHKEYBIT)+HASHKEY1(c))
+
+#define HASHKEYN(n) ((n)-'0'+'z'+1)
+
+#define HASHKEY1(c1) ((c1)-HASHKEYOFF)
+#define HASHKEY2(c1,c2) HASHKEYPART(HASHKEY1(c1),c2)
+#define HASHKEY3(c1,c2,c3) HASHKEYPART(HASHKEY2(c1,c2),c3)
+#define HASHKEY4(c1,c2,c3,c4) HASHKEYPART(HASHKEY3(c1,c2,c3),c4)
+#define HASHKEY5(c1,c2,c3,c4,c5) HASHKEYPART(HASHKEY4(c1,c2,c3,c4),c5)
+#define HASHKEY6(c1,c2,c3,c4,c5,c6) HASHKEYPART(HASHKEY5(c1,c2,c3,c4,c5),c6)
+
+#define HASHNKEY1(n,c1) HASHKEY2((n)+HASHKEYOFF,c1)
+#define HASHNKEY2(n,c2,c1) HASHKEY3((n)+HASHKEYOFF,c2,c1)
+#define HASHNKEY3(n,c3,c2,c1) HASHKEY4((n)+HASHKEYOFF,c3,c2,c1)
+#define HASHNKEY4(n,c4,c3,c2,c1) HASHKEY5((n)+'a',c4,c3,c2,c1)
+#define HASHNKEY5(n,c5,c4,c3,c2,c1) HASHKEY6((n)+'a',c5,c4,c3,c2,c1)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ long strkey __PROTO__((const char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/hashpart.h b/usr/src/lib/libast/sparc/include/ast/hashpart.h
new file mode 100644
index 0000000000..b2aa79649a
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/hashpart.h
@@ -0,0 +1,60 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * K. P. Vo
+ * G. S. Fowler
+ * AT&T Research
+ *
+ * ``the best'' combined linear congruent checksum/hash/PRNG
+ */
+
+#ifndef _HASHPART_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _HASHPART_H
+
+#define HASH_ADD(h) (0x9c39c33dL)
+
+#if __sparc__ || __sparc || sparc
+
+#define HASH_A(h,n) ((((h) << 2) - (h)) << (n))
+#define HASH_B(h,n) ((((h) << 4) - (h)) << (n))
+#define HASH_C(h,n) ((HASH_A(h,7) + HASH_B(h,0)) << (n))
+#define HASH_MPY(h) (HASH_C(h,22)+HASH_C(h,10)+HASH_A(h,6)+HASH_A(h,3)+(h))
+
+#else
+
+#define HASH_MPY(h) ((h)*0x63c63cd9L)
+
+#endif
+
+#define HASHPART(h,c) (h = HASH_MPY(h) + HASH_ADD(h) + (c))
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/iconv.h b/usr/src/lib/libast/sparc/include/ast/iconv.h
new file mode 100644
index 0000000000..e63b3f0fcd
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/iconv.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_iconv.h>
diff --git a/usr/src/lib/libast/sparc/include/ast/lc.h b/usr/src/lib/libast/sparc/include/ast/lc.h
new file mode 100644
index 0000000000..fdd804f36e
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/lc.h
@@ -0,0 +1,158 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated by ./lcgen : : */
+
+
+#ifndef _LC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _LC_H 1
+
+#include <ast.h>
+
+#define LC_abbreviated 0x00001
+#define LC_checked 0x00002
+#define LC_default 0x00004
+#define LC_defined 0x00008
+#define LC_debug 0x00010
+#define LC_local 0x00020
+#define LC_primary 0x00040
+#define LC_qualified 0x00080
+#define LC_undefined 0x00100
+#define LC_verbose 0x00200
+#define LC_user 0x10000
+#define LC_language_attribute_max 2
+#define LC_territory_language_max 4
+
+struct Lc_s;
+
+typedef struct Lc_info_s
+{
+ const struct Lc_s* lc;
+ unsigned long number;
+ __V_* data;
+} Lc_info_t;
+
+typedef struct Lc_attribute_s
+{
+ const char* name;
+ unsigned long flags;
+ unsigned long index;
+} Lc_attribute_t;
+
+typedef struct Lc_charset_s
+{
+ const char* code;
+ const char* alternates;
+ const char* ms;
+ unsigned long index;
+} Lc_charset_t;
+
+typedef struct Lc_language_s
+{
+ const char* code;
+ const char* name;
+ const char* alternates;
+ const Lc_charset_t* charset;
+ unsigned long flags;
+ unsigned long index;
+ const Lc_attribute_t* attributes[LC_language_attribute_max];
+} Lc_language_t;
+
+typedef struct Lc_territory_s
+{
+ const char* code;
+ const char* name;
+ unsigned long flags;
+ unsigned long index;
+ const Lc_language_t* languages[LC_territory_language_max];
+#ifdef _LC_TERRITORY_PRIVATE_
+ _LC_TERRITORY_PRIVATE_
+#endif
+} Lc_territory_t;
+
+typedef struct Lc_map_s
+{
+ const char* code;
+ const Lc_language_t* language;
+ const Lc_territory_t* territory;
+ const Lc_charset_t* charset;
+ const Lc_attribute_t* attribute;
+} Lc_map_t;
+
+typedef struct Lc_attribute_list_s
+{
+ struct Lc_attribute_list_s* next;
+ const Lc_attribute_t* attribute;
+} Lc_attribute_list_t;
+
+typedef struct Lc_s
+{
+ const char* name;
+ const char* code;
+ const Lc_language_t* language;
+ const Lc_territory_t* territory;
+ const Lc_charset_t* charset;
+ const Lc_attribute_list_t* attributes;
+ unsigned long flags;
+ unsigned long index;
+#ifdef _LC_PRIVATE_
+ _LC_PRIVATE_
+#endif
+} Lc_t;
+
+struct Lc_category_s;
+
+typedef int (*Lc_category_set_f) __PROTO__((struct Lc_category_s*));
+
+typedef struct Lc_category_s
+{
+ const char* name;
+ int external;
+ int internal;
+ Lc_category_set_f setf;
+ Lc_t* prev;
+} Lc_category_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ size_t lccanon __PROTO__((Lc_t*, unsigned long flags, char*, size_t));
+extern __MANGLE__ Lc_category_t* lccategories __PROTO__((void));
+extern __MANGLE__ int lcindex __PROTO__((int, int));
+extern __MANGLE__ Lc_info_t* lcinfo __PROTO__((int));
+extern __MANGLE__ Lc_t* lcmake __PROTO__((const char*));
+extern __MANGLE__ Lc_t* lcscan __PROTO__((Lc_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/ls.h b/usr/src/lib/libast/sparc/include/ast/ls.h
new file mode 100644
index 0000000000..cce1771b3f
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/ls.h
@@ -0,0 +1,99 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * ls formatter interface definitions
+ */
+
+#ifndef _LS_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _LS_H
+
+#include <ast_std.h>
+#include <ast_fs.h>
+#include <ast_mode.h>
+
+/*
+ * some systems (could it beee AIX) pollute the std name space
+ */
+
+#undef fileid
+#define fileid fileID
+
+#define LS_BLOCKSIZE 512
+
+#define iblocks(p) _iblocks(p)
+
+#if _mem_st_rdev_stat
+#define idevice(p) ((p)->st_rdev)
+#define IDEVICE(p,v) ((p)->st_rdev=(v))
+#else
+#define idevice(p) 0
+#define IDEVICE(p,v)
+#endif
+
+#define LS_ATIME (1<<0) /* list st_atime */
+#define LS_BLOCKS (1<<1) /* list blocks used by file */
+#define LS_CTIME (1<<2) /* list st_ctime */
+#define LS_EXTERNAL (1<<3) /* st_mode is modex canonical */
+#define LS_INUMBER (1<<4) /* list st_ino */
+#define LS_LONG (1<<5) /* long listing */
+#define LS_MARK (1<<6) /* append file name marks */
+#define LS_NOGROUP (1<<7) /* omit group name for LS_LONG */
+#define LS_NOUSER (1<<8) /* omit user name for LS_LONG */
+#define LS_NUMBER (1<<9) /* number instead of name */
+
+#define LS_USER (1<<10) /* first user flag bit */
+
+#define LS_W_BLOCKS 6 /* LS_BLOCKS field width */
+#define LS_W_INUMBER 7 /* LS_INUMBER field width */
+#define LS_W_LONG 55 /* LS_LONG width (w/o names) */
+#define LS_W_LINK 4 /* link text width (w/o names) */
+#define LS_W_MARK 1 /* LS_MARK field width */
+#define LS_W_NAME 9 /* group|user name field width */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ off_t _iblocks __PROTO__((struct stat*));
+extern __MANGLE__ char* fmtdev __PROTO__((struct stat*));
+extern __MANGLE__ char* fmtfs __PROTO__((struct stat*));
+extern __MANGLE__ char* fmtls __PROTO__((char*, const char*, struct stat*, const char*, const char*, int));
+extern __MANGLE__ int pathstat __PROTO__((const char*, struct stat*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/magic.h b/usr/src/lib/libast/sparc/include/ast/magic.h
new file mode 100644
index 0000000000..f484f2b20d
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/magic.h
@@ -0,0 +1,96 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * magic interface definitions
+ */
+
+#ifndef _MAGIC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MAGIC_H
+
+#include <sfio.h>
+#include <ls.h>
+
+#define MAGIC_VERSION 19961031L
+
+#ifndef MAGIC_FILE
+#define MAGIC_FILE "lib/file/magic"
+#endif
+
+#ifndef MAGIC_DIR
+#define MAGIC_DIR "lib/file"
+#endif
+
+#define MAGIC_FILE_ENV "MAGICFILE"
+
+#define MAGIC_MIME (1<<0) /* magictype returns MIME type */
+#define MAGIC_VERBOSE (1<<1) /* verbose magic file errors */
+
+#define MAGIC_USER (1L<<16) /* first user flag bit */
+
+struct Magic_s;
+struct Magicdisc_s;
+
+typedef struct Magicdisc_s
+{
+ unsigned long version; /* interface version */
+ unsigned long flags; /* MAGIC_* flags */
+ Error_f errorf; /* error function */
+} Magicdisc_t;
+
+typedef struct Magic_s
+{
+ const char* id; /* library id string */
+
+#ifdef _MAGIC_PRIVATE_
+ _MAGIC_PRIVATE_
+#endif
+
+} Magic_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Magic_t* magicopen __PROTO__((Magicdisc_t*));
+extern __MANGLE__ int magicload __PROTO__((Magic_t*, const char*, unsigned long));
+extern __MANGLE__ int magiclist __PROTO__((Magic_t*, Sfio_t*));
+extern __MANGLE__ char* magictype __PROTO__((Magic_t*, Sfio_t*, const char*, struct stat*));
+extern __MANGLE__ int magicclose __PROTO__((Magic_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/magicid.h b/usr/src/lib/libast/sparc/include/ast/magicid.h
new file mode 100644
index 0000000000..ceadff2653
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/magicid.h
@@ -0,0 +1,55 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * generic binary magic id definitions
+ */
+
+#ifndef _MAGICID_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MAGICID_H 1
+
+#include <ast_common.h>
+
+#define MAGICID 0x00010203
+
+typedef uint32_t Magicid_data_t;
+
+typedef struct Magicid_s
+{
+ Magicid_data_t magic; /* magic number */
+ char name[8]; /* generic data/application name*/
+ char type[12]; /* specific data type */
+ Magicid_data_t version; /* YYYYMMDD or 0xWWXXYYZZ */
+ Magicid_data_t size;
+} Magicid_t;
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/mc.h b/usr/src/lib/libast/sparc/include/ast/mc.h
new file mode 100644
index 0000000000..4b55665b3b
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/mc.h
@@ -0,0 +1,107 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * machine independent binary message catalog interface
+ *
+ * file layout
+ * all numbers are sfputu() format
+ *
+ * 4 char magic (^M^S^G0)
+ * <method locale YYYY-MM-DD>\0
+ * (<optional strings>\0)*
+ * \0
+ * string table size
+ * #msgs total
+ * #max set number
+ * #set-id 1
+ * #msgs in set 1
+ * ...
+ * #set-id #sets
+ * #msgs in set #sets
+ * end of sets (0)
+ * msg(1,1) size
+ * ...
+ * msg(#sets,#msgs) size
+ * string table
+ */
+
+#ifndef _MC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MC_H
+
+#include <ast.h>
+
+#define MC_MAGIC "\015\023\007\000"
+#define MC_MAGIC_SIZE 4
+
+#define MC_SET_MAX 1023
+#define MC_NUM_MAX 32767
+
+#define MC_NLS (1<<10)
+
+#define MC_MESSAGE_SET(s) mcindex(s,NiL,NiL,NiL)
+
+typedef struct
+{
+ char** msg;
+ int num;
+ int gen;
+} Mcset_t;
+
+typedef struct
+{
+ Mcset_t* set;
+ int num;
+ int gen;
+ char* translation;
+#ifdef _MC_PRIVATE_
+ _MC_PRIVATE_
+#endif
+} Mc_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ char* mcfind __PROTO__((char*, const char*, const char*, int, int));
+extern __MANGLE__ Mc_t* mcopen __PROTO__((Sfio_t*));
+extern __MANGLE__ char* mcget __PROTO__((Mc_t*, int, int, const char*));
+extern __MANGLE__ int mcput __PROTO__((Mc_t*, int, int, const char*));
+extern __MANGLE__ int mcdump __PROTO__((Mc_t*, Sfio_t*));
+extern __MANGLE__ int mcindex __PROTO__((const char*, char**, int*, int*));
+extern __MANGLE__ int mcclose __PROTO__((Mc_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/mime.h b/usr/src/lib/libast/sparc/include/ast/mime.h
new file mode 100644
index 0000000000..b018b68c9a
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/mime.h
@@ -0,0 +1,102 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * mime/mailcap interface
+ */
+
+#ifndef _MIMETYPE_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MIMETYPE_H 1
+
+#include <sfio.h>
+#include <ls.h>
+
+#define MIME_VERSION 19970717L
+
+#ifndef MIME_FILES
+#define MIME_FILES "~/.mailcap:/usr/local/etc/mailcap:/usr/etc/mailcap:/etc/mailcap:/etc/mail/mailcap:/usr/public/lib/mailcap"
+#endif
+
+#define MIME_FILES_ENV "MAILCAP"
+
+#define MIME_LIST (1<<0) /* mimeload arg is : list */
+#define MIME_NOMAGIC (1<<1) /* no magic for mimetype() */
+#define MIME_PIPE (1<<2) /* mimeview() io is piped */
+#define MIME_REPLACE (1<<3) /* replace existing definition */
+
+#define MIME_USER (1L<<16) /* first user flag bit */
+
+struct Mime_s;
+typedef struct Mime_s Mime_t;
+
+struct Mimedisc_s;
+typedef struct Mimedisc_s Mimedisc_t;
+
+typedef int (*Mimevalue_f) __PROTO__((Mime_t*, __V_*, char*, size_t, Mimedisc_t*));
+
+struct Mimedisc_s
+{
+ unsigned long version; /* interface version */
+ unsigned long flags; /* MIME_* flags */
+ Error_f errorf; /* error function */
+ Mimevalue_f valuef; /* value extraction function */
+};
+
+struct Mime_s
+{
+ const char* id; /* library id string */
+
+#ifdef _MIME_PRIVATE_
+ _MIME_PRIVATE_
+#endif
+
+};
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Mime_t* mimeopen __PROTO__((Mimedisc_t*));
+extern __MANGLE__ int mimeload __PROTO__((Mime_t*, const char*, unsigned long));
+extern __MANGLE__ int mimelist __PROTO__((Mime_t*, Sfio_t*, const char*));
+extern __MANGLE__ int mimeclose __PROTO__((Mime_t*));
+extern __MANGLE__ int mimeset __PROTO__((Mime_t*, char*, unsigned long));
+extern __MANGLE__ char* mimetype __PROTO__((Mime_t*, Sfio_t*, const char*, struct stat*));
+extern __MANGLE__ char* mimeview __PROTO__((Mime_t*, const char*, const char*, const char*, const char*));
+extern __MANGLE__ int mimehead __PROTO__((Mime_t*, __V_*, size_t, size_t, char*));
+extern __MANGLE__ int mimecmp __PROTO__((const char*, const char*, char**));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/mnt.h b/usr/src/lib/libast/sparc/include/ast/mnt.h
new file mode 100644
index 0000000000..d877416642
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/mnt.h
@@ -0,0 +1,69 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * mounted filesystem scan interface
+ */
+
+#ifndef _MNT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MNT_H 1
+
+#undef MNT_REMOTE /* aix clash */
+#define MNT_REMOTE (1<<0) /* remote mount */
+
+typedef struct
+{
+ char* fs; /* filesystem name */
+ char* dir; /* mounted dir */
+ char* type; /* filesystem type */
+ char* options; /* options */
+ int freq; /* backup frequency */
+ int npass; /* number of parallel passes */
+ int flags; /* MNT_* flags */
+} Mnt_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ __V_* mntopen __PROTO__((const char*, const char*));
+extern __MANGLE__ Mnt_t* mntread __PROTO__((__V_*));
+extern __MANGLE__ int mntwrite __PROTO__((__V_*, const Mnt_t*));
+extern __MANGLE__ int mntclose __PROTO__((__V_*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/modecanon.h b/usr/src/lib/libast/sparc/include/ast/modecanon.h
new file mode 100644
index 0000000000..ce107238e3
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/modecanon.h
@@ -0,0 +1,74 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * canonical mode_t representation
+ */
+
+#ifndef _MODECANON_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MODECANON_H
+
+#define X_ITYPE(m) ((m)&X_IFMT)
+
+#define X_IFMT 0170000
+#define X_IFWHT 0160000
+#define X_IFDOOR 0150000
+#define X_IFSOCK 0140000
+#define X_IFLNK 0120000
+#define X_IFCTG 0110000
+#define X_IFREG 0100000
+#define X_IFBLK 0060000
+#define X_IFDIR 0040000
+#define X_IFCHR 0020000
+#define X_IFIFO 0010000
+
+#define X_IPERM 0007777
+#define X_ISUID 0004000
+#define X_ISGID 0002000
+#define X_ISVTX 0001000
+#define X_IRUSR 0000400
+#define X_IWUSR 0000200
+#define X_IXUSR 0000100
+#define X_IRGRP 0000040
+#define X_IWGRP 0000020
+#define X_IXGRP 0000010
+#define X_IROTH 0000004
+#define X_IWOTH 0000002
+#define X_IXOTH 0000001
+
+#define X_IRWXU (X_IRUSR|X_IWUSR|X_IXUSR)
+#define X_IRWXG (X_IRGRP|X_IWGRP|X_IXGRP)
+#define X_IRWXO (X_IROTH|X_IWOTH|X_IXOTH)
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/modex.h b/usr/src/lib/libast/sparc/include/ast/modex.h
new file mode 100644
index 0000000000..458ad18ac1
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/modex.h
@@ -0,0 +1,62 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * AT&T Research
+ *
+ * external mode_t representation support
+ */
+
+#ifndef _MODEX_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MODEX_H
+
+#include <ast_fs.h>
+#include <modecanon.h>
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int modei __PROTO__((int));
+extern __MANGLE__ int modex __PROTO__((int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _S_IDPERM
+#define modei(m) ((m)&X_IPERM)
+#if _S_IDTYPE
+#define modex(m) (m)
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/namval.h b/usr/src/lib/libast/sparc/include/ast/namval.h
new file mode 100644
index 0000000000..d746970d58
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/namval.h
@@ -0,0 +1,51 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * common name-value struct support
+ */
+
+#ifndef _NAMVAL_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _NAMVAL_H
+
+typedef struct
+{
+ char* name;
+ int value;
+#ifdef _NAMVAL_PRIVATE_
+ _NAMVAL_PRIVATE_
+#endif
+} Namval_t;
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/nl_types.h b/usr/src/lib/libast/sparc/include/ast/nl_types.h
new file mode 100644
index 0000000000..db7383c626
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/nl_types.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_nl_types.h>
diff --git a/usr/src/lib/libast/sparc/include/ast/option.h b/usr/src/lib/libast/sparc/include/ast/option.h
new file mode 100644
index 0000000000..7204047891
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/option.h
@@ -0,0 +1,119 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * command line option parse interface
+ */
+
+#ifndef _OPTION_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _OPTION_H
+
+#include <ast.h>
+
+#define OPT_VERSION 20070319L
+
+#define OPT_USER (1L<<16) /* first user flag bit */
+
+struct Opt_s;
+struct Optdisc_s;
+
+typedef int (*Optinfo_f) __PROTO__((struct Opt_s*, Sfio_t*, const char*, struct Optdisc_s*));
+
+typedef struct Optdisc_s
+{
+ unsigned long version; /* OPT_VERSION */
+ unsigned long flags; /* OPT_* flags */
+ char* catalog; /* error catalog id */
+ Optinfo_f infof; /* runtime info function */
+} Optdisc_t;
+
+/* NOTE: Opt_t member order fixed by a previous binary release */
+
+#ifndef _OPT_PRIVATE_
+#define _OPT_PRIVATE_ \
+ char pad[3*sizeof(__V_*)];
+#endif
+
+typedef struct Opt_s
+{
+ int again; /* see optjoin() */
+ char* arg; /* {:,#} string argument */
+ char** argv; /* most recent argv */
+ int index; /* argv index */
+ char* msg; /* error/usage message buffer */
+ long num; /* OBSOLETE -- use number */
+ int offset; /* char offset in argv[index] */
+ char option[8]; /* current flag {-,+} + option */
+ char name[64]; /* current long name or flag */
+ Optdisc_t* disc; /* user discipline */
+ intmax_t number; /* # numeric argument */
+ unsigned char assignment; /* option arg assigment op */
+ unsigned char pads[sizeof(__V_*)-1];
+ _OPT_PRIVATE_
+} Opt_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Opt_t* _opt_infop_;
+
+#define opt_info (*_opt_infop_)
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define optinit(d,f) (memset(d,0,sizeof(*(d))),(d)->version=OPT_VERSION,(d)->infof=(f),opt_info.disc=(d))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int optget __PROTO__((char**, const char*));
+extern __MANGLE__ int optjoin __PROTO__((char**, ...));
+extern __MANGLE__ char* opthelp __PROTO__((const char*, const char*));
+extern __MANGLE__ char* optusage __PROTO__((const char*));
+extern __MANGLE__ int optstr __PROTO__((const char*, const char*));
+extern __MANGLE__ int optesc __PROTO__((Sfio_t*, const char*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/preroot.h b/usr/src/lib/libast/sparc/include/ast/preroot.h
new file mode 100644
index 0000000000..0c4a92fe4d
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/preroot.h
@@ -0,0 +1,27 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/preroot.sh by iffe version 2007-04-04 : : */
+#ifndef _def_preroot_ast
+#define _def_preroot_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* preroot not enabled */
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/proc.h b/usr/src/lib/libast/sparc/include/ast/proc.h
new file mode 100644
index 0000000000..1196fc5b3f
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/proc.h
@@ -0,0 +1,113 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * process library interface
+ */
+
+#ifndef _PROC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _PROC_H
+
+#include <ast.h>
+
+#define PROC_ARGMOD (1<<0) /* argv[-1],argv[0] can be modified */
+#define PROC_BACKGROUND (1<<1) /* shell background (&) setup */
+#define PROC_CLEANUP (1<<2) /* close parent redirect fds on error */
+#define PROC_DAEMON (1<<3) /* daemon setup */
+#define PROC_ENVCLEAR (1<<4) /* clear environment */
+#define PROC_FOREGROUND (1<<14) /* system(3) setup */
+#define PROC_GID (1<<5) /* setgid(getgid()) */
+#define PROC_IGNORE (1<<6) /* ignore parent pipe errors */
+#define PROC_OVERLAY (1<<7) /* overlay current process if possible */
+#define PROC_PARANOID (1<<8) /* restrict everything */
+#define PROC_PRIVELEGED (1<<9) /* setuid(0), setgid(getegid()) */
+#define PROC_READ (1<<10) /* proc pipe fd 1 returned */
+#define PROC_SESSION (1<<11) /* session leader */
+#define PROC_UID (1<<12) /* setuid(getuid()) */
+#define PROC_WRITE (1<<13) /* proc pipe fd 0 returned */
+#define PROC_ZOMBIE (1<<15) /* proc may leave a zombie behind */
+
+#define PROC_ARG_BIT 14 /* bits per op arg */
+#define PROC_OP_BIT 4 /* bits per op */
+
+#define PROC_ARG_NULL ((1<<PROC_ARG_BIT)-1)
+
+#define PROC_fd_dup 0x4
+#define PROC_FD_CHILD 0x1
+#define PROC_FD_PARENT 0x2
+
+#define PROC_sig_dfl 0x8
+#define PROC_sig_ign 0x9
+
+#define PROC_sys_pgrp 0xa
+#define PROC_sys_umask 0xb
+
+#define PROC_op1(o,a) (((o)<<(2*PROC_ARG_BIT))|((a)&((PROC_ARG_NULL<<PROC_ARG_BIT)|PROC_ARG_NULL)))
+#define PROC_op2(o,a,b) (((o)<<(2*PROC_ARG_BIT))|(((b)&PROC_ARG_NULL)<<PROC_ARG_BIT)|((a)&PROC_ARG_NULL))
+
+#define PROC_FD_CLOSE(p,f) PROC_op2(PROC_fd_dup|(f),p,PROC_ARG_NULL)
+#define PROC_FD_DUP(p,c,f) PROC_op2(PROC_fd_dup|(f),p,c)
+#define PROC_SIG_DFL(s) PROC_op1(PROC_sig_dfl,s,0)
+#define PROC_SIG_IGN(s) PROC_op1(PROC_sig_ign,s,0)
+#define PROC_SYS_PGRP(g) PROC_op1(PROC_sys_pgrp,g)
+#define PROC_SYS_UMASK(m) PROC_op1(PROC_sys_umask,m,0)
+
+#define PROC_OP(x) (((x)>>(2*PROC_ARG_BIT))&((1<<PROC_OP_BIT)-1))
+#define PROC_ARG(x,n) ((n)?(((x)>>(((n)-1)*PROC_ARG_BIT))&PROC_ARG_NULL):(((x)&~((1<<(2*PROC_ARG_BIT))-1))==~((1<<(2*PROC_ARG_BIT))-1))?(-1):((x)&~((1<<(2*PROC_ARG_BIT))-1)))
+
+typedef struct
+{
+ pid_t pid; /* process id */
+ pid_t pgrp; /* process group id */
+ int rfd; /* read fd if applicable */
+ int wfd; /* write fd if applicable */
+
+#ifdef _PROC_PRIVATE_
+_PROC_PRIVATE_
+#endif
+
+} Proc_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int procclose __PROTO__((Proc_t*));
+extern __MANGLE__ int procfree __PROTO__((Proc_t*));
+extern __MANGLE__ Proc_t* procopen __PROTO__((const char*, char**, char**, long*, long));
+extern __MANGLE__ int procrun __PROTO__((const char*, char**));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/prototyped.h b/usr/src/lib/libast/sparc/include/ast/prototyped.h
new file mode 100644
index 0000000000..113fb94d24
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/prototyped.h
@@ -0,0 +1,59 @@
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/re_comp.h b/usr/src/lib/libast/sparc/include/ast/re_comp.h
new file mode 100644
index 0000000000..5da565e880
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/re_comp.h
@@ -0,0 +1,52 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * re_comp interface definitions
+ *
+ * OBSOLETE: use <regex.h>
+ */
+
+#ifndef _RE_COMP_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _RE_COMP_H
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ char* re_comp __PROTO__((const char*));
+extern __MANGLE__ int re_exec __PROTO__((const char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/recfmt.h b/usr/src/lib/libast/sparc/include/ast/recfmt.h
new file mode 100644
index 0000000000..1a66761ec2
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/recfmt.h
@@ -0,0 +1,94 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * record format interface
+ */
+
+#ifndef _RECFMT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _RECFMT_H 1
+
+#include <ast.h>
+
+typedef uint32_t Recfmt_t;
+
+#define REC_delimited 0
+#define REC_fixed 1
+#define REC_variable 2
+#define REC_method 14
+#define REC_none 15
+
+#define REC_M_path 0
+#define REC_M_data 1
+
+#define RECTYPE(f) (((f)>>28)&((1<<4)-1))
+
+#define REC_D_TYPE(d) ((REC_delimited<<28)|((d)&((1<<8)-1)))
+#define REC_D_DELIMITER(f) ((f)&((1<<8)-1))
+
+#define REC_F_TYPE(s) ((REC_fixed<<28)|((s)&((1<<28)-1)))
+#define REC_F_SIZE(f) ((f)&((1<<28)-1))
+
+#define REC_U_TYPE(t,a) (((t)<<28)|((a)&((1<<28)-1)))
+#define REC_U_ATTRIBUTES(f) ((f)&~((1<<28)-1))
+
+#define REC_V_TYPE(h,o,z,l,i) ((REC_variable<<28)|((h)<<23)|((o)<<19)|(((z)-1)<<18)|((l)<<17)|((i)<<16))
+#define REC_V_RECORD(f,s) (((f)&(((1<<16)-1)<<16))|(s))
+#define REC_V_HEADER(f) (((f)>>23)&((1<<5)-1))
+#define REC_V_OFFSET(f) (((f)>>19)&((1<<4)-1))
+#define REC_V_LENGTH(f) ((((f)>>18)&1)+1)
+#define REC_V_LITTLE(f) (((f)>>17)&1)
+#define REC_V_INCLUSIVE(f) (((f)>>16)&1)
+#define REC_V_SIZE(f) ((f)&((1<<16)-1))
+#define REC_V_ATTRIBUTES(f) ((f)&~((1<<16)-1))
+
+#define REC_M_TYPE(i) ((REC_method<<28)|(i))
+#define REC_M_INDEX(f) ((f)&((1<<28)-1))
+
+#define REC_N_TYPE() 0xffffffff
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ char* fmtrec __PROTO__((Recfmt_t, int));
+extern __MANGLE__ Recfmt_t recfmt __PROTO__((const __V_*, size_t, off_t));
+extern __MANGLE__ Recfmt_t recstr __PROTO__((const char*, char**));
+extern __MANGLE__ ssize_t reclen __PROTO__((Recfmt_t, const __V_*, size_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/regex.h b/usr/src/lib/libast/sparc/include/ast/regex.h
new file mode 100644
index 0000000000..b1a8976991
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/regex.h
@@ -0,0 +1,227 @@
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+#ifdef _AST_STD_I
+#define _REGEX_H -1
+#define regex_t int
+#define regmatch_t int
+#endif
+#ifndef _REGEX_H
+#define _REGEX_H 1
+#undef regex_t
+#undef regmatch_t
+
+#include <ast_common.h>
+
+#define REG_VERSION 20030916L
+
+/* regcomp flags */
+
+#define REG_AUGMENTED 0x00000001 /* enable ! & < > */
+#define REG_EXTENDED 0x00000002 /* enable ( | ) */
+#define REG_ICASE 0x00000004 /* ignore case in match */
+#define REG_NEWLINE 0x00000008 /* ^/$ match embedded \n */
+#define REG_NOSUB 0x00000010 /* don't report subexp matches */
+#define REG_SHELL 0x00000020 /* shell pattern syntax */
+
+/* nonstandard regcomp flags */
+
+#define REG_LEFT 0x00000100 /* implicit ^... */
+#define REG_LITERAL 0x00000200 /* no operators */
+#define REG_MINIMAL 0x00000400 /* minimal match */
+#define REG_NULL 0x00000800 /* allow null patterns */
+#define REG_RIGHT 0x00001000 /* implicit ...$ */
+#define REG_LENIENT 0x00002000 /* look the other way */
+#define REG_ESCAPE 0x00004000 /* \ escapes delimiter in [...] */
+#define REG_FIRST 0x00008000 /* first match found will do */
+#define REG_MULTIPLE 0x00010000 /* multiple \n sep patterns */
+#define REG_DISCIPLINE 0x00020000 /* regex_t.re_disc is valid */
+#define REG_SPAN 0x00040000 /* . matches \n */
+#define REG_COMMENT 0x00080000 /* ignore pattern space & #...\n*/
+#define REG_MULTIREF 0x00100000 /* multiple digit backrefs */
+#define REG_MUSTDELIM 0x08000000 /* all delimiters required */
+#define REG_DELIMITED 0x10000000 /* pattern[0] is delimiter */
+#define REG_SHELL_GROUP 0x20000000 /* (|&) inside [@|&](...) only */
+
+#define REG_SHELL_DOT 0x00200000 /* explicit leading . match */
+#define REG_SHELL_ESCAPED 0x00400000 /* \ not special */
+#define REG_SHELL_PATH 0x00800000 /* explicit / match */
+
+/* regexec flags */
+
+#define REG_NOTBOL 0x00000040 /* ^ is not a special char */
+#define REG_NOTEOL 0x00000080 /* $ is not a special char */
+
+/* nonstandard regexec flags */
+
+#define REG_INVERT 0x01000000 /* invert regrexec match sense */
+#define REG_STARTEND 0x02000000 /* subject==match[0].rm_{so,eo} */
+#define REG_ADVANCE 0x04000000 /* advance match[0].rm_{so,eo} */
+
+/* regalloc flags */
+
+#define REG_NOFREE 0x00000001 /* don't free */
+
+/* regsub flags */
+
+#define REG_SUB_ALL 0x00000001 /* substitute all occurrences */
+#define REG_SUB_LOWER 0x00000002 /* substitute to lower case */
+#define REG_SUB_UPPER 0x00000004 /* substitute to upper case */
+#define REG_SUB_PRINT 0x00000010 /* internal no-op */
+#define REG_SUB_NUMBER 0x00000020 /* internal no-op */
+#define REG_SUB_STOP 0x00000040 /* internal no-op */
+#define REG_SUB_WRITE 0x00000080 /* internal no-op */
+#define REG_SUB_LAST 0x00000100 /* last substitution option */
+#define REG_SUB_FULL 0x00000200 /* fully delimited */
+#define REG_SUB_USER 0x00001000 /* first user flag bit */
+
+/* regex error codes */
+
+#define REG_ENOSYS (-1) /* not supported */
+#define REG_NOMATCH 1 /* regexec didn't match */
+#define REG_BADPAT 2 /* invalid regular expression */
+#define REG_ECOLLATE 3 /* invalid collation element */
+#define REG_ECTYPE 4 /* invalid character class */
+#define REG_EESCAPE 5 /* trailing \ in pattern */
+#define REG_ESUBREG 6 /* invalid \digit backreference */
+#define REG_EBRACK 7 /* [...] imbalance */
+#define REG_EPAREN 8 /* \(...\) or (...) imbalance */
+#define REG_EBRACE 9 /* \{...\} or {...} imbalance */
+#define REG_BADBR 10 /* invalid {...} digits */
+#define REG_ERANGE 11 /* invalid [...] range endpoint */
+#define REG_ESPACE 12 /* out of space */
+#define REG_BADRPT 13 /* unary op not preceeded by re */
+#define REG_ENULL 14 /* empty subexpr in pattern */
+#define REG_ECOUNT 15 /* re component count overflow */
+#define REG_BADESC 16 /* invalid \char escape */
+#define REG_VERSIONID 17 /* version id (pseudo error) */
+#define REG_EFLAGS 18 /* flags conflict */
+#define REG_EDELIM 19 /* invalid or omitted delimiter */
+#define REG_PANIC 20 /* unrecoverable internal error */
+
+struct regex_s; typedef struct regex_s regex_t;
+struct regdisc_s; typedef struct regdisc_s regdisc_t;
+
+typedef int (*regclass_t) __PROTO__((int));
+typedef int32_t regflags_t;
+typedef int regoff_t;
+typedef int (*regerror_t) __PROTO__((const regex_t*, regdisc_t*, int, ...));
+typedef __V_* (*regcomp_t) __PROTO__((const regex_t*, const char*, size_t, regdisc_t*));
+typedef int (*regexec_t) __PROTO__((const regex_t*, __V_*, const char*, size_t, const char*, size_t, char**, regdisc_t*));
+typedef __V_* (*regresize_t) __PROTO__((__V_*, __V_*, size_t));
+typedef int (*regrecord_t) __PROTO__((__V_*, const char*, size_t));
+
+typedef struct regmatch_s
+{
+ regoff_t rm_so; /* offset of start */
+ regoff_t rm_eo; /* offset of end */
+} regmatch_t;
+
+typedef struct regsub_s
+{
+ regflags_t re_flags; /* regsubcomp() flags */
+ char* re_buf; /* regsubexec() output buffer */
+ size_t re_len; /* re_buf length */
+ int re_min; /* regsubcomp() min matches */
+#ifdef _REG_SUB_PRIVATE_
+ _REG_SUB_PRIVATE_
+#endif
+} regsub_t;
+
+struct regdisc_s
+{
+ unsigned long re_version; /* discipline version */
+ regflags_t re_flags; /* discipline flags */
+ regerror_t re_errorf; /* error function */
+ int re_errorlevel; /* errorf level */
+ regresize_t re_resizef; /* alloc/free function */
+ __V_* re_resizehandle;/* resizef handle */
+ regcomp_t re_compf; /* (?{...}) compile function */
+ regexec_t re_execf; /* (?{...}) execute function */
+ unsigned char* re_map; /* external to native ccode map */
+};
+
+typedef struct regstat_s
+{
+ regflags_t re_flags; /* REG_LEFT|REG_RIGHT */
+ ssize_t re_min; /* min anchored match length */
+ ssize_t re_max; /* max anchored match length */
+ ssize_t re_record; /* regrexec() match length */
+} regstat_t;
+
+struct regex_s
+{
+ size_t re_nsub; /* number of subexpressions */
+ struct reglib_s*re_info; /* library private info */
+ size_t re_npat; /* number of pattern chars used */
+ regdisc_t* re_disc; /* REG_DISCIPLINE discipline */
+ regsub_t* re_sub; /* regsubcomp() data */
+};
+
+#define reginit(disc) (memset(disc,0,sizeof(*(disc))),(disc)->re_version=REG_VERSION)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int regcomp __PROTO__((regex_t*, const char*, regflags_t));
+extern __MANGLE__ size_t regerror __PROTO__((int, const regex_t*, char*, size_t));
+extern __MANGLE__ int regexec __PROTO__((const regex_t*, const char*, size_t, regmatch_t*, regflags_t));
+extern __MANGLE__ void regfree __PROTO__((regex_t*));
+
+/* nonstandard hooks */
+
+#define _REG_cache 1 /* have regcache() */
+#define _REG_class 1 /* have regclass() */
+#define _REG_collate 1 /* have regcollate(), regclass() */
+#define _REG_comb 1 /* have regcomb() */
+#define _REG_decomp 1 /* have regdecomp() */
+#define _REG_dup 1 /* have regdup() */
+#define _REG_fatal 1 /* have regfatal(), regfatalpat() */
+#define _REG_ncomp 1 /* have regncomp() */
+#define _REG_nexec 1 /* have regnexec() */
+#define _REG_rexec 1 /* have regrexec(), regrecord() */
+#define _REG_stat 1 /* have regstat() */
+#define _REG_subcomp 1 /* have regsubcomp(), regsubexec() */
+
+extern __MANGLE__ regclass_t regclass __PROTO__((const char*, char**));
+extern __MANGLE__ int regaddclass __PROTO__((const char*, regclass_t));
+extern __MANGLE__ int regcollate __PROTO__((const char*, char**, char*, int));
+extern __MANGLE__ int regcomb __PROTO__((regex_t*, regex_t*));
+extern __MANGLE__ size_t regdecomp __PROTO__((regex_t*, regflags_t, char*, size_t));
+extern __MANGLE__ int regdup __PROTO__((regex_t*, regex_t*));
+extern __MANGLE__ int regncomp __PROTO__((regex_t*, const char*, size_t, regflags_t));
+extern __MANGLE__ int regnexec __PROTO__((const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t));
+extern __MANGLE__ void regfatal __PROTO__((regex_t*, int, int));
+extern __MANGLE__ void regfatalpat __PROTO__((regex_t*, int, int, const char*));
+extern __MANGLE__ int regrecord __PROTO__((const regex_t*));
+extern __MANGLE__ int regrexec __PROTO__((const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t, int, __V_*, regrecord_t));
+extern __MANGLE__ regstat_t* regstat __PROTO__((const regex_t*));
+
+extern __MANGLE__ regex_t* regcache __PROTO__((const char*, regflags_t, int*));
+
+extern __MANGLE__ int regsubcomp __PROTO__((regex_t*, const char*, const regflags_t*, int, regflags_t));
+extern __MANGLE__ int regsubexec __PROTO__((const regex_t*, const char*, size_t, regmatch_t*));
+extern __MANGLE__ int regsubflags __PROTO__((regex_t*, const char*, char**, int, const regflags_t*, int*, regflags_t*));
+extern __MANGLE__ void regsubfree __PROTO__((regex_t*));
+
+/* obsolete hooks */
+
+#ifndef _SFIO_H
+struct _sfio_s;
+#endif
+
+extern __MANGLE__ void regalloc __PROTO__((__V_*, regresize_t, regflags_t));
+extern __MANGLE__ int regsub __PROTO__((const regex_t*, struct _sfio_s*, const char*, const char*, size_t, regmatch_t*, regflags_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/regexp.h b/usr/src/lib/libast/sparc/include/ast/regexp.h
new file mode 100644
index 0000000000..b7f3ed6313
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/regexp.h
@@ -0,0 +1,139 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * regexp interface and partial implementation
+ * what a novel approach
+ * don't do it again
+ *
+ * OBSOLETE: use <regex.h>
+ */
+
+#ifndef _REGEXP_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _REGEXP_H
+
+#define NBRA 9
+
+typedef struct
+{
+ char* re_braslist[NBRA];
+ char* re_braelist[NBRA];
+ char* re_loc1;
+ char* re_loc2;
+ char* re_locs;
+ int re_circf;
+ int re_nbra;
+ int re_nodelim;
+ int re_sed;
+} regexp_t;
+
+#define braslist _re_info.re_braslist
+#define braelist _re_info.re_braelist
+#define circf _re_info.re_circf
+#define loc1 _re_info.re_loc1
+#define loc2 _re_info.re_loc2
+#define locs _re_info.re_locs
+#define nbra _re_info.re_nbra
+#define nodelim _re_info.re_nodelim
+#define sed _re_info.re_sed
+
+#define advance(a,b) _re_exec(&_re_info,a,b,1)
+#define compile(a,b,c,d) _re_read(&_re_info,a,b,c,d)
+#define step(a,b) _re_exec(&_re_info,a,b,0)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _re_comp __PROTO__((regexp_t*, const char*, char*, unsigned int));
+extern __MANGLE__ int _re_exec __PROTO__((regexp_t*, const char*, const char*, int));
+extern __MANGLE__ char* _re_putc __PROTO__((int));
+extern __MANGLE__ char* _re_read __PROTO__((regexp_t*, const char*, char*, const char*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#ifndef _REGEXP_DECLARE
+
+regexp_t _re_info;
+
+char*
+_re_read __PARAM__((register regexp_t* re, const char* instring, char* ep, const char* endbuf, int seof), (re, instring, ep, endbuf, seof)) __OTORP__(register regexp_t* re; const char* instring; char* ep; const char* endbuf; int seof;){
+ register int c;
+
+ static const char* prev;
+
+#ifdef INIT
+ INIT;
+#endif
+
+ re->re_nodelim = 0;
+ if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0)
+ {
+ if (c != seof)
+ {
+ UNGETC(c);
+ re->re_nodelim = 1;
+ }
+ if (!re->re_sed && !prev)
+ { ERROR(41); }
+ RETURN((char*)endbuf);
+ }
+ UNGETC(c);
+ prev = 0;
+ for (;;)
+ {
+ if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0)
+ {
+ if (re->re_sed)
+ { ERROR(36); }
+ UNGETC(c);
+ re->re_nodelim = 1;
+ break;
+ }
+ if (c == '\\')
+ {
+ _re_putc(c);
+ if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0)
+ { ERROR(36); }
+ }
+ _re_putc(c);
+ }
+ if (c = _re_comp(re, _re_putc(0), ep, (char*)endbuf - ep))
+ { ERROR(c); }
+ prev = endbuf;
+ RETURN((char*)prev);
+}
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/sfdisc.h b/usr/src/lib/libast/sparc/include/ast/sfdisc.h
new file mode 100644
index 0000000000..9e657f045b
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/sfdisc.h
@@ -0,0 +1,82 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * AT&T Research
+ *
+ * sfio discipline interface definitions
+ */
+
+#ifndef _SFDISC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SFDISC_H
+
+#include <ast.h>
+
+#define SFDCEVENT(a,b,n) ((((a)-'A'+1)<<11)^(((b)-'A'+1)<<6)^(n))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#define SFSK_DISCARD SFDCEVENT('S','K',1)
+
+/*
+ * %(...) printf support
+ */
+
+typedef int (*Sf_key_lookup_t) __PROTO__((__V_*, Sffmt_t*, const char*, char**, Sflong_t*));
+typedef char* (*Sf_key_convert_t) __PROTO__((__V_*, Sffmt_t*, const char*, char*, Sflong_t));
+
+extern __MANGLE__ int sfkeyprintf __PROTO__((Sfio_t*, __V_*, const char*, Sf_key_lookup_t, Sf_key_convert_t));
+#define sfkeyprintf sfkeyprintf_20000308 /* Sffmt_t* callback args */
+extern __MANGLE__ int sfkeyprintf __PROTO__((Sfio_t*, __V_*, const char*, Sf_key_lookup_t, Sf_key_convert_t));
+
+/*
+ * pure sfio read and/or write disciplines
+ */
+
+extern __MANGLE__ int sfdcdio __PROTO__((Sfio_t*, size_t));
+extern __MANGLE__ int sfdcdos __PROTO__((Sfio_t*));
+extern __MANGLE__ int sfdcfilter __PROTO__((Sfio_t*, const char*));
+extern __MANGLE__ int sfdcmore __PROTO__((Sfio_t*, const char*, int, int));
+extern __MANGLE__ int sfdcprefix __PROTO__((Sfio_t*, const char*));
+extern __MANGLE__ int sfdcseekable __PROTO__((Sfio_t*));
+extern __MANGLE__ int sfdcslow __PROTO__((Sfio_t*));
+extern __MANGLE__ int sfdctee __PROTO__((Sfio_t*, Sfio_t*));
+extern __MANGLE__ int sfdcunion __PROTO__((Sfio_t*, Sfio_t**, int));
+
+extern __MANGLE__ Sfio_t* sfdcsubstream __PROTO__((Sfio_t*, Sfio_t*, Sfoff_t, Sfoff_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/sfio.h b/usr/src/lib/libast/sparc/include/ast/sfio.h
new file mode 100644
index 0000000000..9feba3043e
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/sfio.h
@@ -0,0 +1,452 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _SFIO_H
+#define _SFIO_H 1
+
+#define SFIO_VERSION 20050202L
+
+/* Public header file for the sfio library
+**
+** Written by Kiem-Phong Vo
+*/
+
+typedef struct _sfio_s Sfio_t;
+typedef struct _sfdisc_s Sfdisc_t;
+
+#if defined(_AST_STD_H) || defined(_PACKAGE_ast) && defined(_SFIO_PRIVATE)
+#include <ast_std.h>
+#else
+#include <ast_common.h>
+#endif /* _PACKAGE_ast */
+
+/* Sfoff_t should be large enough for largest file address */
+#define Sfoff_t intmax_t
+#define Sflong_t intmax_t
+#define Sfulong_t uintmax_t
+#define Sfdouble_t _ast_fltmax_t
+
+typedef ssize_t (*Sfread_f)_ARG_((Sfio_t*, Void_t*, size_t, Sfdisc_t*));
+typedef ssize_t (*Sfwrite_f)_ARG_((Sfio_t*, const Void_t*, size_t, Sfdisc_t*));
+typedef Sfoff_t (*Sfseek_f)_ARG_((Sfio_t*, Sfoff_t, int, Sfdisc_t*));
+typedef int (*Sfexcept_f)_ARG_((Sfio_t*, int, Void_t*, Sfdisc_t*));
+
+/* discipline structure */
+struct _sfdisc_s
+{ Sfread_f readf; /* read function */
+ Sfwrite_f writef; /* write function */
+ Sfseek_f seekf; /* seek function */
+ Sfexcept_f exceptf; /* to handle exceptions */
+ Sfdisc_t* disc; /* the continuing discipline */
+};
+
+#include <sfio_s.h>
+
+/* formatting environment */
+typedef struct _sffmt_s Sffmt_t;
+typedef int (*Sffmtext_f)_ARG_((Sfio_t*, Void_t*, Sffmt_t*));
+typedef int (*Sffmtevent_f)_ARG_((Sfio_t*, int, Void_t*, Sffmt_t*));
+struct _sffmt_s
+{ long version;/* version of this structure */
+ Sffmtext_f extf; /* function to process arguments */
+ Sffmtevent_f eventf; /* process events */
+
+ char* form; /* format string to stack */
+ va_list args; /* corresponding arg list */
+
+ int fmt; /* format character */
+ ssize_t size; /* object size */
+ int flags; /* formatting flags */
+ int width; /* width of field */
+ int precis; /* precision required */
+ int base; /* conversion base */
+
+ char* t_str; /* type string */
+ ssize_t n_str; /* length of t_str */
+
+ Void_t* mbs; /* multibyte state for format string */
+
+ Void_t* none; /* unused for now */
+};
+#define sffmtversion(fe,type) \
+ ((type) ? ((fe)->version = SFIO_VERSION) : (fe)->version)
+
+#define SFFMT_SSHORT 000000010 /* 'hh' flag, char */
+#define SFFMT_TFLAG 000000020 /* 't' flag, ptrdiff_t */
+#define SFFMT_ZFLAG 000000040 /* 'z' flag, size_t */
+
+#define SFFMT_LEFT 000000100 /* left-justification */
+#define SFFMT_SIGN 000000200 /* must have a sign */
+#define SFFMT_BLANK 000000400 /* if not signed, prepend a blank */
+#define SFFMT_ZERO 000001000 /* zero-padding on the left */
+#define SFFMT_ALTER 000002000 /* alternate formatting */
+#define SFFMT_THOUSAND 000004000 /* thousand grouping */
+#define SFFMT_SKIP 000010000 /* skip assignment in scanf() */
+#define SFFMT_SHORT 000020000 /* 'h' flag */
+#define SFFMT_LONG 000040000 /* 'l' flag */
+#define SFFMT_LLONG 000100000 /* 'll' flag */
+#define SFFMT_LDOUBLE 000200000 /* 'L' flag */
+#define SFFMT_VALUE 000400000 /* value is returned */
+#define SFFMT_ARGPOS 001000000 /* getting arg for $ patterns */
+#define SFFMT_IFLAG 002000000 /* 'I' flag */
+#define SFFMT_JFLAG 004000000 /* 'j' flag, intmax_t */
+#define SFFMT_CENTER 010000000 /* '=' flag, center justification */
+#define SFFMT_SET 017777770 /* flags settable on calling extf */
+
+/* for sfmutex() call */
+#define SFMTX_LOCK 0 /* up mutex count */
+#define SFMTX_TRYLOCK 1 /* try to up mutex count */
+#define SFMTX_UNLOCK 2 /* down mutex count */
+#define SFMTX_CLRLOCK 3 /* clear mutex count */
+
+/* various constants */
+#ifndef NULL
+#define NULL 0
+#endif
+#ifndef EOF
+#define EOF (-1)
+#endif
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+/* bits for various types of files */
+#define SF_READ 0000001 /* open for reading */
+#define SF_WRITE 0000002 /* open for writing */
+#define SF_STRING 0000004 /* a string stream */
+#define SF_APPENDWR 0000010 /* file is in append mode only */
+#define SF_MALLOC 0000020 /* buffer is malloc-ed */
+#define SF_LINE 0000040 /* line buffering */
+#define SF_SHARE 0000100 /* stream with shared file descriptor */
+#define SF_EOF 0000200 /* eof was detected */
+#define SF_ERROR 0000400 /* an error happened */
+#define SF_STATIC 0001000 /* a stream that cannot be freed */
+#define SF_IOCHECK 0002000 /* call exceptf before doing IO */
+#define SF_PUBLIC 0004000 /* SF_SHARE and follow physical seek */
+#define SF_MTSAFE 0010000 /* need thread safety */
+#define SF_WHOLE 0020000 /* preserve wholeness of sfwrite/sfputr */
+#define SF_IOINTR 0040000 /* return on interrupts */
+#define SF_WCWIDTH 0100000 /* wcwidth display stream */
+
+#define SF_FLAGS 0177177 /* PUBLIC FLAGS PASSABLE TO SFNEW() */
+#define SF_SETS 0177163 /* flags passable to sfset() */
+
+#ifndef _SF_NO_OBSOLETE
+#define SF_BUFCONST 0400000 /* unused flag - for compatibility only */
+#endif
+
+/* for sfgetr/sfreserve to hold a record */
+#define SF_LOCKR 0000010 /* lock record, stop access to stream */
+#define SF_LASTR 0000020 /* get the last incomplete record */
+
+/* exception events: SF_NEW(0), SF_READ(1), SF_WRITE(2) and the below */
+#define SF_SEEK 3 /* seek error */
+#define SF_CLOSING 4 /* when stream is about to be closed */
+#define SF_DPUSH 5 /* when discipline is being pushed */
+#define SF_DPOP 6 /* when discipline is being popped */
+#define SF_DPOLL 7 /* see if stream is ready for I/O */
+#define SF_DBUFFER 8 /* buffer not empty during push or pop */
+#define SF_SYNC 9 /* announcing start/end synchronization */
+#define SF_PURGE 10 /* a sfpurge() call was issued */
+#define SF_FINAL 11 /* closing is done except stream free */
+#define SF_READY 12 /* a polled stream is ready */
+#define SF_LOCKED 13 /* stream is in a locked state */
+#define SF_ATEXIT 14 /* process is exiting */
+#define SF_EVENT 100 /* start of user-defined events */
+
+/* for stack and disciplines */
+#define SF_POPSTACK ((Sfio_t*)0) /* pop the stream stack */
+#define SF_POPDISC ((Sfdisc_t*)0) /* pop the discipline stack */
+
+/* for the notify function and discipline exception */
+#define SF_NEW 0 /* new stream */
+#define SF_SETFD (-1) /* about to set the file descriptor */
+
+#define SF_BUFSIZE 8192 /* default buffer size */
+#define SF_UNBOUND (-1) /* unbounded buffer size */
+
+/* namespace incursion workarounds -- migrate to the new names */
+#if !_mac_SF_APPEND
+#define SF_APPEND SF_APPENDWR /* BSDI sys/stat.h */
+#endif
+#if !_mac_SF_CLOSE
+#define SF_CLOSE SF_CLOSING /* AIX sys/socket.h */
+#endif
+
+_BEGIN_EXTERNS_
+
+/* standard in/out/err streams */
+
+#if _BLD_sfio && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+#if !_BLD_sfio && defined(__IMPORT__)
+#define extern extern __IMPORT__
+#endif
+
+extern ssize_t _Sfi;
+extern ssize_t _Sfmaxr;
+
+extern Sfio_t* sfstdin;
+extern Sfio_t* sfstdout;
+extern Sfio_t* sfstderr;
+
+#if _UWIN
+#undef extern
+#endif
+
+extern Sfio_t _Sfstdin;
+extern Sfio_t _Sfstdout;
+extern Sfio_t _Sfstderr;
+
+#undef extern
+
+#if _BLD_sfio && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Sfio_t* sfnew _ARG_((Sfio_t*, Void_t*, size_t, int, int));
+extern Sfio_t* sfopen _ARG_((Sfio_t*, const char*, const char*));
+extern Sfio_t* sfpopen _ARG_((Sfio_t*, const char*, const char*));
+extern Sfio_t* sfstack _ARG_((Sfio_t*, Sfio_t*));
+extern Sfio_t* sfswap _ARG_((Sfio_t*, Sfio_t*));
+extern Sfio_t* sftmp _ARG_((size_t));
+extern int sfpurge _ARG_((Sfio_t*));
+extern int sfpoll _ARG_((Sfio_t**, int, int));
+extern Void_t* sfreserve _ARG_((Sfio_t*, ssize_t, int));
+extern int sfresize _ARG_((Sfio_t*, Sfoff_t));
+extern int sfsync _ARG_((Sfio_t*));
+extern int sfclrlock _ARG_((Sfio_t*));
+extern Void_t* sfsetbuf _ARG_((Sfio_t*, Void_t*, size_t));
+extern Sfdisc_t* sfdisc _ARG_((Sfio_t*,Sfdisc_t*));
+extern int sfraise _ARG_((Sfio_t*, int, Void_t*));
+extern int sfnotify _ARG_((void(*)(Sfio_t*, int, int)));
+extern int sfset _ARG_((Sfio_t*, int, int));
+extern int sfsetfd _ARG_((Sfio_t*, int));
+extern Sfio_t* sfpool _ARG_((Sfio_t*, Sfio_t*, int));
+extern ssize_t sfread _ARG_((Sfio_t*, Void_t*, size_t));
+extern ssize_t sfwrite _ARG_((Sfio_t*, const Void_t*, size_t));
+extern Sfoff_t sfmove _ARG_((Sfio_t*, Sfio_t*, Sfoff_t, int));
+extern int sfclose _ARG_((Sfio_t*));
+extern Sfoff_t sftell _ARG_((Sfio_t*));
+extern Sfoff_t sfseek _ARG_((Sfio_t*, Sfoff_t, int));
+extern ssize_t sfputr _ARG_((Sfio_t*, const char*, int));
+extern char* sfgetr _ARG_((Sfio_t*, int, int));
+extern ssize_t sfnputc _ARG_((Sfio_t*, int, size_t));
+extern int sfungetc _ARG_((Sfio_t*, int));
+extern int sfprintf _ARG_((Sfio_t*, const char*, ...));
+extern char* sfprints _ARG_((const char*, ...));
+extern ssize_t sfsprintf _ARG_((char*, size_t, const char*, ...));
+extern ssize_t sfvsprintf _ARG_((char*, size_t, const char*, va_list));
+extern int sfvprintf _ARG_((Sfio_t*, const char*, va_list));
+extern int sfscanf _ARG_((Sfio_t*, const char*, ...));
+extern int sfsscanf _ARG_((const char*, const char*, ...));
+extern int sfvsscanf _ARG_((const char*, const char*, va_list));
+extern int sfvscanf _ARG_((Sfio_t*, const char*, va_list));
+
+/* mutex locking for thread-safety */
+extern int sfmutex _ARG_((Sfio_t*, int));
+
+/* io functions with discipline continuation */
+extern ssize_t sfrd _ARG_((Sfio_t*, Void_t*, size_t, Sfdisc_t*));
+extern ssize_t sfwr _ARG_((Sfio_t*, const Void_t*, size_t, Sfdisc_t*));
+extern Sfoff_t sfsk _ARG_((Sfio_t*, Sfoff_t, int, Sfdisc_t*));
+extern ssize_t sfpkrd _ARG_((int, Void_t*, size_t, int, long, int));
+
+/* portable handling of primitive types */
+extern int sfdlen _ARG_((Sfdouble_t));
+extern int sfllen _ARG_((Sflong_t));
+extern int sfulen _ARG_((Sfulong_t));
+
+extern int sfputd _ARG_((Sfio_t*, Sfdouble_t));
+extern int sfputl _ARG_((Sfio_t*, Sflong_t));
+extern int sfputu _ARG_((Sfio_t*, Sfulong_t));
+extern int sfputm _ARG_((Sfio_t*, Sfulong_t, Sfulong_t));
+extern int sfputc _ARG_((Sfio_t*, int));
+
+extern Sfdouble_t sfgetd _ARG_((Sfio_t*));
+extern Sflong_t sfgetl _ARG_((Sfio_t*));
+extern Sfulong_t sfgetu _ARG_((Sfio_t*));
+extern Sfulong_t sfgetm _ARG_((Sfio_t*, Sfulong_t));
+extern int sfgetc _ARG_((Sfio_t*));
+
+extern int _sfputd _ARG_((Sfio_t*, Sfdouble_t));
+extern int _sfputl _ARG_((Sfio_t*, Sflong_t));
+extern int _sfputu _ARG_((Sfio_t*, Sfulong_t));
+extern int _sfputm _ARG_((Sfio_t*, Sfulong_t, Sfulong_t));
+extern int _sfflsbuf _ARG_((Sfio_t*, int));
+
+extern int _sffilbuf _ARG_((Sfio_t*, int));
+
+extern int _sfdlen _ARG_((Sfdouble_t));
+extern int _sfllen _ARG_((Sflong_t));
+extern int _sfulen _ARG_((Sfulong_t));
+
+/* miscellaneous function analogues of fast in-line functions */
+extern Sfoff_t sfsize _ARG_((Sfio_t*));
+extern int sfclrerr _ARG_((Sfio_t*));
+extern int sfeof _ARG_((Sfio_t*));
+extern int sferror _ARG_((Sfio_t*));
+extern int sffileno _ARG_((Sfio_t*));
+extern int sfstacked _ARG_((Sfio_t*));
+extern ssize_t sfvalue _ARG_((Sfio_t*));
+extern ssize_t sfslen _ARG_((void));
+extern ssize_t sfmaxr _ARG_((ssize_t, int));
+
+#undef extern
+_END_EXTERNS_
+
+/* coding long integers in a portable and compact fashion */
+#define SF_SBITS 6
+#define SF_UBITS 7
+#define SF_BBITS 8
+#define SF_SIGN (1 << SF_SBITS)
+#define SF_MORE (1 << SF_UBITS)
+#define SF_BYTE (1 << SF_BBITS)
+#define SF_U1 SF_MORE
+#define SF_U2 (SF_U1*SF_U1)
+#define SF_U3 (SF_U2*SF_U1)
+#define SF_U4 (SF_U3*SF_U1)
+
+#if __cplusplus
+#define _SF_(f) (f)
+#else
+#define _SF_(f) ((Sfio_t*)(f))
+#endif
+
+#define __sf_putd(f,v) (_sfputd(_SF_(f),(Sfdouble_t)(v)))
+#define __sf_putl(f,v) (_sfputl(_SF_(f),(Sflong_t)(v)))
+#define __sf_putu(f,v) (_sfputu(_SF_(f),(Sfulong_t)(v)))
+#define __sf_putm(f,v,m) (_sfputm(_SF_(f),(Sfulong_t)(v),(Sfulong_t)(m)))
+
+#define __sf_putc(f,c) (_SF_(f)->_next >= _SF_(f)->_endw ? \
+ _sfflsbuf(_SF_(f),(int)((unsigned char)(c))) : \
+ (int)(*_SF_(f)->_next++ = (unsigned char)(c)) )
+#define __sf_getc(f) (_SF_(f)->_next >= _SF_(f)->_endr ? _sffilbuf(_SF_(f),0) : \
+ (int)(*_SF_(f)->_next++) )
+
+#define __sf_dlen(v) (_sfdlen((Sfdouble_t)(v)) )
+#define __sf_llen(v) (_sfllen((Sflong_t)(v)) )
+#define __sf_ulen(v) ((Sfulong_t)(v) < SF_U1 ? 1 : (Sfulong_t)(v) < SF_U2 ? 2 : \
+ (Sfulong_t)(v) < SF_U3 ? 3 : (Sfulong_t)(v) < SF_U4 ? 4 : 5)
+
+#define __sf_fileno(f) (_SF_(f)->_file)
+#define __sf_eof(f) (_SF_(f)->_flags&SF_EOF)
+#define __sf_error(f) (_SF_(f)->_flags&SF_ERROR)
+#define __sf_clrerr(f) (_SF_(f)->_flags &= ~(SF_ERROR|SF_EOF))
+#define __sf_stacked(f) (_SF_(f)->_push != (Sfio_t*)0)
+#define __sf_value(f) (_SF_(f)->_val)
+#define __sf_slen() (_Sfi)
+#define __sf_maxr(n,s) ((s)?((_Sfi=_Sfmaxr),(_Sfmaxr=(n)),_Sfi):_Sfmaxr)
+
+#if defined(__INLINE__) && !_BLD_sfio
+
+__INLINE__ int sfputd(Sfio_t* f, Sfdouble_t v) { return __sf_putd(f,v); }
+__INLINE__ int sfputl(Sfio_t* f, Sflong_t v) { return __sf_putl(f,v); }
+__INLINE__ int sfputu(Sfio_t* f, Sfulong_t v) { return __sf_putu(f,v); }
+__INLINE__ int sfputm(Sfio_t* f, Sfulong_t v, Sfulong_t m)
+ { return __sf_putm(f,v,m); }
+
+__INLINE__ int sfputc(Sfio_t* f, int c) { return __sf_putc(f,c); }
+__INLINE__ int sfgetc(Sfio_t* f) { return __sf_getc(f); }
+
+__INLINE__ int sfdlen(Sfdouble_t v) { return __sf_dlen(v); }
+__INLINE__ int sfllen(Sflong_t v) { return __sf_llen(v); }
+__INLINE__ int sfulen(Sfulong_t v) { return __sf_ulen(v); }
+
+__INLINE__ int sffileno(Sfio_t* f) { return __sf_fileno(f); }
+__INLINE__ int sfeof(Sfio_t* f) { return __sf_eof(f); }
+__INLINE__ int sferror(Sfio_t* f) { return __sf_error(f); }
+__INLINE__ int sfclrerr(Sfio_t* f) { return __sf_clrerr(f); }
+__INLINE__ int sfstacked(Sfio_t* f) { return __sf_stacked(f); }
+__INLINE__ ssize_t sfvalue(Sfio_t* f) { return __sf_value(f); }
+__INLINE__ ssize_t sfslen() { return __sf_slen(); }
+__INLINE__ ssize_t sfmaxr(ssize_t n, int s) { return __sf_maxr(n,s); }
+
+#else
+
+#define sfputd(f,v) ( __sf_putd((f),(v)) )
+#define sfputl(f,v) ( __sf_putl((f),(v)) )
+#define sfputu(f,v) ( __sf_putu((f),(v)) )
+#define sfputm(f,v,m) ( __sf_putm((f),(v),(m)) )
+
+#define sfputc(f,c) ( __sf_putc((f),(c)) )
+#define sfgetc(f) ( __sf_getc(f) )
+
+#define sfdlen(v) ( __sf_dlen(v) )
+#define sfllen(v) ( __sf_llen(v) )
+#define sfulen(v) ( __sf_ulen(v) )
+
+#define sffileno(f) ( __sf_fileno(f) )
+#define sfeof(f) ( __sf_eof(f) )
+#define sferror(f) ( __sf_error(f) )
+#define sfclrerr(f) ( __sf_clrerr(f) )
+#define sfstacked(f) ( __sf_stacked(f) )
+#define sfvalue(f) ( __sf_value(f) )
+#define sfslen() ( __sf_slen() )
+#define sfmaxr(n,s) ( __sf_maxr(n,s) )
+
+#endif /*__INLINE__*/
+
+#ifndef _SFSTR_H /* GSF's string manipulation stuff */
+#define _SFSTR_H 1
+
+#define sfstropen() sfnew(0, 0, -1, -1, SF_READ|SF_WRITE|SF_STRING)
+#define sfstrclose(f) sfclose(f)
+
+#define sfstrseek(f,p,m) \
+ ( (m) == SEEK_SET ? \
+ (((p) < 0 || (p) > (f)->_size) ? (char*)0 : \
+ (char*)((f)->_next = (f)->_data+(p)) ) \
+ : (m) == SEEK_CUR ? \
+ ((f)->_next += (p), \
+ (((f)->_next < (f)->_data || (f)->_next > (f)->_data+(f)->_size) ? \
+ ((f)->_next -= (p), (char*)0) : (char*)(f)->_next ) ) \
+ : (m) == SEEK_END ? \
+ ( ((p) > 0 || (f)->_size+(p) < 0) ? (char*)0 : \
+ (char*)((f)->_next = (f)->_data+(f)->_size+(p)) ) \
+ : (char*)0 \
+ )
+
+#define sfstrsize(f) ((f)->_size)
+#define sfstrtell(f) ((f)->_next - (f)->_data)
+#define sfstrpend(f) ((f)->_size - sfstrtell())
+#define sfstrbase(f) ((char*)(f)->_data)
+
+#define sfstruse(f) \
+ (sfputc((f),0) < 0 ? (char*)0 : (char*)((f)->_next = (f)->_data) \
+ )
+
+#define sfstrrsrv(f,n) \
+ (sfreserve((f),(n),SF_WRITE|SF_LOCKR), sfwrite((f),(f)->_next,0), \
+ ((f)->_next+(n) <= (f)->_data+(f)->_size ? (char*)(f)->_next : (char*)0) \
+ )
+
+#define sfstrbuf(f,b,n,m) \
+ (sfsetbuf((f),(b),(n)), ((f)->_flags |= (m) ? SF_MALLOC : 0), \
+ ((f)->_data == (unsigned char*)(b) ? 0 : -1) \
+ )
+
+#endif /* _SFSTR_H */
+
+#endif /* _SFIO_H */
diff --git a/usr/src/lib/libast/sparc/include/ast/sfio_s.h b/usr/src/lib/libast/sparc/include/ast/sfio_s.h
new file mode 100644
index 0000000000..27936a16b1
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/sfio_s.h
@@ -0,0 +1,51 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _SFIO_S_H
+#define _SFIO_S_H 1
+
+/*
+ * sfio file structure used by sfio and the stdio source compatibility library
+ */
+
+#if !defined(_SFHDR_H) && defined(_SFIO_H) && SFIO_VERSION < 20020214L
+#define _data data
+#define _endb endb
+#define _next next
+#endif
+
+struct _sfio_s
+{ unsigned char* _next; /* next position to read/write from */
+ unsigned char* _endw; /* end of write buffer */
+ unsigned char* _endr; /* end of read buffer */
+ unsigned char* _endb; /* end of buffer */
+ struct _sfio_s* _push; /* the stream that was pushed on */
+ unsigned short _flags; /* type of stream */
+ short _file; /* file descriptor */
+ unsigned char* _data; /* base of data buffer */
+ ssize_t _size; /* buffer size */
+ ssize_t _val; /* values or string lengths */
+#ifdef _SFIO_PRIVATE
+ _SFIO_PRIVATE
+#endif
+};
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/sfio_t.h b/usr/src/lib/libast/sparc/include/ast/sfio_t.h
new file mode 100644
index 0000000000..36be6ecc94
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/sfio_t.h
@@ -0,0 +1,126 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _SFIO_T_H
+#define _SFIO_T_H 1
+
+/* This header file is for library writers who need to know certain
+** internal info concerning the full Sfio_t structure. Including this
+** file means that you agree to track closely with sfio development
+** in case its internal architecture is changed.
+**
+** Written by Kiem-Phong Vo
+*/
+
+/* the parts of Sfio_t private to sfio functions */
+#define _SFIO_PRIVATE \
+ Sfoff_t extent; /* current file size */ \
+ Sfoff_t here; /* current physical location */ \
+ unsigned char getr; /* the last sfgetr separator */ \
+ unsigned char tiny[1];/* for unbuffered read stream */ \
+ unsigned short bits; /* private flags */ \
+ unsigned int mode; /* current io mode */ \
+ struct _sfdisc_s* disc; /* discipline */ \
+ struct _sfpool_s* pool; /* the pool containing this */ \
+ struct _sfrsrv_s* rsrv; /* reserved buffer */ \
+ struct _sfproc_s* proc; /* coprocess id, etc. */ \
+ Void_t* mutex; /* mutex for thread-safety */ \
+ Void_t* stdio; /* stdio FILE if any */ \
+ Sfoff_t lpos; /* last seek position */ \
+ size_t iosz; /* preferred size for I/O */ \
+ size_t blksz; /* preferred block size */ \
+ Void_t* fill[1];/* modest expansion */
+
+#include "sfio.h"
+
+/* mode bit to indicate that the structure hasn't been initialized */
+#define SF_INIT 0000004
+#define SF_DCDOWN 00010000
+
+/* short-hand for common stream types */
+#define SF_RDWR (SF_READ|SF_WRITE)
+#define SF_RDSTR (SF_READ|SF_STRING)
+#define SF_WRSTR (SF_WRITE|SF_STRING)
+#define SF_RDWRSTR (SF_RDWR|SF_STRING)
+
+/* for static initialization of an Sfio_t structure */
+#define SFNEW(data,size,file,type,disc,mutex) \
+ { (unsigned char*)(data), /* next */ \
+ (unsigned char*)(data), /* endw */ \
+ (unsigned char*)(data), /* endr */ \
+ (unsigned char*)(data), /* endb */ \
+ (Sfio_t*)0, /* push */ \
+ (unsigned short)((type)&SF_FLAGS), /* flags */ \
+ (short)(file), /* file */ \
+ (unsigned char*)(data), /* data */ \
+ (ssize_t)(size), /* size */ \
+ (ssize_t)(-1), /* val */ \
+ (Sfoff_t)0, /* extent */ \
+ (Sfoff_t)0, /* here */ \
+ 0, /* getr */ \
+ {0}, /* tiny */ \
+ 0, /* bits */ \
+ (unsigned int)(((type)&(SF_RDWR))|SF_INIT), /* mode */ \
+ (struct _sfdisc_s*)(disc), /* disc */ \
+ (struct _sfpool_s*)0, /* pool */ \
+ (struct _sfrsrv_s*)0, /* rsrv */ \
+ (struct _sfproc_s*)0, /* proc */ \
+ (mutex), /* mutex */ \
+ (Void_t*)0, /* stdio */ \
+ (Sfoff_t)0, /* lpos */ \
+ (size_t)0 /* iosz */ \
+ }
+
+/* function to clear an Sfio_t structure */
+#define SFCLEAR(f,mtx) \
+ ( (f)->next = (unsigned char*)0, /* next */ \
+ (f)->endw = (unsigned char*)0, /* endw */ \
+ (f)->endr = (unsigned char*)0, /* endr */ \
+ (f)->endb = (unsigned char*)0, /* endb */ \
+ (f)->push = (Sfio_t*)0, /* push */ \
+ (f)->flags = (unsigned short)0, /* flags */ \
+ (f)->file = -1, /* file */ \
+ (f)->data = (unsigned char*)0, /* data */ \
+ (f)->size = (ssize_t)(-1), /* size */ \
+ (f)->val = (ssize_t)(-1), /* val */ \
+ (f)->extent = (Sfoff_t)(-1), /* extent */ \
+ (f)->here = (Sfoff_t)0, /* here */ \
+ (f)->getr = 0, /* getr */ \
+ (f)->tiny[0] = 0, /* tiny */ \
+ (f)->bits = 0, /* bits */ \
+ (f)->mode = 0, /* mode */ \
+ (f)->disc = (struct _sfdisc_s*)0, /* disc */ \
+ (f)->pool = (struct _sfpool_s*)0, /* pool */ \
+ (f)->rsrv = (struct _sfrsrv_s*)0, /* rsrv */ \
+ (f)->proc = (struct _sfproc_s*)0, /* proc */ \
+ (f)->mutex = (mtx), /* mutex */ \
+ (f)->stdio = (Void_t*)0, /* stdio */ \
+ (f)->lpos = (Sfoff_t)0, /* lpos */ \
+ (f)->iosz = (size_t)0 /* iosz */ \
+ )
+
+/* expose next stream inside discipline function; state saved in int f */
+#define SFDCNEXT(sp,f) (((f)=(sp)->bits&SF_DCDOWN),(sp)->bits|=SF_DCDOWN)
+
+/* restore SFDCNEXT() state from int f */
+#define SFDCPREV(sp,f) ((f)?(0):((sp)->bits&=~SF_DCDOWN))
+
+#endif /* _SFIO_T_H */
diff --git a/usr/src/lib/libast/sparc/include/ast/sig.h b/usr/src/lib/libast/sparc/include/ast/sig.h
new file mode 100644
index 0000000000..3b09fd5f94
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/sig.h
@@ -0,0 +1,152 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/sig.sh by iffe version 2007-04-04 : : */
+#ifndef _def_sig_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_sig_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define sig_info _sig_info_
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide kill killpg
+#else
+#define kill ______kill
+#define killpg ______killpg
+#endif
+#include <signal.h>
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide kill killpg
+#else
+#undef kill
+#undef killpg
+#endif
+#ifndef sigmask
+#define sigmask(s) (1<<((s)-1))
+#endif
+typedef void (*Sig_handler_t) __PROTO__((int));
+
+
+#define Handler_t Sig_handler_t
+
+#define SIG_REG_PENDING (-1)
+#define SIG_REG_POP 0
+#define SIG_REG_EXEC 00001
+#define SIG_REG_PROC 00002
+#define SIG_REG_TERM 00004
+#define SIG_REG_ALL 00777
+#define SIG_REG_SET 01000
+
+typedef struct
+{
+ char** name;
+ char** text;
+ int sigmax;
+} Sig_info_t;
+
+extern __MANGLE__ int kill __PROTO__((pid_t, int));
+extern __MANGLE__ int killpg __PROTO__((pid_t, int));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Sig_info_t sig_info;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int sigcritical __PROTO__((int));
+extern __MANGLE__ int sigunblock __PROTO__((int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/stack.h b/usr/src/lib/libast/sparc/include/ast/stack.h
new file mode 100644
index 0000000000..ad32ebb8ab
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/stack.h
@@ -0,0 +1,94 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * homogenous stack routine definitions
+ */
+
+#ifndef _STACK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _STACK_H
+
+typedef struct stacktable* STACK; /* stack pointer */
+typedef struct stackposition STACKPOS; /* stack position */
+
+struct stackblock /* stack block cell */
+{
+ __V_** stack; /* actual stack */
+ struct stackblock* prev; /* previous block in list */
+ struct stackblock* next; /* next block in list */
+};
+
+struct stackposition /* stack position */
+{
+ struct stackblock* block; /* current block pointer */
+ int index; /* index within current block */
+};
+
+struct stacktable /* stack information */
+{
+ struct stackblock* blocks; /* stack table blocks */
+ __V_* error; /* error return value */
+ int size; /* size of each block */
+ STACKPOS position; /* current stack position */
+};
+
+/*
+ * map old names to new
+ */
+
+#define mkstack stackalloc
+#define rmstack stackfree
+#define clrstack stackclear
+#define getstack stackget
+#define pushstack stackpush
+#define popstack stackpop
+#define posstack stacktell
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ STACK stackalloc __PROTO__((int, __V_*));
+extern __MANGLE__ void stackfree __PROTO__((STACK));
+extern __MANGLE__ void stackclear __PROTO__((STACK));
+extern __MANGLE__ __V_* stackget __PROTO__((STACK));
+extern __MANGLE__ int stackpush __PROTO__((STACK, __V_*));
+extern __MANGLE__ int stackpop __PROTO__((STACK));
+extern __MANGLE__ void stacktell __PROTO__((STACK, int, STACKPOS*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/stak.h b/usr/src/lib/libast/sparc/include/ast/stak.h
new file mode 100644
index 0000000000..e0e707b0e5
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/stak.h
@@ -0,0 +1,64 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * David Korn
+ * AT&T Research
+ *
+ * Interface definitions for a stack-like storage library
+ *
+ */
+
+#ifndef _STAK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _STAK_H
+
+#include <stk.h>
+
+#define Stak_t Sfio_t
+#define staksp stkstd
+#define STAK_SMALL STK_SMALL
+
+#define stakptr(n) stkptr(stkstd,n)
+#define staktell() stktell(stkstd)
+#define stakputc(c) sfputc(stkstd,(c))
+#define stakwrite(b,n) sfwrite(stkstd,(b),(n))
+#define stakputs(s) (sfputr(stkstd,(s),0),--stkstd->_next)
+#define stakseek(n) stkseek(stkstd,n)
+#define stakcreate(n) stkopen(n)
+#define stakinstall(s,f) stkinstall(s,f)
+#define stakdelete(s) stkclose(s)
+#define staklink(s) stklink(s)
+#define stakalloc(n) stkalloc(stkstd,n)
+#define stakcopy(s) stkcopy(stkstd,s)
+#define stakset(c,n) stkset(stkstd,c,n)
+#define stakfreeze(n) stkfreeze(stkstd,n)
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/stdio.h b/usr/src/lib/libast/sparc/include/ast/stdio.h
new file mode 100644
index 0000000000..7e137c5712
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/stdio.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_stdio.h>
diff --git a/usr/src/lib/libast/sparc/include/ast/stk.h b/usr/src/lib/libast/sparc/include/ast/stk.h
new file mode 100644
index 0000000000..24947d24f1
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/stk.h
@@ -0,0 +1,91 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * David Korn
+ * AT&T Research
+ *
+ * Interface definitions for a stack-like storage library
+ *
+ */
+
+#ifndef _STK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _STK_H
+
+#include <sfio.h>
+
+#define _Stk_data _Stak_data
+
+#define stkstd (&_Stk_data)
+
+#define Stk_t Sfio_t
+
+#define STK_SMALL 1 /* small stkopen stack */
+#define STK_NULL 2 /* return NULL on overflow */
+
+#define stkptr(sp,n) ((char*)((sp)->_data)+(n))
+#define stktop(sp) ((char*)(sp)->_next)
+#define stktell(sp) ((sp)->_next-(sp)->_data)
+#define stkseek(sp,n) ((n)==0?(char*)((sp)->_next=(sp)->_data):_stkseek(sp,n))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Sfio_t _Stk_data;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Stk_t* stkopen __PROTO__((int));
+extern __MANGLE__ Stk_t* stkinstall __PROTO__((Stk_t*, char*(*)(int)));
+extern __MANGLE__ int stkclose __PROTO__((Stk_t*));
+extern __MANGLE__ int stklink __PROTO__((Stk_t*));
+extern __MANGLE__ char* stkalloc __PROTO__((Stk_t*, unsigned));
+extern __MANGLE__ char* stkcopy __PROTO__((Stk_t*,const char*));
+extern __MANGLE__ char* stkset __PROTO__((Stk_t*, char*, unsigned));
+extern __MANGLE__ char* _stkseek __PROTO__((Stk_t*, unsigned));
+extern __MANGLE__ char* stkfreeze __PROTO__((Stk_t*, unsigned));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/swap.h b/usr/src/lib/libast/sparc/include/ast/swap.h
new file mode 100644
index 0000000000..d89248d12b
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/swap.h
@@ -0,0 +1,64 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * integral representation conversion support definitions
+ * supports sizeof(integral_type)<=sizeof(intmax_t)
+ */
+
+#ifndef _SWAP_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SWAP_H
+
+#include <ast_common.h>
+
+#define int_swap _ast_intswap
+
+#define SWAP_MAX 8
+
+#define SWAPOP(n) (((n)&int_swap)^(n))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ __V_* swapmem __PROTO__((int, const __V_*, __V_*, size_t));
+extern __MANGLE__ intmax_t swapget __PROTO__((int, const __V_*, int));
+extern __MANGLE__ __V_* swapput __PROTO__((int, __V_*, int, intmax_t));
+extern __MANGLE__ int swapop __PROTO__((const __V_*, const __V_*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/tar.h b/usr/src/lib/libast/sparc/include/ast/tar.h
new file mode 100644
index 0000000000..910b6e8612
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/tar.h
@@ -0,0 +1,127 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Standard Archive Format
+ * USTAR - Uniform Standard Tape ARchive
+ */
+
+#ifndef _TAR_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TAR_H
+
+#define TBLOCK 512
+#define NAMSIZ 100
+#define PFXSIZ 155
+
+#define TMODLEN 8
+#define TUIDLEN 8
+#define TGIDLEN 8
+#define TSIZLEN 12
+#define TMTMLEN 12
+#define TCKSLEN 8
+
+#define TMAGIC "ustar" /* ustar and a null */
+#define TMAGLEN 6
+#define TVERSION "00" /* 00 and no null */
+#define TVERSLEN 2
+#define TUNMLEN 32
+#define TGNMLEN 32
+#define TDEVLEN 8
+
+/*
+ * values used in typeflag field
+ */
+
+#define REGTYPE '0' /* regular file */
+#define AREGTYPE 0 /* alternate REGTYPE */
+#define LNKTYPE '1' /* hard link */
+#define SYMTYPE '2' /* soft link */
+#define CHRTYPE '3' /* character special */
+#define BLKTYPE '4' /* block special */
+#define DIRTYPE '5' /* directory */
+#define FIFOTYPE '6' /* FIFO special */
+#define CONTTYPE '7' /* reserved */
+#define SOKTYPE '8' /* socket */
+#define EXTTYPE 'x' /* extended header */
+#define GLBTYPE 'g' /* global extended header */
+#define LLNKTYPE 'K' /* long link path */
+#define LREGTYPE 'L' /* long file path */
+#define VERTYPE 'V' /* version */
+
+/*
+ * bits used in mode field
+ */
+
+#define TSUID 04000 /* set uid on exec */
+#define TSGID 02000 /* set gid on exec */
+#define TSVTX 01000 /* sticky bit -- reserved */
+
+/*
+ * file permissions
+ */
+
+#define TUREAD 00400 /* read by owner */
+#define TUWRITE 00200 /* write by owner */
+#define TUEXEC 00100 /* execute by owner */
+#define TGREAD 00040 /* read by group */
+#define TGWRITE 00020 /* execute by group */
+#define TGEXEC 00010 /* write by group */
+#define TOREAD 00004 /* read by other */
+#define TOWRITE 00002 /* write by other */
+#define TOEXEC 00001 /* execute by other */
+
+struct header
+{
+ char name[NAMSIZ];
+ char mode[TMODLEN];
+ char uid[TUIDLEN];
+ char gid[TGIDLEN];
+ char size[TSIZLEN];
+ char mtime[TMTMLEN];
+ char chksum[TCKSLEN];
+ char typeflag;
+ char linkname[NAMSIZ];
+ char magic[TMAGLEN];
+ char version[TVERSLEN];
+ char uname[TUNMLEN];
+ char gname[TGNMLEN];
+ char devmajor[TDEVLEN];
+ char devminor[TDEVLEN];
+ char prefix[PFXSIZ];
+};
+
+union hblock
+{
+ char dummy[TBLOCK];
+ struct header dbuf;
+};
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/times.h b/usr/src/lib/libast/sparc/include/ast/times.h
new file mode 100644
index 0000000000..25e81662be
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/times.h
@@ -0,0 +1,65 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * -last clock_t,time_t interface definitions plus
+ *
+ * <ast.h>
+ * <time.h>
+ * <sys/time.h>
+ * <sys/times.h>
+ */
+
+#ifndef _TIMES_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TIMES_H
+
+#include <ast.h>
+
+#undef _TIMES_H
+#include <ast_time.h>
+#ifndef _TIMES_H
+#define _TIMES_H
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int touch __PROTO__((const char*, time_t, time_t, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/tm.h b/usr/src/lib/libast/sparc/include/ast/tm.h
new file mode 100644
index 0000000000..f790a9a66e
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/tm.h
@@ -0,0 +1,205 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * time conversion support definitions
+ */
+
+#ifndef _TM_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TM_H
+
+#define TM_VERSION 20070319L
+
+#include <ast.h>
+#include <times.h>
+
+#undef daylight
+
+#define tmset(z) tminit(z)
+#define tmisleapyear(y) (!((y)%4)&&(((y)%100)||!((((y)<1900)?((y)+1900):(y))%400)))
+
+#define TM_ADJUST (1<<0) /* local doesn't do leap secs */
+#define TM_LEAP (1<<1) /* do leap seconds */
+#define TM_UTC (1<<2) /* universal coordinated ref */
+
+#define TM_PEDANTIC (1<<3) /* pedantic date parse */
+#define TM_DATESTYLE (1<<4) /* date(1) style mmddHHMMccyy */
+#define TM_SUBSECOND (1<<5) /* <something>%S => ...%S.%P */
+
+#define TM_DST (-60) /* default minutes for DST */
+#define TM_LOCALZONE (25 * 60) /* use local time zone offset */
+#define TM_UTCZONE (26 * 60) /* UTC "time zone" */
+#define TM_MAXLEAP 1 /* max leap secs per leap */
+#define TM_WINDOW 69 /* century windowing guard year */
+
+/*
+ * these indices must agree with tm_dform[]
+ */
+
+#define TM_MONTH_ABBREV 0
+#define TM_MONTH 12
+#define TM_DAY_ABBREV 24
+#define TM_DAY 31
+#define TM_TIME 38
+#define TM_DATE 39
+#define TM_DEFAULT 40
+#define TM_MERIDIAN 41
+
+#define TM_UT 43
+#define TM_DT 47
+#define TM_SUFFIXES 51
+#define TM_PARTS 55
+#define TM_HOURS 62
+#define TM_DAYS 66
+#define TM_LAST 69
+#define TM_THIS 72
+#define TM_NEXT 75
+#define TM_EXACT 78
+#define TM_NOISE 81
+#define TM_ORDINAL 85
+#define TM_DIGITS 95
+#define TM_CTIME 105
+#define TM_DATE_1 106
+#define TM_INTERNATIONAL 107
+#define TM_RECENT 108
+#define TM_DISTANT 109
+#define TM_MERIDIAN_TIME 110
+#define TM_ERA 111
+#define TM_ERA_DATE 112
+#define TM_ERA_TIME 113
+#define TM_ERA_DEFAULT 114
+#define TM_ERA_YEAR 115
+#define TM_ORDINALS 116
+#define TM_FINAL 126
+
+#define TM_NFORM 129
+
+typedef struct /* leap second info */
+{
+ time_t time; /* the leap second event */
+ int total; /* inclusive total since epoch */
+} Tm_leap_t;
+
+typedef struct /* time zone info */
+{
+ char* type; /* type name */
+ char* standard; /* standard time name */
+ char* daylight; /* daylight or summertime name */
+ short west; /* minutes west of GMT */
+ short dst; /* add to tz.west for DST */
+} Tm_zone_t;
+
+typedef struct /* tm library readonly data */
+{
+ char** format; /* default TM_* format strings */
+ char* lex; /* format lex type classes */
+ char* digit; /* output digits */
+ short* days; /* days in month i */
+ short* sum; /* days in months before i */
+ Tm_leap_t* leap; /* leap second table */
+ Tm_zone_t* zone; /* alternate timezone table */
+} Tm_data_t;
+
+typedef struct /* tm library global info */
+{
+ char* deformat; /* TM_DEFAULT override */
+ int flags; /* flags */
+ char** format; /* current format strings */
+ Tm_zone_t* date; /* timezone from last tmdate() */
+ Tm_zone_t* local; /* local timezone */
+ Tm_zone_t* zone; /* current timezone */
+} Tm_info_t;
+
+typedef struct Tm_s
+{
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+ uint32_t tm_nsec;
+ Tm_zone_t* tm_zone;
+} Tm_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Tm_data_t* _tm_datap_;
+extern __MANGLE__ Tm_info_t* _tm_infop_;
+
+#define tm_data (*_tm_datap_)
+#define tm_info (*_tm_infop_)
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ time_t tmdate __PROTO__((const char*, char**, time_t*));
+extern __MANGLE__ int tmequiv __PROTO__((Tm_t*));
+extern __MANGLE__ Tm_t* tmfix __PROTO__((Tm_t*));
+extern __MANGLE__ char* tmfmt __PROTO__((char*, size_t, const char*, time_t*));
+extern __MANGLE__ char* tmform __PROTO__((char*, const char*, time_t*));
+extern __MANGLE__ int tmgoff __PROTO__((const char*, char**, int));
+extern __MANGLE__ void tminit __PROTO__((Tm_zone_t*));
+extern __MANGLE__ time_t tmleap __PROTO__((time_t*));
+extern __MANGLE__ int tmlex __PROTO__((const char*, char**, char**, int, char**, int));
+extern __MANGLE__ char** tmlocale __PROTO__((void));
+extern __MANGLE__ Tm_t* tmmake __PROTO__((time_t*));
+extern __MANGLE__ char* tmpoff __PROTO__((char*, size_t, const char*, int, int));
+extern __MANGLE__ time_t tmscan __PROTO__((const char*, char**, const char*, char**, time_t*, long));
+extern __MANGLE__ int tmsleep __PROTO__((time_t, time_t));
+extern __MANGLE__ time_t tmtime __PROTO__((Tm_t*, int));
+extern __MANGLE__ Tm_zone_t* tmtype __PROTO__((const char*, char**));
+extern __MANGLE__ int tmweek __PROTO__((Tm_t*, int, int, int));
+extern __MANGLE__ int tmword __PROTO__((const char*, char**, const char*, char**, int));
+extern __MANGLE__ Tm_zone_t* tmzone __PROTO__((const char*, char**, const char*, int*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/tmx.h b/usr/src/lib/libast/sparc/include/ast/tmx.h
new file mode 100644
index 0000000000..9388396616
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/tmx.h
@@ -0,0 +1,149 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/tmx by iffe version 2007-04-04 : : */
+
+#ifndef _TMX_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TMX_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Time_t support
+ */
+
+#include <tm.h>
+#include <tv.h>
+
+#define TMX_MAXDATE "2554-07-21+23:34:33.709551614 UTC"
+#define TMX_MAXYEAR 2554
+#define TMX_MAXSEC ((Time_t)18446744073)
+#define TMX_MAXNSEC 709551614
+#define TMX_RESOLUTION 1000000000
+
+typedef uint64_t Time_t;
+typedef uint64_t Tmxsec_t;
+typedef uint32_t Tmxnsec_t;
+
+#define tmxsec(t) ((Tmxsec_t)((t)/1000000000))
+#define tmxnsec(t) ((Tmxnsec_t)((t)%1000000000))
+#define tmxsns(s,n) (((((Time_t)(s))*1000000000))+((Time_t)(n)))
+
+#define TMX_NOTIME ((Time_t)(-1))
+#define TMX_NOW tmxgettime()
+#define TMX_MAXTIME tmxsns(TMX_MAXSEC,TMX_MAXNSEC)
+
+#define tmx2tv(t,v) ((v)->tv_nsec=tmxnsec(t),(v)->tv_sec=tmxsec(t))
+#define tv2tmx(v) tmxsns((v)->tv_sec,(v)->tv_nsec)
+
+#define tmxclock(p) tmxsns(((p)?*(p):time(NiL)),0)
+
+#define tmxgetatime(s) tmxsns((s)->st_atime,ST_ATIME_NSEC_GET(s))
+#define tmxgetctime(s) tmxsns((s)->st_ctime,ST_CTIME_NSEC_GET(s))
+#define tmxgetmtime(s) tmxsns((s)->st_mtime,ST_MTIME_NSEC_GET(s))
+
+#define tmxsetatime(s,t) ((s)->st_atime=tmxsec(t),ST_ATIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetctime(s,t) ((s)->st_ctime=tmxsec(t),ST_CTIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetmtime(s,t) ((s)->st_mtime=tmxsec(t),ST_MTIME_NSEC_SET(s,tmxnsec(t)))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Time_t tmxdate __PROTO__((const char*, char**, Time_t));
+extern __MANGLE__ char* tmxfmt __PROTO__((char*, size_t, const char*, Time_t));
+extern __MANGLE__ Time_t tmxleap __PROTO__((Time_t));
+extern __MANGLE__ Tm_t* tmxmake __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxscan __PROTO__((const char*, char**, const char*, char**, Time_t, long));
+extern __MANGLE__ int tmxsleep __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxtime __PROTO__((Tm_t*, int));
+
+extern __MANGLE__ Time_t tmxgettime __PROTO__((void));
+extern __MANGLE__ int tmxsettime __PROTO__((Time_t));
+
+extern __MANGLE__ int tmxtouch __PROTO__((const char*, Time_t, Time_t, Time_t, int));
+
+extern __MANGLE__ char* fmttmx __PROTO__((const char*, Time_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/tok.h b/usr/src/lib/libast/sparc/include/ast/tok.h
new file mode 100644
index 0000000000..3637489918
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/tok.h
@@ -0,0 +1,58 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * token stream interface definitions
+ */
+
+#ifndef _TOK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TOK_H
+
+#include <ast.h>
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Sfio_t* tokline __PROTO__((const char*, int, int*));
+extern __MANGLE__ int tokscan __PROTO__((char*, char**, const char*, ...));
+extern __MANGLE__ char* tokopen __PROTO__((char*, int));
+extern __MANGLE__ void tokclose __PROTO__((char*));
+extern __MANGLE__ char* tokread __PROTO__((char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/tv.h b/usr/src/lib/libast/sparc/include/ast/tv.h
new file mode 100644
index 0000000000..38633bccf2
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/tv.h
@@ -0,0 +1,132 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/tv by iffe version 2007-04-04 : : */
+
+#ifndef _TV_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TV_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Tv_t interface definitions
+ */
+
+#include <ast.h>
+
+#define TV_NSEC_IGNORE (1000000000L)
+#define TV_TOUCH_RETAIN ((Tv_t*)1)
+
+typedef struct Tv_s
+{
+ uint32_t tv_sec;
+ uint32_t tv_nsec;
+} Tv_t;
+
+#define ST_ATIME_NSEC_GET(st) ((st)->st_atim.tv_nsec)
+#define ST_CTIME_NSEC_GET(st) ((st)->st_ctim.tv_nsec)
+#define ST_MTIME_NSEC_GET(st) ((st)->st_mtim.tv_nsec)
+
+#define ST_ATIME_NSEC_SET(st,n) (ST_ATIME_NSEC_GET(st)=(n))
+#define ST_CTIME_NSEC_SET(st,n) (ST_CTIME_NSEC_GET(st)=(n))
+#define ST_MTIME_NSEC_SET(st,n) (ST_MTIME_NSEC_GET(st)=(n))
+
+#define tvgetatime(t,s) ((t)->tv_nsec=ST_ATIME_NSEC_GET(s),(t)->tv_sec=(s)->st_atime)
+#define tvgetmtime(t,s) ((t)->tv_nsec=ST_MTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_mtime)
+#define tvgetctime(t,s) ((t)->tv_nsec=ST_CTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_ctime)
+
+#define tvsetatime(t,s) (ST_ATIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_atime=(t)->tv_sec)
+#define tvsetmtime(t,s) (ST_MTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_mtime=(t)->tv_sec)
+#define tvsetctime(t,s) (ST_CTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_ctime=(t)->tv_sec)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int tvgettime __PROTO__((Tv_t*));
+extern __MANGLE__ int tvsettime __PROTO__((const Tv_t*));
+extern __MANGLE__ int tvcmp __PROTO__((const Tv_t*, const Tv_t*));
+extern __MANGLE__ int tvtouch __PROTO__((const char*, const Tv_t*, const Tv_t*, const Tv_t*, int));
+extern __MANGLE__ int tvsleep __PROTO__((const Tv_t*, Tv_t*));
+
+extern __MANGLE__ char* fmttv __PROTO__((const char*, Tv_t*));
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/usage.h b/usr/src/lib/libast/sparc/include/ast/usage.h
new file mode 100644
index 0000000000..81b59e1aca
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/usage.h
@@ -0,0 +1,37 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * error catalog and usage defaults
+ */
+
+#ifndef _USAGE_H
+#define _USAGE_H
+
+#ifndef ERROR_CATALOG
+#define ERROR_CATALOG 0
+#endif
+
+#ifndef USAGE_LICENSE
+#define USAGE_LICENSE "[-license?THIS IS AN UNLICENSED COPY]"
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/vdb.h b/usr/src/lib/libast/sparc/include/ast/vdb.h
new file mode 100644
index 0000000000..63e310c724
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/vdb.h
@@ -0,0 +1,55 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * virtual db file directory entry constants
+ */
+
+#ifndef VDB_MAGIC
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+
+#define VDB_MAGIC "vdb"
+
+#define VDB_DIRECTORY "DIRECTORY"
+#define VDB_UNION "UNION"
+#define VDB_DATE "DATE"
+#define VDB_MODE "MODE"
+
+#define VDB_DELIMITER ';'
+#define VDB_IGNORE '_'
+#define VDB_FIXED 10
+#define VDB_LENGTH ((int)sizeof(VDB_DIRECTORY)+2*(VDB_FIXED+1))
+#define VDB_OFFSET ((int)sizeof(VDB_DIRECTORY))
+#define VDB_SIZE (VDB_OFFSET+VDB_FIXED+1)
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/vecargs.h b/usr/src/lib/libast/sparc/include/ast/vecargs.h
new file mode 100644
index 0000000000..4d329cd154
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/vecargs.h
@@ -0,0 +1,56 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * vector argument interface definitions
+ */
+
+#ifndef _VECARGS_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _VECARGS_H
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int vecargs __PROTO__((char**, int*, char***));
+extern __MANGLE__ char** vecfile __PROTO__((const char*));
+extern __MANGLE__ void vecfree __PROTO__((char**, int));
+extern __MANGLE__ char** vecload __PROTO__((char*));
+extern __MANGLE__ char** vecstring __PROTO__((const char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/vmalloc.h b/usr/src/lib/libast/sparc/include/ast/vmalloc.h
new file mode 100644
index 0000000000..f0a8114c6a
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/vmalloc.h
@@ -0,0 +1,315 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _VMALLOC_H
+#define _VMALLOC_H 1
+
+/* Public header file for the virtual malloc package.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+
+#define VMALLOC_VERSION 20050928L
+
+#if _PACKAGE_ast
+#include <ast_std.h>
+#else
+#include <ast_common.h>
+#endif
+
+typedef struct _vmalloc_s Vmalloc_t;
+typedef struct _vmstat_s Vmstat_t;
+typedef struct _vmdisc_s Vmdisc_t;
+typedef struct _vmethod_s Vmethod_t;
+typedef Void_t* (*Vmemory_f)_ARG_((Vmalloc_t*, Void_t*, size_t, size_t, Vmdisc_t*));
+typedef int (*Vmexcept_f)_ARG_((Vmalloc_t*, int, Void_t*, Vmdisc_t*));
+
+struct _vmstat_s
+{ int n_busy; /* number of busy blocks */
+ int n_free; /* number of free blocks */
+ size_t s_busy; /* total amount of busy space */
+ size_t s_free; /* total amount of free space */
+ size_t m_busy; /* largest busy piece */
+ size_t m_free; /* largest free piece */
+ int n_seg; /* number of segments */
+ size_t extent; /* total size of region */
+};
+
+struct _vmdisc_s
+{ Vmemory_f memoryf; /* memory manipulator */
+ Vmexcept_f exceptf; /* exception handler */
+ size_t round; /* rounding requirement */
+};
+
+struct _vmethod_s
+{ Void_t* (*allocf)_ARG_((Vmalloc_t*,size_t));
+ Void_t* (*resizef)_ARG_((Vmalloc_t*,Void_t*,size_t,int));
+ int (*freef)_ARG_((Vmalloc_t*,Void_t*));
+ long (*addrf)_ARG_((Vmalloc_t*,Void_t*));
+ long (*sizef)_ARG_((Vmalloc_t*,Void_t*));
+ int (*compactf)_ARG_((Vmalloc_t*));
+ Void_t* (*alignf)_ARG_((Vmalloc_t*,size_t,size_t));
+ unsigned short meth;
+};
+
+struct _vmalloc_s
+{ Vmethod_t meth; /* method for allocation */
+ char* file; /* file name */
+ int line; /* line number */
+ Void_t* func; /* calling function */
+#ifdef _VM_PRIVATE_
+ _VM_PRIVATE_
+#endif
+};
+
+#undef VM_FLAGS /* solaris sys kernel clash */
+
+#define VM_TRUST 0000001 /* forgo some security checks */
+#define VM_TRACE 0000002 /* generate trace */
+#define VM_DBCHECK 0000004 /* check for boundary overwrite */
+#define VM_DBABORT 0000010 /* abort on any warning */
+#define VM_FLAGS 0000017 /* user-settable flags */
+
+#define VM_MTBEST 0000100 /* Vmbest method */
+#define VM_MTPOOL 0000200 /* Vmpool method */
+#define VM_MTLAST 0000400 /* Vmlast method */
+#define VM_MTDEBUG 0001000 /* Vmdebug method */
+#define VM_MTPROFILE 0002000 /* Vmdebug method */
+#define VM_METHODS 0003700 /* available allocation methods */
+
+#define VM_RSCOPY 0000001 /* copy old contents */
+#define VM_RSMOVE 0000002 /* old contents is moveable */
+#define VM_RSZERO 0000004 /* clear new space */
+
+/* exception types */
+#define VM_OPEN 0 /* region being opened */
+#define VM_CLOSE 1 /* announce being closed */
+#define VM_NOMEM 2 /* can't obtain memory */
+#define VM_BADADDR 3 /* bad addr in vmfree/vmresize */
+#define VM_DISC 4 /* discipline being changed */
+#define VM_ALLOC 5 /* announcement from vmalloc() */
+#define VM_FREE 6 /* announcement from vmfree() */
+#define VM_RESIZE 7 /* announcement from vmresize() */
+
+_BEGIN_EXTERNS_ /* public data */
+#if _BLD_vmalloc && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+#if !_BLD_vmalloc && defined(__IMPORT__)
+#define extern extern __IMPORT__
+#endif
+
+extern Vmethod_t* Vmbest; /* best allocation */
+extern Vmethod_t* Vmlast; /* last-block allocation */
+extern Vmethod_t* Vmpool; /* pool allocation */
+extern Vmethod_t* Vmdebug; /* allocation with debugging */
+extern Vmethod_t* Vmprofile; /* profiling memory usage */
+
+extern Vmdisc_t* Vmdcheap; /* heap discipline */
+extern Vmdisc_t* Vmdcsbrk; /* sbrk discipline */
+
+extern Vmalloc_t* Vmheap; /* heap region */
+extern Vmalloc_t* Vmregion; /* malloc region */
+
+#undef extern
+_END_EXTERNS_
+
+_BEGIN_EXTERNS_ /* public functions */
+#if _BLD_vmalloc && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Vmalloc_t* vmopen _ARG_(( Vmdisc_t*, Vmethod_t*, int ));
+extern int vmclose _ARG_(( Vmalloc_t* ));
+extern int vmclear _ARG_(( Vmalloc_t* ));
+extern int vmcompact _ARG_(( Vmalloc_t* ));
+
+extern Vmdisc_t* vmdisc _ARG_(( Vmalloc_t*, Vmdisc_t* ));
+
+extern Vmalloc_t* vmmopen _ARG_(( char*, Void_t*, size_t ));
+extern Void_t* vmmset _ARG_((Vmalloc_t*, int, Void_t*, int));
+
+extern Void_t* vmalloc _ARG_(( Vmalloc_t*, size_t ));
+extern Void_t* vmalign _ARG_(( Vmalloc_t*, size_t, size_t ));
+extern Void_t* vmresize _ARG_(( Vmalloc_t*, Void_t*, size_t, int ));
+extern Void_t* vmgetmem _ARG_(( Vmalloc_t*, Void_t*, size_t ));
+extern int vmfree _ARG_(( Vmalloc_t*, Void_t* ));
+
+extern long vmaddr _ARG_(( Vmalloc_t*, Void_t* ));
+extern long vmsize _ARG_(( Vmalloc_t*, Void_t* ));
+
+extern Vmalloc_t* vmregion _ARG_(( Void_t* ));
+extern Void_t* vmsegment _ARG_(( Vmalloc_t*, Void_t* ));
+extern int vmset _ARG_(( Vmalloc_t*, int, int ));
+
+extern Void_t* vmdbwatch _ARG_(( Void_t* ));
+extern int vmdbcheck _ARG_(( Vmalloc_t* ));
+extern int vmdebug _ARG_(( int ));
+
+extern int vmprofile _ARG_(( Vmalloc_t*, int ));
+
+extern int vmtrace _ARG_(( int ));
+extern int vmtrbusy _ARG_((Vmalloc_t*));
+
+extern int vmstat _ARG_((Vmalloc_t*, Vmstat_t*));
+
+extern int vmwalk _ARG_((Vmalloc_t*,
+ int(*)(Vmalloc_t*,Void_t*,size_t,Vmdisc_t*)));
+extern char* vmstrdup _ARG_((Vmalloc_t*, const char*));
+
+#if !defined(_BLD_vmalloc) && !defined(_AST_STD_H) && \
+ !defined(__stdlib_h) && !defined(__STDLIB_H) && \
+ !defined(_STDLIB_INCLUDED) && !defined(_INC_STDLIB)
+extern Void_t* malloc _ARG_(( size_t ));
+extern Void_t* realloc _ARG_(( Void_t*, size_t ));
+extern void free _ARG_(( Void_t* ));
+extern void cfree _ARG_(( Void_t* ));
+extern Void_t* calloc _ARG_(( size_t, size_t ));
+extern Void_t* memalign _ARG_(( size_t, size_t ));
+extern Void_t* valloc _ARG_(( size_t ));
+#endif
+
+#undef extern
+_END_EXTERNS_
+
+/* to coerce any value to a Vmalloc_t*, make ANSI happy */
+#define _VM_(vm) ((Vmalloc_t*)(vm))
+
+/* enable recording of where a call originates from */
+#ifdef VMFL
+
+#if defined(__FILE__)
+#define _VMFILE_(vm) (_VM_(vm)->file = (char*)__FILE__)
+#else
+#define _VMFILE_(vm) (_VM_(vm)->file = 0)
+#endif
+
+#if defined(__LINE__)
+#define _VMLINE_(vm) (_VM_(vm)->line = __LINE__)
+#else
+#define _VMLINE_(vm) (_VM_(vm)->line = 0)
+#endif
+
+#if defined(__FUNCTION__)
+#define _VMFUNC_(vm) (_VM_(vm)->func = (Void_t*)__FUNCTION__)
+#else
+#define _VMFUNC_(vm) (_VM_(vm)->func = 0)
+#endif
+
+#define _VMFL_(vm) (_VMFILE_(vm), _VMLINE_(vm), _VMFUNC_(vm))
+
+#define vmalloc(vm,sz) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.allocf))((vm),(sz)) )
+#define vmresize(vm,d,sz,type) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.resizef))\
+ ((vm),(Void_t*)(d),(sz),(type)) )
+#define vmfree(vm,d) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.freef))((vm),(Void_t*)(d)) )
+#define vmalign(vm,sz,align) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.alignf))((vm),(sz),(align)) )
+
+#undef malloc
+#undef realloc
+#undef calloc
+#undef free
+#undef memalign
+#undef valloc
+
+#if _map_malloc
+
+#define malloc(s) (_VMFL_(Vmregion), _ast_malloc((size_t)(s)) )
+#define realloc(d,s) (_VMFL_(Vmregion), _ast_realloc((Void_t*)(d),(size_t)(s)) )
+#define calloc(n,s) (_VMFL_(Vmregion), _ast_calloc((size_t)n, (size_t)(s)) )
+#define free(d) (_VMFL_(Vmregion), _ast_free((Void_t*)(d)) )
+#define memalign(a,s) (_VMFL_(Vmregion), _ast_memalign((size_t)(a),(size_t)(s)) )
+#define valloc(s) (_VMFL_(Vmregion), _ast_valloc((size_t)(s) )
+
+#else
+
+#if !_std_malloc
+
+#if __STD_C || defined(__STDPP__) || defined(__GNUC__)
+#define malloc(s) ( _VMFL_(Vmregion), (malloc)((size_t)(s)) )
+#define realloc(d,s) ( _VMFL_(Vmregion), (realloc)((Void_t*)(d),(size_t)(s)) )
+#define calloc(n,s) ( _VMFL_(Vmregion), (calloc)((size_t)n, (size_t)(s)) )
+#define free(d) ( _VMFL_(Vmregion), (free)((Void_t*)(d)) )
+#define memalign(a,s) ( _VMFL_(Vmregion), (memalign)((size_t)(a),(size_t)(s)) )
+#define valloc(s) ( _VMFL_(Vmregion), (valloc)((size_t)(s)) )
+#ifndef strdup
+#define strdup(s) ( _VMFL_(Vmregion), (strdup)((char*)(s)) )
+#endif
+
+#else
+
+#define _VMNM_(a,b,c,d,e,f) a/**/b/**/c/**/d/**/e/**/f
+#define malloc(s) ( _VMFL_(Vmregion), _VMNM_(mallo,/,*,*,/,c)\
+ ( (size_t)(s)) )
+#define realloc(d,s) ( _VMFL_(Vmregion), _VMNM_(reallo,/,*,*,/,c)\
+ ( (Void_t*)(d),(size_t)(s)) )
+#define calloc(n,s) ( _VMFL_(Vmregion), _VMNM_(callo,/,*,*,/,c)\
+ ( (size_t)n, (size_t)(s)) )
+#define free(d) ( _VMFL_(Vmregion), _VMNM_(fre,/,*,*,/,e)((Void_t*)(d)) )
+#define memalign(a,s) ( _VMFL_(Vmregion), _VMNM_(memalig,/,*,*,/,n)\
+ ( (size_t)(a),(size_t)(s)) )
+#define valloc(s) ( _VMFL_(Vmregion), _VMNM_(vallo,/,*,*,/,c)\
+ ( (size_t)(s)) )
+#ifndef strdup
+#define strdup(s) ( _VMFL_(Vmregion), _VMNM_(strdu,/,*,*,/,p)\
+ ((char*)(s)) )
+#endif
+
+#endif /*__STD_C || defined(__STDPP__) || defined(__GNUC__)*/
+
+#define cfree(d) free(d)
+
+#endif /* !_std_malloc */
+
+#endif /* _map_malloc */
+
+#endif /*VMFL*/
+
+/* non-debugging/profiling allocation calls */
+#ifndef vmalloc
+#define vmalloc(vm,sz) (*(_VM_(vm)->meth.allocf))((vm),(sz))
+#endif
+
+#ifndef vmresize
+#define vmresize(vm,d,sz,type) (*(_VM_(vm)->meth.resizef))\
+ ((vm),(Void_t*)(d),(sz),(type))
+#endif
+
+#ifndef vmfree
+#define vmfree(vm,d) (*(_VM_(vm)->meth.freef))((vm),(Void_t*)(d))
+#endif
+
+#ifndef vmalign
+#define vmalign(vm,sz,align) (*(_VM_(vm)->meth.alignf))((vm),(sz),(align))
+#endif
+
+#define vmaddr(vm,addr) (*(_VM_(vm)->meth.addrf))((vm),(Void_t*)(addr))
+#define vmsize(vm,addr) (*(_VM_(vm)->meth.sizef))((vm),(Void_t*)(addr))
+#define vmcompact(vm) (*(_VM_(vm)->meth.compactf))((vm))
+#define vmoldof(v,p,t,n,x) (t*)vmresize((v), (p), sizeof(t)*(n)+(x), \
+ (VM_RSMOVE) )
+#define vmnewof(v,p,t,n,x) (t*)vmresize((v), (p), sizeof(t)*(n)+(x), \
+ (VM_RSMOVE|VM_RSCOPY|VM_RSZERO) )
+
+#endif /* _VMALLOC_H */
diff --git a/usr/src/lib/libast/sparc/include/ast/wait.h b/usr/src/lib/libast/sparc/include/ast/wait.h
new file mode 100644
index 0000000000..6910081961
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/wait.h
@@ -0,0 +1,107 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * ast POSIX wait/exit support
+ */
+
+#ifndef _WAIT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _WAIT_H
+
+#include <ast.h>
+#include <ast_wait.h>
+
+#if _sys_wait
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide wait waitpid
+#else
+#define wait ______wait
+#define waitpid ______waitpid
+#endif
+#include <sys/wait.h>
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide wait waitpid
+#else
+#undef wait
+#undef waitpid
+#endif
+#endif
+
+#ifndef WNOHANG
+#define WNOHANG 1
+#endif
+
+#ifndef WUNTRACED
+#define WUNTRACED 2
+#endif
+
+#if !_ok_wif
+#undef WIFEXITED
+#undef WEXITSTATUS
+#undef WIFSIGNALED
+#undef WTERMSIG
+#undef WIFSTOPPED
+#undef WSTOPSIG
+#undef WTERMCORE
+#endif
+
+#ifndef WIFEXITED
+#define WIFEXITED(x) (!((x)&((1<<(EXIT_BITS-1))-1)))
+#endif
+
+#ifndef WEXITSTATUS
+#define WEXITSTATUS(x) (((x)>>EXIT_BITS)&((1<<EXIT_BITS)-1))
+#endif
+
+#ifndef WIFSIGNALED
+#define WIFSIGNALED(x) (((x)&((1<<(EXIT_BITS-1))-1))!=0)
+#endif
+
+#ifndef WTERMSIG
+#define WTERMSIG(x) ((x)&((1<<(EXIT_BITS-1))-1))
+#endif
+
+#ifndef WIFSTOPPED
+#define WIFSTOPPED(x) (((x)&((1<<EXIT_BITS)-1))==((1<<(EXIT_BITS-1))-1))
+#endif
+
+#ifndef WSTOPSIG
+#define WSTOPSIG(x) WEXITSTATUS(x)
+#endif
+
+#ifndef WTERMCORE
+#define WTERMCORE(x) ((x)&(1<<(EXIT_BITS-1)))
+#endif
+
+extern __MANGLE__ pid_t wait __PROTO__((int*));
+extern __MANGLE__ pid_t waitpid __PROTO__((pid_t, int*, int));
+
+#endif
diff --git a/usr/src/lib/libast/sparc/include/ast/wchar.h b/usr/src/lib/libast/sparc/include/ast/wchar.h
new file mode 100644
index 0000000000..557a403adc
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/wchar.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_wchar.h>
diff --git a/usr/src/lib/libast/sparc/include/ast/wordexp.h b/usr/src/lib/libast/sparc/include/ast/wordexp.h
new file mode 100644
index 0000000000..b2e80d9f35
--- /dev/null
+++ b/usr/src/lib/libast/sparc/include/ast/wordexp.h
@@ -0,0 +1,74 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * posix wordexp interface definitions
+ */
+
+#ifndef _WORDEXP_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _WORDEXP_H
+
+#include <ast_common.h>
+
+#define WRDE_APPEND 01
+#define WRDE_DOOFFS 02
+#define WRDE_NOCMD 04
+#define WRDE_NOSYS 0100
+#define WRDE_REUSE 010
+#define WRDE_SHOWERR 020
+#define WRDE_UNDEF 040
+
+#define WRDE_BADCHAR 1
+#define WRDE_BADVAL 2
+#define WRDE_CMDSUB 3
+#define WRDE_NOSPACE 4
+#define WRDE_SYNTAX 5
+#define WRDE_NOSHELL 6
+
+typedef struct _wdarg
+{
+ size_t we_wordc;
+ char **we_wordv;
+ size_t we_offs;
+} wordexp_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int wordexp __PROTO__((const char*, wordexp_t*, int));
+extern __MANGLE__ int wordfree __PROTO__((wordexp_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif /* _WORDEXP_H */
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/align b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/align
new file mode 100644
index 0000000000..09939a36da
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/align
@@ -0,0 +1,33 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/align.c by iffe version 2007-04-04 : : */
+#ifndef _def_align_ast
+#define _def_align_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+typedef unsigned long ALIGN_INTEGRAL;
+
+#define ALIGN_CHUNK 8192
+#define ALIGN_INTEGRAL long
+#define ALIGN_INTEGER(x) ((ALIGN_INTEGRAL)(x))
+#define ALIGN_POINTER(x) ((char*)(x))
+#define ALIGN_ROUND(x,y) ALIGN_POINTER(ALIGN_INTEGER((x)+(y)-1)&~((y)-1))
+
+#define ALIGN_BOUND ALIGN_BOUND2
+#define ALIGN_ALIGN(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC(x) ALIGN_TRUNC2(x)
+
+#define ALIGN_BIT1 0x1
+#define ALIGN_BOUND1 ALIGN_BOUND2
+#define ALIGN_ALIGN1(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC1(x) ALIGN_TRUNC2(x)
+#define ALIGN_CLRBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffe)
+#define ALIGN_SETBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x1)
+#define ALIGN_TSTBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x1)
+
+#define ALIGN_BIT2 0x2
+#define ALIGN_BOUND2 8
+#define ALIGN_ALIGN2(x) ALIGN_TRUNC2((x)+7)
+#define ALIGN_TRUNC2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffff8)
+#define ALIGN_CLRBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffd)
+#define ALIGN_SETBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x2)
+#define ALIGN_TSTBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x2)
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/botch b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/botch
new file mode 100644
index 0000000000..ce25726723
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/botch
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/botch.c by iffe version 2007-04-04 : : */
+#ifndef _def_botch_ast
+#define _def_botch_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/ccode b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/ccode
new file mode 100644
index 0000000000..002834f2fa
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/ccode
@@ -0,0 +1,29 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/ccode by iffe version 2007-04-04 : : */
+#ifndef _def_ccode_ast
+#define _def_ccode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define CC_ASCII 1 /* ISO-8859-1 */
+#define CC_EBCDIC_E 2 /* Xopen dd(1) EBCDIC */
+#define CC_EBCDIC_I 3 /* Xopen dd(1) IBM */
+#define CC_EBCDIC_O 4 /* IBM-1047 mvs OpenEdition */
+#define CC_EBCDIC_S 5 /* Siemens posix-bc */
+#define CC_EBCDIC_H 6 /* IBM-37 AS/400 */
+#define CC_EBCDIC_M 7 /* IBM mvs cobol */
+#define CC_EBCDIC_U 8 /* microfocus cobol */
+
+#define CC_MAPS 8 /* number of code maps */
+
+#define CC_EBCDIC CC_EBCDIC_E
+#define CC_EBCDIC1 CC_EBCDIC_E
+#define CC_EBCDIC2 CC_EBCDIC_I
+#define CC_EBCDIC3 CC_EBCDIC_O
+
+#define CC_NATIVE CC_ASCII /* native character code */
+#define CC_ALIEN CC_EBCDIC /* alien character code */
+
+#define CC_bel 0007 /* bel character */
+#define CC_esc 0033 /* esc character */
+#define CC_sub 0032 /* sub character */
+#define CC_vt 0013 /* vt character */
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/common b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/common
new file mode 100644
index 0000000000..21fed4d7b4
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/common
@@ -0,0 +1,199 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/common by iffe version 2007-04-04 : : */
+#ifndef _AST_COMMON_H
+#define _AST_COMMON_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_pthread 1 /* #include <pthread.h> ok */
+#define _hdr_stdarg 1 /* #include <stdarg.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdint 1 /* #include <stdint.h> ok */
+#define _hdr_inttypes 1 /* #include <inttypes.h> ok */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_long_double 1 /* long double is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _std_proto 1 /* standard C prototypes ok */
+#define _ptr_void 1 /* standard C void* ok */
+/* disable non-standard linux/gnu inlines */
+#ifdef __GNUC__
+# undef __OPTIMIZE_SIZE__
+# define __OPTIMIZE_SIZE__ 1
+#endif
+
+/* __STD_C indicates that the language is ANSI-C or C++ */
+#if !defined(__STD_C) && __STDC__
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && (__cplusplus || c_plusplus)
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && _std_proto
+# define __STD_C 1
+#endif
+#if !defined(__STD_C)
+# define __STD_C 0
+#endif
+
+/* extern symbols must be protected against C++ name mangling */
+#ifndef _BEGIN_EXTERNS_
+# if __cplusplus || c_plusplus
+# define _BEGIN_EXTERNS_ extern "C" {
+# define _END_EXTERNS_ }
+# else
+# define _BEGIN_EXTERNS_
+# define _END_EXTERNS_
+# endif
+#endif
+
+/* _ARG_ simplifies function prototyping among flavors of C */
+#ifndef _ARG_
+# if __STD_C
+# define _ARG_(x) x
+# else
+# define _ARG_(x) ()
+# endif
+#endif
+
+/* _NIL_ simplifies defining nil pointers to a given type */
+#ifndef _NIL_
+# define _NIL_(x) ((x)0)
+#endif
+
+/* __INLINE__ is the inline keyword */
+#if !defined(__INLINE__) && defined(__cplusplus)
+# define __INLINE__ inline
+#endif
+#if !defined(__INLINE__) && defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+#endif
+
+/* Void_t is defined so that Void_t* can address any type */
+#ifndef Void_t
+# if __STD_C
+# define Void_t void
+# else
+# define Void_t char
+# endif
+#endif
+
+/* windows variants and veneers */
+#if !defined(_WINIX) && (_UWIN || __CYGWIN__ || __EMX__)
+# define _WINIX 1
+#endif
+
+/* dynamic linked library external scope handling */
+#ifdef __DYNAMIC__
+# undef __DYNAMIC__
+# ifndef _DLL
+# define _DLL 1
+# endif
+#endif
+#if _dll_import
+# if _BLD_STATIC && !_BLD_DLL
+# undef _DLL
+# else
+# if !_UWIN && !defined(_DLL)
+# define _DLL 1
+# endif
+# endif
+# if !defined(__EXPORT__) && _BLD_DLL
+# define __EXPORT__ __declspec(dllexport)
+# endif
+# if !defined(__IMPORT__) && ( _BLD_DLL || defined(_DLL) )
+# define __IMPORT__ __declspec(dllimport)
+# endif
+# if _BLD_DLL && _UWIN
+# define __DYNAMIC__(v) (_ast_getdll()->_ast_ ## v)
+# endif
+#endif
+#if !defined(_astimport)
+# if defined(__IMPORT__) && defined(_DLL)
+# define _astimport __IMPORT__
+# else
+# define _astimport extern
+# endif
+#endif
+#if _dll_import && ( !_BLD_DLL || _WINIX && !_UWIN )
+# ifdef __STDC__
+# define __EXTERN__(T,obj) extern T obj; T* _imp__ ## obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__ ## obj = &obj
+# else
+# define __EXTERN__(T,obj) extern T obj; T* _imp__/**/obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__/**/obj = &obj
+# endif
+#else
+# define __EXTERN__(T,obj) extern T obj
+# define __DEFINE__(T,obj,val) T obj = val
+#endif
+
+#define _ast_LL 1 /* LL numeric suffix supported */
+#define _ast_int1_t char
+#define _ast_int2_t short
+#define _ast_int4_t int
+#define _ast_int8_t long long
+#define _ast_intmax_t _ast_int8_t
+#define _ast_intswap 0
+
+#define _ast_flt4_t float
+#define _ast_flt8_t double
+#define _ast_flt16_t long double
+#define _ast_fltmax_t _ast_flt16_t
+#define _typ_int8_t 1 /* int8_t is a type */
+#define _typ_uint8_t 1 /* uint8_t is a type */
+#define _typ_int16_t 1 /* int16_t is a type */
+#define _typ_uint16_t 1 /* uint16_t is a type */
+#define _typ_int32_t 1 /* int32_t is a type */
+#define _typ_uint32_t 1 /* uint32_t is a type */
+#define _typ_int64_t 1 /* int64_t is a type */
+#define _typ_uint64_t 1 /* uint64_t is a type */
+#define _typ_intmax_t 1 /* intmax_t is a type */
+#define _typ_uintmax_t 1 /* uintmax_t is a type */
+
+#ifndef va_listref
+#define va_listref(p) (p) /* pass va_list to varargs function */
+#define va_listval(p) (p) /* retrieve va_list from va_arg(ap,va_listarg) */
+#define va_listarg va_list /* va_arg() va_list type */
+#ifndef va_start
+#if __STD_C
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+#endif
+#ifndef _AST_STD_H
+# if __STD_C && _hdr_stddef
+# include <stddef.h>
+# endif
+# if _sys_types
+# include <sys/types.h>
+# endif
+# if _hdr_stdint
+# include <stdint.h>
+# else
+# if _hdr_inttypes
+# include <inttypes.h>
+# endif
+# endif
+#endif
+#if !_typ_size_t
+# define _typ_size_t 1
+ typedef int size_t;
+#endif
+#if !_typ_ssize_t
+# define _typ_ssize_t 1
+ typedef int ssize_t;
+#endif
+#ifndef _AST_STD_H
+# define _def_map_ast 1
+# if !_def_map_ast
+# include <ast_map.h>
+# endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/dirent b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/dirent
new file mode 100644
index 0000000000..8221b60e80
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/dirent
@@ -0,0 +1,106 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/dirent by iffe version 2007-04-04 : : */
+
+#ifndef _def_dirent_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dirent_ast 1
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _nxt_dirent <../include/dirent.h> /* include path for the native <dirent.h> */
+#define _nxt_dirent_str "../include/dirent.h" /* include string for the native <dirent.h> */
+/*
+ * <dirent.h> for [fl]stat64 and off64_t
+ */
+
+#ifndef _AST_STD_H
+
+#include <../include/dirent.h> /* the native <dirent.h> */
+
+#else
+
+#ifndef _DIR64_H
+#define _DIR64_H
+
+#include <ast_std.h>
+
+#if _typ_off64_t
+#undef off_t
+#endif
+
+#include <../include/dirent.h> /* the native <dirent.h> */
+
+#if _typ_off64_t
+#define off_t off64_t
+#endif
+
+#if _lib_readdir64 && _typ_struct_dirent64
+#ifndef dirent
+#define dirent dirent64
+#endif
+#ifndef readdir
+#define readdir readdir64
+#endif
+#endif
+
+#endif
+
+#endif
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/eaccess b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/eaccess
new file mode 100644
index 0000000000..0c21b46fbf
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/eaccess
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/eaccess by iffe version 2007-04-04 : : */
+#ifndef _def_eaccess_ast
+#define _def_eaccess_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/errno b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/errno
new file mode 100644
index 0000000000..238ead0128
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/errno
@@ -0,0 +1,7 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/errno by iffe version 2007-04-04 : : */
+#ifndef _def_errno_ast
+#define _def_errno_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _dat_sys_nerr 1 /* sys_nerr in default libs */
+#define _dat_sys_errlist 1 /* sys_errlist in default libs */
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/fcntl b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/fcntl
new file mode 100644
index 0000000000..4cbf8fa21d
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/fcntl
@@ -0,0 +1,114 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/fcntl.c by iffe version 2007-04-04 : : */
+#ifndef _def_fcntl_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fcntl_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <ast_fs.h>
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#define O_BINARY 0
+#define O_TEMPORARY 0
+#define O_TEXT 0
+
+#include <ast_fs.h>
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_fstat64
+#define fstat fstat64
+#endif
+#if _lib_lstat64
+#define lstat lstat64
+#endif
+#if _lib_stat64
+#define stat stat64
+#endif
+#if _lib_creat64
+#define creat creat64
+#endif
+#if _lib_mmap64
+#define mmap mmap64
+#endif
+#if _lib_open64
+#undef open
+#define open open64
+#endif
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/float b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/float
new file mode 100644
index 0000000000..abb9593b60
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/float
@@ -0,0 +1,213 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/float by iffe version 2007-04-04 : : */
+
+#ifndef _def_float_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_float_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_float 1 /* #include <float.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _hdr_values 1 /* #include <values.h> ok */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_frexp 1 /* frexp() in default lib(s) */
+#define _lib_frexpl 1 /* frexpl() in default lib(s) */
+#define _lib_ldexp 1 /* ldexp() in default lib(s) */
+#define _lib_ldexpl 1 /* ldexpl() in default lib(s) */
+#define _lib_finite 1 /* finite() in default lib(s) */
+#define _lib_isnan 1 /* isnan() in default lib(s) */
+#define _lib_isnanl 1 /* isnanl() in default lib(s) */
+#define _lib_copysign 1 /* copysign() in default lib(s) */
+#define _lib_copysignl 1 /* copysignl() in default lib(s) */
+#include <ast_common.h>
+#include <float.h>
+#include <math.h>
+#ifndef FLT_DIG
+#define FLT_DIG 6
+#endif
+#ifndef FLT_MAX
+#define FLT_MAX 3.4028234663852885981170E+38F
+#endif
+#ifndef FLT_MAX_10_EXP
+#define FLT_MAX_10_EXP ( + 38 )
+#endif
+#ifndef FLT_MAX_EXP
+#define FLT_MAX_EXP ( + 128 )
+#endif
+#ifndef FLT_MIN
+#define FLT_MIN 1.1754943508222875079688E-38F
+#endif
+#ifndef FLT_MIN_10_EXP
+#define FLT_MIN_10_EXP ( - 37 )
+#endif
+#ifndef FLT_MIN_EXP
+#define FLT_MIN_EXP ( - 125 )
+#endif
+#ifndef DBL_DIG
+#define DBL_DIG 15
+#endif
+#ifndef DBL_MAX
+#define DBL_MAX 1.7976931348623157081452E+308
+#endif
+#ifndef DBL_MAX_10_EXP
+#define DBL_MAX_10_EXP ( + 308 )
+#endif
+#ifndef DBL_MAX_EXP
+#define DBL_MAX_EXP ( + 1024 )
+#endif
+#ifndef DBL_MIN
+#define DBL_MIN 2.2250738585072013830903E-308
+#endif
+#ifndef DBL_MIN_10_EXP
+#define DBL_MIN_10_EXP ( - 307 )
+#endif
+#ifndef DBL_MIN_EXP
+#define DBL_MIN_EXP ( - 1021 )
+#endif
+#ifndef LDBL_DIG
+#define LDBL_DIG 33
+#endif
+#ifndef LDBL_MAX
+#define LDBL_MAX 1.189731495357231765085759326628007016E+4932L
+#endif
+#ifndef LDBL_MAX_10_EXP
+#define LDBL_MAX_10_EXP ( + 4932 )
+#endif
+#ifndef LDBL_MAX_EXP
+#define LDBL_MAX_EXP ( + 16384 )
+#endif
+#ifndef LDBL_MIN
+#define LDBL_MIN 3.362103143112093506262677817321752603E-4932L
+#endif
+#ifndef LDBL_MIN_10_EXP
+#define LDBL_MIN_10_EXP ( - 4931 )
+#endif
+#ifndef LDBL_MIN_EXP
+#define LDBL_MIN_EXP ( - 16381 )
+#endif
+
+
+#define USHRT_DIG 4
+#define UINT_DIG 9
+#define ULONG_DIG 9
+#define ULLONG_DIG 19
+#define UINTMAX_DIG ULLONG_DIG
+
+#define FLT_ULONG_MAX 4294967295.0F
+#define FLT_ULLONG_MAX 18446744073709551615.0F
+#define FLT_UINTMAX_MAX FLT_ULLONG_MAX
+#define FLT_LONG_MAX 2147483647.0F
+#define FLT_LLONG_MAX 9223372036854775807.0F
+#define FLT_INTMAX_MAX FLT_LLONG_MAX
+#define FLT_LONG_MIN (-2147483648.0F)
+#define FLT_LLONG_MIN (-9223372036854775808.0F)
+#define FLT_INTMAX_MIN FLT_LLONG_MIN
+
+#define DBL_ULONG_MAX 4294967295.0
+#define DBL_ULLONG_MAX 18446744073709551615.0
+#define DBL_UINTMAX_MAX DBL_ULLONG_MAX
+#define DBL_LONG_MAX 2147483647.0
+#define DBL_LLONG_MAX 9223372036854775807.0
+#define DBL_INTMAX_MAX DBL_LLONG_MAX
+#define DBL_LONG_MIN (-2147483648.0)
+#define DBL_LLONG_MIN (-9223372036854775808.0)
+#define DBL_INTMAX_MIN DBL_LLONG_MIN
+
+#define LDBL_ULONG_MAX 4294967295.0L
+#define LDBL_ULLONG_MAX 18446744073709551615.0L
+#define LDBL_UINTMAX_MAX LDBL_ULLONG_MAX
+#define LDBL_LONG_MAX 2147483647.0L
+#define LDBL_LLONG_MAX 9223372036854775807.0L
+#define LDBL_INTMAX_MAX LDBL_LLONG_MAX
+#define LDBL_LONG_MIN (-2147483648.0L)
+#define LDBL_LLONG_MIN (-9223372036854775808.0L)
+#define LDBL_INTMAX_MIN LDBL_LLONG_MIN
+
+#define FLTMAX_UINTMAX_MAX LDBL_UINTMAX_MAX
+#define FLTMAX_INTMAX_MAX LDBL_INTMAX_MAX
+#define FLTMAX_INTMAX_MIN LDBL_INTMAX_MIN
+
+typedef union _ast_dbl_exp_u
+{
+ uint32_t e[sizeof(double)/4];
+ double f;
+} _ast_dbl_exp_t;
+
+#define _ast_dbl_exp_index 0
+#define _ast_dbl_exp_shift 20
+
+typedef union _fltmax_exp_u
+{
+ uint32_t e[sizeof(_ast_fltmax_t)/4];
+ _ast_fltmax_t f;
+} _ast_fltmax_exp_t;
+
+#define _ast_fltmax_exp_index 0
+#define _ast_fltmax_exp_shift 16
+
+#define _ast_flt_unsigned_max_t unsigned long long
+#define _ast_flt_nan_init 0x7f,0xff,0xff,0xff
+#define _ast_flt_inf_init 0x7f,0x80,0x00,0x00
+#define _ast_dbl_nan_init 0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff
+#define _ast_dbl_inf_init 0x7f,0xf0,0x00,0x00,0x00,0x00,0x00,0x00
+#define _ast_ldbl_nan_init 0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
+#define _ast_ldbl_inf_init 0x7f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/fs b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/fs
new file mode 100644
index 0000000000..c2ad71dadc
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/fs
@@ -0,0 +1,154 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/fs by iffe version 2007-04-04 : : */
+
+#ifndef _def_fs_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fs_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _lib_lstat 1 /* lstat() in default lib(s) */
+#define _lib_mknod 1 /* mknod() in default lib(s) */
+#define _lib_sync 1 /* sync() in default lib(s) */
+#include <sys/stat.h>
+#define FS_default "ufs"
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef major
+#define major(x) ( major_t ) ( ( ( ( unsigned ) ( ( x ) ) ) >> 8 ) & 0x7f )
+#endif
+#ifndef minor
+#define minor(x) ( minor_t ) ( ( ( x ) ) & 0xff )
+#endif
+#ifndef makedev
+#define makedev(x,y) ( unsigned short ) ( ( ( ( x ) ) << 8 ) | ( ( ( y ) ) & 0xff ) )
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _sys_mntent 1 /* #include <sys/mntent.h> ok */
+#define _sys_mnttab 1 /* #include <sys/mnttab.h> ok */
+#define _mem_st_blocks_stat 1 /* st_blocks is a member of struct stat */
+#define _mem_st_blksize_stat 1 /* st_blksize is a member of struct stat */
+#define _mem_st_rdev_stat 1 /* st_rdev is a member of struct stat */
+#define _sys_statfs 1 /* #include <sys/statfs.h> ok */
+#define _mem_f_files_statfs 1 /* f_files is a member of struct statfs */
+#define _sys_vfs 1 /* #include <sys/vfs.h> ok */
+#define _sys_param 1 /* #include <sys/param.h> ok */
+#define _sys_mount 1 /* #include <sys/mount.h> ok */
+#define _sys_statvfs 1 /* #include <sys/statvfs.h> ok */
+#define _mem_f_basetype_statvfs 1 /* f_basetype is a member of struct statvfs */
+#define _mem_f_frsize_statvfs 1 /* f_frsize is a member of struct statvfs */
+#define _lib_getmntent 1 /* getmntent() in default lib(s) */
+#define _lib_statfs 1 /* statfs() in default lib(s) */
+#define _lib_statvfs 1 /* statvfs() in default lib(s) */
+#define _lib_statfs4 1 /* compile{\ passed */
+#if _sys_statvfs
+#include <sys/statvfs.h>
+#if !_mem_statvfs_f_basetype
+#if _ary_f_reserved7
+#define f_basetype f_reserved7
+#endif
+#endif
+#else
+#define _mem_f_basetype_statvfs 1
+#define _mem_f_frsize_statvfs 1
+struct statvfs
+{
+unsigned long f_bsize; /* fundamental file system block size */
+unsigned long f_frsize; /* fragment size */
+unsigned long f_blocks; /* total # of blocks of f_frsize on fs */
+unsigned long f_bfree; /* total # of free blocks of f_frsize */
+unsigned long f_bavail; /* # of free blocks avail to non-superuser */
+unsigned long f_files; /* total # of file nodes (inodes) */
+unsigned long f_ffree; /* total # of free file nodes */
+unsigned long f_favail; /* # of free nodes avail to non-superuser */
+unsigned long f_fsid; /* file system id (dev for now) */
+char f_basetype[16]; /* target fs type name, null-terminated */
+unsigned long f_flag; /* bit-mask of flags */
+unsigned long f_namemax; /* maximum file name length */
+char f_fstr[32]; /* filesystem-specific string */
+unsigned long f_filler[16]; /* reserved for future expansion */
+};
+extern __MANGLE__ int fstatvfs __PROTO__((int, struct statvfs*));
+extern __MANGLE__ int statvfs __PROTO__((const char*, struct statvfs*));
+#endif
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_statvfs64 && !defined(statvfs)
+#define statvfs statvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int statvfs64 __PROTO__((const char*, struct statvfs64*));
+#endif
+#endif
+#if _lib_fstatvfs64 && !defined(fstatvfs)
+#define fstatvfs fstatvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int fstatvfs64 __PROTO__((int, struct statvfs64*));
+#endif
+#endif
+
+#define _str_st_fstype 1 /* stat.st_fstype is a string */
+#define _ary_st_pad4 1 /* stat.st_pad4 is an array */
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/hack b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/hack
new file mode 100644
index 0000000000..f8ae1928f5
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/hack
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/hack by iffe version 2007-04-04 : : */
+#ifndef _def_hack_ast
+#define _def_hack_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/iconv b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/iconv
new file mode 100644
index 0000000000..be50daaeca
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/iconv
@@ -0,0 +1,132 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/iconv by iffe version 2007-04-04 : : */
+
+#ifndef _def_iconv_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_iconv_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_iconv 1 /* #include <iconv.h> ok */
+#define _lib_iconv_open 1 /* iconv_open() in default lib(s) */
+#define _lib_iconv_close 1 /* iconv_close() in default lib(s) */
+#define _lib_iconv 1 /* iconv() in default lib(s) */
+#define _nxt_iconv <../include/iconv.h> /* include path for the native <iconv.h> */
+#define _nxt_iconv_str "../include/iconv.h" /* include string for the native <iconv.h> */
+#include <ast_common.h>
+#include <ccode.h>
+#include <../include/iconv.h> /* the native iconv.h */
+
+#define CC_ICONV (-1)
+#define CC_UCS (-2)
+#define CC_SCU (-3)
+#define CC_UTF (-4)
+#define CC_UME (-5)
+
+#ifndef _ICONV_LIST_PRIVATE_
+#undef iconv_t
+#define iconv_t _ast_iconv_t
+#undef iconv_f
+#define iconv_f _ast_iconv_f
+#undef iconv_list_t
+#define iconv_list_t _ast_iconv_list_t
+#undef iconv_open
+#define iconv_open _ast_iconv_open
+#undef iconv
+#define iconv _ast_iconv
+#undef iconv_close
+#define iconv_close _ast_iconv_close
+#undef iconv_list
+#define iconv_list _ast_iconv_list
+#undef iconv_move
+#define iconv_move _ast_iconv_move
+#undef iconv_name
+#define iconv_name _ast_iconv_name
+#undef iconv_write
+#define iconv_write _ast_iconv_write
+#endif
+
+typedef Ccmap_t _ast_iconv_list_t;
+typedef __V_* _ast_iconv_t;
+typedef size_t (*_ast_iconv_f) __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ _ast_iconv_t _ast_iconv_open __PROTO__((const char*, const char*));
+extern __MANGLE__ size_t _ast_iconv __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+extern __MANGLE__ int _ast_iconv_close __PROTO__((_ast_iconv_t));
+extern __MANGLE__ _ast_iconv_list_t* _ast_iconv_list __PROTO__((_ast_iconv_list_t*));
+extern __MANGLE__ int _ast_iconv_name __PROTO__((const char*, char*, size_t));
+#if _SFIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, Sfio_t*, Sfio_t*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, Sfio_t*, char**, size_t*, size_t*));
+#else
+#if _SFSTDIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, FILE*, FILE*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, FILE*, char**, size_t*, size_t*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/lib b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/lib
new file mode 100644
index 0000000000..5fe12a8acb
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/lib
@@ -0,0 +1,171 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/lib by iffe version 2007-04-04 : : */
+#ifndef _def_lib_ast
+#define _def_lib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _hdr_fmtmsg 1 /* #include <fmtmsg.h> ok */
+#define _hdr_fnmatch 1 /* #include <fnmatch.h> ok */
+#define _hdr_libgen 1 /* #include <libgen.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_locale 1 /* #include <locale.h> ok */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_spawn 1 /* #include <spawn.h> ok */
+#define _hdr_syslog 1 /* #include <syslog.h> ok */
+#define _hdr_utime 1 /* #include <utime.h> ok */
+#define _hdr_wctype 1 /* #include <wctype.h> ok */
+#define _hdr_wchar 1 /* <wchar.h> and isw*() really work */
+#define _dat__tzname 1 /* _tzname in default lib(s) */
+#define _dat_tzname 1 /* tzname in default lib(s) */
+#define _lib__cleanup 1 /* _cleanup() in default lib(s) */
+#define _lib_atexit 1 /* atexit() in default lib(s) */
+#define _lib_bcopy 1 /* bcopy() in default lib(s) */
+#define _lib_bzero 1 /* bzero() in default lib(s) */
+#define _lib_catclose 1 /* catclose() in default lib(s) */
+#define _lib_catgets 1 /* catgets() in default lib(s) */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_confstr 1 /* confstr() in default lib(s) */
+#define _lib_dup2 1 /* dup2() in default lib(s) */
+#define _lib_execlp 1 /* execlp() in default lib(s) */
+#define _lib_execve 1 /* execve() in default lib(s) */
+#define _lib_execvp 1 /* execvp() in default lib(s) */
+#define _lib_fchmod 1 /* fchmod() in default lib(s) */
+#define _lib_fcntl 1 /* fcntl() in default lib(s) */
+#define _lib_fmtmsg 1 /* fmtmsg() in default lib(s) */
+#define _lib_fnmatch 1 /* fnmatch() in default lib(s) */
+#define _lib_fork 1 /* fork() in default lib(s) */
+#define _lib_fsync 1 /* fsync() in default lib(s) */
+#define _lib_getdents 1 /* getdents() in default lib(s) */
+#define _lib_getdtablesize 1 /* getdtablesize() in default lib(s) */
+#define _lib_getdate 1 /* getdate() in default lib(s) */
+#define _lib_getgroups 1 /* getgroups() in default lib(s) */
+#define _lib_gethostname 1 /* gethostname() in default lib(s) */
+#define _lib_getlogin 1 /* getlogin() in default lib(s) */
+#define _lib_getpagesize 1 /* getpagesize() in default lib(s) */
+#define _lib_getrlimit 1 /* getrlimit() in default lib(s) */
+#define _lib_getopt 1 /* getopt() in default lib(s) */
+#define _lib_getsubopt 1 /* getsubopt() in default lib(s) */
+#define _lib_getopt_long 1 /* getopt_long() in default lib(s) */
+#define _lib_getopt_long_only 1 /* getopt_long_only() in default lib(s) */
+#define _lib_glob 1 /* glob() in default lib(s) */
+#define _lib_index 1 /* index() in default lib(s) */
+#define _lib_iswblank 1 /* iswblank() in default lib(s) */
+#define _lib_iswctype 1 /* iswctype() in default lib(s) */
+#define _lib_killpg 1 /* killpg() in default lib(s) */
+#define _lib_link 1 /* link() in default lib(s) */
+#define _lib_localeconv 1 /* localeconv() in default lib(s) */
+#define _lib_madvise 1 /* madvise() in default lib(s) */
+#define _lib_mbtowc 1 /* mbtowc() in default lib(s) */
+#define _lib_mbrtowc 1 /* mbrtowc() in default lib(s) */
+#define _lib_memalign 1 /* memalign() in default lib(s) */
+#define _lib_memchr 1 /* memchr() in default lib(s) */
+#define _lib_memcpy 1 /* memcpy() in default lib(s) */
+#define _lib_memmove 1 /* memmove() in default lib(s) */
+#define _lib_memset 1 /* memset() in default lib(s) */
+#define _lib_mkdir 1 /* mkdir() in default lib(s) */
+#define _lib_mkfifo 1 /* mkfifo() in default lib(s) */
+#define _lib_mktemp 1 /* mktemp() in default lib(s) */
+#define _lib_mktime 1 /* mktime() in default lib(s) */
+#define _lib_mount 1 /* mount() in default lib(s) */
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _lib_pathconf 1 /* pathconf() in default lib(s) */
+#define _lib_readlink 1 /* readlink() in default lib(s) */
+#define _lib_remove 1 /* remove() in default lib(s) */
+#define _lib_rename 1 /* rename() in default lib(s) */
+#define _lib_rewinddir 1 /* rewinddir() in default lib(s) */
+#define _lib_rindex 1 /* rindex() in default lib(s) */
+#define _lib_rmdir 1 /* rmdir() in default lib(s) */
+#define _lib_setlocale 1 /* setlocale() in default lib(s) */
+#define _lib_setpgid 1 /* setpgid() in default lib(s) */
+#define _lib_setpgrp 1 /* setpgrp() in default lib(s) */
+#define _lib_setreuid 1 /* setreuid() in default lib(s) */
+#define _lib_setsid 1 /* setsid() in default lib(s) */
+#define _lib_setuid 1 /* setuid() in default lib(s) */
+#define _lib_sigaction 1 /* sigaction() in default lib(s) */
+#define _lib_sigprocmask 1 /* sigprocmask() in default lib(s) */
+#define _lib_socketpair 1 /* socketpair() in default lib(s) */
+#define _lib_strchr 1 /* strchr() in default lib(s) */
+#define _lib_strcoll 1 /* strcoll() in default lib(s) */
+#define _lib_strdup 1 /* strdup() in default lib(s) */
+#define _lib_strerror 1 /* strerror() in default lib(s) */
+#define _lib_strcasecmp 1 /* strcasecmp() in default lib(s) */
+#define _lib_strncasecmp 1 /* strncasecmp() in default lib(s) */
+#define _lib_strrchr 1 /* strrchr() in default lib(s) */
+#define _lib_strstr 1 /* strstr() in default lib(s) */
+#define _lib_strxfrm 1 /* strxfrm() in default lib(s) */
+#define _lib_strftime 1 /* strftime() in default lib(s) */
+#define _lib_swab 1 /* swab() in default lib(s) */
+#define _lib_symlink 1 /* symlink() in default lib(s) */
+#define _lib_sysconf 1 /* sysconf() in default lib(s) */
+#define _lib_sysinfo 1 /* sysinfo() in default lib(s) */
+#define _lib_syslog 1 /* syslog() in default lib(s) */
+#define _lib_telldir 1 /* telldir() in default lib(s) */
+#define _lib_tmpnam 1 /* tmpnam() in default lib(s) */
+#define _lib_tzset 1 /* tzset() in default lib(s) */
+#define _lib_unlink 1 /* unlink() in default lib(s) */
+#define _lib_utime 1 /* utime() in default lib(s) */
+#define _lib_wctype 1 /* wctype() in default lib(s) */
+#define _lib_ftruncate 1 /* ftruncate() in default lib(s) */
+#define _lib_truncate 1 /* truncate() in default lib(s) */
+#define _lib_creat64 1 /* creat64() in default lib(s) */
+#define _lib_fstat64 1 /* fstat64() in default lib(s) */
+#define _lib_fstatvfs64 1 /* fstatvfs64() in default lib(s) */
+#define _lib_ftruncate64 1 /* ftruncate64() in default lib(s) */
+#define _lib_lseek64 1 /* lseek64() in default lib(s) */
+#define _lib_lstat64 1 /* lstat64() in default lib(s) */
+#define _lib_open64 1 /* open64() in default lib(s) */
+#define _lib_readdir64 1 /* readdir64() in default lib(s) */
+#define _lib_stat64 1 /* stat64() in default lib(s) */
+#define _lib_statvfs64 1 /* statvfs64() in default lib(s) */
+#define _lib_truncate64 1 /* truncate64() in default lib(s) */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _lib_strtod 1 /* strtod() in default lib(s) */
+#define _lib_strtold 1 /* strtold() in default lib(s) */
+#define _lib_strtol 1 /* strtol() in default lib(s) */
+#define _lib_strtoll 1 /* strtoll() in default lib(s) */
+#define _lib_strtoul 1 /* strtoul() in default lib(s) */
+#define _lib_strtoull 1 /* strtoull() in default lib(s) */
+#define _mem_d_ino_dirent 1 /* d_ino is a member of struct dirent */
+#define _mem_d_off_dirent 1 /* d_off is a member of struct dirent */
+#define _mem_d_reclen_dirent 1 /* d_reclen is a member of struct dirent */
+#define _mem_DIR 1 /* DIR is a non-opaque struct */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _sys_jioctl 1 /* #include <sys/jioctl.h> ok */
+#define _sys_localedef 1 /* #include <sys/localedef.h> ok */
+#define _sys_ptem 1 /* #include <sys/ptem.h> ok */
+#define _sys_resource 1 /* #include <sys/resource.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _sys_stream 1 /* #include <sys/stream.h> ok */
+#define _sys_systeminfo 1 /* #include <sys/systeminfo.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_off64_t 1 /* off64_t is a type */
+#define _typ_struct_dirent64 1 /* struct dirent64 is a type */
+#define _tst_errno 1 /* errno can be assigned */
+#define _lib_poll_fd_1 1 /* fd is first arg to poll() */
+#define _lib_poll 1 /* _lib_poll_fd_1||_lib_poll_fd_2 is true */
+#define _lib_select 1 /* select() has standard 5 arg interface */
+#define _pipe_rw 1 /* full duplex pipes */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _lib_vfork 1 /* vfork exists and it works */
+#define _real_vfork 1 /* vfork child shares data with parent */
+#define _lib_posix_spawn 1 /* posix_spawn exists and it works and its worth using */
+#define _stream_peek 1 /* ioctl(I_PEEK) works */
+#define _socket_peek 1 /* recv(MSG_PEEK) works */
+#define _hdr_string 1 /* #include <string.h> ok */
+#define _lib_memcmp 1 /* standard memcmp interface that works */
+#define _hdr_fcntl 1 /* #include <fcntl.h> ok */
+#define _hdr_signal 1 /* #include <signal.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_memccpy 1 /* standard memccpy interface that works */
+#define _lib_utime_now 1 /* utime works with 0 time vector */
+#define _UNIV_DEFAULT "att" /* default universe name */
+#define _std_cleanup 1 /* stuck with standard _cleanup */
+#define _std_strcoll 1 /* standard strcoll works */
+#if !_AST_no_spawnveg
+#define _use_spawnveg 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/libpath b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/libpath
new file mode 100644
index 0000000000..c098e8871a
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/libpath
@@ -0,0 +1,6 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/libpath.sh by iffe version 2007-04-04 : : */
+#ifndef _def_libpath_ast
+#define _def_libpath_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define CONF_LIBPATH "lib/64:LD_LIBRARY_PATH_64:sol.*64*,lib/32:LD_LIBRARY_PATH_32,lib:LD_LIBRARY_PATH"
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/limits b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/limits
new file mode 100644
index 0000000000..4abdc47133
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/limits
@@ -0,0 +1,107 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/limits.c by iffe version 2007-04-04 : : */
+#ifndef _def_limits_ast
+#define _def_limits_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+#ifndef CHAR_MAX
+#define CHAR_MAX 127
+#endif
+#ifndef CHAR_MIN
+#define CHAR_MIN -128
+#endif
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC 1000000
+#endif
+#ifndef INT_MIN
+#define INT_MIN -2147483648
+#endif
+#ifndef LLONG_MAX
+#define LLONG_MAX 9223372036854775807
+#endif
+#ifndef LLONG_MIN
+#define LLONG_MIN -9223372036854775808
+#endif
+#ifndef LONG_MAX
+#define LONG_MAX 2147483647
+#endif
+#ifndef LONG_MIN
+#define LONG_MIN -2147483648
+#endif
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 5
+#endif
+#ifndef OPEN_MAX_CEIL
+#ifndef OPEN_MAX
+#define OPEN_MAX 256
+#endif
+#define OPEN_MAX_CEIL OPEN_MAX
+#endif
+#ifndef PTHREAD_STACK_MIN
+#define PTHREAD_STACK_MIN 4096
+#endif
+#ifndef PTRDIFF_MAX
+#define PTRDIFF_MAX 2147483647
+#endif
+#ifndef PTRDIFF_MIN
+#define PTRDIFF_MIN -2147483648
+#endif
+#ifndef SCHAR_MAX
+#define SCHAR_MAX 127
+#endif
+#ifndef SCHAR_MIN
+#define SCHAR_MIN -128
+#endif
+#ifndef SHRT_MIN
+#define SHRT_MIN -32768
+#endif
+#ifndef SIG_ATOMIC_MAX
+#define SIG_ATOMIC_MAX 2147483647
+#endif
+#ifndef SIG_ATOMIC_MIN
+#define SIG_ATOMIC_MIN -2147483648
+#endif
+#ifndef SIZE_MAX
+#ifndef UINT_MAX
+#define UINT_MAX 4294967295
+#endif
+#define SIZE_MAX UINT_MAX
+#endif
+#ifndef SSIZE_MAX
+#ifndef INT_MAX
+#define INT_MAX 2147483647
+#endif
+#define SSIZE_MAX INT_MAX
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+#ifndef UCHAR_MAX
+#define UCHAR_MAX 255
+#endif
+#ifndef ULLONG_MAX
+#define ULLONG_MAX 18446744073709551615
+#endif
+#ifndef ULONG_MAX
+#define ULONG_MAX 4294967295
+#endif
+#ifndef USHRT_MAX
+#define USHRT_MAX 65535
+#endif
+#ifndef WCHAR_MAX
+#define WCHAR_MAX 2147483647
+#endif
+#ifndef WCHAR_MIN
+#define WCHAR_MIN -2147483648
+#endif
+#ifndef WINT_MAX
+#define WINT_MAX 2147483647
+#endif
+#ifndef WINT_MIN
+#define WINT_MIN -2147483648
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/map b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/map
new file mode 100644
index 0000000000..da0d809423
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/map
@@ -0,0 +1,438 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/map.c by iffe version 2007-04-04 : : */
+#ifndef _def_map_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_map_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+/*
+ * prototypes provided for standard interfaces hijacked
+ * by ast and mapped to _ast_* but already prototyped
+ * unmapped in native headers included by <ast_std.h>
+ */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+
+#define _map_libc 1
+#undef basename
+#define basename _ast_basename
+#undef dirname
+#define dirname _ast_dirname
+#undef eaccess
+#define eaccess _ast_eaccess
+#undef execvpe
+#define execvpe _ast_execvpe
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+#undef fnmatch
+#define fnmatch _ast_fnmatch
+#undef fts_children
+#define fts_children _ast_fts_children
+#undef fts_close
+#define fts_close _ast_fts_close
+#undef fts_flags
+#define fts_flags _ast_fts_flags
+#undef fts_notify
+#define fts_notify _ast_fts_notify
+#undef fts_open
+#define fts_open _ast_fts_open
+#undef fts_read
+#define fts_read _ast_fts_read
+#undef fts_set
+#define fts_set _ast_fts_set
+#undef ftw
+#define ftw _ast_ftw
+#undef ftwalk
+#define ftwalk _ast_ftwalk
+#undef ftwflags
+#define ftwflags _ast_ftwflags
+#undef getcwd
+#define getcwd _ast_getcwd
+extern __MANGLE__ char* getcwd __PROTO__((char*, size_t));
+#undef getdate
+#define getdate _ast_getdate
+#undef getopt
+#define getopt _ast_getopt
+#undef getsubopt
+#define getsubopt _ast_getsubopt
+#undef getopt_long
+#define getopt_long _ast_getopt_long
+#undef getopt_long_only
+#define getopt_long_only _ast_getopt_long_only
+#undef getwd
+#define getwd _ast_getwd
+extern __MANGLE__ char* getwd __PROTO__((char*));
+#undef glob
+#define glob _ast_glob
+#undef globfree
+#define globfree _ast_globfree
+#undef memdup
+#define memdup _ast_memdup
+#undef memfatal
+#define memfatal _ast_memfatal
+#undef memhash
+#define memhash _ast_memhash
+#undef memsum
+#define memsum _ast_memsum
+#undef mkstemp
+#define mkstemp _ast_mkstemp
+extern __MANGLE__ int mkstemp __PROTO__((char*));
+#undef mktemp
+#define mktemp _ast_mktemp
+extern __MANGLE__ char* mktemp __PROTO__((char*));
+#undef mktime
+#define mktime _ast_mktime
+#undef nftw
+#define nftw _ast_nftw
+#undef optesc
+#define optesc _ast_optesc
+#undef optget
+#define optget _ast_optget
+#undef opthelp
+#define opthelp _ast_opthelp
+#undef optjoin
+#define optjoin _ast_optjoin
+#undef optstr
+#define optstr _ast_optstr
+#undef optusage
+#define optusage _ast_optusage
+#undef pathaccess
+#define pathaccess _ast_pathaccess
+#undef pathbin
+#define pathbin _ast_pathbin
+#undef pathcanon
+#define pathcanon _ast_pathcanon
+#undef pathcat
+#define pathcat _ast_pathcat
+#undef pathcd
+#define pathcd _ast_pathcd
+#undef pathcheck
+#define pathcheck _ast_pathcheck
+#undef pathexists
+#define pathexists _ast_pathexists
+#undef pathfind
+#define pathfind _ast_pathfind
+#undef pathgetlink
+#define pathgetlink _ast_pathgetlink
+#undef pathinclude
+#define pathinclude _ast_pathinclude
+#undef pathkey
+#define pathkey _ast_pathkey
+#undef pathnative
+#define pathnative _ast_pathnative
+#undef pathpath
+#define pathpath _ast_pathpath
+#undef pathposix
+#define pathposix _ast_pathposix
+#undef pathprobe
+#define pathprobe _ast_pathprobe
+#undef pathrepl
+#define pathrepl _ast_pathrepl
+#undef pathsetlink
+#define pathsetlink _ast_pathsetlink
+#undef pathshell
+#define pathshell _ast_pathshell
+#undef pathstat
+#define pathstat _ast_pathstat
+#undef pathtemp
+#define pathtemp _ast_pathtemp
+#undef pathtmp
+#define pathtmp _ast_pathtmp
+#undef procclose
+#define procclose _ast_procclose
+#undef procfree
+#define procfree _ast_procfree
+#undef procopen
+#define procopen _ast_procopen
+#undef procrun
+#define procrun _ast_procrun
+#undef putenv
+#define putenv _ast_putenv
+#undef re_comp
+#define re_comp _ast_re_comp
+#undef re_exec
+#define re_exec _ast_re_exec
+#undef realpath
+#define realpath _ast_realpath
+extern __MANGLE__ char* realpath __PROTO__((const char*, char*));
+#undef regaddclass
+#define regaddclass _ast_regaddclass
+#undef regalloc
+#define regalloc _ast_regalloc
+#undef regcache
+#define regcache _ast_regcache
+#undef regclass
+#define regclass _ast_regclass
+#undef regcmp
+#define regcmp _ast_regcmp
+#undef regcollate
+#define regcollate _ast_regcollate
+#undef regcomb
+#define regcomb _ast_regcomb
+#undef regcomp
+#define regcomp _ast_regcomp
+#undef regdecomp
+#define regdecomp _ast_regdecomp
+#undef regdup
+#define regdup _ast_regdup
+#undef regerror
+#define regerror _ast_regerror
+#undef regex
+#define regex _ast_regex
+#undef regexec
+#define regexec _ast_regexec
+#undef regfatal
+#define regfatal _ast_regfatal
+#undef regfatalpat
+#define regfatalpat _ast_regfatalpat
+#undef regfree
+#define regfree _ast_regfree
+#undef regncomp
+#define regncomp _ast_regncomp
+#undef regnexec
+#define regnexec _ast_regnexec
+#undef regrecord
+#define regrecord _ast_regrecord
+#undef regrexec
+#define regrexec _ast_regrexec
+#undef regstat
+#define regstat _ast_regstat
+#undef regsub
+#define regsub _ast_regsub
+#undef regsubcomp
+#define regsubcomp _ast_regsubcomp
+#undef regsubexec
+#define regsubexec _ast_regsubexec
+#undef regsubflags
+#define regsubflags _ast_regsubflags
+#undef regsubfree
+#define regsubfree _ast_regsubfree
+#undef remove
+#define remove _ast_remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#undef resolvepath
+#define resolvepath _ast_resolvepath
+extern __MANGLE__ char* resolvepath __PROTO__((const char*, char*, size_t));
+#undef setenv
+#define setenv _ast_setenv
+extern __MANGLE__ int setenv __PROTO__((const char*, const char*, int));
+#undef setenviron
+#define setenviron _ast_setenviron
+#undef sigcritical
+#define sigcritical _ast_sigcritical
+#undef signal
+#define signal _ast_signal
+#undef sigunblock
+#define sigunblock _ast_sigunblock
+#undef stracmp
+#define stracmp _ast_stracmp
+#undef strcopy
+#define strcopy _ast_strcopy
+#undef strelapsed
+#define strelapsed _ast_strelapsed
+#undef stresc
+#define stresc _ast_stresc
+#undef streval
+#define streval _ast_streval
+#undef strexpr
+#define strexpr _ast_strexpr
+#undef strftime
+#define strftime _ast_strftime
+#undef strgid
+#define strgid _ast_strgid
+#undef strgrpmatch
+#define strgrpmatch _ast_strgrpmatch
+#undef strhash
+#define strhash _ast_strhash
+#undef strkey
+#define strkey _ast_strkey
+#undef strlcat
+#define strlcat _ast_strlcat
+extern __MANGLE__ size_t strlcat __PROTO__((char*, const char*, size_t));
+#undef strlcpy
+#define strlcpy _ast_strlcpy
+extern __MANGLE__ size_t strlcpy __PROTO__((char*, const char*, size_t));
+#undef strlook
+#define strlook _ast_strlook
+#undef strmatch
+#define strmatch _ast_strmatch
+#undef strmode
+#define strmode _ast_strmode
+#undef strnacmp
+#define strnacmp _ast_strnacmp
+#undef strncopy
+#define strncopy _ast_strncopy
+#undef strntod
+#define strntod _ast_strntod
+#undef strntol
+#define strntol _ast_strntol
+#undef strntold
+#define strntold _ast_strntold
+#undef strntoll
+#define strntoll _ast_strntoll
+#undef strntoul
+#define strntoul _ast_strntoul
+#undef strntoull
+#define strntoull _ast_strntoull
+#undef stropt
+#define stropt _ast_stropt
+#undef strperm
+#define strperm _ast_strperm
+#undef strpsearch
+#define strpsearch _ast_strpsearch
+#undef strptime
+#define strptime _ast_strptime
+#undef strsearch
+#define strsearch _ast_strsearch
+#undef strsort
+#define strsort _ast_strsort
+#undef strsubmatch
+#define strsubmatch _ast_strsubmatch
+#undef strsum
+#define strsum _ast_strsum
+#undef strtape
+#define strtape _ast_strtape
+#undef strtoip4
+#define strtoip4 _ast_strtoip4
+#undef strton
+#define strton _ast_strton
+#undef strtonll
+#define strtonll _ast_strtonll
+#undef struid
+#define struid _ast_struid
+#undef struniq
+#define struniq _ast_struniq
+#undef system
+#define system _ast_system
+extern __MANGLE__ int system __PROTO__((const char*));
+#undef tempnam
+#define tempnam _ast_tempnam
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+#undef tmpnam
+#define tmpnam _ast_tmpnam
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+#undef touch
+#define touch _ast_touch
+#undef wordexp
+#define wordexp _ast_wordexp
+#undef wordfree
+#define wordfree _ast_wordfree
+#undef unsetenv
+#define unsetenv _ast_unsetenv
+
+/* cannot override local malloc */
+#define _map_malloc 1
+#undef calloc
+#define calloc _ast_calloc
+extern __MANGLE__ __V_* calloc __PROTO__((size_t, size_t));
+#undef cfree
+#define cfree _ast_cfree
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+#undef free
+#define free _ast_free
+extern __MANGLE__ void free __PROTO__((__V_*));
+#undef malloc
+#define malloc _ast_malloc
+extern __MANGLE__ __V_* malloc __PROTO__((size_t));
+#undef memalign
+#define memalign _ast_memalign
+extern __MANGLE__ __V_* memalign __PROTO__((size_t, size_t));
+#undef realloc
+#define realloc _ast_realloc
+extern __MANGLE__ __V_* realloc __PROTO__((__V_*, size_t));
+#undef strdup
+#define strdup _ast_strdup
+extern __MANGLE__ char* strdup __PROTO__((const char*));
+#undef valloc
+#define valloc _ast_valloc
+extern __MANGLE__ __V_* valloc __PROTO__((size_t));
+#undef strtol
+#define strtol _ast_strtol
+#undef strtoul
+#define strtoul _ast_strtoul
+#undef strtoll
+#define strtoll _ast_strtoll
+#undef strtoull
+#define strtoull _ast_strtoull
+#undef strtod
+#define strtod _ast_strtod
+#undef strtold
+#define strtold _ast_strtold
+extern __MANGLE__ long strtol __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned long strtoul __PROTO__((const char*, char**, int));
+extern __MANGLE__ double strtod __PROTO__((const char*, char**));
+#if !_UWIN
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
+extern __MANGLE__ _ast_fltmax_t strtold __PROTO__((const char*, char**));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+extern __MANGLE__ _ast_intmax_t strtoll __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned _ast_intmax_t strtoull __PROTO__((const char*, char**, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/mmap b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/mmap
new file mode 100644
index 0000000000..4a54d5bc78
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/mmap
@@ -0,0 +1,26 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/mmap by iffe version 2007-04-04 : : */
+#ifndef _def_mmap_ast
+#define _def_mmap_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_mmap 1 /* standard mmap interface that works */
+#define _lib_mmap64 1 /* mmap64 interface and implementation work */
+#define _mmap_anon 1 /* use mmap MAP_ANON to get raw memory */
+#define _mmap_devzero 1 /* use mmap on /dev/zero to get raw memory */
+
+/* some systems get it wrong but escape concise detection */
+#ifndef _NO_MMAP
+#if __CYGWIN__
+#define _NO_MMAP 1
+#endif
+#endif
+
+#if _NO_MMAP
+#undef _lib_mmap
+#undef _lib_mmap64
+#undef _mmap_anon
+#undef _mmap_devzero
+#undef _mmap_worthy
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/mode b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/mode
new file mode 100644
index 0000000000..4347cc2d13
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/mode
@@ -0,0 +1,14 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/mode.c by iffe version 2007-04-04 : : */
+#ifndef _def_mode_ast
+#define _def_mode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define S_ITYPE(m) ((m)&S_IFMT)
+
+#define S_IPERM (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
+
+#define _S_IDPERM 1
+#define _S_IDTYPE 1
+
+#define BUFFERSIZE 8192
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/nl_types b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/nl_types
new file mode 100644
index 0000000000..57348178a9
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/nl_types
@@ -0,0 +1,102 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/nl_types by iffe version 2007-04-04 : : */
+
+#ifndef _def_nl_types_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_nl_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_nl_langinfo 1 /* nl_langinfo() in default lib(s) */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_langinfo 1 /* #include <langinfo.h> ok */
+#define _nxt_nl_types <../include/nl_types.h> /* include path for the native <nl_types.h> */
+#define _nxt_nl_types_str "../include/nl_types.h" /* include string for the native <nl_types.h> */
+#include <limits.h>
+#include <../include/nl_types.h> /* the native nl_types.h */
+
+#undef NL_SETMAX
+#define NL_SETMAX 1023
+#undef NL_MSGMAX
+#define NL_MSGMAX 32767
+#undef nl_catd
+#define nl_catd _ast_nl_catd
+#undef catopen
+#define catopen _ast_catopen
+#undef catgets
+#define catgets _ast_catgets
+#undef catclose
+#define catclose _ast_catclose
+
+typedef __V_* nl_catd;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ nl_catd catopen __PROTO__((const char*, int));
+extern __MANGLE__ char* catgets __PROTO__((nl_catd, int, int, const char*));
+extern __MANGLE__ int catclose __PROTO__((nl_catd));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/omitted b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/omitted
new file mode 100644
index 0000000000..0f88dcabac
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/omitted
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/omitted by iffe version 2007-04-04 : : */
+#ifndef _def_omitted_ast
+#define _def_omitted_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/param b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/param
new file mode 100644
index 0000000000..577a0edf88
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/param
@@ -0,0 +1,9 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/param.sh by iffe version 2007-04-04 : : */
+#ifndef _def_param_ast
+#define _def_param_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#include <sys/param.h>
+#ifndef S_IFDIR
+#include <sys/stat.h>
+#endif
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/preroot b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/preroot
new file mode 100644
index 0000000000..7780f31251
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/preroot
@@ -0,0 +1,6 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/preroot.sh by iffe version 2007-04-04 : : */
+#ifndef _def_preroot_ast
+#define _def_preroot_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* preroot not enabled */
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/sfinit b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/sfinit
new file mode 100644
index 0000000000..0d0df0ccbd
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/sfinit
@@ -0,0 +1,5332 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/sfinit.c by iffe version 2007-04-04 : : */
+#ifndef _def_sfinit_ast
+#define _def_sfinit_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+static const float sf_flt_pow10[] =
+{
+ 1E0F,
+ 1E1F,
+ 1E2F,
+ 1E3F,
+ 1E4F,
+ 1E5F,
+ 1E6F,
+ 1E7F,
+ 1E8F,
+ 1E9F,
+ 1E10F,
+ 1E11F,
+ 1E12F,
+ 1E13F,
+ 1E14F,
+ 1E15F,
+ 1E16F,
+ 1E17F,
+ 1E18F,
+ 1E19F,
+ 1E20F,
+ 1E21F,
+ 1E22F,
+ 1E23F,
+ 1E24F,
+ 1E25F,
+ 1E26F,
+ 1E27F,
+ 1E28F,
+ 1E29F,
+ 1E30F,
+ 1E31F,
+ 1E32F,
+ 1E33F,
+ 1E34F,
+ 1E35F,
+ 1E36F,
+ 1E37F,
+ 1E38F,
+};
+
+static const double sf_dbl_pow10[] =
+{
+ 1E0,
+ 1E1,
+ 1E2,
+ 1E3,
+ 1E4,
+ 1E5,
+ 1E6,
+ 1E7,
+ 1E8,
+ 1E9,
+ 1E10,
+ 1E11,
+ 1E12,
+ 1E13,
+ 1E14,
+ 1E15,
+ 1E16,
+ 1E17,
+ 1E18,
+ 1E19,
+ 1E20,
+ 1E21,
+ 1E22,
+ 1E23,
+ 1E24,
+ 1E25,
+ 1E26,
+ 1E27,
+ 1E28,
+ 1E29,
+ 1E30,
+ 1E31,
+ 1E32,
+ 1E33,
+ 1E34,
+ 1E35,
+ 1E36,
+ 1E37,
+ 1E38,
+ 1E39,
+ 1E40,
+ 1E41,
+ 1E42,
+ 1E43,
+ 1E44,
+ 1E45,
+ 1E46,
+ 1E47,
+ 1E48,
+ 1E49,
+ 1E50,
+ 1E51,
+ 1E52,
+ 1E53,
+ 1E54,
+ 1E55,
+ 1E56,
+ 1E57,
+ 1E58,
+ 1E59,
+ 1E60,
+ 1E61,
+ 1E62,
+ 1E63,
+ 1E64,
+ 1E65,
+ 1E66,
+ 1E67,
+ 1E68,
+ 1E69,
+ 1E70,
+ 1E71,
+ 1E72,
+ 1E73,
+ 1E74,
+ 1E75,
+ 1E76,
+ 1E77,
+ 1E78,
+ 1E79,
+ 1E80,
+ 1E81,
+ 1E82,
+ 1E83,
+ 1E84,
+ 1E85,
+ 1E86,
+ 1E87,
+ 1E88,
+ 1E89,
+ 1E90,
+ 1E91,
+ 1E92,
+ 1E93,
+ 1E94,
+ 1E95,
+ 1E96,
+ 1E97,
+ 1E98,
+ 1E99,
+ 1E100,
+ 1E101,
+ 1E102,
+ 1E103,
+ 1E104,
+ 1E105,
+ 1E106,
+ 1E107,
+ 1E108,
+ 1E109,
+ 1E110,
+ 1E111,
+ 1E112,
+ 1E113,
+ 1E114,
+ 1E115,
+ 1E116,
+ 1E117,
+ 1E118,
+ 1E119,
+ 1E120,
+ 1E121,
+ 1E122,
+ 1E123,
+ 1E124,
+ 1E125,
+ 1E126,
+ 1E127,
+ 1E128,
+ 1E129,
+ 1E130,
+ 1E131,
+ 1E132,
+ 1E133,
+ 1E134,
+ 1E135,
+ 1E136,
+ 1E137,
+ 1E138,
+ 1E139,
+ 1E140,
+ 1E141,
+ 1E142,
+ 1E143,
+ 1E144,
+ 1E145,
+ 1E146,
+ 1E147,
+ 1E148,
+ 1E149,
+ 1E150,
+ 1E151,
+ 1E152,
+ 1E153,
+ 1E154,
+ 1E155,
+ 1E156,
+ 1E157,
+ 1E158,
+ 1E159,
+ 1E160,
+ 1E161,
+ 1E162,
+ 1E163,
+ 1E164,
+ 1E165,
+ 1E166,
+ 1E167,
+ 1E168,
+ 1E169,
+ 1E170,
+ 1E171,
+ 1E172,
+ 1E173,
+ 1E174,
+ 1E175,
+ 1E176,
+ 1E177,
+ 1E178,
+ 1E179,
+ 1E180,
+ 1E181,
+ 1E182,
+ 1E183,
+ 1E184,
+ 1E185,
+ 1E186,
+ 1E187,
+ 1E188,
+ 1E189,
+ 1E190,
+ 1E191,
+ 1E192,
+ 1E193,
+ 1E194,
+ 1E195,
+ 1E196,
+ 1E197,
+ 1E198,
+ 1E199,
+ 1E200,
+ 1E201,
+ 1E202,
+ 1E203,
+ 1E204,
+ 1E205,
+ 1E206,
+ 1E207,
+ 1E208,
+ 1E209,
+ 1E210,
+ 1E211,
+ 1E212,
+ 1E213,
+ 1E214,
+ 1E215,
+ 1E216,
+ 1E217,
+ 1E218,
+ 1E219,
+ 1E220,
+ 1E221,
+ 1E222,
+ 1E223,
+ 1E224,
+ 1E225,
+ 1E226,
+ 1E227,
+ 1E228,
+ 1E229,
+ 1E230,
+ 1E231,
+ 1E232,
+ 1E233,
+ 1E234,
+ 1E235,
+ 1E236,
+ 1E237,
+ 1E238,
+ 1E239,
+ 1E240,
+ 1E241,
+ 1E242,
+ 1E243,
+ 1E244,
+ 1E245,
+ 1E246,
+ 1E247,
+ 1E248,
+ 1E249,
+ 1E250,
+ 1E251,
+ 1E252,
+ 1E253,
+ 1E254,
+ 1E255,
+ 1E256,
+ 1E257,
+ 1E258,
+ 1E259,
+ 1E260,
+ 1E261,
+ 1E262,
+ 1E263,
+ 1E264,
+ 1E265,
+ 1E266,
+ 1E267,
+ 1E268,
+ 1E269,
+ 1E270,
+ 1E271,
+ 1E272,
+ 1E273,
+ 1E274,
+ 1E275,
+ 1E276,
+ 1E277,
+ 1E278,
+ 1E279,
+ 1E280,
+ 1E281,
+ 1E282,
+ 1E283,
+ 1E284,
+ 1E285,
+ 1E286,
+ 1E287,
+ 1E288,
+ 1E289,
+ 1E290,
+ 1E291,
+ 1E292,
+ 1E293,
+ 1E294,
+ 1E295,
+ 1E296,
+ 1E297,
+ 1E298,
+ 1E299,
+ 1E300,
+ 1E301,
+ 1E302,
+ 1E303,
+ 1E304,
+ 1E305,
+ 1E306,
+ 1E307,
+ 1E308,
+};
+
+static const _ast_fltmax_t sf_ldbl_pow10[] =
+{
+ 1E0L,
+ 1E1L,
+ 1E2L,
+ 1E3L,
+ 1E4L,
+ 1E5L,
+ 1E6L,
+ 1E7L,
+ 1E8L,
+ 1E9L,
+ 1E10L,
+ 1E11L,
+ 1E12L,
+ 1E13L,
+ 1E14L,
+ 1E15L,
+ 1E16L,
+ 1E17L,
+ 1E18L,
+ 1E19L,
+ 1E20L,
+ 1E21L,
+ 1E22L,
+ 1E23L,
+ 1E24L,
+ 1E25L,
+ 1E26L,
+ 1E27L,
+ 1E28L,
+ 1E29L,
+ 1E30L,
+ 1E31L,
+ 1E32L,
+ 1E33L,
+ 1E34L,
+ 1E35L,
+ 1E36L,
+ 1E37L,
+ 1E38L,
+ 1E39L,
+ 1E40L,
+ 1E41L,
+ 1E42L,
+ 1E43L,
+ 1E44L,
+ 1E45L,
+ 1E46L,
+ 1E47L,
+ 1E48L,
+ 1E49L,
+ 1E50L,
+ 1E51L,
+ 1E52L,
+ 1E53L,
+ 1E54L,
+ 1E55L,
+ 1E56L,
+ 1E57L,
+ 1E58L,
+ 1E59L,
+ 1E60L,
+ 1E61L,
+ 1E62L,
+ 1E63L,
+ 1E64L,
+ 1E65L,
+ 1E66L,
+ 1E67L,
+ 1E68L,
+ 1E69L,
+ 1E70L,
+ 1E71L,
+ 1E72L,
+ 1E73L,
+ 1E74L,
+ 1E75L,
+ 1E76L,
+ 1E77L,
+ 1E78L,
+ 1E79L,
+ 1E80L,
+ 1E81L,
+ 1E82L,
+ 1E83L,
+ 1E84L,
+ 1E85L,
+ 1E86L,
+ 1E87L,
+ 1E88L,
+ 1E89L,
+ 1E90L,
+ 1E91L,
+ 1E92L,
+ 1E93L,
+ 1E94L,
+ 1E95L,
+ 1E96L,
+ 1E97L,
+ 1E98L,
+ 1E99L,
+ 1E100L,
+ 1E101L,
+ 1E102L,
+ 1E103L,
+ 1E104L,
+ 1E105L,
+ 1E106L,
+ 1E107L,
+ 1E108L,
+ 1E109L,
+ 1E110L,
+ 1E111L,
+ 1E112L,
+ 1E113L,
+ 1E114L,
+ 1E115L,
+ 1E116L,
+ 1E117L,
+ 1E118L,
+ 1E119L,
+ 1E120L,
+ 1E121L,
+ 1E122L,
+ 1E123L,
+ 1E124L,
+ 1E125L,
+ 1E126L,
+ 1E127L,
+ 1E128L,
+ 1E129L,
+ 1E130L,
+ 1E131L,
+ 1E132L,
+ 1E133L,
+ 1E134L,
+ 1E135L,
+ 1E136L,
+ 1E137L,
+ 1E138L,
+ 1E139L,
+ 1E140L,
+ 1E141L,
+ 1E142L,
+ 1E143L,
+ 1E144L,
+ 1E145L,
+ 1E146L,
+ 1E147L,
+ 1E148L,
+ 1E149L,
+ 1E150L,
+ 1E151L,
+ 1E152L,
+ 1E153L,
+ 1E154L,
+ 1E155L,
+ 1E156L,
+ 1E157L,
+ 1E158L,
+ 1E159L,
+ 1E160L,
+ 1E161L,
+ 1E162L,
+ 1E163L,
+ 1E164L,
+ 1E165L,
+ 1E166L,
+ 1E167L,
+ 1E168L,
+ 1E169L,
+ 1E170L,
+ 1E171L,
+ 1E172L,
+ 1E173L,
+ 1E174L,
+ 1E175L,
+ 1E176L,
+ 1E177L,
+ 1E178L,
+ 1E179L,
+ 1E180L,
+ 1E181L,
+ 1E182L,
+ 1E183L,
+ 1E184L,
+ 1E185L,
+ 1E186L,
+ 1E187L,
+ 1E188L,
+ 1E189L,
+ 1E190L,
+ 1E191L,
+ 1E192L,
+ 1E193L,
+ 1E194L,
+ 1E195L,
+ 1E196L,
+ 1E197L,
+ 1E198L,
+ 1E199L,
+ 1E200L,
+ 1E201L,
+ 1E202L,
+ 1E203L,
+ 1E204L,
+ 1E205L,
+ 1E206L,
+ 1E207L,
+ 1E208L,
+ 1E209L,
+ 1E210L,
+ 1E211L,
+ 1E212L,
+ 1E213L,
+ 1E214L,
+ 1E215L,
+ 1E216L,
+ 1E217L,
+ 1E218L,
+ 1E219L,
+ 1E220L,
+ 1E221L,
+ 1E222L,
+ 1E223L,
+ 1E224L,
+ 1E225L,
+ 1E226L,
+ 1E227L,
+ 1E228L,
+ 1E229L,
+ 1E230L,
+ 1E231L,
+ 1E232L,
+ 1E233L,
+ 1E234L,
+ 1E235L,
+ 1E236L,
+ 1E237L,
+ 1E238L,
+ 1E239L,
+ 1E240L,
+ 1E241L,
+ 1E242L,
+ 1E243L,
+ 1E244L,
+ 1E245L,
+ 1E246L,
+ 1E247L,
+ 1E248L,
+ 1E249L,
+ 1E250L,
+ 1E251L,
+ 1E252L,
+ 1E253L,
+ 1E254L,
+ 1E255L,
+ 1E256L,
+ 1E257L,
+ 1E258L,
+ 1E259L,
+ 1E260L,
+ 1E261L,
+ 1E262L,
+ 1E263L,
+ 1E264L,
+ 1E265L,
+ 1E266L,
+ 1E267L,
+ 1E268L,
+ 1E269L,
+ 1E270L,
+ 1E271L,
+ 1E272L,
+ 1E273L,
+ 1E274L,
+ 1E275L,
+ 1E276L,
+ 1E277L,
+ 1E278L,
+ 1E279L,
+ 1E280L,
+ 1E281L,
+ 1E282L,
+ 1E283L,
+ 1E284L,
+ 1E285L,
+ 1E286L,
+ 1E287L,
+ 1E288L,
+ 1E289L,
+ 1E290L,
+ 1E291L,
+ 1E292L,
+ 1E293L,
+ 1E294L,
+ 1E295L,
+ 1E296L,
+ 1E297L,
+ 1E298L,
+ 1E299L,
+ 1E300L,
+ 1E301L,
+ 1E302L,
+ 1E303L,
+ 1E304L,
+ 1E305L,
+ 1E306L,
+ 1E307L,
+ 1E308L,
+ 1E309L,
+ 1E310L,
+ 1E311L,
+ 1E312L,
+ 1E313L,
+ 1E314L,
+ 1E315L,
+ 1E316L,
+ 1E317L,
+ 1E318L,
+ 1E319L,
+ 1E320L,
+ 1E321L,
+ 1E322L,
+ 1E323L,
+ 1E324L,
+ 1E325L,
+ 1E326L,
+ 1E327L,
+ 1E328L,
+ 1E329L,
+ 1E330L,
+ 1E331L,
+ 1E332L,
+ 1E333L,
+ 1E334L,
+ 1E335L,
+ 1E336L,
+ 1E337L,
+ 1E338L,
+ 1E339L,
+ 1E340L,
+ 1E341L,
+ 1E342L,
+ 1E343L,
+ 1E344L,
+ 1E345L,
+ 1E346L,
+ 1E347L,
+ 1E348L,
+ 1E349L,
+ 1E350L,
+ 1E351L,
+ 1E352L,
+ 1E353L,
+ 1E354L,
+ 1E355L,
+ 1E356L,
+ 1E357L,
+ 1E358L,
+ 1E359L,
+ 1E360L,
+ 1E361L,
+ 1E362L,
+ 1E363L,
+ 1E364L,
+ 1E365L,
+ 1E366L,
+ 1E367L,
+ 1E368L,
+ 1E369L,
+ 1E370L,
+ 1E371L,
+ 1E372L,
+ 1E373L,
+ 1E374L,
+ 1E375L,
+ 1E376L,
+ 1E377L,
+ 1E378L,
+ 1E379L,
+ 1E380L,
+ 1E381L,
+ 1E382L,
+ 1E383L,
+ 1E384L,
+ 1E385L,
+ 1E386L,
+ 1E387L,
+ 1E388L,
+ 1E389L,
+ 1E390L,
+ 1E391L,
+ 1E392L,
+ 1E393L,
+ 1E394L,
+ 1E395L,
+ 1E396L,
+ 1E397L,
+ 1E398L,
+ 1E399L,
+ 1E400L,
+ 1E401L,
+ 1E402L,
+ 1E403L,
+ 1E404L,
+ 1E405L,
+ 1E406L,
+ 1E407L,
+ 1E408L,
+ 1E409L,
+ 1E410L,
+ 1E411L,
+ 1E412L,
+ 1E413L,
+ 1E414L,
+ 1E415L,
+ 1E416L,
+ 1E417L,
+ 1E418L,
+ 1E419L,
+ 1E420L,
+ 1E421L,
+ 1E422L,
+ 1E423L,
+ 1E424L,
+ 1E425L,
+ 1E426L,
+ 1E427L,
+ 1E428L,
+ 1E429L,
+ 1E430L,
+ 1E431L,
+ 1E432L,
+ 1E433L,
+ 1E434L,
+ 1E435L,
+ 1E436L,
+ 1E437L,
+ 1E438L,
+ 1E439L,
+ 1E440L,
+ 1E441L,
+ 1E442L,
+ 1E443L,
+ 1E444L,
+ 1E445L,
+ 1E446L,
+ 1E447L,
+ 1E448L,
+ 1E449L,
+ 1E450L,
+ 1E451L,
+ 1E452L,
+ 1E453L,
+ 1E454L,
+ 1E455L,
+ 1E456L,
+ 1E457L,
+ 1E458L,
+ 1E459L,
+ 1E460L,
+ 1E461L,
+ 1E462L,
+ 1E463L,
+ 1E464L,
+ 1E465L,
+ 1E466L,
+ 1E467L,
+ 1E468L,
+ 1E469L,
+ 1E470L,
+ 1E471L,
+ 1E472L,
+ 1E473L,
+ 1E474L,
+ 1E475L,
+ 1E476L,
+ 1E477L,
+ 1E478L,
+ 1E479L,
+ 1E480L,
+ 1E481L,
+ 1E482L,
+ 1E483L,
+ 1E484L,
+ 1E485L,
+ 1E486L,
+ 1E487L,
+ 1E488L,
+ 1E489L,
+ 1E490L,
+ 1E491L,
+ 1E492L,
+ 1E493L,
+ 1E494L,
+ 1E495L,
+ 1E496L,
+ 1E497L,
+ 1E498L,
+ 1E499L,
+ 1E500L,
+ 1E501L,
+ 1E502L,
+ 1E503L,
+ 1E504L,
+ 1E505L,
+ 1E506L,
+ 1E507L,
+ 1E508L,
+ 1E509L,
+ 1E510L,
+ 1E511L,
+ 1E512L,
+ 1E513L,
+ 1E514L,
+ 1E515L,
+ 1E516L,
+ 1E517L,
+ 1E518L,
+ 1E519L,
+ 1E520L,
+ 1E521L,
+ 1E522L,
+ 1E523L,
+ 1E524L,
+ 1E525L,
+ 1E526L,
+ 1E527L,
+ 1E528L,
+ 1E529L,
+ 1E530L,
+ 1E531L,
+ 1E532L,
+ 1E533L,
+ 1E534L,
+ 1E535L,
+ 1E536L,
+ 1E537L,
+ 1E538L,
+ 1E539L,
+ 1E540L,
+ 1E541L,
+ 1E542L,
+ 1E543L,
+ 1E544L,
+ 1E545L,
+ 1E546L,
+ 1E547L,
+ 1E548L,
+ 1E549L,
+ 1E550L,
+ 1E551L,
+ 1E552L,
+ 1E553L,
+ 1E554L,
+ 1E555L,
+ 1E556L,
+ 1E557L,
+ 1E558L,
+ 1E559L,
+ 1E560L,
+ 1E561L,
+ 1E562L,
+ 1E563L,
+ 1E564L,
+ 1E565L,
+ 1E566L,
+ 1E567L,
+ 1E568L,
+ 1E569L,
+ 1E570L,
+ 1E571L,
+ 1E572L,
+ 1E573L,
+ 1E574L,
+ 1E575L,
+ 1E576L,
+ 1E577L,
+ 1E578L,
+ 1E579L,
+ 1E580L,
+ 1E581L,
+ 1E582L,
+ 1E583L,
+ 1E584L,
+ 1E585L,
+ 1E586L,
+ 1E587L,
+ 1E588L,
+ 1E589L,
+ 1E590L,
+ 1E591L,
+ 1E592L,
+ 1E593L,
+ 1E594L,
+ 1E595L,
+ 1E596L,
+ 1E597L,
+ 1E598L,
+ 1E599L,
+ 1E600L,
+ 1E601L,
+ 1E602L,
+ 1E603L,
+ 1E604L,
+ 1E605L,
+ 1E606L,
+ 1E607L,
+ 1E608L,
+ 1E609L,
+ 1E610L,
+ 1E611L,
+ 1E612L,
+ 1E613L,
+ 1E614L,
+ 1E615L,
+ 1E616L,
+ 1E617L,
+ 1E618L,
+ 1E619L,
+ 1E620L,
+ 1E621L,
+ 1E622L,
+ 1E623L,
+ 1E624L,
+ 1E625L,
+ 1E626L,
+ 1E627L,
+ 1E628L,
+ 1E629L,
+ 1E630L,
+ 1E631L,
+ 1E632L,
+ 1E633L,
+ 1E634L,
+ 1E635L,
+ 1E636L,
+ 1E637L,
+ 1E638L,
+ 1E639L,
+ 1E640L,
+ 1E641L,
+ 1E642L,
+ 1E643L,
+ 1E644L,
+ 1E645L,
+ 1E646L,
+ 1E647L,
+ 1E648L,
+ 1E649L,
+ 1E650L,
+ 1E651L,
+ 1E652L,
+ 1E653L,
+ 1E654L,
+ 1E655L,
+ 1E656L,
+ 1E657L,
+ 1E658L,
+ 1E659L,
+ 1E660L,
+ 1E661L,
+ 1E662L,
+ 1E663L,
+ 1E664L,
+ 1E665L,
+ 1E666L,
+ 1E667L,
+ 1E668L,
+ 1E669L,
+ 1E670L,
+ 1E671L,
+ 1E672L,
+ 1E673L,
+ 1E674L,
+ 1E675L,
+ 1E676L,
+ 1E677L,
+ 1E678L,
+ 1E679L,
+ 1E680L,
+ 1E681L,
+ 1E682L,
+ 1E683L,
+ 1E684L,
+ 1E685L,
+ 1E686L,
+ 1E687L,
+ 1E688L,
+ 1E689L,
+ 1E690L,
+ 1E691L,
+ 1E692L,
+ 1E693L,
+ 1E694L,
+ 1E695L,
+ 1E696L,
+ 1E697L,
+ 1E698L,
+ 1E699L,
+ 1E700L,
+ 1E701L,
+ 1E702L,
+ 1E703L,
+ 1E704L,
+ 1E705L,
+ 1E706L,
+ 1E707L,
+ 1E708L,
+ 1E709L,
+ 1E710L,
+ 1E711L,
+ 1E712L,
+ 1E713L,
+ 1E714L,
+ 1E715L,
+ 1E716L,
+ 1E717L,
+ 1E718L,
+ 1E719L,
+ 1E720L,
+ 1E721L,
+ 1E722L,
+ 1E723L,
+ 1E724L,
+ 1E725L,
+ 1E726L,
+ 1E727L,
+ 1E728L,
+ 1E729L,
+ 1E730L,
+ 1E731L,
+ 1E732L,
+ 1E733L,
+ 1E734L,
+ 1E735L,
+ 1E736L,
+ 1E737L,
+ 1E738L,
+ 1E739L,
+ 1E740L,
+ 1E741L,
+ 1E742L,
+ 1E743L,
+ 1E744L,
+ 1E745L,
+ 1E746L,
+ 1E747L,
+ 1E748L,
+ 1E749L,
+ 1E750L,
+ 1E751L,
+ 1E752L,
+ 1E753L,
+ 1E754L,
+ 1E755L,
+ 1E756L,
+ 1E757L,
+ 1E758L,
+ 1E759L,
+ 1E760L,
+ 1E761L,
+ 1E762L,
+ 1E763L,
+ 1E764L,
+ 1E765L,
+ 1E766L,
+ 1E767L,
+ 1E768L,
+ 1E769L,
+ 1E770L,
+ 1E771L,
+ 1E772L,
+ 1E773L,
+ 1E774L,
+ 1E775L,
+ 1E776L,
+ 1E777L,
+ 1E778L,
+ 1E779L,
+ 1E780L,
+ 1E781L,
+ 1E782L,
+ 1E783L,
+ 1E784L,
+ 1E785L,
+ 1E786L,
+ 1E787L,
+ 1E788L,
+ 1E789L,
+ 1E790L,
+ 1E791L,
+ 1E792L,
+ 1E793L,
+ 1E794L,
+ 1E795L,
+ 1E796L,
+ 1E797L,
+ 1E798L,
+ 1E799L,
+ 1E800L,
+ 1E801L,
+ 1E802L,
+ 1E803L,
+ 1E804L,
+ 1E805L,
+ 1E806L,
+ 1E807L,
+ 1E808L,
+ 1E809L,
+ 1E810L,
+ 1E811L,
+ 1E812L,
+ 1E813L,
+ 1E814L,
+ 1E815L,
+ 1E816L,
+ 1E817L,
+ 1E818L,
+ 1E819L,
+ 1E820L,
+ 1E821L,
+ 1E822L,
+ 1E823L,
+ 1E824L,
+ 1E825L,
+ 1E826L,
+ 1E827L,
+ 1E828L,
+ 1E829L,
+ 1E830L,
+ 1E831L,
+ 1E832L,
+ 1E833L,
+ 1E834L,
+ 1E835L,
+ 1E836L,
+ 1E837L,
+ 1E838L,
+ 1E839L,
+ 1E840L,
+ 1E841L,
+ 1E842L,
+ 1E843L,
+ 1E844L,
+ 1E845L,
+ 1E846L,
+ 1E847L,
+ 1E848L,
+ 1E849L,
+ 1E850L,
+ 1E851L,
+ 1E852L,
+ 1E853L,
+ 1E854L,
+ 1E855L,
+ 1E856L,
+ 1E857L,
+ 1E858L,
+ 1E859L,
+ 1E860L,
+ 1E861L,
+ 1E862L,
+ 1E863L,
+ 1E864L,
+ 1E865L,
+ 1E866L,
+ 1E867L,
+ 1E868L,
+ 1E869L,
+ 1E870L,
+ 1E871L,
+ 1E872L,
+ 1E873L,
+ 1E874L,
+ 1E875L,
+ 1E876L,
+ 1E877L,
+ 1E878L,
+ 1E879L,
+ 1E880L,
+ 1E881L,
+ 1E882L,
+ 1E883L,
+ 1E884L,
+ 1E885L,
+ 1E886L,
+ 1E887L,
+ 1E888L,
+ 1E889L,
+ 1E890L,
+ 1E891L,
+ 1E892L,
+ 1E893L,
+ 1E894L,
+ 1E895L,
+ 1E896L,
+ 1E897L,
+ 1E898L,
+ 1E899L,
+ 1E900L,
+ 1E901L,
+ 1E902L,
+ 1E903L,
+ 1E904L,
+ 1E905L,
+ 1E906L,
+ 1E907L,
+ 1E908L,
+ 1E909L,
+ 1E910L,
+ 1E911L,
+ 1E912L,
+ 1E913L,
+ 1E914L,
+ 1E915L,
+ 1E916L,
+ 1E917L,
+ 1E918L,
+ 1E919L,
+ 1E920L,
+ 1E921L,
+ 1E922L,
+ 1E923L,
+ 1E924L,
+ 1E925L,
+ 1E926L,
+ 1E927L,
+ 1E928L,
+ 1E929L,
+ 1E930L,
+ 1E931L,
+ 1E932L,
+ 1E933L,
+ 1E934L,
+ 1E935L,
+ 1E936L,
+ 1E937L,
+ 1E938L,
+ 1E939L,
+ 1E940L,
+ 1E941L,
+ 1E942L,
+ 1E943L,
+ 1E944L,
+ 1E945L,
+ 1E946L,
+ 1E947L,
+ 1E948L,
+ 1E949L,
+ 1E950L,
+ 1E951L,
+ 1E952L,
+ 1E953L,
+ 1E954L,
+ 1E955L,
+ 1E956L,
+ 1E957L,
+ 1E958L,
+ 1E959L,
+ 1E960L,
+ 1E961L,
+ 1E962L,
+ 1E963L,
+ 1E964L,
+ 1E965L,
+ 1E966L,
+ 1E967L,
+ 1E968L,
+ 1E969L,
+ 1E970L,
+ 1E971L,
+ 1E972L,
+ 1E973L,
+ 1E974L,
+ 1E975L,
+ 1E976L,
+ 1E977L,
+ 1E978L,
+ 1E979L,
+ 1E980L,
+ 1E981L,
+ 1E982L,
+ 1E983L,
+ 1E984L,
+ 1E985L,
+ 1E986L,
+ 1E987L,
+ 1E988L,
+ 1E989L,
+ 1E990L,
+ 1E991L,
+ 1E992L,
+ 1E993L,
+ 1E994L,
+ 1E995L,
+ 1E996L,
+ 1E997L,
+ 1E998L,
+ 1E999L,
+ 1E1000L,
+ 1E1001L,
+ 1E1002L,
+ 1E1003L,
+ 1E1004L,
+ 1E1005L,
+ 1E1006L,
+ 1E1007L,
+ 1E1008L,
+ 1E1009L,
+ 1E1010L,
+ 1E1011L,
+ 1E1012L,
+ 1E1013L,
+ 1E1014L,
+ 1E1015L,
+ 1E1016L,
+ 1E1017L,
+ 1E1018L,
+ 1E1019L,
+ 1E1020L,
+ 1E1021L,
+ 1E1022L,
+ 1E1023L,
+ 1E1024L,
+ 1E1025L,
+ 1E1026L,
+ 1E1027L,
+ 1E1028L,
+ 1E1029L,
+ 1E1030L,
+ 1E1031L,
+ 1E1032L,
+ 1E1033L,
+ 1E1034L,
+ 1E1035L,
+ 1E1036L,
+ 1E1037L,
+ 1E1038L,
+ 1E1039L,
+ 1E1040L,
+ 1E1041L,
+ 1E1042L,
+ 1E1043L,
+ 1E1044L,
+ 1E1045L,
+ 1E1046L,
+ 1E1047L,
+ 1E1048L,
+ 1E1049L,
+ 1E1050L,
+ 1E1051L,
+ 1E1052L,
+ 1E1053L,
+ 1E1054L,
+ 1E1055L,
+ 1E1056L,
+ 1E1057L,
+ 1E1058L,
+ 1E1059L,
+ 1E1060L,
+ 1E1061L,
+ 1E1062L,
+ 1E1063L,
+ 1E1064L,
+ 1E1065L,
+ 1E1066L,
+ 1E1067L,
+ 1E1068L,
+ 1E1069L,
+ 1E1070L,
+ 1E1071L,
+ 1E1072L,
+ 1E1073L,
+ 1E1074L,
+ 1E1075L,
+ 1E1076L,
+ 1E1077L,
+ 1E1078L,
+ 1E1079L,
+ 1E1080L,
+ 1E1081L,
+ 1E1082L,
+ 1E1083L,
+ 1E1084L,
+ 1E1085L,
+ 1E1086L,
+ 1E1087L,
+ 1E1088L,
+ 1E1089L,
+ 1E1090L,
+ 1E1091L,
+ 1E1092L,
+ 1E1093L,
+ 1E1094L,
+ 1E1095L,
+ 1E1096L,
+ 1E1097L,
+ 1E1098L,
+ 1E1099L,
+ 1E1100L,
+ 1E1101L,
+ 1E1102L,
+ 1E1103L,
+ 1E1104L,
+ 1E1105L,
+ 1E1106L,
+ 1E1107L,
+ 1E1108L,
+ 1E1109L,
+ 1E1110L,
+ 1E1111L,
+ 1E1112L,
+ 1E1113L,
+ 1E1114L,
+ 1E1115L,
+ 1E1116L,
+ 1E1117L,
+ 1E1118L,
+ 1E1119L,
+ 1E1120L,
+ 1E1121L,
+ 1E1122L,
+ 1E1123L,
+ 1E1124L,
+ 1E1125L,
+ 1E1126L,
+ 1E1127L,
+ 1E1128L,
+ 1E1129L,
+ 1E1130L,
+ 1E1131L,
+ 1E1132L,
+ 1E1133L,
+ 1E1134L,
+ 1E1135L,
+ 1E1136L,
+ 1E1137L,
+ 1E1138L,
+ 1E1139L,
+ 1E1140L,
+ 1E1141L,
+ 1E1142L,
+ 1E1143L,
+ 1E1144L,
+ 1E1145L,
+ 1E1146L,
+ 1E1147L,
+ 1E1148L,
+ 1E1149L,
+ 1E1150L,
+ 1E1151L,
+ 1E1152L,
+ 1E1153L,
+ 1E1154L,
+ 1E1155L,
+ 1E1156L,
+ 1E1157L,
+ 1E1158L,
+ 1E1159L,
+ 1E1160L,
+ 1E1161L,
+ 1E1162L,
+ 1E1163L,
+ 1E1164L,
+ 1E1165L,
+ 1E1166L,
+ 1E1167L,
+ 1E1168L,
+ 1E1169L,
+ 1E1170L,
+ 1E1171L,
+ 1E1172L,
+ 1E1173L,
+ 1E1174L,
+ 1E1175L,
+ 1E1176L,
+ 1E1177L,
+ 1E1178L,
+ 1E1179L,
+ 1E1180L,
+ 1E1181L,
+ 1E1182L,
+ 1E1183L,
+ 1E1184L,
+ 1E1185L,
+ 1E1186L,
+ 1E1187L,
+ 1E1188L,
+ 1E1189L,
+ 1E1190L,
+ 1E1191L,
+ 1E1192L,
+ 1E1193L,
+ 1E1194L,
+ 1E1195L,
+ 1E1196L,
+ 1E1197L,
+ 1E1198L,
+ 1E1199L,
+ 1E1200L,
+ 1E1201L,
+ 1E1202L,
+ 1E1203L,
+ 1E1204L,
+ 1E1205L,
+ 1E1206L,
+ 1E1207L,
+ 1E1208L,
+ 1E1209L,
+ 1E1210L,
+ 1E1211L,
+ 1E1212L,
+ 1E1213L,
+ 1E1214L,
+ 1E1215L,
+ 1E1216L,
+ 1E1217L,
+ 1E1218L,
+ 1E1219L,
+ 1E1220L,
+ 1E1221L,
+ 1E1222L,
+ 1E1223L,
+ 1E1224L,
+ 1E1225L,
+ 1E1226L,
+ 1E1227L,
+ 1E1228L,
+ 1E1229L,
+ 1E1230L,
+ 1E1231L,
+ 1E1232L,
+ 1E1233L,
+ 1E1234L,
+ 1E1235L,
+ 1E1236L,
+ 1E1237L,
+ 1E1238L,
+ 1E1239L,
+ 1E1240L,
+ 1E1241L,
+ 1E1242L,
+ 1E1243L,
+ 1E1244L,
+ 1E1245L,
+ 1E1246L,
+ 1E1247L,
+ 1E1248L,
+ 1E1249L,
+ 1E1250L,
+ 1E1251L,
+ 1E1252L,
+ 1E1253L,
+ 1E1254L,
+ 1E1255L,
+ 1E1256L,
+ 1E1257L,
+ 1E1258L,
+ 1E1259L,
+ 1E1260L,
+ 1E1261L,
+ 1E1262L,
+ 1E1263L,
+ 1E1264L,
+ 1E1265L,
+ 1E1266L,
+ 1E1267L,
+ 1E1268L,
+ 1E1269L,
+ 1E1270L,
+ 1E1271L,
+ 1E1272L,
+ 1E1273L,
+ 1E1274L,
+ 1E1275L,
+ 1E1276L,
+ 1E1277L,
+ 1E1278L,
+ 1E1279L,
+ 1E1280L,
+ 1E1281L,
+ 1E1282L,
+ 1E1283L,
+ 1E1284L,
+ 1E1285L,
+ 1E1286L,
+ 1E1287L,
+ 1E1288L,
+ 1E1289L,
+ 1E1290L,
+ 1E1291L,
+ 1E1292L,
+ 1E1293L,
+ 1E1294L,
+ 1E1295L,
+ 1E1296L,
+ 1E1297L,
+ 1E1298L,
+ 1E1299L,
+ 1E1300L,
+ 1E1301L,
+ 1E1302L,
+ 1E1303L,
+ 1E1304L,
+ 1E1305L,
+ 1E1306L,
+ 1E1307L,
+ 1E1308L,
+ 1E1309L,
+ 1E1310L,
+ 1E1311L,
+ 1E1312L,
+ 1E1313L,
+ 1E1314L,
+ 1E1315L,
+ 1E1316L,
+ 1E1317L,
+ 1E1318L,
+ 1E1319L,
+ 1E1320L,
+ 1E1321L,
+ 1E1322L,
+ 1E1323L,
+ 1E1324L,
+ 1E1325L,
+ 1E1326L,
+ 1E1327L,
+ 1E1328L,
+ 1E1329L,
+ 1E1330L,
+ 1E1331L,
+ 1E1332L,
+ 1E1333L,
+ 1E1334L,
+ 1E1335L,
+ 1E1336L,
+ 1E1337L,
+ 1E1338L,
+ 1E1339L,
+ 1E1340L,
+ 1E1341L,
+ 1E1342L,
+ 1E1343L,
+ 1E1344L,
+ 1E1345L,
+ 1E1346L,
+ 1E1347L,
+ 1E1348L,
+ 1E1349L,
+ 1E1350L,
+ 1E1351L,
+ 1E1352L,
+ 1E1353L,
+ 1E1354L,
+ 1E1355L,
+ 1E1356L,
+ 1E1357L,
+ 1E1358L,
+ 1E1359L,
+ 1E1360L,
+ 1E1361L,
+ 1E1362L,
+ 1E1363L,
+ 1E1364L,
+ 1E1365L,
+ 1E1366L,
+ 1E1367L,
+ 1E1368L,
+ 1E1369L,
+ 1E1370L,
+ 1E1371L,
+ 1E1372L,
+ 1E1373L,
+ 1E1374L,
+ 1E1375L,
+ 1E1376L,
+ 1E1377L,
+ 1E1378L,
+ 1E1379L,
+ 1E1380L,
+ 1E1381L,
+ 1E1382L,
+ 1E1383L,
+ 1E1384L,
+ 1E1385L,
+ 1E1386L,
+ 1E1387L,
+ 1E1388L,
+ 1E1389L,
+ 1E1390L,
+ 1E1391L,
+ 1E1392L,
+ 1E1393L,
+ 1E1394L,
+ 1E1395L,
+ 1E1396L,
+ 1E1397L,
+ 1E1398L,
+ 1E1399L,
+ 1E1400L,
+ 1E1401L,
+ 1E1402L,
+ 1E1403L,
+ 1E1404L,
+ 1E1405L,
+ 1E1406L,
+ 1E1407L,
+ 1E1408L,
+ 1E1409L,
+ 1E1410L,
+ 1E1411L,
+ 1E1412L,
+ 1E1413L,
+ 1E1414L,
+ 1E1415L,
+ 1E1416L,
+ 1E1417L,
+ 1E1418L,
+ 1E1419L,
+ 1E1420L,
+ 1E1421L,
+ 1E1422L,
+ 1E1423L,
+ 1E1424L,
+ 1E1425L,
+ 1E1426L,
+ 1E1427L,
+ 1E1428L,
+ 1E1429L,
+ 1E1430L,
+ 1E1431L,
+ 1E1432L,
+ 1E1433L,
+ 1E1434L,
+ 1E1435L,
+ 1E1436L,
+ 1E1437L,
+ 1E1438L,
+ 1E1439L,
+ 1E1440L,
+ 1E1441L,
+ 1E1442L,
+ 1E1443L,
+ 1E1444L,
+ 1E1445L,
+ 1E1446L,
+ 1E1447L,
+ 1E1448L,
+ 1E1449L,
+ 1E1450L,
+ 1E1451L,
+ 1E1452L,
+ 1E1453L,
+ 1E1454L,
+ 1E1455L,
+ 1E1456L,
+ 1E1457L,
+ 1E1458L,
+ 1E1459L,
+ 1E1460L,
+ 1E1461L,
+ 1E1462L,
+ 1E1463L,
+ 1E1464L,
+ 1E1465L,
+ 1E1466L,
+ 1E1467L,
+ 1E1468L,
+ 1E1469L,
+ 1E1470L,
+ 1E1471L,
+ 1E1472L,
+ 1E1473L,
+ 1E1474L,
+ 1E1475L,
+ 1E1476L,
+ 1E1477L,
+ 1E1478L,
+ 1E1479L,
+ 1E1480L,
+ 1E1481L,
+ 1E1482L,
+ 1E1483L,
+ 1E1484L,
+ 1E1485L,
+ 1E1486L,
+ 1E1487L,
+ 1E1488L,
+ 1E1489L,
+ 1E1490L,
+ 1E1491L,
+ 1E1492L,
+ 1E1493L,
+ 1E1494L,
+ 1E1495L,
+ 1E1496L,
+ 1E1497L,
+ 1E1498L,
+ 1E1499L,
+ 1E1500L,
+ 1E1501L,
+ 1E1502L,
+ 1E1503L,
+ 1E1504L,
+ 1E1505L,
+ 1E1506L,
+ 1E1507L,
+ 1E1508L,
+ 1E1509L,
+ 1E1510L,
+ 1E1511L,
+ 1E1512L,
+ 1E1513L,
+ 1E1514L,
+ 1E1515L,
+ 1E1516L,
+ 1E1517L,
+ 1E1518L,
+ 1E1519L,
+ 1E1520L,
+ 1E1521L,
+ 1E1522L,
+ 1E1523L,
+ 1E1524L,
+ 1E1525L,
+ 1E1526L,
+ 1E1527L,
+ 1E1528L,
+ 1E1529L,
+ 1E1530L,
+ 1E1531L,
+ 1E1532L,
+ 1E1533L,
+ 1E1534L,
+ 1E1535L,
+ 1E1536L,
+ 1E1537L,
+ 1E1538L,
+ 1E1539L,
+ 1E1540L,
+ 1E1541L,
+ 1E1542L,
+ 1E1543L,
+ 1E1544L,
+ 1E1545L,
+ 1E1546L,
+ 1E1547L,
+ 1E1548L,
+ 1E1549L,
+ 1E1550L,
+ 1E1551L,
+ 1E1552L,
+ 1E1553L,
+ 1E1554L,
+ 1E1555L,
+ 1E1556L,
+ 1E1557L,
+ 1E1558L,
+ 1E1559L,
+ 1E1560L,
+ 1E1561L,
+ 1E1562L,
+ 1E1563L,
+ 1E1564L,
+ 1E1565L,
+ 1E1566L,
+ 1E1567L,
+ 1E1568L,
+ 1E1569L,
+ 1E1570L,
+ 1E1571L,
+ 1E1572L,
+ 1E1573L,
+ 1E1574L,
+ 1E1575L,
+ 1E1576L,
+ 1E1577L,
+ 1E1578L,
+ 1E1579L,
+ 1E1580L,
+ 1E1581L,
+ 1E1582L,
+ 1E1583L,
+ 1E1584L,
+ 1E1585L,
+ 1E1586L,
+ 1E1587L,
+ 1E1588L,
+ 1E1589L,
+ 1E1590L,
+ 1E1591L,
+ 1E1592L,
+ 1E1593L,
+ 1E1594L,
+ 1E1595L,
+ 1E1596L,
+ 1E1597L,
+ 1E1598L,
+ 1E1599L,
+ 1E1600L,
+ 1E1601L,
+ 1E1602L,
+ 1E1603L,
+ 1E1604L,
+ 1E1605L,
+ 1E1606L,
+ 1E1607L,
+ 1E1608L,
+ 1E1609L,
+ 1E1610L,
+ 1E1611L,
+ 1E1612L,
+ 1E1613L,
+ 1E1614L,
+ 1E1615L,
+ 1E1616L,
+ 1E1617L,
+ 1E1618L,
+ 1E1619L,
+ 1E1620L,
+ 1E1621L,
+ 1E1622L,
+ 1E1623L,
+ 1E1624L,
+ 1E1625L,
+ 1E1626L,
+ 1E1627L,
+ 1E1628L,
+ 1E1629L,
+ 1E1630L,
+ 1E1631L,
+ 1E1632L,
+ 1E1633L,
+ 1E1634L,
+ 1E1635L,
+ 1E1636L,
+ 1E1637L,
+ 1E1638L,
+ 1E1639L,
+ 1E1640L,
+ 1E1641L,
+ 1E1642L,
+ 1E1643L,
+ 1E1644L,
+ 1E1645L,
+ 1E1646L,
+ 1E1647L,
+ 1E1648L,
+ 1E1649L,
+ 1E1650L,
+ 1E1651L,
+ 1E1652L,
+ 1E1653L,
+ 1E1654L,
+ 1E1655L,
+ 1E1656L,
+ 1E1657L,
+ 1E1658L,
+ 1E1659L,
+ 1E1660L,
+ 1E1661L,
+ 1E1662L,
+ 1E1663L,
+ 1E1664L,
+ 1E1665L,
+ 1E1666L,
+ 1E1667L,
+ 1E1668L,
+ 1E1669L,
+ 1E1670L,
+ 1E1671L,
+ 1E1672L,
+ 1E1673L,
+ 1E1674L,
+ 1E1675L,
+ 1E1676L,
+ 1E1677L,
+ 1E1678L,
+ 1E1679L,
+ 1E1680L,
+ 1E1681L,
+ 1E1682L,
+ 1E1683L,
+ 1E1684L,
+ 1E1685L,
+ 1E1686L,
+ 1E1687L,
+ 1E1688L,
+ 1E1689L,
+ 1E1690L,
+ 1E1691L,
+ 1E1692L,
+ 1E1693L,
+ 1E1694L,
+ 1E1695L,
+ 1E1696L,
+ 1E1697L,
+ 1E1698L,
+ 1E1699L,
+ 1E1700L,
+ 1E1701L,
+ 1E1702L,
+ 1E1703L,
+ 1E1704L,
+ 1E1705L,
+ 1E1706L,
+ 1E1707L,
+ 1E1708L,
+ 1E1709L,
+ 1E1710L,
+ 1E1711L,
+ 1E1712L,
+ 1E1713L,
+ 1E1714L,
+ 1E1715L,
+ 1E1716L,
+ 1E1717L,
+ 1E1718L,
+ 1E1719L,
+ 1E1720L,
+ 1E1721L,
+ 1E1722L,
+ 1E1723L,
+ 1E1724L,
+ 1E1725L,
+ 1E1726L,
+ 1E1727L,
+ 1E1728L,
+ 1E1729L,
+ 1E1730L,
+ 1E1731L,
+ 1E1732L,
+ 1E1733L,
+ 1E1734L,
+ 1E1735L,
+ 1E1736L,
+ 1E1737L,
+ 1E1738L,
+ 1E1739L,
+ 1E1740L,
+ 1E1741L,
+ 1E1742L,
+ 1E1743L,
+ 1E1744L,
+ 1E1745L,
+ 1E1746L,
+ 1E1747L,
+ 1E1748L,
+ 1E1749L,
+ 1E1750L,
+ 1E1751L,
+ 1E1752L,
+ 1E1753L,
+ 1E1754L,
+ 1E1755L,
+ 1E1756L,
+ 1E1757L,
+ 1E1758L,
+ 1E1759L,
+ 1E1760L,
+ 1E1761L,
+ 1E1762L,
+ 1E1763L,
+ 1E1764L,
+ 1E1765L,
+ 1E1766L,
+ 1E1767L,
+ 1E1768L,
+ 1E1769L,
+ 1E1770L,
+ 1E1771L,
+ 1E1772L,
+ 1E1773L,
+ 1E1774L,
+ 1E1775L,
+ 1E1776L,
+ 1E1777L,
+ 1E1778L,
+ 1E1779L,
+ 1E1780L,
+ 1E1781L,
+ 1E1782L,
+ 1E1783L,
+ 1E1784L,
+ 1E1785L,
+ 1E1786L,
+ 1E1787L,
+ 1E1788L,
+ 1E1789L,
+ 1E1790L,
+ 1E1791L,
+ 1E1792L,
+ 1E1793L,
+ 1E1794L,
+ 1E1795L,
+ 1E1796L,
+ 1E1797L,
+ 1E1798L,
+ 1E1799L,
+ 1E1800L,
+ 1E1801L,
+ 1E1802L,
+ 1E1803L,
+ 1E1804L,
+ 1E1805L,
+ 1E1806L,
+ 1E1807L,
+ 1E1808L,
+ 1E1809L,
+ 1E1810L,
+ 1E1811L,
+ 1E1812L,
+ 1E1813L,
+ 1E1814L,
+ 1E1815L,
+ 1E1816L,
+ 1E1817L,
+ 1E1818L,
+ 1E1819L,
+ 1E1820L,
+ 1E1821L,
+ 1E1822L,
+ 1E1823L,
+ 1E1824L,
+ 1E1825L,
+ 1E1826L,
+ 1E1827L,
+ 1E1828L,
+ 1E1829L,
+ 1E1830L,
+ 1E1831L,
+ 1E1832L,
+ 1E1833L,
+ 1E1834L,
+ 1E1835L,
+ 1E1836L,
+ 1E1837L,
+ 1E1838L,
+ 1E1839L,
+ 1E1840L,
+ 1E1841L,
+ 1E1842L,
+ 1E1843L,
+ 1E1844L,
+ 1E1845L,
+ 1E1846L,
+ 1E1847L,
+ 1E1848L,
+ 1E1849L,
+ 1E1850L,
+ 1E1851L,
+ 1E1852L,
+ 1E1853L,
+ 1E1854L,
+ 1E1855L,
+ 1E1856L,
+ 1E1857L,
+ 1E1858L,
+ 1E1859L,
+ 1E1860L,
+ 1E1861L,
+ 1E1862L,
+ 1E1863L,
+ 1E1864L,
+ 1E1865L,
+ 1E1866L,
+ 1E1867L,
+ 1E1868L,
+ 1E1869L,
+ 1E1870L,
+ 1E1871L,
+ 1E1872L,
+ 1E1873L,
+ 1E1874L,
+ 1E1875L,
+ 1E1876L,
+ 1E1877L,
+ 1E1878L,
+ 1E1879L,
+ 1E1880L,
+ 1E1881L,
+ 1E1882L,
+ 1E1883L,
+ 1E1884L,
+ 1E1885L,
+ 1E1886L,
+ 1E1887L,
+ 1E1888L,
+ 1E1889L,
+ 1E1890L,
+ 1E1891L,
+ 1E1892L,
+ 1E1893L,
+ 1E1894L,
+ 1E1895L,
+ 1E1896L,
+ 1E1897L,
+ 1E1898L,
+ 1E1899L,
+ 1E1900L,
+ 1E1901L,
+ 1E1902L,
+ 1E1903L,
+ 1E1904L,
+ 1E1905L,
+ 1E1906L,
+ 1E1907L,
+ 1E1908L,
+ 1E1909L,
+ 1E1910L,
+ 1E1911L,
+ 1E1912L,
+ 1E1913L,
+ 1E1914L,
+ 1E1915L,
+ 1E1916L,
+ 1E1917L,
+ 1E1918L,
+ 1E1919L,
+ 1E1920L,
+ 1E1921L,
+ 1E1922L,
+ 1E1923L,
+ 1E1924L,
+ 1E1925L,
+ 1E1926L,
+ 1E1927L,
+ 1E1928L,
+ 1E1929L,
+ 1E1930L,
+ 1E1931L,
+ 1E1932L,
+ 1E1933L,
+ 1E1934L,
+ 1E1935L,
+ 1E1936L,
+ 1E1937L,
+ 1E1938L,
+ 1E1939L,
+ 1E1940L,
+ 1E1941L,
+ 1E1942L,
+ 1E1943L,
+ 1E1944L,
+ 1E1945L,
+ 1E1946L,
+ 1E1947L,
+ 1E1948L,
+ 1E1949L,
+ 1E1950L,
+ 1E1951L,
+ 1E1952L,
+ 1E1953L,
+ 1E1954L,
+ 1E1955L,
+ 1E1956L,
+ 1E1957L,
+ 1E1958L,
+ 1E1959L,
+ 1E1960L,
+ 1E1961L,
+ 1E1962L,
+ 1E1963L,
+ 1E1964L,
+ 1E1965L,
+ 1E1966L,
+ 1E1967L,
+ 1E1968L,
+ 1E1969L,
+ 1E1970L,
+ 1E1971L,
+ 1E1972L,
+ 1E1973L,
+ 1E1974L,
+ 1E1975L,
+ 1E1976L,
+ 1E1977L,
+ 1E1978L,
+ 1E1979L,
+ 1E1980L,
+ 1E1981L,
+ 1E1982L,
+ 1E1983L,
+ 1E1984L,
+ 1E1985L,
+ 1E1986L,
+ 1E1987L,
+ 1E1988L,
+ 1E1989L,
+ 1E1990L,
+ 1E1991L,
+ 1E1992L,
+ 1E1993L,
+ 1E1994L,
+ 1E1995L,
+ 1E1996L,
+ 1E1997L,
+ 1E1998L,
+ 1E1999L,
+ 1E2000L,
+ 1E2001L,
+ 1E2002L,
+ 1E2003L,
+ 1E2004L,
+ 1E2005L,
+ 1E2006L,
+ 1E2007L,
+ 1E2008L,
+ 1E2009L,
+ 1E2010L,
+ 1E2011L,
+ 1E2012L,
+ 1E2013L,
+ 1E2014L,
+ 1E2015L,
+ 1E2016L,
+ 1E2017L,
+ 1E2018L,
+ 1E2019L,
+ 1E2020L,
+ 1E2021L,
+ 1E2022L,
+ 1E2023L,
+ 1E2024L,
+ 1E2025L,
+ 1E2026L,
+ 1E2027L,
+ 1E2028L,
+ 1E2029L,
+ 1E2030L,
+ 1E2031L,
+ 1E2032L,
+ 1E2033L,
+ 1E2034L,
+ 1E2035L,
+ 1E2036L,
+ 1E2037L,
+ 1E2038L,
+ 1E2039L,
+ 1E2040L,
+ 1E2041L,
+ 1E2042L,
+ 1E2043L,
+ 1E2044L,
+ 1E2045L,
+ 1E2046L,
+ 1E2047L,
+ 1E2048L,
+ 1E2049L,
+ 1E2050L,
+ 1E2051L,
+ 1E2052L,
+ 1E2053L,
+ 1E2054L,
+ 1E2055L,
+ 1E2056L,
+ 1E2057L,
+ 1E2058L,
+ 1E2059L,
+ 1E2060L,
+ 1E2061L,
+ 1E2062L,
+ 1E2063L,
+ 1E2064L,
+ 1E2065L,
+ 1E2066L,
+ 1E2067L,
+ 1E2068L,
+ 1E2069L,
+ 1E2070L,
+ 1E2071L,
+ 1E2072L,
+ 1E2073L,
+ 1E2074L,
+ 1E2075L,
+ 1E2076L,
+ 1E2077L,
+ 1E2078L,
+ 1E2079L,
+ 1E2080L,
+ 1E2081L,
+ 1E2082L,
+ 1E2083L,
+ 1E2084L,
+ 1E2085L,
+ 1E2086L,
+ 1E2087L,
+ 1E2088L,
+ 1E2089L,
+ 1E2090L,
+ 1E2091L,
+ 1E2092L,
+ 1E2093L,
+ 1E2094L,
+ 1E2095L,
+ 1E2096L,
+ 1E2097L,
+ 1E2098L,
+ 1E2099L,
+ 1E2100L,
+ 1E2101L,
+ 1E2102L,
+ 1E2103L,
+ 1E2104L,
+ 1E2105L,
+ 1E2106L,
+ 1E2107L,
+ 1E2108L,
+ 1E2109L,
+ 1E2110L,
+ 1E2111L,
+ 1E2112L,
+ 1E2113L,
+ 1E2114L,
+ 1E2115L,
+ 1E2116L,
+ 1E2117L,
+ 1E2118L,
+ 1E2119L,
+ 1E2120L,
+ 1E2121L,
+ 1E2122L,
+ 1E2123L,
+ 1E2124L,
+ 1E2125L,
+ 1E2126L,
+ 1E2127L,
+ 1E2128L,
+ 1E2129L,
+ 1E2130L,
+ 1E2131L,
+ 1E2132L,
+ 1E2133L,
+ 1E2134L,
+ 1E2135L,
+ 1E2136L,
+ 1E2137L,
+ 1E2138L,
+ 1E2139L,
+ 1E2140L,
+ 1E2141L,
+ 1E2142L,
+ 1E2143L,
+ 1E2144L,
+ 1E2145L,
+ 1E2146L,
+ 1E2147L,
+ 1E2148L,
+ 1E2149L,
+ 1E2150L,
+ 1E2151L,
+ 1E2152L,
+ 1E2153L,
+ 1E2154L,
+ 1E2155L,
+ 1E2156L,
+ 1E2157L,
+ 1E2158L,
+ 1E2159L,
+ 1E2160L,
+ 1E2161L,
+ 1E2162L,
+ 1E2163L,
+ 1E2164L,
+ 1E2165L,
+ 1E2166L,
+ 1E2167L,
+ 1E2168L,
+ 1E2169L,
+ 1E2170L,
+ 1E2171L,
+ 1E2172L,
+ 1E2173L,
+ 1E2174L,
+ 1E2175L,
+ 1E2176L,
+ 1E2177L,
+ 1E2178L,
+ 1E2179L,
+ 1E2180L,
+ 1E2181L,
+ 1E2182L,
+ 1E2183L,
+ 1E2184L,
+ 1E2185L,
+ 1E2186L,
+ 1E2187L,
+ 1E2188L,
+ 1E2189L,
+ 1E2190L,
+ 1E2191L,
+ 1E2192L,
+ 1E2193L,
+ 1E2194L,
+ 1E2195L,
+ 1E2196L,
+ 1E2197L,
+ 1E2198L,
+ 1E2199L,
+ 1E2200L,
+ 1E2201L,
+ 1E2202L,
+ 1E2203L,
+ 1E2204L,
+ 1E2205L,
+ 1E2206L,
+ 1E2207L,
+ 1E2208L,
+ 1E2209L,
+ 1E2210L,
+ 1E2211L,
+ 1E2212L,
+ 1E2213L,
+ 1E2214L,
+ 1E2215L,
+ 1E2216L,
+ 1E2217L,
+ 1E2218L,
+ 1E2219L,
+ 1E2220L,
+ 1E2221L,
+ 1E2222L,
+ 1E2223L,
+ 1E2224L,
+ 1E2225L,
+ 1E2226L,
+ 1E2227L,
+ 1E2228L,
+ 1E2229L,
+ 1E2230L,
+ 1E2231L,
+ 1E2232L,
+ 1E2233L,
+ 1E2234L,
+ 1E2235L,
+ 1E2236L,
+ 1E2237L,
+ 1E2238L,
+ 1E2239L,
+ 1E2240L,
+ 1E2241L,
+ 1E2242L,
+ 1E2243L,
+ 1E2244L,
+ 1E2245L,
+ 1E2246L,
+ 1E2247L,
+ 1E2248L,
+ 1E2249L,
+ 1E2250L,
+ 1E2251L,
+ 1E2252L,
+ 1E2253L,
+ 1E2254L,
+ 1E2255L,
+ 1E2256L,
+ 1E2257L,
+ 1E2258L,
+ 1E2259L,
+ 1E2260L,
+ 1E2261L,
+ 1E2262L,
+ 1E2263L,
+ 1E2264L,
+ 1E2265L,
+ 1E2266L,
+ 1E2267L,
+ 1E2268L,
+ 1E2269L,
+ 1E2270L,
+ 1E2271L,
+ 1E2272L,
+ 1E2273L,
+ 1E2274L,
+ 1E2275L,
+ 1E2276L,
+ 1E2277L,
+ 1E2278L,
+ 1E2279L,
+ 1E2280L,
+ 1E2281L,
+ 1E2282L,
+ 1E2283L,
+ 1E2284L,
+ 1E2285L,
+ 1E2286L,
+ 1E2287L,
+ 1E2288L,
+ 1E2289L,
+ 1E2290L,
+ 1E2291L,
+ 1E2292L,
+ 1E2293L,
+ 1E2294L,
+ 1E2295L,
+ 1E2296L,
+ 1E2297L,
+ 1E2298L,
+ 1E2299L,
+ 1E2300L,
+ 1E2301L,
+ 1E2302L,
+ 1E2303L,
+ 1E2304L,
+ 1E2305L,
+ 1E2306L,
+ 1E2307L,
+ 1E2308L,
+ 1E2309L,
+ 1E2310L,
+ 1E2311L,
+ 1E2312L,
+ 1E2313L,
+ 1E2314L,
+ 1E2315L,
+ 1E2316L,
+ 1E2317L,
+ 1E2318L,
+ 1E2319L,
+ 1E2320L,
+ 1E2321L,
+ 1E2322L,
+ 1E2323L,
+ 1E2324L,
+ 1E2325L,
+ 1E2326L,
+ 1E2327L,
+ 1E2328L,
+ 1E2329L,
+ 1E2330L,
+ 1E2331L,
+ 1E2332L,
+ 1E2333L,
+ 1E2334L,
+ 1E2335L,
+ 1E2336L,
+ 1E2337L,
+ 1E2338L,
+ 1E2339L,
+ 1E2340L,
+ 1E2341L,
+ 1E2342L,
+ 1E2343L,
+ 1E2344L,
+ 1E2345L,
+ 1E2346L,
+ 1E2347L,
+ 1E2348L,
+ 1E2349L,
+ 1E2350L,
+ 1E2351L,
+ 1E2352L,
+ 1E2353L,
+ 1E2354L,
+ 1E2355L,
+ 1E2356L,
+ 1E2357L,
+ 1E2358L,
+ 1E2359L,
+ 1E2360L,
+ 1E2361L,
+ 1E2362L,
+ 1E2363L,
+ 1E2364L,
+ 1E2365L,
+ 1E2366L,
+ 1E2367L,
+ 1E2368L,
+ 1E2369L,
+ 1E2370L,
+ 1E2371L,
+ 1E2372L,
+ 1E2373L,
+ 1E2374L,
+ 1E2375L,
+ 1E2376L,
+ 1E2377L,
+ 1E2378L,
+ 1E2379L,
+ 1E2380L,
+ 1E2381L,
+ 1E2382L,
+ 1E2383L,
+ 1E2384L,
+ 1E2385L,
+ 1E2386L,
+ 1E2387L,
+ 1E2388L,
+ 1E2389L,
+ 1E2390L,
+ 1E2391L,
+ 1E2392L,
+ 1E2393L,
+ 1E2394L,
+ 1E2395L,
+ 1E2396L,
+ 1E2397L,
+ 1E2398L,
+ 1E2399L,
+ 1E2400L,
+ 1E2401L,
+ 1E2402L,
+ 1E2403L,
+ 1E2404L,
+ 1E2405L,
+ 1E2406L,
+ 1E2407L,
+ 1E2408L,
+ 1E2409L,
+ 1E2410L,
+ 1E2411L,
+ 1E2412L,
+ 1E2413L,
+ 1E2414L,
+ 1E2415L,
+ 1E2416L,
+ 1E2417L,
+ 1E2418L,
+ 1E2419L,
+ 1E2420L,
+ 1E2421L,
+ 1E2422L,
+ 1E2423L,
+ 1E2424L,
+ 1E2425L,
+ 1E2426L,
+ 1E2427L,
+ 1E2428L,
+ 1E2429L,
+ 1E2430L,
+ 1E2431L,
+ 1E2432L,
+ 1E2433L,
+ 1E2434L,
+ 1E2435L,
+ 1E2436L,
+ 1E2437L,
+ 1E2438L,
+ 1E2439L,
+ 1E2440L,
+ 1E2441L,
+ 1E2442L,
+ 1E2443L,
+ 1E2444L,
+ 1E2445L,
+ 1E2446L,
+ 1E2447L,
+ 1E2448L,
+ 1E2449L,
+ 1E2450L,
+ 1E2451L,
+ 1E2452L,
+ 1E2453L,
+ 1E2454L,
+ 1E2455L,
+ 1E2456L,
+ 1E2457L,
+ 1E2458L,
+ 1E2459L,
+ 1E2460L,
+ 1E2461L,
+ 1E2462L,
+ 1E2463L,
+ 1E2464L,
+ 1E2465L,
+ 1E2466L,
+ 1E2467L,
+ 1E2468L,
+ 1E2469L,
+ 1E2470L,
+ 1E2471L,
+ 1E2472L,
+ 1E2473L,
+ 1E2474L,
+ 1E2475L,
+ 1E2476L,
+ 1E2477L,
+ 1E2478L,
+ 1E2479L,
+ 1E2480L,
+ 1E2481L,
+ 1E2482L,
+ 1E2483L,
+ 1E2484L,
+ 1E2485L,
+ 1E2486L,
+ 1E2487L,
+ 1E2488L,
+ 1E2489L,
+ 1E2490L,
+ 1E2491L,
+ 1E2492L,
+ 1E2493L,
+ 1E2494L,
+ 1E2495L,
+ 1E2496L,
+ 1E2497L,
+ 1E2498L,
+ 1E2499L,
+ 1E2500L,
+ 1E2501L,
+ 1E2502L,
+ 1E2503L,
+ 1E2504L,
+ 1E2505L,
+ 1E2506L,
+ 1E2507L,
+ 1E2508L,
+ 1E2509L,
+ 1E2510L,
+ 1E2511L,
+ 1E2512L,
+ 1E2513L,
+ 1E2514L,
+ 1E2515L,
+ 1E2516L,
+ 1E2517L,
+ 1E2518L,
+ 1E2519L,
+ 1E2520L,
+ 1E2521L,
+ 1E2522L,
+ 1E2523L,
+ 1E2524L,
+ 1E2525L,
+ 1E2526L,
+ 1E2527L,
+ 1E2528L,
+ 1E2529L,
+ 1E2530L,
+ 1E2531L,
+ 1E2532L,
+ 1E2533L,
+ 1E2534L,
+ 1E2535L,
+ 1E2536L,
+ 1E2537L,
+ 1E2538L,
+ 1E2539L,
+ 1E2540L,
+ 1E2541L,
+ 1E2542L,
+ 1E2543L,
+ 1E2544L,
+ 1E2545L,
+ 1E2546L,
+ 1E2547L,
+ 1E2548L,
+ 1E2549L,
+ 1E2550L,
+ 1E2551L,
+ 1E2552L,
+ 1E2553L,
+ 1E2554L,
+ 1E2555L,
+ 1E2556L,
+ 1E2557L,
+ 1E2558L,
+ 1E2559L,
+ 1E2560L,
+ 1E2561L,
+ 1E2562L,
+ 1E2563L,
+ 1E2564L,
+ 1E2565L,
+ 1E2566L,
+ 1E2567L,
+ 1E2568L,
+ 1E2569L,
+ 1E2570L,
+ 1E2571L,
+ 1E2572L,
+ 1E2573L,
+ 1E2574L,
+ 1E2575L,
+ 1E2576L,
+ 1E2577L,
+ 1E2578L,
+ 1E2579L,
+ 1E2580L,
+ 1E2581L,
+ 1E2582L,
+ 1E2583L,
+ 1E2584L,
+ 1E2585L,
+ 1E2586L,
+ 1E2587L,
+ 1E2588L,
+ 1E2589L,
+ 1E2590L,
+ 1E2591L,
+ 1E2592L,
+ 1E2593L,
+ 1E2594L,
+ 1E2595L,
+ 1E2596L,
+ 1E2597L,
+ 1E2598L,
+ 1E2599L,
+ 1E2600L,
+ 1E2601L,
+ 1E2602L,
+ 1E2603L,
+ 1E2604L,
+ 1E2605L,
+ 1E2606L,
+ 1E2607L,
+ 1E2608L,
+ 1E2609L,
+ 1E2610L,
+ 1E2611L,
+ 1E2612L,
+ 1E2613L,
+ 1E2614L,
+ 1E2615L,
+ 1E2616L,
+ 1E2617L,
+ 1E2618L,
+ 1E2619L,
+ 1E2620L,
+ 1E2621L,
+ 1E2622L,
+ 1E2623L,
+ 1E2624L,
+ 1E2625L,
+ 1E2626L,
+ 1E2627L,
+ 1E2628L,
+ 1E2629L,
+ 1E2630L,
+ 1E2631L,
+ 1E2632L,
+ 1E2633L,
+ 1E2634L,
+ 1E2635L,
+ 1E2636L,
+ 1E2637L,
+ 1E2638L,
+ 1E2639L,
+ 1E2640L,
+ 1E2641L,
+ 1E2642L,
+ 1E2643L,
+ 1E2644L,
+ 1E2645L,
+ 1E2646L,
+ 1E2647L,
+ 1E2648L,
+ 1E2649L,
+ 1E2650L,
+ 1E2651L,
+ 1E2652L,
+ 1E2653L,
+ 1E2654L,
+ 1E2655L,
+ 1E2656L,
+ 1E2657L,
+ 1E2658L,
+ 1E2659L,
+ 1E2660L,
+ 1E2661L,
+ 1E2662L,
+ 1E2663L,
+ 1E2664L,
+ 1E2665L,
+ 1E2666L,
+ 1E2667L,
+ 1E2668L,
+ 1E2669L,
+ 1E2670L,
+ 1E2671L,
+ 1E2672L,
+ 1E2673L,
+ 1E2674L,
+ 1E2675L,
+ 1E2676L,
+ 1E2677L,
+ 1E2678L,
+ 1E2679L,
+ 1E2680L,
+ 1E2681L,
+ 1E2682L,
+ 1E2683L,
+ 1E2684L,
+ 1E2685L,
+ 1E2686L,
+ 1E2687L,
+ 1E2688L,
+ 1E2689L,
+ 1E2690L,
+ 1E2691L,
+ 1E2692L,
+ 1E2693L,
+ 1E2694L,
+ 1E2695L,
+ 1E2696L,
+ 1E2697L,
+ 1E2698L,
+ 1E2699L,
+ 1E2700L,
+ 1E2701L,
+ 1E2702L,
+ 1E2703L,
+ 1E2704L,
+ 1E2705L,
+ 1E2706L,
+ 1E2707L,
+ 1E2708L,
+ 1E2709L,
+ 1E2710L,
+ 1E2711L,
+ 1E2712L,
+ 1E2713L,
+ 1E2714L,
+ 1E2715L,
+ 1E2716L,
+ 1E2717L,
+ 1E2718L,
+ 1E2719L,
+ 1E2720L,
+ 1E2721L,
+ 1E2722L,
+ 1E2723L,
+ 1E2724L,
+ 1E2725L,
+ 1E2726L,
+ 1E2727L,
+ 1E2728L,
+ 1E2729L,
+ 1E2730L,
+ 1E2731L,
+ 1E2732L,
+ 1E2733L,
+ 1E2734L,
+ 1E2735L,
+ 1E2736L,
+ 1E2737L,
+ 1E2738L,
+ 1E2739L,
+ 1E2740L,
+ 1E2741L,
+ 1E2742L,
+ 1E2743L,
+ 1E2744L,
+ 1E2745L,
+ 1E2746L,
+ 1E2747L,
+ 1E2748L,
+ 1E2749L,
+ 1E2750L,
+ 1E2751L,
+ 1E2752L,
+ 1E2753L,
+ 1E2754L,
+ 1E2755L,
+ 1E2756L,
+ 1E2757L,
+ 1E2758L,
+ 1E2759L,
+ 1E2760L,
+ 1E2761L,
+ 1E2762L,
+ 1E2763L,
+ 1E2764L,
+ 1E2765L,
+ 1E2766L,
+ 1E2767L,
+ 1E2768L,
+ 1E2769L,
+ 1E2770L,
+ 1E2771L,
+ 1E2772L,
+ 1E2773L,
+ 1E2774L,
+ 1E2775L,
+ 1E2776L,
+ 1E2777L,
+ 1E2778L,
+ 1E2779L,
+ 1E2780L,
+ 1E2781L,
+ 1E2782L,
+ 1E2783L,
+ 1E2784L,
+ 1E2785L,
+ 1E2786L,
+ 1E2787L,
+ 1E2788L,
+ 1E2789L,
+ 1E2790L,
+ 1E2791L,
+ 1E2792L,
+ 1E2793L,
+ 1E2794L,
+ 1E2795L,
+ 1E2796L,
+ 1E2797L,
+ 1E2798L,
+ 1E2799L,
+ 1E2800L,
+ 1E2801L,
+ 1E2802L,
+ 1E2803L,
+ 1E2804L,
+ 1E2805L,
+ 1E2806L,
+ 1E2807L,
+ 1E2808L,
+ 1E2809L,
+ 1E2810L,
+ 1E2811L,
+ 1E2812L,
+ 1E2813L,
+ 1E2814L,
+ 1E2815L,
+ 1E2816L,
+ 1E2817L,
+ 1E2818L,
+ 1E2819L,
+ 1E2820L,
+ 1E2821L,
+ 1E2822L,
+ 1E2823L,
+ 1E2824L,
+ 1E2825L,
+ 1E2826L,
+ 1E2827L,
+ 1E2828L,
+ 1E2829L,
+ 1E2830L,
+ 1E2831L,
+ 1E2832L,
+ 1E2833L,
+ 1E2834L,
+ 1E2835L,
+ 1E2836L,
+ 1E2837L,
+ 1E2838L,
+ 1E2839L,
+ 1E2840L,
+ 1E2841L,
+ 1E2842L,
+ 1E2843L,
+ 1E2844L,
+ 1E2845L,
+ 1E2846L,
+ 1E2847L,
+ 1E2848L,
+ 1E2849L,
+ 1E2850L,
+ 1E2851L,
+ 1E2852L,
+ 1E2853L,
+ 1E2854L,
+ 1E2855L,
+ 1E2856L,
+ 1E2857L,
+ 1E2858L,
+ 1E2859L,
+ 1E2860L,
+ 1E2861L,
+ 1E2862L,
+ 1E2863L,
+ 1E2864L,
+ 1E2865L,
+ 1E2866L,
+ 1E2867L,
+ 1E2868L,
+ 1E2869L,
+ 1E2870L,
+ 1E2871L,
+ 1E2872L,
+ 1E2873L,
+ 1E2874L,
+ 1E2875L,
+ 1E2876L,
+ 1E2877L,
+ 1E2878L,
+ 1E2879L,
+ 1E2880L,
+ 1E2881L,
+ 1E2882L,
+ 1E2883L,
+ 1E2884L,
+ 1E2885L,
+ 1E2886L,
+ 1E2887L,
+ 1E2888L,
+ 1E2889L,
+ 1E2890L,
+ 1E2891L,
+ 1E2892L,
+ 1E2893L,
+ 1E2894L,
+ 1E2895L,
+ 1E2896L,
+ 1E2897L,
+ 1E2898L,
+ 1E2899L,
+ 1E2900L,
+ 1E2901L,
+ 1E2902L,
+ 1E2903L,
+ 1E2904L,
+ 1E2905L,
+ 1E2906L,
+ 1E2907L,
+ 1E2908L,
+ 1E2909L,
+ 1E2910L,
+ 1E2911L,
+ 1E2912L,
+ 1E2913L,
+ 1E2914L,
+ 1E2915L,
+ 1E2916L,
+ 1E2917L,
+ 1E2918L,
+ 1E2919L,
+ 1E2920L,
+ 1E2921L,
+ 1E2922L,
+ 1E2923L,
+ 1E2924L,
+ 1E2925L,
+ 1E2926L,
+ 1E2927L,
+ 1E2928L,
+ 1E2929L,
+ 1E2930L,
+ 1E2931L,
+ 1E2932L,
+ 1E2933L,
+ 1E2934L,
+ 1E2935L,
+ 1E2936L,
+ 1E2937L,
+ 1E2938L,
+ 1E2939L,
+ 1E2940L,
+ 1E2941L,
+ 1E2942L,
+ 1E2943L,
+ 1E2944L,
+ 1E2945L,
+ 1E2946L,
+ 1E2947L,
+ 1E2948L,
+ 1E2949L,
+ 1E2950L,
+ 1E2951L,
+ 1E2952L,
+ 1E2953L,
+ 1E2954L,
+ 1E2955L,
+ 1E2956L,
+ 1E2957L,
+ 1E2958L,
+ 1E2959L,
+ 1E2960L,
+ 1E2961L,
+ 1E2962L,
+ 1E2963L,
+ 1E2964L,
+ 1E2965L,
+ 1E2966L,
+ 1E2967L,
+ 1E2968L,
+ 1E2969L,
+ 1E2970L,
+ 1E2971L,
+ 1E2972L,
+ 1E2973L,
+ 1E2974L,
+ 1E2975L,
+ 1E2976L,
+ 1E2977L,
+ 1E2978L,
+ 1E2979L,
+ 1E2980L,
+ 1E2981L,
+ 1E2982L,
+ 1E2983L,
+ 1E2984L,
+ 1E2985L,
+ 1E2986L,
+ 1E2987L,
+ 1E2988L,
+ 1E2989L,
+ 1E2990L,
+ 1E2991L,
+ 1E2992L,
+ 1E2993L,
+ 1E2994L,
+ 1E2995L,
+ 1E2996L,
+ 1E2997L,
+ 1E2998L,
+ 1E2999L,
+ 1E3000L,
+ 1E3001L,
+ 1E3002L,
+ 1E3003L,
+ 1E3004L,
+ 1E3005L,
+ 1E3006L,
+ 1E3007L,
+ 1E3008L,
+ 1E3009L,
+ 1E3010L,
+ 1E3011L,
+ 1E3012L,
+ 1E3013L,
+ 1E3014L,
+ 1E3015L,
+ 1E3016L,
+ 1E3017L,
+ 1E3018L,
+ 1E3019L,
+ 1E3020L,
+ 1E3021L,
+ 1E3022L,
+ 1E3023L,
+ 1E3024L,
+ 1E3025L,
+ 1E3026L,
+ 1E3027L,
+ 1E3028L,
+ 1E3029L,
+ 1E3030L,
+ 1E3031L,
+ 1E3032L,
+ 1E3033L,
+ 1E3034L,
+ 1E3035L,
+ 1E3036L,
+ 1E3037L,
+ 1E3038L,
+ 1E3039L,
+ 1E3040L,
+ 1E3041L,
+ 1E3042L,
+ 1E3043L,
+ 1E3044L,
+ 1E3045L,
+ 1E3046L,
+ 1E3047L,
+ 1E3048L,
+ 1E3049L,
+ 1E3050L,
+ 1E3051L,
+ 1E3052L,
+ 1E3053L,
+ 1E3054L,
+ 1E3055L,
+ 1E3056L,
+ 1E3057L,
+ 1E3058L,
+ 1E3059L,
+ 1E3060L,
+ 1E3061L,
+ 1E3062L,
+ 1E3063L,
+ 1E3064L,
+ 1E3065L,
+ 1E3066L,
+ 1E3067L,
+ 1E3068L,
+ 1E3069L,
+ 1E3070L,
+ 1E3071L,
+ 1E3072L,
+ 1E3073L,
+ 1E3074L,
+ 1E3075L,
+ 1E3076L,
+ 1E3077L,
+ 1E3078L,
+ 1E3079L,
+ 1E3080L,
+ 1E3081L,
+ 1E3082L,
+ 1E3083L,
+ 1E3084L,
+ 1E3085L,
+ 1E3086L,
+ 1E3087L,
+ 1E3088L,
+ 1E3089L,
+ 1E3090L,
+ 1E3091L,
+ 1E3092L,
+ 1E3093L,
+ 1E3094L,
+ 1E3095L,
+ 1E3096L,
+ 1E3097L,
+ 1E3098L,
+ 1E3099L,
+ 1E3100L,
+ 1E3101L,
+ 1E3102L,
+ 1E3103L,
+ 1E3104L,
+ 1E3105L,
+ 1E3106L,
+ 1E3107L,
+ 1E3108L,
+ 1E3109L,
+ 1E3110L,
+ 1E3111L,
+ 1E3112L,
+ 1E3113L,
+ 1E3114L,
+ 1E3115L,
+ 1E3116L,
+ 1E3117L,
+ 1E3118L,
+ 1E3119L,
+ 1E3120L,
+ 1E3121L,
+ 1E3122L,
+ 1E3123L,
+ 1E3124L,
+ 1E3125L,
+ 1E3126L,
+ 1E3127L,
+ 1E3128L,
+ 1E3129L,
+ 1E3130L,
+ 1E3131L,
+ 1E3132L,
+ 1E3133L,
+ 1E3134L,
+ 1E3135L,
+ 1E3136L,
+ 1E3137L,
+ 1E3138L,
+ 1E3139L,
+ 1E3140L,
+ 1E3141L,
+ 1E3142L,
+ 1E3143L,
+ 1E3144L,
+ 1E3145L,
+ 1E3146L,
+ 1E3147L,
+ 1E3148L,
+ 1E3149L,
+ 1E3150L,
+ 1E3151L,
+ 1E3152L,
+ 1E3153L,
+ 1E3154L,
+ 1E3155L,
+ 1E3156L,
+ 1E3157L,
+ 1E3158L,
+ 1E3159L,
+ 1E3160L,
+ 1E3161L,
+ 1E3162L,
+ 1E3163L,
+ 1E3164L,
+ 1E3165L,
+ 1E3166L,
+ 1E3167L,
+ 1E3168L,
+ 1E3169L,
+ 1E3170L,
+ 1E3171L,
+ 1E3172L,
+ 1E3173L,
+ 1E3174L,
+ 1E3175L,
+ 1E3176L,
+ 1E3177L,
+ 1E3178L,
+ 1E3179L,
+ 1E3180L,
+ 1E3181L,
+ 1E3182L,
+ 1E3183L,
+ 1E3184L,
+ 1E3185L,
+ 1E3186L,
+ 1E3187L,
+ 1E3188L,
+ 1E3189L,
+ 1E3190L,
+ 1E3191L,
+ 1E3192L,
+ 1E3193L,
+ 1E3194L,
+ 1E3195L,
+ 1E3196L,
+ 1E3197L,
+ 1E3198L,
+ 1E3199L,
+ 1E3200L,
+ 1E3201L,
+ 1E3202L,
+ 1E3203L,
+ 1E3204L,
+ 1E3205L,
+ 1E3206L,
+ 1E3207L,
+ 1E3208L,
+ 1E3209L,
+ 1E3210L,
+ 1E3211L,
+ 1E3212L,
+ 1E3213L,
+ 1E3214L,
+ 1E3215L,
+ 1E3216L,
+ 1E3217L,
+ 1E3218L,
+ 1E3219L,
+ 1E3220L,
+ 1E3221L,
+ 1E3222L,
+ 1E3223L,
+ 1E3224L,
+ 1E3225L,
+ 1E3226L,
+ 1E3227L,
+ 1E3228L,
+ 1E3229L,
+ 1E3230L,
+ 1E3231L,
+ 1E3232L,
+ 1E3233L,
+ 1E3234L,
+ 1E3235L,
+ 1E3236L,
+ 1E3237L,
+ 1E3238L,
+ 1E3239L,
+ 1E3240L,
+ 1E3241L,
+ 1E3242L,
+ 1E3243L,
+ 1E3244L,
+ 1E3245L,
+ 1E3246L,
+ 1E3247L,
+ 1E3248L,
+ 1E3249L,
+ 1E3250L,
+ 1E3251L,
+ 1E3252L,
+ 1E3253L,
+ 1E3254L,
+ 1E3255L,
+ 1E3256L,
+ 1E3257L,
+ 1E3258L,
+ 1E3259L,
+ 1E3260L,
+ 1E3261L,
+ 1E3262L,
+ 1E3263L,
+ 1E3264L,
+ 1E3265L,
+ 1E3266L,
+ 1E3267L,
+ 1E3268L,
+ 1E3269L,
+ 1E3270L,
+ 1E3271L,
+ 1E3272L,
+ 1E3273L,
+ 1E3274L,
+ 1E3275L,
+ 1E3276L,
+ 1E3277L,
+ 1E3278L,
+ 1E3279L,
+ 1E3280L,
+ 1E3281L,
+ 1E3282L,
+ 1E3283L,
+ 1E3284L,
+ 1E3285L,
+ 1E3286L,
+ 1E3287L,
+ 1E3288L,
+ 1E3289L,
+ 1E3290L,
+ 1E3291L,
+ 1E3292L,
+ 1E3293L,
+ 1E3294L,
+ 1E3295L,
+ 1E3296L,
+ 1E3297L,
+ 1E3298L,
+ 1E3299L,
+ 1E3300L,
+ 1E3301L,
+ 1E3302L,
+ 1E3303L,
+ 1E3304L,
+ 1E3305L,
+ 1E3306L,
+ 1E3307L,
+ 1E3308L,
+ 1E3309L,
+ 1E3310L,
+ 1E3311L,
+ 1E3312L,
+ 1E3313L,
+ 1E3314L,
+ 1E3315L,
+ 1E3316L,
+ 1E3317L,
+ 1E3318L,
+ 1E3319L,
+ 1E3320L,
+ 1E3321L,
+ 1E3322L,
+ 1E3323L,
+ 1E3324L,
+ 1E3325L,
+ 1E3326L,
+ 1E3327L,
+ 1E3328L,
+ 1E3329L,
+ 1E3330L,
+ 1E3331L,
+ 1E3332L,
+ 1E3333L,
+ 1E3334L,
+ 1E3335L,
+ 1E3336L,
+ 1E3337L,
+ 1E3338L,
+ 1E3339L,
+ 1E3340L,
+ 1E3341L,
+ 1E3342L,
+ 1E3343L,
+ 1E3344L,
+ 1E3345L,
+ 1E3346L,
+ 1E3347L,
+ 1E3348L,
+ 1E3349L,
+ 1E3350L,
+ 1E3351L,
+ 1E3352L,
+ 1E3353L,
+ 1E3354L,
+ 1E3355L,
+ 1E3356L,
+ 1E3357L,
+ 1E3358L,
+ 1E3359L,
+ 1E3360L,
+ 1E3361L,
+ 1E3362L,
+ 1E3363L,
+ 1E3364L,
+ 1E3365L,
+ 1E3366L,
+ 1E3367L,
+ 1E3368L,
+ 1E3369L,
+ 1E3370L,
+ 1E3371L,
+ 1E3372L,
+ 1E3373L,
+ 1E3374L,
+ 1E3375L,
+ 1E3376L,
+ 1E3377L,
+ 1E3378L,
+ 1E3379L,
+ 1E3380L,
+ 1E3381L,
+ 1E3382L,
+ 1E3383L,
+ 1E3384L,
+ 1E3385L,
+ 1E3386L,
+ 1E3387L,
+ 1E3388L,
+ 1E3389L,
+ 1E3390L,
+ 1E3391L,
+ 1E3392L,
+ 1E3393L,
+ 1E3394L,
+ 1E3395L,
+ 1E3396L,
+ 1E3397L,
+ 1E3398L,
+ 1E3399L,
+ 1E3400L,
+ 1E3401L,
+ 1E3402L,
+ 1E3403L,
+ 1E3404L,
+ 1E3405L,
+ 1E3406L,
+ 1E3407L,
+ 1E3408L,
+ 1E3409L,
+ 1E3410L,
+ 1E3411L,
+ 1E3412L,
+ 1E3413L,
+ 1E3414L,
+ 1E3415L,
+ 1E3416L,
+ 1E3417L,
+ 1E3418L,
+ 1E3419L,
+ 1E3420L,
+ 1E3421L,
+ 1E3422L,
+ 1E3423L,
+ 1E3424L,
+ 1E3425L,
+ 1E3426L,
+ 1E3427L,
+ 1E3428L,
+ 1E3429L,
+ 1E3430L,
+ 1E3431L,
+ 1E3432L,
+ 1E3433L,
+ 1E3434L,
+ 1E3435L,
+ 1E3436L,
+ 1E3437L,
+ 1E3438L,
+ 1E3439L,
+ 1E3440L,
+ 1E3441L,
+ 1E3442L,
+ 1E3443L,
+ 1E3444L,
+ 1E3445L,
+ 1E3446L,
+ 1E3447L,
+ 1E3448L,
+ 1E3449L,
+ 1E3450L,
+ 1E3451L,
+ 1E3452L,
+ 1E3453L,
+ 1E3454L,
+ 1E3455L,
+ 1E3456L,
+ 1E3457L,
+ 1E3458L,
+ 1E3459L,
+ 1E3460L,
+ 1E3461L,
+ 1E3462L,
+ 1E3463L,
+ 1E3464L,
+ 1E3465L,
+ 1E3466L,
+ 1E3467L,
+ 1E3468L,
+ 1E3469L,
+ 1E3470L,
+ 1E3471L,
+ 1E3472L,
+ 1E3473L,
+ 1E3474L,
+ 1E3475L,
+ 1E3476L,
+ 1E3477L,
+ 1E3478L,
+ 1E3479L,
+ 1E3480L,
+ 1E3481L,
+ 1E3482L,
+ 1E3483L,
+ 1E3484L,
+ 1E3485L,
+ 1E3486L,
+ 1E3487L,
+ 1E3488L,
+ 1E3489L,
+ 1E3490L,
+ 1E3491L,
+ 1E3492L,
+ 1E3493L,
+ 1E3494L,
+ 1E3495L,
+ 1E3496L,
+ 1E3497L,
+ 1E3498L,
+ 1E3499L,
+ 1E3500L,
+ 1E3501L,
+ 1E3502L,
+ 1E3503L,
+ 1E3504L,
+ 1E3505L,
+ 1E3506L,
+ 1E3507L,
+ 1E3508L,
+ 1E3509L,
+ 1E3510L,
+ 1E3511L,
+ 1E3512L,
+ 1E3513L,
+ 1E3514L,
+ 1E3515L,
+ 1E3516L,
+ 1E3517L,
+ 1E3518L,
+ 1E3519L,
+ 1E3520L,
+ 1E3521L,
+ 1E3522L,
+ 1E3523L,
+ 1E3524L,
+ 1E3525L,
+ 1E3526L,
+ 1E3527L,
+ 1E3528L,
+ 1E3529L,
+ 1E3530L,
+ 1E3531L,
+ 1E3532L,
+ 1E3533L,
+ 1E3534L,
+ 1E3535L,
+ 1E3536L,
+ 1E3537L,
+ 1E3538L,
+ 1E3539L,
+ 1E3540L,
+ 1E3541L,
+ 1E3542L,
+ 1E3543L,
+ 1E3544L,
+ 1E3545L,
+ 1E3546L,
+ 1E3547L,
+ 1E3548L,
+ 1E3549L,
+ 1E3550L,
+ 1E3551L,
+ 1E3552L,
+ 1E3553L,
+ 1E3554L,
+ 1E3555L,
+ 1E3556L,
+ 1E3557L,
+ 1E3558L,
+ 1E3559L,
+ 1E3560L,
+ 1E3561L,
+ 1E3562L,
+ 1E3563L,
+ 1E3564L,
+ 1E3565L,
+ 1E3566L,
+ 1E3567L,
+ 1E3568L,
+ 1E3569L,
+ 1E3570L,
+ 1E3571L,
+ 1E3572L,
+ 1E3573L,
+ 1E3574L,
+ 1E3575L,
+ 1E3576L,
+ 1E3577L,
+ 1E3578L,
+ 1E3579L,
+ 1E3580L,
+ 1E3581L,
+ 1E3582L,
+ 1E3583L,
+ 1E3584L,
+ 1E3585L,
+ 1E3586L,
+ 1E3587L,
+ 1E3588L,
+ 1E3589L,
+ 1E3590L,
+ 1E3591L,
+ 1E3592L,
+ 1E3593L,
+ 1E3594L,
+ 1E3595L,
+ 1E3596L,
+ 1E3597L,
+ 1E3598L,
+ 1E3599L,
+ 1E3600L,
+ 1E3601L,
+ 1E3602L,
+ 1E3603L,
+ 1E3604L,
+ 1E3605L,
+ 1E3606L,
+ 1E3607L,
+ 1E3608L,
+ 1E3609L,
+ 1E3610L,
+ 1E3611L,
+ 1E3612L,
+ 1E3613L,
+ 1E3614L,
+ 1E3615L,
+ 1E3616L,
+ 1E3617L,
+ 1E3618L,
+ 1E3619L,
+ 1E3620L,
+ 1E3621L,
+ 1E3622L,
+ 1E3623L,
+ 1E3624L,
+ 1E3625L,
+ 1E3626L,
+ 1E3627L,
+ 1E3628L,
+ 1E3629L,
+ 1E3630L,
+ 1E3631L,
+ 1E3632L,
+ 1E3633L,
+ 1E3634L,
+ 1E3635L,
+ 1E3636L,
+ 1E3637L,
+ 1E3638L,
+ 1E3639L,
+ 1E3640L,
+ 1E3641L,
+ 1E3642L,
+ 1E3643L,
+ 1E3644L,
+ 1E3645L,
+ 1E3646L,
+ 1E3647L,
+ 1E3648L,
+ 1E3649L,
+ 1E3650L,
+ 1E3651L,
+ 1E3652L,
+ 1E3653L,
+ 1E3654L,
+ 1E3655L,
+ 1E3656L,
+ 1E3657L,
+ 1E3658L,
+ 1E3659L,
+ 1E3660L,
+ 1E3661L,
+ 1E3662L,
+ 1E3663L,
+ 1E3664L,
+ 1E3665L,
+ 1E3666L,
+ 1E3667L,
+ 1E3668L,
+ 1E3669L,
+ 1E3670L,
+ 1E3671L,
+ 1E3672L,
+ 1E3673L,
+ 1E3674L,
+ 1E3675L,
+ 1E3676L,
+ 1E3677L,
+ 1E3678L,
+ 1E3679L,
+ 1E3680L,
+ 1E3681L,
+ 1E3682L,
+ 1E3683L,
+ 1E3684L,
+ 1E3685L,
+ 1E3686L,
+ 1E3687L,
+ 1E3688L,
+ 1E3689L,
+ 1E3690L,
+ 1E3691L,
+ 1E3692L,
+ 1E3693L,
+ 1E3694L,
+ 1E3695L,
+ 1E3696L,
+ 1E3697L,
+ 1E3698L,
+ 1E3699L,
+ 1E3700L,
+ 1E3701L,
+ 1E3702L,
+ 1E3703L,
+ 1E3704L,
+ 1E3705L,
+ 1E3706L,
+ 1E3707L,
+ 1E3708L,
+ 1E3709L,
+ 1E3710L,
+ 1E3711L,
+ 1E3712L,
+ 1E3713L,
+ 1E3714L,
+ 1E3715L,
+ 1E3716L,
+ 1E3717L,
+ 1E3718L,
+ 1E3719L,
+ 1E3720L,
+ 1E3721L,
+ 1E3722L,
+ 1E3723L,
+ 1E3724L,
+ 1E3725L,
+ 1E3726L,
+ 1E3727L,
+ 1E3728L,
+ 1E3729L,
+ 1E3730L,
+ 1E3731L,
+ 1E3732L,
+ 1E3733L,
+ 1E3734L,
+ 1E3735L,
+ 1E3736L,
+ 1E3737L,
+ 1E3738L,
+ 1E3739L,
+ 1E3740L,
+ 1E3741L,
+ 1E3742L,
+ 1E3743L,
+ 1E3744L,
+ 1E3745L,
+ 1E3746L,
+ 1E3747L,
+ 1E3748L,
+ 1E3749L,
+ 1E3750L,
+ 1E3751L,
+ 1E3752L,
+ 1E3753L,
+ 1E3754L,
+ 1E3755L,
+ 1E3756L,
+ 1E3757L,
+ 1E3758L,
+ 1E3759L,
+ 1E3760L,
+ 1E3761L,
+ 1E3762L,
+ 1E3763L,
+ 1E3764L,
+ 1E3765L,
+ 1E3766L,
+ 1E3767L,
+ 1E3768L,
+ 1E3769L,
+ 1E3770L,
+ 1E3771L,
+ 1E3772L,
+ 1E3773L,
+ 1E3774L,
+ 1E3775L,
+ 1E3776L,
+ 1E3777L,
+ 1E3778L,
+ 1E3779L,
+ 1E3780L,
+ 1E3781L,
+ 1E3782L,
+ 1E3783L,
+ 1E3784L,
+ 1E3785L,
+ 1E3786L,
+ 1E3787L,
+ 1E3788L,
+ 1E3789L,
+ 1E3790L,
+ 1E3791L,
+ 1E3792L,
+ 1E3793L,
+ 1E3794L,
+ 1E3795L,
+ 1E3796L,
+ 1E3797L,
+ 1E3798L,
+ 1E3799L,
+ 1E3800L,
+ 1E3801L,
+ 1E3802L,
+ 1E3803L,
+ 1E3804L,
+ 1E3805L,
+ 1E3806L,
+ 1E3807L,
+ 1E3808L,
+ 1E3809L,
+ 1E3810L,
+ 1E3811L,
+ 1E3812L,
+ 1E3813L,
+ 1E3814L,
+ 1E3815L,
+ 1E3816L,
+ 1E3817L,
+ 1E3818L,
+ 1E3819L,
+ 1E3820L,
+ 1E3821L,
+ 1E3822L,
+ 1E3823L,
+ 1E3824L,
+ 1E3825L,
+ 1E3826L,
+ 1E3827L,
+ 1E3828L,
+ 1E3829L,
+ 1E3830L,
+ 1E3831L,
+ 1E3832L,
+ 1E3833L,
+ 1E3834L,
+ 1E3835L,
+ 1E3836L,
+ 1E3837L,
+ 1E3838L,
+ 1E3839L,
+ 1E3840L,
+ 1E3841L,
+ 1E3842L,
+ 1E3843L,
+ 1E3844L,
+ 1E3845L,
+ 1E3846L,
+ 1E3847L,
+ 1E3848L,
+ 1E3849L,
+ 1E3850L,
+ 1E3851L,
+ 1E3852L,
+ 1E3853L,
+ 1E3854L,
+ 1E3855L,
+ 1E3856L,
+ 1E3857L,
+ 1E3858L,
+ 1E3859L,
+ 1E3860L,
+ 1E3861L,
+ 1E3862L,
+ 1E3863L,
+ 1E3864L,
+ 1E3865L,
+ 1E3866L,
+ 1E3867L,
+ 1E3868L,
+ 1E3869L,
+ 1E3870L,
+ 1E3871L,
+ 1E3872L,
+ 1E3873L,
+ 1E3874L,
+ 1E3875L,
+ 1E3876L,
+ 1E3877L,
+ 1E3878L,
+ 1E3879L,
+ 1E3880L,
+ 1E3881L,
+ 1E3882L,
+ 1E3883L,
+ 1E3884L,
+ 1E3885L,
+ 1E3886L,
+ 1E3887L,
+ 1E3888L,
+ 1E3889L,
+ 1E3890L,
+ 1E3891L,
+ 1E3892L,
+ 1E3893L,
+ 1E3894L,
+ 1E3895L,
+ 1E3896L,
+ 1E3897L,
+ 1E3898L,
+ 1E3899L,
+ 1E3900L,
+ 1E3901L,
+ 1E3902L,
+ 1E3903L,
+ 1E3904L,
+ 1E3905L,
+ 1E3906L,
+ 1E3907L,
+ 1E3908L,
+ 1E3909L,
+ 1E3910L,
+ 1E3911L,
+ 1E3912L,
+ 1E3913L,
+ 1E3914L,
+ 1E3915L,
+ 1E3916L,
+ 1E3917L,
+ 1E3918L,
+ 1E3919L,
+ 1E3920L,
+ 1E3921L,
+ 1E3922L,
+ 1E3923L,
+ 1E3924L,
+ 1E3925L,
+ 1E3926L,
+ 1E3927L,
+ 1E3928L,
+ 1E3929L,
+ 1E3930L,
+ 1E3931L,
+ 1E3932L,
+ 1E3933L,
+ 1E3934L,
+ 1E3935L,
+ 1E3936L,
+ 1E3937L,
+ 1E3938L,
+ 1E3939L,
+ 1E3940L,
+ 1E3941L,
+ 1E3942L,
+ 1E3943L,
+ 1E3944L,
+ 1E3945L,
+ 1E3946L,
+ 1E3947L,
+ 1E3948L,
+ 1E3949L,
+ 1E3950L,
+ 1E3951L,
+ 1E3952L,
+ 1E3953L,
+ 1E3954L,
+ 1E3955L,
+ 1E3956L,
+ 1E3957L,
+ 1E3958L,
+ 1E3959L,
+ 1E3960L,
+ 1E3961L,
+ 1E3962L,
+ 1E3963L,
+ 1E3964L,
+ 1E3965L,
+ 1E3966L,
+ 1E3967L,
+ 1E3968L,
+ 1E3969L,
+ 1E3970L,
+ 1E3971L,
+ 1E3972L,
+ 1E3973L,
+ 1E3974L,
+ 1E3975L,
+ 1E3976L,
+ 1E3977L,
+ 1E3978L,
+ 1E3979L,
+ 1E3980L,
+ 1E3981L,
+ 1E3982L,
+ 1E3983L,
+ 1E3984L,
+ 1E3985L,
+ 1E3986L,
+ 1E3987L,
+ 1E3988L,
+ 1E3989L,
+ 1E3990L,
+ 1E3991L,
+ 1E3992L,
+ 1E3993L,
+ 1E3994L,
+ 1E3995L,
+ 1E3996L,
+ 1E3997L,
+ 1E3998L,
+ 1E3999L,
+ 1E4000L,
+ 1E4001L,
+ 1E4002L,
+ 1E4003L,
+ 1E4004L,
+ 1E4005L,
+ 1E4006L,
+ 1E4007L,
+ 1E4008L,
+ 1E4009L,
+ 1E4010L,
+ 1E4011L,
+ 1E4012L,
+ 1E4013L,
+ 1E4014L,
+ 1E4015L,
+ 1E4016L,
+ 1E4017L,
+ 1E4018L,
+ 1E4019L,
+ 1E4020L,
+ 1E4021L,
+ 1E4022L,
+ 1E4023L,
+ 1E4024L,
+ 1E4025L,
+ 1E4026L,
+ 1E4027L,
+ 1E4028L,
+ 1E4029L,
+ 1E4030L,
+ 1E4031L,
+ 1E4032L,
+ 1E4033L,
+ 1E4034L,
+ 1E4035L,
+ 1E4036L,
+ 1E4037L,
+ 1E4038L,
+ 1E4039L,
+ 1E4040L,
+ 1E4041L,
+ 1E4042L,
+ 1E4043L,
+ 1E4044L,
+ 1E4045L,
+ 1E4046L,
+ 1E4047L,
+ 1E4048L,
+ 1E4049L,
+ 1E4050L,
+ 1E4051L,
+ 1E4052L,
+ 1E4053L,
+ 1E4054L,
+ 1E4055L,
+ 1E4056L,
+ 1E4057L,
+ 1E4058L,
+ 1E4059L,
+ 1E4060L,
+ 1E4061L,
+ 1E4062L,
+ 1E4063L,
+ 1E4064L,
+ 1E4065L,
+ 1E4066L,
+ 1E4067L,
+ 1E4068L,
+ 1E4069L,
+ 1E4070L,
+ 1E4071L,
+ 1E4072L,
+ 1E4073L,
+ 1E4074L,
+ 1E4075L,
+ 1E4076L,
+ 1E4077L,
+ 1E4078L,
+ 1E4079L,
+ 1E4080L,
+ 1E4081L,
+ 1E4082L,
+ 1E4083L,
+ 1E4084L,
+ 1E4085L,
+ 1E4086L,
+ 1E4087L,
+ 1E4088L,
+ 1E4089L,
+ 1E4090L,
+ 1E4091L,
+ 1E4092L,
+ 1E4093L,
+ 1E4094L,
+ 1E4095L,
+ 1E4096L,
+ 1E4097L,
+ 1E4098L,
+ 1E4099L,
+ 1E4100L,
+ 1E4101L,
+ 1E4102L,
+ 1E4103L,
+ 1E4104L,
+ 1E4105L,
+ 1E4106L,
+ 1E4107L,
+ 1E4108L,
+ 1E4109L,
+ 1E4110L,
+ 1E4111L,
+ 1E4112L,
+ 1E4113L,
+ 1E4114L,
+ 1E4115L,
+ 1E4116L,
+ 1E4117L,
+ 1E4118L,
+ 1E4119L,
+ 1E4120L,
+ 1E4121L,
+ 1E4122L,
+ 1E4123L,
+ 1E4124L,
+ 1E4125L,
+ 1E4126L,
+ 1E4127L,
+ 1E4128L,
+ 1E4129L,
+ 1E4130L,
+ 1E4131L,
+ 1E4132L,
+ 1E4133L,
+ 1E4134L,
+ 1E4135L,
+ 1E4136L,
+ 1E4137L,
+ 1E4138L,
+ 1E4139L,
+ 1E4140L,
+ 1E4141L,
+ 1E4142L,
+ 1E4143L,
+ 1E4144L,
+ 1E4145L,
+ 1E4146L,
+ 1E4147L,
+ 1E4148L,
+ 1E4149L,
+ 1E4150L,
+ 1E4151L,
+ 1E4152L,
+ 1E4153L,
+ 1E4154L,
+ 1E4155L,
+ 1E4156L,
+ 1E4157L,
+ 1E4158L,
+ 1E4159L,
+ 1E4160L,
+ 1E4161L,
+ 1E4162L,
+ 1E4163L,
+ 1E4164L,
+ 1E4165L,
+ 1E4166L,
+ 1E4167L,
+ 1E4168L,
+ 1E4169L,
+ 1E4170L,
+ 1E4171L,
+ 1E4172L,
+ 1E4173L,
+ 1E4174L,
+ 1E4175L,
+ 1E4176L,
+ 1E4177L,
+ 1E4178L,
+ 1E4179L,
+ 1E4180L,
+ 1E4181L,
+ 1E4182L,
+ 1E4183L,
+ 1E4184L,
+ 1E4185L,
+ 1E4186L,
+ 1E4187L,
+ 1E4188L,
+ 1E4189L,
+ 1E4190L,
+ 1E4191L,
+ 1E4192L,
+ 1E4193L,
+ 1E4194L,
+ 1E4195L,
+ 1E4196L,
+ 1E4197L,
+ 1E4198L,
+ 1E4199L,
+ 1E4200L,
+ 1E4201L,
+ 1E4202L,
+ 1E4203L,
+ 1E4204L,
+ 1E4205L,
+ 1E4206L,
+ 1E4207L,
+ 1E4208L,
+ 1E4209L,
+ 1E4210L,
+ 1E4211L,
+ 1E4212L,
+ 1E4213L,
+ 1E4214L,
+ 1E4215L,
+ 1E4216L,
+ 1E4217L,
+ 1E4218L,
+ 1E4219L,
+ 1E4220L,
+ 1E4221L,
+ 1E4222L,
+ 1E4223L,
+ 1E4224L,
+ 1E4225L,
+ 1E4226L,
+ 1E4227L,
+ 1E4228L,
+ 1E4229L,
+ 1E4230L,
+ 1E4231L,
+ 1E4232L,
+ 1E4233L,
+ 1E4234L,
+ 1E4235L,
+ 1E4236L,
+ 1E4237L,
+ 1E4238L,
+ 1E4239L,
+ 1E4240L,
+ 1E4241L,
+ 1E4242L,
+ 1E4243L,
+ 1E4244L,
+ 1E4245L,
+ 1E4246L,
+ 1E4247L,
+ 1E4248L,
+ 1E4249L,
+ 1E4250L,
+ 1E4251L,
+ 1E4252L,
+ 1E4253L,
+ 1E4254L,
+ 1E4255L,
+ 1E4256L,
+ 1E4257L,
+ 1E4258L,
+ 1E4259L,
+ 1E4260L,
+ 1E4261L,
+ 1E4262L,
+ 1E4263L,
+ 1E4264L,
+ 1E4265L,
+ 1E4266L,
+ 1E4267L,
+ 1E4268L,
+ 1E4269L,
+ 1E4270L,
+ 1E4271L,
+ 1E4272L,
+ 1E4273L,
+ 1E4274L,
+ 1E4275L,
+ 1E4276L,
+ 1E4277L,
+ 1E4278L,
+ 1E4279L,
+ 1E4280L,
+ 1E4281L,
+ 1E4282L,
+ 1E4283L,
+ 1E4284L,
+ 1E4285L,
+ 1E4286L,
+ 1E4287L,
+ 1E4288L,
+ 1E4289L,
+ 1E4290L,
+ 1E4291L,
+ 1E4292L,
+ 1E4293L,
+ 1E4294L,
+ 1E4295L,
+ 1E4296L,
+ 1E4297L,
+ 1E4298L,
+ 1E4299L,
+ 1E4300L,
+ 1E4301L,
+ 1E4302L,
+ 1E4303L,
+ 1E4304L,
+ 1E4305L,
+ 1E4306L,
+ 1E4307L,
+ 1E4308L,
+ 1E4309L,
+ 1E4310L,
+ 1E4311L,
+ 1E4312L,
+ 1E4313L,
+ 1E4314L,
+ 1E4315L,
+ 1E4316L,
+ 1E4317L,
+ 1E4318L,
+ 1E4319L,
+ 1E4320L,
+ 1E4321L,
+ 1E4322L,
+ 1E4323L,
+ 1E4324L,
+ 1E4325L,
+ 1E4326L,
+ 1E4327L,
+ 1E4328L,
+ 1E4329L,
+ 1E4330L,
+ 1E4331L,
+ 1E4332L,
+ 1E4333L,
+ 1E4334L,
+ 1E4335L,
+ 1E4336L,
+ 1E4337L,
+ 1E4338L,
+ 1E4339L,
+ 1E4340L,
+ 1E4341L,
+ 1E4342L,
+ 1E4343L,
+ 1E4344L,
+ 1E4345L,
+ 1E4346L,
+ 1E4347L,
+ 1E4348L,
+ 1E4349L,
+ 1E4350L,
+ 1E4351L,
+ 1E4352L,
+ 1E4353L,
+ 1E4354L,
+ 1E4355L,
+ 1E4356L,
+ 1E4357L,
+ 1E4358L,
+ 1E4359L,
+ 1E4360L,
+ 1E4361L,
+ 1E4362L,
+ 1E4363L,
+ 1E4364L,
+ 1E4365L,
+ 1E4366L,
+ 1E4367L,
+ 1E4368L,
+ 1E4369L,
+ 1E4370L,
+ 1E4371L,
+ 1E4372L,
+ 1E4373L,
+ 1E4374L,
+ 1E4375L,
+ 1E4376L,
+ 1E4377L,
+ 1E4378L,
+ 1E4379L,
+ 1E4380L,
+ 1E4381L,
+ 1E4382L,
+ 1E4383L,
+ 1E4384L,
+ 1E4385L,
+ 1E4386L,
+ 1E4387L,
+ 1E4388L,
+ 1E4389L,
+ 1E4390L,
+ 1E4391L,
+ 1E4392L,
+ 1E4393L,
+ 1E4394L,
+ 1E4395L,
+ 1E4396L,
+ 1E4397L,
+ 1E4398L,
+ 1E4399L,
+ 1E4400L,
+ 1E4401L,
+ 1E4402L,
+ 1E4403L,
+ 1E4404L,
+ 1E4405L,
+ 1E4406L,
+ 1E4407L,
+ 1E4408L,
+ 1E4409L,
+ 1E4410L,
+ 1E4411L,
+ 1E4412L,
+ 1E4413L,
+ 1E4414L,
+ 1E4415L,
+ 1E4416L,
+ 1E4417L,
+ 1E4418L,
+ 1E4419L,
+ 1E4420L,
+ 1E4421L,
+ 1E4422L,
+ 1E4423L,
+ 1E4424L,
+ 1E4425L,
+ 1E4426L,
+ 1E4427L,
+ 1E4428L,
+ 1E4429L,
+ 1E4430L,
+ 1E4431L,
+ 1E4432L,
+ 1E4433L,
+ 1E4434L,
+ 1E4435L,
+ 1E4436L,
+ 1E4437L,
+ 1E4438L,
+ 1E4439L,
+ 1E4440L,
+ 1E4441L,
+ 1E4442L,
+ 1E4443L,
+ 1E4444L,
+ 1E4445L,
+ 1E4446L,
+ 1E4447L,
+ 1E4448L,
+ 1E4449L,
+ 1E4450L,
+ 1E4451L,
+ 1E4452L,
+ 1E4453L,
+ 1E4454L,
+ 1E4455L,
+ 1E4456L,
+ 1E4457L,
+ 1E4458L,
+ 1E4459L,
+ 1E4460L,
+ 1E4461L,
+ 1E4462L,
+ 1E4463L,
+ 1E4464L,
+ 1E4465L,
+ 1E4466L,
+ 1E4467L,
+ 1E4468L,
+ 1E4469L,
+ 1E4470L,
+ 1E4471L,
+ 1E4472L,
+ 1E4473L,
+ 1E4474L,
+ 1E4475L,
+ 1E4476L,
+ 1E4477L,
+ 1E4478L,
+ 1E4479L,
+ 1E4480L,
+ 1E4481L,
+ 1E4482L,
+ 1E4483L,
+ 1E4484L,
+ 1E4485L,
+ 1E4486L,
+ 1E4487L,
+ 1E4488L,
+ 1E4489L,
+ 1E4490L,
+ 1E4491L,
+ 1E4492L,
+ 1E4493L,
+ 1E4494L,
+ 1E4495L,
+ 1E4496L,
+ 1E4497L,
+ 1E4498L,
+ 1E4499L,
+ 1E4500L,
+ 1E4501L,
+ 1E4502L,
+ 1E4503L,
+ 1E4504L,
+ 1E4505L,
+ 1E4506L,
+ 1E4507L,
+ 1E4508L,
+ 1E4509L,
+ 1E4510L,
+ 1E4511L,
+ 1E4512L,
+ 1E4513L,
+ 1E4514L,
+ 1E4515L,
+ 1E4516L,
+ 1E4517L,
+ 1E4518L,
+ 1E4519L,
+ 1E4520L,
+ 1E4521L,
+ 1E4522L,
+ 1E4523L,
+ 1E4524L,
+ 1E4525L,
+ 1E4526L,
+ 1E4527L,
+ 1E4528L,
+ 1E4529L,
+ 1E4530L,
+ 1E4531L,
+ 1E4532L,
+ 1E4533L,
+ 1E4534L,
+ 1E4535L,
+ 1E4536L,
+ 1E4537L,
+ 1E4538L,
+ 1E4539L,
+ 1E4540L,
+ 1E4541L,
+ 1E4542L,
+ 1E4543L,
+ 1E4544L,
+ 1E4545L,
+ 1E4546L,
+ 1E4547L,
+ 1E4548L,
+ 1E4549L,
+ 1E4550L,
+ 1E4551L,
+ 1E4552L,
+ 1E4553L,
+ 1E4554L,
+ 1E4555L,
+ 1E4556L,
+ 1E4557L,
+ 1E4558L,
+ 1E4559L,
+ 1E4560L,
+ 1E4561L,
+ 1E4562L,
+ 1E4563L,
+ 1E4564L,
+ 1E4565L,
+ 1E4566L,
+ 1E4567L,
+ 1E4568L,
+ 1E4569L,
+ 1E4570L,
+ 1E4571L,
+ 1E4572L,
+ 1E4573L,
+ 1E4574L,
+ 1E4575L,
+ 1E4576L,
+ 1E4577L,
+ 1E4578L,
+ 1E4579L,
+ 1E4580L,
+ 1E4581L,
+ 1E4582L,
+ 1E4583L,
+ 1E4584L,
+ 1E4585L,
+ 1E4586L,
+ 1E4587L,
+ 1E4588L,
+ 1E4589L,
+ 1E4590L,
+ 1E4591L,
+ 1E4592L,
+ 1E4593L,
+ 1E4594L,
+ 1E4595L,
+ 1E4596L,
+ 1E4597L,
+ 1E4598L,
+ 1E4599L,
+ 1E4600L,
+ 1E4601L,
+ 1E4602L,
+ 1E4603L,
+ 1E4604L,
+ 1E4605L,
+ 1E4606L,
+ 1E4607L,
+ 1E4608L,
+ 1E4609L,
+ 1E4610L,
+ 1E4611L,
+ 1E4612L,
+ 1E4613L,
+ 1E4614L,
+ 1E4615L,
+ 1E4616L,
+ 1E4617L,
+ 1E4618L,
+ 1E4619L,
+ 1E4620L,
+ 1E4621L,
+ 1E4622L,
+ 1E4623L,
+ 1E4624L,
+ 1E4625L,
+ 1E4626L,
+ 1E4627L,
+ 1E4628L,
+ 1E4629L,
+ 1E4630L,
+ 1E4631L,
+ 1E4632L,
+ 1E4633L,
+ 1E4634L,
+ 1E4635L,
+ 1E4636L,
+ 1E4637L,
+ 1E4638L,
+ 1E4639L,
+ 1E4640L,
+ 1E4641L,
+ 1E4642L,
+ 1E4643L,
+ 1E4644L,
+ 1E4645L,
+ 1E4646L,
+ 1E4647L,
+ 1E4648L,
+ 1E4649L,
+ 1E4650L,
+ 1E4651L,
+ 1E4652L,
+ 1E4653L,
+ 1E4654L,
+ 1E4655L,
+ 1E4656L,
+ 1E4657L,
+ 1E4658L,
+ 1E4659L,
+ 1E4660L,
+ 1E4661L,
+ 1E4662L,
+ 1E4663L,
+ 1E4664L,
+ 1E4665L,
+ 1E4666L,
+ 1E4667L,
+ 1E4668L,
+ 1E4669L,
+ 1E4670L,
+ 1E4671L,
+ 1E4672L,
+ 1E4673L,
+ 1E4674L,
+ 1E4675L,
+ 1E4676L,
+ 1E4677L,
+ 1E4678L,
+ 1E4679L,
+ 1E4680L,
+ 1E4681L,
+ 1E4682L,
+ 1E4683L,
+ 1E4684L,
+ 1E4685L,
+ 1E4686L,
+ 1E4687L,
+ 1E4688L,
+ 1E4689L,
+ 1E4690L,
+ 1E4691L,
+ 1E4692L,
+ 1E4693L,
+ 1E4694L,
+ 1E4695L,
+ 1E4696L,
+ 1E4697L,
+ 1E4698L,
+ 1E4699L,
+ 1E4700L,
+ 1E4701L,
+ 1E4702L,
+ 1E4703L,
+ 1E4704L,
+ 1E4705L,
+ 1E4706L,
+ 1E4707L,
+ 1E4708L,
+ 1E4709L,
+ 1E4710L,
+ 1E4711L,
+ 1E4712L,
+ 1E4713L,
+ 1E4714L,
+ 1E4715L,
+ 1E4716L,
+ 1E4717L,
+ 1E4718L,
+ 1E4719L,
+ 1E4720L,
+ 1E4721L,
+ 1E4722L,
+ 1E4723L,
+ 1E4724L,
+ 1E4725L,
+ 1E4726L,
+ 1E4727L,
+ 1E4728L,
+ 1E4729L,
+ 1E4730L,
+ 1E4731L,
+ 1E4732L,
+ 1E4733L,
+ 1E4734L,
+ 1E4735L,
+ 1E4736L,
+ 1E4737L,
+ 1E4738L,
+ 1E4739L,
+ 1E4740L,
+ 1E4741L,
+ 1E4742L,
+ 1E4743L,
+ 1E4744L,
+ 1E4745L,
+ 1E4746L,
+ 1E4747L,
+ 1E4748L,
+ 1E4749L,
+ 1E4750L,
+ 1E4751L,
+ 1E4752L,
+ 1E4753L,
+ 1E4754L,
+ 1E4755L,
+ 1E4756L,
+ 1E4757L,
+ 1E4758L,
+ 1E4759L,
+ 1E4760L,
+ 1E4761L,
+ 1E4762L,
+ 1E4763L,
+ 1E4764L,
+ 1E4765L,
+ 1E4766L,
+ 1E4767L,
+ 1E4768L,
+ 1E4769L,
+ 1E4770L,
+ 1E4771L,
+ 1E4772L,
+ 1E4773L,
+ 1E4774L,
+ 1E4775L,
+ 1E4776L,
+ 1E4777L,
+ 1E4778L,
+ 1E4779L,
+ 1E4780L,
+ 1E4781L,
+ 1E4782L,
+ 1E4783L,
+ 1E4784L,
+ 1E4785L,
+ 1E4786L,
+ 1E4787L,
+ 1E4788L,
+ 1E4789L,
+ 1E4790L,
+ 1E4791L,
+ 1E4792L,
+ 1E4793L,
+ 1E4794L,
+ 1E4795L,
+ 1E4796L,
+ 1E4797L,
+ 1E4798L,
+ 1E4799L,
+ 1E4800L,
+ 1E4801L,
+ 1E4802L,
+ 1E4803L,
+ 1E4804L,
+ 1E4805L,
+ 1E4806L,
+ 1E4807L,
+ 1E4808L,
+ 1E4809L,
+ 1E4810L,
+ 1E4811L,
+ 1E4812L,
+ 1E4813L,
+ 1E4814L,
+ 1E4815L,
+ 1E4816L,
+ 1E4817L,
+ 1E4818L,
+ 1E4819L,
+ 1E4820L,
+ 1E4821L,
+ 1E4822L,
+ 1E4823L,
+ 1E4824L,
+ 1E4825L,
+ 1E4826L,
+ 1E4827L,
+ 1E4828L,
+ 1E4829L,
+ 1E4830L,
+ 1E4831L,
+ 1E4832L,
+ 1E4833L,
+ 1E4834L,
+ 1E4835L,
+ 1E4836L,
+ 1E4837L,
+ 1E4838L,
+ 1E4839L,
+ 1E4840L,
+ 1E4841L,
+ 1E4842L,
+ 1E4843L,
+ 1E4844L,
+ 1E4845L,
+ 1E4846L,
+ 1E4847L,
+ 1E4848L,
+ 1E4849L,
+ 1E4850L,
+ 1E4851L,
+ 1E4852L,
+ 1E4853L,
+ 1E4854L,
+ 1E4855L,
+ 1E4856L,
+ 1E4857L,
+ 1E4858L,
+ 1E4859L,
+ 1E4860L,
+ 1E4861L,
+ 1E4862L,
+ 1E4863L,
+ 1E4864L,
+ 1E4865L,
+ 1E4866L,
+ 1E4867L,
+ 1E4868L,
+ 1E4869L,
+ 1E4870L,
+ 1E4871L,
+ 1E4872L,
+ 1E4873L,
+ 1E4874L,
+ 1E4875L,
+ 1E4876L,
+ 1E4877L,
+ 1E4878L,
+ 1E4879L,
+ 1E4880L,
+ 1E4881L,
+ 1E4882L,
+ 1E4883L,
+ 1E4884L,
+ 1E4885L,
+ 1E4886L,
+ 1E4887L,
+ 1E4888L,
+ 1E4889L,
+ 1E4890L,
+ 1E4891L,
+ 1E4892L,
+ 1E4893L,
+ 1E4894L,
+ 1E4895L,
+ 1E4896L,
+ 1E4897L,
+ 1E4898L,
+ 1E4899L,
+ 1E4900L,
+ 1E4901L,
+ 1E4902L,
+ 1E4903L,
+ 1E4904L,
+ 1E4905L,
+ 1E4906L,
+ 1E4907L,
+ 1E4908L,
+ 1E4909L,
+ 1E4910L,
+ 1E4911L,
+ 1E4912L,
+ 1E4913L,
+ 1E4914L,
+ 1E4915L,
+ 1E4916L,
+ 1E4917L,
+ 1E4918L,
+ 1E4919L,
+ 1E4920L,
+ 1E4921L,
+ 1E4922L,
+ 1E4923L,
+ 1E4924L,
+ 1E4925L,
+ 1E4926L,
+ 1E4927L,
+ 1E4928L,
+ 1E4929L,
+ 1E4930L,
+ 1E4931L,
+ 1E4932L,
+};
+
+Sftab_t _Sftable =
+{
+ { 1E1L, 1E2L, 1E4L, 1E8L, 1E16L, 1E32L },
+ { 1E-1L, 1E-2L, 1E-4L, 1E-8L, 1E-16L, 1E-32L },
+ { '0','0', '0','1', '0','2', '0','3', '0','4',
+ '0','5', '0','6', '0','7', '0','8', '0','9',
+ '1','0', '1','1', '1','2', '1','3', '1','4',
+ '1','5', '1','6', '1','7', '1','8', '1','9',
+ '2','0', '2','1', '2','2', '2','3', '2','4',
+ '2','5', '2','6', '2','7', '2','8', '2','9',
+ '3','0', '3','1', '3','2', '3','3', '3','4',
+ '3','5', '3','6', '3','7', '3','8', '3','9',
+ '4','0', '4','1', '4','2', '4','3', '4','4',
+ '4','5', '4','6', '4','7', '4','8', '4','9',
+ '5','0', '5','1', '5','2', '5','3', '5','4',
+ '5','5', '5','6', '5','7', '5','8', '5','9',
+ '6','0', '6','1', '6','2', '6','3', '6','4',
+ '6','5', '6','6', '6','7', '6','8', '6','9',
+ '7','0', '7','1', '7','2', '7','3', '7','4',
+ '7','5', '7','6', '7','7', '7','8', '7','9',
+ '8','0', '8','1', '8','2', '8','3', '8','4',
+ '8','5', '8','6', '8','7', '8','8', '8','9',
+ '9','0', '9','1', '9','2', '9','3', '9','4',
+ '9','5', '9','6', '9','7', '9','8', '9','9',
+ },
+ "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@_",
+ sfcvinit, 0,
+ sffmtpos,
+ sffmtint,
+ (float*)&sf_flt_pow10[0],
+ (double*)&sf_dbl_pow10[0],
+ (_ast_fltmax_t*)&sf_ldbl_pow10[0],
+};
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/sfio b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/sfio
new file mode 100644
index 0000000000..465503bc8a
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/sfio
@@ -0,0 +1,14 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/sfio by iffe version 2007-04-04 : : */
+#ifndef _def_sfio_ast
+#define _def_sfio_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_float 1 /* #include <float.h> ok */
+#define _hdr_floatingpoint 1 /* #include <floatingpoint.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _hdr_values 1 /* #include <values.h> ok */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _key_signed 1 /* signed is a reserved keyword */
+#define _lib_cvt 1 /* native floating point conversions ok */
+#define _xopen_stdio 1 /* Stdio fseek/fflush are X/Open-compliant */
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/sig b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/sig
new file mode 100644
index 0000000000..72939b001b
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/sig
@@ -0,0 +1,131 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/sig.sh by iffe version 2007-04-04 : : */
+#ifndef _def_sig_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_sig_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define sig_info _sig_info_
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide kill killpg
+#else
+#define kill ______kill
+#define killpg ______killpg
+#endif
+#include <signal.h>
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide kill killpg
+#else
+#undef kill
+#undef killpg
+#endif
+#ifndef sigmask
+#define sigmask(s) (1<<((s)-1))
+#endif
+typedef void (*Sig_handler_t) __PROTO__((int));
+
+
+#define Handler_t Sig_handler_t
+
+#define SIG_REG_PENDING (-1)
+#define SIG_REG_POP 0
+#define SIG_REG_EXEC 00001
+#define SIG_REG_PROC 00002
+#define SIG_REG_TERM 00004
+#define SIG_REG_ALL 00777
+#define SIG_REG_SET 01000
+
+typedef struct
+{
+ char** name;
+ char** text;
+ int sigmax;
+} Sig_info_t;
+
+extern __MANGLE__ int kill __PROTO__((pid_t, int));
+extern __MANGLE__ int killpg __PROTO__((pid_t, int));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Sig_info_t sig_info;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int sigcritical __PROTO__((int));
+extern __MANGLE__ int sigunblock __PROTO__((int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/signal b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/signal
new file mode 100644
index 0000000000..8459924a5c
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/signal
@@ -0,0 +1,175 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/signal.c by iffe version 2007-04-04 : : */
+#ifndef _def_signal_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_signal_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define SIG_MAX 48
+
+static const char* const sig_name[] =
+{
+ "0",
+ "HUP",
+ "INT",
+ "QUIT",
+ "ILL",
+ "TRAP",
+ "IOT",
+ "EMT",
+ "FPE",
+ "KILL",
+ "BUS",
+ "SEGV",
+ "SYS",
+ "PIPE",
+ "ALRM",
+ "TERM",
+ "USR1",
+ "USR2",
+ "CHLD",
+ "PWR",
+ "WINCH",
+ "URG",
+ "IO",
+ "STOP",
+ "TSTP",
+ "CONT",
+ "TTIN",
+ "TTOU",
+ "VTALRM",
+ "PROF",
+ "XCPU",
+ "XFSZ",
+ "WAITING",
+ "LWP",
+ "FREEZE",
+ "THAW",
+ "36",
+ "LOST",
+ "38",
+ "39",
+ "40",
+ "RTMIN",
+ "RT1",
+ "RT2",
+ "RT3",
+ "RT4",
+ "RT5",
+ "RT6",
+ "RTMAX",
+ 0
+};
+
+static const char* const sig_text[] =
+{
+ "Signal 0",
+ "Hangup",
+ "Interrupt",
+ "Quit",
+ "Illegal instruction",
+ "Trace trap",
+ "IOT trap",
+ "EMT trap",
+ "Floating exception",
+ "Killed",
+ "Bus error",
+ "Memory fault",
+ "Bad system call",
+ "Broken pipe",
+ "Alarm call",
+ "Terminated",
+ "User signal 1",
+ "User signal 2",
+ "Child status change",
+ "Power fail",
+ "Window change",
+ "Urgent IO",
+ "IO possible",
+ "Stopped (signal)",
+ "Stopped",
+ "Stopped process continued",
+ "Stopped (tty input)",
+ "Stopped (tty output)",
+ "Virtual timer alarm",
+ "Profile timer alarm",
+ "CPU time limit",
+ "File size limit",
+ "All threads blocked",
+ "Thread event",
+ "CPR freeze",
+ "CPR thaw",
+ "Signal 36",
+ "Resources lost",
+ "Signal 38",
+ "Signal 39",
+ "Signal 40",
+ "Realtime priority 0 (lo)",
+ "Realtime priority 1",
+ "Realtime priority 2",
+ "Realtime priority 3",
+ "Realtime priority 4",
+ "Realtime priority 5",
+ "Realtime priority 6",
+ "Realtime priority 7 (hi)",
+ 0
+};
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/standards b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/standards
new file mode 100644
index 0000000000..b859405156
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/standards
@@ -0,0 +1,28 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/standards by iffe version 2007-04-04 : : */
+#ifndef _def_standards_ast
+#define _def_standards_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* _ALL_SOURCE & _ISOC99_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works */
+#ifndef _ALL_SOURCE
+#define _ALL_SOURCE 1
+#endif
+#ifndef _ISOC99_SOURCE
+#define _ISOC99_SOURCE 1
+#endif
+#ifndef _POSIX_SOURCE
+#define _POSIX_SOURCE 1
+#endif
+#ifndef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 21000101L
+#endif
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 9900
+#endif
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#ifndef __EXTENSIONS__
+#define __EXTENSIONS__ 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/stdio b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/stdio
new file mode 100644
index 0000000000..f531374a22
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/stdio
@@ -0,0 +1,579 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/stdio by iffe version 2007-04-04 : : */
+
+#ifndef _SFSTDIO_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SFSTDIO_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define __FILE_typedef 1
+#define _FILE_DEFINED 1
+#define _FILE_defined 1
+#define _FILEDEFED 1
+
+#ifndef __FILE_TAG
+#define __FILE_TAG _sfio_s
+#endif
+
+#undef FILE
+#undef _FILE
+#undef fpos_t
+#undef fpos64_t
+
+typedef struct _sfio_s _sfio_FILE;
+
+#define FILE _sfio_FILE
+#define _FILE FILE
+
+#if !defined(__FILE) && !__CYGWIN__
+#undef __FILE
+#define __FILE FILE
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define BUFSIZ SF_BUFSIZE
+
+#else
+
+#ifndef BUFSIZ
+#define BUFSIZ 8192
+#endif
+
+#ifndef EOF
+#define EOF (-1)
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+#include <ast_std.h>
+
+#include <sfio_s.h>
+
+#if __cplusplus
+#define _sf_(f) (f)
+#else
+#define _sf_(f) ((struct _sfio_s*)(f))
+#endif
+
+#define _SF_EOF 0000200
+#define _SF_ERROR 0000400
+
+#endif
+
+#ifdef _NO_LARGEFILE64_SOURCE
+#undef _LARGEFILE64_SOURCE
+#endif
+
+#ifdef _LARGEFILE64_SOURCE
+#undef off_t
+#endif
+
+#define fpos_t _ast_fpos_t
+#if _typ_int64_t
+#define fpos64_t _ast_fpos_t
+#endif
+
+typedef struct _ast_fpos_s
+{
+ intmax_t _sf_offset;
+ unsigned char _sf_state[64 - sizeof(intmax_t)];
+} _ast_fpos_t;
+
+#define _base _data
+#define _ptr _next
+#define _IOFBF 0
+#define _IONBF 1
+#define _IOLBF 2
+
+#if defined(__cplusplus) && defined(__THROW) && !defined(_UWIN)
+
+#undef FILE
+#define FILE FILE
+typedef struct _sfio_s FILE;
+
+#undef strerror
+extern __MANGLE__ char* strerror(int) __THROW;
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#endif
+
+#ifndef FILENAME_MAX
+#define FILENAME_MAX 1024
+#endif
+#ifndef FOPEN_MAX
+#define FOPEN_MAX 20
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+
+#define _doprnt _ast_doprnt
+#define _doscan _ast_doscan
+#define asprintf _ast_asprintf
+#define clearerr _ast_clearerr
+#define fclose _ast_fclose
+#define fdopen _ast_fdopen
+#define fflush _ast_fflush
+#define fgetc _ast_fgetc
+#define fgetpos _ast_fgetpos
+#define fgetpos64 _ast_fgetpos64
+#define fgets _ast_fgets
+#define fopen _ast_fopen
+#define fprintf _ast_fprintf
+#define fpurge _ast_fpurge
+#define fputs _ast_fputs
+#define fread _ast_fread
+#define freopen _ast_freopen
+#define fscanf _ast_fscanf
+#define fseek _ast_fseek
+#define fseek64 _ast_fseek64
+#define fseeko _ast_fseeko
+#define fseeko64 _ast_fseeko64
+#define fsetpos _ast_fsetpos
+#define fsetpos64 _ast_fsetpos64
+#define ftell _ast_ftell
+#define ftell64 _ast_ftell64
+#define ftello _ast_ftello
+#define ftello64 _ast_ftello64
+#define fwrite _ast_fwrite
+#define gets _ast_gets
+#define getw _ast_getw
+#define pclose _ast_pclose
+#define popen _ast_popen
+#define printf _ast_printf
+#define puts _ast_puts
+#define putw _ast_putw
+#define rewind _ast_rewind
+#define scanf _ast_scanf
+#define setbuf _ast_setbuf
+#undef setbuffer
+#define setbuffer _ast_setbuffer
+#define setlinebuf _ast_setlinebuf
+#define setvbuf _ast_setvbuf
+#define snprintf _ast_snprintf
+#define sprintf _ast_sprintf
+#define sscanf _ast_sscanf
+#define tmpfile _ast_tmpfile
+#define ungetc _ast_ungetc
+#define vasprintf _ast_vasprintf
+#define vfprintf _ast_vfprintf
+#define vfscanf _ast_vfscanf
+#define vprintf _ast_vprintf
+#define vscanf _ast_vscanf
+#define vsnprintf _ast_vsnprintf
+#define vsprintf _ast_vsprintf
+#define vsscanf _ast_vsscanf
+#define fcloseall _ast_fcloseall
+#define fmemopen _ast_fmemopen
+#define __getdelim _ast___getdelim
+#define getdelim _ast_getdelim
+#define getline _ast_getline
+#define clearerr_unlocked _ast_clearerr_unlocked
+#define feof_unlocked _ast_feof_unlocked
+#define ferror_unlocked _ast_ferror_unlocked
+#define fflush_unlocked _ast_fflush_unlocked
+#define fgetc_unlocked _ast_fgetc_unlocked
+#define fgets_unlocked _ast_fgets_unlocked
+#define fileno_unlocked _ast_fileno_unlocked
+#define fputc_unlocked _ast_fputc_unlocked
+#define fputs_unlocked _ast_fputs_unlocked
+#define fread_unlocked _ast_fread_unlocked
+#define fwrite_unlocked _ast_fwrite_unlocked
+#define getc_unlocked _ast_getc_unlocked
+#define getchar_unlocked _ast_getchar_unlocked
+#define putc_unlocked _ast_putc_unlocked
+#define putchar_unlocked _ast_putchar_unlocked
+
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef P_tmpdir
+#define P_tmpdir "/var/tmp/" /*NOCATLITERAL*/
+#endif
+#ifndef L_ctermid
+#define L_ctermid 9
+#endif
+#ifndef L_tmpnam
+#define L_tmpnam 25
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#if defined(__cplusplus) && defined(__THROW)
+extern __MANGLE__ char* ctermid(char*) __THROW;
+#else
+extern __MANGLE__ char* ctermid __PROTO__((char*));
+#endif
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+extern __MANGLE__ void perror __PROTO__((const char*));
+#ifndef _AST_STD_H
+#ifndef remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#endif
+#ifndef rename
+extern __MANGLE__ int rename __PROTO__((const char*, const char*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#ifdef _LARGEFILE64_SOURCE
+
+#undef fpos_t
+#undef off_t
+#undef fgetpos
+#undef fsetpos
+#undef fseek
+#undef fseeko
+#undef ftell
+#undef ftello
+
+#define fpos_t fpos64_t
+#if _typ_off64_t
+#define off_t off64_t
+#else
+#define off_t int64_t
+#endif
+
+#define fgetpos fgetpos64
+#define fsetpos fsetpos64
+#define fseek fseek64
+#define fseeko fseeko64
+#define ftell ftell64
+#define ftello ftello64
+
+#endif
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_DLL && _DLL_INDIRECT_DATA
+
+#define stdin ((FILE*)_ast_dll->_ast_stdin)
+#define stdout ((FILE*)_ast_dll->_ast_stdout)
+#define stderr ((FILE*)_ast_dll->_ast_stderr)
+
+#else
+
+#define stdin (&_Sfstdin)
+#define stdout (&_Sfstdout)
+#define stderr (&_Sfstderr)
+
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define feof(f) sfeof(f)
+#define ferror(f) sferror(f)
+#define fileno(f) sffileno(f)
+#define fputc(c,f) sfputc(f,c)
+#define getc(f) sfgetc(f)
+#define getchar() sfgetc(sfstdin)
+#define putc(c,f) sfputc(f,c)
+#define putchar(c) sfputc(sfstdout,c)
+
+#else
+
+#if !_UWIN
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+#endif
+
+extern __MANGLE__ FILE _Sfstdin;
+extern __MANGLE__ FILE _Sfstdout;
+extern __MANGLE__ FILE _Sfstderr;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define feof(f) (_sf_(f)->_flags&_SF_EOF)
+#define ferror(f) (_sf_(f)->_flags&_SF_ERROR)
+#define fileno(f) (_sf_(f)->_file)
+#define fputc(c,f) (_sf_(f)->_next>=_sf_(f)->_endw?_sfflsbuf(_sf_(f),(int)((unsigned char)(c))):(int)(*_sf_(f)->_next++=(unsigned char)(c)))
+#define getc(f) (_sf_(f)->_next>=_sf_(f)->_endr?_sffilbuf(_sf_(f),0):(int)(*_sf_(f)->_next++))
+#define getchar() getc(stdin)
+#define putc(c,f) fputc(c,f)
+#define putchar(c) fputc(c,stdout)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _sffilbuf __PROTO__((FILE*, int));
+extern __MANGLE__ int _sfflsbuf __PROTO__((FILE*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/sys b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/sys
new file mode 100644
index 0000000000..091269fd30
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/sys
@@ -0,0 +1,151 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/sys by iffe version 2007-04-04 : : */
+
+#ifndef _AST_SYS_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_SYS_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#if __mips == 2 && !defined(_NO_LARGEFILE64_SOURCE)
+#define _NO_LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_NO_LARGEFILE64_SOURCE) && _typ_off64_t && _lib_lseek64 && _lib_stat64
+#if !defined(_LARGEFILE64_SOURCE)
+#define _LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_LARGEFILE_SOURCE)
+#define _LARGEFILE_SOURCE 1
+#endif
+#else
+#undef _LARGEFILE64_SOURCE
+#undef _LARGEFILE_SOURCE
+#undef _typ_off64_t
+#undef _typ_struct_dirent64
+#undef _lib_creat64
+#undef _lib_fstat64
+#undef _lib_fstatvfs64
+#undef _lib_ftruncate64
+#undef _lib_lseek64
+#undef _lib_lstat64
+#undef _lib_mmap64
+#undef _lib_open64
+#undef _lib_readdir64
+#undef _lib_stat64
+#undef _lib_statvfs64
+#undef _lib_truncate64
+#endif
+#if defined(__STDC__) && !defined(__USE_FIXED_PROTOTYPES__)
+#define __USE_FIXED_PROTOTYPES__ 1 /* kick gcc out of the past */
+#endif
+#include <stdlib.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <locale.h>
+#include <sys/localedef.h>
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _typ_dev_t 1 /* dev_t is a type */
+#define _typ_nlink_t 1 /* nlink_t is a type */
+#define _typ_gid_t 1 /* gid_t is a type */
+#define _typ_mode_t 1 /* mode_t is a type */
+#define _typ_uid_t 1 /* uid_t is a type */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _typ_wchar_t 1 /* wchar_t is a type */
+#define _typ_pid_t 1 /* pid_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _typ_wint_t 1 /* wint_t is a type */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _typ_socklen_t 1 /* socklen_t is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_ino_t 1 /* ino_t is a type */
+#define _typ_off_t 1 /* off_t is a type */
+#define _typ_ptrdiff_t 1 /* ptrdiff_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#define _typ_div_t 1 /* div_t is a type */
+#define _typ_ldiv_t 1 /* ldiv_t is a type */
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+extern __MANGLE__ int eaccess __PROTO__((const char*, int));
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+extern __MANGLE__ __V_* pvalloc __PROTO__((size_t));
+extern __MANGLE__ pid_t spawnveg __PROTO__((const char*, char* const[], char* const[], pid_t));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#if !defined(va_start)
+#if defined(__STDARG__)
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/time b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/time
new file mode 100644
index 0000000000..c20d4cad00
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/time
@@ -0,0 +1,83 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/time by iffe version 2007-04-04 : : */
+
+#ifndef _def_time_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_time_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_nanosleep 1 /* nanosleep() in default lib(s) */
+#define _lib_usleep 1 /* usleep() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#include <sys/time.h>
+
+#include <sys/times.h>
+
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC CLK_TCK
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tmlib b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tmlib
new file mode 100644
index 0000000000..8fe4f5a0da
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tmlib
@@ -0,0 +1,68 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/tmlib by iffe version 2007-04-04 : : */
+
+#ifndef _def_tmlib_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_tmlib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define tmlocaltime(p) localtime(p)
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tmx b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tmx
new file mode 100644
index 0000000000..f9d742ea73
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tmx
@@ -0,0 +1,128 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/tmx by iffe version 2007-04-04 : : */
+
+#ifndef _TMX_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TMX_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Time_t support
+ */
+
+#include <tm.h>
+#include <tv.h>
+
+#define TMX_MAXDATE "2554-07-21+23:34:33.709551614 UTC"
+#define TMX_MAXYEAR 2554
+#define TMX_MAXSEC ((Time_t)18446744073)
+#define TMX_MAXNSEC 709551614
+#define TMX_RESOLUTION 1000000000
+
+typedef uint64_t Time_t;
+typedef uint64_t Tmxsec_t;
+typedef uint32_t Tmxnsec_t;
+
+#define tmxsec(t) ((Tmxsec_t)((t)/1000000000))
+#define tmxnsec(t) ((Tmxnsec_t)((t)%1000000000))
+#define tmxsns(s,n) (((((Time_t)(s))*1000000000))+((Time_t)(n)))
+
+#define TMX_NOTIME ((Time_t)(-1))
+#define TMX_NOW tmxgettime()
+#define TMX_MAXTIME tmxsns(TMX_MAXSEC,TMX_MAXNSEC)
+
+#define tmx2tv(t,v) ((v)->tv_nsec=tmxnsec(t),(v)->tv_sec=tmxsec(t))
+#define tv2tmx(v) tmxsns((v)->tv_sec,(v)->tv_nsec)
+
+#define tmxclock(p) tmxsns(((p)?*(p):time(NiL)),0)
+
+#define tmxgetatime(s) tmxsns((s)->st_atime,ST_ATIME_NSEC_GET(s))
+#define tmxgetctime(s) tmxsns((s)->st_ctime,ST_CTIME_NSEC_GET(s))
+#define tmxgetmtime(s) tmxsns((s)->st_mtime,ST_MTIME_NSEC_GET(s))
+
+#define tmxsetatime(s,t) ((s)->st_atime=tmxsec(t),ST_ATIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetctime(s,t) ((s)->st_ctime=tmxsec(t),ST_CTIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetmtime(s,t) ((s)->st_mtime=tmxsec(t),ST_MTIME_NSEC_SET(s,tmxnsec(t)))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Time_t tmxdate __PROTO__((const char*, char**, Time_t));
+extern __MANGLE__ char* tmxfmt __PROTO__((char*, size_t, const char*, Time_t));
+extern __MANGLE__ Time_t tmxleap __PROTO__((Time_t));
+extern __MANGLE__ Tm_t* tmxmake __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxscan __PROTO__((const char*, char**, const char*, char**, Time_t, long));
+extern __MANGLE__ int tmxsleep __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxtime __PROTO__((Tm_t*, int));
+
+extern __MANGLE__ Time_t tmxgettime __PROTO__((void));
+extern __MANGLE__ int tmxsettime __PROTO__((Time_t));
+
+extern __MANGLE__ int tmxtouch __PROTO__((const char*, Time_t, Time_t, Time_t, int));
+
+extern __MANGLE__ char* fmttmx __PROTO__((const char*, Time_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tty b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tty
new file mode 100644
index 0000000000..dce44fe8e3
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tty
@@ -0,0 +1,134 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/tty by iffe version 2007-04-04 : : */
+#ifndef _def_tty_ast
+#define _def_tty_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_termios 1 /* #include <termios.h> ok */
+#define _hdr_termio 1 /* #include <termio.h> ok */
+#define _hdr_sgtty 1 /* #include <sgtty.h> ok */
+#define _sys_termios 1 /* #include <sys/termios.h> ok */
+#define _sys_termio 1 /* #include <sys/termio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _lib_tcgetattr 1 /* tcgetattr() in default lib(s) */
+#define _lib_tcgetpgrp 1 /* tcgetpgrp() in default lib(s) */
+#define _mac__POSIX_VDISABLE 1 /* _POSIX_VDISABLE is a macro */
+
+#ifdef _hdr_termios
+# if _mac__POSIX_VDISABLE
+# undef _POSIX_VDISABLE
+# endif
+# include <termios.h>
+#else
+# if defined(_sys_termios) && defined(_lib_tcgetattr)
+# include <sys/termios.h>
+# define _hdr_termios 1
+# else
+# undef _sys_termios
+# endif /* _sys_termios */
+#endif /* _hdr_termios */
+
+#ifdef _hdr_termios
+# undef _hdr_sgtty
+# undef tcgetattr
+# undef tcsetattr
+# undef tcgetpgrp
+# undef tcsetpgrp
+# undef cfgetospeed
+# ifndef TCSANOW
+# define TCSANOW TCSETS
+# define TCSADRAIN TCSETSW
+# define TCSAFLUSH TCSETSF
+# endif /* TCSANOW */
+ /* The following corrects bugs in some implementations */
+# if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
+# define TCSAFLUSH TCSADFLUSH
+# endif /* TCSADFLUSH */
+# ifndef _lib_tcgetattr
+# undef tcgetattr
+# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
+# undef tcsetattr
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# undef cfgetospeed
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# endif /* _lib_tcgetattr */
+# undef TIOCGETC
+#else
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfgetispeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfsetispeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# define cfsetospeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# ifdef _hdr_termio
+# include <termio.h>
+# else
+# ifdef _sys_termio
+# include <sys/termio.h>
+# define _hdr_termio 1
+# endif /* _sys_termio */
+# endif /* _hdr_termio */
+# ifdef _hdr_termio
+# define termios termio
+# undef TIOCGETC
+# define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+
+# ifdef _sys_bsdtty
+# include <sys/bsdtty.h>
+# endif /* _sys_bsdtty */
+# else
+# ifdef _hdr_sgtty
+# include <sgtty.h>
+# ifndef LPENDIN
+# ifdef _sys_nttyio
+# include <sys/nttyio.h>
+# endif /* _sys_nttyio */
+# endif /* LPENDIN */
+# define termios sgttyb
+# ifdef TIOCSETN
+# undef TCSETAW
+# endif /* TIOCSETN */
+# ifdef TIOCGETP
+# define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# else
+# define tcgetattr(fd,tty) gtty(fd, tty)
+# define tcsetattr(fd,action,tty) stty(fd, tty)
+# endif /* TIOCGETP */
+# else
+# ifdef _sys_ttyio
+# include <sys/ttyio.h>
+# endif
+# endif /* _hdr_sgtty */
+# endif /* hdr_termio */
+
+# ifndef TCSANOW
+# ifdef TCSETAW
+# define TCSANOW TCSETA
+# define TCSAFLUSH TCSETAF
+# else
+# ifdef TIOCSETN
+# define TCSANOW TIOCSETN
+# define TCSADRAIN TIOCSETN
+# define TCSAFLUSH TIOCSETP
+# endif /* TIOCSETN */
+# endif /* TCSETAW */
+# endif /* TCSANOW */
+#endif /* _hdr_termios */
+
+/* set ECHOCTL if driver can echo control charaters as ^c */
+#ifdef LCTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LCTLECH
+# endif /* !ECHOCTL */
+#endif /* LCTLECH */
+#ifdef LNEW_CTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LNEW_CTLECH
+# endif /* !ECHOCTL */
+#endif /* LNEW_CTLECH */
+#ifdef LNEW_PENDIN
+# ifndef PENDIN
+# define PENDIN LNEW_PENDIN
+# endif /* !PENDIN */
+#endif /* LNEW_PENDIN */
+
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tv b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tv
new file mode 100644
index 0000000000..9ec820b351
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tv
@@ -0,0 +1,111 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/tv by iffe version 2007-04-04 : : */
+
+#ifndef _TV_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TV_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Tv_t interface definitions
+ */
+
+#include <ast.h>
+
+#define TV_NSEC_IGNORE (1000000000L)
+#define TV_TOUCH_RETAIN ((Tv_t*)1)
+
+typedef struct Tv_s
+{
+ uint32_t tv_sec;
+ uint32_t tv_nsec;
+} Tv_t;
+
+#define ST_ATIME_NSEC_GET(st) ((st)->st_atim.tv_nsec)
+#define ST_CTIME_NSEC_GET(st) ((st)->st_ctim.tv_nsec)
+#define ST_MTIME_NSEC_GET(st) ((st)->st_mtim.tv_nsec)
+
+#define ST_ATIME_NSEC_SET(st,n) (ST_ATIME_NSEC_GET(st)=(n))
+#define ST_CTIME_NSEC_SET(st,n) (ST_CTIME_NSEC_GET(st)=(n))
+#define ST_MTIME_NSEC_SET(st,n) (ST_MTIME_NSEC_GET(st)=(n))
+
+#define tvgetatime(t,s) ((t)->tv_nsec=ST_ATIME_NSEC_GET(s),(t)->tv_sec=(s)->st_atime)
+#define tvgetmtime(t,s) ((t)->tv_nsec=ST_MTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_mtime)
+#define tvgetctime(t,s) ((t)->tv_nsec=ST_CTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_ctime)
+
+#define tvsetatime(t,s) (ST_ATIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_atime=(t)->tv_sec)
+#define tvsetmtime(t,s) (ST_MTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_mtime=(t)->tv_sec)
+#define tvsetctime(t,s) (ST_CTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_ctime=(t)->tv_sec)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int tvgettime __PROTO__((Tv_t*));
+extern __MANGLE__ int tvsettime __PROTO__((const Tv_t*));
+extern __MANGLE__ int tvcmp __PROTO__((const Tv_t*, const Tv_t*));
+extern __MANGLE__ int tvtouch __PROTO__((const char*, const Tv_t*, const Tv_t*, const Tv_t*, int));
+extern __MANGLE__ int tvsleep __PROTO__((const Tv_t*, Tv_t*));
+
+extern __MANGLE__ char* fmttv __PROTO__((const char*, Tv_t*));
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tvlib b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tvlib
new file mode 100644
index 0000000000..c2798de246
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/tvlib
@@ -0,0 +1,17 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/tvlib by iffe version 2007-04-04 : : */
+#ifndef _def_tvlib_ast
+#define _def_tvlib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _lib_clock_settime 1 /* clock_settime() in default lib(s) */
+#define _lib_gettimeofday 1 /* gettimeofday() in default lib(s) */
+#define _lib_settimeofday 1 /* settimeofday() in default lib(s) */
+#define _lib_stime 1 /* stime() in default lib(s) */
+#define _lib_utimes 1 /* utimes() in default lib(s) */
+#define _lib_nanosleep 1 /* nanosleep() in default lib(s) */
+#define _lib_usleep 1 /* usleep() in default lib(s) */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _lib_clock_gettime 1 /* execute{\ passed */
+#define tmgettimeofday(p) gettimeofday(p,(struct timezone*)0)
+#define tmsettimeofday(p) settimeofday(p,(struct timezone*)0)
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/types b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/types
new file mode 100644
index 0000000000..343b5954a0
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/types
@@ -0,0 +1,5 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_types_ast
+#define _def_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/uwin b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/uwin
new file mode 100644
index 0000000000..66b740925f
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/uwin
@@ -0,0 +1,17 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/uwin by iffe version 2007-04-04 : : */
+#ifndef _def_uwin_ast
+#define _def_uwin_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_a64l 1 /* a64l() in default lib(s) */
+#define _lib_crypt 1 /* crypt() in default lib(s) */
+#define _lib_getpass 1 /* getpass() in default lib(s) */
+#define _lib_random 1 /* random() in default lib(s) */
+#define _lib_rcmd 1 /* rcmd() in default lib(s) */
+#define _lib_srand48 1 /* srand48() in default lib(s) */
+#define _lib_logb 1 /* logb() in default lib(s) */
+#define _lib_finite 1 /* finite() in default lib(s) */
+#define _lib_scalb 1 /* scalb() in default lib(s) */
+#define _lib__finite 1 /* _finite() in default lib(s) */
+#define _lib__scalb 1 /* _scalb() in default lib(s) */
+#define _dat__iob 1 /* _iob in default lib(s) */
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/vfork b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/vfork
new file mode 100644
index 0000000000..d70a055a5b
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/vfork
@@ -0,0 +1,68 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/vfork by iffe version 2007-04-04 : : */
+
+#ifndef _def_vfork_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_vfork_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+extern __MANGLE__ pid_t vfork __PROTO__((void));
+#pragma unknown_control_flow(vfork)
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/vmalloc b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/vmalloc
new file mode 100644
index 0000000000..b810c821b8
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/vmalloc
@@ -0,0 +1,36 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/vmalloc by iffe version 2007-04-04 : : */
+#ifndef _def_vmalloc_ast
+#define _def_vmalloc_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_atexit 1 /* atexit() in default lib(s) */
+#define _lib_getpagesize 1 /* getpagesize() in default lib(s) */
+#define _lib_memalign 1 /* memalign() in default lib(s) */
+#define _lib_strdup 1 /* strdup() in default lib(s) */
+#define _lib_valloc 1 /* valloc() in default lib(s) */
+#define _hdr_alloca 1 /* #include <alloca.h> ok */
+#define _hdr_malloc 1 /* #include <malloc.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _mem_arena_mallinfo 1 /* arena is a member of struct mallinfo */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _mem_sbrk 1 /* brk()/sbrk() work as expected */
+#define _lib_alloca 1 /* alloca exists */
+#define _stk_down 1 /* stack grows downward */
+#include "FEATURE/mmap"
+#if _BLD_INSTRUMENT || cray || _UWIN && _BLD_ast
+#undef _map_malloc
+#define _std_malloc 1 /* defer to standard malloc */
+#endif
+#if _mmap_anon
+#define _mem_mmap_anon 1
+#endif
+#if _mmap_devzero
+#define _mem_mmap_zero 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/wait b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/wait
new file mode 100644
index 0000000000..3bcc94d23b
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/wait
@@ -0,0 +1,11 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/wait by iffe version 2007-04-04 : : */
+#ifndef _def_wait_ast
+#define _def_wait_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_wait 1 /* wait() in default lib(s) */
+#define _lib_wait3 1 /* wait3() in default lib(s) */
+#define _lib_wait4 1 /* wait4() in default lib(s) */
+#define _lib_waitpid 1 /* waitpid() in default lib(s) */
+#define _sys_wait 1 /* #include <sys/wait.h> ok */
+#define _ok_wif 1 /* posix wait macros ok */
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/wchar b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/wchar
new file mode 100644
index 0000000000..03e01de07a
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/FEATURE/wchar
@@ -0,0 +1,187 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/wchar by iffe version 2007-04-04 : : */
+
+#ifndef _def_wchar_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_wchar_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _lib_mbstowcs 1 /* mbstowcs() in default lib(s) */
+#define _lib_wctomb 1 /* wctomb() in default lib(s) */
+#define _lib_wcrtomb 1 /* wcrtomb() in default lib(s) */
+#define _lib_wcslen 1 /* wcslen() in default lib(s) */
+#define _lib_wcstombs 1 /* wcstombs() in default lib(s) */
+#define _lib_wcwidth 1 /* wcwidth() in default lib(s) */
+#define _lib_towlower 1 /* towlower() in default lib(s) */
+#define _lib_towupper 1 /* towupper() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_mbstate_t 1 /* mbstate_t is a type */
+#define _nxt_wchar <../include/wchar.h> /* include path for the native <wchar.h> */
+#define _nxt_wchar_str "../include/wchar.h" /* include string for the native <wchar.h> */
+#ifndef _SFSTDIO_H
+#include <ast_common.h>
+#include <stdio.h>
+#endif
+#if _hdr_wchar && defined(_nxt_wchar)
+#include <../include/wchar.h> /* the native wchar.h */
+#endif
+#if _hdr_wctype
+#include <wctype.h>
+#endif
+
+#ifndef WEOF
+#define WEOF (-1)
+#endif
+
+#undef fgetwc
+#undef fgetws
+#undef fputwc
+#undef fputws
+#undef getwc
+#undef getwchar
+#undef getws
+#undef putwc
+#undef putwchar
+#undef ungetwc
+
+#define fgetwc _ast_fgetwc
+#define fgetws _ast_fgetws
+#define fputwc _ast_fputwc
+#define fputws _ast_fputws
+#define fwide _ast_fwide
+#define fwprintf _ast_fwprintf
+#define fwscanf _ast_fwscanf
+#define getwc _ast_getwc
+#define getwchar _ast_getwchar
+#define getws _ast_getws
+#define putwc _ast_putwc
+#define putwchar _ast_putwchar
+#define swprintf _ast_swprintf
+#define swscanf _ast_swscanf
+#define ungetwc _ast_ungetwc
+#define vfwprintf _ast_vfwprintf
+#define vfwscanf _ast_vfwscanf
+#define vswprintf _ast_vswprintf
+#define vswscanf _ast_vswscanf
+#define vwprintf _ast_vwprintf
+#define vwscanf _ast_vwscanf
+#define wprintf _ast_wprintf
+#define wscanf _ast_wscanf
+
+#if !_typ_mbstate_t
+#undef _typ_mbstate_t
+#define _typ_mbstate_t 1
+typedef char mbstate_t;
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#if !_lib_mbstowcs
+extern __MANGLE__ size_t mbstowcs __PROTO__((wchar_t*, const char*, size_t));
+#endif
+#if !_lib_wctomb
+extern __MANGLE__ int wctomb __PROTO__((char*, wchar_t));
+#endif
+#if !_lib_wcrtomb
+extern __MANGLE__ size_t wcrtomb __PROTO__((char*, wchar_t, mbstate_t*));
+#endif
+#if !_lib_wcslen
+extern __MANGLE__ size_t wcslen __PROTO__((const wchar_t*));
+#endif
+#if !_lib_wcstombs
+extern __MANGLE__ size_t wcstombs __PROTO__((char*, const wchar_t*, size_t));
+#endif
+
+extern __MANGLE__ int fwprintf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ int fwscanf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ wint_t fgetwc __PROTO__((FILE*));
+extern __MANGLE__ wchar_t* fgetws __PROTO__((wchar_t*, int, FILE*));
+extern __MANGLE__ wint_t fputwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ int fputws __PROTO__((const wchar_t*, FILE*));
+extern __MANGLE__ int fwide __PROTO__((FILE*, int));
+extern __MANGLE__ wint_t getwc __PROTO__((FILE*));
+extern __MANGLE__ wint_t getwchar __PROTO__((void));
+extern __MANGLE__ wchar_t* getws __PROTO__((wchar_t*));
+extern __MANGLE__ wint_t putwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ wint_t putwchar __PROTO__((wchar_t));
+extern __MANGLE__ int swprintf __PROTO__((wchar_t*, size_t, const wchar_t*, ...));
+extern __MANGLE__ int swscanf __PROTO__((const wchar_t*, const wchar_t*, ...));
+extern __MANGLE__ wint_t ungetwc __PROTO__((wint_t, FILE*));
+extern __MANGLE__ int vfwprintf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vfwscanf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vwprintf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vwscanf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vswprintf __PROTO__((wchar_t*, size_t, const wchar_t*, va_list));
+extern __MANGLE__ int vswscanf __PROTO__((const wchar_t*, const wchar_t*, va_list));
+extern __MANGLE__ int wprintf __PROTO__((const wchar_t*, ...));
+extern __MANGLE__ int wscanf __PROTO__((const wchar_t*, ...));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/align.h b/usr/src/lib/libast/sparc/src/lib/libast/align.h
new file mode 100644
index 0000000000..09939a36da
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/align.h
@@ -0,0 +1,33 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/align.c by iffe version 2007-04-04 : : */
+#ifndef _def_align_ast
+#define _def_align_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+typedef unsigned long ALIGN_INTEGRAL;
+
+#define ALIGN_CHUNK 8192
+#define ALIGN_INTEGRAL long
+#define ALIGN_INTEGER(x) ((ALIGN_INTEGRAL)(x))
+#define ALIGN_POINTER(x) ((char*)(x))
+#define ALIGN_ROUND(x,y) ALIGN_POINTER(ALIGN_INTEGER((x)+(y)-1)&~((y)-1))
+
+#define ALIGN_BOUND ALIGN_BOUND2
+#define ALIGN_ALIGN(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC(x) ALIGN_TRUNC2(x)
+
+#define ALIGN_BIT1 0x1
+#define ALIGN_BOUND1 ALIGN_BOUND2
+#define ALIGN_ALIGN1(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC1(x) ALIGN_TRUNC2(x)
+#define ALIGN_CLRBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffe)
+#define ALIGN_SETBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x1)
+#define ALIGN_TSTBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x1)
+
+#define ALIGN_BIT2 0x2
+#define ALIGN_BOUND2 8
+#define ALIGN_ALIGN2(x) ALIGN_TRUNC2((x)+7)
+#define ALIGN_TRUNC2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffff8)
+#define ALIGN_CLRBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffd)
+#define ALIGN_SETBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x2)
+#define ALIGN_TSTBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x2)
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_botch.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_botch.h
new file mode 100644
index 0000000000..ce25726723
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_botch.h
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/botch.c by iffe version 2007-04-04 : : */
+#ifndef _def_botch_ast
+#define _def_botch_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_ccode.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_ccode.h
new file mode 100644
index 0000000000..002834f2fa
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_ccode.h
@@ -0,0 +1,29 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/ccode by iffe version 2007-04-04 : : */
+#ifndef _def_ccode_ast
+#define _def_ccode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define CC_ASCII 1 /* ISO-8859-1 */
+#define CC_EBCDIC_E 2 /* Xopen dd(1) EBCDIC */
+#define CC_EBCDIC_I 3 /* Xopen dd(1) IBM */
+#define CC_EBCDIC_O 4 /* IBM-1047 mvs OpenEdition */
+#define CC_EBCDIC_S 5 /* Siemens posix-bc */
+#define CC_EBCDIC_H 6 /* IBM-37 AS/400 */
+#define CC_EBCDIC_M 7 /* IBM mvs cobol */
+#define CC_EBCDIC_U 8 /* microfocus cobol */
+
+#define CC_MAPS 8 /* number of code maps */
+
+#define CC_EBCDIC CC_EBCDIC_E
+#define CC_EBCDIC1 CC_EBCDIC_E
+#define CC_EBCDIC2 CC_EBCDIC_I
+#define CC_EBCDIC3 CC_EBCDIC_O
+
+#define CC_NATIVE CC_ASCII /* native character code */
+#define CC_ALIEN CC_EBCDIC /* alien character code */
+
+#define CC_bel 0007 /* bel character */
+#define CC_esc 0033 /* esc character */
+#define CC_sub 0032 /* sub character */
+#define CC_vt 0013 /* vt character */
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_common.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_common.h
new file mode 100644
index 0000000000..0b5de4487b
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_common.h
@@ -0,0 +1,198 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/common by iffe version 2007-04-04 : : */
+#ifndef _AST_COMMON_H
+#define _AST_COMMON_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_pthread 1 /* #include <pthread.h> ok */
+#define _hdr_stdarg 1 /* #include <stdarg.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdint 1 /* #include <stdint.h> ok */
+#define _hdr_inttypes 1 /* #include <inttypes.h> ok */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_long_double 1 /* long double is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _std_proto 1 /* standard C prototypes ok */
+#define _ptr_void 1 /* standard C void* ok */
+/* disable non-standard linux/gnu inlines */
+#ifdef __GNUC__
+# undef __OPTIMIZE_SIZE__
+# define __OPTIMIZE_SIZE__ 1
+#endif
+
+/* __STD_C indicates that the language is ANSI-C or C++ */
+#if !defined(__STD_C) && __STDC__
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && (__cplusplus || c_plusplus)
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && _std_proto
+# define __STD_C 1
+#endif
+#if !defined(__STD_C)
+# define __STD_C 0
+#endif
+
+/* extern symbols must be protected against C++ name mangling */
+#ifndef _BEGIN_EXTERNS_
+# if __cplusplus || c_plusplus
+# define _BEGIN_EXTERNS_ extern "C" {
+# define _END_EXTERNS_ }
+# else
+# define _BEGIN_EXTERNS_
+# define _END_EXTERNS_
+# endif
+#endif
+
+/* _ARG_ simplifies function prototyping among flavors of C */
+#ifndef _ARG_
+# if __STD_C
+# define _ARG_(x) x
+# else
+# define _ARG_(x) ()
+# endif
+#endif
+
+/* _NIL_ simplifies defining nil pointers to a given type */
+#ifndef _NIL_
+# define _NIL_(x) ((x)0)
+#endif
+
+/* __INLINE__ is the inline keyword */
+#if !defined(__INLINE__) && defined(__cplusplus)
+# define __INLINE__ inline
+#endif
+#if !defined(__INLINE__) && defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+#endif
+
+/* Void_t is defined so that Void_t* can address any type */
+#ifndef Void_t
+# if __STD_C
+# define Void_t void
+# else
+# define Void_t char
+# endif
+#endif
+
+/* windows variants and veneers */
+#if !defined(_WINIX) && (_UWIN || __CYGWIN__ || __EMX__)
+# define _WINIX 1
+#endif
+
+/* dynamic linked library external scope handling */
+#ifdef __DYNAMIC__
+# undef __DYNAMIC__
+# ifndef _DLL
+# define _DLL 1
+# endif
+#endif
+#if _dll_import
+# if _BLD_STATIC && !_BLD_DLL
+# undef _DLL
+# else
+# if !_UWIN && !defined(_DLL)
+# define _DLL 1
+# endif
+# endif
+# if !defined(__EXPORT__) && _BLD_DLL
+# define __EXPORT__ __declspec(dllexport)
+# endif
+# if !defined(__IMPORT__) && ( _BLD_DLL || defined(_DLL) )
+# define __IMPORT__ __declspec(dllimport)
+# endif
+# if _BLD_DLL && _UWIN
+# define __DYNAMIC__(v) (_ast_getdll()->_ast_ ## v)
+# endif
+#endif
+#if !defined(_astimport)
+# if defined(__IMPORT__) && defined(_DLL)
+# define _astimport __IMPORT__
+# else
+# define _astimport extern
+# endif
+#endif
+#if _dll_import && ( !_BLD_DLL || _WINIX && !_UWIN )
+# ifdef __STDC__
+# define __EXTERN__(T,obj) extern T obj; T* _imp__ ## obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__ ## obj = &obj
+# else
+# define __EXTERN__(T,obj) extern T obj; T* _imp__/**/obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__/**/obj = &obj
+# endif
+#else
+# define __EXTERN__(T,obj) extern T obj
+# define __DEFINE__(T,obj,val) T obj = val
+#endif
+
+#define _ast_LL 1 /* LL numeric suffix supported */
+#define _ast_int1_t char
+#define _ast_int2_t short
+#define _ast_int4_t int
+#define _ast_int8_t long long
+#define _ast_intmax_t _ast_int8_t
+#define _ast_intswap 0
+
+#define _ast_flt4_t float
+#define _ast_flt8_t double
+#define _ast_flt16_t long double
+#define _ast_fltmax_t _ast_flt16_t
+#define _typ_int8_t 1 /* int8_t is a type */
+#define _typ_uint8_t 1 /* uint8_t is a type */
+#define _typ_int16_t 1 /* int16_t is a type */
+#define _typ_uint16_t 1 /* uint16_t is a type */
+#define _typ_int32_t 1 /* int32_t is a type */
+#define _typ_uint32_t 1 /* uint32_t is a type */
+#define _typ_int64_t 1 /* int64_t is a type */
+#define _typ_uint64_t 1 /* uint64_t is a type */
+#define _typ_intmax_t 1 /* intmax_t is a type */
+#define _typ_uintmax_t 1 /* uintmax_t is a type */
+
+#ifndef va_listref
+#define va_listref(p) (p) /* pass va_list to varargs function */
+#define va_listval(p) (p) /* retrieve va_list from va_arg(ap,va_listarg) */
+#define va_listarg va_list /* va_arg() va_list type */
+#ifndef va_start
+#if __STD_C
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+#endif
+#ifndef _AST_STD_H
+# if __STD_C && _hdr_stddef
+# include <stddef.h>
+# endif
+# if _sys_types
+# include <sys/types.h>
+# endif
+# if _hdr_stdint
+# include <stdint.h>
+# else
+# if _hdr_inttypes
+# include <inttypes.h>
+# endif
+# endif
+#endif
+#if !_typ_size_t
+# define _typ_size_t 1
+ typedef int size_t;
+#endif
+#if !_typ_ssize_t
+# define _typ_ssize_t 1
+ typedef int ssize_t;
+#endif
+#ifndef _AST_STD_H
+# if !_def_map_ast
+# include <ast_map.h>
+# endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_dirent.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_dirent.h
new file mode 100644
index 0000000000..8221b60e80
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_dirent.h
@@ -0,0 +1,106 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/dirent by iffe version 2007-04-04 : : */
+
+#ifndef _def_dirent_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dirent_ast 1
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _nxt_dirent <../include/dirent.h> /* include path for the native <dirent.h> */
+#define _nxt_dirent_str "../include/dirent.h" /* include string for the native <dirent.h> */
+/*
+ * <dirent.h> for [fl]stat64 and off64_t
+ */
+
+#ifndef _AST_STD_H
+
+#include <../include/dirent.h> /* the native <dirent.h> */
+
+#else
+
+#ifndef _DIR64_H
+#define _DIR64_H
+
+#include <ast_std.h>
+
+#if _typ_off64_t
+#undef off_t
+#endif
+
+#include <../include/dirent.h> /* the native <dirent.h> */
+
+#if _typ_off64_t
+#define off_t off64_t
+#endif
+
+#if _lib_readdir64 && _typ_struct_dirent64
+#ifndef dirent
+#define dirent dirent64
+#endif
+#ifndef readdir
+#define readdir readdir64
+#endif
+#endif
+
+#endif
+
+#endif
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_fcntl.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_fcntl.h
new file mode 100644
index 0000000000..4cbf8fa21d
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_fcntl.h
@@ -0,0 +1,114 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/fcntl.c by iffe version 2007-04-04 : : */
+#ifndef _def_fcntl_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fcntl_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <ast_fs.h>
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#define O_BINARY 0
+#define O_TEMPORARY 0
+#define O_TEXT 0
+
+#include <ast_fs.h>
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_fstat64
+#define fstat fstat64
+#endif
+#if _lib_lstat64
+#define lstat lstat64
+#endif
+#if _lib_stat64
+#define stat stat64
+#endif
+#if _lib_creat64
+#define creat creat64
+#endif
+#if _lib_mmap64
+#define mmap mmap64
+#endif
+#if _lib_open64
+#undef open
+#define open open64
+#endif
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_float.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_float.h
new file mode 100644
index 0000000000..abb9593b60
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_float.h
@@ -0,0 +1,213 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/float by iffe version 2007-04-04 : : */
+
+#ifndef _def_float_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_float_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_float 1 /* #include <float.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _hdr_values 1 /* #include <values.h> ok */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_frexp 1 /* frexp() in default lib(s) */
+#define _lib_frexpl 1 /* frexpl() in default lib(s) */
+#define _lib_ldexp 1 /* ldexp() in default lib(s) */
+#define _lib_ldexpl 1 /* ldexpl() in default lib(s) */
+#define _lib_finite 1 /* finite() in default lib(s) */
+#define _lib_isnan 1 /* isnan() in default lib(s) */
+#define _lib_isnanl 1 /* isnanl() in default lib(s) */
+#define _lib_copysign 1 /* copysign() in default lib(s) */
+#define _lib_copysignl 1 /* copysignl() in default lib(s) */
+#include <ast_common.h>
+#include <float.h>
+#include <math.h>
+#ifndef FLT_DIG
+#define FLT_DIG 6
+#endif
+#ifndef FLT_MAX
+#define FLT_MAX 3.4028234663852885981170E+38F
+#endif
+#ifndef FLT_MAX_10_EXP
+#define FLT_MAX_10_EXP ( + 38 )
+#endif
+#ifndef FLT_MAX_EXP
+#define FLT_MAX_EXP ( + 128 )
+#endif
+#ifndef FLT_MIN
+#define FLT_MIN 1.1754943508222875079688E-38F
+#endif
+#ifndef FLT_MIN_10_EXP
+#define FLT_MIN_10_EXP ( - 37 )
+#endif
+#ifndef FLT_MIN_EXP
+#define FLT_MIN_EXP ( - 125 )
+#endif
+#ifndef DBL_DIG
+#define DBL_DIG 15
+#endif
+#ifndef DBL_MAX
+#define DBL_MAX 1.7976931348623157081452E+308
+#endif
+#ifndef DBL_MAX_10_EXP
+#define DBL_MAX_10_EXP ( + 308 )
+#endif
+#ifndef DBL_MAX_EXP
+#define DBL_MAX_EXP ( + 1024 )
+#endif
+#ifndef DBL_MIN
+#define DBL_MIN 2.2250738585072013830903E-308
+#endif
+#ifndef DBL_MIN_10_EXP
+#define DBL_MIN_10_EXP ( - 307 )
+#endif
+#ifndef DBL_MIN_EXP
+#define DBL_MIN_EXP ( - 1021 )
+#endif
+#ifndef LDBL_DIG
+#define LDBL_DIG 33
+#endif
+#ifndef LDBL_MAX
+#define LDBL_MAX 1.189731495357231765085759326628007016E+4932L
+#endif
+#ifndef LDBL_MAX_10_EXP
+#define LDBL_MAX_10_EXP ( + 4932 )
+#endif
+#ifndef LDBL_MAX_EXP
+#define LDBL_MAX_EXP ( + 16384 )
+#endif
+#ifndef LDBL_MIN
+#define LDBL_MIN 3.362103143112093506262677817321752603E-4932L
+#endif
+#ifndef LDBL_MIN_10_EXP
+#define LDBL_MIN_10_EXP ( - 4931 )
+#endif
+#ifndef LDBL_MIN_EXP
+#define LDBL_MIN_EXP ( - 16381 )
+#endif
+
+
+#define USHRT_DIG 4
+#define UINT_DIG 9
+#define ULONG_DIG 9
+#define ULLONG_DIG 19
+#define UINTMAX_DIG ULLONG_DIG
+
+#define FLT_ULONG_MAX 4294967295.0F
+#define FLT_ULLONG_MAX 18446744073709551615.0F
+#define FLT_UINTMAX_MAX FLT_ULLONG_MAX
+#define FLT_LONG_MAX 2147483647.0F
+#define FLT_LLONG_MAX 9223372036854775807.0F
+#define FLT_INTMAX_MAX FLT_LLONG_MAX
+#define FLT_LONG_MIN (-2147483648.0F)
+#define FLT_LLONG_MIN (-9223372036854775808.0F)
+#define FLT_INTMAX_MIN FLT_LLONG_MIN
+
+#define DBL_ULONG_MAX 4294967295.0
+#define DBL_ULLONG_MAX 18446744073709551615.0
+#define DBL_UINTMAX_MAX DBL_ULLONG_MAX
+#define DBL_LONG_MAX 2147483647.0
+#define DBL_LLONG_MAX 9223372036854775807.0
+#define DBL_INTMAX_MAX DBL_LLONG_MAX
+#define DBL_LONG_MIN (-2147483648.0)
+#define DBL_LLONG_MIN (-9223372036854775808.0)
+#define DBL_INTMAX_MIN DBL_LLONG_MIN
+
+#define LDBL_ULONG_MAX 4294967295.0L
+#define LDBL_ULLONG_MAX 18446744073709551615.0L
+#define LDBL_UINTMAX_MAX LDBL_ULLONG_MAX
+#define LDBL_LONG_MAX 2147483647.0L
+#define LDBL_LLONG_MAX 9223372036854775807.0L
+#define LDBL_INTMAX_MAX LDBL_LLONG_MAX
+#define LDBL_LONG_MIN (-2147483648.0L)
+#define LDBL_LLONG_MIN (-9223372036854775808.0L)
+#define LDBL_INTMAX_MIN LDBL_LLONG_MIN
+
+#define FLTMAX_UINTMAX_MAX LDBL_UINTMAX_MAX
+#define FLTMAX_INTMAX_MAX LDBL_INTMAX_MAX
+#define FLTMAX_INTMAX_MIN LDBL_INTMAX_MIN
+
+typedef union _ast_dbl_exp_u
+{
+ uint32_t e[sizeof(double)/4];
+ double f;
+} _ast_dbl_exp_t;
+
+#define _ast_dbl_exp_index 0
+#define _ast_dbl_exp_shift 20
+
+typedef union _fltmax_exp_u
+{
+ uint32_t e[sizeof(_ast_fltmax_t)/4];
+ _ast_fltmax_t f;
+} _ast_fltmax_exp_t;
+
+#define _ast_fltmax_exp_index 0
+#define _ast_fltmax_exp_shift 16
+
+#define _ast_flt_unsigned_max_t unsigned long long
+#define _ast_flt_nan_init 0x7f,0xff,0xff,0xff
+#define _ast_flt_inf_init 0x7f,0x80,0x00,0x00
+#define _ast_dbl_nan_init 0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff
+#define _ast_dbl_inf_init 0x7f,0xf0,0x00,0x00,0x00,0x00,0x00,0x00
+#define _ast_ldbl_nan_init 0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
+#define _ast_ldbl_inf_init 0x7f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_fs.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_fs.h
new file mode 100644
index 0000000000..c2ad71dadc
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_fs.h
@@ -0,0 +1,154 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/fs by iffe version 2007-04-04 : : */
+
+#ifndef _def_fs_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fs_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _lib_lstat 1 /* lstat() in default lib(s) */
+#define _lib_mknod 1 /* mknod() in default lib(s) */
+#define _lib_sync 1 /* sync() in default lib(s) */
+#include <sys/stat.h>
+#define FS_default "ufs"
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef major
+#define major(x) ( major_t ) ( ( ( ( unsigned ) ( ( x ) ) ) >> 8 ) & 0x7f )
+#endif
+#ifndef minor
+#define minor(x) ( minor_t ) ( ( ( x ) ) & 0xff )
+#endif
+#ifndef makedev
+#define makedev(x,y) ( unsigned short ) ( ( ( ( x ) ) << 8 ) | ( ( ( y ) ) & 0xff ) )
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _sys_mntent 1 /* #include <sys/mntent.h> ok */
+#define _sys_mnttab 1 /* #include <sys/mnttab.h> ok */
+#define _mem_st_blocks_stat 1 /* st_blocks is a member of struct stat */
+#define _mem_st_blksize_stat 1 /* st_blksize is a member of struct stat */
+#define _mem_st_rdev_stat 1 /* st_rdev is a member of struct stat */
+#define _sys_statfs 1 /* #include <sys/statfs.h> ok */
+#define _mem_f_files_statfs 1 /* f_files is a member of struct statfs */
+#define _sys_vfs 1 /* #include <sys/vfs.h> ok */
+#define _sys_param 1 /* #include <sys/param.h> ok */
+#define _sys_mount 1 /* #include <sys/mount.h> ok */
+#define _sys_statvfs 1 /* #include <sys/statvfs.h> ok */
+#define _mem_f_basetype_statvfs 1 /* f_basetype is a member of struct statvfs */
+#define _mem_f_frsize_statvfs 1 /* f_frsize is a member of struct statvfs */
+#define _lib_getmntent 1 /* getmntent() in default lib(s) */
+#define _lib_statfs 1 /* statfs() in default lib(s) */
+#define _lib_statvfs 1 /* statvfs() in default lib(s) */
+#define _lib_statfs4 1 /* compile{\ passed */
+#if _sys_statvfs
+#include <sys/statvfs.h>
+#if !_mem_statvfs_f_basetype
+#if _ary_f_reserved7
+#define f_basetype f_reserved7
+#endif
+#endif
+#else
+#define _mem_f_basetype_statvfs 1
+#define _mem_f_frsize_statvfs 1
+struct statvfs
+{
+unsigned long f_bsize; /* fundamental file system block size */
+unsigned long f_frsize; /* fragment size */
+unsigned long f_blocks; /* total # of blocks of f_frsize on fs */
+unsigned long f_bfree; /* total # of free blocks of f_frsize */
+unsigned long f_bavail; /* # of free blocks avail to non-superuser */
+unsigned long f_files; /* total # of file nodes (inodes) */
+unsigned long f_ffree; /* total # of free file nodes */
+unsigned long f_favail; /* # of free nodes avail to non-superuser */
+unsigned long f_fsid; /* file system id (dev for now) */
+char f_basetype[16]; /* target fs type name, null-terminated */
+unsigned long f_flag; /* bit-mask of flags */
+unsigned long f_namemax; /* maximum file name length */
+char f_fstr[32]; /* filesystem-specific string */
+unsigned long f_filler[16]; /* reserved for future expansion */
+};
+extern __MANGLE__ int fstatvfs __PROTO__((int, struct statvfs*));
+extern __MANGLE__ int statvfs __PROTO__((const char*, struct statvfs*));
+#endif
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_statvfs64 && !defined(statvfs)
+#define statvfs statvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int statvfs64 __PROTO__((const char*, struct statvfs64*));
+#endif
+#endif
+#if _lib_fstatvfs64 && !defined(fstatvfs)
+#define fstatvfs fstatvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int fstatvfs64 __PROTO__((int, struct statvfs64*));
+#endif
+#endif
+
+#define _str_st_fstype 1 /* stat.st_fstype is a string */
+#define _ary_st_pad4 1 /* stat.st_pad4 is an array */
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_iconv.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_iconv.h
new file mode 100644
index 0000000000..be50daaeca
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_iconv.h
@@ -0,0 +1,132 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/iconv by iffe version 2007-04-04 : : */
+
+#ifndef _def_iconv_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_iconv_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_iconv 1 /* #include <iconv.h> ok */
+#define _lib_iconv_open 1 /* iconv_open() in default lib(s) */
+#define _lib_iconv_close 1 /* iconv_close() in default lib(s) */
+#define _lib_iconv 1 /* iconv() in default lib(s) */
+#define _nxt_iconv <../include/iconv.h> /* include path for the native <iconv.h> */
+#define _nxt_iconv_str "../include/iconv.h" /* include string for the native <iconv.h> */
+#include <ast_common.h>
+#include <ccode.h>
+#include <../include/iconv.h> /* the native iconv.h */
+
+#define CC_ICONV (-1)
+#define CC_UCS (-2)
+#define CC_SCU (-3)
+#define CC_UTF (-4)
+#define CC_UME (-5)
+
+#ifndef _ICONV_LIST_PRIVATE_
+#undef iconv_t
+#define iconv_t _ast_iconv_t
+#undef iconv_f
+#define iconv_f _ast_iconv_f
+#undef iconv_list_t
+#define iconv_list_t _ast_iconv_list_t
+#undef iconv_open
+#define iconv_open _ast_iconv_open
+#undef iconv
+#define iconv _ast_iconv
+#undef iconv_close
+#define iconv_close _ast_iconv_close
+#undef iconv_list
+#define iconv_list _ast_iconv_list
+#undef iconv_move
+#define iconv_move _ast_iconv_move
+#undef iconv_name
+#define iconv_name _ast_iconv_name
+#undef iconv_write
+#define iconv_write _ast_iconv_write
+#endif
+
+typedef Ccmap_t _ast_iconv_list_t;
+typedef __V_* _ast_iconv_t;
+typedef size_t (*_ast_iconv_f) __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ _ast_iconv_t _ast_iconv_open __PROTO__((const char*, const char*));
+extern __MANGLE__ size_t _ast_iconv __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+extern __MANGLE__ int _ast_iconv_close __PROTO__((_ast_iconv_t));
+extern __MANGLE__ _ast_iconv_list_t* _ast_iconv_list __PROTO__((_ast_iconv_list_t*));
+extern __MANGLE__ int _ast_iconv_name __PROTO__((const char*, char*, size_t));
+#if _SFIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, Sfio_t*, Sfio_t*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, Sfio_t*, char**, size_t*, size_t*));
+#else
+#if _SFSTDIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, FILE*, FILE*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, FILE*, char**, size_t*, size_t*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_lib.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_lib.h
new file mode 100644
index 0000000000..5fe12a8acb
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_lib.h
@@ -0,0 +1,171 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/lib by iffe version 2007-04-04 : : */
+#ifndef _def_lib_ast
+#define _def_lib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _hdr_fmtmsg 1 /* #include <fmtmsg.h> ok */
+#define _hdr_fnmatch 1 /* #include <fnmatch.h> ok */
+#define _hdr_libgen 1 /* #include <libgen.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_locale 1 /* #include <locale.h> ok */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_spawn 1 /* #include <spawn.h> ok */
+#define _hdr_syslog 1 /* #include <syslog.h> ok */
+#define _hdr_utime 1 /* #include <utime.h> ok */
+#define _hdr_wctype 1 /* #include <wctype.h> ok */
+#define _hdr_wchar 1 /* <wchar.h> and isw*() really work */
+#define _dat__tzname 1 /* _tzname in default lib(s) */
+#define _dat_tzname 1 /* tzname in default lib(s) */
+#define _lib__cleanup 1 /* _cleanup() in default lib(s) */
+#define _lib_atexit 1 /* atexit() in default lib(s) */
+#define _lib_bcopy 1 /* bcopy() in default lib(s) */
+#define _lib_bzero 1 /* bzero() in default lib(s) */
+#define _lib_catclose 1 /* catclose() in default lib(s) */
+#define _lib_catgets 1 /* catgets() in default lib(s) */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_confstr 1 /* confstr() in default lib(s) */
+#define _lib_dup2 1 /* dup2() in default lib(s) */
+#define _lib_execlp 1 /* execlp() in default lib(s) */
+#define _lib_execve 1 /* execve() in default lib(s) */
+#define _lib_execvp 1 /* execvp() in default lib(s) */
+#define _lib_fchmod 1 /* fchmod() in default lib(s) */
+#define _lib_fcntl 1 /* fcntl() in default lib(s) */
+#define _lib_fmtmsg 1 /* fmtmsg() in default lib(s) */
+#define _lib_fnmatch 1 /* fnmatch() in default lib(s) */
+#define _lib_fork 1 /* fork() in default lib(s) */
+#define _lib_fsync 1 /* fsync() in default lib(s) */
+#define _lib_getdents 1 /* getdents() in default lib(s) */
+#define _lib_getdtablesize 1 /* getdtablesize() in default lib(s) */
+#define _lib_getdate 1 /* getdate() in default lib(s) */
+#define _lib_getgroups 1 /* getgroups() in default lib(s) */
+#define _lib_gethostname 1 /* gethostname() in default lib(s) */
+#define _lib_getlogin 1 /* getlogin() in default lib(s) */
+#define _lib_getpagesize 1 /* getpagesize() in default lib(s) */
+#define _lib_getrlimit 1 /* getrlimit() in default lib(s) */
+#define _lib_getopt 1 /* getopt() in default lib(s) */
+#define _lib_getsubopt 1 /* getsubopt() in default lib(s) */
+#define _lib_getopt_long 1 /* getopt_long() in default lib(s) */
+#define _lib_getopt_long_only 1 /* getopt_long_only() in default lib(s) */
+#define _lib_glob 1 /* glob() in default lib(s) */
+#define _lib_index 1 /* index() in default lib(s) */
+#define _lib_iswblank 1 /* iswblank() in default lib(s) */
+#define _lib_iswctype 1 /* iswctype() in default lib(s) */
+#define _lib_killpg 1 /* killpg() in default lib(s) */
+#define _lib_link 1 /* link() in default lib(s) */
+#define _lib_localeconv 1 /* localeconv() in default lib(s) */
+#define _lib_madvise 1 /* madvise() in default lib(s) */
+#define _lib_mbtowc 1 /* mbtowc() in default lib(s) */
+#define _lib_mbrtowc 1 /* mbrtowc() in default lib(s) */
+#define _lib_memalign 1 /* memalign() in default lib(s) */
+#define _lib_memchr 1 /* memchr() in default lib(s) */
+#define _lib_memcpy 1 /* memcpy() in default lib(s) */
+#define _lib_memmove 1 /* memmove() in default lib(s) */
+#define _lib_memset 1 /* memset() in default lib(s) */
+#define _lib_mkdir 1 /* mkdir() in default lib(s) */
+#define _lib_mkfifo 1 /* mkfifo() in default lib(s) */
+#define _lib_mktemp 1 /* mktemp() in default lib(s) */
+#define _lib_mktime 1 /* mktime() in default lib(s) */
+#define _lib_mount 1 /* mount() in default lib(s) */
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _lib_pathconf 1 /* pathconf() in default lib(s) */
+#define _lib_readlink 1 /* readlink() in default lib(s) */
+#define _lib_remove 1 /* remove() in default lib(s) */
+#define _lib_rename 1 /* rename() in default lib(s) */
+#define _lib_rewinddir 1 /* rewinddir() in default lib(s) */
+#define _lib_rindex 1 /* rindex() in default lib(s) */
+#define _lib_rmdir 1 /* rmdir() in default lib(s) */
+#define _lib_setlocale 1 /* setlocale() in default lib(s) */
+#define _lib_setpgid 1 /* setpgid() in default lib(s) */
+#define _lib_setpgrp 1 /* setpgrp() in default lib(s) */
+#define _lib_setreuid 1 /* setreuid() in default lib(s) */
+#define _lib_setsid 1 /* setsid() in default lib(s) */
+#define _lib_setuid 1 /* setuid() in default lib(s) */
+#define _lib_sigaction 1 /* sigaction() in default lib(s) */
+#define _lib_sigprocmask 1 /* sigprocmask() in default lib(s) */
+#define _lib_socketpair 1 /* socketpair() in default lib(s) */
+#define _lib_strchr 1 /* strchr() in default lib(s) */
+#define _lib_strcoll 1 /* strcoll() in default lib(s) */
+#define _lib_strdup 1 /* strdup() in default lib(s) */
+#define _lib_strerror 1 /* strerror() in default lib(s) */
+#define _lib_strcasecmp 1 /* strcasecmp() in default lib(s) */
+#define _lib_strncasecmp 1 /* strncasecmp() in default lib(s) */
+#define _lib_strrchr 1 /* strrchr() in default lib(s) */
+#define _lib_strstr 1 /* strstr() in default lib(s) */
+#define _lib_strxfrm 1 /* strxfrm() in default lib(s) */
+#define _lib_strftime 1 /* strftime() in default lib(s) */
+#define _lib_swab 1 /* swab() in default lib(s) */
+#define _lib_symlink 1 /* symlink() in default lib(s) */
+#define _lib_sysconf 1 /* sysconf() in default lib(s) */
+#define _lib_sysinfo 1 /* sysinfo() in default lib(s) */
+#define _lib_syslog 1 /* syslog() in default lib(s) */
+#define _lib_telldir 1 /* telldir() in default lib(s) */
+#define _lib_tmpnam 1 /* tmpnam() in default lib(s) */
+#define _lib_tzset 1 /* tzset() in default lib(s) */
+#define _lib_unlink 1 /* unlink() in default lib(s) */
+#define _lib_utime 1 /* utime() in default lib(s) */
+#define _lib_wctype 1 /* wctype() in default lib(s) */
+#define _lib_ftruncate 1 /* ftruncate() in default lib(s) */
+#define _lib_truncate 1 /* truncate() in default lib(s) */
+#define _lib_creat64 1 /* creat64() in default lib(s) */
+#define _lib_fstat64 1 /* fstat64() in default lib(s) */
+#define _lib_fstatvfs64 1 /* fstatvfs64() in default lib(s) */
+#define _lib_ftruncate64 1 /* ftruncate64() in default lib(s) */
+#define _lib_lseek64 1 /* lseek64() in default lib(s) */
+#define _lib_lstat64 1 /* lstat64() in default lib(s) */
+#define _lib_open64 1 /* open64() in default lib(s) */
+#define _lib_readdir64 1 /* readdir64() in default lib(s) */
+#define _lib_stat64 1 /* stat64() in default lib(s) */
+#define _lib_statvfs64 1 /* statvfs64() in default lib(s) */
+#define _lib_truncate64 1 /* truncate64() in default lib(s) */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _lib_strtod 1 /* strtod() in default lib(s) */
+#define _lib_strtold 1 /* strtold() in default lib(s) */
+#define _lib_strtol 1 /* strtol() in default lib(s) */
+#define _lib_strtoll 1 /* strtoll() in default lib(s) */
+#define _lib_strtoul 1 /* strtoul() in default lib(s) */
+#define _lib_strtoull 1 /* strtoull() in default lib(s) */
+#define _mem_d_ino_dirent 1 /* d_ino is a member of struct dirent */
+#define _mem_d_off_dirent 1 /* d_off is a member of struct dirent */
+#define _mem_d_reclen_dirent 1 /* d_reclen is a member of struct dirent */
+#define _mem_DIR 1 /* DIR is a non-opaque struct */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _sys_jioctl 1 /* #include <sys/jioctl.h> ok */
+#define _sys_localedef 1 /* #include <sys/localedef.h> ok */
+#define _sys_ptem 1 /* #include <sys/ptem.h> ok */
+#define _sys_resource 1 /* #include <sys/resource.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _sys_stream 1 /* #include <sys/stream.h> ok */
+#define _sys_systeminfo 1 /* #include <sys/systeminfo.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_off64_t 1 /* off64_t is a type */
+#define _typ_struct_dirent64 1 /* struct dirent64 is a type */
+#define _tst_errno 1 /* errno can be assigned */
+#define _lib_poll_fd_1 1 /* fd is first arg to poll() */
+#define _lib_poll 1 /* _lib_poll_fd_1||_lib_poll_fd_2 is true */
+#define _lib_select 1 /* select() has standard 5 arg interface */
+#define _pipe_rw 1 /* full duplex pipes */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _lib_vfork 1 /* vfork exists and it works */
+#define _real_vfork 1 /* vfork child shares data with parent */
+#define _lib_posix_spawn 1 /* posix_spawn exists and it works and its worth using */
+#define _stream_peek 1 /* ioctl(I_PEEK) works */
+#define _socket_peek 1 /* recv(MSG_PEEK) works */
+#define _hdr_string 1 /* #include <string.h> ok */
+#define _lib_memcmp 1 /* standard memcmp interface that works */
+#define _hdr_fcntl 1 /* #include <fcntl.h> ok */
+#define _hdr_signal 1 /* #include <signal.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_memccpy 1 /* standard memccpy interface that works */
+#define _lib_utime_now 1 /* utime works with 0 time vector */
+#define _UNIV_DEFAULT "att" /* default universe name */
+#define _std_cleanup 1 /* stuck with standard _cleanup */
+#define _std_strcoll 1 /* standard strcoll works */
+#if !_AST_no_spawnveg
+#define _use_spawnveg 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_limits.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_limits.h
new file mode 100644
index 0000000000..4abdc47133
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_limits.h
@@ -0,0 +1,107 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/limits.c by iffe version 2007-04-04 : : */
+#ifndef _def_limits_ast
+#define _def_limits_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+#ifndef CHAR_MAX
+#define CHAR_MAX 127
+#endif
+#ifndef CHAR_MIN
+#define CHAR_MIN -128
+#endif
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC 1000000
+#endif
+#ifndef INT_MIN
+#define INT_MIN -2147483648
+#endif
+#ifndef LLONG_MAX
+#define LLONG_MAX 9223372036854775807
+#endif
+#ifndef LLONG_MIN
+#define LLONG_MIN -9223372036854775808
+#endif
+#ifndef LONG_MAX
+#define LONG_MAX 2147483647
+#endif
+#ifndef LONG_MIN
+#define LONG_MIN -2147483648
+#endif
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 5
+#endif
+#ifndef OPEN_MAX_CEIL
+#ifndef OPEN_MAX
+#define OPEN_MAX 256
+#endif
+#define OPEN_MAX_CEIL OPEN_MAX
+#endif
+#ifndef PTHREAD_STACK_MIN
+#define PTHREAD_STACK_MIN 4096
+#endif
+#ifndef PTRDIFF_MAX
+#define PTRDIFF_MAX 2147483647
+#endif
+#ifndef PTRDIFF_MIN
+#define PTRDIFF_MIN -2147483648
+#endif
+#ifndef SCHAR_MAX
+#define SCHAR_MAX 127
+#endif
+#ifndef SCHAR_MIN
+#define SCHAR_MIN -128
+#endif
+#ifndef SHRT_MIN
+#define SHRT_MIN -32768
+#endif
+#ifndef SIG_ATOMIC_MAX
+#define SIG_ATOMIC_MAX 2147483647
+#endif
+#ifndef SIG_ATOMIC_MIN
+#define SIG_ATOMIC_MIN -2147483648
+#endif
+#ifndef SIZE_MAX
+#ifndef UINT_MAX
+#define UINT_MAX 4294967295
+#endif
+#define SIZE_MAX UINT_MAX
+#endif
+#ifndef SSIZE_MAX
+#ifndef INT_MAX
+#define INT_MAX 2147483647
+#endif
+#define SSIZE_MAX INT_MAX
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+#ifndef UCHAR_MAX
+#define UCHAR_MAX 255
+#endif
+#ifndef ULLONG_MAX
+#define ULLONG_MAX 18446744073709551615
+#endif
+#ifndef ULONG_MAX
+#define ULONG_MAX 4294967295
+#endif
+#ifndef USHRT_MAX
+#define USHRT_MAX 65535
+#endif
+#ifndef WCHAR_MAX
+#define WCHAR_MAX 2147483647
+#endif
+#ifndef WCHAR_MIN
+#define WCHAR_MIN -2147483648
+#endif
+#ifndef WINT_MAX
+#define WINT_MAX 2147483647
+#endif
+#ifndef WINT_MIN
+#define WINT_MIN -2147483648
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_map.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_map.h
new file mode 100644
index 0000000000..da0d809423
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_map.h
@@ -0,0 +1,438 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/map.c by iffe version 2007-04-04 : : */
+#ifndef _def_map_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_map_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+/*
+ * prototypes provided for standard interfaces hijacked
+ * by ast and mapped to _ast_* but already prototyped
+ * unmapped in native headers included by <ast_std.h>
+ */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+
+#define _map_libc 1
+#undef basename
+#define basename _ast_basename
+#undef dirname
+#define dirname _ast_dirname
+#undef eaccess
+#define eaccess _ast_eaccess
+#undef execvpe
+#define execvpe _ast_execvpe
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+#undef fnmatch
+#define fnmatch _ast_fnmatch
+#undef fts_children
+#define fts_children _ast_fts_children
+#undef fts_close
+#define fts_close _ast_fts_close
+#undef fts_flags
+#define fts_flags _ast_fts_flags
+#undef fts_notify
+#define fts_notify _ast_fts_notify
+#undef fts_open
+#define fts_open _ast_fts_open
+#undef fts_read
+#define fts_read _ast_fts_read
+#undef fts_set
+#define fts_set _ast_fts_set
+#undef ftw
+#define ftw _ast_ftw
+#undef ftwalk
+#define ftwalk _ast_ftwalk
+#undef ftwflags
+#define ftwflags _ast_ftwflags
+#undef getcwd
+#define getcwd _ast_getcwd
+extern __MANGLE__ char* getcwd __PROTO__((char*, size_t));
+#undef getdate
+#define getdate _ast_getdate
+#undef getopt
+#define getopt _ast_getopt
+#undef getsubopt
+#define getsubopt _ast_getsubopt
+#undef getopt_long
+#define getopt_long _ast_getopt_long
+#undef getopt_long_only
+#define getopt_long_only _ast_getopt_long_only
+#undef getwd
+#define getwd _ast_getwd
+extern __MANGLE__ char* getwd __PROTO__((char*));
+#undef glob
+#define glob _ast_glob
+#undef globfree
+#define globfree _ast_globfree
+#undef memdup
+#define memdup _ast_memdup
+#undef memfatal
+#define memfatal _ast_memfatal
+#undef memhash
+#define memhash _ast_memhash
+#undef memsum
+#define memsum _ast_memsum
+#undef mkstemp
+#define mkstemp _ast_mkstemp
+extern __MANGLE__ int mkstemp __PROTO__((char*));
+#undef mktemp
+#define mktemp _ast_mktemp
+extern __MANGLE__ char* mktemp __PROTO__((char*));
+#undef mktime
+#define mktime _ast_mktime
+#undef nftw
+#define nftw _ast_nftw
+#undef optesc
+#define optesc _ast_optesc
+#undef optget
+#define optget _ast_optget
+#undef opthelp
+#define opthelp _ast_opthelp
+#undef optjoin
+#define optjoin _ast_optjoin
+#undef optstr
+#define optstr _ast_optstr
+#undef optusage
+#define optusage _ast_optusage
+#undef pathaccess
+#define pathaccess _ast_pathaccess
+#undef pathbin
+#define pathbin _ast_pathbin
+#undef pathcanon
+#define pathcanon _ast_pathcanon
+#undef pathcat
+#define pathcat _ast_pathcat
+#undef pathcd
+#define pathcd _ast_pathcd
+#undef pathcheck
+#define pathcheck _ast_pathcheck
+#undef pathexists
+#define pathexists _ast_pathexists
+#undef pathfind
+#define pathfind _ast_pathfind
+#undef pathgetlink
+#define pathgetlink _ast_pathgetlink
+#undef pathinclude
+#define pathinclude _ast_pathinclude
+#undef pathkey
+#define pathkey _ast_pathkey
+#undef pathnative
+#define pathnative _ast_pathnative
+#undef pathpath
+#define pathpath _ast_pathpath
+#undef pathposix
+#define pathposix _ast_pathposix
+#undef pathprobe
+#define pathprobe _ast_pathprobe
+#undef pathrepl
+#define pathrepl _ast_pathrepl
+#undef pathsetlink
+#define pathsetlink _ast_pathsetlink
+#undef pathshell
+#define pathshell _ast_pathshell
+#undef pathstat
+#define pathstat _ast_pathstat
+#undef pathtemp
+#define pathtemp _ast_pathtemp
+#undef pathtmp
+#define pathtmp _ast_pathtmp
+#undef procclose
+#define procclose _ast_procclose
+#undef procfree
+#define procfree _ast_procfree
+#undef procopen
+#define procopen _ast_procopen
+#undef procrun
+#define procrun _ast_procrun
+#undef putenv
+#define putenv _ast_putenv
+#undef re_comp
+#define re_comp _ast_re_comp
+#undef re_exec
+#define re_exec _ast_re_exec
+#undef realpath
+#define realpath _ast_realpath
+extern __MANGLE__ char* realpath __PROTO__((const char*, char*));
+#undef regaddclass
+#define regaddclass _ast_regaddclass
+#undef regalloc
+#define regalloc _ast_regalloc
+#undef regcache
+#define regcache _ast_regcache
+#undef regclass
+#define regclass _ast_regclass
+#undef regcmp
+#define regcmp _ast_regcmp
+#undef regcollate
+#define regcollate _ast_regcollate
+#undef regcomb
+#define regcomb _ast_regcomb
+#undef regcomp
+#define regcomp _ast_regcomp
+#undef regdecomp
+#define regdecomp _ast_regdecomp
+#undef regdup
+#define regdup _ast_regdup
+#undef regerror
+#define regerror _ast_regerror
+#undef regex
+#define regex _ast_regex
+#undef regexec
+#define regexec _ast_regexec
+#undef regfatal
+#define regfatal _ast_regfatal
+#undef regfatalpat
+#define regfatalpat _ast_regfatalpat
+#undef regfree
+#define regfree _ast_regfree
+#undef regncomp
+#define regncomp _ast_regncomp
+#undef regnexec
+#define regnexec _ast_regnexec
+#undef regrecord
+#define regrecord _ast_regrecord
+#undef regrexec
+#define regrexec _ast_regrexec
+#undef regstat
+#define regstat _ast_regstat
+#undef regsub
+#define regsub _ast_regsub
+#undef regsubcomp
+#define regsubcomp _ast_regsubcomp
+#undef regsubexec
+#define regsubexec _ast_regsubexec
+#undef regsubflags
+#define regsubflags _ast_regsubflags
+#undef regsubfree
+#define regsubfree _ast_regsubfree
+#undef remove
+#define remove _ast_remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#undef resolvepath
+#define resolvepath _ast_resolvepath
+extern __MANGLE__ char* resolvepath __PROTO__((const char*, char*, size_t));
+#undef setenv
+#define setenv _ast_setenv
+extern __MANGLE__ int setenv __PROTO__((const char*, const char*, int));
+#undef setenviron
+#define setenviron _ast_setenviron
+#undef sigcritical
+#define sigcritical _ast_sigcritical
+#undef signal
+#define signal _ast_signal
+#undef sigunblock
+#define sigunblock _ast_sigunblock
+#undef stracmp
+#define stracmp _ast_stracmp
+#undef strcopy
+#define strcopy _ast_strcopy
+#undef strelapsed
+#define strelapsed _ast_strelapsed
+#undef stresc
+#define stresc _ast_stresc
+#undef streval
+#define streval _ast_streval
+#undef strexpr
+#define strexpr _ast_strexpr
+#undef strftime
+#define strftime _ast_strftime
+#undef strgid
+#define strgid _ast_strgid
+#undef strgrpmatch
+#define strgrpmatch _ast_strgrpmatch
+#undef strhash
+#define strhash _ast_strhash
+#undef strkey
+#define strkey _ast_strkey
+#undef strlcat
+#define strlcat _ast_strlcat
+extern __MANGLE__ size_t strlcat __PROTO__((char*, const char*, size_t));
+#undef strlcpy
+#define strlcpy _ast_strlcpy
+extern __MANGLE__ size_t strlcpy __PROTO__((char*, const char*, size_t));
+#undef strlook
+#define strlook _ast_strlook
+#undef strmatch
+#define strmatch _ast_strmatch
+#undef strmode
+#define strmode _ast_strmode
+#undef strnacmp
+#define strnacmp _ast_strnacmp
+#undef strncopy
+#define strncopy _ast_strncopy
+#undef strntod
+#define strntod _ast_strntod
+#undef strntol
+#define strntol _ast_strntol
+#undef strntold
+#define strntold _ast_strntold
+#undef strntoll
+#define strntoll _ast_strntoll
+#undef strntoul
+#define strntoul _ast_strntoul
+#undef strntoull
+#define strntoull _ast_strntoull
+#undef stropt
+#define stropt _ast_stropt
+#undef strperm
+#define strperm _ast_strperm
+#undef strpsearch
+#define strpsearch _ast_strpsearch
+#undef strptime
+#define strptime _ast_strptime
+#undef strsearch
+#define strsearch _ast_strsearch
+#undef strsort
+#define strsort _ast_strsort
+#undef strsubmatch
+#define strsubmatch _ast_strsubmatch
+#undef strsum
+#define strsum _ast_strsum
+#undef strtape
+#define strtape _ast_strtape
+#undef strtoip4
+#define strtoip4 _ast_strtoip4
+#undef strton
+#define strton _ast_strton
+#undef strtonll
+#define strtonll _ast_strtonll
+#undef struid
+#define struid _ast_struid
+#undef struniq
+#define struniq _ast_struniq
+#undef system
+#define system _ast_system
+extern __MANGLE__ int system __PROTO__((const char*));
+#undef tempnam
+#define tempnam _ast_tempnam
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+#undef tmpnam
+#define tmpnam _ast_tmpnam
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+#undef touch
+#define touch _ast_touch
+#undef wordexp
+#define wordexp _ast_wordexp
+#undef wordfree
+#define wordfree _ast_wordfree
+#undef unsetenv
+#define unsetenv _ast_unsetenv
+
+/* cannot override local malloc */
+#define _map_malloc 1
+#undef calloc
+#define calloc _ast_calloc
+extern __MANGLE__ __V_* calloc __PROTO__((size_t, size_t));
+#undef cfree
+#define cfree _ast_cfree
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+#undef free
+#define free _ast_free
+extern __MANGLE__ void free __PROTO__((__V_*));
+#undef malloc
+#define malloc _ast_malloc
+extern __MANGLE__ __V_* malloc __PROTO__((size_t));
+#undef memalign
+#define memalign _ast_memalign
+extern __MANGLE__ __V_* memalign __PROTO__((size_t, size_t));
+#undef realloc
+#define realloc _ast_realloc
+extern __MANGLE__ __V_* realloc __PROTO__((__V_*, size_t));
+#undef strdup
+#define strdup _ast_strdup
+extern __MANGLE__ char* strdup __PROTO__((const char*));
+#undef valloc
+#define valloc _ast_valloc
+extern __MANGLE__ __V_* valloc __PROTO__((size_t));
+#undef strtol
+#define strtol _ast_strtol
+#undef strtoul
+#define strtoul _ast_strtoul
+#undef strtoll
+#define strtoll _ast_strtoll
+#undef strtoull
+#define strtoull _ast_strtoull
+#undef strtod
+#define strtod _ast_strtod
+#undef strtold
+#define strtold _ast_strtold
+extern __MANGLE__ long strtol __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned long strtoul __PROTO__((const char*, char**, int));
+extern __MANGLE__ double strtod __PROTO__((const char*, char**));
+#if !_UWIN
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
+extern __MANGLE__ _ast_fltmax_t strtold __PROTO__((const char*, char**));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+extern __MANGLE__ _ast_intmax_t strtoll __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned _ast_intmax_t strtoull __PROTO__((const char*, char**, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_mmap.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_mmap.h
new file mode 100644
index 0000000000..4a54d5bc78
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_mmap.h
@@ -0,0 +1,26 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/mmap by iffe version 2007-04-04 : : */
+#ifndef _def_mmap_ast
+#define _def_mmap_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_mmap 1 /* standard mmap interface that works */
+#define _lib_mmap64 1 /* mmap64 interface and implementation work */
+#define _mmap_anon 1 /* use mmap MAP_ANON to get raw memory */
+#define _mmap_devzero 1 /* use mmap on /dev/zero to get raw memory */
+
+/* some systems get it wrong but escape concise detection */
+#ifndef _NO_MMAP
+#if __CYGWIN__
+#define _NO_MMAP 1
+#endif
+#endif
+
+#if _NO_MMAP
+#undef _lib_mmap
+#undef _lib_mmap64
+#undef _mmap_anon
+#undef _mmap_devzero
+#undef _mmap_worthy
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_mode.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_mode.h
new file mode 100644
index 0000000000..4347cc2d13
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_mode.h
@@ -0,0 +1,14 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/mode.c by iffe version 2007-04-04 : : */
+#ifndef _def_mode_ast
+#define _def_mode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define S_ITYPE(m) ((m)&S_IFMT)
+
+#define S_IPERM (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
+
+#define _S_IDPERM 1
+#define _S_IDTYPE 1
+
+#define BUFFERSIZE 8192
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_nl_types.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_nl_types.h
new file mode 100644
index 0000000000..57348178a9
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_nl_types.h
@@ -0,0 +1,102 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/nl_types by iffe version 2007-04-04 : : */
+
+#ifndef _def_nl_types_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_nl_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_nl_langinfo 1 /* nl_langinfo() in default lib(s) */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_langinfo 1 /* #include <langinfo.h> ok */
+#define _nxt_nl_types <../include/nl_types.h> /* include path for the native <nl_types.h> */
+#define _nxt_nl_types_str "../include/nl_types.h" /* include string for the native <nl_types.h> */
+#include <limits.h>
+#include <../include/nl_types.h> /* the native nl_types.h */
+
+#undef NL_SETMAX
+#define NL_SETMAX 1023
+#undef NL_MSGMAX
+#define NL_MSGMAX 32767
+#undef nl_catd
+#define nl_catd _ast_nl_catd
+#undef catopen
+#define catopen _ast_catopen
+#undef catgets
+#define catgets _ast_catgets
+#undef catclose
+#define catclose _ast_catclose
+
+typedef __V_* nl_catd;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ nl_catd catopen __PROTO__((const char*, int));
+extern __MANGLE__ char* catgets __PROTO__((nl_catd, int, int, const char*));
+extern __MANGLE__ int catclose __PROTO__((nl_catd));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_param.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_param.h
new file mode 100644
index 0000000000..577a0edf88
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_param.h
@@ -0,0 +1,9 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/param.sh by iffe version 2007-04-04 : : */
+#ifndef _def_param_ast
+#define _def_param_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#include <sys/param.h>
+#ifndef S_IFDIR
+#include <sys/stat.h>
+#endif
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_standards.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_standards.h
new file mode 100644
index 0000000000..b859405156
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_standards.h
@@ -0,0 +1,28 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/standards by iffe version 2007-04-04 : : */
+#ifndef _def_standards_ast
+#define _def_standards_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* _ALL_SOURCE & _ISOC99_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works */
+#ifndef _ALL_SOURCE
+#define _ALL_SOURCE 1
+#endif
+#ifndef _ISOC99_SOURCE
+#define _ISOC99_SOURCE 1
+#endif
+#ifndef _POSIX_SOURCE
+#define _POSIX_SOURCE 1
+#endif
+#ifndef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 21000101L
+#endif
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 9900
+#endif
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#ifndef __EXTENSIONS__
+#define __EXTENSIONS__ 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_stdio.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_stdio.h
new file mode 100644
index 0000000000..f531374a22
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_stdio.h
@@ -0,0 +1,579 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/stdio by iffe version 2007-04-04 : : */
+
+#ifndef _SFSTDIO_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SFSTDIO_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define __FILE_typedef 1
+#define _FILE_DEFINED 1
+#define _FILE_defined 1
+#define _FILEDEFED 1
+
+#ifndef __FILE_TAG
+#define __FILE_TAG _sfio_s
+#endif
+
+#undef FILE
+#undef _FILE
+#undef fpos_t
+#undef fpos64_t
+
+typedef struct _sfio_s _sfio_FILE;
+
+#define FILE _sfio_FILE
+#define _FILE FILE
+
+#if !defined(__FILE) && !__CYGWIN__
+#undef __FILE
+#define __FILE FILE
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define BUFSIZ SF_BUFSIZE
+
+#else
+
+#ifndef BUFSIZ
+#define BUFSIZ 8192
+#endif
+
+#ifndef EOF
+#define EOF (-1)
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+#include <ast_std.h>
+
+#include <sfio_s.h>
+
+#if __cplusplus
+#define _sf_(f) (f)
+#else
+#define _sf_(f) ((struct _sfio_s*)(f))
+#endif
+
+#define _SF_EOF 0000200
+#define _SF_ERROR 0000400
+
+#endif
+
+#ifdef _NO_LARGEFILE64_SOURCE
+#undef _LARGEFILE64_SOURCE
+#endif
+
+#ifdef _LARGEFILE64_SOURCE
+#undef off_t
+#endif
+
+#define fpos_t _ast_fpos_t
+#if _typ_int64_t
+#define fpos64_t _ast_fpos_t
+#endif
+
+typedef struct _ast_fpos_s
+{
+ intmax_t _sf_offset;
+ unsigned char _sf_state[64 - sizeof(intmax_t)];
+} _ast_fpos_t;
+
+#define _base _data
+#define _ptr _next
+#define _IOFBF 0
+#define _IONBF 1
+#define _IOLBF 2
+
+#if defined(__cplusplus) && defined(__THROW) && !defined(_UWIN)
+
+#undef FILE
+#define FILE FILE
+typedef struct _sfio_s FILE;
+
+#undef strerror
+extern __MANGLE__ char* strerror(int) __THROW;
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#endif
+
+#ifndef FILENAME_MAX
+#define FILENAME_MAX 1024
+#endif
+#ifndef FOPEN_MAX
+#define FOPEN_MAX 20
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+
+#define _doprnt _ast_doprnt
+#define _doscan _ast_doscan
+#define asprintf _ast_asprintf
+#define clearerr _ast_clearerr
+#define fclose _ast_fclose
+#define fdopen _ast_fdopen
+#define fflush _ast_fflush
+#define fgetc _ast_fgetc
+#define fgetpos _ast_fgetpos
+#define fgetpos64 _ast_fgetpos64
+#define fgets _ast_fgets
+#define fopen _ast_fopen
+#define fprintf _ast_fprintf
+#define fpurge _ast_fpurge
+#define fputs _ast_fputs
+#define fread _ast_fread
+#define freopen _ast_freopen
+#define fscanf _ast_fscanf
+#define fseek _ast_fseek
+#define fseek64 _ast_fseek64
+#define fseeko _ast_fseeko
+#define fseeko64 _ast_fseeko64
+#define fsetpos _ast_fsetpos
+#define fsetpos64 _ast_fsetpos64
+#define ftell _ast_ftell
+#define ftell64 _ast_ftell64
+#define ftello _ast_ftello
+#define ftello64 _ast_ftello64
+#define fwrite _ast_fwrite
+#define gets _ast_gets
+#define getw _ast_getw
+#define pclose _ast_pclose
+#define popen _ast_popen
+#define printf _ast_printf
+#define puts _ast_puts
+#define putw _ast_putw
+#define rewind _ast_rewind
+#define scanf _ast_scanf
+#define setbuf _ast_setbuf
+#undef setbuffer
+#define setbuffer _ast_setbuffer
+#define setlinebuf _ast_setlinebuf
+#define setvbuf _ast_setvbuf
+#define snprintf _ast_snprintf
+#define sprintf _ast_sprintf
+#define sscanf _ast_sscanf
+#define tmpfile _ast_tmpfile
+#define ungetc _ast_ungetc
+#define vasprintf _ast_vasprintf
+#define vfprintf _ast_vfprintf
+#define vfscanf _ast_vfscanf
+#define vprintf _ast_vprintf
+#define vscanf _ast_vscanf
+#define vsnprintf _ast_vsnprintf
+#define vsprintf _ast_vsprintf
+#define vsscanf _ast_vsscanf
+#define fcloseall _ast_fcloseall
+#define fmemopen _ast_fmemopen
+#define __getdelim _ast___getdelim
+#define getdelim _ast_getdelim
+#define getline _ast_getline
+#define clearerr_unlocked _ast_clearerr_unlocked
+#define feof_unlocked _ast_feof_unlocked
+#define ferror_unlocked _ast_ferror_unlocked
+#define fflush_unlocked _ast_fflush_unlocked
+#define fgetc_unlocked _ast_fgetc_unlocked
+#define fgets_unlocked _ast_fgets_unlocked
+#define fileno_unlocked _ast_fileno_unlocked
+#define fputc_unlocked _ast_fputc_unlocked
+#define fputs_unlocked _ast_fputs_unlocked
+#define fread_unlocked _ast_fread_unlocked
+#define fwrite_unlocked _ast_fwrite_unlocked
+#define getc_unlocked _ast_getc_unlocked
+#define getchar_unlocked _ast_getchar_unlocked
+#define putc_unlocked _ast_putc_unlocked
+#define putchar_unlocked _ast_putchar_unlocked
+
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef P_tmpdir
+#define P_tmpdir "/var/tmp/" /*NOCATLITERAL*/
+#endif
+#ifndef L_ctermid
+#define L_ctermid 9
+#endif
+#ifndef L_tmpnam
+#define L_tmpnam 25
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#if defined(__cplusplus) && defined(__THROW)
+extern __MANGLE__ char* ctermid(char*) __THROW;
+#else
+extern __MANGLE__ char* ctermid __PROTO__((char*));
+#endif
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+extern __MANGLE__ void perror __PROTO__((const char*));
+#ifndef _AST_STD_H
+#ifndef remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#endif
+#ifndef rename
+extern __MANGLE__ int rename __PROTO__((const char*, const char*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#ifdef _LARGEFILE64_SOURCE
+
+#undef fpos_t
+#undef off_t
+#undef fgetpos
+#undef fsetpos
+#undef fseek
+#undef fseeko
+#undef ftell
+#undef ftello
+
+#define fpos_t fpos64_t
+#if _typ_off64_t
+#define off_t off64_t
+#else
+#define off_t int64_t
+#endif
+
+#define fgetpos fgetpos64
+#define fsetpos fsetpos64
+#define fseek fseek64
+#define fseeko fseeko64
+#define ftell ftell64
+#define ftello ftello64
+
+#endif
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_DLL && _DLL_INDIRECT_DATA
+
+#define stdin ((FILE*)_ast_dll->_ast_stdin)
+#define stdout ((FILE*)_ast_dll->_ast_stdout)
+#define stderr ((FILE*)_ast_dll->_ast_stderr)
+
+#else
+
+#define stdin (&_Sfstdin)
+#define stdout (&_Sfstdout)
+#define stderr (&_Sfstderr)
+
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define feof(f) sfeof(f)
+#define ferror(f) sferror(f)
+#define fileno(f) sffileno(f)
+#define fputc(c,f) sfputc(f,c)
+#define getc(f) sfgetc(f)
+#define getchar() sfgetc(sfstdin)
+#define putc(c,f) sfputc(f,c)
+#define putchar(c) sfputc(sfstdout,c)
+
+#else
+
+#if !_UWIN
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+#endif
+
+extern __MANGLE__ FILE _Sfstdin;
+extern __MANGLE__ FILE _Sfstdout;
+extern __MANGLE__ FILE _Sfstderr;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define feof(f) (_sf_(f)->_flags&_SF_EOF)
+#define ferror(f) (_sf_(f)->_flags&_SF_ERROR)
+#define fileno(f) (_sf_(f)->_file)
+#define fputc(c,f) (_sf_(f)->_next>=_sf_(f)->_endw?_sfflsbuf(_sf_(f),(int)((unsigned char)(c))):(int)(*_sf_(f)->_next++=(unsigned char)(c)))
+#define getc(f) (_sf_(f)->_next>=_sf_(f)->_endr?_sffilbuf(_sf_(f),0):(int)(*_sf_(f)->_next++))
+#define getchar() getc(stdin)
+#define putc(c,f) fputc(c,f)
+#define putchar(c) fputc(c,stdout)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _sffilbuf __PROTO__((FILE*, int));
+extern __MANGLE__ int _sfflsbuf __PROTO__((FILE*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_sys.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_sys.h
new file mode 100644
index 0000000000..091269fd30
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_sys.h
@@ -0,0 +1,151 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/sys by iffe version 2007-04-04 : : */
+
+#ifndef _AST_SYS_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_SYS_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#if __mips == 2 && !defined(_NO_LARGEFILE64_SOURCE)
+#define _NO_LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_NO_LARGEFILE64_SOURCE) && _typ_off64_t && _lib_lseek64 && _lib_stat64
+#if !defined(_LARGEFILE64_SOURCE)
+#define _LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_LARGEFILE_SOURCE)
+#define _LARGEFILE_SOURCE 1
+#endif
+#else
+#undef _LARGEFILE64_SOURCE
+#undef _LARGEFILE_SOURCE
+#undef _typ_off64_t
+#undef _typ_struct_dirent64
+#undef _lib_creat64
+#undef _lib_fstat64
+#undef _lib_fstatvfs64
+#undef _lib_ftruncate64
+#undef _lib_lseek64
+#undef _lib_lstat64
+#undef _lib_mmap64
+#undef _lib_open64
+#undef _lib_readdir64
+#undef _lib_stat64
+#undef _lib_statvfs64
+#undef _lib_truncate64
+#endif
+#if defined(__STDC__) && !defined(__USE_FIXED_PROTOTYPES__)
+#define __USE_FIXED_PROTOTYPES__ 1 /* kick gcc out of the past */
+#endif
+#include <stdlib.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <locale.h>
+#include <sys/localedef.h>
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _typ_dev_t 1 /* dev_t is a type */
+#define _typ_nlink_t 1 /* nlink_t is a type */
+#define _typ_gid_t 1 /* gid_t is a type */
+#define _typ_mode_t 1 /* mode_t is a type */
+#define _typ_uid_t 1 /* uid_t is a type */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _typ_wchar_t 1 /* wchar_t is a type */
+#define _typ_pid_t 1 /* pid_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _typ_wint_t 1 /* wint_t is a type */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _typ_socklen_t 1 /* socklen_t is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_ino_t 1 /* ino_t is a type */
+#define _typ_off_t 1 /* off_t is a type */
+#define _typ_ptrdiff_t 1 /* ptrdiff_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#define _typ_div_t 1 /* div_t is a type */
+#define _typ_ldiv_t 1 /* ldiv_t is a type */
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+extern __MANGLE__ int eaccess __PROTO__((const char*, int));
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+extern __MANGLE__ __V_* pvalloc __PROTO__((size_t));
+extern __MANGLE__ pid_t spawnveg __PROTO__((const char*, char* const[], char* const[], pid_t));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#if !defined(va_start)
+#if defined(__STDARG__)
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_time.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_time.h
new file mode 100644
index 0000000000..c20d4cad00
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_time.h
@@ -0,0 +1,83 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/time by iffe version 2007-04-04 : : */
+
+#ifndef _def_time_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_time_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_nanosleep 1 /* nanosleep() in default lib(s) */
+#define _lib_usleep 1 /* usleep() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#include <sys/time.h>
+
+#include <sys/times.h>
+
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC CLK_TCK
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_tty.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_tty.h
new file mode 100644
index 0000000000..dce44fe8e3
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_tty.h
@@ -0,0 +1,134 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/tty by iffe version 2007-04-04 : : */
+#ifndef _def_tty_ast
+#define _def_tty_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_termios 1 /* #include <termios.h> ok */
+#define _hdr_termio 1 /* #include <termio.h> ok */
+#define _hdr_sgtty 1 /* #include <sgtty.h> ok */
+#define _sys_termios 1 /* #include <sys/termios.h> ok */
+#define _sys_termio 1 /* #include <sys/termio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _lib_tcgetattr 1 /* tcgetattr() in default lib(s) */
+#define _lib_tcgetpgrp 1 /* tcgetpgrp() in default lib(s) */
+#define _mac__POSIX_VDISABLE 1 /* _POSIX_VDISABLE is a macro */
+
+#ifdef _hdr_termios
+# if _mac__POSIX_VDISABLE
+# undef _POSIX_VDISABLE
+# endif
+# include <termios.h>
+#else
+# if defined(_sys_termios) && defined(_lib_tcgetattr)
+# include <sys/termios.h>
+# define _hdr_termios 1
+# else
+# undef _sys_termios
+# endif /* _sys_termios */
+#endif /* _hdr_termios */
+
+#ifdef _hdr_termios
+# undef _hdr_sgtty
+# undef tcgetattr
+# undef tcsetattr
+# undef tcgetpgrp
+# undef tcsetpgrp
+# undef cfgetospeed
+# ifndef TCSANOW
+# define TCSANOW TCSETS
+# define TCSADRAIN TCSETSW
+# define TCSAFLUSH TCSETSF
+# endif /* TCSANOW */
+ /* The following corrects bugs in some implementations */
+# if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
+# define TCSAFLUSH TCSADFLUSH
+# endif /* TCSADFLUSH */
+# ifndef _lib_tcgetattr
+# undef tcgetattr
+# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
+# undef tcsetattr
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# undef cfgetospeed
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# endif /* _lib_tcgetattr */
+# undef TIOCGETC
+#else
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfgetispeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfsetispeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# define cfsetospeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# ifdef _hdr_termio
+# include <termio.h>
+# else
+# ifdef _sys_termio
+# include <sys/termio.h>
+# define _hdr_termio 1
+# endif /* _sys_termio */
+# endif /* _hdr_termio */
+# ifdef _hdr_termio
+# define termios termio
+# undef TIOCGETC
+# define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+
+# ifdef _sys_bsdtty
+# include <sys/bsdtty.h>
+# endif /* _sys_bsdtty */
+# else
+# ifdef _hdr_sgtty
+# include <sgtty.h>
+# ifndef LPENDIN
+# ifdef _sys_nttyio
+# include <sys/nttyio.h>
+# endif /* _sys_nttyio */
+# endif /* LPENDIN */
+# define termios sgttyb
+# ifdef TIOCSETN
+# undef TCSETAW
+# endif /* TIOCSETN */
+# ifdef TIOCGETP
+# define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# else
+# define tcgetattr(fd,tty) gtty(fd, tty)
+# define tcsetattr(fd,action,tty) stty(fd, tty)
+# endif /* TIOCGETP */
+# else
+# ifdef _sys_ttyio
+# include <sys/ttyio.h>
+# endif
+# endif /* _hdr_sgtty */
+# endif /* hdr_termio */
+
+# ifndef TCSANOW
+# ifdef TCSETAW
+# define TCSANOW TCSETA
+# define TCSAFLUSH TCSETAF
+# else
+# ifdef TIOCSETN
+# define TCSANOW TIOCSETN
+# define TCSADRAIN TIOCSETN
+# define TCSAFLUSH TIOCSETP
+# endif /* TIOCSETN */
+# endif /* TCSETAW */
+# endif /* TCSANOW */
+#endif /* _hdr_termios */
+
+/* set ECHOCTL if driver can echo control charaters as ^c */
+#ifdef LCTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LCTLECH
+# endif /* !ECHOCTL */
+#endif /* LCTLECH */
+#ifdef LNEW_CTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LNEW_CTLECH
+# endif /* !ECHOCTL */
+#endif /* LNEW_CTLECH */
+#ifdef LNEW_PENDIN
+# ifndef PENDIN
+# define PENDIN LNEW_PENDIN
+# endif /* !PENDIN */
+#endif /* LNEW_PENDIN */
+
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_types.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_types.h
new file mode 100644
index 0000000000..343b5954a0
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_types.h
@@ -0,0 +1,5 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_types_ast
+#define _def_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_vfork.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_vfork.h
new file mode 100644
index 0000000000..d70a055a5b
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_vfork.h
@@ -0,0 +1,68 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/vfork by iffe version 2007-04-04 : : */
+
+#ifndef _def_vfork_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_vfork_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+extern __MANGLE__ pid_t vfork __PROTO__((void));
+#pragma unknown_control_flow(vfork)
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_wait.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_wait.h
new file mode 100644
index 0000000000..3bcc94d23b
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_wait.h
@@ -0,0 +1,11 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/wait by iffe version 2007-04-04 : : */
+#ifndef _def_wait_ast
+#define _def_wait_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_wait 1 /* wait() in default lib(s) */
+#define _lib_wait3 1 /* wait3() in default lib(s) */
+#define _lib_wait4 1 /* wait4() in default lib(s) */
+#define _lib_waitpid 1 /* waitpid() in default lib(s) */
+#define _sys_wait 1 /* #include <sys/wait.h> ok */
+#define _ok_wif 1 /* posix wait macros ok */
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/ast_wchar.h b/usr/src/lib/libast/sparc/src/lib/libast/ast_wchar.h
new file mode 100644
index 0000000000..03e01de07a
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/ast_wchar.h
@@ -0,0 +1,187 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/wchar by iffe version 2007-04-04 : : */
+
+#ifndef _def_wchar_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_wchar_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _lib_mbstowcs 1 /* mbstowcs() in default lib(s) */
+#define _lib_wctomb 1 /* wctomb() in default lib(s) */
+#define _lib_wcrtomb 1 /* wcrtomb() in default lib(s) */
+#define _lib_wcslen 1 /* wcslen() in default lib(s) */
+#define _lib_wcstombs 1 /* wcstombs() in default lib(s) */
+#define _lib_wcwidth 1 /* wcwidth() in default lib(s) */
+#define _lib_towlower 1 /* towlower() in default lib(s) */
+#define _lib_towupper 1 /* towupper() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_mbstate_t 1 /* mbstate_t is a type */
+#define _nxt_wchar <../include/wchar.h> /* include path for the native <wchar.h> */
+#define _nxt_wchar_str "../include/wchar.h" /* include string for the native <wchar.h> */
+#ifndef _SFSTDIO_H
+#include <ast_common.h>
+#include <stdio.h>
+#endif
+#if _hdr_wchar && defined(_nxt_wchar)
+#include <../include/wchar.h> /* the native wchar.h */
+#endif
+#if _hdr_wctype
+#include <wctype.h>
+#endif
+
+#ifndef WEOF
+#define WEOF (-1)
+#endif
+
+#undef fgetwc
+#undef fgetws
+#undef fputwc
+#undef fputws
+#undef getwc
+#undef getwchar
+#undef getws
+#undef putwc
+#undef putwchar
+#undef ungetwc
+
+#define fgetwc _ast_fgetwc
+#define fgetws _ast_fgetws
+#define fputwc _ast_fputwc
+#define fputws _ast_fputws
+#define fwide _ast_fwide
+#define fwprintf _ast_fwprintf
+#define fwscanf _ast_fwscanf
+#define getwc _ast_getwc
+#define getwchar _ast_getwchar
+#define getws _ast_getws
+#define putwc _ast_putwc
+#define putwchar _ast_putwchar
+#define swprintf _ast_swprintf
+#define swscanf _ast_swscanf
+#define ungetwc _ast_ungetwc
+#define vfwprintf _ast_vfwprintf
+#define vfwscanf _ast_vfwscanf
+#define vswprintf _ast_vswprintf
+#define vswscanf _ast_vswscanf
+#define vwprintf _ast_vwprintf
+#define vwscanf _ast_vwscanf
+#define wprintf _ast_wprintf
+#define wscanf _ast_wscanf
+
+#if !_typ_mbstate_t
+#undef _typ_mbstate_t
+#define _typ_mbstate_t 1
+typedef char mbstate_t;
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#if !_lib_mbstowcs
+extern __MANGLE__ size_t mbstowcs __PROTO__((wchar_t*, const char*, size_t));
+#endif
+#if !_lib_wctomb
+extern __MANGLE__ int wctomb __PROTO__((char*, wchar_t));
+#endif
+#if !_lib_wcrtomb
+extern __MANGLE__ size_t wcrtomb __PROTO__((char*, wchar_t, mbstate_t*));
+#endif
+#if !_lib_wcslen
+extern __MANGLE__ size_t wcslen __PROTO__((const wchar_t*));
+#endif
+#if !_lib_wcstombs
+extern __MANGLE__ size_t wcstombs __PROTO__((char*, const wchar_t*, size_t));
+#endif
+
+extern __MANGLE__ int fwprintf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ int fwscanf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ wint_t fgetwc __PROTO__((FILE*));
+extern __MANGLE__ wchar_t* fgetws __PROTO__((wchar_t*, int, FILE*));
+extern __MANGLE__ wint_t fputwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ int fputws __PROTO__((const wchar_t*, FILE*));
+extern __MANGLE__ int fwide __PROTO__((FILE*, int));
+extern __MANGLE__ wint_t getwc __PROTO__((FILE*));
+extern __MANGLE__ wint_t getwchar __PROTO__((void));
+extern __MANGLE__ wchar_t* getws __PROTO__((wchar_t*));
+extern __MANGLE__ wint_t putwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ wint_t putwchar __PROTO__((wchar_t));
+extern __MANGLE__ int swprintf __PROTO__((wchar_t*, size_t, const wchar_t*, ...));
+extern __MANGLE__ int swscanf __PROTO__((const wchar_t*, const wchar_t*, ...));
+extern __MANGLE__ wint_t ungetwc __PROTO__((wint_t, FILE*));
+extern __MANGLE__ int vfwprintf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vfwscanf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vwprintf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vwscanf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vswprintf __PROTO__((wchar_t*, size_t, const wchar_t*, va_list));
+extern __MANGLE__ int vswscanf __PROTO__((const wchar_t*, const wchar_t*, va_list));
+extern __MANGLE__ int wprintf __PROTO__((const wchar_t*, ...));
+extern __MANGLE__ int wscanf __PROTO__((const wchar_t*, ...));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/conftab.c b/usr/src/lib/libast/sparc/src/lib/libast/conftab.c
new file mode 100644
index 0000000000..49d887d6d2
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/conftab.c
@@ -0,0 +1,451 @@
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+#include "FEATURE/standards"
+#include "FEATURE/common"
+#include <sys/types.h>
+#include <limits.h>
+#include <unistd.h>
+#if !defined(SYS_NMLEN)
+#define SYS_NMLEN 9
+#endif
+#include <sys/systeminfo.h>
+#include "FEATURE/param"
+#include "conftab.h"
+
+/* : : generated by conf from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/comp/conf.tab : : */
+
+/*
+ * prefix strings -- the first few are indexed by Conf_t.standard
+ */
+
+const Prefix_t prefix[] =
+{
+ "C", 1, CONF_C, -1,
+ "POSIX", 5, CONF_POSIX, -1,
+ "SVID", 4, CONF_SVID, -1,
+ "XOPEN", 5, CONF_XOPEN, -1,
+ "SUN", 3, CONF_SUN, -1,
+ "XBS5", 4, CONF_XBS5, -1,
+ "SCO", 3, CONF_SCO, -1,
+ "AST", 3, CONF_AST, -1,
+ "AES", 3, CONF_AES, -1,
+ "XPG", 3, CONF_XPG, -1,
+ "GNU", 3, CONF_GNU, -1,
+ "TRUSTEDBSD", 10, CONF_TRUSTEDBSD, -1,
+ "XX", 2, CONF_POSIX, CONF_nop,
+ "CS", 2, CONF_POSIX, CONF_confstr,
+ "PC", 2, CONF_POSIX, CONF_pathconf,
+ "SC", 2, CONF_POSIX, CONF_sysconf,
+ "SI", 2, CONF_SVID, CONF_sysinfo,
+};
+
+int prefix_elements = (int)sizeof(prefix) / (int)sizeof(prefix[0]);
+
+/*
+ * conf strings sorted in ascending order
+ */
+
+const Conf_t conf[] =
+{
+{ "ABI_AIO_XFER_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ABI_ASYNCHRONOUS_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ABI_ASYNC_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ADVISORY_INFO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_ADVISORY_INFO },
+{ "AIO_LISTIO_MAX", { 0, 0 }, { _POSIX_AIO_LISTIO_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_AIO_LISTIO_MAX },
+{ "AIO_MAX", { 0, 0 }, { _POSIX_AIO_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_AIO_MAX },
+{ "AIO_PRIO_DELTA_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, _SC_AIO_PRIO_DELTA_MAX },
+{ "ALLOC_SIZE_MIN", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_ALLOC_SIZE_MIN },
+{ "ARCHITECTURE", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "ARG_MAX", { 0, 0 }, { _POSIX_ARG_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_ARG_MAX },
+{ "ASYNCHRONOUS_IO", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_ASYNCHRONOUS_IO },
+{ "ASYNC_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_ASYNC_IO },
+{ "ATEXIT_MAX", { 0, 0 }, { 32, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_XOPEN, 1, CONF_sysconf, _SC_ATEXIT_MAX },
+{ "AUDIT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "AVAIL_PROCESSORS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "AVPHYS_PAGES", { 0, 0 }, { 0, 0 }, 0, CONF_SUN, 1, CONF_sysconf, _SC_AVPHYS_PAGES },
+{ "BARRIERS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_BARRIERS },
+{ "BC_BASE_MAX", { 0, 0 }, { _POSIX2_BC_BASE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_BC_BASE_MAX },
+{ "BC_DIM_MAX", { 0, 0 }, { _POSIX2_BC_DIM_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_BC_DIM_MAX },
+{ "BC_SCALE_MAX", { 0, 0 }, { _POSIX2_BC_SCALE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_BC_SCALE_MAX },
+{ "BC_STRING_MAX", { 0, 0 }, { _POSIX2_BC_STRING_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_BC_STRING_MAX },
+{ "BUSTYPES", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "CHARCLASS_NAME_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "CHAR_BIT", { 8, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "CHAR_MAX", { 127, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "CHAR_MIN", { -128, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "CHAR_TERM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_CHAR_TERM },
+{ "CHILD_MAX", { 0, 0 }, { _POSIX_CHILD_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_CHILD_MAX },
+{ "CHOWN_RESTRICTED", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_CHOWN_RESTRICTED },
+{ "CKPT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "CLK_TCK", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_POSIX, 1, CONF_sysconf, _SC_CLK_TCK },
+{ "CLOCKRES_MIN", { 0, 0 }, { _POSIX_CLOCKRES_MIN, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_PREFIX_ONLY|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "CLOCKS_PER_SEC", { 1000000, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_LIMIT|CONF_LIMIT_DEF, CONF_POSIX, 1, CONF_nop, -1 },
+{ "CLOCK_SELECTION", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_CLOCK_SELECTION },
+{ "COLL_WEIGHTS_MAX", { 0, 0 }, { _POSIX2_COLL_WEIGHTS_MAX, 0 }, CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_COLL_WEIGHTS_MAX },
+{ "CPUTIME", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_CPUTIME },
+{ "CPU_KEYBITS1", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "CPU_VERSION", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "CRYPT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_CRYPT },
+{ "C_BIND", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 2, CONF_sysconf, _SC_2_C_BIND },
+{ "C_DEV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 2, CONF_sysconf, _SC_2_C_DEV },
+{ "C_VERSION", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 2, CONF_sysconf, _SC_2_C_VERSION },
+{ "DATAKEYS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "DELAYTIMER_MAX", { 0, 0 }, { _POSIX_DELAYTIMER_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_DELAYTIMER_MAX },
+{ "ENH_I18N", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_ENH_I18N },
+{ "EQUIV_CLASS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "EXEC_INTERPRETER_LENGTH", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "EXPR_NEST_MAX", { 0, 0 }, { _POSIX2_EXPR_NEST_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_EXPR_NEST_MAX },
+{ "FCHR_MAX", { 0, 0 }, { LONG_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "FILESIZEBITS", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_FILESIZEBITS },
+{ "FILE_LOCKING", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "FORT_DEV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_FORT_DEV },
+{ "FORT_RUN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_FORT_RUN },
+{ "FSYNC", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_FSYNC },
+{ "GETGR_R_SIZE_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_sysconf, _SC_GETGR_R_SIZE_MAX },
+{ "GETPW_R_SIZE_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_sysconf, _SC_GETPW_R_SIZE_MAX },
+{ "HOSTID", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "HOSTNAME", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "HOST_NAME_MAX", { 0, 0 }, { _POSIX_HOST_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_HOST_NAME_MAX },
+{ "HW_PROVIDER", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "HW_SERIAL", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ILP32_OFF32", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XBS5, 1, CONF_sysconf, -1 },
+{ "ILP32_OFF32_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFF32_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFF32_LIBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFF32_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFFBIG", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XBS5, 1, CONF_sysconf, -1 },
+{ "ILP32_OFFBIG_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFFBIG_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFFBIG_LIBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFFBIG_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "INITTAB_NAME", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "INT_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "INT_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "IOV_MAX", { 0, 0 }, { _XOPEN_IOV_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_XOPEN, 1, CONF_sysconf, _SC_IOV_MAX },
+{ "IO_TYPE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "IPV6", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_IPV6 },
+{ "IP_SECOPTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "JOB_CONTROL", { 0, 0 }, { 1, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_JOB_CONTROL },
+{ "KERNEL_CLIST", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_CLIST_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_DISK", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_DISK_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_DMABUF", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_DMABUF_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_FILE", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_FILE_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_FLCKREC", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_FLCKREC_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_INODE", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_INODE_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_MOUNT", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_MOUNT_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_PINODE", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_PINODE_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_PROC", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_PROC_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_REGION", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_REGION_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_S5INODE", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_S5INODE_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_STAMP", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "KERN_POINTERS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "KERN_SIM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "LEGACY", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, -1 },
+{ "LFS64_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS64_CFLAGS },
+{ "LFS64_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS64_LDFLAGS },
+{ "LFS64_LIBS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS64_LIBS },
+{ "LFS64_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS64_LINTFLAGS },
+{ "LFS_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_CFLAGS },
+{ "LFS_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_LDFLAGS },
+{ "LFS_LIBS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_LIBS },
+{ "LFS_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_LINTFLAGS },
+{ "LINE_MAX", { 0, 0 }, { _POSIX2_LINE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_LINE_MAX },
+{ "LINK_MAX", { 0, 0 }, { _POSIX_LINK_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_LINK_MAX },
+{ "LLONG_MAX", { 9223372036854775807LL, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "LLONG_MIN", { (-9223372036854775807LL-1LL), 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "LOCALEDEF", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_LOCALEDEF },
+{ "LOGIN_NAME_MAX", { 0, 0 }, { _POSIX_LOGIN_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_LOGIN_NAME_MAX },
+{ "LOGNAME_MAX", { 0, 0 }, { 8, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, _SC_LOGNAME_MAX },
+{ "LONG_BIT", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "LONG_MAX", { 2147483647, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "LONG_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "LP64_OFF64", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XBS5, 1, CONF_sysconf, -1 },
+{ "LP64_OFF64_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LP64_OFF64_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LP64_OFF64_LIBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LP64_OFF64_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LPBIG_OFFBIG", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XBS5, 1, CONF_sysconf, -1 },
+{ "LPBIG_OFFBIG_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LPBIG_OFFBIG_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LPBIG_OFFBIG_LIBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LPBIG_OFFBIG_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "MACHINE", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "MAPPED_FILES", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MAPPED_FILES },
+{ "MAX_CANON", { 0, 0 }, { _POSIX_MAX_CANON, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_MAX_CANON },
+{ "MAX_INPUT", { 0, 0 }, { _POSIX_MAX_INPUT, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_MAX_INPUT },
+{ "MB_LEN_MAX", { 5, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "MCAS_OFFSET", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "MEMLOCK", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MEMLOCK },
+{ "MEMLOCK_RANGE", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MEMLOCK_RANGE },
+{ "MEMORY_PROTECTION", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MEMORY_PROTECTION },
+{ "MESSAGE_PASSING", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MESSAGE_PASSING },
+{ "MMAP_FIXED_ALIGNMENT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "MONOTONIC_CLOCK", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MONOTONIC_CLOCK },
+{ "MQ_OPEN_MAX", { 0, 0 }, { _POSIX_MQ_OPEN_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_MQ_OPEN_MAX },
+{ "MQ_PRIO_MAX", { 0, 0 }, { _POSIX_MQ_PRIO_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_MQ_PRIO_MAX },
+{ "MSEM_LOCKID", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "MULTI_PROCESS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "NACLS_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "NAME_MAX", { 0, 0 }, { _POSIX_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_NAME_MAX },
+{ "NGROUPS_MAX", { 0, 0 }, { _POSIX_NGROUPS_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_NGROUPS_MAX },
+{ "NL_ARGMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_LANGMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NL_MSGMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_NMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_SETMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_SPECMAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NL_TEXTMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NO_TRUNC", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_NO_TRUNC },
+{ "NPROCESSORS_CONF", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, _SC_NPROCESSORS_CONF },
+{ "NPROCESSORS_ONLN", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, _SC_NPROCESSORS_ONLN },
+{ "NPROC_CONF", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NPROC_ONLN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NSS_BUFLEN_GROUP", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NSS_BUFLEN_PASSWD", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NUM_PROCESSORS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NZERO", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "OPEN_MAX", { 0, 0 }, { _POSIX_OPEN_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_OPEN_MAX },
+{ "OPEN_MAX_CEIL", { OPEN_MAX, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_AST, 1, CONF_nop, -1 },
+{ "OSREL_MAJ", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "OSREL_MIN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "OSREL_PATCH", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "OS_BASE", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "OS_PROVIDER", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "OS_VERSION", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE, CONF_AES, 1, CONF_sysconf, -1 },
+{ "PAGESIZE", { 0, 0 }, { 4096, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_PAGESIZE },
+{ "PAGE_SIZE", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, _SC_PAGE_SIZE },
+{ "PASS_MAX", { 0, 0 }, { 8, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, _SC_PASS_MAX },
+{ "PATH", { 0, 0 }, { 0, "/bin:/usr/bin" }, CONF_DEFER_CALL|CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_confstr, _CS_PATH },
+{ "PATH_MAX", { 0, 0 }, { _POSIX_PATH_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_PATH_MAX },
+{ "PBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS },
+{ "PBS_ACCOUNTING", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_ACCOUNTING },
+{ "PBS_CHECKPOINT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_CHECKPOINT },
+{ "PBS_LOCATE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_LOCATE },
+{ "PBS_MESSAGE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_MESSAGE },
+{ "PBS_TRACK", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_TRACK },
+{ "PHYS_PAGES", { 0, 0 }, { 0, 0 }, 0, CONF_SUN, 1, CONF_sysconf, _SC_PHYS_PAGES },
+{ "PID_MAX", { 0, 0 }, { 30000, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "PII", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_INTERNET", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_INTERNET_DGRAM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_INTERNET_STREAM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_OSI", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_OSI_CLTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_OSI_COTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_OSI_M", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_SOCKET", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_XTI", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PIPE_BUF", { 0, 0 }, { _POSIX_PIPE_BUF, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_PIPE_BUF },
+{ "POLL", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PRIORITIZED_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_PRIORITIZED_IO },
+{ "PRIORITY_SCHEDULING", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_PRIORITY_SCHEDULING },
+{ "PRIO_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_PRIO_IO },
+{ "PROC_RSRC_MGR", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTHREAD_DESTRUCTOR_ITERATIONS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTHREAD_KEYS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTHREAD_STACK_MIN", { 4096, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_LIMIT|CONF_LIMIT_DEF, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTHREAD_THREADS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTRDIFF_MAX", { 2147483647, 0 }, { 65535, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "PTRDIFF_MIN", { -2147483648, 0 }, { -65535, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "RAW_SOCKETS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_RAW_SOCKETS },
+{ "READER_WRITER_LOCKS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_READER_WRITER_LOCKS },
+{ "REALTIME", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, -1 },
+{ "REALTIME_SIGNALS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_REALTIME_SIGNALS },
+{ "REALTIME_THREADS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, -1 },
+{ "REC_INCR_XFER_SIZE", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_REC_INCR_XFER_SIZE },
+{ "REC_MAX_XFER_SIZE", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_REC_MAX_XFER_SIZE },
+{ "REC_MIN_XFER_SIZE", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_REC_MIN_XFER_SIZE },
+{ "REC_XFER_ALIGN", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_REC_XFER_ALIGN },
+{ "REENTRANT_FUNCTIONS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "REGEXP", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_REGEXP },
+{ "REGEX_VERSION", { 0, 0 }, { 20030916, 0 }, CONF_FEATURE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "RELEASE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "RESOURCE_LIMITS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "RE_DUP_MAX", { 0, 0 }, { _POSIX2_RE_DUP_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_RE_DUP_MAX },
+{ "RTSIG_MAX", { 0, 0 }, { _POSIX_RTSIG_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_RTSIG_MAX },
+{ "SAVED_IDS", { 0, 0 }, { 1, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SAVED_IDS },
+{ "SCHAR_MAX", { 127, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SCHAR_MIN", { -128, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SECURITY_CLASS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SELECT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "SEMAPHORES", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SEMAPHORES },
+{ "SEM_NSEMS_MAX", { 0, 0 }, { _POSIX_SEM_NSEMS_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_SEM_NSEMS_MAX },
+{ "SEM_VALUE_MAX", { 0, 0 }, { _POSIX_SEM_VALUE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_SEM_VALUE_MAX },
+{ "SH", { 0, 0 }, { 0, "/bin/sh" }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING|CONF_MINMAX_DEF, CONF_AST, 1, CONF_confstr, -1 },
+{ "SHARED_MEMORY_OBJECTS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SHARED_MEMORY_OBJECTS },
+{ "SHELL", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SHELL },
+{ "SHM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_SHM },
+{ "SHRT_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "SHRT_MIN", { -32768, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SIGQUEUE_MAX", { 0, 0 }, { _POSIX_SIGQUEUE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_SIGQUEUE_MAX },
+{ "SIGRT_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, _SC_SIGRT_MAX },
+{ "SIGRT_MIN", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, _SC_SIGRT_MIN },
+{ "SIG_ATOMIC_MAX", { 2147483647, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SIG_ATOMIC_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SIZE_MAX", { UINT_MAX, 0 }, { 65535, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SLVM_MAXNODES", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SOCK_MAXBUF", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SOFTPOWER", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SPAWN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SPAWN },
+{ "SPIN_LOCKS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SPIN_LOCKS },
+{ "SPORADIC_SERVER", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SPORADIC_SERVER },
+{ "SRPC_DOMAIN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SSIZE_MAX", { INT_MAX, 0 }, { _POSIX_SSIZE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SS_REPL_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SS_REPL_MAX },
+{ "STD_BLK", { 0, 0 }, { 1024, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "STREAMS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_STREAMS },
+{ "STREAM_MAX", { 0, 0 }, { _POSIX_STREAM_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_STREAM_MAX },
+{ "SW_DEV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_SW_DEV },
+{ "SYMLINKS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_pathconf, _PC_2_SYMLINKS },
+{ "SYMLINK_MAX", { 0, 0 }, { _POSIX_SYMLINK_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_SYMLINK_MAX },
+{ "SYMLOOP_MAX", { 0, 0 }, { _POSIX_SYMLOOP_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_SYMLOOP_MAX },
+{ "SYNCHRONIZED_IO", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SYNCHRONIZED_IO },
+{ "SYNC_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_SYNC_IO },
+{ "SYSNAME", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "SYSPID_MAX", { 0, 0 }, { 2, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "THREADS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREADS },
+{ "THREADS_PRIO_CEILING", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "THREADS_PRIO_INHERIT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "THREAD_ATTR_STACKADDR", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_ATTR_STACKADDR },
+{ "THREAD_ATTR_STACKSIZE", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_ATTR_STACKSIZE },
+{ "THREAD_CPUTIME", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_CPUTIME },
+{ "THREAD_DESTRUCTOR_ITERATIONS", { 0, 0 }, { _POSIX_THREAD_DESTRUCTOR_ITERATIONS, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_PREFIX_ONLY|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_DESTRUCTOR_ITERATIONS },
+{ "THREAD_KEYS_MAX", { 0, 0 }, { _POSIX_THREAD_KEYS_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_PREFIX_ONLY|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_KEYS_MAX },
+{ "THREAD_PRIORITY_SCHEDULING", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_PRIORITY_SCHEDULING },
+{ "THREAD_PRIO_INHERIT", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_PRIO_INHERIT },
+{ "THREAD_PRIO_PROTECT", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_PRIO_PROTECT },
+{ "THREAD_PROCESS_SHARED", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_PROCESS_SHARED },
+{ "THREAD_SAFE_FUNCTIONS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_SAFE_FUNCTIONS },
+{ "THREAD_SPORADIC_SERVER", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_SPORADIC_SERVER },
+{ "THREAD_STACK_MIN", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_STACK_MIN },
+{ "THREAD_THREADS_MAX", { 0, 0 }, { _POSIX_THREAD_THREADS_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_PREFIX_ONLY|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_THREADS_MAX },
+{ "TIMEOUTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TIMEOUTS },
+{ "TIMERS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TIMERS },
+{ "TIMER_MAX", { 0, 0 }, { _POSIX_TIMER_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_TIMER_MAX },
+{ "TMP", { 0, 0 }, { 0, "/tmp" }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING|CONF_MINMAX_DEF, CONF_AST, 1, CONF_confstr, -1 },
+{ "TMP_MAX", { 17576, 0 }, { 10000, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_C, 1, CONF_sysconf, -1 },
+{ "TRACE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE },
+{ "TRACE_EVENT_FILTER", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_EVENT_FILTER },
+{ "TRACE_EVENT_NAME_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_EVENT_NAME_MAX },
+{ "TRACE_INHERIT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_INHERIT },
+{ "TRACE_LOG", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_LOG },
+{ "TRACE_NAME_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_NAME_MAX },
+{ "TRACE_SYS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_SYS_MAX },
+{ "TRACE_USER_EVENT_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_USER_EVENT_MAX },
+{ "TTY_NAME_MAX", { 0, 0 }, { _POSIX_TTY_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_TTY_NAME_MAX },
+{ "TYPED_MEMORY_OBJECTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TYPED_MEMORY_OBJECTS },
+{ "TZNAME_MAX", { 0, 0 }, { _POSIX_TZNAME_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_TZNAME_MAX },
+{ "T_IOV_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_C, 1, CONF_sysconf, _SC_T_IOV_MAX },
+{ "UCHAR_MAX", { 255, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "UCHAR_MIN", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "UID_MAX", { 0, 0 }, { 60002, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "UINT_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "UIO_MAXIOV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ULLONG_MAX", { 18446744073709551615ULL, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "ULONG_MAX", { 4294967295, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "UNIX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_UNIX },
+{ "UPE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_UPE },
+{ "USER_LIMIT", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "USHRT_MAX", { 65535, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "V6_ILP32_OFF32", { 0, 0 }, { 0, 0 }, CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_V6_ILP32_OFF32 },
+{ "V6_ILP32_OFFBIG", { 0, 0 }, { 0, 0 }, CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_V6_ILP32_OFFBIG },
+{ "V6_LP64_OFF64", { 0, 0 }, { 0, 0 }, CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_V6_LP64_OFF64 },
+{ "V6_LPBIG_OFFBIG", { 0, 0 }, { 0, 0 }, CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_V6_LPBIG_OFFBIG },
+{ "VDISABLE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_VDISABLE },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_PREFIXED|CONF_STANDARD|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "VERSION", { 0, 0 }, { 200112, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "VERSION", { 0, 0 }, { 200112, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 2, CONF_sysconf, -1 },
+{ "VERSION", { 0, 0 }, { 600, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_VERSION },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_XPG, 3, CONF_sysconf, -1 },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_XPG, 4, CONF_sysconf, -1 },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_PREFIXED|CONF_STANDARD, CONF_AST, 1, CONF_nop, -1 },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_PREFIXED|CONF_STANDARD, CONF_GNU, 1, CONF_nop, -1 },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_PREFIXED|CONF_STANDARD, CONF_TRUSTEDBSD, 1, CONF_nop, -1 },
+{ "VERSION_88", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_LIMIT|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "VERSION_88", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "VERSION_90", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_LIMIT|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "VERSION_90", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "VERSION_93", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_LIMIT|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "VERSION_93", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "WCHAR_MAX", { 2147483647, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "WCHAR_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "WINT_MAX", { 2147483647, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "WINT_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "WORD_BIT", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "XCU_VERSION", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_XCU_VERSION },
+{ "XPG2", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "XPG3", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "XPG4", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_nop, -1 },
+};
+
+int conf_elements = (int)sizeof(conf) / (int)sizeof(conf[0]);
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/conftab.h b/usr/src/lib/libast/sparc/src/lib/libast/conftab.h
new file mode 100644
index 0000000000..c16dbc0e06
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/conftab.h
@@ -0,0 +1,154 @@
+
+/* : : generated by proto : : */
+
+
+#ifndef _CONFTAB_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _CONFTAB_H
+
+#if !defined(SYS_NMLEN)
+#define SYS_NMLEN 9
+#endif
+#include <sys/systeminfo.h>
+
+/* : : generated by conf from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/comp/conf.tab : : */
+
+#define conf _ast_conf_data
+#define conf_elements _ast_conf_ndata
+
+#define prefix _ast_conf_prefix
+#define prefix_elements _ast_conf_nprefix
+
+#define CONF_nop 0
+#define CONF_confstr 1
+#define CONF_pathconf 2
+#define CONF_sysconf 3
+#define CONF_sysinfo 4
+
+#define CONF_C 0
+#define CONF_POSIX 1
+#define CONF_SVID 2
+#define CONF_XOPEN 3
+#define CONF_SUN 4
+#define CONF_XBS5 5
+#define CONF_SCO 6
+#define CONF_AST 7
+#define CONF_AES 8
+#define CONF_XPG 9
+#define CONF_GNU 10
+#define CONF_TRUSTEDBSD 11
+#define CONF_call 12
+
+#define _pth_getconf "/usr/bin/getconf"
+#define _pth_getconf_a "-a"
+
+#define CONF_DEFER_CALL 0x0001
+#define CONF_DEFER_MM 0x0002
+#define CONF_FEATURE 0x0004
+#define CONF_LIMIT 0x0008
+#define CONF_LIMIT_DEF 0x0010
+#define CONF_MINMAX 0x0020
+#define CONF_MINMAX_DEF 0x0040
+#define CONF_NOSECTION 0x0080
+#define CONF_NOUNDERSCORE 0x0100
+#define CONF_PREFIX_ONLY 0x0200
+#define CONF_PREFIXED 0x0400
+#define CONF_STANDARD 0x0800
+#define CONF_STRING 0x1000
+#define CONF_UNDERSCORE 0x2000
+#define CONF_USER 0x4000
+
+struct Conf_s; typedef struct Conf_s Conf_t;
+
+typedef int (*Conf_f) __PROTO__((Conf_t*, intmax_t*, char**));
+
+typedef struct Value_s
+{
+ intmax_t number;
+ const char* string;
+} Value_t;
+
+struct Conf_s
+{
+ const char name[32];
+ Value_t limit;
+ Value_t minmax;
+ short flags;
+ short standard;
+ short section;
+ short call;
+ short op;
+};
+
+typedef struct Prefix_s
+{
+ const char name[16];
+ short length;
+ short standard;
+ short call;
+} Prefix_t;
+
+extern __MANGLE__ const Conf_t conf[];
+extern __MANGLE__ int conf_elements;
+
+extern __MANGLE__ const Prefix_t prefix[];
+extern __MANGLE__ int prefix_elements;
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/lc.h b/usr/src/lib/libast/sparc/src/lib/libast/lc.h
new file mode 100644
index 0000000000..fdd804f36e
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/lc.h
@@ -0,0 +1,158 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated by ./lcgen : : */
+
+
+#ifndef _LC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _LC_H 1
+
+#include <ast.h>
+
+#define LC_abbreviated 0x00001
+#define LC_checked 0x00002
+#define LC_default 0x00004
+#define LC_defined 0x00008
+#define LC_debug 0x00010
+#define LC_local 0x00020
+#define LC_primary 0x00040
+#define LC_qualified 0x00080
+#define LC_undefined 0x00100
+#define LC_verbose 0x00200
+#define LC_user 0x10000
+#define LC_language_attribute_max 2
+#define LC_territory_language_max 4
+
+struct Lc_s;
+
+typedef struct Lc_info_s
+{
+ const struct Lc_s* lc;
+ unsigned long number;
+ __V_* data;
+} Lc_info_t;
+
+typedef struct Lc_attribute_s
+{
+ const char* name;
+ unsigned long flags;
+ unsigned long index;
+} Lc_attribute_t;
+
+typedef struct Lc_charset_s
+{
+ const char* code;
+ const char* alternates;
+ const char* ms;
+ unsigned long index;
+} Lc_charset_t;
+
+typedef struct Lc_language_s
+{
+ const char* code;
+ const char* name;
+ const char* alternates;
+ const Lc_charset_t* charset;
+ unsigned long flags;
+ unsigned long index;
+ const Lc_attribute_t* attributes[LC_language_attribute_max];
+} Lc_language_t;
+
+typedef struct Lc_territory_s
+{
+ const char* code;
+ const char* name;
+ unsigned long flags;
+ unsigned long index;
+ const Lc_language_t* languages[LC_territory_language_max];
+#ifdef _LC_TERRITORY_PRIVATE_
+ _LC_TERRITORY_PRIVATE_
+#endif
+} Lc_territory_t;
+
+typedef struct Lc_map_s
+{
+ const char* code;
+ const Lc_language_t* language;
+ const Lc_territory_t* territory;
+ const Lc_charset_t* charset;
+ const Lc_attribute_t* attribute;
+} Lc_map_t;
+
+typedef struct Lc_attribute_list_s
+{
+ struct Lc_attribute_list_s* next;
+ const Lc_attribute_t* attribute;
+} Lc_attribute_list_t;
+
+typedef struct Lc_s
+{
+ const char* name;
+ const char* code;
+ const Lc_language_t* language;
+ const Lc_territory_t* territory;
+ const Lc_charset_t* charset;
+ const Lc_attribute_list_t* attributes;
+ unsigned long flags;
+ unsigned long index;
+#ifdef _LC_PRIVATE_
+ _LC_PRIVATE_
+#endif
+} Lc_t;
+
+struct Lc_category_s;
+
+typedef int (*Lc_category_set_f) __PROTO__((struct Lc_category_s*));
+
+typedef struct Lc_category_s
+{
+ const char* name;
+ int external;
+ int internal;
+ Lc_category_set_f setf;
+ Lc_t* prev;
+} Lc_category_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ size_t lccanon __PROTO__((Lc_t*, unsigned long flags, char*, size_t));
+extern __MANGLE__ Lc_category_t* lccategories __PROTO__((void));
+extern __MANGLE__ int lcindex __PROTO__((int, int));
+extern __MANGLE__ Lc_info_t* lcinfo __PROTO__((int));
+extern __MANGLE__ Lc_t* lcmake __PROTO__((const char*));
+extern __MANGLE__ Lc_t* lcscan __PROTO__((Lc_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/lctab.h b/usr/src/lib/libast/sparc/src/lib/libast/lctab.h
new file mode 100644
index 0000000000..6abbd72c65
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/lctab.h
@@ -0,0 +1,2630 @@
+/* : : generated by ./lcgen : : */
+
+static Lc_attribute_t attribute_es[] =
+{
+{"traditional",LC_default,
+#ifdef SUBLANG_SPANISH_TRADITIONAL
+SUBLANG_SPANISH_TRADITIONAL,
+#else
+0,
+#endif
+
+},
+{"modern",0,
+#ifdef SUBLANG_SPANISH_MODERN
+SUBLANG_SPANISH_MODERN,
+#else
+0,
+#endif
+
+},
+};
+
+static const Lc_charset_t charset[] =
+{
+{"iso8859-1","latin1|west-europe","1252",},
+{"iso8859-2","latin2|east-europe","1250",},
+{"iso8859-3","latin3|south-europe","1257",},
+{"iso8859-4","latin4|north-europe",0},
+{"iso8859-5","cyrillic","1251",},
+{"iso8859-6","arabic","1256",},
+{"iso8859-7","greek","1253",},
+{"iso8859-8","hebrew","1255",},
+{"iso8859-9","latin5|turkish","1254",},
+{"iso8859-10","latin6|nordic",0},
+{"iso8859-13","latin7",0},
+{"iso8859-14","latin8|celtic",0},
+{"iso8859-15","latin0",0},
+{"iso2022","japanese|korean",0},
+{"iso4873","japanese-ascii|korean-ascii",0},
+{"koi8-r","russian",0},
+{"utf8","plan9",0},
+ 0
+};
+
+static const Lc_language_t language[] =
+{
+{"C","C","POSIX",&charset[0],LC_default,0,0,0,},
+{"debug","debug",0,&charset[0],LC_debug,0,0,0,},
+{"aa","afar",0,&charset[0],0,
+#ifdef LANG_AFAR
+LANG_AFAR,
+#else
+0,
+#endif
+0,0,
+},
+{"ab","abkhazian",0,&charset[0],0,
+#ifdef LANG_ABKHAZIAN
+LANG_ABKHAZIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"af","afrikaans","afr",&charset[0],0,
+#ifdef LANG_AFRIKAANS
+LANG_AFRIKAANS,
+#else
+0,
+#endif
+0,0,
+},
+{"am","amharic",0,&charset[0],0,
+#ifdef LANG_AMHARIC
+LANG_AMHARIC,
+#else
+0,
+#endif
+0,0,
+},
+{"ar","arabic","ara",&charset[5],0,
+#ifdef LANG_ARABIC
+LANG_ARABIC,
+#else
+0,
+#endif
+0,0,
+},
+{"as","assamese",0,&charset[0],0,
+#ifdef LANG_ASSAMESE
+LANG_ASSAMESE,
+#else
+0,
+#endif
+0,0,
+},
+{"ay","aymara",0,&charset[0],0,
+#ifdef LANG_AYMARA
+LANG_AYMARA,
+#else
+0,
+#endif
+0,0,
+},
+{"az","azerbaijani",0,&charset[0],0,
+#ifdef LANG_AZERBAIJANI
+LANG_AZERBAIJANI,
+#else
+0,
+#endif
+0,0,
+},
+{"ba","bashkir",0,&charset[0],0,
+#ifdef LANG_BASHKIR
+LANG_BASHKIR,
+#else
+0,
+#endif
+0,0,
+},
+{"be","belarusian","bel",&charset[0],0,
+#ifdef LANG_BELARUSIAN
+LANG_BELARUSIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"bg","bulgarian","bul",&charset[4],0,
+#ifdef LANG_BULGARIAN
+LANG_BULGARIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"bh","bihari",0,&charset[0],0,
+#ifdef LANG_BIHARI
+LANG_BIHARI,
+#else
+0,
+#endif
+0,0,
+},
+{"bi","bislama",0,&charset[0],0,
+#ifdef LANG_BISLAMA
+LANG_BISLAMA,
+#else
+0,
+#endif
+0,0,
+},
+{"bn","bengali-bangla",0,&charset[0],0,
+#ifdef LANG_BENGALI_BANGLA
+LANG_BENGALI_BANGLA,
+#else
+0,
+#endif
+0,0,
+},
+{"bo","tibetan",0,&charset[0],0,
+#ifdef LANG_TIBETAN
+LANG_TIBETAN,
+#else
+0,
+#endif
+0,0,
+},
+{"br","breton",0,&charset[0],0,
+#ifdef LANG_BRETON
+LANG_BRETON,
+#else
+0,
+#endif
+0,0,
+},
+{"ca","catalan","cat",&charset[0],0,
+#ifdef LANG_CATALAN
+LANG_CATALAN,
+#else
+0,
+#endif
+0,0,
+},
+{"co","corsican",0,&charset[0],0,
+#ifdef LANG_CORSICAN
+LANG_CORSICAN,
+#else
+0,
+#endif
+0,0,
+},
+{"cs","czech","ces|cze",&charset[1],0,
+#ifdef LANG_CZECH
+LANG_CZECH,
+#else
+0,
+#endif
+0,0,
+},
+{"cy","welsh",0,&charset[0],0,
+#ifdef LANG_WELSH
+LANG_WELSH,
+#else
+0,
+#endif
+0,0,
+},
+{"da","danish","dan",&charset[0],0,
+#ifdef LANG_DANISH
+LANG_DANISH,
+#else
+0,
+#endif
+0,0,
+},
+{"de","german","deu|ger",&charset[0],0,
+#ifdef LANG_GERMAN
+LANG_GERMAN,
+#else
+0,
+#endif
+0,0,
+},
+{"dz","bhutani",0,&charset[0],0,
+#ifdef LANG_BHUTANI
+LANG_BHUTANI,
+#else
+0,
+#endif
+0,0,
+},
+{"el","greek","ell|gre",&charset[6],0,
+#ifdef LANG_GREEK
+LANG_GREEK,
+#else
+0,
+#endif
+0,0,
+},
+{"en","english","eng",&charset[0],0,
+#ifdef LANG_ENGLISH
+LANG_ENGLISH,
+#else
+0,
+#endif
+0,0,
+},
+{"eo","esperanto",0,&charset[0],0,
+#ifdef LANG_ESPERANTO
+LANG_ESPERANTO,
+#else
+0,
+#endif
+0,0,
+},
+{"es","spanish","spa",&charset[0],0,
+#ifdef LANG_SPANISH
+LANG_SPANISH,
+#else
+0,
+#endif
+&attribute_es[0],&attribute_es[1],
+},
+{"et","estonian","est",&charset[2],0,
+#ifdef LANG_ESTONIAN
+LANG_ESTONIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"eu","basque","eus|baq",&charset[0],0,
+#ifdef LANG_BASQUE
+LANG_BASQUE,
+#else
+0,
+#endif
+0,0,
+},
+{"fa","persian",0,&charset[0],0,
+#ifdef LANG_PERSIAN
+LANG_PERSIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"fi","finnish","fin",&charset[0],0,
+#ifdef LANG_FINNISH
+LANG_FINNISH,
+#else
+0,
+#endif
+0,0,
+},
+{"fj","fiji",0,&charset[0],0,
+#ifdef LANG_FIJI
+LANG_FIJI,
+#else
+0,
+#endif
+0,0,
+},
+{"fo","faeroese",0,&charset[0],0,
+#ifdef LANG_FAEROESE
+LANG_FAEROESE,
+#else
+0,
+#endif
+0,0,
+},
+{"fr","french","fra|fre",&charset[0],0,
+#ifdef LANG_FRENCH
+LANG_FRENCH,
+#else
+0,
+#endif
+0,0,
+},
+{"fy","frisian",0,&charset[0],0,
+#ifdef LANG_FRISIAN
+LANG_FRISIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ga","irish",0,&charset[11],0,
+#ifdef LANG_IRISH
+LANG_IRISH,
+#else
+0,
+#endif
+0,0,
+},
+{"gd","scots-gaelic",0,&charset[11],0,
+#ifdef LANG_SCOTS_GAELIC
+LANG_SCOTS_GAELIC,
+#else
+0,
+#endif
+0,0,
+},
+{"gl","galician",0,&charset[0],0,
+#ifdef LANG_GALICIAN
+LANG_GALICIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"gn","guarani",0,&charset[0],0,
+#ifdef LANG_GUARANI
+LANG_GUARANI,
+#else
+0,
+#endif
+0,0,
+},
+{"gu","gujarati",0,&charset[0],0,
+#ifdef LANG_GUJARATI
+LANG_GUJARATI,
+#else
+0,
+#endif
+0,0,
+},
+{"ha","hausa",0,&charset[0],0,
+#ifdef LANG_HAUSA
+LANG_HAUSA,
+#else
+0,
+#endif
+0,0,
+},
+{"he","hebrew","heb",&charset[7],0,
+#ifdef LANG_HEBREW
+LANG_HEBREW,
+#else
+0,
+#endif
+0,0,
+},
+{"hi","hindi",0,&charset[0],0,
+#ifdef LANG_HINDI
+LANG_HINDI,
+#else
+0,
+#endif
+0,0,
+},
+{"hr","croatian","hrv|scr",&charset[1],0,
+#ifdef LANG_CROATIAN
+LANG_CROATIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"hu","hungarian","hun",&charset[1],0,
+#ifdef LANG_HUNGARIAN
+LANG_HUNGARIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"hy","armenian",0,&charset[0],0,
+#ifdef LANG_ARMENIAN
+LANG_ARMENIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ia","interlingua",0,&charset[0],0,
+#ifdef LANG_INTERLINGUA
+LANG_INTERLINGUA,
+#else
+0,
+#endif
+0,0,
+},
+{"id","indonesian","ind",&charset[0],0,
+#ifdef LANG_INDONESIAN
+LANG_INDONESIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ie","interlingue",0,&charset[0],0,
+#ifdef LANG_INTERLINGUE
+LANG_INTERLINGUE,
+#else
+0,
+#endif
+0,0,
+},
+{"ik","inupiak",0,&charset[0],0,
+#ifdef LANG_INUPIAK
+LANG_INUPIAK,
+#else
+0,
+#endif
+0,0,
+},
+{"in","indonesian",0,&charset[0],0,
+#ifdef LANG_INDONESIAN
+LANG_INDONESIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"is","icelandic","isl|ice",&charset[0],0,
+#ifdef LANG_ICELANDIC
+LANG_ICELANDIC,
+#else
+0,
+#endif
+0,0,
+},
+{"it","italian","ita",&charset[0],0,
+#ifdef LANG_ITALIAN
+LANG_ITALIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"iw","hebrew",0,&charset[0],0,
+#ifdef LANG_HEBREW
+LANG_HEBREW,
+#else
+0,
+#endif
+0,0,
+},
+{"ja","japanese","jpn",&charset[0],0,
+#ifdef LANG_JAPANESE
+LANG_JAPANESE,
+#else
+0,
+#endif
+0,0,
+},
+{"ji","yiddish",0,&charset[0],0,
+#ifdef LANG_YIDDISH
+LANG_YIDDISH,
+#else
+0,
+#endif
+0,0,
+},
+{"jw","javanese",0,&charset[0],0,
+#ifdef LANG_JAVANESE
+LANG_JAVANESE,
+#else
+0,
+#endif
+0,0,
+},
+{"ka","georgian",0,&charset[0],0,
+#ifdef LANG_GEORGIAN
+LANG_GEORGIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"kk","kazakh","kaz",&charset[0],0,
+#ifdef LANG_KAZAKH
+LANG_KAZAKH,
+#else
+0,
+#endif
+0,0,
+},
+{"kl","greenlandic",0,&charset[0],0,
+#ifdef LANG_GREENLANDIC
+LANG_GREENLANDIC,
+#else
+0,
+#endif
+0,0,
+},
+{"km","cambodian",0,&charset[0],0,
+#ifdef LANG_CAMBODIAN
+LANG_CAMBODIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"kn","kannada",0,&charset[0],0,
+#ifdef LANG_KANNADA
+LANG_KANNADA,
+#else
+0,
+#endif
+0,0,
+},
+{"ko","korean","kor",&charset[0],0,
+#ifdef LANG_KOREAN
+LANG_KOREAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ks","kashmiri",0,&charset[0],0,
+#ifdef LANG_KASHMIRI
+LANG_KASHMIRI,
+#else
+0,
+#endif
+0,0,
+},
+{"ku","kurdish",0,&charset[0],0,
+#ifdef LANG_KURDISH
+LANG_KURDISH,
+#else
+0,
+#endif
+0,0,
+},
+{"ky","kirghiz",0,&charset[0],0,
+#ifdef LANG_KIRGHIZ
+LANG_KIRGHIZ,
+#else
+0,
+#endif
+0,0,
+},
+{"la","latin",0,&charset[0],0,
+#ifdef LANG_LATIN
+LANG_LATIN,
+#else
+0,
+#endif
+0,0,
+},
+{"ln","lingala",0,&charset[0],0,
+#ifdef LANG_LINGALA
+LANG_LINGALA,
+#else
+0,
+#endif
+0,0,
+},
+{"lo","laothian",0,&charset[0],0,
+#ifdef LANG_LAOTHIAN
+LANG_LAOTHIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"lt","lithuanian","lit",&charset[10],0,
+#ifdef LANG_LITHUANIAN
+LANG_LITHUANIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"lv","latvian","lav",&charset[10],0,
+#ifdef LANG_LATVIAN
+LANG_LATVIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"mg","malagasy",0,&charset[0],0,
+#ifdef LANG_MALAGASY
+LANG_MALAGASY,
+#else
+0,
+#endif
+0,0,
+},
+{"mi","maori",0,&charset[0],0,
+#ifdef LANG_MAORI
+LANG_MAORI,
+#else
+0,
+#endif
+0,0,
+},
+{"mk","macedonian","mkd|mac",&charset[0],0,
+#ifdef LANG_MACEDONIAN
+LANG_MACEDONIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ml","malayalam","mal",&charset[0],0,
+#ifdef LANG_MALAYALAM
+LANG_MALAYALAM,
+#else
+0,
+#endif
+0,0,
+},
+{"mn","mongolian",0,&charset[0],0,
+#ifdef LANG_MONGOLIAN
+LANG_MONGOLIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"mo","moldavian",0,&charset[0],0,
+#ifdef LANG_MOLDAVIAN
+LANG_MOLDAVIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"mr","marathi",0,&charset[0],0,
+#ifdef LANG_MARATHI
+LANG_MARATHI,
+#else
+0,
+#endif
+0,0,
+},
+{"ms","malay","msa|may",&charset[0],0,
+#ifdef LANG_MALAY
+LANG_MALAY,
+#else
+0,
+#endif
+0,0,
+},
+{"mt","maltese",0,&charset[0],0,
+#ifdef LANG_MALTESE
+LANG_MALTESE,
+#else
+0,
+#endif
+0,0,
+},
+{"my","burmese",0,&charset[0],0,
+#ifdef LANG_BURMESE
+LANG_BURMESE,
+#else
+0,
+#endif
+0,0,
+},
+{"na","nauru",0,&charset[0],0,
+#ifdef LANG_NAURU
+LANG_NAURU,
+#else
+0,
+#endif
+0,0,
+},
+{"nb","norwegian-bokmal","nob",&charset[0],0,
+#ifdef LANG_NORWEGIAN_BOKMAL
+LANG_NORWEGIAN_BOKMAL,
+#else
+0,
+#endif
+0,0,
+},
+{"ne","nepali",0,&charset[0],0,
+#ifdef LANG_NEPALI
+LANG_NEPALI,
+#else
+0,
+#endif
+0,0,
+},
+{"nl","dutch","nld|dut",&charset[0],0,
+#ifdef LANG_DUTCH
+LANG_DUTCH,
+#else
+0,
+#endif
+0,0,
+},
+{"nn","norwegian-nynorsk","nno|non",&charset[0],0,
+#ifdef LANG_NORWEGIAN_NYNORSK
+LANG_NORWEGIAN_NYNORSK,
+#else
+0,
+#endif
+0,0,
+},
+{"no","norwegian","nor",&charset[0],0,
+#ifdef LANG_NORWEGIAN
+LANG_NORWEGIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"oc","occitan",0,&charset[0],0,
+#ifdef LANG_OCCITAN
+LANG_OCCITAN,
+#else
+0,
+#endif
+0,0,
+},
+{"om","oromo",0,&charset[0],0,
+#ifdef LANG_OROMO
+LANG_OROMO,
+#else
+0,
+#endif
+0,0,
+},
+{"or","oriya",0,&charset[0],0,
+#ifdef LANG_ORIYA
+LANG_ORIYA,
+#else
+0,
+#endif
+0,0,
+},
+{"pa","punjabi",0,&charset[0],0,
+#ifdef LANG_PUNJABI
+LANG_PUNJABI,
+#else
+0,
+#endif
+0,0,
+},
+{"pl","polish","pol",&charset[1],0,
+#ifdef LANG_POLISH
+LANG_POLISH,
+#else
+0,
+#endif
+0,0,
+},
+{"ps","pushto",0,&charset[0],0,
+#ifdef LANG_PUSHTO
+LANG_PUSHTO,
+#else
+0,
+#endif
+0,0,
+},
+{"pt","portuguese","por",&charset[0],0,
+#ifdef LANG_PORTUGUESE
+LANG_PORTUGUESE,
+#else
+0,
+#endif
+0,0,
+},
+{"qu","quechua",0,&charset[0],0,
+#ifdef LANG_QUECHUA
+LANG_QUECHUA,
+#else
+0,
+#endif
+0,0,
+},
+{"rm","rhaeto-romance",0,&charset[0],0,
+#ifdef LANG_RHAETO_ROMANCE
+LANG_RHAETO_ROMANCE,
+#else
+0,
+#endif
+0,0,
+},
+{"rn","kirundi",0,&charset[0],0,
+#ifdef LANG_KIRUNDI
+LANG_KIRUNDI,
+#else
+0,
+#endif
+0,0,
+},
+{"ro","romanian","ron|rum",&charset[1],0,
+#ifdef LANG_ROMANIAN
+LANG_ROMANIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ru","russian","rus",&charset[4],0,
+#ifdef LANG_RUSSIAN
+LANG_RUSSIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"rw","kinyarwanda",0,&charset[0],0,
+#ifdef LANG_KINYARWANDA
+LANG_KINYARWANDA,
+#else
+0,
+#endif
+0,0,
+},
+{"sa","sanskrit",0,&charset[0],0,
+#ifdef LANG_SANSKRIT
+LANG_SANSKRIT,
+#else
+0,
+#endif
+0,0,
+},
+{"sd","sindhi",0,&charset[0],0,
+#ifdef LANG_SINDHI
+LANG_SINDHI,
+#else
+0,
+#endif
+0,0,
+},
+{"sg","sangro",0,&charset[0],0,
+#ifdef LANG_SANGRO
+LANG_SANGRO,
+#else
+0,
+#endif
+0,0,
+},
+{"sh","serbo-croatian",0,&charset[0],0,
+#ifdef LANG_SERBO_CROATIAN
+LANG_SERBO_CROATIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"si","singhalese",0,&charset[0],0,
+#ifdef LANG_SINGHALESE
+LANG_SINGHALESE,
+#else
+0,
+#endif
+0,0,
+},
+{"sk","slovak","slk|slo",&charset[1],0,
+#ifdef LANG_SLOVAK
+LANG_SLOVAK,
+#else
+0,
+#endif
+0,0,
+},
+{"sl","slovenian","slv",&charset[1],0,
+#ifdef LANG_SLOVENIAN
+LANG_SLOVENIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"sm","samoan",0,&charset[0],0,
+#ifdef LANG_SAMOAN
+LANG_SAMOAN,
+#else
+0,
+#endif
+0,0,
+},
+{"sn","shona",0,&charset[0],0,
+#ifdef LANG_SHONA
+LANG_SHONA,
+#else
+0,
+#endif
+0,0,
+},
+{"so","somali",0,&charset[0],0,
+#ifdef LANG_SOMALI
+LANG_SOMALI,
+#else
+0,
+#endif
+0,0,
+},
+{"sq","albanian","sqi|alb",&charset[0],0,
+#ifdef LANG_ALBANIAN
+LANG_ALBANIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"sr","serbian","srp",&charset[1],0,
+#ifdef LANG_SERBIAN
+LANG_SERBIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ss","siswati",0,&charset[0],0,
+#ifdef LANG_SISWATI
+LANG_SISWATI,
+#else
+0,
+#endif
+0,0,
+},
+{"st","sesotho",0,&charset[0],0,
+#ifdef LANG_SESOTHO
+LANG_SESOTHO,
+#else
+0,
+#endif
+0,0,
+},
+{"su","sudanese",0,&charset[0],0,
+#ifdef LANG_SUDANESE
+LANG_SUDANESE,
+#else
+0,
+#endif
+0,0,
+},
+{"sv","swedish","swe",&charset[0],0,
+#ifdef LANG_SWEDISH
+LANG_SWEDISH,
+#else
+0,
+#endif
+0,0,
+},
+{"sw","swahili","swa",&charset[0],0,
+#ifdef LANG_SWAHILI
+LANG_SWAHILI,
+#else
+0,
+#endif
+0,0,
+},
+{"ta","tamil",0,&charset[0],0,
+#ifdef LANG_TAMIL
+LANG_TAMIL,
+#else
+0,
+#endif
+0,0,
+},
+{"te","telugu",0,&charset[0],0,
+#ifdef LANG_TELUGU
+LANG_TELUGU,
+#else
+0,
+#endif
+0,0,
+},
+{"tg","tajik",0,&charset[0],0,
+#ifdef LANG_TAJIK
+LANG_TAJIK,
+#else
+0,
+#endif
+0,0,
+},
+{"th","thai","tha",&charset[0],0,
+#ifdef LANG_THAI
+LANG_THAI,
+#else
+0,
+#endif
+0,0,
+},
+{"ti","tigrinya",0,&charset[0],0,
+#ifdef LANG_TIGRINYA
+LANG_TIGRINYA,
+#else
+0,
+#endif
+0,0,
+},
+{"tk","turkmen",0,&charset[0],0,
+#ifdef LANG_TURKMEN
+LANG_TURKMEN,
+#else
+0,
+#endif
+0,0,
+},
+{"tl","tagalog",0,&charset[0],0,
+#ifdef LANG_TAGALOG
+LANG_TAGALOG,
+#else
+0,
+#endif
+0,0,
+},
+{"tn","setswana",0,&charset[0],0,
+#ifdef LANG_SETSWANA
+LANG_SETSWANA,
+#else
+0,
+#endif
+0,0,
+},
+{"to","tonga",0,&charset[0],0,
+#ifdef LANG_TONGA
+LANG_TONGA,
+#else
+0,
+#endif
+0,0,
+},
+{"tr","turkish","tur",&charset[8],0,
+#ifdef LANG_TURKISH
+LANG_TURKISH,
+#else
+0,
+#endif
+0,0,
+},
+{"ts","tsonga",0,&charset[0],0,
+#ifdef LANG_TSONGA
+LANG_TSONGA,
+#else
+0,
+#endif
+0,0,
+},
+{"tt","tatar","tat",&charset[0],0,
+#ifdef LANG_TATAR
+LANG_TATAR,
+#else
+0,
+#endif
+0,0,
+},
+{"tw","chinese-traditional","cht",&charset[0],0,
+#ifdef LANG_CHINESE_TRADITIONAL
+LANG_CHINESE_TRADITIONAL,
+#else
+0,
+#endif
+0,0,
+},
+{"uk","ukrainian","ukr",&charset[4],0,
+#ifdef LANG_UKRAINIAN
+LANG_UKRAINIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ur","urdu",0,&charset[0],0,
+#ifdef LANG_URDU
+LANG_URDU,
+#else
+0,
+#endif
+0,0,
+},
+{"uz","uzbek","uzb",&charset[0],0,
+#ifdef LANG_UZBEK
+LANG_UZBEK,
+#else
+0,
+#endif
+0,0,
+},
+{"vi","vietnamese",0,&charset[0],0,
+#ifdef LANG_VIETNAMESE
+LANG_VIETNAMESE,
+#else
+0,
+#endif
+0,0,
+},
+{"vo","volapuk",0,&charset[0],0,
+#ifdef LANG_VOLAPUK
+LANG_VOLAPUK,
+#else
+0,
+#endif
+0,0,
+},
+{"wo","wolof",0,&charset[0],0,
+#ifdef LANG_WOLOF
+LANG_WOLOF,
+#else
+0,
+#endif
+0,0,
+},
+{"xh","xhosa",0,&charset[0],0,
+#ifdef LANG_XHOSA
+LANG_XHOSA,
+#else
+0,
+#endif
+0,0,
+},
+{"yo","yoruba",0,&charset[0],0,
+#ifdef LANG_YORUBA
+LANG_YORUBA,
+#else
+0,
+#endif
+0,0,
+},
+{"zh","chinese-simplified","zho|chi|chs",&charset[0],0,
+#ifdef LANG_CHINESE_SIMPLIFIED
+LANG_CHINESE_SIMPLIFIED,
+#else
+0,
+#endif
+0,0,
+},
+{"zu","zulu",0,&charset[0],0,
+#ifdef LANG_ZULU
+LANG_ZULU,
+#else
+0,
+#endif
+0,0,
+},
+ 0
+};
+
+static const Lc_territory_t territory[] =
+{
+{"C","C",LC_default,0,&language[0],0,0,0,0,0,0,0,},
+{"debug","debug",LC_debug,0,&language[1],0,0,0,0,0,0,0,},
+{"al","albania",0,
+#ifdef CTRY_ALBANIA
+CTRY_ALBANIA,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"an","netherlands-antilles",0,
+#ifdef CTRY_NETHERLANDS_ANTILLES
+CTRY_NETHERLANDS_ANTILLES,
+#else
+0,
+#endif
+&language[86],0,0,0,
+#ifdef SUBLANG_DUTCH_NETHERLANDS_ANTILLES
+SUBLANG_DUTCH_NETHERLANDS_ANTILLES,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ar","argentina",0,
+#ifdef CTRY_ARGENTINA
+CTRY_ARGENTINA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_ARGENTINA
+SUBLANG_SPANISH_ARGENTINA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"at","austria",0,
+#ifdef CTRY_AUSTRIA
+CTRY_AUSTRIA,
+#else
+0,
+#endif
+&language[23],0,0,0,
+#ifdef SUBLANG_GERMAN_AUSTRIA
+SUBLANG_GERMAN_AUSTRIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"au","australia",0,
+#ifdef CTRY_AUSTRALIA
+CTRY_AUSTRALIA,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_AUSTRALIA
+SUBLANG_ENGLISH_AUSTRALIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"az","azerbaijan",0,
+#ifdef CTRY_AZERBAIJAN
+CTRY_AZERBAIJAN,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"be","belgium",0,
+#ifdef CTRY_BELGIUM
+CTRY_BELGIUM,
+#else
+0,
+#endif
+&language[86],&language[35],&language[23],0,
+#ifdef SUBLANG_DUTCH_BELGIUM
+SUBLANG_DUTCH_BELGIUM,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_FRENCH_BELGIUM
+SUBLANG_FRENCH_BELGIUM,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_GERMAN_BELGIUM
+SUBLANG_GERMAN_BELGIUM,
+#else
+0,
+#endif
+0,
+},
+{"bg","bulgaria",0,
+#ifdef CTRY_BULGARIA
+CTRY_BULGARIA,
+#else
+0,
+#endif
+&language[12],0,0,0,
+#ifdef SUBLANG_BULGARIAN_BULGARIA
+SUBLANG_BULGARIAN_BULGARIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"bn","brunei-darussalam",0,
+#ifdef CTRY_BRUNEI_DARUSSALAM
+CTRY_BRUNEI_DARUSSALAM,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_BRUNEI_DARUSSALAM
+SUBLANG_ARABIC_BRUNEI_DARUSSALAM,
+#else
+0,
+#endif
+0,0,0,
+},
+{"bo","bolivia",0,
+#ifdef CTRY_BOLIVIA
+CTRY_BOLIVIA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_BOLIVIA
+SUBLANG_SPANISH_BOLIVIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"br","brazil",0,
+#ifdef CTRY_BRAZIL
+CTRY_BRAZIL,
+#else
+0,
+#endif
+&language[95],0,0,0,
+#ifdef SUBLANG_PORTUGUESE_BRAZIL
+SUBLANG_PORTUGUESE_BRAZIL,
+#else
+0,
+#endif
+0,0,0,
+},
+{"bw","botswana",0,
+#ifdef CTRY_BOTSWANA
+CTRY_BOTSWANA,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_BOTSWANA
+SUBLANG_ENGLISH_BOTSWANA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"by","belarus",0,
+#ifdef CTRY_BELARUS
+CTRY_BELARUS,
+#else
+0,
+#endif
+&language[100],0,0,0,
+#ifdef SUBLANG_RUSSIAN_BELARUS
+SUBLANG_RUSSIAN_BELARUS,
+#else
+0,
+#endif
+0,0,0,
+},
+{"bz","belize",0,
+#ifdef CTRY_BELIZE
+CTRY_BELIZE,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_BELIZE
+SUBLANG_ENGLISH_BELIZE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ca","canada",0,
+#ifdef CTRY_CANADA
+CTRY_CANADA,
+#else
+0,
+#endif
+&language[26],&language[35],0,0,
+#ifdef SUBLANG_ENGLISH_CANADA
+SUBLANG_ENGLISH_CANADA,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_FRENCH_CANADA
+SUBLANG_FRENCH_CANADA,
+#else
+0,
+#endif
+0,0,
+},
+{"ch","switzerland",0,
+#ifdef CTRY_SWITZERLAND
+CTRY_SWITZERLAND,
+#else
+0,
+#endif
+&language[35],&language[23],&language[54],0,
+#ifdef SUBLANG_FRENCH_SWITZERLAND
+SUBLANG_FRENCH_SWITZERLAND,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_GERMAN_SWITZERLAND
+SUBLANG_GERMAN_SWITZERLAND,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_ITALIAN_SWITZERLAND
+SUBLANG_ITALIAN_SWITZERLAND,
+#else
+0,
+#endif
+0,
+},
+{"cl","chile",0,
+#ifdef CTRY_CHILE
+CTRY_CHILE,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_CHILE
+SUBLANG_SPANISH_CHILE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"cn","china",LC_primary,
+#ifdef CTRY_CHINA
+CTRY_CHINA,
+#else
+0,
+#endif
+&language[140],0,0,0,
+#ifdef SUBLANG_CHINESE_SIMPLIFIED_CHINA
+SUBLANG_CHINESE_SIMPLIFIED_CHINA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"co","colombia",0,
+#ifdef CTRY_COLOMBIA
+CTRY_COLOMBIA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_COLOMBIA
+SUBLANG_SPANISH_COLOMBIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"cr","costa-rica",0,
+#ifdef CTRY_COSTA_RICA
+CTRY_COSTA_RICA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_COSTA_RICA
+SUBLANG_SPANISH_COSTA_RICA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"cz","czech-republic",0,
+#ifdef CTRY_CZECH_REPUBLIC
+CTRY_CZECH_REPUBLIC,
+#else
+0,
+#endif
+&language[20],0,0,0,
+#ifdef SUBLANG_CZECH_CZECH_REPUBLIC
+SUBLANG_CZECH_CZECH_REPUBLIC,
+#else
+0,
+#endif
+0,0,0,
+},
+{"de","germany",0,
+#ifdef CTRY_GERMANY
+CTRY_GERMANY,
+#else
+0,
+#endif
+&language[23],0,0,0,
+#ifdef SUBLANG_GERMAN_GERMANY
+SUBLANG_GERMAN_GERMANY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"dk","denmark",0,
+#ifdef CTRY_DENMARK
+CTRY_DENMARK,
+#else
+0,
+#endif
+&language[22],&language[26],0,0,
+#ifdef SUBLANG_DANISH_DENMARK
+SUBLANG_DANISH_DENMARK,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_ENGLISH_DENMARK
+SUBLANG_ENGLISH_DENMARK,
+#else
+0,
+#endif
+0,0,
+},
+{"do","dominican-republic",0,
+#ifdef CTRY_DOMINICAN_REPUBLIC
+CTRY_DOMINICAN_REPUBLIC,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
+SUBLANG_SPANISH_DOMINICAN_REPUBLIC,
+#else
+0,
+#endif
+0,0,0,
+},
+{"dz","algeria",0,
+#ifdef CTRY_ALGERIA
+CTRY_ALGERIA,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"ec","ecuador",0,
+#ifdef CTRY_ECUADOR
+CTRY_ECUADOR,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_ECUADOR
+SUBLANG_SPANISH_ECUADOR,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ee","estonia",0,
+#ifdef CTRY_ESTONIA
+CTRY_ESTONIA,
+#else
+0,
+#endif
+&language[29],0,0,0,
+#ifdef SUBLANG_ESTONIAN_ESTONIA
+SUBLANG_ESTONIAN_ESTONIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"eg","egypt",0,
+#ifdef CTRY_EGYPT
+CTRY_EGYPT,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_EGYPT
+SUBLANG_ARABIC_EGYPT,
+#else
+0,
+#endif
+0,0,0,
+},
+{"es","spain",0,
+#ifdef CTRY_SPAIN
+CTRY_SPAIN,
+#else
+0,
+#endif
+&language[28],&language[18],&language[30],&language[39],
+#ifdef SUBLANG_SPANISH_SPAIN
+SUBLANG_SPANISH_SPAIN,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_CATALAN_SPAIN
+SUBLANG_CATALAN_SPAIN,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_BASQUE_SPAIN
+SUBLANG_BASQUE_SPAIN,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_GALICIAN_SPAIN
+SUBLANG_GALICIAN_SPAIN,
+#else
+0,
+#endif
+
+},
+{"fi","finland",0,
+#ifdef CTRY_FINLAND
+CTRY_FINLAND,
+#else
+0,
+#endif
+&language[117],0,0,0,
+#ifdef SUBLANG_SWEDISH_FINLAND
+SUBLANG_SWEDISH_FINLAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"fo","faroe-islands",0,
+#ifdef CTRY_FAROE_ISLANDS
+CTRY_FAROE_ISLANDS,
+#else
+0,
+#endif
+&language[34],0,0,0,
+#ifdef SUBLANG_FAEROESE_FAROE_ISLANDS
+SUBLANG_FAEROESE_FAROE_ISLANDS,
+#else
+0,
+#endif
+0,0,0,
+},
+{"fr","france",0,
+#ifdef CTRY_FRANCE
+CTRY_FRANCE,
+#else
+0,
+#endif
+&language[35],0,0,0,
+#ifdef SUBLANG_FRENCH_FRANCE
+SUBLANG_FRENCH_FRANCE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"gb","united-kingdom|great-britain|england",LC_primary,
+#ifdef CTRY_UNITED_KINGDOM
+CTRY_UNITED_KINGDOM,
+#else
+#ifdef CTRY_GREAT_BRITAIN
+CTRY_GREAT_BRITAIN,
+#else
+#ifdef CTRY_ENGLAND
+CTRY_ENGLAND,
+#else
+0,
+#endif
+#endif
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_UNITED_KINGDOM
+SUBLANG_ENGLISH_UNITED_KINGDOM,
+#else
+#ifdef SUBLANG_ENGLISH_GREAT_BRITAIN
+SUBLANG_ENGLISH_GREAT_BRITAIN,
+#else
+#ifdef SUBLANG_ENGLISH_ENGLAND
+SUBLANG_ENGLISH_ENGLAND,
+#else
+0,
+#endif
+#endif
+#endif
+0,0,0,
+},
+{"gl","greenland",0,
+#ifdef CTRY_GREENLAND
+CTRY_GREENLAND,
+#else
+0,
+#endif
+&language[61],0,0,0,
+#ifdef SUBLANG_GREENLANDIC_GREENLAND
+SUBLANG_GREENLANDIC_GREENLAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"gr","greece",0,
+#ifdef CTRY_GREECE
+CTRY_GREECE,
+#else
+0,
+#endif
+&language[25],0,0,0,
+#ifdef SUBLANG_GREEK_GREECE
+SUBLANG_GREEK_GREECE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"gt","guatemala",0,
+#ifdef CTRY_GUATEMALA
+CTRY_GUATEMALA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_GUATEMALA
+SUBLANG_SPANISH_GUATEMALA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"hk","hong-kong",0,
+#ifdef CTRY_HONG_KONG
+CTRY_HONG_KONG,
+#else
+0,
+#endif
+&language[140],0,0,0,
+#ifdef SUBLANG_CHINESE_SIMPLIFIED_HONG_KONG
+SUBLANG_CHINESE_SIMPLIFIED_HONG_KONG,
+#else
+0,
+#endif
+0,0,0,
+},
+{"hn","honduras",0,
+#ifdef CTRY_HONDURAS
+CTRY_HONDURAS,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_HONDURAS
+SUBLANG_SPANISH_HONDURAS,
+#else
+0,
+#endif
+0,0,0,
+},
+{"hr","croatia",0,
+#ifdef CTRY_CROATIA
+CTRY_CROATIA,
+#else
+0,
+#endif
+&language[45],0,0,0,
+#ifdef SUBLANG_CROATIAN_CROATIA
+SUBLANG_CROATIAN_CROATIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"hu","hungary",0,
+#ifdef CTRY_HUNGARY
+CTRY_HUNGARY,
+#else
+0,
+#endif
+&language[46],0,0,0,
+#ifdef SUBLANG_HUNGARIAN_HUNGARY
+SUBLANG_HUNGARIAN_HUNGARY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"id","indonesia",0,
+#ifdef CTRY_INDONESIA
+CTRY_INDONESIA,
+#else
+0,
+#endif
+&language[49],0,0,0,
+#ifdef SUBLANG_INDONESIAN_INDONESIA
+SUBLANG_INDONESIAN_INDONESIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ie","ireland",0,
+#ifdef CTRY_IRELAND
+CTRY_IRELAND,
+#else
+0,
+#endif
+&language[26],&language[37],0,0,
+#ifdef SUBLANG_ENGLISH_IRELAND
+SUBLANG_ENGLISH_IRELAND,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_IRISH_IRELAND
+SUBLANG_IRISH_IRELAND,
+#else
+0,
+#endif
+0,0,
+},
+{"il","israel",0,
+#ifdef CTRY_ISRAEL
+CTRY_ISRAEL,
+#else
+0,
+#endif
+&language[43],0,0,0,
+#ifdef SUBLANG_HEBREW_ISRAEL
+SUBLANG_HEBREW_ISRAEL,
+#else
+0,
+#endif
+0,0,0,
+},
+{"iq","iraq",0,
+#ifdef CTRY_IRAQ
+CTRY_IRAQ,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_IRAQ
+SUBLANG_ARABIC_IRAQ,
+#else
+0,
+#endif
+0,0,0,
+},
+{"is","iceland",0,
+#ifdef CTRY_ICELAND
+CTRY_ICELAND,
+#else
+0,
+#endif
+&language[53],0,0,0,
+#ifdef SUBLANG_ICELANDIC_ICELAND
+SUBLANG_ICELANDIC_ICELAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"it","italy",0,
+#ifdef CTRY_ITALY
+CTRY_ITALY,
+#else
+0,
+#endif
+&language[54],0,0,0,
+#ifdef SUBLANG_ITALIAN_ITALY
+SUBLANG_ITALIAN_ITALY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"jm","jamaica",0,
+#ifdef CTRY_JAMAICA
+CTRY_JAMAICA,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_JAMAICA
+SUBLANG_ENGLISH_JAMAICA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"jo","jordan",0,
+#ifdef CTRY_JORDAN
+CTRY_JORDAN,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_JORDAN
+SUBLANG_ARABIC_JORDAN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"jp","japan",0,
+#ifdef CTRY_JAPAN
+CTRY_JAPAN,
+#else
+0,
+#endif
+&language[56],0,0,0,
+#ifdef SUBLANG_JAPANESE_JAPAN
+SUBLANG_JAPANESE_JAPAN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ke","kenya",0,
+#ifdef CTRY_KENYA
+CTRY_KENYA,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"kr","south-korea",0,
+#ifdef CTRY_SOUTH_KOREA
+CTRY_SOUTH_KOREA,
+#else
+0,
+#endif
+&language[64],0,0,0,
+#ifdef SUBLANG_KOREAN_SOUTH_KOREA
+SUBLANG_KOREAN_SOUTH_KOREA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"kw","kuwait",0,
+#ifdef CTRY_KUWAIT
+CTRY_KUWAIT,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_KUWAIT
+SUBLANG_ARABIC_KUWAIT,
+#else
+0,
+#endif
+0,0,0,
+},
+{"lb","lebanon",0,
+#ifdef CTRY_LEBANON
+CTRY_LEBANON,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_LEBANON
+SUBLANG_ARABIC_LEBANON,
+#else
+0,
+#endif
+0,0,0,
+},
+{"li","liechtenstein",0,
+#ifdef CTRY_LIECHTENSTEIN
+CTRY_LIECHTENSTEIN,
+#else
+0,
+#endif
+&language[23],&language[35],0,0,
+#ifdef SUBLANG_GERMAN_LIECHTENSTEIN
+SUBLANG_GERMAN_LIECHTENSTEIN,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_FRENCH_LIECHTENSTEIN
+SUBLANG_FRENCH_LIECHTENSTEIN,
+#else
+0,
+#endif
+0,0,
+},
+{"lt","lithuania",0,
+#ifdef CTRY_LITHUANIA
+CTRY_LITHUANIA,
+#else
+0,
+#endif
+&language[71],0,0,0,
+#ifdef SUBLANG_LITHUANIAN_LITHUANIA
+SUBLANG_LITHUANIAN_LITHUANIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"lu","luxembourg",0,
+#ifdef CTRY_LUXEMBOURG
+CTRY_LUXEMBOURG,
+#else
+0,
+#endif
+&language[23],&language[35],0,0,
+#ifdef SUBLANG_GERMAN_LUXEMBOURG
+SUBLANG_GERMAN_LUXEMBOURG,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_FRENCH_LUXEMBOURG
+SUBLANG_FRENCH_LUXEMBOURG,
+#else
+0,
+#endif
+0,0,
+},
+{"lv","latvia",0,
+#ifdef CTRY_LATVIA
+CTRY_LATVIA,
+#else
+0,
+#endif
+&language[72],0,0,0,
+#ifdef SUBLANG_LATVIAN_LATVIA
+SUBLANG_LATVIAN_LATVIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ly","libya",0,
+#ifdef CTRY_LIBYA
+CTRY_LIBYA,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_LIBYA
+SUBLANG_ARABIC_LIBYA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ma","morocco",0,
+#ifdef CTRY_MOROCCO
+CTRY_MOROCCO,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_MOROCCO
+SUBLANG_ARABIC_MOROCCO,
+#else
+0,
+#endif
+0,0,0,
+},
+{"mk","macedonia",0,
+#ifdef CTRY_MACEDONIA
+CTRY_MACEDONIA,
+#else
+0,
+#endif
+&language[75],0,0,0,
+#ifdef SUBLANG_MACEDONIAN_MACEDONIA
+SUBLANG_MACEDONIAN_MACEDONIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"mo","macau",0,
+#ifdef CTRY_MACAU
+CTRY_MACAU,
+#else
+0,
+#endif
+&language[140],0,0,0,
+#ifdef SUBLANG_CHINESE_SIMPLIFIED_MACAU
+SUBLANG_CHINESE_SIMPLIFIED_MACAU,
+#else
+0,
+#endif
+0,0,0,
+},
+{"mx","mexico",0,
+#ifdef CTRY_MEXICO
+CTRY_MEXICO,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_MEXICO
+SUBLANG_SPANISH_MEXICO,
+#else
+0,
+#endif
+0,0,0,
+},
+{"my","malaysia",0,
+#ifdef CTRY_MALAYSIA
+CTRY_MALAYSIA,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"ni","nicaragua",0,
+#ifdef CTRY_NICARAGUA
+CTRY_NICARAGUA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_NICARAGUA
+SUBLANG_SPANISH_NICARAGUA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"nl","netherlands",0,
+#ifdef CTRY_NETHERLANDS
+CTRY_NETHERLANDS,
+#else
+0,
+#endif
+&language[86],0,0,0,
+#ifdef SUBLANG_DUTCH_NETHERLANDS
+SUBLANG_DUTCH_NETHERLANDS,
+#else
+0,
+#endif
+0,0,0,
+},
+{"no","norway",0,
+#ifdef CTRY_NORWAY
+CTRY_NORWAY,
+#else
+0,
+#endif
+&language[84],&language[88],&language[87],0,
+#ifdef SUBLANG_NORWEGIAN_BOKMAL_NORWAY
+SUBLANG_NORWEGIAN_BOKMAL_NORWAY,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_NORWEGIAN_NORWAY
+SUBLANG_NORWEGIAN_NORWAY,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_NORWEGIAN_NYNORSK_NORWAY
+SUBLANG_NORWEGIAN_NYNORSK_NORWAY,
+#else
+0,
+#endif
+0,
+},
+{"nz","new-zealand",0,
+#ifdef CTRY_NEW_ZEALAND
+CTRY_NEW_ZEALAND,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_NEW_ZEALAND
+SUBLANG_ENGLISH_NEW_ZEALAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"om","oman",0,
+#ifdef CTRY_OMAN
+CTRY_OMAN,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_OMAN
+SUBLANG_ARABIC_OMAN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pa","panama",0,
+#ifdef CTRY_PANAMA
+CTRY_PANAMA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_PANAMA
+SUBLANG_SPANISH_PANAMA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pe","peru",0,
+#ifdef CTRY_PERU
+CTRY_PERU,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_PERU
+SUBLANG_SPANISH_PERU,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pl","poland",0,
+#ifdef CTRY_POLAND
+CTRY_POLAND,
+#else
+0,
+#endif
+&language[93],0,0,0,
+#ifdef SUBLANG_POLISH_POLAND
+SUBLANG_POLISH_POLAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pr","puerto-rico",0,
+#ifdef CTRY_PUERTO_RICO
+CTRY_PUERTO_RICO,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_PUERTO_RICO
+SUBLANG_SPANISH_PUERTO_RICO,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pt","portugal",0,
+#ifdef CTRY_PORTUGAL
+CTRY_PORTUGAL,
+#else
+0,
+#endif
+&language[95],0,0,0,
+#ifdef SUBLANG_PORTUGUESE_PORTUGAL
+SUBLANG_PORTUGUESE_PORTUGAL,
+#else
+0,
+#endif
+0,0,0,
+},
+{"py","paraguay",0,
+#ifdef CTRY_PARAGUAY
+CTRY_PARAGUAY,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_PARAGUAY
+SUBLANG_SPANISH_PARAGUAY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ro","romania",0,
+#ifdef CTRY_ROMANIA
+CTRY_ROMANIA,
+#else
+0,
+#endif
+&language[99],0,0,0,
+#ifdef SUBLANG_ROMANIAN_ROMANIA
+SUBLANG_ROMANIAN_ROMANIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ru","russia",0,
+#ifdef CTRY_RUSSIA
+CTRY_RUSSIA,
+#else
+0,
+#endif
+&language[100],0,0,0,
+#ifdef SUBLANG_RUSSIAN_RUSSIA
+SUBLANG_RUSSIAN_RUSSIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sa","saudi-arabia",0,
+#ifdef CTRY_SAUDI_ARABIA
+CTRY_SAUDI_ARABIA,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_SAUDI_ARABIA
+SUBLANG_ARABIC_SAUDI_ARABIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"se","sweden",LC_primary,
+#ifdef CTRY_SWEDEN
+CTRY_SWEDEN,
+#else
+0,
+#endif
+&language[117],0,0,0,
+#ifdef SUBLANG_SWEDISH_SWEDEN
+SUBLANG_SWEDISH_SWEDEN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sg","singapore",0,
+#ifdef CTRY_SINGAPORE
+CTRY_SINGAPORE,
+#else
+0,
+#endif
+&language[140],0,0,0,
+#ifdef SUBLANG_CHINESE_SIMPLIFIED_SINGAPORE
+SUBLANG_CHINESE_SIMPLIFIED_SINGAPORE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"si","slovenia",0,
+#ifdef CTRY_SLOVENIA
+CTRY_SLOVENIA,
+#else
+0,
+#endif
+&language[108],0,0,0,
+#ifdef SUBLANG_SLOVENIAN_SLOVENIA
+SUBLANG_SLOVENIAN_SLOVENIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sk","slovakia",0,
+#ifdef CTRY_SLOVAKIA
+CTRY_SLOVAKIA,
+#else
+0,
+#endif
+&language[107],0,0,0,
+#ifdef SUBLANG_SLOVAK_SLOVAKIA
+SUBLANG_SLOVAK_SLOVAKIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sp","serbia",0,
+#ifdef CTRY_SERBIA
+CTRY_SERBIA,
+#else
+0,
+#endif
+&language[113],0,0,0,
+#ifdef SUBLANG_SERBIAN_SERBIA
+SUBLANG_SERBIAN_SERBIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sv","el-salvador",0,
+#ifdef CTRY_EL_SALVADOR
+CTRY_EL_SALVADOR,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_EL_SALVADOR
+SUBLANG_SPANISH_EL_SALVADOR,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sy","syria",0,
+#ifdef CTRY_SYRIA
+CTRY_SYRIA,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_SYRIA
+SUBLANG_ARABIC_SYRIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"th","thailand",0,
+#ifdef CTRY_THAILAND
+CTRY_THAILAND,
+#else
+0,
+#endif
+&language[122],0,0,0,
+#ifdef SUBLANG_THAI_THAILAND
+SUBLANG_THAI_THAILAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"tn","tunisia",0,
+#ifdef CTRY_TUNISIA
+CTRY_TUNISIA,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_TUNISIA
+SUBLANG_ARABIC_TUNISIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"tr","turkey",0,
+#ifdef CTRY_TURKEY
+CTRY_TURKEY,
+#else
+0,
+#endif
+&language[128],0,0,0,
+#ifdef SUBLANG_TURKISH_TURKEY
+SUBLANG_TURKISH_TURKEY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"tt","trinidad&tobago",0,
+#ifdef CTRY_TRINIDAD_TOBAGO
+CTRY_TRINIDAD_TOBAGO,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_TRINIDAD_TOBAGO
+SUBLANG_ENGLISH_TRINIDAD_TOBAGO,
+#else
+0,
+#endif
+0,0,0,
+},
+{"tw","taiwan",0,
+#ifdef CTRY_TAIWAN
+CTRY_TAIWAN,
+#else
+0,
+#endif
+&language[131],0,0,0,
+#ifdef SUBLANG_CHINESE_TRADITIONAL_TAIWAN
+SUBLANG_CHINESE_TRADITIONAL_TAIWAN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ua","ukraine",0,
+#ifdef CTRY_UKRAINE
+CTRY_UKRAINE,
+#else
+0,
+#endif
+&language[132],&language[100],0,0,
+#ifdef SUBLANG_UKRAINIAN_UKRAINE
+SUBLANG_UKRAINIAN_UKRAINE,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_RUSSIAN_UKRAINE
+SUBLANG_RUSSIAN_UKRAINE,
+#else
+0,
+#endif
+0,0,
+},
+{"uk","united-kingdom",LC_primary,
+#ifdef CTRY_UNITED_KINGDOM
+CTRY_UNITED_KINGDOM,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_UNITED_KINGDOM
+SUBLANG_ENGLISH_UNITED_KINGDOM,
+#else
+0,
+#endif
+0,0,0,
+},
+{"us","united-states|usa",0,
+#ifdef CTRY_UNITED_STATES
+CTRY_UNITED_STATES,
+#else
+#ifdef CTRY_USA
+CTRY_USA,
+#else
+0,
+#endif
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_UNITED_STATES
+SUBLANG_ENGLISH_UNITED_STATES,
+#else
+#ifdef SUBLANG_ENGLISH_USA
+SUBLANG_ENGLISH_USA,
+#else
+0,
+#endif
+#endif
+0,0,0,
+},
+{"uy","uruguay",0,
+#ifdef CTRY_URUGUAY
+CTRY_URUGUAY,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_URUGUAY
+SUBLANG_SPANISH_URUGUAY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ve","venezuela",0,
+#ifdef CTRY_VENEZUELA
+CTRY_VENEZUELA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_VENEZUELA
+SUBLANG_SPANISH_VENEZUELA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"yu","yugoslavia",0,
+#ifdef CTRY_YUGOSLAVIA
+CTRY_YUGOSLAVIA,
+#else
+0,
+#endif
+&language[113],0,0,0,
+#ifdef SUBLANG_SERBIAN_YUGOSLAVIA
+SUBLANG_SERBIAN_YUGOSLAVIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"za","south-africa",0,
+#ifdef CTRY_SOUTH_AFRICA
+CTRY_SOUTH_AFRICA,
+#else
+0,
+#endif
+&language[4],0,0,0,
+#ifdef SUBLANG_AFRIKAANS_SOUTH_AFRICA
+SUBLANG_AFRIKAANS_SOUTH_AFRICA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"zw","zimbabwe",0,
+#ifdef CTRY_ZIMBABWE
+CTRY_ZIMBABWE,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_ZIMBABWE
+SUBLANG_ENGLISH_ZIMBABWE,
+#else
+0,
+#endif
+0,0,0,
+},
+ 0
+};
+
+static const Lc_map_t map[] =
+{
+{"enu",&language[26],&territory[93],&charset[0],0},
+{"enz",&language[26],&territory[68],&charset[0],0},
+{"esm",&language[28],&territory[63],&charset[0],0},
+{"esn",&language[28],&territory[30],&charset[0],&attribute_es[1]},
+{"esp",&language[28],&territory[30],&charset[0],&attribute_es[0]},
+{"usa",&language[26],&territory[93],&charset[0],0},
+ 0
+};
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/preroot.h b/usr/src/lib/libast/sparc/src/lib/libast/preroot.h
new file mode 100644
index 0000000000..7780f31251
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/preroot.h
@@ -0,0 +1,6 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/preroot.sh by iffe version 2007-04-04 : : */
+#ifndef _def_preroot_ast
+#define _def_preroot_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* preroot not enabled */
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/sig.h b/usr/src/lib/libast/sparc/src/lib/libast/sig.h
new file mode 100644
index 0000000000..72939b001b
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/sig.h
@@ -0,0 +1,131 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/sig.sh by iffe version 2007-04-04 : : */
+#ifndef _def_sig_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_sig_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define sig_info _sig_info_
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide kill killpg
+#else
+#define kill ______kill
+#define killpg ______killpg
+#endif
+#include <signal.h>
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide kill killpg
+#else
+#undef kill
+#undef killpg
+#endif
+#ifndef sigmask
+#define sigmask(s) (1<<((s)-1))
+#endif
+typedef void (*Sig_handler_t) __PROTO__((int));
+
+
+#define Handler_t Sig_handler_t
+
+#define SIG_REG_PENDING (-1)
+#define SIG_REG_POP 0
+#define SIG_REG_EXEC 00001
+#define SIG_REG_PROC 00002
+#define SIG_REG_TERM 00004
+#define SIG_REG_ALL 00777
+#define SIG_REG_SET 01000
+
+typedef struct
+{
+ char** name;
+ char** text;
+ int sigmax;
+} Sig_info_t;
+
+extern __MANGLE__ int kill __PROTO__((pid_t, int));
+extern __MANGLE__ int killpg __PROTO__((pid_t, int));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Sig_info_t sig_info;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int sigcritical __PROTO__((int));
+extern __MANGLE__ int sigunblock __PROTO__((int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/tmx.h b/usr/src/lib/libast/sparc/src/lib/libast/tmx.h
new file mode 100644
index 0000000000..f9d742ea73
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/tmx.h
@@ -0,0 +1,128 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/tmx by iffe version 2007-04-04 : : */
+
+#ifndef _TMX_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TMX_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Time_t support
+ */
+
+#include <tm.h>
+#include <tv.h>
+
+#define TMX_MAXDATE "2554-07-21+23:34:33.709551614 UTC"
+#define TMX_MAXYEAR 2554
+#define TMX_MAXSEC ((Time_t)18446744073)
+#define TMX_MAXNSEC 709551614
+#define TMX_RESOLUTION 1000000000
+
+typedef uint64_t Time_t;
+typedef uint64_t Tmxsec_t;
+typedef uint32_t Tmxnsec_t;
+
+#define tmxsec(t) ((Tmxsec_t)((t)/1000000000))
+#define tmxnsec(t) ((Tmxnsec_t)((t)%1000000000))
+#define tmxsns(s,n) (((((Time_t)(s))*1000000000))+((Time_t)(n)))
+
+#define TMX_NOTIME ((Time_t)(-1))
+#define TMX_NOW tmxgettime()
+#define TMX_MAXTIME tmxsns(TMX_MAXSEC,TMX_MAXNSEC)
+
+#define tmx2tv(t,v) ((v)->tv_nsec=tmxnsec(t),(v)->tv_sec=tmxsec(t))
+#define tv2tmx(v) tmxsns((v)->tv_sec,(v)->tv_nsec)
+
+#define tmxclock(p) tmxsns(((p)?*(p):time(NiL)),0)
+
+#define tmxgetatime(s) tmxsns((s)->st_atime,ST_ATIME_NSEC_GET(s))
+#define tmxgetctime(s) tmxsns((s)->st_ctime,ST_CTIME_NSEC_GET(s))
+#define tmxgetmtime(s) tmxsns((s)->st_mtime,ST_MTIME_NSEC_GET(s))
+
+#define tmxsetatime(s,t) ((s)->st_atime=tmxsec(t),ST_ATIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetctime(s,t) ((s)->st_ctime=tmxsec(t),ST_CTIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetmtime(s,t) ((s)->st_mtime=tmxsec(t),ST_MTIME_NSEC_SET(s,tmxnsec(t)))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Time_t tmxdate __PROTO__((const char*, char**, Time_t));
+extern __MANGLE__ char* tmxfmt __PROTO__((char*, size_t, const char*, Time_t));
+extern __MANGLE__ Time_t tmxleap __PROTO__((Time_t));
+extern __MANGLE__ Tm_t* tmxmake __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxscan __PROTO__((const char*, char**, const char*, char**, Time_t, long));
+extern __MANGLE__ int tmxsleep __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxtime __PROTO__((Tm_t*, int));
+
+extern __MANGLE__ Time_t tmxgettime __PROTO__((void));
+extern __MANGLE__ int tmxsettime __PROTO__((Time_t));
+
+extern __MANGLE__ int tmxtouch __PROTO__((const char*, Time_t, Time_t, Time_t, int));
+
+extern __MANGLE__ char* fmttmx __PROTO__((const char*, Time_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparc/src/lib/libast/tv.h b/usr/src/lib/libast/sparc/src/lib/libast/tv.h
new file mode 100644
index 0000000000..9ec820b351
--- /dev/null
+++ b/usr/src/lib/libast/sparc/src/lib/libast/tv.h
@@ -0,0 +1,111 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libast/features/tv by iffe version 2007-04-04 : : */
+
+#ifndef _TV_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TV_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Tv_t interface definitions
+ */
+
+#include <ast.h>
+
+#define TV_NSEC_IGNORE (1000000000L)
+#define TV_TOUCH_RETAIN ((Tv_t*)1)
+
+typedef struct Tv_s
+{
+ uint32_t tv_sec;
+ uint32_t tv_nsec;
+} Tv_t;
+
+#define ST_ATIME_NSEC_GET(st) ((st)->st_atim.tv_nsec)
+#define ST_CTIME_NSEC_GET(st) ((st)->st_ctim.tv_nsec)
+#define ST_MTIME_NSEC_GET(st) ((st)->st_mtim.tv_nsec)
+
+#define ST_ATIME_NSEC_SET(st,n) (ST_ATIME_NSEC_GET(st)=(n))
+#define ST_CTIME_NSEC_SET(st,n) (ST_CTIME_NSEC_GET(st)=(n))
+#define ST_MTIME_NSEC_SET(st,n) (ST_MTIME_NSEC_GET(st)=(n))
+
+#define tvgetatime(t,s) ((t)->tv_nsec=ST_ATIME_NSEC_GET(s),(t)->tv_sec=(s)->st_atime)
+#define tvgetmtime(t,s) ((t)->tv_nsec=ST_MTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_mtime)
+#define tvgetctime(t,s) ((t)->tv_nsec=ST_CTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_ctime)
+
+#define tvsetatime(t,s) (ST_ATIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_atime=(t)->tv_sec)
+#define tvsetmtime(t,s) (ST_MTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_mtime=(t)->tv_sec)
+#define tvsetctime(t,s) (ST_CTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_ctime=(t)->tv_sec)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int tvgettime __PROTO__((Tv_t*));
+extern __MANGLE__ int tvsettime __PROTO__((const Tv_t*));
+extern __MANGLE__ int tvcmp __PROTO__((const Tv_t*, const Tv_t*));
+extern __MANGLE__ int tvtouch __PROTO__((const char*, const Tv_t*, const Tv_t*, const Tv_t*, int));
+extern __MANGLE__ int tvsleep __PROTO__((const Tv_t*, Tv_t*));
+
+extern __MANGLE__ char* fmttv __PROTO__((const char*, Tv_t*));
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/Makefile b/usr/src/lib/libast/sparcv9/Makefile
new file mode 100644
index 0000000000..2c6089c89c
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/Makefile
@@ -0,0 +1,48 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+# Fetch minor version from RELEASE, e.g. "10" for "5.10", "11" for "5.11" etc.
+GETRELEASEMINOR = /usr/bin/ksh -c 'x=$(RELEASE) ; print "$${x$(POUND_SIGN)$(POUND_SIGN)*.}"'
+
+# Platform-specific config
+# Note that "HOSTTYPE" matches the value used by AT&T upstream.
+ASTPLATFORMCPPFLAGS = '-DHOSTTYPE="sol$(GETRELEASEMINOR:sh).sun4"'
+
+# platform-specific sources
+OBJECTS = \
+ sparcv9/src/lib/libast/conftab.o
+OBJDIRS = \
+ sparcv9/src/lib/libast
+
+include ../Makefile.com
+include ../../Makefile.lib.64
+
+# Use -KPIC since libast is too big for -Kpic on 64bit
+# (and on 32bit it is close to the barrier)
+sparcv9_C_PICFLAGS = $(C_BIGPICFLAGS)
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/libast/sparcv9/include/ast/align.h b/usr/src/lib/libast/sparcv9/include/ast/align.h
new file mode 100644
index 0000000000..5b874e5ecc
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/align.h
@@ -0,0 +1,54 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/align.c by iffe version 2007-04-04 : : */
+#ifndef _def_align_ast
+#define _def_align_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+typedef unsigned long ALIGN_INTEGRAL;
+
+#define ALIGN_CHUNK 8192
+#define ALIGN_INTEGRAL long
+#define ALIGN_INTEGER(x) ((ALIGN_INTEGRAL)(x))
+#define ALIGN_POINTER(x) ((char*)(x))
+#define ALIGN_ROUND(x,y) ALIGN_POINTER(ALIGN_INTEGER((x)+(y)-1)&~((y)-1))
+
+#define ALIGN_BOUND ALIGN_BOUND2
+#define ALIGN_ALIGN(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC(x) ALIGN_TRUNC2(x)
+
+#define ALIGN_BIT1 0x1
+#define ALIGN_BOUND1 ALIGN_BOUND2
+#define ALIGN_ALIGN1(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC1(x) ALIGN_TRUNC2(x)
+#define ALIGN_CLRBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffffe)
+#define ALIGN_SETBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x1)
+#define ALIGN_TSTBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x1)
+
+#define ALIGN_BIT2 0x2
+#define ALIGN_BOUND2 16
+#define ALIGN_ALIGN2(x) ALIGN_TRUNC2((x)+15)
+#define ALIGN_TRUNC2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffff0)
+#define ALIGN_CLRBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffffd)
+#define ALIGN_SETBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x2)
+#define ALIGN_TSTBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x2)
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast.h b/usr/src/lib/libast/sparcv9/include/ast/ast.h
new file mode 100644
index 0000000000..ea1569f946
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast.h
@@ -0,0 +1,381 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Advanced Software Technology Library
+ * AT&T Research
+ *
+ * std + posix + ast
+ */
+
+#ifndef _AST_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_H
+
+#include <ast_version.h>
+
+#ifndef _AST_STD_H
+#include <ast_std.h>
+#endif
+
+#ifndef _SFIO_H
+#include <sfio.h>
+#endif
+
+#ifndef ast
+#define ast _ast_info
+#endif
+
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif
+
+/*
+ * workaround botched headers that assume <stdio.h>
+ */
+
+#ifndef FILE
+#ifndef _SFIO_H
+struct _sfio_s;
+#endif
+#define FILE struct _sfio_s
+#ifndef __FILE_typedef
+#define __FILE_typedef 1
+#endif
+#ifndef _FILEDEFED
+#define _FILEDEFED 1
+#endif
+#endif
+
+/*
+ * exit() support -- this matches shell exit codes
+ */
+
+#define EXIT_BITS 8 /* # exit status bits */
+
+#define EXIT_USAGE 2 /* usage exit code */
+#define EXIT_QUIT ((1<<(EXIT_BITS))-1) /* parent should quit */
+#define EXIT_NOTFOUND ((1<<(EXIT_BITS-1))-1) /* command not found */
+#define EXIT_NOEXEC ((1<<(EXIT_BITS-1))-2) /* other exec error */
+
+#define EXIT_CODE(x) ((x)&((1<<EXIT_BITS)-1))
+#define EXIT_CORE(x) (EXIT_CODE(x)|(1<<EXIT_BITS)|(1<<(EXIT_BITS-1)))
+#define EXIT_TERM(x) (EXIT_CODE(x)|(1<<EXIT_BITS))
+
+/*
+ * NOTE: for compatibility the following work for EXIT_BITS={7,8}
+ */
+
+#define EXIT_STATUS(x) (((x)&((1<<(EXIT_BITS-2))-1))?(x):EXIT_CODE((x)>>EXIT_BITS))
+
+#define EXITED_CORE(x) (((x)&((1<<EXIT_BITS)|(1<<(EXIT_BITS-1))))==((1<<EXIT_BITS)|(1<<(EXIT_BITS-1)))||((x)&((1<<(EXIT_BITS-1))|(1<<(EXIT_BITS-2))))==((1<<(EXIT_BITS-1))|(1<<(EXIT_BITS-2))))
+#define EXITED_TERM(x) ((x)&((1<<EXIT_BITS)|(1<<(EXIT_BITS-1))))
+
+/*
+ * astconflist() flags
+ */
+
+#define ASTCONF_parse 0x0001
+#define ASTCONF_write 0x0002
+#define ASTCONF_read 0x0004
+#define ASTCONF_lower 0x0008
+#define ASTCONF_base 0x0010
+#define ASTCONF_defined 0x0020
+#define ASTCONF_quote 0x0040
+#define ASTCONF_table 0x0080
+#define ASTCONF_matchcall 0x0100
+#define ASTCONF_matchname 0x0200
+#define ASTCONF_matchstandard 0x0400
+#define ASTCONF_error 0x0800
+#define ASTCONF_system 0x1000
+#define ASTCONF_AST 0x2000
+
+/*
+ * pathcanon() flags
+ */
+
+#define PATH_PHYSICAL 01
+#define PATH_DOTDOT 02
+#define PATH_EXISTS 04
+#define PATH_VERIFIED(n) (((n)&01777)<<5)
+
+/*
+ * pathaccess() flags
+ */
+
+#define PATH_READ 004
+#define PATH_WRITE 002
+#define PATH_EXECUTE 001
+#define PATH_REGULAR 010
+#define PATH_ABSOLUTE 020
+
+/*
+ * touch() flags
+ */
+
+#define PATH_TOUCH_CREATE 01
+#define PATH_TOUCH_VERBATIM 02
+
+/*
+ * pathcheck() info
+ */
+
+typedef struct
+{
+ unsigned long date;
+ char* feature;
+ char* host;
+ char* user;
+} Pathcheck_t;
+
+/*
+ * strgrpmatch() flags
+ */
+
+#define STR_MAXIMAL 01 /* maximal match */
+#define STR_LEFT 02 /* implicit left anchor */
+#define STR_RIGHT 04 /* implicit right anchor */
+#define STR_ICASE 010 /* ignore case */
+#define STR_GROUP 020 /* (|&) inside [@|&](...) only */
+
+/*
+ * fmtquote() flags
+ */
+
+#define FMT_ALWAYS 0x01 /* always quote */
+#define FMT_ESCAPED 0x02 /* already escaped */
+#define FMT_SHELL 0x04 /* escape $ ` too */
+#define FMT_WIDE 0x08 /* don't escape 8 bit chars */
+#define FMT_PARAM 0x10 /* disable FMT_SHELL ${$( quote */
+
+/*
+ * multibyte macros
+ */
+
+#define mbmax() (ast.mb_cur_max)
+#define mberr() (ast.tmp_int<0)
+
+#define mbcoll() (ast.mb_xfrm!=0)
+#define mbwide() (mbmax()>1)
+
+#define mbchar(p) (mbwide()?((ast.tmp_int=(*ast.mb_towc)(&ast.tmp_wchar,(char*)(p),mbmax()))>0?((p+=ast.tmp_int),ast.tmp_wchar):(p++,ast.tmp_int)):(*(unsigned char*)(p++)))
+#define mbinit() (mbwide()?(*ast.mb_towc)((wchar_t*)0,(char*)0,mbmax()):0)
+#define mbsize(p) (mbwide()?(*ast.mb_len)((char*)(p),mbmax()):((p),1))
+#define mbconv(s,w) (ast.mb_conv?(*ast.mb_conv)(s,w):((*(s)=(w)),1))
+#define mbwidth(w) (ast.mb_width&&((ast.tmp_int=(*ast.mb_width)(w))>=0||(w)>UCHAR_MAX)?ast.tmp_int:1)
+#define mbxfrm(t,f,n) (mbcoll()?(*ast.mb_xfrm)((char*)(t),(char*)(f),n):0)
+
+/*
+ * common macros
+ */
+
+#define elementsof(x) (sizeof(x)/sizeof(x[0]))
+#define integralof(x) (((char*)(x))-((char*)0))
+#define newof(p,t,n,x) ((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)calloc(1,sizeof(t)*(n)+(x)))
+#define oldof(p,t,n,x) ((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)malloc(sizeof(t)*(n)+(x)))
+#define pointerof(x) ((__V_*)((char*)0+(x)))
+#define roundof(x,y) (((x)+(y)-1)&~((y)-1))
+#define ssizeof(x) ((int)sizeof(x))
+
+#define streq(a,b) (*(a)==*(b)&&!strcmp(a,b))
+#define strneq(a,b,n) (*(a)==*(b)&&!strncmp(a,b,n))
+#define strsignal(s) fmtsignal(s)
+
+#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
+#define NiL 0
+#define NoP(x) (void)(x)
+#else
+#define NiL ((char*)0)
+#define NoP(x) (&x,1)
+#endif
+
+#if !defined(NoF)
+#if defined(__STDC__) || defined(__STDPP__)
+#define NoF(x) void _DATA_ ## x () {}
+#else
+#define NoF(x) void _DATA_/**/x () {}
+#endif
+#if !defined(_DATA_)
+#define _DATA_
+#endif
+#endif
+
+#if !defined(NoN)
+#if defined(__STDC__) || defined(__STDPP__)
+#define NoN(x) void _STUB_ ## x () {}
+#else
+#define NoN(x) void _STUB_/**/x () {}
+#endif
+#if !defined(_STUB_)
+#define _STUB_
+#endif
+#endif
+
+#define NOT_USED(x) NoP(x)
+
+typedef int (*Error_f) __PROTO__((__V_*, __V_*, int, ...));
+
+typedef int (*Ast_confdisc_f) __PROTO__((const char*, const char*, const char*));
+typedef int (*Strcmp_context_f) __PROTO__((const char*, const char*, __V_*));
+typedef int (*Strcmp_f) __PROTO__((const char*, const char*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ char* astgetconf __PROTO__((const char*, const char*, const char*, int, Error_f));
+extern __MANGLE__ char* astconf __PROTO__((const char*, const char*, const char*));
+extern __MANGLE__ Ast_confdisc_f astconfdisc __PROTO__((Ast_confdisc_f));
+extern __MANGLE__ void astconflist __PROTO__((Sfio_t*, const char*, int, const char*));
+extern __MANGLE__ off_t astcopy __PROTO__((int, int, off_t));
+extern __MANGLE__ int astlicense __PROTO__((char*, int, char*, char*, int, int, int));
+extern __MANGLE__ int astquery __PROTO__((int, const char*, ...));
+extern __MANGLE__ void astwinsize __PROTO__((int, int*, int*));
+
+extern __MANGLE__ ssize_t base64encode __PROTO__((const __V_*, size_t, __V_**, __V_*, size_t, __V_**));
+extern __MANGLE__ ssize_t base64decode __PROTO__((const __V_*, size_t, __V_**, __V_*, size_t, __V_**));
+extern __MANGLE__ int chresc __PROTO__((const char*, char**));
+extern __MANGLE__ int chrtoi __PROTO__((const char*));
+extern __MANGLE__ int eaccess __PROTO__((const char*, int));
+extern __MANGLE__ char* fmtbase __PROTO__((long, int, int));
+extern __MANGLE__ char* fmtbasell __PROTO__((intmax_t, int, int));
+#define fmtbase(a,b,c) fmtbasell((intmax_t)(a),b,c) /* until 2003-09-01 */
+extern __MANGLE__ char* fmtbuf __PROTO__((size_t));
+extern __MANGLE__ char* fmtclock __PROTO__((Sfulong_t));
+extern __MANGLE__ char* fmtelapsed __PROTO__((unsigned long, int));
+extern __MANGLE__ char* fmterror __PROTO__((int));
+extern __MANGLE__ char* fmtesc __PROTO__((const char*));
+extern __MANGLE__ char* fmtesq __PROTO__((const char*, const char*));
+extern __MANGLE__ char* fmtident __PROTO__((const char*));
+extern __MANGLE__ char* fmtip4 __PROTO__((uint32_t, int));
+extern __MANGLE__ char* fmtfmt __PROTO__((const char*));
+extern __MANGLE__ char* fmtgid __PROTO__((int));
+extern __MANGLE__ char* fmtmatch __PROTO__((const char*));
+extern __MANGLE__ char* fmtmode __PROTO__((int, int));
+extern __MANGLE__ char* fmtnesq __PROTO__((const char*, const char*, size_t));
+extern __MANGLE__ char* fmtnum __PROTO__((unsigned long, int));
+extern __MANGLE__ char* fmtperm __PROTO__((int));
+extern __MANGLE__ char* fmtquote __PROTO__((const char*, const char*, const char*, size_t, int));
+extern __MANGLE__ char* fmtre __PROTO__((const char*));
+extern __MANGLE__ char* fmtscale __PROTO__((Sfulong_t, int));
+extern __MANGLE__ char* fmtsignal __PROTO__((int));
+extern __MANGLE__ char* fmttime __PROTO__((const char*, time_t));
+extern __MANGLE__ char* fmtuid __PROTO__((int));
+extern __MANGLE__ char* fmtversion __PROTO__((unsigned long));
+extern __MANGLE__ __V_* memdup __PROTO__((const __V_*, size_t));
+extern __MANGLE__ void memfatal __PROTO__((void));
+extern __MANGLE__ unsigned int memhash __PROTO__((const __V_*, int));
+extern __MANGLE__ unsigned long memsum __PROTO__((const __V_*, int, unsigned long));
+extern __MANGLE__ char* pathaccess __PROTO__((char*, const char*, const char*, const char*, int));
+extern __MANGLE__ char* pathbin __PROTO__((void));
+extern __MANGLE__ char* pathcanon __PROTO__((char*, int));
+extern __MANGLE__ char* pathcat __PROTO__((char*, const char*, int, const char*, const char*));
+extern __MANGLE__ int pathcd __PROTO__((const char*, const char*));
+extern __MANGLE__ int pathcheck __PROTO__((const char*, const char*, Pathcheck_t*));
+extern __MANGLE__ int pathexists __PROTO__((char*, int));
+extern __MANGLE__ char* pathfind __PROTO__((const char*, const char*, const char*, char*, size_t));
+extern __MANGLE__ int pathgetlink __PROTO__((const char*, char*, int));
+extern __MANGLE__ int pathinclude __PROTO__((const char*));
+extern __MANGLE__ char* pathkey __PROTO__((char*, char*, const char*, const char*, const char*));
+extern __MANGLE__ size_t pathnative __PROTO__((const char*, char*, size_t));
+extern __MANGLE__ char* pathpath __PROTO__((char*, const char*, const char*, int));
+extern __MANGLE__ size_t pathposix __PROTO__((const char*, char*, size_t));
+extern __MANGLE__ char* pathprobe __PROTO__((char*, char*, const char*, const char*, const char*, int));
+extern __MANGLE__ char* pathrepl __PROTO__((char*, const char*, const char*));
+extern __MANGLE__ int pathsetlink __PROTO__((const char*, const char*));
+extern __MANGLE__ char* pathshell __PROTO__((void));
+extern __MANGLE__ char* pathtemp __PROTO__((char*, size_t, const char*, const char*, int*));
+extern __MANGLE__ char* pathtmp __PROTO__((char*, const char*, const char*, int*));
+extern __MANGLE__ char* setenviron __PROTO__((const char*));
+extern __MANGLE__ int stracmp __PROTO__((const char*, const char*));
+extern __MANGLE__ char* strcopy __PROTO__((char*, const char*));
+extern __MANGLE__ unsigned long strelapsed __PROTO__((const char*, char**, int));
+extern __MANGLE__ int stresc __PROTO__((char*));
+extern __MANGLE__ long streval __PROTO__((const char*, char**, long(*)(const char*, char**)));
+extern __MANGLE__ long strexpr __PROTO__((const char*, char**, long(*)(const char*, char**, __V_*), __V_*));
+extern __MANGLE__ int strgid __PROTO__((const char*));
+extern __MANGLE__ int strgrpmatch __PROTO__((const char*, const char*, int*, int, int));
+extern __MANGLE__ unsigned int strhash __PROTO__((const char*));
+extern __MANGLE__ __V_* strlook __PROTO__((const __V_*, size_t, const char*));
+extern __MANGLE__ int strmatch __PROTO__((const char*, const char*));
+extern __MANGLE__ int strmode __PROTO__((const char*));
+extern __MANGLE__ int strnacmp __PROTO__((const char*, const char*, size_t));
+extern __MANGLE__ char* strncopy __PROTO__((char*, const char*, size_t));
+extern __MANGLE__ double strntod __PROTO__((const char*, size_t, char**));
+extern __MANGLE__ _ast_fltmax_t strntold __PROTO__((const char*, size_t, char**));
+extern __MANGLE__ long strntol __PROTO__((const char*, size_t, char**, int));
+extern __MANGLE__ intmax_t strntoll __PROTO__((const char*, size_t, char**, int));
+extern __MANGLE__ unsigned long strntoul __PROTO__((const char*, size_t, char**, int));
+extern __MANGLE__ uintmax_t strntoull __PROTO__((const char*, size_t, char**, int));
+extern __MANGLE__ int stropt __PROTO__((const char*, const __V_*, int, int(*)(__V_*, const __V_*, int, const char*), __V_*));
+extern __MANGLE__ int strperm __PROTO__((const char*, char**, int));
+extern __MANGLE__ __V_* strpsearch __PROTO__((const __V_*, size_t, size_t, const char*, char**));
+extern __MANGLE__ __V_* strsearch __PROTO__((const __V_*, size_t, size_t, Strcmp_f, const char*, __V_*));
+extern __MANGLE__ void strsort __PROTO__((char**, int, int(*)(const char*, const char*)));
+extern __MANGLE__ char* strsubmatch __PROTO__((const char*, const char*, int));
+extern __MANGLE__ unsigned long strsum __PROTO__((const char*, unsigned long));
+extern __MANGLE__ char* strtape __PROTO__((const char*, char**));
+extern __MANGLE__ int strtoip4 __PROTO__((const char*, char**, uint32_t*, unsigned char*));
+extern __MANGLE__ long strton __PROTO__((const char*, char**, char*, int));
+extern __MANGLE__ intmax_t strtonll __PROTO__((const char*, char**, char*, int));
+extern __MANGLE__ int struid __PROTO__((const char*));
+extern __MANGLE__ int struniq __PROTO__((char**, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+/*
+ * C library global data symbols not prototyped by <unistd.h>
+ */
+
+#if !defined(environ) && defined(__DYNAMIC__)
+#define environ __DYNAMIC__(environ)
+#else
+extern __MANGLE__ char** environ;
+#endif
+
+/*
+ * really handy malloc()/free() (__FILE__,__LINE__,__FUNCTION__) tracing
+ * make with VMDEBUG==1 or debug=1 or CCFLAGS=$(CC.DEBUG)
+ * VMDEBUG==0 disables
+ * at runtime export VMDEBUG or VMTRACE per vmalloc.3
+ * to list originating call locations
+ */
+
+#if !_std_malloc && !defined(VMFL) && !defined(_VMHDR_H) && \
+ (!defined(VMDEBUG) || VMDEBUG) && (VMDEBUG || _BLD_DEBUG)
+
+#define VMFL 1
+#include <vmalloc.h>
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_botch.h b/usr/src/lib/libast/sparcv9/include/ast/ast_botch.h
new file mode 100644
index 0000000000..62ab0a2325
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_botch.h
@@ -0,0 +1,26 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/botch.c by iffe version 2007-04-04 : : */
+#ifndef _def_botch_ast
+#define _def_botch_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_ccode.h b/usr/src/lib/libast/sparcv9/include/ast/ast_ccode.h
new file mode 100644
index 0000000000..044a145303
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_ccode.h
@@ -0,0 +1,50 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/ccode by iffe version 2007-04-04 : : */
+#ifndef _def_ccode_ast
+#define _def_ccode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define CC_ASCII 1 /* ISO-8859-1 */
+#define CC_EBCDIC_E 2 /* Xopen dd(1) EBCDIC */
+#define CC_EBCDIC_I 3 /* Xopen dd(1) IBM */
+#define CC_EBCDIC_O 4 /* IBM-1047 mvs OpenEdition */
+#define CC_EBCDIC_S 5 /* Siemens posix-bc */
+#define CC_EBCDIC_H 6 /* IBM-37 AS/400 */
+#define CC_EBCDIC_M 7 /* IBM mvs cobol */
+#define CC_EBCDIC_U 8 /* microfocus cobol */
+
+#define CC_MAPS 8 /* number of code maps */
+
+#define CC_EBCDIC CC_EBCDIC_E
+#define CC_EBCDIC1 CC_EBCDIC_E
+#define CC_EBCDIC2 CC_EBCDIC_I
+#define CC_EBCDIC3 CC_EBCDIC_O
+
+#define CC_NATIVE CC_ASCII /* native character code */
+#define CC_ALIEN CC_EBCDIC /* alien character code */
+
+#define CC_bel 0007 /* bel character */
+#define CC_esc 0033 /* esc character */
+#define CC_sub 0032 /* sub character */
+#define CC_vt 0013 /* vt character */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_common.h b/usr/src/lib/libast/sparcv9/include/ast/ast_common.h
new file mode 100644
index 0000000000..439e2a78f2
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_common.h
@@ -0,0 +1,220 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/common by iffe version 2007-04-04 : : */
+#ifndef _AST_COMMON_H
+#define _AST_COMMON_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_pthread 1 /* #include <pthread.h> ok */
+#define _hdr_stdarg 1 /* #include <stdarg.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdint 1 /* #include <stdint.h> ok */
+#define _hdr_inttypes 1 /* #include <inttypes.h> ok */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_long_double 1 /* long double is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _std_proto 1 /* standard C prototypes ok */
+#define _ptr_void 1 /* standard C void* ok */
+/* disable non-standard linux/gnu inlines */
+#ifdef __GNUC__
+# undef __OPTIMIZE_SIZE__
+# define __OPTIMIZE_SIZE__ 1
+#endif
+
+/* __STD_C indicates that the language is ANSI-C or C++ */
+#if !defined(__STD_C) && __STDC__
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && (__cplusplus || c_plusplus)
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && _std_proto
+# define __STD_C 1
+#endif
+#if !defined(__STD_C)
+# define __STD_C 0
+#endif
+
+/* extern symbols must be protected against C++ name mangling */
+#ifndef _BEGIN_EXTERNS_
+# if __cplusplus || c_plusplus
+# define _BEGIN_EXTERNS_ extern "C" {
+# define _END_EXTERNS_ }
+# else
+# define _BEGIN_EXTERNS_
+# define _END_EXTERNS_
+# endif
+#endif
+
+/* _ARG_ simplifies function prototyping among flavors of C */
+#ifndef _ARG_
+# if __STD_C
+# define _ARG_(x) x
+# else
+# define _ARG_(x) ()
+# endif
+#endif
+
+/* _NIL_ simplifies defining nil pointers to a given type */
+#ifndef _NIL_
+# define _NIL_(x) ((x)0)
+#endif
+
+/* __INLINE__ is the inline keyword */
+#if !defined(__INLINE__) && defined(__cplusplus)
+# define __INLINE__ inline
+#endif
+#if !defined(__INLINE__) && defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+#endif
+
+/* Void_t is defined so that Void_t* can address any type */
+#ifndef Void_t
+# if __STD_C
+# define Void_t void
+# else
+# define Void_t char
+# endif
+#endif
+
+/* windows variants and veneers */
+#if !defined(_WINIX) && (_UWIN || __CYGWIN__ || __EMX__)
+# define _WINIX 1
+#endif
+
+/* dynamic linked library external scope handling */
+#ifdef __DYNAMIC__
+# undef __DYNAMIC__
+# ifndef _DLL
+# define _DLL 1
+# endif
+#endif
+#if _dll_import
+# if _BLD_STATIC && !_BLD_DLL
+# undef _DLL
+# else
+# if !_UWIN && !defined(_DLL)
+# define _DLL 1
+# endif
+# endif
+# if !defined(__EXPORT__) && _BLD_DLL
+# define __EXPORT__ __declspec(dllexport)
+# endif
+# if !defined(__IMPORT__) && ( _BLD_DLL || defined(_DLL) )
+# define __IMPORT__ __declspec(dllimport)
+# endif
+# if _BLD_DLL && _UWIN
+# define __DYNAMIC__(v) (_ast_getdll()->_ast_ ## v)
+# endif
+#endif
+#if !defined(_astimport)
+# if defined(__IMPORT__) && defined(_DLL)
+# define _astimport __IMPORT__
+# else
+# define _astimport extern
+# endif
+#endif
+#if _dll_import && ( !_BLD_DLL || _WINIX && !_UWIN )
+# ifdef __STDC__
+# define __EXTERN__(T,obj) extern T obj; T* _imp__ ## obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__ ## obj = &obj
+# else
+# define __EXTERN__(T,obj) extern T obj; T* _imp__/**/obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__/**/obj = &obj
+# endif
+#else
+# define __EXTERN__(T,obj) extern T obj
+# define __DEFINE__(T,obj,val) T obj = val
+#endif
+
+#define _ast_LL 1 /* LL numeric suffix supported */
+#define _ast_int1_t char
+#define _ast_int2_t short
+#define _ast_int4_t int
+#define _ast_int8_t long
+#define _ast_intmax_t _ast_int8_t
+#define _ast_intmax_long 1
+#define _ast_intswap 0
+
+#define _ast_flt4_t float
+#define _ast_flt8_t double
+#define _ast_flt16_t long double
+#define _ast_fltmax_t _ast_flt16_t
+#define _typ_int8_t 1 /* int8_t is a type */
+#define _typ_uint8_t 1 /* uint8_t is a type */
+#define _typ_int16_t 1 /* int16_t is a type */
+#define _typ_uint16_t 1 /* uint16_t is a type */
+#define _typ_int32_t 1 /* int32_t is a type */
+#define _typ_uint32_t 1 /* uint32_t is a type */
+#define _typ_int64_t 1 /* int64_t is a type */
+#define _typ_uint64_t 1 /* uint64_t is a type */
+#define _typ_intmax_t 1 /* intmax_t is a type */
+#define _typ_uintmax_t 1 /* uintmax_t is a type */
+
+#ifndef va_listref
+#define va_listref(p) (p) /* pass va_list to varargs function */
+#define va_listval(p) (p) /* retrieve va_list from va_arg(ap,va_listarg) */
+#define va_listarg va_list /* va_arg() va_list type */
+#ifndef va_start
+#if __STD_C
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+#endif
+#ifndef _AST_STD_H
+# if __STD_C && _hdr_stddef
+# include <stddef.h>
+# endif
+# if _sys_types
+# include <sys/types.h>
+# endif
+# if _hdr_stdint
+# include <stdint.h>
+# else
+# if _hdr_inttypes
+# include <inttypes.h>
+# endif
+# endif
+#endif
+#if !_typ_size_t
+# define _typ_size_t 1
+ typedef int size_t;
+#endif
+#if !_typ_ssize_t
+# define _typ_ssize_t 1
+ typedef int ssize_t;
+#endif
+#ifndef _AST_STD_H
+# if !_def_map_ast
+# include <ast_map.h>
+# endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_dir.h b/usr/src/lib/libast/sparcv9/include/ast/ast_dir.h
new file mode 100644
index 0000000000..336b7f38a6
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_dir.h
@@ -0,0 +1,86 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * AT&T Research
+ *
+ * common dirent maintenance interface
+ */
+
+#ifndef _AST_DIR_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_DIR_H
+
+#include <ast_lib.h>
+
+#if _mem_d_fileno_dirent || _mem_d_ino_dirent
+#if !_mem_d_fileno_dirent
+#undef _mem_d_fileno_dirent
+#define _mem_d_fileno_dirent 1
+#define d_fileno d_ino
+#endif
+#endif
+
+#if _BLD_ast
+#include "dirlib.h"
+#else
+#include <dirent.h>
+#endif
+
+#if _mem_d_fileno_dirent
+#define D_FILENO(d) ((d)->d_fileno)
+#endif
+
+#if _mem_d_namlen_dirent
+#define D_NAMLEN(d) ((d)->d_namlen)
+#else
+#define D_NAMLEN(d) (strlen((d)->d_name))
+#endif
+
+#if _mem_d_reclen_dirent
+#define D_RECLEN(d) ((d)->d_reclen)
+#else
+#define D_RECLEN(d) D_RECSIZ(d,D_NAMLEN(d))
+#endif
+
+#define D_RECSIZ(d,n) (sizeof(*(d))-sizeof((d)->d_name)+((n)+sizeof(char*))&~(sizeof(char*)-1))
+
+/*
+ * NOTE: 2003-03-27 mac osx bug symlink==DT_REG bug discovered;
+ * the kernel *and* all directories must be fixed, so d_type
+ * is summarily disabled until we see that happen
+ */
+
+#if _mem_d_type_dirent && defined(DT_UNKNOWN) && defined(DT_REG) && defined(DT_DIR) && defined(DT_LNK) && ! ( __APPLE__ || __MACH__ )
+#define D_TYPE(d) ((d)->d_type)
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_dirent.h b/usr/src/lib/libast/sparcv9/include/ast/ast_dirent.h
new file mode 100644
index 0000000000..dc89aa9045
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_dirent.h
@@ -0,0 +1,103 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/dirent by iffe version 2007-04-04 : : */
+
+#ifndef _def_dirent_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dirent_ast 1
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _nxt_dirent <../include/dirent.h> /* include path for the native <dirent.h> */
+#define _nxt_dirent_str "../include/dirent.h" /* include string for the native <dirent.h> */
+/*
+ * <dirent.h> for systems with ok <dirent.h>
+ */
+
+#ifndef _DIRENT_H
+
+#include <../include/dirent.h> /* the native <dirent.h> */
+
+#ifndef _DIRENT_H
+#define _DIRENT_H
+#endif
+
+#endif
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_fcntl.h b/usr/src/lib/libast/sparcv9/include/ast/ast_fcntl.h
new file mode 100644
index 0000000000..7da3e4baad
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_fcntl.h
@@ -0,0 +1,135 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/fcntl.c by iffe version 2007-04-04 : : */
+#ifndef _def_fcntl_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fcntl_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <ast_fs.h>
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#define O_BINARY 0
+#define O_TEMPORARY 0
+#define O_TEXT 0
+
+#include <ast_fs.h>
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_fstat64
+#define fstat fstat64
+#endif
+#if _lib_lstat64
+#define lstat lstat64
+#endif
+#if _lib_stat64
+#define stat stat64
+#endif
+#if _lib_creat64
+#define creat creat64
+#endif
+#if _lib_mmap64
+#define mmap mmap64
+#endif
+#if _lib_open64
+#undef open
+#define open open64
+#endif
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_float.h b/usr/src/lib/libast/sparcv9/include/ast/ast_float.h
new file mode 100644
index 0000000000..3a11f21309
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_float.h
@@ -0,0 +1,233 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/float by iffe version 2007-04-04 : : */
+
+#ifndef _def_float_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_float_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_float 1 /* #include <float.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _hdr_values 1 /* #include <values.h> ok */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_frexp 1 /* frexp() in default lib(s) */
+#define _lib_frexpl 1 /* frexpl() in default lib(s) */
+#define _lib_ldexp 1 /* ldexp() in default lib(s) */
+#define _lib_ldexpl 1 /* ldexpl() in default lib(s) */
+#define _lib_finite 1 /* finite() in default lib(s) */
+#define _lib_isnan 1 /* isnan() in default lib(s) */
+#define _lib_isnanl 1 /* isnanl() in default lib(s) */
+#define _lib_copysign 1 /* copysign() in default lib(s) */
+#define _lib_copysignl 1 /* copysignl() in default lib(s) */
+#include <ast_common.h>
+#include <float.h>
+#include <math.h>
+#ifndef FLT_DIG
+#define FLT_DIG 6
+#endif
+#ifndef FLT_MAX
+#define FLT_MAX 3.4028234663852885981170E+38F
+#endif
+#ifndef FLT_MAX_10_EXP
+#define FLT_MAX_10_EXP ( + 38 )
+#endif
+#ifndef FLT_MAX_EXP
+#define FLT_MAX_EXP ( + 128 )
+#endif
+#ifndef FLT_MIN
+#define FLT_MIN 1.1754943508222875079688E-38F
+#endif
+#ifndef FLT_MIN_10_EXP
+#define FLT_MIN_10_EXP ( - 37 )
+#endif
+#ifndef FLT_MIN_EXP
+#define FLT_MIN_EXP ( - 125 )
+#endif
+#ifndef DBL_DIG
+#define DBL_DIG 15
+#endif
+#ifndef DBL_MAX
+#define DBL_MAX 1.7976931348623157081452E+308
+#endif
+#ifndef DBL_MAX_10_EXP
+#define DBL_MAX_10_EXP ( + 308 )
+#endif
+#ifndef DBL_MAX_EXP
+#define DBL_MAX_EXP ( + 1024 )
+#endif
+#ifndef DBL_MIN
+#define DBL_MIN 2.2250738585072013830903E-308
+#endif
+#ifndef DBL_MIN_10_EXP
+#define DBL_MIN_10_EXP ( - 307 )
+#endif
+#ifndef DBL_MIN_EXP
+#define DBL_MIN_EXP ( - 1021 )
+#endif
+#ifndef LDBL_DIG
+#define LDBL_DIG 33
+#endif
+#ifndef LDBL_MAX
+#define LDBL_MAX 1.189731495357231765085759326628007016E+4932L
+#endif
+#ifndef LDBL_MAX_10_EXP
+#define LDBL_MAX_10_EXP ( + 4932 )
+#endif
+#ifndef LDBL_MAX_EXP
+#define LDBL_MAX_EXP ( + 16384 )
+#endif
+#ifndef LDBL_MIN
+#define LDBL_MIN 3.362103143112093506262677817321752603E-4932L
+#endif
+#ifndef LDBL_MIN_10_EXP
+#define LDBL_MIN_10_EXP ( - 4931 )
+#endif
+#ifndef LDBL_MIN_EXP
+#define LDBL_MIN_EXP ( - 16381 )
+#endif
+
+
+#define USHRT_DIG 4
+#define UINT_DIG 9
+#define ULONG_DIG 19
+#define UINTMAX_DIG ULONG_DIG
+
+#define FLT_ULONG_MAX 18446744073709551615.0F
+#define FLT_ULLONG_MAX FLT_ULONG_MAX
+#define FLT_UINTMAX_MAX FLT_ULONG_MAX
+#define FLT_LONG_MAX 9223372036854775807.0F
+#define FLT_LLONG_MAX FLT_LONG_MAX
+#define FLT_INTMAX_MAX FLT_LONG_MAX
+#define FLT_LONG_MIN (-9223372036854775808.0F)
+#define FLT_LLONG_MIN FLT_LONG_MIN
+#define FLT_INTMAX_MIN FLT_LONG_MIN
+
+#define DBL_ULONG_MAX 18446744073709551615.0
+#define DBL_ULLONG_MAX DBL_ULONG_MAX
+#define DBL_UINTMAX_MAX DBL_ULONG_MAX
+#define DBL_LONG_MAX 9223372036854775807.0
+#define DBL_LLONG_MAX DBL_LONG_MAX
+#define DBL_INTMAX_MAX DBL_LONG_MAX
+#define DBL_LONG_MIN (-9223372036854775808.0)
+#define DBL_LLONG_MIN DBL_LONG_MIN
+#define DBL_INTMAX_MIN DBL_LONG_MIN
+
+#define LDBL_ULONG_MAX 18446744073709551615.0L
+#define LDBL_ULLONG_MAX LDBL_ULONG_MAX
+#define LDBL_UINTMAX_MAX LDBL_ULONG_MAX
+#define LDBL_LONG_MAX 9223372036854775807.0L
+#define LDBL_LLONG_MAX LDBL_LONG_MAX
+#define LDBL_INTMAX_MAX LDBL_LONG_MAX
+#define LDBL_LONG_MIN (-9223372036854775808.0L)
+#define LDBL_LLONG_MIN LDBL_LONG_MIN
+#define LDBL_INTMAX_MIN LDBL_LONG_MIN
+
+#define FLTMAX_UINTMAX_MAX LDBL_UINTMAX_MAX
+#define FLTMAX_INTMAX_MAX LDBL_INTMAX_MAX
+#define FLTMAX_INTMAX_MIN LDBL_INTMAX_MIN
+
+typedef union _ast_dbl_exp_u
+{
+ uint32_t e[sizeof(double)/4];
+ double f;
+} _ast_dbl_exp_t;
+
+#define _ast_dbl_exp_index 0
+#define _ast_dbl_exp_shift 20
+
+typedef union _fltmax_exp_u
+{
+ uint32_t e[sizeof(_ast_fltmax_t)/4];
+ _ast_fltmax_t f;
+} _ast_fltmax_exp_t;
+
+#define _ast_fltmax_exp_index 0
+#define _ast_fltmax_exp_shift 16
+
+#define _ast_flt_unsigned_max_t unsigned long long
+#define _ast_flt_nan_init 0x7f,0xff,0xff,0xff
+#define _ast_flt_inf_init 0x7f,0x80,0x00,0x00
+#define _ast_dbl_nan_init 0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff
+#define _ast_dbl_inf_init 0x7f,0xf0,0x00,0x00,0x00,0x00,0x00,0x00
+#define _ast_ldbl_nan_init 0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
+#define _ast_ldbl_inf_init 0x7f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_fs.h b/usr/src/lib/libast/sparcv9/include/ast/ast_fs.h
new file mode 100644
index 0000000000..c83a8b85bb
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_fs.h
@@ -0,0 +1,174 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/fs by iffe version 2007-04-04 : : */
+
+#ifndef _def_fs_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fs_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _lib_lstat 1 /* lstat() in default lib(s) */
+#define _lib_mknod 1 /* mknod() in default lib(s) */
+#define _lib_sync 1 /* sync() in default lib(s) */
+#include <sys/stat.h>
+#define FS_default "ufs"
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef major
+#define major(x) ( major_t ) ( ( ( ( unsigned ) ( ( x ) ) ) >> 8 ) & 0x7f )
+#endif
+#ifndef minor
+#define minor(x) ( minor_t ) ( ( ( x ) ) & 0xff )
+#endif
+#ifndef makedev
+#define makedev(x,y) ( unsigned short ) ( ( ( ( x ) ) << 8 ) | ( ( ( y ) ) & 0xff ) )
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _sys_mntent 1 /* #include <sys/mntent.h> ok */
+#define _sys_mnttab 1 /* #include <sys/mnttab.h> ok */
+#define _mem_st_blocks_stat 1 /* st_blocks is a member of struct stat */
+#define _mem_st_blksize_stat 1 /* st_blksize is a member of struct stat */
+#define _mem_st_rdev_stat 1 /* st_rdev is a member of struct stat */
+#define _sys_statfs 1 /* #include <sys/statfs.h> ok */
+#define _mem_f_files_statfs 1 /* f_files is a member of struct statfs */
+#define _sys_vfs 1 /* #include <sys/vfs.h> ok */
+#define _sys_param 1 /* #include <sys/param.h> ok */
+#define _sys_mount 1 /* #include <sys/mount.h> ok */
+#define _sys_statvfs 1 /* #include <sys/statvfs.h> ok */
+#define _mem_f_basetype_statvfs 1 /* f_basetype is a member of struct statvfs */
+#define _mem_f_frsize_statvfs 1 /* f_frsize is a member of struct statvfs */
+#define _lib_getmntent 1 /* getmntent() in default lib(s) */
+#define _lib_statfs 1 /* statfs() in default lib(s) */
+#define _lib_statvfs 1 /* statvfs() in default lib(s) */
+#define _lib_statfs4 1 /* compile{\ passed */
+#if _sys_statvfs
+#include <sys/statvfs.h>
+#if !_mem_statvfs_f_basetype
+#if _ary_f_reserved7
+#define f_basetype f_reserved7
+#endif
+#endif
+#else
+#define _mem_f_basetype_statvfs 1
+#define _mem_f_frsize_statvfs 1
+struct statvfs
+{
+unsigned long f_bsize; /* fundamental file system block size */
+unsigned long f_frsize; /* fragment size */
+unsigned long f_blocks; /* total # of blocks of f_frsize on fs */
+unsigned long f_bfree; /* total # of free blocks of f_frsize */
+unsigned long f_bavail; /* # of free blocks avail to non-superuser */
+unsigned long f_files; /* total # of file nodes (inodes) */
+unsigned long f_ffree; /* total # of free file nodes */
+unsigned long f_favail; /* # of free nodes avail to non-superuser */
+unsigned long f_fsid; /* file system id (dev for now) */
+char f_basetype[16]; /* target fs type name, null-terminated */
+unsigned long f_flag; /* bit-mask of flags */
+unsigned long f_namemax; /* maximum file name length */
+char f_fstr[32]; /* filesystem-specific string */
+unsigned long f_filler[16]; /* reserved for future expansion */
+};
+extern __MANGLE__ int fstatvfs __PROTO__((int, struct statvfs*));
+extern __MANGLE__ int statvfs __PROTO__((const char*, struct statvfs*));
+#endif
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_statvfs64 && !defined(statvfs)
+#define statvfs statvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int statvfs64 __PROTO__((const char*, struct statvfs64*));
+#endif
+#endif
+#if _lib_fstatvfs64 && !defined(fstatvfs)
+#define fstatvfs fstatvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int fstatvfs64 __PROTO__((int, struct statvfs64*));
+#endif
+#endif
+
+#define _str_st_fstype 1 /* stat.st_fstype is a string */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_getopt.h b/usr/src/lib/libast/sparcv9/include/ast/ast_getopt.h
new file mode 100644
index 0000000000..0de85c6172
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_getopt.h
@@ -0,0 +1,51 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * legacy standard getopt interface
+ */
+
+#ifndef _AST_GETOPT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_GETOPT_H 1
+
+extern __MANGLE__ int opterr;
+extern __MANGLE__ int optind;
+extern __MANGLE__ int optopt;
+extern __MANGLE__ char* optarg;
+
+#ifndef NULL /* in case <stdlib.h> or <stdio.h> got here first */
+
+extern __MANGLE__ int getopt __PROTO__((int, char* const*, const char*));
+extern __MANGLE__ int getsubopt __PROTO__((char**, char* const*, char**));
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_iconv.h b/usr/src/lib/libast/sparcv9/include/ast/ast_iconv.h
new file mode 100644
index 0000000000..546c94c7e4
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_iconv.h
@@ -0,0 +1,153 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/iconv by iffe version 2007-04-04 : : */
+
+#ifndef _def_iconv_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_iconv_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_iconv 1 /* #include <iconv.h> ok */
+#define _lib_iconv_open 1 /* iconv_open() in default lib(s) */
+#define _lib_iconv_close 1 /* iconv_close() in default lib(s) */
+#define _lib_iconv 1 /* iconv() in default lib(s) */
+#define _nxt_iconv <../include/iconv.h> /* include path for the native <iconv.h> */
+#define _nxt_iconv_str "../include/iconv.h" /* include string for the native <iconv.h> */
+#include <ast_common.h>
+#include <ccode.h>
+#include <../include/iconv.h> /* the native iconv.h */
+
+#define CC_ICONV (-1)
+#define CC_UCS (-2)
+#define CC_SCU (-3)
+#define CC_UTF (-4)
+#define CC_UME (-5)
+
+#ifndef _ICONV_LIST_PRIVATE_
+#undef iconv_t
+#define iconv_t _ast_iconv_t
+#undef iconv_f
+#define iconv_f _ast_iconv_f
+#undef iconv_list_t
+#define iconv_list_t _ast_iconv_list_t
+#undef iconv_open
+#define iconv_open _ast_iconv_open
+#undef iconv
+#define iconv _ast_iconv
+#undef iconv_close
+#define iconv_close _ast_iconv_close
+#undef iconv_list
+#define iconv_list _ast_iconv_list
+#undef iconv_move
+#define iconv_move _ast_iconv_move
+#undef iconv_name
+#define iconv_name _ast_iconv_name
+#undef iconv_write
+#define iconv_write _ast_iconv_write
+#endif
+
+typedef Ccmap_t _ast_iconv_list_t;
+typedef __V_* _ast_iconv_t;
+typedef size_t (*_ast_iconv_f) __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ _ast_iconv_t _ast_iconv_open __PROTO__((const char*, const char*));
+extern __MANGLE__ size_t _ast_iconv __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+extern __MANGLE__ int _ast_iconv_close __PROTO__((_ast_iconv_t));
+extern __MANGLE__ _ast_iconv_list_t* _ast_iconv_list __PROTO__((_ast_iconv_list_t*));
+extern __MANGLE__ int _ast_iconv_name __PROTO__((const char*, char*, size_t));
+#if _SFIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, Sfio_t*, Sfio_t*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, Sfio_t*, char**, size_t*, size_t*));
+#else
+#if _SFSTDIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, FILE*, FILE*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, FILE*, char**, size_t*, size_t*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_lib.h b/usr/src/lib/libast/sparcv9/include/ast/ast_lib.h
new file mode 100644
index 0000000000..ec2755bd45
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_lib.h
@@ -0,0 +1,181 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/lib by iffe version 2007-04-04 : : */
+#ifndef _def_lib_ast
+#define _def_lib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _hdr_fmtmsg 1 /* #include <fmtmsg.h> ok */
+#define _hdr_fnmatch 1 /* #include <fnmatch.h> ok */
+#define _hdr_libgen 1 /* #include <libgen.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_locale 1 /* #include <locale.h> ok */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_spawn 1 /* #include <spawn.h> ok */
+#define _hdr_syslog 1 /* #include <syslog.h> ok */
+#define _hdr_utime 1 /* #include <utime.h> ok */
+#define _hdr_wctype 1 /* #include <wctype.h> ok */
+#define _hdr_wchar 1 /* <wchar.h> and isw*() really work */
+#define _dat__tzname 1 /* _tzname in default lib(s) */
+#define _dat_tzname 1 /* tzname in default lib(s) */
+#define _lib__cleanup 1 /* _cleanup() in default lib(s) */
+#define _lib_atexit 1 /* atexit() in default lib(s) */
+#define _lib_bcopy 1 /* bcopy() in default lib(s) */
+#define _lib_bzero 1 /* bzero() in default lib(s) */
+#define _lib_catclose 1 /* catclose() in default lib(s) */
+#define _lib_catgets 1 /* catgets() in default lib(s) */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_confstr 1 /* confstr() in default lib(s) */
+#define _lib_dup2 1 /* dup2() in default lib(s) */
+#define _lib_execlp 1 /* execlp() in default lib(s) */
+#define _lib_execve 1 /* execve() in default lib(s) */
+#define _lib_execvp 1 /* execvp() in default lib(s) */
+#define _lib_fchmod 1 /* fchmod() in default lib(s) */
+#define _lib_fcntl 1 /* fcntl() in default lib(s) */
+#define _lib_fmtmsg 1 /* fmtmsg() in default lib(s) */
+#define _lib_fnmatch 1 /* fnmatch() in default lib(s) */
+#define _lib_fork 1 /* fork() in default lib(s) */
+#define _lib_fsync 1 /* fsync() in default lib(s) */
+#define _lib_getdents 1 /* getdents() in default lib(s) */
+#define _lib_getdtablesize 1 /* getdtablesize() in default lib(s) */
+#define _lib_getdate 1 /* getdate() in default lib(s) */
+#define _lib_getgroups 1 /* getgroups() in default lib(s) */
+#define _lib_gethostname 1 /* gethostname() in default lib(s) */
+#define _lib_getlogin 1 /* getlogin() in default lib(s) */
+#define _lib_getpagesize 1 /* getpagesize() in default lib(s) */
+#define _lib_getrlimit 1 /* getrlimit() in default lib(s) */
+#define _lib_getopt 1 /* getopt() in default lib(s) */
+#define _lib_getsubopt 1 /* getsubopt() in default lib(s) */
+#define _lib_getopt_long 1 /* getopt_long() in default lib(s) */
+#define _lib_getopt_long_only 1 /* getopt_long_only() in default lib(s) */
+#define _lib_glob 1 /* glob() in default lib(s) */
+#define _lib_index 1 /* index() in default lib(s) */
+#define _lib_iswblank 1 /* iswblank() in default lib(s) */
+#define _lib_iswctype 1 /* iswctype() in default lib(s) */
+#define _lib_killpg 1 /* killpg() in default lib(s) */
+#define _lib_link 1 /* link() in default lib(s) */
+#define _lib_localeconv 1 /* localeconv() in default lib(s) */
+#define _lib_madvise 1 /* madvise() in default lib(s) */
+#define _lib_mbtowc 1 /* mbtowc() in default lib(s) */
+#define _lib_mbrtowc 1 /* mbrtowc() in default lib(s) */
+#define _lib_memalign 1 /* memalign() in default lib(s) */
+#define _lib_memchr 1 /* memchr() in default lib(s) */
+#define _lib_memcpy 1 /* memcpy() in default lib(s) */
+#define _lib_memmove 1 /* memmove() in default lib(s) */
+#define _lib_memset 1 /* memset() in default lib(s) */
+#define _lib_mkdir 1 /* mkdir() in default lib(s) */
+#define _lib_mkfifo 1 /* mkfifo() in default lib(s) */
+#define _lib_mktemp 1 /* mktemp() in default lib(s) */
+#define _lib_mktime 1 /* mktime() in default lib(s) */
+#define _lib_mount 1 /* mount() in default lib(s) */
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _lib_pathconf 1 /* pathconf() in default lib(s) */
+#define _lib_readlink 1 /* readlink() in default lib(s) */
+#define _lib_remove 1 /* remove() in default lib(s) */
+#define _lib_rename 1 /* rename() in default lib(s) */
+#define _lib_rewinddir 1 /* rewinddir() in default lib(s) */
+#define _lib_rindex 1 /* rindex() in default lib(s) */
+#define _lib_rmdir 1 /* rmdir() in default lib(s) */
+#define _lib_setlocale 1 /* setlocale() in default lib(s) */
+#define _lib_setpgid 1 /* setpgid() in default lib(s) */
+#define _lib_setpgrp 1 /* setpgrp() in default lib(s) */
+#define _lib_setreuid 1 /* setreuid() in default lib(s) */
+#define _lib_setsid 1 /* setsid() in default lib(s) */
+#define _lib_setuid 1 /* setuid() in default lib(s) */
+#define _lib_sigaction 1 /* sigaction() in default lib(s) */
+#define _lib_sigprocmask 1 /* sigprocmask() in default lib(s) */
+#define _lib_socketpair 1 /* socketpair() in default lib(s) */
+#define _lib_strchr 1 /* strchr() in default lib(s) */
+#define _lib_strcoll 1 /* strcoll() in default lib(s) */
+#define _lib_strdup 1 /* strdup() in default lib(s) */
+#define _lib_strerror 1 /* strerror() in default lib(s) */
+#define _lib_strcasecmp 1 /* strcasecmp() in default lib(s) */
+#define _lib_strncasecmp 1 /* strncasecmp() in default lib(s) */
+#define _lib_strrchr 1 /* strrchr() in default lib(s) */
+#define _lib_strstr 1 /* strstr() in default lib(s) */
+#define _lib_strxfrm 1 /* strxfrm() in default lib(s) */
+#define _lib_strftime 1 /* strftime() in default lib(s) */
+#define _lib_swab 1 /* swab() in default lib(s) */
+#define _lib_symlink 1 /* symlink() in default lib(s) */
+#define _lib_sysconf 1 /* sysconf() in default lib(s) */
+#define _lib_sysinfo 1 /* sysinfo() in default lib(s) */
+#define _lib_syslog 1 /* syslog() in default lib(s) */
+#define _lib_telldir 1 /* telldir() in default lib(s) */
+#define _lib_tmpnam 1 /* tmpnam() in default lib(s) */
+#define _lib_tzset 1 /* tzset() in default lib(s) */
+#define _lib_unlink 1 /* unlink() in default lib(s) */
+#define _lib_utime 1 /* utime() in default lib(s) */
+#define _lib_wctype 1 /* wctype() in default lib(s) */
+#define _lib_ftruncate 1 /* ftruncate() in default lib(s) */
+#define _lib_truncate 1 /* truncate() in default lib(s) */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _lib_strtod 1 /* strtod() in default lib(s) */
+#define _lib_strtold 1 /* strtold() in default lib(s) */
+#define _lib_strtol 1 /* strtol() in default lib(s) */
+#define _lib_strtoll 1 /* strtoll() in default lib(s) */
+#define _lib_strtoul 1 /* strtoul() in default lib(s) */
+#define _lib_strtoull 1 /* strtoull() in default lib(s) */
+#define _mem_d_ino_dirent 1 /* d_ino is a member of struct dirent */
+#define _mem_d_off_dirent 1 /* d_off is a member of struct dirent */
+#define _mem_d_reclen_dirent 1 /* d_reclen is a member of struct dirent */
+#define _mem_DIR 1 /* DIR is a non-opaque struct */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _sys_jioctl 1 /* #include <sys/jioctl.h> ok */
+#define _sys_localedef 1 /* #include <sys/localedef.h> ok */
+#define _sys_ptem 1 /* #include <sys/ptem.h> ok */
+#define _sys_resource 1 /* #include <sys/resource.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _sys_stream 1 /* #include <sys/stream.h> ok */
+#define _sys_systeminfo 1 /* #include <sys/systeminfo.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_off64_t 1 /* off64_t is a type */
+#define _typ_struct_dirent64 1 /* struct dirent64 is a type */
+#define _tst_errno 1 /* errno can be assigned */
+#define _lib_poll_fd_1 1 /* fd is first arg to poll() */
+#define _lib_poll 1 /* _lib_poll_fd_1||_lib_poll_fd_2 is true */
+#define _lib_select 1 /* select() has standard 5 arg interface */
+#define _pipe_rw 1 /* full duplex pipes */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _lib_vfork 1 /* vfork exists and it works */
+#define _real_vfork 1 /* vfork child shares data with parent */
+#define _lib_posix_spawn 1 /* posix_spawn exists and it works and its worth using */
+#define _stream_peek 1 /* ioctl(I_PEEK) works */
+#define _socket_peek 1 /* recv(MSG_PEEK) works */
+#define _hdr_string 1 /* #include <string.h> ok */
+#define _lib_memcmp 1 /* standard memcmp interface that works */
+#define _hdr_fcntl 1 /* #include <fcntl.h> ok */
+#define _hdr_signal 1 /* #include <signal.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_memccpy 1 /* standard memccpy interface that works */
+#define _lib_utime_now 1 /* utime works with 0 time vector */
+#define _UNIV_DEFAULT "att" /* default universe name */
+#define _std_cleanup 1 /* stuck with standard _cleanup */
+#define _std_strcoll 1 /* standard strcoll works */
+#if !_AST_no_spawnveg
+#define _use_spawnveg 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_limits.h b/usr/src/lib/libast/sparcv9/include/ast/ast_limits.h
new file mode 100644
index 0000000000..aa9bb8f9a0
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_limits.h
@@ -0,0 +1,128 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/limits.c by iffe version 2007-04-04 : : */
+#ifndef _def_limits_ast
+#define _def_limits_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+#ifndef CHAR_MAX
+#define CHAR_MAX 127
+#endif
+#ifndef CHAR_MIN
+#define CHAR_MIN -128
+#endif
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC 1000000
+#endif
+#ifndef INT_MIN
+#define INT_MIN -2147483648
+#endif
+#ifndef LLONG_MAX
+#define LLONG_MAX 9223372036854775807
+#endif
+#ifndef LLONG_MIN
+#define LLONG_MIN -9223372036854775808
+#endif
+#ifndef LONG_MAX
+#define LONG_MAX 2147483647
+#endif
+#ifndef LONG_MIN
+#define LONG_MIN -2147483648
+#endif
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 5
+#endif
+#ifndef OPEN_MAX_CEIL
+#ifndef OPEN_MAX
+#define OPEN_MAX 256
+#endif
+#define OPEN_MAX_CEIL OPEN_MAX
+#endif
+#ifndef PTHREAD_STACK_MIN
+#define PTHREAD_STACK_MIN 4096
+#endif
+#ifndef PTRDIFF_MAX
+#define PTRDIFF_MAX 9223372036854775807
+#endif
+#ifndef PTRDIFF_MIN
+#define PTRDIFF_MIN -9223372036854775808
+#endif
+#ifndef SCHAR_MAX
+#define SCHAR_MAX 127
+#endif
+#ifndef SCHAR_MIN
+#define SCHAR_MIN -128
+#endif
+#ifndef SHRT_MIN
+#define SHRT_MIN -32768
+#endif
+#ifndef SIG_ATOMIC_MAX
+#define SIG_ATOMIC_MAX 2147483647
+#endif
+#ifndef SIG_ATOMIC_MIN
+#define SIG_ATOMIC_MIN -2147483648
+#endif
+#ifndef SIZE_MAX
+#ifndef UINT_MAX
+#define UINT_MAX 4294967295
+#endif
+#define SIZE_MAX UINT_MAX
+#endif
+#ifndef SSIZE_MAX
+#ifndef INT_MAX
+#define INT_MAX 2147483647
+#endif
+#define SSIZE_MAX INT_MAX
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+#ifndef UCHAR_MAX
+#define UCHAR_MAX 255
+#endif
+#ifndef ULLONG_MAX
+#define ULLONG_MAX 18446744073709551615
+#endif
+#ifndef ULONG_MAX
+#define ULONG_MAX 4294967295
+#endif
+#ifndef USHRT_MAX
+#define USHRT_MAX 65535
+#endif
+#ifndef WCHAR_MAX
+#define WCHAR_MAX 2147483647
+#endif
+#ifndef WCHAR_MIN
+#define WCHAR_MIN -2147483648
+#endif
+#ifndef WINT_MAX
+#define WINT_MAX 2147483647
+#endif
+#ifndef WINT_MIN
+#define WINT_MIN -2147483648
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_map.h b/usr/src/lib/libast/sparcv9/include/ast/ast_map.h
new file mode 100644
index 0000000000..3d05908817
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_map.h
@@ -0,0 +1,459 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/map.c by iffe version 2007-04-04 : : */
+#ifndef _def_map_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_map_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+/*
+ * prototypes provided for standard interfaces hijacked
+ * by ast and mapped to _ast_* but already prototyped
+ * unmapped in native headers included by <ast_std.h>
+ */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+
+#define _map_libc 1
+#undef basename
+#define basename _ast_basename
+#undef dirname
+#define dirname _ast_dirname
+#undef eaccess
+#define eaccess _ast_eaccess
+#undef execvpe
+#define execvpe _ast_execvpe
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+#undef fnmatch
+#define fnmatch _ast_fnmatch
+#undef fts_children
+#define fts_children _ast_fts_children
+#undef fts_close
+#define fts_close _ast_fts_close
+#undef fts_flags
+#define fts_flags _ast_fts_flags
+#undef fts_notify
+#define fts_notify _ast_fts_notify
+#undef fts_open
+#define fts_open _ast_fts_open
+#undef fts_read
+#define fts_read _ast_fts_read
+#undef fts_set
+#define fts_set _ast_fts_set
+#undef ftw
+#define ftw _ast_ftw
+#undef ftwalk
+#define ftwalk _ast_ftwalk
+#undef ftwflags
+#define ftwflags _ast_ftwflags
+#undef getcwd
+#define getcwd _ast_getcwd
+extern __MANGLE__ char* getcwd __PROTO__((char*, size_t));
+#undef getdate
+#define getdate _ast_getdate
+#undef getopt
+#define getopt _ast_getopt
+#undef getsubopt
+#define getsubopt _ast_getsubopt
+#undef getopt_long
+#define getopt_long _ast_getopt_long
+#undef getopt_long_only
+#define getopt_long_only _ast_getopt_long_only
+#undef getwd
+#define getwd _ast_getwd
+extern __MANGLE__ char* getwd __PROTO__((char*));
+#undef glob
+#define glob _ast_glob
+#undef globfree
+#define globfree _ast_globfree
+#undef memdup
+#define memdup _ast_memdup
+#undef memfatal
+#define memfatal _ast_memfatal
+#undef memhash
+#define memhash _ast_memhash
+#undef memsum
+#define memsum _ast_memsum
+#undef mkstemp
+#define mkstemp _ast_mkstemp
+extern __MANGLE__ int mkstemp __PROTO__((char*));
+#undef mktemp
+#define mktemp _ast_mktemp
+extern __MANGLE__ char* mktemp __PROTO__((char*));
+#undef mktime
+#define mktime _ast_mktime
+#undef nftw
+#define nftw _ast_nftw
+#undef optesc
+#define optesc _ast_optesc
+#undef optget
+#define optget _ast_optget
+#undef opthelp
+#define opthelp _ast_opthelp
+#undef optjoin
+#define optjoin _ast_optjoin
+#undef optstr
+#define optstr _ast_optstr
+#undef optusage
+#define optusage _ast_optusage
+#undef pathaccess
+#define pathaccess _ast_pathaccess
+#undef pathbin
+#define pathbin _ast_pathbin
+#undef pathcanon
+#define pathcanon _ast_pathcanon
+#undef pathcat
+#define pathcat _ast_pathcat
+#undef pathcd
+#define pathcd _ast_pathcd
+#undef pathcheck
+#define pathcheck _ast_pathcheck
+#undef pathexists
+#define pathexists _ast_pathexists
+#undef pathfind
+#define pathfind _ast_pathfind
+#undef pathgetlink
+#define pathgetlink _ast_pathgetlink
+#undef pathinclude
+#define pathinclude _ast_pathinclude
+#undef pathkey
+#define pathkey _ast_pathkey
+#undef pathnative
+#define pathnative _ast_pathnative
+#undef pathpath
+#define pathpath _ast_pathpath
+#undef pathposix
+#define pathposix _ast_pathposix
+#undef pathprobe
+#define pathprobe _ast_pathprobe
+#undef pathrepl
+#define pathrepl _ast_pathrepl
+#undef pathsetlink
+#define pathsetlink _ast_pathsetlink
+#undef pathshell
+#define pathshell _ast_pathshell
+#undef pathstat
+#define pathstat _ast_pathstat
+#undef pathtemp
+#define pathtemp _ast_pathtemp
+#undef pathtmp
+#define pathtmp _ast_pathtmp
+#undef procclose
+#define procclose _ast_procclose
+#undef procfree
+#define procfree _ast_procfree
+#undef procopen
+#define procopen _ast_procopen
+#undef procrun
+#define procrun _ast_procrun
+#undef putenv
+#define putenv _ast_putenv
+#undef re_comp
+#define re_comp _ast_re_comp
+#undef re_exec
+#define re_exec _ast_re_exec
+#undef realpath
+#define realpath _ast_realpath
+extern __MANGLE__ char* realpath __PROTO__((const char*, char*));
+#undef regaddclass
+#define regaddclass _ast_regaddclass
+#undef regalloc
+#define regalloc _ast_regalloc
+#undef regcache
+#define regcache _ast_regcache
+#undef regclass
+#define regclass _ast_regclass
+#undef regcmp
+#define regcmp _ast_regcmp
+#undef regcollate
+#define regcollate _ast_regcollate
+#undef regcomb
+#define regcomb _ast_regcomb
+#undef regcomp
+#define regcomp _ast_regcomp
+#undef regdecomp
+#define regdecomp _ast_regdecomp
+#undef regdup
+#define regdup _ast_regdup
+#undef regerror
+#define regerror _ast_regerror
+#undef regex
+#define regex _ast_regex
+#undef regexec
+#define regexec _ast_regexec
+#undef regfatal
+#define regfatal _ast_regfatal
+#undef regfatalpat
+#define regfatalpat _ast_regfatalpat
+#undef regfree
+#define regfree _ast_regfree
+#undef regncomp
+#define regncomp _ast_regncomp
+#undef regnexec
+#define regnexec _ast_regnexec
+#undef regrecord
+#define regrecord _ast_regrecord
+#undef regrexec
+#define regrexec _ast_regrexec
+#undef regstat
+#define regstat _ast_regstat
+#undef regsub
+#define regsub _ast_regsub
+#undef regsubcomp
+#define regsubcomp _ast_regsubcomp
+#undef regsubexec
+#define regsubexec _ast_regsubexec
+#undef regsubflags
+#define regsubflags _ast_regsubflags
+#undef regsubfree
+#define regsubfree _ast_regsubfree
+#undef remove
+#define remove _ast_remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#undef resolvepath
+#define resolvepath _ast_resolvepath
+extern __MANGLE__ char* resolvepath __PROTO__((const char*, char*, size_t));
+#undef setenv
+#define setenv _ast_setenv
+extern __MANGLE__ int setenv __PROTO__((const char*, const char*, int));
+#undef setenviron
+#define setenviron _ast_setenviron
+#undef sigcritical
+#define sigcritical _ast_sigcritical
+#undef signal
+#define signal _ast_signal
+#undef sigunblock
+#define sigunblock _ast_sigunblock
+#undef stracmp
+#define stracmp _ast_stracmp
+#undef strcopy
+#define strcopy _ast_strcopy
+#undef strelapsed
+#define strelapsed _ast_strelapsed
+#undef stresc
+#define stresc _ast_stresc
+#undef streval
+#define streval _ast_streval
+#undef strexpr
+#define strexpr _ast_strexpr
+#undef strftime
+#define strftime _ast_strftime
+#undef strgid
+#define strgid _ast_strgid
+#undef strgrpmatch
+#define strgrpmatch _ast_strgrpmatch
+#undef strhash
+#define strhash _ast_strhash
+#undef strkey
+#define strkey _ast_strkey
+#undef strlcat
+#define strlcat _ast_strlcat
+extern __MANGLE__ size_t strlcat __PROTO__((char*, const char*, size_t));
+#undef strlcpy
+#define strlcpy _ast_strlcpy
+extern __MANGLE__ size_t strlcpy __PROTO__((char*, const char*, size_t));
+#undef strlook
+#define strlook _ast_strlook
+#undef strmatch
+#define strmatch _ast_strmatch
+#undef strmode
+#define strmode _ast_strmode
+#undef strnacmp
+#define strnacmp _ast_strnacmp
+#undef strncopy
+#define strncopy _ast_strncopy
+#undef strntod
+#define strntod _ast_strntod
+#undef strntol
+#define strntol _ast_strntol
+#undef strntold
+#define strntold _ast_strntold
+#undef strntoll
+#define strntoll _ast_strntoll
+#undef strntoul
+#define strntoul _ast_strntoul
+#undef strntoull
+#define strntoull _ast_strntoull
+#undef stropt
+#define stropt _ast_stropt
+#undef strperm
+#define strperm _ast_strperm
+#undef strpsearch
+#define strpsearch _ast_strpsearch
+#undef strptime
+#define strptime _ast_strptime
+#undef strsearch
+#define strsearch _ast_strsearch
+#undef strsort
+#define strsort _ast_strsort
+#undef strsubmatch
+#define strsubmatch _ast_strsubmatch
+#undef strsum
+#define strsum _ast_strsum
+#undef strtape
+#define strtape _ast_strtape
+#undef strtoip4
+#define strtoip4 _ast_strtoip4
+#undef strton
+#define strton _ast_strton
+#undef strtonll
+#define strtonll _ast_strtonll
+#undef struid
+#define struid _ast_struid
+#undef struniq
+#define struniq _ast_struniq
+#undef system
+#define system _ast_system
+extern __MANGLE__ int system __PROTO__((const char*));
+#undef tempnam
+#define tempnam _ast_tempnam
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+#undef tmpnam
+#define tmpnam _ast_tmpnam
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+#undef touch
+#define touch _ast_touch
+#undef wordexp
+#define wordexp _ast_wordexp
+#undef wordfree
+#define wordfree _ast_wordfree
+#undef unsetenv
+#define unsetenv _ast_unsetenv
+
+/* cannot override local malloc */
+#define _map_malloc 1
+#undef calloc
+#define calloc _ast_calloc
+extern __MANGLE__ __V_* calloc __PROTO__((size_t, size_t));
+#undef cfree
+#define cfree _ast_cfree
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+#undef free
+#define free _ast_free
+extern __MANGLE__ void free __PROTO__((__V_*));
+#undef malloc
+#define malloc _ast_malloc
+extern __MANGLE__ __V_* malloc __PROTO__((size_t));
+#undef memalign
+#define memalign _ast_memalign
+extern __MANGLE__ __V_* memalign __PROTO__((size_t, size_t));
+#undef realloc
+#define realloc _ast_realloc
+extern __MANGLE__ __V_* realloc __PROTO__((__V_*, size_t));
+#undef strdup
+#define strdup _ast_strdup
+extern __MANGLE__ char* strdup __PROTO__((const char*));
+#undef valloc
+#define valloc _ast_valloc
+extern __MANGLE__ __V_* valloc __PROTO__((size_t));
+#undef strtol
+#define strtol _ast_strtol
+#undef strtoul
+#define strtoul _ast_strtoul
+#undef strtoll
+#define strtoll _ast_strtoll
+#undef strtoull
+#define strtoull _ast_strtoull
+#undef strtod
+#define strtod _ast_strtod
+#undef strtold
+#define strtold _ast_strtold
+extern __MANGLE__ long strtol __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned long strtoul __PROTO__((const char*, char**, int));
+extern __MANGLE__ double strtod __PROTO__((const char*, char**));
+#if !_UWIN
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
+extern __MANGLE__ _ast_fltmax_t strtold __PROTO__((const char*, char**));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+extern __MANGLE__ _ast_intmax_t strtoll __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned _ast_intmax_t strtoull __PROTO__((const char*, char**, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_mmap.h b/usr/src/lib/libast/sparcv9/include/ast/ast_mmap.h
new file mode 100644
index 0000000000..66b7fe43c0
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_mmap.h
@@ -0,0 +1,47 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/mmap by iffe version 2007-04-04 : : */
+#ifndef _def_mmap_ast
+#define _def_mmap_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_mmap 1 /* standard mmap interface that works */
+#define _lib_mmap64 1 /* mmap64 interface and implementation work */
+#define _mmap_anon 1 /* use mmap MAP_ANON to get raw memory */
+#define _mmap_devzero 1 /* use mmap on /dev/zero to get raw memory */
+
+/* some systems get it wrong but escape concise detection */
+#ifndef _NO_MMAP
+#if __CYGWIN__
+#define _NO_MMAP 1
+#endif
+#endif
+
+#if _NO_MMAP
+#undef _lib_mmap
+#undef _lib_mmap64
+#undef _mmap_anon
+#undef _mmap_devzero
+#undef _mmap_worthy
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_mode.h b/usr/src/lib/libast/sparcv9/include/ast/ast_mode.h
new file mode 100644
index 0000000000..674760685e
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_mode.h
@@ -0,0 +1,35 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/mode.c by iffe version 2007-04-04 : : */
+#ifndef _def_mode_ast
+#define _def_mode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define S_ITYPE(m) ((m)&S_IFMT)
+
+#define S_IPERM (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
+
+#define _S_IDPERM 1
+#define _S_IDTYPE 1
+
+#define BUFFERSIZE 8192
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_nl_types.h b/usr/src/lib/libast/sparcv9/include/ast/ast_nl_types.h
new file mode 100644
index 0000000000..90ac05aeea
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_nl_types.h
@@ -0,0 +1,123 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/nl_types by iffe version 2007-04-04 : : */
+
+#ifndef _def_nl_types_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_nl_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_nl_langinfo 1 /* nl_langinfo() in default lib(s) */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_langinfo 1 /* #include <langinfo.h> ok */
+#define _nxt_nl_types <../include/nl_types.h> /* include path for the native <nl_types.h> */
+#define _nxt_nl_types_str "../include/nl_types.h" /* include string for the native <nl_types.h> */
+#include <limits.h>
+#include <../include/nl_types.h> /* the native nl_types.h */
+
+#undef NL_SETMAX
+#define NL_SETMAX 1023
+#undef NL_MSGMAX
+#define NL_MSGMAX 32767
+#undef nl_catd
+#define nl_catd _ast_nl_catd
+#undef catopen
+#define catopen _ast_catopen
+#undef catgets
+#define catgets _ast_catgets
+#undef catclose
+#define catclose _ast_catclose
+
+typedef __V_* nl_catd;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ nl_catd catopen __PROTO__((const char*, int));
+extern __MANGLE__ char* catgets __PROTO__((nl_catd, int, int, const char*));
+extern __MANGLE__ int catclose __PROTO__((nl_catd));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_param.h b/usr/src/lib/libast/sparcv9/include/ast/ast_param.h
new file mode 100644
index 0000000000..cb0c504848
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_param.h
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/param.sh by iffe version 2007-04-04 : : */
+#ifndef _def_param_ast
+#define _def_param_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#include <sys/param.h>
+#ifndef S_IFDIR
+#include <sys/stat.h>
+#endif
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_standards.h b/usr/src/lib/libast/sparcv9/include/ast/ast_standards.h
new file mode 100644
index 0000000000..a6713c0db7
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_standards.h
@@ -0,0 +1,49 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/standards by iffe version 2007-04-04 : : */
+#ifndef _def_standards_ast
+#define _def_standards_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* _ALL_SOURCE & _ISOC99_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works */
+#ifndef _ALL_SOURCE
+#define _ALL_SOURCE 1
+#endif
+#ifndef _ISOC99_SOURCE
+#define _ISOC99_SOURCE 1
+#endif
+#ifndef _POSIX_SOURCE
+#define _POSIX_SOURCE 1
+#endif
+#ifndef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 21000101L
+#endif
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 9900
+#endif
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#ifndef __EXTENSIONS__
+#define __EXTENSIONS__ 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_std.h b/usr/src/lib/libast/sparcv9/include/ast/ast_std.h
new file mode 100644
index 0000000000..68e7984670
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_std.h
@@ -0,0 +1,343 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Advanced Software Technology Library
+ * AT&T Research
+ *
+ * a union of standard headers that works
+ * with local extensions enabled
+ * and local omission compensation
+ */
+
+#ifndef _AST_STD_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_STD_H 1
+#define _AST_STD_I 1
+
+#include <ast_common.h>
+
+#if _BLD_ast
+#define _BLD_cdt 1
+#define _BLD_sfio 1
+#if !_UWIN
+#define _BLD_vmalloc 1
+#endif
+#endif
+
+#ifdef _SFSTDIO_H
+#define _SKIP_SFSTDIO_H
+#else
+#define _SFSTDIO_H
+#ifndef FILE
+#ifndef _SFIO_H
+struct _sfio_s;
+#endif
+#define FILE struct _sfio_s
+#ifndef __FILE_typedef
+#define __FILE_typedef 1
+#endif
+#ifndef _FILEDEFED
+#define _FILEDEFED 1
+#endif
+#endif
+#endif
+
+#include <ast_lib.h>
+#include <ast_sys.h>
+#include <ast_getopt.h> /* <stdlib.h> does this */
+#include <ast_fcntl.h>
+#include <ast_limits.h>
+#include <ast_botch.h>
+
+#ifdef _SKIP_SFSTDIO_H
+#undef _SKIP_SFSTDIO_H
+#else
+#undef _SFSTDIO_H
+#undef FILE
+#endif
+
+/* locale stuff */
+
+#if !_hdr_locale
+
+struct lconv
+{
+ char* decimal_point;
+ char* thousands_sep;
+ char* grouping;
+ char* int_curr_symbol;
+ char* currency_symbol;
+ char* mon_decimal_point;
+ char* mon_thousands_sep;
+ char* mon_grouping;
+ char* positive_sign;
+ char* negative_sign;
+ char int_frac_digits;
+ char frac_digits;
+ char p_cs_precedes;
+ char p_sep_by_space;
+ char n_cs_precedes;
+ char n_sep_by_space;
+ char p_sign_posn;
+ char n_sign_posn;
+};
+
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#undef localeconv
+#define localeconv _ast_localeconv
+
+#undef setlocale
+#define setlocale _ast_setlocale
+
+#undef strerror
+#define strerror _ast_strerror
+
+extern __MANGLE__ struct lconv* localeconv __PROTO__((void));
+extern __MANGLE__ char* setlocale __PROTO__((int, const char*));
+extern __MANGLE__ char* strerror __PROTO__((int));
+
+#define AST_MESSAGE_SET 3 /* see <mc.h> mcindex() */
+
+/*
+ * maintain this order when adding categories
+ */
+
+#define AST_LC_ALL 0
+#define AST_LC_COLLATE 1
+#define AST_LC_CTYPE 2
+#define AST_LC_MESSAGES 3
+#define AST_LC_MONETARY 4
+#define AST_LC_NUMERIC 5
+#define AST_LC_TIME 6
+#define AST_LC_IDENTIFICATION 7
+#define AST_LC_ADDRESS 8
+#define AST_LC_NAME 9
+#define AST_LC_TELEPHONE 10
+#define AST_LC_XLITERATE 11
+#define AST_LC_MEASUREMENT 12
+#define AST_LC_PAPER 13
+#define AST_LC_COUNT 14
+
+#define AST_LC_find (1L<<28)
+#define AST_LC_debug (1L<<29)
+#define AST_LC_setlocale (1L<<30)
+#define AST_LC_translate (1L<<31)
+
+#ifndef LC_ALL
+#define LC_ALL (-AST_LC_ALL)
+#endif
+#ifndef LC_COLLATE
+#define LC_COLLATE (-AST_LC_COLLATE)
+#endif
+#ifndef LC_CTYPE
+#define LC_CTYPE (-AST_LC_CTYPE)
+#endif
+#ifndef LC_MESSAGES
+#define LC_MESSAGES (-AST_LC_MESSAGES)
+#endif
+#ifndef LC_MONETARY
+#define LC_MONETARY (-AST_LC_MONETARY)
+#endif
+#ifndef LC_NUMERIC
+#define LC_NUMERIC (-AST_LC_NUMERIC)
+#endif
+#ifndef LC_TIME
+#define LC_TIME (-AST_LC_TIME)
+#endif
+#ifndef LC_ADDRESS
+#define LC_ADDRESS (-AST_LC_ADDRESS)
+#endif
+#ifndef LC_IDENTIFICATION
+#define LC_IDENTIFICATION (-AST_LC_IDENTIFICATION)
+#endif
+#ifndef LC_NAME
+#define LC_NAME (-AST_LC_NAME)
+#endif
+#ifndef LC_TELEPHONE
+#define LC_TELEPHONE (-AST_LC_TELEPHONE)
+#endif
+#ifndef LC_XLITERATE
+#define LC_XLITERATE (-AST_LC_XLITERATE)
+#endif
+#ifndef LC_MEASUREMENT
+#define LC_MEASUREMENT (-AST_LC_MEASUREMENT)
+#endif
+#ifndef LC_PAPER
+#define LC_PAPER (-AST_LC_PAPER)
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#undef strcoll
+#if _std_strcoll
+#define strcoll _ast_info.collate
+#else
+#define strcoll strcmp
+#endif
+
+typedef struct
+{
+
+ char* id;
+
+ struct
+ {
+ uint32_t serial;
+ uint32_t set;
+ } locale;
+
+ long tmp_long;
+ size_t tmp_size;
+ short tmp_short;
+ char tmp_char;
+ wchar_t tmp_wchar;
+
+ int (*collate) __PROTO__((const char*, const char*));
+
+ int tmp_int;
+ __V_* tmp_pointer;
+
+ int mb_cur_max;
+ int (*mb_len) __PROTO__((const char*, size_t));
+ int (*mb_towc) __PROTO__((wchar_t*, const char*, size_t));
+ size_t (*mb_xfrm) __PROTO__((char*, const char*, size_t));
+ int (*mb_width) __PROTO__((wchar_t));
+ int (*mb_conv) __PROTO__((char*, wchar_t));
+
+ uint32_t env_serial;
+
+ char pad[944];
+
+} _Ast_info_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ _Ast_info_t _ast_info;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+/* largefile hackery -- ast uses the large versions by default */
+
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if !defined(ftruncate) && _lib_ftruncate64
+#define ftruncate ftruncate64
+extern __MANGLE__ int ftruncate64 __PROTO__((int, off64_t));
+#endif
+#if !defined(lseek) && _lib_lseek64
+#define lseek lseek64
+extern __MANGLE__ off64_t lseek64 __PROTO__((int, off64_t, int));
+#endif
+#if !defined(truncate) && _lib_truncate64
+#define truncate truncate64
+extern __MANGLE__ int truncate64 __PROTO__((const char*, off64_t));
+#endif
+
+/* direct macro access for bsd crossover */
+
+#if !defined(__cplusplus)
+
+#if !defined(memcpy) && !defined(_lib_memcpy) && defined(_lib_bcopy)
+#define memcpy(t,f,n) (bcopy(f,t,n),(t))
+#endif
+
+#if !defined(memzero) && !defined(_lib_memzero)
+#if defined(_lib_memset) || !defined(_lib_bzero)
+#define memzero(b,n) memset(b,0,n)
+#else
+#define memzero(b,n) (bzero(b,n),(b))
+#endif
+#endif
+
+#endif
+
+#if !defined(remove)
+extern __MANGLE__ int remove __PROTO__((const char*));
+#endif
+
+#if !defined(rename)
+extern __MANGLE__ int rename __PROTO__((const char*, const char*));
+#endif
+
+#if !defined(strchr) && !defined(_lib_strchr) && defined(_lib_index)
+#define strchr(s,c) index(s,c)
+#endif
+
+#if !defined(strrchr) && !defined(_lib_strrchr) && defined(_lib_rindex)
+#define strrchr(s,c) rindex(s,c)
+#endif
+
+/* and now introducing prototypes botched by the standard(s) */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#undef getpgrp
+#define getpgrp() _ast_getpgrp()
+extern __MANGLE__ int _ast_getpgrp __PROTO__((void));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+/*
+ * and finally, standard interfaces hijacked by ast
+ * _ATS_STD_I delays headers that require <ast_map.h>
+ */
+
+#include <ast_map.h>
+
+#undef _AST_STD_I
+
+#if _REGEX_H < 0
+#undef _REGEX_H
+#include <regex.h>
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_stdio.h b/usr/src/lib/libast/sparcv9/include/ast/ast_stdio.h
new file mode 100644
index 0000000000..121a85717a
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_stdio.h
@@ -0,0 +1,600 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/stdio by iffe version 2007-04-04 : : */
+
+#ifndef _SFSTDIO_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SFSTDIO_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define __FILE_typedef 1
+#define _FILE_DEFINED 1
+#define _FILE_defined 1
+#define _FILEDEFED 1
+
+#ifndef __FILE_TAG
+#define __FILE_TAG _sfio_s
+#endif
+
+#undef FILE
+#undef _FILE
+#undef fpos_t
+#undef fpos64_t
+
+typedef struct _sfio_s _sfio_FILE;
+
+#define FILE _sfio_FILE
+#define _FILE FILE
+
+#if !defined(__FILE) && !__CYGWIN__
+#undef __FILE
+#define __FILE FILE
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define BUFSIZ SF_BUFSIZE
+
+#else
+
+#ifndef BUFSIZ
+#define BUFSIZ 8192
+#endif
+
+#ifndef EOF
+#define EOF (-1)
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+#include <ast_std.h>
+
+#include <sfio_s.h>
+
+#if __cplusplus
+#define _sf_(f) (f)
+#else
+#define _sf_(f) ((struct _sfio_s*)(f))
+#endif
+
+#define _SF_EOF 0000200
+#define _SF_ERROR 0000400
+
+#endif
+
+#ifdef _NO_LARGEFILE64_SOURCE
+#undef _LARGEFILE64_SOURCE
+#endif
+
+#ifdef _LARGEFILE64_SOURCE
+#undef off_t
+#endif
+
+#define fpos_t _ast_fpos_t
+#if _typ_int64_t
+#define fpos64_t _ast_fpos_t
+#endif
+
+typedef struct _ast_fpos_s
+{
+ intmax_t _sf_offset;
+ unsigned char _sf_state[64 - sizeof(intmax_t)];
+} _ast_fpos_t;
+
+#define _base _data
+#define _ptr _next
+#define _IOFBF 0
+#define _IONBF 1
+#define _IOLBF 2
+
+#if defined(__cplusplus) && defined(__THROW) && !defined(_UWIN)
+
+#undef FILE
+#define FILE FILE
+typedef struct _sfio_s FILE;
+
+#undef strerror
+extern __MANGLE__ char* strerror(int) __THROW;
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#endif
+
+#ifndef FILENAME_MAX
+#define FILENAME_MAX 1024
+#endif
+#ifndef FOPEN_MAX
+#define FOPEN_MAX 20
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+
+#define _doprnt _ast_doprnt
+#define _doscan _ast_doscan
+#define asprintf _ast_asprintf
+#define clearerr _ast_clearerr
+#define fclose _ast_fclose
+#define fdopen _ast_fdopen
+#define fflush _ast_fflush
+#define fgetc _ast_fgetc
+#define fgetpos _ast_fgetpos
+#define fgetpos64 _ast_fgetpos64
+#define fgets _ast_fgets
+#define fopen _ast_fopen
+#define fprintf _ast_fprintf
+#define fpurge _ast_fpurge
+#define fputs _ast_fputs
+#define fread _ast_fread
+#define freopen _ast_freopen
+#define fscanf _ast_fscanf
+#define fseek _ast_fseek
+#define fseek64 _ast_fseek64
+#define fseeko _ast_fseeko
+#define fseeko64 _ast_fseeko64
+#define fsetpos _ast_fsetpos
+#define fsetpos64 _ast_fsetpos64
+#define ftell _ast_ftell
+#define ftell64 _ast_ftell64
+#define ftello _ast_ftello
+#define ftello64 _ast_ftello64
+#define fwrite _ast_fwrite
+#define gets _ast_gets
+#define getw _ast_getw
+#define pclose _ast_pclose
+#define popen _ast_popen
+#define printf _ast_printf
+#define puts _ast_puts
+#define putw _ast_putw
+#define rewind _ast_rewind
+#define scanf _ast_scanf
+#define setbuf _ast_setbuf
+#undef setbuffer
+#define setbuffer _ast_setbuffer
+#define setlinebuf _ast_setlinebuf
+#define setvbuf _ast_setvbuf
+#define snprintf _ast_snprintf
+#define sprintf _ast_sprintf
+#define sscanf _ast_sscanf
+#define tmpfile _ast_tmpfile
+#define ungetc _ast_ungetc
+#define vasprintf _ast_vasprintf
+#define vfprintf _ast_vfprintf
+#define vfscanf _ast_vfscanf
+#define vprintf _ast_vprintf
+#define vscanf _ast_vscanf
+#define vsnprintf _ast_vsnprintf
+#define vsprintf _ast_vsprintf
+#define vsscanf _ast_vsscanf
+#define fcloseall _ast_fcloseall
+#define fmemopen _ast_fmemopen
+#define __getdelim _ast___getdelim
+#define getdelim _ast_getdelim
+#define getline _ast_getline
+#define clearerr_unlocked _ast_clearerr_unlocked
+#define feof_unlocked _ast_feof_unlocked
+#define ferror_unlocked _ast_ferror_unlocked
+#define fflush_unlocked _ast_fflush_unlocked
+#define fgetc_unlocked _ast_fgetc_unlocked
+#define fgets_unlocked _ast_fgets_unlocked
+#define fileno_unlocked _ast_fileno_unlocked
+#define fputc_unlocked _ast_fputc_unlocked
+#define fputs_unlocked _ast_fputs_unlocked
+#define fread_unlocked _ast_fread_unlocked
+#define fwrite_unlocked _ast_fwrite_unlocked
+#define getc_unlocked _ast_getc_unlocked
+#define getchar_unlocked _ast_getchar_unlocked
+#define putc_unlocked _ast_putc_unlocked
+#define putchar_unlocked _ast_putchar_unlocked
+
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef P_tmpdir
+#define P_tmpdir "/var/tmp/" /*NOCATLITERAL*/
+#endif
+#ifndef L_ctermid
+#define L_ctermid 9
+#endif
+#ifndef L_tmpnam
+#define L_tmpnam 25
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#if defined(__cplusplus) && defined(__THROW)
+extern __MANGLE__ char* ctermid(char*) __THROW;
+#else
+extern __MANGLE__ char* ctermid __PROTO__((char*));
+#endif
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+extern __MANGLE__ void perror __PROTO__((const char*));
+#ifndef _AST_STD_H
+#ifndef remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#endif
+#ifndef rename
+extern __MANGLE__ int rename __PROTO__((const char*, const char*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#ifdef _LARGEFILE64_SOURCE
+
+#undef fpos_t
+#undef off_t
+#undef fgetpos
+#undef fsetpos
+#undef fseek
+#undef fseeko
+#undef ftell
+#undef ftello
+
+#define fpos_t fpos64_t
+#if _typ_off64_t
+#define off_t off64_t
+#else
+#define off_t int64_t
+#endif
+
+#define fgetpos fgetpos64
+#define fsetpos fsetpos64
+#define fseek fseek64
+#define fseeko fseeko64
+#define ftell ftell64
+#define ftello ftello64
+
+#endif
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_DLL && _DLL_INDIRECT_DATA
+
+#define stdin ((FILE*)_ast_dll->_ast_stdin)
+#define stdout ((FILE*)_ast_dll->_ast_stdout)
+#define stderr ((FILE*)_ast_dll->_ast_stderr)
+
+#else
+
+#define stdin (&_Sfstdin)
+#define stdout (&_Sfstdout)
+#define stderr (&_Sfstderr)
+
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define feof(f) sfeof(f)
+#define ferror(f) sferror(f)
+#define fileno(f) sffileno(f)
+#define fputc(c,f) sfputc(f,c)
+#define getc(f) sfgetc(f)
+#define getchar() sfgetc(sfstdin)
+#define putc(c,f) sfputc(f,c)
+#define putchar(c) sfputc(sfstdout,c)
+
+#else
+
+#if !_UWIN
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+#endif
+
+extern __MANGLE__ FILE _Sfstdin;
+extern __MANGLE__ FILE _Sfstdout;
+extern __MANGLE__ FILE _Sfstderr;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define feof(f) (_sf_(f)->_flags&_SF_EOF)
+#define ferror(f) (_sf_(f)->_flags&_SF_ERROR)
+#define fileno(f) (_sf_(f)->_file)
+#define fputc(c,f) (_sf_(f)->_next>=_sf_(f)->_endw?_sfflsbuf(_sf_(f),(int)((unsigned char)(c))):(int)(*_sf_(f)->_next++=(unsigned char)(c)))
+#define getc(f) (_sf_(f)->_next>=_sf_(f)->_endr?_sffilbuf(_sf_(f),0):(int)(*_sf_(f)->_next++))
+#define getchar() getc(stdin)
+#define putc(c,f) fputc(c,f)
+#define putchar(c) fputc(c,stdout)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _sffilbuf __PROTO__((FILE*, int));
+extern __MANGLE__ int _sfflsbuf __PROTO__((FILE*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_sys.h b/usr/src/lib/libast/sparcv9/include/ast/ast_sys.h
new file mode 100644
index 0000000000..493fdadafb
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_sys.h
@@ -0,0 +1,172 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/sys by iffe version 2007-04-04 : : */
+
+#ifndef _AST_SYS_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_SYS_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#if __mips == 2 && !defined(_NO_LARGEFILE64_SOURCE)
+#define _NO_LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_NO_LARGEFILE64_SOURCE) && _typ_off64_t && _lib_lseek64 && _lib_stat64
+#if !defined(_LARGEFILE64_SOURCE)
+#define _LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_LARGEFILE_SOURCE)
+#define _LARGEFILE_SOURCE 1
+#endif
+#else
+#undef _LARGEFILE64_SOURCE
+#undef _LARGEFILE_SOURCE
+#undef _typ_off64_t
+#undef _typ_struct_dirent64
+#undef _lib_creat64
+#undef _lib_fstat64
+#undef _lib_fstatvfs64
+#undef _lib_ftruncate64
+#undef _lib_lseek64
+#undef _lib_lstat64
+#undef _lib_mmap64
+#undef _lib_open64
+#undef _lib_readdir64
+#undef _lib_stat64
+#undef _lib_statvfs64
+#undef _lib_truncate64
+#endif
+#if defined(__STDC__) && !defined(__USE_FIXED_PROTOTYPES__)
+#define __USE_FIXED_PROTOTYPES__ 1 /* kick gcc out of the past */
+#endif
+#include <stdlib.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <locale.h>
+#include <sys/localedef.h>
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _typ_dev_t 1 /* dev_t is a type */
+#define _typ_nlink_t 1 /* nlink_t is a type */
+#define _typ_gid_t 1 /* gid_t is a type */
+#define _typ_mode_t 1 /* mode_t is a type */
+#define _typ_uid_t 1 /* uid_t is a type */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _typ_wchar_t 1 /* wchar_t is a type */
+#define _typ_pid_t 1 /* pid_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _typ_wint_t 1 /* wint_t is a type */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _typ_socklen_t 1 /* socklen_t is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_ino_t 1 /* ino_t is a type */
+#define _typ_off_t 1 /* off_t is a type */
+#define _typ_ptrdiff_t 1 /* ptrdiff_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#define _typ_div_t 1 /* div_t is a type */
+#define _typ_ldiv_t 1 /* ldiv_t is a type */
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+extern __MANGLE__ int eaccess __PROTO__((const char*, int));
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+extern __MANGLE__ __V_* pvalloc __PROTO__((size_t));
+extern __MANGLE__ pid_t spawnveg __PROTO__((const char*, char* const[], char* const[], pid_t));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#if !defined(va_start)
+#if defined(__STDARG__)
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_time.h b/usr/src/lib/libast/sparcv9/include/ast/ast_time.h
new file mode 100644
index 0000000000..28c415109d
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_time.h
@@ -0,0 +1,104 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/time by iffe version 2007-04-04 : : */
+
+#ifndef _def_time_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_time_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_nanosleep 1 /* nanosleep() in default lib(s) */
+#define _lib_usleep 1 /* usleep() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#include <sys/time.h>
+
+#include <sys/times.h>
+
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC CLK_TCK
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_tty.h b/usr/src/lib/libast/sparcv9/include/ast/ast_tty.h
new file mode 100644
index 0000000000..a46782c692
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_tty.h
@@ -0,0 +1,155 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/tty by iffe version 2007-04-04 : : */
+#ifndef _def_tty_ast
+#define _def_tty_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_termios 1 /* #include <termios.h> ok */
+#define _hdr_termio 1 /* #include <termio.h> ok */
+#define _hdr_sgtty 1 /* #include <sgtty.h> ok */
+#define _sys_termios 1 /* #include <sys/termios.h> ok */
+#define _sys_termio 1 /* #include <sys/termio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _lib_tcgetattr 1 /* tcgetattr() in default lib(s) */
+#define _lib_tcgetpgrp 1 /* tcgetpgrp() in default lib(s) */
+#define _mac__POSIX_VDISABLE 1 /* _POSIX_VDISABLE is a macro */
+
+#ifdef _hdr_termios
+# if _mac__POSIX_VDISABLE
+# undef _POSIX_VDISABLE
+# endif
+# include <termios.h>
+#else
+# if defined(_sys_termios) && defined(_lib_tcgetattr)
+# include <sys/termios.h>
+# define _hdr_termios 1
+# else
+# undef _sys_termios
+# endif /* _sys_termios */
+#endif /* _hdr_termios */
+
+#ifdef _hdr_termios
+# undef _hdr_sgtty
+# undef tcgetattr
+# undef tcsetattr
+# undef tcgetpgrp
+# undef tcsetpgrp
+# undef cfgetospeed
+# ifndef TCSANOW
+# define TCSANOW TCSETS
+# define TCSADRAIN TCSETSW
+# define TCSAFLUSH TCSETSF
+# endif /* TCSANOW */
+ /* The following corrects bugs in some implementations */
+# if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
+# define TCSAFLUSH TCSADFLUSH
+# endif /* TCSADFLUSH */
+# ifndef _lib_tcgetattr
+# undef tcgetattr
+# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
+# undef tcsetattr
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# undef cfgetospeed
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# endif /* _lib_tcgetattr */
+# undef TIOCGETC
+#else
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfgetispeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfsetispeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# define cfsetospeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# ifdef _hdr_termio
+# include <termio.h>
+# else
+# ifdef _sys_termio
+# include <sys/termio.h>
+# define _hdr_termio 1
+# endif /* _sys_termio */
+# endif /* _hdr_termio */
+# ifdef _hdr_termio
+# define termios termio
+# undef TIOCGETC
+# define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+
+# ifdef _sys_bsdtty
+# include <sys/bsdtty.h>
+# endif /* _sys_bsdtty */
+# else
+# ifdef _hdr_sgtty
+# include <sgtty.h>
+# ifndef LPENDIN
+# ifdef _sys_nttyio
+# include <sys/nttyio.h>
+# endif /* _sys_nttyio */
+# endif /* LPENDIN */
+# define termios sgttyb
+# ifdef TIOCSETN
+# undef TCSETAW
+# endif /* TIOCSETN */
+# ifdef TIOCGETP
+# define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# else
+# define tcgetattr(fd,tty) gtty(fd, tty)
+# define tcsetattr(fd,action,tty) stty(fd, tty)
+# endif /* TIOCGETP */
+# else
+# ifdef _sys_ttyio
+# include <sys/ttyio.h>
+# endif
+# endif /* _hdr_sgtty */
+# endif /* hdr_termio */
+
+# ifndef TCSANOW
+# ifdef TCSETAW
+# define TCSANOW TCSETA
+# define TCSAFLUSH TCSETAF
+# else
+# ifdef TIOCSETN
+# define TCSANOW TIOCSETN
+# define TCSADRAIN TIOCSETN
+# define TCSAFLUSH TIOCSETP
+# endif /* TIOCSETN */
+# endif /* TCSETAW */
+# endif /* TCSANOW */
+#endif /* _hdr_termios */
+
+/* set ECHOCTL if driver can echo control charaters as ^c */
+#ifdef LCTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LCTLECH
+# endif /* !ECHOCTL */
+#endif /* LCTLECH */
+#ifdef LNEW_CTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LNEW_CTLECH
+# endif /* !ECHOCTL */
+#endif /* LNEW_CTLECH */
+#ifdef LNEW_PENDIN
+# ifndef PENDIN
+# define PENDIN LNEW_PENDIN
+# endif /* !PENDIN */
+#endif /* LNEW_PENDIN */
+
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_types.h b/usr/src/lib/libast/sparcv9/include/ast/ast_types.h
new file mode 100644
index 0000000000..6449f59df8
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_types.h
@@ -0,0 +1,26 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_types_ast
+#define _def_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_version.h b/usr/src/lib/libast/sparcv9/include/ast/ast_version.h
new file mode 100644
index 0000000000..0e586f9555
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_version.h
@@ -0,0 +1,10 @@
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+#define _AST_VERSION 20061111L
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_vfork.h b/usr/src/lib/libast/sparcv9/include/ast/ast_vfork.h
new file mode 100644
index 0000000000..06fc6a49a5
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_vfork.h
@@ -0,0 +1,89 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/vfork by iffe version 2007-04-04 : : */
+
+#ifndef _def_vfork_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_vfork_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+extern __MANGLE__ pid_t vfork __PROTO__((void));
+#pragma unknown_control_flow(vfork)
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_wait.h b/usr/src/lib/libast/sparcv9/include/ast/ast_wait.h
new file mode 100644
index 0000000000..443d16814f
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_wait.h
@@ -0,0 +1,32 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/wait by iffe version 2007-04-04 : : */
+#ifndef _def_wait_ast
+#define _def_wait_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_wait 1 /* wait() in default lib(s) */
+#define _lib_wait3 1 /* wait3() in default lib(s) */
+#define _lib_wait4 1 /* wait4() in default lib(s) */
+#define _lib_waitpid 1 /* waitpid() in default lib(s) */
+#define _sys_wait 1 /* #include <sys/wait.h> ok */
+#define _ok_wif 1 /* posix wait macros ok */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_wchar.h b/usr/src/lib/libast/sparcv9/include/ast/ast_wchar.h
new file mode 100644
index 0000000000..442617c82f
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_wchar.h
@@ -0,0 +1,208 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/wchar by iffe version 2007-04-04 : : */
+
+#ifndef _def_wchar_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_wchar_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _lib_mbstowcs 1 /* mbstowcs() in default lib(s) */
+#define _lib_wctomb 1 /* wctomb() in default lib(s) */
+#define _lib_wcrtomb 1 /* wcrtomb() in default lib(s) */
+#define _lib_wcslen 1 /* wcslen() in default lib(s) */
+#define _lib_wcstombs 1 /* wcstombs() in default lib(s) */
+#define _lib_wcwidth 1 /* wcwidth() in default lib(s) */
+#define _lib_towlower 1 /* towlower() in default lib(s) */
+#define _lib_towupper 1 /* towupper() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_mbstate_t 1 /* mbstate_t is a type */
+#define _nxt_wchar <../include/wchar.h> /* include path for the native <wchar.h> */
+#define _nxt_wchar_str "../include/wchar.h" /* include string for the native <wchar.h> */
+#ifndef _SFSTDIO_H
+#include <ast_common.h>
+#include <stdio.h>
+#endif
+#if _hdr_wchar && defined(_nxt_wchar)
+#include <../include/wchar.h> /* the native wchar.h */
+#endif
+#if _hdr_wctype
+#include <wctype.h>
+#endif
+
+#ifndef WEOF
+#define WEOF (-1)
+#endif
+
+#undef fgetwc
+#undef fgetws
+#undef fputwc
+#undef fputws
+#undef getwc
+#undef getwchar
+#undef getws
+#undef putwc
+#undef putwchar
+#undef ungetwc
+
+#define fgetwc _ast_fgetwc
+#define fgetws _ast_fgetws
+#define fputwc _ast_fputwc
+#define fputws _ast_fputws
+#define fwide _ast_fwide
+#define fwprintf _ast_fwprintf
+#define fwscanf _ast_fwscanf
+#define getwc _ast_getwc
+#define getwchar _ast_getwchar
+#define getws _ast_getws
+#define putwc _ast_putwc
+#define putwchar _ast_putwchar
+#define swprintf _ast_swprintf
+#define swscanf _ast_swscanf
+#define ungetwc _ast_ungetwc
+#define vfwprintf _ast_vfwprintf
+#define vfwscanf _ast_vfwscanf
+#define vswprintf _ast_vswprintf
+#define vswscanf _ast_vswscanf
+#define vwprintf _ast_vwprintf
+#define vwscanf _ast_vwscanf
+#define wprintf _ast_wprintf
+#define wscanf _ast_wscanf
+
+#if !_typ_mbstate_t
+#undef _typ_mbstate_t
+#define _typ_mbstate_t 1
+typedef char mbstate_t;
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#if !_lib_mbstowcs
+extern __MANGLE__ size_t mbstowcs __PROTO__((wchar_t*, const char*, size_t));
+#endif
+#if !_lib_wctomb
+extern __MANGLE__ int wctomb __PROTO__((char*, wchar_t));
+#endif
+#if !_lib_wcrtomb
+extern __MANGLE__ size_t wcrtomb __PROTO__((char*, wchar_t, mbstate_t*));
+#endif
+#if !_lib_wcslen
+extern __MANGLE__ size_t wcslen __PROTO__((const wchar_t*));
+#endif
+#if !_lib_wcstombs
+extern __MANGLE__ size_t wcstombs __PROTO__((char*, const wchar_t*, size_t));
+#endif
+
+extern __MANGLE__ int fwprintf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ int fwscanf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ wint_t fgetwc __PROTO__((FILE*));
+extern __MANGLE__ wchar_t* fgetws __PROTO__((wchar_t*, int, FILE*));
+extern __MANGLE__ wint_t fputwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ int fputws __PROTO__((const wchar_t*, FILE*));
+extern __MANGLE__ int fwide __PROTO__((FILE*, int));
+extern __MANGLE__ wint_t getwc __PROTO__((FILE*));
+extern __MANGLE__ wint_t getwchar __PROTO__((void));
+extern __MANGLE__ wchar_t* getws __PROTO__((wchar_t*));
+extern __MANGLE__ wint_t putwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ wint_t putwchar __PROTO__((wchar_t));
+extern __MANGLE__ int swprintf __PROTO__((wchar_t*, size_t, const wchar_t*, ...));
+extern __MANGLE__ int swscanf __PROTO__((const wchar_t*, const wchar_t*, ...));
+extern __MANGLE__ wint_t ungetwc __PROTO__((wint_t, FILE*));
+extern __MANGLE__ int vfwprintf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vfwscanf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vwprintf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vwscanf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vswprintf __PROTO__((wchar_t*, size_t, const wchar_t*, va_list));
+extern __MANGLE__ int vswscanf __PROTO__((const wchar_t*, const wchar_t*, va_list));
+extern __MANGLE__ int wprintf __PROTO__((const wchar_t*, ...));
+extern __MANGLE__ int wscanf __PROTO__((const wchar_t*, ...));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ast_windows.h b/usr/src/lib/libast/sparcv9/include/ast/ast_windows.h
new file mode 100644
index 0000000000..90e0260f59
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ast_windows.h
@@ -0,0 +1,48 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * AT&T Research
+ *
+ * ast <windows.h> wrapper
+ * for libast only
+ * include after ast headers
+ */
+
+#ifndef _AST_WINDOWS_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_WINDOWS_H 1
+
+#undef SF_ERROR /* clash in <oaidl.h> */
+
+#include <windows.h>
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/bytesex.h b/usr/src/lib/libast/sparcv9/include/ast/bytesex.h
new file mode 100644
index 0000000000..2bf2022afb
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/bytesex.h
@@ -0,0 +1,43 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * linux/gnu compatibility
+ */
+
+#ifndef _BYTESEX_H
+#define _BYTESEX_H
+
+#include <ast_common.h>
+
+#undef __BYTE_ORDER
+
+#if ( _ast_intswap & 3 ) == 3
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#else
+#if ( _ast_intswap & 3 ) == 1
+#define __BYTE_ORDER __PDP_ENDIAN
+#else
+#define __BYTE_ORDER __BIG_ENDIAN
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ccode.h b/usr/src/lib/libast/sparcv9/include/ast/ccode.h
new file mode 100644
index 0000000000..d26926ebc4
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ccode.h
@@ -0,0 +1,101 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * character code map interface
+ *
+ * NOTE: used for mapping between 8-bit character encodings
+ * ISO character sets are handled by sfio
+ */
+
+#ifndef _CHARCODE_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _CHARCODE_H 1
+
+#include <ast.h>
+#include <ast_ccode.h>
+
+typedef struct Ccmap_s
+{
+ const char* name; /* code set name */
+ const char* match; /* strmatch() pattern */
+ const char* desc; /* code set description */
+ const char* canon; /* canonical name format */
+ const char* index; /* default index */
+ int ccode; /* <ccode.h> code index */
+ __V_* data; /* map specific data */
+} Ccmap_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ unsigned char* _ccmap __PROTO__((int, int));
+extern __MANGLE__ __V_* _ccmapcpy __PROTO__((unsigned char*, __V_*, const __V_*, size_t));
+extern __MANGLE__ __V_* _ccmapstr __PROTO__((unsigned char*, __V_*, size_t));
+
+extern __MANGLE__ int ccmapid __PROTO__((const char*));
+extern __MANGLE__ char* ccmapname __PROTO__((int));
+extern __MANGLE__ __V_* ccnative __PROTO__((__V_*, const __V_*, size_t));
+extern __MANGLE__ Ccmap_t* ccmaplist __PROTO__((Ccmap_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define CCOP(i,o) ((i)==(o)?0:(((o)<<8)|(i)))
+#define CCIN(x) ((x)&0xFF)
+#define CCOUT(x) (((x)>>8)&0xFF)
+#define CCCONVERT(x) ((x)&0xFF00)
+
+#define CCCVT(x) CCMAP(x,0)
+#define CCMAP(i,o) ((i)==(o)?(unsigned char*)0:_ccmap(i,o))
+#define CCMAPCHR(m,c) ((m)?(m)[c]:(c))
+#define CCMAPCPY(m,t,f,n) ((m)?_ccmapcpy(m,t,f,n):memcpy(t,f,n))
+#define CCMAPSTR(m,s,n) ((m)?_ccmapstr(m,s,n):(__V_*)(s))
+
+#define ccmap(i,o) CCMAP(i,o)
+#define ccmapchr(m,c) CCMAPCHR(m,c)
+#define ccmapcpy(m,t,f,n) CCMAPCPY(m,t,f,n)
+#define ccmapstr(m,s,n) CCMAPSTR(m,s,n)
+
+#define CCMAPC(c,i,o) ((i)==(o)?(c):CCMAP(i,o)[c])
+#define CCMAPM(t,f,n,i,o) ((i)==(o)?memcpy(t,f,n):_ccmapcpy(CCMAP(i,o),t,f,n))
+#define CCMAPS(s,n,i,o) ((i)==(o)?(__V_*)(s):_ccmapstr(CCMAP(i,o),s,n))
+
+#define ccmapc(c,i,o) CCMAPC(c,i,o)
+#define ccmapm(t,f,n,i,o) CCMAPM(t,f,n,i,o)
+#define ccmaps(s,n,i,o) CCMAPS(s,n,i,o)
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/cdt.h b/usr/src/lib/libast/sparcv9/include/ast/cdt.h
new file mode 100644
index 0000000000..f6274cef92
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/cdt.h
@@ -0,0 +1,311 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _CDT_H
+#define _CDT_H 1
+
+/* Public interface for the dictionary library
+**
+** Written by Kiem-Phong Vo
+*/
+
+#define CDT_VERSION 20050420L
+
+#if _PACKAGE_ast
+#include <ast_std.h>
+#else
+#include <ast_common.h>
+#endif
+
+typedef struct _dtlink_s Dtlink_t;
+typedef struct _dthold_s Dthold_t;
+typedef struct _dtdisc_s Dtdisc_t;
+typedef struct _dtmethod_s Dtmethod_t;
+typedef struct _dtdata_s Dtdata_t;
+typedef struct _dt_s Dt_t;
+typedef struct _dt_s Dict_t; /* for libdict compatibility */
+typedef struct _dtstat_s Dtstat_t;
+typedef Void_t* (*Dtsearch_f)_ARG_((Dt_t*,Void_t*,int));
+typedef Void_t* (*Dtmake_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*));
+typedef void (*Dtfree_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*));
+typedef int (*Dtcompar_f)_ARG_((Dt_t*,Void_t*,Void_t*,Dtdisc_t*));
+typedef unsigned int (*Dthash_f)_ARG_((Dt_t*,Void_t*,Dtdisc_t*));
+typedef Void_t* (*Dtmemory_f)_ARG_((Dt_t*,Void_t*,size_t,Dtdisc_t*));
+typedef int (*Dtevent_f)_ARG_((Dt_t*,int,Void_t*,Dtdisc_t*));
+
+struct _dtlink_s
+{ Dtlink_t* right; /* right child */
+ union
+ { unsigned int _hash; /* hash value */
+ Dtlink_t* _left; /* left child */
+ } hl;
+};
+
+/* private structure to hold an object */
+struct _dthold_s
+{ Dtlink_t hdr; /* header */
+ Void_t* obj; /* user object */
+};
+
+/* method to manipulate dictionary structure */
+struct _dtmethod_s
+{ Dtsearch_f searchf; /* search function */
+ int type; /* type of operation */
+};
+
+/* stuff that may be in shared memory */
+struct _dtdata_s
+{ int type; /* type of dictionary */
+ Dtlink_t* here; /* finger to last search element */
+ union
+ { Dtlink_t** _htab; /* hash table */
+ Dtlink_t* _head; /* linked list */
+ } hh;
+ int ntab; /* number of hash slots */
+ int size; /* number of objects */
+ int loop; /* number of nested loops */
+ int minp; /* min path before splay, always even */
+ /* for hash dt, > 0: fixed table size */
+};
+
+/* structure to hold methods that manipulate an object */
+struct _dtdisc_s
+{ int key; /* where the key begins in an object */
+ int size; /* key size and type */
+ int link; /* offset to Dtlink_t field */
+ Dtmake_f makef; /* object constructor */
+ Dtfree_f freef; /* object destructor */
+ Dtcompar_f comparf;/* to compare two objects */
+ Dthash_f hashf; /* to compute hash value of an object */
+ Dtmemory_f memoryf;/* to allocate/free memory */
+ Dtevent_f eventf; /* to process events */
+};
+
+#define DTDISC(dc,ky,sz,lk,mkf,frf,cmpf,hshf,memf,evf) \
+ ( (dc)->key = (ky), (dc)->size = (sz), (dc)->link = (lk), \
+ (dc)->makef = (mkf), (dc)->freef = (frf), \
+ (dc)->comparf = (cmpf), (dc)->hashf = (hshf), \
+ (dc)->memoryf = (memf), (dc)->eventf = (evf) )
+
+#ifdef offsetof
+#define DTOFFSET(struct_s, member) offsetof(struct_s, member)
+#else
+#define DTOFFSET(struct_s, member) ((int)(&((struct_s*)0)->member))
+#endif
+
+/* the dictionary structure itself */
+struct _dt_s
+{ Dtsearch_f searchf;/* search function */
+ Dtdisc_t* disc; /* method to manipulate objs */
+ Dtdata_t* data; /* sharable data */
+ Dtmemory_f memoryf;/* function to alloc/free memory */
+ Dtmethod_t* meth; /* dictionary method */
+ int type; /* type information */
+ int nview; /* number of parent view dictionaries */
+ Dt_t* view; /* next on viewpath */
+ Dt_t* walk; /* dictionary being walked */
+ Void_t* user; /* for user's usage */
+};
+
+/* structure to get status of a dictionary */
+struct _dtstat_s
+{ int dt_meth; /* method type */
+ int dt_size; /* number of elements */
+ int dt_n; /* number of chains or levels */
+ int dt_max; /* max size of a chain or a level */
+ int* dt_count; /* counts of chains or levels by size */
+};
+
+/* flag set if the last search operation actually found the object */
+#define DT_FOUND 0100000
+
+/* supported storage methods */
+#define DT_SET 0000001 /* set with unique elements */
+#define DT_BAG 0000002 /* multiset */
+#define DT_OSET 0000004 /* ordered set (self-adjusting tree) */
+#define DT_OBAG 0000010 /* ordered multiset */
+#define DT_LIST 0000020 /* linked list */
+#define DT_STACK 0000040 /* stack */
+#define DT_QUEUE 0000100 /* queue */
+#define DT_METHODS 0000177 /* all currently supported methods */
+
+/* asserts to dtdisc() */
+#define DT_SAMECMP 0000001 /* compare methods equivalent */
+#define DT_SAMEHASH 0000002 /* hash methods equivalent */
+
+/* types of search */
+#define DT_INSERT 0000001 /* insert object if not found */
+#define DT_DELETE 0000002 /* delete object if found */
+#define DT_SEARCH 0000004 /* look for an object */
+#define DT_NEXT 0000010 /* look for next element */
+#define DT_PREV 0000020 /* find previous element */
+#define DT_RENEW 0000040 /* renewing an object */
+#define DT_CLEAR 0000100 /* clearing all objects */
+#define DT_FIRST 0000200 /* get first object */
+#define DT_LAST 0000400 /* get last object */
+#define DT_MATCH 0001000 /* find object matching key */
+#define DT_VSEARCH 0002000 /* search using internal representation */
+#define DT_ATTACH 0004000 /* attach an object to the dictionary */
+#define DT_DETACH 0010000 /* detach an object from the dictionary */
+
+/* events */
+#define DT_OPEN 1 /* a dictionary is being opened */
+#define DT_CLOSE 2 /* a dictionary is being closed */
+#define DT_DISC 3 /* discipline is about to be changed */
+#define DT_METH 4 /* method is about to be changed */
+#define DT_ENDOPEN 5 /* dtopen() is done */
+#define DT_ENDCLOSE 6 /* dtclose() is done */
+#define DT_HASHSIZE 7 /* setting hash table size */
+
+_BEGIN_EXTERNS_ /* public data */
+#if _BLD_cdt && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+#if !_BLD_cdt && defined(__IMPORT__)
+#define extern __IMPORT__
+#endif
+
+extern Dtmethod_t* Dtset;
+extern Dtmethod_t* Dtbag;
+extern Dtmethod_t* Dtoset;
+extern Dtmethod_t* Dtobag;
+extern Dtmethod_t* Dtlist;
+extern Dtmethod_t* Dtstack;
+extern Dtmethod_t* Dtqueue;
+
+/* compatibility stuff; will go away */
+#ifndef KPVDEL
+extern Dtmethod_t* Dtorder;
+extern Dtmethod_t* Dttree;
+extern Dtmethod_t* Dthash;
+extern Dtmethod_t _Dttree;
+extern Dtmethod_t _Dthash;
+extern Dtmethod_t _Dtlist;
+extern Dtmethod_t _Dtqueue;
+extern Dtmethod_t _Dtstack;
+#endif
+
+#undef extern
+_END_EXTERNS_
+
+_BEGIN_EXTERNS_ /* public functions */
+#if _BLD_cdt && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Dt_t* dtopen _ARG_((Dtdisc_t*, Dtmethod_t*));
+extern int dtclose _ARG_((Dt_t*));
+extern Dt_t* dtview _ARG_((Dt_t*, Dt_t*));
+extern Dtdisc_t* dtdisc _ARG_((Dt_t* dt, Dtdisc_t*, int));
+extern Dtmethod_t* dtmethod _ARG_((Dt_t*, Dtmethod_t*));
+
+extern Dtlink_t* dtflatten _ARG_((Dt_t*));
+extern Dtlink_t* dtextract _ARG_((Dt_t*));
+extern int dtrestore _ARG_((Dt_t*, Dtlink_t*));
+
+extern int dttreeset _ARG_((Dt_t*, int, int));
+
+extern int dtwalk _ARG_((Dt_t*, int(*)(Dt_t*,Void_t*,Void_t*), Void_t*));
+
+extern Void_t* dtrenew _ARG_((Dt_t*, Void_t*));
+
+extern int dtsize _ARG_((Dt_t*));
+extern int dtstat _ARG_((Dt_t*, Dtstat_t*, int));
+extern unsigned int dtstrhash _ARG_((unsigned int, Void_t*, int));
+
+#if !_PACKAGE_ast
+extern int memcmp _ARG_((const Void_t*, const Void_t*, size_t));
+extern int strcmp _ARG_((const char*, const char*));
+#endif
+
+#undef extern
+_END_EXTERNS_
+
+/* internal functions for translating among holder, object and key */
+#define _DT(dt) ((Dt_t*)(dt))
+#define _DTDSC(dc,ky,sz,lk,cmpf) \
+ (ky = (dc)->key, sz = (dc)->size, lk = (dc)->link, cmpf = (dc)->comparf)
+#define _DTLNK(o,lk) ((Dtlink_t*)((char*)(o) + lk) )
+#define _DTOBJ(e,lk) ((lk) < 0 ? ((Dthold_t*)(e))->obj : (Void_t*)((char*)(e) - (lk)) )
+#define _DTKEY(o,ky,sz) (Void_t*)((sz) < 0 ? *((char**)((char*)(o)+(ky))) : ((char*)(o)+(ky)))
+
+#define _DTCMP(dt,k1,k2,dc,cmpf,sz) \
+ ((cmpf) ? (*cmpf)(dt,k1,k2,dc) : \
+ ((sz) <= 0 ? strcmp(k1,k2) : memcmp(k1,k2,sz)) )
+#define _DTHSH(dt,ky,dc,sz) ((dc)->hashf ? (*(dc)->hashf)(dt,ky,dc) : dtstrhash(0,ky,sz) )
+
+/* special search function for tree structure only */
+#define _DTMTCH(dt,key,action) \
+ do { Dtlink_t* _e; Void_t *_o, *_k, *_key; Dtdisc_t* _dc; \
+ int _ky, _sz, _lk, _cmp; Dtcompar_f _cmpf; \
+ _dc = (dt)->disc; _DTDSC(_dc, _ky, _sz, _lk, _cmpf); \
+ _key = (key); \
+ for(_e = (dt)->data->here; _e; _e = _cmp < 0 ? _e->hl._left : _e->right) \
+ { _o = _DTOBJ(_e, _lk); _k = _DTKEY(_o, _ky, _sz); \
+ if((_cmp = _DTCMP((dt), _key, _k, _dc, _cmpf, _sz)) == 0) \
+ break; \
+ } \
+ action (_e ? _o : (Void_t*)0); \
+ } while(0)
+
+#define _DTSRCH(dt,obj,action) \
+ do { Dtlink_t* _e; Void_t *_o, *_k, *_key; Dtdisc_t* _dc; \
+ int _ky, _sz, _lk, _cmp; Dtcompar_f _cmpf; \
+ _dc = (dt)->disc; _DTDSC(_dc, _ky, _sz, _lk, _cmpf); \
+ _key = _DTKEY(obj, _ky, _sz); \
+ for(_e = (dt)->data->here; _e; _e = _cmp < 0 ? _e->hl._left : _e->right) \
+ { _o = _DTOBJ(_e, _lk); _k = _DTKEY(_o, _ky, _sz); \
+ if((_cmp = _DTCMP((dt), _key, _k, _dc, _cmpf, _sz)) == 0) \
+ break; \
+ } \
+ action (_e ? _o : (Void_t*)0); \
+ } while(0)
+
+#define DTTREEMATCH(dt,key,action) _DTMTCH(_DT(dt),(Void_t*)(key),action)
+#define DTTREESEARCH(dt,obj,action) _DTSRCH(_DT(dt),(Void_t*)(obj),action)
+
+#define dtvnext(d) (_DT(d)->view)
+#define dtvcount(d) (_DT(d)->nview)
+#define dtvhere(d) (_DT(d)->walk)
+
+#define dtlink(d,e) (((Dtlink_t*)(e))->right)
+#define dtobj(d,e) _DTOBJ((e), _DT(d)->disc->link)
+#define dtfinger(d) (_DT(d)->data->here ? dtobj((d),_DT(d)->data->here):(Void_t*)(0))
+
+#define dtfirst(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_FIRST)
+#define dtnext(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_NEXT)
+#define dtleast(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH|DT_NEXT)
+#define dtlast(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_LAST)
+#define dtprev(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_PREV)
+#define dtmost(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH|DT_PREV)
+#define dtsearch(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH)
+#define dtmatch(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_MATCH)
+#define dtinsert(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_INSERT)
+#define dtdelete(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_DELETE)
+#define dtattach(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_ATTACH)
+#define dtdetach(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_DETACH)
+#define dtclear(d) (*(_DT(d)->searchf))((d),(Void_t*)(0),DT_CLEAR)
+#define dtfound(d) (_DT(d)->type & DT_FOUND)
+
+#define DT_PRIME 17109811 /* 2#00000001 00000101 00010011 00110011 */
+#define dtcharhash(h,c) (((unsigned int)(h) + (unsigned int)(c)) * DT_PRIME )
+
+#endif /* _CDT_H */
diff --git a/usr/src/lib/libast/sparcv9/include/ast/debug.h b/usr/src/lib/libast/sparcv9/include/ast/debug.h
new file mode 100644
index 0000000000..ad7ecb7a54
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/debug.h
@@ -0,0 +1,63 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * common ast debug definitions
+ * include after the ast headers
+ */
+
+#ifndef _DEBUG_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _DEBUG_H
+
+#include <ast.h>
+#include <error.h>
+
+#if DEBUG || _BLD_DEBUG
+#define debug(x) x
+#define message(x) do if (error_info.trace < 0) { error x; } while (0)
+#define messagef(x) do if (error_info.trace < 0) { errorf x; } while (0)
+#else
+#define debug(x)
+#define message(x)
+#define messagef(x)
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ void systrace __PROTO__((const char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/dirent.h b/usr/src/lib/libast/sparcv9/include/ast/dirent.h
new file mode 100644
index 0000000000..32f33800b5
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/dirent.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_dirent.h>
diff --git a/usr/src/lib/libast/sparcv9/include/ast/dt.h b/usr/src/lib/libast/sparcv9/include/ast/dt.h
new file mode 100644
index 0000000000..0b7c331577
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/dt.h
@@ -0,0 +1,49 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+#ifndef _DT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _DT_H 1
+
+#include <cdt.h>
+#include <vmalloc.h>
+
+#if _BLD_cdt && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Dt_t* dtnew __PROTO__((Vmalloc_t*, Dtdisc_t*, Dtmethod_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/endian.h b/usr/src/lib/libast/sparcv9/include/ast/endian.h
new file mode 100644
index 0000000000..2299b5a3bc
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/endian.h
@@ -0,0 +1,54 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * linux/gnu compatibility
+ */
+
+#ifndef _ENDIAN_H
+#define _ENDIAN_H
+
+#include <bytesex.h>
+
+#define __LITTLE_ENDIAN 1234
+#define __BIG_ENDIAN 4321
+#define __PDP_ENDIAN 3412
+
+#if defined (__USE_BSD) && !defined(__STRICT_ANSI__)
+
+#ifndef LITTLE_ENDIAN
+#define LITTLE_ENDIAN __LITTLE_ENDIAN
+#endif
+
+#ifndef BIG_ENDIAN
+#define BIG_ENDIAN __BIG_ENDIAN
+#endif
+
+#ifndef PDP_ENDIAN
+#define PDP_ENDIAN __PDP_ENDIAN
+#endif
+
+#undef BYTE_ORDER
+#define BYTE_ORDER __BYTE_ORDER
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/error.h b/usr/src/lib/libast/sparcv9/include/ast/error.h
new file mode 100644
index 0000000000..d6d171a15e
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/error.h
@@ -0,0 +1,196 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * option, error and message formatter external definitions
+ */
+
+#ifndef _ERROR_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _ERROR_H
+
+#include <ast.h>
+#include <option.h>
+#include <errno.h>
+
+#define ERROR_VERSION 20070319L
+
+#if !defined(errno) && defined(__DYNAMIC__)
+#define errno __DYNAMIC__(errno)
+#endif
+
+#define ERROR_debug(n) (-(n))
+#define ERROR_exit(n) ((n)+ERROR_ERROR)
+#define ERROR_system(n) (((n)+ERROR_ERROR)|ERROR_SYSTEM)
+#define ERROR_usage(n) ((((n)?2:0)+ERROR_ERROR)|ERROR_USAGE)
+#define ERROR_warn(n) (ERROR_WARNING)
+
+#ifndef ERROR_catalog
+#define ERROR_catalog(t) t
+#endif
+#ifndef ERROR_dictionary
+#define ERROR_dictionary(t) t
+#endif
+
+#ifndef ERROR_translate
+#define ERROR_translating() (error_info.translate&&(ast.locale.set&(1<<AST_LC_MESSAGES)))
+#define ERROR_translate(l,i,d,m) (ERROR_translating()?errorx((const char*)l,(const char*)i,(const char*)d,(const char*)m):(m))
+#endif
+
+#define ERROR_INFO 0 /* info message -- no err_id */
+#define ERROR_WARNING 1 /* warning message */
+#define ERROR_ERROR 2 /* error message -- no err_exit */
+#define ERROR_FATAL 3 /* error message with err_exit */
+#define ERROR_NOEXEC EXIT_NOEXEC /* shell convention */
+#define ERROR_NOENT EXIT_NOTFOUND /* shell convention */
+#define ERROR_PANIC ERROR_LEVEL /* panic message with err_exit */
+
+#define ERROR_LEVEL 0x00ff /* level portion of status */
+#define ERROR_SYSTEM 0x0100 /* report system errno message */
+#define ERROR_OUTPUT 0x0200 /* next arg is error fd */
+#define ERROR_SOURCE 0x0400 /* next 2 args are FILE,LINE */
+#define ERROR_USAGE 0x0800 /* usage message */
+#define ERROR_PROMPT 0x1000 /* omit trailing newline */
+#define ERROR_NOID 0x2000 /* omit err_id */
+#define ERROR_LIBRARY 0x4000 /* library routine error */
+
+#define ERROR_INTERACTIVE 0x0001 /* context is interactive */
+#define ERROR_SILENT 0x0002 /* context is silent */
+#define ERROR_NOTIFY 0x0004 /* main(-sig,0,ctx) on signal */
+
+#define ERROR_FREE 0x0010 /* free context on pop */
+#define ERROR_POP 0x0020 /* pop context */
+#define ERROR_PUSH 0x0040 /* push context */
+#define ERROR_SET 0x0080 /* set context */
+
+/*
+ * errorpush()/errorpop() are obsolete -- use errorctx() instead
+ */
+
+#ifndef ERROR_CONTEXT_T
+#define ERROR_CONTEXT_T Error_info_t
+#endif
+
+#define ERROR_CONTEXT_BASE ((Error_context_t*)&error_info.context)
+
+#define errorpush(p,f) (*(p)= *ERROR_CONTEXT_BASE,*ERROR_CONTEXT_BASE=error_info.empty,error_info.context=(Error_context_t*)(p),error_info.flags=(f))
+#define errorpop(p) (*ERROR_CONTEXT_BASE= *(p))
+
+typedef struct Error_info_s Error_info_t;
+typedef struct Error_context_s Error_context_t;
+
+#define ERROR_CONTEXT \
+ ERROR_CONTEXT_T* context; /* prev context stack element */ \
+ int errors; /* >= ERROR_ERROR count */ \
+ int flags; /* context flags */ \
+ int line; /* input|output line number */ \
+ int warnings; /* ERROR_WARNING count */ \
+ char* file; /* input|output file name */ \
+ char* id; /* command id */
+
+struct Error_context_s /* context stack element */
+{
+ ERROR_CONTEXT
+};
+
+struct Error_info_s /* error state */
+{
+ int fd; /* write(2) fd */
+
+ void (*exit) __PROTO__((int)); /* error exit */
+ ssize_t (*write) __PROTO__((int, const __V_*, size_t)); /* error output */
+
+ /* the rest are implicitly initialized */
+
+ int clear; /* default clear ERROR_* flags */
+ int core; /* level>=core -> core dump */
+ int indent; /* debug trace indent level */
+ int init; /* initialized */
+ int last_errno; /* last reported errno */
+ int mask; /* multi level debug trace mask */
+ int set; /* default set ERROR_* flags */
+ int trace; /* debug trace level */
+
+ char* version; /* ERROR_SOURCE command version */
+
+ int (*auxilliary) __PROTO__((Sfio_t*, int, int)); /* aux info to append */
+
+ ERROR_CONTEXT /* top of context stack */
+
+ Error_context_t empty; /* empty context stack element */
+
+ unsigned long time; /* debug time trace */
+
+ char* (*translate) __PROTO__((const char*, const char*, const char*, const char*)); /* format translator */
+
+ const char* catalog; /* message catalog */
+};
+
+#ifndef errno
+extern __MANGLE__ int errno; /* system call error status */
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Error_info_t* _error_infop_;
+
+#define error_info (*_error_infop_)
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ void error __PROTO__((int, ...));
+extern __MANGLE__ int errormsg __PROTO__((const char*, int, ...));
+extern __MANGLE__ int errorf __PROTO__((__V_*, __V_*, int, ...));
+extern __MANGLE__ void errorv __PROTO__((const char*, int, va_list));
+#ifndef errorx
+extern __MANGLE__ char* errorx __PROTO__((const char*, const char*, const char*, const char*));
+#endif
+extern __MANGLE__ Error_info_t* errorctx __PROTO__((Error_info_t*, int, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/find.h b/usr/src/lib/libast/sparcv9/include/ast/find.h
new file mode 100644
index 0000000000..0caf2019cf
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/find.h
@@ -0,0 +1,97 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * fast find interface definitions
+ */
+
+#ifndef _FIND_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FIND_H
+
+#define FIND_VERSION 19980301L
+
+#ifndef FIND_CODES
+#define FIND_CODES "lib/find/codes"
+#endif
+
+#define FIND_CODES_ENV "FINDCODES"
+
+#define FIND_GENERATE (1<<0) /* generate new codes */
+#define FIND_ICASE (1<<1) /* ignore case in match */
+#define FIND_GNU (1<<2) /* generate gnu format codes */
+#define FIND_OLD (1<<3) /* generate old format codes */
+#define FIND_TYPE (1<<4) /* generate type with codes */
+#define FIND_VERIFY (1<<5) /* verify the dir hierarchy */
+
+#define FIND_USER (1L<<16) /* first user flag bit */
+
+struct Find_s;
+struct Finddisc_s;
+
+typedef int (*Findverify_f) __PROTO__((struct Find_s*, const char*, size_t, struct Finddisc_s*));
+
+typedef struct Finddisc_s
+{
+ unsigned long version; /* interface version */
+ unsigned long flags; /* FIND_* flags */
+ Error_f errorf; /* error function */
+ Findverify_f verifyf; /* dir verify function */
+ char** dirs; /* dir prefixes to search */
+} Finddisc_t;
+
+typedef struct Find_s
+{
+ const char* id; /* library id string */
+ unsigned long stamp; /* codes time stamp */
+
+#ifdef _FIND_PRIVATE_
+ _FIND_PRIVATE_
+#endif
+
+} Find_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Find_t* findopen __PROTO__((const char*, const char*, const char*, Finddisc_t*));
+extern __MANGLE__ char* findread __PROTO__((Find_t*));
+extern __MANGLE__ int findwrite __PROTO__((Find_t*, const char*, size_t, const char*));
+extern __MANGLE__ int findclose __PROTO__((Find_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/fnmatch.h b/usr/src/lib/libast/sparcv9/include/ast/fnmatch.h
new file mode 100644
index 0000000000..83e2dd9943
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/fnmatch.h
@@ -0,0 +1,71 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * posix fnmatch interface definitions
+ */
+
+#ifndef _FNMATCH_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FNMATCH_H
+
+#include <ast_common.h>
+
+/* fnmatch flags */
+
+#define FNM_NOESCAPE 0x0001 /* \ is literal */
+#define FNM_PATHNAME 0x0002 /* explicit match for / */
+#define FNM_PERIOD 0x0004 /* explicit match for leading . */
+#define FNM_NOSYS 0x0010 /* not implemented */
+
+/* nonstandard fnmatch() flags */
+
+#define FNM_AUGMENTED 0x0008 /* enable ! & ( | ) */
+#define FNM_ICASE 0x0020 /* ignore case in match */
+#define FNM_LEADING_DIR 0x0040 /* match up to implicit / */
+
+#define FNM_CASEFOLD FNM_ICASE /* gnu compatibility */
+#define FNM_FILE_NAME FNM_PATHNAME /* gnu compatibility */
+
+/* fnmatch error codes -- other non-zero values from <regex.h> */
+
+#define FNM_NOMATCH 1 /* == REG_NOMATCH */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int fnmatch __PROTO__((const char*, const char*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/fnv.h b/usr/src/lib/libast/sparcv9/include/ast/fnv.h
new file mode 100644
index 0000000000..6af5c1489c
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/fnv.h
@@ -0,0 +1,81 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * Landon Kurt Knoll
+ * Phong Vo
+ *
+ * FNV-1 linear congruent checksum/hash/PRNG
+ * see http://www.isthe.com/chongo/tech/comp/fnv/
+ */
+
+#ifndef _FNV_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FNV_H
+
+#include <ast_common.h>
+
+#define FNV_INIT 0x811c9dc5L
+#define FNV_MULT 0x01000193L
+
+#define FNVINIT(h) (h = FNV_INIT)
+#define FNVPART(h,c) (h = (h) * FNV_MULT ^ (c))
+#define FNVSUM(h,s,n) do { \
+ register size_t _i_ = 0; \
+ while (_i_ < n) \
+ FNVPART(h, ((unsigned char*)s)[_i_++]); \
+ } while (0)
+
+#if _typ_int64_t
+
+#ifdef _ast_LL
+
+#define FNV_INIT64 0xcbf29ce484222325LL
+#define FNV_MULT64 0x00000100000001b3LL
+
+#else
+
+#define FNV_INIT64 ((int64_t)0xcbf29ce484222325)
+#define FNV_MULT64 ((int64_t)0x00000100000001b3)
+
+#endif
+
+#define FNVINIT64(h) (h = FNV_INIT64)
+#define FNVPART64(h,c) (h = (h) * FNV_MULT64 ^ (c))
+#define FNVSUM64(h,s,n) do { \
+ register int _i_ = 0; \
+ while (_i_ < n) \
+ FNVPART64(h, ((unsigned char*)s)[_i_++]); \
+ } while (0)
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/fs3d.h b/usr/src/lib/libast/sparcv9/include/ast/fs3d.h
new file mode 100644
index 0000000000..a16099d7ae
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/fs3d.h
@@ -0,0 +1,120 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * 3d fs interface definitions
+ */
+
+#ifndef _FS3D_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FS3D_H
+
+#include <ast_fs.h>
+
+#if _int_st_spare1
+#define iview(p) ((p)->st_spare1)
+#define IVIEW(p,v) ((p)->st_spare1=(v))
+#else
+#if _ary_st_spare4
+#define iview(p) ((p)->st_spare4[0])
+#define IVIEW(p,v) ((p)->st_spare4[0]=(v))
+#else
+#if _ary_st_pad4
+#define iview(p) ((p)->st_pad4[0])
+#define IVIEW(p,v) ((p)->st_pad4[0]=(v))
+#else
+#if _mem_st_rdev_stat
+#define iview(p) ((S_ISBLK((p)->st_mode)||S_ISCHR((p)->st_mode))?0:(p)->st_rdev)
+#define IVIEW(p,v) do{if(!S_ISBLK((p)->st_mode)&&!S_ISCHR((p)->st_mode))(p)->st_rdev=(v);}while(0)
+#else
+#define iview(p) 0
+#define IVIEW(p,v)
+#endif
+#endif
+#endif
+#endif
+
+/*
+ * special options
+ */
+
+#define FS3D_init "/#option/init"
+#define FS3D_on "/#option/3d"
+#define FS3D_off "/#option/2d"
+
+/*
+ * fs3d(3) ops
+ */
+
+#define FS3D_OP(o,a) (((a)<<3)|(o))
+
+#define FS3D_INIT FS3D_OP_INIT /* re-initialize tables */
+#define FS3D_OFF FS3D_OP_OFF
+#define FS3D_ON FS3D_OP_ON
+#define FS3D_TEST FS3D_OP_TEST
+#define FS3D_LIMIT(n) FS3D_OP(FS3D_OP_LIMIT,n)
+
+#define FS3D_op(x) ((x)&07)
+#define FS3D_arg(x) (((x)>>3)&07777)
+
+#define FS3D_OP_OFF 0
+#define FS3D_OP_ON 1
+#define FS3D_OP_TEST 2
+#define FS3D_OP_LIMIT 3
+#define FS3D_OP_INIT 7
+
+/*
+ * mount(2) ops
+ */
+
+#define FS3D_ALL (FS3D_VIEW|FS3D_VERSION)
+#define FS3D_VIEW 002
+#define FS3D_VERSION 004
+#define FS3D_GET 010
+#define FS3D_SIZE(n) ((n)<<4)
+#define FS3D_SIZEOF(n) ((n)>>4)
+
+extern __MANGLE__ int mount __PROTO__((const char*, char*, int, __V_*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int fs3d __PROTO__((int));
+extern __MANGLE__ char* pathnext __PROTO__((char*, char*, long*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/fts.h b/usr/src/lib/libast/sparcv9/include/ast/fts.h
new file mode 100644
index 0000000000..081fe2a712
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/fts.h
@@ -0,0 +1,160 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * David Korn
+ * Phong Vo
+ * AT&T Research
+ *
+ * fts interface definitions
+ */
+
+#ifndef _FTS_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FTS_H
+
+#include <ls.h>
+
+/*
+ * fts_open flags
+ */
+
+#define FTS_LOGICAL 0 /* logical traversal, follow symlinks */
+#define FTS_META (1<<0) /* follow top dir symlinks even if phys */
+#define FTS_NOCHDIR (1<<1) /* don't chdir */
+#define FTS_NOPOSTORDER (1<<2) /* no postorder visits */
+#define FTS_NOPREORDER (1<<3) /* no preorder visits */
+#define FTS_NOSEEDOTDIR (1<<11) /* never retain leading . dir */
+#define FTS_NOSTAT (1<<4) /* don't stat children */
+#define FTS_ONEPATH (1<<5) /* pathnames arg is one const char* */
+#define FTS_PHYSICAL (1<<6) /* physical traversal, don't follow */
+#define FTS_SEEDOT (1<<7) /* return . and .. */
+#define FTS_SEEDOTDIR (1<<10) /* always retain leading . dir */
+#define FTS_TOP (1<<8) /* don't traverse subdirectories */
+#define FTS_XDEV (1<<9) /* don't cross mount points */
+
+#define FTS_USER (1<<12) /* first user flag bit */
+
+#define FTS_COMFOLLOW FTS_META
+
+/*
+ * fts_info flags
+ */
+
+#define FTS_DEFAULT 0 /* ok, someone must have wanted this */
+
+#define FTS_NS (1<<0) /* stat failed */
+#define FTS_F (1<<1) /* file - not directory or symbolic link*/
+#define FTS_SL (1<<2) /* symbolic link */
+#define FTS_D (1<<3) /* directory - pre-order visit */
+
+#define FTS_C (1<<4) /* causes cycle */
+#define FTS_ERR (1<<5) /* some other error */
+#define FTS_DD (1<<6) /* . or .. */
+#define FTS_NR (1<<7) /* cannot read */
+#define FTS_NX (1<<8) /* cannot search */
+#define FTS_OK (1<<9) /* no info but otherwise ok */
+#define FTS_P (1<<10) /* post-order visit */
+
+#define FTS_DC (FTS_D|FTS_C) /* dir - would cause cycle */
+#define FTS_DNR (FTS_D|FTS_NR) /* dir - no read permission */
+#define FTS_DNX (FTS_D|FTS_NX) /* dir - no search permission */
+#define FTS_DOT (FTS_D|FTS_DD) /* . or .. */
+#define FTS_DP (FTS_D|FTS_P) /* dir - post-order visit */
+#define FTS_NSOK (FTS_NS|FTS_OK) /* no stat (because you asked) */
+#define FTS_SLNONE (FTS_SL|FTS_NS) /* symlink - to nowhere */
+
+/*
+ * fts_set flags
+ */
+
+#define FTS_AGAIN FTS_TOP /* process entry again */
+#define FTS_FOLLOW FTS_META /* follow FTS_SL symlink */
+#define FTS_SKIP FTS_NOSTAT /* skip FTS_D directory */
+#define FTS_STAT FTS_PHYSICAL /* stat() done by user */
+
+typedef struct Fts FTS;
+typedef struct Ftsent FTSENT;
+
+struct Ftsent
+{
+ char* fts_accpath; /* path relative to . */
+ char* fts_name; /* file name */
+ char* fts_path; /* path relative to top dir */
+ FTSENT* fts_cycle; /* offender if cycle */
+ FTSENT* fts_link; /* next child */
+ FTSENT* fts_parent; /* parent directory */
+ struct stat* fts_statp; /* stat info */
+#ifdef _FTSENT_LOCAL_PRIVATE_
+ _FTSENT_LOCAL_PRIVATE_
+#else
+ __V_* fts_pointer; /* local pointer value */
+#endif
+ long fts_number; /* local numeric value */
+ int fts_errno; /* errno for this entry */
+ unsigned short fts_info; /* info flags */
+ unsigned short fts_namelen; /* strlen(fts_name) */
+ unsigned short fts_pathlen; /* strlen(fts_path) */
+ short fts_level; /* file tree depth, 0 at top */
+
+#ifdef _FTSENT_PRIVATE_
+ _FTSENT_PRIVATE_
+#endif
+
+};
+
+struct Fts
+{
+ int fts_errno; /* last errno */
+
+#ifdef _FTS_PRIVATE_
+ _FTS_PRIVATE_
+#endif
+
+};
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ FTSENT* fts_children __PROTO__((FTS*, int));
+extern __MANGLE__ int fts_close __PROTO__((FTS*));
+extern __MANGLE__ int fts_flags __PROTO__((void));
+extern __MANGLE__ int fts_notify __PROTO__((int(*)(FTS*, FTSENT*, __V_*), __V_*));
+extern __MANGLE__ FTS* fts_open __PROTO__((char* const*, int, int(*)(FTSENT* const*, FTSENT* const*)));
+extern __MANGLE__ FTSENT* fts_read __PROTO__((FTS*));
+extern __MANGLE__ int fts_set __PROTO__((FTS*, FTSENT*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ftw.h b/usr/src/lib/libast/sparcv9/include/ast/ftw.h
new file mode 100644
index 0000000000..bd39851cbc
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ftw.h
@@ -0,0 +1,71 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * ftw,nftw over ftwalk
+ */
+
+#ifndef _FTW_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FTW_H
+
+#define FTW FTWALK
+#include <ftwalk.h>
+#undef FTW
+
+#define FTW_SLN (FTW_SL|FTW_NR)
+
+#define FTW_PHYS (FTW_PHYSICAL)
+#define FTW_CHDIR (FTW_DOT)
+#define FTW_DEPTH (FTW_POST)
+#define FTW_OPEN (0)
+
+struct FTW
+{
+ int quit;
+ int base;
+ int level;
+};
+
+#define FTW_SKD FTW_SKIP
+#define FTW_PRUNE FTW_SKIP
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int ftw __PROTO__((const char*, int(*)(const char*, const struct stat*, int), int));
+extern __MANGLE__ int nftw __PROTO__((const char*, int(*)(const char*, const struct stat*, int, struct FTW*), int, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ftwalk.h b/usr/src/lib/libast/sparcv9/include/ast/ftwalk.h
new file mode 100644
index 0000000000..1ee713a37a
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ftwalk.h
@@ -0,0 +1,137 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Phong Vo
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * ast ftwalk interface definitions
+ * ftwalk was the initial improvement on ftw and nftw
+ * which formed the basis for the POSIX fts proposal
+ *
+ * NOTE: this file is in cahoots with the fts implementation
+ */
+
+#ifndef _FTWALK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _FTWALK_H
+
+#define fts_info info
+#define fts_level level
+#define fts_link link
+#define fts_name name
+#define fts_namelen namelen
+#define fts_parent parent
+#define fts_path path
+#define fts_pathlen pathlen
+
+#define FTSENT Ftw_t /* <fts.h> internal */
+#define Ftsent FTW /* <fts.h> internal */
+
+#define _FTSENT_LOCAL_PRIVATE_ /* <fts.h> internal */ \
+ union \
+ { \
+ long number; /* local numeric value */ \
+ __V_* pointer; /* local pointer value */ \
+ } local;
+
+#define _FTSENT_PRIVATE_ /* fts internal */ \
+ short status; /* internal status */ \
+ struct stat statb; /* fts_statp data */
+
+#include <fts.h>
+
+/*
+ * ftwalk() argument flags
+ */
+
+#define FTW_CANON FTS_CANON
+#define FTW_CHILDREN (FTS_USER<<0)
+#define FTW_DELAY FTS_NOSTAT
+#define FTW_DOT FTS_NOCHDIR
+#define FTW_META FTS_META
+#define FTW_MOUNT FTS_XDEV
+#define FTW_MULTIPLE FTS_ONEPATH
+#define FTW_NOSEEDOTDIR FTS_NOSEEDOTDIR
+#define FTW_PHYSICAL FTS_PHYSICAL
+#define FTW_POST (FTS_USER<<1)
+#define FTW_SEEDOTDIR FTS_SEEDOTDIR
+#define FTW_TOP FTS_TOP
+#define FTW_TWICE (FTS_USER<<2)
+#define FTW_USER (FTS_USER<<3)
+
+/*
+ * Ftw_t.info type bits
+ */
+
+#define FTW_C FTS_C
+#define FTW_D FTS_D
+#define FTW_DC FTS_DC
+#define FTW_DNR FTS_DNR
+#define FTW_DNX FTS_DNX
+#define FTW_DP FTS_DP
+#define FTW_F FTS_F
+#define FTW_NR FTS_NR
+#define FTW_NS FTS_NS
+#define FTW_NSOK FTS_NSOK
+#define FTW_NX FTS_NX
+#define FTW_P FTS_P
+#define FTW_SL FTS_SL
+
+/*
+ * Ftw_t.status entry values
+ */
+
+#define FTW_NAME FTS_DOT /* access by Ftw_t.name */
+#define FTW_PATH FTS_NOCHDIR /* access by Ftw_t.path */
+
+/*
+ * Ftw_t.status return values
+ */
+
+#define FTW_AGAIN FTS_AGAIN
+#define FTW_FOLLOW FTS_FOLLOW
+#define FTW_NOPOST FTS_NOPOSTORDER
+#define FTW_SKIP FTS_SKIP
+#define FTW_STAT FTS_STAT
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int ftwalk __PROTO__((const char*, int(*)(Ftw_t*), int, int(*)(Ftw_t*, Ftw_t*)));
+extern __MANGLE__ int ftwflags __PROTO__((void));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/getopt.h b/usr/src/lib/libast/sparcv9/include/ast/getopt.h
new file mode 100644
index 0000000000..01348b6402
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/getopt.h
@@ -0,0 +1,31 @@
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+#include <ast_getopt.h>
+
+#if !defined(_GETOPT_H) && !defined(_AST_STD_I)
+
+#define _GETOPT_H 1
+
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+struct option
+{
+ const char* name;
+ int has_arg;
+ int* flag;
+ int val;
+};
+
+extern __MANGLE__ int getopt_long __PROTO__((int, char* const*, const char*, const struct option*, int*));
+extern __MANGLE__ int getopt_long_only __PROTO__((int, char* const*, const char*, const struct option*, int*));
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/glob.h b/usr/src/lib/libast/sparcv9/include/ast/glob.h
new file mode 100644
index 0000000000..e02733177d
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/glob.h
@@ -0,0 +1,155 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * posix glob interface definitions with gnu extensions
+ */
+
+#ifndef _GLOB_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _GLOB_H
+
+#define GLOB_VERSION 20060717L
+
+#include <stdlib.h>
+
+struct dirent;
+struct stat;
+
+struct _glob_;
+struct _globlist_;
+
+typedef struct _glob_ glob_t;
+typedef struct _globlist_ globlist_t;
+
+struct _globlist_
+{
+ globlist_t* gl_next;
+ char* gl_begin;
+ unsigned char gl_flags;
+ char gl_path[1];
+};
+
+struct _glob_
+{
+ size_t gl_pathc;
+ char** gl_pathv;
+ size_t gl_offs;
+ globlist_t* gl_list;
+ int gl_flags;
+
+ /* GLOB_DISC data -- memset(&gl,0,sizeof(gl)) before using! */
+
+ const char* gl_fignore;
+ const char* gl_suffix;
+ unsigned char* gl_intr;
+
+ int gl_delim;
+
+ __V_* gl_handle;
+ __V_* (*gl_diropen) __PROTO__((glob_t*, const char*));
+ char* (*gl_dirnext) __PROTO__((glob_t*, __V_*));
+ void (*gl_dirclose) __PROTO__((glob_t*, __V_*));
+ int (*gl_type) __PROTO__((glob_t*, const char*));
+ int (*gl_attr) __PROTO__((glob_t*, const char*));
+
+ /* gnu extensions -- but how do you synthesize dirent and stat? */
+
+ __V_* (*gl_opendir) __PROTO__((const char*));
+ struct dirent* (*gl_readdir) __PROTO__((__V_*));
+ void (*gl_closedir) __PROTO__((__V_*));
+ int (*gl_stat) __PROTO__((const char*, struct stat*));
+ int (*gl_lstat) __PROTO__((const char*, struct stat*));
+
+ /* ast additions */
+
+ char* (*gl_nextdir) __PROTO__((glob_t*, char*));
+ unsigned long gl_status;
+ unsigned long gl_version;
+ unsigned short gl_extra;
+
+#ifdef _GLOB_PRIVATE_
+ _GLOB_PRIVATE_
+#else
+ char* gl_pad[23];
+#endif
+
+};
+
+/* standard interface */
+#define GLOB_APPEND 0x0001 /* append to previous */
+#define GLOB_DOOFFS 0x0002 /* gl_offs defines argv offset */
+#define GLOB_ERR 0x0004 /* abort on error */
+#define GLOB_MARK 0x0008 /* append / to directories */
+#define GLOB_NOCHECK 0x0010 /* nomatch is original pattern */
+#define GLOB_NOESCAPE 0x0020 /* don't treat \ specially */
+#define GLOB_NOSORT 0x0040 /* don't sort the list */
+
+/* extended interface */
+#define GLOB_STARSTAR 0x0080 /* enable [/]**[/] expansion */
+#define GLOB_BRACE 0x0100 /* enable {...} expansion */
+#define GLOB_ICASE 0x0200 /* ignore case on match */
+#define GLOB_COMPLETE 0x0400 /* shell file completeion */
+#define GLOB_AUGMENTED 0x0800 /* augmented shell patterns */
+#define GLOB_STACK 0x1000 /* allocate on current stack */
+#define GLOB_LIST 0x2000 /* just create gl_list */
+#define GLOB_ALTDIRFUNC 0x4000 /* gnu discipline functions */
+#define GLOB_DISC 0x8000 /* discipline initialized */
+
+/* gl_status */
+#define GLOB_NOTDIR 0x0001 /* last gl_dirnext() not a dir */
+
+/* gl_type return */
+#define GLOB_NOTFOUND 0 /* does not exist */
+#define GLOB_DEV 1 /* exists but not DIR EXE REG */
+#define GLOB_DIR 2 /* directory */
+#define GLOB_EXE 3 /* executable regular file */
+#define GLOB_REG 4 /* regular file */
+
+/* error return values */
+#define GLOB_ABORTED 1
+#define GLOB_NOMATCH 2
+#define GLOB_NOSPACE 3
+#define GLOB_INTR 4
+#define GLOB_APPERR 5
+#define GLOB_NOSYS 6
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int glob __PROTO__((const char*, int, int(*)(const char*,int), glob_t*));
+extern __MANGLE__ void globfree __PROTO__((glob_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif /* _GLOB_H */
diff --git a/usr/src/lib/libast/sparcv9/include/ast/hash.h b/usr/src/lib/libast/sparcv9/include/ast/hash.h
new file mode 100644
index 0000000000..4050612983
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/hash.h
@@ -0,0 +1,213 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * hash table library interface definitions
+ *
+ * NOTE: new code should use the more general <cdt.h>
+ */
+
+#ifndef _HASH_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _HASH_H
+
+#define HASH_ALLOCATE (1L<<0) /* allocate new key names */
+#define HASH_FIXED (1L<<1) /* fixed table size */
+#define HASH_HASHED (1L<<6) /* key names already hashed */
+#define HASH_RESIZE (1L<<2) /* table has been resized */
+#define HASH_SCANNING (1L<<3) /* currently scanning scope */
+#define HASH_SCOPE (1L<<4) /* push scope / create in bot */
+#define HASH_STATIC (1L<<5) /* static table allocation */
+
+#define HASH_CREATE (1L<<8) /* create bucket if not found */
+#define HASH_DELETE (1L<<9) /* delete bucket if found */
+#define HASH_LOOKUP 0 /* default op */
+#define HASH_RENAME (1L<<7) /* rename bucket if found */
+
+#define HASH_BUCKET (1L<<11) /* name is installed bucket */
+#define HASH_INSTALL (1L<<12) /* install allocated bucket */
+#define HASH_NOSCOPE (1L<<13) /* top scope only */
+#define HASH_OPAQUE (1L<<14) /* opaque bucket */
+#define HASH_VALUE (1L<<15) /* value bucket field used */
+
+#define HASH_SIZE(n) (((long)(n))<<16) /* fixed bucket size */
+#define HASH_SIZEOF(f) ((((long)(f))>>16)&0xffff) /* extract size */
+
+#define HASH_DELETED ((unsigned long)1<<(8*sizeof(int)-1)) /* deleted placeholder */
+#define HASH_KEEP (1L<<(8*sizeof(int)-2)) /* no free on bucket */
+#define HASH_HIDDEN (1L<<(8*sizeof(int)-3)) /* hidden by scope */
+#define HASH_HIDES (1L<<(8*sizeof(int)-4)) /* hides lower scope */
+#define HASH_OPAQUED (1L<<(8*sizeof(int)-5)) /* opaqued placeholder */
+#define HASH_FREENAME (1L<<(8*sizeof(int)-6)) /* free bucket name */
+
+#define HASH_RESET (HASH_RESIZE|HASH_SCOPE|HASH_STATIC|HASH_VALUE)
+#define HASH_INTERNAL (HASH_BUCKET|HASH_RESIZE|HASH_SCANNING|HASH_STATIC)
+#define HASH_FLAGS (HASH_DELETED|HASH_FREENAME|HASH_HIDDEN|HASH_HIDES|HASH_KEEP|HASH_OPAQUED)
+
+#define HASH_alloc 1
+#define HASH_clear 2
+#define HASH_compare 3
+#define HASH_free 4
+#define HASH_hash 5
+#define HASH_meanchain 6
+#define HASH_name 7
+#define HASH_namesize 8
+#define HASH_set 9
+#define HASH_size 10
+#define HASH_table 11
+#define HASH_va_list 12
+
+#define HASH_bucketsize 13
+
+#define HASH_region 14
+
+#include <hashpart.h>
+
+#define hashclear(t,f) ((t)->flags &= ~((f) & ~HASH_INTERNAL))
+#define hashcover(b) (((b)->hash&HASH_HIDES)?(Hash_bucket_t*)((b)->name):(Hash_bucket_t*)0)
+#define hashdel(t,n) hashlook(t, (char*)(n), HASH_DELETE, (char*)0)
+#define hashget(t,n) hashlook(t, (char*)(n), HASH_LOOKUP|HASH_VALUE, (char*)0)
+#define hashgetbucket(s) ((Hash_bucket_t*)((s)-((sizeof(Hash_bucket_t)+sizeof(char*)-1)/sizeof(char*))*sizeof(char*)))
+#define hashkeep(b) ((b)->hash|=HASH_KEEP)
+#define hashname(b) ((((b)->hash&HASH_HIDES)?((Hash_bucket_t*)((b)->name)):(b))->name)
+#define hashput(t,n,v) hashlook(t, (char*)(n), HASH_CREATE|HASH_VALUE, (char*)(v))
+#define hashref(t,n) hashlook(t, (char*)(n), HASH_LOOKUP|HASH_INTERNAL|HASH_VALUE, (char*)0)
+#define hashscope(t) ((t)->scope)
+#define hashset(t,f) ((t)->flags |= ((f) & ~HASH_INTERNAL))
+
+/*
+ * DEPRECATED renames for compatibility
+ */
+
+#define Hashbin_t Hash_bucket_t
+#define HASHBUCKET Hash_bucket_t
+#define Hashhdr_t Hash_header_t
+#define HASHHEADER Hash_header_t
+#define Hashpos_t Hash_position_t
+#define HASHPOSITION Hash_position_t
+#define Hashtab_t Hash_table_t
+#define HASHTABLE Hash_table_t
+
+#define vhashalloc hashvalloc
+#define hashvalloc(t,a) hashalloc(t,HASH_va_list,a,0)
+
+/*
+ * the #define's avoid union tags
+ */
+
+typedef struct Hash_bucket Hash_bucket_t;
+typedef struct Hash_root Hash_root_t;
+typedef struct Hash_table Hash_table_t;
+
+#define HASH_HEADER /* common bucket header */ \
+ Hash_bucket_t* next; /* next in collision chain */ \
+ unsigned int hash; /* hash flags and value */ \
+ char* name /* key name */
+
+#define HASH_DEFAULT /* HASH_VALUE bucket elements */ \
+ char* value /* key value */
+
+typedef struct /* bucket header */
+{
+ HASH_HEADER;
+} Hash_header_t;
+
+struct Hash_bucket /* prototype bucket */
+{
+ HASH_HEADER;
+ HASH_DEFAULT;
+};
+
+typedef struct /* hash scan bucket position */
+{
+ Hash_bucket_t* bucket; /* bucket */
+#ifdef _HASH_POSITION_PRIVATE_
+ _HASH_POSITION_PRIVATE_
+#endif
+} Hash_position_t;
+
+typedef struct /* last lookup cache */
+{
+ Hash_table_t* table; /* last lookup table */
+ Hash_bucket_t* bucket; /* last lookup bucket */
+#ifdef _HASH_LAST_PRIVATE_
+ _HASH_LAST_PRIVATE_
+#endif
+} Hash_last_t;
+
+struct Hash_root /* root hash table information */
+{
+ int accesses; /* number of accesses */
+ int collisions; /* number of collisions */
+ int flags; /* flags: see HASH_[A-Z]* */
+ Hash_last_t last; /* last lookup cache */
+ __V_* context; /* user defined context */
+#ifdef _HASH_ROOT_PRIVATE_
+ _HASH_ROOT_PRIVATE_
+#endif
+};
+
+struct Hash_table /* hash table information */
+{
+ Hash_root_t* root; /* root hash table information */
+ int size; /* table size */
+ int buckets; /* active bucket count */
+ char* name; /* table name */
+ Hash_table_t* scope; /* scope covered table */
+ short flags; /* flags: see HASH_[A-Z]* */
+#ifdef _HASH_TABLE_PRIVATE_
+ _HASH_TABLE_PRIVATE_
+#endif
+};
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Hash_table_t* hashalloc __PROTO__((Hash_table_t*, ...));
+extern __MANGLE__ void hashdone __PROTO__((Hash_position_t*));
+extern __MANGLE__ void hashdump __PROTO__((Hash_table_t*, int));
+extern __MANGLE__ Hash_table_t* hashfree __PROTO__((Hash_table_t*));
+extern __MANGLE__ Hash_bucket_t* hashlast __PROTO__((Hash_table_t*));
+extern __MANGLE__ char* hashlook __PROTO__((Hash_table_t*, const char*, long, const char*));
+extern __MANGLE__ Hash_bucket_t* hashnext __PROTO__((Hash_position_t*));
+extern __MANGLE__ Hash_position_t* hashscan __PROTO__((Hash_table_t*, int));
+extern __MANGLE__ void hashsize __PROTO__((Hash_table_t*, int));
+extern __MANGLE__ Hash_table_t* hashview __PROTO__((Hash_table_t*, Hash_table_t*));
+extern __MANGLE__ int hashwalk __PROTO__((Hash_table_t*, int, int (*)(const char*, char*, __V_*), __V_*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/hashkey.h b/usr/src/lib/libast/sparcv9/include/ast/hashkey.h
new file mode 100644
index 0000000000..1ce051ff26
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/hashkey.h
@@ -0,0 +1,73 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * 1-6 char lower-case keyword -> long hash
+ * digit args passed as HASHKEYN('2')
+ */
+
+#ifndef _HASHKEY_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _HASHKEY_H
+
+#define HASHKEYMAX 6
+#define HASHKEYBIT 5
+#define HASHKEYOFF ('a'-1)
+#define HASHKEYPART(h,c) (((h)<<HASHKEYBIT)+HASHKEY1(c))
+
+#define HASHKEYN(n) ((n)-'0'+'z'+1)
+
+#define HASHKEY1(c1) ((c1)-HASHKEYOFF)
+#define HASHKEY2(c1,c2) HASHKEYPART(HASHKEY1(c1),c2)
+#define HASHKEY3(c1,c2,c3) HASHKEYPART(HASHKEY2(c1,c2),c3)
+#define HASHKEY4(c1,c2,c3,c4) HASHKEYPART(HASHKEY3(c1,c2,c3),c4)
+#define HASHKEY5(c1,c2,c3,c4,c5) HASHKEYPART(HASHKEY4(c1,c2,c3,c4),c5)
+#define HASHKEY6(c1,c2,c3,c4,c5,c6) HASHKEYPART(HASHKEY5(c1,c2,c3,c4,c5),c6)
+
+#define HASHNKEY1(n,c1) HASHKEY2((n)+HASHKEYOFF,c1)
+#define HASHNKEY2(n,c2,c1) HASHKEY3((n)+HASHKEYOFF,c2,c1)
+#define HASHNKEY3(n,c3,c2,c1) HASHKEY4((n)+HASHKEYOFF,c3,c2,c1)
+#define HASHNKEY4(n,c4,c3,c2,c1) HASHKEY5((n)+'a',c4,c3,c2,c1)
+#define HASHNKEY5(n,c5,c4,c3,c2,c1) HASHKEY6((n)+'a',c5,c4,c3,c2,c1)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ long strkey __PROTO__((const char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/hashpart.h b/usr/src/lib/libast/sparcv9/include/ast/hashpart.h
new file mode 100644
index 0000000000..b2aa79649a
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/hashpart.h
@@ -0,0 +1,60 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * K. P. Vo
+ * G. S. Fowler
+ * AT&T Research
+ *
+ * ``the best'' combined linear congruent checksum/hash/PRNG
+ */
+
+#ifndef _HASHPART_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _HASHPART_H
+
+#define HASH_ADD(h) (0x9c39c33dL)
+
+#if __sparc__ || __sparc || sparc
+
+#define HASH_A(h,n) ((((h) << 2) - (h)) << (n))
+#define HASH_B(h,n) ((((h) << 4) - (h)) << (n))
+#define HASH_C(h,n) ((HASH_A(h,7) + HASH_B(h,0)) << (n))
+#define HASH_MPY(h) (HASH_C(h,22)+HASH_C(h,10)+HASH_A(h,6)+HASH_A(h,3)+(h))
+
+#else
+
+#define HASH_MPY(h) ((h)*0x63c63cd9L)
+
+#endif
+
+#define HASHPART(h,c) (h = HASH_MPY(h) + HASH_ADD(h) + (c))
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/iconv.h b/usr/src/lib/libast/sparcv9/include/ast/iconv.h
new file mode 100644
index 0000000000..e63b3f0fcd
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/iconv.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_iconv.h>
diff --git a/usr/src/lib/libast/sparcv9/include/ast/lc.h b/usr/src/lib/libast/sparcv9/include/ast/lc.h
new file mode 100644
index 0000000000..fdd804f36e
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/lc.h
@@ -0,0 +1,158 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated by ./lcgen : : */
+
+
+#ifndef _LC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _LC_H 1
+
+#include <ast.h>
+
+#define LC_abbreviated 0x00001
+#define LC_checked 0x00002
+#define LC_default 0x00004
+#define LC_defined 0x00008
+#define LC_debug 0x00010
+#define LC_local 0x00020
+#define LC_primary 0x00040
+#define LC_qualified 0x00080
+#define LC_undefined 0x00100
+#define LC_verbose 0x00200
+#define LC_user 0x10000
+#define LC_language_attribute_max 2
+#define LC_territory_language_max 4
+
+struct Lc_s;
+
+typedef struct Lc_info_s
+{
+ const struct Lc_s* lc;
+ unsigned long number;
+ __V_* data;
+} Lc_info_t;
+
+typedef struct Lc_attribute_s
+{
+ const char* name;
+ unsigned long flags;
+ unsigned long index;
+} Lc_attribute_t;
+
+typedef struct Lc_charset_s
+{
+ const char* code;
+ const char* alternates;
+ const char* ms;
+ unsigned long index;
+} Lc_charset_t;
+
+typedef struct Lc_language_s
+{
+ const char* code;
+ const char* name;
+ const char* alternates;
+ const Lc_charset_t* charset;
+ unsigned long flags;
+ unsigned long index;
+ const Lc_attribute_t* attributes[LC_language_attribute_max];
+} Lc_language_t;
+
+typedef struct Lc_territory_s
+{
+ const char* code;
+ const char* name;
+ unsigned long flags;
+ unsigned long index;
+ const Lc_language_t* languages[LC_territory_language_max];
+#ifdef _LC_TERRITORY_PRIVATE_
+ _LC_TERRITORY_PRIVATE_
+#endif
+} Lc_territory_t;
+
+typedef struct Lc_map_s
+{
+ const char* code;
+ const Lc_language_t* language;
+ const Lc_territory_t* territory;
+ const Lc_charset_t* charset;
+ const Lc_attribute_t* attribute;
+} Lc_map_t;
+
+typedef struct Lc_attribute_list_s
+{
+ struct Lc_attribute_list_s* next;
+ const Lc_attribute_t* attribute;
+} Lc_attribute_list_t;
+
+typedef struct Lc_s
+{
+ const char* name;
+ const char* code;
+ const Lc_language_t* language;
+ const Lc_territory_t* territory;
+ const Lc_charset_t* charset;
+ const Lc_attribute_list_t* attributes;
+ unsigned long flags;
+ unsigned long index;
+#ifdef _LC_PRIVATE_
+ _LC_PRIVATE_
+#endif
+} Lc_t;
+
+struct Lc_category_s;
+
+typedef int (*Lc_category_set_f) __PROTO__((struct Lc_category_s*));
+
+typedef struct Lc_category_s
+{
+ const char* name;
+ int external;
+ int internal;
+ Lc_category_set_f setf;
+ Lc_t* prev;
+} Lc_category_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ size_t lccanon __PROTO__((Lc_t*, unsigned long flags, char*, size_t));
+extern __MANGLE__ Lc_category_t* lccategories __PROTO__((void));
+extern __MANGLE__ int lcindex __PROTO__((int, int));
+extern __MANGLE__ Lc_info_t* lcinfo __PROTO__((int));
+extern __MANGLE__ Lc_t* lcmake __PROTO__((const char*));
+extern __MANGLE__ Lc_t* lcscan __PROTO__((Lc_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/ls.h b/usr/src/lib/libast/sparcv9/include/ast/ls.h
new file mode 100644
index 0000000000..cce1771b3f
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/ls.h
@@ -0,0 +1,99 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * ls formatter interface definitions
+ */
+
+#ifndef _LS_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _LS_H
+
+#include <ast_std.h>
+#include <ast_fs.h>
+#include <ast_mode.h>
+
+/*
+ * some systems (could it beee AIX) pollute the std name space
+ */
+
+#undef fileid
+#define fileid fileID
+
+#define LS_BLOCKSIZE 512
+
+#define iblocks(p) _iblocks(p)
+
+#if _mem_st_rdev_stat
+#define idevice(p) ((p)->st_rdev)
+#define IDEVICE(p,v) ((p)->st_rdev=(v))
+#else
+#define idevice(p) 0
+#define IDEVICE(p,v)
+#endif
+
+#define LS_ATIME (1<<0) /* list st_atime */
+#define LS_BLOCKS (1<<1) /* list blocks used by file */
+#define LS_CTIME (1<<2) /* list st_ctime */
+#define LS_EXTERNAL (1<<3) /* st_mode is modex canonical */
+#define LS_INUMBER (1<<4) /* list st_ino */
+#define LS_LONG (1<<5) /* long listing */
+#define LS_MARK (1<<6) /* append file name marks */
+#define LS_NOGROUP (1<<7) /* omit group name for LS_LONG */
+#define LS_NOUSER (1<<8) /* omit user name for LS_LONG */
+#define LS_NUMBER (1<<9) /* number instead of name */
+
+#define LS_USER (1<<10) /* first user flag bit */
+
+#define LS_W_BLOCKS 6 /* LS_BLOCKS field width */
+#define LS_W_INUMBER 7 /* LS_INUMBER field width */
+#define LS_W_LONG 55 /* LS_LONG width (w/o names) */
+#define LS_W_LINK 4 /* link text width (w/o names) */
+#define LS_W_MARK 1 /* LS_MARK field width */
+#define LS_W_NAME 9 /* group|user name field width */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ off_t _iblocks __PROTO__((struct stat*));
+extern __MANGLE__ char* fmtdev __PROTO__((struct stat*));
+extern __MANGLE__ char* fmtfs __PROTO__((struct stat*));
+extern __MANGLE__ char* fmtls __PROTO__((char*, const char*, struct stat*, const char*, const char*, int));
+extern __MANGLE__ int pathstat __PROTO__((const char*, struct stat*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/magic.h b/usr/src/lib/libast/sparcv9/include/ast/magic.h
new file mode 100644
index 0000000000..f484f2b20d
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/magic.h
@@ -0,0 +1,96 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * magic interface definitions
+ */
+
+#ifndef _MAGIC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MAGIC_H
+
+#include <sfio.h>
+#include <ls.h>
+
+#define MAGIC_VERSION 19961031L
+
+#ifndef MAGIC_FILE
+#define MAGIC_FILE "lib/file/magic"
+#endif
+
+#ifndef MAGIC_DIR
+#define MAGIC_DIR "lib/file"
+#endif
+
+#define MAGIC_FILE_ENV "MAGICFILE"
+
+#define MAGIC_MIME (1<<0) /* magictype returns MIME type */
+#define MAGIC_VERBOSE (1<<1) /* verbose magic file errors */
+
+#define MAGIC_USER (1L<<16) /* first user flag bit */
+
+struct Magic_s;
+struct Magicdisc_s;
+
+typedef struct Magicdisc_s
+{
+ unsigned long version; /* interface version */
+ unsigned long flags; /* MAGIC_* flags */
+ Error_f errorf; /* error function */
+} Magicdisc_t;
+
+typedef struct Magic_s
+{
+ const char* id; /* library id string */
+
+#ifdef _MAGIC_PRIVATE_
+ _MAGIC_PRIVATE_
+#endif
+
+} Magic_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Magic_t* magicopen __PROTO__((Magicdisc_t*));
+extern __MANGLE__ int magicload __PROTO__((Magic_t*, const char*, unsigned long));
+extern __MANGLE__ int magiclist __PROTO__((Magic_t*, Sfio_t*));
+extern __MANGLE__ char* magictype __PROTO__((Magic_t*, Sfio_t*, const char*, struct stat*));
+extern __MANGLE__ int magicclose __PROTO__((Magic_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/magicid.h b/usr/src/lib/libast/sparcv9/include/ast/magicid.h
new file mode 100644
index 0000000000..ceadff2653
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/magicid.h
@@ -0,0 +1,55 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * generic binary magic id definitions
+ */
+
+#ifndef _MAGICID_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MAGICID_H 1
+
+#include <ast_common.h>
+
+#define MAGICID 0x00010203
+
+typedef uint32_t Magicid_data_t;
+
+typedef struct Magicid_s
+{
+ Magicid_data_t magic; /* magic number */
+ char name[8]; /* generic data/application name*/
+ char type[12]; /* specific data type */
+ Magicid_data_t version; /* YYYYMMDD or 0xWWXXYYZZ */
+ Magicid_data_t size;
+} Magicid_t;
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/mc.h b/usr/src/lib/libast/sparcv9/include/ast/mc.h
new file mode 100644
index 0000000000..4b55665b3b
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/mc.h
@@ -0,0 +1,107 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * machine independent binary message catalog interface
+ *
+ * file layout
+ * all numbers are sfputu() format
+ *
+ * 4 char magic (^M^S^G0)
+ * <method locale YYYY-MM-DD>\0
+ * (<optional strings>\0)*
+ * \0
+ * string table size
+ * #msgs total
+ * #max set number
+ * #set-id 1
+ * #msgs in set 1
+ * ...
+ * #set-id #sets
+ * #msgs in set #sets
+ * end of sets (0)
+ * msg(1,1) size
+ * ...
+ * msg(#sets,#msgs) size
+ * string table
+ */
+
+#ifndef _MC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MC_H
+
+#include <ast.h>
+
+#define MC_MAGIC "\015\023\007\000"
+#define MC_MAGIC_SIZE 4
+
+#define MC_SET_MAX 1023
+#define MC_NUM_MAX 32767
+
+#define MC_NLS (1<<10)
+
+#define MC_MESSAGE_SET(s) mcindex(s,NiL,NiL,NiL)
+
+typedef struct
+{
+ char** msg;
+ int num;
+ int gen;
+} Mcset_t;
+
+typedef struct
+{
+ Mcset_t* set;
+ int num;
+ int gen;
+ char* translation;
+#ifdef _MC_PRIVATE_
+ _MC_PRIVATE_
+#endif
+} Mc_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ char* mcfind __PROTO__((char*, const char*, const char*, int, int));
+extern __MANGLE__ Mc_t* mcopen __PROTO__((Sfio_t*));
+extern __MANGLE__ char* mcget __PROTO__((Mc_t*, int, int, const char*));
+extern __MANGLE__ int mcput __PROTO__((Mc_t*, int, int, const char*));
+extern __MANGLE__ int mcdump __PROTO__((Mc_t*, Sfio_t*));
+extern __MANGLE__ int mcindex __PROTO__((const char*, char**, int*, int*));
+extern __MANGLE__ int mcclose __PROTO__((Mc_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/mime.h b/usr/src/lib/libast/sparcv9/include/ast/mime.h
new file mode 100644
index 0000000000..b018b68c9a
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/mime.h
@@ -0,0 +1,102 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * mime/mailcap interface
+ */
+
+#ifndef _MIMETYPE_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MIMETYPE_H 1
+
+#include <sfio.h>
+#include <ls.h>
+
+#define MIME_VERSION 19970717L
+
+#ifndef MIME_FILES
+#define MIME_FILES "~/.mailcap:/usr/local/etc/mailcap:/usr/etc/mailcap:/etc/mailcap:/etc/mail/mailcap:/usr/public/lib/mailcap"
+#endif
+
+#define MIME_FILES_ENV "MAILCAP"
+
+#define MIME_LIST (1<<0) /* mimeload arg is : list */
+#define MIME_NOMAGIC (1<<1) /* no magic for mimetype() */
+#define MIME_PIPE (1<<2) /* mimeview() io is piped */
+#define MIME_REPLACE (1<<3) /* replace existing definition */
+
+#define MIME_USER (1L<<16) /* first user flag bit */
+
+struct Mime_s;
+typedef struct Mime_s Mime_t;
+
+struct Mimedisc_s;
+typedef struct Mimedisc_s Mimedisc_t;
+
+typedef int (*Mimevalue_f) __PROTO__((Mime_t*, __V_*, char*, size_t, Mimedisc_t*));
+
+struct Mimedisc_s
+{
+ unsigned long version; /* interface version */
+ unsigned long flags; /* MIME_* flags */
+ Error_f errorf; /* error function */
+ Mimevalue_f valuef; /* value extraction function */
+};
+
+struct Mime_s
+{
+ const char* id; /* library id string */
+
+#ifdef _MIME_PRIVATE_
+ _MIME_PRIVATE_
+#endif
+
+};
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Mime_t* mimeopen __PROTO__((Mimedisc_t*));
+extern __MANGLE__ int mimeload __PROTO__((Mime_t*, const char*, unsigned long));
+extern __MANGLE__ int mimelist __PROTO__((Mime_t*, Sfio_t*, const char*));
+extern __MANGLE__ int mimeclose __PROTO__((Mime_t*));
+extern __MANGLE__ int mimeset __PROTO__((Mime_t*, char*, unsigned long));
+extern __MANGLE__ char* mimetype __PROTO__((Mime_t*, Sfio_t*, const char*, struct stat*));
+extern __MANGLE__ char* mimeview __PROTO__((Mime_t*, const char*, const char*, const char*, const char*));
+extern __MANGLE__ int mimehead __PROTO__((Mime_t*, __V_*, size_t, size_t, char*));
+extern __MANGLE__ int mimecmp __PROTO__((const char*, const char*, char**));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/mnt.h b/usr/src/lib/libast/sparcv9/include/ast/mnt.h
new file mode 100644
index 0000000000..d877416642
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/mnt.h
@@ -0,0 +1,69 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * mounted filesystem scan interface
+ */
+
+#ifndef _MNT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MNT_H 1
+
+#undef MNT_REMOTE /* aix clash */
+#define MNT_REMOTE (1<<0) /* remote mount */
+
+typedef struct
+{
+ char* fs; /* filesystem name */
+ char* dir; /* mounted dir */
+ char* type; /* filesystem type */
+ char* options; /* options */
+ int freq; /* backup frequency */
+ int npass; /* number of parallel passes */
+ int flags; /* MNT_* flags */
+} Mnt_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ __V_* mntopen __PROTO__((const char*, const char*));
+extern __MANGLE__ Mnt_t* mntread __PROTO__((__V_*));
+extern __MANGLE__ int mntwrite __PROTO__((__V_*, const Mnt_t*));
+extern __MANGLE__ int mntclose __PROTO__((__V_*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/modecanon.h b/usr/src/lib/libast/sparcv9/include/ast/modecanon.h
new file mode 100644
index 0000000000..ce107238e3
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/modecanon.h
@@ -0,0 +1,74 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * canonical mode_t representation
+ */
+
+#ifndef _MODECANON_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MODECANON_H
+
+#define X_ITYPE(m) ((m)&X_IFMT)
+
+#define X_IFMT 0170000
+#define X_IFWHT 0160000
+#define X_IFDOOR 0150000
+#define X_IFSOCK 0140000
+#define X_IFLNK 0120000
+#define X_IFCTG 0110000
+#define X_IFREG 0100000
+#define X_IFBLK 0060000
+#define X_IFDIR 0040000
+#define X_IFCHR 0020000
+#define X_IFIFO 0010000
+
+#define X_IPERM 0007777
+#define X_ISUID 0004000
+#define X_ISGID 0002000
+#define X_ISVTX 0001000
+#define X_IRUSR 0000400
+#define X_IWUSR 0000200
+#define X_IXUSR 0000100
+#define X_IRGRP 0000040
+#define X_IWGRP 0000020
+#define X_IXGRP 0000010
+#define X_IROTH 0000004
+#define X_IWOTH 0000002
+#define X_IXOTH 0000001
+
+#define X_IRWXU (X_IRUSR|X_IWUSR|X_IXUSR)
+#define X_IRWXG (X_IRGRP|X_IWGRP|X_IXGRP)
+#define X_IRWXO (X_IROTH|X_IWOTH|X_IXOTH)
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/modex.h b/usr/src/lib/libast/sparcv9/include/ast/modex.h
new file mode 100644
index 0000000000..458ad18ac1
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/modex.h
@@ -0,0 +1,62 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * AT&T Research
+ *
+ * external mode_t representation support
+ */
+
+#ifndef _MODEX_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _MODEX_H
+
+#include <ast_fs.h>
+#include <modecanon.h>
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int modei __PROTO__((int));
+extern __MANGLE__ int modex __PROTO__((int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _S_IDPERM
+#define modei(m) ((m)&X_IPERM)
+#if _S_IDTYPE
+#define modex(m) (m)
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/namval.h b/usr/src/lib/libast/sparcv9/include/ast/namval.h
new file mode 100644
index 0000000000..d746970d58
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/namval.h
@@ -0,0 +1,51 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * common name-value struct support
+ */
+
+#ifndef _NAMVAL_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _NAMVAL_H
+
+typedef struct
+{
+ char* name;
+ int value;
+#ifdef _NAMVAL_PRIVATE_
+ _NAMVAL_PRIVATE_
+#endif
+} Namval_t;
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/nl_types.h b/usr/src/lib/libast/sparcv9/include/ast/nl_types.h
new file mode 100644
index 0000000000..db7383c626
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/nl_types.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_nl_types.h>
diff --git a/usr/src/lib/libast/sparcv9/include/ast/option.h b/usr/src/lib/libast/sparcv9/include/ast/option.h
new file mode 100644
index 0000000000..7204047891
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/option.h
@@ -0,0 +1,119 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * command line option parse interface
+ */
+
+#ifndef _OPTION_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _OPTION_H
+
+#include <ast.h>
+
+#define OPT_VERSION 20070319L
+
+#define OPT_USER (1L<<16) /* first user flag bit */
+
+struct Opt_s;
+struct Optdisc_s;
+
+typedef int (*Optinfo_f) __PROTO__((struct Opt_s*, Sfio_t*, const char*, struct Optdisc_s*));
+
+typedef struct Optdisc_s
+{
+ unsigned long version; /* OPT_VERSION */
+ unsigned long flags; /* OPT_* flags */
+ char* catalog; /* error catalog id */
+ Optinfo_f infof; /* runtime info function */
+} Optdisc_t;
+
+/* NOTE: Opt_t member order fixed by a previous binary release */
+
+#ifndef _OPT_PRIVATE_
+#define _OPT_PRIVATE_ \
+ char pad[3*sizeof(__V_*)];
+#endif
+
+typedef struct Opt_s
+{
+ int again; /* see optjoin() */
+ char* arg; /* {:,#} string argument */
+ char** argv; /* most recent argv */
+ int index; /* argv index */
+ char* msg; /* error/usage message buffer */
+ long num; /* OBSOLETE -- use number */
+ int offset; /* char offset in argv[index] */
+ char option[8]; /* current flag {-,+} + option */
+ char name[64]; /* current long name or flag */
+ Optdisc_t* disc; /* user discipline */
+ intmax_t number; /* # numeric argument */
+ unsigned char assignment; /* option arg assigment op */
+ unsigned char pads[sizeof(__V_*)-1];
+ _OPT_PRIVATE_
+} Opt_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Opt_t* _opt_infop_;
+
+#define opt_info (*_opt_infop_)
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define optinit(d,f) (memset(d,0,sizeof(*(d))),(d)->version=OPT_VERSION,(d)->infof=(f),opt_info.disc=(d))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int optget __PROTO__((char**, const char*));
+extern __MANGLE__ int optjoin __PROTO__((char**, ...));
+extern __MANGLE__ char* opthelp __PROTO__((const char*, const char*));
+extern __MANGLE__ char* optusage __PROTO__((const char*));
+extern __MANGLE__ int optstr __PROTO__((const char*, const char*));
+extern __MANGLE__ int optesc __PROTO__((Sfio_t*, const char*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/preroot.h b/usr/src/lib/libast/sparcv9/include/ast/preroot.h
new file mode 100644
index 0000000000..f9e45684f4
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/preroot.h
@@ -0,0 +1,27 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/preroot.sh by iffe version 2007-04-04 : : */
+#ifndef _def_preroot_ast
+#define _def_preroot_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* preroot not enabled */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/proc.h b/usr/src/lib/libast/sparcv9/include/ast/proc.h
new file mode 100644
index 0000000000..1196fc5b3f
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/proc.h
@@ -0,0 +1,113 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+
+/*
+ * process library interface
+ */
+
+#ifndef _PROC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _PROC_H
+
+#include <ast.h>
+
+#define PROC_ARGMOD (1<<0) /* argv[-1],argv[0] can be modified */
+#define PROC_BACKGROUND (1<<1) /* shell background (&) setup */
+#define PROC_CLEANUP (1<<2) /* close parent redirect fds on error */
+#define PROC_DAEMON (1<<3) /* daemon setup */
+#define PROC_ENVCLEAR (1<<4) /* clear environment */
+#define PROC_FOREGROUND (1<<14) /* system(3) setup */
+#define PROC_GID (1<<5) /* setgid(getgid()) */
+#define PROC_IGNORE (1<<6) /* ignore parent pipe errors */
+#define PROC_OVERLAY (1<<7) /* overlay current process if possible */
+#define PROC_PARANOID (1<<8) /* restrict everything */
+#define PROC_PRIVELEGED (1<<9) /* setuid(0), setgid(getegid()) */
+#define PROC_READ (1<<10) /* proc pipe fd 1 returned */
+#define PROC_SESSION (1<<11) /* session leader */
+#define PROC_UID (1<<12) /* setuid(getuid()) */
+#define PROC_WRITE (1<<13) /* proc pipe fd 0 returned */
+#define PROC_ZOMBIE (1<<15) /* proc may leave a zombie behind */
+
+#define PROC_ARG_BIT 14 /* bits per op arg */
+#define PROC_OP_BIT 4 /* bits per op */
+
+#define PROC_ARG_NULL ((1<<PROC_ARG_BIT)-1)
+
+#define PROC_fd_dup 0x4
+#define PROC_FD_CHILD 0x1
+#define PROC_FD_PARENT 0x2
+
+#define PROC_sig_dfl 0x8
+#define PROC_sig_ign 0x9
+
+#define PROC_sys_pgrp 0xa
+#define PROC_sys_umask 0xb
+
+#define PROC_op1(o,a) (((o)<<(2*PROC_ARG_BIT))|((a)&((PROC_ARG_NULL<<PROC_ARG_BIT)|PROC_ARG_NULL)))
+#define PROC_op2(o,a,b) (((o)<<(2*PROC_ARG_BIT))|(((b)&PROC_ARG_NULL)<<PROC_ARG_BIT)|((a)&PROC_ARG_NULL))
+
+#define PROC_FD_CLOSE(p,f) PROC_op2(PROC_fd_dup|(f),p,PROC_ARG_NULL)
+#define PROC_FD_DUP(p,c,f) PROC_op2(PROC_fd_dup|(f),p,c)
+#define PROC_SIG_DFL(s) PROC_op1(PROC_sig_dfl,s,0)
+#define PROC_SIG_IGN(s) PROC_op1(PROC_sig_ign,s,0)
+#define PROC_SYS_PGRP(g) PROC_op1(PROC_sys_pgrp,g)
+#define PROC_SYS_UMASK(m) PROC_op1(PROC_sys_umask,m,0)
+
+#define PROC_OP(x) (((x)>>(2*PROC_ARG_BIT))&((1<<PROC_OP_BIT)-1))
+#define PROC_ARG(x,n) ((n)?(((x)>>(((n)-1)*PROC_ARG_BIT))&PROC_ARG_NULL):(((x)&~((1<<(2*PROC_ARG_BIT))-1))==~((1<<(2*PROC_ARG_BIT))-1))?(-1):((x)&~((1<<(2*PROC_ARG_BIT))-1)))
+
+typedef struct
+{
+ pid_t pid; /* process id */
+ pid_t pgrp; /* process group id */
+ int rfd; /* read fd if applicable */
+ int wfd; /* write fd if applicable */
+
+#ifdef _PROC_PRIVATE_
+_PROC_PRIVATE_
+#endif
+
+} Proc_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int procclose __PROTO__((Proc_t*));
+extern __MANGLE__ int procfree __PROTO__((Proc_t*));
+extern __MANGLE__ Proc_t* procopen __PROTO__((const char*, char**, char**, long*, long));
+extern __MANGLE__ int procrun __PROTO__((const char*, char**));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/prototyped.h b/usr/src/lib/libast/sparcv9/include/ast/prototyped.h
new file mode 100644
index 0000000000..113fb94d24
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/prototyped.h
@@ -0,0 +1,59 @@
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/re_comp.h b/usr/src/lib/libast/sparcv9/include/ast/re_comp.h
new file mode 100644
index 0000000000..5da565e880
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/re_comp.h
@@ -0,0 +1,52 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * re_comp interface definitions
+ *
+ * OBSOLETE: use <regex.h>
+ */
+
+#ifndef _RE_COMP_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _RE_COMP_H
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ char* re_comp __PROTO__((const char*));
+extern __MANGLE__ int re_exec __PROTO__((const char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/recfmt.h b/usr/src/lib/libast/sparcv9/include/ast/recfmt.h
new file mode 100644
index 0000000000..1a66761ec2
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/recfmt.h
@@ -0,0 +1,94 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * record format interface
+ */
+
+#ifndef _RECFMT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _RECFMT_H 1
+
+#include <ast.h>
+
+typedef uint32_t Recfmt_t;
+
+#define REC_delimited 0
+#define REC_fixed 1
+#define REC_variable 2
+#define REC_method 14
+#define REC_none 15
+
+#define REC_M_path 0
+#define REC_M_data 1
+
+#define RECTYPE(f) (((f)>>28)&((1<<4)-1))
+
+#define REC_D_TYPE(d) ((REC_delimited<<28)|((d)&((1<<8)-1)))
+#define REC_D_DELIMITER(f) ((f)&((1<<8)-1))
+
+#define REC_F_TYPE(s) ((REC_fixed<<28)|((s)&((1<<28)-1)))
+#define REC_F_SIZE(f) ((f)&((1<<28)-1))
+
+#define REC_U_TYPE(t,a) (((t)<<28)|((a)&((1<<28)-1)))
+#define REC_U_ATTRIBUTES(f) ((f)&~((1<<28)-1))
+
+#define REC_V_TYPE(h,o,z,l,i) ((REC_variable<<28)|((h)<<23)|((o)<<19)|(((z)-1)<<18)|((l)<<17)|((i)<<16))
+#define REC_V_RECORD(f,s) (((f)&(((1<<16)-1)<<16))|(s))
+#define REC_V_HEADER(f) (((f)>>23)&((1<<5)-1))
+#define REC_V_OFFSET(f) (((f)>>19)&((1<<4)-1))
+#define REC_V_LENGTH(f) ((((f)>>18)&1)+1)
+#define REC_V_LITTLE(f) (((f)>>17)&1)
+#define REC_V_INCLUSIVE(f) (((f)>>16)&1)
+#define REC_V_SIZE(f) ((f)&((1<<16)-1))
+#define REC_V_ATTRIBUTES(f) ((f)&~((1<<16)-1))
+
+#define REC_M_TYPE(i) ((REC_method<<28)|(i))
+#define REC_M_INDEX(f) ((f)&((1<<28)-1))
+
+#define REC_N_TYPE() 0xffffffff
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ char* fmtrec __PROTO__((Recfmt_t, int));
+extern __MANGLE__ Recfmt_t recfmt __PROTO__((const __V_*, size_t, off_t));
+extern __MANGLE__ Recfmt_t recstr __PROTO__((const char*, char**));
+extern __MANGLE__ ssize_t reclen __PROTO__((Recfmt_t, const __V_*, size_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/regex.h b/usr/src/lib/libast/sparcv9/include/ast/regex.h
new file mode 100644
index 0000000000..b1a8976991
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/regex.h
@@ -0,0 +1,227 @@
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+#ifdef _AST_STD_I
+#define _REGEX_H -1
+#define regex_t int
+#define regmatch_t int
+#endif
+#ifndef _REGEX_H
+#define _REGEX_H 1
+#undef regex_t
+#undef regmatch_t
+
+#include <ast_common.h>
+
+#define REG_VERSION 20030916L
+
+/* regcomp flags */
+
+#define REG_AUGMENTED 0x00000001 /* enable ! & < > */
+#define REG_EXTENDED 0x00000002 /* enable ( | ) */
+#define REG_ICASE 0x00000004 /* ignore case in match */
+#define REG_NEWLINE 0x00000008 /* ^/$ match embedded \n */
+#define REG_NOSUB 0x00000010 /* don't report subexp matches */
+#define REG_SHELL 0x00000020 /* shell pattern syntax */
+
+/* nonstandard regcomp flags */
+
+#define REG_LEFT 0x00000100 /* implicit ^... */
+#define REG_LITERAL 0x00000200 /* no operators */
+#define REG_MINIMAL 0x00000400 /* minimal match */
+#define REG_NULL 0x00000800 /* allow null patterns */
+#define REG_RIGHT 0x00001000 /* implicit ...$ */
+#define REG_LENIENT 0x00002000 /* look the other way */
+#define REG_ESCAPE 0x00004000 /* \ escapes delimiter in [...] */
+#define REG_FIRST 0x00008000 /* first match found will do */
+#define REG_MULTIPLE 0x00010000 /* multiple \n sep patterns */
+#define REG_DISCIPLINE 0x00020000 /* regex_t.re_disc is valid */
+#define REG_SPAN 0x00040000 /* . matches \n */
+#define REG_COMMENT 0x00080000 /* ignore pattern space & #...\n*/
+#define REG_MULTIREF 0x00100000 /* multiple digit backrefs */
+#define REG_MUSTDELIM 0x08000000 /* all delimiters required */
+#define REG_DELIMITED 0x10000000 /* pattern[0] is delimiter */
+#define REG_SHELL_GROUP 0x20000000 /* (|&) inside [@|&](...) only */
+
+#define REG_SHELL_DOT 0x00200000 /* explicit leading . match */
+#define REG_SHELL_ESCAPED 0x00400000 /* \ not special */
+#define REG_SHELL_PATH 0x00800000 /* explicit / match */
+
+/* regexec flags */
+
+#define REG_NOTBOL 0x00000040 /* ^ is not a special char */
+#define REG_NOTEOL 0x00000080 /* $ is not a special char */
+
+/* nonstandard regexec flags */
+
+#define REG_INVERT 0x01000000 /* invert regrexec match sense */
+#define REG_STARTEND 0x02000000 /* subject==match[0].rm_{so,eo} */
+#define REG_ADVANCE 0x04000000 /* advance match[0].rm_{so,eo} */
+
+/* regalloc flags */
+
+#define REG_NOFREE 0x00000001 /* don't free */
+
+/* regsub flags */
+
+#define REG_SUB_ALL 0x00000001 /* substitute all occurrences */
+#define REG_SUB_LOWER 0x00000002 /* substitute to lower case */
+#define REG_SUB_UPPER 0x00000004 /* substitute to upper case */
+#define REG_SUB_PRINT 0x00000010 /* internal no-op */
+#define REG_SUB_NUMBER 0x00000020 /* internal no-op */
+#define REG_SUB_STOP 0x00000040 /* internal no-op */
+#define REG_SUB_WRITE 0x00000080 /* internal no-op */
+#define REG_SUB_LAST 0x00000100 /* last substitution option */
+#define REG_SUB_FULL 0x00000200 /* fully delimited */
+#define REG_SUB_USER 0x00001000 /* first user flag bit */
+
+/* regex error codes */
+
+#define REG_ENOSYS (-1) /* not supported */
+#define REG_NOMATCH 1 /* regexec didn't match */
+#define REG_BADPAT 2 /* invalid regular expression */
+#define REG_ECOLLATE 3 /* invalid collation element */
+#define REG_ECTYPE 4 /* invalid character class */
+#define REG_EESCAPE 5 /* trailing \ in pattern */
+#define REG_ESUBREG 6 /* invalid \digit backreference */
+#define REG_EBRACK 7 /* [...] imbalance */
+#define REG_EPAREN 8 /* \(...\) or (...) imbalance */
+#define REG_EBRACE 9 /* \{...\} or {...} imbalance */
+#define REG_BADBR 10 /* invalid {...} digits */
+#define REG_ERANGE 11 /* invalid [...] range endpoint */
+#define REG_ESPACE 12 /* out of space */
+#define REG_BADRPT 13 /* unary op not preceeded by re */
+#define REG_ENULL 14 /* empty subexpr in pattern */
+#define REG_ECOUNT 15 /* re component count overflow */
+#define REG_BADESC 16 /* invalid \char escape */
+#define REG_VERSIONID 17 /* version id (pseudo error) */
+#define REG_EFLAGS 18 /* flags conflict */
+#define REG_EDELIM 19 /* invalid or omitted delimiter */
+#define REG_PANIC 20 /* unrecoverable internal error */
+
+struct regex_s; typedef struct regex_s regex_t;
+struct regdisc_s; typedef struct regdisc_s regdisc_t;
+
+typedef int (*regclass_t) __PROTO__((int));
+typedef int32_t regflags_t;
+typedef int regoff_t;
+typedef int (*regerror_t) __PROTO__((const regex_t*, regdisc_t*, int, ...));
+typedef __V_* (*regcomp_t) __PROTO__((const regex_t*, const char*, size_t, regdisc_t*));
+typedef int (*regexec_t) __PROTO__((const regex_t*, __V_*, const char*, size_t, const char*, size_t, char**, regdisc_t*));
+typedef __V_* (*regresize_t) __PROTO__((__V_*, __V_*, size_t));
+typedef int (*regrecord_t) __PROTO__((__V_*, const char*, size_t));
+
+typedef struct regmatch_s
+{
+ regoff_t rm_so; /* offset of start */
+ regoff_t rm_eo; /* offset of end */
+} regmatch_t;
+
+typedef struct regsub_s
+{
+ regflags_t re_flags; /* regsubcomp() flags */
+ char* re_buf; /* regsubexec() output buffer */
+ size_t re_len; /* re_buf length */
+ int re_min; /* regsubcomp() min matches */
+#ifdef _REG_SUB_PRIVATE_
+ _REG_SUB_PRIVATE_
+#endif
+} regsub_t;
+
+struct regdisc_s
+{
+ unsigned long re_version; /* discipline version */
+ regflags_t re_flags; /* discipline flags */
+ regerror_t re_errorf; /* error function */
+ int re_errorlevel; /* errorf level */
+ regresize_t re_resizef; /* alloc/free function */
+ __V_* re_resizehandle;/* resizef handle */
+ regcomp_t re_compf; /* (?{...}) compile function */
+ regexec_t re_execf; /* (?{...}) execute function */
+ unsigned char* re_map; /* external to native ccode map */
+};
+
+typedef struct regstat_s
+{
+ regflags_t re_flags; /* REG_LEFT|REG_RIGHT */
+ ssize_t re_min; /* min anchored match length */
+ ssize_t re_max; /* max anchored match length */
+ ssize_t re_record; /* regrexec() match length */
+} regstat_t;
+
+struct regex_s
+{
+ size_t re_nsub; /* number of subexpressions */
+ struct reglib_s*re_info; /* library private info */
+ size_t re_npat; /* number of pattern chars used */
+ regdisc_t* re_disc; /* REG_DISCIPLINE discipline */
+ regsub_t* re_sub; /* regsubcomp() data */
+};
+
+#define reginit(disc) (memset(disc,0,sizeof(*(disc))),(disc)->re_version=REG_VERSION)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int regcomp __PROTO__((regex_t*, const char*, regflags_t));
+extern __MANGLE__ size_t regerror __PROTO__((int, const regex_t*, char*, size_t));
+extern __MANGLE__ int regexec __PROTO__((const regex_t*, const char*, size_t, regmatch_t*, regflags_t));
+extern __MANGLE__ void regfree __PROTO__((regex_t*));
+
+/* nonstandard hooks */
+
+#define _REG_cache 1 /* have regcache() */
+#define _REG_class 1 /* have regclass() */
+#define _REG_collate 1 /* have regcollate(), regclass() */
+#define _REG_comb 1 /* have regcomb() */
+#define _REG_decomp 1 /* have regdecomp() */
+#define _REG_dup 1 /* have regdup() */
+#define _REG_fatal 1 /* have regfatal(), regfatalpat() */
+#define _REG_ncomp 1 /* have regncomp() */
+#define _REG_nexec 1 /* have regnexec() */
+#define _REG_rexec 1 /* have regrexec(), regrecord() */
+#define _REG_stat 1 /* have regstat() */
+#define _REG_subcomp 1 /* have regsubcomp(), regsubexec() */
+
+extern __MANGLE__ regclass_t regclass __PROTO__((const char*, char**));
+extern __MANGLE__ int regaddclass __PROTO__((const char*, regclass_t));
+extern __MANGLE__ int regcollate __PROTO__((const char*, char**, char*, int));
+extern __MANGLE__ int regcomb __PROTO__((regex_t*, regex_t*));
+extern __MANGLE__ size_t regdecomp __PROTO__((regex_t*, regflags_t, char*, size_t));
+extern __MANGLE__ int regdup __PROTO__((regex_t*, regex_t*));
+extern __MANGLE__ int regncomp __PROTO__((regex_t*, const char*, size_t, regflags_t));
+extern __MANGLE__ int regnexec __PROTO__((const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t));
+extern __MANGLE__ void regfatal __PROTO__((regex_t*, int, int));
+extern __MANGLE__ void regfatalpat __PROTO__((regex_t*, int, int, const char*));
+extern __MANGLE__ int regrecord __PROTO__((const regex_t*));
+extern __MANGLE__ int regrexec __PROTO__((const regex_t*, const char*, size_t, size_t, regmatch_t*, regflags_t, int, __V_*, regrecord_t));
+extern __MANGLE__ regstat_t* regstat __PROTO__((const regex_t*));
+
+extern __MANGLE__ regex_t* regcache __PROTO__((const char*, regflags_t, int*));
+
+extern __MANGLE__ int regsubcomp __PROTO__((regex_t*, const char*, const regflags_t*, int, regflags_t));
+extern __MANGLE__ int regsubexec __PROTO__((const regex_t*, const char*, size_t, regmatch_t*));
+extern __MANGLE__ int regsubflags __PROTO__((regex_t*, const char*, char**, int, const regflags_t*, int*, regflags_t*));
+extern __MANGLE__ void regsubfree __PROTO__((regex_t*));
+
+/* obsolete hooks */
+
+#ifndef _SFIO_H
+struct _sfio_s;
+#endif
+
+extern __MANGLE__ void regalloc __PROTO__((__V_*, regresize_t, regflags_t));
+extern __MANGLE__ int regsub __PROTO__((const regex_t*, struct _sfio_s*, const char*, const char*, size_t, regmatch_t*, regflags_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/regexp.h b/usr/src/lib/libast/sparcv9/include/ast/regexp.h
new file mode 100644
index 0000000000..b7f3ed6313
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/regexp.h
@@ -0,0 +1,139 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * regexp interface and partial implementation
+ * what a novel approach
+ * don't do it again
+ *
+ * OBSOLETE: use <regex.h>
+ */
+
+#ifndef _REGEXP_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _REGEXP_H
+
+#define NBRA 9
+
+typedef struct
+{
+ char* re_braslist[NBRA];
+ char* re_braelist[NBRA];
+ char* re_loc1;
+ char* re_loc2;
+ char* re_locs;
+ int re_circf;
+ int re_nbra;
+ int re_nodelim;
+ int re_sed;
+} regexp_t;
+
+#define braslist _re_info.re_braslist
+#define braelist _re_info.re_braelist
+#define circf _re_info.re_circf
+#define loc1 _re_info.re_loc1
+#define loc2 _re_info.re_loc2
+#define locs _re_info.re_locs
+#define nbra _re_info.re_nbra
+#define nodelim _re_info.re_nodelim
+#define sed _re_info.re_sed
+
+#define advance(a,b) _re_exec(&_re_info,a,b,1)
+#define compile(a,b,c,d) _re_read(&_re_info,a,b,c,d)
+#define step(a,b) _re_exec(&_re_info,a,b,0)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _re_comp __PROTO__((regexp_t*, const char*, char*, unsigned int));
+extern __MANGLE__ int _re_exec __PROTO__((regexp_t*, const char*, const char*, int));
+extern __MANGLE__ char* _re_putc __PROTO__((int));
+extern __MANGLE__ char* _re_read __PROTO__((regexp_t*, const char*, char*, const char*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#ifndef _REGEXP_DECLARE
+
+regexp_t _re_info;
+
+char*
+_re_read __PARAM__((register regexp_t* re, const char* instring, char* ep, const char* endbuf, int seof), (re, instring, ep, endbuf, seof)) __OTORP__(register regexp_t* re; const char* instring; char* ep; const char* endbuf; int seof;){
+ register int c;
+
+ static const char* prev;
+
+#ifdef INIT
+ INIT;
+#endif
+
+ re->re_nodelim = 0;
+ if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0)
+ {
+ if (c != seof)
+ {
+ UNGETC(c);
+ re->re_nodelim = 1;
+ }
+ if (!re->re_sed && !prev)
+ { ERROR(41); }
+ RETURN((char*)endbuf);
+ }
+ UNGETC(c);
+ prev = 0;
+ for (;;)
+ {
+ if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0)
+ {
+ if (re->re_sed)
+ { ERROR(36); }
+ UNGETC(c);
+ re->re_nodelim = 1;
+ break;
+ }
+ if (c == '\\')
+ {
+ _re_putc(c);
+ if ((c = GETC()) == seof || c == '\n' || c == -1 || c == 0)
+ { ERROR(36); }
+ }
+ _re_putc(c);
+ }
+ if (c = _re_comp(re, _re_putc(0), ep, (char*)endbuf - ep))
+ { ERROR(c); }
+ prev = endbuf;
+ RETURN((char*)prev);
+}
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/sfdisc.h b/usr/src/lib/libast/sparcv9/include/ast/sfdisc.h
new file mode 100644
index 0000000000..9e657f045b
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/sfdisc.h
@@ -0,0 +1,82 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * AT&T Research
+ *
+ * sfio discipline interface definitions
+ */
+
+#ifndef _SFDISC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SFDISC_H
+
+#include <ast.h>
+
+#define SFDCEVENT(a,b,n) ((((a)-'A'+1)<<11)^(((b)-'A'+1)<<6)^(n))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#define SFSK_DISCARD SFDCEVENT('S','K',1)
+
+/*
+ * %(...) printf support
+ */
+
+typedef int (*Sf_key_lookup_t) __PROTO__((__V_*, Sffmt_t*, const char*, char**, Sflong_t*));
+typedef char* (*Sf_key_convert_t) __PROTO__((__V_*, Sffmt_t*, const char*, char*, Sflong_t));
+
+extern __MANGLE__ int sfkeyprintf __PROTO__((Sfio_t*, __V_*, const char*, Sf_key_lookup_t, Sf_key_convert_t));
+#define sfkeyprintf sfkeyprintf_20000308 /* Sffmt_t* callback args */
+extern __MANGLE__ int sfkeyprintf __PROTO__((Sfio_t*, __V_*, const char*, Sf_key_lookup_t, Sf_key_convert_t));
+
+/*
+ * pure sfio read and/or write disciplines
+ */
+
+extern __MANGLE__ int sfdcdio __PROTO__((Sfio_t*, size_t));
+extern __MANGLE__ int sfdcdos __PROTO__((Sfio_t*));
+extern __MANGLE__ int sfdcfilter __PROTO__((Sfio_t*, const char*));
+extern __MANGLE__ int sfdcmore __PROTO__((Sfio_t*, const char*, int, int));
+extern __MANGLE__ int sfdcprefix __PROTO__((Sfio_t*, const char*));
+extern __MANGLE__ int sfdcseekable __PROTO__((Sfio_t*));
+extern __MANGLE__ int sfdcslow __PROTO__((Sfio_t*));
+extern __MANGLE__ int sfdctee __PROTO__((Sfio_t*, Sfio_t*));
+extern __MANGLE__ int sfdcunion __PROTO__((Sfio_t*, Sfio_t**, int));
+
+extern __MANGLE__ Sfio_t* sfdcsubstream __PROTO__((Sfio_t*, Sfio_t*, Sfoff_t, Sfoff_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/sfio.h b/usr/src/lib/libast/sparcv9/include/ast/sfio.h
new file mode 100644
index 0000000000..9feba3043e
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/sfio.h
@@ -0,0 +1,452 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _SFIO_H
+#define _SFIO_H 1
+
+#define SFIO_VERSION 20050202L
+
+/* Public header file for the sfio library
+**
+** Written by Kiem-Phong Vo
+*/
+
+typedef struct _sfio_s Sfio_t;
+typedef struct _sfdisc_s Sfdisc_t;
+
+#if defined(_AST_STD_H) || defined(_PACKAGE_ast) && defined(_SFIO_PRIVATE)
+#include <ast_std.h>
+#else
+#include <ast_common.h>
+#endif /* _PACKAGE_ast */
+
+/* Sfoff_t should be large enough for largest file address */
+#define Sfoff_t intmax_t
+#define Sflong_t intmax_t
+#define Sfulong_t uintmax_t
+#define Sfdouble_t _ast_fltmax_t
+
+typedef ssize_t (*Sfread_f)_ARG_((Sfio_t*, Void_t*, size_t, Sfdisc_t*));
+typedef ssize_t (*Sfwrite_f)_ARG_((Sfio_t*, const Void_t*, size_t, Sfdisc_t*));
+typedef Sfoff_t (*Sfseek_f)_ARG_((Sfio_t*, Sfoff_t, int, Sfdisc_t*));
+typedef int (*Sfexcept_f)_ARG_((Sfio_t*, int, Void_t*, Sfdisc_t*));
+
+/* discipline structure */
+struct _sfdisc_s
+{ Sfread_f readf; /* read function */
+ Sfwrite_f writef; /* write function */
+ Sfseek_f seekf; /* seek function */
+ Sfexcept_f exceptf; /* to handle exceptions */
+ Sfdisc_t* disc; /* the continuing discipline */
+};
+
+#include <sfio_s.h>
+
+/* formatting environment */
+typedef struct _sffmt_s Sffmt_t;
+typedef int (*Sffmtext_f)_ARG_((Sfio_t*, Void_t*, Sffmt_t*));
+typedef int (*Sffmtevent_f)_ARG_((Sfio_t*, int, Void_t*, Sffmt_t*));
+struct _sffmt_s
+{ long version;/* version of this structure */
+ Sffmtext_f extf; /* function to process arguments */
+ Sffmtevent_f eventf; /* process events */
+
+ char* form; /* format string to stack */
+ va_list args; /* corresponding arg list */
+
+ int fmt; /* format character */
+ ssize_t size; /* object size */
+ int flags; /* formatting flags */
+ int width; /* width of field */
+ int precis; /* precision required */
+ int base; /* conversion base */
+
+ char* t_str; /* type string */
+ ssize_t n_str; /* length of t_str */
+
+ Void_t* mbs; /* multibyte state for format string */
+
+ Void_t* none; /* unused for now */
+};
+#define sffmtversion(fe,type) \
+ ((type) ? ((fe)->version = SFIO_VERSION) : (fe)->version)
+
+#define SFFMT_SSHORT 000000010 /* 'hh' flag, char */
+#define SFFMT_TFLAG 000000020 /* 't' flag, ptrdiff_t */
+#define SFFMT_ZFLAG 000000040 /* 'z' flag, size_t */
+
+#define SFFMT_LEFT 000000100 /* left-justification */
+#define SFFMT_SIGN 000000200 /* must have a sign */
+#define SFFMT_BLANK 000000400 /* if not signed, prepend a blank */
+#define SFFMT_ZERO 000001000 /* zero-padding on the left */
+#define SFFMT_ALTER 000002000 /* alternate formatting */
+#define SFFMT_THOUSAND 000004000 /* thousand grouping */
+#define SFFMT_SKIP 000010000 /* skip assignment in scanf() */
+#define SFFMT_SHORT 000020000 /* 'h' flag */
+#define SFFMT_LONG 000040000 /* 'l' flag */
+#define SFFMT_LLONG 000100000 /* 'll' flag */
+#define SFFMT_LDOUBLE 000200000 /* 'L' flag */
+#define SFFMT_VALUE 000400000 /* value is returned */
+#define SFFMT_ARGPOS 001000000 /* getting arg for $ patterns */
+#define SFFMT_IFLAG 002000000 /* 'I' flag */
+#define SFFMT_JFLAG 004000000 /* 'j' flag, intmax_t */
+#define SFFMT_CENTER 010000000 /* '=' flag, center justification */
+#define SFFMT_SET 017777770 /* flags settable on calling extf */
+
+/* for sfmutex() call */
+#define SFMTX_LOCK 0 /* up mutex count */
+#define SFMTX_TRYLOCK 1 /* try to up mutex count */
+#define SFMTX_UNLOCK 2 /* down mutex count */
+#define SFMTX_CLRLOCK 3 /* clear mutex count */
+
+/* various constants */
+#ifndef NULL
+#define NULL 0
+#endif
+#ifndef EOF
+#define EOF (-1)
+#endif
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+/* bits for various types of files */
+#define SF_READ 0000001 /* open for reading */
+#define SF_WRITE 0000002 /* open for writing */
+#define SF_STRING 0000004 /* a string stream */
+#define SF_APPENDWR 0000010 /* file is in append mode only */
+#define SF_MALLOC 0000020 /* buffer is malloc-ed */
+#define SF_LINE 0000040 /* line buffering */
+#define SF_SHARE 0000100 /* stream with shared file descriptor */
+#define SF_EOF 0000200 /* eof was detected */
+#define SF_ERROR 0000400 /* an error happened */
+#define SF_STATIC 0001000 /* a stream that cannot be freed */
+#define SF_IOCHECK 0002000 /* call exceptf before doing IO */
+#define SF_PUBLIC 0004000 /* SF_SHARE and follow physical seek */
+#define SF_MTSAFE 0010000 /* need thread safety */
+#define SF_WHOLE 0020000 /* preserve wholeness of sfwrite/sfputr */
+#define SF_IOINTR 0040000 /* return on interrupts */
+#define SF_WCWIDTH 0100000 /* wcwidth display stream */
+
+#define SF_FLAGS 0177177 /* PUBLIC FLAGS PASSABLE TO SFNEW() */
+#define SF_SETS 0177163 /* flags passable to sfset() */
+
+#ifndef _SF_NO_OBSOLETE
+#define SF_BUFCONST 0400000 /* unused flag - for compatibility only */
+#endif
+
+/* for sfgetr/sfreserve to hold a record */
+#define SF_LOCKR 0000010 /* lock record, stop access to stream */
+#define SF_LASTR 0000020 /* get the last incomplete record */
+
+/* exception events: SF_NEW(0), SF_READ(1), SF_WRITE(2) and the below */
+#define SF_SEEK 3 /* seek error */
+#define SF_CLOSING 4 /* when stream is about to be closed */
+#define SF_DPUSH 5 /* when discipline is being pushed */
+#define SF_DPOP 6 /* when discipline is being popped */
+#define SF_DPOLL 7 /* see if stream is ready for I/O */
+#define SF_DBUFFER 8 /* buffer not empty during push or pop */
+#define SF_SYNC 9 /* announcing start/end synchronization */
+#define SF_PURGE 10 /* a sfpurge() call was issued */
+#define SF_FINAL 11 /* closing is done except stream free */
+#define SF_READY 12 /* a polled stream is ready */
+#define SF_LOCKED 13 /* stream is in a locked state */
+#define SF_ATEXIT 14 /* process is exiting */
+#define SF_EVENT 100 /* start of user-defined events */
+
+/* for stack and disciplines */
+#define SF_POPSTACK ((Sfio_t*)0) /* pop the stream stack */
+#define SF_POPDISC ((Sfdisc_t*)0) /* pop the discipline stack */
+
+/* for the notify function and discipline exception */
+#define SF_NEW 0 /* new stream */
+#define SF_SETFD (-1) /* about to set the file descriptor */
+
+#define SF_BUFSIZE 8192 /* default buffer size */
+#define SF_UNBOUND (-1) /* unbounded buffer size */
+
+/* namespace incursion workarounds -- migrate to the new names */
+#if !_mac_SF_APPEND
+#define SF_APPEND SF_APPENDWR /* BSDI sys/stat.h */
+#endif
+#if !_mac_SF_CLOSE
+#define SF_CLOSE SF_CLOSING /* AIX sys/socket.h */
+#endif
+
+_BEGIN_EXTERNS_
+
+/* standard in/out/err streams */
+
+#if _BLD_sfio && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+#if !_BLD_sfio && defined(__IMPORT__)
+#define extern extern __IMPORT__
+#endif
+
+extern ssize_t _Sfi;
+extern ssize_t _Sfmaxr;
+
+extern Sfio_t* sfstdin;
+extern Sfio_t* sfstdout;
+extern Sfio_t* sfstderr;
+
+#if _UWIN
+#undef extern
+#endif
+
+extern Sfio_t _Sfstdin;
+extern Sfio_t _Sfstdout;
+extern Sfio_t _Sfstderr;
+
+#undef extern
+
+#if _BLD_sfio && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Sfio_t* sfnew _ARG_((Sfio_t*, Void_t*, size_t, int, int));
+extern Sfio_t* sfopen _ARG_((Sfio_t*, const char*, const char*));
+extern Sfio_t* sfpopen _ARG_((Sfio_t*, const char*, const char*));
+extern Sfio_t* sfstack _ARG_((Sfio_t*, Sfio_t*));
+extern Sfio_t* sfswap _ARG_((Sfio_t*, Sfio_t*));
+extern Sfio_t* sftmp _ARG_((size_t));
+extern int sfpurge _ARG_((Sfio_t*));
+extern int sfpoll _ARG_((Sfio_t**, int, int));
+extern Void_t* sfreserve _ARG_((Sfio_t*, ssize_t, int));
+extern int sfresize _ARG_((Sfio_t*, Sfoff_t));
+extern int sfsync _ARG_((Sfio_t*));
+extern int sfclrlock _ARG_((Sfio_t*));
+extern Void_t* sfsetbuf _ARG_((Sfio_t*, Void_t*, size_t));
+extern Sfdisc_t* sfdisc _ARG_((Sfio_t*,Sfdisc_t*));
+extern int sfraise _ARG_((Sfio_t*, int, Void_t*));
+extern int sfnotify _ARG_((void(*)(Sfio_t*, int, int)));
+extern int sfset _ARG_((Sfio_t*, int, int));
+extern int sfsetfd _ARG_((Sfio_t*, int));
+extern Sfio_t* sfpool _ARG_((Sfio_t*, Sfio_t*, int));
+extern ssize_t sfread _ARG_((Sfio_t*, Void_t*, size_t));
+extern ssize_t sfwrite _ARG_((Sfio_t*, const Void_t*, size_t));
+extern Sfoff_t sfmove _ARG_((Sfio_t*, Sfio_t*, Sfoff_t, int));
+extern int sfclose _ARG_((Sfio_t*));
+extern Sfoff_t sftell _ARG_((Sfio_t*));
+extern Sfoff_t sfseek _ARG_((Sfio_t*, Sfoff_t, int));
+extern ssize_t sfputr _ARG_((Sfio_t*, const char*, int));
+extern char* sfgetr _ARG_((Sfio_t*, int, int));
+extern ssize_t sfnputc _ARG_((Sfio_t*, int, size_t));
+extern int sfungetc _ARG_((Sfio_t*, int));
+extern int sfprintf _ARG_((Sfio_t*, const char*, ...));
+extern char* sfprints _ARG_((const char*, ...));
+extern ssize_t sfsprintf _ARG_((char*, size_t, const char*, ...));
+extern ssize_t sfvsprintf _ARG_((char*, size_t, const char*, va_list));
+extern int sfvprintf _ARG_((Sfio_t*, const char*, va_list));
+extern int sfscanf _ARG_((Sfio_t*, const char*, ...));
+extern int sfsscanf _ARG_((const char*, const char*, ...));
+extern int sfvsscanf _ARG_((const char*, const char*, va_list));
+extern int sfvscanf _ARG_((Sfio_t*, const char*, va_list));
+
+/* mutex locking for thread-safety */
+extern int sfmutex _ARG_((Sfio_t*, int));
+
+/* io functions with discipline continuation */
+extern ssize_t sfrd _ARG_((Sfio_t*, Void_t*, size_t, Sfdisc_t*));
+extern ssize_t sfwr _ARG_((Sfio_t*, const Void_t*, size_t, Sfdisc_t*));
+extern Sfoff_t sfsk _ARG_((Sfio_t*, Sfoff_t, int, Sfdisc_t*));
+extern ssize_t sfpkrd _ARG_((int, Void_t*, size_t, int, long, int));
+
+/* portable handling of primitive types */
+extern int sfdlen _ARG_((Sfdouble_t));
+extern int sfllen _ARG_((Sflong_t));
+extern int sfulen _ARG_((Sfulong_t));
+
+extern int sfputd _ARG_((Sfio_t*, Sfdouble_t));
+extern int sfputl _ARG_((Sfio_t*, Sflong_t));
+extern int sfputu _ARG_((Sfio_t*, Sfulong_t));
+extern int sfputm _ARG_((Sfio_t*, Sfulong_t, Sfulong_t));
+extern int sfputc _ARG_((Sfio_t*, int));
+
+extern Sfdouble_t sfgetd _ARG_((Sfio_t*));
+extern Sflong_t sfgetl _ARG_((Sfio_t*));
+extern Sfulong_t sfgetu _ARG_((Sfio_t*));
+extern Sfulong_t sfgetm _ARG_((Sfio_t*, Sfulong_t));
+extern int sfgetc _ARG_((Sfio_t*));
+
+extern int _sfputd _ARG_((Sfio_t*, Sfdouble_t));
+extern int _sfputl _ARG_((Sfio_t*, Sflong_t));
+extern int _sfputu _ARG_((Sfio_t*, Sfulong_t));
+extern int _sfputm _ARG_((Sfio_t*, Sfulong_t, Sfulong_t));
+extern int _sfflsbuf _ARG_((Sfio_t*, int));
+
+extern int _sffilbuf _ARG_((Sfio_t*, int));
+
+extern int _sfdlen _ARG_((Sfdouble_t));
+extern int _sfllen _ARG_((Sflong_t));
+extern int _sfulen _ARG_((Sfulong_t));
+
+/* miscellaneous function analogues of fast in-line functions */
+extern Sfoff_t sfsize _ARG_((Sfio_t*));
+extern int sfclrerr _ARG_((Sfio_t*));
+extern int sfeof _ARG_((Sfio_t*));
+extern int sferror _ARG_((Sfio_t*));
+extern int sffileno _ARG_((Sfio_t*));
+extern int sfstacked _ARG_((Sfio_t*));
+extern ssize_t sfvalue _ARG_((Sfio_t*));
+extern ssize_t sfslen _ARG_((void));
+extern ssize_t sfmaxr _ARG_((ssize_t, int));
+
+#undef extern
+_END_EXTERNS_
+
+/* coding long integers in a portable and compact fashion */
+#define SF_SBITS 6
+#define SF_UBITS 7
+#define SF_BBITS 8
+#define SF_SIGN (1 << SF_SBITS)
+#define SF_MORE (1 << SF_UBITS)
+#define SF_BYTE (1 << SF_BBITS)
+#define SF_U1 SF_MORE
+#define SF_U2 (SF_U1*SF_U1)
+#define SF_U3 (SF_U2*SF_U1)
+#define SF_U4 (SF_U3*SF_U1)
+
+#if __cplusplus
+#define _SF_(f) (f)
+#else
+#define _SF_(f) ((Sfio_t*)(f))
+#endif
+
+#define __sf_putd(f,v) (_sfputd(_SF_(f),(Sfdouble_t)(v)))
+#define __sf_putl(f,v) (_sfputl(_SF_(f),(Sflong_t)(v)))
+#define __sf_putu(f,v) (_sfputu(_SF_(f),(Sfulong_t)(v)))
+#define __sf_putm(f,v,m) (_sfputm(_SF_(f),(Sfulong_t)(v),(Sfulong_t)(m)))
+
+#define __sf_putc(f,c) (_SF_(f)->_next >= _SF_(f)->_endw ? \
+ _sfflsbuf(_SF_(f),(int)((unsigned char)(c))) : \
+ (int)(*_SF_(f)->_next++ = (unsigned char)(c)) )
+#define __sf_getc(f) (_SF_(f)->_next >= _SF_(f)->_endr ? _sffilbuf(_SF_(f),0) : \
+ (int)(*_SF_(f)->_next++) )
+
+#define __sf_dlen(v) (_sfdlen((Sfdouble_t)(v)) )
+#define __sf_llen(v) (_sfllen((Sflong_t)(v)) )
+#define __sf_ulen(v) ((Sfulong_t)(v) < SF_U1 ? 1 : (Sfulong_t)(v) < SF_U2 ? 2 : \
+ (Sfulong_t)(v) < SF_U3 ? 3 : (Sfulong_t)(v) < SF_U4 ? 4 : 5)
+
+#define __sf_fileno(f) (_SF_(f)->_file)
+#define __sf_eof(f) (_SF_(f)->_flags&SF_EOF)
+#define __sf_error(f) (_SF_(f)->_flags&SF_ERROR)
+#define __sf_clrerr(f) (_SF_(f)->_flags &= ~(SF_ERROR|SF_EOF))
+#define __sf_stacked(f) (_SF_(f)->_push != (Sfio_t*)0)
+#define __sf_value(f) (_SF_(f)->_val)
+#define __sf_slen() (_Sfi)
+#define __sf_maxr(n,s) ((s)?((_Sfi=_Sfmaxr),(_Sfmaxr=(n)),_Sfi):_Sfmaxr)
+
+#if defined(__INLINE__) && !_BLD_sfio
+
+__INLINE__ int sfputd(Sfio_t* f, Sfdouble_t v) { return __sf_putd(f,v); }
+__INLINE__ int sfputl(Sfio_t* f, Sflong_t v) { return __sf_putl(f,v); }
+__INLINE__ int sfputu(Sfio_t* f, Sfulong_t v) { return __sf_putu(f,v); }
+__INLINE__ int sfputm(Sfio_t* f, Sfulong_t v, Sfulong_t m)
+ { return __sf_putm(f,v,m); }
+
+__INLINE__ int sfputc(Sfio_t* f, int c) { return __sf_putc(f,c); }
+__INLINE__ int sfgetc(Sfio_t* f) { return __sf_getc(f); }
+
+__INLINE__ int sfdlen(Sfdouble_t v) { return __sf_dlen(v); }
+__INLINE__ int sfllen(Sflong_t v) { return __sf_llen(v); }
+__INLINE__ int sfulen(Sfulong_t v) { return __sf_ulen(v); }
+
+__INLINE__ int sffileno(Sfio_t* f) { return __sf_fileno(f); }
+__INLINE__ int sfeof(Sfio_t* f) { return __sf_eof(f); }
+__INLINE__ int sferror(Sfio_t* f) { return __sf_error(f); }
+__INLINE__ int sfclrerr(Sfio_t* f) { return __sf_clrerr(f); }
+__INLINE__ int sfstacked(Sfio_t* f) { return __sf_stacked(f); }
+__INLINE__ ssize_t sfvalue(Sfio_t* f) { return __sf_value(f); }
+__INLINE__ ssize_t sfslen() { return __sf_slen(); }
+__INLINE__ ssize_t sfmaxr(ssize_t n, int s) { return __sf_maxr(n,s); }
+
+#else
+
+#define sfputd(f,v) ( __sf_putd((f),(v)) )
+#define sfputl(f,v) ( __sf_putl((f),(v)) )
+#define sfputu(f,v) ( __sf_putu((f),(v)) )
+#define sfputm(f,v,m) ( __sf_putm((f),(v),(m)) )
+
+#define sfputc(f,c) ( __sf_putc((f),(c)) )
+#define sfgetc(f) ( __sf_getc(f) )
+
+#define sfdlen(v) ( __sf_dlen(v) )
+#define sfllen(v) ( __sf_llen(v) )
+#define sfulen(v) ( __sf_ulen(v) )
+
+#define sffileno(f) ( __sf_fileno(f) )
+#define sfeof(f) ( __sf_eof(f) )
+#define sferror(f) ( __sf_error(f) )
+#define sfclrerr(f) ( __sf_clrerr(f) )
+#define sfstacked(f) ( __sf_stacked(f) )
+#define sfvalue(f) ( __sf_value(f) )
+#define sfslen() ( __sf_slen() )
+#define sfmaxr(n,s) ( __sf_maxr(n,s) )
+
+#endif /*__INLINE__*/
+
+#ifndef _SFSTR_H /* GSF's string manipulation stuff */
+#define _SFSTR_H 1
+
+#define sfstropen() sfnew(0, 0, -1, -1, SF_READ|SF_WRITE|SF_STRING)
+#define sfstrclose(f) sfclose(f)
+
+#define sfstrseek(f,p,m) \
+ ( (m) == SEEK_SET ? \
+ (((p) < 0 || (p) > (f)->_size) ? (char*)0 : \
+ (char*)((f)->_next = (f)->_data+(p)) ) \
+ : (m) == SEEK_CUR ? \
+ ((f)->_next += (p), \
+ (((f)->_next < (f)->_data || (f)->_next > (f)->_data+(f)->_size) ? \
+ ((f)->_next -= (p), (char*)0) : (char*)(f)->_next ) ) \
+ : (m) == SEEK_END ? \
+ ( ((p) > 0 || (f)->_size+(p) < 0) ? (char*)0 : \
+ (char*)((f)->_next = (f)->_data+(f)->_size+(p)) ) \
+ : (char*)0 \
+ )
+
+#define sfstrsize(f) ((f)->_size)
+#define sfstrtell(f) ((f)->_next - (f)->_data)
+#define sfstrpend(f) ((f)->_size - sfstrtell())
+#define sfstrbase(f) ((char*)(f)->_data)
+
+#define sfstruse(f) \
+ (sfputc((f),0) < 0 ? (char*)0 : (char*)((f)->_next = (f)->_data) \
+ )
+
+#define sfstrrsrv(f,n) \
+ (sfreserve((f),(n),SF_WRITE|SF_LOCKR), sfwrite((f),(f)->_next,0), \
+ ((f)->_next+(n) <= (f)->_data+(f)->_size ? (char*)(f)->_next : (char*)0) \
+ )
+
+#define sfstrbuf(f,b,n,m) \
+ (sfsetbuf((f),(b),(n)), ((f)->_flags |= (m) ? SF_MALLOC : 0), \
+ ((f)->_data == (unsigned char*)(b) ? 0 : -1) \
+ )
+
+#endif /* _SFSTR_H */
+
+#endif /* _SFIO_H */
diff --git a/usr/src/lib/libast/sparcv9/include/ast/sfio_s.h b/usr/src/lib/libast/sparcv9/include/ast/sfio_s.h
new file mode 100644
index 0000000000..27936a16b1
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/sfio_s.h
@@ -0,0 +1,51 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _SFIO_S_H
+#define _SFIO_S_H 1
+
+/*
+ * sfio file structure used by sfio and the stdio source compatibility library
+ */
+
+#if !defined(_SFHDR_H) && defined(_SFIO_H) && SFIO_VERSION < 20020214L
+#define _data data
+#define _endb endb
+#define _next next
+#endif
+
+struct _sfio_s
+{ unsigned char* _next; /* next position to read/write from */
+ unsigned char* _endw; /* end of write buffer */
+ unsigned char* _endr; /* end of read buffer */
+ unsigned char* _endb; /* end of buffer */
+ struct _sfio_s* _push; /* the stream that was pushed on */
+ unsigned short _flags; /* type of stream */
+ short _file; /* file descriptor */
+ unsigned char* _data; /* base of data buffer */
+ ssize_t _size; /* buffer size */
+ ssize_t _val; /* values or string lengths */
+#ifdef _SFIO_PRIVATE
+ _SFIO_PRIVATE
+#endif
+};
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/sfio_t.h b/usr/src/lib/libast/sparcv9/include/ast/sfio_t.h
new file mode 100644
index 0000000000..36be6ecc94
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/sfio_t.h
@@ -0,0 +1,126 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _SFIO_T_H
+#define _SFIO_T_H 1
+
+/* This header file is for library writers who need to know certain
+** internal info concerning the full Sfio_t structure. Including this
+** file means that you agree to track closely with sfio development
+** in case its internal architecture is changed.
+**
+** Written by Kiem-Phong Vo
+*/
+
+/* the parts of Sfio_t private to sfio functions */
+#define _SFIO_PRIVATE \
+ Sfoff_t extent; /* current file size */ \
+ Sfoff_t here; /* current physical location */ \
+ unsigned char getr; /* the last sfgetr separator */ \
+ unsigned char tiny[1];/* for unbuffered read stream */ \
+ unsigned short bits; /* private flags */ \
+ unsigned int mode; /* current io mode */ \
+ struct _sfdisc_s* disc; /* discipline */ \
+ struct _sfpool_s* pool; /* the pool containing this */ \
+ struct _sfrsrv_s* rsrv; /* reserved buffer */ \
+ struct _sfproc_s* proc; /* coprocess id, etc. */ \
+ Void_t* mutex; /* mutex for thread-safety */ \
+ Void_t* stdio; /* stdio FILE if any */ \
+ Sfoff_t lpos; /* last seek position */ \
+ size_t iosz; /* preferred size for I/O */ \
+ size_t blksz; /* preferred block size */ \
+ Void_t* fill[1];/* modest expansion */
+
+#include "sfio.h"
+
+/* mode bit to indicate that the structure hasn't been initialized */
+#define SF_INIT 0000004
+#define SF_DCDOWN 00010000
+
+/* short-hand for common stream types */
+#define SF_RDWR (SF_READ|SF_WRITE)
+#define SF_RDSTR (SF_READ|SF_STRING)
+#define SF_WRSTR (SF_WRITE|SF_STRING)
+#define SF_RDWRSTR (SF_RDWR|SF_STRING)
+
+/* for static initialization of an Sfio_t structure */
+#define SFNEW(data,size,file,type,disc,mutex) \
+ { (unsigned char*)(data), /* next */ \
+ (unsigned char*)(data), /* endw */ \
+ (unsigned char*)(data), /* endr */ \
+ (unsigned char*)(data), /* endb */ \
+ (Sfio_t*)0, /* push */ \
+ (unsigned short)((type)&SF_FLAGS), /* flags */ \
+ (short)(file), /* file */ \
+ (unsigned char*)(data), /* data */ \
+ (ssize_t)(size), /* size */ \
+ (ssize_t)(-1), /* val */ \
+ (Sfoff_t)0, /* extent */ \
+ (Sfoff_t)0, /* here */ \
+ 0, /* getr */ \
+ {0}, /* tiny */ \
+ 0, /* bits */ \
+ (unsigned int)(((type)&(SF_RDWR))|SF_INIT), /* mode */ \
+ (struct _sfdisc_s*)(disc), /* disc */ \
+ (struct _sfpool_s*)0, /* pool */ \
+ (struct _sfrsrv_s*)0, /* rsrv */ \
+ (struct _sfproc_s*)0, /* proc */ \
+ (mutex), /* mutex */ \
+ (Void_t*)0, /* stdio */ \
+ (Sfoff_t)0, /* lpos */ \
+ (size_t)0 /* iosz */ \
+ }
+
+/* function to clear an Sfio_t structure */
+#define SFCLEAR(f,mtx) \
+ ( (f)->next = (unsigned char*)0, /* next */ \
+ (f)->endw = (unsigned char*)0, /* endw */ \
+ (f)->endr = (unsigned char*)0, /* endr */ \
+ (f)->endb = (unsigned char*)0, /* endb */ \
+ (f)->push = (Sfio_t*)0, /* push */ \
+ (f)->flags = (unsigned short)0, /* flags */ \
+ (f)->file = -1, /* file */ \
+ (f)->data = (unsigned char*)0, /* data */ \
+ (f)->size = (ssize_t)(-1), /* size */ \
+ (f)->val = (ssize_t)(-1), /* val */ \
+ (f)->extent = (Sfoff_t)(-1), /* extent */ \
+ (f)->here = (Sfoff_t)0, /* here */ \
+ (f)->getr = 0, /* getr */ \
+ (f)->tiny[0] = 0, /* tiny */ \
+ (f)->bits = 0, /* bits */ \
+ (f)->mode = 0, /* mode */ \
+ (f)->disc = (struct _sfdisc_s*)0, /* disc */ \
+ (f)->pool = (struct _sfpool_s*)0, /* pool */ \
+ (f)->rsrv = (struct _sfrsrv_s*)0, /* rsrv */ \
+ (f)->proc = (struct _sfproc_s*)0, /* proc */ \
+ (f)->mutex = (mtx), /* mutex */ \
+ (f)->stdio = (Void_t*)0, /* stdio */ \
+ (f)->lpos = (Sfoff_t)0, /* lpos */ \
+ (f)->iosz = (size_t)0 /* iosz */ \
+ )
+
+/* expose next stream inside discipline function; state saved in int f */
+#define SFDCNEXT(sp,f) (((f)=(sp)->bits&SF_DCDOWN),(sp)->bits|=SF_DCDOWN)
+
+/* restore SFDCNEXT() state from int f */
+#define SFDCPREV(sp,f) ((f)?(0):((sp)->bits&=~SF_DCDOWN))
+
+#endif /* _SFIO_T_H */
diff --git a/usr/src/lib/libast/sparcv9/include/ast/sig.h b/usr/src/lib/libast/sparcv9/include/ast/sig.h
new file mode 100644
index 0000000000..7c7f5eeb23
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/sig.h
@@ -0,0 +1,152 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/sig.sh by iffe version 2007-04-04 : : */
+#ifndef _def_sig_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_sig_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define sig_info _sig_info_
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide kill killpg
+#else
+#define kill ______kill
+#define killpg ______killpg
+#endif
+#include <signal.h>
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide kill killpg
+#else
+#undef kill
+#undef killpg
+#endif
+#ifndef sigmask
+#define sigmask(s) (1<<((s)-1))
+#endif
+typedef void (*Sig_handler_t) __PROTO__((int));
+
+
+#define Handler_t Sig_handler_t
+
+#define SIG_REG_PENDING (-1)
+#define SIG_REG_POP 0
+#define SIG_REG_EXEC 00001
+#define SIG_REG_PROC 00002
+#define SIG_REG_TERM 00004
+#define SIG_REG_ALL 00777
+#define SIG_REG_SET 01000
+
+typedef struct
+{
+ char** name;
+ char** text;
+ int sigmax;
+} Sig_info_t;
+
+extern __MANGLE__ int kill __PROTO__((pid_t, int));
+extern __MANGLE__ int killpg __PROTO__((pid_t, int));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Sig_info_t sig_info;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int sigcritical __PROTO__((int));
+extern __MANGLE__ int sigunblock __PROTO__((int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/stack.h b/usr/src/lib/libast/sparcv9/include/ast/stack.h
new file mode 100644
index 0000000000..ad32ebb8ab
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/stack.h
@@ -0,0 +1,94 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * homogenous stack routine definitions
+ */
+
+#ifndef _STACK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _STACK_H
+
+typedef struct stacktable* STACK; /* stack pointer */
+typedef struct stackposition STACKPOS; /* stack position */
+
+struct stackblock /* stack block cell */
+{
+ __V_** stack; /* actual stack */
+ struct stackblock* prev; /* previous block in list */
+ struct stackblock* next; /* next block in list */
+};
+
+struct stackposition /* stack position */
+{
+ struct stackblock* block; /* current block pointer */
+ int index; /* index within current block */
+};
+
+struct stacktable /* stack information */
+{
+ struct stackblock* blocks; /* stack table blocks */
+ __V_* error; /* error return value */
+ int size; /* size of each block */
+ STACKPOS position; /* current stack position */
+};
+
+/*
+ * map old names to new
+ */
+
+#define mkstack stackalloc
+#define rmstack stackfree
+#define clrstack stackclear
+#define getstack stackget
+#define pushstack stackpush
+#define popstack stackpop
+#define posstack stacktell
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ STACK stackalloc __PROTO__((int, __V_*));
+extern __MANGLE__ void stackfree __PROTO__((STACK));
+extern __MANGLE__ void stackclear __PROTO__((STACK));
+extern __MANGLE__ __V_* stackget __PROTO__((STACK));
+extern __MANGLE__ int stackpush __PROTO__((STACK, __V_*));
+extern __MANGLE__ int stackpop __PROTO__((STACK));
+extern __MANGLE__ void stacktell __PROTO__((STACK, int, STACKPOS*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/stak.h b/usr/src/lib/libast/sparcv9/include/ast/stak.h
new file mode 100644
index 0000000000..e0e707b0e5
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/stak.h
@@ -0,0 +1,64 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * David Korn
+ * AT&T Research
+ *
+ * Interface definitions for a stack-like storage library
+ *
+ */
+
+#ifndef _STAK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _STAK_H
+
+#include <stk.h>
+
+#define Stak_t Sfio_t
+#define staksp stkstd
+#define STAK_SMALL STK_SMALL
+
+#define stakptr(n) stkptr(stkstd,n)
+#define staktell() stktell(stkstd)
+#define stakputc(c) sfputc(stkstd,(c))
+#define stakwrite(b,n) sfwrite(stkstd,(b),(n))
+#define stakputs(s) (sfputr(stkstd,(s),0),--stkstd->_next)
+#define stakseek(n) stkseek(stkstd,n)
+#define stakcreate(n) stkopen(n)
+#define stakinstall(s,f) stkinstall(s,f)
+#define stakdelete(s) stkclose(s)
+#define staklink(s) stklink(s)
+#define stakalloc(n) stkalloc(stkstd,n)
+#define stakcopy(s) stkcopy(stkstd,s)
+#define stakset(c,n) stkset(stkstd,c,n)
+#define stakfreeze(n) stkfreeze(stkstd,n)
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/stdio.h b/usr/src/lib/libast/sparcv9/include/ast/stdio.h
new file mode 100644
index 0000000000..7e137c5712
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/stdio.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_stdio.h>
diff --git a/usr/src/lib/libast/sparcv9/include/ast/stk.h b/usr/src/lib/libast/sparcv9/include/ast/stk.h
new file mode 100644
index 0000000000..24947d24f1
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/stk.h
@@ -0,0 +1,91 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * David Korn
+ * AT&T Research
+ *
+ * Interface definitions for a stack-like storage library
+ *
+ */
+
+#ifndef _STK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _STK_H
+
+#include <sfio.h>
+
+#define _Stk_data _Stak_data
+
+#define stkstd (&_Stk_data)
+
+#define Stk_t Sfio_t
+
+#define STK_SMALL 1 /* small stkopen stack */
+#define STK_NULL 2 /* return NULL on overflow */
+
+#define stkptr(sp,n) ((char*)((sp)->_data)+(n))
+#define stktop(sp) ((char*)(sp)->_next)
+#define stktell(sp) ((sp)->_next-(sp)->_data)
+#define stkseek(sp,n) ((n)==0?(char*)((sp)->_next=(sp)->_data):_stkseek(sp,n))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Sfio_t _Stk_data;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Stk_t* stkopen __PROTO__((int));
+extern __MANGLE__ Stk_t* stkinstall __PROTO__((Stk_t*, char*(*)(int)));
+extern __MANGLE__ int stkclose __PROTO__((Stk_t*));
+extern __MANGLE__ int stklink __PROTO__((Stk_t*));
+extern __MANGLE__ char* stkalloc __PROTO__((Stk_t*, unsigned));
+extern __MANGLE__ char* stkcopy __PROTO__((Stk_t*,const char*));
+extern __MANGLE__ char* stkset __PROTO__((Stk_t*, char*, unsigned));
+extern __MANGLE__ char* _stkseek __PROTO__((Stk_t*, unsigned));
+extern __MANGLE__ char* stkfreeze __PROTO__((Stk_t*, unsigned));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/swap.h b/usr/src/lib/libast/sparcv9/include/ast/swap.h
new file mode 100644
index 0000000000..d89248d12b
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/swap.h
@@ -0,0 +1,64 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * integral representation conversion support definitions
+ * supports sizeof(integral_type)<=sizeof(intmax_t)
+ */
+
+#ifndef _SWAP_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SWAP_H
+
+#include <ast_common.h>
+
+#define int_swap _ast_intswap
+
+#define SWAP_MAX 8
+
+#define SWAPOP(n) (((n)&int_swap)^(n))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ __V_* swapmem __PROTO__((int, const __V_*, __V_*, size_t));
+extern __MANGLE__ intmax_t swapget __PROTO__((int, const __V_*, int));
+extern __MANGLE__ __V_* swapput __PROTO__((int, __V_*, int, intmax_t));
+extern __MANGLE__ int swapop __PROTO__((const __V_*, const __V_*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/tar.h b/usr/src/lib/libast/sparcv9/include/ast/tar.h
new file mode 100644
index 0000000000..910b6e8612
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/tar.h
@@ -0,0 +1,127 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Standard Archive Format
+ * USTAR - Uniform Standard Tape ARchive
+ */
+
+#ifndef _TAR_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TAR_H
+
+#define TBLOCK 512
+#define NAMSIZ 100
+#define PFXSIZ 155
+
+#define TMODLEN 8
+#define TUIDLEN 8
+#define TGIDLEN 8
+#define TSIZLEN 12
+#define TMTMLEN 12
+#define TCKSLEN 8
+
+#define TMAGIC "ustar" /* ustar and a null */
+#define TMAGLEN 6
+#define TVERSION "00" /* 00 and no null */
+#define TVERSLEN 2
+#define TUNMLEN 32
+#define TGNMLEN 32
+#define TDEVLEN 8
+
+/*
+ * values used in typeflag field
+ */
+
+#define REGTYPE '0' /* regular file */
+#define AREGTYPE 0 /* alternate REGTYPE */
+#define LNKTYPE '1' /* hard link */
+#define SYMTYPE '2' /* soft link */
+#define CHRTYPE '3' /* character special */
+#define BLKTYPE '4' /* block special */
+#define DIRTYPE '5' /* directory */
+#define FIFOTYPE '6' /* FIFO special */
+#define CONTTYPE '7' /* reserved */
+#define SOKTYPE '8' /* socket */
+#define EXTTYPE 'x' /* extended header */
+#define GLBTYPE 'g' /* global extended header */
+#define LLNKTYPE 'K' /* long link path */
+#define LREGTYPE 'L' /* long file path */
+#define VERTYPE 'V' /* version */
+
+/*
+ * bits used in mode field
+ */
+
+#define TSUID 04000 /* set uid on exec */
+#define TSGID 02000 /* set gid on exec */
+#define TSVTX 01000 /* sticky bit -- reserved */
+
+/*
+ * file permissions
+ */
+
+#define TUREAD 00400 /* read by owner */
+#define TUWRITE 00200 /* write by owner */
+#define TUEXEC 00100 /* execute by owner */
+#define TGREAD 00040 /* read by group */
+#define TGWRITE 00020 /* execute by group */
+#define TGEXEC 00010 /* write by group */
+#define TOREAD 00004 /* read by other */
+#define TOWRITE 00002 /* write by other */
+#define TOEXEC 00001 /* execute by other */
+
+struct header
+{
+ char name[NAMSIZ];
+ char mode[TMODLEN];
+ char uid[TUIDLEN];
+ char gid[TGIDLEN];
+ char size[TSIZLEN];
+ char mtime[TMTMLEN];
+ char chksum[TCKSLEN];
+ char typeflag;
+ char linkname[NAMSIZ];
+ char magic[TMAGLEN];
+ char version[TVERSLEN];
+ char uname[TUNMLEN];
+ char gname[TGNMLEN];
+ char devmajor[TDEVLEN];
+ char devminor[TDEVLEN];
+ char prefix[PFXSIZ];
+};
+
+union hblock
+{
+ char dummy[TBLOCK];
+ struct header dbuf;
+};
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/times.h b/usr/src/lib/libast/sparcv9/include/ast/times.h
new file mode 100644
index 0000000000..25e81662be
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/times.h
@@ -0,0 +1,65 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * -last clock_t,time_t interface definitions plus
+ *
+ * <ast.h>
+ * <time.h>
+ * <sys/time.h>
+ * <sys/times.h>
+ */
+
+#ifndef _TIMES_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TIMES_H
+
+#include <ast.h>
+
+#undef _TIMES_H
+#include <ast_time.h>
+#ifndef _TIMES_H
+#define _TIMES_H
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int touch __PROTO__((const char*, time_t, time_t, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/tm.h b/usr/src/lib/libast/sparcv9/include/ast/tm.h
new file mode 100644
index 0000000000..f790a9a66e
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/tm.h
@@ -0,0 +1,205 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * time conversion support definitions
+ */
+
+#ifndef _TM_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TM_H
+
+#define TM_VERSION 20070319L
+
+#include <ast.h>
+#include <times.h>
+
+#undef daylight
+
+#define tmset(z) tminit(z)
+#define tmisleapyear(y) (!((y)%4)&&(((y)%100)||!((((y)<1900)?((y)+1900):(y))%400)))
+
+#define TM_ADJUST (1<<0) /* local doesn't do leap secs */
+#define TM_LEAP (1<<1) /* do leap seconds */
+#define TM_UTC (1<<2) /* universal coordinated ref */
+
+#define TM_PEDANTIC (1<<3) /* pedantic date parse */
+#define TM_DATESTYLE (1<<4) /* date(1) style mmddHHMMccyy */
+#define TM_SUBSECOND (1<<5) /* <something>%S => ...%S.%P */
+
+#define TM_DST (-60) /* default minutes for DST */
+#define TM_LOCALZONE (25 * 60) /* use local time zone offset */
+#define TM_UTCZONE (26 * 60) /* UTC "time zone" */
+#define TM_MAXLEAP 1 /* max leap secs per leap */
+#define TM_WINDOW 69 /* century windowing guard year */
+
+/*
+ * these indices must agree with tm_dform[]
+ */
+
+#define TM_MONTH_ABBREV 0
+#define TM_MONTH 12
+#define TM_DAY_ABBREV 24
+#define TM_DAY 31
+#define TM_TIME 38
+#define TM_DATE 39
+#define TM_DEFAULT 40
+#define TM_MERIDIAN 41
+
+#define TM_UT 43
+#define TM_DT 47
+#define TM_SUFFIXES 51
+#define TM_PARTS 55
+#define TM_HOURS 62
+#define TM_DAYS 66
+#define TM_LAST 69
+#define TM_THIS 72
+#define TM_NEXT 75
+#define TM_EXACT 78
+#define TM_NOISE 81
+#define TM_ORDINAL 85
+#define TM_DIGITS 95
+#define TM_CTIME 105
+#define TM_DATE_1 106
+#define TM_INTERNATIONAL 107
+#define TM_RECENT 108
+#define TM_DISTANT 109
+#define TM_MERIDIAN_TIME 110
+#define TM_ERA 111
+#define TM_ERA_DATE 112
+#define TM_ERA_TIME 113
+#define TM_ERA_DEFAULT 114
+#define TM_ERA_YEAR 115
+#define TM_ORDINALS 116
+#define TM_FINAL 126
+
+#define TM_NFORM 129
+
+typedef struct /* leap second info */
+{
+ time_t time; /* the leap second event */
+ int total; /* inclusive total since epoch */
+} Tm_leap_t;
+
+typedef struct /* time zone info */
+{
+ char* type; /* type name */
+ char* standard; /* standard time name */
+ char* daylight; /* daylight or summertime name */
+ short west; /* minutes west of GMT */
+ short dst; /* add to tz.west for DST */
+} Tm_zone_t;
+
+typedef struct /* tm library readonly data */
+{
+ char** format; /* default TM_* format strings */
+ char* lex; /* format lex type classes */
+ char* digit; /* output digits */
+ short* days; /* days in month i */
+ short* sum; /* days in months before i */
+ Tm_leap_t* leap; /* leap second table */
+ Tm_zone_t* zone; /* alternate timezone table */
+} Tm_data_t;
+
+typedef struct /* tm library global info */
+{
+ char* deformat; /* TM_DEFAULT override */
+ int flags; /* flags */
+ char** format; /* current format strings */
+ Tm_zone_t* date; /* timezone from last tmdate() */
+ Tm_zone_t* local; /* local timezone */
+ Tm_zone_t* zone; /* current timezone */
+} Tm_info_t;
+
+typedef struct Tm_s
+{
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+ uint32_t tm_nsec;
+ Tm_zone_t* tm_zone;
+} Tm_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Tm_data_t* _tm_datap_;
+extern __MANGLE__ Tm_info_t* _tm_infop_;
+
+#define tm_data (*_tm_datap_)
+#define tm_info (*_tm_infop_)
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ time_t tmdate __PROTO__((const char*, char**, time_t*));
+extern __MANGLE__ int tmequiv __PROTO__((Tm_t*));
+extern __MANGLE__ Tm_t* tmfix __PROTO__((Tm_t*));
+extern __MANGLE__ char* tmfmt __PROTO__((char*, size_t, const char*, time_t*));
+extern __MANGLE__ char* tmform __PROTO__((char*, const char*, time_t*));
+extern __MANGLE__ int tmgoff __PROTO__((const char*, char**, int));
+extern __MANGLE__ void tminit __PROTO__((Tm_zone_t*));
+extern __MANGLE__ time_t tmleap __PROTO__((time_t*));
+extern __MANGLE__ int tmlex __PROTO__((const char*, char**, char**, int, char**, int));
+extern __MANGLE__ char** tmlocale __PROTO__((void));
+extern __MANGLE__ Tm_t* tmmake __PROTO__((time_t*));
+extern __MANGLE__ char* tmpoff __PROTO__((char*, size_t, const char*, int, int));
+extern __MANGLE__ time_t tmscan __PROTO__((const char*, char**, const char*, char**, time_t*, long));
+extern __MANGLE__ int tmsleep __PROTO__((time_t, time_t));
+extern __MANGLE__ time_t tmtime __PROTO__((Tm_t*, int));
+extern __MANGLE__ Tm_zone_t* tmtype __PROTO__((const char*, char**));
+extern __MANGLE__ int tmweek __PROTO__((Tm_t*, int, int, int));
+extern __MANGLE__ int tmword __PROTO__((const char*, char**, const char*, char**, int));
+extern __MANGLE__ Tm_zone_t* tmzone __PROTO__((const char*, char**, const char*, int*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/tmx.h b/usr/src/lib/libast/sparcv9/include/ast/tmx.h
new file mode 100644
index 0000000000..bf69ccfda8
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/tmx.h
@@ -0,0 +1,149 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/tmx by iffe version 2007-04-04 : : */
+
+#ifndef _TMX_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TMX_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Time_t support
+ */
+
+#include <tm.h>
+#include <tv.h>
+
+#define TMX_MAXDATE "2554-07-21+23:34:33.709551614 UTC"
+#define TMX_MAXYEAR 2554
+#define TMX_MAXSEC ((Time_t)18446744073)
+#define TMX_MAXNSEC 709551614
+#define TMX_RESOLUTION 1000000000
+
+typedef uint64_t Time_t;
+typedef uint64_t Tmxsec_t;
+typedef uint32_t Tmxnsec_t;
+
+#define tmxsec(t) ((Tmxsec_t)((t)/1000000000))
+#define tmxnsec(t) ((Tmxnsec_t)((t)%1000000000))
+#define tmxsns(s,n) (((((Time_t)(s))*1000000000))+((Time_t)(n)))
+
+#define TMX_NOTIME ((Time_t)(-1))
+#define TMX_NOW tmxgettime()
+#define TMX_MAXTIME tmxsns(TMX_MAXSEC,TMX_MAXNSEC)
+
+#define tmx2tv(t,v) ((v)->tv_nsec=tmxnsec(t),(v)->tv_sec=tmxsec(t))
+#define tv2tmx(v) tmxsns((v)->tv_sec,(v)->tv_nsec)
+
+#define tmxclock(p) tmxsns(((p)?*(p):time(NiL)),0)
+
+#define tmxgetatime(s) tmxsns((s)->st_atime,ST_ATIME_NSEC_GET(s))
+#define tmxgetctime(s) tmxsns((s)->st_ctime,ST_CTIME_NSEC_GET(s))
+#define tmxgetmtime(s) tmxsns((s)->st_mtime,ST_MTIME_NSEC_GET(s))
+
+#define tmxsetatime(s,t) ((s)->st_atime=tmxsec(t),ST_ATIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetctime(s,t) ((s)->st_ctime=tmxsec(t),ST_CTIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetmtime(s,t) ((s)->st_mtime=tmxsec(t),ST_MTIME_NSEC_SET(s,tmxnsec(t)))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Time_t tmxdate __PROTO__((const char*, char**, Time_t));
+extern __MANGLE__ char* tmxfmt __PROTO__((char*, size_t, const char*, Time_t));
+extern __MANGLE__ Time_t tmxleap __PROTO__((Time_t));
+extern __MANGLE__ Tm_t* tmxmake __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxscan __PROTO__((const char*, char**, const char*, char**, Time_t, long));
+extern __MANGLE__ int tmxsleep __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxtime __PROTO__((Tm_t*, int));
+
+extern __MANGLE__ Time_t tmxgettime __PROTO__((void));
+extern __MANGLE__ int tmxsettime __PROTO__((Time_t));
+
+extern __MANGLE__ int tmxtouch __PROTO__((const char*, Time_t, Time_t, Time_t, int));
+
+extern __MANGLE__ char* fmttmx __PROTO__((const char*, Time_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/tok.h b/usr/src/lib/libast/sparcv9/include/ast/tok.h
new file mode 100644
index 0000000000..3637489918
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/tok.h
@@ -0,0 +1,58 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * token stream interface definitions
+ */
+
+#ifndef _TOK_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TOK_H
+
+#include <ast.h>
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Sfio_t* tokline __PROTO__((const char*, int, int*));
+extern __MANGLE__ int tokscan __PROTO__((char*, char**, const char*, ...));
+extern __MANGLE__ char* tokopen __PROTO__((char*, int));
+extern __MANGLE__ void tokclose __PROTO__((char*));
+extern __MANGLE__ char* tokread __PROTO__((char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/tv.h b/usr/src/lib/libast/sparcv9/include/ast/tv.h
new file mode 100644
index 0000000000..95aea300f6
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/tv.h
@@ -0,0 +1,132 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/tv by iffe version 2007-04-04 : : */
+
+#ifndef _TV_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TV_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Tv_t interface definitions
+ */
+
+#include <ast.h>
+
+#define TV_NSEC_IGNORE (1000000000L)
+#define TV_TOUCH_RETAIN ((Tv_t*)1)
+
+typedef struct Tv_s
+{
+ uint32_t tv_sec;
+ uint32_t tv_nsec;
+} Tv_t;
+
+#define ST_ATIME_NSEC_GET(st) ((st)->st_atim.tv_nsec)
+#define ST_CTIME_NSEC_GET(st) ((st)->st_ctim.tv_nsec)
+#define ST_MTIME_NSEC_GET(st) ((st)->st_mtim.tv_nsec)
+
+#define ST_ATIME_NSEC_SET(st,n) (ST_ATIME_NSEC_GET(st)=(n))
+#define ST_CTIME_NSEC_SET(st,n) (ST_CTIME_NSEC_GET(st)=(n))
+#define ST_MTIME_NSEC_SET(st,n) (ST_MTIME_NSEC_GET(st)=(n))
+
+#define tvgetatime(t,s) ((t)->tv_nsec=ST_ATIME_NSEC_GET(s),(t)->tv_sec=(s)->st_atime)
+#define tvgetmtime(t,s) ((t)->tv_nsec=ST_MTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_mtime)
+#define tvgetctime(t,s) ((t)->tv_nsec=ST_CTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_ctime)
+
+#define tvsetatime(t,s) (ST_ATIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_atime=(t)->tv_sec)
+#define tvsetmtime(t,s) (ST_MTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_mtime=(t)->tv_sec)
+#define tvsetctime(t,s) (ST_CTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_ctime=(t)->tv_sec)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int tvgettime __PROTO__((Tv_t*));
+extern __MANGLE__ int tvsettime __PROTO__((const Tv_t*));
+extern __MANGLE__ int tvcmp __PROTO__((const Tv_t*, const Tv_t*));
+extern __MANGLE__ int tvtouch __PROTO__((const char*, const Tv_t*, const Tv_t*, const Tv_t*, int));
+extern __MANGLE__ int tvsleep __PROTO__((const Tv_t*, Tv_t*));
+
+extern __MANGLE__ char* fmttv __PROTO__((const char*, Tv_t*));
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/usage.h b/usr/src/lib/libast/sparcv9/include/ast/usage.h
new file mode 100644
index 0000000000..81b59e1aca
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/usage.h
@@ -0,0 +1,37 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * error catalog and usage defaults
+ */
+
+#ifndef _USAGE_H
+#define _USAGE_H
+
+#ifndef ERROR_CATALOG
+#define ERROR_CATALOG 0
+#endif
+
+#ifndef USAGE_LICENSE
+#define USAGE_LICENSE "[-license?THIS IS AN UNLICENSED COPY]"
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/vdb.h b/usr/src/lib/libast/sparcv9/include/ast/vdb.h
new file mode 100644
index 0000000000..63e310c724
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/vdb.h
@@ -0,0 +1,55 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * virtual db file directory entry constants
+ */
+
+#ifndef VDB_MAGIC
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+
+#define VDB_MAGIC "vdb"
+
+#define VDB_DIRECTORY "DIRECTORY"
+#define VDB_UNION "UNION"
+#define VDB_DATE "DATE"
+#define VDB_MODE "MODE"
+
+#define VDB_DELIMITER ';'
+#define VDB_IGNORE '_'
+#define VDB_FIXED 10
+#define VDB_LENGTH ((int)sizeof(VDB_DIRECTORY)+2*(VDB_FIXED+1))
+#define VDB_OFFSET ((int)sizeof(VDB_DIRECTORY))
+#define VDB_SIZE (VDB_OFFSET+VDB_FIXED+1)
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/vecargs.h b/usr/src/lib/libast/sparcv9/include/ast/vecargs.h
new file mode 100644
index 0000000000..4d329cd154
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/vecargs.h
@@ -0,0 +1,56 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * vector argument interface definitions
+ */
+
+#ifndef _VECARGS_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _VECARGS_H
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int vecargs __PROTO__((char**, int*, char***));
+extern __MANGLE__ char** vecfile __PROTO__((const char*));
+extern __MANGLE__ void vecfree __PROTO__((char**, int));
+extern __MANGLE__ char** vecload __PROTO__((char*));
+extern __MANGLE__ char** vecstring __PROTO__((const char*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/vmalloc.h b/usr/src/lib/libast/sparcv9/include/ast/vmalloc.h
new file mode 100644
index 0000000000..f0a8114c6a
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/vmalloc.h
@@ -0,0 +1,315 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#ifndef _VMALLOC_H
+#define _VMALLOC_H 1
+
+/* Public header file for the virtual malloc package.
+**
+** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94.
+*/
+
+#define VMALLOC_VERSION 20050928L
+
+#if _PACKAGE_ast
+#include <ast_std.h>
+#else
+#include <ast_common.h>
+#endif
+
+typedef struct _vmalloc_s Vmalloc_t;
+typedef struct _vmstat_s Vmstat_t;
+typedef struct _vmdisc_s Vmdisc_t;
+typedef struct _vmethod_s Vmethod_t;
+typedef Void_t* (*Vmemory_f)_ARG_((Vmalloc_t*, Void_t*, size_t, size_t, Vmdisc_t*));
+typedef int (*Vmexcept_f)_ARG_((Vmalloc_t*, int, Void_t*, Vmdisc_t*));
+
+struct _vmstat_s
+{ int n_busy; /* number of busy blocks */
+ int n_free; /* number of free blocks */
+ size_t s_busy; /* total amount of busy space */
+ size_t s_free; /* total amount of free space */
+ size_t m_busy; /* largest busy piece */
+ size_t m_free; /* largest free piece */
+ int n_seg; /* number of segments */
+ size_t extent; /* total size of region */
+};
+
+struct _vmdisc_s
+{ Vmemory_f memoryf; /* memory manipulator */
+ Vmexcept_f exceptf; /* exception handler */
+ size_t round; /* rounding requirement */
+};
+
+struct _vmethod_s
+{ Void_t* (*allocf)_ARG_((Vmalloc_t*,size_t));
+ Void_t* (*resizef)_ARG_((Vmalloc_t*,Void_t*,size_t,int));
+ int (*freef)_ARG_((Vmalloc_t*,Void_t*));
+ long (*addrf)_ARG_((Vmalloc_t*,Void_t*));
+ long (*sizef)_ARG_((Vmalloc_t*,Void_t*));
+ int (*compactf)_ARG_((Vmalloc_t*));
+ Void_t* (*alignf)_ARG_((Vmalloc_t*,size_t,size_t));
+ unsigned short meth;
+};
+
+struct _vmalloc_s
+{ Vmethod_t meth; /* method for allocation */
+ char* file; /* file name */
+ int line; /* line number */
+ Void_t* func; /* calling function */
+#ifdef _VM_PRIVATE_
+ _VM_PRIVATE_
+#endif
+};
+
+#undef VM_FLAGS /* solaris sys kernel clash */
+
+#define VM_TRUST 0000001 /* forgo some security checks */
+#define VM_TRACE 0000002 /* generate trace */
+#define VM_DBCHECK 0000004 /* check for boundary overwrite */
+#define VM_DBABORT 0000010 /* abort on any warning */
+#define VM_FLAGS 0000017 /* user-settable flags */
+
+#define VM_MTBEST 0000100 /* Vmbest method */
+#define VM_MTPOOL 0000200 /* Vmpool method */
+#define VM_MTLAST 0000400 /* Vmlast method */
+#define VM_MTDEBUG 0001000 /* Vmdebug method */
+#define VM_MTPROFILE 0002000 /* Vmdebug method */
+#define VM_METHODS 0003700 /* available allocation methods */
+
+#define VM_RSCOPY 0000001 /* copy old contents */
+#define VM_RSMOVE 0000002 /* old contents is moveable */
+#define VM_RSZERO 0000004 /* clear new space */
+
+/* exception types */
+#define VM_OPEN 0 /* region being opened */
+#define VM_CLOSE 1 /* announce being closed */
+#define VM_NOMEM 2 /* can't obtain memory */
+#define VM_BADADDR 3 /* bad addr in vmfree/vmresize */
+#define VM_DISC 4 /* discipline being changed */
+#define VM_ALLOC 5 /* announcement from vmalloc() */
+#define VM_FREE 6 /* announcement from vmfree() */
+#define VM_RESIZE 7 /* announcement from vmresize() */
+
+_BEGIN_EXTERNS_ /* public data */
+#if _BLD_vmalloc && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+#if !_BLD_vmalloc && defined(__IMPORT__)
+#define extern extern __IMPORT__
+#endif
+
+extern Vmethod_t* Vmbest; /* best allocation */
+extern Vmethod_t* Vmlast; /* last-block allocation */
+extern Vmethod_t* Vmpool; /* pool allocation */
+extern Vmethod_t* Vmdebug; /* allocation with debugging */
+extern Vmethod_t* Vmprofile; /* profiling memory usage */
+
+extern Vmdisc_t* Vmdcheap; /* heap discipline */
+extern Vmdisc_t* Vmdcsbrk; /* sbrk discipline */
+
+extern Vmalloc_t* Vmheap; /* heap region */
+extern Vmalloc_t* Vmregion; /* malloc region */
+
+#undef extern
+_END_EXTERNS_
+
+_BEGIN_EXTERNS_ /* public functions */
+#if _BLD_vmalloc && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern Vmalloc_t* vmopen _ARG_(( Vmdisc_t*, Vmethod_t*, int ));
+extern int vmclose _ARG_(( Vmalloc_t* ));
+extern int vmclear _ARG_(( Vmalloc_t* ));
+extern int vmcompact _ARG_(( Vmalloc_t* ));
+
+extern Vmdisc_t* vmdisc _ARG_(( Vmalloc_t*, Vmdisc_t* ));
+
+extern Vmalloc_t* vmmopen _ARG_(( char*, Void_t*, size_t ));
+extern Void_t* vmmset _ARG_((Vmalloc_t*, int, Void_t*, int));
+
+extern Void_t* vmalloc _ARG_(( Vmalloc_t*, size_t ));
+extern Void_t* vmalign _ARG_(( Vmalloc_t*, size_t, size_t ));
+extern Void_t* vmresize _ARG_(( Vmalloc_t*, Void_t*, size_t, int ));
+extern Void_t* vmgetmem _ARG_(( Vmalloc_t*, Void_t*, size_t ));
+extern int vmfree _ARG_(( Vmalloc_t*, Void_t* ));
+
+extern long vmaddr _ARG_(( Vmalloc_t*, Void_t* ));
+extern long vmsize _ARG_(( Vmalloc_t*, Void_t* ));
+
+extern Vmalloc_t* vmregion _ARG_(( Void_t* ));
+extern Void_t* vmsegment _ARG_(( Vmalloc_t*, Void_t* ));
+extern int vmset _ARG_(( Vmalloc_t*, int, int ));
+
+extern Void_t* vmdbwatch _ARG_(( Void_t* ));
+extern int vmdbcheck _ARG_(( Vmalloc_t* ));
+extern int vmdebug _ARG_(( int ));
+
+extern int vmprofile _ARG_(( Vmalloc_t*, int ));
+
+extern int vmtrace _ARG_(( int ));
+extern int vmtrbusy _ARG_((Vmalloc_t*));
+
+extern int vmstat _ARG_((Vmalloc_t*, Vmstat_t*));
+
+extern int vmwalk _ARG_((Vmalloc_t*,
+ int(*)(Vmalloc_t*,Void_t*,size_t,Vmdisc_t*)));
+extern char* vmstrdup _ARG_((Vmalloc_t*, const char*));
+
+#if !defined(_BLD_vmalloc) && !defined(_AST_STD_H) && \
+ !defined(__stdlib_h) && !defined(__STDLIB_H) && \
+ !defined(_STDLIB_INCLUDED) && !defined(_INC_STDLIB)
+extern Void_t* malloc _ARG_(( size_t ));
+extern Void_t* realloc _ARG_(( Void_t*, size_t ));
+extern void free _ARG_(( Void_t* ));
+extern void cfree _ARG_(( Void_t* ));
+extern Void_t* calloc _ARG_(( size_t, size_t ));
+extern Void_t* memalign _ARG_(( size_t, size_t ));
+extern Void_t* valloc _ARG_(( size_t ));
+#endif
+
+#undef extern
+_END_EXTERNS_
+
+/* to coerce any value to a Vmalloc_t*, make ANSI happy */
+#define _VM_(vm) ((Vmalloc_t*)(vm))
+
+/* enable recording of where a call originates from */
+#ifdef VMFL
+
+#if defined(__FILE__)
+#define _VMFILE_(vm) (_VM_(vm)->file = (char*)__FILE__)
+#else
+#define _VMFILE_(vm) (_VM_(vm)->file = 0)
+#endif
+
+#if defined(__LINE__)
+#define _VMLINE_(vm) (_VM_(vm)->line = __LINE__)
+#else
+#define _VMLINE_(vm) (_VM_(vm)->line = 0)
+#endif
+
+#if defined(__FUNCTION__)
+#define _VMFUNC_(vm) (_VM_(vm)->func = (Void_t*)__FUNCTION__)
+#else
+#define _VMFUNC_(vm) (_VM_(vm)->func = 0)
+#endif
+
+#define _VMFL_(vm) (_VMFILE_(vm), _VMLINE_(vm), _VMFUNC_(vm))
+
+#define vmalloc(vm,sz) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.allocf))((vm),(sz)) )
+#define vmresize(vm,d,sz,type) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.resizef))\
+ ((vm),(Void_t*)(d),(sz),(type)) )
+#define vmfree(vm,d) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.freef))((vm),(Void_t*)(d)) )
+#define vmalign(vm,sz,align) (_VMFL_(vm), \
+ (*(_VM_(vm)->meth.alignf))((vm),(sz),(align)) )
+
+#undef malloc
+#undef realloc
+#undef calloc
+#undef free
+#undef memalign
+#undef valloc
+
+#if _map_malloc
+
+#define malloc(s) (_VMFL_(Vmregion), _ast_malloc((size_t)(s)) )
+#define realloc(d,s) (_VMFL_(Vmregion), _ast_realloc((Void_t*)(d),(size_t)(s)) )
+#define calloc(n,s) (_VMFL_(Vmregion), _ast_calloc((size_t)n, (size_t)(s)) )
+#define free(d) (_VMFL_(Vmregion), _ast_free((Void_t*)(d)) )
+#define memalign(a,s) (_VMFL_(Vmregion), _ast_memalign((size_t)(a),(size_t)(s)) )
+#define valloc(s) (_VMFL_(Vmregion), _ast_valloc((size_t)(s) )
+
+#else
+
+#if !_std_malloc
+
+#if __STD_C || defined(__STDPP__) || defined(__GNUC__)
+#define malloc(s) ( _VMFL_(Vmregion), (malloc)((size_t)(s)) )
+#define realloc(d,s) ( _VMFL_(Vmregion), (realloc)((Void_t*)(d),(size_t)(s)) )
+#define calloc(n,s) ( _VMFL_(Vmregion), (calloc)((size_t)n, (size_t)(s)) )
+#define free(d) ( _VMFL_(Vmregion), (free)((Void_t*)(d)) )
+#define memalign(a,s) ( _VMFL_(Vmregion), (memalign)((size_t)(a),(size_t)(s)) )
+#define valloc(s) ( _VMFL_(Vmregion), (valloc)((size_t)(s)) )
+#ifndef strdup
+#define strdup(s) ( _VMFL_(Vmregion), (strdup)((char*)(s)) )
+#endif
+
+#else
+
+#define _VMNM_(a,b,c,d,e,f) a/**/b/**/c/**/d/**/e/**/f
+#define malloc(s) ( _VMFL_(Vmregion), _VMNM_(mallo,/,*,*,/,c)\
+ ( (size_t)(s)) )
+#define realloc(d,s) ( _VMFL_(Vmregion), _VMNM_(reallo,/,*,*,/,c)\
+ ( (Void_t*)(d),(size_t)(s)) )
+#define calloc(n,s) ( _VMFL_(Vmregion), _VMNM_(callo,/,*,*,/,c)\
+ ( (size_t)n, (size_t)(s)) )
+#define free(d) ( _VMFL_(Vmregion), _VMNM_(fre,/,*,*,/,e)((Void_t*)(d)) )
+#define memalign(a,s) ( _VMFL_(Vmregion), _VMNM_(memalig,/,*,*,/,n)\
+ ( (size_t)(a),(size_t)(s)) )
+#define valloc(s) ( _VMFL_(Vmregion), _VMNM_(vallo,/,*,*,/,c)\
+ ( (size_t)(s)) )
+#ifndef strdup
+#define strdup(s) ( _VMFL_(Vmregion), _VMNM_(strdu,/,*,*,/,p)\
+ ((char*)(s)) )
+#endif
+
+#endif /*__STD_C || defined(__STDPP__) || defined(__GNUC__)*/
+
+#define cfree(d) free(d)
+
+#endif /* !_std_malloc */
+
+#endif /* _map_malloc */
+
+#endif /*VMFL*/
+
+/* non-debugging/profiling allocation calls */
+#ifndef vmalloc
+#define vmalloc(vm,sz) (*(_VM_(vm)->meth.allocf))((vm),(sz))
+#endif
+
+#ifndef vmresize
+#define vmresize(vm,d,sz,type) (*(_VM_(vm)->meth.resizef))\
+ ((vm),(Void_t*)(d),(sz),(type))
+#endif
+
+#ifndef vmfree
+#define vmfree(vm,d) (*(_VM_(vm)->meth.freef))((vm),(Void_t*)(d))
+#endif
+
+#ifndef vmalign
+#define vmalign(vm,sz,align) (*(_VM_(vm)->meth.alignf))((vm),(sz),(align))
+#endif
+
+#define vmaddr(vm,addr) (*(_VM_(vm)->meth.addrf))((vm),(Void_t*)(addr))
+#define vmsize(vm,addr) (*(_VM_(vm)->meth.sizef))((vm),(Void_t*)(addr))
+#define vmcompact(vm) (*(_VM_(vm)->meth.compactf))((vm))
+#define vmoldof(v,p,t,n,x) (t*)vmresize((v), (p), sizeof(t)*(n)+(x), \
+ (VM_RSMOVE) )
+#define vmnewof(v,p,t,n,x) (t*)vmresize((v), (p), sizeof(t)*(n)+(x), \
+ (VM_RSMOVE|VM_RSCOPY|VM_RSZERO) )
+
+#endif /* _VMALLOC_H */
diff --git a/usr/src/lib/libast/sparcv9/include/ast/wait.h b/usr/src/lib/libast/sparcv9/include/ast/wait.h
new file mode 100644
index 0000000000..6910081961
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/wait.h
@@ -0,0 +1,107 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * ast POSIX wait/exit support
+ */
+
+#ifndef _WAIT_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _WAIT_H
+
+#include <ast.h>
+#include <ast_wait.h>
+
+#if _sys_wait
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide wait waitpid
+#else
+#define wait ______wait
+#define waitpid ______waitpid
+#endif
+#include <sys/wait.h>
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide wait waitpid
+#else
+#undef wait
+#undef waitpid
+#endif
+#endif
+
+#ifndef WNOHANG
+#define WNOHANG 1
+#endif
+
+#ifndef WUNTRACED
+#define WUNTRACED 2
+#endif
+
+#if !_ok_wif
+#undef WIFEXITED
+#undef WEXITSTATUS
+#undef WIFSIGNALED
+#undef WTERMSIG
+#undef WIFSTOPPED
+#undef WSTOPSIG
+#undef WTERMCORE
+#endif
+
+#ifndef WIFEXITED
+#define WIFEXITED(x) (!((x)&((1<<(EXIT_BITS-1))-1)))
+#endif
+
+#ifndef WEXITSTATUS
+#define WEXITSTATUS(x) (((x)>>EXIT_BITS)&((1<<EXIT_BITS)-1))
+#endif
+
+#ifndef WIFSIGNALED
+#define WIFSIGNALED(x) (((x)&((1<<(EXIT_BITS-1))-1))!=0)
+#endif
+
+#ifndef WTERMSIG
+#define WTERMSIG(x) ((x)&((1<<(EXIT_BITS-1))-1))
+#endif
+
+#ifndef WIFSTOPPED
+#define WIFSTOPPED(x) (((x)&((1<<EXIT_BITS)-1))==((1<<(EXIT_BITS-1))-1))
+#endif
+
+#ifndef WSTOPSIG
+#define WSTOPSIG(x) WEXITSTATUS(x)
+#endif
+
+#ifndef WTERMCORE
+#define WTERMCORE(x) ((x)&(1<<(EXIT_BITS-1)))
+#endif
+
+extern __MANGLE__ pid_t wait __PROTO__((int*));
+extern __MANGLE__ pid_t waitpid __PROTO__((pid_t, int*, int));
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/include/ast/wchar.h b/usr/src/lib/libast/sparcv9/include/ast/wchar.h
new file mode 100644
index 0000000000..557a403adc
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/wchar.h
@@ -0,0 +1,22 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include <ast_wchar.h>
diff --git a/usr/src/lib/libast/sparcv9/include/ast/wordexp.h b/usr/src/lib/libast/sparcv9/include/ast/wordexp.h
new file mode 100644
index 0000000000..b2e80d9f35
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/include/ast/wordexp.h
@@ -0,0 +1,74 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * posix wordexp interface definitions
+ */
+
+#ifndef _WORDEXP_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _WORDEXP_H
+
+#include <ast_common.h>
+
+#define WRDE_APPEND 01
+#define WRDE_DOOFFS 02
+#define WRDE_NOCMD 04
+#define WRDE_NOSYS 0100
+#define WRDE_REUSE 010
+#define WRDE_SHOWERR 020
+#define WRDE_UNDEF 040
+
+#define WRDE_BADCHAR 1
+#define WRDE_BADVAL 2
+#define WRDE_CMDSUB 3
+#define WRDE_NOSPACE 4
+#define WRDE_SYNTAX 5
+#define WRDE_NOSHELL 6
+
+typedef struct _wdarg
+{
+ size_t we_wordc;
+ char **we_wordv;
+ size_t we_offs;
+} wordexp_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int wordexp __PROTO__((const char*, wordexp_t*, int));
+extern __MANGLE__ int wordfree __PROTO__((wordexp_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif /* _WORDEXP_H */
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/align b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/align
new file mode 100644
index 0000000000..67bdb68aae
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/align
@@ -0,0 +1,33 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/align.c by iffe version 2007-04-04 : : */
+#ifndef _def_align_ast
+#define _def_align_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+typedef unsigned long ALIGN_INTEGRAL;
+
+#define ALIGN_CHUNK 8192
+#define ALIGN_INTEGRAL long
+#define ALIGN_INTEGER(x) ((ALIGN_INTEGRAL)(x))
+#define ALIGN_POINTER(x) ((char*)(x))
+#define ALIGN_ROUND(x,y) ALIGN_POINTER(ALIGN_INTEGER((x)+(y)-1)&~((y)-1))
+
+#define ALIGN_BOUND ALIGN_BOUND2
+#define ALIGN_ALIGN(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC(x) ALIGN_TRUNC2(x)
+
+#define ALIGN_BIT1 0x1
+#define ALIGN_BOUND1 ALIGN_BOUND2
+#define ALIGN_ALIGN1(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC1(x) ALIGN_TRUNC2(x)
+#define ALIGN_CLRBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffffe)
+#define ALIGN_SETBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x1)
+#define ALIGN_TSTBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x1)
+
+#define ALIGN_BIT2 0x2
+#define ALIGN_BOUND2 16
+#define ALIGN_ALIGN2(x) ALIGN_TRUNC2((x)+15)
+#define ALIGN_TRUNC2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffff0)
+#define ALIGN_CLRBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffffd)
+#define ALIGN_SETBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x2)
+#define ALIGN_TSTBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x2)
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/botch b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/botch
new file mode 100644
index 0000000000..bd5405c63c
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/botch
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/botch.c by iffe version 2007-04-04 : : */
+#ifndef _def_botch_ast
+#define _def_botch_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/ccode b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/ccode
new file mode 100644
index 0000000000..7055bf926b
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/ccode
@@ -0,0 +1,29 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/ccode by iffe version 2007-04-04 : : */
+#ifndef _def_ccode_ast
+#define _def_ccode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define CC_ASCII 1 /* ISO-8859-1 */
+#define CC_EBCDIC_E 2 /* Xopen dd(1) EBCDIC */
+#define CC_EBCDIC_I 3 /* Xopen dd(1) IBM */
+#define CC_EBCDIC_O 4 /* IBM-1047 mvs OpenEdition */
+#define CC_EBCDIC_S 5 /* Siemens posix-bc */
+#define CC_EBCDIC_H 6 /* IBM-37 AS/400 */
+#define CC_EBCDIC_M 7 /* IBM mvs cobol */
+#define CC_EBCDIC_U 8 /* microfocus cobol */
+
+#define CC_MAPS 8 /* number of code maps */
+
+#define CC_EBCDIC CC_EBCDIC_E
+#define CC_EBCDIC1 CC_EBCDIC_E
+#define CC_EBCDIC2 CC_EBCDIC_I
+#define CC_EBCDIC3 CC_EBCDIC_O
+
+#define CC_NATIVE CC_ASCII /* native character code */
+#define CC_ALIEN CC_EBCDIC /* alien character code */
+
+#define CC_bel 0007 /* bel character */
+#define CC_esc 0033 /* esc character */
+#define CC_sub 0032 /* sub character */
+#define CC_vt 0013 /* vt character */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/common b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/common
new file mode 100644
index 0000000000..858d0995e7
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/common
@@ -0,0 +1,200 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/common by iffe version 2007-04-04 : : */
+#ifndef _AST_COMMON_H
+#define _AST_COMMON_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_pthread 1 /* #include <pthread.h> ok */
+#define _hdr_stdarg 1 /* #include <stdarg.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdint 1 /* #include <stdint.h> ok */
+#define _hdr_inttypes 1 /* #include <inttypes.h> ok */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_long_double 1 /* long double is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _std_proto 1 /* standard C prototypes ok */
+#define _ptr_void 1 /* standard C void* ok */
+/* disable non-standard linux/gnu inlines */
+#ifdef __GNUC__
+# undef __OPTIMIZE_SIZE__
+# define __OPTIMIZE_SIZE__ 1
+#endif
+
+/* __STD_C indicates that the language is ANSI-C or C++ */
+#if !defined(__STD_C) && __STDC__
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && (__cplusplus || c_plusplus)
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && _std_proto
+# define __STD_C 1
+#endif
+#if !defined(__STD_C)
+# define __STD_C 0
+#endif
+
+/* extern symbols must be protected against C++ name mangling */
+#ifndef _BEGIN_EXTERNS_
+# if __cplusplus || c_plusplus
+# define _BEGIN_EXTERNS_ extern "C" {
+# define _END_EXTERNS_ }
+# else
+# define _BEGIN_EXTERNS_
+# define _END_EXTERNS_
+# endif
+#endif
+
+/* _ARG_ simplifies function prototyping among flavors of C */
+#ifndef _ARG_
+# if __STD_C
+# define _ARG_(x) x
+# else
+# define _ARG_(x) ()
+# endif
+#endif
+
+/* _NIL_ simplifies defining nil pointers to a given type */
+#ifndef _NIL_
+# define _NIL_(x) ((x)0)
+#endif
+
+/* __INLINE__ is the inline keyword */
+#if !defined(__INLINE__) && defined(__cplusplus)
+# define __INLINE__ inline
+#endif
+#if !defined(__INLINE__) && defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+#endif
+
+/* Void_t is defined so that Void_t* can address any type */
+#ifndef Void_t
+# if __STD_C
+# define Void_t void
+# else
+# define Void_t char
+# endif
+#endif
+
+/* windows variants and veneers */
+#if !defined(_WINIX) && (_UWIN || __CYGWIN__ || __EMX__)
+# define _WINIX 1
+#endif
+
+/* dynamic linked library external scope handling */
+#ifdef __DYNAMIC__
+# undef __DYNAMIC__
+# ifndef _DLL
+# define _DLL 1
+# endif
+#endif
+#if _dll_import
+# if _BLD_STATIC && !_BLD_DLL
+# undef _DLL
+# else
+# if !_UWIN && !defined(_DLL)
+# define _DLL 1
+# endif
+# endif
+# if !defined(__EXPORT__) && _BLD_DLL
+# define __EXPORT__ __declspec(dllexport)
+# endif
+# if !defined(__IMPORT__) && ( _BLD_DLL || defined(_DLL) )
+# define __IMPORT__ __declspec(dllimport)
+# endif
+# if _BLD_DLL && _UWIN
+# define __DYNAMIC__(v) (_ast_getdll()->_ast_ ## v)
+# endif
+#endif
+#if !defined(_astimport)
+# if defined(__IMPORT__) && defined(_DLL)
+# define _astimport __IMPORT__
+# else
+# define _astimport extern
+# endif
+#endif
+#if _dll_import && ( !_BLD_DLL || _WINIX && !_UWIN )
+# ifdef __STDC__
+# define __EXTERN__(T,obj) extern T obj; T* _imp__ ## obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__ ## obj = &obj
+# else
+# define __EXTERN__(T,obj) extern T obj; T* _imp__/**/obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__/**/obj = &obj
+# endif
+#else
+# define __EXTERN__(T,obj) extern T obj
+# define __DEFINE__(T,obj,val) T obj = val
+#endif
+
+#define _ast_LL 1 /* LL numeric suffix supported */
+#define _ast_int1_t char
+#define _ast_int2_t short
+#define _ast_int4_t int
+#define _ast_int8_t long
+#define _ast_intmax_t _ast_int8_t
+#define _ast_intmax_long 1
+#define _ast_intswap 0
+
+#define _ast_flt4_t float
+#define _ast_flt8_t double
+#define _ast_flt16_t long double
+#define _ast_fltmax_t _ast_flt16_t
+#define _typ_int8_t 1 /* int8_t is a type */
+#define _typ_uint8_t 1 /* uint8_t is a type */
+#define _typ_int16_t 1 /* int16_t is a type */
+#define _typ_uint16_t 1 /* uint16_t is a type */
+#define _typ_int32_t 1 /* int32_t is a type */
+#define _typ_uint32_t 1 /* uint32_t is a type */
+#define _typ_int64_t 1 /* int64_t is a type */
+#define _typ_uint64_t 1 /* uint64_t is a type */
+#define _typ_intmax_t 1 /* intmax_t is a type */
+#define _typ_uintmax_t 1 /* uintmax_t is a type */
+
+#ifndef va_listref
+#define va_listref(p) (p) /* pass va_list to varargs function */
+#define va_listval(p) (p) /* retrieve va_list from va_arg(ap,va_listarg) */
+#define va_listarg va_list /* va_arg() va_list type */
+#ifndef va_start
+#if __STD_C
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+#endif
+#ifndef _AST_STD_H
+# if __STD_C && _hdr_stddef
+# include <stddef.h>
+# endif
+# if _sys_types
+# include <sys/types.h>
+# endif
+# if _hdr_stdint
+# include <stdint.h>
+# else
+# if _hdr_inttypes
+# include <inttypes.h>
+# endif
+# endif
+#endif
+#if !_typ_size_t
+# define _typ_size_t 1
+ typedef int size_t;
+#endif
+#if !_typ_ssize_t
+# define _typ_ssize_t 1
+ typedef int ssize_t;
+#endif
+#ifndef _AST_STD_H
+# define _def_map_ast 1
+# if !_def_map_ast
+# include <ast_map.h>
+# endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/dirent b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/dirent
new file mode 100644
index 0000000000..5c447ac078
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/dirent
@@ -0,0 +1,82 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/dirent by iffe version 2007-04-04 : : */
+
+#ifndef _def_dirent_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dirent_ast 1
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _nxt_dirent <../include/dirent.h> /* include path for the native <dirent.h> */
+#define _nxt_dirent_str "../include/dirent.h" /* include string for the native <dirent.h> */
+/*
+ * <dirent.h> for systems with ok <dirent.h>
+ */
+
+#ifndef _DIRENT_H
+
+#include <../include/dirent.h> /* the native <dirent.h> */
+
+#ifndef _DIRENT_H
+#define _DIRENT_H
+#endif
+
+#endif
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/eaccess b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/eaccess
new file mode 100644
index 0000000000..c2ebb0ca07
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/eaccess
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/eaccess by iffe version 2007-04-04 : : */
+#ifndef _def_eaccess_ast
+#define _def_eaccess_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/errno b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/errno
new file mode 100644
index 0000000000..85bd48edd7
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/errno
@@ -0,0 +1,7 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/errno by iffe version 2007-04-04 : : */
+#ifndef _def_errno_ast
+#define _def_errno_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _dat_sys_nerr 1 /* sys_nerr in default libs */
+#define _dat_sys_errlist 1 /* sys_errlist in default libs */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/fcntl b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/fcntl
new file mode 100644
index 0000000000..156e2ec213
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/fcntl
@@ -0,0 +1,114 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/fcntl.c by iffe version 2007-04-04 : : */
+#ifndef _def_fcntl_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fcntl_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <ast_fs.h>
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#define O_BINARY 0
+#define O_TEMPORARY 0
+#define O_TEXT 0
+
+#include <ast_fs.h>
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_fstat64
+#define fstat fstat64
+#endif
+#if _lib_lstat64
+#define lstat lstat64
+#endif
+#if _lib_stat64
+#define stat stat64
+#endif
+#if _lib_creat64
+#define creat creat64
+#endif
+#if _lib_mmap64
+#define mmap mmap64
+#endif
+#if _lib_open64
+#undef open
+#define open open64
+#endif
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/float b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/float
new file mode 100644
index 0000000000..de179a370c
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/float
@@ -0,0 +1,212 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/float by iffe version 2007-04-04 : : */
+
+#ifndef _def_float_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_float_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_float 1 /* #include <float.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _hdr_values 1 /* #include <values.h> ok */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_frexp 1 /* frexp() in default lib(s) */
+#define _lib_frexpl 1 /* frexpl() in default lib(s) */
+#define _lib_ldexp 1 /* ldexp() in default lib(s) */
+#define _lib_ldexpl 1 /* ldexpl() in default lib(s) */
+#define _lib_finite 1 /* finite() in default lib(s) */
+#define _lib_isnan 1 /* isnan() in default lib(s) */
+#define _lib_isnanl 1 /* isnanl() in default lib(s) */
+#define _lib_copysign 1 /* copysign() in default lib(s) */
+#define _lib_copysignl 1 /* copysignl() in default lib(s) */
+#include <ast_common.h>
+#include <float.h>
+#include <math.h>
+#ifndef FLT_DIG
+#define FLT_DIG 6
+#endif
+#ifndef FLT_MAX
+#define FLT_MAX 3.4028234663852885981170E+38F
+#endif
+#ifndef FLT_MAX_10_EXP
+#define FLT_MAX_10_EXP ( + 38 )
+#endif
+#ifndef FLT_MAX_EXP
+#define FLT_MAX_EXP ( + 128 )
+#endif
+#ifndef FLT_MIN
+#define FLT_MIN 1.1754943508222875079688E-38F
+#endif
+#ifndef FLT_MIN_10_EXP
+#define FLT_MIN_10_EXP ( - 37 )
+#endif
+#ifndef FLT_MIN_EXP
+#define FLT_MIN_EXP ( - 125 )
+#endif
+#ifndef DBL_DIG
+#define DBL_DIG 15
+#endif
+#ifndef DBL_MAX
+#define DBL_MAX 1.7976931348623157081452E+308
+#endif
+#ifndef DBL_MAX_10_EXP
+#define DBL_MAX_10_EXP ( + 308 )
+#endif
+#ifndef DBL_MAX_EXP
+#define DBL_MAX_EXP ( + 1024 )
+#endif
+#ifndef DBL_MIN
+#define DBL_MIN 2.2250738585072013830903E-308
+#endif
+#ifndef DBL_MIN_10_EXP
+#define DBL_MIN_10_EXP ( - 307 )
+#endif
+#ifndef DBL_MIN_EXP
+#define DBL_MIN_EXP ( - 1021 )
+#endif
+#ifndef LDBL_DIG
+#define LDBL_DIG 33
+#endif
+#ifndef LDBL_MAX
+#define LDBL_MAX 1.189731495357231765085759326628007016E+4932L
+#endif
+#ifndef LDBL_MAX_10_EXP
+#define LDBL_MAX_10_EXP ( + 4932 )
+#endif
+#ifndef LDBL_MAX_EXP
+#define LDBL_MAX_EXP ( + 16384 )
+#endif
+#ifndef LDBL_MIN
+#define LDBL_MIN 3.362103143112093506262677817321752603E-4932L
+#endif
+#ifndef LDBL_MIN_10_EXP
+#define LDBL_MIN_10_EXP ( - 4931 )
+#endif
+#ifndef LDBL_MIN_EXP
+#define LDBL_MIN_EXP ( - 16381 )
+#endif
+
+
+#define USHRT_DIG 4
+#define UINT_DIG 9
+#define ULONG_DIG 19
+#define UINTMAX_DIG ULONG_DIG
+
+#define FLT_ULONG_MAX 18446744073709551615.0F
+#define FLT_ULLONG_MAX FLT_ULONG_MAX
+#define FLT_UINTMAX_MAX FLT_ULONG_MAX
+#define FLT_LONG_MAX 9223372036854775807.0F
+#define FLT_LLONG_MAX FLT_LONG_MAX
+#define FLT_INTMAX_MAX FLT_LONG_MAX
+#define FLT_LONG_MIN (-9223372036854775808.0F)
+#define FLT_LLONG_MIN FLT_LONG_MIN
+#define FLT_INTMAX_MIN FLT_LONG_MIN
+
+#define DBL_ULONG_MAX 18446744073709551615.0
+#define DBL_ULLONG_MAX DBL_ULONG_MAX
+#define DBL_UINTMAX_MAX DBL_ULONG_MAX
+#define DBL_LONG_MAX 9223372036854775807.0
+#define DBL_LLONG_MAX DBL_LONG_MAX
+#define DBL_INTMAX_MAX DBL_LONG_MAX
+#define DBL_LONG_MIN (-9223372036854775808.0)
+#define DBL_LLONG_MIN DBL_LONG_MIN
+#define DBL_INTMAX_MIN DBL_LONG_MIN
+
+#define LDBL_ULONG_MAX 18446744073709551615.0L
+#define LDBL_ULLONG_MAX LDBL_ULONG_MAX
+#define LDBL_UINTMAX_MAX LDBL_ULONG_MAX
+#define LDBL_LONG_MAX 9223372036854775807.0L
+#define LDBL_LLONG_MAX LDBL_LONG_MAX
+#define LDBL_INTMAX_MAX LDBL_LONG_MAX
+#define LDBL_LONG_MIN (-9223372036854775808.0L)
+#define LDBL_LLONG_MIN LDBL_LONG_MIN
+#define LDBL_INTMAX_MIN LDBL_LONG_MIN
+
+#define FLTMAX_UINTMAX_MAX LDBL_UINTMAX_MAX
+#define FLTMAX_INTMAX_MAX LDBL_INTMAX_MAX
+#define FLTMAX_INTMAX_MIN LDBL_INTMAX_MIN
+
+typedef union _ast_dbl_exp_u
+{
+ uint32_t e[sizeof(double)/4];
+ double f;
+} _ast_dbl_exp_t;
+
+#define _ast_dbl_exp_index 0
+#define _ast_dbl_exp_shift 20
+
+typedef union _fltmax_exp_u
+{
+ uint32_t e[sizeof(_ast_fltmax_t)/4];
+ _ast_fltmax_t f;
+} _ast_fltmax_exp_t;
+
+#define _ast_fltmax_exp_index 0
+#define _ast_fltmax_exp_shift 16
+
+#define _ast_flt_unsigned_max_t unsigned long long
+#define _ast_flt_nan_init 0x7f,0xff,0xff,0xff
+#define _ast_flt_inf_init 0x7f,0x80,0x00,0x00
+#define _ast_dbl_nan_init 0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff
+#define _ast_dbl_inf_init 0x7f,0xf0,0x00,0x00,0x00,0x00,0x00,0x00
+#define _ast_ldbl_nan_init 0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
+#define _ast_ldbl_inf_init 0x7f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/fs b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/fs
new file mode 100644
index 0000000000..d3e524a3d0
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/fs
@@ -0,0 +1,153 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/fs by iffe version 2007-04-04 : : */
+
+#ifndef _def_fs_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fs_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _lib_lstat 1 /* lstat() in default lib(s) */
+#define _lib_mknod 1 /* mknod() in default lib(s) */
+#define _lib_sync 1 /* sync() in default lib(s) */
+#include <sys/stat.h>
+#define FS_default "ufs"
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef major
+#define major(x) ( major_t ) ( ( ( ( unsigned ) ( ( x ) ) ) >> 8 ) & 0x7f )
+#endif
+#ifndef minor
+#define minor(x) ( minor_t ) ( ( ( x ) ) & 0xff )
+#endif
+#ifndef makedev
+#define makedev(x,y) ( unsigned short ) ( ( ( ( x ) ) << 8 ) | ( ( ( y ) ) & 0xff ) )
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _sys_mntent 1 /* #include <sys/mntent.h> ok */
+#define _sys_mnttab 1 /* #include <sys/mnttab.h> ok */
+#define _mem_st_blocks_stat 1 /* st_blocks is a member of struct stat */
+#define _mem_st_blksize_stat 1 /* st_blksize is a member of struct stat */
+#define _mem_st_rdev_stat 1 /* st_rdev is a member of struct stat */
+#define _sys_statfs 1 /* #include <sys/statfs.h> ok */
+#define _mem_f_files_statfs 1 /* f_files is a member of struct statfs */
+#define _sys_vfs 1 /* #include <sys/vfs.h> ok */
+#define _sys_param 1 /* #include <sys/param.h> ok */
+#define _sys_mount 1 /* #include <sys/mount.h> ok */
+#define _sys_statvfs 1 /* #include <sys/statvfs.h> ok */
+#define _mem_f_basetype_statvfs 1 /* f_basetype is a member of struct statvfs */
+#define _mem_f_frsize_statvfs 1 /* f_frsize is a member of struct statvfs */
+#define _lib_getmntent 1 /* getmntent() in default lib(s) */
+#define _lib_statfs 1 /* statfs() in default lib(s) */
+#define _lib_statvfs 1 /* statvfs() in default lib(s) */
+#define _lib_statfs4 1 /* compile{\ passed */
+#if _sys_statvfs
+#include <sys/statvfs.h>
+#if !_mem_statvfs_f_basetype
+#if _ary_f_reserved7
+#define f_basetype f_reserved7
+#endif
+#endif
+#else
+#define _mem_f_basetype_statvfs 1
+#define _mem_f_frsize_statvfs 1
+struct statvfs
+{
+unsigned long f_bsize; /* fundamental file system block size */
+unsigned long f_frsize; /* fragment size */
+unsigned long f_blocks; /* total # of blocks of f_frsize on fs */
+unsigned long f_bfree; /* total # of free blocks of f_frsize */
+unsigned long f_bavail; /* # of free blocks avail to non-superuser */
+unsigned long f_files; /* total # of file nodes (inodes) */
+unsigned long f_ffree; /* total # of free file nodes */
+unsigned long f_favail; /* # of free nodes avail to non-superuser */
+unsigned long f_fsid; /* file system id (dev for now) */
+char f_basetype[16]; /* target fs type name, null-terminated */
+unsigned long f_flag; /* bit-mask of flags */
+unsigned long f_namemax; /* maximum file name length */
+char f_fstr[32]; /* filesystem-specific string */
+unsigned long f_filler[16]; /* reserved for future expansion */
+};
+extern __MANGLE__ int fstatvfs __PROTO__((int, struct statvfs*));
+extern __MANGLE__ int statvfs __PROTO__((const char*, struct statvfs*));
+#endif
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_statvfs64 && !defined(statvfs)
+#define statvfs statvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int statvfs64 __PROTO__((const char*, struct statvfs64*));
+#endif
+#endif
+#if _lib_fstatvfs64 && !defined(fstatvfs)
+#define fstatvfs fstatvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int fstatvfs64 __PROTO__((int, struct statvfs64*));
+#endif
+#endif
+
+#define _str_st_fstype 1 /* stat.st_fstype is a string */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/hack b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/hack
new file mode 100644
index 0000000000..01e6e9f357
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/hack
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/hack by iffe version 2007-04-04 : : */
+#ifndef _def_hack_ast
+#define _def_hack_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/iconv b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/iconv
new file mode 100644
index 0000000000..2409c25672
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/iconv
@@ -0,0 +1,132 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/iconv by iffe version 2007-04-04 : : */
+
+#ifndef _def_iconv_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_iconv_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_iconv 1 /* #include <iconv.h> ok */
+#define _lib_iconv_open 1 /* iconv_open() in default lib(s) */
+#define _lib_iconv_close 1 /* iconv_close() in default lib(s) */
+#define _lib_iconv 1 /* iconv() in default lib(s) */
+#define _nxt_iconv <../include/iconv.h> /* include path for the native <iconv.h> */
+#define _nxt_iconv_str "../include/iconv.h" /* include string for the native <iconv.h> */
+#include <ast_common.h>
+#include <ccode.h>
+#include <../include/iconv.h> /* the native iconv.h */
+
+#define CC_ICONV (-1)
+#define CC_UCS (-2)
+#define CC_SCU (-3)
+#define CC_UTF (-4)
+#define CC_UME (-5)
+
+#ifndef _ICONV_LIST_PRIVATE_
+#undef iconv_t
+#define iconv_t _ast_iconv_t
+#undef iconv_f
+#define iconv_f _ast_iconv_f
+#undef iconv_list_t
+#define iconv_list_t _ast_iconv_list_t
+#undef iconv_open
+#define iconv_open _ast_iconv_open
+#undef iconv
+#define iconv _ast_iconv
+#undef iconv_close
+#define iconv_close _ast_iconv_close
+#undef iconv_list
+#define iconv_list _ast_iconv_list
+#undef iconv_move
+#define iconv_move _ast_iconv_move
+#undef iconv_name
+#define iconv_name _ast_iconv_name
+#undef iconv_write
+#define iconv_write _ast_iconv_write
+#endif
+
+typedef Ccmap_t _ast_iconv_list_t;
+typedef __V_* _ast_iconv_t;
+typedef size_t (*_ast_iconv_f) __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ _ast_iconv_t _ast_iconv_open __PROTO__((const char*, const char*));
+extern __MANGLE__ size_t _ast_iconv __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+extern __MANGLE__ int _ast_iconv_close __PROTO__((_ast_iconv_t));
+extern __MANGLE__ _ast_iconv_list_t* _ast_iconv_list __PROTO__((_ast_iconv_list_t*));
+extern __MANGLE__ int _ast_iconv_name __PROTO__((const char*, char*, size_t));
+#if _SFIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, Sfio_t*, Sfio_t*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, Sfio_t*, char**, size_t*, size_t*));
+#else
+#if _SFSTDIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, FILE*, FILE*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, FILE*, char**, size_t*, size_t*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/lib b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/lib
new file mode 100644
index 0000000000..c546bc76ef
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/lib
@@ -0,0 +1,160 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/lib by iffe version 2007-04-04 : : */
+#ifndef _def_lib_ast
+#define _def_lib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _hdr_fmtmsg 1 /* #include <fmtmsg.h> ok */
+#define _hdr_fnmatch 1 /* #include <fnmatch.h> ok */
+#define _hdr_libgen 1 /* #include <libgen.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_locale 1 /* #include <locale.h> ok */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_spawn 1 /* #include <spawn.h> ok */
+#define _hdr_syslog 1 /* #include <syslog.h> ok */
+#define _hdr_utime 1 /* #include <utime.h> ok */
+#define _hdr_wctype 1 /* #include <wctype.h> ok */
+#define _hdr_wchar 1 /* <wchar.h> and isw*() really work */
+#define _dat__tzname 1 /* _tzname in default lib(s) */
+#define _dat_tzname 1 /* tzname in default lib(s) */
+#define _lib__cleanup 1 /* _cleanup() in default lib(s) */
+#define _lib_atexit 1 /* atexit() in default lib(s) */
+#define _lib_bcopy 1 /* bcopy() in default lib(s) */
+#define _lib_bzero 1 /* bzero() in default lib(s) */
+#define _lib_catclose 1 /* catclose() in default lib(s) */
+#define _lib_catgets 1 /* catgets() in default lib(s) */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_confstr 1 /* confstr() in default lib(s) */
+#define _lib_dup2 1 /* dup2() in default lib(s) */
+#define _lib_execlp 1 /* execlp() in default lib(s) */
+#define _lib_execve 1 /* execve() in default lib(s) */
+#define _lib_execvp 1 /* execvp() in default lib(s) */
+#define _lib_fchmod 1 /* fchmod() in default lib(s) */
+#define _lib_fcntl 1 /* fcntl() in default lib(s) */
+#define _lib_fmtmsg 1 /* fmtmsg() in default lib(s) */
+#define _lib_fnmatch 1 /* fnmatch() in default lib(s) */
+#define _lib_fork 1 /* fork() in default lib(s) */
+#define _lib_fsync 1 /* fsync() in default lib(s) */
+#define _lib_getdents 1 /* getdents() in default lib(s) */
+#define _lib_getdtablesize 1 /* getdtablesize() in default lib(s) */
+#define _lib_getdate 1 /* getdate() in default lib(s) */
+#define _lib_getgroups 1 /* getgroups() in default lib(s) */
+#define _lib_gethostname 1 /* gethostname() in default lib(s) */
+#define _lib_getlogin 1 /* getlogin() in default lib(s) */
+#define _lib_getpagesize 1 /* getpagesize() in default lib(s) */
+#define _lib_getrlimit 1 /* getrlimit() in default lib(s) */
+#define _lib_getopt 1 /* getopt() in default lib(s) */
+#define _lib_getsubopt 1 /* getsubopt() in default lib(s) */
+#define _lib_getopt_long 1 /* getopt_long() in default lib(s) */
+#define _lib_getopt_long_only 1 /* getopt_long_only() in default lib(s) */
+#define _lib_glob 1 /* glob() in default lib(s) */
+#define _lib_index 1 /* index() in default lib(s) */
+#define _lib_iswblank 1 /* iswblank() in default lib(s) */
+#define _lib_iswctype 1 /* iswctype() in default lib(s) */
+#define _lib_killpg 1 /* killpg() in default lib(s) */
+#define _lib_link 1 /* link() in default lib(s) */
+#define _lib_localeconv 1 /* localeconv() in default lib(s) */
+#define _lib_madvise 1 /* madvise() in default lib(s) */
+#define _lib_mbtowc 1 /* mbtowc() in default lib(s) */
+#define _lib_mbrtowc 1 /* mbrtowc() in default lib(s) */
+#define _lib_memalign 1 /* memalign() in default lib(s) */
+#define _lib_memchr 1 /* memchr() in default lib(s) */
+#define _lib_memcpy 1 /* memcpy() in default lib(s) */
+#define _lib_memmove 1 /* memmove() in default lib(s) */
+#define _lib_memset 1 /* memset() in default lib(s) */
+#define _lib_mkdir 1 /* mkdir() in default lib(s) */
+#define _lib_mkfifo 1 /* mkfifo() in default lib(s) */
+#define _lib_mktemp 1 /* mktemp() in default lib(s) */
+#define _lib_mktime 1 /* mktime() in default lib(s) */
+#define _lib_mount 1 /* mount() in default lib(s) */
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _lib_pathconf 1 /* pathconf() in default lib(s) */
+#define _lib_readlink 1 /* readlink() in default lib(s) */
+#define _lib_remove 1 /* remove() in default lib(s) */
+#define _lib_rename 1 /* rename() in default lib(s) */
+#define _lib_rewinddir 1 /* rewinddir() in default lib(s) */
+#define _lib_rindex 1 /* rindex() in default lib(s) */
+#define _lib_rmdir 1 /* rmdir() in default lib(s) */
+#define _lib_setlocale 1 /* setlocale() in default lib(s) */
+#define _lib_setpgid 1 /* setpgid() in default lib(s) */
+#define _lib_setpgrp 1 /* setpgrp() in default lib(s) */
+#define _lib_setreuid 1 /* setreuid() in default lib(s) */
+#define _lib_setsid 1 /* setsid() in default lib(s) */
+#define _lib_setuid 1 /* setuid() in default lib(s) */
+#define _lib_sigaction 1 /* sigaction() in default lib(s) */
+#define _lib_sigprocmask 1 /* sigprocmask() in default lib(s) */
+#define _lib_socketpair 1 /* socketpair() in default lib(s) */
+#define _lib_strchr 1 /* strchr() in default lib(s) */
+#define _lib_strcoll 1 /* strcoll() in default lib(s) */
+#define _lib_strdup 1 /* strdup() in default lib(s) */
+#define _lib_strerror 1 /* strerror() in default lib(s) */
+#define _lib_strcasecmp 1 /* strcasecmp() in default lib(s) */
+#define _lib_strncasecmp 1 /* strncasecmp() in default lib(s) */
+#define _lib_strrchr 1 /* strrchr() in default lib(s) */
+#define _lib_strstr 1 /* strstr() in default lib(s) */
+#define _lib_strxfrm 1 /* strxfrm() in default lib(s) */
+#define _lib_strftime 1 /* strftime() in default lib(s) */
+#define _lib_swab 1 /* swab() in default lib(s) */
+#define _lib_symlink 1 /* symlink() in default lib(s) */
+#define _lib_sysconf 1 /* sysconf() in default lib(s) */
+#define _lib_sysinfo 1 /* sysinfo() in default lib(s) */
+#define _lib_syslog 1 /* syslog() in default lib(s) */
+#define _lib_telldir 1 /* telldir() in default lib(s) */
+#define _lib_tmpnam 1 /* tmpnam() in default lib(s) */
+#define _lib_tzset 1 /* tzset() in default lib(s) */
+#define _lib_unlink 1 /* unlink() in default lib(s) */
+#define _lib_utime 1 /* utime() in default lib(s) */
+#define _lib_wctype 1 /* wctype() in default lib(s) */
+#define _lib_ftruncate 1 /* ftruncate() in default lib(s) */
+#define _lib_truncate 1 /* truncate() in default lib(s) */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _lib_strtod 1 /* strtod() in default lib(s) */
+#define _lib_strtold 1 /* strtold() in default lib(s) */
+#define _lib_strtol 1 /* strtol() in default lib(s) */
+#define _lib_strtoll 1 /* strtoll() in default lib(s) */
+#define _lib_strtoul 1 /* strtoul() in default lib(s) */
+#define _lib_strtoull 1 /* strtoull() in default lib(s) */
+#define _mem_d_ino_dirent 1 /* d_ino is a member of struct dirent */
+#define _mem_d_off_dirent 1 /* d_off is a member of struct dirent */
+#define _mem_d_reclen_dirent 1 /* d_reclen is a member of struct dirent */
+#define _mem_DIR 1 /* DIR is a non-opaque struct */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _sys_jioctl 1 /* #include <sys/jioctl.h> ok */
+#define _sys_localedef 1 /* #include <sys/localedef.h> ok */
+#define _sys_ptem 1 /* #include <sys/ptem.h> ok */
+#define _sys_resource 1 /* #include <sys/resource.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _sys_stream 1 /* #include <sys/stream.h> ok */
+#define _sys_systeminfo 1 /* #include <sys/systeminfo.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_off64_t 1 /* off64_t is a type */
+#define _typ_struct_dirent64 1 /* struct dirent64 is a type */
+#define _tst_errno 1 /* errno can be assigned */
+#define _lib_poll_fd_1 1 /* fd is first arg to poll() */
+#define _lib_poll 1 /* _lib_poll_fd_1||_lib_poll_fd_2 is true */
+#define _lib_select 1 /* select() has standard 5 arg interface */
+#define _pipe_rw 1 /* full duplex pipes */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _lib_vfork 1 /* vfork exists and it works */
+#define _real_vfork 1 /* vfork child shares data with parent */
+#define _lib_posix_spawn 1 /* posix_spawn exists and it works and its worth using */
+#define _stream_peek 1 /* ioctl(I_PEEK) works */
+#define _socket_peek 1 /* recv(MSG_PEEK) works */
+#define _hdr_string 1 /* #include <string.h> ok */
+#define _lib_memcmp 1 /* standard memcmp interface that works */
+#define _hdr_fcntl 1 /* #include <fcntl.h> ok */
+#define _hdr_signal 1 /* #include <signal.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_memccpy 1 /* standard memccpy interface that works */
+#define _lib_utime_now 1 /* utime works with 0 time vector */
+#define _UNIV_DEFAULT "att" /* default universe name */
+#define _std_cleanup 1 /* stuck with standard _cleanup */
+#define _std_strcoll 1 /* standard strcoll works */
+#if !_AST_no_spawnveg
+#define _use_spawnveg 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/libpath b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/libpath
new file mode 100644
index 0000000000..6801765db9
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/libpath
@@ -0,0 +1,6 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/libpath.sh by iffe version 2007-04-04 : : */
+#ifndef _def_libpath_ast
+#define _def_libpath_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define CONF_LIBPATH "lib/64:LD_LIBRARY_PATH_64:sol.*64*,lib/32:LD_LIBRARY_PATH_32,lib:LD_LIBRARY_PATH"
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/limits b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/limits
new file mode 100644
index 0000000000..d4f848a557
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/limits
@@ -0,0 +1,107 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/limits.c by iffe version 2007-04-04 : : */
+#ifndef _def_limits_ast
+#define _def_limits_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+#ifndef CHAR_MAX
+#define CHAR_MAX 127
+#endif
+#ifndef CHAR_MIN
+#define CHAR_MIN -128
+#endif
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC 1000000
+#endif
+#ifndef INT_MIN
+#define INT_MIN -2147483648
+#endif
+#ifndef LLONG_MAX
+#define LLONG_MAX 9223372036854775807
+#endif
+#ifndef LLONG_MIN
+#define LLONG_MIN -9223372036854775808
+#endif
+#ifndef LONG_MAX
+#define LONG_MAX 2147483647
+#endif
+#ifndef LONG_MIN
+#define LONG_MIN -2147483648
+#endif
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 5
+#endif
+#ifndef OPEN_MAX_CEIL
+#ifndef OPEN_MAX
+#define OPEN_MAX 256
+#endif
+#define OPEN_MAX_CEIL OPEN_MAX
+#endif
+#ifndef PTHREAD_STACK_MIN
+#define PTHREAD_STACK_MIN 4096
+#endif
+#ifndef PTRDIFF_MAX
+#define PTRDIFF_MAX 9223372036854775807
+#endif
+#ifndef PTRDIFF_MIN
+#define PTRDIFF_MIN -9223372036854775808
+#endif
+#ifndef SCHAR_MAX
+#define SCHAR_MAX 127
+#endif
+#ifndef SCHAR_MIN
+#define SCHAR_MIN -128
+#endif
+#ifndef SHRT_MIN
+#define SHRT_MIN -32768
+#endif
+#ifndef SIG_ATOMIC_MAX
+#define SIG_ATOMIC_MAX 2147483647
+#endif
+#ifndef SIG_ATOMIC_MIN
+#define SIG_ATOMIC_MIN -2147483648
+#endif
+#ifndef SIZE_MAX
+#ifndef UINT_MAX
+#define UINT_MAX 4294967295
+#endif
+#define SIZE_MAX UINT_MAX
+#endif
+#ifndef SSIZE_MAX
+#ifndef INT_MAX
+#define INT_MAX 2147483647
+#endif
+#define SSIZE_MAX INT_MAX
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+#ifndef UCHAR_MAX
+#define UCHAR_MAX 255
+#endif
+#ifndef ULLONG_MAX
+#define ULLONG_MAX 18446744073709551615
+#endif
+#ifndef ULONG_MAX
+#define ULONG_MAX 4294967295
+#endif
+#ifndef USHRT_MAX
+#define USHRT_MAX 65535
+#endif
+#ifndef WCHAR_MAX
+#define WCHAR_MAX 2147483647
+#endif
+#ifndef WCHAR_MIN
+#define WCHAR_MIN -2147483648
+#endif
+#ifndef WINT_MAX
+#define WINT_MAX 2147483647
+#endif
+#ifndef WINT_MIN
+#define WINT_MIN -2147483648
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/map b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/map
new file mode 100644
index 0000000000..6103ce9791
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/map
@@ -0,0 +1,438 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/map.c by iffe version 2007-04-04 : : */
+#ifndef _def_map_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_map_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+/*
+ * prototypes provided for standard interfaces hijacked
+ * by ast and mapped to _ast_* but already prototyped
+ * unmapped in native headers included by <ast_std.h>
+ */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+
+#define _map_libc 1
+#undef basename
+#define basename _ast_basename
+#undef dirname
+#define dirname _ast_dirname
+#undef eaccess
+#define eaccess _ast_eaccess
+#undef execvpe
+#define execvpe _ast_execvpe
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+#undef fnmatch
+#define fnmatch _ast_fnmatch
+#undef fts_children
+#define fts_children _ast_fts_children
+#undef fts_close
+#define fts_close _ast_fts_close
+#undef fts_flags
+#define fts_flags _ast_fts_flags
+#undef fts_notify
+#define fts_notify _ast_fts_notify
+#undef fts_open
+#define fts_open _ast_fts_open
+#undef fts_read
+#define fts_read _ast_fts_read
+#undef fts_set
+#define fts_set _ast_fts_set
+#undef ftw
+#define ftw _ast_ftw
+#undef ftwalk
+#define ftwalk _ast_ftwalk
+#undef ftwflags
+#define ftwflags _ast_ftwflags
+#undef getcwd
+#define getcwd _ast_getcwd
+extern __MANGLE__ char* getcwd __PROTO__((char*, size_t));
+#undef getdate
+#define getdate _ast_getdate
+#undef getopt
+#define getopt _ast_getopt
+#undef getsubopt
+#define getsubopt _ast_getsubopt
+#undef getopt_long
+#define getopt_long _ast_getopt_long
+#undef getopt_long_only
+#define getopt_long_only _ast_getopt_long_only
+#undef getwd
+#define getwd _ast_getwd
+extern __MANGLE__ char* getwd __PROTO__((char*));
+#undef glob
+#define glob _ast_glob
+#undef globfree
+#define globfree _ast_globfree
+#undef memdup
+#define memdup _ast_memdup
+#undef memfatal
+#define memfatal _ast_memfatal
+#undef memhash
+#define memhash _ast_memhash
+#undef memsum
+#define memsum _ast_memsum
+#undef mkstemp
+#define mkstemp _ast_mkstemp
+extern __MANGLE__ int mkstemp __PROTO__((char*));
+#undef mktemp
+#define mktemp _ast_mktemp
+extern __MANGLE__ char* mktemp __PROTO__((char*));
+#undef mktime
+#define mktime _ast_mktime
+#undef nftw
+#define nftw _ast_nftw
+#undef optesc
+#define optesc _ast_optesc
+#undef optget
+#define optget _ast_optget
+#undef opthelp
+#define opthelp _ast_opthelp
+#undef optjoin
+#define optjoin _ast_optjoin
+#undef optstr
+#define optstr _ast_optstr
+#undef optusage
+#define optusage _ast_optusage
+#undef pathaccess
+#define pathaccess _ast_pathaccess
+#undef pathbin
+#define pathbin _ast_pathbin
+#undef pathcanon
+#define pathcanon _ast_pathcanon
+#undef pathcat
+#define pathcat _ast_pathcat
+#undef pathcd
+#define pathcd _ast_pathcd
+#undef pathcheck
+#define pathcheck _ast_pathcheck
+#undef pathexists
+#define pathexists _ast_pathexists
+#undef pathfind
+#define pathfind _ast_pathfind
+#undef pathgetlink
+#define pathgetlink _ast_pathgetlink
+#undef pathinclude
+#define pathinclude _ast_pathinclude
+#undef pathkey
+#define pathkey _ast_pathkey
+#undef pathnative
+#define pathnative _ast_pathnative
+#undef pathpath
+#define pathpath _ast_pathpath
+#undef pathposix
+#define pathposix _ast_pathposix
+#undef pathprobe
+#define pathprobe _ast_pathprobe
+#undef pathrepl
+#define pathrepl _ast_pathrepl
+#undef pathsetlink
+#define pathsetlink _ast_pathsetlink
+#undef pathshell
+#define pathshell _ast_pathshell
+#undef pathstat
+#define pathstat _ast_pathstat
+#undef pathtemp
+#define pathtemp _ast_pathtemp
+#undef pathtmp
+#define pathtmp _ast_pathtmp
+#undef procclose
+#define procclose _ast_procclose
+#undef procfree
+#define procfree _ast_procfree
+#undef procopen
+#define procopen _ast_procopen
+#undef procrun
+#define procrun _ast_procrun
+#undef putenv
+#define putenv _ast_putenv
+#undef re_comp
+#define re_comp _ast_re_comp
+#undef re_exec
+#define re_exec _ast_re_exec
+#undef realpath
+#define realpath _ast_realpath
+extern __MANGLE__ char* realpath __PROTO__((const char*, char*));
+#undef regaddclass
+#define regaddclass _ast_regaddclass
+#undef regalloc
+#define regalloc _ast_regalloc
+#undef regcache
+#define regcache _ast_regcache
+#undef regclass
+#define regclass _ast_regclass
+#undef regcmp
+#define regcmp _ast_regcmp
+#undef regcollate
+#define regcollate _ast_regcollate
+#undef regcomb
+#define regcomb _ast_regcomb
+#undef regcomp
+#define regcomp _ast_regcomp
+#undef regdecomp
+#define regdecomp _ast_regdecomp
+#undef regdup
+#define regdup _ast_regdup
+#undef regerror
+#define regerror _ast_regerror
+#undef regex
+#define regex _ast_regex
+#undef regexec
+#define regexec _ast_regexec
+#undef regfatal
+#define regfatal _ast_regfatal
+#undef regfatalpat
+#define regfatalpat _ast_regfatalpat
+#undef regfree
+#define regfree _ast_regfree
+#undef regncomp
+#define regncomp _ast_regncomp
+#undef regnexec
+#define regnexec _ast_regnexec
+#undef regrecord
+#define regrecord _ast_regrecord
+#undef regrexec
+#define regrexec _ast_regrexec
+#undef regstat
+#define regstat _ast_regstat
+#undef regsub
+#define regsub _ast_regsub
+#undef regsubcomp
+#define regsubcomp _ast_regsubcomp
+#undef regsubexec
+#define regsubexec _ast_regsubexec
+#undef regsubflags
+#define regsubflags _ast_regsubflags
+#undef regsubfree
+#define regsubfree _ast_regsubfree
+#undef remove
+#define remove _ast_remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#undef resolvepath
+#define resolvepath _ast_resolvepath
+extern __MANGLE__ char* resolvepath __PROTO__((const char*, char*, size_t));
+#undef setenv
+#define setenv _ast_setenv
+extern __MANGLE__ int setenv __PROTO__((const char*, const char*, int));
+#undef setenviron
+#define setenviron _ast_setenviron
+#undef sigcritical
+#define sigcritical _ast_sigcritical
+#undef signal
+#define signal _ast_signal
+#undef sigunblock
+#define sigunblock _ast_sigunblock
+#undef stracmp
+#define stracmp _ast_stracmp
+#undef strcopy
+#define strcopy _ast_strcopy
+#undef strelapsed
+#define strelapsed _ast_strelapsed
+#undef stresc
+#define stresc _ast_stresc
+#undef streval
+#define streval _ast_streval
+#undef strexpr
+#define strexpr _ast_strexpr
+#undef strftime
+#define strftime _ast_strftime
+#undef strgid
+#define strgid _ast_strgid
+#undef strgrpmatch
+#define strgrpmatch _ast_strgrpmatch
+#undef strhash
+#define strhash _ast_strhash
+#undef strkey
+#define strkey _ast_strkey
+#undef strlcat
+#define strlcat _ast_strlcat
+extern __MANGLE__ size_t strlcat __PROTO__((char*, const char*, size_t));
+#undef strlcpy
+#define strlcpy _ast_strlcpy
+extern __MANGLE__ size_t strlcpy __PROTO__((char*, const char*, size_t));
+#undef strlook
+#define strlook _ast_strlook
+#undef strmatch
+#define strmatch _ast_strmatch
+#undef strmode
+#define strmode _ast_strmode
+#undef strnacmp
+#define strnacmp _ast_strnacmp
+#undef strncopy
+#define strncopy _ast_strncopy
+#undef strntod
+#define strntod _ast_strntod
+#undef strntol
+#define strntol _ast_strntol
+#undef strntold
+#define strntold _ast_strntold
+#undef strntoll
+#define strntoll _ast_strntoll
+#undef strntoul
+#define strntoul _ast_strntoul
+#undef strntoull
+#define strntoull _ast_strntoull
+#undef stropt
+#define stropt _ast_stropt
+#undef strperm
+#define strperm _ast_strperm
+#undef strpsearch
+#define strpsearch _ast_strpsearch
+#undef strptime
+#define strptime _ast_strptime
+#undef strsearch
+#define strsearch _ast_strsearch
+#undef strsort
+#define strsort _ast_strsort
+#undef strsubmatch
+#define strsubmatch _ast_strsubmatch
+#undef strsum
+#define strsum _ast_strsum
+#undef strtape
+#define strtape _ast_strtape
+#undef strtoip4
+#define strtoip4 _ast_strtoip4
+#undef strton
+#define strton _ast_strton
+#undef strtonll
+#define strtonll _ast_strtonll
+#undef struid
+#define struid _ast_struid
+#undef struniq
+#define struniq _ast_struniq
+#undef system
+#define system _ast_system
+extern __MANGLE__ int system __PROTO__((const char*));
+#undef tempnam
+#define tempnam _ast_tempnam
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+#undef tmpnam
+#define tmpnam _ast_tmpnam
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+#undef touch
+#define touch _ast_touch
+#undef wordexp
+#define wordexp _ast_wordexp
+#undef wordfree
+#define wordfree _ast_wordfree
+#undef unsetenv
+#define unsetenv _ast_unsetenv
+
+/* cannot override local malloc */
+#define _map_malloc 1
+#undef calloc
+#define calloc _ast_calloc
+extern __MANGLE__ __V_* calloc __PROTO__((size_t, size_t));
+#undef cfree
+#define cfree _ast_cfree
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+#undef free
+#define free _ast_free
+extern __MANGLE__ void free __PROTO__((__V_*));
+#undef malloc
+#define malloc _ast_malloc
+extern __MANGLE__ __V_* malloc __PROTO__((size_t));
+#undef memalign
+#define memalign _ast_memalign
+extern __MANGLE__ __V_* memalign __PROTO__((size_t, size_t));
+#undef realloc
+#define realloc _ast_realloc
+extern __MANGLE__ __V_* realloc __PROTO__((__V_*, size_t));
+#undef strdup
+#define strdup _ast_strdup
+extern __MANGLE__ char* strdup __PROTO__((const char*));
+#undef valloc
+#define valloc _ast_valloc
+extern __MANGLE__ __V_* valloc __PROTO__((size_t));
+#undef strtol
+#define strtol _ast_strtol
+#undef strtoul
+#define strtoul _ast_strtoul
+#undef strtoll
+#define strtoll _ast_strtoll
+#undef strtoull
+#define strtoull _ast_strtoull
+#undef strtod
+#define strtod _ast_strtod
+#undef strtold
+#define strtold _ast_strtold
+extern __MANGLE__ long strtol __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned long strtoul __PROTO__((const char*, char**, int));
+extern __MANGLE__ double strtod __PROTO__((const char*, char**));
+#if !_UWIN
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
+extern __MANGLE__ _ast_fltmax_t strtold __PROTO__((const char*, char**));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+extern __MANGLE__ _ast_intmax_t strtoll __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned _ast_intmax_t strtoull __PROTO__((const char*, char**, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/mmap b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/mmap
new file mode 100644
index 0000000000..47b8dc23b2
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/mmap
@@ -0,0 +1,26 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/mmap by iffe version 2007-04-04 : : */
+#ifndef _def_mmap_ast
+#define _def_mmap_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_mmap 1 /* standard mmap interface that works */
+#define _lib_mmap64 1 /* mmap64 interface and implementation work */
+#define _mmap_anon 1 /* use mmap MAP_ANON to get raw memory */
+#define _mmap_devzero 1 /* use mmap on /dev/zero to get raw memory */
+
+/* some systems get it wrong but escape concise detection */
+#ifndef _NO_MMAP
+#if __CYGWIN__
+#define _NO_MMAP 1
+#endif
+#endif
+
+#if _NO_MMAP
+#undef _lib_mmap
+#undef _lib_mmap64
+#undef _mmap_anon
+#undef _mmap_devzero
+#undef _mmap_worthy
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/mode b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/mode
new file mode 100644
index 0000000000..58c29a7ff5
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/mode
@@ -0,0 +1,14 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/mode.c by iffe version 2007-04-04 : : */
+#ifndef _def_mode_ast
+#define _def_mode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define S_ITYPE(m) ((m)&S_IFMT)
+
+#define S_IPERM (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
+
+#define _S_IDPERM 1
+#define _S_IDTYPE 1
+
+#define BUFFERSIZE 8192
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/nl_types b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/nl_types
new file mode 100644
index 0000000000..08f46d7dee
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/nl_types
@@ -0,0 +1,102 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/nl_types by iffe version 2007-04-04 : : */
+
+#ifndef _def_nl_types_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_nl_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_nl_langinfo 1 /* nl_langinfo() in default lib(s) */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_langinfo 1 /* #include <langinfo.h> ok */
+#define _nxt_nl_types <../include/nl_types.h> /* include path for the native <nl_types.h> */
+#define _nxt_nl_types_str "../include/nl_types.h" /* include string for the native <nl_types.h> */
+#include <limits.h>
+#include <../include/nl_types.h> /* the native nl_types.h */
+
+#undef NL_SETMAX
+#define NL_SETMAX 1023
+#undef NL_MSGMAX
+#define NL_MSGMAX 32767
+#undef nl_catd
+#define nl_catd _ast_nl_catd
+#undef catopen
+#define catopen _ast_catopen
+#undef catgets
+#define catgets _ast_catgets
+#undef catclose
+#define catclose _ast_catclose
+
+typedef __V_* nl_catd;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ nl_catd catopen __PROTO__((const char*, int));
+extern __MANGLE__ char* catgets __PROTO__((nl_catd, int, int, const char*));
+extern __MANGLE__ int catclose __PROTO__((nl_catd));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/omitted b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/omitted
new file mode 100644
index 0000000000..d70464bbac
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/omitted
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/omitted by iffe version 2007-04-04 : : */
+#ifndef _def_omitted_ast
+#define _def_omitted_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/param b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/param
new file mode 100644
index 0000000000..4a9644522d
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/param
@@ -0,0 +1,9 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/param.sh by iffe version 2007-04-04 : : */
+#ifndef _def_param_ast
+#define _def_param_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#include <sys/param.h>
+#ifndef S_IFDIR
+#include <sys/stat.h>
+#endif
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/preroot b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/preroot
new file mode 100644
index 0000000000..508e3aada4
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/preroot
@@ -0,0 +1,6 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/preroot.sh by iffe version 2007-04-04 : : */
+#ifndef _def_preroot_ast
+#define _def_preroot_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* preroot not enabled */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/sfinit b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/sfinit
new file mode 100644
index 0000000000..c68b631e2a
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/sfinit
@@ -0,0 +1,5332 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/sfinit.c by iffe version 2007-04-04 : : */
+#ifndef _def_sfinit_ast
+#define _def_sfinit_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+static const float sf_flt_pow10[] =
+{
+ 1E0F,
+ 1E1F,
+ 1E2F,
+ 1E3F,
+ 1E4F,
+ 1E5F,
+ 1E6F,
+ 1E7F,
+ 1E8F,
+ 1E9F,
+ 1E10F,
+ 1E11F,
+ 1E12F,
+ 1E13F,
+ 1E14F,
+ 1E15F,
+ 1E16F,
+ 1E17F,
+ 1E18F,
+ 1E19F,
+ 1E20F,
+ 1E21F,
+ 1E22F,
+ 1E23F,
+ 1E24F,
+ 1E25F,
+ 1E26F,
+ 1E27F,
+ 1E28F,
+ 1E29F,
+ 1E30F,
+ 1E31F,
+ 1E32F,
+ 1E33F,
+ 1E34F,
+ 1E35F,
+ 1E36F,
+ 1E37F,
+ 1E38F,
+};
+
+static const double sf_dbl_pow10[] =
+{
+ 1E0,
+ 1E1,
+ 1E2,
+ 1E3,
+ 1E4,
+ 1E5,
+ 1E6,
+ 1E7,
+ 1E8,
+ 1E9,
+ 1E10,
+ 1E11,
+ 1E12,
+ 1E13,
+ 1E14,
+ 1E15,
+ 1E16,
+ 1E17,
+ 1E18,
+ 1E19,
+ 1E20,
+ 1E21,
+ 1E22,
+ 1E23,
+ 1E24,
+ 1E25,
+ 1E26,
+ 1E27,
+ 1E28,
+ 1E29,
+ 1E30,
+ 1E31,
+ 1E32,
+ 1E33,
+ 1E34,
+ 1E35,
+ 1E36,
+ 1E37,
+ 1E38,
+ 1E39,
+ 1E40,
+ 1E41,
+ 1E42,
+ 1E43,
+ 1E44,
+ 1E45,
+ 1E46,
+ 1E47,
+ 1E48,
+ 1E49,
+ 1E50,
+ 1E51,
+ 1E52,
+ 1E53,
+ 1E54,
+ 1E55,
+ 1E56,
+ 1E57,
+ 1E58,
+ 1E59,
+ 1E60,
+ 1E61,
+ 1E62,
+ 1E63,
+ 1E64,
+ 1E65,
+ 1E66,
+ 1E67,
+ 1E68,
+ 1E69,
+ 1E70,
+ 1E71,
+ 1E72,
+ 1E73,
+ 1E74,
+ 1E75,
+ 1E76,
+ 1E77,
+ 1E78,
+ 1E79,
+ 1E80,
+ 1E81,
+ 1E82,
+ 1E83,
+ 1E84,
+ 1E85,
+ 1E86,
+ 1E87,
+ 1E88,
+ 1E89,
+ 1E90,
+ 1E91,
+ 1E92,
+ 1E93,
+ 1E94,
+ 1E95,
+ 1E96,
+ 1E97,
+ 1E98,
+ 1E99,
+ 1E100,
+ 1E101,
+ 1E102,
+ 1E103,
+ 1E104,
+ 1E105,
+ 1E106,
+ 1E107,
+ 1E108,
+ 1E109,
+ 1E110,
+ 1E111,
+ 1E112,
+ 1E113,
+ 1E114,
+ 1E115,
+ 1E116,
+ 1E117,
+ 1E118,
+ 1E119,
+ 1E120,
+ 1E121,
+ 1E122,
+ 1E123,
+ 1E124,
+ 1E125,
+ 1E126,
+ 1E127,
+ 1E128,
+ 1E129,
+ 1E130,
+ 1E131,
+ 1E132,
+ 1E133,
+ 1E134,
+ 1E135,
+ 1E136,
+ 1E137,
+ 1E138,
+ 1E139,
+ 1E140,
+ 1E141,
+ 1E142,
+ 1E143,
+ 1E144,
+ 1E145,
+ 1E146,
+ 1E147,
+ 1E148,
+ 1E149,
+ 1E150,
+ 1E151,
+ 1E152,
+ 1E153,
+ 1E154,
+ 1E155,
+ 1E156,
+ 1E157,
+ 1E158,
+ 1E159,
+ 1E160,
+ 1E161,
+ 1E162,
+ 1E163,
+ 1E164,
+ 1E165,
+ 1E166,
+ 1E167,
+ 1E168,
+ 1E169,
+ 1E170,
+ 1E171,
+ 1E172,
+ 1E173,
+ 1E174,
+ 1E175,
+ 1E176,
+ 1E177,
+ 1E178,
+ 1E179,
+ 1E180,
+ 1E181,
+ 1E182,
+ 1E183,
+ 1E184,
+ 1E185,
+ 1E186,
+ 1E187,
+ 1E188,
+ 1E189,
+ 1E190,
+ 1E191,
+ 1E192,
+ 1E193,
+ 1E194,
+ 1E195,
+ 1E196,
+ 1E197,
+ 1E198,
+ 1E199,
+ 1E200,
+ 1E201,
+ 1E202,
+ 1E203,
+ 1E204,
+ 1E205,
+ 1E206,
+ 1E207,
+ 1E208,
+ 1E209,
+ 1E210,
+ 1E211,
+ 1E212,
+ 1E213,
+ 1E214,
+ 1E215,
+ 1E216,
+ 1E217,
+ 1E218,
+ 1E219,
+ 1E220,
+ 1E221,
+ 1E222,
+ 1E223,
+ 1E224,
+ 1E225,
+ 1E226,
+ 1E227,
+ 1E228,
+ 1E229,
+ 1E230,
+ 1E231,
+ 1E232,
+ 1E233,
+ 1E234,
+ 1E235,
+ 1E236,
+ 1E237,
+ 1E238,
+ 1E239,
+ 1E240,
+ 1E241,
+ 1E242,
+ 1E243,
+ 1E244,
+ 1E245,
+ 1E246,
+ 1E247,
+ 1E248,
+ 1E249,
+ 1E250,
+ 1E251,
+ 1E252,
+ 1E253,
+ 1E254,
+ 1E255,
+ 1E256,
+ 1E257,
+ 1E258,
+ 1E259,
+ 1E260,
+ 1E261,
+ 1E262,
+ 1E263,
+ 1E264,
+ 1E265,
+ 1E266,
+ 1E267,
+ 1E268,
+ 1E269,
+ 1E270,
+ 1E271,
+ 1E272,
+ 1E273,
+ 1E274,
+ 1E275,
+ 1E276,
+ 1E277,
+ 1E278,
+ 1E279,
+ 1E280,
+ 1E281,
+ 1E282,
+ 1E283,
+ 1E284,
+ 1E285,
+ 1E286,
+ 1E287,
+ 1E288,
+ 1E289,
+ 1E290,
+ 1E291,
+ 1E292,
+ 1E293,
+ 1E294,
+ 1E295,
+ 1E296,
+ 1E297,
+ 1E298,
+ 1E299,
+ 1E300,
+ 1E301,
+ 1E302,
+ 1E303,
+ 1E304,
+ 1E305,
+ 1E306,
+ 1E307,
+ 1E308,
+};
+
+static const _ast_fltmax_t sf_ldbl_pow10[] =
+{
+ 1E0L,
+ 1E1L,
+ 1E2L,
+ 1E3L,
+ 1E4L,
+ 1E5L,
+ 1E6L,
+ 1E7L,
+ 1E8L,
+ 1E9L,
+ 1E10L,
+ 1E11L,
+ 1E12L,
+ 1E13L,
+ 1E14L,
+ 1E15L,
+ 1E16L,
+ 1E17L,
+ 1E18L,
+ 1E19L,
+ 1E20L,
+ 1E21L,
+ 1E22L,
+ 1E23L,
+ 1E24L,
+ 1E25L,
+ 1E26L,
+ 1E27L,
+ 1E28L,
+ 1E29L,
+ 1E30L,
+ 1E31L,
+ 1E32L,
+ 1E33L,
+ 1E34L,
+ 1E35L,
+ 1E36L,
+ 1E37L,
+ 1E38L,
+ 1E39L,
+ 1E40L,
+ 1E41L,
+ 1E42L,
+ 1E43L,
+ 1E44L,
+ 1E45L,
+ 1E46L,
+ 1E47L,
+ 1E48L,
+ 1E49L,
+ 1E50L,
+ 1E51L,
+ 1E52L,
+ 1E53L,
+ 1E54L,
+ 1E55L,
+ 1E56L,
+ 1E57L,
+ 1E58L,
+ 1E59L,
+ 1E60L,
+ 1E61L,
+ 1E62L,
+ 1E63L,
+ 1E64L,
+ 1E65L,
+ 1E66L,
+ 1E67L,
+ 1E68L,
+ 1E69L,
+ 1E70L,
+ 1E71L,
+ 1E72L,
+ 1E73L,
+ 1E74L,
+ 1E75L,
+ 1E76L,
+ 1E77L,
+ 1E78L,
+ 1E79L,
+ 1E80L,
+ 1E81L,
+ 1E82L,
+ 1E83L,
+ 1E84L,
+ 1E85L,
+ 1E86L,
+ 1E87L,
+ 1E88L,
+ 1E89L,
+ 1E90L,
+ 1E91L,
+ 1E92L,
+ 1E93L,
+ 1E94L,
+ 1E95L,
+ 1E96L,
+ 1E97L,
+ 1E98L,
+ 1E99L,
+ 1E100L,
+ 1E101L,
+ 1E102L,
+ 1E103L,
+ 1E104L,
+ 1E105L,
+ 1E106L,
+ 1E107L,
+ 1E108L,
+ 1E109L,
+ 1E110L,
+ 1E111L,
+ 1E112L,
+ 1E113L,
+ 1E114L,
+ 1E115L,
+ 1E116L,
+ 1E117L,
+ 1E118L,
+ 1E119L,
+ 1E120L,
+ 1E121L,
+ 1E122L,
+ 1E123L,
+ 1E124L,
+ 1E125L,
+ 1E126L,
+ 1E127L,
+ 1E128L,
+ 1E129L,
+ 1E130L,
+ 1E131L,
+ 1E132L,
+ 1E133L,
+ 1E134L,
+ 1E135L,
+ 1E136L,
+ 1E137L,
+ 1E138L,
+ 1E139L,
+ 1E140L,
+ 1E141L,
+ 1E142L,
+ 1E143L,
+ 1E144L,
+ 1E145L,
+ 1E146L,
+ 1E147L,
+ 1E148L,
+ 1E149L,
+ 1E150L,
+ 1E151L,
+ 1E152L,
+ 1E153L,
+ 1E154L,
+ 1E155L,
+ 1E156L,
+ 1E157L,
+ 1E158L,
+ 1E159L,
+ 1E160L,
+ 1E161L,
+ 1E162L,
+ 1E163L,
+ 1E164L,
+ 1E165L,
+ 1E166L,
+ 1E167L,
+ 1E168L,
+ 1E169L,
+ 1E170L,
+ 1E171L,
+ 1E172L,
+ 1E173L,
+ 1E174L,
+ 1E175L,
+ 1E176L,
+ 1E177L,
+ 1E178L,
+ 1E179L,
+ 1E180L,
+ 1E181L,
+ 1E182L,
+ 1E183L,
+ 1E184L,
+ 1E185L,
+ 1E186L,
+ 1E187L,
+ 1E188L,
+ 1E189L,
+ 1E190L,
+ 1E191L,
+ 1E192L,
+ 1E193L,
+ 1E194L,
+ 1E195L,
+ 1E196L,
+ 1E197L,
+ 1E198L,
+ 1E199L,
+ 1E200L,
+ 1E201L,
+ 1E202L,
+ 1E203L,
+ 1E204L,
+ 1E205L,
+ 1E206L,
+ 1E207L,
+ 1E208L,
+ 1E209L,
+ 1E210L,
+ 1E211L,
+ 1E212L,
+ 1E213L,
+ 1E214L,
+ 1E215L,
+ 1E216L,
+ 1E217L,
+ 1E218L,
+ 1E219L,
+ 1E220L,
+ 1E221L,
+ 1E222L,
+ 1E223L,
+ 1E224L,
+ 1E225L,
+ 1E226L,
+ 1E227L,
+ 1E228L,
+ 1E229L,
+ 1E230L,
+ 1E231L,
+ 1E232L,
+ 1E233L,
+ 1E234L,
+ 1E235L,
+ 1E236L,
+ 1E237L,
+ 1E238L,
+ 1E239L,
+ 1E240L,
+ 1E241L,
+ 1E242L,
+ 1E243L,
+ 1E244L,
+ 1E245L,
+ 1E246L,
+ 1E247L,
+ 1E248L,
+ 1E249L,
+ 1E250L,
+ 1E251L,
+ 1E252L,
+ 1E253L,
+ 1E254L,
+ 1E255L,
+ 1E256L,
+ 1E257L,
+ 1E258L,
+ 1E259L,
+ 1E260L,
+ 1E261L,
+ 1E262L,
+ 1E263L,
+ 1E264L,
+ 1E265L,
+ 1E266L,
+ 1E267L,
+ 1E268L,
+ 1E269L,
+ 1E270L,
+ 1E271L,
+ 1E272L,
+ 1E273L,
+ 1E274L,
+ 1E275L,
+ 1E276L,
+ 1E277L,
+ 1E278L,
+ 1E279L,
+ 1E280L,
+ 1E281L,
+ 1E282L,
+ 1E283L,
+ 1E284L,
+ 1E285L,
+ 1E286L,
+ 1E287L,
+ 1E288L,
+ 1E289L,
+ 1E290L,
+ 1E291L,
+ 1E292L,
+ 1E293L,
+ 1E294L,
+ 1E295L,
+ 1E296L,
+ 1E297L,
+ 1E298L,
+ 1E299L,
+ 1E300L,
+ 1E301L,
+ 1E302L,
+ 1E303L,
+ 1E304L,
+ 1E305L,
+ 1E306L,
+ 1E307L,
+ 1E308L,
+ 1E309L,
+ 1E310L,
+ 1E311L,
+ 1E312L,
+ 1E313L,
+ 1E314L,
+ 1E315L,
+ 1E316L,
+ 1E317L,
+ 1E318L,
+ 1E319L,
+ 1E320L,
+ 1E321L,
+ 1E322L,
+ 1E323L,
+ 1E324L,
+ 1E325L,
+ 1E326L,
+ 1E327L,
+ 1E328L,
+ 1E329L,
+ 1E330L,
+ 1E331L,
+ 1E332L,
+ 1E333L,
+ 1E334L,
+ 1E335L,
+ 1E336L,
+ 1E337L,
+ 1E338L,
+ 1E339L,
+ 1E340L,
+ 1E341L,
+ 1E342L,
+ 1E343L,
+ 1E344L,
+ 1E345L,
+ 1E346L,
+ 1E347L,
+ 1E348L,
+ 1E349L,
+ 1E350L,
+ 1E351L,
+ 1E352L,
+ 1E353L,
+ 1E354L,
+ 1E355L,
+ 1E356L,
+ 1E357L,
+ 1E358L,
+ 1E359L,
+ 1E360L,
+ 1E361L,
+ 1E362L,
+ 1E363L,
+ 1E364L,
+ 1E365L,
+ 1E366L,
+ 1E367L,
+ 1E368L,
+ 1E369L,
+ 1E370L,
+ 1E371L,
+ 1E372L,
+ 1E373L,
+ 1E374L,
+ 1E375L,
+ 1E376L,
+ 1E377L,
+ 1E378L,
+ 1E379L,
+ 1E380L,
+ 1E381L,
+ 1E382L,
+ 1E383L,
+ 1E384L,
+ 1E385L,
+ 1E386L,
+ 1E387L,
+ 1E388L,
+ 1E389L,
+ 1E390L,
+ 1E391L,
+ 1E392L,
+ 1E393L,
+ 1E394L,
+ 1E395L,
+ 1E396L,
+ 1E397L,
+ 1E398L,
+ 1E399L,
+ 1E400L,
+ 1E401L,
+ 1E402L,
+ 1E403L,
+ 1E404L,
+ 1E405L,
+ 1E406L,
+ 1E407L,
+ 1E408L,
+ 1E409L,
+ 1E410L,
+ 1E411L,
+ 1E412L,
+ 1E413L,
+ 1E414L,
+ 1E415L,
+ 1E416L,
+ 1E417L,
+ 1E418L,
+ 1E419L,
+ 1E420L,
+ 1E421L,
+ 1E422L,
+ 1E423L,
+ 1E424L,
+ 1E425L,
+ 1E426L,
+ 1E427L,
+ 1E428L,
+ 1E429L,
+ 1E430L,
+ 1E431L,
+ 1E432L,
+ 1E433L,
+ 1E434L,
+ 1E435L,
+ 1E436L,
+ 1E437L,
+ 1E438L,
+ 1E439L,
+ 1E440L,
+ 1E441L,
+ 1E442L,
+ 1E443L,
+ 1E444L,
+ 1E445L,
+ 1E446L,
+ 1E447L,
+ 1E448L,
+ 1E449L,
+ 1E450L,
+ 1E451L,
+ 1E452L,
+ 1E453L,
+ 1E454L,
+ 1E455L,
+ 1E456L,
+ 1E457L,
+ 1E458L,
+ 1E459L,
+ 1E460L,
+ 1E461L,
+ 1E462L,
+ 1E463L,
+ 1E464L,
+ 1E465L,
+ 1E466L,
+ 1E467L,
+ 1E468L,
+ 1E469L,
+ 1E470L,
+ 1E471L,
+ 1E472L,
+ 1E473L,
+ 1E474L,
+ 1E475L,
+ 1E476L,
+ 1E477L,
+ 1E478L,
+ 1E479L,
+ 1E480L,
+ 1E481L,
+ 1E482L,
+ 1E483L,
+ 1E484L,
+ 1E485L,
+ 1E486L,
+ 1E487L,
+ 1E488L,
+ 1E489L,
+ 1E490L,
+ 1E491L,
+ 1E492L,
+ 1E493L,
+ 1E494L,
+ 1E495L,
+ 1E496L,
+ 1E497L,
+ 1E498L,
+ 1E499L,
+ 1E500L,
+ 1E501L,
+ 1E502L,
+ 1E503L,
+ 1E504L,
+ 1E505L,
+ 1E506L,
+ 1E507L,
+ 1E508L,
+ 1E509L,
+ 1E510L,
+ 1E511L,
+ 1E512L,
+ 1E513L,
+ 1E514L,
+ 1E515L,
+ 1E516L,
+ 1E517L,
+ 1E518L,
+ 1E519L,
+ 1E520L,
+ 1E521L,
+ 1E522L,
+ 1E523L,
+ 1E524L,
+ 1E525L,
+ 1E526L,
+ 1E527L,
+ 1E528L,
+ 1E529L,
+ 1E530L,
+ 1E531L,
+ 1E532L,
+ 1E533L,
+ 1E534L,
+ 1E535L,
+ 1E536L,
+ 1E537L,
+ 1E538L,
+ 1E539L,
+ 1E540L,
+ 1E541L,
+ 1E542L,
+ 1E543L,
+ 1E544L,
+ 1E545L,
+ 1E546L,
+ 1E547L,
+ 1E548L,
+ 1E549L,
+ 1E550L,
+ 1E551L,
+ 1E552L,
+ 1E553L,
+ 1E554L,
+ 1E555L,
+ 1E556L,
+ 1E557L,
+ 1E558L,
+ 1E559L,
+ 1E560L,
+ 1E561L,
+ 1E562L,
+ 1E563L,
+ 1E564L,
+ 1E565L,
+ 1E566L,
+ 1E567L,
+ 1E568L,
+ 1E569L,
+ 1E570L,
+ 1E571L,
+ 1E572L,
+ 1E573L,
+ 1E574L,
+ 1E575L,
+ 1E576L,
+ 1E577L,
+ 1E578L,
+ 1E579L,
+ 1E580L,
+ 1E581L,
+ 1E582L,
+ 1E583L,
+ 1E584L,
+ 1E585L,
+ 1E586L,
+ 1E587L,
+ 1E588L,
+ 1E589L,
+ 1E590L,
+ 1E591L,
+ 1E592L,
+ 1E593L,
+ 1E594L,
+ 1E595L,
+ 1E596L,
+ 1E597L,
+ 1E598L,
+ 1E599L,
+ 1E600L,
+ 1E601L,
+ 1E602L,
+ 1E603L,
+ 1E604L,
+ 1E605L,
+ 1E606L,
+ 1E607L,
+ 1E608L,
+ 1E609L,
+ 1E610L,
+ 1E611L,
+ 1E612L,
+ 1E613L,
+ 1E614L,
+ 1E615L,
+ 1E616L,
+ 1E617L,
+ 1E618L,
+ 1E619L,
+ 1E620L,
+ 1E621L,
+ 1E622L,
+ 1E623L,
+ 1E624L,
+ 1E625L,
+ 1E626L,
+ 1E627L,
+ 1E628L,
+ 1E629L,
+ 1E630L,
+ 1E631L,
+ 1E632L,
+ 1E633L,
+ 1E634L,
+ 1E635L,
+ 1E636L,
+ 1E637L,
+ 1E638L,
+ 1E639L,
+ 1E640L,
+ 1E641L,
+ 1E642L,
+ 1E643L,
+ 1E644L,
+ 1E645L,
+ 1E646L,
+ 1E647L,
+ 1E648L,
+ 1E649L,
+ 1E650L,
+ 1E651L,
+ 1E652L,
+ 1E653L,
+ 1E654L,
+ 1E655L,
+ 1E656L,
+ 1E657L,
+ 1E658L,
+ 1E659L,
+ 1E660L,
+ 1E661L,
+ 1E662L,
+ 1E663L,
+ 1E664L,
+ 1E665L,
+ 1E666L,
+ 1E667L,
+ 1E668L,
+ 1E669L,
+ 1E670L,
+ 1E671L,
+ 1E672L,
+ 1E673L,
+ 1E674L,
+ 1E675L,
+ 1E676L,
+ 1E677L,
+ 1E678L,
+ 1E679L,
+ 1E680L,
+ 1E681L,
+ 1E682L,
+ 1E683L,
+ 1E684L,
+ 1E685L,
+ 1E686L,
+ 1E687L,
+ 1E688L,
+ 1E689L,
+ 1E690L,
+ 1E691L,
+ 1E692L,
+ 1E693L,
+ 1E694L,
+ 1E695L,
+ 1E696L,
+ 1E697L,
+ 1E698L,
+ 1E699L,
+ 1E700L,
+ 1E701L,
+ 1E702L,
+ 1E703L,
+ 1E704L,
+ 1E705L,
+ 1E706L,
+ 1E707L,
+ 1E708L,
+ 1E709L,
+ 1E710L,
+ 1E711L,
+ 1E712L,
+ 1E713L,
+ 1E714L,
+ 1E715L,
+ 1E716L,
+ 1E717L,
+ 1E718L,
+ 1E719L,
+ 1E720L,
+ 1E721L,
+ 1E722L,
+ 1E723L,
+ 1E724L,
+ 1E725L,
+ 1E726L,
+ 1E727L,
+ 1E728L,
+ 1E729L,
+ 1E730L,
+ 1E731L,
+ 1E732L,
+ 1E733L,
+ 1E734L,
+ 1E735L,
+ 1E736L,
+ 1E737L,
+ 1E738L,
+ 1E739L,
+ 1E740L,
+ 1E741L,
+ 1E742L,
+ 1E743L,
+ 1E744L,
+ 1E745L,
+ 1E746L,
+ 1E747L,
+ 1E748L,
+ 1E749L,
+ 1E750L,
+ 1E751L,
+ 1E752L,
+ 1E753L,
+ 1E754L,
+ 1E755L,
+ 1E756L,
+ 1E757L,
+ 1E758L,
+ 1E759L,
+ 1E760L,
+ 1E761L,
+ 1E762L,
+ 1E763L,
+ 1E764L,
+ 1E765L,
+ 1E766L,
+ 1E767L,
+ 1E768L,
+ 1E769L,
+ 1E770L,
+ 1E771L,
+ 1E772L,
+ 1E773L,
+ 1E774L,
+ 1E775L,
+ 1E776L,
+ 1E777L,
+ 1E778L,
+ 1E779L,
+ 1E780L,
+ 1E781L,
+ 1E782L,
+ 1E783L,
+ 1E784L,
+ 1E785L,
+ 1E786L,
+ 1E787L,
+ 1E788L,
+ 1E789L,
+ 1E790L,
+ 1E791L,
+ 1E792L,
+ 1E793L,
+ 1E794L,
+ 1E795L,
+ 1E796L,
+ 1E797L,
+ 1E798L,
+ 1E799L,
+ 1E800L,
+ 1E801L,
+ 1E802L,
+ 1E803L,
+ 1E804L,
+ 1E805L,
+ 1E806L,
+ 1E807L,
+ 1E808L,
+ 1E809L,
+ 1E810L,
+ 1E811L,
+ 1E812L,
+ 1E813L,
+ 1E814L,
+ 1E815L,
+ 1E816L,
+ 1E817L,
+ 1E818L,
+ 1E819L,
+ 1E820L,
+ 1E821L,
+ 1E822L,
+ 1E823L,
+ 1E824L,
+ 1E825L,
+ 1E826L,
+ 1E827L,
+ 1E828L,
+ 1E829L,
+ 1E830L,
+ 1E831L,
+ 1E832L,
+ 1E833L,
+ 1E834L,
+ 1E835L,
+ 1E836L,
+ 1E837L,
+ 1E838L,
+ 1E839L,
+ 1E840L,
+ 1E841L,
+ 1E842L,
+ 1E843L,
+ 1E844L,
+ 1E845L,
+ 1E846L,
+ 1E847L,
+ 1E848L,
+ 1E849L,
+ 1E850L,
+ 1E851L,
+ 1E852L,
+ 1E853L,
+ 1E854L,
+ 1E855L,
+ 1E856L,
+ 1E857L,
+ 1E858L,
+ 1E859L,
+ 1E860L,
+ 1E861L,
+ 1E862L,
+ 1E863L,
+ 1E864L,
+ 1E865L,
+ 1E866L,
+ 1E867L,
+ 1E868L,
+ 1E869L,
+ 1E870L,
+ 1E871L,
+ 1E872L,
+ 1E873L,
+ 1E874L,
+ 1E875L,
+ 1E876L,
+ 1E877L,
+ 1E878L,
+ 1E879L,
+ 1E880L,
+ 1E881L,
+ 1E882L,
+ 1E883L,
+ 1E884L,
+ 1E885L,
+ 1E886L,
+ 1E887L,
+ 1E888L,
+ 1E889L,
+ 1E890L,
+ 1E891L,
+ 1E892L,
+ 1E893L,
+ 1E894L,
+ 1E895L,
+ 1E896L,
+ 1E897L,
+ 1E898L,
+ 1E899L,
+ 1E900L,
+ 1E901L,
+ 1E902L,
+ 1E903L,
+ 1E904L,
+ 1E905L,
+ 1E906L,
+ 1E907L,
+ 1E908L,
+ 1E909L,
+ 1E910L,
+ 1E911L,
+ 1E912L,
+ 1E913L,
+ 1E914L,
+ 1E915L,
+ 1E916L,
+ 1E917L,
+ 1E918L,
+ 1E919L,
+ 1E920L,
+ 1E921L,
+ 1E922L,
+ 1E923L,
+ 1E924L,
+ 1E925L,
+ 1E926L,
+ 1E927L,
+ 1E928L,
+ 1E929L,
+ 1E930L,
+ 1E931L,
+ 1E932L,
+ 1E933L,
+ 1E934L,
+ 1E935L,
+ 1E936L,
+ 1E937L,
+ 1E938L,
+ 1E939L,
+ 1E940L,
+ 1E941L,
+ 1E942L,
+ 1E943L,
+ 1E944L,
+ 1E945L,
+ 1E946L,
+ 1E947L,
+ 1E948L,
+ 1E949L,
+ 1E950L,
+ 1E951L,
+ 1E952L,
+ 1E953L,
+ 1E954L,
+ 1E955L,
+ 1E956L,
+ 1E957L,
+ 1E958L,
+ 1E959L,
+ 1E960L,
+ 1E961L,
+ 1E962L,
+ 1E963L,
+ 1E964L,
+ 1E965L,
+ 1E966L,
+ 1E967L,
+ 1E968L,
+ 1E969L,
+ 1E970L,
+ 1E971L,
+ 1E972L,
+ 1E973L,
+ 1E974L,
+ 1E975L,
+ 1E976L,
+ 1E977L,
+ 1E978L,
+ 1E979L,
+ 1E980L,
+ 1E981L,
+ 1E982L,
+ 1E983L,
+ 1E984L,
+ 1E985L,
+ 1E986L,
+ 1E987L,
+ 1E988L,
+ 1E989L,
+ 1E990L,
+ 1E991L,
+ 1E992L,
+ 1E993L,
+ 1E994L,
+ 1E995L,
+ 1E996L,
+ 1E997L,
+ 1E998L,
+ 1E999L,
+ 1E1000L,
+ 1E1001L,
+ 1E1002L,
+ 1E1003L,
+ 1E1004L,
+ 1E1005L,
+ 1E1006L,
+ 1E1007L,
+ 1E1008L,
+ 1E1009L,
+ 1E1010L,
+ 1E1011L,
+ 1E1012L,
+ 1E1013L,
+ 1E1014L,
+ 1E1015L,
+ 1E1016L,
+ 1E1017L,
+ 1E1018L,
+ 1E1019L,
+ 1E1020L,
+ 1E1021L,
+ 1E1022L,
+ 1E1023L,
+ 1E1024L,
+ 1E1025L,
+ 1E1026L,
+ 1E1027L,
+ 1E1028L,
+ 1E1029L,
+ 1E1030L,
+ 1E1031L,
+ 1E1032L,
+ 1E1033L,
+ 1E1034L,
+ 1E1035L,
+ 1E1036L,
+ 1E1037L,
+ 1E1038L,
+ 1E1039L,
+ 1E1040L,
+ 1E1041L,
+ 1E1042L,
+ 1E1043L,
+ 1E1044L,
+ 1E1045L,
+ 1E1046L,
+ 1E1047L,
+ 1E1048L,
+ 1E1049L,
+ 1E1050L,
+ 1E1051L,
+ 1E1052L,
+ 1E1053L,
+ 1E1054L,
+ 1E1055L,
+ 1E1056L,
+ 1E1057L,
+ 1E1058L,
+ 1E1059L,
+ 1E1060L,
+ 1E1061L,
+ 1E1062L,
+ 1E1063L,
+ 1E1064L,
+ 1E1065L,
+ 1E1066L,
+ 1E1067L,
+ 1E1068L,
+ 1E1069L,
+ 1E1070L,
+ 1E1071L,
+ 1E1072L,
+ 1E1073L,
+ 1E1074L,
+ 1E1075L,
+ 1E1076L,
+ 1E1077L,
+ 1E1078L,
+ 1E1079L,
+ 1E1080L,
+ 1E1081L,
+ 1E1082L,
+ 1E1083L,
+ 1E1084L,
+ 1E1085L,
+ 1E1086L,
+ 1E1087L,
+ 1E1088L,
+ 1E1089L,
+ 1E1090L,
+ 1E1091L,
+ 1E1092L,
+ 1E1093L,
+ 1E1094L,
+ 1E1095L,
+ 1E1096L,
+ 1E1097L,
+ 1E1098L,
+ 1E1099L,
+ 1E1100L,
+ 1E1101L,
+ 1E1102L,
+ 1E1103L,
+ 1E1104L,
+ 1E1105L,
+ 1E1106L,
+ 1E1107L,
+ 1E1108L,
+ 1E1109L,
+ 1E1110L,
+ 1E1111L,
+ 1E1112L,
+ 1E1113L,
+ 1E1114L,
+ 1E1115L,
+ 1E1116L,
+ 1E1117L,
+ 1E1118L,
+ 1E1119L,
+ 1E1120L,
+ 1E1121L,
+ 1E1122L,
+ 1E1123L,
+ 1E1124L,
+ 1E1125L,
+ 1E1126L,
+ 1E1127L,
+ 1E1128L,
+ 1E1129L,
+ 1E1130L,
+ 1E1131L,
+ 1E1132L,
+ 1E1133L,
+ 1E1134L,
+ 1E1135L,
+ 1E1136L,
+ 1E1137L,
+ 1E1138L,
+ 1E1139L,
+ 1E1140L,
+ 1E1141L,
+ 1E1142L,
+ 1E1143L,
+ 1E1144L,
+ 1E1145L,
+ 1E1146L,
+ 1E1147L,
+ 1E1148L,
+ 1E1149L,
+ 1E1150L,
+ 1E1151L,
+ 1E1152L,
+ 1E1153L,
+ 1E1154L,
+ 1E1155L,
+ 1E1156L,
+ 1E1157L,
+ 1E1158L,
+ 1E1159L,
+ 1E1160L,
+ 1E1161L,
+ 1E1162L,
+ 1E1163L,
+ 1E1164L,
+ 1E1165L,
+ 1E1166L,
+ 1E1167L,
+ 1E1168L,
+ 1E1169L,
+ 1E1170L,
+ 1E1171L,
+ 1E1172L,
+ 1E1173L,
+ 1E1174L,
+ 1E1175L,
+ 1E1176L,
+ 1E1177L,
+ 1E1178L,
+ 1E1179L,
+ 1E1180L,
+ 1E1181L,
+ 1E1182L,
+ 1E1183L,
+ 1E1184L,
+ 1E1185L,
+ 1E1186L,
+ 1E1187L,
+ 1E1188L,
+ 1E1189L,
+ 1E1190L,
+ 1E1191L,
+ 1E1192L,
+ 1E1193L,
+ 1E1194L,
+ 1E1195L,
+ 1E1196L,
+ 1E1197L,
+ 1E1198L,
+ 1E1199L,
+ 1E1200L,
+ 1E1201L,
+ 1E1202L,
+ 1E1203L,
+ 1E1204L,
+ 1E1205L,
+ 1E1206L,
+ 1E1207L,
+ 1E1208L,
+ 1E1209L,
+ 1E1210L,
+ 1E1211L,
+ 1E1212L,
+ 1E1213L,
+ 1E1214L,
+ 1E1215L,
+ 1E1216L,
+ 1E1217L,
+ 1E1218L,
+ 1E1219L,
+ 1E1220L,
+ 1E1221L,
+ 1E1222L,
+ 1E1223L,
+ 1E1224L,
+ 1E1225L,
+ 1E1226L,
+ 1E1227L,
+ 1E1228L,
+ 1E1229L,
+ 1E1230L,
+ 1E1231L,
+ 1E1232L,
+ 1E1233L,
+ 1E1234L,
+ 1E1235L,
+ 1E1236L,
+ 1E1237L,
+ 1E1238L,
+ 1E1239L,
+ 1E1240L,
+ 1E1241L,
+ 1E1242L,
+ 1E1243L,
+ 1E1244L,
+ 1E1245L,
+ 1E1246L,
+ 1E1247L,
+ 1E1248L,
+ 1E1249L,
+ 1E1250L,
+ 1E1251L,
+ 1E1252L,
+ 1E1253L,
+ 1E1254L,
+ 1E1255L,
+ 1E1256L,
+ 1E1257L,
+ 1E1258L,
+ 1E1259L,
+ 1E1260L,
+ 1E1261L,
+ 1E1262L,
+ 1E1263L,
+ 1E1264L,
+ 1E1265L,
+ 1E1266L,
+ 1E1267L,
+ 1E1268L,
+ 1E1269L,
+ 1E1270L,
+ 1E1271L,
+ 1E1272L,
+ 1E1273L,
+ 1E1274L,
+ 1E1275L,
+ 1E1276L,
+ 1E1277L,
+ 1E1278L,
+ 1E1279L,
+ 1E1280L,
+ 1E1281L,
+ 1E1282L,
+ 1E1283L,
+ 1E1284L,
+ 1E1285L,
+ 1E1286L,
+ 1E1287L,
+ 1E1288L,
+ 1E1289L,
+ 1E1290L,
+ 1E1291L,
+ 1E1292L,
+ 1E1293L,
+ 1E1294L,
+ 1E1295L,
+ 1E1296L,
+ 1E1297L,
+ 1E1298L,
+ 1E1299L,
+ 1E1300L,
+ 1E1301L,
+ 1E1302L,
+ 1E1303L,
+ 1E1304L,
+ 1E1305L,
+ 1E1306L,
+ 1E1307L,
+ 1E1308L,
+ 1E1309L,
+ 1E1310L,
+ 1E1311L,
+ 1E1312L,
+ 1E1313L,
+ 1E1314L,
+ 1E1315L,
+ 1E1316L,
+ 1E1317L,
+ 1E1318L,
+ 1E1319L,
+ 1E1320L,
+ 1E1321L,
+ 1E1322L,
+ 1E1323L,
+ 1E1324L,
+ 1E1325L,
+ 1E1326L,
+ 1E1327L,
+ 1E1328L,
+ 1E1329L,
+ 1E1330L,
+ 1E1331L,
+ 1E1332L,
+ 1E1333L,
+ 1E1334L,
+ 1E1335L,
+ 1E1336L,
+ 1E1337L,
+ 1E1338L,
+ 1E1339L,
+ 1E1340L,
+ 1E1341L,
+ 1E1342L,
+ 1E1343L,
+ 1E1344L,
+ 1E1345L,
+ 1E1346L,
+ 1E1347L,
+ 1E1348L,
+ 1E1349L,
+ 1E1350L,
+ 1E1351L,
+ 1E1352L,
+ 1E1353L,
+ 1E1354L,
+ 1E1355L,
+ 1E1356L,
+ 1E1357L,
+ 1E1358L,
+ 1E1359L,
+ 1E1360L,
+ 1E1361L,
+ 1E1362L,
+ 1E1363L,
+ 1E1364L,
+ 1E1365L,
+ 1E1366L,
+ 1E1367L,
+ 1E1368L,
+ 1E1369L,
+ 1E1370L,
+ 1E1371L,
+ 1E1372L,
+ 1E1373L,
+ 1E1374L,
+ 1E1375L,
+ 1E1376L,
+ 1E1377L,
+ 1E1378L,
+ 1E1379L,
+ 1E1380L,
+ 1E1381L,
+ 1E1382L,
+ 1E1383L,
+ 1E1384L,
+ 1E1385L,
+ 1E1386L,
+ 1E1387L,
+ 1E1388L,
+ 1E1389L,
+ 1E1390L,
+ 1E1391L,
+ 1E1392L,
+ 1E1393L,
+ 1E1394L,
+ 1E1395L,
+ 1E1396L,
+ 1E1397L,
+ 1E1398L,
+ 1E1399L,
+ 1E1400L,
+ 1E1401L,
+ 1E1402L,
+ 1E1403L,
+ 1E1404L,
+ 1E1405L,
+ 1E1406L,
+ 1E1407L,
+ 1E1408L,
+ 1E1409L,
+ 1E1410L,
+ 1E1411L,
+ 1E1412L,
+ 1E1413L,
+ 1E1414L,
+ 1E1415L,
+ 1E1416L,
+ 1E1417L,
+ 1E1418L,
+ 1E1419L,
+ 1E1420L,
+ 1E1421L,
+ 1E1422L,
+ 1E1423L,
+ 1E1424L,
+ 1E1425L,
+ 1E1426L,
+ 1E1427L,
+ 1E1428L,
+ 1E1429L,
+ 1E1430L,
+ 1E1431L,
+ 1E1432L,
+ 1E1433L,
+ 1E1434L,
+ 1E1435L,
+ 1E1436L,
+ 1E1437L,
+ 1E1438L,
+ 1E1439L,
+ 1E1440L,
+ 1E1441L,
+ 1E1442L,
+ 1E1443L,
+ 1E1444L,
+ 1E1445L,
+ 1E1446L,
+ 1E1447L,
+ 1E1448L,
+ 1E1449L,
+ 1E1450L,
+ 1E1451L,
+ 1E1452L,
+ 1E1453L,
+ 1E1454L,
+ 1E1455L,
+ 1E1456L,
+ 1E1457L,
+ 1E1458L,
+ 1E1459L,
+ 1E1460L,
+ 1E1461L,
+ 1E1462L,
+ 1E1463L,
+ 1E1464L,
+ 1E1465L,
+ 1E1466L,
+ 1E1467L,
+ 1E1468L,
+ 1E1469L,
+ 1E1470L,
+ 1E1471L,
+ 1E1472L,
+ 1E1473L,
+ 1E1474L,
+ 1E1475L,
+ 1E1476L,
+ 1E1477L,
+ 1E1478L,
+ 1E1479L,
+ 1E1480L,
+ 1E1481L,
+ 1E1482L,
+ 1E1483L,
+ 1E1484L,
+ 1E1485L,
+ 1E1486L,
+ 1E1487L,
+ 1E1488L,
+ 1E1489L,
+ 1E1490L,
+ 1E1491L,
+ 1E1492L,
+ 1E1493L,
+ 1E1494L,
+ 1E1495L,
+ 1E1496L,
+ 1E1497L,
+ 1E1498L,
+ 1E1499L,
+ 1E1500L,
+ 1E1501L,
+ 1E1502L,
+ 1E1503L,
+ 1E1504L,
+ 1E1505L,
+ 1E1506L,
+ 1E1507L,
+ 1E1508L,
+ 1E1509L,
+ 1E1510L,
+ 1E1511L,
+ 1E1512L,
+ 1E1513L,
+ 1E1514L,
+ 1E1515L,
+ 1E1516L,
+ 1E1517L,
+ 1E1518L,
+ 1E1519L,
+ 1E1520L,
+ 1E1521L,
+ 1E1522L,
+ 1E1523L,
+ 1E1524L,
+ 1E1525L,
+ 1E1526L,
+ 1E1527L,
+ 1E1528L,
+ 1E1529L,
+ 1E1530L,
+ 1E1531L,
+ 1E1532L,
+ 1E1533L,
+ 1E1534L,
+ 1E1535L,
+ 1E1536L,
+ 1E1537L,
+ 1E1538L,
+ 1E1539L,
+ 1E1540L,
+ 1E1541L,
+ 1E1542L,
+ 1E1543L,
+ 1E1544L,
+ 1E1545L,
+ 1E1546L,
+ 1E1547L,
+ 1E1548L,
+ 1E1549L,
+ 1E1550L,
+ 1E1551L,
+ 1E1552L,
+ 1E1553L,
+ 1E1554L,
+ 1E1555L,
+ 1E1556L,
+ 1E1557L,
+ 1E1558L,
+ 1E1559L,
+ 1E1560L,
+ 1E1561L,
+ 1E1562L,
+ 1E1563L,
+ 1E1564L,
+ 1E1565L,
+ 1E1566L,
+ 1E1567L,
+ 1E1568L,
+ 1E1569L,
+ 1E1570L,
+ 1E1571L,
+ 1E1572L,
+ 1E1573L,
+ 1E1574L,
+ 1E1575L,
+ 1E1576L,
+ 1E1577L,
+ 1E1578L,
+ 1E1579L,
+ 1E1580L,
+ 1E1581L,
+ 1E1582L,
+ 1E1583L,
+ 1E1584L,
+ 1E1585L,
+ 1E1586L,
+ 1E1587L,
+ 1E1588L,
+ 1E1589L,
+ 1E1590L,
+ 1E1591L,
+ 1E1592L,
+ 1E1593L,
+ 1E1594L,
+ 1E1595L,
+ 1E1596L,
+ 1E1597L,
+ 1E1598L,
+ 1E1599L,
+ 1E1600L,
+ 1E1601L,
+ 1E1602L,
+ 1E1603L,
+ 1E1604L,
+ 1E1605L,
+ 1E1606L,
+ 1E1607L,
+ 1E1608L,
+ 1E1609L,
+ 1E1610L,
+ 1E1611L,
+ 1E1612L,
+ 1E1613L,
+ 1E1614L,
+ 1E1615L,
+ 1E1616L,
+ 1E1617L,
+ 1E1618L,
+ 1E1619L,
+ 1E1620L,
+ 1E1621L,
+ 1E1622L,
+ 1E1623L,
+ 1E1624L,
+ 1E1625L,
+ 1E1626L,
+ 1E1627L,
+ 1E1628L,
+ 1E1629L,
+ 1E1630L,
+ 1E1631L,
+ 1E1632L,
+ 1E1633L,
+ 1E1634L,
+ 1E1635L,
+ 1E1636L,
+ 1E1637L,
+ 1E1638L,
+ 1E1639L,
+ 1E1640L,
+ 1E1641L,
+ 1E1642L,
+ 1E1643L,
+ 1E1644L,
+ 1E1645L,
+ 1E1646L,
+ 1E1647L,
+ 1E1648L,
+ 1E1649L,
+ 1E1650L,
+ 1E1651L,
+ 1E1652L,
+ 1E1653L,
+ 1E1654L,
+ 1E1655L,
+ 1E1656L,
+ 1E1657L,
+ 1E1658L,
+ 1E1659L,
+ 1E1660L,
+ 1E1661L,
+ 1E1662L,
+ 1E1663L,
+ 1E1664L,
+ 1E1665L,
+ 1E1666L,
+ 1E1667L,
+ 1E1668L,
+ 1E1669L,
+ 1E1670L,
+ 1E1671L,
+ 1E1672L,
+ 1E1673L,
+ 1E1674L,
+ 1E1675L,
+ 1E1676L,
+ 1E1677L,
+ 1E1678L,
+ 1E1679L,
+ 1E1680L,
+ 1E1681L,
+ 1E1682L,
+ 1E1683L,
+ 1E1684L,
+ 1E1685L,
+ 1E1686L,
+ 1E1687L,
+ 1E1688L,
+ 1E1689L,
+ 1E1690L,
+ 1E1691L,
+ 1E1692L,
+ 1E1693L,
+ 1E1694L,
+ 1E1695L,
+ 1E1696L,
+ 1E1697L,
+ 1E1698L,
+ 1E1699L,
+ 1E1700L,
+ 1E1701L,
+ 1E1702L,
+ 1E1703L,
+ 1E1704L,
+ 1E1705L,
+ 1E1706L,
+ 1E1707L,
+ 1E1708L,
+ 1E1709L,
+ 1E1710L,
+ 1E1711L,
+ 1E1712L,
+ 1E1713L,
+ 1E1714L,
+ 1E1715L,
+ 1E1716L,
+ 1E1717L,
+ 1E1718L,
+ 1E1719L,
+ 1E1720L,
+ 1E1721L,
+ 1E1722L,
+ 1E1723L,
+ 1E1724L,
+ 1E1725L,
+ 1E1726L,
+ 1E1727L,
+ 1E1728L,
+ 1E1729L,
+ 1E1730L,
+ 1E1731L,
+ 1E1732L,
+ 1E1733L,
+ 1E1734L,
+ 1E1735L,
+ 1E1736L,
+ 1E1737L,
+ 1E1738L,
+ 1E1739L,
+ 1E1740L,
+ 1E1741L,
+ 1E1742L,
+ 1E1743L,
+ 1E1744L,
+ 1E1745L,
+ 1E1746L,
+ 1E1747L,
+ 1E1748L,
+ 1E1749L,
+ 1E1750L,
+ 1E1751L,
+ 1E1752L,
+ 1E1753L,
+ 1E1754L,
+ 1E1755L,
+ 1E1756L,
+ 1E1757L,
+ 1E1758L,
+ 1E1759L,
+ 1E1760L,
+ 1E1761L,
+ 1E1762L,
+ 1E1763L,
+ 1E1764L,
+ 1E1765L,
+ 1E1766L,
+ 1E1767L,
+ 1E1768L,
+ 1E1769L,
+ 1E1770L,
+ 1E1771L,
+ 1E1772L,
+ 1E1773L,
+ 1E1774L,
+ 1E1775L,
+ 1E1776L,
+ 1E1777L,
+ 1E1778L,
+ 1E1779L,
+ 1E1780L,
+ 1E1781L,
+ 1E1782L,
+ 1E1783L,
+ 1E1784L,
+ 1E1785L,
+ 1E1786L,
+ 1E1787L,
+ 1E1788L,
+ 1E1789L,
+ 1E1790L,
+ 1E1791L,
+ 1E1792L,
+ 1E1793L,
+ 1E1794L,
+ 1E1795L,
+ 1E1796L,
+ 1E1797L,
+ 1E1798L,
+ 1E1799L,
+ 1E1800L,
+ 1E1801L,
+ 1E1802L,
+ 1E1803L,
+ 1E1804L,
+ 1E1805L,
+ 1E1806L,
+ 1E1807L,
+ 1E1808L,
+ 1E1809L,
+ 1E1810L,
+ 1E1811L,
+ 1E1812L,
+ 1E1813L,
+ 1E1814L,
+ 1E1815L,
+ 1E1816L,
+ 1E1817L,
+ 1E1818L,
+ 1E1819L,
+ 1E1820L,
+ 1E1821L,
+ 1E1822L,
+ 1E1823L,
+ 1E1824L,
+ 1E1825L,
+ 1E1826L,
+ 1E1827L,
+ 1E1828L,
+ 1E1829L,
+ 1E1830L,
+ 1E1831L,
+ 1E1832L,
+ 1E1833L,
+ 1E1834L,
+ 1E1835L,
+ 1E1836L,
+ 1E1837L,
+ 1E1838L,
+ 1E1839L,
+ 1E1840L,
+ 1E1841L,
+ 1E1842L,
+ 1E1843L,
+ 1E1844L,
+ 1E1845L,
+ 1E1846L,
+ 1E1847L,
+ 1E1848L,
+ 1E1849L,
+ 1E1850L,
+ 1E1851L,
+ 1E1852L,
+ 1E1853L,
+ 1E1854L,
+ 1E1855L,
+ 1E1856L,
+ 1E1857L,
+ 1E1858L,
+ 1E1859L,
+ 1E1860L,
+ 1E1861L,
+ 1E1862L,
+ 1E1863L,
+ 1E1864L,
+ 1E1865L,
+ 1E1866L,
+ 1E1867L,
+ 1E1868L,
+ 1E1869L,
+ 1E1870L,
+ 1E1871L,
+ 1E1872L,
+ 1E1873L,
+ 1E1874L,
+ 1E1875L,
+ 1E1876L,
+ 1E1877L,
+ 1E1878L,
+ 1E1879L,
+ 1E1880L,
+ 1E1881L,
+ 1E1882L,
+ 1E1883L,
+ 1E1884L,
+ 1E1885L,
+ 1E1886L,
+ 1E1887L,
+ 1E1888L,
+ 1E1889L,
+ 1E1890L,
+ 1E1891L,
+ 1E1892L,
+ 1E1893L,
+ 1E1894L,
+ 1E1895L,
+ 1E1896L,
+ 1E1897L,
+ 1E1898L,
+ 1E1899L,
+ 1E1900L,
+ 1E1901L,
+ 1E1902L,
+ 1E1903L,
+ 1E1904L,
+ 1E1905L,
+ 1E1906L,
+ 1E1907L,
+ 1E1908L,
+ 1E1909L,
+ 1E1910L,
+ 1E1911L,
+ 1E1912L,
+ 1E1913L,
+ 1E1914L,
+ 1E1915L,
+ 1E1916L,
+ 1E1917L,
+ 1E1918L,
+ 1E1919L,
+ 1E1920L,
+ 1E1921L,
+ 1E1922L,
+ 1E1923L,
+ 1E1924L,
+ 1E1925L,
+ 1E1926L,
+ 1E1927L,
+ 1E1928L,
+ 1E1929L,
+ 1E1930L,
+ 1E1931L,
+ 1E1932L,
+ 1E1933L,
+ 1E1934L,
+ 1E1935L,
+ 1E1936L,
+ 1E1937L,
+ 1E1938L,
+ 1E1939L,
+ 1E1940L,
+ 1E1941L,
+ 1E1942L,
+ 1E1943L,
+ 1E1944L,
+ 1E1945L,
+ 1E1946L,
+ 1E1947L,
+ 1E1948L,
+ 1E1949L,
+ 1E1950L,
+ 1E1951L,
+ 1E1952L,
+ 1E1953L,
+ 1E1954L,
+ 1E1955L,
+ 1E1956L,
+ 1E1957L,
+ 1E1958L,
+ 1E1959L,
+ 1E1960L,
+ 1E1961L,
+ 1E1962L,
+ 1E1963L,
+ 1E1964L,
+ 1E1965L,
+ 1E1966L,
+ 1E1967L,
+ 1E1968L,
+ 1E1969L,
+ 1E1970L,
+ 1E1971L,
+ 1E1972L,
+ 1E1973L,
+ 1E1974L,
+ 1E1975L,
+ 1E1976L,
+ 1E1977L,
+ 1E1978L,
+ 1E1979L,
+ 1E1980L,
+ 1E1981L,
+ 1E1982L,
+ 1E1983L,
+ 1E1984L,
+ 1E1985L,
+ 1E1986L,
+ 1E1987L,
+ 1E1988L,
+ 1E1989L,
+ 1E1990L,
+ 1E1991L,
+ 1E1992L,
+ 1E1993L,
+ 1E1994L,
+ 1E1995L,
+ 1E1996L,
+ 1E1997L,
+ 1E1998L,
+ 1E1999L,
+ 1E2000L,
+ 1E2001L,
+ 1E2002L,
+ 1E2003L,
+ 1E2004L,
+ 1E2005L,
+ 1E2006L,
+ 1E2007L,
+ 1E2008L,
+ 1E2009L,
+ 1E2010L,
+ 1E2011L,
+ 1E2012L,
+ 1E2013L,
+ 1E2014L,
+ 1E2015L,
+ 1E2016L,
+ 1E2017L,
+ 1E2018L,
+ 1E2019L,
+ 1E2020L,
+ 1E2021L,
+ 1E2022L,
+ 1E2023L,
+ 1E2024L,
+ 1E2025L,
+ 1E2026L,
+ 1E2027L,
+ 1E2028L,
+ 1E2029L,
+ 1E2030L,
+ 1E2031L,
+ 1E2032L,
+ 1E2033L,
+ 1E2034L,
+ 1E2035L,
+ 1E2036L,
+ 1E2037L,
+ 1E2038L,
+ 1E2039L,
+ 1E2040L,
+ 1E2041L,
+ 1E2042L,
+ 1E2043L,
+ 1E2044L,
+ 1E2045L,
+ 1E2046L,
+ 1E2047L,
+ 1E2048L,
+ 1E2049L,
+ 1E2050L,
+ 1E2051L,
+ 1E2052L,
+ 1E2053L,
+ 1E2054L,
+ 1E2055L,
+ 1E2056L,
+ 1E2057L,
+ 1E2058L,
+ 1E2059L,
+ 1E2060L,
+ 1E2061L,
+ 1E2062L,
+ 1E2063L,
+ 1E2064L,
+ 1E2065L,
+ 1E2066L,
+ 1E2067L,
+ 1E2068L,
+ 1E2069L,
+ 1E2070L,
+ 1E2071L,
+ 1E2072L,
+ 1E2073L,
+ 1E2074L,
+ 1E2075L,
+ 1E2076L,
+ 1E2077L,
+ 1E2078L,
+ 1E2079L,
+ 1E2080L,
+ 1E2081L,
+ 1E2082L,
+ 1E2083L,
+ 1E2084L,
+ 1E2085L,
+ 1E2086L,
+ 1E2087L,
+ 1E2088L,
+ 1E2089L,
+ 1E2090L,
+ 1E2091L,
+ 1E2092L,
+ 1E2093L,
+ 1E2094L,
+ 1E2095L,
+ 1E2096L,
+ 1E2097L,
+ 1E2098L,
+ 1E2099L,
+ 1E2100L,
+ 1E2101L,
+ 1E2102L,
+ 1E2103L,
+ 1E2104L,
+ 1E2105L,
+ 1E2106L,
+ 1E2107L,
+ 1E2108L,
+ 1E2109L,
+ 1E2110L,
+ 1E2111L,
+ 1E2112L,
+ 1E2113L,
+ 1E2114L,
+ 1E2115L,
+ 1E2116L,
+ 1E2117L,
+ 1E2118L,
+ 1E2119L,
+ 1E2120L,
+ 1E2121L,
+ 1E2122L,
+ 1E2123L,
+ 1E2124L,
+ 1E2125L,
+ 1E2126L,
+ 1E2127L,
+ 1E2128L,
+ 1E2129L,
+ 1E2130L,
+ 1E2131L,
+ 1E2132L,
+ 1E2133L,
+ 1E2134L,
+ 1E2135L,
+ 1E2136L,
+ 1E2137L,
+ 1E2138L,
+ 1E2139L,
+ 1E2140L,
+ 1E2141L,
+ 1E2142L,
+ 1E2143L,
+ 1E2144L,
+ 1E2145L,
+ 1E2146L,
+ 1E2147L,
+ 1E2148L,
+ 1E2149L,
+ 1E2150L,
+ 1E2151L,
+ 1E2152L,
+ 1E2153L,
+ 1E2154L,
+ 1E2155L,
+ 1E2156L,
+ 1E2157L,
+ 1E2158L,
+ 1E2159L,
+ 1E2160L,
+ 1E2161L,
+ 1E2162L,
+ 1E2163L,
+ 1E2164L,
+ 1E2165L,
+ 1E2166L,
+ 1E2167L,
+ 1E2168L,
+ 1E2169L,
+ 1E2170L,
+ 1E2171L,
+ 1E2172L,
+ 1E2173L,
+ 1E2174L,
+ 1E2175L,
+ 1E2176L,
+ 1E2177L,
+ 1E2178L,
+ 1E2179L,
+ 1E2180L,
+ 1E2181L,
+ 1E2182L,
+ 1E2183L,
+ 1E2184L,
+ 1E2185L,
+ 1E2186L,
+ 1E2187L,
+ 1E2188L,
+ 1E2189L,
+ 1E2190L,
+ 1E2191L,
+ 1E2192L,
+ 1E2193L,
+ 1E2194L,
+ 1E2195L,
+ 1E2196L,
+ 1E2197L,
+ 1E2198L,
+ 1E2199L,
+ 1E2200L,
+ 1E2201L,
+ 1E2202L,
+ 1E2203L,
+ 1E2204L,
+ 1E2205L,
+ 1E2206L,
+ 1E2207L,
+ 1E2208L,
+ 1E2209L,
+ 1E2210L,
+ 1E2211L,
+ 1E2212L,
+ 1E2213L,
+ 1E2214L,
+ 1E2215L,
+ 1E2216L,
+ 1E2217L,
+ 1E2218L,
+ 1E2219L,
+ 1E2220L,
+ 1E2221L,
+ 1E2222L,
+ 1E2223L,
+ 1E2224L,
+ 1E2225L,
+ 1E2226L,
+ 1E2227L,
+ 1E2228L,
+ 1E2229L,
+ 1E2230L,
+ 1E2231L,
+ 1E2232L,
+ 1E2233L,
+ 1E2234L,
+ 1E2235L,
+ 1E2236L,
+ 1E2237L,
+ 1E2238L,
+ 1E2239L,
+ 1E2240L,
+ 1E2241L,
+ 1E2242L,
+ 1E2243L,
+ 1E2244L,
+ 1E2245L,
+ 1E2246L,
+ 1E2247L,
+ 1E2248L,
+ 1E2249L,
+ 1E2250L,
+ 1E2251L,
+ 1E2252L,
+ 1E2253L,
+ 1E2254L,
+ 1E2255L,
+ 1E2256L,
+ 1E2257L,
+ 1E2258L,
+ 1E2259L,
+ 1E2260L,
+ 1E2261L,
+ 1E2262L,
+ 1E2263L,
+ 1E2264L,
+ 1E2265L,
+ 1E2266L,
+ 1E2267L,
+ 1E2268L,
+ 1E2269L,
+ 1E2270L,
+ 1E2271L,
+ 1E2272L,
+ 1E2273L,
+ 1E2274L,
+ 1E2275L,
+ 1E2276L,
+ 1E2277L,
+ 1E2278L,
+ 1E2279L,
+ 1E2280L,
+ 1E2281L,
+ 1E2282L,
+ 1E2283L,
+ 1E2284L,
+ 1E2285L,
+ 1E2286L,
+ 1E2287L,
+ 1E2288L,
+ 1E2289L,
+ 1E2290L,
+ 1E2291L,
+ 1E2292L,
+ 1E2293L,
+ 1E2294L,
+ 1E2295L,
+ 1E2296L,
+ 1E2297L,
+ 1E2298L,
+ 1E2299L,
+ 1E2300L,
+ 1E2301L,
+ 1E2302L,
+ 1E2303L,
+ 1E2304L,
+ 1E2305L,
+ 1E2306L,
+ 1E2307L,
+ 1E2308L,
+ 1E2309L,
+ 1E2310L,
+ 1E2311L,
+ 1E2312L,
+ 1E2313L,
+ 1E2314L,
+ 1E2315L,
+ 1E2316L,
+ 1E2317L,
+ 1E2318L,
+ 1E2319L,
+ 1E2320L,
+ 1E2321L,
+ 1E2322L,
+ 1E2323L,
+ 1E2324L,
+ 1E2325L,
+ 1E2326L,
+ 1E2327L,
+ 1E2328L,
+ 1E2329L,
+ 1E2330L,
+ 1E2331L,
+ 1E2332L,
+ 1E2333L,
+ 1E2334L,
+ 1E2335L,
+ 1E2336L,
+ 1E2337L,
+ 1E2338L,
+ 1E2339L,
+ 1E2340L,
+ 1E2341L,
+ 1E2342L,
+ 1E2343L,
+ 1E2344L,
+ 1E2345L,
+ 1E2346L,
+ 1E2347L,
+ 1E2348L,
+ 1E2349L,
+ 1E2350L,
+ 1E2351L,
+ 1E2352L,
+ 1E2353L,
+ 1E2354L,
+ 1E2355L,
+ 1E2356L,
+ 1E2357L,
+ 1E2358L,
+ 1E2359L,
+ 1E2360L,
+ 1E2361L,
+ 1E2362L,
+ 1E2363L,
+ 1E2364L,
+ 1E2365L,
+ 1E2366L,
+ 1E2367L,
+ 1E2368L,
+ 1E2369L,
+ 1E2370L,
+ 1E2371L,
+ 1E2372L,
+ 1E2373L,
+ 1E2374L,
+ 1E2375L,
+ 1E2376L,
+ 1E2377L,
+ 1E2378L,
+ 1E2379L,
+ 1E2380L,
+ 1E2381L,
+ 1E2382L,
+ 1E2383L,
+ 1E2384L,
+ 1E2385L,
+ 1E2386L,
+ 1E2387L,
+ 1E2388L,
+ 1E2389L,
+ 1E2390L,
+ 1E2391L,
+ 1E2392L,
+ 1E2393L,
+ 1E2394L,
+ 1E2395L,
+ 1E2396L,
+ 1E2397L,
+ 1E2398L,
+ 1E2399L,
+ 1E2400L,
+ 1E2401L,
+ 1E2402L,
+ 1E2403L,
+ 1E2404L,
+ 1E2405L,
+ 1E2406L,
+ 1E2407L,
+ 1E2408L,
+ 1E2409L,
+ 1E2410L,
+ 1E2411L,
+ 1E2412L,
+ 1E2413L,
+ 1E2414L,
+ 1E2415L,
+ 1E2416L,
+ 1E2417L,
+ 1E2418L,
+ 1E2419L,
+ 1E2420L,
+ 1E2421L,
+ 1E2422L,
+ 1E2423L,
+ 1E2424L,
+ 1E2425L,
+ 1E2426L,
+ 1E2427L,
+ 1E2428L,
+ 1E2429L,
+ 1E2430L,
+ 1E2431L,
+ 1E2432L,
+ 1E2433L,
+ 1E2434L,
+ 1E2435L,
+ 1E2436L,
+ 1E2437L,
+ 1E2438L,
+ 1E2439L,
+ 1E2440L,
+ 1E2441L,
+ 1E2442L,
+ 1E2443L,
+ 1E2444L,
+ 1E2445L,
+ 1E2446L,
+ 1E2447L,
+ 1E2448L,
+ 1E2449L,
+ 1E2450L,
+ 1E2451L,
+ 1E2452L,
+ 1E2453L,
+ 1E2454L,
+ 1E2455L,
+ 1E2456L,
+ 1E2457L,
+ 1E2458L,
+ 1E2459L,
+ 1E2460L,
+ 1E2461L,
+ 1E2462L,
+ 1E2463L,
+ 1E2464L,
+ 1E2465L,
+ 1E2466L,
+ 1E2467L,
+ 1E2468L,
+ 1E2469L,
+ 1E2470L,
+ 1E2471L,
+ 1E2472L,
+ 1E2473L,
+ 1E2474L,
+ 1E2475L,
+ 1E2476L,
+ 1E2477L,
+ 1E2478L,
+ 1E2479L,
+ 1E2480L,
+ 1E2481L,
+ 1E2482L,
+ 1E2483L,
+ 1E2484L,
+ 1E2485L,
+ 1E2486L,
+ 1E2487L,
+ 1E2488L,
+ 1E2489L,
+ 1E2490L,
+ 1E2491L,
+ 1E2492L,
+ 1E2493L,
+ 1E2494L,
+ 1E2495L,
+ 1E2496L,
+ 1E2497L,
+ 1E2498L,
+ 1E2499L,
+ 1E2500L,
+ 1E2501L,
+ 1E2502L,
+ 1E2503L,
+ 1E2504L,
+ 1E2505L,
+ 1E2506L,
+ 1E2507L,
+ 1E2508L,
+ 1E2509L,
+ 1E2510L,
+ 1E2511L,
+ 1E2512L,
+ 1E2513L,
+ 1E2514L,
+ 1E2515L,
+ 1E2516L,
+ 1E2517L,
+ 1E2518L,
+ 1E2519L,
+ 1E2520L,
+ 1E2521L,
+ 1E2522L,
+ 1E2523L,
+ 1E2524L,
+ 1E2525L,
+ 1E2526L,
+ 1E2527L,
+ 1E2528L,
+ 1E2529L,
+ 1E2530L,
+ 1E2531L,
+ 1E2532L,
+ 1E2533L,
+ 1E2534L,
+ 1E2535L,
+ 1E2536L,
+ 1E2537L,
+ 1E2538L,
+ 1E2539L,
+ 1E2540L,
+ 1E2541L,
+ 1E2542L,
+ 1E2543L,
+ 1E2544L,
+ 1E2545L,
+ 1E2546L,
+ 1E2547L,
+ 1E2548L,
+ 1E2549L,
+ 1E2550L,
+ 1E2551L,
+ 1E2552L,
+ 1E2553L,
+ 1E2554L,
+ 1E2555L,
+ 1E2556L,
+ 1E2557L,
+ 1E2558L,
+ 1E2559L,
+ 1E2560L,
+ 1E2561L,
+ 1E2562L,
+ 1E2563L,
+ 1E2564L,
+ 1E2565L,
+ 1E2566L,
+ 1E2567L,
+ 1E2568L,
+ 1E2569L,
+ 1E2570L,
+ 1E2571L,
+ 1E2572L,
+ 1E2573L,
+ 1E2574L,
+ 1E2575L,
+ 1E2576L,
+ 1E2577L,
+ 1E2578L,
+ 1E2579L,
+ 1E2580L,
+ 1E2581L,
+ 1E2582L,
+ 1E2583L,
+ 1E2584L,
+ 1E2585L,
+ 1E2586L,
+ 1E2587L,
+ 1E2588L,
+ 1E2589L,
+ 1E2590L,
+ 1E2591L,
+ 1E2592L,
+ 1E2593L,
+ 1E2594L,
+ 1E2595L,
+ 1E2596L,
+ 1E2597L,
+ 1E2598L,
+ 1E2599L,
+ 1E2600L,
+ 1E2601L,
+ 1E2602L,
+ 1E2603L,
+ 1E2604L,
+ 1E2605L,
+ 1E2606L,
+ 1E2607L,
+ 1E2608L,
+ 1E2609L,
+ 1E2610L,
+ 1E2611L,
+ 1E2612L,
+ 1E2613L,
+ 1E2614L,
+ 1E2615L,
+ 1E2616L,
+ 1E2617L,
+ 1E2618L,
+ 1E2619L,
+ 1E2620L,
+ 1E2621L,
+ 1E2622L,
+ 1E2623L,
+ 1E2624L,
+ 1E2625L,
+ 1E2626L,
+ 1E2627L,
+ 1E2628L,
+ 1E2629L,
+ 1E2630L,
+ 1E2631L,
+ 1E2632L,
+ 1E2633L,
+ 1E2634L,
+ 1E2635L,
+ 1E2636L,
+ 1E2637L,
+ 1E2638L,
+ 1E2639L,
+ 1E2640L,
+ 1E2641L,
+ 1E2642L,
+ 1E2643L,
+ 1E2644L,
+ 1E2645L,
+ 1E2646L,
+ 1E2647L,
+ 1E2648L,
+ 1E2649L,
+ 1E2650L,
+ 1E2651L,
+ 1E2652L,
+ 1E2653L,
+ 1E2654L,
+ 1E2655L,
+ 1E2656L,
+ 1E2657L,
+ 1E2658L,
+ 1E2659L,
+ 1E2660L,
+ 1E2661L,
+ 1E2662L,
+ 1E2663L,
+ 1E2664L,
+ 1E2665L,
+ 1E2666L,
+ 1E2667L,
+ 1E2668L,
+ 1E2669L,
+ 1E2670L,
+ 1E2671L,
+ 1E2672L,
+ 1E2673L,
+ 1E2674L,
+ 1E2675L,
+ 1E2676L,
+ 1E2677L,
+ 1E2678L,
+ 1E2679L,
+ 1E2680L,
+ 1E2681L,
+ 1E2682L,
+ 1E2683L,
+ 1E2684L,
+ 1E2685L,
+ 1E2686L,
+ 1E2687L,
+ 1E2688L,
+ 1E2689L,
+ 1E2690L,
+ 1E2691L,
+ 1E2692L,
+ 1E2693L,
+ 1E2694L,
+ 1E2695L,
+ 1E2696L,
+ 1E2697L,
+ 1E2698L,
+ 1E2699L,
+ 1E2700L,
+ 1E2701L,
+ 1E2702L,
+ 1E2703L,
+ 1E2704L,
+ 1E2705L,
+ 1E2706L,
+ 1E2707L,
+ 1E2708L,
+ 1E2709L,
+ 1E2710L,
+ 1E2711L,
+ 1E2712L,
+ 1E2713L,
+ 1E2714L,
+ 1E2715L,
+ 1E2716L,
+ 1E2717L,
+ 1E2718L,
+ 1E2719L,
+ 1E2720L,
+ 1E2721L,
+ 1E2722L,
+ 1E2723L,
+ 1E2724L,
+ 1E2725L,
+ 1E2726L,
+ 1E2727L,
+ 1E2728L,
+ 1E2729L,
+ 1E2730L,
+ 1E2731L,
+ 1E2732L,
+ 1E2733L,
+ 1E2734L,
+ 1E2735L,
+ 1E2736L,
+ 1E2737L,
+ 1E2738L,
+ 1E2739L,
+ 1E2740L,
+ 1E2741L,
+ 1E2742L,
+ 1E2743L,
+ 1E2744L,
+ 1E2745L,
+ 1E2746L,
+ 1E2747L,
+ 1E2748L,
+ 1E2749L,
+ 1E2750L,
+ 1E2751L,
+ 1E2752L,
+ 1E2753L,
+ 1E2754L,
+ 1E2755L,
+ 1E2756L,
+ 1E2757L,
+ 1E2758L,
+ 1E2759L,
+ 1E2760L,
+ 1E2761L,
+ 1E2762L,
+ 1E2763L,
+ 1E2764L,
+ 1E2765L,
+ 1E2766L,
+ 1E2767L,
+ 1E2768L,
+ 1E2769L,
+ 1E2770L,
+ 1E2771L,
+ 1E2772L,
+ 1E2773L,
+ 1E2774L,
+ 1E2775L,
+ 1E2776L,
+ 1E2777L,
+ 1E2778L,
+ 1E2779L,
+ 1E2780L,
+ 1E2781L,
+ 1E2782L,
+ 1E2783L,
+ 1E2784L,
+ 1E2785L,
+ 1E2786L,
+ 1E2787L,
+ 1E2788L,
+ 1E2789L,
+ 1E2790L,
+ 1E2791L,
+ 1E2792L,
+ 1E2793L,
+ 1E2794L,
+ 1E2795L,
+ 1E2796L,
+ 1E2797L,
+ 1E2798L,
+ 1E2799L,
+ 1E2800L,
+ 1E2801L,
+ 1E2802L,
+ 1E2803L,
+ 1E2804L,
+ 1E2805L,
+ 1E2806L,
+ 1E2807L,
+ 1E2808L,
+ 1E2809L,
+ 1E2810L,
+ 1E2811L,
+ 1E2812L,
+ 1E2813L,
+ 1E2814L,
+ 1E2815L,
+ 1E2816L,
+ 1E2817L,
+ 1E2818L,
+ 1E2819L,
+ 1E2820L,
+ 1E2821L,
+ 1E2822L,
+ 1E2823L,
+ 1E2824L,
+ 1E2825L,
+ 1E2826L,
+ 1E2827L,
+ 1E2828L,
+ 1E2829L,
+ 1E2830L,
+ 1E2831L,
+ 1E2832L,
+ 1E2833L,
+ 1E2834L,
+ 1E2835L,
+ 1E2836L,
+ 1E2837L,
+ 1E2838L,
+ 1E2839L,
+ 1E2840L,
+ 1E2841L,
+ 1E2842L,
+ 1E2843L,
+ 1E2844L,
+ 1E2845L,
+ 1E2846L,
+ 1E2847L,
+ 1E2848L,
+ 1E2849L,
+ 1E2850L,
+ 1E2851L,
+ 1E2852L,
+ 1E2853L,
+ 1E2854L,
+ 1E2855L,
+ 1E2856L,
+ 1E2857L,
+ 1E2858L,
+ 1E2859L,
+ 1E2860L,
+ 1E2861L,
+ 1E2862L,
+ 1E2863L,
+ 1E2864L,
+ 1E2865L,
+ 1E2866L,
+ 1E2867L,
+ 1E2868L,
+ 1E2869L,
+ 1E2870L,
+ 1E2871L,
+ 1E2872L,
+ 1E2873L,
+ 1E2874L,
+ 1E2875L,
+ 1E2876L,
+ 1E2877L,
+ 1E2878L,
+ 1E2879L,
+ 1E2880L,
+ 1E2881L,
+ 1E2882L,
+ 1E2883L,
+ 1E2884L,
+ 1E2885L,
+ 1E2886L,
+ 1E2887L,
+ 1E2888L,
+ 1E2889L,
+ 1E2890L,
+ 1E2891L,
+ 1E2892L,
+ 1E2893L,
+ 1E2894L,
+ 1E2895L,
+ 1E2896L,
+ 1E2897L,
+ 1E2898L,
+ 1E2899L,
+ 1E2900L,
+ 1E2901L,
+ 1E2902L,
+ 1E2903L,
+ 1E2904L,
+ 1E2905L,
+ 1E2906L,
+ 1E2907L,
+ 1E2908L,
+ 1E2909L,
+ 1E2910L,
+ 1E2911L,
+ 1E2912L,
+ 1E2913L,
+ 1E2914L,
+ 1E2915L,
+ 1E2916L,
+ 1E2917L,
+ 1E2918L,
+ 1E2919L,
+ 1E2920L,
+ 1E2921L,
+ 1E2922L,
+ 1E2923L,
+ 1E2924L,
+ 1E2925L,
+ 1E2926L,
+ 1E2927L,
+ 1E2928L,
+ 1E2929L,
+ 1E2930L,
+ 1E2931L,
+ 1E2932L,
+ 1E2933L,
+ 1E2934L,
+ 1E2935L,
+ 1E2936L,
+ 1E2937L,
+ 1E2938L,
+ 1E2939L,
+ 1E2940L,
+ 1E2941L,
+ 1E2942L,
+ 1E2943L,
+ 1E2944L,
+ 1E2945L,
+ 1E2946L,
+ 1E2947L,
+ 1E2948L,
+ 1E2949L,
+ 1E2950L,
+ 1E2951L,
+ 1E2952L,
+ 1E2953L,
+ 1E2954L,
+ 1E2955L,
+ 1E2956L,
+ 1E2957L,
+ 1E2958L,
+ 1E2959L,
+ 1E2960L,
+ 1E2961L,
+ 1E2962L,
+ 1E2963L,
+ 1E2964L,
+ 1E2965L,
+ 1E2966L,
+ 1E2967L,
+ 1E2968L,
+ 1E2969L,
+ 1E2970L,
+ 1E2971L,
+ 1E2972L,
+ 1E2973L,
+ 1E2974L,
+ 1E2975L,
+ 1E2976L,
+ 1E2977L,
+ 1E2978L,
+ 1E2979L,
+ 1E2980L,
+ 1E2981L,
+ 1E2982L,
+ 1E2983L,
+ 1E2984L,
+ 1E2985L,
+ 1E2986L,
+ 1E2987L,
+ 1E2988L,
+ 1E2989L,
+ 1E2990L,
+ 1E2991L,
+ 1E2992L,
+ 1E2993L,
+ 1E2994L,
+ 1E2995L,
+ 1E2996L,
+ 1E2997L,
+ 1E2998L,
+ 1E2999L,
+ 1E3000L,
+ 1E3001L,
+ 1E3002L,
+ 1E3003L,
+ 1E3004L,
+ 1E3005L,
+ 1E3006L,
+ 1E3007L,
+ 1E3008L,
+ 1E3009L,
+ 1E3010L,
+ 1E3011L,
+ 1E3012L,
+ 1E3013L,
+ 1E3014L,
+ 1E3015L,
+ 1E3016L,
+ 1E3017L,
+ 1E3018L,
+ 1E3019L,
+ 1E3020L,
+ 1E3021L,
+ 1E3022L,
+ 1E3023L,
+ 1E3024L,
+ 1E3025L,
+ 1E3026L,
+ 1E3027L,
+ 1E3028L,
+ 1E3029L,
+ 1E3030L,
+ 1E3031L,
+ 1E3032L,
+ 1E3033L,
+ 1E3034L,
+ 1E3035L,
+ 1E3036L,
+ 1E3037L,
+ 1E3038L,
+ 1E3039L,
+ 1E3040L,
+ 1E3041L,
+ 1E3042L,
+ 1E3043L,
+ 1E3044L,
+ 1E3045L,
+ 1E3046L,
+ 1E3047L,
+ 1E3048L,
+ 1E3049L,
+ 1E3050L,
+ 1E3051L,
+ 1E3052L,
+ 1E3053L,
+ 1E3054L,
+ 1E3055L,
+ 1E3056L,
+ 1E3057L,
+ 1E3058L,
+ 1E3059L,
+ 1E3060L,
+ 1E3061L,
+ 1E3062L,
+ 1E3063L,
+ 1E3064L,
+ 1E3065L,
+ 1E3066L,
+ 1E3067L,
+ 1E3068L,
+ 1E3069L,
+ 1E3070L,
+ 1E3071L,
+ 1E3072L,
+ 1E3073L,
+ 1E3074L,
+ 1E3075L,
+ 1E3076L,
+ 1E3077L,
+ 1E3078L,
+ 1E3079L,
+ 1E3080L,
+ 1E3081L,
+ 1E3082L,
+ 1E3083L,
+ 1E3084L,
+ 1E3085L,
+ 1E3086L,
+ 1E3087L,
+ 1E3088L,
+ 1E3089L,
+ 1E3090L,
+ 1E3091L,
+ 1E3092L,
+ 1E3093L,
+ 1E3094L,
+ 1E3095L,
+ 1E3096L,
+ 1E3097L,
+ 1E3098L,
+ 1E3099L,
+ 1E3100L,
+ 1E3101L,
+ 1E3102L,
+ 1E3103L,
+ 1E3104L,
+ 1E3105L,
+ 1E3106L,
+ 1E3107L,
+ 1E3108L,
+ 1E3109L,
+ 1E3110L,
+ 1E3111L,
+ 1E3112L,
+ 1E3113L,
+ 1E3114L,
+ 1E3115L,
+ 1E3116L,
+ 1E3117L,
+ 1E3118L,
+ 1E3119L,
+ 1E3120L,
+ 1E3121L,
+ 1E3122L,
+ 1E3123L,
+ 1E3124L,
+ 1E3125L,
+ 1E3126L,
+ 1E3127L,
+ 1E3128L,
+ 1E3129L,
+ 1E3130L,
+ 1E3131L,
+ 1E3132L,
+ 1E3133L,
+ 1E3134L,
+ 1E3135L,
+ 1E3136L,
+ 1E3137L,
+ 1E3138L,
+ 1E3139L,
+ 1E3140L,
+ 1E3141L,
+ 1E3142L,
+ 1E3143L,
+ 1E3144L,
+ 1E3145L,
+ 1E3146L,
+ 1E3147L,
+ 1E3148L,
+ 1E3149L,
+ 1E3150L,
+ 1E3151L,
+ 1E3152L,
+ 1E3153L,
+ 1E3154L,
+ 1E3155L,
+ 1E3156L,
+ 1E3157L,
+ 1E3158L,
+ 1E3159L,
+ 1E3160L,
+ 1E3161L,
+ 1E3162L,
+ 1E3163L,
+ 1E3164L,
+ 1E3165L,
+ 1E3166L,
+ 1E3167L,
+ 1E3168L,
+ 1E3169L,
+ 1E3170L,
+ 1E3171L,
+ 1E3172L,
+ 1E3173L,
+ 1E3174L,
+ 1E3175L,
+ 1E3176L,
+ 1E3177L,
+ 1E3178L,
+ 1E3179L,
+ 1E3180L,
+ 1E3181L,
+ 1E3182L,
+ 1E3183L,
+ 1E3184L,
+ 1E3185L,
+ 1E3186L,
+ 1E3187L,
+ 1E3188L,
+ 1E3189L,
+ 1E3190L,
+ 1E3191L,
+ 1E3192L,
+ 1E3193L,
+ 1E3194L,
+ 1E3195L,
+ 1E3196L,
+ 1E3197L,
+ 1E3198L,
+ 1E3199L,
+ 1E3200L,
+ 1E3201L,
+ 1E3202L,
+ 1E3203L,
+ 1E3204L,
+ 1E3205L,
+ 1E3206L,
+ 1E3207L,
+ 1E3208L,
+ 1E3209L,
+ 1E3210L,
+ 1E3211L,
+ 1E3212L,
+ 1E3213L,
+ 1E3214L,
+ 1E3215L,
+ 1E3216L,
+ 1E3217L,
+ 1E3218L,
+ 1E3219L,
+ 1E3220L,
+ 1E3221L,
+ 1E3222L,
+ 1E3223L,
+ 1E3224L,
+ 1E3225L,
+ 1E3226L,
+ 1E3227L,
+ 1E3228L,
+ 1E3229L,
+ 1E3230L,
+ 1E3231L,
+ 1E3232L,
+ 1E3233L,
+ 1E3234L,
+ 1E3235L,
+ 1E3236L,
+ 1E3237L,
+ 1E3238L,
+ 1E3239L,
+ 1E3240L,
+ 1E3241L,
+ 1E3242L,
+ 1E3243L,
+ 1E3244L,
+ 1E3245L,
+ 1E3246L,
+ 1E3247L,
+ 1E3248L,
+ 1E3249L,
+ 1E3250L,
+ 1E3251L,
+ 1E3252L,
+ 1E3253L,
+ 1E3254L,
+ 1E3255L,
+ 1E3256L,
+ 1E3257L,
+ 1E3258L,
+ 1E3259L,
+ 1E3260L,
+ 1E3261L,
+ 1E3262L,
+ 1E3263L,
+ 1E3264L,
+ 1E3265L,
+ 1E3266L,
+ 1E3267L,
+ 1E3268L,
+ 1E3269L,
+ 1E3270L,
+ 1E3271L,
+ 1E3272L,
+ 1E3273L,
+ 1E3274L,
+ 1E3275L,
+ 1E3276L,
+ 1E3277L,
+ 1E3278L,
+ 1E3279L,
+ 1E3280L,
+ 1E3281L,
+ 1E3282L,
+ 1E3283L,
+ 1E3284L,
+ 1E3285L,
+ 1E3286L,
+ 1E3287L,
+ 1E3288L,
+ 1E3289L,
+ 1E3290L,
+ 1E3291L,
+ 1E3292L,
+ 1E3293L,
+ 1E3294L,
+ 1E3295L,
+ 1E3296L,
+ 1E3297L,
+ 1E3298L,
+ 1E3299L,
+ 1E3300L,
+ 1E3301L,
+ 1E3302L,
+ 1E3303L,
+ 1E3304L,
+ 1E3305L,
+ 1E3306L,
+ 1E3307L,
+ 1E3308L,
+ 1E3309L,
+ 1E3310L,
+ 1E3311L,
+ 1E3312L,
+ 1E3313L,
+ 1E3314L,
+ 1E3315L,
+ 1E3316L,
+ 1E3317L,
+ 1E3318L,
+ 1E3319L,
+ 1E3320L,
+ 1E3321L,
+ 1E3322L,
+ 1E3323L,
+ 1E3324L,
+ 1E3325L,
+ 1E3326L,
+ 1E3327L,
+ 1E3328L,
+ 1E3329L,
+ 1E3330L,
+ 1E3331L,
+ 1E3332L,
+ 1E3333L,
+ 1E3334L,
+ 1E3335L,
+ 1E3336L,
+ 1E3337L,
+ 1E3338L,
+ 1E3339L,
+ 1E3340L,
+ 1E3341L,
+ 1E3342L,
+ 1E3343L,
+ 1E3344L,
+ 1E3345L,
+ 1E3346L,
+ 1E3347L,
+ 1E3348L,
+ 1E3349L,
+ 1E3350L,
+ 1E3351L,
+ 1E3352L,
+ 1E3353L,
+ 1E3354L,
+ 1E3355L,
+ 1E3356L,
+ 1E3357L,
+ 1E3358L,
+ 1E3359L,
+ 1E3360L,
+ 1E3361L,
+ 1E3362L,
+ 1E3363L,
+ 1E3364L,
+ 1E3365L,
+ 1E3366L,
+ 1E3367L,
+ 1E3368L,
+ 1E3369L,
+ 1E3370L,
+ 1E3371L,
+ 1E3372L,
+ 1E3373L,
+ 1E3374L,
+ 1E3375L,
+ 1E3376L,
+ 1E3377L,
+ 1E3378L,
+ 1E3379L,
+ 1E3380L,
+ 1E3381L,
+ 1E3382L,
+ 1E3383L,
+ 1E3384L,
+ 1E3385L,
+ 1E3386L,
+ 1E3387L,
+ 1E3388L,
+ 1E3389L,
+ 1E3390L,
+ 1E3391L,
+ 1E3392L,
+ 1E3393L,
+ 1E3394L,
+ 1E3395L,
+ 1E3396L,
+ 1E3397L,
+ 1E3398L,
+ 1E3399L,
+ 1E3400L,
+ 1E3401L,
+ 1E3402L,
+ 1E3403L,
+ 1E3404L,
+ 1E3405L,
+ 1E3406L,
+ 1E3407L,
+ 1E3408L,
+ 1E3409L,
+ 1E3410L,
+ 1E3411L,
+ 1E3412L,
+ 1E3413L,
+ 1E3414L,
+ 1E3415L,
+ 1E3416L,
+ 1E3417L,
+ 1E3418L,
+ 1E3419L,
+ 1E3420L,
+ 1E3421L,
+ 1E3422L,
+ 1E3423L,
+ 1E3424L,
+ 1E3425L,
+ 1E3426L,
+ 1E3427L,
+ 1E3428L,
+ 1E3429L,
+ 1E3430L,
+ 1E3431L,
+ 1E3432L,
+ 1E3433L,
+ 1E3434L,
+ 1E3435L,
+ 1E3436L,
+ 1E3437L,
+ 1E3438L,
+ 1E3439L,
+ 1E3440L,
+ 1E3441L,
+ 1E3442L,
+ 1E3443L,
+ 1E3444L,
+ 1E3445L,
+ 1E3446L,
+ 1E3447L,
+ 1E3448L,
+ 1E3449L,
+ 1E3450L,
+ 1E3451L,
+ 1E3452L,
+ 1E3453L,
+ 1E3454L,
+ 1E3455L,
+ 1E3456L,
+ 1E3457L,
+ 1E3458L,
+ 1E3459L,
+ 1E3460L,
+ 1E3461L,
+ 1E3462L,
+ 1E3463L,
+ 1E3464L,
+ 1E3465L,
+ 1E3466L,
+ 1E3467L,
+ 1E3468L,
+ 1E3469L,
+ 1E3470L,
+ 1E3471L,
+ 1E3472L,
+ 1E3473L,
+ 1E3474L,
+ 1E3475L,
+ 1E3476L,
+ 1E3477L,
+ 1E3478L,
+ 1E3479L,
+ 1E3480L,
+ 1E3481L,
+ 1E3482L,
+ 1E3483L,
+ 1E3484L,
+ 1E3485L,
+ 1E3486L,
+ 1E3487L,
+ 1E3488L,
+ 1E3489L,
+ 1E3490L,
+ 1E3491L,
+ 1E3492L,
+ 1E3493L,
+ 1E3494L,
+ 1E3495L,
+ 1E3496L,
+ 1E3497L,
+ 1E3498L,
+ 1E3499L,
+ 1E3500L,
+ 1E3501L,
+ 1E3502L,
+ 1E3503L,
+ 1E3504L,
+ 1E3505L,
+ 1E3506L,
+ 1E3507L,
+ 1E3508L,
+ 1E3509L,
+ 1E3510L,
+ 1E3511L,
+ 1E3512L,
+ 1E3513L,
+ 1E3514L,
+ 1E3515L,
+ 1E3516L,
+ 1E3517L,
+ 1E3518L,
+ 1E3519L,
+ 1E3520L,
+ 1E3521L,
+ 1E3522L,
+ 1E3523L,
+ 1E3524L,
+ 1E3525L,
+ 1E3526L,
+ 1E3527L,
+ 1E3528L,
+ 1E3529L,
+ 1E3530L,
+ 1E3531L,
+ 1E3532L,
+ 1E3533L,
+ 1E3534L,
+ 1E3535L,
+ 1E3536L,
+ 1E3537L,
+ 1E3538L,
+ 1E3539L,
+ 1E3540L,
+ 1E3541L,
+ 1E3542L,
+ 1E3543L,
+ 1E3544L,
+ 1E3545L,
+ 1E3546L,
+ 1E3547L,
+ 1E3548L,
+ 1E3549L,
+ 1E3550L,
+ 1E3551L,
+ 1E3552L,
+ 1E3553L,
+ 1E3554L,
+ 1E3555L,
+ 1E3556L,
+ 1E3557L,
+ 1E3558L,
+ 1E3559L,
+ 1E3560L,
+ 1E3561L,
+ 1E3562L,
+ 1E3563L,
+ 1E3564L,
+ 1E3565L,
+ 1E3566L,
+ 1E3567L,
+ 1E3568L,
+ 1E3569L,
+ 1E3570L,
+ 1E3571L,
+ 1E3572L,
+ 1E3573L,
+ 1E3574L,
+ 1E3575L,
+ 1E3576L,
+ 1E3577L,
+ 1E3578L,
+ 1E3579L,
+ 1E3580L,
+ 1E3581L,
+ 1E3582L,
+ 1E3583L,
+ 1E3584L,
+ 1E3585L,
+ 1E3586L,
+ 1E3587L,
+ 1E3588L,
+ 1E3589L,
+ 1E3590L,
+ 1E3591L,
+ 1E3592L,
+ 1E3593L,
+ 1E3594L,
+ 1E3595L,
+ 1E3596L,
+ 1E3597L,
+ 1E3598L,
+ 1E3599L,
+ 1E3600L,
+ 1E3601L,
+ 1E3602L,
+ 1E3603L,
+ 1E3604L,
+ 1E3605L,
+ 1E3606L,
+ 1E3607L,
+ 1E3608L,
+ 1E3609L,
+ 1E3610L,
+ 1E3611L,
+ 1E3612L,
+ 1E3613L,
+ 1E3614L,
+ 1E3615L,
+ 1E3616L,
+ 1E3617L,
+ 1E3618L,
+ 1E3619L,
+ 1E3620L,
+ 1E3621L,
+ 1E3622L,
+ 1E3623L,
+ 1E3624L,
+ 1E3625L,
+ 1E3626L,
+ 1E3627L,
+ 1E3628L,
+ 1E3629L,
+ 1E3630L,
+ 1E3631L,
+ 1E3632L,
+ 1E3633L,
+ 1E3634L,
+ 1E3635L,
+ 1E3636L,
+ 1E3637L,
+ 1E3638L,
+ 1E3639L,
+ 1E3640L,
+ 1E3641L,
+ 1E3642L,
+ 1E3643L,
+ 1E3644L,
+ 1E3645L,
+ 1E3646L,
+ 1E3647L,
+ 1E3648L,
+ 1E3649L,
+ 1E3650L,
+ 1E3651L,
+ 1E3652L,
+ 1E3653L,
+ 1E3654L,
+ 1E3655L,
+ 1E3656L,
+ 1E3657L,
+ 1E3658L,
+ 1E3659L,
+ 1E3660L,
+ 1E3661L,
+ 1E3662L,
+ 1E3663L,
+ 1E3664L,
+ 1E3665L,
+ 1E3666L,
+ 1E3667L,
+ 1E3668L,
+ 1E3669L,
+ 1E3670L,
+ 1E3671L,
+ 1E3672L,
+ 1E3673L,
+ 1E3674L,
+ 1E3675L,
+ 1E3676L,
+ 1E3677L,
+ 1E3678L,
+ 1E3679L,
+ 1E3680L,
+ 1E3681L,
+ 1E3682L,
+ 1E3683L,
+ 1E3684L,
+ 1E3685L,
+ 1E3686L,
+ 1E3687L,
+ 1E3688L,
+ 1E3689L,
+ 1E3690L,
+ 1E3691L,
+ 1E3692L,
+ 1E3693L,
+ 1E3694L,
+ 1E3695L,
+ 1E3696L,
+ 1E3697L,
+ 1E3698L,
+ 1E3699L,
+ 1E3700L,
+ 1E3701L,
+ 1E3702L,
+ 1E3703L,
+ 1E3704L,
+ 1E3705L,
+ 1E3706L,
+ 1E3707L,
+ 1E3708L,
+ 1E3709L,
+ 1E3710L,
+ 1E3711L,
+ 1E3712L,
+ 1E3713L,
+ 1E3714L,
+ 1E3715L,
+ 1E3716L,
+ 1E3717L,
+ 1E3718L,
+ 1E3719L,
+ 1E3720L,
+ 1E3721L,
+ 1E3722L,
+ 1E3723L,
+ 1E3724L,
+ 1E3725L,
+ 1E3726L,
+ 1E3727L,
+ 1E3728L,
+ 1E3729L,
+ 1E3730L,
+ 1E3731L,
+ 1E3732L,
+ 1E3733L,
+ 1E3734L,
+ 1E3735L,
+ 1E3736L,
+ 1E3737L,
+ 1E3738L,
+ 1E3739L,
+ 1E3740L,
+ 1E3741L,
+ 1E3742L,
+ 1E3743L,
+ 1E3744L,
+ 1E3745L,
+ 1E3746L,
+ 1E3747L,
+ 1E3748L,
+ 1E3749L,
+ 1E3750L,
+ 1E3751L,
+ 1E3752L,
+ 1E3753L,
+ 1E3754L,
+ 1E3755L,
+ 1E3756L,
+ 1E3757L,
+ 1E3758L,
+ 1E3759L,
+ 1E3760L,
+ 1E3761L,
+ 1E3762L,
+ 1E3763L,
+ 1E3764L,
+ 1E3765L,
+ 1E3766L,
+ 1E3767L,
+ 1E3768L,
+ 1E3769L,
+ 1E3770L,
+ 1E3771L,
+ 1E3772L,
+ 1E3773L,
+ 1E3774L,
+ 1E3775L,
+ 1E3776L,
+ 1E3777L,
+ 1E3778L,
+ 1E3779L,
+ 1E3780L,
+ 1E3781L,
+ 1E3782L,
+ 1E3783L,
+ 1E3784L,
+ 1E3785L,
+ 1E3786L,
+ 1E3787L,
+ 1E3788L,
+ 1E3789L,
+ 1E3790L,
+ 1E3791L,
+ 1E3792L,
+ 1E3793L,
+ 1E3794L,
+ 1E3795L,
+ 1E3796L,
+ 1E3797L,
+ 1E3798L,
+ 1E3799L,
+ 1E3800L,
+ 1E3801L,
+ 1E3802L,
+ 1E3803L,
+ 1E3804L,
+ 1E3805L,
+ 1E3806L,
+ 1E3807L,
+ 1E3808L,
+ 1E3809L,
+ 1E3810L,
+ 1E3811L,
+ 1E3812L,
+ 1E3813L,
+ 1E3814L,
+ 1E3815L,
+ 1E3816L,
+ 1E3817L,
+ 1E3818L,
+ 1E3819L,
+ 1E3820L,
+ 1E3821L,
+ 1E3822L,
+ 1E3823L,
+ 1E3824L,
+ 1E3825L,
+ 1E3826L,
+ 1E3827L,
+ 1E3828L,
+ 1E3829L,
+ 1E3830L,
+ 1E3831L,
+ 1E3832L,
+ 1E3833L,
+ 1E3834L,
+ 1E3835L,
+ 1E3836L,
+ 1E3837L,
+ 1E3838L,
+ 1E3839L,
+ 1E3840L,
+ 1E3841L,
+ 1E3842L,
+ 1E3843L,
+ 1E3844L,
+ 1E3845L,
+ 1E3846L,
+ 1E3847L,
+ 1E3848L,
+ 1E3849L,
+ 1E3850L,
+ 1E3851L,
+ 1E3852L,
+ 1E3853L,
+ 1E3854L,
+ 1E3855L,
+ 1E3856L,
+ 1E3857L,
+ 1E3858L,
+ 1E3859L,
+ 1E3860L,
+ 1E3861L,
+ 1E3862L,
+ 1E3863L,
+ 1E3864L,
+ 1E3865L,
+ 1E3866L,
+ 1E3867L,
+ 1E3868L,
+ 1E3869L,
+ 1E3870L,
+ 1E3871L,
+ 1E3872L,
+ 1E3873L,
+ 1E3874L,
+ 1E3875L,
+ 1E3876L,
+ 1E3877L,
+ 1E3878L,
+ 1E3879L,
+ 1E3880L,
+ 1E3881L,
+ 1E3882L,
+ 1E3883L,
+ 1E3884L,
+ 1E3885L,
+ 1E3886L,
+ 1E3887L,
+ 1E3888L,
+ 1E3889L,
+ 1E3890L,
+ 1E3891L,
+ 1E3892L,
+ 1E3893L,
+ 1E3894L,
+ 1E3895L,
+ 1E3896L,
+ 1E3897L,
+ 1E3898L,
+ 1E3899L,
+ 1E3900L,
+ 1E3901L,
+ 1E3902L,
+ 1E3903L,
+ 1E3904L,
+ 1E3905L,
+ 1E3906L,
+ 1E3907L,
+ 1E3908L,
+ 1E3909L,
+ 1E3910L,
+ 1E3911L,
+ 1E3912L,
+ 1E3913L,
+ 1E3914L,
+ 1E3915L,
+ 1E3916L,
+ 1E3917L,
+ 1E3918L,
+ 1E3919L,
+ 1E3920L,
+ 1E3921L,
+ 1E3922L,
+ 1E3923L,
+ 1E3924L,
+ 1E3925L,
+ 1E3926L,
+ 1E3927L,
+ 1E3928L,
+ 1E3929L,
+ 1E3930L,
+ 1E3931L,
+ 1E3932L,
+ 1E3933L,
+ 1E3934L,
+ 1E3935L,
+ 1E3936L,
+ 1E3937L,
+ 1E3938L,
+ 1E3939L,
+ 1E3940L,
+ 1E3941L,
+ 1E3942L,
+ 1E3943L,
+ 1E3944L,
+ 1E3945L,
+ 1E3946L,
+ 1E3947L,
+ 1E3948L,
+ 1E3949L,
+ 1E3950L,
+ 1E3951L,
+ 1E3952L,
+ 1E3953L,
+ 1E3954L,
+ 1E3955L,
+ 1E3956L,
+ 1E3957L,
+ 1E3958L,
+ 1E3959L,
+ 1E3960L,
+ 1E3961L,
+ 1E3962L,
+ 1E3963L,
+ 1E3964L,
+ 1E3965L,
+ 1E3966L,
+ 1E3967L,
+ 1E3968L,
+ 1E3969L,
+ 1E3970L,
+ 1E3971L,
+ 1E3972L,
+ 1E3973L,
+ 1E3974L,
+ 1E3975L,
+ 1E3976L,
+ 1E3977L,
+ 1E3978L,
+ 1E3979L,
+ 1E3980L,
+ 1E3981L,
+ 1E3982L,
+ 1E3983L,
+ 1E3984L,
+ 1E3985L,
+ 1E3986L,
+ 1E3987L,
+ 1E3988L,
+ 1E3989L,
+ 1E3990L,
+ 1E3991L,
+ 1E3992L,
+ 1E3993L,
+ 1E3994L,
+ 1E3995L,
+ 1E3996L,
+ 1E3997L,
+ 1E3998L,
+ 1E3999L,
+ 1E4000L,
+ 1E4001L,
+ 1E4002L,
+ 1E4003L,
+ 1E4004L,
+ 1E4005L,
+ 1E4006L,
+ 1E4007L,
+ 1E4008L,
+ 1E4009L,
+ 1E4010L,
+ 1E4011L,
+ 1E4012L,
+ 1E4013L,
+ 1E4014L,
+ 1E4015L,
+ 1E4016L,
+ 1E4017L,
+ 1E4018L,
+ 1E4019L,
+ 1E4020L,
+ 1E4021L,
+ 1E4022L,
+ 1E4023L,
+ 1E4024L,
+ 1E4025L,
+ 1E4026L,
+ 1E4027L,
+ 1E4028L,
+ 1E4029L,
+ 1E4030L,
+ 1E4031L,
+ 1E4032L,
+ 1E4033L,
+ 1E4034L,
+ 1E4035L,
+ 1E4036L,
+ 1E4037L,
+ 1E4038L,
+ 1E4039L,
+ 1E4040L,
+ 1E4041L,
+ 1E4042L,
+ 1E4043L,
+ 1E4044L,
+ 1E4045L,
+ 1E4046L,
+ 1E4047L,
+ 1E4048L,
+ 1E4049L,
+ 1E4050L,
+ 1E4051L,
+ 1E4052L,
+ 1E4053L,
+ 1E4054L,
+ 1E4055L,
+ 1E4056L,
+ 1E4057L,
+ 1E4058L,
+ 1E4059L,
+ 1E4060L,
+ 1E4061L,
+ 1E4062L,
+ 1E4063L,
+ 1E4064L,
+ 1E4065L,
+ 1E4066L,
+ 1E4067L,
+ 1E4068L,
+ 1E4069L,
+ 1E4070L,
+ 1E4071L,
+ 1E4072L,
+ 1E4073L,
+ 1E4074L,
+ 1E4075L,
+ 1E4076L,
+ 1E4077L,
+ 1E4078L,
+ 1E4079L,
+ 1E4080L,
+ 1E4081L,
+ 1E4082L,
+ 1E4083L,
+ 1E4084L,
+ 1E4085L,
+ 1E4086L,
+ 1E4087L,
+ 1E4088L,
+ 1E4089L,
+ 1E4090L,
+ 1E4091L,
+ 1E4092L,
+ 1E4093L,
+ 1E4094L,
+ 1E4095L,
+ 1E4096L,
+ 1E4097L,
+ 1E4098L,
+ 1E4099L,
+ 1E4100L,
+ 1E4101L,
+ 1E4102L,
+ 1E4103L,
+ 1E4104L,
+ 1E4105L,
+ 1E4106L,
+ 1E4107L,
+ 1E4108L,
+ 1E4109L,
+ 1E4110L,
+ 1E4111L,
+ 1E4112L,
+ 1E4113L,
+ 1E4114L,
+ 1E4115L,
+ 1E4116L,
+ 1E4117L,
+ 1E4118L,
+ 1E4119L,
+ 1E4120L,
+ 1E4121L,
+ 1E4122L,
+ 1E4123L,
+ 1E4124L,
+ 1E4125L,
+ 1E4126L,
+ 1E4127L,
+ 1E4128L,
+ 1E4129L,
+ 1E4130L,
+ 1E4131L,
+ 1E4132L,
+ 1E4133L,
+ 1E4134L,
+ 1E4135L,
+ 1E4136L,
+ 1E4137L,
+ 1E4138L,
+ 1E4139L,
+ 1E4140L,
+ 1E4141L,
+ 1E4142L,
+ 1E4143L,
+ 1E4144L,
+ 1E4145L,
+ 1E4146L,
+ 1E4147L,
+ 1E4148L,
+ 1E4149L,
+ 1E4150L,
+ 1E4151L,
+ 1E4152L,
+ 1E4153L,
+ 1E4154L,
+ 1E4155L,
+ 1E4156L,
+ 1E4157L,
+ 1E4158L,
+ 1E4159L,
+ 1E4160L,
+ 1E4161L,
+ 1E4162L,
+ 1E4163L,
+ 1E4164L,
+ 1E4165L,
+ 1E4166L,
+ 1E4167L,
+ 1E4168L,
+ 1E4169L,
+ 1E4170L,
+ 1E4171L,
+ 1E4172L,
+ 1E4173L,
+ 1E4174L,
+ 1E4175L,
+ 1E4176L,
+ 1E4177L,
+ 1E4178L,
+ 1E4179L,
+ 1E4180L,
+ 1E4181L,
+ 1E4182L,
+ 1E4183L,
+ 1E4184L,
+ 1E4185L,
+ 1E4186L,
+ 1E4187L,
+ 1E4188L,
+ 1E4189L,
+ 1E4190L,
+ 1E4191L,
+ 1E4192L,
+ 1E4193L,
+ 1E4194L,
+ 1E4195L,
+ 1E4196L,
+ 1E4197L,
+ 1E4198L,
+ 1E4199L,
+ 1E4200L,
+ 1E4201L,
+ 1E4202L,
+ 1E4203L,
+ 1E4204L,
+ 1E4205L,
+ 1E4206L,
+ 1E4207L,
+ 1E4208L,
+ 1E4209L,
+ 1E4210L,
+ 1E4211L,
+ 1E4212L,
+ 1E4213L,
+ 1E4214L,
+ 1E4215L,
+ 1E4216L,
+ 1E4217L,
+ 1E4218L,
+ 1E4219L,
+ 1E4220L,
+ 1E4221L,
+ 1E4222L,
+ 1E4223L,
+ 1E4224L,
+ 1E4225L,
+ 1E4226L,
+ 1E4227L,
+ 1E4228L,
+ 1E4229L,
+ 1E4230L,
+ 1E4231L,
+ 1E4232L,
+ 1E4233L,
+ 1E4234L,
+ 1E4235L,
+ 1E4236L,
+ 1E4237L,
+ 1E4238L,
+ 1E4239L,
+ 1E4240L,
+ 1E4241L,
+ 1E4242L,
+ 1E4243L,
+ 1E4244L,
+ 1E4245L,
+ 1E4246L,
+ 1E4247L,
+ 1E4248L,
+ 1E4249L,
+ 1E4250L,
+ 1E4251L,
+ 1E4252L,
+ 1E4253L,
+ 1E4254L,
+ 1E4255L,
+ 1E4256L,
+ 1E4257L,
+ 1E4258L,
+ 1E4259L,
+ 1E4260L,
+ 1E4261L,
+ 1E4262L,
+ 1E4263L,
+ 1E4264L,
+ 1E4265L,
+ 1E4266L,
+ 1E4267L,
+ 1E4268L,
+ 1E4269L,
+ 1E4270L,
+ 1E4271L,
+ 1E4272L,
+ 1E4273L,
+ 1E4274L,
+ 1E4275L,
+ 1E4276L,
+ 1E4277L,
+ 1E4278L,
+ 1E4279L,
+ 1E4280L,
+ 1E4281L,
+ 1E4282L,
+ 1E4283L,
+ 1E4284L,
+ 1E4285L,
+ 1E4286L,
+ 1E4287L,
+ 1E4288L,
+ 1E4289L,
+ 1E4290L,
+ 1E4291L,
+ 1E4292L,
+ 1E4293L,
+ 1E4294L,
+ 1E4295L,
+ 1E4296L,
+ 1E4297L,
+ 1E4298L,
+ 1E4299L,
+ 1E4300L,
+ 1E4301L,
+ 1E4302L,
+ 1E4303L,
+ 1E4304L,
+ 1E4305L,
+ 1E4306L,
+ 1E4307L,
+ 1E4308L,
+ 1E4309L,
+ 1E4310L,
+ 1E4311L,
+ 1E4312L,
+ 1E4313L,
+ 1E4314L,
+ 1E4315L,
+ 1E4316L,
+ 1E4317L,
+ 1E4318L,
+ 1E4319L,
+ 1E4320L,
+ 1E4321L,
+ 1E4322L,
+ 1E4323L,
+ 1E4324L,
+ 1E4325L,
+ 1E4326L,
+ 1E4327L,
+ 1E4328L,
+ 1E4329L,
+ 1E4330L,
+ 1E4331L,
+ 1E4332L,
+ 1E4333L,
+ 1E4334L,
+ 1E4335L,
+ 1E4336L,
+ 1E4337L,
+ 1E4338L,
+ 1E4339L,
+ 1E4340L,
+ 1E4341L,
+ 1E4342L,
+ 1E4343L,
+ 1E4344L,
+ 1E4345L,
+ 1E4346L,
+ 1E4347L,
+ 1E4348L,
+ 1E4349L,
+ 1E4350L,
+ 1E4351L,
+ 1E4352L,
+ 1E4353L,
+ 1E4354L,
+ 1E4355L,
+ 1E4356L,
+ 1E4357L,
+ 1E4358L,
+ 1E4359L,
+ 1E4360L,
+ 1E4361L,
+ 1E4362L,
+ 1E4363L,
+ 1E4364L,
+ 1E4365L,
+ 1E4366L,
+ 1E4367L,
+ 1E4368L,
+ 1E4369L,
+ 1E4370L,
+ 1E4371L,
+ 1E4372L,
+ 1E4373L,
+ 1E4374L,
+ 1E4375L,
+ 1E4376L,
+ 1E4377L,
+ 1E4378L,
+ 1E4379L,
+ 1E4380L,
+ 1E4381L,
+ 1E4382L,
+ 1E4383L,
+ 1E4384L,
+ 1E4385L,
+ 1E4386L,
+ 1E4387L,
+ 1E4388L,
+ 1E4389L,
+ 1E4390L,
+ 1E4391L,
+ 1E4392L,
+ 1E4393L,
+ 1E4394L,
+ 1E4395L,
+ 1E4396L,
+ 1E4397L,
+ 1E4398L,
+ 1E4399L,
+ 1E4400L,
+ 1E4401L,
+ 1E4402L,
+ 1E4403L,
+ 1E4404L,
+ 1E4405L,
+ 1E4406L,
+ 1E4407L,
+ 1E4408L,
+ 1E4409L,
+ 1E4410L,
+ 1E4411L,
+ 1E4412L,
+ 1E4413L,
+ 1E4414L,
+ 1E4415L,
+ 1E4416L,
+ 1E4417L,
+ 1E4418L,
+ 1E4419L,
+ 1E4420L,
+ 1E4421L,
+ 1E4422L,
+ 1E4423L,
+ 1E4424L,
+ 1E4425L,
+ 1E4426L,
+ 1E4427L,
+ 1E4428L,
+ 1E4429L,
+ 1E4430L,
+ 1E4431L,
+ 1E4432L,
+ 1E4433L,
+ 1E4434L,
+ 1E4435L,
+ 1E4436L,
+ 1E4437L,
+ 1E4438L,
+ 1E4439L,
+ 1E4440L,
+ 1E4441L,
+ 1E4442L,
+ 1E4443L,
+ 1E4444L,
+ 1E4445L,
+ 1E4446L,
+ 1E4447L,
+ 1E4448L,
+ 1E4449L,
+ 1E4450L,
+ 1E4451L,
+ 1E4452L,
+ 1E4453L,
+ 1E4454L,
+ 1E4455L,
+ 1E4456L,
+ 1E4457L,
+ 1E4458L,
+ 1E4459L,
+ 1E4460L,
+ 1E4461L,
+ 1E4462L,
+ 1E4463L,
+ 1E4464L,
+ 1E4465L,
+ 1E4466L,
+ 1E4467L,
+ 1E4468L,
+ 1E4469L,
+ 1E4470L,
+ 1E4471L,
+ 1E4472L,
+ 1E4473L,
+ 1E4474L,
+ 1E4475L,
+ 1E4476L,
+ 1E4477L,
+ 1E4478L,
+ 1E4479L,
+ 1E4480L,
+ 1E4481L,
+ 1E4482L,
+ 1E4483L,
+ 1E4484L,
+ 1E4485L,
+ 1E4486L,
+ 1E4487L,
+ 1E4488L,
+ 1E4489L,
+ 1E4490L,
+ 1E4491L,
+ 1E4492L,
+ 1E4493L,
+ 1E4494L,
+ 1E4495L,
+ 1E4496L,
+ 1E4497L,
+ 1E4498L,
+ 1E4499L,
+ 1E4500L,
+ 1E4501L,
+ 1E4502L,
+ 1E4503L,
+ 1E4504L,
+ 1E4505L,
+ 1E4506L,
+ 1E4507L,
+ 1E4508L,
+ 1E4509L,
+ 1E4510L,
+ 1E4511L,
+ 1E4512L,
+ 1E4513L,
+ 1E4514L,
+ 1E4515L,
+ 1E4516L,
+ 1E4517L,
+ 1E4518L,
+ 1E4519L,
+ 1E4520L,
+ 1E4521L,
+ 1E4522L,
+ 1E4523L,
+ 1E4524L,
+ 1E4525L,
+ 1E4526L,
+ 1E4527L,
+ 1E4528L,
+ 1E4529L,
+ 1E4530L,
+ 1E4531L,
+ 1E4532L,
+ 1E4533L,
+ 1E4534L,
+ 1E4535L,
+ 1E4536L,
+ 1E4537L,
+ 1E4538L,
+ 1E4539L,
+ 1E4540L,
+ 1E4541L,
+ 1E4542L,
+ 1E4543L,
+ 1E4544L,
+ 1E4545L,
+ 1E4546L,
+ 1E4547L,
+ 1E4548L,
+ 1E4549L,
+ 1E4550L,
+ 1E4551L,
+ 1E4552L,
+ 1E4553L,
+ 1E4554L,
+ 1E4555L,
+ 1E4556L,
+ 1E4557L,
+ 1E4558L,
+ 1E4559L,
+ 1E4560L,
+ 1E4561L,
+ 1E4562L,
+ 1E4563L,
+ 1E4564L,
+ 1E4565L,
+ 1E4566L,
+ 1E4567L,
+ 1E4568L,
+ 1E4569L,
+ 1E4570L,
+ 1E4571L,
+ 1E4572L,
+ 1E4573L,
+ 1E4574L,
+ 1E4575L,
+ 1E4576L,
+ 1E4577L,
+ 1E4578L,
+ 1E4579L,
+ 1E4580L,
+ 1E4581L,
+ 1E4582L,
+ 1E4583L,
+ 1E4584L,
+ 1E4585L,
+ 1E4586L,
+ 1E4587L,
+ 1E4588L,
+ 1E4589L,
+ 1E4590L,
+ 1E4591L,
+ 1E4592L,
+ 1E4593L,
+ 1E4594L,
+ 1E4595L,
+ 1E4596L,
+ 1E4597L,
+ 1E4598L,
+ 1E4599L,
+ 1E4600L,
+ 1E4601L,
+ 1E4602L,
+ 1E4603L,
+ 1E4604L,
+ 1E4605L,
+ 1E4606L,
+ 1E4607L,
+ 1E4608L,
+ 1E4609L,
+ 1E4610L,
+ 1E4611L,
+ 1E4612L,
+ 1E4613L,
+ 1E4614L,
+ 1E4615L,
+ 1E4616L,
+ 1E4617L,
+ 1E4618L,
+ 1E4619L,
+ 1E4620L,
+ 1E4621L,
+ 1E4622L,
+ 1E4623L,
+ 1E4624L,
+ 1E4625L,
+ 1E4626L,
+ 1E4627L,
+ 1E4628L,
+ 1E4629L,
+ 1E4630L,
+ 1E4631L,
+ 1E4632L,
+ 1E4633L,
+ 1E4634L,
+ 1E4635L,
+ 1E4636L,
+ 1E4637L,
+ 1E4638L,
+ 1E4639L,
+ 1E4640L,
+ 1E4641L,
+ 1E4642L,
+ 1E4643L,
+ 1E4644L,
+ 1E4645L,
+ 1E4646L,
+ 1E4647L,
+ 1E4648L,
+ 1E4649L,
+ 1E4650L,
+ 1E4651L,
+ 1E4652L,
+ 1E4653L,
+ 1E4654L,
+ 1E4655L,
+ 1E4656L,
+ 1E4657L,
+ 1E4658L,
+ 1E4659L,
+ 1E4660L,
+ 1E4661L,
+ 1E4662L,
+ 1E4663L,
+ 1E4664L,
+ 1E4665L,
+ 1E4666L,
+ 1E4667L,
+ 1E4668L,
+ 1E4669L,
+ 1E4670L,
+ 1E4671L,
+ 1E4672L,
+ 1E4673L,
+ 1E4674L,
+ 1E4675L,
+ 1E4676L,
+ 1E4677L,
+ 1E4678L,
+ 1E4679L,
+ 1E4680L,
+ 1E4681L,
+ 1E4682L,
+ 1E4683L,
+ 1E4684L,
+ 1E4685L,
+ 1E4686L,
+ 1E4687L,
+ 1E4688L,
+ 1E4689L,
+ 1E4690L,
+ 1E4691L,
+ 1E4692L,
+ 1E4693L,
+ 1E4694L,
+ 1E4695L,
+ 1E4696L,
+ 1E4697L,
+ 1E4698L,
+ 1E4699L,
+ 1E4700L,
+ 1E4701L,
+ 1E4702L,
+ 1E4703L,
+ 1E4704L,
+ 1E4705L,
+ 1E4706L,
+ 1E4707L,
+ 1E4708L,
+ 1E4709L,
+ 1E4710L,
+ 1E4711L,
+ 1E4712L,
+ 1E4713L,
+ 1E4714L,
+ 1E4715L,
+ 1E4716L,
+ 1E4717L,
+ 1E4718L,
+ 1E4719L,
+ 1E4720L,
+ 1E4721L,
+ 1E4722L,
+ 1E4723L,
+ 1E4724L,
+ 1E4725L,
+ 1E4726L,
+ 1E4727L,
+ 1E4728L,
+ 1E4729L,
+ 1E4730L,
+ 1E4731L,
+ 1E4732L,
+ 1E4733L,
+ 1E4734L,
+ 1E4735L,
+ 1E4736L,
+ 1E4737L,
+ 1E4738L,
+ 1E4739L,
+ 1E4740L,
+ 1E4741L,
+ 1E4742L,
+ 1E4743L,
+ 1E4744L,
+ 1E4745L,
+ 1E4746L,
+ 1E4747L,
+ 1E4748L,
+ 1E4749L,
+ 1E4750L,
+ 1E4751L,
+ 1E4752L,
+ 1E4753L,
+ 1E4754L,
+ 1E4755L,
+ 1E4756L,
+ 1E4757L,
+ 1E4758L,
+ 1E4759L,
+ 1E4760L,
+ 1E4761L,
+ 1E4762L,
+ 1E4763L,
+ 1E4764L,
+ 1E4765L,
+ 1E4766L,
+ 1E4767L,
+ 1E4768L,
+ 1E4769L,
+ 1E4770L,
+ 1E4771L,
+ 1E4772L,
+ 1E4773L,
+ 1E4774L,
+ 1E4775L,
+ 1E4776L,
+ 1E4777L,
+ 1E4778L,
+ 1E4779L,
+ 1E4780L,
+ 1E4781L,
+ 1E4782L,
+ 1E4783L,
+ 1E4784L,
+ 1E4785L,
+ 1E4786L,
+ 1E4787L,
+ 1E4788L,
+ 1E4789L,
+ 1E4790L,
+ 1E4791L,
+ 1E4792L,
+ 1E4793L,
+ 1E4794L,
+ 1E4795L,
+ 1E4796L,
+ 1E4797L,
+ 1E4798L,
+ 1E4799L,
+ 1E4800L,
+ 1E4801L,
+ 1E4802L,
+ 1E4803L,
+ 1E4804L,
+ 1E4805L,
+ 1E4806L,
+ 1E4807L,
+ 1E4808L,
+ 1E4809L,
+ 1E4810L,
+ 1E4811L,
+ 1E4812L,
+ 1E4813L,
+ 1E4814L,
+ 1E4815L,
+ 1E4816L,
+ 1E4817L,
+ 1E4818L,
+ 1E4819L,
+ 1E4820L,
+ 1E4821L,
+ 1E4822L,
+ 1E4823L,
+ 1E4824L,
+ 1E4825L,
+ 1E4826L,
+ 1E4827L,
+ 1E4828L,
+ 1E4829L,
+ 1E4830L,
+ 1E4831L,
+ 1E4832L,
+ 1E4833L,
+ 1E4834L,
+ 1E4835L,
+ 1E4836L,
+ 1E4837L,
+ 1E4838L,
+ 1E4839L,
+ 1E4840L,
+ 1E4841L,
+ 1E4842L,
+ 1E4843L,
+ 1E4844L,
+ 1E4845L,
+ 1E4846L,
+ 1E4847L,
+ 1E4848L,
+ 1E4849L,
+ 1E4850L,
+ 1E4851L,
+ 1E4852L,
+ 1E4853L,
+ 1E4854L,
+ 1E4855L,
+ 1E4856L,
+ 1E4857L,
+ 1E4858L,
+ 1E4859L,
+ 1E4860L,
+ 1E4861L,
+ 1E4862L,
+ 1E4863L,
+ 1E4864L,
+ 1E4865L,
+ 1E4866L,
+ 1E4867L,
+ 1E4868L,
+ 1E4869L,
+ 1E4870L,
+ 1E4871L,
+ 1E4872L,
+ 1E4873L,
+ 1E4874L,
+ 1E4875L,
+ 1E4876L,
+ 1E4877L,
+ 1E4878L,
+ 1E4879L,
+ 1E4880L,
+ 1E4881L,
+ 1E4882L,
+ 1E4883L,
+ 1E4884L,
+ 1E4885L,
+ 1E4886L,
+ 1E4887L,
+ 1E4888L,
+ 1E4889L,
+ 1E4890L,
+ 1E4891L,
+ 1E4892L,
+ 1E4893L,
+ 1E4894L,
+ 1E4895L,
+ 1E4896L,
+ 1E4897L,
+ 1E4898L,
+ 1E4899L,
+ 1E4900L,
+ 1E4901L,
+ 1E4902L,
+ 1E4903L,
+ 1E4904L,
+ 1E4905L,
+ 1E4906L,
+ 1E4907L,
+ 1E4908L,
+ 1E4909L,
+ 1E4910L,
+ 1E4911L,
+ 1E4912L,
+ 1E4913L,
+ 1E4914L,
+ 1E4915L,
+ 1E4916L,
+ 1E4917L,
+ 1E4918L,
+ 1E4919L,
+ 1E4920L,
+ 1E4921L,
+ 1E4922L,
+ 1E4923L,
+ 1E4924L,
+ 1E4925L,
+ 1E4926L,
+ 1E4927L,
+ 1E4928L,
+ 1E4929L,
+ 1E4930L,
+ 1E4931L,
+ 1E4932L,
+};
+
+Sftab_t _Sftable =
+{
+ { 1E1L, 1E2L, 1E4L, 1E8L, 1E16L, 1E32L },
+ { 1E-1L, 1E-2L, 1E-4L, 1E-8L, 1E-16L, 1E-32L },
+ { '0','0', '0','1', '0','2', '0','3', '0','4',
+ '0','5', '0','6', '0','7', '0','8', '0','9',
+ '1','0', '1','1', '1','2', '1','3', '1','4',
+ '1','5', '1','6', '1','7', '1','8', '1','9',
+ '2','0', '2','1', '2','2', '2','3', '2','4',
+ '2','5', '2','6', '2','7', '2','8', '2','9',
+ '3','0', '3','1', '3','2', '3','3', '3','4',
+ '3','5', '3','6', '3','7', '3','8', '3','9',
+ '4','0', '4','1', '4','2', '4','3', '4','4',
+ '4','5', '4','6', '4','7', '4','8', '4','9',
+ '5','0', '5','1', '5','2', '5','3', '5','4',
+ '5','5', '5','6', '5','7', '5','8', '5','9',
+ '6','0', '6','1', '6','2', '6','3', '6','4',
+ '6','5', '6','6', '6','7', '6','8', '6','9',
+ '7','0', '7','1', '7','2', '7','3', '7','4',
+ '7','5', '7','6', '7','7', '7','8', '7','9',
+ '8','0', '8','1', '8','2', '8','3', '8','4',
+ '8','5', '8','6', '8','7', '8','8', '8','9',
+ '9','0', '9','1', '9','2', '9','3', '9','4',
+ '9','5', '9','6', '9','7', '9','8', '9','9',
+ },
+ "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@_",
+ sfcvinit, 0,
+ sffmtpos,
+ sffmtint,
+ (float*)&sf_flt_pow10[0],
+ (double*)&sf_dbl_pow10[0],
+ (_ast_fltmax_t*)&sf_ldbl_pow10[0],
+};
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/sfio b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/sfio
new file mode 100644
index 0000000000..e51f7a598a
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/sfio
@@ -0,0 +1,16 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/sfio by iffe version 2007-04-04 : : */
+#ifndef _def_sfio_ast
+#define _def_sfio_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_float 1 /* #include <float.h> ok */
+#define _hdr_floatingpoint 1 /* #include <floatingpoint.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _hdr_values 1 /* #include <values.h> ok */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _key_signed 1 /* signed is a reserved keyword */
+#define _more_void_int 1 /* voidptr is larger than int */
+#define _more_long_int 1 /* long is larger than int */
+#define _lib_cvt 1 /* native floating point conversions ok */
+#define _xopen_stdio 1 /* Stdio fseek/fflush are X/Open-compliant */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/sig b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/sig
new file mode 100644
index 0000000000..40e930cd93
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/sig
@@ -0,0 +1,131 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/sig.sh by iffe version 2007-04-04 : : */
+#ifndef _def_sig_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_sig_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define sig_info _sig_info_
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide kill killpg
+#else
+#define kill ______kill
+#define killpg ______killpg
+#endif
+#include <signal.h>
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide kill killpg
+#else
+#undef kill
+#undef killpg
+#endif
+#ifndef sigmask
+#define sigmask(s) (1<<((s)-1))
+#endif
+typedef void (*Sig_handler_t) __PROTO__((int));
+
+
+#define Handler_t Sig_handler_t
+
+#define SIG_REG_PENDING (-1)
+#define SIG_REG_POP 0
+#define SIG_REG_EXEC 00001
+#define SIG_REG_PROC 00002
+#define SIG_REG_TERM 00004
+#define SIG_REG_ALL 00777
+#define SIG_REG_SET 01000
+
+typedef struct
+{
+ char** name;
+ char** text;
+ int sigmax;
+} Sig_info_t;
+
+extern __MANGLE__ int kill __PROTO__((pid_t, int));
+extern __MANGLE__ int killpg __PROTO__((pid_t, int));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Sig_info_t sig_info;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int sigcritical __PROTO__((int));
+extern __MANGLE__ int sigunblock __PROTO__((int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/signal b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/signal
new file mode 100644
index 0000000000..10dd975320
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/signal
@@ -0,0 +1,175 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/signal.c by iffe version 2007-04-04 : : */
+#ifndef _def_signal_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_signal_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define SIG_MAX 48
+
+static const char* const sig_name[] =
+{
+ "0",
+ "HUP",
+ "INT",
+ "QUIT",
+ "ILL",
+ "TRAP",
+ "IOT",
+ "EMT",
+ "FPE",
+ "KILL",
+ "BUS",
+ "SEGV",
+ "SYS",
+ "PIPE",
+ "ALRM",
+ "TERM",
+ "USR1",
+ "USR2",
+ "CHLD",
+ "PWR",
+ "WINCH",
+ "URG",
+ "IO",
+ "STOP",
+ "TSTP",
+ "CONT",
+ "TTIN",
+ "TTOU",
+ "VTALRM",
+ "PROF",
+ "XCPU",
+ "XFSZ",
+ "WAITING",
+ "LWP",
+ "FREEZE",
+ "THAW",
+ "36",
+ "LOST",
+ "38",
+ "39",
+ "40",
+ "RTMIN",
+ "RT1",
+ "RT2",
+ "RT3",
+ "RT4",
+ "RT5",
+ "RT6",
+ "RTMAX",
+ 0
+};
+
+static const char* const sig_text[] =
+{
+ "Signal 0",
+ "Hangup",
+ "Interrupt",
+ "Quit",
+ "Illegal instruction",
+ "Trace trap",
+ "IOT trap",
+ "EMT trap",
+ "Floating exception",
+ "Killed",
+ "Bus error",
+ "Memory fault",
+ "Bad system call",
+ "Broken pipe",
+ "Alarm call",
+ "Terminated",
+ "User signal 1",
+ "User signal 2",
+ "Child status change",
+ "Power fail",
+ "Window change",
+ "Urgent IO",
+ "IO possible",
+ "Stopped (signal)",
+ "Stopped",
+ "Stopped process continued",
+ "Stopped (tty input)",
+ "Stopped (tty output)",
+ "Virtual timer alarm",
+ "Profile timer alarm",
+ "CPU time limit",
+ "File size limit",
+ "All threads blocked",
+ "Thread event",
+ "CPR freeze",
+ "CPR thaw",
+ "Signal 36",
+ "Resources lost",
+ "Signal 38",
+ "Signal 39",
+ "Signal 40",
+ "Realtime priority 0 (lo)",
+ "Realtime priority 1",
+ "Realtime priority 2",
+ "Realtime priority 3",
+ "Realtime priority 4",
+ "Realtime priority 5",
+ "Realtime priority 6",
+ "Realtime priority 7 (hi)",
+ 0
+};
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/standards b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/standards
new file mode 100644
index 0000000000..f625ff6f49
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/standards
@@ -0,0 +1,28 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/standards by iffe version 2007-04-04 : : */
+#ifndef _def_standards_ast
+#define _def_standards_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* _ALL_SOURCE & _ISOC99_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works */
+#ifndef _ALL_SOURCE
+#define _ALL_SOURCE 1
+#endif
+#ifndef _ISOC99_SOURCE
+#define _ISOC99_SOURCE 1
+#endif
+#ifndef _POSIX_SOURCE
+#define _POSIX_SOURCE 1
+#endif
+#ifndef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 21000101L
+#endif
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 9900
+#endif
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#ifndef __EXTENSIONS__
+#define __EXTENSIONS__ 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/stdio b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/stdio
new file mode 100644
index 0000000000..0a1824b6fa
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/stdio
@@ -0,0 +1,579 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/stdio by iffe version 2007-04-04 : : */
+
+#ifndef _SFSTDIO_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SFSTDIO_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define __FILE_typedef 1
+#define _FILE_DEFINED 1
+#define _FILE_defined 1
+#define _FILEDEFED 1
+
+#ifndef __FILE_TAG
+#define __FILE_TAG _sfio_s
+#endif
+
+#undef FILE
+#undef _FILE
+#undef fpos_t
+#undef fpos64_t
+
+typedef struct _sfio_s _sfio_FILE;
+
+#define FILE _sfio_FILE
+#define _FILE FILE
+
+#if !defined(__FILE) && !__CYGWIN__
+#undef __FILE
+#define __FILE FILE
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define BUFSIZ SF_BUFSIZE
+
+#else
+
+#ifndef BUFSIZ
+#define BUFSIZ 8192
+#endif
+
+#ifndef EOF
+#define EOF (-1)
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+#include <ast_std.h>
+
+#include <sfio_s.h>
+
+#if __cplusplus
+#define _sf_(f) (f)
+#else
+#define _sf_(f) ((struct _sfio_s*)(f))
+#endif
+
+#define _SF_EOF 0000200
+#define _SF_ERROR 0000400
+
+#endif
+
+#ifdef _NO_LARGEFILE64_SOURCE
+#undef _LARGEFILE64_SOURCE
+#endif
+
+#ifdef _LARGEFILE64_SOURCE
+#undef off_t
+#endif
+
+#define fpos_t _ast_fpos_t
+#if _typ_int64_t
+#define fpos64_t _ast_fpos_t
+#endif
+
+typedef struct _ast_fpos_s
+{
+ intmax_t _sf_offset;
+ unsigned char _sf_state[64 - sizeof(intmax_t)];
+} _ast_fpos_t;
+
+#define _base _data
+#define _ptr _next
+#define _IOFBF 0
+#define _IONBF 1
+#define _IOLBF 2
+
+#if defined(__cplusplus) && defined(__THROW) && !defined(_UWIN)
+
+#undef FILE
+#define FILE FILE
+typedef struct _sfio_s FILE;
+
+#undef strerror
+extern __MANGLE__ char* strerror(int) __THROW;
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#endif
+
+#ifndef FILENAME_MAX
+#define FILENAME_MAX 1024
+#endif
+#ifndef FOPEN_MAX
+#define FOPEN_MAX 20
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+
+#define _doprnt _ast_doprnt
+#define _doscan _ast_doscan
+#define asprintf _ast_asprintf
+#define clearerr _ast_clearerr
+#define fclose _ast_fclose
+#define fdopen _ast_fdopen
+#define fflush _ast_fflush
+#define fgetc _ast_fgetc
+#define fgetpos _ast_fgetpos
+#define fgetpos64 _ast_fgetpos64
+#define fgets _ast_fgets
+#define fopen _ast_fopen
+#define fprintf _ast_fprintf
+#define fpurge _ast_fpurge
+#define fputs _ast_fputs
+#define fread _ast_fread
+#define freopen _ast_freopen
+#define fscanf _ast_fscanf
+#define fseek _ast_fseek
+#define fseek64 _ast_fseek64
+#define fseeko _ast_fseeko
+#define fseeko64 _ast_fseeko64
+#define fsetpos _ast_fsetpos
+#define fsetpos64 _ast_fsetpos64
+#define ftell _ast_ftell
+#define ftell64 _ast_ftell64
+#define ftello _ast_ftello
+#define ftello64 _ast_ftello64
+#define fwrite _ast_fwrite
+#define gets _ast_gets
+#define getw _ast_getw
+#define pclose _ast_pclose
+#define popen _ast_popen
+#define printf _ast_printf
+#define puts _ast_puts
+#define putw _ast_putw
+#define rewind _ast_rewind
+#define scanf _ast_scanf
+#define setbuf _ast_setbuf
+#undef setbuffer
+#define setbuffer _ast_setbuffer
+#define setlinebuf _ast_setlinebuf
+#define setvbuf _ast_setvbuf
+#define snprintf _ast_snprintf
+#define sprintf _ast_sprintf
+#define sscanf _ast_sscanf
+#define tmpfile _ast_tmpfile
+#define ungetc _ast_ungetc
+#define vasprintf _ast_vasprintf
+#define vfprintf _ast_vfprintf
+#define vfscanf _ast_vfscanf
+#define vprintf _ast_vprintf
+#define vscanf _ast_vscanf
+#define vsnprintf _ast_vsnprintf
+#define vsprintf _ast_vsprintf
+#define vsscanf _ast_vsscanf
+#define fcloseall _ast_fcloseall
+#define fmemopen _ast_fmemopen
+#define __getdelim _ast___getdelim
+#define getdelim _ast_getdelim
+#define getline _ast_getline
+#define clearerr_unlocked _ast_clearerr_unlocked
+#define feof_unlocked _ast_feof_unlocked
+#define ferror_unlocked _ast_ferror_unlocked
+#define fflush_unlocked _ast_fflush_unlocked
+#define fgetc_unlocked _ast_fgetc_unlocked
+#define fgets_unlocked _ast_fgets_unlocked
+#define fileno_unlocked _ast_fileno_unlocked
+#define fputc_unlocked _ast_fputc_unlocked
+#define fputs_unlocked _ast_fputs_unlocked
+#define fread_unlocked _ast_fread_unlocked
+#define fwrite_unlocked _ast_fwrite_unlocked
+#define getc_unlocked _ast_getc_unlocked
+#define getchar_unlocked _ast_getchar_unlocked
+#define putc_unlocked _ast_putc_unlocked
+#define putchar_unlocked _ast_putchar_unlocked
+
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef P_tmpdir
+#define P_tmpdir "/var/tmp/" /*NOCATLITERAL*/
+#endif
+#ifndef L_ctermid
+#define L_ctermid 9
+#endif
+#ifndef L_tmpnam
+#define L_tmpnam 25
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#if defined(__cplusplus) && defined(__THROW)
+extern __MANGLE__ char* ctermid(char*) __THROW;
+#else
+extern __MANGLE__ char* ctermid __PROTO__((char*));
+#endif
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+extern __MANGLE__ void perror __PROTO__((const char*));
+#ifndef _AST_STD_H
+#ifndef remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#endif
+#ifndef rename
+extern __MANGLE__ int rename __PROTO__((const char*, const char*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#ifdef _LARGEFILE64_SOURCE
+
+#undef fpos_t
+#undef off_t
+#undef fgetpos
+#undef fsetpos
+#undef fseek
+#undef fseeko
+#undef ftell
+#undef ftello
+
+#define fpos_t fpos64_t
+#if _typ_off64_t
+#define off_t off64_t
+#else
+#define off_t int64_t
+#endif
+
+#define fgetpos fgetpos64
+#define fsetpos fsetpos64
+#define fseek fseek64
+#define fseeko fseeko64
+#define ftell ftell64
+#define ftello ftello64
+
+#endif
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_DLL && _DLL_INDIRECT_DATA
+
+#define stdin ((FILE*)_ast_dll->_ast_stdin)
+#define stdout ((FILE*)_ast_dll->_ast_stdout)
+#define stderr ((FILE*)_ast_dll->_ast_stderr)
+
+#else
+
+#define stdin (&_Sfstdin)
+#define stdout (&_Sfstdout)
+#define stderr (&_Sfstderr)
+
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define feof(f) sfeof(f)
+#define ferror(f) sferror(f)
+#define fileno(f) sffileno(f)
+#define fputc(c,f) sfputc(f,c)
+#define getc(f) sfgetc(f)
+#define getchar() sfgetc(sfstdin)
+#define putc(c,f) sfputc(f,c)
+#define putchar(c) sfputc(sfstdout,c)
+
+#else
+
+#if !_UWIN
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+#endif
+
+extern __MANGLE__ FILE _Sfstdin;
+extern __MANGLE__ FILE _Sfstdout;
+extern __MANGLE__ FILE _Sfstderr;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define feof(f) (_sf_(f)->_flags&_SF_EOF)
+#define ferror(f) (_sf_(f)->_flags&_SF_ERROR)
+#define fileno(f) (_sf_(f)->_file)
+#define fputc(c,f) (_sf_(f)->_next>=_sf_(f)->_endw?_sfflsbuf(_sf_(f),(int)((unsigned char)(c))):(int)(*_sf_(f)->_next++=(unsigned char)(c)))
+#define getc(f) (_sf_(f)->_next>=_sf_(f)->_endr?_sffilbuf(_sf_(f),0):(int)(*_sf_(f)->_next++))
+#define getchar() getc(stdin)
+#define putc(c,f) fputc(c,f)
+#define putchar(c) fputc(c,stdout)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _sffilbuf __PROTO__((FILE*, int));
+extern __MANGLE__ int _sfflsbuf __PROTO__((FILE*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/sys b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/sys
new file mode 100644
index 0000000000..8b3d838a49
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/sys
@@ -0,0 +1,151 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/sys by iffe version 2007-04-04 : : */
+
+#ifndef _AST_SYS_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_SYS_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#if __mips == 2 && !defined(_NO_LARGEFILE64_SOURCE)
+#define _NO_LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_NO_LARGEFILE64_SOURCE) && _typ_off64_t && _lib_lseek64 && _lib_stat64
+#if !defined(_LARGEFILE64_SOURCE)
+#define _LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_LARGEFILE_SOURCE)
+#define _LARGEFILE_SOURCE 1
+#endif
+#else
+#undef _LARGEFILE64_SOURCE
+#undef _LARGEFILE_SOURCE
+#undef _typ_off64_t
+#undef _typ_struct_dirent64
+#undef _lib_creat64
+#undef _lib_fstat64
+#undef _lib_fstatvfs64
+#undef _lib_ftruncate64
+#undef _lib_lseek64
+#undef _lib_lstat64
+#undef _lib_mmap64
+#undef _lib_open64
+#undef _lib_readdir64
+#undef _lib_stat64
+#undef _lib_statvfs64
+#undef _lib_truncate64
+#endif
+#if defined(__STDC__) && !defined(__USE_FIXED_PROTOTYPES__)
+#define __USE_FIXED_PROTOTYPES__ 1 /* kick gcc out of the past */
+#endif
+#include <stdlib.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <locale.h>
+#include <sys/localedef.h>
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _typ_dev_t 1 /* dev_t is a type */
+#define _typ_nlink_t 1 /* nlink_t is a type */
+#define _typ_gid_t 1 /* gid_t is a type */
+#define _typ_mode_t 1 /* mode_t is a type */
+#define _typ_uid_t 1 /* uid_t is a type */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _typ_wchar_t 1 /* wchar_t is a type */
+#define _typ_pid_t 1 /* pid_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _typ_wint_t 1 /* wint_t is a type */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _typ_socklen_t 1 /* socklen_t is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_ino_t 1 /* ino_t is a type */
+#define _typ_off_t 1 /* off_t is a type */
+#define _typ_ptrdiff_t 1 /* ptrdiff_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#define _typ_div_t 1 /* div_t is a type */
+#define _typ_ldiv_t 1 /* ldiv_t is a type */
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+extern __MANGLE__ int eaccess __PROTO__((const char*, int));
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+extern __MANGLE__ __V_* pvalloc __PROTO__((size_t));
+extern __MANGLE__ pid_t spawnveg __PROTO__((const char*, char* const[], char* const[], pid_t));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#if !defined(va_start)
+#if defined(__STDARG__)
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/time b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/time
new file mode 100644
index 0000000000..89db712e51
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/time
@@ -0,0 +1,83 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/time by iffe version 2007-04-04 : : */
+
+#ifndef _def_time_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_time_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_nanosleep 1 /* nanosleep() in default lib(s) */
+#define _lib_usleep 1 /* usleep() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#include <sys/time.h>
+
+#include <sys/times.h>
+
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC CLK_TCK
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tmlib b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tmlib
new file mode 100644
index 0000000000..4cb071effe
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tmlib
@@ -0,0 +1,68 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/tmlib by iffe version 2007-04-04 : : */
+
+#ifndef _def_tmlib_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_tmlib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define tmlocaltime(p) localtime(p)
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tmx b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tmx
new file mode 100644
index 0000000000..11aa0d9b2b
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tmx
@@ -0,0 +1,128 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/tmx by iffe version 2007-04-04 : : */
+
+#ifndef _TMX_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TMX_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Time_t support
+ */
+
+#include <tm.h>
+#include <tv.h>
+
+#define TMX_MAXDATE "2554-07-21+23:34:33.709551614 UTC"
+#define TMX_MAXYEAR 2554
+#define TMX_MAXSEC ((Time_t)18446744073)
+#define TMX_MAXNSEC 709551614
+#define TMX_RESOLUTION 1000000000
+
+typedef uint64_t Time_t;
+typedef uint64_t Tmxsec_t;
+typedef uint32_t Tmxnsec_t;
+
+#define tmxsec(t) ((Tmxsec_t)((t)/1000000000))
+#define tmxnsec(t) ((Tmxnsec_t)((t)%1000000000))
+#define tmxsns(s,n) (((((Time_t)(s))*1000000000))+((Time_t)(n)))
+
+#define TMX_NOTIME ((Time_t)(-1))
+#define TMX_NOW tmxgettime()
+#define TMX_MAXTIME tmxsns(TMX_MAXSEC,TMX_MAXNSEC)
+
+#define tmx2tv(t,v) ((v)->tv_nsec=tmxnsec(t),(v)->tv_sec=tmxsec(t))
+#define tv2tmx(v) tmxsns((v)->tv_sec,(v)->tv_nsec)
+
+#define tmxclock(p) tmxsns(((p)?*(p):time(NiL)),0)
+
+#define tmxgetatime(s) tmxsns((s)->st_atime,ST_ATIME_NSEC_GET(s))
+#define tmxgetctime(s) tmxsns((s)->st_ctime,ST_CTIME_NSEC_GET(s))
+#define tmxgetmtime(s) tmxsns((s)->st_mtime,ST_MTIME_NSEC_GET(s))
+
+#define tmxsetatime(s,t) ((s)->st_atime=tmxsec(t),ST_ATIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetctime(s,t) ((s)->st_ctime=tmxsec(t),ST_CTIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetmtime(s,t) ((s)->st_mtime=tmxsec(t),ST_MTIME_NSEC_SET(s,tmxnsec(t)))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Time_t tmxdate __PROTO__((const char*, char**, Time_t));
+extern __MANGLE__ char* tmxfmt __PROTO__((char*, size_t, const char*, Time_t));
+extern __MANGLE__ Time_t tmxleap __PROTO__((Time_t));
+extern __MANGLE__ Tm_t* tmxmake __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxscan __PROTO__((const char*, char**, const char*, char**, Time_t, long));
+extern __MANGLE__ int tmxsleep __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxtime __PROTO__((Tm_t*, int));
+
+extern __MANGLE__ Time_t tmxgettime __PROTO__((void));
+extern __MANGLE__ int tmxsettime __PROTO__((Time_t));
+
+extern __MANGLE__ int tmxtouch __PROTO__((const char*, Time_t, Time_t, Time_t, int));
+
+extern __MANGLE__ char* fmttmx __PROTO__((const char*, Time_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tty b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tty
new file mode 100644
index 0000000000..fee4db4ea4
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tty
@@ -0,0 +1,134 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/tty by iffe version 2007-04-04 : : */
+#ifndef _def_tty_ast
+#define _def_tty_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_termios 1 /* #include <termios.h> ok */
+#define _hdr_termio 1 /* #include <termio.h> ok */
+#define _hdr_sgtty 1 /* #include <sgtty.h> ok */
+#define _sys_termios 1 /* #include <sys/termios.h> ok */
+#define _sys_termio 1 /* #include <sys/termio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _lib_tcgetattr 1 /* tcgetattr() in default lib(s) */
+#define _lib_tcgetpgrp 1 /* tcgetpgrp() in default lib(s) */
+#define _mac__POSIX_VDISABLE 1 /* _POSIX_VDISABLE is a macro */
+
+#ifdef _hdr_termios
+# if _mac__POSIX_VDISABLE
+# undef _POSIX_VDISABLE
+# endif
+# include <termios.h>
+#else
+# if defined(_sys_termios) && defined(_lib_tcgetattr)
+# include <sys/termios.h>
+# define _hdr_termios 1
+# else
+# undef _sys_termios
+# endif /* _sys_termios */
+#endif /* _hdr_termios */
+
+#ifdef _hdr_termios
+# undef _hdr_sgtty
+# undef tcgetattr
+# undef tcsetattr
+# undef tcgetpgrp
+# undef tcsetpgrp
+# undef cfgetospeed
+# ifndef TCSANOW
+# define TCSANOW TCSETS
+# define TCSADRAIN TCSETSW
+# define TCSAFLUSH TCSETSF
+# endif /* TCSANOW */
+ /* The following corrects bugs in some implementations */
+# if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
+# define TCSAFLUSH TCSADFLUSH
+# endif /* TCSADFLUSH */
+# ifndef _lib_tcgetattr
+# undef tcgetattr
+# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
+# undef tcsetattr
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# undef cfgetospeed
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# endif /* _lib_tcgetattr */
+# undef TIOCGETC
+#else
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfgetispeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfsetispeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# define cfsetospeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# ifdef _hdr_termio
+# include <termio.h>
+# else
+# ifdef _sys_termio
+# include <sys/termio.h>
+# define _hdr_termio 1
+# endif /* _sys_termio */
+# endif /* _hdr_termio */
+# ifdef _hdr_termio
+# define termios termio
+# undef TIOCGETC
+# define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+
+# ifdef _sys_bsdtty
+# include <sys/bsdtty.h>
+# endif /* _sys_bsdtty */
+# else
+# ifdef _hdr_sgtty
+# include <sgtty.h>
+# ifndef LPENDIN
+# ifdef _sys_nttyio
+# include <sys/nttyio.h>
+# endif /* _sys_nttyio */
+# endif /* LPENDIN */
+# define termios sgttyb
+# ifdef TIOCSETN
+# undef TCSETAW
+# endif /* TIOCSETN */
+# ifdef TIOCGETP
+# define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# else
+# define tcgetattr(fd,tty) gtty(fd, tty)
+# define tcsetattr(fd,action,tty) stty(fd, tty)
+# endif /* TIOCGETP */
+# else
+# ifdef _sys_ttyio
+# include <sys/ttyio.h>
+# endif
+# endif /* _hdr_sgtty */
+# endif /* hdr_termio */
+
+# ifndef TCSANOW
+# ifdef TCSETAW
+# define TCSANOW TCSETA
+# define TCSAFLUSH TCSETAF
+# else
+# ifdef TIOCSETN
+# define TCSANOW TIOCSETN
+# define TCSADRAIN TIOCSETN
+# define TCSAFLUSH TIOCSETP
+# endif /* TIOCSETN */
+# endif /* TCSETAW */
+# endif /* TCSANOW */
+#endif /* _hdr_termios */
+
+/* set ECHOCTL if driver can echo control charaters as ^c */
+#ifdef LCTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LCTLECH
+# endif /* !ECHOCTL */
+#endif /* LCTLECH */
+#ifdef LNEW_CTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LNEW_CTLECH
+# endif /* !ECHOCTL */
+#endif /* LNEW_CTLECH */
+#ifdef LNEW_PENDIN
+# ifndef PENDIN
+# define PENDIN LNEW_PENDIN
+# endif /* !PENDIN */
+#endif /* LNEW_PENDIN */
+
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tv b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tv
new file mode 100644
index 0000000000..7f91a2883e
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tv
@@ -0,0 +1,111 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/tv by iffe version 2007-04-04 : : */
+
+#ifndef _TV_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TV_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Tv_t interface definitions
+ */
+
+#include <ast.h>
+
+#define TV_NSEC_IGNORE (1000000000L)
+#define TV_TOUCH_RETAIN ((Tv_t*)1)
+
+typedef struct Tv_s
+{
+ uint32_t tv_sec;
+ uint32_t tv_nsec;
+} Tv_t;
+
+#define ST_ATIME_NSEC_GET(st) ((st)->st_atim.tv_nsec)
+#define ST_CTIME_NSEC_GET(st) ((st)->st_ctim.tv_nsec)
+#define ST_MTIME_NSEC_GET(st) ((st)->st_mtim.tv_nsec)
+
+#define ST_ATIME_NSEC_SET(st,n) (ST_ATIME_NSEC_GET(st)=(n))
+#define ST_CTIME_NSEC_SET(st,n) (ST_CTIME_NSEC_GET(st)=(n))
+#define ST_MTIME_NSEC_SET(st,n) (ST_MTIME_NSEC_GET(st)=(n))
+
+#define tvgetatime(t,s) ((t)->tv_nsec=ST_ATIME_NSEC_GET(s),(t)->tv_sec=(s)->st_atime)
+#define tvgetmtime(t,s) ((t)->tv_nsec=ST_MTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_mtime)
+#define tvgetctime(t,s) ((t)->tv_nsec=ST_CTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_ctime)
+
+#define tvsetatime(t,s) (ST_ATIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_atime=(t)->tv_sec)
+#define tvsetmtime(t,s) (ST_MTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_mtime=(t)->tv_sec)
+#define tvsetctime(t,s) (ST_CTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_ctime=(t)->tv_sec)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int tvgettime __PROTO__((Tv_t*));
+extern __MANGLE__ int tvsettime __PROTO__((const Tv_t*));
+extern __MANGLE__ int tvcmp __PROTO__((const Tv_t*, const Tv_t*));
+extern __MANGLE__ int tvtouch __PROTO__((const char*, const Tv_t*, const Tv_t*, const Tv_t*, int));
+extern __MANGLE__ int tvsleep __PROTO__((const Tv_t*, Tv_t*));
+
+extern __MANGLE__ char* fmttv __PROTO__((const char*, Tv_t*));
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tvlib b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tvlib
new file mode 100644
index 0000000000..62d643333f
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/tvlib
@@ -0,0 +1,17 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/tvlib by iffe version 2007-04-04 : : */
+#ifndef _def_tvlib_ast
+#define _def_tvlib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _lib_clock_settime 1 /* clock_settime() in default lib(s) */
+#define _lib_gettimeofday 1 /* gettimeofday() in default lib(s) */
+#define _lib_settimeofday 1 /* settimeofday() in default lib(s) */
+#define _lib_stime 1 /* stime() in default lib(s) */
+#define _lib_utimes 1 /* utimes() in default lib(s) */
+#define _lib_nanosleep 1 /* nanosleep() in default lib(s) */
+#define _lib_usleep 1 /* usleep() in default lib(s) */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _lib_clock_gettime 1 /* execute{\ passed */
+#define tmgettimeofday(p) gettimeofday(p,(struct timezone*)0)
+#define tmsettimeofday(p) settimeofday(p,(struct timezone*)0)
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/types b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/types
new file mode 100644
index 0000000000..343b5954a0
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/types
@@ -0,0 +1,5 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_types_ast
+#define _def_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/uwin b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/uwin
new file mode 100644
index 0000000000..a315020330
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/uwin
@@ -0,0 +1,17 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/uwin by iffe version 2007-04-04 : : */
+#ifndef _def_uwin_ast
+#define _def_uwin_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_a64l 1 /* a64l() in default lib(s) */
+#define _lib_crypt 1 /* crypt() in default lib(s) */
+#define _lib_getpass 1 /* getpass() in default lib(s) */
+#define _lib_random 1 /* random() in default lib(s) */
+#define _lib_rcmd 1 /* rcmd() in default lib(s) */
+#define _lib_srand48 1 /* srand48() in default lib(s) */
+#define _lib_logb 1 /* logb() in default lib(s) */
+#define _lib_finite 1 /* finite() in default lib(s) */
+#define _lib_scalb 1 /* scalb() in default lib(s) */
+#define _lib__finite 1 /* _finite() in default lib(s) */
+#define _lib__scalb 1 /* _scalb() in default lib(s) */
+#define _dat__iob 1 /* _iob in default lib(s) */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/vfork b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/vfork
new file mode 100644
index 0000000000..975726cf26
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/vfork
@@ -0,0 +1,68 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/vfork by iffe version 2007-04-04 : : */
+
+#ifndef _def_vfork_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_vfork_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+extern __MANGLE__ pid_t vfork __PROTO__((void));
+#pragma unknown_control_flow(vfork)
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/vmalloc b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/vmalloc
new file mode 100644
index 0000000000..033a1d2315
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/vmalloc
@@ -0,0 +1,36 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/vmalloc by iffe version 2007-04-04 : : */
+#ifndef _def_vmalloc_ast
+#define _def_vmalloc_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_atexit 1 /* atexit() in default lib(s) */
+#define _lib_getpagesize 1 /* getpagesize() in default lib(s) */
+#define _lib_memalign 1 /* memalign() in default lib(s) */
+#define _lib_strdup 1 /* strdup() in default lib(s) */
+#define _lib_valloc 1 /* valloc() in default lib(s) */
+#define _hdr_alloca 1 /* #include <alloca.h> ok */
+#define _hdr_malloc 1 /* #include <malloc.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _mem_arena_mallinfo 1 /* arena is a member of struct mallinfo */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _mem_sbrk 1 /* brk()/sbrk() work as expected */
+#define _lib_alloca 1 /* alloca exists */
+#define _stk_down 1 /* stack grows downward */
+#include "FEATURE/mmap"
+#if _BLD_INSTRUMENT || cray || _UWIN && _BLD_ast
+#undef _map_malloc
+#define _std_malloc 1 /* defer to standard malloc */
+#endif
+#if _mmap_anon
+#define _mem_mmap_anon 1
+#endif
+#if _mmap_devzero
+#define _mem_mmap_zero 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/wait b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/wait
new file mode 100644
index 0000000000..69a5c225da
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/wait
@@ -0,0 +1,11 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/wait by iffe version 2007-04-04 : : */
+#ifndef _def_wait_ast
+#define _def_wait_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_wait 1 /* wait() in default lib(s) */
+#define _lib_wait3 1 /* wait3() in default lib(s) */
+#define _lib_wait4 1 /* wait4() in default lib(s) */
+#define _lib_waitpid 1 /* waitpid() in default lib(s) */
+#define _sys_wait 1 /* #include <sys/wait.h> ok */
+#define _ok_wif 1 /* posix wait macros ok */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/wchar b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/wchar
new file mode 100644
index 0000000000..c667a53fa1
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/FEATURE/wchar
@@ -0,0 +1,187 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/wchar by iffe version 2007-04-04 : : */
+
+#ifndef _def_wchar_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_wchar_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _lib_mbstowcs 1 /* mbstowcs() in default lib(s) */
+#define _lib_wctomb 1 /* wctomb() in default lib(s) */
+#define _lib_wcrtomb 1 /* wcrtomb() in default lib(s) */
+#define _lib_wcslen 1 /* wcslen() in default lib(s) */
+#define _lib_wcstombs 1 /* wcstombs() in default lib(s) */
+#define _lib_wcwidth 1 /* wcwidth() in default lib(s) */
+#define _lib_towlower 1 /* towlower() in default lib(s) */
+#define _lib_towupper 1 /* towupper() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_mbstate_t 1 /* mbstate_t is a type */
+#define _nxt_wchar <../include/wchar.h> /* include path for the native <wchar.h> */
+#define _nxt_wchar_str "../include/wchar.h" /* include string for the native <wchar.h> */
+#ifndef _SFSTDIO_H
+#include <ast_common.h>
+#include <stdio.h>
+#endif
+#if _hdr_wchar && defined(_nxt_wchar)
+#include <../include/wchar.h> /* the native wchar.h */
+#endif
+#if _hdr_wctype
+#include <wctype.h>
+#endif
+
+#ifndef WEOF
+#define WEOF (-1)
+#endif
+
+#undef fgetwc
+#undef fgetws
+#undef fputwc
+#undef fputws
+#undef getwc
+#undef getwchar
+#undef getws
+#undef putwc
+#undef putwchar
+#undef ungetwc
+
+#define fgetwc _ast_fgetwc
+#define fgetws _ast_fgetws
+#define fputwc _ast_fputwc
+#define fputws _ast_fputws
+#define fwide _ast_fwide
+#define fwprintf _ast_fwprintf
+#define fwscanf _ast_fwscanf
+#define getwc _ast_getwc
+#define getwchar _ast_getwchar
+#define getws _ast_getws
+#define putwc _ast_putwc
+#define putwchar _ast_putwchar
+#define swprintf _ast_swprintf
+#define swscanf _ast_swscanf
+#define ungetwc _ast_ungetwc
+#define vfwprintf _ast_vfwprintf
+#define vfwscanf _ast_vfwscanf
+#define vswprintf _ast_vswprintf
+#define vswscanf _ast_vswscanf
+#define vwprintf _ast_vwprintf
+#define vwscanf _ast_vwscanf
+#define wprintf _ast_wprintf
+#define wscanf _ast_wscanf
+
+#if !_typ_mbstate_t
+#undef _typ_mbstate_t
+#define _typ_mbstate_t 1
+typedef char mbstate_t;
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#if !_lib_mbstowcs
+extern __MANGLE__ size_t mbstowcs __PROTO__((wchar_t*, const char*, size_t));
+#endif
+#if !_lib_wctomb
+extern __MANGLE__ int wctomb __PROTO__((char*, wchar_t));
+#endif
+#if !_lib_wcrtomb
+extern __MANGLE__ size_t wcrtomb __PROTO__((char*, wchar_t, mbstate_t*));
+#endif
+#if !_lib_wcslen
+extern __MANGLE__ size_t wcslen __PROTO__((const wchar_t*));
+#endif
+#if !_lib_wcstombs
+extern __MANGLE__ size_t wcstombs __PROTO__((char*, const wchar_t*, size_t));
+#endif
+
+extern __MANGLE__ int fwprintf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ int fwscanf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ wint_t fgetwc __PROTO__((FILE*));
+extern __MANGLE__ wchar_t* fgetws __PROTO__((wchar_t*, int, FILE*));
+extern __MANGLE__ wint_t fputwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ int fputws __PROTO__((const wchar_t*, FILE*));
+extern __MANGLE__ int fwide __PROTO__((FILE*, int));
+extern __MANGLE__ wint_t getwc __PROTO__((FILE*));
+extern __MANGLE__ wint_t getwchar __PROTO__((void));
+extern __MANGLE__ wchar_t* getws __PROTO__((wchar_t*));
+extern __MANGLE__ wint_t putwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ wint_t putwchar __PROTO__((wchar_t));
+extern __MANGLE__ int swprintf __PROTO__((wchar_t*, size_t, const wchar_t*, ...));
+extern __MANGLE__ int swscanf __PROTO__((const wchar_t*, const wchar_t*, ...));
+extern __MANGLE__ wint_t ungetwc __PROTO__((wint_t, FILE*));
+extern __MANGLE__ int vfwprintf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vfwscanf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vwprintf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vwscanf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vswprintf __PROTO__((wchar_t*, size_t, const wchar_t*, va_list));
+extern __MANGLE__ int vswscanf __PROTO__((const wchar_t*, const wchar_t*, va_list));
+extern __MANGLE__ int wprintf __PROTO__((const wchar_t*, ...));
+extern __MANGLE__ int wscanf __PROTO__((const wchar_t*, ...));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/align.h b/usr/src/lib/libast/sparcv9/src/lib/libast/align.h
new file mode 100644
index 0000000000..67bdb68aae
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/align.h
@@ -0,0 +1,33 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/align.c by iffe version 2007-04-04 : : */
+#ifndef _def_align_ast
+#define _def_align_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+typedef unsigned long ALIGN_INTEGRAL;
+
+#define ALIGN_CHUNK 8192
+#define ALIGN_INTEGRAL long
+#define ALIGN_INTEGER(x) ((ALIGN_INTEGRAL)(x))
+#define ALIGN_POINTER(x) ((char*)(x))
+#define ALIGN_ROUND(x,y) ALIGN_POINTER(ALIGN_INTEGER((x)+(y)-1)&~((y)-1))
+
+#define ALIGN_BOUND ALIGN_BOUND2
+#define ALIGN_ALIGN(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC(x) ALIGN_TRUNC2(x)
+
+#define ALIGN_BIT1 0x1
+#define ALIGN_BOUND1 ALIGN_BOUND2
+#define ALIGN_ALIGN1(x) ALIGN_ALIGN2(x)
+#define ALIGN_TRUNC1(x) ALIGN_TRUNC2(x)
+#define ALIGN_CLRBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffffe)
+#define ALIGN_SETBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x1)
+#define ALIGN_TSTBIT1(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x1)
+
+#define ALIGN_BIT2 0x2
+#define ALIGN_BOUND2 16
+#define ALIGN_ALIGN2(x) ALIGN_TRUNC2((x)+15)
+#define ALIGN_TRUNC2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffff0)
+#define ALIGN_CLRBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0xfffffffffffffffd)
+#define ALIGN_SETBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)|0x2)
+#define ALIGN_TSTBIT2(x) ALIGN_POINTER(ALIGN_INTEGER(x)&0x2)
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_botch.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_botch.h
new file mode 100644
index 0000000000..bd5405c63c
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_botch.h
@@ -0,0 +1,5 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/botch.c by iffe version 2007-04-04 : : */
+#ifndef _def_botch_ast
+#define _def_botch_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_ccode.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_ccode.h
new file mode 100644
index 0000000000..7055bf926b
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_ccode.h
@@ -0,0 +1,29 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/ccode by iffe version 2007-04-04 : : */
+#ifndef _def_ccode_ast
+#define _def_ccode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define CC_ASCII 1 /* ISO-8859-1 */
+#define CC_EBCDIC_E 2 /* Xopen dd(1) EBCDIC */
+#define CC_EBCDIC_I 3 /* Xopen dd(1) IBM */
+#define CC_EBCDIC_O 4 /* IBM-1047 mvs OpenEdition */
+#define CC_EBCDIC_S 5 /* Siemens posix-bc */
+#define CC_EBCDIC_H 6 /* IBM-37 AS/400 */
+#define CC_EBCDIC_M 7 /* IBM mvs cobol */
+#define CC_EBCDIC_U 8 /* microfocus cobol */
+
+#define CC_MAPS 8 /* number of code maps */
+
+#define CC_EBCDIC CC_EBCDIC_E
+#define CC_EBCDIC1 CC_EBCDIC_E
+#define CC_EBCDIC2 CC_EBCDIC_I
+#define CC_EBCDIC3 CC_EBCDIC_O
+
+#define CC_NATIVE CC_ASCII /* native character code */
+#define CC_ALIEN CC_EBCDIC /* alien character code */
+
+#define CC_bel 0007 /* bel character */
+#define CC_esc 0033 /* esc character */
+#define CC_sub 0032 /* sub character */
+#define CC_vt 0013 /* vt character */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_common.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_common.h
new file mode 100644
index 0000000000..23fce187e2
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_common.h
@@ -0,0 +1,199 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/common by iffe version 2007-04-04 : : */
+#ifndef _AST_COMMON_H
+#define _AST_COMMON_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_pthread 1 /* #include <pthread.h> ok */
+#define _hdr_stdarg 1 /* #include <stdarg.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdint 1 /* #include <stdint.h> ok */
+#define _hdr_inttypes 1 /* #include <inttypes.h> ok */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_long_double 1 /* long double is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _std_proto 1 /* standard C prototypes ok */
+#define _ptr_void 1 /* standard C void* ok */
+/* disable non-standard linux/gnu inlines */
+#ifdef __GNUC__
+# undef __OPTIMIZE_SIZE__
+# define __OPTIMIZE_SIZE__ 1
+#endif
+
+/* __STD_C indicates that the language is ANSI-C or C++ */
+#if !defined(__STD_C) && __STDC__
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && (__cplusplus || c_plusplus)
+# define __STD_C 1
+#endif
+#if !defined(__STD_C) && _std_proto
+# define __STD_C 1
+#endif
+#if !defined(__STD_C)
+# define __STD_C 0
+#endif
+
+/* extern symbols must be protected against C++ name mangling */
+#ifndef _BEGIN_EXTERNS_
+# if __cplusplus || c_plusplus
+# define _BEGIN_EXTERNS_ extern "C" {
+# define _END_EXTERNS_ }
+# else
+# define _BEGIN_EXTERNS_
+# define _END_EXTERNS_
+# endif
+#endif
+
+/* _ARG_ simplifies function prototyping among flavors of C */
+#ifndef _ARG_
+# if __STD_C
+# define _ARG_(x) x
+# else
+# define _ARG_(x) ()
+# endif
+#endif
+
+/* _NIL_ simplifies defining nil pointers to a given type */
+#ifndef _NIL_
+# define _NIL_(x) ((x)0)
+#endif
+
+/* __INLINE__ is the inline keyword */
+#if !defined(__INLINE__) && defined(__cplusplus)
+# define __INLINE__ inline
+#endif
+#if !defined(__INLINE__) && defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+#endif
+
+/* Void_t is defined so that Void_t* can address any type */
+#ifndef Void_t
+# if __STD_C
+# define Void_t void
+# else
+# define Void_t char
+# endif
+#endif
+
+/* windows variants and veneers */
+#if !defined(_WINIX) && (_UWIN || __CYGWIN__ || __EMX__)
+# define _WINIX 1
+#endif
+
+/* dynamic linked library external scope handling */
+#ifdef __DYNAMIC__
+# undef __DYNAMIC__
+# ifndef _DLL
+# define _DLL 1
+# endif
+#endif
+#if _dll_import
+# if _BLD_STATIC && !_BLD_DLL
+# undef _DLL
+# else
+# if !_UWIN && !defined(_DLL)
+# define _DLL 1
+# endif
+# endif
+# if !defined(__EXPORT__) && _BLD_DLL
+# define __EXPORT__ __declspec(dllexport)
+# endif
+# if !defined(__IMPORT__) && ( _BLD_DLL || defined(_DLL) )
+# define __IMPORT__ __declspec(dllimport)
+# endif
+# if _BLD_DLL && _UWIN
+# define __DYNAMIC__(v) (_ast_getdll()->_ast_ ## v)
+# endif
+#endif
+#if !defined(_astimport)
+# if defined(__IMPORT__) && defined(_DLL)
+# define _astimport __IMPORT__
+# else
+# define _astimport extern
+# endif
+#endif
+#if _dll_import && ( !_BLD_DLL || _WINIX && !_UWIN )
+# ifdef __STDC__
+# define __EXTERN__(T,obj) extern T obj; T* _imp__ ## obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__ ## obj = &obj
+# else
+# define __EXTERN__(T,obj) extern T obj; T* _imp__/**/obj = &obj
+# define __DEFINE__(T,obj,val) T obj = val; T* _imp__/**/obj = &obj
+# endif
+#else
+# define __EXTERN__(T,obj) extern T obj
+# define __DEFINE__(T,obj,val) T obj = val
+#endif
+
+#define _ast_LL 1 /* LL numeric suffix supported */
+#define _ast_int1_t char
+#define _ast_int2_t short
+#define _ast_int4_t int
+#define _ast_int8_t long
+#define _ast_intmax_t _ast_int8_t
+#define _ast_intmax_long 1
+#define _ast_intswap 0
+
+#define _ast_flt4_t float
+#define _ast_flt8_t double
+#define _ast_flt16_t long double
+#define _ast_fltmax_t _ast_flt16_t
+#define _typ_int8_t 1 /* int8_t is a type */
+#define _typ_uint8_t 1 /* uint8_t is a type */
+#define _typ_int16_t 1 /* int16_t is a type */
+#define _typ_uint16_t 1 /* uint16_t is a type */
+#define _typ_int32_t 1 /* int32_t is a type */
+#define _typ_uint32_t 1 /* uint32_t is a type */
+#define _typ_int64_t 1 /* int64_t is a type */
+#define _typ_uint64_t 1 /* uint64_t is a type */
+#define _typ_intmax_t 1 /* intmax_t is a type */
+#define _typ_uintmax_t 1 /* uintmax_t is a type */
+
+#ifndef va_listref
+#define va_listref(p) (p) /* pass va_list to varargs function */
+#define va_listval(p) (p) /* retrieve va_list from va_arg(ap,va_listarg) */
+#define va_listarg va_list /* va_arg() va_list type */
+#ifndef va_start
+#if __STD_C
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+#endif
+#ifndef _AST_STD_H
+# if __STD_C && _hdr_stddef
+# include <stddef.h>
+# endif
+# if _sys_types
+# include <sys/types.h>
+# endif
+# if _hdr_stdint
+# include <stdint.h>
+# else
+# if _hdr_inttypes
+# include <inttypes.h>
+# endif
+# endif
+#endif
+#if !_typ_size_t
+# define _typ_size_t 1
+ typedef int size_t;
+#endif
+#if !_typ_ssize_t
+# define _typ_ssize_t 1
+ typedef int ssize_t;
+#endif
+#ifndef _AST_STD_H
+# if !_def_map_ast
+# include <ast_map.h>
+# endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_dirent.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_dirent.h
new file mode 100644
index 0000000000..5c447ac078
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_dirent.h
@@ -0,0 +1,82 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/dirent by iffe version 2007-04-04 : : */
+
+#ifndef _def_dirent_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dirent_ast 1
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _nxt_dirent <../include/dirent.h> /* include path for the native <dirent.h> */
+#define _nxt_dirent_str "../include/dirent.h" /* include string for the native <dirent.h> */
+/*
+ * <dirent.h> for systems with ok <dirent.h>
+ */
+
+#ifndef _DIRENT_H
+
+#include <../include/dirent.h> /* the native <dirent.h> */
+
+#ifndef _DIRENT_H
+#define _DIRENT_H
+#endif
+
+#endif
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_fcntl.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_fcntl.h
new file mode 100644
index 0000000000..156e2ec213
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_fcntl.h
@@ -0,0 +1,114 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/fcntl.c by iffe version 2007-04-04 : : */
+#ifndef _def_fcntl_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fcntl_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <ast_fs.h>
+
+#if _typ_off64_t
+#undef off_t
+#ifdef __STDC__
+#define off_t off_t
+#endif
+#endif
+
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#define O_BINARY 0
+#define O_TEMPORARY 0
+#define O_TEXT 0
+
+#include <ast_fs.h>
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_fstat64
+#define fstat fstat64
+#endif
+#if _lib_lstat64
+#define lstat lstat64
+#endif
+#if _lib_stat64
+#define stat stat64
+#endif
+#if _lib_creat64
+#define creat creat64
+#endif
+#if _lib_mmap64
+#define mmap mmap64
+#endif
+#if _lib_open64
+#undef open
+#define open open64
+#endif
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_float.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_float.h
new file mode 100644
index 0000000000..de179a370c
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_float.h
@@ -0,0 +1,212 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/float by iffe version 2007-04-04 : : */
+
+#ifndef _def_float_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_float_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_float 1 /* #include <float.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _hdr_values 1 /* #include <values.h> ok */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_frexp 1 /* frexp() in default lib(s) */
+#define _lib_frexpl 1 /* frexpl() in default lib(s) */
+#define _lib_ldexp 1 /* ldexp() in default lib(s) */
+#define _lib_ldexpl 1 /* ldexpl() in default lib(s) */
+#define _lib_finite 1 /* finite() in default lib(s) */
+#define _lib_isnan 1 /* isnan() in default lib(s) */
+#define _lib_isnanl 1 /* isnanl() in default lib(s) */
+#define _lib_copysign 1 /* copysign() in default lib(s) */
+#define _lib_copysignl 1 /* copysignl() in default lib(s) */
+#include <ast_common.h>
+#include <float.h>
+#include <math.h>
+#ifndef FLT_DIG
+#define FLT_DIG 6
+#endif
+#ifndef FLT_MAX
+#define FLT_MAX 3.4028234663852885981170E+38F
+#endif
+#ifndef FLT_MAX_10_EXP
+#define FLT_MAX_10_EXP ( + 38 )
+#endif
+#ifndef FLT_MAX_EXP
+#define FLT_MAX_EXP ( + 128 )
+#endif
+#ifndef FLT_MIN
+#define FLT_MIN 1.1754943508222875079688E-38F
+#endif
+#ifndef FLT_MIN_10_EXP
+#define FLT_MIN_10_EXP ( - 37 )
+#endif
+#ifndef FLT_MIN_EXP
+#define FLT_MIN_EXP ( - 125 )
+#endif
+#ifndef DBL_DIG
+#define DBL_DIG 15
+#endif
+#ifndef DBL_MAX
+#define DBL_MAX 1.7976931348623157081452E+308
+#endif
+#ifndef DBL_MAX_10_EXP
+#define DBL_MAX_10_EXP ( + 308 )
+#endif
+#ifndef DBL_MAX_EXP
+#define DBL_MAX_EXP ( + 1024 )
+#endif
+#ifndef DBL_MIN
+#define DBL_MIN 2.2250738585072013830903E-308
+#endif
+#ifndef DBL_MIN_10_EXP
+#define DBL_MIN_10_EXP ( - 307 )
+#endif
+#ifndef DBL_MIN_EXP
+#define DBL_MIN_EXP ( - 1021 )
+#endif
+#ifndef LDBL_DIG
+#define LDBL_DIG 33
+#endif
+#ifndef LDBL_MAX
+#define LDBL_MAX 1.189731495357231765085759326628007016E+4932L
+#endif
+#ifndef LDBL_MAX_10_EXP
+#define LDBL_MAX_10_EXP ( + 4932 )
+#endif
+#ifndef LDBL_MAX_EXP
+#define LDBL_MAX_EXP ( + 16384 )
+#endif
+#ifndef LDBL_MIN
+#define LDBL_MIN 3.362103143112093506262677817321752603E-4932L
+#endif
+#ifndef LDBL_MIN_10_EXP
+#define LDBL_MIN_10_EXP ( - 4931 )
+#endif
+#ifndef LDBL_MIN_EXP
+#define LDBL_MIN_EXP ( - 16381 )
+#endif
+
+
+#define USHRT_DIG 4
+#define UINT_DIG 9
+#define ULONG_DIG 19
+#define UINTMAX_DIG ULONG_DIG
+
+#define FLT_ULONG_MAX 18446744073709551615.0F
+#define FLT_ULLONG_MAX FLT_ULONG_MAX
+#define FLT_UINTMAX_MAX FLT_ULONG_MAX
+#define FLT_LONG_MAX 9223372036854775807.0F
+#define FLT_LLONG_MAX FLT_LONG_MAX
+#define FLT_INTMAX_MAX FLT_LONG_MAX
+#define FLT_LONG_MIN (-9223372036854775808.0F)
+#define FLT_LLONG_MIN FLT_LONG_MIN
+#define FLT_INTMAX_MIN FLT_LONG_MIN
+
+#define DBL_ULONG_MAX 18446744073709551615.0
+#define DBL_ULLONG_MAX DBL_ULONG_MAX
+#define DBL_UINTMAX_MAX DBL_ULONG_MAX
+#define DBL_LONG_MAX 9223372036854775807.0
+#define DBL_LLONG_MAX DBL_LONG_MAX
+#define DBL_INTMAX_MAX DBL_LONG_MAX
+#define DBL_LONG_MIN (-9223372036854775808.0)
+#define DBL_LLONG_MIN DBL_LONG_MIN
+#define DBL_INTMAX_MIN DBL_LONG_MIN
+
+#define LDBL_ULONG_MAX 18446744073709551615.0L
+#define LDBL_ULLONG_MAX LDBL_ULONG_MAX
+#define LDBL_UINTMAX_MAX LDBL_ULONG_MAX
+#define LDBL_LONG_MAX 9223372036854775807.0L
+#define LDBL_LLONG_MAX LDBL_LONG_MAX
+#define LDBL_INTMAX_MAX LDBL_LONG_MAX
+#define LDBL_LONG_MIN (-9223372036854775808.0L)
+#define LDBL_LLONG_MIN LDBL_LONG_MIN
+#define LDBL_INTMAX_MIN LDBL_LONG_MIN
+
+#define FLTMAX_UINTMAX_MAX LDBL_UINTMAX_MAX
+#define FLTMAX_INTMAX_MAX LDBL_INTMAX_MAX
+#define FLTMAX_INTMAX_MIN LDBL_INTMAX_MIN
+
+typedef union _ast_dbl_exp_u
+{
+ uint32_t e[sizeof(double)/4];
+ double f;
+} _ast_dbl_exp_t;
+
+#define _ast_dbl_exp_index 0
+#define _ast_dbl_exp_shift 20
+
+typedef union _fltmax_exp_u
+{
+ uint32_t e[sizeof(_ast_fltmax_t)/4];
+ _ast_fltmax_t f;
+} _ast_fltmax_exp_t;
+
+#define _ast_fltmax_exp_index 0
+#define _ast_fltmax_exp_shift 16
+
+#define _ast_flt_unsigned_max_t unsigned long long
+#define _ast_flt_nan_init 0x7f,0xff,0xff,0xff
+#define _ast_flt_inf_init 0x7f,0x80,0x00,0x00
+#define _ast_dbl_nan_init 0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff
+#define _ast_dbl_inf_init 0x7f,0xf0,0x00,0x00,0x00,0x00,0x00,0x00
+#define _ast_ldbl_nan_init 0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
+#define _ast_ldbl_inf_init 0x7f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_fs.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_fs.h
new file mode 100644
index 0000000000..d3e524a3d0
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_fs.h
@@ -0,0 +1,153 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/fs by iffe version 2007-04-04 : : */
+
+#ifndef _def_fs_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_fs_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _lib_lstat 1 /* lstat() in default lib(s) */
+#define _lib_mknod 1 /* mknod() in default lib(s) */
+#define _lib_sync 1 /* sync() in default lib(s) */
+#include <sys/stat.h>
+#define FS_default "ufs"
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef major
+#define major(x) ( major_t ) ( ( ( ( unsigned ) ( ( x ) ) ) >> 8 ) & 0x7f )
+#endif
+#ifndef minor
+#define minor(x) ( minor_t ) ( ( ( x ) ) & 0xff )
+#endif
+#ifndef makedev
+#define makedev(x,y) ( unsigned short ) ( ( ( ( x ) ) << 8 ) | ( ( ( y ) ) & 0xff ) )
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _sys_mntent 1 /* #include <sys/mntent.h> ok */
+#define _sys_mnttab 1 /* #include <sys/mnttab.h> ok */
+#define _mem_st_blocks_stat 1 /* st_blocks is a member of struct stat */
+#define _mem_st_blksize_stat 1 /* st_blksize is a member of struct stat */
+#define _mem_st_rdev_stat 1 /* st_rdev is a member of struct stat */
+#define _sys_statfs 1 /* #include <sys/statfs.h> ok */
+#define _mem_f_files_statfs 1 /* f_files is a member of struct statfs */
+#define _sys_vfs 1 /* #include <sys/vfs.h> ok */
+#define _sys_param 1 /* #include <sys/param.h> ok */
+#define _sys_mount 1 /* #include <sys/mount.h> ok */
+#define _sys_statvfs 1 /* #include <sys/statvfs.h> ok */
+#define _mem_f_basetype_statvfs 1 /* f_basetype is a member of struct statvfs */
+#define _mem_f_frsize_statvfs 1 /* f_frsize is a member of struct statvfs */
+#define _lib_getmntent 1 /* getmntent() in default lib(s) */
+#define _lib_statfs 1 /* statfs() in default lib(s) */
+#define _lib_statvfs 1 /* statvfs() in default lib(s) */
+#define _lib_statfs4 1 /* compile{\ passed */
+#if _sys_statvfs
+#include <sys/statvfs.h>
+#if !_mem_statvfs_f_basetype
+#if _ary_f_reserved7
+#define f_basetype f_reserved7
+#endif
+#endif
+#else
+#define _mem_f_basetype_statvfs 1
+#define _mem_f_frsize_statvfs 1
+struct statvfs
+{
+unsigned long f_bsize; /* fundamental file system block size */
+unsigned long f_frsize; /* fragment size */
+unsigned long f_blocks; /* total # of blocks of f_frsize on fs */
+unsigned long f_bfree; /* total # of free blocks of f_frsize */
+unsigned long f_bavail; /* # of free blocks avail to non-superuser */
+unsigned long f_files; /* total # of file nodes (inodes) */
+unsigned long f_ffree; /* total # of free file nodes */
+unsigned long f_favail; /* # of free nodes avail to non-superuser */
+unsigned long f_fsid; /* file system id (dev for now) */
+char f_basetype[16]; /* target fs type name, null-terminated */
+unsigned long f_flag; /* bit-mask of flags */
+unsigned long f_namemax; /* maximum file name length */
+char f_fstr[32]; /* filesystem-specific string */
+unsigned long f_filler[16]; /* reserved for future expansion */
+};
+extern __MANGLE__ int fstatvfs __PROTO__((int, struct statvfs*));
+extern __MANGLE__ int statvfs __PROTO__((const char*, struct statvfs*));
+#endif
+#if _typ_off64_t
+#undef off_t
+#define off_t off64_t
+#endif
+#if _lib_statvfs64 && !defined(statvfs)
+#define statvfs statvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int statvfs64 __PROTO__((const char*, struct statvfs64*));
+#endif
+#endif
+#if _lib_fstatvfs64 && !defined(fstatvfs)
+#define fstatvfs fstatvfs64
+#if !defined(__USE_LARGEFILE64)
+extern __MANGLE__ int fstatvfs64 __PROTO__((int, struct statvfs64*));
+#endif
+#endif
+
+#define _str_st_fstype 1 /* stat.st_fstype is a string */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_iconv.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_iconv.h
new file mode 100644
index 0000000000..2409c25672
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_iconv.h
@@ -0,0 +1,132 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/iconv by iffe version 2007-04-04 : : */
+
+#ifndef _def_iconv_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_iconv_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_iconv 1 /* #include <iconv.h> ok */
+#define _lib_iconv_open 1 /* iconv_open() in default lib(s) */
+#define _lib_iconv_close 1 /* iconv_close() in default lib(s) */
+#define _lib_iconv 1 /* iconv() in default lib(s) */
+#define _nxt_iconv <../include/iconv.h> /* include path for the native <iconv.h> */
+#define _nxt_iconv_str "../include/iconv.h" /* include string for the native <iconv.h> */
+#include <ast_common.h>
+#include <ccode.h>
+#include <../include/iconv.h> /* the native iconv.h */
+
+#define CC_ICONV (-1)
+#define CC_UCS (-2)
+#define CC_SCU (-3)
+#define CC_UTF (-4)
+#define CC_UME (-5)
+
+#ifndef _ICONV_LIST_PRIVATE_
+#undef iconv_t
+#define iconv_t _ast_iconv_t
+#undef iconv_f
+#define iconv_f _ast_iconv_f
+#undef iconv_list_t
+#define iconv_list_t _ast_iconv_list_t
+#undef iconv_open
+#define iconv_open _ast_iconv_open
+#undef iconv
+#define iconv _ast_iconv
+#undef iconv_close
+#define iconv_close _ast_iconv_close
+#undef iconv_list
+#define iconv_list _ast_iconv_list
+#undef iconv_move
+#define iconv_move _ast_iconv_move
+#undef iconv_name
+#define iconv_name _ast_iconv_name
+#undef iconv_write
+#define iconv_write _ast_iconv_write
+#endif
+
+typedef Ccmap_t _ast_iconv_list_t;
+typedef __V_* _ast_iconv_t;
+typedef size_t (*_ast_iconv_f) __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ _ast_iconv_t _ast_iconv_open __PROTO__((const char*, const char*));
+extern __MANGLE__ size_t _ast_iconv __PROTO__((_ast_iconv_t, char**, size_t*, char**, size_t*));
+extern __MANGLE__ int _ast_iconv_close __PROTO__((_ast_iconv_t));
+extern __MANGLE__ _ast_iconv_list_t* _ast_iconv_list __PROTO__((_ast_iconv_list_t*));
+extern __MANGLE__ int _ast_iconv_name __PROTO__((const char*, char*, size_t));
+#if _SFIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, Sfio_t*, Sfio_t*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, Sfio_t*, char**, size_t*, size_t*));
+#else
+#if _SFSTDIO_H
+extern __MANGLE__ ssize_t _ast_iconv_move __PROTO__((_ast_iconv_t, FILE*, FILE*, size_t, size_t*));
+extern __MANGLE__ ssize_t _ast_iconv_write __PROTO__((_ast_iconv_t, FILE*, char**, size_t*, size_t*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_lib.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_lib.h
new file mode 100644
index 0000000000..c546bc76ef
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_lib.h
@@ -0,0 +1,160 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/lib by iffe version 2007-04-04 : : */
+#ifndef _def_lib_ast
+#define _def_lib_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_dirent 1 /* #include <dirent.h> ok */
+#define _hdr_fmtmsg 1 /* #include <fmtmsg.h> ok */
+#define _hdr_fnmatch 1 /* #include <fnmatch.h> ok */
+#define _hdr_libgen 1 /* #include <libgen.h> ok */
+#define _hdr_limits 1 /* #include <limits.h> ok */
+#define _hdr_locale 1 /* #include <locale.h> ok */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_spawn 1 /* #include <spawn.h> ok */
+#define _hdr_syslog 1 /* #include <syslog.h> ok */
+#define _hdr_utime 1 /* #include <utime.h> ok */
+#define _hdr_wctype 1 /* #include <wctype.h> ok */
+#define _hdr_wchar 1 /* <wchar.h> and isw*() really work */
+#define _dat__tzname 1 /* _tzname in default lib(s) */
+#define _dat_tzname 1 /* tzname in default lib(s) */
+#define _lib__cleanup 1 /* _cleanup() in default lib(s) */
+#define _lib_atexit 1 /* atexit() in default lib(s) */
+#define _lib_bcopy 1 /* bcopy() in default lib(s) */
+#define _lib_bzero 1 /* bzero() in default lib(s) */
+#define _lib_catclose 1 /* catclose() in default lib(s) */
+#define _lib_catgets 1 /* catgets() in default lib(s) */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_confstr 1 /* confstr() in default lib(s) */
+#define _lib_dup2 1 /* dup2() in default lib(s) */
+#define _lib_execlp 1 /* execlp() in default lib(s) */
+#define _lib_execve 1 /* execve() in default lib(s) */
+#define _lib_execvp 1 /* execvp() in default lib(s) */
+#define _lib_fchmod 1 /* fchmod() in default lib(s) */
+#define _lib_fcntl 1 /* fcntl() in default lib(s) */
+#define _lib_fmtmsg 1 /* fmtmsg() in default lib(s) */
+#define _lib_fnmatch 1 /* fnmatch() in default lib(s) */
+#define _lib_fork 1 /* fork() in default lib(s) */
+#define _lib_fsync 1 /* fsync() in default lib(s) */
+#define _lib_getdents 1 /* getdents() in default lib(s) */
+#define _lib_getdtablesize 1 /* getdtablesize() in default lib(s) */
+#define _lib_getdate 1 /* getdate() in default lib(s) */
+#define _lib_getgroups 1 /* getgroups() in default lib(s) */
+#define _lib_gethostname 1 /* gethostname() in default lib(s) */
+#define _lib_getlogin 1 /* getlogin() in default lib(s) */
+#define _lib_getpagesize 1 /* getpagesize() in default lib(s) */
+#define _lib_getrlimit 1 /* getrlimit() in default lib(s) */
+#define _lib_getopt 1 /* getopt() in default lib(s) */
+#define _lib_getsubopt 1 /* getsubopt() in default lib(s) */
+#define _lib_getopt_long 1 /* getopt_long() in default lib(s) */
+#define _lib_getopt_long_only 1 /* getopt_long_only() in default lib(s) */
+#define _lib_glob 1 /* glob() in default lib(s) */
+#define _lib_index 1 /* index() in default lib(s) */
+#define _lib_iswblank 1 /* iswblank() in default lib(s) */
+#define _lib_iswctype 1 /* iswctype() in default lib(s) */
+#define _lib_killpg 1 /* killpg() in default lib(s) */
+#define _lib_link 1 /* link() in default lib(s) */
+#define _lib_localeconv 1 /* localeconv() in default lib(s) */
+#define _lib_madvise 1 /* madvise() in default lib(s) */
+#define _lib_mbtowc 1 /* mbtowc() in default lib(s) */
+#define _lib_mbrtowc 1 /* mbrtowc() in default lib(s) */
+#define _lib_memalign 1 /* memalign() in default lib(s) */
+#define _lib_memchr 1 /* memchr() in default lib(s) */
+#define _lib_memcpy 1 /* memcpy() in default lib(s) */
+#define _lib_memmove 1 /* memmove() in default lib(s) */
+#define _lib_memset 1 /* memset() in default lib(s) */
+#define _lib_mkdir 1 /* mkdir() in default lib(s) */
+#define _lib_mkfifo 1 /* mkfifo() in default lib(s) */
+#define _lib_mktemp 1 /* mktemp() in default lib(s) */
+#define _lib_mktime 1 /* mktime() in default lib(s) */
+#define _lib_mount 1 /* mount() in default lib(s) */
+#define _lib_opendir 1 /* opendir() in default lib(s) */
+#define _lib_pathconf 1 /* pathconf() in default lib(s) */
+#define _lib_readlink 1 /* readlink() in default lib(s) */
+#define _lib_remove 1 /* remove() in default lib(s) */
+#define _lib_rename 1 /* rename() in default lib(s) */
+#define _lib_rewinddir 1 /* rewinddir() in default lib(s) */
+#define _lib_rindex 1 /* rindex() in default lib(s) */
+#define _lib_rmdir 1 /* rmdir() in default lib(s) */
+#define _lib_setlocale 1 /* setlocale() in default lib(s) */
+#define _lib_setpgid 1 /* setpgid() in default lib(s) */
+#define _lib_setpgrp 1 /* setpgrp() in default lib(s) */
+#define _lib_setreuid 1 /* setreuid() in default lib(s) */
+#define _lib_setsid 1 /* setsid() in default lib(s) */
+#define _lib_setuid 1 /* setuid() in default lib(s) */
+#define _lib_sigaction 1 /* sigaction() in default lib(s) */
+#define _lib_sigprocmask 1 /* sigprocmask() in default lib(s) */
+#define _lib_socketpair 1 /* socketpair() in default lib(s) */
+#define _lib_strchr 1 /* strchr() in default lib(s) */
+#define _lib_strcoll 1 /* strcoll() in default lib(s) */
+#define _lib_strdup 1 /* strdup() in default lib(s) */
+#define _lib_strerror 1 /* strerror() in default lib(s) */
+#define _lib_strcasecmp 1 /* strcasecmp() in default lib(s) */
+#define _lib_strncasecmp 1 /* strncasecmp() in default lib(s) */
+#define _lib_strrchr 1 /* strrchr() in default lib(s) */
+#define _lib_strstr 1 /* strstr() in default lib(s) */
+#define _lib_strxfrm 1 /* strxfrm() in default lib(s) */
+#define _lib_strftime 1 /* strftime() in default lib(s) */
+#define _lib_swab 1 /* swab() in default lib(s) */
+#define _lib_symlink 1 /* symlink() in default lib(s) */
+#define _lib_sysconf 1 /* sysconf() in default lib(s) */
+#define _lib_sysinfo 1 /* sysinfo() in default lib(s) */
+#define _lib_syslog 1 /* syslog() in default lib(s) */
+#define _lib_telldir 1 /* telldir() in default lib(s) */
+#define _lib_tmpnam 1 /* tmpnam() in default lib(s) */
+#define _lib_tzset 1 /* tzset() in default lib(s) */
+#define _lib_unlink 1 /* unlink() in default lib(s) */
+#define _lib_utime 1 /* utime() in default lib(s) */
+#define _lib_wctype 1 /* wctype() in default lib(s) */
+#define _lib_ftruncate 1 /* ftruncate() in default lib(s) */
+#define _lib_truncate 1 /* truncate() in default lib(s) */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _lib_strtod 1 /* strtod() in default lib(s) */
+#define _lib_strtold 1 /* strtold() in default lib(s) */
+#define _lib_strtol 1 /* strtol() in default lib(s) */
+#define _lib_strtoll 1 /* strtoll() in default lib(s) */
+#define _lib_strtoul 1 /* strtoul() in default lib(s) */
+#define _lib_strtoull 1 /* strtoull() in default lib(s) */
+#define _mem_d_ino_dirent 1 /* d_ino is a member of struct dirent */
+#define _mem_d_off_dirent 1 /* d_off is a member of struct dirent */
+#define _mem_d_reclen_dirent 1 /* d_reclen is a member of struct dirent */
+#define _mem_DIR 1 /* DIR is a non-opaque struct */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _sys_jioctl 1 /* #include <sys/jioctl.h> ok */
+#define _sys_localedef 1 /* #include <sys/localedef.h> ok */
+#define _sys_ptem 1 /* #include <sys/ptem.h> ok */
+#define _sys_resource 1 /* #include <sys/resource.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _sys_stream 1 /* #include <sys/stream.h> ok */
+#define _sys_systeminfo 1 /* #include <sys/systeminfo.h> ok */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_off64_t 1 /* off64_t is a type */
+#define _typ_struct_dirent64 1 /* struct dirent64 is a type */
+#define _tst_errno 1 /* errno can be assigned */
+#define _lib_poll_fd_1 1 /* fd is first arg to poll() */
+#define _lib_poll 1 /* _lib_poll_fd_1||_lib_poll_fd_2 is true */
+#define _lib_select 1 /* select() has standard 5 arg interface */
+#define _pipe_rw 1 /* full duplex pipes */
+#define _hdr_unistd 1 /* #include <unistd.h> ok */
+#define _lib_vfork 1 /* vfork exists and it works */
+#define _real_vfork 1 /* vfork child shares data with parent */
+#define _lib_posix_spawn 1 /* posix_spawn exists and it works and its worth using */
+#define _stream_peek 1 /* ioctl(I_PEEK) works */
+#define _socket_peek 1 /* recv(MSG_PEEK) works */
+#define _hdr_string 1 /* #include <string.h> ok */
+#define _lib_memcmp 1 /* standard memcmp interface that works */
+#define _hdr_fcntl 1 /* #include <fcntl.h> ok */
+#define _hdr_signal 1 /* #include <signal.h> ok */
+#define _sys_stat 1 /* #include <sys/stat.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_memccpy 1 /* standard memccpy interface that works */
+#define _lib_utime_now 1 /* utime works with 0 time vector */
+#define _UNIV_DEFAULT "att" /* default universe name */
+#define _std_cleanup 1 /* stuck with standard _cleanup */
+#define _std_strcoll 1 /* standard strcoll works */
+#if !_AST_no_spawnveg
+#define _use_spawnveg 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_limits.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_limits.h
new file mode 100644
index 0000000000..d4f848a557
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_limits.h
@@ -0,0 +1,107 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/limits.c by iffe version 2007-04-04 : : */
+#ifndef _def_limits_ast
+#define _def_limits_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+#ifndef CHAR_MAX
+#define CHAR_MAX 127
+#endif
+#ifndef CHAR_MIN
+#define CHAR_MIN -128
+#endif
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC 1000000
+#endif
+#ifndef INT_MIN
+#define INT_MIN -2147483648
+#endif
+#ifndef LLONG_MAX
+#define LLONG_MAX 9223372036854775807
+#endif
+#ifndef LLONG_MIN
+#define LLONG_MIN -9223372036854775808
+#endif
+#ifndef LONG_MAX
+#define LONG_MAX 2147483647
+#endif
+#ifndef LONG_MIN
+#define LONG_MIN -2147483648
+#endif
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 5
+#endif
+#ifndef OPEN_MAX_CEIL
+#ifndef OPEN_MAX
+#define OPEN_MAX 256
+#endif
+#define OPEN_MAX_CEIL OPEN_MAX
+#endif
+#ifndef PTHREAD_STACK_MIN
+#define PTHREAD_STACK_MIN 4096
+#endif
+#ifndef PTRDIFF_MAX
+#define PTRDIFF_MAX 9223372036854775807
+#endif
+#ifndef PTRDIFF_MIN
+#define PTRDIFF_MIN -9223372036854775808
+#endif
+#ifndef SCHAR_MAX
+#define SCHAR_MAX 127
+#endif
+#ifndef SCHAR_MIN
+#define SCHAR_MIN -128
+#endif
+#ifndef SHRT_MIN
+#define SHRT_MIN -32768
+#endif
+#ifndef SIG_ATOMIC_MAX
+#define SIG_ATOMIC_MAX 2147483647
+#endif
+#ifndef SIG_ATOMIC_MIN
+#define SIG_ATOMIC_MIN -2147483648
+#endif
+#ifndef SIZE_MAX
+#ifndef UINT_MAX
+#define UINT_MAX 4294967295
+#endif
+#define SIZE_MAX UINT_MAX
+#endif
+#ifndef SSIZE_MAX
+#ifndef INT_MAX
+#define INT_MAX 2147483647
+#endif
+#define SSIZE_MAX INT_MAX
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+#ifndef UCHAR_MAX
+#define UCHAR_MAX 255
+#endif
+#ifndef ULLONG_MAX
+#define ULLONG_MAX 18446744073709551615
+#endif
+#ifndef ULONG_MAX
+#define ULONG_MAX 4294967295
+#endif
+#ifndef USHRT_MAX
+#define USHRT_MAX 65535
+#endif
+#ifndef WCHAR_MAX
+#define WCHAR_MAX 2147483647
+#endif
+#ifndef WCHAR_MIN
+#define WCHAR_MIN -2147483648
+#endif
+#ifndef WINT_MAX
+#define WINT_MAX 2147483647
+#endif
+#ifndef WINT_MIN
+#define WINT_MIN -2147483648
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_map.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_map.h
new file mode 100644
index 0000000000..6103ce9791
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_map.h
@@ -0,0 +1,438 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/map.c by iffe version 2007-04-04 : : */
+#ifndef _def_map_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_map_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+
+/*
+ * prototypes provided for standard interfaces hijacked
+ * by ast and mapped to _ast_* but already prototyped
+ * unmapped in native headers included by <ast_std.h>
+ */
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+
+#define _map_libc 1
+#undef basename
+#define basename _ast_basename
+#undef dirname
+#define dirname _ast_dirname
+#undef eaccess
+#define eaccess _ast_eaccess
+#undef execvpe
+#define execvpe _ast_execvpe
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+#undef fnmatch
+#define fnmatch _ast_fnmatch
+#undef fts_children
+#define fts_children _ast_fts_children
+#undef fts_close
+#define fts_close _ast_fts_close
+#undef fts_flags
+#define fts_flags _ast_fts_flags
+#undef fts_notify
+#define fts_notify _ast_fts_notify
+#undef fts_open
+#define fts_open _ast_fts_open
+#undef fts_read
+#define fts_read _ast_fts_read
+#undef fts_set
+#define fts_set _ast_fts_set
+#undef ftw
+#define ftw _ast_ftw
+#undef ftwalk
+#define ftwalk _ast_ftwalk
+#undef ftwflags
+#define ftwflags _ast_ftwflags
+#undef getcwd
+#define getcwd _ast_getcwd
+extern __MANGLE__ char* getcwd __PROTO__((char*, size_t));
+#undef getdate
+#define getdate _ast_getdate
+#undef getopt
+#define getopt _ast_getopt
+#undef getsubopt
+#define getsubopt _ast_getsubopt
+#undef getopt_long
+#define getopt_long _ast_getopt_long
+#undef getopt_long_only
+#define getopt_long_only _ast_getopt_long_only
+#undef getwd
+#define getwd _ast_getwd
+extern __MANGLE__ char* getwd __PROTO__((char*));
+#undef glob
+#define glob _ast_glob
+#undef globfree
+#define globfree _ast_globfree
+#undef memdup
+#define memdup _ast_memdup
+#undef memfatal
+#define memfatal _ast_memfatal
+#undef memhash
+#define memhash _ast_memhash
+#undef memsum
+#define memsum _ast_memsum
+#undef mkstemp
+#define mkstemp _ast_mkstemp
+extern __MANGLE__ int mkstemp __PROTO__((char*));
+#undef mktemp
+#define mktemp _ast_mktemp
+extern __MANGLE__ char* mktemp __PROTO__((char*));
+#undef mktime
+#define mktime _ast_mktime
+#undef nftw
+#define nftw _ast_nftw
+#undef optesc
+#define optesc _ast_optesc
+#undef optget
+#define optget _ast_optget
+#undef opthelp
+#define opthelp _ast_opthelp
+#undef optjoin
+#define optjoin _ast_optjoin
+#undef optstr
+#define optstr _ast_optstr
+#undef optusage
+#define optusage _ast_optusage
+#undef pathaccess
+#define pathaccess _ast_pathaccess
+#undef pathbin
+#define pathbin _ast_pathbin
+#undef pathcanon
+#define pathcanon _ast_pathcanon
+#undef pathcat
+#define pathcat _ast_pathcat
+#undef pathcd
+#define pathcd _ast_pathcd
+#undef pathcheck
+#define pathcheck _ast_pathcheck
+#undef pathexists
+#define pathexists _ast_pathexists
+#undef pathfind
+#define pathfind _ast_pathfind
+#undef pathgetlink
+#define pathgetlink _ast_pathgetlink
+#undef pathinclude
+#define pathinclude _ast_pathinclude
+#undef pathkey
+#define pathkey _ast_pathkey
+#undef pathnative
+#define pathnative _ast_pathnative
+#undef pathpath
+#define pathpath _ast_pathpath
+#undef pathposix
+#define pathposix _ast_pathposix
+#undef pathprobe
+#define pathprobe _ast_pathprobe
+#undef pathrepl
+#define pathrepl _ast_pathrepl
+#undef pathsetlink
+#define pathsetlink _ast_pathsetlink
+#undef pathshell
+#define pathshell _ast_pathshell
+#undef pathstat
+#define pathstat _ast_pathstat
+#undef pathtemp
+#define pathtemp _ast_pathtemp
+#undef pathtmp
+#define pathtmp _ast_pathtmp
+#undef procclose
+#define procclose _ast_procclose
+#undef procfree
+#define procfree _ast_procfree
+#undef procopen
+#define procopen _ast_procopen
+#undef procrun
+#define procrun _ast_procrun
+#undef putenv
+#define putenv _ast_putenv
+#undef re_comp
+#define re_comp _ast_re_comp
+#undef re_exec
+#define re_exec _ast_re_exec
+#undef realpath
+#define realpath _ast_realpath
+extern __MANGLE__ char* realpath __PROTO__((const char*, char*));
+#undef regaddclass
+#define regaddclass _ast_regaddclass
+#undef regalloc
+#define regalloc _ast_regalloc
+#undef regcache
+#define regcache _ast_regcache
+#undef regclass
+#define regclass _ast_regclass
+#undef regcmp
+#define regcmp _ast_regcmp
+#undef regcollate
+#define regcollate _ast_regcollate
+#undef regcomb
+#define regcomb _ast_regcomb
+#undef regcomp
+#define regcomp _ast_regcomp
+#undef regdecomp
+#define regdecomp _ast_regdecomp
+#undef regdup
+#define regdup _ast_regdup
+#undef regerror
+#define regerror _ast_regerror
+#undef regex
+#define regex _ast_regex
+#undef regexec
+#define regexec _ast_regexec
+#undef regfatal
+#define regfatal _ast_regfatal
+#undef regfatalpat
+#define regfatalpat _ast_regfatalpat
+#undef regfree
+#define regfree _ast_regfree
+#undef regncomp
+#define regncomp _ast_regncomp
+#undef regnexec
+#define regnexec _ast_regnexec
+#undef regrecord
+#define regrecord _ast_regrecord
+#undef regrexec
+#define regrexec _ast_regrexec
+#undef regstat
+#define regstat _ast_regstat
+#undef regsub
+#define regsub _ast_regsub
+#undef regsubcomp
+#define regsubcomp _ast_regsubcomp
+#undef regsubexec
+#define regsubexec _ast_regsubexec
+#undef regsubflags
+#define regsubflags _ast_regsubflags
+#undef regsubfree
+#define regsubfree _ast_regsubfree
+#undef remove
+#define remove _ast_remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#undef resolvepath
+#define resolvepath _ast_resolvepath
+extern __MANGLE__ char* resolvepath __PROTO__((const char*, char*, size_t));
+#undef setenv
+#define setenv _ast_setenv
+extern __MANGLE__ int setenv __PROTO__((const char*, const char*, int));
+#undef setenviron
+#define setenviron _ast_setenviron
+#undef sigcritical
+#define sigcritical _ast_sigcritical
+#undef signal
+#define signal _ast_signal
+#undef sigunblock
+#define sigunblock _ast_sigunblock
+#undef stracmp
+#define stracmp _ast_stracmp
+#undef strcopy
+#define strcopy _ast_strcopy
+#undef strelapsed
+#define strelapsed _ast_strelapsed
+#undef stresc
+#define stresc _ast_stresc
+#undef streval
+#define streval _ast_streval
+#undef strexpr
+#define strexpr _ast_strexpr
+#undef strftime
+#define strftime _ast_strftime
+#undef strgid
+#define strgid _ast_strgid
+#undef strgrpmatch
+#define strgrpmatch _ast_strgrpmatch
+#undef strhash
+#define strhash _ast_strhash
+#undef strkey
+#define strkey _ast_strkey
+#undef strlcat
+#define strlcat _ast_strlcat
+extern __MANGLE__ size_t strlcat __PROTO__((char*, const char*, size_t));
+#undef strlcpy
+#define strlcpy _ast_strlcpy
+extern __MANGLE__ size_t strlcpy __PROTO__((char*, const char*, size_t));
+#undef strlook
+#define strlook _ast_strlook
+#undef strmatch
+#define strmatch _ast_strmatch
+#undef strmode
+#define strmode _ast_strmode
+#undef strnacmp
+#define strnacmp _ast_strnacmp
+#undef strncopy
+#define strncopy _ast_strncopy
+#undef strntod
+#define strntod _ast_strntod
+#undef strntol
+#define strntol _ast_strntol
+#undef strntold
+#define strntold _ast_strntold
+#undef strntoll
+#define strntoll _ast_strntoll
+#undef strntoul
+#define strntoul _ast_strntoul
+#undef strntoull
+#define strntoull _ast_strntoull
+#undef stropt
+#define stropt _ast_stropt
+#undef strperm
+#define strperm _ast_strperm
+#undef strpsearch
+#define strpsearch _ast_strpsearch
+#undef strptime
+#define strptime _ast_strptime
+#undef strsearch
+#define strsearch _ast_strsearch
+#undef strsort
+#define strsort _ast_strsort
+#undef strsubmatch
+#define strsubmatch _ast_strsubmatch
+#undef strsum
+#define strsum _ast_strsum
+#undef strtape
+#define strtape _ast_strtape
+#undef strtoip4
+#define strtoip4 _ast_strtoip4
+#undef strton
+#define strton _ast_strton
+#undef strtonll
+#define strtonll _ast_strtonll
+#undef struid
+#define struid _ast_struid
+#undef struniq
+#define struniq _ast_struniq
+#undef system
+#define system _ast_system
+extern __MANGLE__ int system __PROTO__((const char*));
+#undef tempnam
+#define tempnam _ast_tempnam
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+#undef tmpnam
+#define tmpnam _ast_tmpnam
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+#undef touch
+#define touch _ast_touch
+#undef wordexp
+#define wordexp _ast_wordexp
+#undef wordfree
+#define wordfree _ast_wordfree
+#undef unsetenv
+#define unsetenv _ast_unsetenv
+
+/* cannot override local malloc */
+#define _map_malloc 1
+#undef calloc
+#define calloc _ast_calloc
+extern __MANGLE__ __V_* calloc __PROTO__((size_t, size_t));
+#undef cfree
+#define cfree _ast_cfree
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+#undef free
+#define free _ast_free
+extern __MANGLE__ void free __PROTO__((__V_*));
+#undef malloc
+#define malloc _ast_malloc
+extern __MANGLE__ __V_* malloc __PROTO__((size_t));
+#undef memalign
+#define memalign _ast_memalign
+extern __MANGLE__ __V_* memalign __PROTO__((size_t, size_t));
+#undef realloc
+#define realloc _ast_realloc
+extern __MANGLE__ __V_* realloc __PROTO__((__V_*, size_t));
+#undef strdup
+#define strdup _ast_strdup
+extern __MANGLE__ char* strdup __PROTO__((const char*));
+#undef valloc
+#define valloc _ast_valloc
+extern __MANGLE__ __V_* valloc __PROTO__((size_t));
+#undef strtol
+#define strtol _ast_strtol
+#undef strtoul
+#define strtoul _ast_strtoul
+#undef strtoll
+#define strtoll _ast_strtoll
+#undef strtoull
+#define strtoull _ast_strtoull
+#undef strtod
+#define strtod _ast_strtod
+#undef strtold
+#define strtold _ast_strtold
+extern __MANGLE__ long strtol __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned long strtoul __PROTO__((const char*, char**, int));
+extern __MANGLE__ double strtod __PROTO__((const char*, char**));
+#if !_UWIN
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
+extern __MANGLE__ _ast_fltmax_t strtold __PROTO__((const char*, char**));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+extern __MANGLE__ _ast_intmax_t strtoll __PROTO__((const char*, char**, int));
+extern __MANGLE__ unsigned _ast_intmax_t strtoull __PROTO__((const char*, char**, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_mmap.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_mmap.h
new file mode 100644
index 0000000000..47b8dc23b2
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_mmap.h
@@ -0,0 +1,26 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/mmap by iffe version 2007-04-04 : : */
+#ifndef _def_mmap_ast
+#define _def_mmap_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _sys_mman 1 /* #include <sys/mman.h> ok */
+#define _lib_mmap 1 /* standard mmap interface that works */
+#define _lib_mmap64 1 /* mmap64 interface and implementation work */
+#define _mmap_anon 1 /* use mmap MAP_ANON to get raw memory */
+#define _mmap_devzero 1 /* use mmap on /dev/zero to get raw memory */
+
+/* some systems get it wrong but escape concise detection */
+#ifndef _NO_MMAP
+#if __CYGWIN__
+#define _NO_MMAP 1
+#endif
+#endif
+
+#if _NO_MMAP
+#undef _lib_mmap
+#undef _lib_mmap64
+#undef _mmap_anon
+#undef _mmap_devzero
+#undef _mmap_worthy
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_mode.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_mode.h
new file mode 100644
index 0000000000..58c29a7ff5
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_mode.h
@@ -0,0 +1,14 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/mode.c by iffe version 2007-04-04 : : */
+#ifndef _def_mode_ast
+#define _def_mode_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define S_ITYPE(m) ((m)&S_IFMT)
+
+#define S_IPERM (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
+
+#define _S_IDPERM 1
+#define _S_IDTYPE 1
+
+#define BUFFERSIZE 8192
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_nl_types.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_nl_types.h
new file mode 100644
index 0000000000..08f46d7dee
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_nl_types.h
@@ -0,0 +1,102 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/nl_types by iffe version 2007-04-04 : : */
+
+#ifndef _def_nl_types_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_nl_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_catopen 1 /* catopen() in default lib(s) */
+#define _lib_nl_langinfo 1 /* nl_langinfo() in default lib(s) */
+#define _hdr_nl_types 1 /* #include <nl_types.h> ok */
+#define _hdr_langinfo 1 /* #include <langinfo.h> ok */
+#define _nxt_nl_types <../include/nl_types.h> /* include path for the native <nl_types.h> */
+#define _nxt_nl_types_str "../include/nl_types.h" /* include string for the native <nl_types.h> */
+#include <limits.h>
+#include <../include/nl_types.h> /* the native nl_types.h */
+
+#undef NL_SETMAX
+#define NL_SETMAX 1023
+#undef NL_MSGMAX
+#define NL_MSGMAX 32767
+#undef nl_catd
+#define nl_catd _ast_nl_catd
+#undef catopen
+#define catopen _ast_catopen
+#undef catgets
+#define catgets _ast_catgets
+#undef catclose
+#define catclose _ast_catclose
+
+typedef __V_* nl_catd;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ nl_catd catopen __PROTO__((const char*, int));
+extern __MANGLE__ char* catgets __PROTO__((nl_catd, int, int, const char*));
+extern __MANGLE__ int catclose __PROTO__((nl_catd));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_param.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_param.h
new file mode 100644
index 0000000000..4a9644522d
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_param.h
@@ -0,0 +1,9 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/param.sh by iffe version 2007-04-04 : : */
+#ifndef _def_param_ast
+#define _def_param_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#include <sys/param.h>
+#ifndef S_IFDIR
+#include <sys/stat.h>
+#endif
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_standards.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_standards.h
new file mode 100644
index 0000000000..f625ff6f49
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_standards.h
@@ -0,0 +1,28 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/standards by iffe version 2007-04-04 : : */
+#ifndef _def_standards_ast
+#define _def_standards_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* _ALL_SOURCE & _ISOC99_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works */
+#ifndef _ALL_SOURCE
+#define _ALL_SOURCE 1
+#endif
+#ifndef _ISOC99_SOURCE
+#define _ISOC99_SOURCE 1
+#endif
+#ifndef _POSIX_SOURCE
+#define _POSIX_SOURCE 1
+#endif
+#ifndef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 21000101L
+#endif
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 9900
+#endif
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#ifndef __EXTENSIONS__
+#define __EXTENSIONS__ 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_stdio.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_stdio.h
new file mode 100644
index 0000000000..0a1824b6fa
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_stdio.h
@@ -0,0 +1,579 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/stdio by iffe version 2007-04-04 : : */
+
+#ifndef _SFSTDIO_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _SFSTDIO_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define __FILE_typedef 1
+#define _FILE_DEFINED 1
+#define _FILE_defined 1
+#define _FILEDEFED 1
+
+#ifndef __FILE_TAG
+#define __FILE_TAG _sfio_s
+#endif
+
+#undef FILE
+#undef _FILE
+#undef fpos_t
+#undef fpos64_t
+
+typedef struct _sfio_s _sfio_FILE;
+
+#define FILE _sfio_FILE
+#define _FILE FILE
+
+#if !defined(__FILE) && !__CYGWIN__
+#undef __FILE
+#define __FILE FILE
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define BUFSIZ SF_BUFSIZE
+
+#else
+
+#ifndef BUFSIZ
+#define BUFSIZ 8192
+#endif
+
+#ifndef EOF
+#define EOF (-1)
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif
+
+#include <ast_std.h>
+
+#include <sfio_s.h>
+
+#if __cplusplus
+#define _sf_(f) (f)
+#else
+#define _sf_(f) ((struct _sfio_s*)(f))
+#endif
+
+#define _SF_EOF 0000200
+#define _SF_ERROR 0000400
+
+#endif
+
+#ifdef _NO_LARGEFILE64_SOURCE
+#undef _LARGEFILE64_SOURCE
+#endif
+
+#ifdef _LARGEFILE64_SOURCE
+#undef off_t
+#endif
+
+#define fpos_t _ast_fpos_t
+#if _typ_int64_t
+#define fpos64_t _ast_fpos_t
+#endif
+
+typedef struct _ast_fpos_s
+{
+ intmax_t _sf_offset;
+ unsigned char _sf_state[64 - sizeof(intmax_t)];
+} _ast_fpos_t;
+
+#define _base _data
+#define _ptr _next
+#define _IOFBF 0
+#define _IONBF 1
+#define _IOLBF 2
+
+#if defined(__cplusplus) && defined(__THROW) && !defined(_UWIN)
+
+#undef FILE
+#define FILE FILE
+typedef struct _sfio_s FILE;
+
+#undef strerror
+extern __MANGLE__ char* strerror(int) __THROW;
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#endif
+
+#ifndef FILENAME_MAX
+#define FILENAME_MAX 1024
+#endif
+#ifndef FOPEN_MAX
+#define FOPEN_MAX 20
+#endif
+#ifndef TMP_MAX
+#define TMP_MAX 17576
+#endif
+
+#define _doprnt _ast_doprnt
+#define _doscan _ast_doscan
+#define asprintf _ast_asprintf
+#define clearerr _ast_clearerr
+#define fclose _ast_fclose
+#define fdopen _ast_fdopen
+#define fflush _ast_fflush
+#define fgetc _ast_fgetc
+#define fgetpos _ast_fgetpos
+#define fgetpos64 _ast_fgetpos64
+#define fgets _ast_fgets
+#define fopen _ast_fopen
+#define fprintf _ast_fprintf
+#define fpurge _ast_fpurge
+#define fputs _ast_fputs
+#define fread _ast_fread
+#define freopen _ast_freopen
+#define fscanf _ast_fscanf
+#define fseek _ast_fseek
+#define fseek64 _ast_fseek64
+#define fseeko _ast_fseeko
+#define fseeko64 _ast_fseeko64
+#define fsetpos _ast_fsetpos
+#define fsetpos64 _ast_fsetpos64
+#define ftell _ast_ftell
+#define ftell64 _ast_ftell64
+#define ftello _ast_ftello
+#define ftello64 _ast_ftello64
+#define fwrite _ast_fwrite
+#define gets _ast_gets
+#define getw _ast_getw
+#define pclose _ast_pclose
+#define popen _ast_popen
+#define printf _ast_printf
+#define puts _ast_puts
+#define putw _ast_putw
+#define rewind _ast_rewind
+#define scanf _ast_scanf
+#define setbuf _ast_setbuf
+#undef setbuffer
+#define setbuffer _ast_setbuffer
+#define setlinebuf _ast_setlinebuf
+#define setvbuf _ast_setvbuf
+#define snprintf _ast_snprintf
+#define sprintf _ast_sprintf
+#define sscanf _ast_sscanf
+#define tmpfile _ast_tmpfile
+#define ungetc _ast_ungetc
+#define vasprintf _ast_vasprintf
+#define vfprintf _ast_vfprintf
+#define vfscanf _ast_vfscanf
+#define vprintf _ast_vprintf
+#define vscanf _ast_vscanf
+#define vsnprintf _ast_vsnprintf
+#define vsprintf _ast_vsprintf
+#define vsscanf _ast_vsscanf
+#define fcloseall _ast_fcloseall
+#define fmemopen _ast_fmemopen
+#define __getdelim _ast___getdelim
+#define getdelim _ast_getdelim
+#define getline _ast_getline
+#define clearerr_unlocked _ast_clearerr_unlocked
+#define feof_unlocked _ast_feof_unlocked
+#define ferror_unlocked _ast_ferror_unlocked
+#define fflush_unlocked _ast_fflush_unlocked
+#define fgetc_unlocked _ast_fgetc_unlocked
+#define fgets_unlocked _ast_fgets_unlocked
+#define fileno_unlocked _ast_fileno_unlocked
+#define fputc_unlocked _ast_fputc_unlocked
+#define fputs_unlocked _ast_fputs_unlocked
+#define fread_unlocked _ast_fread_unlocked
+#define fwrite_unlocked _ast_fwrite_unlocked
+#define getc_unlocked _ast_getc_unlocked
+#define getchar_unlocked _ast_getchar_unlocked
+#define putc_unlocked _ast_putc_unlocked
+#define putchar_unlocked _ast_putchar_unlocked
+
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:initial
+#endif
+#ifndef P_tmpdir
+#define P_tmpdir "/var/tmp/" /*NOCATLITERAL*/
+#endif
+#ifndef L_ctermid
+#define L_ctermid 9
+#endif
+#ifndef L_tmpnam
+#define L_tmpnam 25
+#endif
+#if defined(__STDPP__directive) && defined(__STDPP__initial)
+__STDPP__directive pragma pp:noinitial
+#endif
+#if defined(__cplusplus) && defined(__THROW)
+extern __MANGLE__ char* ctermid(char*) __THROW;
+#else
+extern __MANGLE__ char* ctermid __PROTO__((char*));
+#endif
+extern __MANGLE__ char* tmpnam __PROTO__((char*));
+extern __MANGLE__ char* tempnam __PROTO__((const char*, const char*));
+extern __MANGLE__ void perror __PROTO__((const char*));
+#ifndef _AST_STD_H
+#ifndef remove
+extern __MANGLE__ int remove __PROTO__((const char*));
+#endif
+#ifndef rename
+extern __MANGLE__ int rename __PROTO__((const char*, const char*));
+#endif
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _doprnt __PROTO__((const char*, va_list, FILE*));
+extern __MANGLE__ int _doscan __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int asprintf __PROTO__((char**, const char*, ...));
+extern __MANGLE__ int clearerr __PROTO__((FILE*));
+extern __MANGLE__ int fclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* fdopen __PROTO__((int, const char*));
+extern __MANGLE__ int feof __PROTO__((FILE*));
+extern __MANGLE__ int ferror __PROTO__((FILE*));
+extern __MANGLE__ int fflush __PROTO__((FILE*));
+extern __MANGLE__ int fgetc __PROTO__((FILE*));
+extern __MANGLE__ int fgetpos __PROTO__((FILE*, fpos_t*));
+extern __MANGLE__ char* fgets __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno __PROTO__((FILE*));
+extern __MANGLE__ FILE* fopen __PROTO__((const char*, const char*));
+extern __MANGLE__ int fprintf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fpurge __PROTO__((FILE*));
+extern __MANGLE__ int fputc __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs __PROTO__((const char*, FILE*));
+extern __MANGLE__ ssize_t fread __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ FILE* freopen __PROTO__((const char*, const char*, FILE*));
+extern __MANGLE__ int fscanf __PROTO__((FILE*, const char*, ...));
+extern __MANGLE__ int fseek __PROTO__((FILE*, long, int));
+extern __MANGLE__ int fseeko __PROTO__((FILE*, off_t, int));
+extern __MANGLE__ int fsetpos __PROTO__((FILE*, const fpos_t*));
+extern __MANGLE__ long ftell __PROTO__((FILE*));
+extern __MANGLE__ off_t ftello __PROTO__((FILE*));
+extern __MANGLE__ ssize_t fwrite __PROTO__((const __V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc __PROTO__((FILE*));
+extern __MANGLE__ int getchar __PROTO__((void));
+extern __MANGLE__ char* gets __PROTO__((char*));
+extern __MANGLE__ int getw __PROTO__((FILE*));
+extern __MANGLE__ int pclose __PROTO__((FILE*));
+extern __MANGLE__ FILE* popen __PROTO__((const char*, const char*));
+extern __MANGLE__ int printf __PROTO__((const char*, ...));
+extern __MANGLE__ int putc __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar __PROTO__((int));
+extern __MANGLE__ int puts __PROTO__((const char*));
+extern __MANGLE__ int putw __PROTO__((int, FILE*));
+extern __MANGLE__ void rewind __PROTO__((FILE*));
+extern __MANGLE__ int scanf __PROTO__((const char*, ...));
+extern __MANGLE__ void setbuf __PROTO__((FILE*, char*));
+extern __MANGLE__ int setbuffer __PROTO__((FILE*, char*, int));
+extern __MANGLE__ int setlinebuf __PROTO__((FILE*));
+extern __MANGLE__ int setvbuf __PROTO__((FILE*, char*, int, size_t));
+extern __MANGLE__ int snprintf __PROTO__((char*, int, const char*, ...));
+extern __MANGLE__ int sprintf __PROTO__((char*, const char*, ...));
+extern __MANGLE__ int sscanf __PROTO__((const char*, const char*, ...));
+extern __MANGLE__ FILE* tmpfile __PROTO__((void));
+extern __MANGLE__ int ungetc __PROTO__((int, FILE*));
+extern __MANGLE__ int vasprintf __PROTO__((char**, const char*, va_list));
+extern __MANGLE__ int vfprintf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vfscanf __PROTO__((FILE*, const char*, va_list));
+extern __MANGLE__ int vprintf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vscanf __PROTO__((const char*, va_list));
+extern __MANGLE__ int vsnprintf __PROTO__((char*, int, const char*, va_list));
+extern __MANGLE__ int vsprintf __PROTO__((char*, const char*, va_list));
+extern __MANGLE__ int vsscanf __PROTO__((const char*, const char*, va_list));
+
+#if _typ_int64_t
+
+extern __MANGLE__ int fgetpos64 __PROTO__((FILE*, fpos64_t*));
+extern __MANGLE__ int fsetpos64 __PROTO__((FILE*, const fpos64_t*));
+extern __MANGLE__ int fseek64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int fseeko64 __PROTO__((FILE*, int64_t, int));
+extern __MANGLE__ int64_t ftell64 __PROTO__((FILE*));
+extern __MANGLE__ int64_t ftello64 __PROTO__((FILE*));
+
+#ifdef _LARGEFILE64_SOURCE
+
+#undef fpos_t
+#undef off_t
+#undef fgetpos
+#undef fsetpos
+#undef fseek
+#undef fseeko
+#undef ftell
+#undef ftello
+
+#define fpos_t fpos64_t
+#if _typ_off64_t
+#define off_t off64_t
+#else
+#define off_t int64_t
+#endif
+
+#define fgetpos fgetpos64
+#define fsetpos fsetpos64
+#define fseek fseek64
+#define fseeko fseeko64
+#define ftell ftell64
+#define ftello ftello64
+
+#endif
+
+#endif
+
+extern __MANGLE__ void clearerr_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int feof_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int ferror_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fflush_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fgetc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ char* fgets_unlocked __PROTO__((char*, int, FILE*));
+extern __MANGLE__ int fileno_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int fputc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int fputs_unlocked __PROTO__((char*, FILE*));
+extern __MANGLE__ size_t fread_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ size_t fwrite_unlocked __PROTO__((__V_*, size_t, size_t, FILE*));
+extern __MANGLE__ int getc_unlocked __PROTO__((FILE*));
+extern __MANGLE__ int getchar_unlocked __PROTO__((void));
+extern __MANGLE__ int putc_unlocked __PROTO__((int, FILE*));
+extern __MANGLE__ int putchar_unlocked __PROTO__((int));
+
+#ifdef _USE_GNU
+
+extern __MANGLE__ int fcloseall __PROTO__((void));
+extern __MANGLE__ FILE* fmemopen __PROTO__((__V_*, size_t, const char*));
+extern __MANGLE__ ssize_t __getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getdelim __PROTO__((char**, size_t*, int, FILE*));
+extern __MANGLE__ ssize_t getline __PROTO__((char**, size_t*, FILE*));
+
+#endif
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_DLL && _DLL_INDIRECT_DATA
+
+#define stdin ((FILE*)_ast_dll->_ast_stdin)
+#define stdout ((FILE*)_ast_dll->_ast_stdout)
+#define stderr ((FILE*)_ast_dll->_ast_stderr)
+
+#else
+
+#define stdin (&_Sfstdin)
+#define stdout (&_Sfstdout)
+#define stderr (&_Sfstderr)
+
+#endif
+
+#if defined(_AST_H) || defined(_SFIO_H)
+
+#define feof(f) sfeof(f)
+#define ferror(f) sferror(f)
+#define fileno(f) sffileno(f)
+#define fputc(c,f) sfputc(f,c)
+#define getc(f) sfgetc(f)
+#define getchar() sfgetc(sfstdin)
+#define putc(c,f) sfputc(f,c)
+#define putchar(c) sfputc(sfstdout,c)
+
+#else
+
+#if !_UWIN
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+#endif
+
+extern __MANGLE__ FILE _Sfstdin;
+extern __MANGLE__ FILE _Sfstdout;
+extern __MANGLE__ FILE _Sfstderr;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#define feof(f) (_sf_(f)->_flags&_SF_EOF)
+#define ferror(f) (_sf_(f)->_flags&_SF_ERROR)
+#define fileno(f) (_sf_(f)->_file)
+#define fputc(c,f) (_sf_(f)->_next>=_sf_(f)->_endw?_sfflsbuf(_sf_(f),(int)((unsigned char)(c))):(int)(*_sf_(f)->_next++=(unsigned char)(c)))
+#define getc(f) (_sf_(f)->_next>=_sf_(f)->_endr?_sffilbuf(_sf_(f),0):(int)(*_sf_(f)->_next++))
+#define getchar() getc(stdin)
+#define putc(c,f) fputc(c,f)
+#define putchar(c) fputc(c,stdout)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _sffilbuf __PROTO__((FILE*, int));
+extern __MANGLE__ int _sfflsbuf __PROTO__((FILE*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_sys.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_sys.h
new file mode 100644
index 0000000000..8b3d838a49
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_sys.h
@@ -0,0 +1,151 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/sys by iffe version 2007-04-04 : : */
+
+#ifndef _AST_SYS_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _AST_SYS_H 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#if __mips == 2 && !defined(_NO_LARGEFILE64_SOURCE)
+#define _NO_LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_NO_LARGEFILE64_SOURCE) && _typ_off64_t && _lib_lseek64 && _lib_stat64
+#if !defined(_LARGEFILE64_SOURCE)
+#define _LARGEFILE64_SOURCE 1
+#endif
+#if !defined(_LARGEFILE_SOURCE)
+#define _LARGEFILE_SOURCE 1
+#endif
+#else
+#undef _LARGEFILE64_SOURCE
+#undef _LARGEFILE_SOURCE
+#undef _typ_off64_t
+#undef _typ_struct_dirent64
+#undef _lib_creat64
+#undef _lib_fstat64
+#undef _lib_fstatvfs64
+#undef _lib_ftruncate64
+#undef _lib_lseek64
+#undef _lib_lstat64
+#undef _lib_mmap64
+#undef _lib_open64
+#undef _lib_readdir64
+#undef _lib_stat64
+#undef _lib_statvfs64
+#undef _lib_truncate64
+#endif
+#if defined(__STDC__) && !defined(__USE_FIXED_PROTOTYPES__)
+#define __USE_FIXED_PROTOTYPES__ 1 /* kick gcc out of the past */
+#endif
+#include <stdlib.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <locale.h>
+#include <sys/localedef.h>
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _typ_dev_t 1 /* dev_t is a type */
+#define _typ_nlink_t 1 /* nlink_t is a type */
+#define _typ_gid_t 1 /* gid_t is a type */
+#define _typ_mode_t 1 /* mode_t is a type */
+#define _typ_uid_t 1 /* uid_t is a type */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _typ_wchar_t 1 /* wchar_t is a type */
+#define _typ_pid_t 1 /* pid_t is a type */
+#define _typ_ssize_t 1 /* ssize_t is a type */
+#define _typ_wint_t 1 /* wint_t is a type */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _typ_socklen_t 1 /* socklen_t is a type */
+#define _typ_size_t 1 /* size_t is a type */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_ino_t 1 /* ino_t is a type */
+#define _typ_off_t 1 /* off_t is a type */
+#define _typ_ptrdiff_t 1 /* ptrdiff_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#define _typ_div_t 1 /* div_t is a type */
+#define _typ_ldiv_t 1 /* ldiv_t is a type */
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+extern __MANGLE__ void cfree __PROTO__((__V_*));
+extern __MANGLE__ int eaccess __PROTO__((const char*, int));
+extern __MANGLE__ int execvpe __PROTO__((const char*, char* const[], char* const[]));
+extern __MANGLE__ __V_* pvalloc __PROTO__((size_t));
+extern __MANGLE__ pid_t spawnveg __PROTO__((const char*, char* const[], char* const[], pid_t));
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#if !defined(va_start)
+#if defined(__STDARG__)
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_time.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_time.h
new file mode 100644
index 0000000000..89db712e51
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_time.h
@@ -0,0 +1,83 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/time by iffe version 2007-04-04 : : */
+
+#ifndef _def_time_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_time_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_nanosleep 1 /* nanosleep() in default lib(s) */
+#define _lib_usleep 1 /* usleep() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_clock_t 1 /* clock_t is a type */
+#define _typ_time_t 1 /* time_t is a type */
+#include <sys/time.h>
+
+#include <sys/times.h>
+
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC CLK_TCK
+#endif
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_tty.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_tty.h
new file mode 100644
index 0000000000..fee4db4ea4
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_tty.h
@@ -0,0 +1,134 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/tty by iffe version 2007-04-04 : : */
+#ifndef _def_tty_ast
+#define _def_tty_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_termios 1 /* #include <termios.h> ok */
+#define _hdr_termio 1 /* #include <termio.h> ok */
+#define _hdr_sgtty 1 /* #include <sgtty.h> ok */
+#define _sys_termios 1 /* #include <sys/termios.h> ok */
+#define _sys_termio 1 /* #include <sys/termio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _lib_tcgetattr 1 /* tcgetattr() in default lib(s) */
+#define _lib_tcgetpgrp 1 /* tcgetpgrp() in default lib(s) */
+#define _mac__POSIX_VDISABLE 1 /* _POSIX_VDISABLE is a macro */
+
+#ifdef _hdr_termios
+# if _mac__POSIX_VDISABLE
+# undef _POSIX_VDISABLE
+# endif
+# include <termios.h>
+#else
+# if defined(_sys_termios) && defined(_lib_tcgetattr)
+# include <sys/termios.h>
+# define _hdr_termios 1
+# else
+# undef _sys_termios
+# endif /* _sys_termios */
+#endif /* _hdr_termios */
+
+#ifdef _hdr_termios
+# undef _hdr_sgtty
+# undef tcgetattr
+# undef tcsetattr
+# undef tcgetpgrp
+# undef tcsetpgrp
+# undef cfgetospeed
+# ifndef TCSANOW
+# define TCSANOW TCSETS
+# define TCSADRAIN TCSETSW
+# define TCSAFLUSH TCSETSF
+# endif /* TCSANOW */
+ /* The following corrects bugs in some implementations */
+# if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
+# define TCSAFLUSH TCSADFLUSH
+# endif /* TCSADFLUSH */
+# ifndef _lib_tcgetattr
+# undef tcgetattr
+# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
+# undef tcsetattr
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# undef cfgetospeed
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# endif /* _lib_tcgetattr */
+# undef TIOCGETC
+#else
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfgetispeed(tp) ((tp)->c_cflag & CBAUD)
+# define cfsetispeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# define cfsetospeed(tp,val) ((tp)->c_cflag &=~ CBAUD,(tp)->c_cflag|=(val))
+# ifdef _hdr_termio
+# include <termio.h>
+# else
+# ifdef _sys_termio
+# include <sys/termio.h>
+# define _hdr_termio 1
+# endif /* _sys_termio */
+# endif /* _hdr_termio */
+# ifdef _hdr_termio
+# define termios termio
+# undef TIOCGETC
+# define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+
+# ifdef _sys_bsdtty
+# include <sys/bsdtty.h>
+# endif /* _sys_bsdtty */
+# else
+# ifdef _hdr_sgtty
+# include <sgtty.h>
+# ifndef LPENDIN
+# ifdef _sys_nttyio
+# include <sys/nttyio.h>
+# endif /* _sys_nttyio */
+# endif /* LPENDIN */
+# define termios sgttyb
+# ifdef TIOCSETN
+# undef TCSETAW
+# endif /* TIOCSETN */
+# ifdef TIOCGETP
+# define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# else
+# define tcgetattr(fd,tty) gtty(fd, tty)
+# define tcsetattr(fd,action,tty) stty(fd, tty)
+# endif /* TIOCGETP */
+# else
+# ifdef _sys_ttyio
+# include <sys/ttyio.h>
+# endif
+# endif /* _hdr_sgtty */
+# endif /* hdr_termio */
+
+# ifndef TCSANOW
+# ifdef TCSETAW
+# define TCSANOW TCSETA
+# define TCSAFLUSH TCSETAF
+# else
+# ifdef TIOCSETN
+# define TCSANOW TIOCSETN
+# define TCSADRAIN TIOCSETN
+# define TCSAFLUSH TIOCSETP
+# endif /* TIOCSETN */
+# endif /* TCSETAW */
+# endif /* TCSANOW */
+#endif /* _hdr_termios */
+
+/* set ECHOCTL if driver can echo control charaters as ^c */
+#ifdef LCTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LCTLECH
+# endif /* !ECHOCTL */
+#endif /* LCTLECH */
+#ifdef LNEW_CTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LNEW_CTLECH
+# endif /* !ECHOCTL */
+#endif /* LNEW_CTLECH */
+#ifdef LNEW_PENDIN
+# ifndef PENDIN
+# define PENDIN LNEW_PENDIN
+# endif /* !PENDIN */
+#endif /* LNEW_PENDIN */
+
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_types.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_types.h
new file mode 100644
index 0000000000..343b5954a0
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_types.h
@@ -0,0 +1,5 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_types_ast
+#define _def_types_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_vfork.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_vfork.h
new file mode 100644
index 0000000000..975726cf26
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_vfork.h
@@ -0,0 +1,68 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/vfork by iffe version 2007-04-04 : : */
+
+#ifndef _def_vfork_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_vfork_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+extern __MANGLE__ pid_t vfork __PROTO__((void));
+#pragma unknown_control_flow(vfork)
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_wait.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_wait.h
new file mode 100644
index 0000000000..69a5c225da
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_wait.h
@@ -0,0 +1,11 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/wait by iffe version 2007-04-04 : : */
+#ifndef _def_wait_ast
+#define _def_wait_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _lib_wait 1 /* wait() in default lib(s) */
+#define _lib_wait3 1 /* wait3() in default lib(s) */
+#define _lib_wait4 1 /* wait4() in default lib(s) */
+#define _lib_waitpid 1 /* waitpid() in default lib(s) */
+#define _sys_wait 1 /* #include <sys/wait.h> ok */
+#define _ok_wif 1 /* posix wait macros ok */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/ast_wchar.h b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_wchar.h
new file mode 100644
index 0000000000..c667a53fa1
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/ast_wchar.h
@@ -0,0 +1,187 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/wchar by iffe version 2007-04-04 : : */
+
+#ifndef _def_wchar_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_wchar_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_stdio 1 /* #include <stdio.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _lib_mbstowcs 1 /* mbstowcs() in default lib(s) */
+#define _lib_wctomb 1 /* wctomb() in default lib(s) */
+#define _lib_wcrtomb 1 /* wcrtomb() in default lib(s) */
+#define _lib_wcslen 1 /* wcslen() in default lib(s) */
+#define _lib_wcstombs 1 /* wcstombs() in default lib(s) */
+#define _lib_wcwidth 1 /* wcwidth() in default lib(s) */
+#define _lib_towlower 1 /* towlower() in default lib(s) */
+#define _lib_towupper 1 /* towupper() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _typ_mbstate_t 1 /* mbstate_t is a type */
+#define _nxt_wchar <../include/wchar.h> /* include path for the native <wchar.h> */
+#define _nxt_wchar_str "../include/wchar.h" /* include string for the native <wchar.h> */
+#ifndef _SFSTDIO_H
+#include <ast_common.h>
+#include <stdio.h>
+#endif
+#if _hdr_wchar && defined(_nxt_wchar)
+#include <../include/wchar.h> /* the native wchar.h */
+#endif
+#if _hdr_wctype
+#include <wctype.h>
+#endif
+
+#ifndef WEOF
+#define WEOF (-1)
+#endif
+
+#undef fgetwc
+#undef fgetws
+#undef fputwc
+#undef fputws
+#undef getwc
+#undef getwchar
+#undef getws
+#undef putwc
+#undef putwchar
+#undef ungetwc
+
+#define fgetwc _ast_fgetwc
+#define fgetws _ast_fgetws
+#define fputwc _ast_fputwc
+#define fputws _ast_fputws
+#define fwide _ast_fwide
+#define fwprintf _ast_fwprintf
+#define fwscanf _ast_fwscanf
+#define getwc _ast_getwc
+#define getwchar _ast_getwchar
+#define getws _ast_getws
+#define putwc _ast_putwc
+#define putwchar _ast_putwchar
+#define swprintf _ast_swprintf
+#define swscanf _ast_swscanf
+#define ungetwc _ast_ungetwc
+#define vfwprintf _ast_vfwprintf
+#define vfwscanf _ast_vfwscanf
+#define vswprintf _ast_vswprintf
+#define vswscanf _ast_vswscanf
+#define vwprintf _ast_vwprintf
+#define vwscanf _ast_vwscanf
+#define wprintf _ast_wprintf
+#define wscanf _ast_wscanf
+
+#if !_typ_mbstate_t
+#undef _typ_mbstate_t
+#define _typ_mbstate_t 1
+typedef char mbstate_t;
+#endif
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#if !_lib_mbstowcs
+extern __MANGLE__ size_t mbstowcs __PROTO__((wchar_t*, const char*, size_t));
+#endif
+#if !_lib_wctomb
+extern __MANGLE__ int wctomb __PROTO__((char*, wchar_t));
+#endif
+#if !_lib_wcrtomb
+extern __MANGLE__ size_t wcrtomb __PROTO__((char*, wchar_t, mbstate_t*));
+#endif
+#if !_lib_wcslen
+extern __MANGLE__ size_t wcslen __PROTO__((const wchar_t*));
+#endif
+#if !_lib_wcstombs
+extern __MANGLE__ size_t wcstombs __PROTO__((char*, const wchar_t*, size_t));
+#endif
+
+extern __MANGLE__ int fwprintf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ int fwscanf __PROTO__((FILE*, const wchar_t*, ...));
+extern __MANGLE__ wint_t fgetwc __PROTO__((FILE*));
+extern __MANGLE__ wchar_t* fgetws __PROTO__((wchar_t*, int, FILE*));
+extern __MANGLE__ wint_t fputwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ int fputws __PROTO__((const wchar_t*, FILE*));
+extern __MANGLE__ int fwide __PROTO__((FILE*, int));
+extern __MANGLE__ wint_t getwc __PROTO__((FILE*));
+extern __MANGLE__ wint_t getwchar __PROTO__((void));
+extern __MANGLE__ wchar_t* getws __PROTO__((wchar_t*));
+extern __MANGLE__ wint_t putwc __PROTO__((wchar_t, FILE*));
+extern __MANGLE__ wint_t putwchar __PROTO__((wchar_t));
+extern __MANGLE__ int swprintf __PROTO__((wchar_t*, size_t, const wchar_t*, ...));
+extern __MANGLE__ int swscanf __PROTO__((const wchar_t*, const wchar_t*, ...));
+extern __MANGLE__ wint_t ungetwc __PROTO__((wint_t, FILE*));
+extern __MANGLE__ int vfwprintf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vfwscanf __PROTO__((FILE*, const wchar_t*, va_list));
+extern __MANGLE__ int vwprintf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vwscanf __PROTO__((const wchar_t*, va_list));
+extern __MANGLE__ int vswprintf __PROTO__((wchar_t*, size_t, const wchar_t*, va_list));
+extern __MANGLE__ int vswscanf __PROTO__((const wchar_t*, const wchar_t*, va_list));
+extern __MANGLE__ int wprintf __PROTO__((const wchar_t*, ...));
+extern __MANGLE__ int wscanf __PROTO__((const wchar_t*, ...));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/conftab.c b/usr/src/lib/libast/sparcv9/src/lib/libast/conftab.c
new file mode 100644
index 0000000000..ad51298b85
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/conftab.c
@@ -0,0 +1,451 @@
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+#include "FEATURE/standards"
+#include "FEATURE/common"
+#include <sys/types.h>
+#include <limits.h>
+#include <unistd.h>
+#if !defined(SYS_NMLEN)
+#define SYS_NMLEN 9
+#endif
+#include <sys/systeminfo.h>
+#include "FEATURE/param"
+#include "conftab.h"
+
+/* : : generated by conf from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/comp/conf.tab : : */
+
+/*
+ * prefix strings -- the first few are indexed by Conf_t.standard
+ */
+
+const Prefix_t prefix[] =
+{
+ "C", 1, CONF_C, -1,
+ "POSIX", 5, CONF_POSIX, -1,
+ "SVID", 4, CONF_SVID, -1,
+ "XOPEN", 5, CONF_XOPEN, -1,
+ "SUN", 3, CONF_SUN, -1,
+ "XBS5", 4, CONF_XBS5, -1,
+ "SCO", 3, CONF_SCO, -1,
+ "AST", 3, CONF_AST, -1,
+ "AES", 3, CONF_AES, -1,
+ "XPG", 3, CONF_XPG, -1,
+ "GNU", 3, CONF_GNU, -1,
+ "TRUSTEDBSD", 10, CONF_TRUSTEDBSD, -1,
+ "XX", 2, CONF_POSIX, CONF_nop,
+ "CS", 2, CONF_POSIX, CONF_confstr,
+ "PC", 2, CONF_POSIX, CONF_pathconf,
+ "SC", 2, CONF_POSIX, CONF_sysconf,
+ "SI", 2, CONF_SVID, CONF_sysinfo,
+};
+
+int prefix_elements = (int)sizeof(prefix) / (int)sizeof(prefix[0]);
+
+/*
+ * conf strings sorted in ascending order
+ */
+
+const Conf_t conf[] =
+{
+{ "ABI_AIO_XFER_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ABI_ASYNCHRONOUS_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ABI_ASYNC_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ADVISORY_INFO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_ADVISORY_INFO },
+{ "AIO_LISTIO_MAX", { 0, 0 }, { _POSIX_AIO_LISTIO_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_AIO_LISTIO_MAX },
+{ "AIO_MAX", { 0, 0 }, { _POSIX_AIO_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_AIO_MAX },
+{ "AIO_PRIO_DELTA_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, _SC_AIO_PRIO_DELTA_MAX },
+{ "ALLOC_SIZE_MIN", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_ALLOC_SIZE_MIN },
+{ "ARCHITECTURE", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "ARG_MAX", { 0, 0 }, { _POSIX_ARG_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_ARG_MAX },
+{ "ASYNCHRONOUS_IO", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_ASYNCHRONOUS_IO },
+{ "ASYNC_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_ASYNC_IO },
+{ "ATEXIT_MAX", { 0, 0 }, { 32, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_XOPEN, 1, CONF_sysconf, _SC_ATEXIT_MAX },
+{ "AUDIT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "AVAIL_PROCESSORS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "AVPHYS_PAGES", { 0, 0 }, { 0, 0 }, 0, CONF_SUN, 1, CONF_sysconf, _SC_AVPHYS_PAGES },
+{ "BARRIERS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_BARRIERS },
+{ "BC_BASE_MAX", { 0, 0 }, { _POSIX2_BC_BASE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_BC_BASE_MAX },
+{ "BC_DIM_MAX", { 0, 0 }, { _POSIX2_BC_DIM_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_BC_DIM_MAX },
+{ "BC_SCALE_MAX", { 0, 0 }, { _POSIX2_BC_SCALE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_BC_SCALE_MAX },
+{ "BC_STRING_MAX", { 0, 0 }, { _POSIX2_BC_STRING_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_BC_STRING_MAX },
+{ "BUSTYPES", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "CHARCLASS_NAME_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "CHAR_BIT", { 8, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "CHAR_MAX", { 127, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "CHAR_MIN", { -128, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "CHAR_TERM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_CHAR_TERM },
+{ "CHILD_MAX", { 0, 0 }, { _POSIX_CHILD_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_CHILD_MAX },
+{ "CHOWN_RESTRICTED", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_CHOWN_RESTRICTED },
+{ "CKPT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "CLK_TCK", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_POSIX, 1, CONF_sysconf, _SC_CLK_TCK },
+{ "CLOCKRES_MIN", { 0, 0 }, { _POSIX_CLOCKRES_MIN, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_PREFIX_ONLY|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "CLOCKS_PER_SEC", { 1000000, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_LIMIT|CONF_LIMIT_DEF, CONF_POSIX, 1, CONF_nop, -1 },
+{ "CLOCK_SELECTION", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_CLOCK_SELECTION },
+{ "COLL_WEIGHTS_MAX", { 0, 0 }, { _POSIX2_COLL_WEIGHTS_MAX, 0 }, CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_COLL_WEIGHTS_MAX },
+{ "CPUTIME", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_CPUTIME },
+{ "CPU_KEYBITS1", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "CPU_VERSION", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "CRYPT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_CRYPT },
+{ "C_BIND", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 2, CONF_sysconf, _SC_2_C_BIND },
+{ "C_DEV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 2, CONF_sysconf, _SC_2_C_DEV },
+{ "C_VERSION", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 2, CONF_sysconf, _SC_2_C_VERSION },
+{ "DATAKEYS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "DELAYTIMER_MAX", { 0, 0 }, { _POSIX_DELAYTIMER_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_DELAYTIMER_MAX },
+{ "ENH_I18N", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_ENH_I18N },
+{ "EQUIV_CLASS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "EXEC_INTERPRETER_LENGTH", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "EXPR_NEST_MAX", { 0, 0 }, { _POSIX2_EXPR_NEST_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_EXPR_NEST_MAX },
+{ "FCHR_MAX", { 0, 0 }, { LONG_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "FILESIZEBITS", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_FILESIZEBITS },
+{ "FILE_LOCKING", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "FORT_DEV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_FORT_DEV },
+{ "FORT_RUN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_FORT_RUN },
+{ "FSYNC", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_FSYNC },
+{ "GETGR_R_SIZE_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_sysconf, _SC_GETGR_R_SIZE_MAX },
+{ "GETPW_R_SIZE_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_sysconf, _SC_GETPW_R_SIZE_MAX },
+{ "HOSTID", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "HOSTNAME", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "HOST_NAME_MAX", { 0, 0 }, { _POSIX_HOST_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_HOST_NAME_MAX },
+{ "HW_PROVIDER", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "HW_SERIAL", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ILP32_OFF32", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XBS5, 1, CONF_sysconf, -1 },
+{ "ILP32_OFF32_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFF32_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFF32_LIBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFF32_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFFBIG", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XBS5, 1, CONF_sysconf, -1 },
+{ "ILP32_OFFBIG_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFFBIG_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFFBIG_LIBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "ILP32_OFFBIG_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "INITTAB_NAME", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "INT_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "INT_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "IOV_MAX", { 0, 0 }, { _XOPEN_IOV_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_XOPEN, 1, CONF_sysconf, _SC_IOV_MAX },
+{ "IO_TYPE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "IPV6", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_IPV6 },
+{ "IP_SECOPTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "JOB_CONTROL", { 0, 0 }, { 1, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_JOB_CONTROL },
+{ "KERNEL_CLIST", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_CLIST_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_DISK", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_DISK_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_DMABUF", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_DMABUF_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_FILE", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_FILE_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_FLCKREC", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_FLCKREC_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_INODE", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_INODE_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_MOUNT", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_MOUNT_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_PINODE", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_PINODE_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_PROC", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_PROC_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_REGION", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_REGION_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_S5INODE", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_S5INODE_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SCO, 1, CONF_sysconf, -1 },
+{ "KERNEL_STAMP", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "KERN_POINTERS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "KERN_SIM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "LEGACY", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, -1 },
+{ "LFS64_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS64_CFLAGS },
+{ "LFS64_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS64_LDFLAGS },
+{ "LFS64_LIBS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS64_LIBS },
+{ "LFS64_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS64_LINTFLAGS },
+{ "LFS_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_CFLAGS },
+{ "LFS_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_LDFLAGS },
+{ "LFS_LIBS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_LIBS },
+{ "LFS_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_LINTFLAGS },
+{ "LINE_MAX", { 0, 0 }, { _POSIX2_LINE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_LINE_MAX },
+{ "LINK_MAX", { 0, 0 }, { _POSIX_LINK_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_LINK_MAX },
+{ "LLONG_MAX", { 9223372036854775807LL, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "LLONG_MIN", { (-9223372036854775807LL-1LL), 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "LOCALEDEF", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_LOCALEDEF },
+{ "LOGIN_NAME_MAX", { 0, 0 }, { _POSIX_LOGIN_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_LOGIN_NAME_MAX },
+{ "LOGNAME_MAX", { 0, 0 }, { 8, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, _SC_LOGNAME_MAX },
+{ "LONG_BIT", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "LONG_MAX", { 2147483647, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "LONG_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "LP64_OFF64", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XBS5, 1, CONF_sysconf, -1 },
+{ "LP64_OFF64_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LP64_OFF64_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LP64_OFF64_LIBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LP64_OFF64_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LPBIG_OFFBIG", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XBS5, 1, CONF_sysconf, -1 },
+{ "LPBIG_OFFBIG_CFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LPBIG_OFFBIG_LDFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LPBIG_OFFBIG_LIBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "LPBIG_OFFBIG_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_STRING, CONF_XBS5, 1, CONF_confstr, -1 },
+{ "MACHINE", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "MAPPED_FILES", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MAPPED_FILES },
+{ "MAX_CANON", { 0, 0 }, { _POSIX_MAX_CANON, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_MAX_CANON },
+{ "MAX_INPUT", { 0, 0 }, { _POSIX_MAX_INPUT, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_MAX_INPUT },
+{ "MB_LEN_MAX", { 5, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "MCAS_OFFSET", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "MEMLOCK", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MEMLOCK },
+{ "MEMLOCK_RANGE", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MEMLOCK_RANGE },
+{ "MEMORY_PROTECTION", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MEMORY_PROTECTION },
+{ "MESSAGE_PASSING", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MESSAGE_PASSING },
+{ "MMAP_FIXED_ALIGNMENT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "MONOTONIC_CLOCK", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_MONOTONIC_CLOCK },
+{ "MQ_OPEN_MAX", { 0, 0 }, { _POSIX_MQ_OPEN_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_MQ_OPEN_MAX },
+{ "MQ_PRIO_MAX", { 0, 0 }, { _POSIX_MQ_PRIO_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_MQ_PRIO_MAX },
+{ "MSEM_LOCKID", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "MULTI_PROCESS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "NACLS_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "NAME_MAX", { 0, 0 }, { _POSIX_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_NAME_MAX },
+{ "NGROUPS_MAX", { 0, 0 }, { _POSIX_NGROUPS_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_NGROUPS_MAX },
+{ "NL_ARGMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_LANGMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NL_MSGMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_NMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_SETMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NL_SPECMAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NL_TEXTMAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "NO_TRUNC", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_NO_TRUNC },
+{ "NPROCESSORS_CONF", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, _SC_NPROCESSORS_CONF },
+{ "NPROCESSORS_ONLN", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, _SC_NPROCESSORS_ONLN },
+{ "NPROC_CONF", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NPROC_ONLN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NSS_BUFLEN_GROUP", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NSS_BUFLEN_PASSWD", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NUM_PROCESSORS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "NZERO", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "OPEN_MAX", { 0, 0 }, { _POSIX_OPEN_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_OPEN_MAX },
+{ "OPEN_MAX_CEIL", { OPEN_MAX, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_AST, 1, CONF_nop, -1 },
+{ "OSREL_MAJ", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "OSREL_MIN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "OSREL_PATCH", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "OS_BASE", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "OS_PROVIDER", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "OS_VERSION", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE, CONF_AES, 1, CONF_sysconf, -1 },
+{ "PAGESIZE", { 0, 0 }, { 4096, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_PAGESIZE },
+{ "PAGE_SIZE", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, _SC_PAGE_SIZE },
+{ "PASS_MAX", { 0, 0 }, { 8, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, _SC_PASS_MAX },
+{ "PATH", { 0, 0 }, { 0, "/bin:/usr/bin" }, CONF_DEFER_CALL|CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_confstr, _CS_PATH },
+{ "PATH_MAX", { 0, 0 }, { _POSIX_PATH_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_PATH_MAX },
+{ "PBS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS },
+{ "PBS_ACCOUNTING", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_ACCOUNTING },
+{ "PBS_CHECKPOINT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_CHECKPOINT },
+{ "PBS_LOCATE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_LOCATE },
+{ "PBS_MESSAGE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_MESSAGE },
+{ "PBS_TRACK", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_PBS_TRACK },
+{ "PHYS_PAGES", { 0, 0 }, { 0, 0 }, 0, CONF_SUN, 1, CONF_sysconf, _SC_PHYS_PAGES },
+{ "PID_MAX", { 0, 0 }, { 30000, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "PII", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_INTERNET", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_INTERNET_DGRAM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_INTERNET_STREAM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_OSI", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_OSI_CLTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_OSI_COTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_OSI_M", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_SOCKET", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PII_XTI", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PIPE_BUF", { 0, 0 }, { _POSIX_PIPE_BUF, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_PIPE_BUF },
+{ "POLL", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "PRIORITIZED_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_PRIORITIZED_IO },
+{ "PRIORITY_SCHEDULING", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_PRIORITY_SCHEDULING },
+{ "PRIO_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_PRIO_IO },
+{ "PROC_RSRC_MGR", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTHREAD_DESTRUCTOR_ITERATIONS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTHREAD_KEYS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTHREAD_STACK_MIN", { 4096, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_LIMIT|CONF_LIMIT_DEF, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTHREAD_THREADS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "PTRDIFF_MAX", { 9223372036854775807LL, 0 }, { 65535, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "PTRDIFF_MIN", { (-9223372036854775807LL-1LL), 0 }, { -65535, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "RAW_SOCKETS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_RAW_SOCKETS },
+{ "READER_WRITER_LOCKS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_READER_WRITER_LOCKS },
+{ "REALTIME", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, -1 },
+{ "REALTIME_SIGNALS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_REALTIME_SIGNALS },
+{ "REALTIME_THREADS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, -1 },
+{ "REC_INCR_XFER_SIZE", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_REC_INCR_XFER_SIZE },
+{ "REC_MAX_XFER_SIZE", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_REC_MAX_XFER_SIZE },
+{ "REC_MIN_XFER_SIZE", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_REC_MIN_XFER_SIZE },
+{ "REC_XFER_ALIGN", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_REC_XFER_ALIGN },
+{ "REENTRANT_FUNCTIONS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "REGEXP", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_REGEXP },
+{ "REGEX_VERSION", { 0, 0 }, { 20030916, 0 }, CONF_FEATURE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "RELEASE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "RESOURCE_LIMITS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "RE_DUP_MAX", { 0, 0 }, { _POSIX2_RE_DUP_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_RE_DUP_MAX },
+{ "RTSIG_MAX", { 0, 0 }, { _POSIX_RTSIG_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_RTSIG_MAX },
+{ "SAVED_IDS", { 0, 0 }, { 1, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SAVED_IDS },
+{ "SCHAR_MAX", { 127, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SCHAR_MIN", { -128, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SECURITY_CLASS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SELECT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "SEMAPHORES", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SEMAPHORES },
+{ "SEM_NSEMS_MAX", { 0, 0 }, { _POSIX_SEM_NSEMS_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_SEM_NSEMS_MAX },
+{ "SEM_VALUE_MAX", { 0, 0 }, { _POSIX_SEM_VALUE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_SEM_VALUE_MAX },
+{ "SH", { 0, 0 }, { 0, "/bin/sh" }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING|CONF_MINMAX_DEF, CONF_AST, 1, CONF_confstr, -1 },
+{ "SHARED_MEMORY_OBJECTS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SHARED_MEMORY_OBJECTS },
+{ "SHELL", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SHELL },
+{ "SHM", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_SHM },
+{ "SHRT_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "SHRT_MIN", { -32768, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SIGQUEUE_MAX", { 0, 0 }, { _POSIX_SIGQUEUE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_SIGQUEUE_MAX },
+{ "SIGRT_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, _SC_SIGRT_MAX },
+{ "SIGRT_MIN", { 0, 0 }, { 0, 0 }, 0, CONF_SVID, 1, CONF_sysconf, _SC_SIGRT_MIN },
+{ "SIG_ATOMIC_MAX", { 2147483647, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SIG_ATOMIC_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SIZE_MAX", { UINT_MAX, 0 }, { 65535, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "SLVM_MAXNODES", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SOCK_MAXBUF", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SOFTPOWER", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SPAWN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SPAWN },
+{ "SPIN_LOCKS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SPIN_LOCKS },
+{ "SPORADIC_SERVER", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SPORADIC_SERVER },
+{ "SRPC_DOMAIN", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SSIZE_MAX", { INT_MAX, 0 }, { _POSIX_SSIZE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_nop, -1 },
+{ "SS_REPL_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SS_REPL_MAX },
+{ "STD_BLK", { 0, 0 }, { 1024, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "STREAMS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_STREAMS },
+{ "STREAM_MAX", { 0, 0 }, { _POSIX_STREAM_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_STREAM_MAX },
+{ "SW_DEV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_SW_DEV },
+{ "SYMLINKS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_pathconf, _PC_2_SYMLINKS },
+{ "SYMLINK_MAX", { 0, 0 }, { _POSIX_SYMLINK_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_SYMLINK_MAX },
+{ "SYMLOOP_MAX", { 0, 0 }, { _POSIX_SYMLOOP_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_SYMLOOP_MAX },
+{ "SYNCHRONIZED_IO", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_SYNCHRONIZED_IO },
+{ "SYNC_IO", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_SYNC_IO },
+{ "SYSNAME", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "SYSPID_MAX", { 0, 0 }, { 2, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "THREADS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREADS },
+{ "THREADS_PRIO_CEILING", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "THREADS_PRIO_INHERIT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "THREAD_ATTR_STACKADDR", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_ATTR_STACKADDR },
+{ "THREAD_ATTR_STACKSIZE", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_ATTR_STACKSIZE },
+{ "THREAD_CPUTIME", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_CPUTIME },
+{ "THREAD_DESTRUCTOR_ITERATIONS", { 0, 0 }, { _POSIX_THREAD_DESTRUCTOR_ITERATIONS, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_PREFIX_ONLY|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_DESTRUCTOR_ITERATIONS },
+{ "THREAD_KEYS_MAX", { 0, 0 }, { _POSIX_THREAD_KEYS_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_PREFIX_ONLY|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_KEYS_MAX },
+{ "THREAD_PRIORITY_SCHEDULING", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_PRIORITY_SCHEDULING },
+{ "THREAD_PRIO_INHERIT", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_PRIO_INHERIT },
+{ "THREAD_PRIO_PROTECT", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_PRIO_PROTECT },
+{ "THREAD_PROCESS_SHARED", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_PROCESS_SHARED },
+{ "THREAD_SAFE_FUNCTIONS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_SAFE_FUNCTIONS },
+{ "THREAD_SPORADIC_SERVER", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_SPORADIC_SERVER },
+{ "THREAD_STACK_MIN", { 0, 0 }, { 0, 0 }, CONF_LIMIT|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_STACK_MIN },
+{ "THREAD_THREADS_MAX", { 0, 0 }, { _POSIX_THREAD_THREADS_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_PREFIX_ONLY|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_THREAD_THREADS_MAX },
+{ "TIMEOUTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TIMEOUTS },
+{ "TIMERS", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TIMERS },
+{ "TIMER_MAX", { 0, 0 }, { _POSIX_TIMER_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_TIMER_MAX },
+{ "TMP", { 0, 0 }, { 0, "/tmp" }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING|CONF_MINMAX_DEF, CONF_AST, 1, CONF_confstr, -1 },
+{ "TMP_MAX", { 17576, 0 }, { 10000, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_LIMIT_DEF|CONF_MINMAX_DEF, CONF_C, 1, CONF_sysconf, -1 },
+{ "TRACE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE },
+{ "TRACE_EVENT_FILTER", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_EVENT_FILTER },
+{ "TRACE_EVENT_NAME_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_EVENT_NAME_MAX },
+{ "TRACE_INHERIT", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_INHERIT },
+{ "TRACE_LOG", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_LOG },
+{ "TRACE_NAME_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_NAME_MAX },
+{ "TRACE_SYS_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_SYS_MAX },
+{ "TRACE_USER_EVENT_MAX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_NOUNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TRACE_USER_EVENT_MAX },
+{ "TTY_NAME_MAX", { 0, 0 }, { _POSIX_TTY_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_TTY_NAME_MAX },
+{ "TYPED_MEMORY_OBJECTS", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_TYPED_MEMORY_OBJECTS },
+{ "TZNAME_MAX", { 0, 0 }, { _POSIX_TZNAME_MAX, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_TZNAME_MAX },
+{ "T_IOV_MAX", { 0, 0 }, { 0, 0 }, 0, CONF_C, 1, CONF_sysconf, _SC_T_IOV_MAX },
+{ "UCHAR_MAX", { 255, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "UCHAR_MIN", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "UID_MAX", { 0, 0 }, { 60002, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+{ "UINT_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "UIO_MAXIOV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+{ "ULLONG_MAX", { 18446744073709551615ULL, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "ULONG_MAX", { 4294967295, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "UNIX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_UNIX },
+{ "UPE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_UPE },
+{ "USER_LIMIT", { 0, 0 }, { 0, 0 }, 0|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "USHRT_MAX", { 65535, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "V6_ILP32_OFF32", { 0, 0 }, { 0, 0 }, CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_V6_ILP32_OFF32 },
+{ "V6_ILP32_OFFBIG", { 0, 0 }, { 0, 0 }, CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_V6_ILP32_OFFBIG },
+{ "V6_LP64_OFF64", { 0, 0 }, { 0, 0 }, CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_V6_LP64_OFF64 },
+{ "V6_LPBIG_OFFBIG", { 0, 0 }, { 0, 0 }, CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_sysconf, _SC_V6_LPBIG_OFFBIG },
+{ "VDISABLE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 1, CONF_pathconf, _PC_VDISABLE },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_PREFIXED|CONF_STANDARD|CONF_STRING, CONF_SVID, 1, CONF_sysinfo, -1 },
+{ "VERSION", { 0, 0 }, { 200112, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "VERSION", { 0, 0 }, { 200112, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 2, CONF_sysconf, -1 },
+{ "VERSION", { 0, 0 }, { 600, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_VERSION },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_XPG, 3, CONF_sysconf, -1 },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_DEFER_MM|CONF_FEATURE|CONF_PREFIXED|CONF_STANDARD|CONF_UNDERSCORE, CONF_XPG, 4, CONF_sysconf, -1 },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_PREFIXED|CONF_STANDARD, CONF_AST, 1, CONF_nop, -1 },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_PREFIXED|CONF_STANDARD, CONF_GNU, 1, CONF_nop, -1 },
+{ "VERSION", { 0, 0 }, { 0, 0 }, CONF_PREFIXED|CONF_STANDARD, CONF_TRUSTEDBSD, 1, CONF_nop, -1 },
+{ "VERSION_88", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_LIMIT|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "VERSION_88", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "VERSION_90", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_LIMIT|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "VERSION_90", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "VERSION_93", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_LIMIT|CONF_STANDARD|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_sysconf, -1 },
+{ "VERSION_93", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+{ "WCHAR_MAX", { 2147483647, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "WCHAR_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "WINT_MAX", { 2147483647, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "WINT_MIN", { -2147483648, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+{ "WORD_BIT", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "XCU_VERSION", { 0, 0 }, { 0, 0 }, CONF_DEFER_CALL|CONF_DEFER_MM|CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_XCU_VERSION },
+{ "XPG2", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "XPG3", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_nop, -1 },
+{ "XPG4", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_XOPEN, 1, CONF_nop, -1 },
+};
+
+int conf_elements = (int)sizeof(conf) / (int)sizeof(conf[0]);
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/conftab.h b/usr/src/lib/libast/sparcv9/src/lib/libast/conftab.h
new file mode 100644
index 0000000000..b88d4b5182
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/conftab.h
@@ -0,0 +1,154 @@
+
+/* : : generated by proto : : */
+
+
+#ifndef _CONFTAB_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _CONFTAB_H
+
+#if !defined(SYS_NMLEN)
+#define SYS_NMLEN 9
+#endif
+#include <sys/systeminfo.h>
+
+/* : : generated by conf from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/comp/conf.tab : : */
+
+#define conf _ast_conf_data
+#define conf_elements _ast_conf_ndata
+
+#define prefix _ast_conf_prefix
+#define prefix_elements _ast_conf_nprefix
+
+#define CONF_nop 0
+#define CONF_confstr 1
+#define CONF_pathconf 2
+#define CONF_sysconf 3
+#define CONF_sysinfo 4
+
+#define CONF_C 0
+#define CONF_POSIX 1
+#define CONF_SVID 2
+#define CONF_XOPEN 3
+#define CONF_SUN 4
+#define CONF_XBS5 5
+#define CONF_SCO 6
+#define CONF_AST 7
+#define CONF_AES 8
+#define CONF_XPG 9
+#define CONF_GNU 10
+#define CONF_TRUSTEDBSD 11
+#define CONF_call 12
+
+#define _pth_getconf "/usr/bin/getconf"
+#define _pth_getconf_a "-a"
+
+#define CONF_DEFER_CALL 0x0001
+#define CONF_DEFER_MM 0x0002
+#define CONF_FEATURE 0x0004
+#define CONF_LIMIT 0x0008
+#define CONF_LIMIT_DEF 0x0010
+#define CONF_MINMAX 0x0020
+#define CONF_MINMAX_DEF 0x0040
+#define CONF_NOSECTION 0x0080
+#define CONF_NOUNDERSCORE 0x0100
+#define CONF_PREFIX_ONLY 0x0200
+#define CONF_PREFIXED 0x0400
+#define CONF_STANDARD 0x0800
+#define CONF_STRING 0x1000
+#define CONF_UNDERSCORE 0x2000
+#define CONF_USER 0x4000
+
+struct Conf_s; typedef struct Conf_s Conf_t;
+
+typedef int (*Conf_f) __PROTO__((Conf_t*, intmax_t*, char**));
+
+typedef struct Value_s
+{
+ intmax_t number;
+ const char* string;
+} Value_t;
+
+struct Conf_s
+{
+ const char name[32];
+ Value_t limit;
+ Value_t minmax;
+ short flags;
+ short standard;
+ short section;
+ short call;
+ short op;
+};
+
+typedef struct Prefix_s
+{
+ const char name[16];
+ short length;
+ short standard;
+ short call;
+} Prefix_t;
+
+extern __MANGLE__ const Conf_t conf[];
+extern __MANGLE__ int conf_elements;
+
+extern __MANGLE__ const Prefix_t prefix[];
+extern __MANGLE__ int prefix_elements;
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/lc.h b/usr/src/lib/libast/sparcv9/src/lib/libast/lc.h
new file mode 100644
index 0000000000..fdd804f36e
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/lc.h
@@ -0,0 +1,158 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+/* : : generated by ./lcgen : : */
+
+
+#ifndef _LC_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _LC_H 1
+
+#include <ast.h>
+
+#define LC_abbreviated 0x00001
+#define LC_checked 0x00002
+#define LC_default 0x00004
+#define LC_defined 0x00008
+#define LC_debug 0x00010
+#define LC_local 0x00020
+#define LC_primary 0x00040
+#define LC_qualified 0x00080
+#define LC_undefined 0x00100
+#define LC_verbose 0x00200
+#define LC_user 0x10000
+#define LC_language_attribute_max 2
+#define LC_territory_language_max 4
+
+struct Lc_s;
+
+typedef struct Lc_info_s
+{
+ const struct Lc_s* lc;
+ unsigned long number;
+ __V_* data;
+} Lc_info_t;
+
+typedef struct Lc_attribute_s
+{
+ const char* name;
+ unsigned long flags;
+ unsigned long index;
+} Lc_attribute_t;
+
+typedef struct Lc_charset_s
+{
+ const char* code;
+ const char* alternates;
+ const char* ms;
+ unsigned long index;
+} Lc_charset_t;
+
+typedef struct Lc_language_s
+{
+ const char* code;
+ const char* name;
+ const char* alternates;
+ const Lc_charset_t* charset;
+ unsigned long flags;
+ unsigned long index;
+ const Lc_attribute_t* attributes[LC_language_attribute_max];
+} Lc_language_t;
+
+typedef struct Lc_territory_s
+{
+ const char* code;
+ const char* name;
+ unsigned long flags;
+ unsigned long index;
+ const Lc_language_t* languages[LC_territory_language_max];
+#ifdef _LC_TERRITORY_PRIVATE_
+ _LC_TERRITORY_PRIVATE_
+#endif
+} Lc_territory_t;
+
+typedef struct Lc_map_s
+{
+ const char* code;
+ const Lc_language_t* language;
+ const Lc_territory_t* territory;
+ const Lc_charset_t* charset;
+ const Lc_attribute_t* attribute;
+} Lc_map_t;
+
+typedef struct Lc_attribute_list_s
+{
+ struct Lc_attribute_list_s* next;
+ const Lc_attribute_t* attribute;
+} Lc_attribute_list_t;
+
+typedef struct Lc_s
+{
+ const char* name;
+ const char* code;
+ const Lc_language_t* language;
+ const Lc_territory_t* territory;
+ const Lc_charset_t* charset;
+ const Lc_attribute_list_t* attributes;
+ unsigned long flags;
+ unsigned long index;
+#ifdef _LC_PRIVATE_
+ _LC_PRIVATE_
+#endif
+} Lc_t;
+
+struct Lc_category_s;
+
+typedef int (*Lc_category_set_f) __PROTO__((struct Lc_category_s*));
+
+typedef struct Lc_category_s
+{
+ const char* name;
+ int external;
+ int internal;
+ Lc_category_set_f setf;
+ Lc_t* prev;
+} Lc_category_t;
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ size_t lccanon __PROTO__((Lc_t*, unsigned long flags, char*, size_t));
+extern __MANGLE__ Lc_category_t* lccategories __PROTO__((void));
+extern __MANGLE__ int lcindex __PROTO__((int, int));
+extern __MANGLE__ Lc_info_t* lcinfo __PROTO__((int));
+extern __MANGLE__ Lc_t* lcmake __PROTO__((const char*));
+extern __MANGLE__ Lc_t* lcscan __PROTO__((Lc_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/lctab.h b/usr/src/lib/libast/sparcv9/src/lib/libast/lctab.h
new file mode 100644
index 0000000000..6abbd72c65
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/lctab.h
@@ -0,0 +1,2630 @@
+/* : : generated by ./lcgen : : */
+
+static Lc_attribute_t attribute_es[] =
+{
+{"traditional",LC_default,
+#ifdef SUBLANG_SPANISH_TRADITIONAL
+SUBLANG_SPANISH_TRADITIONAL,
+#else
+0,
+#endif
+
+},
+{"modern",0,
+#ifdef SUBLANG_SPANISH_MODERN
+SUBLANG_SPANISH_MODERN,
+#else
+0,
+#endif
+
+},
+};
+
+static const Lc_charset_t charset[] =
+{
+{"iso8859-1","latin1|west-europe","1252",},
+{"iso8859-2","latin2|east-europe","1250",},
+{"iso8859-3","latin3|south-europe","1257",},
+{"iso8859-4","latin4|north-europe",0},
+{"iso8859-5","cyrillic","1251",},
+{"iso8859-6","arabic","1256",},
+{"iso8859-7","greek","1253",},
+{"iso8859-8","hebrew","1255",},
+{"iso8859-9","latin5|turkish","1254",},
+{"iso8859-10","latin6|nordic",0},
+{"iso8859-13","latin7",0},
+{"iso8859-14","latin8|celtic",0},
+{"iso8859-15","latin0",0},
+{"iso2022","japanese|korean",0},
+{"iso4873","japanese-ascii|korean-ascii",0},
+{"koi8-r","russian",0},
+{"utf8","plan9",0},
+ 0
+};
+
+static const Lc_language_t language[] =
+{
+{"C","C","POSIX",&charset[0],LC_default,0,0,0,},
+{"debug","debug",0,&charset[0],LC_debug,0,0,0,},
+{"aa","afar",0,&charset[0],0,
+#ifdef LANG_AFAR
+LANG_AFAR,
+#else
+0,
+#endif
+0,0,
+},
+{"ab","abkhazian",0,&charset[0],0,
+#ifdef LANG_ABKHAZIAN
+LANG_ABKHAZIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"af","afrikaans","afr",&charset[0],0,
+#ifdef LANG_AFRIKAANS
+LANG_AFRIKAANS,
+#else
+0,
+#endif
+0,0,
+},
+{"am","amharic",0,&charset[0],0,
+#ifdef LANG_AMHARIC
+LANG_AMHARIC,
+#else
+0,
+#endif
+0,0,
+},
+{"ar","arabic","ara",&charset[5],0,
+#ifdef LANG_ARABIC
+LANG_ARABIC,
+#else
+0,
+#endif
+0,0,
+},
+{"as","assamese",0,&charset[0],0,
+#ifdef LANG_ASSAMESE
+LANG_ASSAMESE,
+#else
+0,
+#endif
+0,0,
+},
+{"ay","aymara",0,&charset[0],0,
+#ifdef LANG_AYMARA
+LANG_AYMARA,
+#else
+0,
+#endif
+0,0,
+},
+{"az","azerbaijani",0,&charset[0],0,
+#ifdef LANG_AZERBAIJANI
+LANG_AZERBAIJANI,
+#else
+0,
+#endif
+0,0,
+},
+{"ba","bashkir",0,&charset[0],0,
+#ifdef LANG_BASHKIR
+LANG_BASHKIR,
+#else
+0,
+#endif
+0,0,
+},
+{"be","belarusian","bel",&charset[0],0,
+#ifdef LANG_BELARUSIAN
+LANG_BELARUSIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"bg","bulgarian","bul",&charset[4],0,
+#ifdef LANG_BULGARIAN
+LANG_BULGARIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"bh","bihari",0,&charset[0],0,
+#ifdef LANG_BIHARI
+LANG_BIHARI,
+#else
+0,
+#endif
+0,0,
+},
+{"bi","bislama",0,&charset[0],0,
+#ifdef LANG_BISLAMA
+LANG_BISLAMA,
+#else
+0,
+#endif
+0,0,
+},
+{"bn","bengali-bangla",0,&charset[0],0,
+#ifdef LANG_BENGALI_BANGLA
+LANG_BENGALI_BANGLA,
+#else
+0,
+#endif
+0,0,
+},
+{"bo","tibetan",0,&charset[0],0,
+#ifdef LANG_TIBETAN
+LANG_TIBETAN,
+#else
+0,
+#endif
+0,0,
+},
+{"br","breton",0,&charset[0],0,
+#ifdef LANG_BRETON
+LANG_BRETON,
+#else
+0,
+#endif
+0,0,
+},
+{"ca","catalan","cat",&charset[0],0,
+#ifdef LANG_CATALAN
+LANG_CATALAN,
+#else
+0,
+#endif
+0,0,
+},
+{"co","corsican",0,&charset[0],0,
+#ifdef LANG_CORSICAN
+LANG_CORSICAN,
+#else
+0,
+#endif
+0,0,
+},
+{"cs","czech","ces|cze",&charset[1],0,
+#ifdef LANG_CZECH
+LANG_CZECH,
+#else
+0,
+#endif
+0,0,
+},
+{"cy","welsh",0,&charset[0],0,
+#ifdef LANG_WELSH
+LANG_WELSH,
+#else
+0,
+#endif
+0,0,
+},
+{"da","danish","dan",&charset[0],0,
+#ifdef LANG_DANISH
+LANG_DANISH,
+#else
+0,
+#endif
+0,0,
+},
+{"de","german","deu|ger",&charset[0],0,
+#ifdef LANG_GERMAN
+LANG_GERMAN,
+#else
+0,
+#endif
+0,0,
+},
+{"dz","bhutani",0,&charset[0],0,
+#ifdef LANG_BHUTANI
+LANG_BHUTANI,
+#else
+0,
+#endif
+0,0,
+},
+{"el","greek","ell|gre",&charset[6],0,
+#ifdef LANG_GREEK
+LANG_GREEK,
+#else
+0,
+#endif
+0,0,
+},
+{"en","english","eng",&charset[0],0,
+#ifdef LANG_ENGLISH
+LANG_ENGLISH,
+#else
+0,
+#endif
+0,0,
+},
+{"eo","esperanto",0,&charset[0],0,
+#ifdef LANG_ESPERANTO
+LANG_ESPERANTO,
+#else
+0,
+#endif
+0,0,
+},
+{"es","spanish","spa",&charset[0],0,
+#ifdef LANG_SPANISH
+LANG_SPANISH,
+#else
+0,
+#endif
+&attribute_es[0],&attribute_es[1],
+},
+{"et","estonian","est",&charset[2],0,
+#ifdef LANG_ESTONIAN
+LANG_ESTONIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"eu","basque","eus|baq",&charset[0],0,
+#ifdef LANG_BASQUE
+LANG_BASQUE,
+#else
+0,
+#endif
+0,0,
+},
+{"fa","persian",0,&charset[0],0,
+#ifdef LANG_PERSIAN
+LANG_PERSIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"fi","finnish","fin",&charset[0],0,
+#ifdef LANG_FINNISH
+LANG_FINNISH,
+#else
+0,
+#endif
+0,0,
+},
+{"fj","fiji",0,&charset[0],0,
+#ifdef LANG_FIJI
+LANG_FIJI,
+#else
+0,
+#endif
+0,0,
+},
+{"fo","faeroese",0,&charset[0],0,
+#ifdef LANG_FAEROESE
+LANG_FAEROESE,
+#else
+0,
+#endif
+0,0,
+},
+{"fr","french","fra|fre",&charset[0],0,
+#ifdef LANG_FRENCH
+LANG_FRENCH,
+#else
+0,
+#endif
+0,0,
+},
+{"fy","frisian",0,&charset[0],0,
+#ifdef LANG_FRISIAN
+LANG_FRISIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ga","irish",0,&charset[11],0,
+#ifdef LANG_IRISH
+LANG_IRISH,
+#else
+0,
+#endif
+0,0,
+},
+{"gd","scots-gaelic",0,&charset[11],0,
+#ifdef LANG_SCOTS_GAELIC
+LANG_SCOTS_GAELIC,
+#else
+0,
+#endif
+0,0,
+},
+{"gl","galician",0,&charset[0],0,
+#ifdef LANG_GALICIAN
+LANG_GALICIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"gn","guarani",0,&charset[0],0,
+#ifdef LANG_GUARANI
+LANG_GUARANI,
+#else
+0,
+#endif
+0,0,
+},
+{"gu","gujarati",0,&charset[0],0,
+#ifdef LANG_GUJARATI
+LANG_GUJARATI,
+#else
+0,
+#endif
+0,0,
+},
+{"ha","hausa",0,&charset[0],0,
+#ifdef LANG_HAUSA
+LANG_HAUSA,
+#else
+0,
+#endif
+0,0,
+},
+{"he","hebrew","heb",&charset[7],0,
+#ifdef LANG_HEBREW
+LANG_HEBREW,
+#else
+0,
+#endif
+0,0,
+},
+{"hi","hindi",0,&charset[0],0,
+#ifdef LANG_HINDI
+LANG_HINDI,
+#else
+0,
+#endif
+0,0,
+},
+{"hr","croatian","hrv|scr",&charset[1],0,
+#ifdef LANG_CROATIAN
+LANG_CROATIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"hu","hungarian","hun",&charset[1],0,
+#ifdef LANG_HUNGARIAN
+LANG_HUNGARIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"hy","armenian",0,&charset[0],0,
+#ifdef LANG_ARMENIAN
+LANG_ARMENIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ia","interlingua",0,&charset[0],0,
+#ifdef LANG_INTERLINGUA
+LANG_INTERLINGUA,
+#else
+0,
+#endif
+0,0,
+},
+{"id","indonesian","ind",&charset[0],0,
+#ifdef LANG_INDONESIAN
+LANG_INDONESIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ie","interlingue",0,&charset[0],0,
+#ifdef LANG_INTERLINGUE
+LANG_INTERLINGUE,
+#else
+0,
+#endif
+0,0,
+},
+{"ik","inupiak",0,&charset[0],0,
+#ifdef LANG_INUPIAK
+LANG_INUPIAK,
+#else
+0,
+#endif
+0,0,
+},
+{"in","indonesian",0,&charset[0],0,
+#ifdef LANG_INDONESIAN
+LANG_INDONESIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"is","icelandic","isl|ice",&charset[0],0,
+#ifdef LANG_ICELANDIC
+LANG_ICELANDIC,
+#else
+0,
+#endif
+0,0,
+},
+{"it","italian","ita",&charset[0],0,
+#ifdef LANG_ITALIAN
+LANG_ITALIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"iw","hebrew",0,&charset[0],0,
+#ifdef LANG_HEBREW
+LANG_HEBREW,
+#else
+0,
+#endif
+0,0,
+},
+{"ja","japanese","jpn",&charset[0],0,
+#ifdef LANG_JAPANESE
+LANG_JAPANESE,
+#else
+0,
+#endif
+0,0,
+},
+{"ji","yiddish",0,&charset[0],0,
+#ifdef LANG_YIDDISH
+LANG_YIDDISH,
+#else
+0,
+#endif
+0,0,
+},
+{"jw","javanese",0,&charset[0],0,
+#ifdef LANG_JAVANESE
+LANG_JAVANESE,
+#else
+0,
+#endif
+0,0,
+},
+{"ka","georgian",0,&charset[0],0,
+#ifdef LANG_GEORGIAN
+LANG_GEORGIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"kk","kazakh","kaz",&charset[0],0,
+#ifdef LANG_KAZAKH
+LANG_KAZAKH,
+#else
+0,
+#endif
+0,0,
+},
+{"kl","greenlandic",0,&charset[0],0,
+#ifdef LANG_GREENLANDIC
+LANG_GREENLANDIC,
+#else
+0,
+#endif
+0,0,
+},
+{"km","cambodian",0,&charset[0],0,
+#ifdef LANG_CAMBODIAN
+LANG_CAMBODIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"kn","kannada",0,&charset[0],0,
+#ifdef LANG_KANNADA
+LANG_KANNADA,
+#else
+0,
+#endif
+0,0,
+},
+{"ko","korean","kor",&charset[0],0,
+#ifdef LANG_KOREAN
+LANG_KOREAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ks","kashmiri",0,&charset[0],0,
+#ifdef LANG_KASHMIRI
+LANG_KASHMIRI,
+#else
+0,
+#endif
+0,0,
+},
+{"ku","kurdish",0,&charset[0],0,
+#ifdef LANG_KURDISH
+LANG_KURDISH,
+#else
+0,
+#endif
+0,0,
+},
+{"ky","kirghiz",0,&charset[0],0,
+#ifdef LANG_KIRGHIZ
+LANG_KIRGHIZ,
+#else
+0,
+#endif
+0,0,
+},
+{"la","latin",0,&charset[0],0,
+#ifdef LANG_LATIN
+LANG_LATIN,
+#else
+0,
+#endif
+0,0,
+},
+{"ln","lingala",0,&charset[0],0,
+#ifdef LANG_LINGALA
+LANG_LINGALA,
+#else
+0,
+#endif
+0,0,
+},
+{"lo","laothian",0,&charset[0],0,
+#ifdef LANG_LAOTHIAN
+LANG_LAOTHIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"lt","lithuanian","lit",&charset[10],0,
+#ifdef LANG_LITHUANIAN
+LANG_LITHUANIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"lv","latvian","lav",&charset[10],0,
+#ifdef LANG_LATVIAN
+LANG_LATVIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"mg","malagasy",0,&charset[0],0,
+#ifdef LANG_MALAGASY
+LANG_MALAGASY,
+#else
+0,
+#endif
+0,0,
+},
+{"mi","maori",0,&charset[0],0,
+#ifdef LANG_MAORI
+LANG_MAORI,
+#else
+0,
+#endif
+0,0,
+},
+{"mk","macedonian","mkd|mac",&charset[0],0,
+#ifdef LANG_MACEDONIAN
+LANG_MACEDONIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ml","malayalam","mal",&charset[0],0,
+#ifdef LANG_MALAYALAM
+LANG_MALAYALAM,
+#else
+0,
+#endif
+0,0,
+},
+{"mn","mongolian",0,&charset[0],0,
+#ifdef LANG_MONGOLIAN
+LANG_MONGOLIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"mo","moldavian",0,&charset[0],0,
+#ifdef LANG_MOLDAVIAN
+LANG_MOLDAVIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"mr","marathi",0,&charset[0],0,
+#ifdef LANG_MARATHI
+LANG_MARATHI,
+#else
+0,
+#endif
+0,0,
+},
+{"ms","malay","msa|may",&charset[0],0,
+#ifdef LANG_MALAY
+LANG_MALAY,
+#else
+0,
+#endif
+0,0,
+},
+{"mt","maltese",0,&charset[0],0,
+#ifdef LANG_MALTESE
+LANG_MALTESE,
+#else
+0,
+#endif
+0,0,
+},
+{"my","burmese",0,&charset[0],0,
+#ifdef LANG_BURMESE
+LANG_BURMESE,
+#else
+0,
+#endif
+0,0,
+},
+{"na","nauru",0,&charset[0],0,
+#ifdef LANG_NAURU
+LANG_NAURU,
+#else
+0,
+#endif
+0,0,
+},
+{"nb","norwegian-bokmal","nob",&charset[0],0,
+#ifdef LANG_NORWEGIAN_BOKMAL
+LANG_NORWEGIAN_BOKMAL,
+#else
+0,
+#endif
+0,0,
+},
+{"ne","nepali",0,&charset[0],0,
+#ifdef LANG_NEPALI
+LANG_NEPALI,
+#else
+0,
+#endif
+0,0,
+},
+{"nl","dutch","nld|dut",&charset[0],0,
+#ifdef LANG_DUTCH
+LANG_DUTCH,
+#else
+0,
+#endif
+0,0,
+},
+{"nn","norwegian-nynorsk","nno|non",&charset[0],0,
+#ifdef LANG_NORWEGIAN_NYNORSK
+LANG_NORWEGIAN_NYNORSK,
+#else
+0,
+#endif
+0,0,
+},
+{"no","norwegian","nor",&charset[0],0,
+#ifdef LANG_NORWEGIAN
+LANG_NORWEGIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"oc","occitan",0,&charset[0],0,
+#ifdef LANG_OCCITAN
+LANG_OCCITAN,
+#else
+0,
+#endif
+0,0,
+},
+{"om","oromo",0,&charset[0],0,
+#ifdef LANG_OROMO
+LANG_OROMO,
+#else
+0,
+#endif
+0,0,
+},
+{"or","oriya",0,&charset[0],0,
+#ifdef LANG_ORIYA
+LANG_ORIYA,
+#else
+0,
+#endif
+0,0,
+},
+{"pa","punjabi",0,&charset[0],0,
+#ifdef LANG_PUNJABI
+LANG_PUNJABI,
+#else
+0,
+#endif
+0,0,
+},
+{"pl","polish","pol",&charset[1],0,
+#ifdef LANG_POLISH
+LANG_POLISH,
+#else
+0,
+#endif
+0,0,
+},
+{"ps","pushto",0,&charset[0],0,
+#ifdef LANG_PUSHTO
+LANG_PUSHTO,
+#else
+0,
+#endif
+0,0,
+},
+{"pt","portuguese","por",&charset[0],0,
+#ifdef LANG_PORTUGUESE
+LANG_PORTUGUESE,
+#else
+0,
+#endif
+0,0,
+},
+{"qu","quechua",0,&charset[0],0,
+#ifdef LANG_QUECHUA
+LANG_QUECHUA,
+#else
+0,
+#endif
+0,0,
+},
+{"rm","rhaeto-romance",0,&charset[0],0,
+#ifdef LANG_RHAETO_ROMANCE
+LANG_RHAETO_ROMANCE,
+#else
+0,
+#endif
+0,0,
+},
+{"rn","kirundi",0,&charset[0],0,
+#ifdef LANG_KIRUNDI
+LANG_KIRUNDI,
+#else
+0,
+#endif
+0,0,
+},
+{"ro","romanian","ron|rum",&charset[1],0,
+#ifdef LANG_ROMANIAN
+LANG_ROMANIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ru","russian","rus",&charset[4],0,
+#ifdef LANG_RUSSIAN
+LANG_RUSSIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"rw","kinyarwanda",0,&charset[0],0,
+#ifdef LANG_KINYARWANDA
+LANG_KINYARWANDA,
+#else
+0,
+#endif
+0,0,
+},
+{"sa","sanskrit",0,&charset[0],0,
+#ifdef LANG_SANSKRIT
+LANG_SANSKRIT,
+#else
+0,
+#endif
+0,0,
+},
+{"sd","sindhi",0,&charset[0],0,
+#ifdef LANG_SINDHI
+LANG_SINDHI,
+#else
+0,
+#endif
+0,0,
+},
+{"sg","sangro",0,&charset[0],0,
+#ifdef LANG_SANGRO
+LANG_SANGRO,
+#else
+0,
+#endif
+0,0,
+},
+{"sh","serbo-croatian",0,&charset[0],0,
+#ifdef LANG_SERBO_CROATIAN
+LANG_SERBO_CROATIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"si","singhalese",0,&charset[0],0,
+#ifdef LANG_SINGHALESE
+LANG_SINGHALESE,
+#else
+0,
+#endif
+0,0,
+},
+{"sk","slovak","slk|slo",&charset[1],0,
+#ifdef LANG_SLOVAK
+LANG_SLOVAK,
+#else
+0,
+#endif
+0,0,
+},
+{"sl","slovenian","slv",&charset[1],0,
+#ifdef LANG_SLOVENIAN
+LANG_SLOVENIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"sm","samoan",0,&charset[0],0,
+#ifdef LANG_SAMOAN
+LANG_SAMOAN,
+#else
+0,
+#endif
+0,0,
+},
+{"sn","shona",0,&charset[0],0,
+#ifdef LANG_SHONA
+LANG_SHONA,
+#else
+0,
+#endif
+0,0,
+},
+{"so","somali",0,&charset[0],0,
+#ifdef LANG_SOMALI
+LANG_SOMALI,
+#else
+0,
+#endif
+0,0,
+},
+{"sq","albanian","sqi|alb",&charset[0],0,
+#ifdef LANG_ALBANIAN
+LANG_ALBANIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"sr","serbian","srp",&charset[1],0,
+#ifdef LANG_SERBIAN
+LANG_SERBIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ss","siswati",0,&charset[0],0,
+#ifdef LANG_SISWATI
+LANG_SISWATI,
+#else
+0,
+#endif
+0,0,
+},
+{"st","sesotho",0,&charset[0],0,
+#ifdef LANG_SESOTHO
+LANG_SESOTHO,
+#else
+0,
+#endif
+0,0,
+},
+{"su","sudanese",0,&charset[0],0,
+#ifdef LANG_SUDANESE
+LANG_SUDANESE,
+#else
+0,
+#endif
+0,0,
+},
+{"sv","swedish","swe",&charset[0],0,
+#ifdef LANG_SWEDISH
+LANG_SWEDISH,
+#else
+0,
+#endif
+0,0,
+},
+{"sw","swahili","swa",&charset[0],0,
+#ifdef LANG_SWAHILI
+LANG_SWAHILI,
+#else
+0,
+#endif
+0,0,
+},
+{"ta","tamil",0,&charset[0],0,
+#ifdef LANG_TAMIL
+LANG_TAMIL,
+#else
+0,
+#endif
+0,0,
+},
+{"te","telugu",0,&charset[0],0,
+#ifdef LANG_TELUGU
+LANG_TELUGU,
+#else
+0,
+#endif
+0,0,
+},
+{"tg","tajik",0,&charset[0],0,
+#ifdef LANG_TAJIK
+LANG_TAJIK,
+#else
+0,
+#endif
+0,0,
+},
+{"th","thai","tha",&charset[0],0,
+#ifdef LANG_THAI
+LANG_THAI,
+#else
+0,
+#endif
+0,0,
+},
+{"ti","tigrinya",0,&charset[0],0,
+#ifdef LANG_TIGRINYA
+LANG_TIGRINYA,
+#else
+0,
+#endif
+0,0,
+},
+{"tk","turkmen",0,&charset[0],0,
+#ifdef LANG_TURKMEN
+LANG_TURKMEN,
+#else
+0,
+#endif
+0,0,
+},
+{"tl","tagalog",0,&charset[0],0,
+#ifdef LANG_TAGALOG
+LANG_TAGALOG,
+#else
+0,
+#endif
+0,0,
+},
+{"tn","setswana",0,&charset[0],0,
+#ifdef LANG_SETSWANA
+LANG_SETSWANA,
+#else
+0,
+#endif
+0,0,
+},
+{"to","tonga",0,&charset[0],0,
+#ifdef LANG_TONGA
+LANG_TONGA,
+#else
+0,
+#endif
+0,0,
+},
+{"tr","turkish","tur",&charset[8],0,
+#ifdef LANG_TURKISH
+LANG_TURKISH,
+#else
+0,
+#endif
+0,0,
+},
+{"ts","tsonga",0,&charset[0],0,
+#ifdef LANG_TSONGA
+LANG_TSONGA,
+#else
+0,
+#endif
+0,0,
+},
+{"tt","tatar","tat",&charset[0],0,
+#ifdef LANG_TATAR
+LANG_TATAR,
+#else
+0,
+#endif
+0,0,
+},
+{"tw","chinese-traditional","cht",&charset[0],0,
+#ifdef LANG_CHINESE_TRADITIONAL
+LANG_CHINESE_TRADITIONAL,
+#else
+0,
+#endif
+0,0,
+},
+{"uk","ukrainian","ukr",&charset[4],0,
+#ifdef LANG_UKRAINIAN
+LANG_UKRAINIAN,
+#else
+0,
+#endif
+0,0,
+},
+{"ur","urdu",0,&charset[0],0,
+#ifdef LANG_URDU
+LANG_URDU,
+#else
+0,
+#endif
+0,0,
+},
+{"uz","uzbek","uzb",&charset[0],0,
+#ifdef LANG_UZBEK
+LANG_UZBEK,
+#else
+0,
+#endif
+0,0,
+},
+{"vi","vietnamese",0,&charset[0],0,
+#ifdef LANG_VIETNAMESE
+LANG_VIETNAMESE,
+#else
+0,
+#endif
+0,0,
+},
+{"vo","volapuk",0,&charset[0],0,
+#ifdef LANG_VOLAPUK
+LANG_VOLAPUK,
+#else
+0,
+#endif
+0,0,
+},
+{"wo","wolof",0,&charset[0],0,
+#ifdef LANG_WOLOF
+LANG_WOLOF,
+#else
+0,
+#endif
+0,0,
+},
+{"xh","xhosa",0,&charset[0],0,
+#ifdef LANG_XHOSA
+LANG_XHOSA,
+#else
+0,
+#endif
+0,0,
+},
+{"yo","yoruba",0,&charset[0],0,
+#ifdef LANG_YORUBA
+LANG_YORUBA,
+#else
+0,
+#endif
+0,0,
+},
+{"zh","chinese-simplified","zho|chi|chs",&charset[0],0,
+#ifdef LANG_CHINESE_SIMPLIFIED
+LANG_CHINESE_SIMPLIFIED,
+#else
+0,
+#endif
+0,0,
+},
+{"zu","zulu",0,&charset[0],0,
+#ifdef LANG_ZULU
+LANG_ZULU,
+#else
+0,
+#endif
+0,0,
+},
+ 0
+};
+
+static const Lc_territory_t territory[] =
+{
+{"C","C",LC_default,0,&language[0],0,0,0,0,0,0,0,},
+{"debug","debug",LC_debug,0,&language[1],0,0,0,0,0,0,0,},
+{"al","albania",0,
+#ifdef CTRY_ALBANIA
+CTRY_ALBANIA,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"an","netherlands-antilles",0,
+#ifdef CTRY_NETHERLANDS_ANTILLES
+CTRY_NETHERLANDS_ANTILLES,
+#else
+0,
+#endif
+&language[86],0,0,0,
+#ifdef SUBLANG_DUTCH_NETHERLANDS_ANTILLES
+SUBLANG_DUTCH_NETHERLANDS_ANTILLES,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ar","argentina",0,
+#ifdef CTRY_ARGENTINA
+CTRY_ARGENTINA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_ARGENTINA
+SUBLANG_SPANISH_ARGENTINA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"at","austria",0,
+#ifdef CTRY_AUSTRIA
+CTRY_AUSTRIA,
+#else
+0,
+#endif
+&language[23],0,0,0,
+#ifdef SUBLANG_GERMAN_AUSTRIA
+SUBLANG_GERMAN_AUSTRIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"au","australia",0,
+#ifdef CTRY_AUSTRALIA
+CTRY_AUSTRALIA,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_AUSTRALIA
+SUBLANG_ENGLISH_AUSTRALIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"az","azerbaijan",0,
+#ifdef CTRY_AZERBAIJAN
+CTRY_AZERBAIJAN,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"be","belgium",0,
+#ifdef CTRY_BELGIUM
+CTRY_BELGIUM,
+#else
+0,
+#endif
+&language[86],&language[35],&language[23],0,
+#ifdef SUBLANG_DUTCH_BELGIUM
+SUBLANG_DUTCH_BELGIUM,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_FRENCH_BELGIUM
+SUBLANG_FRENCH_BELGIUM,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_GERMAN_BELGIUM
+SUBLANG_GERMAN_BELGIUM,
+#else
+0,
+#endif
+0,
+},
+{"bg","bulgaria",0,
+#ifdef CTRY_BULGARIA
+CTRY_BULGARIA,
+#else
+0,
+#endif
+&language[12],0,0,0,
+#ifdef SUBLANG_BULGARIAN_BULGARIA
+SUBLANG_BULGARIAN_BULGARIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"bn","brunei-darussalam",0,
+#ifdef CTRY_BRUNEI_DARUSSALAM
+CTRY_BRUNEI_DARUSSALAM,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_BRUNEI_DARUSSALAM
+SUBLANG_ARABIC_BRUNEI_DARUSSALAM,
+#else
+0,
+#endif
+0,0,0,
+},
+{"bo","bolivia",0,
+#ifdef CTRY_BOLIVIA
+CTRY_BOLIVIA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_BOLIVIA
+SUBLANG_SPANISH_BOLIVIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"br","brazil",0,
+#ifdef CTRY_BRAZIL
+CTRY_BRAZIL,
+#else
+0,
+#endif
+&language[95],0,0,0,
+#ifdef SUBLANG_PORTUGUESE_BRAZIL
+SUBLANG_PORTUGUESE_BRAZIL,
+#else
+0,
+#endif
+0,0,0,
+},
+{"bw","botswana",0,
+#ifdef CTRY_BOTSWANA
+CTRY_BOTSWANA,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_BOTSWANA
+SUBLANG_ENGLISH_BOTSWANA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"by","belarus",0,
+#ifdef CTRY_BELARUS
+CTRY_BELARUS,
+#else
+0,
+#endif
+&language[100],0,0,0,
+#ifdef SUBLANG_RUSSIAN_BELARUS
+SUBLANG_RUSSIAN_BELARUS,
+#else
+0,
+#endif
+0,0,0,
+},
+{"bz","belize",0,
+#ifdef CTRY_BELIZE
+CTRY_BELIZE,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_BELIZE
+SUBLANG_ENGLISH_BELIZE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ca","canada",0,
+#ifdef CTRY_CANADA
+CTRY_CANADA,
+#else
+0,
+#endif
+&language[26],&language[35],0,0,
+#ifdef SUBLANG_ENGLISH_CANADA
+SUBLANG_ENGLISH_CANADA,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_FRENCH_CANADA
+SUBLANG_FRENCH_CANADA,
+#else
+0,
+#endif
+0,0,
+},
+{"ch","switzerland",0,
+#ifdef CTRY_SWITZERLAND
+CTRY_SWITZERLAND,
+#else
+0,
+#endif
+&language[35],&language[23],&language[54],0,
+#ifdef SUBLANG_FRENCH_SWITZERLAND
+SUBLANG_FRENCH_SWITZERLAND,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_GERMAN_SWITZERLAND
+SUBLANG_GERMAN_SWITZERLAND,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_ITALIAN_SWITZERLAND
+SUBLANG_ITALIAN_SWITZERLAND,
+#else
+0,
+#endif
+0,
+},
+{"cl","chile",0,
+#ifdef CTRY_CHILE
+CTRY_CHILE,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_CHILE
+SUBLANG_SPANISH_CHILE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"cn","china",LC_primary,
+#ifdef CTRY_CHINA
+CTRY_CHINA,
+#else
+0,
+#endif
+&language[140],0,0,0,
+#ifdef SUBLANG_CHINESE_SIMPLIFIED_CHINA
+SUBLANG_CHINESE_SIMPLIFIED_CHINA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"co","colombia",0,
+#ifdef CTRY_COLOMBIA
+CTRY_COLOMBIA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_COLOMBIA
+SUBLANG_SPANISH_COLOMBIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"cr","costa-rica",0,
+#ifdef CTRY_COSTA_RICA
+CTRY_COSTA_RICA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_COSTA_RICA
+SUBLANG_SPANISH_COSTA_RICA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"cz","czech-republic",0,
+#ifdef CTRY_CZECH_REPUBLIC
+CTRY_CZECH_REPUBLIC,
+#else
+0,
+#endif
+&language[20],0,0,0,
+#ifdef SUBLANG_CZECH_CZECH_REPUBLIC
+SUBLANG_CZECH_CZECH_REPUBLIC,
+#else
+0,
+#endif
+0,0,0,
+},
+{"de","germany",0,
+#ifdef CTRY_GERMANY
+CTRY_GERMANY,
+#else
+0,
+#endif
+&language[23],0,0,0,
+#ifdef SUBLANG_GERMAN_GERMANY
+SUBLANG_GERMAN_GERMANY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"dk","denmark",0,
+#ifdef CTRY_DENMARK
+CTRY_DENMARK,
+#else
+0,
+#endif
+&language[22],&language[26],0,0,
+#ifdef SUBLANG_DANISH_DENMARK
+SUBLANG_DANISH_DENMARK,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_ENGLISH_DENMARK
+SUBLANG_ENGLISH_DENMARK,
+#else
+0,
+#endif
+0,0,
+},
+{"do","dominican-republic",0,
+#ifdef CTRY_DOMINICAN_REPUBLIC
+CTRY_DOMINICAN_REPUBLIC,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
+SUBLANG_SPANISH_DOMINICAN_REPUBLIC,
+#else
+0,
+#endif
+0,0,0,
+},
+{"dz","algeria",0,
+#ifdef CTRY_ALGERIA
+CTRY_ALGERIA,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"ec","ecuador",0,
+#ifdef CTRY_ECUADOR
+CTRY_ECUADOR,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_ECUADOR
+SUBLANG_SPANISH_ECUADOR,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ee","estonia",0,
+#ifdef CTRY_ESTONIA
+CTRY_ESTONIA,
+#else
+0,
+#endif
+&language[29],0,0,0,
+#ifdef SUBLANG_ESTONIAN_ESTONIA
+SUBLANG_ESTONIAN_ESTONIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"eg","egypt",0,
+#ifdef CTRY_EGYPT
+CTRY_EGYPT,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_EGYPT
+SUBLANG_ARABIC_EGYPT,
+#else
+0,
+#endif
+0,0,0,
+},
+{"es","spain",0,
+#ifdef CTRY_SPAIN
+CTRY_SPAIN,
+#else
+0,
+#endif
+&language[28],&language[18],&language[30],&language[39],
+#ifdef SUBLANG_SPANISH_SPAIN
+SUBLANG_SPANISH_SPAIN,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_CATALAN_SPAIN
+SUBLANG_CATALAN_SPAIN,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_BASQUE_SPAIN
+SUBLANG_BASQUE_SPAIN,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_GALICIAN_SPAIN
+SUBLANG_GALICIAN_SPAIN,
+#else
+0,
+#endif
+
+},
+{"fi","finland",0,
+#ifdef CTRY_FINLAND
+CTRY_FINLAND,
+#else
+0,
+#endif
+&language[117],0,0,0,
+#ifdef SUBLANG_SWEDISH_FINLAND
+SUBLANG_SWEDISH_FINLAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"fo","faroe-islands",0,
+#ifdef CTRY_FAROE_ISLANDS
+CTRY_FAROE_ISLANDS,
+#else
+0,
+#endif
+&language[34],0,0,0,
+#ifdef SUBLANG_FAEROESE_FAROE_ISLANDS
+SUBLANG_FAEROESE_FAROE_ISLANDS,
+#else
+0,
+#endif
+0,0,0,
+},
+{"fr","france",0,
+#ifdef CTRY_FRANCE
+CTRY_FRANCE,
+#else
+0,
+#endif
+&language[35],0,0,0,
+#ifdef SUBLANG_FRENCH_FRANCE
+SUBLANG_FRENCH_FRANCE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"gb","united-kingdom|great-britain|england",LC_primary,
+#ifdef CTRY_UNITED_KINGDOM
+CTRY_UNITED_KINGDOM,
+#else
+#ifdef CTRY_GREAT_BRITAIN
+CTRY_GREAT_BRITAIN,
+#else
+#ifdef CTRY_ENGLAND
+CTRY_ENGLAND,
+#else
+0,
+#endif
+#endif
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_UNITED_KINGDOM
+SUBLANG_ENGLISH_UNITED_KINGDOM,
+#else
+#ifdef SUBLANG_ENGLISH_GREAT_BRITAIN
+SUBLANG_ENGLISH_GREAT_BRITAIN,
+#else
+#ifdef SUBLANG_ENGLISH_ENGLAND
+SUBLANG_ENGLISH_ENGLAND,
+#else
+0,
+#endif
+#endif
+#endif
+0,0,0,
+},
+{"gl","greenland",0,
+#ifdef CTRY_GREENLAND
+CTRY_GREENLAND,
+#else
+0,
+#endif
+&language[61],0,0,0,
+#ifdef SUBLANG_GREENLANDIC_GREENLAND
+SUBLANG_GREENLANDIC_GREENLAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"gr","greece",0,
+#ifdef CTRY_GREECE
+CTRY_GREECE,
+#else
+0,
+#endif
+&language[25],0,0,0,
+#ifdef SUBLANG_GREEK_GREECE
+SUBLANG_GREEK_GREECE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"gt","guatemala",0,
+#ifdef CTRY_GUATEMALA
+CTRY_GUATEMALA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_GUATEMALA
+SUBLANG_SPANISH_GUATEMALA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"hk","hong-kong",0,
+#ifdef CTRY_HONG_KONG
+CTRY_HONG_KONG,
+#else
+0,
+#endif
+&language[140],0,0,0,
+#ifdef SUBLANG_CHINESE_SIMPLIFIED_HONG_KONG
+SUBLANG_CHINESE_SIMPLIFIED_HONG_KONG,
+#else
+0,
+#endif
+0,0,0,
+},
+{"hn","honduras",0,
+#ifdef CTRY_HONDURAS
+CTRY_HONDURAS,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_HONDURAS
+SUBLANG_SPANISH_HONDURAS,
+#else
+0,
+#endif
+0,0,0,
+},
+{"hr","croatia",0,
+#ifdef CTRY_CROATIA
+CTRY_CROATIA,
+#else
+0,
+#endif
+&language[45],0,0,0,
+#ifdef SUBLANG_CROATIAN_CROATIA
+SUBLANG_CROATIAN_CROATIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"hu","hungary",0,
+#ifdef CTRY_HUNGARY
+CTRY_HUNGARY,
+#else
+0,
+#endif
+&language[46],0,0,0,
+#ifdef SUBLANG_HUNGARIAN_HUNGARY
+SUBLANG_HUNGARIAN_HUNGARY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"id","indonesia",0,
+#ifdef CTRY_INDONESIA
+CTRY_INDONESIA,
+#else
+0,
+#endif
+&language[49],0,0,0,
+#ifdef SUBLANG_INDONESIAN_INDONESIA
+SUBLANG_INDONESIAN_INDONESIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ie","ireland",0,
+#ifdef CTRY_IRELAND
+CTRY_IRELAND,
+#else
+0,
+#endif
+&language[26],&language[37],0,0,
+#ifdef SUBLANG_ENGLISH_IRELAND
+SUBLANG_ENGLISH_IRELAND,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_IRISH_IRELAND
+SUBLANG_IRISH_IRELAND,
+#else
+0,
+#endif
+0,0,
+},
+{"il","israel",0,
+#ifdef CTRY_ISRAEL
+CTRY_ISRAEL,
+#else
+0,
+#endif
+&language[43],0,0,0,
+#ifdef SUBLANG_HEBREW_ISRAEL
+SUBLANG_HEBREW_ISRAEL,
+#else
+0,
+#endif
+0,0,0,
+},
+{"iq","iraq",0,
+#ifdef CTRY_IRAQ
+CTRY_IRAQ,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_IRAQ
+SUBLANG_ARABIC_IRAQ,
+#else
+0,
+#endif
+0,0,0,
+},
+{"is","iceland",0,
+#ifdef CTRY_ICELAND
+CTRY_ICELAND,
+#else
+0,
+#endif
+&language[53],0,0,0,
+#ifdef SUBLANG_ICELANDIC_ICELAND
+SUBLANG_ICELANDIC_ICELAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"it","italy",0,
+#ifdef CTRY_ITALY
+CTRY_ITALY,
+#else
+0,
+#endif
+&language[54],0,0,0,
+#ifdef SUBLANG_ITALIAN_ITALY
+SUBLANG_ITALIAN_ITALY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"jm","jamaica",0,
+#ifdef CTRY_JAMAICA
+CTRY_JAMAICA,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_JAMAICA
+SUBLANG_ENGLISH_JAMAICA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"jo","jordan",0,
+#ifdef CTRY_JORDAN
+CTRY_JORDAN,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_JORDAN
+SUBLANG_ARABIC_JORDAN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"jp","japan",0,
+#ifdef CTRY_JAPAN
+CTRY_JAPAN,
+#else
+0,
+#endif
+&language[56],0,0,0,
+#ifdef SUBLANG_JAPANESE_JAPAN
+SUBLANG_JAPANESE_JAPAN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ke","kenya",0,
+#ifdef CTRY_KENYA
+CTRY_KENYA,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"kr","south-korea",0,
+#ifdef CTRY_SOUTH_KOREA
+CTRY_SOUTH_KOREA,
+#else
+0,
+#endif
+&language[64],0,0,0,
+#ifdef SUBLANG_KOREAN_SOUTH_KOREA
+SUBLANG_KOREAN_SOUTH_KOREA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"kw","kuwait",0,
+#ifdef CTRY_KUWAIT
+CTRY_KUWAIT,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_KUWAIT
+SUBLANG_ARABIC_KUWAIT,
+#else
+0,
+#endif
+0,0,0,
+},
+{"lb","lebanon",0,
+#ifdef CTRY_LEBANON
+CTRY_LEBANON,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_LEBANON
+SUBLANG_ARABIC_LEBANON,
+#else
+0,
+#endif
+0,0,0,
+},
+{"li","liechtenstein",0,
+#ifdef CTRY_LIECHTENSTEIN
+CTRY_LIECHTENSTEIN,
+#else
+0,
+#endif
+&language[23],&language[35],0,0,
+#ifdef SUBLANG_GERMAN_LIECHTENSTEIN
+SUBLANG_GERMAN_LIECHTENSTEIN,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_FRENCH_LIECHTENSTEIN
+SUBLANG_FRENCH_LIECHTENSTEIN,
+#else
+0,
+#endif
+0,0,
+},
+{"lt","lithuania",0,
+#ifdef CTRY_LITHUANIA
+CTRY_LITHUANIA,
+#else
+0,
+#endif
+&language[71],0,0,0,
+#ifdef SUBLANG_LITHUANIAN_LITHUANIA
+SUBLANG_LITHUANIAN_LITHUANIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"lu","luxembourg",0,
+#ifdef CTRY_LUXEMBOURG
+CTRY_LUXEMBOURG,
+#else
+0,
+#endif
+&language[23],&language[35],0,0,
+#ifdef SUBLANG_GERMAN_LUXEMBOURG
+SUBLANG_GERMAN_LUXEMBOURG,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_FRENCH_LUXEMBOURG
+SUBLANG_FRENCH_LUXEMBOURG,
+#else
+0,
+#endif
+0,0,
+},
+{"lv","latvia",0,
+#ifdef CTRY_LATVIA
+CTRY_LATVIA,
+#else
+0,
+#endif
+&language[72],0,0,0,
+#ifdef SUBLANG_LATVIAN_LATVIA
+SUBLANG_LATVIAN_LATVIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ly","libya",0,
+#ifdef CTRY_LIBYA
+CTRY_LIBYA,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_LIBYA
+SUBLANG_ARABIC_LIBYA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ma","morocco",0,
+#ifdef CTRY_MOROCCO
+CTRY_MOROCCO,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_MOROCCO
+SUBLANG_ARABIC_MOROCCO,
+#else
+0,
+#endif
+0,0,0,
+},
+{"mk","macedonia",0,
+#ifdef CTRY_MACEDONIA
+CTRY_MACEDONIA,
+#else
+0,
+#endif
+&language[75],0,0,0,
+#ifdef SUBLANG_MACEDONIAN_MACEDONIA
+SUBLANG_MACEDONIAN_MACEDONIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"mo","macau",0,
+#ifdef CTRY_MACAU
+CTRY_MACAU,
+#else
+0,
+#endif
+&language[140],0,0,0,
+#ifdef SUBLANG_CHINESE_SIMPLIFIED_MACAU
+SUBLANG_CHINESE_SIMPLIFIED_MACAU,
+#else
+0,
+#endif
+0,0,0,
+},
+{"mx","mexico",0,
+#ifdef CTRY_MEXICO
+CTRY_MEXICO,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_MEXICO
+SUBLANG_SPANISH_MEXICO,
+#else
+0,
+#endif
+0,0,0,
+},
+{"my","malaysia",0,
+#ifdef CTRY_MALAYSIA
+CTRY_MALAYSIA,
+#else
+0,
+#endif
+0,0,0,0,0,0,0,0,
+},
+{"ni","nicaragua",0,
+#ifdef CTRY_NICARAGUA
+CTRY_NICARAGUA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_NICARAGUA
+SUBLANG_SPANISH_NICARAGUA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"nl","netherlands",0,
+#ifdef CTRY_NETHERLANDS
+CTRY_NETHERLANDS,
+#else
+0,
+#endif
+&language[86],0,0,0,
+#ifdef SUBLANG_DUTCH_NETHERLANDS
+SUBLANG_DUTCH_NETHERLANDS,
+#else
+0,
+#endif
+0,0,0,
+},
+{"no","norway",0,
+#ifdef CTRY_NORWAY
+CTRY_NORWAY,
+#else
+0,
+#endif
+&language[84],&language[88],&language[87],0,
+#ifdef SUBLANG_NORWEGIAN_BOKMAL_NORWAY
+SUBLANG_NORWEGIAN_BOKMAL_NORWAY,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_NORWEGIAN_NORWAY
+SUBLANG_NORWEGIAN_NORWAY,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_NORWEGIAN_NYNORSK_NORWAY
+SUBLANG_NORWEGIAN_NYNORSK_NORWAY,
+#else
+0,
+#endif
+0,
+},
+{"nz","new-zealand",0,
+#ifdef CTRY_NEW_ZEALAND
+CTRY_NEW_ZEALAND,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_NEW_ZEALAND
+SUBLANG_ENGLISH_NEW_ZEALAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"om","oman",0,
+#ifdef CTRY_OMAN
+CTRY_OMAN,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_OMAN
+SUBLANG_ARABIC_OMAN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pa","panama",0,
+#ifdef CTRY_PANAMA
+CTRY_PANAMA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_PANAMA
+SUBLANG_SPANISH_PANAMA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pe","peru",0,
+#ifdef CTRY_PERU
+CTRY_PERU,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_PERU
+SUBLANG_SPANISH_PERU,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pl","poland",0,
+#ifdef CTRY_POLAND
+CTRY_POLAND,
+#else
+0,
+#endif
+&language[93],0,0,0,
+#ifdef SUBLANG_POLISH_POLAND
+SUBLANG_POLISH_POLAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pr","puerto-rico",0,
+#ifdef CTRY_PUERTO_RICO
+CTRY_PUERTO_RICO,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_PUERTO_RICO
+SUBLANG_SPANISH_PUERTO_RICO,
+#else
+0,
+#endif
+0,0,0,
+},
+{"pt","portugal",0,
+#ifdef CTRY_PORTUGAL
+CTRY_PORTUGAL,
+#else
+0,
+#endif
+&language[95],0,0,0,
+#ifdef SUBLANG_PORTUGUESE_PORTUGAL
+SUBLANG_PORTUGUESE_PORTUGAL,
+#else
+0,
+#endif
+0,0,0,
+},
+{"py","paraguay",0,
+#ifdef CTRY_PARAGUAY
+CTRY_PARAGUAY,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_PARAGUAY
+SUBLANG_SPANISH_PARAGUAY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ro","romania",0,
+#ifdef CTRY_ROMANIA
+CTRY_ROMANIA,
+#else
+0,
+#endif
+&language[99],0,0,0,
+#ifdef SUBLANG_ROMANIAN_ROMANIA
+SUBLANG_ROMANIAN_ROMANIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ru","russia",0,
+#ifdef CTRY_RUSSIA
+CTRY_RUSSIA,
+#else
+0,
+#endif
+&language[100],0,0,0,
+#ifdef SUBLANG_RUSSIAN_RUSSIA
+SUBLANG_RUSSIAN_RUSSIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sa","saudi-arabia",0,
+#ifdef CTRY_SAUDI_ARABIA
+CTRY_SAUDI_ARABIA,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_SAUDI_ARABIA
+SUBLANG_ARABIC_SAUDI_ARABIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"se","sweden",LC_primary,
+#ifdef CTRY_SWEDEN
+CTRY_SWEDEN,
+#else
+0,
+#endif
+&language[117],0,0,0,
+#ifdef SUBLANG_SWEDISH_SWEDEN
+SUBLANG_SWEDISH_SWEDEN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sg","singapore",0,
+#ifdef CTRY_SINGAPORE
+CTRY_SINGAPORE,
+#else
+0,
+#endif
+&language[140],0,0,0,
+#ifdef SUBLANG_CHINESE_SIMPLIFIED_SINGAPORE
+SUBLANG_CHINESE_SIMPLIFIED_SINGAPORE,
+#else
+0,
+#endif
+0,0,0,
+},
+{"si","slovenia",0,
+#ifdef CTRY_SLOVENIA
+CTRY_SLOVENIA,
+#else
+0,
+#endif
+&language[108],0,0,0,
+#ifdef SUBLANG_SLOVENIAN_SLOVENIA
+SUBLANG_SLOVENIAN_SLOVENIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sk","slovakia",0,
+#ifdef CTRY_SLOVAKIA
+CTRY_SLOVAKIA,
+#else
+0,
+#endif
+&language[107],0,0,0,
+#ifdef SUBLANG_SLOVAK_SLOVAKIA
+SUBLANG_SLOVAK_SLOVAKIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sp","serbia",0,
+#ifdef CTRY_SERBIA
+CTRY_SERBIA,
+#else
+0,
+#endif
+&language[113],0,0,0,
+#ifdef SUBLANG_SERBIAN_SERBIA
+SUBLANG_SERBIAN_SERBIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sv","el-salvador",0,
+#ifdef CTRY_EL_SALVADOR
+CTRY_EL_SALVADOR,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_EL_SALVADOR
+SUBLANG_SPANISH_EL_SALVADOR,
+#else
+0,
+#endif
+0,0,0,
+},
+{"sy","syria",0,
+#ifdef CTRY_SYRIA
+CTRY_SYRIA,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_SYRIA
+SUBLANG_ARABIC_SYRIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"th","thailand",0,
+#ifdef CTRY_THAILAND
+CTRY_THAILAND,
+#else
+0,
+#endif
+&language[122],0,0,0,
+#ifdef SUBLANG_THAI_THAILAND
+SUBLANG_THAI_THAILAND,
+#else
+0,
+#endif
+0,0,0,
+},
+{"tn","tunisia",0,
+#ifdef CTRY_TUNISIA
+CTRY_TUNISIA,
+#else
+0,
+#endif
+&language[6],0,0,0,
+#ifdef SUBLANG_ARABIC_TUNISIA
+SUBLANG_ARABIC_TUNISIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"tr","turkey",0,
+#ifdef CTRY_TURKEY
+CTRY_TURKEY,
+#else
+0,
+#endif
+&language[128],0,0,0,
+#ifdef SUBLANG_TURKISH_TURKEY
+SUBLANG_TURKISH_TURKEY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"tt","trinidad&tobago",0,
+#ifdef CTRY_TRINIDAD_TOBAGO
+CTRY_TRINIDAD_TOBAGO,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_TRINIDAD_TOBAGO
+SUBLANG_ENGLISH_TRINIDAD_TOBAGO,
+#else
+0,
+#endif
+0,0,0,
+},
+{"tw","taiwan",0,
+#ifdef CTRY_TAIWAN
+CTRY_TAIWAN,
+#else
+0,
+#endif
+&language[131],0,0,0,
+#ifdef SUBLANG_CHINESE_TRADITIONAL_TAIWAN
+SUBLANG_CHINESE_TRADITIONAL_TAIWAN,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ua","ukraine",0,
+#ifdef CTRY_UKRAINE
+CTRY_UKRAINE,
+#else
+0,
+#endif
+&language[132],&language[100],0,0,
+#ifdef SUBLANG_UKRAINIAN_UKRAINE
+SUBLANG_UKRAINIAN_UKRAINE,
+#else
+0,
+#endif
+
+#ifdef SUBLANG_RUSSIAN_UKRAINE
+SUBLANG_RUSSIAN_UKRAINE,
+#else
+0,
+#endif
+0,0,
+},
+{"uk","united-kingdom",LC_primary,
+#ifdef CTRY_UNITED_KINGDOM
+CTRY_UNITED_KINGDOM,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_UNITED_KINGDOM
+SUBLANG_ENGLISH_UNITED_KINGDOM,
+#else
+0,
+#endif
+0,0,0,
+},
+{"us","united-states|usa",0,
+#ifdef CTRY_UNITED_STATES
+CTRY_UNITED_STATES,
+#else
+#ifdef CTRY_USA
+CTRY_USA,
+#else
+0,
+#endif
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_UNITED_STATES
+SUBLANG_ENGLISH_UNITED_STATES,
+#else
+#ifdef SUBLANG_ENGLISH_USA
+SUBLANG_ENGLISH_USA,
+#else
+0,
+#endif
+#endif
+0,0,0,
+},
+{"uy","uruguay",0,
+#ifdef CTRY_URUGUAY
+CTRY_URUGUAY,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_URUGUAY
+SUBLANG_SPANISH_URUGUAY,
+#else
+0,
+#endif
+0,0,0,
+},
+{"ve","venezuela",0,
+#ifdef CTRY_VENEZUELA
+CTRY_VENEZUELA,
+#else
+0,
+#endif
+&language[28],0,0,0,
+#ifdef SUBLANG_SPANISH_VENEZUELA
+SUBLANG_SPANISH_VENEZUELA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"yu","yugoslavia",0,
+#ifdef CTRY_YUGOSLAVIA
+CTRY_YUGOSLAVIA,
+#else
+0,
+#endif
+&language[113],0,0,0,
+#ifdef SUBLANG_SERBIAN_YUGOSLAVIA
+SUBLANG_SERBIAN_YUGOSLAVIA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"za","south-africa",0,
+#ifdef CTRY_SOUTH_AFRICA
+CTRY_SOUTH_AFRICA,
+#else
+0,
+#endif
+&language[4],0,0,0,
+#ifdef SUBLANG_AFRIKAANS_SOUTH_AFRICA
+SUBLANG_AFRIKAANS_SOUTH_AFRICA,
+#else
+0,
+#endif
+0,0,0,
+},
+{"zw","zimbabwe",0,
+#ifdef CTRY_ZIMBABWE
+CTRY_ZIMBABWE,
+#else
+0,
+#endif
+&language[26],0,0,0,
+#ifdef SUBLANG_ENGLISH_ZIMBABWE
+SUBLANG_ENGLISH_ZIMBABWE,
+#else
+0,
+#endif
+0,0,0,
+},
+ 0
+};
+
+static const Lc_map_t map[] =
+{
+{"enu",&language[26],&territory[93],&charset[0],0},
+{"enz",&language[26],&territory[68],&charset[0],0},
+{"esm",&language[28],&territory[63],&charset[0],0},
+{"esn",&language[28],&territory[30],&charset[0],&attribute_es[1]},
+{"esp",&language[28],&territory[30],&charset[0],&attribute_es[0]},
+{"usa",&language[26],&territory[93],&charset[0],0},
+ 0
+};
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/preroot.h b/usr/src/lib/libast/sparcv9/src/lib/libast/preroot.h
new file mode 100644
index 0000000000..508e3aada4
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/preroot.h
@@ -0,0 +1,6 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/preroot.sh by iffe version 2007-04-04 : : */
+#ifndef _def_preroot_ast
+#define _def_preroot_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+/* preroot not enabled */
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/sig.h b/usr/src/lib/libast/sparcv9/src/lib/libast/sig.h
new file mode 100644
index 0000000000..40e930cd93
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/sig.h
@@ -0,0 +1,131 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/sig.sh by iffe version 2007-04-04 : : */
+#ifndef _def_sig_ast
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_sig_ast 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+
+#define sig_info _sig_info_
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide kill killpg
+#else
+#define kill ______kill
+#define killpg ______killpg
+#endif
+#include <signal.h>
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide kill killpg
+#else
+#undef kill
+#undef killpg
+#endif
+#ifndef sigmask
+#define sigmask(s) (1<<((s)-1))
+#endif
+typedef void (*Sig_handler_t) __PROTO__((int));
+
+
+#define Handler_t Sig_handler_t
+
+#define SIG_REG_PENDING (-1)
+#define SIG_REG_POP 0
+#define SIG_REG_EXEC 00001
+#define SIG_REG_PROC 00002
+#define SIG_REG_TERM 00004
+#define SIG_REG_ALL 00777
+#define SIG_REG_SET 01000
+
+typedef struct
+{
+ char** name;
+ char** text;
+ int sigmax;
+} Sig_info_t;
+
+extern __MANGLE__ int kill __PROTO__((pid_t, int));
+extern __MANGLE__ int killpg __PROTO__((pid_t, int));
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_ast && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ Sig_info_t sig_info;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int sigcritical __PROTO__((int));
+extern __MANGLE__ int sigunblock __PROTO__((int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/tmx.h b/usr/src/lib/libast/sparcv9/src/lib/libast/tmx.h
new file mode 100644
index 0000000000..11aa0d9b2b
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/tmx.h
@@ -0,0 +1,128 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/tmx by iffe version 2007-04-04 : : */
+
+#ifndef _TMX_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TMX_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Time_t support
+ */
+
+#include <tm.h>
+#include <tv.h>
+
+#define TMX_MAXDATE "2554-07-21+23:34:33.709551614 UTC"
+#define TMX_MAXYEAR 2554
+#define TMX_MAXSEC ((Time_t)18446744073)
+#define TMX_MAXNSEC 709551614
+#define TMX_RESOLUTION 1000000000
+
+typedef uint64_t Time_t;
+typedef uint64_t Tmxsec_t;
+typedef uint32_t Tmxnsec_t;
+
+#define tmxsec(t) ((Tmxsec_t)((t)/1000000000))
+#define tmxnsec(t) ((Tmxnsec_t)((t)%1000000000))
+#define tmxsns(s,n) (((((Time_t)(s))*1000000000))+((Time_t)(n)))
+
+#define TMX_NOTIME ((Time_t)(-1))
+#define TMX_NOW tmxgettime()
+#define TMX_MAXTIME tmxsns(TMX_MAXSEC,TMX_MAXNSEC)
+
+#define tmx2tv(t,v) ((v)->tv_nsec=tmxnsec(t),(v)->tv_sec=tmxsec(t))
+#define tv2tmx(v) tmxsns((v)->tv_sec,(v)->tv_nsec)
+
+#define tmxclock(p) tmxsns(((p)?*(p):time(NiL)),0)
+
+#define tmxgetatime(s) tmxsns((s)->st_atime,ST_ATIME_NSEC_GET(s))
+#define tmxgetctime(s) tmxsns((s)->st_ctime,ST_CTIME_NSEC_GET(s))
+#define tmxgetmtime(s) tmxsns((s)->st_mtime,ST_MTIME_NSEC_GET(s))
+
+#define tmxsetatime(s,t) ((s)->st_atime=tmxsec(t),ST_ATIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetctime(s,t) ((s)->st_ctime=tmxsec(t),ST_CTIME_NSEC_SET(s,tmxnsec(t)))
+#define tmxsetmtime(s,t) ((s)->st_mtime=tmxsec(t),ST_MTIME_NSEC_SET(s,tmxnsec(t)))
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Time_t tmxdate __PROTO__((const char*, char**, Time_t));
+extern __MANGLE__ char* tmxfmt __PROTO__((char*, size_t, const char*, Time_t));
+extern __MANGLE__ Time_t tmxleap __PROTO__((Time_t));
+extern __MANGLE__ Tm_t* tmxmake __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxscan __PROTO__((const char*, char**, const char*, char**, Time_t, long));
+extern __MANGLE__ int tmxsleep __PROTO__((Time_t));
+extern __MANGLE__ Time_t tmxtime __PROTO__((Tm_t*, int));
+
+extern __MANGLE__ Time_t tmxgettime __PROTO__((void));
+extern __MANGLE__ int tmxsettime __PROTO__((Time_t));
+
+extern __MANGLE__ int tmxtouch __PROTO__((const char*, Time_t, Time_t, Time_t, int));
+
+extern __MANGLE__ char* fmttmx __PROTO__((const char*, Time_t));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libast/sparcv9/src/lib/libast/tv.h b/usr/src/lib/libast/sparcv9/src/lib/libast/tv.h
new file mode 100644
index 0000000000..7f91a2883e
--- /dev/null
+++ b/usr/src/lib/libast/sparcv9/src/lib/libast/tv.h
@@ -0,0 +1,111 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libast/features/tv by iffe version 2007-04-04 : : */
+
+#ifndef _TV_H
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _TV_H 1
+/*
+ * AT&T Research
+ *
+ * high resolution Tv_t interface definitions
+ */
+
+#include <ast.h>
+
+#define TV_NSEC_IGNORE (1000000000L)
+#define TV_TOUCH_RETAIN ((Tv_t*)1)
+
+typedef struct Tv_s
+{
+ uint32_t tv_sec;
+ uint32_t tv_nsec;
+} Tv_t;
+
+#define ST_ATIME_NSEC_GET(st) ((st)->st_atim.tv_nsec)
+#define ST_CTIME_NSEC_GET(st) ((st)->st_ctim.tv_nsec)
+#define ST_MTIME_NSEC_GET(st) ((st)->st_mtim.tv_nsec)
+
+#define ST_ATIME_NSEC_SET(st,n) (ST_ATIME_NSEC_GET(st)=(n))
+#define ST_CTIME_NSEC_SET(st,n) (ST_CTIME_NSEC_GET(st)=(n))
+#define ST_MTIME_NSEC_SET(st,n) (ST_MTIME_NSEC_GET(st)=(n))
+
+#define tvgetatime(t,s) ((t)->tv_nsec=ST_ATIME_NSEC_GET(s),(t)->tv_sec=(s)->st_atime)
+#define tvgetmtime(t,s) ((t)->tv_nsec=ST_MTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_mtime)
+#define tvgetctime(t,s) ((t)->tv_nsec=ST_CTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_ctime)
+
+#define tvsetatime(t,s) (ST_ATIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_atime=(t)->tv_sec)
+#define tvsetmtime(t,s) (ST_MTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_mtime=(t)->tv_sec)
+#define tvsetctime(t,s) (ST_CTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_ctime=(t)->tv_sec)
+
+#if _BLD_ast && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int tvgettime __PROTO__((Tv_t*));
+extern __MANGLE__ int tvsettime __PROTO__((const Tv_t*));
+extern __MANGLE__ int tvcmp __PROTO__((const Tv_t*, const Tv_t*));
+extern __MANGLE__ int tvtouch __PROTO__((const char*, const Tv_t*, const Tv_t*, const Tv_t*, int));
+extern __MANGLE__ int tvsleep __PROTO__((const Tv_t*, Tv_t*));
+
+extern __MANGLE__ char* fmttv __PROTO__((const char*, Tv_t*));
+
+#endif
diff --git a/usr/src/lib/libc/amd64/Makefile b/usr/src/lib/libc/amd64/Makefile
index 7baca5cb48..bab9f5bc84 100644
--- a/usr/src/lib/libc/amd64/Makefile
+++ b/usr/src/lib/libc/amd64/Makefile
@@ -924,6 +924,11 @@ CPPFLAGS= -D_REENTRANT -D$(MACH64) -D__$(MACH64) \
ASFLAGS= $(AS_PICFLAGS) -P -D__STDC__ -D_ASM $(CPPFLAGS) \
$(amd64_AS_XARCH)
+# Conditionally add support for making |wordexp()| check whether
+# /usr/bin/ksh is ksh93 or not
+include ../../../Makefile.ksh93switch
+CPPFLAGS += -DWORDEXP_KSH93=$(ON_BUILD_KSH93_AS_BINKSH)
+
# Inform the run-time linker about libc specialized initialization
RTLDINFO = -z rtldinfo=tls_rtldinfo
DYNFLAGS += $(RTLDINFO)
diff --git a/usr/src/lib/libc/i386/Makefile.com b/usr/src/lib/libc/i386/Makefile.com
index 4466ec7c5a..60fdde7f71 100644
--- a/usr/src/lib/libc/i386/Makefile.com
+++ b/usr/src/lib/libc/i386/Makefile.com
@@ -971,6 +971,11 @@ CPPFLAGS= -D_REENTRANT -Di386 $(EXTN_CPPFLAGS) \
-I$(LIBCBASE)/inc -I../inc $(CPPFLAGS.master)
ASFLAGS= $(AS_PICFLAGS) -P -D__STDC__ -D_ASM $(CPPFLAGS) $(i386_AS_XARCH)
+# Conditionally add support for making |wordexp()| check whether
+# /usr/bin/ksh is ksh93 or not
+include ../../../Makefile.ksh93switch
+CPPFLAGS += -DWORDEXP_KSH93=$(ON_BUILD_KSH93_AS_BINKSH)
+
# Inform the run-time linker about libc specialized initialization
RTLDINFO = -z rtldinfo=tls_rtldinfo
DYNFLAGS += $(RTLDINFO)
diff --git a/usr/src/lib/libc/port/gen/getusershell.c b/usr/src/lib/libc/port/gen/getusershell.c
index aee3abb15b..a8fb5d97e5 100644
--- a/usr/src/lib/libc/port/gen/getusershell.c
+++ b/usr/src/lib/libc/port/gen/getusershell.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -31,15 +31,26 @@
/*
* Do not add local shells here. They should be added in /etc/shells
+ *
+ * Do not add restricted shells:
+ * Shells returned by getusershell traditionally allow:
+ * - users to change away from (i.e., if you have an rksh in
+ * getusershell(), then users can change their shell to ksh)
+ * - by default, ftp in is allowed only for shells returned by
+ * getusershell(); since FTP has no restrictions on directory
+ * movement, adding rksh to getusershell() would defeat that
+ * protection.
*/
const char *okshells[] = {
"/usr/bin/sh",
"/usr/bin/csh",
"/usr/bin/ksh",
+ "/usr/bin/ksh93",
"/usr/bin/jsh",
"/bin/sh",
"/bin/csh",
"/bin/ksh",
+ "/bin/ksh93",
"/bin/jsh",
"/sbin/sh",
"/sbin/jsh",
diff --git a/usr/src/lib/libc/port/regex/wordexp.c b/usr/src/lib/libc/port/regex/wordexp.c
index 117976e9c5..0090d40fec 100644
--- a/usr/src/lib/libc/port/regex/wordexp.c
+++ b/usr/src/lib/libc/port/regex/wordexp.c
@@ -18,9 +18,8 @@
*
* CDDL HEADER END
*/
-
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -41,12 +40,18 @@
* wordexp, wordfree -- POSIX.2 D11.2 word expansion routines.
*
* Copyright 1985, 1992 by Mortice Kern Systems Inc. All rights reserved.
+ * Modified by Roland Mainz <roland.mainz@nrubsig.org> to support ksh93.
*
*/
#pragma weak wordexp = _wordexp
#pragma weak wordfree = _wordfree
+/* Safeguard against mistakes in the Makefiles */
+#ifndef WORDEXP_KSH93
+#error "WORDEXP_KSH93 not set. Please check the Makefile flags."
+#endif
+
#include "synonyms.h"
#include <stdio.h>
#include <unistd.h>
@@ -54,6 +59,9 @@
#include <fcntl.h>
#include <limits.h>
#include <stdlib.h>
+#if WORDEXP_KSH93
+#include <alloca.h>
+#endif /* WORDEXP_KSH93 */
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
@@ -65,7 +73,250 @@
#define INITIAL 8 /* initial pathv allocation */
#define BUFSZ 256 /* allocation unit of the line buffer */
-static int append(wordexp_t *, char *);
+/* Local prototypes */
+static int append(wordexp_t *, char *);
+
+#if WORDEXP_KSH93
+/*
+ * |mystpcpy| - like |strcpy()| but returns the end of the buffer
+ * We'll add this later (and a matching multibyte/widechar version)
+ * as normal libc function.
+ *
+ * Copy string s2 to s1. s1 must be large enough.
+ * return s1-1 (position of string terminator ('\0') in destination buffer).
+ */
+static char *
+mystpcpy(char *s1, const char *s2)
+{
+ while (*s1++ = *s2++)
+ ;
+ return (s1-1);
+}
+
+/*
+ * Do word expansion.
+ * We built a mini-script in |buff| which takes care of all details,
+ * including stdin/stdout/stderr redirection, WRDE_NOCMD mode and
+ * the word expansion itself.
+ */
+int
+wordexp(const char *word, wordexp_t *wp, int flags)
+{
+ char *args[10];
+ wordexp_t wptmp;
+ size_t si;
+ int i;
+ pid_t pid;
+ char *line, *eob, *cp; /* word from shell */
+ int rv = WRDE_ERRNO;
+ int status;
+ int pv[2]; /* pipe from shell stdout */
+ FILE *fp; /* pipe read stream */
+ int serrno, tmpalloc;
+
+ /*
+ * Do absolute minimum necessary for the REUSE flag. Eventually
+ * want to be able to actually avoid excessive malloc calls.
+ */
+ if (flags & WRDE_REUSE)
+ wordfree(wp);
+
+ /*
+ * Initialize wordexp_t
+ *
+ * XPG requires that the struct pointed to by wp not be modified
+ * unless wordexp() either succeeds, or fails on WRDE_NOSPACE.
+ * So we work with wptmp, and only copy wptmp to wp if one of the
+ * previously mentioned conditions is satisfied.
+ */
+ wptmp = *wp;
+
+ /*
+ * Man page says:
+ * 2. All of the calls must set WRDE_DOOFFS, or all must not
+ * set it.
+ * Therefore, if it's not set, we_offs will always be reset.
+ */
+ if ((flags & WRDE_DOOFFS) == 0)
+ wptmp.we_offs = 0;
+
+ /*
+ * If we get APPEND|REUSE, how should we do?
+ * We allocate the buffer anyway to avoid segfault.
+ */
+ tmpalloc = 0;
+ if ((flags & WRDE_APPEND) == 0 || (flags & WRDE_REUSE)) {
+ wptmp.we_wordc = 0;
+ wptmp.we_wordn = wptmp.we_offs + INITIAL;
+ wptmp.we_wordv = (char **)malloc(
+ sizeof (char *) * wptmp.we_wordn);
+ if (wptmp.we_wordv == NULL)
+ return (WRDE_NOSPACE);
+ wptmp.we_wordp = wptmp.we_wordv + wptmp.we_offs;
+ for (si = 0; si < wptmp.we_offs; si++)
+ wptmp.we_wordv[si] = NULL;
+ tmpalloc = 1;
+ }
+
+ /*
+ * Set up pipe from shell stdout to "fp" for us
+ */
+ if (pipe(pv) < 0)
+ goto cleanup;
+
+ /*
+ * Fork/exec shell
+ */
+
+ if ((pid = fork()) == -1) {
+ serrno = errno;
+ (void) close(pv[0]);
+ (void) close(pv[1]);
+ errno = serrno;
+ goto cleanup;
+ }
+
+ if (pid == 0) { /* child */
+ /*
+ * Calculate size of required buffer (which is size of the
+ * input string (|word|) plus all string literals below;
+ * this value MUST be adjusted each time the literals are
+ * changed!!!!).
+ */
+ size_t bufflen = 124+strlen(word); /* Length of |buff| */
+ char *buff = alloca(bufflen);
+ char *currbuffp; /* Current position of '\0' in |buff| */
+ int i;
+ const char *path;
+
+ (void) dup2(pv[1], 1);
+ (void) close(pv[0]);
+ (void) close(pv[1]);
+
+ path = "/usr/bin/ksh93";
+ i = 0;
+
+ /* Start filling the buffer */
+ buff[0] = '\0';
+ currbuffp = buff;
+
+ if (flags & WRDE_UNDEF)
+ currbuffp = mystpcpy(currbuffp, "set -o nounset ; ");
+ if ((flags & WRDE_SHOWERR) == 0) {
+ /*
+ * The newline ('\n') is neccesary to make sure that
+ * the redirection to /dev/null is already active in
+ * the case the printf below contains a syntax
+ * error...
+ */
+ currbuffp = mystpcpy(currbuffp, "exec 2>/dev/null\n");
+ }
+ /* Squish stdin */
+ currbuffp = mystpcpy(currbuffp, "exec 0</dev/null\n");
+
+ if (flags & WRDE_NOCMD) {
+ /*
+ * Switch to restricted shell (rksh) mode here to
+ * put the word expansion into a "cage" which
+ * prevents users from executing external commands
+ * (outside those listed by ${PATH} (which we set
+ * explicitly to /usr/no/such/path/element/)).
+ */
+ currbuffp = mystpcpy(currbuffp, "set -o restricted\n");
+
+ (void) putenv("PATH=/usr/no/such/path/element/");
+
+ }
+
+ (void) snprintf(currbuffp, bufflen,
+ "print -f \"%%s\\000\" %s", word);
+
+ args[i++] = strrchr(path, '/') + 1;
+ args[i++] = "-c";
+ args[i++] = buff;
+ args[i++] = NULL;
+
+ (void) execv(path, args);
+ _exit(127);
+ }
+
+ (void) close(pv[1]);
+
+ if ((fp = fdopen(pv[0], "rF")) == NULL) {
+ serrno = errno;
+ (void) close(pv[0]);
+ errno = serrno;
+ goto wait_cleanup;
+ }
+
+ /*
+ * Read words from shell, separated with '\0'.
+ * Since there is no way to disable IFS splitting,
+ * it would be possible to separate the output with '\n'.
+ */
+ cp = line = malloc(BUFSZ);
+ if (line == NULL) {
+ (void) fclose(fp);
+ rv = WRDE_NOSPACE;
+ goto wait_cleanup;
+ }
+ eob = line + BUFSZ;
+
+ rv = 0;
+ while ((i = getc(fp)) != EOF) {
+ *cp++ = (char)i;
+ if (i == '\0') {
+ cp = line;
+ if ((rv = append(&wptmp, cp)) != 0) {
+ break;
+ }
+ }
+ if (cp == eob) {
+ size_t bs = (eob - line);
+ char *nl;
+
+ if ((nl = realloc(line, bs + BUFSZ)) == NULL) {
+ rv = WRDE_NOSPACE;
+ break;
+ }
+ line = nl;
+ cp = line + bs;
+ eob = cp + BUFSZ;
+ }
+ }
+
+ wptmp.we_wordp[wptmp.we_wordc] = NULL;
+
+ free(line);
+ (void) fclose(fp); /* kill shell if still writing */
+
+wait_cleanup:
+ if (waitpid(pid, &status, 0) == -1)
+ rv = WRDE_ERRNO;
+ else if (rv == 0)
+ rv = WEXITSTATUS(status); /* shell WRDE_* status */
+
+cleanup:
+ if (rv == 0)
+ *wp = wptmp;
+ else {
+ if (tmpalloc)
+ wordfree(&wptmp);
+ }
+
+ /*
+ * Map ksh errors to wordexp() errors
+ */
+ if (rv == 4)
+ rv = WRDE_CMDSUB;
+ else if (rv == 5)
+ rv = WRDE_BADVAL;
+ else if (rv == 6)
+ rv = WRDE_SYNTAX;
+ return (rv);
+}
+
+#else /* WORDEXP_KSH93 */
extern int __xpg4; /* defined in _xpg4.c; 0 if not xpg4-compiled program */
@@ -325,8 +576,10 @@ cleanup:
return (rv);
}
+#endif /* WORDEXP_KSH93 */
+
/*
- * Append a word to the wordexp_t structure, growing it as neccessary.
+ * Append a word to the wordexp_t structure, growing it as necessary.
*/
static int
append(wordexp_t *wp, char *str)
@@ -339,9 +592,9 @@ append(wordexp_t *wp, char *str)
* one more NULL. So we need 2 more free slots.
*/
if ((wp->we_wordp + wp->we_wordc) ==
- (wp->we_wordv + wp->we_wordn - 1)) {
+ (wp->we_wordv + wp->we_wordn - 1)) {
nwp = realloc(wp->we_wordv,
- (wp->we_wordn + INITIAL) * sizeof (char *));
+ (wp->we_wordn + INITIAL) * sizeof (char *));
if (nwp == NULL)
return (WRDE_NOSPACE);
wp->we_wordn += INITIAL;
diff --git a/usr/src/lib/libc/sparc/Makefile b/usr/src/lib/libc/sparc/Makefile
index 63e8e88ea4..94c264121a 100644
--- a/usr/src/lib/libc/sparc/Makefile
+++ b/usr/src/lib/libc/sparc/Makefile
@@ -989,6 +989,11 @@ CPPFLAGS= -D_REENTRANT -Dsparc $(EXTN_CPPFLAGS) \
-I$(LIBCBASE)/inc -I../inc $(CPPFLAGS.master)
ASFLAGS= -K pic -P -D__STDC__ -D_ASM $(CPPFLAGS) $(sparc_AS_XARCH)
+# Conditionally add support for making |wordexp()| check whether
+# /usr/bin/ksh is ksh93 or not
+include ../../../Makefile.ksh93switch
+CPPFLAGS += -DWORDEXP_KSH93=$(ON_BUILD_KSH93_AS_BINKSH)
+
# Inform the run-time linker about libc specialized initialization
RTLDINFO = -z rtldinfo=tls_rtldinfo
DYNFLAGS += $(RTLDINFO)
diff --git a/usr/src/lib/libc/sparcv9/Makefile b/usr/src/lib/libc/sparcv9/Makefile
index f4a5b48a74..566dea2a7e 100644
--- a/usr/src/lib/libc/sparcv9/Makefile
+++ b/usr/src/lib/libc/sparcv9/Makefile
@@ -935,6 +935,11 @@ CPPFLAGS= -D_REENTRANT -Dsparc $(EXTN_CPPFLAGS) \
ASFLAGS= -K PIC -P -D__STDC__ -D_ASM -D__sparcv9 $(CPPFLAGS) \
$(sparcv9_AS_XARCH)
+# Conditionally add support for making |wordexp()| check whether
+# /usr/bin/ksh is ksh93 or not
+include ../../../Makefile.ksh93switch
+CPPFLAGS += -DWORDEXP_KSH93=$(ON_BUILD_KSH93_AS_BINKSH)
+
# Inform the run-time linker about libc specialized initialization
RTLDINFO = -z rtldinfo=tls_rtldinfo
DYNFLAGS += $(RTLDINFO)
diff --git a/usr/src/lib/libcmd/Makefile b/usr/src/lib/libcmd/Makefile
index 3892533bd7..022938b848 100644
--- a/usr/src/lib/libcmd/Makefile
+++ b/usr/src/lib/libcmd/Makefile
@@ -19,12 +19,14 @@
# CDDL HEADER END
#
#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
#
+SHELL=/usr/bin/ksh
+
include ../Makefile.lib
SUBDIRS = $(MACH)
@@ -35,12 +37,28 @@ clean := TARGET= clean
clobber := TARGET= clobber
install := TARGET= install
lint := TARGET= lint
+_msg := TARGET= _msg
.KEEP_STATE:
-all clean clobber install lint: $(SUBDIRS)
+all clean clobber install lint _msg: $(SUBDIRS)
+
+HDRS= \
+ cmd.h \
+ cmdext.h
+
+HDRDIR32= $(MACH)/include/ast
+HDRDIR64= $(MACH64)/include/ast
+include ../Makefile.asthdr
+
+install_h: $(ROOTHDRS)
+
+# We don't check these header files because they're owned by AT&T/AST
+check:
$(SUBDIRS): FRC
@cd $@; pwd; $(MAKE) $(TARGET)
FRC:
+
+include ../Makefile.targ
diff --git a/usr/src/lib/libcmd/Makefile.com b/usr/src/lib/libcmd/Makefile.com
index 11e09b5a14..b87ad23c8c 100644
--- a/usr/src/lib/libcmd/Makefile.com
+++ b/usr/src/lib/libcmd/Makefile.com
@@ -19,32 +19,121 @@
# CDDL HEADER END
#
#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
#
+SHELL=/usr/bin/ksh
+
LIBRARY = libcmd.a
VERS = .1
-OBJECTS = placeholder.o
+OBJECTS = \
+ basename.o \
+ cat.o \
+ chgrp.o \
+ chmod.o \
+ chown.o \
+ cmdinit.o \
+ cmp.o \
+ comm.o \
+ cp.o \
+ cut.o \
+ date.o \
+ dirname.o \
+ expr.o \
+ fds.o \
+ fmt.o \
+ fold.o \
+ getconf.o \
+ head.o \
+ id.o \
+ join.o \
+ ln.o \
+ logname.o \
+ mkdir.o \
+ mkfifo.o \
+ mv.o \
+ paste.o \
+ pathchk.o \
+ rev.o \
+ revlib.o \
+ rm.o \
+ rmdir.o \
+ stty.o \
+ sync.o \
+ tail.o \
+ tee.o \
+ tty.o \
+ uname.o \
+ uniq.o \
+ wc.o \
+ wclib.o
+
+include ../../Makefile.astmsg
include ../../Makefile.lib
+# mapfile-vers does not live with the sources in in common/ to make
+# automated code updates easier.
+MAPFILES= ../mapfile-vers
+
+# Set common AST build flags (e.g., needed to support the math stuff).
+include ../../../Makefile.ast
+
LIBS = $(DYNLIB) $(LINTLIB)
-#LDLIBS += -lc
+$(LINTLIB) := SRCS = $(SRCDIR)/$(LINTSRC)
+LDLIBS += \
+ -z lazyload -last -lsocket -lnsl -z nolazyload \
+ -lc
SRCDIR = ../common
-$(LINTLIB) := SRCS = $(SRCDIR)/$(LINTSRC)
-CFLAGS += $(CCVERBOSE)
-CPPFLAGS += -I../../common/inc -D_REENTRANT
+# We use "=" here since using $(CPPFLAGS.master) is very tricky in our
+# case - it MUST come as the last element but future changes in -D options
+# may then cause silent breakage in the AST sources because the last -D
+# option specified overrides previous -D options so we prefer the current
+# way to explicitly list each single flag.
+# Notes:
+# - "-D_BLD_DLL" comes from ${mam_cc_DLL} in Mamfile
+CPPFLAGS = \
+ $(DTEXTDOM) $(DTS_ERRNO) \
+ -I../common \
+ -Isrc/lib/libcmd \
+ -I$(ROOT)/usr/include/ast \
+ -D_BLD_cmd \
+ -D_PACKAGE_ast \
+ -D_BLD_DLL \
+ '-DERROR_CATALOG="libcmd"' \
+ '-DUSAGE_LICENSE=\
+ "[-author?Glenn Fowler <gsf@research.att.com>]"\
+ "[-author?David Korn <dgk@research.att.com>]"\
+ "[-copyright?Copyright (c) 1992-2007 AT&T Knowledge Ventures]"\
+ "[-license?http://www.opensource.org/licenses/cpl1.0.txt]"\
+ "[--catalog?libcmd]"'
+
+CFLAGS += \
+ $(CCVERBOSE) \
+ -xstrconst
+CFLAGS64 += \
+ $(CCVERBOSE) \
+ -xstrconst
+
+pics/sync.o := CERRWARN += -erroff=E_END_OF_LOOP_CODE_NOT_REACHED
.KEEP_STATE:
-all: $(LIBS) fnamecheck
+all: $(LIBS)
-lint: lintcheck
+#
+# libcmd is not lint-clean yet; fake up a target. (You can use
+# "make lintcheck" to actually run lint; please send all lint fixes
+# upstream (to AT&T) so the next update will pull them into ON.)
+#
+lint:
+ @ print "usr/src/lib/libcmd is not lint-clean: skipping"
+ @ $(TRUE)
include ../../Makefile.targ
diff --git a/usr/src/lib/libcmd/THIRDPARTYLICENSE b/usr/src/lib/libcmd/THIRDPARTYLICENSE
new file mode 100644
index 0000000000..50c6364c06
--- /dev/null
+++ b/usr/src/lib/libcmd/THIRDPARTYLICENSE
@@ -0,0 +1,245 @@
++------------------------------------------------------------------------------+
+| This license covers all software that refers to the URL |
+| http://www.opensource.org/licenses/cpl1.0.txt |
++------------------------------------------------------------------------------+
+
+Common Public License Version 1.0
+
+ THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON
+ PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF
+ THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+ 1. DEFINITIONS
+
+ "Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and
+ documentation distributed under this Agreement, and
+
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from
+ and are distributed by that particular Contributor. A Contribution
+ 'originates' from a Contributor if it was added to the Program by
+ such Contributor itself or anyone acting on such Contributor's
+ behalf. Contributions do not include additions to the Program
+ which: (i) are separate modules of software distributed in
+ conjunction with the Program under their own license agreement, and
+ (ii) are not derivative works of the Program.
+
+ "Contributor" means any person or entity that distributes the Program.
+
+ "Licensed Patents " mean patent claims licensable by a Contributor
+ which are necessarily infringed by the use or sale of its Contribution
+ alone or when combined with the Program.
+
+ "Program" means the Contributions distributed in accordance with this
+ Agreement.
+
+ "Recipient" means anyone who receives the Program under this
+ Agreement, including all Contributors.
+
+ 2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free copyright
+ license to reproduce, prepare derivative works of, publicly
+ display, publicly perform, distribute and sublicense the
+ Contribution of such Contributor, if any, and such derivative
+ works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free patent
+ license under Licensed Patents to make, use, sell, offer to sell,
+ import and otherwise transfer the Contribution of such Contributor,
+ if any, in source code and object code form. This patent license
+ shall apply to the combination of the Contribution and the Program
+ if, at the time the Contribution is added by the Contributor, such
+ addition of the Contribution causes such combination to be covered
+ by the Licensed Patents. The patent license shall not apply to any
+ other combinations which include the Contribution. No hardware per
+ se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the
+ licenses to its Contributions set forth herein, no assurances are
+ provided by any Contributor that the Program does not infringe the
+ patent or other intellectual property rights of any other entity.
+ Each Contributor disclaims any liability to Recipient for claims
+ brought by any other entity based on infringement of intellectual
+ property rights or otherwise. As a condition to exercising the
+ rights and licenses granted hereunder, each Recipient hereby
+ assumes sole responsibility to secure any other intellectual
+ property rights needed, if any. For example, if a third party
+ patent license is required to allow Recipient to distribute the
+ Program, it is Recipient's responsibility to acquire that license
+ before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has
+ sufficient copyright rights in its Contribution, if any, to grant
+ the copyright license set forth in this Agreement.
+
+ 3. REQUIREMENTS
+
+ A Contributor may choose to distribute the Program in object code form
+ under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all
+ warranties and conditions, express and implied, including
+ warranties or conditions of title and non-infringement, and implied
+ warranties or conditions of merchantability and fitness for a
+ particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all
+ liability for damages, including direct, indirect, special,
+ incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement
+ are offered by that Contributor alone and not by any other party;
+ and
+
+ iv) states that source code for the Program is available from such
+ Contributor, and informs licensees how to obtain it in a reasonable
+ manner on or through a medium customarily used for software
+ exchange.
+
+ When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the
+ Program.
+
+ Contributors may not remove or alter any copyright notices contained
+ within the Program.
+
+ Each Contributor must identify itself as the originator of its
+ Contribution, if any, in a manner that reasonably allows subsequent
+ Recipients to identify the originator of the Contribution.
+
+ 4. COMMERCIAL DISTRIBUTION
+
+ Commercial distributors of software may accept certain
+ responsibilities with respect to end users, business partners and the
+ like. While this license is intended to facilitate the commercial use
+ of the Program, the Contributor who includes the Program in a
+ commercial product offering should do so in a manner which does not
+ create potential liability for other Contributors. Therefore, if a
+ Contributor includes the Program in a commercial product offering,
+ such Contributor ("Commercial Contributor") hereby agrees to defend
+ and indemnify every other Contributor ("Indemnified Contributor")
+ against any losses, damages and costs (collectively "Losses") arising
+ from claims, lawsuits and other legal actions brought by a third party
+ against the Indemnified Contributor to the extent caused by the acts
+ or omissions of such Commercial Contributor in connection with its
+ distribution of the Program in a commercial product offering. The
+ obligations in this section do not apply to any claims or Losses
+ relating to any actual or alleged intellectual property infringement.
+ In order to qualify, an Indemnified Contributor must: a) promptly
+ notify the Commercial Contributor in writing of such claim, and b)
+ allow the Commercial Contributor to control, and cooperate with the
+ Commercial Contributor in, the defense and any related settlement
+ negotiations. The Indemnified Contributor may participate in any such
+ claim at its own expense.
+
+ For example, a Contributor might include the Program in a commercial
+ product offering, Product X. That Contributor is then a Commercial
+ Contributor. If that Commercial Contributor then makes performance
+ claims, or offers warranties related to Product X, those performance
+ claims and warranties are such Commercial Contributor's responsibility
+ alone. Under this section, the Commercial Contributor would have to
+ defend claims against the other Contributors related to those
+ performance claims and warranties, and if a court requires any other
+ Contributor to pay any damages as a result, the Commercial Contributor
+ must pay those damages.
+
+ 5. NO WARRANTY
+
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+ PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
+ WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
+ OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+ responsible for determining the appropriateness of using and
+ distributing the Program and assumes all risks associated with its
+ exercise of rights under this Agreement, including but not limited to
+ the risks and costs of program errors, compliance with applicable
+ laws, damage to or loss of data, programs or equipment, and
+ unavailability or interruption of operations.
+
+ 6. DISCLAIMER OF LIABILITY
+
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
+ ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+ WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+ DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+ 7. GENERAL
+
+ If any provision of this Agreement is invalid or unenforceable under
+ applicable law, it shall not affect the validity or enforceability of
+ the remainder of the terms of this Agreement, and without further
+ action by the parties hereto, such provision shall be reformed to the
+ minimum extent necessary to make such provision valid and enforceable.
+
+ If Recipient institutes patent litigation against a Contributor with
+ respect to a patent applicable to software (including a cross-claim or
+ counterclaim in a lawsuit), then any patent licenses granted by that
+ Contributor to such Recipient under this Agreement shall terminate as
+ of the date such litigation is filed. In addition, if Recipient
+ institutes patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Program
+ itself (excluding combinations of the Program with other software or
+ hardware) infringes such Recipient's patent(s), then such Recipient's
+ rights granted under Section 2(b) shall terminate as of the date such
+ litigation is filed.
+
+ All Recipient's rights under this Agreement shall terminate if it
+ fails to comply with any of the material terms or conditions of this
+ Agreement and does not cure such failure in a reasonable period of
+ time after becoming aware of such noncompliance. If all Recipient's
+ rights under this Agreement terminate, Recipient agrees to cease use
+ and distribution of the Program as soon as reasonably practicable.
+ However, Recipient's obligations under this Agreement and any licenses
+ granted by Recipient relating to the Program shall continue and
+ survive.
+
+ Everyone is permitted to copy and distribute copies of this Agreement,
+ but in order to avoid inconsistency the Agreement is copyrighted and
+ may only be modified in the following manner. The Agreement Steward
+ reserves the right to publish new versions (including revisions) of
+ this Agreement from time to time. No one other than the Agreement
+ Steward has the right to modify this Agreement. IBM is the initial
+ Agreement Steward. IBM may assign the responsibility to serve as the
+ Agreement Steward to a suitable separate entity. Each new version of
+ the Agreement will be given a distinguishing version number. The
+ Program (including Contributions) may always be distributed subject to
+ the version of the Agreement under which it was received. In addition,
+ after a new version of the Agreement is published, Contributor may
+ elect to distribute the Program (including its Contributions) under
+ the new version. Except as expressly stated in Sections 2(a) and 2(b)
+ above, Recipient receives no rights or licenses to the intellectual
+ property of any Contributor under this Agreement, whether expressly,
+ by implication, estoppel or otherwise. All rights in the Program not
+ expressly granted under this Agreement are reserved.
+
+ This Agreement is governed by the laws of the State of New York and
+ the intellectual property laws of the United States of America. No
+ party to this Agreement will bring a legal action under this Agreement
+ more than one year after the cause of action arose. Each party waives
+ its rights to a jury trial in any resulting litigation.
+
+Copyright (c) 2004 by the Open Source Initiative
+This is a copy of the license posted on 2004-10-06 at:
+ http://www.opensource.org/licenses/cpl
diff --git a/usr/src/lib/libcmd/THIRDPARTYLICENSE.descrip b/usr/src/lib/libcmd/THIRDPARTYLICENSE.descrip
new file mode 100644
index 0000000000..59afe46fa5
--- /dev/null
+++ b/usr/src/lib/libcmd/THIRDPARTYLICENSE.descrip
@@ -0,0 +1 @@
+AT&T ADVANCED SOFTWARE TECHNOLOGY COMMAND LIBRARY (LIBCMD)
diff --git a/usr/src/lib/libcmd/amd64/include/ast/cmd.h b/usr/src/lib/libcmd/amd64/include/ast/cmd.h
new file mode 100644
index 0000000000..2484c17c5a
--- /dev/null
+++ b/usr/src/lib/libcmd/amd64/include/ast/cmd.h
@@ -0,0 +1,187 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * AT&T Research
+ *
+ * builtin cmd definitions
+ */
+
+#ifndef _CMD_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _CMD_H
+
+#include <ast.h>
+#include <error.h>
+#include <stak.h>
+
+#define cmdinit _cmd_init
+#define cmdquit() 0
+
+#if _BLD_cmd && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#include <cmdext.h>
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if defined(CMD_BUILTIN) && !defined(CMD_STANDALONE)
+#define CMD_STANDALONE CMD_BUILTIN
+#endif
+
+#ifdef CMD_STANDALONE
+
+#if CMD_DYNAMIC
+
+#include <dlldefs.h>
+
+typedef int (*Builtin_f) __PROTO__((int, char**, __V_*));
+
+#else
+
+extern __MANGLE__ int CMD_STANDALONE __PROTO__((int, char**, __V_*));
+
+#endif
+
+#ifndef CMD_BUILTIN
+
+/*
+ * command initialization
+ */
+
+static int
+cmdinit __PARAM__((int argc, register char** argv, __V_* context, const char* catalog, int flags), (argc, argv, context, catalog, flags)) __OTORP__(int argc; register char** argv; __V_* context; const char* catalog; int flags;){
+ register char* cp;
+ register char* pp;
+
+ if (cp = strrchr(argv[0], '/'))
+ cp++;
+ else
+ cp = argv[0];
+ if (pp = strrchr(cp, '_'))
+ cp = pp + 1;
+ error_info.id = cp;
+ if (!error_info.catalog)
+ error_info.catalog = (char*)catalog;
+ opt_info.index = 0;
+ if (context)
+ error_info.flags |= flags;
+ return 0;
+}
+
+#endif
+
+int
+main __PARAM__((int argc, char** argv), (argc, argv)) __OTORP__(int argc; char** argv;){
+#if CMD_DYNAMIC
+ register char* s;
+ register char* t;
+ __V_* dll;
+ Builtin_f fun;
+ char buf[64];
+
+ if (s = strrchr(argv[0], '/'))
+ s++;
+ else if (!(s = argv[0]))
+ return 127;
+ if ((t = strrchr(s, '_')) && *++t)
+ s = t;
+ buf[0] = '_';
+ buf[1] = 'b';
+ buf[2] = '_';
+ strncpy(buf + 3, s, sizeof(buf) - 4);
+ buf[sizeof(buf) - 1] = 0;
+ if (t = strchr(buf, '.'))
+ *t = 0;
+ for (;;)
+ {
+ if (dll = dlopen(NiL, RTLD_LAZY))
+ {
+ if (fun = (Builtin_f)dlsym(dll, buf + 1))
+ break;
+ if (fun = (Builtin_f)dlsym(dll, buf))
+ break;
+ }
+ if (dll = dllfind("cmd", NiL, RTLD_LAZY))
+ {
+ if (fun = (Builtin_f)dlsym(dll, buf + 1))
+ break;
+ if (fun = (Builtin_f)dlsym(dll, buf))
+ break;
+ }
+ return 127;
+ }
+ return (*fun)(argc, argv, NiL);
+#else
+ return CMD_STANDALONE(argc, argv, NiL);
+#endif
+}
+
+#else
+
+#undef cmdinit
+#define cmdinit(a,b,c,d,e) do{if(_cmd_init(a,b,c,d,e))return -1;}while(0)
+
+#ifndef CMD_BUILTIN
+
+#undef cmdquit
+#define cmdquit() (_cmd_quit)
+
+#if _BLD_cmd && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_cmd && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ int _cmd_quit;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#if _BLD_cmd && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _cmd_init __PROTO__((int, char**, __V_*, const char*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libcmd/amd64/include/ast/cmdext.h b/usr/src/lib/libcmd/amd64/include/ast/cmdext.h
new file mode 100644
index 0000000000..b5c58b5d04
--- /dev/null
+++ b/usr/src/lib/libcmd/amd64/include/ast/cmdext.h
@@ -0,0 +1,69 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+extern __MANGLE__ int b_basename __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cat __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_chgrp __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_chmod __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_chown __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cksum __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cmp __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_comm __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cp __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cut __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_date __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_dirname __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_expr __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_fds __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_fmt __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_fold __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_getconf __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_head __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_id __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_join __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_ln __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_logname __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_md5sum __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_mkdir __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_mkfifo __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_mv __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_paste __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_pathchk __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_rev __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_rm __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_rmdir __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_stty __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_sum __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_sync __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_tail __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_tee __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_tty __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_uname __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_uniq __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_wc __PROTO__((int, char**, __V_*));
diff --git a/usr/src/lib/libcmd/amd64/src/lib/libcmd/FEATURE/ids b/usr/src/lib/libcmd/amd64/src/lib/libcmd/FEATURE/ids
new file mode 100644
index 0000000000..397e8afccb
--- /dev/null
+++ b/usr/src/lib/libcmd/amd64/src/lib/libcmd/FEATURE/ids
@@ -0,0 +1,15 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libcmd/features/ids by iffe version 2007-04-04 : : */
+#ifndef _def_ids_cmd
+#define _def_ids_cmd 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_endgrent 1 /* endgrent() in default lib(s) */
+#define _lib_getgrent 1 /* getgrent() in default lib(s) */
+#define _lib_setgrent 1 /* setgrent() in default lib(s) */
+#define _sys_fss 1 /* #include <sys/fss.h> ok */
+#if !_lib_fsid && _mac_fsid
+#define _lib_fsid 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libcmd/amd64/src/lib/libcmd/FEATURE/sockets b/usr/src/lib/libcmd/amd64/src/lib/libcmd/FEATURE/sockets
new file mode 100644
index 0000000000..b40d706945
--- /dev/null
+++ b/usr/src/lib/libcmd/amd64/src/lib/libcmd/FEATURE/sockets
@@ -0,0 +1,13 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libcmd/features/sockets by iffe version 2007-04-04 : : */
+#ifndef _def_sockets_cmd
+#define _def_sockets_cmd 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _hdr_arpa_inet 1 /* #include <arpa/inet.h> ok */
+#define _hdr_netinet_in 1 /* #include <netinet/in.h> ok */
+#define _lib_getsockname 1 /* getsockname() in default lib(s) */
+#define _lib_getsockopt 1 /* getsockopt() in default lib(s) */
+#define _lib_inet_ntoa 1 /* inet_ntoa() in default lib(s) */
+#endif
diff --git a/usr/src/lib/libcmd/amd64/src/lib/libcmd/FEATURE/symlink b/usr/src/lib/libcmd/amd64/src/lib/libcmd/FEATURE/symlink
new file mode 100644
index 0000000000..4975396e7b
--- /dev/null
+++ b/usr/src/lib/libcmd/amd64/src/lib/libcmd/FEATURE/symlink
@@ -0,0 +1,8 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libcmd/features/symlink by iffe version 2007-04-04 : : */
+#ifndef _def_symlink_cmd
+#define _def_symlink_cmd 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_lchown 1 /* lchown implemented */
+#endif
diff --git a/usr/src/lib/libcmd/amd64/src/lib/libcmd/FEATURE/utsname b/usr/src/lib/libcmd/amd64/src/lib/libcmd/FEATURE/utsname
new file mode 100644
index 0000000000..34d932c637
--- /dev/null
+++ b/usr/src/lib/libcmd/amd64/src/lib/libcmd/FEATURE/utsname
@@ -0,0 +1,16 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libcmd/features/utsname by iffe version 2007-04-04 : : */
+#ifndef _def_utsname_cmd
+#define _def_utsname_cmd 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_getdomainname 1 /* getdomainname() in default lib(s) */
+#define _lib_gethostid 1 /* gethostid() in default lib(s) */
+#define _lib_gethostname 1 /* gethostname() in default lib(s) */
+#define _lib_sethostname 1 /* sethostname() in default lib(s) */
+#define _lib_syscall 1 /* syscall() in default lib(s) */
+#define _lib_uname 1 /* uname() in default lib(s) */
+#define _sys_utsname 1 /* #include <sys/utsname.h> ok */
+#define _sys_syscall 1 /* #include <sys/syscall.h> ok */
+#define _sys_systeminfo 1 /* #include <sys/systeminfo.h> ok */
+#endif
diff --git a/usr/src/lib/libcmd/common/RELEASE b/usr/src/lib/libcmd/common/RELEASE
new file mode 100644
index 0000000000..7e343a5607
--- /dev/null
+++ b/usr/src/lib/libcmd/common/RELEASE
@@ -0,0 +1,217 @@
+07-03-28 date.c: add --unelepsed=scale, -U: fmtelapsed() => strelapsed()
+07-03-25 wclib.h: iswspace() requires <wctype.h>!
+07-03-11 tty.c: add sysV --line-number, -l
+07-02-26 Makefile: sumlib.o: direct extract from +lsum (vcodex someday)
+07-02-24 Makefile: tweak cmdext.h action for --mam bootstrap
+07-02-09 Makefile: { cmdext.h cmdlist.h } depend on *.c list!
+07-02-09 Makefile: +lsum to bring in static -lsum (no dynamic right now)
+07-02-07 cksum.c: move from src/cmd/std with ftwalk => fts
+07-02-07 getconf.c: handle /bin == /usr/bin in defer logic
+07-01-26 chmod.c: don't FTS_FOLLOW if !FTS_PHYSICAL
+07-01-23 cut.c: Cut_t variable dimension list[] must be last member
+07-01-22 uname.c: fix -h typo that clobbered astconf() state -- ouch
+07-01-02 fmt.c: fix buffer splice off by one bug -- what else
+06-11-23 cmd.h: because of proto cmdinit cannot be a function like macro
+06-11-21 cp.c: fix 06-10-31 const dot[] readonly assignment
+06-11-15 cp.c: fix 06-10-31 ln -s enoent bug
+06-11-11 getconf.c: let astconf() handle "undefined" vs. ""
+06-11-11 getconf.c: fix deferred getconf path search
+06-11-11 fmt.c: handle two char { \t \n } in --usage ouput
+06-10-31 global edit to eliminate most non-const static data0
+06-10-31 use <cmd.h> for all b_*() implementations; drop <cmdlib.h>
+06-10-31 cmd.h: add CMD_ prefix to { BUILTIN DYNAMIC STANDALONE }
+06-10-31 join.c: tone down /tmp usage vi SFSK_DISCARD
+06-10-31 cp.c,rm.c: update to <fts.h> to accomodate non-static data
+06-10-29 date.c: "...%H%..." => "...%H" "%..." to avoid SCCS conflict
+06-10-26 fds.c: handle sctp
+06-10-18 tail.c: fix invalid suffix infinite loop
+06-10-11 chgrp.c,cp.c: add sfstruse() error checks
+06-10-10 tee.c: add --linebuffer, -l
+06-10-06 getconf.c: preserve native getconf(1) known variable behavior
+06-10-04 sync.c: add (thanks to Roland Mainz)
+06-10-04 getconf.c: add -v specification => run native getconf(1)
+06-09-28 stty.c: static setmode() => set() for darwin.i386
+06-09-27 head.c: handle -1c => -c1
+06-09-19 pathchk.c: pathconf() => astconf()
+06-09-11 tail.c: handle compatibility corner cases
+06-09-08 date.c: add output write error diagnostic
+06-09-04 tail.c: fix initial position for -n0, no args => no -f
+06-08-28 uniq.c: add -D,--all-repeated
+06-08-25 wc.c,wclib.c: add -L,--longest-line,WC_LONGEST
+06-08-24 wc.c,wclib.c: implement -m and WC_MBYTE
+06-08-24 rmdir.c: -sp applies to every message, add gnu -e
+06-08-23 rmdir.c: add solaris --suppress, -s
+06-08-23 mkdir.c: don't add 0300 to -p final dir mode
+06-07-17 cut.c: handle last line with no newline
+06-07-17 cut.c: --output-delimiter == --line-delimiter
+06-06-25 chmod.c: mask -c output with S_IPERM
+06-05-09 uname.c: add -o; change -a to match linux
+06-05-03 date.c: add --last -L to list last of multiple time args
+06-02-14 tail.c: fix -f bug that lost fast stream data
+06-02-11 getconf.c: exit 1 if name invalid -- duh
+06-01-28 cp.c,rm.c: fix astquery() 'q' to return and not exit()
+05-08-11 fmt.c: fix -o to handle raw --usage strings
+05-05-17 cat.c,head.c: disable EPIPE error messages
+05-04-14 chgrp.c: -f means all non-syntax error messages
+05-04-11 fds.c: add from old internal open(1)
+05-04-09 cmdext.h,cmdlist.h: generate from source -- about time
+05-03-24 features/symlink: verify { lchmod lchown } implementations
+05-03-07 date.c: add --listzones to list the time zone table
+05-02-14 chmod.c: add --reference=file
+05-01-11 cat.c: restore output stream to binary mode on exit
+04-12-15 cp.c: add --preserve high resolution time support
+04-12-08 date.c: add high resolution time support
+04-12-01 cmp.c: fix %6I*ld => %6I*d -- doh
+ fmt.c: handle "\n\n operands \n\n"
+ head.c: handle -cN -nN, N > 4Gb
+04-11-22 cmp.c: handle >2G chars/lines
+04-11-18 fold.c: add --prepend=text, --append=text
+04-10-31 tail.c: use SF_LOCKR macro
+04-10-28 tail.c: use strtol() for old stype [+-]number[suffix] -- doh
+04-10-22 cp.c: check rename() errno==ENOENT to retain destination
+04-10-11 fmt.c: fix -o,--optget sublist bugs
+ tail.c: use strton() for number conversion
+04-10-08 pathchk.c: add empty path and -p - first component char
+04-10-01 fmt.c: add -o,--optget concatenated usage string format
+ stty.c: context is ERROR_INTERCATIVE
+ rm.c: restore 3d before exit
+04-09-24 pathchk.c: fix docs
+04-09-14 date.c: add %| and %& --parse docs
+04-08-27 cp.c: add FTW_DC check -- duh
+04-08-01 fmt.c: handle last char != '\n'
+04-07-22 date.c,uname.c: access() => eaccess()
+04-07-01 fmt.c: handle large input lines -- ouch
+04-06-11 id.c: fix -r to output something!
+04-05-27 expr.c: fix `:' op subexpression output
+04-04-15 chmod.c: follow symlink for relative mode
+04-04-12 Makefile: add STDCHMOD (for osf.alpha)
+04-03-19 tail.c: handle -f sfreserve() large chunk failure
+04-02-29 cp.c: decouple -f and -i for standard CONFORMANCE
+ cp.c: mv now attempts rename() before remove()+rename()
+ date.c: -f format or +format disables system clock set
+04-02-14 cp.c: add -F --fsync to call fsync(2) for each copied file
+04-01-05 head.c: -s now uses opt_info.number for >2Gb skip
+03-09-18 tail.c: add --log
+03-09-11 rm.c: add --unconditional
+03-08-11 fold.c: add --delimiter=c to break at c
+03-07-28 features/time: change settimeofday() test to 2nd arg of (void*)0
+ expr.c: add {match,substr,index,length,quote}
+03-07-15 fmt.c: fix trailing space bug
+03-06-20 uname.c: fix -p constant string overwrite
+03-06-04 stty.c: add undef to control assignment docs
+03-05-31 uname.c: add -f and sysinfo()/confstr() compatibility via astconf()
+03-05-27 rm.c: fix inappropriate "/.." append path overflow
+ cut.c: snarf from dgk
+03-05-18 rm.c: check st_nlink to verify progress w.r.t. ftwalk/fts
+03-05-15 join.c: fix stealth -v2 bug (thanks ahs)
+03-05-04 wc.c: drop trailing space for `wc -l < file'
+03-03-21 date.c: add %Q/recent/distant/ docs
+03-02-19 date.c: fix %+|!flag docs
+02-11-14 update for cmdinit() 4th arg and ERROR_NOTIFY for interrupt cleanup
+02-10-02 date.c: tmform() => tmfmt()
+02-09-30 date.c,uname.c: change execv() calls to procrun(): exec|exit => bad
+02-09-06 wclib.c: fix 1 char-at-a-time miscount bug
+02-08-19 chgrp.c: convert to use <cdt.h>
+02-07-23 join.c: fix comm snarf typo
+02-04-05 date.c: add %u
+02-01-24 stty.c: ifdef a few more macros for uts (yes, its still running)
+01-12-14 date.c: clarify %z doc
+01-10-31 mkdir.c: mkdir() on existing dir could fail with errno!=EEXIST
+ uname.c: add execve() loop check for unknown options
+01-10-29 tail.c: SF_SHARE on only if not reading through EOF
+01-10-11 getconf.c: fix usage typos
+01-09-11 cp.c,cmd.h: handle . in argv[0]
+ cp.c: add O_BINARY to all open() calls
+01-09-06 tail: input streams must be SF_SHARE -- duh
+01-07-16 stty: fix cntl() macro for CC_NATIVE!=CC_ASCII
+01-05-31 date: fix /bin/date fallback logic
+ stty: fix a few mismatched flags, -a and -g option logic
+ stty: tone down sane to modify current settings rather than from zero
+01-05-01 uname: -i => -h, add sol.sun4 -i, add sgi -R, punt to /usr/bin/uname
+01-04-17 date,rm: add
+01-03-07 cp: fix readonly string mod on "."
+01-01-23 cp: `cp foo' => `cp foo .' only for CONFORMANCE!=standard
+00-12-01 cut: multibyte support
+00-10-31 mkdir: handle races by checking EEXIST
+00-09-20 cp: copy argv to stack before modifying in place
+00-05-18 add setlocale(LC_ALL,"")
+00-04-30 join: drop wierd opt_info.argv reference
+00-03-17 expr: add == operator -- duh
+ cp,ln,mv: delay pathcanon() on destination to verify `cp a b/.'
+ getconf: use astgetconf for proper message control
+ ERROR_translate: dictionary update
+00-03-08 tail: handle multiple -f files
+00-03-07 fmt: add
+00-03-07 dirname: handle PATH_LEADING_SLASHES as documented
+ tail: accept + options
+00-02-14 chmod: --ignore-umask to ignore umask(2) in symbolic expressions
+ chmod,chgrp,cp: use FTS_NOSEEDOTDIR for correct path construction
+ cat: fix -n (was ignored, wow)
+00-01-27 getconf: add "-a" and "-v spec" for sol7.* compatibility
+99-09-09 join: fix -j1 vs. -j 1, add --ignorecase
+99-06-22 paste: defualt delim in writable string
+99-06-16 cat: fix --dos-ouput typo
+99-06-11 cp: tighten chown() diagnostics
+99-06-08 expr: nothing for NULL string bug fix
+99-05-21 paste: fix missing newline columnize bug
+99-05-20 mv: do not check for `mv foo foo' since rename() handles it
+99-05-01 cmp,comm,cp/mv/ln,expr,fold,getconf,head: long options
+ join,logname,paste,pathchk,tail,tee: long options
+99-04-10 uname: long options, stdize -a
+ chmod,head,tail,rev: long options
+ cut: long options, pass regression test 02
+99-04-07 cat: long options, fix O_TEXT modes
+99-01-11 tail: fix +n
+ join: another ggs/psm bug
+ join: all 1 and/or 2 to be unseekable
+99-01-01 cp: fix -p
+ chmod: drop -l option because of clash with l (lock) mode
+98-12-25 cat: add -T to sfopen(,,"rt")
+98-11-11 chgrp,chmod: cannot open file stream => not found
+ join: fix another ggs/psm bug; thanks guys
+98-10-20 cp: fix cp -rp to update dir times too
+98-09-22 join: fix ggs null field bug
+98-08-11 join: fix last regression test bug
+98-05-29 join: add jp->common to handle boundary conditions
+98-03-11 cat,cp,rev,tee: fix sfmove() error checks
+98-03-01 join: fix bug that emitted records more than once after eof
+ cp: fix sfmove() error check
+98-02-14 cp: -R physical, -[HLP], -r getconf(PATH_RESOLVE)
+98-01-11 cp: check sfclose() return value
+98-01-07 chown,chgrp,chmod: use fts for -R
+ mkdir: fix -p default mode
+97-12-07 mkdir: fix umask() reset
+97-11-11 chown,chgrp: proper interpretation of -h,-l for lchown()
+ chown,chgrp: only chown() if uid or gid change
+97-10-31 mkdir: do umask right
+97-08-11 cmdinit: clear opt_info.index to allow multiple calls
+ cp,ln,mv: add
+97-07-17 join: fix a few more -a bugs
+97-05-31 expr: optget() only if CONFORMANCE==standard
+97-04-01 join: fix a few bugs that make it work!
+96-12-25 head: sfset(sfstdin,SF_SHARE,1)
+ Makefile: add -last to cmd lib list
+ drop function __IMPORT__
+96-08-11 tail: check for truncated file and rewind for -f
+96-04-08 update <cmd.h>
+96-02-29 uname: -a like std, -l for everything
+ id: add -a (default)
+96-02-14 wc: speed up inner loop newline breakout
+96-01-30 unused var cleanup
+96-01-01 AT&T Research now
+ pathchk: handle getcwd(0,0) error
+ expr: switch to <regex.h>
+95-11-11 add expr.c
+ fix cut exit code and -s optimization
+95-10-11 add extern b_* to cmd.h
+ add void* context 3rd arg to b_main()
+95-05-09 add getconf
+ cat -u avoids mmap
+ add chown|chgrp -m uid|gid map file
+ add chown|chgrp -P for systems with lchown(2)
+ chown|chgrp -P => lstat() too!
+ chmod|chown|chgrp -HLP
+95-04-01 version 1.2
+ add rmdir
+95-02-14 fix mkdir -p symlink bug
+ fix mkdir '/' skip bug that went one too far
diff --git a/usr/src/lib/libcmd/common/basename.c b/usr/src/lib/libcmd/common/basename.c
new file mode 100644
index 0000000000..f715091c32
--- /dev/null
+++ b/usr/src/lib/libcmd/common/basename.c
@@ -0,0 +1,116 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Bell Laboratories
+ *
+ * namebase pathname [suffix]
+ *
+ * print the namebase of a pathname
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: basename (AT&T Research) 1999-04-10 $\n]"
+USAGE_LICENSE
+"[+NAME?basename - strip directory and suffix from filenames]"
+"[+DESCRIPTION?\bbasename\b removes all leading directory components "
+ "from the file name defined by \astring\a. If the file name "
+ "defined by \astring\a has a suffix that ends in \asuffix\a, "
+ "it is removed as well.]"
+"[+?If \astring\a consists solely of \b/\b characters the output will "
+ "be a single \b/\b unless \bPATH_LEADING_SLASHES\b returned by "
+ "\bgetconf\b(1) is \b1\b and \astring\a consists of multiple "
+ "\b/\b characters in which case \b//\b will be output. "
+ "Otherwise, trailing \b/\b characters are removed, and if "
+ "there are any remaining \b/\b characters in \astring\a, "
+ "all characters up to and including the last \b/\b are removed. "
+ "Finally, if \asuffix\a is specified, and is identical the end "
+ "of \astring\a, these characters are removed. The characters "
+ "not removed from \astring\a will be written to standard output.]"
+"\n"
+"\n string [suffix]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Successful Completion.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bdirname\b(1), \bgetconf\b(1), \bbasename\b(3)]"
+;
+
+
+#include <cmd.h>
+
+static void namebase(Sfio_t *outfile, register char *pathname, char *suffix)
+{
+ register char *first, *last;
+ register int n=0;
+ for(first=last=pathname; *last; last++);
+ /* back over trailing '/' */
+ if(last>first)
+ while(*--last=='/' && last > first);
+ if(last==first && *last=='/')
+ {
+ /* all '/' or "" */
+ if(*first=='/')
+ if(*++last=='/') /* keep leading // */
+ last++;
+ }
+ else
+ {
+ for(first=last++;first>pathname && *first!='/';first--);
+ if(*first=='/')
+ first++;
+ /* check for trailing suffix */
+ if(suffix && (n=strlen(suffix)) && n<(last-first))
+ {
+ if(memcmp(last-n,suffix,n)==0)
+ last -=n;
+ }
+ }
+ if(last>first)
+ sfwrite(outfile,first,last-first);
+ sfputc(outfile,'\n');
+}
+
+int
+b_basename(int argc,register char *argv[], void* context)
+{
+ register int n;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ while (n = optget(argv, usage)) switch (n)
+ {
+ case ':':
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ argc -= opt_info.index;
+ if(error_info.errors || argc < 1 || argc > 2)
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ namebase(sfstdout,argv[0],argv[1]);
+ return(0);
+}
+
diff --git a/usr/src/lib/libcmd/common/cat.c b/usr/src/lib/libcmd/common/cat.c
new file mode 100644
index 0000000000..884726e572
--- /dev/null
+++ b/usr/src/lib/libcmd/common/cat.c
@@ -0,0 +1,381 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * cat
+ */
+
+#include <cmd.h>
+#include <fcntl.h>
+
+static const char usage[] =
+"[-?\n@(#)$Id: cat (AT&T Research) 2006-05-17 $\n]"
+USAGE_LICENSE
+"[+NAME?cat - concatenate files]"
+"[+DESCRIPTION?\bcat\b copies each \afile\a in sequence to the standard"
+" output. If no \afile\a is given, or if the \afile\a is \b-\b,"
+" \bcat\b copies from standard input starting at the current location.]"
+
+"[b:number-nonblank?Number lines as with \b-n\b but omit line numbers from"
+" blank lines.]"
+"[d:dos-input?Input files are opened in \atext\amode which removes carriage"
+" returns in front of new-lines on some systems.]"
+"[e?Equivalent to \b-vE\b.]"
+"[n:number?Causes a line number to be inserted at the beginning of each line.]"
+"[s?Equivalent to \b-S\b for \aatt\a universe and \b-B\b otherwise.]"
+"[t?Equivalent to \b-vT\b.]"
+"[u:unbuffer?The output is not delayed by buffering.]"
+"[v:show-nonprinting?Causes non-printing characters (whith the exception of"
+" tabs, new-lines, and form-feeds) to be output as printable charater"
+" sequences. ASCII control characters are printed as \b^\b\an\a,"
+" where \an\a is the corresponding ASCII character in the range"
+" octal 100-137. The DEL character (octal 0177) is copied"
+" as \b^?\b. Other non-printable characters are copied as \bM-\b\ax\a"
+" where \ax\a is the ASCII character specified by the low-order seven"
+" bits. Multibyte characters in the current locale are treated as"
+" printable characters.]"
+"[A:show-all?Equivalent to \b-vET\b.]"
+"[B:squeeze-blank?Multiple adjacent new-line characters are replace by one"
+" new-line.]"
+"[D:dos-output?Output files are opened in \atext\amode which inserts carriage"
+" returns in front of new-lines on some systems.]"
+"[E:show-ends?Causes a \b$\b to be inserted before each new-line.]"
+"[S:silent?\bcat\b is silent about non-existent files.]"
+"[T:show-blank?Causes tabs to be copied as \b^I\b and formfeeds as \b^L\b.]"
+
+"\n"
+"\n[file ...]\n"
+"\n"
+
+"[+SEE ALSO?\bcp\b(1), \bgetconf\b(1), \bpr\b(1)]"
+;
+
+#define RUBOUT 0177
+
+/* control flags */
+#define B_FLAG (1<<0)
+#define E_FLAG (1<<1)
+#define F_FLAG (1<<2)
+#define N_FLAG (1<<3)
+#define S_FLAG (1<<4)
+#define T_FLAG (1<<5)
+#define U_FLAG (1<<6)
+#define V_FLAG (1<<7)
+#define D_FLAG (1<<8)
+#define d_FLAG (1<<9)
+
+/* character types */
+#define T_ENDBUF 1
+#define T_CONTROL 2
+#define T_NEWLINE 3
+#define T_EIGHTBIT 4
+#define T_CNTL8BIT 5
+
+#define printof(c) ((c)^0100)
+
+/*
+ * called for any special output processing
+ */
+
+static int
+vcat(register char* states, Sfio_t *fdin, Sfio_t *fdout, int flags)
+{
+ register unsigned char* cp;
+ register unsigned char* cpold;
+ register int n;
+ register int m;
+ register int line = 1;
+ register unsigned char* endbuff;
+ unsigned char* inbuff;
+ int printdefer = (flags&(B_FLAG|N_FLAG));
+ int lastchar;
+
+ unsigned char meta[4];
+
+ meta[0] = 'M';
+ meta[1] = '-';
+ for (;;)
+ {
+ /* read in a buffer full */
+ if (!(inbuff = (unsigned char*)sfreserve(fdin, SF_UNBOUND, 0)))
+ return sfvalue(fdin) ? -1 : 0;
+ if ((n = sfvalue(fdin)) <= 0)
+ return n;
+ cp = inbuff;
+ lastchar = *(endbuff = cp + --n);
+ *endbuff = 0;
+ if (printdefer)
+ {
+ if (states[*cp]!=T_NEWLINE || !(flags&B_FLAG))
+ sfprintf(fdout,"%6d\t",line);
+ printdefer = 0;
+ }
+ while (endbuff)
+ {
+ cpold = cp;
+ /* skip over printable characters */
+ if (mbwide())
+ while ((n = (m = mbsize(cp)) < 2 ? states[*cp++] : (cp += m, states['a'])) == 0);
+ else
+ while ((n = states[*cp++]) == 0);
+ if (n==T_ENDBUF)
+ {
+ if (cp>endbuff)
+ {
+ if (!(n = states[lastchar]))
+ {
+ *endbuff = lastchar;
+ cp++;
+ }
+ else
+ {
+ if (--cp > cpold)
+ sfwrite(fdout,(char*)cpold,cp-cpold);
+ if (endbuff==inbuff)
+ *++endbuff = 0;
+ cp = cpold = endbuff;
+ cp[-1] = lastchar;
+ if (n==T_ENDBUF)
+ n = T_CONTROL;
+
+ }
+ endbuff = 0;
+ }
+ else n = T_CONTROL;
+ }
+ if (--cp>cpold)
+ sfwrite(fdout,(char*)cpold,cp-cpold);
+ switch(n)
+ {
+ case T_CNTL8BIT:
+ meta[2] = '^';
+ do
+ {
+ n = (*cp++)&~0200;
+ meta[3] = printof(n);
+ sfwrite(fdout,(char*)meta,4);
+ }
+ while ((n=states[*cp])==T_CNTL8BIT);
+ break;
+ case T_EIGHTBIT:
+ do
+ {
+ meta[2] = (*cp++)&~0200;
+ sfwrite(fdout,(char*)meta,3);
+ }
+ while ((n=states[*cp])==T_EIGHTBIT);
+ break;
+ case T_CONTROL:
+ do
+ {
+ n = *cp++;
+ sfputc(fdout,'^');
+ sfputc(fdout,printof(n));
+ }
+ while ((n=states[*cp])==T_CONTROL);
+ break;
+ case T_NEWLINE:
+ if (flags&S_FLAG)
+ {
+ while (states[*++cp]==T_NEWLINE)
+ line++;
+ cp--;
+ }
+ do
+ {
+ cp++;
+ if (flags&E_FLAG)
+ sfputc(fdout,'$');
+ sfputc(fdout,'\n');
+ if (!(flags&(N_FLAG|B_FLAG)))
+ continue;
+ line++;
+ if (cp < endbuff)
+ sfprintf(fdout,"%6d\t",line);
+ else printdefer = 1;
+ }
+ while (states[*cp]==T_NEWLINE);
+ break;
+ }
+ }
+ }
+}
+
+int
+b_cat(int argc, char** argv, void* context)
+{
+ register int n;
+ register int flags = 0;
+ register char* cp;
+ register Sfio_t* fp;
+ char* mode;
+ int att;
+ int dovcat=0;
+ char states[UCHAR_MAX+1];
+
+ NoP(argc);
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ att = !strcmp(astconf("UNIVERSE", NiL, NiL), "att");
+ mode = "r";
+ for (;;)
+ {
+ switch (optget(argv, usage))
+ {
+ case 'A':
+ flags |= T_FLAG|E_FLAG|V_FLAG;
+ continue;
+ case 'B':
+ flags |= S_FLAG;
+ continue;
+ case 'b':
+ flags |= B_FLAG;
+ continue;
+ case 'E':
+ flags |= E_FLAG;
+ continue;
+ case 'e':
+ flags |= E_FLAG|V_FLAG;
+ continue;
+ case 'n':
+ flags |= N_FLAG;
+ continue;
+ case 's':
+ flags |= att ? F_FLAG : S_FLAG;
+ continue;
+ case 'S':
+ flags |= F_FLAG;
+ continue;
+ case 'T':
+ flags |= T_FLAG;
+ continue;
+ case 't':
+ flags |= T_FLAG|V_FLAG;
+ continue;
+ case 'u':
+ flags |= U_FLAG;
+ continue;
+ case 'v':
+ flags |= V_FLAG;
+ continue;
+ case 'd':
+ mode = "rt";
+ continue;
+ case 'D':
+ flags |= d_FLAG;
+ continue;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ if (error_info.errors)
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ memset(states, 0, sizeof(states));
+ if (flags&V_FLAG)
+ {
+ memset(states, T_CONTROL, ' ');
+ states[RUBOUT] = T_CONTROL;
+ memset(states+0200, T_EIGHTBIT, 0200);
+ memset(states+0200, T_CNTL8BIT, ' ');
+ states[RUBOUT|0200] = T_CNTL8BIT;
+ states['\n'] = 0;
+ }
+ if (flags&T_FLAG)
+ states['\t'] = T_CONTROL;
+ states[0] = T_ENDBUF;
+ if (att)
+ {
+ if (flags&V_FLAG)
+ {
+ states['\n'|0200] = T_EIGHTBIT;
+ if (!(flags&T_FLAG))
+ {
+ states['\t'] = states['\f'] = 0;
+ states['\t'|0200] = states['\f'|0200] = T_EIGHTBIT;
+ }
+ }
+ }
+ else if (flags)
+ {
+ if (!(flags&T_FLAG))
+ states['\t'] = 0;
+ }
+ if (flags&(V_FLAG|T_FLAG|N_FLAG|E_FLAG|B_FLAG))
+ {
+ states['\n'] = T_NEWLINE;
+ dovcat = 1;
+ }
+ if (flags&B_FLAG)
+ flags |= S_FLAG;
+ if (flags&d_FLAG)
+ sfopen(sfstdout, NiL, "wt");
+ if (cp = *argv)
+ argv++;
+ do
+ {
+ if (!cp || streq(cp,"-"))
+ {
+ fp = sfstdin;
+ if (flags&D_FLAG)
+ sfopen(fp, NiL, mode);
+ }
+ else if (!(fp = sfopen(NiL, cp, mode)))
+ {
+ if (!(flags&F_FLAG))
+ error(ERROR_system(0), "%s: cannot open", cp);
+ error_info.errors = 1;
+ continue;
+ }
+ if (flags&U_FLAG)
+ sfsetbuf(fp, (void*)fp, -1);
+ if (dovcat)
+ n = vcat(states, fp, sfstdout, flags);
+ else if (sfmove(fp, sfstdout, SF_UNBOUND, -1) >= 0 && sfeof(fp))
+ n = 0;
+ else
+ n = -1;
+ if (fp != sfstdin)
+ sfclose(fp);
+ if (n < 0 && errno != EPIPE)
+ {
+ if (cp)
+ error(ERROR_system(0), "%s: read error", cp);
+ else
+ error(ERROR_system(0), "read error");
+ }
+ if (sferror(sfstdout))
+ break;
+ } while (cp = *argv++);
+ if (sfsync(sfstdout))
+ error(ERROR_system(0), "write error");
+ if (flags&d_FLAG)
+ sfopen(sfstdout, NiL, "w");
+ return error_info.errors;
+}
diff --git a/usr/src/lib/libcmd/common/chgrp.c b/usr/src/lib/libcmd/common/chgrp.c
new file mode 100644
index 0000000000..5538f5e310
--- /dev/null
+++ b/usr/src/lib/libcmd/common/chgrp.c
@@ -0,0 +1,454 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * chgrp+chown
+ */
+
+static const char usage_1[] =
+"[-?@(#)$Id: chgrp (AT&T Research) 2006-10-11 $\n]"
+USAGE_LICENSE
+;
+
+static const char usage_grp_1[] =
+"[+NAME?chgrp - change the group ownership of files]"
+"[+DESCRIPTION?\bchgrp\b changes the group ownership of each file"
+" to \agroup\a, which can be either a group name or a numeric"
+" group id. The user ownership of each file may also be changed to"
+" \auser\a by prepending \auser\a\b:\b to the group name.]"
+;
+
+static const char usage_own_1[] =
+"[+NAME?chown - change the ownership of files]"
+"[+DESCRIPTION?\bchown\b changes the ownership of each file"
+" to \auser\a, which can be either a user name or a numeric"
+" user id. The group ownership of each file may also be changed to"
+" \auser\a by appending \b:\b\agroup\a to the user name.]"
+;
+
+static const char usage_2[] =
+"[c:changes?Describe only files whose ownership actually changes.]"
+"[f:quiet|silent?Do not report files whose ownership fails to change.]"
+"[l|h:symlink?Change the ownership of the symbolic links on systems that"
+" support this.]"
+"[m:map?The first operand is interpreted as a file that contains a map"
+" of \afrom_uid:from_gid to_uid:to_gid\a pairs. Ownership of files"
+" matching the \afrom\a part of any pair is changed to the corresponding"
+" \ato\a part of the pair. The process stops at the first match for"
+" each file. Unmatched files are silently ignored.]"
+"[n:show?Show actions but don't execute.]"
+"[r:reference?Omit the explicit ownership operand and use the ownership of"
+" \afile\a instead.]:[file]"
+"[v:verbose?Describe changed permissions of all files.]"
+"[H:metaphysical?Follow symbolic links for command arguments; otherwise don't"
+" follow symbolic links when traversing directories.]"
+"[L:logical|follow?Follow symbolic links when traversing directories.]"
+"[P:physical|nofollow?Don't follow symbolic links when traversing directories.]"
+"[R:recursive?Recursively change ownership of directories and their contents.]"
+"[X:test?Canonicalize output for testing.]"
+
+"\n"
+"\n"
+;
+
+static const char usage_3[] =
+" file ...\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?All files changed successfully.]"
+ "[+>0?Unable to change ownership of one or more files.]"
+"}"
+"[+SEE ALSO?\bchmod\b(1), \btw\b(1), \bgetconf\b(1), \bls\b(1)]"
+;
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide lchown
+#else
+#define lchown ______lchown
+#endif
+
+#include <cmd.h>
+#include <cdt.h>
+#include <ls.h>
+#include <ctype.h>
+#include <fts.h>
+
+#include "FEATURE/symlink"
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide lchown
+#else
+#undef lchown
+#endif
+
+typedef struct /* uid/gid map */
+{
+ Dtlink_t link; /* dictionary link */
+ int id; /* id */
+ int uid; /* id maps to this uid */
+ int gid; /* id maps to this gid */
+} Map_t;
+
+#define NOID (-1)
+
+#define OPT_CHOWN (1<<0) /* chown */
+#define OPT_FORCE (1<<1) /* ignore errors */
+#define OPT_GID (1<<2) /* have gid */
+#define OPT_LCHOWN (1<<3) /* lchown */
+#define OPT_SHOW (1<<4) /* show but don't do */
+#define OPT_TEST (1<<5) /* canonicalize output */
+#define OPT_UID (1<<6) /* have uid */
+#define OPT_VERBOSE (1<<7) /* have uid */
+
+extern int lchown(const char*, uid_t, gid_t);
+
+#if !_lib_lchown
+
+#ifndef ENOSYS
+#define ENOSYS EINVAL
+#endif
+
+int
+lchown(const char* path, uid_t uid, gid_t gid)
+{
+ return ENOSYS;
+}
+
+#endif /* _lib_chown */
+
+/*
+ * parse uid and gid from s
+ */
+
+static void
+getids(register char* s, char** e, int* uid, int* gid, int options)
+{
+ register char* t;
+ register int n;
+ char* z;
+ char buf[64];
+
+ *uid = *gid = NOID;
+ while (isspace(*s))
+ s++;
+ for (t = s; (n = *t) && n != ':' && n != '.' && !isspace(n); t++);
+ if (n)
+ {
+ options |= OPT_CHOWN;
+ if ((n = t++ - s) >= sizeof(buf))
+ n = sizeof(buf) - 1;
+ *((s = (char*)memcpy(buf, s, n)) + n) = 0;
+ while (isspace(*t))
+ t++;
+ }
+ if (options & OPT_CHOWN)
+ {
+ if (*s)
+ {
+ if ((n = struid(s)) == NOID)
+ {
+ n = (int)strtol(s, &z, 0);
+ if (*z)
+ error(ERROR_exit(1), "%s: unknown user", s);
+ }
+ *uid = n;
+ }
+ for (s = t; (n = *t) && !isspace(n); t++);
+ if (n)
+ {
+ if ((n = t++ - s) >= sizeof(buf))
+ n = sizeof(buf) - 1;
+ *((s = (char*)memcpy(buf, s, n)) + n) = 0;
+ }
+ }
+ if (*s)
+ {
+ if ((n = strgid(s)) == NOID)
+ {
+ n = (int)strtol(s, &z, 0);
+ if (*z)
+ error(ERROR_exit(1), "%s: unknown group", s);
+ }
+ *gid = n;
+ }
+ if (e)
+ *e = t;
+}
+
+int
+b_chgrp(int argc, char** argv, void* context)
+{
+ register int options = 0;
+ register char* s;
+ register Map_t* m;
+ register FTS* fts;
+ register FTSENT*ent;
+ Dt_t* map = 0;
+ int flags;
+ int uid;
+ int gid;
+ char* op;
+ char* usage;
+ Sfio_t* sp;
+ Dtdisc_t mapdisc;
+ struct stat st;
+ int (*chownf)(const char*, uid_t, gid_t);
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, ERROR_NOTIFY);
+ flags = fts_flags() | FTS_TOP | FTS_NOPOSTORDER | FTS_NOSEEDOTDIR;
+ if (!(sp = sfstropen()))
+ error(ERROR_SYSTEM|3, "out of space");
+ sfputr(sp, usage_1, -1);
+ if (error_info.id[2] == 'g')
+ sfputr(sp, usage_grp_1, -1);
+ else
+ {
+ sfputr(sp, usage_own_1, -1);
+ options |= OPT_CHOWN;
+ }
+ sfputr(sp, usage_2, -1);
+ if (options & OPT_CHOWN)
+ sfputr(sp, ERROR_translate(0, 0, 0, "[owner[:group]]"), -1);
+ else
+ sfputr(sp, ERROR_translate(0, 0, 0, "[[owner:]group]"), -1);
+ sfputr(sp, usage_3, -1);
+ if (!(usage = sfstruse(sp)))
+ error(ERROR_SYSTEM|3, "out of space");
+ for (;;)
+ {
+ switch (optget(argv, usage))
+ {
+ case 'c':
+ case 'v':
+ options |= OPT_VERBOSE;
+ continue;
+ case 'f':
+ options |= OPT_FORCE;
+ continue;
+ case 'l':
+ options |= OPT_LCHOWN;
+ continue;
+ case 'm':
+ memset(&mapdisc, 0, sizeof(mapdisc));
+ mapdisc.key = offsetof(Map_t, id);
+ mapdisc.size = sizeof(int);
+ if (!(map = dtopen(&mapdisc, Dthash)))
+ error(ERROR_exit(1), "out of space [id map]");
+ continue;
+ case 'n':
+ options |= OPT_SHOW;
+ continue;
+ case 'r':
+ if (stat(opt_info.arg, &st))
+ error(ERROR_exit(1), "%s: cannot stat", opt_info.arg);
+ uid = st.st_uid;
+ gid = st.st_gid;
+ options |= OPT_UID|OPT_GID;
+ continue;
+ case 'H':
+ flags |= FTS_META|FTS_PHYSICAL;
+ continue;
+ case 'L':
+ flags &= ~(FTS_META|FTS_PHYSICAL);
+ continue;
+ case 'P':
+ flags &= ~FTS_META;
+ flags |= FTS_PHYSICAL;
+ continue;
+ case 'R':
+ flags &= ~FTS_TOP;
+ continue;
+ case 'X':
+ options |= OPT_TEST;
+ continue;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ continue;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ argc -= opt_info.index;
+ if (error_info.errors || argc < 2)
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ s = *argv;
+ if (map)
+ {
+ char* t;
+ int nuid;
+ int ngid;
+
+ if (streq(s, "-"))
+ sp = sfstdin;
+ else if (!(sp = sfopen(NiL, s, "r")))
+ error(ERROR_exit(1), "%s: cannot read", s);
+ while (s = sfgetr(sp, '\n', 1))
+ {
+ getids(s, &t, &uid, &gid, options);
+ getids(t, NiL, &nuid, &ngid, options);
+ if (uid != NOID)
+ {
+ if (m = (Map_t*)dtmatch(map, &uid))
+ {
+ m->uid = nuid;
+ if (m->gid == NOID)
+ m->gid = ngid;
+ }
+ else if (m = (Map_t*)stakalloc(sizeof(Map_t)))
+ {
+ m->id = uid;
+ m->uid = nuid;
+ m->gid = ngid;
+ dtinsert(map, m);
+ }
+ else
+ error(ERROR_exit(1), "out of space [id dictionary]");
+ }
+ if (gid != NOID)
+ {
+ if (gid == uid || (m = (Map_t*)dtmatch(map, &gid)))
+ m->gid = ngid;
+ else if (m = (Map_t*)stakalloc(sizeof(Map_t)))
+ {
+ m->id = gid;
+ m->uid = NOID;
+ m->gid = ngid;
+ dtinsert(map, m);
+ }
+ else
+ error(ERROR_exit(1), "out of space [id dictionary]");
+ }
+ }
+ if (sp != sfstdin)
+ sfclose(sp);
+ }
+ else if (!(options & (OPT_UID|OPT_GID)))
+ {
+ getids(s, NiL, &uid, &gid, options);
+ if (uid != NOID)
+ options |= OPT_UID;
+ if (gid != NOID)
+ options |= OPT_GID;
+ }
+ switch (options & (OPT_UID|OPT_GID))
+ {
+ case OPT_UID:
+ s = ERROR_translate(0, 0, 0, " owner");
+ break;
+ case OPT_GID:
+ s = ERROR_translate(0, 0, 0, " group");
+ break;
+ case OPT_UID|OPT_GID:
+ s = ERROR_translate(0, 0, 0, " owner and group");
+ break;
+ default:
+ s = "";
+ break;
+ }
+ if (!(fts = fts_open(argv + 1, flags, NiL)))
+ error(ERROR_system(1), "%s: not found", argv[1]);
+ while (!cmdquit() && (ent = fts_read(fts)))
+ switch (ent->fts_info)
+ {
+ case FTS_F:
+ case FTS_D:
+ case FTS_SL:
+ case FTS_SLNONE:
+ anyway:
+ if (map)
+ {
+ options &= ~(OPT_UID|OPT_GID);
+ uid = ent->fts_statp->st_uid;
+ gid = ent->fts_statp->st_gid;
+ if ((m = (Map_t*)dtmatch(map, &uid)) && m->uid != NOID)
+ {
+ uid = m->uid;
+ options |= OPT_UID;
+ }
+ if (gid != uid)
+ m = (Map_t*)dtmatch(map, &gid);
+ if (m && m->gid != NOID)
+ {
+ gid = m->gid;
+ options |= OPT_GID;
+ }
+ }
+ else
+ {
+ if (!(options & OPT_UID))
+ uid = ent->fts_statp->st_uid;
+ if (!(options & OPT_GID))
+ gid = ent->fts_statp->st_gid;
+ }
+ if (uid != ent->fts_statp->st_uid || gid != ent->fts_statp->st_gid)
+ {
+ if ((ent->fts_info & FTS_SL) && (flags & FTS_PHYSICAL) && (options & OPT_LCHOWN))
+ {
+ op = "lchown";
+ chownf = lchown;
+ }
+ else
+ {
+ op = "chown";
+ chownf = chown;
+ }
+ if (options & (OPT_SHOW|OPT_VERBOSE))
+ {
+ if (options & OPT_TEST)
+ {
+ ent->fts_statp->st_uid = 0;
+ ent->fts_statp->st_gid = 0;
+ }
+ sfprintf(sfstdout, "%s uid:%05d->%05d gid:%05d->%05d %s\n", op, ent->fts_statp->st_uid, uid, ent->fts_statp->st_gid, gid, ent->fts_accpath);
+ }
+ if (!(options & OPT_SHOW) && (*chownf)(ent->fts_accpath, uid, gid) && !(options & OPT_FORCE))
+ error(ERROR_system(0), "%s: cannot change%s", ent->fts_accpath, s);
+ }
+ break;
+ case FTS_DC:
+ if (!(options & OPT_FORCE))
+ error(ERROR_warn(0), "%s: directory causes cycle", ent->fts_accpath);
+ break;
+ case FTS_DNR:
+ if (!(options & OPT_FORCE))
+ error(ERROR_system(0), "%s: cannot read directory", ent->fts_accpath);
+ goto anyway;
+ case FTS_DNX:
+ if (!(options & OPT_FORCE))
+ error(ERROR_system(0), "%s: cannot search directory", ent->fts_accpath);
+ goto anyway;
+ case FTS_NS:
+ if (!(options & OPT_FORCE))
+ error(ERROR_system(0), "%s: not found", ent->fts_accpath);
+ break;
+ }
+ fts_close(fts);
+ if (map)
+ dtclose(map);
+ return error_info.errors != 0;
+}
diff --git a/usr/src/lib/libcmd/common/chmod.c b/usr/src/lib/libcmd/common/chmod.c
new file mode 100644
index 0000000000..b1745585a0
--- /dev/null
+++ b/usr/src/lib/libcmd/common/chmod.c
@@ -0,0 +1,296 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * chmod
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: chmod (AT&T Research) 2007-07-26 $\n]"
+USAGE_LICENSE
+"[+NAME?chmod - change the access permissions of files]"
+"[+DESCRIPTION?\bchmod\b changes the permission of each file "
+ "according to mode, which can be either a symbolic representation "
+ "of changes to make, or an octal number representing the bit "
+ "pattern for the new permissions.]"
+"[+?Symbolic mode strings consist of one or more comma separated list "
+ "of operations that can be perfomed on the mode. Each operation is of "
+ "the form \auser\a \aop\a \aperm\a where \auser\a is zero or more of "
+ "the following letters:]{"
+ "[+u?User permission bits.]"
+ "[+g?Group permission bits.]"
+ "[+o?Other permission bits.]"
+ "[+a?All permission bits. This is the default if none are specified.]"
+ "}"
+"[+?The \aperm\a portion consists of zero or more of the following letters:]{"
+ "[+r?Read permission.]"
+ "[+s?Setuid when \bu\b is selected for \awho\a and setgid when \bg\b "
+ "is selected for \awho\a.]"
+ "[+w?Write permission.]"
+ "[+x?Execute permission for files, search permission for directories.]"
+ "[+X?Same as \bx\b except that it is ignored for files that do not "
+ "already have at least one \bx\b bit set.]"
+ "[+l?Exclusive lock bit on systems that support it. Group execute "
+ "must be off.]"
+ "[+t?Sticky bit on systems that support it.]"
+ "}"
+"[+?The \aop\a portion consists of one or more of the following characters:]{"
+ "[++?Cause the permission selected to be added to the existing "
+ "permissions. | is equivalent to +.]"
+ "[+-?Cause the permission selected to be removed to the existing "
+ "permissions.]"
+ "[+=?Cause the permission to be set to the given permissions.]"
+ "[+&?Cause the permission selected to be \aand\aed with the existing "
+ "permissions.]"
+ "[+^?Cause the permission selected to be propagated to more "
+ "restrictive groups.]"
+ "}"
+"[+?Symbolic modes with the \auser\a portion omitted are subject to "
+ "\bumask\b(2) settings unless the \b=\b \aop\a or the "
+ "\b--ignore-umask\b option is specified.]"
+"[+?A numeric mode is from one to four octal digits (0-7), "
+ "derived by adding up the bits with values 4, 2, and 1. "
+ "Any omitted digits are assumed to be leading zeros. The "
+ "first digit selects the set user ID (4) and set group ID "
+ "(2) and save text image (1) attributes. The second digit "
+ "selects permissions for the user who owns the file: read "
+ "(4), write (2), and execute (1); the third selects permissions"
+ "for other users in the file's group, with the same values; "
+ "and the fourth for other users not in the file's group, with "
+ "the same values.]"
+
+"[+?For symbolic links, by default, \bchmod\b changes the mode on the file "
+ "referenced by the symbolic link, not on the symbolic link itself. "
+ "The \b-h\b options can be specified to change the mode of the link. "
+ "When traversing directories with \b-R\b, \bchmod\b either follows "
+ "symbolic links or does not follow symbolic links, based on the "
+ "options \b-H\b, \b-L\b, and \b-P\b. The configuration parameter "
+ "\bPATH_RESOLVE\b determines the default behavior if none of these "
+ "options is specified.]"
+
+"[+?When the \b-c\b or \b-v\b options are specified, change notifications "
+ "are written to standard output using the format, "
+ "\bmode of %s changed to %0.4o (%s)\b, with arguments of the "
+ "pathname, the numeric mode, and the resulting permission bits as "
+ "would be displayed by the \bls\b command.]"
+
+"[+?For backwards compatibility, if an invalid option is given that is a valid "
+ "symbolic mode specification, \bchmod\b treats this as a mode "
+ "specification rather than as an option specification.]"
+
+"[H:metaphysical?Follow symbolic links for command arguments; otherwise don't "
+ "follow symbolic links when traversing directories.]"
+"[L:logical|follow?Follow symbolic links when traversing directories.]"
+"[P:physical|nofollow?Don't follow symbolic links when traversing directories.]"
+"[R:recursive?Change the mode for files in subdirectories recursively.]"
+"[c:changes?Describe only files whose permission actually change.]"
+"[f:quiet|silent?Do not report files whose permissioins fail to change.]"
+"[h:symlink?Change the mode of the symbolic links on systems that "
+ "support this.]"
+"[i:ignore-umask?Ignore the \bumask\b(2) value in symbolic mode "
+ "expressions. This is probably how you expect \bchmod\b to work.]"
+"[F:reference?Omit the \amode\a operand and use the mode of \afile\a "
+ "instead.]:[file]"
+"[v:verbose?Describe changed permissions of all files.]"
+"\n"
+"\nmode file ...\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?All files changed successfully.]"
+ "[+>0?Unable to change mode of one or more files.]"
+"}"
+"[+SEE ALSO?\bchgrp\b(1), \bchown\b(1), \btw\b(1), \bgetconf\b(1), \bls\b(1), "
+ "\bumask\b(2)]"
+;
+
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide lchmod
+#else
+#define lchmod ______lchmod
+#endif
+
+#include <cmd.h>
+#include <ls.h>
+#include <fts.h>
+
+#include "FEATURE/symlink"
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide lchmod
+#else
+#undef lchmod
+#endif
+
+extern int lchmod(const char*, mode_t);
+
+int
+b_chmod(int argc, char** argv, void* context)
+{
+ register int mode;
+ register int force = 0;
+ register int flags;
+ register char* amode = 0;
+ register FTS* fts;
+ register FTSENT*ent;
+ char* last;
+ int (*chmodf)(const char*, mode_t);
+ int notify = 0;
+ int ignore = 0;
+#if _lib_lchmod
+ int chlink = 0;
+#endif
+ struct stat st;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, ERROR_NOTIFY);
+ flags = fts_flags() | FTS_TOP | FTS_NOPOSTORDER | FTS_NOSEEDOTDIR;
+
+ /*
+ * NOTE: we diverge from the normal optget boilerplate
+ * to allow `chmod -x etc' to fall through
+ */
+
+ for (;;)
+ {
+ switch (optget(argv, usage))
+ {
+ case 'c':
+ notify = 1;
+ continue;
+ case 'f':
+ force = 1;
+ continue;
+ case 'h':
+#if _lib_lchmod
+ chlink = 1;
+#endif
+ continue;
+ case 'i':
+ ignore = 1;
+ continue;
+ case 'v':
+ notify = 2;
+ continue;
+ case 'F':
+ if (stat(opt_info.arg, &st))
+ error(ERROR_exit(1), "%s: cannot stat", opt_info.arg);
+ mode = st.st_mode;
+ amode = "";
+ continue;
+ case 'H':
+ flags |= FTS_META|FTS_PHYSICAL;
+ continue;
+ case 'L':
+ flags &= ~(FTS_META|FTS_PHYSICAL);
+ continue;
+ case 'P':
+ flags &= ~FTS_META;
+ flags |= FTS_PHYSICAL;
+ continue;
+ case 'R':
+ flags &= ~FTS_TOP;
+ continue;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ if (error_info.errors || !*argv || !amode && !*(argv + 1))
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ if (ignore)
+ ignore = umask(0);
+ if (amode)
+ amode = 0;
+ else
+ {
+ amode = *argv++;
+ mode = strperm(amode, &last, 0);
+ if (*last)
+ {
+ if (ignore)
+ umask(ignore);
+ error(ERROR_exit(1), "%s: invalid mode", amode);
+ }
+ }
+ chmodf =
+#if _lib_lchmod
+ chlink ? lchmod :
+#endif
+ chmod;
+ if (!(fts = fts_open(argv, flags, NiL)))
+ {
+ if (ignore)
+ umask(ignore);
+ error(ERROR_system(1), "%s: not found", *argv);
+ }
+ while (!cmdquit() && (ent = fts_read(fts)))
+ switch (ent->fts_info)
+ {
+ case FTS_SL:
+ if (chmodf == chmod)
+ {
+ if (!(flags & FTS_PHYSICAL) || (flags & FTS_META) && ent->fts_level == 1)
+ fts_set(NiL, ent, FTS_FOLLOW);
+ break;
+ }
+ /*FALLTHROUGH*/
+ case FTS_F:
+ case FTS_D:
+ case FTS_SLNONE:
+ anyway:
+ if (amode)
+ mode = strperm(amode, &last, ent->fts_statp->st_mode);
+ if ((*chmodf)(ent->fts_accpath, mode) >= 0)
+ {
+ if (notify == 2 || notify == 1 && (mode&S_IPERM) != (ent->fts_statp->st_mode&S_IPERM))
+ sfprintf(sfstdout, "%s: mode changed to %0.4o (%s)\n", ent->fts_path, mode, fmtmode(mode, 1)+1);
+ }
+ else if (!force)
+ error(ERROR_system(0), "%s: cannot change mode", ent->fts_accpath);
+ break;
+ case FTS_DC:
+ if (!force)
+ error(ERROR_warn(0), "%s: directory causes cycle", ent->fts_accpath);
+ break;
+ case FTS_DNR:
+ if (!force)
+ error(ERROR_system(0), "%s: cannot read directory", ent->fts_accpath);
+ goto anyway;
+ case FTS_DNX:
+ if (!force)
+ error(ERROR_system(0), "%s: cannot search directory", ent->fts_accpath);
+ goto anyway;
+ case FTS_NS:
+ if (!force)
+ error(ERROR_system(0), "%s: not found", ent->fts_accpath);
+ break;
+ }
+ fts_close(fts);
+ if (ignore)
+ umask(ignore);
+ return error_info.errors != 0;
+}
diff --git a/usr/src/lib/libcmd/common/chown.c b/usr/src/lib/libcmd/common/chown.c
new file mode 100644
index 0000000000..f31421df18
--- /dev/null
+++ b/usr/src/lib/libcmd/common/chown.c
@@ -0,0 +1,39 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * chown
+ */
+
+static const char id[] = "\n@(#)$Id: chown (AT&T Research) 1997-11-11 $\0\n";
+
+#include <cmd.h>
+
+int
+b_chown(int argc, char** argv, void* context)
+{
+ NoP(id[0]);
+ return b_chgrp(argc, argv, context);
+}
diff --git a/usr/src/lib/libcmd/common/cksum.c b/usr/src/lib/libcmd/common/cksum.c
new file mode 100644
index 0000000000..25d9ee0c0f
--- /dev/null
+++ b/usr/src/lib/libcmd/common/cksum.c
@@ -0,0 +1,599 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * sum -- list file checksum and size
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: sum (AT&T Research) 2007-02-07 $\n]"
+USAGE_LICENSE
+"[+NAME?cksum,md5sum,sum - print file checksum and block count]"
+"[+DESCRIPTION?\bsum\b lists the checksum, and for most methods the block"
+" count, for each file argument. The standard input is read if there are"
+" no \afile\a arguments. \bgetconf UNIVERSE\b determines the default"
+" \bsum\b method: \batt\b for the \batt\b universe, \bbsd\b otherwise."
+" The default for the other commands is the command name itself. The"
+" \batt\b method is a true sum, all others are order dependent.]"
+"[+?Method names consist of a leading identifier and 0 or more options"
+" separated by -.]"
+"[+?\bgetconf PATH_RESOLVE\b determines how symbolic links are handled. This"
+" can be explicitly overridden by the \b--logical\b, \b--metaphysical\b,"
+" and \b--physical\b options below. \bPATH_RESOLVE\b can be one of:]{"
+" [+logical?Follow all symbolic links.]"
+" [+metaphysical?Follow command argument symbolic links,"
+" otherwise don't follow.]"
+" [+physical?Don't follow symbolic links.]"
+"}"
+
+"[a:all?List the checksum for all files. Use with \b--total\b to list both"
+" individual and total checksums and block counts.]"
+"[b:binary?Read files in binary mode. This is the default.]"
+"[c:check?Each \afile\a is interpreted as the output from a previous \bsum\b."
+" If \b--header\b or \b--permissions\b was specified in the previous"
+" \bsum\b then the checksum method is automatically determined,"
+" otherwise \b--method\b must be specified. The listed checksum is"
+" compared with the current value and a warning is issued for each file"
+" that does not match. If \afile\a was generated by \b--permissions\b"
+" then the file mode, user and group are also checked. Empty lines,"
+" lines starting with \b#<space>\b, or the line \b#\b are ignored. Lines"
+" containing no blanks are interpreted as [no]]\aname\a[=\avalue\a]]"
+" options:]{"
+" [+method=name?Checksum method to apply to subsequent lines.]"
+" [+permissions?Subsequent lines were generated with"
+" \b--permissions\b.]"
+"}"
+"[h:header?Print the checksum method as the first output line. Used with"
+" \b--check\b and \b--permissions\b.]"
+"[l:list?Each \afile\a is interpreted as a list of files, one per line,"
+" that is checksummed.]"
+"[p:permissions?If \b--check\b is not specified then list the file"
+" mode, user and group between the checksum and path. User and group"
+" matching the caller are output as \b-\b. If \b--check\b is"
+" specified then the mode, user and group for each path in \afile\a"
+" are updated if necessary to match those in \afile\a. A warning is"
+" printed on the standard error for each changed file.]"
+"[r:recursive?Recursively checksum the contents of directories.]"
+"[s:silent|status?No output for \b--check\b; 0 exit status means all sums"
+" matched, non-0 means at least one sum failed to match. Ignored for"
+" \b--permissions\b.]"
+"[t:total?List only the total checksum and block count of all files."
+" \b--all\b \b--total\b lists each checksum and the total. The"
+" total checksum and block count may be different from the checksum"
+" and block count of the catenation of all files due to partial"
+" blocks that may occur when the files are treated separately.]"
+"[T:text?Read files in text mode (i.e., treat \b\\r\\n\b as \b\\n\b).]"
+"[w!:warn?Warn about invalid \b--check\b lines.]"
+"[x:method|algorithm?Specifies the checksum \amethod\a to"
+" apply. Parenthesized method options are readonly implementation"
+" details.]:[method]{\fmethods\f}"
+"[L:logical|follow?Follow symbolic links when traversing directories. The"
+" default is determined by \bgetconf PATH_RESOLVE\b.]"
+"[H:metaphysical?Follow command argument symbolic links, otherwise don't"
+" follow symbolic links when traversing directories. The default is"
+" determined by \bgetconf PATH_RESOLVE\b.]"
+"[P:physical?Don't follow symbolic links when traversing directories. The"
+" default is determined by \bgetconf PATH_RESOLVE\b.]"
+
+"\n"
+"\n[ file ... ]\n"
+"\n"
+
+"[+SEE ALSO?\bgetconf\b(1), \btw\b(1), \buuencode\b(1)]"
+;
+
+#include <cmd.h>
+#include <sum.h>
+#include <ls.h>
+#include <fts.h>
+#include <error.h>
+
+typedef struct State_s /* program state */
+{
+ int all; /* list all items */
+ Sfio_t* check; /* check previous output */
+ gid_t gid; /* caller gid */
+ int header; /* list method on output */
+ int list; /* list file name too */
+ Sum_t* oldsum; /* previous sum method */
+ int permissions; /* include mode,uer,group */
+ int haveperm; /* permissions in the input */
+ int recursive; /* recursively descend dirs */
+ unsigned long size; /* combined size of all files */
+ int silent; /* silent check, 0 exit if ok */
+ int (*sort)(FTSENT* const*, FTSENT* const*);
+ Sum_t* sum; /* sum method */
+ int text; /* \r\n == \n */
+ int total; /* list totals only */
+ uid_t uid; /* caller uid */
+ int warn; /* invalid check line warnings */
+} State_t;
+
+static void verify(State_t*, char*, char*, Sfio_t*);
+
+/*
+ * open path for read mode
+ */
+
+static Sfio_t*
+openfile(const char* path, const char* mode)
+{
+ Sfio_t* sp;
+
+ if (!path || streq(path, "-") || streq(path, "/dev/stdin") || streq(path, "/dev/fd/0"))
+ {
+ sp = sfstdin;
+ sfopen(sp, NiL, mode);
+ }
+ else if (!(sp = sfopen(NiL, path, mode)))
+ error(ERROR_SYSTEM|2, "%s: cannot read", path);
+ return sp;
+}
+
+/*
+ * close an openfile() stream
+ */
+
+static int
+closefile(Sfio_t* sp)
+{
+ return sp == sfstdin ? 0 : sfclose(sp);
+}
+
+/*
+ * compute and print sum on an open file
+ */
+
+static void
+pr(State_t* state, Sfio_t* op, Sfio_t* ip, char* file, int perm, struct stat* st, Sfio_t* check)
+{
+ register char* p;
+ register char* r;
+ register char* e;
+ register int peek;
+ struct stat ss;
+
+ if (check)
+ {
+ state->oldsum = state->sum;
+ while (p = sfgetr(ip, '\n', 1))
+ verify(state, p, file, check);
+ state->sum = state->oldsum;
+ if (state->warn && !sfeof(ip))
+ error(2, "%s: last line incomplete", file);
+ return;
+ }
+ suminit(state->sum);
+ if (state->text)
+ {
+ peek = 0;
+ while (p = sfreserve(ip, SF_UNBOUND, 0))
+ {
+ e = p + sfvalue(ip);
+ if (peek)
+ {
+ peek = 0;
+ if (*p != '\n')
+ sumblock(state->sum, "\r", 1);
+ }
+ while (r = memchr(p, '\r', e - p))
+ {
+ if (++r >= e)
+ {
+ e--;
+ peek = 1;
+ break;
+ }
+ sumblock(state->sum, p, r - p - (*r == '\n'));
+ p = r;
+ }
+ sumblock(state->sum, p, e - p);
+ }
+ if (peek)
+ sumblock(state->sum, "\r", 1);
+ }
+ else
+ while (p = sfreserve(ip, SF_UNBOUND, 0))
+ sumblock(state->sum, p, sfvalue(ip));
+ if (sfvalue(ip))
+ error(ERROR_SYSTEM|2, "%s: read error", file);
+ sumdone(state->sum);
+ if (!state->total || state->all)
+ {
+ sumprint(state->sum, op, SUM_SIZE|SUM_SCALE);
+ if (perm >= 0)
+ {
+ if (perm)
+ {
+ if (!st && fstat(sffileno(ip), st = &ss))
+ error(ERROR_SYSTEM|2, "%s: cannot stat", file);
+ else
+ sfprintf(sfstdout, " %04o %s %s",
+ modex(st->st_mode & S_IPERM),
+ (st->st_uid != state->uid && ((st->st_mode & S_ISUID) || (st->st_mode & S_IRUSR) && !(st->st_mode & (S_IRGRP|S_IROTH)) || (st->st_mode & S_IXUSR) && !(st->st_mode & (S_IXGRP|S_IXOTH)))) ? fmtuid(st->st_uid) : "-",
+ (st->st_gid != state->gid && ((st->st_mode & S_ISGID) || (st->st_mode & S_IRGRP) && !(st->st_mode & S_IROTH) || (st->st_mode & S_IXGRP) && !(st->st_mode & S_IXOTH))) ? fmtgid(st->st_gid) : "-");
+ }
+ if (ip != sfstdin)
+ sfprintf(op, " %s", file);
+ sfputc(op, '\n');
+ }
+ }
+}
+
+/*
+ * verify previous sum output
+ */
+
+static void
+verify(State_t* state, register char* s, char* check, Sfio_t* rp)
+{
+ register char* t;
+ char* e;
+ char* file;
+ int attr;
+ int mode;
+ int uid;
+ int gid;
+ Sfio_t* sp;
+ struct stat st;
+
+ if (!*s || *s == '#' && (!*(s + 1) || *(s + 1) == ' ' || *(s + 1) == '\t'))
+ return;
+ if (t = strchr(s, ' '))
+ {
+ if ((t - s) > 10 || !(file = strchr(t + 1, ' ')))
+ file = t;
+ *file++ = 0;
+ attr = 0;
+ if ((mode = strtol(file, &e, 8)) && *e == ' ' && (e - file) == 4)
+ {
+ mode = modei(mode);
+ if (t = strchr(++e, ' '))
+ {
+ if (*e == '-' && (t - e) == 1)
+ uid = -1;
+ else
+ {
+ *t = 0;
+ uid = struid(e);
+ *t = ' ';
+ }
+ if (e = strchr(++t, ' '))
+ {
+ if (*t == '-' && (e - t) == 1)
+ gid = -1;
+ else
+ {
+ *e = 0;
+ gid = struid(t);
+ *e = ' ';
+ }
+ file = e + 1;
+ attr = 1;
+ }
+ }
+ }
+ if (sp = openfile(file, "rb"))
+ {
+ pr(state, rp, sp, file, -1, NiL, NiL);
+ if (!(t = sfstruse(rp)))
+ error(ERROR_SYSTEM|3, "out of space");
+ if (!streq(s, t))
+ {
+ if (state->silent)
+ error_info.errors++;
+ else
+ error(2, "%s: checksum changed", file);
+ }
+ else if (attr)
+ {
+ if (fstat(sffileno(sp), &st))
+ {
+ if (state->silent)
+ error_info.errors++;
+ else
+ error(ERROR_SYSTEM|2, "%s: cannot stat", file);
+ }
+ else
+ {
+ if (uid < 0 || uid == st.st_uid)
+ uid = -1;
+ else if (!state->permissions)
+ {
+ if (state->silent)
+ error_info.errors++;
+ else
+ error(2, "%s: uid should be %s", file, fmtuid(uid));
+ }
+ if (gid < 0 || gid == st.st_gid)
+ gid = -1;
+ else if (!state->permissions)
+ {
+ if (state->silent)
+ error_info.errors++;
+ else
+ error(2, "%s: gid should be %s", file, fmtgid(gid));
+ }
+ if (state->permissions && (uid >= 0 || gid >= 0))
+ {
+ if (chown(file, uid, gid) < 0)
+ {
+ if (uid < 0)
+ error(ERROR_SYSTEM|2, "%s: cannot change group to %s", file, fmtgid(gid));
+ else if (gid < 0)
+ error(ERROR_SYSTEM|2, "%s: cannot change user to %s", file, fmtuid(uid));
+ else
+ error(ERROR_SYSTEM|2, "%s: cannot change user to %s and group to %s", file, fmtuid(uid), fmtgid(gid));
+ }
+ else
+ {
+ if (uid < 0)
+ error(1, "%s: changed group to %s", file, fmtgid(gid));
+ else if (gid < 0)
+ error(1, "%s: changed user to %s", file, fmtuid(uid));
+ else
+ error(1, "%s: changed user to %s and group to %s", file, fmtuid(uid), fmtgid(gid));
+ }
+ }
+ if ((st.st_mode & S_IPERM) ^ mode)
+ {
+ if (state->permissions)
+ {
+ if (chmod(file, mode) < 0)
+ error(ERROR_SYSTEM|2, "%s: cannot change mode to %s", file, fmtmode(mode, 0));
+ else
+ error(ERROR_SYSTEM|1, "%s: changed mode to %s", file, fmtmode(mode, 0));
+ }
+ else if (state->silent)
+ error_info.errors++;
+ else
+ error(2, "%s: mode should be %s", file, fmtmode(mode, 0));
+ }
+ }
+ }
+ closefile(sp);
+ }
+ }
+ else if (strneq(s, "method=", 7))
+ {
+ s += 7;
+ if (state->sum != state->oldsum)
+ sumclose(state->sum);
+ if (!(state->sum = sumopen(s)))
+ error(3, "%s: %s: unknown checksum method", check, s);
+ }
+ else if (streq(s, "permissions"))
+ state->haveperm = 1;
+ else
+ error(1, "%s: %s: unknown option", check, s);
+}
+
+/*
+ * sum the list of files in lp
+ */
+
+static void
+list(State_t* state, register Sfio_t* lp)
+{
+ register char* file;
+ register Sfio_t* sp;
+
+ while (file = sfgetr(lp, '\n', 1))
+ if (sp = openfile(file, state->check ? "rt" : "rb"))
+ {
+ pr(state, sfstdout, sp, file, state->permissions, NiL, state->check);
+ closefile(sp);
+ }
+}
+
+/*
+ * order child entries
+ */
+
+static int
+order(FTSENT* const* f1, FTSENT* const* f2)
+{
+ return strcoll((*f1)->fts_name, (*f2)->fts_name);
+}
+
+/*
+ * optget() info discipline function
+ */
+
+static int
+optinfo(Opt_t* op, Sfio_t* sp, const char* s, Optdisc_t* dp)
+{
+ if (streq(s, "methods"))
+ return sumusage(sp);
+ return 0;
+}
+
+int
+b_cksum(int argc, register char** argv, void* context)
+{
+ register int flags;
+ register char* s;
+ char* file;
+ Sfio_t* sp;
+ FTS* fts;
+ FTSENT* ent;
+ Optdisc_t optdisc;
+ State_t state;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, ERROR_NOTIFY);
+ memset(&state, 0, sizeof(state));
+ setlocale(LC_ALL, "");
+ flags = fts_flags() | FTS_TOP | FTS_NOPOSTORDER | FTS_NOSEEDOTDIR;
+ state.warn = 1;
+ optinit(&optdisc, optinfo);
+ for (;;)
+ {
+ switch (optget(argv, usage))
+ {
+ case 'a':
+ state.all = 1;
+ continue;
+ case 'b':
+ state.text = 0;
+ continue;
+ case 'c':
+ if (!(state.check = sfstropen()))
+ error(3, "out of space [check]");
+ continue;
+ case 'h':
+ state.header = 1;
+ continue;
+ case 'l':
+ state.list = 1;
+ continue;
+ case 'p':
+ state.permissions = 1;
+ continue;
+ case 'r':
+ flags &= ~FTS_TOP;
+ state.recursive = 1;
+ state.sort = order;
+ continue;
+ case 's':
+ state.silent = opt_info.num;
+ continue;
+ case 't':
+ state.total = 1;
+ continue;
+ case 'w':
+ state.warn = opt_info.num;
+ continue;
+ case 'x':
+ if (!(state.sum = sumopen(opt_info.arg)))
+ error(3, "%s: unknown checksum method", opt_info.arg);
+ continue;
+ case 'H':
+ flags |= FTS_META|FTS_PHYSICAL;
+ continue;
+ case 'L':
+ flags &= ~(FTS_META|FTS_PHYSICAL);
+ continue;
+ case 'P':
+ flags &= ~FTS_META;
+ flags |= FTS_PHYSICAL;
+ continue;
+ case 'T':
+ state.text = 1;
+ continue;
+ case '?':
+ error(ERROR_USAGE|4, "%s", opt_info.arg);
+ break;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ break;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ if (error_info.errors)
+ error(ERROR_USAGE|4, "%s", optusage(NiL));
+
+ /*
+ * check the method
+ */
+
+ if (!state.sum && !(state.sum = sumopen(error_info.id)) && !(state.sum = sumopen(astconf("UNIVERSE", NiL, NiL))))
+ state.sum = sumopen(NiL);
+
+ /*
+ * do it
+ */
+
+ if (state.permissions)
+ {
+ state.uid = geteuid();
+ state.gid = getegid();
+ state.silent = 0;
+ }
+ if (!state.check && (state.header || state.permissions))
+ {
+ sfprintf(sfstdout, "method=%s\n", state.sum->name);
+ if (state.permissions)
+ sfprintf(sfstdout, "permissions\n");
+ }
+ if (state.list)
+ {
+ if (*argv)
+ {
+ while (file = *argv++)
+ if (sp = openfile(file, "rt"))
+ {
+ list(&state, sp);
+ closefile(sp);
+ }
+ }
+ else if (sp = openfile(NiL, "rt"))
+ {
+ list(&state, sp);
+ closefile(sp);
+ }
+ }
+ else if (!*argv && !state.recursive)
+ pr(&state, sfstdout, sfstdin, "/dev/stdin", state.permissions, NiL, state.check);
+ else if (!(fts = fts_open(argv, flags, state.sort)))
+ error(ERROR_system(1), "%s: not found", *argv);
+ else
+ {
+ while (!cmdquit() && (ent = fts_read(fts)))
+ switch (ent->fts_info)
+ {
+ case FTS_SL:
+ if (!(flags & FTS_PHYSICAL) || (flags & FTS_META) && ent->fts_level == 1)
+ fts_set(NiL, ent, FTS_FOLLOW);
+ break;
+ case FTS_F:
+ if (sp = openfile(ent->fts_accpath, "rb"))
+ {
+ pr(&state, sfstdout, sp, ent->fts_path, state.permissions, ent->fts_statp, state.check);
+ closefile(sp);
+ }
+ break;
+ case FTS_DC:
+ error(ERROR_warn(0), "%s: directory causes cycle", ent->fts_accpath);
+ break;
+ case FTS_DNR:
+ error(ERROR_system(0), "%s: cannot read directory", ent->fts_accpath);
+ break;
+ case FTS_DNX:
+ error(ERROR_system(0), "%s: cannot search directory", ent->fts_accpath);
+ break;
+ case FTS_NS:
+ error(ERROR_system(0), "%s: not found", ent->fts_accpath);
+ break;
+ }
+ fts_close(fts);
+ }
+ if (state.total)
+ {
+ sumprint(state.sum, sfstdout, SUM_TOTAL|SUM_SIZE|SUM_SCALE);
+ sfputc(sfstdout, '\n');
+ }
+ sumclose(state.sum);
+ return error_info.errors != 0;
+}
diff --git a/usr/src/lib/libcmd/common/cmd.h b/usr/src/lib/libcmd/common/cmd.h
new file mode 100644
index 0000000000..50092c2018
--- /dev/null
+++ b/usr/src/lib/libcmd/common/cmd.h
@@ -0,0 +1,173 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * AT&T Research
+ *
+ * builtin cmd definitions
+ */
+
+#ifndef _CMD_H
+#define _CMD_H
+
+#include <ast.h>
+#include <error.h>
+#include <stak.h>
+
+#define cmdinit _cmd_init
+#define cmdquit() 0
+
+#if _BLD_cmd && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+#include <cmdext.h>
+
+#undef extern
+
+#if defined(CMD_BUILTIN) && !defined(CMD_STANDALONE)
+#define CMD_STANDALONE CMD_BUILTIN
+#endif
+
+#ifdef CMD_STANDALONE
+
+#if CMD_DYNAMIC
+
+#include <dlldefs.h>
+
+typedef int (*Builtin_f)(int, char**, void*);
+
+#else
+
+extern int CMD_STANDALONE(int, char**, void*);
+
+#endif
+
+#ifndef CMD_BUILTIN
+
+/*
+ * command initialization
+ */
+
+static int
+cmdinit(int argc, register char** argv, void* context, const char* catalog, int flags)
+{
+ register char* cp;
+ register char* pp;
+
+ if (cp = strrchr(argv[0], '/'))
+ cp++;
+ else
+ cp = argv[0];
+ if (pp = strrchr(cp, '_'))
+ cp = pp + 1;
+ error_info.id = cp;
+ if (!error_info.catalog)
+ error_info.catalog = (char*)catalog;
+ opt_info.index = 0;
+ if (context)
+ error_info.flags |= flags;
+ return 0;
+}
+
+#endif
+
+int
+main(int argc, char** argv)
+{
+#if CMD_DYNAMIC
+ register char* s;
+ register char* t;
+ void* dll;
+ Builtin_f fun;
+ char buf[64];
+
+ if (s = strrchr(argv[0], '/'))
+ s++;
+ else if (!(s = argv[0]))
+ return 127;
+ if ((t = strrchr(s, '_')) && *++t)
+ s = t;
+ buf[0] = '_';
+ buf[1] = 'b';
+ buf[2] = '_';
+ strncpy(buf + 3, s, sizeof(buf) - 4);
+ buf[sizeof(buf) - 1] = 0;
+ if (t = strchr(buf, '.'))
+ *t = 0;
+ for (;;)
+ {
+ if (dll = dlopen(NiL, RTLD_LAZY))
+ {
+ if (fun = (Builtin_f)dlsym(dll, buf + 1))
+ break;
+ if (fun = (Builtin_f)dlsym(dll, buf))
+ break;
+ }
+ if (dll = dllfind("cmd", NiL, RTLD_LAZY))
+ {
+ if (fun = (Builtin_f)dlsym(dll, buf + 1))
+ break;
+ if (fun = (Builtin_f)dlsym(dll, buf))
+ break;
+ }
+ return 127;
+ }
+ return (*fun)(argc, argv, NiL);
+#else
+ return CMD_STANDALONE(argc, argv, NiL);
+#endif
+}
+
+#else
+
+#undef cmdinit
+#define cmdinit(a,b,c,d,e) do{if(_cmd_init(a,b,c,d,e))return -1;}while(0)
+
+#ifndef CMD_BUILTIN
+
+#undef cmdquit
+#define cmdquit() (_cmd_quit)
+
+#if _BLD_cmd && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+#if !_BLD_cmd && defined(__IMPORT__)
+#define extern extern __IMPORT__
+#endif
+
+extern int _cmd_quit;
+
+#undef extern
+
+#endif
+
+#if _BLD_cmd && defined(__EXPORT__)
+#define extern extern __EXPORT__
+#endif
+
+extern int _cmd_init(int, char**, void*, const char*, int);
+
+#undef extern
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libcmd/common/cmdinit.c b/usr/src/lib/libcmd/common/cmdinit.c
new file mode 100644
index 0000000000..0a8f4359c8
--- /dev/null
+++ b/usr/src/lib/libcmd/common/cmdinit.c
@@ -0,0 +1,68 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * command initialization
+ */
+
+#include <cmd.h>
+
+int _cmd_quit = 0;
+
+int
+_cmd_init(int argc, char** argv, void* context, const char* catalog, int flags)
+{
+ register char* cp;
+
+ if (argc < 0)
+ {
+ _cmd_quit = 1;
+ return -1;
+ }
+ _cmd_quit = 0;
+ if (cp = strrchr(argv[0], '/'))
+ cp++;
+ else
+ cp = argv[0];
+ error_info.id = cp;
+ if (!error_info.catalog)
+ error_info.catalog = catalog;
+ opt_info.index = 0;
+ if (context)
+ error_info.flags |= flags;
+ return 0;
+}
+
+#if __OBSOLETE__ < 20080101
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+#undef cmdinit
+
+extern void
+cmdinit(char** argv, void* context, const char* catalog, int flags)
+{
+ _cmd_init(0, argv, context, catalog, flags);
+}
+
+#endif
diff --git a/usr/src/lib/libcmd/common/cmp.c b/usr/src/lib/libcmd/common/cmp.c
new file mode 100644
index 0000000000..3baebdd8da
--- /dev/null
+++ b/usr/src/lib/libcmd/common/cmp.c
@@ -0,0 +1,288 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * Glenn Fowler
+ * AT&T Bell Laboratories
+ *
+ * cmp
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: cmp (AT&T Research) 2004-12-01 $\n]"
+USAGE_LICENSE
+"[+NAME?cmp - compare two files]"
+"[+DESCRIPTION?\bcmp\b compares two files \afile1\a and \afile2\a. "
+ "\bcmp\b writes no output if the files are the same. By default, "
+ "if the files differ, the byte and line number at which the "
+ "first difference occurred are written to standard output. Bytes "
+ "and lines are numbered beginning with 1.]"
+"[+?If \askip1\a or \askip2\a are specified, or the \b-i\b option is "
+ "specified, initial bytes of the corresponding file are skipped "
+ "before beginning the compare. The skip values are in bytes or "
+ "can have a suffix of \bk\b for kilobytes or \bm\b for megabytes.]"
+"[+?If either \afile1\a or \afiles2\a is \b-\b, \bcmp\b "
+ "uses standard input starting at the current location.]"
+"[c:print-chars?Writes control characters as a \b^\b followed by a letter of "
+ "the alphabet and precede characters that have the high bit set with "
+ "\bM-\b as with \bcat\b(1).]"
+"[i:ignore-initial]#[skip:=0?Sets default skip values for the operands "
+ "\askip1\a and \askip2\a to \askip\a.]"
+"[l:verbose?Write the decimal byte number and the differing bytes (in octal) "
+ "for each difference.]"
+"[s:quiet|silent?Write nothing for differing files; return non-zero "
+ "exit status only.] ]"
+"\n"
+"\nfile1 file2 [skip1 [skip2]]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?The files or portions compared are identical.]"
+ "[+1?The files are different.]"
+ "[+>1?An error occurred.]"
+"}"
+"[+SEE ALSO?\bcomm\b(1), \bdiff\b(1), \bcat\b(1)]"
+;
+
+
+#include <cmd.h>
+#include <ls.h>
+#include <ctype.h>
+
+#define CMP_VERBOSE 1
+#define CMP_SILENT 2
+#define CMP_CHARS 4
+
+#define cntl(x) (x&037)
+#define printchar(c) ((c) ^ ('A'-cntl('A')))
+
+static void outchar(Sfio_t *out, register int c, int delim)
+{
+ if(c&0200)
+ {
+ sfputc(out,'M');
+ sfputc(out,'-');
+ c &= ~0200;
+ }
+ else if(!isprint(c))
+ {
+ sfputc(out,'^');
+ c = printchar(c);
+ }
+ sfputc(out,c);
+ sfputc(out,delim);
+}
+
+/*
+ * compare two files
+ */
+
+static int
+cmp(const char* file1, Sfio_t* f1, const char* file2, Sfio_t* f2, int flags)
+{
+ register int c1;
+ register int c2;
+ register unsigned char* p1 = 0;
+ register unsigned char* p2 = 0;
+ register Sfoff_t lines = 1;
+ register unsigned char* e1 = 0;
+ register unsigned char* e2 = 0;
+ Sfoff_t pos = 0;
+ int ret = 0;
+ unsigned char* last;
+
+ for (;;)
+ {
+ if ((c1 = e1 - p1) <= 0)
+ {
+ if (!(p1 = (unsigned char*)sfreserve(f1, SF_UNBOUND, 0)) || (c1 = sfvalue(f1)) <= 0)
+ {
+ if ((e2 - p2) > 0 || sfreserve(f2, SF_UNBOUND, 0) && sfvalue(f2) > 0)
+ {
+ ret = 1;
+ if (!(flags & CMP_SILENT))
+ error(ERROR_exit(1), "%s: EOF", file1);
+ }
+ return(ret);
+ }
+ e1 = p1 + c1;
+ }
+ if ((c2 = e2 - p2) <= 0)
+ {
+ if (!(p2 = (unsigned char*)sfreserve(f2, SF_UNBOUND, 0)) || (c2 = sfvalue(f2)) <= 0)
+ {
+ if (!(flags & CMP_SILENT))
+ error(ERROR_exit(1), "%s: EOF", file2);
+ return(1);
+ }
+ e2 = p2 + c2;
+ }
+ if (c1 > c2)
+ c1 = c2;
+ pos += c1;
+ if (flags & CMP_SILENT)
+ {
+ if (memcmp(p1, p2, c1))
+ return(1);
+ p1 += c1;
+ p2 += c1;
+ }
+ else
+ {
+ last = p1 + c1;
+ while (p1 < last)
+ {
+ if ((c1 = *p1++) != *p2++)
+ {
+ if (flags)
+ {
+ ret = 1;
+ if(flags&CMP_CHARS)
+ {
+ sfprintf(sfstdout, "%6I*d ", sizeof(pos), pos - (last - p1));
+ outchar(sfstdout,c1,' ');
+ outchar(sfstdout,*(p2-1),'\n');
+ }
+ else
+ sfprintf(sfstdout, "%6I*d %3o %3o\n", sizeof(pos), pos - (last - p1), c1, *(p2 - 1));
+ }
+ else
+ {
+ sfprintf(sfstdout, "%s %s differ: char %I*d, line %I*u\n", file1, file2, sizeof(pos), pos - (last - p1), sizeof(lines), lines);
+ return(1);
+ }
+ }
+ if (c1 == '\n')
+ lines++;
+ }
+ }
+ }
+}
+
+int
+b_cmp(int argc, register char** argv, void* context)
+{
+ char* s;
+ char* e;
+ Sfio_t* f1 = 0;
+ Sfio_t* f2 = 0;
+ char* file1;
+ char* file2;
+ int n;
+ off_t o1 = 0;
+ off_t o2 = 0;
+ struct stat s1;
+ struct stat s2;
+
+ int flags = 0;
+
+ NoP(argc);
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ while (n = optget(argv, usage)) switch (n)
+ {
+ case 'l':
+ flags |= CMP_VERBOSE;
+ break;
+ case 's':
+ flags |= CMP_SILENT;
+ break;
+ case 'c':
+ flags |= CMP_CHARS;
+ break;
+ case 'i':
+ o1 = o2 = opt_info.num;
+ break;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ if (error_info.errors || !(file1 = *argv++) || !(file2 = *argv++))
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ n = 2;
+ if (streq(file1, "-"))
+ f1 = sfstdin;
+ else if (!(f1 = sfopen(NiL, file1, "r")))
+ {
+ if (!(flags & CMP_SILENT))
+ error(ERROR_system(0), "%s: cannot open", file1);
+ goto done;
+ }
+ if (streq(file2, "-"))
+ f2 = sfstdin;
+ else if (!(f2 = sfopen(NiL, file2, "r")))
+ {
+ if (!(flags & CMP_SILENT))
+ error(ERROR_system(0), "%s: cannot open", file2);
+ goto done;
+ }
+ if (s = *argv++)
+ {
+ o1 = strtol(s, &e, 0);
+ if (*e)
+ {
+ error(ERROR_exit(0), "%s: %s: invalid skip", file1, s);
+ goto done;
+ }
+ if (s = *argv++)
+ {
+ o2 = strtol(s, &e, 0);
+ if (*e)
+ {
+ error(ERROR_exit(0), "%s: %s: invalid skip", file2, s);
+ goto done;
+ }
+ }
+ if (*argv)
+ {
+ error(ERROR_usage(0), "%s", optusage(NiL));
+ goto done;
+ }
+ }
+ if (o1 && sfseek(f1, o1, SEEK_SET) != o1)
+ {
+ if (!(flags & CMP_SILENT))
+ error(ERROR_exit(0), "%s: EOF", file1);
+ n = 1;
+ goto done;
+ }
+ if (o2 && sfseek(f2, o2, SEEK_SET) != o2)
+ {
+ if (!(flags & CMP_SILENT))
+ error(ERROR_exit(0), "%s: EOF", file2);
+ n = 1;
+ goto done;
+ }
+ if (fstat(sffileno(f1), &s1))
+ error(ERROR_system(0), "%s: cannot stat", file1);
+ else if (fstat(sffileno(f2), &s2))
+ error(ERROR_system(0), "%s: cannot stat", file1);
+ else if (s1.st_ino == s2.st_ino && s1.st_dev == s2.st_dev && o1 == o2)
+ n = 0;
+ else n = ((flags & CMP_SILENT) && S_ISREG(s1.st_mode) && S_ISREG(s2.st_mode) && (s1.st_size - o1) != (s2.st_size - o2)) ? 1 : cmp(file1, f1, file2, f2, flags);
+ done:
+ if (f1 && f1 != sfstdin) sfclose(f1);
+ if (f2 && f2 != sfstdin) sfclose(f2);
+ return(n);
+}
diff --git a/usr/src/lib/libcmd/common/comm.c b/usr/src/lib/libcmd/common/comm.c
new file mode 100644
index 0000000000..3e28867e7e
--- /dev/null
+++ b/usr/src/lib/libcmd/common/comm.c
@@ -0,0 +1,201 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Bell Laboratories
+ *
+ * comm
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: comm (AT&T Research) 1999-04-28 $\n]"
+USAGE_LICENSE
+"[+NAME?comm - select or reject lines common to two files]"
+"[+DESCRIPTION?\bcomm\b reads two files \afile1\a and \afile2\a "
+ "which should be ordered in the collating sequence of the "
+ "current locale, and produces three text columns as output:]{"
+ "[+1?Lines only in \afile1\a.]"
+ "[+2?Lines only in \afile2\a.]"
+ "[+3?Lines in both files.]"
+ "}"
+"[+?If lines in either file are not ordered according to the collating "
+ "sequence of the current locale, the results are not specified.]"
+"[+?If either \afile1\a or \afile2\a is \b-\b, \bcomm\b "
+ "uses standard input starting at the current location.]"
+
+"[1?Suppress the output column of lines unique to \afile1\a.]"
+"[2?Suppress the output column of lines unique to \afile2\a.]"
+"[3?Suppress the output column of lines duplicate in \afile1\a and \afile2\a.]"
+"\n"
+"\nfile1 file2\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Both files processed successfully.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bcmp\b(1), \bdiff\b(1)]"
+;
+
+
+#include <cmd.h>
+
+#define C_FILE1 1
+#define C_FILE2 2
+#define C_COMMON 4
+#define C_ALL (C_FILE1|C_FILE2|C_COMMON)
+
+static int comm(Sfio_t *in1, Sfio_t *in2, register Sfio_t *out,register int mode)
+{
+ register char *cp1, *cp2;
+ register int n1, n2, n, comp;
+ if(cp1 = sfgetr(in1,'\n',0))
+ n1 = sfvalue(in1);
+ if(cp2 = sfgetr(in2,'\n',0))
+ n2 = sfvalue(in2);
+ while(cp1 && cp2)
+ {
+ n=(n1<n2?n1:n2);
+ if((comp=memcmp(cp1,cp2,n-1))==0 && (comp=n1-n2)==0)
+ {
+ if(mode&C_COMMON)
+ {
+ if(mode!=C_COMMON)
+ {
+ sfputc(out,'\t');
+ if(mode==C_ALL)
+ sfputc(out,'\t');
+ }
+ if(sfwrite(out,cp1,n) < 0)
+ return(-1);
+ }
+ if(cp1 = sfgetr(in1,'\n',0))
+ n1 = sfvalue(in1);
+ if(cp2 = sfgetr(in2,'\n',0))
+ n2 = sfvalue(in2);
+ }
+ else if(comp > 0)
+ {
+ if(mode&C_FILE2)
+ {
+ if(mode&C_FILE1)
+ sfputc(out,'\t');
+ if(sfwrite(out,cp2,n2) < 0)
+ return(-1);
+ }
+ if(cp2 = sfgetr(in2,'\n',0))
+ n2 = sfvalue(in2);
+ }
+ else
+ {
+ if((mode&C_FILE1) && sfwrite(out,cp1,n1) < 0)
+ return(-1);
+ if(cp1 = sfgetr(in1,'\n',0))
+ n1 = sfvalue(in1);
+ }
+ }
+ n = 0;
+ if(cp2)
+ {
+ cp1 = cp2;
+ in1 = in2;
+ n1 = n2;
+ if(mode&C_FILE1)
+ n = 1;
+ mode &= C_FILE2;
+ }
+ else
+ mode &= C_FILE1;
+ if(!mode || !cp1)
+ {
+ if(cp1 && in1==sfstdin)
+ sfseek(in1,(Sfoff_t)0,SEEK_END);
+ return(0);
+ }
+ /* process the remaining stream */
+ while(1)
+ {
+ if(n)
+ sfputc(out,'\t');
+ if(sfwrite(out,cp1,n1) < 0)
+ return(-1);
+ if(!(cp1 = sfgetr(in1,'\n',0)))
+ return(0);
+ n1 = sfvalue(in1);
+ }
+ /* NOT REACHED */
+}
+
+int
+b_comm(int argc, char *argv[], void* context)
+{
+ register int n;
+ register int mode = C_FILE1|C_FILE2|C_COMMON;
+ register char *cp;
+ Sfio_t *f1, *f2;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ while (n = optget(argv, usage)) switch (n)
+ {
+ case '1':
+ mode &= ~C_FILE1;
+ break;
+ case '2':
+ mode &= ~C_FILE2;
+ break;
+ case '3':
+ mode &= ~C_COMMON;
+ break;
+ case ':':
+ error(2, "%s",opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s",opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ argc -= opt_info.index;
+ if(error_info.errors || argc!=2)
+ error(ERROR_usage(2),"%s",optusage(NiL));
+ cp = *argv++;
+ if(streq(cp,"-"))
+ f1 = sfstdin;
+ else if(!(f1 = sfopen(NiL, cp,"r")))
+ error(ERROR_system(1),"%s: cannot open",cp);
+ cp = *argv;
+ if(streq(cp,"-"))
+ f2 = sfstdin;
+ else if(!(f2 = sfopen(NiL, cp,"r")))
+ error(ERROR_system(1),"%s: cannot open",cp);
+ if(mode)
+ {
+ if(comm(f1,f2,sfstdout,mode) < 0)
+ error(ERROR_system(1)," write error");
+ }
+ else if(f1==sfstdin || f2==sfstdin)
+ sfseek(sfstdin,(Sfoff_t)0,SEEK_END);
+ if(f1!=sfstdin)
+ sfclose(f1);
+ if(f2!=sfstdin)
+ sfclose(f2);
+ return(error_info.errors);
+}
+
diff --git a/usr/src/lib/libcmd/common/cp.c b/usr/src/lib/libcmd/common/cp.c
new file mode 100644
index 0000000000..3aa6b75273
--- /dev/null
+++ b/usr/src/lib/libcmd/common/cp.c
@@ -0,0 +1,927 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * cp/ln/mv -- copy/link/move files
+ */
+
+static const char usage_head[] =
+"[-?@(#)$Id: cp (AT&T Research) 2006-11-21 $\n]"
+USAGE_LICENSE
+;
+
+static const char usage_cp[] =
+"[+NAME?cp - copy files]"
+"[+DESCRIPTION?If the last argument names an existing directory, \bcp\b"
+" copies each \afile\a into a file with the same name in that"
+" directory. Otherwise, if only two files are given, \bcp\b copies"
+" the first onto the second. It is an error if the last argument is"
+" not a directory and more than two files are given. By default"
+" directories are not copied.]"
+
+"[a:archive?Preserve as much as possible of the structure and attributes of"
+" the original files in the copy. Equivalent to \b--physical\b"
+" \b--preserve\b \b--recursive\b.]"
+"[p:preserve?Preserve file owner, group, permissions and timestamps.]"
+"[h:hierarchy|parents?Form the name of each destination file by appending"
+" to the target directory a slash and the specified source file name."
+" The last argument must be an existing directory. Missing destination"
+" directories are created.]"
+"[H:metaphysical?Follow command argument symbolic links, otherwise don't"
+" follow.]"
+"[l:link?Make hard links to destination files instead of copies.]"
+"[L:logical|dereference?Follow symbolic links and copy the files"
+" they point to.]"
+"[P|d:physical|nodereference?Don't follow symbolic links; copy symbolic"
+" rather than the files they point to.]"
+;
+
+static const char usage_ln[] =
+"[+NAME?ln - link files]"
+"[+DESCRIPTION?If the last argument names an existing directory, \bln\b"
+" links each \afile\a into a file with the same name in that"
+" directory. Otherwise, if only two files are given, \bln\b links"
+" the first onto the second. It is an error if the last argument is"
+" not a directory and more than two files are given. By default"
+" directories are not linked.]"
+;
+
+static const char usage_mv[] =
+"[+NAME?mv - rename files]"
+"[+DESCRIPTION?If the last argument names an existing directory, \bmv\b"
+" renames each \afile\a into a file with the same name in that"
+" directory. Otherwise, if only two files are given, \bmv\b renames"
+" the first onto the second. It is an error if the last argument is"
+" not a directory and more than two files are given. If a source and"
+" destination file reside on different filesystems then \bmv\b copies"
+" the file contents to the destination and then deletes the source"
+" file.]"
+;
+
+static const char usage_tail[] =
+"[f:force?Replace existing destination files.]"
+"[i:interactive|prompt?Prompt whether to replace existing destination files."
+" An affirmative response (\by\b or \bY\b) replaces the file, a quit"
+" response (\bq\b or \bQ\b) exits immediately, and all other"
+" responses skip the file.]"
+"[r|R:recursive?Operate on the contents of directories recursively.]"
+"[s:symlink|symbolic-link?Make symbolic links to destination files.]"
+"[u:update?Replace a destination file only if its modification time is older"
+" than the corresponding source file modification time.]"
+"[v:verbose?Print the name of each file before operating on it.]"
+"[b:backup?Make backups of files that are about to be replaced. See"
+" \b--suffix\b and \b--version-control\b for more information.]"
+"[F:fsync|sync?\bfsync\b(2) each file after it is copied.]"
+"[S:backup-suffix|suffix?A backup file is made by renaming the file to the"
+" same name with the backup suffix appended. The backup suffix is"
+" determined in this order: this option, the \bSIMPLE_BACKUP_SUFFIX\b,"
+" environment variable, or the default value \b~\b.]:[suffix]"
+"[V:backup-type|version-control?The backup type is determined in this order:"
+" this option, the \bVERSION_CONTROL\b environment variable, or the"
+" default value \bexisting\b. \atype\a may be one of:]:[type]{"
+" [+numbered|t?Always make numbered backups. The numbered backup"
+" suffix is \b.\aSNS\a, where \aS\a is the"
+" \bbackup-suffix\b and \aN\a is the version number,"
+" starting at 1, incremented with each version.]"
+" [+existing|nil?Make numbered backups of files that already"
+" have them, otherwise simple backups.]"
+" [+simple|never?Always make simple backups.]"
+"}"
+"[x|X|l:xdev|local|mount|one-file-system?Do not descend into directories in"
+" different filesystems than their parents.]"
+
+"\n"
+"\nsource destination\n"
+"file ... directory\n"
+"\n"
+
+"[+SEE ALSO?\bpax\b(1), \bfsync\b(2), \brename\b(2), \bunlink\b(2),"
+" \bremove\b(3)]"
+;
+
+#include <cmd.h>
+#include <ls.h>
+#include <times.h>
+#include <fts.h>
+#include <fs3d.h>
+#include <hashkey.h>
+#include <stk.h>
+#include <tmx.h>
+
+#define PATH_CHUNK 256
+
+#define CP 1
+#define LN 2
+#define MV 3
+
+#define BAK_replace 0 /* no backup -- just replace */
+#define BAK_existing 1 /* number if already else simple*/
+#define BAK_number 2 /* append .suffix number suffix */
+#define BAK_simple 3 /* append suffix */
+
+typedef struct State_s /* program state */
+{
+ int backup; /* BAK_* type */
+ int directory; /* destination is directory */
+ int flags; /* FTS_* flags */
+ int force; /* force approval */
+ int fs3d; /* 3d fs enabled */
+ int hierarchy; /* preserve hierarchy */
+ int interactive; /* prompt for approval */
+ int missmode; /* default missing dir mode */
+ int official; /* move to next view */
+ int op; /* {CP,LN,MV} */
+ int pathsiz; /* state.path buffer size */
+ int perm; /* permissions to preserve */
+ int postsiz; /* state.path post index */
+ int presiz; /* state.path pre index */
+ int preserve; /* preserve { id mode time } */
+ int recursive; /* subtrees too */
+ int suflen; /* strlen(state.suffix) */
+ int sync; /* fsync() each file after copy */
+ int uid; /* caller uid */
+ int update; /* replace only if newer */
+ int verbose; /* list each file before op */
+
+ int (*link)(const char*, const char*); /* link */
+ int (*stat)(const char*, struct stat*); /* stat */
+
+ char* path; /* to pathname buffer */
+ char* opname; /* state.op message string */
+ char* suffix; /* backup suffix */
+
+ Sfio_t* tmp; /* tmp string stream */
+
+ char text[PATH_MAX]; /* link text buffer */
+} State_t;
+
+static const char dot[2] = { '.' };
+
+/*
+ * preserve support
+ */
+
+static void
+preserve(State_t* state, const char* path, struct stat* ns, struct stat* os)
+{
+ int n;
+
+ if (tmxtouch(path, tmxgetatime(os), tmxgetmtime(os), TMX_NOTIME, 0))
+ error(ERROR_SYSTEM|2, "%s: cannot reset access and modify times", path);
+ n = ((ns->st_uid != os->st_uid) << 1) | (ns->st_gid != os->st_gid);
+ if (n && chown(state->path, os->st_uid, os->st_gid))
+ switch (n)
+ {
+ case 01:
+ error(ERROR_SYSTEM|2, "%s: cannot reset group to %s", path, fmtgid(os->st_gid));
+ break;
+ case 02:
+ error(ERROR_SYSTEM|2, "%s: cannot reset owner to %s", path, fmtuid(os->st_uid));
+ break;
+ case 03:
+ error(ERROR_SYSTEM|2, "%s: cannot reset owner to %s and group to %s", path, fmtuid(os->st_uid), fmtgid(os->st_gid));
+ break;
+ }
+}
+
+/*
+ * visit a single file and state.op to the destination
+ */
+
+static int
+visit(State_t* state, register FTSENT* ent)
+{
+ register char* base;
+ register int n;
+ register int len;
+ int rm;
+ int rfd;
+ int wfd;
+ int m;
+ int v;
+ char* s;
+ char* e;
+ char* protection;
+ Sfio_t* ip;
+ Sfio_t* op;
+ FTS* fts;
+ FTSENT* sub;
+ struct stat st;
+
+ if (cmdquit())
+ return -1;
+ if (ent->fts_info == FTS_DC)
+ {
+ error(2, "%s: directory causes cycle", ent->fts_path);
+ fts_set(NiL, ent, FTS_SKIP);
+ return 0;
+ }
+ if (ent->fts_level == 0)
+ {
+ base = ent->fts_name;
+ len = ent->fts_namelen;
+ if (state->hierarchy)
+ state->presiz = -1;
+ else
+ {
+ state->presiz = ent->fts_pathlen;
+ while (*base == '.' && *(base + 1) == '/')
+ for (base += 2; *base == '/'; base++);
+ if (*base == '.' && !*(base + 1))
+ state->presiz--;
+ else if (*base)
+ state->presiz -= base - ent->fts_name;
+ base = ent->fts_name + len;
+ while (base > ent->fts_name && *(base - 1) == '/')
+ base--;
+ while (base > ent->fts_name && *(base - 1) != '/')
+ base--;
+ len -= base - ent->fts_name;
+ if (state->directory)
+ state->presiz -= len + 1;
+ }
+ }
+ else
+ {
+ base = ent->fts_path + state->presiz + 1;
+ len = ent->fts_pathlen - state->presiz - 1;
+ }
+ len++;
+ if (state->directory)
+ {
+ if ((state->postsiz + len) > state->pathsiz && !(state->path = newof(state->path, char, state->pathsiz = roundof(state->postsiz + len, PATH_CHUNK), 0)))
+ error(3, "out of space");
+ if (state->hierarchy && ent->fts_level == 0 && strchr(base, '/'))
+ {
+ s = state->path + state->postsiz;
+ memcpy(s, base, len);
+ while (e = strchr(s, '/'))
+ {
+ *e = 0;
+ if (access(state->path, F_OK))
+ {
+ st.st_mode = state->missmode;
+ if (s = strrchr(s, '/'))
+ {
+ *s = 0;
+ stat(state->path, &st);
+ *s = '/';
+ }
+ if (mkdir(state->path, st.st_mode & S_IPERM))
+ {
+ error(ERROR_SYSTEM|2, "%s: cannot create directory -- %s ignored", state->path, ent->fts_path);
+ fts_set(NiL, ent, FTS_SKIP);
+ return 0;
+ }
+ }
+ *e++ = '/';
+ s = e;
+ }
+ }
+ }
+ switch (ent->fts_info)
+ {
+ case FTS_DP:
+ if (state->preserve && state->op != LN || ent->fts_level > 0 && (ent->fts_statp->st_mode & S_IRWXU) != S_IRWXU)
+ {
+ if (len && ent->fts_level > 0)
+ memcpy(state->path + state->postsiz, base, len);
+ else
+ state->path[state->postsiz] = 0;
+ if (stat(state->path, &st))
+ error(ERROR_SYSTEM|2, "%s: cannot stat", state->path);
+ else
+ {
+ if ((ent->fts_statp->st_mode & S_IPERM) != (st.st_mode & S_IPERM) && chmod(state->path, ent->fts_statp->st_mode & S_IPERM))
+ error(ERROR_SYSTEM|2, "%s: cannot reset directory mode to %s", state->path, fmtmode(st.st_mode & S_IPERM, 0) + 1);
+ if (state->preserve)
+ preserve(state, state->path, &st, ent->fts_statp);
+ }
+ }
+ return 0;
+ case FTS_DNR:
+ case FTS_DNX:
+ case FTS_D:
+ if (!state->recursive)
+ {
+ fts_set(NiL, ent, FTS_SKIP);
+ if (state->op == CP)
+ error(1, "%s: directory -- copying as plain file", ent->fts_path);
+ else if (state->link == link && !state->force)
+ {
+ error(2, "%s: cannot link directory", ent->fts_path);
+ return 0;
+ }
+ }
+ else switch (ent->fts_info)
+ {
+ case FTS_DNR:
+ error(2, "%s: cannot read directory", ent->fts_path);
+ return 0;
+ case FTS_DNX:
+ error(2, "%s: cannot search directory", ent->fts_path);
+ fts_set(NiL, ent, FTS_SKIP);
+
+ /*FALLTHROUGH*/
+ case FTS_D:
+ if (state->directory)
+ memcpy(state->path + state->postsiz, base, len);
+ if (!(*state->stat)(state->path, &st))
+ {
+ if (!S_ISDIR(st.st_mode))
+ {
+ error(2, "%s: not a directory -- %s ignored", state->path, ent->fts_path);
+ return 0;
+ }
+ }
+ else if (mkdir(state->path, (ent->fts_statp->st_mode & S_IPERM)|(ent->fts_info == FTS_D ? S_IRWXU : 0)))
+ {
+ error(ERROR_SYSTEM|2, "%s: cannot create directory -- %s ignored", state->path, ent->fts_path);
+ fts_set(NiL, ent, FTS_SKIP);
+ }
+ if (!state->directory)
+ {
+ state->directory = 1;
+ state->path[state->postsiz++] = '/';
+ state->presiz--;
+ }
+ return 0;
+ }
+ break;
+ case FTS_ERR:
+ case FTS_NS:
+ case FTS_SLNONE:
+ if (state->link != pathsetlink)
+ {
+ error(2, "%s: not found", ent->fts_path);
+ return 0;
+ }
+ break;
+#if 0
+ case FTS_SL:
+ if (state->op == CP)
+ {
+ error(2, "%s: cannot copy non-terminal symbolic link", ent->fts_path);
+ return 0;
+ }
+ break;
+#endif
+ }
+ if (state->directory)
+ memcpy(state->path + state->postsiz, base, len);
+ if ((*state->stat)(state->path, &st))
+ st.st_mode = 0;
+ else if (state->update && !S_ISDIR(st.st_mode) && (unsigned long)ent->fts_statp->st_mtime < (unsigned long)st.st_mtime)
+ {
+ fts_set(NiL, ent, FTS_SKIP);
+ return 0;
+ }
+ else if (!state->fs3d || !iview(&st))
+ {
+ /*
+ * target is in top 3d view
+ */
+
+ if (st.st_dev == ent->fts_statp->st_dev && st.st_ino == ent->fts_statp->st_ino)
+ {
+ if (state->op == MV)
+ {
+ /*
+ * let rename() handle it
+ */
+
+ if (state->verbose)
+ sfputr(sfstdout, state->path, '\n');
+ goto operate;
+ }
+ if (!state->official)
+ error(2, "%s: identical to %s", state->path, ent->fts_path);
+ return 0;
+ }
+ if (S_ISDIR(st.st_mode))
+ {
+ error(2, "%s: cannot %s existing directory", state->path, state->opname);
+ return 0;
+ }
+ if (state->verbose)
+ sfputr(sfstdout, state->path, '\n');
+ rm = state->op == LN || ent->fts_info == FTS_SL;
+ if (!rm || !state->force)
+ {
+ if ((n = open(state->path, O_RDWR|O_BINARY)) >= 0)
+ {
+ close(n);
+ if (state->force)
+ /* ok */;
+ else if (state->interactive)
+ {
+ if (astquery(-1, "%s %s? ", state->opname, state->path))
+ return 0;
+ }
+ else if (state->op == LN)
+ {
+ error(2, "%s: cannot %s existing file", state->path, state->opname);
+ return 0;
+ }
+ }
+ else if (state->force)
+ rm = 1;
+ else
+ {
+ protection =
+#ifdef ETXTBSY
+ errno == ETXTBSY ? "``running program''" :
+#endif
+ st.st_uid != state->uid ? "``not owner''" :
+ fmtmode(st.st_mode & (S_IRWXU|S_IRWXG|S_IRWXO), 0) + 1;
+ if (state->interactive)
+ {
+ if (astquery(-1, "override protection %s for %s? ", protection, state->path))
+ return 0;
+ rm = 1;
+ }
+ else if (!rm)
+ {
+ error(2, "%s: cannot %s %s protection", state->path, state->opname, protection);
+ return 0;
+ }
+ }
+ }
+ switch (state->backup)
+ {
+ case BAK_existing:
+ case BAK_number:
+ v = 0;
+ if (s = strrchr(state->path, '/'))
+ {
+ e = state->path;
+ *s++ = 0;
+ }
+ else
+ {
+ e = (char*)dot;
+ s = state->path;
+ }
+ n = strlen(s);
+ if (fts = fts_open((char**)e, FTS_NOCHDIR|FTS_ONEPATH|FTS_PHYSICAL|FTS_NOPOSTORDER|FTS_NOSTAT|FTS_NOSEEDOTDIR, NiL))
+ {
+ while (sub = fts_read(fts))
+ {
+ if (strneq(s, sub->fts_name, n) && sub->fts_name[n] == '.' && strneq(sub->fts_name + n + 1, state->suffix, state->suflen) && (m = strtol(sub->fts_name + n + state->suflen + 1, &e, 10)) && streq(e, state->suffix) && m > v)
+ v = m;
+ if (sub->fts_level)
+ fts_set(NiL, sub, FTS_SKIP);
+ }
+ fts_close(fts);
+ }
+ if (s != state->path)
+ *--s = '/';
+ if (v || state->backup == BAK_number)
+ {
+ sfprintf(state->tmp, "%s.%s%d%s", state->path, state->suffix, v + 1, state->suffix);
+ goto backup;
+ }
+ /*FALLTHROUGH*/
+ case BAK_simple:
+ sfprintf(state->tmp, "%s%s", state->path, state->suffix);
+ backup:
+ if (!(s = sfstruse(state->tmp)))
+ error(ERROR_SYSTEM|3, "%s: out of space", state->path);
+ if (rename(state->path, s))
+ {
+ error(ERROR_SYSTEM|2, "%s: cannot backup to %s", state->path, s);
+ return 0;
+ }
+ break;
+ default:
+ if (rm && remove(state->path))
+ {
+ error(ERROR_SYSTEM|2, "%s: cannot remove", state->path);
+ return 0;
+ }
+ break;
+ }
+ }
+ operate:
+ switch (state->op)
+ {
+ case MV:
+ for (;;)
+ {
+ if (!rename(ent->fts_path, state->path))
+ return 0;
+ if (errno == ENOENT)
+ rm = 1;
+ else if (!rm && st.st_mode && !remove(state->path))
+ {
+ rm = 1;
+ continue;
+ }
+ if (errno != EXDEV && (rm || S_ISDIR(ent->fts_statp->st_mode)))
+ {
+ error(ERROR_SYSTEM|2, "%s: cannot rename to %s", ent->fts_path, state->path);
+ return 0;
+ }
+ else
+ break;
+ }
+ /*FALLTHROUGH*/
+ case CP:
+ if (S_ISLNK(ent->fts_statp->st_mode))
+ {
+ if ((n = pathgetlink(ent->fts_path, state->text, sizeof(state->text) - 1)) < 0)
+ {
+ error(ERROR_SYSTEM|2, "%s: cannot read symbolic link text", ent->fts_path);
+ return 0;
+ }
+ state->text[n] = 0;
+ if (pathsetlink(state->text, state->path))
+ {
+ error(ERROR_SYSTEM|2, "%s: cannot copy symbolic link to %s", ent->fts_path, state->path);
+ return 0;
+ }
+ }
+ else if (state->op == CP || S_ISREG(ent->fts_statp->st_mode) || S_ISDIR(ent->fts_statp->st_mode))
+ {
+ if (ent->fts_statp->st_size > 0 && (rfd = open(ent->fts_path, O_RDONLY|O_BINARY)) < 0)
+ {
+ error(ERROR_SYSTEM|2, "%s: cannot read", ent->fts_path);
+ return 0;
+ }
+ else if ((wfd = open(state->path, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, ent->fts_statp->st_mode & state->perm)) < 0)
+ {
+ error(ERROR_SYSTEM|2, "%s: cannot write", state->path);
+ if (ent->fts_statp->st_size > 0)
+ close(rfd);
+ return 0;
+ }
+ else if (ent->fts_statp->st_size > 0)
+ {
+ if (!(ip = sfnew(NiL, NiL, SF_UNBOUND, rfd, SF_READ)))
+ {
+ error(ERROR_SYSTEM|2, "%s: %s read stream error", ent->fts_path, state->path);
+ close(rfd);
+ close(wfd);
+ }
+ else
+ {
+ n = 0;
+ if (!(op = sfnew(NiL, NiL, SF_UNBOUND, wfd, SF_WRITE)))
+ {
+ error(ERROR_SYSTEM|2, "%s: %s write stream error", ent->fts_path, state->path);
+ close(wfd);
+ sfclose(ip);
+ }
+ else
+ {
+ if (sfmove(ip, op, (Sfoff_t)SF_UNBOUND, -1) < 0)
+ n |= 3;
+ if (!sfeof(ip))
+ n |= 1;
+ if (sfsync(op) || state->sync && fsync(wfd) || sfclose(op))
+ n |= 2;
+ if (sfclose(ip))
+ n |= 1;
+ if (n)
+ error(ERROR_SYSTEM|2, "%s: %s %s error", ent->fts_path, state->path, n == 1 ? ERROR_translate(0, 0, 0, "read") : n == 2 ? ERROR_translate(0, 0, 0, "write") : ERROR_translate(0, 0, 0, "io"));
+ }
+ }
+ }
+ else
+ close(wfd);
+ }
+ else if (S_ISBLK(ent->fts_statp->st_mode) || S_ISCHR(ent->fts_statp->st_mode) || S_ISFIFO(ent->fts_statp->st_mode))
+ {
+ if (mknod(state->path, ent->fts_statp->st_mode, idevice(ent->fts_statp)))
+ {
+ error(ERROR_SYSTEM|2, "%s: cannot copy special file to %s", ent->fts_path, state->path);
+ return 0;
+ }
+ }
+ else
+ {
+ error(2, "%s: cannot copy -- unknown file type 0%o", ent->fts_path, S_ITYPE(ent->fts_statp->st_mode));
+ return 0;
+ }
+ if (state->preserve)
+ {
+ if (ent->fts_info != FTS_SL)
+ {
+ if (stat(state->path, &st))
+ error(ERROR_SYSTEM|2, "%s: cannot stat", state->path);
+ else
+ {
+ if ((ent->fts_statp->st_mode & state->perm) != (st.st_mode & state->perm) && chmod(state->path, ent->fts_statp->st_mode & state->perm))
+ error(ERROR_SYSTEM|2, "%s: cannot reset mode to %s", state->path, fmtmode(st.st_mode & state->perm, 0) + 1);
+ preserve(state, state->path, &st, ent->fts_statp);
+ }
+ }
+ if (state->op == MV && remove(ent->fts_path))
+ error(ERROR_SYSTEM|1, "%s: cannot remove", ent->fts_path);
+ }
+ break;
+ case LN:
+ if ((*state->link)(ent->fts_path, state->path))
+ error(ERROR_SYSTEM|2, "%s: cannot link to %s", ent->fts_path, state->path);
+ break;
+ }
+ return 0;
+}
+
+int
+b_cp(int argc, register char** argv, void* context)
+{
+ register char* file;
+ register char* s;
+ char** v;
+ char* backup_type;
+ FTS* fts;
+ FTSENT* ent;
+ const char* usage;
+ int path_resolve;
+ int standard;
+ struct stat st;
+ State_t state;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, ERROR_NOTIFY);
+ memset(&state, 0, sizeof(state));
+ state.presiz = -1;
+ backup_type = 0;
+ state.flags = FTS_NOCHDIR|FTS_NOSEEDOTDIR;
+ state.uid = geteuid();
+ if (!(state.tmp = sfstropen()))
+ error(ERROR_SYSTEM|3, "out of space [tmp string]");
+ sfputr(state.tmp, usage_head, -1);
+ standard = !strcmp(astconf("CONFORMANCE", NiL, NiL), "standard");
+ switch (error_info.id[0])
+ {
+ case 'c':
+ case 'C':
+ sfputr(state.tmp, usage_cp, -1);
+ state.op = CP;
+ state.stat = stat;
+ path_resolve = -1;
+ break;
+ case 'l':
+ case 'L':
+ sfputr(state.tmp, usage_ln, -1);
+ state.op = LN;
+ state.flags |= FTS_PHYSICAL;
+ state.link = link;
+ state.stat = lstat;
+ path_resolve = 1;
+ break;
+ case 'm':
+ case 'M':
+ sfputr(state.tmp, usage_mv, -1);
+ state.op = MV;
+ state.flags |= FTS_PHYSICAL;
+ state.preserve = 1;
+ state.stat = lstat;
+ path_resolve = 1;
+ break;
+ default:
+ error(3, "not implemented");
+ break;
+ }
+ sfputr(state.tmp, usage_tail, -1);
+ if (!(usage = sfstruse(state.tmp)))
+ error(ERROR_SYSTEM|3, "%s: out of space", state.path);
+ state.opname = state.op == CP ? ERROR_translate(0, 0, 0, "overwrite") : ERROR_translate(0, 0, 0, "replace");
+ for (;;)
+ {
+ switch (optget(argv, usage))
+ {
+ case 'a':
+ state.flags |= FTS_PHYSICAL;
+ state.preserve = 1;
+ state.recursive = 1;
+ path_resolve = 1;
+ continue;
+ case 'b':
+ state.backup = 1;
+ continue;
+ case 'f':
+ state.force = 1;
+ if (state.op != CP || !standard)
+ state.interactive = 0;
+ continue;
+ case 'h':
+ state.hierarchy = 1;
+ continue;
+ case 'i':
+ state.interactive = 1;
+ if (state.op != CP || !standard)
+ state.force = 0;
+ continue;
+ case 'l':
+ state.op = LN;
+ state.link = link;
+ state.stat = lstat;
+ continue;
+ case 'p':
+ state.preserve = 1;
+ continue;
+ case 'r':
+ state.recursive = 1;
+ if (path_resolve < 0)
+ path_resolve = 0;
+ continue;
+ case 's':
+ state.op = LN;
+ state.link = pathsetlink;
+ state.stat = lstat;
+ continue;
+ case 'u':
+ state.update = 1;
+ continue;
+ case 'v':
+ state.verbose = 1;
+ continue;
+ case 'x':
+ state.flags |= FTS_XDEV;
+ continue;
+ case 'F':
+#if _lib_fsync
+ state.sync = 1;
+#else
+ error(1, "%s not implemented on this system", opt_info.name);
+#endif
+ continue;
+ case 'H':
+ state.flags |= FTS_META|FTS_PHYSICAL;
+ path_resolve = 1;
+ continue;
+ case 'L':
+ state.flags &= ~FTS_PHYSICAL;
+ path_resolve = 1;
+ continue;
+ case 'P':
+ state.flags &= ~FTS_META;
+ state.flags |= FTS_PHYSICAL;
+ path_resolve = 1;
+ continue;
+ case 'R':
+ state.recursive = 1;
+ state.flags &= ~FTS_META;
+ state.flags |= FTS_PHYSICAL;
+ path_resolve = 1;
+ continue;
+ case 'S':
+ state.suffix = opt_info.arg;
+ continue;
+ case 'V':
+ backup_type = opt_info.arg;
+ continue;
+ case '?':
+ error(ERROR_USAGE|4, "%s", opt_info.arg);
+ continue;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ continue;
+ }
+ break;
+ }
+ argc -= opt_info.index + 1;
+ argv += opt_info.index;
+ if (*argv && streq(*argv, "-") && !streq(*(argv - 1), "--"))
+ {
+ argc--;
+ argv++;
+ }
+ if (!(v = (char**)stkalloc(stkstd, (argc + 2) * sizeof(char*))))
+ error(3, "out of space");
+ memcpy(v, argv, (argc + 1) * sizeof(char*));
+ argv = v;
+ if (!argc && !standard)
+ {
+ argc++;
+ argv[1] = (char*)dot;
+ }
+ if (state.backup)
+ {
+ if (!(file = backup_type) && !(backup_type = getenv("VERSION_CONTROL")))
+ state.backup = BAK_existing;
+ else
+ switch (strkey(backup_type))
+ {
+ case HASHKEY6('e','x','i','s','t','i'):
+ case HASHKEY5('e','x','i','s','t'):
+ case HASHKEY4('e','x','i','s'):
+ case HASHKEY3('e','x','i'):
+ case HASHKEY2('e','x'):
+ case HASHKEY1('e'):
+ case HASHKEY3('n','i','l'):
+ case HASHKEY2('n','i'):
+ state.backup = BAK_existing;
+ break;
+ case HASHKEY5('n','e','v','e','r'):
+ case HASHKEY4('n','e','v','e'):
+ case HASHKEY3('n','e','v'):
+ case HASHKEY2('n','e'):
+ case HASHKEY6('s','i','m','p','l','e'):
+ case HASHKEY5('s','i','m','p','l'):
+ case HASHKEY4('s','i','m','p'):
+ case HASHKEY3('s','i','m'):
+ case HASHKEY2('s','i'):
+ case HASHKEY1('s'):
+ state.backup = BAK_simple;
+ break;
+ case HASHKEY6('n','u','m','b','e','r'):
+ case HASHKEY5('n','u','m','b','e'):
+ case HASHKEY4('n','u','m','b'):
+ case HASHKEY3('n','u','m'):
+ case HASHKEY2('n','u'):
+ case HASHKEY1('t'):
+ state.backup = BAK_number;
+ break;
+ default:
+ if (file)
+ error(2, "%s: unknown backup type", backup_type);
+ break;
+ }
+ if (!state.suffix && !(state.suffix = getenv("SIMPLE_BACKUP_SUFFIX")))
+ state.suffix = "~";
+ state.suflen = strlen(state.suffix);
+ }
+ if (argc <= 0 || error_info.errors)
+ error(ERROR_USAGE|4, "%s", optusage(NiL));
+ if (!path_resolve)
+ state.flags |= fts_flags();
+ file = argv[argc];
+ argv[argc] = 0;
+ if (s = strrchr(file, '/'))
+ {
+ while (*s == '/')
+ s++;
+ if (!(!*s || *s == '.' && (!*++s || *s == '.' && !*++s)))
+ s = 0;
+ }
+ if (file != (char*)dot)
+ pathcanon(file, 0);
+ if (!(state.directory = !stat(file, &st) && S_ISDIR(st.st_mode)) && argc > 1)
+ error(ERROR_USAGE|4, "%s", optusage(NiL));
+ if (s && !state.directory)
+ error(3, "%s: not a directory", file);
+ if ((state.fs3d = fs3d(FS3D_TEST)) && strmatch(file, "...|*/...|.../*"))
+ state.official = 1;
+ state.postsiz = strlen(file);
+ state.pathsiz = roundof(state.postsiz + 2, PATH_CHUNK);
+ if (!(state.path = newof(0, char, state.pathsiz, 0)))
+ error(3, "out of space");
+ memcpy(state.path, file, state.postsiz + 1);
+ if (state.directory && state.path[state.postsiz - 1] != '/')
+ state.path[state.postsiz++] = '/';
+ if (state.hierarchy)
+ {
+ if (!state.directory)
+ error(3, "%s: last argument must be a directory", file);
+ state.missmode = st.st_mode;
+ }
+ state.perm = state.uid ? S_IPERM : (S_IPERM & ~S_ISVTX);
+ if (!state.recursive)
+ state.flags |= FTS_TOP;
+ if (fts = fts_open(argv, state.flags, NiL))
+ {
+ while ((ent = fts_read(fts)) && !visit(&state, ent));
+ fts_close(fts);
+ }
+ else if (state.link != pathsetlink)
+ switch (state.op)
+ {
+ case CP:
+ error(ERROR_SYSTEM|2, "%s: cannot copy", argv[0]);
+ break;
+ case LN:
+ error(ERROR_SYSTEM|2, "%s: cannot link", argv[0]);
+ break;
+ case MV:
+ error(ERROR_SYSTEM|2, "%s: cannot move", argv[0]);
+ break;
+ }
+ else if ((*state.link)(*argv, state.path))
+ error(ERROR_SYSTEM|2, "%s: cannot link to %s", *argv, state.path);
+ free(state.path);
+ return error_info.errors != 0;
+}
diff --git a/usr/src/lib/libcmd/common/cut.c b/usr/src/lib/libcmd/common/cut.c
new file mode 100644
index 0000000000..732d1784da
--- /dev/null
+++ b/usr/src/lib/libcmd/common/cut.c
@@ -0,0 +1,512 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Bell Laboratories
+ *
+ * cut [-sN] [-f flist] [-c clist] [-d delim] [-D delim] [-r reclen] [file] ...
+ *
+ * cut fields or columns from fields from a file
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: cut (AT&T Research) 2007-01-23 $\n]"
+USAGE_LICENSE
+"[+NAME?cut - cut out selected columns or fields of each line of a file]"
+"[+DESCRIPTION?\bcut\b bytes, characters, or character-delimited fields "
+ "from one or more files, contatenating them on standard output.]"
+"[+?The option argument \alist\a is a comma-separated or blank-separated "
+ "list of positive numbers and ranges. Ranges can be of three "
+ "forms. The first is two positive integers separated by a hyphen "
+ "(\alow\a\b-\b\ahigh\a), which represents all fields from \alow\a to "
+ "\ahigh\a. The second is a positive number preceded by a hyphen "
+ "(\b-\b\ahigh\a), which represents all fields from field \b1\b to "
+ "\ahigh\a. The last is a positive number followed by a hyphen "
+ "(\alow\a\b-\b), which represents all fields from \alow\a to the "
+ "last field, inclusive. Elements in the \alist\a can be repeated, "
+ "can overlap, and can appear in any order. The order of the "
+ "output is that of the input.]"
+"[+?One and only one of \b-b\b, \b-c\b, or \b-f\b must be specified.]"
+"[+?If no \afile\a is given, or if the \afile\a is \b-\b, \bcut\b "
+ "cuts from standard input. The start of the file is defined "
+ "as the current offset.]"
+"[b:bytes]:[list?\bcut\b based on a list of bytes.]"
+"[c:characters]:[list?\bcut\b based on a list of characters.]"
+"[d:delimiter]:[delim?The field character for the \b-f\b option is set "
+ "to \adelim\a. The default is the \btab\b character.]"
+"[f:fields]:[list?\bcut\b based on fields separated by the delimiter "
+ "character specified with the \b-d\b optiion.]"
+"[n:nosplit?Do not split characters. Currently ignored.]"
+"[R|r:reclen]#[reclen?If \areclen\a > 0, the input will be read as fixed length "
+ "records of length \areclen\a when used with the \b-b\b or \b-c\b "
+ "option.]"
+"[s:suppress|only-delimited?Suppress lines with no delimiter characters, "
+ "when used with the \b-f\b option. By default, lines with no "
+ "delimiters will be passsed in untouched.]"
+"[D:line-delimeter|output-delimiter]:[ldelim?The line delimiter character for "
+ "the \b-f\b option is set to \aldelim\a. The default is the "
+ "\bnewline\b character.]"
+"[N:nonewline?Do not output new-lines at end of each record when used "
+ "with the \b-b\b or \b-c\b option.]"
+"\n"
+"\n[file ...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?All files processed successfully.]"
+ "[+>0?One or more files failed to open or could not be read.]"
+"}"
+"[+SEE ALSO?\bpaste\b(1), \bgrep\b(1)]"
+;
+
+#include <cmd.h>
+#include <ctype.h>
+
+typedef struct Last_s
+{
+ int seqno;
+ int seq;
+ int wdelim;
+ int ldelim;
+} Last_t;
+
+typedef struct Cut_s
+{
+ int cflag;
+ int sflag;
+ int nlflag;
+ int wdelim;
+ int ldelim;
+ int seqno;
+ int reclen;
+ signed char space[UCHAR_MAX];
+ Last_t last;
+ int list[2]; /* NOTE: must be last member */
+} Cut_t;
+
+#define HUGE (1<<14)
+#define BLOCK 8*1024
+#define C_BYTES 1
+#define C_CHARS 2
+#define C_FIELDS 4
+#define C_SUPRESS 8
+#define C_NOCHOP 16
+#define C_NONEWLINE 32
+
+/*
+ * compare the first of an array of integers
+ */
+
+static int mycomp(register const void *a,register const void *b)
+{
+ return(*((int*)a) - *((int*)b));
+}
+
+static Cut_t *cutinit(int mode,char *str,int wdelim,int ldelim,size_t reclen)
+{
+ register int *lp, c, n=0;
+ register int range = 0;
+ register char *cp = str;
+ Cut_t *cuthdr;
+ if (!(cuthdr = (Cut_t*)stakalloc(sizeof(Cut_t)+strlen(cp)*sizeof(int))))
+ error(ERROR_exit(1), "out of space");
+ memset(cuthdr->space, 0, sizeof(cuthdr->space));
+ cuthdr->last.seqno = 0;
+ cuthdr->last.seq = 0;
+ cuthdr->last.wdelim = 0;
+ cuthdr->last.ldelim = '\n';
+ cuthdr->cflag = ((mode&C_CHARS)!=0 && mbwide());
+ cuthdr->sflag = ((mode&C_SUPRESS)!=0);
+ cuthdr->nlflag = ((mode&C_NONEWLINE)!=0);
+ cuthdr->wdelim = wdelim;
+ cuthdr->ldelim = ldelim;
+ cuthdr->reclen = reclen;
+ cuthdr->seqno = ++cuthdr->last.seqno;
+ lp = cuthdr->list;
+ while(1) switch(c= *cp++)
+ {
+ case ' ':
+ case '\t':
+ while(*cp==' ' || *cp=='\t')
+ cp++;
+ case 0:
+ case ',':
+ if(range)
+ {
+ --range;
+ if((n = (n==0?HUGE:n-range)) < 0)
+ error(ERROR_exit(1),"invalid range for c/f option");
+ *lp++ = range;
+ *lp++ = n;
+ }
+ else
+ {
+ *lp++ = --n;
+ *lp++ = 1;
+ }
+ if(c==0)
+ {
+ register int *dp;
+ *lp = HUGE;
+ n = 1 + (lp-cuthdr->list)/2;
+ qsort(lp=cuthdr->list,n,2*sizeof(*lp),mycomp);
+ /* eliminate overlapping regions */
+ for(n=0,range= -2,dp=lp; *lp!=HUGE; lp+=2)
+ {
+ if(lp[0] <= range)
+ {
+ if(lp[1]==HUGE)
+ {
+ dp[-1] = HUGE;
+ break;
+ }
+ if((c = lp[0]+lp[1]-range)>0)
+ {
+ range += c;
+ dp[-1] += c;
+ }
+ }
+ else
+ {
+ range = *dp++ = lp[0];
+ if(lp[1]==HUGE)
+ {
+ *dp++ = HUGE;
+ break;
+ }
+ range += (*dp++ = lp[1]);
+ }
+ }
+ *dp = HUGE;
+ lp = cuthdr->list;
+ /* convert ranges into gaps */
+ for(n=0; *lp!=HUGE; lp+=2)
+ {
+ c = *lp;
+ *lp -= n;
+ n = c+lp[1];
+ }
+ return(cuthdr);
+ }
+ n = range = 0;
+ break;
+
+ case '-':
+ if(range)
+ error(ERROR_exit(1),"bad list for c/f option");
+ range = n?n:1;
+ n = 0;
+ break;
+
+ default:
+ if(!isdigit(c))
+ error(ERROR_exit(1),"bad list for c/f option");
+ n = 10*n + (c-'0');
+ }
+ /* NOTREACHED */
+}
+
+/*
+ * advance <cp> by <n> multi-byte characters
+ */
+static int advance(const char *str, register int n, register int inlen)
+{
+ register int size, len=inlen;
+ register const char *cp=str;
+ while(len>0 && n-->0)
+ {
+ size = mblen(cp, len);
+ if(size<0)
+ size = 1;
+ cp += size;
+ len -= size;
+
+ }
+ if(n>0)
+ return(inlen+1);
+ return(cp-str);
+}
+
+/*
+ * cut each line of file <fdin> and put results to <fdout> using list <list>
+ */
+
+static int cutcols(Cut_t *cuthdr,Sfio_t *fdin,Sfio_t *fdout)
+{
+ register int c, ncol=0,len;
+ register const int *lp = cuthdr->list;
+ register char *inp;
+ register int skip; /* non-zero for don't copy */
+ while(1)
+ {
+ if(len = cuthdr->reclen)
+ inp = sfreserve(fdin, len, -1);
+ else
+ inp = sfgetr(fdin, '\n', 0);
+ if(!inp && !(inp = sfgetr(fdin, 0, SF_LASTR)))
+ break;
+ len = sfvalue(fdin);
+ if((ncol = skip = *(lp = cuthdr->list)) == 0)
+ ncol = *++lp;
+ while(1)
+ {
+ if((c=(cuthdr->cflag?advance(inp,ncol,len):ncol)) > len)
+ c = len;
+ else if(c==len && !skip)
+ ncol++;
+ ncol -= c;
+ if(!skip && sfwrite(fdout,(char*)inp,c)<0)
+ return(-1);
+ inp += c;
+ if(ncol)
+ break;
+ len -= c;
+ ncol = *++lp;
+ skip = !skip;
+ }
+ if(!cuthdr->nlflag && (skip || cuthdr->reclen))
+ sfputc(fdout,cuthdr->ldelim);
+ }
+ return(c);
+}
+
+/*
+ * cut each line of file <fdin> and put results to <fdout> using list <list>
+ * stream <fdin> must be line buffered
+ */
+
+#define endline(c) (((signed char)-1)<0?(c)<0:(c)==((char)-1))
+
+static int cutfields(Cut_t *cuthdr,Sfio_t *fdin,Sfio_t *fdout)
+{
+ register unsigned char *cp;
+ register int c, nfields;
+ register const int *lp = cuthdr->list;
+ register unsigned char *copy;
+ register int nodelim, empty, inword=0;
+ register unsigned char *endbuff;
+ unsigned char *inbuff, *first;
+ int lastchar;
+ Sfio_t *fdtmp = 0;
+ long offset = 0;
+ if(cuthdr->seqno != cuthdr->last.seq)
+ {
+ cuthdr->space[cuthdr->last.ldelim] = 0;
+ cuthdr->space[cuthdr->last.wdelim] = 0;
+ cuthdr->space[cuthdr->last.wdelim=cuthdr->wdelim] = 1;
+ cuthdr->space[cuthdr->last.ldelim=cuthdr->ldelim] = -1;
+ cuthdr->last.seq = cuthdr->seqno;
+ }
+ /* process each buffer */
+ while ((inbuff = (unsigned char*)sfreserve(fdin, SF_UNBOUND, 0)) && (c = sfvalue(fdin)) > 0)
+ {
+ cp = inbuff;
+ endbuff = cp + --c;
+ if((lastchar = cp[c]) != cuthdr->ldelim)
+ *endbuff = cuthdr->ldelim;
+ /* process each line in the buffer */
+ while(cp <= endbuff)
+ {
+ first = cp;
+ if(!inword)
+ {
+ nodelim = empty = 1;
+ copy = cp;
+ if(nfields = *(lp = cuthdr->list))
+ copy = 0;
+ else
+ nfields = *++lp;
+ }
+ else if(copy)
+ copy = cp;
+ inword = 0;
+ while(!inword)
+ {
+ /* skip over non-delimiter characters */
+ while(!(c=cuthdr->space[*cp++]));
+ /* check for end-of-line */
+ if(endline(c))
+ {
+ if(cp<=endbuff)
+ break;
+ if((c=cuthdr->space[lastchar]),endline(c))
+ break;
+ /* restore cuthdr->last. character */
+ if(lastchar != cuthdr->ldelim)
+ *endbuff = lastchar;
+ inword++;
+ if(!c)
+ break;
+ }
+ nodelim = 0;
+ if(--nfields >0)
+ continue;
+ nfields = *++lp;
+ if(copy)
+ {
+ empty = 0;
+ if((c=(cp-1)-copy)>0 && sfwrite(fdout,(char*)copy,c)< 0)
+ goto failed;
+ copy = 0;
+ }
+ else
+ /* set to delimiter unless the first field */
+ copy = cp -!empty;
+ }
+ if(!inword)
+ {
+ if(!copy)
+ {
+ if(nodelim)
+ {
+ if(!cuthdr->sflag)
+ {
+ if(offset)
+ {
+ sfseek(fdtmp,(Sfoff_t)0,SEEK_SET);
+ sfmove(fdtmp,fdout,offset,-1);
+ }
+ copy = first;
+ }
+ }
+ else
+ sfputc(fdout,'\n');
+ }
+ if(offset)
+ sfseek(fdtmp,offset=0,SEEK_SET);
+ }
+ if(copy && (c=cp-copy)>0 && (!nodelim || !cuthdr->sflag) && sfwrite(fdout,(char*)copy,c)< 0)
+ goto failed;
+ }
+ /* see whether to save in tmp file */
+ if(nodelim && inword && !cuthdr->sflag && (c=cp-first)>0)
+ {
+ /* copy line to tmpfile in case no fields */
+ if(!fdtmp)
+ fdtmp = sftmp(BLOCK);
+ sfwrite(fdtmp,(char*)first,c);
+ offset +=c;
+ }
+ }
+failed:
+ if(fdtmp)
+ sfclose(fdtmp);
+ return(0);
+}
+
+int
+b_cut(int argc,char *argv[], void* context)
+{
+ register char *cp = 0;
+ register Sfio_t *fp;
+ int n;
+ Cut_t *cuthdr;
+ int mode = 0;
+ int wdelim = '\t';
+ int ldelim = '\n';
+ size_t reclen = 0;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ while (n = optget(argv, usage)) switch (n)
+ {
+ case 'b':
+ case 'c':
+ if(mode&C_FIELDS)
+ {
+ error(2, "f option already specified");
+ break;
+ }
+ cp = opt_info.arg;
+ if(n=='b')
+ mode |= C_BYTES;
+ else
+ mode |= C_CHARS;
+ break;
+ case 'D':
+ ldelim = *(unsigned char*)opt_info.arg;
+ break;
+ case 'd':
+ wdelim = *(unsigned char*)opt_info.arg;
+ break;
+ case 'f':
+ if(mode&(C_CHARS|C_BYTES))
+ {
+ error(2, "c option already specified");
+ break;
+ }
+ cp = opt_info.arg;
+ mode |= C_FIELDS;
+ break;
+ case 'n':
+ mode |= C_NOCHOP;
+ break;
+ case 'N':
+ mode |= C_NONEWLINE;
+ break;
+ case 'R':
+ case 'r':
+ if(opt_info.num>0)
+ reclen = opt_info.num;
+ break;
+ case 's':
+ mode |= C_SUPRESS;
+ break;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ if (error_info.errors)
+ error(ERROR_usage(2), "%s",optusage(NiL));
+ if(!cp)
+ {
+ error(2, "b, c or f option must be specified");
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ }
+ if(!*cp)
+ error(3, "non-empty b, c or f option must be specified");
+ if((mode & (C_FIELDS|C_SUPRESS)) == C_SUPRESS)
+ error(3, "s option requires f option");
+ cuthdr = cutinit(mode,cp,wdelim,ldelim,reclen);
+ if(cp = *argv)
+ argv++;
+ do
+ {
+ if(!cp || streq(cp,"-"))
+ fp = sfstdin;
+ else if(!(fp = sfopen(NiL,cp,"r")))
+ {
+ error(ERROR_system(0),"%s: cannot open",cp);
+ continue;
+ }
+ if(mode&C_FIELDS)
+ cutfields(cuthdr,fp,sfstdout);
+ else
+ cutcols(cuthdr,fp,sfstdout);
+ if(fp!=sfstdin)
+ sfclose(fp);
+ }
+ while(cp= *argv++);
+ return(error_info.errors?1:0);
+}
diff --git a/usr/src/lib/libcmd/common/date.c b/usr/src/lib/libcmd/common/date.c
new file mode 100644
index 0000000000..b2ea46d146
--- /dev/null
+++ b/usr/src/lib/libcmd/common/date.c
@@ -0,0 +1,489 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * date -- set/display date
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: date (AT&T Research) 2007-03-28 $\n]"
+USAGE_LICENSE
+"[+NAME?date - set/list/convert dates]"
+"[+DESCRIPTION?\bdate\b sets the current date and time (with appropriate"
+" privilege), lists the current date or file dates, or converts"
+" dates.]"
+"[+?Most common \adate\a forms are recognized, including those for"
+" \bcrontab\b(1), \bls\b(1), \btouch\b(1), and the default"
+" output from \bdate\b itself.]"
+"[+?If the \adate\a operand consists of 4, 6, 8, 10 or 12 digits followed"
+" by an optional \b.\b and two digits then it is interpreted as:"
+" \aHHMM.SS\a, \addHHMM.SS\a, \ammddHHMM.SS\a, \ammddHHMMyy.SS\a or"
+" \ayymmddHHMM.SS\a, or \ammddHHMMccyy.SS\a or \accyymmddHHMM.SS\a."
+" Conflicting standards and practice allow a leading or trailing"
+" 2 or 4 digit year for the 10 and 12 digit forms; the X/Open trailing"
+" form is used to disambiguate (\btouch\b(1) uses the leading form.)"
+" Avoid the 10 digit form to avoid confusion. The digit fields are:]{"
+" [+cc?Century - 1, 19-20.]"
+" [+yy?Year in century, 00-99.]"
+" [+mm?Month, 01-12.]"
+" [+dd?Day of month, 01-31.]"
+" [+HH?Hour, 00-23.]"
+" [+MM?Minute, 00-59.]"
+" [+SS?Seconds, 00-60.]"
+"}"
+"[+?If more than one \adate\a operand is specified then:]{"
+" [+1.?Each operand sets the reference date for the next"
+" operand.]"
+" [+2.?The date is listed for each operand.]"
+" [+3.?The system date is not set.]"
+"}"
+
+"[a:access-time|atime?List file argument access times.]"
+"[c:change-time|ctime?List file argument change times.]"
+"[d:date?Use \adate\a as the current date and do not set the system"
+" clock.]:[date]"
+"[e:epoch?Output the date in seconds since the epoch."
+" Equivalent to \b--format=%s\b.]"
+"[E:elapsed?Interpret pairs of arguments as start and stop dates, sum the"
+" differences between all pairs, and list the result as a"
+" \bfmtelapsed\b(3) elapsed time on the standard output. If there are"
+" an odd number of arguments then the last time argument is differenced"
+" with the current time.]"
+"[f:format?Output the date according to the \bstrftime\b(3) \aformat\a."
+" For backwards compatibility, a first argument of the form"
+" \b+\b\aformat\a is equivalent to \b-f\b format."
+" \aformat\a is in \bprintf\b(3) style, where %\afield\a names"
+" a fixed size field, zero padded if necessary,"
+" and \\\ac\a and \\\annn\a sequences are as in C. Invalid"
+" %\afield\a specifications and all other characters are copied"
+" without change. \afield\a may be preceded by \b%-\b to turn off"
+" padding or \b%_\b to pad with space, otherwise numeric fields"
+" are padded with \b0\b and string fields are padded with space."
+" \afield\a may also be preceded by \bE\b for alternate era"
+" representation or \bO\b for alternate digit representation (if"
+" supported by the current locale.) Finally, an integral \awidth\a"
+" preceding \afield\a truncates the field to \awidth\a characters."
+" The fields are:]:[format]{"
+" [+%?% character]"
+" [+a?abbreviated weekday name]"
+" [+A?full weekday name]"
+" [+b?abbreviated month name]"
+" [+c?\bctime\b(3) style date without the trailing newline]"
+" [+C?2-digit century]"
+" [+d?day of month number]"
+" [+D?date as \amm/dd/yy\a]"
+" [+e?blank padded day of month number]"
+" [+E?unpadded day of month number]"
+" [+f?locale default override date format]"
+" [+F?locale default date format]"
+" [+g?\bls\b(1) \b-l\b recent date with \ahh:mm\a]"
+" [+G?\bls\b(1) \b-l\b distant date with \ayyyy\a]"
+" [+h?abbreviated month name]"
+" [+H?24-hour clock hour]"
+" [+i?international \bdate\b(1) date with time zone type name]"
+" [+I?12-hour clock hour]"
+" [+j?1-offset Julian date]"
+" [+J?0-offset Julian date]"
+" [+k?\bdate\b(1) style date]"
+" [+K?all numeric date; equivalent to \b%Y-%m-%d+%H:%M:%S\b]"
+" [+l?\bls\b(1) \b-l\b date; equivalent to \b%Q/%g/%G/\b]"
+" [+m?month number]"
+" [+M?minutes]"
+" [+n?newline character]"
+" [+N?nanoseconds 000000000-999999999]"
+" [+p?meridian (e.g., \bAM\b or \bPM\b)]"
+" [+q?time zone type name (nation code)]"
+" [+Q?\a<del>recent<del>distant<del>\a: \a<del>\a is a unique"
+" delimter character; \arecent\a format for recent"
+" dates, \adistant\a format otherwise]"
+" [+r?12-hour time as \ahh:mm:ss meridian\a]"
+" [+R?24-hour time as \ahh:mm\a]"
+" [+s?number of seconds since the epoch; \a.prec\a preceding"
+" \bs\b appends \aprec\a nanosecond digits, \b9\b if"
+" \aprec\a is omitted]"
+" [+S?seconds 00-60]"
+" [+t?tab character]"
+" [+T?24-hour time as \ahh:mm:ss\a]"
+" [+u?weekday number 1(Monday)-7]"
+" [+U?week number with Sunday as the first day]"
+" [+V?ISO week number (i18n is \afun\a)]"
+" [+w?weekday number 0(Sunday)-6]"
+" [+W?week number with Monday as the first day]"
+" [+x?locale date style that includes month, day and year]"
+" [+X?locale time style that includes hours and minutes]"
+" [+y?2-digit year (you'll be sorry)]"
+" [+Y?4-digit year]"
+" [+z?time zone \aSHHMM\a west of GMT offset where S is"
+" \b+\b or \b-\b]"
+" [+Z?time zone name]"
+" [+=[=]][-+]]flag?set (default or +) or clear (-) \aflag\a"
+" for the remainder of \aformat\a, or for the remainder"
+" of the process if \b==\b is specified. \aflag\a may be:]{"
+" [+l?enable leap second adjustments]"
+" [+n?convert \b%S\b as \b%S.%N\b]"
+" [+u?UTC time zone]"
+" }"
+" [+#?equivalent to %s]"
+" [+??alternate?use \aalternate\a format if a default format"
+" override has not been specified, e.g., \bls\b(1) uses"
+" \"%?%l\"; export TM_OPTIONS=\"format='\aoverride\a'\""
+" to override the default]"
+"}"
+"[i:incremental|adjust?Set the system time in incrementatl adjustments to"
+" avoid complete time shift shock. Negative adjustments still maintain"
+" monotonic increasing time. Not available on all systems.]"
+"[L:last?List only the last time for multiple \adate\a operands.]"
+"[l:leap-seconds?Include leap seconds in time calculations. Leap seconds"
+" after the ast library release date are not accounted for.]"
+"[m:modify-time|mtime?List file argument modify times.]"
+"[n!:network?Set network time.]"
+"[p:parse?Add \aformat\a to the list of \bstrptime\b(3) parse conversion"
+" formats. \aformat\a follows the same conventions as the"
+" \b--format\b option, with the addition of these format"
+" fields:]:[format]{"
+" [+|?If the format failed before this point then restart"
+" the parse with the remaining format.]"
+" [+&?Call the \btmdate\b(3) heuristic parser. This is"
+" is the default when \b--parse\b is omitted.]"
+"}"
+"[s:show?Show the date without setting the system time.]"
+"[u:utc|gmt|zulu?Output dates in \acoordinated universal time\a (UTC).]"
+"[U:unelapsed?Interpret each argument as \bfmtelapsed\b(3) elapsed"
+" time and list the \bstrelapsed\b(3) 1/\ascale\a seconds.]#[scale]"
+"[z:list-zones?List the known time zone table and exit. The table columns"
+" are: country code, standard zone name, savings time zone name,"
+" minutes west of \bUTC\b, and savings time minutes offset. Blank"
+" or empty entries are listed as \b-\b.]"
+
+"\n"
+"\n[ +format | date ... | file ... ]\n"
+"\n"
+
+"[+SEE ALSO?\bcrontab\b(1), \bls\b(1), \btouch\b(1), \bfmtelapsed\b(3),"
+" \bstrftime\b(3), \bstrptime\b(3), \btm\b(3)]"
+;
+
+#include <cmd.h>
+#include <ls.h>
+#include <proc.h>
+#include <tmx.h>
+#include <times.h>
+
+typedef struct Fmt
+{
+ struct Fmt* next;
+ char* format;
+} Fmt_t;
+
+#ifndef ENOSYS
+#define ENOSYS EINVAL
+#endif
+
+/*
+ * set the system clock
+ * the standards wimped out here
+ */
+
+static int
+settime(const char* cmd, Time_t now, int adjust, int network)
+{
+ char* s;
+ char** argv;
+ char* args[5];
+ char buf[128];
+
+ if (!adjust && !network)
+ return tmxsettime(now);
+ argv = args;
+ s = "/usr/bin/date";
+ if (!streq(cmd, s) && (!eaccess(s, X_OK) || !eaccess(s+=4, X_OK)))
+ {
+ *argv++ = s;
+ if (streq(astconf("UNIVERSE", NiL, NiL), "att"))
+ {
+ tmxfmt(buf, sizeof(buf), "%m%d%H" "%M" "%Y.%S", now);
+ if (adjust)
+ *argv++ = "-a";
+ }
+ else
+ {
+ tmxfmt(buf, sizeof(buf), "%Y" "%m%d%H" "%M.%S", now);
+ if (network)
+ *argv++ = "-n";
+ if (tm_info.flags & TM_UTC)
+ *argv++ = "-u";
+ }
+ *argv++ = buf;
+ *argv = 0;
+ if (!procrun(s, args))
+ return 0;
+ }
+ return -1;
+}
+
+/*
+ * convert s to Time_t with error checking
+ */
+
+static Time_t
+convert(register Fmt_t* f, char* s, Time_t now)
+{
+ char* t;
+ char* u;
+
+ do
+ {
+ now = tmxscan(s, &t, f->format, &u, now, 0);
+ if (!*t && (!f->format || !*u))
+ break;
+ } while (f = f->next);
+ if (!f || *t)
+ error(3, "%s: invalid date specification", f ? t : s);
+ return now;
+}
+
+int
+b_date(int argc, register char** argv, void* context)
+{
+ register int n;
+ register char* s;
+ register Fmt_t* f;
+ char* t;
+ unsigned long u;
+ Time_t now;
+ Time_t ts;
+ Time_t te;
+ Time_t e;
+ char buf[128];
+ Fmt_t* fmts;
+ Fmt_t fmt;
+ struct stat st;
+
+ char* cmd = argv[0]; /* original command path */
+ char* format = 0; /* tmxfmt() format */
+ char* string = 0; /* date string */
+ int elapsed = 0; /* args are start/stop pairs */
+ int filetime = 0; /* use this st_ time field */
+ int increment = 0; /* incrementally adjust time */
+ int last = 0; /* display the last time arg */
+ Tm_zone_t* listzones = 0; /* known time zone table */
+ int network = 0; /* don't set network time */
+ int show = 0; /* show date and don't set */
+ int unelapsed = 0; /* fmtelapsed() => strelapsed */
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ setlocale(LC_ALL, "");
+ tm_info.flags = TM_DATESTYLE;
+ fmts = &fmt;
+ fmt.format = "";
+ fmt.next = 0;
+ for (;;)
+ {
+ switch (optget(argv, usage))
+ {
+ case 'a':
+ case 'c':
+ case 'm':
+ filetime = opt_info.option[1];
+ continue;
+ case 'd':
+ string = opt_info.arg;
+ show = 1;
+ continue;
+ case 'e':
+ format = "%#";
+ continue;
+ case 'E':
+ elapsed = 1;
+ continue;
+ case 'f':
+ format = opt_info.arg;
+ continue;
+ case 'i':
+ increment = 1;
+ continue;
+ case 'l':
+ tm_info.flags |= TM_LEAP;
+ continue;
+ case 'L':
+ last = 1;
+ continue;
+ case 'n':
+ network = 1;
+ continue;
+ case 'p':
+ if (!(f = newof(0, Fmt_t, 1, 0)))
+ error(ERROR_SYSTEM|3, "out of space [format]");
+ f->next = fmts;
+ f->format = opt_info.arg;
+ fmts = f;
+ continue;
+ case 's':
+ show = 1;
+ continue;
+ case 'u':
+ tm_info.flags |= TM_UTC;
+ continue;
+ case 'U':
+ unelapsed = (int)opt_info.num;
+ continue;
+ case 'z':
+ listzones = tm_data.zone;
+ continue;
+ case '?':
+ error(ERROR_USAGE|4, "%s", opt_info.arg);
+ continue;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ continue;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ if (error_info.errors)
+ error(ERROR_USAGE|4, "%s", optusage(NiL));
+ now = tmxgettime();
+ if (listzones)
+ {
+ s = "-";
+ while (listzones->standard)
+ {
+ if (listzones->type)
+ s = listzones->type;
+ sfprintf(sfstdout, "%3s %4s %4s %4d %4d\n", s, *listzones->standard ? listzones->standard : "-", listzones->daylight ? listzones->daylight : "-", listzones->west, listzones->dst);
+ listzones++;
+ show = 1;
+ }
+ }
+ else if (elapsed)
+ {
+ e = 0;
+ while (s = *argv++)
+ {
+ if (!(t = *argv++))
+ {
+ argv--;
+ t = "now";
+ }
+ ts = convert(fmts, s, now);
+ te = convert(fmts, t, now);
+ if (te > ts)
+ e += te - ts;
+ else
+ e += ts - te;
+ }
+ sfputr(sfstdout, fmtelapsed((unsigned long)tmxsec(e), 1), '\n');
+ show = 1;
+ }
+ else if (unelapsed)
+ {
+ while (s = *argv++)
+ {
+ u = strelapsed(s, &t, unelapsed);
+ if (*t)
+ error(3, "%s: invalid elapsed time", s);
+ sfprintf(sfstdout, "%lu\n", u);
+ }
+ show = 1;
+ }
+ else if (filetime)
+ {
+ if (!*argv)
+ error(ERROR_USAGE|4, "%s", optusage(NiL));
+ n = argv[1] != 0;
+ while (s = *argv++)
+ {
+ if (stat(s, &st))
+ error(2, "%s: not found", s);
+ else
+ {
+ switch (filetime)
+ {
+ case 'a':
+ now = tmxgetatime(&st);
+ break;
+ case 'c':
+ now = tmxgetctime(&st);
+ break;
+ default:
+ now = tmxgetmtime(&st);
+ break;
+ }
+ tmxfmt(buf, sizeof(buf), format, now);
+ if (n)
+ sfprintf(sfstdout, "%s: %s\n", s, buf);
+ else
+ sfprintf(sfstdout, "%s\n", buf);
+ show = 1;
+ }
+ }
+ }
+ else
+ {
+ if ((s = *argv) && !format && *s == '+')
+ {
+ format = s + 1;
+ argv++;
+ s = *argv;
+ }
+ if (s || (s = string))
+ {
+ if (*argv && string)
+ error(ERROR_USAGE|4, "%s", optusage(NiL));
+ now = convert(fmts, s, now);
+ if (*argv && (s = *++argv))
+ {
+ show = 1;
+ do
+ {
+ if (!last)
+ {
+ tmxfmt(buf, sizeof(buf), format, now);
+ sfprintf(sfstdout, "%s\n", buf);
+ }
+ now = convert(fmts, s, now);
+ } while (s = *++argv);
+ }
+ }
+ else
+ show = 1;
+ if (format || show)
+ {
+ tmxfmt(buf, sizeof(buf), format, now);
+ sfprintf(sfstdout, "%s\n", buf);
+ }
+ else if (settime(cmd, now, increment, network))
+ error(ERROR_SYSTEM|3, "cannot set system time");
+ }
+ while (fmts != &fmt)
+ {
+ f = fmts;
+ fmts = fmts->next;
+ free(f);
+ }
+ tm_info.flags = 0;
+ if (show && sfsync(sfstdout))
+ error(ERROR_system(0), "write error");
+ return error_info.errors != 0;
+}
diff --git a/usr/src/lib/libcmd/common/dirname.c b/usr/src/lib/libcmd/common/dirname.c
new file mode 100644
index 0000000000..f4a3c820c3
--- /dev/null
+++ b/usr/src/lib/libcmd/common/dirname.c
@@ -0,0 +1,116 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Bell Laboratories
+ *
+ * dirname path [suffix]
+ *
+ * print the dirname of a pathname
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: dirname (AT&T Research) 2000-03-07 $\n]"
+USAGE_LICENSE
+"[+NAME?dirname - return directory portion of file name]"
+"[+DESCRIPTION?\bdirname\b treats \astring\a as a file name and returns "
+ "the name of the directory containing the file name by deleting "
+ "the last component from \astring\a.]"
+"[+?If \astring\a consists solely of \b/\b characters the output will "
+ "be a single \b/\b unless \bPATH_LEADING_SLASHES\b returned by "
+ "\bgetconf\b(1) is \b1\b and \astring\a consists of multiple "
+ "\b/\b characters in which case \b//\b will be output. "
+ "Otherwise, trailing \b/\b characters are removed, and if "
+ "there are no remaining \b/\b characters in \astring\a, "
+ "the string \b.\b will be written to standard output. "
+ "Otherwise, all characters following the last \b/\b are removed. "
+ "If the remaining string consists solely of \b/\b characters, "
+ "the output will be as if the original string had consisted solely "
+ "as \b/\b characters as described above. Otherwise, all "
+ "trailing slashes are removed and the output will be this string "
+ "unless this string is empty. If empty the output will be \b.\b.]"
+"\n"
+"\n string\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Successful Completion.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bbasename\b(1), \bgetconf\b(1), \bdirname\b(3)]"
+;
+
+#include <cmd.h>
+
+static void l_dirname(register Sfio_t *outfile, register const char *pathname)
+{
+ register const char *last;
+ /* go to end of path */
+ for(last=pathname; *last; last++);
+ /* back over trailing '/' */
+ while(last>pathname && *--last=='/');
+ /* back over non-slash chars */
+ for(;last>pathname && *last!='/';last--);
+ if(last==pathname)
+ {
+ /* all '/' or "" */
+ if(*pathname!='/')
+ last = pathname = ".";
+ }
+ else
+ {
+ /* back over trailing '/' */
+ for(;*last=='/' && last > pathname; last--);
+ }
+ /* preserve // */
+ if(last!=pathname && pathname[0]=='/' && pathname[1]=='/')
+ {
+ while(pathname[2]=='/' && pathname<last)
+ pathname++;
+ if(last!=pathname && pathname[0]=='/' && pathname[1]=='/' && *astconf("PATH_LEADING_SLASHES",NiL,NiL)!='1')
+ pathname++;
+ }
+ sfwrite(outfile,pathname,last+1-pathname);
+ sfputc(outfile,'\n');
+}
+
+int
+b_dirname(int argc,register char *argv[], void* context)
+{
+ register int n;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ while (n = optget(argv, usage)) switch (n)
+ {
+ case ':':
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ argc -= opt_info.index;
+ if(error_info.errors || argc != 1)
+ error(ERROR_usage(2),"%s", optusage(NiL));
+ l_dirname(sfstdout,argv[0]);
+ return(0);
+}
diff --git a/usr/src/lib/libcmd/common/expr.c b/usr/src/lib/libcmd/common/expr.c
new file mode 100644
index 0000000000..1baee2435e
--- /dev/null
+++ b/usr/src/lib/libcmd/common/expr.c
@@ -0,0 +1,535 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * expr.c
+ * Written by David Korn
+ * Tue Oct 31 08:48:11 EST 1995
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: expr (AT&T Research) 2004-05-27 $\n]"
+USAGE_LICENSE
+"[+NAME?expr - evaluate arguments as an expression]"
+"[+DESCRIPTION?\bexpr\b evaluates an expression given as arguments and writes "
+ "the result to standard output. The character \b0\b will be written "
+ "to indicate a zero value and nothing will be written to indicate an "
+ "empty string.]"
+"[+?Most of the functionality of \bexpr\b is provided in a more natural "
+ "way by the shell, \bsh\b(1), and \bexpr\b is provided primarily "
+ "for backward compatibility.]"
+"[+?Terms of the expression must be separate arguments. A string argument is "
+ "one that can not be identified as an integer. Integer-valued "
+ "arguments may be preceded by a unary plus or minus sign. Because "
+ "many of the operators use characters that have special meaning to "
+ "the shell, they must be quoted when entered from the shell.]"
+
+"[+?Expressions are formed from the operators listed below in order "
+ "of increasing precedence within groups. All of the operators are "
+ "left associative. The symbols \aexpr1\a and \aexpr2\a represent "
+ "expressions formed from strings and integers and the following "
+ "operators:]{"
+ "[+\aexpr1\a \b|\b \aexpr2\a?Returns the evaluation of \aexpr1\a if "
+ "it is neither null nor 0, otherwise returns the evaluation of expr2.]"
+
+ "[+\aexpr1\a \b&\b \aexpr2\a?Returns the evaluation of \aexpr1\a if "
+ "neither expression evaluates to null or 0, otherwise returns 0.]"
+
+ "[+\aexpr1\a \aop\a \aexpr2\a?Returns the result of a decimal integer "
+ "comparison if both arguments are integers; otherwise, returns the "
+ "result of a string comparison using the locale-specific collation "
+ "sequence. The result of each comparison will be 1 if the specified "
+ "relationship is true, or 0 if the relationship is false. \aop\a "
+ "can be one of the following:]{"
+ "[+=?Equal.]"
+ "[+==?Equal.]"
+ "[+>?Greater than.]"
+ "[+>=?Greater than or equal to.]"
+ "[+<?Less than.]"
+ "[+<=?Less than or equal to.]"
+ "[+!=?Not equal to.]"
+ "}"
+
+ "[+\aexpr1\a \aop\a \aexpr2\a?Where \aop\a is \b+\b or \b-\b; "
+ "addition or subtraction of decimal integer-valued arguments.]"
+ "[+\aexpr1\a \aop\a \aexpr2\a?Where \aop\a is \b*\b, \b/\b or \b%\b; "
+ "multiplication, division, or remainder of the decimal "
+ "integer-valued arguments.]"
+ "[+\aexpr1\a \b::\b \aexpr2\a?The matching operator : compares "
+ "\aexpr1\a with \aexpr2\a, which must be a BRE. Normally, "
+ "the matching operator returns the number of bytes matched "
+ "and 0 on failure. However, if the pattern contains at "
+ "least one sub-expression [\\( . . .\\)]], the string "
+ "corresponding to \\1 will be returned.]"
+ "[+( \aexpr1\a )?Grouping symbols. An expression can "
+ "be placed within parenthesis to change precedence.]"
+ "[+match\b \astring\a \aexpr\a?Equivalent to \astring\a \b:\b "
+ "\aexpr\a.]"
+ "[+substr\b \astring\a \apos\a \alength\a?\alength\a character "
+ "substring of \astring\a starting at \apos\a "
+ "(counting from 1).]"
+ "[+index\b \astring\a \achars\a?The position in \astring\a "
+ "(counting from 1) of the leftmost occurrence of any "
+ "character in \achars\a.]"
+ "[+length\b \astring\a?The number of characters in \astring\a.]"
+ "[+quote\b \atoken\a?Treat \atoken\a as a string operand.]"
+ "}"
+"[+?For backwards compatibility, unrecognized options beginning with "
+ "a \b-\b will be treated as operands. Portable applications "
+ "should use \b--\b to indicate end of options.]"
+
+"\n"
+"\n operand ...\n"
+"\n"
+
+"[+EXIT STATUS?]{"
+ "[+0?The expression is neither null nor 0.]"
+ "[+1?The expression is null or 0.]"
+ "[+2?Invalid expressions.]"
+ "[+>2?An error occurred.]"
+ "}"
+"[+SEE ALSO?\bregcomp\b(5), \bgrep\b(1), \bsh\b(1)]"
+;
+
+#include <cmd.h>
+#include <regex.h>
+
+#define T_ADD 0x100
+#define T_MULT 0x200
+#define T_CMP 0x400
+#define T_FUN 0x800
+#define T_OP 7
+#define T_NUM 1
+#define T_STR 2
+
+#define OP_EQ (T_CMP|0)
+#define OP_GT (T_CMP|1)
+#define OP_LT (T_CMP|2)
+#define OP_GE (T_CMP|3)
+#define OP_LE (T_CMP|4)
+#define OP_NE (T_CMP|5)
+#define OP_PLUS (T_ADD|0)
+#define OP_MINUS (T_ADD|1)
+#define OP_MULT (T_MULT|0)
+#define OP_DIV (T_MULT|1)
+#define OP_MOD (T_MULT|2)
+#define OP_INDEX (T_FUN|0)
+#define OP_LENGTH (T_FUN|1)
+#define OP_MATCH (T_FUN|2)
+#define OP_QUOTE (T_FUN|3)
+#define OP_SUBSTR (T_FUN|4)
+
+#define numeric(np) ((np)->type&T_NUM)
+
+static const struct Optable_s
+{
+ const char opname[3];
+ int op;
+}
+optable[] =
+{
+ "|", '|',
+ "&", '&',
+ "=", OP_EQ,
+ "==", OP_EQ,
+ ">", OP_GT,
+ "<", OP_LT,
+ ">=", OP_GE,
+ "<=", OP_LE,
+ "!=", OP_NE,
+ "+", OP_PLUS,
+ "-", OP_MINUS,
+ "*", OP_MULT,
+ "/", OP_DIV,
+ "%", OP_MOD,
+ ":", ':',
+ "(", '(',
+ ")", ')'
+};
+
+typedef struct Node_s
+{
+ int type;
+ long num;
+ char *str;
+} Node_t;
+
+typedef struct State_s
+{
+ int standard;
+ char** arglist;
+ char buf[36];
+} State_t;
+
+static int expr_or(State_t*, Node_t*);
+
+static int getnode(State_t* state, Node_t *np)
+{
+ register char* sp;
+ register char* cp;
+ register int i;
+ register int j;
+ register int k;
+ register int tok;
+ char* ep;
+
+ if (!(cp = *state->arglist++))
+ error(ERROR_exit(2), "argument expected");
+ if (!state->standard)
+ switch (cp[0])
+ {
+ case 'i':
+ if (cp[1] == 'n' && !strcmp(cp, "index"))
+ {
+ if (!(cp = *state->arglist++))
+ error(ERROR_exit(2), "string argument expected");
+ if (!(ep = *state->arglist++))
+ error(ERROR_exit(2), "chars argument expected");
+ np->num = (ep = strpbrk(cp, ep)) ? (ep - cp + 1) : 0;
+ np->type = T_NUM;
+ goto next;
+ }
+ break;
+ case 'l':
+ if (cp[1] == 'e' && !strcmp(cp, "length"))
+ {
+ if (!(cp = *state->arglist++))
+ error(ERROR_exit(2), "string argument expected");
+ np->num = strlen(cp);
+ np->type = T_NUM;
+ goto next;
+ }
+ break;
+ case 'm':
+ if (cp[1] == 'a' && !strcmp(cp, "match"))
+ {
+ if (!(np->str = *state->arglist++))
+ error(ERROR_exit(2), "pattern argument expected");
+ np->type = T_STR;
+ return ':';
+ }
+ break;
+ case 'q':
+ if (cp[1] == 'u' && !strcmp(cp, "quote") && !(cp = *state->arglist++))
+ error(ERROR_exit(2), "string argument expected");
+ break;
+ case 's':
+ if (cp[1] == 'u' && !strcmp(cp, "substr"))
+ {
+ if (!(sp = *state->arglist++))
+ error(ERROR_exit(2), "string argument expected");
+ if (!(cp = *state->arglist++))
+ error(ERROR_exit(2), "position argument expected");
+ i = strtol(cp, &ep, 10);
+ if (*ep || --i <= 0)
+ i = -1;
+ if (!(cp = *state->arglist++))
+ error(ERROR_exit(2), "length argument expected");
+ j = strtol(cp, &ep, 10);
+ if (*ep)
+ j = -1;
+ k = strlen(sp);
+ if (i < 0 || i >= k || j < 0)
+ sp = "";
+ else
+ {
+ sp += i;
+ k -= i;
+ if (j < k)
+ sp[j] = 0;
+ }
+ np->type = T_STR;
+ np->str = sp;
+ goto next;
+ }
+ break;
+ }
+ if (*cp=='(' && cp[1]==0)
+ {
+ tok = expr_or(state, np);
+ if (tok != ')')
+ error(ERROR_exit(2),"closing parenthesis missing");
+ }
+ else
+ {
+ np->type = T_STR;
+ np->str = cp;
+ if (*cp)
+ {
+ np->num = strtol(np->str,&ep,10);
+ if (!*ep)
+ np->type |= T_NUM;
+ }
+ }
+ next:
+ if (!(cp = *state->arglist))
+ return 0;
+ state->arglist++;
+ for (i=0; i < sizeof(optable)/sizeof(*optable); i++)
+ if (*cp==optable[i].opname[0] && cp[1]==optable[i].opname[1])
+ return optable[i].op;
+ error(ERROR_exit(2),"%s: unknown operator argument",cp);
+ return 0;
+}
+
+static int expr_cond(State_t* state, Node_t *np)
+{
+ register int tok = getnode(state, np);
+
+ while (tok==':')
+ {
+ regex_t re;
+ regmatch_t match[2];
+ int n;
+ Node_t rp;
+ char *cp;
+ tok = getnode(state, &rp);
+ if (np->type&T_STR)
+ cp = np->str;
+ else
+ sfsprintf(cp=state->buf,sizeof(state->buf),"%d",np->num);
+ np->num = 0;
+ np->type = T_NUM;
+ if (n = regcomp(&re, rp.str, REG_LEFT|REG_LENIENT))
+ regfatal(&re, ERROR_exit(2), n);
+ if (!(n = regexec(&re, cp, elementsof(match), match, 0)))
+ {
+ if (re.re_nsub > 0)
+ {
+ np->type = T_STR;
+ if (match[1].rm_so >= 0)
+ {
+ np->str = cp + match[1].rm_so;
+ np->str[match[1].rm_eo - match[1].rm_so] = 0;
+ np->num = strtol(np->str,&cp,10);
+ if (cp!=np->str && *cp==0)
+ np->type |= T_NUM;
+ }
+ else
+ np->str = "";
+ }
+ else
+ np->num = match[0].rm_eo - match[0].rm_so;
+ }
+ else if (n != REG_NOMATCH)
+ regfatal(&re, ERROR_exit(2), n);
+ else if (re.re_nsub)
+ {
+ np->str = "";
+ np->type = T_STR;
+ }
+ regfree(&re);
+ }
+ return tok;
+}
+
+static int expr_mult(State_t* state, Node_t *np)
+{
+ register int tok = expr_cond(state, np);
+
+ while ((tok&~T_OP)==T_MULT)
+ {
+ Node_t rp;
+ int op = (tok&T_OP);
+ tok = expr_cond(state, &rp);
+ if (!numeric(np) || !numeric(&rp))
+ error(ERROR_exit(2),"non-numeric argument");
+ if (op && rp.num==0)
+ error(ERROR_exit(2),"division by zero");
+ switch(op)
+ {
+ case 0:
+ np->num *= rp.num;
+ break;
+ case 1:
+ np->num /= rp.num;
+ break;
+ case 2:
+ np->num %= rp.num;
+ }
+ np->type = T_NUM;
+ }
+ return tok;
+}
+
+static int expr_add(State_t* state, Node_t *np)
+{
+ register int tok = expr_mult(state, np);
+
+ while ((tok&~T_OP)==T_ADD)
+ {
+ Node_t rp;
+ int op = (tok&T_OP);
+ tok = expr_mult(state, &rp);
+ if (!numeric(np) || !numeric(&rp))
+ error(ERROR_exit(2),"non-numeric argument");
+ if (op)
+ np->num -= rp.num;
+ else
+ np->num += rp.num;
+ np->type = T_NUM;
+ }
+ return tok;
+}
+
+static int expr_cmp(State_t* state, Node_t *np)
+{
+ register int tok = expr_add(state, np);
+
+ while ((tok&~T_OP)==T_CMP)
+ {
+ Node_t rp;
+ register char *left,*right;
+ char buff1[36],buff2[36];
+ int op = (tok&T_OP);
+ tok = expr_add(state, &rp);
+ if (numeric(&rp) && numeric(np))
+ op |= 010;
+ else
+ {
+ if (np->type&T_STR)
+ left = np->str;
+ else
+ sfsprintf(left=buff1,sizeof(buff1),"%d",np->num);
+ if (rp.type&T_STR)
+ right = rp.str;
+ else
+ sfsprintf(right=buff2,sizeof(buff2),"%d",rp.num);
+ }
+ switch(op)
+ {
+ case 0:
+ np->num = streq(left,right);
+ break;
+ case 1:
+ np->num = (strcoll(left,right)>0);
+ break;
+ case 2:
+ np->num = (strcoll(left,right)<0);
+ break;
+ case 3:
+ np->num = (strcoll(left,right)>=0);
+ break;
+ case 4:
+ np->num = (strcoll(left,right)<=0);
+ break;
+ case 5:
+ np->num = !streq(left,right);
+ break;
+ case 010:
+ np->num = (np->num==rp.num);
+ break;
+ case 011:
+ np->num = (np->num>rp.num);
+ break;
+ case 012:
+ np->num = (np->num<rp.num);
+ break;
+ case 013:
+ np->num = (np->num>=rp.num);
+ break;
+ case 014:
+ np->num = (np->num<=rp.num);
+ break;
+ case 015:
+ np->num = (np->num!=rp.num);
+ break;
+ }
+ np->type = T_NUM;
+ }
+ return tok;
+}
+
+static int expr_and(State_t* state, Node_t *np)
+{
+ register int tok = expr_cmp(state, np);
+ while (tok=='&')
+ {
+ Node_t rp;
+ tok = expr_cmp(state, &rp);
+ if ((numeric(&rp) && rp.num==0) || *rp.str==0)
+ {
+ np->num = 0;
+ np->type=T_NUM;
+ }
+ }
+ return tok;
+}
+
+static int expr_or(State_t* state, Node_t *np)
+{
+ register int tok = expr_and(state, np);
+ while (tok=='|')
+ {
+ Node_t rp;
+ tok = expr_and(state, &rp);
+ if ((numeric(np) && np->num==0) || *np->str==0)
+ *np = rp;
+ }
+ return tok;
+}
+
+int
+b_expr(int argc, char *argv[], void *context)
+{
+ State_t state;
+ Node_t node;
+ int n;
+
+ cmdinit(argc, argv,context, ERROR_CATALOG, 0);
+ state.standard = !strcmp(astconf("CONFORMANCE", NiL, NiL), "standard");
+#if 0
+ if (state.standard)
+ state.arglist = argv+1;
+ else
+#endif
+ {
+ while (n=optget(argv, usage))
+ {
+ /*
+ * NOTE: this loop ignores all but literal -- and -?
+ * out of kindness for obsolescent usage
+ * (and is ok with the standard) but strict
+ * getopt conformance would give usage for all
+ * unknown - options
+ */
+ if(n=='?')
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ if (opt_info.option[1] != '?')
+ break;
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ }
+ if (error_info.errors)
+ error(ERROR_usage(2),"%s",optusage((char*)0));
+ state.arglist = argv+opt_info.index;
+ }
+ if (expr_or(&state, &node))
+ error(ERROR_exit(2),"syntax error");
+ if (node.type&T_STR)
+ {
+ if (*node.str)
+ sfprintf(sfstdout,"%s\n",node.str);
+ }
+ else
+ sfprintf(sfstdout,"%d\n",node.num);
+ return numeric(&node)?node.num==0:*node.str==0;
+}
diff --git a/usr/src/lib/libcmd/common/fds.c b/usr/src/lib/libcmd/common/fds.c
new file mode 100644
index 0000000000..b7e9fb2e88
--- /dev/null
+++ b/usr/src/lib/libcmd/common/fds.c
@@ -0,0 +1,168 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+static const char usage[] =
+"[-?\n@(#)$Id: fds (AT&T Research) 2006-10-26 $\n]"
+USAGE_LICENSE
+"[+NAME?fds - list open file descriptor status]"
+"[+DESCRIPTION?\bfds\b lists the status for each open file descriptor. "
+ "When invoked as a shell builtin it accesses the file descriptors of the "
+ "calling shell, otherwise it lists the file descriptors passed across "
+ "\bexec\b(2).]"
+"[l:long?List file descriptor details.]"
+"[+SEE ALSO?\blogname\b(1), \bwho\b(1), \bgetgroups\b(2)]"
+;
+
+#include <cmd.h>
+#include <ls.h>
+
+#include "FEATURE/sockets"
+
+#if defined(S_IFSOCK) && _sys_socket && _hdr_arpa_inet && _hdr_netinet_in && _lib_getsockname && _lib_getsockopt && _lib_inet_ntoa
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#else
+#undef S_IFSOCK
+#endif
+
+#ifndef minor
+#define minor(x) (int)((x)&0xff)
+#endif
+#ifndef major
+#define major(x) (int)(((unsigned int)(x)>>8)&0xff)
+#endif
+
+int
+b_fds(int argc, char** argv, void* context)
+{
+ register char* s;
+ register int i;
+ register char* m;
+ register char* x;
+ int flags;
+ int details;
+ struct stat st;
+#ifdef S_IFSOCK
+ struct sockaddr_in addr;
+ socklen_t len;
+ int type;
+ int prot;
+ char num[32];
+#endif
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ details = 0;
+ for (;;)
+ {
+ switch (optget(argv, usage))
+ {
+ case 'l':
+ details = opt_info.num;
+ continue;
+ case '?':
+ error(ERROR_USAGE|4, "%s", opt_info.arg);
+ continue;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ continue;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ if (error_info.errors || *argv)
+ error(ERROR_USAGE|4, "%s", optusage(NiL));
+ for (i = 0; i <= OPEN_MAX; i++)
+ if (fstat(i, &st))
+ /* not open */;
+ else if (details)
+ {
+ if ((flags = fcntl(i, F_GETFL, (char*)0)) == -1)
+ m = "--";
+ else
+ switch (flags & (O_RDONLY|O_WRONLY|O_RDWR))
+ {
+ case O_RDONLY:
+ m = "r-";
+ break;
+ case O_WRONLY:
+ m = "-w";
+ break;
+ case O_RDWR:
+ m = "rw";
+ break;
+ default:
+ m = "??";
+ break;
+ }
+ x = (fcntl(i, F_GETFD, (char*)0) > 0) ? "x" : "-";
+ if (isatty(i) && (s = ttyname(i)))
+ sfprintf(sfstdout, "%02d %s%s %s %s\n", i, m, x, fmtmode(st.st_mode, 0), s);
+#ifdef S_IFSOCK
+ else if ((len = sizeof(addr))
+ && !getsockname(i, (struct sockaddr*)&addr, (void*)&len)
+ && len == sizeof(addr)
+ && addr.sin_family == AF_INET
+#ifdef SO_TYPE
+ && (len = sizeof(type))
+ && !getsockopt(i, SOL_SOCKET, SO_TYPE, (void*)&type, (void*)&len)
+ && len == sizeof(type)
+#else
+ && !(type = 0)
+#endif
+#ifdef SO_PROTOTYPE
+ && (len = sizeof(prot))
+ && (!getsockopt(i, SOL_SOCKET, SO_PROTOTYPE, (void*)&prot, (void*)&len) || !(prot = 0))
+#else
+ && !(prot = 0)
+#endif
+ )
+ {
+ if (!st.st_mode)
+ st.st_mode = S_IFSOCK|S_IRUSR|S_IWUSR;
+ s = 0;
+ switch (type)
+ {
+ case SOCK_DGRAM:
+ s = "udp";
+ break;
+ case SOCK_STREAM:
+ if (prot == 0)
+ s = "tcp";
+#ifdef IPPROTO_SCTP
+ else if (prot == IPPROTO_SCTP)
+ s = "sctp";
+#endif
+ break;
+ }
+ if (!s)
+ sfprintf(sfstdout, s = num, "type.%d.prot.%d", type, prot);
+ sfprintf(sfstdout, "%02d %s%s %s /dev/%s/%s/%d\n", i, m, x, fmtmode(st.st_mode, 0), s, inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
+ }
+#endif
+ else
+ sfprintf(sfstdout, "%02d %s%s %s /dev/inode/%u/%u\n", i, m, x, fmtmode(st.st_mode, 0), st.st_dev, st.st_ino);
+ }
+ else
+ sfprintf(sfstdout, "%d\n", i);
+ return 0;
+}
diff --git a/usr/src/lib/libcmd/common/features/ids b/usr/src/lib/libcmd/common/features/ids
new file mode 100644
index 0000000000..04be5755cf
--- /dev/null
+++ b/usr/src/lib/libcmd/common/features/ids
@@ -0,0 +1,8 @@
+lib endgrent,getgrent,setgrent
+lib fsid,getfsgid,isfsg sys/types.h sys/fss.h fsg.h -lfsg
+mac fsid sys/types.h sys/fss.h fsg.h
+cat{
+ #if !_lib_fsid && _mac_fsid
+ #define _lib_fsid 1
+ #endif
+}end
diff --git a/usr/src/lib/libcmd/common/features/sockets b/usr/src/lib/libcmd/common/features/sockets
new file mode 100644
index 0000000000..2660abb8df
--- /dev/null
+++ b/usr/src/lib/libcmd/common/features/sockets
@@ -0,0 +1,3 @@
+sys socket
+hdr arpa.inet,netinet.in
+lib getsockname,getsockopt,inet_ntoa
diff --git a/usr/src/lib/libcmd/common/features/symlink b/usr/src/lib/libcmd/common/features/symlink
new file mode 100644
index 0000000000..a7d86b09f5
--- /dev/null
+++ b/usr/src/lib/libcmd/common/features/symlink
@@ -0,0 +1,21 @@
+lib lchmod note{ lchmod implemented }end execute{
+ #include <unistd.h>
+ #include <errno.h>
+ int
+ main()
+ {
+ lchmod("No-FiLe", 0);
+ return errno != ENOENT;
+ }
+}end
+
+lib lchown note{ lchown implemented }end execute{
+ #include <unistd.h>
+ #include <errno.h>
+ int
+ main()
+ {
+ lchown("No-FiLe", 0, 0);
+ return errno != ENOENT;
+ }
+}end
diff --git a/usr/src/lib/libcmd/common/features/utsname b/usr/src/lib/libcmd/common/features/utsname
new file mode 100644
index 0000000000..5b746ce7ad
--- /dev/null
+++ b/usr/src/lib/libcmd/common/features/utsname
@@ -0,0 +1,12 @@
+lib getdomainname,gethostid,gethostname,sethostname,syscall,systeminfo,uname
+lib syssgi
+mem utsname.base_rel,utsname.idnumber,utsname.m_type,utsname.nodeext sys/utsname.h
+sys syscall,systeminfo,syssgi
+
+tst cross{
+ u=`/bin/uname -o 2>/dev/null`
+ case $u in
+ '') ;;
+ *) echo "#define _UNAME_os_DEFAULT \"$u\" /* default os name */" ;;
+ esac
+}end
diff --git a/usr/src/lib/libcmd/common/fmt.c b/usr/src/lib/libcmd/common/fmt.c
new file mode 100644
index 0000000000..2cbcc9c8ea
--- /dev/null
+++ b/usr/src/lib/libcmd/common/fmt.c
@@ -0,0 +1,632 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+static const char usage[] =
+"[-?\n@(#)$Id: fmt (AT&T Research) 2007-01-02 $\n]"
+USAGE_LICENSE
+"[+NAME?fmt - simple text formatter]"
+"[+DESCRIPTION?\bfmt\b reads the input files and left justifies space "
+ "separated words into lines \awidth\a characters or less in length and "
+ "writes the lines to the standard output. The standard input is read if "
+ "\b-\b or no files are specified. Blank lines and interword spacing are "
+ "preserved in the output. Indentation is preserved, and lines with "
+ "identical indentation are joined and justified.]"
+"[+?\bfmt\b is meant to format mail messages prior to sending, but may "
+ "also be useful for other simple tasks. For example, in \bvi\b(1) the "
+ "command \b:!}fmt\b will justify the lines in the current paragraph.]"
+"[c:crown-margin?Preserve the indentation of the first two lines within "
+ "a paragraph, and align the left margin of each subsequent line with "
+ "that of the second line.]"
+"[o:optget?Format concatenated \boptget\b(3) usage strings.]"
+"[s:split-only?Split lines only; do not join short lines to form longer "
+ "ones.]"
+"[u:uniform-spacing?One space between words, two after sentences.]"
+"[w:width?Set the output line width to \acolumns\a.]#[columns:=72]"
+ "\n\n"
+"[ file ... ]"
+ "\n\n"
+"[+SEE ALSO?\bmailx\b(1), \bnroff\b(1), \btroff\b(1), \bvi\b(1), "
+ "\boptget\b(3)]"
+;
+
+#include <cmd.h>
+#include <ctype.h>
+
+typedef struct Fmt_s
+{
+ long flags;
+ char* outp;
+ char* outbuf;
+ char* endbuf;
+ Sfio_t* in;
+ Sfio_t* out;
+ int indent;
+ int nextdent;
+ int nwords;
+ int prefix;
+ int quote;
+ int retain;
+ int section;
+} Fmt_t;
+
+#define INDENT 4
+#define TABSZ 8
+
+#define isoption(fp,c) ((fp)->flags&(1L<<((c)-'a')))
+#define setoption(fp,c) ((fp)->flags|=(1L<<((c)-'a')))
+#define clroption(fp,c) ((fp)->flags&=~(1L<<((c)-'a')))
+
+static void
+outline(Fmt_t* fp)
+{
+ register char* cp = fp->outbuf;
+ int n = 0;
+ int c;
+ int d;
+
+ if (!fp->outp)
+ return;
+ while (fp->outp[-1] == ' ')
+ fp->outp--;
+ *fp->outp = 0;
+ while (*cp++ == ' ')
+ n++;
+ if (n >= TABSZ)
+ {
+ n /= TABSZ;
+ cp = &fp->outbuf[TABSZ*n];
+ while (n--)
+ *--cp = '\t';
+ }
+ else
+ cp = fp->outbuf;
+ fp->nwords = 0;
+ if (!isoption(fp, 'o'))
+ sfputr(fp->out, cp, '\n');
+ else if (*cp)
+ {
+ n = fp->indent;
+ if (*cp != '[')
+ {
+ if (*cp == ' ')
+ cp++;
+ n += INDENT;
+ }
+ while (n--)
+ sfputc(fp->out, ' ');
+ if (fp->quote)
+ {
+ if ((d = (fp->outp - cp)) <= 0)
+ c = 0;
+ else if ((c = fp->outp[-1]) == 'n' && d > 1 && fp->outp[-2] == '\\')
+ c = '}';
+ sfprintf(fp->out, "\"%s%s\"\n", cp, c == ']' || c == '{' || c == '}' ? "" : " ");
+ }
+ else
+ sfputr(fp->out, cp, '\n');
+ if (fp->nextdent)
+ {
+ fp->indent += fp->nextdent;
+ fp->endbuf -= fp->nextdent;
+ fp->nextdent = 0;
+ }
+ }
+ fp->outp = 0;
+}
+
+static void
+split(Fmt_t* fp, char* buf, int splice)
+{
+ register char* cp;
+ register char* ep;
+ register char* qp;
+ register int c = 1;
+ register int q = 0;
+ register int n;
+ int prefix;
+
+ for (ep = buf; *ep == ' '; ep++);
+ prefix = ep - buf;
+
+ /*
+ * preserve blank lines
+ */
+
+ if ((*ep == 0 || *buf == '.') && !isoption(fp, 'o'))
+ {
+ if (*ep)
+ prefix = strlen(buf);
+ outline(fp);
+ strcpy(fp->outbuf, buf);
+ fp->outp = fp->outbuf+prefix;
+ outline(fp);
+ return;
+ }
+ if (fp->prefix < prefix && !isoption(fp, 'c'))
+ outline(fp);
+ if (!fp->outp || prefix < fp->prefix)
+ fp->prefix = prefix;
+ while (c)
+ {
+ cp = ep;
+ while (*ep == ' ')
+ ep++;
+ if (cp != ep && isoption(fp, 'u'))
+ cp = ep-1;
+ while (c = *ep)
+ {
+ if (c == ' ')
+ break;
+ ep++;
+
+ /*
+ * skip over \space
+ */
+
+ if (c == '\\' && *ep)
+ ep++;
+ }
+ n = (ep-cp);
+ if (n && isoption(fp, 'o'))
+ {
+ for (qp = cp; qp < ep; qp++)
+ if (*qp == '\\')
+ qp++;
+ else if (*qp == '"')
+ q = !q;
+ if (*(ep-1) == '"')
+ goto skip;
+ }
+ if (fp->nwords > 0 && &fp->outp[n] >= fp->endbuf && !fp->retain && !q)
+ outline(fp);
+ skip:
+ if (fp->nwords == 0)
+ {
+ if (fp->prefix)
+ memset(fp->outbuf, ' ', fp->prefix);
+ fp->outp = &fp->outbuf[fp->prefix];
+ while (*cp == ' ')
+ cp++;
+ n = (ep-cp);
+ }
+ memcpy(fp->outp, cp, n);
+ fp->outp += n;
+ fp->nwords++;
+ }
+ if (isoption(fp, 's') || *buf == 0)
+ outline(fp);
+ else if (fp->outp)
+ {
+ /*
+ * two spaces at ends of sentences
+ */
+
+ if (!isoption(fp, 'o') && strchr(".:!?", fp->outp[-1]))
+ *fp->outp++ = ' ';
+ if (!splice && !fp->retain && (!fp->quote || (fp->outp - fp->outbuf) < 2 || fp->outp[-2] != '\\' || fp->outp[-1] != 'n' && fp->outp[-1] != 't' && fp->outp[-1] != ' '))
+ *fp->outp++ = ' ';
+ }
+}
+
+static int
+dofmt(Fmt_t* fp)
+{
+ register int c;
+ int b;
+ int x;
+ int splice;
+ char* cp;
+ char* dp;
+ char* ep;
+ char* lp;
+ char* tp;
+ char buf[8192];
+
+ cp = 0;
+ while (cp || (cp = sfgetr(fp->in, '\n', 0)) && !(splice = 0) && (lp = cp + sfvalue(fp->in) - 1) || (cp = sfgetr(fp->in, '\n', SF_LASTR)) && (splice = 1) && (lp = cp + sfvalue(fp->in)))
+ {
+ if (isoption(fp, 'o'))
+ {
+ if (!isoption(fp, 'i'))
+ {
+ setoption(fp, 'i');
+ b = 0;
+ while (cp < lp)
+ {
+ if (*cp == ' ')
+ b += 1;
+ else if (*cp == '\t')
+ b += INDENT;
+ else
+ break;
+ cp++;
+ }
+ fp->indent = roundof(b, INDENT);
+ }
+ else
+ while (cp < lp && (*cp == ' ' || *cp == '\t'))
+ cp++;
+ if (!isoption(fp, 'q') && cp < lp)
+ {
+ setoption(fp, 'q');
+ if (*cp == '"')
+ {
+ ep = lp;
+ while (--ep > cp)
+ if (*ep == '"')
+ {
+ fp->quote = 1;
+ break;
+ }
+ else if (*ep != ' ' && *ep != '\t')
+ break;
+ }
+ }
+ }
+ again:
+ dp = buf;
+ ep = 0;
+ for (b = 1;; b = 0)
+ {
+ if (cp >= lp)
+ {
+ cp = 0;
+ break;
+ }
+ c = *cp++;
+ if (isoption(fp, 'o'))
+ {
+ if (c == '\\')
+ {
+ x = 0;
+ c = ' ';
+ cp--;
+ while (cp < lp)
+ {
+ if (*cp == '\\')
+ {
+ cp++;
+ if ((lp - cp) < 1)
+ {
+ c = '\\';
+ break;
+ }
+ if (*cp == 'n')
+ {
+ cp++;
+ c = '\n';
+ if ((lp - cp) > 2)
+ {
+ if (*cp == ']' || *cp == '@' && *(cp + 1) == '(')
+ {
+ *dp++ = '\\';
+ *dp++ = 'n';
+ c = *cp++;
+ break;
+ }
+ if (*cp == '\\' && *(cp + 1) == 'n')
+ {
+ cp += 2;
+ *dp++ = '\n';
+ break;
+ }
+ }
+ }
+ else if (*cp == 't' || *cp == ' ')
+ {
+ cp++;
+ x = 1;
+ c = ' ';
+ }
+ else
+ {
+ if (x && dp != buf && *(dp - 1) != ' ')
+ *dp++ = ' ';
+ *dp++ = '\\';
+ c = *cp++;
+ break;
+ }
+ }
+ else if (*cp == ' ' || *cp == '\t')
+ {
+ cp++;
+ c = ' ';
+ x = 1;
+ }
+ else
+ {
+ if (x && c != '\n' && dp != buf && *(dp - 1) != ' ')
+ *dp++ = ' ';
+ break;
+ }
+ }
+ if (c == '\n')
+ {
+ c = 0;
+ goto flush;
+ }
+ if (c == ' ' && (dp == buf || *(dp - 1) == ' '))
+ continue;
+ }
+ else if (c == '"')
+ {
+ if (b || cp >= lp)
+ {
+ if (fp->quote)
+ continue;
+ fp->section = 0;
+ }
+ }
+ else if (c == '\a')
+ {
+ *dp++ = '\\';
+ c = 'a';
+ }
+ else if (c == '\b')
+ {
+ *dp++ = '\\';
+ c = 'b';
+ }
+ else if (c == '\f')
+ {
+ *dp++ = '\\';
+ c = 'f';
+ }
+ else if (c == '\v')
+ {
+ *dp++ = '\\';
+ c = 'v';
+ }
+ else if (c == ']' && (cp >= lp || *cp != ':' && *cp != '#' && *cp != '!'))
+ {
+ if (cp < lp && *cp == ']')
+ {
+ cp++;
+ *dp++ = c;
+ }
+ else
+ {
+ fp->section = 1;
+ fp->retain = 0;
+ flush:
+ *dp++ = c;
+ *dp = 0;
+ split(fp, buf, 0);
+ outline(fp);
+ goto again;
+ }
+ }
+ else if (fp->section)
+ {
+ if (c == '[')
+ {
+ if (b)
+ fp->retain = 1;
+ else
+ {
+ cp--;
+ c = 0;
+ goto flush;
+ }
+ fp->section = 0;
+ }
+ else if (c == '{')
+ {
+ x = 1;
+ for (tp = cp; tp < lp; tp++)
+ {
+ if (*tp == '[' || *tp == '\n')
+ break;
+ if (*tp == ' ' || *tp == '\t' || *tp == '"')
+ continue;
+ if (*tp == '\\' && (lp - tp) > 1)
+ {
+ if (*++tp == 'n')
+ break;
+ if (*tp == 't' || *tp == '\n')
+ continue;
+ }
+ x = 0;
+ break;
+ }
+ if (x)
+ {
+ if (fp->endbuf > (fp->outbuf + fp->indent + 2*INDENT))
+ fp->nextdent = 2*INDENT;
+ goto flush;
+ }
+ else
+ fp->section = 0;
+ }
+ else if (c == '}')
+ {
+ if (fp->indent && (b || *(cp - 2) != 'f'))
+ {
+ if (b)
+ {
+ fp->indent -= 2*INDENT;
+ fp->endbuf += 2*INDENT;
+ }
+ else
+ {
+ cp--;
+ c = 0;
+ }
+ goto flush;
+ }
+ else
+ fp->section = 0;
+ }
+ else if (c == ' ' || c == '\t')
+ continue;
+ else
+ fp->section = 0;
+ }
+ else if (c == '?' && (cp >= lp || *cp != '?'))
+ {
+ if (fp->retain)
+ {
+ cp--;
+ while (cp < lp && *cp != ' ' && *cp != '\t' && *cp != ']' && dp < &buf[sizeof(buf)-3])
+ *dp++ = *cp++;
+ if (cp < lp && (*cp == ' ' || *cp == '\t'))
+ *dp++ = *cp++;
+ *dp = 0;
+ split(fp, buf, 0);
+ dp = buf;
+ ep = 0;
+ fp->retain = 0;
+ if (fp->outp >= fp->endbuf)
+ outline(fp);
+ continue;
+ }
+ }
+ else if (c == ' ' || c == '\t')
+ for (c = ' '; *cp == ' ' || *cp == '\t'; cp++);
+ }
+ else if (c == '\b')
+ {
+ if (dp > buf)
+ {
+ dp--;
+ if (ep)
+ ep--;
+ }
+ continue;
+ }
+ else if (c == '\t')
+ {
+ /*
+ * expand tabs
+ */
+
+ if (!ep)
+ ep = dp;
+ c = isoption(fp, 'o') ? 1 : TABSZ - (dp - buf) % TABSZ;
+ if (dp >= &buf[sizeof(buf) - c - 3])
+ {
+ cp--;
+ break;
+ }
+ while (c-- > 0)
+ *dp++ = ' ';
+ continue;
+ }
+ else if (!isprint(c))
+ continue;
+ if (dp >= &buf[sizeof(buf) - 3])
+ {
+ tp = dp;
+ while (--tp > buf)
+ if (isspace(*tp))
+ {
+ cp -= dp - tp;
+ dp = tp;
+ break;
+ }
+ ep = 0;
+ break;
+ }
+ if (c != ' ')
+ ep = 0;
+ else if (!ep)
+ ep = dp;
+ *dp++ = c;
+ }
+ if (ep)
+ *ep = 0;
+ else
+ *dp = 0;
+ split(fp, buf, splice);
+ }
+ return 0;
+}
+
+int
+b_fmt(int argc, char** argv, void *context)
+{
+ register int n;
+ char* cp;
+ Fmt_t fmt;
+ char outbuf[8 * 1024];
+
+ fmt.flags = 0;
+ fmt.out = sfstdout;
+ fmt.outbuf = outbuf;
+ fmt.outp = 0;
+ fmt.endbuf = &outbuf[72];
+ fmt.indent = 0;
+ fmt.nextdent = 0;
+ fmt.nwords = 0;
+ fmt.prefix = 0;
+ fmt.quote = 0;
+ fmt.retain = 0;
+ fmt.section = 1;
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ while (n = optget(argv, usage))
+ switch (n)
+ {
+ case 'c':
+ case 'o':
+ case 's':
+ case 'u':
+ setoption(&fmt, n);
+ break;
+ case 'w':
+ if (opt_info.num < TABSZ || opt_info.num>= sizeof(outbuf))
+ error(2, "width out of range");
+ fmt.endbuf = &outbuf[opt_info.num];
+ break;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ if (error_info.errors)
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ if (isoption(&fmt, 'o'))
+ setoption(&fmt, 'c');
+ if (isoption(&fmt, 's'))
+ clroption(&fmt, 'u');
+ if (cp = *argv)
+ argv++;
+ do {
+ if (!cp || streq(cp, "-"))
+ fmt.in = sfstdin;
+ else if (!(fmt.in = sfopen(NiL, cp, "r")))
+ {
+ error(ERROR_system(0), "%s: cannot open", cp);
+ error_info.errors = 1;
+ continue;
+ }
+ dofmt(&fmt);
+ if (fmt.in != sfstdin)
+ sfclose(fmt.in);
+ } while (cp = *argv++);
+ outline(&fmt);
+ if (sfsync(sfstdout))
+ error(ERROR_system(0), "write error");
+ return error_info.errors != 0;
+}
diff --git a/usr/src/lib/libcmd/common/fold.c b/usr/src/lib/libcmd/common/fold.c
new file mode 100644
index 0000000000..459ad35850
--- /dev/null
+++ b/usr/src/lib/libcmd/common/fold.c
@@ -0,0 +1,242 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Bell Laboratories
+ *
+ * fold
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: fold (AT&T Research) 2004-11-18 $\n]"
+USAGE_LICENSE
+"[+NAME?fold - fold lines]"
+"[+DESCRIPTION?\bfold\b is a filter that folds lines from its input, "
+ "breaking the lines to have a maximum of \awidth\a column "
+ "positions (or bytes if the \b-b\b option is specified). Lines "
+ "are broken by the insertion of a newline character such that "
+ "each output line is the maximum width possible that does not "
+ "exceed the specified number of column positions, (or bytes). A line "
+ "will not be broken in the middle of a character.] "
+"[+?Unless the \b-b\b option is specified, the following will be treated "
+ "specially:]{"
+ "[+carriage-return?The current count of line width will be set "
+ "to zero. \bfold\b will not insert a newline immediately "
+ "before or after a carriage-return.]"
+ "[+backspace?If positive, the current count of line width will be "
+ "decremented by one. \bfold\b will not insert a newline "
+ "immediately before or after a backspace.]"
+ "[+tab?Each tab character encountered will advance the column "
+ "position to the next tab stop. Tab stops are at each "
+ "column position \an\a, where \an\a modulo 8 equals 1.]"
+ "}"
+"[+?If no \afile\a is given, or if the \afile\a is \b-\b, \bfold\b "
+ "reads from standard input. The start of the file is defined "
+ "as the current offset.]"
+
+"[b:bytes?Count bytes rather than columns so that each carriage-return, "
+ "backspace, and tab counts as 1.]"
+"[c:continue?Emit \atext\a at line splits.]:[text:='\\n']"
+"[d:delimiter?Break at \adelim\a boundaries.]:[delim]"
+"[s:spaces?Break at word boundaries. If the line contains any blanks, "
+ "(spaces or tabs), within the first \awidth\a column positions or "
+ "bytes, the line is broken after the last blank meeting the "
+ "\awidth\a constraint.]"
+"[w:width]#[width:=80?Use a maximum line length of \awidth\a columns "
+ "instead of the default.]"
+"\n"
+"\n[file ...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?All files processed successfully.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bpaste\b(1)]"
+;
+
+
+#include <cmd.h>
+
+#define WIDTH 80
+#define TABSIZE 8
+
+#define T_EOF 1
+#define T_NL 2
+#define T_BS 3
+#define T_TAB 4
+#define T_SP 5
+#define T_RET 6
+
+static void fold(Sfio_t *in, Sfio_t *out, register int width, const char *cont, size_t contsize, char *cols)
+{
+ register char *cp, *first;
+ register int n, col=0, x=0;
+ register char *last_space=0;
+ cols[0] = 0;
+ for (;;)
+ {
+ if (!(cp = sfgetr(in,'\n',0)))
+ {
+ if (!(cp = sfgetr(in,'\n',-1)) || (n = sfvalue(in)) <= 0)
+ break;
+ x = cp[--n];
+ cp[n] = '\n';
+ }
+ /* special case -b since no column adjustment is needed */
+ if(cols['\b']==0 && (n=sfvalue(in))<=width)
+ {
+ sfwrite(out,cp,n);
+ continue;
+ }
+ first = cp;
+ col = 0;
+ last_space = 0;
+ for(;;)
+ {
+ while((n=cols[*(unsigned char*)cp++])==0);
+ while((cp-first) > (width-col))
+ {
+ if(last_space)
+ col = last_space - first;
+ else
+ col = width-col;
+ sfwrite(out,first,col);
+ first += col;
+ col = 0;
+ last_space = 0;
+ if(cp>first+1 || (n!=T_NL && n!=T_BS))
+ sfwrite(out, cont, contsize);
+ }
+ switch(n)
+ {
+ case T_NL:
+ if(x)
+ *(cp-1) = x;
+ break;
+ case T_RET:
+ col = 0;
+ continue;
+ case T_BS:
+ if((cp+(--col)-first)>0)
+ col--;
+ continue;
+ case T_TAB:
+ n = (TABSIZE-1) - (cp+col-1-first)&(TABSIZE-1);
+ col +=n;
+ if((cp-first) > (width-col))
+ {
+ sfwrite(out,first,(--cp)-first);
+ sfwrite(out, cont, contsize);
+ first = cp;
+ col = TABSIZE-1;
+ last_space = 0;
+ continue;
+ }
+ if(cols[' '])
+ last_space = cp;
+ continue;
+ case T_SP:
+ last_space = cp;
+ continue;
+ default:
+ continue;
+ }
+ break;
+ }
+ sfwrite(out,first,cp-first);
+ }
+}
+
+int
+b_fold(int argc, char *argv[], void* context)
+{
+ register int n, width=WIDTH;
+ register Sfio_t *fp;
+ register char *cp;
+ char *cont="\n";
+ size_t contsize = 1;
+ char cols[1<<CHAR_BIT];
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ memset(cols, 0, sizeof(cols));
+ cols['\t'] = T_TAB;
+ cols['\b'] = T_BS;
+ cols['\n'] = T_NL;
+ cols['\r'] = T_RET;
+ for (;;)
+ {
+ switch (optget(argv, usage))
+ {
+ case 0:
+ break;
+ case 'b':
+ cols['\r'] = cols['\b'] = 0;
+ cols['\t'] = cols[' '];
+ continue;
+ case 'c':
+ contsize = stresc(cont = strdup(opt_info.arg));
+ continue;
+ case 'd':
+ if (n = *opt_info.arg)
+ cols[n] = T_SP;
+ continue;
+ case 's':
+ cols[' '] = T_SP;
+ if(cols['\t']==0)
+ cols['\t'] = T_SP;
+ continue;
+ case 'w':
+ if ((width = opt_info.num) <= 0)
+ error(2, "%d: width must be positive", opt_info.num);
+ continue;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ continue;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ continue;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ argc -= opt_info.index;
+ if(error_info.errors)
+ error(ERROR_usage(2),"%s", optusage(NiL));
+ if(cp = *argv)
+ argv++;
+ do
+ {
+ if(!cp || streq(cp,"-"))
+ fp = sfstdin;
+ else if(!(fp = sfopen(NiL,cp,"r")))
+ {
+ error(ERROR_system(0),"%s: cannot open",cp);
+ error_info.errors = 1;
+ continue;
+ }
+ fold(fp,sfstdout,width,cont,contsize,cols);
+ if(fp!=sfstdin)
+ sfclose(fp);
+ }
+ while(cp= *argv++);
+ return(error_info.errors);
+}
diff --git a/usr/src/lib/libcmd/common/getconf.c b/usr/src/lib/libcmd/common/getconf.c
new file mode 100644
index 0000000000..d30d002c0b
--- /dev/null
+++ b/usr/src/lib/libcmd/common/getconf.c
@@ -0,0 +1,393 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * getconf - get configuration values
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: getconf (AT&T Research) 2007-02-07 $\n]"
+USAGE_LICENSE
+"[+NAME?getconf - get configuration values]"
+"[+DESCRIPTION?\bgetconf\b displays the system configuration value for"
+" \aname\a. If \aname\a is a filesystem specific variable then"
+" the value is determined relative to \apath\a or the current"
+" directory if \apath\a is omitted. If \avalue\a is specified then"
+" \bgetconf\b attempts to change the process local value to \avalue\a."
+" \b-\b may be used in place of \apath\a when it is not relevant."
+" Only \bwritable\b variables may be set; \breadonly\b variables"
+" cannot be changed.]"
+"[+?The current value for \aname\a is written to the standard output. If"
+" \aname\a is valid but undefined then \bundefined\b is written to"
+" the standard output. If \aname\a is invalid or an error occurs in"
+" determining its value, then a diagnostic written to the standard error"
+" and \bgetconf\b exits with a non-zero exit status.]"
+"[+?More than one variable may be set or queried by providing the \aname\a"
+" \apath\a \avalue\a 3-tuple for each variable, specifying \b-\b for"
+" \avalue\a when querying.]"
+"[+?If no operands are specified then all known variables are written in"
+" \aname\a=\avalue\a form to the standard output, one per line."
+" Only one of \b--call\b, \b--name\b or \b--standard\b may be specified.]"
+"[+?This implementation uses the \bastgetconf\b(3) string interface to the native"
+" \bsysconf\b(2), \bconfstr\b(2), \bpathconf\b(2), and \bsysinfo\b(2)"
+" system calls. If \bgetconf\b on \b$PATH\b is not the default native"
+" \bgetconf\b, named by \b$(getconf GETCONF)\b, then \bastgetconf\b(3)"
+" checks only \bast\b specific extensions and the native system calls;"
+" invalid options and/or names not supported by \bastgetconf\b(3) cause"
+" the \bgetconf\b on \b$PATH\b to be executed.]"
+
+"[a:all?Call the native \bgetconf\b(1) with option \b-a\b.]"
+"[b:base?List base variable name sans call and standard prefixes.]"
+"[c:call?Display variables with call prefix that matches \aRE\a. The call"
+" prefixes are:]:[RE]{"
+" [+CS?\bconfstr\b(2)]"
+" [+PC?\bpathconf\b(2)]"
+" [+SC?\bsysconf\b(2)]"
+" [+SI?\bsysinfo\b(2)]"
+" [+XX?Constant value.]"
+"}"
+"[d:defined?Only display defined values when no operands are specified.]"
+"[l:lowercase?List variable names in lower case.]"
+"[n:name?Display variables with name that match \aRE\a.]:[RE]"
+"[p:portable?Display the named \bwritable\b variables and values in a form that"
+" can be directly executed by \bsh\b(1) to set the values. If \aname\a"
+" is omitted then all \bwritable\b variables are listed.]"
+"[q:quote?\"...\" quote values.]"
+"[r:readonly?Display the named \breadonly\b variables in \aname\a=\avalue\a form."
+" If \aname\a is omitted then all \breadonly\b variables are listed.]"
+"[s:standard?Display variables with standard prefix that matches \aRE\a."
+" Use the \b--table\b option to view all standard prefixes, including"
+" local additions. The standard prefixes available on all systems"
+" are:]:[RE]{"
+" [+AES]"
+" [+AST]"
+" [+C]"
+" [+GNU]"
+" [+POSIX]"
+" [+SVID]"
+" [+XBS5]"
+" [+XOPEN]"
+" [+XPG]"
+"}"
+"[t:table?Display the internal table that contains the name, standard,"
+" standard section, and system call symbol prefix for each variable.]"
+"[w:writable?Display the named \bwritable\b variables in \aname\a=\avalue\a"
+" form. If \aname\a is omitted then all \bwritable\b variables are"
+" listed.]"
+"[v:specification?Call the native \bgetconf\b(1) with option"
+" \b-v\b \aname\a.]:[name]"
+
+"\n"
+"\n[ name [ path [ value ] ] ... ]\n"
+"\n"
+
+"[+ENVIRONMENT]{"
+" [+_AST_FEATURES?Process local writable values that are different from"
+" the default are stored in the \b_AST_FEATURES\b environment"
+" variable. The \b_AST_FEATURES\b value is a space-separated"
+" list of \aname\a \apath\a \avalue\a 3-tuples, where"
+" \aname\a is the system configuration name, \apath\a is the"
+" corresponding path, \b-\b if no path is applicable, and"
+" \avalue\a is the system configuration value.]"
+"}"
+"[+SEE ALSO?\bpathchk\b(1), \bconfstr\b(2), \bpathconf\b(2),"
+" \bsysconf\b(2), \bastgetconf\b(3)]"
+;
+
+#include <cmd.h>
+#include <proc.h>
+#include <ls.h>
+
+typedef struct Path_s
+{
+ char* path;
+ int len;
+} Path_t;
+
+int
+b_getconf(int argc, char** argv, void* context)
+{
+ register char* name;
+ register char* path;
+ register char* value;
+ register char* s;
+ register char* t;
+ char* pattern;
+ char* native;
+ char* cmd;
+ Path_t* e;
+ Path_t* p;
+ int flags;
+ int n;
+ int i;
+ int m;
+ int q;
+ char** oargv;
+ char buf[PATH_MAX];
+ Path_t std[64];
+ struct stat st0;
+ struct stat st1;
+
+ static const char empty[] = "-";
+ static const Path_t equiv[] = { { "/bin", 4 }, { "/usr/bin", 8 } };
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ oargv = argv;
+ if (*(native = astconf("GETCONF", NiL, NiL)) != '/')
+ native = 0;
+ flags = 0;
+ name = 0;
+ pattern = 0;
+ for (;;)
+ {
+ switch (optget(argv, usage))
+ {
+ case 'a':
+ if (native)
+ goto defer;
+ continue;
+ case 'b':
+ flags |= ASTCONF_base;
+ continue;
+ case 'c':
+ flags |= ASTCONF_matchcall;
+ pattern = opt_info.arg;
+ continue;
+ case 'd':
+ flags |= ASTCONF_defined;
+ continue;
+ case 'l':
+ flags |= ASTCONF_lower;
+ continue;
+ case 'n':
+ flags |= ASTCONF_matchname;
+ pattern = opt_info.arg;
+ continue;
+ case 'p':
+ flags |= ASTCONF_parse;
+ continue;
+ case 'q':
+ flags |= ASTCONF_quote;
+ continue;
+ case 'r':
+ flags |= ASTCONF_read;
+ continue;
+ case 's':
+ flags |= ASTCONF_matchstandard;
+ pattern = opt_info.arg;
+ continue;
+ case 't':
+ flags |= ASTCONF_table;
+ continue;
+ case 'v':
+ if (native)
+ goto defer;
+ continue;
+ case 'w':
+ flags |= ASTCONF_write;
+ continue;
+ case ':':
+ if (native)
+ goto defer;
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ if (!(name = *argv))
+ path = 0;
+ else if (streq(name, empty))
+ {
+ name = 0;
+ if (path = *++argv)
+ {
+ argv++;
+ if (streq(path, empty))
+ path = 0;
+ }
+ }
+ if (error_info.errors || !name && *argv)
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ if (!name)
+ astconflist(sfstdout, path, flags, pattern);
+ else
+ {
+ flags = native ? (ASTCONF_system|ASTCONF_error) : 0;
+ do
+ {
+ if (!(path = *++argv))
+ value = 0;
+ else
+ {
+ if (streq(path, empty))
+ {
+ path = 0;
+ flags = 0;
+ }
+ if ((value = *++argv) && (streq(value, empty)))
+ {
+ value = 0;
+ flags = 0;
+ }
+ }
+ s = astgetconf(name, path, value, flags, errorf);
+ if (error_info.errors)
+ break;
+ if (!s)
+ goto defer;
+ if (!value)
+ {
+ if (flags & ASTCONF_write)
+ {
+ sfputr(sfstdout, name, ' ');
+ sfputr(sfstdout, path ? path : empty, ' ');
+ }
+ sfputr(sfstdout, s, '\n');
+ }
+ } while (*argv && (name = *++argv));
+ }
+ return error_info.errors != 0;
+
+ defer:
+
+ /*
+ * defer to argv[0] if absolute and it exists
+ */
+
+ if ((cmd = oargv[0]) && *cmd == '/' && !access(cmd, X_OK))
+ goto found;
+
+ /*
+ * defer to the first getconf on $PATH that is also on the standard PATH
+ */
+
+ e = std;
+ s = astconf("PATH", NiL, NiL);
+ q = !stat(equiv[0].path, &st0) && !stat(equiv[1].path, &st1) && st0.st_ino == st1.st_ino && st0.st_dev == st1.st_dev;
+ m = 0;
+ do
+ {
+ for (t = s; *s && *s != ':'; s++);
+ if ((n = s - t) && *t == '/')
+ {
+ if (q)
+ for (i = 0; i < 2; i++)
+ if (n == equiv[i].len && !strncmp(t, equiv[i].path, n))
+ {
+ if (m & (i+1))
+ t = 0;
+ else
+ {
+ m |= (i+1);
+ if (!(m & (!i+1)))
+ {
+ m |= (!i+1);
+ e->path = t;
+ e->len = n;
+ e++;
+ if (e >= &std[elementsof(std)])
+ break;
+ t = equiv[!i].path;
+ n = equiv[!i].len;
+ }
+ }
+ }
+ if (t)
+ {
+ e->path = t;
+ e->len = n;
+ e++;
+ }
+ }
+ while (*s == ':')
+ s++;
+ } while (*s && e < &std[elementsof(std)]);
+ if (e < &std[elementsof(std)])
+ {
+ e->len = strlen(e->path = "/usr/sbin");
+ if (++e < &std[elementsof(std)])
+ {
+ e->len = strlen(e->path = "/sbin");
+ e++;
+ }
+ }
+ if (s = getenv("PATH"))
+ do
+ {
+ for (t = s; *s && *s != ':'; s++);
+ if ((n = s - t) && *t == '/')
+ {
+ for (p = std; p < e; p++)
+ if (p->len == n && !strncmp(t, p->path, n))
+ {
+ sfsprintf(buf, sizeof(buf), "%-*.*s/%s", n, n, t, error_info.id);
+ if (!access(buf, X_OK))
+ {
+ cmd = buf;
+ goto found;
+ }
+ }
+ }
+ while (*s == ':')
+ s++;
+ } while (*s);
+
+ /*
+ * defer to the first getconf on the standard PATH
+ */
+
+ for (p = std; p < e; p++)
+ {
+ sfsprintf(buf, sizeof(buf), "%-*.*s/%s", p->len, p->len, p->path, error_info.id);
+ if (!access(buf, X_OK))
+ {
+ cmd = buf;
+ goto found;
+ }
+ }
+
+ /*
+ * out of deferrals
+ */
+
+ if (name)
+ error(4, "%s: unknown name -- no native getconf(1) to defer to", name);
+ else
+ error(4, "no native getconf(1) to defer to");
+ return 2;
+
+ found:
+
+ /*
+ * don't blame us for crappy diagnostics
+ */
+
+ if ((n = procrun(cmd, oargv)) >= EXIT_NOEXEC)
+ error(ERROR_SYSTEM|2, "%s: exec error [%d]", cmd, n);
+ return n;
+}
diff --git a/usr/src/lib/libcmd/common/head.c b/usr/src/lib/libcmd/common/head.c
new file mode 100644
index 0000000000..707d0478a8
--- /dev/null
+++ b/usr/src/lib/libcmd/common/head.c
@@ -0,0 +1,150 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Bell Laboratories
+ *
+ * output the beginning portion of one or more files
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: head (AT&T Research) 2006-09-27 $\n]"
+USAGE_LICENSE
+"[+NAME?head - output beginning portion of one or more files ]"
+"[+DESCRIPTION?\bhead\b copies one or more input files to standard "
+ "output stopping at a designated point for each file or to the end of "
+ "the file whichever comes first. Copying ends at the point indicated by "
+ "the options. By default a header of the form \b==> \b\afilename\a\b "
+ "<==\b is output before all but the first file but this can be changed "
+ "with the \b-q\b and \b-v\b options.]"
+"[+?If no \afile\a is given, or if the \afile\a is \b-\b, \bhead\b "
+ "copies from standard input starting at the current location.]"
+"[+?The option argument for \b-c\b, and \b-s\b can optionally be "
+ "followed by one of the following characters to specify a different unit "
+ "other than a single byte:]"
+ "{"
+ "[+b?512 bytes.]"
+ "[+k?1-killobyte.]"
+ "[+m?1-megabyte.]"
+ "}"
+"[+?For backwards compatibility, \b-\b\anumber\a is equivalent to \b-n\b "
+ "\anumber\a.]"
+"[n:lines?Copy \alines\a lines from each file.]#[lines:=10]"
+"[c:bytes?Copy \achars\a bytes from each file.]#[chars]"
+"[q:quiet|silent?Never ouput filename headers.]"
+"[s:skip?Skip \askip\a characters or lines from each file before "
+ "copying.]#[skip]"
+"[v:verbose?Always ouput filename headers.]"
+ "\n\n"
+"[ file ... ]"
+ "\n\n"
+"[+EXIT STATUS?]"
+ "{"
+ "[+0?All files copied successfully.]"
+ "[+>0?One or more files did not copy.]"
+ "}"
+"[+SEE ALSO?\bcat\b(1), \btail\b(1)]"
+;
+
+#include <cmd.h>
+
+int
+b_head(int argc, register char** argv, void* context)
+{
+ static const char header_fmt[] = "\n==> %s <==\n";
+
+ register Sfio_t* fp;
+ register char* cp;
+ register off_t keep = 10;
+ register off_t skip = 0;
+ register int delim = '\n';
+ int header = 1;
+ char* format = (char*)header_fmt+1;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ for (;;)
+ {
+ switch (optget(argv, usage))
+ {
+ case 'c':
+ delim = -1;
+ /*FALLTHROUGH*/
+ case 'n':
+ if (opt_info.offset && argv[opt_info.index][opt_info.offset] == 'c')
+ {
+ delim = -1;
+ opt_info.offset++;
+ }
+ if ((keep = opt_info.number) <=0)
+ error(2, "%s: %I*d: positive numeric option argument expected", opt_info.name, sizeof(keep), keep);
+ continue;
+ case 'q':
+ header = argc;
+ continue;
+ case 'v':
+ header = 0;
+ continue;
+ case 's':
+ skip = opt_info.number;
+ continue;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ continue;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ continue;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ argc -= opt_info.index;
+ if (error_info.errors)
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ if (cp = *argv)
+ argv++;
+ do
+ {
+ if (!cp || streq(cp, "-"))
+ {
+ cp = "/dev/stdin";
+ fp = sfstdin;
+ sfset(fp, SF_SHARE, 1);
+ }
+ else if (!(fp = sfopen(NiL, cp, "r")))
+ {
+ error(ERROR_system(0), "%s: cannot open", cp);
+ continue;
+ }
+ if (argc > header)
+ sfprintf(sfstdout, format, cp);
+ format = (char*)header_fmt;
+ if (skip > 0)
+ sfmove(fp, NiL, skip, delim);
+ if (sfmove(fp, sfstdout, keep, delim) < 0 && errno != EPIPE)
+ error(ERROR_system(0), "%s: read error", cp);
+ if (fp != sfstdin)
+ sfclose(fp);
+ } while (cp = *argv++);
+ if (sfsync(sfstdout))
+ error(ERROR_system(0), "write error");
+ return error_info.errors != 0;
+}
diff --git a/usr/src/lib/libcmd/common/id.c b/usr/src/lib/libcmd/common/id.c
new file mode 100644
index 0000000000..b880659ad5
--- /dev/null
+++ b/usr/src/lib/libcmd/common/id.c
@@ -0,0 +1,468 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * id
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: id (AT&T Research) 2004-06-11 $\n]"
+USAGE_LICENSE
+"[+NAME?id - return user identity]"
+"[+DESCRIPTION?If no \auser\a operand is specified \bid\b writes user and "
+ "group IDs and the corresponding user and group names of the "
+ "invoking process to standard output. If the effective and "
+ "real IDs do not match, both are written. Any supplementary "
+ "groups the current process belongs to will also be written.]"
+"[+?If a \auser\a operand is specified and the process has permission, "
+ "the user and group IDs and any supplementary group IDs of the "
+ "selected user will be written to standard output.]"
+"[+?If any options are specified, then only a portion of the information "
+ "is written.]"
+"[n:name?Write the name instead of the numeric ID.]"
+"[r:real?Writes real ID instead of the effective ID.]"
+"[[a?This option is ignored.]"
+"[g:group?Writes only the group ID.]"
+"[u:user?Writes only the user ID.]"
+"[G:groups?Writes only the supplementary group IDs.]"
+"[s:fair-share?Writes fair share scheduler IDs and groups on systems that "
+ "support fair share scheduling.]"
+"\n"
+"\n[user]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Successful completion.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\blogname\b(1), \bwho\b(1), \bgetgroups\b(2)]"
+;
+
+#include <cmd.h>
+
+#include "FEATURE/ids"
+
+#include <grp.h>
+#include <pwd.h>
+
+#if _lib_fsid
+#if _lib_getfsgid && ( _sys_fss || _hdr_fsg )
+#define fss_grp fs_grp
+#define fss_id fs_id
+#define fss_mem fs_mem
+#define fss_passwd fs_passwd
+#define fss_shares fs_shares
+#if _sys_fss
+#include <sys/fss.h>
+#endif
+#if _hdr_fsg
+#include <fsg.h>
+#endif
+#if !_lib_isfsg && !defined(isfsg)
+#define isfsg(p) (!(p)->fs_id&&!(p)->fs_shares&&(!(p)->fs_passwd||!*(p)->fs_passwd))
+#endif
+#else
+#undef _lib_fsid
+#endif
+#endif
+
+#define power2(n) (!((n)&((n)-1)))
+
+#define GG_FLAG (1<<0)
+#define G_FLAG (1<<1)
+#define N_FLAG (1<<2)
+#define R_FLAG (1<<3)
+#define U_FLAG (1<<4)
+#define S_FLAG (1<<5)
+#define O_FLAG (1<<6)
+#define X_FLAG (1<<7)
+
+#if _lib_fsid
+static void
+getfsids(Sfio_t* sp, const char* name, int flags, register int lastchar)
+{
+ register struct fsg* fs;
+ register char* s;
+ register char** p;
+ char** x;
+
+ if (lastchar)
+ {
+ if (flags & O_FLAG) flags = 1;
+ else flags = 0;
+ }
+ else if (flags & N_FLAG) flags = 1;
+ else flags = -1;
+ setfsgent();
+ while (fs = getfsgnam(name))
+ if (!isfsg(fs))
+ {
+ if (p = fs->fs_mem)
+ {
+ if (flags > 0) x = 0;
+ else
+ {
+ register char** q;
+ register char* t;
+ register int n;
+
+ n = 0;
+ q = p;
+ while (s = *q++)
+ n += strlen(s) + 1;
+ if (!(x = newof(0, char*, q - p, n)))
+ break;
+ s = (char*)(x + (q - p));
+ q = x;
+ while (t = *p++)
+ {
+ *q++ = s;
+ while (*s++ = *t++);
+ }
+ *q = 0;
+ p = x;
+ }
+ while (s = *p++)
+ {
+ if (lastchar == '=')
+ {
+ lastchar = ',';
+ sfputr(sp, " fsid=", -1);
+ }
+ else if (!lastchar) lastchar = ' ';
+ else sfputc(sp, lastchar);
+ if (flags > 0) sfprintf(sp, "%s", s);
+ else
+ {
+ setfsgent();
+ while (fs = getfsgnam(s))
+ if (isfsg(fs))
+ {
+ if (flags < 0) sfprintf(sp, "%u", fs->fs_id);
+ else sfprintf(sp, "%u(%s)", fs->fs_id, s);
+ break;
+ }
+ }
+ }
+ if (x) free(x);
+ }
+ break;
+ }
+ endfsgent();
+ if (lastchar == ' ') sfputc(sp, '\n');
+}
+#endif
+
+static void
+putid(Sfio_t* sp, int flags, const char* label, const char* name, long number)
+{
+ sfprintf(sp, "%s=", label);
+ if (flags & O_FLAG)
+ {
+ if (name) sfputr(sp, name, -1);
+ else sfprintf(sp, "%lu", number);
+ }
+ else
+ {
+ sfprintf(sp, "%u", number);
+ if (name) sfprintf(sp, "(%s)", name);
+ }
+}
+
+static int
+getids(Sfio_t* sp, const char* name, register int flags)
+{
+ register struct passwd* pw;
+ register struct group* grp;
+ register int i;
+ register int j;
+ register int k;
+#if _lib_fsid
+ register struct fsg* fs;
+ const char* fs_name;
+ int fs_id;
+#endif
+ char** p;
+ char* s;
+ int lastchar;
+ int ngroups = 0;
+ const char* gname;
+ uid_t user;
+ uid_t euid;
+ gid_t group;
+ gid_t egid;
+
+ static gid_t* groups;
+
+ if (flags & GG_FLAG)
+ {
+ static int maxgroups;
+
+ /*
+ * get supplemental groups if required
+ */
+
+ if (!maxgroups)
+ {
+ /*
+ * first time
+ */
+
+ if ((maxgroups = getgroups(0, groups)) <= 0)
+ maxgroups = NGROUPS_MAX;
+ if (!(groups = newof(0, gid_t, maxgroups + 1, 0)))
+ error(ERROR_exit(1), "out of space [group array]");
+ }
+ ngroups = getgroups(maxgroups, groups);
+ for (i = j = 0; i < ngroups; i++)
+ {
+ for (k = 0; k < j && groups[k] != groups[i]; k++);
+ if (k >= j) groups[j++] = groups[i];
+ }
+ ngroups = j;
+ }
+ if (name)
+ {
+ flags |= X_FLAG;
+ if (!(flags & N_FLAG) || (flags & (G_FLAG|GG_FLAG)))
+ {
+ if (!(pw = getpwnam(name)))
+ {
+ user = strtol(name, &s, 0);
+ if (*s || !(pw = getpwuid(user)))
+ error(ERROR_exit(1), "%s: name not found", name);
+ name = pw->pw_name;
+ }
+ user = pw->pw_uid;
+ group = pw->pw_gid;
+ }
+#if _lib_fsid
+ if (!(flags & N_FLAG) || (flags & S_FLAG))
+ {
+ setfsgent();
+ do
+ {
+ if (!(fs = getfsgnam(name)))
+ error(ERROR_exit(1), "%u: fss name not found", name);
+ } while (isfsg(fs));
+ fs_id = fs->fs_id;
+ }
+#endif
+ }
+ else
+ {
+ if (flags & G_FLAG)
+ group = (flags & R_FLAG) ? getgid() : getegid();
+ if (flags & (GG_FLAG|N_FLAG|U_FLAG))
+ user = (flags & R_FLAG) ? getuid() : geteuid();
+#if _lib_fsid
+ if (flags & S_FLAG)
+ fs_id = fsid(0);
+#endif
+ if (flags & N_FLAG)
+ name = (pw = getpwuid(user)) ? pw->pw_name : (char*)0;
+ }
+ if (ngroups == 1 && groups[0] == group)
+ ngroups = 0;
+ if ((flags & N_FLAG) && (flags & G_FLAG))
+ gname = (grp = getgrgid(group)) ? grp->gr_name : (char*)0;
+#if _lib_fsid
+ if ((flags & N_FLAG) && (flags & S_FLAG))
+ {
+ setfsgent();
+ fs_name = (fs = getfsgid(fs_id)) ? fs->fs_grp : (char*)0;
+ }
+#endif
+ if ((flags & (U_FLAG|G_FLAG|S_FLAG)) == (U_FLAG|G_FLAG|S_FLAG))
+ {
+ putid(sp, flags, "uid", name, user);
+ putid(sp, flags, " gid", gname, group);
+ if ((flags & X_FLAG) && name)
+ {
+#if _lib_getgrent
+#if _lib_setgrent
+ setgrent();
+#endif
+ lastchar = '=';
+ while (grp = getgrent())
+ if (p = grp->gr_mem)
+ while (s = *p++)
+ if (streq(s, name))
+ {
+ if (lastchar == '=')
+ sfputr(sp, " groups", -1);
+ sfputc(sp, lastchar);
+ lastchar = ',';
+ if (flags & O_FLAG)
+ sfprintf(sp, "%s", grp->gr_name);
+ else sfprintf(sp, "%u(%s)", grp->gr_gid, grp->gr_name);
+ }
+#if _lib_endgrent
+ endgrent();
+#endif
+#endif
+#if _lib_fsid
+ getfsids(sp, name, flags, '=');
+#endif
+ }
+ else
+ {
+ if ((euid = geteuid()) != user)
+ putid(sp, flags, " euid", (pw = getpwuid(euid)) ? pw->pw_name : (char*)0, euid);
+ if ((egid = getegid()) != group)
+ putid(sp, flags, " egid", (grp = getgrgid(egid)) ? grp->gr_name : (char*)0, egid);
+ if (ngroups > 0)
+ {
+ sfputr(sp, " groups", -1);
+ lastchar = '=';
+ for (i = 0; i < ngroups; i++)
+ {
+ group = groups[i];
+ sfputc(sp, lastchar);
+ if (grp = getgrgid(group))
+ {
+ if (flags & O_FLAG) sfprintf(sp, "%s", grp->gr_name);
+ else sfprintf(sp, "%u(%s)", group, grp->gr_name);
+ }
+ else sfprintf(sp, "%u", group);
+ lastchar = ',';
+ }
+ }
+#if _lib_fsid
+ putid(sp, flags, " fsid", fs_name, fs_id);
+#endif
+ }
+ sfputc(sp,'\n');
+ return(0);
+ }
+ if (flags & U_FLAG)
+ {
+ if ((flags & N_FLAG) && name) sfputr(sp, name, '\n');
+ else sfprintf(sp, "%u\n", user);
+ }
+ else if (flags & G_FLAG)
+ {
+ if ((flags & N_FLAG) && gname) sfputr(sp, gname, '\n');
+ else sfprintf(sp, "%u\n", group);
+ }
+ else if (flags & GG_FLAG)
+ {
+ if ((flags & X_FLAG) && name)
+ {
+#if _lib_getgrent
+#if _lib_setgrent
+ setgrent();
+#endif
+ i = 0;
+ while (grp = getgrent())
+ if (p = grp->gr_mem)
+ while (s = *p++)
+ if (streq(s, name))
+ {
+ if (i++) sfputc(sp, ' ');
+ if (flags & N_FLAG) sfprintf(sp, "%s", grp->gr_name);
+ else sfprintf(sp, "%u", grp->gr_gid);
+ }
+#if _lib_endgrent
+ endgrent();
+#endif
+ if (i) sfputc(sp, '\n');
+#endif
+ }
+ else if (ngroups > 0)
+ {
+ for (i = 0;;)
+ {
+ group = groups[i];
+ if ((flags & N_FLAG) && (grp = getgrgid(group)))
+ sfprintf(sp, "%s", grp->gr_name);
+ else sfprintf(sp, "%u", group);
+ if (++i >= ngroups) break;
+ sfputc(sp, ' ');
+ }
+ sfputc(sp, '\n');
+ }
+ }
+#if _lib_fsid
+ else if (flags & S_FLAG)
+ {
+ if ((flags & X_FLAG) && name) getfsids(sp, name, flags, 0);
+ else if ((flags & N_FLAG) && fs_name) sfputr(sp, fs_name, '\n');
+ else sfprintf(sp, "%u\n", fs_id);
+ }
+#endif
+ return(0);
+}
+
+int
+b_id(int argc, char *argv[], void* context)
+{
+ register int flags = 0;
+ register int n;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ while (n = optget(argv, usage)) switch (n)
+ {
+ case 'a':
+ break;
+ case 'G':
+ flags |= GG_FLAG;
+ break;
+ case 'g':
+ flags |= G_FLAG;
+ break;
+ case 'n':
+ flags |= N_FLAG;
+ break;
+ case 'r':
+ flags |= R_FLAG;
+ break;
+ case 's':
+ flags |= S_FLAG;
+ break;
+ case 'u':
+ flags |= U_FLAG;
+ break;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ argc -= opt_info.index;
+ n = (flags & (GG_FLAG|G_FLAG|S_FLAG|U_FLAG));
+ if (!power2(n))
+ error(2, "incompatible options selected");
+ if (error_info.errors || argc > 1)
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ if (!(flags & ~(N_FLAG|R_FLAG)))
+ {
+ if (flags & N_FLAG) flags |= O_FLAG;
+ flags |= (U_FLAG|G_FLAG|N_FLAG|R_FLAG|S_FLAG|GG_FLAG);
+ }
+ error_info.errors = getids(sfstdout, *argv, flags);
+ return(error_info.errors);
+}
diff --git a/usr/src/lib/libcmd/common/join.c b/usr/src/lib/libcmd/common/join.c
new file mode 100644
index 0000000000..1687c898ca
--- /dev/null
+++ b/usr/src/lib/libcmd/common/join.c
@@ -0,0 +1,816 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * join
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: join (AT&T Research) 2006-10-31 $\n]"
+USAGE_LICENSE
+"[+NAME?join - relational database operator]"
+"[+DESCRIPTION?\bjoin\b performs an \aequality join\a on the files \afile1\a "
+ "and \afile2\a and writes the resulting joined files to standard "
+ "output. By default, a field is delimited by one or more spaces "
+ "and tabs with leading spaces and/or tabs ignored. The \b-t\b option "
+ "can be used to change the field delimiter.]"
+"[+?The \ajoin field\a is a field in each file on which files are compared. "
+ "By default \bjoin\b writes one line in the output for each pair "
+ "of lines in \afiles1\a and \afiles2\a that have identical join "
+ "fields. The default output line consists of the join field, "
+ "then the remaining fields from \afile1\a, then the remaining "
+ "fields from \afile2\a, but this can be changed with the \b-o\b "
+ "option. The \b-a\b option can be used to add unmatched lines "
+ "to the output. The \b-v\b option can be used to output only "
+ "unmatched lines.]"
+"[+?The files \afile1\a and \afile2\a must be ordered in the collating "
+ "sequence of \bsort -b\b on the fields on which they are to be "
+ "joined otherwise the results are unspecified.]"
+"[+?If either \afile1\a or \afile2\a is \b-\b, \bjoin\b "
+ "uses standard input starting at the current location.]"
+
+"[e:empty]:[string?Replace empty output fields in the list selected with"
+" \b-o\b with \astring\a.]"
+"[o:output]:[list?Construct the output line to comprise the fields specified "
+ "in a blank or comma separated list \alist\a. Each element in "
+ "\alist\a consists of a file number (either 1 or 2), a period, "
+ "and a field number or \b0\b representing the join field. "
+ "As an obsolete feature multiple occurrences of \b-o\b can "
+ "be specified.]"
+"[t:separator|tabs]:[delim?Use \adelim\a as the field separator for both input"
+" and output.]"
+"[1:j1]#[field?Join on field \afield\a of \afile1\a. Fields start at 1.]"
+"[2:j2]#[field?Join on field \afield\a of \afile2\a. Fields start at 1.]"
+"[j:join]#[field?Equivalent to \b-1\b \afield\a \b-2\b \afield\a.]"
+"[a:unpairable]#[fileno?Write a line for each unpairable line in file"
+" \afileno\a, where \afileno\a is either 1 or 2, in addition to the"
+" normal output. If \b-a\b options appear for both 1 and 2, then "
+ "all unpairable lines will be output.]"
+"[v:suppress]#[fileno?Write a line for each unpairable line in file"
+" \afileno\a, where \afileno\a is either 1 or 2, instead of the normal "
+ "output. If \b-v\b options appear for both 1 and 2, then "
+ "all unpairable lines will be output.] ]"
+"[i:ignorecase?Ignore case in field comparisons.]"
+"[B!:mmap?Enable memory mapped reads instead of buffered.]"
+
+"[+?The following obsolete option forms are also recognized: \b-j\b \afield\a"
+" is equivalent to \b-1\b \afield\a \b-2\b \afield\a, \b-j1\b \afield\a"
+" is equivalent to \b-1\b \afield\a, and \b-j2\b \afield\a is"
+" equivalent to \b-2\b \afield\a.]"
+
+"\n"
+"\nfile1 file2\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Both files processed successfully.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bcut\b(1), \bcomm\b(1), \bpaste\b(1), \bsort\b(1), \buniq\b(1)]"
+;
+
+#include <cmd.h>
+#include <sfdisc.h>
+
+#define C_FILE1 001
+#define C_FILE2 002
+#define C_COMMON 004
+#define C_ALL (C_FILE1|C_FILE2|C_COMMON)
+
+#define NFIELD 10
+#define JOINFIELD 2
+
+#define S_DELIM 1
+#define S_SPACE 2
+#define S_NL 3
+
+typedef struct
+{
+ Sfio_t* iop;
+ char* name;
+ char* recptr;
+ int reclen;
+ int field;
+ int fieldlen;
+ int nfields;
+ int maxfields;
+ int spaces;
+ int hit;
+ int discard;
+ char** fieldlist;
+} File_t;
+
+typedef struct
+{
+ unsigned char state[1<<CHAR_BIT];
+ Sfio_t* outfile;
+ int* outlist;
+ int outmode;
+ int ooutmode;
+ char* nullfield;
+ int delim;
+ int buffered;
+ int ignorecase;
+ char* same;
+ int samesize;
+ File_t file[2];
+} Join_t;
+
+static void
+done(register Join_t* jp)
+{
+ if (jp->file[0].iop && jp->file[0].iop != sfstdin)
+ sfclose(jp->file[0].iop);
+ if (jp->file[1].iop && jp->file[1].iop != sfstdin)
+ sfclose(jp->file[1].iop);
+ if (jp->outlist)
+ free(jp->outlist);
+ if (jp->file[0].fieldlist)
+ free(jp->file[0].fieldlist);
+ if (jp->file[1].fieldlist)
+ free(jp->file[1].fieldlist);
+ if (jp->same)
+ free(jp->same);
+ free(jp);
+}
+
+static Join_t*
+init(void)
+{
+ register Join_t* jp;
+
+ if (jp = newof(0, Join_t, 1, 0))
+ {
+ jp->state[' '] = jp->state['\t'] = S_SPACE;
+ jp->delim = -1;
+ jp->nullfield = 0;
+ if (!(jp->file[0].fieldlist = newof(0, char*, NFIELD + 1, 0)) ||
+ !(jp->file[1].fieldlist = newof(0, char*, NFIELD + 1, 0)))
+ {
+ done(jp);
+ return 0;
+ }
+ jp->file[0].maxfields = NFIELD;
+ jp->file[1].maxfields = NFIELD;
+ jp->outmode = C_COMMON;
+ }
+ return jp;
+}
+
+static int
+getolist(Join_t* jp, const char* first, char** arglist)
+{
+ register const char* cp = first;
+ char** argv = arglist;
+ register int c;
+ int* outptr;
+ int* outmax;
+ int nfield = NFIELD;
+ char* str;
+
+ outptr = jp->outlist = newof(0, int, NFIELD + 1, 0);
+ outmax = outptr + NFIELD;
+ while (c = *cp++)
+ {
+ if (c==' ' || c=='\t' || c==',')
+ continue;
+ str = (char*)--cp;
+ if (*cp=='0' && ((c=cp[1])==0 || c==' ' || c=='\t' || c==','))
+ {
+ str++;
+ c = JOINFIELD;
+ goto skip;
+ }
+ if (cp[1]!='.' || (*cp!='1' && *cp!='2') || (c=strtol(cp+2,&str,10)) <=0)
+ {
+ error(2,"%s: invalid field list",first);
+ break;
+ }
+ c--;
+ c <<=2;
+ if (*cp=='2')
+ c |=1;
+ skip:
+ if (outptr >= outmax)
+ {
+ jp->outlist = newof(jp->outlist, int, 2 * nfield + 1, 0);
+ outptr = jp->outlist + nfield;
+ nfield *= 2;
+ outmax = jp->outlist + nfield;
+ }
+ *outptr++ = c;
+ cp = str;
+ }
+ /* need to accept obsolescent command syntax */
+ while (1)
+ {
+ if (!(cp= *argv) || cp[1]!='.' || (*cp!='1' && *cp!='2'))
+ {
+ if (*cp=='0' && cp[1]==0)
+ {
+ c = JOINFIELD;
+ goto skip2;
+ }
+ break;
+ }
+ str = (char*)cp;
+ c = strtol(cp+2, &str,10);
+ if (*str || --c<0)
+ break;
+ argv++;
+ c <<= 2;
+ if (*cp=='2')
+ c |=1;
+ skip2:
+ if (outptr >= outmax)
+ {
+ jp->outlist = newof(jp->outlist, int, 2 * nfield + 1, 0);
+ outptr = jp->outlist + nfield;
+ nfield *= 2;
+ outmax = jp->outlist + nfield;
+ }
+ *outptr++ = c;
+ }
+ *outptr = -1;
+ return argv-arglist;
+}
+
+/*
+ * read in a record from file <index> and split into fields
+ */
+static unsigned char*
+getrec(Join_t* jp, int index, int discard)
+{
+ register unsigned char* sp = jp->state;
+ register File_t* fp = &jp->file[index];
+ register char** ptr = fp->fieldlist;
+ register char** ptrmax = ptr + fp->maxfields;
+ register char* cp;
+ register int n = 0;
+
+ if (cmdquit())
+ return 0;
+ if (discard && fp->discard)
+ sfraise(fp->iop, SFSK_DISCARD, NiL);
+ fp->spaces = 0;
+ fp->hit = 0;
+ if (!(cp = sfgetr(fp->iop, '\n', 0)))
+ {
+ jp->outmode &= ~(1<<index);
+ return 0;
+ }
+ fp->recptr = cp;
+ fp->reclen = sfvalue(fp->iop);
+ if (jp->delim=='\n') /* handle new-line delimiter specially */
+ {
+ *ptr++ = cp;
+ cp += fp->reclen;
+ }
+ else while (n!=S_NL) /* separate into fields */
+ {
+ if (ptr >= ptrmax)
+ {
+ n = 2*fp->maxfields;
+ fp->fieldlist = newof(fp->fieldlist, char*, n + 1, 0);
+ ptr = fp->fieldlist + fp->maxfields;
+ fp->maxfields = n;
+ ptrmax = fp->fieldlist+n;
+ }
+ *ptr++ = cp;
+ if (jp->delim<=0 && sp[*(unsigned char*)cp]==S_SPACE)
+ {
+ fp->spaces = 1;
+ while (sp[*(unsigned char*)cp++]==S_SPACE);
+ cp--;
+ }
+ while ((n=sp[*(unsigned char*)cp++])==0);
+ }
+ *ptr = cp;
+ fp->nfields = ptr - fp->fieldlist;
+ if ((n=fp->field) < fp->nfields)
+ {
+ cp = fp->fieldlist[n];
+ /* eliminate leading spaces */
+ if (fp->spaces)
+ {
+ while (sp[*(unsigned char*)cp++]==S_SPACE);
+ cp--;
+ }
+ fp->fieldlen = (fp->fieldlist[n+1]-cp)-1;
+ return (unsigned char*)cp;
+ }
+ fp->fieldlen = 0;
+ return (unsigned char*)"";
+}
+
+#if DEBUG_TRACE
+static unsigned char* u1,u2,u3;
+#define getrec(p,n,d) (u1 = getrec(p, n, d), sfprintf(sfstdout, "[G%d#%d@%I*d:%-.8s]", __LINE__, n, sizeof(Sfoff_t), sftell(p->file[n].iop), u1), u1)
+#endif
+
+/*
+ * print field <n> from file <index>
+ */
+static int
+outfield(Join_t* jp, int index, register int n, int last)
+{
+ register File_t* fp = &jp->file[index];
+ register char* cp;
+ register char* cpmax;
+ register int size;
+ register Sfio_t* iop = jp->outfile;
+
+ if (n < fp->nfields)
+ {
+ cp = fp->fieldlist[n];
+ cpmax = fp->fieldlist[n+1];
+ }
+ else
+ cp = 0;
+ if ((n=jp->delim)<=0)
+ {
+ if (fp->spaces)
+ {
+ /*eliminate leading spaces */
+ while (jp->state[*(unsigned char*)cp++]==S_SPACE);
+ cp--;
+ }
+ n = ' ';
+ }
+ if (last)
+ n = '\n';
+ if (cp)
+ size = cpmax-cp;
+ else
+ size = 0;
+ if (size==0)
+ {
+ if (!jp->nullfield)
+ sfputc(iop,n);
+ else if (sfputr(iop,jp->nullfield,n) < 0)
+ return -1;
+ }
+ else
+ {
+ last = cp[size-1];
+ cp[size-1] = n;
+ if (sfwrite(iop,cp,size) < 0)
+ return -1;
+ cp[size-1] = last;
+ }
+ return 0;
+}
+
+#if DEBUG_TRACE
+static int i1,i2,i3;
+#define outfield(p,i,n,f) (sfprintf(sfstdout, "[F%d#%d:%d,%d]", __LINE__, i1=i, i2=n, i3=f), outfield(p, i1, i2, i3))
+#endif
+
+static int
+outrec(register Join_t* jp, int mode)
+{
+ register File_t* fp;
+ register int i;
+ register int j;
+ register int k;
+ register int n;
+ int* out;
+
+ if (mode < 0 && jp->file[0].hit++)
+ return 0;
+ if (mode > 0 && jp->file[1].hit++)
+ return 0;
+ if (out = jp->outlist)
+ {
+ while ((n = *out++) >= 0)
+ {
+ if (n == JOINFIELD)
+ {
+ i = mode >= 0;
+ j = jp->file[i].field;
+ }
+ else
+ {
+ i = n & 1;
+ j = (mode<0 && i || mode>0 && !i) ?
+ jp->file[i].nfields :
+ n >> 2;
+ }
+ if (outfield(jp, i, j, *out < 0) < 0)
+ return -1;
+ }
+ return 0;
+ }
+ k = jp->file[0].nfields;
+ if (mode >= 0)
+ k += jp->file[1].nfields - 1;
+ for (i=0; i<2; i++)
+ {
+ fp = &jp->file[i];
+ if (mode>0 && i==0)
+ {
+ k -= (fp->nfields - 1);
+ continue;
+ }
+ n = fp->field;
+ if (mode||i==0)
+ {
+ /* output join field first */
+ if (outfield(jp,i,n,!--k) < 0)
+ return -1;
+ if (!k)
+ return 0;
+ for (j=0; j<n; j++)
+ {
+ if (outfield(jp,i,j,!--k) < 0)
+ return -1;
+ if (!k)
+ return 0;
+ }
+ j = n + 1;
+ }
+ else
+ j = 0;
+ for (;j<fp->nfields; j++)
+ {
+ if (j!=n && outfield(jp,i,j,!--k) < 0)
+ return -1;
+ if (!k)
+ return 0;
+ }
+ }
+ return 0;
+}
+
+#if DEBUG_TRACE
+#define outrec(p,n) (sfprintf(sfstdout, "[R#%d,%d,%lld,%lld:%-.*s{%d}:%-.*s{%d}]", __LINE__, i1=n, lo, hi, jp->file[0].fieldlen, cp1, jp->file[0].hit, jp->file[1].fieldlen, cp2, jp->file[1].hit), outrec(p, i1))
+#endif
+
+static int
+join(Join_t* jp)
+{
+ register unsigned char* cp1;
+ register unsigned char* cp2;
+ register int n1;
+ register int n2;
+ register int n;
+ register int cmp;
+ register int same;
+ int o2;
+ Sfoff_t lo = -1;
+ Sfoff_t hi = -1;
+
+ if ((cp1 = getrec(jp, 0, 0)) && (cp2 = getrec(jp, 1, 0)) || (cp2 = 0))
+ {
+ n1 = jp->file[0].fieldlen;
+ n2 = jp->file[1].fieldlen;
+ same = 0;
+ for (;;)
+ {
+ n = n1 < n2 ? n1 : n2;
+#if DEBUG_TRACE
+ if (!n && !(cmp = n1 < n2 ? -1 : (n1 > n2)) || n && !(cmp = (int)*cp1 - (int)*cp2) && !(cmp = jp->ignorecase ? strncasecmp((char*)cp1, (char*)cp2, n) : memcmp(cp1, cp2, n)))
+ cmp = n1 - n2;
+sfprintf(sfstdout, "[C#%d:%d(%c-%c),%d,%lld,%lld%s]", __LINE__, cmp, *cp1, *cp2, same, lo, hi, (jp->outmode & C_COMMON) ? ",COMMON" : "");
+ if (!cmp)
+#else
+ if (!n && !(cmp = n1 < n2 ? -1 : (n1 > n2)) || n && !(cmp = (int)*cp1 - (int)*cp2) && !(cmp = jp->ignorecase ? strncasecmp((char*)cp1, (char*)cp2, n) : memcmp(cp1, cp2, n)) && !(cmp = n1 - n2))
+#endif
+ {
+ if (!(jp->outmode & C_COMMON))
+ {
+ if (cp1 = getrec(jp, 0, 1))
+ {
+ n1 = jp->file[0].fieldlen;
+ same = 1;
+ continue;
+ }
+ if ((jp->ooutmode & (C_FILE1|C_FILE2)) != C_FILE2)
+ break;
+ if (sfseek(jp->file[0].iop, (Sfoff_t)-jp->file[0].reclen, SEEK_CUR) < 0 || !(cp1 = getrec(jp, 0, 0)))
+ {
+ error(ERROR_SYSTEM|2, "%s: seek error", jp->file[0].name);
+ return -1;
+ }
+ }
+ else if (outrec(jp, 0) < 0)
+ return -1;
+ else if (lo < 0 && (jp->outmode & C_COMMON))
+ {
+ if ((lo = sfseek(jp->file[1].iop, (Sfoff_t)0, SEEK_CUR)) < 0)
+ {
+ error(ERROR_SYSTEM|2, "%s: seek error", jp->file[1].name);
+ return -1;
+ }
+ lo -= jp->file[1].reclen;
+ }
+ if (cp2 = getrec(jp, 1, lo < 0))
+ {
+ n2 = jp->file[1].fieldlen;
+ continue;
+ }
+#if DEBUG_TRACE
+sfprintf(sfstdout, "[2#%d:0,%lld,%lld]", __LINE__, lo, hi);
+#endif
+ }
+ else if (cmp > 0)
+ {
+ if (same)
+ {
+ same = 0;
+ next:
+ if (n2 > jp->samesize)
+ {
+ jp->samesize = roundof(n2, 16);
+ if (!(jp->same = newof(jp->same, char, jp->samesize, 0)))
+ {
+ error(ERROR_SYSTEM|2, "out of space");
+ return -1;
+ }
+ }
+ memcpy(jp->same, cp2, o2 = n2);
+ if (!(cp2 = getrec(jp, 1, 0)))
+ break;
+ n2 = jp->file[1].fieldlen;
+ if (n2 == o2 && *cp2 == *jp->same && !memcmp(cp2, jp->same, n2))
+ goto next;
+ continue;
+ }
+ if (hi >= 0)
+ {
+ if (sfseek(jp->file[1].iop, hi, SEEK_SET) != hi)
+ {
+ error(ERROR_SYSTEM|2, "%s: seek error", jp->file[1].name);
+ return -1;
+ }
+ hi = -1;
+ }
+ else if ((jp->outmode & C_FILE2) && outrec(jp, 1) < 0)
+ return -1;
+ lo = -1;
+ if (cp2 = getrec(jp, 1, 1))
+ {
+ n2 = jp->file[1].fieldlen;
+ continue;
+ }
+#if DEBUG_TRACE
+sfprintf(sfstdout, "[2#%d:0,%lld,%lld]", __LINE__, lo, hi);
+#endif
+ }
+ else if (same)
+ {
+ same = 0;
+ if (!(cp1 = getrec(jp, 0, 0)))
+ break;
+ n1 = jp->file[0].fieldlen;
+ continue;
+ }
+ if (lo >= 0)
+ {
+ if ((hi = sfseek(jp->file[1].iop, (Sfoff_t)0, SEEK_CUR)) < 0 ||
+ (hi -= jp->file[1].reclen) < 0 ||
+ sfseek(jp->file[1].iop, lo, SEEK_SET) != lo ||
+ !(cp2 = getrec(jp, 1, 0)))
+ {
+ error(ERROR_SYSTEM|2, "%s: seek error", jp->file[1].name);
+ return -1;
+ }
+ n2 = jp->file[1].fieldlen;
+ lo = -1;
+ if (jp->file[1].discard)
+ sfseek(jp->file[1].iop, (Sfoff_t)-1, SEEK_SET);
+ }
+ else if (!cp2)
+ break;
+ else if ((jp->outmode & C_FILE1) && outrec(jp, -1) < 0)
+ return -1;
+ if (!(cp1 = getrec(jp, 0, 1)))
+ break;
+ n1 = jp->file[0].fieldlen;
+ }
+ }
+#if DEBUG_TRACE
+sfprintf(sfstdout, "[X#%d:?,%p,%p,%d%,%d,%d%s]", __LINE__, cp1, cp2, cmp, lo, hi, (jp->outmode & C_COMMON) ? ",COMMON" : "");
+#endif
+ if (cp2)
+ {
+ if (hi >= 0 &&
+ sfseek(jp->file[1].iop, (Sfoff_t)0, SEEK_CUR) < hi &&
+ sfseek(jp->file[1].iop, hi, SEEK_SET) != hi)
+ {
+ error(ERROR_SYSTEM|2, "%s: seek error", jp->file[1].name);
+ return -1;
+ }
+#if DEBUG_TRACE
+sfprintf(sfstdout, "[O#%d:%02o:%02o]", __LINE__, jp->ooutmode, jp->outmode);
+#endif
+ cp1 = (!cp1 && cmp && hi < 0 && !jp->file[1].hit && ((jp->ooutmode ^ C_ALL) <= 1 || jp->outmode == 2)) ? cp2 : getrec(jp, 1, 0);
+ cmp = 1;
+ n = 1;
+ }
+ else
+ {
+ cmp = -1;
+ n = 0;
+ }
+#if DEBUG_TRACE
+sfprintf(sfstdout, "[X#%d:%d,%p,%p,%d,%02o,%02o%s]", __LINE__, n, cp1, cp2, cmp, jp->ooutmode, jp->outmode, (jp->outmode & C_COMMON) ? ",COMMON" : "");
+#endif
+ if (!cp1 || !(jp->outmode & (1<<n)))
+ {
+ if (cp1 && jp->file[n].iop == sfstdin)
+ sfseek(sfstdin, (Sfoff_t)0, SEEK_END);
+ return 0;
+ }
+ if (outrec(jp, cmp) < 0)
+ return -1;
+ do
+ {
+ if (!getrec(jp, n, 1))
+ return 0;
+ } while (outrec(jp, cmp) >= 0);
+ return -1;
+}
+
+int
+b_join(int argc, char** argv, void* context)
+{
+ register int n;
+ register char* cp;
+ register Join_t* jp;
+ char* e;
+
+#if !DEBUG_TRACE
+ cmdinit(argc, argv, context, ERROR_CATALOG, ERROR_NOTIFY);
+#endif
+ if (!(jp = init()))
+ error(ERROR_system(1),"out of space");
+ for (;;)
+ {
+ switch (n = optget(argv, usage))
+ {
+ case 0:
+ break;
+ case 'j':
+ /*
+ * check for obsolete "-j1 field" and "-j2 field"
+ */
+
+ if (opt_info.offset == 0)
+ {
+ cp = argv[opt_info.index - 1];
+ for (n = strlen(cp) - 1; n > 0 && cp[n] != 'j'; n--);
+ n = cp[n] == 'j';
+ }
+ else
+ n = 0;
+ if (n)
+ {
+ if (opt_info.num!=1 && opt_info.num!=2)
+ error(2,"-jfileno field: fileno must be 1 or 2");
+ n = '0' + opt_info.num;
+ if (!(cp = argv[opt_info.index]))
+ {
+ argc = 0;
+ break;
+ }
+ opt_info.num = strtol(cp, &e, 10);
+ if (*e)
+ {
+ argc = 0;
+ break;
+ }
+ opt_info.index++;
+ }
+ else
+ {
+ jp->file[0].field = (int)(opt_info.num-1);
+ n = '2';
+ }
+ /*FALLTHROUGH*/
+ case '1':
+ case '2':
+ if (opt_info.num <=0)
+ error(2,"field number must positive");
+ jp->file[n-'1'].field = (int)(opt_info.num-1);
+ continue;
+ case 'v':
+ jp->outmode &= ~C_COMMON;
+ /*FALLTHROUGH*/
+ case 'a':
+ if (opt_info.num!=1 && opt_info.num!=2)
+ error(2,"%s: file number must be 1 or 2", opt_info.name);
+ jp->outmode |= 1<<(opt_info.num-1);
+ continue;
+ case 'e':
+ jp->nullfield = opt_info.arg;
+ continue;
+ case 'o':
+ /* need to accept obsolescent command syntax */
+ n = getolist(jp, opt_info.arg, argv+opt_info.index);
+ opt_info.index += n;
+ continue;
+ case 't':
+ jp->state[' '] = jp->state['\t'] = 0;
+ n= *(unsigned char*)opt_info.arg;
+ jp->state[n] = S_DELIM;
+ jp->delim = n;
+ continue;
+ case 'i':
+ jp->ignorecase = !opt_info.num;
+ continue;
+ case 'B':
+ jp->buffered = !opt_info.num;
+ continue;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ done(jp);
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ argc -= opt_info.index;
+ if (error_info.errors || argc!=2)
+ {
+ done(jp);
+ error(ERROR_usage(2),"%s", optusage(NiL));
+ }
+ jp->ooutmode = jp->outmode;
+ jp->file[0].name = cp = *argv++;
+ if (streq(cp,"-"))
+ {
+ if (sfseek(sfstdin,(Sfoff_t)0,SEEK_CUR) < 0)
+ {
+ if (sfdcseekable(sfstdin))
+ error(ERROR_warn(0),"%s: seek may fail",cp);
+ else
+ jp->file[0].discard = 1;
+ }
+ jp->file[0].iop = sfstdin;
+ }
+ else if (!(jp->file[0].iop = sfopen(NiL, cp, "r")))
+ {
+ done(jp);
+ error(ERROR_system(1),"%s: cannot open",cp);
+ }
+ jp->file[1].name = cp = *argv;
+ if (streq(cp,"-"))
+ {
+ if (sfseek(sfstdin,(Sfoff_t)0,SEEK_CUR) < 0)
+ {
+ if (sfdcseekable(sfstdin))
+ error(ERROR_warn(0),"%s: seek may fail",cp);
+ else
+ jp->file[1].discard = 1;
+ }
+ jp->file[1].iop = sfstdin;
+ }
+ else if (!(jp->file[1].iop = sfopen(NiL, cp, "r")))
+ {
+ done(jp);
+ error(ERROR_system(1),"%s: cannot open",cp);
+ }
+ if (jp->buffered)
+ {
+ sfsetbuf(jp->file[0].iop, jp->file[0].iop, SF_UNBOUND);
+ sfsetbuf(jp->file[1].iop, jp->file[0].iop, SF_UNBOUND);
+ }
+ jp->state['\n'] = S_NL;
+ jp->outfile = sfstdout;
+ if (!jp->outlist)
+ jp->nullfield = 0;
+ if (join(jp) < 0)
+ {
+ done(jp);
+ error(ERROR_system(1),"write error");
+ }
+ else if (jp->file[0].iop==sfstdin || jp->file[1].iop==sfstdin)
+ sfseek(sfstdin,(Sfoff_t)0,SEEK_END);
+ done(jp);
+ return error_info.errors;
+}
diff --git a/usr/src/lib/libcmd/common/llib-lcmd b/usr/src/lib/libcmd/common/llib-lcmd
index c9de823563..8908e1c639 100644
--- a/usr/src/lib/libcmd/common/llib-lcmd
+++ b/usr/src/lib/libcmd/common/llib-lcmd
@@ -18,22 +18,68 @@
*
* CDDL HEADER END
*/
-
-/* LINTLIBRARY */
-/* PROTOLIB1 */
-
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ *
+ * lib/libcmd/common/llib-lcmd
+ *
*/
#pragma ident "%Z%%M% %I% %E% SMI"
+/*LINTLIBRARY*/
+/*PROTOLIB1*/
+
+#include <cmd.h>
+#include <cmdext.h>
+
+/* automatically generated data start here */
+extern int STANDALONE(int, char**, void*);
+extern int cmdrecurse(int, char**, int, char**);
+extern int b_basename(int, char**, void*);
+extern int b_cat(int, char**, void*);
+extern int b_chgrp(int, char**, void*);
+extern int b_chmod(int, char**, void*);
+extern int b_chown(int, char**, void*);
+extern int b_cmp(int, char**, void*);
+extern int b_comm(int, char**, void*);
+extern int b_cp(int, char**, void*);
+extern int b_cut(int, char**, void*);
+extern int b_date(int, char**, void*);
+extern int b_dirname(int, char**, void*);
+extern int b_expr(int, char**, void*);
+extern int b_fds(int, char**, void*);
+extern int b_fmt(int, char**, void*);
+extern int b_fold(int, char**, void*);
+extern int b_getconf(int, char**, void*);
+extern int b_head(int, char**, void*);
+extern int b_id(int, char**, void*);
+extern int b_join(int, char**, void*);
+extern int b_ln(int, char**, void*);
+extern int b_logname(int, char**, void*);
+extern int b_mkdir(int, char**, void*);
+extern int b_mkfifo(int, char**, void*);
+extern int b_mv(int, char**, void*);
+extern int b_paste(int, char**, void*);
+extern int b_pathchk(int, char**, void*);
+extern int b_rev(int, char**, void*);
+extern int b_rm(int, char**, void*);
+extern int b_rmdir(int, char**, void*);
+extern int b_stty(int, char**, void*);
+extern int b_tail(int, char**, void*);
+extern int b_tee(int, char**, void*);
+extern int b_tty(int, char**, void*);
+extern int b_uname(int, char**, void*);
+extern int b_uniq(int, char**, void*);
+extern int b_wc(int, char**, void*);
+/* end of automatically generated data */
+
/*
- * The def*() functions are the historical contents of libcmd.
- * They have been moved to libc and libcmd contains only filter
- * symbols for them, redirecting to libc.
+ * The |def*()| functions are the historical contents of Solaris
+ * libcmd. They have been moved to libc and libcmd contains only
+ * filter symbols for them, redirecting to libc.
*/
-int defopen(char *fn);
-char *defread(char *cp);
-int defcntl(int cmd, int newflags);
+extern int defopen(char *fn);
+extern char *defread(char *cp);
+extern int defcntl(int cmd, int newflags);
diff --git a/usr/src/lib/libcmd/common/ln.c b/usr/src/lib/libcmd/common/ln.c
new file mode 100644
index 0000000000..9adb32e3fd
--- /dev/null
+++ b/usr/src/lib/libcmd/common/ln.c
@@ -0,0 +1,35 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * cp/ln/mv -- copy/link/move files
+ */
+
+#include <cmd.h>
+
+int
+b_ln(int argc, register char** argv, void* context)
+{
+ return b_cp(argc, argv, context);
+}
diff --git a/usr/src/lib/libcmd/common/logname.c b/usr/src/lib/libcmd/common/logname.c
new file mode 100644
index 0000000000..fe771e95ed
--- /dev/null
+++ b/usr/src/lib/libcmd/common/logname.c
@@ -0,0 +1,78 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Research
+ *
+ * logname
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: logname (AT&T Research) 1999-04-30 $\n]"
+USAGE_LICENSE
+"[+NAME?logname - return the user's login name]"
+"[+DESCRIPTION?\blogname\b writes the users's login name to standard "
+ "output. The login name is the string that is returned by the "
+ "\bgetlogin\b(2) function. If \bgetlogin\b(2) does not return "
+ "successfully, the corresponding to the real user id of the calling "
+ "process is used instead.]"
+
+"\n"
+"\n\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Successful Completion.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bgetlogin\b(2)]"
+;
+
+
+#include <cmd.h>
+
+int
+b_logname(int argc, char** argv, void* context)
+{
+ register char* logname;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ for (;;)
+ {
+ switch (optget(argv, usage))
+ {
+ case ':':
+ error(2, "%s", opt_info.arg);
+ continue;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ continue;
+ }
+ break;
+ }
+ if (error_info.errors)
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ if (!(logname = getlogin()))
+ logname = fmtuid(getuid());
+ sfputr(sfstdout, logname, '\n');
+ return 0;
+}
+
diff --git a/usr/src/lib/libcmd/common/md5sum.c b/usr/src/lib/libcmd/common/md5sum.c
new file mode 100644
index 0000000000..11977d008e
--- /dev/null
+++ b/usr/src/lib/libcmd/common/md5sum.c
@@ -0,0 +1,35 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * md5sum -- implemented by cksum
+ */
+
+#include <cmd.h>
+
+int
+b_md5sum(int argc, register char** argv, void* context)
+{
+ return b_cksum(argc, argv, context);
+}
diff --git a/usr/src/lib/libcmd/common/mkdir.c b/usr/src/lib/libcmd/common/mkdir.c
new file mode 100644
index 0000000000..df47adc11c
--- /dev/null
+++ b/usr/src/lib/libcmd/common/mkdir.c
@@ -0,0 +1,152 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Bell Laboratories
+ *
+ * mkdir
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: mkdir (AT&T Research) 2006-08-27 $\n]"
+USAGE_LICENSE
+"[+NAME?mkdir - make directories]"
+"[+DESCRIPTION?\bmkdir\b creates one or more directories. By "
+ "default, the mode of created directories is \ba=rwx\b minus the "
+ "bits set in the \bumask\b(1).]"
+"[m:mode]:[mode?Set the mode of created directories to \amode\a. "
+ "\amode\a is symbolic or octal mode as in \bchmod\b(1). Relative "
+ "modes assume an initial mode of \ba=rwx\b.]"
+"[p:parents?Create any missing intermediate pathname components. For "
+ "each dir operand that does not name an existing directory, effects "
+ "equivalent to those caused by the following command shall occur: "
+ "\vmkdir -p -m $(umask -S),u+wx $(dirname dir) && mkdir [-m mode]] "
+ "dir\v where the \b-m\b mode option represents that option supplied to "
+ "the original invocation of \bmkdir\b, if any. Each dir operand that "
+ "names an existing directory shall be ignored without error.]"
+"\n"
+"\ndirectory ...\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?All directories created successfully, or the \b-p\b option "
+ "was specified and all the specified directories now exist.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bchmod\b(1), \brmdir\b(1), \bumask\b(1)]"
+;
+
+#include <cmd.h>
+#include <ls.h>
+
+#define DIRMODE (S_IRWXU|S_IRWXG|S_IRWXO)
+
+int
+b_mkdir(int argc, char** argv, void* context)
+{
+ register char* arg;
+ register int n;
+ register mode_t mode = DIRMODE;
+ register mode_t mask = 0;
+ register int mflag = 0;
+ register int pflag = 0;
+ char* name;
+ mode_t dmode;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ while (n = optget(argv, usage)) switch (n)
+ {
+ case 'p':
+ pflag = 1;
+ break;
+ case 'm':
+ mflag = 1;
+ mode = strperm(arg = opt_info.arg, &opt_info.arg, mode);
+ if (*opt_info.arg)
+ error(ERROR_exit(0), "%s: invalid mode", arg);
+ break;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ if (error_info.errors || !*argv)
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ mask = umask(0);
+ if (mflag || pflag)
+ {
+ dmode = DIRMODE & ~mask;
+ if (!mflag)
+ mode = dmode;
+ dmode |= S_IWUSR | S_IXUSR;
+ }
+ else
+ {
+ mode &= ~mask;
+ umask(mask);
+ mask = 0;
+ }
+ while (arg = *argv++)
+ {
+ if (mkdir(arg, mode) < 0)
+ {
+ if (!pflag || !(errno == ENOENT || errno == EEXIST || errno == ENOTDIR))
+ {
+ error(ERROR_system(0), "%s:", arg);
+ continue;
+ }
+ if (errno == EEXIST)
+ continue;
+
+ /*
+ * -p option, preserve intermediates
+ * first eliminate trailing /'s
+ */
+
+ n = strlen(arg);
+ while (n > 0 && arg[--n] == '/');
+ arg[n + 1] = 0;
+ for (name = arg, n = *arg; n;)
+ {
+ /* skip over slashes */
+ while (*arg == '/')
+ arg++;
+ /* skip to next component */
+ while ((n = *arg) && n != '/')
+ arg++;
+ *arg = 0;
+ if (mkdir(name, n ? dmode : mode) < 0 && errno != EEXIST && access(name, F_OK) < 0)
+ {
+ *arg = n;
+ error(ERROR_system(0), "%s:", name);
+ break;
+ }
+ *arg = n;
+ }
+ }
+ }
+ if (mask)
+ umask(mask);
+ return error_info.errors != 0;
+}
diff --git a/usr/src/lib/libcmd/common/mkfifo.c b/usr/src/lib/libcmd/common/mkfifo.c
new file mode 100644
index 0000000000..cffcab1e81
--- /dev/null
+++ b/usr/src/lib/libcmd/common/mkfifo.c
@@ -0,0 +1,89 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Bell Laboratories
+ *
+ * mkfifo
+ */
+
+
+static const char usage[] =
+"[-?\n@(#)$Id: mkfifo (AT&T Research) 1999-04-20 $\n]"
+USAGE_LICENSE
+"[+NAME?mkfifo - make FIFOs (named pipes)]"
+"[+DESCRIPTION?\bmkfifo\b creates one or more FIFO's. By "
+ "default, the mode of created FIFO is \ba=rw\b minus the "
+ "bits set in the \bumask\b(1).]"
+"[m:mode]:[mode?Set the mode of created FIFO to \amode\a. "
+ "\amode\a is symbolic or octal mode as in \bchmod\b(1). Relative "
+ "modes assume an initial mode of \ba=rw\b.]"
+"\n"
+"\nfile ...\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?All FIFO's created successfully.]"
+ "[+>0?One or more FIFO's could not be created.]"
+"}"
+"[+SEE ALSO?\bchmod\b(1), \bumask\b(1)]"
+;
+
+#include <cmd.h>
+#include <ls.h>
+
+#define RWALL (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
+
+int
+b_mkfifo(int argc, char *argv[], void* context)
+{
+ register char *arg;
+ register mode_t mode=RWALL, mask=0;
+ register int n;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ while (n = optget(argv, usage)) switch (n)
+ {
+ case 'm':
+ mode = strperm(arg=opt_info.arg,&opt_info.arg,mode);
+ if(*opt_info.arg)
+ error(ERROR_exit(0),"%s: invalid mode",arg);
+ break;
+ case ':':
+ error(2, "%s",opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s",opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ if(error_info.errors || !*argv)
+ error(ERROR_usage(2),"%s",optusage(NiL));
+ while(arg = *argv++)
+ {
+ if(mkfifo(arg,mode) < 0)
+ error(ERROR_system(0),"%s:",arg);
+ }
+ if(mask)
+ umask(mask);
+ return(error_info.errors!=0);
+}
+
diff --git a/usr/src/lib/libcmd/common/mv.c b/usr/src/lib/libcmd/common/mv.c
new file mode 100644
index 0000000000..cf4e6785dd
--- /dev/null
+++ b/usr/src/lib/libcmd/common/mv.c
@@ -0,0 +1,35 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * cp/ln/mv -- copy/link/move files
+ */
+
+#include <cmd.h>
+
+int
+b_mv(int argc, register char** argv, void* context)
+{
+ return b_cp(argc, argv, context);
+}
diff --git a/usr/src/lib/libcmd/common/paste.c b/usr/src/lib/libcmd/common/paste.c
new file mode 100644
index 0000000000..5aaeb369ac
--- /dev/null
+++ b/usr/src/lib/libcmd/common/paste.c
@@ -0,0 +1,247 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Bell Laboratories
+ *
+ * paste [-s] [-d delim] [file] ...
+ *
+ * paste lines from files together
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: paste (AT&T Research) 1999-06-22 $\n]"
+USAGE_LICENSE
+"[+NAME?paste - merge lines of files]"
+"[+DESCRIPTION?\bpaste\b concatenates the corresponding lines of a "
+ "given input file and writes the resulting lines to standard "
+ "output. By default \bpaste\b replaces the newline character of "
+ "every line other than the last input file with the TAB character.]"
+"[+?Unless the \b-s\b option is specified, if an end-of-file is encountered "
+ "on one or more input files, but not all input files, \bpaste\b "
+ "behaves as if empty lines were read from the file(s) on which "
+ "end-of-file was detected.]"
+"[+?Unless the \b-s\b option is specified, \bpaste\b is limited by "
+ "the underlying operating system on how many \afile\a operands "
+ "can be specified.]"
+"[+?If no \afile\a operands are given or if the \afile\a is \b-\b, \bpaste\b "
+ "reads from standard input. The start of the file is defined as the "
+ "current offset.]"
+
+"[s:serial?Paste the lines of one file at a time rather than one line "
+ "from each file. In this case if the \b-d\b option is "
+ "specified the delimiter will be reset to the first in the "
+ "list at the beginning of each file.]"
+"[d:delimiters]:[list?\alist\a specifies a list of delimiters. These "
+ "delimiters are used circularly instead of TAB to replace "
+ "the newline character of the input lines. Unless the \b-s\b "
+ "option is specified, the delimiter will be reset to the first "
+ "element of \alist\a each time a line is processed from each file. "
+ "The delimiter characters corresponding to \alist\a will be found "
+ "by treating \alist\a as an ANSI-C string, except that the \b\\0\b "
+ "sequence will insert the empty string instead of the null character.]"
+"\n"
+"\n[file ...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?All files processed successfully.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bcut\b(1), \bcat\b(1), \bjoin\b(1)]"
+;
+
+
+#include <cmd.h>
+
+/*
+ * paste the lines of the <nstreams> defined in <streams> and put results
+ * to <out>
+ */
+
+static int paste(int nstream,Sfio_t* streams[],Sfio_t *out, register const char *delim,int dlen)
+{
+ register const char *cp;
+ register int d, n, more=1;
+ register Sfio_t *fp;
+ do
+ {
+ d = (dlen>0?0:-1);
+ for(n=more-1,more=0; n < nstream;)
+ {
+ if(fp=streams[n])
+ {
+ if(cp = sfgetr(fp,'\n',0))
+ {
+ if(n==0)
+ more = 1;
+ else if(!more) /* first stream with output */
+ {
+ if(dlen==1)
+ sfnputc(out, *delim, n);
+ else if(dlen>0)
+ {
+ for(d=n; d>dlen; d-=dlen)
+ sfwrite(out,delim,dlen);
+ if(d)
+ sfwrite(out,delim,d);
+ }
+ more = n+1;
+ }
+ if(sfwrite(out,cp,sfvalue(fp)-((n+1)<nstream)) < 0)
+ return(-1);
+ }
+ else
+ streams[n] = 0;
+ }
+ if(++n<nstream && more && d>=0)
+ {
+ register int c;
+ if(d >= dlen)
+ d = 0;
+ if(c=delim[d++])
+ sfputc(out,c);
+ }
+ else if(n==nstream && !streams[n-1] && more)
+ sfputc(out,'\n');
+ }
+ }
+ while(more);
+ return(0);
+}
+
+/*
+ * Handles paste -s, for file <in> to file <out> using delimiters <delim>
+ */
+static int spaste(Sfio_t *in,register Sfio_t* out,register const char *delim,int dlen)
+{
+ register const char *cp;
+ register int d=0;
+ if(cp = sfgetr(in,'\n',0))
+ {
+ if(sfwrite(out,cp,sfvalue(in)-1) < 0)
+ return(-1);
+ }
+ while(cp=sfgetr(in, '\n',0))
+ {
+ if(dlen)
+ {
+ register int c;
+ if(d >= dlen)
+ d = 0;
+ if(c=delim[d++])
+ sfputc(out,c);
+ }
+ if(sfwrite(out,cp,sfvalue(in)-1) < 0)
+ return(-1);
+ }
+ sfputc(out,'\n');
+ return(0);
+}
+
+int
+b_paste(int argc,register char *argv[], void* context)
+{
+ register int n, sflag=0;
+ register Sfio_t *fp, **streams;
+ register char *cp, *delim;
+ int dlen;
+ char defdelim[2];
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ delim = 0;
+ while (n = optget(argv, usage)) switch (n)
+ {
+ case 'd':
+ delim = opt_info.arg;
+ break;
+ case 's':
+ sflag++;
+ break;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ if(error_info.errors)
+ error(ERROR_usage(2),"%s", optusage(NiL));
+ if(delim)
+ dlen = stresc(delim);
+ else
+ {
+ *(delim = defdelim) = '\t';
+ dlen = 1;
+ }
+ if(cp = *argv)
+ {
+ n = argc - opt_info.index;
+ argv++;
+ }
+ else
+ n = 1;
+ if(!sflag)
+ {
+ if (!(streams = (Sfio_t**)stakalloc(n*sizeof(Sfio_t*))))
+ error(ERROR_exit(1), "out of space");
+ n = 0;
+ }
+ do
+ {
+ if(!cp || streq(cp,"-"))
+ fp = sfstdin;
+ else if(!(fp = sfopen(NiL,cp,"r")))
+ {
+ error(ERROR_system(0),"%s: cannot open",cp);
+ error_info.errors = 1;
+ }
+ if(fp && sflag)
+ {
+ if(spaste(fp,sfstdout,delim,dlen) < 0)
+ {
+ error(ERROR_system(0),"write failed");
+ error_info.errors = 1;
+ }
+ if(fp!=sfstdin)
+ sfclose(fp);
+ }
+ else
+ streams[n++] = fp;
+ }
+ while(cp= *argv++);
+ if(!sflag)
+ {
+ if(error_info.errors==0 && paste(n,streams,sfstdout,delim,dlen) < 0)
+ {
+ error(ERROR_system(0),"write failed");
+ error_info.errors = 1;
+ }
+ while(--n>=0)
+ {
+ if((fp=streams[n]) && fp!=sfstdin)
+ sfclose(fp);
+ }
+ }
+ return(error_info.errors);
+}
+
diff --git a/usr/src/lib/libcmd/common/pathchk.c b/usr/src/lib/libcmd/common/pathchk.c
new file mode 100644
index 0000000000..fff22f52bf
--- /dev/null
+++ b/usr/src/lib/libcmd/common/pathchk.c
@@ -0,0 +1,248 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * pathchk
+ *
+ * Written by David Korn
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: pathchk (AT&T Research) 2006-09-19 $\n]"
+USAGE_LICENSE
+"[+NAME?pathchk - check pathnames for portability]"
+"[+DESCRIPTION?\bpathchk\b checks each \apathname\a to see if it "
+ "is valid and/or portable. A \apathname\a is valid if it "
+ "can be used to access or create a file without causing syntax "
+ "errors. A file is portable, if no truncation will result on "
+ "any conforming POSIX.1 implementation.]"
+"[+?By default \bpathchk\b checks each component of each \apathname\a "
+ "based on the underlying file system. A diagnostic is written "
+ "to standard error for each pathname that:]{"
+ "[+-?Is longer than \b$(getconf PATH_MAX)\b bytes.]"
+ "[+-?Contains any component longer than \b$(getconf NAME_MAX)\b bytes.]"
+ "[+-?Contains any directory component in a directory that is "
+ "not searchable.]"
+ "[+-?Contains any character in any component that is not valid in "
+ "its containing directory.]"
+ "[+-?Is empty.]"
+ "}"
+"[p:portability?Instead of performing length checks on the underlying "
+ "file system, write a diagnostic for each pathname operand that:]{"
+ "[+-?Is longer than \b$(getconf _POSIX_PATH_MAX)\b bytes.]"
+ "[+-?Contains any component longer than "
+ "\b$(getconf _POSIX_NAME_MAX)\b bytes.]"
+ "[+-?Contains any character in any component that is not in the "
+ "portable filename character set.]"
+#if 0
+ "[+-?Contains any component with \b-\b as the first character.]"
+#endif
+ "[+-?Is empty.]"
+ "}"
+"\n"
+"\npathname ...\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?All \apathname\a operands passed all of the checks.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bgetconf\b(1), \bcreat\b(2), \bpathchk\b(2)]"
+;
+
+
+#include <cmd.h>
+#include <ls.h>
+
+#define isport(c) (((c)>='a' && (c)<='z') || ((c)>='A' && (c)<='Z') || ((c)>='0' && (c)<='9') || (strchr("._-",(c))!=0) )
+
+/*
+ * call pathconf and handle unlimited sizes
+ */
+static long mypathconf(const char *path, int op)
+{
+ register long r;
+
+ static const char* ops[] = { "NAME_MAX", "PATH_MAX" };
+
+ errno=0;
+ if((r=strtol(astconf(ops[op], path, NiL), NiL, 0))<0 && errno==0)
+ return(LONG_MAX);
+ return(r);
+}
+
+/*
+ * returns 1 if <path> passes test
+ */
+static int pathchk(char* path, int mode)
+{
+ register char *cp=path, *cpold;
+ register int c;
+ register long r,name_max,path_max;
+ char buf[2];
+
+ if(!*path)
+ {
+ error(2,"path is empty");
+ return(0);
+ }
+ if(mode)
+ {
+ name_max = _POSIX_NAME_MAX;
+ path_max = _POSIX_PATH_MAX;
+ }
+ else
+ {
+ char tmp[2];
+ name_max = path_max = 0;
+ tmp[0] = (*cp=='/'? '/': '.');
+ tmp[1] = 0;
+ if((r=mypathconf(tmp, 0)) > _POSIX_NAME_MAX)
+ name_max = r;
+ if((r=mypathconf(tmp, 1)) > _POSIX_PATH_MAX)
+ path_max = r;
+ if(*cp!='/')
+ {
+ if(name_max==0||path_max==0)
+ {
+ if(!(cpold = getcwd((char*)0, 0)) && errno == EINVAL && (cpold = newof(0, char, PATH_MAX, 0)) && !getcwd(cpold, PATH_MAX))
+ {
+ free(cpold);
+ cpold = 0;
+ }
+ if(cpold)
+ {
+ cp = cpold + strlen(cpold);
+ while(name_max==0 || path_max==0)
+ {
+ if(cp>cpold)
+ while(--cp>cpold && *cp=='/');
+ *++cp = 0;
+ if(name_max==0 && (r=mypathconf(cpold, 0)) > _POSIX_NAME_MAX)
+ name_max = r;
+ if(path_max==0 && (r=mypathconf(cpold, 1)) > _POSIX_PATH_MAX)
+ path_max=r;
+ if(--cp==cpold)
+ {
+ free(cpold);
+ break;
+ }
+ while(*cp!='/')
+ cp--;
+ }
+ cp=path;
+ }
+ }
+ while(*cp=='/')
+ cp++;
+ }
+ if(name_max==0)
+ name_max=_POSIX_NAME_MAX;
+ if(path_max==0)
+ path_max=_POSIX_PATH_MAX;
+ while(*(cpold=cp))
+ {
+ while((c= *cp++) && c!='/');
+ if((cp-cpold) > name_max)
+ goto err;
+ errno=0;
+ cp[-1] = 0;
+ r = mypathconf(path, 0);
+ if((cp[-1]=c)==0)
+ cp--;
+ else while(*cp=='/')
+ cp++;
+ if(r>=0)
+ name_max=(r<_POSIX_NAME_MAX?_POSIX_NAME_MAX:r);
+ else if(errno==EINVAL)
+ continue;
+#ifdef ENAMETOOLONG
+ else if(errno==ENAMETOOLONG)
+ {
+ error(2,"%s: pathname too long",path);
+ return(0);
+ }
+#endif /*ENAMETOOLONG*/
+ else
+ break;
+ }
+ }
+ while(*(cpold=cp))
+ {
+ if(mode && *cp == '-')
+ {
+ error(2,"%s: path component begins with '-'",path,fmtquote(buf, NiL, "'", 1, 0));
+ return(0);
+ }
+ while((c= *cp++) && c!='/')
+ if(mode && !isport(c))
+ {
+ buf[0] = c;
+ buf[1] = 0;
+ error(2,"%s: '%s' not in portable character set",path,fmtquote(buf, NiL, "'", 1, 0));
+ return(0);
+ }
+ if((cp-cpold) > name_max)
+ goto err;
+ if(c==0)
+ break;
+ while(*cp=='/')
+ cp++;
+ }
+ if((cp-path) >= path_max)
+ {
+ error(2,"%s: pathname too long",path);
+ return(0);
+ }
+ return(1);
+err:
+ error(2,"%s: component name %.*s too long",path,cp-cpold-1,cpold);
+ return(0);
+}
+
+int
+b_pathchk(int argc, char** argv, void* context)
+{
+ register int n, mode=0;
+ register char *cp;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ while (n = optget(argv, usage)) switch (n)
+ {
+ case 'p':
+ mode = 1;
+ break;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ if(*argv==0 || error_info.errors)
+ error(ERROR_usage(2),"%s", optusage((char*)0));
+ while(cp = *argv++)
+ {
+ if(!pathchk(cp,mode))
+ error_info.errors=1;
+ }
+ return(error_info.errors);
+}
diff --git a/usr/src/lib/libcmd/common/rev.c b/usr/src/lib/libcmd/common/rev.c
new file mode 100644
index 0000000000..ce3f2ae425
--- /dev/null
+++ b/usr/src/lib/libcmd/common/rev.c
@@ -0,0 +1,128 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * rev [-l] [file ...]
+ *
+ * reverse the characters or lines of one or more files
+ *
+ * David Korn
+ * AT&T Laboratories
+ * dgk@research.att.com
+ *
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: rev (AT&T Research) 1999-04-10 $\n]"
+USAGE_LICENSE
+"[+NAME?rev - reverse the characters or lines of one or more files]"
+"[+DESCRIPTION?\brev\b copies one or more files to standard output "
+ "reversing the order of characters on every line of the file "
+ "or reversing the order of lines of the file if \b-l\b is specified.]"
+"[+?If no \afile\a is given, or if the \afile\a is \b-\b, \brev\b "
+ "copies from standard input starting at the current offset.]"
+"[l:line?Reverse the lines of the file.]"
+
+"\n"
+"\n[file ...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?All files copied successfully.]"
+ "[+>0?One or more files did not copy.]"
+"}"
+"[+SEE ALSO?\bcat\b(1), \btail\b(1)]"
+;
+
+#include <cmd.h>
+#include <rev.h>
+
+/*
+ * reverse the characters within a line
+ */
+static int rev_char(Sfio_t *in, Sfio_t *out)
+{
+ register int c;
+ register char *ep, *bp, *cp;
+ register int n;
+ while(cp = bp = sfgetr(in,'\n',0))
+ {
+ ep = bp + (n=sfvalue(in)) -1;
+ while(ep > bp)
+ {
+ c = *--ep;
+ *ep = *bp;
+ *bp++ = c;
+ }
+ if(sfwrite(out,cp,n)<0)
+ return(-1);
+ }
+ return(0);
+}
+
+int
+b_rev(int argc, register char** argv, void* context)
+{
+ register Sfio_t *fp;
+ register char *cp;
+ register int n, line=0;
+ NOT_USED(argc);
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ while (n = optget(argv, usage)) switch (n)
+ {
+ case 'l':
+ line=1;
+ break;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ if(error_info.errors)
+ error(ERROR_usage(2),"%s",optusage((char*)0));
+ n=0;
+ if(cp = *argv)
+ argv++;
+ do
+ {
+ if(!cp || streq(cp,"-"))
+ fp = sfstdin;
+ else if(!(fp = sfopen((Sfio_t*)0,cp,"r")))
+ {
+ error(ERROR_system(0),"%s: cannot open",cp);
+ n=1;
+ continue;
+ }
+ if(line)
+ line = rev_line(fp,sfstdout,sftell(fp));
+ else
+ line = rev_char(fp,sfstdout);
+ if(fp!=sfstdin)
+ sfclose(fp);
+ if(line < 0)
+ error(ERROR_system(1),"write failed");
+ }
+ while(cp= *argv++);
+ return(n);
+}
diff --git a/usr/src/lib/libcmd/common/rev.h b/usr/src/lib/libcmd/common/rev.h
new file mode 100644
index 0000000000..1ea6d55277
--- /dev/null
+++ b/usr/src/lib/libcmd/common/rev.h
@@ -0,0 +1,34 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * rev common definitions
+ */
+
+#ifndef _REVLIB_H
+#define _REVLIB_H
+
+#define rev_line _cmd_revline
+
+extern int rev_line(Sfio_t*, Sfio_t*, off_t);
+
+#endif
diff --git a/usr/src/lib/libcmd/common/revlib.c b/usr/src/lib/libcmd/common/revlib.c
new file mode 100644
index 0000000000..3693d15b2d
--- /dev/null
+++ b/usr/src/lib/libcmd/common/revlib.c
@@ -0,0 +1,112 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * common support for tail and rev
+ */
+
+#include <cmd.h>
+#include <rev.h>
+
+#define BUFSIZE SF_BUFSIZE
+#define rounddown(n,size) (((n)-1)&~((size)-1))
+
+/*
+ * copy the lines starting at offset <start> from in <in> to <out>
+ * in reverse order
+ */
+int rev_line(Sfio_t *in, Sfio_t *out, off_t start)
+{
+ register char *cp, *cpold;
+ register int n, nleft=0;
+ char buff[BUFSIZE];
+ off_t offset;
+ if(sfseek(in,(off_t)0,SEEK_CUR) < 0)
+ {
+ Sfio_t *tmp = sftmp(4*SF_BUFSIZE);
+ if(!tmp)
+ return(-1);
+ if(start>0 && sfmove(in, (Sfio_t*)0, start, -1) != start)
+ return(-1);
+ if(sfmove(in, tmp, SF_UNBOUND, -1) < 0 || !sfeof(in) || sferror(tmp))
+ return(-1);
+ in = tmp;
+ start=0;
+ }
+ if((offset = sfseek(in,(off_t)0,SEEK_END)) <= start)
+ return(0);
+ offset = rounddown(offset,BUFSIZE);
+ while(1)
+ {
+ n = BUFSIZE;
+ if(offset < start)
+ {
+ n -= (start-offset);
+ offset = start;
+ }
+ sfseek(in, offset, SEEK_SET);
+ if((n=sfread(in, buff, n)) <=0)
+ break;
+ cp = buff+n;
+ n = *buff;
+ *buff = '\n';
+ while(1)
+ {
+ cpold = cp;
+ if(nleft==0)
+ cp--;
+ if(cp==buff)
+ {
+ nleft= 1;
+ break;
+ }
+ while(*--cp != '\n');
+ if(cp==buff && n!='\n')
+ {
+ *cp = n;
+ nleft += cpold-cp;
+ break;
+ }
+ else
+ cp++;
+ if(sfwrite(out,cp,cpold-cp) < 0)
+ return(-1);
+ if(nleft)
+ {
+ if(nleft==1)
+ sfputc(out,'\n');
+ else if(sfmove(in,out,nleft,-1) != nleft)
+ return(-1);
+ nleft = 0;
+ }
+ }
+ if(offset <= start)
+ break;
+ offset -= BUFSIZE;
+ }
+ if(nleft)
+ {
+ sfseek(in, start, SEEK_SET);
+ if(sfmove(in,out,nleft,-1) != nleft)
+ return(-1);
+ }
+ return(0);
+}
diff --git a/usr/src/lib/libcmd/common/rm.c b/usr/src/lib/libcmd/common/rm.c
new file mode 100644
index 0000000000..62cf8a8b2f
--- /dev/null
+++ b/usr/src/lib/libcmd/common/rm.c
@@ -0,0 +1,414 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * rm [-fir] [file ...]
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: rm (AT&T Research) 2006-11-21 $\n]"
+USAGE_LICENSE
+"[+NAME?rm - remove files]"
+"[+DESCRIPTION?\brm\b removes the named \afile\a arguments. By default it"
+" does not remove directories. If a file is unwritable, the"
+" standard input is a terminal, and the \b--force\b option is not"
+" given, \brm\b prompts the user for whether to remove the file."
+" An affirmative response (\by\b or \bY\b) removes the file, a quit"
+" response (\bq\b or \bQ\b) causes \brm\b to exit immediately, and"
+" all other responses skip the current file.]"
+
+"[c|F:clear|clobber?Clear the contents of each file before removing by"
+" writing a 0 filled buffer the same size as the file, executing"
+" \bfsync\b(2) and closing before attempting to remove. Implemented"
+" only on systems that support \bfsync\b(2).]"
+"[d:directory?\bremove\b(3) (or \bunlink\b(2)) directories rather than"
+" \brmdir\b(2), and don't require that they be empty before removal."
+" The caller requires sufficient privilege, not to mention a strong"
+" constitution, to use this option. Even though the directory must"
+" not be empty, \brm\b still attempts to empty it before removal.]"
+"[f:force?Ignore nonexistent files and never prompt the user.]"
+"[i:interactive|prompt?Prompt whether to remove each file."
+" An affirmative response (\by\b or \bY\b) removes the file, a quit"
+" response (\bq\b or \bQ\b) causes \brm\b to exit immediately, and"
+" all other responses skip the current file.]"
+"[r|R:recursive?Remove the contents of directories recursively.]"
+"[u:unconditional?If \b--recursive\b and \b--force\b are also enabled then"
+" the owner read, write and execute modes are enabled (if not already"
+" enabled) for each directory before attempting to remove directory"
+" contents.]"
+"[v:verbose?Print the name of each file before removing it.]"
+
+"\n"
+"\nfile ...\n"
+"\n"
+
+"[+SEE ALSO?\bmv\b(1), \brmdir\b(2), \bunlink\b(2), \bremove\b(3)]"
+;
+
+#include <cmd.h>
+#include <ls.h>
+#include <fts.h>
+#include <fs3d.h>
+
+#define RM_ENTRY 1
+
+#define beenhere(f) (((f)->fts_number>>1)==(f)->fts_statp->st_nlink)
+#define isempty(f) (!((f)->fts_number&RM_ENTRY))
+#define nonempty(f) ((f)->fts_parent->fts_number|=RM_ENTRY)
+#define pathchunk(n) roundof(n,1024)
+#define retry(f) ((f)->fts_number=((f)->fts_statp->st_nlink<<1))
+
+typedef struct State_s /* program state */
+{
+ int clobber; /* clear out file data first */
+ int directory; /* remove(dir) not rmdir(dir) */
+ int force; /* force actions */
+ int fs3d; /* 3d enabled */
+ int interactive; /* prompt for approval */
+ int recursive; /* remove subtrees too */
+ int terminal; /* attached to terminal */
+ int uid; /* caller uid */
+ int unconditional; /* enable dir rwx on preorder */
+ int verbose; /* display each file */
+#if _lib_fsync
+ char buf[SF_BUFSIZE];/* clobber buffer */
+#endif
+} State_t;
+
+/*
+ * remove a single file
+ */
+
+static int
+rm(State_t* state, register FTSENT* ent)
+{
+ register char* path;
+ register int n;
+ int v;
+ struct stat st;
+
+ if (cmdquit())
+ return -1;
+ if (ent->fts_info == FTS_NS || ent->fts_info == FTS_ERR || ent->fts_info == FTS_SLNONE)
+ {
+ if (!state->force)
+ error(2, "%s: not found", ent->fts_path);
+ }
+ else if (state->fs3d && iview(ent->fts_statp))
+ fts_set(NiL, ent, FTS_SKIP);
+ else switch (ent->fts_info)
+ {
+ case FTS_DNR:
+ case FTS_DNX:
+ if (state->unconditional)
+ {
+ if (!chmod(ent->fts_name, (ent->fts_statp->st_mode & S_IPERM)|S_IRWXU))
+ {
+ fts_set(NiL, ent, FTS_AGAIN);
+ break;
+ }
+ error_info.errors++;
+ }
+ else if (!state->force)
+ error(2, "%s: cannot %s directory", ent->fts_path, (ent->fts_info & FTS_NR) ? "read" : "search");
+ else
+ error_info.errors++;
+ fts_set(NiL, ent, FTS_SKIP);
+ nonempty(ent);
+ break;
+ case FTS_D:
+ case FTS_DC:
+ path = ent->fts_name;
+ if (path[0] == '.' && (!path[1] || path[1] == '.' && !path[2]) && (ent->fts_level > 0 || path[1]))
+ {
+ fts_set(NiL, ent, FTS_SKIP);
+ if (!state->force)
+ error(2, "%s: cannot remove", ent->fts_path);
+ else
+ error_info.errors++;
+ break;
+ }
+ if (!state->recursive)
+ {
+ fts_set(NiL, ent, FTS_SKIP);
+ error(2, "%s: directory", ent->fts_path);
+ break;
+ }
+ if (!beenhere(ent))
+ {
+ if (state->unconditional && (ent->fts_statp->st_mode ^ S_IRWXU))
+ chmod(path, (ent->fts_statp->st_mode & S_IPERM)|S_IRWXU);
+ if (ent->fts_level > 0)
+ {
+ char* s;
+
+ if (ent->fts_accpath == ent->fts_name || !(s = strrchr(ent->fts_accpath, '/')))
+ v = !stat(".", &st);
+ else
+ {
+ path = ent->fts_accpath;
+ *s = 0;
+ v = !stat(path, &st);
+ *s = '/';
+ }
+ if (v)
+ v = st.st_nlink <= 2 || st.st_ino == ent->fts_parent->fts_statp->st_ino && st.st_dev == ent->fts_parent->fts_statp->st_dev || strchr(astconf("PATH_ATTRIBUTES", path, NiL), 'l');
+ }
+ else
+ v = 1;
+ if (v)
+ {
+ if (state->interactive)
+ {
+ if ((v = astquery(-1, "remove directory %s? ", ent->fts_path)) < 0)
+ return -1;
+ if (v > 0)
+ {
+ fts_set(NiL, ent, FTS_SKIP);
+ nonempty(ent);
+ }
+ }
+ if (ent->fts_info == FTS_D)
+ break;
+ }
+ else
+ {
+ ent->fts_info = FTS_DC;
+ error(1, "%s: hard link to directory", ent->fts_path);
+ }
+ }
+ else if (ent->fts_info == FTS_D)
+ break;
+ /*FALLTHROUGH*/
+ case FTS_DP:
+ if (isempty(ent) || state->directory)
+ {
+ path = ent->fts_name;
+ if (path[0] != '.' || path[1])
+ {
+ path = ent->fts_accpath;
+ if (state->verbose)
+ sfputr(sfstdout, ent->fts_path, '\n');
+ if ((ent->fts_info == FTS_DC || state->directory) ? remove(path) : rmdir(path))
+ switch (errno)
+ {
+ case EEXIST:
+#if defined(ENOTEMPTY) && (ENOTEMPTY) != (EEXIST)
+ case ENOTEMPTY:
+#endif
+ if (ent->fts_info == FTS_DP && !beenhere(ent))
+ {
+ retry(ent);
+ fts_set(NiL, ent, FTS_AGAIN);
+ break;
+ }
+ /*FALLTHROUGH*/
+ default:
+ nonempty(ent);
+ if (!state->force)
+ error(ERROR_SYSTEM|2, "%s: directory not removed", ent->fts_path);
+ else
+ error_info.errors++;
+ break;
+ }
+ }
+ else if (!state->force)
+ error(2, "%s: cannot remove", ent->fts_path);
+ else
+ error_info.errors++;
+ }
+ else
+ {
+ nonempty(ent);
+ if (!state->force)
+ error(2, "%s: directory not removed", ent->fts_path);
+ else
+ error_info.errors++;
+ }
+ break;
+ default:
+ path = ent->fts_accpath;
+ if (state->verbose)
+ sfputr(sfstdout, ent->fts_path, '\n');
+ if (state->interactive)
+ {
+ if ((v = astquery(-1, "remove %s? ", ent->fts_path)) < 0)
+ return -1;
+ if (v > 0)
+ {
+ nonempty(ent);
+ break;
+ }
+ }
+ else if (!state->force && state->terminal && S_ISREG(ent->fts_statp->st_mode))
+ {
+ if ((n = open(path, O_RDWR)) < 0)
+ {
+ if (
+#ifdef ENOENT
+ errno != ENOENT &&
+#endif
+#ifdef EROFS
+ errno != EROFS &&
+#endif
+ (v = astquery(-1, "override protection %s for %s? ",
+#ifdef ETXTBSY
+ errno == ETXTBSY ? "``running program''" :
+#endif
+ ent->fts_statp->st_uid != state->uid ? "``not owner''" :
+ fmtmode(ent->fts_statp->st_mode & S_IPERM, 0) + 1, ent->fts_path)) < 0)
+ return -1;
+ if (v > 0)
+ {
+ nonempty(ent);
+ break;
+ }
+ }
+ else
+ close(n);
+ }
+#if _lib_fsync
+ if (state->clobber && S_ISREG(ent->fts_statp->st_mode) && ent->fts_statp->st_size > 0)
+ {
+ if ((n = open(path, O_WRONLY)) < 0)
+ error(ERROR_SYSTEM|2, "%s: cannot clear data", ent->fts_path);
+ else
+ {
+ off_t c = ent->fts_statp->st_size;
+
+ for (;;)
+ {
+ if (write(n, state->buf, sizeof(state->buf)) != sizeof(state->buf))
+ {
+ error(ERROR_SYSTEM|2, "%s: data clear error", ent->fts_path);
+ break;
+ }
+ if (c <= sizeof(state->buf))
+ break;
+ c -= sizeof(state->buf);
+ }
+ fsync(n);
+ close(n);
+ }
+ }
+#endif
+ if (remove(path))
+ {
+ nonempty(ent);
+ if (!state->force || state->interactive)
+ error(ERROR_SYSTEM|2, "%s: not removed", ent->fts_path);
+ else
+ error_info.errors++;
+ }
+ break;
+ }
+ return 0;
+}
+
+int
+b_rm(int argc, register char** argv, void* context)
+{
+ State_t state;
+ FTS* fts;
+ FTSENT* ent;
+ int set3d;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, ERROR_NOTIFY);
+ memset(&state, 0, sizeof(state));
+ state.fs3d = fs3d(FS3D_TEST);
+ state.terminal = isatty(0);
+ for (;;)
+ {
+ switch (optget(argv, usage))
+ {
+ case 'd':
+ state.directory = 1;
+ continue;
+ case 'f':
+ state.force = 1;
+ state.interactive = 0;
+ continue;
+ case 'i':
+ state.interactive = 1;
+ state.force = 0;
+ continue;
+ case 'r':
+ case 'R':
+ state.recursive = 1;
+ continue;
+ case 'F':
+#if _lib_fsync
+ state.clobber = 1;
+#else
+ error(1, "%s not implemented on this system", opt_info.name);
+#endif
+ continue;
+ case 'u':
+ state.unconditional = 1;
+ continue;
+ case 'v':
+ state.verbose = 1;
+ continue;
+ case '?':
+ error(ERROR_USAGE|4, "%s", opt_info.arg);
+ continue;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ continue;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ if (*argv && streq(*argv, "-") && !streq(*(argv - 1), "--"))
+ argv++;
+ if (error_info.errors || !*argv)
+ error(ERROR_USAGE|4, "%s", optusage(NiL));
+
+ /*
+ * do it
+ */
+
+ if (state.interactive)
+ state.verbose = 0;
+ state.uid = geteuid();
+ state.unconditional = state.unconditional && state.recursive && state.force;
+ if (state.recursive && state.fs3d)
+ {
+ set3d = state.fs3d;
+ state.fs3d = 0;
+ fs3d(0);
+ }
+ else
+ set3d = 0;
+ if (fts = fts_open(argv, FTS_PHYSICAL, NiL))
+ {
+ while ((ent = fts_read(fts)) && !rm(&state, ent));
+ fts_close(fts);
+ }
+ else if (!state.force)
+ error(ERROR_SYSTEM|2, "%s: cannot remove", argv[0]);
+ if (set3d)
+ fs3d(set3d);
+ return error_info.errors != 0;
+}
diff --git a/usr/src/lib/libcmd/common/rmdir.c b/usr/src/lib/libcmd/common/rmdir.c
new file mode 100644
index 0000000000..4edcda4df8
--- /dev/null
+++ b/usr/src/lib/libcmd/common/rmdir.c
@@ -0,0 +1,122 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * rmdir
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: rmdir (AT&T Research) 2006-08-24 $\n]"
+USAGE_LICENSE
+"[+NAME?rmdir - remove empty directories]"
+"[+DESCRIPTION?\brmdir\b deletes each given directory. The directory "
+ "must be empty; containing no entries other than \b.\b or \b..\b. "
+ "If a directory and a subdirectory of that directory are specified "
+ "as operands, the subdirectory must be specified before the parent "
+ "so that the parent directory will be empty when \brmdir\b attempts "
+ "to remove it.]"
+"[e:ignore-fail-on-non-empty?Ignore each non-empty directory failure.]"
+"[p:parents?Remove each explicit \adirectory\a argument directory that "
+ "becomes empty after its child directories are removed.]"
+"[s:suppress?Suppress the message printed on the standard error when "
+ "\b-p\b is in effect.]"
+"\n"
+"\ndirectory ...\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?All directories deleted successfully.]"
+ "[+>0?One or more directories could not be deleted.]"
+"}"
+"[+SEE ALSO?\bmkdir\b(1), \brm\b(1), \brmdir\b(2), \bunlink\b(2)]"
+;
+
+#include <cmd.h>
+
+int
+b_rmdir(int argc, char** argv, void* context)
+{
+ register char* dir;
+ register char* end;
+ register int n;
+ int eflag = 0;
+ int pflag = 0;
+ int sflag = 0;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ while (n = optget(argv, usage)) switch (n)
+ {
+ case 'e':
+ eflag = 1;
+ break;
+ case 'p':
+ pflag = 1;
+ break;
+ case 's':
+ sflag = 1;
+ break;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ if (error_info.errors || !*argv)
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ if (!pflag)
+ sflag = 0;
+ while (dir = *argv++)
+ {
+ end = dir;
+ if (pflag) end += strlen(dir);
+ n = 0;
+ for (;;)
+ {
+ if (rmdir(dir) < 0)
+ {
+ if (!eflag || errno != EEXIST
+#ifdef ENOTEMPTY
+ && errno != ENOTEMPTY
+#endif
+ )
+ {
+ if (sflag)
+ error_info.errors++;
+ else
+ error(ERROR_system(0), "%s: cannot remove", dir);
+ }
+ break;
+ }
+ if (n) *end = '/';
+ else n = 1;
+ do if (end <= dir) goto next; while (*--end != '/');
+ do if (end <= dir) goto next; while (*(end - 1) == '/' && end--);
+ *end = 0;
+ }
+ next: ;
+ }
+ return(error_info.errors != 0);
+}
+
diff --git a/usr/src/lib/libcmd/common/stty.c b/usr/src/lib/libcmd/common/stty.c
new file mode 100644
index 0000000000..ef53c61bf7
--- /dev/null
+++ b/usr/src/lib/libcmd/common/stty.c
@@ -0,0 +1,943 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * stty.c
+ * Written by David Korn
+ * Tue Apr 4 10:46:00 EDT 1995
+ */
+
+static const char usage[] =
+"[-?@(#)$Id: stty (AT&T Research) 2006-10-31 $\n]"
+USAGE_LICENSE
+"[+NAME?stty - set or get terminal modes]"
+"[+DESCRIPTION?\bstty\b sets certain terminal I/O modes for the device "
+ "that is the current standard input; without arguments, it writes "
+ "the settings of certain modes to standard output.]"
+
+"[a:all?Writes to standard output all of the mode settings.]"
+"[g:save?Writes the current settings to standard output in a form that can "
+ "be used as an argument to another \bstty\b command. The \brows\b "
+ "and \bcolumns\b values are not included.]"
+"\n"
+"\n[mode ...]\n"
+"\n"
+"[+EXTENDED DESCRIPTION?Modes are specified either as a single name or "
+ "as a name followed by a value. As indicated below, many of the "
+ "mode names can be preceded by a \b-\b to negate its meaning. "
+ "Modes are listed by group corresponding to field in the "
+ "\btermios\b structure defined in \b<termios.h>\b. Modes "
+ "in the last group are implemented using options in the previous "
+ "groups. Note that many combinations of modes make no sense, but "
+ "no sanity checking is performed. The modes are selected from the "
+ "following:]{\fabc\f}"
+
+"[+EXIT STATUS?]{"
+ "[+0?All modes reported or set successfully.]"
+ "[+>0?Standard input not a terminaol or one or more modes failed.]"
+"}"
+"[+SEE ALSO?\btegetattr\b(2), \btcsetattr\b(2), \bioctl\b(2)]"
+;
+
+
+#include <cmd.h>
+#include <ccode.h>
+#include <ctype.h>
+#include <ast_tty.h>
+#if _sys_ioctl
+#include <sys/ioctl.h>
+#endif
+
+#define C(x) ERROR_catalog(x)
+
+#ifndef _POSIX_VDISABLE
+# define _POSIX_VDISABLE 0
+#endif
+
+#ifndef NCCS
+# ifdef NCC
+# define NCCS NCC
+# else
+# define NCCS elementsof(((struct termio*)0)->c_cc)
+# endif
+#endif
+
+/* command options */
+#define A_FLAG 1
+#define G_FLAG 2
+
+/* termios fields */
+#define C_FLAG 1
+#define C_LINE 2
+#define C_SPEED 3
+#define I_FLAG 4
+#define O_FLAG 5
+#define L_FLAG 6
+#define T_CHAR 7
+#define W_SIZE 8
+
+#define BIT 1
+#define BITS 2
+#define NUM 3
+#define CHAR 4
+#define SPEED 5
+#define SIZE 6
+#define MIXED 7
+#define SANE 8
+#define COOKED 9
+#define CASE 10
+#define TABS 11
+#define WIND 12
+
+#undef SS /* who co-opted this namespace? */
+
+#define IG 0x0001 /* ignore display */
+#define NL 0x0002 /* entry ends line of display */
+#define SS 0x0004 /* set in sane mode */
+#define US 0x0010 /* unset in sane mode */
+
+typedef struct tty_s
+{
+ const char name[8];
+ unsigned char type;
+ unsigned char field;
+ short flags;
+ unsigned long mask;
+ unsigned long val;
+ const char description[76];
+} Tty_t;
+
+static const Tty_t Ttable[] =
+{
+#ifdef CBAUD
+{ "ispeed", NUM, C_SPEED,0, CBAUD, 0, C("\an\a is the input baud rate") },
+{ "ospeed", NUM, C_SPEED,0, CBAUD, 0, C("\an\a is the output baud rate") },
+{ "speed", NUM, C_SPEED,IG, CBAUD },
+#endif
+{ "0", SPEED, C_FLAG, 0, B0 },
+{ "50", SPEED, C_FLAG, 0, B50 },
+{ "75", SPEED, C_FLAG, 0, B75 },
+{ "110", SPEED, C_FLAG, 0, B110 },
+{ "134", SPEED, C_FLAG, 0, B134 },
+{ "150", SPEED, C_FLAG, 0, B150 },
+{ "200", SPEED, C_FLAG, 0, B200 },
+{ "300", SPEED, C_FLAG, 0, B300 },
+{ "600", SPEED, C_FLAG, 0, B600 },
+{ "1200", SPEED, C_FLAG, 0, B1200 },
+{ "1800", SPEED, C_FLAG, 0, B1800 },
+{ "2400", SPEED, C_FLAG, 0, B2400 },
+{ "4800", SPEED, C_FLAG, 0, B4800 },
+{ "9600", SPEED, C_FLAG, 0, B9600 },
+{ "19200", SPEED, C_FLAG, 0, B19200 },
+{ "38400", SPEED, C_FLAG, 0, B38400 },
+
+#ifdef TIOCSWINSZ
+{ "rows", WIND, W_SIZE, IG, 0, 24, C("\an\a is the number of lines for display") },
+{ "cols", WIND, W_SIZE, IG, 1, 80, C("\an\a is the number of columns for display") },
+{ "columns", WIND, W_SIZE, IG, 1, 80, C("Same as \bcols\b") },
+#endif
+{ "intr", CHAR, T_CHAR, SS, VINTR, 'C', C("Send an interrupt signal") },
+{ "quit", CHAR, T_CHAR, SS, VQUIT, '|', C("Send a quit signal") },
+{ "erase", CHAR, T_CHAR, SS, VERASE, 'H', C("Erase the last character entered") },
+{ "kill", CHAR, T_CHAR, NL|SS, VKILL, 'U', C("Erase the current line") },
+{ "eof", CHAR, T_CHAR, SS, VEOF, 'D', C("Send an end of file") },
+#ifdef VEOL2
+{ "eol2", CHAR, T_CHAR, US, VEOL2, _POSIX_VDISABLE, C("Alternate character to end the line") },
+#endif /* VEOL2 */
+#ifdef VSWTCH
+{ "swtch", CHAR, T_CHAR, US, VSWTCH, _POSIX_VDISABLE, C("Switch to a different shell layer") },
+#endif /* VSWTCH */
+{ "eol", CHAR, T_CHAR, NL|US, VEOL, _POSIX_VDISABLE, C("End the line") },
+#ifdef VSTART
+{ "start", CHAR, T_CHAR, SS, VSTART, 'Q', C("Restart the output after stopping it") },
+#endif /* VSTART */
+#ifdef VSTOP
+{ "stop", CHAR, T_CHAR, SS, VSTOP, 'S', C("Stop the output") },
+#endif /* VSTOP */
+#ifdef VDSUSP
+{ "dsusp", CHAR, T_CHAR, SS, VDSUSP, 'Y', C("Send a terminal stop signal after flushing the input") },
+#endif /* VDSUSP */
+#ifdef VSUSP
+{ "susp", CHAR, T_CHAR, NL|SS, VSUSP, 'Z', C("Send a terminal stop signal") },
+#endif /* VSUSP */
+#ifdef VREPRINT
+{ "rprnt", CHAR, T_CHAR, SS, VREPRINT, 'R', C("Redraw the current line") },
+#endif /* VREPRINT */
+#ifdef VDISCARD
+{ "flush", CHAR, T_CHAR, SS, VDISCARD, 'O', C("Discard output") },
+#endif /* VDISCARD */
+#ifdef VWERASE
+{ "werase", CHAR, T_CHAR, SS, VWERASE, 'W', C("Erase the last word entered") },
+#endif /* VWERASE */
+#ifdef VLNEXT
+{ "lnext", CHAR, T_CHAR, NL|SS, VLNEXT, 'V', C("Enter the next input character literally") },
+#endif /* VLNEXT */
+
+#if _mem_c_line_termios
+{ "line", NUM, C_LINE, 0, 0, 0, C("Line discipline number") },
+#endif
+{ "min", NUM, T_CHAR, 0, VMIN, 0, C("Mininmum number of characters to read in raw mode") },
+{ "time", NUM, T_CHAR, 0, VTIME, 0, C("Number of .1 second intervals with raw mode") },
+
+{ "parenb", BIT, C_FLAG, 0, PARENB, PARENB, C("Enable (disable) parity generation and detection") },
+{ "parodd", BIT, C_FLAG, 0, PARODD, PARODD, C("Use odd (even) parity") },
+#ifdef PAREXT
+{ "parext", BIT, C_FLAG, 0, PAREXT, PAREXT },
+#endif /* PAREXT */
+#ifdef CREAD
+{ "cread", BIT, C_FLAG, SS, CREAD, CREAD, C("Enable (disable) input") },
+#endif /* CREAD */
+{ "cs5", SIZE, C_FLAG, 0, CSIZE, CS5 , C("Char size 5") },
+{ "cs6", SIZE, C_FLAG, 0, CSIZE, CS6 , C("Char size 6") },
+{ "cs7", SIZE, C_FLAG, 0, CSIZE, CS7 , C("Char size 7") },
+{ "cs8", SIZE, C_FLAG, 0, CSIZE, CS8 , C("Char size 8") },
+{ "hupcl", BIT, C_FLAG, 0, HUPCL, HUPCL, C("Hangup (do not hangup) connection on last close") },
+{ "hup", BIT, C_FLAG, IG, HUPCL, HUPCL, C("Same as \bhupcl\b") },
+{ "cstopb", BIT, C_FLAG, 0, CSTOPB, CSTOPB, C("Use two (one) stop bits") },
+#ifdef CRTSCTS
+{ "crtscts", BIT, C_FLAG, 0, CRTSCTS, CRTSCTS, C("Enable (disable) RTS/CTS handshaking") },
+#endif /* CRTSCTS */
+{ "clocal", BIT, C_FLAG, NL, CLOCAL, CLOCAL, C("Disable (enable) modem control signals") },
+
+{ "ignbrk", BIT, I_FLAG, US, IGNBRK, IGNBRK, C("Ignore (do not ignore) break characters") },
+{ "brkint", BIT, I_FLAG, SS, BRKINT, BRKINT, C("Generate (do not generate) INTR signal on break") },
+{ "ignpar", BIT, I_FLAG, 0, IGNPAR, IGNPAR, C("Ignore (do not ignore) characters with parity errors") },
+{ "parmrk", BIT, I_FLAG, 0, PARMRK, PARMRK, C("Mark (do not mark) parity errors") },
+{ "inpck", BIT, I_FLAG, 0, INPCK, INPCK, C("Enable (disable) input parity checking") },
+{ "istrip", BIT, I_FLAG, 0, ISTRIP, ISTRIP, C("Clear (do not clear) high bit of input characters") },
+{ "inlcr", BIT, I_FLAG, US, INLCR, INLCR, C("Translate (do not translate) carriage return to newline") },
+{ "igncr", BIT, I_FLAG, US, IGNCR, IGNCR, C("Ignore (do not ignore) carriage return") },
+#ifdef IUCLC
+{ "iuclc", BIT, I_FLAG, US, IUCLC, IUCLC, C("Map (do not map) upper-case to lower case") },
+#endif /* IUCLC */
+{ "ixon", BIT, I_FLAG, 0, IXON, IXON, C("Enable (disable) XON/XOFF flow control. \bstop\b character stops output") },
+#ifdef IXANY
+{ "ixany", BIT, I_FLAG, US, IXANY, IXANY, C("Any character (only start character) can restart output.") },
+{ "decctlq", BIT, I_FLAG, IG, IXANY, 0, C("Same as \b-ixany\b") },
+#endif /* IXANY */
+{ "ixoff", BIT, I_FLAG, US, IXOFF, IXOFF, C("Disable (enable) XON/XOFF flow control") },
+#ifdef IMAXBEL
+{ "imaxbel", BIT, I_FLAG, SS, IMAXBEL, IMAXBEL, C("Beep (do not beep) if a character arrives with full input buffer") },
+#endif /* IMAXBEL */
+{ "icrnl", BIT, I_FLAG, NL|SS, ICRNL, ICRNL, C("Translate (do not translate) carriage return to newline") },
+
+{ "isig", BIT, L_FLAG, SS, ISIG, ISIG, C("Enable (disable) \bintr\b, \bquit\b, and \bsusp\b special characters") },
+{ "icanon", BIT, L_FLAG, SS, ICANON, ICANON, C("Enable (disable) \berase\b, \bkill\b, \bwerase\b, and \brprnt\b special characters") },
+{ "icannon", BIT, L_FLAG, SS, ICANON, ICANON },
+#ifdef IEXTEN
+{ "iexten", BIT, L_FLAG, SS, IEXTEN, IEXTEN, C("Enable (disable) non-POSIX special characters") },
+#endif /* IEXTEN */
+{ "echo", BIT, L_FLAG, SS, ECHO|ECHONL, ECHO|ECHONL, C("Echo (do not echo) input characters") },
+{ "echoe", BIT, L_FLAG, SS, ECHOE, ECHOE, C("Echo (do not echo) erase characters as backspace-space-backspace") },
+{ "echok", BIT, L_FLAG, SS, ECHOK, ECHOK, C("Echo (do not echo) a newline after a kill character") },
+#ifdef ECHOKE
+{ "echoke", BIT, L_FLAG, SS, ECHOKE, ECHOKE, C("Echo (do not echo) a newline after a kill character") },
+#endif
+{ "lfkc", BIT, L_FLAG, IG, ECHOK, ECHOK, C("Same as \bechok\b (\b-echok\b); obsolete") },
+{ "echonl", BIT, L_FLAG, SS, ECHONL, ECHONL,"Echo (do not echo) newline even if not echoing other character" },
+#ifdef ECHOCTL
+{ "echoctl", BIT, L_FLAG, SS, ECHOCTL, ECHOCTL, C("Echo (do not echo) control characters as \b^\b\ac\a") },
+#else
+#define ECHOCTL 0
+#endif /* ECHOCTL */
+#ifdef ECHOPRT
+{ "echoprt", BIT, L_FLAG, US, ECHOPRT, ECHOPRT, C("Echo (do not echo) erased characters backward, between '\\' and '/'") },
+#else
+#define ECHOPRT 0
+#endif /* ECHOPRT */
+#ifdef XCASE
+{ "xcase", BIT, L_FLAG, US, XCASE, XCASE, C("Enable (disable) \bicanon\b uppercase as lowercase with '\\' prefix") },
+#endif /* XCASE */
+#ifdef DEFECHO
+{ "defecho", BIT, L_FLAG, 0, DEFECHO, DEFECHO },
+#endif /* DEFECHO */
+#ifdef FLUSHO
+{ "flusho", BIT, L_FLAG, 0, FLUSHO, FLUSHO, C("Discard (do not discard) written data. Cleared by subsequent input") },
+#endif /* FLUSHO */
+#ifdef PENDIN
+{ "pendin", BIT, L_FLAG, 0, PENDIN, PENDIN, C("Redisplay pending input at next read and then automatically clear \bpendin\b") },
+#endif /* PENDIN */
+{ "noflsh", BIT, L_FLAG, US, NOFLSH, NOFLSH, C("Disable (enable) flushing after \bintr\b and \bquit\b special characters") },
+#ifdef TOSTOP
+{ "tostop", BIT, L_FLAG, NL|US, TOSTOP, TOSTOP, C("Stop (do not stop) background jobs that try to write to the terminal") },
+#endif /* TOSTOP */
+#ifdef OLCUC
+{ "olcuc", BIT, O_FLAG, US, OLCUC, OLCUC, C("Translate (do not translate) lowercase characters to uppercase") },
+#endif /* OLCUC */
+#ifdef ONLCR
+{ "onlcr", BIT, O_FLAG, SS, ONLCR, ONLCR, C("Translate (do not translate) newline to carriage return-newline") },
+#endif /* ONLCR */
+#ifdef ONLRET
+{ "onlret", BIT, O_FLAG, US, ONLRET, ONLRET, C("Newline performs (does not perform) a carriage return") },
+#endif /* ONLRET */
+#ifdef OCRNL
+{ "ocrnl", BIT, O_FLAG, US, OCRNL, OCRNL, C("Translate (do not translate) carriage return to newline") },
+#endif /* OCRNL */
+#ifdef ONOCR
+{ "onocr", BIT, O_FLAG, US, ONOCR, ONOCR, C("Do not (do) print carriage returns in the first column") },
+#endif /* ONOCR */
+#ifdef OFILL
+{ "ofill", BIT, O_FLAG, US, OFILL, OFILL, C("Use fill characters (use timing) for delays") },
+#endif /* OFILL */
+#ifdef OFDEL
+{ "ofdel", BIT, O_FLAG, US, OFDEL, OFDEL, C("Use DEL (NUL) as fill characters for delays") },
+#endif /* OFDEL */
+{ "opost", BIT, O_FLAG, SS, OPOST, OPOST, C(" Postprocess (do not postprocess) output") },
+#ifdef CRDLY
+{ "cr0", BITS, O_FLAG, IG|SS, CRDLY, CR0 },
+{ "cr1", BITS, O_FLAG, US, CRDLY, CR1 },
+{ "cr2", BITS, O_FLAG, US, CRDLY, CR2 },
+{ "cr3", BITS, O_FLAG, US, CRDLY, CR3 },
+#endif
+#ifdef NLDLY
+{ "nl0", BITS, O_FLAG, IG|US, NLDLY, NL0 },
+{ "nl1", BITS, O_FLAG, US, NLDLY, NL1 },
+#endif
+#ifdef TABDLY
+{ "tabs", TABS, O_FLAG, IG, TABDLY, TAB3, C("Preserve (expand to spaces) tabs") },
+{ "tab0", BITS, O_FLAG, IG|SS, TABDLY, TAB0 },
+{ "tab1", BITS, O_FLAG, US, TABDLY, TAB1 },
+{ "tab2", BITS, O_FLAG, US, TABDLY, TAB2 },
+{ "tab3", BITS, O_FLAG, US, TABDLY, TAB3 },
+#endif
+#ifdef BSDLY
+{ "bs0", BITS, O_FLAG, IG|SS, BSDLY, BS0 },
+{ "bs1", BITS, O_FLAG, US, BSDLY, BS1 },
+#endif
+#ifdef VTDLY
+{ "vt0", BITS, O_FLAG, IG|SS, VTDLY, VT0 },
+{ "vt1", BITS, O_FLAG, US, VTDLY, VT1 },
+#endif
+#ifdef FFDLY
+{ "ff0", BITS, O_FLAG, IG|SS, FFDLY, FF0 },
+{ "ff1", BITS, O_FLAG, US, FFDLY, FF1 },
+#endif
+{ "", MIXED, O_FLAG, NL|IG },
+
+{ "evenp", MIXED, C_FLAG, IG, PARENB, 0, C("Same as \bparenb -parodd cs7\b") },
+{ "oddp", MIXED, C_FLAG, IG, PARODD, 0, C("Same as \bparenb parodd cs7\b") },
+{ "parity", MIXED, C_FLAG, IG, 0, 0, C("Same as parenb \b-parodd cs7\b") },
+{ "ek", MIXED, C_FLAG, IG, 0, 0, C("Reset the \berase\b and \bkill\b special characters to their default values") },
+{ "sane", SANE, C_FLAG, IG, 0, 0, C("Reset all modes to some reasonable values") },
+{ "cooked", COOKED, C_FLAG, IG, 0, 0, C("Disable raw input and output") },
+{ "raw", COOKED, C_FLAG, IG, 0, 0, C("Enable raw input and output") },
+{ "lcase", CASE, C_FLAG, IG, 0 , 0, C("Set \bxcase\b, \biuclc\b, and \bolcuc\b") },
+{ "LCASE", CASE, C_FLAG, IG, 0 , 0, C("Same as \blcase\b") }
+};
+
+#if CC_NATIVE == CC_ASCII
+#define cntl(x) (((x)=='?')?0177:((x)&037))
+#else
+#define cntl(x) (((x)=='?')?ccmapc(0177,CC_ASCII,CC_NATIVE):ccmapc(ccmapc(x,CC_NATIVE,CC_ASCII)&037,CC_ASCII,CC_NATIVE))
+#endif
+
+static void sane(register struct termios *sp)
+{
+ register const Tty_t* tp;
+
+ for (tp = Ttable; tp < &Ttable[elementsof(Ttable)]; tp++)
+ if (tp->flags & (SS|US))
+ switch (tp->type)
+ {
+ case BIT:
+ case BITS:
+ switch (tp->field)
+ {
+ case C_FLAG:
+ if (tp->flags & SS)
+ sp->c_cflag |= tp->mask;
+ else
+ sp->c_cflag &= ~tp->mask;
+ break;
+ case I_FLAG:
+ if (tp->flags & SS)
+ sp->c_iflag |= tp->mask;
+ else
+ sp->c_iflag &= ~tp->mask;
+ break;
+ case O_FLAG:
+ if (tp->flags & SS)
+ sp->c_oflag |= tp->mask;
+ else
+ sp->c_oflag &= ~tp->mask;
+ break;
+ case L_FLAG:
+ if (tp->flags & SS)
+ sp->c_lflag |= tp->mask;
+ else
+ sp->c_lflag &= ~tp->mask;
+ break;
+ }
+ break;
+ case CHAR:
+ sp->c_cc[tp->mask] = cntl(tp->val);
+ break;
+ }
+}
+
+static int gin(char *arg,struct termios *sp)
+{
+ register int i;
+ if(*arg++ != ':')
+ return(0);
+ sp->c_iflag = strtol(arg,&arg,16);
+ if(*arg++ != ':')
+ return(0);
+ sp->c_oflag = strtol(arg,&arg,16);
+ if(*arg++ != ':')
+ return(0);
+ sp->c_cflag = strtol(arg,&arg,16);
+ if(*arg++ != ':')
+ return(0);
+ sp->c_lflag = strtol(arg,&arg,16);
+ if(*arg++ != ':')
+ return(0);
+ for(i=0;i< NCCS; i++)
+ {
+ sp->c_cc[i] = strtol(arg,&arg,16);
+ if(*arg++ != ':')
+ return(0);
+ }
+#if _mem_c_line_termios
+ sp->c_line =
+#endif
+ strtol(arg,&arg,16);
+ if(*arg++ != ':')
+ return(0);
+ i = strtol(arg,&arg,16);
+ if(*arg++ != ':')
+ return(0);
+ cfsetispeed(sp, i);
+ i = strtol(arg,&arg,16);
+ if(*arg++ != ':')
+ return(0);
+ cfsetospeed(sp, i);
+ if(*arg)
+ return(0);
+ return(1);
+}
+
+static void gout(struct termios *sp)
+{
+ register int i;
+ sfprintf(sfstdout,":%x",sp->c_iflag);
+ sfprintf(sfstdout,":%x",sp->c_oflag);
+ sfprintf(sfstdout,":%x",sp->c_cflag);
+ sfprintf(sfstdout,":%x",sp->c_lflag);
+ for(i=0;i< NCCS; i++)
+ sfprintf(sfstdout,":%x",sp->c_cc[i]);
+#if _mem_c_line_termios
+ sfprintf(sfstdout,":%x", sp->c_line);
+#else
+ sfprintf(sfstdout,":%x", 0);
+#endif
+ sfprintf(sfstdout,":%x",cfgetispeed(sp));
+ sfprintf(sfstdout,":%x",cfgetospeed(sp));
+ sfprintf(sfstdout,":\n");
+}
+
+static void output(struct termios *sp, int flags)
+{
+ const Tty_t *tp;
+ struct termios tty;
+ register int delim = ' ';
+ register int i,off,off2;
+ char schar[2];
+ unsigned int ispeed = cfgetispeed(sp);
+ unsigned int ospeed = cfgetospeed(sp);
+ if(flags&G_FLAG)
+ {
+ gout(sp);
+ return;
+ }
+ tty = *sp;
+ sane(&tty);
+ for(i=0; i < elementsof(Ttable); i++)
+ {
+ tp= &Ttable[i];
+ if(tp->flags&IG)
+ {
+ if(tp->flags&NL)
+ sfputc(sfstdout,'\n');
+ continue;
+ }
+ switch(tp->type)
+ {
+ case BIT:
+ case BITS:
+ off = 1;
+ switch(tp->field)
+ {
+ case C_FLAG:
+ if(sp->c_cflag&tp->mask)
+ off = 0;
+ if(tty.c_cflag&tp->mask)
+ off2 = 0;
+ break;
+ case I_FLAG:
+ if(sp->c_iflag&tp->mask)
+ off = 0;
+ if(tty.c_iflag&tp->mask)
+ off2 = 0;
+ break;
+ case O_FLAG:
+ if((sp->c_oflag&tp->mask)==tp->val)
+ off = 0;
+ if(tty.c_oflag&tp->mask)
+ off2 = 0;
+ break;
+ case L_FLAG:
+ if(sp->c_lflag&tp->mask)
+ off = 0;
+ if(tty.c_lflag&tp->mask)
+ off2 = 0;
+ }
+ if(tp->flags&NL)
+ delim = '\n';
+ if(!flags && off==off2)
+ continue;
+ if(!off)
+ sfprintf(sfstdout,"%s%c",tp->name,delim);
+ else if(tp->type==BIT)
+ sfprintf(sfstdout,"-%s%c",tp->name,delim);
+ delim = ' ';
+ break;
+
+ case CHAR:
+ off = sp->c_cc[tp->mask];
+ if(tp->flags&NL)
+ delim = '\n';
+ if(!flags && off==(unsigned char)tty.c_cc[tp->mask])
+ continue;
+ if(off==_POSIX_VDISABLE)
+ sfprintf(sfstdout,"%s = <undef>;%c",tp->name,delim);
+ else if(isprint(off&0xff))
+ sfprintf(sfstdout,"%s = %c;%c",tp->name,off,delim);
+ else
+#if CC_NATIVE == CC_ASCII
+ sfprintf(sfstdout,"%s = ^%c;%c",tp->name,off==0177?'?':(off^0100),delim);
+#else
+ {
+ off = ccmapc(off, CC_NATIVE, CC_ASCII);
+ sfprintf(sfstdout,"%s = ^%c;%c",tp->name,off==0177?'?':ccmapc(off^0100,CC_ASCII,CC_NATIVE),delim);
+ }
+#endif
+ delim = ' ';
+ break;
+ case SIZE:
+ if((sp->c_cflag&CSIZE)!=tp->mask)
+ continue;
+ if(flags || (sp->c_cflag&CSIZE) != (tty.c_cflag&CSIZE))
+ sfprintf(sfstdout,"%s ",tp->name);
+ break;
+ case SPEED:
+ if(tp->mask==ispeed)
+ {
+ if(ispeed!=ospeed)
+ schar[0]='i';
+ else
+ schar[0]=0;
+ }
+ else if(tp->mask==ospeed)
+ schar[0]='o';
+ else
+ continue;
+ schar[1] = 0;
+#ifdef TIOCSWINSZ
+ {
+ struct winsize win;
+ off = ioctl(0,TIOCGWINSZ,&win);
+ if(off>=0)
+ sfprintf(sfstdout,"%sspeed %s baud; rows %d; columns %d;\n",schar,tp->name,win.ws_row,win.ws_col);
+ }
+ if(off<0)
+#endif
+ sfprintf(sfstdout,"%sspeed %s baud;\n",schar,tp->name);
+ }
+ }
+ if(delim=='\n')
+ sfputc(sfstdout,'\n');
+}
+
+static const Tty_t *lookup(const char *name)
+{
+ register int i;
+ for(i=0; i < elementsof(Ttable); i++)
+ {
+ if(strcmp(Ttable[i].name,name)==0)
+ return(&Ttable[i]);
+ }
+ return(0);
+
+}
+
+static const Tty_t *getspeed(unsigned long val)
+{
+ register int i;
+ for(i=0; i < elementsof(Ttable); i++)
+ {
+ if(Ttable[i].type==SPEED && Ttable[i].mask==val)
+ return(&Ttable[i]);
+ }
+ return(0);
+}
+
+static int gettchar(register const char *cp)
+{
+ if(*cp==0)
+ return(-1);
+ if(cp[1]==0)
+ return((unsigned)cp[0]);
+ if(*cp=='^' && cp[1] && cp[2]==0)
+ {
+ switch(cp[1])
+ {
+ case '-':
+ return(-1);
+ default:
+ return(cntl(cp[1]));
+ }
+ }
+ if(streq(cp,"undef") || streq(cp,"<undef>"))
+ return(-1);
+ return(*((unsigned char*)cp));
+}
+
+static void set(char *argv[], struct termios *sp)
+{
+ const Tty_t *tp;
+ register int c,off;
+ char *cp;
+ char *ep;
+ while(cp = *argv++)
+ {
+ off = 0;
+ if(*cp=='-')
+ {
+ cp++;
+ off=1;
+ }
+ if(!(tp=lookup(cp)) || (off && (tp->type!=BIT) && (tp->type!=TABS)))
+ error(ERROR_exit(1),"%s: unknown mode",cp);
+ switch(tp->type)
+ {
+ case CHAR:
+ if(off)
+ error(ERROR_exit(1),"%s: unknown mode",cp);
+ if(!*argv)
+ error(ERROR_exit(1),"missing argument to %s",cp);
+ c = gettchar(*argv++);
+ if(c>=0)
+ sp->c_cc[tp->mask] = c;
+ else
+ sp->c_cc[tp->mask] = _POSIX_VDISABLE;
+ break;
+ case BIT: case BITS:
+ switch(tp->field)
+ {
+ case C_FLAG:
+ if(off)
+ sp->c_cflag &= ~tp->mask;
+ else
+ sp->c_cflag |= tp->mask;
+ break;
+ case I_FLAG:
+ if(off)
+ sp->c_iflag &= ~tp->mask;
+ else
+ sp->c_iflag |= tp->mask;
+ break;
+ case O_FLAG:
+ sp->c_oflag &= ~tp->mask;
+ sp->c_oflag |= tp->val;
+ break;
+ case L_FLAG:
+ if(off)
+ sp->c_lflag &= ~tp->mask;
+ else
+ sp->c_lflag |= tp->mask;
+ break;
+ }
+ break;
+ case TABS:
+ sp->c_oflag &= ~tp->mask;
+ if(off)
+ sp->c_oflag |= tp->val;
+ break;
+#ifdef TIOCSWINSZ
+ case WIND:
+ {
+ struct winsize win;
+ int n;
+ if(ioctl(0,TIOCGWINSZ,&win)<0)
+ error(ERROR_system(1),"cannot set %s",tp->name);
+ if(!(cp= *argv))
+ {
+ sfprintf(sfstdout,"%d\n",tp->mask?win.ws_col:win.ws_row);
+ break;
+ }
+ argv++;
+ n=strtol(cp,&cp,10);
+ if(*cp)
+ error(ERROR_system(1),"%d: invalid number of %s",argv[-1],tp->name);
+ if(tp->mask)
+ win.ws_col = n;
+ else
+ win.ws_row = n;
+ if(ioctl(0,TIOCSWINSZ,&win)<0)
+ error(ERROR_system(1),"cannot set %s",tp->name);
+ break;
+ }
+#endif
+ case NUM:
+ cp = *argv;
+ if (!cp)
+ {
+ if (tp->field == C_SPEED)
+ {
+ if (tp = getspeed(*tp->name == 'i' ? cfgetispeed(sp) : cfgetospeed(sp)))
+ sfprintf(sfstdout, "%s\n", tp->name);
+ break;
+ }
+ error(ERROR_exit(1), "%s: missing numeric argument", tp->name);
+ }
+ argv++;
+ c = (int)strtol(cp, &ep, 10);
+ if (*ep)
+ error(ERROR_exit(1), "%s: %s: numeric argument expected", tp->name, cp);
+ switch (tp->field)
+ {
+#if _mem_c_line_termios
+ case C_LINE:
+ sp->c_line = c;
+ break;
+#endif
+ case C_SPEED:
+ if(getspeed(c))
+ {
+ if (*tp->name != 'o')
+ cfsetispeed(sp, c);
+ if (*tp->name != 'i')
+ cfsetospeed(sp, c);
+ }
+ else
+ error(ERROR_exit(1), "%s: %s: invalid speed", tp->name, cp);
+ break;
+ case T_CHAR:
+ sp->c_cc[tp->mask] = c;
+ break;
+ }
+ break;
+ case SPEED:
+ cfsetospeed(sp, tp->mask);
+ cfsetispeed(sp, tp->mask);
+ break;
+ case SIZE:
+ sp->c_cflag &= ~CSIZE;
+ sp->c_cflag |= tp->mask;
+ break;
+ case SANE:
+ sane(sp);
+ break;
+#if defined(OLCUC) && defined(IUCLC)
+ case CASE:
+ if(off)
+ {
+ sp->c_iflag |= IUCLC;
+ sp->c_oflag |= OLCUC;
+ }
+ else
+ {
+ sp->c_iflag &= ~IUCLC;
+ sp->c_oflag &= ~OLCUC;
+ }
+ break;
+#endif /* OLCUC && IUCLC */
+ }
+ }
+}
+
+
+static void listchars(Sfio_t *sp,int type)
+{
+ int i,c;
+ c = (type==CHAR?'c':'n');
+ for(i=0; i < elementsof(Ttable); i++)
+ {
+ if(Ttable[i].type==type && *Ttable[i].description)
+ sfprintf(sp,"[+%s \a%c\a?%s.]",Ttable[i].name,c,Ttable[i].description);
+ }
+}
+
+static void listgroup(Sfio_t *sp,int type, const char *description)
+{
+ int i;
+ sfprintf(sp,"[+");
+ for(i=0; i < elementsof(Ttable); i++)
+ {
+ if(Ttable[i].type==type)
+ sfprintf(sp,"%s ",Ttable[i].name);
+ }
+ sfprintf(sp,"?%s.]",description);
+}
+
+static void listmask(Sfio_t *sp,unsigned int mask,const char *description)
+{
+ int i;
+ sfprintf(sp,"[+");
+ for(i=0; i < elementsof(Ttable); i++)
+ {
+ if(Ttable[i].mask==mask && Ttable[i].type==BITS)
+ sfprintf(sp,"%s ",Ttable[i].name);
+ }
+ sfprintf(sp,"?%s.]",description);
+}
+
+static void listfields(Sfio_t *sp,int field)
+{
+ int i;
+ for(i=0; i < elementsof(Ttable); i++)
+ {
+ if(Ttable[i].field==field && Ttable[i].type==BIT && *Ttable[i].description)
+ sfprintf(sp,"[+%s (-%s)?%s.]",Ttable[i].name,Ttable[i].name,Ttable[i].description);
+ }
+}
+
+static void listmode(Sfio_t *sp,const char *name)
+{
+ sfprintf(sp,"[+%s?%s.]",name,lookup(name)->description);
+}
+
+static int infof(Opt_t* op, Sfio_t* sp, const char* s, Optdisc_t* dp)
+{
+ NoP(op);
+ NoP(s);
+ NoP(dp);
+ sfprintf(sp,"[+Control Modes.]{");
+ listfields(sp,C_FLAG);
+ listgroup(sp,SPEED,"Attempt to set input and output baud rate to number given. A value of \b0\b causes immediate hangup");
+ listchars(sp,NUM);
+ listgroup(sp,SIZE,"Number of bits in a character");
+ sfprintf(sp,"}[+Input Modes.]{");
+ listfields(sp,I_FLAG);
+ sfprintf(sp,"}[+Output Modes.]{");
+ listfields(sp,O_FLAG);
+#ifdef CRDLY
+ listmask(sp,CRDLY,"Carriage return delay style");
+#endif
+#ifdef NLDLY
+ listmask(sp,NLDLY,"Newline delay style");
+#endif
+#ifdef TABDLY
+ listmask(sp,TABDLY,"Horizontal tab delay style");
+#endif
+#ifdef BSDLY
+ listmask(sp,BSDLY,"Backspace delay style");
+#endif
+#ifdef FFDLY
+ listmask(sp,FFDLY,"Form feed delay style");
+#endif
+#ifdef VTDLY
+ listmask(sp,VTDLY,"Vertical tab delay style");
+#endif
+ sfprintf(sp,"}[+Local Modes.]{");
+ listfields(sp,L_FLAG);
+ sfprintf(sp,"}[+Control Assignments.?If \ac\a is \bundef\b or an empty "
+ "string then the control assignment is disabled.]{");
+ listchars(sp,WIND);
+ listchars(sp,CHAR);
+ sfprintf(sp,"}[+Combination Modes.]{");
+ listmode(sp,"ek");
+ listmode(sp,"evenp");
+ listmode(sp,"lcase");
+ listmode(sp,"oddp");
+ listmode(sp,"parity");
+ listmode(sp,"sane");
+ listmode(sp,"tabs");
+ listmode(sp,"LCASE");
+ sfputc(sp,'}');
+ return(1);
+}
+
+int
+b_stty(int argc, char** argv, void* context)
+{
+ struct termios tty;
+ register int n;
+ register int flags = 0;
+ const Tty_t* tp;
+ Optdisc_t disc;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, ERROR_INTERACTIVE);
+ if (tcgetattr(0, &tty) < 0)
+ error(ERROR_system(1),"not a tty");
+ memset(&disc, 0, sizeof(disc));
+ disc.version = OPT_VERSION;
+ disc.infof = infof;
+ opt_info.disc = &disc;
+ for (;;)
+ {
+ switch (n = optget(argv, usage))
+ {
+ case 'a':
+ case 'g':
+ if (!opt_info.offset || !argv[opt_info.index][opt_info.offset])
+ {
+ switch (n)
+ {
+ case 'a':
+ flags |= A_FLAG;
+ break;
+ case 'g':
+ flags |= G_FLAG;
+ break;
+ }
+ continue;
+ }
+ /*FALLTHROUGH*/
+ case ':':
+ if (!opt_info.offset)
+ error(2, "%s", opt_info.arg);
+ else if (!(tp = lookup(argv[opt_info.index]+1)) || (tp->type != BIT && tp->type != TABS))
+ error(ERROR_exit(1), "%s: unknown mode", argv[opt_info.index]);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ if (error_info.errors || (flags && *argv))
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ if (*argv)
+ {
+ if (!argv[1] && **argv == ':')
+ gin(*argv, &tty);
+ else
+ set(argv, &tty);
+ if (tcsetattr(0, TCSANOW, &tty) < 0)
+ error(ERROR_system(1), "cannot set tty");
+ }
+ else
+ output(&tty, flags);
+ return error_info.errors;
+}
diff --git a/usr/src/lib/libcmd/common/sum.c b/usr/src/lib/libcmd/common/sum.c
new file mode 100644
index 0000000000..3fa2e520e2
--- /dev/null
+++ b/usr/src/lib/libcmd/common/sum.c
@@ -0,0 +1,35 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * sum -- implemented by cksum
+ */
+
+#include <cmd.h>
+
+int
+b_sum(int argc, register char** argv, void* context)
+{
+ return b_cksum(argc, argv, context);
+}
diff --git a/usr/src/lib/libcmd/common/sync.c b/usr/src/lib/libcmd/common/sync.c
new file mode 100644
index 0000000000..d977048766
--- /dev/null
+++ b/usr/src/lib/libcmd/common/sync.c
@@ -0,0 +1,79 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * Glenn Fowler
+ * AT&T Research
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: sync (AT&T Research) 2006-10-04 $\n]"
+USAGE_LICENSE
+"[+NAME?sync - schedule file system updates]"
+"[+DESCRIPTION?\bsync\b calls \bsync\b(2), which causes all information "
+ "in memory that updates file systems to be scheduled for writing out to "
+ "all file systems. The writing, although scheduled, is not necessarily "
+ "complete upon return from \bsync\b.]"
+"[+?Since \bsync\b(2) has no failure indication, \bsync\b only fails for "
+ "option/operand syntax errors, or when \bsync\b(2) does not return, in "
+ "which case \bsync\b also does not return.]"
+"[+?At minimum \bsync\b should be called before halting the system. Most "
+ "systems provide graceful shutdown procedures that include \bsync\b -- "
+ "use them if possible.]"
+"[+EXIT STATUS?]"
+ "{"
+ "[+0?\bsync\b(2) returned.]"
+ "[+>0?Option/operand syntax error.]"
+ "}"
+"[+SEE ALSO?\bsync\b(2), \bshutdown\b(8)]"
+;
+
+#include <cmd.h>
+#include <ls.h>
+
+int
+b_sync(int argc, char** argv, void* context)
+{
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ for (;;)
+ {
+ switch (optget(argv, usage))
+ {
+ case ':':
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ if (error_info.errors || *argv)
+ error(ERROR_usage(2), "%s", optusage(NiL));
+#if _lib_sync
+ sync();
+#else
+ error(ERROR_usage(2), "failed -- the native system does not provide a sync(2) call");
+#endif
+ return 0;
+}
diff --git a/usr/src/lib/libcmd/common/tail.c b/usr/src/lib/libcmd/common/tail.c
new file mode 100644
index 0000000000..83de0f7c91
--- /dev/null
+++ b/usr/src/lib/libcmd/common/tail.c
@@ -0,0 +1,683 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * print the tail of one or more files
+ *
+ * David Korn
+ * Glenn Fowler
+ */
+
+static const char usage[] =
+"+[-?\n@(#)$Id: tail (AT&T Research) 2006-10-18 $\n]"
+USAGE_LICENSE
+"[+NAME?tail - output trailing portion of one or more files ]"
+"[+DESCRIPTION?\btail\b copies one or more input files to standard output "
+ "starting at a designated point for each file. Copying starts "
+ "at the point indicated by the options and is unlimited in size.]"
+"[+?By default a header of the form \b==> \b\afilename\a\b <==\b "
+ "is output before all but the first file but this can be changed "
+ "with the \b-q\b and \b-v\b options.]"
+"[+?If no \afile\a is given, or if the \afile\a is \b-\b, \btail\b "
+ "copies from standard input. The start of the file is defined "
+ "as the current offset.]"
+"[+?The option argument for \b-c\b can optionally be "
+ "followed by one of the following characters to specify a different "
+ "unit other than a single byte:]{"
+ "[+b?512 bytes.]"
+ "[+k?1-kilobyte.]"
+ "[+m?1-megabyte.]"
+ "}"
+"[+?For backwards compatibility, \b-\b\anumber\a is equivalent to "
+ "\b-n\b \anumber\a and \b+\b\anumber\a is equivalent to "
+ "\b-n -\b\anumber\a.]"
+
+"[n:lines]:[lines:=10?Copy \alines\a lines from each file. A negative value "
+ "for \alines\a indicates an offset from the start of the file.]"
+"[c:bytes]:?[chars?Copy \achars\a bytes from each file. A negative value "
+ "for \achars\a indicates an offset from the start of the file.]"
+"[f:forever|follow?Loop forever trying to read more characters as the "
+ "end of each file to copy new data. Ignored if reading from a pipe "
+ "or fifo.]"
+"[h!:headers?Output filename headers.]"
+"[L:log?When a \b--forever\b file times out via \b--timeout\b, verify that "
+ "the curent file has not been renamed and replaced by another file "
+ "of the same name (a common log file practice) before giving up on "
+ "the file.]"
+"[q:quiet?Don't output filename headers. For GNU compatibility.]"
+"[r:reverse?Output lines in reverse order.]"
+"[s:silent?Don't warn about timeout expiration and log file changes.]"
+"[t:timeout?Stop checking after \atimeout\a elapses with no additional "
+ "\b--forever\b output. A separate elapsed time is maintained for "
+ "each file operand. There is no timeout by default. The default "
+ "\atimeout\a unit is seconds. \atimeout\a may be a catenation of 1 "
+ "or more integers, each followed by a 1 character suffix. The suffix "
+ "may be omitted from the last integer, in which case it is "
+ "interpreted as seconds. The supported suffixes are:]:[timeout]{"
+ "[+s?seconds]"
+ "[+m?minutes]"
+ "[+h?hours]"
+ "[+d?days]"
+ "[+w?weeks]"
+ "[+M?months]"
+ "[+y?years]"
+ "[+S?scores]"
+ "}"
+"[v:verbose?Always ouput filename headers.]"
+"\n"
+"\n[file ...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?All files copied successfully.]"
+ "[+>0?One or more files did not copy.]"
+"}"
+"[+SEE ALSO?\bcat\b(1), \bhead\b(1), \brev\b(1)]"
+;
+
+#include <cmd.h>
+#include <ctype.h>
+#include <ls.h>
+#include <tm.h>
+#include <rev.h>
+
+#define COUNT (1<<0)
+#define ERROR (1<<1)
+#define FOLLOW (1<<2)
+#define HEADERS (1<<3)
+#define LOG (1<<4)
+#define NEGATIVE (1<<5)
+#define POSITIVE (1<<6)
+#define REVERSE (1<<7)
+#define SILENT (1<<8)
+#define TIMEOUT (1<<9)
+#define VERBOSE (1<<10)
+
+#define NOW (unsigned long)time(NiL)
+
+#define LINES 10
+
+#ifdef S_ISSOCK
+#define FIFO(m) (S_ISFIFO(m)||S_ISSOCK(m))
+#else
+#define FIFO(m) S_ISFIFO(m)
+#endif
+
+struct Tail_s; typedef struct Tail_s Tail_t;
+
+struct Tail_s
+{
+ Tail_t* next;
+ char* name;
+ Sfio_t* sp;
+ Sfoff_t last;
+ unsigned long expire;
+ long dev;
+ long ino;
+};
+
+/*
+ * if file is seekable, position file to tail location and return offset
+ * otherwise, return -1
+ */
+
+static Sfoff_t
+tailpos(register Sfio_t* fp, register Sfoff_t number, int delim)
+{
+ register size_t n;
+ register Sfoff_t offset;
+ register Sfoff_t first;
+ register Sfoff_t last;
+ register char* s;
+ register char* t;
+ struct stat st;
+
+ last = sfsize(fp);
+ if ((first = sfseek(fp, (Sfoff_t)0, SEEK_CUR)) < 0)
+ return last || fstat(sffileno(fp), &st) || st.st_size || FIFO(st.st_mode) ? -1 : 0;
+ if (delim < 0)
+ {
+ if ((offset = last - number) < first)
+ return first;
+ return offset;
+ }
+ if ((offset = last - SF_BUFSIZE) < first)
+ offset = first;
+ for (;;)
+ {
+ sfseek(fp, offset, SEEK_SET);
+ n = last - offset;
+ if (!(s = sfreserve(fp, n, SF_LOCKR)))
+ return -1;
+ t = s + n;
+ while (t > s)
+ if (*--t == delim && number-- <= 0)
+ {
+ sfread(fp, s, 0);
+ return offset + (t - s) + 1;
+ }
+ sfread(fp, s, 0);
+ if (offset == first)
+ break;
+ last = offset;
+ if ((offset = last - SF_BUFSIZE) < first)
+ offset = first;
+ }
+ return first;
+}
+
+/*
+ * this code handles tail from a pipe without any size limits
+ */
+
+static void
+pipetail(Sfio_t* infile, Sfio_t* outfile, Sfoff_t number, int delim)
+{
+ register Sfio_t* out;
+ register Sfoff_t n;
+ register Sfoff_t nleft = number;
+ register size_t a = 2 * SF_BUFSIZE;
+ register int fno = 0;
+ Sfoff_t offset[2];
+ Sfio_t* tmp[2];
+
+ if (delim < 0 && a > number)
+ a = number;
+ out = tmp[0] = sftmp(a);
+ tmp[1] = sftmp(a);
+ offset[0] = offset[1] = 0;
+ while ((n = sfmove(infile, out, number, delim)) > 0)
+ {
+ offset[fno] = sftell(out);
+ if ((nleft -= n) <= 0)
+ {
+ out = tmp[fno= !fno];
+ sfseek(out, (Sfoff_t)0, SEEK_SET);
+ nleft = number;
+ }
+ }
+ if (nleft == number)
+ {
+ offset[fno] = 0;
+ fno= !fno;
+ }
+ sfseek(tmp[0], (Sfoff_t)0, SEEK_SET);
+
+ /*
+ * see whether both files are needed
+ */
+
+ if (offset[fno])
+ {
+ sfseek(tmp[1], (Sfoff_t)0, SEEK_SET);
+ if ((n = number - nleft) > 0)
+ sfmove(tmp[!fno], NiL, n, delim);
+ if ((n = offset[!fno] - sftell(tmp[!fno])) > 0)
+ sfmove(tmp[!fno], outfile, n, -1);
+ }
+ else
+ fno = !fno;
+ sfmove(tmp[fno], outfile, offset[fno], -1);
+ sfclose(tmp[0]);
+ sfclose(tmp[1]);
+}
+
+/*
+ * (re)initialize a tail stream
+ */
+
+static int
+init(Tail_t* tp, Sfoff_t number, int delim, int flags)
+{
+ Sfoff_t offset;
+ struct stat st;
+
+ if (tp->sp)
+ {
+ offset = 0;
+ if (tp->sp == sfstdin)
+ tp->sp = 0;
+ }
+ else if (!number)
+ offset = 0;
+ else
+ offset = 1;
+ if (!tp->name || streq(tp->name, "-"))
+ {
+ tp->name = "/dev/stdin";
+ tp->sp = sfstdin;
+ }
+ else if (!(tp->sp = sfopen(tp->sp, tp->name, "r")))
+ {
+ error(ERROR_system(0), "%s: cannot open", tp->name);
+ return -1;
+ }
+ sfset(tp->sp, SF_SHARE, 0);
+ if (offset)
+ {
+ if ((offset = tailpos(tp->sp, number, delim)) < 0)
+ {
+ error(ERROR_SYSTEM|2, "%s: cannot position file to tail", tp->name);
+ goto bad;
+ }
+ sfseek(tp->sp, offset, SEEK_SET);
+ }
+ tp->last = offset;
+ if (flags & LOG)
+ {
+ if (fstat(sffileno(tp->sp), &st))
+ {
+ error(ERROR_system(0), "%s: cannot stat", tp->name);
+ goto bad;
+ }
+ tp->dev = st.st_dev;
+ tp->ino = st.st_ino;
+ }
+ return 0;
+ bad:
+ if (tp->sp != sfstdin)
+ sfclose(tp->sp);
+ tp->sp = 0;
+ return -1;
+}
+
+/*
+ * convert number with validity diagnostics
+ */
+
+static intmax_t
+num(register const char* s, char** e, int* f, int o)
+{
+ intmax_t number;
+ char* t;
+ int c;
+
+ *f &= ~(ERROR|NEGATIVE|POSITIVE);
+ if ((c = *s) == '-')
+ {
+ *f |= NEGATIVE;
+ s++;
+ }
+ else if (c == '+')
+ {
+ *f |= POSITIVE;
+ s++;
+ }
+ while (*s == '0' && isdigit(*(s + 1)))
+ s++;
+ errno = 0;
+ number = strtonll(s, &t, NiL, 0);
+ if (!o && t > s && *(t - 1) == 'l')
+ t--;
+ if (t == s)
+ number = LINES;
+ if (o && *t)
+ {
+ number = 0;
+ *f |= ERROR;
+ error(2, "-%c: %s: invalid numeric argument -- unknown suffix", o, s);
+ }
+ else if (errno)
+ {
+ *f |= ERROR;
+ if (o)
+ error(2, "-%c: %s: invalid numeric argument -- out of range", o, s);
+ else
+ error(2, "%s: invalid numeric argument -- out of range", s);
+ }
+ else
+ {
+ *f |= COUNT;
+ if (c == '-')
+ number = -number;
+ }
+ if (e)
+ *e = t;
+ return number;
+}
+
+int
+b_tail(int argc, char** argv, void* context)
+{
+ static const char header_fmt[] = "\n==> %s <==\n";
+
+ register Sfio_t* ip;
+ register int n;
+ register int i;
+ register int delim = '\n';
+ int flags = HEADERS;
+ char* s;
+ char* t;
+ char* r;
+ char* e;
+ char* file;
+ Sfoff_t offset;
+ Sfoff_t number = LINES;
+ unsigned long timeout = 0;
+ struct stat st;
+ const char* format = header_fmt+1;
+ size_t z;
+ Sfio_t* op;
+ register Tail_t* fp;
+ register Tail_t* pp;
+ register Tail_t* hp;
+ Tail_t* files;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ for (;;)
+ {
+ switch (n = optget(argv, usage))
+ {
+ case 'c':
+ delim = -1;
+ if (opt_info.arg && *opt_info.arg=='f' && !*(opt_info.arg+1))
+ {
+ flags |= FOLLOW;
+ continue;
+ }
+ /*FALLTHROUGH*/
+ case 'n':
+ case 'N':
+ flags |= COUNT;
+ if (s = opt_info.arg)
+ number = num(s, &s, &flags, n);
+ else
+ {
+ number = LINES;
+ flags &= ~(ERROR|NEGATIVE|POSITIVE);
+ s = "";
+ }
+ if (n=='c' && *s=='f')
+ {
+ s++;
+ flags |= FOLLOW;
+ }
+ if (flags & ERROR)
+ continue;
+ if (flags & (NEGATIVE|POSITIVE))
+ number = -number;
+ if (opt_info.option[0]=='+')
+ number = -number;
+ continue;
+ case 'f':
+ flags |= FOLLOW;
+ continue;
+ case 'h':
+ if (opt_info.num)
+ flags |= HEADERS;
+ else
+ flags &= ~HEADERS;
+ continue;
+ case 'L':
+ flags |= LOG;
+ continue;
+ case 'q':
+ flags &= ~HEADERS;
+ continue;
+ case 'r':
+ flags |= REVERSE;
+ continue;
+ case 's':
+ flags |= SILENT;
+ continue;
+ case 't':
+ flags |= TIMEOUT;
+ timeout = strelapsed(opt_info.arg, &s, 1);
+ if (*s)
+ error(ERROR_exit(1), "%s: invalid elapsed time", opt_info.arg);
+ continue;
+ case 'v':
+ flags |= VERBOSE;
+ continue;
+ case ':':
+ /* handle old style arguments */
+ r = s = argv[opt_info.index];
+ number = num(s, &t, &flags, 0);
+ for (;;)
+ {
+ switch (*t++)
+ {
+ case 0:
+ opt_info.offset = t - r - 1;
+ if (number)
+ number = -number;
+ break;
+ case 'c':
+ delim = -1;
+ continue;
+ case 'f':
+ flags |= FOLLOW;
+ continue;
+ case 'l':
+ delim = '\n';
+ continue;
+ case 'r':
+ flags |= REVERSE;
+ continue;
+ default:
+ error(2, "%s: invalid suffix", t - 1);
+ opt_info.offset = strlen(r);
+ break;
+ }
+ break;
+ }
+ continue;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ if (!*argv)
+ {
+ flags &= ~HEADERS;
+ if (fstat(0, &st))
+ error(ERROR_system(0), "/dev/stdin: cannot stat");
+ else if (FIFO(st.st_mode))
+ flags &= ~FOLLOW;
+ }
+ else if (!*(argv + 1))
+ flags &= ~HEADERS;
+ if (flags & REVERSE)
+ {
+ if (delim < 0)
+ error(2, "--reverse requires line mode");
+ else if (!(flags & COUNT))
+ number = 0;
+ flags &= ~FOLLOW;
+ }
+ if ((flags & (FOLLOW|TIMEOUT)) == TIMEOUT)
+ {
+ flags &= ~TIMEOUT;
+ timeout = 0;
+ error(ERROR_warn(0), "--timeout ignored for --noforever");
+ }
+ if ((flags & (LOG|TIMEOUT)) == LOG)
+ {
+ flags &= ~LOG;
+ error(ERROR_warn(0), "--log ignored for --notimeout");
+ }
+ if (error_info.errors)
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ if (flags & FOLLOW)
+ {
+ if (!(fp = (Tail_t*)stakalloc(argc * sizeof(Tail_t))))
+ error(ERROR_system(1), "out of space");
+ files = 0;
+ s = *argv;
+ do
+ {
+ fp->name = s;
+ fp->sp = 0;
+ if (!init(fp, number, delim, flags))
+ {
+ fp->expire = timeout ? (NOW + timeout + 1) : 0;
+ if (files)
+ pp->next = fp;
+ else
+ files = fp;
+ pp = fp;
+ fp++;
+ }
+ } while (s && (s = *++argv));
+ if (!files)
+ return error_info.errors != 0;
+ pp->next = 0;
+ hp = 0;
+ for (;;)
+ {
+ if (sfsync(sfstdout))
+ error(ERROR_system(1), "write error");
+ sleep(1);
+ n = 0;
+ pp = 0;
+ fp = files;
+ while (fp)
+ {
+ if (fstat(sffileno(fp->sp), &st))
+ error(ERROR_system(0), "%s: cannot stat", fp->name);
+ else if (st.st_size > fp->last)
+ {
+ n = 1;
+ if (timeout)
+ fp->expire = NOW + timeout;
+ z = st.st_size - fp->last;
+ i = 0;
+ if ((s = sfreserve(fp->sp, z, SF_LOCKR)) || (z = sfvalue(fp->sp)) && (s = sfreserve(fp->sp, z, SF_LOCKR)) && (i = 1))
+ {
+ r = 0;
+ for (e = (t = s) + z; t < e; t++)
+ if (*t == '\n')
+ r = t;
+ if (r || i && (r = e))
+ {
+ if ((flags & (HEADERS|VERBOSE)) && hp != fp)
+ {
+ hp = fp;
+ sfprintf(sfstdout, format, fp->name);
+ format = header_fmt;
+ }
+ z = r - s + 1;
+ fp->last += z;
+ sfwrite(sfstdout, s, z);
+ }
+ else
+ z = 0;
+ sfread(fp->sp, s, z);
+ }
+ goto next;
+ }
+ else if (!timeout || fp->expire > NOW)
+ goto next;
+ else
+ {
+ if (flags & LOG)
+ {
+ i = 3;
+ while (--i && stat(fp->name, &st))
+ sleep(1);
+ if (i && (fp->dev != st.st_dev || fp->ino != st.st_ino) && !init(fp, 0, 0, flags))
+ {
+ if (!(flags & SILENT))
+ error(ERROR_warn(0), "%s: log file change", fp->name);
+ fp->expire = NOW + timeout;
+ goto next;
+ }
+ }
+ if (!(flags & SILENT))
+ error(ERROR_warn(0), "%s: %s timeout", fp->name, fmtelapsed(timeout, 1));
+ }
+ if (fp->sp && fp->sp != sfstdin)
+ sfclose(fp->sp);
+ if (pp)
+ pp = pp->next = fp->next;
+ else if (!(files = files->next))
+ return error_info.errors != 0;
+ fp = fp->next;
+ continue;
+ next:
+ pp = fp;
+ fp = fp->next;
+ }
+ }
+ }
+ else
+ {
+ if (file = *argv)
+ argv++;
+ do
+ {
+ if (!file || streq(file, "-"))
+ {
+ file = "/dev/stdin";
+ ip = sfstdin;
+ }
+ else if (!(ip = sfopen(NiL, file, "r")))
+ {
+ error(ERROR_system(0), "%s: cannot open", file);
+ continue;
+ }
+ if (flags & (HEADERS|VERBOSE))
+ sfprintf(sfstdout, format, file);
+ format = header_fmt;
+ if (number < 0 || !number && (flags & POSITIVE))
+ {
+ sfset(ip, SF_SHARE, !(flags & FOLLOW));
+ if (number < -1)
+ sfmove(ip, NiL, -number - 1, delim);
+ if (flags & REVERSE)
+ rev_line(ip, sfstdout, sfseek(ip, (Sfoff_t)0, SEEK_CUR));
+ else
+ sfmove(ip, sfstdout, SF_UNBOUND, -1);
+ }
+ else
+ {
+ sfset(ip, SF_SHARE, 0);
+ if ((offset = tailpos(ip, number, delim)) >= 0)
+ {
+ if (flags & REVERSE)
+ rev_line(ip, sfstdout, offset);
+ else
+ {
+ sfseek(ip, offset, SEEK_SET);
+ sfmove(ip, sfstdout, SF_UNBOUND, -1);
+ }
+ }
+ else
+ {
+ op = (flags & REVERSE) ? sftmp(4*SF_BUFSIZE) : sfstdout;
+ pipetail(ip, op, number, delim);
+ if (flags & REVERSE)
+ {
+ sfseek(op, (Sfoff_t)0, SEEK_SET);
+ rev_line(op, sfstdout, (Sfoff_t)0);
+ sfclose(op);
+ }
+ flags = 0;
+ }
+ }
+ if (ip != sfstdin)
+ sfclose(ip);
+ } while (file = *argv++);
+ }
+ return error_info.errors != 0;
+}
diff --git a/usr/src/lib/libcmd/common/tee.c b/usr/src/lib/libcmd/common/tee.c
new file mode 100644
index 0000000000..243d6d0932
--- /dev/null
+++ b/usr/src/lib/libcmd/common/tee.c
@@ -0,0 +1,181 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Bell Laboratories
+ *
+ * tee
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: tee (AT&T Research) 2006-10-10 $\n]"
+USAGE_LICENSE
+"[+NAME?tee - duplicate standard input]"
+"[+DESCRIPTION?\btee\b copies standard input to standard output "
+ "and to zero or more files. The options determine whether "
+ "the specified files are overwritten or appended to. The "
+ "\btee\b utility does not buffer output. If writes to any "
+ "\afile\a fail, writes to other files continue although \btee\b "
+ "will exit with a non-zero exit status.]"
+"[+?The number of \afile\a operands that can be specified is limited "
+ "by the underlying operating system.]"
+"[a:append?Append the standard input to the given files rather "
+ "than overwriting them.]"
+"[i:ignore-interrupts?Ignore SIGINT signal.]"
+"[l:linebuffer?Set the standard output to be line buffered.]"
+"\n"
+"\n[file ...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?All files copies successfully.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bcat\b(1), \bsignal\b(3)]"
+;
+
+
+#include <cmd.h>
+#include <ls.h>
+#include <sig.h>
+
+typedef struct Tee_s
+{
+ Sfdisc_t disc;
+ int fd[1];
+} Tee_t;
+
+/*
+ * This discipline writes to each file in the list given in handle
+ */
+
+static ssize_t tee_write(Sfio_t* fp, const void* buf, size_t n, Sfdisc_t* handle)
+{
+ register const char* bp;
+ register const char* ep;
+ register int* hp = ((Tee_t*)handle)->fd;
+ register int fd = sffileno(fp);
+ register ssize_t r;
+
+ do
+ {
+ bp = (const char*)buf;
+ ep = bp + n;
+ while (bp < ep)
+ {
+ if ((r = write(fd, bp, ep - bp)) <= 0)
+ return(-1);
+ bp += r;
+ }
+ } while ((fd = *hp++) >= 0);
+ return(n);
+}
+
+int
+b_tee(int argc, register char** argv, void* context)
+{
+ register Tee_t* tp = 0;
+ register int oflag = O_WRONLY|O_TRUNC|O_CREAT|O_BINARY;
+ register int n;
+ register int* hp;
+ register char* cp;
+ int line;
+ Sfdisc_t tee_disc;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ line = -1;
+ while (n = optget(argv, usage)) switch (n)
+ {
+ case 'a':
+ oflag &= ~O_TRUNC;
+ oflag |= O_APPEND;
+ break;
+ case 'i':
+ signal(SIGINT, SIG_IGN);
+ break;
+ case 'l':
+ line = sfset(sfstdout, 0, 0) & SF_LINE;
+ if ((line == 0) == (opt_info.num == 0))
+ line = -1;
+ else
+ sfset(sfstdout, SF_LINE, !!opt_info.num);
+ break;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ if(error_info.errors)
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ argv += opt_info.index;
+ argc -= opt_info.index;
+
+ /*
+ * for backward compatibility
+ */
+
+ if (*argv && streq(*argv, "-"))
+ {
+ signal(SIGINT, SIG_IGN);
+ argv++;
+ argc--;
+ }
+ if (argc > 0)
+ {
+ if (!(tp = (Tee_t*)stakalloc(sizeof(Tee_t) + argc * sizeof(int))))
+ error(ERROR_exit(1), "no space");
+ memset(&tee_disc, 0, sizeof(tee_disc));
+ tee_disc.writef = tee_write;
+ tp->disc = tee_disc;
+ hp = tp->fd;
+ while (cp = *argv++)
+ {
+ if ((*hp = open(cp, oflag, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) < 0)
+ error(ERROR_system(0), "%s: cannot create", cp);
+ else hp++;
+ }
+ if (hp == tp->fd)
+ tp = 0;
+ else
+ {
+ *hp = -1;
+ sfdisc(sfstdout, &tp->disc);
+ }
+ }
+ if (sfmove(sfstdin, sfstdout, SF_UNBOUND, -1) < 0 || !sfeof(sfstdin) || sfsync(sfstdout))
+ error(ERROR_system(1), "cannot copy");
+
+ /*
+ * close files and free resources
+ */
+
+ if (tp)
+ {
+ sfdisc(sfstdout, NiL);
+ if (line >= 0)
+ sfset(sfstdout, SF_LINE, line);
+ for(hp = tp->fd; (n = *hp) >= 0; hp++)
+ close(n);
+ }
+ return(error_info.errors);
+}
diff --git a/usr/src/lib/libcmd/common/tty.c b/usr/src/lib/libcmd/common/tty.c
new file mode 100644
index 0000000000..22115b2343
--- /dev/null
+++ b/usr/src/lib/libcmd/common/tty.c
@@ -0,0 +1,94 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Bell Laboratories
+ *
+ * tty
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: tty (AT&T Research) 2007-03-11 $\n]"
+USAGE_LICENSE
+"[+NAME?tty - write the name of the terminal to standard output]"
+"[+DESCRIPTION?\btty\b writes the name of the terminal that is connected "
+ "to standard input onto standard output. If the standard input is not "
+ "a terminal, \"\bnot a tty\b\" will be written to standard output.]"
+"[l:line-number?Write the synchronous line number of the terminal on a "
+ "separate line following the terminal name line. If the standard "
+ "input is not a synchronous terminal then "
+ "\"\bnot on an active synchronous line\b\" is written.]"
+"[s:silent|quiet?Disable the terminal name line. Use \b[[ -t 0 ]]]]\b instead.]"
+"[+EXIT STATUS?]{"
+ "[+0?Standard input is a tty.]"
+ "[+1?Standard input is not a tty.]"
+ "[+2?Invalid arguments.]"
+ "[+3?A an error occurred.]"
+"}"
+;
+
+
+#include <cmd.h>
+
+#if _mac_STWLINE
+#include <sys/stermio.h>
+#endif
+
+int
+b_tty(int argc, char *argv[], void* context)
+{
+ register int n,sflag=0,lflag=0;
+ register char *tty;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ while (n = optget(argv, usage)) switch (n)
+ {
+ case 'l':
+ lflag++;
+ break;
+ case 's':
+ sflag++;
+ break;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ if(error_info.errors)
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ if(!(tty=ttyname(0)))
+ {
+ tty = ERROR_translate(0, 0, 0, "not a tty");
+ error_info.errors++;
+ }
+ if(!sflag)
+ sfputr(sfstdout,tty,'\n');
+#if _mac_STWLINE
+ if(lflag && (n = ioctl(0, STWLINE, 0)) >= 0)
+ error(ERROR_OUTPUT, 1, "synchronous line %d", n);
+ else
+#endif
+ error(ERROR_OUTPUT, 1, "not on an active synchronous line");
+ return(error_info.errors);
+}
diff --git a/usr/src/lib/libcmd/common/uname.c b/usr/src/lib/libcmd/common/uname.c
new file mode 100644
index 0000000000..97cdf9100f
--- /dev/null
+++ b/usr/src/lib/libcmd/common/uname.c
@@ -0,0 +1,512 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * uname
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: uname (AT&T Research) 2007-01-22 $\n]"
+USAGE_LICENSE
+"[+NAME?uname - identify the current system ]"
+"[+DESCRIPTION?By default \buname\b writes the operating system name to"
+" standard output. When options are specified, one or more"
+" system characteristics are written to standard output, space"
+" separated, on a single line. When more than one option is specifed"
+" the output is in the order specfied by the \b-A\b option below."
+" Unsupported option values are listed as \a[option]]\a. If any unknown"
+" options are specified then the local \b/usr/bin/uname\b is called.]"
+"[+?If any \aname\a operands are specified then the \bsysinfo\b(2) values"
+" for each \aname\a are listed, separated by space, on one line."
+" \bgetconf\b(1), a pre-existing \astandard\a interface, provides"
+" access to the same information; vendors should spend more time"
+" using standards than inventing them.]"
+"[+?Selected information is printed in the same order as the options below.]"
+"[a:all?Equivalent to \b-snrvmpio\b.]"
+"[s:system|sysname|kernel-name?The detailed kernel name. This is the default.]"
+"[n:nodename?The hostname or nodename.]"
+"[r:release|kernel-release?The kernel release level.]"
+"[v:version|kernel-version?The kernel version level.]"
+"[m:machine?The name of the hardware type the system is running on.]"
+"[p:processor?The name of the processor instruction set architecture.]"
+"[i:implementation|platform|hardware-platform?The hardware implementation;"
+" this is \b--host-id\b on some systems.]"
+"[o:operating-system?The generic operating system name.]"
+"[h:host-id|id?The host id in hex.]"
+"[d:domain?The domain name returned by \agetdomainname\a(2).]"
+"[R:extended-release?The extended release name.]"
+"[A:everything?Equivalent to \b-snrvmpiohdR\b.]"
+"[f:list?List all \bsysinfo\b(2) names and values, one per line.]"
+"[S:sethost?Set the hostname or nodename to \aname\a. No output is"
+" written to standard output.]:[name]"
+
+"[+SEE ALSO?\bhostname\b(1), \bgetconf\b(1), \buname\b(2),"
+" \bsysconf\b(2), \bsysinfo\b(2)]"
+;
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:hide getdomainname gethostid gethostname sethostname
+#else
+#define getdomainname ______getdomainname
+#define gethostid ______gethostid
+#define gethostname ______gethostname
+#define sethostname ______sethostname
+#endif
+
+#include <cmd.h>
+#include <ctype.h>
+#include <proc.h>
+
+#include "FEATURE/utsname"
+
+#define MAXHOSTNAME 64
+
+#if _lib_uname && _sys_utsname
+
+#include <sys/utsname.h>
+
+#endif
+
+#if defined(__STDPP__directive) && defined(__STDPP__hide)
+__STDPP__directive pragma pp:nohide getdomainname gethostid gethostname sethostname
+#else
+#undef getdomainname
+#undef gethostid
+#undef gethostname
+#undef sethostname
+#endif
+
+#if _lib_getdomainname
+extern int getdomainname(char*, size_t);
+#endif
+#if _lib_gethostid
+extern int gethostid(void);
+#endif
+#if _lib_gethostname
+extern int gethostname(char*, size_t);
+#endif
+#if _lib_sethostname
+extern int sethostname(const char*, size_t);
+#endif
+
+#ifndef HOSTTYPE
+#define HOSTTYPE "unknown"
+#endif
+
+static const char hosttype[] = HOSTTYPE;
+
+#if !_lib_uname || !_sys_utsname
+
+#if defined(__STDPP__)
+#define SYSNAME #(getprd machine)
+#define RELEASE #(getprd release)
+#define VERSION #(getprd version)
+#define MACHINE #(getprd architecture)
+#else
+#define SYSNAME ""
+#define RELEASE ""
+#define VERSION ""
+#define MACHINE ""
+#endif
+
+struct utsname
+{
+ char* sysname;
+ char nodename[MAXHOSTNAME];
+ char* release;
+ char* version;
+ char* machine;
+};
+
+int
+uname(register struct utsname* ut)
+{
+#ifdef HOSTTYPE
+ char* sys = 0;
+ char* arch = 0;
+
+ if (*hosttype)
+ {
+ static char buf[sizeof(hosttype)];
+
+ strcpy(buf, hosttype);
+ sys = buf;
+ if (arch = strchr(sys, '.'))
+ {
+ *arch++ = 0;
+ if (!*arch)
+ arch = 0;
+ }
+ if (!*sys)
+ sys = 0;
+ }
+#endif
+#ifdef _lib_gethostname
+ if (gethostname(ut->nodename, sizeof(ut->nodename) - 1))
+ return -1;
+#else
+ strncpy(ut->nodename, "local", sizeof(ut->nodename) - 1);
+#endif
+#ifdef HOSTTYPE
+ if (!(ut->sysname = sys))
+#endif
+ if (!*(ut->sysname = SYSNAME))
+ ut->sysname = ut->nodename;
+#ifdef HOSTTYPE
+ if (!(ut->machine = arch))
+#endif
+ ut->machine = MACHINE;
+ ut->release = RELEASE;
+ ut->version = VERSION;
+ return 0;
+}
+
+#endif
+
+#define OPT_system (1<<0)
+#define OPT_nodename (1<<1)
+#define OPT_release (1<<2)
+#define OPT_version (1<<3)
+#define OPT_machine (1<<4)
+#define OPT_processor (1<<5)
+
+#define OPT_STANDARD 6
+
+#define OPT_implementation (1<<6)
+#define OPT_operating_system (1<<7)
+
+#define OPT_ALL 8
+
+#define OPT_hostid (1<<8)
+#define OPT_vendor (1<<9)
+#define OPT_domain (1<<10)
+#define OPT_machine_type (1<<11)
+#define OPT_base (1<<12)
+#define OPT_extended_release (1<<13)
+#define OPT_extra (1<<14)
+
+#define OPT_TOTAL 15
+
+#define OPT_all (1L<<29)
+#define OPT_total (1L<<30)
+#define OPT_standard ((1<<OPT_STANDARD)-1)
+
+#ifndef MACHINE
+#if defined(__STDPP__)
+#define MACHINE #(getprd architecture)
+#else
+#define MACHINE ""
+#endif
+#endif
+
+#ifndef HOSTTYPE
+#define HOSTTYPE "unknown"
+#endif
+
+#define extra(m) do \
+ { \
+ if ((char*)&ut.m[sizeof(ut.m)] > last) \
+ last = (char*)&ut.m[sizeof(ut.m)]; \
+ } while(0)
+
+#define output(f,v,u) do \
+ { \
+ if ((flags&(f))&&(*(v)||(flags&(OPT_all|OPT_total))==OPT_all&&((f)&OPT_standard)||!(flags&(OPT_all|OPT_total)))) \
+ { \
+ if (sep) \
+ sfputc(sfstdout, ' '); \
+ else \
+ sep = 1; \
+ if (*(v)) \
+ sfputr(sfstdout, v, -1); \
+ else \
+ sfprintf(sfstdout, "[%s]", u); \
+ } \
+ } while (0)
+
+int
+b_uname(int argc, char** argv, void* context)
+{
+ register long flags = 0;
+ register int sep = 0;
+ register int n;
+ register char* s;
+ char* t;
+ char* e;
+ char* sethost = 0;
+ int list = 0;
+ struct utsname ut;
+ char buf[257];
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ for (;;)
+ {
+ switch (optget(argv, usage))
+ {
+ case 'a':
+ flags |= OPT_all|((1L<<OPT_ALL)-1);
+ continue;
+ case 'b':
+ flags |= OPT_base;
+ continue;
+ case 'c':
+ flags |= OPT_vendor;
+ continue;
+ case 'd':
+ flags |= OPT_domain;
+ continue;
+ case 'f':
+ list = 1;
+ continue;
+ case 'h':
+ flags |= OPT_hostid;
+ continue;
+ case 'i':
+ flags |= OPT_implementation;
+ continue;
+ case 'm':
+ flags |= OPT_machine;
+ continue;
+ case 'n':
+ flags |= OPT_nodename;
+ continue;
+ case 'o':
+ flags |= OPT_operating_system;
+ continue;
+ case 'p':
+ flags |= OPT_processor;
+ continue;
+ case 'r':
+ flags |= OPT_release;
+ continue;
+ case 's':
+ flags |= OPT_system;
+ continue;
+ case 't':
+ flags |= OPT_machine_type;
+ continue;
+ case 'v':
+ flags |= OPT_version;
+ continue;
+ case 'x':
+ flags |= OPT_extra;
+ continue;
+ case 'A':
+ flags |= OPT_total|((1L<<OPT_TOTAL)-1);
+ continue;
+ case 'R':
+ flags |= OPT_extended_release;
+ continue;
+ case 'S':
+ sethost = opt_info.arg;
+ continue;
+ case ':':
+ s = "/usr/bin/uname";
+ if (!streq(argv[0], s) && (!eaccess(s, X_OK) || !eaccess(s+=4, X_OK)))
+ {
+ argv[0] = s;
+ return procrun(s, argv);
+ }
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ if (error_info.errors || *argv && (flags || sethost) || sethost && flags)
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ if (sethost)
+ {
+#if _lib_sethostname
+ if (sethostname(sethost, strlen(sethost) + 1))
+#else
+#ifdef ENOSYS
+ errno = ENOSYS;
+#else
+ errno = EPERM;
+#endif
+#endif
+ error(ERROR_system(1), "%s: cannot set host name", sethost);
+ }
+ else if (list)
+ astconflist(sfstdout, NiL, ASTCONF_base|ASTCONF_defined|ASTCONF_lower|ASTCONF_quote|ASTCONF_matchcall, "CS|SI");
+ else if (*argv)
+ {
+ e = &buf[sizeof(buf)-1];
+ while (s = *argv++)
+ {
+ t = buf;
+ *t++ = 'C';
+ *t++ = 'S';
+ *t++ = '_';
+ while (t < e && (n = *s++))
+ *t++ = islower(n) ? toupper(n) : n;
+ *t = 0;
+ sfprintf(sfstdout, "%s%c", *(t = astconf(buf, NiL, NiL)) ? t : "unknown", *argv ? ' ' : '\n');
+ }
+ }
+ else
+ {
+ s = buf;
+ if (!flags)
+ flags = OPT_system;
+ memzero(&ut, sizeof(ut));
+ if (uname(&ut) < 0)
+ error(ERROR_usage(2), "information unavailable");
+ output(OPT_system, ut.sysname, "sysname");
+ if (flags & OPT_nodename)
+ {
+#if !_mem_nodeext_utsname && _lib_gethostname
+ if (sizeof(ut.nodename) > 9 || gethostname(s, sizeof(buf)))
+#endif
+ s = ut.nodename;
+ output(OPT_nodename, s, "nodename");
+ }
+ output(OPT_release, ut.release, "release");
+ output(OPT_version, ut.version, "version");
+ output(OPT_machine, ut.machine, "machine");
+ if (flags & OPT_processor)
+ {
+ if (!*(s = astconf("ARCHITECTURE", NiL, NiL)))
+ s = ut.machine;
+ output(OPT_processor, s, "processor");
+ }
+ if (flags & OPT_implementation)
+ {
+ if (!*(s = astconf("PLATFORM", NiL, NiL)) && !*(s = astconf("HW_NAME", NiL, NiL)))
+ {
+ if (t = strchr(hosttype, '.'))
+ t++;
+ else
+ t = (char*)hosttype;
+ strncpy(s = buf, t, sizeof(buf) - 1);
+ }
+ output(OPT_implementation, s, "implementation");
+ }
+ if (flags & OPT_operating_system)
+ {
+ s = astconf("OPERATING_SYSTEM", NiL, NiL);
+ if (!*s)
+#ifdef _UNAME_os_DEFAULT
+ s = _UNAME_os_DEFAULT;
+#else
+ s = ut.sysname;
+#endif
+ output(OPT_operating_system, s, "operating-system");
+ }
+ if (flags & OPT_extended_release)
+ {
+ s = astconf("RELEASE", NiL, NiL);
+ output(OPT_extended_release, s, "extended-release");
+ }
+#if _mem_idnumber_utsname
+ output(OPT_hostid, ut.idnumber, "hostid");
+#else
+ if (flags & OPT_hostid)
+ {
+ if (!*(s = astconf("HW_SERIAL", NiL, NiL)))
+#if _lib_gethostid
+ sfsprintf(s = buf, sizeof(buf), "%08x", gethostid());
+#else
+ /*NOP*/;
+#endif
+ output(OPT_hostid, s, "hostid");
+ }
+#endif
+ if (flags & OPT_vendor)
+ {
+ s = astconf("HW_PROVIDER", NiL, NiL);
+ output(OPT_vendor, s, "vendor");
+ }
+ if (flags & OPT_domain)
+ {
+ if (!*(s = astconf("SRPC_DOMAIN", NiL, NiL)))
+#if _lib_getdomainname
+ getdomainname(s, sizeof(buf));
+#else
+ /*NOP*/;
+#endif
+ output(OPT_domain, s, "domain");
+ }
+#if _mem_m_type_utsname
+ s = ut.m_type;
+#else
+ s = astconf("MACHINE", NiL, NiL);
+#endif
+ output(OPT_machine_type, s, "m_type");
+#if _mem_base_rel_utsname
+ s = ut.base_rel;
+#else
+ s = astconf("BASE", NiL, NiL);
+#endif
+ output(OPT_base, s, "base_rel");
+ if (flags & OPT_extra)
+ {
+ char* last = (char*)&ut;
+
+ extra(sysname);
+ extra(nodename);
+ extra(release);
+ extra(version);
+ extra(machine);
+#if _mem_idnumber_utsname
+ extra(idnumber);
+#endif
+#if _mem_m_type_utsname
+ extra(m_type);
+#endif
+#if _mem_base_rel_utsname
+ extra(base_rel);
+#endif
+ if (last < ((char*)(&ut + 1)))
+ {
+ s = t = last;
+ while (s < (char*)(&ut + 1))
+ {
+ if (!(n = *s++))
+ {
+ if ((s - t) > 1)
+ {
+ if (sep)
+ sfputc(sfstdout, ' ');
+ else
+ sep = 1;
+ sfputr(sfstdout, t, -1);
+ }
+ t = s;
+ }
+ else if (!isprint(n))
+ break;
+ }
+ }
+ }
+ if (sep)
+ sfputc(sfstdout, '\n');
+ }
+ return error_info.errors;
+}
diff --git a/usr/src/lib/libcmd/common/uniq.c b/usr/src/lib/libcmd/common/uniq.c
new file mode 100644
index 0000000000..e6e0da4667
--- /dev/null
+++ b/usr/src/lib/libcmd/common/uniq.c
@@ -0,0 +1,302 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * uniq
+ *
+ * Written by David Korn
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: uniq (AT&T Research) 2006-08-28 $\n]"
+USAGE_LICENSE
+"[+NAME?uniq - Report or filter out repeated lines in a file]"
+"[+DESCRIPTION?\buniq\b reads an input, comparing adjacent lines, and "
+ "writing one copy of each input line on the output. The second "
+ "and succeeding copies of the repeated adjacent lines are not "
+ "written.]"
+"[+?If the output file, \aoutfile\a, is not specified, \buniq\b writes "
+ "to standard output. If no \ainfile\a is given, or if the \ainfile\a "
+ "is \b-\b, \buniq\b reads from standard input with the start of "
+ "the file is defined as the current offset.]"
+"[c:count?Output the number of times each line occurred along with "
+ "the line.]"
+"[d:repeated|duplicates?Output the first of each duplicate line.]"
+"[D:all-repeated?Output all duplicate lines as a group with an empty "
+ "line delimiter specified by \adelimit\a:]:?[delimit:=none]"
+ "{"
+ "[n:none?Do not delimit duplicate groups.]"
+ "[p:prepend?Prepend an empty line before each group.]"
+ "[s:separate?Separate each group with an empty line.]"
+ "}"
+"[f:skip-fields]#[fields?\afields\a is the number of fields to skip over "
+ "before checking for uniqueness. A field is the minimal string matching "
+ "the BRE \b[[:blank:]]]]*[^[:blank:]]]]*\b.]"
+"[i:ignore-case?Ignore case in comparisons.]"
+"[s:skip-chars]#[chars?\achars\a is the number of characters to skip over "
+ "before checking for uniqueness. If specified along with \b-f\b, "
+ "the first \achars\a after the first \afields\a are ignored. If "
+ "the \achars\a specifies more characters than are on the line, "
+ "an empty string will be used for comparison.]"
+"[u:unique?Output unique lines.]"
+"[w:check-chars]#[chars?\achars\a is the number of characters to compare "
+ "after skipping any specified fields and characters.]"
+"\n"
+"\n[infile [outfile]]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?The input file was successfully processed.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bsort\b(1), \bgrep\b(1)]"
+;
+
+#include <cmd.h>
+
+#define C_FLAG 1
+#define D_FLAG 2
+#define U_FLAG 4
+
+#define CWIDTH 4
+#define MAXCNT 9999
+
+typedef int (*Compare_f)(const char*, const char*, size_t);
+
+static int uniq(Sfio_t *fdin, Sfio_t *fdout, int fields, int chars, int width, int mode, int* all, Compare_f compare)
+{
+ register int n, f, outsize=0;
+ register char *cp, *ep, *bufp, *outp;
+ char *orecp, *sbufp=0, *outbuff;
+ int reclen,oreclen= -1,count=0,cwidth=0,sep,next;
+ if(mode&C_FLAG)
+ cwidth = CWIDTH+1;
+ while(1)
+ {
+ if(bufp = sfgetr(fdin,'\n',0))
+ n = sfvalue(fdin);
+ else if(bufp = sfgetr(fdin,'\n',SF_LASTR))
+ {
+ n = sfvalue(fdin);
+ bufp = memcpy(fmtbuf(n + 1), bufp, n);
+ bufp[n++] = '\n';
+ }
+ else
+ n = 0;
+ if(n)
+ {
+ cp = bufp;
+ ep = cp + n;
+ if(f=fields)
+ while(f-->0 && cp<ep) /* skip over fields */
+ {
+ while(cp<ep && *cp==' ' || *cp=='\t')
+ cp++;
+ while(cp<ep && *cp!=' ' && *cp!='\t')
+ cp++;
+ }
+ if(chars)
+ cp += chars;
+ if((reclen = n - (cp-bufp)) <=0)
+ {
+ reclen = 1;
+ cp = bufp + sfvalue(fdin)-1;
+ }
+ else if(width >= 0 && width < reclen)
+ reclen = width;
+ }
+ else
+ reclen=-2;
+ if(reclen==oreclen && (!reclen || !(*compare)(cp,orecp,reclen)))
+ {
+ count++;
+ if (!all)
+ continue;
+ next = count;
+ }
+ else
+ {
+ next = 0;
+ if(outsize>0)
+ {
+ if(((mode&D_FLAG)&&count==0) || ((mode&U_FLAG)&&count))
+ {
+ if(outp!=sbufp)
+ sfwrite(fdout,outp,0);
+ }
+ else
+ {
+ if(cwidth)
+ {
+ outp[CWIDTH] = ' ';
+ if(count<MAXCNT)
+ {
+ sfsprintf(outp,cwidth,"%*d",CWIDTH,count+1);
+ outp[CWIDTH] = ' ';
+ }
+ else
+ {
+ outsize -= (CWIDTH+1);
+ if(outp!=sbufp)
+ {
+ if(!(sbufp=fmtbuf(outsize)))
+ return(1);
+ memcpy(sbufp,outp+CWIDTH+1,outsize);
+ sfwrite(fdout,outp,0);
+ outp = sbufp;
+ }
+ else
+ outp += CWIDTH+1;
+ sfprintf(fdout,"%4d ",count+1);
+ }
+ }
+ if(sfwrite(fdout,outp,outsize) != outsize)
+ return(1);
+ }
+ }
+ }
+ if(n==0)
+ break;
+ if(count = next)
+ {
+ if(sfwrite(fdout,outp,outsize) != outsize)
+ return(1);
+ if(*all >= 0)
+ *all = 1;
+ sep = 0;
+ }
+ else
+ sep = all && *all > 0;
+ /* save current record */
+ if (!(outbuff = sfreserve(fdout, 0, 0)) || (outsize = sfvalue(fdout)) < 0)
+ return(1);
+ outp = outbuff;
+ if(outsize < n+cwidth+sep)
+ {
+ /* no room in outp, clear lock and use side buffer */
+ sfwrite(fdout,outp,0);
+ if(!(sbufp = outp=fmtbuf(outsize=n+cwidth+sep)))
+ return(1);
+ }
+ else
+ outsize = n+cwidth+sep;
+ memcpy(outp+cwidth+sep,bufp,n);
+ if(sep)
+ outp[cwidth] = '\n';
+ oreclen = reclen;
+ orecp = outp+cwidth+sep + (cp-bufp);
+ }
+ return(0);
+}
+
+int
+b_uniq(int argc, char** argv, void* context)
+{
+ register int n, mode=0;
+ register char *cp;
+ int fields=0, chars=0, width=-1;
+ Sfio_t *fpin, *fpout;
+ int* all = 0;
+ int sep;
+ Compare_f compare = (Compare_f)memcmp;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ while (n = optget(argv, usage)) switch (n)
+ {
+ case 'c':
+ mode |= C_FLAG;
+ break;
+ case 'd':
+ mode |= D_FLAG;
+ break;
+ case 'D':
+ mode |= D_FLAG;
+ switch ((int)opt_info.num)
+ {
+ case 'p':
+ sep = 1;
+ break;
+ case 's':
+ sep = 0;
+ break;
+ default:
+ sep = -1;
+ break;
+ }
+ all = &sep;
+ break;
+ case 'i':
+ compare = (Compare_f)strncasecmp;
+ break;
+ case 'u':
+ mode |= U_FLAG;
+ break;
+ case 'f':
+ if(*opt_info.option=='-')
+ fields = opt_info.num;
+ else
+ chars = opt_info.num;
+ break;
+ case 's':
+ chars = opt_info.num;
+ break;
+ case 'w':
+ width = opt_info.num;
+ break;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ if(all && (mode&C_FLAG))
+ error(2, "-c and -D are mutually exclusive");
+ if(error_info.errors)
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ if((cp = *argv) && (argv++,!streq(cp,"-")))
+ {
+ if(!(fpin = sfopen(NiL,cp,"r")))
+ error(ERROR_system(1),"%s: cannot open",cp);
+ }
+ else
+ fpin = sfstdin;
+ if(cp = *argv)
+ {
+ argv++;
+ if(!(fpout = sfopen(NiL,cp,"w")))
+ error(ERROR_system(1),"%s: cannot create",cp);
+ }
+ else
+ fpout = sfstdout;
+ if(*argv)
+ {
+ error(2, "too many arguments");
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ }
+ error_info.errors = uniq(fpin,fpout,fields,chars,width,mode,all,compare);
+ if(fpin!=sfstdin)
+ sfclose(fpin);
+ if(fpout!=sfstdout)
+ sfclose(fpout);
+ return(error_info.errors);
+}
+
diff --git a/usr/src/lib/libcmd/common/wc.c b/usr/src/lib/libcmd/common/wc.c
new file mode 100644
index 0000000000..9d4b2567c7
--- /dev/null
+++ b/usr/src/lib/libcmd/common/wc.c
@@ -0,0 +1,186 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Bell Laboratories
+ *
+ * count the number of bytes, words, and lines in a file
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: wc (AT&T Research) 2006-08-25 $\n]"
+USAGE_LICENSE
+"[+NAME?wc - print the number of bytes, words, and lines in files]"
+"[+DESCRIPTION?\bwc\b reads one or more input files and, by default, "
+ "for each file writes a line containing the number of newlines, "
+ "\aword\as, and bytes contained in each file followed by the "
+ "file name to standard output in that order. A \aword\a is "
+ "defined to be a non-zero length string delimited by \bisspace\b(3) "
+ "characters.]"
+"[+?If more than one file is specified, \bwc\b writes a total count "
+ "for all of the named files with \btotal\b written instead "
+ "of the file name.]"
+"[+?By default, \bwc\b writes all three counts. Options can specified "
+ "so that only certain counts are written. The options \b-c\b "
+ "and \b-m\b are mutually exclusive.]"
+"[+?If no \afile\a is given, or if the \afile\a is \b-\b, \bwc\b "
+ "reads from standard input and no filename is written to standard "
+ "output. The start of the file is defined as the current offset.]"
+"[l:lines?List the line counts.]"
+"[w:words?List the word counts.]"
+"[c:bytes|chars:chars?List the byte counts.]"
+"[m|C:multibyte-chars?List the character counts.]"
+"[q:quiet?Suppress invalid multibyte character warnings.]"
+"[L:longest-line|max-line-length?List the longest line length.]"
+"\n"
+"\n[file ...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?All files processed successfully.]"
+ "[+>0?One or more files failed to open or could not be read.]"
+"}"
+"[+SEE ALSO?\bcat\b(1), \bisspace\b(3)]"
+;
+
+
+#include <cmd.h>
+#include <wc.h>
+#include <ls.h>
+
+#define ERRORMAX 125
+
+static void printout(register Wc_t *wp, register char *name,register int mode)
+{
+ if(mode&WC_LINES)
+ sfprintf(sfstdout," %7I*d",sizeof(wp->lines),wp->lines);
+ if(mode&WC_WORDS)
+ sfprintf(sfstdout," %7I*d",sizeof(wp->words),wp->words);
+ if(mode&WC_CHARS)
+ sfprintf(sfstdout," %7I*d",sizeof(wp->chars),wp->chars);
+ if(mode&WC_LONGEST)
+ sfprintf(sfstdout," %7I*d",sizeof(wp->chars),wp->longest);
+ if(name)
+ sfprintf(sfstdout," %s",name);
+ sfputc(sfstdout,'\n');
+}
+
+int
+b_wc(int argc,register char **argv, void* context)
+{
+ register char *cp;
+ register int mode=0, n;
+ register Wc_t *wp;
+ Sfio_t *fp;
+ Sfoff_t tlines=0, twords=0, tchars=0;
+ struct stat statb;
+
+ cmdinit(argc, argv, context, ERROR_CATALOG, 0);
+ while (n = optget(argv,usage)) switch (n)
+ {
+ case 'c':
+ mode |= WC_CHARS;
+ break;
+ case 'l':
+ mode |= WC_LINES;
+ break;
+ case 'L':
+ mode |= WC_LONGEST;
+ break;
+ case 'm':
+ case 'C':
+ mode |= WC_MBYTE;
+ break;
+ case 'q':
+ mode |= WC_QUIET;
+ break;
+ case 'w':
+ mode |= WC_WORDS;
+ break;
+ case ':':
+ error(2, "%s", opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ if (error_info.errors)
+ error(ERROR_usage(2), "%s", optusage(NiL));
+ if(mode&WC_MBYTE)
+ {
+ if(mode&WC_CHARS)
+ error(2, "-c and -C are mutually exclusive");
+ mode |= WC_CHARS;
+ if(!mbwide())
+ {
+ mode &= ~WC_MBYTE;
+ setlocale(LC_CTYPE, "C");
+ }
+ }
+ if(!(mode&(WC_WORDS|WC_CHARS|WC_LINES|WC_MBYTE|WC_LONGEST)))
+ mode |= (WC_WORDS|WC_CHARS|WC_LINES);
+ if(!(wp = wc_init(mode)))
+ error(3,"internal error");
+ if(!(mode&WC_WORDS))
+ {
+ memzero(wp->space, (1<<CHAR_BIT));
+ wp->space['\n'] = -1;
+ }
+ if(cp = *argv)
+ argv++;
+ do
+ {
+ if(!cp || streq(cp,"-"))
+ fp = sfstdin;
+ else if(!(fp = sfopen(NiL,cp,"r")))
+ {
+ error(ERROR_system(0),"%s: cannot open",cp);
+ continue;
+ }
+ if(cp)
+ n++;
+ if(!(mode&(WC_WORDS|WC_LINES|WC_MBYTE|WC_LONGEST)) && fstat(sffileno(fp),&statb)>=0
+ && S_ISREG(statb.st_mode))
+ {
+ wp->chars = statb.st_size - lseek(sffileno(fp),0L,1);
+ lseek(sffileno(fp),0L,2);
+ }
+ else
+ wc_count(wp, fp, cp);
+ if(fp!=sfstdin)
+ sfclose(fp);
+ tchars += wp->chars;
+ twords += wp->words;
+ tlines += wp->lines;
+ printout(wp,cp,mode);
+ }
+ while(cp= *argv++);
+ if(n>1)
+ {
+ wp->lines = tlines;
+ wp->chars = tchars;
+ wp->words = twords;
+ printout(wp,"total",mode);
+ }
+ return(error_info.errors<ERRORMAX?error_info.errors:ERRORMAX);
+}
+
diff --git a/usr/src/lib/libcmd/common/wc.h b/usr/src/lib/libcmd/common/wc.h
new file mode 100644
index 0000000000..0296a898f8
--- /dev/null
+++ b/usr/src/lib/libcmd/common/wc.h
@@ -0,0 +1,57 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Bell Laboratories
+ *
+ * header for wc library interface
+ */
+
+#ifndef _WC_H
+#define _WC_H
+
+#include <ast.h>
+
+#define WC_LINES 0x01
+#define WC_WORDS 0x02
+#define WC_CHARS 0x04
+#define WC_MBYTE 0x08
+#define WC_LONGEST 0x10
+#define WC_QUIET 0x20
+
+typedef struct
+{
+ signed char space[1<<CHAR_BIT];
+ Sfoff_t words;
+ Sfoff_t lines;
+ Sfoff_t chars;
+ Sfoff_t longest;
+ int mode;
+} Wc_t;
+
+#define wc_count _cmd_wccount
+#define wc_init _cmd_wcinit
+
+extern Wc_t* wc_init(int);
+extern int wc_count(Wc_t*, Sfio_t*, const char*);
+
+#endif /* _WC_H */
diff --git a/usr/src/lib/libcmd/common/wclib.c b/usr/src/lib/libcmd/common/wclib.c
new file mode 100644
index 0000000000..c16e4efc87
--- /dev/null
+++ b/usr/src/lib/libcmd/common/wclib.c
@@ -0,0 +1,197 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Bell Laboratories
+ *
+ * library interface for word count
+ */
+
+#include <cmd.h>
+#include <wc.h>
+#include <ctype.h>
+
+#if _hdr_wchar && _hdr_wctype
+
+#include <wchar.h>
+#include <wctype.h>
+
+#else
+
+#ifndef iswspace
+#define iswspace(x) isspace(x)
+#endif
+
+#endif
+
+#define endline(c) (((signed char)-1)<0?(c)<0:(c)==((char)-1))
+#define mbok(p,n) (((n)<1)?0:mbwide()?((*ast.mb_towc)(NiL,(char*)(p),n)>=0):1)
+
+Wc_t *wc_init(int mode)
+{
+ register int n;
+ register int w;
+ Wc_t* wp;
+
+ if(!(wp = (Wc_t*)stakalloc(sizeof(Wc_t))))
+ return(0);
+ wp->mode = mode;
+ w = mode & WC_WORDS;
+ for(n=(1<<CHAR_BIT);--n >=0;)
+ wp->space[n] = w ? !!isspace(n) : 0;
+ wp->space['\n'] = -1;
+ return(wp);
+}
+
+/*
+ * compute the line, word, and character count for file <fd>
+ */
+int wc_count(Wc_t *wp, Sfio_t *fd, const char* file)
+{
+ register signed char *space = wp->space;
+ register unsigned char *cp;
+ register Sfoff_t nchars;
+ register Sfoff_t nwords;
+ register Sfoff_t nlines;
+ register Sfoff_t eline;
+ register Sfoff_t longest;
+ register ssize_t c;
+ register unsigned char *endbuff;
+ register int lasttype = 1;
+ unsigned int lastchar;
+ unsigned char *buff;
+ wchar_t x;
+
+ sfset(fd,SF_WRITE,1);
+ nlines = nwords = nchars = 0;
+ wp->longest = 0;
+ if (wp->mode & (WC_LONGEST|WC_MBYTE))
+ {
+ longest = 0;
+ eline = -1;
+ cp = buff = endbuff = 0;
+ for (;;)
+ {
+ if (!mbok(cp, endbuff-cp))
+ {
+ if (buff)
+ sfread(fd, buff, cp-buff);
+ if (!(buff = (unsigned char*)sfreserve(fd, SF_UNBOUND, SF_LOCKR)))
+ break;
+ endbuff = (cp = buff) + sfvalue(fd);
+ }
+ nchars++;
+ x = mbchar(cp);
+ if (x == -1)
+ {
+ if (eline != nlines && !(wp->mode & WC_QUIET))
+ {
+ error_info.file = (char*)file;
+ error_info.line = eline = nlines;
+ error(ERROR_SYSTEM|1, "invalid multibyte character");
+ error_info.file = 0;
+ error_info.line = 0;
+ }
+ }
+ else if (x == '\n')
+ {
+ if ((nchars - longest) > wp->longest)
+ wp->longest = nchars - longest;
+ longest = nchars;
+ nlines++;
+ lasttype = 1;
+ }
+ else if (iswspace(x))
+ lasttype = 1;
+ else if (lasttype)
+ {
+ lasttype = 0;
+ nwords++;
+ }
+ }
+ }
+ else
+ {
+ for (;;)
+ {
+ /* fill next buffer and check for end-of-file */
+ if (!(buff = (unsigned char*)sfreserve(fd, 0, 0)) || (c = sfvalue(fd)) <= 0)
+ break;
+ sfread(fd,(char*)(cp=buff),c);
+ nchars += c;
+ /* check to see whether first character terminates word */
+ if(c==1)
+ {
+ if(endline(lasttype))
+ nlines++;
+ if((c = space[*cp]) && !lasttype)
+ nwords++;
+ lasttype = c;
+ continue;
+ }
+ if(!lasttype && space[*cp])
+ nwords++;
+ lastchar = cp[--c];
+ cp[c] = '\n';
+ endbuff = cp+c;
+ c = lasttype;
+ /* process each buffer */
+ for (;;)
+ {
+ /* process spaces and new-lines */
+ do if (endline(c))
+ {
+ for (;;)
+ {
+ /* check for end of buffer */
+ if (cp > endbuff)
+ goto eob;
+ nlines++;
+ if (*cp != '\n')
+ break;
+ cp++;
+ }
+ } while (c = space[*cp++]);
+ /* skip over word characters */
+ while(!(c = space[*cp++]));
+ nwords++;
+ }
+ eob:
+ if((cp -= 2) >= buff)
+ c = space[*cp];
+ else
+ c = lasttype;
+ lasttype = space[lastchar];
+ /* see if was in word */
+ if(!c && !lasttype)
+ nwords--;
+ }
+ if(endline(lasttype))
+ nlines++;
+ else if(!lasttype)
+ nwords++;
+ }
+ wp->chars = nchars;
+ wp->words = nwords;
+ wp->lines = nlines;
+ return(0);
+}
diff --git a/usr/src/lib/libcmd/i386/include/ast/cmd.h b/usr/src/lib/libcmd/i386/include/ast/cmd.h
new file mode 100644
index 0000000000..2484c17c5a
--- /dev/null
+++ b/usr/src/lib/libcmd/i386/include/ast/cmd.h
@@ -0,0 +1,187 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * AT&T Research
+ *
+ * builtin cmd definitions
+ */
+
+#ifndef _CMD_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _CMD_H
+
+#include <ast.h>
+#include <error.h>
+#include <stak.h>
+
+#define cmdinit _cmd_init
+#define cmdquit() 0
+
+#if _BLD_cmd && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#include <cmdext.h>
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if defined(CMD_BUILTIN) && !defined(CMD_STANDALONE)
+#define CMD_STANDALONE CMD_BUILTIN
+#endif
+
+#ifdef CMD_STANDALONE
+
+#if CMD_DYNAMIC
+
+#include <dlldefs.h>
+
+typedef int (*Builtin_f) __PROTO__((int, char**, __V_*));
+
+#else
+
+extern __MANGLE__ int CMD_STANDALONE __PROTO__((int, char**, __V_*));
+
+#endif
+
+#ifndef CMD_BUILTIN
+
+/*
+ * command initialization
+ */
+
+static int
+cmdinit __PARAM__((int argc, register char** argv, __V_* context, const char* catalog, int flags), (argc, argv, context, catalog, flags)) __OTORP__(int argc; register char** argv; __V_* context; const char* catalog; int flags;){
+ register char* cp;
+ register char* pp;
+
+ if (cp = strrchr(argv[0], '/'))
+ cp++;
+ else
+ cp = argv[0];
+ if (pp = strrchr(cp, '_'))
+ cp = pp + 1;
+ error_info.id = cp;
+ if (!error_info.catalog)
+ error_info.catalog = (char*)catalog;
+ opt_info.index = 0;
+ if (context)
+ error_info.flags |= flags;
+ return 0;
+}
+
+#endif
+
+int
+main __PARAM__((int argc, char** argv), (argc, argv)) __OTORP__(int argc; char** argv;){
+#if CMD_DYNAMIC
+ register char* s;
+ register char* t;
+ __V_* dll;
+ Builtin_f fun;
+ char buf[64];
+
+ if (s = strrchr(argv[0], '/'))
+ s++;
+ else if (!(s = argv[0]))
+ return 127;
+ if ((t = strrchr(s, '_')) && *++t)
+ s = t;
+ buf[0] = '_';
+ buf[1] = 'b';
+ buf[2] = '_';
+ strncpy(buf + 3, s, sizeof(buf) - 4);
+ buf[sizeof(buf) - 1] = 0;
+ if (t = strchr(buf, '.'))
+ *t = 0;
+ for (;;)
+ {
+ if (dll = dlopen(NiL, RTLD_LAZY))
+ {
+ if (fun = (Builtin_f)dlsym(dll, buf + 1))
+ break;
+ if (fun = (Builtin_f)dlsym(dll, buf))
+ break;
+ }
+ if (dll = dllfind("cmd", NiL, RTLD_LAZY))
+ {
+ if (fun = (Builtin_f)dlsym(dll, buf + 1))
+ break;
+ if (fun = (Builtin_f)dlsym(dll, buf))
+ break;
+ }
+ return 127;
+ }
+ return (*fun)(argc, argv, NiL);
+#else
+ return CMD_STANDALONE(argc, argv, NiL);
+#endif
+}
+
+#else
+
+#undef cmdinit
+#define cmdinit(a,b,c,d,e) do{if(_cmd_init(a,b,c,d,e))return -1;}while(0)
+
+#ifndef CMD_BUILTIN
+
+#undef cmdquit
+#define cmdquit() (_cmd_quit)
+
+#if _BLD_cmd && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_cmd && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ int _cmd_quit;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#if _BLD_cmd && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _cmd_init __PROTO__((int, char**, __V_*, const char*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libcmd/i386/include/ast/cmdext.h b/usr/src/lib/libcmd/i386/include/ast/cmdext.h
new file mode 100644
index 0000000000..b5c58b5d04
--- /dev/null
+++ b/usr/src/lib/libcmd/i386/include/ast/cmdext.h
@@ -0,0 +1,69 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+extern __MANGLE__ int b_basename __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cat __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_chgrp __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_chmod __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_chown __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cksum __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cmp __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_comm __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cp __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cut __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_date __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_dirname __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_expr __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_fds __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_fmt __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_fold __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_getconf __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_head __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_id __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_join __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_ln __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_logname __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_md5sum __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_mkdir __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_mkfifo __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_mv __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_paste __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_pathchk __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_rev __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_rm __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_rmdir __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_stty __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_sum __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_sync __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_tail __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_tee __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_tty __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_uname __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_uniq __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_wc __PROTO__((int, char**, __V_*));
diff --git a/usr/src/lib/libcmd/i386/src/lib/libcmd/FEATURE/ids b/usr/src/lib/libcmd/i386/src/lib/libcmd/FEATURE/ids
new file mode 100644
index 0000000000..214990e44d
--- /dev/null
+++ b/usr/src/lib/libcmd/i386/src/lib/libcmd/FEATURE/ids
@@ -0,0 +1,15 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libcmd/features/ids by iffe version 2007-04-04 : : */
+#ifndef _def_ids_cmd
+#define _def_ids_cmd 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_endgrent 1 /* endgrent() in default lib(s) */
+#define _lib_getgrent 1 /* getgrent() in default lib(s) */
+#define _lib_setgrent 1 /* setgrent() in default lib(s) */
+#define _sys_fss 1 /* #include <sys/fss.h> ok */
+#if !_lib_fsid && _mac_fsid
+#define _lib_fsid 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libcmd/i386/src/lib/libcmd/FEATURE/sockets b/usr/src/lib/libcmd/i386/src/lib/libcmd/FEATURE/sockets
new file mode 100644
index 0000000000..f5b9d0855b
--- /dev/null
+++ b/usr/src/lib/libcmd/i386/src/lib/libcmd/FEATURE/sockets
@@ -0,0 +1,13 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libcmd/features/sockets by iffe version 2007-04-04 : : */
+#ifndef _def_sockets_cmd
+#define _def_sockets_cmd 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _hdr_arpa_inet 1 /* #include <arpa/inet.h> ok */
+#define _hdr_netinet_in 1 /* #include <netinet/in.h> ok */
+#define _lib_getsockname 1 /* getsockname() in default lib(s) */
+#define _lib_getsockopt 1 /* getsockopt() in default lib(s) */
+#define _lib_inet_ntoa 1 /* inet_ntoa() in default lib(s) */
+#endif
diff --git a/usr/src/lib/libcmd/i386/src/lib/libcmd/FEATURE/symlink b/usr/src/lib/libcmd/i386/src/lib/libcmd/FEATURE/symlink
new file mode 100644
index 0000000000..59beb5bfe8
--- /dev/null
+++ b/usr/src/lib/libcmd/i386/src/lib/libcmd/FEATURE/symlink
@@ -0,0 +1,8 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libcmd/features/symlink by iffe version 2007-04-04 : : */
+#ifndef _def_symlink_cmd
+#define _def_symlink_cmd 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_lchown 1 /* lchown implemented */
+#endif
diff --git a/usr/src/lib/libcmd/i386/src/lib/libcmd/FEATURE/utsname b/usr/src/lib/libcmd/i386/src/lib/libcmd/FEATURE/utsname
new file mode 100644
index 0000000000..e1cf94aa4b
--- /dev/null
+++ b/usr/src/lib/libcmd/i386/src/lib/libcmd/FEATURE/utsname
@@ -0,0 +1,16 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libcmd/features/utsname by iffe version 2007-04-04 : : */
+#ifndef _def_utsname_cmd
+#define _def_utsname_cmd 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_getdomainname 1 /* getdomainname() in default lib(s) */
+#define _lib_gethostid 1 /* gethostid() in default lib(s) */
+#define _lib_gethostname 1 /* gethostname() in default lib(s) */
+#define _lib_sethostname 1 /* sethostname() in default lib(s) */
+#define _lib_syscall 1 /* syscall() in default lib(s) */
+#define _lib_uname 1 /* uname() in default lib(s) */
+#define _sys_utsname 1 /* #include <sys/utsname.h> ok */
+#define _sys_syscall 1 /* #include <sys/syscall.h> ok */
+#define _sys_systeminfo 1 /* #include <sys/systeminfo.h> ok */
+#endif
diff --git a/usr/src/lib/libcmd/mapfile-vers b/usr/src/lib/libcmd/mapfile-vers
new file mode 100644
index 0000000000..373f2bc8ac
--- /dev/null
+++ b/usr/src/lib/libcmd/mapfile-vers
@@ -0,0 +1,82 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+# functions by AST/ksh93's version of libcmd
+SUNWprivate_1.1 {
+ global:
+ b_basename;
+ b_cat;
+ b_chgrp;
+ b_chmod;
+ b_chown;
+ b_cmp;
+ b_comm;
+ b_cp;
+ b_cut;
+ b_date;
+ b_dirname;
+ b_expr;
+ b_fds;
+ b_fmt;
+ b_fold;
+ b_getconf;
+ b_head;
+ b_id;
+ b_join;
+ b_ln;
+ b_logname;
+ b_mkdir;
+ b_mkfifo;
+ b_mv;
+ b_paste;
+ b_pathchk;
+ b_rev;
+ b_rm;
+ b_rmdir;
+ b_stty;
+ b_sync;
+ b_tail;
+ b_tee;
+ b_tty;
+ b_uname;
+ b_uniq;
+ b_wc;
+ local:
+ *;
+};
+
+# functions exported by the old Solaris version of libcmd
+# (the code has been moved to libc starting with Solaris 11/B51)
+SUNWprivate_1.1 {
+ global:
+ defcntl = FUNCTION FILTER libc.so.1;
+ defopen = FUNCTION FILTER libc.so.1;
+ defread = FUNCTION FILTER libc.so.1;
+ local:
+ *;
+};
diff --git a/usr/src/lib/libcmd/sparc/include/ast/cmd.h b/usr/src/lib/libcmd/sparc/include/ast/cmd.h
new file mode 100644
index 0000000000..2484c17c5a
--- /dev/null
+++ b/usr/src/lib/libcmd/sparc/include/ast/cmd.h
@@ -0,0 +1,187 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * AT&T Research
+ *
+ * builtin cmd definitions
+ */
+
+#ifndef _CMD_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _CMD_H
+
+#include <ast.h>
+#include <error.h>
+#include <stak.h>
+
+#define cmdinit _cmd_init
+#define cmdquit() 0
+
+#if _BLD_cmd && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#include <cmdext.h>
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if defined(CMD_BUILTIN) && !defined(CMD_STANDALONE)
+#define CMD_STANDALONE CMD_BUILTIN
+#endif
+
+#ifdef CMD_STANDALONE
+
+#if CMD_DYNAMIC
+
+#include <dlldefs.h>
+
+typedef int (*Builtin_f) __PROTO__((int, char**, __V_*));
+
+#else
+
+extern __MANGLE__ int CMD_STANDALONE __PROTO__((int, char**, __V_*));
+
+#endif
+
+#ifndef CMD_BUILTIN
+
+/*
+ * command initialization
+ */
+
+static int
+cmdinit __PARAM__((int argc, register char** argv, __V_* context, const char* catalog, int flags), (argc, argv, context, catalog, flags)) __OTORP__(int argc; register char** argv; __V_* context; const char* catalog; int flags;){
+ register char* cp;
+ register char* pp;
+
+ if (cp = strrchr(argv[0], '/'))
+ cp++;
+ else
+ cp = argv[0];
+ if (pp = strrchr(cp, '_'))
+ cp = pp + 1;
+ error_info.id = cp;
+ if (!error_info.catalog)
+ error_info.catalog = (char*)catalog;
+ opt_info.index = 0;
+ if (context)
+ error_info.flags |= flags;
+ return 0;
+}
+
+#endif
+
+int
+main __PARAM__((int argc, char** argv), (argc, argv)) __OTORP__(int argc; char** argv;){
+#if CMD_DYNAMIC
+ register char* s;
+ register char* t;
+ __V_* dll;
+ Builtin_f fun;
+ char buf[64];
+
+ if (s = strrchr(argv[0], '/'))
+ s++;
+ else if (!(s = argv[0]))
+ return 127;
+ if ((t = strrchr(s, '_')) && *++t)
+ s = t;
+ buf[0] = '_';
+ buf[1] = 'b';
+ buf[2] = '_';
+ strncpy(buf + 3, s, sizeof(buf) - 4);
+ buf[sizeof(buf) - 1] = 0;
+ if (t = strchr(buf, '.'))
+ *t = 0;
+ for (;;)
+ {
+ if (dll = dlopen(NiL, RTLD_LAZY))
+ {
+ if (fun = (Builtin_f)dlsym(dll, buf + 1))
+ break;
+ if (fun = (Builtin_f)dlsym(dll, buf))
+ break;
+ }
+ if (dll = dllfind("cmd", NiL, RTLD_LAZY))
+ {
+ if (fun = (Builtin_f)dlsym(dll, buf + 1))
+ break;
+ if (fun = (Builtin_f)dlsym(dll, buf))
+ break;
+ }
+ return 127;
+ }
+ return (*fun)(argc, argv, NiL);
+#else
+ return CMD_STANDALONE(argc, argv, NiL);
+#endif
+}
+
+#else
+
+#undef cmdinit
+#define cmdinit(a,b,c,d,e) do{if(_cmd_init(a,b,c,d,e))return -1;}while(0)
+
+#ifndef CMD_BUILTIN
+
+#undef cmdquit
+#define cmdquit() (_cmd_quit)
+
+#if _BLD_cmd && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_cmd && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ int _cmd_quit;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#if _BLD_cmd && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _cmd_init __PROTO__((int, char**, __V_*, const char*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libcmd/sparc/include/ast/cmdext.h b/usr/src/lib/libcmd/sparc/include/ast/cmdext.h
new file mode 100644
index 0000000000..b5c58b5d04
--- /dev/null
+++ b/usr/src/lib/libcmd/sparc/include/ast/cmdext.h
@@ -0,0 +1,69 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+extern __MANGLE__ int b_basename __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cat __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_chgrp __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_chmod __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_chown __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cksum __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cmp __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_comm __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cp __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cut __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_date __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_dirname __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_expr __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_fds __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_fmt __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_fold __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_getconf __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_head __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_id __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_join __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_ln __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_logname __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_md5sum __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_mkdir __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_mkfifo __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_mv __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_paste __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_pathchk __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_rev __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_rm __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_rmdir __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_stty __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_sum __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_sync __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_tail __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_tee __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_tty __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_uname __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_uniq __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_wc __PROTO__((int, char**, __V_*));
diff --git a/usr/src/lib/libcmd/sparc/src/lib/libcmd/FEATURE/ids b/usr/src/lib/libcmd/sparc/src/lib/libcmd/FEATURE/ids
new file mode 100644
index 0000000000..ee06a813a2
--- /dev/null
+++ b/usr/src/lib/libcmd/sparc/src/lib/libcmd/FEATURE/ids
@@ -0,0 +1,15 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libcmd/features/ids by iffe version 2007-04-04 : : */
+#ifndef _def_ids_cmd
+#define _def_ids_cmd 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_endgrent 1 /* endgrent() in default lib(s) */
+#define _lib_getgrent 1 /* getgrent() in default lib(s) */
+#define _lib_setgrent 1 /* setgrent() in default lib(s) */
+#define _sys_fss 1 /* #include <sys/fss.h> ok */
+#if !_lib_fsid && _mac_fsid
+#define _lib_fsid 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libcmd/sparc/src/lib/libcmd/FEATURE/sockets b/usr/src/lib/libcmd/sparc/src/lib/libcmd/FEATURE/sockets
new file mode 100644
index 0000000000..9fbdd78fe1
--- /dev/null
+++ b/usr/src/lib/libcmd/sparc/src/lib/libcmd/FEATURE/sockets
@@ -0,0 +1,13 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libcmd/features/sockets by iffe version 2007-04-04 : : */
+#ifndef _def_sockets_cmd
+#define _def_sockets_cmd 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _hdr_arpa_inet 1 /* #include <arpa/inet.h> ok */
+#define _hdr_netinet_in 1 /* #include <netinet/in.h> ok */
+#define _lib_getsockname 1 /* getsockname() in default lib(s) */
+#define _lib_getsockopt 1 /* getsockopt() in default lib(s) */
+#define _lib_inet_ntoa 1 /* inet_ntoa() in default lib(s) */
+#endif
diff --git a/usr/src/lib/libcmd/sparc/src/lib/libcmd/FEATURE/symlink b/usr/src/lib/libcmd/sparc/src/lib/libcmd/FEATURE/symlink
new file mode 100644
index 0000000000..c06b9a3e85
--- /dev/null
+++ b/usr/src/lib/libcmd/sparc/src/lib/libcmd/FEATURE/symlink
@@ -0,0 +1,8 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libcmd/features/symlink by iffe version 2007-04-04 : : */
+#ifndef _def_symlink_cmd
+#define _def_symlink_cmd 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_lchown 1 /* lchown implemented */
+#endif
diff --git a/usr/src/lib/libcmd/sparc/src/lib/libcmd/FEATURE/utsname b/usr/src/lib/libcmd/sparc/src/lib/libcmd/FEATURE/utsname
new file mode 100644
index 0000000000..37720b4530
--- /dev/null
+++ b/usr/src/lib/libcmd/sparc/src/lib/libcmd/FEATURE/utsname
@@ -0,0 +1,16 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libcmd/features/utsname by iffe version 2007-04-04 : : */
+#ifndef _def_utsname_cmd
+#define _def_utsname_cmd 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_getdomainname 1 /* getdomainname() in default lib(s) */
+#define _lib_gethostid 1 /* gethostid() in default lib(s) */
+#define _lib_gethostname 1 /* gethostname() in default lib(s) */
+#define _lib_sethostname 1 /* sethostname() in default lib(s) */
+#define _lib_syscall 1 /* syscall() in default lib(s) */
+#define _lib_uname 1 /* uname() in default lib(s) */
+#define _sys_utsname 1 /* #include <sys/utsname.h> ok */
+#define _sys_syscall 1 /* #include <sys/syscall.h> ok */
+#define _sys_systeminfo 1 /* #include <sys/systeminfo.h> ok */
+#endif
diff --git a/usr/src/lib/libcmd/sparcv9/include/ast/cmd.h b/usr/src/lib/libcmd/sparcv9/include/ast/cmd.h
new file mode 100644
index 0000000000..2484c17c5a
--- /dev/null
+++ b/usr/src/lib/libcmd/sparcv9/include/ast/cmd.h
@@ -0,0 +1,187 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+/*
+ * AT&T Research
+ *
+ * builtin cmd definitions
+ */
+
+#ifndef _CMD_H
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _CMD_H
+
+#include <ast.h>
+#include <error.h>
+#include <stak.h>
+
+#define cmdinit _cmd_init
+#define cmdquit() 0
+
+#if _BLD_cmd && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+#include <cmdext.h>
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#if defined(CMD_BUILTIN) && !defined(CMD_STANDALONE)
+#define CMD_STANDALONE CMD_BUILTIN
+#endif
+
+#ifdef CMD_STANDALONE
+
+#if CMD_DYNAMIC
+
+#include <dlldefs.h>
+
+typedef int (*Builtin_f) __PROTO__((int, char**, __V_*));
+
+#else
+
+extern __MANGLE__ int CMD_STANDALONE __PROTO__((int, char**, __V_*));
+
+#endif
+
+#ifndef CMD_BUILTIN
+
+/*
+ * command initialization
+ */
+
+static int
+cmdinit __PARAM__((int argc, register char** argv, __V_* context, const char* catalog, int flags), (argc, argv, context, catalog, flags)) __OTORP__(int argc; register char** argv; __V_* context; const char* catalog; int flags;){
+ register char* cp;
+ register char* pp;
+
+ if (cp = strrchr(argv[0], '/'))
+ cp++;
+ else
+ cp = argv[0];
+ if (pp = strrchr(cp, '_'))
+ cp = pp + 1;
+ error_info.id = cp;
+ if (!error_info.catalog)
+ error_info.catalog = (char*)catalog;
+ opt_info.index = 0;
+ if (context)
+ error_info.flags |= flags;
+ return 0;
+}
+
+#endif
+
+int
+main __PARAM__((int argc, char** argv), (argc, argv)) __OTORP__(int argc; char** argv;){
+#if CMD_DYNAMIC
+ register char* s;
+ register char* t;
+ __V_* dll;
+ Builtin_f fun;
+ char buf[64];
+
+ if (s = strrchr(argv[0], '/'))
+ s++;
+ else if (!(s = argv[0]))
+ return 127;
+ if ((t = strrchr(s, '_')) && *++t)
+ s = t;
+ buf[0] = '_';
+ buf[1] = 'b';
+ buf[2] = '_';
+ strncpy(buf + 3, s, sizeof(buf) - 4);
+ buf[sizeof(buf) - 1] = 0;
+ if (t = strchr(buf, '.'))
+ *t = 0;
+ for (;;)
+ {
+ if (dll = dlopen(NiL, RTLD_LAZY))
+ {
+ if (fun = (Builtin_f)dlsym(dll, buf + 1))
+ break;
+ if (fun = (Builtin_f)dlsym(dll, buf))
+ break;
+ }
+ if (dll = dllfind("cmd", NiL, RTLD_LAZY))
+ {
+ if (fun = (Builtin_f)dlsym(dll, buf + 1))
+ break;
+ if (fun = (Builtin_f)dlsym(dll, buf))
+ break;
+ }
+ return 127;
+ }
+ return (*fun)(argc, argv, NiL);
+#else
+ return CMD_STANDALONE(argc, argv, NiL);
+#endif
+}
+
+#else
+
+#undef cmdinit
+#define cmdinit(a,b,c,d,e) do{if(_cmd_init(a,b,c,d,e))return -1;}while(0)
+
+#ifndef CMD_BUILTIN
+
+#undef cmdquit
+#define cmdquit() (_cmd_quit)
+
+#if _BLD_cmd && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+#if !_BLD_cmd && defined(__IMPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+#endif
+
+extern __MANGLE__ int _cmd_quit;
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#if _BLD_cmd && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ int _cmd_init __PROTO__((int, char**, __V_*, const char*, int));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libcmd/sparcv9/include/ast/cmdext.h b/usr/src/lib/libcmd/sparcv9/include/ast/cmdext.h
new file mode 100644
index 0000000000..b5c58b5d04
--- /dev/null
+++ b/usr/src/lib/libcmd/sparcv9/include/ast/cmdext.h
@@ -0,0 +1,69 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1992-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+/* : : generated by proto : : */
+
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+extern __MANGLE__ int b_basename __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cat __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_chgrp __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_chmod __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_chown __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cksum __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cmp __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_comm __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cp __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_cut __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_date __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_dirname __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_expr __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_fds __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_fmt __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_fold __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_getconf __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_head __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_id __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_join __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_ln __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_logname __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_md5sum __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_mkdir __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_mkfifo __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_mv __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_paste __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_pathchk __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_rev __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_rm __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_rmdir __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_stty __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_sum __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_sync __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_tail __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_tee __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_tty __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_uname __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_uniq __PROTO__((int, char**, __V_*));
+extern __MANGLE__ int b_wc __PROTO__((int, char**, __V_*));
diff --git a/usr/src/lib/libcmd/sparcv9/src/lib/libcmd/FEATURE/ids b/usr/src/lib/libcmd/sparcv9/src/lib/libcmd/FEATURE/ids
new file mode 100644
index 0000000000..d74a8c699f
--- /dev/null
+++ b/usr/src/lib/libcmd/sparcv9/src/lib/libcmd/FEATURE/ids
@@ -0,0 +1,15 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libcmd/features/ids by iffe version 2007-04-04 : : */
+#ifndef _def_ids_cmd
+#define _def_ids_cmd 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_endgrent 1 /* endgrent() in default lib(s) */
+#define _lib_getgrent 1 /* getgrent() in default lib(s) */
+#define _lib_setgrent 1 /* setgrent() in default lib(s) */
+#define _sys_fss 1 /* #include <sys/fss.h> ok */
+#if !_lib_fsid && _mac_fsid
+#define _lib_fsid 1
+#endif
+
+#endif
diff --git a/usr/src/lib/libcmd/sparcv9/src/lib/libcmd/FEATURE/sockets b/usr/src/lib/libcmd/sparcv9/src/lib/libcmd/FEATURE/sockets
new file mode 100644
index 0000000000..00732f6357
--- /dev/null
+++ b/usr/src/lib/libcmd/sparcv9/src/lib/libcmd/FEATURE/sockets
@@ -0,0 +1,13 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libcmd/features/sockets by iffe version 2007-04-04 : : */
+#ifndef _def_sockets_cmd
+#define _def_sockets_cmd 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _hdr_arpa_inet 1 /* #include <arpa/inet.h> ok */
+#define _hdr_netinet_in 1 /* #include <netinet/in.h> ok */
+#define _lib_getsockname 1 /* getsockname() in default lib(s) */
+#define _lib_getsockopt 1 /* getsockopt() in default lib(s) */
+#define _lib_inet_ntoa 1 /* inet_ntoa() in default lib(s) */
+#endif
diff --git a/usr/src/lib/libcmd/sparcv9/src/lib/libcmd/FEATURE/symlink b/usr/src/lib/libcmd/sparcv9/src/lib/libcmd/FEATURE/symlink
new file mode 100644
index 0000000000..d62a9cabae
--- /dev/null
+++ b/usr/src/lib/libcmd/sparcv9/src/lib/libcmd/FEATURE/symlink
@@ -0,0 +1,8 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libcmd/features/symlink by iffe version 2007-04-04 : : */
+#ifndef _def_symlink_cmd
+#define _def_symlink_cmd 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_lchown 1 /* lchown implemented */
+#endif
diff --git a/usr/src/lib/libcmd/sparcv9/src/lib/libcmd/FEATURE/utsname b/usr/src/lib/libcmd/sparcv9/src/lib/libcmd/FEATURE/utsname
new file mode 100644
index 0000000000..51d38ec3c0
--- /dev/null
+++ b/usr/src/lib/libcmd/sparcv9/src/lib/libcmd/FEATURE/utsname
@@ -0,0 +1,16 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libcmd/features/utsname by iffe version 2007-04-04 : : */
+#ifndef _def_utsname_cmd
+#define _def_utsname_cmd 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _lib_getdomainname 1 /* getdomainname() in default lib(s) */
+#define _lib_gethostid 1 /* gethostid() in default lib(s) */
+#define _lib_gethostname 1 /* gethostname() in default lib(s) */
+#define _lib_sethostname 1 /* sethostname() in default lib(s) */
+#define _lib_syscall 1 /* syscall() in default lib(s) */
+#define _lib_uname 1 /* uname() in default lib(s) */
+#define _sys_utsname 1 /* #include <sys/utsname.h> ok */
+#define _sys_syscall 1 /* #include <sys/syscall.h> ok */
+#define _sys_systeminfo 1 /* #include <sys/systeminfo.h> ok */
+#endif
diff --git a/usr/src/lib/libdll/Makefile b/usr/src/lib/libdll/Makefile
new file mode 100644
index 0000000000..bfe056bbd3
--- /dev/null
+++ b/usr/src/lib/libdll/Makefile
@@ -0,0 +1,65 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+SHELL=/usr/bin/ksh
+
+include ../Makefile.lib
+
+SUBDIRS = $(MACH)
+$(BUILD64)SUBDIRS += $(MACH64)
+
+all := TARGET= all
+clean := TARGET= clean
+clobber := TARGET= clobber
+install := TARGET= install
+lint := TARGET= lint
+_msg := TARGET= _msg
+
+.KEEP_STATE:
+
+all clean clobber install lint _msg: $(SUBDIRS)
+
+LIBRARY= libdll.a
+
+HDRS= \
+ dlldefs.h
+
+HDRDIR32= $(MACH)/src/lib/libdll
+HDRDIR64= $(MACH64)/src/lib/libdll
+include ../Makefile.asthdr
+
+install_h: $(ROOTHDRS)
+
+# We don't check these header files because they're owned by AT&T/AST
+check:
+
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
+
+include ../Makefile.targ
diff --git a/usr/src/lib/libdll/Makefile.com b/usr/src/lib/libdll/Makefile.com
new file mode 100644
index 0000000000..31e0864b26
--- /dev/null
+++ b/usr/src/lib/libdll/Makefile.com
@@ -0,0 +1,96 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+SHELL=/usr/bin/ksh
+
+LIBRARY= libdll.a
+VERS= .1
+
+OBJECTS= \
+ dlfcn.o \
+ dllfind.o \
+ dlllook.o \
+ dllnext.o \
+ dllplug.o \
+ dllscan.o
+
+include ../../Makefile.astmsg
+
+include ../../Makefile.lib
+
+# mapfile-vers does not live with the sources in in common/ to make
+# automated code updates easier.
+MAPFILES= ../mapfile-vers
+
+# Set common AST build flags (e.g., needed to support the math stuff).
+include ../../../Makefile.ast
+
+LIBS = $(DYNLIB) $(LINTLIB)
+LDLIBS += -last -lc
+$(LINTLIB) := SRCS = $(SRCDIR)/$(LINTSRC)
+
+SRCDIR = ../common
+
+# We use "=" here since using $(CPPFLAGS.master) is very tricky in our
+# case - it MUST come as the last element but future changes in -D options
+# may then cause silent breakage in the AST sources because the last -D
+# option specified overrides previous -D options so we prefer the current
+# way to explicitly list each single flag.
+# Notes:
+# - "-D_BLD_DLL" comes from ${mam_cc_DLL} in Mamfile
+CPPFLAGS = \
+ $(DTEXTDOM) $(DTS_ERRNO) \
+ $(DLLPLATFORMCPPFLAGS) \
+ -I. \
+ -I$(ROOT)/usr/include/ast \
+ '-DCONF_LIBSUFFIX=".so"' \
+ '-DCONF_LIBPREFIX="lib"' \
+ -D_BLD_dll \
+ -D_PACKAGE_ast \
+ -D_BLD_DLL
+
+CFLAGS += \
+ $(CCVERBOSE) \
+ -xstrconst
+CFLAGS64 += \
+ $(CCVERBOSE) \
+ -xstrconst
+
+.KEEP_STATE:
+
+all: $(LIBS)
+
+#
+# libdll is not lint-clean yet; fake up a target. (You can use
+# "make lintcheck" to actually run lint; please send all lint fixes
+# upstream (to AT&T) so the next update will pull them into ON.)
+#
+lint:
+ @ print "usr/src/lib/libdll is not lint-clean: skipping"
+ @ $(TRUE)
+
+include ../../Makefile.targ
diff --git a/usr/src/lib/libdll/THIRDPARTYLICENSE b/usr/src/lib/libdll/THIRDPARTYLICENSE
new file mode 100644
index 0000000000..50c6364c06
--- /dev/null
+++ b/usr/src/lib/libdll/THIRDPARTYLICENSE
@@ -0,0 +1,245 @@
++------------------------------------------------------------------------------+
+| This license covers all software that refers to the URL |
+| http://www.opensource.org/licenses/cpl1.0.txt |
++------------------------------------------------------------------------------+
+
+Common Public License Version 1.0
+
+ THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON
+ PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF
+ THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+ 1. DEFINITIONS
+
+ "Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and
+ documentation distributed under this Agreement, and
+
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from
+ and are distributed by that particular Contributor. A Contribution
+ 'originates' from a Contributor if it was added to the Program by
+ such Contributor itself or anyone acting on such Contributor's
+ behalf. Contributions do not include additions to the Program
+ which: (i) are separate modules of software distributed in
+ conjunction with the Program under their own license agreement, and
+ (ii) are not derivative works of the Program.
+
+ "Contributor" means any person or entity that distributes the Program.
+
+ "Licensed Patents " mean patent claims licensable by a Contributor
+ which are necessarily infringed by the use or sale of its Contribution
+ alone or when combined with the Program.
+
+ "Program" means the Contributions distributed in accordance with this
+ Agreement.
+
+ "Recipient" means anyone who receives the Program under this
+ Agreement, including all Contributors.
+
+ 2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free copyright
+ license to reproduce, prepare derivative works of, publicly
+ display, publicly perform, distribute and sublicense the
+ Contribution of such Contributor, if any, and such derivative
+ works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free patent
+ license under Licensed Patents to make, use, sell, offer to sell,
+ import and otherwise transfer the Contribution of such Contributor,
+ if any, in source code and object code form. This patent license
+ shall apply to the combination of the Contribution and the Program
+ if, at the time the Contribution is added by the Contributor, such
+ addition of the Contribution causes such combination to be covered
+ by the Licensed Patents. The patent license shall not apply to any
+ other combinations which include the Contribution. No hardware per
+ se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the
+ licenses to its Contributions set forth herein, no assurances are
+ provided by any Contributor that the Program does not infringe the
+ patent or other intellectual property rights of any other entity.
+ Each Contributor disclaims any liability to Recipient for claims
+ brought by any other entity based on infringement of intellectual
+ property rights or otherwise. As a condition to exercising the
+ rights and licenses granted hereunder, each Recipient hereby
+ assumes sole responsibility to secure any other intellectual
+ property rights needed, if any. For example, if a third party
+ patent license is required to allow Recipient to distribute the
+ Program, it is Recipient's responsibility to acquire that license
+ before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has
+ sufficient copyright rights in its Contribution, if any, to grant
+ the copyright license set forth in this Agreement.
+
+ 3. REQUIREMENTS
+
+ A Contributor may choose to distribute the Program in object code form
+ under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all
+ warranties and conditions, express and implied, including
+ warranties or conditions of title and non-infringement, and implied
+ warranties or conditions of merchantability and fitness for a
+ particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all
+ liability for damages, including direct, indirect, special,
+ incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement
+ are offered by that Contributor alone and not by any other party;
+ and
+
+ iv) states that source code for the Program is available from such
+ Contributor, and informs licensees how to obtain it in a reasonable
+ manner on or through a medium customarily used for software
+ exchange.
+
+ When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the
+ Program.
+
+ Contributors may not remove or alter any copyright notices contained
+ within the Program.
+
+ Each Contributor must identify itself as the originator of its
+ Contribution, if any, in a manner that reasonably allows subsequent
+ Recipients to identify the originator of the Contribution.
+
+ 4. COMMERCIAL DISTRIBUTION
+
+ Commercial distributors of software may accept certain
+ responsibilities with respect to end users, business partners and the
+ like. While this license is intended to facilitate the commercial use
+ of the Program, the Contributor who includes the Program in a
+ commercial product offering should do so in a manner which does not
+ create potential liability for other Contributors. Therefore, if a
+ Contributor includes the Program in a commercial product offering,
+ such Contributor ("Commercial Contributor") hereby agrees to defend
+ and indemnify every other Contributor ("Indemnified Contributor")
+ against any losses, damages and costs (collectively "Losses") arising
+ from claims, lawsuits and other legal actions brought by a third party
+ against the Indemnified Contributor to the extent caused by the acts
+ or omissions of such Commercial Contributor in connection with its
+ distribution of the Program in a commercial product offering. The
+ obligations in this section do not apply to any claims or Losses
+ relating to any actual or alleged intellectual property infringement.
+ In order to qualify, an Indemnified Contributor must: a) promptly
+ notify the Commercial Contributor in writing of such claim, and b)
+ allow the Commercial Contributor to control, and cooperate with the
+ Commercial Contributor in, the defense and any related settlement
+ negotiations. The Indemnified Contributor may participate in any such
+ claim at its own expense.
+
+ For example, a Contributor might include the Program in a commercial
+ product offering, Product X. That Contributor is then a Commercial
+ Contributor. If that Commercial Contributor then makes performance
+ claims, or offers warranties related to Product X, those performance
+ claims and warranties are such Commercial Contributor's responsibility
+ alone. Under this section, the Commercial Contributor would have to
+ defend claims against the other Contributors related to those
+ performance claims and warranties, and if a court requires any other
+ Contributor to pay any damages as a result, the Commercial Contributor
+ must pay those damages.
+
+ 5. NO WARRANTY
+
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+ PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
+ WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
+ OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+ responsible for determining the appropriateness of using and
+ distributing the Program and assumes all risks associated with its
+ exercise of rights under this Agreement, including but not limited to
+ the risks and costs of program errors, compliance with applicable
+ laws, damage to or loss of data, programs or equipment, and
+ unavailability or interruption of operations.
+
+ 6. DISCLAIMER OF LIABILITY
+
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
+ ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+ WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+ DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+ 7. GENERAL
+
+ If any provision of this Agreement is invalid or unenforceable under
+ applicable law, it shall not affect the validity or enforceability of
+ the remainder of the terms of this Agreement, and without further
+ action by the parties hereto, such provision shall be reformed to the
+ minimum extent necessary to make such provision valid and enforceable.
+
+ If Recipient institutes patent litigation against a Contributor with
+ respect to a patent applicable to software (including a cross-claim or
+ counterclaim in a lawsuit), then any patent licenses granted by that
+ Contributor to such Recipient under this Agreement shall terminate as
+ of the date such litigation is filed. In addition, if Recipient
+ institutes patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Program
+ itself (excluding combinations of the Program with other software or
+ hardware) infringes such Recipient's patent(s), then such Recipient's
+ rights granted under Section 2(b) shall terminate as of the date such
+ litigation is filed.
+
+ All Recipient's rights under this Agreement shall terminate if it
+ fails to comply with any of the material terms or conditions of this
+ Agreement and does not cure such failure in a reasonable period of
+ time after becoming aware of such noncompliance. If all Recipient's
+ rights under this Agreement terminate, Recipient agrees to cease use
+ and distribution of the Program as soon as reasonably practicable.
+ However, Recipient's obligations under this Agreement and any licenses
+ granted by Recipient relating to the Program shall continue and
+ survive.
+
+ Everyone is permitted to copy and distribute copies of this Agreement,
+ but in order to avoid inconsistency the Agreement is copyrighted and
+ may only be modified in the following manner. The Agreement Steward
+ reserves the right to publish new versions (including revisions) of
+ this Agreement from time to time. No one other than the Agreement
+ Steward has the right to modify this Agreement. IBM is the initial
+ Agreement Steward. IBM may assign the responsibility to serve as the
+ Agreement Steward to a suitable separate entity. Each new version of
+ the Agreement will be given a distinguishing version number. The
+ Program (including Contributions) may always be distributed subject to
+ the version of the Agreement under which it was received. In addition,
+ after a new version of the Agreement is published, Contributor may
+ elect to distribute the Program (including its Contributions) under
+ the new version. Except as expressly stated in Sections 2(a) and 2(b)
+ above, Recipient receives no rights or licenses to the intellectual
+ property of any Contributor under this Agreement, whether expressly,
+ by implication, estoppel or otherwise. All rights in the Program not
+ expressly granted under this Agreement are reserved.
+
+ This Agreement is governed by the laws of the State of New York and
+ the intellectual property laws of the United States of America. No
+ party to this Agreement will bring a legal action under this Agreement
+ more than one year after the cause of action arose. Each party waives
+ its rights to a jury trial in any resulting litigation.
+
+Copyright (c) 2004 by the Open Source Initiative
+This is a copy of the license posted on 2004-10-06 at:
+ http://www.opensource.org/licenses/cpl
diff --git a/usr/src/lib/libdll/THIRDPARTYLICENSE.descrip b/usr/src/lib/libdll/THIRDPARTYLICENSE.descrip
new file mode 100644
index 0000000000..3f4cc4c8fc
--- /dev/null
+++ b/usr/src/lib/libdll/THIRDPARTYLICENSE.descrip
@@ -0,0 +1 @@
+AT&T ADVANCED SOFTWARE TECHNOLOGY DYNAMIC LINKING LIBRARY (LIBDLL)
diff --git a/usr/src/lib/libdll/amd64/Makefile b/usr/src/lib/libdll/amd64/Makefile
new file mode 100644
index 0000000000..5511ce5642
--- /dev/null
+++ b/usr/src/lib/libdll/amd64/Makefile
@@ -0,0 +1,38 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+# Fetch minor version from RELEASE, e.g. "10" for "5.10", "11" for "5.11" etc.
+GETRELEASEMINOR = /usr/bin/ksh -c 'x=$(RELEASE) ; print "$${x$(POUND_SIGN)$(POUND_SIGN)*.}"'
+
+# Platform-specific config
+# Note that "HOSTTYPE" matches the value used by AT&T upstream.
+DLLPLATFORMCPPFLAGS = '-DHOSTTYPE="sol$(GETRELEASEMINOR:sh).i386"'
+
+include ../Makefile.com
+include ../../Makefile.lib.64
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/libdll/amd64/src/lib/libdll/FEATURE/dll b/usr/src/lib/libdll/amd64/src/lib/libdll/FEATURE/dll
new file mode 100644
index 0000000000..7c02252c4d
--- /dev/null
+++ b/usr/src/lib/libdll/amd64/src/lib/libdll/FEATURE/dll
@@ -0,0 +1,125 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libdll/features/dll by iffe version 2007-04-04 : : */
+
+#ifndef _def_dll_dll
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dll_dll 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _hdr_dlfcn 1 /* #include <dlfcn.h> ok */
+#define _LIB_dl 1 /* -ldl is a library */
+#define _lib_dlopen 1 /* dlopen() in default lib(s) */
+#define _DLL_NEXT_PATH "/usr/lib/libc.so.1"
+
+#include <dlfcn.h>
+
+#define DLL_INFO_PREVER 0x0001 /* pre-suffix style version */
+#define DLL_INFO_DOTVER 0x0002 /* post-suffix style version */
+
+typedef struct Dllinfo_s
+{
+ char** sibling; /* sibling dirs on $PATH */
+ char* prefix; /* library name prefix */
+ char* suffix; /* library name suffix */
+ char* env; /* library path env var */
+ int flags; /* DLL_INFO_* flags */
+#ifdef _DLLINFO_PRIVATE_
+ _DLLINFO_PRIVATE_
+#endif
+} Dllinfo_t;
+
+typedef struct Dllent_s
+{
+ char* path;
+ char* name;
+#ifdef _DLLENT_PRIVATE_
+ _DLLENT_PRIVATE_
+#endif
+} Dllent_t;
+
+typedef struct Dllscan_s
+{
+ __V_* pad;
+#ifdef _DLLSCAN_PRIVATE_
+ _DLLSCAN_PRIVATE_
+#endif
+} Dllscan_t;
+
+#if _BLD_dll && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Dllinfo_t* dllinfo __PROTO__((void));
+extern __MANGLE__ __V_* dllplug __PROTO__((const char*, const char*, const char*, int, char*, size_t));
+extern __MANGLE__ __V_* dllfind __PROTO__((const char*, const char*, int, char*, size_t));
+extern __MANGLE__ __V_* dllnext __PROTO__((int));
+extern __MANGLE__ __V_* dlllook __PROTO__((__V_*, const char*));
+
+extern __MANGLE__ Dllscan_t* dllsopen __PROTO__((const char*, const char*, const char*));
+extern __MANGLE__ Dllent_t* dllsread __PROTO__((Dllscan_t*));
+extern __MANGLE__ int dllsclose __PROTO__((Dllscan_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libdll/amd64/src/lib/libdll/dlldefs.h b/usr/src/lib/libdll/amd64/src/lib/libdll/dlldefs.h
new file mode 100644
index 0000000000..7c02252c4d
--- /dev/null
+++ b/usr/src/lib/libdll/amd64/src/lib/libdll/dlldefs.h
@@ -0,0 +1,125 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/lib/libdll/features/dll by iffe version 2007-04-04 : : */
+
+#ifndef _def_dll_dll
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dll_dll 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _hdr_dlfcn 1 /* #include <dlfcn.h> ok */
+#define _LIB_dl 1 /* -ldl is a library */
+#define _lib_dlopen 1 /* dlopen() in default lib(s) */
+#define _DLL_NEXT_PATH "/usr/lib/libc.so.1"
+
+#include <dlfcn.h>
+
+#define DLL_INFO_PREVER 0x0001 /* pre-suffix style version */
+#define DLL_INFO_DOTVER 0x0002 /* post-suffix style version */
+
+typedef struct Dllinfo_s
+{
+ char** sibling; /* sibling dirs on $PATH */
+ char* prefix; /* library name prefix */
+ char* suffix; /* library name suffix */
+ char* env; /* library path env var */
+ int flags; /* DLL_INFO_* flags */
+#ifdef _DLLINFO_PRIVATE_
+ _DLLINFO_PRIVATE_
+#endif
+} Dllinfo_t;
+
+typedef struct Dllent_s
+{
+ char* path;
+ char* name;
+#ifdef _DLLENT_PRIVATE_
+ _DLLENT_PRIVATE_
+#endif
+} Dllent_t;
+
+typedef struct Dllscan_s
+{
+ __V_* pad;
+#ifdef _DLLSCAN_PRIVATE_
+ _DLLSCAN_PRIVATE_
+#endif
+} Dllscan_t;
+
+#if _BLD_dll && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Dllinfo_t* dllinfo __PROTO__((void));
+extern __MANGLE__ __V_* dllplug __PROTO__((const char*, const char*, const char*, int, char*, size_t));
+extern __MANGLE__ __V_* dllfind __PROTO__((const char*, const char*, int, char*, size_t));
+extern __MANGLE__ __V_* dllnext __PROTO__((int));
+extern __MANGLE__ __V_* dlllook __PROTO__((__V_*, const char*));
+
+extern __MANGLE__ Dllscan_t* dllsopen __PROTO__((const char*, const char*, const char*));
+extern __MANGLE__ Dllent_t* dllsread __PROTO__((Dllscan_t*));
+extern __MANGLE__ int dllsclose __PROTO__((Dllscan_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libdll/common/RELEASE b/usr/src/lib/libdll/common/RELEASE
new file mode 100644
index 0000000000..75f6ccd0f6
--- /dev/null
+++ b/usr/src/lib/libdll/common/RELEASE
@@ -0,0 +1,40 @@
+06-10-11 dllscan.c: check sfstruse() return values -- doh
+06-01-25 dllplug.c: add errorf() library message for dlopen() error
+05-02-14 dllscan.c: "" || "-" => NiL
+04-10-01 dllfind.c: drop ksh "builtin" workaround
+ dllscan.c: directory prefix in name limits search to dir and siblings
+04-07-22 dllscan.c: access() => eaccess()
+04-01-30 dllfind.c: dllplug(error_info.id) then dllplug(0)
+04-01-28 dllscan.c: update for new plugin scheme: lib/foo/bar.xxx
+ dllplug.c: add dllplug() for plugin dllfind()
+03-03-12 dllfind.c: dlopen() with RTLD_GLOBAL|RTLD_PARENT defaults
+03-02-11 dllscan.c: change LIBPATH to <dir>[:<env>[:<pat>]][,...]
+03-01-08 dllscan.c: hack version logic again -- is consistency rocket science?
+03-01-07 dlfcn.c: fix darwin.ppc dlopen/dlsym/dlclose
+02-11-18 dllfind.c: add path,size args (with backwards compatibility checks)
+02-11-15 dllfind.c: check for ./path if '.' in path but no '/'
+02-08-30 dllfind.c: fix a bug that returned uninitialized value on not found
+02-08-28 dllscan.c: handle and display bin as a sibling dir
+02-07-31 dllscan.c: add dllsopen,dllsread,dllsclose
+ dllfind.c: use dllsopen,dllsread,dllsclose
+02-07-26 dllfind.c: add dllinfo()
+02-06-27 dllnext.c: define _GNU_SOURCE to enable RTLD_NEXT
+02-03-17 dllfind.c: fix dll prefix search (for cygwin)
+02-01-11 features/dll: include <dlfcn.h> only if _hdr_dlfcn&&_lib_dlopen
+01-10-31 dlfcn.c: change hp.pa dlopen() prototype (<dlfcn.h> but no -ldl!)
+01-09-25 dllfind: add LIBSUFFIX
+01-07-17 dllfind: do at least one dlopen() to prime dlerror()
+01-05-29 dlopen: fix dlopen(0,0) for HP
+01-04-20 dllfind: use getconf HOSTTYPE LIBPATH LIBSUFFIX
+01-02-14 features/dll: fix unbalanced ' quote and ancient hostinfo reference
+00-01-26 dlllook: add -- dlsym() with `_' weak prefix fallback
+99-04-01 features/dll: drop <stdio.h> -- iffe protos printf
+99-03-19 static=1 for all but win32.*
+98-06-01 dllfind: fix version search
+98-03-11 features/dll: probe for _DLL_RLD_SYM
+98-03-01 dllnext: fix to work!
+98-01-23 -ldl test moved to lib0ast
+98-01-11 update for astconf("LIBPATH")
+ add dllnext(flags) to uncover next layer
+ dllfind() and dllnext() in separate files (for 3d)
+97-10-11 move from libast so libast can link static
diff --git a/usr/src/lib/libdll/common/dlfcn.c b/usr/src/lib/libdll/common/dlfcn.c
new file mode 100644
index 0000000000..00c4584667
--- /dev/null
+++ b/usr/src/lib/libdll/common/dlfcn.c
@@ -0,0 +1,536 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1997-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * provide dlopen/dlsym/dlerror interface
+ *
+ * David Korn
+ * Glenn Fowler
+ * AT&T Research
+ */
+
+static const char id[] = "\n@(#)$Id: dll library (AT&T Research) 2005-02-14 $\0\n";
+
+#include <ast.h>
+#include <dlldefs.h>
+#include <error.h>
+
+#define T(x) ERROR_dictionary(x)
+
+#if _BLD_dll && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+#if _hdr_dlfcn && _lib_dlopen
+
+ /*
+ * standard
+ */
+
+# include <dlfcn.h>
+
+#else
+#if _hdr_dl
+
+ /*
+ * HP-UX
+ */
+
+# include <dl.h>
+# ifndef BIND_FIRST
+# define BIND_FIRST 0x4
+# endif
+# ifndef BIND_NOSTART
+# define BIND_NOSTART 0x10
+# endif
+
+ static shl_t all;
+ static int err;
+
+ extern void* dlopen(const char* path, int mode)
+ {
+ void* dll;
+
+ if (!path)
+ return (void*)&all;
+ if (mode)
+ mode = (BIND_IMMEDIATE|BIND_FIRST|BIND_NOSTART);
+ if (!(dll = (void*)shl_load(path, mode, 0L)))
+ err = errno;
+ return dll;
+ }
+
+ extern int dlclose(void* dll)
+ {
+ return 0;
+ }
+
+ extern void* dlsym(void* dll, const char* name)
+ {
+ shl_t handle;
+ long addr;
+
+ handle = dll == (void*)&all ? (shl_t)0 : (shl_t)dll;
+ if (shl_findsym(&handle, name, TYPE_UNDEFINED, &addr))
+ {
+ err = errno;
+ return 0;
+ }
+ return (void*)addr;
+ }
+
+ extern char* dlerror(void)
+ {
+ char* msg;
+
+ if (!err)
+ return 0;
+ msg = fmterror(err);
+ err = 0;
+ return msg;
+ }
+
+#else
+#if _sys_ldr && _lib_loadbind
+
+ /*
+ * rs6000
+ */
+
+# include <sys/ldr.h>
+# include <xcoff.h>
+
+ /* xcoff module header */
+ struct hdr
+ {
+ struct filehdr f;
+ struct aouthdr a;
+ struct scnhdr s[1];
+ };
+
+ static struct ld_info* ld_info;
+ static unsigned int ld_info_size = 1024;
+ static void* last_module;
+ static int err;
+
+ extern void* dlopen(const char* path, int mode)
+ {
+ void* dll;
+
+ if (!(dll = (void*)load((char*)path, mode, getenv("LIBPATH"))))
+ err = errno;
+ return dll;
+ }
+
+ extern int dlclose(void* dll)
+ {
+ return 0;
+ }
+
+ static int getquery(void)
+ {
+ if (!ld_info)
+ ld_info = malloc(ld_info_size);
+ for (;;)
+ {
+ if (!ld_info)
+ return 1;
+ if (!loadquery(L_GETINFO, ld_info, ld_info_size))
+ return 0;
+ if (errno != ENOMEM)
+ return 1;
+ ld_info = realloc(ld_info, ld_info_size *= 2);
+ }
+ }
+
+ /* find the loaded module whose data area contains the
+ * address passed in. Remember that procedure pointers
+ * are implemented as pointers to descriptors in the
+ * data area of the module defining the procedure
+ */
+ static struct ld_info* getinfo(void* module)
+ {
+ struct ld_info* info = ld_info;
+ register int n = 1;
+
+ if (!ld_info || module != last_module)
+ {
+ last_module = module;
+ if (getquery())
+ return 0;
+ info = ld_info;
+ }
+ while (n)
+ {
+ if ((char*)(info->ldinfo_dataorg) <= (char*)module &&
+ (char*)module <= ((char*)(info->ldinfo_dataorg)
+ + (unsigned)(info->ldinfo_datasize)))
+ return info;
+ if (n=info->ldinfo_next)
+ info = (void*)((char*)info + n);
+ }
+ return 0;
+ }
+
+ static char* getloc(struct hdr* hdr, char* data, char* name)
+ {
+ struct ldhdr* ldhdr;
+ struct ldsym* ldsym;
+ ulong datareloc;
+ ulong textreloc;
+ int i;
+
+ /* data is relocated by the difference between
+ * its virtual origin and where it was
+ * actually placed
+ */
+ /*N.B. o_sndata etc. are one based */
+ datareloc = (ulong)data - hdr->s[hdr->a.o_sndata-1].s_vaddr;
+ /*hdr is address of header, not text, so add text s_scnptr */
+ textreloc = (ulong)hdr + hdr->s[hdr->a.o_sntext-1].s_scnptr
+ - hdr->s[hdr->a.o_sntext-1].s_vaddr;
+ ldhdr = (void*)((char*)hdr+ hdr->s[hdr->a.o_snloader-1].s_scnptr);
+ ldsym = (void*) (ldhdr+1);
+ /* search the exports symbols */
+ for(i=0; i < ldhdr->l_nsyms;ldsym++,i++)
+ {
+ char *symname,symbuf[9];
+ char *loc;
+ /* the symbol name representation is a nuisance since
+ * 8 character names appear in l_name but may
+ * not be null terminated. This code works around
+ * that by brute force
+ */
+ if (ldsym->l_zeroes)
+ {
+ symname = symbuf;
+ memcpy(symbuf,ldsym->l_name,8);
+ symbuf[8] = 0;
+ }
+ else
+ symname = (void*)(ldsym->l_offset + (ulong)ldhdr + ldhdr->l_stoff);
+ if (strcmp(symname,name))
+ continue;
+ loc = (char*)ldsym->l_value;
+ if ((ldsym->l_scnum==hdr->a.o_sndata) ||
+ (ldsym->l_scnum==hdr->a.o_snbss))
+ loc += datareloc;
+ else if (ldsym->l_scnum==hdr->a.o_sntext)
+ loc += textreloc;
+ return loc;
+ }
+ return 0;
+ }
+
+ extern void* dlsym(void* handle, const char* name)
+ {
+ void* addr;
+ struct ld_info* info;
+
+ if (!(info = getinfo(handle)) || !(addr = getloc(info->ldinfo_textorg,info->ldinfo_dataorg,(char*)name)))
+ {
+ err = errno;
+ return 0;
+ }
+ return addr;
+ }
+
+ extern char* dlerror(void)
+ {
+ char* msg;
+
+ if (!err)
+ return 0;
+ msg = fmterror(err);
+ err = 0;
+ return msg;
+ }
+
+#else
+#if _hdr_dll && _lib_dllload
+
+ /*
+ * MVS
+ */
+
+# include <dll.h>
+
+ static int err;
+
+ extern void* dlopen(const char* path, int mode)
+ {
+ void* dll;
+
+ NoP(mode);
+ if (!(dll = (void*)dllload(path)))
+ err = errno;
+ return dll;
+ }
+
+ extern int dlclose(void* dll)
+ {
+ return 0;
+ }
+
+ extern void* dlsym(void* handle, const char* name)
+ {
+ void* addr;
+
+ if (!(addr = (void*)dllqueryfn(handle, (char*)name)))
+ err = errno;
+ return addr;
+ }
+
+ extern char* dlerror(void)
+ {
+ char* msg;
+
+ if (!err)
+ return 0;
+ msg = fmterror(err);
+ err = 0;
+ return msg;
+ }
+
+#else
+#if _hdr_mach_o_dyld
+
+ /*
+ * mac[h]
+ */
+
+# include <mach-o/dyld.h>
+
+ typedef const struct mach_header* NSImage;
+
+ typedef struct Dll_s
+ {
+ unsigned long magic;
+ NSImage image;
+ NSModule module;
+ char path[1];
+ } Dll_t;
+
+ #define DL_MAGIC 0x04190c04
+ #define DL_NEXT ((Dll_t*)RTLD_NEXT)
+
+ static const char* dlmessage = "no error";
+
+ static const char e_cover[] = T("cannot access covered library");
+ static const char e_handle[] = T("invalid handle");
+ static const char e_space[] = T("out of space");
+ static const char e_static[] = T("image statically linked");
+ static const char e_undefined[] = T("undefined symbol");
+
+ static Dll_t global = { DL_MAGIC };
+
+ static void undefined(const char* name)
+ {
+ }
+
+ static NSModule multiple(NSSymbol sym, NSModule om, NSModule nm)
+ {
+ return om;
+ }
+
+ static void linkedit(NSLinkEditErrors c, int n, const char* f, const char* m)
+ {
+ dlmessage = m;
+ }
+
+ static NSLinkEditErrorHandlers handlers =
+ {
+ undefined, multiple, linkedit
+ };
+
+ extern void* dlopen(const char* path, int mode)
+ {
+ Dll_t* dll;
+ int i;
+ NSObjectFileImage image;
+
+ static int init = 0;
+
+ if (!_dyld_present())
+ {
+ dlmessage = e_static;
+ return 0;
+ }
+ if (!init)
+ {
+ init = 1;
+ NSInstallLinkEditErrorHandlers(&handlers);
+ }
+ if (!path)
+ dll = &global;
+ else if (!(dll = newof(0, Dll_t, 1, strlen(path))))
+ {
+ dlmessage = e_space;
+ return 0;
+ }
+ else
+ {
+ switch (NSCreateObjectFileImageFromFile(path, &image))
+ {
+ case NSObjectFileImageSuccess:
+ dll->module = NSLinkModule(image, path, (mode & RTLD_LAZY) ? 0 : NSLINKMODULE_OPTION_BINDNOW);
+ NSDestroyObjectFileImage(image);
+ if (!dll->module)
+ {
+ free(dll);
+ return 0;
+ }
+ break;
+ case NSObjectFileImageInappropriateFile:
+ dll->image = NSAddImage(path, 0);
+ if (!dll->image)
+ {
+ free(dll);
+ return 0;
+ }
+ break;
+ default:
+ free(dll);
+ return 0;
+ }
+ strcpy(dll->path, path);
+ dll->magic = DL_MAGIC;
+ }
+ return (void*)dll;
+ }
+
+ extern int dlclose(void* handle)
+ {
+ Dll_t* dll = (Dll_t*)handle;
+
+ if (!dll || dll == DL_NEXT || dll->magic != DL_MAGIC)
+ {
+ dlmessage = e_handle;
+ return -1;
+ }
+ if (dll->module)
+ NSUnLinkModule(dll->module, 0);
+ free(dll);
+ return 0;
+ }
+
+ static NSSymbol
+ lookup(Dll_t* dll, const char* name)
+ {
+ unsigned long pun;
+ void* address;
+
+ if (dll == DL_NEXT)
+ {
+ if (!_dyld_func_lookup(name, &pun))
+ return 0;
+ address = (NSSymbol)pun;
+ }
+ else if (dll->module)
+ address = NSLookupSymbolInModule(dll->module, name);
+ else if (dll->image)
+ {
+ if (!NSIsSymbolNameDefinedInImage(dll->image, name))
+ return 0;
+ address = NSLookupSymbolInImage(dll->image, name, 0);
+ }
+ else
+ {
+ if (!NSIsSymbolNameDefined(name))
+ return 0;
+ address = NSLookupAndBindSymbol(name);
+ }
+ if (address)
+ address = NSAddressOfSymbol(address);
+ return address;
+ }
+
+ extern void* dlsym(void* handle, const char* name)
+ {
+ Dll_t* dll = (Dll_t*)handle;
+ NSSymbol address;
+ char buf[1024];
+
+ if (!dll || dll != DL_NEXT && (dll->magic != DL_MAGIC || !dll->image && !dll->module))
+ {
+ dlmessage = e_handle;
+ return 0;
+ }
+ if (!(address = lookup(dll, name)) && name[0] != '_' && strlen(name) < (sizeof(buf) - 1))
+ {
+ buf[0] = '_';
+ strcpy(buf + 1, name);
+ address = lookup(dll, buf);
+ }
+ if (!address)
+ {
+ dlmessage = dll == DL_NEXT ? e_cover : e_undefined;
+ return 0;
+ }
+ return (void*)address;
+ }
+
+ extern char* dlerror(void)
+ {
+ char* msg;
+
+ msg = (char*)dlmessage;
+ dlmessage = 0;
+ return msg;
+ }
+
+#else
+ /*
+ * punt
+ */
+
+ static int err;
+
+ extern void* dlopen(const char* path, int mode)
+ {
+ err = 1;
+ return 0;
+ }
+
+ extern int dlclose(void* dll)
+ {
+ err = 1;
+ return 0;
+ }
+
+ extern void* dlsym(void* handle, const char* name)
+ {
+ err = 1;
+ return 0;
+ }
+
+ extern char* dlerror(void)
+ {
+ if (!err)
+ return 0;
+ err = 0;
+ return "dynamic linking not supported";
+ }
+
+#endif
+#endif
+#endif
+#endif
+#endif
diff --git a/usr/src/lib/libdll/common/dllfind.c b/usr/src/lib/libdll/common/dllfind.c
new file mode 100644
index 0000000000..beba43cdc2
--- /dev/null
+++ b/usr/src/lib/libdll/common/dllfind.c
@@ -0,0 +1,46 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1997-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ */
+
+#include <ast.h>
+#include <dlldefs.h>
+#include <error.h>
+
+/*
+ * find and load library name with optional version ver and dlopen() flags
+ * at least one dlopen() is called to initialize dlerror()
+ * if path!=0 then library path up to size chars copied to path with trailing 0
+ * if name contains a directory prefix then library search is limited to the dir and siblings
+ */
+
+extern void*
+dllfind(const char* lib, const char* ver, int flags, char* path, size_t size)
+{
+ char* id;
+ void* dll;
+
+ if ((id = error_info.id) && (dll = dllplug(id, lib, ver, flags, path, size)))
+ return dll;
+ return dllplug(NiL, lib, ver, flags, path, size);
+}
diff --git a/usr/src/lib/libdll/common/dlllook.c b/usr/src/lib/libdll/common/dlllook.c
new file mode 100644
index 0000000000..5a408d8df5
--- /dev/null
+++ b/usr/src/lib/libdll/common/dlllook.c
@@ -0,0 +1,46 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1997-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ */
+
+#include <ast.h>
+#include <dlldefs.h>
+
+/*
+ * dlsym() with `_' weak fallback
+ */
+
+void*
+dlllook(void* dll, const char* name)
+{
+ register void* addr;
+ char buf[256];
+
+ if (!(addr = dlsym(dll, name)) && strlen(name) < (sizeof(buf) - 2))
+ {
+ buf[0] = '_';
+ strcpy(buf + 1, name);
+ addr = dlsym(dll, buf);
+ }
+ return addr;
+}
diff --git a/usr/src/lib/libdll/common/dllnext.c b/usr/src/lib/libdll/common/dllnext.c
new file mode 100644
index 0000000000..a932d96c7c
--- /dev/null
+++ b/usr/src/lib/libdll/common/dllnext.c
@@ -0,0 +1,223 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1997-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#ifndef __EXTENSIONS__
+#define __EXTENSIONS__ 1
+#endif
+
+#include <ast.h>
+#include <dlldefs.h>
+
+#if _hdr_rld_interface
+#include <rld_interface.h>
+#endif
+
+/*
+ * return a handle for the next layer down,
+ * i.e., the next layer that has symbols covered
+ * by the main prog and dll's loaded so far
+ *
+ * intentionally light on external lib calls
+ * so this routine can be used early in process
+ * startup
+ */
+
+#ifdef _DLL_RLD_SYM
+
+#define DEBUG 1
+
+#if DEBUG
+
+typedef ssize_t (*Write_f)(int, const void*, size_t);
+
+#endif
+
+#undef dllnext
+
+void*
+_dll_next(int flags, _DLL_RLD_SYM_TYPE* here)
+{
+ register char* vp;
+ register void* lp;
+ register int found = 0;
+ char* s;
+ char* b;
+ char* e;
+ char dummy[256];
+#if DEBUG
+ Write_f wr = 0;
+ Write_f xr;
+ char buf[1024];
+#endif
+
+#if DEBUG
+ if (getenv("DLL_DEBUG") && (vp = (char*)_rld_new_interface(_RLD_FIRST_PATHNAME)))
+ {
+ do
+ {
+ if (strcmp(vp, "MAIN") && (lp = dlopen(vp, flags)))
+ {
+ if (xr = (Write_f)dlsym(lp, "write"))
+ wr = xr;
+ }
+ } while (vp = (char*)_rld_new_interface(_RLD_NEXT_PATHNAME));
+ }
+#endif
+ if (vp = (char*)_rld_new_interface(_RLD_FIRST_PATHNAME))
+ {
+ do
+ {
+ if (lp = dlopen(strcmp(vp, "MAIN") ? vp : (char*)0, flags))
+ {
+ if (found)
+ {
+ b = e = 0;
+ s = vp;
+ for (;;)
+ {
+ switch (*s++)
+ {
+ case 0:
+ break;
+ case '/':
+ b = s;
+ e = 0;
+ continue;
+ case '.':
+ if (!e)
+ e = s - 1;
+ continue;
+ default:
+ continue;
+ }
+ break;
+ }
+ if (b && e)
+ {
+ s = dummy;
+ *s++ = '_';
+ *s++ = '_';
+ while (b < e)
+ *s++ = *b++;
+ b = "_dummy";
+ while (*s++ = *b++);
+ if (dlsym(lp, dummy))
+ {
+ dlclose(lp);
+ lp = 0;
+ }
+ }
+ if (lp)
+ {
+#if DEBUG
+ if (wr)
+ (*wr)(2, buf, sfsprintf(buf, sizeof(buf), "dll: next %s\n", vp));
+#endif
+ return lp;
+ }
+#if DEBUG
+ else if (wr)
+ (*wr)(2, buf, sfsprintf(buf, sizeof(buf), "dll: skip %s\n", vp));
+#endif
+ }
+ else if ((_DLL_RLD_SYM_TYPE*)dlsym(lp, _DLL_RLD_SYM_STR) == here)
+ {
+#if DEBUG
+ if (wr)
+ (*wr)(2, buf, sfsprintf(buf, sizeof(buf), "dll: this %s\n", vp));
+#endif
+ found = 1;
+ }
+ }
+ } while (vp = (char*)_rld_new_interface(_RLD_NEXT_PATHNAME));
+ }
+ return dllnext(flags);
+}
+
+#endif
+
+#ifndef RTLD_NEXT
+#if _dll_DYNAMIC
+
+#include <link.h>
+
+extern struct link_dynamic _DYNAMIC;
+
+#endif
+#endif
+
+void*
+dllnext(int flags)
+{
+ register void* dll;
+#ifndef RTLD_NEXT
+#if _dll_DYNAMIC
+ register struct link_map* map;
+ register char* s;
+ register char* b;
+#endif
+ register char* ver;
+ char* path;
+
+ static char next[] = { _DLL_NEXT_PATH };
+#endif
+
+#ifdef RTLD_NEXT
+ dll = RTLD_NEXT;
+#else
+ path = next;
+#if _dll_DYNAMIC
+ for (map = _DYNAMIC.ld_un.ld_1->ld_loaded; map; map = map->lm_next)
+ {
+ b = 0;
+ s = map->lm_name;
+ while (*s)
+ if (*s++ == '/')
+ b = s;
+ if (b && b[0] == 'l' && b[1] == 'i' && b[2] == 'b' && b[3] == 'c' && b[4] == '.')
+ {
+ path = map->lm_name;
+ break;
+ }
+ }
+#endif
+ ver = path + strlen(path);
+ while (!(dll = dlopen(path, flags)))
+ {
+ do
+ {
+ if (ver <= path)
+ return 0;
+ } while (*--ver != '.');
+ if (*(ver + 1) <= '0' || *(ver + 1) >= '9')
+ return 0;
+ *ver = 0;
+ }
+#endif
+ return dll;
+}
diff --git a/usr/src/lib/libdll/common/dllplug.c b/usr/src/lib/libdll/common/dllplug.c
new file mode 100644
index 0000000000..303ffb513a
--- /dev/null
+++ b/usr/src/lib/libdll/common/dllplug.c
@@ -0,0 +1,75 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1997-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ */
+
+#include <ast.h>
+#include <dlldefs.h>
+#include <error.h>
+
+/*
+ * find and load lib plugin/module library name with optional version ver and dlopen() flags
+ * at least one dlopen() is called to initialize dlerror()
+ * if path!=0 then library path up to size chars copied to path with trailing 0
+ * if name contains a directory prefix then library search is limited to the dir and siblings
+ */
+
+extern void*
+dllplug(const char* lib, const char* name, const char* ver, int flags, char* path, size_t size)
+{
+ void* dll;
+ int hit;
+ Dllscan_t* dls;
+ Dllent_t* dle;
+
+ hit = 0;
+ for (;;)
+ {
+ if (dls = dllsopen(lib, name, ver))
+ {
+ while (dle = dllsread(dls))
+ {
+ hit = 1;
+ if (dll = dlopen(dle->path, flags|RTLD_GLOBAL|RTLD_PARENT))
+ {
+ if (path && size)
+ strncopy(path, dle->path, size);
+ break;
+ }
+ else
+ errorf("dll", NiL, 1, "%s: dlopen failed: %s", dle->path, dlerror());
+ }
+ dllsclose(dls);
+ }
+ if (hit)
+ return dll;
+ if (!lib)
+ break;
+ lib = 0;
+ }
+ if (!(dll = dlopen(name, flags)) && !strchr(name, '/') && strchr(name, '.'))
+ dll = dlopen(sfprints("./%s", name), flags);
+ if (dll && path && size)
+ strncopy(path, name, size);
+ return dll;
+}
diff --git a/usr/src/lib/libdll/common/dllscan.c b/usr/src/lib/libdll/common/dllscan.c
new file mode 100644
index 0000000000..e40296348e
--- /dev/null
+++ b/usr/src/lib/libdll/common/dllscan.c
@@ -0,0 +1,492 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1997-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ */
+
+#define _DLLINFO_PRIVATE_ \
+ char* sib[3]; \
+ char sibbuf[64]; \
+ char envbuf[64];
+
+#define _DLLSCAN_PRIVATE_ \
+ Dllent_t entry; \
+ Uniq_t* uniq; \
+ int flags; \
+ Vmalloc_t* vm; \
+ Dt_t* dict; \
+ Dtdisc_t disc; \
+ FTS* fts; \
+ FTSENT* ent; \
+ Sfio_t* tmp; \
+ char** sb; \
+ char** sp; \
+ char* pb; \
+ char* pp; \
+ char* pe; \
+ int off; \
+ int prelen; \
+ int suflen; \
+ char** lib; \
+ char nam[64]; \
+ char pat[64]; \
+ char buf[64];
+
+#define DLL_MATCH_DONE 0x8000
+#define DLL_MATCH_NAME 0x4000
+#define DLL_MATCH_VERSION 0x2000
+
+#include <ast.h>
+#include <cdt.h>
+#include <ctype.h>
+#include <error.h>
+#include <fts.h>
+#include <vmalloc.h>
+
+typedef struct Uniq_s
+{
+ Dtlink_t link;
+ char name[1];
+} Uniq_t;
+
+#include <dlldefs.h>
+
+static char bin[] = "bin";
+static char lib[] = "lib";
+
+/*
+ * we need a sibling dir in PATH to search for dlls
+ * the confstr LIBPATH provides the local info
+ *
+ * <sibling-dir>[:<env-var>[:<host-pattern>]][,...]
+ *
+ * if <host-pattern> is present then it must match confstr HOSTTYPE
+ */
+
+Dllinfo_t*
+dllinfo(void)
+{
+ register char* s;
+ register char* h;
+ char* d;
+ char* v;
+ char* p;
+ int dn;
+ int vn;
+ int pn;
+ char pat[256];
+
+ static Dllinfo_t info;
+
+ if (!info.sibling)
+ {
+ info.sibling = info.sib;
+ if (*(s = astconf("LIBPATH", NiL, NiL)))
+ {
+ while (*s == ':' || *s == ',')
+ s++;
+ if (*s)
+ {
+ h = 0;
+ for (;;)
+ {
+ for (d = s; *s && *s != ':' && *s != ','; s++);
+ if (!(dn = s - d))
+ d = 0;
+ if (*s == ':')
+ {
+ for (v = ++s; *s && *s != ':' && *s != ','; s++);
+ if (!(vn = s - v))
+ v = 0;
+ if (*s == ':')
+ {
+ for (p = ++s; *s && *s != ':' && *s != ','; s++);
+ if (!(pn = s - p))
+ p = 0;
+ }
+ else
+ p = 0;
+ }
+ else
+ {
+ v = 0;
+ p = 0;
+ }
+ while (*s && *s++ != ',');
+ if (!*s || !p || !h && !*(h = astconf("HOSTTYPE", NiL, NiL)))
+ break;
+ if (pn >= sizeof(pat))
+ pn = sizeof(pat) - 1;
+ memcpy(pat, p, pn);
+ pat[pn] = 0;
+ if (strmatch(h, pat))
+ break;
+ }
+ if (d && dn < sizeof(info.sibbuf))
+ {
+ memcpy(info.sibbuf, d, dn);
+ info.sibling[0] = info.sibbuf;
+ }
+ if (v && vn < sizeof(info.envbuf))
+ {
+ memcpy(info.envbuf, v, vn);
+ info.env = info.envbuf;
+ }
+ }
+ }
+ if (!info.sibling[0] || streq(info.sibling[0], bin))
+ info.sibling[0] = bin;
+ if (!streq(info.sibling[0], lib))
+ info.sibling[1] = lib;
+ if (!info.env)
+ info.env = "LD_LIBRARY_PATH";
+ info.prefix = astconf("LIBPREFIX", NiL, NiL);
+ info.suffix = astconf("LIBSUFFIX", NiL, NiL);
+ if (streq(info.suffix, ".dll"))
+ info.flags |= DLL_INFO_PREVER;
+ else
+ info.flags |= DLL_INFO_DOTVER;
+ }
+ return &info;
+}
+
+/*
+ * fts version sort order
+ * higher versions appear first
+ */
+
+static int
+vercmp(FTSENT* const* ap, FTSENT* const* bp)
+{
+ register unsigned char* a = (unsigned char*)(*ap)->fts_name;
+ register unsigned char* b = (unsigned char*)(*bp)->fts_name;
+ register int n;
+ register int m;
+ char* e;
+
+ for (;;)
+ {
+ if (isdigit(*a) && isdigit(*b))
+ {
+ m = strtol((char*)a, &e, 10);
+ a = (unsigned char*)e;
+ n = strtol((char*)b, &e, 10);
+ b = (unsigned char*)e;
+ if (n -= m)
+ return n;
+ }
+ if (n = *a - *b)
+ return n;
+ if (!*a++)
+ return *b ? 0 : -1;
+ if (!*b++)
+ return 1;
+ }
+ /*NOTREACHED*/
+}
+
+/*
+ * open a scan stream
+ */
+
+Dllscan_t*
+dllsopen(const char* lib, const char* name, const char* version)
+{
+ register char* s;
+ register char* t;
+ Dllscan_t* scan;
+ Dllinfo_t* info;
+ Vmalloc_t* vm;
+ int i;
+ char buf[32];
+
+ if (!(vm = vmopen(Vmdcheap, Vmlast, 0)))
+ return 0;
+ if (lib && *lib && (*lib != '-' || *(lib + 1)))
+ {
+ /*
+ * grab the local part of the library id
+ */
+
+ if (s = strrchr(lib, ':'))
+ lib = (const char*)(s + 1);
+ i = 2 * sizeof(char**) + strlen(lib) + 5;
+ }
+ else
+ {
+ lib = 0;
+ i = 0;
+ }
+ if (!(scan = vmnewof(vm, 0, Dllscan_t, 1, i)) || !(scan->tmp = sfstropen()))
+ {
+ vmclose(vm);
+ return 0;
+ }
+ if (lib)
+ {
+ scan->lib = (char**)(scan + 1);
+ s = *scan->lib = (char*)(scan->lib + 2);
+ sfsprintf(s, i, "lib/%s", lib);
+ }
+ scan->vm = vm;
+ info = dllinfo();
+ scan->flags = info->flags;
+ if (!name || !*name || *name == '-' && !*(name + 1))
+ {
+ name = (const char*)"?*";
+ scan->flags |= DLL_MATCH_NAME;
+ }
+ else if (t = strrchr(name, '/'))
+ {
+ if (!(scan->pb = vmnewof(vm, 0, char, t - (char*)name, 2)))
+ goto bad;
+ memcpy(scan->pb, name, t - (char*)name);
+ name = (const char*)(t + 1);
+ }
+ if (!version || !*version || *version == '-' && !*(version + 1))
+ {
+ version = 0;
+ scan->flags |= DLL_MATCH_VERSION;
+ sfsprintf(scan->nam, sizeof(scan->nam), "%s%s%s", info->prefix, name, info->suffix);
+ }
+ else if (scan->flags & DLL_INFO_PREVER)
+ {
+ sfprintf(scan->tmp, "%s%s", info->prefix, name);
+ for (s = (char*)version; *s; s++)
+ if (isdigit(*s))
+ sfputc(scan->tmp, *s);
+ sfprintf(scan->tmp, "%s", info->suffix);
+ if (!(s = sfstruse(scan->tmp)))
+ goto bad;
+ sfsprintf(scan->nam, sizeof(scan->nam), "%s", s);
+ }
+ else
+ {
+ scan->flags |= DLL_MATCH_VERSION;
+ sfsprintf(scan->nam, sizeof(scan->nam), "%s%s%s.%s", info->prefix, name, info->suffix, version);
+ }
+ if (scan->flags & (DLL_MATCH_NAME|DLL_MATCH_VERSION))
+ {
+ if (scan->flags & DLL_INFO_PREVER)
+ {
+ if (!version)
+ version = "*([0-9_])";
+ else
+ {
+ t = buf;
+ for (s = (char*)version; *s; s++)
+ if (isdigit(*s) && t < &buf[sizeof(buf)-1])
+ *t++ = *s;
+ *t = 0;
+ version = (const char*)buf;
+ }
+ sfsprintf(scan->pat, sizeof(scan->pat), "%s%s%s%s", info->prefix, name, version, info->suffix);
+ }
+ else if (version)
+ sfsprintf(scan->pat, sizeof(scan->pat), "%s%s@(%s([-.])%s%s|%s.%s)", info->prefix, name, strchr(version, '.') ? "@" : "?", version, info->suffix, info->suffix, version);
+ else
+ {
+ version = "*([0-9.])";
+ sfsprintf(scan->pat, sizeof(scan->pat), "%s%s@(?([-.])%s%s|%s%s)", info->prefix, name, version, info->suffix, info->suffix, version);
+ }
+ }
+ scan->sp = scan->sb = (scan->lib ? scan->lib : info->sibling);
+ scan->prelen = strlen(info->prefix);
+ scan->suflen = strlen(info->suffix);
+ return scan;
+ bad:
+ dllsclose(scan);
+ return 0;
+}
+
+/*
+ * close a scan stream
+ */
+
+int
+dllsclose(Dllscan_t* scan)
+{
+ if (!scan)
+ return -1;
+ if (scan->fts)
+ fts_close(scan->fts);
+ if (scan->dict)
+ dtclose(scan->dict);
+ if (scan->tmp)
+ sfclose(scan->tmp);
+ if (scan->vm)
+ vmclose(scan->vm);
+ return 0;
+}
+
+/*
+ * return the next scan stream entry
+ */
+
+Dllent_t*
+dllsread(register Dllscan_t* scan)
+{
+ register char* p;
+ register char* b;
+ register char* t;
+ register Uniq_t* u;
+ register int n;
+ register int m;
+
+ if (scan->flags & DLL_MATCH_DONE)
+ return 0;
+ again:
+ do
+ {
+ while (!scan->ent || !(scan->ent = scan->ent->fts_link))
+ {
+ if (scan->fts)
+ {
+ fts_close(scan->fts);
+ scan->fts = 0;
+ }
+ if (!scan->pb)
+ scan->pb = pathbin();
+ else if (!*scan->sp)
+ {
+ scan->sp = scan->sb;
+ if (!*scan->pe++)
+ return 0;
+ scan->pb = scan->pe;
+ }
+ for (p = scan->pp = scan->pb; *p && *p != ':'; p++)
+ if (*p == '/')
+ scan->pp = p;
+ scan->pe = p;
+ if (*scan->sp == bin)
+ scan->off = sfprintf(scan->tmp, "%-.*s", scan->pe - scan->pb, scan->pb);
+ else
+ scan->off = sfprintf(scan->tmp, "%-.*s/%s", scan->pp - scan->pb, scan->pb, *scan->sp);
+ scan->sp++;
+ if (!(scan->flags & DLL_MATCH_NAME))
+ {
+ sfprintf(scan->tmp, "/%s", scan->nam);
+ if (!(p = sfstruse(scan->tmp)))
+ return 0;
+ if (!eaccess(p, R_OK))
+ {
+ b = scan->nam;
+ goto found;
+ }
+ if (errno != ENOENT)
+ continue;
+ }
+ if (scan->flags & (DLL_MATCH_NAME|DLL_MATCH_VERSION))
+ {
+ sfstrseek(scan->tmp, scan->off, SEEK_SET);
+ if (!(t = sfstruse(scan->tmp)))
+ return 0;
+ if ((scan->fts = fts_open((char**)t, FTS_LOGICAL|FTS_NOPOSTORDER|FTS_ONEPATH, vercmp)) && (scan->ent = fts_read(scan->fts)) && (scan->ent = fts_children(scan->fts, FTS_NOSTAT)))
+ break;
+ }
+ }
+ } while (!strmatch(scan->ent->fts_name, scan->pat));
+ b = scan->ent->fts_name;
+ sfstrseek(scan->tmp, scan->off, SEEK_SET);
+ sfprintf(scan->tmp, "/%s", b);
+ if (!(p = sfstruse(scan->tmp)))
+ return 0;
+ found:
+ b = scan->buf + sfsprintf(scan->buf, sizeof(scan->buf), "%s", b + scan->prelen);
+ if (!(scan->flags & DLL_INFO_PREVER))
+ while (b > scan->buf)
+ {
+ if (!isdigit(*(b - 1)) && *(b - 1) != '.')
+ break;
+ b--;
+ }
+ b -= scan->suflen;
+ if (b > (scan->buf + 2) && (*(b - 1) == 'g' || *(b - 1) == 'O') && *(b - 2) == '-')
+ b -= 2;
+ n = m = 0;
+ for (t = b; t > scan->buf; t--)
+ if (isdigit(*(t - 1)))
+ n = 1;
+ else if (*(t - 1) != m)
+ {
+ if (*(t - 1) == '.' || *(t - 1) == '-' || *(t - 1) == '_')
+ {
+ n = 1;
+ if (m)
+ {
+ m = -1;
+ t--;
+ break;
+ }
+ m = *(t - 1);
+ }
+ else
+ break;
+ }
+ if (n)
+ {
+ if (isdigit(t[0]) && isdigit(t[1]) && !isdigit(t[2]))
+ n = (t[0] - '0') * 10 + (t[1] - '0');
+ else if (isdigit(t[1]) && isdigit(t[2]) && !isdigit(t[3]))
+ n = (t[1] - '0') * 10 + (t[2] - '0');
+ else
+ n = 0;
+ if (n && !(n & (n - 1)))
+ {
+ if (!isdigit(t[0]))
+ t++;
+ m = *(t += 2);
+ }
+ if (m || (scan->flags & DLL_INFO_PREVER))
+ b = t;
+ }
+ *b = 0;
+ if (!*(b = scan->buf))
+ goto again;
+ if (scan->uniq)
+ {
+ if (!scan->dict)
+ {
+ scan->disc.key = offsetof(Uniq_t, name);
+ scan->disc.size = 0;
+ scan->disc.link = offsetof(Uniq_t, link);
+ if (!(scan->dict = dtopen(&scan->disc, Dthash)))
+ return 0;
+ dtinsert(scan->dict, scan->uniq);
+ }
+ if (dtmatch(scan->dict, b))
+ goto again;
+ if (!(u = vmnewof(scan->vm, 0, Uniq_t, 1, strlen(b))))
+ return 0;
+ strcpy(u->name, b);
+ dtinsert(scan->dict, u);
+ }
+ else if (!(scan->flags & DLL_MATCH_NAME))
+ scan->flags |= DLL_MATCH_DONE;
+ else if (!(scan->uniq = vmnewof(scan->vm, 0, Uniq_t, 1, strlen(b))))
+ return 0;
+ else
+ strcpy(scan->uniq->name, b);
+ scan->entry.name = b;
+ scan->entry.path = p;
+ return &scan->entry;
+}
diff --git a/usr/src/lib/libdll/common/features/dll b/usr/src/lib/libdll/common/features/dll
new file mode 100644
index 0000000000..c1a4900e3a
--- /dev/null
+++ b/usr/src/lib/libdll/common/features/dll
@@ -0,0 +1,235 @@
+set prototyped
+hdr dl,dlfcn,dll,rld_interface,mach-o/dyld
+sys ldr
+lib dlopen -ldl
+lib dllload,loadbind,shl_load -ldl
+tst dll_DYNAMIC link{
+ #include <sys/types.h>
+ #include <link.h>
+ extern struct link_dynamic _DYNAMIC;
+ int
+ main()
+ {
+ return _DYNAMIC.ld_version;
+ }
+}end
+tst run{
+ lib=
+ for d in /shlib /usr/shlib /lib /usr/lib
+ do if test -d $d
+ then for s in "*.*" "*[!a]*"
+ do for b in libc
+ do for i in $d/$b.$s
+ do if test -f $i
+ then lib=$i
+ fi
+ done
+ case $lib in
+ ?*) break 3 ;;
+ esac
+ done
+ done
+ fi
+ done
+ case $lib in
+ *.[0-9]*.[0-9]*)
+ i=`echo $lib | sed 's,\([^0-9]*[0-9]*\).*,\1,'`
+ if test -f $i
+ then lib=$i
+ fi
+ ;;
+ esac
+ # some run time linkers barf with /lib/xxx if
+ # /usr/lib/xxx is there
+ case $lib in
+ /usr*) ;;
+ *) if test -f /usr$lib
+ then lib=/usr$lib
+ fi
+ ;;
+ esac
+ case $lib in
+ "") lib=/lib/libc.so.1 ;;
+ esac
+ case $lib in
+ /usr/lib/*)
+ case `package` in
+ sgi.mips3)
+ abi=/lib32
+ ;;
+ sgi.mips4)
+ abi=/lib64
+ ;;
+ *) abi=
+ ;;
+ esac
+ case $abi in
+ ?*) if test -d $abi
+ then lib=`echo $lib | sed 's,/usr/lib/,,'`
+ lib=$abi/$lib
+ fi
+ ;;
+ esac
+ ;;
+ esac
+ echo "#define _DLL_NEXT_PATH \"$lib\""
+}end
+tst - output{
+ #if _hdr_dlfcn && _lib_dlopen
+ #include <dlfcn.h>
+ #endif
+ #if _hdr_rld_interface
+ #include <rld_interface.h>
+ #endif
+ int
+ main()
+ {
+ int i;
+ #if _hdr_rld_interface
+ void* dll;
+ static char* local[] = { "__elf_header", "_call_add_gp_range", "_etext" };
+ #endif
+ printf("\n");
+ #if _hdr_dlfcn && _lib_dlopen
+ printf("#include <dlfcn.h>\n");
+ #endif
+ #ifndef RTLD_LAZY
+ i = 0;
+ printf("\n");
+ printf("#define RTLD_LAZY 1\n");
+ #else
+ i = 1;
+ #endif
+ #ifndef RTLD_NOW
+ if (i)
+ {
+ i = 0;
+ printf("\n");
+ }
+ printf("#define RTLD_NOW 2\n");
+ #endif
+ #ifndef RTLD_GLOBAL
+ if (i)
+ {
+ i = 0;
+ printf("\n");
+ }
+ printf("#define RTLD_GLOBAL 0\n");
+ #endif
+ #ifndef RTLD_LOCAL
+ if (i)
+ {
+ i = 0;
+ printf("\n");
+ }
+ printf("#define RTLD_LOCAL 0\n");
+ #endif
+ #ifndef RTLD_PARENT
+ if (i)
+ {
+ i = 0;
+ printf("\n");
+ }
+ printf("#define RTLD_PARENT 0\n");
+ #endif
+ #if defined(_hdr_mach_o_dyld) && !defined(RTLD_NEXT)
+ if (i)
+ {
+ i = 0;
+ printf("\n");
+ }
+ printf("#define RTLD_NEXT ((void*)16)\n");
+ #endif
+ #if _hdr_rld_interface
+ if (!(dll = dlopen(0, RTLD_LAZY)))
+ i = -1;
+ else
+ {
+ for (i = 0; i < sizeof(local) / sizeof(local[0]); i++)
+ if (dlsym(dll, local[i]))
+ break;
+ if (i >= sizeof(local) / sizeof(local[0]))
+ i = -1;
+ }
+ if (i >= 0)
+ {
+ printf("\n");
+ printf("#define _DLL_RLD_SYM %s\n", local[i]);
+ printf("#define _DLL_RLD_SYM_STR \"%s\"\n", local[i]);
+ printf("#define _DLL_RLD_SYM_TYPE void*\n");
+ }
+ #endif
+ printf("\n");
+ printf("#define DLL_INFO_PREVER 0x0001 /* pre-suffix style version */\n");
+ printf("#define DLL_INFO_DOTVER 0x0002 /* post-suffix style version */\n");
+ printf("\n");
+ printf("typedef struct Dllinfo_s\n");
+ printf("{\n");
+ printf(" char** sibling; /* sibling dirs on $PATH */\n");
+ printf(" char* prefix; /* library name prefix */\n");
+ printf(" char* suffix; /* library name suffix */\n");
+ printf(" char* env; /* library path env var */\n");
+ printf(" int flags; /* DLL_INFO_* flags */\n");
+ printf("#ifdef _DLLINFO_PRIVATE_\n");
+ printf(" _DLLINFO_PRIVATE_\n");
+ printf("#endif\n");
+ printf("} Dllinfo_t;\n");
+ printf("\n");
+ printf("typedef struct Dllent_s\n");
+ printf("{\n");
+ printf(" char* path;\n");
+ printf(" char* name;\n");
+ printf("#ifdef _DLLENT_PRIVATE_\n");
+ printf(" _DLLENT_PRIVATE_\n");
+ printf("#endif\n");
+ printf("} Dllent_t;\n");
+ printf("\n");
+ printf("typedef struct Dllscan_s\n");
+ printf("{\n");
+ printf(" void* pad;\n");
+ printf("#ifdef _DLLSCAN_PRIVATE_\n");
+ printf(" _DLLSCAN_PRIVATE_\n");
+ printf("#endif\n");
+ printf("} Dllscan_t;\n");
+ #if !_hdr_dlfcn || !_lib_dlopen
+ printf("\n");
+ printf("extern void* dlopen(const char*, int);\n");
+ printf("extern void* dlsym(void*, const char*);\n");
+ printf("extern int dlclose(void*);\n");
+ printf("extern char* dlerror(void);\n");
+ #endif
+ printf("\n");
+ printf("#if _BLD_dll && defined(__EXPORT__)\n");
+ printf("#define extern __EXPORT__\n");
+ printf("#endif\n");
+ printf("\n");
+ printf("extern Dllinfo_t* dllinfo(void);\n");
+ printf("extern void* dllplug(const char*, const char*, const char*, int, char*, size_t);\n");
+ printf("extern void* dllfind(const char*, const char*, int, char*, size_t);\n");
+ printf("extern void* dllnext(int);\n");
+ printf("extern void* dlllook(void*, const char*);\n");
+ #if _hdr_rld_interface
+ if (i >= 0)
+ {
+ printf("\n");
+ printf("extern void* _dll_next(int, _DLL_RLD_SYM_TYPE*);\n");
+ printf("#define dllnext(f) _dll_next(f, &_DLL_RLD_SYM)\n");
+ }
+ #endif
+ printf("\n");
+ printf("extern Dllscan_t* dllsopen(const char*, const char*, const char*);\n");
+ printf("extern Dllent_t* dllsread(Dllscan_t*);\n");
+ printf("extern int dllsclose(Dllscan_t*);\n");
+ printf("\n");
+ printf("#undef extern\n");
+ #if _hdr_rld_interface
+ if (i >= 0)
+ {
+ printf("\n");
+ printf("extern _DLL_RLD_SYM_TYPE _DLL_RLD_SYM;\n");
+ }
+ #endif
+ printf("\n");
+ return 0;
+ }
+}end
diff --git a/usr/src/lib/libdll/common/llib-ldll b/usr/src/lib/libdll/common/llib-ldll
new file mode 100644
index 0000000000..446d400cd7
--- /dev/null
+++ b/usr/src/lib/libdll/common/llib-ldll
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * lib/libdll/common/llib-ldll
+ *
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*LINTLIBRARY*/
+/*PROTOLIB1*/
+
+#include <dlldefs.h>
+
+/* automatically generated data start here */
+extern Dllinfo_t* dllinfo(void);
+extern void* dllplug(const char*, const char*, const char*, int, char*, size_t);
+extern void* dllfind(const char*, const char*, int, char*, size_t);
+extern void* dllnext(int);
+extern void* dlllook(void*, const char*);
+extern Dllscan_t* dllsopen(const char*, const char*, const char*);
+extern Dllent_t* dllsread(Dllscan_t*);
+extern int dllsclose(Dllscan_t*);
+/* end of automatically generated data */
diff --git a/usr/src/lib/libdll/i386/Makefile b/usr/src/lib/libdll/i386/Makefile
new file mode 100644
index 0000000000..8577dbfcc9
--- /dev/null
+++ b/usr/src/lib/libdll/i386/Makefile
@@ -0,0 +1,37 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+# Fetch minor version from RELEASE, e.g. "10" for "5.10", "11" for "5.11" etc.
+GETRELEASEMINOR = /usr/bin/ksh -c 'x=$(RELEASE) ; print "$${x$(POUND_SIGN)$(POUND_SIGN)*.}"'
+
+# Platform-specific config
+# Note that "HOSTTYPE" matches the value used by AT&T upstream.
+DLLPLATFORMCPPFLAGS = '-DHOSTTYPE="sol$(GETRELEASEMINOR:sh).i386"'
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/usr/src/lib/libdll/i386/src/lib/libdll/FEATURE/dll b/usr/src/lib/libdll/i386/src/lib/libdll/FEATURE/dll
new file mode 100644
index 0000000000..4a4efa79a4
--- /dev/null
+++ b/usr/src/lib/libdll/i386/src/lib/libdll/FEATURE/dll
@@ -0,0 +1,125 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libdll/features/dll by iffe version 2007-04-04 : : */
+
+#ifndef _def_dll_dll
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dll_dll 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _hdr_dlfcn 1 /* #include <dlfcn.h> ok */
+#define _LIB_dl 1 /* -ldl is a library */
+#define _lib_dlopen 1 /* dlopen() in default lib(s) */
+#define _DLL_NEXT_PATH "/usr/lib/libc.so.1"
+
+#include <dlfcn.h>
+
+#define DLL_INFO_PREVER 0x0001 /* pre-suffix style version */
+#define DLL_INFO_DOTVER 0x0002 /* post-suffix style version */
+
+typedef struct Dllinfo_s
+{
+ char** sibling; /* sibling dirs on $PATH */
+ char* prefix; /* library name prefix */
+ char* suffix; /* library name suffix */
+ char* env; /* library path env var */
+ int flags; /* DLL_INFO_* flags */
+#ifdef _DLLINFO_PRIVATE_
+ _DLLINFO_PRIVATE_
+#endif
+} Dllinfo_t;
+
+typedef struct Dllent_s
+{
+ char* path;
+ char* name;
+#ifdef _DLLENT_PRIVATE_
+ _DLLENT_PRIVATE_
+#endif
+} Dllent_t;
+
+typedef struct Dllscan_s
+{
+ __V_* pad;
+#ifdef _DLLSCAN_PRIVATE_
+ _DLLSCAN_PRIVATE_
+#endif
+} Dllscan_t;
+
+#if _BLD_dll && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Dllinfo_t* dllinfo __PROTO__((void));
+extern __MANGLE__ __V_* dllplug __PROTO__((const char*, const char*, const char*, int, char*, size_t));
+extern __MANGLE__ __V_* dllfind __PROTO__((const char*, const char*, int, char*, size_t));
+extern __MANGLE__ __V_* dllnext __PROTO__((int));
+extern __MANGLE__ __V_* dlllook __PROTO__((__V_*, const char*));
+
+extern __MANGLE__ Dllscan_t* dllsopen __PROTO__((const char*, const char*, const char*));
+extern __MANGLE__ Dllent_t* dllsread __PROTO__((Dllscan_t*));
+extern __MANGLE__ int dllsclose __PROTO__((Dllscan_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libdll/i386/src/lib/libdll/dlldefs.h b/usr/src/lib/libdll/i386/src/lib/libdll/dlldefs.h
new file mode 100644
index 0000000000..4a4efa79a4
--- /dev/null
+++ b/usr/src/lib/libdll/i386/src/lib/libdll/dlldefs.h
@@ -0,0 +1,125 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/lib/libdll/features/dll by iffe version 2007-04-04 : : */
+
+#ifndef _def_dll_dll
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dll_dll 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _hdr_dlfcn 1 /* #include <dlfcn.h> ok */
+#define _LIB_dl 1 /* -ldl is a library */
+#define _lib_dlopen 1 /* dlopen() in default lib(s) */
+#define _DLL_NEXT_PATH "/usr/lib/libc.so.1"
+
+#include <dlfcn.h>
+
+#define DLL_INFO_PREVER 0x0001 /* pre-suffix style version */
+#define DLL_INFO_DOTVER 0x0002 /* post-suffix style version */
+
+typedef struct Dllinfo_s
+{
+ char** sibling; /* sibling dirs on $PATH */
+ char* prefix; /* library name prefix */
+ char* suffix; /* library name suffix */
+ char* env; /* library path env var */
+ int flags; /* DLL_INFO_* flags */
+#ifdef _DLLINFO_PRIVATE_
+ _DLLINFO_PRIVATE_
+#endif
+} Dllinfo_t;
+
+typedef struct Dllent_s
+{
+ char* path;
+ char* name;
+#ifdef _DLLENT_PRIVATE_
+ _DLLENT_PRIVATE_
+#endif
+} Dllent_t;
+
+typedef struct Dllscan_s
+{
+ __V_* pad;
+#ifdef _DLLSCAN_PRIVATE_
+ _DLLSCAN_PRIVATE_
+#endif
+} Dllscan_t;
+
+#if _BLD_dll && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Dllinfo_t* dllinfo __PROTO__((void));
+extern __MANGLE__ __V_* dllplug __PROTO__((const char*, const char*, const char*, int, char*, size_t));
+extern __MANGLE__ __V_* dllfind __PROTO__((const char*, const char*, int, char*, size_t));
+extern __MANGLE__ __V_* dllnext __PROTO__((int));
+extern __MANGLE__ __V_* dlllook __PROTO__((__V_*, const char*));
+
+extern __MANGLE__ Dllscan_t* dllsopen __PROTO__((const char*, const char*, const char*));
+extern __MANGLE__ Dllent_t* dllsread __PROTO__((Dllscan_t*));
+extern __MANGLE__ int dllsclose __PROTO__((Dllscan_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libdll/mapfile-vers b/usr/src/lib/libdll/mapfile-vers
new file mode 100644
index 0000000000..2ddb1442ce
--- /dev/null
+++ b/usr/src/lib/libdll/mapfile-vers
@@ -0,0 +1,42 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+# information generated from usr/src/lib/libdll/i386/src/lib/libdll/dlldefs.h
+SUNWprivate_1.1 {
+ global:
+ dllinfo;
+ dllplug;
+ dllsopen;
+ dllfind;
+ dllsread;
+ dllnext;
+ dlllook;
+ dllsclose;
+ local:
+ *;
+};
diff --git a/usr/src/lib/libdll/sparc/Makefile b/usr/src/lib/libdll/sparc/Makefile
new file mode 100644
index 0000000000..b45208ffc9
--- /dev/null
+++ b/usr/src/lib/libdll/sparc/Makefile
@@ -0,0 +1,37 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+# Fetch minor version from RELEASE, e.g. "10" for "5.10", "11" for "5.11" etc.
+GETRELEASEMINOR = /usr/bin/ksh -c 'x=$(RELEASE) ; print "$${x$(POUND_SIGN)$(POUND_SIGN)*.}"'
+
+# Platform-specific config
+# Note that "HOSTTYPE" matches the value used by AT&T upstream.
+DLLPLATFORMCPPFLAGS = '-DHOSTTYPE="sol$(GETRELEASEMINOR:sh).sun4"'
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/usr/src/lib/libdll/sparc/src/lib/libdll/FEATURE/dll b/usr/src/lib/libdll/sparc/src/lib/libdll/FEATURE/dll
new file mode 100644
index 0000000000..ea5573ff05
--- /dev/null
+++ b/usr/src/lib/libdll/sparc/src/lib/libdll/FEATURE/dll
@@ -0,0 +1,125 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libdll/features/dll by iffe version 2007-04-04 : : */
+
+#ifndef _def_dll_dll
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dll_dll 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _hdr_dlfcn 1 /* #include <dlfcn.h> ok */
+#define _LIB_dl 1 /* -ldl is a library */
+#define _lib_dlopen 1 /* dlopen() in default lib(s) */
+#define _DLL_NEXT_PATH "/usr/lib/libc.so.1"
+
+#include <dlfcn.h>
+
+#define DLL_INFO_PREVER 0x0001 /* pre-suffix style version */
+#define DLL_INFO_DOTVER 0x0002 /* post-suffix style version */
+
+typedef struct Dllinfo_s
+{
+ char** sibling; /* sibling dirs on $PATH */
+ char* prefix; /* library name prefix */
+ char* suffix; /* library name suffix */
+ char* env; /* library path env var */
+ int flags; /* DLL_INFO_* flags */
+#ifdef _DLLINFO_PRIVATE_
+ _DLLINFO_PRIVATE_
+#endif
+} Dllinfo_t;
+
+typedef struct Dllent_s
+{
+ char* path;
+ char* name;
+#ifdef _DLLENT_PRIVATE_
+ _DLLENT_PRIVATE_
+#endif
+} Dllent_t;
+
+typedef struct Dllscan_s
+{
+ __V_* pad;
+#ifdef _DLLSCAN_PRIVATE_
+ _DLLSCAN_PRIVATE_
+#endif
+} Dllscan_t;
+
+#if _BLD_dll && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Dllinfo_t* dllinfo __PROTO__((void));
+extern __MANGLE__ __V_* dllplug __PROTO__((const char*, const char*, const char*, int, char*, size_t));
+extern __MANGLE__ __V_* dllfind __PROTO__((const char*, const char*, int, char*, size_t));
+extern __MANGLE__ __V_* dllnext __PROTO__((int));
+extern __MANGLE__ __V_* dlllook __PROTO__((__V_*, const char*));
+
+extern __MANGLE__ Dllscan_t* dllsopen __PROTO__((const char*, const char*, const char*));
+extern __MANGLE__ Dllent_t* dllsread __PROTO__((Dllscan_t*));
+extern __MANGLE__ int dllsclose __PROTO__((Dllscan_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libdll/sparc/src/lib/libdll/dlldefs.h b/usr/src/lib/libdll/sparc/src/lib/libdll/dlldefs.h
new file mode 100644
index 0000000000..ea5573ff05
--- /dev/null
+++ b/usr/src/lib/libdll/sparc/src/lib/libdll/dlldefs.h
@@ -0,0 +1,125 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/lib/libdll/features/dll by iffe version 2007-04-04 : : */
+
+#ifndef _def_dll_dll
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dll_dll 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _hdr_dlfcn 1 /* #include <dlfcn.h> ok */
+#define _LIB_dl 1 /* -ldl is a library */
+#define _lib_dlopen 1 /* dlopen() in default lib(s) */
+#define _DLL_NEXT_PATH "/usr/lib/libc.so.1"
+
+#include <dlfcn.h>
+
+#define DLL_INFO_PREVER 0x0001 /* pre-suffix style version */
+#define DLL_INFO_DOTVER 0x0002 /* post-suffix style version */
+
+typedef struct Dllinfo_s
+{
+ char** sibling; /* sibling dirs on $PATH */
+ char* prefix; /* library name prefix */
+ char* suffix; /* library name suffix */
+ char* env; /* library path env var */
+ int flags; /* DLL_INFO_* flags */
+#ifdef _DLLINFO_PRIVATE_
+ _DLLINFO_PRIVATE_
+#endif
+} Dllinfo_t;
+
+typedef struct Dllent_s
+{
+ char* path;
+ char* name;
+#ifdef _DLLENT_PRIVATE_
+ _DLLENT_PRIVATE_
+#endif
+} Dllent_t;
+
+typedef struct Dllscan_s
+{
+ __V_* pad;
+#ifdef _DLLSCAN_PRIVATE_
+ _DLLSCAN_PRIVATE_
+#endif
+} Dllscan_t;
+
+#if _BLD_dll && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Dllinfo_t* dllinfo __PROTO__((void));
+extern __MANGLE__ __V_* dllplug __PROTO__((const char*, const char*, const char*, int, char*, size_t));
+extern __MANGLE__ __V_* dllfind __PROTO__((const char*, const char*, int, char*, size_t));
+extern __MANGLE__ __V_* dllnext __PROTO__((int));
+extern __MANGLE__ __V_* dlllook __PROTO__((__V_*, const char*));
+
+extern __MANGLE__ Dllscan_t* dllsopen __PROTO__((const char*, const char*, const char*));
+extern __MANGLE__ Dllent_t* dllsread __PROTO__((Dllscan_t*));
+extern __MANGLE__ int dllsclose __PROTO__((Dllscan_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libdll/sparcv9/Makefile b/usr/src/lib/libdll/sparcv9/Makefile
new file mode 100644
index 0000000000..dab99d2e2d
--- /dev/null
+++ b/usr/src/lib/libdll/sparcv9/Makefile
@@ -0,0 +1,38 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+# Fetch minor version from RELEASE, e.g. "10" for "5.10", "11" for "5.11" etc.
+GETRELEASEMINOR = /usr/bin/ksh -c 'x=$(RELEASE) ; print "$${x$(POUND_SIGN)$(POUND_SIGN)*.}"'
+
+# Platform-specific config
+# Note that "HOSTTYPE" matches the value used by AT&T upstream.
+DLLPLATFORMCPPFLAGS = '-DHOSTTYPE="sol$(GETRELEASEMINOR:sh).sun4"'
+
+include ../Makefile.com
+include ../../Makefile.lib.64
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/libdll/sparcv9/src/lib/libdll/FEATURE/dll b/usr/src/lib/libdll/sparcv9/src/lib/libdll/FEATURE/dll
new file mode 100644
index 0000000000..b83700214c
--- /dev/null
+++ b/usr/src/lib/libdll/sparcv9/src/lib/libdll/FEATURE/dll
@@ -0,0 +1,125 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libdll/features/dll by iffe version 2007-04-04 : : */
+
+#ifndef _def_dll_dll
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dll_dll 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _hdr_dlfcn 1 /* #include <dlfcn.h> ok */
+#define _LIB_dl 1 /* -ldl is a library */
+#define _lib_dlopen 1 /* dlopen() in default lib(s) */
+#define _DLL_NEXT_PATH "/usr/lib/libc.so.1"
+
+#include <dlfcn.h>
+
+#define DLL_INFO_PREVER 0x0001 /* pre-suffix style version */
+#define DLL_INFO_DOTVER 0x0002 /* post-suffix style version */
+
+typedef struct Dllinfo_s
+{
+ char** sibling; /* sibling dirs on $PATH */
+ char* prefix; /* library name prefix */
+ char* suffix; /* library name suffix */
+ char* env; /* library path env var */
+ int flags; /* DLL_INFO_* flags */
+#ifdef _DLLINFO_PRIVATE_
+ _DLLINFO_PRIVATE_
+#endif
+} Dllinfo_t;
+
+typedef struct Dllent_s
+{
+ char* path;
+ char* name;
+#ifdef _DLLENT_PRIVATE_
+ _DLLENT_PRIVATE_
+#endif
+} Dllent_t;
+
+typedef struct Dllscan_s
+{
+ __V_* pad;
+#ifdef _DLLSCAN_PRIVATE_
+ _DLLSCAN_PRIVATE_
+#endif
+} Dllscan_t;
+
+#if _BLD_dll && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Dllinfo_t* dllinfo __PROTO__((void));
+extern __MANGLE__ __V_* dllplug __PROTO__((const char*, const char*, const char*, int, char*, size_t));
+extern __MANGLE__ __V_* dllfind __PROTO__((const char*, const char*, int, char*, size_t));
+extern __MANGLE__ __V_* dllnext __PROTO__((int));
+extern __MANGLE__ __V_* dlllook __PROTO__((__V_*, const char*));
+
+extern __MANGLE__ Dllscan_t* dllsopen __PROTO__((const char*, const char*, const char*));
+extern __MANGLE__ Dllent_t* dllsread __PROTO__((Dllscan_t*));
+extern __MANGLE__ int dllsclose __PROTO__((Dllscan_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libdll/sparcv9/src/lib/libdll/dlldefs.h b/usr/src/lib/libdll/sparcv9/src/lib/libdll/dlldefs.h
new file mode 100644
index 0000000000..b83700214c
--- /dev/null
+++ b/usr/src/lib/libdll/sparcv9/src/lib/libdll/dlldefs.h
@@ -0,0 +1,125 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/lib/libdll/features/dll by iffe version 2007-04-04 : : */
+
+#ifndef _def_dll_dll
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_dll_dll 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _hdr_dlfcn 1 /* #include <dlfcn.h> ok */
+#define _LIB_dl 1 /* -ldl is a library */
+#define _lib_dlopen 1 /* dlopen() in default lib(s) */
+#define _DLL_NEXT_PATH "/usr/lib/libc.so.1"
+
+#include <dlfcn.h>
+
+#define DLL_INFO_PREVER 0x0001 /* pre-suffix style version */
+#define DLL_INFO_DOTVER 0x0002 /* post-suffix style version */
+
+typedef struct Dllinfo_s
+{
+ char** sibling; /* sibling dirs on $PATH */
+ char* prefix; /* library name prefix */
+ char* suffix; /* library name suffix */
+ char* env; /* library path env var */
+ int flags; /* DLL_INFO_* flags */
+#ifdef _DLLINFO_PRIVATE_
+ _DLLINFO_PRIVATE_
+#endif
+} Dllinfo_t;
+
+typedef struct Dllent_s
+{
+ char* path;
+ char* name;
+#ifdef _DLLENT_PRIVATE_
+ _DLLENT_PRIVATE_
+#endif
+} Dllent_t;
+
+typedef struct Dllscan_s
+{
+ __V_* pad;
+#ifdef _DLLSCAN_PRIVATE_
+ _DLLSCAN_PRIVATE_
+#endif
+} Dllscan_t;
+
+#if _BLD_dll && defined(__EXPORT__)
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+#endif
+
+extern __MANGLE__ Dllinfo_t* dllinfo __PROTO__((void));
+extern __MANGLE__ __V_* dllplug __PROTO__((const char*, const char*, const char*, int, char*, size_t));
+extern __MANGLE__ __V_* dllfind __PROTO__((const char*, const char*, int, char*, size_t));
+extern __MANGLE__ __V_* dllnext __PROTO__((int));
+extern __MANGLE__ __V_* dlllook __PROTO__((__V_*, const char*));
+
+extern __MANGLE__ Dllscan_t* dllsopen __PROTO__((const char*, const char*, const char*));
+extern __MANGLE__ Dllent_t* dllsread __PROTO__((Dllscan_t*));
+extern __MANGLE__ int dllsclose __PROTO__((Dllscan_t*));
+
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+
+#endif
diff --git a/usr/src/lib/libpp/Makefile b/usr/src/lib/libpp/Makefile
new file mode 100644
index 0000000000..4091cfcbbf
--- /dev/null
+++ b/usr/src/lib/libpp/Makefile
@@ -0,0 +1,66 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+SHELL=/usr/bin/ksh
+
+include ../Makefile.lib
+
+SUBDIRS = $(MACH)
+#$(BUILD64)SUBDIRS += $(MACH64)
+
+all := TARGET= all
+clean := TARGET= clean
+clobber := TARGET= clobber
+install := TARGET= install
+lint := TARGET= lint
+_msg := TARGET= _msg
+
+.KEEP_STATE:
+
+all clean clobber install lint _msg: $(SUBDIRS)
+
+LIBRARY= libpp.a
+
+HDRS= \
+ pp.h \
+ ppkey.h
+
+HDRDIR32= common
+HDRDIR64= common
+include ../Makefile.asthdr
+
+install_h: $(ROOTHDRS)
+
+# We don't check these header files because they're owned by AT&T/AST
+check:
+
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
+
+include ../Makefile.targ
diff --git a/usr/src/lib/libpp/Makefile.com b/usr/src/lib/libpp/Makefile.com
new file mode 100644
index 0000000000..f9a16b9af1
--- /dev/null
+++ b/usr/src/lib/libpp/Makefile.com
@@ -0,0 +1,121 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+SHELL=/usr/bin/ksh
+
+LIBRARY= libpp.a
+VERS= .1
+
+OBJECTS= \
+ ppargs.o \
+ ppbuiltin.o \
+ ppcall.o \
+ ppcomment.o \
+ ppcontext.o \
+ ppcontrol.o \
+ ppcpp.o \
+ ppdata.o \
+ pperror.o \
+ ppexpr.o \
+ ppfsm.o \
+ ppincref.o \
+ ppinput.o \
+ ppkey.o \
+ pplex.o \
+ ppline.o \
+ ppmacref.o \
+ ppmisc.o \
+ ppop.o \
+ pppragma.o \
+ ppprintf.o \
+ ppproto.o \
+ ppsearch.o \
+ pptrace.o
+
+include ../../Makefile.astmsg
+
+include ../../Makefile.lib
+
+# mapfile-vers does not live with the sources in in common/ to make
+# automated code updates easier.
+MAPFILES= ../mapfile-vers
+
+# Set common AST build flags (e.g., needed to support the math stuff).
+include ../../../Makefile.ast
+
+LIBS = $(DYNLIB) $(LINTLIB)
+LDLIBS += -last -lc
+$(LINTLIB) := SRCS = $(SRCDIR)/$(LINTSRC)
+
+SRCDIR = ../common
+
+# We use "=" here since using $(CPPFLAGS.master) is very tricky in our
+# case - it MUST come as the last element but future changes in -D options
+# may then cause silent breakage in the AST sources because the last -D
+# option specified overrides previous -D options so we prefer the current
+# way to explicitly list each single flag.
+CPPFLAGS = \
+ $(DTEXTDOM) $(DTS_ERRNO) \
+ -I. \
+ -I$(ROOT)/usr/include/ast \
+ -D_PACKAGE_ast \
+ '-DUSAGE_LICENSE=\
+ "[-author?Glenn Fowler <gsf@research.att.com>]"\
+ "[-copyright?Copyright (c) 1986-2007 AT&T Knowledge Ventures]"\
+ "[-license?http://www.opensource.org/licenses/cpl1.0.txt]"\
+ "[--catalog?libpp]"'
+
+CFLAGS += \
+ $(CCVERBOSE) \
+ -xstrconst
+CFLAGS64 += \
+ $(CCVERBOSE) \
+ -xstrconst
+
+pics/ppcall.o := CERRWARN += -erroff=E_INTEGER_OVERFLOW_DETECTED
+pics/ppcontrol.o := CERRWARN += -erroff=E_INTEGER_OVERFLOW_DETECTED
+pics/ppcpp.o := CERRWARN += -erroff=E_INTEGER_OVERFLOW_DETECTED
+pics/pplex.o := CERRWARN += -erroff=E_INTEGER_OVERFLOW_DETECTED
+pics/ppexpr.o := CERRWARN += -erroff=E_INTEGER_OVERFLOW_DETECTED
+pics/ppop.o := CERRWARN += -erroff=E_INTEGER_OVERFLOW_DETECTED
+pics/ppsearch.o := CERRWARN += -erroff=E_INTEGER_OVERFLOW_DETECTED
+pics/ppsearch.o := CERRWARN += -_gcc=-Wno-sequence-point
+
+.KEEP_STATE:
+
+all: $(LIBS)
+
+#
+# libpp is not lint-clean yet; fake up a target. (You can use
+# "make lintcheck" to actually run lint; please send all lint fixes
+# upstream (to AT&T) so the next update will pull them into ON.)
+#
+lint:
+ @ print "usr/src/lib/libpp is not lint-clean: skipping"
+ @ $(TRUE)
+
+include ../../Makefile.targ
diff --git a/usr/src/lib/libpp/THIRDPARTYLICENSE b/usr/src/lib/libpp/THIRDPARTYLICENSE
new file mode 100644
index 0000000000..50c6364c06
--- /dev/null
+++ b/usr/src/lib/libpp/THIRDPARTYLICENSE
@@ -0,0 +1,245 @@
++------------------------------------------------------------------------------+
+| This license covers all software that refers to the URL |
+| http://www.opensource.org/licenses/cpl1.0.txt |
++------------------------------------------------------------------------------+
+
+Common Public License Version 1.0
+
+ THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON
+ PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF
+ THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+ 1. DEFINITIONS
+
+ "Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and
+ documentation distributed under this Agreement, and
+
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from
+ and are distributed by that particular Contributor. A Contribution
+ 'originates' from a Contributor if it was added to the Program by
+ such Contributor itself or anyone acting on such Contributor's
+ behalf. Contributions do not include additions to the Program
+ which: (i) are separate modules of software distributed in
+ conjunction with the Program under their own license agreement, and
+ (ii) are not derivative works of the Program.
+
+ "Contributor" means any person or entity that distributes the Program.
+
+ "Licensed Patents " mean patent claims licensable by a Contributor
+ which are necessarily infringed by the use or sale of its Contribution
+ alone or when combined with the Program.
+
+ "Program" means the Contributions distributed in accordance with this
+ Agreement.
+
+ "Recipient" means anyone who receives the Program under this
+ Agreement, including all Contributors.
+
+ 2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free copyright
+ license to reproduce, prepare derivative works of, publicly
+ display, publicly perform, distribute and sublicense the
+ Contribution of such Contributor, if any, and such derivative
+ works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free patent
+ license under Licensed Patents to make, use, sell, offer to sell,
+ import and otherwise transfer the Contribution of such Contributor,
+ if any, in source code and object code form. This patent license
+ shall apply to the combination of the Contribution and the Program
+ if, at the time the Contribution is added by the Contributor, such
+ addition of the Contribution causes such combination to be covered
+ by the Licensed Patents. The patent license shall not apply to any
+ other combinations which include the Contribution. No hardware per
+ se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the
+ licenses to its Contributions set forth herein, no assurances are
+ provided by any Contributor that the Program does not infringe the
+ patent or other intellectual property rights of any other entity.
+ Each Contributor disclaims any liability to Recipient for claims
+ brought by any other entity based on infringement of intellectual
+ property rights or otherwise. As a condition to exercising the
+ rights and licenses granted hereunder, each Recipient hereby
+ assumes sole responsibility to secure any other intellectual
+ property rights needed, if any. For example, if a third party
+ patent license is required to allow Recipient to distribute the
+ Program, it is Recipient's responsibility to acquire that license
+ before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has
+ sufficient copyright rights in its Contribution, if any, to grant
+ the copyright license set forth in this Agreement.
+
+ 3. REQUIREMENTS
+
+ A Contributor may choose to distribute the Program in object code form
+ under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all
+ warranties and conditions, express and implied, including
+ warranties or conditions of title and non-infringement, and implied
+ warranties or conditions of merchantability and fitness for a
+ particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all
+ liability for damages, including direct, indirect, special,
+ incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement
+ are offered by that Contributor alone and not by any other party;
+ and
+
+ iv) states that source code for the Program is available from such
+ Contributor, and informs licensees how to obtain it in a reasonable
+ manner on or through a medium customarily used for software
+ exchange.
+
+ When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the
+ Program.
+
+ Contributors may not remove or alter any copyright notices contained
+ within the Program.
+
+ Each Contributor must identify itself as the originator of its
+ Contribution, if any, in a manner that reasonably allows subsequent
+ Recipients to identify the originator of the Contribution.
+
+ 4. COMMERCIAL DISTRIBUTION
+
+ Commercial distributors of software may accept certain
+ responsibilities with respect to end users, business partners and the
+ like. While this license is intended to facilitate the commercial use
+ of the Program, the Contributor who includes the Program in a
+ commercial product offering should do so in a manner which does not
+ create potential liability for other Contributors. Therefore, if a
+ Contributor includes the Program in a commercial product offering,
+ such Contributor ("Commercial Contributor") hereby agrees to defend
+ and indemnify every other Contributor ("Indemnified Contributor")
+ against any losses, damages and costs (collectively "Losses") arising
+ from claims, lawsuits and other legal actions brought by a third party
+ against the Indemnified Contributor to the extent caused by the acts
+ or omissions of such Commercial Contributor in connection with its
+ distribution of the Program in a commercial product offering. The
+ obligations in this section do not apply to any claims or Losses
+ relating to any actual or alleged intellectual property infringement.
+ In order to qualify, an Indemnified Contributor must: a) promptly
+ notify the Commercial Contributor in writing of such claim, and b)
+ allow the Commercial Contributor to control, and cooperate with the
+ Commercial Contributor in, the defense and any related settlement
+ negotiations. The Indemnified Contributor may participate in any such
+ claim at its own expense.
+
+ For example, a Contributor might include the Program in a commercial
+ product offering, Product X. That Contributor is then a Commercial
+ Contributor. If that Commercial Contributor then makes performance
+ claims, or offers warranties related to Product X, those performance
+ claims and warranties are such Commercial Contributor's responsibility
+ alone. Under this section, the Commercial Contributor would have to
+ defend claims against the other Contributors related to those
+ performance claims and warranties, and if a court requires any other
+ Contributor to pay any damages as a result, the Commercial Contributor
+ must pay those damages.
+
+ 5. NO WARRANTY
+
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+ PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
+ WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
+ OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+ responsible for determining the appropriateness of using and
+ distributing the Program and assumes all risks associated with its
+ exercise of rights under this Agreement, including but not limited to
+ the risks and costs of program errors, compliance with applicable
+ laws, damage to or loss of data, programs or equipment, and
+ unavailability or interruption of operations.
+
+ 6. DISCLAIMER OF LIABILITY
+
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
+ ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+ WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+ DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+ 7. GENERAL
+
+ If any provision of this Agreement is invalid or unenforceable under
+ applicable law, it shall not affect the validity or enforceability of
+ the remainder of the terms of this Agreement, and without further
+ action by the parties hereto, such provision shall be reformed to the
+ minimum extent necessary to make such provision valid and enforceable.
+
+ If Recipient institutes patent litigation against a Contributor with
+ respect to a patent applicable to software (including a cross-claim or
+ counterclaim in a lawsuit), then any patent licenses granted by that
+ Contributor to such Recipient under this Agreement shall terminate as
+ of the date such litigation is filed. In addition, if Recipient
+ institutes patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Program
+ itself (excluding combinations of the Program with other software or
+ hardware) infringes such Recipient's patent(s), then such Recipient's
+ rights granted under Section 2(b) shall terminate as of the date such
+ litigation is filed.
+
+ All Recipient's rights under this Agreement shall terminate if it
+ fails to comply with any of the material terms or conditions of this
+ Agreement and does not cure such failure in a reasonable period of
+ time after becoming aware of such noncompliance. If all Recipient's
+ rights under this Agreement terminate, Recipient agrees to cease use
+ and distribution of the Program as soon as reasonably practicable.
+ However, Recipient's obligations under this Agreement and any licenses
+ granted by Recipient relating to the Program shall continue and
+ survive.
+
+ Everyone is permitted to copy and distribute copies of this Agreement,
+ but in order to avoid inconsistency the Agreement is copyrighted and
+ may only be modified in the following manner. The Agreement Steward
+ reserves the right to publish new versions (including revisions) of
+ this Agreement from time to time. No one other than the Agreement
+ Steward has the right to modify this Agreement. IBM is the initial
+ Agreement Steward. IBM may assign the responsibility to serve as the
+ Agreement Steward to a suitable separate entity. Each new version of
+ the Agreement will be given a distinguishing version number. The
+ Program (including Contributions) may always be distributed subject to
+ the version of the Agreement under which it was received. In addition,
+ after a new version of the Agreement is published, Contributor may
+ elect to distribute the Program (including its Contributions) under
+ the new version. Except as expressly stated in Sections 2(a) and 2(b)
+ above, Recipient receives no rights or licenses to the intellectual
+ property of any Contributor under this Agreement, whether expressly,
+ by implication, estoppel or otherwise. All rights in the Program not
+ expressly granted under this Agreement are reserved.
+
+ This Agreement is governed by the laws of the State of New York and
+ the intellectual property laws of the United States of America. No
+ party to this Agreement will bring a legal action under this Agreement
+ more than one year after the cause of action arose. Each party waives
+ its rights to a jury trial in any resulting litigation.
+
+Copyright (c) 2004 by the Open Source Initiative
+This is a copy of the license posted on 2004-10-06 at:
+ http://www.opensource.org/licenses/cpl
diff --git a/usr/src/lib/libpp/THIRDPARTYLICENSE.descrip b/usr/src/lib/libpp/THIRDPARTYLICENSE.descrip
new file mode 100644
index 0000000000..e82817ee4d
--- /dev/null
+++ b/usr/src/lib/libpp/THIRDPARTYLICENSE.descrip
@@ -0,0 +1 @@
+AT&T ADVANCED SOFTWARE TECHNOLOGY PREPROCESSOR LIBRARY (LIBPP)
diff --git a/usr/src/lib/libpp/common/BUGS b/usr/src/lib/libpp/common/BUGS
new file mode 100644
index 0000000000..1d3304d103
--- /dev/null
+++ b/usr/src/lib/libpp/common/BUGS
@@ -0,0 +1,6 @@
+libpp bug list
+
+01/22/93 gsf "" join drops trailing newline of last token in last file
+06/11/92 gsf spurious empty character constant warning for shipproto.c
+02/29/92 gsf "" join bombs if next line is #ident
+02/01/87 gsf a/**/b doesn't concatenate outside macro bodies (COMPATIBILITY)
diff --git a/usr/src/lib/libpp/common/HISTORY b/usr/src/lib/libpp/common/HISTORY
new file mode 100644
index 0000000000..37d9156541
--- /dev/null
+++ b/usr/src/lib/libpp/common/HISTORY
@@ -0,0 +1,220 @@
+libpp change history
+
+ ----- minor sync release -----
+09/11/89 add extra sun style 1,2 arg to line syncs in ppline with pp:linetype
+ add pp:oldc to convert __STDC__ void* and prototypes to old C
+08/11/89 fix <...> include dir bug
+08/08/89 add SYM_INIT for #define during INIT
+07/28/89 delete STRIPTOP, STRIP only T_STRING & T_CHARCONST at pp.level==1
+ add ppcargs() compatibility command line argument parse
+07/17/89 dialect: ANSI (default) or (Reiser) compatibility
+ style: extended (default) or strict
+ use pathprobe(3) for dynamic ppdefault.h
+ add PP_PROBE to specify pathprobe() processor
+ add -[DI]+ to invert options in ppargs()
+ delete PP_ANSI, PP_DIALECT, PP_INITDIR, PP_LANGUAGE
+ delete PP_NONHOSTED, PP_NOPASSTHROUGH, PP_PHASEOUT
+ add #pragma's for most ppargs() options
+ add #option(pragma-option) predicate test
+ PP_MACREF now called during initialization
+07/11/89 add PP_BUILTIN for external #(...) handler
+ add line number to missing endif message
+ ignore errors in skipped ppexpr() &&, || and ?: subexpressions
+ add space before macro actual in replacement text
+07/04/89 fix PP_TRUNCATE interaction with PP_COMPILE
+06/30/89 #define x #; x was recognized as directive #
+06/27/89 don't pass comments during #if skip
+05/01/89 add L"..." and L'...' wide quoted constants
+ mixed "..." and L"..." ok -- L"..." for COMPILE, first otherwise
+ fix PASSCOMMENTS in directives
+ allow #define f(a,) for COMPATIBILITY
+ fix literal string concatenation bugs
+ fix header parsing in non-active if-blocks
+ #endmac now takes no arg
+04/11/89 tone down unknown directive diagnostic in conditional
+04/07/89 move macref call before arg processing
+03/27/89 fix pplex bug that bombed line sync for last line == #include
+03/15/89 fix PP_TRUNCATE macro id bit table checks
+ remove compatibility option s from ppargs() -- belongs in cmds
+03/08/89 remove ``empty character constant'' warning for PASSTHROUGH
+02/28/89 fix variable n usage conflict for DEFINE: in ppcontrol
+02/22/89 fix -T conflict with __GNUC__ in ppargs
+02/01/89 add -T (PP_TRUNCATE) for old non-flexname compiler compatibility
+01/31/89 -I-M-<char><suffix> finds map file by mapping input file name
+ -I-H[directory] allowed for fine hosted control
+01/24/89 fix #undef of SYM_READONLY macro message
+ add PPCOMPATIBLE for compatibility installation in /lib/cpp
+ add PP_MAP & -I-M to map include files for minimal including
+01/18/89 fix pp.token setting by noting with pp.state|=TOKENSET
+01/11/89 fix #if skip bug where quoted token set begin line state
+12/11/88 add error checking wrappers to *alloc()
+12/05/88 add PP_FILEDEPS (-M) and FILEDEPS mode for BSD compatibility
+12/01/88 add #macdef-#endmac and change actualsync() char to SYNC ('\r')
+11/30/88 TOKOUTBUF controls 11/28/88 STANDALONE speedup
+11/28/88 speed up STANDALONE by avoiding pp.token copy
+11/22/88 add comment removal to string_special
+11/11/88 LIBEXPR enables expr(3) in ppexpr() (12K extra text)
+10/11/88 move VARQUOTE to pp.mode
+10/01/88 allow checkpoint files for !STANDALONE
+08/31/88 add pp.undefsym for pp.macref's on undefined symbols
+08/23/88 0xe+N -> `0xe' `+' `N'
+08/16/88 fix ppckeys.c: T_DOUBLE->T_DOUBLE_T, T_FLOAT->T_FLOAT_T
+07/17/88 add \newline to string_special
+ add line number arg to pp.comment call
+ move private stuff from pp.h to pplib.h
+ add ignored -v to ppargs() (GNU uses this)
+06/22/88 move pp.macref check; stack pp.state in ppcontrol()
+ add PP_INCREF and (*pp.incref)(old-file, new-file, push|return)
+06/11/88 add pp.macref
+ add ppckeys.h and C, C++ and pcc-based C keyword tables
+06/01/88 convert to new hash library interface
+05/31/88 pp:readonly in PP_INIT only for STRICT
+05/11/88 T_MOREARGS -> T_VARIADIC; add SYM_VARIADIC for ... last macro arg
+05/03/88 fix empty include file bug by omitting empty check
+04/27/88 ignore space in pragma % maps to accomodate SCCS %.% expansion
+04/19/88 change pp.h to check for old nmake cpp clash with ppsymbol
+04/11/88 fix flag check bug in ppload()
+02/29/88 add MAP_ECHO and %E for MAP_RESCAN + echo
+ PP_INITDIR inserted before PP_STANDARD during initialization
+02/18/88 ignore malformed #'s in COMPATIBILITY macro definitions
+ add pp.prefix, PP_PREFIX and -I-P for prefix dir "..." includes
+02/10/88 add NOQUOTE to disable ' and " and decouple from VARQUOTE
+ add keyword and quote pragmas
+02/02/88 add strcmp builtin predicate for token string value comparison
+01/24/88 fix <backslash><newline> handling in #define on bsd
+01/20/88 add %T and fix %[...] pragma mapping formats
+01/11/88 complete 12/11/87 COMPATIBILITY macro arg /**/ pasting bug fix
+ complete KEYWORD support
+01/08/88 add PP_KEYWORD, (pp.state & KEYWORD), -D-K and #if KEYARGS
+01/06/88 hex char constants are now variable length
+01/04/88 do not add terminator for COMPATIBILITY " and ' constants
+12/11/87 remove #multiple in lieu of #pragma multiple
+ add %R MAP_RESCAN option to rescan pragma/directive mapping
+ fix COMPATIBILITY macro arg /**/ pasting bug
+12/08/87 recode for updated hash library interface
+ add T_PTRMEMREF ->* and T_DOTREF .* C++ operator tokens
+12/01/87 reorganize pp token numbers to span 0401..0477
+11/22/87 add operand error checks to ppexpr()
+ add PP_DEFAULT and -I-Dfile for fine PPDEFAULT control
+11/11/87 pppragma() now omits space after # for primitive passes (uts)
+10/30/87 fix line count on `newline' in ['"] constant warning
+10/29/87 add MAP_PLUSCOMMENT and %P to pragma|directive mapping
+10/28/87 add head & tail args to ppcomment; pass // comments as is
+10/23/87 add warning for multiple ppop(PP_LOCAL) calls
+10/16/87 change PP_HOSTED to PP_HOSTDIR, add PP_HOSTED and PP_NONHOSTED
+ add #(BASE) that expands to base name of #(FILE)
+10/15/87 for PASSTHROUGH each line of multi-line "..." or '...' is a token
+10/14/87 add ppmultiple() for multiple include test ops
+10/11/87 delete CONVERTASSIGN -> `=<op>' no longer recognized
+ delete C++ := -> = conversion
+ fix COMPATIBILITY macro recursion bug
+ add `#pragma multiple' equivalent to `#multiple'
+10/06/87 split pplex.c adding ppdirective.c and ppbuiltin.c
+ don't recognize obsolete assignments for PLUSPLUS
+10/05/87 fix PLUSPLUS PASSCOMMENTS bug `// */' -> `/* ***/'
+10/01/87 allow newlines in ' and " constants for PASSTHROUGH
+09/28/87 fix CONVERTCC STRICT bug that omitted octal character constants
+ add CATLITERAL compile switch for adjacent string literal concatenation
+ fix "\07" "3" -> "\073" string literal concatenation bug -> "\0073"
+09/18/87 complete ppdump() and ppload() checkpoint support
+09/17/87 fix macro formal bug that didn't update pointers after realloc()
+ add PP_DONE complement op to PP_INIT
+ add SYM_BUILTIN and #pragma pp:builtin to note builtin macros
+ add PP_DUMP, -D-D and #pragma pp:load checkpoint support
+08/20/87 fix bug that omitted some actualsync() calls for '\n' in pp.in->actual
+08/19/87 fix pp.linesync==0 && PASSTHROUGH bug that omitted '\n' after "token"
+08/11/87 fix #($var) null pointer bug
+07/31/87 fix linesync bug for comment after #include in PASSCOMMENTS
+07/24/87 add PP_NOPASSTHROUGH
+07/16/87 fix predicate missing # ambiguity warning
+07/09/87 fix `macro("@*")' bug in expand_special()
+06/17/87 fix comment error message check that was off by one line
+06/16/87 remove #pragma pp:multiple; add #multiple; retain PP_MULTIPLE
+06/08/87 add # operator to disambiguate predicate tests
+ inhibit more warnings on hosted files
+ make diagnostics more consistent -- a little more work
+ PP_READ files and their included files always marked hosted
+06/05/87 fix macro actual arg collection with imbedded #include, #line
+05/28/87 add `#pragma pp:multiple *' to mark all files multiple
+ add -D-M for command line equivalent to `#pragma pp:multiple *'
+05/01/87 clarify HOSTED and SYM_PREDEFINED
+04/24/87 split pplex.c into smaller files -- too big for some compilers
+ move common wrapper routines into the library
+ fix ppargs() to cooperate with other option parsers
+04/22/87 remove getenv("PPSTANDARD") override of PP_STANDARD
+04/21/87 replace yacc parser with recursive expr() from library streval()
+04/20/87 add #((<expr>)) expression evaluation on (x)
+ add #(<sym>=<expr>) to dynamically evaluate macro values
+04/11/87 home brew output buffering for PP_STANDALONE -- up to 10%
+ cleanup
+04/10/87 change T_STRING concatenation in preparation for new output buffering
+04/09/87 fix character constant conversion warnings
+04/07/87 fix \\n and ??/\n bugs in comment scan
+04/06/87 add DIGIT, HEX, OCTAL and NONOCTAL case classes to ppdefs.h
+ use GETCHR() and ISSPECIAL() in outer pplex() loop -- up to 10%
+ fix macro actual arg count test
+04/03/87 add PP_TEST and TEST1, TEST2 to mode for internal tests
+04/02/87 delete PPDEFAULT and generalize with PP_READ
+ note `# <line> "<file>"' as non-standard
+ add check for malloc() out of space
+04/01/87 C specific error messages only if language="C"
+ C++ specific error messages only if language="C++"
+03/31/87 delete command() predicate -- gateway for trojan horse
+03/30/87 add dialect() and language() builtin predicates
+ change in->standard to in->hosted and STANDARD to HOSTED
+ add PP_HOSTED and change PP_NOSTANDARD to PP_NOHOSTED
+ ignore #pragma for non-hosted files in STRICT dialect
+03/27/87 add predop(); delete pp:plusplus
+ pp:dialect and pp:language for verification only
+03/24/87 ----- first release -----
+03/24/87 ----- first release -----
+03/23/87 allow WARN to apply to all dialects
+ fix pp:directive `...multiple...' warning
+ add MAP_NEWLINE to separate multiple pragmas
+03/22/87 warn about null macro args for STRICT
+ add PP_LANGUAGE, `#pragma language [language]'
+ warn about newline in macro call arguments in directives
+ warn about directives in macro call arguments for STRICT
+ validate character constants in #if expressions
+03/20/87 add PP_DIRECTIVE and PP_LOCAL
+ add %I (ignore) map format and allow %X for pragma args
+03/19/87 change PP_DEFAULT to PP_STANDARD, add PP_DIALECT
+ add dialect arg to PP_COMPATIBILITY, PP_DIALECT and PP_STRICT
+ add `#pragma pp:pragma pass:option format' mapping
+03/18/87 delete pp:obsolete; fix `#pragma version'
+ fixed macro stack frame bug during recursive macro arg expansion
+ change CONFORMING, PP_CONFORMING to STRICT, PP_STRICT
+ add `#pragma dialect [dialect]' verification
+03/17/87 add PP_NOSTANDARD to disable any special handling of std files
+ refine mkdefault.sh for sun workstations
+ remove comma operator from pp.yacc since it implies side effects
+ add argument type checking for pp:directive and pp:obsolete
+03/16/87 refine CONFORMING messages
+ disambiguate most #assert/#define clashes
+ add PASSCOMMENT and (*ppcomment)() for old lint fans
+03/14/87 #undef in pp:readonly marks id as readonly macro
+03/11/87 warn about macros that are predicates in #if expressions
+ add mode to handle uncoupled flag bit overflow from state
+03/04/87 fix COMPATIBILITY to expand a macro in its definition
+02/24/87 add gentab.sh and mkdefault.sh to Makefile
+02/20/87 add IN_RECURSIVE for proper handling of #(...)
+02/16/87 add #unassert; PP_WARN & WARN to note obsolete usage
+ only recognize directive if # is first char for (state&COMPATIBILITY)
+ generalize gentab.sh and retrofit pp.tab
+ change in->name.file to be the name of including file
+02/13/87 add pp.tab; PP_PRAGMA "x=y" -> "#pragma x y"
+ add #(x y...) -> "#x y..." for recursive directive evaluation
+02/12/87 #pragma [pass:] [no]option [arg ...]
+ #pragma pp:[no]directive [pass:]<new-directive>
+ #pragma pp:id <identifier-character>
+02/11/87 distribute post-token switch in pplex() to individual cases (~5%)
+02/09/87 clarify invalid numeric token gobble
+ add VARQUOTE & PP_VARQUOTE for `X...X vs. '...' & "..." constants
+02/06/87 change STRICT to CONFORMING; add PP_CONFORMING
+02/06/87 change PPBUILTIN to #(<id>)
+02/05/87 clarify /*...*/ concatenation for (state&COMPATIBILITY)
+ add convertcc() to convert new char const to old style
+ rework # op to work with convertcc()
+02/04/87 add =<op> obsolete operators for (state&COMPATIBILITY)
+02/02/87 fix expand() to save and restore (state&DISABLE)
+12/17/86 first code
diff --git a/usr/src/lib/libpp/common/NOTES b/usr/src/lib/libpp/common/NOTES
new file mode 100644
index 0000000000..85ab42e74b
--- /dev/null
+++ b/usr/src/lib/libpp/common/NOTES
@@ -0,0 +1,83 @@
+C preprocessor features:
+
+(1) The preprocessor is centered around the libpp.a library. This
+ library provides a tokenizing implementation of the preprocessing
+ stages of ANSI standard C. The same library is used to construct
+ a standalone prepreprocessor as well as a C compiler front end
+ that, compiled with the library, eliminates the need for a
+ separate preprocessing pass. Other C tools requiring C tokenizing
+ can use this library, providing a common interface to C language
+ tokens.
+
+(2) The #pragma interface is exploited to allow the addition of new
+ directives and #pragma's without changing the preprocessor
+ executable. Most implementation details can be specified by
+ directives in the file "ppdefault.h" that is automatically included
+ (by the standalone cpp library wrapper) as an initialization step.
+
+(3) #assert, #unassert and corresponding #if predicate tests have been
+ added to relieve the conflicts introduced by predefined #define
+ macros (e.g., unix, vax, u3b, ...). This is the same feature
+ present in the extended Reiser cpp that has been included in the
+ nmake distribution. (NOTE: #assert is a failed experiment)
+
+(4) The implementation is sensitive to the incompatible differences
+ between the Reiser cpp (used by AT&T and BSD compilers) and the new
+ ANSI standard C. A compatibility dialect implements Reiser
+ features, allowing for a smooth transition to the ANSI standard.
+
+(5) To aid in the transition to ANSI, the preprocessor can do some
+ operations that would normally be done by the lexical analysis
+ stage of a compiler front end:
+
+ (a) convert new-style character constants to a form
+ recognized by all current compilers
+
+ (b) concatenate adjacent string literals
+
+(6) The preprocessor can also warn about obsolete constructs used
+ in the compatibility dialect and on non-standard constructs
+ used in the ANSI dialect. The latter is useful in writing
+ C code that is made to run through other implementations of
+ ANSI standard C.
+
+(7) The preprocessor allows a C language implementor to take
+ advantage of local extensions without invalidating the
+ conformance of the C language implementation.
+
+C9X additions:
+
+(1) #pragma STDC ...
+ special forms always accecpted
+
+(2) _Pragma unary operator for pragmas via macro expansion
+ _Pragma(string-literal)
+ #pragma a b c
+ _Pragma("a b c")
+
+(3) keywords
+ restrict inline _Bool _Complex _Imaginary
+
+(4) macros
+ __STDC_VERSION__ 199901L
+ __STDC_IEC_559__ 1 or undef
+ __STDC_IEC_559_COMPLEX__ 1 or udef
+ __STDC_ISO_10646__ yyyymmL
+
+(5) empty arguments allowed in function-like macros
+
+(6) variable arguments via ...
+ __VA_ARGS__ in replacement list only, expands to var args
+ only var args is ok (shall only appear in ...)
+
+(7) hex floating constant with binary exponents
+ xxxxxx[pP]dddd
+
+(8) // style comments
+
+(9) universal characters, even in identifiers!
+ \uxxxx \Uxxxxxxxx
+
+(10) LL ll ULL ull suffix for long long literals
+
+(11) <stdarg.h> has va_copy()
diff --git a/usr/src/lib/libpp/common/RELEASE b/usr/src/lib/libpp/common/RELEASE
new file mode 100644
index 0000000000..179930e147
--- /dev/null
+++ b/usr/src/lib/libpp/common/RELEASE
@@ -0,0 +1,432 @@
+06-09-23 ppop.c: check -I <dev,ino> for c and TYPE_HOSTED|TYPE_VENDOR attrs
+06-09-23 pplex.c: add HOSTED check for "/* appears in // comment" -- doh
+06-09-05 pp.probe: add version stamp comment
+06-06-29 pp.probe: gcc pp:linefile probe (otherwise it can dump!)
+06-06-28 ppproto.c: fix inappropriate __PARAM__ insertion
+06-05-09 pp.tab,ppcontrol.c,ppproto.c: add externalize
+ ppfsm.c: handle compatibility ul numeric qualifiers
+06-02-28 probe.win32: add wchar_t probe
+06-01-11 pplex.c: fix rpcgen pp:passthrough header splice bug
+05-12-16 pplex.c: fix imake pp:passthrough comment splice bug
+05-09-16 pplib.h: add <string.h> for standalone proto
+05-07-31 pplib.h: finally trust __STDC__ headers
+05-04-11 pplex.c: fix '"a" #s' catliteral + stringize bug
+05-03-29 pp.probe: check $? and stderr messages for pp:lineid
+05-02-20 probe.win32: handle /platformsdk mount
+05-01-11 ppargs.c: fix -I-S docs
+ ppinput.c: ppproto() only for COMPATIBILITY or PLUSPLUS
+04-10-22 ppproto.c: handle `type var[x][y]' arg prototype
+04-10-01 pplex.c: really fix directive hidden newline logic
+04-08-31 pplex.c: fix directive hidden newline logic
+ ppcall.c: fix '(' peek bug that missed the MARK
+04-08-30 add pragma pp:pragmaflags PP_PRAGMAFLAGS, pp:system_header
+04-08-11 ppproto.c: intercept "#(define|undef) extern" for __(EX|IM)PORT__
+04-07-23 probe.win32: generalize #include dir order search
+04-07-22 ppsearch.c: access() => eaccess()
+04-05-20 ppproto.c: don't __PROTO__ `int fun __P((int));'
+04-04-15 probe.win32: sync up with uwin 2003-08-06 master -- oops
+04-04-01 pp.probe: add stdinclude usrinclude path cleanup
+04-02-29 ppproto.c: fix bug that skipped prototyped check during notices check
+ ppproto.c: recognize `Copyright nn'
+04-02-14 ppproto.c: comment[0]==0 => no notice
+04-02-11 Makefile: fix %.yacc to handle cross-compile
+04-01-28 pp.h,pplib.h,ppop.c: add PP_RESET to restore original pp.symtab scope
+03-12-12 ppcall.c: missing macro actual warned but expanded
+03-11-12 ppexpr.c: fix premature #if expression token strip
+03-06-21 ppproto.c: fix T_INVALID ? splice bug that did 0?val => 0?vaL
+03-06-10 ppargs.c: add -D-d and -D-m
+ ppargs.c: add gnu options { -dD -dM -imacros -include -lang-* -lint }
+03-05-19 pplex.c: fix stray SKIPMACRO bug
+03-05-18 ppcall.c: add SYM_FUNCTION '(' peek to avoid inappropriate ungetchr()
+03-04-30 pp:mapinclude hosted <std.h>="." will search only hosted dirs
+ pp.probe: add pp:mapinclude probe for namespace incursions
+03-04-29 ignore()=>ppmapinclude(), add pp:mapinclude
+03-03-25 ppop.c: PP_RESERVED now deletes old symbol before redef with lex value
+03-03-14 pp.probe: fix the #include_next probe
+03-02-28 ppsearch.c: fix -MM bug that missed prefix include hosted mark
+03-02-18 pplex.c: handle COMPATIBILITY \" and \' in macro actuals
+03-01-23 probe.win32: mingw32 tweaks
+02-12-17 ppargs.c: document -I-!
+02-12-06 -I- pp:noprefix otherwise pp:prefix default
+02-11-29 probe.win32: added __INTSIZE, drop dm pp:noallmultiple
+02-11-26 pp.def: add STDC_HOSTED
+ probe.win32: add C95 and C99 STDC predefined macros
+02-10-30 ppfsm.h: add boundary check to IDSTATE()
+02-10-18 probe.win32: update for mingw
+02-10-15 ppsearch.c: if PLUSPLUS && not found && no suffix then try with .h
+02-10-10 pplex.c: fix does not end with `newline' bugs
+02-10-01 ppop.c,ppargs.c: -I-I => -I-M with proper docs; -I-I for PP_IGNORE
+02-09-21 pp.probe: add pp:nocatliteral test
+02-09-10 pp.tab: add pp:passthrough to match -D-P docs
+02-08-30 probe.win32: fix for borland cc -E
+02-08-22 ppexpr.c: add __SOURCE__ and #match(string,pattern)
+02-06-25 ppproto.c: fix pragma search bug that stopped after 8 comment lines
+02-06-11 ppsearch.c: fix ... next include search to skip *all* intermediates
+02-05-28 probe.win32: updates for { mingw }
+ ppsearch.c: don't use inherited prefix for <...> -- duh
+02-05-24 ppcontrol.c: simplify getline() space canonicalization
+ probe.win32: updates for { digital-mars borland lcc }
+02-05-20 ppcontrol.c: update to use regsubcomp(),regsubexec()
+02-05-09 ppcontrol.c: inhibit `EOF in directive': newline warning will catch it
+ pplex.c: inhibit `newline in character constant' for hosted directives
+02-05-06 probe.win32: add more win32 compilers
+02-04-15 probe.win32: handle long long unsigned int
+02-04-12 ppproto.c: fix NOTICED check
+02-03-15 ppproto.c: fix cpp pp:compatibility double line sync memory fault
+02-03-11 pplex.c: add pp:modern to emit \a \v instead of octal forms
+02-02-14 ppargs.c: fix -D or -U as last arg core dump
+02-01-24 pplib.h: use vmalloc(Vmregion) if _std_malloc
+02-01-23 probe.win32: add more msvc predefined macro candidates
+02-01-14 ppproto.c: #pragma prototyped noticed -- has notice comment
+02-01-10 ppproto.c: fix PROTO_FORCE|PROTO_PASS bug that disabled PROTO_FORCE
+02-01-08 pplex.c: fix HEADEREXPAND|HEADEREXPANDALL logic
+01-11-22 pplex.c: add pp:headerexpandall for gcc vs. msvc <...> expand diff
+ pp.probe: add pp:headerexpandall test
+01-10-20 pplex.c: fix pp:splicespace inside "..."
+01-09-11 ppinput.c: use pathnative() for native fs representation
+01-08-31 pp.probe: handle -Dmacro(args)=value
+01-08-11 ppcontrol: fix ... and __VAR_ARGS__ for C99
+ ppsearch: fix SEARCH_NEXT bug that skipped the include stack
+01-08-06 ppproto: preserve #! first line for # comments
+01-07-17 gentab.sh: fix ksh test to omit pdksh (typeset -u fails)
+01-06-26 ppproto.c: fix another buffer boundary bug that didn't preserve OTHER
+01-06-06 ppsearch.c: list PP_FILEDEPS headers once
+01-06-01 pp.h,ppop.c,ppsearch.c: allow multiple PP_FILEDEPS (-M)
+01-05-24 pp.probe: fix pp:hostedtransition probe: only suncc can __STDC__==1?
+01-04-25 pp.probe: split macro probe files for compilers that have #line limits
+01-04-19 pp.h,pplex.c,ppproto.c: fix { \a \E \v } EBCDIC translations
+01-04-16 pp.tab: add pp:splicespace for mvs jcl decks -- the 60's live on
+01-04-13 ppbuiltin: add __FUNCTION__ cache for functions that span the buffer
+01-03-08 pp.tab,ppbuiltin,ppcontrol,probe: add pp:hostedtransition
+01-02-22 pp.tab,ppfsm,pplex,pp.probe,probe.win32: add pp:zeof for ^Z => EOF
+01-02-14 ppcall.c: fix macro(tuple*) bug that truncated macro arg expand buffer
+ pplex.c: fix # inside pp:pragmaexpand
+ gentab.sh: change ksh test for openbsd /bin/sh
+ ppproto.c: fix buffer boundary bug that lost call nesting
+ ppproto.c: add realloc prototype and memcpy=>memcopy strcpy=>strcopy
+01-02-09 ppsearch.c: fix another pp.include null dereference
+01-02-07 ppcall.c: fix stack inequality checks
+ ppcall.c: handle trailing \ in macro args
+01-02-06 fix readonly buffer write (cpp test 07:2873)
+01-02-04 fix -M* to properly handle .cxx .cpp .C input
+ fix IN_BUFFER pop bug that did not reset the token pointer
+01-01-01 pp:headerexpand: space ok if not IN_MACRO
+ ppcall: hide if IN_FILE|IN_MACRO|IN_EXPAND
+ pplex: don't complain about ^L or ^Z as last char in file
+ ppsearch: fix #include <.../foo.h> loop
+ ppcontrol: manulally increment IN_RESCAN error_info.line
+00-12-25 add EXPOSE to expose hidden macros (for #import ...)
+ probe.win32: add cc path *and* args to first line to avoid hash clash
+ pp.probe: filter out invalid symbols for predefined macro scan, duh
+ pp:headerexpand: limit expansion to IN_MACRO
+00-10-31 __STDC__==0 if HOSTED && _UWIN
+00-10-26 pplib.h: change SEEK_SET to O_RDONLY for aix
+00-10-17 pp.probe: __IMPORT__ => __STDPP__IMPORT__
+00-09-18 add __FUNCTION__=#(FUNCTION), #define <a b> c
+ pp.probe: add probe_longlong
+ probe.win32: add #define <long long>
+00-09-11 add pp:noproto (NOPROTO pp.option) to disable ppproto()
+00-09-01 ppproto: fix buffer slide bug
+00-08-11 pplb.h: check for <unistd.h> already included for PROTOMAIN
+ pragma: add pp:pragmaexpand to expand pragma args
+ ppcontrol: always disable pp:* pragma expansion
+ ppcall: fix pp:hide buffer clash
+00-06-01 pplex: fix "\\U" and "\\u"
+00-05-22 ppsearch: fix uwin #include <C:/foo/bar.h>
+00-05-16 probe.win32: update reserved word list
+00-05-09 ppcontrol: fix C++ macro >+> invalid fuse
+ ppcontrol: 'macro' expansion only for COMPATIBILITY | TRANSITION
+ c9x: up to date with proposed standard
+00-04-01 pp.tab: add allpossible and ALLPOSSIBLE
+ ppmacref: fix ref inside literal catenation
+00-02-14 pppopen(): general comments with "bme" (begin middle end) string
+00-01-11 pp.probe: hosttype now in C.probe
+99-11-19 is[a-z]*( => ppis[a-z]*(
+ ppproto: "..." [A-Z_]+ "..." ignores [A-Z_]+ if PROTOMAIN
+99-11-11 ppproto: use astlicense()
+99-10-31 ppproto: add PROTO_SHARP, update license parse
+ pplex: fix some MARK bugs seen by #define X "A B <C@D>"
+99-10-01 add pp:stringsplit for "...\\n..." => "..."\n"..."
+ add pp:lineid to match PP_LINEID
+99-07-17 ppbuiltin: fix getline() canon spacing for numbers
+ ppsearch: fix FILEDEPS not found \\n print
+ pplex: fix spurious FILEDEPS '.' empty character constant message
+ ppargs: fix usage error call and error_info.id default value
+ ppproto: fix up copyright notice for ksh93 style .author file
+ ppproto: check if notice text if file path
+99-06-02 ppproto: add __MANGLE_package_DATA__ & __MANGLE_package_FUNC__
+99-05-26 ppcontrol: all pragmas but prototyped need pp:
+99-05-25 ppargs: long options
+99-05-22 ppproto: changes for full ast vs. PROTO_STANDALONE
+99-05-09 ppinput: add #pragma pp:native and (pp.option&NATIVE) for native paths
+99-04-22 ppproto: finish type=open notice
+99-02-11 #define __STDC__ #(STDC); demote __STDC__ to 0 for HOSTED (thanks sun)
+99-02-04 pplex: joined strings separated by \\\n
+99-01-11 probe.win32: add _UWIN predef
+98-10-20 pplex: a few more (HOSTED|RELAX) checks
+ -D:preserve throws a bunch of stuff -- great for imake (yuk)
+98-05-11 pplex: fix "..." \n off by one line count
+98-02-14 ppcontrol: fix HEADEREXPAND missing NUL
+98-01-23 ppproto: add _GNUC_ to _WIN32 check
+ ppfsm: don't optimize for hp.pa
+97-11-11 ppcontrol: fix recursive use of pp.hdrbuf for HEADEREXPAND
+97-10-31 ppmacref,pp.h: add ppmacref sum arg -- some parts assumed it!
+97-10-01 pplex: loosen HEADEREXPAND check
+97-08-11 pplex: fix COMPILE pplex() bug that did not reset NEWLINE for S_MACRO
+ pplex: PP_PRESERVE does not pp.pragma <token> ... # <pragma-stuff>
+ pp.def: add UWIN
+ ppcall: fix macro actual arg error checks
+97-07-17 ppproto.c: C++ __INLINE__ prefixed with extern __MANGLE__
+ ppop.c: fix PP_RESERVED T_* lookup
+97-05-09 pp.def: add MVS :architecture:
+ ppfsm.c: change C_* pseudo codes to not clash with ebcdic
+ pp.probe: fix stdc.$src sed script
+97-04-01 ppcontrol.c: fix tokop() for PP_RESERVED
+96-12-25 add ms #@ charize to complement # stringize
+ pp.probe now detects preincludes
+ ppproto: allow #ifdef'd function definions before {
+ ppproto: NoN() is not a function
+ pp.key,ppkey.h: add int64
+ ppargs.c: fix -M{DGM}*
+96-12-06 add pp:headerexpand for ms that expands macros in expanded <...>
+96-10-31 a few more line sync tweaks for EDG C++
+96-10-11 fix pp:macref off by one for standalone pp (big suprise)
+96-10-01 -D:macref -D-L -> #line (n-2)\n#pragma pp:macref ...
+96-08-11 fix transition macro expansion
+ compatibility \" or \' does not start quote
+96-02-29 use <hashkey.h>
+ drop ungetchr() in ppcall that modified macro values
+ tighten the DEBUG PANIC case in ppcontrol.c
+ unify #architecture() and #machine() probe
+ add POSIX,WIN32,X86 to pp.sym
+ tweak pp.probe
+96-02-14 pp:noallmultiple works on hosted files too
+ fix #define /* EOF loop
+96-01-31 fix ## as arg to stringize macro to have ## value, not #
+ add nonstopux and SYSTYPE_SVR4 to pp.def
+96-01-01 AT&T Research now
+ fix catliteral line sync line number bug
+ ppproto() converts non-directive <num>u to (unsigned)<num>
+ switch to <regex.h>
+95-10-31 fix PP_COMPILE PP_TRANSITION bug that didn't allow space before #
+ fix PP_TRANSITION \newline in definition complaint
+95-10-11 fix ppproto() PROTO_PLUSPLUS bug
+ change ignored pp.incref PP_SYNC_POP to PP_SYNC_IGNORE
+ add PP_PEDANTIC to handle gnu oversights (can't beat em ...)
+ add memfatal() call
+ relax newline in quote semantics
+ proto inline -> __INLINE__
+ fix __INLINE__ proto def for __GCC__>=2
+95-08-11 pp:preserve for easel (aka IFS) and imake
+ fix pp:reguard ## macro output
+ fix MARK PANIC with CATLITERAL
+ PP_INPUT *.(s|S|as|AS|asm|ASM) implies pp:nocatliteral pp:spaceout
+ ppargs() can't use isid() until after FSM_INIT
+ -D#... for assert, -D%... for directives
+ __STRICT_ANSI__ && __GNUC__ requires -pedantic for PP_STRICT
+ #include <.../x> for include_next
+95-05-09 fix tokop() bug that concatenated adjacent strings
+ don't concatenate directive string literals in proto
+ split pp.mode into pp.mode and pp.option
+ restrict pp.probe hostinfo output to the first token
+ fix EOB/EOF pplex() nonterminating loop
+ unused var cleanup
+ add pp:reguard to emit #define and #undef (for C++ templates)
+ add a few ppproto '\r's for NT
+ fix T_BUILTIN ppsymbol -> ppsymkey pun
+ fix pp:stringspan `#define x "' hang
+95-04-01 fix pp:hide for macros defined before the hide
+ fix pp:map getline space canonicalization
+ fix proto `<digits>[uU]'
+ proto does // comments by default (fixes bug introduced 07/17/94)
+ proto does "..." "..." string literal concatenation
+ spice up proto copyright comments for nonexclusive license
+ add hosttype assertion
+ fix proto `typedef type fun(args)'
+ proto copyright finishing touches
+ fix overzealous "empty character constant" message
+95-02-14 pp:nopredefined probe info defines are now pp:builtin
+ clean up pp:hosted conflicts
+ tighten up unknown directive warning
+ PP_INPUT *.(s|as|AS|asm|ASM) implies pp:nocatliteral pp:spaceout
+ change newof(0,char,n,0) to newof(0,char,0,n) if 0 init not needed
+ don't emit unkown directives inside #if 0 ... #endif
+95-01-19 *strict-* does not force STRICT
+ token##null-last-variadic-arg consumes token (to match gcc)
+ variadic actuals call be one less than arity (to match gcc)
+ fix PLUSPLUS digraph bug that lost comment state
+ tighten up PLUSPLUS //, /*, */ interaction warnings
+ macro formals in "..." for COMPATIBILITY|TRANSITION
+ macro formals in '...' for COMPATIBILITY|TRANSITION|!STRICT
+ STRINGSPAN allows '\n' in '... too
+ add PP_SYNC_* flags for pp.incref arg 3
+ add PP_SYNC_INSERT for invented file references
+ fix C++ fsm bug that popped out of comment in // /* */ ...
+ PP_INPUT *.(s|S|asm|ASM) implies pp:nocatliteral pp:spaceout
+95-01-01 avoid string literal concatenation in pp.probe #if #predicate() tests
+ fix pplib.h memcpy,strncmp PROTOMAIN prototypes (its a nop tho)
+94-11-11 fix readonly memory reference in refill
+ add C++ digraphs (digraph = --trigraph)
+ add C++ T_EXPLICIT -- did dos take over C++?
+ fix improper ppproto() C++ __PARAM__ expansion
+94-11-01 allow #include string header arg concatenation (yes, its not ansi)
+ #macdef macros are recursive
+94-10-01 fix C++ } loop in ppfsm/refill
+ T_NOISES consumes symbol and optional paren group
+ __builtin_* T_NOISES by default
+ fix "..." "...MARK..." join
+ fix STANDALONE */*comment*/
+94-09-11 fix pp.probe cp+strip with chmod u+w
+94-08-11 add -I<vdb-archive> to handle pax -x ppar header archives
+ fix -D-Q header checkpoints
+ add `pp:chop prefix' to chop prefix/ from include prefix/*/*
+ add pp:keyargs for key=value macro formals/actuals (not for C!)
+94-06-01 fix ppcontrol/tokop() that botched pp:id, etc.
+ add pp:plussplice to handle cfront // \<newline> ignorance
+ inhibit trigraph conversion for pp:compatibility, duh
+ new C++ keywords enabled by pp:keyword
+ proto: int fun xxx((yyy)) is macro call, not decl
+ fix !ALLMULTIPLE pp:load to SKIP between duplicated line syncs
+ fix PP_DUMP for pp:noallmultiple, optimize pp:load format
+ fix CPP CACHEOUTX() buffer boundary bug
+94-04-01 drop warnings for -X*
+ fix ppproto() %% in comment bug for yacc proto
+ PP_COMMENT now truncates comments to MAXTOKEN-4
+94-03-01 no pp:truncate for #pragma pp:macref
+94-01-01 fix STANDALONE+PP_TRUNCATE fsm macro bug
+ drop __VOID__ from ppproto.c
+93-12-01 release
+93-11-11 fix PP_COMPILE+PP_TRUNCATE=8 bug for continue,unsigned,etc.
+ add PP_LINEBASE for compilers that botch long line sync paths
+ fix #if unsigned promotions
+ aggressive interactive line splice flush
+ fix #else inside multiline null dereference
+ fix "..." newline space # COMPATIBILITY CATLITERAL bug
+ fix m(a)b compatibility token pasting [cpp/test/ess.01.c]
+ fix nested @X mark bug [cpp/test/net.02.c]
+93-10-11 add FSM_COMPATIBILITY for floating point hex -- yo ansi, anybody home
+ add #else if|ifdef|ifndef for COMPATIBILITY but with warning
+ drop PP_HOSTED, add ppop(PP_CDIR|PP_HOSTED,"-",n), -D-I for pp:cdir
+93-10-01 add pp:opspace to tokenize <binop><space>= to <binop>=
+93-08-11 drop ancient BCD constant (`...`) detection -- wake up cfront
+ fix PP_TRUNCATE macro fsm bug that missed some expansions
+ fix stringize bug that choked if space preceded #
+ fix <function-like-macro> <identifier> bug that omitted space
+93-07-17 minor transition mode fix for string concatenation
+ fix standalone macdef line sync buffer bug
+ pp:noline turns off linesync, pp:line restores it
+93-06-22 add pp:prefix to control prefix include compatibility
+93-04-01 use probe_verbose in predefined symbol probe
+93-03-11 close fd after last file block read -- relaxes open fd limit
+ remove pp.control nesting limit
+ add `#rename old new'
+ __STDC__ not defined for plusplus (until they figure it out)
+93-01-22 fix ansi macro args recursion bug
+93-01-11 fix '\377'<0 for signed char compilers
+ add RELAX for __STDPP__directive directives
+92-12-25 fix #include guard test that omitted IN_tokens for CPP=1
+92-12-11 fix pp:truncate for STANDALONE and COMPILE
+ fix pp:allmultiple again!
+92-11-30 add pp:final, pp:initial
+ add __STDPP__directive and #(directive) as ??= alternative
+ relax obsolete macro expand warning for _xxx||xxx
+ retain quoted \newline when PP_LINEID != ""
+ fix CATLITERAL hidden newline line sync
+92-11-11 fix COMPATIBILITY EOF in macro arg list and # in macro body
+ fix [?\] on 4K buffer boundary bug that lost next refill()
+ fix ppproto bug that botched -ih comments
+92-10-31 fix standalone -C bug that duplicated output buffer
+ add pp:stringspan to handle gnu "<newline>" extension
+92-10-12 fix T_X_GROUP asm bug
+ allow `#define a "b' pp:compatibility hack
+92-08-11 add PP_PLUSCOMMENT, pp:pluscomment probe
+ add #(default v,d) #(empty v) #(iterate m,...)
+ compatibility allows #define f(a,,b) for 2 args!
+ probe now handles gcc -E -g3 to get gnu predefines
+92-07-17 fix pp:multiple again, fix ppproto() out of bounds
+ PP_STANDARD is always PP_CDIR and PP_HOSTED
+92-07-11 add #import and #include_next probes
+92-06-11 fix bug where comments dissappeared after disabled macro in standalone
+ COMPATIBILITY macro recursion bug fix may cause some to be missed
+ PP_MACREF or -D-L- ignores #line until #line with file arg
+92-06-01 add pp:ignore
+ fix probe of stdpp to handle -I[-+][CH]
+92-05-11 add pp:hide <id>, pp:note <id>, noticed(<id>), exists(<...>)
+ add defined(__STDPP__<pragma>) feature test
+ add PP_CDIR, pp:cdir for C++ extern "C" { ... } include wrapping
+ pp.probe now handles predefines with values other than 1
+92-04-11 add inverse proto (K&R -> prototype) to ppproto
+92-04-01 release
+92-02-29 #include <...> inside <xxx.h> gets next xxx.h on -I list
+ non-libpp generated symbols containing ' ' are not truncated
+92-02-11 conversion to new lexer brings time close to reiser (esp. w/gcc -O)
+ combine standalone (ppcpp) tokenizing (pplex) and proto lex tables
+ recode ppproto for standalone operation via PROTOMAIN
+ add PP_NOHASH for PP_COMPILE front ends that rehash T_ID anyway
+ delete PP_NOQUOTE
+ delete #option(strict) test in probe in favor of non-hosted warnings
+ add unsigned to ppexpr()
+91-10-11 add pp:truncate <len> for non-flexname compilers
+91-09-11 fix ppproto aggression on f(*y); -> f __PROTO__((*y));
+91-08-11 switch seterror() to error_info.*
+ add pp:linefile to force file name in line sync
+ add pp:spaceout for probed compilers that don't allow pp override
+91-06-11 fix ignored -I/usr/include bug
+91-04-11 set SYM_INIT in pp.macref for -U on cmd line
+91-01-31 replace pp:pragma and pp:directive with pp:map
+ replace #assert and #unassert with #define #... and #undef #...
+ #assert and #unassert compatibility retained via pp:map
+ replace -D#directive with -D%directive (because of #assert change)
+ add pp:splicecat for \<newline> #define token paste
+ fix \<newline> bug that added space in COMPATIBILITY quoted strings
+90-12-11 fix #pragma pp:multiple
+90-11-11 generalize handling of non-standard keywords for COMPILE
+ replace pp:identifier/PP_IDENTIFIER with pp:reserved/PP_RESERVED
+ pp*keys* -> ppkey
+ add PP_NOISE
+ (gag) handle msdos paths by changing \ to / and retrying on failure
+ (gag) handle msdos :> operator by pplex() '+' return
+ add #pragma prototyped and ppproto.c for prototype conversion
+ add unsigned long arg to PP_MACREF for hashed macro arity+value
+90-10-11 0f is not a float constant
+ change -I-M to -I-I, file just lists include files to be ignored
+ fix ppprobe for __STDC__==0 hybrids
+ add pp.flags and PP_[a-z0-9]+ for exported state info
+90-10-01 fix standalone ppmacref for directives
+ add `try' to C++ keywords
+ fine tune a few COMPILE error messages
+ privatize pp.h
+90-08-11 use opt_again in cmdargs() option parsers
+ (gag) add pp:macref macro reference pragma to handle CC preprocessors
+ (gag) add pp:spaceout to handle ansi + asm hacks
+90-07-17 remove spaces from macdef line sync (blew sun cc)
+90-06-11 add internal ppsymkey to avoid ppsymbol.value pun for SYM_KEYWORD
+90-05-01 fix catliteral bug of `"..." << ' -> `"..." <='
+90-04-01 fix `ifndef-define-endif' include wrapper test
+90-03-27 add setpreroot() to ppop() [ sleazy but well hidden ]
+90-03-22 pp.macref called for all undef's
+90-03-20 add <prefix>cpp checks to ppprobe
+ add pp:hostdir before pp:include in ppprobe
+ fix PP_HOSTDIR op with no dir arg
+90-03-15 System V CCS compatibility update
+ add PP_ASSERT
+ add -A for PP_ASSERT and -YI,dir for PP_STANDARD
+ add ppincref.c and -H to use it
+ -Xa defines __STDC__ to 0 (gak)
+90-03-09 duplicate macro formals cause level 2 error
+90-03-01 add #(ARGC) for (variadic) macro arg count
+90-02-11 fix line sync number bug in pppush()
+89-12-01 ignore leading = in pragma map for old pragma compatibility
+ check for NEWLINE on first macdef line sync
+89-11-11 add -1 arg to pp.incref -- include skipped
+ STRICT 0x7e-macro is T_INVALID per standard
+89-10-31 put all C keys in ppckeys.c, C++ keys in pppkeys.c
+ add pp:identifier pragma to selectively undo PP_COMPILE keywords
+ add tokop() to ppcontrol to support multi-valued pragmas
+ add #ifndef...#endif include optimization for STRICT
+89-10-27 use REF_NORMAL, REF_IF, REF_UNDEF for pp.macref arg2
+89-10-17 fix c(x)y compatibility pasting bug
+ #line 1 "f" now marks "f" included
+89-10-11 enable -I. during initialization
+89-10-01 inhibit pp:linetype syncs for top level #line directives
+ ----- see HISTORY -----
diff --git a/usr/src/lib/libpp/common/gentab.sh b/usr/src/lib/libpp/common/gentab.sh
new file mode 100644
index 0000000000..0234ce6c93
--- /dev/null
+++ b/usr/src/lib/libpp/common/gentab.sh
@@ -0,0 +1,234 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1986-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# Glenn Fowler <gsf@research.att.com> #
+# #
+########################################################################
+:
+# Glenn Fowler
+# AT&T Bell Laboratories
+#
+# @(#)gentab (gsf@research.att.com) 07/17/94
+#
+# C table generator
+#
+# %flags [ prefix=<prefix> ] [ index=<index> ] [ init=<init> ]
+#
+# %keyword <name> [ prefix=<prefix> ] [ index=<index> ] [ init=<init> ] [ first=<id> ] [ last=<id> ]
+#
+# %sequence [ prefix=<prefix> ] [ index=<index> ] [ init=<init> ]
+#
+
+case `(typeset -u s=a n=0; ((n=n+1)); print $s$n) 2>/dev/null` in
+A1) shell=ksh
+ typeset -u ID
+ typeset -i counter err_line
+ ;;
+*) shell=bsh
+ ;;
+esac
+command=$0
+counter=0
+define=1
+err_line=0
+type=""
+index=""
+first=""
+last=""
+table=1
+while :
+do case $1 in
+ -d) table=0 ;;
+ -t) define=0 ;;
+ *) break ;;
+ esac
+ shift
+done
+case $1 in
+"") err_file=""
+ ;;
+*) exec <$1
+ err_file="\"$1\", "
+ ;;
+esac
+while read line
+do case $shell in
+ ksh) ((err_line=err_line+1)) ;;
+ *) err_line=`expr $err_line + 1` ;;
+ esac
+ set '' $line
+ shift
+ case $1 in
+ [#]*) echo "/*"
+ while :
+ do case $1 in
+ [#]*) shift
+ echo " * $*"
+ read line
+ set '' $line
+ shift
+ ;;
+ *) break
+ ;;
+ esac
+ done
+ echo " */"
+ echo
+ ;;
+ esac
+ eval set '""' $line
+ shift
+ case $1 in
+ "") ;;
+ %flags|%keywords|%sequence)
+ case $define:$last in
+ 1:?*) case $shell in
+ ksh) ((n=counter-1)) ;;
+ *) n=`expr $counter - 1` ;;
+ esac
+ echo "#define $prefix$last $n"
+ ;;
+ esac
+ case $type in
+ %flags|%sequence)
+ if test $define = 1
+ then echo
+ fi
+ ;;
+ %keywords)
+ if test $table = 1
+ then echo " 0, 0"
+ echo "};"
+ echo
+ elif test $define = 1
+ then echo
+ fi
+ ;;
+ esac
+ case $index in
+ ?*) eval $index=$counter ;;
+ esac
+ type=$1
+ shift
+ name=""
+ prefix=""
+ index=""
+ init=""
+ first=""
+ last=""
+ case $type in
+ %keywords)
+ case $1 in
+ "") echo "$command: ${err_file}line $err_line: $type table name omitted" >&2
+ exit 1
+ ;;
+ esac
+ name=$1
+ shift
+ if test $table = 1
+ then echo "$name"'[] ='
+ echo "{"
+ fi
+ ;;
+ esac
+ eval "$@"
+ case $init in
+ "") case $type in
+ %flags|%sequence)
+ init=0
+ ;;
+ *) init=1
+ ;;
+ esac
+ ;;
+ esac
+ case $index in
+ "") counter=$init
+ ;;
+ *) eval value=\$$index
+ case $value in
+ "") counter=$init ;;
+ [0123456789]*) counter=$value ;;
+ esac
+ ;;
+ esac
+ case $define:$first in
+ 1:?*) echo "#define $prefix$first $counter" ;;
+ esac
+ ;;
+ %*) echo "$command: ${err_file}line $err_line: $1: unknown keyword" >&2
+ exit 1
+ ;;
+ *) while :
+ do case $1 in
+ "") break
+ ;;
+ *) case $shell in
+ ksh) ID=${1#[!abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]} ;;
+ *) ID=`echo $1 | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | sed 's/^[^ABCDEFGHIJKLMNOPQRSTUVWXYZ_]//'` ;;
+ esac
+ case $type in
+ %flags) if test $define = 1
+ then case $counter in
+ 32) echo "$command: ${err_file}line $err_line: warning: $1: too many flag bits" >&2 ;;
+ 1[56789]|[23][0123456789]) long=L ;;
+ *) long= ;;
+ esac
+ echo "#define $prefix$ID (1$long<<$counter)"
+ fi
+ ;;
+ %keywords)
+ if test $define = 1
+ then echo "#define $prefix$ID $counter"
+ fi
+ if test $table = 1
+ then echo " \"$1\", $prefix$ID,"
+ fi
+ ;;
+ %sequence)
+ if test $define = 1
+ then echo "#define $prefix$ID $counter"
+ fi
+ ;;
+ esac
+ case $shell in
+ ksh) ((counter=counter+1)) ;;
+ *) counter=`expr $counter + 1` ;;
+ esac
+ shift
+ ;;
+ esac
+ done
+ ;;
+ esac
+done
+case $define:$last in
+1:?*) case $shell in
+ ksh) ((n=counter-1)) ;;
+ *) n=`expr $counter - 1` ;;
+ esac
+ echo "#define $prefix$last $n"
+ ;;
+esac
+case $type in
+%keywords)
+ if test $table = 1
+ then echo " 0, 0"
+ echo "};"
+ fi
+ ;;
+esac
+exit 0
diff --git a/usr/src/lib/libpp/common/llib-lpp b/usr/src/lib/libpp/common/llib-lpp
new file mode 100644
index 0000000000..d3df1ce176
--- /dev/null
+++ b/usr/src/lib/libpp/common/llib-lpp
@@ -0,0 +1,53 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * lib/libpp/common/llib-lpp
+ *
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*LINTLIBRARY*/
+/*PROTOLIB1*/
+
+#include "pp.h"
+
+/* automatically generated data start here */
+extern struct ppglobals pp;
+extern char ppctype[];
+extern int ppargs(char**, int);
+extern void ppcpp(void);
+extern void ppcomment(char*, char*, char*, int);
+extern void* ppcontext(void*, int);
+extern void pperror(int, ...);
+extern void ppincref(char*, char*, int, int);
+extern void ppinput(char*, char*, int);
+extern int pplex(void);
+extern void ppline(int, char*);
+extern void ppmacref(struct ppsymbol*, char*, int, int, unsigned long);
+extern void ppop(int, ...);
+extern void pppragma(char*, char*, char*, char*, int);
+extern int ppprintf(char*, ...);
+extern int ppsync(void);
+/* end of automatically generated data */
diff --git a/usr/src/lib/libpp/common/pp.3 b/usr/src/lib/libpp/common/pp.3
new file mode 100644
index 0000000000..988185bd24
--- /dev/null
+++ b/usr/src/lib/libpp/common/pp.3
@@ -0,0 +1,890 @@
+.fp 5 CW
+.de L \" literal font
+.ft 5
+.if !\\$1 \&\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \f1
+..
+.de LR
+.}S 5 1 \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
+..
+.de RL
+.}S 1 5 \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
+..
+.de EX \" start example
+.ta 1i 2i 3i 4i 5i 6i
+.PP
+.RS
+.PD 0
+.ft 5
+.nf
+..
+.de EE \" end example
+.fi
+.ft
+.PD
+.RE
+.PP
+..
+.TH PP 3
+.SH NAME \" @(#)pp.3 (gsf@research.att.com) 04/01/92
+pp \- ANSI C preprocessor library
+.SH SYNOPSIS
+.EX
+:PACKAGE: ast
+#include <pp.h>
+%include "pptokens.yacc
+\-lpp
+.EE
+.SH DESCRIPTION
+The
+.I pp
+library provides a tokenizing implementation of the C language preprocessor
+and supports K&R (Reiser), ANSI and C++ dialects.
+The preprocessor is comprised of 12 public functions,
+a global character class table accessed by macros, and
+a single global struct with 10 public elements.
+.PP
+.I pp
+operates in two modes.
+.I Standalone
+mode is used to implement the traditional standalone C preprocessor.
+.I Tokeinizing
+mode provides a function interface to a stream of preprocessed tokens.
+.I pp
+is by default ANSI; the only default predefined symbols are
+.L __STDC__
+and
+.LR __STDPP__ .
+Dialects (K&R, C++) and local conventions are determined by
+compiler specific
+.IR probe (1)
+information that is included at runtime.
+The
+.I probe
+information can be overridden by providing a file
+.L pp_default.h
+with pragmas and definitions for each compiler implementation.
+This file is usually located in the compiler specific
+default include directory.
+.PP
+Directive, command line argument, option and pragma syntax is described in
+.IR cpp (1).
+.I pp
+specific semantics are described below.
+Most semantic differences with standard or classic implementations are in the
+form of optimizations.
+.PP
+Options and pragmas map to
+.L ppop
+function calls described below.
+For the remaining descriptions,
+``setting \f5ppop(PP_\fP\fIoperation\fP\f5)\fP''
+is a shorthand for calling
+.L ppop
+with the arguments appropriate for
+\f5PP_\fP\fIoperation\fP.
+.PP
+The library interface describes only the public functions and struct elements.
+Static structs and pointers to structs are provided by the library.
+The user should not attempt to allocate structs.
+In particular,
+.L sizeof
+is meaningless for
+.I pp
+supplied structs.
+.PP
+The global struct
+.L pp
+provides readonly information.
+Any changes to
+.L pp
+must be done using the functions described below.
+.L pp
+has the following public elements:
+.TP
+.L "char* version"
+The
+.I pp
+implementaion version string.
+.TP
+.L "char* lineid"
+The current line sync directive name.
+Used for standalone line sync output.
+The default value is the empty string.
+See the
+.L ppline
+function below.
+.TP
+.L "char* outfile"
+The current output file name.
+.TP
+.L "char* pass"
+The pragma pass name for
+.I pp.
+The default value is
+.LR pp .
+.TP
+.L "char* token"
+The string representation for the current input token.
+.TP
+.L "int flags"
+The inclusive or of:
+.RS
+.TP
+.L PP_comment
+Set if
+.L ppop(PP_COMMENT)
+was set.
+.TP
+.L PP_compatibility
+Set if
+.L ppop(PP_COMPATIBILITY)
+was set.
+.TP
+.L PP_linefile
+Set if standalone line syncs require a file argument.
+.TP
+.L PP_linetype
+Set if standalone line syncs require a third argument.
+The third argument is
+.L 1
+for include file push,
+.L 2
+for include file pop and null otherwise.
+.TP
+.L PP_strict
+Set if
+.L ppop(PP_STRICT)
+was set.
+.TP
+.L PP_transition
+Set if
+.L ppop(PP_TRANSITION)
+was set.
+.RE
+.TP
+.L "struct ppdirs* lcldirs"
+The list of directories to be searched for "..." include files.
+If the first directory name is "" then it is replaced by the
+directory of the including file at include time.
+The public elements of
+.L "struct ppdirs"
+are:
+.RS
+.TP
+.L "char* name"
+The directory pathname.
+.TP
+.L "struct ppdirs* next"
+The next directory,
+.L 0
+if it is the last in the list.
+.RE
+.TP
+.L "struct ppdirs* stddirs"
+.L pp.stddirs\->next
+is the list of directories to be searched for <...> include files.
+This list may be
+.LR 0 .
+.TP
+.L "struct ppsymbol* symbol"
+If
+.L ppop(PP_COMPILE)
+was set then
+.L pp.symbol
+points to the symbol table entry for the current identifier token.
+.L pp.symbol
+is undefined for non-identifier tokens.
+Once defined, an identifier will always have the same
+.L ppsymbol
+pointer.
+If
+.L ppop(PP_NOHASH)
+was also set then
+.L pp.symbol
+is defined for macro and keyword tokens and
+.L 0
+for all other identifiers.
+The elements of
+.L "struct ppsymbol"
+are:
+.RS
+.TP
+.L "char* name"
+The identifier name.
+.TP
+.L "int flags"
+The inclusive or of the following flags:
+.PD 0
+.RS
+.TP
+.L SYM_ACTIVE
+Currently being expanded.
+.TP
+.L SYM_BUILTIN
+Builtin macro.
+.TP
+.L SYM_DISABLED
+Macro expansion currently disabled.
+.TP
+.L SYM_FUNCTION
+Function-like macro.
+.TP
+.L SYM_INIT
+Initialization macro.
+.TP
+.L SYM_KEYWORD
+Keyword identifier.
+.TP
+.L SYM_LOADED
+Loaded checkpoint macro.
+.TP
+.L SYM_MULTILINE
+.L #macdef
+macro.
+.TP
+.L SYM_NOEXPAND
+No identifiers in macro body.
+.TP
+.L SYM_PREDEFINED
+Predefined macro.
+.TP
+.L SYM_PREDICATE
+Also a
+.L #assert
+predicate.
+.TP
+.L SYM_READONLY
+Readonly macro.
+.TP
+.L SYM_REDEFINE
+Ok to redefine.
+.TP
+.L SYM_VARIADIC
+Variadic function-like macro.
+.TP
+.L SYM_UNUSED
+First unused symbol flag bit index.
+The bits from
+.L (1<<SYM_UNUSED)
+on are initially unset and may be set by the user.
+.RE
+.PD
+.TP
+.L "struct ppmacro* macro"
+Non-zero if the identifier is a macro.
+.L "int macro\->arity"
+is the number of formal arguments for function-like macros and
+.L "char* macro\->value"
+is the macro definition value, a
+.L 0
+terminated string that may contain internal mark sequences.
+.TP
+.L "char* value"
+Initially set to
+.L 0
+and never modified by
+.IR pp .
+This field may be set by the user.
+.RE
+.TP
+.L "Hash_table_t* symtab"
+The macro and identifier
+.L "struct ppsymbol"
+hash table.
+The
+.IR hash (3)
+routines may be used to examine the table, with the exception that the
+following macros must be used for individual
+.L pp.symtab
+symbol lookup:
+.RS
+.TP
+.L "struct ppsymbol* ppsymget(Hash_table_t* table, char* name)"
+Return the
+.L ppsymbol
+pointer for
+.LR name ,
+0 if
+.L name
+not defined.
+.TP
+.L "struct ppsymbol* ppsymset(Hash_table_t* table, char* name)"
+Return the
+.L ppsymbol
+pointer for
+.LR name .
+If
+.L name
+is not defined then allocate and return a new
+.L ppsymbol
+for it.
+.RE
+.RE
+.PP
+Error messages are reported using
+.IR error (3)
+and the following globals relate to
+.IR pp :
+.TP
+.L "int error_info.errors"
+The level 2 error count.
+Error levels above 2 cause immediate exit.
+If
+.L error_info.errors
+is non-zero then the user program exit status should also be non-zero.
+.TP
+.L "char* error_info.file"
+The current input file name.
+.TP
+.L "int error_info.line"
+The current input line number.
+.TP
+.L "int error_info.trace"
+The debug trace level,
+.L 0
+by default.
+Larger negative numbers produce more trace information.
+Enabled when the user program is linked with the
+.B \-g
+.IR cc (1)
+option.
+.TP
+.L "int error_info.warnings"
+The level 1 error count.
+Warnings do not affect the exit status.
+.PP
+The functions are:
+.TP
+.L "extern int ppargs(char** argv, int last);"
+Passed to
+.IR optjoin (3)
+to parse
+.IR cpp (1)
+style options and arguments.
+The user may also supply application specific option parsers.
+Also handles non-standard options like the sun
+.L \-undef
+and GNU
+.LR \-trigraphs .
+Hello in there, ever here of
+.IR getopt (3)?
+.TP
+.L "extern void ppcpp(void);"
+This is the standalone
+.IR cpp (1)
+entry point.
+.L ppcpp
+consumes all of the input and writes the preprocessed text to the output.
+A single call to
+.L ppcpp
+is equivalent to, but more efficient than:
+.EX
+ ppop(PP_SPACEOUT, 1);
+ while (pplex())
+ ppprintf(" %s", pp.token);
+.EE
+.TP
+.L "extern int ppcomment(char* head, char* comment, char* tail, int line);"
+The default comment handler that passes comments to the output.
+May be used as an argument to
+.LR ppop(PP_COMMENT) ,
+or the user may supply an application specific handler.
+.L head
+is the comment head text,
+.L "/*"
+for C and
+.L "//"
+for C++,
+.L comment
+is the comment body,
+.L tail
+is the comment tail text,
+.L "*/"
+for C and
+.B newline
+for C++, and
+.L line
+is the comment starting line number.
+.TP
+.L "extern void pperror(int level, char* format, ...);"
+Equivalent to
+.IR error (3).
+All
+.I pp
+error and warning messages pass through
+.LR pperror .
+The user may link with an application specific
+.L pperror
+to override the library default.
+.TP
+.L "extern int ppincref(char* parent, char* file, int line, int push);"
+The default include reference handler that outputs
+.L file
+to the standard error.
+May be used as an argument to the
+.LR ppop(PP_INCREF) ,
+or the user may supply an application specific handler.
+.L parent
+is the including file name,
+.L file
+is the current include file name,
+.L line
+is the current line number in
+.LR file ,
+and
+.L push
+is non-zero if
+.L file
+is being pushed or
+.L 0
+if file is being popped.
+.TP
+.L "extern void ppinput(char* buffer, char* file, int line);"
+Pushes the
+.L 0
+terminated
+.L buffer
+on the
+.I pp
+input stack.
+.L file
+is the pseudo file name used in line syncs for
+.L buffer
+and
+.L line
+is the starting line number.
+.TP
+.L "int pplex(void)"
+Returns the token type of the next input token.
+.L pp.token
+and where applicable
+.L pp.symbol
+are updated to refer to the new token.
+The token type constants are defined in
+.L pp.h
+for
+.L #include
+and
+.L pp.yacc
+for
+.IR yacc (1)
+.LR %include .
+The token constant names match
+.LR T_[A-Z_]* ;
+some are encoded by oring with
+.L N_[A-Z_]*
+tokens.
+.sp
+The numeric constant tokens and encodings are:
+.EX
+ T_DOUBLE (N_NUMBER|N_REAL)
+ T_DOUBLE_L (N_NUMBER|N_REAL|N_LONG)
+ T_FLOAT (N_NUMBER|N_REAL|N_FLOAT)
+ T_DECIMAL (N_NUMBER)
+ T_DECIMAL_L (N_NUMBER|N_LONG)
+ T_DECIMAL_U (N_NUMBER|N_UNSIGNED)
+ T_DECIMAL_UL (N_NUMBER|N_UNSIGNED|N_LONG)
+ T_OCTAL (N_NUMBER|N_OCTAL)
+ T_OCTAL_L (N_NUMBER|N_OCTAL|N_LONG)
+ T_OCTAL_U (N_NUMBER|N_OCTAL|N_UNSIGNED)
+ T_OCTAL_UL (N_NUMBER|N_OCTAL|N_UNSIGNED|N_LONG)
+ T_HEXADECIMAL (N_NUMBER|N_HEXADECIMAL)
+ T_HEXADECIMAL_L (N_NUMBER|N_HEXADECIMAL|N_LONG)
+ T_HEXADECIMAL_U (N_NUMBER|N_HEXADECIMAL|N_UNSIGNED)
+ T_HEXADECIMAL_UL (N_NUMBER|N_HEXADECIMAL|N_UNSIGNED|N_LONG)
+.EE
+The normal C tokens are:
+.EX
+ T_ID \fIC identifier\fP
+ T_INVALID \fIinvalid token\fP
+ T_HEADER <..>
+ T_CHARCONST '..'
+ T_WCHARCONST L'..'
+ T_STRING ".."
+ T_WSTRING L".."
+ T_PTRMEM ->
+ T_ADDADD ++
+ T_SUBSUB --
+ T_LSHIFT <<
+ T_RSHIFT >>
+ T_LE <=
+ T_GE >=
+ T_EQ ==
+ T_NE !=
+ T_ANDAND &&
+ T_OROR ||
+ T_MPYEQ *=
+ T_DIVEQ /=
+ T_MODEQ %=
+ T_ADDEQ +=
+ T_SUBEQ -=
+ T_LSHIFTEQ <<=
+ T_RSHIFTEQ >>=
+ T_ANDEQ &=
+ T_XOREQ ^=
+ T_OREQ |=
+ T_TOKCAT ##
+ T_VARIADIC ...
+ T_DOTREF .* [\fIif\fP PP_PLUSPLUS]
+ T_PTRMEMREF ->* [\fIif\fP PP_PLUSPLUS]
+ T_SCOPE :: [\fIif\fP PP_PLUSPLUS]
+ T_UMINUS \fIunary minus\fP
+.EE
+If
+.L ppop(PP_COMPILE)
+was set then the keyword tokens are also defined.
+Compiler differences and dialects are detected by the
+.I pp
+.IR probe (1)
+information, and only the appropriate keywords are enabled.
+The ANSI keyword tokens are:
+.EX
+T_AUTO T_BREAK T_CASE T_CHAR
+T_CONTINUE T_DEFAULT T_DO T_DOUBLE_T
+T_ELSE T_EXTERN T_FLOAT_T T_FOR
+T_GOTO T_IF T_INT T_LONG
+T_REGISTER T_RETURN T_SHORT T_SIZEOF
+T_STATIC T_STRUCT T_SWITCH T_TYPEDEF
+T_UNION T_UNSIGNED T_WHILE T_CONST
+T_ENUM T_SIGNED T_VOID T_VOLATILE
+.EE
+and the C++ keyword tokens are:
+.EX
+T_CATCH T_CLASS T_DELETE T_FRIEND
+T_INLINE T_NEW T_OPERATOR T_OVERLOAD
+T_PRIVATE T_PROTECTED T_PUBLIC T_TEMPLATE
+T_THIS T_THROW T_TRY T_VIRTUAL
+.EE
+In addition,
+.L T_ASM
+is recognized where appropriate.
+Additional keyword tokens
+.L ">= T_KEYWORD"
+may be added using
+.LR ppop(PP_COMPILE) .
+.sp
+Many C implementations show no restraint in adding new keywords; some
+PC compilers have tripled the number of keywords.
+For the most part these new keywords introduce noise constructs that
+can be ignored for standard
+.RI ( reasonable )
+analysis and compilation.
+The noise keywords fall in four syntactic categories that map into the two
+noise keyword tokens
+.L T_NOISE
+and
+.LR T_NOISES .
+For
+.L T_NOISES
+.L pp.token
+points to the entire noise construct, including the offending noise keyword.
+The basic noise keyword categories are:
+.RS
+.TP
+.L T_NOISE
+The simplest noise: a single keyword that is noise in any context and maps to
+.LR T_NOISE .
+.TP
+.L T_X_GROUP
+A noise keyword that precedes an optional grouping construct, either
+.L "(..)"
+or
+.L "{..}"
+and maps to
+.LR T_NOISES .
+.TP
+.L T_X_LINE
+A noise keyword that consumes the remaining tokens in the line
+and maps to
+.LR T_NOISES .
+.TP
+.L T_X_STATEMENT
+A noise keyword that consumes the tokens up to the next
+.L ;
+and maps to
+.LR T_NOISES .
+.RE
+.sp
+If
+.L ppop(PP_NOISE)
+is
+.L "> 0"
+then implementation specific noise constructs are mapped to either
+.L T_NOISE
+or
+.L T_NOISES ,
+otherwise if
+.L ppop(PP_NOISE)
+is
+.L "< 0"
+then noise constructs are completely ignored,
+otherwise the unmapped grouping noise tokens
+.L T_X_.*
+are returned.
+.sp
+Token encodings may be tested by the following macros:
+.RS
+.TP
+.L "int isnumber(int token);"
+Non-zero if
+.L token
+is an integral or floating point numeric constant.
+.TP
+.L "int isinteger(int token);"
+Non-zero if
+.L token
+is an integral numeric constant.
+.TP
+.L "int isreal(int token);"
+Non-zero if
+.L token
+is a floating point numeric constant.
+.TP
+.L "int isassignop(int token);"
+Non-zero if
+.L token
+is a C assignment operator.
+.TP
+.L "int isseparate(int token);"
+Non-zero if
+.L token
+must be separated from other tokens by
+.BR space .
+.TP
+.L "int isnoise(int token);"
+Non-zero if
+.L token
+is a noise keyword.
+.RE
+.TP
+.L "extern int ppline(int line, char* file);"
+The default line sync handler that outputs line sync pragmas for the C compiler
+front end.
+May be used as an argument to
+.LR ppop(PP_LINE) ,
+or the user may supply an application specific handler.
+.L line
+is the line number and
+.L file
+is the file name.
+If
+.L ppop(PP_LINEID)
+was set then the directive
+\fB#\fP \fIlineid line \fP"\fIfile\fP" is output.
+.TP
+.L "extern int ppmacref(struct ppsymbol* symbol, char* file, int line, int type);"
+The default macro reference handler that outputs a macro reference pragmas.
+May be used as an argument to
+.LR ppop(PP_MACREF) ,
+or the user may supply an application specific handler.
+.L symbol
+is the macro
+.L ppsymbol
+pointer,
+.L file
+is the reference file,
+.L line
+is the reference line,
+and if
+.L type
+is non-zero a macro value checksum is also output.
+The pragma syntax is
+\fB#pragma pp:macref\fP "\fIsymbol\->name\fP" \fIline checksum\fP.
+.TP
+.L "int ppop(int op, ...)"
+.L ppop
+is the option control interface.
+.L op
+determines the type(s) of the remaining argument(s).
+Options marked by
+.L "/*INIT*/"
+must be done before
+.LR PP_INIT .
+.RS
+.TP
+.L "(PP_ASSERT, char* string) /*INIT*/"
+.L string
+is asserted as if by
+.LR #assert .
+.TP
+.L "(PP_BUILTIN, char*(*fun)(char* buf, char* name, char* args)) /*INIT*/"
+Installs
+.L fun
+as the unknown builtin macro handler.
+Builtin macros are of the form
+.LR "#(name args)" .
+.L fun
+is called with
+.L name
+set to the unknown builtin macro name and
+.L args
+set to the arguments.
+.L buf
+is a
+.L MAXTOKEN+1
+buffer that can be used for the
+.L fun
+return value.
+.L 0
+should be returned on error.
+.TP
+.L "(PP_COMMENT,void (*fun)(char*head,char*body,char*tail,int line) /*INIT*/"
+.TP
+.L "(PP_COMPATIBILITY, char* string) /*INIT*/"
+.TP
+.L "(PP_COMPILE, char* string) /*INIT*/"
+.TP
+.L "(PP_DEBUG, char* string) /*INIT*/"
+.TP
+.L "(PP_DEFAULT, char* string) /*INIT*/"
+.TP
+.L "(PP_DEFINE, char* string) /*INIT*/"
+.L string
+is defined as if by
+.LR #define .
+.TP
+.L "(PP_DIRECTIVE, char* string) /*INIT*/"
+The directive
+.BI # string
+is executed.
+.TP
+.L "(PP_DONE, char* string) /*INIT*/"
+.TP
+.L "(PP_DUMP, char* string) /*INIT*/"
+.TP
+.L "(PP_FILEDEPS, char* string) /*INIT*/"
+.TP
+.L "(PP_FILENAME, char* string) /*INIT*/"
+.TP
+.L "(PP_HOSTDIR, char* string) /*INIT*/"
+.TP
+.L "(PP_HOSTED, char* string) /*INIT*/"
+.TP
+.L "(PP_ID, char* string) /*INIT*/"
+.TP
+.L "(PP_IGNORE, char* string) /*INIT*/"
+.TP
+.L "(PP_INCLUDE, char* string) /*INIT*/"
+.TP
+.L "(PP_INCREF, char* string) /*INIT*/"
+.TP
+.L "(PP_INIT, char* string) /*INIT*/"
+.TP
+.L "(PP_INPUT, char* string) /*INIT*/"
+.TP
+.L "(PP_LINE, char* string) /*INIT*/"
+.TP
+.L "(PP_LINEFILE, char* string) /*INIT*/"
+.TP
+.L "(PP_LINEID, char* string) /*INIT*/"
+.TP
+.L "(PP_LINETYPE, char* string) /*INIT*/"
+.TP
+.L "(PP_LOCAL, char* string) /*INIT*/"
+.TP
+.L "(PP_MACREF, char* string) /*INIT*/"
+.TP
+.L "(PP_MULTIPLE, char* string) /*INIT*/"
+.TP
+.L "(PP_NOHASH, char* string) /*INIT*/"
+.TP
+.L "(PP_NOID, char* string) /*INIT*/"
+.TP
+.L "(PP_NOISE, char* string) /*INIT*/"
+.TP
+.L "(PP_OPTION, char* string) /*INIT*/"
+The directive
+\fB#pragma pp:\fP\fIstring\fP
+is executed.
+.TP
+.L "(PP_OPTARG, char* string) /*INIT*/"
+.TP
+.L "(PP_OUTPUT, char* string) /*INIT*/"
+.TP
+.L "(PP_PASSNEWLINE, char* string) /*INIT*/"
+.TP
+.L "(PP_PASSTHROUGH, char* string) /*INIT*/"
+.TP
+.L "(PP_PLUSPLUS, char* string) /*INIT*/"
+.TP
+.L "(PP_PRAGMA, char* string) /*INIT*/"
+.TP
+.L "(PP_PREFIX, char* string) /*INIT*/"
+.TP
+.L "(PP_PROBE, char* string) /*INIT*/"
+.TP
+.L "(PP_READ, char* string) /*INIT*/"
+.TP
+.L "(PP_RESERVED, char* string) /*INIT*/"
+.TP
+.L "(PP_SPACEOUT, char* string) /*INIT*/"
+.TP
+.L "(PP_STANDALONE, char* string) /*INIT*/"
+.TP
+.L "(PP_STANDARD, char* string) /*INIT*/"
+.TP
+.L "(PP_STRICT, char* string) /*INIT*/"
+.TP
+.L "(PP_TEST, char* string) /*INIT*/"
+.TP
+.L "(PP_TRUNCATE, char* string) /*INIT*/"
+.TP
+.L "(PP_UNDEF, char* string) /*INIT*/"
+.TP
+.L "(PP_WARN, char* string) /*INIT*/"
+.RE
+.TP
+.L "int pppragma(char* dir, char* pass, char* name, char* value, int nl);"
+The default handler that
+copies unknown directives and pragmas to the output.
+May be used as an argument to
+.LR ppop(PP_PRAGMA) ,
+or the user may supply an application specific handler.
+This function is most often called after directive and pragma mapping.
+Any of the arguments may be
+.LR 0 .
+.L dir
+is the directive name,
+.L pass
+is the pragma pass name,
+.L name
+is the pragma option name,
+.L value
+is the pragma option value, and
+.L nl
+is non-zero
+if a trailing newline is required if the pragma is copied to the output.
+.TP
+.L "int ppprintf(char* format, ...);"
+A
+.IR printf (3)
+interface to the standalone
+.I pp
+output buffer.
+Macros provide limited control over output buffering:
+.L "void ppflushout()"
+flushes the output buffer,
+.L "void ppcheckout()"
+flushes the output buffer if over
+.L PPBUFSIZ
+character are buffered,
+.L "int pppendout()"
+returns the number of pending character in the output buffer, and
+.L "void ppputchar(int c)"
+places the character
+.L c
+in the output buffer.
+.SH CAVEATS
+The ANSI mode is intended to be true to the standard.
+The compatibility mode has been proven in practice, but there are
+surely dark corners of some implementations that may have been omitted.
+.SH "SEE ALSO"
+cc(1), cpp(1), nmake(1), probe(1), yacc(1),
+.br
+ast(3), error(3), hash(3), optjoin(3)
+.SH AUTHOR
+Glenn Fowler
+.br
+(Dennis Ritchie provided the original table driven lexer.)
+.br
+AT&T Bell Laboratories
diff --git a/usr/src/lib/libpp/common/pp.def b/usr/src/lib/libpp/common/pp.def
new file mode 100644
index 0000000000..f2d679f3af
--- /dev/null
+++ b/usr/src/lib/libpp/common/pp.def
@@ -0,0 +1,282 @@
+#
+# list of known old cpp predefined symbols
+#
+# @(#)pp.def (gsf@research.att.com) 2002-11-26
+#
+# symbols will be tested for the common `_' permutations
+# qualifiers may be combinations of
+#
+# architecture cpu architecture
+# dialect C dialect
+# machine bundled package name
+# release system release name
+# source *_SOURCE baggage
+# system default is unix
+# vendor compiler vendor
+#
+ABI_SOURCE :source:
+AES_SOURCE :source:
+AIX :architecture:
+AIX32 :architecture:
+AIX64 :architecture:
+ALL_SOURCE :source:
+AM29000 :architecture:
+AM29K :architecture:
+ANSI_CPP :dialect:
+AOSVS :release:
+APPLE :vendor:
+APPLE_CC :dialect:
+ATT :release:
+ATT4 :release:
+BIG_ENDIAN
+BSD :release:
+BSD_COMPAT :source:
+BSD_TYPES :source:
+CDECL
+CI
+CLASSIFY_TYPE
+COMPACT :architecture:
+COMPILER_VER
+CRAY :machine:
+CRAY1 :machine:
+CRAY2 :machine:
+DATAGENERAL :machine:
+DGUX :release:
+DLL
+DMERT :release:
+DYNAMIC :dialect:
+EXTENSIONS :dialect:
+FreeBSD :release:
+GNUC :dialect:vendor:
+GNUC_MINOR
+GNUG :dialect:vendor:
+HFS :vendor:
+HIGHC
+HOST_MIPS
+HPUX_SOURCE :source:
+HUGE :architecture:
+IBMR2 :architecture:
+ISIS
+LANGUAGE_C :dialect:
+LANGUAGE_CPLUS :dialect:
+LANGUAGE_C_PLUS_PLUS :dialect:
+LARGE :architecture:
+LARGE_M
+LATTICE :vendor:
+LONGLONG :dialect:
+LONG_LONG :dialect:
+M68010 :machine:
+M68020 :machine:
+MACH :release:
+MEDIUM :architecture:
+MIPSEB
+MIPSEL
+MIPS_FPSET
+MIPS_ISA
+MIPS_ISA_MIPS1
+MIPS_ISA_MIPS2
+MIPS_SIM
+MIPS_SIM_ABI16
+MIPS_SIM_ABI32
+MIPS_SZINT
+MIPS_SZLONG
+MIPS_SZPTR
+MODERN_C :dialect:
+MOXIE :release:
+MSC_VER :release:
+MSDOS :system:
+MSNT :system:
+MVS :architecture:
+M_ALPHA :architecture:
+M_BITFIELDS
+M_I186 :architecture:
+M_I286 :architecture:
+M_I386 :architecture:
+M_I8086 :architecture:
+M_I86 :architecture:
+M_I86LM
+M_I86MM
+M_I86SM
+M_IX86 :architecture:
+M_LDATA
+M_LTEXT
+M_MRX000 :architecture:
+M_PPC :architecture:
+M_SDATA
+M_STEXT
+M_SYS3
+M_SYS5
+M_SYSIII
+M_SYSV
+M_WDSWAP
+M_XENIX
+NATURAL_ALIGNMENT
+NEXT :release:
+NeXT :release:
+ON_SEL
+OSK
+OVERLAY
+PASCAL
+PDP11 :architecture:
+POSIX
+POSIX2_SOURCE :source:
+POSIX_C_SOURCE :source:
+POSIX_SOURCE :source:
+POWER :architecture:
+PTRDIFF_TYPE
+PWB
+RES
+RT
+SGI_MP_SOURCE :source:
+SGI_REENTRANT_FUNCTIONS :dialect:
+SGI_SOURCE :source:
+SIZE_TYPE
+SMALL :architecture:
+SMALL_M
+STDC_HOSTED
+STDC_IEC_559
+STDC_IEC_559_COMPLEX
+STDC_ISO_10646
+STDC_VERSION
+STD_INCLUDE_DIR
+SVR3
+SVR4
+SVR4_SOURCE :source:
+SYSTYPE_BSD
+SYSTYPE_SVR4
+SYSTYPE_SYSV
+TARGET_LIB
+TINY :architecture:
+TM_DPS6
+TM_L66
+TS
+TS_GCOS
+TS_MOD400
+TURBOC
+UTS :release:
+UWIN :release:
+V9 :release:
+VAX :architecture:
+VAX11C :vendor:
+VAXC :vendor:
+VMS :system:
+WCHAR_TYPE
+WIN32 :release:
+X86 :architecture:
+XOPEN_SOURCE :source:
+XPG2 :source:
+XPG3 :source:
+XPG4 :source:
+_50SERIES
+alliant :machine:
+aosvs :release:
+apollo :machine:
+c_plusplus :dialect:
+cpc :machine:
+cplusplus :dialect:
+cpm :system:
+cpm68k :machine:
+cpm80 :machine:
+cpm86 :machine:
+cray :machine:
+datageneral :machine:
+decus
+dgux :release:
+dmert :release:
+fpcc
+ftx
+gcos :release:
+gimpel :release:
+gnu
+gould :machine:
+hobbit :architecture:
+host_mips
+hp9000s200 :architecture:
+hp9000s300 :architecture:
+hp9000s500 :architecture:
+hp9000s700 :architecture:
+hp9000s800 :architecture:
+hppa :architecture:machine:
+hpux :release:
+i286 :architecture:
+i386 :architecture:
+i80186 :architecture:
+i80286 :architecture:
+i8080 :architecture:
+i8086 :architecture:
+i860 :architecture:
+iAPX286 :architecture:
+iAPX386 :architecture:
+ibm :architecture:
+ibm032 :architecture:
+interdata :architecture:
+kl10
+linux :release:
+m68000 :architecture:
+m68k :architecture:
+m88000 :architecture:
+m88k :architecture:
+mbb
+mc300 :architecture:
+mc500 :architecture:
+mc68000 :architecture:
+mc68008 :architecture:
+mc68010 :architecture:
+mc68020 :architecture:
+mc68k32 :architecture:
+mc700 :architecture:
+mert :release:
+mips :architecture:
+mpm
+msdos :system:
+n16 :architecture:
+n32032 :architecture:
+n32332 :architecture:
+news800
+nomacarg
+nonstopux :system:
+ns1600 :architecture:
+ns16000 :architecture:
+ns32000 :architecture:
+orion :release:
+os :release:
+pcdos :system:
+pdp11 :architecture:
+ppc :architecture:
+pyr :architecture:
+rsx :release:
+sel :architecture:
+selport
+sequent :machine:
+sequoia :machine:
+sparc :architecture:
+spectrum :machine:
+sun :machine:
+sun2 :machine:
+sun3 :machine:
+svr4 :release:
+tahoe :architecture:
+topix :release:
+tops20 :machine:
+tss :system:
+u370 :architecture:
+u3b :architecture:
+u3b15 :architecture:
+u3b2 :architecture:
+u3b20 :architecture:
+u3b200 :architecture:
+u3b20d :architecture:
+u3b4000 :architecture:
+u3b5 :architecture:
+univac :machine:
+unix :system:
+unixpc :machine:
+uts :release:
+vax :architecture:
+vax11c :vendor:
+vaxc :vendor:
+vms :system:
+xinu :release:
+z80 :architecture:
+z800 :architecture:
+z8000 :architecture:
diff --git a/usr/src/lib/libpp/common/pp.h b/usr/src/lib/libpp/common/pp.h
new file mode 100644
index 0000000000..2b91c8e435
--- /dev/null
+++ b/usr/src/lib/libpp/common/pp.h
@@ -0,0 +1,452 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * preprocessor library public definitions
+ */
+
+#ifndef _PP_H
+#define _PP_H
+
+#ifdef ppsymbol
+/*
+ * undo old nmake cpp name-space intrusion
+ * this disables __LINE__, __FILE__, __DATE__ and __TIME__
+ */
+#undef ppsymbol
+#undef __LINE__
+#define __LINE__ 0
+#undef __FILE__
+#define __FILE__ "libpp"
+#undef __DATE__
+#define __DATE__ "MMM DD YYYY"
+#undef __TIME__
+#define __TIME__ "HH:MM:SS"
+#endif
+
+
+#if PROTOMAIN
+#define HASH_HEADER int hash_header
+#define Hash_table_t char
+#define Sfio_t char
+#define CC_bel (('A'==0301)?0057:0007)
+#define CC_esc (('A'==0301)?0047:0033)
+#define CC_vt 0013
+#else
+#include <limits.h>
+#include <hash.h>
+#include <error.h>
+#include <ccode.h>
+#endif
+
+#define PPDEFAULT "pp_default.h" /* runtime definitions */
+#define PPPROBE "cc" /* default probe key */
+#define PPSTANDARD "/usr/include" /* standard include dir */
+
+#define PPBLKSIZ 1024 /* unit block size */
+#define PPBAKSIZ (1*PPBLKSIZ) /* input pushback size */
+#define PPBUFSIZ (32*PPBLKSIZ) /* io buffer size */
+#define PPTOKSIZ ((PPBUFSIZ/2)-1) /* max token size */
+
+#define PPWRITE(n) do{if(write(1,pp.outbuf,n)!=(n))pperror(ERROR_SYSTEM|3,"%s: write error",pp.outfile);pp.offset+=(n);pp.lastout=pp.outbuf[n-1];}while(0)
+
+#define pplastout() ((pp.outp>pp.outbuf)?*(pp.outp-1):pp.lastout)
+#define ppoffset() (pp.offset+pppendout())
+#define pppendout() (pp.outp-pp.outbuf)
+#define ppputchar(c) (*pp.outp++=(c))
+#define ppflushout() do{if(pp.outp>pp.outbuf){PPWRITE(pp.outp-pp.outbuf);pp.outp=pp.outbuf;}}while(0)
+#define ppcheckout() do{if(pp.outp>pp.oute){PPWRITE(PPBUFSIZ);if(pp.outbuf==pp.outb){pp.outbuf+=PPBUFSIZ;pp.oute+=PPBUFSIZ;}else{pp.outbuf-=PPBUFSIZ;memcpy(pp.outbuf,pp.oute,pp.outp-pp.oute);pp.oute-=PPBUFSIZ;pp.outp-=2*PPBUFSIZ;}}}while(0)
+
+#define ppsymget(t,n) (struct ppsymbol*)hashlook(t,n,HASH_LOOKUP,NiL)
+#define ppsymref(t,n) (struct ppsymbol*)hashlook(t,n,pp.truncate?HASH_LOOKUP:HASH_LOOKUP|HASH_INTERNAL,NiL)
+#define ppsymset(t,n) (struct ppsymbol*)hashlook(t,n,HASH_CREATE|HASH_SIZE(sizeof(struct ppsymbol)),NiL)
+
+#if CHAR_MIN < 0
+#define pptype (ppctype-(CHAR_MIN)+1)
+#else
+#define pptype (ppctype)
+#endif
+
+#define C_ID (1<<0)
+#define C_DIG (1<<1)
+#define C_SPLICE (1<<2)
+
+#define ppisdig(c) ((pptype)[c]&C_DIG)
+#define ppisid(c) ((pptype)[c]&C_ID)
+#define ppisidig(c) ((pptype)[c]&(C_ID|C_DIG))
+#define ppismac(c) ((pptype)[c]&(C_ID|C_DIG|C_SPLICE))
+#define ppissplice(c) ((pptype)[c]&C_SPLICE)
+
+#define setid(c) ((pptype)[c]|=C_ID)
+#define clrid(c) ((pptype)[c]&=~C_ID)
+#define setdig(c) ((pptype)[c]|=C_DIG)
+#define setsplice(c) ((pptype)[c]|=C_SPLICE)
+
+#define REF_CREATE (REF_NORMAL+1) /* include wrapper (internal) */
+#define REF_DELETE (REF_NORMAL+2) /* macro definition (internal) */
+#define REF_NORMAL 0 /* normal macro reference */
+#define REF_IF (-1) /* if, ifdef, ifndef, elif */
+#define REF_UNDEF (-2) /* undef */
+
+#define SYM_ACTIVE (1L<<0) /* active macro lock */
+#define SYM_BUILTIN (1L<<1) /* builtin macro */
+#define SYM_DISABLED (1L<<2) /* macro expansion disabled */
+#define SYM_EMPTY (1L<<3) /* allow empty/missing actuals */
+#define SYM_FINAL (1L<<4) /* final hosted value */
+#define SYM_FUNCTION (1L<<5) /* macro with args */
+#define SYM_INIT (1L<<6) /* initialization macro */
+#define SYM_INITIAL (1L<<7) /* initial hosted value */
+#define SYM_KEYWORD (1L<<8) /* keyword identifier */
+#define SYM_LEX (1L<<9) /* ppsymkey with lex field */
+#define SYM_MULTILINE (1L<<10) /* multi-line macro */
+#define SYM_NOEXPAND (1L<<11) /* no identifiers in macro body */
+#define SYM_NOTICED (1L<<12) /* symbol noticed in output */
+#define SYM_PREDEFINED (1L<<13) /* predefined macro */
+#define SYM_PREDICATE (1L<<14) /* also a predicate */
+#define SYM_READONLY (1L<<15) /* readonly macro */
+#define SYM_REDEFINE (1L<<16) /* ok to redefine */
+#define SYM_VARIADIC (1L<<17) /* variadic macro with args */
+#define SYM_UNUSED 24 /* first unused symbol flag bit */
+
+#define PP_ASSERT 1 /* preassert symbol */
+#define PP_BUILTIN 2 /* #(<id>) handler */
+#define PP_CDIR 3 /* C (vs. C++) file dirs follow */
+#define PP_CHOP 4 /* include prefix chop */
+#define PP_COMMENT 5 /* passed comment handler */
+#define PP_COMPATIBILITY 6 /* old (Reiser) dialect */
+#define PP_COMPILE 7 /* tokenize for front end */
+#define PP_DEBUG 8 /* set debug trace level */
+#define PP_DEFINE 9 /* predefine symbol */
+#define PP_DEFAULT 10 /* read default include files */
+#define PP_DIRECTIVE 11 /* initialization directive */
+#define PP_DONE 12 /* all processing done */
+#define PP_DUMP 13 /* do checkpoint dump */
+#define PP_FILEDEPS 14 /* output file dependencies */
+#define PP_FILENAME 15 /* set input file name */
+#define PP_HOSTDIR 16 /* hosted file dirs follow */
+#define PP_ID 17 /* add to identifier set */
+#define PP_IGNORE 18 /* ignore this include file */
+#define PP_IGNORELIST 19 /* include ignore list file */
+#define PP_INCLUDE 20 /* add dir to include search */
+#define PP_INCREF 21 /* include file push/ret handler*/
+#define PP_INIT 22 /* one time initialization */
+#define PP_INPUT 23 /* set input source file */
+#define PP_KEYARGS 24 /* name=value macro args */
+#define PP_LINE 25 /* line sync handler */
+#define PP_LINEBASE 26 /* base name in line sync */
+#define PP_LINEFILE 27 /* line sync requires file arg */
+#define PP_LINEID 28 /* PP_LINE directive id */
+#define PP_LINETYPE 29 /* # extra line sync type args */
+#define PP_LOCAL 30 /* previous PP_INCLUDE for "" */
+#define PP_MACREF 31 /* macro def/ref handler */
+#define PP_MULTIPLE 32 /* set all files multiple */
+#define PP_NOHASH 33 /* don't hash PP_COMPILE T_ID's */
+#define PP_NOISE 34 /* convert T_X_* to T_NOISE */
+#define PP_OPTION 35 /* set pragma option */
+#define PP_OPTARG 36 /* unknown option arg handler */
+#define PP_OUTPUT 37 /* set output file sink */
+#define PP_PASSTHROUGH 38 /* ppcpp() expands # lines only */
+#define PP_PEDANTIC 39 /* pedantic non-hosted warnings */
+#define PP_PLUSCOMMENT 40 /* enable C++ comments */
+#define PP_PLUSPLUS 41 /* tokenize for C++ */
+#define PP_POOL 42 /* pool for multiple io passes */
+#define PP_PRAGMA 43 /* passed pragma handler */
+#define PP_PRAGMAFLAGS 44 /* global pragma flags */
+#define PP_PROBE 45 /* ppdefault probe key */
+#define PP_QUOTE 46 /* add to quote set */
+#define PP_READ 47 /* include file without output */
+#define PP_REGUARD 48 /* file pop emits guard define */
+#define PP_RESERVED 49 /* COMPILE reserved keyword */
+#define PP_RESET 50 /* reset to initiali predefs */
+#define PP_SPACEOUT 51 /* pplex returns space,newline */
+#define PP_STANDALONE 52 /* standalone preprocessor */
+#define PP_STANDARD 53 /* standard include dir */
+#define PP_STRICT 54 /* strict implementation */
+#define PP_TEST 55 /* enable (undocumented) tests */
+#define PP_TEXT 56 /* include file with output */
+#define PP_TRANSITION 57 /* on COMPATIBILITY boundary */
+#define PP_TRUNCATE 58 /* truncate macro names */
+#define PP_UNDEF 59 /* undef symbol after ppdefault */
+#define PP_VENDOR 60 /* vendor file dirs follow */
+#define PP_WARN 61 /* enable annoying warnings */
+
+#define PP_comment (1<<0) /* PP_COMMENT is set */
+#define PP_compatibility (1<<1) /* PP_COMPATIBILITY is set */
+#define PP_hosted (1<<2) /* current file is hosted */
+#define PP_linebase (1<<3) /* base name in line sync */
+#define PP_linefile (1<<4) /* line sync file arg required */
+#define PP_linehosted (1<<5) /* line sync hosted arg required*/
+#define PP_lineignore (1<<6) /* line sync for ignored file */
+#define PP_linetype (1<<7) /* line sync type arg required */
+#define PP_strict (1<<8) /* PP_STRICT is set */
+#define PP_transition (1<<9) /* PP_TRANSITION is set */
+
+#define PP_deps (1<<0) /* generate header deps */
+#define PP_deps_file (1<<1) /* write deps to separate file */
+#define PP_deps_generated (1<<2) /* missing deps are generated */
+#define PP_deps_local (1<<3) /* only local header deps */
+
+#define PP_sync 0 /* normal line sync */
+#define PP_sync_push '1' /* [3] include file push */
+#define PP_sync_pop '2' /* [3] include file pop */
+#define PP_sync_ignore '3' /* [3] ignored include file */
+#define PP_sync_hosted '3' /* [4] hosted include file */
+
+#define PP_SYNC_PUSH (1<<0) /* pp.incref PP_sync_push type */
+#define PP_SYNC_POP (1<<1) /* pp.incref PP_sync_pop type */
+#define PP_SYNC_IGNORE (1<<2) /* pp.incref PP_sync_ignore type*/
+#define PP_SYNC_HOSTED (1<<3) /* pp.incref PP_sync_hosted type*/
+#define PP_SYNC_INSERT (1<<4) /* pinserted by other means */
+
+/*
+ * numeric modifiers
+ *
+ * NOTE: 0400 is claimed by error in yacc
+ * (N_PP+30) is the largest valid pp token
+ * free tokens start at T_TOKEN
+ */
+
+#define N_PP 0401 /* pp tokens 0401..0437 */
+#define N_NUMBER 0440 /* numbers 0440..0477 */
+#define N_TEST (N_NUMBER|07700)/* number test mask */
+#define N_TOKEN 0500 /* free 0500..07777 */
+#define N_WIDE 1 /* wide quoted constant */
+
+/*
+ * NOTE: preserve the token ranges and encodings for is*(x)
+ */
+
+#define ppisnumber(x) (((x)&N_TEST)==N_NUMBER)
+#define ppisinteger(x) (((x)&(N_TEST|N_REAL))==N_NUMBER)
+#define ppisreal(x) (((x)&(N_TEST|N_REAL))==(N_NUMBER|N_REAL))
+#define ppisassignop(x) (((x)>=T_MPYEQ)&&((x)<=T_OREQ))
+#define ppisseparate(x) (((x)>=N_PP)&&((x)<=T_WSTRING)||((x)>=N_NUMBER)||((x)=='+')||((x)=='-'))
+
+#define N_LONG 0001
+#define N_UNSIGNED 0002 /* if ppisinteger(x) */
+#define N_FLOAT 0002 /* if ppisreal(x) */
+
+#define N_REAL 0004
+#define N_OCTAL 0010
+#define N_HEXADECIMAL 0020
+
+#define N_EXPONENT 010000 /* for lexing only */
+#define N_SIGN 020000 /* for lexing only */
+#define N_TRAILING 040000 /* for lexing only */
+
+#if !defined(T_DOUBLE)
+
+/*
+ * numeric constants
+ */
+
+#define T_DOUBLE (N_NUMBER|N_REAL)
+#define T_DOUBLE_L (N_NUMBER|N_REAL|N_LONG)
+#define T_FLOAT (N_NUMBER|N_REAL|N_FLOAT)
+#define T_DECIMAL (N_NUMBER)
+#define T_DECIMAL_L (N_NUMBER|N_LONG)
+#define T_DECIMAL_U (N_NUMBER|N_UNSIGNED)
+#define T_DECIMAL_UL (N_NUMBER|N_UNSIGNED|N_LONG)
+#define T_OCTAL (N_NUMBER|N_OCTAL)
+#define T_OCTAL_L (N_NUMBER|N_OCTAL|N_LONG)
+#define T_OCTAL_U (N_NUMBER|N_OCTAL|N_UNSIGNED)
+#define T_OCTAL_UL (N_NUMBER|N_OCTAL|N_UNSIGNED|N_LONG)
+#define T_HEXADECIMAL (N_NUMBER|N_HEXADECIMAL)
+#define T_HEXADECIMAL_L (N_NUMBER|N_HEXADECIMAL|N_LONG)
+#define T_HEXADECIMAL_U (N_NUMBER|N_HEXADECIMAL|N_UNSIGNED)
+#define T_HEXADECIMAL_UL (N_NUMBER|N_HEXADECIMAL|N_UNSIGNED|N_LONG)
+#define T_HEXDOUBLE (N_NUMBER|N_HEXADECIMAL|N_REAL)
+#define T_HEXDOUBLE_L (N_NUMBER|N_HEXADECIMAL|N_REAL|N_LONG)
+
+/*
+ * identifier and invalid token
+ */
+
+#define T_ID (N_PP+0)
+#define T_INVALID (N_PP+1)
+
+/*
+ * quoted constants
+ */
+
+#define T_HEADER (N_PP+2) /* <..> */
+#define T_CHARCONST (N_PP+3) /* '..' */
+#define T_WCHARCONST (T_CHARCONST|N_WIDE) /* L'..' */
+#define T_STRING (N_PP+5) /* ".." */
+#define T_WSTRING (T_STRING|N_WIDE) /* L".." */
+
+/*
+ * multichar operators
+ */
+
+#define T_PTRMEM (N_PP+7) /* -> */
+#define T_ADDADD (N_PP+8) /* ++ */
+#define T_SUBSUB (N_PP+9) /* -- */
+#define T_LSHIFT (N_PP+10) /* << */
+#define T_RSHIFT (N_PP+11) /* >> */
+#define T_LE (N_PP+12) /* <= */
+#define T_GE (N_PP+13) /* >= */
+#define T_EQ (N_PP+14) /* == */
+#define T_NE (N_PP+15) /* != */
+#define T_ANDAND (N_PP+16) /* && */
+#define T_OROR (N_PP+17) /* || */
+#define T_MPYEQ (N_PP+18) /* *= */
+#define T_DIVEQ (N_PP+19) /* /= */
+#define T_MODEQ (N_PP+20) /* %= */
+#define T_ADDEQ (N_PP+21) /* += */
+#define T_SUBEQ (N_PP+22) /* -= */
+#define T_LSHIFTEQ (N_PP+23) /* <<= */
+#define T_RSHIFTEQ (N_PP+24) /* >>= */
+#define T_ANDEQ (N_PP+25) /* &= */
+#define T_XOREQ (N_PP+26) /* ^= */
+#define T_OREQ (N_PP+27) /* |= */
+#define T_TOKCAT (N_PP+28) /* ## */
+#define T_VARIADIC (N_PP+29) /* ... */
+
+/*
+ * C++ tokens
+ */
+
+#define T_DOTREF (N_TOKEN+0) /* .* */
+#define T_PTRMEMREF (N_TOKEN+1) /* ->* */
+#define T_SCOPE (N_TOKEN+2) /* :: */
+
+/*
+ * compiler tokens
+ */
+
+#define T_UMINUS (N_TOKEN+3)
+
+#endif
+
+/*
+ * start of free tokens
+ */
+
+#define T_TOKEN (N_TOKEN+4)
+
+struct ppdirs /* directory list */
+{
+ char* name; /* directory name */
+ struct ppdirs* next; /* next in list */
+
+#ifdef _PP_DIRS_PRIVATE_
+ _PP_DIRS_PRIVATE_
+#endif
+
+};
+
+struct ppkeyword /* pp keyword info */
+{
+ char* name; /* keyword name */
+ int value; /* keyword token value */
+};
+
+struct ppmacro /* pp macro info */
+{
+ int arity; /* # formal arguments */
+ char* value; /* definition value */
+
+#ifdef _PP_MACRO_PRIVATE_
+ _PP_MACRO_PRIVATE_
+#endif
+
+};
+
+struct ppsymbol /* pp symbol info */
+{
+ HASH_HEADER; /* hash stuff and symbol name */
+ unsigned long flags; /* SYM_* status */
+ struct ppmacro* macro; /* macro info */
+ void* value; /* value (for other passes) */
+
+#ifdef _PP_SYMBOL_PRIVATE_
+ _PP_SYMBOL_PRIVATE_
+#endif
+
+};
+
+#define _PP_CONTEXT_BASE_ ((char*)&pp.lcldirs)
+
+#define _PP_CONTEXT_PUBLIC_ \
+ struct ppdirs* lcldirs; /* the "..." dir list */ \
+ struct ppdirs* stddirs; /* next is the <...> dir list */ \
+ int flags; /* PP_[a-z]* flags */ \
+ Hash_table_t* symtab; /* macro and id hash table */
+
+struct ppglobals /* globals accessed by pp.* */
+{
+ const char* version; /* version stamp */
+ char* lineid; /* line sync directive id */
+ char* outfile; /* output file name */
+ char* pass; /* pass name */
+ char* token; /* pplex() token name */
+ struct ppsymbol* symbol; /* last symbol if PP_COMPILE */
+
+ /* exposed for the output macros */
+
+ char* outb; /* output buffer base */
+ char* outbuf; /* output buffer */
+ char* outp; /* outbuf pointer */
+ char* oute; /* outbuf end */
+ unsigned long offset; /* output offset */
+
+#ifdef _PP_CONTEXT_PUBLIC_
+ _PP_CONTEXT_PUBLIC_ /* public context */
+#endif
+
+#ifdef _PP_CONTEXT_PRIVATE_
+ _PP_CONTEXT_PRIVATE_ /* library private context */
+#endif
+
+#ifdef _PP_GLOBALS_PRIVATE_
+ _PP_GLOBALS_PRIVATE_ /* library private additions */
+#endif
+
+};
+
+/*
+ * library interface globals
+ */
+
+#define ppctype _pp_ctype
+
+extern struct ppglobals pp;
+extern char ppctype[];
+
+extern int ppargs(char**, int);
+extern void ppcpp(void);
+extern void ppcomment(char*, char*, char*, int);
+extern void* ppcontext(void*, int);
+extern void pperror(int, ...);
+extern void ppincref(char*, char*, int, int);
+extern void ppinput(char*, char*, int);
+extern int pplex(void);
+extern void ppline(int, char*);
+extern void ppmacref(struct ppsymbol*, char*, int, int, unsigned long);
+extern void ppop(int, ...);
+extern void pppragma(char*, char*, char*, char*, int);
+extern int ppprintf(char*, ...);
+extern int ppsync(void);
+
+#endif
diff --git a/usr/src/lib/libpp/common/pp.key b/usr/src/lib/libpp/common/pp.key
new file mode 100644
index 0000000000..36de339f36
--- /dev/null
+++ b/usr/src/lib/libpp/common/pp.key
@@ -0,0 +1,117 @@
+#
+# list of known non-classic keywords
+#
+# @(#)pp.key (AT&T Labs Research) 2000-05-09
+#
+# keyword type alternate comment
+#
+# . either T_<keyword> or T_NOISE
+# GROUP balanced (), optional {} group
+# LINE upto newline
+# STATEMENT upto ;
+# [pre][.[suf]] [pre]<keyword>[suf]
+#
+
+_Bool . . c9x
+_Complex . . c9x
+_Imaginary . . c9x
+__alignof GROUP .__ gnu
+__attribute GROUP .__ gnu
+__extension GROUP .__ gnu
+__null . .__ gnu
+asm GROUP _,__,__.__ common
+const . __,__.__ ansi
+entry . . ancient
+enum . . pcc,ansi
+fortran . _ ancient
+inline . __,__.__ c9x
+int8 . _,__,__.__ common
+int16 . _,__,__.__ common
+int32 . _,__,__.__ common
+int64 . _,__,__.__ common
+restrict . __,__.__ c9x
+signed . __,__.__ ansi
+typeof GROUP __,__.__ gnu
+void . . pcc,ansi
+volatile . __,__.__ ansi
+
+# new C++ keywords -- is any identifier safe?
+
+and . . C++ (no left_parenthesis?)
+and_eq . . C++
+bitand . . C++
+bitor . . C++
+bool . . C++
+catch . . C++
+compl . . C++
+const_cast . . C++
+dynamic_cast . . C++
+explicit . . C++
+false . . C++
+mutable . . C++
+namespace . . C++
+not . . C++
+not_eq . . C++
+or . . C++
+or_eq . . C++
+protected . . C++
+reinterpret_cast . . C++
+static_cast . . C++
+template . . C++
+throw . . C++
+true . . C++
+try . . C++
+typeid . . C++
+using . . C++
+wchar_t . _,__ C++ ughlee and strange
+xor . . C++
+xor_eq . . C++
+
+# these are typically found in pc compilers, but may be in cross compilers
+
+based GROUP _,__ microsoft
+cdecl . _,__ microsoft
+declspec GROUP _,__ microsoft
+except . _,__ microsoft
+export . _,__ microsoft
+far . _,__ microsoft
+fastcall . _,__ microsoft
+finally . _,__ microsoft
+huge . _,__ microsoft
+interrupt . _,__ microsoft
+leave . _,__ microsoft
+loadds . _,__ microsoft
+near . _,__ microsoft
+novtordisp . _,__ microsoft
+oldcall . _,__ microsoft
+pascal . _,__ microsoft
+saveregs . _,__ microsoft
+segment . _,__ microsoft
+segname . _,__ microsoft
+self . _,__ microsoft
+stdcall . _,__ microsoft
+syscall . _,__ microsoft
+try . _,__ microsoft
+
+cs . _,__ turbo
+ds . _,__ turbo
+es . _,__ turbo
+regparam . _,__ turbo
+seg . _,__ turbo
+ss . _,__ turbo
+
+# these must have been a vms edict
+
+align . _,__,__.__ dec
+f_float . _,__,__.__ dec
+g_float . _,__,__.__ dec
+globaldef . _,__,__.__ dec
+globalref . _,__,__.__ dec
+globalvalue . _,__,__.__ dec
+noshare . _,__,__.__ dec
+readonly . _,__,__.__ dec
+s_float . _,__,__.__ dec
+t_float . _,__,__.__ dec
+unaligned . _,__,__.__ dec
+variant_struct . _,__,__.__ dec
+variant_union . _,__,__.__ dec
diff --git a/usr/src/lib/libpp/common/pp.probe b/usr/src/lib/libpp/common/pp.probe
new file mode 100644
index 0000000000..285f23da71
--- /dev/null
+++ b/usr/src/lib/libpp/common/pp.probe
@@ -0,0 +1,1210 @@
+:
+# Glenn Fowler
+# AT&T Research
+#
+# @(#)pp.probe (AT&T Research) 2006-09-05
+#
+# C probe for libpp
+#
+# NOTE: C.probe must be included or .'d here
+#
+
+ppdef=$dir/pp.def
+ppkey=$dir/pp.key
+ppsym=$dir/ppsym
+for f in $ppdef $ppkey $ppsym
+do test -f $f || { echo "$0: $f: not found" >&4; exit 1 ;}
+done
+
+sed -e "/^#/d" -e "s/[ ].*//" < $ppdef > all.pp
+
+system=
+release=
+version=
+architecture=
+cpu=
+model=
+machine=
+
+#
+# path cleanup
+#
+
+for i in stdinclude usrinclude
+do eval o='$'$i
+ v=$o
+ case $v in
+ *//*) v=`echo $v | sed 's,///*,/,g'` ;;
+ esac
+ if (test . -ef "`pwd`")
+ then k=
+ for x in $v
+ do case $x in
+ */../*|*/..)
+ case $x in
+ /*) a=/ ;;
+ *) a= ;;
+ esac
+ IFS=/
+ set '' $x
+ IFS=$ifs
+ r=
+ for d
+ do r="$d $r"
+ done
+ p=
+ g=
+ for d in $r
+ do case $d in
+ ..) g="$g $d" ;;
+ *) case $g in
+ '') case $p in
+ '') p=$d ;;
+ *) p=$d/$p ;;
+ esac
+ ;;
+ *) set $g
+ shift
+ g=$*
+ ;;
+ esac
+ ;;
+ esac
+ done
+ case $a in
+ '') for d in $g
+ do p=$d/$p
+ done
+ ;;
+ *) p=$a$p
+ ;;
+ esac
+ case $p in
+ /) continue ;;
+ esac
+ test $x -ef $p && x=$p
+ ;;
+ esac
+ k="$k $x"
+ done
+ set '' $k
+ shift
+ v=$1
+ case $# in
+ 0) ;;
+ *) shift
+ while :
+ do case $# in
+ 0) break ;;
+ esac
+ k=
+ for d
+ do for j in $v
+ do test $d -ef $j && continue 2
+ done
+ k="$k $d"
+ done
+ set '' $k
+ case $# in
+ 1) break ;;
+ esac
+ shift
+ v="$v $1"
+ shift
+ done
+ ;;
+ esac
+ fi
+ case $v in
+ $o) ;;
+ *) eval $i='$'v ;;
+ esac
+done
+
+id="::IDENT::`date`::IDENT::"
+echo '#assert test(ok)
+#if #test(ok)
+#else
+(
+#endif' > assert.$src
+echo '#ifdef __BASE_FILE__
+int ok;
+#else
+(
+#endif' > basefile.$src
+cat > catlit1.i <<'!'
+char test[] = "te"
+"st";
+!
+cat > catlit2.i <<'!'
+char test[] = "te\
+st";
+!
+echo '#define g(a,b) a ## b
+volatile int a;
+const int g(x,y)=1;
+extern int c(int);' > compat.$src
+echo > cpp.$src
+echo "#defincl <x.h>" > defincl.$src
+echo 'int a$b;' > dollar.$src
+echo "#eject" > eject.$src
+echo "#if 0
+(
+#else if 1
+int x;
+#else
+(
+#endif" > elseif.$src
+echo "#define _CAT(a,b,c) a##b##c
+#define hdra hdrx
+#define hdr _CAT(<,hdra,.h>)
+#include hdr" > hdra.$src
+echo "#define _XAT(a,b,c) a##b##c
+#define _CAT(a,b,c) _XAT(a,b,c)
+#define hdra hdrx
+#define hdr _CAT(<,hdra,.h>)
+#include hdr" > hdrx.$src
+echo "int f(){return 0;}" > hdrx.h
+echo "#ident \"$id\"" > ident.$src
+echo "#import \"import.h\"" > import.$src
+echo "int aaa;" > import.h
+echo "#include <inc_next.h>" > inc_next.$src
+mkdir inc0 inc1
+echo "#include_next <inc_next.h>" > inc0/inc_next.h
+echo 'char s[] = "INCLUDE_NEXT";' > inc1/inc_next.h
+echo '# 1 "linefile.i"
+
+# 1 "linefile.i"
+
+int i;' > linefile1.i
+echo '# 1 "linefile.i"
+
+# 1
+
+int i;' > linefile2.i
+echo "int i = 0;" > lineid1.i
+echo '# 1 "t.c"
+int i = 0;' > lineid2.i
+echo '# 1 "t.c"
+int i = 0;' > lineid3.$src
+echo "#include <stdio.h>" > linetype.$src
+echo '#include <sys/types.h>
+main()
+{
+ return sizeof(LONGLONG) != 8;
+}' > longlong.$src
+echo '#include "once.h"
+#include "once.h"' > once.$src
+echo '#ifdef once
+allmultiple
+#else
+#define once
+#endif' > once.h
+echo "extern int a,b;int f(){return a + = b;}" > opspace.$src
+echo "int f(){return(0);} // ((" > pluscom.$src
+echo "class x {int n;} m;" > plusplus.$src
+echo > preinc.$src
+echo '// splice \
+(
+int x = 1;' > plusspl.$src
+echo "int stdc_default_value = __STDC__ ;" > stdc.$src
+echo 'char xxx[] = "abc
+(";' > span.$src
+echo '#define g(a,b) a\
+b
+int ab,xy;
+#define xy XY
+char* g(x,y);' > splice.$src
+{
+echo 'int a\ '
+echo 'b = 1;'
+} > splicesp.$src
+echo '#define g(a,b) a/**/b
+int g(x,y)=1;' > trans.$src
+echo '#define m 65
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 65
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 64
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 63
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 62
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 61
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 60
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 59
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 58
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 57
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 56
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 55
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 54
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 53
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 52
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 51
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 50
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 49
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 48
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 47
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 46
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 45
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 44
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 43
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 42
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 41
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 40
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 39
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 38
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 37
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 36
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 35
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 34
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 33
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 32
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 31
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 30
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxx 29
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxxx 28
+#define xxxxxxxxxxxxxxxxxxxxxxxxxxx 27
+#define xxxxxxxxxxxxxxxxxxxxxxxxxx 26
+#define xxxxxxxxxxxxxxxxxxxxxxxxx 25
+#define xxxxxxxxxxxxxxxxxxxxxxxx 24
+#define xxxxxxxxxxxxxxxxxxxxxxx 23
+#define xxxxxxxxxxxxxxxxxxxxxx 22
+#define xxxxxxxxxxxxxxxxxxxxx 21
+#define xxxxxxxxxxxxxxxxxxxx 20
+#define xxxxxxxxxxxxxxxxxxx 19
+#define xxxxxxxxxxxxxxxxxx 18
+#define xxxxxxxxxxxxxxxxx 17
+#define xxxxxxxxxxxxxxxx 16
+#define xxxxxxxxxxxxxxx 15
+#define xxxxxxxxxxxxxx 14
+#define xxxxxxxxxxxxx 13
+#define xxxxxxxxxxxx 12
+#define xxxxxxxxxxx 11
+#define xxxxxxxxxx 10
+#define xxxxxxxxx 9
+#define xxxxxxxx 8
+#define xxxxxxx 7
+#define xxxxxx 6
+#define xxxxx 5
+#define xxxx 4
+#define xxx 3
+#define xx 2
+#define x 1
+#if xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx != m
+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+#endif' > truncate.$src
+cat > zeof.c <<'!'
+char* foo = "az";
+!
+
+allmultiple=
+assert=
+basefile=
+compatibility=1
+defincl=
+dollar=
+eject=
+elseif=
+headerexpand=
+headerexpandall=
+hostedtransition=
+ident=
+import=
+include_next=
+linefile=
+lineid=
+linetype=
+nocatliteral=
+opspace=
+pluscom=
+plusplus=
+plussplice=
+redef=
+reguard=
+reserved=
+spaceout=
+splicecat=
+splicespace=
+strict=
+stringspan=
+transition=
+truncate=
+zeof=
+
+$cc -c assert.$src && assert=1
+
+$cc -c basefile.$src && basefile=__BASE_FILE__
+
+if $cc -E defincl.$src
+then case "`$cc -E defincl.$src | grep -c 'defincl'`" in
+ 0) defincl=1 ;;
+ esac
+fi
+
+if $cc -c catlit1.i 2>e
+then if $cc -c catlit2.i 2>f
+ then if test `wc -c < f` -gt `wc -c < e`
+ then nocatliteral=1
+ fi
+ else nocatliteral=1
+ fi
+fi
+
+$cc -c dollar.$src && dollar=1
+
+$cc -c elseif.$src && elseif=1
+
+if $cc -I. -c hdra.$src
+then headerexpandall=1
+elif $cc -I. -c hdrx.$src
+then headerexpand=1
+fi
+
+if $cc -E eject.$src
+then case "`$cc -E eject.$src | grep -c 'eject'`" in
+ 0) eject=1 ;;
+ esac
+fi
+
+$cc -S ident.$src && grep "$id" ident.s && ident=1
+
+{ $cc -E import.$src | grep aaa ;} && import=1
+
+{ $cc -E -Iinc0 -Iinc1 inc_next.$src | grep INCLUDE_NEXT ;} && include_next=1
+
+if $cc -c linefile1.i
+then $cc -c linefile2.i
+ case $? in
+ 0) ;;
+ *) linefile=1 ;;
+ esac
+fi
+
+if $cc -c lineid1.i 2>b
+then $cc -c lineid2.i 2>e
+ c=$?
+else $cc -c lineid3.c 2>e
+ c=$?
+fi
+case $c in
+0) case `wc -l < b` in
+ `wc -l < e`) ;;
+ *) lineid=line ;;
+ esac
+ ;;
+*) lineid=line
+ ;;
+esac
+
+if $cc -E linetype.$src | grep '^[ ]*#[ ]*[0123456789]*[ ]*".*"[ ]*[12]' > linetype
+then if grep '^[ ]*#[ ]*[0123456789]*[ ]*".*"[ ]*[12][ ][ ]*3' linetype
+ then linetype=2
+ else linetype=1
+ fi
+fi
+
+{ $cc -E once.$src | grep allmultiple ;} && allmultiple=1
+
+$cc -c plusplus.$src && plusplus=1
+
+$cc -c span.$src && stringspan=1
+
+$cc -c splice.$src && splicecat=1
+
+$cc -c splicesp.$src && splicespace=1
+
+exec < $ppkey
+while read keyword type alternate comment
+do case $keyword in
+ .) break ;;
+ ""|"#") continue ;;
+ esac
+ case $type in
+ ""|".") type= ;;
+ *) type="=$type" ;;
+ esac
+ for pre in '' _ __
+ do for suf in '' _ __
+ do case $suf in
+ '') sep= ;;
+ *) sep=. ;;
+ esac
+ case ,,$alternate, in
+ *,$pre$sep$suf,*)
+ key=$pre$keyword$suf
+ undef="$undef $key"
+ echo "int f(){
+ int $key = 0;
+ return $key;
+}
+#undef $key
+int g(){
+ int $key = 0;
+ return $key;
+}" > key.$src
+ $cc -c key.$src >/dev/null 2>&1 || reserved="$reserved $key$type"
+ ;;
+ esac
+ done
+ done
+done
+
+$cc -c opspace.$src && opspace=1
+
+case $plusplus in
+"") $cc -c compat.$src && compatibility=
+ $cc -c pluscom.$src && pluscom=1
+ ;;
+esac
+case $plusplus$pluscom in
+?*) $cc -c plusspl.$src || plussplice=1 ;;
+esac
+case $plusplus in
+?*) mkdir reguard
+ cd reguard
+ echo '#include "ptrone.h"
+#include "ptrdef.h"
+int main () { return gt(2,1) + gt(2.0,1.0); }' > ptr.$src
+ echo '#include "ptrone.h"
+template<class T> int gt(T a, T b) { return a > b; }' > ptrdef.$src
+ echo 'template<class T> int gt(T a, T b);' > ptrdef.h
+ echo '/* empty */' > ptrone.h
+ if $cc -E ptr.$src > x.i && $cc x.i
+ then echo '#ifndef _PTRONE_H
+#define _PTRONE_H
+static int xxx;
+#endif' > ptrone.h
+ if $cc -E ptr.$src > x.i && echo "#define _PTRONE_H" >> x.i && $cc x.i
+ then reguard=1
+ fi
+ fi
+ cd ..
+ rm -rf reguard
+ ;;
+esac
+
+stdc=`$cc -E stdc.$src | sed -e '/stdc_default_value/!d' -e 's/.*=[ ]*//' -e 's/[ ]*;.*//'`
+case $stdc in
+0) $cc -c trans.$src && transition=1 ;;
+[0123456789]*) ;;
+*) stdc= ;;
+esac
+
+truncate=`$cc -E truncate.$src | grep '^[ ]*[0123456789]'`
+$cc -c zeof.c || zeof=1
+
+echo "$predef" >> all.pp
+{
+ case $ppopt$ppenv in
+ ?*) ppcmd=cpp
+ ppdir=.
+ eval $ppenv '$'cc -Dmycpp -E '$'ppopt cpp.$src
+ ;;
+ esac
+ eval set x $probe_verbose
+ shift
+ x=
+ for o in "$@"
+ do set x `$cc $o -c cpp.$src 2>&1`
+ while :
+ do shift
+ case $# in
+ 0) break ;;
+ esac
+ case $1 in
+ *[\\/]rm)
+ ;;
+ [\\/]*) case " $x " in
+ *" $1 "*) ;;
+ *) test -x $1 && x="$x $1" ;;
+ esac
+ ;;
+ esac
+ done
+ case $x in
+ ?*) for f in $x
+ do cp $f x && chmod u+w x && strip x && f=x
+ $ppsym < $f
+ done
+ break
+ ;;
+ esac
+ done
+} 3>&- 3>&1 >/dev/null |
+ sed -e '/^ppsymbol$/d' -e '/^.$/d' -e '/^..$/d' -e '/[ABCDEFGHIJKLMNOPQRSTUVWXYZ].*[abcdefghijklmnopqrstuvwxyz]/d' -e '/[abcdefghijklmnopqrstuvwxyz].*[ABCDEFGHIJKLMNOPQRSTUVWXYZ]/d' |
+ cat - all.pp |
+ sort -u |
+ {
+ for i in 0 1 2 3 4 5
+ do echo "struct { char* name; long value; } predef[] = {" > cpp$i.$src
+ done
+ while read sym junk
+ do case $sym in
+ _*) set 0 ${sym}
+ ;;
+ *_) continue
+ ;;
+ [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*)
+ set 1 ${sym} 2 _${sym} 3 _${sym}_ 4 __${sym} 5 __${sym}__
+ ;;
+ *) continue
+ ;;
+ esac
+ while :
+ do case $# in
+ 0|1) break ;;
+ esac
+ {
+ echo "#ifdef $2"
+ echo "\"$2\" , (long) $2 -1,"
+ echo "#endif"
+ } >> cpp$1.$src
+ shift
+ shift
+ done
+ done
+ for i in 0 1 2 3 4 5
+ do echo "\"\", 0 };" >> cpp$i.$src
+ done
+ }
+preval="`for i in 0 1 2 3 4 5;do $cc -E cpp$i.$src;done | sed -e '/\".*\".*,.*,/!d' -e 's/[^\"]*\"\\([^\"]*\\)\"[ ]*,[ ]*([ ]*long[ ]*)[ ]*\\(.*\\)[ ]*-[ ]*1[ ]*,[ ]*\$/\\1 \\2 =/g'` `$cc -dM -E stdc.$src | sed -e '/[ ]*#[ ]*define/!d' -e '/\"/d' -e 's/[ ]*#[ ]*define[ ]*\\([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*\\)[ ]*\\(.*\\)/\\1 \\2 =/'`"
+
+for i in bufld namei quota reboot utsname vfs
+do echo "#include <sys/$i.h>" > t.$src
+ if $cc -E t.$src
+ then x=1
+ else x=0
+ fi
+ eval sys_$i=$x
+done
+
+case "`grep -c '__STDC__[-0 ]*[=!]=[ ]*0' $usrinclude/stdio.h 2>/dev/null`" in
+0) ;;
+*) hostedtransition=1 ;;
+esac
+
+mapinclude=
+for i in builtins
+do echo "#include <$i.h>" > t.$src
+ if $cc -E t.$src
+ then mapinclude="$mapinclude <$i.h>=\".\""
+ fi
+done
+
+#
+# the payoff
+#
+
+exec >&3
+
+case "$compatibility:$transition:$dollar" in
+::) strict=1 ;;
+esac
+case $version_stamp in
+?*) echo "/* $version_stamp" ;;
+*) echo "/* $cc" ;;
+esac
+echo "*/"
+case $plusplus:$stdc in
+1:?*) preval="$preval = __STDC__ $stdc ="
+ redef="$redef __STDC__"
+ ;;
+esac
+ppbuiltin=0
+set x $preval
+shift
+case $# in
+0) ;;
+*) echo
+ echo "#pragma pp:predefined"
+ predef=
+ while :
+ do case $# in
+ 0) break ;;
+ esac
+ m=$1
+ shift
+ case $m in
+ *'('*) i=`echo "$m" | sed 's,(.*,,'` ;;
+ *) i=$m ;;
+ esac
+ predef="$predef
+$i"
+ eval predef_$i=0
+ while :
+ do case $1 in
+ '=') break ;;
+ *) shift ;;
+ esac
+ done
+ while :
+ do case $1 in
+ '=') shift ;;
+ *) break ;;
+ esac
+ done
+ done
+ for i in $undef
+ do case " $redef " in
+ *" $i "*) ;;
+ *) eval predef_$i=3 ;;
+ esac
+ done
+ set $preval
+ while :
+ do case $# in
+ 0) break ;;
+ esac
+ m=$1
+ shift
+ case $m in
+ *'('*) i=`echo "$m" | sed 's,(.*,,'` ;;
+ *) i=$m ;;
+ esac
+ case $i in
+ '=') continue ;;
+ esac
+ v=
+ while :
+ do case $1 in
+ '=') break ;;
+ esac
+ v="$v $1"
+ shift
+ done
+ while :
+ do case $1 in
+ '=') shift ;;
+ *) break ;;
+ esac
+ done
+ case $i in
+ __LCC__)strict=2 ;;
+ _*) ;;
+ *) eval j=\$predef_$i
+ case $j in
+ 0) eval predef_$i=1
+ echo "#define $m$v"
+ case $strict in
+ 1) strict= ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+ done
+ nopredef=0
+ while :
+ do set $preval
+ while :
+ do case $# in
+ 0) break ;;
+ esac
+ m=$1
+ shift
+ case $m in
+ *'('*) i=`echo "$m" | sed 's,(.*,,'` ;;
+ *) i=$m ;;
+ esac
+ v=
+ while :
+ do case $1 in
+ '=') break ;;
+ esac
+ v="$v $1"
+ shift
+ done
+ while :
+ do case $1 in
+ '=') shift ;;
+ *) break ;;
+ esac
+ done
+ case $nopredef in
+ 2) ;;
+ *) case $v in
+ ' '*' '*)
+ nopredef=1
+ continue
+ ;;
+ ' '[0123456789]*|' '"'"*"'"*)
+ ;;
+ *) case $1 in
+ _*) ;;
+ *) nopredef=1
+ continue
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+ eval j=\$predef_$i
+ case $j in
+ 0) case $ppbuiltin in
+ 2) echo "#pragma pp:builtin"
+ ppbuiltin=1
+ ;;
+ esac
+ eval predef_$i=2
+ echo "#define $m$v"
+ ;;
+ 1) case $m in
+ $i) eval predef_$i=2
+ eval j=\$predef___${i}__
+ case $j in
+ [12]) ;;
+ *) case $ppbuiltin in
+ 2) echo "#pragma pp:builtin"
+ ppbuiltin=1
+ ;;
+ esac
+ eval predef___${i}__=2
+ echo "#define __${i}__$v"
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+ done
+ case $nopredef in
+ 2) break ;;
+ esac
+ echo "#pragma pp:nopredefined"
+ case $nopredef in
+ 0) break ;;
+ esac
+ ppbuiltin=2
+ nopredef=2
+ done
+ ;;
+esac
+case $basefile in
+?*) case $ppbuiltin in
+ 0|2) ppbuiltin=1
+ echo "#pragma pp:builtin"
+ ;;
+ esac
+ echo "#define $basefile #(BASE)"
+ ;;
+esac
+case $ppbuiltin in
+1) echo "#pragma pp:nobuiltin" ;;
+esac
+
+eval set x $probe_longlong
+shift
+x=
+for o in "$@"
+do rm -f longlong.$exe
+ if $cc -DLONGLONG="$o" -o longlong.$exe longlong.$src &&
+ ./longlong.$exe
+ then x=1
+ break
+ fi
+done
+case $x in
+'') eval set x $probe_longlong_t
+ shift
+ for o in "$@"
+ do rm -f longlong.$exe
+ if $cc -DLONGLONG="$o" -o longlong.$exe longlong.$src &&
+ ./longlong.$exe
+ then echo "#define <long long> $o"
+ break
+ fi
+ done
+ ;;
+esac
+
+echo
+for i in `echo "$predef" | sed -e 's/^__*\(.*\)_*\$/\1/' -e '/^[abcdefghijklmnopqrstuvwxyz][abcdefghijklmnopqrstuvwxyz]*[0123456789][abcdefghijklmnopqrstuvwxyz0123456789]*\$/!d'` `echo "$predef" | sed -e 's/^__*\(.*\)_*\$/\1/' -e '/^[abcdefghijklmnopqrstuvwxyz][abcdefghijklmnopqrstuvwxyz]*\$/!d'`
+do case $i in
+ *ix) ;;
+ *) architecture=$i
+ break
+ ;;
+ esac
+done
+for i in `sed -e '/^#/d' -e '/:architecture:/!d' -e 's/[ ].*//' < $ppdef`
+do eval j="\" \$predef_$i \$predef__${i} \$predef__${i}_ \$predef___${i} \$predef___${i}__ \""
+ case $j in
+ *" 2 "*)architecture=$i
+ break
+ ;;
+ esac
+done
+for i in `sed -e '/^#/d' -e '/:machine:/!d' -e 's/[ ].*//' < $ppdef`
+do eval j="\" \$predef_$i \$predef__${i} \$predef__${i}_ \$predef___${i} \$predef___${i}__ \""
+ case $j in
+ *" 2 "*)machine="$machine $i" ;;
+ esac
+done
+case $sys_bufld$sys_reboot$sys_utsname in
+1??) release=research
+ version=9
+ ;;
+01?) release=bsd
+ case $sys_quota in
+ 0) case $sys_vfs in
+ 0) version=4.1
+ ;;
+ esac
+ ;;
+ 1) case $sys_namei in
+ 0) version=4.2
+ ;;
+ 1) version=4.3
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+001) release=V
+ ;;
+esac
+for i in `sed -e '/^#/d' -e '/:release:/!d' -e 's/[ ].*//' < $ppdef`
+do eval j=\$predef_$i
+ case $j in
+ 2) release="$release $i" ;;
+ esac
+done
+for i in `sed -e '/^#/d' -e '/:system:/!d' -e 's/[ ].*//' < $ppdef`
+do eval j=\$predef_$i
+ case $j in
+ 2) system="$system $i" ;;
+ esac
+done
+case $release in
+topix) release="$release V"
+ ;;
+esac
+case $assert in
+?*) for i in $predef
+ do case $i in
+ _*|*_) ;;
+ *) for p in architecture cpu machine system
+ do echo "#if #$p($i)
+eval \"case \\\" \$$p \\\" in *\\\" $i \\\"*) ;; *) $p=\\\"$i \$$p\\\" ;; esac\"
+: avoid string literal concatenation
+#endif"
+ done
+ ;;
+ esac
+ done > t.$src
+ eval "`$cc -E t.$src`"
+ set x x $prepred
+ while :
+ do shift
+ shift
+ case $# in
+ [01]) break ;;
+ esac
+ eval "
+ case \" \$$1 \" in
+ *\" $2 \"*) ;;
+ *) $1=\"$2 \$$1\" ;;
+ esac
+ "
+ done
+ ;;
+esac
+case $system in
+"") system=unix ;;
+esac
+case $architecture in
+ibm|uts|u370) model=370
+ architecture=ibm
+ ;;
+m*68*) architecture=m68000
+ for i in $predef
+ do case $i in
+ m*68*[123456789][0123456789])
+ model=`echo $i | sed 's/.*\(..\)/\1/'`
+ break
+ ;;
+ esac
+ done
+ ;;
+u3b?*) model=`echo $architecture | sed 's/u3b//'`
+ architecture=3b
+ ;;
+u3b) case $model in
+ "") model=20 ;;
+ esac
+ architecture=3b
+ ;;
+vax[0123456789]*)
+ model=`echo $architecture | sed 's/vax//'`
+ architecture=vax
+ ;;
+hp[0123456789]*s[0123456789])
+ case $release in
+ [abcdefghijklmnopqrstuvwxyz]*.[abcdefghijklmnopqrstuvwxyz]*.*)
+ version=$release
+ release=V
+ ;;
+ esac
+ architecture="$architecture `echo $architecture | sed 's/s.*//'`"
+ ;;
+esac
+case $hosttype in
+*.*) i=`echo $hosttype | sed -e 's,.*\.,,'` ;;
+*) i=$hosttype ;;
+esac
+case $i in
+unknown);;
+?*) case " $architecture " in
+ *" $i "*) ;;
+ *) architecture="$architecture $i" ;;
+ esac
+ ;;
+esac
+case $architecture in
+"") echo "$cc: warning: architecture not determined" >&4
+ set x $machine
+ architecture=$2
+ ;;
+esac
+echo "#define #hosttype($hosttype)"
+for i in $system
+do echo "#define #system($i)"
+done
+case $release in
+"") echo "#define #release()" ;;
+*) for i in $release
+ do echo "#define #release($i)"
+ case $i in
+ V) echo "#define #release(system5)" ;; # compatibility
+ esac
+ done
+ ;;
+esac
+echo "#define #version($version)"
+case $architecture in
+"") echo "#define #architecture()" ;;
+*) for i in `echo $architecture | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
+ do echo "#define #architecture($i)"
+ done
+ ;;
+esac
+echo "#define #model($model)"
+case $machine in
+"") case $architecture:$model in
+ ?*:?*) set x $architecture; machine="$2/$model $architecture" ;;
+ *) machine=$architecture ;;
+ esac
+ ;;
+*) machine="$machine $architecture"
+ ;;
+esac
+case $machine in
+"") echo "#define #machine()" ;;
+*) j=
+ for i in `echo $machine | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
+ do case " $i " in
+ *" $j "*)
+ ;;
+ *) j="$j $i"
+ echo "#define #machine($i)"
+ ;;
+ esac
+ done
+ ;;
+esac
+for i in $cpu
+do echo "#define #cpu($i)"
+done
+echo "#define #addressing()"
+for i in $ATTRIBUTES
+do eval d=\$$i
+ n=`echo $i | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
+ echo "#define #$n($d)"
+done
+case $stdc in
+?*) echo "#define #dialect(ansi)" ;;
+esac
+case $plusplus in
+?*) echo "#define #dialect(C++)" ;;
+esac
+case $hosted in
+"") echo "#define #dialect(cross)" ;;
+esac
+case $so:$dynamic:$static in
+::) ;;
+*) echo "#define #dialect(dynamic)" ;;
+esac
+echo
+case $plusplus in
+?*) echo "#pragma pp:plusplus" ;;
+esac
+case $reserved in
+?*) echo "#pragma pp:reserved" $reserved ;;
+esac
+case $nocatliteral in
+?*) echo "#pragma pp:nocatliteral" ;;
+esac
+case $opspace in
+?*) echo "#pragma pp:opspace" ;;
+esac
+case $pluscom in
+?*) echo "#pragma pp:pluscomment" ;;
+esac
+case $plussplice in
+?*) echo "#pragma pp:plussplice" ;;
+esac
+case $reguard in
+?*) echo "#pragma pp:reguard" ;;
+esac
+case $splicecat in
+?*) echo "#pragma pp:splicecat" ;;
+esac
+case $splicespace in
+?*) echo "#pragma pp:splicespace" ;;
+esac
+case $stringspan in
+?*) echo "#pragma pp:stringspan" ;;
+esac
+case $stdc in
+"") echo "#pragma pp:compatibility"
+ ;;
+0) echo "#pragma pp:transition"
+ ;;
+1) case $strict in
+ ?*) echo "#pragma pp:strict" ;;
+ esac
+ ;;
+esac
+case $hostedtransition in
+1) echo "#pragma pp:hostedtransition" ;;
+esac
+case $stdc in
+?*) case $ppopt$ppenv in
+ "") spaceout=1
+ echo "#pragma pp:spaceout"
+ ;;
+ esac
+ ;;
+esac
+case $truncate in
+?*) echo "#pragma pp:truncate $truncate" ;;
+esac
+case $zeof in
+?*) echo "#pragma pp:zeof" ;;
+esac
+case $dollar in
+1) echo '#pragma pp:id "$"' ;;
+esac
+cdir=-I+C
+hdir=-I+H
+set x $stdinclude
+while :
+do shift
+ case $# in
+ 0) break ;;
+ esac
+ case $1 in
+ $cdir|$hdir)
+ ;;
+ -I+C) cdir=$1
+ echo "#pragma pp:nocdir"
+ ;;
+ -I-C) cdir=$1
+ echo "#pragma pp:cdir"
+ ;;
+ -I+H) hdir=$1
+ echo "#pragma pp:nohostdir"
+ ;;
+ -I-H) hdir=$1
+ echo "#pragma pp:hostdir"
+ ;;
+ -I*) ;;
+ *) echo "#pragma pp:include \"$1\""
+ ;;
+ esac
+done
+case $usrinclude in
+/usr/include)
+ ;;
+?*) echo "#pragma pp:standard \"$usrinclude\""
+ ;;
+esac
+case $plusplus in
+?*) case $usrinclude in
+ ?*) if grep plusplus $usrinclude/ctype.h >/dev/null 2>&1
+ then echo '#pragma pp:nocdir "-"'
+ fi
+ ;;
+ esac
+ ;;
+esac
+case $mapinclude in
+?*) echo "#pragma pp:mapinclude hosted$mapinclude" ;;
+esac
+case $linefile in
+?*) echo "#pragma pp:linefile" ;;
+esac
+case $lineid in
+?*) echo "#pragma pp:lineid line" ;;
+esac
+case $linetype in
+1) echo "#pragma pp:linetype" ;;
+?*) echo "#pragma pp:linetype $linetype" ;;
+esac
+case $allmultiple in
+"") echo "#pragma pp:noallmultiple" ;;
+esac
+case $defincl in
+1) echo '#pragma pp:map "/#(pragma )?defincl>/"' ;;
+esac
+case $eject in
+1) echo '#pragma pp:map "/#(pragma )?eject>/"' ;;
+esac
+case $elseif in
+1) echo "#pragma pp:elseif" ;;
+esac
+case $headerexpand in
+1) echo "#pragma pp:headerexpand" ;;
+esac
+case $headerexpandall in
+1) echo "#pragma pp:headerexpandall" ;;
+esac
+case $ident in
+1) echo '#pragma pp:map "/#(pragma )?ident>/" "/#(pragma )?/###/"' ;;
+*) echo '#pragma pp:map "/#(pragma )?ident>/"' ;;
+esac
+case $import in
+1) echo '#pragma pp:map "/#(pragma )?import>/" "/#(pragma )?import(.*)/__STDPP__IMPORT__(\2)/"
+#macdef __STDPP__IMPORT__(x)
+#pragma pp:noallmultiple
+#include x
+#pragma pp:allmultiple
+#endmac' ;;
+esac
+case $include_next in
+1) echo '#pragma pp:map "/#include_next>/" ",[^\<]*\<,#include <.../,"' ;;
+esac
+echo '#pragma pp:map "/#pragma lint:/" ",#pragma lint:(.*),##/*\1*/,u"'
+echo '#pragma pp:map "/#(pragma )?sccs>/"'
+
+case $stdc:$spaceout in
+1:) case ' '$reserved' ' in
+ *' 'asm' '*|*' 'asm=*)
+ echo "#macdef asm"
+ echo "#pragma pp:spaceout"
+ echo "#undef asm"
+ echo "asm"
+ echo "#endmac"
+ ;;
+ esac
+ ;;
+esac
+
+if $cc -E preinc.$src > preinc.out
+then for f in `sed -e 's,\\\\,/,g' -e 's,"[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz]:/,"/,g' -e '/^#[line ]*[0123456789][0123456789]*[ ][ ]*"[\\/]/!d' -e 's/^#[line ]*[0123456789][0123456789]*[ ][ ]*".*[\\/]\(.*\)".*/\1/' preinc.out | sort -u`
+ do case $f in
+ *preinc.$src*)
+ ;;
+ *) echo "#include <$f>"
+ ;;
+ esac
+ done
+fi
diff --git a/usr/src/lib/libpp/common/pp.tab b/usr/src/lib/libpp/common/pp.tab
new file mode 100644
index 0000000000..30a576d404
--- /dev/null
+++ b/usr/src/lib/libpp/common/pp.tab
@@ -0,0 +1,233 @@
+#
+# Glenn Fowler
+# AT&T Research
+#
+# @(#)pp.tab (AT&T Labs Research) 2006-05-09
+#
+# C preprocessor tables and states
+#
+# + marks extensions to the standard
+#
+
+%keywords "static struct ppkeyword directives"
+
+ define
+ elif
+ else
+ endif
+ +endmac
+ error
+ if
+ ifdef
+ ifndef
+ include
+ +let
+ line
+ +macdef
+ pragma
+ +rename
+ undef
+ +warning
+
+%keywords "static struct ppkeyword options" prefix=X_ index=optindex last=last_option
+
+ allmultiple
+ allpossible
+ builtin
+ catliteral
+ cdir
+ checkpoint
+ chop
+ compatibility
+ debug
+ elseif
+ externalize
+ final
+ hide
+ headerexpand
+ headerexpandall
+ hosted
+ hostedtransition
+ hostdir
+ id
+ ignore
+ include
+ initial
+ keyargs
+ line
+ linebase
+ linefile
+ lineid
+ linetype
+ macref
+ map
+ mapinclude
+ modern
+ multiple
+ native
+ note
+ opspace
+ passthrough
+ pedantic
+ pluscomment
+ plusplus
+ plussplice
+ pragmaflags
+ pragmaexpand
+ predefined
+ prefix
+ preserve
+ proto
+ prototyped
+ quote
+ readonly
+ reguard
+ reserved
+ spaceout
+ splicecat
+ splicespace
+ standard
+ statement
+ strict
+ stringspan
+ stringsplit
+ system_header
+ test
+ text
+ transition
+ truncate
+ vendor
+ version
+ warn
+ zeof
+
+%keywords "static struct ppkeyword predicates" prefix=X_ index=optindex
+
+ defined
+ +exists
+ +included
+ +match
+ +noticed
+ +option
+ sizeof
+ +strcmp
+
+%keywords "static struct ppkeyword readonlys" prefix=R_
+
+ defined
+
+%flags # state : coupled, high frequency
+
+ ADD # add pp.addbuf into output buffer
+ COLLECTING # collecting macro call arguments
+ COMPATIBILITY # compatibility (Reiser) dialect
+ COMPILE # tokenize for compiler
+ CONDITIONAL # processing #[el]if directive
+ DEFINITION # processing macro definition
+ DIRECTIVE # processing directive
+ DISABLE # disable macro evaluation
+ EOF2NL # pass eof as newline token
+ ESCAPE # \ -> \\ in QUOTE|SQUOTE
+ FILEPOP # 0 on IN_FILE pop - no popin
+ HEADER # processing include statement
+ HIDDEN # hidden lines encountered
+ JOINING # joining adjacent strings
+ NEWLINE # last non-space was newline
+ NOEXPAND # no macro expansions or disables
+ NOSPACE # don't pass space+ as token
+ NOTEXT # don't output text
+ NOVERTICAL # vertical space invalid
+ PASSEOF # pass EOF as 0 without pop
+ PASSTHROUGH # ppcpp expands # lines only
+ QUOTE # processing "..." token
+ SKIPCONTROL # skip until # control or EOF
+ SKIPMACRO # disable next macro
+ SPACEOUT # output spaces in STANDALONE
+ SQUOTE # processing '...' token
+ STANDALONE # output tokens on stdout
+ STRICT # strict implementation
+ STRIP # strip quotes from T_STRING and T_CHARCONST
+ SYNCLINE # output line sync soon
+ TRANSITION # on the COMPATIBILITY boundary
+ WARN # note obnoxious incompatibilities
+
+%flags # mode : coupled, low frequency
+
+ ALLMULTIPLE # all files can be included more than once
+ BUILTIN # mark macro definitions builtin
+ CATLITERAL # concatenate adjacent "..."
+ DUMP # do a checkpoint dump
+ EXPOSE # expose hidden macros
+ EXTERNALIZE # set PROTO_EXTERNALIZE
+ FILEDEPS # output file dependencies
+ GENDEPS # missings FILEDEPS are generated
+ HEADERDEPS # <...> too for FILEDEPS
+ HOSTED # hosted include file
+ HOSTEDTRANSITION # hosted include files get __STDC__=0
+ INACTIVE # inactive conditional branch
+ INIT # initialization phase
+ LOADING # loading a checkpoint file
+ MARKC # last ppsearch() file was in C language
+ MARKHOSTED # last ppsearch() file was hosted
+ MARKMACRO # mark macro to disable later
+ PEDANTIC # pedantic non-hosted non-standard warnings
+ READONLY # mark macro definitions readonly
+ RELAX # relax complaints for this directive
+
+%flags # options : uncoupled, low frequency
+
+ ALLPOSSIBLE # ignore top level conditionals
+ DEFINITIONS # output macro definitions
+ ELSEIF # #else if|ifdef|ifndef ok
+ FINAL # final hosted macro value
+ HEADEREXPAND # HEADEREXPANDALL but macro args not expanded
+ HEADEREXPANDALL # expanded < does not quote #include macros
+ IGNORELINE # ignore #line until first file arg
+ INITIAL # initial hosted macro value
+ KEEPNOTEXT # keep NOTEXT setting
+ KEYARGS # name=value macro arguments
+ MODERN # generate modern output (\a instead of \007)
+ NATIVE # report native paths
+ NOHASH # don't hash PP_COMPILE T_ID's
+ NOISE # convert T_X_* to T_NOISES
+ NOISEFILTER # filter (ignore) NOISE
+ NOPROTO # disable ppproto()
+ PLUSCOMMENT # enable C++ comments
+ PLUSPLUS # preprocess for C++
+ PLUSSPLICE # C++ // \<newline> does not splice
+ PRAGMAEXPAND # expand #pragma args
+ PREDEFINED # mark macro definitions predefined
+ PREDEFINITIONS # output predefined macro definitions
+ PREFIX # prefix include for compatibility
+ PRESERVE # preserve input layout
+ PROTOTYPED # force all input to be prototyped
+ REGUARD # emit header guard define at file pop
+ SPLICECAT # \<newline> ok for COMPATIBILITY catenation
+ SPLICESPACE # \<space>+<newline> == \<newline> for jcl
+ STRINGSPAN # <newline> in string ok
+ STRINGSPLIT # "...\\n..." => "..."\n"..."
+ TRUNCATE # truncate identifiers
+ ZEOF # ^Z anywhere in file => EOF
+
+%keywords "static struct ppkeyword variables" prefix=V_ index=optindex
+
+ _Pragma
+ +ARGC
+ +BASE
+ DATE
+ FILE
+ +FUNCTION
+ LINE
+ +PATH
+ +SOURCE
+ -STDC
+ TIME
+ +VERSION
+ -default
+ -directive
+ -empty
+ -getenv
+ -getmac
+ -getopt
+ -getprd
+ -iterate
diff --git a/usr/src/lib/libpp/common/ppargs.c b/usr/src/lib/libpp/common/ppargs.c
new file mode 100644
index 0000000000..0aaff3905e
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppargs.c
@@ -0,0 +1,603 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * common preprocessor command line argument parse
+ * called by optjoin()
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: cpp (AT&T Research) 2006-01-11 $\n]"
+USAGE_LICENSE
+"[+NAME?cpp - C language preprocessor]"
+"[+DESCRIPTION?\bcpp\b is the preprocessor for all C language dialects. It is"
+" a standalone version of the \blibpp\b(3) preprocessor library. The"
+" C dialect implemented by \bcpp\b is determined by probing \bcc\b(1)"
+" using \bprobe\b(1). The path of the emulated compiler can be changed"
+" by the \b-D-X\b command line option.]"
+"[+?If \aoutput\a is omitted then the standard output is written; if \ainput\a"
+" is also omitted then the standard input is read. NOTE: this is an"
+" ancient, non-standard, non-intuitiive file operand syntax that is"
+" required by \bcc\b(1); use shell file name expansion at your peril.]"
+"[+?\bcpp\b specific options are set by the \b-D-\b and \b-I-\b options.]"
+
+"[C:comments?Pass comments to the output. By default comments are omitted.]"
+"[D:define?Define the macro \aname\a to have \avalue\a; \b1\b is assumed if"
+" \b=\b\avalue\a is omitted. If \aname\a begins with \b:\b then it is"
+" interpreted as a \blibpp\b(3) \b#pragma pp:\b statement; if \aname\a"
+" begins with \b%\b then it is interpreted as a \blibpp\b(3) \b#\b"
+" directive statement; if \aname\a begins with \b-\b or \b+\b then it is"
+" interpreted as a \blibpp\b(3) option; \b-\b turns the option on,"
+" \b+\b turns it off. Most options have a \b#pragma\b counterpart that"
+" is listed with the option definition. Right, this is ugly, but its the"
+" only portable way to pass options through \bcc\b(1) to"
+" \bcpp\b:]:[name[=value]]]{"
+" [+-D-C, pp::compatibility?Preprocess for K&R compatibility.]"
+" [+-D-D\alevel\a, \bpp::debug\b \alevel\a?Set the debug trace level."
+" Higher levels produce more output. Levels higher than 3"
+" enabled only in \b-g\b compiled versions.]"
+" [+-D-F\aname\a?Set the main input file name to \aname\a. This only"
+" affects error message and line sync output.]"
+" [+-D-H, pp::hosted?All directories are hosted; compatibility"
+" warning messages from hosted directory headers are suppressed.]"
+" [+-D-I, pp::cdir?All directories contain C headers; used only with"
+" \b-D-+\b.]"
+" [+-D-K, pp::keyargs?Enable the non-standard \aname=value\a macro"
+" argument mode.]"
+" [+-D-L\b[\aid\a]], \bpp::lineid\b [\aid\a]]?Set the line sync directive"
+" id to \aid\a or null if omitted.]"
+" [+-D-M, pp::nomultiple?Disable multiple include detection.]"
+" [+-D-P, pp::passthrough?Enable the non-standard passthrough mode; may"
+" be useful for processing non-C input.]"
+" [+-D-Q, pp::dump?Dump macro definitions to the output so that the"
+" output may be passed through \bcpp\b again. Used for"
+" generating precompiled headers.]"
+" [+-D-R, pp::transition?Enable the transition preprocessing mode. Used"
+" for compilers that can't make up their semantics between"
+" K&R and ISO.]"
+" [+-D-S, pp::strict?Enable strict preprocessing semantics and warnings."
+" Works with any mode (compatibiliy, transition,"
+" or the default ISO).]"
+" [+-D-T\atest\a, \bpp::test\b \atest\a?Enable implementation specific"
+" test code according to \atest\a.]"
+" [+-D-W, pp::warn?Enable pedantic warnings in non-hosted files.]"
+" [+-D-X\b[\acc\a]]?Preprocess for the compiler \acc\a which must be"
+" an executable path or an executable on \b$PATH\b.]"
+" [+-D-Z, pp::pool?Enable pool mode. See \blibpp\b(3).]"
+" [+-D-d?List canonicalized \b#define\b statements for non-predefined"
+" macros in the output. ]"
+" [+-D-m?List canonicalized \b#define\b statements for all macros. All"
+" other output is disabled.]"
+" [+-D-+, pp::plusplus?Preprocess for the C++ dialect.]"
+"}"
+"[I:include?Append \adirectory\a to the list of directories searched for"
+" \b#include\b files. If \adirectory\a is \b-\b then: (1) \b-I\b"
+" directories before \b-I-\b are searched only for \"...\" include"
+" files; (2) \b-I\b directories after \b-I-\b are searched for"
+" \"...\" and <...> include files; (3) the directory \b.\b is searched"
+" only if it is explicitly specified by a \b-I\b option.]:?[directory]{"
+" [+-I-C\adirectory\a, \bpp::cdir\b \adirectory\a?Mark \adirectory\a"
+" as a C header directory. Used with \bpp:plusplus\b.]"
+" [+-I-D[\afile\a]]?Read the default \bprobe\b(1) definitions from"
+" \afile\a, or ignore the default definitions if \afile\a"
+" is omitted.]"
+" [+-I-H\adirectory\a, \bpp::hostdir\b \adirectory\a?Mark \adirectory\a"
+" as a hosted directory. Headers from hosted directories have"
+" compatibility warnings disabled.]"
+" [+-I-I\aheader\a, \bpp::ignore\b \aheader\a?Add \aheader\a to the"
+" list of ignored headers.]"
+" [+-I-M\afile\a?\afile\a contains a sequence of \aheader\a"
+" [= \"\amap\a\" ]] lines, where \aheader\a is either <\aname\a>"
+" or \"\aname\a\", and \"\amap\a\" is an explicit binding"
+" for \aheader\a. \aheader\a is ignored if = \"\amap\a\" is"
+" omitted.]"
+" [+-I-R\afile\a?Include \afile\a but do not emit text or line syncs.]"
+" [+-I-S\adirectory\a?Add \adirectory\a to the default standard include"
+" directory list.]"
+" [+-I-T\afile\a?Include \afile\a and emit text to the output file.]"
+"}"
+"[M:dependencies?Generate \bmake\b(1) dependencies. Not needed with"
+" \bnmake\b(1). \b-M\b may be followed by optional \aflags\a to change"
+" dependency output styles:]{"
+" [+D?Generate dependencies in a separate \b.d\b file. Preprocessed"
+" output is still written to \aoutput\a, or the standard output"
+" if \aoutput\a is omitted.]"
+" [+G?Generate missing dependencies too.]"
+" [+M?Only generate local header dependencies; \ahosted\a headers are"
+" omitted. Note that \ahosted\a headers are determined by"
+" \b-I-H\b and the \bpp:hosted\b and \bpp:hostdir\b pragmas;"
+" no special distiction is made between \"\" and <> \binclude\b"
+" styles.]"
+"}"
+"[P!:sync?Emit line syncs.]"
+"[U:undefine?Remove the definition for the macro \aname\a.]:[name]"
+
+"[A:assert?Enter the assertion via \b#assert\b for system V"
+" compatibility.]:[assertion]"
+"[E:preprocess?Ignored for compatibility with ancient compilers.]"
+"[H:include-reference?Emit \b#include\b file paths on the standard error,"
+" one per line, indented to show nesting.]"
+"[T?If not \bgcc\b(1) then truncate identifiers to \alength\a"
+" characters for compatibility with old AT&T (I guess only Lucent needs"
+" them now) compilers.]#?[length]"
+"[V:version?Emit the \blibpp\b(3) version.]"
+"[X:argmode?Enable \aname\a=\avalue\a macro arguments for \beasel\b(1)"
+" compatibility.]"
+"[Y:standard?Add \adirectory\a to the list searched for"
+" \b#include\b \b<...>\b files.]:[directory]"
+
+"\n"
+"\n[ input [ output ] ]\n"
+"\n"
+
+"[+SEE ALSO?\bcc\b(1), \bgcc\b(1), \blibpp\b(3)]"
+;
+
+#include "pplib.h"
+
+#include <ctype.h>
+
+/*
+ * convert lint comments to pragmas
+ */
+
+static void
+pplint(char* head, char* comment, char* tail, int line)
+{
+ NoP(line);
+ if (strmatch(comment, "(ARGSUSED|PRINTFLIKE|PROTOLIB|SCANFLIKE|VARARGS)*([0-9])|CONSTCOND|CONSTANTCOND|CONSTANTCONDITION|EMPTY|FALLTHRU|FALLTHROUGH|LINTLIBRARY|LINTED*|NOTREACHED"))
+ {
+ strncopy(pp.token, comment, MAXTOKEN);
+ ppprintf("\n#%s %s:%s\n", dirname(PRAGMA), pp.pass, pp.token);
+ ppline(error_info.line, NiL);
+ }
+}
+
+/*
+ * if last!=0 then argv[opt_info.index]==0 with return(0)
+ * else if argv[opt_info.index]==0 then return(0)
+ * otherwise argv[opt_info.index] is the first unrecognized
+ * option with return(1)
+ *
+ * use last=0 if the preprocessor is combined with other passes
+ * so that unknown options may be interpreted for those passes
+ */
+
+int
+ppargs(char** argv, int last)
+{
+ register char* s;
+ register int c;
+ register int n;
+ char* p;
+
+ /*
+ * check the args and initialize
+ */
+
+ if (!error_info.id)
+ error_info.id = "cpp";
+ for (;;)
+ {
+ for (; c = optget(argv, usage); last = 0) switch (c)
+ {
+ case 'C':
+ ppop(PP_COMMENT, ppcomment);
+ break;
+ case 'D':
+ /*
+ * this allows single arg pp option extensions
+ * without touching cc
+ * (not all cc wrappers have -W...)
+ */
+
+ switch (*(s = opt_info.arg))
+ {
+ case '-':
+ case '+':
+ n = (*s++ == '-');
+ while (c = *s++) switch (c)
+ {
+ case 'C':
+ ppop(PP_COMPATIBILITY, n);
+ break;
+ case 'D':
+ if (n && ((c = strtol(s, &p, 0)) || p != s))
+ {
+ s = p;
+ n = c;
+ }
+ ppop(PP_DEBUG, -n);
+ break;
+ case 'F':
+ ppop(PP_FILENAME, n ? s : NiL);
+ goto hasarg;
+ case 'H':
+ ppop(PP_HOSTDIR, "-", n);
+ break;
+ case 'I':
+ ppop(PP_CDIR, "-", n);
+ break;
+ case 'K':
+ ppop(PP_KEYARGS, n);
+ break;
+ case 'L':
+ ppop(PP_LINEID, n && *s ? s : "line");
+ goto hasarg;
+ case 'M':
+ ppop(PP_MULTIPLE, !n);
+ break;
+ case 'P':
+ ppop(PP_PASSTHROUGH, n);
+ break;
+ case 'Q':
+ ppop(PP_DUMP, n);
+ break;
+ case 'R':
+ ppop(PP_TRANSITION, n);
+ break;
+ case 'S':
+ ppop(PP_STRICT, n);
+ break;
+ case 'T':
+ ppop(PP_TEST, s);
+ goto hasarg;
+ case 'V':
+ ppop(PP_VENDOR, "-", n);
+ break;
+ case 'W':
+ ppop(PP_WARN, n);
+ break;
+ case 'X':
+ ppop(PP_PROBE, n && *s ? s : 0);
+ goto hasarg;
+ case 'Z':
+ ppop(PP_POOL, n);
+ break;
+ case 'd':
+ pp.option |= DEFINITIONS;
+ break;
+ case 'm':
+ pp.state |= NOTEXT;
+ pp.option |= KEEPNOTEXT|DEFINITIONS|PREDEFINITIONS;
+ pp.linesync = 0;
+ break;
+ case '+':
+ ppop(PP_PLUSPLUS, n);
+ break;
+ default:
+ if (pp.optarg)
+ {
+ if ((c = (*pp.optarg)(n, c, s)) > 0) goto hasarg;
+ else if (!c) break;
+ }
+ error(1, "%c%s: unknown -D option overload", n ? '-' : '+', s - 1);
+ goto hasarg;
+ }
+ hasarg:
+ break;
+ case ':':
+ ppop(PP_OPTION, s + 1);
+ break;
+ case '%':
+ ppop(PP_DIRECTIVE, s + 1);
+ break;
+ case '_':
+ if (strmatch(s, "__GNUC__*"))
+ pp.arg_style |= STYLE_gnu;
+ else if (strmatch(s, "__(ANSI|STDC|STRICT)__*") || !(pp.arg_style & STYLE_gnu) && strmatch(s, "__STRICT_ANSI__*"))
+ ppop(PP_STRICT, 1);
+ else if (strmatch(s, "__cplusplus*"))
+ ppop(PP_PLUSPLUS, 1);
+ /*FALLTHROUGH*/
+ default:
+ ppop(PP_DEFINE, s);
+ break;
+ }
+ break;
+ case 'E':
+ /* historically ignored */
+ break;
+ case 'I':
+ if (!(s = opt_info.arg))
+ {
+ /*
+ * some compilers interpret `-I ...' as
+ * `-I-S' and arg ... while others interpret
+ * it as `-I...'
+ */
+
+ p = "-S";
+ if ((s = argv[opt_info.index]) && ((n = *s++) == '-' || n == '+') && *s++ == 'D')
+ {
+ if (isalpha(*s) || *s == '_')
+ while (isalnum(*++s) || *s == '_');
+ if (*s && *s != '=' && *s != '-' && *s != '+')
+ p = argv[opt_info.index++];
+ }
+ s = p;
+ }
+ switch (*s)
+ {
+ case '-':
+ case '+':
+ n = *(p = s++) == '-';
+ c = *s++;
+ if (!n && !*s) s = 0;
+ switch (c)
+ {
+ case 0:
+ ppop(PP_LOCAL);
+ break;
+ case 'C':
+ ppop(PP_CDIR, s, n);
+ break;
+ case 'D':
+ ppop(PP_DEFAULT, s);
+ break;
+ case 'H':
+ ppop(PP_HOSTDIR, s, n);
+ break;
+ case 'I':
+ ppop(PP_IGNORE, s);
+ break;
+ case 'M':
+ ppop(PP_IGNORELIST, s);
+ break;
+ case 'R':
+ ppop(PP_READ, s);
+ break;
+ case 'S':
+ ppop(PP_STANDARD, s);
+ break;
+ case 'T':
+ ppop(PP_TEXT, s);
+ break;
+ case 'V':
+ ppop(PP_VENDOR, s, n);
+ break;
+ default:
+ error(1, "%s: unknown -I option overload", p);
+ break;
+ }
+ break;
+ default:
+ ppop(PP_INCLUDE, s);
+ break;
+ }
+ break;
+ case 'M':
+ for (n = PP_deps; argv[opt_info.index]; opt_info.offset++)
+ {
+ switch (argv[opt_info.index][opt_info.offset])
+ {
+ case 'D':
+ n |= PP_deps_file;
+ continue;
+ case 'G':
+ n |= PP_deps_generated;
+ continue;
+ case 'M':
+ n |= PP_deps_local;
+ continue;
+ }
+ break;
+ }
+ ppop(PP_FILEDEPS, n);
+ break;
+ case 'P':
+ ppop(PP_LINE, (PPLINESYNC)0);
+ break;
+ case 'U':
+ ppop(PP_UNDEF, opt_info.arg);
+ break;
+
+ /*
+ * System V CCS compatibility
+ */
+
+ case 'A':
+ if (isalpha(opt_info.arg[0]) || opt_info.arg[0] == '_' || opt_info.arg[0] == '$')
+ ppop(PP_ASSERT, opt_info.arg);
+ break;
+ case 'H':
+ ppop(PP_INCREF, ppincref);
+ break;
+ case 'T':
+ if (!(pp.arg_style & STYLE_gnu))
+ ppop(PP_TRUNCATE, TRUNCLENGTH);
+ /* else enable ANSI trigraphs -- default */
+ break;
+ case 'V':
+ error(0, "%s", pp.version);
+ break;
+ case 'X':
+ pp.arg_mode = (*(opt_info.arg + 1) || pp.arg_mode && pp.arg_mode != *opt_info.arg) ? '-' : *opt_info.arg;
+ break;
+ case 'Y':
+ if (*(s = opt_info.arg) && *(s + 1) == ',')
+ {
+ if (*s != 'I') break;
+ s += 2;
+ }
+ ppop(PP_STANDARD, s);
+ break;
+
+ /*
+ * errors
+ */
+
+ case '?':
+ error(ERROR_USAGE|4, "%s", opt_info.arg);
+ break;
+ case ':':
+ if (!last)
+ {
+ opt_info.again = 1;
+ return(1);
+ }
+
+ /*
+ * cross your fingers
+ */
+
+ if (!(s = argv[opt_info.index]))
+ error(3, "%s", opt_info.arg);
+ if (opt_info.offset == 2 && (pp.arg_style & STYLE_gnu))
+ {
+ p = argv[opt_info.index + 1];
+ if (streq(s, "-$"))
+ {
+ ppop(PP_OPTION, "noid \"$\"");
+ goto ignore;
+ }
+ else if (streq(s, "-dD"))
+ {
+ pp.option |= DEFINITIONS;
+ goto ignore;
+ }
+ else if (streq(s, "-dM"))
+ {
+ pp.state |= NOTEXT;
+ pp.option |= KEEPNOTEXT|DEFINITIONS|PREDEFINITIONS;
+ pp.linesync = 0;
+ goto ignore;
+ }
+ else if (streq(s, "-imacros"))
+ {
+ if (p)
+ {
+ ppop(PP_READ, p);
+ opt_info.index++;
+ opt_info.offset = 0;
+ }
+ goto ignore;
+ }
+ else if (streq(s, "-include"))
+ {
+ if (p)
+ {
+ ppop(PP_TEXT, p);
+ opt_info.index++;
+ opt_info.offset = 0;
+ }
+ opt_info.offset = 0;
+ goto ignore;
+ }
+ else if (strneq(s, "-lang-", 6))
+ {
+ s += 6;
+ if (streq(s, "c"))
+ c = 0;
+ else if (streq(s, "c++"))
+ c = 1;
+ else if (streq(s, "objc"))
+ c = 2;
+ else if (streq(s, "objc++"))
+ c = 3;
+ ppop(PP_PLUSPLUS, c & 1);
+ if (c & 2)
+ ppop(PP_DIRECTIVE, "pragma pp:map \"/#(pragma )?import>/\" \"/#(pragma )?import(.*)/__STDPP__IMPORT__(\\2)/\"\n\
+#macdef __STDPP__IMPORT__(x)\n\
+#pragma pp:noallmultiple\n\
+#include x\n\
+#pragma pp:allmultiple\n\
+#endmac");
+ goto ignore;
+ }
+ else if (streq(s, "-lint"))
+ {
+ ppop(PP_COMMENT, pplint);
+ goto ignore;
+ }
+ }
+ s += opt_info.offset - 1;
+ if (strmatch(s, "i*.h"))
+ ppop((pp.arg_style & STYLE_gnu) || s[1] == '/' ? PP_READ : PP_TEXT, s + 1);
+ else if (strmatch(s, "*@(nostandard|nostdinc)*"))
+ ppop(PP_STANDARD, "");
+ else if (strmatch(s, "*@(exten|xansi)*|std"))
+ {
+ ppop(PP_COMPATIBILITY, 0);
+ ppop(PP_TRANSITION, 1);
+ }
+ else if (strmatch(s, "*@(ansi|conform|pedantic|stand|std1|strict[!-])*"))
+ {
+ ppop(PP_COMPATIBILITY, 0);
+ ppop(PP_STRICT, 1);
+ if (strmatch(s, "*pedantic*"))
+ ppop(PP_PEDANTIC, 1);
+ }
+ else if (strmatch(s, "*@(trans)*"))
+ {
+ ppop(PP_COMPATIBILITY, 1);
+ ppop(PP_TRANSITION, 1);
+ }
+ else if (strmatch(s, "*@(classic|compat|std0|tradition|[kK][n&+][rR])*"))
+ {
+ ppop(PP_COMPATIBILITY, 1);
+ ppop(PP_TRANSITION, 0);
+ }
+ else if (strmatch(s, "*@(plusplus|++)*"))
+ ppop(PP_PLUSPLUS, 1);
+ else if (strmatch(s, "*@(warn)*"))
+ ppop(PP_WARN, 1);
+
+ /*
+ * ignore unknown options
+ * the probe info takes care of these
+ * fails if an option value is in the next arg
+ * and this is the last option
+ */
+
+ if (argv[opt_info.index + 1] && argv[opt_info.index + 1][0] != '-' && argv[opt_info.index + 2] && argv[opt_info.index + 2][0] == '-')
+ {
+ opt_info.index++;
+ opt_info.offset = 0;
+ }
+ ignore:
+ while (argv[opt_info.index][opt_info.offset]) opt_info.offset++;
+ break;
+ }
+ if (!(s = argv[opt_info.index])) return(0);
+ switch (pp.arg_file)
+ {
+ case 0:
+ if (*s != '-' || *(s + 1)) ppop(PP_INPUT, s);
+ break;
+ case 1:
+ if (*s != '-' || *(s + 1)) ppop(PP_OUTPUT, s);
+ break;
+ default:
+ if (!last) return(1);
+ error(1, "%s: extraneous argument ignored", s);
+ break;
+ }
+ pp.arg_file++;
+ if (!argv[++opt_info.index]) return(0);
+
+ /*
+ * old versions allow options after file args
+ */
+ }
+}
diff --git a/usr/src/lib/libpp/common/ppbuiltin.c b/usr/src/lib/libpp/common/ppbuiltin.c
new file mode 100644
index 0000000000..b9a906f657
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppbuiltin.c
@@ -0,0 +1,397 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * preprocessor builtin macro support
+ */
+
+#include "pplib.h"
+
+#include <times.h>
+
+/*
+ * process a #(...) builtin macro call
+ * `#(' has already been seen
+ */
+
+void
+ppbuiltin(void)
+{
+ register int c;
+ register char* p;
+ register char* a;
+
+ int n;
+ int op;
+ char* token;
+ char* t;
+ long number;
+ struct ppinstk* in;
+ struct pplist* list;
+ struct ppsymbol* sym;
+ Sfio_t* sp;
+
+ number = pp.state;
+ pp.state |= DISABLE|FILEPOP|NOSPACE;
+ token = pp.token;
+ p = pp.token = pp.tmpbuf;
+ *(a = pp.args) = 0;
+ if ((c = pplex()) != T_ID)
+ {
+ error(2, "%s: #(<identifier>...) expected", p);
+ *p = 0;
+ }
+ switch (op = (int)hashget(pp.strtab, p))
+ {
+ case V_DEFAULT:
+ n = 0;
+ p = pp.token = pp.valbuf;
+ if ((c = pplex()) == ',')
+ {
+ op = -1;
+ c = pplex();
+ }
+ pp.state &= ~NOSPACE;
+ for (;;)
+ {
+ if (!c)
+ {
+ error(2, "%s in #(...) argument", pptokchr(c));
+ break;
+ }
+ if (c == '(') n++;
+ else if (c == ')' && !n--) break;
+ else if (c == ',' && !n && op > 0) op = 0;
+ if (op) pp.token = pp.toknxt;
+ c = pplex();
+ }
+ *pp.token = 0;
+ pp.token = token;
+ pp.state = number;
+ break;
+ case V_EMPTY:
+ p = pp.valbuf;
+ if ((c = pplex()) == ')') *p = '1';
+ else
+ {
+ *p = '0';
+ n = 0;
+ for (;;)
+ {
+ if (!c)
+ {
+ error(2, "%s in #(...) argument", pptokchr(c));
+ break;
+ }
+ if (c == '(') n++;
+ else if (c == ')' && !n--) break;
+ c = pplex();
+ }
+ }
+ *(p + 1) = 0;
+ pp.token = token;
+ pp.state = number;
+ break;
+ case V_ITERATE:
+ n = 0;
+ pp.token = pp.valbuf;
+ if ((c = pplex()) != T_ID || !(sym = ppsymref(pp.symtab, pp.token)) || !sym->macro || sym->macro->arity != 1 || (c = pplex()) != ',')
+ {
+ error(2, "#(%s <macro(x)>, ...) expected", p);
+ for (;;)
+ {
+ if (!c)
+ {
+ error(2, "%s in #(...) argument", pptokchr(c));
+ break;
+ }
+ if (c == '(') n++;
+ else if (c == ')' && !n--) break;
+ c = pplex();
+ }
+ *pp.valbuf = 0;
+ }
+ else while (c != ')')
+ {
+ p = pp.token;
+ if (pp.token > pp.valbuf) *pp.token++ = ' ';
+ STRCOPY(pp.token, sym->name, a);
+ *pp.token++ = '(';
+ if (!c || !(c = pplex()))
+ {
+ pp.token = p;
+ error(2, "%s in #(...) argument", pptokchr(c));
+ break;
+ }
+ pp.state &= ~NOSPACE;
+ while (c)
+ {
+ if (c == '(') n++;
+ else if (c == ')' && !n--) break;
+ else if (c == ',' && !n) break;
+ pp.token = pp.toknxt;
+ c = pplex();
+ }
+ *pp.token++ = ')';
+ pp.state |= NOSPACE;
+ }
+ p = pp.valbuf;
+ pp.token = token;
+ pp.state = number;
+ break;
+ default:
+ pp.token = token;
+ while (c != ')')
+ {
+ if (!c)
+ {
+ error(2, "%s in #(...) argument", pptokchr(c));
+ break;
+ }
+ if ((c = pplex()) == T_ID && !*a)
+ strcpy(a, pp.token);
+ }
+ pp.state = number;
+ switch (op)
+ {
+ case V_ARGC:
+ c = -1;
+ for (in = pp.in; in; in = in->prev)
+ if ((in->type == IN_MACRO || in->type == IN_MULTILINE) && (in->symbol->flags & SYM_FUNCTION))
+ {
+ c = *((unsigned char*)(pp.macp->arg[0] - 2));
+ break;
+ }
+ sfsprintf(p = pp.valbuf, MAXTOKEN, "%d", c);
+ break;
+ case V_BASE:
+ p = (a = strrchr(error_info.file, '/')) ? a + 1 : error_info.file;
+ break;
+ case V_DATE:
+ if (!(p = pp.date))
+ {
+ time_t tm;
+
+ time(&tm);
+ a = p = ctime(&tm) + 4;
+ *(p + 20) = 0;
+ for (p += 7; *p = *(p + 9); p++);
+ pp.date = p = strdup(a);
+ }
+ break;
+ case V_FILE:
+ p = error_info.file;
+ break;
+ case V_LINE:
+ sfsprintf(p = pp.valbuf, MAXTOKEN, "%d", error_info.line);
+ break;
+ case V_PATH:
+ p = pp.path;
+ break;
+ case V_SOURCE:
+ p = error_info.file;
+ for (in = pp.in; in->prev; in = in->prev)
+ if (in->prev->type == IN_FILE && in->file)
+ p = in->file;
+ break;
+ case V_STDC:
+ p = pp.valbuf;
+ p[0] = ((pp.state & (COMPATIBILITY|TRANSITION)) || (pp.mode & (HOSTED|HOSTEDTRANSITION)) == (HOSTED|HOSTEDTRANSITION)) ? '0' : '1';
+ p[1] = 0;
+ break;
+ case V_TIME:
+ if (!(p = pp.time))
+ {
+ time_t tm;
+
+ time(&tm);
+ p = ctime(&tm) + 11;
+ *(p + 8) = 0;
+ pp.time = p = strdup(p);
+ }
+ break;
+ case V_VERSION:
+ p = (char*)pp.version;
+ break;
+ case V_DIRECTIVE:
+ pp.state |= NEWLINE;
+ pp.mode |= RELAX;
+ strcpy(p = pp.valbuf, "#");
+ break;
+ case V_GETENV:
+ if (!(p = getenv(a))) p = "";
+ break;
+ case V_GETMAC:
+ p = (sym = pprefmac(a, REF_NORMAL)) ? sym->macro->value : "";
+ break;
+ case V_GETOPT:
+ sfsprintf(p = pp.valbuf, MAXTOKEN, "%ld", ppoption(a));
+ break;
+ case V_GETPRD:
+ p = (list = (struct pplist*)hashget(pp.prdtab, a)) ? list->value : "";
+ break;
+ case V__PRAGMA:
+ if ((c = pplex()) == '(')
+ {
+ number = pp.state;
+ pp.state |= NOSPACE|STRIP;
+ c = pplex();
+ pp.state = number;
+ if (c == T_STRING || c == T_WSTRING)
+ {
+ if (!(sp = sfstropen()))
+ error(3, "temporary buffer allocation error");
+ sfprintf(sp, "#%s %s\n", dirname(PRAGMA), pp.token);
+ a = sfstruse(sp);
+ if ((c = pplex()) == ')')
+ {
+ pp.state |= NEWLINE;
+ PUSH_BUFFER(p, a, 1);
+ }
+ sfstrclose(sp);
+ }
+ }
+ if (c != ')')
+ error(2, "%s: (\"...\") expected", p);
+ return;
+ case V_FUNCTION:
+
+#define BACK(a,p) ((a>p)?*--a:(number++?0:((p=pp.outbuf+PPBUFSIZ),(a=pp.outbuf+2*PPBUFSIZ),*--a)))
+#define PEEK(a,p) ((a>p)?*(a-1):(number?0:*(pp.outbuf+2*PPBUFSIZ-1)))
+
+ number = pp.outbuf == pp.outb;
+ a = pp.outp;
+ p = pp.outb;
+ op = 0;
+ while (c = BACK(a, p))
+ {
+ if (c == '"' || c == '\'')
+ {
+ op = 0;
+ while ((n = BACK(a, p)) && n != c || PEEK(a, p) == '\\');
+ }
+ else if (c == '\n')
+ {
+ token = a;
+ while (c = BACK(a, p))
+ if (c == '\n')
+ {
+ a = token;
+ break;
+ }
+ else if (c == '#' && PEEK(a, p) == '\n')
+ break;
+ }
+ else if (c == ' ')
+ /*ignore*/;
+ else if (c == '{') /* '}' */
+ op = 1;
+ else if (op == 1)
+ {
+ if (c == ')')
+ {
+ op = 2;
+ n = 1;
+ }
+ else
+ op = 0;
+ }
+ else if (op == 2)
+ {
+ if (c == ')')
+ n++;
+ else if (c == '(' && !--n)
+ op = 3;
+ }
+ else if (op == 3)
+ {
+ if (ppisidig(c))
+ {
+ for (t = p, token = a; ppisidig(PEEK(a, p)); a--);
+ for (p = pp.valbuf + 1; a <= token; *p++ = *a++);
+ *p = 0;
+ p = pp.valbuf + 1;
+ if (streq(p, "for") || streq(p, "if") || streq(p, "switch") || streq(p, "while"))
+ {
+ op = 0;
+ p = t;
+ continue;
+ }
+ }
+ else
+ op = 0;
+ break;
+ }
+ }
+ if (op == 3)
+ strncpy(pp.funbuf, p, sizeof(pp.funbuf) - 1);
+ else if (*pp.funbuf)
+ p = pp.funbuf;
+ else
+ p = "__FUNCTION__";
+ break;
+ default:
+ if (pp.builtin && (a = (*pp.builtin)(pp.valbuf, p, a)))
+ p = a;
+ break;
+ }
+ break;
+ }
+ if (strchr(p, MARK))
+ {
+ a = pp.tmpbuf;
+ strcpy(a, p);
+ c = p != pp.valbuf;
+ p = pp.valbuf + c;
+ for (;;)
+ {
+ if (p < pp.valbuf + MAXTOKEN - 2)
+ switch (*p++ = *a++)
+ {
+ case 0:
+ break;
+ case MARK:
+ *p++ = MARK;
+ /*FALLTHROUGH*/
+ default:
+ continue;
+ }
+ break;
+ }
+ p = pp.valbuf + c;
+ }
+ if (p == pp.valbuf)
+ PUSH_STRING(p);
+ else
+ {
+ if (p == pp.valbuf + 1)
+ *pp.valbuf = '"';
+ else
+ {
+ if (strlen(p) > MAXTOKEN - 2)
+ error(1, "%-.16s: builtin value truncated", p);
+ sfsprintf(pp.valbuf, MAXTOKEN, "\"%-.*s", MAXTOKEN - 2, p);
+ }
+ PUSH_QUOTE(pp.valbuf, 1);
+ }
+}
diff --git a/usr/src/lib/libpp/common/ppcall.c b/usr/src/lib/libpp/common/ppcall.c
new file mode 100644
index 0000000000..8e273dc92f
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppcall.c
@@ -0,0 +1,452 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * preprocessor macro call
+ */
+
+#include "pplib.h"
+
+#include <ctype.h>
+
+/*
+ * call a macro by pushing its value on the input stream
+ * only the macro token itself has been consumed
+ * -1 returned if macro disabled
+ * 0 returned if tok==0 and sym->mac->value to be copied to output by caller
+ * 1 returned if value pushed on input
+ */
+
+int
+ppcall(register struct ppsymbol* sym, int tok)
+{
+ register int c;
+ register char* p;
+ register char* q;
+ register struct ppmacro* mac;
+ int n;
+ int m;
+ int ret;
+ int old_hidden;
+ int last_line;
+ long old_state;
+ char* last_file;
+ char* old_token;
+ struct ppmacstk* mp;
+ struct ppinstk* old_in;
+ struct ppinstk* kp;
+ struct pptuple* tp;
+
+ ret = -1;
+ sym->flags |= SYM_NOTICED;
+ if (mac = sym->macro)
+ {
+ count(macro);
+ if ((sym->flags & SYM_PREDICATE) && (pp.state & (CONDITIONAL|WARN)) == (CONDITIONAL|WARN))
+ error(1, "%s: macro definition overrides assertion: use #%s ...", sym->name, sym->name);
+ if (sym->flags & SYM_DISABLED)
+#if COMPATIBLE
+ if ((pp.state & (COMPATIBILITY|TRANSITION)) != COMPATIBILITY || !mac->arity)
+#endif
+ {
+ pp.mode |= MARKMACRO;
+#if COMPATIBLE
+ if ((pp.state & (COMPATIBILITY|STRICT)) == (COMPATIBILITY|STRICT))
+ error(1, "%s: macro recursion inhibited", sym->name);
+#endif
+ goto disable;
+ }
+ if ((sym->flags & SYM_PREDEFINED) && !(pp.mode & (HOSTED|INACTIVE)))
+ {
+#if COMPATIBLE
+ if (*sym->name != '_' && !(pp.state & COMPATIBILITY))
+#else
+ if (*sym->name != '_')
+#endif
+ {
+ if (pp.state & STRICT)
+ {
+ error(1, "%s: obsolete predefined symbol expansion disabled", sym->name);
+ goto disable;
+ }
+ error(1, "%s: obsolete predefined symbol expanded%s", sym->name, (pp.state & DIRECTIVE) ? "" : " outside of directive");
+ }
+ else if (!(pp.state & DIRECTIVE) && mac->value && (ppisdig(*mac->value) || *mac->value == '#'))
+ error(1, "%s: predefined symbol expanded outside of directive", sym->name);
+ }
+ debug((-5, "macro %s = %s", sym->name, mac->value));
+ if (pp.macref)
+ (*pp.macref)(sym, error_info.file, error_info.line, (pp.state & CONDITIONAL) ? REF_IF : REF_NORMAL, 0L);
+ if (tp = mac->tuple)
+ {
+ old_state = pp.state;
+ pp.state |= DEFINITION|NOSPACE;
+ old_token = pp.token;
+ n = 2 * MAXTOKEN;
+ pp.token = p = oldof(0, char, 0, n);
+ q = p + MAXTOKEN;
+ *pp.token++ = ' ';
+ old_hidden = pp.hidden;
+ while (c = pplex())
+ {
+ if (c == '\n')
+ {
+ pp.hidden++;
+ pp.state |= HIDDEN|NEWLINE;
+ old_state |= HIDDEN|NEWLINE;
+ error_info.line++;
+ }
+ else if (c == '#')
+ {
+ ungetchr(c);
+ break;
+ }
+ else
+ {
+ for (;;)
+ {
+ if (streq(pp.token, tp->token))
+ {
+ if (!(tp = tp->match))
+ break;
+ if (!tp->nomatch)
+ {
+ free(p);
+ pp.state = old_state;
+ pp.token = old_token;
+ PUSH_TUPLE(sym, tp->token);
+ ret = 1;
+ goto disable;
+ }
+ }
+ else if (!(tp = tp->nomatch))
+ break;
+ }
+ if (!tp)
+ {
+ pp.token = pp.toknxt;
+ break;
+ }
+ }
+ if ((pp.token = pp.toknxt) > q)
+ {
+ c = pp.token - p;
+ p = newof(p, char, n += MAXTOKEN, 0);
+ q = p + n - MAXTOKEN;
+ pp.token = p + c;
+ }
+ *pp.token++ = ' ';
+ }
+ if (pp.token > p && *(pp.token - 1) == ' ')
+ pp.token--;
+ if (pp.hidden != old_hidden)
+ *pp.token++ = '\n';
+ else
+ *pp.token++ = ' ';
+ *pp.token = 0;
+ pp.state = old_state;
+ pp.token = old_token;
+ if (*p)
+ PUSH_RESCAN(p);
+ else
+ free(p);
+ if (!mac->value)
+ goto disable;
+ }
+ if (sym->flags & SYM_FUNCTION)
+ {
+ /*
+ * a quick and dirty '(' peek to avoid possibly
+ * inappropriate ungetchr()'s below
+ */
+
+ for (p = pp.in->nextchr; isspace(*p); p++);
+ if ((c = *p) != '(' && c != '/' && c != 0 && c != MARK)
+ goto disable;
+ old_token = pp.token;
+ mp = pp.macp->next;
+ if ((pp.token = (char*)&mp->arg[mac->arity + 1]) > pp.maxmac)
+ error(3, "%s: too many nested function-like macros", sym->name);
+ old_hidden = pp.hidden;
+ old_state = pp.state;
+ pp.state |= DEFINITION|FILEPOP|NOSPACE;
+ while ((c = pplex()) == '\n')
+ {
+ pp.hidden++;
+ pp.state |= HIDDEN|NEWLINE;
+ old_state |= HIDDEN|NEWLINE;
+ error_info.line++;
+ }
+ if (c != '(')
+ {
+ pp.state = old_state;
+ if (c)
+ {
+ p = pp.toknxt;
+ while (p > pp.token)
+ ungetchr(*--p);
+#if COMPATIBLE
+ if ((pp.state & (COMPATIBILITY|STRICT)) == (COMPATIBILITY|STRICT))
+ error(1, "%s: macro arguments omitted", sym->name);
+#endif
+ if (c == T_ID && !(pp.state & HIDDEN))
+ ungetchr(' ');
+ }
+ if (pp.hidden != old_hidden)
+ {
+ ungetchr('\n');
+ error_info.line--;
+ if (pp.hidden && !--pp.hidden)
+ pp.state &= ~HIDDEN;
+ }
+ pp.token = old_token;
+ goto disable;
+ }
+ pp.state = old_state;
+
+ /*
+ * arg[i][-1] is an extra char for each actual i
+ * for a possible ungetchr('"') during IN_QUOTE
+ * arg[i][-1]==0 if arg i need not be expanded
+ * arg[0][-2] holds the actual arg count
+ */
+
+ c = 0;
+ m = 0;
+ n = 0;
+ mp = pp.macp->next;
+ p = pp.token = (char*)&mp->arg[mac->arity + 1];
+ pp.state |= COLLECTING|NOEXPAND;
+ pp.state &= ~FILEPOP;
+ sym->flags |= SYM_ACTIVE;
+ old_in = pp.in;
+ last_line = error_info.line;
+ last_file = error_info.file;
+ mp->line = error_info.line;
+#if MACKEYARGS
+ if (pp.option & KEYARGS)
+ {
+ for (c = 0; c < mac->arity; c++)
+ mp->arg[c] = mac->args.key[c].value + 1;
+ mp->arg[0]++;
+ }
+ else
+#endif
+ {
+ *++p = ' ';
+ mp->arg[0] = ++p;
+ }
+#if MACKEYARGS
+ keyarg:
+ if (pp.option & KEYARGS)
+ {
+ pp.state |= NOSPACE;
+ switch (pplex())
+ {
+ case T_ID:
+ break;
+ case ')': /* no actual key args */
+ if (!(pp.state & NOEXPAND))
+ pp.state |= NOEXPAND;
+ for (c = 0; c < mac->arity; c++)
+ mp->arg[c][-1] = 0;
+ c = 0;
+ goto endactuals;
+ default:
+ error(3, "%s: invalid keyword macro argument", pp.token);
+ break;
+ }
+ for (c = 0; c < mac->arity; c++)
+ if (streq(pp.token, mac->args.key[c].name)) break;
+ if (c >= mac->arity)
+ error(2, "%s: invalid macro argument keyword", pp.token);
+ if (pplex() != '=')
+ error(2, "= expected in keyword macro argument");
+ pp.state &= ~NOSPACE;
+ if (!c)
+ p++;
+ pp.token = mp->arg[c] = ++p;
+ }
+#endif
+ for (;;)
+ {
+ if ((pp.mactop = pp.token = p) >= pp.maxmac)
+ error(3, "%s: too many nested function-like macros", sym->name);
+ switch (pplex())
+ {
+ case '(':
+ n++;
+ break;
+ case ')':
+ if (!n--)
+ {
+ if (p > mp->arg[c] && *(p - 1) == ' ')
+ p--;
+ if (p > mp->arg[c] && *(p - 1) == '\\')
+ {
+ for (q = mp->arg[c]; q < p; q++)
+ if (*q == '\\')
+ q++;
+ if (q > p)
+ *p++ = '\\';
+ }
+#if MACKEYARGS
+ *p = 0;
+ m++;
+#endif
+ goto endactuals;
+ }
+ break;
+ case ',':
+ if (!n && (m++, (c < mac->arity - 1 || !(sym->flags & SYM_VARIADIC))))
+ {
+ if (p > mp->arg[c] && *(p - 1) == ' ')
+ p--;
+ *p++ = 0;
+ if (!(pp.state & NOEXPAND))
+ pp.state |= NOEXPAND;
+ else
+ mp->arg[c][-1] = 0;
+#if MACKEYARGS
+ if (pp.option & KEYARGS)
+ {
+ pp.token = p + 1;
+ goto keyarg;
+ }
+#endif
+ {
+ if ((pp.state & STRICT) && p == mp->arg[c])
+ error(1, "%s: macro call argument %d is null", sym->name, c + 1);
+ if (c < mac->arity)
+ c++;
+ *p++ = ' ';
+ }
+ pp.toknxt = mp->arg[c] = p;
+ }
+ break;
+ case 0:
+ if (pp.in == old_in)
+ kp = 0;
+ else
+ for (kp = pp.in; kp && kp != old_in; kp = kp->prev);
+ if (!kp)
+ {
+ error(
+#if COMPATIBLE
+ (pp.state & COMPATIBILITY) ? 3 :
+#endif
+ 2, "%s: %s in macro argument list", sym->name, pptokchr(0));
+ goto endactuals;
+ }
+ continue;
+ case '\n':
+ pp.state |= HIDDEN;
+ error_info.line++;
+ pp.hidden++;
+ /*FALLTHROUGH*/
+ case ' ':
+ if (p > mp->arg[c] && *(p - 1) != ' ') *p++ = ' ';
+ continue;
+ }
+ p = pp.toknxt;
+ if (error_info.line != last_line)
+ {
+ SETLINE(p, error_info.line);
+ last_line = error_info.line;
+ }
+ if (error_info.file != last_file)
+ {
+ SETFILE(p, error_info.file);
+ last_file = error_info.file;
+ }
+ }
+ endactuals:
+ if (pp.state & NOEXPAND)
+ mp->arg[c][-1] = 0;
+ pp.token = old_token;
+ if (pp.in != old_in)
+ {
+ for (kp = pp.in; kp && kp != old_in; kp = kp->prev);
+ if (kp)
+ error(2, "%s: macro call starts and ends in different files", sym->name);
+ }
+ pp.state &= ~(COLLECTING|FILEPOP|NOEXPAND);
+ sym->flags &= ~SYM_ACTIVE;
+#if MACKEYARGS
+ if (!(pp.option & KEYARGS))
+#endif
+ {
+ if (p > mp->arg[0] && ++m || (sym->flags & SYM_VARIADIC))
+ c++;
+ if (c != mac->arity && !(sym->flags & SYM_EMPTY))
+ {
+ n = mac->arity;
+ if (!(sym->flags & SYM_VARIADIC))
+ error(1, "%s: %d actual argument%s expected", sym->name, n, n == 1 ? "" : "s");
+ else if (c < --n)
+ error(1, "%s: at least %d actual argument%s expected", sym->name, n, n == 1 ? "" : "s");
+#if COMPATIBLE
+ if (!c && (pp.state & (COMPATIBILITY|STRICT)) == (COMPATIBILITY|STRICT))
+ goto disable;
+#endif
+ }
+ if (!c)
+ ++c;
+ while (c < mac->arity)
+ mp->arg[c++] = (char*)"\0" + 1;
+ }
+ mp->arg[0][-2] = m;
+ *p++ = 0;
+ nextframe(mp, p);
+ count(function);
+ }
+ if (!tok && (sym->flags & SYM_NOEXPAND))
+ {
+ if (sym->flags & SYM_FUNCTION)
+ popframe(mp);
+ ret = !mac->size;
+ }
+ else if (!(pp.state & HEADER) || (pp.option & HEADEREXPANDALL) || pp.in->type != IN_COPY)
+ {
+ if (sym->flags & SYM_MULTILINE)
+ PUSH_MULTILINE(sym);
+ else
+ PUSH_MACRO(sym);
+ ret = 1;
+ }
+ }
+ disable:
+ if (ret < 0 && sym->hidden && !(pp.mode & EXPOSE) && !(pp.state & HEADER) && (pp.in->type == IN_FILE || pp.in->type == IN_MACRO || pp.in->type == IN_EXPAND))
+ {
+ struct ppinstk* inp;
+
+ for (inp = pp.in; inp->type != IN_FILE && inp->prev; inp = inp->prev);
+ sfsprintf(pp.hidebuf, MAXTOKEN, "_%d_%s_hIDe", inp->index, sym->name);
+ PUSH_STRING(pp.hidebuf);
+ ret = 1;
+ }
+ pp.state &= ~NEWLINE;
+ pp.in->flags |= IN_tokens;
+ count(token);
+ return ret;
+}
diff --git a/usr/src/lib/libpp/common/ppcomment.c b/usr/src/lib/libpp/common/ppcomment.c
new file mode 100644
index 0000000000..c938bc2e67
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppcomment.c
@@ -0,0 +1,35 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * common preprocessor comment handler
+ */
+
+#include "pplib.h"
+
+void
+ppcomment(char* head, char* comment, char* tail, int line)
+{
+ NoP(line);
+ ppprintf("%s%-.*s%s", head, MAXTOKEN - 4, comment, tail);
+}
diff --git a/usr/src/lib/libpp/common/ppcontext.c b/usr/src/lib/libpp/common/ppcontext.c
new file mode 100644
index 0000000000..220481ab87
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppcontext.c
@@ -0,0 +1,65 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * preprocessor context switch
+ *
+ * args op return
+ * (0,0) free current context 0
+ * (0,1) save current context current
+ * (p,0) free context p 0
+ * (p,1) make p current context previous
+ */
+
+#include "pplib.h"
+
+void*
+ppcontext(void* context, int flags)
+{
+ struct ppcontext* np = (struct ppcontext*)context;
+ struct ppcontext* op;
+
+ if (flags & 01)
+ {
+ if (!(op = pp.context)) op = pp.context = newof(0, struct ppcontext, 1, 0);
+ memcpy(op, _PP_CONTEXT_BASE_, sizeof(struct ppcontext));
+ }
+ else
+ {
+ if (!(op = np)) op = (struct ppcontext*)_PP_CONTEXT_BASE_;
+ if (op->filtab) hashfree(op->filtab);
+ if (op->prdtab) hashfree(op->prdtab);
+ if (op->symtab) hashfree(op->symtab);
+ if (op->date) free(op->date);
+ if (op->time) free(op->time);
+ if (np)
+ {
+ free(np);
+ np = 0;
+ }
+ memzero(op, sizeof(struct ppcontext));
+ op = 0;
+ }
+ if (np) memcpy(_PP_CONTEXT_BASE_, np, sizeof(struct ppcontext));
+ return((void*)op);
+}
diff --git a/usr/src/lib/libpp/common/ppcontrol.c b/usr/src/lib/libpp/common/ppcontrol.c
new file mode 100644
index 0000000000..a5d9974927
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppcontrol.c
@@ -0,0 +1,2295 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * preprocessor control directive support
+ */
+
+#include "pplib.h"
+
+#include <regex.h>
+
+#define TOKOP_DUP (1<<0)
+#define TOKOP_STRING (1<<1)
+#define TOKOP_UNSET (1<<2)
+
+struct edit
+{
+ struct edit* next;
+ regex_t re;
+};
+
+struct map
+{
+ struct map* next;
+ regex_t re;
+ struct edit* edit;
+};
+
+#define RESTORE (COLLECTING|CONDITIONAL|DEFINITION|DIRECTIVE|DISABLE|EOF2NL|HEADER|NOSPACE|NOVERTICAL|PASSEOF|STRIP)
+
+/*
+ * common predicate assertion operations
+ * op is DEFINE or UNDEF
+ */
+
+static void
+assert(int op, char* pred, char* args)
+{
+ register struct pplist* a;
+ register struct ppsymbol* sym;
+ register struct pplist* p;
+ register struct pplist* q;
+
+ if (!args) switch (op)
+ {
+ case DEFINE:
+ goto mark;
+ case UNDEF:
+ a = 0;
+ goto unmark;
+ }
+ if (a = (struct pplist*)hashget(pp.prdtab, pred))
+ {
+ p = 0;
+ q = a;
+ while (q)
+ {
+ if (streq(q->value, args))
+ {
+ if (op == DEFINE) return;
+ q = q->next;
+ if (p) p->next = q;
+ else a = q;
+ }
+ else
+ {
+ p = q;
+ q = q->next;
+ }
+ }
+ if (op == UNDEF)
+ {
+ unmark:
+ hashput(pp.prdtab, pred, a);
+ if (sym = ppsymref(pp.symtab, pred))
+ sym->flags &= ~SYM_PREDICATE;
+ return;
+ }
+ }
+ if (op == DEFINE)
+ {
+ p = newof(0, struct pplist, 1, 0);
+ p->next = a;
+ p->value = strdup(args);
+ hashput(pp.prdtab, NiL, p);
+ mark:
+ if ((pp.state & COMPILE) && pp.truncate) return;
+ if (sym = ppsymset(pp.symtab, pred))
+ sym->flags |= SYM_PREDICATE;
+ }
+}
+
+/*
+ * tokenize string ppop()
+ *
+ * op PP_* op
+ * name option name
+ * s string of option values
+ * n option sense
+ * flags TOKOP_* flags
+ */
+
+static void
+tokop(int op, char* name, register char* s, register int n, int flags)
+{
+ register int c;
+ register char* t;
+
+ if (!(flags & TOKOP_UNSET) && !n) error(2, "%s: option cannot be unset", name);
+ else if (!s) ppop(op, s, n);
+ else if (flags & TOKOP_STRING)
+ {
+ PUSH_LINE(s);
+ for (;;)
+ {
+ pp.state &= ~NOSPACE;
+ c = pplex();
+ pp.state |= NOSPACE;
+ if (!c) break;
+ if (c != ' ')
+ ppop(op, (flags & TOKOP_DUP) ? strdup(pp.token) : pp.token, n);
+ }
+ POP_LINE();
+ }
+ else do
+ {
+ while (*s == ' ') s++;
+ for (t = s; *t && *t != ' '; t++);
+ if (*t) *t++ = 0;
+ else t = 0;
+ if (*s) ppop(op, (flags & TOKOP_DUP) ? strdup(s) : s, n);
+ } while (s = t);
+}
+
+/*
+ * return symbol pointer for next token macro (re)definition
+ */
+
+static struct ppsymbol*
+macsym(int tok)
+{
+ register struct ppsymbol* sym;
+
+ if (tok != T_ID)
+ {
+ error(2, "%s: invalid macro name", pptokstr(pp.token, 0));
+ return 0;
+ }
+ sym = pprefmac(pp.token, REF_CREATE);
+ if ((sym->flags & SYM_FINAL) && (pp.mode & HOSTED)) return 0;
+ if (sym->flags & (SYM_ACTIVE|SYM_READONLY))
+ {
+ if (!(pp.option & ALLPOSSIBLE))
+ error(2, "%s: macro is %s", sym->name, (sym->flags & SYM_READONLY) ? "readonly" : "active");
+ return 0;
+ }
+ if (!sym->macro) sym->macro = newof(0, struct ppmacro, 1, 0);
+ return sym;
+}
+
+/*
+ * get one space canonical pplex() line, sans '\n', and place in p
+ * x is max+1 pos in p
+ * 0 returned if line too large
+ * otherwise end of p ('\0') returned
+ */
+
+static char*
+getline(register char* p, char* x, int disable)
+{
+ register int c;
+ register char* s;
+ char* b;
+ long restore;
+
+ restore = pp.state & (NOSPACE|STRIP);
+ pp.state &= ~(NEWLINE|NOSPACE|STRIP);
+ pp.state |= EOF2NL;
+ b = p;
+ while ((c = pplex()) != '\n')
+ {
+ if (disable)
+ {
+ if (c == ' ')
+ /*ignore*/;
+ else if (disable == 1)
+ disable = (c == T_ID && streq(pp.token, pp.pass)) ? 2 : 0;
+ else
+ {
+ disable = 0;
+ if (c == ':')
+ pp.state |= DISABLE;
+ }
+ }
+ s = pp.token;
+ while (*p = *s++)
+ if (++p >= x)
+ {
+ p = 0;
+ goto done;
+ }
+ }
+ if (p > b && *(p - 1) == ' ')
+ p--;
+ if (p >= x)
+ p = 0;
+ else
+ *p = 0;
+ done:
+ pp.state &= ~(NOSPACE|STRIP);
+ pp.state |= restore;
+ return p;
+}
+
+/*
+ * regex error handler
+ */
+
+void
+regfatal(regex_t* p, int level, int code)
+{
+ char buf[128];
+
+ regerror(code, p, buf, sizeof(buf));
+ regfree(p);
+ error(level, "regular expression: %s", buf);
+}
+
+/*
+ * process a single directive line
+ */
+
+int
+ppcontrol(void)
+{
+ register char* p;
+ register int c;
+ register int n;
+ register char* s;
+ register struct ppmacro* mac;
+ register struct ppsymbol* sym;
+ struct edit* edit;
+ struct map* map;
+ struct ppfile* fp;
+ int o;
+ int directive;
+ long restore;
+ struct pptuple* rp;
+ struct pptuple* tp;
+ char* v;
+ int emitted;
+
+ union
+ {
+ struct map* best;
+ struct ppinstk* inp;
+ struct pplist* list;
+ char* string;
+ struct ppsymbol* symbol;
+ int type;
+ PPLINESYNC linesync;
+ } var;
+
+ static char __va_args__[] = "__VA_ARGS__";
+ static int i0;
+ static int i1;
+ static int i2;
+ static int i3;
+ static int i4;
+
+ static long n1;
+ static long n2;
+ static long n3;
+
+ static char* p0;
+ static char* p1;
+ static char* p2;
+ static char* p3;
+ static char* p4;
+ static char* p5;
+ static char* p6;
+
+ static struct ppmacro old;
+ static char* formargs[MAXFORMALS];
+#if MACKEYARGS
+ static char* formvals[MAXFORMALS];
+#endif
+
+ emitted = 0;
+ if (pp.state & SKIPCONTROL) pp.level--;
+ restore = (pp.state & RESTORE)|NEWLINE;
+ if (pp.state & PASSTHROUGH) restore |= DISABLE;
+ else restore &= ~DISABLE;
+ pp.state &= ~(NEWLINE|RESTORE|SKIPCONTROL);
+ pp.state |= DIRECTIVE|DISABLE|EOF2NL|NOSPACE|NOVERTICAL;
+#if COMPATIBLE
+ if ((pp.state & (COMPATIBILITY|STRICT)) == COMPATIBILITY || (pp.mode & HOSTED)) pp.state &= ~NOVERTICAL;
+#else
+ if (pp.mode & HOSTED) pp.state &= ~NOVERTICAL;
+#endif
+ switch (c = pplex())
+ {
+ case T_DECIMAL:
+ case T_OCTAL:
+ if ((pp.state & STRICT) && !(pp.mode & (HOSTED|RELAX)))
+ error(1, "# <line> [ \"<file>\" [ <type> ] ]: non-standard directive");
+ directive = INCLUDE;
+ goto linesync;
+ case T_ID:
+ switch (directive = (int)hashref(pp.dirtab, pp.token))
+ {
+ case ELIF:
+ else_if:
+ if ((pp.option & ALLPOSSIBLE) && !pp.in->prev->prev)
+ goto eatdirective;
+ if (pp.control <= pp.in->control)
+ {
+ error(2, "no matching #%s for #%s", dirname(IF), dirname(ELIF));
+ goto eatdirective;
+ }
+ if (pp.control == (pp.in->control + 1)) pp.in->flags |= IN_noguard;
+ if (*pp.control & HADELSE)
+ {
+ error(2, "invalid #%s after #%s", dirname(ELIF), dirname(ELSE));
+ *pp.control |= SKIP;
+ goto eatdirective;
+ }
+ if (*pp.control & KEPT)
+ {
+ *pp.control |= SKIP;
+ goto eatdirective;
+ }
+ if (directive == IFDEF || directive == IFNDEF)
+ {
+ *pp.control &= ~SKIP;
+ goto else_ifdef;
+ }
+ conditional:
+ if (ppexpr(&i1))
+ {
+ *pp.control &= ~SKIP;
+ *pp.control |= KEPT;
+ }
+ else *pp.control |= SKIP;
+ c = (pp.state & NEWLINE) ? '\n' : ' ';
+ goto eatdirective;
+ case ELSE:
+ if ((pp.option & ALLPOSSIBLE) && !pp.in->prev->prev)
+ goto eatdirective;
+ if ((pp.option & ELSEIF) && (c = pplex()) == T_ID && ((n = (int)hashref(pp.dirtab, pp.token)) == IF || n == IFDEF || n == IFNDEF))
+ {
+ error(1, "#%s %s is non-standard -- use #%s", dirname(directive), dirname(n), dirname(ELIF));
+ directive = n;
+ goto else_if;
+ }
+ if (pp.control <= pp.in->control) error(2, "no matching #%s for #%s", dirname(IF), dirname(ELSE));
+ else
+ {
+ if (pp.control == (pp.in->control + 1)) pp.in->flags |= IN_noguard;
+ if (!(*pp.control & KEPT))
+ {
+ *pp.control &= ~SKIP;
+ *pp.control |= HADELSE|KEPT;
+ }
+ else
+ {
+ if (*pp.control & HADELSE) error(2, "more than one #%s for #%s", dirname(ELSE), dirname(IF));
+ *pp.control |= HADELSE|SKIP;
+ }
+ }
+ goto enddirective;
+ case ENDIF:
+ if ((pp.option & ALLPOSSIBLE) && !pp.in->prev->prev)
+ goto eatdirective;
+ if (pp.control <= pp.in->control) error(2, "no matching #%s for #%s", dirname(IF), dirname(ENDIF));
+ else if (--pp.control == pp.in->control && pp.in->symbol)
+ {
+ if (pp.in->flags & IN_endguard) pp.in->flags |= IN_noguard;
+ else
+ {
+ pp.in->flags &= ~IN_tokens;
+ pp.in->flags |= IN_endguard;
+ }
+ }
+ goto enddirective;
+ case IF:
+ case IFDEF:
+ case IFNDEF:
+ if ((pp.option & ALLPOSSIBLE) && !pp.in->prev->prev)
+ goto eatdirective;
+ pushcontrol();
+ SETIFBLOCK(pp.control);
+ if (*pp.control & SKIP)
+ {
+ *pp.control |= KEPT;
+ goto eatdirective;
+ }
+ if (directive == IF) goto conditional;
+ else_ifdef:
+ if ((c = pplex()) == T_ID)
+ {
+ sym = pprefmac(pp.token, REF_IF);
+ if (directive == IFNDEF && pp.control == pp.in->control + 1)
+ {
+ if (pp.in->flags & (IN_defguard|IN_endguard))
+ pp.in->flags |= IN_noguard;
+ else
+ {
+ pp.in->flags |= IN_defguard;
+ if (!(pp.in->flags & IN_tokens))
+ pp.in->symbol = sym ? sym : pprefmac(pp.token, REF_CREATE);
+ }
+ }
+ }
+ else
+ {
+ sym = 0;
+ if (!(pp.mode & HOSTED))
+ error(1, "%s: invalid macro name", pptokstr(pp.token, 0));
+ }
+ *pp.control |= ((sym != 0) == (directive == IFDEF)) ? KEPT : SKIP;
+ goto enddirective;
+ case INCLUDE:
+ if (*pp.control & SKIP)
+ {
+ pp.state |= HEADER;
+ c = pplex();
+ pp.state &= ~HEADER;
+ goto eatdirective;
+ }
+ pp.state &= ~DISABLE;
+ pp.state |= HEADER|STRIP;
+ switch (c = pplex())
+ {
+ case T_STRING:
+ p = pp.token;
+ do pp.token = pp.toknxt; while ((c = pplex()) == T_STRING);
+ *pp.token = 0;
+ pp.token = p;
+ /*FALLTHROUGH*/
+ case T_HEADER:
+ header:
+ if (!*pp.token)
+ {
+ error(2, "#%s: null file name", dirname(INCLUDE));
+ break;
+ }
+ if (*pp.token == '/' && !(pp.mode & (HOSTED|RELAX)))
+ error(1, "#%s: reference to %s is not portable", dirname(INCLUDE), pp.token);
+ n = ppsearch(pp.token, c, SEARCH_INCLUDE);
+ break;
+ case '<':
+ /*
+ * HEADEREXPAND|HEADEREXPANDALL gets us here
+ */
+
+ if (!(p = pp.hdrbuf) && !(p = pp.hdrbuf = newof(0, char, MAXTOKEN, 0)))
+ error(3, "out of space");
+ pp.state &= ~NOSPACE;
+ while ((c = pplex()) && c != '>')
+ {
+ v = p + 1;
+ STRCOPY(p, pp.token, s);
+ if (p == v && *(p - 1) == ' ' && pp.in->type != IN_MACRO)
+ p--;
+ }
+ pp.state |= NOSPACE;
+ *p++ = 0;
+ memcpy(pp.token, pp.hdrbuf, p - pp.hdrbuf);
+ c = T_HEADER;
+ goto header;
+ default:
+ error(2, "#%s: \"...\" or <...> argument expected", dirname(INCLUDE));
+ goto eatdirective;
+ }
+ goto enddirective;
+ case 0:
+ {
+ regmatch_t match[10];
+
+ /*UNDENT*/
+ p = pp.valbuf;
+ *p++ = '#';
+ STRCOPY(p, pp.token, s);
+ p0 = p;
+ pp.mode |= EXPOSE;
+ pp.state |= HEADER;
+ p6 = getline(p, &pp.valbuf[MAXTOKEN], 0);
+ pp.state &= ~HEADER;
+ pp.mode &= ~EXPOSE;
+ if (!p6)
+ {
+ *p0 = 0;
+ error(2, "%s: directive too long", pp.valbuf);
+ c = 0;
+ goto eatdirective;
+ }
+ p1 = p2 = p3 = p4 = 0;
+ p5 = *p ? p + 1 : 0;
+ checkmap:
+ i0 = *p0;
+ p = pp.valbuf;
+ var.best = 0;
+ n = 0;
+ for (map = (struct map*)pp.maps; map; map = map->next)
+ if (!(i1 = regexec(&map->re, p, elementsof(match), match, 0)))
+ {
+ if ((c = match[0].rm_eo - match[0].rm_so) > n)
+ {
+ n = c;
+ var.best = map;
+ }
+ }
+ else if (i1 != REG_NOMATCH)
+ regfatal(&map->re, 3, i1);
+ c = '\n';
+ if (map = var.best)
+ {
+ if ((pp.state & (STRICT|WARN)) && !(pp.mode & (HOSTED|RELAX)))
+ {
+ *p0 = 0;
+ if (!(pp.state & WARN) || strcmp(p + 1, dirname(PRAGMA)))
+ error(1, "%s: non-standard directive", p);
+ *p0 = i0;
+ }
+ if (!(*pp.control & SKIP))
+ {
+ n = 0;
+ for (edit = map->edit; edit; edit = edit->next)
+ if (!(i0 = regexec(&edit->re, p, elementsof(match), match, 0)))
+ {
+ n++;
+ if (i0 = regsubexec(&edit->re, p, elementsof(match), match))
+ regfatal(&edit->re, 3, i0);
+ p = edit->re.re_sub->re_buf;
+ if (edit->re.re_sub->re_flags & REG_SUB_STOP)
+ break;
+ }
+ else if (i0 != REG_NOMATCH)
+ regfatal(&edit->re, 3, i0);
+ if (n && *p)
+ {
+ p1 = s = oldof(0, char, 0, strlen(p) + 32);
+ while (*s = *p++) s++;
+ debug((-4, "map: %s", p1));
+ *s++ = '\n';
+ *s = 0;
+ error_info.line++;
+ PUSH_RESCAN(p1);
+ error_info.line--;
+ directive = LINE;
+ }
+ }
+ goto donedirective;
+ }
+ if (directive != PRAGMA && (!(*pp.control & SKIP) || !(pp.mode & (HOSTED|RELAX))))
+ {
+ *p0 = 0;
+ error(1, "%s: unknown directive", pptokstr(pp.valbuf, 0));
+ *p0 = i0;
+ }
+ pass:
+ if (!(*pp.control & SKIP) && pp.pragma && !(pp.state & NOTEXT) && (directive == PRAGMA || !(pp.mode & INIT)))
+ {
+ *p0 = 0;
+ if (p2) *p2 = 0;
+ if (p4)
+ {
+ if (p4 == p5)
+ {
+ p5 = strcpy(pp.tmpbuf, p5);
+ if (p = strchr(p5, MARK))
+ {
+ s = p;
+ while (*p)
+ if ((*s++ = *p++) == MARK && *p == MARK) p++;
+ *s = 0;
+ }
+ }
+ *p4 = 0;
+ }
+ if (p = (char*)memchr(pp.valbuf + 1, MARK, p6 - pp.valbuf - 1))
+ {
+ s = p;
+ while (p < p6) switch (*s++ = *p++)
+ {
+ case 0:
+ s = p;
+ break;
+ case MARK:
+ p++;
+ break;
+ }
+ *s = 0;
+ }
+ (*pp.pragma)(pp.valbuf + 1, p1, p3, p5, (pp.state & COMPILE) || (pp.mode & INIT) != 0);
+ emitted = 1;
+ }
+ goto donedirective;
+
+ /*INDENT*/
+ }
+ }
+ if (*pp.control & SKIP) goto eatdirective;
+ switch (directive)
+ {
+#if MACDEF
+ case ENDMAC:
+ c = pplex();
+ error(2, "no matching #%s for #%s", dirname(MACDEF), dirname(ENDMAC));
+ goto enddirective;
+#endif
+#if MACDEF
+ case MACDEF:
+ if ((pp.state & STRICT) && !(pp.mode & (HOSTED|RELAX)))
+ error(1, "#%s: non-standard directive", pp.token);
+ /*FALLTHROUGH*/
+#endif
+ case DEFINE:
+ n2 = error_info.line;
+ if ((c = pplex()) == '#' && directive == DEFINE)
+ goto assertion;
+ if (c == '<')
+ {
+ n = 1;
+ c = pplex();
+ }
+ else
+ n = 0;
+ if (!(sym = macsym(c)))
+ goto eatdirective;
+ if (pp.truncate)
+ ppfsm(FSM_MACRO, pp.token);
+ mac = sym->macro;
+ if ((pp.option & ALLPOSSIBLE) && !pp.in->prev->prev && mac->value)
+ goto eatdirective;
+ if (n)
+ goto tuple;
+ old = *mac;
+ i0 = sym->flags;
+ sym->flags &= ~(SYM_BUILTIN|SYM_EMPTY|SYM_FINAL|SYM_FUNCTION|SYM_INIT|SYM_INITIAL|SYM_MULTILINE|SYM_NOEXPAND|SYM_PREDEFINED|SYM_REDEFINE|SYM_VARIADIC);
+#if MACDEF
+ if (directive == MACDEF)
+ sym->flags |= SYM_MULTILINE;
+#endif
+ mac->arity = 0;
+ mac->formals = 0;
+ mac->value = 0;
+ pp.state &= ~NOSPACE;
+ pp.state |= DEFINITION|NOEXPAND;
+ switch (c = pplex())
+ {
+ case '(':
+ sym->flags |= SYM_FUNCTION;
+ pp.state |= NOSPACE;
+#if MACKEYARGS
+ if (pp.option & KEYARGS)
+ {
+ n = 2 * MAXTOKEN;
+ p = mac->formals = oldof(0, char, 0, n);
+ if ((c = pplex()) == T_ID) for (;;)
+ {
+ if (mac->arity < MAXFORMALS)
+ {
+ if (mac->arity) p++;
+ formargs[mac->arity] = p;
+ STRAPP(p, pp.token, s);
+ formvals[mac->arity++] = p1 = p;
+ if (mac->arity == 1) *p++ = ' ';
+ *p++ = ' ';
+ *p = 0;
+ }
+ else error(2, "%s: formal argument %s ignored", sym->name, pp.token);
+ switch (c = pplex())
+ {
+ case '=':
+ c = pplex();
+ break;
+ case ',':
+ break;
+ default:
+ goto endformals;
+ }
+ pp.state &= ~NOSPACE;
+ p0 = 0;
+ for (;;)
+ {
+ switch (c)
+ {
+ case '\n':
+ goto endformals;
+ case '(':
+ p0++;
+ break;
+ case ')':
+ if (!p0--)
+ {
+ if (p > formvals[mac->arity - 1] && *(p - 1) == ' ') *--p = 0;
+ goto endformals;
+ }
+ break;
+ case ',':
+ if (!p0)
+ {
+ if (p > formvals[mac->arity - 1] && *(p - 1) == ' ') *--p = 0;
+ goto nextformal;
+ }
+ break;
+ case ' ':
+ if (p > formvals[mac->arity - 1] && *(p - 1) == ' ') continue;
+ break;
+ }
+ STRCOPY(p, pp.token, s);
+ if (p > &mac->formals[n - MAXTOKEN] && (s = newof(mac->formals, char, n += MAXTOKEN, 0)) != mac->formals)
+ {
+ n1 = s - mac->formals;
+ for (n = 0; n < mac->arity; n++)
+ {
+ formargs[n] += n1;
+ formvals[n] += n1;
+ }
+ c = p - mac->formals;
+ mac->formals = s;
+ p = mac->formals + c;
+ }
+ c = pplex();
+ }
+ nextformal:
+ pp.state |= NOSPACE;
+ if ((c = pplex()) != T_ID)
+ {
+ c = ',';
+ break;
+ }
+ }
+ endformals: /*NOP*/;
+ }
+ else
+#endif
+ {
+ p = mac->formals = oldof(0, char, 0, MAXFORMALS * (MAXID + 1));
+ c = pplex();
+#if COMPATIBLE
+ if ((pp.state & COMPATIBILITY) && c == ',')
+ {
+ if ((pp.state & WARN) && !(pp.mode & HOSTED))
+ error(1, "%s: macro formal argument expected", sym->name);
+ while ((c = pplex()) == ',');
+ }
+#endif
+ for (;;)
+ {
+ if (c == T_VARIADIC)
+ {
+ if (sym->flags & SYM_VARIADIC)
+ error(2, "%s: %s: duplicate macro formal argument", sym->name, pp.token);
+ sym->flags |= SYM_VARIADIC;
+ v = __va_args__;
+ }
+ else if (c == T_ID)
+ {
+ v = pp.token;
+ if (sym->flags & SYM_VARIADIC)
+ error(2, "%s: %s: macro formal argument cannot follow ...", sym->name, v);
+ else if (streq(v, __va_args__))
+ error(2, "%s: %s: invalid macro formal argument", sym->name, v);
+ }
+ else
+ break;
+ if (mac->arity < MAXFORMALS)
+ {
+ for (n = 0; n < mac->arity; n++)
+ if (streq(formargs[n], v))
+ error(2, "%s: %s: duplicate macro formal argument", sym->name, v);
+ formargs[mac->arity++] = p;
+ STRAPP(p, v, s);
+ }
+ else
+ error(2, "%s: %s: macro formal argument ignored", sym->name, v);
+ if ((c = pplex()) == ',')
+ {
+ c = pplex();
+#if COMPATIBLE
+ if ((pp.state & COMPATIBILITY) && c == ',')
+ {
+ if ((pp.state & WARN) && !(pp.mode & HOSTED))
+ error(1, "%s: macro formal argument expected", sym->name);
+ while ((c = pplex()) == ',');
+ }
+#endif
+ }
+ else if (c != T_VARIADIC)
+ break;
+ else
+ {
+ if (sym->flags & SYM_VARIADIC)
+ error(2, "%s: %s: duplicate macro formal argument", sym->name, pp.token);
+ sym->flags |= SYM_VARIADIC;
+ c = pplex();
+ break;
+ }
+ }
+ if (mac->arity && (s = newof(mac->formals, char, p - mac->formals, 0)) != mac->formals)
+ {
+ n1 = s - mac->formals;
+ for (n = 0; n < mac->arity; n++)
+ formargs[n] += n1;
+ mac->formals = s;
+ }
+ }
+ if (!mac->arity)
+ {
+ free(mac->formals);
+ mac->formals = 0;
+ }
+ switch (c)
+ {
+ case ')':
+#if MACKEYARGS
+ pp.state |= NOEXPAND|NOSPACE;
+#else
+ pp.state |= NOEXPAND;
+#endif
+ c = pplex();
+ break;
+ default:
+ error(2, "%s: invalid macro formal argument list", sym->name);
+ if (mac->formals)
+ {
+ free(mac->formals);
+ mac->formals = 0;
+ mac->arity = 0;
+ }
+ free(mac);
+ sym->macro = 0;
+ goto eatdirective;
+ }
+ pp.state &= ~NOSPACE;
+ break;
+ case ' ':
+ case '\t':
+ c = pplex();
+ break;
+ }
+ n = 2 * MAXTOKEN;
+#if MACKEYARGS
+ p1 = p;
+#endif
+ p = mac->value = oldof(0, char, 0, n);
+ var.type = 0;
+ n1 = 0;
+#if MACDEF
+ i2 = i3 = 0;
+ n3 = pp.state;
+#endif
+ if ((pp.option & PLUSPLUS) && (pp.state & (COMPATIBILITY|TRANSITION)) != COMPATIBILITY)
+ switch (c)
+ {
+ case '+':
+ case '-':
+ case '&':
+ case '|':
+ case '<':
+ case '>':
+ case ':':
+ case '=':
+ *p++ = ' ';
+ break;
+ }
+ o = 0;
+ for (;;)
+ {
+ switch (c)
+ {
+ case T_ID:
+ for (c = 0; c < mac->arity; c++)
+ if (streq(formargs[c], pp.token))
+ {
+#if COMPATIBLE
+ if (!(pp.state & COMPATIBILITY))
+#endif
+ if (var.type != TOK_TOKCAT && p > mac->value && *(p - 1) != ' ' && !(pp.option & PRESERVE)) *p++ = ' ';
+ *p++ = MARK;
+#if COMPATIBLE
+ if ((pp.state & (COMPATIBILITY|TRANSITION)) == COMPATIBILITY) *p++ = 'C';
+ else
+#endif
+ *p++ = (n1 || var.type == TOK_TOKCAT) ? 'C' : 'A';
+ *p++ = c + ARGOFFSET;
+ var.type = TOK_FORMAL|TOK_ID;
+ c = '>';
+ goto checkvalue;
+ }
+ if (var.type == TOK_BUILTIN) switch ((int)hashget(pp.strtab, pp.token))
+ {
+ case V_DEFAULT:
+ case V_EMPTY:
+ sym->flags |= SYM_EMPTY;
+ break;
+ }
+ else if (pp.hiding && (var.symbol = ppsymref(pp.symtab, pp.token)) && var.symbol->hidden)
+ {
+ for (var.inp = pp.in; var.inp->type != IN_FILE && var.inp->prev; var.inp = var.inp->prev);
+ p += sfsprintf(p, MAXTOKEN, "_%d_%s_hIDe", var.inp->hide, pp.token);
+ var.type = TOK_ID;
+ goto checkvalue;
+ }
+ var.type = TOK_ID;
+ break;
+ case '#':
+ var.type = 0;
+#if MACDEF
+ if (!(sym->flags & (SYM_FUNCTION|SYM_MULTILINE))) break;
+#else
+ if (!(sym->flags & SYM_FUNCTION)) break;
+#endif
+ pp.state |= NOSPACE;
+ c = pplex();
+ if (c == '@')
+ {
+ c = pplex();
+ i4 = 'S';
+ }
+ else i4 = 'Q';
+ pp.state &= ~NOSPACE;
+ if (c != T_ID) c = mac->arity;
+ else for (c = 0; c < mac->arity; c++)
+ if (streq(formargs[c], pp.token))
+ break;
+ if (c >= mac->arity)
+ {
+#if MACDEF
+ if (sym->flags & SYM_MULTILINE)
+ {
+ if (n3 & NEWLINE)
+ {
+ pp.state &= ~NOEXPAND;
+ switch ((int)hashref(pp.dirtab, pp.token))
+ {
+ case ENDMAC:
+ if (!i2--) goto gotdefinition;
+ break;
+ case INCLUDE:
+ /* PARSE HEADER constant */
+ break;
+ case MACDEF:
+ i2++;
+ break;
+ }
+ *p++ = '#';
+ }
+ }
+ else
+#endif
+#if COMPATIBLE
+ if (pp.state & COMPATIBILITY) *p++ = '#';
+ else
+#endif
+ error(2, "# must precede a formal parameter");
+ }
+ else
+ {
+ if (p > mac->value && ppisidig(*(p - 1)) && !(pp.option & PRESERVE)) *p++ = ' ';
+ *p++ = MARK;
+ *p++ = i4;
+ *p++ = c + ARGOFFSET;
+ goto checkvalue;
+ }
+ break;
+ case T_TOKCAT:
+ if (p <= mac->value) error(2, "%s lhs operand omitted", pp.token);
+ else
+ {
+ if (*(p - 1) == ' ') p--;
+ if (var.type == (TOK_FORMAL|TOK_ID)) *(p - 2) = 'C';
+ }
+ pp.state |= NOSPACE;
+ c = pplex();
+ pp.state &= ~NOSPACE;
+ if (c == '\n') error(2, "%s rhs operand omitted", pptokchr(T_TOKCAT));
+ var.type = TOK_TOKCAT;
+ continue;
+ case '(':
+ if (*pp.token == '#')
+ {
+ var.type = TOK_BUILTIN;
+ n1++;
+ }
+ else
+ {
+ var.type = 0;
+ if (n1) n1++;
+ }
+ break;
+ case ')':
+ var.type = 0;
+ if (n1) n1--;
+ break;
+ case T_STRING:
+ case T_CHARCONST:
+ pp.state &= ~NOEXPAND;
+ var.type = 0;
+ if (strchr(pp.token, MARK)) pp.state &= ~NOEXPAND;
+#if COMPATIBLE
+ /*UNDENT*/
+
+ if ((sym->flags & SYM_FUNCTION) && (pp.state & (COMPATIBILITY|TRANSITION)))
+ {
+ char* v;
+
+ s = pp.token;
+ for (;;)
+ {
+ if (!*s) goto checkvalue;
+ if (ppisid(*s))
+ {
+ v = s;
+ while (ppisid(*++s));
+ i1 = *s;
+ *s = 0;
+ for (c = 0; c < mac->arity; c++)
+ if (streq(formargs[c], v))
+ {
+ *p++ = MARK;
+ *p++ = 'C';
+ *p++ = c + ARGOFFSET;
+ if (!(pp.mode & HOSTED) && (!(pp.state & COMPATIBILITY) || (pp.state & WARN))) switch (*pp.token)
+ {
+ case '"':
+ error(1, "use the # operator to \"...\" quote macro arguments");
+ break;
+ case '\'':
+ error(1, "macro arguments should be '...' quoted before substitution");
+ break;
+ }
+ goto quotearg;
+ }
+ STRCOPY2(p, v);
+ quotearg:
+ *s = i1;
+ }
+ else *p++ = *s++;
+ }
+ }
+ /*INDENT*/
+#endif
+ break;
+ case '\n':
+#if MACDEF
+ if (sym->flags & SYM_MULTILINE)
+ {
+ if (pp.state & EOF2NL)
+ {
+ error_info.line++;
+ pp.state |= HIDDEN;
+ pp.hidden++;
+ var.type = 0;
+ if (!i3++)
+ goto checkvalue;
+ break;
+ }
+ pp.state |= EOF2NL;
+ error(2, "%s: missing #%s", sym->name, dirname(ENDMAC));
+ }
+#endif
+ goto gotdefinition;
+ case 0:
+ c = '\n';
+ goto gotdefinition;
+#if COMPATIBLE
+ case ' ':
+ if (pp.state & COMPATIBILITY) var.type = 0;
+ if (pp.option & PRESERVE) break;
+ if (p > mac->value && *(p - 1) != ' ') *p++ = ' ';
+ goto checkvalue;
+ case '\t':
+ if (var.type & TOK_ID)
+ {
+ while ((c = pplex()) == '\t');
+ if (c == T_ID)
+ {
+ if (var.type == (TOK_FORMAL|TOK_ID)) *(p - 2) = 'C';
+ var.type = TOK_TOKCAT;
+ if (pp.state & WARN) error(1, "use the ## operator to concatenate macro arguments");
+ }
+ else var.type = 0;
+ continue;
+ }
+ var.type = 0;
+ if (pp.option & PRESERVE) break;
+ if (p > mac->value && *(p - 1) != ' ') *p++ = ' ';
+ goto checkvalue;
+#endif
+ case MARK:
+ pp.state &= ~NOEXPAND;
+ /*FALLTHROUGH*/
+
+ default:
+ var.type = 0;
+ break;
+ }
+ STRCOPY(p, pp.token, s);
+ checkvalue:
+ o = c;
+ if (p > &mac->value[n - MAXTOKEN] && (s = newof(mac->value, char, n += MAXTOKEN, 0)) != mac->value)
+ {
+ c = p - mac->value;
+ mac->value = s;
+ p = mac->value + c;
+ }
+#if MACDEF
+ n3 = pp.state;
+#endif
+ c = pplex();
+ }
+ gotdefinition:
+ while (p > mac->value && *(p - 1) == ' ') p--;
+ if (p > mac->value && (pp.option & PLUSPLUS) && (pp.state & (COMPATIBILITY|TRANSITION)) != COMPATIBILITY)
+ switch (o)
+ {
+ case '+':
+ case '-':
+ case '&':
+ case '|':
+ case '<':
+ case '>':
+ case ':':
+ case '=':
+ *p++ = ' ';
+ break;
+ }
+ *p = 0;
+#if MACKEYARGS
+ if (!mac->arity) /* ok */;
+ else if (pp.option & KEYARGS)
+ {
+ p0 = mac->formals;
+ mac->formkeys = newof(0, struct ppkeyarg, n, p1 - p0 + 1);
+ s = (char*)&mac->formkeys[mac->arity];
+ (void)memcpy(s, p0, p1 - p0 + 1);
+ free(p0);
+ for (n = 0; n < mac->arity; n++)
+ {
+ mac->formkeys[n].name = s + (formargs[n] - p0);
+ mac->formkeys[n].value = s + (formvals[n] - p0);
+ }
+ }
+ else
+#endif
+ for (n = 1; n < mac->arity; n++)
+ *(formargs[n] - 1) = ',';
+ if (old.value)
+ {
+ if ((i0 & SYM_FUNCTION) != (sym->flags & SYM_FUNCTION) || old.arity != mac->arity || !streq(old.value, mac->value)) goto redefined;
+ if (!old.formals)
+ {
+ if (mac->formals) goto redefined;
+ }
+ else if (mac->formals)
+ {
+#if MACKEYARGS
+ if (pp.option & KEYARGS)
+ {
+ for (n = 0; n < mac->arity; n++)
+ if (!streq(mac->formkeys[n].name, old.formkeys[n].name) || !streq(mac->formkeys[n].value, old.formkeys[n].value))
+ goto redefined;
+ }
+ else
+#endif
+ if (!streq(mac->formals, old.formals)) goto redefined;
+ }
+#if MACKEYARGS
+ if (pp.option & KEYARGS)
+ {
+ if (mac->formkeys) free(mac->formkeys);
+ mac->formkeys = old.formkeys;
+ }
+ else
+#endif
+ {
+ if (mac->formals) free(mac->formals);
+ mac->formals = old.formals;
+ }
+ free(mac->value);
+ mac->value = old.value;
+ goto benign;
+ redefined:
+ if (!(pp.mode & HOSTED) || !(i0 & SYM_INITIAL))
+ error(1, "%s redefined", sym->name);
+#if MACKEYARGS
+ if ((pp.option & KEYARGS) && mac->formkeys)
+ free(mac->formkeys);
+#endif
+#if MACKEYARGS
+ if (!(pp.option & KEYARGS))
+#endif
+ if (old.formals) free(old.formals);
+ free(old.value);
+ }
+ else if (!pp.truncate) ppfsm(FSM_MACRO, sym->name);
+ mac->value = newof(mac->value, char, (mac->size = p - mac->value) + 1, 0);
+ if ((pp.option & (DEFINITIONS|PREDEFINITIONS|REGUARD)) && !sym->hidden && !(sym->flags & SYM_MULTILINE) && ((pp.option & PREDEFINITIONS) || !(pp.mode & INIT)) && ((pp.option & (DEFINITIONS|PREDEFINITIONS)) || !(pp.state & NOTEXT)))
+ {
+ ppsync();
+ ppprintf("#%s %s", dirname(DEFINE), sym->name);
+ if (sym->flags & SYM_FUNCTION)
+ {
+ ppputchar('(');
+ if (mac->formals)
+ ppprintf("%s", mac->formals);
+ ppputchar(')');
+ }
+ if ((p = mac->value) && *p)
+ {
+ ppputchar(' ');
+ i0 = 0;
+ while (n = *p++)
+ {
+ if (n != MARK || (n = *p++) == MARK)
+ {
+ ppputchar(n);
+ i0 = ppisid(n);
+ }
+ else
+ {
+ if (n == 'Q')
+ ppputchar('#');
+ else if (i0)
+ {
+ ppputchar('#');
+ ppputchar('#');
+ }
+ s = formargs[*p++ - ARGOFFSET];
+ while ((n = *s++) && n != ',')
+ ppputchar(n);
+ if (ppisid(*p) || *p == MARK)
+ {
+ ppputchar('#');
+ ppputchar('#');
+ }
+ i0 = 0;
+ }
+ ppcheckout();
+ }
+ }
+ emitted = 1;
+ }
+ benign:
+ if (pp.mode & BUILTIN) sym->flags |= SYM_BUILTIN;
+ if (pp.option & FINAL) sym->flags |= SYM_FINAL;
+ if (pp.mode & INIT) sym->flags |= SYM_INIT;
+ if (pp.option & INITIAL) sym->flags |= SYM_INITIAL;
+ if (pp.state & NOEXPAND) sym->flags |= SYM_NOEXPAND;
+ if (pp.option & PREDEFINED) sym->flags |= SYM_PREDEFINED;
+ if (pp.mode & READONLY) sym->flags |= SYM_READONLY;
+ if (pp.macref) (*pp.macref)(sym, error_info.file, n2, mac ? error_info.line - n2 + 1 : REF_UNDEF, mac ? strsum(mac->value, (long)mac->arity) : 0L);
+ break;
+ assertion:
+ c = pplex();
+ if ((pp.state & STRICT) && !(pp.mode & (HOSTED|RELAX)))
+ error(1, "#%s #%s: assertions are non-standard", dirname(directive), pptokstr(pp.token, 0));
+ if (c != T_ID)
+ {
+ error(2, "%s: invalid predicate name", pptokstr(pp.token, 0));
+ goto eatdirective;
+ }
+ switch ((int)hashref(pp.strtab, pp.token))
+ {
+ case X_DEFINED:
+ case X_EXISTS:
+ case X_STRCMP:
+ error(2, "%s is a builtin predicate", pp.token);
+ goto eatdirective;
+ case X_SIZEOF:
+ error(2, "%s cannot be a predicate", pp.token);
+ goto eatdirective;
+ }
+ strcpy(pp.tmpbuf, pp.token);
+ switch (pppredargs())
+ {
+ case T_ID:
+ case T_STRING:
+ assert(directive, pp.tmpbuf, pp.args);
+ break;
+ case 0:
+ assert(directive, pp.tmpbuf, NiL);
+ break;
+ default:
+ error(2, "invalid predicate argument list");
+ goto eatdirective;
+ }
+ break;
+ tuple:
+ pp.state |= DEFINITION|NOEXPAND|NOSPACE;
+ rp = 0;
+ tp = mac->tuple;
+ if (!tp && !mac->value)
+ ppfsm(FSM_MACRO, sym->name);
+ while ((c = pplex()) && c != '>' && c != '\n')
+ {
+ for (; tp; tp = tp->nomatch)
+ if (streq(tp->token, pp.token))
+ break;
+ if (!tp)
+ {
+ if (!(tp = newof(0, struct pptuple, 1, strlen(pp.token))))
+ error(3, "out of space");
+ strcpy(tp->token, pp.token);
+ if (rp)
+ {
+ tp->nomatch = rp;
+ rp->nomatch = tp;
+ }
+ else
+ {
+ tp->nomatch = mac->tuple;
+ mac->tuple = tp;
+ }
+ }
+ rp = tp;
+ tp = tp->match;
+ }
+ pp.state &= ~NOSPACE;
+ if (!rp || c != '>')
+ error(2, "%s: > omitted in tuple macro definition", sym->name);
+ else
+ {
+ n = 2 * MAXTOKEN;
+ p = v = oldof(0, char, 0, n);
+ while ((c = pplex()) && c != '\n')
+ if (p > v || c != ' ')
+ {
+ STRCOPY(p, pp.token, s);
+ if (p > &v[n - MAXTOKEN] && (s = newof(v, char, n += MAXTOKEN, 0)) != v)
+ {
+ c = p - v;
+ v = s;
+ p = v + c;
+ }
+ }
+ while (p > v && *(p - 1) == ' ')
+ p--;
+ n = p - v;
+ tp = newof(0, struct pptuple, 1, n);
+ strcpy(tp->token, v);
+ tp->match = rp->match;
+ rp->match = tp;
+ }
+ goto benign;
+ case WARNING:
+ if ((pp.state & STRICT) && !(pp.mode & (HOSTED|RELAX)))
+ error(1, "#%s: non-standard directive", pp.token);
+ /*FALLTHROUGH*/
+ case ERROR:
+ pp.state &= ~DISABLE;
+ p = pp.tmpbuf;
+ while ((c = pplex()) != '\n')
+ if (p + strlen(pp.token) < &pp.tmpbuf[MAXTOKEN])
+ {
+ STRCOPY(p, pp.token, s);
+ pp.state &= ~NOSPACE;
+ }
+ *p = 0;
+ p = *pp.tmpbuf ? pp.tmpbuf : ((directive == WARNING) ? "user warning" : "user error");
+ n = (directive == WARNING) ? 1 : 3;
+ error(n, "%s", p);
+ break;
+ case LET:
+ n2 = error_info.line;
+ if ((pp.state & STRICT) && !(pp.mode & (HOSTED|RELAX)))
+ error(1, "#%s: non-standard directive", pp.token);
+ if (!(sym = macsym(c = pplex()))) goto eatdirective;
+ if ((c = pplex()) != '=')
+ {
+ error(2, "%s: = expected", sym->name);
+ goto eatdirective;
+ }
+ sym->flags &= ~(SYM_BUILTIN|SYM_FUNCTION|SYM_MULTILINE|SYM_PREDEFINED|SYM_VARIADIC);
+ mac = sym->macro;
+ mac->arity = 0;
+ if (mac->value)
+ {
+ if (!(sym->flags & SYM_REDEFINE) && !sym->hidden)
+ error(1, "%s: redefined", sym->name);
+#if MACKEYARGS
+ if ((pp.option & KEYARGS) && mac->formkeys) free(mac->formkeys);
+ else
+#endif
+ free(mac->formals);
+ mac->formals = 0;
+ n = strlen(mac->value) + 1;
+ }
+ else
+ {
+ ppfsm(FSM_MACRO, sym->name);
+ n = 0;
+ }
+ n1 = ppexpr(&i1);
+ if (i1) c = sfsprintf(pp.tmpbuf, MAXTOKEN, "%luU", n1);
+ else c = sfsprintf(pp.tmpbuf, MAXTOKEN, "%ld", n1);
+ if (n < ++c)
+ {
+ if (mac->value) free(mac->value);
+ mac->value = oldof(0, char, 0, c);
+ }
+ strcpy(mac->value, pp.tmpbuf);
+ sym->flags |= SYM_REDEFINE;
+ c = (pp.state & NEWLINE) ? '\n' : ' ';
+ goto benign;
+ case LINE:
+ pp.state &= ~DISABLE;
+ if ((c = pplex()) == '#')
+ {
+ c = pplex();
+ directive = INCLUDE;
+ }
+ if (c != T_DECIMAL && c != T_OCTAL)
+ {
+ error(1, "#%s: line number expected", dirname(LINE));
+ goto eatdirective;
+ }
+ linesync:
+ n = error_info.line;
+ error_info.line = strtol(pp.token, NiL, 0);
+ if (error_info.line == 0 && directive == LINE && (pp.state & STRICT) && !(pp.mode & HOSTED))
+ error(1, "#%s: line number should be > 0", dirname(LINE));
+ pp.state &= ~DISABLE;
+ pp.state |= STRIP;
+ switch (c = pplex())
+ {
+ case T_STRING:
+ s = error_info.file;
+ if (*(p = pp.token)) pathcanon(p, 0);
+ fp = ppsetfile(p);
+ error_info.file = fp->name;
+ if (error_info.line == 1)
+ ppmultiple(fp, INC_TEST);
+ switch (c = pplex())
+ {
+ case '\n':
+ break;
+ case T_DECIMAL:
+ case T_OCTAL:
+ if (directive == LINE && (pp.state & STRICT) && !(pp.mode & (HOSTED|RELAX)))
+ error(1, "#%s: integer file type argument is non-standard", dirname(LINE));
+ break;
+ default:
+ error(1, "#%s: integer file type argument expected", dirname(LINE));
+ break;
+ }
+ if (directive == LINE) pp.in->flags &= ~IN_ignoreline;
+ else if (pp.incref)
+ {
+ if (error_info.file != s)
+ {
+ switch (*pp.token)
+ {
+ case PP_sync_push:
+ if (pp.insert) (*pp.incref)(s, error_info.file, n, PP_SYNC_INSERT);
+ else (*pp.incref)(s, error_info.file, n, PP_SYNC_PUSH);
+ break;
+ case PP_sync_pop:
+ if (pp.insert) (*pp.incref)(s, error_info.file, n, PP_SYNC_INSERT);
+ else (*pp.incref)(s, error_info.file, n - 1, PP_SYNC_POP);
+ break;
+ case PP_sync_ignore:
+ if (pp.insert) (*pp.incref)(s, error_info.file, n, PP_SYNC_INSERT);
+ else
+ {
+ (*pp.incref)(s, error_info.file, n, PP_SYNC_IGNORE);
+ error_info.file = s;
+ }
+ break;
+ default:
+ if (*s)
+ {
+ if (fp == pp.insert)
+ pp.insert = 0;
+ else if (error_info.line == 1 && !pp.insert)
+ (*pp.incref)(s, error_info.file, n, PP_SYNC_PUSH);
+ else
+ {
+ if (!pp.insert) pp.insert = ppgetfile(s);
+ (*pp.incref)(s, error_info.file, n, PP_SYNC_INSERT);
+ }
+ }
+ break;
+ }
+ }
+ }
+ break;
+ case '\n':
+ break;
+ default:
+ error(1, "#%s: \"file-name\" expected", dirname(LINE));
+ break;
+ }
+ if (directive == LINE && (pp.in->flags & IN_ignoreline))
+ error_info.line = n + 1;
+ else
+ {
+ pp.hidden = 0;
+ pp.state &= ~HIDDEN;
+ if (pp.linesync)
+ {
+#if CATSTRINGS
+ if (pp.state & JOINING) pp.state |= HIDDEN|SYNCLINE;
+ else
+#endif
+ {
+ s = pp.lineid;
+ n = pp.flags;
+ if (directive == LINE)
+ {
+ pp.flags &= ~PP_linetype;
+ if (pp.macref) pp.lineid = dirname(LINE);
+ }
+ (*pp.linesync)(error_info.line, error_info.file);
+ pp.flags = n;
+ pp.lineid = s;
+ }
+ }
+ }
+ directive = LINE;
+ break;
+ case PRAGMA:
+ /*
+ * #pragma [STDC] [pass:] [no]option [arg ...]
+ *
+ * pragma args are not expanded by default
+ *
+ * if STDC is present then it is silently passed on
+ *
+ * if pass is pp.pass then the option is used
+ * and verified but is not passed on
+ *
+ * if pass is omitted then the option is passed on
+ *
+ * otherwise if pass is non-null and not pp.pass then
+ * the option is passed on but not used
+ *
+ * if the line does not match this form then
+ * it is passed on unchanged
+ *
+ * #directive pass: option [...]
+ * ^ ^ ^ ^ ^ ^ ^ ^
+ * pp.valbuf p0 p1 p2 p3 p4 p5 p6
+ *
+ * p? 0 if component omitted
+ * i0 0 if ``no''option
+ */
+
+ p = pp.valbuf;
+ *p++ = '#';
+ STRCOPY(p, pp.token, s);
+ p0 = p;
+ if (pp.option & PRAGMAEXPAND)
+ pp.state &= ~DISABLE;
+ if (!(p6 = getline(p, &pp.valbuf[MAXTOKEN], !!(pp.option & PRAGMAEXPAND))))
+ {
+ *p0 = 0;
+ error(2, "%s: directive too long", pp.valbuf);
+ c = 0;
+ goto eatdirective;
+ }
+ p1 = ++p;
+ while (ppisid(*p))
+ p++;
+ if (p == p1)
+ {
+ p5 = p;
+ p4 = 0;
+ p3 = 0;
+ p2 = 0;
+ p1 = 0;
+ }
+ else if (*p != ':')
+ {
+ p5 = *p ? p + (*p == ' ') : 0;
+ p4 = p;
+ p3 = p1;
+ p2 = 0;
+ p1 = 0;
+ }
+ else
+ {
+ p2 = p++;
+ p3 = p;
+ while (ppisid(*p))
+ p++;
+ if (p == p3)
+ {
+ p4 = p1;
+ p3 = 0;
+ p2 = 0;
+ p1 = 0;
+ }
+ else
+ p4 = p;
+ p5 = *p4 ? p4 + (*p4 == ' ') : 0;
+ }
+ if (!p1 && p3 && (p4 - p3) == 4 && strneq(p3, "STDC", 4))
+ goto pass;
+ if ((pp.state & WARN) && !(pp.mode & (HOSTED|RELAX)))
+ error(1, "#%s: non-standard directive", dirname(PRAGMA));
+ i0 = !p3 || *p3 != 'n' || *(p3 + 1) != 'o';
+ if (!p3)
+ goto checkmap;
+ if (p1)
+ {
+ *p2 = 0;
+ n = streq(p1, pp.pass);
+ *p2 = ':';
+ if (!n)
+ goto checkmap;
+ }
+ else
+ n = 0;
+ i2 = *p4;
+ *p4 = 0;
+ if (((i1 = (int)hashref(pp.strtab, p3 + (i0 ? 0 : 2))) < 1 || i1 > X_last_option) && (i0 || (i1 = (int)hashref(pp.strtab, p3)) > X_last_option))
+ i1 = 0;
+ if ((pp.state & (COMPATIBILITY|STRICT)) == STRICT && !(pp.mode & (HOSTED|RELAX)))
+ {
+ if (pp.optflags[i1] & OPT_GLOBAL)
+ goto donedirective;
+ if (n || (pp.mode & WARN))
+ {
+ n = 0;
+ error(1, "#%s: non-standard directive ignored", dirname(PRAGMA));
+ }
+ i1 = 0;
+ }
+ if (!n)
+ {
+ if (!(pp.optflags[i1] & OPT_GLOBAL))
+ {
+ *p4 = i2;
+ goto checkmap;
+ }
+ if (!(pp.optflags[i1] & OPT_PASS))
+ n = 1;
+ }
+ else if (!i1)
+ error(2, "%s: unknown option", p1);
+ else if ((pp.state & STRICT) && !(pp.mode & (HOSTED|RELAX)))
+ error(1, "%s: non-standard option", p1);
+ p = p5;
+ switch (i1)
+ {
+ case X_ALLMULTIPLE:
+ ppop(PP_MULTIPLE, i0);
+ break;
+ case X_ALLPOSSIBLE:
+ setoption(ALLPOSSIBLE, i0);
+ break;
+ case X_BUILTIN:
+ setmode(BUILTIN, i0);
+ break;
+ case X_CATLITERAL:
+ setmode(CATLITERAL, i0);
+ if (pp.mode & CATLITERAL)
+ setoption(STRINGSPLIT, 0);
+ break;
+ case X_CDIR:
+ tokop(PP_CDIR, p3, p, i0, TOKOP_UNSET|TOKOP_STRING|TOKOP_DUP);
+ break;
+ case X_CHECKPOINT:
+#if CHECKPOINT
+ ppload(p);
+#else
+ error(3, "%s: preprocessor not compiled with checkpoint enabled", p3);
+#endif
+ break;
+ case X_CHOP:
+ tokop(PP_CHOP, p3, p, i0, TOKOP_UNSET|TOKOP_STRING);
+ break;
+ case X_COMPATIBILITY:
+ ppop(PP_COMPATIBILITY, i0);
+ break;
+ case X_DEBUG:
+ error_info.trace = i0 ? (p ? -strtol(p, NiL, 0) : -1) : 0;
+ break;
+ case X_ELSEIF:
+ setoption(ELSEIF, i0);
+ break;
+ case X_EXTERNALIZE:
+ setmode(EXTERNALIZE, i0);
+ break;
+ case X_FINAL:
+ setoption(FINAL, i0);
+ break;
+ case X_HEADEREXPAND:
+ setoption(HEADEREXPAND, i0);
+ break;
+ case X_HEADEREXPANDALL:
+ setoption(HEADEREXPANDALL, i0);
+ break;
+ case X_HIDE:
+ case X_NOTE:
+ PUSH_LINE(p);
+ /* UNDENT...*/
+ while (c = pplex())
+ {
+ if (c != T_ID) error(1, "%s: %s: identifier expected", p3, pp.token);
+ else if (sym = ppsymset(pp.symtab, pp.token))
+ {
+ if (i1 == X_NOTE)
+ {
+ sym->flags &= ~SYM_NOTICED;
+ ppfsm(FSM_MACRO, sym->name);
+ }
+ else if (i0)
+ {
+ if (!sym->hidden && !(sym->hidden = newof(0, struct pphide, 1, 0)))
+ error(3, "out of space");
+ if (!sym->macro)
+ ppfsm(FSM_MACRO, sym->name);
+ if (!sym->hidden->level++)
+ {
+ pp.hiding++;
+ if (sym->macro && !(sym->flags & (SYM_ACTIVE|SYM_READONLY)))
+ {
+ sym->hidden->macro = sym->macro;
+ sym->macro = 0;
+ sym->hidden->flags = sym->flags;
+ sym->flags &= ~(SYM_BUILTIN|SYM_FUNCTION|SYM_INIT|SYM_MULTILINE|SYM_PREDEFINED|SYM_REDEFINE|SYM_VARIADIC);
+ }
+ }
+ }
+ else if (sym->hidden)
+ {
+ if ((mac = sym->macro) && !(sym->flags & (SYM_ACTIVE|SYM_READONLY)))
+ {
+ if (mac->formals) free(mac->formals);
+ free(mac->value);
+ free(mac);
+ sym->macro = 0;
+ sym->flags &= ~(SYM_BUILTIN|SYM_FUNCTION|SYM_INIT|SYM_MULTILINE|SYM_PREDEFINED|SYM_REDEFINE|SYM_VARIADIC);
+ }
+ if (!--sym->hidden->level)
+ {
+ pp.hiding--;
+ if (sym->hidden->macro)
+ {
+ sym->macro = sym->hidden->macro;
+ sym->flags = sym->hidden->flags;
+ }
+ free(sym->hidden);
+ sym->hidden = 0;
+ }
+ }
+ }
+ }
+ /*...INDENT*/
+ POP_LINE();
+ break;
+ case X_HOSTDIR:
+ tokop(PP_HOSTDIR, p3, p, i0, TOKOP_UNSET|TOKOP_STRING|TOKOP_DUP);
+ break;
+ case X_HOSTED:
+ setmode(HOSTED, i0);
+ break;
+ case X_HOSTEDTRANSITION:
+ setmode(HOSTEDTRANSITION, i0);
+ break;
+ case X_ID:
+ tokop(PP_ID, p3, p, i0, TOKOP_UNSET|TOKOP_STRING);
+ break;
+ case X_IGNORE:
+ tokop(PP_IGNORE, p3, p, i0, TOKOP_UNSET|TOKOP_STRING);
+ break;
+ case X_INCLUDE:
+ tokop(PP_INCLUDE, p3, p, i0, TOKOP_STRING|TOKOP_DUP);
+ break;
+ case X_INITIAL:
+ setoption(INITIAL, i0);
+ break;
+ case X_KEYARGS:
+ ppop(PP_KEYARGS, i0);
+ break;
+ case X_LINE:
+ if (pp.linesync) pp.olinesync = pp.linesync;
+ pp.linesync = i0 ? pp.olinesync : (PPLINESYNC)0;
+ break;
+ case X_LINEBASE:
+ ppop(PP_LINEBASE, i0);
+ break;
+ case X_LINEFILE:
+ ppop(PP_LINEFILE, i0);
+ break;
+ case X_LINEID:
+ ppop(PP_LINEID, i0 ? p : (char*)0);
+ break;
+ case X_LINETYPE:
+ ppop(PP_LINETYPE, i0 ? (p ? strtol(p, NiL, 0) : 1) : 0);
+ break;
+ case X_MACREF:
+ if (!p)
+ {
+ if (i0 && !pp.macref)
+ {
+ ppop(PP_LINETYPE, 1);
+ ppop(PP_MACREF, ppmacref);
+ }
+ else error(2, "%s: option cannot be unset", p3);
+ }
+ else if (s = strchr(p, ' '))
+ {
+ if (pp.macref && (s = strchr(p, ' ')))
+ {
+ *s++ = 0;
+ c = strtol(s, NiL, 0);
+ var.type = pp.truncate;
+ pp.truncate = PPTOKSIZ;
+ (*pp.macref)(pprefmac(p, REF_CREATE), error_info.file, error_info.line - (c == REF_NORMAL ? 2 : 1), c, (s = strchr(s, ' ')) ? strtol(s, NiL, 0) : 0L);
+ pp.truncate = var.type;
+ }
+ error_info.line -= 2;
+ }
+ break;
+ case X_MAP:
+ /*UNDENT*/
+ /*
+ * #pragma pp:map [id ...] "/from/[,/to/]" [ "/old/new/[glnu]" ... ]
+ */
+
+ if (!i0)
+ {
+ error(2, "%s: option cannot be unset", p3);
+ goto donedirective;
+ }
+ if (!p5)
+ {
+ error(2, "%s: address argument expected", p3);
+ goto donedirective;
+ }
+ PUSH_LINE(p5);
+ while ((c = pplex()) == T_ID)
+ {
+ sfsprintf(pp.tmpbuf, MAXTOKEN, "__%s__", s = pp.token);
+ if (c = (int)hashget(pp.dirtab, s))
+ {
+ hashput(pp.dirtab, 0, 0);
+ hashput(pp.dirtab, pp.tmpbuf, c);
+ }
+ if (c = (int)hashget(pp.strtab, s))
+ {
+ hashput(pp.strtab, 0, 0);
+ hashput(pp.strtab, pp.tmpbuf, c);
+ }
+ }
+ if (c != T_STRING || !*(s = pp.token))
+ {
+ if (c)
+ error(2, "%s: %s: address argument expected", p3, pptokstr(pp.token, 0));
+ goto eatmap;
+ }
+ map = newof(0, struct map, 1, 0);
+
+ /*
+ * /from/
+ */
+
+ if (i0 = regcomp(&map->re, s, REG_AUGMENTED|REG_DELIMITED|REG_LENIENT|REG_NULL))
+ regfatal(&map->re, 3, i0);
+ if (*(s += map->re.re_npat))
+ {
+ error(2, "%s: invalid characters after pattern: %s ", p3, s);
+ goto eatmap;
+ }
+
+ /*
+ * /old/new/[flags]
+ */
+
+ edit = 0;
+ while ((c = pplex()) == T_STRING)
+ {
+ if (!*(s = pp.token))
+ {
+ error(2, "%s: substitution argument expected", p3);
+ goto eatmap;
+ }
+ if (edit)
+ edit = edit->next = newof(0, struct edit, 1, 0);
+ else
+ edit = map->edit = newof(0, struct edit, 1, 0);
+ if (!(i0 = regcomp(&edit->re, s, REG_AUGMENTED|REG_DELIMITED|REG_LENIENT|REG_NULL)) && !(i0 = regsubcomp(&edit->re, s += edit->re.re_npat, NiL, 0, 0)))
+ s += edit->re.re_npat;
+ if (i0)
+ regfatal(&edit->re, 3, i0);
+ if (*s)
+ {
+ error(2, "%s: invalid characters after substitution: %s ", p3, s);
+ goto eatmap;
+ }
+ }
+ if (c)
+ {
+ error(2, "%s: %s: substitution argument expected", p3, pptokstr(pp.token, 0));
+ goto eatmap;
+ }
+ map->next = (struct map*)pp.maps;
+ pp.maps = (char*)map;
+ eatmap:
+ POP_LINE();
+ /*INDENT*/
+ break;
+ case X_MAPINCLUDE:
+ ppmapinclude(NiL, p5);
+ break;
+ case X_MODERN:
+ setoption(MODERN, i0);
+ break;
+ case X_MULTIPLE:
+ n = 1;
+ if (pp.in->type == IN_FILE)
+ ppmultiple(ppsetfile(error_info.file), i0 ? INC_CLEAR : INC_TEST);
+ break;
+ case X_NATIVE:
+ setoption(NATIVE, i0);
+ break;
+ case X_OPSPACE:
+ ppfsm(FSM_OPSPACE, i0 ? p4 : (char*)0);
+ break;
+ case X_PASSTHROUGH:
+ ppop(PP_PASSTHROUGH, i0);
+ break;
+ case X_PEDANTIC:
+ ppop(PP_PEDANTIC, i0);
+ break;
+ case X_PLUSCOMMENT:
+ ppop(PP_PLUSCOMMENT, i0);
+ break;
+ case X_PLUSPLUS:
+ ppop(PP_PLUSPLUS, i0);
+ break;
+ case X_PLUSSPLICE:
+ setoption(PLUSSPLICE, i0);
+ break;
+ case X_PRAGMAEXPAND:
+ setoption(PRAGMAEXPAND, i0);
+ break;
+ case X_PRAGMAFLAGS:
+ tokop(PP_PRAGMAFLAGS, p3, p, i0, 0);
+ break;
+ case X_PREDEFINED:
+ setoption(PREDEFINED, i0);
+ break;
+ case X_PREFIX:
+ setoption(PREFIX, i0);
+ break;
+ case X_PRESERVE:
+ setoption(PRESERVE, i0);
+ if (pp.option & PRESERVE)
+ {
+ setmode(CATLITERAL, 0);
+ ppop(PP_COMPATIBILITY, 1);
+ ppop(PP_TRANSITION, 0);
+ ppop(PP_PLUSCOMMENT, 1);
+ ppop(PP_SPACEOUT, 1);
+ setoption(STRINGSPAN, 1);
+ setoption(STRINGSPLIT, 0);
+ ppop(PP_HOSTDIR, "-", 1);
+ }
+ break;
+ case X_PROTOTYPED:
+ /*
+ * this option doesn't bump the token count
+ */
+
+ n = 1;
+ directive = ENDIF;
+#if PROTOTYPE
+ setoption(PROTOTYPED, i0);
+#else
+ error(1, "preprocessor not compiled with prototype conversion enabled");
+#endif
+ break;
+ case X_PROTO:
+ setoption(NOPROTO, !i0);
+ break;
+ case X_QUOTE:
+ tokop(PP_QUOTE, p3, p, i0, TOKOP_UNSET|TOKOP_STRING);
+ break;
+ case X_READONLY:
+ setmode(READONLY, i0);
+ break;
+ case X_REGUARD:
+ setoption(REGUARD, i0);
+ break;
+ case X_RESERVED:
+ tokop(PP_RESERVED, p3, p, i0, 0);
+ break;
+ case X_SPACEOUT:
+ if (!(pp.state & (COMPATIBILITY|COMPILE)))
+ ppop(PP_SPACEOUT, i0);
+ break;
+ case X_SPLICECAT:
+ setoption(SPLICECAT, i0);
+ break;
+ case X_SPLICESPACE:
+ setoption(SPLICESPACE, i0);
+ break;
+ case X_STANDARD:
+ tokop(PP_STANDARD, p3, p, i0, TOKOP_UNSET|TOKOP_STRING|TOKOP_DUP);
+ break;
+ case X_STRICT:
+ ppop(PP_STRICT, i0);
+ break;
+ case X_STRINGSPAN:
+ setoption(STRINGSPAN, i0);
+ break;
+ case X_STRINGSPLIT:
+ setoption(STRINGSPLIT, i0);
+ if (pp.option & STRINGSPLIT)
+ setmode(CATLITERAL, 0);
+ break;
+ case X_SYSTEM_HEADER:
+ if (i0)
+ {
+ pp.mode |= HOSTED;
+ pp.flags |= PP_hosted;
+ pp.in->flags |= IN_hosted;
+ }
+ else
+ {
+ pp.mode &= ~HOSTED;
+ pp.flags &= ~PP_hosted;
+ pp.in->flags &= ~PP_hosted;
+ }
+ break;
+ case X_TEST:
+ ppop(PP_TEST, p);
+ break;
+ case X_TEXT:
+ if (!(pp.option & KEEPNOTEXT))
+ setstate(NOTEXT, !i0);
+ break;
+ case X_TRANSITION:
+ ppop(PP_TRANSITION, i0);
+ if (pp.state & TRANSITION) ppop(PP_COMPATIBILITY, i0);
+ break;
+ case X_TRUNCATE:
+ ppop(PP_TRUNCATE, i0 ? (p ? strtol(p, NiL, 0) : TRUNCLENGTH) : 0);
+ break;
+ case X_VENDOR:
+ tokop(PP_VENDOR, p3, p, i0, TOKOP_UNSET|TOKOP_STRING|TOKOP_DUP);
+ break;
+ case X_VERSION:
+ if (!(*pp.control & SKIP) && pp.pragma && !(pp.state & NOTEXT))
+ {
+ sfsprintf(pp.tmpbuf, MAXTOKEN, "\"%s\"", pp.version);
+ (*pp.pragma)(dirname(PRAGMA), pp.pass, p3, pp.tmpbuf, !n);
+ if (pp.linesync && !n)
+ (*pp.linesync)(error_info.line, error_info.file);
+ emitted = 1;
+ }
+ break;
+ case X_WARN:
+ ppop(PP_WARN, i0);
+ break;
+ case X_ZEOF:
+ setoption(ZEOF, i0);
+ break;
+#if DEBUG
+ case 0:
+ case X_INCLUDED:
+ case X_NOTICED:
+ case X_OPTION:
+ case X_STATEMENT:
+ break;
+ default:
+ error(PANIC, "%s: option recognized but not implemented", pp.valbuf);
+ break;
+#endif
+ }
+ *p4 = i2;
+ if (!n)
+ goto checkmap;
+ goto donedirective;
+ case RENAME:
+ if ((pp.state & STRICT) && !(pp.mode & (HOSTED|RELAX)))
+ error(1, "#%s: non-standard directive", pp.token);
+ if ((c = pplex()) != T_ID)
+ {
+ error(1, "%s: invalid macro name", pptokstr(pp.token, 0));
+ goto eatdirective;
+ }
+ if (!(sym = pprefmac(pp.token, REF_DELETE)) || !sym->macro)
+ goto eatdirective;
+ if (sym->flags & (SYM_ACTIVE|SYM_READONLY))
+ {
+ if (!(pp.option & ALLPOSSIBLE))
+ error(2, "%s: macro is %s", sym->name, (sym->flags & SYM_READONLY) ? "readonly" : "active");
+ goto eatdirective;
+ }
+ if ((c = pplex()) != T_ID)
+ {
+ error(1, "%s: invalid macro name", pptokstr(pp.token, 0));
+ goto eatdirective;
+ }
+ var.symbol = pprefmac(pp.token, REF_CREATE);
+ if (mac = var.symbol->macro)
+ {
+ if (var.symbol->flags & (SYM_ACTIVE|SYM_READONLY))
+ {
+ if (!(pp.option & ALLPOSSIBLE))
+ error(2, "%s: macro is %s", var.symbol->name, (var.symbol->flags & SYM_READONLY) ? "readonly" : "active");
+ goto eatdirective;
+ }
+ if (!(pp.mode & HOSTED) || !(var.symbol->flags & SYM_INITIAL))
+ error(1, "%s redefined", var.symbol->name);
+ if (mac->formals) free(mac->formals);
+ free(mac->value);
+ free(mac);
+ }
+ ppfsm(FSM_MACRO, var.symbol->name);
+ var.symbol->flags = sym->flags;
+ sym->flags &= ~(SYM_BUILTIN|SYM_FUNCTION|SYM_INIT|SYM_MULTILINE|SYM_PREDEFINED|SYM_REDEFINE|SYM_VARIADIC);
+ var.symbol->macro = sym->macro;
+ sym->macro = 0;
+ break;
+ case UNDEF:
+ if ((c = pplex()) != T_ID)
+ {
+ error(1, "%s: invalid macro name", pptokstr(pp.token, 0));
+ goto eatdirective;
+ }
+ if (sym = pprefmac(pp.token, REF_DELETE))
+ {
+ if (mac = sym->macro)
+ {
+ if (sym->flags & (SYM_ACTIVE|SYM_READONLY))
+ {
+ if (!(pp.option & ALLPOSSIBLE))
+ error(2, "%s: macro is %s", sym->name, (sym->flags & SYM_READONLY) ? "readonly" : "active");
+ goto eatdirective;
+ }
+ if (mac->formals) free(mac->formals);
+ free(mac->value);
+ free(mac);
+ mac = sym->macro = 0;
+ }
+ if ((pp.option & (DEFINITIONS|PREDEFINITIONS|REGUARD)) && !sym->hidden && !(sym->flags & SYM_MULTILINE) && ((pp.option & PREDEFINITIONS) || !(pp.mode & INIT)) && ((pp.option & (DEFINITIONS|PREDEFINITIONS)) || !(pp.state & NOTEXT)))
+ {
+ ppsync();
+ ppprintf("#%s %s", dirname(UNDEF), sym->name);
+ emitted = 1;
+ }
+ sym->flags &= ~(SYM_BUILTIN|SYM_FUNCTION|SYM_INIT|SYM_MULTILINE|SYM_PREDEFINED|SYM_REDEFINE|SYM_VARIADIC);
+ n2 = error_info.line;
+ goto benign;
+ }
+ else pprefmac(pp.token, REF_UNDEF);
+ break;
+#if DEBUG
+ default:
+ error(PANIC, "#%s: directive recognized but not implemented", pp.token);
+ goto eatdirective;
+#endif
+ }
+ break;
+ case '\n':
+ break;
+ default:
+ error(1, "%s: invalid directive name", pptokstr(pp.token, 0));
+ goto eatdirective;
+ }
+ enddirective:
+#if COMPATIBLE
+ if (c != '\n' && !(pp.state & COMPATIBILITY))
+#else
+ if (c != '\n')
+#endif
+ {
+ pp.state |= DISABLE|NOSPACE;
+ if ((c = pplex()) != '\n' && (pp.mode & (HOSTED|PEDANTIC)) == PEDANTIC)
+ error(1, "%s: invalid characters after directive", pptokstr(pp.token, 0));
+ }
+ eatdirective:
+ if (c != '\n')
+ {
+ pp.state |= DISABLE;
+ while (pplex() != '\n');
+ }
+ donedirective:
+#if _HUH_2002_05_09
+ if (!(pp.state & EOF2NL))
+ error(2, "%s in directive", pptokchr(0));
+#endif
+ pp.state &= ~RESTORE;
+ pp.mode &= ~RELAX;
+ if (!(*pp.control & SKIP))
+ {
+ pp.state |= restore;
+ switch (directive)
+ {
+ case LINE:
+ return 0;
+ case INCLUDE:
+ if (pp.include)
+ {
+ error_info.line++;
+ PUSH_FILE(pp.include, n);
+ if (!pp.vendor && (pp.found->type & TYPE_VENDOR))
+ pp.vendor = 1;
+ pp.include = 0;
+ return 0;
+ }
+ if (pp.incref)
+ (*pp.incref)(error_info.file, ppgetfile(pp.path)->name, error_info.line, PP_SYNC_IGNORE);
+ else if (pp.linesync && pp.macref)
+ {
+ pp.flags |= PP_lineignore;
+ (*pp.linesync)(error_info.line, ppgetfile(pp.path)->name);
+ }
+ /*FALLTHROUGH*/
+ default:
+ pp.in->flags |= IN_tokens;
+ /*FALLTHROUGH*/
+ case ENDIF:
+ error_info.line++;
+ if (emitted)
+ {
+ ppputchar('\n');
+ ppcheckout();
+ }
+ else
+ {
+ pp.state |= HIDDEN;
+ pp.hidden++;
+ }
+ return 0;
+ }
+ }
+ pp.state |= restore|HIDDEN|SKIPCONTROL;
+ pp.hidden++;
+ pp.level++;
+ error_info.line++;
+ return 0;
+}
+
+/*
+ * grow the pp nesting control stack
+ */
+
+void
+ppnest(void)
+{
+ register struct ppinstk* ip;
+ int oz;
+ int nz;
+ long adjust;
+ long* op;
+ long* np;
+
+ oz = pp.constack;
+ op = pp.maxcon - oz + 1;
+ nz = oz * 2;
+ np = newof(op, long, nz, 0);
+ if (adjust = (np - op))
+ {
+ ip = pp.in;
+ do
+ {
+ if (ip->control)
+ ip->control += adjust;
+ } while (ip = ip->prev);
+ }
+ pp.control = np + oz;
+ pp.constack = nz;
+ pp.maxcon = np + nz - 1;
+}
diff --git a/usr/src/lib/libpp/common/ppcpp.c b/usr/src/lib/libpp/common/ppcpp.c
new file mode 100644
index 0000000000..23e3fe7541
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppcpp.c
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * standalone preprocessor lexical analyzer
+ */
+
+#define CPP 1
+
+#include "pplex.c"
diff --git a/usr/src/lib/libpp/common/ppdata.c b/usr/src/lib/libpp/common/ppdata.c
new file mode 100644
index 0000000000..4c15eaf940
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppdata.c
@@ -0,0 +1,179 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * preprocessor data
+ *
+ * intended to be a conforming implementation of the translation phases
+ * (2.1.1.2) 1,2,3,4 and 6 of the "American National Standard for
+ * Information Systems -- Programming Language -- C", ANSI X3.159-1989.
+ *
+ * STANDARD INTERPRETATION:
+ *
+ * include files are forced to preserve #if nesting levels
+ * support for this is found in the recursive description for
+ * include file processing in the translation phases
+ *
+ * ID"..." produces two tokens: {ID}{"..."}
+ * ID'...' produces two tokens: {ID}{'...'}
+ *
+ * COMPATIBILITY:
+ *
+ * only sane Reiser compatibility is implemented
+ *
+ * strange handling of `\newline', especially in directives,
+ * is not implemented
+ *
+ * dissappearing comments used as concatenation operators work
+ * only within macro bodies
+ */
+
+static const char id[] = "\n@(#)$Id: libpp (AT&T Research) 2006-11-23 $\0\n";
+
+#include "pplib.h"
+
+#ifndef IDNAME
+#define IDNAME "pp"
+#endif
+
+static char addbuf[MAXTOKEN+1]; /* ADD buffer */
+static char argsbuf[MAXTOKEN+1]; /* predicate args */
+static char catbuf[MAXTOKEN+1]; /* catenation buffer */
+static char hidebuf[MAXTOKEN+1]; /* pp:hide buffer */
+static char outbuf[2*(PPBUFSIZ+MAXTOKEN)];/* output buffer */
+static char pathbuf[MAXTOKEN+1]; /* full path of last #include */
+static char tmpbuf[MAXTOKEN+1]; /* very temporary buffer */
+static char tokbuf[2*MAXTOKEN+1]; /* token buffer */
+static char valbuf[MAXTOKEN+1]; /* builtin macro value buffer */
+
+static char optflags[X_last_option+1];/* OPT_* flags indexed by X_* */
+
+static char null[1];
+
+static struct ppinstk instack = /* input stream stack */
+{
+ &null[0] /* nextchr */
+};
+
+static struct ppdirs stddir = /* standard include directory */
+{
+ PPSTANDARD, 0, 1, INC_STANDARD, TYPE_INCLUDE|TYPE_DIRECTORY|TYPE_HOSTED
+};
+
+static struct ppdirs firstdir = /* first include directory */
+{
+ "", &stddir, 0, INC_PREFIX, TYPE_INCLUDE|TYPE_DIRECTORY
+};
+
+struct ppglobals pp =
+{
+ /* public globals */
+
+ &id[10], /* version */
+ "", /* lineid */
+ "/dev/stdout", /* outfile */
+ IDNAME, /* pass */
+ &tokbuf[0], /* token */
+ 0, /* symbol */
+
+ /* exposed for the output macros */
+
+ &outbuf[0], /* outb */
+ &outbuf[0], /* outbuf */
+ &outbuf[0], /* outp */
+ &outbuf[PPBUFSIZ], /* oute */
+ 0, /* offset */
+
+ /* public context */
+
+ &firstdir, /* lcldirs */
+ &firstdir, /* stddirs */
+ 0, /* flags */
+ 0, /* symtab */
+
+ /* private context */
+
+ 0, /* context */
+ 0, /* state */
+ ALLMULTIPLE|CATLITERAL, /* mode */
+ PREFIX, /* option */
+ 0, /* test */
+ 0, /* filedeps.sp */
+ 0, /* filedeps.flags */
+ &firstdir, /* firstdir */
+ &firstdir, /* lastdir */
+ 0, /* hide */
+ 0, /* column */
+ -1, /* pending */
+ 0, /* firstfile */
+ 0, /* lastfile */
+ 0, /* ignore */
+ 0, /* probe */
+ 0, /* filtab */
+ 0, /* prdtab */
+ 0, /* date */
+ 0, /* time */
+ 0, /* maps */
+ 0, /* ro_state */
+ 0, /* ro_mode */
+ 0, /* ro_option */
+ {0}, /* cdir */
+ {0}, /* hostdir */
+ 0, /* ppdefault */
+ 0, /* firstindex */
+ 0, /* lastindex */
+ 0, /* firstop */
+ 0, /* lastop */
+ 0, /* firsttx */
+ 0, /* lasttx */
+ 0, /* arg_file */
+ 0, /* arg_mode */
+ 0, /* arg_style */
+ 0, /* c */
+ 0, /* hosted */
+ 0, /* ignoresrc */
+ 0, /* initialized */
+ 0, /* standalone */
+ 0, /* spare_1 */
+
+ /* library private globals */
+
+ "\"08/11/94\"", /* checkpoint (with quotes!) */
+ 128, /* constack */
+ &instack, /* in */
+ &addbuf[0], /* addp */
+ &argsbuf[0], /* args */
+ &addbuf[0], /* addbuf */
+ &catbuf[0], /* catbuf */
+ 0, /* hdrbuf */
+ &hidebuf[0], /* hidebuf */
+ &pathbuf[0], /* path */
+ &tmpbuf[0], /* tmpbuf */
+ &valbuf[0], /* valbuf */
+ &optflags[0], /* optflags */
+ '\n', /* lastout */
+
+ /* the rest are implicitly initialized */
+};
+
+char ppctype[UCHAR_MAX];
diff --git a/usr/src/lib/libpp/common/pperror.c b/usr/src/lib/libpp/common/pperror.c
new file mode 100644
index 0000000000..46f7442ec7
--- /dev/null
+++ b/usr/src/lib/libpp/common/pperror.c
@@ -0,0 +1,38 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * preprocessor error handler
+ */
+
+#include "pplib.h"
+
+void
+pperror(int level, ...)
+{
+ va_list ap;
+
+ va_start(ap, level);
+ errorv(pp.pass, level, ap);
+ va_end(ap);
+}
diff --git a/usr/src/lib/libpp/common/ppexpr.c b/usr/src/lib/libpp/common/ppexpr.c
new file mode 100644
index 0000000000..5fd93afde5
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppexpr.c
@@ -0,0 +1,697 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * preprocessor expression evaluation support
+ */
+
+#include "pplib.h"
+
+#include <regex.h>
+
+#define lex(c) ((((c)=peektoken)>=0?(peektoken=(-1)):((c)=pplex())),(c))
+#define unlex(c) (peektoken=(c))
+
+static int peektoken; /* expression lookahead token */
+static char* errmsg; /* subexpr() error message */
+
+/*
+ * exists predicate evaluation
+ */
+
+static int
+exists(int op, char* pred, register char* args)
+{
+ register int c;
+ register int type;
+ char* pptoken;
+ long state;
+ char file[MAXTOKEN + 1];
+
+ state = (pp.state & ~DISABLE);
+ PUSH_STRING(args);
+ pptoken = pp.token;
+ pp.token = file;
+ pp.state |= HEADER|PASSEOF;
+ type = pplex();
+ pp.state &= ~HEADER;
+ pp.token = pptoken;
+ switch (type)
+ {
+ case T_STRING:
+ case T_HEADER:
+ break;
+ default:
+ error(1, "%s: \"...\" or <...> argument expected", pred);
+ c = 0;
+ goto done;
+ }
+ if (op == X_EXISTS)
+ {
+ if ((c = pplex()) == ',')
+ {
+ while ((c = pplex()) == T_STRING)
+ {
+ if (pathaccess(pp.path, pp.token, file, NiL, 0))
+ {
+ pathcanon(pp.path, 0);
+ message((-2, "%s: %s found", pred, pp.path));
+ c = 1;
+ goto done;
+ }
+ if ((c = pplex()) != ',') break;
+ }
+ if (c) error(1, "%s: \"...\" arguments expected", pred);
+ strcpy(pp.path, file);
+ message((-2, "%s: %s not found", pred, file));
+ c = 0;
+ }
+ else c = ppsearch(file, type, SEARCH_EXISTS) >= 0;
+ }
+ else
+ {
+ register struct ppfile* fp;
+
+ fp = ppsetfile(file);
+ c = fp->flags || fp->guard == INC_IGNORE;
+ }
+ done:
+ while (pplex());
+ pp.state = state;
+ return c;
+}
+
+/*
+ * strcmp/match predicate evaluation
+ */
+
+static int
+compare(char* pred, char* args, int match)
+{
+ register int c;
+ char* pptoken;
+ long state;
+ regex_t re;
+ char tmp[MAXTOKEN + 1];
+
+ state = (pp.state & ~DISABLE);
+ PUSH_STRING(args);
+ pp.state |= PASSEOF;
+ pptoken = pp.token;
+ pp.token = tmp;
+ if (!pplex())
+ goto bad;
+ pp.token = pptoken;
+ if (pplex() != ',' || !pplex())
+ goto bad;
+ if (!match)
+ c = strcmp(tmp, pp.token);
+ else if ((c = regcomp(&re, pp.token, REG_AUGMENTED|REG_LENIENT|REG_NULL)) || (c = regexec(&re, tmp, NiL, 0, 0)) && c != REG_NOMATCH)
+ regfatal(&re, 3, c);
+ else
+ {
+ c = !c;
+ regfree(&re);
+ }
+ if ((pp.state & PASSEOF) && pplex())
+ goto bad;
+ pp.state = state;
+ return c;
+ bad:
+ pp.token = pptoken;
+ error(2, "%s: 2 arguments expected", pred);
+ while (pplex());
+ pp.state = state;
+ return 0;
+}
+
+/*
+ * #if predicate parse and evaluation
+ */
+
+static int
+predicate(int warn)
+{
+ register char* args;
+ register struct pplist* p;
+ register struct ppsymbol* sym;
+ register int type;
+ int index;
+
+ static char pred[MAXID + 1];
+
+ /*
+ * first gather the args
+ */
+
+ index = (int)hashref(pp.strtab, pp.token);
+ if (warn && peekchr() != '(') switch (index)
+ {
+ case X_DEFINED:
+ case X_EXISTS:
+ case X_INCLUDED:
+ case X_MATCH:
+ case X_NOTICED:
+ case X_OPTION:
+ case X_SIZEOF:
+ case X_STRCMP:
+ break;
+ default:
+ if (pp.macref) pprefmac(pp.token, REF_IF);
+ return 0;
+ }
+ strcpy(pred, pp.token);
+ pp.state |= DISABLE;
+ type = pppredargs();
+ pp.state &= ~DISABLE;
+ switch (type)
+ {
+ case T_ID:
+ case T_STRING:
+ break;
+ default:
+ unlex(type);
+ /*FALLTHROUGH*/
+ case 0:
+ if (index && !(pp.state & STRICT))
+ error(1, "%s: predicate argument expected", pred);
+ if (pp.macref) pprefmac(pred, REF_IF);
+ return 0;
+ }
+ args = pp.args;
+
+ /*
+ * now evaluate
+ */
+
+ debug((-6, "pred=%s args=%s", pred, args));
+ if ((pp.state & STRICT) && !(pp.mode & HOSTED)) switch (index)
+ {
+ case X_DEFINED:
+ case X_SIZEOF:
+ break;
+ default:
+ error(1, "%s(%s): non-standard predicate test", pred, args);
+ return 0;
+ }
+ switch (index)
+ {
+ case X_DEFINED:
+ if (type != T_ID) error(1, "%s: identifier argument expected", pred);
+ else if ((sym = pprefmac(args, REF_IF)) && sym->macro) return 1;
+ else if (args[0] == '_' && args[1] == '_' && !strncmp(args, "__STDPP__", 9))
+ {
+ if (pp.hosted == 1 && pp.in->prev->type == IN_FILE)
+ {
+ pp.mode |= HOSTED;
+ pp.flags |= PP_hosted;
+ }
+ return *(args + 9) ? (int)hashref(pp.strtab, args + 9) : 1;
+ }
+ break;
+ case X_EXISTS:
+ case X_INCLUDED:
+ return exists(index, pred, args);
+ case X_MATCH:
+ case X_STRCMP:
+ return compare(pred, args, index == X_MATCH);
+ case X_NOTICED:
+ if (type != T_ID) error(1, "%s: identifier argument expected", pred);
+ else if (((sym = pprefmac(args, REF_IF)) || (sym = ppsymref(pp.symtab, args))) && (sym->flags & SYM_NOTICED)) return 1;
+ break;
+ case X_OPTION:
+ return ppoption(args);
+ case X_SIZEOF:
+ error(2, "%s invalid in #%s expressions", pred, dirname(IF));
+ break;
+ default:
+ if (warn && !(pp.mode & HOSTED) && (sym = ppsymref(pp.symtab, pred)) && (sym->flags & SYM_PREDICATE))
+ error(1, "use #%s(%s) to disambiguate", pred, args);
+ if (p = (struct pplist*)hashget(pp.prdtab, pred))
+ {
+ if (!*args) return 1;
+ while (p)
+ {
+ if (streq(p->value, args)) return 1;
+ p = p->next;
+ }
+ }
+ break;
+ }
+ return 0;
+}
+
+/*
+ * evaluate a long integer subexpression with precedence
+ * taken from the library routine streval()
+ * may be called recursively
+ *
+ * NOTE: all operands are evaluated as both the parse
+ * and evaluation are done on the fly
+ */
+
+static long
+subexpr(register int precedence, int* pun)
+{
+ register int c;
+ register long n;
+ register long x;
+ register int operand = 1;
+ int un = 0;
+ int xn;
+
+ switch (lex(c))
+ {
+ case 0:
+ case '\n':
+ unlex(c);
+ if (!errmsg && !(pp.mode & INACTIVE)) errmsg = "more tokens expected";
+ return 0;
+ case '-':
+ n = -subexpr(13, &un);
+ break;
+ case '+':
+ n = subexpr(13, &un);
+ break;
+ case '!':
+ n = !subexpr(13, &un);
+ break;
+ case '~':
+ n = ~subexpr(13, &un);
+ break;
+ default:
+ unlex(c);
+ n = 0;
+ operand = 0;
+ break;
+ }
+ un <<= 1;
+ for (;;)
+ {
+ switch (lex(c))
+ {
+ case 0:
+ case '\n':
+ goto done;
+ case ')':
+ if (!precedence)
+ {
+ if (!errmsg && !(pp.mode & INACTIVE)) errmsg = "too many )'s";
+ return 0;
+ }
+ goto done;
+ case '(':
+ n = subexpr(1, &un);
+ if (lex(c) != ')')
+ {
+ unlex(c);
+ if (!errmsg && !(pp.mode & INACTIVE)) errmsg = "closing ) expected";
+ return 0;
+ }
+ gotoperand:
+ if (operand)
+ {
+ if (!errmsg && !(pp.mode & INACTIVE)) errmsg = "operator expected";
+ return 0;
+ }
+ operand = 1;
+ un <<= 1;
+ continue;
+ case '?':
+ if (precedence > 1) goto done;
+ un = 0;
+ if (lex(c) == ':')
+ {
+ if (!n) n = subexpr(2, &un);
+ else
+ {
+ x = pp.mode;
+ pp.mode |= INACTIVE;
+ subexpr(2, &xn);
+ pp.mode = x;
+ }
+ }
+ else
+ {
+ unlex(c);
+ x = subexpr(2, &xn);
+ if (lex(c) != ':')
+ {
+ unlex(c);
+ if (!errmsg && !(pp.mode & INACTIVE)) errmsg = ": expected for ? operator";
+ return 0;
+ }
+ if (n)
+ {
+ n = x;
+ un = xn;
+ subexpr(2, &xn);
+ }
+ else n = subexpr(2, &un);
+ }
+ break;
+ case ':':
+ goto done;
+ case T_ANDAND:
+ case T_OROR:
+ xn = (c == T_ANDAND) ? 4 : 3;
+ if (precedence >= xn) goto done;
+ if ((n != 0) == (c == T_ANDAND)) n = subexpr(xn, &un) != 0;
+ else
+ {
+ x = pp.mode;
+ pp.mode |= INACTIVE;
+ subexpr(xn, &un);
+ pp.mode = x;
+ }
+ un = 0;
+ break;
+ case '|':
+ if (precedence > 4) goto done;
+ n |= subexpr(5, &un);
+ break;
+ case '^':
+ if (precedence > 5) goto done;
+ n ^= subexpr(6, &un);
+ break;
+ case '&':
+ if (precedence > 6) goto done;
+ n &= subexpr(7, &un);
+ break;
+ case T_EQ:
+ case T_NE:
+ if (precedence > 7) goto done;
+ n = (n == subexpr(8, &un)) == (c == T_EQ);
+ un = 0;
+ break;
+ case '<':
+ case T_LE:
+ case T_GE:
+ case '>':
+ if (precedence > 8) goto done;
+ x = subexpr(9, &un);
+ switch (c)
+ {
+ case '<':
+ switch (un)
+ {
+ case 01:
+ n = n < (unsigned long)x;
+ break;
+ case 02:
+ n = (unsigned long)n < x;
+ break;
+ case 03:
+ n = (unsigned long)n < (unsigned long)x;
+ break;
+ default:
+ n = n < x;
+ break;
+ }
+ break;
+ case T_LE:
+ switch (un)
+ {
+ case 01:
+ n = n <= (unsigned long)x;
+ break;
+ case 02:
+ n = (unsigned long)n <= x;
+ break;
+ case 03:
+ n = (unsigned long)n <= (unsigned long)x;
+ break;
+ default:
+ n = n <= x;
+ break;
+ }
+ break;
+ case T_GE:
+ switch (un)
+ {
+ case 01:
+ n = n >= (unsigned long)x;
+ break;
+ case 02:
+ n = (unsigned long)n >= x;
+ break;
+ case 03:
+ n = (unsigned long)n >= (unsigned long)x;
+ break;
+ default:
+ n = n >= x;
+ break;
+ }
+ break;
+ case '>':
+ switch (un)
+ {
+ case 01:
+ n = n > (unsigned long)x;
+ break;
+ case 02:
+ n = (unsigned long)n > x;
+ break;
+ case 03:
+ n = (unsigned long)n > (unsigned long)x;
+ break;
+ default:
+ n = n > x;
+ break;
+ }
+ break;
+ }
+ un = 0;
+ break;
+ case T_LSHIFT:
+ case T_RSHIFT:
+ if (precedence > 9) goto done;
+ x = subexpr(10, &un);
+ if (c == T_LSHIFT) n <<= x;
+ else n >>= x;
+ un >>= 1;
+ break;
+ case '+':
+ case '-':
+ if (precedence > 10) goto done;
+ x = subexpr(11, &un);
+ if (c == '+') n += x;
+ else n -= x;
+ break;
+ case '*':
+ case '/':
+ case '%':
+ if (precedence > 11) goto done;
+ x = subexpr(12, &un);
+ if (c == '*') n *= x;
+ else if (x == 0)
+ {
+ if (!errmsg && !(pp.mode & INACTIVE)) errmsg = "divide by zero";
+ return 0;
+ }
+ else if (c == '/') n /= x;
+ else n %= x;
+ break;
+ case '#':
+ pp.state |= DISABLE;
+ c = pplex();
+ pp.state &= ~DISABLE;
+ if (c != T_ID)
+ {
+ if (!errmsg && !(pp.mode & INACTIVE)) errmsg = "# must precede a predicate identifier";
+ return 0;
+ }
+ n = predicate(0);
+ goto gotoperand;
+ case T_ID:
+ n = predicate(1);
+ goto gotoperand;
+ case T_CHARCONST:
+ c = *(pp.toknxt - 1);
+ *(pp.toknxt - 1) = 0;
+ n = chrtoi(pp.token + 1);
+ *(pp.toknxt - 1) = c;
+ if (n & ~((1<<CHAR_BIT)-1))
+ {
+ if (!(pp.mode & HOSTED))
+ error(1, "'%s': multi-character character constants are not portable", pp.token);
+ }
+#if CHAR_MIN < 0
+ else n = (char)n;
+#endif
+ goto gotoperand;
+ case T_DECIMAL_U:
+ case T_DECIMAL_UL:
+ case T_OCTAL_U:
+ case T_OCTAL_UL:
+ case T_HEXADECIMAL_U:
+ case T_HEXADECIMAL_UL:
+ un |= 01;
+ /*FALLTHROUGH*/
+ case T_DECIMAL:
+ case T_DECIMAL_L:
+ case T_OCTAL:
+ case T_OCTAL_L:
+ case T_HEXADECIMAL:
+ case T_HEXADECIMAL_L:
+ n = strtoul(pp.token, NiL, 0);
+ if ((unsigned long)n > LONG_MAX) un |= 01;
+ goto gotoperand;
+ case T_WCHARCONST:
+ n = chrtoi(pp.token);
+ goto gotoperand;
+ default:
+ if (!errmsg && !(pp.mode & INACTIVE)) errmsg = "invalid token";
+ return 0;
+ }
+ if (errmsg) return 0;
+ if (!operand) goto nooperand;
+ }
+ done:
+ unlex(c);
+ if (!operand)
+ {
+ nooperand:
+ if (!errmsg && !(pp.mode & INACTIVE)) errmsg = "operand expected";
+ return 0;
+ }
+ if (un) *pun |= 01;
+ return n;
+}
+
+/*
+ * preprocessor expression evaluator using modified streval(3)
+ * *pun!=0 if result is unsigned
+ */
+
+long
+ppexpr(int* pun)
+{
+ long n;
+ int opeektoken;
+ long ppstate;
+
+ ppstate = (pp.state & (CONDITIONAL|DISABLE|NOSPACE|STRIP));
+ pp.state &= ~(DISABLE|STRIP);
+ pp.state |= CONDITIONAL|NOSPACE;
+ opeektoken = peektoken;
+ peektoken = -1;
+ *pun = 0;
+ n = subexpr(0, pun);
+ if (peektoken == ':' && !errmsg && !(pp.mode & INACTIVE)) errmsg = "invalid use of :";
+ if (errmsg)
+ {
+ error(2, "%s in expression", errmsg);
+ errmsg = 0;
+ n = 0;
+ }
+ peektoken = opeektoken;
+ pp.state &= ~(CONDITIONAL|NOSPACE);
+ pp.state |= ppstate;
+ if (*pun) debug((-4, "ppexpr() = %luU", n));
+ else debug((-4, "ppexpr() = %ld", n));
+ return n;
+}
+
+/*
+ * return non-zero if option s is set
+ */
+
+int
+ppoption(char* s)
+{
+ switch ((int)hashget(pp.strtab, s))
+ {
+ case X_ALLMULTIPLE:
+ return pp.mode & ALLMULTIPLE;
+ case X_BUILTIN:
+ return pp.mode & BUILTIN;
+ case X_CATLITERAL:
+ return pp.mode & CATLITERAL;
+ case X_COMPATIBILITY:
+ return pp.state & COMPATIBILITY;
+ case X_DEBUG:
+ return -error_info.trace;
+ case X_ELSEIF:
+ return pp.option & ELSEIF;
+ case X_FINAL:
+ return pp.option & FINAL;
+ case X_HOSTDIR:
+ return pp.mode & HOSTED;
+ case X_HOSTED:
+ return pp.flags & PP_hosted;
+ case X_INITIAL:
+ return pp.option & INITIAL;
+ case X_KEYARGS:
+ return pp.option & KEYARGS;
+ case X_LINEBASE:
+ return pp.flags & PP_linebase;
+ case X_LINEFILE:
+ return pp.flags & PP_linefile;
+ case X_LINETYPE:
+ return pp.flags & PP_linetype;
+ case X_PLUSCOMMENT:
+ return pp.option & PLUSCOMMENT;
+ case X_PLUSPLUS:
+ return pp.option & PLUSPLUS;
+ case X_PLUSSPLICE:
+ return pp.option & PLUSSPLICE;
+ case X_PRAGMAEXPAND:
+ return pp.option & PRAGMAEXPAND;
+ case X_PREDEFINED:
+ return pp.option & PREDEFINED;
+ case X_PREFIX:
+ return pp.option & PREFIX;
+ case X_PROTOTYPED:
+ return pp.option & PROTOTYPED;
+ case X_READONLY:
+ return pp.mode & READONLY;
+ case X_REGUARD:
+ return pp.option & REGUARD;
+ case X_SPACEOUT:
+ return pp.state & SPACEOUT;
+ case X_SPLICECAT:
+ return pp.option & SPLICECAT;
+ case X_SPLICESPACE:
+ return pp.option & SPLICESPACE;
+ case X_STRICT:
+ return pp.state & STRICT;
+ case X_STRINGSPAN:
+ return pp.option & STRINGSPAN;
+ case X_STRINGSPLIT:
+ return pp.option & STRINGSPLIT;
+ case X_TEST:
+ return pp.test;
+ case X_TEXT:
+ return !(pp.state & NOTEXT);
+ case X_TRANSITION:
+ return pp.state & TRANSITION;
+ case X_TRUNCATE:
+ return pp.truncate;
+ case X_WARN:
+ return pp.state & WARN;
+ default:
+ if (pp.state & WARN) error(1, "%s: unknown option name", s);
+ return 0;
+ }
+}
diff --git a/usr/src/lib/libpp/common/ppfsm.c b/usr/src/lib/libpp/common/ppfsm.c
new file mode 100644
index 0000000000..5cef65db2a
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppfsm.c
@@ -0,0 +1,946 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * preprocessor and proto lexical analyzer fsm
+ * define PROTOMAIN for standalone proto
+ */
+
+#include "pplib.h"
+#include "ppfsm.h"
+
+/*
+ * lexical FSM encoding
+ * derived from a standalone ansi cpp by Dennis Ritchie
+ * modified for libpp by Glenn Fowler
+ *
+ * fsm[] is initialized from fsminit[]. The encoding is blown out into
+ * fsm[] for time efficiency. When in state state, and one of the
+ * characters in ch arrives, enter nextstate. States >= TERMINAL are
+ * either final, or at least require special action. In fsminit[] there
+ * is a line for each <state,charset,nextstate>. Early entries are
+ * overwritten by later ones. C_XXX is the universal set and should
+ * always be first. Some of the fsminit[] entries are templates for
+ * groups of states. The OP entries trigger the state copies. States
+ * above TERMINAL are represented in fsm[] as negative values. S_TOK and
+ * S_TOKB encode the resulting token type in the upper bits. These actions
+ * differ in that S_TOKB has a lookahead char.
+ *
+ * fsm[] has three start states:
+ *
+ * PROTO proto (ANSI -> K&R,C++,ANSI)
+ * QUICK standalone ppcpp()
+ * TOKEN tokenizing pplex()
+ *
+ * If the next state remains the same then the fsm[] transition value is 0.
+ * MAX+1 is a power of 2 so that fsm[state][EOF==MAX+1] actually accesses
+ * fsm[state+1][0] which is ~S_EOB for all states. This preserves the
+ * power of 2 fsm[] row size for efficient array indexing. Thanks to
+ * D. G. Korn for the last two observations. The pseudo non-terminal state
+ * fsm[TERMINAL][state+1] is used to differentiate EOB from EOF.
+ *
+ * The bit layout is:
+ *
+ * TERM arg SPLICE next
+ * 15 14-8 7 6-0
+ */
+
+/*
+ * NOTE: these must be `control' characters for all native codesets
+ * currently ok for {ascii,ebcdic1,ebcdic2,ebcdic3}
+ */
+
+#define C_DEC 001
+#define C_EOF 002
+#define C_HEX 003
+#define C_LET 021
+#define C_OCT 022
+#define C_XXX 023
+
+#define OP (-1)
+#define END 0
+#define COPY 1
+
+#define copy(t,f) (memcpy(&fsm[t][1],&fsm[f][1],(MAX+1)*sizeof(short)),fsm[TERMINAL][(t)+1]=fsm[TERMINAL][(f)+1])
+
+struct fsminit /* fsm initialization row */
+{
+ int state; /* if in this state */
+ unsigned char ch[4]; /* and see one of these */
+ int nextstate; /* enter this state if <TERMINAL*/
+};
+
+static struct fsminit fsminit[] =
+{
+ /* proto start state */
+ { PROTO, { C_XXX }, S_CHR, },
+ { PROTO, { C_EOF }, S_EOF, },
+ { PROTO, { C_DEC }, BAD1, },
+ { PROTO, { '.' }, DOT, },
+ { PROTO, { C_LET }, NID, },
+ { PROTO, { 'L' }, LIT, },
+ { PROTO, { 'd', 'e', 'f', 'i' }, RES1, },
+ { PROTO, { 'r', 's', 't', 'v' }, RES1, },
+ { PROTO, { 'w', 'N' }, RES1, },
+ { PROTO, { '"', '\'' }, S_LITBEG, },
+ { PROTO, { '/' }, COM1, },
+ { PROTO, { '\n' }, S_NL, },
+ { PROTO, { ' ','\t','\f','\v' }, WS1, },
+
+/* proto {do,else,extern,for,if,inline,return,static,typedef,va_start,void,while,NoN} */
+ { RES1, { C_XXX }, S_MACRO, },
+ { RES1, { C_LET, C_DEC }, NID, },
+ { RES1, { 'a' }, RES1a, },
+ { RES1, { 'e' }, RES1e, },
+ { RES1, { 'f' }, RES1f, },
+ { RES1, { 'h' }, RES1h, },
+ { RES1, { 'l' }, RES1l, },
+ { RES1, { 'n' }, RES1n, },
+ { RES1, { 'o' }, RES1o, },
+ { RES1, { 't' }, RES1t, },
+ { RES1, { 'x' }, RES1x, },
+ { RES1, { 'y' }, RES1y, },
+
+ /* proto reserved {va_start} */
+ { RES1a, { C_XXX }, S_RESERVED, },
+ { RES1a, { C_LET, C_DEC }, NID, },
+ { RES1a, { '_','s','t','a' }, RES1a, },
+ { RES1a, { 'r' }, RES1a, },
+
+ /* proto reserved {return} */
+ { RES1e, { C_XXX }, S_RESERVED, },
+ { RES1e, { C_LET, C_DEC }, NID, },
+ { RES1e, { 't','u','r','n' }, RES1e, },
+
+ /* proto reserved {if} */
+ { RES1f, { C_XXX }, S_RESERVED, },
+ { RES1f, { C_LET, C_DEC }, NID, },
+
+ /* proto reserved {while} */
+ { RES1h, { C_XXX }, S_RESERVED, },
+ { RES1h, { C_LET, C_DEC }, NID, },
+ { RES1h, { 'i','l','e' }, RES1h, },
+
+ /* proto reserved {else} */
+ { RES1l, { C_XXX }, S_RESERVED, },
+ { RES1l, { C_LET, C_DEC }, NID, },
+ { RES1l, { 's','e' }, RES1l, },
+
+ /* proto reserved {inline} */
+ { RES1n, { C_XXX }, S_RESERVED, },
+ { RES1n, { C_LET, C_DEC }, NID, },
+ { RES1n, { 'l','i','n','e' }, RES1n, },
+
+ /* proto reserved {do,for,void} */
+ { RES1o, { C_XXX }, S_RESERVED, },
+ { RES1o, { C_LET, C_DEC }, NID, },
+ { RES1o, { 'r','i','d','N' }, RES1o, },
+
+ /* proto reserved {static} */
+ { RES1t, { C_XXX }, S_RESERVED, },
+ { RES1t, { C_LET, C_DEC }, NID, },
+ { RES1t, { 'a','t','i','c' }, RES1t, },
+
+ /* proto reserved {extern} */
+ { RES1x, { C_XXX }, S_RESERVED, },
+ { RES1x, { C_LET, C_DEC }, NID, },
+ { RES1x, { 't','e','r','n' }, RES1x, },
+
+ /* proto reserved {typedef} */
+ { RES1y, { C_XXX }, S_RESERVED, },
+ { RES1y, { C_LET, C_DEC }, NID, },
+ { RES1y, { 'p','e','d','f' }, RES1y, },
+
+ /* saw /, perhaps start of comment */
+ { COM1, { C_XXX }, S_CHRB, },
+ { COM1, { '*' }, COM2, },
+#if PROTOMAIN
+ { COM1, { '/' }, COM5, },
+#endif
+
+ /* saw / *, start of comment */
+ { COM2, { C_XXX }, COM2, },
+ { COM2, { '\n', C_EOF }, S_COMMENT, },
+ { COM2, { '/' }, COM4, },
+ { COM2, { '*' }, COM3, },
+ { COM2, { '#', ';', ')' }, QUAL(COM2), },
+
+ /* saw the * possibly ending a comment */
+ { COM3, { C_XXX }, COM2, },
+ { COM3, { '\n', C_EOF }, S_COMMENT, },
+ { COM3, { '#', ';', ')' }, QUAL(COM2), },
+ { COM3, { '*' }, COM3, },
+ { COM3, { '/' }, S_COMMENT, },
+
+ /* saw / in / * comment, possible malformed nest */
+ { COM4, { C_XXX }, COM2, },
+ { COM4, { '*', '\n', C_EOF }, S_COMMENT, },
+ { COM4, { '/' }, COM4, },
+
+ /* saw / /, start of comment */
+ { COM5, { C_XXX }, COM5, },
+ { COM5, { '\n', C_EOF }, S_COMMENT, },
+ { COM5, { '/' }, COM6, },
+ { COM5, { '*' }, COM7, },
+
+ /* saw / in / / comment, possible malformed nest */
+ { COM6, { C_XXX }, COM5, },
+ { COM6, { '*', '\n', C_EOF }, S_COMMENT, },
+ { COM6, { '/' }, COM6, },
+
+ /* saw * in / /, possible malformed nest */
+ { COM7, { C_XXX }, COM5, },
+ { COM7, { '\n', C_EOF }, S_COMMENT, },
+ { COM7, { '*' }, COM7, },
+ { COM7, { '/' }, S_COMMENT, },
+
+ /* normal identifier -- always a macro candidate */
+ { NID, { C_XXX }, S_MACRO, },
+ { NID, { C_LET, C_DEC }, NID, },
+
+ /* saw ., operator or dbl constant */
+ { DOT, { C_XXX }, S_CHRB, },
+ { DOT, { '.' }, DOT2, },
+ { DOT, { C_DEC }, BAD1, },
+
+ /* saw .., possible ... */
+ { DOT2, { C_XXX }, BACK(T_INVALID), },
+ { DOT2, { '.' }, KEEP(T_VARIADIC), },
+
+ /* saw L (possible start of normal wide literal) */
+ { LIT, { C_XXX }, S_MACRO, },
+ { LIT, { C_LET, C_DEC }, NID, },
+ { LIT, { '"', '\'' }, QUAL(LIT1), },
+
+ /* saw " or ' beginning literal */
+ { LIT1, { C_XXX }, LIT1, },
+ { LIT1, { '"', '\'' }, S_LITEND, },
+ { LIT1, { '\n', C_EOF }, S_LITEND, },
+ { LIT1, { '\\' }, LIT2, },
+
+ /* saw \ in literal */
+ { LIT2, { C_XXX }, S_LITESC, },
+ { LIT2, { '\n', C_EOF }, S_LITEND, },
+
+ /* eat malformed numeric constant */
+ { BAD1, { C_XXX }, BACK(T_INVALID), },
+ { BAD1, { C_LET, C_DEC, '.' }, BAD1, },
+ { BAD1, { 'e', 'E' }, BAD2, },
+
+ /* eat malformed numeric fraction|exponent */
+ { BAD2, { C_XXX }, BACK(T_INVALID), },
+ { BAD2, { C_LET, C_DEC, '.' }, BAD1, },
+ { BAD2, { '+', '-' }, BAD1, },
+
+ /* saw white space, eat it up */
+ { WS1, { C_XXX }, S_WS, },
+ { WS1, { ' ', '\t' }, WS1, },
+ { WS1, { '\f', '\v' }, S_VS, },
+
+#if !PROTOMAIN
+
+ /* quick template */
+ { QUICK, { C_XXX }, QTOK, },
+ { QUICK, { C_EOF, MARK }, S_CHRB, },
+ { QUICK, { C_LET, C_DEC }, QID, },
+ { QUICK, { 'L' }, LIT0, },
+ { QUICK, { '"', '\'' }, S_LITBEG, },
+ { QUICK, { '/' }, S_CHRB, },
+ { QUICK, { '*' }, QCOM, },
+ { QUICK, { '#' }, SHARP1, },
+ { QUICK, { '\n' }, S_NL, },
+ { QUICK, { '\f', '\v' }, S_VS, },
+
+ /* copy QUICK to QUICK+1 through MAC0+1 */
+ { OP, {QUICK,QUICK+1,MAC0+1}, COPY, },
+
+ /* quick start state */
+ { QUICK, { C_EOF }, S_EOF, },
+ { QUICK, { C_DEC }, QNUM, },
+ { QUICK, { MARK }, QTOK, },
+ { QUICK, { '/' }, COM1, },
+ { QUICK, { ' ', '\t' }, QUICK, },
+
+ /* grab non-macro tokens */
+ { QTOK, { C_DEC }, QNUM, },
+
+ /* grab numeric and invalid tokens */
+ { QNUM, { C_LET, C_DEC, '.' }, QNUM, },
+ { QNUM, { 'e', 'E' }, QEXP, },
+
+ /* grab exponent token */
+ { QEXP, { C_LET, C_DEC, '.' }, QNUM, },
+ { QEXP, { '+', '-' }, QNUM, },
+
+ /* saw *, grab possible bad comment terminator */
+ { QCOM, { C_DEC }, QNUM, },
+ { QCOM, { '/' }, S_COMMENT, },
+
+ /* saw L (possible start of wide string or first macro char) */
+ { MAC0, { 'L' }, QID, },
+ { MAC0, { '"', '\'' }, QUAL(LIT1), },
+
+ /* macro candidate template */
+ { MAC0+1, { 'L' }, QID, },
+
+ /* copy MAC0+1 to MAC0+2 through MACN */
+ { OP, {MAC0+1,MAC0+2,MACN}, COPY },
+
+ /* saw L (possible start of wide string or macro L) */
+ { HIT0, { C_XXX }, S_MACRO, },
+ { HIT0, { C_LET, C_DEC }, QID, },
+ { HIT0, { '"', '\'' }, QUAL(LIT1), },
+
+ /* macro hit template */
+ { HIT0+1, { C_XXX }, S_MACRO, },
+ { HIT0+1, { C_LET, C_DEC }, QID, },
+
+ /* copy HIT0+1 to HIT0+2 through HITN */
+ { OP, {HIT0+1,HIT0+2,HITN}, COPY },
+
+ /* saw L (possible start of wide literal) */
+ { LIT0, { C_XXX }, S_MACRO, },
+ { LIT0, { C_LET, C_DEC }, QID, },
+ { LIT0, { '"', '\'' }, QUAL(LIT1), },
+
+ /* (!PROTOMAIN COM1) saw /, perhaps start of comment or /= */
+ { COM1, { '=' }, KEEP(T_DIVEQ), },
+
+ /* normal start state */
+ { TOKEN, { C_XXX }, S_HUH, },
+ { TOKEN, { C_EOF }, S_EOF, },
+ { TOKEN, { C_DEC }, DEC1, },
+ { TOKEN, { '0' }, OCT1, },
+ { TOKEN, { '.' }, DOT1, },
+ { TOKEN, { C_LET }, NID, },
+ { TOKEN, { 'L' }, LIT, },
+ { TOKEN, { '"', '\'', '<' }, S_LITBEG, },
+ { TOKEN, { '/' }, COM1, },
+ { TOKEN, { '\n' }, S_NL, },
+ { TOKEN, { ' ', '\t' }, WS1, },
+ { TOKEN, { '\f', '\v' }, S_VS, },
+ { TOKEN, { '#' }, SHARP1, },
+ { TOKEN, { ':' }, COLON1, },
+ { TOKEN, { '%' }, PCT1, },
+ { TOKEN, { '&' }, AND1, },
+ { TOKEN, { '*' }, STAR1, },
+ { TOKEN, { '+' }, PLUS1, },
+ { TOKEN, { '-' }, MINUS1, },
+ { TOKEN, { '=' }, EQ1, },
+ { TOKEN, { '!' }, NOT1, },
+ { TOKEN, { '>' }, GT1, },
+ { TOKEN, { '^' }, CIRC1, },
+ { TOKEN, { '|' }, OR1, },
+ { TOKEN, { '(', ')', '[', ']' }, S_CHR, },
+ { TOKEN, { '{', '}', ',', ';' }, S_CHR, },
+ { TOKEN, { '~', '?' }, S_CHR, },
+
+ /* saw 0, possible oct|hex|dec|dbl constant */
+ { OCT1, { C_XXX }, BACK(T_DECIMAL), },
+ { OCT1, { C_LET, C_DEC }, BAD1, },
+ { OCT1, { C_OCT }, OCT2, },
+ { OCT1, { 'e', 'E' }, DBL2, },
+ { OCT1, { 'l', 'L', 'u', 'U' }, QUAL(DEC2), },
+ { OCT1, { 'x', 'X' }, HEX1, },
+ { OCT1, { '.' }, DBL1, },
+
+ /* saw 0<oct>, oct constant */
+ { OCT2, { C_XXX }, BACK(T_OCTAL), },
+ { OCT2, { C_LET, C_DEC }, BAD1, },
+ { OCT2, { C_OCT }, OCT2, },
+ { OCT2, { 'e', 'E' }, DBL2, },
+ { OCT2, { 'l', 'L', 'u', 'U' }, QUAL(OCT3), },
+ { OCT2, { '.' }, DBL1, },
+
+ /* oct constant qualifier */
+ { OCT3, { C_XXX }, BACK(T_OCTAL), },
+ { OCT3, { C_LET, C_DEC, '.' }, BAD1, },
+ { OCT3, { 'l', 'L', 'u', 'U' }, QUAL(OCT3), },
+
+ /* saw 0 [xX], hex constant */
+ { HEX1, { C_XXX }, BACK(T_HEXADECIMAL), },
+ { HEX1, { C_LET }, BAD1, },
+ { HEX1, { C_HEX }, HEX1, },
+ { HEX1, { 'e', 'E' }, HEX3, },
+ { HEX1, { 'l', 'L', 'u', 'U' }, QUAL(HEX2), },
+ { HEX1, { '.' }, HEX4, },
+ { HEX1, { 'p', 'P' }, HEX5, },
+
+ /* hex constant qualifier */
+ { HEX2, { C_XXX }, BACK(T_HEXADECIMAL), },
+ { HEX2, { C_LET, C_DEC, '.' }, BAD1, },
+ { HEX2, { 'l', 'L', 'u', 'U' }, QUAL(HEX2), },
+
+ /* hex [eE][-+] botch */
+ { HEX3, { C_XXX }, BACK(T_HEXADECIMAL), },
+ { HEX3, { C_LET, '.', '-', '+'},BAD1, },
+ { HEX3, { C_HEX }, HEX1, },
+ { HEX3, { 'e', 'E' }, HEX3, },
+ { HEX3, { 'l', 'L', 'u', 'U' }, QUAL(HEX2), },
+
+ /* hex dbl fraction */
+ { HEX4, { C_XXX }, BACK(T_HEXDOUBLE), },
+ { HEX4, { C_LET, '.' }, BAD1, },
+ { HEX4, { C_HEX }, HEX4, },
+ { HEX4, { 'p', 'P' }, HEX5, },
+ { HEX4, { 'f', 'F', 'l', 'L' }, QUAL(HEX8), },
+
+ /* optional hex dbl exponent sign */
+ { HEX5, { C_XXX }, BACK(T_INVALID), },
+ { HEX5, { C_LET, '.' }, BAD1, },
+ { HEX5, { '+', '-' }, HEX6, },
+ { HEX5, { C_DEC }, HEX7, },
+
+ /* mandatory hex dbl exponent first digit */
+ { HEX6, { C_XXX }, BACK(T_INVALID), },
+ { HEX6, { C_LET, '.' }, BAD1, },
+ { HEX6, { C_DEC }, HEX7, },
+
+ /* hex dbl exponent digits */
+ { HEX7, { C_XXX }, BACK(T_HEXDOUBLE), },
+ { HEX7, { C_LET, '.' }, BAD1, },
+ { HEX7, { C_DEC }, HEX7, },
+ { HEX7, { 'f', 'F', 'l', 'L' }, QUAL(HEX8), },
+
+ /* hex dbl constant qualifier */
+ { HEX8, { C_XXX }, BACK(T_HEXDOUBLE), },
+ { HEX8, { C_LET, '.' }, BAD1, },
+ { HEX8, { 'f', 'F', 'l', 'L' }, QUAL(HEX8), },
+
+ /* saw <dec>, dec constant */
+ { DEC1, { C_XXX }, BACK(T_DECIMAL), },
+ { DEC1, { C_LET }, BAD1, },
+ { DEC1, { C_DEC }, DEC1, },
+ { DEC1, { 'e', 'E' }, DBL2, },
+ { DEC1, { 'l', 'L', 'u', 'U' }, QUAL(DEC2), },
+ { DEC1, { '.' }, DBL1, },
+
+ /* dec constant qualifier */
+ { DEC2, { C_XXX }, BACK(T_DECIMAL), },
+ { DEC2, { C_LET, C_DEC }, BAD1, },
+ { DEC2, { 'l', 'L', 'u', 'U' }, QUAL(DEC2), },
+
+ /* saw ., operator or dbl constant */
+ { DOT1, { C_XXX }, S_CHRB, },
+ { DOT1, { '.' }, DOT2, },
+ { DOT1, { C_DEC }, DBL1, },
+
+ /* dbl fraction */
+ { DBL1, { C_XXX }, BACK(T_DOUBLE), },
+ { DBL1, { C_LET, '.' }, BAD1, },
+ { DBL1, { C_DEC }, DBL1, },
+ { DBL1, { 'e', 'E' }, DBL2, },
+ { DBL1, { 'f', 'F', 'l', 'L' }, QUAL(DBL5), },
+
+ /* optional dbl exponent sign */
+ { DBL2, { C_XXX }, BACK(T_INVALID), },
+ { DBL2, { C_LET, '.' }, BAD1, },
+ { DBL2, { '+', '-' }, DBL3, },
+ { DBL2, { C_DEC }, DBL4, },
+
+ /* mandatory dbl exponent first digit */
+ { DBL3, { C_XXX }, BACK(T_INVALID), },
+ { DBL3, { C_LET, '.' }, BAD1, },
+ { DBL3, { C_DEC }, DBL4, },
+
+ /* dbl exponent digits */
+ { DBL4, { C_XXX }, BACK(T_DOUBLE), },
+ { DBL4, { C_LET, '.' }, BAD1, },
+ { DBL4, { C_DEC }, DBL4, },
+ { DBL4, { 'f', 'F', 'l', 'L' }, QUAL(DBL5), },
+
+ /* dbl constant qualifier */
+ { DBL5, { C_XXX }, BACK(T_DOUBLE), },
+ { DBL5, { C_LET, '.' }, BAD1, },
+ { DBL5, { 'f', 'F', 'l', 'L' }, QUAL(DBL5), },
+
+ /* saw < starting include header */
+ { HDR1, { C_XXX }, HDR1, },
+ { HDR1, { '>', '\n', C_EOF }, S_LITEND, },
+
+ /* saw <binop><space> expecting = */
+ { BIN1, { C_XXX }, S_HUH, },
+ { BIN1, { ' ', '\t' }, BIN1, },
+
+ /* 2-char ops */
+
+ { SHARP1, { C_XXX }, S_SHARP, },
+
+ { PCT1, { C_XXX }, S_CHRB, },
+ { PCT1, { '=' }, KEEP(T_MODEQ), },
+
+ { AND1, { C_XXX }, S_CHRB, },
+ { AND1, { '=' }, KEEP(T_ANDEQ), },
+ { AND1, { '&' }, KEEP(T_ANDAND), },
+
+ { STAR1, { C_XXX }, S_CHRB, },
+ { STAR1, { '=' }, KEEP(T_MPYEQ), },
+ { STAR1, { '/' }, S_COMMENT, },
+
+ { PLUS1, { C_XXX }, S_CHRB, },
+ { PLUS1, { '=' }, KEEP(T_ADDEQ), },
+ { PLUS1, { '+' }, KEEP(T_ADDADD), },
+
+ { MINUS1, { C_XXX }, S_CHRB, },
+ { MINUS1, { '=' }, KEEP(T_SUBEQ), },
+ { MINUS1, { '-' }, KEEP(T_SUBSUB), },
+ { MINUS1, { '>' }, KEEP(T_PTRMEM), },
+
+ { COLON1, { C_XXX }, S_CHRB, },
+ { COLON1, { '=', '>' }, S_HUH, },
+
+ { LT1, { C_XXX }, S_CHRB, },
+ { LT1, { '=' }, KEEP(T_LE), },
+ { LT1, { '<' }, LSH1, },
+
+ { EQ1, { C_XXX }, S_CHRB, },
+ { EQ1, { '=' }, KEEP(T_EQ), },
+
+ { NOT1, { C_XXX }, S_CHRB, },
+ { NOT1, { '=' }, KEEP(T_NE), },
+
+ { GT1, { C_XXX }, S_CHRB, },
+ { GT1, { '=' }, KEEP(T_GE), },
+ { GT1, { '>' }, RSH1, },
+
+ { CIRC1, { C_XXX }, S_CHRB, },
+ { CIRC1, { '=' }, KEEP(T_XOREQ), },
+
+ { OR1, { C_XXX }, S_CHRB, },
+ { OR1, { '=' }, KEEP(T_OREQ), },
+ { OR1, { '|' }, KEEP(T_OROR), },
+
+ /* 3-char ops */
+
+ { ARROW1, { C_XXX }, BACK(T_PTRMEM), },
+ { ARROW1, { '*' }, KEEP(T_PTRMEMREF), },
+
+ { LSH1, { C_XXX }, BACK(T_LSHIFT), },
+ { LSH1, { '=' }, KEEP(T_LSHIFTEQ), },
+
+ { RSH1, { C_XXX }, BACK(T_RSHIFT), },
+ { RSH1, { '=' }, KEEP(T_RSHIFTEQ), },
+
+#endif
+
+ /* end */
+ { OP, { 0 }, END, }
+};
+
+short fsm[TERMINAL+1][MAX+1];
+
+char trigraph[MAX+1];
+
+#if PROTOMAIN
+static char spl[] = { '\\', '\r', 0 };
+static char aln[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_$@";
+#else
+static char spl[] = { MARK, '?', '\\', '\r', CC_sub, 0 };
+static char aln[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_";
+#endif
+static char* let = &aln[10];
+static char hex[] = "fedcbaFEDCBA9876543210";
+static char* dec = &hex[12];
+static char* oct = &hex[14];
+
+/*
+ * runtime FSM modifications
+ * ppfsm(FSM_INIT,0) must be called first
+ */
+
+void
+ppfsm(int op, register char* s)
+{
+ register int c;
+ register int n;
+ register int i;
+ register short* rp;
+ register struct fsminit* fp;
+#if !PROTOMAIN
+ char* t;
+ int x;
+#endif
+
+ switch (op)
+ {
+
+#if !PROTOMAIN
+
+ case FSM_IDADD:
+ while (c = *s++)
+ if (!ppisid(c))
+ {
+ if (fsm[TOKEN][c] == ~S_HUH)
+ {
+ setid(c);
+ for (i = 0; i < TERMINAL; i++)
+ fsm[i][c] = IDSTATE(fsm[i]['_']);
+ }
+ else error(2, "%c: cannot add to identifier set", c);
+ }
+ break;
+
+ case FSM_IDDEL:
+ while (c = *s++)
+ if (ppisid(c))
+ {
+ clrid(c);
+ for (i = 0; i < TERMINAL; i++)
+ fsm[i][c] = ~S_HUH;
+ }
+ break;
+
+#endif
+
+ case FSM_INIT:
+ for (fp = fsminit;; fp++)
+ {
+ if ((n = fp->nextstate) >= TERMINAL) n = ~n;
+ if (fp->state == OP)
+ {
+#if !PROTOMAIN
+ switch (n)
+ {
+ case COPY:
+ c = fp->ch[0];
+ n = fp->ch[2];
+ for (i = fp->ch[1]; i <= n; i++)
+ copy(i, c);
+ continue;
+ default:
+ break;
+ }
+#endif
+ break;
+ }
+ rp = fsm[fp->state];
+ for (i = 0; i < sizeof(fp->ch) && (c = fp->ch[i]); i++)
+ {
+ switch (c)
+ {
+ case C_XXX:
+ for (c = 0; c <= MAX; c++)
+ rp[c] = n;
+ /*FALLTHROUGH*/
+
+ case C_EOF:
+ fsm[TERMINAL][fp->state+1] = n < 0 ? ~n : n;
+ continue;
+
+ case C_LET:
+ s = let;
+ break;
+
+ case C_HEX:
+ s = hex;
+ break;
+
+ case C_DEC:
+ s = dec;
+ break;
+
+ case C_OCT:
+ s = oct;
+ break;
+
+ default:
+ rp[c] = n;
+ continue;
+ }
+ while (c = *s++)
+ rp[c] = n;
+ }
+ }
+
+ /*
+ * install splice special cases
+ * and same non-terminal transitions
+ */
+
+ for (i = 0; i < TERMINAL; i++)
+ {
+ rp = fsm[i];
+ s = spl;
+ while (c = *s++)
+ if (c != MARK || !INCOMMENT(rp))
+ {
+ if (rp[c] >= 0) rp[c] = ~rp[c];
+ rp[c] &= ~SPLICE;
+ }
+ rp[EOB] = ~S_EOB;
+ for (c = 0; c <= MAX; c++)
+ if (rp[c] == i)
+ rp[c] = 0;
+ }
+ fsm[TERMINAL][0] = ~S_EOB;
+
+#if !PROTOMAIN
+
+ /*
+ * default character types
+ */
+
+ s = let;
+ while (c = *s++)
+ setid(c);
+ s = dec;
+ while (c = *s++)
+ setdig(c);
+ s = spl;
+ do setsplice(c = *s++); while (c);
+
+ /*
+ * trigraph map
+ */
+
+ trigraph['='] = '#';
+ trigraph['('] = '[';
+ trigraph['/'] = '\\';
+ trigraph[')'] = ']';
+ trigraph['\''] = '^';
+ trigraph['<'] = '{';
+ trigraph['!'] = '|';
+ trigraph['>'] = '}';
+ trigraph['-'] = '~';
+#endif
+ break;
+
+#if !PROTOMAIN
+
+ case FSM_PLUSPLUS:
+ if (pp.option & PLUSPLUS)
+ {
+ fsm[COLON1][':'] = ~KEEP(T_SCOPE);
+ fsm[DOT1]['*'] = ~KEEP(T_DOTREF);
+ fsm[MINUS1]['>'] = ARROW1;
+ fsm[COM1]['/'] = COM5;
+ t = "%<:";
+ for (i = 0; i < TERMINAL; i++)
+ {
+ rp = fsm[i];
+ if (!INCOMMENT(rp) && !INQUOTE(rp))
+ {
+ s = t;
+ while (c = *s++)
+ {
+ if (rp[c] > 0) rp[c] = ~rp[c];
+ else if (!rp[c]) rp[c] = ~i;
+ rp[c] &= ~SPLICE;
+ }
+ }
+ }
+ s = t;
+ while (c = *s++) setsplice(c);
+ }
+ else
+ {
+ fsm[COLON1][':'] = ~S_CHRB;
+ fsm[DOT1]['*'] = ~S_CHRB;
+ fsm[MINUS1]['>'] = ~KEEP(T_PTRMEM);
+ fsm[COM1]['/'] = (pp.option & PLUSCOMMENT) ? COM5 : ~S_CHRB;
+ }
+ break;
+
+#if COMPATIBLE
+
+ case FSM_COMPATIBILITY:
+ if (pp.state & COMPATIBILITY)
+ {
+ fsm[HEX1]['e'] = HEX1;
+ fsm[HEX1]['E'] = HEX1;
+ fsm[QNUM]['e'] = QNUM;
+ fsm[QNUM]['E'] = QNUM;
+ fsm[QNUM]['u'] = ~QUAL(QNUM);
+ fsm[QNUM]['U'] = ~QUAL(QNUM);
+ }
+ else
+ {
+ fsm[HEX1]['e'] = HEX3;
+ fsm[HEX1]['E'] = HEX3;
+ fsm[QNUM]['e'] = QEXP;
+ fsm[QNUM]['E'] = QEXP;
+ fsm[QNUM]['u'] = QNUM;
+ fsm[QNUM]['U'] = QNUM;
+ }
+ break;
+
+#endif
+
+ case FSM_QUOTADD:
+ while (c = *s++)
+ if (fsm[TOKEN][c] == ~S_HUH)
+ for (i = 0; i < TERMINAL; i++)
+ fsm[i][c] = fsm[i]['"'];
+ else error(2, "%c: cannot add to quote set", c);
+ break;
+
+ case FSM_QUOTDEL:
+ while (c = *s++)
+ if (c != '"' && fsm[TOKEN][c] == fsm[TOKEN]['"'])
+ for (i = 0; i < TERMINAL; i++)
+ fsm[i][c] = fsm[i]['_'];
+ break;
+
+ case FSM_OPSPACE:
+ n = s ? BIN1 : ~S_CHRB;
+ fsm[COM1][' '] = fsm[COM1]['\t'] = n;
+ fsm[AND1][' '] = fsm[AND1]['\t'] = n;
+ fsm[STAR1][' '] = fsm[STAR1]['\t'] = n;
+ fsm[PCT1][' '] = fsm[PCT1]['\t'] = n;
+ fsm[PLUS1][' '] = fsm[PLUS1]['\t'] = n;
+ fsm[MINUS1][' '] = fsm[MINUS1]['\t'] = n;
+ fsm[CIRC1][' '] = fsm[CIRC1]['\t'] = n;
+ fsm[OR1][' '] = fsm[OR1]['\t'] = n;
+ fsm[LSH1][' '] = fsm[LSH1]['\t'] = s ? BIN1 : ~BACK(T_LSHIFT);
+ fsm[RSH1][' '] = fsm[RSH1]['\t'] = s ? BIN1 : ~BACK(T_RSHIFT);
+ break;
+
+ case FSM_MACRO:
+ if (pp.truncate && strlen(s) >= pp.truncate)
+ {
+ x = s[pp.truncate];
+ s[pp.truncate] = 0;
+ }
+ else x = -1;
+ i = MAC0 + ((c = *s++) != 'L');
+ if ((n = fsm[QUICK][c]) != (i + NMAC))
+ {
+ n = i;
+ if (!*s) n += NMAC;
+ }
+ if (fsm[QUICK][c] != n)
+ fsm[QUICK][c] = fsm[QCOM][c] = fsm[QTOK][c] = n;
+ if (c = *s++)
+ {
+ for (;;)
+ {
+ if ((i = n) < HIT0)
+ {
+ if (n < MACN) n++;
+ if (!*s)
+ {
+ n += NMAC;
+ break;
+ }
+ if (fsm[i][c] < HIT0)
+ fsm[i][c] = n;
+ if (fsm[i + NMAC][c] < HIT0)
+ fsm[i + NMAC][c] = n;
+ }
+ else
+ {
+ if (n < HITN) n++;
+ if (!*s) break;
+ if (fsm[i][c] < HIT0)
+ {
+ n -= NMAC;
+ fsm[i][c] = n;
+ }
+ }
+ c = *s++;
+ }
+ if (x >= 0)
+ {
+ *s = x;
+ for (n = CHAR_MIN; n <= CHAR_MAX; n++)
+ if (ppisidig(n))
+ fsm[HITN][n] = HITN;
+ n = HITN;
+ }
+ if (fsm[i][c] < n)
+ fsm[i][c] = n;
+ if (i < HIT0 && fsm[i + NMAC][c] < n)
+ fsm[i + NMAC][c] = n;
+ }
+ break;
+
+#endif
+
+ }
+}
+
+#if !PROTOMAIN
+
+/*
+ * file buffer refill
+ * c is current input char
+ */
+
+void
+refill(register int c)
+{
+ if (pp.in->flags & IN_eof)
+ {
+ pp.in->nextchr--;
+ c = 0;
+ }
+ else
+ {
+ *((pp.in->nextchr = pp.in->buffer + PPBAKSIZ) - 1) = c;
+ c =
+#if PROTOTYPE
+ (pp.in->flags & IN_prototype) ? pppread(pp.in->nextchr) :
+#endif
+ read(pp.in->fd, pp.in->nextchr, PPBUFSIZ);
+ }
+ if (c > 0)
+ {
+ if (pp.in->nextchr[c - 1] == '\n') pp.in->flags |= IN_newline;
+ else pp.in->flags &= ~IN_newline;
+#if PROTOTYPE
+ if (!(pp.in->flags & IN_prototype))
+#endif
+ if (c < PPBUFSIZ && (pp.in->flags & IN_regular))
+ {
+ pp.in->flags |= IN_eof;
+ close(pp.in->fd);
+ pp.in->fd = -1;
+ }
+ }
+ else
+ {
+ if (c < 0)
+ {
+ error(ERROR_SYSTEM|3, "read error");
+ c = 0;
+ }
+ else if ((pp.in->flags ^ pp.in->prev->flags) & IN_c)
+ {
+ static char ket[] = { 0, '}', '\n', 0 };
+
+ pp.in->flags ^= IN_c;
+ pp.in->nextchr = ket + 1;
+ c = 2;
+ }
+ pp.in->flags |= IN_eof;
+ }
+#if CHECKPOINT
+ pp.in->buflen = c;
+#endif
+ pp.in->nextchr[c] = 0;
+ debug((-7, "refill(\"%s\") = %d = \"%-.*s%s\"", error_info.file, c, (c > 32 ? 32 : c), pp.in->nextchr, c > 32 ? "..." : ""));
+ if (pp.test & 0x0080)
+ sfprintf(sfstderr, "===== refill(\"%s\") = %d =====\n%s\n===== eob(\"%s\") =====\n", error_info.file, c, pp.in->nextchr, error_info.file);
+}
+
+#endif
diff --git a/usr/src/lib/libpp/common/ppfsm.h b/usr/src/lib/libpp/common/ppfsm.h
new file mode 100644
index 0000000000..1aff931d2b
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppfsm.h
@@ -0,0 +1,278 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * preprocessor lexical analyzer definitions
+ */
+
+#ifndef _PPFSM_H
+#define _PPFSM_H
+
+#define BITSTATE 16 /* bitsof(state) */
+#define BITNONTERM 7 /* bitsof(non-terminal-state) */
+#define BITTERM 7 /* bitsof(terminal-state) */
+#define NMAC 19 /* number of MAC states */
+
+#define SPLICE (1<<BITTERM)
+
+#define CODE(tok,act) ((((tok)-N_PP)<<(BITTERM+1))|(act))
+#define TERM(st) ((st)&((1<<(BITTERM+1))-1))
+#define NEXT(st) (((st)>>(BITTERM+1))&((1<<BITNONTERM)-1))
+#define QUAL(st) (((st)<<(BITTERM+1))|(S_QUAL))
+#define TYPE(st) (NEXT(st)+N_PP)
+
+#define BACK(tok) CODE(tok,S_TOKB)
+#define KEEP(tok) CODE(tok,S_TOK)
+
+#undef MAX
+#define MAX 255
+
+#undef EOB
+#define EOB 0
+#undef EOF
+#define EOF (MAX+1)
+
+/*
+ * FSM states
+ *
+ * NOTE: preserve the ranges
+ */
+
+#define INDEX(p) (((p)-fsm[0])/(MAX+1))
+
+#define IDSTATE(x) (((x)>=0&&INQMACRO(fsm[x]))?QID:(x))
+
+#define INCOMMENT(p) ((p)>=fsm[COM2]&&(p)<=fsm[COM7])
+#define INCOMMENTXX(p) ((p)>=fsm[COM5]&&(p)<=fsm[COM7])
+#define INQMACRO(p) ((p)>=fsm[MAC0]&&(p)<=fsm[LIT0])
+#define INTMACRO(p) ((p)>=fsm[NID]&&(p)<=fsm[LIT])
+#define INQUOTE(p) ((p)>=fsm[LIT1]&&(p)<=fsm[LIT2])
+#define INOPSPACE(p) ((p)==fsm[BIN1])
+#define INSPACE(p) ((p)==fsm[WS1])
+
+/*
+ * proto non-terminal states
+ */
+
+#define PROTO 0
+#define RES1 (PROTO+1)
+#define RES1a (PROTO+2)
+#define RES1e (PROTO+3)
+#define RES1f (PROTO+4)
+#define RES1h (PROTO+5)
+#define RES1l (PROTO+6)
+#define RES1n (PROTO+7)
+#define RES1o (PROTO+8)
+#define RES1t (PROTO+9)
+#define RES1x (PROTO+10)
+#define RES1y (PROTO+11)
+#define COM1 (PROTO+12)
+#define COM2 (PROTO+13)
+#define COM3 (PROTO+14)
+#define COM4 (PROTO+15)
+#define COM5 (PROTO+16)
+#define COM6 (PROTO+17)
+#define COM7 (PROTO+18)
+#define NID (PROTO+19)
+#define LIT (PROTO+20)
+#define LIT1 (PROTO+21)
+#define LIT2 (PROTO+22)
+#define BAD1 (PROTO+23)
+#define BAD2 (PROTO+24)
+#define DOT (PROTO+25)
+#define DOT2 (PROTO+26)
+#define WS1 (PROTO+27)
+
+#if PROTOMAIN
+
+#define TERMINAL (PROTO+28) /* PROTOMAIN */
+
+#else
+
+/*
+ * quick non-terminal states
+ */
+
+#define QUICK (PROTO+28)
+#define QTOK (QUICK+1)
+#define QNUM (QUICK+2)
+#define QEXP (QUICK+3)
+#define QCOM (QUICK+4)
+#define QID (QUICK+5)
+#define MAC0 (QUICK+6)
+#define MACN (MAC0+NMAC-1)
+#define HIT0 (MACN+1)
+#define HITN (HIT0+NMAC-1)
+#define LIT0 (HITN+1)
+#define SHARP1 (HITN+2)
+
+/*
+ * tokenize non-terminal states
+ */
+
+#define TOKEN (HITN+3)
+#define OCT1 (TOKEN+1)
+#define OCT2 (TOKEN+2)
+#define OCT3 (TOKEN+3)
+#define NOT1 (TOKEN+4)
+#define PCT1 (TOKEN+5)
+#define AND1 (TOKEN+6)
+#define STAR1 (TOKEN+7)
+#define PLUS1 (TOKEN+8)
+#define MINUS1 (TOKEN+9)
+#define ARROW1 (TOKEN+10)
+#define COLON1 (TOKEN+11)
+#define LT1 (TOKEN+12)
+#define LSH1 (TOKEN+13)
+#define EQ1 (TOKEN+14)
+#define RSH1 (TOKEN+15)
+#define GT1 (TOKEN+16)
+#define CIRC1 (TOKEN+17)
+#define OR1 (TOKEN+18)
+#define DEC1 (TOKEN+19)
+#define DEC2 (TOKEN+20)
+#define HEX1 (TOKEN+21)
+#define HEX2 (TOKEN+22)
+#define HEX3 (TOKEN+23)
+#define HEX4 (TOKEN+24)
+#define HEX5 (TOKEN+25)
+#define HEX6 (TOKEN+26)
+#define HEX7 (TOKEN+27)
+#define HEX8 (TOKEN+28)
+#define DBL1 (TOKEN+29)
+#define DBL2 (TOKEN+30)
+#define DBL3 (TOKEN+31)
+#define DBL4 (TOKEN+32)
+#define DBL5 (TOKEN+33)
+#define DOT1 (TOKEN+34)
+#define HDR1 (TOKEN+35)
+#define BIN1 (TOKEN+36)
+
+#define TERMINAL (TOKEN+37)
+
+#endif
+
+/*
+ * quick terminal states grouped together
+ */
+
+#define S_CHRB (TERMINAL+0)
+#define S_COMMENT (TERMINAL+1)
+#define S_EOB (TERMINAL+2)
+#define S_LITBEG (TERMINAL+3)
+#define S_LITEND (TERMINAL+4)
+#define S_LITESC (TERMINAL+5)
+#define S_MACRO (TERMINAL+6)
+#define S_NL (TERMINAL+7)
+#define S_QUAL (TERMINAL+8)
+#define S_SHARP (TERMINAL+9)
+#define S_VS (TERMINAL+10)
+
+/*
+ * and the remaining terminal states
+ */
+
+#define S_CHR (TERMINAL+11)
+#define S_HUH (TERMINAL+12)
+#define S_TOK (TERMINAL+13)
+#define S_TOKB (TERMINAL+14)
+#define S_WS (TERMINAL+15)
+
+#define S_RESERVED (S_HUH)
+
+/*
+ * the last terminal state (for tracing)
+ */
+
+#define LAST (S_WS)
+
+/*
+ * pseudo terminal states
+ */
+
+#define S_EOF (0)
+
+/*
+ * common lex macros
+ *
+ * NOTE: common local variable names assumed
+ */
+
+#define GET(p,c,tp,xp) \
+ do \
+ { \
+ if ((c = GETCHR()) == EOB && pp.in->type == IN_FILE) \
+ FGET(p, c, tp, xp); \
+ } while (0)
+
+#define FGET(p,c,tp,xp) \
+ do \
+ { \
+ if (op > xp + PPTOKSIZ) \
+ { \
+ if (!INCOMMENT(rp) && !(pp.state & (NOTEXT|SKIPCONTROL))) \
+ error(2, "long token truncated"); \
+ op = xp + PPTOKSIZ; \
+ } \
+ if ((pp.in->flags & IN_flush) && pp.level == 1 && !INMACRO(rp) && (!pp.comment || !INCOMMENT(rp)) && (c = op - pp.outbuf) > 0 && *(op - 1) == '\n') \
+ { \
+ PPWRITE(c); \
+ op = tp = pp.outp = pp.outbuf; \
+ } \
+ SYNCIN(); \
+ refill(p); \
+ CACHEIN(); \
+ if ((c = GETCHR()) == EOB) BACKIN(); \
+ } while (0)
+
+#define POP() \
+ do \
+ { \
+ debug((-7, "POP in=%s next=%s state=%s", ppinstr(cur), pptokchr(*prv->nextchr), pplexstr(INDEX(rp)))); \
+ ip = (pp.in = prv)->nextchr; \
+ } while (0)
+
+/*
+ * fsm implementaion globals
+ */
+
+#define fsm _pp_fsmtab
+#define refill _pp_refill
+#define trigraph _pp_trigraph
+
+/*
+ * first index is state, second is char, value is next state
+ * except for fsm[TERMINAL] where second is state+1 for EOF transition
+ */
+
+extern short fsm[TERMINAL+1][MAX+1];
+
+/*
+ * the index is char, value is trigraph value for <?><?><char>, 0 if invalid
+ */
+
+extern char trigraph[MAX+1];
+
+extern void refill(int);
+
+#endif
diff --git a/usr/src/lib/libpp/common/ppincref.c b/usr/src/lib/libpp/common/ppincref.c
new file mode 100644
index 0000000000..336940bb12
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppincref.c
@@ -0,0 +1,49 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * common include reference handler
+ * the type arg is inclusive or of PP_SYNC_*
+ */
+
+#include "pplib.h"
+
+void
+ppincref(char* parent, char* file, int line, int type)
+{
+ register struct ppinstk* sp;
+ int level;
+
+ NoP(parent);
+ NoP(line);
+ if (type & PP_SYNC_PUSH)
+ {
+ level = 0;
+ for (sp = pp.in; sp; sp = sp->prev)
+ if (sp->type == IN_FILE)
+ level++;
+ if (level > 0)
+ level--;
+ error(0, "%-*s%s", level * 4, "", file);
+ }
+}
diff --git a/usr/src/lib/libpp/common/ppinput.c b/usr/src/lib/libpp/common/ppinput.c
new file mode 100644
index 0000000000..170e5f5dca
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppinput.c
@@ -0,0 +1,721 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * preprocessor stacked input stream support
+ */
+
+#include "pplib.h"
+
+
+/*
+ * convert path to native representation
+ */
+
+#if 0
+#include "../../lib/libast/path/pathnative.c" /* drop in 2002 */
+#else
+/* Modified by gisburn 2006-08-18 for OpenSolaris ksh93-integration */
+#include "../../libast/common/path/pathnative.c"
+#endif
+
+static char*
+native(register const char* s)
+{
+ register int c;
+ register struct ppfile* xp;
+ int m;
+ int n;
+
+ static Sfio_t* np;
+ static Sfio_t* qp;
+
+ if (!s)
+ return 0;
+ if (!np && !(np = sfstropen()) || !qp && !(qp = sfstropen()))
+ return (char*)s;
+ n = PATH_MAX;
+ do
+ {
+ m = n;
+ n = pathnative(s, sfstrrsrv(np, m), m);
+ } while (n > m);
+ sfstrseek(np, n, SEEK_CUR);
+ s = (const char*)sfstruse(np);
+ for (;;)
+ {
+ switch (c = *s++)
+ {
+ case 0:
+ break;
+ case '\\':
+ case '"':
+ sfputc(qp, '\\');
+ /*FALLTHROUGH*/
+ default:
+ sfputc(qp, c);
+ continue;
+ }
+ break;
+ }
+ if (!(xp = ppsetfile(sfstruse(qp))))
+ return (char*)s;
+ return xp->name;
+}
+
+/*
+ * push stream onto input stack
+ * used by the PUSH_type macros
+ */
+
+void
+pppush(register int t, register char* s, register char* p, int n)
+{
+ register struct ppinstk* cur;
+
+ PUSH(t, cur);
+ cur->line = error_info.line;
+ cur->file = error_info.file;
+ switch (t)
+ {
+ case IN_FILE:
+ if (pp.option & NATIVE)
+ s = native(s);
+ cur->flags |= IN_newline;
+ cur->fd = n;
+ cur->hide = ++pp.hide;
+ cur->symbol = 0;
+#if CHECKPOINT
+ if ((pp.mode & (DUMP|INIT)) == DUMP)
+ {
+ cur->index = newof(0, struct ppindex, 1, 0);
+ if (pp.lastindex) pp.lastindex->next = cur->index;
+ else pp.firstindex = cur->index;
+ pp.lastindex = cur->index;
+ cur->index->file = pp.original;
+ cur->index->begin = ppoffset();
+ }
+#endif
+ n = 1;
+#if CHECKPOINT
+ if (!(pp.mode & DUMP))
+#endif
+ if (!cur->prev->prev && !(pp.state & COMPILE) && isatty(0))
+ cur->flags |= IN_flush;
+#if ARCHIVE
+ if (pp.member)
+ {
+ switch (pp.member->archive->type & (TYPE_BUFFER|TYPE_CHECKPOINT))
+ {
+ case 0:
+#if CHECKPOINT
+ cur->buflen = pp.member->size;
+#endif
+ p = (cur->buffer = oldof(0, char, 0, pp.member->size + PPBAKSIZ + 1)) + PPBAKSIZ;
+ if (sfseek(pp.member->archive->info.sp, pp.member->offset, SEEK_SET) != pp.member->offset)
+ error(3, "%s: archive seek error", pp.member->archive->name);
+ if (sfread(pp.member->archive->info.sp, p, pp.member->size) != pp.member->size)
+ error(3, "%s: archive read error", pp.member->archive->name);
+ pp.member = 0;
+ break;
+ case TYPE_BUFFER:
+#if CHECKPOINT
+ case TYPE_CHECKPOINT|TYPE_BUFFER:
+ cur->buflen = pp.member->size;
+#endif
+ p = cur->buffer = pp.member->archive->info.buffer + pp.member->offset;
+ cur->flags |= IN_static;
+ pp.member = 0;
+ break;
+#if CHECKPOINT
+ case TYPE_CHECKPOINT:
+ p = cur->buffer = "";
+ cur->flags |= IN_static;
+ break;
+#endif
+ }
+ cur->flags |= IN_eof|IN_newline;
+ cur->fd = -1;
+ }
+ else
+#endif
+ {
+ if (lseek(cur->fd, 0L, SEEK_END) > 0 && !lseek(cur->fd, 0L, SEEK_SET))
+ cur->flags |= IN_regular;
+ errno = 0;
+#if PROTOTYPE
+ if (!(pp.option & NOPROTO) && !(pp.test & TEST_noproto) && ((pp.state & (COMPATIBILITY|TRANSITION)) == COMPATIBILITY || (pp.option & PLUSPLUS) || (pp.mode & EXTERNALIZE)) && (cur->buffer = pppopen(NiL, cur->fd, NiL, NiL, NiL, NiL, (PROTO_HEADER|PROTO_RETAIN)|(((pp.mode & EXTERNALIZE) || (pp.option & PROTOTYPED)) ? PROTO_FORCE : PROTO_PASS)|((pp.mode & EXTERNALIZE) ? PROTO_EXTERNALIZE : 0)|((pp.mode & MARKC) ? PROTO_PLUSPLUS : 0))))
+ {
+ *(p = cur->buffer - 1) = 0;
+ cur->buffer -= PPBAKSIZ;
+ cur->flags |= IN_prototype;
+ cur->fd = -1;
+ }
+ else
+#endif
+ *(p = (cur->buffer = oldof(0, char, 0, PPBUFSIZ + PPBAKSIZ + 1)) + PPBAKSIZ) = 0;
+ }
+ if (pp.incref && !(pp.mode & INIT))
+ (*pp.incref)(error_info.file, s, error_info.line - 1, PP_SYNC_PUSH);
+ if (pp.macref || (pp.option & IGNORELINE))
+ cur->flags |= IN_ignoreline;
+ cur->prefix = pp.prefix;
+ /*FALLTHROUGH*/
+ case IN_BUFFER:
+ case IN_INIT:
+ case IN_RESCAN:
+ pushcontrol();
+ cur->control = pp.control;
+ *pp.control = 0;
+ cur->vendor = pp.vendor;
+ if (cur->type != IN_RESCAN)
+ {
+ if (cur->type == IN_INIT)
+ pp.mode |= MARKHOSTED;
+ error_info.file = s;
+ error_info.line = n;
+ }
+ if (pp.state & HIDDEN)
+ {
+ pp.state &= ~HIDDEN;
+ pp.hidden = 0;
+ if (!(pp.state & NOTEXT) && pplastout() != '\n')
+ ppputchar('\n');
+ }
+ pp.state |= NEWLINE;
+ if (pp.mode & HOSTED) cur->flags |= IN_hosted;
+ else cur->flags &= ~IN_hosted;
+ if (pp.mode & (INIT|MARKHOSTED))
+ {
+ pp.mode |= HOSTED;
+ pp.flags |= PP_hosted;
+ }
+ switch (cur->type)
+ {
+ case IN_FILE:
+ if (!(pp.mode & (INIT|MARKHOSTED)))
+ {
+ pp.mode &= ~HOSTED;
+ pp.flags &= ~PP_hosted;
+ }
+#if CATSTRINGS
+ if (pp.state & JOINING) pp.state |= HIDDEN|SYNCLINE;
+ else
+#endif
+ if (pp.linesync)
+ (*pp.linesync)(error_info.line, error_info.file);
+#if ARCHIVE && CHECKPOINT
+ if (pp.member)
+ ppload(NiL);
+#endif
+ if (pp.mode & MARKC)
+ {
+ cur->flags |= IN_c;
+ pp.mode &= ~MARKC;
+ if (!(cur->prev->flags & IN_c))
+ {
+ debug((-7, "PUSH in=%s next=%s [%s]", ppinstr(pp.in), pptokchr(*pp.in->nextchr), pp.in->nextchr));
+ PUSH_BUFFER("C", "extern \"C\" {\n", 1);
+ return;
+ }
+ }
+ else if (cur->prev->flags & IN_c)
+ {
+ debug((-7, "PUSH in=%s next=%s [%s]", ppinstr(pp.in), pptokchr(*pp.in->nextchr), pp.in->nextchr));
+ PUSH_BUFFER("C", "extern \"C++\" {\n", 1);
+ return;
+ }
+ break;
+ case IN_BUFFER:
+ cur->buffer = p = strdup(p);
+ break;
+ default:
+ cur->buffer = p;
+ break;
+ }
+ cur->nextchr = p;
+ break;
+#if DEBUG
+ default:
+ error(PANIC, "use PUSH_<%d>(...) instead of pppush(IN_<%d>, ...)", cur->type, cur->type);
+ break;
+#endif
+ }
+ debug((-7, "PUSH in=%s next=%s", ppinstr(pp.in), pptokchr(*pp.in->nextchr)));
+}
+
+/*
+ * external buffer push
+ */
+
+void
+ppinput(char* b, char* f, int n)
+{
+ PUSH_BUFFER(f, b, n);
+}
+
+/*
+ * return expanded value of buffer p
+ */
+
+char*
+ppexpand(register char* p)
+{
+ register char* m;
+ register int n;
+ register int c;
+ long restore;
+ char* pptoken;
+ char* ppmactop;
+ struct ppmacstk* nextmacp;
+ struct ppinstk* cur;
+
+ debug((-7, "before expand: %s", p));
+ if (ppmactop = pp.mactop)
+ {
+ nextmacp = pp.macp->next;
+ nextframe(pp.macp, pp.mactop);
+ }
+ restore = pp.state & (COLLECTING|DISABLE|STRIP);
+ pp.state &= ~restore;
+ pp.mode &= ~MARKMACRO;
+ PUSH_STRING(p);
+ cur = pp.in;
+ pp.in->flags |= IN_expand;
+ pptoken = pp.token;
+ n = 2 * MAXTOKEN;
+ pp.token = p = oldof(0, char, 0, n);
+ m = p + MAXTOKEN;
+ for (;;)
+ {
+ if (pplex())
+ {
+ if ((pp.token = pp.toknxt) > m)
+ {
+ c = pp.token - p;
+ p = newof(p, char, n += MAXTOKEN, 0);
+ m = p + n - MAXTOKEN;
+ pp.token = p + c;
+ }
+ if (pp.mode & MARKMACRO)
+ {
+ pp.mode &= ~MARKMACRO;
+ *pp.token++ = MARK;
+ *pp.token++ = 'X';
+ }
+ }
+ else if (pp.in == cur)
+ break;
+ }
+ *pp.token = 0;
+ if (ppmactop)
+ pp.macp->next = nextmacp;
+ debug((-7, "after expand: %s", p));
+ pp.token = pptoken;
+ pp.state |= restore;
+ pp.in = pp.in->prev;
+ return p;
+}
+
+#if CHECKPOINT
+
+#define LOAD_FUNCTION (1<<0)
+#define LOAD_MULTILINE (1<<1)
+#define LOAD_NOEXPAND (1<<2)
+#define LOAD_PREDICATE (1<<3)
+#define LOAD_READONLY (1<<4)
+#define LOAD_VARIADIC (1<<5)
+
+/*
+ * macro definition dump
+ */
+
+static int
+dump(const char* name, char* v, void* handle)
+{
+ register struct ppmacro* mac;
+ register struct ppsymbol* sym = (struct ppsymbol*)v;
+ register int flags;
+
+ NoP(name);
+ NoP(handle);
+ if ((mac = sym->macro) && !(sym->flags & (SYM_BUILTIN|SYM_PREDEFINED)))
+ {
+ ppprintf("%s", sym->name);
+ ppputchar(0);
+ flags = 0;
+ if (sym->flags & SYM_FUNCTION) flags |= LOAD_FUNCTION;
+ if (sym->flags & SYM_MULTILINE) flags |= LOAD_MULTILINE;
+ if (sym->flags & SYM_NOEXPAND) flags |= LOAD_NOEXPAND;
+ if (sym->flags & SYM_PREDICATE) flags |= LOAD_PREDICATE;
+ if (sym->flags & SYM_READONLY) flags |= LOAD_READONLY;
+ if (sym->flags & SYM_VARIADIC) flags |= LOAD_VARIADIC;
+ ppputchar(flags);
+ if (sym->flags & SYM_FUNCTION)
+ {
+ ppprintf("%d", mac->arity);
+ ppputchar(0);
+ if (mac->arity)
+ {
+ ppprintf("%s", mac->formals);
+ ppputchar(0);
+ }
+ }
+ ppprintf("%s", mac->value);
+ ppputchar(0);
+ }
+ return(0);
+}
+
+/*
+ * dump macro definitions for quick loading via ppload()
+ */
+
+void
+ppdump(void)
+{
+ register struct ppindex* ip;
+ unsigned long macro_offset;
+ unsigned long index_offset;
+
+ /*
+ * NOTE: we assume '\0' does not occur in valid preprocessed output
+ */
+
+ ppputchar(0);
+
+ /*
+ * output global flags
+ */
+
+ macro_offset = ppoffset();
+ ppputchar(0);
+
+ /*
+ * output macro definitions
+ */
+
+ hashwalk(pp.symtab, 0, dump, NiL);
+ ppputchar(0);
+
+ /*
+ * output include file index
+ */
+
+ index_offset = ppoffset();
+ ip = pp.firstindex;
+ while (ip)
+ {
+ ppprintf("%s", ip->file->name);
+ ppputchar(0);
+ if (ip->file->guard != INC_CLEAR && ip->file->guard != INC_IGNORE && ip->file->guard != INC_TEST)
+ ppprintf("%s", ip->file->guard->name);
+ ppputchar(0);
+ ppprintf("%lu", ip->begin);
+ ppputchar(0);
+ ppprintf("%lu", ip->end);
+ ppputchar(0);
+ ip = ip->next;
+ }
+ ppputchar(0);
+
+ /*
+ * output offset directory
+ */
+
+ ppprintf("%010lu", macro_offset);
+ ppputchar(0);
+ ppprintf("%010lu", index_offset);
+ ppputchar(0);
+ ppflushout();
+}
+
+/*
+ * load text and macro definitions from a previous ppdump()
+ * s is the string argument from the pragma (including quotes)
+ */
+
+void
+ppload(register char* s)
+{
+ register char* b;
+ register Sfio_t* sp;
+ int m;
+ char* g;
+ char* t;
+ unsigned long n;
+ unsigned long p;
+ unsigned long macro_offset;
+ unsigned long index_offset;
+ unsigned long file_offset;
+ unsigned long file_size;
+ unsigned long keep_begin;
+ unsigned long keep_end;
+ unsigned long skip_end;
+ unsigned long next_begin;
+ unsigned long next_end;
+ struct ppfile* fp;
+ struct ppsymbol* sym;
+ struct ppmacro* mac;
+
+ char* ip = 0;
+
+ pp.mode |= LOADING;
+ if (!(pp.state & STANDALONE))
+ error(3, "checkpoint load in standalone mode only");
+#if ARCHIVE
+ if (pp.member)
+ {
+ sp = pp.member->archive->info.sp;
+ file_offset = pp.member->offset;
+ file_size = pp.member->size;
+ if (sfseek(sp, file_offset + 22, SEEK_SET) != file_offset + 22 || !(s = sfgetr(sp, '\n', 1)))
+ error(3, "checkpoint magic error");
+ }
+ else
+#endif
+ {
+ if (pp.in->type != IN_FILE)
+ error(3, "checkpoint load from files only");
+ if (pp.in->flags & IN_prototype)
+ pp.in->fd = pppdrop(pp.in->buffer + PPBAKSIZ);
+ file_offset = 0;
+ if (pp.in->fd >= 0)
+ {
+ if (!(sp = sfnew(NiL, NiL, SF_UNBOUND, pp.in->fd, SF_READ)))
+ error(3, "checkpoint read error");
+ file_size = sfseek(sp, 0L, SEEK_END);
+ }
+ else
+ {
+ file_size = pp.in->buflen;
+ if (!(sp = sfnew(NiL, pp.in->buffer + ((pp.in->flags & IN_static) ? 0 : PPBAKSIZ), file_size, -1, SF_READ|SF_STRING)))
+ error(3, "checkpoint read error");
+ }
+ }
+ if (!streq(s, pp.checkpoint))
+ error(3, "checkpoint version %s does not match %s", s, pp.checkpoint);
+
+ /*
+ * get the macro and index offsets
+ */
+
+ p = file_offset + file_size - 22;
+ if ((n = sfseek(sp, p, SEEK_SET)) != p)
+ error(3, "checkpoint directory seek error");
+ if (!(t = sfreserve(sp, 22, 0)))
+ error(3, "checkpoint directory read error");
+ macro_offset = file_offset + strtol(t, &t, 10);
+ index_offset = file_offset + strtol(t + 1, NiL, 10);
+
+ /*
+ * read the include index
+ */
+
+ if (sfseek(sp, index_offset, SEEK_SET) != index_offset)
+ error(3, "checkpoint index seek error");
+ if (!(s = sfreserve(sp, n - index_offset, 0)))
+ error(3, "checkpoint index read error");
+ if (sfset(sp, 0, 0) & SF_STRING)
+ b = s;
+ else if (!(b = ip = memdup(s, n - index_offset)))
+ error(3, "checkpoint index alloc error");
+
+ /*
+ * loop on the index and copy the non-ignored chunks to the output
+ */
+
+ ppcheckout();
+ p = PPBUFSIZ - (pp.outp - pp.outbuf);
+ keep_begin = 0;
+ keep_end = 0;
+ skip_end = 0;
+ while (*b)
+ {
+ fp = ppsetfile(b);
+ while (*b++);
+ g = b;
+ while (*b++);
+ next_begin = strtol(b, &t, 10);
+ next_end = strtol(t + 1, &t, 10);
+if (pp.test & 0x0200) error(2, "%s: %s p=%lu next=<%lu,%lu> keep=<%lu,%lu> skip=<-,%lu> guard=%s", keyname(X_CHECKPOINT), fp->name, p, next_begin, next_end, keep_begin, keep_end, skip_end, fp->guard == INC_CLEAR ? "[CLEAR]" : fp->guard == INC_TEST ? "[TEST]" : fp->guard == INC_IGNORE ? "[IGNORE]" : fp->guard->name);
+ b = t + 1;
+ if (next_begin >= skip_end)
+ {
+ if (!ppmultiple(fp, INC_TEST))
+ {
+if (pp.test & 0x0100) error(2, "%s: %s IGNORE", keyname(X_CHECKPOINT), fp->name);
+ if (!keep_begin && skip_end < next_begin)
+ keep_begin = skip_end;
+ if (keep_begin)
+ {
+ flush:
+ if (sfseek(sp, file_offset + keep_begin, SEEK_SET) != file_offset + keep_begin)
+ error(3, "checkpoint data seek error");
+ n = next_begin - keep_begin;
+if (pp.test & 0x0100) error(2, "%s: copy <%lu,%lu> n=%lu p=%lu", keyname(X_CHECKPOINT), keep_begin, next_begin - 1, n, p);
+ while (n > p)
+ {
+ if (sfread(sp, pp.outp, p) != p)
+ error(3, "checkpoint data read error");
+ PPWRITE(PPBUFSIZ);
+ pp.outp = pp.outbuf;
+ n -= p;
+ p = PPBUFSIZ;
+ }
+ if (n)
+ {
+ if (sfread(sp, pp.outp, n) != n)
+ error(3, "checkpoint data read error");
+ pp.outp += n;
+ p -= n;
+ }
+ keep_begin = 0;
+ if (keep_end <= next_end)
+ keep_end = 0;
+ }
+ skip_end = next_end;
+ }
+ else if (!keep_begin)
+ {
+ if (skip_end)
+ {
+ keep_begin = skip_end;
+ skip_end = 0;
+ }
+ else keep_begin = next_begin;
+ if (keep_end < next_end)
+ keep_end = next_end;
+ }
+ }
+ if (*g && fp->guard != INC_IGNORE)
+ fp->guard = ppsymset(pp.symtab, g);
+ }
+ if (keep_end)
+ {
+ if (!keep_begin)
+ keep_begin = skip_end > next_end ? skip_end : next_end;
+ next_begin = next_end = keep_end;
+ g = b;
+ goto flush;
+ }
+if (pp.test & 0x0100) error(2, "%s: loop", keyname(X_CHECKPOINT));
+
+ /*
+ * read the compacted definitions
+ */
+
+ if (sfseek(sp, macro_offset, SEEK_SET) != macro_offset)
+ error(3, "checkpoint macro seek error");
+ if (!(s = sfreserve(sp, index_offset - macro_offset, 0)))
+ error(3, "checkpoint macro read error");
+
+ /*
+ * read the flags
+ */
+
+ while (*s)
+ {
+#if _options_dumped_
+ if (streq(s, "OPTION")) /* ... */;
+ else
+#endif
+ error(3, "%-.48s: unknown flags in checkpoint file", s);
+ }
+ s++;
+
+ /*
+ * unpack and enter the definitions
+ */
+
+ while (*s)
+ {
+ b = s;
+ while (*s++);
+ m = *s++;
+ sym = ppsymset(pp.symtab, b);
+ if (sym->macro)
+ {
+ if (m & LOAD_FUNCTION)
+ {
+ if (*s++ != '0')
+ while (*s++);
+ while (*s++);
+ }
+if (pp.test & 0x1000) error(2, "checkpoint SKIP %s=%s [%s]", sym->name, s, sym->macro->value);
+ while (*s++);
+ }
+ else
+ {
+ ppfsm(FSM_MACRO, b);
+ sym->flags = 0;
+ if (m & LOAD_FUNCTION) sym->flags |= SYM_FUNCTION;
+ if (m & LOAD_MULTILINE) sym->flags |= SYM_MULTILINE;
+ if (m & LOAD_NOEXPAND) sym->flags |= SYM_NOEXPAND;
+ if (m & LOAD_PREDICATE) sym->flags |= SYM_PREDICATE;
+ if (m & LOAD_READONLY) sym->flags |= SYM_READONLY;
+ if (m & LOAD_VARIADIC) sym->flags |= SYM_VARIADIC;
+ mac = sym->macro = newof(0, struct ppmacro, 1, 0);
+ if (sym->flags & SYM_FUNCTION)
+ {
+ for (n = 0; *s >= '0' && *s <= '9'; n = n * 10 + *s++ - '0');
+ if (*s++) error(3, "%-.48: checkpoint macro arity botched", sym->name);
+ if (mac->arity = n)
+ {
+ b = s;
+ while (*s++);
+ mac->formals = (char*)memcpy(oldof(0, char, 0, s - b), b, s - b);
+ }
+ }
+ b = s;
+ while (*s++);
+ mac->size = s - b - 1;
+ mac->value = (char*)memcpy(oldof(0, char, 0, mac->size + 1), b, mac->size + 1);
+if (pp.test & 0x1000) error(2, "checkpoint LOAD %s=%s", sym->name, mac->value);
+ }
+ }
+
+ /*
+ * we are now at EOF
+ */
+
+ if (ip)
+ {
+ pp.in->fd = -1;
+ free(ip);
+ }
+#if ARCHIVE
+ if (pp.member) pp.member = 0;
+ else
+#endif
+ {
+ sfclose(sp);
+ pp.in->flags |= IN_eof|IN_newline;
+ pp.in->nextchr = pp.in->buffer + PPBAKSIZ;
+ *pp.in->nextchr++ = 0;
+ *pp.in->nextchr = 0;
+ }
+ pp.mode &= ~LOADING;
+}
+
+#endif
diff --git a/usr/src/lib/libpp/common/ppkey.c b/usr/src/lib/libpp/common/ppkey.c
new file mode 100644
index 0000000000..6dfe481cc4
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppkey.c
@@ -0,0 +1,118 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * preprocessor C language reserved keyword token table
+ * for use by PP_COMPILE
+ *
+ * "-" keywords entered without SYM_KEYWORD
+ * "+" keywords entered without SYM_KEYWORD unless PP_PLUSPLUS was set
+ * upper case are pseudo keywords for PP_RESERVED token classes
+ */
+
+#include "pplib.h"
+#include "ppkey.h"
+
+struct ppkeyword ppkey[] =
+{
+ "auto", T_AUTO,
+ "break", T_BREAK,
+ "case", T_CASE,
+ "char", T_CHAR,
+ "continue", T_CONTINUE,
+ "default", T_DEFAULT,
+ "do", T_DO,
+ "double", T_DOUBLE_T,
+ "else", T_ELSE,
+ "extern", T_EXTERN,
+ "float", T_FLOAT_T,
+ "for", T_FOR,
+ "goto", T_GOTO,
+ "if", T_IF,
+ "int", T_INT,
+ "long", T_LONG,
+ "register", T_REGISTER,
+ "return", T_RETURN,
+ "short", T_SHORT,
+ "sizeof", T_SIZEOF,
+ "static", T_STATIC,
+ "struct", T_STRUCT,
+ "switch", T_SWITCH,
+ "typedef", T_TYPEDEF,
+ "union", T_UNION,
+ "unsigned", T_UNSIGNED,
+ "while", T_WHILE,
+ "-const", T_CONST,
+ "-enum", T_ENUM,
+ "-signed", T_SIGNED,
+ "-void", T_VOID,
+ "-volatile", T_VOLATILE,
+ "+asm", T_ASM,
+ "+class", T_CLASS,
+ "+delete", T_DELETE,
+ "+friend", T_FRIEND,
+ "+inline", T_INLINE,
+ "+new", T_NEW,
+ "+operator", T_OPERATOR,
+ "+overload", T_OVERLOAD,
+ "+private", T_PRIVATE,
+ "+public", T_PUBLIC,
+ "+this", T_THIS,
+ "+virtual", T_VIRTUAL,
+ "-and", T_ANDAND,
+ "-and_eq", T_ANDEQ,
+ "-bitand", '&',
+ "-bitor", '|',
+ "-bool", T_BOOL,
+ "-catch", T_CATCH,
+ "-compl", '~',
+ "-const_cast", T_CONST_CAST,
+ "-dynamic_cast",T_DYNAMIC_CAST,
+ "-explicit", T_EXPLICIT,
+ "-false", T_FALSE,
+ "-mutable", T_MUTABLE,
+ "-namespace", T_NAMESPACE,
+ "-not", '!',
+ "-not_eq", T_NE,
+ "-or", T_OROR,
+ "-or_eq", T_OREQ,
+ "-protected", T_PROTECTED,
+ "-reinterpret_cast", T_REINTERPRET_CAST,
+ "-static_cast", T_STATIC_CAST,
+ "-template", T_TEMPLATE,
+ "-throw", T_THROW,
+ "-true", T_TRUE,
+ "-try", T_TRY,
+ "-typeid", T_TYPEID,
+ "-using", T_USING,
+ "-wchar_t", T_WCHAR_T,
+ "-xor", '^',
+ "-xor_eq", T_XOREQ,
+ "-int64", T_INT64,
+ "-NOISES", T_NOISES,
+ "-NOISE", T_NOISE,
+ "-GROUP", T_X_GROUP,
+ "-LINE", T_X_LINE,
+ "-STATEMENT", T_X_STATEMENT,
+ 0, 0, 0
+};
diff --git a/usr/src/lib/libpp/common/ppkey.h b/usr/src/lib/libpp/common/ppkey.h
new file mode 100644
index 0000000000..95f89e52c1
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppkey.h
@@ -0,0 +1,146 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * preprocessor C language keyword token values
+ * handles classic, ANSI and C++
+ * additional non-standard keyword tokens are
+ * crammed into T_NOISE and T_X_*
+ */
+
+#ifndef _PPKEY_H
+#define _PPKEY_H
+
+/*
+ * NOTE: preserve the ranges for is*()
+ */
+
+#define ppisnoise(x) ((x)>=T_NOISE&&(x)<T_KEYWORD)
+
+/*
+ * classic
+ */
+
+#define T_AUTO (T_TOKEN+0)
+#define T_BREAK (T_TOKEN+1)
+#define T_CASE (T_TOKEN+2)
+#define T_CHAR (T_TOKEN+3)
+#define T_CONTINUE (T_TOKEN+4)
+#define T_DEFAULT (T_TOKEN+5)
+#define T_DO (T_TOKEN+6)
+#define T_DOUBLE_T (T_TOKEN+7)
+#define T_ELSE (T_TOKEN+8)
+#define T_EXTERN (T_TOKEN+9)
+#define T_FLOAT_T (T_TOKEN+10)
+#define T_FOR (T_TOKEN+11)
+#define T_GOTO (T_TOKEN+12)
+#define T_IF (T_TOKEN+13)
+#define T_INT (T_TOKEN+14)
+#define T_LONG (T_TOKEN+15)
+#define T_REGISTER (T_TOKEN+16)
+#define T_RETURN (T_TOKEN+17)
+#define T_SHORT (T_TOKEN+18)
+#define T_SIZEOF (T_TOKEN+19)
+#define T_STATIC (T_TOKEN+20)
+#define T_STRUCT (T_TOKEN+21)
+#define T_SWITCH (T_TOKEN+22)
+#define T_TYPEDEF (T_TOKEN+23)
+#define T_UNION (T_TOKEN+24)
+#define T_UNSIGNED (T_TOKEN+25)
+#define T_WHILE (T_TOKEN+26)
+
+/*
+ * ANSI
+ */
+
+#define T_CONST (T_TOKEN+27)
+#define T_ENUM (T_TOKEN+28)
+#define T_SIGNED (T_TOKEN+29)
+#define T_VOID (T_TOKEN+30)
+#define T_VOLATILE (T_TOKEN+31)
+
+/*
+ * C++
+ */
+
+#define T_ASM (T_TOKEN+32)
+#define T_BOOL (T_TOKEN+33)
+#define T_CATCH (T_TOKEN+34)
+#define T_CLASS (T_TOKEN+35)
+#define T_CONST_CAST (T_TOKEN+36)
+#define T_DELETE (T_TOKEN+37)
+#define T_DYNAMIC_CAST (T_TOKEN+38)
+#define T_EXPLICIT (T_TOKEN+39)
+#define T_FALSE (T_TOKEN+40)
+#define T_FRIEND (T_TOKEN+41)
+#define T_INLINE (T_TOKEN+42)
+#define T_MUTABLE (T_TOKEN+43)
+#define T_NAMESPACE (T_TOKEN+44)
+#define T_NEW (T_TOKEN+45)
+#define T_OPERATOR (T_TOKEN+46)
+#define T_OVERLOAD (T_TOKEN+47)
+#define T_PRIVATE (T_TOKEN+48)
+#define T_PROTECTED (T_TOKEN+49)
+#define T_PUBLIC (T_TOKEN+50)
+#define T_REINTERPRET_CAST (T_TOKEN+51)
+#define T_STATIC_CAST (T_TOKEN+52)
+#define T_TEMPLATE (T_TOKEN+53)
+#define T_THIS (T_TOKEN+54)
+#define T_THROW (T_TOKEN+55)
+#define T_TRUE (T_TOKEN+56)
+#define T_TRY (T_TOKEN+57)
+#define T_TYPEID (T_TOKEN+58)
+#define T_USING (T_TOKEN+59)
+#define T_VIRTUAL (T_TOKEN+60)
+#define T_WCHAR_T (T_TOKEN+61)
+
+/*
+ * future
+ */
+
+#define T_INT64 (T_TOKEN+62)
+
+/*
+ * non-standard
+ */
+
+#define T_BUILTIN (T_TOKEN+63)
+#define T_NOISES (T_TOKEN+64)
+#define T_NOISE (T_TOKEN+65)
+#define T_X_GROUP (T_TOKEN+66)
+#define T_X_LINE (T_TOKEN+67)
+#define T_X_STATEMENT (T_TOKEN+68)
+
+/*
+ * first available keyword token value
+ */
+
+#define T_KEYWORD (T_TOKEN+69)
+
+/*
+ * implementation globals
+ */
+
+extern struct ppkeyword ppkey[];
+
+#endif
diff --git a/usr/src/lib/libpp/common/pplex.c b/usr/src/lib/libpp/common/pplex.c
new file mode 100644
index 0000000000..364854d8ae
--- /dev/null
+++ b/usr/src/lib/libpp/common/pplex.c
@@ -0,0 +1,2441 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * preprocessor lexical analyzer
+ * standalone and tokenizing lexer combined in one source
+ * define CPP=1 for standalone
+ */
+
+#include "pplib.h"
+#include "ppfsm.h"
+
+#if CPP
+
+/*
+ * standalone entry point
+ */
+
+#define PPCPP_T void
+
+#define START QUICK
+#define INMACRO(x) INQMACRO(x)
+#define DOSTRIP() (st&STRIP)
+
+#if DEBUG & TRACE_debug
+static int hit[LAST-TERMINAL+2];
+#endif
+
+#define BACKIN() (ip--)
+#define BACKOUT() (op=tp)
+#define CACHE() do{CACHEINX();CACHEOUTX();st=pp.state;if(!pp.hidden)spliced=0;}while(0)
+#define CACHEIN() do{CACHEINX();st=pp.state;if(!pp.hidden)spliced=0;}while(0)
+#define CACHEINX() do{ip=pp.in->nextchr;}while(0)
+#define CACHEOUT() do{CACHEOUTX();st=pp.state;if(!pp.hidden)spliced=0;}while(0)
+#define CACHEOUTX() do{tp=op=pp.outp;xp=pp.oute;if(sp)sp=op;}while(0)
+#define GETCHR() (*(unsigned char*)ip++)
+#define LASTCHR() (*(ip-1))
+#define LASTOUT() ((op>pp.outbuf)?*(op-1):pp.lastout)
+#define SKIPIN() (ip++)
+#define PUTCHR(c) (*op++=(c))
+#define SETCHR(c) (*op=(c))
+#define SYNC() do{SYNCINX();SYNCOUTX();pp.state=st;}while(0)
+#define SYNCIN() do{SYNCINX();pp.state=st;}while(0)
+#define SYNCINX() do{pp.in->nextchr=ip;}while(0)
+#define SYNCOUT() do{SYNCOUTX();pp.state=st;}while(0)
+#define SYNCOUTX() do{if(sp)op=tp=sp;pp.outp=op;}while(0)
+#define UNGETCHR(c) (*--ip=(c))
+
+#define PPCHECKOUT() do{if(op>xp){{PPWRITE(PPBUFSIZ);if(pp.outbuf==pp.outb){pp.outbuf+=PPBUFSIZ;xp=pp.oute+=PPBUFSIZ;}else{pp.outbuf-=PPBUFSIZ;memcpy(pp.outbuf,xp,op-xp);xp=pp.oute-=PPBUFSIZ;op-=2*PPBUFSIZ;}}}}while(0)
+#define PPCHECKOUTSP() do{if(op>xp){if(sp)op=sp;else{PPWRITE(PPBUFSIZ);if(pp.outbuf==pp.outb){pp.outbuf+=PPBUFSIZ;xp=pp.oute+=PPBUFSIZ;}else{pp.outbuf-=PPBUFSIZ;memcpy(pp.outbuf,xp,op-xp);xp=pp.oute-=PPBUFSIZ;op-=2*PPBUFSIZ;}}}}while(0)
+#define PPCHECKOUTTP() do{if(op>xp){{PPWRITE(PPBUFSIZ);if(pp.outbuf==pp.outb){pp.outbuf+=PPBUFSIZ;xp=pp.oute+=PPBUFSIZ;}else{pp.outbuf-=PPBUFSIZ;memcpy(pp.outbuf,xp,op-xp);xp=pp.oute-=PPBUFSIZ;op-=2*PPBUFSIZ;}}tp=op;}}while(0)
+
+#define PPSYNCLINE() do { \
+ if ((st & (ADD|HIDDEN)) && !(*pp.control & SKIP)) \
+ { \
+ if (spliced) \
+ { \
+ error_info.line += spliced; \
+ spliced = 0; \
+ } \
+ else \
+ { \
+ if (st & ADD) \
+ { \
+ st &= ~ADD; \
+ m = pp.addp - pp.addbuf; \
+ pp.addp = pp.addbuf; \
+ memcpy(op, pp.addbuf, m); \
+ op += m; \
+ PPCHECKOUT(); \
+ } \
+ if (pp.linesync) \
+ { \
+ if ((st & SYNCLINE) || pp.hidden >= MAXHIDDEN) \
+ { \
+ pp.hidden = 0; \
+ st &= ~(HIDDEN|SYNCLINE); \
+ if (error_info.line) \
+ { \
+ if (LASTOUT() != '\n') \
+ PUTCHR('\n'); \
+ SYNCOUT(); \
+ (*pp.linesync)(error_info.line, error_info.file); \
+ CACHEOUT(); \
+ } \
+ } \
+ else \
+ { \
+ m = pp.hidden; \
+ pp.hidden = 0; \
+ st &= ~HIDDEN; \
+ while (m-- > 0) \
+ PUTCHR('\n'); \
+ } \
+ } \
+ else \
+ { \
+ pp.hidden = 0; \
+ st &= ~HIDDEN; \
+ PUTCHR('\n'); \
+ } \
+ } \
+ } \
+ } while (0)
+
+#if POOL
+
+/*
+ * <wait.h> is poison here so pool moved to the end
+ */
+
+static void poolstatus(void);
+static void pool(void);
+
+#endif
+
+#else
+
+/*
+ * return next pp token
+ *
+ * NOTE: pp.token points to at least MAXTOKEN*2 chars and is
+ * truncated back to MAXTOKEN on EOB
+ */
+
+#define PPCPP_T int
+#define ppcpp pplex
+
+#define START TOKEN
+#define INMACRO(x) INTMACRO(x)
+#define DOSTRIP() ((st&STRIP)||pp.level==1&&(st&(COMPILE|JOINING))==COMPILE&&!(pp.option&PRESERVE))
+
+#define st pp.state
+#define tp pp.token
+#define xp &pp.token[MAXTOKEN]
+
+#define BACKIN() (ip--)
+#define BACKOUT() (op=pp.token)
+#define CACHE() do{CACHEIN();CACHEOUT();}while(0)
+#define CACHEIN() (ip=pp.in->nextchr)
+#define CACHEOUT() (op=pp.token)
+#define GETCHR() (*(unsigned char*)ip++)
+#define LASTCHR() (*(ip-1))
+#define PUTCHR(c) (*op++=(c))
+#define SETCHR(c) (*op=(c))
+#define SKIPIN() (ip++)
+#define SYNC() do{SYNCIN();SYNCOUT();}while(0)
+#define SYNCIN() (pp.in->nextchr=ip)
+#define SYNCOUT() (pp.toknxt=op)
+#define UNGETCHR(c) (*--ip=(c))
+
+#endif
+
+PPCPP_T
+ppcpp(void)
+{
+ register short* rp;
+ register char* ip;
+ register int state;
+ register int c;
+ register char* op;
+ char* bp;
+ int n;
+ int m;
+ int quot;
+ int quotquot;
+ int comdelim = 0;
+ int comstart = 0;
+ int comwarn = 0;
+ char* s;
+ struct ppsymbol* sym;
+#if CPP
+ register long st;
+ char* tp;
+ char* xp;
+ char* sp = 0;
+ int qual = 0;
+ int spliced = 0;
+#else
+ int qual;
+#endif
+
+#if CPP
+#if POOL
+ fsm_pool:
+#endif
+#else
+ count(pplex);
+#endif
+ error_info.indent++;
+ pp.level++;
+ CACHE();
+#if !CPP
+ fsm_top:
+ qual = 0;
+#endif
+ fsm_start:
+#if CPP
+ PPCHECKOUTSP();
+ tp = op;
+#endif
+ state = START;
+ fsm_begin:
+ bp = ip;
+ do
+ {
+ rp = fsm[state];
+ fsm_get:
+ while (!(state = rp[c = GETCHR()]));
+ fsm_next:
+ ;
+ } while (state > 0);
+ if (((state = ~state) != S_COMMENT || pp.comment || c == '/' && !INCOMMENT(rp)) && (n = ip - bp - 1) > 0)
+ {
+ ip = bp;
+#if CPP
+ if (op == tp && (st & (ADD|HIDDEN)) && !(st & PASSTHROUGH))
+ switch (TERM(state))
+ {
+ case S_SHARP:
+ break;
+ case S_CHRB:
+ case S_NL:
+ if (*ip == '\n')
+ break;
+ /*FALLTHROUGH*/
+ default:
+ PPSYNCLINE();
+ tp = op;
+ break;
+ }
+#endif
+ MEMCPY(op, ip, n);
+ ip++;
+ }
+ count(terminal);
+#if CPP && (DEBUG & TRACE_debug)
+ hit[(state & SPLICE) ? (elementsof(hit) - 1) : (TERM(state) - TERMINAL)]++;
+#endif
+ fsm_terminal:
+ debug((-9, "TERM %s > %s%s%s |%-*.*s|%s|", pplexstr(INDEX(rp)), pplexstr(state), (st & NEWLINE) ? "|NEWLINE" : "", (st & SKIPCONTROL) ? "|SKIP" : "", op - tp, op - tp, tp, pptokchr(c)));
+ switch (TERM(state))
+ {
+
+#if !CPP
+ case S_CHR:
+ PUTCHR(c);
+ break;
+#endif
+
+ case S_CHRB:
+ BACKIN();
+#if CPP
+ st &= ~NEWLINE;
+ pp.in->flags |= IN_tokens;
+ count(token);
+ goto fsm_start;
+#else
+ c = *tp;
+ break;
+#endif
+
+ case S_COMMENT:
+ switch (c)
+ {
+ case '\n':
+ if (!INCOMMENTXX(rp))
+ {
+ qual = 0;
+ if (!comstart) comstart = comdelim = error_info.line;
+ error_info.line++;
+ if (pp.comment) PUTCHR(c);
+ else BACKOUT();
+#if CPP
+ rp = fsm[COM2];
+ bp = ip;
+ goto fsm_get;
+#else
+ state = COM2;
+ goto fsm_begin;
+#endif
+ }
+ else if (comwarn < 0 && !(pp.mode & HOSTED))
+ error(1, "/* appears in // comment");
+ break;
+ case '*':
+ if (!comwarn && !(pp.mode & HOSTED))
+ {
+ if (INCOMMENTXX(rp)) comwarn = -1;
+ else if (comstart && comstart != error_info.line)
+ {
+ if (qual || comdelim < error_info.line - 1)
+ {
+ error(1, "/* appears in /* ... */ comment starting at line %d", comstart);
+ comwarn = 1;
+ }
+ else comdelim = error_info.line;
+ }
+ }
+ fsm_comment:
+ PUTCHR(c);
+#if CPP
+ rp = fsm[INCOMMENTXX(rp) ? COM5 : COM3];
+ bp = ip;
+ goto fsm_get;
+#else
+ state = INCOMMENTXX(rp) ? COM5 : COM3;
+ goto fsm_begin;
+#endif
+ case '/':
+ if (!INCOMMENT(rp))
+ {
+ if (!(pp.mode & HOSTED))
+ error(1, "*/ appears outside of comment");
+ BACKIN();
+#if CPP
+ st &= ~NEWLINE;
+ pp.in->flags |= IN_tokens;
+ count(token);
+ goto fsm_start;
+#else
+ c = '*';
+ if (!pp.comment) PUTCHR(c);
+ goto fsm_token;
+#endif
+ }
+ else if (INCOMMENTXX(rp))
+ {
+ if (!(pp.mode & HOSTED))
+ {
+ if (comwarn < 0) comwarn = 0;
+ else if (!comwarn)
+ {
+ comwarn = 1;
+ error(1, "*/ appears in // comment");
+ }
+ }
+ goto fsm_comment;
+ }
+ break;
+ case EOF:
+ BACKIN();
+ if (!(pp.mode & HOSTED))
+ {
+ if (comstart) error(2, "unterminated /* ... */ comment starting at line %d", comstart);
+ else if (INCOMMENTXX(rp)) error(2, "unterminated // ... comment");
+ else error(2, "unterminated /* ... */ comment");
+ }
+ break;
+ }
+#if CPP
+ if (!pp.comment || sp)
+ {
+#if COMPATIBLE
+ if (!(pp.state & COMPATIBILITY) || *bp == ' ' || *bp == '\t')
+#endif
+ {
+ BACKOUT();
+ PUTCHR(' ');
+ tp = op;
+ }
+ }
+ else if (pp.in->type & IN_TOP)
+#else
+ if (pp.comment && !(st & (COLLECTING|DIRECTIVE|JOINING)) && !(*pp.control & SKIP) && (pp.in->type & IN_TOP))
+#endif
+ {
+ st &= ~HIDDEN;
+ pp.hidden = 0;
+ *(op - (c != '\n')) = 0;
+ m = (op - (c != '\n') - tp > MAXTOKEN - 6) ? (error_info.line - MAXHIDDEN) : 0;
+ BACKOUT();
+ SYNC();
+ while (*tp != '/') tp++;
+ (*pp.comment)(c == '\n' ? "//" : "/*", tp + 2, c == '\n' ? "" : (st & HEADER) ? "*/\n" : "*/", comstart ? comstart : error_info.line);
+ CACHE();
+ comstart = m;
+ }
+ if (comstart)
+ {
+ st |= HIDDEN;
+ pp.hidden += error_info.line - comstart;
+ comstart = 0;
+ }
+ qual = comwarn = comdelim = 0;
+ BACKOUT();
+ if (c == '\n') goto fsm_newline;
+ if ((st & PASSTHROUGH) && ((st & (HIDDEN|NEWLINE)) || *ip == '\n'))
+ {
+ if (*ip == '\n')
+ ip++;
+ goto fsm_newline;
+ }
+#if COMPATIBLE
+ if ((st & (COMPATIBILITY|TRANSITION)) == COMPATIBILITY) st &= ~NEWLINE;
+#endif
+#if !CPP
+ if (pp.level > 1 && !(st & (NOSPACE|SKIPCONTROL)))
+ {
+#if COMPATIBLE
+ c = ((st & (COMPATIBILITY|DEFINITION)) == ((COMPATIBILITY|DEFINITION))) ? '\t' : ' ';
+#else
+ c = ' ';
+#endif
+ goto fsm_return;
+ }
+#endif
+ goto fsm_start;
+
+ case S_EOB:
+ if (c)
+ {
+ if (state = fsm[TERMINAL][INDEX(rp)+1])
+ goto fsm_terminal;
+#if CPP
+#if POOL
+ if (pp.pool.input)
+ {
+ BACKIN();
+ SYNC();
+ pool();
+ CACHE();
+ goto fsm_pool;
+ }
+#endif
+ SYNCOUT();
+ return;
+#else
+ BACKIN();
+ c = 0;
+ goto fsm_return;
+#endif
+ }
+ {
+ register struct ppinstk* cur = pp.in;
+ register struct ppinstk* prv = pp.in->prev;
+
+#if CPP
+ if (sp) op = sp;
+#endif
+ switch (cur->type)
+ {
+ case IN_BUFFER:
+ case IN_INIT:
+ case IN_RESCAN:
+#if CPP
+ if (prv)
+#else
+ if (!(st & PASSEOF) && prv)
+#endif
+ {
+ if (cur->type == IN_RESCAN || cur->type == IN_BUFFER)
+ {
+ fsm_pop:
+#if PROTOTYPE
+ if (cur->flags & IN_prototype)
+ pppclose(cur->buffer + PPBAKSIZ);
+ else
+#endif
+ if (!(cur->flags & IN_static))
+ free(cur->buffer);
+ }
+ while (pp.control-- != cur->control)
+ error(2, "#%s on line %d has no #%s", dirname(IF), GETIFLINE(pp.control+1), dirname(ENDIF));
+ st |= NEWLINE;
+ error_info.file = cur->file;
+ error_info.line = cur->line;
+ pp.hidden = 0;
+#if CPP
+ spliced = 0;
+#endif
+ if (cur->flags & IN_hosted)
+ {
+ pp.mode |= HOSTED;
+ pp.flags |= PP_hosted;
+ }
+ else
+ {
+ pp.mode &= ~HOSTED;
+ pp.flags &= ~PP_hosted;
+ }
+#if !CPP && CATSTRINGS
+ if (st & JOINING) st |= HIDDEN|SYNCLINE;
+ else
+#endif
+ {
+ st &= ~(HIDDEN|SYNCLINE);
+ switch (cur->type)
+ {
+ case IN_BUFFER:
+ case IN_INIT:
+ if (!prv->prev) break;
+ /*FALLTHROUGH*/
+ case IN_FILE:
+ case IN_RESCAN:
+ if (prv->type == IN_FILE || cur->type == IN_FILE && (prv->type == IN_RESCAN || prv->type == IN_MULTILINE))
+ {
+ if (pp.linesync && (cur->type != IN_RESCAN || (cur->flags & IN_sync)))
+ {
+ POP();
+ SYNCOUT();
+ (*pp.linesync)(error_info.line, error_info.file);
+ CACHEOUT();
+ prv = pp.in;
+ }
+ }
+#if DEBUG
+ else if (!prv->prev)
+ {
+ /*UNDENT*/
+ c = 0;
+#if DEBUG & TRACE_count
+ if (pp.test & TEST_count)
+ {
+ c = 1;
+ sfprintf(sfstderr, "\n");
+ sfprintf(sfstderr, "%7d: pplex calls\n", pp.counter.pplex);
+ sfprintf(sfstderr, "%7d: terminal states\n", pp.counter.terminal);
+ sfprintf(sfstderr, "%7d: emitted tokens\n", pp.counter.token);
+ sfprintf(sfstderr, "%7d: input stream pushes\n", pp.counter.push);
+ sfprintf(sfstderr, "%7d: macro candidates\n", pp.counter.candidate);
+ sfprintf(sfstderr, "%7d: macro expansions\n", pp.counter.macro);
+ sfprintf(sfstderr, "%7d: function macros\n", pp.counter.function);
+ }
+#endif
+#if CPP && (DEBUG & TRACE_debug)
+ if (pp.test & TEST_hit)
+ {
+ c = 1;
+ sfprintf(sfstderr, "\n");
+ if (hit[elementsof(hit) - 1])
+ sfprintf(sfstderr, "%7d: SPLICE\n", hit[elementsof(hit) - 1]);
+ for (n = 0; n < elementsof(hit) - 1; n++)
+ if (hit[n])
+ sfprintf(sfstderr, "%7d: %s\n", hit[n], pplexstr(TERMINAL + n));
+ }
+#endif
+ if (pp.test & (TEST_hashcount|TEST_hashdump))
+ {
+ c = 1;
+ sfprintf(sfstderr, "\n");
+ hashdump(NiL, (pp.test & TEST_hashdump) ? HASH_BUCKET : 0);
+ }
+ if (c) sfprintf(sfstderr, "\n");
+ /*INDENT*/
+ }
+#endif
+ break;
+ }
+ }
+#if CHECKPOINT
+ if (cur->index)
+ {
+ SYNCOUT();
+ cur->index->end = ppoffset();
+ cur->index = 0;
+ CACHEOUT();
+ }
+#endif
+ POP();
+ bp = ip;
+ tp = op;
+ goto fsm_get;
+ }
+ c = EOF;
+ break;
+ case IN_COPY:
+ if (prv)
+ {
+ error_info.line = cur->line;
+ if (!(prv->symbol->flags & SYM_MULTILINE))
+ prv->symbol->flags |= SYM_DISABLED;
+ POP();
+ bp = ip;
+ goto fsm_get;
+ }
+ c = EOF;
+ break;
+ case IN_EXPAND:
+ if (prv)
+ {
+ error_info.line = cur->line;
+ free(cur->buffer);
+ POP();
+ bp = ip;
+ goto fsm_get;
+ }
+ c = EOF;
+ break;
+ case IN_FILE:
+ FGET(c, c, tp, xp);
+ if (c == EOB)
+ {
+#if CPP
+ if ((st & (NOTEXT|HIDDEN)) == HIDDEN && LASTOUT() != '\n')
+ PUTCHR('\n');
+ if (prv)
+#else
+ if (st & EOF2NL)
+ {
+ st &= ~EOF2NL;
+ *(ip - 1) = c = '\n';
+ }
+ else if (!(st & (FILEPOP|PASSEOF)) && prv)
+#endif
+ {
+ if (!(cur->flags & IN_newline))
+ {
+ cur->flags |= IN_newline;
+ if ((pp.mode & (HOSTED|PEDANTIC)) == PEDANTIC && LASTCHR() != '\f' && LASTCHR() != CC_sub)
+ error(1, "file does not end with %s", pptokchr('\n'));
+ *(ip - 1) = c = '\n';
+ }
+ else
+ {
+ if (!(cur->flags & (IN_noguard|IN_tokens)) && cur->symbol)
+ ppmultiple(ppsetfile(error_info.file), cur->symbol);
+ if (cur->fd >= 0)
+ close(cur->fd);
+ if (pp.incref && !(pp.mode & INIT))
+ {
+ SYNCOUT();
+ (*pp.incref)(error_info.file, cur->file, error_info.line - 1, PP_SYNC_POP);
+ CACHEOUT();
+ }
+ goto fsm_pop;
+ }
+ }
+ else
+ c = EOF;
+ }
+ break;
+ case IN_MACRO:
+ case IN_MULTILINE:
+#if !CPP
+ if (!(st & PASSEOF))
+#endif
+#if COMPATIBLE
+ if (prv && (!INMACRO(rp) || (st & (COMPATIBILITY|TRANSITION)) == COMPATIBILITY && ppismac(*prv->nextchr)))
+#else
+ if (prv && !INMACRO(rp))
+#endif
+ {
+ if (cur->type == IN_MULTILINE)
+ {
+ while (pp.control-- != cur->control)
+ error(2, "#%s on line %d has no #%s", dirname(IF), GETIFLINE(pp.control+1), dirname(ENDIF));
+ free(cur->buffer);
+ error_info.file = cur->file;
+ error_info.line = cur->line;
+ if (pp.linesync)
+ {
+ SYNCOUT();
+ (*pp.linesync)(error_info.line, error_info.file);
+ CACHEOUT();
+ }
+ }
+ cur->symbol->flags &= ~SYM_DISABLED;
+ if (cur->symbol->flags & SYM_FUNCTION)
+ popframe(pp.macp);
+ POP();
+#if CPP
+ if (!(st & COMPATIBILITY) && ppisidig(*(op - 1)) && ppisidig(*ip)) UNGETCHR(' ');
+#endif
+ bp = ip;
+ goto fsm_get;
+ }
+ c = EOF;
+ break;
+ case IN_QUOTE:
+ if (prv)
+ {
+ error_info.line = cur->line;
+ st &= ~(ESCAPE|QUOTE);
+ POP();
+ c = '"';
+ }
+ else c = EOF;
+ break;
+ case IN_SQUOTE:
+ if (prv)
+ {
+ error_info.line = cur->line;
+ st &= ~(ESCAPE|SQUOTE);
+ POP();
+ c = '\'';
+ }
+ else c = EOF;
+ break;
+ case IN_STRING:
+#if CPP
+ if (prv)
+#else
+ if (!(st & PASSEOF) && !(cur->flags & IN_expand) && prv)
+#endif
+ {
+ if (cur->flags & IN_disable) st |= DISABLE;
+ else st &= ~DISABLE;
+ POP();
+ bp = ip;
+ goto fsm_get;
+ }
+ c = EOF;
+ break;
+ default:
+ c = EOF;
+ break;
+ }
+ }
+ bp = ip - 1;
+ if (state = rp[c]) goto fsm_next;
+ goto fsm_get;
+
+#if !CPP
+ case S_HUH:
+ if (INOPSPACE(rp))
+ {
+ if (c == '=')
+ {
+#if PROTOTYPE
+ if (pp.in->flags & IN_prototype) PUTCHR(c);
+ else
+ {
+#endif
+ while (*(op - 1) == ' ' || *(op - 1) == '\t') op--;
+ PUTCHR(c);
+ if (st & (STRICT|WARN)) error(1, "%-*.*s: space ignored in operator", op - tp, op - tp, tp);
+#if PROTOTYPE
+ }
+#endif
+ switch (*tp)
+ {
+ case '/':
+ c = T_DIVEQ;
+ break;
+ case '%':
+ c = T_MODEQ;
+ break;
+ case '&':
+ c = T_ANDEQ;
+ break;
+ case '*':
+ c = T_MPYEQ;
+ break;
+ case '+':
+ c = T_ADDEQ;
+ break;
+ case '-':
+ c = T_SUBEQ;
+ break;
+ case '^':
+ c = T_XOREQ;
+ break;
+ case '|':
+ c = T_OREQ;
+ break;
+ case '<':
+ c = T_LSHIFTEQ;
+ break;
+ case '>':
+ c = T_RSHIFTEQ;
+ break;
+ }
+ }
+ else
+ {
+ BACKIN();
+ switch (c = *tp)
+ {
+ case '<':
+ c = T_LSHIFT;
+ break;
+ case '>':
+ c = T_RSHIFT;
+ break;
+ }
+ }
+ }
+ else if (pp.level > 1 || (pp.option & PRESERVE)) PUTCHR(c);
+ else if (tp == op)
+ {
+ if (pp.in->type != IN_BUFFER)
+ {
+ if (!(pp.option & ALLPOSSIBLE))
+ error(1, "%s: invalid character ignored", pptokchr(c));
+ goto fsm_top;
+ }
+ PUTCHR(c);
+ }
+ else if (*tp == ':')
+ {
+ PUTCHR(c);
+ if (c == '=') error(2, "real programmers use =");
+ else c = '+';
+ }
+ else
+ {
+ BACKIN();
+ c = *tp;
+ }
+ break;
+#endif
+
+ case S_QUAL:
+ if ((state = NEXT(state)) != LIT1)
+ {
+ rp = fsm[state];
+ bp = ip;
+#if CPP
+ qual = 1;
+#if COMPATIBLE
+ if (!(st & COMPATIBILITY) || c != 'u' && c != 'U')
+#endif
+ PUTCHR(c);
+#else
+ switch (c)
+ {
+ case 'f':
+ case 'F':
+ qual |= N_FLOAT;
+#if COMPATIBLE
+ if (!(st & COMPATIBILITY))
+#endif
+ PUTCHR(c);
+ break;
+ case 'l':
+ case 'L':
+ qual |= N_LONG;
+ PUTCHR(c);
+ break;
+ case 'u':
+ case 'U':
+ qual |= N_UNSIGNED;
+#if COMPATIBLE
+ if (!(st & COMPATIBILITY))
+#endif
+ PUTCHR(c);
+ break;
+ default:
+ PUTCHR(c);
+ break;
+ }
+#endif
+ goto fsm_get;
+ }
+#if !CPP
+ qual |= N_WIDE;
+ if (DOSTRIP()) BACKOUT();
+#endif
+ /*FALLTHROUGH*/
+
+ case S_LITBEG:
+#if CPP
+ quot = c;
+ rp = fsm[LIT1];
+ if (op == tp)
+ {
+ PPSYNCLINE();
+ tp = op;
+ }
+#else
+ if ((quot = c) == '<')
+ {
+ if (!(st & HEADER) || (pp.option & (HEADEREXPAND|HEADEREXPANDALL)) && pp.in->type != IN_FILE && pp.in->type != IN_BUFFER && pp.in->type != IN_INIT && pp.in->type != IN_RESCAN)
+ {
+ PUTCHR(c);
+ bp = ip;
+ rp = fsm[LT1];
+ goto fsm_get;
+ }
+ quot = '>';
+ rp = fsm[HDR1];
+ }
+ else rp = fsm[LIT1];
+ if (!DOSTRIP())
+#endif
+ PUTCHR(c);
+ bp = ip;
+ goto fsm_get;
+
+ case S_LITEND:
+ n = 1;
+ if (c != quot)
+ {
+ if (c != '\n' && c != EOF)
+ {
+ if (st & (QUOTE|SQUOTE))
+ {
+ if (!(st & ESCAPE))
+ {
+ st |= ESCAPE;
+ quotquot = c;
+ }
+ else if (c == quotquot) st &= ~ESCAPE;
+ }
+ PUTCHR(c);
+ bp = ip;
+ goto fsm_get;
+ }
+#if CPP
+ if (st & PASSTHROUGH)
+ {
+ if (c == '\n') goto fsm_newline;
+ bp = ip;
+ goto fsm_start;
+ }
+#endif
+ m = (st & SKIPCONTROL) && (pp.mode & HOSTED) ? -1 : 1;
+ if (c == '\n' && quot == '\'' && (pp.option & STRINGSPAN)) n = 0;
+ else
+#if COMPATIBLE && !CPP
+ if ((st & (COMPATIBILITY|DEFINITION)) != (COMPATIBILITY|DEFINITION))
+#endif
+ {
+ switch (quot)
+ {
+ case '"':
+ if (c == '\n')
+ {
+ if (!(pp.option & STRINGSPAN) || (st & (COMPATIBILITY|STRICT)) == STRICT)
+ error(m, "%s in string", pptokchr(c));
+ error_info.line++;
+ if (!(pp.option & STRINGSPAN))
+ {
+ PUTCHR('\\');
+ c = 'n';
+ }
+ else if (pp.option & STRINGSPLIT)
+ {
+ PUTCHR('\\');
+ PUTCHR('n');
+ PUTCHR('"');
+ PUTCHR('\n');
+ c = '"';
+ }
+ PUTCHR(c);
+ bp = ip;
+ goto fsm_get;
+ }
+ error(m, "%s in string", pptokchr(c));
+ c = '\n';
+ break;
+ case '\'':
+ if (!(st & DIRECTIVE) || !(pp.mode & (HOSTED|RELAX)))
+ error(m, "%s in character constant", pptokchr(c));
+ break;
+ case '>':
+ error(m, "%s in header constant", pptokchr(c));
+ break;
+ default:
+ error(m, "%s in %c quote", pptokchr(c), quot);
+ break;
+ }
+#if !CPP
+ if (!DOSTRIP())
+#endif
+ PUTCHR(quot);
+ }
+ if (c == '\n')
+ {
+ UNGETCHR(c);
+ c = quot;
+ }
+ }
+ else if (st & (SQUOTE|QUOTE))
+ {
+ if (!(st & ESCAPE))
+ {
+ st |= ESCAPE;
+ quotquot = c;
+ }
+ else if (c == quotquot) st &= ~ESCAPE;
+ PUTCHR('\\');
+ PUTCHR(c);
+ bp = ip;
+ goto fsm_get;
+ }
+#if CPP
+ else PUTCHR(c);
+#else
+ else if (!DOSTRIP()) PUTCHR(c);
+#endif
+#if CATSTRINGS
+#if CPP
+ if (c == '"' && !(st & (COLLECTING|NOTEXT|PASSTHROUGH|SKIPCONTROL)) && (pp.mode & CATLITERAL))
+#else
+ if (c == '"' && pp.level == 1 && !(st & (COLLECTING|JOINING|NOTEXT|SKIPCONTROL)) && (pp.mode & CATLITERAL))
+#endif
+ {
+ char* pptoken;
+ long ppstate;
+
+ pptoken = pp.token;
+ pp.token = pp.catbuf;
+ *pp.token++ = 0;
+ ppstate = (st & STRIP);
+ if (DOSTRIP())
+ ppstate |= ADD|QUOTE;
+ st |= JOINING;
+ st &= ~(NEWLINE|STRIP);
+
+ /*
+ * revert to the top level since string
+ * concatenation crosses file boundaries
+ * (allowing intervening directives)
+ */
+
+ pp.level = 0;
+ SYNCIN();
+ m = n = 0;
+ for (;;)
+ {
+ switch (c = pplex())
+ {
+ case '\n':
+ m++;
+ continue;
+ case ' ':
+ *pp.catbuf = ' ';
+ continue;
+ case T_WSTRING:
+#if !CPP
+ qual = N_WIDE;
+#endif
+ if (ppstate & ADD)
+ ppstate &= ~ADD;
+ else if (m == n || !(st & SPACEOUT))
+ op--;
+ else
+ {
+ n = m;
+ *(op - 1) = '\\';
+ *op++ = '\n';
+ }
+ STRCOPY(op, pp.token + 2 + (*pp.token == ' '), s);
+ continue;
+ case T_STRING:
+ if (ppstate & ADD)
+ ppstate &= ~ADD;
+ else if (m == n || !(st & SPACEOUT))
+ op--;
+ else
+ {
+ n = m;
+ *(op - 1) = '\\';
+ *op++ = '\n';
+ }
+ STRCOPY(op, pp.token + 1 + (*pp.token == ' '), s);
+ continue;
+ case 0:
+ m = error_info.line ? (error_info.line - 1) : 0;
+ *pp.token = 0;
+ /*FALLTHROUGH*/
+ default:
+ if (m)
+ {
+ if (--m)
+ {
+ pp.state |= HIDDEN|SYNCLINE;
+ pp.hidden += m;
+ }
+#if COMPATIBLE
+ if ((st & COMPATIBILITY) && c == '#' && *(pp.token - 1))
+ {
+ *(pp.token + 3) = *(pp.token + 2);
+ *(pp.token + 2) = *(pp.token + 1);
+ *(pp.token + 1) = *pp.token;
+ *pp.token = *(pp.token - 1);
+ }
+ error_info.line--;
+ *--pp.token = '\n';
+#endif
+ }
+ else if (*(pp.token - 1))
+ pp.token--;
+ if (ppisidig(*pp.token))
+ *op++ = ' ';
+ if (pp.in->type == IN_MACRO && (s = strchr(pp.token, MARK)) && !*(s + 1))
+ {
+ *(s + 1) = MARK;
+ *(s + 2) = 0;
+ }
+ PUSH_STRING(pp.token);
+ pp.state &= ~(JOINING|NEWLINE);
+ pp.state |= ppstate & ~(ADD|QUOTE);
+ if ((ppstate & (ADD|QUOTE)) == QUOTE)
+ op--;
+ break;
+ }
+ break;
+ }
+ pp.token = pptoken;
+ CACHEIN();
+ pp.level = 1;
+#if !CPP
+ c = T_STRING | qual;
+ break;
+#endif
+ }
+#endif
+#if CPP
+ if (n && !(st & (PASSTHROUGH|SKIPCONTROL|NOTEXT)) && c == '\'' && (op - tp) <= 2 && !(pp.mode & (HOSTED|RELAX)))
+ error(1, "empty character constant");
+ st &= ~(ESCAPE|NEWLINE);
+ pp.in->flags |= IN_tokens;
+ count(token);
+ goto fsm_start;
+#else
+ st &= ~ESCAPE;
+ switch (quot)
+ {
+ case '\'':
+ if (n && !(st & NOTEXT) && (op - tp) <= (DOSTRIP() ? 0 : 2) && !(pp.mode & (HOSTED|RELAX)))
+ error(1, "empty character constant");
+ c = T_CHARCONST | qual;
+ break;
+ case '>':
+ c = T_HEADER;
+ break;
+ default:
+ if (c == quot)
+ c = T_STRING | qual;
+ break;
+ }
+ break;
+#endif
+
+ case S_LITESC:
+ if (st & (COLLECTING|DIRECTIVE|QUOTE|SQUOTE))
+ {
+ if (st & ESCAPE)
+ {
+ PUTCHR('\\');
+ if (c == quot) PUTCHR('\\');
+ }
+ PUTCHR(c);
+ }
+#if CPP
+ else if (st & PASSTHROUGH) PUTCHR(c);
+#endif
+ else if (pp.option & PRESERVE) PUTCHR(c);
+ else switch (c)
+ {
+ case 'b':
+ case 'f':
+ case 'n':
+ case 'r':
+ case 't':
+ case '\\':
+ case '\'':
+ case '"':
+ case '?':
+ PUTCHR(c);
+ break;
+#if COMPATIBLE
+ case '8':
+ case '9':
+ if (!(st & COMPATIBILITY)) goto unknown;
+ if (st & STRICT) error(1, "%c: invalid character in octal character escape", c);
+ /*FALLTHROUGH*/
+#endif
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ n = c - '0';
+ for (m = 0; m < 2; m++)
+ {
+ GET(c, c, tp, xp);
+ switch (c)
+ {
+#if COMPATIBLE
+ case '8':
+ case '9':
+ if (!(st & COMPATIBILITY))
+ {
+ UNGETCHR(c);
+ break;
+ }
+ if (st & STRICT) error(1, "%c: invalid character in octal character escape", c);
+ /*FALLTHROUGH*/
+#endif
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ n = (n << 3) + c - '0';
+ continue;
+ default:
+ UNGETCHR(c);
+ break;
+ }
+ break;
+ }
+ if (n & ~0777) error(1, "octal character constant too large");
+ goto octal;
+ case 'a':
+ if (pp.option & MODERN)
+ {
+ PUTCHR(c);
+ break;
+ }
+#if COMPATIBLE
+ if (st & COMPATIBILITY) goto unknown;
+#endif
+ n = CC_bel;
+ goto octal;
+ case 'v':
+ if (pp.option & MODERN)
+ {
+ PUTCHR(c);
+ break;
+ }
+ n = CC_vt;
+ goto octal;
+ case 'E':
+ if (st & (COMPATIBILITY|STRICT)) goto unknown;
+ n = CC_esc;
+ goto octal;
+ case 'x':
+#if COMPATIBLE
+ if (st & COMPATIBILITY) goto unknown;
+#endif
+ n = 0;
+ for (m = 0; m < 3; m++)
+ {
+ GET(c, c, tp, xp);
+ switch (c)
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ n = (n << 4) + c - '0';
+ continue;
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ n = (n << 4) + c - 'a' + 10;
+ continue;
+ case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ n = (n << 4) + c - 'A' + 10;
+ continue;
+ default:
+ if (!m) error(1, "\\x%c: invalid character in hexadecimal character constant", c);
+ UNGETCHR(c);
+ break;
+ }
+ break;
+ }
+ if (n & ~0777) error(1, "hexadecimal character constant too large");
+ octal:
+ PUTCHR(((n >> 6) & 07) + '0');
+ PUTCHR(((n >> 3) & 07) + '0');
+ PUTCHR((n & 07) + '0');
+ break;
+ default:
+ unknown:
+ if (st & (STRICT|WARN)) error(1, "\\%c: non-standard character constant", c);
+ PUTCHR(c);
+ break;
+ }
+ state = LIT1;
+ goto fsm_begin;
+
+ case S_MACRO:
+ BACKIN();
+#if CPP
+ if (st & (DISABLE|SKIPCONTROL|SKIPMACRO))
+ {
+ if (st & SKIPMACRO)
+ pp.mode |= MARKMACRO;
+ st &= ~(NEWLINE|SKIPMACRO);
+ pp.in->flags |= IN_tokens;
+ count(token);
+ goto fsm_start;
+ }
+ count(candidate);
+ SETCHR(0);
+ switch (state = INDEX(rp))
+ {
+ case HIT0:
+ tp = op - 1;
+ break;
+ case HITN:
+ bp = tp;
+ tp = op - ((pp.truncate && pp.truncate < (HITN - HIT0)) ? (pp.truncate - 1) : (HITN - HIT0));
+ while (tp > bp && ppisidig(*(tp - 1))) tp--;
+ break;
+ default:
+ bp = tp;
+ if ((tp = op - (state - HIT0)) > bp && *(tp - 1) == 'L') tp--;
+ break;
+ }
+ if (sym = ppsymref(pp.symtab, tp))
+ {
+ SYNCIN();
+ n = ppcall(sym, 0);
+ CACHEIN();
+ if (n >= 0)
+ {
+ BACKOUT();
+ if (!n)
+ {
+ if (sp) op = sp;
+ else
+ {
+ s = ip;
+ ip = sym->macro->value;
+ c = sym->macro->size;
+ while (c > 0)
+ {
+ if (op + c < xp + PPBUFSIZ) n = c;
+ else n = xp + PPBUFSIZ - op;
+ MEMCPY(op, ip, n);
+ c -= n;
+ PPCHECKOUT();
+ }
+ ip = s;
+ }
+ }
+ else if ((sym->flags & SYM_MULTILINE) && pp.linesync)
+ {
+ SYNCOUT();
+ if (!(state & NEWLINE))
+ ppputchar('\n');
+ (*pp.linesync)(error_info.line, error_info.file);
+ CACHEOUT();
+ }
+ }
+ }
+ pp.in->flags |= IN_tokens;
+ goto fsm_start;
+#else
+ if (st & (COLLECTING|DEFINITION|DISABLE|SKIPCONTROL|SKIPMACRO))
+ {
+ if (st & SKIPMACRO)
+ pp.mode |= MARKMACRO;
+ st &= ~(NEWLINE|NOEXPAND|SKIPMACRO);
+ c = T_ID;
+ if (pp.level == 1)
+ {
+ pp.in->flags |= IN_tokens;
+ if (st & NOTEXT)
+ {
+ BACKOUT();
+ goto fsm_top;
+ }
+ if (st & COMPILE)
+ {
+ SETCHR(0);
+ if (pp.truncate && (op - tp) > pp.truncate) tp[pp.truncate] = 0;
+ sym = (pp.option & NOHASH) ? ppsymref(pp.symtab, tp) : ppsymset(pp.symtab, tp);
+ fsm_noise:
+ if (pp.symbol = sym)
+ {
+ if ((sym->flags & SYM_KEYWORD) && (!pp.truncate || (op - tp) <= pp.truncate || (tp[pp.truncate] = '_', tp[pp.truncate + 1] = 0, pp.symbol = sym = (pp.option & NOHASH) ? ppsymref(pp.symtab, tp) : ppsymset(pp.symtab, tp), 0)))
+ {
+ c = ((struct ppsymkey*)sym)->lex;
+ /*UNDENT*/
+
+#define ADVANCE() do{if(pp.toknxt<op)pp.token=pp.toknxt;}while(0)
+
+#define NOISE_BRACE 01
+#define NOISE_NOSPACEOUT 02
+#define NOISE_PAREN 04
+
+ if ((pp.option & NOISE) && ppisnoise(c))
+ {
+ if (c != T_NOISE)
+ {
+ int p;
+ int f;
+ char* pptoken;
+ PPCOMMENT ppcomment;
+
+ SYNCIN();
+ pp.toknxt = op;
+ f = 0;
+ if (!(pp.state & SPACEOUT))
+ {
+ pp.state |= SPACEOUT;
+ f |= NOISE_NOSPACEOUT;
+ }
+ ppcomment = pp.comment;
+ pp.comment = 0;
+ op = (pptoken = tp) + MAXTOKEN;
+ switch (c)
+ {
+ case T_X_GROUP:
+ m = p = 0;
+ quot = 1;
+ for (;;)
+ {
+ ADVANCE();
+ switch (c = pplex())
+ {
+ case '(':
+ case '{':
+ if (!p)
+ {
+ if (c == '(')
+ {
+ if (f & NOISE_PAREN)
+ {
+ ungetchr(c);
+ *--pp.toknxt = 0;
+ break;
+ }
+ f |= NOISE_PAREN;
+ p = ')';
+ }
+ else
+ {
+ f |= NOISE_BRACE|NOISE_PAREN;
+ p = '}';
+ }
+ n = 1;
+ m = c;
+ }
+ else if (c == m) n++;
+ quot = 0;
+ continue;
+ case ')':
+ case '}':
+ if (c == p && --n <= 0)
+ {
+ if (c == '}') break;
+ m = '\n';
+ p = 0;
+ }
+ quot = 0;
+ continue;
+ case ' ':
+ continue;
+ case '\n':
+ error_info.line++;
+ if (!m) m = '\n';
+ continue;
+ case 0:
+ break;
+ case T_ID:
+ if (quot) continue;
+ /*FALLTHROUGH*/
+ default:
+ if (m == '\n')
+ {
+ /*
+ * NOTE: token expanded again
+ */
+
+ s = pp.toknxt;
+ while (s > pp.token) ungetchr(*--s);
+ *(pp.toknxt = s) = 0;
+ break;
+ }
+ continue;
+ }
+ break;
+ }
+ break;
+ case T_X_LINE:
+ for (;;)
+ {
+ ADVANCE();
+ switch (pplex())
+ {
+ case 0:
+ break;
+ case '\n':
+ error_info.line++;
+ break;
+ default:
+ continue;
+ }
+ break;
+ }
+ break;
+ case T_X_STATEMENT:
+ for (;;)
+ {
+ ADVANCE();
+ switch (pplex())
+ {
+ case 0:
+ break;
+ case ';':
+ ungetchr(';');
+ *(pp.toknxt = pp.token) = 0;
+ break;
+ default:
+ continue;
+ }
+ break;
+ }
+ break;
+ }
+ pp.comment = ppcomment;
+ if (f & NOISE_NOSPACEOUT)
+ pp.state &= ~SPACEOUT;
+ CACHEIN();
+ tp = pptoken;
+ op = pp.toknxt;
+ c = T_NOISES;
+ }
+ if (pp.option & NOISEFILTER)
+ {
+ BACKOUT();
+ goto fsm_top;
+ }
+ }
+
+ /*INDENT*/
+ }
+ else if ((pp.option & NOISE) && c == T_ID && strneq(tp, "__builtin_", 10))
+ {
+ hashlook(pp.symtab, tp, HASH_DELETE, NiL);
+ pp.symbol = sym = (struct ppsymbol*)ppkeyset(pp.symtab, tp);
+ sym->flags |= SYM_KEYWORD;
+ c = ((struct ppsymkey*)sym)->lex = T_BUILTIN;
+ }
+ }
+ }
+ goto fsm_symbol;
+ }
+ goto fsm_check;
+ }
+ if (pp.level == 1)
+ {
+ st &= ~(NEWLINE|PASSEOF);
+ pp.in->flags |= IN_tokens;
+ }
+ else st &= ~PASSEOF;
+ count(candidate);
+ SETCHR(0);
+ if (sym = ppsymref(pp.symtab, tp))
+ {
+ SYNCIN();
+ c = ppcall(sym, 1);
+ CACHEIN();
+ if (c >= 0)
+ {
+ BACKOUT();
+ if ((sym->flags & SYM_MULTILINE) && pp.linesync)
+ {
+ SYNCOUT();
+ (*pp.linesync)(error_info.line, error_info.file);
+ CACHEOUT();
+ }
+ goto fsm_top;
+ }
+ }
+ c = T_ID;
+ if (pp.level == 1)
+ {
+ if (st & NOTEXT)
+ {
+ BACKOUT();
+ goto fsm_top;
+ }
+ if (st & COMPILE)
+ {
+ if (pp.truncate && (op - tp) > pp.truncate)
+ {
+ tp[pp.truncate] = 0;
+ sym = 0;
+ }
+ if (!sym)
+ {
+ if (!(pp.option & NOHASH)) sym = ppsymset(pp.symtab, tp);
+ else if (!(sym = ppsymref(pp.symtab, tp))) goto fsm_symbol;
+ }
+ goto fsm_noise;
+ }
+ goto fsm_symbol;
+ }
+ goto fsm_check;
+#endif
+
+ case S_SHARP:
+ if (c == '(')
+ {
+ pp.in->flags |= IN_tokens;
+ if ((st & STRICT) && pp.in->type != IN_MACRO && pp.in->type != IN_MULTILINE)
+ {
+ if (!(pp.mode & HOSTED)) error(1, "non-standard reference to #(...)");
+ if (st & STRICT)
+ {
+ PUTCHR(c);
+#if CPP
+ st &= ~NEWLINE;
+ count(token);
+ goto fsm_start;
+#else
+ break;
+#endif
+ }
+ }
+ if (st & (COLLECTING|DEFINITION|DISABLE|SKIPCONTROL))
+ {
+ PUTCHR(c);
+#if CPP
+ st &= ~NEWLINE;
+ count(token);
+ goto fsm_start;
+#else
+ st &= ~NOEXPAND;
+ break;
+#endif
+ }
+ op--;
+ SYNC();
+ ppbuiltin();
+ CACHE();
+#if CPP
+ count(token);
+ goto fsm_start;
+#else
+ goto fsm_top;
+#endif
+ }
+ BACKIN();
+#if CPP
+ if (!(st & NEWLINE) || !(pp.in->type & IN_TOP))
+ {
+ fsm_nondirective:
+ st &= ~NEWLINE;
+ pp.in->flags |= IN_tokens;
+ count(token);
+ goto fsm_start;
+ }
+ if (*(s = tp) != '#')
+ {
+#if COMPATIBLE
+ if ((st & (COMPATIBILITY|TRANSITION)) == COMPATIBILITY) goto fsm_nondirective;
+#endif
+ while (*s == ' ' || *s == '\t') s++;
+ if (*s != '#') goto fsm_nondirective;
+ }
+ BACKOUT();
+#else
+ if (!(st & NEWLINE) || (st & DEFINITION) || !(pp.in->type & IN_TOP))
+ {
+ if (c == '#')
+ {
+ SKIPIN();
+ if (!(st & DEFINITION))
+ PUTCHR(c);
+ c = T_TOKCAT;
+ }
+ else if (pp.level == 1 && !(st & (JOINING|SPACEOUT)) && !(pp.option & PRESERVE))
+ {
+ char* pptoken;
+ char* oop;
+ PPCOMMENT ppcomment;
+
+ SYNCIN();
+ pp.toknxt = oop = op;
+ pp.state |= SPACEOUT;
+ ppcomment = pp.comment;
+ pp.comment = 0;
+ op = (pptoken = tp) + MAXTOKEN;
+ for (;;)
+ {
+ ADVANCE();
+ switch (pplex())
+ {
+ case 0:
+ break;
+ case '\n':
+ error_info.line++;
+ break;
+ default:
+ continue;
+ }
+ break;
+ }
+ pp.comment = ppcomment;
+ pp.state &= ~SPACEOUT;
+ CACHEIN();
+ tp = pptoken;
+ *--op = 0;
+ op = oop;
+ if (pp.pragma && !(st & NOTEXT))
+ {
+ *s = 0;
+ SYNC();
+ (*pp.pragma)(NiL, NiL, NiL, tp, 1);
+ CACHE();
+ }
+ if (!c) BACKIN();
+ goto fsm_top;
+ }
+ else c = '#';
+ break;
+ }
+ if ((st & (COLLECTING|STRICT)) == (COLLECTING|STRICT))
+ error(1, "directives in macro call arguments are not portable");
+#endif
+ if (c == '#' && pp.in->type == IN_RESCAN)
+ {
+ /*
+ * pass line to pp.pragma VERBATIM
+ */
+
+ SKIPIN();
+ s = pp.valbuf;
+ while ((c = GETCHR()) && c != '\n')
+ if ((*s++ = c) == MARK) SKIPIN();
+ if (pp.pragma && !(st & NOTEXT))
+ {
+ *s = 0;
+ SYNC();
+ (*pp.pragma)(NiL, NiL, NiL, pp.valbuf, 1);
+ CACHE();
+ }
+ if (!c) BACKIN();
+#if CPP
+ goto fsm_start;
+#else
+ goto fsm_top;
+#endif
+ }
+ SYNC();
+ ppcontrol();
+ CACHE();
+#if CPP
+ if (st & (NOTEXT|SKIPCONTROL))
+ {
+ if (!sp)
+ {
+ PPCHECKOUTTP();
+ sp = tp;
+ }
+ }
+ else if (sp)
+ {
+ tp = op = sp;
+ sp = 0;
+ }
+ goto fsm_start;
+#else
+ goto fsm_top;
+#endif
+
+ case S_NL:
+#if CPP
+ if (op == tp && !(st & JOINING) && pp.in->type == IN_FILE)
+ {
+ st |= NEWLINE|HIDDEN;
+ pp.hidden++;
+ error_info.line++;
+ goto fsm_start;
+ }
+#endif
+ fsm_newline:
+#if CPP
+ if (sp)
+ op = sp;
+ else if (!(pp.in->flags & IN_noguard))
+ {
+ while (tp < op)
+ if ((c = *tp++) != ' ' && c != '\t')
+ {
+ pp.in->flags |= IN_tokens;
+ break;
+ }
+ c = '\n';
+ }
+ st |= NEWLINE;
+ error_info.line++;
+ if (*ip == '\n' && *(ip + 1) != '\n' && !pp.macref && !(st & (ADD|HIDDEN)))
+ {
+ ip++;
+ PUTCHR('\n');
+ error_info.line++;
+ }
+ if ((st & NOTEXT) && ((pp.mode & FILEDEPS) || (pp.option & (DEFINITIONS|PREDEFINITIONS))))
+ BACKOUT();
+ else
+ {
+ debug((-5, "token[%d] %03o = %s [line=%d]", pp.level, c, pptokchr(c), error_info.line));
+ PUTCHR('\n');
+ PPSYNCLINE();
+ if (sp)
+ {
+ PPCHECKOUT();
+ sp = op;
+ }
+ }
+ goto fsm_start;
+#else
+ st |= NEWLINE;
+ if (pp.level == 1)
+ {
+ error_info.line++;
+ if (!(st & (JOINING|SPACEOUT)))
+ {
+ debug((-5, "token[%d] %03o = %s [line=%d]", pp.level, c, pptokchr(c), error_info.line));
+ BACKOUT();
+ goto fsm_top;
+ }
+ }
+ BACKOUT();
+ if (st & SKIPCONTROL)
+ {
+ error_info.line++;
+ st |= HIDDEN;
+ pp.hidden++;
+ goto fsm_start;
+ }
+ PUTCHR(c = '\n');
+ goto fsm_return;
+#endif
+
+#if !CPP
+ case S_TOK:
+ PUTCHR(c);
+ c = TYPE(state) | qual;
+ break;
+
+ case S_TOKB:
+ BACKIN();
+ c = TYPE(state) | qual;
+ break;
+#endif
+
+ case S_VS:
+ PUTCHR(c);
+#if !CPP
+ if (st & NOVERTICAL)
+ {
+ error(1, "%s invalid in directives", pptokchr(c));
+ st &= ~NOVERTICAL;
+ }
+#endif
+#if COMPATIBLE
+ if (st & COMPATIBILITY) st |= NEWLINE;
+#endif
+#if CPP
+ if (!(pp.in->flags & IN_noguard))
+ while (tp < op)
+ if ((c = *tp++) != ' ' && c != '\t')
+ {
+ pp.in->flags |= IN_tokens;
+ break;
+ }
+ goto fsm_start;
+#else
+ bp = ip;
+ rp = fsm[WS1];
+ goto fsm_get;
+#endif
+
+#if !CPP
+ case S_WS:
+#if COMPATIBLE
+ if ((st & (COMPATIBILITY|TRANSITION)) == COMPATIBILITY) st &= ~NEWLINE;
+#endif
+ if (pp.level == 1)
+ {
+ if ((st & (COMPATIBILITY|SPACEOUT)) && !(st & TRANSITION))
+ {
+ if (st & (COMPILE|NOTEXT))
+ {
+#if CATSTRINGS
+ if ((st & (JOINING|NOTEXT|SPACEOUT)) != SPACEOUT)
+#else
+ if ((st & (NOTEXT|SPACEOUT)) != SPACEOUT)
+#endif
+ {
+ BACKOUT();
+ bp = ip - 1;
+ rp = fsm[START];
+ if (state = rp[c]) goto fsm_next;
+ goto fsm_get;
+ }
+ }
+ else
+#if CATSTRINGS
+ if (!(st & JOINING))
+#endif
+ {
+ tp = op;
+ bp = ip - 1;
+ rp = fsm[START];
+ if (state = rp[c]) goto fsm_next;
+ goto fsm_get;
+ }
+ BACKIN();
+ c = ' ';
+ goto fsm_return;
+ }
+ BACKOUT();
+ bp = ip - 1;
+ rp = fsm[START];
+ if (state = rp[c]) goto fsm_next;
+ goto fsm_get;
+ }
+ if (st & (NOSPACE|SKIPCONTROL))
+ {
+ BACKOUT();
+ bp = ip - 1;
+ rp = fsm[START];
+ if (state = rp[c]) goto fsm_next;
+ goto fsm_get;
+ }
+ if (c != '\n')
+ {
+ BACKIN();
+ c = ' ';
+ }
+ if (!(pp.option & PRESERVE))
+ {
+ BACKOUT();
+ PUTCHR(c);
+ }
+ goto fsm_return;
+#endif
+
+ default:
+ if (state & SPLICE)
+ {
+ switch (c)
+ {
+ case MARK:
+ /*
+ * internal mark
+ */
+
+ switch (pp.in->type)
+ {
+ case IN_BUFFER:
+ case IN_FILE:
+#if !CPP
+ case IN_INIT:
+#if CATSTRINGS
+ if ((st & JOINING) && (!INQUOTE(rp) || quot != '"') || pp.level > 1 && (rp == fsm[START] || INQUOTE(rp)))
+#else
+ if (pp.level > 1 && (rp == fsm[START] || INQUOTE(rp)))
+#endif
+ PUTCHR(c);
+#endif
+ break;
+ default:
+ switch (GETCHR())
+ {
+ case 'A':
+ if (!(st & (DEFINITION|DISABLE)))
+ {
+ c = GETCHR();
+ SYNCIN();
+ if (pp.macp->arg[c - ARGOFFSET][-1])
+ PUSH_EXPAND(pp.macp->arg[c - ARGOFFSET], pp.macp->line);
+ else
+ PUSH_COPY(pp.macp->arg[c - ARGOFFSET], pp.macp->line);
+ CACHEIN();
+ bp = ip;
+ goto fsm_get;
+ }
+ /*FALLTHROUGH*/
+ case 'C':
+ c = GETCHR() - ARGOFFSET;
+ if (!*(s = pp.macp->arg[c]) && (pp.in->symbol->flags & SYM_VARIADIC) && pp.in->symbol->macro->arity == (c + 1))
+ {
+ s = ip - 3;
+ while (--op > tp && --s > bp && ppisidig(*s));
+ }
+ else
+ {
+ SYNCIN();
+ PUSH_COPY(s, pp.macp->line);
+ CACHEIN();
+ }
+ bp = ip;
+ goto fsm_get;
+ case 'F':
+ error_info.file = (char*)strtoul(ip, &s, 16);
+ debug((-6, "actual sync: file = \"%s\"", error_info.file));
+ bp = ip = s + 1;
+ goto fsm_get;
+ case 'L':
+ error_info.line = strtoul(ip, &s, 16);
+ debug((-6, "actual sync: line = %d", error_info.line));
+ bp = ip = s + 1;
+ goto fsm_get;
+ case 'Q':
+ c = GETCHR();
+ SYNCIN();
+ PUSH_QUOTE(pp.macp->arg[c - ARGOFFSET], pp.macp->line);
+ CACHEIN();
+ bp = ip - 1;
+ if (st & (COLLECTING|EOF2NL|JOINING)) rp = fsm[START];
+ if (state = rp[c = '"']) goto fsm_next;
+ goto fsm_get;
+ case 'S':
+ c = GETCHR();
+ SYNCIN();
+ PUSH_SQUOTE(pp.macp->arg[c - ARGOFFSET], pp.macp->line);
+ CACHEIN();
+ bp = ip - 1;
+ if (st & COLLECTING) rp = fsm[START];
+ if (state = rp[c = '\'']) goto fsm_next;
+ goto fsm_get;
+ case 'X':
+ if (pp.in->type != IN_COPY)
+ st |= SKIPMACRO;
+ if (pp.level <= 1)
+ {
+ bp = ip;
+ goto fsm_get;
+ }
+ if (pp.in->type == IN_EXPAND)
+ {
+ st &= ~SKIPMACRO;
+ PUTCHR(c);
+ PUTCHR('X');
+ }
+ c = GETCHR();
+ break;
+ case 0:
+ if ((state &= ~SPLICE) >= TERMINAL) goto fsm_terminal;
+ goto fsm_begin;
+ default:
+#if DEBUG
+ error(PANIC, "invalid mark op `%c'", LASTCHR());
+ /*FALLTHROUGH*/
+ case MARK:
+#endif
+#if CATSTRINGS
+ if ((st & (JOINING|QUOTE)) == JOINING)
+ {
+ if (!INQUOTE(rp))
+ PUTCHR(c);
+ }
+ else
+#endif
+#if CPP
+ if (rp != fsm[START] && !INQUOTE(rp))
+ UNGETCHR(c);
+#else
+ if (rp != fsm[START] && !INQUOTE(rp))
+ UNGETCHR(c);
+ else if (pp.level > 1)
+ PUTCHR(c);
+#endif
+ break;
+ }
+ break;
+ }
+ break;
+ case '?':
+ /*
+ * trigraph
+ */
+
+ if (pp.in->type == IN_FILE)
+ {
+ GET(c, n, tp, xp);
+ if (n == '?')
+ {
+ GET(c, n, tp, xp);
+ if (c = trigraph[n])
+ {
+ if ((st & WARN) && (st & (COMPATIBILITY|TRANSITION)) && !(pp.mode & HOSTED) && !INCOMMENT(rp))
+ error(1, "trigraph conversion %c%c%c -> %c%s", '?', '?', n, c, (st & TRANSITION) ? "" : " inhibited");
+#if COMPATIBLE
+ if ((st & (COMPATIBILITY|TRANSITION)) != COMPATIBILITY)
+ {
+#endif
+ *(bp = ip - 1) = c;
+ if (state = rp[c]) goto fsm_next;
+ goto fsm_get;
+#if COMPATIBLE
+ }
+#endif
+ }
+ if (n != EOB) BACKIN();
+ UNGETCHR(c = '?');
+ }
+ else if (n != EOB) BACKIN();
+ }
+ break;
+ case '%':
+ case '<':
+ case ':':
+ /*
+ * digraph = --trigraph
+ */
+
+ if (pp.in->type == IN_FILE && (pp.option & PLUSPLUS))
+ {
+ m = 0;
+ GET(c, n, tp, xp);
+ switch (n)
+ {
+ case '%':
+ if (c == '<') m = '{';
+ break;
+ case '>':
+ if (c == '%') m = '}';
+ else if (c == ':') m = ']';
+ break;
+ case ':':
+ if (c == '%') m = '#';
+ else if (c == '<') m = '[';
+ break;
+ }
+ if (m)
+ {
+ if ((st & WARN) && (st & (COMPATIBILITY|TRANSITION)) && !(pp.mode & HOSTED) && !INCOMMENT(rp))
+ error(1, "digraph conversion %c%c -> %c%s", c, n, m, (st & TRANSITION) ? "" : " inhibited");
+#if COMPATIBLE
+ if ((st & (COMPATIBILITY|TRANSITION)) != COMPATIBILITY)
+ {
+#endif
+ *(bp = ip - 1) = c = m;
+ if (state = rp[c]) goto fsm_next;
+ goto fsm_get;
+#if COMPATIBLE
+ }
+#endif
+ }
+ if (n != EOB) BACKIN();
+ }
+ break;
+ case '\\':
+ /*
+ * line splice
+ */
+
+ if (pp.in->type == IN_FILE && (!(pp.option & PLUSSPLICE) || !INCOMMENTXX(rp)))
+ {
+ m = 0;
+ GET(c, n, tp, xp);
+ if ((pp.option & SPLICESPACE) && !INQUOTE(rp))
+ while (n == ' ')
+ {
+ GET(c, n, tp, xp);
+ m = 1;
+ }
+ if (n == '\r')
+ {
+ GET(c, n, tp, xp);
+ if (n != '\n' && n != EOB)
+ BACKIN();
+ }
+ if (n == '\n')
+ {
+#if CPP
+ if (INQUOTE(rp))
+ {
+ if ((pp.option & STRINGSPLIT) && quot == '"')
+ {
+ PUTCHR(quot);
+ PUTCHR(n);
+ PUTCHR(quot);
+ }
+ else if (*pp.lineid)
+ {
+ PUTCHR(c);
+ PUTCHR(n);
+ }
+ else
+ {
+ st |= HIDDEN;
+ pp.hidden++;
+ }
+ }
+ else
+#else
+#if COMPATIBLE
+ if (!INQUOTE(rp) && (st & (COMPATIBILITY|DEFINITION|TRANSITION)) == (COMPATIBILITY|DEFINITION))
+ {
+ if (op == tp)
+ {
+ st |= HIDDEN;
+ pp.hidden++;
+ error_info.line++;
+ if (st & SPACEOUT)
+ goto fsm_start;
+ c = (pp.option & SPLICECAT) ? '\t' : ' ';
+ PUTCHR(c);
+ goto fsm_check;
+ }
+ UNGETCHR(n);
+ state &= ~SPLICE;
+ goto fsm_terminal;
+ }
+#endif
+#endif
+ {
+ st |= HIDDEN;
+ pp.hidden++;
+ }
+#if CPP
+ spliced++;
+#else
+ error_info.line++;
+#endif
+ bp = ip;
+ goto fsm_get;
+ }
+ else if ((n == 'u' || n == 'U') && !INQUOTE(rp))
+ {
+ PUTCHR(c);
+ PUTCHR(n);
+ bp = ip;
+ goto fsm_get;
+ }
+#if COMPATIBLE
+ else if ((st & (COMPATIBILITY|TRANSITION)) == COMPATIBILITY && (n == '"' || n == '\'') && !INQUOTE(rp))
+ {
+ PUTCHR(c);
+ PUTCHR(n);
+ bp = ip;
+ goto fsm_get;
+ }
+#endif
+ else if (n != EOB)
+ BACKIN();
+ if (m && INSPACE(rp))
+ UNGETCHR(c);
+ }
+#if COMPATIBLE
+ else if ((st & (COMPATIBILITY|TRANSITION)) == COMPATIBILITY && !INQUOTE(rp))
+ {
+ GET(c, n, tp, xp);
+ if (n == '"' || n == '\'')
+ {
+ PUTCHR(c);
+ PUTCHR(n);
+ bp = ip;
+ goto fsm_get;
+ }
+ if (n != EOB)
+ BACKIN();
+ }
+#endif
+ break;
+ case '\r':
+ /*
+ * barf
+ */
+
+ if (pp.in->type == IN_FILE)
+ {
+ GET(c, n, tp, xp);
+ if (n == '\n')
+ {
+ *(bp = ip - 1) = c = n;
+ if (state = rp[c]) goto fsm_next;
+ goto fsm_get;
+ }
+ if (n != EOB) BACKIN();
+ }
+ break;
+ case CC_sub:
+ /*
+ * barf & puke
+ */
+
+ if ((pp.option & ZEOF) && pp.in->type == IN_FILE)
+ {
+ pp.in->flags |= IN_eof;
+ c = 0;
+ state = S_EOB;
+ goto fsm_terminal;
+ }
+ break;
+ }
+ if ((state &= ~SPLICE) >= TERMINAL)
+ goto fsm_terminal;
+ PUTCHR(c);
+ goto fsm_begin;
+ }
+#if CPP
+ if (INOPSPACE(rp))
+ {
+ BACKIN();
+ goto fsm_start;
+ }
+#endif
+ PUTCHR(c);
+ bp = ip;
+ goto fsm_get;
+ }
+#if !CPP
+ fsm_token:
+ st &= ~NEWLINE;
+ if (pp.level == 1)
+ {
+ pp.in->flags |= IN_tokens;
+ if (st & NOTEXT)
+ {
+ BACKOUT();
+ goto fsm_top;
+ }
+ fsm_symbol:
+ count(token);
+ }
+ fsm_check:
+ if (st & SKIPCONTROL)
+ {
+ BACKOUT();
+ goto fsm_start;
+ }
+ fsm_return:
+#if CPP
+ error_info.line += spliced;
+#endif
+ SETCHR(0);
+ debug((-5, "token[%d] %03o = %s", pp.level, c, pptokstr(tp, 0)));
+ SYNC();
+ pp.level--;
+ error_info.indent--;
+ return c;
+#endif
+}
+
+#if CPP && POOL
+
+#include <ls.h>
+#include <wait.h>
+
+/*
+ * output pool status on exit
+ */
+
+static void
+poolstatus(void)
+{
+ error(ERROR_OUTPUT|0, pp.pool.output, "%d", error_info.errors != 0);
+}
+
+/*
+ * loop on < input output >
+ */
+
+static void
+pool(void)
+{
+ char* ifile;
+ char* ofile;
+
+ ppflushout();
+ if (!sfnew(sfstdin, NiL, SF_UNBOUND, pp.pool.input, SF_READ))
+ error(ERROR_SYSTEM|3, "cannot dup pool input");
+
+ /*
+ * kick the -I cache
+ */
+
+ ppsearch(".", T_STRING, SEARCH_EXISTS);
+
+ /*
+ * loop on < input output >
+ */
+
+ pp.pool.input = 0;
+ while (ifile = sfgetr(sfstdin, '\n', 1))
+ {
+ if (!(ofile = strchr(ifile, ' ')))
+ error(3, "%s: pool output file expected", ifile);
+ *ofile++ = 0;
+ waitpid(0, NiL, WNOHANG);
+ switch (fork())
+ {
+ case -1:
+ error(ERROR_SYSTEM|3, "cannot fork pool");
+ case 0:
+ atexit(poolstatus);
+ error_info.errors = 0;
+ error_info.warnings = 0;
+ close(0);
+ if (open(ifile, O_RDONLY))
+ error(ERROR_SYSTEM|3, "%s: cannot read", ifile);
+ close(1);
+ if (open(ofile, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) != 1)
+ error(ERROR_SYSTEM|3, "%s: cannot create", ofile);
+ pp.outfile = ofile;
+ pathcanon(ifile, 0);
+ ifile = ppsetfile(ifile)->name;
+#if CHECKPOINT
+ if (pp.mode & DUMP)
+ {
+ if (!pp.pragma)
+ error(3, "#%s must be enabled for checkpoints", dirname(PRAGMA));
+ (*pp.pragma)(dirname(PRAGMA), pp.pass, keyname(X_CHECKPOINT), pp.checkpoint, 1);
+ }
+#endif
+ PUSH_FILE(ifile, 0);
+ return;
+ }
+ }
+ while (wait(NiL) != -1);
+}
+
+#endif
diff --git a/usr/src/lib/libpp/common/pplib.h b/usr/src/lib/libpp/common/pplib.h
new file mode 100644
index 0000000000..3428b4d55f
--- /dev/null
+++ b/usr/src/lib/libpp/common/pplib.h
@@ -0,0 +1,863 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * preprocessor library private definitions
+ */
+
+#ifndef _PPLIB_H
+#define _PPLIB_H
+
+/*
+ * the first definitions control optional code -- 0 disables
+ */
+
+#ifndef ARCHIVE
+#define ARCHIVE 1 /* -I can specify header archives */
+#endif
+#ifndef CATSTRINGS
+#define CATSTRINGS 1 /* concatenate adjacent strings */
+#endif
+#ifndef CHECKPOINT
+#define CHECKPOINT 1 /* checkpoint preprocessed files */
+#endif
+#ifndef COMPATIBLE
+#define COMPATIBLE 1 /* enable COMPATIBILITY related code */
+#endif
+#ifndef MACKEYARGS
+#define MACKEYARGS _BLD_DEBUG /* name=value macro formals and actuals */
+#endif
+#ifndef POOL
+#define POOL 1 /* enable loop on input,output,error */
+#endif
+#ifndef PROTOTYPE
+#define PROTOTYPE 1 /* enable ppproto code */
+#endif
+
+#define TRUNCLENGTH 8 /* default TRUNCATE length */
+
+#if _BLD_DEBUG
+#undef DEBUG
+#define DEBUG (TRACE_message|TRACE_count|TRACE_debug)
+#else
+#ifndef DEBUG
+#define DEBUG (TRACE_message)
+#endif
+#endif
+
+/*
+ * the lower tests are transient
+ */
+
+#define TEST_count (1L<<24)
+#define TEST_hashcount (1L<<25)
+#define TEST_hashdump (1L<<26)
+#define TEST_hit (1L<<27)
+#define TEST_noinit (1L<<28)
+#define TEST_nonoise (1L<<29)
+#define TEST_noproto (1L<<30)
+
+#define TEST_INVERT (1L<<31)
+
+#define PROTO_CLASSIC (1<<0) /* classic to prototyped */
+#define PROTO_DISABLE (1<<1) /* disable conversion */
+#define PROTO_EXTERNALIZE (1<<2) /* static fun() => extern fun() */
+#define PROTO_FORCE (1<<3) /* force even if no magic */
+#define PROTO_HEADER (1<<4) /* header defines too */
+#define PROTO_INCLUDE (1<<5) /* <prototyped.h> instead */
+#define PROTO_INITIALIZED (1<<6) /* internal initialization */
+#define PROTO_LINESYNC (1<<7) /* force standalone line syncs */
+#define PROTO_NOPRAGMA (1<<8) /* delete pragma prototyped */
+#define PROTO_PASS (1<<9) /* pass blocks if no magic */
+#define PROTO_PLUSPLUS (1<<10) /* extern () -> extern (...) */
+#define PROTO_RETAIN (1<<11) /* defines retained after close */
+#define PROTO_TEST (1<<12) /* enable test code */
+
+#define PROTO_USER (1<<13) /* first user flag */
+
+#define SEARCH_EXISTS 0 /* ppsearch for existence */
+#define SEARCH_HOSTED (1<<0) /* search hosted dirs only */
+#define SEARCH_IGNORE (1<<1) /* ignore if not found */
+#define SEARCH_INCLUDE (1<<2) /* ppsearch for include */
+#define SEARCH_VENDOR (1<<3) /* search vendor dirs only */
+#define SEARCH_USER (1<<4) /* first user flag */
+
+#define STYLE_gnu (1<<0) /* gnu style args */
+
+#define IN_c (1<<0) /* C language file */
+#define IN_defguard (1<<1) /* did multiple include check */
+#define IN_disable (1<<2) /* saved state&DISABLE */
+#define IN_endguard (1<<3) /* did multiple include check */
+#define IN_eof (1<<4) /* reached EOF */
+#define IN_expand (1<<5) /* ppexpand buffer */
+#define IN_flush (1<<6) /* flush stdout on file_refill()*/
+#define IN_hosted (1<<7) /* saved mode&HOSTED */
+#define IN_ignoreline (1<<8) /* ignore #line until file */
+#define IN_newline (1<<9) /* newline at end of last fill */
+#define IN_noguard (1<<10) /* no multiple include guard */
+#define IN_prototype (1<<11) /* ppproto() input */
+#define IN_regular (1<<12) /* regular input file */
+#define IN_static (1<<13) /* static buffer - don't free */
+#define IN_sync (1<<14) /* line sync required on pop */
+#define IN_tokens (1L<<15)/* non-space tokens encountered */
+
+#define OPT_GLOBAL (1<<0) /* pp: pass optional */
+#define OPT_PASS (1<<1) /* pass on */
+
+struct ppsymbol;
+struct ppindex;
+
+typedef char* (*PPBUILTIN)(char*, const char*, const char*);
+typedef void (*PPCOMMENT)(const char*, const char*, const char*, int);
+typedef void (*PPINCREF)(const char*, const char*, int, int);
+typedef void (*PPLINESYNC)(int, const char*);
+typedef void (*PPMACREF)(struct ppsymbol*, const char*, int, int, unsigned long);
+typedef int (*PPOPTARG)(int, int, const char*);
+typedef void (*PPPRAGMA)(const char*, const char*, const char*, const char*, int);
+
+struct ppinstk /* input stream stack frame */
+{
+ char* nextchr; /* next input char (first elt) */
+ struct ppinstk* next; /* next frame (for allocation) */
+ struct ppinstk* prev; /* previous frame */
+ long* control; /* control block level */
+ char* buffer; /* buffer base pointer */
+ char* file; /* saved file name */
+ char* prefix; /* directory prefix */
+ struct ppsymbol* symbol; /* macro info */
+#if CHECKPOINT
+ struct ppindex* index; /* checkpoint include index */
+ int buflen; /* buffer count */
+#endif
+ int line; /* saved line number */
+ int vendor; /* saved pp.vendor */
+ short fd; /* file descriptor */
+ short hide; /* hide index (from pp.hide) */
+ short flags; /* IN_[a-z]* flags */
+ char type; /* input type */
+};
+
+#if MACKEYARGS
+struct ppkeyarg /* pp macro keyword arg info */
+{
+ char* name; /* keyword arg name */
+ char* value; /* keyword arg value */
+};
+#endif
+
+struct pplist /* string list */
+{
+ char* value; /* string value */
+ struct pplist* next; /* next in list */
+};
+
+struct oplist /* queue op until PP_INIT */
+{
+ int op; /* PP_* op */
+ char* value; /* op value */
+ struct oplist* next; /* next op */
+};
+
+struct pphide /* hidden symbol info */
+{
+ struct ppmacro* macro; /* saved macro info */
+ unsigned long flags; /* saved symbol flags if macro */
+ int level; /* nesting level */
+};
+
+struct ppmacstk /* macro invocation stack frame */
+{
+ struct ppmacstk* next; /* next frame (for allocation) */
+ struct ppmacstk* prev; /* previous frame */
+ int line; /* line number of first arg */
+ char* arg[1]; /* arg text pointers */
+};
+
+struct ppmember /* archive member pun on ppfile */
+{
+ struct ppdirs* archive; /* archive holding file */
+ unsigned long offset; /* data offset */
+ unsigned long size; /* data size */
+};
+
+struct counter /* monitoring counters */
+{
+ int candidate; /* macro candidates */
+ int function; /* function macros */
+ int macro; /* macro hits */
+ int pplex; /* pplex() calls */
+ int push; /* input stream pushes */
+ int terminal; /* terminal states */
+ int token; /* emitted tokens */
+};
+
+struct pptuple /* tuple macro */
+{
+ struct pptuple* nomatch; /* nomatch tuple */
+ struct pptuple* match; /* match tuple */
+ char token[1]; /* matching token */
+};
+
+struct ppfileid /* physical file id */
+{
+ unsigned long st_dev; /* dev */
+ unsigned long st_ino; /* ino */
+};
+
+struct pathid /* physical file name and id */
+{
+ char* path; /* file path */
+ struct ppfileid id; /* file id */
+};
+
+#define SAMEID(a,b) ((a)->st_ino==(unsigned long)(b)->st_ino&&(a)->st_dev==(unsigned long)(b)->st_dev)
+#define SAVEID(a,b) ((a)->st_ino=(unsigned long)(b)->st_ino,(a)->st_dev=(unsigned long)(b)->st_dev)
+
+#define _PP_CONTEXT_PRIVATE_ /* ppglobals private context */ \
+ struct ppcontext* context; /* current context */ \
+ long state; /* pp state flags */ \
+ long mode; /* uncoupled pp state flags */ \
+ long option; /* option flags */ \
+ long test; /* implementation tests */ \
+ struct \
+ { \
+ Sfio_t* sp; /* FILEDEPS output stream */ \
+ long flags; /* PP_FILEDEPS flags */ \
+ } filedeps; /* FILEDEPS info */ \
+ struct ppdirs* firstdir; /* first include dir */ \
+ struct ppdirs* lastdir; /* last include dir */ \
+ int hide; /* current include hide index */ \
+ int column; /* FILEDEPS column */ \
+ int pending; /* ppline() pending output */ \
+ char* firstfile; /* ppline() first file */ \
+ char* lastfile; /* ppline() most recent file */ \
+ char* ignore; /* include ignore list file */ \
+ char* probe; /* ppdefault probe key */ \
+ Hash_table_t* filtab; /* file name hash table */ \
+ Hash_table_t* prdtab; /* predicate hash table */ \
+ char* date; /* start date string */ \
+ char* time; /* start time string */ \
+ char* maps; /* directive maps */ \
+ long ro_state; /* readonly state */ \
+ long ro_mode; /* readonly mode */ \
+ long ro_option; /* readonly option */ \
+ struct pathid cdir; /* arg C dir */ \
+ struct pathid hostdir; /* arg host dir */ \
+ char* ppdefault; /* arg default info file */ \
+ struct ppindex* firstindex; /* first include index entry */ \
+ struct ppindex* lastindex; /* last include index entry */ \
+ struct oplist* firstop; /* first arg op */ \
+ struct oplist* lastop; /* last arg op */ \
+ struct oplist* firsttx; /* first text file */ \
+ struct oplist* lasttx; /* last text file */ \
+ unsigned char arg_file; /* arg file index */ \
+ unsigned char arg_mode; /* arg mode */ \
+ unsigned char arg_style; /* arg style */ \
+ unsigned char c; /* arg C state */ \
+ unsigned char hosted; /* arg hosted state */ \
+ unsigned char ignoresrc; /* arg ignore source state */ \
+ unsigned char initialized; /* arg initialized state */ \
+ unsigned char standalone; /* arg standalone state */ \
+ unsigned char spare_1; /* padding spare */
+
+#define _PP_GLOBALS_PRIVATE_ /* ppglobals private additions */ \
+ char* checkpoint; /* checkpoint version */ \
+ int constack; /* pp.control size */ \
+ struct ppinstk* in; /* input stream stack pointer */ \
+ char* addp; /* addbuf pointer */ \
+ char* args; /* predicate args */ \
+ char* addbuf; /* ADD buffer */ \
+ char* catbuf; /* catenation buffer */ \
+ char* hdrbuf; /* HEADEREXPAND buffer */ \
+ char* hidebuf; /* pp:hide buffer */ \
+ char* path; /* full path of last #include */ \
+ char* tmpbuf; /* very temporary buffer */ \
+ char* valbuf; /* builtin macro value buffer */ \
+ char* optflags; /* OPT_* flags indexed by X_* */ \
+ int lastout; /* last output char */ \
+ /* the rest are implicitly initialized */ \
+ char* include; /* saved path of last #include */ \
+ char* prefix; /* current directory prefix */ \
+ struct ppmember* member; /* include archive member data */ \
+ int hidden; /* hidden newline count */ \
+ int hiding; /* number of symbols in hiding */ \
+ int level; /* pplex() recursion level */ \
+ struct \
+ { \
+ int input; /* pool input */ \
+ int output; /* pool output */ \
+ } pool; /* loop on input,output,error */ \
+ struct \
+ { \
+ long ro_state; /* original pp.ro_state */ \
+ long ro_mode; /* original pp.ro_mode */ \
+ long ro_option; /* original pp.ro_option */ \
+ int on; /* PP_RESET enabled */ \
+ Hash_table_t* symtab; /* original pp.symtab scope */ \
+ } reset; /* PP_RESET state */ \
+ int truncate; /* identifier truncation length */ \
+ struct ppmacstk* macp; /* top of macro actual stack */ \
+ char* maxmac; /* maximum size of macro stack */ \
+ char* mactop; /* top of current macro frame */ \
+ char* toknxt; /* '\0' of pp.token */ \
+ long* control; /* control block flags pointer */ \
+ long* maxcon; /* max control block frame */ \
+ struct oplist* chop; /* include prefix chop list */ \
+ struct ppfile* insert; /* inserted line sync file */ \
+ struct ppfile* original; /* original include name */ \
+ struct ppdirs* found; /* last successful ppsearch dir */ \
+ int vendor; /* vendor includes only */ \
+ Hash_table_t* dirtab; /* directive hash table */ \
+ Hash_table_t* strtab; /* string hash table */ \
+ PPBUILTIN builtin; /* builtin macro handler */ \
+ PPCOMMENT comment; /* pass along comments */ \
+ PPINCREF incref; /* include file push/return */ \
+ PPLINESYNC linesync; /* pass along line sync info */ \
+ PPLINESYNC olinesync; /* original linesync value */ \
+ PPMACREF macref; /* called on macro def/ref */ \
+ PPOPTARG optarg; /* unknown option arg handler */ \
+ PPPRAGMA pragma; /* pass along unknown pragmas */ \
+ struct counter counter; /* monitoring counters */ \
+ char funbuf[256]; /* last __FUNCTION__ */
+
+#define _PP_SYMBOL_PRIVATE_ /* ppsymbol private additions */ \
+ struct pphide* hidden; /* hidden symbol info */
+
+#if MACKEYARGS
+#define _PP_MACRO_PRIVATE_ /* ppmacro private additions */ \
+ struct pptuple* tuple; /* tuple macro */ \
+ union \
+ { \
+ char* formal; /* normal formals list */ \
+ struct ppkeyarg* key; /* keyword formals table */ \
+ } args; /* macro args info */ \
+ int size; /* body size */
+#define formals args.formal /* formal argument list */
+#define formkeys args.key /* formal keyword argument list */
+#else
+#define _PP_MACRO_PRIVATE_ /* ppmacro private additions */ \
+ struct pptuple* tuple; /* tuple macro */ \
+ char* formals; /* formal argument list */ \
+ int size; /* body size */
+#endif
+
+#define _PP_DIRS_PRIVATE_ /* ppdirs private additions */ \
+ unsigned char c; /* files here are C language */ \
+ unsigned char index; /* prefix,local,standard index */ \
+ unsigned char type; /* dir type */ \
+ union \
+ { \
+ char* buffer; /* TYPE_BUFFER buffer */ \
+ Sfio_t* sp; /* archive stream */ \
+ struct ppdirs* subdir; /* subdir list */ \
+ } info; /* type info */ \
+ struct ppfileid id; /* directory id */ \
+
+#if !PROTOMAIN
+#include <ast.h>
+#include <error.h>
+#endif
+
+#undef newof
+#define newof(p,t,n,x) ((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)calloc(1,sizeof(t)*(n)+(x)))
+
+#include "pp.h"
+#include "ppdef.h"
+#include "ppkey.h"
+
+#undef setstate /* random clash! */
+
+/*
+ * DEBUG is encoded with the following bits
+ */
+
+#define TRACE_message 01
+#define TRACE_count 02
+#define TRACE_debug 04
+
+#if DEBUG && !lint
+#define PANIC (ERROR_PANIC|ERROR_SOURCE|ERROR_SYSTEM),__FILE__,__LINE__
+#else
+#define PANIC ERROR_PANIC
+#endif
+
+#if DEBUG & TRACE_count
+#define count(x) pp.counter.x++
+#else
+#define count(x)
+#endif
+
+#if DEBUG & TRACE_message
+#define message(x) do { if (tracing) error x; } while (0)
+#else
+#define message(x)
+#endif
+
+#if DEBUG & TRACE_debug
+#define debug(x) do { if (tracing) error x; } while (0)
+#else
+#define debug(x)
+#endif
+
+/*
+ * note that MEMCPY advances the associated pointers
+ */
+
+#define MEMCPY(to,fr,n) \
+ do switch(n) \
+ { default : memcpy(to,fr,n); to += n; fr += n; break; \
+ case 7 : *to++ = *fr++; \
+ case 6 : *to++ = *fr++; \
+ case 5 : *to++ = *fr++; \
+ case 4 : *to++ = *fr++; \
+ case 3 : *to++ = *fr++; \
+ case 2 : *to++ = *fr++; \
+ case 1 : *to++ = *fr++; \
+ case 0 : break; \
+ } while (0)
+
+#define NEWDIRECTIVE (-1)
+
+#undef dirname
+#undef error
+
+#define dirname(x) ppkeyname(x,1)
+#define error pperror
+#define keyname(x) ppkeyname(x,0)
+#define nextframe(m,p) (m->next=m+(p-(char*)m+sizeof(struct ppmacstk)-1)/sizeof(struct ppmacstk)+1)
+#define popframe(m) (m=m->prev)
+#define pptokchr(c) pptokstr(NiL,(c))
+#define pushcontrol() do { if (pp.control++ >= pp.maxcon) ppnest(); } while (0)
+#define pushframe(m) (m->next->prev=m,m=m->next)
+#define setmode(m,v) ((v)?(pp.mode|=(m)):(pp.mode&=~(m)))
+#define setoption(m,v) ((v)?(pp.option|=(m)):(pp.option&=~(m)))
+#define setstate(s,v) ((v)?(pp.state|=(s)):(pp.state&=~(s)))
+#define tracing (error_info.trace<0)
+
+#define ppgetfile(x) ((struct ppfile*)hashlook(pp.filtab,x,HASH_LOOKUP,NiL))
+#define ppsetfile(x) ((struct ppfile*)hashlook(pp.filtab,x,HASH_CREATE|HASH_SIZE(sizeof(struct ppfile)),NiL))
+
+#define ppkeyget(t,n) (struct ppsymkey*)hashlook(t,n,HASH_LOOKUP,NiL)
+#define ppkeyref(t,n) (struct ppsymkey*)hashlook(t,n,HASH_LOOKUP|HASH_INTERNAL,NiL)
+#define ppkeyset(t,n) (struct ppsymkey*)hashlook(t,n,HASH_CREATE|HASH_SIZE(sizeof(struct ppsymkey)),NiL)
+
+#define MARK '@' /* internal mark */
+#define ARGOFFSET '1' /* macro arg mark offset */
+
+#define STRAPP(p,v,r) do{r=(v);while((*p++)=(*r++));}while(0)
+#define STRCOPY(p,v,r) do{r=(v);while((*p++)=(*r++));p--;}while(0)
+#define STRCOPY2(p,r) do{while((*p++)=(*r++));p--;}while(0)
+
+#define SETFILE(p,v) (p+=sfsprintf(p,16,"%c%c%lx%c",MARK,'F',(long)v,MARK))
+#define SETLINE(p,v) (p+=sfsprintf(p,16,"%c%c%lx%c",MARK,'L',(long)v,MARK))
+
+#define peekchr() (*pp.in->nextchr)
+#define ungetchr(c) (*--pp.in->nextchr=(c))
+
+#define MAXID 255 /* maximum identifier size */
+#define MAXTOKEN PPTOKSIZ /* maximum token size */
+#define MAXFORMALS 64 /* maximum number macro formals */
+#define MAXHIDDEN 8 /* ppline if hidden>=MAXHIDDEN */
+#define DEFMACSTACK (MAXFORMALS*32*32)/* default macstack size */
+
+#define FSM_COMPATIBILITY 1 /* compatibility mode */
+#define FSM_IDADD 2 /* add to identifer set */
+#define FSM_IDDEL 3 /* delete from identifer set */
+#define FSM_INIT 4 /* initilize */
+#define FSM_MACRO 5 /* add new macro */
+#define FSM_OPSPACE 6 /* handle <binop><space>= */
+#define FSM_PLUSPLUS 7 /* C++ lexical analysis */
+#define FSM_QUOTADD 8 /* add to quote set */
+#define FSM_QUOTDEL 9 /* delete from quote set */
+
+#define IN_TOP 01 /* top level -- directives ok */
+
+#define IN_BUFFER (2|IN_TOP) /* buffer of lines */
+#define IN_COPY 2 /* macro arg (copied) */
+#define IN_EXPAND 4 /* macro arg (expanded) */
+#define IN_FILE (4|IN_TOP) /* file */
+#define IN_INIT (6|IN_TOP) /* initialization IN_BUFFER */
+#define IN_MACRO 8 /* macro text */
+#define IN_MULTILINE (8|IN_TOP) /* multi-line macro text */
+#define IN_QUOTE 10 /* "..." macro arg (copied) */
+#define IN_RESCAN (10|IN_TOP) /* directive rescan buffer */
+#define IN_SQUOTE 12 /* '...' macro arg (copied) */
+#define IN_STRING 14 /* string */
+
+#define INC_CLEAR ((struct ppsymbol*)0)
+#define INC_IGNORE ((struct ppsymbol*)pp.addbuf)
+#define INC_TEST ((struct ppsymbol*)pp.catbuf)
+
+#define INC_BOUND(n) (1<<(n))
+#define INC_MEMBER(n) (1<<((n)+INC_MAX))
+#define INC_PREFIX 0
+#define INC_LOCAL 1
+#define INC_STANDARD 2
+#define INC_VENDOR 3
+#define INC_MAX 4
+#define INC_SELF (1<<(2*INC_MAX+0))
+#define INC_EXISTS (1<<(2*INC_MAX+1))
+#define INC_LISTED (1<<(2*INC_MAX+2))
+#define INC_MAPALL (1<<(2*INC_MAX+3))
+#define INC_MAPHOSTED (1<<(2*INC_MAX+4))
+#define INC_MAPNOHOSTED (1<<(2*INC_MAX+5))
+#define INC_MAPNOLOCAL (1<<(2*INC_MAX+6))
+#define INC_HOSTED (1<<(2*INC_MAX+7))
+
+#define TYPE_ARCHIVE (1<<0)
+#define TYPE_BUFFER (1<<1)
+#define TYPE_CHECKPOINT (1<<2)
+#define TYPE_DIRECTORY (1<<3)
+#define TYPE_HOSTED (1<<4)
+#define TYPE_INCLUDE (1<<5)
+#define TYPE_VENDOR (1<<6)
+
+#define TOK_BUILTIN (1<<0) /* last token was #( */
+#define TOK_FORMAL (1<<1) /* last token was arg formal id */
+#define TOK_ID (1<<2) /* last token was identifier */
+#define TOK_TOKCAT (1<<3) /* last token was ## */
+
+#define HADELSE (1<<0) /* already had else part */
+#define KEPT (1<<1) /* already kept part of block */
+#define SKIP (1<<2) /* skip this block */
+#define BLOCKBITS 3 /* block flag bits */
+
+#define SETIFBLOCK(p) (*(p)=(*((p)-1)&SKIP)|((long)error_info.line<<BLOCKBITS))
+#define GETIFLINE(p) ((*(p)>>BLOCKBITS)&((1L<<(sizeof(long)*CHAR_BIT-BLOCKBITS))-1))
+
+#define PUSH(t,p) \
+ do \
+ { \
+ count(push); \
+ if (!pp.in->next) \
+ { \
+ pp.in->next = newof(0, struct ppinstk, 1, 0); \
+ pp.in->next->prev = pp.in; \
+ } \
+ p = pp.in = pp.in->next; \
+ p->type = t; \
+ p->flags = 0; \
+ } while (0)
+
+#define PUSH_BUFFER(f,p,n) \
+ pppush(IN_BUFFER,f,p,n)
+
+#define PUSH_COPY(p,n) \
+ do \
+ { \
+ register struct ppinstk* cur; \
+ PUSH(IN_COPY, cur); \
+ cur->line = error_info.line; \
+ error_info.line = n; \
+ cur->nextchr = p; \
+ cur->prev->symbol->flags &= ~SYM_DISABLED; \
+ debug((-7, "PUSH in=%s next=%s", ppinstr(pp.in), pptokchr(*pp.in->nextchr))); \
+ } while (0)
+
+#define PUSH_EXPAND(p,n) \
+ do \
+ { \
+ register struct ppinstk* cur; \
+ PUSH(IN_EXPAND, cur); \
+ cur->line = error_info.line; \
+ error_info.line = n; \
+ cur->prev->symbol->flags &= ~SYM_DISABLED; \
+ cur->buffer = cur->nextchr = ppexpand(p); \
+ if (!(cur->prev->symbol->flags & SYM_MULTILINE)) \
+ cur->prev->symbol->flags |= SYM_DISABLED; \
+ debug((-7, "PUSH in=%s next=%s", ppinstr(pp.in), pptokchr(*pp.in->nextchr))); \
+ } while (0)
+
+#define PUSH_FILE(f,d) \
+ pppush(IN_FILE,f,NiL,d)
+
+#define PUSH_INIT(f,p) \
+ pppush(IN_INIT,f,p,1)
+
+#define PUSH_MACRO(p) \
+ do \
+ { \
+ register struct ppinstk* cur; \
+ PUSH(IN_MACRO, cur); \
+ cur->symbol = p; \
+ cur->nextchr = p->macro->value; \
+ p->flags |= SYM_DISABLED; \
+ if (p->flags & SYM_FUNCTION) pushframe(pp.macp); \
+ pp.state &= ~NEWLINE; \
+ debug((-7, "PUSH in=%s next=%s", ppinstr(pp.in), pptokchr(*pp.in->nextchr))); \
+ } while (0)
+
+#define PUSH_TUPLE(p,v) \
+ do \
+ { \
+ register struct ppinstk* cur; \
+ PUSH(IN_MACRO, cur); \
+ cur->symbol = p; \
+ cur->nextchr = v; \
+ p->flags |= SYM_DISABLED; \
+ pp.state &= ~NEWLINE; \
+ debug((-7, "PUSH in=%s next=%s", ppinstr(pp.in), pptokchr(*pp.in->nextchr))); \
+ } while (0)
+
+#define PUSH_MULTILINE(p) \
+ do \
+ { \
+ register struct ppinstk* cur; \
+ register int n; \
+ PUSH(IN_MULTILINE, cur); \
+ cur->symbol = p; \
+ cur->flags |= IN_defguard|IN_endguard|IN_noguard; \
+ pushcontrol(); \
+ cur->control = pp.control; \
+ *pp.control = 0; \
+ cur->file = error_info.file; \
+ n = strlen(error_info.file) + strlen(((struct ppsymbol*)p)->name) + 24; \
+ error_info.file = cur->buffer = newof(0, char, n, 0); \
+ sfsprintf(error_info.file, n, "%s:%s,%d", cur->file, p->name, error_info.line); \
+ cur->line = error_info.line; \
+ error_info.line = 1; \
+ cur->nextchr = p->macro->value; \
+ if (p->flags & SYM_FUNCTION) pushframe(pp.macp); \
+ pp.state &= ~NEWLINE; \
+ debug((-7, "PUSH in=%s next=%s", ppinstr(pp.in), pptokchr(*pp.in->nextchr))); \
+ } while (0)
+
+#define PUSH_QUOTE(p,n) \
+ do \
+ { \
+ register struct ppinstk* cur; \
+ PUSH(IN_QUOTE, cur); \
+ cur->nextchr = p; \
+ pp.state |= QUOTE; \
+ cur->line = error_info.line; \
+ error_info.line = n; \
+ debug((-7, "PUSH in=%s next=%s", ppinstr(pp.in), pptokchr(*pp.in->nextchr))); \
+ } while (0)
+
+#define PUSH_RESCAN(p) \
+ pppush(IN_RESCAN,NiL,p,0)
+
+#define PUSH_SQUOTE(p,n) \
+ do \
+ { \
+ register struct ppinstk* cur; \
+ PUSH(IN_SQUOTE, cur); \
+ cur->nextchr = p; \
+ pp.state |= SQUOTE; \
+ cur->line = error_info.line; \
+ error_info.line = n; \
+ debug((-7, "PUSH in=%s next=%s", ppinstr(pp.in), pptokchr(*pp.in->nextchr))); \
+ } while (0)
+
+#define PUSH_STRING(p) \
+ do \
+ { \
+ register struct ppinstk* cur; \
+ PUSH(IN_STRING, cur); \
+ cur->nextchr = p; \
+ if (pp.state & DISABLE) cur->flags |= IN_disable; \
+ debug((-7, "PUSH in=%s next=%s", ppinstr(pp.in), pptokchr(*pp.in->nextchr))); \
+ } while (0)
+
+#define PUSH_LINE(p) \
+ do \
+ { \
+ register struct ppinstk* cur; \
+ PUSH(IN_STRING, cur); \
+ cur->nextchr = p; \
+ pp.state |= DISABLE|NOSPACE|PASSEOF|STRIP; \
+ debug((-7, "PUSH in=%s next=%s", ppinstr(pp.in), pptokchr(*pp.in->nextchr))); \
+ } while (0)
+
+#define POP_LINE() \
+ do \
+ { \
+ debug((-7, "POP in=%s", ppinstr(pp.in))); \
+ pp.in = pp.in->prev; \
+ pp.state &= ~(DISABLE|NOSPACE|PASSEOF|STRIP); \
+ } while (0)
+
+struct ppcontext /* pp context */
+{
+ _PP_CONTEXT_PUBLIC_
+ _PP_CONTEXT_PRIVATE_
+};
+
+struct ppfile /* include file info */
+{
+ HASH_HEADER; /* this is a hash bucket too */
+ struct ppsymbol* guard; /* guard symbol */
+ struct ppfile* bound[INC_MAX]; /* include bindings */
+ int flags; /* INC_* flags */
+};
+
+#if CHECKPOINT
+
+struct ppindex /* checkpoint include index */
+{
+ struct ppindex* next; /* next in list */
+ struct ppfile* file; /* include file */
+ unsigned long begin; /* beginning output offset */
+ unsigned long end; /* ending output offset */
+};
+
+#endif
+
+struct ppsymkey /* pun for SYM_KEYWORD lex val */
+{
+ struct ppsymbol sym; /* symbol as usual */
+ int lex; /* lex value for SYM_KEYWORD */
+};
+
+#if PROTOMAIN && PROTO_STANDALONE
+
+#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
+#define NiL 0
+#define NoP(x) (&x,1)
+#else
+#define NiL ((char*)0)
+#define NoP(x)
+#endif
+
+#define newof(p,t,n,x) ((p)?(t*)realloc((char*)(p),sizeof(t)*(n)+(x)):(t*)calloc(1,sizeof(t)*(n)+(x)))
+
+#define _PP_DELAY_ #
+
+_PP_DELAY_ ifdef __STDC__
+
+_PP_DELAY_ include <stdlib.h>
+_PP_DELAY_ include <unistd.h>
+_PP_DELAY_ include <time.h>
+_PP_DELAY_ include <string.h>
+
+_PP_DELAY_ else
+
+_PP_DELAY_ define size_t int
+
+extern void* realloc(void*, size_t);
+extern void* calloc(size_t, size_t);
+extern char* ctime(time_t*);
+extern void free(void*);
+
+_PP_DELAY_ ifndef O_RDONLY
+
+extern int access(const char*, int);
+extern int close(int);
+extern int creat(const char*, int);
+extern void exit(int);
+extern int link(const char*, const char*);
+extern int open(const char*, int, ...);
+extern int read(int, void*, int);
+extern time_t time(time_t*);
+extern int unlink(const char*);
+extern int write(int, const void*, int);
+
+_PP_DELAY_ endif
+
+_PP_DELAY_ endif
+
+#else
+
+/*
+ * library implementation globals
+ */
+
+#define ppassert _pp_assert
+#define ppbuiltin _pp_builtin
+#define ppcall _pp_call
+#define ppcontrol _pp_control
+#define ppdump _pp_dump
+#define ppexpand _pp_expand
+#define ppexpr _pp_expr
+#define ppfsm _pp_fsm
+#define ppinmap _pp_inmap
+#define ppinstr _pp_instr
+#define ppkeyname _pp_keyname
+#define pplexmap _pp_lexmap
+#define pplexstr _pp_lexstr
+#define ppload _pp_load
+#define ppmodestr _pp_modestr
+#define ppmultiple _pp_multiple
+#define ppnest _pp_nest
+#define ppoption _pp_option
+#define ppoptionstr _pp_optionstr
+#define pppclose _pp_pclose
+#define pppdrop _pp_pdrop
+#define pppopen _pp_popen
+#define pppread _pp_pread
+#define pppredargs _pp_predargs
+#define pppush _pp_push
+#define pprefmac _pp_refmac
+#define ppsearch _pp_search
+#define ppstatestr _pp_statestr
+#define pptokstr _pp_tokstr
+#define pptrace _pp_trace
+
+#endif
+
+extern void ppassert(int, char*, char*);
+extern void ppbuiltin(void);
+extern int ppcall(struct ppsymbol*, int);
+extern int ppcontrol(void);
+extern void ppdump(void);
+extern char* ppexpand(char*);
+extern long ppexpr(int*);
+extern void ppfsm(int, char*);
+extern char* ppinstr(struct ppinstk*);
+extern char* ppkeyname(int, int);
+extern char* pplexstr(int);
+extern void ppload(char*);
+extern void ppmapinclude(char*, char*);
+extern char* ppmodestr(long);
+extern int ppmultiple(struct ppfile*, struct ppsymbol*);
+extern void ppnest(void);
+extern int ppoption(char*);
+extern char* ppoptionstr(long);
+extern void pppclose(char*);
+extern int pppdrop(char*);
+extern char* pppopen(char*, int, char*, char*, char*, char*, int);
+extern int pppread(char*);
+extern int pppredargs(void);
+extern void pppush(int, char*, char*, int);
+extern struct ppsymbol* pprefmac(char*, int);
+extern int ppsearch(char*, int, int);
+extern char* ppstatestr(long);
+extern char* pptokstr(char*, int);
+extern void pptrace(int);
+
+#if _std_malloc
+
+#include <vmalloc.h>
+
+#undef free
+#define free(p) vmfree(Vmregion,(void*)p)
+#undef newof
+#define newof(p,t,n,x) vmnewof(Vmregion,p,t,n,x)
+#undef oldof
+#define oldof(p,t,n,x) vmoldof(Vmregion,p,t,n,x)
+#undef strdup
+#define strdup(s) vmstrdup(Vmregion,s)
+
+#endif
+
+#endif
diff --git a/usr/src/lib/libpp/common/ppline.c b/usr/src/lib/libpp/common/ppline.c
new file mode 100644
index 0000000000..8ff7c23339
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppline.c
@@ -0,0 +1,86 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * common preprocessor line sync handler
+ */
+
+#include "pplib.h"
+
+void
+ppline(int line, char* file)
+{
+ char* s;
+ static char type[5];
+
+ if (pp.flags & PP_lineignore)
+ {
+ pp.flags &= ~PP_lineignore;
+ if (!(pp.flags & PP_linetype) || *pp.lineid)
+ {
+ ppline(1, file);
+ file = error_info.file;
+ }
+ else
+ type[1] = PP_sync_ignore;
+ }
+ else if (file != pp.lastfile)
+ {
+ if (!pp.firstfile)
+ pp.firstfile = file;
+ type[1] = ((pp.flags & PP_linetype) && !*pp.lineid && pp.lastfile) ? (line <= 1 ? (file == pp.firstfile ? PP_sync : PP_sync_push) : PP_sync_pop) : PP_sync;
+ pp.lastfile = file;
+ }
+ else
+ {
+ if (!(pp.flags & PP_linefile))
+ file = 0;
+ type[1] = PP_sync;
+ }
+ if (!(pp.flags & PP_linetype) || *pp.lineid || type[1] == PP_sync)
+ type[0] = 0;
+ else
+ {
+ type[0] = ' ';
+ if ((pp.flags & (PP_hosted|PP_linehosted)) == (PP_hosted|PP_linehosted))
+ {
+ type[2] = ' ';
+ type[3] = PP_sync_hosted;
+ }
+ else
+ type[2] = 0;
+ }
+
+ /*
+ * some front ends can't handle two line syncs in a row
+ */
+
+ if (pp.pending == pppendout() || pplastout() != '\n')
+ ppputchar('\n');
+ if (file)
+ ppprintf("#%s %d \"%s\"%s\n", pp.lineid, line, (pp.flags & PP_linebase) && (s = strrchr(file, '/')) ? s + 1 : file, type);
+ else
+ ppprintf("#%s %d\n", pp.lineid, line);
+ if (!pp.macref)
+ pp.pending = pppendout();
+}
diff --git a/usr/src/lib/libpp/common/ppmacref.c b/usr/src/lib/libpp/common/ppmacref.c
new file mode 100644
index 0000000000..d744f99803
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppmacref.c
@@ -0,0 +1,58 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * common preprocessor macro reference handler
+ */
+
+#include "pplib.h"
+
+void
+ppmacref(struct ppsymbol* sym, char* file, int line, int type, unsigned long sum)
+{
+ register char* p;
+
+ NoP(file);
+ NoP(line);
+ p = (pp.state & (DIRECTIVE|JOINING)) == DIRECTIVE ? pp.outp : pp.addp;
+ p += sfsprintf(p, MAXTOKEN, "\n#%s %d", pp.lineid, error_info.line);
+ p += sfsprintf(p, MAXTOKEN, "\n#%s %s:%s %s %d", dirname(PRAGMA), pp.pass, keyname(X_MACREF), sym->name, type);
+ if (type > 0)
+ {
+ if (sym->macro && sym->macro->value)
+ sum = strsum(sym->macro->value, (long)sym->macro->arity);
+ p += sfsprintf(p, MAXTOKEN, " %lu", sum);
+ }
+ if ((pp.state & (DIRECTIVE|JOINING)) == DIRECTIVE)
+ {
+ pp.outp = p;
+ ppcheckout();
+ }
+ else
+ {
+ *p++ = '\n';
+ pp.addp = p;
+ pp.state |= ADD;
+ }
+ pp.pending = pppendout();
+}
diff --git a/usr/src/lib/libpp/common/ppmisc.c b/usr/src/lib/libpp/common/ppmisc.c
new file mode 100644
index 0000000000..d7b5d3730e
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppmisc.c
@@ -0,0 +1,242 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * miscellaneous preprocessor support
+ */
+
+#include "pplib.h"
+
+/*
+ * macro symbol def|ref
+ */
+
+struct ppsymbol*
+pprefmac(char* name, int ref)
+{
+ register struct ppsymbol* sym;
+
+ if (!(sym = ppsymget(pp.symtab, name)) && (ref <= REF_NORMAL && pp.macref || ref == REF_CREATE || ref == REF_DELETE && (pp.mode & (INIT|READONLY))))
+ {
+ if ((pp.state & COMPILE) && pp.truncate && strlen(name) > pp.truncate)
+ name[pp.truncate] = 0;
+ sym = ppsymset(pp.symtab, NiL);
+ }
+ if (sym && ref <= REF_NORMAL)
+ {
+ if (pp.macref) (*pp.macref)(sym, error_info.file, error_info.line, ref == REF_NORMAL && (pp.state & CONDITIONAL) ? REF_IF : ref, 0L);
+ if (!sym->macro) sym = 0;
+ }
+#if COMPATIBLE
+ if (!(pp.state & COMPATIBILITY))
+#endif
+ if (ref == REF_IF && sym && (sym->flags & SYM_PREDEFINED) && *name != '_' && !(pp.mode & (HOSTED|INACTIVE)))
+ {
+ if (pp.state & STRICT)
+ {
+ error(1, "%s: obsolete predefined symbol reference disabled", name);
+ return(0);
+ }
+ error(1, "%s: obsolete predefined symbol referenced", name);
+ }
+ return(sym);
+}
+
+/*
+ * common predicate assertion operations
+ * op is DEFINE or UNDEF
+ */
+
+void
+ppassert(int op, char* pred, char* args)
+{
+ register struct pplist* a;
+ register struct ppsymbol* sym;
+ register struct pplist* p;
+ register struct pplist* q;
+
+ if (!args) switch (op)
+ {
+ case DEFINE:
+ goto mark;
+ case UNDEF:
+ a = 0;
+ goto unmark;
+ }
+ if (a = (struct pplist*)hashget(pp.prdtab, pred))
+ {
+ p = 0;
+ q = a;
+ while (q)
+ {
+ if (streq(q->value, args))
+ {
+ if (op == DEFINE) return;
+ q = q->next;
+ if (p) p->next = q;
+ else a = q;
+ }
+ else
+ {
+ p = q;
+ q = q->next;
+ }
+ }
+ if (op == UNDEF)
+ {
+ unmark:
+ hashput(pp.prdtab, pred, a);
+ if (sym = ppsymref(pp.symtab, pred))
+ sym->flags &= ~SYM_PREDICATE;
+ return;
+ }
+ }
+ if (op == DEFINE)
+ {
+ p = newof(0, struct pplist, 1, 0);
+ p->next = a;
+ p->value = strdup(args);
+ hashput(pp.prdtab, NiL, p);
+ mark:
+ if ((pp.state & COMPILE) && pp.truncate) return;
+ if (sym = ppsymset(pp.symtab, pred))
+ sym->flags |= SYM_PREDICATE;
+ }
+}
+
+/*
+ * parse a predicate argument list
+ * the args are placed in pp.args
+ * the first non-space/paren argument token type is returned
+ * forms:
+ *
+ * predicate <identifier> type=T_ID
+ * predicate ( <identifier> ) type=T_ID
+ * predicate ( ) type=0
+ * predicate ( <balanced-paren-list> ) type=T_STRING
+ * otherwise type=<other>
+ */
+
+int
+pppredargs(void)
+{
+ register int c;
+ register int n;
+ register int type;
+ char* pptoken;
+
+ pptoken = pp.token;
+ pp.token = pp.args;
+ switch (type = pplex())
+ {
+ case '(':
+ type = 0;
+ n = 1;
+ pp.state |= HEADER;
+ pp.state &= ~STRIP;
+ c = pplex();
+ pp.state &= ~NOSPACE;
+ for (;;)
+ {
+ switch (c)
+ {
+ case '(':
+ n++;
+ break;
+ case '\n':
+ ungetchr(c);
+ error(2, "missing %d )%s in predicate argument list", n, n == 1 ? "" : "'s");
+ type = 0;
+ goto done;
+ case ')':
+ if (!--n) goto done;
+ break;
+ }
+ pp.token = pp.toknxt;
+ if (c != ' ')
+ {
+ if (type) type = T_STRING;
+ else type = (c == T_ID) ? T_ID : T_STRING;
+ }
+ c = pplex();
+ }
+ done:
+ pp.state &= ~HEADER;
+ pp.state |= NOSPACE|STRIP;
+ if (pp.token > pp.args && *(pp.token - 1) == ' ') pp.token--;
+ *pp.token = 0;
+ break;
+ case '\n':
+ ungetchr('\n');
+ type = 0;
+ break;
+ }
+ pp.token = pptoken;
+ return(type);
+}
+
+/*
+ * sync output line number
+ */
+
+int
+ppsync(void)
+{
+ long m;
+
+ if ((pp.state & (ADD|HIDDEN)))
+ {
+ if (pp.state & ADD)
+ {
+ pp.state &= ~ADD;
+ m = pp.addp - pp.addbuf;
+ pp.addp = pp.addbuf;
+ ppprintf("%-.*s", m, pp.addbuf);
+ }
+ if (pp.linesync)
+ {
+ if ((pp.state & SYNCLINE) || pp.hidden >= MAXHIDDEN)
+ {
+ pp.hidden = 0;
+ pp.state &= ~(HIDDEN|SYNCLINE);
+ if (error_info.line)
+ (*pp.linesync)(error_info.line, error_info.file);
+ }
+ else
+ {
+ m = pp.hidden;
+ pp.hidden = 0;
+ pp.state &= ~HIDDEN;
+ while (m-- > 0)
+ ppputchar('\n');
+ }
+ }
+ else
+ {
+ pp.hidden = 0;
+ pp.state &= ~HIDDEN;
+ ppputchar('\n');
+ }
+ }
+ return 0;
+}
diff --git a/usr/src/lib/libpp/common/ppop.c b/usr/src/lib/libpp/common/ppop.c
new file mode 100644
index 0000000000..86e3651864
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppop.c
@@ -0,0 +1,1553 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * preprocessor library control interface
+ */
+
+#include "pplib.h"
+#include "pptab.h"
+
+#include <ls.h>
+
+#define REFONE (pp.truncate?(Hash_table_t*)0:pp.symtab)
+#define REFALL (pp.truncate?pp.dirtab:pp.symtab)
+
+#define ppiskey(t,v,p) (p=t,v>=p->value&&value<=(p+elementsof(t)-2)->value)
+
+/*
+ * set option value
+ * initialization files have lowest precedence
+ */
+
+static void
+set(register long* p, register long op, int val)
+{
+ long* r;
+
+ r = p == &pp.state ? &pp.ro_state : p == &pp.mode ? &pp.ro_mode : &pp.ro_option;
+ if (!(pp.mode & INIT) || !(pp.in->type == IN_FILE) || !(*r & op))
+ {
+ if (!pp.initialized && !(pp.mode & INIT))
+ *r |= op;
+ if (val)
+ *p |= op;
+ else
+ *p &= ~op;
+ }
+ debug((-7, "set(%s)=%s", p == &pp.state ? "state" : p == &pp.mode ? "mode" : "option", p == &pp.state ? ppstatestr(*p) : p == &pp.mode ? ppmodestr(*p) : ppoptionstr(*p)));
+}
+
+/*
+ * initialize hash table with keywords from key
+ */
+
+static void
+inithash(register Hash_table_t* tab, register struct ppkeyword* key)
+{
+ register char* s;
+
+ for (; s = key->name; key++)
+ {
+ if (!ppisid(*s))
+ s++;
+ hashput(tab, s, key->value);
+ }
+}
+
+/*
+ * return ppkeyword table name given value
+ */
+
+char*
+ppkeyname(register int value, int dir)
+{
+ register char* s;
+ register struct ppkeyword* p;
+
+ if (dir && ppiskey(directives, value, p) || !dir && (ppiskey(options, value, p) || ppiskey(predicates, value, p) || ppiskey(variables, value, p)))
+ {
+ s = (p + (value - p->value))->name;
+ return s + !ppisid(*s);
+ }
+#if DEBUG
+ error(PANIC, "no keyword table name for value=%d", value);
+#endif
+ return "UNKNOWN";
+}
+
+/*
+ * add to the include maps
+ */
+
+void
+ppmapinclude(char* file, register char* s)
+{
+ register int c;
+ register struct ppdirs* dp;
+ int fd;
+ int flags;
+ int index;
+ int token;
+ char* t;
+ char* old_file;
+ long old_state;
+ struct ppfile* fp;
+ struct ppfile* mp;
+
+ old_file = error_info.file;
+ old_state = pp.state;
+ if (s)
+ PUSH_BUFFER("mapinclude", s, 1);
+ else if (file)
+ {
+ if (*file == '-')
+ {
+ if (!error_info.file)
+ {
+ error(1, "%s: input file name required for %s ignore", file, dirname(INCLUDE));
+ return;
+ }
+ s = t = strcopy(pp.tmpbuf, error_info.file);
+ c = *++file;
+ for (;;)
+ {
+ if (s <= pp.tmpbuf || *s == '/')
+ {
+ s = t;
+ break;
+ }
+ else if (*s == c)
+ break;
+ s--;
+ }
+ strcpy(s, file);
+ file = pp.tmpbuf;
+ }
+ if ((fd = ppsearch(file, INC_LOCAL, SEARCH_INCLUDE)) < 0)
+ return;
+ PUSH_FILE(file, fd);
+ }
+ else
+ return;
+#if CATSTRINGS
+ pp.state |= (COMPILE|FILEPOP|HEADER|JOINING|STRIP|NOSPACE|PASSEOF);
+#else
+ pp.state |= (COMPILE|FILEPOP|HEADER|STRIP|NOSPACE|PASSEOF);
+#endif
+ pp.level++;
+ flags = INC_MAPALL;
+ fp = mp = 0;
+ for (;;)
+ {
+ switch (token = pplex())
+ {
+ case 0:
+ case T_STRING:
+ case T_HEADER:
+ if (fp)
+ {
+ fp->guard = INC_IGNORE;
+ for (dp = pp.firstdir->next; dp; dp = dp->next)
+ if (dp->name && (c = strlen(dp->name)) && !strncmp(dp->name, fp->name, c) && fp->name[c] == '/')
+ {
+ ppsetfile(fp->name + c + 1)->guard = INC_IGNORE;
+ break;
+ }
+ }
+ if (!token)
+ break;
+ pathcanon(pp.token, 0);
+ fp = ppsetfile(pp.token);
+ if (mp)
+ {
+ mp->flags |= flags;
+ if (streq(fp->name, "."))
+ mp->flags |= INC_MAPNOLOCAL;
+ else
+ mp->bound[index] = fp;
+
+ fp = mp = 0;
+ }
+ else
+ index = token == T_HEADER ? INC_STANDARD : INC_LOCAL;
+ continue;
+ case '=':
+ if (!(mp = fp))
+ error(3, "%s: \"name\" = \"binding\" expected");
+ fp = 0;
+ continue;
+ case '\n':
+ continue;
+ case T_ID:
+ if (streq(pp.token, "all"))
+ {
+ flags = INC_MAPALL;
+ continue;
+ }
+ else if (streq(pp.token, "hosted"))
+ {
+ flags = INC_MAPHOSTED;
+ continue;
+ }
+ else if (streq(pp.token, "nohosted"))
+ {
+ flags = INC_MAPNOHOSTED;
+ continue;
+ }
+ /*FALLTHROUGH*/
+ default:
+ error(3, "%s unexpected in %s map list", pptokstr(pp.token, 0), dirname(INCLUDE));
+ break;
+ }
+ break;
+ }
+ pp.level--;
+ error_info.file = old_file;
+ pp.state = old_state;
+}
+
+/*
+ * return non-0 if file is identical to fd
+ */
+
+static int
+identical(char* file, int fd)
+{
+ struct stat a;
+ struct stat b;
+
+ return !stat(file, &a) && !fstat(fd, &b) && a.st_dev == b.st_dev && a.st_ino == b.st_ino;
+}
+
+/*
+ * compare up to pp.truncate chars
+ *
+ * NOTE: __STD* and symbols containing ' ' are not truncated
+ */
+
+static int
+trunccomp(register char* a, register char* b)
+{
+ return !strchr(b, ' ') && !strneq(b, "__STD", 5) ? strncmp(a, b, pp.truncate) : strcmp(a, b);
+}
+
+/*
+ * hash up to pp.truncate chars
+ *
+ * NOTE: __STD* and symbols containing ' ' are not truncated
+ */
+
+static unsigned int
+trunchash(char* a)
+{
+ int n;
+
+ return memhash(a, (n = strlen(a)) > pp.truncate && !strchr(a, ' ') && !strneq(a, "__STD", 5) ? pp.truncate : n);
+}
+
+#if DEBUG & TRACE_debug
+/*
+ * append context to debug trace
+ */
+
+static int
+context(Sfio_t* sp, int level, int flags)
+{
+ static int state;
+
+ NoP(level);
+ NoP(flags);
+ if (error_info.trace <= -10 && pp.state != state)
+ {
+ state = pp.state;
+ sfprintf(sp, " %s", ppstatestr(pp.state));
+ }
+ return 1;
+}
+#endif
+
+/*
+ * reset include guard
+ */
+
+static int
+unguard(const char* name, char* v, void* handle)
+{
+ register struct ppfile* fp = (struct ppfile*)v;
+
+ fp->guard = 0;
+ return 0;
+}
+
+/*
+ * reset macro definition
+ */
+
+static void
+undefine(void* p)
+{
+ struct ppmacro* mac = ((struct ppsymbol*)p)->macro;
+
+ if (mac)
+ {
+ if (mac->formals)
+ free(mac->formals);
+ free(mac->value);
+ free(mac);
+ }
+}
+
+/*
+ * pp operations
+ *
+ * NOTE: PP_INIT must be done before the first pplex() call
+ * PP_DONE must be done after the last pplex() call
+ * PP_INIT-PP_DONE must be done for each new PP_INPUT
+ */
+
+void
+ppop(int op, ...)
+{
+ va_list ap;
+ register char* p;
+ register struct ppkeyword* kp;
+ register char* s;
+ int c;
+ long n;
+ char* t;
+ struct ppdirs* dp;
+ struct ppdirs* hp;
+ struct ppsymkey* key;
+ struct oplist* xp;
+ Sfio_t* sp;
+ struct stat st;
+ PPCOMMENT ppcomment;
+ PPLINESYNC pplinesync;
+
+ static int initialized;
+
+ va_start(ap, op);
+ switch (op)
+ {
+ case PP_ASSERT:
+ case PP_DEFINE:
+ case PP_DIRECTIVE:
+ case PP_OPTION:
+ case PP_READ:
+ case PP_UNDEF:
+ if (pp.initialized)
+ goto before;
+ if ((p = va_arg(ap, char*)) && *p)
+ {
+ if (pp.lastop)
+ pp.lastop = (pp.lastop->next = newof(0, struct oplist, 1, 0));
+ else
+ pp.firstop = pp.lastop = newof(0, struct oplist, 1, 0);
+ pp.lastop->op = op;
+ pp.lastop->value = p;
+ }
+ break;
+ case PP_BUILTIN:
+ pp.builtin = va_arg(ap, PPBUILTIN);
+ break;
+ case PP_CDIR:
+ p = va_arg(ap, char*);
+ c = va_arg(ap, int);
+ pp.cdir.path = 0;
+ if (!p)
+ pp.c = c;
+ else if (streq(p, "-"))
+ {
+ pp.c = c;
+ for (dp = pp.firstdir; dp; dp = dp->next)
+ dp->c = c;
+ }
+ else if (!pp.c)
+ {
+ if (!*p || stat((pathcanon(p, 0), p), &st))
+ pp.c = c;
+ else
+ {
+ for (dp = pp.firstdir; dp; dp = dp->next)
+ {
+ if (!pp.c && (dp->c || dp->name && SAMEID(&dp->id, &st)))
+ pp.c = 1;
+ dp->c = pp.c == 1;
+ }
+ if (!pp.c)
+ {
+ pp.cdir.path = p;
+ SAVEID(&pp.cdir.id, &st);
+ }
+ }
+ }
+ break;
+ case PP_CHOP:
+ if (p = va_arg(ap, char*))
+ {
+ c = strlen(p);
+ xp = newof(0, struct oplist, 1, c + 1);
+ xp->value = ((char*)xp) + sizeof(struct oplist);
+ s = xp->value;
+ c = *p++;
+ while (*p && *p != c)
+ *s++ = *p++;
+ *s++ = '/';
+ xp->op = s - xp->value;
+ *s++ = 0;
+ if (*p && *++p && *p != c)
+ {
+ while (*p && *p != c)
+ *s++ = *p++;
+ *s++ = '/';
+ }
+ *s = 0;
+ xp->next = pp.chop;
+ pp.chop = xp;
+ }
+ break;
+ case PP_COMMENT:
+ if (pp.comment = va_arg(ap, PPCOMMENT))
+ pp.flags |= PP_comment;
+ else
+ pp.flags &= ~PP_comment;
+ break;
+ case PP_COMPATIBILITY:
+ set(&pp.state, COMPATIBILITY, va_arg(ap, int));
+#if COMPATIBLE
+ if (pp.initialized)
+ ppfsm(FSM_COMPATIBILITY, NiL);
+#else
+ if (pp.state & COMPATIBILITY)
+ error(3, "preprocessor not compiled with compatibility dialect enabled [COMPATIBLE]");
+#endif
+ if (pp.state & COMPATIBILITY)
+ pp.flags |= PP_compatibility;
+ else
+ pp.flags &= ~PP_compatibility;
+ break;
+ case PP_COMPILE:
+ if (pp.initialized)
+ goto before;
+ pp.state |= COMPILE;
+ if (!pp.symtab)
+ pp.symtab = hashalloc(NiL, HASH_name, "symbols", 0);
+ if (kp = va_arg(ap, struct ppkeyword*))
+ for (; s = kp->name; kp++)
+ {
+ n = SYM_LEX;
+ switch (*s)
+ {
+ case '-':
+ s++;
+ break;
+ case '+':
+ s++;
+ if (!(pp.option & PLUSPLUS))
+ break;
+ /*FALLTHROUGH*/
+ default:
+ n |= SYM_KEYWORD;
+ break;
+ }
+ if (key = ppkeyset(pp.symtab, s))
+ {
+ key->sym.flags = n;
+ key->lex = kp->value;
+ }
+ }
+ break;
+ case PP_DEBUG:
+ error_info.trace = va_arg(ap, int);
+ break;
+ case PP_DEFAULT:
+ if (p = va_arg(ap, char*))
+ p = strdup(p);
+ if (pp.ppdefault)
+ free(pp.ppdefault);
+ pp.ppdefault = p;
+ break;
+ case PP_DONE:
+#if CHECKPOINT
+ if (pp.mode & DUMP)
+ ppdump();
+#endif
+ if (pp.mode & FILEDEPS)
+ {
+ sfputc(pp.filedeps.sp, '\n');
+ if (pp.filedeps.sp == sfstdout)
+ sfsync(pp.filedeps.sp);
+ else
+ sfclose(pp.filedeps.sp);
+ }
+ if (pp.state & STANDALONE)
+ {
+ if ((pp.state & (NOTEXT|HIDDEN)) == HIDDEN && pplastout() != '\n')
+ ppputchar('\n');
+ ppflushout();
+ }
+ error_info.file = 0;
+ break;
+ case PP_DUMP:
+ set(&pp.mode, DUMP, va_arg(ap, int));
+#if !CHECKPOINT
+ if (pp.mode & DUMP)
+ error(3, "preprocessor not compiled with checkpoint enabled [CHECKPOINT]");
+#endif
+ break;
+ case PP_FILEDEPS:
+ if (n = va_arg(ap, int))
+ pp.filedeps.flags |= n;
+ else
+ pp.filedeps.flags = 0;
+ break;
+ case PP_FILENAME:
+ error_info.file = va_arg(ap, char*);
+ break;
+ case PP_HOSTDIR:
+ if (!(pp.mode & INIT))
+ pp.ro_mode |= HOSTED;
+ else if (pp.ro_mode & HOSTED)
+ break;
+ pp.ro_mode |= INIT;
+ p = va_arg(ap, char*);
+ c = va_arg(ap, int);
+ pp.hostdir.path = 0;
+ if (!p)
+ pp.hosted = c;
+ else if (streq(p, "-"))
+ {
+ if (pp.initialized)
+ set(&pp.mode, HOSTED, c);
+ else
+ {
+ pp.hosted = c ? 1 : 2;
+ for (dp = pp.firstdir; dp; dp = dp->next)
+ if (pp.hosted == 1)
+ dp->type |= TYPE_HOSTED;
+ else
+ dp->type &= ~TYPE_HOSTED;
+ }
+ }
+ else if (!pp.hosted)
+ {
+ if (!*p || stat((pathcanon(p, 0), p), &st))
+ pp.hosted = 1;
+ else
+ {
+ for (dp = pp.firstdir; dp; dp = dp->next)
+ {
+ if (!pp.hosted && ((dp->type & TYPE_HOSTED) || dp->name && SAMEID(&dp->id, &st)))
+ pp.hosted = 1;
+ if (pp.hosted == 1)
+ dp->type |= TYPE_HOSTED;
+ else
+ dp->type &= ~TYPE_HOSTED;
+ }
+ if (!pp.hosted)
+ {
+ pp.hostdir.path = p;
+ SAVEID(&pp.hostdir.id, &st);
+ }
+ }
+ }
+ break;
+ case PP_ID:
+ p = va_arg(ap, char*);
+ c = va_arg(ap, int);
+ if (p)
+ ppfsm(c ? FSM_IDADD : FSM_IDDEL, p);
+ break;
+ case PP_IGNORE:
+ if (p = va_arg(ap, char*))
+ {
+ pathcanon(p, 0);
+ ppsetfile(p)->guard = INC_IGNORE;
+ message((-3, "%s: ignore", p));
+ }
+ break;
+ case PP_IGNORELIST:
+ if (pp.initialized)
+ goto before;
+ pp.ignore = va_arg(ap, char*);
+ break;
+ case PP_INCLUDE:
+ if ((p = va_arg(ap, char*)) && *p)
+ {
+ pathcanon(p, 0);
+ if (stat(p, &st))
+ break;
+ for (dp = pp.stddirs; dp = dp->next;)
+ if (dp->name && SAMEID(&dp->id, &st))
+ break;
+ if (pp.cdir.path && SAMEID(&pp.cdir.id, &st))
+ {
+ pp.cdir.path = 0;
+ pp.c = 1;
+ }
+ if (pp.hostdir.path && SAMEID(&pp.hostdir.id, &st))
+ {
+ pp.hostdir.path = 0;
+ pp.hosted = 1;
+ }
+ if ((pp.mode & INIT) && !(pp.ro_mode & INIT))
+ pp.hosted = 1;
+ c = dp && dp->c || pp.c == 1;
+ n = dp && (dp->type & TYPE_HOSTED) || pp.hosted == 1;
+ if (!dp || dp == pp.lastdir->next)
+ {
+ if (dp)
+ {
+ c = dp->c;
+ n = dp->type & TYPE_HOSTED;
+ }
+ dp = newof(0, struct ppdirs, 1, 0);
+ dp->name = p;
+ SAVEID(&dp->id, &st);
+ dp->type |= TYPE_INCLUDE;
+ dp->index = INC_LOCAL + pp.ignoresrc != 0;
+ dp->next = pp.lastdir->next;
+ pp.lastdir = pp.lastdir->next = dp;
+ }
+ dp->c = c;
+ if (n)
+ dp->type |= TYPE_HOSTED;
+ else
+ dp->type &= ~TYPE_HOSTED;
+ }
+ break;
+ case PP_INCREF:
+ pp.incref = va_arg(ap, PPINCREF);
+ break;
+ case PP_RESET:
+ pp.reset.on = 1;
+ break;
+ case PP_INIT:
+ if (pp.initialized)
+ {
+ error_info.errors = 0;
+ error_info.warnings = 0;
+ }
+ else
+ {
+ /*
+ * context initialization
+ */
+
+ if (!initialized)
+ {
+ /*
+ * out of malloc is fatal
+ */
+
+ memfatal();
+
+ /*
+ * initialize the error message interface
+ */
+
+ error_info.version = (char*)pp.version;
+#if DEBUG & TRACE_debug
+ error_info.auxilliary = context;
+ pptrace(0);
+#endif
+
+ /*
+ * initialize pplex tables
+ */
+
+ ppfsm(FSM_INIT, NiL);
+
+ /*
+ * fixed macro stack size -- room for improvement
+ */
+
+ pp.macp = newof(0, struct ppmacstk, DEFMACSTACK, 0);
+ pp.macp->next = pp.macp + 1;
+ pp.maxmac = (char*)pp.macp + DEFMACSTACK;
+ initialized = 1;
+
+ /*
+ * initial include/if control stack
+ */
+
+ pp.control = newof(0, long, pp.constack, 0);
+ pp.maxcon = pp.control + pp.constack - 1;
+ }
+
+ /*
+ * validate modes
+ */
+
+ switch (pp.arg_mode)
+ {
+ case 'a':
+ case 'C':
+ ppop(PP_COMPATIBILITY, 0);
+ ppop(PP_TRANSITION, 1);
+ break;
+ case 'A':
+ case 'c':
+ ppop(PP_COMPATIBILITY, 0);
+ ppop(PP_STRICT, 1);
+ break;
+ case 'f':
+ ppop(PP_COMPATIBILITY, 1);
+ ppop(PP_PLUSPLUS, 1);
+ ppop(PP_TRANSITION, 1);
+ break;
+ case 'F':
+ ppop(PP_COMPATIBILITY, 0);
+ ppop(PP_PLUSPLUS, 1);
+ break;
+ case 'k':
+ case 's':
+ ppop(PP_COMPATIBILITY, 1);
+ ppop(PP_STRICT, 1);
+ break;
+ case 'o':
+ case 'O':
+ ppop(PP_COMPATIBILITY, 1);
+ ppop(PP_TRANSITION, 0);
+ break;
+ case 't':
+ ppop(PP_COMPATIBILITY, 1);
+ ppop(PP_TRANSITION, 1);
+ break;
+ }
+ if (!(pp.arg_style & STYLE_gnu))
+ ppop(PP_PEDANTIC, 1);
+ if (pp.state & PASSTHROUGH)
+ {
+ if (pp.state & COMPILE)
+ {
+ pp.state &= ~PASSTHROUGH;
+ error(1, "passthrough ignored for compile");
+ }
+ else
+ {
+ ppop(PP_COMPATIBILITY, 1);
+ ppop(PP_HOSTDIR, "-", 1);
+ ppop(PP_SPACEOUT, 1);
+ set(&pp.state, DISABLE, va_arg(ap, int));
+ }
+ }
+
+ /*
+ * create the hash tables
+ */
+
+ if (!pp.symtab)
+ pp.symtab = hashalloc(NiL, HASH_name, "symbols", 0);
+ if (!pp.dirtab)
+ {
+ pp.dirtab = hashalloc(REFONE, HASH_name, "directives", 0);
+ inithash(pp.dirtab, directives);
+ }
+ if (!pp.filtab)
+ pp.filtab = hashalloc(REFALL, HASH_name, "files", 0);
+ if (!pp.prdtab)
+ pp.prdtab = hashalloc(REFALL, HASH_name, "predicates", 0);
+ if (!pp.strtab)
+ {
+ pp.strtab = hashalloc(REFALL, HASH_name, "strings", 0);
+ inithash(pp.strtab, options);
+ inithash(pp.strtab, predicates);
+ inithash(pp.strtab, variables);
+ }
+ pp.optflags[X_PROTOTYPED] = OPT_GLOBAL;
+ pp.optflags[X_SYSTEM_HEADER] = OPT_GLOBAL|OPT_PASS;
+
+ /*
+ * mark macros that are builtin predicates
+ */
+
+ for (kp = predicates; s = kp->name; kp++)
+ {
+ if (!ppisid(*s))
+ s++;
+ ppassert(DEFINE, s, 0);
+ }
+
+ /*
+ * the remaining entry names must be allocated
+ */
+
+ hashset(pp.dirtab, HASH_ALLOCATE);
+ hashset(pp.filtab, HASH_ALLOCATE);
+ hashset(pp.prdtab, HASH_ALLOCATE);
+ hashset(pp.strtab, HASH_ALLOCATE);
+ hashset(pp.symtab, HASH_ALLOCATE);
+ if (pp.test & TEST_nonoise)
+ {
+ c = error_info.trace;
+ error_info.trace = 0;
+ }
+#if DEBUG
+ if (!(pp.test & TEST_noinit))
+ {
+#endif
+
+ /*
+ * compose, push and read the builtin initialization script
+ */
+
+ if (!(sp = sfstropen()))
+ error(3, "temporary buffer allocation error");
+ sfprintf(sp,
+"\
+#%s %s:%s \"/#<assert> /\" \"/assert /%s #/\"\n\
+#%s %s:%s \"/#<unassert> /\" \"/unassert /%s #/\"\n\
+",
+ dirname(PRAGMA),
+ pp.pass,
+ keyname(X_MAP),
+ dirname(DEFINE),
+ dirname(PRAGMA),
+ pp.pass,
+ keyname(X_MAP),
+ dirname(UNDEF));
+ if (pp.ppdefault && *pp.ppdefault)
+ {
+ if (pp.probe)
+ {
+ c = pp.lastdir->next->type;
+ pp.lastdir->next->type = 0;
+ }
+ if (ppsearch(pp.ppdefault, T_STRING, SEARCH_EXISTS) < 0)
+ {
+ free(pp.ppdefault);
+ if (!(pp.ppdefault = pathprobe(pp.path, NiL, "C", pp.pass, pp.probe ? pp.probe : PPPROBE, 0)))
+ error(1, "cannot determine default definitions for %s", pp.probe ? pp.probe : PPPROBE);
+ }
+ if (pp.ppdefault)
+ sfprintf(sp, "#%s \"%s\"\n", dirname(INCLUDE), pp.ppdefault);
+ if (pp.probe)
+ pp.lastdir->next->type = c;
+ }
+ while (pp.firstop)
+ {
+ switch (pp.firstop->op)
+ {
+ case PP_ASSERT:
+ sfprintf(sp, "#%s #%s\n", dirname(DEFINE), pp.firstop->value);
+ break;
+ case PP_DEFINE:
+ if (*pp.firstop->value == '#')
+ sfprintf(sp, "#%s %s\n", dirname(DEFINE), pp.firstop->value);
+ else
+ {
+ if (s = strchr(pp.firstop->value, '='))
+ sfprintf(sp, "#%s %-.*s %s\n", dirname(DEFINE), s - pp.firstop->value, pp.firstop->value, s + 1);
+ else
+ sfprintf(sp, "#%s %s 1\n", dirname(DEFINE), pp.firstop->value);
+ }
+ break;
+ case PP_DIRECTIVE:
+ sfprintf(sp, "#%s\n", pp.firstop->value);
+ break;
+ case PP_OPTION:
+ if (s = strchr(pp.firstop->value, '='))
+ sfprintf(sp, "#%s %s:%-.*s %s\n", dirname(PRAGMA), pp.pass, s - pp.firstop->value, pp.firstop->value, s + 1);
+ else
+ sfprintf(sp, "#%s %s:%s\n", dirname(PRAGMA), pp.pass, pp.firstop->value);
+ break;
+ case PP_READ:
+ sfprintf(sp, "#%s \"%s\"\n", dirname(INCLUDE), pp.firstop->value);
+ break;
+ case PP_UNDEF:
+ sfprintf(sp, "#%s %s\n", dirname(UNDEF), pp.firstop->value);
+ break;
+ }
+ pp.lastop = pp.firstop;
+ pp.firstop = pp.firstop->next;
+ free(pp.lastop);
+ }
+ sfprintf(sp,
+"\
+#%s %s:%s\n\
+#%s %s:%s\n\
+#%s !#%s(%s)\n\
+#%s !#%s(%s) || #%s(%s)\n\
+"
+ , dirname(PRAGMA)
+ , pp.pass
+ , keyname(X_BUILTIN)
+ , dirname(PRAGMA)
+ , pp.pass
+ , keyname(X_PREDEFINED)
+ , dirname(IF)
+ , keyname(X_OPTION)
+ , keyname(X_PLUSPLUS)
+ , dirname(IF)
+ , keyname(X_OPTION)
+ , keyname(X_COMPATIBILITY)
+ , keyname(X_OPTION)
+ , keyname(X_TRANSITION)
+ );
+ sfprintf(sp,
+"\
+#%s __STDC__\n\
+#%s __STDC__ #(STDC)\n\
+#%s\n\
+#%s #%s(%s)\n\
+#%s %s:%s\n\
+#%s %s:%s\n\
+#%s __STRICT__ 1\n\
+#%s\n\
+#%s\n\
+"
+ , dirname(IFNDEF)
+ , dirname(DEFINE)
+ , dirname(ENDIF)
+ , dirname(IF)
+ , keyname(X_OPTION)
+ , keyname(X_STRICT)
+ , dirname(PRAGMA)
+ , pp.pass
+ , keyname(X_ALLMULTIPLE)
+ , dirname(PRAGMA)
+ , pp.pass
+ , keyname(X_READONLY)
+ , dirname(DEFINE)
+ , dirname(ENDIF)
+ , dirname(ENDIF)
+ );
+ for (kp = readonlys; s = kp->name; kp++)
+ {
+ if (!ppisid(*s))
+ s++;
+ sfprintf(sp, "#%s %s\n", dirname(UNDEF), s);
+ }
+ sfprintf(sp,
+"\
+#%s\n\
+#%s __STDPP__ 1\n\
+#%s %s:no%s\n\
+"
+ , dirname(ENDIF)
+ , dirname(DEFINE)
+ , dirname(PRAGMA)
+ , pp.pass
+ , keyname(X_PREDEFINED)
+ );
+ if (!pp.truncate)
+ sfprintf(sp,
+"\
+#%s __STDPP__directive #(%s)\n\
+"
+ , dirname(DEFINE)
+ , keyname(V_DIRECTIVE)
+ );
+ for (kp = variables; s = kp->name; kp++)
+ if (ppisid(*s) || *s++ == '+')
+ {
+ t = *s == '_' ? "" : "__";
+ sfprintf(sp, "#%s %s%s%s #(%s)\n" , dirname(DEFINE), t, s, t, s);
+ }
+ sfprintf(sp,
+"\
+#%s %s:no%s\n\
+#%s %s:no%s\n\
+"
+ , dirname(PRAGMA)
+ , pp.pass
+ , keyname(X_READONLY)
+ , dirname(PRAGMA)
+ , pp.pass
+ , keyname(X_BUILTIN)
+ );
+ t = sfstruse(sp);
+ debug((-9, "\n/* begin initialization */\n%s/* end initialization */", t));
+ ppcomment = pp.comment;
+ pp.comment = 0;
+ pplinesync = pp.linesync;
+ pp.linesync = 0;
+ PUSH_INIT(pp.pass, t);
+ pp.mode |= INIT;
+ while (pplex());
+ pp.mode &= ~INIT;
+ pp.comment = ppcomment;
+ pp.linesync = pplinesync;
+ pp.prefix = 0;
+ sfstrclose(sp);
+ if (error_info.trace)
+ for (dp = pp.firstdir; dp; dp = dp->next)
+ message((-1, "include directory %s%s%s%s", dp->name, (dp->type & TYPE_VENDOR) ? " [VENDOR]" : "", (dp->type & TYPE_HOSTED) ? " [HOSTED]" : "", dp->c ? " [C]" : ""));
+#if DEBUG
+ }
+ if (pp.test & TEST_nonoise)
+ error_info.trace = c;
+#endif
+ {
+ /*
+ * this is sleazy but at least it's
+ * hidden in the library
+ */
+#include <preroot.h>
+#if FS_PREROOT
+ struct pplist* preroot;
+
+ if ((preroot = (struct pplist*)hashget(pp.prdtab, "preroot")))
+ setpreroot(NiL, preroot->value);
+#endif
+ }
+ if (pp.ignoresrc)
+ {
+ if (pp.ignoresrc > 1 && pp.stddirs != pp.firstdir)
+ error(1, "directories up to and including %s are for \"...\" include files only", pp.stddirs->name);
+ pp.lcldirs = pp.lcldirs->next;
+ }
+ if (pp.ignore)
+ {
+ if (*pp.ignore)
+ ppmapinclude(pp.ignore, NiL);
+ else
+ pp.ignore = 0;
+ }
+ if (pp.standalone)
+ pp.state |= STANDALONE;
+#if COMPATIBLE
+ ppfsm(FSM_COMPATIBILITY, NiL);
+#endif
+ ppfsm(FSM_PLUSPLUS, NiL);
+ pp.initialized = 1;
+ if (pp.reset.on)
+ {
+ pp.reset.symtab = pp.symtab;
+ pp.symtab = 0;
+ pp.reset.ro_state = pp.ro_state;
+ pp.reset.ro_mode = pp.ro_mode;
+ pp.reset.ro_option = pp.ro_option;
+ }
+ }
+ if (pp.reset.on)
+ {
+ if (pp.symtab)
+ {
+ hashwalk(pp.filtab, 0, unguard, NiL);
+ hashfree(pp.symtab);
+ }
+ pp.symtab = hashalloc(NiL, HASH_name, "symbols", HASH_free, undefine, HASH_set, HASH_ALLOCATE|HASH_BUCKET, 0);
+ hashview(pp.symtab, pp.reset.symtab);
+ pp.ro_state = pp.reset.ro_state;
+ pp.ro_mode = pp.reset.ro_mode;
+ pp.ro_option = pp.reset.ro_option;
+ }
+#if CHECKPOINT
+ if (pp.mode & DUMP)
+ {
+ if (!pp.pragma)
+ error(3, "#%s must be enabled for checkpoints", dirname(PRAGMA));
+ (*pp.pragma)(dirname(PRAGMA), pp.pass, keyname(X_CHECKPOINT), pp.checkpoint, 1);
+ }
+#endif
+ if (n = pp.filedeps.flags)
+ {
+ if (!(n & PP_deps_file))
+ {
+ pp.state |= NOTEXT;
+ pp.option |= KEEPNOTEXT;
+ pp.linesync = 0;
+ }
+ if (n & PP_deps_generated)
+ pp.mode |= GENDEPS;
+ if (n & PP_deps_local)
+ pp.mode &= ~HEADERDEPS;
+ else if (!(pp.mode & FILEDEPS))
+ pp.mode |= HEADERDEPS;
+ pp.mode |= FILEDEPS;
+ }
+
+ /*
+ * push the main input file -- special case for hosted mark
+ */
+
+ if (pp.firstdir->type & TYPE_HOSTED)
+ pp.mode |= MARKHOSTED;
+ else
+ pp.mode &= ~MARKHOSTED;
+#if CHECKPOINT
+ if (!(pp.mode & DUMP))
+#endif
+ {
+ if (!(p = error_info.file))
+ p = "";
+ else
+ {
+ error_info.file = 0;
+ if (*p)
+ {
+ pathcanon(p, 0);
+ p = ppsetfile(p)->name;
+ }
+ }
+ PUSH_FILE(p, 0);
+ }
+ if (pp.mode & FILEDEPS)
+ {
+ if (s = strrchr(error_info.file, '/'))
+ s++;
+ else
+ s = error_info.file;
+ if (!*s)
+ s = "-";
+ s = strcpy(pp.tmpbuf, s);
+ if ((t = p = strrchr(s, '.')) && (*++p == 'c' || *p == 'C'))
+ {
+ if (c = *++p)
+ while (*++p == c);
+ if (*p)
+ t = 0;
+ else
+ t++;
+ }
+ if (!t)
+ {
+ t = s + strlen(s);
+ *t++ = '.';
+ }
+ *(t + 1) = 0;
+ if (pp.state & NOTEXT)
+ pp.filedeps.sp = sfstdout;
+ else
+ {
+ *t = 'd';
+ if (!(pp.filedeps.sp = sfopen(NiL, s, "w")))
+ error(ERROR_SYSTEM|3, "%s: cannot create", s);
+ }
+ *t = 'o';
+ pp.column = sfprintf(pp.filedeps.sp, "%s :", s);
+ if (*error_info.file)
+ pp.column += sfprintf(pp.filedeps.sp, " %s", error_info.file);
+ }
+ if (xp = pp.firsttx)
+ {
+ if (!(sp = sfstropen()))
+ error(3, "temporary buffer allocation error");
+ while (xp)
+ {
+ sfprintf(sp, "#%s \"%s\"\n", dirname(INCLUDE), xp->value);
+ xp = xp->next;
+ }
+ t = sfstruse(sp);
+ PUSH_BUFFER("options", t, 1);
+ sfstrclose(sp);
+ }
+ break;
+ case PP_INPUT:
+#if CHECKPOINT && POOL
+ if (!(pp.mode & DUMP) || pp.pool.input)
+#else
+#if CHECKPOINT
+ if (!(pp.mode & DUMP))
+#else
+#if POOL
+ if (pp.pool.input)
+#endif
+#endif
+#endif
+ {
+ p = va_arg(ap, char*);
+ if (!error_info.file)
+ error_info.file = p;
+ close(0);
+ if (open(p, O_RDONLY) != 0)
+ error(ERROR_SYSTEM|3, "%s: cannot read", p);
+ if (strmatch(p, "*.(s|S|as|AS|asm|ASM)"))
+ {
+ set(&pp.mode, CATLITERAL, 0);
+ ppop(PP_SPACEOUT, 1);
+ }
+ break;
+ }
+ /*FALLTHROUGH*/
+ case PP_TEXT:
+ if (pp.initialized)
+ goto before;
+ if ((p = va_arg(ap, char*)) && *p)
+ {
+ if (pp.lasttx)
+ pp.lasttx = pp.lasttx->next = newof(0, struct oplist, 1, 0);
+ else
+ pp.firsttx = pp.lasttx = newof(0, struct oplist, 1, 0);
+ pp.lasttx->op = op;
+ pp.lasttx->value = p;
+ }
+ break;
+ case PP_KEYARGS:
+ if (pp.initialized)
+ goto before;
+ set(&pp.option, KEYARGS, va_arg(ap, int));
+ if (pp.option & KEYARGS)
+#if MACKEYARGS
+ set(&pp.mode, CATLITERAL, 1);
+#else
+ error(3, "preprocessor not compiled with macro keyword arguments enabled [MACKEYARGS]");
+#endif
+ break;
+ case PP_LINE:
+ pp.linesync = va_arg(ap, PPLINESYNC);
+ break;
+ case PP_LINEBASE:
+ if (va_arg(ap, int))
+ pp.flags |= PP_linebase;
+ else
+ pp.flags &= ~PP_linebase;
+ break;
+ case PP_LINEFILE:
+ if (va_arg(ap, int))
+ pp.flags |= PP_linefile;
+ else
+ pp.flags &= ~PP_linefile;
+ break;
+ case PP_LINEID:
+ if (!(p = va_arg(ap, char*)))
+ pp.lineid = "";
+ else if (*p != '-')
+ pp.lineid = strdup(p);
+ else
+ pp.option |= IGNORELINE;
+ break;
+ case PP_LINETYPE:
+ if ((n = va_arg(ap, int)) >= 1)
+ pp.flags |= PP_linetype;
+ else
+ pp.flags &= ~PP_linetype;
+ if (n >= 2)
+ pp.flags |= PP_linehosted;
+ else
+ pp.flags &= ~PP_linehosted;
+ break;
+ case PP_LOCAL:
+ if (pp.initialized)
+ goto before;
+ pp.ignoresrc++;
+ pp.stddirs = pp.lastdir;
+ if (!(pp.ro_option & PREFIX))
+ pp.option &= ~PREFIX;
+ break;
+ case PP_MACREF:
+ pp.macref = va_arg(ap, PPMACREF);
+ break;
+ case PP_MULTIPLE:
+ set(&pp.mode, ALLMULTIPLE, va_arg(ap, int));
+ break;
+ case PP_NOHASH:
+ set(&pp.option, NOHASH, va_arg(ap, int));
+ break;
+ case PP_NOISE:
+ op = va_arg(ap, int);
+ set(&pp.option, NOISE, op);
+ set(&pp.option, NOISEFILTER, op < 0);
+ break;
+ case PP_OPTARG:
+ pp.optarg = va_arg(ap, PPOPTARG);
+ break;
+ case PP_OUTPUT:
+ pp.outfile = va_arg(ap, char*);
+ if (identical(pp.outfile, 0))
+ error(3, "%s: identical to input", pp.outfile);
+ close(1);
+ if (open(pp.outfile, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) != 1)
+ error(ERROR_SYSTEM|3, "%s: cannot create", pp.outfile);
+ break;
+ case PP_PASSTHROUGH:
+ if (!(pp.state & COMPILE))
+ set(&pp.state, PASSTHROUGH, va_arg(ap, int));
+ break;
+ case PP_PEDANTIC:
+ set(&pp.mode, PEDANTIC, va_arg(ap, int));
+ break;
+ case PP_PLUSCOMMENT:
+ set(&pp.option, PLUSCOMMENT, va_arg(ap, int));
+ if (pp.initialized)
+ ppfsm(FSM_PLUSPLUS, NiL);
+ break;
+ case PP_PLUSPLUS:
+ set(&pp.option, PLUSPLUS, va_arg(ap, int));
+ set(&pp.option, PLUSCOMMENT, va_arg(ap, int));
+ if (pp.initialized)
+ ppfsm(FSM_PLUSPLUS, NiL);
+ break;
+ case PP_POOL:
+ if (pp.initialized)
+ goto before;
+ if (va_arg(ap, int))
+ {
+#if POOL
+ pp.pool.input = dup(0);
+ pp.pool.output = dup(1);
+ p = "/dev/null";
+ if (!identical(p, 0))
+ {
+ if (!identical(p, 1))
+ ppop(PP_OUTPUT, p);
+ ppop(PP_INPUT, p);
+ }
+#else
+ error(3, "preprocessor not compiled with input pool enabled [POOL]");
+#endif
+ }
+ break;
+ case PP_PRAGMA:
+ pp.pragma = va_arg(ap, PPPRAGMA);
+ break;
+ case PP_PRAGMAFLAGS:
+ if (p = va_arg(ap, char*))
+ {
+ n = OPT_GLOBAL;
+ if (*p == '-')
+ p++;
+ else
+ n |= OPT_PASS;
+ if ((c = (int)hashref(pp.strtab, p)) > 0 && c <= X_last_option)
+ pp.optflags[c] = n;
+ }
+ break;
+ case PP_PROBE:
+ pp.probe = va_arg(ap, char*);
+ break;
+ case PP_QUOTE:
+ p = va_arg(ap, char*);
+ c = va_arg(ap, int);
+ if (p)
+ ppfsm(c ? FSM_QUOTADD : FSM_QUOTDEL, p);
+ break;
+ case PP_REGUARD:
+ set(&pp.option, REGUARD, va_arg(ap, int));
+ break;
+ case PP_RESERVED:
+ if ((pp.state & COMPILE) && (p = va_arg(ap, char*)))
+ {
+ if (!(sp = sfstropen()))
+ error(3, "temporary buffer allocation error");
+ sfputr(sp, p, -1);
+ p = sfstruse(sp);
+ if (s = strchr(p, '='))
+ *s++ = 0;
+ else
+ s = p;
+ while (*s == '_')
+ s++;
+ for (t = s + strlen(s); t > s && *(t - 1) == '_'; t--);
+ if (*t == '_')
+ *t = 0;
+ else
+ t = 0;
+ op = ((key = ppkeyref(pp.symtab, s)) && (key->sym.flags & SYM_LEX)) ? key->lex : T_NOISE;
+ if (pp.test & 0x0400)
+ error(1, "reserved#1 `%s' %d", s, op);
+ if (t)
+ *t = '_';
+ if (!(key = ppkeyget(pp.symtab, p)))
+ key = ppkeyset(pp.symtab, NiL);
+ else if (!(key->sym.flags & SYM_LEX))
+ {
+ struct ppsymbol tmp;
+
+ tmp = key->sym;
+ hashlook(pp.symtab, p, HASH_DELETE, NiL);
+ key = ppkeyset(pp.symtab, NiL);
+ key->sym.flags = tmp.flags;
+ key->sym.macro = tmp.macro;
+ key->sym.value = tmp.value;
+ key->sym.hidden = tmp.hidden;
+ }
+ if (!(key->sym.flags & SYM_KEYWORD))
+ {
+ key->sym.flags |= SYM_KEYWORD|SYM_LEX;
+ key->lex = op;
+ if (pp.test & 0x0400)
+ error(1, "reserved#2 `%s' %d", p, op);
+ }
+ sfstrclose(sp);
+ }
+ break;
+ case PP_SPACEOUT:
+ set(&pp.state, SPACEOUT, va_arg(ap, int));
+ break;
+ case PP_STANDALONE:
+ if (pp.initialized)
+ goto before;
+ pp.standalone = 1;
+ break;
+ case PP_STANDARD:
+ if ((pp.lastdir->next->name = ((p = va_arg(ap, char*)) && *p) ? p : NiL) && !stat(p, &st))
+ SAVEID(&pp.lastdir->next->id, &st);
+ for (dp = pp.firstdir; dp; dp = dp->next)
+ if (dp->name)
+ for (hp = pp.firstdir; hp != dp; hp = hp->next)
+ if (hp->name && SAMEID(&hp->id, &dp->id))
+ {
+ hp->c = dp->c;
+ if (dp->type & TYPE_HOSTED)
+ hp->type |= TYPE_HOSTED;
+ else
+ hp->type &= ~TYPE_HOSTED;
+ }
+ break;
+ case PP_STRICT:
+ set(&pp.state, TRANSITION, 0);
+ pp.flags &= ~PP_transition;
+ set(&pp.state, STRICT, va_arg(ap, int));
+ if (pp.state & STRICT)
+ pp.flags |= PP_strict;
+ else
+ pp.flags &= ~PP_strict;
+ break;
+ case PP_TEST:
+ if (p = va_arg(ap, char*))
+ for (;;)
+ {
+ while (*p == ' ' || *p == '\t') p++;
+ for (s = p; n = *s; s++)
+ if (n == ',' || n == ' ' || n == '\t')
+ {
+ *s++ = 0;
+ break;
+ }
+ if (!*p)
+ break;
+ n = 0;
+ if (*p == 'n' && *(p + 1) == 'o')
+ {
+ p += 2;
+ op = 0;
+ }
+ else
+ op = 1;
+ if (streq(p, "count"))
+ n = TEST_count;
+ else if (streq(p, "hashcount"))
+ n = TEST_hashcount;
+ else if (streq(p, "hashdump"))
+ n = TEST_hashdump;
+ else if (streq(p, "hit"))
+ n = TEST_hit;
+ else if (streq(p, "init"))
+ n = TEST_noinit|TEST_INVERT;
+ else if (streq(p, "noise"))
+ n = TEST_nonoise|TEST_INVERT;
+ else if (streq(p, "proto"))
+ n = TEST_noproto|TEST_INVERT;
+ else if (*p >= '0' && *p <= '9')
+ n = strtoul(p, NiL, 0);
+ else
+ {
+ error(1, "%s: unknown test", p);
+ break;
+ }
+ if (n & TEST_INVERT)
+ {
+ n &= ~TEST_INVERT;
+ op = !op;
+ }
+ if (op)
+ pp.test |= n;
+ else
+ pp.test &= ~n;
+ p = s;
+ debug((-4, "test = 0%o", pp.test));
+ }
+ break;
+ case PP_TRANSITION:
+ set(&pp.state, STRICT, 0);
+ pp.flags &= ~PP_strict;
+ set(&pp.state, TRANSITION, va_arg(ap, int));
+ if (pp.state & TRANSITION)
+ pp.flags |= PP_transition;
+ else
+ pp.flags &= ~PP_transition;
+ break;
+ case PP_TRUNCATE:
+ if (pp.initialized)
+ goto before;
+ if ((op = va_arg(ap, int)) < 0)
+ op = 0;
+ set(&pp.option, TRUNCATE, op);
+ if (pp.option & TRUNCATE)
+ {
+ Hash_bucket_t* b;
+ Hash_bucket_t* p;
+ Hash_position_t* pos;
+ Hash_table_t* tab;
+
+ pp.truncate = op;
+ tab = pp.symtab;
+ pp.symtab = hashalloc(NiL, HASH_set, tab ? HASH_ALLOCATE : 0, HASH_compare, trunccomp, HASH_hash, trunchash, HASH_name, "truncate", 0);
+ if (tab && (pos = hashscan(tab, 0)))
+ {
+ if (p = hashnext(pos))
+ do
+ {
+ b = hashnext(pos);
+ hashlook(pp.symtab, (char*)p, HASH_BUCKET|HASH_INSTALL, NiL);
+ } while (p = b);
+ hashdone(pos);
+ }
+ }
+ else
+ pp.truncate = 0;
+ break;
+ case PP_VENDOR:
+ p = va_arg(ap, char*);
+ c = va_arg(ap, int) != 0;
+ if (!p || !*p)
+ for (dp = pp.firstdir; dp; dp = dp->next)
+ dp->type &= ~TYPE_VENDOR;
+ else if (streq(p, "-"))
+ {
+ for (dp = pp.firstdir; dp; dp = dp->next)
+ if (c)
+ dp->type |= TYPE_VENDOR;
+ else
+ dp->type &= ~TYPE_VENDOR;
+ }
+ else if (!stat((pathcanon(p, 0), p), &st))
+ {
+ c = 0;
+ for (dp = pp.firstdir; dp; dp = dp->next)
+ {
+ if (!c && ((dp->type & TYPE_VENDOR) || dp->name && SAMEID(&dp->id, &st)))
+ c = 1;
+ if (c)
+ dp->type |= TYPE_VENDOR;
+ else
+ dp->type &= ~TYPE_VENDOR;
+ }
+ }
+ break;
+ case PP_WARN:
+ set(&pp.state, WARN, va_arg(ap, int));
+ break;
+ before:
+ error(3, "ppop(%d): preprocessor operation must be done before PP_INIT", op);
+ break;
+ default:
+ error(3, "ppop(%d): invalid preprocessor operation", op);
+ break;
+ }
+ va_end(ap);
+}
diff --git a/usr/src/lib/libpp/common/pppragma.c b/usr/src/lib/libpp/common/pppragma.c
new file mode 100644
index 0000000000..875a17e5eb
--- /dev/null
+++ b/usr/src/lib/libpp/common/pppragma.c
@@ -0,0 +1,66 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * common preprocessor pragma handler
+ */
+
+#include "pplib.h"
+
+void
+pppragma(char* directive, char* pass, char* name, char* value, int newline)
+{
+ register int sep = 0;
+
+ ppsync();
+ if (directive)
+ {
+ ppprintf("#%s", directive);
+ sep = 1;
+ }
+ if (pass)
+ {
+ if (sep)
+ {
+ sep = 0;
+ ppprintf(" ");
+ }
+ ppprintf("%s:", pass);
+ }
+ if (name)
+ {
+ if (sep)
+ ppprintf(" ");
+ else
+ sep = 1;
+ ppprintf("%s", name);
+ }
+ if (value)
+ {
+ if (sep || pass)
+ ppprintf(" ");
+ ppprintf("%s", value);
+ }
+ if (newline)
+ ppprintf("\n");
+}
diff --git a/usr/src/lib/libpp/common/ppprintf.c b/usr/src/lib/libpp/common/ppprintf.c
new file mode 100644
index 0000000000..b8c6c77a07
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppprintf.c
@@ -0,0 +1,45 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * preprocessor printf using ppputchar() buffering
+ */
+
+#include "pplib.h"
+
+int
+ppprintf(char* format, ...)
+{
+ va_list ap;
+ Sfio_t* sp;
+
+ if (!(sp = sfnew(NiL, pp.outp, MAXTOKEN, -1, SF_WRITE|SF_STRING)))
+ error(3, "temporary buffer allocation error");
+ va_start(ap, format);
+ sfvprintf(sp, format, ap);
+ va_end(ap);
+ pp.outp += sfseek(sp, 0L, SEEK_CUR);
+ ppcheckout();
+ sfclose(sp);
+ return 0;
+}
diff --git a/usr/src/lib/libpp/common/ppproto.c b/usr/src/lib/libpp/common/ppproto.c
new file mode 100644
index 0000000000..f03b2535bc
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppproto.c
@@ -0,0 +1,2549 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * convert C prototypes to ANSI, K&R and C++ styles or K&R to ANSI
+ * slips into the pp block read
+ *
+ * define PROTOMAIN for standalone proto
+ * PROTOMAIN is coded for minimal library support
+ */
+
+static const char id[] = "\n@(#)$Id: proto (AT&T Research) 2006-06-28 $\0\n";
+
+#if PROTOMAIN
+
+#include "ppfsm.c"
+
+#include <hashkey.h>
+
+#if PROTO_STANDALONE
+#undef O_RDONLY
+#endif
+
+#else
+
+#include "pplib.h"
+#include "ppfsm.h"
+
+#endif
+
+#define MAGICGEN "/* : : generated by proto : : */\n"
+
+#define MAGICDIR "pragma" /* proto magic directive */
+#define MAGICARG "prototyped" /* proto magic directive arg */
+#define MAGICOFF "noticed" /* no notice if found in pragma */
+#define MAGICTOP 64 /* must be in these top lines */
+#define NOTICED "Copyright" /* no notice if found in magic */
+
+struct proto /* proto buffer state */
+{
+ int brace; /* {..} level */
+ int call; /* call level */
+ int fd; /* input file descriptor */
+ char* file; /* input file name */
+ long flags; /* coupled flags */
+ long options; /* uncoupled flags */
+ char* package; /* header package */
+ int line; /* input line count */
+ int test; /* testing */
+
+ char* tp; /* input token base */
+
+ int iz; /* input buffer size */
+ char* ib; /* input buffer base */
+ char* ip; /* input buffer pointer */
+
+ int oz; /* output buffer size */
+ char* ob; /* output buffer base */
+ char* op; /* output buffer pointer */
+ char* ox; /* output buffer externalize */
+
+ char cc[3]; /* beg mid end comment char */
+ char pushback[4]; /* pushback area for caller */
+
+ char variadic[256]; /* variadic args buffer */
+
+ /* output buffer */
+ /* slide buffer */
+ /* input buffer */
+};
+
+/*
+ * proto is separate from pp so these undef's are ok
+ */
+
+#undef CLASSIC
+#define CLASSIC (1L<<0)
+#undef DECLARE
+#define DECLARE (1L<<1)
+#undef DEFINE
+#define DEFINE (1L<<2)
+#undef DIRECTIVE
+#define DIRECTIVE (1L<<3)
+#undef ERROR
+#define ERROR (1L<<4)
+#undef EXTERN
+#define EXTERN (1L<<5)
+#undef EXTERNALIZE
+#define EXTERNALIZE (1L<<6)
+#undef IDID
+#define IDID (1L<<7)
+#undef INDIRECT
+#define INDIRECT (1L<<8)
+#undef INIT
+#define INIT (1L<<9)
+#undef INIT_DEFINE
+#define INIT_DEFINE (1L<<10)
+#undef INIT_INCLUDE
+#define INIT_INCLUDE (1L<<11)
+#undef JUNK
+#define JUNK (1L<<12)
+#undef LINESYNC
+#define LINESYNC (1L<<13)
+#undef MANGLE
+#define MANGLE (1L<<14)
+#undef MATCH
+#define MATCH (1L<<15)
+#undef MORE
+#define MORE (1L<<16)
+#undef OTHER
+#define OTHER (1L<<17)
+#undef PASS
+#define PASS (1L<<18)
+#undef PLUSONLY
+#define PLUSONLY (1L<<19)
+#undef PLUSPLUS
+#define PLUSPLUS (1L<<20)
+#undef RECURSIVE
+#define RECURSIVE (1L<<21)
+#undef SHARP
+#define SHARP (1L<<22)
+#undef SKIP
+#define SKIP (1L<<23)
+#undef SLIDE
+#define SLIDE (1L<<24)
+#undef TOKENS
+#define TOKENS (1L<<25)
+#undef TYPEDEF
+#define TYPEDEF (1L<<26)
+#undef VARIADIC
+#define VARIADIC (1L<<27)
+#undef VARIADIC2
+#define VARIADIC2 (1L<<28)
+#undef YACC
+#define YACC (1L<<29)
+#undef YACCSPLIT
+#define YACCSPLIT (1L<<30)
+#undef YACC2
+#define YACC2 (1L<<31)
+
+#undef GLOBAL
+#define GLOBAL (MORE)
+
+#undef REGULAR
+#define REGULAR (1L<<0)
+
+#ifndef CHUNK
+#define CHUNK 1024
+#endif
+#define BLOCK (8*CHUNK)
+
+#define T_VA_START (N_TOKEN+1)
+
+#define RESERVED(b,e,n) ((((long)(b))<<16)|(((long)(e))<<8)|((long)(n)))
+
+/*
+ * generate integer
+ * pointer to end returned
+ */
+
+static char*
+number(register char* p, register long n)
+{
+ register long d;
+
+ for (d = 1000000; d > 1; d /= 10)
+ if (n >= d) *p++ = '0' + (n / d) % 10;
+ *p++ = '0' + n % 10;
+ return p;
+}
+
+#if PROTOMAIN
+
+static int errors;
+
+#if PROTO_STANDALONE
+
+/*
+ * namespace pollution forces us to claim parts of libc
+ */
+
+#undef memcpy
+#define memcpy(t,f,n) memcopy(t,f,n)
+#undef strcpy
+#define strcpy(t,f) strcopy(t,f)
+#undef strlen
+#define strlen(s) sstrlen(s)
+#undef strncmp
+#define strncmp(s,t,n) sstrncmp(s,t,n)
+
+/*
+ * environmentally safe strlen()
+ */
+
+static int
+sstrlen(register const char* s)
+{
+ register const char* b;
+
+ for (b = s; *s; s++);
+ return s - b;
+}
+
+/*
+ * environmentally safe strncmp()
+ */
+
+static int
+sstrncmp(register const char* s, register char* t, register int n)
+{
+ register const char* e = s + n;
+
+ while (s < e)
+ {
+ if (*s != *t || !*s)
+ return *s - *t;
+ s++;
+ t++;
+ }
+ return 0;
+}
+
+/*
+ * strcpy() except pointer to end returned
+ */
+
+static char*
+strcopy(register char* s, register const char* t)
+{
+ while (*s++ = *t++);
+ return s - 1;
+}
+
+#endif
+
+static void
+proto_error(char* iob, int level, char* msg, char* arg)
+{
+ register char* p;
+ char buf[1024];
+
+ p = strcopy(buf, "proto: ");
+ if (iob)
+ {
+ register struct proto* proto = (struct proto*)(iob - sizeof(struct proto));
+
+ if (proto->line)
+ {
+ if (proto->file)
+ {
+ *p++ = '"';
+ p = strcopy(p, proto->file);
+ *p++ = '"';
+ *p++ = ',';
+ *p++ = ' ';
+ }
+ p = strcopy(p, "line ");
+ p = number(p, proto->line);
+ }
+ else if (proto->file)
+ p = strcopy(p, proto->file);
+ }
+ else
+ {
+ p = strcopy(p, msg);
+ msg = arg;
+ arg = 0;
+ }
+ if (*(p - 1) != ' ')
+ {
+ *p++ = ':';
+ *p++ = ' ';
+ }
+ if (level == 1)
+ p = strcopy(p, "warning: ");
+ p = strcopy(p, msg);
+ if (arg)
+ {
+ *p++ = ' ';
+ p = strcopy(p, arg);
+ }
+ *p++ = '\n';
+ write(2, buf, p - buf);
+ if (level >= 3)
+ exit(level - 2);
+ if (level >= 2)
+ errors++;
+}
+
+/*
+ * memcpy() but pointer to end returned
+ */
+
+static char*
+memcopy(register char* s, register char* t, int n)
+{
+ register char* e = t + n;
+
+ while (t < e) *s++ = *t++;
+ return s;
+}
+
+#include "../libast/port/astlicense.c"
+
+#else
+
+#define memcopy(s,t,n) (((char*)memcpy(s,t,n))+(n))
+
+#endif
+
+/*
+ * generate line sync
+ * pointer to end returned
+ */
+
+static char*
+linesync(register struct proto* proto, register char* p, register long n)
+{
+#if PROTOMAIN
+ if (proto->flags & LINESYNC)
+#endif
+ {
+#if PROTOMAIN
+ p = strcopy(p, "\n#line ");
+#else
+ p = strcopy(p, "\n# ");
+#endif
+ p = number(p, n);
+ *p++ = '\n';
+ }
+ return p;
+}
+
+/*
+ * output init header
+ * pointer to end returned
+ */
+
+static char*
+init(struct proto* proto, char* op, int flags)
+{
+ register char* s;
+
+ if (flags & INIT_DEFINE)
+ {
+ op = strcopy(op, "\
+\n\
+#if !defined(__PROTO__)\n\
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)\n\
+# if defined(__cplusplus)\n\
+# define __LINKAGE__ \"C\"\n\
+# else\n\
+# define __LINKAGE__\n\
+# endif\n\
+# define __STDARG__\n\
+# define __PROTO__(x) x\n\
+# define __OTORP__(x)\n\
+# define __PARAM__(n,o) n\n\
+# if !defined(__STDC__) && !defined(__cplusplus)\n\
+# if !defined(c_plusplus)\n\
+# define const\n\
+# endif\n\
+# define signed\n\
+# define void int\n\
+# define volatile\n\
+# define __V_ char\n\
+# else\n\
+# define __V_ void\n\
+# endif\n\
+# else\n\
+# define __PROTO__(x) ()\n\
+# define __OTORP__(x) x\n\
+# define __PARAM__(n,o) o\n\
+# define __LINKAGE__\n\
+# define __V_ char\n\
+# define const\n\
+# define signed\n\
+# define void int\n\
+# define volatile\n\
+# endif\n\
+# define __MANGLE__ __LINKAGE__\n\
+# if defined(__cplusplus) || defined(c_plusplus)\n\
+# define __VARARG__ ...\n\
+# else\n\
+# define __VARARG__\n\
+# endif\n\
+# if defined(__STDARG__)\n\
+# define __VA_START__(p,a) va_start(p,a)\n\
+# else\n\
+# define __VA_START__(p,a) va_start(p)\n\
+# endif\n\
+# if !defined(__INLINE__)\n\
+# if defined(__cplusplus)\n\
+# define __INLINE__ extern __MANGLE__ inline\n\
+# else\n\
+# if defined(_WIN32) && !defined(__GNUC__)\n\
+# define __INLINE__ __inline\n\
+# endif\n\
+# endif\n\
+# endif\n\
+#endif\n\
+#if !defined(__LINKAGE__)\n\
+#define __LINKAGE__ /* 2004-08-11 transition */\n\
+#endif\n\
+");
+ }
+ else
+ op = strcopy(op, "\
+\n\
+#if !defined(__PROTO__)\n\
+#include <prototyped.h>\n\
+#endif\n\
+#if !defined(__LINKAGE__)\n\
+#define __LINKAGE__ /* 2004-08-11 transition */\n\
+#endif\n\
+");
+ if (proto->package)
+ {
+ s = "\
+#ifndef __MANGLE_%_DATA__\n\
+# ifdef _BLD_%\n\
+# ifdef __EXPORT__\n\
+# define __MANGLE_%_DATA__ __MANGLE__ __EXPORT__\n\
+# else\n\
+# define __MANGLE_%_DATA__ __MANGLE__\n\
+# endif\n\
+# define __MANGLE_%_FUNC__ __MANGLE__\n\
+# else\n\
+# ifdef __IMPORT__\n\
+# define __MANGLE_%_DATA__ __MANGLE__ __IMPORT__\n\
+# else\n\
+# define __MANGLE_%_DATA__ __MANGLE__\n\
+# endif\n\
+# define __MANGLE_%_FUNC__ __MANGLE__\n\
+# endif\n\
+#endif\n\
+";
+ for (;;)
+ {
+ switch (*op++ = *s++)
+ {
+ case 0:
+ op--;
+ break;
+ case '%':
+ op = strcopy(op - 1, proto->package);
+ continue;
+ default:
+ continue;
+ }
+ break;
+ }
+ }
+ return op;
+}
+
+#define BACKOUT() (op=ko)
+#define CACHE() do{CACHEIN();CACHEOUT();call=proto->call;}while(0)
+#define CACHEIN() (ip=proto->ip)
+#define CACHEOUT() (op=proto->op)
+#define GETCHR() (*(unsigned char*)ip++)
+#define KEEPOUT() (ko=op)
+#define LASTOUT() (*(op-1))
+#define PUTCHR(c) (*op++=(c))
+#define SYNC() do{SYNCIN();SYNCOUT();proto->flags&=~(EXTERN|INIT|OTHER|VARIADIC|VARIADIC2);proto->flags|=flags&(EXTERN|INIT|OTHER|VARIADIC|VARIADIC2);proto->call=call;}while(0)
+#define SYNCIN() (proto->ip=ip)
+#define SYNCOUT() (proto->op=op)
+#define UNGETCHR() (ip--)
+#define UNPUTCHR() (op--)
+
+/*
+ * advance to the next non-space character
+ */
+
+static char*
+nns(register char* s)
+{
+ while (*s == ' ' || *s == '\t' || *s == '\n')
+ s++;
+ return s;
+}
+
+#define DIR_if 01
+#define DIR_el 02
+#define DIR_en 03
+#define DIR 03
+
+/*
+ * update directive mask
+ */
+
+static int
+directive(register char* s, int dir)
+{
+ switch (*(s = nns(s)))
+ {
+ case 'e':
+ case 'i':
+ dir <<= 2;
+ switch (*++s)
+ {
+ case 'f':
+ dir |= DIR_if;
+ break;
+ case 'l':
+ dir |= DIR_el;
+ break;
+ case 'n':
+ dir |= DIR_en;
+ break;
+ }
+ break;
+ }
+ return dir;
+}
+
+/*
+ * the tokenizer
+ * top level calls loop until EOB
+ * recursive calls just return the next token
+ */
+
+static int
+lex(register struct proto* proto, register long flags)
+{
+ register char* ip;
+ register char* op;
+ register int c;
+ register int state;
+ register short* rp;
+ char* m;
+ char* e;
+ char* t;
+ char* bp;
+ char* v;
+ char* im;
+ char* ko;
+ char* aom;
+ int n;
+ int line;
+ int quot;
+ int brack;
+ int sub;
+ int x;
+ int vc;
+
+ char* ie = 0;
+ char* om = 0;
+ char* aim = 0;
+ char* aie = 0;
+ char* func = 0;
+ int call = 0;
+ int dir = 0;
+ int group = 0;
+ int last = 0;
+ int paren = 0;
+#if PROTOMAIN
+ char* qe = 0;
+ int qn = 0;
+ int args = 0;
+#endif
+
+ CACHE();
+#if PROTOMAIN
+ if (flags & EXTERN) KEEPOUT();
+#endif
+ fsm_start:
+ proto->tp = ip;
+ state = PROTO;
+ bp = ip;
+ do
+ {
+ rp = fsm[state];
+ fsm_get:
+ while (!(state = rp[c = GETCHR()]));
+ fsm_next:
+ ;
+ } while (state > 0);
+ if ((n = ip - bp - 1) > 0)
+ {
+ ip = bp;
+ MEMCPY(op, ip, n);
+ ip++;
+ }
+ state = ~state;
+ fsm_terminal:
+ switch (TERM(state))
+ {
+ case S_CHR:
+ if (op > proto->ob && *(op - 1) == '=' && (op == proto->ob + 1 || *(op - 2) != '=')) switch (c)
+ {
+ case '+':
+ case '-':
+ case '*':
+ case '&':
+ PUTCHR(' ');
+ break;
+ }
+ PUTCHR(c);
+ break;
+
+ case S_CHRB:
+ UNGETCHR();
+ c = LASTOUT();
+ break;
+
+ case S_COMMENT:
+ switch (c)
+ {
+ case '\n':
+ if (INCOMMENTXX(rp)) goto fsm_newline;
+ PUTCHR(c);
+ proto->line++;
+ rp = fsm[COM2];
+ break;
+ case '/':
+#if PROTOMAIN
+ if ((flags & (EXTERN|MATCH)) == EXTERN) BACKOUT();
+ else
+#endif
+ PUTCHR(c);
+ if (INCOMMENTXX(rp))
+ {
+ rp = fsm[COM5];
+ break;
+ }
+ goto fsm_start;
+ case EOF:
+ break;
+ default:
+#if PROTOMAIN
+ if ((flags & (EXTERN|MATCH)) == EXTERN) BACKOUT();
+ else
+#endif
+ PUTCHR(c);
+ rp = fsm[INCOMMENTXX(rp) ? COM5 : COM3];
+ break;
+ }
+ bp = ip;
+ goto fsm_get;
+
+ case S_EOB:
+ if (c)
+ {
+ if (state = fsm[TERMINAL][INDEX(rp)+1])
+ goto fsm_terminal;
+ SYNC();
+ return 0;
+ }
+ UNGETCHR();
+ fsm_eob:
+ if ((flags & (DECLARE|GLOBAL|RECURSIVE)) == GLOBAL && (proto->flags & MORE))
+ {
+#if PROTOMAIN
+ if (!(flags & EXTERN)) /* XXX */
+#endif
+ flags |= SLIDE;
+ c = ip - proto->ib;
+ if (!(flags & MATCH))
+ im = proto->tp;
+ if (ip > proto->ib)
+ {
+ n = ip - im;
+ if (ip - n < proto->ib)
+ proto->flags |= ERROR;
+ memcopy(proto->ib - n, ip - n, n);
+ ip = proto->ib;
+ }
+ proto->tp -= c;
+ if (flags & MATCH)
+ {
+ im -= c;
+ ie -= c;
+ }
+ if (aim)
+ aim -= c;
+ if (aie)
+ aie -= c;
+ if ((n = read(proto->fd, ip, proto->iz)) > 0)
+ {
+ if ((proto->options & REGULAR) && n < proto->iz)
+ {
+ proto->flags &= ~MORE;
+ close(proto->fd);
+ }
+ *(ip + n) = 0;
+ if (state & SPLICE)
+ goto fsm_splice;
+ bp = ip;
+ goto fsm_get;
+ }
+ *ip = 0;
+ proto->flags &= ~MORE;
+ close(proto->fd);
+ }
+ if (state & SPLICE)
+ goto fsm_splice;
+ /* NOTE: RECURSIVE lex() should really SLIDE too */
+ if (!(flags & RECURSIVE) && (state = rp[c = EOF]))
+ {
+ bp = ip;
+ goto fsm_next;
+ }
+ SYNC();
+ return 0;
+
+ case S_LITBEG:
+ quot = c;
+#if PROTOMAIN
+ if (c == '"' && qe)
+ {
+ for (n = 0, t = qe + 1; t < op && (*t == ' ' || *t == '\t' || *t == '\n' && ++n || *t >= 'A' && *t <= 'Z' || *t == '_'); t++);
+ if (t == op)
+ {
+ op = qe;
+ qe = 0;
+ qn = n;
+ }
+ else PUTCHR(c);
+ }
+ else
+#endif
+ PUTCHR(c);
+ rp = fsm[LIT1];
+ bp = ip;
+ goto fsm_get;
+
+ case S_LITEND:
+ if (c == quot)
+ {
+#if PROTOMAIN
+ if (!(flags & DIRECTIVE))
+ qe = (c == '"') ? op : (char*)0;
+#endif
+ PUTCHR(c);
+#if PROTOMAIN
+ while (qn > 0)
+ {
+ qn--;
+ PUTCHR('\n');
+ }
+#endif
+ }
+ else if (c != '\n' && c != EOF)
+ {
+ PUTCHR(c);
+ bp = ip;
+ goto fsm_get;
+ }
+ else
+ {
+#if PROTOMAIN
+ while (qn > 0)
+ {
+ qn--;
+ PUTCHR('\n');
+ }
+#endif
+ UNGETCHR();
+ }
+ c = T_INVALID;
+ break;
+
+ case S_LITESC:
+#if PROTOMAIN
+ if (flags & CLASSIC) PUTCHR(c);
+ else
+#endif
+ switch (c)
+ {
+ case 'a':
+ n = CC_bel;
+ goto fsm_oct;
+ case 'E':
+ n = CC_esc;
+ goto fsm_oct;
+ case 'v':
+ n = CC_vt;
+ goto fsm_oct;
+ case 'x':
+ SYNC();
+ lex(proto, (flags & GLOBAL) | RECURSIVE);
+ for (n = x = 0; (c = GETCHR()), x < 3; x++) switch (c)
+ {
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ case '8': case '9':
+ n = (n << 4) + c - '0';
+ break;
+ case 'a': case 'b': case 'c': case 'd':
+ case 'e': case 'f':
+ n = (n << 4) + c - 'a' + 10;
+ break;
+ case 'A': case 'B': case 'C': case 'D':
+ case 'E': case 'F':
+ n = (n << 4) + c - 'A' + 10;
+ break;
+ default:
+ goto fsm_hex;
+ }
+ fsm_hex:
+ UNGETCHR();
+ fsm_oct:
+ PUTCHR(((n >> 6) & 07) + '0');
+ PUTCHR(((n >> 3) & 07) + '0');
+ PUTCHR((n & 07) + '0');
+ break;
+ default:
+ PUTCHR(c);
+ break;
+ }
+ rp = fsm[LIT1];
+ bp = ip;
+ goto fsm_get;
+
+ case S_MACRO:
+ UNGETCHR();
+#if PROTOMAIN
+ if ((flags & EXTERN) && *proto->tp == 's' && !strncmp(proto->tp, "static", 6))
+ {
+ c = T_EXTERN;
+ break;
+ }
+#endif
+ if (*proto->tp == '_' && !strncmp(proto->tp, "__STDPP__directive", 6)) c = '#';
+ else c = T_ID;
+
+ break;
+
+ case S_NL:
+ fsm_newline:
+ proto->line++;
+#if PROTOMAIN
+ if (flags & EXTERN)
+ {
+ if (op != proto->ob && LASTOUT() != ' ' && LASTOUT() != '\n')
+ PUTCHR(' ');
+ }
+ else
+#endif
+ PUTCHR(c);
+ if (flags & DIRECTIVE)
+ {
+#if PROTOMAIN
+ if (flags & CLASSIC)
+ {
+ if (flags & EXTERN) BACKOUT();
+ if (flags & JUNK)
+ {
+ *(ip - 1) = 0;
+ op = strcopy(om, "/* ");
+ op = strcopy(op, im);
+ op = strcopy(op, " */\n");
+ }
+ flags &= ~(DEFINE|DIRECTIVE|IDID|INDIRECT|JUNK|MATCH|SHARP|TYPEDEF);
+ }
+ else
+#endif
+ {
+ if ((flags & (DEFINE|SHARP)) == (DEFINE|SHARP))
+ {
+ *(ip - 1) = 0;
+ op = strcopy(om, "#if defined(__STDC__) || defined(__STDPP__)\n");
+ op = strcopy(op, im);
+ op = strcopy(op, "\n#else\n");
+ bp = ip;
+ ip = im;
+ *op++ = *ip++;
+ while (*op = *ip++)
+ if (*op++ == '#' && *ip != '(')
+ {
+ op--;
+ while (*--op == ' ' || *op == '\t');
+ if (*ip == '#')
+ {
+ op = strcopy(op + 1, "/**/");
+ while (*++ip == ' ' || *ip == '\t');
+ }
+ else
+ {
+ if (*op != '"') *++op = '"';
+ op++;
+ while (*ip == ' ' || *ip == '\t') ip++;
+ while ((c = *ip) >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '0' && c <= '9' || c == '_') *op++ = *ip++;
+ while (*ip == ' ' || *ip == '\t') ip++;
+ if (*ip == '"') ip++;
+ else *op++ = '"';
+ }
+ }
+ ip = bp;
+ op = strcopy(op, "\n#endif\n");
+ op = linesync(proto, op, proto->line);
+ }
+ flags &= ~(DEFINE|DIRECTIVE|IDID|INDIRECT|MATCH|OTHER|SHARP|SKIP|TOKENS|TYPEDEF);
+ }
+ call = 0;
+ group = 0;
+ paren = 0;
+ last = '\n';
+ }
+ if (paren == 0 && (flags & (MATCH|RECURSIVE|SKIP|SLIDE)) == SLIDE)
+ {
+#if PROTOMAIN
+ if (flags & EXTERN) BACKOUT();
+#endif
+ SYNC();
+ return 0;
+ }
+ goto fsm_start;
+
+ case S_QUAL:
+ PUTCHR(c);
+ rp = fsm[NEXT(state)];
+ bp = ip;
+ goto fsm_get;
+
+ case S_TOK:
+ PUTCHR(c);
+ c = TYPE(state);
+ break;
+
+ case S_TOKB:
+ UNGETCHR();
+ c = TYPE(state);
+ break;
+
+ case S_RESERVED:
+ UNGETCHR();
+ c = T_ID;
+ if (!(flags & DECLARE)) switch (RESERVED(*proto->tp, *(ip - 1), ip - proto->tp))
+ {
+ case RESERVED('N', 'N', 3):
+ if (proto->tp[1] == 'o')
+ c = T_DO;
+ break;
+ case RESERVED('d', 'o', 2):
+ c = T_DO;
+ break;
+ case RESERVED('e', 'e', 4):
+ if (!(flags & RECURSIVE) && (flags & (DIRECTIVE|TOKENS)) != DIRECTIVE && !strncmp(proto->tp, "else", 4))
+ {
+ c = T_ELSE;
+ goto fsm_id;
+ }
+ break;
+ case RESERVED('e', 'n', 6):
+ if (!strncmp(proto->tp, "extern", 6))
+ c = T_EXTERN;
+ break;
+ case RESERVED('f', 'r', 3):
+ if (!(flags & RECURSIVE) && !strncmp(proto->tp, "for", 3))
+ {
+ c = T_FOR;
+ goto fsm_id;
+ }
+ break;
+ case RESERVED('i', 'f', 2):
+ c = T_IF;
+ break;
+ case RESERVED('i', 'e', 6):
+ if (!strncmp(proto->tp, "inline", 6) && !(flags & (MATCH|SKIP|TOKENS|TYPEDEF)) && proto->brace == 0 && paren == 0 && group == 0 && (last == ';' || last == '}' || last == '\n' || last == 0))
+ {
+ flags |= SKIP;
+ SYNC();
+ line = proto->line;
+ op = strcopy(op - 6, "__INLINE__");
+ SYNC();
+ }
+ break;
+ case RESERVED('r', 'n', 6):
+ if (!(flags & RECURSIVE) && !strncmp(proto->tp, "return", 6))
+ {
+ c = T_RETURN;
+ goto fsm_id;
+ }
+ break;
+ case RESERVED('s', 'c', 6):
+ if ((proto->options & EXTERNALIZE) && !strncmp(proto->tp, "static", 6))
+ {
+ proto->ox = op - 6;
+ flags |= EXTERNALIZE;
+ }
+ break;
+ case RESERVED('t', 'f', 7):
+ if (!(flags & RECURSIVE) && !strncmp(proto->tp, "typedef", 7))
+ {
+ flags |= TYPEDEF;
+ c = T_EXTERN;
+ }
+ break;
+ case RESERVED('v', 't', 8):
+ if (*ip == '(' && !strncmp(proto->tp, "va_start", 8)) c = T_VA_START;
+ break;
+ case RESERVED('v', 'd', 4):
+ if (!strncmp(proto->tp, "void", 4))
+ {
+ if (flags & (CLASSIC|PLUSONLY|INIT_DEFINE|INIT_INCLUDE)) c = T_VOID;
+ else
+ {
+ SYNC();
+ line = proto->line;
+ if (lex(proto, (flags & GLOBAL) | RECURSIVE) == '*')
+ {
+ memcopy(op - 4, "__V_", 4);
+ memcopy(ip - 4, "__V_", 4);
+ }
+ else c = T_VOID;
+ proto->line = line;
+ SYNC();
+ bp = ip;
+ }
+ }
+ break;
+ case RESERVED('w', 'e', 5):
+ if (!(flags & RECURSIVE) && !strncmp(proto->tp, "while", 5))
+ {
+ c = T_WHILE;
+ goto fsm_id;
+ }
+ break;
+ }
+#if PROTOMAIN
+ if ((flags & CLASSIC) && c != T_EXTERN)
+ c = T_ID;
+#endif
+ break;
+
+ case S_VS:
+ goto fsm_start;
+
+ case S_WS:
+ UNGETCHR();
+#if PROTOMAIN
+ if ((flags & (EXTERN|MATCH)) == EXTERN)
+ {
+ while (op > proto->ob && (*(op - 1) == ' ' || *(op - 1) == '\t'))
+ op--;
+ if (op > proto->ob && *(op - 1) != '\n') *op++ = ' ';
+ }
+#endif
+ goto fsm_start;
+
+ default:
+ if (state & SPLICE)
+ {
+ if (c == '\\')
+ {
+ if (!(n = GETCHR()))
+ {
+ goto fsm_eob;
+ fsm_splice:
+ c = '\\';
+ n = GETCHR();
+ }
+ if (n == '\n')
+ {
+ proto->line++;
+ PUTCHR('\\');
+ PUTCHR('\n');
+ bp = ip;
+ goto fsm_get;
+ }
+ UNGETCHR();
+ }
+ state &= ~SPLICE;
+ if (state >= TERMINAL)
+ goto fsm_terminal;
+ rp = fsm[state];
+ }
+ PUTCHR(c);
+ bp = ip;
+ goto fsm_get;
+ }
+ if (!(flags & (INIT_DEFINE|INIT_INCLUDE|RECURSIVE)))
+ {
+ if (!(flags & DIRECTIVE)) switch (c)
+ {
+ case '(':
+#if PROTOMAIN
+ if (!(flags & CLASSIC) || proto->brace == 0)
+#endif
+ {
+ if (paren++ == 0)
+ {
+#if PROTOMAIN
+ if (!(flags & CLASSIC) || group <= 1)
+#endif
+ {
+#if PROTOMAIN
+ args = 0;
+#endif
+ if (group++ == 0) group++;
+ else if (flags & INDIRECT) call++;
+ flags |= MATCH;
+ im = ip - 1;
+ om = op - 1;
+ }
+ sub = 0;
+ }
+ else if (paren == 2 && !aim)
+ {
+ sub++;
+ if (last == '(')
+ {
+ flags &= ~MATCH;
+ om = 0;
+ }
+ else if (flags & INDIRECT)
+ {
+ aim = ip - 1;
+ aom = op - 1;
+ }
+ else if ((flags & (MATCH|TOKENS)) == MATCH)
+ {
+ for (m = ip - 2; m > im && (*m == ' ' || *m == '\t'); m--);
+ if (m != im && sub == 1)
+ {
+ m = im + (*nns(ip) == '*');
+ }
+ if (m == im)
+ {
+ flags &= ~MATCH;
+ om = 0;
+ }
+ }
+ else if ((flags & MATCH) && sub == 1 && *nns(ip) != '*')
+ {
+ flags &= ~MATCH;
+ om = 0;
+ }
+ }
+ flags &= ~TOKENS;
+ }
+ break;
+ case ')':
+#if PROTOMAIN
+ if (!(flags & CLASSIC) || proto->brace == 0)
+#endif
+ if (--paren == 0)
+ {
+#if PROTOMAIN
+ if (flags & CLASSIC)
+ {
+ if (group != 2)
+ {
+ c = T_ID;
+ break;
+ }
+ group++;
+ }
+#endif
+ ie = ip;
+ }
+ else if (paren == 1 && (flags & INDIRECT) && !aie)
+ aie = ip;
+ break;
+ case '*':
+ if (last == '(' && group == 2)
+ {
+ group--;
+ if (paren == 1)
+ {
+ flags |= INDIRECT;
+ aim = aie = 0;
+ }
+ }
+ break;
+ case '#':
+ dir = directive(ip, dir);
+ if (proto->brace == 0 && paren == 0 && last != '=' && (flags & (CLASSIC|DECLARE|DIRECTIVE|MATCH|PLUSONLY|SKIP|TOKENS)) == (MATCH|TOKENS) && ((dir & DIR) != DIR_en || ((dir>>2) & DIR) != DIR_if))
+ flags |= DIRECTIVE;
+ else if (!(flags & (DECLARE|DIRECTIVE)))
+ {
+ flags |= DIRECTIVE;
+ if (!(flags & PLUSONLY))
+ {
+ bp = ip;
+ while (*ip == ' ' || *ip == '\t') ip++;
+ if (*ip == 'l' && *++ip == 'i' && *++ip == 'n' && *++ip == 'e')
+ {
+ if (*++ip == ' ' || *ip == '\t')
+ {
+ proto->line = 0;
+ while (*++ip >= '0' && *ip <= '9')
+ proto->line = proto->line * 10 + *ip - '0';
+ proto->line--;
+ }
+ }
+#if PROTOMAIN
+ else if ((flags & (CLASSIC|EXTERN)) == CLASSIC)
+ {
+ n = 0;
+ t = ip + 6;
+ while (ip < t && *ip >= 'a' && *ip <= 'z')
+ n = HASHKEYPART(n, *ip++);
+ switch (n)
+ {
+ case HASHKEY4('e','l','s','e'):
+ case HASHKEY5('e','n','d','i','f'):
+ while (*ip == ' ' || *ip == '\t') ip++;
+ if (*ip != '\n' && *ip != '/' && *(ip + 1) != '*')
+ {
+ flags |= JUNK|MATCH;
+ im = ip;
+ om = op + (ip - bp);
+ }
+ break;
+ case HASHKEY4('e','l','i','f'):
+ case HASHKEY5('e','r','r','o','r'):
+ case HASHKEY2('i','f'):
+ case HASHKEY5('i','f','d','e','f'):
+ case HASHKEY6('i','f','n','d','e','f'):
+ case HASHKEY5('u','n','d','e','f'):
+ break;
+ case HASHKEY6('i','n','c','l','u','d'):
+ if (*ip == 'e') ip++;
+ /*FALLTHROUGH*/
+ case HASHKEY6('d','e','f','i','n','e'):
+ case HASHKEY6('p','r','a','g','m','a'):
+ if (*ip < 'a' || *ip > 'z') break;
+ /*FALLTHROUGH*/
+ default:
+ flags |= JUNK|MATCH;
+ im = bp - 1;
+ om = op - 1;
+ break;
+ }
+ }
+ else
+#endif
+ {
+ if (*ip == 'i' && *++ip == 'n' && *++ip == 'c' && *++ip == 'l' && *++ip == 'u' && *++ip == 'd' && *++ip == 'e')
+ {
+ while (*++ip == ' ' || *ip == '\t');
+ if (*ip++ == '<' && *ip++ == 's' && *ip++ == 't' && *ip++ == 'd' && *ip++ == 'a' && *ip++ == 'r' && *ip++ == 'g' && *ip++ == '.' && *ip++ == 'h' && *ip++ == '>')
+ {
+ op = strcopy(op, "\
+if !defined(va_start)\n\
+#if defined(__STDARG__)\n\
+#include <stdarg.h>\n\
+#else\n\
+#include <varargs.h>\n\
+#endif\n\
+#endif\n\
+");
+ op = linesync(proto, op, proto->line);
+ break;
+ }
+ }
+ else if (*ip == 'd' && *++ip == 'e' && *++ ip == 'f' && *++ip == 'i' && *++ip == 'n' && *++ip == 'e' && (*++ip == ' ' || *ip == '\t'))
+ {
+ while (*++ip == ' ' || *ip == '\t');
+ if (*ip == 'e' && *++ip == 'x' && *++ ip == 't' && *++ip == 'e' && *++ip == 'r' && *++ip == 'n' && (*++ip == ' ' || *ip == '\t'))
+ {
+ t = ip;
+ while (*++t == ' ' || *t == '\t');
+ if (*t == 'e' && *++t == 'x' && *++ t == 't' && *++t == 'e' && *++t == 'r' && *++t == 'n' && (*++t == ' ' || *t == '\t' || *t == '\n' || *t == '\r'))
+ ip = t;
+ t = ip;
+ while (*++t == ' ' || *t == '\t');
+ if (*t == '_' && *(t + 1) == '_')
+ {
+ op = strcopy(op, "undef __MANGLE__\n");
+ op = linesync(proto, op, proto->line);
+ op = strcopy(op, "#define __MANGLE__ __LINKAGE__");
+ break;
+ }
+ }
+ flags |= DEFINE|MATCH;
+ im = bp - 1;
+ om = op - 1;
+ }
+ else if (*ip == 'u' && *++ip == 'n' && *++ ip == 'd' && *++ip == 'e' && *++ip == 'f' && (*++ip == ' ' || *ip == '\t'))
+ {
+ while (*++ip == ' ' || *ip == '\t');
+ if (*ip == 'e' && *++ip == 'x' && *++ ip == 't' && *++ip == 'e' && *++ip == 'r' && *++ip == 'n' && (*++ip == ' ' || *ip == '\t' || *ip == '\n' || *ip == '\r'))
+ {
+ op = strcopy(op, "undef __MANGLE__\n");
+ op = linesync(proto, op, proto->line);
+ op = strcopy(op, "#define __MANGLE__ __LINKAGE__");
+ break;
+ }
+ flags |= DEFINE|MATCH;
+ im = bp - 1;
+ om = op - 1;
+ }
+ }
+ ip = bp;
+ }
+ break;
+ }
+ else
+ break;
+ /*FALLTHROUGH*/
+ case '{':
+ if (proto->brace++ == 0 && paren == 0)
+ {
+ if (last == '=') flags |= INIT;
+#if PROTOMAIN
+ else if (flags & CLASSIC)
+ {
+ if ((flags & (MATCH|OTHER|SKIP)) == MATCH)
+ {
+ if (args)
+ {
+ v = number(op, args < 0 ? -args : args);
+ v = strcopy(v, " argument actual/formal mismatch");
+ *v++ = ' ';
+ v = memcopy(v, im, ie - im);
+ *v = 0;
+ proto_error((char*)proto + sizeof(struct proto), 2, op, NiL);
+ }
+ ip--;
+ /*UNDENT...*/
+ v = ie;
+ while (ie < ip)
+ if (*ie++ == '/' && *ie == '*')
+ {
+ e = ie - 1;
+ while (++ie < ip)
+ {
+ if (*ie == '*')
+ {
+ while (ie < ip && *ie == '*') ie++;
+ if (ie < ip && *ie == '/')
+ {
+ while (++ie < ip && (*ie == ' ' || *ie == '\t'));
+ while (e > v && (*(e - 1) == ' ' || *(e - 1) == '\t')) e--;
+ if (e > v && *e != '\n') *e++ = ' ';
+ t = ie;
+ while (--e >= v)
+ *--t = *e;
+ v = t;
+ break;
+ }
+ }
+ }
+ }
+ ie = v;
+ /*...INDENT*/
+ op = om++;
+ if (flags & EXTERN)
+ {
+ v = op;
+ while (v > ko && *--v != ' ');
+ if (*v != ' ')
+ {
+ om = (v = (op += 4)) + 1;
+ while (v >= ko + 4)
+ {
+ *v = *(v - 4);
+ v--;
+ }
+ memcopy(ko, "int ", 4);
+ }
+ if (*v == ' ')
+ {
+ while (*(v + 1) == '*')
+ *v++ = '*';
+ *v = '\t';
+ if ((v - ko) <= 8)
+ {
+ om = (e = ++op) + 1;
+ while (e > v)
+ {
+ *e = *(e - 1);
+ e--;
+ }
+ }
+ }
+ om = (v = (op += 7)) + 1;
+ while (v >= ko + 7)
+ {
+ *v = *(v - 7);
+ v--;
+ }
+ memcopy(ko, "extern ", 7);
+ }
+ PUTCHR('(');
+ t = op;
+ e = 0;
+ /*UNDENT...*/
+ while (ie < ip)
+ {
+ if ((c = *ie) == ' ' || c == '\t' || c == '\n')
+ {
+ while ((c = *++ie) == ' ' || c == '\t' || c == '\n');
+ if (ie >= ip) break;
+ if (c != '*' && op > om) PUTCHR(' ');
+ }
+ if ((n = ((c = *ie) == ',')) || c == ';')
+ {
+ if (flags & EXTERN)
+ {
+ m = op;
+ while (op > om && ((c = *(op - 1)) == '(' || c == ')' || c == '[' || c == ']'))
+ op--;
+ v = op;
+ while (op > om && (c = *(op - 1)) != ' ' && c != '*')
+ op--;
+ while (*(op - 1) == ' ')
+ op--;
+ if (!e)
+ {
+ e = op;
+ while (e > om && *(e - 1) == '*')
+ e--;
+ }
+#if _s5r4_386_compiler_bug_fixed_
+ if (op <= om || *(op - 1) == ',' && (*op++ = ' '))
+ op = strcopy(op, "int");
+#else
+ if (op <= om)
+ op = strcopy(op, "int");
+ else if (*(op - 1) == ',')
+ op = strcopy(op, " int");
+#endif
+ while (v < m)
+ PUTCHR(*v++);
+ }
+ PUTCHR(',');
+ if (n)
+ {
+ if (x = !e) e = op - 1;
+ PUTCHR(' ');
+ m = t;
+ while (m < e)
+ PUTCHR(*m++);
+ if (x)
+ {
+ m = e;
+ while (*--e != ' ');
+ while (*(e - 1) == '*') e--;
+ op -= m - e;
+ }
+ }
+ while ((c = *++ie) == ' ' || c == '\t' || c == '\n');
+ if (ie >= ip) UNPUTCHR();
+ else PUTCHR(' ');
+ if (!n)
+ {
+ t = op;
+ e = 0;
+ }
+ }
+ else if (*ie == '*')
+ {
+ if (op > om && (c = *(op - 1)) == ' ') op--;
+ while (*ie == '*') PUTCHR(*ie++);
+ while (*ie == ' ' || *ie == '\t' || *ie == '\n') ie++;
+ if (c != '(') PUTCHR(' ');
+ }
+ else if (*ie == '(')
+ {
+ if (op > om && *(op - 1) == ' ') op--;
+ PUTCHR(*ie++);
+ while (*ie == ' ' || *ie == '\t' || *ie == '\n') ie++;
+ }
+ else if (*ie == ')')
+ {
+ if (op > om && *(op - 1) == '(')
+ proto_error((char*)proto + sizeof(struct proto), 1, "function pointer argument prototype omitted", NiL);
+ PUTCHR(*ie++);
+ while (*ie == ' ' || *ie == '\t' || *ie == '\n') ie++;
+ }
+ else if ((flags & EXTERN) && (op == om || *(op - 1) == ' ') && *ie == 'r' && !strncmp(ie, "register", 8) && (*(ie + 8) == ' ' || *(ie + 8) == '\t' || *(ie + 8) == '\n'))
+ {
+ ie += 8;
+ if (op > om) UNPUTCHR();
+ }
+ else PUTCHR(*ie++);
+ }
+ /*...INDENT*/
+ if (op <= om) op = strcopy(op, "void");
+ PUTCHR(')');
+ if (flags & EXTERN)
+ {
+ PUTCHR(';');
+ PUTCHR('\n');
+ SYNCOUT();
+ KEEPOUT();
+ }
+ else
+ {
+ PUTCHR('\n');
+ PUTCHR(*ip);
+ }
+ ip++;
+ flags &= ~(MATCH|SKIP);
+ }
+ }
+#endif
+ else if ((flags & (MATCH|PLUSONLY|SKIP|TOKENS)) == (MATCH|TOKENS))
+ {
+ line = proto->line;
+ op = strcopy(om, " __PARAM__(");
+ op = memcopy(op, im, ie - im);
+ PUTCHR(',');
+ PUTCHR(' ');
+ PUTCHR('(');
+ flags &= ~(MATCH|SKIP);
+ if (flags & VARIADIC)
+ {
+ if ((vc = ie - im + 1) > sizeof(proto->variadic)) vc = sizeof(proto->variadic);
+ memcopy(proto->variadic, im, vc);
+ op = strcopy(op, "va_alist)) __OTORP__(va_dcl)\n{");
+ }
+ else
+ {
+ flags |= SKIP;
+ proto->ip = im;
+ proto->op = op;
+ group = 0;
+ brack = 0;
+ for (;;)
+ {
+ switch (lex(proto, (flags & GLOBAL) | RECURSIVE))
+ {
+ case '[':
+ brack++;
+ continue;
+ case ']':
+ brack--;
+ continue;
+ case '(':
+ if (paren++) group++;
+ continue;
+ case ')':
+ if (--paren == 0)
+ {
+ group = 0;
+ if (flags & MATCH)
+ {
+ flags &= ~(MATCH|SKIP);
+ op = memcopy(op, m, e - m);
+ }
+ break;
+ }
+ continue;
+ case ',':
+ if (paren == 1)
+ {
+ group = 0;
+ if (flags & MATCH)
+ {
+ flags &= ~(MATCH|SKIP);
+ op = memcopy(op, m, e - m);
+ }
+ PUTCHR(',');
+ PUTCHR(' ');
+ proto->op = op;
+ }
+ continue;
+ case T_ID:
+ if (group <= 1 && !brack)
+ {
+ flags |= MATCH;
+ m = proto->tp;
+ e = proto->ip;
+ }
+ continue;
+ default:
+ continue;
+ }
+ break;
+ }
+ PUTCHR(')');
+ PUTCHR(')');
+ }
+ if (!(flags & SKIP))
+ {
+ flags |= SKIP;
+ proto->op = strcopy(op, " __OTORP__(");
+ proto->ip = im + 1;
+ n = *(ie - 1);
+ *(ie - 1) = ';';
+ c = *ie;
+ *ie = 0;
+ lex(proto, (flags & GLOBAL) | DECLARE);
+ *(ie - 1) = n;
+ *ie = c;
+ proto->ip = ie;
+ op = proto->op;
+ PUTCHR(')');
+ }
+ if (flags & EXTERNALIZE) memcpy(proto->ox, "extern", 6);
+ op = linesync(proto, op, proto->line = line);
+ if (flags & DIRECTIVE)
+ {
+ proto->brace = 0;
+ PUTCHR('\n');
+ PUTCHR('#');
+ }
+ else if (!(flags & VARIADIC)) PUTCHR('{');
+ }
+ }
+ flags &= ~(IDID|INDIRECT|MATCH|OTHER|SKIP);
+ call = 0;
+ group = 0;
+ break;
+ case '}':
+ flags &= ~(IDID|INDIRECT|MATCH|OTHER|SKIP|TOKENS);
+ if (--proto->brace == 0)
+ {
+ flags &= ~(INIT|VARIADIC|VARIADIC2);
+#if PROTOMAIN
+ if (flags & EXTERN) BACKOUT();
+#endif
+ }
+ call = 0;
+ group = 0;
+ paren = 0;
+ break;
+ case '=':
+ if (last == '?') flags |= DIRECTIVE;
+ else if (paren == 0 && (flags & (INIT|MATCH|SKIP)) == MATCH) goto fsm_statement;
+ goto fsm_other;
+ case ',':
+#if PROTOMAIN
+ if (flags & CLASSIC)
+ {
+ if (paren == 1) args++;
+ else
+ {
+ args--;
+ flags &= ~MATCH;
+ }
+ break;
+ }
+#endif
+ if (paren == 0 && (flags & DECLARE)) *(op - 1) = c = ';';
+ /*FALLTHROUGH*/
+ case ';':
+ fsm_statement:
+ if (flags & INIT) /* ignore */;
+#if PROTOMAIN
+ else if (flags & CLASSIC)
+ {
+ if (paren == 0)
+ {
+ if ((flags & MATCH) && last == ')')
+ flags &= ~MATCH;
+ if (!(flags & MATCH))
+ {
+ call = 0;
+ group = 0;
+ flags &= ~SKIP;
+ if (flags & EXTERN) BACKOUT();
+ if (flags & SLIDE)
+ {
+ SYNC();
+ return 0;
+ }
+ }
+ else
+ {
+ args--;
+ if ((flags & (EXTERN|SKIP)) == (EXTERN|SKIP))
+ BACKOUT();
+ }
+ }
+ }
+#endif
+ else if (paren == 0)
+ {
+ if ((flags & (MATCH|OTHER|SKIP)) == MATCH && call > 1)
+ {
+ if ((flags & MANGLE) && func)
+ {
+ func[0] = 'F';
+ func[1] = 'U';
+ func[2] = 'N';
+ func[3] = 'C';
+ func = 0;
+ }
+ if ((flags & (DECLARE|INDIRECT)) == INDIRECT && aim && aie < im)
+ {
+ while (aie < ip && (*aie == ' ' || *aie == '\t' || *aie == '\n')) aie++;
+ v = aim;
+ while (v < aie)
+ if (*v++ == ')') break;
+ while (v < aie && (*v == ' ' || *v == '\t' || *v == '\n')) v++;
+ if (v == aie || !(flags & PLUSPLUS))
+ {
+ if (flags & PLUSPLUS) n = 3;
+ else if (v == aie && *v == '(') n = 10;
+ else n = 11;
+ ko = op;
+ om += n;
+ v = op += n;
+ while (v >= ko + n)
+ {
+ *v = *(v - n);
+ v--;
+ }
+ if (flags & PLUSPLUS) memcopy(aom, "(...))", 6);
+ else if (n == 10) memcopy(aom, "(__VARARG__))", 13);
+ else
+ {
+ ko = strcopy(aom, " __PROTO__(");
+ ko = memcopy(ko, aim, aie - aim);
+ *ko = ')';
+ if (++ko >= om)
+ {
+ *ko++ = ')';
+ om = ko;
+ }
+ }
+ }
+ }
+ else if (flags & TYPEDEF)
+ {
+ op = om;
+ while (*--op == ' ' || *op == '\t' || *op == '\n');
+ if (*op != ')')
+ {
+ op = om += 14;
+ *--op = ')';
+ while ((x = *(op - 14)) >= 'A' && x <= 'Z' || x >= 'a' && x <= 'z' || x >= '0' && x <= '9' || x == '_')
+ *--op = x;
+ memcopy(op - 13, "(__OTORP__(*)", 13);
+ }
+ }
+ if (flags & OTHER)
+ ;
+ else if (flags & PLUSPLUS)
+ {
+ op = om;
+ if (!(flags & TOKENS)) op = strcopy(op, "(...)");
+ else op = memcopy(op, im, ie - im);
+ PUTCHR(c);
+ }
+ else
+ {
+ if (flags & DECLARE) op = strcopy(om, "()");
+ else if (!(flags & TOKENS)) op = strcopy(om, "(__VARARG__)");
+ else
+ {
+ op = strcopy(om, " __PROTO__(");
+ op = memcopy(op, im, ie - im);
+ PUTCHR(')');
+ }
+ if (flags & EXTERNALIZE) memcpy(proto->ox, "extern", 6);
+ PUTCHR(c);
+ }
+ flags &= ~(MATCH|VARIADIC|VARIADIC2);
+ if (c == ',' && !(flags & INDIRECT))
+ {
+ call = 1;
+ group = 0;
+ break;
+ }
+ }
+ else if (flags & (OTHER|SKIP)) call = 0;
+ if (c == ';')
+ {
+ flags &= ~(EXTERNALIZE|MANGLE|TOKENS|TYPEDEF);
+ call = 0;
+ if (flags & SLIDE)
+ {
+ SYNC();
+ return 0;
+ }
+ }
+ else call = call > 1 && c == ',';
+ group = 0;
+ flags &= ~(IDID|INDIRECT|MATCH|OTHER|SKIP);
+ }
+ else if (paren == 1 && group == 1 && !(flags & (IDID|MANGLE))) flags |= TOKENS|OTHER;
+ break;
+ case T_DO:
+ case T_IF:
+ flags |= TOKENS|SKIP;
+ break;
+ case T_EXTERN:
+#if PROTOMAIN
+ if (flags & CLASSIC)
+ {
+ if (proto->brace == 0)
+ flags |= SKIP;
+ }
+ else
+#endif
+ if (paren == 0 && !(flags & TYPEDEF))
+ {
+ flags |= MANGLE;
+ if (!(flags & PLUSONLY) || proto->package)
+ {
+ op = strcopy(op, " __MANGLE__");
+ if (proto->package)
+ {
+ op = strcopy(op - 1, proto->package);
+ func = op + 1;
+ op = strcopy(op, "_DATA__");
+ }
+ }
+ else
+ func = 0;
+ }
+ break;
+ case T_VARIADIC:
+ if (paren == 0 && (flags & (DECLARE|VARIADIC)) == DECLARE)
+ {
+ op -= 3;
+ SYNC();
+ return c;
+ }
+ if (paren == 1 && !(flags & SKIP))
+ flags |= VARIADIC;
+ flags |= TOKENS;
+ break;
+ case T_VOID:
+ goto fsm_id;
+ case T_VA_START:
+ if ((flags & (PLUSONLY|VARIADIC)) == VARIADIC)
+ {
+ flags &= ~MATCH;
+ line = proto->line;
+ op = strcopy(op - 8, "__VA_START__");
+ SYNC();
+ for (;;)
+ {
+ switch (lex(proto, (flags & GLOBAL) | RECURSIVE))
+ {
+ case 0:
+ case ';':
+ break;
+ case T_ID:
+ if (!(flags & MATCH))
+ {
+ flags |= MATCH;
+ m = proto->tp;
+ e = proto->ip;
+ }
+ continue;
+ default:
+ continue;
+ }
+ break;
+ }
+ CACHE();
+ if (flags & MATCH)
+ {
+ v = m;
+ n = e - m;
+ }
+ else
+ {
+ v = "ap";
+ n = 2;
+ }
+ op = strcopy(op, " __OTORP__(");
+ proto->ip = proto->variadic;
+ proto->op = op;
+ flags &= ~MATCH;
+ group = 0;
+ bp = proto->ip + 1;
+ if (*bp == 'r' && !strncmp(bp, "register", 8) && (*(bp + 8) == ' ' || *(bp + 8) == '\t')) bp += 9;
+ for (;;)
+ {
+ switch (lex(proto, (flags & GLOBAL) | RECURSIVE))
+ {
+ case '(':
+ if (paren++) group++;
+ continue;
+ case ')':
+ if (--paren == 0)
+ {
+ if (flags & MATCH)
+ {
+ flags &= ~MATCH;
+ if (!(flags & VARIADIC2))
+ {
+ op = memcopy(op, m, e - m);
+ op = strcopy(op, " = ");
+ }
+ op = strcopy(op, "va_arg(");
+ op = memcopy(op, v, n);
+ PUTCHR(',');
+ PUTCHR(' ');
+ if (m > bp) op = memcopy(op, bp, m - bp);
+ else op = strcopy(op, "int ");
+ if (group > 1) op = strcopy(op, ")()");
+ else op = memcopy(op, e, proto->ip - e - 1);
+ PUTCHR(')');
+ PUTCHR(';');
+ }
+ group = 0;
+ break;
+ }
+ continue;
+ case ',':
+ if (paren == 1)
+ {
+ if (flags & MATCH)
+ {
+ flags &= ~MATCH;
+ if (!(flags & VARIADIC2))
+ {
+ op = memcopy(op, m, e - m);
+ op = strcopy(op, " = ");
+ }
+ op = strcopy(op, "va_arg(");
+ op = memcopy(op, v, n);
+ PUTCHR(',');
+ PUTCHR(' ');
+ if (m > bp) op = memcopy(op, bp, m - bp);
+ else op = strcopy(op, "int ");
+ if (group > 1) op = strcopy(op, ")()");
+ else op = memcopy(op, e, proto->ip - e - 1);
+ PUTCHR(')');
+ PUTCHR(';');
+ bp = proto->ip + 1;
+ if (*bp == 'r' && !strncmp(bp, "register", 8) && (*(bp + 8) == ' ' || *(bp + 8) == '\t')) bp += 9;
+ }
+ group = 0;
+ proto->op = op;
+ }
+ continue;
+ case T_ID:
+ if (group <= 1)
+ {
+ flags |= MATCH;
+ m = proto->tp;
+ e = proto->ip;
+ }
+ continue;
+ default:
+ continue;
+ }
+ break;
+ }
+ op = strcopy(op, ")");
+ flags |= VARIADIC2;
+ proto->line = line;
+ call = 0;
+ break;
+ }
+ /*FALLTHROUGH*/
+ case T_ID:
+ fsm_id:
+#if PROTOMAIN
+ if (flags & CLASSIC)
+ {
+ if (!args && paren == 1) args++;
+ break;
+ }
+#endif
+ if (paren == 0)
+ {
+ if (last == ')')
+ {
+ if (proto->brace == 0 && !(flags & DECLARE)) flags |= SKIP;
+ call = !call;
+ }
+ else if ((flags & SKIP) || c == T_ID || c == T_VOID) call++;
+ else flags |= SKIP;
+ if (last == T_ID) flags |= IDID;
+ }
+ c = T_ID;
+ flags |= TOKENS;
+ break;
+ case T_INVALID:
+ if (*proto->tp >= '0' && *proto->tp <= '9')
+ {
+ n = 0;
+ for (;; op--)
+ {
+ switch (*(op - 1))
+ {
+ case 'f':
+ case 'F':
+ t = op;
+ while ((c = *--t) >= '0' && c <= '9' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z');
+ if (*t == '.')
+ op--;
+ n = 0;
+ break;
+ case 'l':
+ case 'L':
+ if (!(n & 01))
+ {
+ n |= 01;
+ t = op;
+ while ((c = *--t) >= '0' && c <= '9' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z');
+ if (*t == '.')
+ {
+ n = 0;
+ op--;
+ break;
+ }
+ }
+ continue;
+ case 'u':
+ case 'U':
+ n |= 02;
+ continue;
+ }
+ break;
+ }
+ if (n & 01)
+ *op++ = 'L';
+ if (n & 02)
+ {
+ m = op;
+ t = op = m + 10;
+ while ((c = *--m) >= '0' && c <= '9' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')
+ *--t = c;
+ c = *t;
+ strcopy(m + 1, "(unsigned)");
+ *t = c;
+ break;
+ }
+ }
+ goto fsm_other;
+#if PROTOMAIN
+ case '[':
+ if ((flags & CLASSIC) && paren == 0 && group <= 2) flags |= SKIP;
+ /*FALLTHROUGH*/
+#endif
+ default:
+ fsm_other:
+#if PROTOMAIN
+ if (flags & CLASSIC) break;
+#endif
+ flags |= TOKENS;
+ if (paren == 0) flags |= OTHER;
+ break;
+ }
+ else if (c == '#' && *ip != '(') flags |= SHARP;
+ last = c;
+#if PROTOMAIN
+ if ((flags & (EXTERN|MATCH)) == (EXTERN|MATCH) && ((flags & (DIRECTIVE|SKIP)) || proto->brace || c != '(' && c != ')' && c != '*' && c != T_ID))
+ CACHEOUT();
+ else
+#endif
+ SYNCOUT();
+ goto fsm_start;
+ }
+ else if (flags & (INIT_DEFINE|INIT_INCLUDE))
+ {
+#if PROTOMAIN
+ if ((flags & YACC) && c == '%' && *ip == '{') t = 0;
+ else
+#endif
+ {
+ if (c == '#') for (t = ip; *t == ' ' || *t == '\t'; t++);
+ else t = "";
+ if (*t++ == 'i' && *t++ == 'f' && *t++ == 'n' && *t++ == 'd' && *t++ == 'e' && *t++ == 'f')
+ {
+#if !PROTOMAIN
+ while (*t == ' ' || *t == '\t') t++;
+ if (*t != '_')
+#endif
+ t = 0;
+ }
+ }
+ if (t)
+ {
+ ip = bp;
+ op = proto->op;
+ }
+ else while (*ip != '\n') *op++ = *ip++;
+ op = init(proto, op, flags);
+ op = linesync(proto, op, proto->line);
+ flags &= ~(INIT_DEFINE|INIT_INCLUDE);
+ proto->flags &= ~(INIT_DEFINE|INIT_INCLUDE);
+ goto fsm_start;
+ }
+ SYNC();
+ return c;
+}
+
+/*
+ * close a proto buffer stream
+ */
+
+void
+pppclose(char* iob)
+{
+ register struct proto* proto = (struct proto*)(iob - sizeof(struct proto));
+
+ if (proto->flags & MORE) close(proto->fd);
+ free((char*)proto); /* some ANSI cc's botch the free() prototype */
+}
+
+/*
+ * open a new proto buffer stream
+ * read buffer pointer returned
+ * 0 returned on error or if no magic
+ *
+ * file !=0 file path to open, otherwise use fd
+ * fd open file fd if file==0
+ * notice !=0 copyright notice info commented at the top
+ * options !=0 additional notice name=value pairs, space or ; separated
+ * package !=0 generate header for this package
+ */
+
+char*
+pppopen(char* file, int fd, char* notice, char* options, char* package, char* comment, int flags)
+{
+ register struct proto* proto;
+ register char* iob;
+ register long n;
+ register char* s;
+ int pragma;
+ char* b;
+#if PROTOMAIN
+ int comlen;
+ char com[80];
+#endif
+ int m = 0;
+
+ static int retain;
+
+ /*
+ * initialize proto
+ */
+
+#if PROTOMAIN
+ if (flags & PROTO_CLASSIC) flags &= ~PROTO_INCLUDE;
+#endif
+ if (flags & PROTO_RETAIN) flags &= ~retain;
+ else retain &= PROTO_INITIALIZED;
+ if (file && (fd = open(file, O_RDONLY)) < 0) return 0;
+#if !PROTOMAIN
+ if ((n = lseek(fd, 0L, 2)) > 0)
+ {
+ if (lseek(fd, 0L, 0)) return 0;
+ if (n < CHUNK) n = CHUNK;
+ else if (n > 2 * BLOCK) n = 0;
+ m = 1;
+ }
+ if (n > 0)
+ {
+ /*
+ * file read in one chunk
+ */
+
+ if (!(proto = newof(0, struct proto, 1, 4 * n + 2)))
+ return 0;
+ proto->iz = n;
+ proto->oz = 3 * n;
+ n = 0;
+ }
+ else
+#endif
+ {
+ /*
+ * file read in BLOCK chunks
+ */
+
+ n = BLOCK;
+ if (!(proto = newof(0, struct proto, 1, 5 * n + 2)))
+ return 0;
+ proto->iz = n;
+ proto->oz = 3 * n;
+ proto->flags |= MORE;
+ }
+ proto->fd = fd;
+ proto->package = package;
+ iob = (char*)proto + sizeof(struct proto);
+ proto->op = proto->ob = iob;
+ proto->ip = proto->ib = iob + proto->oz + n;
+ if (m) proto->options |= REGULAR;
+ if (!comment)
+ comment = "/*";
+ if (!(proto->cc[0] = comment[0]))
+ notice = options = 0;
+ else if (comment[1])
+ {
+ proto->cc[1] = comment[1];
+ proto->cc[2] = comment[2] ? comment[2] : comment[0];
+ }
+ else
+ proto->cc[1] = proto->cc[2] = comment[0];
+
+ /*
+ * read the first chunk
+ */
+
+ n = read(fd, proto->ip, proto->iz);
+ if (!(proto->flags & MORE))
+ close(fd);
+ if (n < 0)
+ {
+ pppclose(iob);
+ return 0;
+ }
+ *(proto->ip + n) = 0;
+
+ /*
+ * check for proto pragma in first block of lines
+ * pragma blanked out if found
+ *
+ * -1 no pragma
+ * 0 #pragma noprototyped
+ * 1 #pragma prototyped
+ *
+ * NOTE: matches may occur inside comments and quotes
+ */
+
+#if PROTOMAIN
+ if (!notice && !options || (comlen = astlicense(com, sizeof(com), NiL, "type=check", proto->cc[0], proto->cc[1], proto->cc[2])) <= 0)
+ *com = 0;
+#endif
+ pragma = -1;
+ s = proto->ip;
+ m = MAGICTOP;
+ while (m-- > 0 && *s)
+ {
+ while (*s == ' ' || *s == '\t') s++;
+ if (*s == '#')
+ {
+ b = s++;
+ while (*s == ' ' || *s == '\t') s++;
+ if (!strncmp(s, MAGICDIR, sizeof(MAGICDIR) - 1) && (*(s += sizeof(MAGICDIR) - 1) == ' ' || *s == '\t'))
+ {
+ while (*s == ' ' || *s == '\t') s++;
+ if (*s == 'n' && *(s + 1) == 'o')
+ {
+ s += 2;
+ pragma = -2;
+ }
+ if (!strncmp(s, MAGICARG, sizeof(MAGICARG) - 1) && (*(s += sizeof(MAGICARG) - 1) == ' ' || *s == '\t' || *s == '\n' || *s == '\r'))
+ while (*s)
+ {
+ if ((*(s - 1) == ' ' || *(s - 1) == '\t') && *s == *MAGICOFF && !strncmp(s, MAGICOFF, sizeof(MAGICOFF) - 1))
+ notice = options = 0;
+ if (*s++ == '\n')
+ {
+ pragma += 2;
+#if PROTOMAIN
+ if (!(flags & PROTO_DISABLE) || (flags & PROTO_NOPRAGMA))
+#endif
+ for (s--; b < s; *b++ = ' ');
+ goto magic;
+ }
+ }
+ pragma = -1;
+ }
+ }
+ else if (*s == '/' && !strncmp(s, MAGICGEN, sizeof(MAGICGEN) - 1))
+ {
+ pragma = 0;
+ break;
+ }
+#if PROTOMAIN
+ else if (*s == '%' && *(s + 1) == '{')
+ proto->flags |= YACC;
+ if (notice || options)
+ {
+ if (*s == *com && !strncmp(s, com, comlen))
+ notice = options = 0;
+ else
+ while (*s)
+ {
+ if (*s == *NOTICED && !strncmp(s, NOTICED, sizeof(NOTICED) - 1))
+ {
+ s += sizeof(NOTICED) - 1;
+ while (*s == ' ' || *s == '\t')
+ s++;
+ if (*s == '(' && (*(s + 1) == 'c' || *(s + 1) == 'C') && *(s + 2) == ')' || *s >= '0' && *s <= '9' && *(s + 1) >= '0' && *(s + 1) <= '9')
+ {
+ notice = options = 0;
+ break;
+ }
+ }
+ else if (*s++ == '\n')
+ {
+ s--;
+ break;
+ }
+ }
+ }
+#endif
+ while (*s && *s++ != '\n');
+ }
+ magic:
+ if (flags & PROTO_PLUSPLUS) proto->flags |= PLUSPLUS;
+ if (flags & PROTO_TEST) proto->test = 1;
+ if (flags & PROTO_EXTERNALIZE) proto->options |= EXTERNALIZE;
+#if PROTOMAIN
+ if (flags & PROTO_CLASSIC) pragma = -pragma;
+ if (flags & PROTO_DISABLE) pragma = 0;
+ if (flags & PROTO_LINESYNC) proto->flags |= LINESYNC;
+ if (!(proto->flags & YACC) && file && (m = strlen(file)) > 2 && file[--m] == 'y' && file[--m] == '.')
+ proto->flags |= YACC;
+#endif
+ if (pragma <= 0)
+ {
+ if (flags & PROTO_PLUSPLUS)
+ {
+ flags &= ~(PROTO_HEADER|PROTO_INCLUDE);
+ proto->flags |= PLUSONLY;
+ }
+ else if (!(flags & (PROTO_FORCE|PROTO_PASS)))
+ {
+ pppclose(iob);
+ return 0;
+ }
+ else if ((flags & (PROTO_FORCE|PROTO_PASS)) == PROTO_PASS || !pragma)
+ {
+ proto->flags |= PASS;
+ if (proto->flags & MORE)
+ proto->oz += proto->iz;
+ proto->iz = n;
+ if (notice || options)
+ {
+ if (proto->cc[0] == '#' && proto->ip[0] == '#' && proto->ip[1] == '!')
+ {
+ s = proto->ip;
+ while (*s && *s++ != '\n');
+ m = s - proto->ip;
+ proto->op = memcopy(proto->op, proto->ip, m);
+ proto->ip = s;
+ proto->iz = n -= m;
+ }
+#if PROTOMAIN
+ if (proto->cc[0])
+ {
+ if ((comlen = astlicense(proto->op, proto->oz, notice, options, proto->cc[0], proto->cc[1], proto->cc[2])) < 0)
+ proto_error((char*)proto + sizeof(struct proto), 1, proto->op, NiL);
+ else
+ proto->op += comlen;
+ }
+ if (!(flags & PROTO_CLASSIC) && !(proto->flags & YACC))
+#endif
+ proto->op = linesync(proto, proto->op, 1);
+ proto->iz += proto->op - proto->ob;
+ }
+ memcopy(proto->op, proto->ip, n);
+ return iob;
+ }
+ }
+#if PROTOMAIN
+ if (!(retain & PROTO_INITIALIZED))
+ {
+ retain |= PROTO_INITIALIZED;
+ ppfsm(FSM_INIT, NiL);
+ }
+#endif
+ proto->line = 1;
+#if CHUNK >= 512
+ if (notice || options || (flags & (PROTO_HEADER|PROTO_INCLUDE)))
+ {
+#if PROTOMAIN
+ if (notice || options)
+ {
+ if ((comlen = astlicense(proto->op, proto->oz, notice, options, proto->cc[0], proto->cc[1], proto->cc[2])) < 0)
+ proto_error((char*)proto + sizeof(struct proto), 1, proto->op, NiL);
+ else
+ proto->op += comlen;
+ }
+#endif
+ if (flags & PROTO_INCLUDE)
+ {
+ proto->flags |= INIT_INCLUDE;
+ if (flags & PROTO_RETAIN)
+ retain |= PROTO_INCLUDE;
+ }
+ else if (flags & PROTO_HEADER)
+ {
+ if (flags & PROTO_RETAIN) retain |= PROTO_HEADER;
+#if PROTOMAIN
+ if (flags & PROTO_CLASSIC)
+ {
+ *proto->op++ = '#';
+ proto->op = strcopy(proto->op, MAGICDIR);
+ *proto->op++ = ' ';
+ proto->op = strcopy(proto->op, MAGICARG);
+ *proto->op++ = '\n';
+ }
+ else
+#endif
+ proto->flags |= INIT_DEFINE;
+ }
+#if PROTOMAIN
+ if (!(flags & PROTO_CLASSIC))
+ {
+ if (proto->flags & YACC)
+ {
+ proto->op = strcopy(proto->op, "\n%{\n" + !notice);
+ proto->op = strcopy(proto->op, MAGICGEN);
+ proto->op = strcopy(proto->op, "%}\n");
+ }
+ else
+ {
+ if (n || notice || options)
+ *proto->op++ = '\n';
+ proto->op = strcopy(proto->op, MAGICGEN);
+ if (n)
+ proto->op = linesync(proto, proto->op, proto->line);
+ else if (proto->flags & (INIT_DEFINE|INIT_INCLUDE))
+ proto->op = init(proto, proto->op, proto->flags);
+ }
+ }
+#endif
+ }
+#endif
+#if PROTOMAIN
+ proto->file = file;
+ if (flags & PROTO_CLASSIC)
+ {
+ proto->flags |= CLASSIC;
+ if (!(flags & PROTO_HEADER)) proto->flags |= EXTERN;
+ }
+#endif
+ return iob;
+}
+
+/*
+ * read next proto'd chunk into iob
+ * the chunk is 0 terminated and its size is returned
+ */
+
+int
+pppread(char* iob)
+{
+ register struct proto* proto = (struct proto*)(iob - sizeof(struct proto));
+ register int n;
+
+ if (proto->flags & PASS)
+ {
+ if (proto->iz)
+ {
+ n = proto->iz;
+ proto->iz = 0;
+ }
+ else if (!(proto->flags & MORE)) n = 0;
+ else if ((n = read(proto->fd, proto->ob, proto->oz)) <= 0 || (proto->options & REGULAR) && n < proto->oz)
+ {
+ proto->flags &= ~MORE;
+ close(proto->fd);
+ }
+ }
+ else
+ {
+ if (proto->op == proto->ob)
+ {
+ if (proto->flags & ERROR) return -1;
+#if PROTOMAIN
+ if (proto->flags & YACC)
+ {
+ register char* ip = proto->ip;
+ register char* op = proto->ob;
+ register char* ep = proto->ob + proto->oz - 2;
+
+ if (!*ip)
+ {
+ ip = proto->ip = proto->ib;
+ if (!(proto->flags & MORE)) n = 0;
+ else if ((n = read(proto->fd, ip, proto->iz)) <= 0 || (proto->options & REGULAR) && n < proto->iz)
+ {
+ if (n < 0) n = 0;
+ proto->flags &= ~MORE;
+ close(proto->fd);
+ }
+ ip[n] = 0;
+ }
+ if (proto->flags & YACCSPLIT)
+ {
+ proto->flags &= ~YACCSPLIT;
+ if (*ip == '%')
+ {
+ *op++ = *ip++;
+ if (proto->flags & YACC2) proto->flags &= ~YACC;
+ else proto->flags |= YACC2;
+ }
+ }
+ if (proto->flags & YACC)
+ while (op < ep && (n = *op++ = *ip))
+ {
+ ip++;
+ if (n == '%')
+ {
+ if (*ip == '%' && (ip == proto->ip + 1 || *(ip - 2) == '\n'))
+ {
+ *op++ = *ip++;
+ if (proto->flags & YACC2) proto->flags &= ~YACC;
+ else proto->flags |= YACC2;
+ break;
+ }
+ if (!*ip)
+ {
+ *op++ = '%';
+ proto->flags |= YACCSPLIT;
+ break;
+ }
+ }
+ else if (n == '\n') proto->line++;
+ }
+ proto->op = memcopy(proto->ob, proto->ip, ip - proto->ip);
+ proto->ip = ip;
+ }
+ else
+#endif
+ lex(proto, proto->flags);
+ if ((proto->flags & (ERROR|MORE)) == ERROR)
+ proto->op = strcopy(proto->op, "/* NOTE: some constructs may not have been converted */\n");
+ }
+ n = proto->op - proto->ob;
+ proto->op = proto->ob;
+ }
+ return n;
+}
+
+#if !PROTOMAIN
+
+/*
+ * drop control of iob after first pppread()
+ * return value is input fd
+ * if fd<0 then all data in iob
+ */
+
+int
+pppdrop(char* iob)
+{
+ register struct proto* proto = (struct proto*)(iob - sizeof(struct proto));
+
+ if (proto->flags & MORE)
+ {
+ proto->flags &= ~MORE;
+ return proto->fd;
+ }
+ return -1;
+}
+
+#endif
diff --git a/usr/src/lib/libpp/common/ppsearch.c b/usr/src/lib/libpp/common/ppsearch.c
new file mode 100644
index 0000000000..f9bf29fe01
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppsearch.c
@@ -0,0 +1,807 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * include file search support
+ */
+
+#include "pplib.h"
+
+#define SEARCH_NEXT (SEARCH_USER<<1)/* search for next (uncover) */
+#define SEARCH_SKIP (SEARCH_USER<<2)/* current binding skipped */
+#define SEARCH_TEST (SEARCH_USER<<3)/* test for binding */
+#define SEARCH_FOUND (SEARCH_USER<<4)/* current binding found */
+
+#define COLUMN_TAB 7
+#define COLUMN_MAX 72
+
+#if ARCHIVE
+
+#include <vdb.h>
+#include <ls.h>
+
+#endif
+
+/*
+ * multiple include test
+ * fp is a canonicalized ppfile pointer
+ *
+ * test
+ *
+ * INC_CLEAR can be included again
+ * INC_TEST test if include required
+ * <symbol> ifndef guard symbol
+ *
+ * test!=INC_CLEAR returns 1 if file can be included again
+ *
+ * NOTE:
+ *
+ * (1) different hard links to the same file are treated as
+ * different files
+ *
+ * (2) symbolic links in combination with .. may cause two
+ * different files to be treated as the same file:
+ *
+ * "../h/<file>" == "/usr/include/sys/../h/<file>" -> "/usr/include/h/<file>"
+ * "h/<file>" -> "/usr/include/h/<file>"
+ */
+
+int
+ppmultiple(register struct ppfile* fp, register struct ppsymbol* test)
+{
+ register struct ppsymbol* status;
+
+ status = fp->guard;
+ message((-3, "search: %s: status=%s%s test=%s", fp->name, status == INC_CLEAR ? "[CLEAR]" : status == INC_TEST ? "[ONCE]" : status == INC_IGNORE ? "[IGNORE]" : status->name, (pp.mode & HOSTED) ? "[HOSTED]" : "", test == INC_CLEAR ? "[CLEAR]" : test == INC_TEST ? "[TEST]" : test->name));
+ if (status == INC_IGNORE)
+ {
+ message((-2, "%s: ignored [%s]", fp->name, pp.ignore));
+ return 0;
+ }
+ if (test == INC_TEST)
+ {
+ if (status != INC_CLEAR)
+ {
+ if (status != INC_TEST && status->macro || !(pp.mode & ALLMULTIPLE) && !(pp.state & STRICT))
+ {
+ if ((pp.mode & (ALLMULTIPLE|LOADING)) == LOADING)
+ fp->guard = INC_IGNORE;
+ if (pp.state & WARN)
+ error(1, "%s: ignored -- already included", fp->name);
+ else
+ message((-3, "%s: ignored -- already included", fp->name));
+ return 0;
+ }
+ return 1;
+ }
+ if ((pp.mode & (ALLMULTIPLE|LOADING)) == LOADING)
+ test = INC_IGNORE;
+ }
+ fp->guard = test;
+ return 1;
+}
+
+/*
+ * search for file using directories in dp
+ */
+
+static int
+search(register struct ppfile* fp, register struct ppdirs* dp, int type, int flags)
+{
+ register char* prefix;
+ register struct ppdirs* up;
+ register struct ppfile* xp;
+ struct ppfile* mp;
+ int fd;
+ int index;
+ int need;
+ int markhosted;
+ char* t;
+
+ if (!(pp.option & PREFIX))
+ prefix = 0;
+ else if ((prefix = strrchr(fp->name, '/')) && prefix > fp->name)
+ {
+ *prefix = 0;
+ t = ppsetfile(fp->name)->name;
+ *prefix = '/';
+ prefix = t;
+ }
+ message((-3, "search: %s %s%s%s%s%s%s type=%s prefix=%s flags=|%s%s%s%s%s%s start=%s=\"%s\" pre=%s lcl=%s vnd=%s std=%s cur=%s",
+ fp->name,
+ (flags & SEARCH_INCLUDE) ? "include" : "exists",
+ (flags & SEARCH_VENDOR) ? " vendor" : "",
+ (flags & SEARCH_HOSTED) ? " hosted" : "",
+ (flags & SEARCH_NEXT) ? " next" : "",
+ (flags & SEARCH_SKIP) ? " skip" : "",
+ (flags & SEARCH_TEST) ? " test" : "",
+ type == T_HEADER ? "<*>" : "\"*\"", prefix,
+ (fp->flags & INC_SELF) ? "SELF|" : "",
+ (fp->flags & INC_EXISTS) ? "EXISTS|" : "",
+ (fp->flags & INC_BOUND(INC_PREFIX)) ? "PREFIX|" : "",
+ (fp->flags & INC_BOUND(INC_LOCAL)) ? "LOCAL|" : "",
+ (fp->flags & INC_BOUND(INC_VENDOR)) ? "VENDOR|" : "",
+ (fp->flags & INC_BOUND(INC_STANDARD)) ? "STANDARD|" : "",
+ dp ? (dp->index == INC_PREFIX ? "pre" : dp->index == INC_LOCAL ? "lcl" : dp->index == INC_VENDOR ? "vnd" : "std") : NiL,
+ dp ? dp->name : NiL,
+ !(fp->flags & INC_MEMBER(INC_PREFIX)) && (xp = fp->bound[INC_PREFIX]) ? xp->name : NiL,
+ !(fp->flags & INC_MEMBER(INC_LOCAL)) && (xp = fp->bound[INC_LOCAL]) ? xp->name : NiL,
+ !(fp->flags & INC_MEMBER(INC_VENDOR)) && (xp = fp->bound[INC_VENDOR]) ? xp->name : NiL,
+ !(fp->flags & INC_MEMBER(INC_STANDARD)) && (xp = fp->bound[INC_STANDARD]) ? xp->name : NiL,
+ error_info.file
+ ));
+ if (flags & SEARCH_HOSTED)
+ need = TYPE_HOSTED;
+ else if (flags & SEARCH_VENDOR)
+ need = TYPE_VENDOR;
+ else
+ need = TYPE_INCLUDE;
+ for (index = -1; dp; dp = dp->next)
+ if (dp->type & need)
+ {
+ message((-3, "search: fp=%s need=%02x index=%d dp=%s type=%02x index=%d", fp->name, need, index, dp->name, dp->type, dp->index));
+#if ARCHIVE
+ if (!(dp->type & (TYPE_ARCHIVE|TYPE_DIRECTORY)))
+ {
+ struct stat st;
+
+ if (stat(dp->name, &st))
+ {
+ message((-3, "search: omit %s", dp->name));
+ dp->type = 0;
+ continue;
+ }
+ if (S_ISREG(st.st_mode))
+ {
+ register char* s;
+ char* e;
+ int delimiter;
+ int variant;
+ unsigned long siz;
+ unsigned long off;
+ struct ppmember* ap;
+ Sfio_t* sp;
+
+ /*
+ * check for vdb header archive
+ */
+
+ if (!(sp = sfopen(NiL, dp->name, "r")))
+ {
+ error(ERROR_SYSTEM|1, "%s: ignored -- cannot open", dp->name);
+ dp->type = 0;
+ continue;
+ }
+ variant = sfsprintf(pp.tmpbuf, MAXTOKEN, "%c%s%c%s:archive", VDB_DELIMITER, VDB_MAGIC, VDB_DELIMITER, pp.pass);
+ if (!(s = sfgetr(sp, '\n', 1)) || !strneq(s, pp.tmpbuf, variant))
+ {
+ sfclose(sp);
+ error(1, "%s: ignored -- not a directory or archive", dp->name);
+ dp->type = 0;
+ continue;
+ }
+
+ /*
+ * parse the options
+ */
+
+ dp->type |= TYPE_ARCHIVE;
+ for (s += variant;;)
+ {
+ while (*s == ' ') s++;
+ e = s;
+ for (t = 0; *s && *s != ' '; s++)
+ if (*s == '=')
+ {
+ *s = 0;
+ t = s + 1;
+ }
+ if (*s)
+ *s++ = 0;
+ if (!*e)
+ break;
+ switch ((int)hashref(pp.strtab, e))
+ {
+ case X_CHECKPOINT:
+#if CHECKPOINT
+ dp->type |= TYPE_CHECKPOINT;
+ break;
+#else
+ error(1, "preprocessor not compiled with checkpoint enabled");
+ goto notvdb;
+#endif
+ case X_HIDE:
+
+ if (t)
+ error(1, "%s: %s: archive option value ignored", e);
+ if (e = strrchr(dp->name, '/'))
+ *e = 0;
+ else
+ dp->name = ".";
+ break;
+ case X_MAP:
+ if (!t)
+ error(1, "%s: archive option value expected", e);
+ else
+ dp->name = strdup(t);
+ break;
+ default:
+ error(1, "%s: unknown archive option", e);
+ break;
+ }
+ }
+ if (sfseek(sp, -(VDB_LENGTH + 1), SEEK_END) <= 0 || !(s = sfgetr(sp, '\n', 1)))
+ {
+ notvdb:
+ sfclose(sp);
+ error(1, "%s: ignored -- cannot load archive", dp->name);
+ dp->type = 0;
+ continue;
+ }
+ if (variant = *s != 0)
+ s++;
+ else if (!(s = sfgetr(sp, '\n', 1)))
+ goto notvdb;
+ if (sfvalue(sp) != (VDB_LENGTH + variant))
+ goto notvdb;
+ if (!strneq(s, VDB_DIRECTORY, sizeof(VDB_DIRECTORY) - 1))
+ goto notvdb;
+ delimiter = s[VDB_OFFSET - 1];
+ off = strtol(s + VDB_OFFSET, NiL, 10) - sizeof(VDB_DIRECTORY);
+ siz = strtol(s + VDB_SIZE, NiL, 10);
+ if (sfseek(sp, off, SEEK_SET) != off)
+ goto notvdb;
+ if (!(s = sfreserve(sp, siz + 1, 0)))
+ goto notvdb;
+ s[siz] = 0;
+ if (!strneq(s, VDB_DIRECTORY, sizeof(VDB_DIRECTORY)) - 1)
+ goto notvdb;
+ if (!(s = strchr(s, '\n')))
+ goto notvdb;
+ s++;
+ while (e = strchr(s, '\n'))
+ {
+ delimiter = variant ? *s++ : delimiter;
+ if (!(t = strchr(s, delimiter)))
+ break;
+ *t = 0;
+ if (!streq(s, VDB_DIRECTORY))
+ {
+ pathcanon(s, 0);
+ ap = newof(0, struct ppmember, 1, 0);
+ ap->archive = dp;
+ ap->offset = strtol(t + 1, &t, 10);
+ ap->size = strtol(t + 1, NiL, 10);
+ xp = ppsetfile(s);
+ xp->flags |= INC_MEMBER(dp->index);
+ xp->bound[dp->index] = (struct ppfile*)ap;
+if (pp.test & 0x0020) error(1, "VDB#%d %s %s index=%d data=<%lu,%lu>", __LINE__, dp->name, xp->name, index, ap->offset, ap->size);
+ }
+ s = e + 1;
+ }
+ if (sfseek(sp, 0L, SEEK_SET))
+ goto notvdb;
+ if (!(pp.test & 0x4000) &&
+#if POOL
+ (pp.pool.input || !(dp->type & TYPE_CHECKPOINT))
+#else
+ !(dp->type & TYPE_CHECKPOINT)
+#endif
+ && (dp->info.buffer = sfreserve(sp, off, 0)))
+ dp->type |= TYPE_BUFFER;
+ else
+ {
+ dp->info.sp = sp;
+#if POOL
+ if (pp.pool.input)
+ sfset(sp, SF_SHARE, 1);
+#endif
+ }
+ }
+ else
+ dp->type |= TYPE_DIRECTORY;
+ }
+#endif
+ if (streq(fp->name, "."))
+ continue;
+ if (prefix && *fp->name != '/' && dp->index != INC_PREFIX)
+#if ARCHIVE
+ if (dp->type & TYPE_DIRECTORY)
+#endif
+ {
+ for (up = dp->info.subdir; up; up = up->next)
+ if (up->name == prefix)
+ break;
+ if (!up)
+ {
+ up = newof(0, struct ppdirs, 1, 0);
+ up->name = prefix;
+ up->type = dp->type;
+ up->next = dp->info.subdir;
+ dp->info.subdir = up;
+ if (!*dp->name)
+ t = prefix;
+ else
+ sfsprintf(t = pp.path, PATH_MAX - 1, "%s/%s", dp->name, prefix);
+ if (eaccess(t, X_OK))
+ {
+ message((-3, "search: omit %s", t));
+ continue;
+ }
+ up->type |= TYPE_HOSTED;
+ }
+ else if (!(up->type & TYPE_HOSTED))
+ continue;
+ }
+ mp = xp = 0;
+ if (!(flags & SEARCH_NEXT) && index != dp->index && (!(need & TYPE_HOSTED) || dp->index == INC_STANDARD) && (!(need & TYPE_VENDOR) || dp->index == INC_VENDOR))
+ {
+ if (index >= 0 && !(fp->flags & INC_MEMBER(index)))
+ fp->flags |= INC_BOUND(index);
+ index = dp->index;
+ if (fp->flags & INC_BOUND(index))
+ {
+ xp = fp->bound[index];
+ if (index == INC_PREFIX)
+ {
+ if (*fp->name == '/' || !*dp->name)
+ strcpy(pp.path, fp->name);
+ else
+ sfsprintf(pp.path, PATH_MAX - 1, "%s/%s", dp->name, fp->name);
+ pathcanon(pp.path, 0);
+ if (!xp || !streq(xp->name, pp.path))
+ {
+ fp->bound[index] = xp = ppsetfile(pp.path);
+ if (dp->type & TYPE_HOSTED)
+ xp->flags |= INC_HOSTED;
+ if ((flags & SEARCH_INCLUDE) || (xp->flags & INC_EXISTS))
+ {
+ if (!(flags & SEARCH_INCLUDE))
+ return 0;
+ if (!ppmultiple(xp, INC_TEST))
+ {
+ if (flags & SEARCH_TEST)
+ pp.include = xp->name;
+ return 0;
+ }
+ mp = xp;
+ }
+ }
+ }
+ else if (!xp)
+ {
+ while (dp->next && dp->next->index == index)
+ dp = dp->next;
+ message((-3, "search: omit %s/%s", dp->name, fp->name));
+ continue;
+ }
+ else
+ {
+ strcpy(pp.path, xp->name);
+ if (!(flags & SEARCH_INCLUDE))
+ return 0;
+ if (!ppmultiple(xp, INC_TEST))
+ {
+ if (flags & SEARCH_TEST)
+ pp.include = xp->name;
+ return 0;
+ }
+ mp = xp;
+ }
+ }
+ }
+ if (!(fp->flags & INC_BOUND(index)) || (flags & SEARCH_NEXT))
+ {
+ if (*fp->name == '/' || !*dp->name)
+ strcpy(pp.path, fp->name);
+ else
+ sfsprintf(pp.path, PATH_MAX - 1, "%s/%s", dp->name, fp->name);
+ pathcanon(pp.path, 0);
+ if (!(flags & SEARCH_SKIP))
+ {
+ int found;
+ struct ppinstk* in;
+
+ if (streq(error_info.file, pp.path))
+ found = 1;
+ else
+ {
+ found = 0;
+ for (in = pp.in; in; in = in->prev)
+ if (in->type == IN_FILE && in->file && streq(in->file, pp.path))
+ {
+ found = 1;
+ break;
+ }
+ }
+ if (found)
+ {
+ flags |= SEARCH_FOUND;
+ continue;
+ }
+ if (!(flags & SEARCH_FOUND))
+ continue;
+ }
+ }
+ if ((xp || (xp = ppgetfile(pp.path))) && (xp->flags & INC_SELF))
+ {
+ if (xp->flags & INC_EXISTS)
+ {
+ if (!(flags & SEARCH_INCLUDE))
+ return 0;
+ if (!(flags & SEARCH_NEXT) && mp != xp && (mp = xp) && !ppmultiple(xp, INC_TEST))
+ {
+ if (flags & SEARCH_TEST)
+ pp.include = xp->name;
+ return 0;
+ }
+ }
+ else if (*fp->name == '/')
+ break;
+ else
+ continue;
+ }
+ message((-3, "search: file=%s path=%s", fp->name, pp.path));
+#if ARCHIVE
+if (pp.test & 0x0040) error(1, "SEARCH#%d dir=%s%s%s%s%s file=%s%s path=%s index=%d", __LINE__, dp->name, (dp->type & TYPE_ARCHIVE) ? " ARCHIVE" : "", (dp->type & TYPE_BUFFER) ? " BUFFER" : "", (dp->type & TYPE_CHECKPOINT) ? " CHECKPOINT" : "", (dp->type & TYPE_DIRECTORY) ? " DIRECTORY" : "", fp->name, (fp->flags & INC_MEMBER(index)) ? " MEMBER" : "", pp.path, index);
+ if ((fp->flags & INC_MEMBER(index)) && ((struct ppmember*)fp->bound[index])->archive == dp)
+ {
+ fd = 0;
+ pp.member = (struct ppmember*)fp->bound[index];
+if (pp.test & 0x0010) error(1, "SEARCH#%d file=%s path=%s index=%d data=<%lu,%lu>", __LINE__, fp->name, pp.path, index, pp.member->offset, pp.member->size);
+ }
+ else if (!(dp->type & TYPE_DIRECTORY))
+ continue;
+ else
+#endif
+ {
+ pp.member = 0;
+ fd = (flags & SEARCH_INCLUDE) ? open(pp.path, O_RDONLY) : eaccess(pp.path, R_OK);
+ }
+ if (fd >= 0)
+ {
+ pp.found = dp;
+ if ((pp.option & (PLUSPLUS|NOPROTO)) == PLUSPLUS && !(pp.test & TEST_noproto))
+ {
+ if (dp->c)
+ pp.mode |= MARKC;
+ else
+ pp.mode &= ~MARKC;
+ }
+ if (xp)
+ markhosted = xp->flags & INC_HOSTED;
+ else if (!(markhosted = (dp->type & TYPE_HOSTED)) && dp->index == INC_PREFIX && (pp.mode & (FILEDEPS|HEADERDEPS|INIT)) == FILEDEPS)
+ {
+ up = dp;
+ while ((up = up->next) && !streq(up->name, dp->name));
+ if (up && (up->type & TYPE_HOSTED))
+ markhosted = 1;
+ }
+ if (markhosted)
+ pp.mode |= MARKHOSTED;
+ else
+ pp.mode &= ~MARKHOSTED;
+ xp = ppsetfile(pp.path);
+ if (markhosted)
+ xp->flags |= INC_HOSTED;
+ message((-2, "search: %s -> %s%s%s", fp->name, pp.path, (pp.mode & MARKC) ? " [C]" : "", (pp.mode & MARKHOSTED) ? " [hosted]" : ""));
+#if ARCHIVE
+ if (!pp.member)
+ {
+#endif
+ fp->flags |= INC_BOUND(index);
+ fp->bound[index] = xp;
+ if ((index == INC_STANDARD || index == INC_VENDOR) && type != T_HEADER && !(fp->flags & INC_BOUND(INC_LOCAL)))
+ {
+ fp->flags |= INC_BOUND(INC_LOCAL);
+ fp->bound[INC_LOCAL] = xp;
+ }
+#if ARCHIVE
+ }
+#endif
+ xp->flags |= INC_SELF|INC_EXISTS;
+ if (flags & SEARCH_INCLUDE)
+ {
+ if ((pp.prefix = prefix) || (pp.prefix = pp.in->prefix))
+ message((-2, "search: %s: prefix=%s", xp->name, pp.prefix));
+ if (!(pp.mode & ALLMULTIPLE))
+ {
+ if (xp->guard == INC_CLEAR || xp == mp)
+ xp->guard = INC_TEST;
+ else
+ {
+ if (pp.state & WARN)
+ error(1, "%s: ignored -- already included", xp->name);
+ else
+ message((-3, "%s: ignored -- already included", xp->name));
+ xp->guard = fp->guard = INC_IGNORE;
+#if ARCHIVE
+ if (!pp.member)
+#endif
+ if (fd > 0)
+ close(fd);
+ if (flags & SEARCH_TEST)
+ pp.include = xp->name;
+ return 0;
+ }
+ }
+ pp.include = xp->name;
+ if ((pp.mode & (FILEDEPS|INIT)) == FILEDEPS && ((pp.mode & HEADERDEPS) || !(pp.mode & MARKHOSTED)) && !(xp->flags & INC_LISTED))
+ {
+ xp->flags |= INC_LISTED;
+ if ((pp.column + strlen(xp->name)) >= COLUMN_MAX)
+ {
+ sfprintf(pp.filedeps.sp, " \\\n");
+ pp.column = COLUMN_TAB;
+ index = '\t';
+ }
+ else
+ index = ' ';
+ pp.column += sfprintf(pp.filedeps.sp, "%c%s", index, xp->name);
+ }
+ }
+ return fd;
+ }
+ if (xp)
+ xp->flags |= INC_SELF;
+ if (errno == EMFILE)
+ error(3, "%s: too many open files", fp->name);
+ else if (errno != ENOENT && errno != ENOTDIR)
+ error(ERROR_SYSTEM|1, "%s: cannot open file for reading", pp.path);
+ if (*fp->name == '/')
+ break;
+ }
+ strcpy(pp.path, fp->name);
+ message((-2, "search: %s%s not found", (flags & SEARCH_NEXT) ? "next " : "", fp->name));
+ return -1;
+}
+
+/*
+ * search for an include file
+ * if (flags&SEARCH_INCLUDE) then
+ * if file found then open read file descriptor returned
+ * with pp.path set to the full path and
+ * pp.prefix set to the directory prefix
+ * otherwise 0 returned if file found but ignored
+ * otherwise -1 returned
+ * otherwise
+ * if file found then 0 returned
+ * otherwise -1 returned
+ */
+
+int
+ppsearch(char* file, int type, int flags)
+{
+ register struct ppfile* fp;
+ register char* s;
+ register struct ppdirs* dp;
+ struct oplist* cp;
+ struct ppfile* xp;
+ int dospath;
+ int fd;
+ int index;
+ char name[MAXTOKEN + 1];
+
+ pp.include = 0;
+ fd = -1;
+ dospath = 0;
+ again:
+ pathcanon(file, 0);
+ for (cp = pp.chop; cp; cp = cp->next)
+ if (strneq(file, cp->value, cp->op))
+ {
+ if (cp->value[cp->op + 1])
+ {
+ sfsprintf(name, sizeof(name) - 1, "%s%s", cp->value + cp->op + 1, file + cp->op);
+ message((-3, "chop: %s -> %s", file, name));
+ file = name;
+ }
+ else if (strchr(file + cp->op, '/'))
+ {
+ message((-3, "chop: %s -> %s", file, file + cp->op));
+ file += cp->op;
+ }
+ break;
+ }
+ fp = ppsetfile(file);
+ while ((fp->flags & INC_MAPALL) || (fp->flags & INC_MAPHOSTED) && (pp.mode & HOSTED) || (fp->flags & INC_MAPNOHOSTED) && !(pp.mode & HOSTED))
+ {
+ if (!(xp = fp->bound[type == T_HEADER ? INC_STANDARD : INC_LOCAL]) || xp == fp)
+ break;
+ message((-1, "map: %s -> %s", fp->name, xp->name));
+ fp = xp;
+ }
+ if ((fp->flags & INC_MAPNOLOCAL) && (pp.mode & HOSTED))
+ flags |= SEARCH_HOSTED;
+ else if (pp.vendor)
+ flags |= SEARCH_VENDOR;
+ pp.original = fp;
+ if (type == T_HEADER && strneq(fp->name, "...", 3) && (!fp->name[3] || fp->name[3] == '/'))
+ {
+ if (fp->name[3] == '/')
+ {
+ int n;
+ int m;
+
+ n = strlen(error_info.file);
+ m = strlen(fp->name + 4);
+ if (n < m || !streq(fp->name + 4, error_info.file + n - m))
+ {
+ if ((fd = ppsearch(fp->name + 4, type, flags|SEARCH_TEST)) < 0)
+ return -1;
+ if (fd > 0)
+ close(fd);
+ s = error_info.file;
+ error_info.file = pp.include;
+ fd = ppsearch(fp->name + 4, type, flags|SEARCH_NEXT);
+ error_info.file = s;
+ return fd;
+ }
+ file = error_info.file + n - m;
+ }
+ else if (file = strrchr(error_info.file, '/'))
+ file++;
+ else
+ file = error_info.file;
+ flags |= SEARCH_NEXT;
+#if _HUH_2002_05_28
+ if (pp.in->prefix)
+ {
+ sfsprintf(name, sizeof(name) - 1, "%s/%s", pp.in->prefix, file);
+ fp = ppsetfile(name);
+ if ((fd = ppsearch(fp->name, type, flags)) >= 0)
+ return fd;
+ }
+#endif
+ fp = ppsetfile(file);
+ return ppsearch(fp->name, type, flags);
+ }
+ else if ((flags & SEARCH_INCLUDE) && fp->guard == INC_IGNORE)
+ {
+ strcpy(pp.path, fp->name);
+ message((-2, "%s: ignored", fp->name));
+ return 0;
+ }
+ else if (!(flags & SEARCH_NEXT))
+ flags |= SEARCH_SKIP;
+ pp.prefix = 0;
+ if (type == T_HEADER)
+ dp = pp.stddirs->next;
+ else
+ {
+ dp = pp.lcldirs;
+ if (dp == pp.firstdir)
+ {
+ /*
+ * look in directory of including file first
+ */
+
+ if (error_info.file && (s = strrchr(error_info.file, '/')))
+ {
+ *s = 0;
+ dp->name = ppsetfile(error_info.file)->name;
+ *s = '/';
+ }
+ else
+ dp->name = "";
+ }
+ else if (pp.in->prefix && pp.lcldirs != pp.firstdir)
+ {
+ /*
+ * look in prefix directory of including file first
+ */
+
+ if (*fp->name != '/')
+ {
+ if ((s = strchr(fp->name, '/')) && (fp->name[0]
+!= '.' || fp->name[1] != '.' || fp->name[2] != '/'))
+ {
+ *s = 0;
+ if (!streq(fp->name, pp.in->prefix))
+ fd = 0;
+ *s = '/';
+ }
+ else
+ fd = 0;
+ }
+ if (fd >= 0)
+ {
+ sfsprintf(name, sizeof(name) - 1, "%s/%s", pp.in->prefix, fp->name);
+ pathcanon(name, 0);
+ xp = ppsetfile(name);
+ if ((fd = search(xp, dp, type, flags)) >= 0)
+ return fd;
+ }
+ }
+ }
+ if ((fd = search(fp, dp, type, flags)) < 0)
+ {
+ if ((pp.option & PLUSPLUS) && file != pp.tmpbuf)
+ {
+ s = file + strlen(file);
+ while (s > file && *--s != '/' && *s != '\\' && *s != '.');
+ if (*s != '.')
+ {
+ sfsprintf(pp.tmpbuf, MAXTOKEN, "%s.h", file);
+ file = pp.tmpbuf;
+ goto again;
+ }
+ }
+
+ /*
+ * hackery for msdos files viewed through unix
+ */
+
+ switch (dospath)
+ {
+ case 0:
+ if (s = strchr(file, '\\'))
+ {
+ do *s++ = '/'; while (s = strchr(s, '\\'));
+ pathcanon(file, 0);
+ dospath = 1;
+ goto again;
+ }
+ /*FALLTHROUGH*/
+ case 1:
+ if (ppisid(file[0]) && file[1] == ':' && file[2] == '/')
+ {
+ file[1] = file[0];
+ file[0] = '/';
+ pathcanon(file, 0);
+ dospath = 2;
+ goto again;
+ }
+ break;
+ case 2:
+ file += 2;
+ goto again;
+ }
+ if ((flags & (SEARCH_INCLUDE|SEARCH_NEXT)) == SEARCH_INCLUDE)
+ {
+ if (!(pp.mode & GENDEPS))
+ {
+ if (!(pp.option & ALLPOSSIBLE) || pp.in->prev->prev)
+ error(2, "%s: cannot find include file", file);
+ }
+ else if (!(pp.mode & INIT))
+ {
+ xp = ppsetfile(file);
+ if (!(xp->flags & INC_LISTED))
+ {
+ xp->flags |= INC_LISTED;
+ if ((pp.column + strlen(file)) >= COLUMN_MAX)
+ {
+ sfprintf(pp.filedeps.sp, " \\\n");
+ pp.column = COLUMN_TAB;
+ index = '\t';
+ }
+ else
+ index = ' ';
+ pp.column += sfprintf(pp.filedeps.sp, "%c%s", index, file);
+ }
+ }
+ }
+ }
+ return fd;
+}
diff --git a/usr/src/lib/libpp/common/ppsym.c b/usr/src/lib/libpp/common/ppsym.c
new file mode 100644
index 0000000000..081f1bcd94
--- /dev/null
+++ b/usr/src/lib/libpp/common/ppsym.c
@@ -0,0 +1,94 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * cpp predefined symbol detection support
+ *
+ * with no args stdin is treated as an a.out for
+ * a Reiser derived cpp -- all strings that may
+ * be identifiers are listed on fd 3 (1 if no 3)
+ *
+ * with args the -D argument values are listed on fd 3 (1 if no 3)
+ */
+
+#include <ast.h>
+#include <ctype.h>
+
+int
+main(int argc, char** argv)
+{
+ register int state;
+ register int c;
+ register char* s;
+ Sfio_t* out;
+
+ NoP(argc);
+ if (dup(3) < 0 || !(out = sfnew(NiL, NiL, -1, 3, SF_WRITE)))
+ out = sfstdout;
+ if (*++argv)
+ {
+ while (s = *argv++)
+ if (*s++ == '-' && *s++ == 'D' && isalpha(*s))
+ {
+ while (*s && *s != '=') sfputc(out, *s++);
+ sfputc(out, '\n');
+ }
+ return 0;
+ }
+ state = 0;
+ for (;;)
+ {
+ switch (c = sfgetc(sfstdin))
+ {
+ case EOF:
+ break;
+ case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+ case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+ case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+ case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+ case 'y': case 'z': case '_':
+ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+ case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+ case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+ case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+ case 'Y': case 'Z':
+ state++;
+ sfputc(out, c);
+ continue;
+ case '0': case '1': case '2': case '3': case '4': case '5':
+ case '6': case '7': case '8': case '9':
+ if (state)
+ {
+ sfputc(out, c);
+ continue;
+ }
+ /*FALLTHROUGH*/
+ default:
+ if (state)
+ {
+ sfputc(out, '\n');
+ state = 0;
+ }
+ continue;
+ }
+ break;
+ }
+ return 0;
+}
diff --git a/usr/src/lib/libpp/common/pptrace.c b/usr/src/lib/libpp/common/pptrace.c
new file mode 100644
index 0000000000..d1b1204817
--- /dev/null
+++ b/usr/src/lib/libpp/common/pptrace.c
@@ -0,0 +1,264 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1986-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * preprocessor library trace and debug support
+ */
+
+#include "pplib.h"
+#include "ppfsm.h"
+
+#include <ctype.h>
+
+/*
+ * convert token string to printable form
+ */
+
+char*
+pptokstr(register char* s, register int c)
+{
+ register char* t;
+
+ static char buf[8];
+
+ if (t = s)
+ {
+ while (*t == ' ' || *t == '\t') t++;
+ c = *t ? *t : *s;
+ }
+ switch (c)
+ {
+ case 0:
+ case 0400:
+ return("`EOF'");
+ case ' ':
+ return("`space'");
+ case '\f':
+ return("`formfeed'");
+ case '\n':
+ return("`newline'");
+ case '\t':
+ return("`tab'");
+ case '\v':
+ return("`vertical-tab'");
+ case T_TOKCAT:
+ return("##");
+ default:
+ if (iscntrl(c) || !isprint(c)) sfsprintf(buf, sizeof(buf), "`%03o'", c);
+ else if (s) return(s);
+ else sfsprintf(buf, sizeof(buf), "%c", c);
+ return(buf);
+ }
+}
+
+#if DEBUG & TRACE_debug
+
+#include "ppdebug.h"
+
+/*
+ * return input stream name given index
+ */
+
+char*
+ppinstr(register struct ppinstk* p)
+{
+ register int i;
+
+ static char buf[128];
+
+ for (i = 0; i < elementsof(ppinmap); i++)
+ if (p->type == ppinmap[i].val)
+ {
+ switch (p->type)
+ {
+ case IN_MACRO:
+#if MACDEF
+ case IN_MULTILINE:
+#endif
+ if (p->symbol)
+ {
+ sfsprintf(buf, sizeof(buf), "%s=%s", ppinmap[i].nam, p->symbol->name);
+ return(buf);
+ }
+ break;
+ }
+ return(ppinmap[i].nam);
+ }
+ sfsprintf(buf, sizeof(buf), "UNKNOWN[%d]", p->type);
+ return(buf);
+}
+
+/*
+ * return string given fsm lex state
+ */
+
+char*
+pplexstr(register int lex)
+{
+ register int i;
+ int splice;
+ static char buf[64];
+
+ if (lex < 0) lex &= ~lex;
+ splice = (lex & SPLICE);
+ lex &= 0x7f;
+ for (i = 0; i < (elementsof(pplexmap) - 1) && (lex > pplexmap[i].val || lex == pplexmap[i+1].val); i++);
+ if (lex != pplexmap[i].val)
+ {
+ if (pplexmap[i].val < 0) sfsprintf(buf, sizeof(buf), "%s|0x%04x%s", pplexmap[i].nam, lex, splice ? "|SPLICE" : "");
+ else sfsprintf(buf, sizeof(buf), "%s+%d", pplexmap[i-1].nam, lex - pplexmap[i-1].val, splice ? "|SPLICE" : "");
+ return(buf);
+ }
+ if (splice)
+ {
+ sfsprintf(buf, sizeof(buf), "%s|SPLICE", pplexmap[i].nam);
+ return(buf);
+ }
+ return(pplexmap[i].nam);
+}
+
+/*
+ * return string given map p of size n and flags
+ */
+
+static char*
+ppflagstr(register struct map* p, int n, register long flags)
+{
+ register int i;
+ register int k;
+ register char* s;
+
+ static char buf[128];
+
+ s = buf;
+ for (i = 0; i < n; i++)
+ if (flags & p[i].val)
+ {
+ k = strlen(p[i].nam);
+ if ((elementsof(buf) - 2 - (s - buf)) > k)
+ {
+ if (s > buf) *s++ = '|';
+ strcpy(s, p[i].nam);
+ s += k;
+ }
+ }
+ *s = 0;
+ return(buf);
+}
+
+/*
+ * return string given pp.mode
+ */
+
+char*
+ppmodestr(register long mode)
+{
+ return(ppflagstr(ppmodemap, elementsof(ppmodemap), mode));
+}
+
+/*
+ * return string given pp.option
+ */
+
+char*
+ppoptionstr(register long option)
+{
+ return(ppflagstr(ppoptionmap, elementsof(ppoptionmap), option));
+}
+
+/*
+ * return string given pp.state
+ */
+
+char*
+ppstatestr(register long state)
+{
+ return(ppflagstr(ppstatemap, elementsof(ppstatemap), state));
+}
+
+#include <sig.h>
+
+/*
+ * io stream stack trace
+ * sig==0 registers the handler
+ */
+
+void
+pptrace(int sig)
+{
+ register char* s;
+ register char* x;
+ register struct ppinstk* p;
+ static int handling;
+
+ if (!sig)
+ {
+#ifdef SIGBUS
+ signal(SIGBUS, pptrace);
+#endif
+#ifdef SIGSEGV
+ signal(SIGSEGV, pptrace);
+#endif
+#ifdef SIGILL
+ signal(SIGILL, pptrace);
+#endif
+ signal(SIGQUIT, pptrace);
+ return;
+ }
+ s = fmtsignal(sig);
+ if (handling)
+ {
+ sfprintf(sfstderr, "\n%s during io stack trace\n", s);
+ signal(handling, SIG_DFL);
+ sigunblock(handling);
+ kill(getpid(), handling);
+ pause();
+ error(PANIC, "signal not redelivered");
+ }
+ handling = sig;
+ sfprintf(sfstderr, "\n%s - io stack trace\n", s);
+ for (p = pp.in; p->prev; p = p->prev)
+ {
+ sfprintf(sfstderr, "\n[%s]\n", ppinstr(p));
+ if ((s = pp.in->nextchr) && *s)
+ {
+ if (*s != '\n') sfputc(sfstderr, '\t');
+ x = s + 256;
+ while (*s && s < x)
+ {
+ sfputc(sfstderr, *s);
+ if (*s++ == '\n' && *s && *s != '\n') sfputc(sfstderr, '\t');
+ }
+ if (*s) sfprintf(sfstderr, " ...");
+ }
+ }
+ sfprintf(sfstderr, "\n");
+ handling = 0;
+ signal(sig, SIG_DFL);
+ sigunblock(sig);
+ kill(getpid(), sig);
+ pause();
+ error(PANIC, "signal not redelivered");
+}
+
+#endif
diff --git a/usr/src/lib/libpp/i386/Makefile b/usr/src/lib/libpp/i386/Makefile
new file mode 100644
index 0000000000..f91f0270e9
--- /dev/null
+++ b/usr/src/lib/libpp/i386/Makefile
@@ -0,0 +1,30 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/usr/src/lib/libpp/i386/pp.req b/usr/src/lib/libpp/i386/pp.req
new file mode 100644
index 0000000000..6c6437695b
--- /dev/null
+++ b/usr/src/lib/libpp/i386/pp.req
@@ -0,0 +1,2 @@
+ -lpp
+ -last
diff --git a/usr/src/lib/libpp/i386/pp.yacc b/usr/src/lib/libpp/i386/pp.yacc
new file mode 100644
index 0000000000..1de9080a7a
--- /dev/null
+++ b/usr/src/lib/libpp/i386/pp.yacc
@@ -0,0 +1 @@
+%token /*generated from pp.h*/ T_DOUBLE 292 T_DOUBLE_L 293 T_FLOAT 294 T_DECIMAL 288 T_DECIMAL_L 289 T_DECIMAL_U 290 T_DECIMAL_UL 291 T_OCTAL 296 T_OCTAL_L 297 T_OCTAL_U 298 T_OCTAL_UL 299 T_HEXADECIMAL 304 T_HEXADECIMAL_L 305 T_HEXADECIMAL_U 306 T_HEXADECIMAL_UL 307 T_HEXDOUBLE 308 T_HEXDOUBLE_L 309 T_ID 257 T_INVALID 258 T_CHARCONST 260 T_WCHARCONST 261 T_STRING 262 T_WSTRING 263 T_PTRMEM 264 T_ADDADD 265 T_SUBSUB 266 T_LSHIFT 267 T_RSHIFT 268 T_LE 269 T_GE 270 T_EQ 271 T_NE 272 T_ANDAND 273 T_OROR 274 T_MPYEQ 275 T_DIVEQ 276 T_MODEQ 277 T_ADDEQ 278 T_SUBEQ 279 T_LSHIFTEQ 280 T_RSHIFTEQ 281 T_ANDEQ 282 T_XOREQ 283 T_OREQ 284 T_VARIADIC 286 T_DOTREF 320 T_PTRMEMREF 321 T_SCOPE 322 T_UMINUS 323
diff --git a/usr/src/lib/libpp/i386/ppdebug.h b/usr/src/lib/libpp/i386/ppdebug.h
new file mode 100644
index 0000000000..9c9f29e795
--- /dev/null
+++ b/usr/src/lib/libpp/i386/ppdebug.h
@@ -0,0 +1,211 @@
+/*
+* preprocessor library debug maps
+*/
+struct map
+{
+ char* nam;
+ long val;
+};
+static struct map pplexmap[] =
+{
+ "PROTO", PROTO,
+ "RES1", RES1,
+ "RES1a", RES1a,
+ "RES1e", RES1e,
+ "RES1f", RES1f,
+ "RES1h", RES1h,
+ "RES1l", RES1l,
+ "RES1n", RES1n,
+ "RES1o", RES1o,
+ "RES1t", RES1t,
+ "RES1x", RES1x,
+ "RES1y", RES1y,
+ "COM1", COM1,
+ "COM2", COM2,
+ "COM3", COM3,
+ "COM4", COM4,
+ "COM5", COM5,
+ "COM6", COM6,
+ "COM7", COM7,
+ "NID", NID,
+ "LIT", LIT,
+ "LIT1", LIT1,
+ "LIT2", LIT2,
+ "BAD1", BAD1,
+ "BAD2", BAD2,
+ "DOT", DOT,
+ "DOT2", DOT2,
+ "WS1", WS1,
+ "QUICK", QUICK,
+ "QTOK", QTOK,
+ "QNUM", QNUM,
+ "QEXP", QEXP,
+ "QCOM", QCOM,
+ "QID", QID,
+ "MAC0", MAC0,
+ "MACN", MACN,
+ "HIT0", HIT0,
+ "HITN", HITN,
+ "LIT0", LIT0,
+ "SHARP1", SHARP1,
+ "TOKEN", TOKEN,
+ "OCT1", OCT1,
+ "OCT2", OCT2,
+ "OCT3", OCT3,
+ "NOT1", NOT1,
+ "PCT1", PCT1,
+ "AND1", AND1,
+ "STAR1", STAR1,
+ "PLUS1", PLUS1,
+ "MINUS1", MINUS1,
+ "ARROW1", ARROW1,
+ "COLON1", COLON1,
+ "LT1", LT1,
+ "LSH1", LSH1,
+ "EQ1", EQ1,
+ "RSH1", RSH1,
+ "GT1", GT1,
+ "CIRC1", CIRC1,
+ "OR1", OR1,
+ "DEC1", DEC1,
+ "DEC2", DEC2,
+ "HEX1", HEX1,
+ "HEX2", HEX2,
+ "HEX3", HEX3,
+ "HEX4", HEX4,
+ "HEX5", HEX5,
+ "HEX6", HEX6,
+ "HEX7", HEX7,
+ "HEX8", HEX8,
+ "DBL1", DBL1,
+ "DBL2", DBL2,
+ "DBL3", DBL3,
+ "DBL4", DBL4,
+ "DBL5", DBL5,
+ "DOT1", DOT1,
+ "HDR1", HDR1,
+ "BIN1", BIN1,
+ "TERMINAL", TERMINAL,
+ "S_CHRB", S_CHRB,
+ "S_COMMENT", S_COMMENT,
+ "S_EOB", S_EOB,
+ "S_LITBEG", S_LITBEG,
+ "S_LITEND", S_LITEND,
+ "S_LITESC", S_LITESC,
+ "S_MACRO", S_MACRO,
+ "S_NL", S_NL,
+ "S_QUAL", S_QUAL,
+ "S_SHARP", S_SHARP,
+ "S_VS", S_VS,
+ "S_CHR", S_CHR,
+ "S_HUH", S_HUH,
+ "S_TOK", S_TOK,
+ "S_TOKB", S_TOKB,
+ "S_WS", S_WS,
+ "S_RESERVED", S_RESERVED,
+};
+static struct map ppstatemap[] =
+{
+ "ADD", ADD,
+ "COLLECTING", COLLECTING,
+ "COMPATIBILITY", COMPATIBILITY,
+ "COMPILE", COMPILE,
+ "CONDITIONAL", CONDITIONAL,
+ "DEFINITION", DEFINITION,
+ "DIRECTIVE", DIRECTIVE,
+ "DISABLE", DISABLE,
+ "EOF2NL", EOF2NL,
+ "ESCAPE", ESCAPE,
+ "FILEPOP", FILEPOP,
+ "HEADER", HEADER,
+ "HIDDEN", HIDDEN,
+ "JOINING", JOINING,
+ "NEWLINE", NEWLINE,
+ "NOEXPAND", NOEXPAND,
+ "NOSPACE", NOSPACE,
+ "NOTEXT", NOTEXT,
+ "NOVERTICAL", NOVERTICAL,
+ "PASSEOF", PASSEOF,
+ "PASSTHROUGH", PASSTHROUGH,
+ "QUOTE", QUOTE,
+ "SKIPCONTROL", SKIPCONTROL,
+ "SKIPMACRO", SKIPMACRO,
+ "SPACEOUT", SPACEOUT,
+ "SQUOTE", SQUOTE,
+ "STANDALONE", STANDALONE,
+ "STRICT", STRICT,
+ "STRIP", STRIP,
+ "SYNCLINE", SYNCLINE,
+ "TRANSITION", TRANSITION,
+ "WARN", WARN,
+};
+static struct map ppmodemap[] =
+{
+ "ALLMULTIPLE", ALLMULTIPLE,
+ "BUILTIN", BUILTIN,
+ "CATLITERAL", CATLITERAL,
+ "DUMP", DUMP,
+ "EXPOSE", EXPOSE,
+ "EXTERNALIZE", EXTERNALIZE,
+ "FILEDEPS", FILEDEPS,
+ "GENDEPS", GENDEPS,
+ "HEADERDEPS", HEADERDEPS,
+ "HOSTED", HOSTED,
+ "HOSTEDTRANSITION", HOSTEDTRANSITION,
+ "INACTIVE", INACTIVE,
+ "INIT", INIT,
+ "LOADING", LOADING,
+ "MARKC", MARKC,
+ "MARKHOSTED", MARKHOSTED,
+ "MARKMACRO", MARKMACRO,
+ "PEDANTIC", PEDANTIC,
+ "READONLY", READONLY,
+ "RELAX", RELAX,
+};
+static struct map ppoptionmap[] =
+{
+ "ELSEIF", ELSEIF,
+ "FINAL", FINAL,
+ "HEADEREXPAND", HEADEREXPAND,
+ "HEADEREXPANDALL", HEADEREXPANDALL,
+ "IGNORELINE", IGNORELINE,
+ "INITIAL", INITIAL,
+ "KEEPNOTEXT", KEEPNOTEXT,
+ "KEYARGS", KEYARGS,
+ "MODERN", MODERN,
+ "NATIVE", NATIVE,
+ "NOHASH", NOHASH,
+ "NOISE", NOISE,
+ "NOISEFILTER", NOISEFILTER,
+ "NOPROTO", NOPROTO,
+ "PLUSCOMMENT", PLUSCOMMENT,
+ "PLUSPLUS", PLUSPLUS,
+ "PLUSSPLICE", PLUSSPLICE,
+ "PRAGMAEXPAND", PRAGMAEXPAND,
+ "PREDEFINED", PREDEFINED,
+ "PREDEFINITIONS", PREDEFINITIONS,
+ "PREFIX", PREFIX,
+ "PRESERVE", PRESERVE,
+ "PROTOTYPED", PROTOTYPED,
+ "REGUARD", REGUARD,
+ "SPLICECAT", SPLICECAT,
+ "SPLICESPACE", SPLICESPACE,
+ "STRINGSPAN", STRINGSPAN,
+ "STRINGSPLIT", STRINGSPLIT,
+ "TRUNCATE", TRUNCATE,
+ "ZEOF", ZEOF,
+};
+static struct map ppinmap[] =
+{
+ "BUFFER", IN_BUFFER,
+ "COPY", IN_COPY,
+ "EXPAND", IN_EXPAND,
+ "FILE", IN_FILE,
+ "INIT", IN_INIT,
+ "MACRO", IN_MACRO,
+ "MULTILINE", IN_MULTILINE,
+ "QUOTE", IN_QUOTE,
+ "RESCAN", IN_RESCAN,
+ "SQUOTE", IN_SQUOTE,
+ "STRING", IN_STRING,
+};
diff --git a/usr/src/lib/libpp/i386/ppdef.h b/usr/src/lib/libpp/i386/ppdef.h
new file mode 100644
index 0000000000..6cb3481f8b
--- /dev/null
+++ b/usr/src/lib/libpp/i386/ppdef.h
@@ -0,0 +1,220 @@
+/*
+ *
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * @(#)pp.tab (AT&T Labs Research) 2006-05-09
+ *
+ * C preprocessor tables and states
+ *
+ * + marks extensions to the standard
+ *
+ */
+
+#define DEFINE 1
+#define ELIF 2
+#define ELSE 3
+#define ENDIF 4
+#define ENDMAC 5
+#define ERROR 6
+#define IF 7
+#define IFDEF 8
+#define IFNDEF 9
+#define INCLUDE 10
+#define LET 11
+#define LINE 12
+#define MACDEF 13
+#define PRAGMA 14
+#define RENAME 15
+#define UNDEF 16
+#define WARNING 17
+
+#define X_ALLMULTIPLE 1
+#define X_ALLPOSSIBLE 2
+#define X_BUILTIN 3
+#define X_CATLITERAL 4
+#define X_CDIR 5
+#define X_CHECKPOINT 6
+#define X_CHOP 7
+#define X_COMPATIBILITY 8
+#define X_DEBUG 9
+#define X_ELSEIF 10
+#define X_EXTERNALIZE 11
+#define X_FINAL 12
+#define X_HIDE 13
+#define X_HEADEREXPAND 14
+#define X_HEADEREXPANDALL 15
+#define X_HOSTED 16
+#define X_HOSTEDTRANSITION 17
+#define X_HOSTDIR 18
+#define X_ID 19
+#define X_IGNORE 20
+#define X_INCLUDE 21
+#define X_INITIAL 22
+#define X_KEYARGS 23
+#define X_LINE 24
+#define X_LINEBASE 25
+#define X_LINEFILE 26
+#define X_LINEID 27
+#define X_LINETYPE 28
+#define X_MACREF 29
+#define X_MAP 30
+#define X_MAPINCLUDE 31
+#define X_MODERN 32
+#define X_MULTIPLE 33
+#define X_NATIVE 34
+#define X_NOTE 35
+#define X_OPSPACE 36
+#define X_PASSTHROUGH 37
+#define X_PEDANTIC 38
+#define X_PLUSCOMMENT 39
+#define X_PLUSPLUS 40
+#define X_PLUSSPLICE 41
+#define X_PRAGMAFLAGS 42
+#define X_PRAGMAEXPAND 43
+#define X_PREDEFINED 44
+#define X_PREFIX 45
+#define X_PRESERVE 46
+#define X_PROTO 47
+#define X_PROTOTYPED 48
+#define X_QUOTE 49
+#define X_READONLY 50
+#define X_REGUARD 51
+#define X_RESERVED 52
+#define X_SPACEOUT 53
+#define X_SPLICECAT 54
+#define X_SPLICESPACE 55
+#define X_STANDARD 56
+#define X_STATEMENT 57
+#define X_STRICT 58
+#define X_STRINGSPAN 59
+#define X_STRINGSPLIT 60
+#define X_SYSTEM_HEADER 61
+#define X_TEST 62
+#define X_TEXT 63
+#define X_TRANSITION 64
+#define X_TRUNCATE 65
+#define X_VENDOR 66
+#define X_VERSION 67
+#define X_WARN 68
+#define X_ZEOF 69
+#define X_last_option 69
+
+#define X_DEFINED 70
+#define X_EXISTS 71
+#define X_INCLUDED 72
+#define X_MATCH 73
+#define X_NOTICED 74
+#define X_OPTION 75
+#define X_SIZEOF 76
+#define X_STRCMP 77
+
+#define R_DEFINED 1
+
+#define ADD (1<<0)
+#define COLLECTING (1<<1)
+#define COMPATIBILITY (1<<2)
+#define COMPILE (1<<3)
+#define CONDITIONAL (1<<4)
+#define DEFINITION (1<<5)
+#define DIRECTIVE (1<<6)
+#define DISABLE (1<<7)
+#define EOF2NL (1<<8)
+#define ESCAPE (1<<9)
+#define FILEPOP (1<<10)
+#define HEADER (1<<11)
+#define HIDDEN (1<<12)
+#define JOINING (1<<13)
+#define NEWLINE (1<<14)
+#define NOEXPAND (1L<<15)
+#define NOSPACE (1L<<16)
+#define NOTEXT (1L<<17)
+#define NOVERTICAL (1L<<18)
+#define PASSEOF (1L<<19)
+#define PASSTHROUGH (1L<<20)
+#define QUOTE (1L<<21)
+#define SKIPCONTROL (1L<<22)
+#define SKIPMACRO (1L<<23)
+#define SPACEOUT (1L<<24)
+#define SQUOTE (1L<<25)
+#define STANDALONE (1L<<26)
+#define STRICT (1L<<27)
+#define STRIP (1L<<28)
+#define SYNCLINE (1L<<29)
+#define TRANSITION (1L<<30)
+#define WARN (1L<<31)
+
+#define ALLMULTIPLE (1<<0)
+#define BUILTIN (1<<1)
+#define CATLITERAL (1<<2)
+#define DUMP (1<<3)
+#define EXPOSE (1<<4)
+#define EXTERNALIZE (1<<5)
+#define FILEDEPS (1<<6)
+#define GENDEPS (1<<7)
+#define HEADERDEPS (1<<8)
+#define HOSTED (1<<9)
+#define HOSTEDTRANSITION (1<<10)
+#define INACTIVE (1<<11)
+#define INIT (1<<12)
+#define LOADING (1<<13)
+#define MARKC (1<<14)
+#define MARKHOSTED (1L<<15)
+#define MARKMACRO (1L<<16)
+#define PEDANTIC (1L<<17)
+#define READONLY (1L<<18)
+#define RELAX (1L<<19)
+
+#define ALLPOSSIBLE (1<<0)
+#define DEFINITIONS (1<<1)
+#define ELSEIF (1<<2)
+#define FINAL (1<<3)
+#define HEADEREXPAND (1<<4)
+#define HEADEREXPANDALL (1<<5)
+#define IGNORELINE (1<<6)
+#define INITIAL (1<<7)
+#define KEEPNOTEXT (1<<8)
+#define KEYARGS (1<<9)
+#define MODERN (1<<10)
+#define NATIVE (1<<11)
+#define NOHASH (1<<12)
+#define NOISE (1<<13)
+#define NOISEFILTER (1<<14)
+#define NOPROTO (1L<<15)
+#define PLUSCOMMENT (1L<<16)
+#define PLUSPLUS (1L<<17)
+#define PLUSSPLICE (1L<<18)
+#define PRAGMAEXPAND (1L<<19)
+#define PREDEFINED (1L<<20)
+#define PREDEFINITIONS (1L<<21)
+#define PREFIX (1L<<22)
+#define PRESERVE (1L<<23)
+#define PROTOTYPED (1L<<24)
+#define REGUARD (1L<<25)
+#define SPLICECAT (1L<<26)
+#define SPLICESPACE (1L<<27)
+#define STRINGSPAN (1L<<28)
+#define STRINGSPLIT (1L<<29)
+#define TRUNCATE (1L<<30)
+#define ZEOF (1L<<31)
+
+#define V__PRAGMA 78
+#define V_ARGC 79
+#define V_BASE 80
+#define V_DATE 81
+#define V_FILE 82
+#define V_FUNCTION 83
+#define V_LINE 84
+#define V_PATH 85
+#define V_SOURCE 86
+#define V_STDC 87
+#define V_TIME 88
+#define V_VERSION 89
+#define V_DEFAULT 90
+#define V_DIRECTIVE 91
+#define V_EMPTY 92
+#define V_GETENV 93
+#define V_GETMAC 94
+#define V_GETOPT 95
+#define V_GETPRD 96
+#define V_ITERATE 97
diff --git a/usr/src/lib/libpp/i386/pptab.h b/usr/src/lib/libpp/i386/pptab.h
new file mode 100644
index 0000000000..d153e8e65c
--- /dev/null
+++ b/usr/src/lib/libpp/i386/pptab.h
@@ -0,0 +1,152 @@
+/*
+ *
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * @(#)pp.tab (AT&T Labs Research) 2006-05-09
+ *
+ * C preprocessor tables and states
+ *
+ * + marks extensions to the standard
+ *
+ */
+
+static struct ppkeyword directives[] =
+{
+ "define", DEFINE,
+ "elif", ELIF,
+ "else", ELSE,
+ "endif", ENDIF,
+ "+endmac", ENDMAC,
+ "error", ERROR,
+ "if", IF,
+ "ifdef", IFDEF,
+ "ifndef", IFNDEF,
+ "include", INCLUDE,
+ "+let", LET,
+ "line", LINE,
+ "+macdef", MACDEF,
+ "pragma", PRAGMA,
+ "+rename", RENAME,
+ "undef", UNDEF,
+ "+warning", WARNING,
+ 0, 0
+};
+
+static struct ppkeyword options[] =
+{
+ "allmultiple", X_ALLMULTIPLE,
+ "allpossible", X_ALLPOSSIBLE,
+ "builtin", X_BUILTIN,
+ "catliteral", X_CATLITERAL,
+ "cdir", X_CDIR,
+ "checkpoint", X_CHECKPOINT,
+ "chop", X_CHOP,
+ "compatibility", X_COMPATIBILITY,
+ "debug", X_DEBUG,
+ "elseif", X_ELSEIF,
+ "externalize", X_EXTERNALIZE,
+ "final", X_FINAL,
+ "hide", X_HIDE,
+ "headerexpand", X_HEADEREXPAND,
+ "headerexpandall", X_HEADEREXPANDALL,
+ "hosted", X_HOSTED,
+ "hostedtransition", X_HOSTEDTRANSITION,
+ "hostdir", X_HOSTDIR,
+ "id", X_ID,
+ "ignore", X_IGNORE,
+ "include", X_INCLUDE,
+ "initial", X_INITIAL,
+ "keyargs", X_KEYARGS,
+ "line", X_LINE,
+ "linebase", X_LINEBASE,
+ "linefile", X_LINEFILE,
+ "lineid", X_LINEID,
+ "linetype", X_LINETYPE,
+ "macref", X_MACREF,
+ "map", X_MAP,
+ "mapinclude", X_MAPINCLUDE,
+ "modern", X_MODERN,
+ "multiple", X_MULTIPLE,
+ "native", X_NATIVE,
+ "note", X_NOTE,
+ "opspace", X_OPSPACE,
+ "passthrough", X_PASSTHROUGH,
+ "pedantic", X_PEDANTIC,
+ "pluscomment", X_PLUSCOMMENT,
+ "plusplus", X_PLUSPLUS,
+ "plussplice", X_PLUSSPLICE,
+ "pragmaflags", X_PRAGMAFLAGS,
+ "pragmaexpand", X_PRAGMAEXPAND,
+ "predefined", X_PREDEFINED,
+ "prefix", X_PREFIX,
+ "preserve", X_PRESERVE,
+ "proto", X_PROTO,
+ "prototyped", X_PROTOTYPED,
+ "quote", X_QUOTE,
+ "readonly", X_READONLY,
+ "reguard", X_REGUARD,
+ "reserved", X_RESERVED,
+ "spaceout", X_SPACEOUT,
+ "splicecat", X_SPLICECAT,
+ "splicespace", X_SPLICESPACE,
+ "standard", X_STANDARD,
+ "statement", X_STATEMENT,
+ "strict", X_STRICT,
+ "stringspan", X_STRINGSPAN,
+ "stringsplit", X_STRINGSPLIT,
+ "system_header", X_SYSTEM_HEADER,
+ "test", X_TEST,
+ "text", X_TEXT,
+ "transition", X_TRANSITION,
+ "truncate", X_TRUNCATE,
+ "vendor", X_VENDOR,
+ "version", X_VERSION,
+ "warn", X_WARN,
+ "zeof", X_ZEOF,
+ 0, 0
+};
+
+static struct ppkeyword predicates[] =
+{
+ "defined", X_DEFINED,
+ "+exists", X_EXISTS,
+ "+included", X_INCLUDED,
+ "+match", X_MATCH,
+ "+noticed", X_NOTICED,
+ "+option", X_OPTION,
+ "sizeof", X_SIZEOF,
+ "+strcmp", X_STRCMP,
+ 0, 0
+};
+
+static struct ppkeyword readonlys[] =
+{
+ "defined", R_DEFINED,
+ 0, 0
+};
+
+static struct ppkeyword variables[] =
+{
+ "_Pragma", V__PRAGMA,
+ "+ARGC", V_ARGC,
+ "+BASE", V_BASE,
+ "DATE", V_DATE,
+ "FILE", V_FILE,
+ "+FUNCTION", V_FUNCTION,
+ "LINE", V_LINE,
+ "+PATH", V_PATH,
+ "+SOURCE", V_SOURCE,
+ "-STDC", V_STDC,
+ "TIME", V_TIME,
+ "+VERSION", V_VERSION,
+ "-default", V_DEFAULT,
+ "-directive", V_DIRECTIVE,
+ "-empty", V_EMPTY,
+ "-getenv", V_GETENV,
+ "-getmac", V_GETMAC,
+ "-getopt", V_GETOPT,
+ "-getprd", V_GETPRD,
+ "-iterate", V_ITERATE,
+ 0, 0
+};
diff --git a/usr/src/lib/libpp/mapfile-vers b/usr/src/lib/libpp/mapfile-vers
new file mode 100644
index 0000000000..43e4584b85
--- /dev/null
+++ b/usr/src/lib/libpp/mapfile-vers
@@ -0,0 +1,39 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+SUNWprivate_1.1 {
+ global:
+ pp;
+ ppop;
+ pplex;
+ ppinput;
+ ppargs;
+
+ local:
+ *;
+};
diff --git a/usr/src/lib/libpp/sparc/Makefile b/usr/src/lib/libpp/sparc/Makefile
new file mode 100644
index 0000000000..f91f0270e9
--- /dev/null
+++ b/usr/src/lib/libpp/sparc/Makefile
@@ -0,0 +1,30 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/usr/src/lib/libpp/sparc/pp.req b/usr/src/lib/libpp/sparc/pp.req
new file mode 100644
index 0000000000..6c6437695b
--- /dev/null
+++ b/usr/src/lib/libpp/sparc/pp.req
@@ -0,0 +1,2 @@
+ -lpp
+ -last
diff --git a/usr/src/lib/libpp/sparc/pp.yacc b/usr/src/lib/libpp/sparc/pp.yacc
new file mode 100644
index 0000000000..1de9080a7a
--- /dev/null
+++ b/usr/src/lib/libpp/sparc/pp.yacc
@@ -0,0 +1 @@
+%token /*generated from pp.h*/ T_DOUBLE 292 T_DOUBLE_L 293 T_FLOAT 294 T_DECIMAL 288 T_DECIMAL_L 289 T_DECIMAL_U 290 T_DECIMAL_UL 291 T_OCTAL 296 T_OCTAL_L 297 T_OCTAL_U 298 T_OCTAL_UL 299 T_HEXADECIMAL 304 T_HEXADECIMAL_L 305 T_HEXADECIMAL_U 306 T_HEXADECIMAL_UL 307 T_HEXDOUBLE 308 T_HEXDOUBLE_L 309 T_ID 257 T_INVALID 258 T_CHARCONST 260 T_WCHARCONST 261 T_STRING 262 T_WSTRING 263 T_PTRMEM 264 T_ADDADD 265 T_SUBSUB 266 T_LSHIFT 267 T_RSHIFT 268 T_LE 269 T_GE 270 T_EQ 271 T_NE 272 T_ANDAND 273 T_OROR 274 T_MPYEQ 275 T_DIVEQ 276 T_MODEQ 277 T_ADDEQ 278 T_SUBEQ 279 T_LSHIFTEQ 280 T_RSHIFTEQ 281 T_ANDEQ 282 T_XOREQ 283 T_OREQ 284 T_VARIADIC 286 T_DOTREF 320 T_PTRMEMREF 321 T_SCOPE 322 T_UMINUS 323
diff --git a/usr/src/lib/libpp/sparc/ppdebug.h b/usr/src/lib/libpp/sparc/ppdebug.h
new file mode 100644
index 0000000000..9c9f29e795
--- /dev/null
+++ b/usr/src/lib/libpp/sparc/ppdebug.h
@@ -0,0 +1,211 @@
+/*
+* preprocessor library debug maps
+*/
+struct map
+{
+ char* nam;
+ long val;
+};
+static struct map pplexmap[] =
+{
+ "PROTO", PROTO,
+ "RES1", RES1,
+ "RES1a", RES1a,
+ "RES1e", RES1e,
+ "RES1f", RES1f,
+ "RES1h", RES1h,
+ "RES1l", RES1l,
+ "RES1n", RES1n,
+ "RES1o", RES1o,
+ "RES1t", RES1t,
+ "RES1x", RES1x,
+ "RES1y", RES1y,
+ "COM1", COM1,
+ "COM2", COM2,
+ "COM3", COM3,
+ "COM4", COM4,
+ "COM5", COM5,
+ "COM6", COM6,
+ "COM7", COM7,
+ "NID", NID,
+ "LIT", LIT,
+ "LIT1", LIT1,
+ "LIT2", LIT2,
+ "BAD1", BAD1,
+ "BAD2", BAD2,
+ "DOT", DOT,
+ "DOT2", DOT2,
+ "WS1", WS1,
+ "QUICK", QUICK,
+ "QTOK", QTOK,
+ "QNUM", QNUM,
+ "QEXP", QEXP,
+ "QCOM", QCOM,
+ "QID", QID,
+ "MAC0", MAC0,
+ "MACN", MACN,
+ "HIT0", HIT0,
+ "HITN", HITN,
+ "LIT0", LIT0,
+ "SHARP1", SHARP1,
+ "TOKEN", TOKEN,
+ "OCT1", OCT1,
+ "OCT2", OCT2,
+ "OCT3", OCT3,
+ "NOT1", NOT1,
+ "PCT1", PCT1,
+ "AND1", AND1,
+ "STAR1", STAR1,
+ "PLUS1", PLUS1,
+ "MINUS1", MINUS1,
+ "ARROW1", ARROW1,
+ "COLON1", COLON1,
+ "LT1", LT1,
+ "LSH1", LSH1,
+ "EQ1", EQ1,
+ "RSH1", RSH1,
+ "GT1", GT1,
+ "CIRC1", CIRC1,
+ "OR1", OR1,
+ "DEC1", DEC1,
+ "DEC2", DEC2,
+ "HEX1", HEX1,
+ "HEX2", HEX2,
+ "HEX3", HEX3,
+ "HEX4", HEX4,
+ "HEX5", HEX5,
+ "HEX6", HEX6,
+ "HEX7", HEX7,
+ "HEX8", HEX8,
+ "DBL1", DBL1,
+ "DBL2", DBL2,
+ "DBL3", DBL3,
+ "DBL4", DBL4,
+ "DBL5", DBL5,
+ "DOT1", DOT1,
+ "HDR1", HDR1,
+ "BIN1", BIN1,
+ "TERMINAL", TERMINAL,
+ "S_CHRB", S_CHRB,
+ "S_COMMENT", S_COMMENT,
+ "S_EOB", S_EOB,
+ "S_LITBEG", S_LITBEG,
+ "S_LITEND", S_LITEND,
+ "S_LITESC", S_LITESC,
+ "S_MACRO", S_MACRO,
+ "S_NL", S_NL,
+ "S_QUAL", S_QUAL,
+ "S_SHARP", S_SHARP,
+ "S_VS", S_VS,
+ "S_CHR", S_CHR,
+ "S_HUH", S_HUH,
+ "S_TOK", S_TOK,
+ "S_TOKB", S_TOKB,
+ "S_WS", S_WS,
+ "S_RESERVED", S_RESERVED,
+};
+static struct map ppstatemap[] =
+{
+ "ADD", ADD,
+ "COLLECTING", COLLECTING,
+ "COMPATIBILITY", COMPATIBILITY,
+ "COMPILE", COMPILE,
+ "CONDITIONAL", CONDITIONAL,
+ "DEFINITION", DEFINITION,
+ "DIRECTIVE", DIRECTIVE,
+ "DISABLE", DISABLE,
+ "EOF2NL", EOF2NL,
+ "ESCAPE", ESCAPE,
+ "FILEPOP", FILEPOP,
+ "HEADER", HEADER,
+ "HIDDEN", HIDDEN,
+ "JOINING", JOINING,
+ "NEWLINE", NEWLINE,
+ "NOEXPAND", NOEXPAND,
+ "NOSPACE", NOSPACE,
+ "NOTEXT", NOTEXT,
+ "NOVERTICAL", NOVERTICAL,
+ "PASSEOF", PASSEOF,
+ "PASSTHROUGH", PASSTHROUGH,
+ "QUOTE", QUOTE,
+ "SKIPCONTROL", SKIPCONTROL,
+ "SKIPMACRO", SKIPMACRO,
+ "SPACEOUT", SPACEOUT,
+ "SQUOTE", SQUOTE,
+ "STANDALONE", STANDALONE,
+ "STRICT", STRICT,
+ "STRIP", STRIP,
+ "SYNCLINE", SYNCLINE,
+ "TRANSITION", TRANSITION,
+ "WARN", WARN,
+};
+static struct map ppmodemap[] =
+{
+ "ALLMULTIPLE", ALLMULTIPLE,
+ "BUILTIN", BUILTIN,
+ "CATLITERAL", CATLITERAL,
+ "DUMP", DUMP,
+ "EXPOSE", EXPOSE,
+ "EXTERNALIZE", EXTERNALIZE,
+ "FILEDEPS", FILEDEPS,
+ "GENDEPS", GENDEPS,
+ "HEADERDEPS", HEADERDEPS,
+ "HOSTED", HOSTED,
+ "HOSTEDTRANSITION", HOSTEDTRANSITION,
+ "INACTIVE", INACTIVE,
+ "INIT", INIT,
+ "LOADING", LOADING,
+ "MARKC", MARKC,
+ "MARKHOSTED", MARKHOSTED,
+ "MARKMACRO", MARKMACRO,
+ "PEDANTIC", PEDANTIC,
+ "READONLY", READONLY,
+ "RELAX", RELAX,
+};
+static struct map ppoptionmap[] =
+{
+ "ELSEIF", ELSEIF,
+ "FINAL", FINAL,
+ "HEADEREXPAND", HEADEREXPAND,
+ "HEADEREXPANDALL", HEADEREXPANDALL,
+ "IGNORELINE", IGNORELINE,
+ "INITIAL", INITIAL,
+ "KEEPNOTEXT", KEEPNOTEXT,
+ "KEYARGS", KEYARGS,
+ "MODERN", MODERN,
+ "NATIVE", NATIVE,
+ "NOHASH", NOHASH,
+ "NOISE", NOISE,
+ "NOISEFILTER", NOISEFILTER,
+ "NOPROTO", NOPROTO,
+ "PLUSCOMMENT", PLUSCOMMENT,
+ "PLUSPLUS", PLUSPLUS,
+ "PLUSSPLICE", PLUSSPLICE,
+ "PRAGMAEXPAND", PRAGMAEXPAND,
+ "PREDEFINED", PREDEFINED,
+ "PREDEFINITIONS", PREDEFINITIONS,
+ "PREFIX", PREFIX,
+ "PRESERVE", PRESERVE,
+ "PROTOTYPED", PROTOTYPED,
+ "REGUARD", REGUARD,
+ "SPLICECAT", SPLICECAT,
+ "SPLICESPACE", SPLICESPACE,
+ "STRINGSPAN", STRINGSPAN,
+ "STRINGSPLIT", STRINGSPLIT,
+ "TRUNCATE", TRUNCATE,
+ "ZEOF", ZEOF,
+};
+static struct map ppinmap[] =
+{
+ "BUFFER", IN_BUFFER,
+ "COPY", IN_COPY,
+ "EXPAND", IN_EXPAND,
+ "FILE", IN_FILE,
+ "INIT", IN_INIT,
+ "MACRO", IN_MACRO,
+ "MULTILINE", IN_MULTILINE,
+ "QUOTE", IN_QUOTE,
+ "RESCAN", IN_RESCAN,
+ "SQUOTE", IN_SQUOTE,
+ "STRING", IN_STRING,
+};
diff --git a/usr/src/lib/libpp/sparc/ppdef.h b/usr/src/lib/libpp/sparc/ppdef.h
new file mode 100644
index 0000000000..6cb3481f8b
--- /dev/null
+++ b/usr/src/lib/libpp/sparc/ppdef.h
@@ -0,0 +1,220 @@
+/*
+ *
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * @(#)pp.tab (AT&T Labs Research) 2006-05-09
+ *
+ * C preprocessor tables and states
+ *
+ * + marks extensions to the standard
+ *
+ */
+
+#define DEFINE 1
+#define ELIF 2
+#define ELSE 3
+#define ENDIF 4
+#define ENDMAC 5
+#define ERROR 6
+#define IF 7
+#define IFDEF 8
+#define IFNDEF 9
+#define INCLUDE 10
+#define LET 11
+#define LINE 12
+#define MACDEF 13
+#define PRAGMA 14
+#define RENAME 15
+#define UNDEF 16
+#define WARNING 17
+
+#define X_ALLMULTIPLE 1
+#define X_ALLPOSSIBLE 2
+#define X_BUILTIN 3
+#define X_CATLITERAL 4
+#define X_CDIR 5
+#define X_CHECKPOINT 6
+#define X_CHOP 7
+#define X_COMPATIBILITY 8
+#define X_DEBUG 9
+#define X_ELSEIF 10
+#define X_EXTERNALIZE 11
+#define X_FINAL 12
+#define X_HIDE 13
+#define X_HEADEREXPAND 14
+#define X_HEADEREXPANDALL 15
+#define X_HOSTED 16
+#define X_HOSTEDTRANSITION 17
+#define X_HOSTDIR 18
+#define X_ID 19
+#define X_IGNORE 20
+#define X_INCLUDE 21
+#define X_INITIAL 22
+#define X_KEYARGS 23
+#define X_LINE 24
+#define X_LINEBASE 25
+#define X_LINEFILE 26
+#define X_LINEID 27
+#define X_LINETYPE 28
+#define X_MACREF 29
+#define X_MAP 30
+#define X_MAPINCLUDE 31
+#define X_MODERN 32
+#define X_MULTIPLE 33
+#define X_NATIVE 34
+#define X_NOTE 35
+#define X_OPSPACE 36
+#define X_PASSTHROUGH 37
+#define X_PEDANTIC 38
+#define X_PLUSCOMMENT 39
+#define X_PLUSPLUS 40
+#define X_PLUSSPLICE 41
+#define X_PRAGMAFLAGS 42
+#define X_PRAGMAEXPAND 43
+#define X_PREDEFINED 44
+#define X_PREFIX 45
+#define X_PRESERVE 46
+#define X_PROTO 47
+#define X_PROTOTYPED 48
+#define X_QUOTE 49
+#define X_READONLY 50
+#define X_REGUARD 51
+#define X_RESERVED 52
+#define X_SPACEOUT 53
+#define X_SPLICECAT 54
+#define X_SPLICESPACE 55
+#define X_STANDARD 56
+#define X_STATEMENT 57
+#define X_STRICT 58
+#define X_STRINGSPAN 59
+#define X_STRINGSPLIT 60
+#define X_SYSTEM_HEADER 61
+#define X_TEST 62
+#define X_TEXT 63
+#define X_TRANSITION 64
+#define X_TRUNCATE 65
+#define X_VENDOR 66
+#define X_VERSION 67
+#define X_WARN 68
+#define X_ZEOF 69
+#define X_last_option 69
+
+#define X_DEFINED 70
+#define X_EXISTS 71
+#define X_INCLUDED 72
+#define X_MATCH 73
+#define X_NOTICED 74
+#define X_OPTION 75
+#define X_SIZEOF 76
+#define X_STRCMP 77
+
+#define R_DEFINED 1
+
+#define ADD (1<<0)
+#define COLLECTING (1<<1)
+#define COMPATIBILITY (1<<2)
+#define COMPILE (1<<3)
+#define CONDITIONAL (1<<4)
+#define DEFINITION (1<<5)
+#define DIRECTIVE (1<<6)
+#define DISABLE (1<<7)
+#define EOF2NL (1<<8)
+#define ESCAPE (1<<9)
+#define FILEPOP (1<<10)
+#define HEADER (1<<11)
+#define HIDDEN (1<<12)
+#define JOINING (1<<13)
+#define NEWLINE (1<<14)
+#define NOEXPAND (1L<<15)
+#define NOSPACE (1L<<16)
+#define NOTEXT (1L<<17)
+#define NOVERTICAL (1L<<18)
+#define PASSEOF (1L<<19)
+#define PASSTHROUGH (1L<<20)
+#define QUOTE (1L<<21)
+#define SKIPCONTROL (1L<<22)
+#define SKIPMACRO (1L<<23)
+#define SPACEOUT (1L<<24)
+#define SQUOTE (1L<<25)
+#define STANDALONE (1L<<26)
+#define STRICT (1L<<27)
+#define STRIP (1L<<28)
+#define SYNCLINE (1L<<29)
+#define TRANSITION (1L<<30)
+#define WARN (1L<<31)
+
+#define ALLMULTIPLE (1<<0)
+#define BUILTIN (1<<1)
+#define CATLITERAL (1<<2)
+#define DUMP (1<<3)
+#define EXPOSE (1<<4)
+#define EXTERNALIZE (1<<5)
+#define FILEDEPS (1<<6)
+#define GENDEPS (1<<7)
+#define HEADERDEPS (1<<8)
+#define HOSTED (1<<9)
+#define HOSTEDTRANSITION (1<<10)
+#define INACTIVE (1<<11)
+#define INIT (1<<12)
+#define LOADING (1<<13)
+#define MARKC (1<<14)
+#define MARKHOSTED (1L<<15)
+#define MARKMACRO (1L<<16)
+#define PEDANTIC (1L<<17)
+#define READONLY (1L<<18)
+#define RELAX (1L<<19)
+
+#define ALLPOSSIBLE (1<<0)
+#define DEFINITIONS (1<<1)
+#define ELSEIF (1<<2)
+#define FINAL (1<<3)
+#define HEADEREXPAND (1<<4)
+#define HEADEREXPANDALL (1<<5)
+#define IGNORELINE (1<<6)
+#define INITIAL (1<<7)
+#define KEEPNOTEXT (1<<8)
+#define KEYARGS (1<<9)
+#define MODERN (1<<10)
+#define NATIVE (1<<11)
+#define NOHASH (1<<12)
+#define NOISE (1<<13)
+#define NOISEFILTER (1<<14)
+#define NOPROTO (1L<<15)
+#define PLUSCOMMENT (1L<<16)
+#define PLUSPLUS (1L<<17)
+#define PLUSSPLICE (1L<<18)
+#define PRAGMAEXPAND (1L<<19)
+#define PREDEFINED (1L<<20)
+#define PREDEFINITIONS (1L<<21)
+#define PREFIX (1L<<22)
+#define PRESERVE (1L<<23)
+#define PROTOTYPED (1L<<24)
+#define REGUARD (1L<<25)
+#define SPLICECAT (1L<<26)
+#define SPLICESPACE (1L<<27)
+#define STRINGSPAN (1L<<28)
+#define STRINGSPLIT (1L<<29)
+#define TRUNCATE (1L<<30)
+#define ZEOF (1L<<31)
+
+#define V__PRAGMA 78
+#define V_ARGC 79
+#define V_BASE 80
+#define V_DATE 81
+#define V_FILE 82
+#define V_FUNCTION 83
+#define V_LINE 84
+#define V_PATH 85
+#define V_SOURCE 86
+#define V_STDC 87
+#define V_TIME 88
+#define V_VERSION 89
+#define V_DEFAULT 90
+#define V_DIRECTIVE 91
+#define V_EMPTY 92
+#define V_GETENV 93
+#define V_GETMAC 94
+#define V_GETOPT 95
+#define V_GETPRD 96
+#define V_ITERATE 97
diff --git a/usr/src/lib/libpp/sparc/pptab.h b/usr/src/lib/libpp/sparc/pptab.h
new file mode 100644
index 0000000000..d153e8e65c
--- /dev/null
+++ b/usr/src/lib/libpp/sparc/pptab.h
@@ -0,0 +1,152 @@
+/*
+ *
+ * Glenn Fowler
+ * AT&T Research
+ *
+ * @(#)pp.tab (AT&T Labs Research) 2006-05-09
+ *
+ * C preprocessor tables and states
+ *
+ * + marks extensions to the standard
+ *
+ */
+
+static struct ppkeyword directives[] =
+{
+ "define", DEFINE,
+ "elif", ELIF,
+ "else", ELSE,
+ "endif", ENDIF,
+ "+endmac", ENDMAC,
+ "error", ERROR,
+ "if", IF,
+ "ifdef", IFDEF,
+ "ifndef", IFNDEF,
+ "include", INCLUDE,
+ "+let", LET,
+ "line", LINE,
+ "+macdef", MACDEF,
+ "pragma", PRAGMA,
+ "+rename", RENAME,
+ "undef", UNDEF,
+ "+warning", WARNING,
+ 0, 0
+};
+
+static struct ppkeyword options[] =
+{
+ "allmultiple", X_ALLMULTIPLE,
+ "allpossible", X_ALLPOSSIBLE,
+ "builtin", X_BUILTIN,
+ "catliteral", X_CATLITERAL,
+ "cdir", X_CDIR,
+ "checkpoint", X_CHECKPOINT,
+ "chop", X_CHOP,
+ "compatibility", X_COMPATIBILITY,
+ "debug", X_DEBUG,
+ "elseif", X_ELSEIF,
+ "externalize", X_EXTERNALIZE,
+ "final", X_FINAL,
+ "hide", X_HIDE,
+ "headerexpand", X_HEADEREXPAND,
+ "headerexpandall", X_HEADEREXPANDALL,
+ "hosted", X_HOSTED,
+ "hostedtransition", X_HOSTEDTRANSITION,
+ "hostdir", X_HOSTDIR,
+ "id", X_ID,
+ "ignore", X_IGNORE,
+ "include", X_INCLUDE,
+ "initial", X_INITIAL,
+ "keyargs", X_KEYARGS,
+ "line", X_LINE,
+ "linebase", X_LINEBASE,
+ "linefile", X_LINEFILE,
+ "lineid", X_LINEID,
+ "linetype", X_LINETYPE,
+ "macref", X_MACREF,
+ "map", X_MAP,
+ "mapinclude", X_MAPINCLUDE,
+ "modern", X_MODERN,
+ "multiple", X_MULTIPLE,
+ "native", X_NATIVE,
+ "note", X_NOTE,
+ "opspace", X_OPSPACE,
+ "passthrough", X_PASSTHROUGH,
+ "pedantic", X_PEDANTIC,
+ "pluscomment", X_PLUSCOMMENT,
+ "plusplus", X_PLUSPLUS,
+ "plussplice", X_PLUSSPLICE,
+ "pragmaflags", X_PRAGMAFLAGS,
+ "pragmaexpand", X_PRAGMAEXPAND,
+ "predefined", X_PREDEFINED,
+ "prefix", X_PREFIX,
+ "preserve", X_PRESERVE,
+ "proto", X_PROTO,
+ "prototyped", X_PROTOTYPED,
+ "quote", X_QUOTE,
+ "readonly", X_READONLY,
+ "reguard", X_REGUARD,
+ "reserved", X_RESERVED,
+ "spaceout", X_SPACEOUT,
+ "splicecat", X_SPLICECAT,
+ "splicespace", X_SPLICESPACE,
+ "standard", X_STANDARD,
+ "statement", X_STATEMENT,
+ "strict", X_STRICT,
+ "stringspan", X_STRINGSPAN,
+ "stringsplit", X_STRINGSPLIT,
+ "system_header", X_SYSTEM_HEADER,
+ "test", X_TEST,
+ "text", X_TEXT,
+ "transition", X_TRANSITION,
+ "truncate", X_TRUNCATE,
+ "vendor", X_VENDOR,
+ "version", X_VERSION,
+ "warn", X_WARN,
+ "zeof", X_ZEOF,
+ 0, 0
+};
+
+static struct ppkeyword predicates[] =
+{
+ "defined", X_DEFINED,
+ "+exists", X_EXISTS,
+ "+included", X_INCLUDED,
+ "+match", X_MATCH,
+ "+noticed", X_NOTICED,
+ "+option", X_OPTION,
+ "sizeof", X_SIZEOF,
+ "+strcmp", X_STRCMP,
+ 0, 0
+};
+
+static struct ppkeyword readonlys[] =
+{
+ "defined", R_DEFINED,
+ 0, 0
+};
+
+static struct ppkeyword variables[] =
+{
+ "_Pragma", V__PRAGMA,
+ "+ARGC", V_ARGC,
+ "+BASE", V_BASE,
+ "DATE", V_DATE,
+ "FILE", V_FILE,
+ "+FUNCTION", V_FUNCTION,
+ "LINE", V_LINE,
+ "+PATH", V_PATH,
+ "+SOURCE", V_SOURCE,
+ "-STDC", V_STDC,
+ "TIME", V_TIME,
+ "+VERSION", V_VERSION,
+ "-default", V_DEFAULT,
+ "-directive", V_DIRECTIVE,
+ "-empty", V_EMPTY,
+ "-getenv", V_GETENV,
+ "-getmac", V_GETMAC,
+ "-getopt", V_GETOPT,
+ "-getprd", V_GETPRD,
+ "-iterate", V_ITERATE,
+ 0, 0
+};
diff --git a/usr/src/lib/libshell/Makefile b/usr/src/lib/libshell/Makefile
new file mode 100644
index 0000000000..bd4a38cb78
--- /dev/null
+++ b/usr/src/lib/libshell/Makefile
@@ -0,0 +1,70 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+SHELL=/usr/bin/ksh
+
+include ../Makefile.lib
+
+SUBDIRS = $(MACH)
+$(BUILD64)SUBDIRS += $(MACH64)
+
+all := TARGET= all
+clean := TARGET= clean
+clobber := TARGET= clobber
+install := TARGET= install
+lint := TARGET= lint
+_msg := TARGET= _msg
+
+.KEEP_STATE:
+
+all clean clobber install lint _msg: $(SUBDIRS)
+
+LIBRARY= libshell.a
+
+HDRS= \
+ history.h \
+ nval.h \
+ shell.h
+
+HDRDIR32= $(MACH)/include/ast
+HDRDIR64= $(MACH64)/include/ast
+include ../Makefile.asthdr
+
+install_h: $(ROOTHDRS)
+
+# We don't check these header files because they're owned by AT&T/AST
+check:
+
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
+
+# rules to install demo files in $(ROOT)/usr/demo/ksh/
+include Makefile.demo
+
+include ../Makefile.targ
diff --git a/usr/src/lib/libshell/Makefile.com b/usr/src/lib/libshell/Makefile.com
new file mode 100644
index 0000000000..6645641727
--- /dev/null
+++ b/usr/src/lib/libshell/Makefile.com
@@ -0,0 +1,168 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+SHELL=/usr/bin/ksh
+
+LIBRARY= libshell.a
+VERS= .1
+
+OBJECTS= \
+ bltins/alarm.o \
+ bltins/cd_pwd.o \
+ bltins/cflow.o \
+ bltins/getopts.o \
+ bltins/hist.o \
+ bltins/misc.o \
+ bltins/print.o \
+ bltins/read.o \
+ bltins/shiocmd_solaris.o \
+ bltins/sleep.o \
+ bltins/test.o \
+ bltins/trap.o \
+ bltins/typeset.o \
+ bltins/ulimit.o \
+ bltins/umask.o \
+ bltins/whence.o \
+ data/aliases.o \
+ data/builtins.o \
+ data/keywords.o \
+ data/lexstates.o \
+ data/limits.o \
+ data/msg.o \
+ data/options.o \
+ data/signals.o \
+ data/strdata.o \
+ data/testops.o \
+ data/variables.o \
+ edit/completion.o \
+ edit/edit.o \
+ edit/emacs.o \
+ edit/hexpand.o \
+ edit/history.o \
+ edit/vi.o \
+ sh/args.o \
+ sh/arith.o \
+ sh/array.o \
+ sh/defs.o \
+ sh/deparse.o \
+ sh/expand.o \
+ sh/fault.o \
+ sh/fcin.o \
+ sh/init.o \
+ sh/io.o \
+ sh/jobs.o \
+ sh/lex.o \
+ sh/macro.o \
+ sh/main.o \
+ sh/name.o \
+ sh/nvdisc.o \
+ sh/nvtree.o \
+ sh/parse.o \
+ sh/path.o \
+ sh/streval.o \
+ sh/string.o \
+ sh/subshell.o \
+ sh/tdump.o \
+ sh/timers.o \
+ sh/trestore.o \
+ sh/waitevent.o \
+ sh/xec.o
+
+# We are storing the object files into subdirs avoid the
+# confusion with having too many object files in the toplevel pics/
+# directory (this matches the way how the original AST build system
+# deals with this "logistic" issue) - the rules below ensure that
+# the destination directory is available.
+OBJDIRS = \
+ bltins \
+ data \
+ edit \
+ sh
+PICSDIRS= $(OBJDIRS:%=pics/%)
+mkpicdirs:
+ @mkdir -p $(PICSDIRS)
+
+include ../../Makefile.astmsg
+
+include ../../Makefile.lib
+
+# mapfile-vers does not live with the sources in in common/ to make
+# automated code updates easier.
+MAPFILES= ../mapfile-vers
+
+# Set common AST build flags (e.g., needed to support the math stuff).
+include ../../../Makefile.ast
+
+LIBS = $(DYNLIB) $(LINTLIB)
+
+# load dll, socket, and secdb libraries on demand
+LDLIBS += \
+ -lcmd \
+ -z lazyload -ldll -z nolazyload \
+ -last \
+ -z lazyload -lsocket -lsecdb -z nolazyload \
+ -lm -lc
+
+$(LINTLIB) := SRCS = $(SRCDIR)/$(LINTSRC)
+
+SRCDIR = ../common
+
+# 1. Make sure that the -D/-U defines in CPPFLAGS below are in sync
+# with usr/src/cmd/ksh/Makefile.com
+# 2. We use "=" here since using $(CPPFLAGS.master) is very tricky in our
+# case - it MUST come as the last element but future changes in -D options
+# may then cause silent breakage in the AST sources because the last -D
+# option specified overrides previous -D options so we prefer the current
+# way to explicitly list each single flag.
+CPPFLAGS = \
+ $(DTEXTDOM) $(DTS_ERRNO) \
+ -Isrc/cmd/ksh93 \
+ -I../common/include \
+ $(LIBSHELLCPPFLAGS)
+
+
+CFLAGS += \
+ $(CCVERBOSE) \
+ -xstrconst
+CFLAGS64 += \
+ $(CCVERBOSE) \
+ -xstrconst
+
+.KEEP_STATE:
+
+all: mkpicdirs .WAIT $(LIBS)
+
+#
+# libshell is not lint-clean yet; fake up a target. (You can use
+# "make lintcheck" to actually run lint; please send all lint fixes
+# upstream (to AT&T) so the next update will pull them into ON.)
+#
+lint:
+ @ print "usr/src/lib/libshell is not lint-clean: skipping"
+ @ $(TRUE)
+
+include ../../Makefile.targ
diff --git a/usr/src/lib/libshell/Makefile.demo b/usr/src/lib/libshell/Makefile.demo
new file mode 100644
index 0000000000..608f1569cb
--- /dev/null
+++ b/usr/src/lib/libshell/Makefile.demo
@@ -0,0 +1,74 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+ROOTDEMODIRBASE= $(ROOT)/usr/demo/ksh
+
+DEMOFILES= \
+ fun/dirs \
+ fun/gnaw \
+ fun/mandelbrotset1 \
+ fun/rssread \
+ fun/popd \
+ fun/pushd \
+ fun/termclock \
+ fun/title \
+ tests/shtests \
+ tests/alias.sh \
+ tests/append.sh \
+ tests/arith.sh \
+ tests/arrays.sh \
+ tests/attributes.sh \
+ tests/basic.sh \
+ tests/bracket.sh \
+ tests/builtins.sh \
+ tests/case.sh \
+ tests/comvar.sh \
+ tests/coprocess.sh \
+ tests/exit.sh \
+ tests/expand.sh \
+ tests/functions.sh \
+ tests/glob.sh \
+ tests/grep.sh \
+ tests/heredoc.sh \
+ tests/io.sh \
+ tests/nameref.sh \
+ tests/options.sh \
+ tests/path.sh \
+ tests/quoting.sh \
+ tests/quoting2.sh \
+ tests/return.sh \
+ tests/select.sh \
+ tests/substring.sh \
+ tests/sun_solaris_getconf.sh \
+ tests/tilde.sh \
+ tests/variables.sh
+
+ROOTDEMODIRS= $(ROOTDEMODIRBASE) .WAIT \
+ $(ROOTDEMODIRBASE)/fun \
+ $(ROOTDEMODIRBASE)/tests
+
+install: $(ROOTDEMODIRS) .WAIT $(ROOTDEMOFILES)
diff --git a/usr/src/lib/libshell/THIRDPARTYLICENSE b/usr/src/lib/libshell/THIRDPARTYLICENSE
new file mode 100644
index 0000000000..50c6364c06
--- /dev/null
+++ b/usr/src/lib/libshell/THIRDPARTYLICENSE
@@ -0,0 +1,245 @@
++------------------------------------------------------------------------------+
+| This license covers all software that refers to the URL |
+| http://www.opensource.org/licenses/cpl1.0.txt |
++------------------------------------------------------------------------------+
+
+Common Public License Version 1.0
+
+ THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON
+ PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF
+ THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+ 1. DEFINITIONS
+
+ "Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and
+ documentation distributed under this Agreement, and
+
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from
+ and are distributed by that particular Contributor. A Contribution
+ 'originates' from a Contributor if it was added to the Program by
+ such Contributor itself or anyone acting on such Contributor's
+ behalf. Contributions do not include additions to the Program
+ which: (i) are separate modules of software distributed in
+ conjunction with the Program under their own license agreement, and
+ (ii) are not derivative works of the Program.
+
+ "Contributor" means any person or entity that distributes the Program.
+
+ "Licensed Patents " mean patent claims licensable by a Contributor
+ which are necessarily infringed by the use or sale of its Contribution
+ alone or when combined with the Program.
+
+ "Program" means the Contributions distributed in accordance with this
+ Agreement.
+
+ "Recipient" means anyone who receives the Program under this
+ Agreement, including all Contributors.
+
+ 2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free copyright
+ license to reproduce, prepare derivative works of, publicly
+ display, publicly perform, distribute and sublicense the
+ Contribution of such Contributor, if any, and such derivative
+ works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free patent
+ license under Licensed Patents to make, use, sell, offer to sell,
+ import and otherwise transfer the Contribution of such Contributor,
+ if any, in source code and object code form. This patent license
+ shall apply to the combination of the Contribution and the Program
+ if, at the time the Contribution is added by the Contributor, such
+ addition of the Contribution causes such combination to be covered
+ by the Licensed Patents. The patent license shall not apply to any
+ other combinations which include the Contribution. No hardware per
+ se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the
+ licenses to its Contributions set forth herein, no assurances are
+ provided by any Contributor that the Program does not infringe the
+ patent or other intellectual property rights of any other entity.
+ Each Contributor disclaims any liability to Recipient for claims
+ brought by any other entity based on infringement of intellectual
+ property rights or otherwise. As a condition to exercising the
+ rights and licenses granted hereunder, each Recipient hereby
+ assumes sole responsibility to secure any other intellectual
+ property rights needed, if any. For example, if a third party
+ patent license is required to allow Recipient to distribute the
+ Program, it is Recipient's responsibility to acquire that license
+ before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has
+ sufficient copyright rights in its Contribution, if any, to grant
+ the copyright license set forth in this Agreement.
+
+ 3. REQUIREMENTS
+
+ A Contributor may choose to distribute the Program in object code form
+ under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all
+ warranties and conditions, express and implied, including
+ warranties or conditions of title and non-infringement, and implied
+ warranties or conditions of merchantability and fitness for a
+ particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all
+ liability for damages, including direct, indirect, special,
+ incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement
+ are offered by that Contributor alone and not by any other party;
+ and
+
+ iv) states that source code for the Program is available from such
+ Contributor, and informs licensees how to obtain it in a reasonable
+ manner on or through a medium customarily used for software
+ exchange.
+
+ When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the
+ Program.
+
+ Contributors may not remove or alter any copyright notices contained
+ within the Program.
+
+ Each Contributor must identify itself as the originator of its
+ Contribution, if any, in a manner that reasonably allows subsequent
+ Recipients to identify the originator of the Contribution.
+
+ 4. COMMERCIAL DISTRIBUTION
+
+ Commercial distributors of software may accept certain
+ responsibilities with respect to end users, business partners and the
+ like. While this license is intended to facilitate the commercial use
+ of the Program, the Contributor who includes the Program in a
+ commercial product offering should do so in a manner which does not
+ create potential liability for other Contributors. Therefore, if a
+ Contributor includes the Program in a commercial product offering,
+ such Contributor ("Commercial Contributor") hereby agrees to defend
+ and indemnify every other Contributor ("Indemnified Contributor")
+ against any losses, damages and costs (collectively "Losses") arising
+ from claims, lawsuits and other legal actions brought by a third party
+ against the Indemnified Contributor to the extent caused by the acts
+ or omissions of such Commercial Contributor in connection with its
+ distribution of the Program in a commercial product offering. The
+ obligations in this section do not apply to any claims or Losses
+ relating to any actual or alleged intellectual property infringement.
+ In order to qualify, an Indemnified Contributor must: a) promptly
+ notify the Commercial Contributor in writing of such claim, and b)
+ allow the Commercial Contributor to control, and cooperate with the
+ Commercial Contributor in, the defense and any related settlement
+ negotiations. The Indemnified Contributor may participate in any such
+ claim at its own expense.
+
+ For example, a Contributor might include the Program in a commercial
+ product offering, Product X. That Contributor is then a Commercial
+ Contributor. If that Commercial Contributor then makes performance
+ claims, or offers warranties related to Product X, those performance
+ claims and warranties are such Commercial Contributor's responsibility
+ alone. Under this section, the Commercial Contributor would have to
+ defend claims against the other Contributors related to those
+ performance claims and warranties, and if a court requires any other
+ Contributor to pay any damages as a result, the Commercial Contributor
+ must pay those damages.
+
+ 5. NO WARRANTY
+
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+ PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
+ WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
+ OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+ responsible for determining the appropriateness of using and
+ distributing the Program and assumes all risks associated with its
+ exercise of rights under this Agreement, including but not limited to
+ the risks and costs of program errors, compliance with applicable
+ laws, damage to or loss of data, programs or equipment, and
+ unavailability or interruption of operations.
+
+ 6. DISCLAIMER OF LIABILITY
+
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
+ ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+ WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+ DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+ 7. GENERAL
+
+ If any provision of this Agreement is invalid or unenforceable under
+ applicable law, it shall not affect the validity or enforceability of
+ the remainder of the terms of this Agreement, and without further
+ action by the parties hereto, such provision shall be reformed to the
+ minimum extent necessary to make such provision valid and enforceable.
+
+ If Recipient institutes patent litigation against a Contributor with
+ respect to a patent applicable to software (including a cross-claim or
+ counterclaim in a lawsuit), then any patent licenses granted by that
+ Contributor to such Recipient under this Agreement shall terminate as
+ of the date such litigation is filed. In addition, if Recipient
+ institutes patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Program
+ itself (excluding combinations of the Program with other software or
+ hardware) infringes such Recipient's patent(s), then such Recipient's
+ rights granted under Section 2(b) shall terminate as of the date such
+ litigation is filed.
+
+ All Recipient's rights under this Agreement shall terminate if it
+ fails to comply with any of the material terms or conditions of this
+ Agreement and does not cure such failure in a reasonable period of
+ time after becoming aware of such noncompliance. If all Recipient's
+ rights under this Agreement terminate, Recipient agrees to cease use
+ and distribution of the Program as soon as reasonably practicable.
+ However, Recipient's obligations under this Agreement and any licenses
+ granted by Recipient relating to the Program shall continue and
+ survive.
+
+ Everyone is permitted to copy and distribute copies of this Agreement,
+ but in order to avoid inconsistency the Agreement is copyrighted and
+ may only be modified in the following manner. The Agreement Steward
+ reserves the right to publish new versions (including revisions) of
+ this Agreement from time to time. No one other than the Agreement
+ Steward has the right to modify this Agreement. IBM is the initial
+ Agreement Steward. IBM may assign the responsibility to serve as the
+ Agreement Steward to a suitable separate entity. Each new version of
+ the Agreement will be given a distinguishing version number. The
+ Program (including Contributions) may always be distributed subject to
+ the version of the Agreement under which it was received. In addition,
+ after a new version of the Agreement is published, Contributor may
+ elect to distribute the Program (including its Contributions) under
+ the new version. Except as expressly stated in Sections 2(a) and 2(b)
+ above, Recipient receives no rights or licenses to the intellectual
+ property of any Contributor under this Agreement, whether expressly,
+ by implication, estoppel or otherwise. All rights in the Program not
+ expressly granted under this Agreement are reserved.
+
+ This Agreement is governed by the laws of the State of New York and
+ the intellectual property laws of the United States of America. No
+ party to this Agreement will bring a legal action under this Agreement
+ more than one year after the cause of action arose. Each party waives
+ its rights to a jury trial in any resulting litigation.
+
+Copyright (c) 2004 by the Open Source Initiative
+This is a copy of the license posted on 2004-10-06 at:
+ http://www.opensource.org/licenses/cpl
diff --git a/usr/src/lib/libshell/THIRDPARTYLICENSE.descrip b/usr/src/lib/libshell/THIRDPARTYLICENSE.descrip
new file mode 100644
index 0000000000..72b0590dc6
--- /dev/null
+++ b/usr/src/lib/libshell/THIRDPARTYLICENSE.descrip
@@ -0,0 +1 @@
+PORTIONS OF AT&T KSH93 SOFTWARE (LIBSHELL)
diff --git a/usr/src/lib/libshell/amd64/Makefile b/usr/src/lib/libshell/amd64/Makefile
new file mode 100644
index 0000000000..600ff73f12
--- /dev/null
+++ b/usr/src/lib/libshell/amd64/Makefile
@@ -0,0 +1,31 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+include ../../Makefile.lib.64
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/libshell/amd64/include/ast/history.h b/usr/src/lib/libshell/amd64/include/ast/history.h
new file mode 100644
index 0000000000..55ead66f9e
--- /dev/null
+++ b/usr/src/lib/libshell/amd64/include/ast/history.h
@@ -0,0 +1,84 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+#ifndef HIST_VERSION
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+/*
+ * Interface for history mechanism
+ * written by David Korn
+ *
+ */
+
+#include <ast.h>
+
+#define HIST_CHAR '!'
+#define HIST_VERSION 1 /* history file format version no. */
+
+typedef struct
+{
+ Sfdisc_t histdisc; /* discipline for history */
+ Sfio_t *histfp; /* history file stream pointer */
+ char *histname; /* name of history file */
+ int32_t histind; /* current command number index */
+ int histsize; /* number of accessible history lines */
+#ifdef _HIST_PRIVATE
+ _HIST_PRIVATE
+#endif /* _HIST_PRIVATE */
+} History_t;
+
+typedef struct
+{
+ int hist_command;
+ int hist_line;
+ int hist_char;
+} Histloc_t;
+
+/* the following are readonly */
+extern __MANGLE__ const char hist_fname[];
+
+extern __MANGLE__ int _Hist;
+#define hist_min(hp) ((_Hist=((int)((hp)->histind-(hp)->histsize)))>=0?_Hist:0)
+#define hist_max(hp) ((int)((hp)->histind))
+/* these are the history interface routines */
+extern __MANGLE__ int sh_histinit __PROTO__((void));
+extern __MANGLE__ void hist_cancel __PROTO__((History_t*));
+extern __MANGLE__ void hist_close __PROTO__((History_t*));
+extern __MANGLE__ int hist_copy __PROTO__((char*, int, int, int));
+extern __MANGLE__ void hist_eof __PROTO__((History_t*));
+extern __MANGLE__ Histloc_t hist_find __PROTO__((History_t*,char*,int, int, int));
+extern __MANGLE__ void hist_flush __PROTO__((History_t*));
+extern __MANGLE__ void hist_list __PROTO__((History_t*,Sfio_t*, off_t, int, char*));
+extern __MANGLE__ int hist_match __PROTO__((History_t*,off_t, char*, int*));
+extern __MANGLE__ off_t hist_tell __PROTO__((History_t*,int));
+extern __MANGLE__ off_t hist_seek __PROTO__((History_t*,int));
+extern __MANGLE__ char *hist_word __PROTO__((char*, int, int));
+#if SHOPT_ESH
+ extern __MANGLE__ Histloc_t hist_locate __PROTO__((History_t*,int, int, int));
+#endif /* SHOPT_ESH */
+
+#endif /* HIST_VERSION */
diff --git a/usr/src/lib/libshell/amd64/include/ast/nval.h b/usr/src/lib/libshell/amd64/include/ast/nval.h
new file mode 100644
index 0000000000..06b18217b7
--- /dev/null
+++ b/usr/src/lib/libshell/amd64/include/ast/nval.h
@@ -0,0 +1,317 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+#ifndef NV_DEFAULT
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * Interface definitions of structures for name-value pairs
+ * These structures are used for named variables, functions and aliases
+ *
+ */
+
+
+#include <ast.h>
+#include <cdt.h>
+
+/* for compatibility with old hash library */
+#define Hashtab_t Dt_t
+#define HASH_BUCKET 1
+#define HASH_NOSCOPE 2
+#define HASH_SCOPE 4
+#define hashscope(x) dtvnext(x)
+
+typedef struct Namval Namval_t;
+typedef struct Namfun Namfun_t;
+typedef struct Namdisc Namdisc_t;
+typedef struct Nambfun Nambfun_t;
+typedef struct Namarray Namarr_t;
+typedef struct Nambltin Nambltin_t;
+typedef struct Namtype Namtype_t;
+
+/*
+ * This defines the template for nodes that have their own assignment
+ * and or lookup functions
+ */
+struct Namdisc
+{
+ size_t dsize;
+ void (*putval) __PROTO__((Namval_t*, const char*, int, Namfun_t*));
+ char *(*getval) __PROTO__((Namval_t*, Namfun_t*));
+ Sfdouble_t (*getnum) __PROTO__((Namval_t*, Namfun_t*));
+ char *(*setdisc) __PROTO__((Namval_t*, const char*, Namval_t*, Namfun_t*));
+ Namval_t *(*createf) __PROTO__((Namval_t*, const char*, int, Namfun_t*));
+ Namfun_t *(*clonef) __PROTO__((Namval_t*, Namval_t*, int, Namfun_t*));
+ char *(*namef) __PROTO__((Namval_t*, Namfun_t*));
+ Namval_t *(*nextf) __PROTO__((Namval_t*, Dt_t*, Namfun_t*));
+ Namval_t *(*typef) __PROTO__((Namval_t*, Namfun_t*));
+ int (*readf) __PROTO__((Namval_t*, Sfio_t*, int, Namfun_t*));
+};
+
+struct Namfun
+{
+ const Namdisc_t *disc;
+ char nofree;
+ char funs;
+ unsigned short dsize;
+ Namfun_t *next;
+ char *last;
+ Namval_t *type;
+};
+
+struct Nambfun
+{
+ Namfun_t fun;
+ int num;
+ const char **bnames;
+ Namval_t *bltins[1];
+};
+
+/* This is an array template header */
+struct Namarray
+{
+ Namfun_t hdr;
+ long nelem; /* number of elements */
+ __V_ *(*fun) __PROTO__((Namval_t*,const char*,int)); /* associative arrays */
+ Namval_t *parent; /* for multi-dimensional */
+};
+
+/* Passed as third argument to a builtin when NV_BLTINOPT is set on node */
+struct Nambltin
+{
+ __V_ *shp;
+ Namval_t *np;
+ __V_ *ptr;
+ __V_ *data;
+ int flags;
+};
+
+struct Namtype
+{
+ __V_ *shp;
+ Namval_t *np;
+ const char *optstring;
+ __V_ *optinfof;
+};
+
+/* attributes of name-value node attribute flags */
+
+#define NV_DEFAULT 0
+/* This defines the attributes for an attributed name-value pair node */
+struct Namval
+{
+ Dtlink_t nvlink; /* space for cdt links */
+ char *nvname; /* pointer to name of the node */
+ unsigned short nvflag; /* attributes */
+ unsigned short nvsize; /* size or base */
+#ifdef _NV_PRIVATE
+ _NV_PRIVATE
+#else
+ Namfun_t *nvfun;
+ char *nvalue;
+ char *nvprivate;
+#endif /* _NV_PRIVATE */
+};
+
+#define NV_CLASS ".sh.type"
+#define NV_MINSZ (sizeof(struct Namval)-sizeof(Dtlink_t)-sizeof(char*))
+#define nv_namptr(p,n) ((Namval_t*)((char*)(p)+(n)*NV_MINSZ-sizeof(Dtlink_t)))
+
+/* The following attributes are for internal use */
+#define NV_NOFREE 0x200 /* don't free the space when releasing value */
+#define NV_ARRAY 0x400 /* node is an array */
+#define NV_REF 0x4000 /* reference bit */
+#define NV_TABLE 0x800 /* node is a dictionary table */
+#define NV_IMPORT 0x1000 /* value imported from environment */
+#define NV_MINIMAL NV_IMPORT /* node does not contain all fields */
+
+#define NV_INTEGER 0x2 /* integer attribute */
+/* The following attributes are valid only when NV_INTEGER is off */
+#define NV_LTOU 0x4 /* convert to uppercase */
+#define NV_UTOL 0x8 /* convert to lowercase */
+#define NV_ZFILL 0x10 /* right justify and fill with leading zeros */
+#define NV_RJUST 0x20 /* right justify and blank fill */
+#define NV_LJUST 0x40 /* left justify and blank fill */
+#define NV_BINARY 0x100 /* fixed size data buffer */
+#define NV_RAW NV_LJUST /* used only with NV_BINARY */
+#define NV_HOST (NV_RJUST|NV_LJUST) /* map to host filename */
+
+/* The following attributes do not effect the value */
+#define NV_RDONLY 0x1 /* readonly bit */
+#define NV_EXPORT 0x2000 /* export bit */
+#define NV_TAGGED 0x8000 /* user define tag bit */
+
+/* The following are used with NV_INTEGER */
+#define NV_SHORT (NV_RJUST) /* when integers are not long */
+#define NV_LONG (NV_UTOL) /* for long long and long double */
+#define NV_UNSIGN (NV_LTOU) /* for unsigned quantities */
+#define NV_DOUBLE (NV_ZFILL) /* for floating point */
+#define NV_EXPNOTE (NV_LJUST) /* for scientific notation */
+
+/* options for nv_open */
+
+#define NV_APPEND 0x10000 /* append value */
+#define NV_MOVE 0x20000 /* for use with nv_clone */
+#define NV_ADD 8
+ /* add node if not found */
+#define NV_ASSIGN NV_NOFREE /* assignment is possible */
+#define NV_NOASSIGN 0 /* backward compatibility */
+#define NV_NOARRAY 0x200000 /* array name not possible */
+#define NV_IARRAY 0x400000 /* for indexed array */
+#define NV_NOREF NV_REF /* don't follow reference */
+#define NV_IDENT 0x80 /* name must be identifier */
+#define NV_VARNAME 0x20000 /* name must be ?(.)id*(.id) */
+#define NV_NOADD 0x40000 /* do not add node */
+#define NV_NOSCOPE 0x80000 /* look only in current scope */
+#define NV_NOFAIL 0x100000 /* return 0 on failure, no msg */
+#define NV_NODISC NV_IDENT /* ignore disciplines */
+
+#define NV_FUNCT NV_IDENT /* option for nv_create */
+#define NV_BLTINOPT NV_ZFILL /* save state for optimization*/
+
+#define NV_PUBLIC (~(NV_NOSCOPE|NV_ASSIGN|NV_IDENT|NV_VARNAME|NV_NOADD))
+
+/* numeric types */
+#define NV_INT16 (NV_SHORT|NV_INTEGER)
+#define NV_UINT16 (NV_UNSIGN|NV_SHORT|NV_INTEGER)
+#define NV_INT32 (NV_INTEGER)
+#define NV_UNT32 (NV_UNSIGN|NV_INTEGER)
+#define NV_INT64 (NV_LONG|NV_INTEGER)
+#define NV_UINT64 (NV_UNSIGN|NV_LONG|NV_INTEGER)
+#define NV_FLOAT (NV_SHORT|NV_DOUBLE|NV_INTEGER)
+#define NV_LDOUBLE (NV_LONG|NV_DOUBLE|NV_INTEGER)
+
+/* name-value pair macros */
+#define nv_isattr(np,f) ((np)->nvflag & (f))
+#define nv_onattr(n,f) ((n)->nvflag |= (f))
+#define nv_offattr(n,f) ((n)->nvflag &= ~(f))
+#define nv_isarray(np) (nv_isattr((np),NV_ARRAY))
+
+/* The following are operations for associative arrays */
+#define NV_AINIT 1 /* initialize */
+#define NV_AFREE 2 /* free array */
+#define NV_ANEXT 3 /* advance to next subscript */
+#define NV_ANAME 4 /* return subscript name */
+#define NV_ADELETE 5 /* delete current subscript */
+#define NV_AADD 6 /* add subscript if not found */
+#define NV_ACURRENT 7 /* return current subscript Namval_t* */
+
+/* The following are for nv_disc */
+#define NV_FIRST 1
+#define NV_LAST 2
+#define NV_POP 3
+#define NV_CLONE 4
+
+/* The following are operations for nv_putsub() */
+#define ARRAY_BITS 24
+#define ARRAY_ADD (1L<<ARRAY_BITS) /* add subscript if not found */
+#define ARRAY_SCAN (2L<<ARRAY_BITS) /* For ${array[@]} */
+#define ARRAY_UNDEF (4L<<ARRAY_BITS) /* For ${array} */
+
+
+/* These are disciplines provided by the library for use with nv_discfun */
+#define NV_DCADD 0 /* used to add named disciplines */
+#define NV_DCRESTRICT 1 /* variable that are restricted in rsh */
+
+#if defined(__EXPORT__) && defined(_DLL)
+# ifdef _BLD_shell
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+# else
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+# endif /* _BLD_shell */
+#endif /* _DLL */
+/* prototype for array interface*/
+extern __MANGLE__ Namarr_t *nv_setarray __PROTO__((Namval_t*,__V_*(*)(Namval_t*,const char*,int)));
+extern __MANGLE__ __V_ *nv_associative __PROTO__((Namval_t*,const char*,int));
+extern __MANGLE__ int nv_aindex __PROTO__((Namval_t*));
+extern __MANGLE__ int nv_nextsub __PROTO__((Namval_t*));
+extern __MANGLE__ char *nv_getsub __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_putsub __PROTO__((Namval_t*, char*, long));
+extern __MANGLE__ Namval_t *nv_opensub __PROTO__((Namval_t*));
+
+/* name-value pair function prototypes */
+extern __MANGLE__ int nv_adddisc __PROTO__((Namval_t*, const char**, Namval_t**));
+extern __MANGLE__ int nv_clone __PROTO__((Namval_t*, Namval_t*, int));
+extern __MANGLE__ void nv_close __PROTO__((Namval_t*));
+extern __MANGLE__ __V_ *nv_context __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_create __PROTO__((const char*, Dt_t*, int,Namfun_t*));
+extern __MANGLE__ Dt_t *nv_dict __PROTO__((Namval_t*));
+extern __MANGLE__ Sfdouble_t nv_getn __PROTO__((Namval_t*, Namfun_t*));
+extern __MANGLE__ Sfdouble_t nv_getnum __PROTO__((Namval_t*));
+extern __MANGLE__ char *nv_getv __PROTO__((Namval_t*, Namfun_t*));
+extern __MANGLE__ char *nv_getval __PROTO__((Namval_t*));
+extern __MANGLE__ Namfun_t *nv_hasdisc __PROTO__((Namval_t*, const Namdisc_t*));
+extern __MANGLE__ int nv_isnull __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_lastdict __PROTO__((void));
+extern __MANGLE__ void nv_newattr __PROTO__((Namval_t*,unsigned,int));
+extern __MANGLE__ Namval_t *nv_open __PROTO__((const char*,Dt_t*,int));
+extern __MANGLE__ void nv_putval __PROTO__((Namval_t*,const char*,int));
+extern __MANGLE__ void nv_putv __PROTO__((Namval_t*,const char*,int,Namfun_t*));
+extern __MANGLE__ int nv_scan __PROTO__((Dt_t*,void(*)(Namval_t*,__V_*),__V_*,int,int));
+extern __MANGLE__ Namval_t *nv_scoped __PROTO__((Namval_t*));
+extern __MANGLE__ char *nv_setdisc __PROTO__((Namval_t*,const char*,Namval_t*,Namfun_t*));
+extern __MANGLE__ void nv_setref __PROTO__((Namval_t*, Dt_t*,int));
+extern __MANGLE__ int nv_settype __PROTO__((Namval_t*, Namval_t*, int));
+extern __MANGLE__ void nv_setvec __PROTO__((Namval_t*,int,int,char*[]));
+extern __MANGLE__ void nv_setvtree __PROTO__((Namval_t*));
+extern __MANGLE__ int nv_setsize __PROTO__((Namval_t*,int));
+extern __MANGLE__ Namfun_t *nv_disc __PROTO__((Namval_t*,Namfun_t*,int));
+extern __MANGLE__ void nv_unset __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_search __PROTO__((const char *, Dt_t*, int));
+extern __MANGLE__ void nv_unscope __PROTO__((void));
+extern __MANGLE__ char *nv_name __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_type __PROTO__((Namval_t*));
+extern __MANGLE__ const Namdisc_t *nv_discfun __PROTO__((int));
+
+#ifdef _DLL
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif /* _DLL */
+
+#define nv_size(np) nv_setsize((np),-1)
+#define nv_stack(np,nf) nv_disc(np,nf,0)
+
+#if 0
+/*
+ * The names of many functions were changed in early '95
+ * Here is a mapping to the old names
+ */
+# define nv_istype(np) nv_isattr(np)
+# define nv_newtype(np) nv_newattr(np)
+# define nv_namset(np,a,b) nv_open(np,a,b)
+# define nv_free(np) nv_unset(np)
+# define nv_settype(np,a,b,c) nv_setdisc(np,a,b,c)
+# define nv_search(np,a,b) nv_open(np,a,((b)?0:NV_NOADD))
+# define settype setdisc
+#endif
+
+#endif /* NV_DEFAULT */
diff --git a/usr/src/lib/libshell/amd64/include/ast/shell.h b/usr/src/lib/libshell/amd64/include/ast/shell.h
new file mode 100644
index 0000000000..37cafa932b
--- /dev/null
+++ b/usr/src/lib/libshell/amd64/include/ast/shell.h
@@ -0,0 +1,256 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+#ifndef SH_INTERACTIVE
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * Interface definitions for shell command language
+ *
+ */
+
+#include <cmd.h>
+#include <cdt.h>
+#ifdef _SH_PRIVATE
+# include "name.h"
+#else
+# include <nval.h>
+#endif /* _SH_PRIVATE */
+
+#define SH_VERSION 20060510
+
+#undef NOT_USED
+#define NOT_USED(x) (&x,1)
+
+/* options */
+typedef struct
+{
+ unsigned long v[4];
+}
+Shopt_t;
+
+typedef void (*Shinit_f) __PROTO__((int));
+typedef int (*Shbltin_f) __PROTO__((int, char*[], __V_*));
+typedef int (*Shwait_f) __PROTO__((int, long, int));
+
+union Shnode_u;
+typedef union Shnode_u Shnode_t;
+
+#define SH_CFLAG 0
+#define SH_HISTORY 1 /* used also as a state */
+#define SH_ERREXIT 2 /* used also as a state */
+#define SH_VERBOSE 3 /* used also as a state */
+#define SH_MONITOR 4 /* used also as a state */
+#define SH_INTERACTIVE 5 /* used also as a state */
+#define SH_RESTRICTED 6
+#define SH_XTRACE 7
+#define SH_KEYWORD 8
+#define SH_NOUNSET 9
+#define SH_NOGLOB 10
+#define SH_ALLEXPORT 11
+#define SH_PFSH 12
+#define SH_IGNOREEOF 13
+#define SH_NOCLOBBER 14
+#define SH_MARKDIRS 15
+#define SH_BGNICE 16
+#define SH_VI 17
+#define SH_VIRAW 18
+#define SH_TFLAG 19
+#define SH_TRACKALL 20
+#define SH_SFLAG 21
+#define SH_NOEXEC 22
+#define SH_GMACS 24
+#define SH_EMACS 25
+#define SH_PRIVILEGED 26
+#define SH_SUBSHARE 27 /* subshell shares state with parent */
+#define SH_NOLOG 28
+#define SH_NOTIFY 29
+#define SH_DICTIONARY 30
+#define SH_PIPEFAIL 32
+#define SH_GLOBSTARS 33
+#define SH_XARGS 34
+#define SH_RC 35
+#define SH_SHOWME 36
+
+/*
+ * passed as flags to builtins in Nambltin_t struct when BLT_OPTIM is on
+ */
+#define SH_BEGIN_OPTIM 0x1
+#define SH_END_OPTIM 0x2
+
+/* The following type is used for error messages */
+
+/* error messages */
+extern __MANGLE__ const char e_defpath[];
+extern __MANGLE__ const char e_found[];
+extern __MANGLE__ const char e_nospace[];
+extern __MANGLE__ const char e_format[];
+extern __MANGLE__ const char e_number[];
+extern __MANGLE__ const char e_restricted[];
+extern __MANGLE__ const char e_recursive[];
+extern __MANGLE__ char e_version[];
+
+typedef struct sh_scope
+{
+ struct sh_scope *par_scope;
+ int argc;
+ char **argv;
+ char *cmdname;
+ char *filename;
+ int lineno;
+ Dt_t *var_tree;
+ struct sh_scope *self;
+} Shscope_t;
+
+/*
+ * Saves the state of the shell
+ */
+
+typedef struct sh_static
+{
+ Shopt_t options; /* set -o options */
+ Dt_t *var_tree; /* for shell variables */
+ Dt_t *fun_tree; /* for shell functions */
+ Dt_t *alias_tree; /* for alias names */
+ Dt_t *bltin_tree; /* for builtin commands */
+ Shscope_t *topscope; /* pointer to top-level scope */
+ int inlineno; /* line number of current input file */
+ int exitval; /* most recent exit value */
+ unsigned char trapnote; /* set when trap/signal is pending */
+ char subshell; /* set for virtual subshell */
+#ifdef _SH_PRIVATE
+ _SH_PRIVATE
+#endif /* _SH_PRIVATE */
+} Shell_t;
+
+/* flags for sh_parse */
+#define SH_NL 1 /* Treat new-lines as ; */
+#define SH_EOF 2 /* EOF causes syntax error */
+
+/* symbolic values for sh_iogetiop */
+#define SH_IOCOPROCESS (-2)
+#define SH_IOHISTFILE (-3)
+
+/* symbolic value for sh_fdnotify */
+#define SH_FDCLOSE (-1)
+
+#if defined(__EXPORT__) && defined(_DLL)
+# ifdef _BLD_shell
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+# endif /* _BLD_shell */
+#endif /* _DLL */
+
+extern __MANGLE__ Dt_t *sh_bltin_tree __PROTO__((void));
+extern __MANGLE__ void sh_subfork __PROTO__((void));
+extern __MANGLE__ Shell_t *sh_init __PROTO__((int,char*[],Shinit_f));
+extern __MANGLE__ int sh_reinit __PROTO__((char*[]));
+extern __MANGLE__ int sh_eval __PROTO__((Sfio_t*,int));
+extern __MANGLE__ void sh_delay __PROTO__((double));
+extern __MANGLE__ __V_ *sh_parse __PROTO__((Shell_t*, Sfio_t*,int));
+extern __MANGLE__ int sh_trap __PROTO__((const char*,int));
+extern __MANGLE__ int sh_fun __PROTO__((Namval_t*,Namval_t*, char*[]));
+extern __MANGLE__ int sh_funscope __PROTO__((int,char*[],int(*)(__V_*),__V_*,int));
+extern __MANGLE__ Sfio_t *sh_iogetiop __PROTO__((int,int));
+extern __MANGLE__ int sh_main __PROTO__((int, char*[], void(*)(int)));
+extern __MANGLE__ void sh_menu __PROTO__((Sfio_t*, int, char*[]));
+extern __MANGLE__ Namval_t *sh_addbuiltin __PROTO__((const char*, int(*)(int, char*[],__V_*), __V_*));
+extern __MANGLE__ char *sh_fmtq __PROTO__((const char*));
+extern __MANGLE__ char *sh_fmtqf __PROTO__((const char*, int, int));
+extern __MANGLE__ Sfdouble_t sh_strnum __PROTO__((const char*, char**, int));
+extern __MANGLE__ int sh_access __PROTO__((const char*,int));
+extern __MANGLE__ int sh_close __PROTO__((int));
+extern __MANGLE__ int sh_dup __PROTO__((int));
+extern __MANGLE__ void sh_exit __PROTO__((int));
+extern __MANGLE__ int sh_fcntl __PROTO__((int, int, ...));
+extern __MANGLE__ Sfio_t *sh_fd2sfio __PROTO__((int));
+extern __MANGLE__ int (*sh_fdnotify __PROTO__((int(*)(int,int)))) __PROTO__((int,int));
+extern __MANGLE__ Shell_t *sh_getinterp __PROTO__((void));
+extern __MANGLE__ int sh_open __PROTO__((const char*, int, ...));
+extern __MANGLE__ int sh_openmax __PROTO__((void));
+extern __MANGLE__ Sfio_t *sh_pathopen __PROTO__((const char*));
+extern __MANGLE__ ssize_t sh_read __PROTO__((int, __V_*, size_t));
+extern __MANGLE__ ssize_t sh_write __PROTO__((int, const __V_*, size_t));
+extern __MANGLE__ off_t sh_seek __PROTO__((int, off_t, int));
+extern __MANGLE__ int sh_pipe __PROTO__((int[]));
+extern __MANGLE__ mode_t sh_umask __PROTO__((mode_t));
+extern __MANGLE__ __V_ *sh_waitnotify __PROTO__((Shwait_f));
+extern __MANGLE__ Shscope_t *sh_getscope __PROTO__((int,int));
+extern __MANGLE__ Shscope_t *sh_setscope __PROTO__((Shscope_t*));
+extern __MANGLE__ void sh_sigcheck __PROTO__((void));
+extern __MANGLE__ unsigned long sh_isoption __PROTO__((int));
+extern __MANGLE__ unsigned long sh_onoption __PROTO__((int));
+extern __MANGLE__ unsigned long sh_offoption __PROTO__((int));
+extern __MANGLE__ int sh_waitsafe __PROTO__((void));
+extern __MANGLE__ int sh_exec __PROTO__((const Shnode_t*,int));
+
+#if SHOPT_DYNAMIC
+ extern __MANGLE__ __V_ **sh_getliblist __PROTO__((void));
+#endif /* SHOPT_DYNAMIC */
+
+/*
+ * direct access to sh is obsolete, use sh_getinterp() instead
+ */
+#if !defined(_SH_PRIVATE) && defined(__IMPORT__) && !defined(_BLD_shell)
+ extern __MANGLE__ __IMPORT__ Shell_t sh;
+#else
+ extern __MANGLE__ Shell_t sh;
+#endif
+
+#ifdef _DLL
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif /* _DLL */
+
+#ifndef _SH_PRIVATE
+# define access(a,b) sh_access(a,b)
+# define close(a) sh_close(a)
+# define exit(a) sh_exit(a)
+# define fcntl(a,b,c) sh_fcntl(a,b,c)
+# define pipe(a) sh_pipe(a)
+# define read(a,b,c) sh_read(a,b,c)
+# define write(a,b,c) sh_write(a,b,c)
+# define umask(a) sh_umask(a)
+# define dup sh_dup
+# if _lib_lseek64
+# define open64 sh_open
+# define lseek64 sh_seek
+# else
+# define open sh_open
+# define lseek sh_seek
+# endif
+#endif /* !_SH_PRIVATE */
+
+#define SH_SIGSET 4
+#define SH_EXITSIG 0400 /* signal exit bit */
+#define SH_EXITMASK (SH_EXITSIG-1) /* normal exit status bits */
+#define SH_RUNPROG -1022 /* needs to be negative and < 256 */
+
+#endif /* SH_INTERACTIVE */
diff --git a/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/acct b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/acct
new file mode 100644
index 0000000000..76cc13fbf6
--- /dev/null
+++ b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/acct
@@ -0,0 +1,12 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_acct_ksh93
+#define _def_acct_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _lib_acct 1 /* acct() in default lib(s) */
+#define _sys_acct 1 /* #include <sys/acct.h> ok */
+#endif
diff --git a/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/cmds b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/cmds
new file mode 100644
index 0000000000..57854c2559
--- /dev/null
+++ b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/cmds
@@ -0,0 +1,36 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/cmd/ksh93/features/cmds by iffe version 2007-04-04 : : */
+#ifndef _def_cmds_ksh93
+#define _def_cmds_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _cmd_newgrp 1 /* newgrp in ?(/usr)/(bin|etc|ucb) */
+#define _bin_newgrp 1 /* /bin/newgrp found */
+#define _usr_bin_newgrp 1 /* /usr/bin/newgrp found */
+#define _cmd_test 1 /* test in ?(/usr)/(bin|etc|ucb) */
+#define _bin_test 1 /* /bin/test found */
+#define _usr_bin_test 1 /* /usr/bin/test found */
+#define _usr_ucb_test 1 /* /usr/ucb/test found */
+#define _cmd_id 1 /* id in ?(/usr)/(bin|etc|ucb) */
+#define _bin_id 1 /* /bin/id found */
+#define _usr_bin_id 1 /* /usr/bin/id found */
+#define _cmd_wc 1 /* wc in ?(/usr)/(bin|etc|ucb) */
+#define _bin_wc 1 /* /bin/wc found */
+#define _usr_bin_wc 1 /* /usr/bin/wc found */
+#define _usr_ucb_wc 1 /* /usr/ucb/wc found */
+#define _cmd_cut 1 /* cut in ?(/usr)/(bin|etc|ucb) */
+#define _bin_cut 1 /* /bin/cut found */
+#define _usr_bin_cut 1 /* /usr/bin/cut found */
+#define _cmd_logname 1 /* logname in ?(/usr)/(bin|etc|ucb) */
+#define _bin_logname 1 /* /bin/logname found */
+#define _usr_bin_logname 1 /* /usr/bin/logname found */
+#define _cmd_pfexec 1 /* pfexec in ?(/usr)/(bin|etc|ucb) */
+#define _bin_pfexec 1 /* /bin/pfexec found */
+#define _usr_bin_pfexec 1 /* /usr/bin/pfexec found */
+#define _cmd_tput 1 /* tput in ?(/usr)/(bin|etc|ucb) */
+#define _bin_tput 1 /* /bin/tput found */
+#define _usr_bin_tput 1 /* /usr/bin/tput found */
+#endif
diff --git a/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/dynamic b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/dynamic
new file mode 100644
index 0000000000..f9ec2d669f
--- /dev/null
+++ b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/dynamic
@@ -0,0 +1,23 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/cmd/ksh93/features/dynamic by iffe version 2007-04-04 : : */
+#ifndef _def_dynamic_ksh93
+#define _def_dynamic_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_dlfcn 1 /* #include <dlfcn.h> ok */
+#define _sys_dl 1 /* #include <sys/dl.h> ok */
+#define _hdr_dlldefs 1 /* #include <dlldefs.h> ok */
+#define _lib_dlopen 1 /* dlopen() in default lib(s) */
+#define _lib_dllfind 1 /* dllfind() in default lib(s) */
+#if !defined(SHOPT_FS_3D) && ( _lib_dllfind || _lib_dlopen || _lib_shl_load || _lib_loadbind )
+# define SHOPT_FS_3D 1
+#endif /* !SHOPT_FS_3D */
+#if SHOPT_FS_3D
+# undef mount
+# include <fs3d.h>
+#endif /* SHOPT_FS_3D */
+
+#endif
diff --git a/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/execargs b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/execargs
new file mode 100644
index 0000000000..9db500ed8e
--- /dev/null
+++ b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/execargs
@@ -0,0 +1,10 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_execargs_ksh93
+#define _def_execargs_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#endif
diff --git a/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/externs b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/externs
new file mode 100644
index 0000000000..748f14c9df
--- /dev/null
+++ b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/externs
@@ -0,0 +1,81 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/cmd/ksh93/features/externs by iffe version 2007-04-04 : : */
+
+#ifndef _def_externs_ksh93
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_externs_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_exec_attr 1 /* #include <exec_attr.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _mem_name_exception 1 /* name is a member of struct exception */
+#define _lib_setreuid 1 /* setreuid() in default lib(s) */
+#define _lib_setregid 1 /* setregid() in default lib(s) */
+#define _lib_nice 1 /* nice() in default lib(s) */
+#define _lib_sigflag 1 /* sigflag() in default lib(s) */
+#define _lib_fork 1 /* fork() in default lib(s) */
+#define _lib_spawnveg 1 /* spawnveg() in default lib(s) */
+#define _lib_fchdir 1 /* fchdir() in default lib(s) */
+#endif
diff --git a/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/locale b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/locale
new file mode 100644
index 0000000000..d5a67a858f
--- /dev/null
+++ b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/locale
@@ -0,0 +1,38 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/cmd/ksh93/features/locale by iffe version 2007-04-04 : : */
+#ifndef _def_locale_ksh93
+#define _def_locale_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_locale 1 /* #include <locale.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _lib_localeconv 1 /* localeconv() in default lib(s) */
+#define _lib_wctype 1 /* wctype() in default lib(s) */
+#define _lib_iswctype 1 /* iswctype() in default lib(s) */
+#define _lib_iswblank 1 /* iswblank() in default lib(s) */
+#if _PACKAGE_ast
+# undef _hdr_locale
+# define _hdr_locale 1
+#else
+# ifdef _hdr_locale
+# include <locale.h>
+# ifndef LC_MESSAGES
+# define LC_MESSAGES LC_ALL
+# endif /* LC_MESSAGES */
+# endif /* _hdr_locale */
+#endif /* _PACKAGE_ast */
+#ifdef _hdr_locale
+# ifdef _lib_localeconv
+ static struct lconv *lp;
+# define GETDECIMAL(x) (((lp=localeconv()) && lp->decimal_point && *lp->decimal_point) ? *lp->decimal_point : '.' )
+# else
+# define GETDECIMAL(x) ('.')
+# endif /* _lib_localeconv */
+#else
+# define GETDECIMAL(x) ('.')
+#endif /* _hdr_locale */
+
+#endif
diff --git a/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/math b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/math
new file mode 100644
index 0000000000..843a4147cf
--- /dev/null
+++ b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/math
@@ -0,0 +1,162 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/cmd/ksh93/features/math.sh by iffe version 2007-04-04 : : */
+#ifndef _def_math_ksh93
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_math_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+
+
+/* : : generated by iffe from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/cmd/ksh93/data/math.tab : : */
+
+typedef Sfdouble_t (*Math_f) __PROTO__((Sfdouble_t,...));
+
+#include <ast_standards.h>
+#include <math.h>
+#include <ieeefp.h>
+
+static Sfdouble_t local_finite __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return finite(a1);}
+static int local_fpclassify __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return fpclassify(a1);}
+static int local_isfinite __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return isfinite(a1);}
+static int local_isgreater __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return isgreater(a1,a2);}
+static int local_isgreaterequal __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return isgreaterequal(a1,a2);}
+static int local_isinf __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return isinf(a1);}
+static int local_isless __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return isless(a1,a2);}
+static int local_islessequal __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return islessequal(a1,a2);}
+static int local_islessgreater __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return islessgreater(a1,a2);}
+static int local_isnormal __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return isnormal(a1);}
+static int local_isunordered __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return isunordered(a1,a2);}
+static int local_signbit __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return signbit(a1);}
+
+/*
+ * first byte is two-digit octal number. Last digit is number of args
+ * first digit is 0 if return value is double, 1 for integer
+ */
+const struct mathtab shtab_math[] =
+{
+ "\001acos", (Math_f)acosl,
+ "\001acosh", (Math_f)acoshl,
+ "\001asin", (Math_f)asinl,
+ "\001asinh", (Math_f)asinhl,
+ "\001atan", (Math_f)atanl,
+ "\002atan2", (Math_f)atan2l,
+ "\001atanh", (Math_f)atanhl,
+ "\001cbrt", (Math_f)cbrtl,
+ "\002copysign", (Math_f)copysignl,
+ "\001cos", (Math_f)cosl,
+ "\001cosh", (Math_f)coshl,
+ "\001erf", (Math_f)erfl,
+ "\001erfc", (Math_f)erfcl,
+ "\001exp", (Math_f)expl,
+ "\001exp2", (Math_f)exp2l,
+ "\001expm1", (Math_f)expm1l,
+ "\001fabs", (Math_f)fabsl,
+ "\001abs", (Math_f)fabsl,
+ "\002fdim", (Math_f)fdiml,
+ "\001finite", (Math_f)local_finite,
+ "\001floor", (Math_f)floorl,
+ "\001int", (Math_f)floorl,
+ "\003fma", (Math_f)fmal,
+ "\002fmax", (Math_f)fmaxl,
+ "\002fmin", (Math_f)fminl,
+ "\002fmod", (Math_f)fmodl,
+ "\011fpclassify", (Math_f)local_fpclassify,
+ "\002hypot", (Math_f)hypotl,
+ "\011ilogb", (Math_f)ilogbl,
+ "\011isfinite", (Math_f)local_isfinite,
+ "\012isgreater", (Math_f)local_isgreater,
+ "\012isgreaterequal", (Math_f)local_isgreaterequal,
+ "\011isinf", (Math_f)local_isinf,
+ "\012isless", (Math_f)local_isless,
+ "\012islessequal", (Math_f)local_islessequal,
+ "\012islessgreater", (Math_f)local_islessgreater,
+ "\011isnan", (Math_f)isnanl,
+ "\011isnormal", (Math_f)local_isnormal,
+ "\012isunordered", (Math_f)local_isunordered,
+ "\001lgamma", (Math_f)lgammal,
+ "\001log", (Math_f)logl,
+ "\001log1p", (Math_f)log1pl,
+ "\001log2", (Math_f)log2l,
+ "\001logb", (Math_f)logbl,
+ "\001nearbyint", (Math_f)nearbyintl,
+ "\002nextafter", (Math_f)nextafterl,
+ "\002nexttoward", (Math_f)nexttowardl,
+ "\002pow", (Math_f)powl,
+ "\002remainder", (Math_f)remainderl,
+ "\001rint", (Math_f)rintl,
+ "\001round", (Math_f)roundl,
+ "\002scalb", (Math_f)scalbl,
+ "\002scalbn", (Math_f)scalbnl,
+ "\011signbit", (Math_f)local_signbit,
+ "\001sin", (Math_f)sinl,
+ "\001sinh", (Math_f)sinhl,
+ "\001sqrt", (Math_f)sqrtl,
+ "\001tan", (Math_f)tanl,
+ "\001tanh", (Math_f)tanhl,
+ "\001tgamma", (Math_f)tgammal,
+ "\001trunc", (Math_f)truncl,
+ "", (Math_f)0
+};
+#endif
diff --git a/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/options b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/options
new file mode 100644
index 0000000000..e9bd00d3d5
--- /dev/null
+++ b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/options
@@ -0,0 +1,23 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/cmd/ksh93/features/options by iffe version 2007-04-04 : : */
+#ifndef _def_options_ksh93
+#define _def_options_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define SHELLMAGIC 1
+#ifndef SHOPT_DEVFD
+# define SHOPT_DEVFD 1
+#endif
+#ifndef SHOPT_PFSH
+# define SHOPT_PFSH 1
+#endif
+#undef SHOPT_TEST_L
+#undef SHOPT_UCB
+#if !_PACKAGE_ast && ( (MB_LEN_MAX-1)<=0 || !defined(_lib_mbtowc) )
+# undef SHOPT_MULTIBYTE
+#endif
+
+#endif
diff --git a/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/poll b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/poll
new file mode 100644
index 0000000000..76ab8e259f
--- /dev/null
+++ b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/poll
@@ -0,0 +1,119 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/cmd/ksh93/features/poll by iffe version 2007-04-04 : : */
+#ifndef _def_poll_ksh93
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_poll_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_poll 1 /* #include <poll.h> ok */
+#define _hdr_netinet_in 1 /* #include <netinet/in.h> ok */
+#define _sys_poll 1 /* #include <sys/poll.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _lib_select 1 /* select() in default lib(s) */
+#define _lib_poll 1 /* poll() in default lib(s) */
+#define _lib_socket 1 /* socket() in default lib(s) */
+#define _lib_htons 1 /* htons() in default lib(s) */
+#define _lib_htonl 1 /* htonl() in default lib(s) */
+#define _hdr_netdb 1 /* #include <netdb.h> ok */
+#define _lib_getaddrinfo 1 /* getaddrinfo() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _sys_select 1 /* #include <sys/select.h> ok */
+#define _typ_fd_set 1 /* fd_set is a type */
+#define _socketpair_devfd 1 /* /dev/fd/N handles socketpair() */
+
+#ifdef _lib_poll
+# define poll _SYS_poll
+#else
+# undef _hdr_poll
+# undef _sys_poll
+#endif /* _lib_poll */
+#ifdef _hdr_poll
+# include <poll.h>
+#else
+# ifdef _sys_poll
+# include <sys/poll.h>
+# endif /* _sys_poll */
+#endif /* _hdr_poll */
+#ifdef _lib_poll
+# undef poll
+ extern __MANGLE__ int poll __PROTO__((struct pollfd*,unsigned long,int));
+#endif /* _lib_poll */
+#ifdef _lib_select
+# ifndef FD_ZERO
+# define FD_ZERO(x) (*(x)=0)
+# endif /* FD_ZERO */
+# ifndef FD_SET
+# define FD_SET(n,x) (*(x)|=(1L<<(n)))
+# endif /* FD_SET */
+# ifndef _typ_fd_set
+ typedef long fd_set;
+# endif /*_typ_fd_set */
+#endif /* _lib_select */
+
+#endif
diff --git a/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/pstat b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/pstat
new file mode 100644
index 0000000000..4d6fe66e36
--- /dev/null
+++ b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/pstat
@@ -0,0 +1,10 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_pstat_ksh93
+#define _def_pstat_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#endif
diff --git a/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/rlimits b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/rlimits
new file mode 100644
index 0000000000..813ee70722
--- /dev/null
+++ b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/rlimits
@@ -0,0 +1,19 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/cmd/ksh93/features/rlimits by iffe version 2007-04-04 : : */
+#ifndef _def_rlimits_ksh93
+#define _def_rlimits_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _sys_resource 1 /* #include <sys/resource.h> ok */
+#define _lib_getrlimit 1 /* getrlimit() in default lib(s) */
+#define _lib_ulimit 1 /* ulimit() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_rlim_t 1 /* rlim_t is a type */
+#endif
diff --git a/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/setjmp b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/setjmp
new file mode 100644
index 0000000000..fa0e877cf8
--- /dev/null
+++ b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/setjmp
@@ -0,0 +1,35 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/cmd/ksh93/features/setjmp by iffe version 2007-04-04 : : */
+#ifndef _def_setjmp_ksh93
+#define _def_setjmp_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _lib_sigsetjmp 1 /* sigsetjmp() in default lib(s) */
+#define _lib__setjmp 1 /* _setjmp() in default lib(s) */
+#define _lib__longjmp 1 /* _longjmp() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_setjmp 1 /* #include <setjmp.h> ok */
+#define _typ_sigjmp_buf 1 /* sigjmp_buf is a type */
+#undef sigsetjmp
+#undef siglongjmp
+#undef sigjmp_buf
+#define sigjmp_buf jmp_buf
+#ifdef _lib__setjmp
+# define sigsetjmp(a,b) _setjmp(a)
+#else
+# define sigsetjmp(a,b) setjmp(a)
+#endif /* _lib__setjmp */
+#ifdef _lib__longjmp
+# define siglongjmp(a,b) _longjmp(a,b)
+#else
+# define siglongjmp(a,b) longjmp(a,b)
+#endif /* _lib__longjmp */
+
+#endif
diff --git a/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/sigfeatures b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/sigfeatures
new file mode 100644
index 0000000000..d8ab88e7a5
--- /dev/null
+++ b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/sigfeatures
@@ -0,0 +1,54 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/cmd/ksh93/features/sigfeatures by iffe version 2007-04-04 : : */
+#ifndef _def_sigfeatures_ksh93
+#define _def_sigfeatures_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _lib_sigrelse 1 /* sigrelse() in default lib(s) */
+#define _lib_sigprocmask 1 /* sigprocmask() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_ast 1 /* #include <ast.h> ok */
+#define _hdr_signal 1 /* #include <signal.h> ok */
+#define _typ_sigset_t 1 /* sigset_t is a type */
+#ifndef _mem_sigvec_sv_mask
+# undef _lib_sigvec
+#endif
+#ifdef _lib_sigprocmask
+# define sh_sigaction(s,action) do { sigset_t ss;\
+ sigemptyset(&ss);\
+ sigaddset(&ss,(s));\
+ sigprocmask(action,&ss,0); \
+ }while(0)
+# define sigrelease(s) sh_sigaction(s,SIG_UNBLOCK)
+# define sigblock(s) sh_sigaction(s,SIG_BLOCK)
+# define sig_begin() sh_sigaction(0,SIG_SETMASK)
+#else
+# ifndef _lib_sigblock
+# define sigblock(s)
+# endif
+# ifdef _lib_sigsetmask
+# define sigrelease(s) sigsetmask(0)
+# define sig_begin() sigsetmask(0)
+# else
+# ifdef _lib_sigrelse
+# define sigrelease sigrelse
+# define sig_begin()
+# else
+# define sig_begin() (0)
+# define sigrelease(s) (0)
+# endif /* _lib_sigrelse */
+# endif /* _lib_sigsetmask */
+#endif /* _lib_sigprocmask */
+
+#undef _SIGRTMIN
+#define _SIGRTMIN 41
+#undef _SIGRTMAX
+#define _SIGRTMAX 48
+#endif
diff --git a/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/time b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/time
new file mode 100644
index 0000000000..17539409eb
--- /dev/null
+++ b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/time
@@ -0,0 +1,28 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/cmd/ksh93/features/time by iffe version 2007-04-04 : : */
+#ifndef _def_time_ksh93
+#define _def_time_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_utime 1 /* #include <utime.h> ok */
+#define _lib_gettimeofday 1 /* gettimeofday() in default lib(s) */
+#define _lib_setitimer 1 /* setitimer() in default lib(s) */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _mem_tv_usec_timeval 1 /* tv_usec is a member of struct timeval */
+#define _lib_2_timeofday 1 /* 2 arg gettimeofday() */
+#undef _def_time
+#include <times.h>
+#define _def_time 1
+#undef timeofday
+#if _lib_2_timeofday
+#define timeofday(p) gettimeofday(p,(struct timezone*)0)
+#else
+#if _lib_1_timeofday
+#define timeofday(p) gettimeofday(p)
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/ttys b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/ttys
new file mode 100644
index 0000000000..3f877e9f7b
--- /dev/null
+++ b/usr/src/lib/libshell/amd64/src/cmd/ksh93/FEATURE/ttys
@@ -0,0 +1,19 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/src/cmd/ksh93/features/ttys by iffe version 2007-04-04 : : */
+#ifndef _def_ttys_ksh93
+#define _def_ttys_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_64bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_termios 1 /* #include <termios.h> ok */
+#define _hdr_termio 1 /* #include <termio.h> ok */
+#define _hdr_sgtty 1 /* #include <sgtty.h> ok */
+#define _sys_termios 1 /* #include <sys/termios.h> ok */
+#define _sys_termio 1 /* #include <sys/termio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _lib_tcgetattr 1 /* tcgetattr() in default lib(s) */
+#define _lib_tcgetpgrp 1 /* tcgetpgrp() in default lib(s) */
+#endif
diff --git a/usr/src/lib/libshell/common/COMPATIBILITY b/usr/src/lib/libshell/common/COMPATIBILITY
new file mode 100644
index 0000000000..8f20d44374
--- /dev/null
+++ b/usr/src/lib/libshell/common/COMPATIBILITY
@@ -0,0 +1,129 @@
+
+ KSH-93 VS. KSH-88
+
+
+The following is a list of known incompatibilities between ksh-93 and ksh-88.
+I have not include cases that are clearly bugs in ksh-88. I also have
+omitted features that are completely upward compatible.
+
+1. Functions, defined with name() with ksh-93 are compatible with
+ the POSIX standard, not with ksh-88. No local variables are
+ permitted, and there is no separate scope. Functions defined
+ with the function name syntax, maintain compatibility.
+ This also affects function traces.
+
+2. ! is now a reserved word. As a result, any command by that
+ name will no longer work with ksh-93.
+
+3. The -x attribute of alias and typeset -f is no longer
+ effective and the ENV file is only read for interactive
+ shells. You need to use FPATH to make function definitions
+ visible to scripts.
+
+4. A built-in command named command has been added which is
+ always found before the PATH search. Any script which uses
+ this name as the name of a command (or function) will not
+ be compatible.
+
+5. The output format for some built-ins has changed. In particular
+ the output format for set, typeset and alias now have single
+ quotes around values that have special characters. The output
+ for trap without arguments has a format that can be used as input.
+
+6. With ksh-88, a dollar sign ($') followed by a single quote was
+ interpreted literally. Now it is an ANSI-C string. You
+ must quote the dollar sign to get the previous behavior.
+ Also, a $ in front of a " indicates that the string needs
+ to be translated for locales other than C or POSIX. The $
+ is ignored in the C and POSIX locale.
+
+7. With ksh-88, tilde expansion did not take place inside ${...}.
+ with ksh-93, ${foo-~} will cause tilde expansion if foo is
+ not set. You need to escape the ~ for the previous behavior.
+
+8. Some changes in the tokenizing rules where made that might
+ cause some scripts with previously ambiguous use of quoting
+ to produce syntax errors.
+
+9. Programs that rely on specific exit values for the shell,
+ (rather than 0 or non-zero) may not be compatible. The
+ exit status for many shell failures has been changed.
+
+10. Built-ins in ksh-88 were always executed before looking for
+ the command in the PATH variable. This is no longer true.
+ Thus, with ksh-93, if you have the current directory first
+ in your PATH, and you have a program named test in your
+ directory, it will be executed when you type test; the
+ built-in version will be run at the point /bin is found
+ in your PATH.
+
+11. Some undocumented combinations of argument passing to ksh
+ builtins no longer works since ksh-93 is getopts conforming
+ with respect to its built-ins. For example, typeset -8i
+ previously would work as a synonym for typeset -i8.
+
+12. Command substitution and arithmetic expansion are now performed
+ on PS1, PS3, and ENV when they are expanded. Thus, ` and $(
+ as part of the value of these variables must be preceded by a \
+ to preserve their previous behavior.
+
+13. The ERRNO variable has been dropped.
+
+14. If the file name following a redirection symbol contain pattern
+ characters they will only be expanded for interactive shells.
+
+15. The arguments to a dot script will be restored when it completes.
+
+16. The list of tracked aliases is not displayed with alias unless
+ the -t option is specified.
+
+17. The POSIX standard requires that test "$arg" have exit status
+ of 0, if and only if $arg is null. However, since this breaks
+ programs that use test -t, ksh93 treats an explicit test -t
+ as if the user had entered test -t 1.
+
+18. The ^T directive of emacs mode has been changed to work the
+ way it does in gnu-emacs.
+
+19. ksh-88 allowed unbalanced parenthes within ${name op val} whereas
+ ksh-93 does not. Thus, ${foo-(} needs to be written as ${foo-\(}
+ which works with both versions.
+
+20. kill -l in ksh-93 lists only the signal names, not their numerical
+ values.
+
+21. Local variables defined by typeset are statically scoped in
+ ksh93. In ksh88 they were dynamically scoped although this
+ behavior was never documented.
+
+22. The value of the variable given to getopts is set to ? when
+ the end-of-options is reached to conform to the POSIX standard.
+
+23. Since the POSIX standard requires that octal constants be
+ recongnized, doing arithmetic on typeset -Z variables can
+ yield different results that with ksh88. Most of these
+ differences were eliminated in ksh93o.
+
+24. Starting after ksh93l, If you run ksh name, where name does
+ not contain a /, the current directory will be searched
+ before doing a path search on name as required by the POSIX
+ shell standard.
+
+25. In ksh93, cd - will output the directory that it changes
+ to on standard output as required by X/Open. With ksh88,
+ this only happened for interactive shells.
+
+26. As an undocumented feature of ksh-88, a leading 0 to an
+ assignment of an integer variable caused that variable
+ to be treated as unsigned. This behavior was removed
+ starting in ksh93p.
+
+27. The getopts builtin in ksh93 requires that optstring contain
+ a leading + to allow options to begin with a +.
+
+28. In emacs/gmacs mode, control-v will not display the version when
+ the stty lnext character is set to control-v or is unset.
+ The sequence escape control-v will display the shell version.
+
+I am interested in expanding this list so please let me know if you
+uncover any others.
diff --git a/usr/src/lib/libshell/common/DESIGN b/usr/src/lib/libshell/common/DESIGN
new file mode 100644
index 0000000000..8e35e3fc55
--- /dev/null
+++ b/usr/src/lib/libshell/common/DESIGN
@@ -0,0 +1,163 @@
+Here is an overview of the source code organization for ksh93.
+
+Directory layout:
+
+ The directory include contains header files for ksh93.
+ The files nval.h and shell.h are intended to be public
+ headers and can be used to add runtime builtin command.
+ The remainder are private.
+
+ The directory data contains readonly data files for ksh93.
+
+ The directory edit contains the code for command line
+ editing and history.
+
+ The fun directory contains some shell function such as
+ pushd, popd, and dirs.
+
+ The directory features contains files that are used to generate
+ header files in the FEATURE directory. Most of these files
+ are in a format that is processed by iffe.
+
+ The directory bltins contains code for most of the built-in
+ commands. Additional built-in commands are part of libcmd.
+
+ The directory sh contains most of the code for ksh93.
+
+ The directory tests contains a number of regression tests.
+ In most cases, when a bug gets fixed, a test is added to
+ one of these files. The regression tests can be run by
+ going to this directory and running
+ SHELL=shell_path shell_path shtests
+ where shell_path is an absolute pathname for the shell to
+ be tested.
+
+ The top level directory contains the nmake Makefile, a README,
+ and several documentation files. The RELEASE file contains
+ the list of bug fixes and new features since the original
+ ksh93 release. The file COMPATIBILITY is a list of all
+ known incompatibilities with ksh88.
+
+ The bash_pre_rc.sh is a startup script used when emulating
+ bash if the shell is compiled with SHOPT_BASH and the shell
+ is invoked as bash. The bash emulation is not complete.
+
+Include directory:
+ 1. argnod.h contains the type definitions for command
+ nodes, io nodes, argument nodes, and for positional
+ parameters.a It defines the prototypes for
+ all the positional parameters functions.
+ 2. builtins.h contains prototypes for builtins as well
+ as symbolic constants that refer to the name-pairs
+ that are associated with some of the built-ins.
+ It also contains prototypes for many of the strings.
+ 3. defs.h is the catch all for all definitions that
+ don't fit elsewhere and it includes several other
+ headers. It defines a strucuture that contains ksh
+ global data, sh, and a structure that contains per
+ function data, sh.st.
+ 4. edit.h contains definitions that are common to both
+ vi and emacs edit modes.
+ 5. env.h contains interfaces for creating and modifying
+ environment variables.
+ 6. fault.h contains prototypes for signal related
+ functions and trap and fault handling.
+ 7. fcin.h contains macro and function definitions for
+ reading from a file or string.
+ 8. history.h contains macros and functions definitions
+ related to history file processing.
+ 9. jobs.h contains the definitions relating to job
+ processing and control.
+ 10. lexstates.h contains the states associated with
+ lexical processing.
+ 11. name.h contains the internal definitions related
+ to name-value pair processing.
+ 12. national.h contains a few I18N definitions, mostly
+ obsolete.
+ 13. nval.h is the public interface to the name-value
+ pair library that is documented with nval.3.
+ 14. path.h contains the interface for pathname processing
+ and pathname searching.
+ 15. shell.h is the public interface for shell functions
+ that are documented int shell.3.
+ 16. shlex.h contains the lexical token definitions and
+ interfaces for lexical analysis.
+ 17. shnodes.h contains the definition of the structures
+ for each of the parse nodes and flags for the attributes.
+ 18. shtable.h contains some interfaces and functions for
+ table lookup.
+ 19. streval.h contains the interface to the arithmetic
+ functions.
+ 20. terminal.h is a header file that includes the appropriate
+ terminal include.
+ 21. test.h contains the definitions for the test and [[...]]
+ commands.
+ 22. timeout.h contains the define constant for the maximum
+ shell timeout.
+ 23. ulimit.h includes the appropriate resource header.
+ 24. variables.h contains symbolic constants for the built-in
+ shell variables.
+
+sh directory:
+ 1. args.c contains functions for parsing shell options
+ and for processing positional parameters.
+ 2. arith.c contains callback functions for the streval.c
+ library and the interface to shell arithmetic.
+ 3. array.c contains the code for indexed and associative
+ arrays.
+ 4. bash.h contains code used when compiling with SHOPT_BASH
+ to add bash specific features such as shopt.
+ 5. defs.c contains the data definitions for global symbols.
+ 6. deparse.c contains code to generate shell script from
+ a parse tree.
+ 7. env.c contains code to add and delete environment variables
+ to an environment list.
+ 8. expand.c contains code for file name expansion and
+ file name generation.
+ 9. fault.c contains code for signal processing, trap
+ handling and termination.
+ 10. fcin.c contains code for reading and writing a character
+ at a time from a file or string.
+ 11. init.c contains initialization code and callbacks
+ for get and set functions for built-in variables.
+ 12. io.o contains code for redirections and managing file
+ descriptors and file streams.
+ 13. jobs.c contains the code for job management.
+ 14. lex.c contains the code for the lexical analyzer.
+ 15. macro.c contains code for the $ macro expansions, including
+ here-documents.
+ 16. main.c contains the calls to initialization, profile
+ processing and the main evaluation loop as well as
+ mail processing.
+ 17. name.c contains the name-value pair routines that are
+ built on the hash library in libast.
+ 18. nvdisc.c contains code related to name-value pair disciplines.
+ 19. nvtree.c contains code for compound variables and for
+ walking the namespace.
+ 20. parse.c contains the code for the shell parser.
+ 21. path.c contains the code for pathname lookup and
+ some path functions. It also contains the code
+ that executes commands and scripts.
+ 22. pmain.c is just a calls sh_main() so that all of the
+ rest of the shell can be in a shared library.
+ 23. shcomp.c contains the main program to the shell
+ compiler. This program parses a script and creates
+ a file that the shell can read containing the parse tree.
+ 24. streval.c is an C arithmetic evaluator.
+ 25. string.c contains some string related functions.
+ 26. subshell.c contains the code to save and restore
+ environments so that subshells can run without creating
+ a new process.
+ 27. suid_exec.c contains the program from running execute
+ only and/or setuid/setgid scripts.
+ 28. tdump.c contains the code to dump a parse tree into
+ a file.
+ 29. timers.c contains code for multiple event timeouts.
+ 30. trestore contians the code for restoring the parse
+ tree from the file created by tdump.
+ 31. userinit.c contains a dummy userinit() function.
+ This is now obsolete with the new version of sh_main().
+ 32. waitevent.c contains the sh_waitnotify function so
+ that builtins can handle processing events when the
+ shell is waiting for input or for process completion.
+ 33. xec.c is the main shell executuion loop.
diff --git a/usr/src/lib/libshell/common/OBSOLETE b/usr/src/lib/libshell/common/OBSOLETE
new file mode 100644
index 0000000000..c29cb8bb63
--- /dev/null
+++ b/usr/src/lib/libshell/common/OBSOLETE
@@ -0,0 +1,152 @@
+.sp 3
+.tl ''Ksh Features That Are Obsolete in Ksh93''
+.sp 2
+.AL 1
+.LI
+Using a pair of grave accents \^\fB\(ga\fR ... \fB\(ga\fR\^
+for command substition. Use \fB$(\fR ... \fB)\fR instead.
+.LI
+.B FCEDIT
+is an obsolete name for
+the default editor name for the
+.B hist
+command.
+.B FCEDIT
+is not used when
+.B HISTEDIT
+is set. Use
+.B HISTEDIT
+instead.
+.LI
+The newtest (\fB[[\fR ... \fB]]\fR) operator
+\fB\-a\fP \fIfile\fP
+is obsolete. Use
+\fB\-e\fP instead.
+.LI
+The newtest (\fB[[\fR ... \fB]]\fR) operator
+.BR = ,
+as used in
+\fIstring\fP \fB=\fP \fIpattern\fP
+is obsolete. Use
+\fB==\fP instead.
+.LI
+The following obsolete arithmetic comparisons are also permitted:
+.in +5
+.VL 20
+.LI "\fIexp1\fP \fB\-eq\fP \fIexp2\fP"
+True, if
+.I exp1
+is equal to
+.IR exp2 .
+.LI "\fIexp1\fP \fB\-ne\fP \fIexp2\fP"
+True, if
+.I exp1
+is not equal to
+.IR exp2 .
+.LI "\fIexp1\fP \fB\-lt\fP \fIexp2\fP"
+True, if
+.I exp1
+is less than
+.IR exp2 .
+.LI "\fIexp1\fP \fB\-gt\fP \fIexp2\fP"
+True, if
+.I exp1
+is greater than
+.IR exp2 .
+.LI "\fIexp1\fP \fB\-le\fP \fIexp2\fP"
+True, if
+.I exp1
+is less than or equal to
+.IR exp2 .
+.LI "\fIexp1\fP \fB\-ge\fP \fIexp2\fP"
+True, if
+.I exp1
+is greater than or equal to
+.IR exp2 .
+.LE \" End .VL
+.in -5
+.LI
+Using test -t or [ -t ] without specifying the file unit number.
+.LI
+The
+.B \-k
+option to the \fBset\fR builtin is obsolete. It causes
+.I all\^
+variable assignment arguments are placed in the environment,
+even if they occur after the command name.
+The following
+first prints
+.B "a=b c"
+and then
+.BR c :
+There is no alternative.
+.LI
+The obsolete
+.B \-xf
+option of the
+.B typeset
+command allows a function to be exported
+to scripts that are executed without a separate
+invocation of the shell.
+Functions that need to be defined across separate
+invocations of the shell should
+be placed in a directory and the
+.B FPATH
+variable should contains the name of this directory.
+They may also
+be specified in the
+.B ENV
+file with the
+.B \-xf
+option of
+.BR typeset .
+.LI
+The shell environment variable
+.B FCEDIT
+is obsolete. Use
+.B HISTEDIT
+instead.
+.LI
+In the
+.B \-s
+option
+(to \fBfc\fR or \fBhist\fR command???)
+(
+and in obsolete versions, the editor name
+.B \-
+)
+is used to skip the editing phase and
+to re-execute the command.
+.LI
+The
+.B \-t
+option to \fBalias\fR builtin is is obsolete. It
+is used to set and list tracked aliases.
+There is no replacement.
+.LI
+The shell command line option
+.B \-t
+is obsolete. This option cause the shell to exit after reading
+and executing one command. The is no replacement (although ending
+\&"command" with the exit builtin should have the same effect).
+.LI
+As an obsolete feature of the "set" builtin,
+if the first
+.I arg\^
+is
+.B \-
+then the
+.B \-x
+and
+.B \-v
+options are turned off and the next
+.I arg
+is treated as the first argument.
+Using
+.B \+
+rather than
+.B \-
+causes these options to be turned off.
+These options can also be used upon invocation of the shell.
+.LE
+
diff --git a/usr/src/lib/libshell/common/PROMO.mm b/usr/src/lib/libshell/common/PROMO.mm
new file mode 100644
index 0000000000..332ff3a855
--- /dev/null
+++ b/usr/src/lib/libshell/common/PROMO.mm
@@ -0,0 +1,141 @@
+.H 1 ksh93
+KSH-93 is the most recent version of the KornShell Language
+described in
+"The KornShell Command and Programming Language,"
+by Morris Bolsky and David Korn of AT&T Bell Laboratories, ISBN 0-13-182700-6.
+The KornShell is a shell programming language,
+which is upward compatible with "sh" (the Bourne Shell),
+and is intended to conform to the IEEE P1003.2/ISO 9945.2 Shell and
+Utilities standard.
+KSH-93 provides an enhanced programming environment in
+addition to the major command-entry features of the BSD
+shell "csh". With KSH-93, medium-sized programming tasks can be
+performed at shell-level without a significant loss in performance.
+In addition, "sh" scripts can be run on KSH-93 without modification.
+.P
+The code should conform to the IEEE POSIX 1003.1 standard and to the
+proposed ANSI-C standard so that it should be portable to all
+such systems. Like the previous version, KSH-88,
+it is designed to accept eight bit character sets
+transparently, thereby making it internationally compatible.
+It can support multi-byte characters sets with some characteristics
+of the character set given at run time.
+.P
+KSH-93 provides the following features, many of which were also inherent
+in KSH-88:
+.BL
+.LI
+Enhanced Command Re-entry Capability: The KSH-93 history
+function records commands entered at any shell level and stores
+them, up to a user-specified limit, even after you log off.
+This allows you to re-enter long commands with a few keystrokes
+- even those commands you entered yesterday.
+The history file allows for eight bit characters in
+commands and supports essentially unlimited size histories.
+.LI
+In-line Editing: In "sh", the only way to fix mistyped
+commands is to backspace or retype the line. KSH-93 allows you
+to edit a command line using a choice of EMACS-TC or "vi"
+functions.
+You can use the in-line editors to complete filenames as
+you type them.
+You may also use this editing feature when entering
+command lines from your history file.
+A user can capture keystrokes and rebind keys to customize the
+editing interface.
+.LI
+Extended I/O Capabilities: KSH-93 provides several I/O
+capabilities not available in "sh", including the ability to:
+.BL
+.LI
+specify a file descriptor for input and output
+.LI
+start up and run co-processes
+.LI
+produce a prompt at the terminal before a read
+.LI
+easily format and interpret responses to a menu
+.LI
+echo lines exactly as output without escape processing
+.LI
+format output using printf formats.
+.LI
+read and echo lines ending in "\e".
+.LE
+.LI
+Improved performance: KSH-93 executes many scripts faster
+than the System V Bourne shell. A major reason for this is
+that many of the standard utilities are built-in.
+To reduce the time to initiate a command, KSH-93 allows
+commands to be added as built-ins at run time
+on systems that support dynamic loading such as System V Release 4.
+.LI
+Arithmetic: KSH-93 allows you to do integer arithmetic in any
+base from two to sixty-four. You can also do double
+precision floating point arithmetic.
+Almost the complete set of C language operators are available
+with the same syntax and precedence.
+Arithmetic expressions can be used to as an argument expansion
+or as a separate command.
+In addition there is an arithmetic for command that works
+like the for statement in C.
+.LI
+Arrays: KSH-93 supports both indexed and associative arrays.
+The subscript for an indexed array is an arithmetic expression,
+whereas, the subscript for an associative array is a string.
+.LI
+Shell Functions and Aliases: Two mechanisms - functions and
+aliases - can be used to assign a user-selected identifier to
+an existing command or shell script.
+Functions allow local variables and provide scoping
+for exception handling.
+Functions can be searched for and loaded on first reference the
+way scripts are.
+.LI
+Substring Capabilities: KSH-93 allows you to create a
+substring of any given string either by specifying the starting
+offset and length, or by stripping off leading
+or trailing substrings during parameter substitution.
+You can also specify attributes, such as upper and lower case,
+field width, and justification to shell variables.
+.LI
+More pattern matching capabilities: KSH-93 allows you to specify
+extended regular expressions for file and string matches.
+.LI
+KSH-93 uses a hierarchal name space for variables.
+Compound variables can be defined and variables can
+be passed by reference. In addition, each variable
+can have one or more disciplines associated with
+it to intercept assignments and references.
+.LI
+Improved debugging: KSH-93 can generate line numbers on execution
+traces. Also, I/O redirections are now traced.
+There is a DEBUG trap that gets evaluated after each command
+so that errors can be localized.
+.LI
+Job Control: On systems that support job control, including
+System V Release 4, KSH-93
+provides a job-control mechanism almost identical to that of
+the BSD "csh", version 4.1.
+This feature allows you
+to stop and restart programs, and to move programs between the
+foreground and the background.
+.LI
+Added security:
+KSH-93 can execute scripts which do not have read permission
+and scripts which have the setuid and/or setgid set when
+invoked by name, rather than as an argument to the shell.
+It is possible to log or control the execution of setuid and/or
+setgid scripts.
+The noclobber option prevents you from accidentally erasing
+a file by redirecting to an existing file.
+.LI
+KSH-93 can be extended by adding built-in commands at run time.
+In addition, KSH-93 can be used as a library that can
+be embedded into an application to allow scripting.
+.LE
+Documentation for KSH-93 consists of an "Introduction to KSH-93",
+"Compatibility with the Bourne Shell" and a manual page and a
+README file. In addition, the "New KornShell Command and Programming
+Language," book is available from Prentice Hall.
+
diff --git a/usr/src/lib/libshell/common/README b/usr/src/lib/libshell/common/README
new file mode 100644
index 0000000000..3c3899fda2
--- /dev/null
+++ b/usr/src/lib/libshell/common/README
@@ -0,0 +1,227 @@
+This directory, and its subdirectories contain the source code
+for ksh-93; the language described in the second addition of
+the book, "The KornShell Command and Programming Language," by
+Morris Bolsky and David Korn which is published by Prentice Hall.
+ksh-93 has been compiled and run on several machines with several
+operating systems. The end of this file contains a partial list of
+operating systems and machines that ksh-93 has been known to run on.
+
+The layout of files for ksh-93 has changed somewhat since ksh-88,
+the last major release. Most of the source code for ksh remains in
+the sh directory. However, the shell editing and history routines
+are in the edit sub-directory. The code for shell built-ins is
+in the bltins directory. The data directory contains read-only
+data tables and messages that are used by the shell. The include
+files remain in the include directory and the shlib directory
+is gone. The features directory replaces the older install
+directory. The method for generating systems specific feature
+information has changed substantially.
+
+The Makefile file contains several compilation options that can be set
+before compiling ksh. Options are of the form SHOPT_option and become
+#define inside the code. These options are set to their recommended
+value and some of these may disappear as options in future releases.
+A value of 0, or no value represents off, 1 represents on.
+Note that == is needed, not =, because these are nmake state variables
+and changing their value will cause all modules that could be affected
+by this change to be recompiled.
+The options have the following defaults and meanings:
+ ACCT off Shell accounting.
+ ACCTFILE off Enable per user accounting info
+ APPEND on Allows var+=val string and array append.
+ BASH off Bash compatibility mode. It is not fully implemented
+ and is experimental.
+ BRACEPAT on C-shell type abc{d,e}f style file generation
+ CMDLIB_BLTIN off Makes all commands in libcmd.a builtins. The
+ SH_CMDLIB_DIR nmake state variable can be used to
+ specify a directory.
+ CMDLIB_DIR off Sets CMDLIB_BLTIN=1 and provides a default value
+ of "/opt/ast/bin" for SH_CMDLIB_DIR.
+ COMPOUND_ARRAY
+ on Allows all components of compound variables except the
+ first to be any string by enclosing in [...]. It also
+ allows components other than the last to be arrays.
+ This is experimental and only partially complete.
+ CRNL off <cr><nl> treated as <nl> in shell grammar.
+ DYNAMIC on Dynamic loading of builtins. (Requires dlopen() interface.)
+ ECHOPRINT off Make echo equivalent to print.
+ ESH on Compile with emacs command line editing. The original
+ emacs line editor code was provided by Mike Veach at IH.
+ FILESCAN on Experimental option that allows fast reading of files
+ using while < file;do ...; done and allowing fields in
+ each line to be accessed as positional parameters.
+ FS_3D off For use with 3-D file system. Enabled automatically for
+ sytems with dynamic linking.
+ KIA off Allow generation of shell cross reference database with -I.
+ MULTIBYTE on Multibyte character handling. Requires mblen() and
+ mbctowc().
+ NAMESPACE on Allows namespaces. This is experimental, incomplete
+ and undocumented.
+ OLDTERMIO off Use either termios or termio at runtime.
+ OO on Experimental object oriented extension. This option
+ should disappear soon.
+ OPTIMIZE on Optimize loop invariants for with for and while loops.
+ P_SUID off If set, all real uids, greater than or equal to this
+ value will require the -p flag to run suid/sgid scripts.
+ PFSH off Compile with support for profile shell.
+ RAWONLY off Turn on if the vi line mode doesn't work right unless
+ you do a set -o viraw.
+ SEVENBIT off Strip the eigth bit from characters.
+ SPAWN off Use spawn as combined fork/exec. May improve speed on
+ some systems.
+ SUID_EXEC on Execute /etc/suid_exec for setuid, setgid script.
+ TIMEOUT off Set this to the number of seconds for timing out and
+ exiting the shell when you don't enter a command. If
+ non-zero, TMOUT can not be set larger than this value.
+ VSH on Compile with vi command line editing. The original vi
+ line editor code was provided by Pat Sullivan at CB.
+
+The following compile options are set automatically by the feature testing:
+ DEVFD Set when /dev/fd is a directory that names open files.
+ SHELLMAGIC
+ Set on systems that recognize script beginning with #! specially.
+ VPIX Set on systems the have /usr/bin/vpix program for running MS-DOS.
+
+
+In most instances, you will generate ksh from a higher level directory
+which also generates libcmd and libast libraries on which ksh depends.
+However, it is possible to generate ksh, with by running make -f ksh.mk
+in this directory. The ksh.mk file was generated from the nmake Makefile.
+If you do not have make or nmake, but do have a Version 7 UNIX compatible
+shell, then you can run the script mamexec < Mamfile to build ksh.
+If you have nmake, version 2.3 or later, you can use it without the -f ksh.mk.
+In either case, ksh relies on libraries libast and libcmd which must be
+built first. The binary for ksh becomes the file named ./ksh which can
+be copied to where ever you install it.
+
+If you use old make or the Mamfile, and you system has dynamic shared
+libraries, then you should define the variables mam_cc_static and
+mam_cc_dynanamic as the compiler options that request static linking
+and dynamic linking respectively. This will decrease the number of
+shared libraries that ksh need and cut startup time substantially.
+
+The makefile should also generate shcomp, a program that will precompile
+a script. ksh93 is able to recognize files in this format and process
+them as scripts. You can use shcomp to send out scripts when you
+don't want to give away the original script source.
+
+It is advisable that you put the line PWD=$HOME;export PWD into the
+/etc/profile file to reduce initialization time for ksh.
+
+To be able to run setuid/setgid shell scripts, or scripts without read
+permission, the SUID_EXEC compile option must be on, and ksh must be installed
+in the /bin directory, the /usr/bin directory, the /usr/lbin directory,
+or the /usr/local/bin directory and the name must end in sh. The program
+suid_exec must be installed in the /etc directory, must be owned by root,
+and must be a suid program. If you must install ksh in some other directory
+and want to be able to run setuid/setgid and execute only scripts, then
+you will have to change the source code file sh/suid_exec.c explicitly.
+If you do not have ksh in one of these secure locations, /bin/sh will
+be invoked with the -p options and will fail when you execute a setuid/setgid
+and/or execute only script. Note, that ksh does not read the .profile
+or $ENV file when it the real and effective user/group id's are not
+equal.
+
+The tests sub-directory contains a number of regression tests for ksh.
+To run all these tests with the shell you just built, go to the tests
+directory and run the command
+ SHELL=../ksh shtests
+
+The file PROMO.mm is an advertisement that extolls the virtues of ksh.
+The file sh.1 contains the troff (man) description of this Shell.
+The file nval.3 contains the troff (man) description of the name-value
+pair library that is needed for writing built-ins that need to
+access shell variables.
+
+The file sh.memo contains a draft troff (mm) memo describing ksh. The
+file RELEASE88 contains the changes made for ksh88. The file RELEASE93
+contains the changes made in this release since ksh-88. The file
+RELEASE contains bug fixes made in this release since ksh-88. The file
+COMPATIBILITY contains a list of incompatibilities with ksh-88. The
+file bltins.mm is a draft troff (mm) memo describing how to write
+built-in commands that can be loaded at run time.
+
+Most of the work for internationalization has been done with ksh93.
+The file ksh.msg is a generated file that contains error messages
+that need to be translated. In addition, the function translate()
+in sh/init.c has to be completed to interface with the dictionary
+lookup. The translate function takes two argument, the string
+that is to be translated and a type which is
+ 0 when a library string needs translation.
+ 1 when one of the error messages in ksh.msg needs translation.
+ 2 when a string in a script needs translation. You use a $ in front
+ of a double quoted string in a script to indicate that it
+ needs translation. The -D option for ksh builds the dictionary.
+The translate routine needs to return the translated message.
+For dictionaries that need to use a numeric key, it should be
+possible to use the strhash() function to generate numbers to
+go along with each of the messages and to use this number both
+when generating the dictionary and when converting strings.
+If you encounter error messages of type 1 that are not be translated via
+this translate() function send mail to the address below.
+
+Please report any problems or suggestions to:
+
+dgk@research.att.com
+
+
+ksh93 has been compiled and alpha tested on the following. An asterisk
+signifies that ksh has been installed as /bin/sh on this machine.
+
+* Sun OS 4.1.[123] on sparc.
+ Sun OS 4.1.1 on sun.
+ Solaris 2.[1-9] on sparc.
+ Solaris 2.[4-8] on X86.
+ HP/UX 8 on HP-9000/730.
+ HP/UX 9 on HP-9000/730.
+ HP/UX 10 on HP-9000/857.
+ HP/UX 11 on pa-risc.
+ System V Release 3 on Counterpoint C19
+ System V Release 4 on AT&T Intel 486.
+ System V Release 4 on NCR 4850 Intel 486.
+ IRIX Release 4.0.? System V on SGI-MIPS.
+ IRIX Release 5.1 System V on SGI-MIPS.
+ IRIX Release 6.[1-5] System V on SGI-MIPS.
+ System V Release 3.2 on 3B2.
+ UTS 5.2.6 on Amdahl 3090,5990,580.
+ System V Release 3.2 on i386.
+ SMP_DC.OSx olivetti dcosx MIServer-S 2/128.
+ SMP_DC.OSx Pyramid dcosx MIServer-S 2/160 r3000.
+ 4.3BSD on Vax 8650.
+ AIX release 2 on RS6000.
+ AIX 3.2 on RS6000.
+ Linux 1.X on Intel
+ Linux 2.X on Intel
+ Linux 2.X on Alpha
+ Linux 2.X on Alpha
+ Linux 2.X on OS/390
+ Linux 2.X on sparc
+ Linux 2.4 on intel itanium 64
+ Linux Slackware on sparc64
+* Linux ARM on i-PAQ
+ OSF1 on DEC alpha.
+ OSF4 on DEC alpha.
+ UMIPS 4.52 on mips.
+ BSD-i [2-4] on X86.
+ OpenBSD on X86
+ NetBSD on X86
+ FreeBSD on X86
+ NeXT on Intel X86.
+ NeXT on HP.
+* Windows NT using UWIN on X86
+* Windows NT using UWIN on alpha
+ Windows NT using Cygwin on X86
+ Windows NT with NutCracker libraries.
+ Windows NT with Portage libraries.
+ Windows 3.1 using custom C library.
+ OpenEdition on MVS
+ Darwin OS X on PPC
+ MVS on OS 390
+ SCO Openserver 3.2 on X86
+ Unixware 7 on X86
+
+Good luck!!
+
+David Korn
+dgk@research.att.com
+
diff --git a/usr/src/lib/libshell/common/RELEASE b/usr/src/lib/libshell/common/RELEASE
new file mode 100644
index 0000000000..034ca7033d
--- /dev/null
+++ b/usr/src/lib/libshell/common/RELEASE
@@ -0,0 +1,1455 @@
+07-04-18 --- Release ksh93s+ ---
+07-04-18 A small memory leak with each redirection of a non-builtin has
+ been fixed.
+07-03-08 A bug in which set +o output command line options has been fixed.
+07-03-08 A bug in which an error in read (for example, an invalid variable
+ name), could leave the terminal in raw mode has been fixed.
+07-03-06 A bug in which read could core dump when specified with an array
+ variable with a subscript that is an arithmetic expression has
+ been fixed.
+07-03-06 Several serious bugs with the restricted shell were reported and
+ fixed.
+07-03-02 If a job is stopped, and subsequently restarted with a CONT
+ signal and exits normally, ksh93 was incorrectly exiting with
+ the exit status of the stop signal number.
+07-02-26 M-^L added to emacs mode to clear the screen.
+07-02-26 A bug in which setting a variable readonly in a subshell would
+ cause an unset error when the subshell completed has been fixed.
+07-02-19 The format with printf uses the new = flag to center the output.
+07-02-19 A bug in which ksh93 did not allow multibyte characters in
+ identifier names has been fixed.
+07-02-19 A bug introduced in ksh93 that causes global compound variable
+ definitions inside functions to exit with "no parent" has been fixed.
+07-02-19 A bug in which using compound commands in process redirection
+ arguments would give syntax errors <(...) and >(...) has been fixed.
+07-01-29 A bug which caused the shell to core dump which can occur when a
+ built-in exits without closing files that it opens has been fixed.
+07-01-26 A bug in which ~(E) in patterns containing \ that are not inside ()
+ has been fixed.
+
+06-12-29 --- Release ksh93s ---
+06-12-29 A bug in which the value of IFS could be changed after a command
+ substitution has been fixed.
+06-12-22 /dev/(tcp|udp|sctp)/HOST/SEVRICE now handles IPv6 addresses on
+ systems that provide getaddrinfo(3).
+06-12-19 A -v option was added to read. With this option the value of
+ the first variable name argument will become the default value
+ when read from a terminal device.
+06-11-20 A bug in which "${foo[@]:1}}" expands a null argument (instead of
+ no argument), when foo[0] is not empty has been fixed.
+06-11-16 The discipline functions have been modified to allow each subscript
+ to act independently. Currently the discipline function will not
+ be called when called from a discipline function of the same variable.
+06-11-14 A bug which could cause a core dump if a file descriptor for
+ an internal file was closed from with a subshell has been fixed.
+06-10-30 The redirections <# pattern, and <## pattern have been added.
+ Both seek forward to the beginning of the next line that contains
+ the pattern. The <## form copies the skipped portion to standard
+ output.
+06-10-26 On systems that support stream control transport, the virtual file
+ name /dev/sctp/host/port can now be used to establish connections.
+06-10-26 The printf modifier # when used with d produces units in thousands
+ with a single letter suffix added. The modifier # when used with
+ the i specification provides units of 1024 with a two letter suffix.
+06-10-24 The value of $! is now set to the process id of a job put
+ into the background with the bg command as required by POSIX.
+06-10-23 A bug in which the value of $! was affected by a background
+ job started from a subshell has been fixed.
+06-10-23 A bug in ${var:offset:len} in multibyte locales has been fixed.
+06-10-15 The remaining math functions from C99 were added for any system
+ that supports them.
+06-10-13 The klockwork.com software detected a few coding errors that
+ have been fixed.
+06-10-12 A bug when skipping over `...` with ${x:=`...`} when x is set
+ has been fixed.
+06-10-11 A bug in process floating constants produced by the %a format
+ of printf has been fixed.
+06-10-06 A bug in which IFS was not being restored correctly in some
+ cases after a subshell has been fixed.
+06-10-06 A bug in which pipefail was not detecting some failures in
+ pipelines with 3 or more states has been fixed.
+06-10-03 A bug in the processing of >(...) with builtins which could
+ cause the builtin to hang has been fixed.
+06-10-03 A bug in the for loop optimizer which causes >(...) process
+ substitution to be ignored has been fixed.
+06-09-17 The -a option was added to typeset for indexed arrays. This
+ is only needed when using the ([subscript]=value ...) form.
+06-09-06 The showme option was added. Each simple command not beginning
+ with a redirection and not occurring with in the while, until, if,
+ select condition can be preceded by a semi-colon which will
+ be ignored when showme is off. When showme is on, any command
+ preceded by a colon will be traced but not executed.
+06-08-16 As a new feature, a leading ~(N) on a pattern has no effect
+ except when used for file expansion. In this case if not
+ matches are found, the pattern is replaced by nothing rather
+ than itself.
+06-08-11 A bug in the expansion of ${.sh.match[i]:${#.shmatch[i]}} has
+ been fixed.
+06-08-10 The read builtin options -n and -N have been modified to treat
+ the size as characters rather than bytes unless storing into a
+ binary (typeset -B) variable.
+06-07-27 When the here document operator << is followed directly by a #
+ rather than a -, the first line of the here-document determines
+ how much whitespace is removed for each line.
+06-07-26 A bug in the C-shell history (enabled with set -H) in which the
+ history event !$ was not processed has been fixed.
+06-07-21 A bug on some systems in which assigning PATH on a command line
+ would not take effect has been fixed.
+06-07-20 Add ksh93 and rksh93 as allowable names for ksh binaries.
+06-07-20 Removed the SHOPT_OO compilation option which was only partially
+ implemented.
+06-07-20 The ability to use egrep, grep, and fgrep expressions within
+ shell patterns has been documented.
+06-07-17 A bug with arithmetic command expressions for locales in which
+ the comma is a thousands separator has been fixed.
+06-07-13 The default HISTSIZE was increased from 128 to 512.
+06-07-13 A multibyte problem with locales that use shift codes has been fixed.
+06-06-23 A number of bug fixes for command, file, and variable completion
+ have been mode.
+06-06-20 Floating point division by zero now yields the constant Inf or -Inf
+ and floating functions with invalid arguments yield NaN.
+06-06-20 The floating point constants Inf and NaN can be used in arithmetic
+ expressions.
+06-06-20 The functions isinf(), isnan(), tanhl() have been added for
+ arithmetic expressions.
+06-06-13 Internal change to use ordering for variables instead of hashing
+ to speed up prefix matching.
+06-06-13 A window between fork/exec in which a signal could get lost
+ and cause a program to hang has been eliminated
+06-06-13 A bug in edit completion with quoted strings has been fixed.
+06-06-07 The restricted options can now be enabled by set as well as on
+ the command line. Once set, it can not be disabled.
+06-06-04 Modified built-in binding so that for systems for which /bin
+ and /usr/bin are the same, a builtin bound to /bin will get
+ selected when either /bin or /usr/bin is scanned.
+06-06-04 Added literal-next character processing for emacs/gmacs mode.
+ This change is not compatible with earlier versions of ksh93
+ and ksh88 when the stty lnext is control-v. The sequence
+ escape-control-v will display the shell version.
+06-05-31 Modified emacs and vi mode so that entering a TAB after a partial
+ TAB completion, generates a listing of possible completions.
+ After the second TAB, a number followed by a TAB will perform
+ the completion with the corresponding item.
+06-05-19 Modified arithmetic so that conversions to strings default to
+ the maximum number of precision digits.
+06-05-16 Bug fixes for multibyte locales.
+06-05-10 The =~ operator was added to [[...]] and [[ string ~= ERE ]]
+ is equivalent to [[ string == ~(E)ERE ]].
+06-04-25 A bug in the vi edit mode which could cause the shell to core dump
+ when switching from emacs mode.
+06-04-17 A bug in which using LANG or LC_ in assignment lists with builtins
+ did not restore the localed correctly has been fixed.
+06-04-04 A bug in which discipline functions could not be added to variables
+ whose names started with .sh has been fixed.
+06-03-28 The -s option to typeset was added to modify -i to indicate short
+ integers.
+06-03-28 A bug in which variables assignment lists before functions
+ defined with function name were not passed on the functions
+ invoked by this function has been fixed.
+06-03-28 A bug in which name references defined within a function defined
+ with function name could not be used with compound variables has
+ been fixed.
+06-03-27 A bug in which read <&p (print >&p) would cause the coprocess input
+ (output) pipe to close before reading from (after writing to)
+ it has been fixed.
+06-02-28 A bug in which stopping a job created with the hist builtin command
+ would create a job that could not be restarted has been fixed.
+
+06-01-24 --- Release ksh93r ---
+06-01-24 A bug in which running commands with standard output closed would
+ not work as expected has been fixed.
+06-01-23 A bug in which print -u<n> could fail when file descriptor <n> was
+ open for writing has been fixed.
+06-01-19 The ?: arithmetic operator fixed to work when the operation after
+ the colon was an assignment.
+05-12-24 A bug which could lead to a core dump when elements of a compound
+ variable were array elements, i.e. foo=(bar=(1 2)), has been fixed.
+05-12-13 An arithmetic bug in which x+=y+=z was not working has been fixed.
+05-12-13 An arithmetic bug in which x||y was returning x when x was non-zero
+ rather than 1 has been fixed.
+05-12-07 The aliases for integer and float have been changed to use attributes
+ -li and -lE to handle long long and long double types.
+05-12-07 The histexpand (-H) option has been added which allows C-shell
+ style history expansions using the history character !.
+05-12-07 The multiline option was added which changes that way the edit
+ modes handle lines longer than the window width. Instead of
+ horizontal scrolling, multiple lines on the screen are used.
+05-12-05 The whence builtin now returns an absolute pathname when the
+ command is found in the current directory.
+05-11-29 A bug which caused ksh -c '[[ ! ((' to core dump rather than
+ report a syntax error has been fixed.
+05-11-29 A bug when reading fixed length records into typeset -b variables
+ which caused a zero byte to terminate the value has been fixed.
+05-11-22 The ability to seek to an offset within a file has been added
+ with the new I/O redirection operators, <# and >#. Currently,
+ these redirection operators must be followed by ((expr))
+ but in a future release, it should be able to used to seek forward
+ to the specified shell pattern. In addition $(n<#) expands to the
+ current byte offset for file descriptor n.
+05-11-22 The .sh.match array variable is now set after each [[ ... ]]
+ pattern match. Previously it was only set for substring matches.
+05-10-17 A bug in which the library path variable could be prefixed
+ with a directory when a .path file was not encountered in
+ the directory of the executable has been fixed.
+05-09-15 A for/while loop optimizer bug in which $OPTIND was not
+ correctly expanded has been fixed.
+05-09-05 A bug in which a history command that invoked a history
+ command could go into an infinite loop has been fixed.
+05-08-31 In the case that IFS contains to adjacent new-lines so that
+ new-line is not treated as a space delimiter, only a single
+ new-line is deleted at the end of a command substitution.
+05-08-19 When a tilde substitution expands to the / directory and is
+ followed by a /, it is replaced by the empty string.
+05-08-16 A bug in which n<&m did not synchronize m has been fixed.
+05-08-16 A bug in which process substitution ( <() and >() ) was not
+ working within for and while loops has been fixed.
+05-07-24 A bug in which the pattern ~(E)(foo|bar) was treated as a syntax
+ error has been fixed.
+05-07-24 A bug in completion with <n>=, where n was the one of the
+ previous selection choices has been fixed.
+05-07-21 A bug with multibyte input when no edit mode was specified which
+ caused the input line to shift left/right has been fixed.
+05-06-24 A race condition which could cause the exit status to get lost
+ on some fast systems has been fixed.
+05-06-21 A bug in which nested patterns of the form {m,n}(pat) would cause
+ syntax errors has been fixed.
+05-06-21 A bug in the macro expander has been fixed which could cause a
+ syntax error for an expansion of the form ${x-$(...)} when
+ x is set and the command substitution contained certain strings.
+05-06-08 On systems for which echo does not do System V style \ expansions,
+ the -e option was added to enable these expansion.
+05-06-08 A bug in which ${var op pattern} to not work when inside an
+ arithmetic expression has been fixed.
+05-05-23 An extension to shell patterns that allows matching of nested
+ groups while skipping over quoted strings has been added.
+05-05-18 A bug in which the line number for errors was not correct for
+ functions loaded from FPATH has been fixed.
+05-04-18 A bug in which the exit status $? is not set when a trap triggered
+ by the [[...]] command is executed has been fixed.
+05-04-08 Redirection operators can be directly preceded with {varname}
+ with no intervening space, where varname is a variable name which
+ allows the shell to select a file descriptor > 10 and store it
+ into varname.
+05-04-08 SHOPT_CMDLIB_BLTIN=1 now includes <cmdlist.h> generated table.
+05-04-07 [[ -o ?option ]] is true if "option" is a supported option.
+05-04-05 A bug in handling file completion with spaces in the names
+ has been fixed.
+05-03-25 The SIGWINCH signal is caught by default to keeps the LINES and
+ COLUMNS variables in sync with the actual window size.
+05-03-25 Building ksh with SHOPT_REMOTE=1 causes ksh to set --rc if stdin is
+ a socket (presumably part of a remote shell invocation.)
+05-03-25 Building ksh with SHOPT_SYSRC=1 causes interactive ksh to source
+ /etc/ksh.kshrc (if it exists) before sourcing the $ENV file.
+05-03-25 {first..last[..incr][%fmt]} sequences added to brace expansions
+ when braceexpand is enabled.
+05-03-03 A bug where a SIGCHLD interrupt could cause a fifo open to fail has
+ been fixed.
+05-02-25 A bug in which a builtin command run in the background could
+ keep a file descriptor open which could cause a foreground
+ process to hang has been fixed.
+05-02-24 A bug where builtin library commands (e.g., date and TZ) failed to
+ detect environment variable changes has been fixed.
+05-02-22 The read builtin and word splitting are now consistent with respect
+ to IFS -- both treat IFS as field delimiters.
+05-02-22 The read builtin no longer strips off trailing delimiters that
+ are not space characters when there are fewer variables than fields.
+05-02-17 A builtin bug on systems where dlsym(libcmd) returns link-time
+ bindings has been fixed.
+05-02-12 A bug in which the lib_init() function for .paths BUILTIN_LIB
+ libraries was not called has been fixed.
+05-02-06 A bug on some systems in which moving the write end of a co-process
+ to a numbered file descriptor could cause it to close has been fixed.
+05-02-06 A bug in the vi-edit mode in which the character under the cursor
+ was not deleted in some cases with the d% directive has been fixed.
+05-02-06 A bug where external builtin stdout/stderr redirection corrupted
+ stdout has been fixed.
+05-02-04 A bug where times formatting assumed CLK_TCK==60 has been fixed.
+
+05-01-11 --- Release ksh93q ---
+05-01-11 A bug in the integral divide by zero check has been fixed.
+05-01-11 The -l option has been added to read /etc/profile and
+ $HOME/.profile, if they exist, before the first command.
+05-01-11 An argument parsing bug that caused `kill -s x -- n' to fail has
+ been fixed.
+05-01-11 The .paths file, introduced in ksh93m, which can appear in
+ any directory in PATH, now allows a line of the form 'BUILTIN_LIB=.'
+ When a command is searched for this directory, and the full path
+ matches the path of the built-in version of the command (listed
+ by the 'builtin' command) then the built-in version of the command
+ is used. When ksh is built with SHOPT_CMDLIB_DIR=1 then all libcmd
+ functions become builtins with the '/opt/ast/bin/' directory prefix.
+05-01-10 A bug in which a nameref to a compound name caused a core dump has
+ been fixed.
+05-01-09 A bug in which some SIGCHLD interrupts (from child processes exiting)
+ caused a fatal print/echo error diagnostic has been fixed.
+04-12-24 A bug in which some SIGCHLD interrupts (from child processes exiting)
+ corrupted the internal process/job list, sometimes causing the shell
+ to hang, has been fixed.
+04-12-01 A bug in which typeset -Fn truncated less than n digits for large
+ numbers has been fixed.
+04-11-25 A bug in which standard error could be closed after a redirection
+ to /dev/stderr has been fixed.
+04-11-17 A bug in which an expansion of the form ${array[@]:3} could expand
+ to ${array[0]} when ${array[3]} was not set has been fixed.
+04-10-22 The -E or -orc command line option reads ${ENV-$HOME/.kshrc} file.
+04-10-22 `-o foo' equivalent to `+o nofoo', `-o nobar' equivalent to `+o bar'.
+ `--foo' equivalent to `-o foo', `--nofoo' equivalent to `+o foo'
+04-10-05 The .paths file, introduced in ksh93m, which can appear in
+ any directory in PATH, now allows a line of the form
+ 'BUILTIN_LIB=libname'. When a command is searched for this directory,
+ the shared library named by libname will first be searched for a
+ built-in version of the command.
+04-09-03 <<< here documents now handle quotes in the word token correctly.
+04-08-08 The maximum size for read -n and and read -N was increased from
+ 4095 to 32M.
+04-08-04 printf %q was modified so that if an no operand was supplied, no
+ no output would be generated rather than a quoted empty string.
+04-08-01 The -n and -N options of the read builtin has been modified
+ when reading variables with the binary attribute so that the
+ data is stored directly rather than through assignment.
+04-08-01 The shcomp command has been modified to process alias commands
+ under some conditions.
+04-07-31 The .sh.match variable added in ksh93l, now works like other
+ indexed arrays.
+04-07-08 A loop optimizer bug which occurs when typeset is used in
+ a for or while loop inside a function has been fixed.
+04-06-24 The number of subexpressions in a pattern was increased to 64
+ from the current number of 20.
+04-06-17 The -t option to read was modified to allow seconds to be
+ specified as any arithmetic expression rather than just
+ an integral number of seconds, for example even -t 'sin(.5)'
+ is now valid.
+04-06-16 Two small memory leak problems were fixed.
+04-06-15 A bug in ${var/pattern/"string"} which occurred when string
+ contained pattern matching characters has been fixed.
+04-05-08 printf $'%d\n' produced an erroneous error message and has
+ been fixed.
+04-05-24 A bug in which an associative array without any elements could
+ cause a core dump when a script with an associative array with
+ the same name was declared in a script invoked by name has
+ been fixed.
+04-05-11 A bug in which an exec statement could close the script that
+ is being processed in a script that is run by name causing
+ a failure has been fixed.
+04-04-28 If the first character of assignment to an integer variable was 0,
+ the variable had been treated as unsigned. This behavior was
+ undocumented and has been removed.
+04-04-05 A bug in which the positioning of standard input could be incorrect
+ after reading from standard input from a subshell has been fixed.
+04-03-30 A bug in the for loop optimizer which in rare cases could cause
+ memory corruption has been fixed.
+04-03-29 The preset alias source='command .' has been added.
+04-03-29 A bug introduced in ksh93p on some systems in which invoked by
+ name with #! on the first line would not get the signals handling
+ initialized correctly has been fixed.
+04-03-29 A bug introduced in ksh93p in which a HUP signal received by
+ a shell that is a session group leader was not passed down to
+ its children has been fixed.
+
+04-02-28 --- Release ksh93p ---
+04-02-28 The ability to apply an append discipline to any variable has
+ been added.
+04-02-14 A bug in which the exportall option (set -a) would cause incorrect
+ results for arrays has been fixed.
+04-02-02 A bug in which an exported array would pass more than
+ the first element to a script invoked by name has been fixed.
+04-02-02 A bug on some systems in which name=value pairs preceding a script
+ invoked by name was not getting passed to the script has been fixed.
+04-01-20 A bug in which an unset discipline function could cause a core
+ dump on some systems has been fixed.
+04-01-12 A bug in which a continue or break called outside a loop from
+ inside a function defined with name() syntax could affect
+ the invoking function has been fixed.
+04-01-08 If a command name begins with ~, only filename completion will be
+ attempted rather than pathname completion using the builtin editors.
+04-01-08 A bug in the vi edit mode in which the wrong repeat count on
+ multiple word replacements with the . directive has been fixed.
+04-01-06 Backspace characters are now handled correctly in prompt strings.
+04-01-06 The getopts builtin has been modified to accept numerical
+ arguments of size long long on systems that support this.
+04-01-06 A bug in which unsetting all elements of an associative array
+ would cause it to be treated as an indexed array has been fixed.
+03-12-15 A bug in which a quoted string ending with an unescaped $ would
+ delete the ending $ in certain cases has been fixed.
+03-12-05 A bug in which the shell could hang when set -x tracing a command
+ when an invalid multibyte character is encountered has been fixed.
+03-12-05 On some systems, if the KEYBD trap is set, then commands that use
+ the meta key were not processed until return was hit. This
+ has been fixed.
+03-12-05 A problem which occurred when the login shell was not a group
+ leader that could cause it to fail has been fixed.
+03-12-05 A problem in which a shell could core dump after receiving a signal
+ that should cause it to terminate while it was in the process
+ of acquiring more space has been fixed.
+03-12-05 If ENV is not specified, the shell will default to $HOME/.kshrc
+ for interactive shells.
+03-11-21 A bug introduced in ksh93o in which the DEBUG trap could get
+ disabled after it triggered has been fixed.
+03-11-04 A bug in which using arithmetic prefix operators ++ or -- on a
+ non-lvalue could cause a core dump has been fixed.
+03-11-04 A bug in which leading zeros were stripped from variable
+ expansions within arithmetic computation to avoid being treated
+ as octal constants when they should not have, has been fixed.
+03-10-08 A bug introduced in ksh93o in which a large here document inside
+ a function definition could get corrupted has been fixed.
+03-09-22 A bug in which the .get discipline function was not being
+ called when a string variable was implicitly referenced from
+ within a numerical expression has been fixed.
+03-09-22 A bug in which a script without a leading #! could get executed
+ by /bin/sh rather than the current shell on some systems has
+ been fixed.
+03-09-12 To improve conformance with ksh88, leading zeros will be ignored
+ when getting the numerical value of a string variable so that
+ they will not be treated as octal constants.
+03-09-03 The builtin kill command now processes obsolete invocations
+ such as kill -1 -pid.
+03-09-02 The restriction on modifying FPATH in a restricted shell (sh -r)
+ has been documented.
+03-09-02 The restricted shell (sh -r) has been modified to disallow
+ executing command -p.
+03-08-07 A bug in which the KEYBD trap was not being invoked when
+ characters with the 8th bit set has been fixed.
+03-08-02 A parser bug introduced in ksh93o which caused the character
+ after () in a Posix function definition to be skipped
+ when reading from standard input has been fixed.
+03-08-01 A bug in which "${foo#pattern}(x)" treated (x) as if it were
+ part of the pattern has been fixed.
+03-08-01 The command -x option has been modified so that any trailing
+ arguments that do expand to a single word will be included
+ on each invocation, so that commands like command -x mv * dir
+ work as expected.
+
+03-07-20 --- Release ksh93o+ ---
+03-07-20 A bug in which could cause memory corruption when a posix
+ function invoked another one has been fixed.
+03-07-15 A bug in which a file descriptor>2 could be closed before
+ executing a script has been fixed.
+03-07-15 A parsing error for <() and >() process substitutions inside
+ command substitution has been fixed.
+03-07-15 A parsing error for patterns of the form {...}(...) when
+ used inside ${...} has been fixed.
+03-07-15 An error in which expanding an indexed array inside a compound
+ variable could cause a core dump has been fixed.
+03-07-15 A bug in which under on rare occassions a job completion interrupt
+ could cause to core dump has been fixed.
+03-06-26 A bug in which process substitution embedded within command
+ substitution would generate a syntax error has been fixed.
+03-96-23 A bug in which ${@:offset:len} could core dump when there
+ were no arguments has been fixed.
+03-96-23 A bug in which ${X[@]:offset:len} could core dump when X
+ was unset has been fixed.
+03-06-22 The -x option was added to the command builtin. If this
+ option is on, and the number of arguments would exceed ARG_MAX,
+ the command will be invoked multiple times with a subset of
+ the arguments. For example, with alias grep='command -x grep,
+ any number of arguments can be specified.
+03-06-14 A bug in which could cause a core dump on some systems with
+ vi and emacs editors with the MULTIBYTE option has been fixed.
+03-06-06 A bug in which the shell could core dump when a script was
+ run from its directory, and the script name a symlink to a file
+ beginning with .., has been fixed.
+03-06-05 A bug in which the shell could core dump when a child process
+ that it is unaware of terminates while it is calling malloc()
+ has been fixed.
+03-06-02 An option named globstar (set -G) has been added. When enabled,
+ during pathname expansion, any component that consists only of ** is
+ matches all files and any number of directory levels.
+03-05-30 A bug in which the PATH search could give incorrect results when
+ run from directory foo and PATH contained .:foo:xxx has been fixed.
+03-05-29 Some changes were made to the code that displays the prompt in edit
+ mode to better handle escape sequences in the prompt.
+03-05-27 I added = to the list of characters that mark the beginning of
+ a word for edit completion so that filenames in assignments
+ can be completed.
+03-05-20 A bug in which read -N could hang on some systems when reading
+ from a terminal or a pipe has been fixed.
+03-05-19 A bug in which the output of uname from a command substitution
+ would go to the standard output of the invoking command when
+ uname was invoked with a non-standard option has been fixed.
+03-05-19 A job control bug which would cause the shell to exit because
+ it hadn't take back the terminal has been fixed. The bug
+ could occur when running a function that contained a pipeline
+ whose last element was a function.
+03-05-19 A job control timing bug introduced in ksh93o on some systems
+ which could cause a pipeline to hang if the first component
+ completed quickly has been fixed.
+03-05-13 The read builtin has been modified so that the builtin editors
+ will not overwrite output from a previous incomplete line.
+03-05-13 A bug in which the name of an identifier could have the string
+ .sh. prefixed to it after expanding a variable whose name begins
+ with .sh. has been fixed.
+03-05-13 A bug in the expansion of $var for compound variables in which
+ some elements would not be output when the name was a prefix
+ of another name in the compound variable has been fixed.
+03-05-08 The last item in the ksh93o release on 03-01-02 has been
+ altered slightly to preserve the leading 0's when the
+ preceding character is a digit. Thus, with typeset -LZ3 x=10,
+ $(( 1$x)) will be 1010 whereas $(( $x) will be 10.
+03-04-25 A bug in which if x is a name reference, then nameref y=x.foo
+ did not follow x has been fixed.
+
+03-03-18 --- Release ksh93o ---
+03-03-18 A -N unary operator was added to test and [[...]] which returns
+ true if the file exists and the file has been modified since it
+ was last read.
+03-03-18 The TIMEFORMAT variable was added to control the format for
+ the time compound command. The formatting description is
+ described in the man page.
+03-03-06 A -N n option was added to read which causes exactly n bytes
+ to be read unlike -n n which causes at most n bytes to be read.
+03-03-03 Three new shell variables were added. The variable .sh.file
+ stores the full pathname of the file that the current command
+ was found in. The variable .sh.fun names the current function
+ that is running. The variable .sh.subshell contains the depth
+ of the current subshell or command substitution.
+03-03-03 When the DEBUG trap is executed, the current command line after
+ expansions is placed in the variable .sh.command. The trap
+ is also now triggered before each iteration of a for, select,
+ and case command and before each assignment and redirection.
+03-02-28 Function definitions are no longer stored in the history file so
+ that set -o nolog no longer has any meaning.
+03-02-28 All function definitions can be displayed with typeset -f not
+ just those stored in the history file. In addition, typeset +f
+ displays the function name followed by a comment containing the
+ line number and the path name for the file that defined this function.
+03-02-28 A bug in which the value of $LINENO was not correct when executing
+ command contained inside mult-line command substitutions has been
+ fixed.
+03-02-19 Since some existing ksh88 scripts use the undocumented and
+ unintended ability to insert a : in front of the % and # parameter
+ expansion operators, ksh93 was modified to accept :% as equivalent
+ to % and :# as equivalent to # with ${name op word}.
+03-02-14 A bug which could cause a core dump when reading from standard
+ error when standard error was a pty has been fixed.
+03-02-14 The shell arithmetic was modified to use long double on systems
+ that provide this data type.
+03-02-09 A bug in which a function located in the first directory in FPATH
+ would not be found when the last component of PATH was . and the
+ current directory was one of the directories in PATH has been fixed.
+03-02-07 The trap and kill builtin commands now accept a leading SIG prefix
+ on the signal names as documented.
+03-02-05 A bug in the expansion of ${var/$pattern}, when pattern contained
+ \[ has been fixed.
+03-02-05 A bug in which .sh.match[n], n>0, was not being set for substring
+ matches with % and %% has been fixed.
+03-01-15 A bug in which getopts did not work for numerical arguments specified
+ as n#var in the getopts string has been fixed.
+03-01-09 A bug in which using ${.sh.match} multiple times could lead to
+ a memory exception has been fixed.
+03-01-06 A bug in the expansion of ${var/pattern/$string} in the case that
+ $string contains \digit has been fixed.
+03-01-02 A -P option was added for systems such as Solaris 8 that support
+ profile shell.
+03-01-02 For backward compatibility with ksh88, arithmetic expansion
+ with ((...)) and let has been modified so that if x is a zero-filled
+ variable, $x will not be treated as an octal constant.
+
+02-12-05 --- Release ksh93n+ ---
+02-11-30 A bug that can show up in evaluating arithmetic statements that
+ are in an autoloaded function when the function is autoload from
+ another function has been fixed.
+02-11-30 An optimization bug in which an expansion of the form ${!name.@},
+ which occurred inside a for or a while loop, when name is a name
+ reference, has been fixed.
+02-11-18 A bug in which modifying array variables in a subshell could leave
+ side effects in the parent shell environment has been fixed.
+02-11-18 A memory leak when unsetting an associative array has been fixed.
+02-11-14 The code to display compound objects was rewritten to make
+ it easier for runtime extensions to reuse this code.
+02-11-14 A change was made to allow runtime builtins to be notified when
+ a signal is received so that cleanup can be performed.
+02-10-31 User applications can now trap the ALRM signal. Previously,
+ the ALRM signal was used internally and could not be used
+ by applications.
+02-10-31 A bug in which signals received while reading from a coprocess
+ for which traps were set was not handled correctly has been fixed.
+02-10-31 A bug in which a file opened with exec inside a subshell could
+ be closed before the subshell completed has been fixed.
+02-10-21 A bug in which setting PATH or FPATH inside a function might not
+ take effect has been fixed.
+02-10-21 A bug which could cause a core dump when a local SECONDS variable
+ is defined in a function has been fixed.
+02-10-15 A bug in which the associate array name operator ${!array[@]}
+ could return the same name multiple times has been fixed.
+02-10-15 A bug in which the zero'th element of an associative array was
+ not getting set when an assignment was made without a subscript
+ specified has been fixed.
+
+02-09-30 --- Release ksh93n ---
+02-09-30 The maximum indexed array size was increased to 16Megs.
+02-09-30 A bug which could cause a core dump when changing attributes
+ of associative array has been fixed.
+02-09-30 A bug in which exporting an array variable would not export the
+ 0-th element has been fixed.
+02-09-30 A bug in which an array assignment of the form a=($a ...) would unset
+ 'a' before the right hand side was evaluated has been fixed.
+02-09-27 A bug in which the error message for ${var?message} when var was
+ null or unset did not contain the variable name var has been fixed.
+02-09-27 A bug in which closing file descriptors 0 through 2 could
+ cause a subsequent here document to fail has been fixed.
+02-09-14 A bug in whence which occurs when the specified name contained
+ a / has been fixed.
+02-09-14 A bug in the parser for strings of the form name$((expr))=value
+ has been fixed.
+02-09-14 A for loop optimization bug in which the number of elements in
+ an array was treated as an invariant has been fixed.
+02-09-09 A bug in which redirection or closing of a file descriptor between
+ 3 and 9 could cause a subsequent here document to fail has been
+ fixed.
+02-09-09 A bug in which a background job was not removed from the job list
+ when a subshell completed has been fixed, for example (prog&).
+02-09-03 A bug in which an assignment of the form name=(integer x=3)
+ could be interpretted as an array assignment rather than a
+ compound variable assignment has been fixed.
+02-08-19 A command completion bug which occurred on file systems that
+ are case insensitive has been fixed.
+02-08-19 A bug which could lead to an exception on some systems (for
+ example FREEBSD) which occurred when setting PATH has been fixed.
+02-08-11 A bug in arithmetic rounding in which a value input as a decimal
+ string would output as a rounded version of the string has
+ been fixed.
+02-08-11 A bug in which the last character could be deleted from shell
+ traces and from whence when called from a multibyte locale
+ has been fixed.
+02-08-01 A bug which could cause a core dump to occur when a shell script
+ is executed while a coprocess is running that has closed the
+ output pipe has been fixed.
+02-08-01 A bug in which command completion in multibyte mode could
+ corrupt memory for long command lines has been fixed.
+
+02-06-17 --- Release ksh93n- ---
+02-06-17 A bug in which user defined macros could cause a core dump in
+ with MULTIBYE mode has been fixed.
+02-06-17 A bug in which printf format specifiers of the form %2$s were causing
+ a core dump has been fixed.
+02-06-17 A bug in which setting stty to noecho mode did not prevent the
+ echoing of characters by ksh when emacs or viraw mode
+ was enabled has been fixed.
+02-06-17 A bug in which background job completion could cause the sleep
+ builtin to terminate prematurely has been fixed.
+02-06-17 A bug in which the shell could core dump if getopts was called
+ when the OPTIND variable contained a negative value has been fixed.
+02-06-10 The edit mode prompt has been modified to handle escape sequences.
+02-06-10 A bug which occurred for interactive shells in which the builtin
+ cat command was used in command substitution on a file whose
+ size was larger than PIPE_BUF has been fixed.
+02-06-10 A bug in which the trap on ERR was not being processed when
+ set inside a function has been fixed.
+02-06-07 A bug in which function definitions could cause the history count
+ to be decremented by one (and even become negative) has been fixed.
+02-06-05 A bug in read in which share mode could be enabled has been fixed.
+02-05-28 A bug which could occur when the last command of a script was
+ a case statement and the action selected ended in ;& instead of ;;
+ has been fixed.
+02-05-23 A bug with unary + introduced in ksh93k has been fixed.
+02-05-07 A bug in substitutions of the form ${var/pattern/string} in which
+ a backslash was inserted in the replacement string when it contained
+ a special pattern character has been fixed.
+02-05-01 A bug in the emacs edit mode which occurred in versions compiled
+ for multibyte character sets which occurred when a repeated search
+ was requested after a long line had been returned for the previous
+ search has been fixed.
+02-04-02 vi and emacs edit modes were modified so that tab completion is
+ disabled when invoked from the read built-in.
+
+02-03-26 --- Release ksh93m+ ---
+02-03-26 A bug in which \ was not handled correctly when used in file
+ expansion has been fixed.
+02-02-18 A bug in which lines beginning with a # were deleted from here
+ documents when the here-document delimiter was followed by
+ a comment has been fixed.
+02-12-06 An optimization bug in which ${!x[@]) was treated as invariant in
+ a for loop has been fixed.
+02-02-06 A bug in which the ERR trap is not cleared for a script invoked
+ by name from within a function has been fixed.
+02-01-08 A bug in which a shell script executed from within a subshell
+ could cause this script to have an invalid pointer leading
+ to a memory fault has been fixed.
+02-01-07 Added here documents of the form <<< word (as per zsh) which
+ is equivalent to << delim\nword\ndelim.
+02-01-07 A bug in which the first word of a compound assignment,
+ x=(word ...), was treated as a reserved word has been fixed.
+02-01-07 A bug in the handling of \ when noglob was enabled and a
+ substitution of the form ${word op pattern} occurred in the
+ same word has been fixed.
+02-01-07 A compilation option, CMDLIB_BLTIN in the file OPTION, has
+ been added. When this options is set, all commands implemented
+ in libcmd become shell builtin commands by default.
+02-01-07 A bug in which builtin foo, where foo is already a builtin
+ would result in the builtin foo getting removed has been fixed.
+02-01-07 A bug which the shell executed a command found in the current
+ directory when PATH have no valid directories has been fixed.
+01-11-28 The value of $? was not being set when called with exit.
+01-11-28 If the last command was of the form (...) and a trap on EXIT or
+ ERR was set, and the command inside () modified the trap, then
+ the original trap wasn't executed.
+01-11-26 The value for 0 is now preceded by the base number when
+ the base was not 10.
+01-11-26 The default has compilation mode has been changes so that
+ viraw mode will always be on.
+
+01-10-31 --- Release ksh93m ---
+01-10-31 A for loop optimizer bug for subshells contained withing for
+ loops has been fixed.
+01-10-16 typeset without arguments no longer outputs variable names
+ that do not have any attributes that are set.
+01-10-16 A bug introduced in ksh93l in which assignments specified with
+ the exec built-in were not being expanded properly has been
+ fixed.
+01-10-11 An optimization bug in which ${!x) was treated as invariant in
+ a for loop has been fixed.
+01-10-11 Unsigned integer variables in bases other than 10 are printed now
+ expand in that base with the base prefix.
+01-10-10 A number of typos in the self generating man pages for shell
+ built-ins have been fixed.
+01-10-04 The self generated man pages for hist and fc were not working
+ correctly and have been fixed.
+01-10-03 Yet another optimizer bug in which shell patterns were
+ treated as invariants has been fixed.
+01-09-27 Two bugs relating to multibyte history searches and to find
+ have been fixed.
+01-09-27 A bug introduced in ksh93k in which the PATH searching was
+ not restored after running a command with an assignment list
+ has been fixed.
+01-09-26 A bug in which a zero filled field was treated as octal when
+ converted to integer has been fixed.
+01-09-26 Yet another bug in the optimization of for loops related to
+ recursive functions with break or continue statements has been fixed.
+01-09-25 The exponentiation operator ** was added to the shell arithmetic
+ evaluation. It has higher precedence than * and is left
+ associative.
+01-09-25 The code was modified to use the ast multibyte macros
+ and functions for handing multibyte locales.
+01-09-25 The expansion ${parameter:offset:length} now handles negative
+ offsets which cause offsets to be measured from the end.
+01-09-25 Some spelling errors in the documentation were corrected.
+01-09-24 The /dev/tcp/host/port and /dev/udp/host/port now allow
+ the ports to be specified by service name.
+01-09-24 The change staring with ksh93g in which the the appropriate
+ library path variable is prepended with a corresponding library
+ directory has been modified. With the new method, only the
+ library path defined in the file named .paths in the directory
+ where the executable is found will be modified. See the
+ man page for more details.
+01-09-23 The .fpath file (see ksh93h) is no longer looked for in each
+ directory on the path to locate function directories. The
+ file named .paths is used instead.
+01-09-23 A bug in which IFS was not being restored after being changed in
+ a subshell has been fixed.
+01-09-16 With the vi and emacs edit modes, after a list of command
+ or functions is generated with = or M-= respectively,
+ any element from the list can be pasted on the command line
+ by preceding the = or M-= with a numeric parameter specifying
+ the position on the list.
+01-09-16 A bug in ksh93l caused command completion not to find aliases
+ and functions. Command listing from the edit mode was presented
+ in reverse order. This has been fixed.
+01-09-13 Another bug in the optimization of for loops related to subshells
+ when traps were set has been fixed.
+01-09-07 A change in ksh93l caused brace expansion to stop working
+ and this has been fixed.
+01-09-04 A bug introduced in ksh93k in which an arithmetic statement
+ within a function that used name references did not follow the
+ reference has been fixed.
+01-09-04 A bug introduced in ksh93l in which export -p did not prefix
+ each export with the word export has been fixed.
+01-08-29 A bug in multibyte input which occurred when a partial multibyte
+ character was received has been fixed.
+01-08-29 A bug introduced in ksh93l which could cause a core dump
+ when an assignment list containing PATH is specified inside
+ command substitution has been fixed.
+01-08-09 Another bug in the optimization of for loops in ksh93l caused
+ errors in recursive functions using local variables that
+ contained for loops has been fixed.
+01-07-27 A bug in which IFS would be unset after a command substitution
+ inside a here document has been fixed.
+01-07-26 To conform to the POSIX standard, if you invoked ksh name,
+ and name does not contain a /, it will first try to run
+ one in the current directory whether it is executable or not
+ before doing a path search for an executable script. Earlier
+ versions first checked for an executable script using the
+ PATH variable.
+01-07-23 A bug in which unset -f invoked in a subshell could unset a
+ function defined in the parent has been fixed.
+01-07-16 A bug in the optimization of for loops in ksh93l caused
+ name references to be treated as invariants has been fixed.
+01-07-09 A bug in which a discipline function applied to a local variable
+ could cause a shell exception has been fixed. Discipline
+ functions can only be specified for global variables.
+
+01-06-18 --- Release ksh93l ---
+01-06-18 A bug in assigning integers larger than can be represented as
+ long integers to floating point variables has been fixed.
+01-06-18 A bug in the handling of unsigned integers (typeset -ui) has
+ been fixed.
+01-06-04 The evaluation of the PS1 prompt no longer effects the value
+ of the $? variable.
+01-06-01 A small memory leak from subshells has been fixed.
+01-05-22 A bug in which attributes for variables that did not have
+ values would be lost after a subshell has been fixed.
+01-05-22 The %R format has been added to convert a shell pattern into
+ an extended regular expression.
+01-05-22 The escape sequences \e, \cX, \C[.collating-element.], and
+ \x{hex} have been added to ASCII-C strings and to printf format
+ strings.
+01-05-20 Patterns of the form {n}(pattern) and {m,n}(pattern) are now
+ recognized. The first form matches exactly n of pattern whereas,
+ the second form matches from m to n instances of pattern.
+01-05-20 The shell allows *-(pattern), +-(pattern), ?-(pattern),
+ {m,n}-(pattern}, and @-(pattern) to cause the minimal
+ match of pattern to be selected whenever possible rather
+ than the maximal (greedy) match.
+01-05-20 The character class [:word:] has been added to patterns.
+ The word class is the union of [:alnum:] and the character _.
+01-05-20 Inside (...) pattern groups, the \ character is now treated
+ specially even when in an enclosing character class. The
+ sequences, \w, \d, \s are equivalent to the character classes
+ word, digit, and space respectively. The sequences \W, \D,
+ and \S are their complement sets.
+01-05-20 The shell now recognizes pattern groups of the form
+ ~(options:pattern) where options or :pattern can be omitted.
+ Options use the letters + and - to enable and disable options
+ respectively. The option letters g (greedy), i (ignore case)
+ are used to cause maximal matching and to cause case
+ insensitive matching respectively. If :pattern is also
+ specified, these options are only in effect while this
+ pattern is being processed. Otherwise, these options remain
+ in effect until the end of the pattern group that they are contained
+ in or until another ~(...) is encountered. These pattern groups
+ are not counted with respect to group numbering.
+01-05-14 When edit completion, expansion, or listing occurs in the
+ middle of a quoted string, the leading quote is ignored when
+ performing the completion, expansion, or listing.
+01-05-14 A small memory leak from subshells has been fixed.
+01-05-10 A bug in which open files were not restored after a subshell
+ that had used exec to replace a file has been fixed.
+01-05-10 Redirection to a null file name now generates an error message.
+01-05-09 The shell now rejects some invalid parameter substitutions that
+ were previously processed in undefined ways.
+01-05-09 A bug in which the output of select was not flushed before the
+ read when input did not come from the terminal has been fixed.
+01-05-08 A bug in which job ids would not be freed for interactive shells
+ when subshells ran built-ins in the background has been fixed.
+01-05-08 The FPATH variable now requires an explicit . to cause the
+ current directory to be treated as a function directory.
+01-05-08 A bug in read -n when echo mode was disabled has been fixed.
+01-05-07 A bug in which function definitions could be listed as part
+ of the history has been fixed.
+01-04-30 This release uses a new and often much faster pattern matcher than
+ earlier releases.
+01-04-30 An optimizer now eliminates invariant parameter expansions from
+ for while and until loops.
+01-04-30 The variable .sh.match is set after each pattern match (# % or /)
+ in a variable substitution. The variable .sh.match is an
+ indexed array with element 0 being the complete match.
+ The array is only valid until the next subsequent pattern
+ match or until the value of the variable changes which ever
+ comes first.
+01-04-30 A self generating man page has been added to shcomp. Also,
+ shcomp now stops compiling when it finds an exit or exec
+ command and copies the remainder so that it can be used
+ for standard input.
+01-04-30 The shcomp command was modified so that it can work in an
+ EBCIDIC environment and that binary scripts are portable
+ across environments.
+01-04-30 A bug in the handling of a trailing : in PATH has been fixed.
+01-04-30 A bug in which the builtin version of a command would get invoked
+ even though the full pathname for the command was specified
+ has been fixed.
+01-04-30 A bug in which read would loose the last character when
+ reading the last line of a file that did not contain a new-line
+ character has been fixed.
+01-04-23 A bug on some systems in which in vi mode the end of file
+ character and end of line character could be swapped has
+ been fixed.
+01-04-23 A bug on some systems in which invoking a shell script that
+ did not have execute permission could set the exit value to
+ 127 rather than 126 has been fixed.
+01-04-20 A bug in which read -n from a pipe would block if fewer than
+ n characters was received has been fixed.
+01-04-09 A bug in which invalid patterns, for example, ) by itself,
+ was not treated as a string has been fixed so that if i=')',
+ then [[ $i == $i ]] is true.
+01-04-09 The shell arithmetic now interprets C character constants.
+01-04-09 A bug in which a non-zero return from a function defined
+ with the function reserved word did not trigger the ERR
+ trap or exit with set -e has been fixed.
+01-04-02 A bug on some systems, in which characters above 127 were
+ not displayed correctly in vi or emacs edit mode has been fixed.
+01-04-02 A bug on some systems, introduced in the 'k' point release, in
+ which the erase character in viraw mode was moving the cursor
+ to the left without erasing the character has been fixed.
+01-04-02 On some systems the wcwith() function was returning a wrong
+ value for characters and caused characters to be displayed
+ incorrectly from the shell edit modes. A work around for
+ this problem has been added.
+01-03-26 A bug in which valid scripts could produce syntax errors
+ when run with locales that considered characters such as "'"
+ to be space characters has been fixed.
+01-03-20 A bug in which an syntax error in an arithmetic expression
+ entered interactively could cause the shell to go into
+ an infinite loop outputting the error message has been fixed.
+01-03-10 ksh93 accepts -l as a synonym for -L in test on systems for
+ which /bin/test -l tests for symbolic links.
+01-03-10 A bug in parsing scripts in which { and } are used in place of
+ in and esac in case statements embedded in compound commands
+ has been fixed. Use of { and } for in and esac is obsolete.
+01-03-06 A bug in which an argument of the form foo=bar was not
+ being passed correctly to a traced function whose name
+ was foo has been fixed.
+01-03-02 Using $(trap -p name) did not print the name of the current
+ trap setting for trap name.
+01-02-26 Exported floating point variables gave incorrect results
+ when passing them to ksh88. This has been fixed.
+01-02-25 A race condition in which a coprocess which completed too quickly
+ would not allow subsequent coprocesses to start has been fixed.
+01-02-25 The 'g' format specifier is now handled by printf. It had
+ inadvertently been omitted.
+01-02-20 The + was not being displayed during an execution trace
+ with the += assignment operator.
+01-02-19 The error message which occurs when the interpreter name
+ defined on the #! line does not exist is more informative.
+01-02-19 A bug in which $0 would not be set correctly when a
+ script with #! was invoked by full pathname from the
+ directory of the script has been fixed.
+01-02-19 A shell script did not always pick up tty mode changes
+ made by external commands such as stty which could
+ effect the behavior of read.
+01-02-19 The -u, -g, and -k unary tests did not give the correct
+ results when used with negation and this has been fixed.
+
+01-02-05 --- Release ksh93k+ ---
+01-02-05 The sequence \<newline> inside $'...' was not incrementing
+ the line count and this has been fixed.
+01-02-05 Modified expansion of "${@-}" so that if no arguments are set
+ it results in null string rather than nothing.
+01-02-02 memory leak problem with local variables in functions fixed.
+01-01-25 allow arithmetic expressions with float%int and treat them
+ as ((int)float)%int rather than as an error.
+01-01-19 read -n1 was not working and has been fixed.
+01-01-17 ksh now handles the case in which a here document in command
+ substitution $() is terminated by the trailing ). Previously,
+ a new-line was needed at the end of the delimiter word.
+01-01-02 A bug in which a KEYBD trap would cause a multi-line token
+ to be processed incorrectly has been fixed.
+00-12-10 Arithmetic integer constants can now have L and U suffices.
+00-12-10 A bug in the processing of arithmetic expressions with compound
+ variables when the -n option is on has been fixed.
+00-12-08 A bug in M-f and M-b from emacs mode has been fixed. This
+ bug only occurs when ksh93 is compiled without MULTIBYTE enabled.
+00-11-29 A bug in which jobs -p would yield 0 for background
+ jobs run in a script has been fixed.
+00-11-21 A bug in integer arrays in which the number of elements is
+ incorrect when the ++ operator is applied to a non-existing
+ element has been fixed. For example, integer x; ((x[3]++)).
+00-11-20 A timing bug in which the shell could reset the terminal
+ group to the wrong value in the case that the a new process
+ changes the terminal group during startup has been fixed.
+
+00-10-27 --- Release ksh93k ---
+00-10-27 Using tab for completion now works only when applied
+ after a non-blank character at the end of the current line.
+ In other case a tab is inserted.
+00-10-27 A bug in the emacs edit mode for ^X^E has been fixed.
+ The ^X^E sequence is supposed to invoke the full editor
+ on the current command.
+00-10-18 A bug in which expansions of the form ${var//pattern/string}
+ did not work correctly when pattern was '/' or "/" has
+ been fixed.
+00-10-18 The output format for indexed arrays in compound variables
+ has been modified so that it can be used as input.
+00-10-18 Assignments with name references (typeset -n) will now
+ implicitly unreference an existing name reference.
+00-10-17 A bug the += append operator when a single array element
+ is appended to a variable that is not an array has been fixed.
+00-10-16 A bug in which the SIGCONT signal was being sent to
+ each process will kill -0 or kill -n 0 has been fixed.
+00-10-12 The arithmetic evaluation portion has been rewritten to
+ perform a number of optimizations.
+00-10-10 A bug in which name prefix matching ${!name.*} was not
+ checking name to see if it was a name reference has been fixed.
+00-09-26 A bug in the multibyte version in which the width of for
+ non-printing characters was not correct has been fixed.
+00-09-12 Made changes to get multibyte editing work on UWIN for windows
+00-09-12 A bug in which multibyte characters would be displayed incorrectly
+ has been fixed.
+00-08-08 Removed build dependency on iswprint() and iswalph().
+00-07-20 In some cases the read builtin would read more than a single
+ line from a pipe on standard input and therefore leave the seek
+ position in the wrong location.
+00-07-05 If the directory / is on the path, a / will not be inserted
+ between the directory and the file name during path searching
+ to avoid searching // for systems that treat this specially.
+00-06-26 A bug in which on rare occasions wait could return before all
+ jobs have completed has been fixed.
+00-06-21 A bug in which backspace did not work correctly during the
+ R replace directive in vi-mode has been fixed.
+00-06-12 Added variable name completion/expansion/listing to the set of
+ completions. Variable name completions begin with $ or "$ followed
+ by a letter.
+00-05-09 --- Release ksh93j ---
+00-05-09 Modified command substitution to avoid using /tmp files when
+ run on read-only file systems.
+00-04-17 Modified printf to handle '%..Xc' and '%..Xs' options where X
+ is not an alpha character. Previous versions core dumped with this.
+00-04-10 Changes to multibyte editing code were made to use standard
+ ISO C functions rather than methods devised before the standard.
+00-04-09 Add %H options to printf to output strings with <"'&\t> properly
+ converted for use in HTML and XML documents.
+00-04-07 Modified getopts builtin to handle \f...\f in usage string
+ by invoking specified function.
+00-04-04 Added self generating man pages for bg, fc, fg, disown, jobs,
+ hist, let, ., and ulimit.
+00-03-30 The append operator += has been added and can be used
+ for all assignments, strings, arrays, and compound variables.
+00-03-30 Code was modified in several places to support automatic
+ generation of C locale dictionaries.
+00-03-28 A bug in which the set and trap commands invoked with --name
+ type arguments would terminate the invoking script has
+ been fixed.
+00-03-27 A bug in which the library path variable was not updated
+ correctly on some systems as described in the 'g' point
+ release has been fixed.
+00-03-07 printf now returns a non-zero exit status when one of
+ its arguments cannot be converted to the given type.
+00-03-05 The return value and error message for a command that
+ was found on the path but was not executable was set
+ incorrectly.
+00-03-05 A prototype for ioctl() was removed from the vi edit mode.
+
+00-01-28 --- Release ksh93i ---
+00-01-28 Most of the built-in commands and ksh itself are now
+ self documenting. Running command --man will produce
+ screen output. Running command --html produces the
+ man page in html format.
+00-01-28 The getopts builtin can process command description
+ strings to produce man pages.
+00-01-28 A bug in which a script could terminate when getopts
+ encountered an error when invoked inside a function
+ has been fixed.
+00-01-28 When a symbolic link was specified as the name of
+ the script to invoke by name, the value of $0 was
+ set to the real file name rather than the link name
+ in some cases and this has been fixed.
+00-01-28 A bug in which the precision given as an argument
+ to printf was not working has been fixed.
+
+99-03-31 --- Release ksh93h ---
+99-03-31 The PATH search algorithm has been modified to look
+ for a file named .fpath in each bin directory and if
+ found, to search for functions in this directory if
+ it cannot find the command in that directory.
+99-03-31 When performing pathname expansion, the shell checks
+ to see whether each directory it reads is case sensitive
+ or not, and performs the matching accordingly.
+99-03-31 The %T format for printing formatted date/time.
+99-03-31 The emacs and vi modes now handle arrow keys when
+ they use standard ANSI escape sequences.
+99-03-31 The TAB key can be used for completion in emacs and viraw mode.
+99-03-31 A bug in setting .sh.editchar during the KEYBD trap
+ for the MULTIBYTE option was fixed in release ksh93h.
+99-03-31 A bug in shcomp for compilation of unary operators with [[...]]
+ has been fixed.
+99-03-31 A bug in which the value of $? was changed when executing
+ a keyboard trap has been fixed.
+99-03-31 The handling of SIGCHLD has been changed so that the
+ trap is not triggered while executing trap commands
+ to avoid recursive trap calls.
+99-03-31 A bug in which a local variable in a function declared readonly
+ would generated an error when the function went out of
+ scope has been fixed.
+99-03-31 A bug in which \<new_line> entered from the keyboard
+ with the KEYBD trap enabled has been fixed.
+99-03-31 The error message for a misplaced ((, for example print ((3),
+ was often garbled and has been fixed.
+99-03-31 A bug in the KEYBD trap in which escape sequences of the form
+ <ESC>[#~ were not being handled as a unit has been fixed.
+99-03-31 A bug in which ksh would consider expressions like [[ (a) ]]
+ as syntax errors has been fixed.
+99-03-31 A function defined as foo() without a function body
+ was not reported as a syntax error.
+99-03-31 A bug in which ksh could run out of file descriptors when
+ a stream was repeatedly opened with exec and read from
+ has been fixed.
+
+98-04-30 --- Release ksh93g ---
+98-04-30 The pipefail option has been added. With pipefail
+ enabled, a pipeline will not complete until all
+ commands are complete, and the return value will
+ be that of the last command to fail, or zero if
+ all complete successfully.
+98-04-30 The name-value pair library uses the cdt library rather
+ than the hash library. This change should be transparent
+ to applications.
+98-04-30 On the U/WIN version for Window 95 and Windows NT,
+ when a directory beginning with a letter followed by
+ a colon is given to cd, it is assumed to be an absolute
+ directory
+98-04-30 When an executable is found on a given path,
+ the appropriate library path variable is prepended
+ with a corresponding library directory.
+98-04-30 A bug in which a name reference could be created to
+ itself and later cause the shell to get into an infinite
+ loop has been fixed.
+98-04-30 A bug in shcomp relating to compound variables was fixed.
+98-04-30 A bug introduced in ksh93e in which leading 0's in -Z
+ fields caused the value to be treated as octal for arithmetic
+ evaluation has been fixed.
+98-04-30 A bug when a name reference with a shorter name than
+ the variable it references was the subject of a compound
+ assignment has been fixed.
+98-04-30 A bug which in which assignment to array variables in
+ a subshell could effect the parent shell has been
+ fixed.
+98-04-30 read name?prompt was putting a 0 byte at the end of the
+ prompt on standard error.
+98-04-30 A bug in [[ string1 > string2 ]] when ksh was run with -x
+ has been fixed.
+98-04-30 A bug in which the escape character was not processed
+ correctly inside {...} when brace expansion is enabled
+ has been fixed, for example {\$foo}.
+98-04-30 A bug in line continuation in here-documents has been
+ fixed.
+98-04-30 The default base when not specified with typeset -i is
+ 10 in accordance with the documentation. Previously,
+ the value was determined by the first assignment.
+98-04-30 A parsing bug in which a # preceded alphanumeric
+ characters inside a command substitution caused
+ a syntax error to be reported has been fixed.
+98-04-30 A bug in which a decimal constant represented as 10#ddd
+ where ddd was more than five digits generated a syntax
+ error has been fixed.
+98-04-30 A bug in here document expansion in which ${...} expansions
+ were split across buffer boundaries has been fixed.
+98-04-30 The sh_fun() function now takes third argument which
+ is an argument list for the invoked discipline function
+ or built-in.
+98-04-30 A callback function can be installed which will give
+ notification of file duplications and file closes.
+98-04-30 When ksh is compiled on systems that do not use fork()
+ current option settings where not propagated to sub-shells.
+
+97-06-30 --- Release ksh93f ---
+97-06-30 Hostnames in addition to host addresses can be given in
+ /dev/tcp/host/port virtual file names.
+97-06-30 File name completion and expansion now quotes special
+ characters in file names from both emacs and vi edit modes.
+97-06-30 An empty for list behave like a for list with null expansions.
+ It produces a warning message with sh -n.
+97-06-30 The code has been modified to work with EBCDIC as well as ASCII.
+97-06-30 A bug which would cause the secondary prompt to be
+ displayed when a user entered a literal carriage
+ return has been fixed.
+97-06-30 A bug which caused ksh read -s name to core dump was
+ fixed.
+97-06-30 A bug with the expansion of \} and \] inside double
+ quoted strings that also contained variable expansions
+ has been fixed
+97-06-30 Changes in the ksh93e point release caused autoload
+ functions invoked from within command substitution
+ to fail. This has been fixed.
+97-06-30 A bug in the processing of here-documents that could
+ prevent variable substitution to occur after $(...) command
+ substitution for long here documents has been fixed.
+97-06-30 A bug caused by a race condition that could cause SIGTERM
+ to be ignored by a child process has been fixed.
+97-06-30 A bug which prevented the startup of a coprocess immediately
+ after killing a running coprocess has been fixed.
+97-06-30 ulimit foobar, where foobar is not an arithmetic
+ expression, now gives an error message as it did with ksh88
+ instead of setting the file size limit to 0.
+97-06-30 A bug which could cause an interactive shell to terminate when
+ the last process of a pipeline was a POSIX function was fixed.
+97-06-30 A bug which could cause command substitution of a shell script
+ to core dump has been fixed.
+97-06-30 A security hole was fixed in suid_exec.
+97-06-30 Arithmetic functions such as pow() that take more than
+ one argument, did not work if arguments other than the
+ first contained parenthesized sub-expression.
+97-06-30 The error message from a script containing an incomplete
+ arithmetic expression has been corrected.
+97-06-30 A bug which caused a core dump on some machines when
+ the value of a name reference contained a positional
+ parameter and the name reference was not defined inside
+ a function has been fixed.
+97-06-30 Arithmetic expressions now correctly handle hexadecimal
+ constants.
+97-06-30 A bug in which integer variables could be expanded
+ with a leading 10# when declared with typeset -i
+ multiple times has been corrected.
+97-06-30 A bug in which IFS wasn't correctly restored when
+ set within command substitution has been fixed.
+97-06-30 The _ character is now considered as part of a word
+ with the M-f and M-b emacs directives as it was in ksh88.
+97-06-30 A bug in brace pattern expansions that caused expressions
+ such as {foo\,bar,bam} to expand incorrectly have been fixed.
+
+
+96-07-31 --- Release ksh93e ---
+96-07-31 The math functions, atan2, hypot, fmod, and pow were added.
+96-07-31 When a shared library is loaded, if the function lib_init()
+ is defined in the library, it is invoked the first time that
+ the library is loaded with builtin -f library.
+96-07-31 The k-shell information abstraction database option, KIA,
+ has been revamped.
+96-07-31 Empty command substitutions of the form $() now work.
+ whence -v foo now gives the correct result after calling
+ builtin -d foo.
+96-07-31 A bug in right to left arithmetic assignment for which
+ the arithmetic expression (( y = x = 1.5 )) did not
+ yield 1 for y when x was declared typeset -i was fixed.
+96-07-31 printf has been fixed to handle format containing \0
+ and/or \0145 correctly. In addition, characters following
+ %b in the format string are no longer displayed when
+ the operand contains \c.
+96-07-31 A bug in printf that could cause the %E format to
+ produce unnormalized results has been fixed.
+96-07-31 A bug which causes some arithmetic expressions to be
+ incorrectly evaluated as integer expressions rather
+ that floating point has been fixed.
+96-07-31 Functions defined inside a subshell no longer remain
+ defined when the subshell completes.
+96-07-31 The error message from sh -c ';echo foo' has been
+ corrected.
+96-07-31 The format for umask -S has been changed to agree
+ with the specification in the POSIX standard.
+96-07-31 A bug that caused side effects in subscript evaluation
+ when tracing was enabled for subscripts using ++ or --
+ has been fixed.
+96-07-31 To conform to the Posix standard getopts has been changed
+ so that the option char is set to ? when it returns with
+ a non-zero exit status.
+96-07-31 The handling of \} inside ${name...} has been fixed so
+ that the \ quotes the }.
+96-07-31 A bug that caused the read builtin to resume execution
+ after processing a trap has been fixed.
+96-07-31 [[ -s file ]] has been fixed so that if file is open
+ by ksh, it is flushed first.
+96-07-31 In some cases attributes and sizes for non exported
+ variables weren't being reset before running a script.
+96-07-31 The value of TMOUT was affected by changes make to
+ it in a subshell.
+96-07-31 The jobs command did not reflect changes make by
+ sending the CONT signal to a command.
+96-07-31 The error message for ksh -o unknown was incorrect.
+96-07-31 Functions invoked as name=value name, did not use
+ values from the calling scope when evaluating value.
+96-07-31 A bug in which the shell would reexecute previously
+ executed code when a shell script or coprocess was
+ run in the background has been fixed.
+96-07-31 A bug in which an empty here-document would leave
+ a file descriptor open has been fixed.
+96-07-31 A bug in which $(set -A array ...) would leave a
+ side effect has been fixed.
+96-07-31 A discipline function for a global variable defined
+ within a function defined with the function keyword,
+ incorrectly created a local variable of the same name
+ and applied the discipline to it.
+
+95-08-28 --- Release ksh93d ---
+95-08-28 The \ character was not handled correctly in replacement
+ patterns with ${x/pattern/replace}.
+95-08-28 A bug with read in which the line did not end with
+ a new-line has been fixed.
+95-08-28 A bug in file name generation which sometimes
+ appended a . for filenames that ended in / has
+ been fixed.
+95-08-28 If a process is waited for after a status has
+ been returned by a previous wait, wait now
+ returns 127.
+95-08-28 A bug with hist (fc) -e which prevented a command
+ to re-executed after it had been edited has been fixed.
+95-08-28 A bug which prevented quoting from removing the meaning
+ of unary test operators has been fixed.
+95-08-28 A bug with typeahead and KEYBOARD traps with the
+ MULTIBYTE option set has been fixed.
+95-08-28 Builtin functions can take a third argument which is
+ a void*.
+95-08-28 The nv_scan() function can restrict the scope of a walk
+ to the top scope.
+
+95-04-31 --- Release ksh93c ---
+95-04-31 The expansion of "$@" was incorrect when $1 was the null
+ string.
+95-04-31 A bug which could incorrectly report a syntax error in
+ a backquoted expression when a $ was preceded by \\
+ has been fixed.
+95-04-31 A bug which prevented the shell from exiting after
+ reporting an error when failing to open a script
+ has been fixed.
+95-04-31 A bug that could lead to memory corruption when a
+ large here document that required parameter or command
+ substitution was expanded has been fixed.
+95-04-31 A bug that could cause a core dump on some systems
+ after ksh detected an error when reading a function
+ has been fixed.
+95-04-31 A bug which could cause a coprocess to hang when
+ reading from a process that has terminated has been fixed.
+95-04-31 A bug which caused a script to terminate when set -e
+ was on and the first command of and && or || list
+ failed has been fixed.
+95-04-31 A bug with here documents inside $(...) when the delimiter
+ word is an identifier has been fixed.
+95-04-31 A bug which caused $0 to display the wrong value when
+ a script was invoked as an argument to the . command
+ and the eval command has been fixed.
+95-04-31 A bug that could cause the built-in sleep to hang
+ has been fixed.
+95-04-31 A bug introduces in 12/28/93b which caused the backslash
+ to be removed when it was followed by digit inside double
+ quotes in some instances has been fixed.
+95-04-31 A bug which could cause a core dump if ksh was invoked with
+ standard input closed has been fixed.
+95-04-31 A bug which could cause a core dump if typeset -A was
+ specified for an existing variable has been fixed.
+95-04-31 Variables that were unset but had attributes such as readonly
+ and export were not listed with readonly, export and typeset.
+95-04-31 Several problems with signals have been fixed.
+95-04-31 A bug which prevented ulimit -t from working has been fixed.
+ Also, a bug in which failed ulimits could cause a core dump
+ has also been fixed.
+95-04-31 A bug in expansion of the form ${name/#pattern/string} and
+ ${name/%pattern/string} has been fixed.
+95-04-31 A bug which caused read -r on a line that contained only
+ blanks to get a non-null value has been fixed.
+95-04-31 A bug introduced in the 'a' point release in which
+ ${x='\\'} expanded to \ when x was unset has been fixed.
+95-04-31 A bug which prevented a trap on EXIT from being executed
+ when the last command in a script was a function invocation
+ has been fixed.
+95-04-31 A bug which caused an interactive shell ignore input when
+ standard error was redirected to a file with exec,
+ and then restored with exec 2>&1 has been fixed.
+95-04-31 An interactive shell turns on monitor mode even when
+ standard error has been redirected to a file.
+95-04-31 A bug which could cause standard input to be incorrectly
+ positioned for the last command of a script has been fixed.
+95-04-31 A bug in the edit modes which allowed walking back in
+ the history file for more than HISTSIZE commands has
+ beed fixed.
+95-04-31 A bug which could cause a core dump if variable TMPDIR was
+ changed between two command substitutions has been fixed.
+95-04-31. A bug which prevented a trap on EXIT from being cleared
+ has been fixed.
+95-04-31 A bug fixed for the v directive in vi MULTIBYTE has been
+ fixed.
+95-04-31 Code to for IFS handling of multibyte characters has
+ been added.
+95-04-31 The displaying of multibyte strings in export, readonly,
+ typeset, and execution traces has been fixed.
+95-04-31 Variables inside functions are now statically scoped.
+ The previous behavior was never documented.
+95-04-31 Variables inside functions are now statically scoped.
+ The previous behavior was never documented.
+95-04-31 A few changes have been made to the name-value library
+ that affect built-ins that use disciplines. The
+ changes allow disciplines to be shared by variables
+ and should make it possible to add new disciplines
+ without recompilation.
+95-04-31 The name-value library interface has undergone significant
+ change for this revision. See the new nval.3 man page.
+
+94-12-31 --- Release ksh93b ---
+94-12-31 Variables inside functions are now statically scoped.
+ The previous behavior was never documented.
+94-12-31 If IFS contains two consecutive identical characters belonging
+ to the [:space:] class, then this character is treated as
+ a non-space delimiter so that each instance will delimit
+ a field. For example, IFS=$'\t\t' will cause two consecutive
+ tabs to delimit a null field.
+94-12-31 The getopts command has a -a name option that specifies a
+ name that will be used for usage messages.
+94-12-31 A bug which caused unset RANDOM to dump core has been
+ fixed.
+94-12-31 A bug which prevented return for terminating a profile
+ or ENV file has been fixed.
+94-12-31 A bug which prevented standard input from being
+ directed to /dev/null for background jobs when
+ monitor mode was turned off has been fixed.
+94-12-31 Statements of the form typeset -options var[expr]=value
+ did not perform substitutions on expr as expected.
+94-12-31 A bug which prevented the shell from sending a HUP
+ signal to some background jobs that were not disowned
+ has been fixed.
+94-12-31 A bug which allowed a script to trap signals that are
+ ignored at the time that the shell was invoked by exec
+ has been fixed.
+94-12-31 A bug which could cause a core dump when a discipline
+ function was unset within a discipline was fixed.
+94-12-31 The typeset builtin now accepts a first argument of
+ + or - for compatibility with ksh88.
+94-12-31 For compatibility with ksh88, the results of expansions
+ of command arguments will treat the extended character
+ match characters ()|& as ordinary characters.
+94-12-31 A bug which caused read to fail on a file that was
+ open for read/write with <> when the first operation
+ was print or printf has been fixed.
+94-12-31 When a job is suspended, it is put on the top of
+ the job list as required by the POSIX standard.
+94-12-31 The value of OPTARG when an option that required
+ an argument but didn't have one was incorrect in the
+ case the the option string began with a :.
+94-12-31 A bug which caused the terminal to get into a bad
+ state with some KEYBD traps in vi-mode has been fixed.
+94-12-31 A bug which caused an invalid trap to cause a script
+ to terminate, rather than just return an error, has
+ been fixed.
+94-12-31 Backreferencing sub-expressions in patterns and replacement
+ strings now works.
+94-12-31 A bug in chmod which caused the -R option to fail has
+ been fixed.
+94-12-31 More signal names have been added for Solaris
+
+94-06-30 --- Release ksh93a ---
+94-06-30 An expansion bug which causes portions of a word after
+ a $((...)) expansion that contains a nested $var expansion
+ to be lost has been fixed.
+94-06-30 A bug that caused a core dump when a script that did not
+ have PWD set and did a cd inside command substitution
+ has been fixed.
+94-06-30 A bug which caused a core dump on some machines when
+ the LANG variable was assigned to has been fixed.
+94-06-30 A bug which incorrectly handled set disciplines that
+ performed arithmetic evaluation when the discipline
+ was called from the arithmetic evaluator has been fixed.
+94-06-30 A bug caused by an EXIT trap inside a function that
+ was executed in a subshell was fixed.
+94-06-30 If foo is a function, and not a program, then command foo
+ now reports that foo isn't found rather than invoking foo.
+94-06-30 The previous version incorrectly listed -A as an
+ invocation option. The -A option is only for set.
+94-06-30 A bug was fixed which caused ksh to loop when execution trace
+ was enabled and the PS4 prompt required command substitution.
+94-06-30 A bug which could cause the job control switch character
+ to be disabled when a script that enabled monitor mode
+ terminated was fixed.
+94-06-30 A bug in the macro expansion global replacement operator //,
+ when the pattern began with a [ or +( has been fixed.
+94-06-30 A bug which prevented ~ expansion from occurring when
+ it was terminated with a colon inside an assignment
+ has been fixed.
+94-06-30 A bug in the dot command which prevented autoload functions
+ from working has been fixed.
+94-06-30 A bug which caused a variable to be unset if the
+ its value were expanded inside a set discipline has
+ been fixed.
+94-06-30 Whence -a now longer reports that a defined function
+ is undefined.
+94-06-30 A bug on some systems in which $0 would be incorrect
+ in scripts invoked by name has been fixed.
+94-06-30 Here documents with an empty body now work.
+94-06-30 A bug which disabled argument passing and resetting
+ of options for a script invoked by name inside a
+ function has been fixed.
+94-06-30 A bug in which an EXIT trap set the caller of a function
+ would be executed if a command called inside a function
+ was not found has been fixed.
+94-06-30 A bug which allowed a script to trap signals that are
+ ignored at the time that the shell was invoked has
+ been fixed.
+94-06-30 A bug which caused 2<&1- when applied to a shell built-in
+ to leave standard input closed has been fixed.
+94-06-30 A bug which caused the shell to incorrectly parse
+ $() command substitutions with nested case statements
+ has been fixed.
+
diff --git a/usr/src/lib/libshell/common/RELEASE88 b/usr/src/lib/libshell/common/RELEASE88
new file mode 100644
index 0000000000..2466e39781
--- /dev/null
+++ b/usr/src/lib/libshell/common/RELEASE88
@@ -0,0 +1,422 @@
+This is a list of changes that have been made since the 11/16/88 version
+of ksh.
+
+1. New features in 12/28/93
+ a. Associative arrays. The new version of ksh supports both
+ associate arrays and the older indexed arrays with the same
+ array syntax. A new -A option of typeset is used to declare
+ an array to be associative. As with indexed arrays, $name is
+ equivalent to ${name[0]}. The prefix operator ! was added
+ to the parameter expansion syntax to expand to the list of
+ indices. For example, ${!name[@]} expands to the list of array
+ indices for variable name.
+
+ b. Several additions have been made to shell arithmetic:
+ 1. The shell now performs floating point arithmetic. The
+ typeset options -F and -E have been added for floating
+ point and scientific notation respectively.
+ 2. The prefix and postfix ++ and -- operators.
+ 3. The comma and ?: operators.
+ 4. The math library functions.
+ 5. An arithmetic for statement of the form
+ for ((expr1; expr2; expr3))
+ do ...
+ done
+ 6. Integer arithmetic extended up to base 64.
+
+ c. Some additions to the macro expansion syntax have been made
+ to specify substrings and sub-arrays:
+ 1. ${name:expr} expands to the substring of ${name} starting at
+ the character position defined by arithmetic expression expr.
+ 2. ${name:expr1:expr2} expands to the substring of ${name} starting
+ at expr1 and consisting of at most expr2 characters.
+ 3. ${name[@]:expr} expands to the values of ${name[@]} starting at
+ the element defined by arithmetic expression expr.
+ 4. ${name[@]:expr1:expr2} expands to at most expr2 values of
+ ${name} starting at expr1.
+ 5. ${@:expr} expands the positional parameters starting at expr.
+ 6. ${@:expr1:expr2} expands to at most expr2 positional parameters
+ starting at expr1.
+ 7. ${!name} expands to the name of the variable named by name.
+ It will expand to name unless name is reference variable.
+ 8. ${!name[sub]} expands to the name of the subscript of the
+ given variable. If sub is @ or * the list of subscripts
+ is generated.
+ 9. ${!prefix*} and ${!prefix@} expand to the list of variable
+ names beginning with prefix.
+ 10. The substring operators, # and % can be now be applied
+ with aggregates (@ or *) and are applied to each.
+ 11. ${name/pattern/string} expands to the value of name with
+ the first occurrence of pattern replaced by string.
+ With aggregates (@ or *) this operation is applied to each.
+ 12. ${name/#pattern/string} Same as above but the pattern
+ to be replaced must match at the beginning.
+ 13. ${name/%pattern/string} Same as above but the pattern
+ to be replaced must match at the end.
+ 14. ${name//pattern/string} expands to the value of name with
+ the each occurrence of pattern replaced by string.
+ With aggregates (@ or *) this operation is applied to each.
+
+ d. The name space for variables has been extended. The character '.'
+ can be used at the beginning of a name, and to separate identifiers
+ within a name. However, to create a name of the form, foo.bar,
+ the variable foo must exist. The namespace starting with .sh
+ is reserved for shell implementation variables. Exported
+ variable cannot contain a '.'.
+
+ e. Compound assignments. The assignment syntax, varname=value,
+ has been extended to allow assignments of the form
+ varname=(assignment_list). As elsewhere in the shell
+ spaces or tabs are optional around the parentheses, and
+ no space is permitted between the varname and the =. The
+ assignment_list can be one of the following:
+ 1. A list of words. In this case each word is expanded as
+ in a for list and the resulting items become elements
+ of the indexed array varname.
+ 2. A list of subscript assignments in the form
+ [subscript]=value. In this, these elements become
+ elements of the associative array varname.
+ 3. A list of assignments; simple or compound. In this
+ case, each assignment is made to varname.name, where
+ name is the name of the enclosed assignment.
+ 4. Assignments in the form of readonly or typeset
+ statements. In this case each assignment is made as
+ in 3 above, and the attributes are given to the
+ corresponding variable.
+ In case 3 and 4 above, the value of "$varname" after
+ the above assignment is (assignment_list), where the
+ assignment_list produced would reproduce all of the
+ variables under varname.*.
+
+ f. Function names of the form variable.action (called discipline
+ functions) can be defined where variable is any valid variable
+ name and action is get, set, or unset. The function variable.get
+ is invoked each time the variable is referenced. The set
+ discipline is invoked each time the variable is assigned to.
+ The unset discipline is invoked when a variable is unset.
+ The new variables .sh.name, .sh.subscript, and .sh.value are
+ defined inside the function body. Other shell extensions
+ may have their own set of discipline functions.
+
+ g. The compound command !, which negates the return value of the
+ following pipeline, has been added.
+
+ h. On systems that support dynamic loading with dlopen(), it is
+ now possible to add built-in commands at runtime with the
+ a builtin command named builtin.
+
+ i. The following builtins have been added:
+ 1. command name [ ... ]
+ 2. sleep [decimal-seconds]
+ 3. builtin [-ds] [-f file] [name...]
+ 4. getconf name [pathname]
+ 5. disown [job...]
+
+ j. An addition format for literal strings, $'....' can
+ be used where ever literal strings are valid. The string
+ inside the single quotes will be converted using the ANSI-C
+ escape conventions. Additionally, the escape sequence \E
+ expands to the escape character (default \033) whenever ANSI-C
+ escape sequences are recognized.
+
+ k. A typeset -n option has been added which causes the value of a
+ variable to be treated as a reference to another variable so that
+ variables can be indirectly named. For example, if $1 contains
+ the name of a variable, then typeset -n foo=$1 causes the variable
+ foo to be synonymous with the variable whose name is $1. A builtin
+ alias, nameref='typeset -n' has been added to aid mnemonics.
+ Reference names cannot contain a '.'. Whenever that portion of
+ a variable up to the first '.' matches a reference name, the
+ reference value is substituted. For example, with nameref foo=.top,
+ then ${foo.bar} is equivalent to ${.top.bar}. When used as the
+ index of a for or select loop, each assignment causes a
+ new name reference to occur.
+
+ l. The KEYBD trap has been added which is triggered when a key
+ or escape sequence is typed while reading from the keyboard
+ in an edit mode. This, combined with some new variables
+ makes it possible to program your key bindings in ksh.
+
+ m. New variables have been added:
+ 1. FIGNORE defines a set of file names to be ignored in each
+ directory when performing pathname expansion, replacing
+ the rule that requires that a leading . be matched explicitly.
+ 2. Variable sh.edchar contains the value of the keyboard character
+ that has been entered when processing a KEYBD trap. If the value
+ is changed as part of the trap action, then the new value replaces
+ the key or keys that caused the trap.
+ 3. Variable sh.edcol is set to the character position of the cursor
+ within the input buffer during a KEYBD trap.
+ 4. Variable sh.edmode is set to the escape character when in vi
+ insert mode.
+ 5. Variable sh.edtext is set to the contents of the input buffer
+ during a KEYBD trap.
+ 6. HISTEDIT is checked before FCEDIT. FCEDIT is obsolete.
+ 7. HISTCMD is the number of the current command in the history
+ file.
+ 8. Variable .sh.version is set to the version string for
+ this shell.
+ 9. Variable .sh.name is set to the name of the variable
+ that that was referenced or assigned to when executing a get
+ or set discipline function.
+ 10. Variable .sh.subscript is set to the subscript for the variable
+ that was referenced or assign to when executing a get or
+ set discipline function.
+ 11. Variable .sh.value is set to the new value for the variable
+ that was assigned to when executing the set discipline function.
+
+ n. New invocation and set -o options have been added:
+ 1. set -o notify (or set -b) causes background completion messages
+ to be displayed as soon as the job completes.
+ 2. There is a compile time option named KIA which enables
+ creation of a relational database for commands, variables
+ and functions defined and referenced by a script. The
+ option -I <filename>, causes the database to be generated
+ in <filename>. The database format can be queried via
+ the cql command.
+ o. ksh93 can read and evaluate pre-compiled scripts generated by
+ a separate program called shcomp.
+ p. More work on internationalization has been added:
+ 1. The decimal point character is processed per locale
+ 2. A $ can be placed in front of each string to indicate
+ that the string needs translation but is otherwise ignored.
+ This means that if a message catalog of all $"..." strings
+ is generated, then a program such as print $"hello world"
+ could display "bonjour monde" in the french locale.
+ q. Backreferences have been added to pattern matching. The sequence
+ \d, where d is a digit from 1-9, matches the same string as
+ the d-th previous parenthesis group. Backreferences
+ can be used within patterns, and within replacement strings
+ with any of the ${name/...} operators.
+
+2. Changes made in 12/28/93
+ a. The output format of many commands has changed as follows:
+ 1. System error messages are displayed whenever a failure
+ is caused by a system call.
+ 2. The exit status has changed in many cases:
+ a. USAGE messages cause an exit status of 2.
+ b. Commands not found cause exit - 127.
+ c. Command found, but not executable - 126.
+ d. Terminated because of signal - 256+sig
+ 3. The output of values from built-ins that contain special
+ characters are quoted in a manner that then can be re-input.
+ 4. The trace output puts quotes around the output so that it
+ can be reused as input.
+ 5. The output for trap is in a format that can be reinput the
+ the shell to restore the traps.
+ 6. kill -l lists the signal names without numbers as
+ required by the POSIX standard.
+
+ b. The following changes have been made to shell functions:
+ 1. The semantics of functions declared with name() has changed
+ to conform with the IEEE-POSIX 1003.2 standard. In particular,
+ these functions are executed in a dot script environment rather
+ than a separated function environment so that there are no
+ local variables and no scoping for traps.
+ 2. Functions declared as function name, preserve the old ksh
+ semantics can be also used as the first argument to the dot (.)
+ command to have them executed in a dot script environment.
+
+ c. The command search rules have changed as follows:
+ 1. Special built-ins (those with a dagger in front of them) are
+ executed first.
+ 2. Functions are executed next.
+ 3. Other built-ins that do not require an executable version
+ (for example cd and read) come next.
+ 4. If the command name contains a slash, the pathname corresponding
+ to the command name is executed.
+ 5. If name corresponds to a previously encountered pathname
+ on the PATH variable, the corresponding command is executed.
+ 6. If the command name does not contain a slash, then the PATH
+ variable is used to find an executable by that name. If
+ the directory that the command is found is also contained in
+ the FPATH variable, then the command treated as a function.
+ If the shell has a built-in version of the command corresponding
+ to this command, then the built-in version of this command
+ is executed. Otherwise, the shell remembers that pathname
+ corresponding to this command name and executes this pathname.
+ 7. If the name is not found on PATH, then the directories in
+ FPATH are searched. If found, then the command is executed
+ as a function.
+
+ d. Built-in commands options now conform to the IEEE-POSIX 1003.2
+ conventions with some additions. In particular,
+ name -?
+ will now print a Usage line for name, except for true, false,
+ colon, login, newgrp, echo, [, and command.
+
+ e. Tilde expansion is now performed as part of the word expansions.
+ The effect of this is that if word begins with ~ in ${name op word},
+ it will be expanded unless escaped.
+
+ f. Pathname expansion is no longer performed on redirection words
+ unless the shell is interactive.
+
+ g. Changes to shell and options:
+ 1. The -n option has been enhanced to produce more warning and
+ portability messages.
+ 2. The -C option is equivalent to -o noclobber. Files are
+ created with O_EXCL when -C is on.
+
+ h. The following changes have been made to [[...]]:
+ 1. A string by itself is equivalent to -n string.
+ 2. -e has been added as equivalent to -a.
+ 3. == has been added as equivalent =.
+ 4. -a and = are now considered obsolete.
+ 5. Arithmetic comparisons are now considered obsolete.
+
+ i. kill has been changed as follows:
+ 1. Signal names can be upper case or lower case.
+ 2. Numerical arguments to kill -l cause the given signal names to
+ be displayed.
+ 3. String arguments to kill -l cause the given signal numbers to
+ be displayed.
+ 4. Synopsis changed for getopts conformance.
+
+ j. print has a -f format option which is equivalent to
+ the IEEE POSIX printf. Both print -f format, and
+ printf have the following extensions from IEEE POSIX:
+ 1. Floating point formats are supported.
+ 2. Size and precision specifications can be *.
+ 3. The %d option can take an argument after precision to
+ specify the base that the number will be displayed.
+ 4. A %q format can be used to output a string quoted so
+ that it can be re-input to the shell.
+ 5. A %P format can be used to output the shell pattern which
+ corresponds to the give extended regular expression.
+ 6. For numerical fields, the arguments can be arithmetic
+ expressions which will be evaluated.
+ 7. The %n format works as described in ANSI-C.
+
+ k. The following changes have been made to fc:
+ 1. It has been renamed hist. fc is now a predefined alias.
+ 2. hist uses ${HISTEDIT:-$FCEDIT}. FCEDIT is obsolete.
+ 3. A new -s option is equivalent to the obsolete -e -.
+ 4. If the first argument refers to a command earlier than the
+ first accessible command, it now implies the first accessible
+ command, so that hist -l 1 lists all accessible history commands.
+
+ l. The dot command (.) has changed as follows:
+ 1. The argument can be the name of a function declared as
+ function name. The function will execute without creating a
+ new scope.
+ 2. If there are arguments to the given script or function,
+ the positional parameters are restored to their original
+ value when . completes.
+
+ m. The read built-in has been changed as follows:
+ 1. A -A option to read has been added to allow the fields to be
+ read into an indexed array.
+ 2. A -t n option has been added which causes read to
+ timeout after n seconds when reading from a slow device.
+ 3. A -d char option has been added which causes the read
+ to terminate at char rather than at new-line.
+
+ n. The trap command has been changed as follows:
+ 1. Trap names can be either upper case or lower case.
+ 2. Trap -p cause only the specified trap values to be displayed.
+ 3. The value of trap in a subshell will be the value in the parent
+ shell until a call to trap which changes the trap settings has
+ been made. Thus, savetraps=$(trap) works as required by the
+ POSIX standard.
+
+ o. The exec command has been extended as follows:
+ 1. The -c option clears the environment first.
+ 2. The -a name option sets argv[0] to name for the program.
+
+ p. true and false are built-ins, not aliases to built-ins.
+
+ q. test has been modified to conform to the IEEE-POSIX 1003.2
+ standard when there are three or less arguments.
+
+ r. umask -S option displays the mask in a symbolic format.
+
+ s. wait now returns the correct exit status of any previous
+ background job that has not been waited for, not just
+ the most recent one.
+
+ t. The whence built-in has an option -a which causes all
+ uses for the given command name to be reported.
+
+ u. unalias has -a option to clear all the aliases.
+
+ v. The times built-in command has been removed. The time
+ reserved word, without a command, gives time cumulative
+ time for the shell and its children. A built-in alias
+ for times should enable scripts using times to continue
+ to run.
+
+ w. Command substitution and arithmetic substitution will now be
+ performed for PS1, ENV, and PS4 evaluation in addition to
+ parameter expansion.
+
+ x. The SECONDS variable now displays elapsed time in floating
+ point seconds with 3 places after the decimal point by
+ default.
+
+ y. The getopts built-in now handles the complete libast optget
+ functionality. If any errors have occurred with getopts
+ when it has reached the end of arguments, then the Usage
+ message will be generated from the option string and the
+ exit status from getopts will be 2 rather than 1. The
+ usage message will be stored in the OPTARG variable if
+ the option string contains a leading colon; otherwise
+ it will be printed on standard error automatically.
+
+ z. THE ENV file is only processed for interactive shell
+ invocations. In addition, the -x attributes for
+ aliases and functions is ignored.
+
+ aa. The built-in edit modes have been changed as follows:
+ 1. The pathname completion and pathname listing options
+ now perform command completion and command listing
+ when applied to a word in the command position.
+ 2. In emacs mode ^N as the first related command after
+ the prompt will move to the next command relative to the
+ last known history position.
+ 3. In emacs mode, successive kill and delete commands will
+ accumulate their data in the kill buffer, by appending or
+ prepending as appropriate. This mode will be reset by any
+ command not adding something to the kill buffer.
+ 4. The control-T of emacs mode has been changed to behave like
+ control-T in gnu-emacs.
+ bb. The TMOUT variable also sets a limit for select timeouts
+ and default timeouts for read.
+
+
+4. The source code has undergone significant modification.
+ a. Much of the code has been rewritten, In many cases this has
+ resulted in significant performance improvement.
+
+ b. The code is organized differently. See the README files
+ for more details.
+
+ c. Most configuration parameters now get generated using
+ the FEATURE mechanism of nmake. Other options are set
+ in the OPTIONS file.
+
+ c. The are several new compile time options. See the README
+ file for details. Some of the old ones have been removed.
+
+ d. The install script is a Mamfile that is generated by
+ nmake and processed by a script that comes with the
+ distribution.
+
+ e. There are far fewer global names. This should make it
+ must easier to add built-in commands without worrying
+ about conflicts.
+
+ f. The code uses the sfio library which makes it possible
+ to mix with stdio.
+
+ g. The code is written in ANSI C with full prototypes.
+ The code is based on the IEEE POSIX 1003.1 standard.
+ The code can be compiled with K&R C and with C++ by
+ using the ANSI cpp that comes with nmake or running
+ the code through the proto filter before pre-processing.
+ This happens automatically with our shipping system.
+
+ h. There is a programming interface for capturing references
+ and assignment to shell variables. It is also possible
+ to intercept variable creation and supply the array processing
+ function for that variable. See nval.3 for a description.
diff --git a/usr/src/lib/libshell/common/RELEASE93 b/usr/src/lib/libshell/common/RELEASE93
new file mode 100644
index 0000000000..e99c8781c6
--- /dev/null
+++ b/usr/src/lib/libshell/common/RELEASE93
@@ -0,0 +1,455 @@
+This is a list of changes that have been made since the 12/28/93 version
+of ksh.
+
+1. New features in 12/28/93b
+ a. If IFS contains two consecutive identical characters belonging
+ to the [:space:] class, then this character is treated as
+ a non-space delimiter so that each instance will delimit
+ a field. For example, IFS=$'\t\t' will cause two consecutive
+ tabs to delimit a null field.
+ b. The getopts command has a -a name option that specifies a
+ name that will be used for usage messages.
+
+2. New features in 12/28/93e
+ a. The math functions, atan2, hypot, fmod, and pow were added.
+ b. When a shared library is loaded, if the function lib_init()
+ is defined in the library, it is invoked the first time that
+ the library is loaded with builtin -f library.
+
+3. New features in 12/28/93f
+ a. Hostnames in addition to host addresses can be given in
+ /dev/tcp/host/port virtual file names.
+ b. File name completion and expansion now quotes special
+ characters in file names from both emacs and vi edit modes.
+
+4. New features in 12/28/93g
+ a. The pipefail option has been added. With pipefail
+ enabled, a pipeline will not complete until all
+ commands are complete, and the return value will
+ be that of the last command to fail, or zero if
+ all complete successfully.
+ b. When an executable is found on a given path,
+ the appropriate library path variable is prepended
+ with a corresponding library directory.
+5. New features in 12/28/93h
+ a. The PATH search algorithm has been modified to look
+ for a file named .fpath in each bin directory and if
+ found, to search for functions in this directory if
+ it cannot find the command in that directory.
+ b. When performing pathname expansion, the shell checks
+ to see whether each directory it reads is case sensitive
+ or not, and performs the matching accordingly.
+ c. The %T format for printing formatted date/time.
+6. New features in 12/28/93i
+ a. Most of the built-in commands and ksh itself are now
+ self documenting. Running command --man will produce
+ screen output. Running command --html produces the
+ man page in html format.
+ b. The getopts builtin can process command description
+ strings to produce man pages.
+
+7. Bugs fixed in 12/28/93a for default OPTIONS
+ a. An expansion bug which causes portions of a word after
+ a $((...)) expansion that contains a nested $var expansion
+ to be lost has been fixed.
+ b. A bug that caused a core dump when a script that did not
+ have PWD set and did a cd inside command substitution
+ has been fixed.
+ c. A bug which caused a core dump on some machines when
+ the LANG variable was assigned to has been fixed.
+ d. A bug which incorrectly handled set disciplines that
+ performed arithmetic evaluation when the discipline
+ was called from the arithmetic evaluator has been fixed.
+ e. A bug caused by an EXIT trap inside a function that
+ was executed in a subshell was fixed.
+ f. If foo is a function, and not a program, then command foo
+ now reports that foo isn't found rather than invoking foo.
+ g. The previous version incorrectly listed -A as an
+ invocation option. The -A option is only for set.
+ h. A bug was fixed which caused ksh to loop when execution trace
+ was enabled and the PS4 prompt required command substitution.
+ i. A bug which could cause the job control switch character
+ to be disabled when a script that enabled monitor mode
+ terminated was fixed.
+ j. A bug in the macro expansion global replacement operator //,
+ when the pattern began with a [ or +( has been fixed.
+ k. A bug which prevented ~ expansion from occurring when
+ it was terminated with a colon inside an assignment
+ has been fixed.
+ l. A bug in the dot command which prevented autoload functions
+ from working has been fixed.
+ m. A bug which caused a variable to be unset if the
+ its value were expanded inside a set discipline has
+ been fixed.
+ n. Whence -a now longer reports that a defined function
+ is undefined.
+ o. A bug on some systems in which $0 would be incorrect
+ in scripts invoked by name has been fixed.
+ p. Here documents with an empty body now work.
+ 1. A bug which disabled argument passing and resetting
+ of options for a script invoked by name inside a
+ function has been fixed.
+ r. A bug in which an EXIT trap set the caller of a function
+ would be executed if a command called inside a function
+ was not found has been fixed.
+ s. A bug which allowed a script to trap signals that are
+ ignored at the time that the shell was invoked has
+ been fixed.
+ t. A bug which caused 2<&1- when applied to a shell built-in
+ to leave standard input closed has been fixed.
+ u. A bug which caused the shell to incorrectly parse
+ $() command substitutions with nested case statements
+ has been fixed.
+
+8. Bugs fixed in 12/28/93b for default OPTIONS
+ a. A bug which caused unset RANDOM to dump core has been
+ fixed.
+ b. A bug which prevented return for terminating a profile
+ or ENV file has been fixed.
+ c. A bug which prevented standard input from being
+ directed to /dev/null for background jobs when
+ monitor mode was turned off has been fixed.
+ d. Statements of the form typeset -options var[expr]=value
+ did not perform substitutions on expr as expected.
+ e. A bug which prevented the shell from sending a HUP
+ signal to some background jobs that were not disowned
+ has been fixed.
+ f. A bug which allowed a script to trap signals that are
+ ignored at the time that the shell was invoked by exec
+ has been fixed.
+ g. A bug which could cause a core dump when a discipline
+ function was unset within a discipline was fixed.
+ h. The typeset builtin now accepts a first argument of
+ + or - for compatibility with ksh88.
+ i. For compatibility with ksh88, the results of expansions
+ of command arguments will treat the extended character
+ match characters ()|& as ordinary characters.
+ j. A bug which caused read to fail on a file that was
+ open for read/write with <> when the first operation
+ was print or printf has been fixed.
+ k. When a job is suspended, it is put on the top of
+ the job list as required by the POSIX standard.
+ l. The value of OPTARG when an option that required
+ an argument but didn't have one was incorrect in the
+ case the the option string began with a :.
+ m. A bug which caused the terminal to get into a bad
+ state with some KEYBD traps in vi-mode has been fixed.
+ n. A bug which caused an invalid trap to cause a script
+ to terminate, rather than just return an error, has
+ been fixed.
+ o. Backreferencing sub-expressions in patterns and replacement
+ strings now works.
+ p. A bug in chmod which caused the -R option to fail has
+ been fixed.
+
+9. Bugs fixed in 12/28/93c for default OPTIONS
+ a. The expansion of "$@" was incorrect when $1 was the null
+ string.
+ b. A bug which could incorrectly report a syntax error in
+ a backquoted expression when a $ was preceded by \\
+ has been fixed.
+ c. A bug which prevented the shell from exiting after
+ reporting an error when failing to open a script
+ has been fixed.
+ d. A bug that could lead to memory corruption when a
+ large here document that required parameter or command
+ substitution was expanded has been fixed.
+ e. A bug that could cause a core dump on some systems
+ after ksh detected an error when reading a function
+ has been fixed.
+ f. A bug which could cause a coprocess to hang when
+ reading from a process that has terminated has been fixed.
+ g. A bug which caused a script to terminate when set -e
+ was on and the first command of and && or || list
+ failed has been fixed.
+ h. A bug with here documents inside $(...) when the delimiter
+ word is an identifier has been fixed.
+ i. A bug which caused $0 to display the wrong value when
+ a script was invoked as an argument to the . command
+ and the eval command has been fixed.
+ j. A bug that could cause the built-in sleep to hang
+ has been fixed.
+ k. A bug introduces in 12/28/93b which caused the backslash
+ to be removed when it was followed by digit inside double
+ quotes in some instances has been fixed.
+ l. A bug which could cause a core dump if ksh was invoked with
+ standard input closed has been fixed.
+ m. A bug which could cause a core dump if typeset -A was
+ specified for an existing variable has been fixed.
+ n. Variables that were unset but had attributes such as readonly
+ and export were not listed with readonly, export and typeset.
+ o. Several problems with signals have been fixed.
+ p. A bug which prevented ulimit -t from working has been fixed.
+ Also, a bug in which failed ulimits could cause a core dump
+ has also been fixed.
+ q. A bug in expansion of the form ${name/#pattern/string} and
+ ${name/%pattern/string} has been fixed.
+ r. A bug which caused read -r on a line that contained only
+ blanks to get a non-null value has been fixed.
+ s. A bug introduced in the 'a' point release in which
+ ${x='\\'} expanded to \ when x was unset has been fixed.
+ t. A bug which prevented a trap on EXIT from being executed
+ when the last command in a script was a function invocation
+ has been fixed.
+ u. A bug which caused an interactive shell ignore input when
+ standard error was redirected to a file with exec,
+ and then restored with exec 2>&1 has been fixed.
+ v. An interactive shell turns on monitor mode even when
+ standard error has been redirected to a file.
+ w. A bug which could cause standard input to be incorrectly
+ positioned for the last command of a script has been fixed.
+ y. A bug in the edit modes which allowed walking back in
+ the history file for more than HISTSIZE commands has
+ beed fixed.
+ z. A bug which could cause a core dump if variable TMPDIR was
+ changed between two command substitutions has been fixed.
+ aa. A bug which prevented a trap on EXIT from being cleared
+ has been fixed.
+
+10. Bugs fixed in 12/28/93d for default OPTIONS
+ a. The \ character was not handled correctly in replacement
+ patterns with ${x/pattern/replace}.
+ b. A bug with read in which the line did not end with
+ a new-line has been fixed.
+ c. A bug in file name generation which sometimes
+ appended a . for filenames that ended in / has
+ been fixed.
+ d. If a process is waited for after a status has
+ been returned by a previous wait, wait now
+ returns 127.
+ e. A bug with hist (fc) -e which prevented a command
+ to re-executed after it had been edited has been fixed.
+ f. A bug which prevented quoting from removing the meaning
+ of unary test operators has been fixed.
+
+11. Bugs fixed in 12/28/93e for default OPTIONS
+ a. Empty command substitutions of the form $() now work.
+ b. whence -v foo now gives the correct result after calling
+ builtin -d foo.
+ c. A bug in right to left arithmetic assignment for which
+ the arithmetic expression (( y = x = 1.5 )) did not
+ yield 1 for y when x was declared typeset -i was fixed.
+ d. printf has been fixed to handle format containing \0
+ and/or \0145 correctly. In addition, characters following
+ %b in the format string are no longer displayed when
+ the operand contains \c.
+ e. A bug in printf that could cause the %E format to
+ produce unnormalized results has been fixed.
+ f. A bug which causes some arithmetic expressions to be
+ incorrectly evaluated as integer expressions rather
+ that floating point has been fixed.
+ g. Functions defined inside a subshell no longer remain
+ defined when the subshell completes.
+ h. The error message from sh -c ';echo foo' has been
+ corrected.
+ i. The format for umask -S has been changed to agree
+ with the specification in the POSIX standard.
+ j. A bug that caused side effects in subscript evaluation
+ when tracing was enabled for subscripts using ++ or --
+ has been fixed.
+ k. To conform to the Posix standard getopts has been changed
+ so that the option char is set to ? when it returns with
+ a non-zero exit status.
+ l. The handling of \} inside ${name...} has been fixed so
+ that the \ quotes the }.
+ m. A bug that caused the read builtin to resume execution
+ after processing a trap has been fixed.
+ n. [[ -s file ]] has been fixed so that if file is open
+ by ksh, it is flushed first.
+ o. In some cases attributes and sizes for non exported
+ variables weren't being reset before running a script.
+ p. The value of TMOUT was affected by changes make to
+ it in a subshell.
+ q. The jobs command did not reflect changes make by
+ sending the CONT signal to a command.
+ r. The error message for ksh -o unknown was incorrect.
+ s. Functions invoked as name=value name, did not use
+ values from the calling scope when evaluating value.
+ t. A bug in which the shell would reexecute previously
+ executed code when a shell script or coprocess was
+ run in the background has been fixed.
+ u. A bug in which an empty here-document would leave
+ a file descriptor open has been fixed.
+ v. A bug in which $(set -A array ...) would leave a
+ side effect has been fixed.
+ w. A discipline function for a global variable defined
+ within a function defined with the function keyword,
+ incorrectly created a local variable of the same name
+ and applied the discipline to it.
+
+12. Bugs fixed in 12/28/93f for default OPTIONS
+ a. A bug which would cause the secondary prompt to be
+ displayed when a user entered a literal carriage
+ return has been fixed.
+ b. I bug which caused ksh read -s name to core dump was
+ fixed.
+ c. I bug with the expansion of \} and \] inside double
+ quoted strings that also contained variable expansions
+ has been fixed
+ d. Changes in the 'e' point release caused autoload
+ functions invoked from within command substitution
+ to fail. This has been fixed.
+ e. A bug in the processing of here-documents that could
+ prevent variable substitution to occur after $(...) command
+ substitution for long here documents has been fixed.
+ f. A bug caused by a race condition that could cause SIGTERM
+ to be ignored by a child process has been fixed.
+ g. A bug which prevented the startup of a coprocess immediately
+ after killing a running coprocess has been fixed.
+ h. ulimit foobar, where foobar is not an arithmetic
+ expression, now gives an error message as it did with ksh88
+ instead of setting the file size limit to 0.
+ i. A bug which could cause an interactive shell to terminate when
+ the last process of a pipeline was a POSIX function was fixed.
+ j. A bug which could cause command substitution of a shell script
+ to core dump has been fixed.
+ k. A security hole was fixed in suid_exec.
+ l. Arithmetic functions such as pow() that take more than
+ one argument, did not work if arguments other than the
+ first contained parenthesized sub-expression.
+ m. The error message from a script containing an incomplete
+ arithmetic expression has been corrected.
+ n. A bug which caused a core dump on some machines when
+ the value of a name reference contained a positional
+ parameter and the name reference was not defined inside
+ a function has been fixed.
+ o. Arithmetic expressions now correctly handle hexidecimal
+ constants.
+ p. A bug in which integer variables could be expanded
+ with a leading 10# when declared with typeset -i
+ multiple times has been corrected.
+ q. A bug in which IFS wasn't correctly restored when
+ set within command substitution has been fixed.
+ r. The _ character is now considered as part of a word
+ with the M-f and M-b emacs directives as it was in ksh88.
+
+13. Bugs fixed in 12/28/93g for default OPTIONS
+ a. A bug in which a name reference could be created to
+ itself and later cause the shell to get into an infinite
+ loop has been fixed.
+ b. A bug in shcomp relating to compound variables was fixed.
+ c. A bug introduced in 'e' in which leading 0's in -Z
+ fields caused the value to be treated as octal for arithmetic
+ evaluation has been fixed.
+ d. A bug when a name reference with a shorter name than
+ the variable it references was the subject of a compound
+ assignment has been fixed.
+ e. A bug which in which assignment to array variables in
+ a subshell could effect the parent shell has been
+ fixed.
+ f. read name?prompt was putting a 0 byte at the end of the
+ prompt on standard error.
+ g. A bug in [[ string1 > string2 ]] when ksh was run with -x
+ has been fixed.
+ k. A bug in which the escape character was not processed
+ correctly inside {...} when brace expansion is enabled
+ has been fixed, for example {\$foo}.
+ l. A bug in line continuation in here-documents has been
+ fixed.
+ m. The default base when not specified with typeset -i is
+ 10 in accordance with the documentation. Previously,
+ the value was determined by the first assignment.
+ n. A parsing bug in which a # preceded alphanumeric
+ characters inside a command substitution caused
+ a syntax error to be reported has been fixed.
+ o. A bug in which a decimal constant represented as 10#ddd
+ where ddd was more than five digits generated a syntax
+ error has been fixed.
+ p. A bug in here document expansion in which ${...} expansions
+ were split across buffer boundaries has been fixed.
+
+14. Bugs fixed in 12/28/93h for default OPTIONS
+ a. I bug in shcomp for compilation of unary operators with [[...]]
+ has been fixed.
+ b. A bug in which the value of $? was changed when executing
+ a keyboard trap has been fixed.
+ c. The handling of SIGCHLD has been changed so that the
+ trap is not triggered while executing trap commands
+ to avoid recursive trap calls.
+ d. I bug in which a local variable in a function declared readonly
+ would generated an error when the function went out of
+ scope has been fixed.
+ e. I bug in which \<new_line> entered from the keyboard
+ with the KEYBD trap enabled has been fixed.
+ f. The error message for a misplaced ((, for example print ((3),
+ was often garbled and has been fixed.
+ g. I bug in the KEYBD trap in which escape sequences of the form
+ <ESC>[#~ were not being handled as a unit has been fixed.
+ h. A bug in which ksh would consider expressions like [[ (a) ]]
+ as syntax errors has been fixed.
+ i. A function defined as foo() without a function body
+ was not reported as a syntax error.
+ j. A bug in which ksh could run out of file descriptors when
+ a stream was repeatedly opened with exec and read from
+ has been fixed.
+ k. A bug introduced when fixing item n from the 'g' point
+ release has been fixed.
+
+15. Bugs fixed in 12/28/93i for default OPTIONS
+ a. A bug in which a script could terminate when getopts
+ encountered an error when invoked inside a function
+ has been fixed.
+ b. When a symbolic link was specified as the name of
+ the script to invoke by name, the value of $0 was
+ set to the real file name rather than the link name
+ in some cases and this has been fixed.
+
+16. Bug fixes for specific non-default option combinations.
+ a. More signal names have been added for Solaris
+ b. A bug fixed for the v directive in vi MULTIBYTE has been
+ fixed.
+ c. Code to for IFS handling of multibyte characters has
+ been added.
+ d. The displaying of multibyte strings in export, readonly,
+ typeset, and execution traces has been fixed.
+ e. A bug with type ahead and KEYBOARD traps with the
+ MULTIBYTE option set has been fixed.
+ f. The k-shell information abstraction database option, KIA,
+ has been revamped for the 'e' point release.
+ g. A bug in brace pattern expansions that caused expressions
+ such as {foo\,bar,bam} to expand incorrectly have been fixed.
+ h. On the U/WIN version for Window 95 and Windows NT,
+ when a directory beginning with a letter followed by
+ a colon is given to cd, it is assumed to be an absolute
+ directory.
+ i. There was a bug in the compile option that does not
+ use fork() in which the current option settings where
+ not propagated to sub-shells.
+ j. A bug in setting .sh.editchar during the KEYBD trap
+ for the MULTIBYTE option was fixed in release 'h'.
+ k. A bug in which the precision given as an argument
+ to printf was not working has been fixed.
+
+17. Other changes to 12/28/93[abcdefghi]
+ a. A couple of minor changes to make adding built-ins easier.
+ b. Variables inside functions are now statically scoped.
+ The previous behavior was never documented.
+ c. A few changes have been made to the name-value library
+ that affect built-ins that use disciplines. The
+ changes allow disciplines to be shared by variables
+ and should make it possible to add new disciplines
+ without recompilation.
+ d. The name-value library interface has undergone significant
+ change for this revision. See the new nval.3 man page.
+ e. Builtin functions can take a third argument which is
+ a void*.
+ f. The nv_scan() function can restrict the scope of a walk
+ to the top scope. Starting in 'f', nv_scan() has an
+ additional pointer argument that is passed to each invoked
+ function.
+ g. Starting with release 'f', an empty for list behave like
+ a for list with null expansions. It produces a warning
+ message with sh -n.
+ h. Starting with release 'f' the code has been modified to
+ work with EBCDIC as well as ASCII.
+ i. Starting with the release 'g', the name-value pair library
+ uses the cdt library rather than the hash library.
+ j. The sh_fun() function now takes third argument which
+ is an argument list for the invoked discipline function
+ or built-in.
+ k. A callback function can be installed which will give
+ notification of file duplications and file closes.
+
+18. Incompatibilities with 12/28/93 version.
+ None intentional.
+
diff --git a/usr/src/lib/libshell/common/bltins/alarm.c b/usr/src/lib/libshell/common/bltins/alarm.c
new file mode 100644
index 0000000000..6f4aa2f644
--- /dev/null
+++ b/usr/src/lib/libshell/common/bltins/alarm.c
@@ -0,0 +1,276 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * alarm [-r] [varname [+]when]
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#include "defs.h"
+#include <error.h>
+#include <stak.h>
+#include "builtins.h"
+#include "FEATURE/time"
+
+#define R_FLAG 1
+#define L_FLAG 2
+
+struct tevent
+{
+ Namfun_t fun;
+ Namval_t *node;
+ Namval_t *action;
+ struct tevent *next;
+ long milli;
+ int flags;
+ void *timeout;
+ Shell_t *sh;
+};
+
+static const char ALARM[] = "alarm";
+
+static void trap_timeout(void*);
+
+/*
+ * insert timeout item on current given list in sorted order
+ */
+static void *time_add(struct tevent *item, void *list)
+{
+ register struct tevent *tp = (struct tevent*)list;
+ if(!tp || item->milli < tp->milli)
+ {
+ item->next = tp;
+ list = (void*)item;
+ }
+ else
+ {
+ while(tp->next && item->milli > tp->next->milli)
+ tp = tp->next;
+ item->next = tp->next;
+ tp->next = item;
+ }
+ tp = item;
+ tp->timeout = (void*)sh_timeradd(tp->milli,tp->flags&R_FLAG,trap_timeout,(void*)tp);
+ return(list);
+}
+
+/*
+ * delete timeout item from current given list, delete timer
+ */
+static void *time_delete(register struct tevent *item, void *list)
+{
+ register struct tevent *tp = (struct tevent*)list;
+ if(item==tp)
+ list = (void*)tp->next;
+ else
+ {
+ while(tp && tp->next != item)
+ tp = tp->next;
+ if(tp)
+ tp->next = item->next;
+ }
+ if(item->timeout)
+ timerdel((void*)item->timeout);
+ return(list);
+}
+
+static void print_alarms(void *list)
+{
+ register struct tevent *tp = (struct tevent*)list;
+ while(tp)
+ {
+ if(tp->timeout)
+ {
+ register char *name = nv_name(tp->node);
+ if(tp->flags&R_FLAG)
+ {
+ double d = tp->milli;
+ sfprintf(sfstdout,e_alrm1,name,d/1000.);
+ }
+ else
+ sfprintf(sfstdout,e_alrm2,name,nv_getnum(tp->node));
+ }
+ tp = tp->next;
+ }
+}
+
+static void trap_timeout(void* handle)
+{
+ register struct tevent *tp = (struct tevent*)handle;
+ tp->sh->trapnote |= SH_SIGALRM;
+ if(!(tp->flags&R_FLAG))
+ tp->timeout = 0;
+ tp->flags |= L_FLAG;
+ tp->sh->sigflag[SIGALRM] |= SH_SIGALRM;
+ if(sh_isstate(SH_TTYWAIT))
+ sh_timetraps();
+}
+
+void sh_timetraps(void)
+{
+ register struct tevent *tp, *tpnext;
+ register struct tevent *tptop;
+ while(1)
+ {
+ sh.sigflag[SIGALRM] &= ~SH_SIGALRM;
+ tptop= (struct tevent*)sh.st.timetrap;
+ for(tp=tptop;tp;tp=tpnext)
+ {
+ tpnext = tp->next;
+ if(tp->flags&L_FLAG)
+ {
+ tp->flags &= ~L_FLAG;
+ if(tp->action)
+ sh_fun(tp->action,tp->node,(char**)0);
+ tp->flags &= ~L_FLAG;
+ if(!tp->flags)
+ {
+ nv_unset(tp->node);
+ nv_close(tp->node);
+ }
+ }
+ }
+ if(!(sh.sigflag[SIGALRM]&SH_SIGALRM))
+ break;
+ }
+}
+
+
+/*
+ * This trap function catches "alarm" actions only
+ */
+static char *setdisc(Namval_t *np, const char *event, Namval_t* action, Namfun_t
+ *fp)
+{
+ register struct tevent *tp = (struct tevent*)fp;
+ if(!event)
+ return(action?"":(char*)ALARM);
+ if(strcmp(event,ALARM)!=0)
+ {
+ /* try the next level */
+ return(nv_setdisc(np, event, action, fp));
+ }
+ if(action==np)
+ action = tp->action;
+ else
+ tp->action = action;
+ return(action?(char*)action:"");
+}
+
+/*
+ * catch assignments and set alarm traps
+ */
+static void putval(Namval_t* np, const char* val, int flag, Namfun_t* fp)
+{
+ register struct tevent *tp;
+ register double d;
+ if(val)
+ {
+ double now;
+#ifdef timeofday
+ struct timeval tmp;
+ timeofday(&tmp);
+ now = tmp.tv_sec + 1.e-6*tmp.tv_usec;
+#else
+ now = (double)time(NIL(time_t*));
+#endif /* timeofday */
+ nv_putv(np,val,flag,fp);
+ d = nv_getnum(np);
+ tp = (struct tevent*)fp;
+ if(*val=='+')
+ {
+ double x = d + now;
+ nv_putv(np,(char*)&x,NV_INTEGER,fp);
+ }
+ else
+ d -= now;
+ tp->milli = 1000*(d+.0005);
+ if(tp->timeout)
+ sh.st.timetrap = time_delete(tp,sh.st.timetrap);
+ if(tp->milli > 0)
+ sh.st.timetrap = time_add(tp,sh.st.timetrap);
+ }
+ else
+ {
+ tp = (struct tevent*)nv_stack(np, (Namfun_t*)0);
+ sh.st.timetrap = time_delete(tp,sh.st.timetrap);
+ if(tp->action)
+ nv_close(tp->action);
+ nv_unset(np);
+ free((void*)fp);
+ }
+}
+
+static const Namdisc_t alarmdisc =
+{
+ sizeof(struct tevent),
+ putval,
+ 0,
+ 0,
+ setdisc,
+};
+
+int b_alarm(int argc,char *argv[],void *extra)
+{
+ register int n,rflag=0;
+ register Namval_t *np;
+ register struct tevent *tp;
+ register Shell_t *shp = (Shell_t*)extra;
+ while (n = optget(argv, sh_optalarm)) switch (n)
+ {
+ case 'r':
+ rflag = R_FLAG;
+ break;
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argc -= opt_info.index;
+ argv += opt_info.index;
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),optusage((char*)0));
+ if(argc==0)
+ {
+ print_alarms(shp->st.timetrap);
+ return(0);
+ }
+ if(argc!=2)
+ errormsg(SH_DICT,ERROR_usage(2),optusage((char*)0));
+ np = nv_open(argv[0],shp->var_tree,NV_NOARRAY|NV_VARNAME|NV_NOASSIGN);
+ if(!nv_isnull(np))
+ nv_unset(np);
+ nv_setattr(np, NV_INTEGER|NV_DOUBLE);
+ if(!(tp = newof(NIL(struct tevent*),struct tevent,1,0)))
+ errormsg(SH_DICT,ERROR_exit(1),e_nospace);
+ tp->fun.disc = &alarmdisc;
+ tp->flags = rflag;
+ tp->node = np;
+ tp->sh = shp;
+ nv_stack(np,(Namfun_t*)tp);
+ nv_putval(np, argv[1], 0);
+ return(0);
+}
+
diff --git a/usr/src/lib/libshell/common/bltins/cd_pwd.c b/usr/src/lib/libshell/common/bltins/cd_pwd.c
new file mode 100644
index 0000000000..f57f7c977e
--- /dev/null
+++ b/usr/src/lib/libshell/common/bltins/cd_pwd.c
@@ -0,0 +1,280 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * cd [-LP] [dirname]
+ * cd [-LP] [old] [new]
+ * pwd [-LP]
+ *
+ * David Korn
+ * AT&T Labs
+ * research!dgk
+ *
+ */
+
+#include "defs.h"
+#include <stak.h>
+#include <error.h>
+#include "variables.h"
+#include "path.h"
+#include "name.h"
+#include "builtins.h"
+#include <ls.h>
+#include <ctype.h>
+
+#ifdef PATH_BFPATH
+/*
+ * Invalidate path name bindings to relative paths
+ */
+static void rehash(register Namval_t *np,void *data)
+{
+ Pathcomp_t *pp = (Pathcomp_t*)np->nvalue.cp;
+ NOT_USED(data);
+ if(pp && *pp->name!='/')
+ nv_unset(np);
+}
+#endif
+
+int b_cd(int argc, char *argv[],void *extra)
+{
+#ifdef PATH_BFPATH
+ register char *dir;
+ Pathcomp_t *cdpath = 0;
+#else
+ register char *dir, *cdpath="";
+#endif
+ register const char *dp;
+ register Shell_t *shp = (Shell_t*)extra;
+ int saverrno=0;
+ int rval,flag=0;
+ char *oldpwd;
+ Namval_t *opwdnod, *pwdnod;
+ if(sh_isoption(SH_RESTRICTED))
+ errormsg(SH_DICT,ERROR_exit(1),e_restricted+4);
+ while((rval = optget(argv,sh_optcd))) switch(rval)
+ {
+ case 'L':
+ flag = 0;
+ break;
+ case 'P':
+ flag = 1;
+ break;
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ argc -= opt_info.index;
+ dir = argv[0];
+ if(error_info.errors>0 || argc >2)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+ oldpwd = (char*)shp->pwd;
+ opwdnod = (shp->subshell?sh_assignok(OLDPWDNOD,1):OLDPWDNOD);
+ pwdnod = (shp->subshell?sh_assignok(PWDNOD,1):PWDNOD);
+ if(argc==2)
+ dir = sh_substitute(oldpwd,dir,argv[1]);
+ else if(!dir || *dir==0)
+ dir = nv_getval(HOME);
+ else if(*dir == '-' && dir[1]==0)
+ dir = nv_getval(opwdnod);
+ if(!dir || *dir==0)
+ errormsg(SH_DICT,ERROR_exit(1),argc==2?e_subst+4:e_direct);
+#if _WINIX
+ if(*dir != '/' && (dir[1]!=':'))
+#else
+ if(*dir != '/')
+#endif /* _WINIX */
+ {
+#ifdef PATH_BFPATH
+ if(!(cdpath = (Pathcomp_t*)shp->cdpathlist) && (dp=(CDPNOD)->nvalue.cp))
+ {
+ if(cdpath=path_addpath((Pathcomp_t*)0,dp,PATH_CDPATH))
+ {
+ shp->cdpathlist = (void*)cdpath;
+ cdpath->shp = shp;
+ }
+ }
+#else
+ cdpath = nv_getval(nv_scoped(CDPNOD));
+#endif
+ if(!oldpwd)
+ oldpwd = path_pwd(1);
+ }
+#ifndef PATH_BFPATH
+ if(!cdpath)
+ cdpath = "";
+#endif
+ if(*dir=='.')
+ {
+ /* test for pathname . ./ .. or ../ */
+ if(*(dp=dir+1) == '.')
+ dp++;
+ if(*dp==0 || *dp=='/')
+#ifdef PATH_BFPATH
+ cdpath = 0;
+#else
+ cdpath = "";
+#endif
+ }
+ rval = -1;
+ do
+ {
+#ifdef PATH_BFPATH
+ dp = cdpath?cdpath->name:"";
+ cdpath = path_nextcomp(cdpath,dir,0);
+#else
+ dp = cdpath;
+ cdpath=path_join(cdpath,dir);
+#endif
+#if _WINIX
+ if(*stakptr(PATH_OFFSET+1)==':' && isalpha(*stakptr(PATH_OFFSET)))
+ {
+ *stakptr(PATH_OFFSET+1) = *stakptr(PATH_OFFSET);
+ *stakptr(PATH_OFFSET)='/';
+ }
+#endif /* _WINIX */
+ if(*stakptr(PATH_OFFSET)!='/')
+
+ {
+ char *last=(char*)stakfreeze(1);
+ stakseek(PATH_OFFSET);
+ stakputs(oldpwd);
+ /* don't add '/' of oldpwd is / itself */
+ if(*oldpwd!='/' || oldpwd[1])
+ stakputc('/');
+ stakputs(last+PATH_OFFSET);
+ stakputc(0);
+ }
+ if(!flag)
+ {
+ register char *cp;
+ stakseek(PATH_MAX+PATH_OFFSET);
+#if SHOPT_FS_3D
+ if(!(cp = pathcanon(stakptr(PATH_OFFSET),PATH_DOTDOT)))
+ continue;
+ /* eliminate trailing '/' */
+ while(*--cp == '/' && cp>stakptr(PATH_OFFSET))
+ *cp = 0;
+#else
+ if(*(cp=stakptr(PATH_OFFSET))=='/')
+ if(!pathcanon(cp,PATH_DOTDOT))
+ continue;
+#endif /* SHOPT_FS_3D */
+ }
+ if((rval=chdir(path_relative(stakptr(PATH_OFFSET)))) >= 0)
+ goto success;
+ if(errno!=ENOENT && saverrno==0)
+ saverrno=errno;
+ }
+ while(cdpath);
+ if(rval<0 && *dir=='/' && *(path_relative(stakptr(PATH_OFFSET)))!='/')
+ rval = chdir(dir);
+ /* use absolute chdir() if relative chdir() fails */
+ if(rval<0)
+ {
+ if(saverrno)
+ errno = saverrno;
+ errormsg(SH_DICT,ERROR_system(1),"%s:",dir);
+ }
+success:
+ if(dir == nv_getval(opwdnod) || argc==2)
+ dp = dir; /* print out directory for cd - */
+ if(flag)
+ {
+ dir = stakptr(PATH_OFFSET);
+ if (!(dir=pathcanon(dir,PATH_PHYSICAL)))
+ {
+ dir = stakptr(PATH_OFFSET);
+ errormsg(SH_DICT,ERROR_system(1),"%s:",dir);
+ }
+ stakseek(dir-stakptr(0));
+ }
+ dir = (char*)stakfreeze(1)+PATH_OFFSET;
+#ifdef PATH_BFPATH
+ if(*dp && (*dp!='.'||dp[1]) && strchr(dir,'/'))
+#else
+ if(*dp && *dp!= ':' && strchr(dir,'/'))
+#endif
+ sfputr(sfstdout,dir,'\n');
+ if(*dir != '/')
+ return(0);
+ nv_putval(opwdnod,oldpwd,NV_RDONLY);
+ if(oldpwd)
+ free(oldpwd);
+ flag = strlen(dir);
+ /* delete trailing '/' */
+ while(--flag>0 && dir[flag]=='/')
+ dir[flag] = 0;
+ nv_putval(pwdnod,dir,NV_RDONLY);
+ nv_onattr(pwdnod,NV_NOFREE|NV_EXPORT);
+ shp->pwd = pwdnod->nvalue.cp;
+#ifdef PATH_BFPATH
+ nv_scan(shp->track_tree,rehash,(void*)0,NV_TAGGED,NV_TAGGED);
+ path_newdir(shp->pathlist);
+ path_newdir(shp->cdpathlist);
+#endif
+ return(0);
+}
+
+int b_pwd(int argc, char *argv[],void *extra)
+{
+ register int n, flag = 0;
+ register char *cp;
+ register Shell_t *shp = (Shell_t*)extra;
+ NOT_USED(argc);
+ while((n = optget(argv,sh_optpwd))) switch(n)
+ {
+ case 'L':
+ flag = 0;
+ break;
+ case 'P':
+ flag = 1;
+ break;
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+ if(*(cp = path_pwd(0)) != '/')
+ errormsg(SH_DICT,ERROR_system(1), e_pwd);
+ if(flag)
+ {
+#if SHOPT_FS_3D
+ if(shp->lim.fs3d && (flag = mount(e_dot,NIL(char*),FS3D_GET|FS3D_VIEW,0))>=0)
+ {
+ cp = (char*)stakseek(++flag+PATH_MAX);
+ mount(e_dot,cp,FS3D_GET|FS3D_VIEW|FS3D_SIZE(flag),0);
+ }
+ else
+#endif /* SHOPT_FS_3D */
+ cp = strcpy(stakseek(strlen(cp)+PATH_MAX),cp);
+ pathcanon(cp,PATH_PHYSICAL);
+ }
+ sfputr(sfstdout,cp,'\n');
+ return(0);
+}
+
diff --git a/usr/src/lib/libshell/common/bltins/cflow.c b/usr/src/lib/libshell/common/bltins/cflow.c
new file mode 100644
index 0000000000..3f32f4386d
--- /dev/null
+++ b/usr/src/lib/libshell/common/bltins/cflow.c
@@ -0,0 +1,118 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * break [n]
+ * continue [n]
+ * return [n]
+ * exit [n]
+ *
+ * David Korn
+ * AT&T Labs
+ * dgk@research.att.com
+ *
+ */
+
+#include "defs.h"
+#include <ast.h>
+#include <error.h>
+#include <ctype.h>
+#include "shnodes.h"
+#include "builtins.h"
+
+/*
+ * return and exit
+ */
+#if 0
+ /* for the dictionary generator */
+ int b_exit(int n, register char *argv[],void *extra){}
+#endif
+int b_return(register int n, register char *argv[],void *extra)
+{
+ register char *arg;
+ register Shell_t *shp = (Shell_t*)extra;
+ struct checkpt *pp = (struct checkpt*)shp->jmplist;
+ const char *options = (**argv=='r'?sh_optreturn:sh_optexit);
+ while((n = optget(argv,options))) switch(n)
+ {
+ case ':':
+ if(!strmatch(argv[opt_info.index],"[+-]+([0-9])"))
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ goto done;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(0), "%s", opt_info.arg);
+ return(2);
+ }
+done:
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+ pp->mode = (**argv=='e'?SH_JMPEXIT:SH_JMPFUN);
+ argv += opt_info.index;
+ n = (((arg= *argv)?(int)strtol(arg, (char**)0, 10):shp->oldexit)&SH_EXITMASK);
+ /* return outside of function, dotscript and profile is exit */
+ if(shp->fn_depth==0 && shp->dot_depth==0 && !sh_isstate(SH_PROFILE))
+ pp->mode = SH_JMPEXIT;
+ sh_exit(shp->savexit=n);
+ return(1);
+}
+
+
+/*
+ * break and continue
+ */
+#if 0
+ /* for the dictionary generator */
+ int b_continue(int n, register char *argv[],void *extra){}
+#endif
+int b_break(register int n, register char *argv[],void *extra)
+{
+ char *arg;
+ register int cont= **argv=='c';
+ register Shell_t *shp = (Shell_t*)extra;
+ while((n = optget(argv,cont?sh_optcont:sh_optbreak))) switch(n)
+ {
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(0), "%s", opt_info.arg);
+ return(2);
+ }
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+ argv += opt_info.index;
+ n=1;
+ if(arg= *argv)
+ {
+ n = strtol(arg,&arg,10);
+ if(n<=0 || *arg)
+ errormsg(SH_DICT,ERROR_exit(1),e_nolabels,*argv);
+ }
+ if(shp->st.loopcnt)
+ {
+ shp->st.execbrk = shp->st.breakcnt = n;
+ if(shp->st.breakcnt > shp->st.loopcnt)
+ shp->st.breakcnt = shp->st.loopcnt;
+ if(cont)
+ shp->st.breakcnt = -shp->st.breakcnt;
+ }
+ return(0);
+}
+
diff --git a/usr/src/lib/libshell/common/bltins/getopts.c b/usr/src/lib/libshell/common/bltins/getopts.c
new file mode 100644
index 0000000000..65057da8d2
--- /dev/null
+++ b/usr/src/lib/libshell/common/bltins/getopts.c
@@ -0,0 +1,185 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * getopts optstring name [arg...]
+ *
+ * David Korn
+ * AT&T Labs
+ * research!dgk
+ *
+ */
+
+#include "defs.h"
+#include "variables.h"
+#include <error.h>
+#include <nval.h>
+#include "builtins.h"
+
+static int infof(Opt_t* op, Sfio_t* sp, const char* s, Optdisc_t* dp)
+{
+ if(nv_search(s,sh.fun_tree,0))
+ {
+ int savtop = staktell();
+ char *savptr = stakfreeze(0);
+ stakputc('$');
+ stakputc('(');
+ stakputs(s);
+ stakputc(')');
+ sfputr(sp,sh_mactry(stakfreeze(1)),-1);
+ stakset(savptr,savtop);
+ }
+ return(1);
+}
+
+int b_getopts(int argc,char *argv[],void *extra)
+{
+ register char *options=error_info.context->id;
+ register Namval_t *np;
+ register int flag, mode, r=0;
+ register Shell_t *shp = (Shell_t*)extra;
+ char value[2], key[2];
+ int jmpval;
+ struct checkpt buff, *pp;
+ Optdisc_t disc;
+ memset(&disc, 0, sizeof(disc));
+ disc.version = OPT_VERSION;
+ disc.infof = infof;
+ value[1] = 0;
+ key[1] = 0;
+ while((flag = optget(argv,sh_optgetopts))) switch(flag)
+ {
+ case 'a':
+ options = opt_info.arg;
+ break;
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ argc -= opt_info.index;
+ if(error_info.errors || argc<2)
+ errormsg(SH_DICT,ERROR_usage(2), "%s", optusage((char*)0));
+ error_info.context->flags |= ERROR_SILENT;
+ error_info.id = options;
+ options = argv[0];
+ np = nv_open(argv[1],shp->var_tree,NV_NOASSIGN|NV_VARNAME);
+ if(argc>2)
+ {
+ argv +=1;
+ argc -=1;
+ }
+ else
+ {
+ argv = shp->st.dolv;
+ argc = shp->st.dolc;
+ }
+ opt_info.index = shp->st.optindex;
+ opt_info.offset = shp->st.optchar;
+ if(mode= (*options==':'))
+ options++;
+ sh_pushcontext(&buff,1);
+ jmpval = sigsetjmp(buff.buff,0);
+ if(jmpval)
+ {
+ sh_popcontext(&buff);
+ pp = (struct checkpt*)shp->jmplist;
+ pp->mode = SH_JMPERREXIT;
+ sh_exit(2);
+ }
+ opt_info.disc = &disc;
+ switch(opt_info.index>=0 && opt_info.index<=argc?(opt_info.num= LONG_MIN,flag=optget(argv,options)):0)
+ {
+ case '?':
+ if(mode==0)
+ errormsg(SH_DICT,ERROR_usage(2), "%s", opt_info.arg);
+ opt_info.option[1] = '?';
+ /* FALL THRU */
+ case ':':
+ key[0] = opt_info.option[1];
+ if(strmatch(opt_info.arg,"*unknown*"))
+ flag = '?';
+ if(mode)
+ opt_info.arg = key;
+ else
+ {
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ opt_info.arg = 0;
+ flag = '?';
+ }
+ *(options = value) = flag;
+ shp->st.opterror = 1;
+ if (opt_info.offset != 0 && !argv[opt_info.index][opt_info.offset])
+ {
+ opt_info.offset = 0;
+ opt_info.index++;
+ }
+ break;
+ case 0:
+ if(shp->st.opterror)
+ {
+ char *com[2];
+ com[0] = "-?";
+ com[1] = 0;
+ flag = opt_info.index;
+ opt_info.index = 0;
+ optget(com,options);
+ opt_info.index = flag;
+ if(!mode && strchr(options,' '))
+ errormsg(SH_DICT,ERROR_usage(2), "%s", optusage((char*)0));
+ }
+ opt_info.arg = 0;
+ options = value;
+ *options = '?';
+ r=1;
+ opt_info.offset = 0;
+ break;
+ default:
+ options = opt_info.option + (*opt_info.option!='+');
+ }
+ error_info.context->flags &= ~ERROR_SILENT;
+ shp->st.optindex = opt_info.index;
+ shp->st.optchar = opt_info.offset;
+ nv_putval(np, options, 0);
+ nv_close(np);
+ np = nv_open(nv_name(OPTARGNOD),shp->var_tree,NV_NOSCOPE);
+ if(opt_info.num == LONG_MIN)
+ nv_putval(np, opt_info.arg, NV_RDONLY);
+ else if (opt_info.num > 0 && opt_info.arg && opt_info.arg[0] == (char)opt_info.num)
+ {
+ key[0] = (char)opt_info.num;
+ key[1] = 0;
+ nv_putval(np, key, NV_RDONLY);
+ }
+ else
+ {
+ Sfdouble_t d;
+ d = opt_info.number;
+ nv_putval(np, (char*)&d, NV_LDOUBLE|NV_RDONLY);
+ }
+ nv_close(np);
+ sh_popcontext(&buff);
+ opt_info.disc = 0;
+ return(r);
+}
+
diff --git a/usr/src/lib/libshell/common/bltins/hist.c b/usr/src/lib/libshell/common/bltins/hist.c
new file mode 100644
index 0000000000..fcb81958e4
--- /dev/null
+++ b/usr/src/lib/libshell/common/bltins/hist.c
@@ -0,0 +1,309 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#include "defs.h"
+#include <stak.h>
+#include <ls.h>
+#include <error.h>
+#include <ctype.h>
+#include "variables.h"
+#include "io.h"
+#include "name.h"
+#include "history.h"
+#include "builtins.h"
+#if SHOPT_HISTEXPAND
+# include "edit.h"
+#endif
+
+#define HIST_RECURSE 5
+
+static void hist_subst(const char*, int fd, char*);
+
+#if 0
+ /* for the benefit of the dictionary generator */
+ int b_fc(int argc,char *argv[], void *extra){}
+#endif
+int b_hist(int argc,char *argv[], void *extra)
+{
+ register History_t *hp;
+ register char *arg;
+ register int flag,fdo;
+ register Shell_t *shp = (Shell_t*)extra;
+ Sfio_t *outfile;
+ char *fname;
+ int range[2], incr, index2, indx= -1;
+ char *edit = 0; /* name of editor */
+ char *replace = 0; /* replace old=new */
+ int lflag = 0, nflag = 0, rflag = 0;
+#if SHOPT_HISTEXPAND
+ int pflag = 0;
+#endif
+ Histloc_t location;
+ NOT_USED(argc);
+ if(!sh_histinit())
+ errormsg(SH_DICT,ERROR_system(1),e_histopen);
+ hp = shp->hist_ptr;
+ while((flag = optget(argv,sh_opthist))) switch(flag)
+ {
+ case 'e':
+ edit = opt_info.arg;
+ break;
+ case 'n':
+ nflag++;
+ break;
+ case 'l':
+ lflag++;
+ break;
+ case 'r':
+ rflag++;
+ break;
+ case 's':
+ edit = "-";
+ break;
+#if SHOPT_HISTEXPAND
+ case 'p':
+ pflag++;
+ break;
+#endif
+ case 'N':
+ if(indx<=0)
+ {
+ if((flag = hist_max(hp) - opt_info.num-1) < 0)
+ flag = 1;
+ range[++indx] = flag;
+ break;
+ }
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+ argv += (opt_info.index-1);
+#if SHOPT_HISTEXPAND
+ if(pflag)
+ {
+ hist_cancel(hp);
+ pflag = 0;
+ while(arg=argv[1])
+ {
+ flag = hist_expand(arg,&replace);
+ if(!(flag & HIST_ERROR))
+ sfputr(sfstdout, replace, '\n');
+ else
+ pflag = 1;
+ if(replace)
+ free(replace);
+ argv++;
+ }
+ return pflag;
+ }
+#endif
+ flag = indx;
+ while(flag<1 && (arg=argv[1]))
+ {
+ /* look for old=new argument */
+ if(!replace && strchr(arg+1,'='))
+ {
+ replace = arg;
+ argv++;
+ continue;
+ }
+ else if(isdigit(*arg) || *arg == '-')
+ {
+ /* see if completely numeric */
+ do arg++;
+ while(isdigit(*arg));
+ if(*arg==0)
+ {
+ arg = argv[1];
+ range[++flag] = (int)strtol(arg, (char**)0, 10);
+ if(*arg == '-')
+ range[flag] += (hist_max(hp)-1);
+ argv++;
+ continue;
+ }
+ }
+ /* search for last line starting with string */
+ location = hist_find(hp,argv[1],hist_max(hp)-1,0,-1);
+ if((range[++flag] = location.hist_command) < 0)
+ errormsg(SH_DICT,ERROR_exit(1),e_found,argv[1]);
+ argv++;
+ }
+ if(flag <0)
+ {
+ /* set default starting range */
+ if(lflag)
+ {
+ flag = hist_max(hp)-16;
+ if(flag<1)
+ flag = 1;
+ }
+ else
+ flag = hist_max(hp)-2;
+ range[0] = flag;
+ flag = 0;
+ }
+ index2 = hist_min(hp);
+ if(range[0]<index2)
+ range[0] = index2;
+ if(flag==0)
+ /* set default termination range */
+ range[1] = (lflag?hist_max(hp)-1:range[0]);
+ if(range[1]>=(flag=(hist_max(hp) - !lflag)))
+ range[1] = flag;
+ /* check for valid ranges */
+ if(range[1]<index2 || range[0]>=flag)
+ errormsg(SH_DICT,ERROR_exit(1),e_badrange,range[0],range[1]);
+ if(edit && *edit=='-' && range[0]!=range[1])
+ errormsg(SH_DICT,ERROR_exit(1),e_eneedsarg);
+ /* now list commands from range[rflag] to range[1-rflag] */
+ incr = 1;
+ flag = rflag>0;
+ if(range[1-flag] < range[flag])
+ incr = -1;
+ if(lflag)
+ {
+ outfile = sfstdout;
+ arg = "\n\t";
+ }
+ else
+ {
+ if(!(fname=pathtmp(NIL(char*),0,0,NIL(int*))))
+ errormsg(SH_DICT,ERROR_exit(1),e_create,"");
+ if((fdo=open(fname,O_CREAT|O_RDWR,S_IRUSR|S_IWUSR)) < 0)
+ errormsg(SH_DICT,ERROR_system(1),e_create,fname);
+ outfile= sfnew(NIL(Sfio_t*),shp->outbuff,IOBSIZE,fdo,SF_WRITE);
+ arg = "\n";
+ nflag++;
+ }
+ while(1)
+ {
+ if(nflag==0)
+ sfprintf(outfile,"%d\t",range[flag]);
+ else if(lflag)
+ sfputc(outfile,'\t');
+ hist_list(shp->hist_ptr,outfile,hist_tell(shp->hist_ptr,range[flag]),0,arg);
+ if(lflag)
+ sh_sigcheck();
+ if(range[flag] == range[1-flag])
+ break;
+ range[flag] += incr;
+ }
+ if(lflag)
+ return(0);
+ sfclose(outfile);
+ hist_eof(hp);
+ arg = edit;
+ if(!arg && !(arg=nv_getval(nv_scoped(HISTEDIT))) && !(arg=nv_getval(nv_scoped(FCEDNOD))))
+ arg = (char*)e_defedit;
+#ifdef apollo
+ /*
+ * Code to support the FC using the pad editor.
+ * Exampled of how to use: HISTEDIT=pad
+ */
+ if (strcmp (arg, "pad") == 0)
+ {
+ extern int pad_create(char*);
+ sh_close(fdo);
+ fdo = pad_create(fname);
+ pad_wait(fdo);
+ unlink(fname);
+ strcat(fname, ".bak");
+ unlink(fname);
+ lseek(fdo,(off_t)0,SEEK_SET);
+ }
+ else
+ {
+#endif /* apollo */
+ if(*arg != '-')
+ {
+ char *com[3];
+ com[0] = arg;
+ com[1] = fname;
+ com[2] = 0;
+ error_info.errors = sh_eval(sh_sfeval(com),0);
+ }
+ fdo = sh_chkopen(fname);
+ unlink(fname);
+ free((void*)fname);
+#ifdef apollo
+ }
+#endif /* apollo */
+ /* don't history fc itself unless forked */
+ error_info.flags |= ERROR_SILENT;
+ if(!sh_isstate(SH_FORKED))
+ hist_cancel(hp);
+ sh_onstate(SH_HISTORY);
+ sh_onstate(SH_VERBOSE); /* echo lines as read */
+ if(replace)
+ hist_subst(error_info.id,fdo,replace);
+ else if(error_info.errors == 0)
+ {
+ char buff[IOBSIZE+1];
+ Sfio_t *iop = sfnew(NIL(Sfio_t*),buff,IOBSIZE,fdo,SF_READ);
+ /* read in and run the command */
+ if(shp->hist_depth++ > HIST_RECURSE)
+ errormsg(SH_DICT,ERROR_exit(1),e_toodeep,"history");
+ sh_eval(iop,1);
+ shp->hist_depth--;
+ }
+ else
+ {
+ sh_close(fdo);
+ if(!sh_isoption(SH_VERBOSE))
+ sh_offstate(SH_VERBOSE);
+ sh_offstate(SH_HISTORY);
+ }
+ return(shp->exitval);
+}
+
+
+/*
+ * given a file containing a command and a string of the form old=new,
+ * execute the command with the string old replaced by new
+ */
+
+static void hist_subst(const char *command,int fd,char *replace)
+{
+ register char *newp=replace;
+ register char *sp;
+ register int c;
+ off_t size;
+ char *string;
+ while(*++newp != '='); /* skip to '=' */
+ if((size = lseek(fd,(off_t)0,SEEK_END)) < 0)
+ return;
+ lseek(fd,(off_t)0,SEEK_SET);
+ c = (int)size;
+ string = stakalloc(c+1);
+ if(read(fd,string,c)!=c)
+ return;
+ string[c] = 0;
+ *newp++ = 0;
+ if((sp=sh_substitute(string,replace,newp))==0)
+ errormsg(SH_DICT,ERROR_exit(1),e_subst,command);
+ *(newp-1) = '=';
+ sh_eval(sfopen(NIL(Sfio_t*),sp,"s"),1);
+}
+
diff --git a/usr/src/lib/libshell/common/bltins/misc.c b/usr/src/lib/libshell/common/bltins/misc.c
new file mode 100644
index 0000000000..974c3de037
--- /dev/null
+++ b/usr/src/lib/libshell/common/bltins/misc.c
@@ -0,0 +1,589 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * exec [arg...]
+ * eval [arg...]
+ * jobs [-lnp] [job...]
+ * login [arg...]
+ * let expr...
+ * . file [arg...]
+ * :, true, false
+ * vpath [top] [base]
+ * vmap [top] [base]
+ * wait [job...]
+ * shift [n]
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#include "defs.h"
+#include "variables.h"
+#include "shnodes.h"
+#include "path.h"
+#include "io.h"
+#include "name.h"
+#include "history.h"
+#include "builtins.h"
+#include "jobs.h"
+
+#define DOTMAX MAXDEPTH /* maximum level of . nesting */
+
+static void noexport(Namval_t*,void*);
+
+struct login
+{
+ Shell_t *sh;
+ int clear;
+ char *arg0;
+};
+
+int b_exec(int argc,char *argv[], void *extra)
+{
+ struct login logdata;
+ register int n;
+ logdata.clear = 0;
+ logdata.arg0 = 0;
+ logdata.sh = (Shell_t*)extra;
+ logdata.sh->st.ioset = 0;
+ while (n = optget(argv, sh_optexec)) switch (n)
+ {
+ case 'a':
+ logdata.arg0 = opt_info.arg;
+ argc = 0;
+ break;
+ case 'c':
+ logdata.clear=1;
+ break;
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(0), "%s", opt_info.arg);
+ return(2);
+ }
+ argv += opt_info.index;
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+ if(*argv)
+ B_login(0,argv,(void*)&logdata);
+ return(0);
+}
+
+static void noexport(register Namval_t* np, void *data)
+{
+ NOT_USED(data);
+ nv_offattr(np,NV_EXPORT);
+}
+
+int B_login(int argc,char *argv[],void *extra)
+{
+ struct checkpt *pp;
+ register struct login *logp=0;
+ register Shell_t *shp;
+ const char *pname;
+ if(argc)
+ shp = (Shell_t*)extra;
+ else
+ {
+ logp = (struct login*)extra;
+ shp = logp->sh;
+ }
+ pp = (struct checkpt*)shp->jmplist;
+ if(sh_isoption(SH_RESTRICTED))
+ errormsg(SH_DICT,ERROR_exit(1),e_restricted,argv[0]);
+ else
+ {
+ register struct argnod *arg=shp->envlist;
+ register Namval_t* np;
+ register char *cp;
+ if(shp->subshell)
+ sh_subfork();
+ if(logp && logp->clear)
+ {
+#ifdef _ENV_H
+ env_close(shp->env);
+ shp->env = env_open((char**)0,3);
+#else
+ nv_scan(shp->var_tree,noexport,0,NV_EXPORT,NV_EXPORT);
+#endif
+ }
+ while(arg)
+ {
+ if((cp=strchr(arg->argval,'=')) &&
+ (*cp=0,np=nv_search(arg->argval,shp->var_tree,0)))
+ {
+ nv_onattr(np,NV_EXPORT);
+ sh_envput(shp->env,np);
+ }
+ if(cp)
+ *cp = '=';
+ arg=arg->argnxt.ap;
+ }
+ pname = argv[0];
+ if(logp && logp->arg0)
+ argv[0] = logp->arg0;
+#ifdef JOBS
+ if(job_close() < 0)
+ return(1);
+#endif /* JOBS */
+ /* force bad exec to terminate shell */
+ pp->mode = SH_JMPEXIT;
+ sh_sigreset(2);
+ sh_freeup();
+ path_exec(pname,argv,NIL(struct argnod*));
+ sh_done(0);
+ }
+ return(1);
+}
+
+int b_let(int argc,char *argv[],void *extra)
+{
+ register int r;
+ register char *arg;
+ NOT_USED(argc);
+ NOT_USED(extra);
+ while (r = optget(argv,sh_optlet)) switch (r)
+ {
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ if(error_info.errors || !*argv)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+ while(arg= *argv++)
+ r = !sh_arith(arg);
+ return(r);
+}
+
+int b_eval(int argc,char *argv[], void *extra)
+{
+ register int r;
+ register Shell_t *shp = (Shell_t*)extra;
+ NOT_USED(argc);
+ while (r = optget(argv,sh_opteval)) switch (r)
+ {
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(0), "%s",opt_info.arg);
+ return(2);
+ }
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+ argv += opt_info.index;
+ if(*argv && **argv)
+ {
+ sh_offstate(SH_MONITOR);
+ sh_eval(sh_sfeval(argv),0);
+ }
+ return(shp->exitval);
+}
+
+int b_dot_cmd(register int n,char *argv[],void* extra)
+{
+ register char *script;
+ register Namval_t *np;
+ register int jmpval;
+ register Shell_t *shp = (Shell_t*)extra;
+ struct sh_scoped savst, *prevscope = shp->st.self;
+ char *filename=0;
+ int fd;
+ struct dolnod *argsave=0, *saveargfor;
+ struct checkpt buff;
+ Sfio_t *iop=0;
+ NOT_USED(extra);
+ while (n = optget(argv,sh_optdot)) switch (n)
+ {
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(0), "%s",opt_info.arg);
+ return(2);
+ }
+ argv += opt_info.index;
+ script = *argv;
+ if(error_info.errors || !script)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+ if(shp->dot_depth++ > DOTMAX)
+ errormsg(SH_DICT,ERROR_exit(1),e_toodeep,script);
+ shp->st.lineno = error_info.line;
+ if(!(np=shp->posix_fun))
+ {
+ /* check for KornShell style function first */
+ np = nv_search(script,shp->fun_tree,0);
+ if(np && is_afunction(np) && !nv_isattr(np,NV_FPOSIX))
+ {
+ if(!np->nvalue.ip)
+ {
+#ifdef PATH_BFPATH
+ path_search(script,NIL(Pathcomp_t*),0);
+#else
+ path_search(script,NIL(char*),0);
+#endif
+ if(np->nvalue.ip)
+ {
+ if(nv_isattr(np,NV_FPOSIX))
+ np = 0;
+ }
+ else
+ errormsg(SH_DICT,ERROR_exit(1),e_found,script);
+ }
+ }
+ else
+ np = 0;
+ if(!np)
+ {
+ if((fd=path_open(script,path_get(script))) < 0)
+ errormsg(SH_DICT,ERROR_system(1),e_open,script);
+ filename = path_fullname(stakptr(PATH_OFFSET));
+ }
+ }
+ *prevscope = shp->st;
+ if(filename)
+ shp->st.filename = filename;
+ shp->st.prevst = prevscope;
+ shp->st.self = &savst;
+ shp->topscope = (Shscope_t*)shp->st.self;
+ prevscope->save_tree = shp->var_tree;
+ shp->st.cmdname = argv[0];
+ if(np)
+ shp->st.filename = np->nvalue.rp->fname;
+ nv_putval(SH_PATHNAMENOD, shp->st.filename ,NV_NOFREE);
+ shp->posix_fun = 0;
+ if(np || argv[1])
+ argsave = sh_argnew(argv,&saveargfor);
+ sh_pushcontext(&buff,SH_JMPDOT);
+ jmpval = sigsetjmp(buff.buff,0);
+ if(jmpval == 0)
+ {
+ if(np)
+ sh_exec((Shnode_t*)(nv_funtree(np)),sh_isstate(SH_ERREXIT));
+ else
+ {
+ char buff[IOBSIZE+1];
+ iop = sfnew(NIL(Sfio_t*),buff,IOBSIZE,fd,SF_READ);
+ sh_eval(iop,0);
+ }
+ }
+ sh_popcontext(&buff);
+ if(!np)
+ free((void*)shp->st.filename);
+ shp->dot_depth--;
+ if((np || argv[1]) && jmpval!=SH_JMPSCRIPT)
+ sh_argreset(argsave,saveargfor);
+ else
+ {
+ prevscope->dolc = shp->st.dolc;
+ prevscope->dolv = shp->st.dolv;
+ }
+ if (shp->st.self != &savst)
+ *shp->st.self = shp->st;
+ /* only restore the top Shscope_t portion for posix functions */
+ memcpy((void*)&shp->st, (void*)prevscope, sizeof(Shscope_t));
+ shp->topscope = (Shscope_t*)prevscope;
+ nv_putval(SH_PATHNAMENOD, shp->st.filename ,NV_NOFREE);
+ if(shp->exitval > SH_EXITSIG)
+ sh_fault(shp->exitval&SH_EXITMASK);
+ if(jmpval && jmpval!=SH_JMPFUN)
+ siglongjmp(*shp->jmplist,jmpval);
+ return(shp->exitval);
+}
+
+/*
+ * null, true command
+ */
+int b_true(int argc,register char *argv[],void *extra)
+{
+ NOT_USED(argc);
+ NOT_USED(argv[0]);
+ NOT_USED(extra);
+ return(0);
+}
+
+/*
+ * false command
+ */
+int b_false(int argc,register char *argv[], void *extra)
+{
+ NOT_USED(argc);
+ NOT_USED(argv[0]);
+ NOT_USED(extra);
+ return(1);
+}
+
+int b_shift(register int n, register char *argv[], void *extra)
+{
+ register char *arg;
+ register Shell_t *shp = (Shell_t*)extra;
+ while((n = optget(argv,sh_optshift))) switch(n)
+ {
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(0), "%s",opt_info.arg);
+ return(2);
+ }
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+ argv += opt_info.index;
+ n = ((arg= *argv)?(int)sh_arith(arg):1);
+ if(n<0 || shp->st.dolc<n)
+ errormsg(SH_DICT,ERROR_exit(1),e_number,arg);
+ else
+ {
+ shp->st.dolv += n;
+ shp->st.dolc -= n;
+ }
+ return(0);
+}
+
+int b_wait(int n,register char *argv[],void *extra)
+{
+ register Shell_t *shp = (Shell_t*)extra;
+ while((n = optget(argv,sh_optwait))) switch(n)
+ {
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s",opt_info.arg);
+ break;
+ }
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+ argv += opt_info.index;
+ job_bwait(argv);
+ return(shp->exitval);
+}
+
+#ifdef JOBS
+# if 0
+ /* for the dictionary generator */
+ int b_fg(int n,char *argv[],void *extra){}
+ int b_disown(int n,char *argv[],void *extra){}
+# endif
+int b_bg(register int n,register char *argv[],void *extra)
+{
+ register int flag = **argv;
+ register Shell_t *shp = (Shell_t*)extra;
+ register const char *optstr = sh_optbg;
+ if(*argv[0]=='f')
+ optstr = sh_optfg;
+ else if(*argv[0]=='d')
+ optstr = sh_optdisown;
+ while((n = optget(argv,optstr))) switch(n)
+ {
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s",opt_info.arg);
+ break;
+ }
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+ argv += opt_info.index;
+ if(!sh_isoption(SH_MONITOR) || !job.jobcontrol)
+ {
+ if(sh_isstate(SH_INTERACTIVE))
+ errormsg(SH_DICT,ERROR_exit(1),e_no_jctl);
+ return(1);
+ }
+ if(flag=='d' && *argv==0)
+ argv = (char**)0;
+ if(job_walk(sfstdout,job_switch,flag,argv))
+ errormsg(SH_DICT,ERROR_exit(1),e_no_job);
+ return(shp->exitval);
+}
+
+int b_jobs(register int n,char *argv[],void *extra)
+{
+ register int flag = 0;
+ register Shell_t *shp = (Shell_t*)extra;
+ while((n = optget(argv,sh_optjobs))) switch(n)
+ {
+ case 'l':
+ flag = JOB_LFLAG;
+ break;
+ case 'n':
+ flag = JOB_NFLAG;
+ break;
+ case 'p':
+ flag = JOB_PFLAG;
+ break;
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s",opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+ if(*argv==0)
+ argv = (char**)0;
+ if(job_walk(sfstdout,job_list,flag,argv))
+ errormsg(SH_DICT,ERROR_exit(1),e_no_job);
+ job_wait((pid_t)0);
+ return(shp->exitval);
+}
+#endif
+
+#ifdef _cmd_universe
+/*
+ * There are several universe styles that are masked by the getuniv(),
+ * setuniv() calls.
+ */
+int b_universe(int argc, char *argv[],void *extra)
+{
+ register char *arg;
+ register int n;
+ NOT_USED(extra);
+ while((n = optget(argv,sh_optuniverse))) switch(n)
+ {
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s",opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ argc -= opt_info.index;
+ if(error_info.errors || argc>1)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+ if(arg = argv[0])
+ {
+ if(!astconf("UNIVERSE",0,arg))
+ errormsg(SH_DICT,ERROR_exit(1), e_badname,arg);
+ }
+ else
+ {
+ if(!(arg=astconf("UNIVERSE",0,0)))
+ errormsg(SH_DICT,ERROR_exit(1),e_nouniverse);
+ else
+ sfputr(sfstdout,arg,'\n');
+ }
+ return(0);
+}
+#endif /* cmd_universe */
+
+#if SHOPT_FS_3D
+# if 0
+ /* for the dictionary generator */
+ int b_vmap(int argc,char *argv[], void *extra){}
+# endif
+ int b_vpath(register int argc,char *argv[], void *extra)
+ {
+ register int flag, n;
+ register const char *optstr;
+ register char *vend;
+ register Shell_t *shp = (Shell_t*)extra;
+ if(argv[0][1]=='p')
+ {
+ optstr = sh_optvpath;
+ flag = FS3D_VIEW;
+ }
+ else
+ {
+ optstr = sh_optvmap;
+ flag = FS3D_VERSION;
+ }
+ while(n = optget(argv, optstr)) switch(n)
+ {
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s",opt_info.arg);
+ break;
+ }
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+ if(!shp->lim.fs3d)
+ goto failed;
+ argv += opt_info.index;
+ argc -= opt_info.index;
+ switch(argc)
+ {
+ case 0:
+ case 1:
+ flag |= FS3D_GET;
+ if((n = mount(*argv,(char*)0,flag,0)) >= 0)
+ {
+ vend = stakalloc(++n);
+ n = mount(*argv,vend,flag|FS3D_SIZE(n),0);
+ }
+ if(n < 0)
+ goto failed;
+ if(argc==1)
+ {
+ sfprintf(sfstdout,"%s\n",vend);
+ break;
+ }
+ n = 0;
+ while(flag = *vend++)
+ {
+ if(flag==' ')
+ {
+ flag = e_sptbnl[n+1];
+ n = !n;
+ }
+ sfputc(sfstdout,flag);
+ }
+ if(n)
+ sfputc(sfstdout,'\n');
+ break;
+ default:
+ if((argc&1))
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+ /*FALLTHROUGH*/
+ case 2:
+ if(!shp->lim.fs3d)
+ goto failed;
+ if(shp->subshell)
+ sh_subfork();
+ for(n=0;n<argc;n+=2)
+ {
+ if(mount(argv[n+1],argv[n],flag,0)<0)
+ goto failed;
+ }
+ }
+ return(0);
+failed:
+ if(argc>1)
+ errormsg(SH_DICT,ERROR_exit(1),e_cantset,flag==2?e_mapping:e_versions);
+ else
+ errormsg(SH_DICT,ERROR_exit(1),e_cantget,flag==2?e_mapping:e_versions);
+ return(1);
+ }
+#endif /* SHOPT_FS_3D */
+
diff --git a/usr/src/lib/libshell/common/bltins/mkservice.c b/usr/src/lib/libshell/common/bltins/mkservice.c
new file mode 100644
index 0000000000..bba532b79d
--- /dev/null
+++ b/usr/src/lib/libshell/common/bltins/mkservice.c
@@ -0,0 +1,494 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * mkservice varname pathname
+ * eloop [-t timeout]
+ * Written by David Korn
+ * AT&T Labs
+ */
+
+static const char mkservice_usage[] =
+"[-?\n@(#)$Id: mkservice (AT&T Research) 2001-06-13 $\n]"
+USAGE_LICENSE
+"[+NAME? mkservice - create a shell server ]"
+"[+DESCRIPTION?\bmkservice\b creates a tcp or udp server that is "
+ "implemented by shell functions.]"
+"[+?The \aservice_path\a must be of the form \b/dev/tcp/localhost/\b\aportno\a "
+ "or \b/dev/udp/localhost/\b\aportno\a depending on whether the "
+ "\btcp\b or \budp\b protocol is used. \aportno\a is the port "
+ "number that the service will use.]"
+"[+?The shell variable \avarname\a is associated with the service. This "
+ "variable can have subvariables that keeps the state of all "
+ "active connections. The functions \avarname\a\b.accept\b, "
+ "\avarname\a\b.action\b and \avarname\a\b.close\b implement the "
+ "service as follows:]{"
+ "[+accept?This function is invoked when a client tries to connect "
+ "to the service. It is called with an argument which "
+ "is the file descriptor number associated with the "
+ "accepted connection. If the function returns a non-zero "
+ "value, this connection will be closed.]"
+ "[+action?This function is invoked when there is data waiting "
+ "to be read from one of the active connections. It is "
+ "called with the file descriptor number that has data "
+ "to be read. If the function returns a non-zero "
+ "value, this connection will be closed.]"
+ "[+close?This function is invoked when the connection is closed.]"
+ "}"
+"[+?If \avarname\a is unset, then all active connection, and the service "
+ "itself will be closed.]"
+""
+"\n"
+"\nvarname service_path\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Success.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\beloop\b(1)]"
+;
+
+
+static const char eloop_usage[] =
+"[-?\n@(#)$Id: eloop (AT&T Research) 2001-06-13 $\n]"
+USAGE_LICENSE
+"[+NAME? eloop - process event loop]"
+"[+DESCRIPTION?\beloop\b causes the shell to block waiting for events "
+ "to process. By default, \beloop\b does not return.]"
+"[t]#[timeout?\atimeout\a is the number of milliseconds to wait "
+ "without receiving any events to process.]"
+"\n"
+"\n\n"
+"\n"
+"[+EXIT STATUS?If no timeout is specified, \beloop\b will not return "
+ "unless interrupted. Otherwise]{"
+ "[+0?The specified timeout interval occurred.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bmkservice\b(1)]"
+;
+
+
+#include "defs.h"
+
+#include <cmd.h>
+#include <error.h>
+#include <nval.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+#define ACCEPT 0
+#define ACTION 1
+#define CLOSE 2
+
+#ifndef O_SERVICE
+# define O_SERVICE O_NOCTTY
+#endif
+
+static const char* disctab[] =
+{
+ "accept",
+ "action",
+ "close",
+ 0
+};
+
+typedef struct Service_s Service_t;
+
+struct Service_s
+{
+ Namfun_t fun;
+ short fd;
+ int refcount;
+ int (*acceptf)(Service_t*,int);
+ int (*actionf)(Service_t*,int,int);
+ int (*errorf)(Service_t*,int,const char*, ...);
+ void *context;
+ Namval_t* node;
+ Namval_t* disc[elementsof(disctab)-1];
+};
+
+static short *file_list;
+static Sfio_t **poll_list;
+static Service_t **service_list;
+static int npoll;
+static int nready;
+static int ready;
+static int (*covered_fdnotify)(int, int);
+
+static int fdclose(Service_t *sp, register int fd)
+{
+ register int i;
+ service_list[fd] = 0;
+ if(sp->fd==fd)
+ sp->fd = -1;
+ for(i=0; i < npoll; i++)
+ {
+ if(file_list[i]==fd)
+ {
+ file_list[i] = file_list[npoll--];
+ if(sp->actionf)
+ (*sp->actionf)(sp, fd, 1);
+ return(1);
+ }
+ }
+ return(0);
+}
+
+static int fdnotify(int fd1, int fd2)
+{
+ Service_t *sp;
+ if (covered_fdnotify)
+ (*covered_fdnotify)(fd1, fd2);
+ if(fd2!=SH_FDCLOSE)
+ {
+ register int i;
+ service_list[fd2] = service_list[fd1];
+ service_list[fd1] = 0;
+ for(i=0; i < npoll; i++)
+ {
+ if(file_list[i]==fd1)
+ {
+ file_list[i] = fd2;
+ return(0);
+ }
+ }
+ }
+ else if(sp = service_list[fd1])
+ {
+ fdclose(sp,fd1);
+ if(--sp->refcount==0)
+ nv_unset(sp->node);
+ }
+ return(0);
+}
+
+static void process_stream(Sfio_t* iop)
+{
+ int r=0, fd = sffileno(iop);
+ Service_t * sp = service_list[fd];
+ if(fd==sp->fd) /* connection socket */
+ {
+ struct sockaddr addr;
+ socklen_t addrlen = sizeof(addr);
+ fd = accept(fd, &addr, &addrlen);
+ service_list[fd] = sp;
+ sp->refcount++;
+ file_list[npoll++] = fd;
+ if(fd>=0)
+ {
+ if(sp->acceptf)
+ r = (*sp->acceptf)(sp,fd);
+ }
+ }
+ else if(sp->actionf)
+ {
+ service_list[fd] = 0;
+ r = (*sp->actionf)(sp, fd, 0);
+ service_list[fd] = sp;
+ if(r<0)
+ close(fd);
+ }
+}
+
+static int waitnotify(int fd, long timeout, int rw)
+{
+ Sfio_t *special=0, **pstream;
+ register int i;
+
+ if (fd >= 0)
+ special = sh_fd2sfio(fd);
+ while(1)
+ {
+ pstream = poll_list;
+ while(ready < nready)
+ process_stream(pstream[ready++]);
+ if(special)
+ *pstream++ = special;
+ for(i=0; i < npoll; i++)
+ {
+ if(service_list[file_list[i]])
+ *pstream++ = sh_fd2sfio(file_list[i]);
+ }
+#if 1
+ for(i=0; i < pstream-poll_list; i++)
+ sfset(poll_list[i],SF_WRITE,0);
+#endif
+ nready = ready = 0;
+ errno = 0;
+#ifdef DEBUG
+ sfprintf(sfstderr,"before poll npoll=%d",pstream-poll_list);
+ for(i=0; i < pstream-poll_list; i++)
+ sfprintf(sfstderr," %d",sffileno(poll_list[i]));
+ sfputc(sfstderr,'\n');
+#endif
+ nready = sfpoll(poll_list,pstream-poll_list,timeout);
+#ifdef DEBUG
+ sfprintf(sfstderr,"after poll nready=%d",nready);
+ for(i=0; i < nready; i++)
+ sfprintf(sfstderr," %d",sffileno(poll_list[i]));
+ sfputc(sfstderr,'\n');
+#endif
+#if 1
+ for(i=0; i < pstream-poll_list; i++)
+ sfset(poll_list[i],SF_WRITE,1);
+#endif
+ if(nready<=0)
+ return(errno? -1: 0);
+ if(special && poll_list[0]==special)
+ {
+ ready = 1;
+ return(fd);
+ }
+ }
+}
+
+static int service_init(void)
+{
+ file_list = newof(NULL,short,n,0);
+ poll_list = newof(NULL,Sfio_t*,n,0);
+ service_list = newof(NULL,Service_t*,n,0);
+ covered_fdnotify = sh_fdnotify(fdnotify);
+ sh_waitnotify(waitnotify);
+ return(1);
+}
+
+void service_add(Service_t *sp)
+{
+ static int init;
+ if (!init)
+ init = service_init();
+ service_list[sp->fd] = sp;
+ file_list[npoll++] = sp->fd;
+}
+
+static int Accept(register Service_t *sp, int accept_fd)
+{
+ register Namval_t* nq = sp->disc[ACCEPT];
+ int fd;
+
+ fd = fcntl(accept_fd, F_DUPFD, 10);
+ if (fd >= 0)
+ {
+ close(accept_fd);
+ if (nq)
+ {
+ char* av[3];
+ char buff[20];
+
+ av[1] = buff;
+ av[2] = 0;
+ sfsprintf(buff, sizeof(buff), "%d", fd);
+ if (sh_fun(nq, sp->node, av))
+ {
+ close(fd);
+ return -1;
+ }
+ }
+ }
+ sfsync(NiL);
+ return fd;
+}
+
+static int Action(Service_t *sp, int fd, int close)
+{
+ register Namval_t* nq;
+ int r=0;
+
+ if(close)
+ nq = sp->disc[CLOSE];
+ else
+ nq = sp->disc[ACTION];
+ if (nq)
+ {
+ char* av[3];
+ char buff[20];
+
+ av[1] = buff;
+ av[2] = 0;
+ sfsprintf(buff, sizeof(buff), "%d", fd);
+ r=sh_fun(nq, sp->node, av);
+ }
+ sfsync(NiL);
+ return r > 0 ? -1 : 1;
+}
+
+static int Error(Service_t *sp, int level, const char* arg, ...)
+{
+ va_list ap;
+
+ va_start(ap, arg);
+ if(sp->node)
+ nv_unset(sp->node);
+ free((void*)sp);
+ errorv(NiL, ERROR_exit(1), ap);
+ va_end(ap);
+ return 0;
+}
+
+static char* setdisc(Namval_t* np, const char* event, Namval_t* action, Namfun_t* fp)
+{
+ register Service_t* sp = (Service_t*)fp;
+ register const char* cp;
+ register int i;
+ register int n = strlen(event) - 1;
+ register Namval_t* nq;
+
+ for (i = 0; cp = disctab[i]; i++)
+ {
+ if (memcmp(event, cp, n))
+ continue;
+ if (action == np)
+ action = sp->disc[i];
+ else
+ {
+ if (nq = sp->disc[i])
+ free((void*)nq);
+ if (action)
+ sp->disc[i] = action;
+ else
+ sp->disc[i] = 0;
+ }
+ return action ? (char*)action : "";
+ }
+ /* try the next level */
+ return nv_setdisc(np, event, action, fp);
+}
+
+static void putval(Namval_t* np, const char* val, int flag, Namfun_t* fp)
+{
+ register Service_t* sp = (Service_t*)fp;
+ if (!val)
+ fp = nv_stack(np, NiL);
+ nv_putv(np, val, flag, fp);
+ if (!val)
+ {
+ register int i;
+ for(i=0; i< sh.lim.open_max; i++)
+ {
+ if(service_list[i]==sp)
+ {
+ close(i);
+ if(--sp->refcount<=0)
+ break;
+ }
+ }
+ free((void*)fp);
+ return;
+ }
+}
+
+static const Namdisc_t servdisc =
+{
+ sizeof(Service_t),
+ putval,
+ 0,
+ 0,
+ setdisc
+};
+
+int b_mkservice(int argc, char** argv, void* extra)
+{
+ register char* var;
+ register char* path;
+ register Namval_t* np;
+ register Service_t* sp;
+ register int fd;
+
+ NOT_USED(argc);
+ NOT_USED(extra);
+ for (;;)
+ {
+ switch (optget(argv, mkservice_usage))
+ {
+ case 0:
+ break;
+ case ':':
+ error(2, opt_info.arg);
+ continue;
+ case '?':
+ error(ERROR_usage(2), opt_info.arg);
+ continue;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ if (error_info.errors || !(var = *argv++) || !(path = *argv++) || *argv)
+ error(ERROR_usage(2), optusage(NiL));
+ if (!(sp = newof(0, Service_t, 1, 0)))
+ error(ERROR_exit(1), "out of space");
+ sp->acceptf = Accept;
+ sp->actionf = Action;
+ sp->errorf = Error;
+ sp->refcount = 1;
+ sp->context = extra;
+ sp->node = 0;
+ sp->fun.disc = &servdisc;
+ if((fd = sh_open(path, O_SERVICE|O_RDWR))<=0)
+ {
+ free((void*)sp);
+ error(ERROR_exit(1), "%s: cannot start service", path);
+ }
+ if((sp->fd = fcntl(fd, F_DUPFD, 10))>=10)
+ close(fd);
+ else
+ sp->fd = fd;
+ np = nv_open(var,sh.var_tree,NV_ARRAY|NV_VARNAME|NV_NOASSIGN);
+ sp->node = np;
+ nv_putval(np, path, 0);
+ nv_stack(np, (Namfun_t*)sp);
+ service_add(sp);
+ return(0);
+}
+
+int b_eloop(int argc, char** argv, void* extra)
+{
+ register long timeout = -1;
+ NOT_USED(argc);
+ NOT_USED(extra);
+ for (;;)
+ {
+ switch (optget(argv, eloop_usage))
+ {
+ case 0:
+ break;
+ case 't':
+ timeout = opt_info.num;
+ continue;
+ case ':':
+ error(2, opt_info.arg);
+ continue;
+ case '?':
+ error(ERROR_usage(2), opt_info.arg);
+ continue;
+ }
+ break;
+ }
+ argv += opt_info.index;
+ if (error_info.errors || *argv)
+ error(ERROR_usage(2), optusage(NiL));
+ while(1)
+ {
+ if(waitnotify(-1, timeout, 0)==0)
+ break;
+ sfprintf(sfstderr,"interrupted\n");
+ }
+ return(errno != 0);
+}
diff --git a/usr/src/lib/libshell/common/bltins/print.c b/usr/src/lib/libshell/common/bltins/print.c
new file mode 100644
index 0000000000..5363c6f3ab
--- /dev/null
+++ b/usr/src/lib/libshell/common/bltins/print.c
@@ -0,0 +1,897 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * echo [arg...]
+ * print [-nrps] [-f format] [-u filenum] [arg...]
+ * printf format [arg...]
+ *
+ * David Korn
+ * AT&T Labs
+ */
+
+#include "defs.h"
+#include <error.h>
+#include <stak.h>
+#include "io.h"
+#include "name.h"
+#include "history.h"
+#include "builtins.h"
+#include "streval.h"
+#include <tmx.h>
+#include <ctype.h>
+#include <ccode.h>
+
+union types_t
+{
+ unsigned char c;
+ short h;
+ int i;
+ long l;
+ Sflong_t ll;
+ Sfdouble_t ld;
+ double d;
+ float f;
+ char *s;
+ int *ip;
+ char **p;
+};
+
+struct printf
+{
+ Sffmt_t hdr;
+ int argsize;
+ int intvar;
+ char **nextarg;
+ char cescape;
+ char err;
+ Shell_t *sh;
+};
+
+static int extend(Sfio_t*,void*, Sffmt_t*);
+static const char preformat[] = "";
+static char *genformat(char*);
+static int fmtvecho(const char*, struct printf*);
+
+struct print
+{
+ Shell_t *sh;
+ const char *options;
+ char raw;
+ char echon;
+};
+
+static char* nullarg[] = { 0, 0 };
+
+/*
+ * Need to handle write failures to avoid locking output pool
+ */
+static int outexceptf(Sfio_t* iop, int mode, void* data, Sfdisc_t* dp)
+{
+ if(mode==SF_DPOP || mode==SF_FINAL)
+ free((void*)dp);
+ else if(mode==SF_WRITE && (errno!= EINTR || sh.trapnote))
+ {
+ int save = errno;
+ sfpurge(iop);
+ sfpool(iop,NIL(Sfio_t*),SF_WRITE);
+ errno = save;
+ errormsg(SH_DICT,ERROR_system(1),e_badwrite,sffileno(iop));
+ }
+ return(0);
+}
+
+#if !SHOPT_ECHOPRINT
+ int B_echo(int argc, char *argv[],void *extra)
+ {
+ static char bsd_univ;
+ struct print prdata;
+ prdata.options = sh_optecho+5;
+ prdata.raw = prdata.echon = 0;
+ prdata.sh = (Shell_t*)extra;
+ NOT_USED(argc);
+ /* This mess is because /bin/echo on BSD is different */
+ if(!prdata.sh->universe)
+ {
+ register char *universe;
+ if(universe=astconf("UNIVERSE",0,0))
+ bsd_univ = (strcmp(universe,"ucb")==0);
+ prdata.sh->universe = 1;
+ }
+ if(!bsd_univ)
+ return(b_print(0,argv,&prdata));
+ prdata.options = sh_optecho;
+ prdata.raw = 1;
+ while(argv[1] && *argv[1]=='-')
+ {
+ if(strcmp(argv[1],"-n")==0)
+ prdata.echon = 1;
+#if !SHOPT_ECHOE
+ else if(strcmp(argv[1],"-e")==0)
+ prdata.raw = 0;
+ else if(strcmp(argv[1],"-ne")==0 || strcmp(argv[1],"-en")==0)
+ {
+ prdata.raw = 0;
+ prdata.echon = 1;
+ }
+#endif /* SHOPT_ECHOE */
+ else
+ break;
+ argv++;
+ }
+ return(b_print(0,argv,&prdata));
+ }
+#endif /* SHOPT_ECHOPRINT */
+
+int b_printf(int argc, char *argv[],void *extra)
+{
+ struct print prdata;
+ NOT_USED(argc);
+ memset(&prdata,0,sizeof(prdata));
+ prdata.sh = (Shell_t*)extra;
+ prdata.options = sh_optprintf;
+ return(b_print(-1,argv,&prdata));
+}
+
+/*
+ * argc==0 when called from echo
+ * argc==-1 when called from printf
+ */
+
+int b_print(int argc, char *argv[], void *extra)
+{
+ register Sfio_t *outfile;
+ register int exitval=0,n, fd = 1;
+ register Shell_t *shp = (Shell_t*)extra;
+ const char *options, *msg = e_file+4;
+ char *format = 0;
+ int sflag = 0, nflag=0, rflag=0;
+ if(argc>0)
+ {
+ options = sh_optprint;
+ nflag = rflag = 0;
+ format = 0;
+ }
+ else
+ {
+ struct print *pp = (struct print*)extra;
+ shp = pp->sh;
+ options = pp->options;
+ if(argc==0)
+ {
+ nflag = pp->echon;
+ rflag = pp->raw;
+ argv++;
+ goto skip;
+ }
+ }
+ while((n = optget(argv,options))) switch(n)
+ {
+ case 'n':
+ nflag++;
+ break;
+ case 'p':
+ fd = shp->coutpipe;
+ msg = e_query;
+ break;
+ case 'f':
+ format = opt_info.arg;
+ break;
+ case 's':
+ /* print to history file */
+ if(!sh_histinit())
+ errormsg(SH_DICT,ERROR_system(1),e_history);
+ fd = sffileno(shp->hist_ptr->histfp);
+ sh_onstate(SH_HISTORY);
+ sflag++;
+ break;
+ case 'e':
+ rflag = 0;
+ break;
+ case 'r':
+ rflag = 1;
+ break;
+ case 'u':
+ fd = (int)strtol(opt_info.arg,&opt_info.arg,10);
+ if(*opt_info.arg)
+ fd = -1;
+ else if(fd<0 || fd >= shp->lim.open_max)
+ fd = -1;
+ else if(!(sh.inuse_bits&(1<<fd)) && (sh_inuse(fd) || (shp->hist_ptr && fd==sffileno(shp->hist_ptr->histfp))))
+
+ fd = -1;
+ break;
+ case ':':
+ /* The following is for backward compatibility */
+#if OPT_VERSION >= 19990123
+ if(strcmp(opt_info.name,"-R")==0)
+#else
+ if(strcmp(opt_info.option,"-R")==0)
+#endif
+ {
+ rflag = 1;
+ if(error_info.errors==0)
+ {
+ argv += opt_info.index+1;
+ /* special case test for -Rn */
+ if(strchr(argv[-1],'n'))
+ nflag++;
+ if(*argv && strcmp(*argv,"-n")==0)
+ {
+
+ nflag++;
+ argv++;
+ }
+ goto skip2;
+ }
+ }
+ else
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ if(error_info.errors || (argc<0 && !(format = *argv++)))
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+skip:
+ if(format)
+ format = genformat(format);
+ /* handle special case of '-' operand for print */
+ if(argc>0 && *argv && strcmp(*argv,"-")==0 && strcmp(argv[-1],"--"))
+ argv++;
+skip2:
+ if(fd < 0)
+ {
+ errno = EBADF;
+ n = 0;
+ }
+ else if(!(n=shp->fdstatus[fd]))
+ n = sh_iocheckfd(fd);
+ if(!(n&IOWRITE))
+ {
+ /* don't print error message for stdout for compatibility */
+ if(fd==1)
+ return(1);
+ errormsg(SH_DICT,ERROR_system(1),msg);
+ }
+ if(!(outfile=shp->sftable[fd]))
+ {
+ Sfdisc_t *dp;
+ sh_onstate(SH_NOTRACK);
+ n = SF_WRITE|((n&IOREAD)?SF_READ:0);
+ shp->sftable[fd] = outfile = sfnew(NIL(Sfio_t*),shp->outbuff,IOBSIZE,fd,n);
+ sh_offstate(SH_NOTRACK);
+ sfpool(outfile,shp->outpool,SF_WRITE);
+ if(dp = new_of(Sfdisc_t,0))
+ {
+ dp->exceptf = outexceptf;
+ dp->seekf = 0;
+ dp->writef = 0;
+ dp->readf = 0;
+ sfdisc(outfile,dp);
+ }
+ }
+ /* turn off share to guarantee atomic writes for printf */
+ n = sfset(outfile,SF_SHARE|SF_PUBLIC,0);
+ if(format)
+ {
+ /* printf style print */
+ Sfio_t *pool;
+ struct printf pdata;
+ memset(&pdata, 0, sizeof(pdata));
+ pdata.sh = shp;
+ pdata.hdr.version = SFIO_VERSION;
+ pdata.hdr.extf = extend;
+ pdata.nextarg = argv;
+ sh_offstate(SH_STOPOK);
+ pool=sfpool(sfstderr,NIL(Sfio_t*),SF_WRITE);
+ do
+ {
+ if(shp->trapnote&SH_SIGSET)
+ break;
+ pdata.hdr.form = format;
+ sfprintf(outfile,"%!",&pdata);
+ } while(*pdata.nextarg && pdata.nextarg!=argv);
+ if(pdata.nextarg == nullarg && pdata.argsize>0)
+ sfwrite(outfile,stakptr(staktell()),pdata.argsize);
+ sfpool(sfstderr,pool,SF_WRITE);
+ exitval = pdata.err;
+ }
+ else
+ {
+ /* echo style print */
+ if(sh_echolist(outfile,rflag,argv) && !nflag)
+ sfputc(outfile,'\n');
+ }
+ if(sflag)
+ {
+ hist_flush(shp->hist_ptr);
+ sh_offstate(SH_HISTORY);
+ }
+ else if(n&SF_SHARE)
+ {
+ sfset(outfile,SF_SHARE|SF_PUBLIC,1);
+ sfsync(outfile);
+ }
+ return(exitval);
+}
+
+/*
+ * echo the argument list onto <outfile>
+ * if <raw> is non-zero then \ is not a special character.
+ * returns 0 for \c otherwise 1.
+ */
+
+int sh_echolist(Sfio_t *outfile, int raw, char *argv[])
+{
+ register char *cp;
+ register int n;
+ struct printf pdata;
+ pdata.cescape = 0;
+ pdata.err = 0;
+ while(!pdata.cescape && (cp= *argv++))
+ {
+ if(!raw && (n=fmtvecho(cp,&pdata))>=0)
+ {
+ if(n)
+ sfwrite(outfile,stakptr(staktell()),n);
+ }
+ else
+ sfputr(outfile,cp,-1);
+ if(*argv)
+ sfputc(outfile,' ');
+ sh_sigcheck();
+ }
+ return(!pdata.cescape);
+}
+
+/*
+ * modified version of stresc for generating formats
+ */
+static char strformat(char *s)
+{
+ register char* t;
+ register int c;
+ char* b;
+ char* p;
+
+ b = t = s;
+ for (;;)
+ {
+ switch (c = *s++)
+ {
+ case '\\':
+ if(*s==0)
+ break;
+ c = chresc(s - 1, &p);
+ s = p;
+#if SHOPT_MULTIBYTE
+ if(c>UCHAR_MAX && mbwide())
+ {
+ t += wctomb(t, c);
+ continue;
+ }
+#endif /* SHOPT_MULTIBYTE */
+ if(c=='%')
+ *t++ = '%';
+ else if(c==0)
+ {
+ *t++ = '%';
+ c = 'Z';
+ }
+ break;
+ case 0:
+ *t = 0;
+ return(t - b);
+ }
+ *t++ = c;
+ }
+}
+
+
+static char *genformat(char *format)
+{
+ register char *fp;
+ stakseek(0);
+ stakputs(preformat);
+ stakputs(format);
+ fp = (char*)stakfreeze(1);
+ strformat(fp+sizeof(preformat)-1);
+ return(fp);
+}
+
+static char *fmthtml(const char *string)
+{
+ register const char *cp = string;
+ register int c, offset = staktell();
+ while(c= *(unsigned char*)cp++)
+ {
+#if SHOPT_MULTIBYTE
+ register int s;
+ if((s=mbsize(cp-1)) > 1)
+ {
+ cp += (s-1);
+ continue;
+ }
+#endif /* SHOPT_MULTIBYTE */
+ if(c=='<')
+ stakputs("&lt;");
+ else if(c=='>')
+ stakputs("&gt;");
+ else if(c=='&')
+ stakputs("&amp;");
+ else if(c=='"')
+ stakputs("&quot;");
+ else if(c=='\'')
+ stakputs("&apos;");
+ else if(c==' ')
+ stakputs("&nbsp;");
+ else if(!isprint(c) && c!='\n' && c!='\r')
+ sfprintf(stkstd,"&#%X;",CCMAPC(c,CC_NATIVE,CC_ASCII));
+ else
+ stakputc(c);
+ }
+ stakputc(0);
+ return(stakptr(offset));
+}
+
+static void *fmtbase64(char *string, ssize_t *sz)
+{
+ char *cp;
+ Sfdouble_t d;
+ size_t size;
+ Namval_t *np = nv_open(string, NiL, NV_VARNAME|NV_NOASSIGN|NV_NOADD);
+ static union types_t number;
+ if(!np)
+ return("");
+ if(nv_isattr(np,NV_INTEGER))
+ {
+ d = nv_getnum(np);
+ if(nv_isattr(np,NV_DOUBLE))
+ {
+ if(nv_isattr(np,NV_LONG))
+ {
+ size = sizeof(Sfdouble_t);
+ number.ld = d;
+ }
+ else if(nv_isattr(np,NV_SHORT))
+ {
+ size = sizeof(float);
+ number.f = (float)d;
+ }
+ else
+ {
+ size = sizeof(double);
+ number.d = (double)d;
+ }
+ }
+ else
+ {
+ if(nv_isattr(np,NV_LONG))
+ {
+ size = sizeof(Sflong_t);
+ number.ll = (Sflong_t)d;
+ }
+ else if(nv_isattr(np,NV_SHORT))
+ {
+ size = sizeof(short);
+ number.h = (short)d;
+ }
+ else
+ {
+ size = sizeof(short);
+ number.i = (int)d;
+ }
+ }
+ if(sz)
+ *sz = size;
+ return((void*)&number);
+ }
+ if(nv_isattr(np,NV_BINARY))
+ nv_onattr(np,NV_RAW);
+ cp = nv_getval(np);
+ if(nv_isattr(np,NV_BINARY))
+ nv_offattr(np,NV_RAW);
+ if((size = nv_size(np))==0)
+ size = strlen(cp);
+ if(sz)
+ *sz = size;
+ return((void*)cp);
+}
+
+static int extend(Sfio_t* sp, void* v, Sffmt_t* fe)
+{
+ char* lastchar = "";
+ register int neg = 0;
+ Sfdouble_t d;
+ Sfdouble_t longmin = LDBL_LLONG_MIN;
+ Sfdouble_t longmax = LDBL_LLONG_MAX;
+ int format = fe->fmt;
+ int n;
+ int fold = fe->base;
+ union types_t* value = (union types_t*)v;
+ struct printf* pp = (struct printf*)fe;
+ register char* argp = *pp->nextarg;
+
+ fe->flags |= SFFMT_VALUE;
+ if(!argp || format=='Z')
+ {
+ switch(format)
+ {
+ case 'c':
+ value->c = 0;
+ fe->flags &= ~SFFMT_LONG;
+ break;
+ case 'q':
+ format = 's';
+ /* FALL THROUGH */
+ case 's':
+ case 'H':
+ case 'B':
+ case 'P':
+ case 'R':
+ case 'Z':
+ case 'b':
+ fe->fmt = 's';
+ fe->size = -1;
+ fe->base = -1;
+ value->s = "";
+ fe->flags &= ~SFFMT_LONG;
+ break;
+ case 'a':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'A':
+ case 'E':
+ case 'F':
+ case 'G':
+ if(SFFMT_LDOUBLE)
+ value->ld = 0.;
+ else
+ value->d = 0.;
+ break;
+ case 'n':
+ value->ip = &pp->intvar;
+ break;
+ case 'Q':
+ value->ll = 0;
+ break;
+ case 'T':
+ fe->fmt = 'd';
+ value->ll = tmxgettime();
+ break;
+ default:
+ if(!strchr("DdXxoUu",format))
+ errormsg(SH_DICT,ERROR_exit(1),e_formspec,format);
+ fe->fmt = 'd';
+ value->ll = 0;
+ break;
+ }
+ }
+ else
+ {
+ switch(format)
+ {
+ case 'p':
+ value->p = (char**)strtol(argp,&lastchar,10);
+ break;
+ case 'n':
+ {
+ Namval_t *np;
+ np = nv_open(argp,sh.var_tree,NV_VARNAME|NV_NOASSIGN|NV_NOARRAY);
+ nv_unset(np);
+ nv_onattr(np,NV_INTEGER);
+ if (np->nvalue.lp = new_of(int32_t,0))
+ *np->nvalue.lp = 0;
+ nv_setsize(np,10);
+ if(sizeof(int)==sizeof(int32_t))
+ value->ip = (int*)np->nvalue.lp;
+ else
+ {
+ int32_t sl = 1;
+ value->ip = (int*)(((char*)np->nvalue.lp) + (*((char*)&sl) ? 0 : sizeof(int)));
+ }
+ nv_close(np);
+ break;
+ }
+ case 'q':
+ case 'b':
+ case 's':
+ case 'B':
+ case 'H':
+ case 'P':
+ case 'R':
+ fe->fmt = 's';
+ fe->size = -1;
+ if(format=='s' && fe->base>=0)
+ {
+ value->p = pp->nextarg;
+ pp->nextarg = nullarg;
+ }
+ else
+ {
+ fe->base = -1;
+ value->s = argp;
+ }
+ fe->flags &= ~SFFMT_LONG;
+ break;
+ case 'c':
+ if(fe->base >=0)
+ value->s = argp;
+ else
+ value->c = *argp;
+ fe->flags &= ~SFFMT_LONG;
+ break;
+ case 'o':
+ case 'x':
+ case 'X':
+ case 'u':
+ case 'U':
+ longmax = LDBL_ULLONG_MAX;
+ case '.':
+ if(fe->size==2 && strchr("bcsqHPRQTZ",*fe->form))
+ {
+ value->ll = ((unsigned char*)argp)[0];
+ break;
+ }
+ case 'd':
+ case 'D':
+ case 'i':
+ switch(*argp)
+ {
+ case '\'':
+ case '"':
+ value->ll = ((unsigned char*)argp)[1];
+ break;
+ default:
+ d = sh_strnum(argp,&lastchar,0);
+ if(d<longmin)
+ {
+ errormsg(SH_DICT,ERROR_warn(0),e_overflow,argp);
+ pp->err = 1;
+ d = longmin;
+ }
+ else if(d>longmax)
+ {
+ errormsg(SH_DICT,ERROR_warn(0),e_overflow,argp);
+ pp->err = 1;
+ d = longmax;
+ }
+ value->ll = (Sflong_t)d;
+ if(lastchar == *pp->nextarg)
+ {
+ value->ll = *argp;
+ lastchar = "";
+ }
+ break;
+ }
+ if(neg)
+ value->ll = -value->ll;
+ fe->size = sizeof(value->ll);
+ break;
+ case 'a':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'A':
+ case 'E':
+ case 'F':
+ case 'G':
+ d = sh_strnum(*pp->nextarg,&lastchar,0);
+ if(SFFMT_LDOUBLE)
+ {
+ value->ld = d;
+ fe->size = sizeof(value->ld);
+ }
+ else
+ {
+ value->d = d;
+ fe->size = sizeof(value->d);
+ }
+ break;
+ case 'Q':
+ value->ll = (Sflong_t)strelapsed(*pp->nextarg,&lastchar,1);
+ break;
+ case 'T':
+ value->ll = (Sflong_t)tmxdate(*pp->nextarg,&lastchar,TMX_NOW);
+ break;
+ default:
+ value->ll = 0;
+ fe->fmt = 'd';
+ fe->size = sizeof(value->ll);
+ errormsg(SH_DICT,ERROR_exit(1),e_formspec,format);
+ break;
+ }
+ if (format == '.')
+ value->i = value->ll;
+ if(*lastchar)
+ {
+ errormsg(SH_DICT,ERROR_warn(0),e_argtype,format);
+ pp->err = 1;
+ }
+ pp->nextarg++;
+ }
+ switch(format)
+ {
+ case 'Z':
+ fe->fmt = 'c';
+ fe->base = -1;
+ value->c = 0;
+ break;
+ case 'b':
+ if((n=fmtvecho(value->s,pp))>=0)
+ {
+ if(pp->nextarg == nullarg)
+ {
+ pp->argsize = n;
+ return -1;
+ }
+ value->s = stakptr(staktell());
+ }
+ break;
+ case 'B':
+ value->s = (char*)fmtbase64(value->s, &fe->size);
+ break;
+ case 'H':
+ value->s = fmthtml(value->s);
+ break;
+ case 'q':
+ value->s = sh_fmtqf(value->s, !!(fe->flags & SFFMT_ALTER), fold);
+ break;
+ case 'P':
+ {
+ char *s = fmtmatch(value->s);
+ if(!s || *s==0)
+ errormsg(SH_DICT,ERROR_exit(1),e_badregexp,value->s);
+ value->s = s;
+ break;
+ }
+ case 'R':
+ value->s = fmtre(value->s);
+ if(*value->s==0)
+ errormsg(SH_DICT,ERROR_exit(1),e_badregexp,value->s);
+ break;
+ case 'Q':
+ if (fe->n_str>0)
+ {
+ fe->fmt = 'd';
+ fe->size = sizeof(value->ll);
+ }
+ else
+ {
+ value->s = fmtelapsed(value->ll, 1);
+ fe->fmt = 's';
+ fe->size = -1;
+ }
+ break;
+ case 'T':
+ if(fe->n_str>0)
+ {
+ n = fe->t_str[fe->n_str];
+ fe->t_str[fe->n_str] = 0;
+ value->s = fmttmx(fe->t_str, value->ll);
+ fe->t_str[fe->n_str] = n;
+ }
+ else value->s = fmttmx(NIL(char*), value->ll);
+ fe->fmt = 's';
+ fe->size = -1;
+ break;
+ }
+ return 0;
+}
+
+/*
+ * construct System V echo string out of <cp>
+ * If there are not escape sequences, returns -1
+ * Otherwise, puts null terminated result on stack, but doesn't freeze it
+ * returns length of output.
+ */
+
+static int fmtvecho(const char *string, struct printf *pp)
+{
+ register const char *cp = string, *cpmax;
+ register int c;
+ register int offset = staktell();
+#if SHOPT_MULTIBYTE
+ int chlen;
+ if(mbwide())
+ {
+ while(1)
+ {
+ if ((chlen = mbsize(cp)) > 1)
+ /* Skip over multibyte characters */
+ cp += chlen;
+ else if((c= *cp++)==0 || c == '\\')
+ break;
+ }
+ }
+ else
+#endif /* SHOPT_MULTIBYTE */
+ while((c= *cp++) && (c!='\\'));
+ if(c==0)
+ return(-1);
+ c = --cp - string;
+ if(c>0)
+ stakwrite((void*)string,c);
+ for(; c= *cp; cp++)
+ {
+#if SHOPT_MULTIBYTE
+ if (mbwide() && ((chlen = mbsize(cp)) > 1))
+ {
+ stakwrite(cp,chlen);
+ cp += (chlen-1);
+ continue;
+ }
+#endif /* SHOPT_MULTIBYTE */
+ if( c=='\\') switch(*++cp)
+ {
+ case 'E':
+ c = ('a'==97?'\033':39); /* ASCII/EBCDIC */
+ break;
+ case 'a':
+ c = '\a';
+ break;
+ case 'b':
+ c = '\b';
+ break;
+ case 'c':
+ pp->cescape++;
+ pp->nextarg = nullarg;
+ goto done;
+ case 'f':
+ c = '\f';
+ break;
+ case 'n':
+ c = '\n';
+ break;
+ case 'r':
+ c = '\r';
+ break;
+ case 'v':
+ c = '\v';
+ break;
+ case 't':
+ c = '\t';
+ break;
+ case '\\':
+ c = '\\';
+ break;
+ case '0':
+ c = 0;
+ cpmax = cp + 4;
+ while(++cp<cpmax && *cp>='0' && *cp<='7')
+ {
+ c <<= 3;
+ c |= (*cp-'0');
+ }
+ default:
+ cp--;
+ }
+ stakputc(c);
+ }
+done:
+ c = staktell()-offset;
+ stakputc(0);
+ stakseek(offset);
+ return(c);
+}
diff --git a/usr/src/lib/libshell/common/bltins/read.c b/usr/src/lib/libshell/common/bltins/read.c
new file mode 100644
index 0000000000..930470275c
--- /dev/null
+++ b/usr/src/lib/libshell/common/bltins/read.c
@@ -0,0 +1,590 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * read [-Aprs] [-d delim] [-u filenum] [-t timeout] [-n n] [-N n] [name...]
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#include <ast.h>
+#include <error.h>
+#include <ctype.h>
+#include "defs.h"
+#include "variables.h"
+#include "lexstates.h"
+#include "io.h"
+#include "name.h"
+#include "builtins.h"
+#include "history.h"
+#include "terminal.h"
+#include "edit.h"
+
+#define R_FLAG 1 /* raw mode */
+#define S_FLAG 2 /* save in history file */
+#define A_FLAG 4 /* read into array */
+#define N_FLAG 8 /* fixed size read at most */
+#define NN_FLAG 0x10 /* fixed size read exact */
+#define V_FLAG 0x20 /* use default value */
+#define D_FLAG 8 /* must be number of bits for all flags */
+
+int b_read(int argc,char *argv[], void *extra)
+{
+ Sfdouble_t sec;
+ register char *name;
+ register int r, flags=0, fd=0;
+ register Shell_t *shp = (Shell_t*)extra;
+ long timeout = 1000*shp->st.tmout;
+ int save_prompt;
+ static char default_prompt[3] = {ESC,ESC};
+ NOT_USED(argc);
+ while((r = optget(argv,sh_optread))) switch(r)
+ {
+ case 'A':
+ flags |= A_FLAG;
+ break;
+ case 't':
+ sec = sh_strnum(opt_info.arg, (char**)0,1);
+ timeout = sec ? 1000*sec : 1;
+ break;
+ case 'd':
+ if(opt_info.arg && *opt_info.arg!='\n')
+ {
+ char *cp = opt_info.arg;
+ flags &= ~((1<<D_FLAG)-1);
+ flags |= (mbchar(cp)<< D_FLAG);
+ }
+ break;
+ case 'p':
+ if((fd = shp->cpipe[0])<=0)
+ errormsg(SH_DICT,ERROR_exit(1),e_query);
+ break;
+ case 'n': case 'N':
+ flags &= ~((1<<D_FLAG)-1);
+ flags |= (r=='n'?N_FLAG:NN_FLAG);
+ r = (int)opt_info.num;
+ if((unsigned)r > (1<<((8*sizeof(int))-D_FLAG))-1)
+ errormsg(SH_DICT,ERROR_exit(1),e_overlimit,"n");
+ flags |= (r<< D_FLAG);
+ break;
+ case 'r':
+ flags |= R_FLAG;
+ break;
+ case 's':
+ /* save in history file */
+ flags |= S_FLAG;
+ break;
+ case 'u':
+ fd = (int)opt_info.num;
+ if(sh_inuse(fd))
+ fd = -1;
+ break;
+ case 'v':
+ flags |= V_FLAG;
+ break;
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2), "%s", optusage((char*)0));
+ if(!((r=shp->fdstatus[fd])&IOREAD) || !(r&(IOSEEK|IONOSEEK)))
+ r = sh_iocheckfd(fd);
+ if(fd<0 || !(r&IOREAD))
+ errormsg(SH_DICT,ERROR_system(1),e_file+4);
+ /* look for prompt */
+ shp->prompt = default_prompt;
+ if((name = *argv) && (name=strchr(name,'?')) && (r&IOTTY))
+ {
+ r = strlen(++name)+1;
+ if(shp->prompt=(char*)sfreserve(sfstderr,r,SF_LOCKR))
+ {
+ memcpy(shp->prompt,name,r);
+ sfwrite(sfstderr,shp->prompt,r-1);
+ }
+ }
+ shp->timeout = 0;
+ save_prompt = shp->nextprompt;
+ shp->nextprompt = 0;
+ r=sh_readline(shp,argv,fd,flags,timeout);
+ shp->nextprompt = save_prompt;
+ if(r==0 && (r=(sfeof(shp->sftable[fd])||sferror(shp->sftable[fd]))))
+ {
+ if(fd == shp->cpipe[0])
+ {
+ sh_pclose(shp->cpipe);
+ return(1);
+ }
+ }
+ sfclrerr(shp->sftable[fd]);
+ return(r);
+}
+
+/*
+ * here for read timeout
+ */
+static void timedout(void *handle)
+{
+ sfclrlock((Sfio_t*)handle);
+ sh_exit(1);
+}
+
+/*
+ * This is the code to read a line and to split it into tokens
+ * <names> is an array of variable names
+ * <fd> is the file descriptor
+ * <flags> is union of -A, -r, -s, and contains delimiter if not '\n'
+ * <timeout> is number of milli-seconds until timeout
+ */
+
+int sh_readline(register Shell_t *shp,char **names, int fd, int flags,long timeout)
+{
+ register int c;
+ register unsigned char *cp;
+ register Namval_t *np;
+ register char *name, *val;
+ register Sfio_t *iop;
+ char *ifs;
+ unsigned char *cpmax;
+ unsigned char *del;
+ char was_escape = 0;
+ char use_stak = 0;
+ char was_write = 0;
+ char was_share = 1;
+ int rel, wrd;
+ long array_index = 0;
+ void *timeslot=0;
+ int delim = '\n';
+ int jmpval=0;
+ int size = 0;
+ struct checkpt buff;
+ if(!(iop=shp->sftable[fd]) && !(iop=sh_iostream(fd)))
+ return(1);
+ if(names && (name = *names))
+ {
+ if(val= strchr(name,'?'))
+ *val = 0;
+ np = nv_open(name,shp->var_tree,NV_NOASSIGN|NV_VARNAME|NV_ARRAY);
+ if((flags&V_FLAG) && shp->ed_context)
+ ((struct edit*)shp->ed_context)->e_default = np;
+ if(flags&A_FLAG)
+ {
+ flags &= ~A_FLAG;
+ array_index = 1;
+ nv_unset(np);
+ nv_putsub(np,NIL(char*),0L);
+ }
+ else
+ name = *++names;
+ if(val)
+ *val = '?';
+ }
+ else
+ {
+ name = 0;
+ if(dtvnext(shp->var_tree) || shp->namespace)
+ np = nv_open(nv_name(REPLYNOD),shp->var_tree,0);
+ else
+ np = REPLYNOD;
+ }
+ if(flags>>D_FLAG) /* delimiter not new-line or fixed size read */
+ {
+ if(flags&(N_FLAG|NN_FLAG))
+ size = ((unsigned)flags)>>D_FLAG;
+ else
+ delim = ((unsigned)flags)>>D_FLAG;
+ if(shp->fdstatus[fd]&IOTTY)
+ tty_raw(fd,1);
+ }
+ if(!(flags&(N_FLAG|NN_FLAG)))
+ {
+ Namval_t *mp;
+ /* set up state table based on IFS */
+ ifs = nv_getval(mp=nv_scoped(IFSNOD));
+ if((flags&R_FLAG) && shp->ifstable['\\']==S_ESC)
+ shp->ifstable['\\'] = 0;
+ else if(!(flags&R_FLAG) && shp->ifstable['\\']==0)
+ shp->ifstable['\\'] = S_ESC;
+ shp->ifstable[delim] = S_NL;
+ if(delim!='\n')
+ {
+ shp->ifstable['\n'] = 0;
+ nv_putval(mp, ifs, NV_RDONLY);
+ }
+ shp->ifstable[0] = S_EOF;
+ }
+ sfclrerr(iop);
+ if(np->nvfun && np->nvfun->disc->readf)
+ return((* np->nvfun->disc->readf)(np,iop,delim,np->nvfun));
+ was_write = (sfset(iop,SF_WRITE,0)&SF_WRITE)!=0;
+ if(fd==0)
+ was_share = (sfset(iop,SF_SHARE,1)&SF_SHARE)!=0;
+ if(timeout || (shp->fdstatus[fd]&(IOTTY|IONOSEEK)))
+ {
+ sh_pushcontext(&buff,1);
+ jmpval = sigsetjmp(buff.buff,0);
+ if(jmpval)
+ goto done;
+ if(timeout)
+ timeslot = (void*)sh_timeradd(timeout,0,timedout,(void*)iop);
+ }
+ if(flags&(N_FLAG|NN_FLAG))
+ {
+ char buf[64],*var=buf;
+ /* reserved buffer */
+ if((c=size)>=sizeof(buf))
+ {
+ if(!(var = (char*)malloc(c+1)))
+ sh_exit(1);
+ }
+ if((sfset(iop,SF_SHARE,1)&SF_SHARE) && fd!=0)
+ was_share = 1;
+ if(size==0)
+ {
+ cp = sfreserve(iop,0,0);
+ c = 0;
+ }
+ else
+ {
+ c= (shp->fdstatus[fd]&(IOTTY|IONOSEEK))?1:-1;
+ if(flags&NN_FLAG)
+ c = size;
+ if(cp = sfreserve(iop,c,!(flags&NN_FLAG)))
+ c = sfvalue(iop);
+ else
+ c = 0;
+ if(c>size)
+ c = size;
+ if(c>0)
+ {
+ memcpy((void*)var,cp,c);
+ if(flags&N_FLAG)
+ sfread(iop,cp,c);
+ }
+ var[c] = 0;
+ if(c>=size)
+ sfclrerr(iop);
+ }
+ if(timeslot)
+ timerdel(timeslot);
+ if(nv_isattr(np,NV_BINARY))
+ {
+ if(c<sizeof(buf))
+ var = memdup(var,c);
+ nv_putval(np,var, NV_RAW);
+ nv_setsize(np,c);
+ }
+ else
+ {
+ nv_putval(np,var,0);
+ if(c>=sizeof(buf))
+ free((void*)var);
+ }
+ goto done;
+ }
+ else if(cp = (unsigned char*)sfgetr(iop,delim,0))
+ c = sfvalue(iop);
+ else if(cp = (unsigned char*)sfgetr(iop,delim,-1))
+ c = sfvalue(iop)+1;
+ if(timeslot)
+ timerdel(timeslot);
+ if((flags&S_FLAG) && !shp->hist_ptr)
+ {
+ sh_histinit();
+ if(!shp->hist_ptr)
+ flags &= ~S_FLAG;
+ }
+ if(cp)
+ {
+ cpmax = cp + c;
+#if SHOPT_CRNL
+ if(delim=='\n' && c>=2 && cpmax[-2]=='\r')
+ cpmax--;
+#endif /* SHOPT_CRNL */
+ if(*(cpmax-1) != delim)
+ *(cpmax-1) = delim;
+ if(flags&S_FLAG)
+ sfwrite(shp->hist_ptr->histfp,(char*)cp,c);
+ c = shp->ifstable[*cp++];
+#if !SHOPT_MULTIBYTE
+ if(!name && (flags&R_FLAG)) /* special case single argument */
+ {
+ /* skip over leading blanks */
+ while(c==S_SPACE)
+ c = shp->ifstable[*cp++];
+ /* strip trailing delimiters */
+ if(cpmax[-1] == '\n')
+ cpmax--;
+ if(cpmax>cp)
+ {
+ while((c=shp->ifstable[*--cpmax])==S_DELIM || c==S_SPACE);
+ cpmax[1] = 0;
+ }
+ else
+ *cpmax =0;
+ if(nv_isattr(np, NV_RDONLY))
+ {
+ errormsg(SH_DICT,ERROR_warn(0),e_readonly, nv_name(np));
+ jmpval = 1;
+ }
+ else
+ nv_putval(np,(char*)cp-1,0);
+ goto done;
+ }
+#endif /* !SHOPT_MULTIBYTE */
+ }
+ else
+ c = S_NL;
+ shp->nextprompt = 2;
+ rel= staktell();
+ /* val==0 at the start of a field */
+ val = 0;
+ del = 0;
+ while(1)
+ {
+ switch(c)
+ {
+#if SHOPT_MULTIBYTE
+ case S_MBYTE:
+ if(val==0)
+ val = (char*)(cp-1);
+ if(sh_strchr(ifs,(char*)cp-1)>=0)
+ {
+ c = mbsize((char*)cp-1);
+ if(name)
+ cp[-1] = 0;
+ if(c>1)
+ cp += (c-1);
+ c = S_DELIM;
+ }
+ else
+ c = 0;
+ continue;
+#endif /*SHOPT_MULTIBYTE */
+ case S_ESC:
+ /* process escape character */
+ if((c = shp->ifstable[*cp++]) == S_NL)
+ was_escape = 1;
+ else
+ c = 0;
+ if(val)
+ {
+ stakputs(val);
+ use_stak = 1;
+ was_escape = 1;
+ *val = 0;
+ }
+ continue;
+
+ case S_EOF:
+ /* check for end of buffer */
+ if(val && *val)
+ {
+ stakputs(val);
+ use_stak = 1;
+ }
+ val = 0;
+ if(cp>=cpmax)
+ {
+ c = S_NL;
+ break;
+ }
+ /* eliminate null bytes */
+ c = shp->ifstable[*cp++];
+ if(!name && val && (c==S_SPACE||c==S_DELIM||c==S_MBYTE))
+ c = 0;
+ continue;
+ case S_NL:
+ if(was_escape)
+ {
+ was_escape = 0;
+ if(cp = (unsigned char*)sfgetr(iop,delim,0))
+ c = sfvalue(iop);
+ else if(cp=(unsigned char*)sfgetr(iop,delim,-1))
+ c = sfvalue(iop)+1;
+ if(cp)
+ {
+ if(flags&S_FLAG)
+ sfwrite(shp->hist_ptr->histfp,(char*)cp,c);
+ cpmax = cp + c;
+ c = shp->ifstable[*cp++];
+ val=0;
+ if(!name && (c==S_SPACE || c==S_DELIM || c==S_MBYTE))
+ c = 0;
+ continue;
+ }
+ }
+ c = S_NL;
+ break;
+
+ case S_SPACE:
+ /* skip over blanks */
+ while((c=shp->ifstable[*cp++])==S_SPACE);
+ if(!val)
+ continue;
+#if SHOPT_MULTIBYTE
+ if(c==S_MBYTE)
+ {
+ if(sh_strchr(ifs,(char*)cp-1)>=0)
+ {
+ if((c = mbsize((char*)cp-1))>1)
+ cp += (c-1);
+ c = S_DELIM;
+ }
+ else
+ c = 0;
+ }
+#endif /* SHOPT_MULTIBYTE */
+ if(c!=S_DELIM)
+ break;
+ /* FALL THRU */
+
+ case S_DELIM:
+ if(!del)
+ del = cp - 1;
+ if(name)
+ {
+ /* skip over trailing blanks */
+ while((c=shp->ifstable[*cp++])==S_SPACE);
+ break;
+ }
+ /* FALL THRU */
+
+ case 0:
+ if(val==0 || was_escape)
+ {
+ val = (char*)(cp-1);
+ was_escape = 0;
+ }
+ /* skip over word characters */
+ wrd = -1;
+ while(1)
+ {
+ while((c=shp->ifstable[*cp++])==0)
+ if(!wrd)
+ wrd = 1;
+ if(!del&&c==S_DELIM)
+ del = cp - 1;
+ if(name || c==S_NL || c==S_ESC || c==S_EOF || c==S_MBYTE)
+ break;
+ if(wrd<0)
+ wrd = 0;
+ }
+ if(wrd>0)
+ del = (unsigned char*)"";
+ if(c!=S_MBYTE)
+ cp[-1] = 0;
+ continue;
+ }
+ /* assign value and advance to next variable */
+ if(!val)
+ val = "";
+ if(use_stak)
+ {
+ stakputs(val);
+ stakputc(0);
+ val = stakptr(rel);
+ }
+ if(!name && *val)
+ {
+ /* strip off trailing space delimiters */
+ register unsigned char *vp = (unsigned char*)val + strlen(val);
+ while(shp->ifstable[*--vp]==S_SPACE);
+ if(vp==del)
+ {
+ if(vp==(unsigned char*)val)
+ vp--;
+ else
+ while(shp->ifstable[*--vp]==S_SPACE);
+ }
+ vp[1] = 0;
+ }
+ if(nv_isattr(np, NV_RDONLY))
+ {
+ errormsg(SH_DICT,ERROR_warn(0),e_readonly, nv_name(np));
+ jmpval = 1;
+ }
+ else
+ nv_putval(np,val,0);
+ val = 0;
+ del = 0;
+ if(use_stak)
+ {
+ stakseek(rel);
+ use_stak = 0;
+ }
+ if(array_index)
+ {
+ nv_putsub(np, NIL(char*), array_index++);
+ if(c!=S_NL)
+ continue;
+ name = *++names;
+ }
+ while(1)
+ {
+ if(sh_isoption(SH_ALLEXPORT)&&!strchr(nv_name(np),'.') && !nv_isattr(np,NV_EXPORT))
+ {
+ nv_onattr(np,NV_EXPORT);
+ sh_envput(sh.env,np);
+ }
+ if(name)
+ {
+ nv_close(np);
+ np = nv_open(name,shp->var_tree,NV_NOASSIGN|NV_VARNAME);
+ name = *++names;
+ }
+ else
+ np = 0;
+ if(c!=S_NL)
+ break;
+ if(!np)
+ goto done;
+ if(nv_isattr(np, NV_RDONLY))
+ {
+ errormsg(SH_DICT,ERROR_warn(0),e_readonly, nv_name(np));
+ jmpval = 1;
+ }
+ else
+ nv_putval(np, "", 0);
+ }
+ }
+done:
+ if(timeout || (shp->fdstatus[fd]&(IOTTY|IONOSEEK)))
+ sh_popcontext(&buff);
+ if(was_write)
+ sfset(iop,SF_WRITE,1);
+ if(!was_share)
+ sfset(iop,SF_SHARE,0);
+ nv_close(np);
+ if((flags>>D_FLAG) && (shp->fdstatus[fd]&IOTTY))
+ tty_cooked(fd);
+ if(flags&S_FLAG)
+ hist_flush(shp->hist_ptr);
+ if(jmpval > 1)
+ siglongjmp(*shp->jmplist,jmpval);
+ return(jmpval);
+}
+
diff --git a/usr/src/lib/libshell/common/bltins/shiocmd_solaris.c b/usr/src/lib/libshell/common/bltins/shiocmd_solaris.c
new file mode 100644
index 0000000000..25bced42a2
--- /dev/null
+++ b/usr/src/lib/libshell/common/bltins/shiocmd_solaris.c
@@ -0,0 +1,1180 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <shell.h>
+#include <stdio.h>
+#include <option.h>
+#include <stk.h>
+#include <tm.h>
+#include "name.h"
+#undef nv_isnull
+#ifndef SH_DICT
+# define SH_DICT "libshell"
+#endif
+#include <poll.h>
+
+/*
+ * time formatting related
+*/
+struct dctime
+{
+ Namfun_t fun;
+ Namval_t *format;
+ char buff[256]; /* Must be large enougth for |tmfmt()| */
+};
+
+static char *get_time(Namval_t* np, Namfun_t* nfp)
+{
+ struct dctime *dp = (struct dctime*)nfp;
+ time_t t = nv_getn(np,nfp);
+ char *format = nv_getval(dp->format);
+ tmfmt(dp->buff,sizeof(dp->buff),format,(time_t*)0);
+ return(dp->buff);
+}
+
+static void put_time(Namval_t* np, const char* val, int flag, Namfun_t* nfp)
+{
+ struct dctime *dp = (struct dctime*)nfp;
+ char *last;
+ if(val)
+ {
+ int32_t t;
+ if(flag&NV_INTEGER)
+ {
+ if(flag&NV_LONG)
+ t = *(Sfdouble_t*)val;
+ else
+ t = *(double*)val;
+ }
+ else
+ {
+ t = tmdate(val, &last, (time_t*)0);
+ if(*last)
+ errormsg(SH_DICT, ERROR_exit(1),"%s: invalid date/time string", val);
+ }
+ nv_putv(np, (char*)&t,NV_INTEGER, nfp);
+ }
+ else
+ {
+ nv_unset(dp->format);
+ free((void*)dp->format);
+ nv_putv(np, val, flag, nfp);
+ }
+}
+
+static Namval_t *create_time(Namval_t *np, const char *name, int flags, Namfun_t *nfp)
+{
+ struct dctime *dp = (struct dctime*)nfp;
+ if(strcmp(name, "format"))
+ return((Namval_t*)0);
+ return(dp->format);
+}
+
+static const Namdisc_t timedisc =
+{
+ sizeof(struct dctime),
+ put_time,
+ get_time,
+ 0,
+ 0,
+ create_time,
+};
+
+
+static Namval_t *make_time(Namval_t* np)
+{
+ int offset = stktell(stkstd);
+ char *name = nv_name(np);
+ struct dctime *dp = newof(NULL,struct dctime,1,0);
+ if(!dp)
+ return((Namval_t*)0);
+ sfprintf(stkstd,"%s.format\0",name);
+ sfputc(stkstd,0);
+ dp->format = nv_search(stkptr(stkstd,offset),sh.var_tree,NV_ADD);
+ dp->fun.disc = &timedisc;
+ nv_stack(np,&dp->fun);
+ return(np);
+}
+
+/*
+ * mode formatting related
+*/
+static char *get_mode(Namval_t* np, Namfun_t* nfp)
+{
+ mode_t mode = nv_getn(np,nfp);
+ return(fmtperm(mode));
+}
+
+static void put_mode(Namval_t* np, const char* val, int flag, Namfun_t* nfp)
+{
+ if(val)
+ {
+ int32_t mode;
+ char *last;
+ if(flag&NV_INTEGER)
+ {
+ if(flag&NV_LONG)
+ mode = *(Sfdouble_t*)val;
+ else
+ mode = *(double*)val;
+ }
+ else
+ {
+ mode = strperm(val, &last,0);
+ if(*last)
+ errormsg(SH_DICT, ERROR_exit(1),"%s: invalid mode string", val);
+ }
+ nv_putv(np,(char*)&mode,NV_INTEGER,nfp);
+ }
+ else
+ nv_putv(np,val,flag,nfp);
+}
+
+static const Namdisc_t modedisc =
+{
+ 0,
+ put_mode,
+ get_mode,
+};
+
+static Namval_t *make_mode(Namval_t* np)
+{
+ char *name = nv_name(np);
+ Namfun_t *nfp = newof(NULL,Namfun_t,1,0);
+ if(!nfp)
+ return((Namval_t*)0);
+ nfp->disc = &modedisc;
+ nv_stack(np,nfp);
+ return(np);
+}
+
+/*
+ * field related typese and functions
+ */
+typedef struct _field_
+{
+ char *name; /* field name */
+ int flags; /* flags */
+ short offset; /* offset of field into data */
+ short size; /* size of field */
+ Namval_t *(*make)(Namval_t*); /* discipline constructor */
+} Shfield_t;
+
+/*
+ * lookup field in field table
+ */
+static Shfield_t *sh_findfield(Shfield_t *ftable, int nelem, const char *name)
+{
+ Shfield_t *fp = ftable;
+ register int i,n;
+ register const char *cp;
+ for(cp=name; *cp; cp++)
+ {
+ if(*cp=='.')
+ break;
+ }
+ n = cp-name;
+ for(i=0; i < nelem; i++,fp++)
+ {
+ if(memcmp(fp->name,name,n)==0 && fp->name[n]==0)
+ return(fp);
+ }
+ return(0);
+}
+
+/*
+ * class types and functions
+ */
+
+typedef struct _class_
+{
+ int nelem; /* number of elements */
+ int dsize; /* size for data structure */
+ Shfield_t *fields; /* field description table */
+} Shclass_t;
+
+struct dcclass
+{
+ Namfun_t fun;
+ Shclass_t sclass;
+};
+
+static Namval_t *sh_newnode(register Shfield_t *fp, Namval_t *np)
+{
+ char *val = np->nvalue + fp->offset;
+ char *name = nv_name(np);
+ register Namval_t *nq;
+ int offset = stktell(stkstd);
+ sfprintf(stkstd,"%s.%s\0",name,fp->name);
+ sfputc(stkstd,0);
+ nq = nv_search(stkptr(stkstd,offset),sh.var_tree,NV_ADD);
+ if(fp->size<0)
+ val = *(char**)val;
+ nv_putval(nq,val,fp->flags|NV_NOFREE);
+ if(fp->make)
+ (*fp->make)(nq);
+ return(nq);
+}
+
+static Namval_t *fieldcreate(Namval_t *np, const char *name, int flags, Namfun_t *nfp)
+{
+ struct dcclass *dcp = (struct dcclass*)nfp;
+ Shclass_t *sp = &dcp->sclass;
+ Shfield_t *fp = sh_findfield(sp->fields,sp->nelem,name);
+ Namval_t *nq,**nodes = (Namval_t**)(dcp+1);
+ int n = fp-sp->fields;
+ int len = strlen(fp->name);
+ void *data = (void*)np->nvalue;
+ if(!(nq=nodes[n]))
+ {
+ nodes[n] = nq = sh_newnode(fp,np);
+ nfp->last = "";
+ }
+ if(name[len]==0)
+ return(nq);
+ return(nq);
+}
+
+static void genvalue(Sfio_t *out, Shclass_t *sp, int indent, Namval_t *npar)
+{
+ Shfield_t *fp = sp->fields;
+ Namval_t *np, **nodes= (Namval_t**)(sp+1);
+ register int i,isarray;
+ if(out)
+ {
+ sfwrite(out,"(\n",2);
+ indent++;
+ }
+ for(i=0; i < sp->nelem; i++,fp++)
+ {
+#if 0
+ /* handle recursive case */
+#endif
+ if(!(np=nodes[i]) && out)
+ np = sh_newnode(fp,npar);
+ if(np)
+ {
+ isarray=0;
+ if(nv_isattr(np,NV_ARRAY))
+ {
+ isarray=1;
+ if(array_elem(nv_arrayptr(np))==0)
+ isarray=2;
+ else
+ nv_putsub(np,(char*)0,ARRAY_SCAN);
+ }
+ sfnputc(out,'\t',indent);
+ sfputr(out,fp->name,(isarray==2?'\n':'='));
+ if(isarray)
+ {
+ if(isarray==2)
+ continue;
+ sfwrite(out,"(\n",2);
+ sfnputc(out,'\t',++indent);
+ }
+ while(1)
+ {
+ char *fmtq;
+ if(isarray)
+ {
+ sfprintf(out,"[%s]",sh_fmtq(nv_getsub(np)));
+ sfputc(out,'=');
+ }
+ if(!(fmtq=nv_getval(np)) || !(fmtq=sh_fmtq(fmtq)))
+ fmtq = "";
+ sfputr(out,fmtq,'\n');
+ if(!nv_nextsub(np))
+ break;
+ sfnputc(out,'\t',indent);
+ }
+ if(isarray)
+ {
+ sfnputc(out,'\t',--indent);
+ sfwrite(out,")\n",2);
+ }
+ }
+ }
+ if(out)
+ {
+ if(indent>1)
+ sfnputc(out,'\t',indent-1);
+ sfputc(out,')');
+ }
+}
+
+static char *walk_class(register Namval_t *np, int dlete, struct dcclass *dcp)
+{
+ static Sfio_t *out;
+ Sfio_t *outfile;
+ int savtop = stktell(stkstd);
+ char *savptr = stkfreeze(stkstd,0);
+ if(dlete)
+ outfile = 0;
+ else if(!(outfile=out))
+ outfile = out = sfnew((Sfio_t*)0,(char*)0,-1,-1,SF_WRITE|SF_STRING);
+ else
+ sfseek(outfile,0L,SEEK_SET);
+ genvalue(outfile,&dcp->sclass,0,np);
+ stkset(stkstd,savptr,savtop);
+ if(!outfile)
+ return((char*)0);
+ sfputc(out,0);
+ return((char*)out->_data);
+}
+
+static char *get_classval(Namval_t* np, Namfun_t* nfp)
+{
+ return(walk_class(np,0,(struct dcclass *)nfp));
+}
+
+static void put_classval(Namval_t* np, const char* val, int flag, Namfun_t* nfp)
+{
+ walk_class(np,1,(struct dcclass *)nfp);
+ if(nfp = nv_stack(np,(Namfun_t*)0))
+ {
+ free((void*)nfp);
+ if(np->nvalue && !nv_isattr(np,NV_NOFREE))
+ free((void*)np->nvalue);
+ }
+ if(val)
+ nv_putval(np,val,flag);
+}
+
+static const Namdisc_t classdisc =
+{
+ sizeof(struct dcclass),
+ put_classval,
+ get_classval,
+ 0,
+ 0,
+ fieldcreate
+};
+
+static int mkclass(Namval_t *np, Shclass_t *sp)
+{
+ struct dcclass *tcp = newof(NULL,struct dcclass,1,sp->nelem*sizeof(Namval_t*));
+ if(!tcp)
+ return(0);
+ memset((void*)(tcp+1),0,sp->nelem*sizeof(Namval_t*));
+ tcp->fun.disc = &classdisc;
+ tcp->sclass = *sp;
+ np->nvalue = (char*)calloc(sp->dsize,1);
+ nv_stack(np,&tcp->fun);
+ return(1);
+}
+
+/*
+ * ====================from here down is file class specific
+ */
+static struct stat *Sp;
+
+struct filedata
+{
+ struct stat statb;
+ int fd;
+ char *name;
+};
+
+static Shfield_t filefield[] =
+{
+ { "atime", NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_atime), sizeof(Sp->st_atime), make_time},
+ { "ctime", NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_ctime), sizeof(Sp->st_ctime), make_time},
+ { "dev", NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_dev),sizeof(Sp->st_dev)},
+ { "fd", NV_INTEGER|NV_RDONLY, offsetof(struct filedata,fd), sizeof(int)},
+ { "gid", NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_gid), sizeof(Sp->st_gid)},
+ { "ino", NV_LONG|NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_ino), sizeof(Sp->st_ino)},
+ { "mode", NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_mode), sizeof(Sp->st_mode), make_mode},
+ { "mtime", NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_mtime), sizeof(Sp->st_mtime), make_time},
+ { "name", NV_RDONLY, offsetof(struct filedata,name), -1 },
+ { "nlink", NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_nlink), sizeof(Sp->st_nlink)},
+ { "size", NV_LONG|NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_size), sizeof(Sp->st_size)},
+ { "uid", NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_uid), sizeof(Sp->st_uid)}
+};
+
+static Shclass_t Fileclass =
+{
+ sizeof(filefield)/sizeof(*filefield),
+ sizeof(struct filedata),
+ filefield
+};
+
+
+#define letterbit(bit) (1<<((bit)-'a'))
+
+static const char sh_optopen[] =
+"[-?\n@(#)$Id: open (AT&T Labs Research) 2007-05-07 $\n]"
+"[-author?David Korn <dgk@research.att.com>]"
+"[-author?Roland Mainz <roland.mainz@nrubsig.org>]"
+"[-license?http://www.opensource.org/licenses/cpl1.0.txt]"
+"[+NAME? open - create a shell variable correspnding to a file]"
+"[+DESCRIPTION?\bopen\b creates the compound variable \avar\a correspinding "
+ "to the file given by the pathname \afile\a. The elements of \avar\a "
+ "are the names of elements in the \astat\a structure with the \bst_\b "
+ "prefix removed.]"
+"[+?\afile\a is opened (based on \b-r\b and/or \b-w\b) and the variable "
+ "\avar\a\b.fd\b is the file descriptor.]"
+"[a:append?Open for append.]"
+"[b:binary?Open in binary mode"
+#ifndef O_BINARY
+ " (not supported/ignored on this platform)"
+#endif
+ ".]"
+"[t:text?Open in text mode"
+#ifndef O_TEXT
+ " (not supported/ignored on this platform)"
+#endif
+ ".]"
+"[c:create?Open for create.]"
+"[i:inherit?Open without the close-on-exec bit set.]"
+"[I:noinherit?Open with the close-on-exec bit set.]"
+"[r:read?Open with read access.]"
+"[w:write?Open with write access.]"
+"[m:mode]:[mode:=rwrwrw?Open with access mode \amode\a.]"
+"[x:exclusive?Open exclusive.]"
+
+"[N:nofollow?If the path names a symbolic link, open fails with ELOOP "
+#ifndef O_NOFOLLOW
+ " (not supported/ignored on this platform)"
+#endif
+ ".]"
+"[S:sync?Write I/O operations on the file descriptor complete as "
+ "defined by synchronized I/O file integrity completion"
+#ifndef O_SYNC
+ " (not supported/ignored on this platform)"
+#endif
+ ".]"
+"[T:trunc?If the file exists and is a regular file, and the file "
+ "is successfully opened read/write or write-only, its length is "
+ "truncated to 0 and the mode and owner are unchanged. It "
+ "has no effect on FIFO special files or terminal device "
+ "files. Its effect on other file types is "
+ "implementation-dependent. The result of using -T "
+ "with read-only files is undefined"
+#ifndef O_TRUNC
+ " (not supported/ignored on this platform)"
+#endif
+ ".]"
+"\n"
+"\nvar file\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Success.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\btmpfile\b(1),\bdup\b(1),\bclose\b(1),\bstat\b(1),\bpoll\b(1),\bstat\b(2)]"
+;
+
+
+extern int b_open(int argc, char *argv[], void *extra)
+{
+ register Namval_t *np;
+ register int n,oflag=0;
+ Shell_t *shp = (Shell_t*)extra;
+ struct filedata *fdp;
+ mode_t mode = 0666;
+ long flags = 0;
+ int fd = -1;
+ char *arg;
+
+ while (n = optget(argv, sh_optopen)) switch (n)
+ {
+ case 'r':
+ case 'w':
+ case 'i':
+ flags |= letterbit(n);
+ break;
+ case 'I':
+ flags &= ~(letterbit('i'));
+ break;
+ case 'b':
+#ifdef O_BINARY
+ oflag |= O_BINARY;
+#endif
+ break;
+ case 't':
+#ifdef O_TEXT
+ oflag |= O_TEXT;
+#endif
+ break;
+ case 'N':
+#ifdef O_NOFOLLOW
+ oflag |= O_NOFOLLOW;
+#endif
+ break;
+ case 'T':
+#ifdef O_TRUNC
+ oflag |= O_TRUNC;
+#endif
+ break;
+ case 'x':
+ oflag |= O_EXCL;
+ break;
+ case 'c':
+ oflag |= O_CREAT;
+ break;
+ case 'a':
+ oflag |= O_APPEND;
+ break;
+ case 'S':
+#ifdef O_SYNC
+ oflag |= O_SYNC;
+#endif
+ break;
+ case 'm':
+ mode = strperm(arg = opt_info.arg, &opt_info.arg, mode);
+ if (*opt_info.arg)
+ errormsg(SH_DICT, ERROR_system(1), "%s: invalid mode", arg);
+ break;
+ case ':':
+ errormsg(SH_DICT, 2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT, ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argc -= opt_info.index;
+ argv += opt_info.index;
+ if(argc!=2 || !(flags&(letterbit('r')|letterbit('w'))))
+ errormsg(SH_DICT, ERROR_usage(2), optusage((char*)0));
+
+ if(flags&letterbit('r'))
+ {
+ if(flags&letterbit('w'))
+ oflag |= O_RDWR;
+ else
+ oflag |= O_RDONLY;
+ }
+ else if(flags&letterbit('w'))
+ oflag |= O_WRONLY;
+
+ fd = sh_open(argv[1], oflag, mode);
+ if(fd<0)
+ errormsg(SH_DICT, ERROR_system(1), "%s: open failed", argv[1]);
+
+ if(!(flags&letterbit('i')))
+ fcntl(fd, F_SETFL, 0);
+
+ np = nv_open(argv[0], shp->var_tree, NV_ARRAY|NV_VARNAME|NV_NOASSIGN);
+ if(!nv_isnull(np))
+ nv_unset(np);
+ mkclass(np, &Fileclass);
+ fdp = (struct filedata*)np->nvalue;
+ fstat(fd, &fdp->statb);
+ fdp->fd = fd;
+ fdp->name = strdup(argv[1]);
+ return(0);
+}
+
+static const char sh_optclose[] =
+"[-?\n@(#)$Id: close (AT&T Labs Research) 2007-04-21 $\n]"
+"[-author?Roland Mainz <roland.mainz@nrubsig.org>]"
+"[-license?http://www.opensource.org/licenses/cpl1.0.txt]"
+"[+NAME? close - close a file descriptor]"
+"[+DESCRIPTION?\bclose\b closes the file descriptor specified by fd.]"
+"\n"
+"\nfd\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Success.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bopen\b(1),\bdup\b(1),\btmpfile\b(1),\bpoll\b(1),\bstat\b(1)]"
+;
+
+extern int b_close(int argc, char *argv[], void *extra)
+{
+ register int n=0;
+ int fd = -1;
+
+ while (n = optget(argv, sh_optclose)) switch (n)
+ {
+ case ':':
+ errormsg(SH_DICT, 2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT, ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argc -= opt_info.index;
+ argv += opt_info.index;
+ if(argc!=1)
+ errormsg(SH_DICT, ERROR_usage(2), optusage((char*)0));
+
+ errno = 0;
+ fd = strtol(argv[0], (char **)NULL, 0);
+ if (errno != 0 || fd < 0)
+ errormsg(SH_DICT, ERROR_system(1), "%s: invalid descriptor", argv[0]);
+
+ n = sh_close(fd);
+
+ if (n < 0)
+ errormsg(SH_DICT, ERROR_system(1), "%s: close error", argv[0]);
+
+ return(n==0?0:1);
+}
+
+
+static const char sh_opttmpfile[] =
+"[-?\n@(#)$Id: tmpfile (AT&T Labs Research) 2007-05-07 $\n]"
+"[-author?Roland Mainz <roland.mainz@nrubsig.org>]"
+"[-license?http://www.opensource.org/licenses/cpl1.0.txt]"
+"[+NAME? tmpfile - create a shell variable correspnding to a temporary file]"
+"[+DESCRIPTION?\btmpfile\b creates the compound variable \avar\a correspinding "
+ "to a temporary file. The elements of \avar\a "
+ "are the names of elements in the \astat\a structure with the \bst_\b "
+ "prefix removed.]"
+"[i:inherit?Open without the close-on-exec bit set.]"
+"[I:noinherit?Open with the close-on-exec bit set.]"
+"\n"
+"\nvar\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Success.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bopen\b(1),\bdup\b(1),\bclose\b(1),\bstat\b(1),\bstat\b(2)]"
+;
+
+
+extern int b_tmpfile(int argc, char *argv[], void *extra)
+{
+ register Namval_t *np;
+ register int n;
+ Shell_t *shp = (Shell_t*)extra;
+ struct filedata *fdp;
+ int inherit = 0;
+ FILE *file = NULL;
+ int ffd, fd = -1;
+ while (n = optget(argv, sh_opttmpfile)) switch (n)
+ {
+ case 'i':
+ inherit = 1;
+ break;
+ case 'I':
+ inherit = 0;
+ break;
+ case ':':
+ errormsg(SH_DICT, 2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT, ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argc -= opt_info.index;
+ argv += opt_info.index;
+ if(argc!=1)
+ errormsg(SH_DICT, ERROR_usage(2), optusage((char*)0));
+
+ file = tmpfile();
+ if(!file)
+ errormsg(SH_DICT, ERROR_system(1), "%s: tmpfile failed", argv[1]);
+ ffd = fileno(file);
+ fd = sh_dup(ffd);
+ if(fd<0)
+ errormsg(SH_DICT, ERROR_system(1), "%s: tmpfile failed", argv[1]);
+ fclose(file);
+
+ if(!inherit)
+ fcntl(fd, F_SETFL, 0);
+
+ np = nv_open(argv[0], shp->var_tree, NV_ARRAY|NV_VARNAME|NV_NOASSIGN);
+ if(!nv_isnull(np))
+ nv_unset(np);
+ mkclass(np,&Fileclass);
+ fdp = (struct filedata*)np->nvalue;
+
+ fstat(fd, &fdp->statb);
+ fdp->fd = fd;
+ fdp->name = NULL;
+ return(0);
+}
+
+static const char sh_optdup[] =
+"[-?\n@(#)$Id: dup (AT&T Labs Research) 2007-05-07 $\n]"
+"[-author?Roland Mainz <roland.mainz@nrubsig.org>]"
+"[-license?http://www.opensource.org/licenses/cpl1.0.txt]"
+"[+NAME? dup - duplicate an open file descriptor]"
+"[+DESCRIPTION?The \bdup\b commands returns a new file descriptor having the "
+ "following in common with the original open file descriptor "
+ "fd: same open file (or pipe), same file pointer (that is, both file descriptors "
+ "share one file pointer) same access mode (read, write or read/write). "
+ "The file descriptor returned is the lowest one available.]"
+"[i:inherit?Open without the close-on-exec bit set.]"
+"[I:noinherit?Open with the close-on-exec bit set.]"
+"\n"
+"\nvar fd\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Success.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bopen\b(1),\btmpfile\b(1),\bclose\b(1),\bpoll\b(1),\bstat\b(1)]"
+;
+
+
+extern int b_dup(int argc, char *argv[], void *extra)
+{
+ register Namval_t *np;
+ register int n;
+ Shell_t *shp = (Shell_t*)extra;
+ struct filedata *fdp;
+ int inherit = 0;
+ int ffd, fd = -1;
+ while (n = optget(argv, sh_optdup)) switch (n)
+ {
+ case 'i':
+ inherit = 1;
+ break;
+ case 'I':
+ inherit = 0;
+ break;
+ case ':':
+ errormsg(SH_DICT, 2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT, ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argc -= opt_info.index;
+ argv += opt_info.index;
+ if(argc!=2)
+ errormsg(SH_DICT, ERROR_usage(2), optusage((char*)0));
+
+ errno = 0;
+ ffd = strtol(argv[1], (char **)NULL, 0);
+ if (errno != 0 || ffd < 0)
+ errormsg(SH_DICT, ERROR_system(1), "%s: invalid fd", argv[1]);
+
+ fd = sh_dup(ffd);
+ if(fd<0)
+ errormsg(SH_DICT, ERROR_system(1), "%s: dup failed", argv[1]);
+
+ if(!inherit)
+ fcntl(fd,F_SETFL,0);
+
+ np = nv_open(argv[0],shp->var_tree,NV_ARRAY|NV_VARNAME|NV_NOASSIGN);
+ if(!nv_isnull(np))
+ nv_unset(np);
+ mkclass(np, &Fileclass);
+ fdp = (struct filedata*)np->nvalue;
+
+ fstat(fd, &fdp->statb);
+ fdp->fd = fd;
+ fdp->name = NULL;
+ return(0);
+}
+
+static const char sh_optstat[] =
+"[-?\n@(#)$Id: stat (AT&T Labs Research) 2007-05-07 $\n]"
+"[-author?David Korn <dgk@research.att.com>]"
+"[-author?Roland Mainz <roland.mainz@nrubsig.org>]"
+"[-license?http://www.opensource.org/licenses/cpl1.0.txt]"
+"[+NAME? stat - get file status]"
+"[+DESCRIPTION?\bstat\b creates the compound variable \avar\a correspinding "
+ "to the file given by the pathname \afile\a. The elements of \avar\a "
+ "are the names of elements in the \astat\a structure with the \bst_\b "
+ "prefix removed.]"
+"[l:lstat?If the the named file is a symbolic link returns information about "
+ "the link itself.]"
+"\n"
+"\nvar file\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Success.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bopen\b(1),\btmpfile\b(1),\bdup\b(1),\bclose\b(1),\bpoll\b(1),\bstat\b(2),\blstat\b(2)]"
+;
+
+
+extern int b_stat(int argc, char *argv[], void *extra)
+{
+ register Namval_t *np;
+ register int n;
+ Shell_t *shp = (Shell_t*)extra;
+ struct filedata *fdp;
+ long flags = 0;
+ struct stat statb;
+ while (n = optget(argv, sh_optstat)) switch (n)
+ {
+ case 'l':
+ flags |= letterbit(n);
+ break;
+ case ':':
+ errormsg(SH_DICT, 2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT, ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argc -= opt_info.index;
+ argv += opt_info.index;
+ if(argc!=2)
+ errormsg(SH_DICT, ERROR_usage(2), optusage((char*)0));
+
+ if(flags&letterbit('l'))
+ {
+ if(lstat(argv[1], &statb) < 0)
+ errormsg(SH_DICT, ERROR_system(1), "%s: stat failed", argv[1]);
+ }
+ else
+ {
+ if(stat(argv[1], &statb) < 0)
+ errormsg(SH_DICT, ERROR_system(1), "%s: stat failed", argv[1]);
+
+ }
+
+ np = nv_open(argv[0],shp->var_tree,NV_ARRAY|NV_VARNAME|NV_NOASSIGN);
+ if(!nv_isnull(np))
+ nv_unset(np);
+ mkclass(np,&Fileclass);
+ fdp = (struct filedata*)np->nvalue;
+ fdp->statb = statb;
+ fdp->fd = -1;
+ fdp->name = strdup(argv[1]);
+ return(0);
+}
+
+static const char sh_optpoll[] =
+"[-?\n@(#)$Id: poll (AT&T Labs Research) 2007-05-07 $\n]"
+"[-author?Roland Mainz <roland.mainz@nrubsig.org]"
+"[-license?http://www.opensource.org/licenses/cpl1.0.txt]"
+"[+NAME? poll - input/output multiplexing]"
+"[+DESCRIPTION?The poll command provides applications with a mechanism "
+ "for multiplexing input/output over a set of file descriptors. "
+ "For each member of the array variable \bvar\b, "
+ "poll examines the given file descriptor in the subscript \b.fd\b "
+ "for the event(s) specified in the subscript \b.events\b."
+ "The poll command identifies those file descriptors on which an "
+ "application can read or write data, or on which certain events have "
+ "occurred.]"
+"[+?The \bvar\b argument specifies the file descriptors to be examined "
+ "and the events of interest for each file descriptor. "
+ "It is a array of structured variables with one member for each open "
+ "file descriptor of interest. The array's members contain the following "
+ "subscripts:]{"
+ "[+?\b.fd\b # file descriptor]"
+ "[+?\b.events\b # requested events]"
+ "[+?\b.revents\b # returned event]"
+ "}"
+"[+?The \bfd\b variable specifies an open file descriptor and the "
+ "\bevents\b and \brevents\b members are strings constructed from "
+ "a concaternation of the following event flags, seperated by '|':]"
+ "{ "
+ "[+POLLIN?Data other than high priority data may be "
+ "read without blocking. For STREAMS, this "
+ "flag is set in revents even if the message "
+ "is of zero length.]"
+ "[+POLLRDNORM?Normal data (priority band equals 0) may be "
+ "read without blocking. For STREAMS, this "
+ "flag is set in revents even if the message "
+ "is of zero length.]"
+ "[+POLLRDBAND?Data from a non-zero priority band may be "
+ "read without blocking. For STREAMS, this "
+ "flag is set in revents even if the message "
+ "is of zero length.]"
+ "[+POLLPRI?High priority data may be received without "
+ "blocking. For STREAMS, this flag is set in "
+ "revents even if the message is of zero "
+ "length.]"
+ "[+POLLOUT?Normal data (priority band equals 0) may be "
+ "written without blocking.]"
+ "[+POLLWRNORM?The same as POLLOUT.]"
+ "[+POLLWRBAND?Priority data (priority band > 0) may be "
+ "written. This event only examines bands "
+ "that have been written to at least once.]"
+ "[+POLLERR?An error has occurred on the device or "
+ "stream. This flag is only valid in the "
+ "revents bitmask; it is not used in the "
+ "events member.]"
+ "[+POLLHUP?A hangup has occurred on the stream. This "
+ "event and POLLOUT are mutually exclusive; a "
+ "stream can never be writable if a hangup has "
+ "occurred. However, this event and POLLIN, "
+ ", POLLRDBAND, or POLLPRI are not "
+ "mutually exclusive. This flag is only valid "
+ "in the revents bitmask; it is not used in "
+ "the events member.]"
+ "[+POLLNVAL?The specified fd value does not belong to an "
+ "open file. This flag is only valid in the "
+ "revents member; it is not used in the events "
+ "member.]"
+ "}"
+"]"
+
+"[+?If the value fd is less than 0, events is ignored and "
+ "revents is set to 0 in that entry on return from poll.]"
+
+"[+?The results of the poll query are stored in the revents "
+ "member in the \bvar\b structure. POLL*-strings are set in the \brevents\b "
+ "variable to indicate which of the requested events are true. "
+ "If none are true, the \brevents\b will be an empty string when "
+ "the poll command returns. The event flags "
+ "POLLHUP, POLLERR, and POLLNVAL are always set in \brevents\b "
+ "if the conditions they indicate are true; this occurs even "
+ "though these flags were not present in events.]"
+
+"[+?If none of the defined events have occurred on any selected "
+ "file descriptor, poll waits at least timeout milliseconds "
+ "for an event to occur on any of the selected file descriptors. "
+ "On a computer where millisecond timing accuracy is not "
+ "available, timeout is rounded up to the nearest legal value "
+ "available on that system. If the value timeout is 0, poll "
+ "returns immediately. If the value of timeout is -1, poll "
+ "blocks until a requested event occurs or until the call is "
+ "interrupted.]"
+
+"[+?The poll function supports regular files, terminal and "
+ "pseudo-terminal devices, STREAMS-based files, FIFOs and "
+ "pipes. The behavior of poll on elements of fds that refer "
+ "to other types of file is unspecified.]"
+
+"[+?The poll function supports sockets.]"
+
+"[+?A file descriptor for a socket that is listening for connections "
+ "will indicate that it is ready for reading, once connections "
+ "are available. A file descriptor for a socket that "
+ "is connecting asynchronously will indicate that it is ready "
+ "for writing, once a connection has been established.]"
+
+"[+?Regular files always poll TRUE for reading and writing.]"
+
+"[t:timeout]:[milliseconds?Timeout in milliseconds. If the value timeout is 0, "
+ "poll returns immediately. If the value of timeout is -1, poll "
+ "blocks until a requested event occurs or until the call is "
+ "interrupted.]"
+"\n"
+"\nvar\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Success.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bopen\b(1),\btmpfile\b(1),\bdup\b(1),\bclose\b(1),\bpoll\b(2)]"
+;
+
+/*
+ * |mystpcpy| - like |strcpy()| but returns the end of the buffer
+ *
+ * Copy string s2 to s1. s1 must be large enough.
+ * return s1-1 (position of string terminator ('\0') in destnation buffer).
+ */
+static
+char *mystpcpy(char *s1, const char *s2)
+{
+ while (*s1++ = *s2++)
+ ;
+ return (s1-1);
+}
+
+static
+Namval_t *nv_open_fmt(Dt_t *dict, int flags, const char *namefmt, ...)
+{
+ char varnamebuff[PATH_MAX];
+ va_list ap;
+
+ va_start(ap, namefmt);
+ vsnprintf(varnamebuff, sizeof(varnamebuff), namefmt, ap);
+ va_end(ap);
+
+ return nv_open(varnamebuff, dict, flags);
+}
+
+static
+int poll_strtoevents(const char *str)
+{
+ int events = 0;
+
+ if (strstr(str, "POLLIN")) events |= POLLIN;
+ if (strstr(str, "POLLRDNORM")) events |= POLLRDNORM;
+ if (strstr(str, "POLLRDBAND")) events |= POLLRDBAND;
+ if (strstr(str, "POLLPRI")) events |= POLLPRI;
+ if (strstr(str, "POLLOUT")) events |= POLLOUT;
+ if (strstr(str, "POLLWRNORM")) events |= POLLWRNORM;
+ if (strstr(str, "POLLWRBAND")) events |= POLLWRBAND;
+ if (strstr(str, "POLLERR")) events |= POLLERR;
+ if (strstr(str, "POLLHUP")) events |= POLLHUP;
+ if (strstr(str, "POLLNVAL")) events |= POLLNVAL;
+
+ return events;
+}
+
+
+static
+void poll_eventstostr(char *s, int events)
+{
+ *s='\0';
+ if (!events)
+ return;
+
+ if (events & POLLIN) s=mystpcpy(s, "POLLIN|");
+ if (events & POLLRDNORM) s=mystpcpy(s, "POLLRDNORM|");
+ if (events & POLLRDBAND) s=mystpcpy(s, "POLLRDBAND|");
+ if (events & POLLPRI) s=mystpcpy(s, "POLLPRI|");
+ if (events & POLLOUT) s=mystpcpy(s, "POLLOUT|");
+ if (events & POLLWRNORM) s=mystpcpy(s, "POLLWRNORM|");
+ if (events & POLLWRBAND) s=mystpcpy(s, "POLLWRBAND|");
+ if (events & POLLERR) s=mystpcpy(s, "POLLERR|");
+ if (events & POLLHUP) s=mystpcpy(s, "POLLHUP|");
+ if (events & POLLNVAL) s=mystpcpy(s, "POLLNVAL|");
+
+ /* Remove trailling '|' */
+ s--;
+ if(*s=='|')
+ *s='\0';
+}
+
+extern int b_poll(int argc, char *argv[], void *extra)
+{
+ register Namval_t *np;
+ register int n;
+ Shell_t *shp = (Shell_t*)extra;
+ char *varname;
+ int fd;
+/* |BPOLL_MAX| needs to be larger than |OPEN_MAX| to make sure we
+ * can listen to different sets of events per fd.
+ */
+#define BPOLL_MAX 512
+ struct pollfd pollfd[BPOLL_MAX];
+ unsigned int numpollfd = 0;
+ int i;
+ char *s;
+ long timeout = -1;
+ char buff[256];
+
+ while (n = optget(argv, sh_optpoll)) switch (n)
+ {
+ case 't':
+ errno = 0;
+ timeout = strtol(opt_info.arg, (char **)NULL, 0);
+ if (errno != 0)
+ errormsg(SH_DICT, ERROR_system(1), "%s: invalid timeout", opt_info.arg);
+ break;
+ case ':':
+ errormsg(SH_DICT, 2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT, ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argc -= opt_info.index;
+ argv += opt_info.index;
+ if(argc!=1)
+ errormsg(SH_DICT, ERROR_usage(2), optusage((char*)0));
+
+ varname = argv[0];
+
+ for(i=0 ; i < BPOLL_MAX ; i++)
+ {
+ np = nv_open_fmt(shp->var_tree, NV_ARRAY|NV_VARNAME|NV_NOASSIGN|NV_NOFAIL|NV_NOADD, "%s[%d].fd", varname, i);
+ if (!np)
+ break;
+ fd = (int)nv_getnum(np);
+ if (fd < 0 || fd > OPEN_MAX)
+ errormsg(SH_DICT, ERROR_system(1), "poll: invalid pollfd fd");
+ nv_close(np);
+ pollfd[i].fd = fd;
+
+ np = nv_open_fmt(shp->var_tree, NV_ARRAY|NV_VARNAME|NV_NOASSIGN|NV_NOFAIL|NV_NOADD, "%s[%d].events", varname, i);
+ if (!s)
+ errormsg(SH_DICT, ERROR_system(1), "poll: missing pollfd events");
+
+ s = nv_getval(np);
+ if (!s)
+ errormsg(SH_DICT, ERROR_system(1), "poll: missing pollfd events value");
+ pollfd[i].events = poll_strtoevents(s);
+ nv_close(np);
+
+ pollfd[i].revents = 0;
+
+ numpollfd++;
+ }
+
+ if (i == BPOLL_MAX)
+ errormsg(SH_DICT, ERROR_system(1), "poll: cannot handle more than %d entries.", BPOLL_MAX);
+
+ n = poll(pollfd, numpollfd, timeout);
+ /* FixMe: EGAIN and EINTR may require extra handling */
+ if (n < 0)
+ errormsg(SH_DICT, ERROR_system(1), "poll: failure");
+
+ for(i=0 ; i < numpollfd ; i++)
+ {
+ np = nv_open_fmt(shp->var_tree, NV_ARRAY|NV_VARNAME|NV_NOASSIGN|NV_NOFAIL, "%s[%d].revents", varname, i);
+ if (!np)
+ errormsg(SH_DICT, ERROR_system(1), "poll: couldn't create pollfd %s[%d].revents", varname, i);
+
+ poll_eventstostr(buff, pollfd[i].revents);
+
+ nv_putval(np, buff, 0);
+ nv_close(np);
+ }
+
+ return(0);
+}
+
+static const char sh_optrewind[] =
+"[-?\n@(#)$Id: rewind (AT&T Labs Research) 2007-05-07 $\n]"
+"[-author?Roland Mainz <roland.mainz@nrubsig.org>]"
+"[-license?http://www.opensource.org/licenses/cpl1.0.txt]"
+"[+NAME? rewind - reset file position indicator in a stream]"
+"[+DESCRIPTION?The \brewind\b command will move the file pointer of fd to position 0.]"
+"\n"
+"\nfd\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Success.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bopen\b(1),\btmpfile\b(1),\bdup\b(1),\bclose\b(1),\bstat\b(1),\bstat\b(2)]"
+;
+
+
+extern int b_rewind(int argc, char *argv[], void *extra)
+{
+ Shell_t *shp = (Shell_t*)extra;
+ int fd = -1;
+ register int n;
+ while (n = optget(argv, sh_optrewind)) switch (n)
+ {
+ case ':':
+ errormsg(SH_DICT, 2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT, ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argc -= opt_info.index;
+ argv += opt_info.index;
+ if(argc!=1)
+ errormsg(SH_DICT, ERROR_usage(2), optusage((char*)0));
+
+ errno = 0;
+ fd = strtol(argv[0], (char **)NULL, 0);
+ if (errno != 0 || fd < 0)
+ errormsg(SH_DICT, ERROR_system(1), "%s: invalid fd", argv[0]);
+
+ if (sh_seek(fd, 0, SEEK_SET) == (off_t)-1)
+ errormsg(SH_DICT, ERROR_system(1), "seek error");
+
+ return(0);
+}
+
diff --git a/usr/src/lib/libshell/common/bltins/shopen.c b/usr/src/lib/libshell/common/bltins/shopen.c
new file mode 100644
index 0000000000..6a7a85a990
--- /dev/null
+++ b/usr/src/lib/libshell/common/bltins/shopen.c
@@ -0,0 +1,533 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+static const char id[] = "\n@(#)$Id: open (AT&T Research) 1998-07-07 $\0\n";
+
+#include <shell.h>
+#include <option.h>
+#include <stk.h>
+#include <tm.h>
+#ifndef SH_DICT
+# define SH_DICT "libshell"
+#endif
+
+/*
+ * time formatting related
+*/
+struct dctime
+{
+ Namfun_t fun;
+ Namval_t *format;
+};
+
+static char *get_time(Namval_t* np, Namfun_t* nfp)
+{
+ static char buff[256];
+ struct dctime *dp = (struct dctime*)nfp;
+ time_t t = nv_getn(np,nfp);
+ char *format = nv_getval(dp->format);
+ tmfmt(buff,sizeof(buff),format,(time_t*)0);
+ return(buff);
+}
+
+static void put_time(Namval_t* np, const char* val, int flag, Namfun_t* nfp)
+{
+ struct dctime *dp = (struct dctime*)nfp;
+ char *last;
+ if(val)
+ {
+ int32_t t;
+ if(flag&NV_INTEGER)
+ {
+ if(flag&NV_LONG)
+ t = *(Sfdouble_t*)val;
+ else
+ t = *(double*)val;
+ }
+ else
+ {
+ t = tmdate(val, &last, (time_t*)0);
+ if(*last)
+ errormsg(SH_DICT,ERROR_exit(1),"%s: invalid date/time string",val);
+ }
+ nv_putv(np,(char*)&t,NV_INTEGER,nfp);
+ }
+ else
+ {
+ nv_unset(dp->format);
+ free((void*)dp->format);
+ nv_putv(np,val,flag,nfp);
+ }
+}
+
+static Namval_t *create_time(Namval_t *np, const char *name, int flags, Namfun_t *nfp)
+{
+ struct dctime *dp = (struct dctime*)nfp;
+ if(strcmp(name,"format"))
+ return((Namval_t*)0);
+ return(dp->format);
+}
+
+static const Namdisc_t timedisc =
+{
+ sizeof(struct dctime),
+ put_time,
+ get_time,
+ 0,
+ 0,
+ create_time,
+};
+
+
+static Namval_t *make_time(Namval_t* np)
+{
+ int offset = stktell(stkstd);
+ char *name = nv_name(np);
+ struct dctime *dp = newof(NULL,struct dctime,1,0);
+ if(!dp)
+ return((Namval_t*)0);
+ sfprintf(stkstd,"%s.format\0",name);
+ sfputc(stkstd,0);
+ dp->format = nv_search(stkptr(stkstd,offset),sh.var_tree,NV_ADD);
+ dp->fun.disc = &timedisc;
+ nv_stack(np,&dp->fun);
+ return(np);
+}
+
+/*
+ * mode formatting related
+*/
+static char *get_mode(Namval_t* np, Namfun_t* nfp)
+{
+ mode_t mode = nv_getn(np,nfp);
+ return(fmtperm(mode));
+}
+
+static void put_mode(Namval_t* np, const char* val, int flag, Namfun_t* nfp)
+{
+ if(val)
+ {
+ int32_t mode;
+ char *last;
+ if(flag&NV_INTEGER)
+ {
+ if(flag&NV_LONG)
+ mode = *(Sfdouble_t*)val;
+ else
+ mode = *(double*)val;
+ }
+ else
+ {
+ mode = strperm(val, &last,0);
+ if(*last)
+ errormsg(SH_DICT,ERROR_exit(1),"%s: invalid mode string",val);
+ }
+ nv_putv(np,(char*)&mode,NV_INTEGER,nfp);
+ }
+ else
+ nv_putv(np,val,flag,nfp);
+}
+
+static const Namdisc_t modedisc =
+{
+ 0,
+ put_mode,
+ get_mode,
+};
+
+static Namval_t *make_mode(Namval_t* np)
+{
+ char *name = nv_name(np);
+ Namfun_t *nfp = newof(NULL,Namfun_t,1,0);
+ if(!nfp)
+ return((Namval_t*)0);
+ nfp->disc = &modedisc;
+ nv_stack(np,nfp);
+ return(np);
+}
+
+/*
+ * field related typese and functions
+ */
+typedef struct _field_
+{
+ char *name; /* field name */
+ int flags; /* flags */
+ short offset; /* offset of field into data */
+ short size; /* size of field */
+ Namval_t *(*make)(Namval_t*); /* discipline constructor */
+} Shfield_t;
+
+/*
+ * lookup field in field table
+ */
+static Shfield_t *sh_findfield(Shfield_t *ftable, int nelem, const char *name)
+{
+ Shfield_t *fp = ftable;
+ register int i,n;
+ register const char *cp;
+ for(cp=name; *cp; cp++)
+ {
+ if(*cp=='.')
+ break;
+ }
+ n = cp-name;
+ for(i=0; i < nelem; i++,fp++)
+ {
+ if(memcmp(fp->name,name,n)==0 && fp->name[n]==0)
+ return(fp);
+ }
+ return(0);
+}
+
+/*
+ * class types and functions
+ */
+
+typedef struct _class_
+{
+ int nelem; /* number of elements */
+ int dsize; /* size for data structure */
+ Shfield_t *fields; /* field description table */
+} Shclass_t;
+
+struct dcclass
+{
+ Namfun_t fun;
+ Shclass_t sclass;
+};
+
+static Namval_t *sh_newnode(register Shfield_t *fp, Namval_t *np)
+{
+ char *val = np->nvalue + fp->offset;
+ char *name = nv_name(np);
+ register Namval_t *nq;
+ int offset = stktell(stkstd);
+ sfprintf(stkstd,"%s.%s\0",name,fp->name);
+ sfputc(stkstd,0);
+ nq = nv_search(stkptr(stkstd,offset),sh.var_tree,NV_ADD);
+ if(fp->size<0)
+ val = *(char**)val;
+ nv_putval(nq,val,fp->flags|NV_NOFREE);
+ if(fp->make)
+ (*fp->make)(nq);
+ return(nq);
+}
+
+static Namval_t *fieldcreate(Namval_t *np, const char *name, int flags, Namfun_t *nfp)
+{
+ struct dcclass *dcp = (struct dcclass*)nfp;
+ Shclass_t *sp = &dcp->sclass;
+ Shfield_t *fp = sh_findfield(sp->fields,sp->nelem,name);
+ Namval_t *nq,**nodes = (Namval_t**)(dcp+1);
+ int n = fp-sp->fields;
+ int len = strlen(fp->name);
+ void *data = (void*)np->nvalue;
+ if(!(nq=nodes[n]))
+ {
+ nodes[n] = nq = sh_newnode(fp,np);
+ nfp->last = "";
+ }
+ if(name[len]==0)
+ return(nq);
+ return(nq);
+}
+
+static void genvalue(Sfio_t *out, Shclass_t *sp, int indent, Namval_t *npar)
+{
+ Shfield_t *fp = sp->fields;
+ Namval_t *np, **nodes= (Namval_t**)(sp+1);
+ register int i,isarray;
+ if(out)
+ {
+ sfwrite(out,"(\n",2);
+ indent++;
+ }
+ for(i=0; i < sp->nelem; i++,fp++)
+ {
+#if 0
+ /* handle recursive case */
+#endif
+ if(!(np=nodes[i]) && out)
+ np = sh_newnode(fp,npar);
+ if(np)
+ {
+ isarray=0;
+ if(nv_isattr(np,NV_ARRAY))
+ {
+ isarray=1;
+ if(array_elem(nv_arrayptr(np))==0)
+ isarray=2;
+ else
+ nv_putsub(np,(char*)0,ARRAY_SCAN);
+ }
+ sfnputc(out,'\t',indent);
+ sfputr(out,fp->name,(isarray==2?'\n':'='));
+ if(isarray)
+ {
+ if(isarray==2)
+ continue;
+ sfwrite(out,"(\n",2);
+ sfnputc(out,'\t',++indent);
+ }
+ while(1)
+ {
+ char *fmtq;
+ if(isarray)
+ {
+ sfprintf(out,"[%s]",sh_fmtq(nv_getsub(np)));
+ sfputc(out,'=');
+ }
+ if(!(fmtq=nv_getval(np)) || !(fmtq=sh_fmtq(fmtq)))
+ fmtq = "";
+ sfputr(out,fmtq,'\n');
+ if(!nv_nextsub(np))
+ break;
+ sfnputc(out,'\t',indent);
+ }
+ if(isarray)
+ {
+ sfnputc(out,'\t',--indent);
+ sfwrite(out,")\n",2);
+ }
+ }
+ }
+ if(out)
+ {
+ if(indent>1)
+ sfnputc(out,'\t',indent-1);
+ sfputc(out,')');
+ }
+}
+
+static char *walk_class(register Namval_t *np, int dlete, struct dcclass *dcp)
+{
+ static Sfio_t *out;
+ Sfio_t *outfile;
+ int savtop = stktell(stkstd);
+ char *savptr = stkfreeze(stkstd,0);
+ if(dlete)
+ outfile = 0;
+ else if(!(outfile=out))
+ outfile = out = sfnew((Sfio_t*)0,(char*)0,-1,-1,SF_WRITE|SF_STRING);
+ else
+ sfseek(outfile,0L,SEEK_SET);
+ genvalue(outfile,&dcp->sclass,0,np);
+ stkset(stkstd,savptr,savtop);
+ if(!outfile)
+ return((char*)0);
+ sfputc(out,0);
+ return((char*)out->_data);
+}
+
+static char *get_classval(Namval_t* np, Namfun_t* nfp)
+{
+ return(walk_class(np,0,(struct dcclass *)nfp));
+}
+
+static void put_classval(Namval_t* np, const char* val, int flag, Namfun_t* nfp)
+{
+ walk_class(np,1,(struct dcclass *)nfp);
+ if(nfp = nv_stack(np,(Namfun_t*)0))
+ {
+ free((void*)nfp);
+ if(np->nvalue && !nv_isattr(np,NV_NOFREE))
+ free((void*)np->nvalue);
+ }
+ if(val)
+ nv_putval(np,val,flag);
+}
+
+static const Namdisc_t classdisc =
+{
+ sizeof(struct dcclass),
+ put_classval,
+ get_classval,
+ 0,
+ 0,
+ fieldcreate
+};
+
+static int mkclass(Namval_t *np, Shclass_t *sp)
+{
+ struct dcclass *tcp = newof(NULL,struct dcclass,1,sp->nelem*sizeof(Namval_t*));
+ if(!tcp)
+ return(0);
+ memset((void*)(tcp+1),0,sp->nelem*sizeof(Namval_t*));
+ tcp->fun.disc = &classdisc;
+ tcp->sclass = *sp;
+ np->nvalue = (char*)calloc(sp->dsize,1);
+ nv_stack(np,&tcp->fun);
+ return(1);
+}
+
+/*
+ * ====================from here down is file class specific
+ */
+static struct stat *Sp;
+
+struct filedata
+{
+ struct stat statb;
+ int fd;
+ char *name;
+};
+
+static Shfield_t filefield[] =
+{
+ { "atime", NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_atime), sizeof(Sp->st_atime), make_time},
+ { "ctime", NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_ctime), sizeof(Sp->st_ctime), make_time},
+ { "dev", NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_dev),sizeof(Sp->st_dev)},
+ { "fd", NV_INTEGER|NV_RDONLY, offsetof(struct filedata,fd), sizeof(int)},
+ { "gid", NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_gid), sizeof(Sp->st_gid)},
+ { "ino", NV_LONG|NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_ino), sizeof(Sp->st_ino)},
+ { "mode", NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_mode), sizeof(Sp->st_mode), make_mode},
+ { "mtime", NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_mtime), sizeof(Sp->st_mtime), make_time},
+ { "name", NV_RDONLY, offsetof(struct filedata,name), -1 },
+ { "nlink", NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_nlink), sizeof(Sp->st_nlink)},
+ { "size", NV_LONG|NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_size), sizeof(Sp->st_size)},
+ { "uid", NV_INTEGER|NV_RDONLY, offsetof(struct stat,st_uid), sizeof(Sp->st_uid)}
+};
+
+static Shclass_t Fileclass =
+{
+ sizeof(filefield)/sizeof(*filefield),
+ sizeof(struct filedata),
+ filefield
+};
+
+
+#define letterbit(bit) (1<<((bit)-'a'))
+
+static const char sh_optopen[] =
+"[-?\n@(#)$Id: open (AT&T Labs Research) 2007-03-11 $\n]"
+"[-author?David Korn <dgk@research.att.com>]"
+"[-license?http://www.opensource.org/licenses/cpl1.0.txt]"
+"[+NAME? open - create a shell variable correspnding to a file]"
+"[+DESCRIPTION?\bopen\b creates the compound variable \avar\a correspinding "
+ "to the file given by the pathname \afile\a. The elements of \avar\a "
+ "are the names of elements in the \astat\a structure with the \bst_\b "
+ "prefix removed.]"
+"[+?If the \b-r\b and/or \b-w\b mode is specified, then \afile\a is opened and "
+ "the variable \avar\a\b.fd\b is the file descriptor.]"
+"[a:append?Open for append.]"
+"[b:binary?Open in binary mode.]"
+"[c:create?Open for create.]"
+"[i:inherit?Open without the close-on-exec bit set.]"
+"[r:read?Open with read access.]"
+"[w:write?Open with write access.]"
+"[m:mode]:[mode:=rwrwrw?Open with access mode \amode\a.]"
+"[x:exclusive?Open exclusive.]"
+"\n"
+"\nvar file\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Success.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bstat\b(2)]"
+;
+
+
+extern int b_open(int argc, char *argv[], void *extra)
+{
+ register Namval_t *np;
+ register int n,oflag=0;
+ Shell_t *shp = (Shell_t*)extra;
+ struct filedata *fdp;
+ struct stat statb;
+ mode_t mode = 0666;
+ long flags = 0;
+ int fd = -1;
+ while (n = optget(argv, sh_optopen)) switch (n)
+ {
+ case 'r':
+ case 'i':
+ case 'w':
+ flags |= letterbit(n);
+ break;
+ case 'b':
+#ifdef O_BINARY
+ oflag |= O_BINARY;
+#endif
+ break;
+ case 't':
+#ifdef O_TEXT
+ oflag |= O_TEXT;
+#endif
+ break;
+ case 'x':
+ oflag |= O_EXCL;
+ break;
+ case 'c':
+ oflag |= O_CREAT;
+ break;
+ case 'a':
+ oflag |= O_APPEND;
+ break;
+ case 'm':
+ break;
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argc -= opt_info.index;
+ argv += opt_info.index;
+ if(argc!=2)
+ errormsg(SH_DICT,ERROR_usage(2),optusage((char*)0));
+ if(!(flags&(letterbit('r')|letterbit('w'))))
+ {
+ if(stat(argv[1],&statb)<0)
+ errormsg(SH_DICT,ERROR_system(1),"%s: open failed",argv[1]);
+ }
+ else
+ {
+ if(flags&letterbit('r'))
+ {
+ if(flags&letterbit('w'))
+ oflag |= O_RDWR;
+ else
+ oflag |= O_RDONLY;
+ }
+ else if(flags&letterbit('w'))
+ oflag |= O_WRONLY;
+ fd = open(argv[1],oflag,mode);
+ if(fd<0)
+ errormsg(SH_DICT,ERROR_system(1),"%s: open failed",argv[1]);
+ }
+ if(!(flags&letterbit('i')))
+ fcntl(fd,F_SETFL,0);
+ np = nv_open(argv[0],shp->var_tree,NV_ARRAY|NV_VARNAME|NV_NOASSIGN);
+ if(!nv_isnull(np))
+ nv_unset(np);
+ mkclass(np,&Fileclass);
+ fdp = (struct filedata*)np->nvalue;
+ if(!(flags&(letterbit('r')|letterbit('w'))))
+ fdp->statb = statb;
+ else
+ fstat(fd,&fdp->statb);
+ fdp->fd = fd;
+ fdp->name = strdup(argv[1]);
+ return(0);
+}
diff --git a/usr/src/lib/libshell/common/bltins/sleep.c b/usr/src/lib/libshell/common/bltins/sleep.c
new file mode 100644
index 0000000000..2f52ca651c
--- /dev/null
+++ b/usr/src/lib/libshell/common/bltins/sleep.c
@@ -0,0 +1,190 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * sleep delay
+ *
+ * David Korn
+ * AT&T Labs
+ * research!dgk
+ *
+ */
+
+#define sleep ______sleep
+#include "defs.h"
+#undef sleep
+#include <error.h>
+#include <errno.h>
+#include "builtins.h"
+#include "FEATURE/time"
+#include "FEATURE/poll"
+#ifdef _NEXT_SOURCE
+# define sleep _ast_sleep
+#endif /* _NEXT_SOURCE */
+#ifdef _lib_poll_notimer
+# undef _lib_poll
+#endif /* _lib_poll_notimer */
+
+int b_sleep(register int argc,char *argv[],void *extra)
+{
+ register char *cp;
+ register double d;
+ register Shell_t *shp = (Shell_t*)extra;
+ time_t tloc = 0;
+ while((argc = optget(argv,sh_optsleep))) switch(argc)
+ {
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ if(error_info.errors || !(cp= *argv) || !(strmatch(cp,e_numeric)))
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+ if((d=strtod(cp, (char**)0)) > .10)
+ {
+ sfsync(shp->outpool);
+ time(&tloc);
+ tloc += (time_t)(d+.5);
+ }
+ while(1)
+ {
+ time_t now;
+ errno = 0;
+ shp->lastsig=0;
+ sh_delay(d);
+ if(tloc==0 || errno!=EINTR || shp->lastsig)
+ break;
+ sh_sigcheck();
+ if(tloc < (now=time(NIL(time_t*))))
+ break;
+ d = (double)(tloc-now);
+ if(shp->sigflag[SIGALRM]&SH_SIGTRAP)
+ sh_timetraps();
+ }
+ return(0);
+}
+
+static void completed(void * handle)
+{
+ char *expired = (char*)handle;
+ *expired = 1;
+}
+
+unsigned int sleep(unsigned int sec)
+{
+ pid_t newpid, curpid=getpid();
+ void *tp;
+ char expired = 0;
+ sh.lastsig = 0;
+ tp = (void*)sh_timeradd(1000*sec, 0, completed, (void*)&expired);
+ do
+ {
+ if(!sh.waitevent || (*sh.waitevent)(-1,-1L,0)==0)
+ pause();
+ if(sh.sigflag[SIGALRM]&SH_SIGTRAP)
+ sh_timetraps();
+ if((newpid=getpid()) != curpid)
+ {
+ curpid = newpid;
+ sh.lastsig = 0;
+ sh.trapnote &= ~SH_SIGSET;
+ if(expired)
+ expired = 0;
+ else
+ timerdel(tp);
+ tp = (void*)sh_timeradd(1000*sec, 0, completed, (void*)&expired);
+ }
+ }
+ while(!expired && sh.lastsig==0);
+ if(!expired)
+ timerdel(tp);
+ sh_sigcheck();
+ return(0);
+}
+
+/*
+ * delay execution for time <t>
+ */
+
+void sh_delay(double t)
+{
+ register int n = (int)t;
+#ifdef _lib_poll
+ struct pollfd fd;
+ if(t<=0)
+ return;
+ else if(n > 30)
+ {
+ sleep(n);
+ t -= n;
+ }
+ if(n=(int)(1000*t))
+ {
+ if(!sh.waitevent || (*sh.waitevent)(-1,(long)n,0)==0)
+ poll(&fd,0,n);
+ }
+#else
+# if defined(_lib_select) && defined(_mem_tv_usec_timeval)
+ struct timeval timeloc;
+ if(t<=0)
+ return;
+ if(n=(int)(1000*t) && sh.waitevent && (*sh.waitevent)(-1,(long)n,0))
+ return;
+ n = (int)t;
+ timeloc.tv_sec = n;
+ timeloc.tv_usec = 1000000*(t-(double)n);
+ select(0,(fd_set*)0,(fd_set*)0,(fd_set*)0,&timeloc);
+# else
+# ifdef _lib_select
+ /* for 9th edition machines */
+ if(t<=0)
+ return;
+ if(n > 30)
+ {
+ sleep(n);
+ t -= n;
+ }
+ if(n=(int)(1000*t))
+ {
+ if(!sh.waitevent || (*sh.waitevent)(-1,(long)n,0)==0)
+ select(0,(fd_set*)0,(fd_set*)0,n);
+ }
+# else
+ struct tms tt;
+ if(t<=0)
+ return;
+ sleep(n);
+ t -= n;
+ if(t)
+ {
+ clock_t begin = times(&tt);
+ if(begin==0)
+ return;
+ t *= sh.lim.clk_tck;
+ n += (t+.5);
+ while((times(&tt)-begin) < n);
+ }
+# endif
+# endif
+#endif /* _lib_poll */
+}
diff --git a/usr/src/lib/libshell/common/bltins/test.c b/usr/src/lib/libshell/common/bltins/test.c
new file mode 100644
index 0000000000..f21db8a75c
--- /dev/null
+++ b/usr/src/lib/libshell/common/bltins/test.c
@@ -0,0 +1,629 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * test expression
+ * [ expression ]
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+
+#include "defs.h"
+#include <ctype.h>
+#include <error.h>
+#include <ls.h>
+#include "io.h"
+#include "terminal.h"
+#include "test.h"
+#include "builtins.h"
+#include "FEATURE/externs"
+#include "FEATURE/poll"
+#include <tmx.h>
+
+#if !_lib_setregid
+# undef _lib_setreuid
+#endif /* _lib_setregid */
+
+#ifdef S_ISSOCK
+# if _pipe_socketpair
+# if _socketpair_shutdown_mode
+# define isapipe(f,p) (test_stat(f,p)>=0&&S_ISFIFO((p)->st_mode)||S_ISSOCK((p)->st_mode)&&(p)->st_ino&&((p)->st_mode&(S_IRUSR|S_IWUSR))!=(S_IRUSR|S_IWUSR))
+# else
+# define isapipe(f,p) (test_stat(f,p)>=0&&S_ISFIFO((p)->st_mode)||S_ISSOCK((p)->st_mode)&&(p)->st_ino)
+# endif
+# else
+# define isapipe(f,p) (test_stat(f,p)>=0&&S_ISFIFO((p)->st_mode)||S_ISSOCK((p)->st_mode)&&(p)->st_ino)
+# endif
+# define isasock(f,p) (test_stat(f,p)>=0&&S_ISSOCK((p)->st_mode))
+#else
+# define isapipe(f,p) (test_stat(f,p)>=0&&S_ISFIFO((p)->st_mode))
+# define isasock(f,p) (0)
+#endif
+
+#define permission(a,f) (sh_access(a,f)==0)
+static time_t test_time(const char*, const char*);
+static int test_stat(const char*, struct stat*);
+static int test_mode(const char*);
+
+/* single char string compare */
+#define c_eq(a,c) (*a==c && *(a+1)==0)
+/* two character string compare */
+#define c2_eq(a,c1,c2) (*a==c1 && *(a+1)==c2 && *(a+2)==0)
+
+struct test
+{
+ Shell_t *sh;
+ int ap;
+ int ac;
+ char **av;
+};
+
+static char *nxtarg(struct test*,int);
+static int expr(struct test*,int);
+static int e3(struct test*);
+
+static int test_strmatch(const char *str, const char *pat)
+{
+ int match[2*(MATCH_MAX+1)],n;
+ register int c, m=0;
+ register const char *cp=pat;
+ while(c = *cp++)
+ {
+ if(c=='(')
+ m++;
+ if(c=='\\' && *cp)
+ cp++;
+ }
+ if(m)
+ m++;
+ else
+ match[0] = 0;
+ if(m > elementsof(match)/2)
+ m = elementsof(match)/2;
+ n = strgrpmatch(str, pat, match, m, STR_MAXIMAL|STR_LEFT|STR_RIGHT);
+ if(m==0 && n==1)
+ match[1] = strlen(str);
+ if(n)
+ sh_setmatch(str, -1, n, match);
+ return(n);
+}
+
+int b_test(int argc, char *argv[],void *extra)
+{
+ struct test tdata;
+ register char *cp = argv[0];
+ register int not;
+ tdata.sh = (Shell_t*)extra;
+ tdata.av = argv;
+ tdata.ap = 1;
+ if(c_eq(cp,'['))
+ {
+ cp = argv[--argc];
+ if(!c_eq(cp, ']'))
+ errormsg(SH_DICT,ERROR_exit(2),e_missing,"']'");
+ }
+ if(argc <= 1)
+ return(1);
+ cp = argv[1];
+ not = c_eq(cp,'!');
+ /* posix portion for test */
+ switch(argc)
+ {
+ case 5:
+ if(!not)
+ break;
+ argv++;
+ /* fall through */
+ case 4:
+ {
+ register int op = sh_lookup(cp=argv[2],shtab_testops);
+ if(op&TEST_BINOP)
+ break;
+ if(!op)
+ {
+ if(argc==5)
+ break;
+ if(not && cp[0]=='-' && cp[2]==0)
+ return(test_unop(cp[1],argv[3])!=0);
+ else if(argv[1][0]=='-' && argv[1][2]==0)
+ return(!test_unop(argv[1][1],cp));
+ errormsg(SH_DICT,ERROR_exit(2),e_badop,cp);
+ }
+ return(test_binop(op,argv[1],argv[3])^(argc!=5));
+ }
+ case 3:
+ if(not)
+ return(*argv[2]!=0);
+ if(cp[0] != '-' || cp[2] || cp[1]=='?')
+ {
+ if(cp[0]=='-' && (cp[1]=='-' || cp[1]=='?') &&
+ strcmp(argv[2],"--")==0)
+ {
+ char *av[3];
+ av[0] = argv[0];
+ av[1] = argv[1];
+ av[2] = 0;
+ optget(av,sh_opttest);
+ errormsg(SH_DICT,ERROR_usage(2), "%s",opt_info.arg);
+ return(2);
+ }
+ break;
+ }
+ return(!test_unop(cp[1],argv[2]));
+ case 2:
+ return(*cp==0);
+ }
+ if(argc==5)
+ argv--;
+ tdata.ac = argc;
+ return(!expr(&tdata,0));
+}
+
+/*
+ * evaluate a test expression.
+ * flag is 0 on outer level
+ * flag is 1 when in parenthesis
+ * flag is 2 when evaluating -a
+ */
+static int expr(struct test *tp,register int flag)
+{
+ register int r;
+ register char *p;
+ r = e3(tp);
+ while(tp->ap < tp->ac)
+ {
+ p = nxtarg(tp,0);
+ /* check for -o and -a */
+ if(flag && c_eq(p,')'))
+ {
+ tp->ap--;
+ break;
+ }
+ if(*p=='-' && *(p+2)==0)
+ {
+ if(*++p == 'o')
+ {
+ if(flag==2)
+ {
+ tp->ap--;
+ break;
+ }
+ r |= expr(tp,3);
+ continue;
+ }
+ else if(*p == 'a')
+ {
+ r &= expr(tp,2);
+ continue;
+ }
+ }
+ if(flag==0)
+ break;
+ errormsg(SH_DICT,ERROR_exit(2),e_badsyntax);
+ }
+ return(r);
+}
+
+static char *nxtarg(struct test *tp,int mt)
+{
+ if(tp->ap >= tp->ac)
+ {
+ if(mt)
+ {
+ tp->ap++;
+ return(0);
+ }
+ errormsg(SH_DICT,ERROR_exit(2),e_argument);
+ }
+ return(tp->av[tp->ap++]);
+}
+
+
+static int e3(struct test *tp)
+{
+ register char *arg, *cp;
+ register int op;
+ char *binop;
+ arg=nxtarg(tp,0);
+ if(arg && c_eq(arg, '!'))
+ return(!e3(tp));
+ if(c_eq(arg, '('))
+ {
+ op = expr(tp,1);
+ cp = nxtarg(tp,0);
+ if(!cp || !c_eq(cp, ')'))
+ errormsg(SH_DICT,ERROR_exit(2),e_missing,"')'");
+ return(op);
+ }
+ cp = nxtarg(tp,1);
+ if(cp!=0 && (c_eq(cp,'=') || c2_eq(cp,'!','=')))
+ goto skip;
+ if(c2_eq(arg,'-','t'))
+ {
+ if(cp && isdigit(*cp))
+ return(*(cp+1)?0:tty_check(*cp-'0'));
+ else
+ {
+ /* test -t with no arguments */
+ tp->ap--;
+ return(tty_check(1));
+ }
+ }
+ if(*arg=='-' && arg[2]==0)
+ {
+ op = arg[1];
+ if(!cp)
+ {
+ /* for backward compatibility with new flags */
+ if(op==0 || !strchr(test_opchars+10,op))
+ return(1);
+ errormsg(SH_DICT,ERROR_exit(2),e_argument);
+ }
+ if(strchr(test_opchars,op))
+ return(test_unop(op,cp));
+ }
+ if(!cp)
+ {
+ tp->ap--;
+ return(*arg!=0);
+ }
+skip:
+ op = sh_lookup(binop=cp,shtab_testops);
+ if(!(op&TEST_BINOP))
+ cp = nxtarg(tp,0);
+ if(!op)
+ errormsg(SH_DICT,ERROR_exit(2),e_badop,binop);
+ if(op==TEST_AND | op==TEST_OR)
+ tp->ap--;
+ return(test_binop(op,arg,cp));
+}
+
+int test_unop(register int op,register const char *arg)
+{
+ struct stat statb;
+ int f;
+ switch(op)
+ {
+ case 'r':
+ return(permission(arg, R_OK));
+ case 'w':
+ return(permission(arg, W_OK));
+ case 'x':
+ return(permission(arg, X_OK));
+ case 'V':
+#if SHOPT_FS_3D
+ {
+ register int offset = staktell();
+ if(stat(arg,&statb)<0 || !S_ISREG(statb.st_mode))
+ return(0);
+ /* add trailing / */
+ stakputs(arg);
+ stakputc('/');
+ stakputc(0);
+ arg = (const char*)stakptr(offset);
+ stakseek(offset);
+ /* FALL THRU */
+ }
+#else
+ return(0);
+#endif /* SHOPT_FS_3D */
+ case 'd':
+ return(test_stat(arg,&statb)>=0 && S_ISDIR(statb.st_mode));
+ case 'c':
+ return(test_stat(arg,&statb)>=0 && S_ISCHR(statb.st_mode));
+ case 'b':
+ return(test_stat(arg,&statb)>=0 && S_ISBLK(statb.st_mode));
+ case 'f':
+ return(test_stat(arg,&statb)>=0 && S_ISREG(statb.st_mode));
+ case 'u':
+ return(test_mode(arg)&S_ISUID);
+ case 'g':
+ return(test_mode(arg)&S_ISGID);
+ case 'k':
+#ifdef S_ISVTX
+ return(test_mode(arg)&S_ISVTX);
+#else
+ return(0);
+#endif /* S_ISVTX */
+#if SHOPT_TEST_L
+ case 'l':
+#endif
+ case 'L':
+ case 'h': /* undocumented, and hopefully will disappear */
+ if(*arg==0 || arg[strlen(arg)-1]=='/' || lstat(arg,&statb)<0)
+ return(0);
+ return(S_ISLNK(statb.st_mode));
+
+ case 'C':
+#ifdef S_ISCTG
+ return(test_stat(arg,&statb)>=0 && S_ISCTG(statb.st_mode));
+#else
+ return(0);
+#endif /* S_ISCTG */
+ case 'H':
+#ifdef S_ISCDF
+ {
+ register int offset = staktell();
+ if(test_stat(arg,&statb)>=0 && S_ISCDF(statb.st_mode))
+ return(1);
+ stakputs(arg);
+ stakputc('+');
+ stakputc(0);
+ arg = (const char*)stakptr(offset);
+ stakseek(offset);
+ return(test_stat(arg,&statb)>=0 && S_ISCDF(statb.st_mode));
+ }
+#else
+ return(0);
+#endif /* S_ISCDF */
+
+ case 'S':
+ return(isasock(arg,&statb));
+ case 'N':
+ return(test_stat(arg,&statb)>=0 && tmxgetmtime(&statb) > tmxgetatime(&statb));
+ case 'p':
+ return(isapipe(arg,&statb));
+ case 'n':
+ return(*arg != 0);
+ case 'z':
+ return(*arg == 0);
+ case 's':
+ sfsync(sfstdout);
+ case 'O':
+ case 'G':
+ if(*arg==0 || test_stat(arg,&statb)<0)
+ return(0);
+ if(op=='s')
+ return(statb.st_size>0);
+ else if(op=='O')
+ return(statb.st_uid==sh.userid);
+ return(statb.st_gid==sh.groupid);
+ case 'a':
+ case 'e':
+ return(permission(arg, F_OK));
+ case 'o':
+ f=1;
+ if(*arg=='?')
+ return(sh_lookopt(arg+1,&f)>0);
+ op = sh_lookopt(arg,&f);
+ return(op && (f==(sh_isoption(op)!=0)));
+ case 't':
+ if(isdigit(*arg) && arg[1]==0)
+ return(tty_check(*arg-'0'));
+ return(0);
+ default:
+ {
+ static char a[3] = "-?";
+ a[1]= op;
+ errormsg(SH_DICT,ERROR_exit(2),e_badop,a);
+ /* NOTREACHED */
+ return(0);
+ }
+ }
+}
+
+int test_binop(register int op,const char *left,const char *right)
+{
+ register double lnum,rnum;
+ if(op&TEST_ARITH)
+ {
+ while(*left=='0')
+ left++;
+ while(*right=='0')
+ right++;
+ lnum = sh_arith(left);
+ rnum = sh_arith(right);
+ }
+ switch(op)
+ {
+ /* op must be one of the following values */
+ case TEST_AND:
+ case TEST_OR:
+ return(*left!=0);
+ case TEST_PEQ:
+ return(test_strmatch(left, right));
+ case TEST_PNE:
+ return(!test_strmatch(left, right));
+ case TEST_SGT:
+ return(strcoll(left, right)>0);
+ case TEST_SLT:
+ return(strcoll(left, right)<0);
+ case TEST_SEQ:
+ return(strcmp(left, right)==0);
+ case TEST_SNE:
+ return(strcmp(left, right)!=0);
+ case TEST_EF:
+ return(test_inode(left,right));
+ case TEST_NT:
+ return(test_time(left,right)>0);
+ case TEST_OT:
+ return(test_time(left,right)<0);
+ case TEST_EQ:
+ return(lnum==rnum);
+ case TEST_NE:
+ return(lnum!=rnum);
+ case TEST_GT:
+ return(lnum>rnum);
+ case TEST_LT:
+ return(lnum<rnum);
+ case TEST_GE:
+ return(lnum>=rnum);
+ case TEST_LE:
+ return(lnum<=rnum);
+ }
+ /* NOTREACHED */
+ return(0);
+}
+
+/*
+ * returns the modification time of f1 - modification time of f2
+ */
+
+static time_t test_time(const char *file1,const char *file2)
+{
+ Time_t t1, t2;
+ struct stat statb1,statb2;
+ int r=test_stat(file2,&statb2);
+ if(test_stat(file1,&statb1)<0)
+ return(r<0?0:-1);
+ if(r<0)
+ return(1);
+ t1 = tmxgetmtime(&statb1);
+ t2 = tmxgetmtime(&statb2);
+ if (t1 > t2)
+ return(1);
+ if (t1 < t2)
+ return(-1);
+ return(0);
+}
+
+/*
+ * return true if inode of two files are the same
+ */
+
+int test_inode(const char *file1,const char *file2)
+{
+ struct stat stat1,stat2;
+ if(test_stat(file1,&stat1)>=0 && test_stat(file2,&stat2)>=0)
+ if(stat1.st_dev == stat2.st_dev && stat1.st_ino == stat2.st_ino)
+ return(1);
+ return(0);
+}
+
+
+/*
+ * This version of access checks against effective uid/gid
+ * The static buffer statb is shared with test_mode.
+ */
+
+int sh_access(register const char *name, register int mode)
+{
+ struct stat statb;
+ if(*name==0)
+ return(-1);
+ if(strmatch(name,(char*)e_devfdNN))
+ return(sh_ioaccess((int)strtol(name+8, (char**)0, 10),mode));
+ /* can't use access function for execute permission with root */
+ if(mode==X_OK && sh.euserid==0)
+ goto skip;
+ if(sh.userid==sh.euserid && sh.groupid==sh.egroupid)
+ return(access(name,mode));
+#ifdef _lib_setreuid
+ /* swap the real uid to effective, check access then restore */
+ /* first swap real and effective gid, if different */
+ if(sh.groupid==sh.euserid || setregid(sh.egroupid,sh.groupid)==0)
+ {
+ /* next swap real and effective uid, if needed */
+ if(sh.userid==sh.euserid || setreuid(sh.euserid,sh.userid)==0)
+ {
+ mode = access(name,mode);
+ /* restore ids */
+ if(sh.userid!=sh.euserid)
+ setreuid(sh.userid,sh.euserid);
+ if(sh.groupid!=sh.egroupid)
+ setregid(sh.groupid,sh.egroupid);
+ return(mode);
+ }
+ else if(sh.groupid!=sh.egroupid)
+ setregid(sh.groupid,sh.egroupid);
+ }
+#endif /* _lib_setreuid */
+skip:
+ if(test_stat(name, &statb) == 0)
+ {
+ if(mode == F_OK)
+ return(mode);
+ else if(sh.euserid == 0)
+ {
+ if(!S_ISREG(statb.st_mode) || mode!=X_OK)
+ return(0);
+ /* root needs execute permission for someone */
+ mode = (S_IXUSR|S_IXGRP|S_IXOTH);
+ }
+ else if(sh.euserid == statb.st_uid)
+ mode <<= 6;
+ else if(sh.egroupid == statb.st_gid)
+ mode <<= 3;
+#ifdef _lib_getgroups
+ /* on some systems you can be in several groups */
+ else
+ {
+ static int maxgroups;
+ gid_t *groups;
+ register int n;
+ if(maxgroups==0)
+ {
+ /* first time */
+ if((maxgroups=getgroups(0,(gid_t*)0)) <= 0)
+ {
+ /* pre-POSIX system */
+ maxgroups=NGROUPS_MAX;
+ }
+ }
+ groups = (gid_t*)stakalloc((maxgroups+1)*sizeof(gid_t));
+ n = getgroups(maxgroups,groups);
+ while(--n >= 0)
+ {
+ if(groups[n] == statb.st_gid)
+ {
+ mode <<= 3;
+ break;
+ }
+ }
+ }
+# endif /* _lib_getgroups */
+ if(statb.st_mode & mode)
+ return(0);
+ }
+ return(-1);
+}
+
+/*
+ * Return the mode bits of file <file>
+ * If <file> is null, then the previous stat buffer is used.
+ * The mode bits are zero if the file doesn't exist.
+ */
+
+static int test_mode(register const char *file)
+{
+ struct stat statb;
+ if(file && (*file==0 || test_stat(file,&statb)<0))
+ return(0);
+ return(statb.st_mode);
+}
+
+/*
+ * do an fstat() for /dev/fd/n, otherwise stat()
+ */
+static int test_stat(const char *name,struct stat *buff)
+{
+ if(*name==0)
+ {
+ errno = ENOENT;
+ return(-1);
+ }
+ if(strmatch(name,(char*)e_devfdNN))
+ return(fstat((int)strtol(name+8, (char**)0, 10),buff));
+ else
+ return(stat(name,buff));
+}
diff --git a/usr/src/lib/libshell/common/bltins/trap.c b/usr/src/lib/libshell/common/bltins/trap.c
new file mode 100644
index 0000000000..7197144d5e
--- /dev/null
+++ b/usr/src/lib/libshell/common/bltins/trap.c
@@ -0,0 +1,347 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * trap [-p] action sig...
+ * kill [-l] [sig...]
+ * kill [-s sig] pid...
+ *
+ * David Korn
+ * AT&T Labs
+ * research!dgk
+ *
+ */
+
+#include "defs.h"
+#include <ctype.h>
+#include "jobs.h"
+#include "builtins.h"
+
+#define L_FLAG 1
+#define S_FLAG 2
+
+static const char trapfmt[] = "trap -- %s %s\n";
+
+static int sig_number(const char*);
+static void sig_list(Shell_t*,int);
+
+int b_trap(int argc,char *argv[],void *extra)
+{
+ register char *arg = argv[1];
+ register int sig, pflag = 0;
+ register Shell_t *shp = (Shell_t*)extra;
+ NOT_USED(argc);
+ while (sig = optget(argv, sh_opttrap)) switch (sig)
+ {
+ case 'p':
+ pflag=1;
+ break;
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(0), "%s", opt_info.arg);
+ return(2);
+ break;
+ }
+ argv += opt_info.index;
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),"%s", optusage((char*)0));
+ if(arg = *argv)
+ {
+ register int clear;
+ char *action = arg;
+ if(!pflag)
+ {
+ /* first argument all digits or - means clear */
+ while(isdigit(*arg))
+ arg++;
+ clear = (arg!=action && *arg==0);
+ if(!clear)
+ {
+ ++argv;
+ if(*action=='-' && action[1]==0)
+ clear++;
+ }
+ while(!argv[0])
+ errormsg(SH_DICT,ERROR_exit(1),e_condition);
+ }
+ while(arg = *argv++)
+ {
+ sig = sig_number(arg);
+ if(sig<0)
+ {
+ errormsg(SH_DICT,2,e_trap,arg);
+ return(1);
+ }
+ /* internal traps */
+ if(sig&SH_TRAP)
+ {
+ sig &= ~SH_TRAP;
+ if(sig>SH_DEBUGTRAP)
+ {
+ errormsg(SH_DICT,2,e_trap,arg);
+ return(1);
+ }
+ if(pflag)
+ {
+ if(arg=shp->st.trap[sig])
+ sfputr(sfstdout,sh_fmtq(arg),'\n');
+ continue;
+ }
+ if(shp->st.trap[sig])
+ free(shp->st.trap[sig]);
+ shp->st.trap[sig] = 0;
+ if(!clear && *action)
+ shp->st.trap[sig] = strdup(action);
+ if(sig == SH_DEBUGTRAP)
+ {
+ if(shp->st.trap[sig])
+ shp->trapnote |= SH_SIGTRAP;
+ else
+ shp->trapnote = 0;
+ }
+ continue;
+ }
+ if(sig>shp->sigmax)
+ {
+ errormsg(SH_DICT,2,e_trap,arg);
+ return(1);
+ }
+ else if(pflag)
+ {
+ char **trapcom = (shp->st.otrapcom?shp->st.otrapcom:shp->st.trapcom);
+ if(arg=trapcom[sig])
+ sfputr(sfstdout,arg,'\n');
+ }
+ else if(clear)
+ sh_sigclear(sig);
+ else
+ {
+ if(sig >= shp->st.trapmax)
+ shp->st.trapmax = sig+1;
+ if(arg=shp->st.trapcom[sig])
+ free(arg);
+ shp->st.trapcom[sig] = strdup(action);
+ sh_sigtrap(sig);
+ }
+ }
+ }
+ else /* print out current traps */
+ sig_list(shp,-1);
+ return(0);
+}
+
+int b_kill(int argc,char *argv[],void *extra)
+{
+ register char *signame;
+ register int sig=SIGTERM, flag=0, n;
+ register Shell_t *shp = (Shell_t*)extra;
+ NOT_USED(argc);
+ while((n = optget(argv,sh_optkill))) switch(n)
+ {
+ case ':':
+ if((signame=argv[opt_info.index++]) && (sig=sig_number(signame+1))>=0)
+ goto endopts;
+ opt_info.index--;
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case 'n':
+ sig = (int)opt_info.num;
+ goto endopts;
+ case 's':
+ flag |= S_FLAG;
+ signame = opt_info.arg;
+ goto endopts;
+ case 'l':
+ flag |= L_FLAG;
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+endopts:
+ argv += opt_info.index;
+ if(*argv && strcmp(*argv,"--")==0 && strcmp(*(argv-1),"--")!=0)
+ argv++;
+ if(error_info.errors || flag==(L_FLAG|S_FLAG) || (!(*argv) && !(flag&L_FLAG)))
+ errormsg(SH_DICT,ERROR_usage(2),"%s", optusage((char*)0));
+ /* just in case we send a kill -9 $$ */
+ sfsync(sfstderr);
+ if(flag&L_FLAG)
+ {
+ if(!(*argv))
+ sig_list(shp,0);
+ else while(signame = *argv++)
+ {
+ if(isdigit(*signame))
+ sig_list(shp,((int)strtol(signame, (char**)0, 10)&0177)+1);
+ else
+ {
+ if((sig=sig_number(signame))<0)
+ {
+ shp->exitval = 2;
+ errormsg(SH_DICT,ERROR_exit(1),e_nosignal,signame);
+ }
+ sfprintf(sfstdout,"%d\n",sig);
+ }
+ }
+ return(shp->exitval);
+ }
+ if(flag&S_FLAG)
+ {
+ if((sig=sig_number(signame)) < 0 || sig > shp->sigmax)
+ errormsg(SH_DICT,ERROR_exit(1),e_nosignal,signame);
+ }
+ if(job_walk(sfstdout,job_kill,sig,argv))
+ shp->exitval = 1;
+ return(shp->exitval);
+}
+
+/*
+ * Given the name or number of a signal return the signal number
+ */
+
+static int sig_number(const char *string)
+{
+ const Shtable_t *tp;
+ register int n,sig=0;
+ char *last;
+ if(isdigit(*string))
+ {
+ n = strtol(string,&last,10);
+ if(*last)
+ n = -1;
+ }
+ else
+ {
+ register int c;
+ n = staktell();
+ do
+ {
+ c = *string++;
+ if(islower(c))
+ c = toupper(c);
+ stakputc(c);
+ }
+ while(c);
+ stakseek(n);
+ if(memcmp(stakptr(n),"SIG",3)==0)
+ {
+ sig = 1;
+ n += 3;
+ }
+ tp = sh_locate(stakptr(n),(const Shtable_t*)shtab_signals,sizeof(*shtab_signals));
+ n = tp->sh_number;
+ if(sig==1 && (n>=(SH_TRAP-1) && n < (1<<SH_SIGBITS)))
+ {
+ /* sig prefix cannot match internal traps */
+ n = 0;
+ tp = (Shtable_t*)((char*)tp + sizeof(*shtab_signals));
+ if(strcmp(stakptr(n),tp->sh_name)==0)
+ n = tp->sh_number;
+ }
+ n &= (1<<SH_SIGBITS)-1;
+ if(n < SH_TRAP)
+ n--;
+ }
+ return(n);
+}
+
+/*
+ * if <flag> is positive, then print signal name corresponding to <flag>
+ * if <flag> is zero, then print all signal names
+ * if <flag> is negative, then print all traps
+ */
+static void sig_list(register Shell_t *shp,register int flag)
+{
+ register const struct shtable2 *tp;
+ register int sig = shp->sigmax+1;
+ const char *names[SH_TRAP];
+ const char *traps[SH_DEBUGTRAP+1];
+ tp=shtab_signals;
+ if(flag==0)
+ {
+ /* not all signals may be defined, so initialize */
+ while(--sig >= 0)
+ names[sig] = 0;
+ for(sig=SH_DEBUGTRAP; sig>=0; sig--)
+ traps[sig] = 0;
+ }
+ while(*tp->sh_name)
+ {
+ sig = tp->sh_number;
+ sig &= ((1<<SH_SIGBITS)-1);
+ if(sig==flag)
+ {
+ sfprintf(sfstdout,"%s\n",tp->sh_name);
+ return;
+ }
+ else if(sig&SH_TRAP)
+ traps[sig&~SH_TRAP] = (char*)tp->sh_name;
+ else if(sig < sizeof(names)/sizeof(char*))
+ names[sig] = (char*)tp->sh_name;
+ tp++;
+ }
+ if(flag > 0)
+ sfprintf(sfstdout,"%d\n",flag-1);
+ else if(flag<0)
+ {
+ /* print the traps */
+ register char *trap,*sname,**trapcom;
+ char name[6];
+ sig = shp->st.trapmax;
+ /* use parent traps if otrapcom is set (for $(trap) */
+ trapcom = (shp->st.otrapcom?shp->st.otrapcom:shp->st.trapcom);
+ while(--sig >= 0)
+ {
+ if(!(trap=trapcom[sig]))
+ continue;
+ if(!(sname=(char*)names[sig+1]))
+ {
+ sname = name;
+ sname[0] = 'S';
+ sname[1] = 'I';
+ sname[2] = 'G';
+ sname[3] = (sig/10)+'0';
+ sname[4] = (sig%10)+'0';
+ }
+ sfprintf(sfstdout,trapfmt,sh_fmtq(trap),sname);
+ }
+ for(sig=SH_DEBUGTRAP; sig>=0; sig--)
+ {
+ if(!(trap=shp->st.trap[sig]))
+ continue;
+ sfprintf(sfstdout,trapfmt,sh_fmtq(trap),traps[sig]);
+ }
+ }
+ else
+ {
+ /* print all the signal names */
+ for(sig=2; sig <= shp->sigmax; sig++)
+ {
+ if(names[sig])
+ sfputr(sfstdout,names[sig],'\n');
+ else
+ sfprintf(sfstdout,"SIG%d\n",sig-1);
+ }
+ }
+}
+
diff --git a/usr/src/lib/libshell/common/bltins/typeset.c b/usr/src/lib/libshell/common/bltins/typeset.c
new file mode 100644
index 0000000000..14b02a6ad3
--- /dev/null
+++ b/usr/src/lib/libshell/common/bltins/typeset.c
@@ -0,0 +1,979 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * export [-p] [arg...]
+ * readonly [-p] [arg...]
+ * typeset [options] [arg...]
+ * alias [-ptx] [arg...]
+ * unalias [arg...]
+ * builtin [-sd] [-f file] [name...]
+ * set [options] [name...]
+ * unset [-fnv] [name...]
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#include "defs.h"
+#include <error.h>
+#include "path.h"
+#include "name.h"
+#include "history.h"
+#include "builtins.h"
+#include "variables.h"
+#include <dlldefs.h>
+
+struct tdata
+{
+ Shell_t *sh;
+ Namval_t *tp;
+ Sfio_t *outfile;
+ char *prefix;
+ int aflag;
+ int argnum;
+ int scanmask;
+ Dt_t *scanroot;
+ char **argnam;
+};
+
+
+static int print_namval(Sfio_t*, Namval_t*, int, struct tdata*);
+static void print_attribute(Namval_t*,void*);
+static void print_all(Sfio_t*, Dt_t*, struct tdata*);
+static void print_scan(Sfio_t*, int, Dt_t*, int, struct tdata*t);
+static int b_unall(int, char**, Dt_t*, Shell_t*);
+static int b_common(char**, int, Dt_t*, struct tdata*);
+static void pushname(Namval_t*,void*);
+static void(*nullscan)(Namval_t*,void*);
+
+static Namval_t *load_class(const char *name)
+{
+ errormsg(SH_DICT,ERROR_exit(1),"%s: type not loadable",name);
+ return(0);
+}
+
+/*
+ * Note export and readonly are the same
+ */
+#if 0
+ /* for the dictionary generator */
+ int b_export(int argc,char *argv[],void *extra){}
+#endif
+int b_readonly(int argc,char *argv[],void *extra)
+{
+ register int flag;
+ char *command = argv[0];
+ struct tdata tdata;
+ NOT_USED(argc);
+ memset((void*)&tdata,0,sizeof(tdata));
+ tdata.sh = (Shell_t*)extra;
+ tdata.aflag = '-';
+ while((flag = optget(argv,*command=='e'?sh_optexport:sh_optreadonly))) switch(flag)
+ {
+ case 'p':
+ tdata.prefix = command;
+ break;
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(0), "%s", opt_info.arg);
+ return(2);
+ }
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),optusage(NIL(char*)));
+ argv += (opt_info.index-1);
+ if(*command=='r')
+ flag = (NV_ASSIGN|NV_RDONLY|NV_VARNAME);
+#ifdef _ENV_H
+ else if(!argv[1])
+ {
+ char *cp,**env=env_get(tdata.sh->env);
+ while(cp = *env++)
+ {
+ if(tdata.prefix)
+ sfputr(sfstdout,tdata.prefix,' ');
+ sfprintf(sfstdout,"%s\n",sh_fmtq(cp));
+ }
+ return(0);
+ }
+#endif
+ else
+ {
+ flag = (NV_ASSIGN|NV_EXPORT|NV_IDENT);
+ if(!sh.prefix)
+ sh.prefix = "";
+ }
+ return(b_common(argv,flag,tdata.sh->var_tree, &tdata));
+}
+
+
+int b_alias(int argc,register char *argv[],void *extra)
+{
+ register unsigned flag = NV_NOARRAY|NV_NOSCOPE|NV_ASSIGN;
+ register Dt_t *troot;
+ register int n;
+ struct tdata tdata;
+ NOT_USED(argc);
+ memset((void*)&tdata,0,sizeof(tdata));
+ tdata.sh = (Shell_t*)extra;
+ troot = tdata.sh->alias_tree;
+ if(*argv[0]=='h')
+ flag = NV_TAGGED;
+ if(argv[1])
+ {
+ opt_info.offset = 0;
+ opt_info.index = 1;
+ *opt_info.option = 0;
+ tdata.argnum = 0;
+ tdata.aflag = *argv[1];
+ while((n = optget(argv,sh_optalias))) switch(n)
+ {
+ case 'p':
+ tdata.prefix = argv[0];
+ break;
+ case 't':
+ flag |= NV_TAGGED;
+ break;
+ case 'x':
+ flag |= NV_EXPORT;
+ break;
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(0), "%s", opt_info.arg);
+ return(2);
+ }
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage(NIL(char*)));
+ argv += (opt_info.index-1);
+ if(flag&NV_TAGGED)
+ {
+ if(argv[1] && strcmp(argv[1],"-r")==0)
+ {
+ /* hack to handle hash -r */
+ nv_putval(PATHNOD,nv_getval(PATHNOD),NV_RDONLY);
+ return(0);
+ }
+ troot = tdata.sh->track_tree;
+ }
+ }
+ return(b_common(argv,flag,troot,&tdata));
+}
+
+
+#if 0
+ /* for the dictionary generator */
+ int b_local(int argc,char *argv[],void *extra){}
+#endif
+int b_typeset(int argc,register char *argv[],void *extra)
+{
+ register int flag = NV_VARNAME|NV_ASSIGN;
+ register int n;
+ struct tdata tdata;
+ Namtype_t *ntp = (Namtype_t*)extra;
+ Dt_t *troot;
+ int isfloat=0, shortint=0;
+ NOT_USED(argc);
+ memset((void*)&tdata,0,sizeof(tdata));
+ tdata.sh = ntp->shp;
+ tdata.tp = ntp->np;
+ troot = tdata.sh->var_tree;
+ opt_info.disc = (Optdisc_t*)ntp->optinfof;
+ while((n = optget(argv,ntp->optstring)))
+ {
+ switch(n)
+ {
+ case 'a':
+ flag |= NV_IARRAY;
+ break;
+ case 'A':
+ flag |= NV_ARRAY;
+ break;
+ case 'E':
+ /* The following is for ksh88 compatibility */
+ if(opt_info.offset && !strchr(argv[opt_info.index],'E'))
+ {
+ tdata.argnum = (int)opt_info.num;
+ break;
+ }
+ case 'F':
+ if(!opt_info.arg || (tdata.argnum = opt_info.num) <0)
+ tdata.argnum = 10;
+ isfloat = 1;
+ if(n=='E')
+ flag |= NV_EXPNOTE;
+ break;
+ case 'b':
+ flag |= NV_BINARY;
+ break;
+ case 'n':
+ flag &= ~NV_VARNAME;
+ flag |= (NV_REF|NV_IDENT);
+ break;
+ case 'H':
+ flag |= NV_HOST;
+ break;
+ case 'T':
+ flag |= NV_TYPE;
+ tdata.prefix = opt_info.arg;
+ break;
+ case 'L':
+ if(tdata.argnum==0)
+ tdata.argnum = (int)opt_info.num;
+ if(tdata.argnum < 0)
+ errormsg(SH_DICT,ERROR_exit(1), e_badfield, tdata.argnum);
+ flag &= ~NV_RJUST;
+ flag |= NV_LJUST;
+ break;
+ case 'Z':
+ flag |= NV_ZFILL;
+ /* FALL THRU*/
+ case 'R':
+ if(tdata.argnum==0)
+ tdata.argnum = (int)opt_info.num;
+ if(tdata.argnum < 0)
+ errormsg(SH_DICT,ERROR_exit(1), e_badfield, tdata.argnum);
+ flag &= ~NV_LJUST;
+ flag |= NV_RJUST;
+ break;
+ case 'f':
+ flag &= ~(NV_VARNAME|NV_ASSIGN);
+ troot = tdata.sh->fun_tree;
+ break;
+ case 'i':
+ if(!opt_info.arg || (tdata.argnum = opt_info.num) <0)
+ tdata.argnum = 10;
+ flag |= NV_INTEGER;
+ break;
+ case 'l':
+ flag |= NV_UTOL;
+ break;
+ case 'p':
+ tdata.prefix = argv[0];
+ continue;
+ case 'r':
+ flag |= NV_RDONLY;
+ break;
+ case 's':
+ shortint=1;
+ break;
+ case 't':
+ flag |= NV_TAGGED;
+ break;
+ case 'u':
+ flag |= NV_LTOU;
+ break;
+ case 'x':
+ flag &= ~NV_VARNAME;
+ flag |= (NV_EXPORT|NV_IDENT);
+ break;
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(0), "%s", opt_info.arg);
+ opt_info.disc = 0;
+ return(2);
+ }
+ if(tdata.aflag==0)
+ tdata.aflag = *opt_info.option;
+ }
+ argv += opt_info.index;
+ opt_info.disc = 0;
+ /* handle argument of + and - specially */
+ if(*argv && argv[0][1]==0 && (*argv[0]=='+' || *argv[0]=='-'))
+ tdata.aflag = *argv[0];
+ else
+ argv--;
+ if((flag&NV_INTEGER) && (flag&(NV_LJUST|NV_RJUST|NV_ZFILL)))
+ error_info.errors++;
+ if((flag&NV_BINARY) && (flag&(NV_LJUST|NV_UTOL|NV_LTOU)))
+ error_info.errors++;
+ if(troot==tdata.sh->fun_tree && ((isfloat || flag&~(NV_FUNCT|NV_TAGGED|NV_EXPORT|NV_LTOU))))
+ error_info.errors++;
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),"%s", optusage(NIL(char*)));
+ if(isfloat)
+ flag |= NV_INTEGER|NV_DOUBLE;
+ if(shortint)
+ flag |= NV_SHORT|NV_INTEGER;
+ if(tdata.sh->fn_depth)
+ flag |= NV_NOSCOPE;
+ if(flag&NV_TYPE)
+ {
+ int offset = staktell();
+ stakputs(NV_CLASS);
+ if(NV_CLASS[sizeof(NV_CLASS)-2]!='.')
+ stakputc('.');
+ stakputs(tdata.prefix);
+ stakputc(0);
+ tdata.tp = nv_open(stakptr(offset),tdata.sh->var_tree,NV_VARNAME|NV_NOARRAY|NV_NOASSIGN);
+ stakseek(offset);
+ if(!tdata.tp)
+ errormsg(SH_DICT,ERROR_exit(1),"%s: unknown type",tdata.prefix);
+ flag &= ~NV_TYPE;
+ }
+ else if(tdata.aflag==0 && ntp->np)
+ tdata.aflag = '-';
+ return(b_common(argv,flag,troot,&tdata));
+}
+
+static int b_common(char **argv,register int flag,Dt_t *troot,struct tdata *tp)
+{
+ register char *name;
+ char *last = 0;
+ int nvflags=(flag&(NV_ARRAY|NV_NOARRAY|NV_VARNAME|NV_IDENT|NV_ASSIGN));
+ int r=0, ref=0;
+ Shell_t *shp =tp->sh;
+ if(!sh.prefix)
+ nvflags |= NV_NOSCOPE;
+ else if(*sh.prefix==0)
+ sh.prefix = 0;
+ flag &= ~(NV_NOARRAY|NV_NOSCOPE|NV_VARNAME|NV_IDENT);
+ if(argv[1])
+ {
+ if(flag&NV_REF)
+ {
+ flag &= ~NV_REF;
+ ref=1;
+ if(tp->aflag!='-')
+ nvflags |= NV_NOREF;
+ }
+ while(name = *++argv)
+ {
+ register unsigned newflag;
+ register Namval_t *np;
+ unsigned curflag;
+ if(troot == shp->fun_tree)
+ {
+ /*
+ *functions can be exported or
+ * traced but not set
+ */
+ flag &= ~NV_ASSIGN;
+ if(flag&NV_LTOU)
+ {
+ /* Function names cannot be special builtin */
+ if((np=nv_search(name,shp->bltin_tree,0)) && nv_isattr(np,BLT_SPC))
+ errormsg(SH_DICT,ERROR_exit(1),e_badfun,name);
+ np = nv_open(name,shp->fun_tree,NV_NOARRAY|NV_IDENT|NV_NOSCOPE);
+ }
+ else
+ np = nv_search(name,shp->fun_tree,HASH_NOSCOPE);
+ if(np && ((flag&NV_LTOU) || !nv_isnull(np) || nv_isattr(np,NV_LTOU)))
+ {
+ if(flag==0)
+ {
+ print_namval(sfstdout,np,tp->aflag=='+',tp);
+ continue;
+ }
+ if(shp->subshell)
+ sh_subfork();
+ if(tp->aflag=='-')
+ nv_onattr(np,flag|NV_FUNCTION);
+ else if(tp->aflag=='+')
+ nv_offattr(np,flag);
+ }
+ else
+ r++;
+ continue;
+ }
+ np = nv_open(name,troot,nvflags);
+ /* tracked alias */
+ if(troot==shp->track_tree && tp->aflag=='-')
+ {
+#ifdef PATH_BFPATH
+ path_alias(np,path_absolute(nv_name(np),NIL(Pathcomp_t*)));
+#else
+ nv_onattr(np,NV_NOALIAS);
+ path_alias(np,path_absolute(nv_name(np),NIL(char*)));
+#endif
+ continue;
+ }
+ if(flag==NV_ASSIGN && !ref && tp->aflag!='-' && !strchr(name,'='))
+ {
+ if(troot!=shp->var_tree && (nv_isnull(np) || !print_namval(sfstdout,np,0,tp)))
+ {
+ sfprintf(sfstderr,sh_translate(e_noalias),name);
+ r++;
+ }
+ continue;
+ }
+ if(tp->tp)
+ {
+ nv_settype(np,tp->tp,tp->aflag=='-'?0:NV_APPEND);
+ flag = (np->nvflag&NV_NOCHANGE);
+ }
+ if(troot==shp->var_tree && (flag&NV_IARRAY))
+ {
+ flag &= ~NV_IARRAY;
+ if(nv_isnull(np))
+ nv_onattr(np,NV_ARRAY);
+ else
+ nv_putsub(np, (char*)0, 0);
+ }
+ if(troot==shp->var_tree && (nvflags&NV_ARRAY))
+ nv_setarray(np,nv_associative);
+ curflag = np->nvflag;
+ flag &= ~NV_ASSIGN;
+ if(last=strchr(name,'='))
+ *last = 0;
+ if (tp->aflag == '-')
+ {
+ if((flag&NV_EXPORT) && strchr(name,'.'))
+ errormsg(SH_DICT,ERROR_exit(1),e_badexport,name);
+#if SHOPT_BSH
+ if(flag&NV_EXPORT)
+ nv_offattr(np,NV_IMPORT);
+#endif /* SHOPT_BSH */
+ newflag = curflag;
+ if(flag&~NV_NOCHANGE)
+ newflag &= NV_NOCHANGE;
+ newflag |= flag;
+ if (flag & (NV_LJUST|NV_RJUST))
+ {
+ if(!(flag&NV_RJUST))
+ newflag &= ~NV_RJUST;
+
+ else if(!(flag&NV_LJUST))
+ newflag &= ~NV_LJUST;
+ }
+ if (flag & NV_UTOL)
+ newflag &= ~NV_LTOU;
+ else if (flag & NV_LTOU)
+ newflag &= ~NV_UTOL;
+ }
+ else
+ {
+ if((flag&NV_RDONLY) && (curflag&NV_RDONLY))
+ errormsg(SH_DICT,ERROR_exit(1),e_readonly,nv_name(np));
+ newflag = curflag & ~flag;
+ }
+ if (tp->aflag && (tp->argnum>0 || (curflag!=newflag)))
+ {
+ if(shp->subshell)
+ sh_assignok(np,1);
+ if(troot!=shp->var_tree)
+ nv_setattr(np,newflag&~NV_ASSIGN);
+ else
+ {
+ char *oldname=0;
+ if(tp->argnum==1 && newflag==NV_INTEGER && nv_isattr(np,NV_INTEGER))
+ tp->argnum = 10;
+ /* use reference name for export */
+ if((newflag^curflag)&NV_EXPORT)
+ {
+ oldname = np->nvname;
+ np->nvname = name;
+ }
+ nv_newattr (np, newflag&~NV_ASSIGN,tp->argnum);
+ if(oldname)
+ np->nvname = oldname;
+ }
+ }
+ if(last)
+ *last = '=';
+ /* set or unset references */
+ if(ref)
+ {
+ if(tp->aflag=='-')
+ {
+ Dt_t *hp=0;
+ if(nv_isattr(np,NV_PARAM) && shp->st.prevst)
+ {
+ if(!(hp=(Dt_t*)shp->st.prevst->save_tree))
+ hp = dtvnext(shp->var_tree);
+ }
+ nv_setref(np,hp,NV_VARNAME);
+ }
+ else
+ nv_unref(np);
+ }
+ nv_close(np);
+ }
+ }
+ else if(!sh.envlist)
+ {
+ if(tp->aflag)
+ {
+ if(troot==shp->fun_tree)
+ {
+ flag |= NV_FUNCTION;
+ tp->prefix = 0;
+ }
+ else if(troot==shp->var_tree)
+ flag |= (nvflags&NV_ARRAY);
+ print_scan(sfstdout,flag,troot,tp->aflag=='+',tp);
+ }
+ else if(troot==shp->alias_tree)
+ print_scan(sfstdout,0,troot,0,tp);
+ else
+ print_all(sfstdout,troot,tp);
+ sfsync(sfstdout);
+ }
+ return(r);
+}
+
+typedef void (*Iptr_t)(int);
+typedef int (*Fptr_t)(int, char*[], void*);
+
+#define GROWLIB 4
+
+static void** liblist;
+static int nlib;
+static int maxlib;
+
+/*
+ * This allows external routines to load from the same library */
+void **sh_getliblist(void)
+{
+ return(liblist);
+}
+
+/*
+ * add library to loaded list
+ * call (*lib_init)() on first load if defined
+ * always move to head of search list
+ * return: 0: already loaded 1: first load
+ */
+int sh_addlib(void* library)
+{
+ register int n;
+ register int r;
+ Iptr_t initfn;
+
+ for (n = r = 0; n < nlib; n++)
+ {
+ if (r)
+ liblist[n-1] = liblist[n];
+ else if (liblist[n] == library)
+ r++;
+ }
+ if (r)
+ nlib--;
+ else if ((initfn = (Iptr_t)dlllook(library, "lib_init")))
+ (*initfn)(0);
+ if (nlib >= maxlib)
+ {
+ maxlib += GROWLIB;
+ if (liblist)
+ liblist = (void**)realloc((void*)liblist, (maxlib+1)*sizeof(void**));
+ else
+ liblist = (void**)malloc((maxlib+1)*sizeof(void**));
+ }
+ liblist[nlib++] = library;
+ liblist[nlib] = 0;
+ return !r;
+}
+
+/*
+ * add change or list built-ins
+ * adding builtins requires dlopen() interface
+ */
+int b_builtin(int argc,char *argv[],void *extra)
+{
+ register char *arg=0, *name;
+ register int n, r=0, flag=0;
+ register Namval_t *np;
+ long dlete=0;
+ struct tdata tdata;
+ Fptr_t addr;
+ void *library=0;
+ char *errmsg;
+ NOT_USED(argc);
+ tdata.sh = (Shell_t*)extra;
+ while (n = optget(argv,sh_optbuiltin)) switch (n)
+ {
+ case 's':
+ flag = BLT_SPC;
+ break;
+ case 'd':
+ dlete=1;
+ break;
+ case 'f':
+#if SHOPT_DYNAMIC
+ arg = opt_info.arg;
+#else
+ errormsg(SH_DICT,2, "adding built-ins not supported");
+ error_info.errors++;
+#endif /* SHOPT_DYNAMIC */
+ break;
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),"%s", optusage(NIL(char*)));
+ if(arg || *argv)
+ {
+ if(sh_isoption(SH_RESTRICTED))
+ errormsg(SH_DICT,ERROR_exit(1),e_restricted,argv[-opt_info.index]);
+ if(sh_isoption(SH_PFSH))
+ errormsg(SH_DICT,ERROR_exit(1),e_pfsh,argv[-opt_info.index]);
+ if(tdata.sh->subshell)
+ sh_subfork();
+ }
+ if(arg)
+ {
+#ifdef _hdr_dlldefs
+#if (_AST_VERSION>=20040404)
+ if(!(library = dllplug(SH_ID,arg,NIL(char*),RTLD_LAZY,NIL(char*),0)))
+#else
+ if(!(library = dllfind(arg,NIL(char*),RTLD_LAZY,NIL(char*),0)))
+#endif
+#else
+ if(!(library = dlopen(arg,DL_MODE)))
+#endif
+ {
+ errormsg(SH_DICT,ERROR_exit(0),"%s: %s",arg,dlerror());
+ return(1);
+ }
+ sh_addlib(library);
+ }
+ else if(*argv==0 && !dlete)
+ {
+ print_scan(sfstdout, flag, tdata.sh->bltin_tree, 1, &tdata);
+ return(0);
+ }
+ r = 0;
+ flag = staktell();
+ while(arg = *argv)
+ {
+ name = path_basename(arg);
+ stakputs("b_");
+ stakputs(name);
+ errmsg = 0;
+ addr = 0;
+ for(n=(nlib?nlib:dlete); --n>=0;)
+ {
+ /* (char*) added for some sgi-mips compilers */
+ if(dlete || (addr = (Fptr_t)dlllook(liblist[n],stakptr(flag))))
+ {
+ if(np = sh_addbuiltin(arg, addr,pointerof(dlete)))
+ {
+ if(dlete || nv_isattr(np,BLT_SPC))
+ errmsg = "restricted name";
+ }
+ break;
+ }
+ }
+ if(!dlete && !addr)
+ {
+ np = sh_addbuiltin(arg, 0 ,0);
+ if(np && nv_isattr(np,BLT_SPC))
+ errmsg = "restricted name";
+ else if(!np)
+ errmsg = "not found";
+ }
+ if(errmsg)
+ {
+ errormsg(SH_DICT,ERROR_exit(0),"%s: %s",*argv,errmsg);
+ r = 1;
+ }
+ stakseek(flag);
+ argv++;
+ }
+ return(r);
+}
+
+int b_set(int argc,register char *argv[],void *extra)
+{
+ struct tdata tdata;
+ memset(&tdata,0,sizeof(tdata));
+ tdata.sh = (Shell_t*)extra;
+ tdata.prefix=0;
+ if(argv[1])
+ {
+ if(sh_argopts(argc,argv) < 0)
+ return(2);
+ if(sh_isoption(SH_VERBOSE))
+ sh_onstate(SH_VERBOSE);
+ else
+ sh_offstate(SH_VERBOSE);
+ if(sh_isoption(SH_MONITOR))
+ sh_onstate(SH_MONITOR);
+ else
+ sh_offstate(SH_MONITOR);
+ }
+ else
+ /*scan name chain and print*/
+ print_scan(sfstdout,0,tdata.sh->var_tree,0,&tdata);
+ return(0);
+}
+
+/*
+ * The removing of Shell variable names, aliases, and functions
+ * is performed here.
+ * Unset functions with unset -f
+ * Non-existent items being deleted give non-zero exit status
+ */
+
+int b_unalias(int argc,register char *argv[],void *extra)
+{
+ Shell_t *shp = (Shell_t*)extra;
+ return(b_unall(argc,argv,shp->alias_tree,shp));
+}
+
+int b_unset(int argc,register char *argv[],void *extra)
+{
+ Shell_t *shp = (Shell_t*)extra;
+ return(b_unall(argc,argv,shp->var_tree,shp));
+}
+
+static int b_unall(int argc, char **argv, register Dt_t *troot, Shell_t* shp)
+{
+ register Namval_t *np;
+ register const char *name;
+ register int r;
+ int nflag=0,all=0,isfun;
+ NOT_USED(argc);
+ if(troot==shp->alias_tree)
+ {
+ name = sh_optunalias;
+ if(shp->subshell)
+ troot = sh_subaliastree(0);
+ }
+ else
+ name = sh_optunset;
+ while(r = optget(argv,name)) switch(r)
+ {
+ case 'f':
+ troot = sh_subfuntree(0);
+ break;
+ case 'a':
+ all=1;
+ break;
+ case 'n':
+ nflag = NV_NOREF;
+ case 'v':
+ troot = shp->var_tree;
+ break;
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(0), "%s", opt_info.arg);
+ return(2);
+ }
+ argv += opt_info.index;
+ if(error_info.errors || (*argv==0 &&!all))
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage(NIL(char*)));
+ if(!troot)
+ return(1);
+ r = 0;
+ if(troot==shp->var_tree)
+ nflag |= NV_VARNAME;
+ else
+ nflag = NV_NOSCOPE;
+ if(all)
+ dtclear(troot);
+ else while(name = *argv++)
+ {
+ if(np=nv_open(name,troot,NV_NOADD|nflag))
+ {
+ if(is_abuiltin(np))
+ {
+ r = 1;
+ continue;
+ }
+ isfun = is_afunction(np);
+ if(shp->subshell && troot==shp->var_tree)
+ np=sh_assignok(np,0);
+ nv_unset(np);
+ nv_close(np);
+ if(isfun)
+ dtdelete(troot,np);
+ }
+ else
+ r = 1;
+ }
+ return(r);
+}
+
+/*
+ * print out the name and value of a name-value pair <np>
+ */
+
+static int print_namval(Sfio_t *file,register Namval_t *np,register int flag, struct tdata *tp)
+{
+ register char *cp;
+ sh_sigcheck();
+ if(flag)
+ flag = '\n';
+ if(nv_isattr(np,NV_NOPRINT)==NV_NOPRINT)
+ {
+ if(is_abuiltin(np))
+ sfputr(file,nv_name(np),'\n');
+ return(0);
+ }
+ if(tp->prefix)
+ sfputr(file,tp->prefix,' ');
+ if(is_afunction(np))
+ {
+ Sfio_t *iop=0;
+ char *fname=0;
+ if(!flag && !np->nvalue.ip)
+ sfputr(file,"typeset -fu",' ');
+ else if(!flag && !nv_isattr(np,NV_FPOSIX))
+ sfputr(file,"function",' ');
+ sfputr(file,nv_name(np),-1);
+ if(nv_isattr(np,NV_FPOSIX))
+ sfwrite(file,"()",2);
+ if(np->nvalue.ip && np->nvalue.rp->hoffset>=0)
+ fname = np->nvalue.rp->fname;
+ else
+ flag = '\n';
+ if(flag)
+ {
+ if(np->nvalue.ip && np->nvalue.rp->hoffset>=0)
+ sfprintf(file," #line %d %s\n",np->nvalue.rp->lineno,fname?sh_fmtq(fname):"");
+ else
+ sfputc(file, '\n');
+ }
+ else
+ {
+ if(nv_isattr(np,NV_FTMP))
+ {
+ fname = 0;
+ iop = tp->sh->heredocs;
+ }
+ else if(fname)
+ iop = sfopen(iop,fname,"r");
+ else if(tp->sh->hist_ptr)
+ iop = (tp->sh->hist_ptr)->histfp;
+ if(iop && sfseek(iop,(Sfoff_t)np->nvalue.rp->hoffset,SEEK_SET)>=0)
+ sfmove(iop,file, nv_size(np), -1);
+ else
+ flag = '\n';
+ if(fname)
+ sfclose(iop);
+ }
+ return(nv_size(np)+1);
+ }
+ if(cp=nv_getval(np))
+ {
+ sfputr(file,nv_name(np),-1);
+ if(!flag)
+ {
+ flag = '=';
+ if(nv_arrayptr(np))
+ sfprintf(file,"[%s]", sh_fmtq(nv_getsub(np)));
+ }
+ sfputc(file,flag);
+ if(flag != '\n')
+ {
+ if(nv_isref(np) && nv_refsub(np))
+ {
+ sfputr(file,sh_fmtq(cp),-1);
+ sfprintf(file,"[%s]\n", sh_fmtq(nv_refsub(np)));
+ }
+ else
+ sfputr(file,sh_fmtq(cp),'\n');
+ }
+ return(1);
+ }
+ else if(tp->scanmask && tp->scanroot==tp->sh->var_tree)
+ sfputr(file,nv_name(np),'\n');
+ return(0);
+}
+
+/*
+ * print attributes at all nodes
+ */
+static void print_all(Sfio_t *file,Dt_t *root, struct tdata *tp)
+{
+ tp->outfile = file;
+ nv_scan(root, print_attribute, (void*)tp, 0, 0);
+}
+
+/*
+ * print the attributes of name value pair give by <np>
+ */
+static void print_attribute(register Namval_t *np,void *data)
+{
+ register struct tdata *dp = (struct tdata*)data;
+ nv_attribute(np,dp->outfile,dp->prefix,dp->aflag);
+}
+
+/*
+ * print the nodes in tree <root> which have attributes <flag> set
+ * of <option> is non-zero, no subscript or value is printed.
+ */
+
+static void print_scan(Sfio_t *file, int flag, Dt_t *root, int option,struct tdata *tp)
+{
+ register char **argv;
+ register Namval_t *np;
+ register int namec;
+ Namval_t *onp = 0;
+ sh.last_table=0;
+ flag &= ~NV_ASSIGN;
+ tp->scanmask = flag&~NV_NOSCOPE;
+ tp->scanroot = root;
+ tp->outfile = file;
+ if(flag&NV_INTEGER)
+ tp->scanmask |= (NV_DOUBLE|NV_EXPNOTE);
+ namec = nv_scan(root,nullscan,(void*)tp,tp->scanmask,flag);
+ argv = tp->argnam = (char**)stakalloc((namec+1)*sizeof(char*));
+ namec = nv_scan(root, pushname, (void*)tp, tp->scanmask, flag);
+ if(mbcoll())
+ strsort(argv,namec,strcoll);
+ while(namec--)
+ {
+ if((np=nv_search(*argv++,root,0)) && np!=onp && (!nv_isnull(np) || np->nvfun || nv_isattr(np,~NV_NOFREE)))
+ {
+ onp = np;
+ if((flag&NV_ARRAY) && nv_aindex(np)>=0)
+ continue;
+ if(!flag && nv_isattr(np,NV_ARRAY))
+ {
+ if(array_elem(nv_arrayptr(np))==0)
+ continue;
+ nv_putsub(np,NIL(char*),ARRAY_SCAN);
+ do
+ {
+ print_namval(file,np,option,tp);
+ }
+ while(!option && nv_nextsub(np));
+ }
+ else
+ print_namval(file,np,option,tp);
+ }
+ }
+}
+
+/*
+ * add the name of the node to the argument list argnam
+ */
+
+static void pushname(Namval_t *np,void *data)
+{
+ struct tdata *tp = (struct tdata*)data;
+ *tp->argnam++ = nv_name(np);
+}
+
diff --git a/usr/src/lib/libshell/common/bltins/ulimit.c b/usr/src/lib/libshell/common/bltins/ulimit.c
new file mode 100644
index 0000000000..4f7a2fc844
--- /dev/null
+++ b/usr/src/lib/libshell/common/bltins/ulimit.c
@@ -0,0 +1,211 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * ulimit [-HSacdfmnstuv] [limit]
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#include <ast.h>
+#include <sfio.h>
+#include <error.h>
+#include <shell.h>
+#include "builtins.h"
+#include "name.h"
+#include "ulimit.h"
+#ifndef SH_DICT
+# define SH_DICT "libshell"
+#endif
+
+#ifdef _no_ulimit
+ int b_ulimit(int argc,char *argv[],void *extra)
+ {
+ NOT_USED(argc);
+ NOT_USED(argv);
+ NOT_USED(extra);
+ errormsg(SH_DICT,ERROR_exit(2),e_nosupport);
+ return(0);
+ }
+#else
+
+static int infof(Opt_t* op, Sfio_t* sp, const char* s, Optdisc_t* dp)
+{
+ register const Limit_t* tp;
+
+ for (tp = shtab_limits; tp->option; tp++)
+ {
+ sfprintf(sp, "[%c=%d:%s?The %s", tp->option, tp - shtab_limits + 1, tp->name, tp->description);
+ if(tp->type != LIM_COUNT)
+ sfprintf(sp, " in %ss", e_units[tp->type]);
+ sfprintf(sp, ".]");
+ }
+ return(1);
+}
+
+#define HARD 2
+#define SOFT 4
+
+int b_ulimit(int argc,char *argv[],void *extra)
+{
+ register char *limit;
+ register int mode=0, n;
+ register unsigned long hit = 0;
+ Shell_t *shp = (Shell_t*)extra;
+#ifdef _lib_getrlimit
+ struct rlimit rlp;
+#endif /* _lib_getrlimit */
+ const Limit_t* tp;
+ char* conf;
+ int label, unit, noargs, nosupport;
+ rlim_t i;
+ char tmp[32];
+ Optdisc_t disc;
+ memset(&disc, 0, sizeof(disc));
+ disc.version = OPT_VERSION;
+ disc.infof = infof;
+ opt_info.disc = &disc;
+ while((n = optget(argv,sh_optulimit))) switch(n)
+ {
+ case 'H':
+ mode |= HARD;
+ continue;
+ case 'S':
+ mode |= SOFT;
+ continue;
+ case 'a':
+ hit = ~0;
+ break;
+ default:
+ if(n < 0)
+ hit |= (1L<<(-(n+1)));
+ else
+ errormsg(SH_DICT,2, e_notimp, opt_info.name);
+ break;
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ opt_info.disc = 0;
+ limit = argv[opt_info.index];
+ /* default to -f */
+ if(noargs=(hit==0))
+ for(n=0; shtab_limits[n].option; n++)
+ if(shtab_limits[n].index == RLIMIT_FSIZE)
+ {
+ hit |= (1L<<n);
+ break;
+ }
+ /* only one option at a time for setting */
+ label = (hit&(hit-1));
+ if(error_info.errors || (limit && label) || argc>opt_info.index+1)
+ errormsg(SH_DICT,ERROR_usage(2),optusage((char*)0));
+ if(mode==0)
+ mode = (HARD|SOFT);
+ for(tp = shtab_limits; tp->option && hit; tp++,hit>>=1)
+ {
+ if(!(hit&1))
+ continue;
+ nosupport = (n = tp->index) == RLIMIT_UNKNOWN;
+ unit = shtab_units[tp->type];
+ if(limit)
+ {
+ if(shp->subshell)
+ sh_subfork();
+ if(strcmp(limit,e_unlimited)==0)
+ i = INFINITY;
+ else
+ {
+ char *last;
+ if((i=sh_strnum(limit,&last,2))==INFINITY || *last)
+ errormsg(SH_DICT,ERROR_system(1),e_number,limit);
+ i *= unit;
+ }
+ if(nosupport)
+ errormsg(SH_DICT,ERROR_system(1),e_readonly,tp->name);
+ else
+ {
+#ifdef _lib_getrlimit
+ if(getrlimit(n,&rlp) <0)
+ errormsg(SH_DICT,ERROR_system(1),e_number,limit);
+ if(mode&HARD)
+ rlp.rlim_max = i;
+ if(mode&SOFT)
+ rlp.rlim_cur = i;
+ if(setrlimit(n,&rlp) <0)
+ errormsg(SH_DICT,ERROR_system(1),e_overlimit,limit);
+#else
+ if((i=vlimit(n,i)) < 0)
+ errormsg(SH_DICT,ERROR_system(1),e_number,limit);
+#endif /* _lib_getrlimit */
+ }
+ }
+ else
+ {
+ if(!nosupport)
+ {
+#ifdef _lib_getrlimit
+ if(getrlimit(n,&rlp) <0)
+ errormsg(SH_DICT,ERROR_system(1),e_number,limit);
+ if(mode&HARD)
+ i = rlp.rlim_max;
+ if(mode&SOFT)
+ i = rlp.rlim_cur;
+#else
+# ifdef _lib_ulimit
+ n--;
+# endif /* _lib_ulimit */
+ i = -1;
+ if((i=vlimit(n,i)) < 0)
+ errormsg(SH_DICT,ERROR_system(1),e_number,limit);
+#endif /* _lib_getrlimit */
+ }
+ if(label)
+ {
+ if(tp->type != LIM_COUNT)
+ sfsprintf(tmp,sizeof(tmp),"%s (%ss)", tp->description, e_units[tp->type]);
+ else
+ sfsprintf(tmp,sizeof(tmp),"%s", tp->name);
+ sfprintf(sfstdout,"%-30s (-%c) ",tmp,tp->option);
+ }
+ if(nosupport)
+ {
+ if(!tp->conf || !*(conf = astconf(tp->conf, NiL, NiL)))
+ conf = (char*)e_nosupport;
+ sfputr(sfstdout,conf,'\n');
+ }
+ else if(i!=INFINITY || noargs)
+ {
+ if(!noargs)
+ i += (unit-1);
+ sfprintf(sfstdout,"%I*d\n",sizeof(i),i/unit);
+ }
+ else
+ sfputr(sfstdout,e_unlimited,'\n');
+ }
+ }
+ return(0);
+}
+#endif /* _no_ulimit */
diff --git a/usr/src/lib/libshell/common/bltins/umask.c b/usr/src/lib/libshell/common/bltins/umask.c
new file mode 100644
index 0000000000..a3f0072363
--- /dev/null
+++ b/usr/src/lib/libshell/common/bltins/umask.c
@@ -0,0 +1,98 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * umask [-S] [mask]
+ *
+ * David Korn
+ * AT&T Labs
+ * research!dgk
+ *
+ */
+
+#include <ast.h>
+#include <sfio.h>
+#include <error.h>
+#include <ctype.h>
+#include <ls.h>
+#include <shell.h>
+#include "builtins.h"
+#ifndef SH_DICT
+# define SH_DICT "libshell"
+#endif
+
+int b_umask(int argc,char *argv[],void *extra)
+{
+ register char *mask;
+ register int flag = 0, sflag = 0;
+ NOT_USED(extra);
+ while((argc = optget(argv,sh_optumask))) switch(argc)
+ {
+ case 'S':
+ sflag++;
+ break;
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s",opt_info.arg);
+ break;
+ }
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+ argv += opt_info.index;
+ if(mask = *argv)
+ {
+ register int c;
+ if(isdigit(*mask))
+ {
+ while(c = *mask++)
+ {
+ if (c>='0' && c<='7')
+ flag = (flag<<3) + (c-'0');
+ else
+ errormsg(SH_DICT,ERROR_exit(1),e_number,*argv);
+ }
+ }
+ else
+ {
+ char *cp = mask;
+ flag = umask(0);
+ c = strperm(cp,&cp,~flag);
+ if(*cp)
+ {
+ umask(flag);
+ errormsg(SH_DICT,ERROR_exit(1),e_format,mask);
+ }
+ flag = (~c&0777);
+ }
+ umask(flag);
+ }
+ else
+ {
+ umask(flag=umask(0));
+ if(sflag)
+ sfprintf(sfstdout,"%s\n",fmtperm(~flag&0777));
+ else
+ sfprintf(sfstdout,"%0#4o\n",flag);
+ }
+ return(0);
+}
+
diff --git a/usr/src/lib/libshell/common/bltins/whence.c b/usr/src/lib/libshell/common/bltins/whence.c
new file mode 100644
index 0000000000..7d05a741d6
--- /dev/null
+++ b/usr/src/lib/libshell/common/bltins/whence.c
@@ -0,0 +1,273 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * command [-pvVx] name [arg...]
+ * whence [-afvp] name...
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#include "defs.h"
+#include <error.h>
+#include "shtable.h"
+#include "name.h"
+#include "path.h"
+#include "shlex.h"
+#include "builtins.h"
+
+#define P_FLAG 1
+#define V_FLAG 2
+#define A_FLAG 4
+#define F_FLAG 010
+#define X_FLAG 020
+
+static int whence(Shell_t *,char**, int);
+
+/*
+ * command is called with argc==0 when checking for -V or -v option
+ * In this case return 0 when -v or -V or unknown option, otherwise
+ * the shift count to the command is returned
+ */
+int b_command(register int argc,char *argv[],void *extra)
+{
+ register int n, flags=0;
+ register Shell_t *shp = (Shell_t*)extra;
+ opt_info.index = opt_info.offset = 0;
+ while((n = optget(argv,sh_optcommand))) switch(n)
+ {
+ case 'p':
+ if(sh_isoption(SH_RESTRICTED))
+ errormsg(SH_DICT,ERROR_exit(1),e_restricted,"-p");
+ sh_onstate(SH_DEFPATH);
+ break;
+ case 'v':
+ flags |= X_FLAG;
+ break;
+ case 'V':
+ flags |= V_FLAG;
+ break;
+ case 'x':
+ shp->xargexit = 1;
+ break;
+ case ':':
+ if(argc==0)
+ return(0);
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ if(argc==0)
+ return(0);
+ errormsg(SH_DICT,ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ if(argc==0)
+ return(flags?0:opt_info.index);
+ argv += opt_info.index;
+ if(error_info.errors || !*argv)
+ errormsg(SH_DICT,ERROR_usage(2),"%s", optusage((char*)0));
+ return(whence(shp,argv, flags));
+}
+
+/*
+ * for the whence command
+ */
+int b_whence(int argc,char *argv[],void *extra)
+{
+ register int flags=0, n;
+ register Shell_t *shp = (Shell_t*)extra;
+ NOT_USED(argc);
+ if(*argv[0]=='t')
+ flags = V_FLAG;
+ while((n = optget(argv,sh_optwhence))) switch(n)
+ {
+ case 'a':
+ flags |= A_FLAG;
+ /* FALL THRU */
+ case 'v':
+ flags |= V_FLAG;
+ break;
+ case 'f':
+ flags |= F_FLAG;
+ break;
+ case 'p':
+ flags |= P_FLAG;
+ break;
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argv += opt_info.index;
+ if(error_info.errors || !*argv)
+ errormsg(SH_DICT,ERROR_usage(2),optusage((char*)0));
+ return(whence(shp, argv, flags));
+}
+
+static int whence(Shell_t *shp,char **argv, register int flags)
+{
+ register const char *name;
+ register Namval_t *np;
+ register const char *cp;
+ register int aflag,r=0;
+ register const char *msg;
+ int tofree;
+ Dt_t *root;
+ Namval_t *nq;
+ char *notused;
+#ifdef PATH_BFPATH
+ Pathcomp_t *pp;
+#endif
+ int notrack = 1;
+ while(name= *argv++)
+ {
+ tofree=0;
+ aflag = ((flags&A_FLAG)!=0);
+ cp = 0;
+ np = 0;
+#ifdef PATH_BFPATH
+ pp = 0;
+#endif
+ if(flags&P_FLAG)
+ goto search;
+ /* reserved words first */
+ if(sh_lookup(name,shtab_reserved))
+ {
+ sfprintf(sfstdout,"%s%s\n",name,(flags&V_FLAG)?sh_translate(is_reserved):"");
+ if(!aflag)
+ continue;
+ aflag++;
+ }
+ /* non-tracked aliases */
+ if((np=nv_search(name,shp->alias_tree,0))
+ && !nv_isnull(np) && !(notrack=nv_isattr(np,NV_TAGGED))
+ && (cp=nv_getval(np)))
+ {
+ if(flags&V_FLAG)
+ {
+ if(nv_isattr(np,NV_EXPORT))
+ msg = sh_translate(is_xalias);
+ else
+ msg = sh_translate(is_alias);
+ sfprintf(sfstdout,msg,name);
+ }
+ sfputr(sfstdout,sh_fmtq(cp),'\n');
+ if(!aflag)
+ continue;
+ cp = 0;
+ aflag++;
+ }
+ /* built-ins and functions next */
+ root = (flags&F_FLAG)?shp->bltin_tree:shp->fun_tree;
+ if(np= nv_bfsearch(name, root, &nq, &notused))
+ {
+ if(is_abuiltin(np) && nv_isnull(np))
+ goto search;
+ cp = "";
+ if(flags&V_FLAG)
+ {
+ if(nv_isnull(np))
+ cp = sh_translate(is_ufunction);
+ else if(is_abuiltin(np))
+ cp = sh_translate(is_builtin);
+ else
+ cp = sh_translate(is_function);
+ }
+ sfprintf(sfstdout,"%s%s\n",name,cp);
+ if(!aflag)
+ continue;
+ cp = 0;
+ aflag++;
+ }
+ search:
+ if(sh_isstate(SH_DEFPATH))
+ {
+ cp=0;
+ notrack=1;
+ }
+#ifdef PATH_BFPATH
+ if(path_search(name,pp,2))
+ cp = name;
+ else
+ {
+ cp = stakptr(PATH_OFFSET);
+ if(*cp==0)
+ cp = 0;
+ else if(*cp!='/')
+ {
+ cp = path_fullname(cp);
+ tofree=1;
+ }
+ }
+#else
+ if(path_search(name,cp,2))
+ cp = name;
+ else
+ cp = shp->lastpath;
+ shp->lastpath = 0;
+#endif
+ if(cp)
+ {
+ if(flags&V_FLAG)
+ {
+ if(*cp!= '/')
+ {
+#ifdef PATH_BFPATH
+ if(!np && (np=nv_search(name,shp->track_tree,0)))
+ sfprintf(sfstdout,"%s %s %s/%s\n",name,sh_translate(is_talias),path_pwd(0),cp);
+ else if(!np || nv_isnull(np))
+#else
+ if(!np || nv_isnull(np))
+#endif
+ sfprintf(sfstdout,"%s%s\n",name,sh_translate(is_ufunction));
+ continue;
+ }
+ sfputr(sfstdout,sh_fmtq(name),' ');
+ /* built-in version of program */
+ if(*cp=='/' && (np=nv_search(cp,shp->bltin_tree,0)))
+ msg = sh_translate(is_builtver);
+ /* tracked aliases next */
+ else if(!notrack || strchr(name,'/'))
+ msg = sh_translate("is");
+ else
+ msg = sh_translate(is_talias);
+ sfputr(sfstdout,msg,' ');
+ }
+ sfputr(sfstdout,sh_fmtq(cp),'\n');
+ if(tofree)
+ free((char*)cp);
+ }
+ else if(aflag<=1)
+ {
+ r |= 1;
+ if(flags&V_FLAG)
+ {
+ sfprintf(sfstdout,sh_translate(e_found),sh_fmtq(name));
+ sfputc(sfstdout,'\n');
+ }
+ }
+ }
+ return(r);
+}
+
diff --git a/usr/src/lib/libshell/common/builtins.mm b/usr/src/lib/libshell/common/builtins.mm
new file mode 100644
index 0000000000..5713c48eab
--- /dev/null
+++ b/usr/src/lib/libshell/common/builtins.mm
@@ -0,0 +1,631 @@
+.ds DT July 9, 1993 \" use troff -mm
+.nr C 3
+.nr N 2
+.SA 1 \" right justified
+.TL "311466-6713" "49059-6" \" charging case filing case
+Guidelines for writing \f5ksh-93\fP built-in commands
+.AU "David G. Korn" DGK FP 11267 8062 D-237 "(research!dgk)"
+.AF
+.TM 11267-930???-93 \" technical memo + TM numbers
+.MT 4
+.AS 2 \" abstract start for TM
+One of the features of \f5ksh93\fP, the latest version of \f5ksh\fP,
+is the ability to add built-in commands at run time.
+This feature only works on operating systems that have the ability
+to load and link code into the current process at run time.
+Some examples of the systems that have this feature
+are System V Release 4, Solaris, Sun OS, HP-UX Release 8 and above,
+AIX 3.2 and above, and Microsoft Windows systems.
+.P
+This memo describes how to write and compile programs
+to can be loaded into \f5ksh\fP at run time as built-in
+commands.
+.AE \" abstract end
+.OK Shell "Command interpreter" Language UNIX \" keyword
+.MT 1 \" memo type
+.H 1 INTRODUCTION
+A built-in command is executed without creating a separate process.
+Instead, the command is invoked as a C function by \f5ksh\fP.
+If this function has no side effects in the shell process,
+then the behavior of this built-in is identical to that of
+the equivalent stand-alone command. The primary difference
+in this case is performance. The overhead of process creation
+is eliminated. For commands of short duration, the effect
+can be dramatic. For example, on SUN OS 4.1, the time do
+run \f5wc\fP on a small file of about 1000 bytes, runs
+about 50 times faster as a built-in command.
+.P
+In addition, built-in commands that have side effects on the
+shell environment can be written.
+This is usually done to extend the application domain for
+shell programming. For example, an X-windows extension
+that makes heavy use of the shell variable namespace
+was added as a group of built-ins commands that
+are added at run time.
+The result is a windowing shell that can be used to write
+X-windows applications.
+.P
+While there are definite advantages to adding built-in
+commands, there are some disadvantages as well.
+Since the built-in command and \f5ksh\fP share the same
+address space, a coding error in the built-in program
+may affect the behavior of \f5ksh\fP; perhaps causing
+it to core dump or hang.
+Debugging is also more complex since your code is now
+a part of a larger entity.
+The isolation provided by a separate process
+guarantees that all resources used by the command
+will be freed when the command completes.
+Also, since the address space of \f5ksh\fP will be larger,
+this may increase the time it takes \f5ksh\fP to fork() and
+exec() a non-builtin command.
+It makes no sense to add a built-in command that takes
+a long time to run or that is run only once, since the performance
+benefits will be negligible.
+Built-ins that have side effects in the current shell
+environment have the disadvantage of increasing the
+coupling between the built-in and \f5ksh\fP making
+the overall system less modular and more monolithic.
+.P
+Despite these drawbacks, in many cases extending
+\f5ksh\fP by adding built-in
+commands makes sense and allows reuse of the shell
+scripting ability in an application specific domain.
+This memo describes how to write \f5ksh\fP extensions.
+.H 1 "WRITING BUILT-IN COMMANDS"
+There is a development kit available for writing \f5ksh\fP
+built-ins. The development kit has three directories,
+\f5include\fP, \f5lib\fP, and \f5bin\fP.
+The \f5include\fP directory contains a sub-directory
+named \f5ast\fP that contains interface prototypes
+for functions that you can call from built-ins. The \f5lib\fP
+directory contains the \fBast\fP library\*F
+.FS
+\fBast\fP stands for Advanced Software Technology
+.FE
+and a library named \fBlibcmd\fP that contains a version
+of several of the standard POSIX\*(Rf
+.RS
+.I "POSIX \- Part 2: Shell and Utilities,"
+IEEE Std 1003.2-1992, ISO/IEC 9945-2:1993.
+.RF
+utilities that can be made run time built-ins.
+It is best to set the value of the environment variable
+\fB\s-1PACKAGE_\s+1ast\fP to the pathname of the directory
+containing the development kit.
+Users of \f5nmake\fP\*(Rf
+.RS
+Glenn Fowler,
+Nmake reference needed
+.RF
+2.3 and above will then be able to
+use the rule
+.nf
+.in .5i
+\f5:PACKAGE: ast\fP
+.in
+.fi
+in their makefiles and not have to specify any \f5-I\fP switches
+to the compiler.
+.P
+A built-in command has a calling convention similar to
+the \f5main\fP function of a program,
+.nf
+.in .5i
+\f5int main(int argc, char *argv[])\fP.
+.in
+.fi
+However, instead of \f5main\fP, you must use the function name
+\f5b_\fP\fIname\fP, where \fIname\fP is the name
+of the built-in you wish to define.
+The built-in function takes a third
+\f5void*\fP argument which you can define as \f5NULL\fP.
+Instead of \f5exit\fP, you need to use \f5return\fP
+to terminate your command.
+The return value, will become the exit status of the command.
+.P
+The steps necessary to create and add a run time built-in are
+illustrated in the following simple example.
+Suppose, you wish to add a built-in command named \f5hello\fP
+which requires one argument and prints the word hello followed
+by its argument. First, write the following program in the file
+\f5hello.c\fP:
+.nf
+.in .5i
+\f5#include <stdio.h>
+int b_hello(int argc, char *argv[], void *context)
+{
+ if(argc != 2)
+ {
+ fprintf(stderr,"Usage: hello arg\en");
+ return(2);
+ }
+ printf("hello %s\en",argv[1]);
+ return(0);
+}\fP
+.in
+.fi
+.P
+Next, the program needs to be compiled.
+On some systems it is necessary to specify a compiler
+option to produce position independent code
+for dynamic linking.
+If you do not compile with \f5nmake\fP
+it is important to specify the a special include directory
+when compiling built-ins.
+.nf
+.in .5i
+\f5cc -pic -I$PACKAGE_ast/include -c hello.c\fP
+.in
+.fi
+since the special version of \f5<stdio.h>\fP
+in the development kit is required.
+This command generates \f5hello.o\fP in the current
+directory.
+.P
+On some systems, you cannot load \f5hello.o\fP directly,
+you must build a shared library instead.
+Unfortunately, the method for generating a shared library
+differs with operating system.
+However, if you are building with the AT\&T \f5nmake\fP
+program you can use the \f5:LIBRARY:\fP rule to specify
+this in a system independent fashion.
+In addition, if you have several built-ins, it is desirable
+to build a shared library that contains them all.
+.P
+The final step is using the built-in.
+This can be done with the \f5ksh\fP command \f5builtin\fP.
+To load the shared library \f5hello.so\fP and to add
+the built-in \f5hello\fP, invoke the command,
+.nf
+.in .5i
+\f5builtin -f hello hello\fP
+.in
+.fi
+The suffix for the shared library can be omitted in
+which case the shell will add an appropriate suffix
+for the system that it is loading from.
+Once this command has been invoked, you can invoke \f5hello\fP
+as you do any other command.
+.P
+It is often desirable to make a command \fIbuilt-in\fP
+the first time that it is referenced. The first
+time \f5hello\fP is invoked, \f5ksh\fP should load and execute it,
+whereas for subsequent invocations \f5ksh\fP should just execute the built-in.
+This can be done by creating a file named \f5hello\fP
+with the following contents:
+.nf
+.in .5i
+\f5function hello
+{
+ unset -f hello
+ builtin -f hello hello
+ hello "$@"
+}\fP
+.in
+.fi
+This file \f5hello\fP needs to be placed in a directory that is
+in your \fB\s-1FPATH\s+1\fP variable. In addition, the full
+pathname for \f5hello.so\fP should be used in this script
+so that the run time loader will be able to find this shared library
+no matter where the command \f5hello\fP is invoked.
+.H 1 "CODING REQUIREMENTS AND CONVENTIONS"
+As mentioned above, the entry point for built-ins must be of
+the form \f5b_\fP\fIname\fP.
+Your built-ins can call functions from the standard C library,
+the \fBast\fP library, interface functions provided by \f5ksh\fP,
+and your own functions.
+You should avoid using any global symbols beginning with
+.BR sh_ ,
+.BR nv_ ,
+and
+.B ed_
+since these are used by \f5ksh\fP itself.
+In addition, \f5#define\fP constants in \f5ksh\fP interface
+files, use symbols beginning with \fBSH_\fP to that you should
+avoid using names beginning with \fBSH_\fP.
+.H 2 "Header Files"
+The development kit provides a portable interface
+to the C library and to libast.
+The header files in the development kit are compatible with
+K&R C\*(Rf,
+.RS
+Brian W. Kernighan and Dennis M. Ritchie,
+.IR "The C Programming Language" ,
+Prentice Hall, 1978.
+.RF
+ANSI-C\*(Rf,
+.RS
+American National Standard for Information Systems \- Programming
+Language \- C, ANSI X3.159-1989.
+.RF
+and C++\*(Rf.
+.RS
+Bjarne Stroustroup,
+.IR "C++" ,
+Addison Wesley, xxxx
+.RF
+.P
+The best thing to do is to include the header file \f5<shell.h>\fP.
+This header file causes the \f5<ast.h>\fP header, the
+\f5<error.h>\fP header and the \f5<stak.h>\fP
+header to be included as well as defining prototypes
+for functions that you can call to get shell
+services for your builtins.
+The header file \f5<ast.h>\fP
+provides prototypes for many \fBlibast\fP functions
+and all the symbol and function definitions from the
+ANSI-C headers, \f5<stddef.h>\fP,
+\f5<stdlib.h>\fP, \f5<stdarg.h>\fP, \f5<limits.h>\fP,
+and \f5<string.h>\fP.
+It also provides all the symbols and definitions for the
+POSIX\*(Rf
+.RS
+.I "POSIX \- Part 1: System Application Program Interface,"
+IEEE Std 1003.1-1990, ISO/IEC 9945-1:1990.
+.RF
+headers \f5<sys/types.h>\fP, \f5<fcntl.h>\fP, and
+\f5<unistd.h>\fP.
+You should include \f5<ast.h>\fP instead of one or more of
+these headers.
+The \f5<error.h>\fP header provides the interface to the error
+and option parsing routines defined below.
+The \f5<stak.h>\fP header provides the interface to the memory
+allocation routines described below.
+.P
+Programs that want to use the information in \f5<sys/stat.h>\fP
+should include the file \f5<ls.h>\fP instead.
+This provides the complete POSIX interface to \f5stat()\fP
+related functions even on non-POSIX systems.
+.P
+.H 2 "Input/Output"
+\f5ksh\fP uses \fBsfio\fP,
+the Safe/Fast I/O library\*(Rf,
+.RS
+David Korn and Kiem-Phong Vo,
+.IR "SFIO - A Safe/Fast Input/Output library,"
+Proceedings of the Summer Usenix,
+pp. , 1991.
+.RF
+to perform all I/O operations.
+The \fBsfio\fP library, which is part of \fBlibast\fP,
+provides a superset of the functionality provided by the standard
+I/O library defined in ANSI-C.
+If none of the additional functionality is required,
+and if you are not familiar with \fBsfio\fP and
+you do not want to spend the time learning it,
+then you can use \fBsfio\fP via the \fBstdio\fP library
+interface. The development kit contains the header \f5<stdio.h>\fP
+which maps \fBstdio\fP calls to \fBsfio\fP calls.
+In most instances the mapping is done
+by macros or inline functions so that there is no overhead.
+The man page for the \fBsfio\fP library is in an Appendix.
+.P
+However, there are some very nice extensions and
+performance improvements in \fBsfio\fP
+and if you plan any major extensions I recommend
+that you use it natively.
+.H 2 "Error Handling"
+For error messages it is best to use the \fBast\fP library
+function \f5errormsg()\fP rather that sending output to
+\f5stderr\fP or the equivalent \f5sfstderr\fP directly.
+Using \f5errormsg()\fP will make error message appear
+more uniform to the user.
+Furthermore, using \f5errormsg()\fP should make it easier
+to do error message translation for other locales
+in future versions of \f5ksh\fP.
+.P
+The first argument to
+\f5errormsg()\fP specifies the dictionary in which the string
+will be searched for translation.
+The second argument to \f5errormsg()\fP contains that error type
+and value. The third argument is a \fIprintf\fP style format
+and the remaining arguments are arguments to be printed
+as part of the message. A new-line is inserted at the
+end of each message and therefore, should not appear as
+part of the format string.
+The second argument should be one of the following:
+.VL .5i
+.LI \f5ERROR_exit(\fP\fIn\fP\f5)\fP:
+If \fIn\fP is not-zero, the builtin will exit value \fIn\fP after
+printing the message.
+.LI \f5ERROR_system(\fP\fIn\fP\f5)\fP:
+Exit builtin with exit value \fIn\fP after printing the message.
+The message will display the message corresponding to \f5errno\fP
+enclosed within \f5[\ ]\fP at the end of the message.
+.LI \f5ERROR_usage(\fP\fIn\fP\f5)\fP:
+Will generate a usage message and exit. If \fIn\fP is non-zero,
+the exit value will be 2. Otherwise the exit value will be 0.
+.LI \f5ERROR_debug(\fP\fIn\fP\f5)\fP:
+Will print a level \fIn\fP debugging message and will then continue.
+.LI \f5ERROR_warn(\fP\fIn\fP\f5)\fP:
+Prints a warning message. \fIn\fP is ignored.
+.H 2 "Option Parsing"
+The first thing that a built-in should do is to check
+the arguments for correctness and to print any usage
+messages on standard error.
+For consistency with the rest of \f5ksh\fP, it is best
+to use the \f5libast\fP functions \f5optget()\fP and
+\f5optusage()\fPfor this
+purpose.
+The header \f5<error.h>\fP included prototypes for
+these functions.
+The \f5optget()\fP function is similar to the
+System V C library function \f5getopt()\fP,
+but provides some additional capabilities.
+Built-ins that use \f5optget()\fP provide a more
+consistent user interface.
+.P
+The \f5optget()\fP function is invoked as
+.nf
+.in .5i
+\f5int optget(char *argv[], const char *optstring)\fP
+.in
+.fi
+where \f5argv\fP is the argument list and \f5optstring\fP
+is a string that specifies the allowable arguments and
+additional information that is used to format \fIusage\fP
+messages.
+In fact a complete man page in \f5troff\fP or \f5html\fP
+can be generated by passing a usage string as described
+by the \f5getopts\fP command.
+Like \f5getopt()\fP,
+single letter options are represented by the letter itself,
+and options that take a string argument are followed by the \f5:\fP
+character.
+Option strings have the following special characters:
+.VL .5i
+.LI \f5:\fP
+Used after a letter option to indicate that the option
+takes an option argument.
+The variable \f5opt_info.arg\fP will point to this
+value after the given argument is encountered.
+.LI \f5#\fP
+Used after a letter option to indicate that the option
+can only take a numerical value.
+The variable \f5opt_info.num\fP will contain this
+value after the given argument is encountered.
+.LI \f5?\fP
+Used after a \f5:\fP or \f5#\fP (and after the optional \f5?\fP)
+to indicate the the
+preceding option argument is not required.
+.LI \f5[\fP...\f5]\fP
+After a \f5:\fP or \f5#\fP, the characters contained
+inside the brackets are used to identify the option
+argument when generating a \fIusage\fP message.
+.LI \fIspace\fP
+The remainder of the string will only be used when generating
+usage messages.
+.LE
+.P
+The \f5optget()\fP function returns the matching option letter if
+one of the legal option is matched.
+Otherwise, \f5optget()\fP returns
+.VL .5i
+.LI \f5':'\fP
+If there is an error. In this case the variable \f5opt_info.arg\fP
+contains the error string.
+.LI \f50\fP
+Indicates the end of options.
+The variable \f5opt_info.index\fP contains the number of arguments
+processed.
+.LI \f5'?'\fP
+A usage message has been required.
+You normally call \f5optusage()\fP to generate and display
+the usage message.
+.LE
+.P
+The following is an example of the option parsing portion
+of the \f5wc\fP utility.
+.nf
+.in +5
+\f5#include <shell.h>
+while(1) switch(n=optget(argv,"xf:[file]"))
+{
+ case 'f':
+ file = opt_info.arg;
+ break;
+ case ':':
+ error(ERROR_exit(0), opt_info.arg);
+ break;
+ case '?':
+ error(ERROR_usage(2), opt_info.arg);
+ break;
+}\fP
+.in
+.fi
+.H 2 "Storage Management"
+It is important that any memory used by your built-in
+be returned. Otherwise, if your built-in is called frequently,
+\f5ksh\fP will eventually run out of memory.
+You should avoid using \f5malloc()\fP for memory that must
+be freed before returning from you built-in, because by default,
+\f5ksh\fP will terminate you built-in in the event of an
+interrupt and the memory will not be freed.
+.P
+The best way to to allocate variable sized storage is
+through calls to the \fBstak\fP library
+which is included in \fBlibast\fP
+and which is used extensively by \f5ksh\fP itself.
+Objects allocated with the \f5stakalloc()\fP
+function are freed when you function completes
+or aborts.
+The \fBstak\fP library provides a convenient way to
+build variable length strings and other objects dynamically.
+The man page for the \fBstak\fP library is contained
+in the Appendix.
+.P
+Before \f5ksh\fP calls each built-in command, it saves
+the current stack location and restores it after
+it returns.
+It is not necessary to save and restore the stack
+location in the \f5b_\fP entry function,
+but you may want to write functions that use this stack
+are restore it when leaving the function.
+The following coding convention will do this in
+an efficient manner:
+.nf
+.in .5i
+\fIyourfunction\fP\f5()
+{
+ char *savebase;
+ int saveoffset;
+ if(saveoffset=staktell())
+ savebase = stakfreeze(0);
+ \fP...\f5
+ if(saveoffset)
+ stakset(savebase,saveoffset);
+ else
+ stakseek(0);
+}\fP
+.in
+.fi
+.H 1 "CALLING \f5ksh\fP SERVICES"
+Some of the more interesting applications are those that extend
+the functionality of \f5ksh\fP in application specific directions.
+A prime example of this is the X-windows extension which adds
+builtins to create and delete widgets.
+The \fBnval\fP library is used to interface with the shell
+name space.
+The \fBshell\fP library is used to access other shell services.
+.H 2 "The nval library"
+A great deal of power is derived from the ability to use
+portions of the hierarchal variable namespace provided by \f5ksh-93\fP
+and turn these names into active objects.
+.P
+The \fBnval\fP library is used to interface with shell
+variables.
+A man page for this file is provided in an Appendix.
+You need to include the header \f5<nval.h>\fP
+to access the functions defined in the \fBnval\fP library.
+All the functions provided by the \fBnval\fP library begin
+with the prefix \f5nv_\fP.
+Each shell variable is an object in an associative table
+that is referenced by name.
+The type \f5Namval_t*\fP is pointer to a shell variable.
+To operate on a shell variable, you first get a handle
+to the variable with the \f5nv_open()\fP function
+and then supply the handle returned as the first
+argument of the function that provides an operation
+on the variable.
+You must call \f5nv_close()\fP when you are finished
+using this handle so that the space can be freed once
+the value is unset.
+The two most frequent operations are to get the value of
+the variable, and to assign value to the variable.
+The \f5nv_getval()\fP returns a pointer the the
+value of the variable.
+In some cases the pointer returned is to a region that
+will be overwritten by the next \f5nv_getval()\fP call
+so that if the value isn't used immediately, it should
+be copied.
+Many variables can also generate a numeric value.
+The \f5nv_getnum()\fP function returns a numeric
+value for the given variable pointer, calling the
+arithmetic evaluator if necessary.
+.P
+The \f5nv_putval()\fP function is used to assign a new
+value to a given variable.
+The second argument to \f5putval()\fP is the value
+to be assigned
+and the third argument is a \fIflag\fP which
+is used in interpreting the second argument.
+.P
+Each shell variable can have one or more attributes.
+The \f5nv_isattr()\fP is used to test for the existence
+of one or more attributes.
+See the appendix for a complete list of attributes.
+.P
+By default, each shell variable passively stores the string you
+give with with \f5nv_putval()\fP, and returns the value
+with \f5getval()\fP. However, it is possible to turn
+any node into an active entity by assigning functions
+to it that will be called whenever \f5nv_putval()\fP
+and/or \f5nv_getval()\fP is called.
+In fact there are up to five functions that can
+associated with each variable to override the
+default actions.
+The type \f5Namfun_t\fP is used to define these functions.
+Only those that are non-\f5NULL\fP override the
+default actions.
+To override the default actions, you must allocate an
+instance of \f5Namfun_t\fP, and then assign
+the functions that you wish to override.
+The \f5putval()\fP
+function is called by the \f5nv_putval()\fP function.
+A \f5NULL\fP for the \fIvalue\fP argument
+indicates a request to unset the variable.
+The \fItype\fP argument might contain the \f5NV_INTEGER\fP
+bit so you should be prepared to do a conversion if
+necessary.
+The \f5getval()\fP
+function is called by \f5nv_getval()\fP
+value and must return a string.
+The \f5getnum()\fP
+function is called by by the arithmetic evaluator
+and must return double.
+If omitted, then it will call \f5nv_getval()\fP and
+convert the result to a number.
+.P
+The functionality of a variable can further be increased
+by adding discipline functions that
+can be associated with the variable.
+A discipline function allows a script that uses your
+variable to define functions whose name is
+\fIvarname\fP\f5.\fP\fIdiscname\fP
+where \fIvarname\fP is the name of the variable, and \fIdiscname\fP
+is the name of the discipline.
+When the user defines such a function, the \f5settrap()\fP
+function will be called with the name of the discipline and
+a pointer to the parse tree corresponding to the discipline
+function.
+The application determines when these functions are actually
+executed.
+By default, \f5ksh\fP defines \f5get\fP,
+\f5set\fP, and \f5unset\fP as discipline functions.
+.P
+In addition, it is possible to provide a data area that
+will be passed as an argument to
+each of these functions whenever any of these functions are called.
+To have private data, you need to define and allocate a structure
+that looks like
+.nf
+.in .5i
+\f5struct \fIyours\fP
+{
+ Namfun_t fun;
+ \fIyour_data_fields\fP;
+};\fP
+.in
+.fi
+.H 2 "The shell library"
+There are several functions that are used by \f5ksh\fP itself
+that can also be called from built-in commands.
+The man page for these routines are in the Appendix.
+.P
+The \f5sh_addbuiltin()\fP function can be used to add or delete
+builtin commands. It takes the name of the built-in, the
+address of the function that implements the built-in, and
+a \f5void*\fP pointer that will be passed to this function
+as the third agument whenever it is invoked.
+If the function address is \f5NULL\fP, the specified built-in
+will be deleted. However, special built-in functions cannot
+be deleted or modified.
+.P
+The \f5sh_fmtq()\fP function takes a string and returns
+a string that is quoted as necessary so that it can
+be used as shell input.
+This function is used to implement the \f5%q\fP option
+of the shell built-in \f5printf\fP command.
+.P
+The \f5sh_parse()\fP function returns a parse tree corresponding
+to a give file stream. The tree can be executed by supplying
+it as the first argument to
+the \f5sh_trap()\fP function and giving a value of \f51\fP as the
+second argument.
+Alternatively, the \f5sh_trap()\fP function can parse and execute
+a string by passing the string as the first argument and giving \f50\fP
+as the second argument.
+.P
+The \f5sh_isoption()\fP function can be used to set to see whether one
+or more of the option settings is enabled.
diff --git a/usr/src/lib/libshell/common/data/aliases.c b/usr/src/lib/libshell/common/data/aliases.c
new file mode 100644
index 0000000000..577f098f1d
--- /dev/null
+++ b/usr/src/lib/libshell/common/data/aliases.c
@@ -0,0 +1,58 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#include <ast.h>
+#include <signal.h>
+#include "FEATURE/options"
+#include "FEATURE/dynamic"
+#include "shtable.h"
+#include "name.h"
+
+/*
+ * This is the table of built-in aliases. These should be exported.
+ */
+
+const struct shtable2 shtab_aliases[] =
+{
+#if SHOPT_FS_3D
+ "2d", NV_NOFREE, "set -f;_2d",
+#endif /* SHOPT_FS_3D */
+ "autoload", NV_NOFREE, "typeset -fu",
+ "command", NV_NOFREE, "command ",
+ "fc", NV_NOFREE, "hist",
+ "float", NV_NOFREE, "typeset -lE",
+ "functions", NV_NOFREE, "typeset -f",
+ "hash", NV_NOFREE, "alias -t --",
+ "history", NV_NOFREE, "hist -l",
+ "integer", NV_NOFREE, "typeset -li",
+ "nameref", NV_NOFREE, "typeset -n",
+ "nohup", NV_NOFREE, "nohup ",
+ "r", NV_NOFREE, "hist -s",
+ "redirect", NV_NOFREE, "command exec",
+ "source", NV_NOFREE, "command .",
+#ifdef SIGTSTP
+ "stop", NV_NOFREE, "kill -s STOP",
+ "suspend", NV_NOFREE, "kill -s STOP $$",
+#endif /*SIGTSTP */
+ "times", NV_NOFREE, "{ { time;} 2>&1;}",
+ "type", NV_NOFREE, "whence -v",
+ "", 0, (char*)0
+};
+
diff --git a/usr/src/lib/libshell/common/data/bash_pre_rc.sh b/usr/src/lib/libshell/common/data/bash_pre_rc.sh
new file mode 100644
index 0000000000..98e6aba833
--- /dev/null
+++ b/usr/src/lib/libshell/common/data/bash_pre_rc.sh
@@ -0,0 +1,221 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+#
+# bash compatibility startup script
+#
+# Author:
+# Karsten Fleischer
+# Omnium Software Engineering
+# An der Luisenburg 7
+# D-51379 Leverkusen
+# Germany
+#
+# <K.Fleischer@omnium.de>
+#
+
+alias declare=typeset
+
+nameref FUNCNAME=.sh.fun
+integer SHLVL
+export SHLVL
+SHLVL+=1
+
+if [[ ! $EUID ]]
+then EUID=$(id -u)
+ readonly EUID
+fi
+
+if [[ ! $UID ]]
+then UID=$(id -u)
+ readonly UID
+fi
+
+readonly SHELLOPTS
+if ! shopt -qo restricted; then
+ IFS=:
+ for i in $SHELLOPTS
+ do
+ [[ -n "$i" ]] && set -o $i
+ done
+ unset IFS
+fi
+function SHELLOPTS.get
+{
+ .sh.value=$(shopt -so)
+ .sh.value=${.sh.value//+([[:space:]])on*([[:space:]])/:}
+ .sh.value=${.sh.value%:}
+}
+
+set -A GROUPS $(id -G)
+function GROUPS.set
+{
+ return 1
+}
+function GROUPS.unset
+{
+ unset -f GROUPS.set
+ unset -f GROUPS.unset
+}
+
+typeset -A DIRSTACK
+function DIRSTACK.get
+{
+ set -A .sh.value $(dirs)
+}
+function DIRSTACK.set
+{
+ integer index
+ index=_push_max-.sh.subscript
+ (( index == _push_max || index < _push_top )) && return
+ _push_stack[index]=${.sh.value}
+}
+function DIRSTACK.unset
+{
+ unset -f DIRSTACK.get
+ unset -f DIRSTACK.set
+ unset -f DIRSTACK.unset
+}
+
+function PS1.set
+{
+ typeset prefix remaining=${.sh.value} var= n= k=
+ while [[ $remaining ]]
+ do prefix=${remaining%%'\'*}
+ remaining=${remaining#$prefix}
+ var+="$prefix"
+ case ${remaining:1:1} in
+ t) var+="\$(printf '%(%H:%M:%S)T')";;
+ d) var+="\$(printf '%(%a %b:%d)T')";;
+ n) var+=$'\n';;
+ s) var+=ksh;;
+ w) var+="\$(pwd)";;
+ W) var+="\$(basename \"\$(pwd)\")";;
+ u) var+=$USER;;
+ h) var+=$(hostname);;
+ '#') var+=!;;
+ !) var+=!;;
+ '$') if (( $(id -u) == 0 ))
+ then var+='#'
+ else var+='$'
+ fi;;
+ '\') var+='\\';;
+ '['|']') ;;
+ [0-7]) case ${remaining:1:3} in
+ [0-7][0-7][0-7])
+ k=4;;
+ [0-7][0-7])
+ k=3;;
+ *) k=2;;
+ esac
+ eval n="\$'"${remaining:0:k}"'"
+ var+=$n
+ remaining=${remaining:k}
+ continue
+ ;;
+ "") ;;
+ *) var+='\'${remaining:0:2};;
+ esac
+ remaining=${remaining:2}
+ done
+ .sh.value=$var
+}
+function logout
+{
+ if shopt -q login_shell; then
+ exit
+ else
+ print ${BASH##*/}: $0: not login shell: use 'exit' >&2
+ return 1
+ fi
+}
+PS1="bash$ "
+
+function source
+{
+ if ! shopt -qpo posix; then
+ unset OPATH
+ typeset OPATH=$PATH
+ typeset PATH=$PATH
+ if shopt -q sourcepath; then
+ PATH=$OPATH:.
+ else
+ PATH=.
+ fi
+ fi
+ . "$@"
+}
+unalias .
+alias .=source
+
+alias enable=builtin
+
+function help
+{
+ man=--man
+ [[ $1 == -s ]] && man=--short && shift
+ b=$(builtin)
+ for i
+ do
+ for j in $b
+ do
+ [[ $i == $j ]] && $j $man
+ done
+ done
+}
+
+function cd
+{
+
+ local msg
+ local args
+ local i
+ local a
+ local ret
+
+ if ! shopt -q cdable_vars; then
+ command cd "$@"
+ else
+ msg=$(command cd "$@" 2>&1)
+ ret=$?
+ if [[ $ret != 0 ]]; then
+ for i
+ do
+ case $i in
+ -*) args="$args $i" ;;
+ */*) args="$args $i" ;;
+ *) eval a="$"$i
+ if [[ -n $a ]]; then args="$args $a"
+ else args="$args $i"
+ fi
+ ;;
+ esac
+ done
+
+ command cd $args
+ else
+ print -- $msg
+ return $ret
+ fi
+ fi
+}
+
+typeset BASH=$0
+! shopt -qo posix && HISTFILE=~/.bash_history
+HOSTNAME=$(hostname)
diff --git a/usr/src/lib/libshell/common/data/builtins.c b/usr/src/lib/libshell/common/data/builtins.c
new file mode 100644
index 0000000000..ddbe5c74ea
--- /dev/null
+++ b/usr/src/lib/libshell/common/data/builtins.c
@@ -0,0 +1,1833 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <shell.h>
+#include <signal.h>
+#include "defs.h"
+#include "shtable.h"
+#include "ulimit.h"
+#include "name.h"
+#include "version.h"
+#if KSHELL
+# include "builtins.h"
+# include "jobs.h"
+# include "FEATURE/cmds"
+# define bltin(x) (b_##x)
+ /* The following is for builtins that do not accept -- options */
+# define Bltin(x) (B_##x)
+#else
+# define bltin(x) 0
+#endif
+
+#ifndef SH_CMDLIB_DIR
+# define SH_CMDLIB_DIR "/opt/ast/bin"
+#endif
+#if defined(SHOPT_CMDLIB_DIR) && !defined(SHOPT_CMDLIB_HDR)
+# define SHOPT_CMDLIB_HDR <cmdlist.h>
+#endif
+#define Q(f) #f /* libpp cpp workaround -- fixed 2005-04-11 */
+#define CMDLIST(f) SH_CMDLIB_DIR "/" Q(f), NV_BLTIN|NV_NOFREE, bltin(f),
+
+#undef basename
+#undef dirname
+
+/*
+ * The order up through "[" is significant
+ */
+const struct shtable3 shtab_builtins[] =
+{
+ "login", NV_BLTIN|BLT_ENV|BLT_SPC, Bltin(login),
+ "exec", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(exec),
+ "set", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(set),
+ ":", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(true),
+ "true", NV_BLTIN|BLT_ENV, bltin(true),
+ "command", NV_BLTIN|BLT_ENV|BLT_EXIT, bltin(command),
+ "cd", NV_BLTIN|BLT_ENV, bltin(cd),
+ "break", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(break),
+ "continue", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(break),
+ "typeset", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_DCL,bltin(typeset),
+ "test", NV_BLTIN|BLT_ENV|NV_NOFREE, bltin(test),
+ "[", NV_BLTIN|BLT_ENV, bltin(test),
+ "let", NV_BLTIN|BLT_ENV, bltin(let),
+ "export", NV_BLTIN|BLT_SPC|BLT_DCL, bltin(readonly),
+#if SHOPT_BASH
+ "local", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_DCL,bltin(typeset),
+#endif
+#if _bin_newgrp || _usr_bin_newgrp
+ "newgrp", NV_BLTIN|BLT_ENV|BLT_SPC, Bltin(login),
+#endif /* _bin_newgrp || _usr_bin_newgrp */
+ ".", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(dot_cmd),
+ "alias", NV_BLTIN|BLT_SPC|BLT_DCL, bltin(alias),
+ "hash", NV_BLTIN|BLT_SPC|BLT_DCL, bltin(alias),
+ "exit", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(return),
+ "eval", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_EXIT,bltin(eval),
+ "fc", NV_BLTIN|BLT_ENV|BLT_EXIT, bltin(hist),
+ "hist", NV_BLTIN|BLT_ENV|BLT_EXIT, bltin(hist),
+ "readonly", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_DCL,bltin(readonly),
+ "return", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(return),
+ "shift", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(shift),
+ "trap", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(trap),
+ "unalias", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(unalias),
+ "unset", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(unset),
+ "builtin", NV_BLTIN, bltin(builtin),
+#if SHOPT_ECHOPRINT
+ "echo", NV_BLTIN|BLT_ENV, bltin(print),
+#else
+ "echo", NV_BLTIN|BLT_ENV, Bltin(echo),
+#endif /* SHOPT_ECHOPRINT */
+#ifdef JOBS
+# ifdef SIGTSTP
+ "bg", NV_BLTIN|BLT_ENV, bltin(bg),
+ "fg", NV_BLTIN|BLT_ENV|BLT_EXIT, bltin(bg),
+ "disown", NV_BLTIN|BLT_ENV, bltin(bg),
+ "kill", NV_BLTIN|BLT_ENV|NV_NOFREE, bltin(kill),
+# else
+ "/bin/kill", NV_BLTIN|BLT_ENV|NV_NOFREE, bltin(kill),
+# endif /* SIGTSTP */
+ "jobs", NV_BLTIN|BLT_ENV, bltin(jobs),
+#endif /* JOBS */
+ "false", NV_BLTIN|BLT_ENV, bltin(false),
+SH_CMDLIB_DIR "/getconf",NV_BLTIN|BLT_ENV, bltin(getconf),
+ "getopts", NV_BLTIN|BLT_ENV, bltin(getopts),
+ "print", NV_BLTIN|BLT_ENV, bltin(print),
+ "printf", NV_BLTIN|NV_NOFREE, bltin(printf),
+ "pwd", NV_BLTIN|NV_NOFREE, bltin(pwd),
+ "read", NV_BLTIN|BLT_ENV, bltin(read),
+ "sleep", NV_BLTIN|NV_NOFREE, bltin(sleep),
+ "alarm", NV_BLTIN, bltin(alarm),
+ "ulimit", NV_BLTIN|BLT_ENV, bltin(ulimit),
+ "umask", NV_BLTIN|BLT_ENV, bltin(umask),
+#ifdef _cmd_universe
+ "universe", NV_BLTIN|BLT_ENV, bltin(universe),
+#endif /* _cmd_universe */
+#if SHOPT_FS_3D
+ "vpath", NV_BLTIN|BLT_ENV, bltin(vpath),
+ "vmap", NV_BLTIN|BLT_ENV, bltin(vpath),
+#endif /* SHOPT_FS_3D */
+ "wait", NV_BLTIN|BLT_ENV|BLT_EXIT, bltin(wait),
+ "type", NV_BLTIN|BLT_ENV, bltin(whence),
+ "whence", NV_BLTIN|BLT_ENV, bltin(whence),
+#ifdef SHOPT_CMDLIB_HDR
+#include SHOPT_CMDLIB_HDR
+#else
+ CMDLIST(basename)
+ CMDLIST(chmod)
+ CMDLIST(dirname)
+ CMDLIST(head)
+ CMDLIST(mkdir)
+ CMDLIST(logname)
+ CMDLIST(cat)
+ CMDLIST(cmp)
+ CMDLIST(cut)
+ CMDLIST(uname)
+ CMDLIST(wc)
+ CMDLIST(sync)
+#endif
+ "", 0, 0
+};
+
+
+const char sh_set[] =
+"[a?Set the export attribute for each variable whose name does not "
+ "contain a \b.\b that you assign a value in the current shell "
+ "environment.]"
+"[b?The shell writes a message to standard error as soon it detects that "
+ "a background job completes rather than waiting until the next prompt.]"
+"[e?A simple command that has an non-zero exit status will cause the shell "
+ "to exit unless the simple command is:]{"
+ "[++?contained in an \b&&\b or \b||\b list.]"
+ "[++?the command immediately following \bif\b, \bwhile\b, or \buntil\b.]"
+ "[++?contained in the pipeline following \b!\b.]"
+"}"
+"[f?Pathname expansion is disabled.]"
+"[h?Obsolete. Causes each command whose name has the syntax of an "
+ "alias to become a tracked aliase when it is first encountered.]"
+"[k?This is obsolete. All arguments of the form \aname\a\b=\b\avalue\a "
+ "are removed and placed in the variable assignment list for "
+ "the command. Ordinarily, variable assignments must precede "
+ "command arguments.]"
+"[m?When enabled, the shell runs background jobs in a separate process "
+ "group and displays a line upon completion. This mode is enabled "
+ "by default for interactive shells on systems that support job "
+ "control.]"
+"[n?The shell reads commands and checks for syntax errors, but does "
+ "not execute the command. Usually specified on command invocation.]"
+"[o]:?[option?If \aoption\a is not specified, the list of options and "
+ "their current settings will be written to standard output. When "
+ "invoked with a \b+\b the options will be written in a format "
+ "that can be reinput to the shell to restore the settings. "
+ "This option can be repeated to enable/disable multiple options. "
+ "The value of \aoption\a must be one of the following:]{"
+ "[+allexport?Equivalent to \b-a\b.]"
+ "[+bgnice?Runs background jobs at lower priorities.]"
+ "[+braceexpand?Equivalent to \b-B\b.] "
+ "[+emacs?Enables/disables \bemacs\b editing mode.]"
+ "[+errexit?Equivalent to \b-e\b.]"
+ "[+globstar?Equivalent to \b-G\b.]"
+ "[+gmacs?Enables/disables \bgmacs\b editing mode. \bgmacs\b "
+ "editing mode is the same as \bemacs\b editing mode "
+ "except for the handling of \b^T\b.]"
+#if SHOPT_BASH
+ "[+hashall?Equivalent to \b-h\b and \b-o trackall\b. Available "
+ "in bash compatibility mode only.]"
+ "[+history?Enable command history. Available in bash "
+ "compatibility mode only. On by default in interactive "
+ "shells.]"
+#endif
+#if SHOPT_HISTEXPAND
+ "[+histexpand?Equivalent to \b-H\b.]"
+#endif
+ "[+ignoreeof?Prevents an interactive shell from exiting on "
+ "reading an end-of-file.]"
+ "[+keyword?Equivalent to \b-k\b.]"
+ "[+markdirs?A trailing \b/\b is appended to directories "
+ "resulting from pathname expansion.]"
+ "[+monitor?Equivalent to \b-m\b.]"
+ "[+multiline?Use multiple lines when editing lines that are "
+ "longer than the window width.]"
+ "[+noclobber?Equivalent to \b-C\b.]"
+ "[+noexec?Equivalent to \b-n\b.]"
+ "[+noglob?Equivalent to \b-f\b.]"
+ "[+nolog?This has no effect. It is provided for backward "
+ "compatibility.]"
+ "[+notify?Equivalent to \b-b\b.]"
+ "[+nounset?Equivalent to \b-u\b.]"
+#if SHOPT_BASH
+ "[+onecmd?Equivalent to \b-t\b. Available in bash compatibility "
+ "mode only.]"
+ "[+physical?Equivalent to \b-P\b. Available in bash "
+ "compatibility mode only.]"
+ "[+posix?Turn on POSIX compatibility. Available in bash "
+ "compatibility mode only. Bash in POSIX mode is not the "
+ "same as ksh.]"
+#endif
+ "[+pipefail?A pipeline will not complete until all components "
+ "of the pipeline have completed, and the exit status "
+ "of the pipeline will be the value of the last "
+ "command to exit with non-zero exit status, or will "
+ "be zero if all commands return zero exit status.]"
+ "[+privileged?Equivalent to \b-p\b.]"
+ "[+showme?Simple commands preceded by a \b;\b will be traced "
+ "as if \b-x\b were enabled but not executed.]"
+ "[+trackall?Equivalent to \b-h\b.]"
+ "[+verbose?Equivalent to \b-v\b.]"
+ "[+vi?Enables/disables \bvi\b editing mode.]"
+ "[+viraw?Does not use canonical input mode when using \bvi\b "
+ "edit mode.]"
+ "[+xtrace?Equivalent to \b-x\b.]"
+"}"
+"[p?Privileged mode. Disabling \b-p\b sets the effective user id to the "
+ "real user id, and the effective group id to the real group id. "
+ "Enabling \b-p\b restores the effective user and group ids to their "
+ "values when the shell was invoked. The \b-p\b option is on "
+ "whenever the real and effective user id is not equal or the "
+ "real and effective group id is not equal. User profiles are "
+ "not processed when \b-p\b is enabled.]"
+"[r?restricted. Enables restricted shell. This option cannot be unset once "
+ "enabled.]"
+"[t?Obsolete. The shell reads one command and then exits.]"
+"[u?If enabled, the shell displays an error message when it tries to expand "
+ "a variable that is unset.]"
+"[v?Verbose. The shell displays its input onto standard error as it "
+ "reads it.]"
+"[x?Execution trace. The shell will display each command after all "
+ "expansion and before execution preceded by the expanded value "
+ "of the \bPS4\b parameter.]"
+#if SHOPT_BASH
+ "\fbash1\f"
+#endif
+#if SHOPT_BRACEPAT
+"[B?Enable {...} group expansion. On by default.]"
+#endif
+"[C?Prevents existing regular files from being overwritten using the \b>\b "
+ "redirection operator. The \b>|\b redirection overrides this "
+ "\bnoclobber\b option.]"
+"[G?Causes \b**\b by itself to also match all sub-directories during pathname "
+ "expansion.]"
+#if SHOPT_HISTEXPAND
+ "[H?Enable \b!\b-style history expansion similar to \bcsh\b.]"
+#endif
+;
+
+const char sh_optbreak[] =
+"[-1c?\n@(#)$Id: break (AT&T Research) 1999-04-07 $\n]"
+USAGE_LICENSE
+"[+NAME?break - break out of loop ]"
+"[+DESCRIPTION?\bbreak\b is a shell special built-in that exits the "
+ "smallest enclosing \bfor\b, \bselect\b, \bwhile\b, or \buntil\b loop, "
+ "or the \an\a-th enclosing loop if \an\a is specified. "
+ "Execution continues at the command following the loop(s).]"
+"[+?If \an\a is given, it must be a positive integer >= 1. If \an\a "
+ "is larger than the number of enclosing loops, the last enclosing "
+ "loop will be exited.]"
+"\n"
+"\n[n]\n"
+"\n"
+"[+EXIT STATUS?0]"
+"[+SEE ALSO?\bcontinue\b(1), \breturn\b(1)]"
+;
+
+const char sh_optcont[] =
+"[-1c?\n@(#)$Id: continue (AT&T Research) 1999-04-07 $\n]"
+USAGE_LICENSE
+"[+NAME?continue - continue execution at top of the loop]"
+"[+DESCRIPTION?\bcontinue\b is a shell special built-in that continues "
+ "execution at the top of smallest enclosing enclosing \bfor\b, "
+ "\bselect\b, \bwhile\b, or \buntil\b loop, if any; or the top of "
+ "the \an\a-th enclosing loop if \an\a is specified.]"
+"[+?If \an\a is given, it must be a positive integer >= 1. If \an\a "
+ "is larger than the number of enclosing loops, the last enclosing "
+ " loop will be used.]"
+
+"\n"
+"\n[n]\n"
+"\n"
+"[+SEE ALSO?\bbreak\b(1)]"
+;
+
+const char sh_optalarm[] = "r [varname seconds]";
+const char sh_optalias[] =
+"[-1c?\n@(#)$Id: alias (AT&T Research) 1999-07-07 $\n]"
+USAGE_LICENSE
+"[+NAME?alias - define or display aliases]"
+"[+DESCRIPTION?\balias\b creates or redefines alias definitions "
+ "or writes the existing alias definitions to standard output. "
+ "An alias definitions provides a string value that will replace "
+ "a command name when the command is read. Alias names can "
+ "contain any printable character which is not special to the shell. "
+ "If an alias value ends in a space or tab, then the word "
+ "following the command name the alias replaces is also checked "
+ "to see whether it is an alias.]"
+"[+?If no \aname\as are specified then the names and values of all "
+ "aliases are written to standard output. Otherwise, for "
+ "each \aname\a that is specified, and \b=\b\avalue\a is not "
+ "specified, the current value of the alias corresponding to "
+ "\aname\a is written to standard output. If \b=\b\avalue\a is "
+ "specified, the alias \aname\a will be created or redefined.]"
+"[+?\balias\b is built-in to the shell as a declaration command so that "
+ "field splitting and pathname expansion are not performed on "
+ "the arguments. Tilde expansion occurs on \avalue\a. An alias "
+ "definition only affects scripts read by the current shell "
+ "environment. It does not effect scripts run by this shell.]"
+"[p?Causes the output to be in the form of alias commands that can be used "
+ "as input to the shell to recreate the current aliases.]"
+"[t?Used for tracked aliases. These are aliases that connect a "
+ "command name to the pathname of the command and are reset "
+ "when the \bPATH\b variable is unset. The tracked aliases feature is "
+ "now obsolete.]"
+"[x?Ignored, this option is obsolete.]"
+"\n"
+"\n[name[=value]...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Successful completion.]"
+ "[+>0?One or more \aname\a operands did not have an alias "
+ "definition, or an error occurred.]"
+"}"
+
+"[+SEE ALSO?\bsh\b(1), \bunalias\b(1)]"
+;
+
+const char sh_optbuiltin[] =
+"[-1c?\n@(#)$Id: builtin (AT&T Research) 1999-07-10 $\n]"
+USAGE_LICENSE
+"[+NAME?builtin - add, delete, or display shell built-ins]"
+"[+DESCRIPTION?\bbuiltin\b can be used to add, delete, or display "
+ "built-in commands in the current shell environment. A built-in command "
+ "executes in the current shell process and can have side effects in the "
+ "current shell. On most systems, the invocation time for built-in "
+ "commands is one or two orders of magnitude less than commands that "
+ "create a separate process.]"
+"[+?For each \apathname\a specified, the basename of the pathname "
+ "determines the name of the built-in. For each basename, the shell looks "
+ "for a C level function in the current shell whose name is determined by "
+ "prepending \bb_\b to the built-in name. If \apathname\a contains a "
+ "\b/\b, then the built-in is bound to this pathname. A built-in bound to "
+ "a pathname will only be executed if \apathname\a is the first "
+ "executable found during a path search. Otherwise, built-ins are found "
+ "prior to performing the path search.]"
+"[+?If no \apathname\a operands are specified, then \bbuiltin\b displays "
+ "the current list of built-ins, or just the special built-ins if \b-s\b "
+ "is specified, on standard output. The full pathname for built-ins that "
+ "are bound to pathnames are displayed.]"
+"[+?Libraries containing built-ins can be specified with the \b-f\b "
+ "option. If the library contains a function named \blib_init\b(), this "
+ "function will be invoked with argument \b0\b when the library is "
+ "loaded. The \blib_init\b() function can load built-ins by invoking an "
+ "appropriate C level function. In this case there is no restriction on "
+ "the C level function name.]"
+"[+?The C level function will be invoked with three arguments. The first "
+ "two are the same as \bmain\b() and the third one is a pointer.]"
+"[+?\bbuiltin\b cannot be invoked from a restricted shell.]"
+"[d?Deletes each of the specified built-ins. Special built-ins cannot be "
+ "deleted.]"
+"[f]:[lib?On systems with dynamic linking, \alib\a names a shared "
+ "library to load and search for built-ins. Libraries are search for in "
+ "\b$PATH\b and system dependent library directories. The system "
+ "dependent shared library prefix and/or suffix may be omitted. Once a "
+ "library is loaded, its symbols become available for the current and "
+ "subsequent invocations of \bbuiltin\b. Multiple libraries can be "
+ "specified with separate invocations of \bbuiltin\b. Libraries are "
+ "searched in the reverse order in which they are specified.]"
+"[s?Display only the special built-ins.]"
+"\n"
+"\n[pathname ...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?All \apathname\a operands and \b-f\b options processed "
+ "successfully.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bwhence\b(1)]"
+;
+
+const char sh_optcd[] =
+"[-1c?\n@(#)$Id: cd (AT&T Research) 1999-06-05 $\n]"
+USAGE_LICENSE
+"[+NAME?cd - change working directory ]"
+"[+DESCRIPTION?\bcd\b changes the current working directory of the "
+ "current shell environment.]"
+"[+?In the first form with one operand, if \adirectory\a begins with "
+ "\b/\b, or if the first component is \b.\b or \b..\b, the "
+ "directory will be changed to this directory. If directory is \b-\b, "
+ "the directory will be changed to the last directory visited. "
+ "Otherwise, if the \bCDPATH\b environment variable is set, \bcd\b "
+ "searches for \adirectory\a relative to each directory named in "
+ "the colon separated list of directories defined by \bCDPATH\b. "
+ "If \bCDPATH\b not set, \bcd\b changes to the directory specified "
+ "by \adirectory\a.]"
+"[+?In the second form, the first occurrence of the string \aold\a "
+ "contained in the pathname of the present working directory "
+ "is replaced by the string \anew\a and the resulting string "
+ "is used as the directory to which to change.]"
+"[+?When invoked without operands and when the \bHOME\b environment "
+ "variable is set to a nonempty value, the directory named by "
+ "the \bHOME\b environment variable will be used. If \bHOME\b "
+ "is empty or unset, \bcd\b will fail.]"
+"[+?When \bcd\b is successful, the \bPWD\b environment variable will be set "
+ "to the name of an absolute pathname that does not contain any "
+ "\b..\b components corresponding to the new directory. The "
+ "environment variable \bOLDPWD\b will be set to the previous "
+ "value of \bPWD\b. If the new directory is found by searching "
+ "the directories named by \bCDPATH\b, or if \adirectory\a is \b-\b, "
+ "or if the two operand form is used, the new value of \bPWD\b will be "
+ "written to standard output.]"
+"[+?If both \b-L\b and \b-P\b are specified, the last one specified will "
+ "be used. If neither \b-P\b or \b-L\b is specified then the "
+ "behavior will be determined by the \bgetconf\b parameter "
+ "\bPATH_RESOLVE\b. If \bPATH_RESOLVE\b is \bphysical\b, "
+ "then the behavior will be as if \b-P\b were specified. Otherwise, "
+ "the behavior will be as if \b-L\b were specified.]"
+"[L?Handle each pathname component \b..\b in a logical fashion by moving "
+ "up one level by name in the present working directory.]"
+"[P?The present working directory is first converted to an absolute pathname "
+ "that does not contain symbolic link components and symbolic name "
+ "components are expanded in the resulting directory name.]"
+"\n"
+"\n[directory]\n"
+"old new\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Directory successfully changed.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bpwd\b(1), \bgetconf\b(1)]"
+;
+
+const char sh_optcommand[] =
+"[-1c?\n@(#)$Id: command (AT&T Research) 2003-08-01 $\n]"
+USAGE_LICENSE
+"[+NAME?command - execute a simple command]"
+"[+DESCRIPTION?Without \b-v\b or \b-V\b, \bcommand\b executes \acommand\a "
+ "with arguments given by \aarg\a, suppressing the shell function lookup "
+ "that normally occurs. In addition, if \acommand\a is a special "
+ "built-in command, then the special properties are removed so that "
+ "failures will not cause the script that executes it to terminate.]"
+"[+?With the \b-v\b or \b-V\b options, \bcommand\b is equivalent to the "
+ "\bwhence\b(1) command.]"
+"[p?Causes a default path to be searched rather than the one defined by the "
+ "value of \bPATH\b.]"
+"[v?Equivalent to \bwhence\b \acommand\a [\aarg\a ...]].]"
+"[x?If \acommand\a fails because there are too many \aarg\as, it will be "
+ "invoked multiple times with a subset of the arguments on each "
+ "invocation. Arguments that occur prior to the first word that expand "
+ "to multiple arguments and arguments that occur after the last word "
+ "that expands to multiple arguments will be passed on each invocation. "
+ "The exit status will be the maximum invocation exit status.]"
+"[V?Equivalent to \bwhence \b-v\b \acommand\a [\aarg\a ...]].]"
+"\n"
+"\n[command [arg ...]]\n"
+"\n"
+"[+EXIT STATUS?If \acommand\a is invoked, the exit status of \bcommand\b "
+ "will be that of \acommand\a. Otherwise, it will be one of "
+ "the following:]{"
+ "[+0?\bcommand\b completed successfully.]"
+ "[+>0?\b-v\b or \b-V\b has been specified and an error occurred.]"
+ "[+126?\acommand\a was found but could not be invoked.]"
+ "[+127?\acommand\a could not be found.]"
+"}"
+
+"[+SEE ALSO?\bwhence\b(1), \bgetconf\b(1)]"
+;
+
+const char sh_optdot[] =
+"[-1c?@(#)$Id: \b.\b (AT&T Research) 2000-04-02 $\n]"
+USAGE_LICENSE
+"[+NAME?\b.\b - execute commands in the current environment]"
+"[+DESCRIPTION?\b.\b is a special built-in command that executes commands "
+ "from a function or a file in the current environment.]"
+"[+?If \aname\a refers to a function defined with the \bfunction\b \aname\a "
+ "syntax, the function executes in the current environment as "
+ "if it had been defined with the \aname\a\b()\b syntax so that "
+ "there is no scoping. Otherwise, commands from the file defined "
+ "by \aname\a are executed in the current environment. Note that "
+ "the complete script is read before it begins to execute so that "
+ "any aliases defined in this script will not take effect until "
+ "the script completes execution.]"
+"[+?When \aname\a refers to a file, the \bPATH\b variable is searched "
+ "for the file containing commands. In this case execute permission "
+ "is not required for \aname\a.]"
+"[+?If any \aarg\as are specified, these become the positional parameters "
+ "for the duration of the function or script and are restored "
+ "upon completion.]"
+"\n"
+"\n name [arg ...]\n"
+"\n"
+"[+EXIT STATUS?If \aname\a is found, then the exit status is that "
+ "of the last command executed. Otherwise, since this is a special "
+ "built-in, an error will cause a non-interactive shell to exit with "
+ "a non-zero exit status. An interactive shell returns a non-zero exit "
+ "status to indicate an error.]"
+
+"[+SEE ALSO?\bcommand\b(1), \bksh\b(1)]"
+;
+
+#ifndef ECHOPRINT
+ const char sh_optecho[] = " [-n] [arg...]";
+#endif /* !ECHOPRINT */
+
+const char sh_opteval[] =
+"[-1c?\n@(#)$Id: eval (AT&T Research) 1999-07-07 $\n]"
+USAGE_LICENSE
+"[+NAME?eval - create a shell command and process it]"
+"[+DESCRIPTION?\beval\b is a shell special built-in command that constructs "
+ "a command by concatenating the \aarg\as together, separating each "
+ "with a space. The resulting string is then taken as input to "
+ "the shell and evaluated in the current environment. Note that "
+ "command words are expanded twice; once to construct \aarg\a, and "
+ "again when the shell executes the constructed command.]"
+"[+?It is not an error if \aarg\a is not given.]"
+"\n"
+"\n[arg...]\n"
+"\n"
+"[+EXIT STATUS?If \aarg\a is not specified, the exit status is \b0\b. "
+ "Otherwise, it is the exit status of the command defined by the "
+ "\aarg\a operands.]"
+"[+SEE ALSO?\bexec\b(1), \btrap\b(1), \b.\b(1)]"
+;
+
+const char sh_optexec[] =
+"[-1c?\n@(#)$Id: exec (AT&T Research) 1999-07-10 $\n]"
+USAGE_LICENSE
+"[+NAME?exec - execute command, open/close and duplicate file descriptors]"
+"[+DESCRIPTION?\bexec\b is a special built-in command that can be used to "
+ "manipulate file descriptors or to replace the current shell "
+ "with a new command.]"
+"[+?If \acommand\a is specified, then the current shell process will be "
+ "replaced by \acommand\a rather than running \acommand\a and waiting "
+ "for it to complete. Note that there is no need to use "
+ "\bexec\b to enhance performance since the shell implicitly "
+ "uses the exec mechanism internally whenever possible.]"
+"[+?If no operands are specified, \bexec\b can be used to open or "
+ "close files, or to manipulate file descriptors from \b0\b to "
+ "\b9\b in the current shell environment using the standard "
+ "redirection mechanism available with all commands. The "
+ "close-on-exec flags will be set on file descriptor numbers "
+ "greater than \b2\b that are opened this way so that they "
+ "will be closed when another program is invoked.]"
+"[+?Because \bexec\b is a special command, any failure will cause the "
+ "script that invokes it to exit. This can be prevented by "
+ "invoking \bexec\b from the \bcommand\b utility.]"
+"[+?\bexec\b cannot be invoked from a restricted shell to create "
+ "files or to open a file for writing or appending.]"
+"[c?Clear all environment variables before executions except variable "
+ "assignments that are part of the current \bexec\b command.]"
+"[a]:[name?\bargv[0]]\b will be set to \aname\a for \acommand\a]"
+"\n"
+"\n[command [arg ...]]\n"
+"\n"
+"[+EXIT STATUS?If \acommand\a is specified, \bexec\b does not return. "
+ "Otherwise, the exit status is one of the following:]{"
+ "[+0?All I/O redirections were successful.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bcommand\b(1), \beval\b(1)]"
+;
+
+
+const char sh_optexit[] =
+"[-1c?\n@(#)$Id: exit (AT&T Research) 1999-07-07 $\n]"
+USAGE_LICENSE
+"[+NAME?exit - exit the current shell]"
+"[+DESCRIPTION?\bexit\b is shell special built-in that causes the "
+ "shell that invokes it to exit. Before exiting the shell, if the "
+ "\bEXIT\b trap is set it will be invoked.]"
+"[+?If \an\a is given, it will be used to set the exit status.]"
+"\n"
+"\n[n]\n"
+"\n"
+"[+EXIT STATUS?If \an\a is specified, the exit status is the least significant "
+ "eight bits of the value of \an\a. Otherwise, the exit status is the "
+ "exit status of preceding command. When invoked inside a trap, the "
+ "preceding command means the command that invoked the trap.]"
+"[+SEE ALSO?\bbreak\b(1), \breturn\b(1)]"
+;
+
+const char sh_optexport[] =
+"[-1c?\n@(#)$Id: export (AT&T Research) 1999-07-07 $\n]"
+USAGE_LICENSE
+"[+NAME?export - set export attribute on variables]"
+"[+DESCRIPTION?\bexport\b sets the export attribute on each of "
+ "the variables specified by \aname\a which causes them "
+ "to be in the environment of subsequently executed commands. "
+ "If \b=\b\avalue\a is specified, the variable \aname\a is "
+ "set to \avalue\a.]"
+"[+?If no \aname\as are specified then the names and values of all "
+ "exported variables are written to standard output.]"
+"[+?\bexport\b is built-in to the shell as a declaration command so that "
+ "field splitting and pathname expansion are not performed on "
+ "the arguments. Tilde expansion occurs on \avalue\a.]"
+"[p?Causes the output to be in the form of \bexport\b commands that can be "
+ "used as input to the shell to recreate the current exports.]"
+"\n"
+"\n[name[=value]...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Successful completion.]"
+ "[+>0?An error occurred.]"
+"}"
+
+"[+SEE ALSO?\bsh\b(1), \btypeset\b(1)]"
+;
+
+const char sh_optgetopts[] =
+":[-1c?\n@(#)$Id: getopts (AT&T Research) 2005-01-01 $\n]"
+"[-author?Glenn Fowler <gsf@research.att.com>]"
+USAGE_LICENSE
+"[+NAME?\f?\f - parse utility options]"
+"[+DESCRIPTION?The \bgetopts\b utility can be used to retrieve options and "
+ "arguments from a list of arguments given by \aargs\a or the positional "
+ "parameters if \aargs\a is omitted. It can also generate usage messages "
+ "and a man page for the command based on the information in \aoptstring\a.]"
+"[+?Each time it is invoked, the \bgetopts\b utility places the value "
+ "of the next option in the shell variable specified by the \aname\a "
+ "operand and the index of the next argument to be processed in the "
+ "shell variable \bOPTIND\b. When the shell is invoked \bOPTIND\b "
+ "is initialized to \b1\b. When an option requires or permits an option "
+ "argument, \bgetopts\b places the option argument in the shell "
+ "variable \bOPTARG\b. Otherwise \bOPTARG\b is set to \b1\b when the "
+ "option is set and \b0\b when the option is unset.]"
+"[+?The \aoptstring\a string consists of alpha-numeric characters, "
+ "the special characters +, -, ?, :, and <space>, or character groups "
+ "enclosed in [...]]. Character groups may be nested in {...}. "
+ "Outside of a [...]] group, a single new-line followed by zero or "
+ "more blanks is ignored. One or more blank lines separate the "
+ "options from the command argument synopsis.]"
+"[+?Each [...]] group consists of an optional label, "
+ "optional attributes separated by :, and an "
+ "optional description string following ?. The characters from the ? "
+ "to the end of the next ]] are ignored for option parsing and short "
+ "usage messages. They are used for generating verbose help or man pages. "
+ "The : character may not appear in the label. "
+ "The ? character must be specified as ?? in the label and the ]] character "
+ "must be specified as ]]]] in the description string. "
+ "Text between two \\b (backspace) characters indicates "
+ "that the text should be emboldened when displayed. "
+ "Text between two \\a (bell) characters indicates that the text should "
+ "be emphasised or italicized when displayed. "
+ "Text between two \\v (vertical tab) characters indicates "
+ "that the text should displayed in a fixed width font. "
+ "Text between two \\f (formfeed) characters will be replaced by the "
+ "output from the shell function whose name is that of the enclosed text.]"
+"[+?All output from this interface is written to the standard error.]"
+"[+?There are several group types:]{"
+ "[+1.?A group of the form "
+ "[-[\aversion\a]][\aflag\a[\anumber\a]]]]...[?\atext\a]]]] "
+ "appearing as the first group enables the extended interface. \aversion\a "
+ "specifies the interface version, currently \b1\b. The latest version is "
+ "assumed if \aversion\a is omitted. Future enhancements "
+ "may increment \aversion\a, but all versions will be supported. \atext\a "
+ "typically specifies an SCCS or CVS identification string. Zero or more "
+ "\aflags\a with optional \anumber\a values may be specified to control "
+ "option parsing. "
+ "The flags are:]{"
+ "[+c?Cache this \aoptstring\a for multiple passes. Used to optimize "
+ "builtins that may be called many times within the same process.]"
+ "[+i?Ignore this \aoptstring\a when generating help. Used when "
+ "combining \aoptstring\a values from multiple passes.]"
+ "[+l?Display only \alongname\a options in help messages.]"
+ "[+o?The \b-\b option character prefix is optional (supports "
+ "obsolete \bps\b(1) option syntax.)]"
+ "[+p?\anumber\a specifies the number of \b-\b characters that must "
+ "prefix long option names. The default is \b2\b; \b0\b, \b1\b or "
+ "\b2\b are accepted (e.g., \bp0\b for \bdd\b(1) and \bp1\b for "
+ "\bfind\b(1).)]"
+ "[+s?\anumber\a specifies the \b--??man\b section number, "
+ "\b1\b by default.]"
+ "}"
+ "[+2.?An option specification of the form "
+ "[\aoption\a[!]][=\anumber\a]][:\alongname\a]][?\atext\a]]]]. In this "
+ "case the first field is the option character; this is the value returned "
+ "in the \aname\a operand when the option is matched. If there is no "
+ "option character then a two or more digit number should be specified. "
+ "This number will be returned as the value of the \aname\a operand if the "
+ "long option is matched. If \aoption\a is followed by \b!\b then the option "
+ "character sense is the inverse of the longname sense. For options that do "
+ "not take values \bOPTARG\b will be set to \b0\b for \b!\b inverted option "
+ "characters and \b1\b otherwise. =\anumber\a optionally specifies a number to "
+ "be returned in the \aname\a operand instead of the option character. A "
+ "longname is specified by \b--\b\alongname\a and is matched by the shortest "
+ "non-ambiguous prefix of all long options. * in the \alongname\a field "
+ "indicates that only characters up to that point need to match, provided "
+ "any additional characters match exactly. The enclosing [ and ]] can be "
+ "omitted for an option that does not have a longname or descriptive text.]"
+ "[+3.?An option argument specification. "
+ "Options that take arguments can be followed by : (string value) or # "
+ "(numeric value) and an option argument specification. An option argument "
+ "specification consists of the option argument name as field 1. "
+ "The remaining \b:\b separated fields are a type name and zero or more of "
+ "the special attribute words \blistof\b, \boneof\b, and \bignorecase\b. "
+ "A default option value may be specified in the final field as "
+ "\b:=\b\adefault\a. The option argument specification may be followed "
+ "by a list of option value descriptions enclosed in braces. "
+ "A long option that takes an argument is specified as "
+ "\b--\b\alongname\a=\avalue\a. If the : or # is followed by ? then the "
+ "option argument is optional. If only the option character form is "
+ "specified then the optional argument value is not set if the next "
+ "argument starts with - or +.]"
+ "[+4.?A option value description.]"
+ "[+5.?A argument specification. A list of valid option argument values "
+ "can be specified by enclosing them inside a {...} following "
+ "the option argument specification. Each of the permitted "
+ "values can be specified with a [...]] containing the "
+ "value followed by a description.]"
+ "[+6.?A group of the form [+\\n...]] will display the characters "
+ "representing ... in fixed with font without adding line breaks.]"
+ "[+7.?A group of the form [+\aname\a?\atext\a]] specifies a section "
+ "\aname\a with descriptive \atext\a. If \aname\a is omitted then "
+ "\atext\a is placed in a new paragraph.]"
+ "[+8.?A group of the form [-\aname\a?\atext\a]] specifies entries "
+ "for the \bIMPLEMENTATION\b section.]"
+"}"
+"[+?If the leading character of \aoptstring\a is +, then arguments "
+ "beginning with + will also be considered options.]"
+"[+?A leading : character or a : following a leading + in \aoptstring\a "
+ "affects the way errors are handled. If an option character or longname "
+ "argument not specified in \aoptstring\a is encountered when processing "
+ "options, the shell variable whose name is \aname\a will be set to the ? "
+ "character. The shell variable \bOPTARG\b will be set to "
+ "the character found. If an option argument is missing or has an invalid "
+ "value, then \aname\a will be set to the : character and the shell variable "
+ "\bOPTARG\b will be set to the option character found. "
+ "Without the leading :, \aname\a will be set to the ? character, \bOPTARG\b "
+ "will be unset, and an error message will be written to standard error "
+ "when errors are encountered.]"
+"[+?The end of options occurs when:]{"
+ "[+1.?The special argument \b--\b is encountered.]"
+ "[+2.?An argument that does not begin with a \b-\b is encountered.]"
+ "[+3.?A help argument is specified.]"
+ "[+4.?An error is encountered.]"
+"}"
+"[+?If \bOPTIND\b is set to the value \b1\b, a new set of arguments "
+ "can be used.]"
+"[+?\bgetopts\b can also be used to generate help messages containing command "
+ "usage and detailed descriptions. Specify \aargs\a as:]"
+"{ "
+ "[+-???To generate a usage synopsis.]"
+ "[+--?????To generate a verbose usage message.]"
+ "[+--????man?To generate a formatted man page.]"
+ "[+--????api?To generate an easy to parse usage message.]"
+ "[+--????html?To generate a man page in \bhtml\b format.]"
+ "[+--????nroff?To generate a man page in \bnroff\b format.]"
+ "[+--????usage?List the current \aoptstring\a.]"
+ "[+--??????\aname\a?List \bversion=\b\an\a, \an\a>0, "
+ "if the option \aname\a is recognized by \bgetopts\b.]"
+"}"
+"[+?When the end of options is encountered, \bgetopts\b exits with a "
+ "non-zero return value and the variable \bOPTIND\b is set to the "
+ "index of the first non-option argument.]"
+"a:[name?Use \aname\a instead of the command name in usage messages.]"
+"\n"
+"\nopstring name [args...]\n"
+"\n"
+"[+EXIT STATUS]{"
+ "[+0?An option specified was found.]"
+ "[+1?An end of options was encountered.]"
+ "[+2?A usage or information message was generated.]"
+"}"
+;
+
+const char sh_optbg[] =
+"[-1c?@(#)$Id: bg (AT&T Research) 2000-04-02 $\n]"
+USAGE_LICENSE
+"[+NAME?bg - resume jobs in the background]"
+"[+DESCRIPTION?\bbg\b places the given \ajob\as into the background "
+ "and sends them a \bCONT\b signal to start them running.]"
+"[+?If \ajob\a is omitted, the most recently started or stopped "
+ "background job is resumed or continued in the background.]"
+"[+?Each \ajob\a can be specified as one of the following:]{"
+ "[+\anumber\a?\anumber\a refers to a process id.]"
+ "[+-\anumber\a?\anumber\a refers to a process group id.]"
+ "[+%\anumber\a?\anumber\a refer to a job number.]"
+ "[+%\astring\a?Refers to a job whose name begins with \astring\a.]"
+ "[+%??\astring\a?Refers to a job whose name contains \astring\a.]"
+ "[+%+ \bor\b %%?Refers to the current job.]"
+ "[+%-?Refers to the previous job.]"
+"}"
+"\n"
+"\n[job ...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?If all background jobs are started.]"
+ "[+>0?If one more jobs does not exist or there are no background "
+ "jobs.]"
+"}"
+
+"[+SEE ALSO?\bwait\b(1), \bfg\b(1), \bdisown\b(1), \bjobs\b(1)]"
+;
+
+const char sh_optfg[] =
+"[-1c?@(#)$Id: fg (AT&T Research) 2000-04-02 $\n]"
+USAGE_LICENSE
+"[+NAME?fg - move jobs to the foreground]"
+"[+DESCRIPTION?\bfg\b places the given \ajob\as into the foreground "
+ "in sequence and sends them a \bCONT\b signal to start each running.]"
+"[+?If \ajob\a is omitted, the most recently started or stopped "
+ "background job is moved to the foreground.]"
+"[+?Each \ajob\a can be specified as one of the following:]{"
+ "[+\anumber\a?\anumber\a refers to a process id.]"
+ "[+-\anumber\a?\anumber\a refers to a process group id.]"
+ "[+%\anumber\a?\anumber\a refer to a job number.]"
+ "[+%\astring\a?Refers to a job whose name begins with \astring\a.]"
+ "[+%??\astring\a?Refers to a job whose name contains \astring\a.]"
+ "[+%+ \bor\b %%?Refers to the current job.]"
+ "[+%-?Refers to the previous job.]"
+"}"
+"\n"
+"\n[job ...]\n"
+"\n"
+"[+EXIT STATUS?If \bfg\b brings one or more jobs into the foreground, "
+ "the exit status of \bfg\b will be that of the last \ajob\a. "
+ "If one or more jobs does not exist or has completed, \bfg\b will "
+ "return a non-zero exit status.]"
+"}"
+
+"[+SEE ALSO?\bwait\b(1), \bbg\b(1), \bjobs\b(1)]"
+;
+
+const char sh_optdisown[] =
+"[-1c?@(#)$Id: disown (AT&T Research) 2000-04-02 $\n]"
+USAGE_LICENSE
+"[+NAME?disown - disassociate a job with the current shell]"
+"[+DESCRIPTION?\bdisown\b prevents the current shell from sending "
+ "a \bHUP\b signal to each of the given \ajob\as when "
+ "the current shell terminates a login session.]"
+"[+?If \ajob\a is omitted, the most recently started or stopped "
+ "background job is used.]"
+"[+?Each \ajob\a can be specified as one of the following:]{"
+ "[+\anumber\a?\anumber\a refers to a process id.]"
+ "[+-\anumber\a?\anumber\a refers to a process group id.]"
+ "[+%\anumber\a?\anumber\a refer to a job number.]"
+ "[+%\astring\a?Refers to a job whose name begins with \astring\a.]"
+ "[+%??\astring\a?Refers to a job whose name contains \astring\a.]"
+ "[+%+ \bor\b %%?Refers to the current job.]"
+ "[+%-?Refers to the previous job.]"
+"}"
+"\n"
+"\n[job ...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?If all jobs are sucessfully disowned.]"
+ "[+>0?If one more \ajob\as does not exist.]"
+"}"
+
+"[+SEE ALSO?\bwait\b(1), \bbg\b(1), \bjobs\b(1)]"
+;
+
+const char sh_optjobs[] =
+"[-1c?@(#)$Id: jobs (AT&T Research) 2000-04-02 $\n]"
+USAGE_LICENSE
+"[+NAME?jobs - display status of jobs]"
+"[+DESCRIPTION?\bjobs\b displays information about specified \ajob\as "
+ "that were started by the current shell environment on standard "
+ "output. The information contains the job number enclosed in "
+ "[...]], the status, and the command line that started the job.]"
+"[+?If \ajob\a is omitted, \bjobs\b displays the status of all stopped jobs, "
+ "background jobs, and all jobs whose status has changed since last "
+ "reported by the shell.]"
+"[+?When \bjobs\b reports the termination status of a job, the "
+ "shell removes the jobs from the list of known jobs in "
+ "the current shell environment.]"
+"[+?Each \ajob\a can be specified as one of the following:]{"
+ "[+\anumber\a?\anumber\a refers to a process id.]"
+ "[+-\anumber\a?\anumber\a refers to a process group id.]"
+ "[+%\anumber\a?\anumber\a refer to a job number.]"
+ "[+%\astring\a?Refers to a job whose name begins with \astring\a.]"
+ "[+%??\astring\a?Refers to a job whose name contains \astring\a.]"
+ "[+%+ \bor\b %%?Refers to the current job.]"
+ "[+%-?Refers to the previous job.]"
+"}"
+"[l?\bjobs\b displays process id's after the job number in addition "
+ "to the usual information]"
+"[n?Only the jobs whose status has changed since the last prompt "
+ "is displayed.]"
+"[p?The process group leader id's for the specified jobs are displayed.]"
+"\n"
+"\n[job ...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?The information for each job is written to standard output.]"
+ "[+>0?One or more jobs does not exist.]"
+"}"
+
+"[+SEE ALSO?\bwait\b(1), \bps\b(1), \bfg\b(1), \bbg\b(1)]"
+;
+
+const char sh_opthist[] =
+"[-1c?@(#)$Id: hist (AT&T Research) 2000-04-02 $\n]"
+USAGE_LICENSE
+"[+NAME?\f?\f - process command history list]"
+"[+DESCRIPTION?\b\f?\f\b lists, edits, or re-executes, commands "
+ "previously entered into the current shell environment.]"
+"[+?The command history list references commands by number. The first number "
+ "in the list is selected arbitrarily. The relationship of a number "
+ "to its command does not change during a login session. When the "
+ "number reaches 32767 the number wraps around to 1 but "
+ "maintains the ordering.]"
+"[+?When commands are edited (when the \b-l\b option is not specified), the "
+ "resulting lines will be entered at the end of the history list and "
+ "then reexecuted by the current shell. The \b\f?\f\b command that "
+ "caused the editing will not be entered into the history list. If the "
+ "editor returns a non-zero exit status, this will suppress the "
+ "entry into the history list and the command reexecution. Command "
+ "line variable assignments and redirections affect both the \f?\f "
+ "command and the commands that are reexecuted.]"
+"[+?\afirst\a and \alast\a define the range of commands. \afirst\a and "
+ "\alast\a can be one of the following:]{"
+ "[+\anumber\a?A positive number representing a command "
+ "number. A \b+\b sign can precede \anumber\a.]"
+ "[+-\anumber\a?A negative number representing a command "
+ "that was executed \anumber\a commands previously. "
+ "For example, \b-1\b is the previous command.]"
+ "[+\astring\a?\astring\a indicates the most recently "
+ "entered command that begins with \astring\a. "
+ "\astring\a should not contain an \b=\b.]"
+ "}"
+"[+?If \afirst\a is omitted, the previous command is used, unless \b-l\b "
+ "is specified, in which case it will default to \b-16\b and \alast\a "
+ "will default to \b-1\b.]"
+"[+?If \afirst\a is specified and \alast\a is omitted, then \alast\a will "
+ "default to \afirst\a unless \b-l\b is specified in which case "
+ "it will default to \b-1\b.]"
+"[+?If no editor is specified, then the editor specfied by the \bHISTEDIT\b "
+ "variable will be used if set, or the \bFCEDIT\b variable will be "
+ "used if set, otherwise, \bed\b will be used.]"
+"[e]:[editor?\aeditor\a specifies the editor to use to edit the history "
+ "command. A value of \b-\b for \aeditor\a is equivalent to "
+ "specifiying the \b-s\b option.]"
+"[l?List the commands rather than editing and reexecuting them.]"
+"[N]#[num?Start at \anum\a commands back.]"
+"[n?Suppress the command numbers when the commands are listed.]"
+#if SHOPT_HISTEXPAND
+"[p?Writes the result of history expansion for each operand to standard "
+ "output. All other options are ignored.]"
+#endif
+"[r?Reverse the order of the commands.]"
+"[s?Reexecute the command without invoking an editor. In this case "
+ "an operand of the form \aold\a\b=\b\anew\a can be specified "
+ "to change the first occurrence of the string \aold\a in the "
+ "command to \anew\a before reexecuting the command.]"
+
+"\n"
+"\n[first [last] ]\n"
+"\n"
+"[+EXIT STATUS?If a command is reexecuted, the exit status is that of "
+ "the command that gets reexecuted. Otherwise, it is one of the "
+ "following:]{"
+ "[+0?Successfully completion of the listing.]"
+ "[+>0?An error occurred.]"
+"}"
+
+"[+SEE ALSO?\bksh\b(1), \bsh\b(1), \bed\b(1)]"
+;
+
+const char sh_optkill[] =
+"[-1c?\n@(#)$Id: kill (AT&T Research) 1999-06-17 $\n]"
+USAGE_LICENSE
+"[+NAME?kill - terminate or signal process]"
+"[+DESCRIPTION?With the first form in which \b-l\b is not specified, "
+ "\bkill\b sends a signal to one or more processes specified by "
+ "\ajob\a. This normally terminates the processes unless the signal "
+ "is being caught or ignored.]"
+"[+?A \ajob\a can be specified as one of the following:]{"
+ "[+\anumber\a?\anumber\a refers to a process id.]"
+ "[+-\anumber\a?\anumber\a refers to a process group id.]"
+ "[+%\anumber\a?\anumber\a refer to a job number.]"
+ "[+%\astring\a?Refers to a job whose name begins with \astring\a.]"
+ "[+%??\astring\a?Refers to a job whose name contains \astring\a.]"
+ "[+%+ \bor\b %%?Refers to the current job.]"
+ "[+%-?Refers to the previous job.]"
+"}"
+"[+?If the signal is not specified with either the \b-n\b or the \b-s\b "
+ "option, the \bSIGTERM\b signal is used.]"
+"[+?If \b-l\b is specified, and no \aarg\a is specified, then \bkill\b "
+ "writes the list of signals to standard output. Otherwise, \aarg\a "
+ "can be either a signal name, or a number representing either a "
+ "signal number or exit status for a process that was terminated "
+ "due to a signal. If a name is given the corresponding signal "
+ "number will be written to standard output. If a number is given "
+ "the corresponding signal name will be written to standard output.]"
+"[l?List signal names or signal numbers rather than sending signals as "
+ "described above. "
+ "The \b-n\b and \b-s\b options cannot be specified.]"
+"[n]#[signum?Specify a signal number to send. Signal numbers are not "
+ "portable across platforms, except for the following:]{"
+ "[+0?No signal]"
+ "[+1?\bHUP\b]"
+ "[+2?\bINT\b]"
+ "[+3?\bQUIT\b]"
+ "[+6?\bABRT\b]"
+ "[+9?\bKILL\b]"
+ "[+14?\bALRM\b]"
+ "[+15?\bTERM\b]"
+ "}"
+"[s]:[signame?Specify a signal name to send. The signal names are derived "
+ "from their names in \b<signal.h>\b without the \bSIG\b prefix and "
+ "are case insensitive. \bkill -l\b will generate the list of "
+ "signals on the current platform.]"
+"\n"
+"\njob ...\n"
+" -l [arg ...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?At least one matching process was found for each \ajob\a "
+ "operand, and the specified signal was successfully sent to at "
+ "least one matching process.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bps\b(1), \bjobs\b(1), \bkill\b(2), \bsignal\b(2)]"
+;
+
+const char sh_optlet[] =
+"[-1c?@(#)$Id: let (AT&T Research) 2000-04-02 $\n]"
+USAGE_LICENSE
+"[+NAME?let - evaluate arithmetic expressions]"
+"[+DESCRIPTION?\blet\b evaluates each \aexpr\a in the current "
+ "shell environment as an arithmetic expression using ANSI C "
+ "syntax. Variables names are shell variables and they "
+ "are recursively evaluated as arithmetic expressions to "
+ "get numerical values.]"
+"[+?\blet\b has been made obsolete by the \b((\b...\b))\b syntax "
+ "of \bksh\b(1) which does not require quoting of the operators "
+ "to pass them as command arguments.]"
+"\n"
+"\n[expr ...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?The last \aexpr\a evaluates to a non-zero value.]"
+ "[+>0?The last \aexpr\a evaluates to \b0\b or an error occurred.]"
+"}"
+
+"[+SEE ALSO?\bexpr\b(1), \btest\b(1), \bksh\b(1)]"
+;
+
+const char sh_optprint[] =
+"[-1c?\n@(#)$Id: print (AT&T Research) 1999-04-07 $\n]"
+USAGE_LICENSE
+"[+NAME?print - write arguments to standard output]"
+"[+DESCRIPTION?By default, \bprint\b writes each \astring\a operand to "
+ "standard output and appends a newline character.]"
+"[+?Unless, the \b-r\b or \b-f\b option is specifed, each \b\\\b "
+ "character in each \astring\a operand is processed specially as "
+ "follows:]{"
+ "[+\\a?Alert character.]"
+ "[+\\b?Backspace character.]"
+ "[+\\c?Terminate output without appending newline. The "
+ "remaining \astring\a operands are ignored.]"
+ "[+\\f?Formfeed character.]"
+ "[+\\n?Newline character.]"
+ "[+\\t?Tab character.]"
+ "[+\\v?Vertical tab character.]"
+ "[+\\\\?Backslash character.]"
+ "[+\\E?Escape character (ASCII octal 033).]"
+ "[+\\0\ax\a?The 8-bit character whose ASCII code is the "
+ "1-, 2-, or 3-digit octal number \ax\a.]"
+ "}"
+"[+?If both \b-e\b and \b-r\b are specified, the last one specified is "
+ "the one that is used.]"
+"[+?When the \b-f\b option is specified and there are more \astring\a "
+ "operands than format specifiers, the format string is "
+ "reprocessed from the beginning. If there are fewer \astring\a "
+ "operands than format specifiers, then outputting will end "
+ "at the first unneeded format specifier.]"
+"[e?Unless \b-f\b is specified, process \b\\\b sequences in each \astring\a "
+ "operand as described above. This is the default behavior.]"
+"[n?Do not append a new-line character to the output.]"
+"[f]:[format?Write the \astring\a arguments using the format string "
+ "\aformat\a and do not append a new-line. See \bprintf\b for "
+ "details on how to specify \aformat\a.]"
+"[p?Write to the current co-process instead of standard output.]"
+"[r?Do not process \b\\\b sequences in each \astring\a operand as described "
+ "above.]"
+"[s?Write the output as an entry in the shell history file instead of "
+ "standard output.]"
+"[u]:[fd:=1?Write to file descriptor number \afd\a instead of standard output.]"
+"\n"
+"\n[string ...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Successful completion.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\becho\b(1), \bprintf\b(1), \bread\b(1)]"
+;
+
+const char sh_optprintf[] =
+"[-1c?\n@(#)$Id: printf (AT&T Research) 2006-10-26 $\n]"
+USAGE_LICENSE
+"[+NAME?printf - write formatted output]"
+"[+DESCRIPTION?\bprintf\b writes each \astring\a operand to "
+ "standard output using \aformat\a to control the output format.]"
+"[+?The \aformat\a operands supports the full range of ANSI C formatting "
+ "specifiers plus the following additional specifiers:]{"
+ "[+%b?Each character in the \astring\a operand is processed "
+ "specially as follows:]{"
+ "[+\\a?Alert character.]"
+ "[+\\b?Backspace character.]"
+ "[+\\c?Terminate output without appending newline. "
+ "The remaining \astring\a operands are ignored.]"
+ "[+\\f?Formfeed character.]"
+ "[+\\n?Newline character.]"
+ "[+\\t?Tab character.]"
+ "[+\\v?Vertical tab character.]"
+ "[+\\\\?Backslash character.]"
+ "[+\\E?Escape character (ASCII octal 033).]"
+ "[+\\0\ax\a?The 8-bit character whose ASCII code is "
+ "the 1-, 2-, or 3-digit octal number \ax\a.]"
+ "}"
+ "[+%q?Output \astring\a quoted in a manner that it can be read in "
+ "by the shell to get back the same string. However, empty "
+ "strings resulting from missing \astring\a operands will "
+ "not be quoted.]"
+ "[+%B?Treat the argument as a variable name and output the value "
+ "without converting it to a string. This is most useful for "
+ "variables of type \b-b\b.]"
+ "[+%H?Output \astring\a with characters \b<\b, \b&\b, \b>\b, "
+ "\b\"\b, and non-printable characters properly escaped for "
+ "use in HTML and XML documents.]"
+ "[+%P?Treat \astring\a as an extended regular expression and "
+ "convert it to a shell pattern.]"
+ "[+%R?Treat \astring\a as an shell pattern expression and "
+ "convert it to an extended regular expression.]"
+ "[+%T?Treat \astring\a as a date/time string and format it. The "
+ "\bT\b can be preceded by \b(\b\adformat\a\b)\b, where "
+ "\adformat\a is a date format as defined by the \bdate\b "
+ "command.]"
+ "[+%Z?Output a byte whose value is \b0\b.]"
+"}"
+"[+?When performing conversions of \astring\a to satisfy a numeric "
+ "format specifier, if the first character of \astring\a "
+ "is \b\"\b or \b'\b, then the value will be the numeric value "
+ "in the underlying code set of the character following the "
+ "\b\"\b or \b'\b. Otherwise, \astring\a is treated like a shell "
+ "arithmetic expression and evaluated.]"
+"[+?If a \astring\a operand cannot be completed converted into a value "
+ "appropriate for that format specifier, an error will occur, "
+ "but remaining \astring\a operands will continue to be processed.]"
+"[+?In addition to the format specifier extensions, the following "
+ "extensions of ANSI-C are permitted in format specifiers:]{"
+ "[+-?The escape sequences \b\\E\b and \b\\e\b expand to the escape "
+ "character which is octal \b033\b in ASCII.]"
+ "[+-?The escape sequence \b\\c\b\ax\a expands to Control-\ax\a.]"
+ "[+-?The escape sequence \b\\C[.\b\aname\a\b.]]\b expands to "
+ "the collating element \aname\a.]"
+ "[+-?The escape sequence \b\\x{\b\ahex\a\b}\b expands to the "
+ "character corresponding to the hexidecimal value \ahex\a.]"
+ "[+-?The format modifier flag \b=\b can be used to center a field to "
+ "a specified width. When the output is a terminal, the "
+ "character width is used rather than the number of bytes.]"
+ "[+-?Each of the integral format specifiers can have a third "
+ "modifier after width and precision that specifies the "
+ "base of the conversion from 2 to 64. In this case the "
+ "\b#\b modifier will cause \abase\a\b#\b to be prepended to "
+ "the value.]"
+ "[+-?The \b#\b modifier can be used with the \bd\b specifier when "
+ "no base is specified cause the output to be written in units "
+ "of \b1000\b with a suffix of one of \bk M G T P E\b.]"
+ "[+-?The \b#\b modifier can be used with the \bi\b specifier to "
+ "cause the output to be written in units of \b1024\b with "
+ "a suffix of one of \bKi Mi Gi Ti Pi Ei\b.]"
+ "}"
+"[+?If there are more \astring\a operands than format specifiers, the "
+ "\aformat\a string is reprocessed from the beginning. If there are "
+ "fewer \astring\a operands than format specifiers, then string "
+ "specifiers will be treated as if empty strings were supplied, "
+ "numeric conversions will be treated as if 0 were supplied, and "
+ "time conversions will be treated as if \bnow\b were supplied.]"
+"[+?\bprintf\b is equivalent to \bprint -f\b which allows additional "
+ "options to be specified.]"
+"\n"
+"\nformat [string ...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Successful completion.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bdate\b(1), \bprint\b(1), \bread\b(1)]"
+;
+
+const char sh_optpwd[] =
+"[-1c?\n@(#)$Id: pwd (AT&T Research) 1999-06-07 $\n]"
+USAGE_LICENSE
+"[+NAME?pwd - write working directory name]"
+"[+DESCRIPTION?\bpwd\b writes an absolute pathname of the current working "
+ "directory to standard output. An absolute pathname is a "
+ "pathname that begins with \b/\b that does not contains any "
+ "\b.\b or \b..\b components.]"
+"[+?If both \b-L\b and \b-P\b are specified, the last one specified will "
+ "be used. If neither \b-P\b or \b-L\b is specified then the "
+ "behavior will be determined by the \bgetconf\b parameter "
+ "\bPATH_RESOLVE\b. If \bPATH_RESOLVE\b is \bphysical\b, "
+ "then the behavior will be as if \b-P\b were specified. Otherwise, "
+ "the behavior will be as if \b-L\b were specified.]"
+"[L?The absolute pathname may contains symbolic link components. This is "
+ "the default.]"
+"[P?The absolute pathname will not contain any symbolic link components.]"
+"[+EXIT STATUS?]{"
+ "[+0?Successful completion.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bcd\b(1), \bgetconf\b(1)]"
+;
+
+const char sh_optread[] =
+"[-1c?\n@(#)$Id: read (AT&T Research) 2006-12-19 $\n]"
+USAGE_LICENSE
+"[+NAME?read - read a line from standard input]"
+"[+DESCRIPTION?\bread\b reads a line from standard input and breaks it "
+ "into fields using the characters in value of the \bIFS\b variable "
+ "as separators. The escape character, \b\\\b, is used to remove "
+ "any special meaning for the next character and for line continuation "
+ "unless the \b-r\b option is specified.]"
+"[+?If there are more variables than fields, the remaining variables are "
+ "set to empty strings. If there are fewer variables than fields, "
+ "the leftover fields and their intervening separators are assigned "
+ "to the last variable. If no \avar\a is specifed then the variable "
+ "\bREPLY\b is used.]"
+"[+?When \avar\a has the binary attribute and \b-n\b or \b-N\b is specified, "
+ "the bytes that are read are stored directly into \bvar\b.]"
+"[+?If you specify \b?\b\aprompt\a after the first \avar\a, then \bread\b "
+ "will display \aprompt\a on standard error when standard input "
+ "is a terminal or pipe.]"
+"[A?Unset \avar\a and then create an indexed array containing each field in "
+ "the line starting at index 0.]"
+"[d]:[delim?Read until delimiter \adelim\a instead of to the end of line.]"
+"[p?Read from the current co-process instead of standard input. An end of "
+ "file causes \bread\b to disconnect the co-process so that another "
+ "can be created.]"
+"[r?Do not treat \b\\\b specially when processing the input line.]"
+"[s?Save a copy of the input as an entry in the shell history file.]"
+"[u]#[fd:=0?Read from file descriptor number \afd\a instead of standard input.]"
+"[t]:[timeout?Specify a timeout \atimeout\a in seconds when reading from "
+ "a terminal or pipe.]"
+"[n]#[nbyte?Read at most \ansize\a characters. For binary fields \asize\a "
+ "will be in bytes.]"
+"[N]#[nbyte?Read exactly \ansize\a characters. For binary fields \asize\a "
+ "will be in bytes.]"
+"[v?When reading from a terminal the value of the first variable is displayed "
+ "and used as a default value.]"
+"\n"
+"\n[var?prompt] [var ...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0? Successful completion.]"
+ "[+>0?End of file was detected or an error occurred.]"
+"}"
+"[+SEE ALSO?\bprint\b(1), \bprintf\b(1), \bcat\b(1)]"
+;
+
+const char sh_optreadonly[] =
+"[-1c?\n@(#)$Id: readonly (AT&T Research) 1999-07-07 $\n]"
+USAGE_LICENSE
+"[+NAME?readonly - set readonly attribute on variables]"
+"[+DESCRIPTION?\breadonly\b sets the readonly attribute on each of "
+ "the variables specified by \aname\a which prevents their "
+ "values from being changed. If \b=\b\avalue\a is specified, "
+ "the variable \aname\a is set to \avalue\a before the variable "
+ "is made readonly.]"
+"[+?If no \aname\as are specified then the names and values of all "
+ "readonly variables are written to standard output.]"
+"[+?\breadonly\b is built-in to the shell as a declaration command so that "
+ "field splitting and pathname expansion are not performed on "
+ "the arguments. Tilde expansion occurs on \avalue\a.]"
+"[p?Causes the output to be in a form of \breadonly\b commands that can be "
+ "used as input to the shell to recreate the current set of "
+ "readonly variables.]"
+"\n"
+"\n[name[=value]...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Successful completion.]"
+ "[+>0?An error occurred.]"
+"}"
+
+"[+SEE ALSO?\bsh\b(1), \btypeset\b(1)]"
+;
+
+const char sh_optreturn[] =
+"[-1c?\n@(#)$Id: return (AT&T Research) 1999-07-07 $\n]"
+USAGE_LICENSE
+"[+NAME?return - return from a function or dot script ]"
+"[+DESCRIPTION?\breturn\b is a shell special built-in that causes the "
+ "function or dot script that invokes it to exit. "
+ "If \breturn\b is invoked outside of a function or dot script "
+ "it is equivalent to \bexit\b.]"
+"[+?If \breturn\b is invoked inside a function defined with the \bfunction\b "
+ "reserved word syntax, then any \bEXIT\b trap set within the "
+ "then function will be invoked in the context of the caller "
+ "before the function returns.]"
+"[+?If \an\a is given, it will be used to set the exit status.]"
+"\n"
+"\n[n]\n"
+"\n"
+"[+EXIT STATUS?If \an\a is specified, the exit status is the least significant "
+ "eight bits of the value of \an\a. Otherwise, the exit status is the "
+ "exit status of preceding command.]"
+"[+SEE ALSO?\bbreak\b(1), \bexit\b(1)]"
+;
+
+
+const char sh_optksh[] =
+"+[-1c?\n@(#)$Id: sh (AT&T Research) "SH_RELEASE" $\n]"
+USAGE_LICENSE
+"[+NAME?\b\f?\f\b - Shell, the standard command language interpreter]"
+"[+DESCRIPTION?\b\f?\f\b is a command language interpreter that "
+ "executes commands read from a command line string, the "
+ "standard input, or a specified file.]"
+"[+?If the \b-i\b option is present, or there are no \aarg\as and "
+ "the standard input and standard error are attached to a "
+ "terminal, the shell is considered to be interactive.]"
+"[+?The \b-s\b and \b-c\b options are mutually exclusive. If the \b-c\b "
+ "option is specified, the first \aarg\a is the command-line string "
+ "and must be specified. Any remaining \aarg\as will be used "
+ "to initialize \b$0\b and positional parameters.]"
+"[+?If the neither \b-s\b nor \b-c\b is specified, then the first \barg\b "
+ "will be the pathname of the file containing commands and \b$0\b "
+ "will be set to this value. If there is no file with this pathname, "
+ "and this pathame does not contain a \b/\b, then the \bPATH\b "
+ "will be searched for an executable with this name. Any remaining "
+ "\aarg\as will be used to initialize the positional parmaeters.]"
+"[+?Any option can use a \b+\b instead of a \b-\b to disable the corresponding "
+ "option.]"
+"[c?Read the commands from the first \aarg\a.]"
+"[i?Specifies that the shell is interactive.]"
+"[l?Invoke the shell as a login shell; \b/etc/profile\b and \b$HOME/.profile\b, "
+ "if they exist, are read before the first command.]"
+"[r\f:restricted\f?Invoke the shell in a restricted mode. A restricted "
+ "shell does not permit any of the following:]{"
+ "[+-?Changing the working directory.]"
+ "[+-?Setting values or attributes of the variables \bSHELL\b, "
+ "\bENV\b, \bFPATH\b, or \bPATH\b.]"
+ "[+-?Executing any command whose name as a \b/\b in it.]"
+ "[+-?Redirecting output of a command with \b>\b, \b>|\b, "
+ "\b<>\b, or \b>>\b.]"
+ "[+-?Adding or deleting built-in commands or libraries with "
+ "\bbuiltin\b.]"
+ "[+-?Executing \bcommand -p\b \a...\a .]"
+ "}"
+"[s?Read the commands from standard input. The positional parameters will be "
+ "initialized from \aarg\a.]"
+"[D\f:dump-strings\f?Do not execute the script, but output the set of double "
+ "quoted strings preceded by a \b$\b. These strings are needed for "
+ "localization of the script to different locales.]"
+"[E?Reads the file \b${ENV-$HOME/.kshrc}\b, if it exists, as a profile. "
+ "On by default for interactive shells; use \b+E\b to disable.]"
+#if SHOPT_PFSH
+"[P?Invoke the shell as a profile shell. See \bpfexec\b(1).]"
+#endif
+#if SHOPT_KIA
+"[R]:[file?Do not execute the script, but create a cross reference database "
+ "in \afile\a that can be used a separate shell script browser.]"
+#endif /* SHOPT_KIA */
+#if SHOPT_BASH
+ "\fbash2\f"
+#endif
+"\fabc\f"
+"\n"
+"\n[arg ...]\n"
+"\n"
+"[+EXIT STATUS?If \b\f?\f\b executes command, the exit status will be that "
+ "of the last command executed. Otherwise, it will be one of "
+ "the following:]{"
+ "[+0?The script or command line to be executed consists entirely "
+ "of zero or more blank lines or comments.]"
+ "[+>1-125?A noninteractive shell detected a syntax error, a variable "
+ "assignment error, or an error in a special built-in.]"
+ "[+126?\b-c\b and \b-s\b were not specified and the command script "
+ "was found on \bPATH\b but was not executable.]"
+ "[+127?\b-c\b and \b-s\b were not specified and the command script "
+ "corresponding to \aarg\a could not be found.]"
+"}"
+
+"[+SEE ALSO?\bset\b(1), \bbuiltin\b(1)]"
+;
+const char sh_optset[] =
+"+[-1c?\n@(#)$Id: set (AT&T Research) 1999-09-28 $\n]"
+USAGE_LICENSE
+"[+NAME?set - set/unset options and positional parameters]"
+"[+DESCRIPTION?\bset\b sets or unsets options and positional parameters. "
+ "Options that are specified with a \b-\b cause the options to "
+ "be set. Options that are specified with a \b+\b cause the "
+ "option to be unset.]"
+"[+?\bset\b without any options or arguments displays the names and "
+ "values of all shell variables in the order of the collation "
+ "sequence in the current locale. The values are quoted so that "
+ "they are suitable for reinput to the shell.]"
+"[+?If no \aarg\as are specified, not even the end of options argument \b--\b, "
+ "the positional parameters are unchanged. Otherwise, unless "
+ "the \b-A\b options has been specified, the positional parameters "
+ "are replaced by the list of \aarg\as. A first \aarg\a of "
+ "\b--\b is ignored when setting positional parameters.]"
+"[+?For backward compatibility, a \bset\b command without any options "
+ "specified whose first \aarg\a is \b-\b will turn off "
+ "the \b-v\b and \b-x\b options. If any additional \aarg\as "
+ "are specified, they will replace the positional parameters.]"
+"[s?Sort the positional parameters.]"
+"[A]:[name?Assign the arguments sequentially to the array named by \aname\a "
+ "starting at subscript 0 rather than to the positional parameters.]"
+"\fabc\f"
+"\n"
+"\n[arg ...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?No errors occurred.]"
+ "[+>0?An error occurred.]"
+"}"
+
+"[+SEE ALSO?\btypeset\b(1), \bshift\b(1)]"
+;
+
+
+
+const char sh_optshift[] =
+"[-1c?\n@(#)$Id: shift (AT&T Research) 1999-07-07 $\n]"
+USAGE_LICENSE
+"[+NAME?shift - shift positional parameters]"
+"[+DESCRIPTION?\bshift\b is a shell special built-in that shifts the "
+ "positional parameters to the left by the number of places "
+ "defined by \an\a, or \b1\b if \an\a is omitted. The number of "
+ "positional parameters remaining will be reduced by the "
+ "number of places that are shifted.]"
+"[+?If \an\a is given, it will be evaluated as an arithmetic expression "
+ "to determinate the number of places to shift. It is an error "
+ "to shift more than the number of positional parameters or a "
+ "negative number of places.]"
+"\n"
+"\n[n]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?The positional parameters were successfully shifted.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bset\b(1)]"
+;
+
+const char sh_optsleep[] =
+"[-1c?\n@(#)$Id: sleep (AT&T Research) 1999-04-07 $\n]"
+USAGE_LICENSE
+"[+NAME?sleep - suspend execution for an interval]"
+"[+DESCRIPTION?\bsleep\b suspends execution for at least the time specified "
+ "by \aseconds\a or until a \bSIGALRM\b signal is received. "
+ "\aseconds\a can be specifed as a floating point number but the "
+ "actual granularity depends on the underlying system, normally "
+ "around 1 millisecond.]"
+"\n"
+"\nseconds\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?The execution was successfully suspended for at least \atime\a "
+ "seconds, or a \bSIGALRM\b signal was received.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\btime\b(1), \bwait\b(1)]"
+;
+
+const char sh_opttrap[] =
+"[-1c?\n@(#)$Id: trap (AT&T Research) 1999-07-17 $\n]"
+USAGE_LICENSE
+"[+NAME?trap - trap signals and conditions]"
+"[+DESCRIPTION?\btrap\b is a special built-in that defines actions to be "
+ "taken when conditions such as receiving a signal occur. Also, "
+ "\btrap\b can be used to display the current trap settings on "
+ "standard output.]"
+"[+?If \aaction\a is \b-\b, \btrap\b resets each \acondition\a "
+ "to the default value. If \aaction\a is an empty string, the "
+ "shell ignores each of the \acondition\as if they arise. "
+ "Otherwise, the argument \aaction\a will be read and executed "
+ "by the shell as if it were processed by \beval\b(1) when one "
+ "of the corresponding conditions arise. The action of the trap "
+ "will override any previous action associated with each specified "
+ "\acondition\a. The value of \b$?\b is not altered by the trap "
+ "execution.]"
+"[+?\acondition\a can be the name or number of a signal, or one of the "
+ "following:]{"
+ "[+EXIT?This trap is executed when the shell exits. If defined "
+ "within a function defined with the \bfunction\b reserved "
+ "word, the trap is executed in the caller's environment "
+ "when the function returns and the trap action is restored "
+ "to the value it had when it called the function.]"
+ "[+0?Same as EXIT.]"
+ "[+DEBUG?Executed before each simple command is executed but after "
+ "the arguments are expanded.]"
+ "[+ERR?Executed whenever \bset -e\b would cause the shell to exit.]"
+ "[+KEYBD?Executed when a key is entered from a terminal device.]"
+"}"
+"[+?Signal names are case insensitive and the \bsig\b prefix is optional. "
+ "Signals that were ignored on entry to a noninteractive shell cannot "
+ "trapped or reset although doing so will not report an error. The "
+ "use of signal numbers other than \b1\b, \b2\b, \b3\b, \b6\b, "
+ "\b9\b, \b14\b, and \b15\b is not portable.]"
+"[+?Although \btrap\b is a special built-in, specifying a condition that "
+ "the shell does not know about causes \btrap\b to exit with a "
+ "non-zero exit status, but does not terminate the invoking shell.]"
+"[+?If no \aaction\a or \acondition\as are specified then all the current "
+ "trap settings are written to standard output.]"
+"[p?Causes the current traps to be output in a format that can be processed "
+ "as input to the shell to recreate the current traps.]"
+"\n"
+"\n[action condition ...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Successful completion.]"
+ "[+>0?An error occurred.]"
+"}"
+
+"[+SEE ALSO?\bkill\b(1), \beval\b(1), \bsignal\b(3)]"
+;
+
+const char sh_opttypeset[] =
+"+[-1c?\n@(#)$Id: typeset (AT&T Research) 2003-01-15 $\n]"
+USAGE_LICENSE
+"[+NAME?\f?\f - declare or display variables with attributes]"
+"[+DESCRIPTION?Without the \b-f\b option, \b\f?\f\b sets, unsets, "
+ "or displays attributes of variables as specified with the "
+ "options. If the first option is specified with a \b-\b "
+ "then the attributes are set for each of the given \aname\as. "
+ "If the first option is specified with a \b+\b, then the specified "
+ "attributes are unset. If \b=\b\avalue\a is specified value is "
+ "assigned before the attributes are set.]"
+"[+?When \b\f?\f\b is called inside a function defined with the "
+ "\bfunction\b reserved word, and \aname\a does not contain a "
+ "\b.\b, then a local variable statically scoped to that function "
+ "will be created.]"
+"[+?Not all option combinations are possible. For example, the numeric "
+ "options \b-i\b, \b-E\b, and \b-F\b cannot be specified with "
+ "the justification options \b-L\b, \b-R\b, and \b-Z\b.]"
+"[+?Note that the following preset aliases are set by the shell:]{"
+ "[+float?\b\f?\f -E\b.]"
+ "[+functions?\b\f?\f -f\b.]"
+ "[+integer?\b\f?\f -i\b.]"
+ "[+nameref?\b\f?\f -n\b.]"
+"}"
+"[+?If no \aname\as are specified then variables that have the specified "
+ "options are displayed. If the first option is specified with "
+ "a leading \b-\b then the name and value of each variable is "
+ "written to standard output. Otherwise, only the names are "
+ "written. If no options are specified or just \b-p\b is "
+ "specified, then the names and attributes of all variables that have "
+ "attributes are written to standard output. When \b-f\b is specified, "
+ "the names displayed will be function names.]"
+"[+?If \b-f\b is specified, then each \aname\a refers to a function "
+ "and the only valid options are \b-u\b and \b-t\b. In this "
+ "case no \b=\b\avalue\a can be specified.]"
+"[+?\b\f?\f\b is built-in to the shell as a declaration command so that "
+ "field splitting and pathname expansion are not performed on "
+ "the arguments. Tilde expansion occurs on \avalue\a.]"
+#if SHOPT_BASH
+"[a?Ignored, used for bash compatibility.]"
+#endif
+"[a?Indexed array. this is the default.]"
+"[b?Each \aname\a may contain binary data. Its value is the mime "
+ "base64 encoding of the data. It can be used with \b-Z\b, "
+ "to specify fixed sized fields.]"
+"[f?Each of the options and \aname\as refers to a function.]"
+"[i]#?[base:=10?An integer. \abase\a represents the arithmetic base "
+ "from 2 to 64.]"
+"[l?Convert uppercase character to lowercase. Unsets \b-u\b attribute. When "
+ "used with \b-i\b, \b-E\b, or \b-F\b indicates long variant.]"
+"[n?Name reference. The value is the name of a variable that \aname\a "
+ "references. \aname\a cannot contain a \b.\b.]"
+"[p?Causes the output to be in a format that can be used as input to the "
+ "shell to recreate the attributes for variables.]"
+"[r?Enables readonly. Once enabled it cannot be disabled. See "
+ "\breadonly\b(1).]"
+"[s?Used with \b-i\b to restrict integer size to short.]"
+"[t?When used with \b-f\b, enables tracing for each of the specified "
+ "functions. Otherwise, \b-t\b is a user defined attribute and "
+ "has no meaning to the shell.]"
+"[u?Without \b-f\b or \b-i\b, converts lowercase character to uppercase "
+ "and unsets \b-l\b. With \b-f\b specifies that \aname\a is a function "
+ "that hasn't been loaded yet. With \b-i\b specifies that the "
+ "value will be displayed as an unsigned integer.]"
+"[x?Puts each \aname\a on the export list. See \bexport\b(1). \aname\a "
+ "cannot contain a \b.\b.]"
+"[A?Associative array. Each \aname\a will converted to an associate "
+ "array. If a variable already exists, the current value will "
+ "become index \b0\b.]"
+"[E]#?[n:=10?Floating point number represented in scientific notation. "
+ "\an\a specifies the number of significant figures when the "
+ "value is expanded.]"
+"[F]#?[n:=10?Floating point. \an\a is the number of places after the "
+ "decimal point when the value is expanded.]"
+"[H?Hostname mapping. Each \aname\a holds a native pathname. Assigning a "
+ "UNIX format pathname will cause it to be converted to a pathname "
+ "suitable for the current host. This has no effect when the "
+ "native system is UNIX.]"
+"[L]#?[n?Left justify. If \an\a is given it represents the field width. If "
+ "the \b-Z\b attribute is also specified, then leading zeros are "
+ "stripped.]"
+"[R]#?[n?Right justify. If \an\a is given it represents the field width. If "
+ "the \b-Z\b attribute is also specified, then zeros will "
+ "be used as the fill character. Otherwise, spaces are used.]"
+"[T]:[tname?\atname\a is the name of a type name given to each \aname\a.]"
+"[Z]#?[n?Zero fill. If \an\a is given it represents the field width.]"
+"\n"
+"\n[name[=value]...]\n"
+" -f [name...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?No errors occurred.]"
+ "[+>0?An error occurred.]"
+"}"
+
+"[+SEE ALSO?\breadonly\b(1), \bexport\b(1)]"
+;
+
+const char sh_optulimit[] =
+"[-1c?@(#)$Id: ulimit (AT&T Research) 2003-06-21 $\n]"
+USAGE_LICENSE
+"[+NAME?ulimit - set or display resource limits]"
+"[+DESCRIPTION?\bulimit\b sets or displays resource limits. These "
+ "limits apply to the current process and to each child process "
+ "created after the resource limit has been set. If \alimit\a "
+ "is specified, the resource limit is set, otherwise, its current value "
+ "is displayed on standard output.]"
+"[+?Increasing the limit for a resource usually requires special privileges. "
+ "Some systems allow you to lower resource limits and later increase "
+ "them. These are called soft limits. Once a hard limit is "
+ "set the resource can not be increased.]"
+"[+?Different systems allow you to specify different resources and some "
+ "restrict how much you can raise the limit of the resource.]"
+"[+?The value of \alimit\a depends on the unit of the resource listed "
+ "for each resource. In addition, \alimit\a can be \bunlimited\b "
+ "to indicate no limit for that resource.]"
+"[+?If you do not specify \b-H\b or \b-S\b, then \b-S\b is used for "
+ "listing and both \b-S\b and \b-H\b are used for setting resources.]"
+"[+?If you do not specify any resource, the default is \b-f\b.]"
+"[H?A hard limit is set or displayed.]"
+"[S?A soft limit is set or displayed.]"
+"[a?Displays all current resource limits]"
+"\flimits\f"
+"\n"
+"\n[limit]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Successful completion.]"
+ "[+>0?A request for a higher limit was rejected or an error occurred.]"
+"}"
+
+"[+SEE ALSO?\bulimit\b(2), \bgetrlimit\b(2)]"
+;
+
+const char sh_optumask[] =
+"[-1c?\n@(#)$Id: umask (AT&T Research) 1999-04-07 $\n]"
+USAGE_LICENSE
+"[+NAME?umask - get or set the file creation mask]"
+"[+DESCRIPTION?\bumask\b sets the file creation mask of the current "
+ "shell execution environment to the value specified by the "
+ "\amask\a operand. This mask affects the file permission bits "
+ "of subsequently created files. \amask\a can either be an "
+ "octal number or a symbolic value as described in \bchmod\b(1). "
+ "If a symbolic value is given, the new file creation mask is the "
+ "complement of the result of applying \amask\a to the complement "
+ "of the current file creation mask.]"
+"[+?If \amask\a is not specified, \bumask\b writes the value of the "
+ "file creation mask for the current process to standard output.]"
+"[S?Causes the file creation mask to be written or treated as a symbolic value "
+ "rather than an octal number.]"
+"\n"
+"\n[mask]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?The file creation mask was successfully changed, or no "
+ "\amask\a operand was supplied.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bchmod\b(1)]"
+;
+const char sh_optuniverse[] = " [name]";
+const char sh_optunset[] =
+"[-1c?\n@(#)$Id: unset (AT&T Research) 1999-07-07 $\n]"
+USAGE_LICENSE
+"[+NAME?unset - unset values and attributes of variables and functions]"
+"[+DESCRIPTION?For each \aname\a specified, \bunset\b unsets the variable, "
+ "or function if \b-f\b is specified, from the current shell "
+ "execution environment. Readonly variables cannot be unset.]"
+"[n?If \aname\a refers to variable that is a reference, the variable \aname\a "
+ "will be unset rather than the variable it references. Otherwise, "
+ "is is equivalent to \b-v\b.]"
+"[f?\aname\a refers to a function name and the shell will unset the "
+ "function definition.]"
+"[v?\aname\a refers to a variable name and the shell will unset it and "
+ "remove it from the environment. This is the default behavior.]"
+"\n"
+"\nname...\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?All \aname\as were successfully unset.]"
+ "[+>0?One or more \aname\a operands could not be unset "
+ "or an error occurred.]"
+"}"
+
+"[+SEE ALSO?\btypeset\b(1)]"
+;
+
+const char sh_optunalias[] =
+"[-1c?\n@(#)$Id: unalias (AT&T Research) 1999-07-07 $\n]"
+USAGE_LICENSE
+"[+NAME?unalias - remove alias definitions]"
+"[+DESCRIPTION?\bunalias\b removes the definition of each named alias "
+ "from the current shell execution environment, or all aliases if "
+ "\b-a\b is specified. It will not affect any commands that "
+ "have already been read and subsequently executed.]"
+"[a?Causes all alias definitions to be removed. \aname\a operands "
+ "are optional and ignored in this case.]"
+"\n"
+"\nname...\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Successful completion.]"
+ "[+>0?\b-a\b was not specified and one or more \aname\a operands "
+ "did not have an alias definition, or an error occurred.]"
+"}"
+
+"[+SEE ALSO?\balias\b(1)]"
+;
+
+const char sh_optwait[] =
+"[-1c?\n@(#)$Id: wait (AT&T Research) 1999-06-17 $\n]"
+USAGE_LICENSE
+"[+NAME?wait - wait for process or job completion]"
+"[+DESCRIPTION?\bwait\b with no operands, waits until all jobs "
+ "known to the invoking shell have terminated. If one or more "
+ "\ajob\a operands are specified, \bwait\b waits until all of them "
+ "have completed.]"
+"[+?Each \ajob\a can be specified as one of the following:]{"
+ "[+\anumber\a?\anumber\a refers to a process id.]"
+ "[+-\anumber\a?\anumber\a refers to a process group id.]"
+ "[+%\anumber\a?\anumber\a refer to a job number.]"
+ "[+%\astring\a?Refers to a job whose name begins with \astring\a.]"
+ "[+%??\astring\a?Refers to a job whose name contains \astring\a.]"
+ "[+%+ \bor\b %%?Refers to the current job.]"
+ "[+%-?Refers to the previous job.]"
+"}"
+"[+?If one ore more \ajob\a operands is a process id or process group id "
+ "not known by the current shell environment, \bwait\b treats each "
+ "of them as if it were a process that exited with status 127.]"
+"\n"
+"\n[job ...]\n"
+"\n"
+"[+EXIT STATUS?If \await\a is invoked with one or more \ajob\as, and all of "
+ "them have terminated or were not known by the invoking shell, "
+ "the exit status of \bwait\b will be that of the last \ajob\a. "
+ "Otherwise, it will be one of the following:]{"
+ "[+0?\bwait\b utility was invoked with no operands and all "
+ "processes known by the invoking process have terminated.]"
+ "[+127?\ajob\a is a process id or process group id that is unknown "
+ "to the current shell environment.]"
+"}"
+
+"[+SEE ALSO?\bjobs\b(1), \bps\b(1)]"
+;
+
+#if SHOPT_FS_3D
+ const char sh_optvpath[] = " [top] [base]";
+ const char sh_optvmap[] = " [dir] [list]";
+#endif /* SHOPT_FS_3D */
+
+const char sh_optwhence[] =
+"[-1c?\n@(#)$Id: whence (AT&T Research) 1999-07-07 $\n]"
+USAGE_LICENSE
+"[+NAME?whence - locate a command and describe its type]"
+"[+DESCRIPTION?Without \b-v\b, \bwhence\b writes on standard output an "
+ "absolute pathname, if any, corresponding to \aname\a based "
+ "on the complete search order that the shell uses. If \aname\a "
+ "is not found, then no output is produced.]"
+"[+?If \b-v\b is specified, the output will also contain information "
+ "that indicates how the given \aname\a would be interpretted by "
+ "the shell in the current execution environment.]"
+"[a?Displays all uses for each \aname\a rather than the first.]"
+"[f?Do not check for functions.]"
+"[p?Do not check to see if \aname\a is a reserved word, a built-in, "
+ "an alias, or a function.]"
+"[v?For each name you specify, the shell displays a line that indicates "
+ "if that name is one of the following:]{"
+ "[+?Reserved word]"
+ "[+?Alias]"
+ "[+?Built-in]"
+ "[+?Undefined function]"
+ "[+?Function]"
+ "[+?Tracked alias]"
+ "[+?Program]"
+ "[+?Not found]"
+"}"
+"\n"
+"\nname ...\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Each \aname\a was found by the shell.]"
+ "[+1?One or more \aname\as were not found by the shell.]"
+ "[+>1?An error occurred.]"
+"}"
+
+"[+SEE ALSO?\bcommand\b(1)]"
+;
+
+
+const char e_alrm1[] = "alarm -r %s +%.3g\n";
+const char e_alrm2[] = "alarm %s %.3f\n";
+const char e_baddisc[] = "%s: invalid discipline function";
+const char e_nospace[] = "out of memory";
+const char e_nofork[] = "cannot fork";
+const char e_nosignal[] = "%s: unknown signal name";
+const char e_numeric[] = "*([0-9])?(.)*([0-9])";
+const char e_condition[] = "condition(s) required";
+const char e_cneedsarg[] = "-c requires argument";
diff --git a/usr/src/lib/libshell/common/data/keywords.c b/usr/src/lib/libshell/common/data/keywords.c
new file mode 100644
index 0000000000..66b3c3cea2
--- /dev/null
+++ b/usr/src/lib/libshell/common/data/keywords.c
@@ -0,0 +1,63 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#include "shtable.h"
+#include <shell.h>
+#include "shlex.h"
+#include "FEATURE/options"
+
+/*
+ * table of reserved words in shell language
+ * This list must be in in ascii sorted order
+ */
+
+const Shtable_t shtab_reserved[] =
+{
+ "!", NOTSYM,
+ "[[", BTESTSYM,
+ "case", CASESYM,
+ "do", DOSYM,
+ "done", DONESYM,
+ "elif", ELIFSYM,
+ "else", ELSESYM,
+ "esac", ESACSYM,
+ "fi", FISYM,
+ "for", FORSYM,
+ "function", FUNCTSYM,
+ "if", IFSYM,
+ "in", INSYM,
+#if SHOPT_NAMESPACE
+ "namespace", NSPACESYM,
+#endif /* SHOPT_NAMESPACE */
+ "select", SELECTSYM,
+ "then", THENSYM,
+ "time", TIMESYM,
+ "until", UNTILSYM,
+ "while", WHILESYM,
+ "{", LBRACE,
+ "}", RBRACE,
+ "", 0,
+};
+
+const char e_unexpected[] = "unexpected";
+const char e_unmatched[] = "unmatched";
+const char e_endoffile[] = "end of file";
+const char e_newline[] = "newline";
+
diff --git a/usr/src/lib/libshell/common/data/lexstates.c b/usr/src/lib/libshell/common/data/lexstates.c
new file mode 100644
index 0000000000..0cedf9a4dc
--- /dev/null
+++ b/usr/src/lib/libshell/common/data/lexstates.c
@@ -0,0 +1,411 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+
+#include "FEATURE/options"
+#include "lexstates.h"
+
+
+/*
+ * This is the initial state for tokens
+ */
+static const char sh_lexstate0[256] =
+{
+ S_EOF, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+#if SHOPT_CRNL
+ S_REG, 0, S_NLTOK,S_REG, S_REG, 0, S_REG, S_REG,
+#else
+ S_REG, 0, S_NLTOK,S_REG, S_REG, S_REG, S_REG, S_REG,
+#endif /* SHOPT_CRNL */
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+
+ 0, S_REG, S_REG, S_COM, S_REG, S_REG, S_OP, S_REG,
+ S_OP, S_OP, S_REG, S_REG, S_REG, S_REG, S_NAME, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_OP, S_OP, S_REG, S_OP, S_REG,
+
+ S_REG, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME,
+ S_NAME, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME,
+ S_NAME, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME,
+ S_NAME, S_NAME, S_NAME, S_REG, S_REG, S_REG, S_REG, S_NAME,
+
+ S_REG, S_NAME, S_NAME, S_RES, S_RES, S_RES, S_RES, S_NAME,
+#if SHOPT_NAMESPACE
+ S_NAME, S_RES, S_NAME, S_NAME, S_NAME, S_NAME, S_RES, S_NAME,
+#else
+ S_NAME, S_RES, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME,
+#endif /* SHOPT_NAMESPACE */
+ S_NAME, S_NAME, S_NAME, S_RES, S_RES, S_RES, S_NAME, S_RES,
+ S_NAME, S_NAME, S_NAME, S_REG, S_OP, S_REG, S_TILDE,S_REG,
+
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+};
+
+/*
+ * This state is for identifiers
+ */
+static const char sh_lexstate1[256] =
+{
+ S_EOF, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+#if SHOPT_CRNL
+ S_REG, S_BREAK,S_BREAK,S_REG, S_REG, S_BREAK,S_REG, S_REG,
+#else
+ S_REG, S_BREAK,S_BREAK,S_REG, S_REG, S_REG, S_REG, S_REG,
+#endif /* SHOPT_CRNL */
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+
+ S_BREAK,S_EPAT, S_QUOTE,S_REG, S_DOL, S_EPAT, S_BREAK,S_LIT,
+ S_BREAK,S_BREAK,S_PAT, S_EPAT, S_REG, S_EPAT, S_DOT, S_REG,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, S_LABEL,S_BREAK,S_BREAK,S_EQ, S_BREAK,S_PAT,
+
+ S_EPAT, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, S_BRACT,S_ESC, S_REG, S_REG, 0,
+
+ S_GRAVE,0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, S_BRACE,S_BREAK,S_BRACE,S_EPAT, S_REG,
+
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+ S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
+};
+
+static const char sh_lexstate2[256] =
+{
+ S_EOF, 0, 0, 0, 0, 0, 0, 0,
+#if SHOPT_CRNL
+ 0, S_BREAK,S_BREAK,0, 0, S_BREAK,0, 0,
+#else
+ 0, S_BREAK,S_BREAK,0, 0, 0, 0, 0,
+#endif /* SHOPT_CRNL */
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+
+ S_BREAK,S_EPAT, S_QUOTE,0, S_DOL, S_EPAT, S_BREAK,S_LIT,
+ S_BREAK,S_BREAK,S_PAT, S_EPAT, 0, S_EPAT, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, S_COLON,S_BREAK,S_BREAK,0, S_BREAK,S_PAT,
+
+ S_EPAT, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, S_PAT, S_ESC, 0, 0, 0,
+
+ S_GRAVE,0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, S_BRACE,S_BREAK,S_BRACE,S_EPAT, 0,
+};
+
+/*
+ * for skipping over '...'
+ */
+static const char sh_lexstate3[256] =
+{
+ S_EOF, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, S_NL, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 0, 0, 0, 0, S_LIT,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, S_ESC2, 0, 0, 0
+};
+
+/*
+ * for skipping over "..." and `...`
+ */
+static const char sh_lexstate4[256] =
+{
+ S_EOF, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, S_NL, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, S_QUOTE,0, S_DOL, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, S_ESC, 0, 0, 0,
+ S_GRAVE,0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, S_RBRA, 0, 0
+};
+
+/*
+ * for skipping over ?(...), [...]
+ */
+static const char sh_lexstate5[256] =
+{
+ S_EOF, 0, 0, 0, 0, 0, 0, 0,
+ 0, S_BLNK, S_NL, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ S_BLNK, 0, S_QUOTE,0, S_DOL, 0, S_META, S_LIT,
+ S_PUSH, S_POP, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, S_POP, S_META, 0, S_META, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, S_BRACT,S_ESC, S_POP, 0, 0,
+ S_GRAVE,0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, S_BRACE,S_META, S_POP, 0, 0
+};
+
+/*
+ * Defines valid expansion characters
+ */
+static const char sh_lexstate6[256] =
+{
+ S_EOF, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+
+ S_ERR, S_SPC1, S_ERR, S_SPC1, S_SPC2, S_ERR, S_ERR, S_LIT,
+ S_PAR, S_ERR, S_SPC2, S_ERR, S_ERR, S_SPC2, S_ALP, S_ERR,
+ S_DIG, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG,
+ S_DIG, S_DIG, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_SPC2,
+
+#if SHOPT_TYPEDEF
+ S_SPC1, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP,
+#else
+ S_SPC2, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP,
+#endif
+ S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP,
+ S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP,
+ S_ALP, S_ALP, S_ALP, S_ERR, S_ERR, S_ERR, S_ERR, S_ALP,
+
+ S_ERR, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP,
+ S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP,
+ S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP,
+ S_ALP, S_ALP, S_ALP, S_LBRA, S_ERR, S_RBRA, S_ERR, S_ERR,
+
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+};
+
+/*
+ * for skipping over ${...} until modifier
+ */
+static const char sh_lexstate7[256] =
+{
+ S_EOF, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+
+ S_ERR, S_ERR, S_ERR, S_MOD2, S_ERR, S_MOD2, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_MOD1, S_MOD1, S_ERR, S_MOD1, S_DOT, S_MOD2,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, S_MOD1, S_ERR, S_ERR, S_MOD1, S_ERR, S_MOD1,
+
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, S_BRACT,S_ESC, S_ERR, S_ERR, 0,
+
+ S_ERR, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, S_ERR, S_ERR, S_POP, S_ERR, S_ERR,
+
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+ S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
+};
+
+/*
+ * This state is for $name
+ */
+static const char sh_lexstate8[256] =
+{
+ S_EOF, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+
+ S_EDOL, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, S_EDOL, S_EDOL, S_EDOL, S_EDOL, 0,
+
+ S_EDOL,0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+ S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
+};
+
+/*
+ * This is used for macro expansion
+ */
+static const char sh_lexstate9[256] =
+{
+ S_EOF, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, S_QUOTE,0, S_DOL, 0, S_PAT, S_LIT,
+ S_PAT, S_PAT, S_PAT, 0, 0, 0, 0, S_SLASH,
+ 0, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG,
+ S_DIG, S_DIG, S_COLON,0, 0, S_EQ, 0, S_PAT,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, S_BRACT,S_ESC, S_ENDCH,0, 0,
+ S_GRAVE,0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+#if SHOPT_BRACEPAT
+ 0, 0, 0, S_BRACE,S_PAT, S_ENDCH,0, 0
+#else
+ 0, 0, 0, 0, S_PAT, S_ENDCH,0, 0
+#endif /* SHOPT_BRACEPAT */
+};
+
+const char *sh_lexrstates[ST_NONE] =
+{
+ sh_lexstate0, sh_lexstate1, sh_lexstate2, sh_lexstate3,
+ sh_lexstate4, sh_lexstate5, sh_lexstate6, sh_lexstate7,
+ sh_lexstate8, sh_lexstate9, sh_lexstate5
+};
+
+
+const char e_lexversion[] = "%d: invalid binary script version";
+const char e_lexspace[] = "line %d: use space or tab to separate operators %c and %c";
+const char e_lexslash[] = "line %d: $ not preceeded by \\";
+const char e_lexsyntax1[] = "syntax error at line %d: `%s' %s";
+const char e_lexsyntax2[] = "syntax error: `%s' %s";
+const char e_lexsyntax3[] = "syntax error at line %d: duplicate label %s";
+const char e_lexlabignore[] = "line %d: label %s ignored";
+const char e_lexlabunknown[] = "line %d: %s unknown label";
+const char e_lexobsolete1[] = "line %d: `...` obsolete, use $(...)";
+const char e_lexobsolete2[] = "line %d: -a obsolete, use -e";
+const char e_lexobsolete3[] = "line %d: '=' obsolete, use '=='";
+const char e_lexobsolete4[] = "line %d: %s within [[...]] obsolete, use ((...))";
+const char e_lexobsolete5[] = "line %d: set %s obsolete";
+const char e_lexobsolete6[] = "line %d: `{' instead of `in' is obsolete";
+const char e_lexusebrace[] = "line %d: use braces to avoid ambiguities with $id[...]";
+const char e_lexusequote[] = "line %d: %c within ${} should be quoted";
+const char e_lexescape[] = "line %d: escape %c to avoid ambiguities";
+const char e_lexquote[] = "line %d: quote %c to avoid ambiguities";
+const char e_lexnested[] = "line %d: spaces required for nested subshell";
+const char e_lexbadchar[] = "%c: invalid character in expression - %s";
+const char e_lexfuture[] = "line %d: \\ in front of %c reserved for future use";
+const char e_lexlongquote[] = "line %d: %c quote may be missing";
+const char e_lexzerobyte[] = "zero byte";
+const char e_lexemptyfor[] = "line %d: empty for list";
diff --git a/usr/src/lib/libshell/common/data/limits.c b/usr/src/lib/libshell/common/data/limits.c
new file mode 100644
index 0000000000..9f0a87b3e8
--- /dev/null
+++ b/usr/src/lib/libshell/common/data/limits.c
@@ -0,0 +1,57 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+#include "ulimit.h"
+
+/*
+ * This is the list of resouce limits controlled by ulimit
+ * This command requires getrlimit(), vlimit(), or ulimit()
+ */
+
+#ifndef _no_ulimit
+
+const char e_unlimited[] = "unlimited";
+const char* e_units[] = { 0, "block", "byte", "kbyte", "second" };
+
+const int shtab_units[] = { 1, 512, 1, 1024, 1 };
+
+const Limit_t shtab_limits[] =
+{
+"as", "address space limit", RLIMIT_AS, 0, 'M', LIM_KBYTE,
+"core", "core file size", RLIMIT_CORE, 0, 'c', LIM_BLOCK,
+"cpu", "cpu time", RLIMIT_CPU, 0, 't', LIM_SECOND,
+"data", "data size", RLIMIT_DATA, 0, 'd', LIM_KBYTE,
+"fsize", "file size", RLIMIT_FSIZE, 0, 'f', LIM_BLOCK,
+"locks", "number of file locks", RLIMIT_LOCKS, 0, 'L', LIM_COUNT,
+"memlock", "locked address space", RLIMIT_MEMLOCK, 0, 'l', LIM_KBYTE,
+"nofile", "number of open files", RLIMIT_NOFILE, "OPEN_MAX", 'n', LIM_COUNT,
+"nproc", "number of processes", RLIMIT_NPROC, "CHILD_MAX", 'u', LIM_COUNT,
+"pipe", "pipe buffer size", RLIMIT_PIPE, "PIPE_BUF", 'p', LIM_BYTE,
+"rss", "resident set size", RLIMIT_RSS, 0, 'm', LIM_KBYTE,
+"sbsize", "socket buffer size", RLIMIT_SBSIZE, "PIPE_BUF", 'b', LIM_BYTE,
+"stack", "stack size", RLIMIT_STACK, 0, 's', LIM_KBYTE,
+"threads", "number of threads", RLIMIT_PTHREAD, "THREADS_MAX", 'T', LIM_COUNT,
+"vmem", "process size", RLIMIT_VMEM, 0, 'v', LIM_KBYTE,
+{ 0 }
+};
+
+#endif
diff --git a/usr/src/lib/libshell/common/data/math.tab b/usr/src/lib/libshell/common/data/math.tab
new file mode 100644
index 0000000000..cecfc12a34
--- /dev/null
+++ b/usr/src/lib/libshell/common/data/math.tab
@@ -0,0 +1,64 @@
+# <return type: i:integer f:floating-point> <#floating-point-args> <function-name> [<alias> ...]
+# <function-name>l variants are handled by features/math.sh
+# @(#)math.tab (AT&T Research) 2006-10-18
+f 1 acos
+f 1 acosh
+f 1 asin
+f 1 asinh
+f 1 atan
+f 2 atan2
+f 1 atanh
+f 1 cbrt
+f 2 copysign
+f 1 cos
+f 1 cosh
+f 1 erf
+f 1 erfc
+f 1 exp
+f 1 exp2
+f 1 expm1
+f 1 fabs abs
+f 2 fdim
+f 1 finite
+f 1 floor int
+f 3 fma
+f 2 fmax
+f 2 fmin
+f 2 fmod
+i 1 fpclassify
+f 2 hypot
+i 1 ilogb
+i 1 isfinite
+i 2 isgreater
+i 2 isgreaterequal
+i 1 isinf
+i 2 isless
+i 2 islessequal
+i 2 islessgreater
+i 1 isnan
+i 1 isnormal
+i 1 issubnormal
+i 2 isunordered
+i 1 iszero
+f 1 lgamma
+f 1 log
+f 1 log1p
+f 1 log2
+f 1 logb
+f 1 nearbyint
+f 2 nextafter
+f 2 nexttoward
+f 2 pow
+f 2 remainder
+f 1 rint
+f 1 round
+f 2 scalb
+f 2 scalbn
+i 1 signbit
+f 1 sin
+f 1 sinh
+f 1 sqrt
+f 1 tan
+f 1 tanh
+f 1 tgamma
+f 1 trunc
diff --git a/usr/src/lib/libshell/common/data/msg.c b/usr/src/lib/libshell/common/data/msg.c
new file mode 100644
index 0000000000..498f6558d0
--- /dev/null
+++ b/usr/src/lib/libshell/common/data/msg.c
@@ -0,0 +1,188 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * UNIX shell
+ * S. R. Bourne
+ * Rewritten by David Korn
+ *
+ * AT&T Labs
+ *
+ */
+
+#include <ast.h>
+#include <errno.h>
+#include "defs.h"
+#include "path.h"
+#include "io.h"
+#include "shlex.h"
+#include "timeout.h"
+#include "history.h"
+#include "builtins.h"
+#include "jobs.h"
+#include "edit.h"
+
+/* error messages */
+const char e_timewarn[] = "\r\n\ashell will timeout in 60 seconds due to inactivity";
+const char e_runvi[] = "\\hist -e \"${VISUAL:-${EDITOR:-vi}}\" ";
+const char e_timeout[] = "timed out waiting for input";
+const char e_mailmsg[] = "you have mail in $_";
+const char e_query[] = "no query process";
+const char e_history[] = "no history file";
+const char e_histopen[] = "history file cannot open";
+const char e_option[] = "%s: bad option(s)";
+const char e_toomany[] = "open file limit exceeded";
+const char e_argtype[] = "invalid argument of type %c";
+const char e_formspec[] = "%c: unknown format specifier";
+const char e_badregexp[] = "%s: invalid regular expression";
+const char e_number[] = "%s: bad number";
+const char e_badlocale[] = "%s: unknown locale";
+const char e_nullset[] = "%s: parameter null";
+const char e_notset[] = "%s: parameter not set";
+const char e_noparent[] = "%s: no parent";
+const char e_subst[] = "%s: bad substitution";
+const char e_create[] = "%s: cannot create";
+const char e_tmpcreate[] = "cannot create temporary file";
+const char e_restricted[] = "%s: restricted";
+const char e_pfsh[] = "%s: disabled in profile shell";
+const char e_pexists[] = "process already exists";
+const char e_exists[] = "%s: file already exists";
+const char e_pipe[] = "cannot create pipe";
+const char e_alarm[] = "cannot set alarm";
+const char e_open[] = "%s: cannot open";
+const char e_notseek[] = "%s: not seekable";
+const char e_badseek[] = "%s: invalid seek offset";
+const char e_badpattern[] = "%s: invalid shell pattern";
+const char e_noread[] = "%s: pattern seek requires read access";
+const char e_logout[] = "Use 'exit' to terminate this shell";
+const char e_exec[] = "%s: cannot execute";
+const char e_pwd[] = "cannot access parent directories";
+const char e_found[] = "%s: not found";
+const char e_defined[] = "%s: function not defined";
+const char e_nointerp[] = "%s: interpreter not found";
+const char e_subscript[] = "%s: subscript out of range";
+const char e_toodeep[] = "%s: recursion too deep";
+const char e_access[] = "permission denied";
+#ifdef _cmd_universe
+ const char e_nouniverse[] = "universe not accessible";
+#endif /* _cmd_universe */
+const char e_direct[] = "bad directory";
+const char e_file[] = "%s: bad file unit number";
+const char e_trap[] = "%s: bad trap";
+const char e_readonly[] = "%s: is read only";
+const char e_badfield[] = "%d: negative field size";
+const char e_ident[] = "%s: is not an identifier";
+const char e_badname[] = "%s: invalid name";
+const char e_varname[] = "%s: invalid variable name";
+const char e_badfun[] = "%s: invalid function name";
+const char e_aliname[] = "%s: invalid alias name";
+const char e_badexport[] = "%s: invalid export name";
+const char e_badref[] = "%s: reference variable cannot be an array";
+const char e_noarray[] = "%s: cannot be an array";
+const char e_noref[] = "%s: no reference name";
+const char e_selfref[] = "%s: invalid self reference";
+const char e_noalias[] = "%s: alias not found\n";
+const char e_format[] = "%s: bad format";
+const char e_redef[] = "%s: type cannot be redefined";
+const char e_badtformat[] = "%c: bad format character in time format";
+const char e_nolabels[] = "%s: label not implemented";
+const char e_notimp[] = "%s: not implemented";
+const char e_nosupport[] = "not supported";
+const char e_badrange[] = "%d-%d: invalid range";
+const char e_eneedsarg[] = "-e - requires single argument";
+const char e_badbase[] = "%s unknown base";
+const char e_loop[] = "%s: would cause loop";
+const char e_overlimit[] = "%s: limit exceeded";
+const char e_badsyntax[] = "incorrect syntax";
+const char e_badwrite[] = "write to %d failed";
+const char e_on [] = "on";
+const char e_off[] = "off";
+const char is_reserved[] = " is a keyword";
+const char is_builtin[] = " is a shell builtin";
+const char is_builtver[] = "is a shell builtin version of";
+const char is_alias[] = "%s is an alias for ";
+const char is_xalias[] = "%s is an exported alias for ";
+const char is_talias[] = "is a tracked alias for";
+const char is_function[] = " is a function";
+const char is_ufunction[] = " is an undefined function";
+#ifdef JOBS
+# ifdef SIGTSTP
+ const char e_newtty[] = "Switching to new tty driver...";
+ const char e_oldtty[] = "Reverting to old tty driver...";
+ const char e_no_start[] = "Cannot start job control";
+# endif /*SIGTSTP */
+ const char e_no_jctl[] = "No job control";
+ const char e_terminate[] = "You have stopped jobs";
+ const char e_done[] = " Done";
+ const char e_nlspace[] = "\n ";
+ const char e_running[] = " Running";
+ const char e_ambiguous[] = "%s: Ambiguous";
+ const char e_jobsrunning[] = "You have running jobs";
+ const char e_no_job[] = "no such job";
+ const char e_no_proc[] = "no such process";
+ const char e_jobusage[] = "%s: Arguments must be %%job or process ids";
+#endif /* JOBS */
+const char e_coredump[] = "(coredump)";
+const char e_alphanum[] = "[_[:alpha:]]*([_[:alnum:]])";
+const char e_devfdNN[] = "/dev/fd/+([0-9])";
+const char e_devfdstd[] = "/dev/@(fd/+([0-9])|std@(in|out|err))";
+const char e_signo[] = "Signal %d";
+#if SHOPT_FS_3D
+ const char e_cantget[] = "cannot get %s";
+ const char e_cantset[] = "cannot set %s";
+ const char e_mapping[] = "mapping";
+ const char e_versions[] = "versions";
+#endif /* SHOPT_FS_3D */
+
+/* string constants */
+const char e_heading[] = "Current option settings";
+const char e_sptbnl[] = " \t\n";
+const char e_defpath[] = "/bin:/usr/bin:";
+const char e_defedit[] = "/bin/ed";
+const char e_unknown [] = "<command unknown>";
+const char e_devnull[] = "/dev/null";
+const char e_traceprompt[] = "+ ";
+const char e_supprompt[] = "# ";
+const char e_stdprompt[] = "$ ";
+const char e_profile[] = "$HOME/.profile";
+const char e_sysprofile[] = "/etc/profile";
+const char e_suidprofile[] = "/etc/suid_profile";
+#if SHOPT_SYSRC
+const char e_sysrc[] = "/etc/ksh.kshrc";
+#endif
+#if SHOPT_BASH
+#if SHOPT_SYSRC
+const char e_bash_sysrc[] = "/etc/bash.bashrc";
+#endif
+const char e_bash_rc[] = "$HOME/.bashrc";
+const char e_bash_login[] = "$HOME/.bash_login";
+const char e_bash_logout[] = "$HOME/.bash_logout";
+const char e_bash_profile[] = "$HOME/.bash_profile";
+#endif
+const char e_crondir[] = "/usr/spool/cron/atjobs";
+const char e_prohibited[] = "login setuid/setgid shells prohibited";
+#if SHOPT_SUID_EXEC
+ const char e_suidexec[] = "/etc/suid_exec";
+#endif /* SHOPT_SUID_EXEC */
+const char hist_fname[] = "/.sh_history";
+const char e_dot[] = ".";
+const char e_envmarker[] = "A__z";
+const char e_timeformat[] = "\nreal\t%2lR\nuser\t%2lU\nsys\t%2lS";
+const char e_dict[] = "libshell";
diff --git a/usr/src/lib/libshell/common/data/options.c b/usr/src/lib/libshell/common/data/options.c
new file mode 100644
index 0000000000..82ffd82d6c
--- /dev/null
+++ b/usr/src/lib/libshell/common/data/options.c
@@ -0,0 +1,140 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <defs.h>
+#include "FEATURE/options"
+#include "name.h"
+#include "shtable.h"
+
+#if SHOPT_BASH
+# define bashopt(a,b) a, b|SH_BASHOPT,
+# define bashextra(a,b) a, b|SH_BASHEXTRA,
+#else
+# define bashopt(a,b)
+# define bashextra(a,b)
+#endif
+
+/*
+ * This is the list of invocation and set options
+ * This list must be in in ascii sorted order
+ */
+
+const Shtable_t shtab_options[] =
+{
+ "allexport", SH_ALLEXPORT,
+#if SHOPT_BASH
+ "bash", (SH_BASH|SH_COMMANDLINE),
+#endif
+ "bgnice", SH_BGNICE,
+ "braceexpand", SH_BRACEEXPAND,
+ bashopt("cdable_vars", SH_CDABLE_VARS)
+ bashopt("cdspell", SH_CDSPELL)
+ bashopt("checkhash", SH_CHECKHASH)
+ bashopt("checkwinsize", SH_CHECKWINSIZE)
+ "noclobber", SH_NOCLOBBER,
+ bashopt("dotglob", SH_DOTGLOB)
+ "emacs", SH_EMACS,
+ "errexit", SH_ERREXIT,
+ "noexec", SH_NOEXEC,
+ bashopt("execfail", SH_EXECFAIL)
+ bashopt("expand_aliases", SH_EXPAND_ALIASES)
+ bashopt("extglob", SH_EXTGLOB)
+ "noglob", SH_NOGLOB,
+ "globstar", SH_GLOBSTARS,
+ "gmacs", SH_GMACS,
+ bashextra("hashall", SH_TRACKALL)
+ bashopt("histappend", SH_HISTAPPEND)
+#if SHOPT_HISTEXPAND
+ "histexpand", SH_HISTEXPAND,
+#else
+ bashextra("histexpand", SH_HISTEXPAND)
+#endif
+ bashextra("history", SH_HISTORY2)
+ bashopt("histreedit", SH_HISTREEDIT)
+ bashopt("histverify", SH_HISTVERIFY)
+ bashopt("hostcomplete", SH_HOSTCOMPLETE)
+ bashopt("huponexit", SH_HUPONEXIT)
+ "ignoreeof", SH_IGNOREEOF,
+ "interactive", SH_INTERACTIVE|SH_COMMANDLINE,
+ bashextra("interactive_comments", SH_INTERACTIVE_COMM)
+ "keyword", SH_KEYWORD,
+ bashopt("lithist", SH_LITHIST)
+ "nolog", SH_NOLOG,
+ "login_shell", SH_LOGIN_SHELL|SH_COMMANDLINE,
+ bashopt("mailwarn", SH_MAILWARN)
+ "markdirs", SH_MARKDIRS,
+ "monitor", SH_MONITOR,
+ "multiline", SH_MULTILINE,
+ bashopt("no_empty_cmd_completion", SH_NOEMPTYCMDCOMPL)
+ bashopt("nocaseglob", SH_NOCASEGLOB)
+ "notify", SH_NOTIFY,
+ bashopt("nullglob", SH_NULLGLOB)
+ bashextra("onecmd", SH_TFLAG)
+ "pipefail", SH_PIPEFAIL,
+ bashextra("physical", SH_PHYSICAL)
+ bashextra("posix", SH_POSIX)
+ "privileged", SH_PRIVILEGED,
+#if SHOPT_PFSH
+ "profile", SH_PFSH|SH_COMMANDLINE,
+#endif
+ bashopt("progcomp", SH_PROGCOMP)
+ bashopt("promptvars", SH_PROMPTVARS)
+ "rc", SH_RC|SH_COMMANDLINE,
+ "restricted", SH_RESTRICTED,
+ bashopt("restricted_shell", SH_RESTRICTED2|SH_COMMANDLINE)
+ bashopt("shift_verbose", SH_SHIFT_VERBOSE)
+ "showme", SH_SHOWME,
+ bashopt("sourcepath", SH_SOURCEPATH)
+ "trackall", SH_TRACKALL,
+ "nounset", SH_NOUNSET,
+ "verbose", SH_VERBOSE,
+ "vi", SH_VI,
+ "viraw", SH_VIRAW,
+ bashopt("xpg_echo", SH_XPG_ECHO)
+ "xtrace", SH_XTRACE,
+ "", 0
+};
+
+const Shtable_t shtab_attributes[] =
+{
+ {"-nnameref", NV_REF},
+ {"-xexport", NV_EXPORT},
+ {"-rreadonly", NV_RDONLY},
+ {"-ttagged", NV_TAGGED},
+ {"-llong", (NV_INTEGER|NV_DOUBLE|NV_LONG)},
+ {"-Eexponential",(NV_INTEGER|NV_DOUBLE|NV_EXPNOTE)},
+ {"-Ffloat", (NV_INTEGER|NV_DOUBLE)},
+ {"-llong", (NV_INTEGER|NV_LONG)},
+ {"-sshort", (NV_INTEGER|NV_SHORT)},
+ {"-uunsigned", (NV_INTEGER|NV_UNSIGN)},
+ {"-iinteger", NV_INTEGER},
+ {"-Hfilename", NV_HOST},
+ {"-bbinary", NV_BINARY},
+ {"-llowercase", NV_UTOL},
+ {"-Zzerofill", NV_ZFILL},
+ {"-Lleftjust", NV_LJUST},
+ {"-Rrightjust", NV_RJUST},
+ {"-uuppercase", NV_LTOU},
+ {"-Aassociative array", NV_ARRAY},
+ {"-aindexed array", NV_ARRAY},
+ {"++namespace", NV_TABLE},
+ {"", 0}
+};
diff --git a/usr/src/lib/libshell/common/data/signals.c b/usr/src/lib/libshell/common/data/signals.c
new file mode 100644
index 0000000000..cb29d32a1a
--- /dev/null
+++ b/usr/src/lib/libshell/common/data/signals.c
@@ -0,0 +1,227 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#include <ast.h>
+#include "shtable.h"
+#include "fault.h"
+
+#if defined(SIGCLD) && !defined(SIGCHLD)
+# define SIGCHLD SIGCLD
+#endif
+
+#define VAL(sig,mode) ((sig+1)|(mode)<<SH_SIGBITS)
+#define TRAP(n) (((n)|SH_TRAP)-1)
+
+#ifndef ERROR_dictionary
+# define ERROR_dictionary(s) (s)
+#endif
+#define S(s) ERROR_dictionary(s)
+
+/*
+ * This is a table that gives numbers and default settings to each signal
+ * The signal numbers go in the low bits and the attributes go in the high bits
+ */
+
+const struct shtable2 shtab_signals[] =
+{
+#ifdef SIGABRT
+ "ABRT", VAL(SIGABRT,SH_SIGDONE), S("Abort"),
+#endif /*SIGABRT */
+#ifdef SIGAIO
+ "AIO", VAL(SIGAIO,SH_SIGIGNORE), S("Asynchronous I/O"),
+#endif /*SIGAIO */
+#ifdef SIGALRM
+ "ALRM", VAL(SIGALRM,SH_SIGDONE), S("Alarm call"),
+#endif /* SIGALRM */
+#ifdef SIGAPOLLO
+ "APOLLO", VAL(SIGAPOLLO,0), "SIGAPOLLO"),
+#endif /* SIGAPOLLO */
+#ifdef SIGBUS
+ "BUS", VAL(SIGBUS,SH_SIGDONE), S("Bus error"),
+#endif /* SIGBUS */
+#ifdef SIGCHLD
+ "CHLD", VAL(SIGCHLD,SH_SIGFAULT), S("Death of Child"),
+# ifdef SIGCLD
+# if SIGCLD!=SIGCHLD
+ "CLD", VAL(SIGCLD,SH_SIGFAULT), S("Death of Child"),
+# endif
+# endif /* SIGCLD */
+#else
+# ifdef SIGCLD
+ "CLD", VAL(SIGCLD,SH_SIGFAULT), S("Death of Child"),
+# endif /* SIGCLD */
+#endif /* SIGCHLD */
+#ifdef SIGCONT
+ "CONT", VAL(SIGCONT,SH_SIGIGNORE), S("Stopped process continued"),
+#endif /* SIGCONT */
+ "DEBUG", VAL(TRAP(SH_DEBUGTRAP),0), "",
+#ifdef SIGDIL
+ "DIL", VAL(SIGDIL,0), S("DIL signal"),
+#endif /* SIGDIL */
+#ifdef SIGEMT
+ "EMT", VAL(SIGEMT,SH_SIGDONE), S("EMT trap"),
+#endif /* SIGEMT */
+ "ERR", VAL(TRAP(SH_ERRTRAP),0), "",
+#ifdef SIGERR
+ "ERR", VAL(SIGERR,0), "",
+#endif /* SIGERR */
+ "EXIT", VAL(0,0), "",
+ "FPE", VAL(SIGFPE,SH_SIGDONE), S("Floating exception"),
+#ifdef SIGFREEZE
+ "FREEZE", VAL(SIGFREEZE,SH_SIGIGNORE), S("Special signal used by CPR"),
+#endif /* SIGFREEZE */
+ "HUP", VAL(SIGHUP,SH_SIGDONE), S("Hangup"),
+ "ILL", VAL(SIGILL,SH_SIGDONE), S("Illegal instruction"),
+#ifdef JOBS
+ "INT", VAL(SIGINT,SH_SIGINTERACTIVE), S("Interrupt"),
+#else
+ "INT", VAL(SIGINT,SH_SIGINTERACTIVE), "",
+#endif /* JOBS */
+#ifdef SIGIO
+ "IO", VAL(SIGIO,SH_SIGIGNORE), S("IO signal"),
+#endif /* SIGIO */
+#ifdef SIGIOT
+ "IOT", VAL(SIGIOT,SH_SIGDONE), S("Abort"),
+#endif /* SIGIOT */
+ "KEYBD", VAL(TRAP(SH_KEYTRAP),0), "",
+#ifdef SIGKILL
+ "KILL", VAL(SIGKILL,0), S("Killed"),
+#endif /* SIGKILL */
+#ifdef SIGLAB
+ "LAB", VAL(SIGLAB,0), S("Security label changed"),
+#endif /* SIGLAB */
+#ifdef SIGLOST
+ "LOST", VAL(SIGLOST,SH_SIGDONE), S("Resources lost"),
+#endif /* SIGLOST */
+#ifdef SIGLWP
+ "LWP", VAL(SIGLWP,SH_SIGIGNORE), S("Special signal used by thread library"),
+#endif /* SIGLWP */
+#ifdef SIGPHONE
+ "PHONE", VAL(SIGPHONE,0), S("Phone interrupt"),
+#endif /* SIGPHONE */
+#ifdef SIGPIPE
+#ifdef JOBS
+ "PIPE", VAL(SIGPIPE,SH_SIGDONE), S("Broken Pipe"),
+#else
+ "PIPE", VAL(SIGPIPE,SH_SIGDONE), "",
+#endif /* JOBS */
+#endif /* SIGPIPE */
+#ifdef SIGPOLL
+ "POLL", VAL(SIGPOLL,SH_SIGDONE), S("Polling alarm"),
+#endif /* SIGPOLL */
+#ifdef SIGPROF
+ "PROF", VAL(SIGPROF,SH_SIGDONE), S("Profiling time alarm"),
+#endif /* SIGPROF */
+#ifdef SIGPWR
+# if SIGPWR>0
+ "PWR", VAL(SIGPWR,SH_SIGIGNORE), S("Power fail"),
+# endif
+#endif /* SIGPWR */
+#ifdef SIGQUIT
+ "QUIT", VAL(SIGQUIT,SH_SIGDONE|SH_SIGINTERACTIVE), S("Quit"),
+#ifdef __SIGRTMIN
+#undef SIGRTMIN
+#define SIGRTMIN __SIGRTMIN
+#else
+#ifdef _SIGRTMIN
+#undef SIGRTMIN
+#define SIGRTMIN _SIGRTMIN
+#endif
+#endif
+#ifdef SIGRTMIN
+ "RTMIN", VAL(SIGRTMIN,0), S("Lowest priority realtime signal"),
+#endif /* SIGRTMIN */
+#ifdef __SIGRTMAX
+#undef SIGRTMAX
+#define SIGRTMAX __SIGRTMAX
+#else
+#ifdef _SIGRTMAX
+#undef SIGRTMAX
+#define SIGRTMAX _SIGRTMAX
+#endif
+#endif
+#ifdef SIGRTMAX
+ "RTMAX", VAL(SIGRTMAX,0), S("Highest priority realtime signal"),
+#endif /* SIGRTMAX */
+#endif /* SIGQUIT */
+ "SEGV", VAL(SIGSEGV,0), S("Memory fault"),
+#ifdef SIGSTOP
+ "STOP", VAL(SIGSTOP,0), S("Stopped (SIGSTOP)"),
+#endif /* SIGSTOP */
+#ifdef SIGSYS
+ "SYS", VAL(SIGSYS,SH_SIGDONE), S("Bad system call"),
+#endif /* SIGSYS */
+ "TERM", VAL(SIGTERM,SH_SIGDONE|SH_SIGINTERACTIVE), S("Terminated"),
+#ifdef SIGTINT
+# ifdef JOBS
+ "TINT", VAL(SIGTINT,0), S("Interrupt"),
+# else
+ "TINT", VAL(SIGTINT,0), "".
+# endif /* JOBS */
+#endif /* SIGTINT */
+#ifdef SIGTRAP
+ "TRAP", VAL(SIGTRAP,SH_SIGDONE), S("Trace/BPT trap"),
+#endif /* SIGTRAP */
+#ifdef SIGTSTP
+ "TSTP", VAL(SIGTSTP,0), S("Stopped"),
+#endif /* SIGTSTP */
+#ifdef SIGTTIN
+ "TTIN", VAL(SIGTTIN,0), S("Stopped (SIGTTIN)"),
+#endif /* SIGTTIN */
+#ifdef SIGTTOU
+ "TTOU", VAL(SIGTTOU,0), S("Stopped(SIGTTOU)"),
+#endif /* SIGTTOU */
+#ifdef SIGURG
+ "URG", VAL(SIGURG,SH_SIGIGNORE), S("Socket interrupt"),
+#endif /* SIGURG */
+#ifdef SIGUSR1
+ "USR1", VAL(SIGUSR1,SH_SIGDONE), S("User signal 1"),
+#endif /* SIGUSR1 */
+#ifdef SIGUSR2
+ "USR2", VAL(SIGUSR2,SH_SIGDONE), S("User signal 2"),
+#endif /* SIGUSR2 */
+#ifdef SIGVTALRM
+ "VTALRM", VAL(SIGVTALRM,SH_SIGDONE), S("Virtual time alarm"),
+#endif /* SIGVTALRM */
+#ifdef SIGWINCH
+ "WINCH", VAL(SIGWINCH,SH_SIGIGNORE), S("Window size change"),
+#endif /* SIGWINCH */
+#ifdef SIGMIGRATE
+ "MIGRATE", VAL(SIGMIGRATE,0), S("Migrate process"),
+#endif /* SIGMIGRATE */
+#ifdef SIGDANGER
+ "DANGER", VAL(SIGDANGER,0), S("System crash soon"),
+#endif /* SIGDANGER */
+#ifdef SIGSOUND
+ "SOUND", VAL(SIGSOUND,0), S("Sound completed"),
+#endif /* SIGSOUND */
+#ifdef SIGTHAW
+ "THAW", VAL(SIGTHAW,SH_SIGIGNORE), S("Special signal used by CPR"),
+#endif /* SIGTHAW */
+#ifdef SIGWAITING
+ "WAITING", VAL(SIGWAITING,SH_SIGIGNORE), S("All threads blocked"),
+#endif /* SIGWAITING */
+#ifdef SIGXCPU
+ "XCPU", VAL(SIGXCPU,SH_SIGDONE|SH_SIGINTERACTIVE), S("Exceeded CPU time limit"),
+#endif /* SIGXCPU */
+#ifdef SIGXFSZ
+ "XFSZ", VAL(SIGXFSZ,SH_SIGDONE|SH_SIGINTERACTIVE), S("Exceeded file size limit"),
+#endif /* SIGXFSZ */
+ "", 0, 0
+};
diff --git a/usr/src/lib/libshell/common/data/solaris_cmdlist.h b/usr/src/lib/libshell/common/data/solaris_cmdlist.h
new file mode 100644
index 0000000000..d12e2c0ddb
--- /dev/null
+++ b/usr/src/lib/libshell/common/data/solaris_cmdlist.h
@@ -0,0 +1,128 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SOLARIS_CMDLIST_H
+#define _SOLARIS_CMDLIST_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * List builtins for Solaris.
+ * The list here is partially autogenerated and partially hand-picked
+ * based on compatibility with the native Solaris versions of these
+ * tools
+ */
+
+/* POSIX compatible commands */
+#ifdef _NOT_YET
+#define XPG6CMDLIST(f) { "/usr/xpg6/bin/" #f, NV_BLTIN|NV_NOFREE, bltin(f) },
+#define XPG4CMDLIST(f) { "/usr/xpg4/bin/" #f, NV_BLTIN|NV_NOFREE, bltin(f) },
+#else
+#define XPG6CMDLIST(f)
+#define XPG4CMDLIST(f)
+#endif /* NOT_YET */
+/*
+ * Commands which are 100% compatible with native Solaris versions (/bin is
+ * a softlink to ./usr/bin so both need to be listed here)
+ */
+#define BINCMDLIST(f) { "/bin/" #f, NV_BLTIN|NV_NOFREE, bltin(f) },
+/* Make all ksh93 builtins accessible when /usr/ast/bin was added to ${PATH} */
+#define ASTCMDLIST(f) { "/usr/ast/bin/" #f, NV_BLTIN|NV_NOFREE, bltin(f) },
+
+/* undo ast_map.h #defines to avoid collision */
+#undef basename
+#undef dirname
+
+/* Generated data, do not edit. */
+XPG4CMDLIST(basename)
+ASTCMDLIST(basename)
+BINCMDLIST(cat)
+ASTCMDLIST(cat)
+XPG4CMDLIST(chgrp)
+ASTCMDLIST(chgrp)
+ASTCMDLIST(chmod)
+XPG4CMDLIST(chown)
+BINCMDLIST(chown)
+ASTCMDLIST(chown)
+ASTCMDLIST(cmp)
+ASTCMDLIST(comm)
+XPG4CMDLIST(cp)
+ASTCMDLIST(cp)
+ASTCMDLIST(cut)
+XPG4CMDLIST(date)
+ASTCMDLIST(date)
+ASTCMDLIST(dirname)
+XPG4CMDLIST(expr)
+ASTCMDLIST(expr)
+ASTCMDLIST(fds)
+ASTCMDLIST(fmt)
+ASTCMDLIST(fold)
+BINCMDLIST(head)
+ASTCMDLIST(head)
+XPG4CMDLIST(id)
+ASTCMDLIST(id)
+ASTCMDLIST(join)
+XPG4CMDLIST(ln)
+ASTCMDLIST(ln)
+ASTCMDLIST(logname)
+BINCMDLIST(mkdir)
+ASTCMDLIST(mkdir)
+ASTCMDLIST(mkfifo)
+XPG4CMDLIST(mv)
+ASTCMDLIST(mv)
+ASTCMDLIST(paste)
+ASTCMDLIST(pathchk)
+ASTCMDLIST(rev)
+XPG4CMDLIST(rm)
+ASTCMDLIST(rm)
+BINCMDLIST(rmdir)
+ASTCMDLIST(rmdir)
+XPG4CMDLIST(stty)
+ASTCMDLIST(stty)
+XPG4CMDLIST(tail)
+ASTCMDLIST(tail)
+BINCMDLIST(tee)
+ASTCMDLIST(tee)
+ASTCMDLIST(tty)
+ASTCMDLIST(uname)
+BINCMDLIST(uniq)
+ASTCMDLIST(uniq)
+BINCMDLIST(wc)
+ASTCMDLIST(wc)
+/* End-of-generated-data. */
+
+/* Mandatory for ksh93 test suite and AST scripts */
+BINCMDLIST(getconf)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SOLARIS_CMDLIST_H */
diff --git a/usr/src/lib/libshell/common/data/strdata.c b/usr/src/lib/libshell/common/data/strdata.c
new file mode 100644
index 0000000000..57689b68a3
--- /dev/null
+++ b/usr/src/lib/libshell/common/data/strdata.c
@@ -0,0 +1,104 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * data for string evaluator library
+ */
+
+#include <ast_standards.h>
+#include "FEATURE/options"
+#include "streval.h"
+
+const unsigned char strval_precedence[35] =
+ /* opcode precedence,assignment */
+{
+ /* DEFAULT */ MAXPREC|NOASSIGN,
+ /* DONE */ 0|NOASSIGN|RASSOC,
+ /* NEQ */ 10|NOASSIGN,
+ /* NOT */ MAXPREC|NOASSIGN,
+ /* MOD */ 14,
+ /* ANDAND */ 6|NOASSIGN|SEQPOINT,
+ /* AND */ 9|NOFLOAT,
+ /* LPAREN */ MAXPREC|NOASSIGN|SEQPOINT,
+ /* RPAREN */ 1|NOASSIGN|RASSOC|SEQPOINT,
+ /* POW */ 14|NOASSIGN|RASSOC,
+ /* TIMES */ 14,
+ /* PLUSPLUS */ 15|NOASSIGN|NOFLOAT|SEQPOINT,
+ /* PLUS */ 13,
+ /* COMMA */ 1|NOASSIGN|SEQPOINT,
+ /* MINUSMINUS */ 15|NOASSIGN|NOFLOAT|SEQPOINT,
+ /* MINUS */ 13,
+ /* DIV */ 14,
+ /* LSHIFT */ 12|NOFLOAT,
+ /* LE */ 11|NOASSIGN,
+ /* LT */ 11|NOASSIGN,
+ /* EQ */ 10|NOASSIGN,
+ /* ASSIGNMENT */ 2|RASSOC,
+ /* COLON */ 0|NOASSIGN,
+ /* RSHIFT */ 12|NOFLOAT,
+ /* GE */ 11|NOASSIGN,
+ /* GT */ 11|NOASSIGN,
+ /* QCOLON */ 3|NOASSIGN|SEQPOINT,
+ /* QUEST */ 3|NOASSIGN|SEQPOINT|RASSOC,
+ /* XOR */ 8|NOFLOAT,
+ /* OROR */ 5|NOASSIGN|SEQPOINT,
+ /* OR */ 7|NOFLOAT,
+ /* DEFAULT */ MAXPREC|NOASSIGN,
+ /* DEFAULT */ MAXPREC|NOASSIGN,
+ /* DEFAULT */ MAXPREC|NOASSIGN,
+ /* DEFAULT */ MAXPREC|NOASSIGN
+};
+
+/*
+ * This is for arithmetic expressions
+ */
+const char strval_states[64] =
+{
+ A_EOF, A_REG, A_REG, A_REG, A_REG, A_REG, A_REG, A_REG,
+ A_REG, 0, 0, A_REG, A_REG, A_REG, A_REG, A_REG,
+ A_REG, A_REG, A_REG, A_REG, A_REG, A_REG, A_REG, A_REG,
+ A_REG, A_REG, A_REG, A_REG, A_REG, A_REG, A_REG, A_REG,
+
+ 0, A_NOT, 0, A_REG, A_REG, A_MOD, A_AND, A_LIT,
+ A_LPAR, A_RPAR, A_TIMES,A_PLUS, A_COMMA,A_MINUS,A_DOT, A_DIV,
+ A_DIG, A_DIG, A_DIG, A_DIG, A_DIG, A_DIG, A_DIG, A_DIG,
+ A_DIG, A_DIG, A_COLON,A_REG, A_LT, A_ASSIGN,A_GT, A_QUEST
+
+};
+
+
+const char e_argcount[] = "%s: function has wrong number of arguments";
+const char e_badnum[] = "%s: bad number";
+const char e_moretokens[] = "%s: more tokens expected";
+const char e_paren[] = "%s: unbalanced parenthesis";
+const char e_badcolon[] = "%s: invalid use of :";
+const char e_divzero[] = "%s: divide by zero";
+const char e_synbad[] = "%s: arithmetic syntax error";
+const char e_notlvalue[] = "%s: assignment requires lvalue";
+const char e_recursive[] = "%s: recursion too deep";
+const char e_questcolon[] = "%s: ':' expected for '?' operator";
+const char e_function[] = "%s: unknown function";
+const char e_incompatible[] = "%s: invalid floating point operation";
+const char e_overflow[] = "%s: overflow exception";
+const char e_domain[] = "%s: domain exception";
+const char e_singularity[] = "%s: singularity exception";
+const char e_charconst[] = "%s: invalid character constant";
+
+#include "FEATURE/math"
diff --git a/usr/src/lib/libshell/common/data/testops.c b/usr/src/lib/libshell/common/data/testops.c
new file mode 100644
index 0000000000..449ca99efb
--- /dev/null
+++ b/usr/src/lib/libshell/common/data/testops.c
@@ -0,0 +1,168 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * tables for the test builin [[...]] and [...]
+ */
+
+#include <ast.h>
+
+#include "shtable.h"
+#include "test.h"
+
+/*
+ * This is the list of binary test and [[...]] operators
+ */
+
+const Shtable_t shtab_testops[] =
+{
+ "!=", TEST_SNE,
+ "-a", TEST_AND,
+ "-ef", TEST_EF,
+ "-eq", TEST_EQ,
+ "-ge", TEST_GE,
+ "-gt", TEST_GT,
+ "-le", TEST_LE,
+ "-lt", TEST_LT,
+ "-ne", TEST_NE,
+ "-nt", TEST_NT,
+ "-o", TEST_OR,
+ "-ot", TEST_OT,
+ "=", TEST_SEQ,
+ "==", TEST_SEQ,
+ "=~", TEST_REP,
+ "<", TEST_SLT,
+ ">", TEST_SGT,
+ "]]", TEST_END,
+ "", 0
+};
+
+const char sh_opttest[] =
+"[-1c?\n@(#)$Id: test (AT&T Research) 2003-03-18 $\n]"
+USAGE_LICENSE
+"[+NAME?test - evaluate expression]"
+"[+DESCRIPTION?\btest\b evaluates expressions and indicates its "
+ "results based on the exit status. Option parsing is not "
+ "performed so that all arguments, including \b--\b are processed "
+ " as operands. The evaluation of the "
+ "expression depends on the number of operands as follows:]{"
+ "[+0?Evaluates to false.]"
+ "[+1?True if argument is not an empty string.]"
+ "[+2?If first operand is \b!\b, the result is True if the second "
+ "operand an empty string. Otherwise, it is evaluated "
+ "as one of the unary expressions defined below. If the "
+ "unary operator is invalid and the second argument is \b--\b,"
+ "then the first argument is processed as an option argument.]"
+ "[+3?If first operand is \b!\b, the result is True if the second "
+ "and third operand evaluated as a unary expression is False. "
+ "Otherwise, the three operands are evaluaged as one of the "
+ "binary expressions listed below.]"
+ "[+4?If first operand is \b!\b, the result is True if the next "
+ "three operands are a valid binary expression that is False.]"
+"}"
+"[If any \afile\a is of the form \b/dev/fd/\b\an\a, then file descriptor "
+ "\an\a is checked.]"
+"[+?Unary expressions can be one of the following:]{"
+ "[+-a \afile\a?True if \afile\a exists, obsolete.]"
+ "[+-b \afile\a?True if \afile\a exists and is a block special file.]"
+ "[+-c \afile\a?True if \afile\a exists and is a character special "
+ "file.]"
+ "[+-d \afile\a?True if \afile\a exists and is a directory.]"
+ "[+-e \afile\a?True if \afile\a exists.]"
+ "[+-f \afile\a?True if \afile\a exists and is a regular file.]"
+ "[+-g \afile\a?True if \afile\a exists and has its set-group-id bit "
+ "set.]"
+ "[+-h \afile\a?True if \afile\a exists and is a symbolic link.]"
+ "[+-k \afile\a?True if \afile\a exists and has its sticky bit on.]"
+#if SHOPT_TEST_L
+ "[+-l \afile\a?True if \afile\a exists and is a symbolic link.]"
+#endif
+ "[+-n \astring\a?True if length of \astring\a is non-zero.]"
+ "[+-o \aoption\a?True if the shell option \aoption\a is enabled.]"
+ "[+-p \afile\a?True if \afile\a exists and is a pipe or fifo.]"
+ "[+-r \afile\a?True if \afile\a exists and is readable.]"
+ "[+-s \afile\a?True if \afile\a exists and has size > 0.]"
+ "[+-t \afildes\a?True if file descriptor number \afildes\a is "
+ "open and is associated with a terminal device.]"
+ "[+-u \afile\a?True if \afile\a exists and has its set-user-id bit "
+ "set.]"
+ "[+-w \afile\a?True if \afile\a exists and is writable.]"
+ "[+-x \afile\a?True if \afile\a exists and is executable. For a "
+ "directory it means that it can be searched.]"
+ "[+-z \astring\a?True if \astring\a is a zero length string.]"
+ "[+-G \afile\a?True if \afile\a exists and group is the effective "
+ "group id of the current process.]"
+ "[+-L \afile\a?True if \afile\a exists and is a symbolic link.]"
+ "[+-N \afile\a?True if \afile\a exists and has been modified since "
+ "it was last read.]"
+ "[+-O \afile\a?True if \afile\a exists and owner is the effective "
+ "user id of the current process.]"
+ "[+-S \afile\a?True if \afile\a exists and is a socket.]"
+"}"
+"[+?Binary expressions can be one of the following:]{"
+ "[+\astring1\a = \astring2\a?True if \astring1\a is equal to "
+ "\astring2\a.]"
+ "[+\astring1\a == \astring2\a?True if \astring1\a is equal to "
+ "\astring2\a.]"
+ "[+\astring1\a != \astring2\a?True if \astring1\a is not equal to "
+ "\astring2\a.]"
+ "[+\anum1\a -eq \anum2\a?True if numerical value of \anum1\a is "
+ "equal to \anum2\a.]"
+ "[+\anum1\a -ne \anum2\a?True if numerical value of \anum1\a is not "
+ "equal to \anum2\a.]"
+ "[+\anum1\a -lt \anum2\a?True if numerical value of \anum1\a is less "
+ "than \anum2\a.]"
+ "[+\anum1\a -le \anum2\a?True if numerical value of \anum1\a is less "
+ "than or equal to \anum2\a.]"
+ "[+\anum1\a -gt \anum2\a?True if numerical value of \anum1\a is "
+ "greater than \anum2\a.]"
+ "[+\anum1\a -ge \anum2\a?True if numerical value of \anum1\a is "
+ "greater than or equal to \anum2\a.]"
+ "[+\afile1\a -nt \afile2\a?True if \afile1\a is newer than \afile2\a "
+ "or \afile2\a does not exist.]"
+ "[+\afile1\a -ot \afile2\a?True if \afile1\a is older than \afile2\a "
+ "or \afile2\a does not exist.]"
+ "[+\afile1\a -ef \afile2\a?True if \afile1\a is another name for "
+ "\afile2\a. This will be true if \afile1\a is a hard link "
+ "or a symbolic link to \afile2\a.]"
+"}"
+"\n"
+"\n[expression]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Indicates that the specified expression is True.]"
+ "[+1?Indicates that the specified expression is False.]"
+ "[+>1?An error occurred.]"
+"}"
+
+"[+SEE ALSO?\blet\b(1), \bexpr\b(1)]"
+;
+
+const char test_opchars[] = "HLNSVOGCaeohrwxdcbfugk"
+#if SHOPT_TEST_L
+ "l"
+#endif
+ "psnzt";
+const char e_argument[] = "argument expected";
+const char e_missing[] = "%s missing";
+const char e_badop[] = "%s: unknown operator";
+const char e_tstbegin[] = "[[ ! ";
+const char e_tstend[] = " ]]\n";
diff --git a/usr/src/lib/libshell/common/data/variables.c b/usr/src/lib/libshell/common/data/variables.c
new file mode 100644
index 0000000000..9042e235b0
--- /dev/null
+++ b/usr/src/lib/libshell/common/data/variables.c
@@ -0,0 +1,105 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+#include "FEATURE/options"
+#include "FEATURE/dynamic"
+#include <shell.h>
+#include "shtable.h"
+#include "name.h"
+#include "defs.h"
+
+/*
+ * This is the list of built-in shell variables and default values
+ * and default attributes.
+ */
+
+const struct shtable2 shtab_variables[] =
+{
+ "PATH", 0, (char*)0,
+ "PS1", 0, (char*)0,
+ "PS2", NV_NOFREE, "> ",
+ "IFS", NV_NOFREE, " \t\n",
+ "PWD", 0, (char*)0,
+ "HOME", 0, (char*)0,
+ "MAIL", 0, (char*)0,
+ "REPLY", 0, (char*)0,
+ "SHELL", NV_NOFREE, "/bin/" SH_STD,
+ "EDITOR", 0, (char*)0,
+ "MAILCHECK", NV_NOFREE|NV_INTEGER, (char*)0,
+ "RANDOM", NV_NOFREE|NV_INTEGER, (char*)0,
+ "ENV", NV_NOFREE, "$HOME/.kshrc",
+ "HISTFILE", 0, (char*)0,
+ "HISTSIZE", 0, (char*)0,
+ "HISTEDIT", NV_NOFREE, (char*)0,
+ "HISTCMD", NV_NOFREE|NV_INTEGER, (char*)0,
+ "FCEDIT", NV_NOFREE, "/bin/ed",
+ "CDPATH", 0, (char*)0,
+ "MAILPATH", 0, (char*)0,
+ "PS3", NV_NOFREE, "#? ",
+ "OLDPWD", 0, (char*)0,
+ "VISUAL", 0, (char*)0,
+ "COLUMNS", 0, (char*)0,
+ "LINES", 0, (char*)0,
+ "PPID", NV_NOFREE|NV_INTEGER, (char*)0,
+ "_", NV_EXPORT, (char*)0,
+ "TMOUT", NV_NOFREE|NV_INTEGER, (char*)0,
+ "SECONDS", NV_NOFREE|NV_INTEGER|NV_DOUBLE, (char*)0,
+ "LINENO", NV_NOFREE|NV_INTEGER, (char*)0,
+ "OPTARG", 0, (char*)0,
+ "OPTIND", NV_NOFREE|NV_INTEGER, (char*)0,
+ "PS4", 0, (char*)0,
+ "FPATH", 0, (char*)0,
+ "LANG", 0, (char*)0,
+ "LC_ALL", 0, (char*)0,
+ "LC_COLLATE", 0, (char*)0,
+ "LC_CTYPE", 0, (char*)0,
+ "LC_MESSAGES", 0, (char*)0,
+ "LC_NUMERIC", 0, (char*)0,
+ "FIGNORE", 0, (char*)0,
+ ".sh", NV_TABLE|NV_RDONLY|NV_NOFREE|NV_NOPRINT,(char*)0,
+ ".sh.edchar", 0, (char*)0,
+ ".sh.edcol", 0, (char*)0,
+ ".sh.edtext", 0, (char*)0,
+ ".sh.edmode", 0, (char*)0,
+ ".sh.name", 0, (char*)0,
+ ".sh.subscript",0, (char*)0,
+ ".sh.value", 0, (char*)0,
+ ".sh.version", NV_NOFREE, (char*)(&e_version[10]),
+ ".sh.dollar", 0, (char*)0,
+ ".sh.match", 0, (char*)0,
+ ".sh.command", 0, (char*)0,
+ ".sh.file", 0, (char*)0,
+ ".sh.fun", 0, (char*)0,
+ ".sh.subshell", NV_INTEGER|NV_SHORT|NV_NOFREE, (char*)0,
+ ".sh.level", 0, (char*)0,
+#if SHOPT_FS_3D
+ "VPATH", 0, (char*)0,
+#endif /* SHOPT_FS_3D */
+#if SHOPT_MULTIBYTE
+ "CSWIDTH", 0, (char*)0,
+#endif /* SHOPT_MULTIBYTE */
+#ifdef apollo
+ "SYSTYPE", 0, (char*)0,
+#endif /* apollo */
+ "", 0, (char*)0
+};
+
diff --git a/usr/src/lib/libshell/common/edit/completion.c b/usr/src/lib/libshell/common/edit/completion.c
new file mode 100644
index 0000000000..050019fbe5
--- /dev/null
+++ b/usr/src/lib/libshell/common/edit/completion.c
@@ -0,0 +1,522 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * completion.c - command and file completion for shell editors
+ *
+ */
+
+#include "defs.h"
+#include <ctype.h>
+#include <ast_wchar.h>
+#include "lexstates.h"
+#include "path.h"
+#include "io.h"
+#include "edit.h"
+#include "history.h"
+
+static int charcmp(int a, int b, int nocase)
+{
+ if(nocase)
+ {
+ if(isupper(a))
+ a = tolower(a);
+ if(isupper(b))
+ b = tolower(b);
+ }
+ return(a==b);
+}
+
+/*
+ * overwrites <str> to common prefix of <str> and <newstr>
+ * if <str> is equal to <newstr> returns <str>+strlen(<str>)+1
+ * otherwise returns <str>+strlen(<str>)
+ */
+static char *overlaid(register char *str,register const char *newstr,int nocase)
+{
+ register int c,d;
+ while((c= *(unsigned char *)str) && ((d= *(unsigned char*)newstr++),charcmp(c,d,nocase)))
+ str++;
+ if(*str)
+ *str = 0;
+ else if(*newstr==0)
+ str++;
+ return(str);
+}
+
+
+/*
+ * returns pointer to beginning of expansion and sets type of expansion
+ */
+static char *find_begin(char outbuff[], char *last, int endchar, int *type)
+{
+ register char *cp=outbuff, *bp, *xp;
+ register int c,inquote = 0;
+ bp = outbuff;
+ *type = 0;
+ while(cp < last)
+ {
+ xp = cp;
+ switch(c= mbchar(cp))
+ {
+ case '\'': case '"':
+ if(!inquote)
+ {
+ inquote = c;
+ bp = xp;
+ break;
+ }
+ if(inquote==c)
+ inquote = 0;
+ break;
+ case '\\':
+ if(inquote != '\'')
+ mbchar(cp);
+ break;
+ case '$':
+ if(inquote == '\'')
+ break;
+ c = *(unsigned char*)cp;
+ if(isaletter(c) || c=='{')
+ {
+ int dot = '.';
+ if(c=='{')
+ {
+ xp = cp;
+ mbchar(cp);
+ c = *(unsigned char*)cp;
+ if(c!='.' && !isaletter(c))
+ break;
+ }
+ else
+ dot = 'a';
+ while(cp < last)
+ {
+ if((c= mbchar(cp)) , c!=dot && !isaname(c))
+ break;
+ }
+ if(cp>=last)
+ {
+ *type='$';
+ return(++xp);
+ }
+ }
+ else if(c=='(')
+ {
+ xp = find_begin(cp,last,')',type);
+ if(*(cp=xp)!=')')
+ bp = xp;
+ else
+ cp++;
+ }
+ break;
+ case '=':
+ if(!inquote)
+ bp = cp;
+ break;
+ case '~':
+ if(*cp=='(')
+ break;
+ /* fall through */
+ default:
+ if(c && c==endchar)
+ return(xp);
+ if(!inquote && ismeta(c))
+ bp = cp;
+ break;
+ }
+ }
+ if(inquote && *bp==inquote)
+ *type = *bp++;
+ return(bp);
+}
+
+/*
+ * file name generation for edit modes
+ * non-zero exit for error, <0 ring bell
+ * don't search back past beginning of the buffer
+ * mode is '*' for inline expansion,
+ * mode is '\' for filename completion
+ * mode is '=' cause files to be listed in select format
+ */
+
+int ed_expand(Edit_t *ep, char outbuff[],int *cur,int *eol,int mode, int count)
+{
+ struct comnod *comptr;
+ struct argnod *ap;
+ register char *out;
+ char *av[2], *begin , *dir=0;
+ int addstar=0, rval=0, var=0, strip=1;
+ int nomarkdirs = !sh_isoption(SH_MARKDIRS);
+ sh_onstate(SH_FCOMPLETE);
+ if(ep->e_nlist)
+ {
+ if(mode=='=' && count>0)
+ {
+ if(count> ep->e_nlist)
+ return(-1);
+ mode = '*';
+ av[0] = ep->e_clist[count-1];
+ av[1] = 0;
+ }
+ else
+ {
+ stakset(ep->e_stkptr,ep->e_stkoff);
+ ep->e_nlist = 0;
+ }
+ }
+ comptr = (struct comnod*)stakalloc(sizeof(struct comnod));
+ ap = (struct argnod*)stakseek(ARGVAL);
+#if SHOPT_MULTIBYTE
+ {
+ register int c = *cur;
+ register genchar *cp;
+ /* adjust cur */
+ cp = (genchar *)outbuff + *cur;
+ c = *cp;
+ *cp = 0;
+ *cur = ed_external((genchar*)outbuff,(char*)stakptr(0));
+ *cp = c;
+ *eol = ed_external((genchar*)outbuff,outbuff);
+ }
+#endif /* SHOPT_MULTIBYTE */
+ out = outbuff + *cur + (sh_isoption(SH_VI)!=0);
+ comptr->comtyp = COMSCAN;
+ comptr->comarg = ap;
+ ap->argflag = (ARG_MAC|ARG_EXP);
+ ap->argnxt.ap = 0;
+ ap->argchn.cp = 0;
+ {
+ register int c;
+ char *last = out;
+ c = *(unsigned char*)out;
+ begin = out = find_begin(outbuff,last,0,&var);
+ /* addstar set to zero if * should not be added */
+ if(var=='$')
+ {
+ stakputs("${!");
+ stakwrite(out,last-out);
+ stakputs("@}");
+ out = last;
+ }
+ else
+ {
+ addstar = '*';
+ while(out < last)
+ {
+ c = *(unsigned char*)out;
+ if(isexp(c))
+ addstar = 0;
+ if (c == '/')
+ {
+ if(addstar == 0)
+ strip = 0;
+ dir = out+1;
+ }
+ stakputc(c);
+ out++;
+ }
+ }
+ if(var!='$' && mode=='\\' && out[-1]!='*')
+ addstar = '*';
+ if(*begin=='~' && !strchr(begin,'/'))
+ addstar = 0;
+ stakputc(addstar);
+ ap = (struct argnod*)stakfreeze(1);
+ }
+ if(mode!='*')
+ sh_onoption(SH_MARKDIRS);
+ {
+ register char **com;
+ char *cp=begin, *left=0, *saveout=".";
+ int nocase=0,narg,cmd_completion=0;
+ register int size='x';
+ while(cp>outbuff && ((size=cp[-1])==' ' || size=='\t'))
+ cp--;
+ if(!var && !strchr(ap->argval,'/') && (((cp==outbuff&&sh.nextprompt==1) || (strchr(";&|(",size)) && (cp==outbuff+1||size=='('||cp[-2]!='>') && *begin!='~' )))
+ {
+ cmd_completion=1;
+ sh_onstate(SH_COMPLETE);
+ }
+ if(ep->e_nlist)
+ {
+ narg = 1;
+ com = av;
+ if(dir)
+ begin += (dir-begin);
+ }
+ else
+ {
+ com = sh_argbuild(&narg,comptr,0);
+ /* special handling for leading quotes */
+ if(begin>outbuff && (begin[-1]=='"' || begin[-1]=='\''))
+ begin--;
+ }
+ sh_offstate(SH_COMPLETE);
+ /* allow a search to be aborted */
+ if(sh.trapnote&SH_SIGSET)
+ {
+ rval = -1;
+ goto done;
+ }
+ /* match? */
+ if (*com==0 || (narg <= 1 && (strcmp(ap->argval,*com)==0) || (addstar && com[0][strlen(*com)-1]=='*')))
+ {
+ rval = -1;
+ goto done;
+ }
+ if(mode=='=')
+ {
+ if (strip && !cmd_completion)
+ {
+ register char **ptrcom;
+ for(ptrcom=com;*ptrcom;ptrcom++)
+ /* trim directory prefix */
+ *ptrcom = path_basename(*ptrcom);
+ }
+ sfputc(sfstderr,'\n');
+ sh_menu(sfstderr,narg,com);
+ sfsync(sfstderr);
+ ep->e_nlist = narg;
+ ep->e_clist = com;
+ goto done;
+ }
+ /* see if there is enough room */
+ size = *eol - (out-begin);
+ if(mode=='\\')
+ {
+ int c;
+ if(dir)
+ {
+ c = *dir;
+ *dir = 0;
+ saveout = begin;
+ }
+ if(saveout=astconf("PATH_ATTRIBUTES",saveout,(char*)0))
+ nocase = (strchr(saveout,'c')!=0);
+ if(dir)
+ *dir = c;
+ /* just expand until name is unique */
+ size += strlen(*com);
+ }
+ else
+ {
+ size += narg;
+ {
+ char **savcom = com;
+ while (*com)
+ size += strlen(cp=sh_fmtq(*com++));
+ com = savcom;
+ }
+ }
+ /* see if room for expansion */
+ if(outbuff+size >= &outbuff[MAXLINE])
+ {
+ com[0] = ap->argval;
+ com[1] = 0;
+ }
+ /* save remainder of the buffer */
+ if(*out)
+ left=stakcopy(out);
+ if(cmd_completion && mode=='\\')
+ out = strcopy(begin,path_basename(cp= *com++));
+ else if(mode=='*')
+ {
+ if(ep->e_nlist && dir && var)
+ {
+ if(*cp==var)
+ cp++;
+ else
+ *begin++ = var;
+ out = strcopy(begin,cp);
+ var = 0;
+ }
+ else
+ out = strcopy(begin,sh_fmtq(*com));
+ com++;
+ }
+ else
+ out = strcopy(begin,*com++);
+ if(mode=='\\')
+ {
+ saveout= ++out;
+ while (*com && *begin)
+ {
+ if(cmd_completion)
+ out = overlaid(begin,path_basename(*com++),nocase);
+ else
+ out = overlaid(begin,*com++,nocase);
+ }
+ mode = (out==saveout);
+ if(out[-1]==0)
+ out--;
+ if(mode && out[-1]!='/')
+ {
+ if(cmd_completion)
+ {
+ Namval_t *np;
+ /* add as tracked alias */
+#ifdef PATH_BFPATH
+ Pathcomp_t *pp;
+ if(*cp=='/' && (pp=path_dirfind(sh.pathlist,cp,'/')) && (np=nv_search(begin,sh.track_tree,NV_ADD)))
+ path_alias(np,pp);
+#else
+ if(*cp=='/' && (np=nv_search(begin,sh.track_tree,NV_ADD)))
+ path_alias(np,cp);
+#endif
+ out = strcopy(begin,cp);
+ }
+ /* add quotes if necessary */
+ if((cp=sh_fmtq(begin))!=begin)
+ out = strcopy(begin,cp);
+ if(var=='$' && begin[-1]=='{')
+ *out = '}';
+ else
+ *out = ' ';
+ *++out = 0;
+ }
+ else if(out[-1]=='/' && (cp=sh_fmtq(begin))!=begin)
+ {
+ out = strcopy(begin,cp);
+ if(out[-1] =='"' || out[-1]=='\'')
+ *--out = 0;;
+ }
+ if(*begin==0)
+ ed_ringbell();
+ }
+ else
+ {
+ while (*com)
+ {
+ *out++ = ' ';
+ out = strcopy(out,sh_fmtq(*com++));
+ }
+ }
+ if(ep->e_nlist)
+ {
+ cp = com[-1];
+ if(cp[strlen(cp)-1]!='/')
+ {
+ if(var=='$' && begin[-1]=='{')
+ *out = '}';
+ else
+ *out = ' ';
+ out++;
+ }
+ else if(out[-1] =='"' || out[-1]=='\'')
+ out--;
+ *out = 0;
+ }
+ *cur = (out-outbuff);
+ /* restore rest of buffer */
+ if(left)
+ out = strcopy(out,left);
+ *eol = (out-outbuff);
+ }
+ done:
+ sh_offstate(SH_FCOMPLETE);
+ if(!ep->e_nlist)
+ stakset(ep->e_stkptr,ep->e_stkoff);
+ if(nomarkdirs)
+ sh_offoption(SH_MARKDIRS);
+#if SHOPT_MULTIBYTE
+ {
+ register int c,n=0;
+ /* first re-adjust cur */
+ c = outbuff[*cur];
+ outbuff[*cur] = 0;
+ for(out=outbuff; *out;n++)
+ mbchar(out);
+ outbuff[*cur] = c;
+ *cur = n;
+ outbuff[*eol+1] = 0;
+ *eol = ed_internal(outbuff,(genchar*)outbuff);
+ }
+#endif /* SHOPT_MULTIBYTE */
+ return(rval);
+}
+
+/*
+ * look for edit macro named _i
+ * if found, puts the macro definition into lookahead buffer and returns 1
+ */
+int ed_macro(Edit_t *ep, register int i)
+{
+ register char *out;
+ Namval_t *np;
+ genchar buff[LOOKAHEAD+1];
+ if(i != '@')
+ ep->e_macro[1] = i;
+ /* undocumented feature, macros of the form <ESC>[c evoke alias __c */
+ if(i=='_')
+ ep->e_macro[2] = ed_getchar(ep,1);
+ else
+ ep->e_macro[2] = 0;
+ if (isalnum(i)&&(np=nv_search(ep->e_macro,sh.alias_tree,HASH_SCOPE))&&(out=nv_getval(np)))
+ {
+#if SHOPT_MULTIBYTE
+ /* copy to buff in internal representation */
+ int c = 0;
+ if( strlen(out) > LOOKAHEAD )
+ {
+ c = out[LOOKAHEAD];
+ out[LOOKAHEAD] = 0;
+ }
+ i = ed_internal(out,buff);
+ if(c)
+ out[LOOKAHEAD] = c;
+#else
+ strncpy((char*)buff,out,LOOKAHEAD);
+ buff[LOOKAHEAD] = 0;
+ i = strlen((char*)buff);
+#endif /* SHOPT_MULTIBYTE */
+ while(i-- > 0)
+ ed_ungetchar(ep,buff[i]);
+ return(1);
+ }
+ return(0);
+}
+
+/*
+ * Enter the fc command on the current history line
+ */
+int ed_fulledit(Edit_t *ep)
+{
+ register char *cp;
+ if(!sh.hist_ptr)
+ return(-1);
+ /* use EDITOR on current command */
+ if(ep->e_hline == ep->e_hismax)
+ {
+ if(ep->e_eol<0)
+ return(-1);
+#if SHOPT_MULTIBYTE
+ ep->e_inbuf[ep->e_eol+1] = 0;
+ ed_external(ep->e_inbuf, (char *)ep->e_inbuf);
+#endif /* SHOPT_MULTIBYTE */
+ sfwrite(sh.hist_ptr->histfp,(char*)ep->e_inbuf,ep->e_eol+1);
+ sh_onstate(SH_HISTORY);
+ hist_flush(sh.hist_ptr);
+ }
+ cp = strcopy((char*)ep->e_inbuf,e_runvi);
+ cp = strcopy(cp, fmtbase((long)ep->e_hline,10,0));
+ ep->e_eol = ((unsigned char*)cp - (unsigned char*)ep->e_inbuf)-(sh_isoption(SH_VI)!=0);
+ return(0);
+}
diff --git a/usr/src/lib/libshell/common/edit/edit.c b/usr/src/lib/libshell/common/edit/edit.c
new file mode 100644
index 0000000000..a832a4a965
--- /dev/null
+++ b/usr/src/lib/libshell/common/edit/edit.c
@@ -0,0 +1,1489 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * edit.c - common routines for vi and emacs one line editors in shell
+ *
+ * David Korn P.D. Sullivan
+ * AT&T Labs
+ *
+ * Coded April 1983.
+ */
+
+#include <ast.h>
+#include <errno.h>
+#include <ccode.h>
+#include <ctype.h>
+#include "FEATURE/options"
+#include "FEATURE/time"
+#include "FEATURE/cmds"
+#ifdef _hdr_utime
+# include <utime.h>
+# include <ls.h>
+#endif
+
+#if KSHELL
+# include "defs.h"
+# include "variables.h"
+#else
+ extern char ed_errbuf[];
+ char e_version[] = "\n@(#)$Id: Editlib version 1993-12-28 r $\0\n";
+#endif /* KSHELL */
+#include "io.h"
+#include "terminal.h"
+#include "history.h"
+#include "edit.h"
+
+static char CURSOR_UP[20] = { ESC, '[', 'A', 0 };
+
+#if SHOPT_MULTIBYTE
+# define is_cntrl(c) ((c<=STRIP) && iscntrl(c))
+# define is_print(c) ((c&~STRIP) || isprint(c))
+#else
+# define is_cntrl(c) iscntrl(c)
+# define is_print(c) isprint(c)
+#endif
+
+#if (CC_NATIVE == CC_ASCII)
+# define printchar(c) ((c) ^ ('A'-cntl('A')))
+#else
+ static int printchar(int c)
+ {
+ switch(c)
+ {
+
+ case cntl('A'): return('A');
+ case cntl('B'): return('B');
+ case cntl('C'): return('C');
+ case cntl('D'): return('D');
+ case cntl('E'): return('E');
+ case cntl('F'): return('F');
+ case cntl('G'): return('G');
+ case cntl('H'): return('H');
+ case cntl('I'): return('I');
+ case cntl('J'): return('J');
+ case cntl('K'): return('K');
+ case cntl('L'): return('L');
+ case cntl('M'): return('M');
+ case cntl('N'): return('N');
+ case cntl('O'): return('O');
+ case cntl('P'): return('P');
+ case cntl('Q'): return('Q');
+ case cntl('R'): return('R');
+ case cntl('S'): return('S');
+ case cntl('T'): return('T');
+ case cntl('U'): return('U');
+ case cntl('V'): return('V');
+ case cntl('W'): return('W');
+ case cntl('X'): return('X');
+ case cntl('Y'): return('Y');
+ case cntl('Z'): return('Z');
+ case cntl(']'): return(']');
+ case cntl('['): return('[');
+ }
+ return('?');
+ }
+#endif
+#define MINWINDOW 15 /* minimum width window */
+#define DFLTWINDOW 80 /* default window width */
+#define RAWMODE 1
+#define ALTMODE 2
+#define ECHOMODE 3
+#define SYSERR -1
+
+#if SHOPT_OLDTERMIO
+# undef tcgetattr
+# undef tcsetattr
+#endif /* SHOPT_OLDTERMIO */
+
+#ifdef RT
+# define VENIX 1
+#endif /* RT */
+
+
+#ifdef _hdr_sgtty
+# ifdef TIOCGETP
+ static int l_mask;
+ static struct tchars l_ttychars;
+ static struct ltchars l_chars;
+ static char l_changed; /* set if mode bits changed */
+# define L_CHARS 4
+# define T_CHARS 2
+# define L_MASK 1
+# endif /* TIOCGETP */
+#endif /* _hdr_sgtty */
+
+#if KSHELL
+ static int keytrap(Edit_t *,char*, int, int, int);
+#else
+ Edit_t editb;
+#endif /* KSHELL */
+
+
+#ifndef _POSIX_DISABLE
+# define _POSIX_DISABLE 0
+#endif
+
+#ifdef future
+ static int compare(const char*, const char*, int);
+#endif /* future */
+#if SHOPT_VSH || SHOPT_ESH
+# define ttyparm (ep->e_ttyparm)
+# define nttyparm (ep->e_nttyparm)
+ static const char bellchr[] = "\a"; /* bell char */
+#endif /* SHOPT_VSH || SHOPT_ESH */
+
+
+/*
+ * This routine returns true if fd refers to a terminal
+ * This should be equivalent to isatty
+ */
+int tty_check(int fd)
+{
+ register Edit_t *ep = (Edit_t*)(sh_getinterp()->ed_context);
+ struct termios tty;
+ ep->e_savefd = -1;
+ return(tty_get(fd,&tty)==0);
+}
+
+/*
+ * Get the current terminal attributes
+ * This routine remembers the attributes and just returns them if it
+ * is called again without an intervening tty_set()
+ */
+
+int tty_get(register int fd, register struct termios *tty)
+{
+ register Edit_t *ep = (Edit_t*)(sh_getinterp()->ed_context);
+ if(fd == ep->e_savefd)
+ *tty = ep->e_savetty;
+ else
+ {
+ while(tcgetattr(fd,tty) == SYSERR)
+ {
+ if(errno !=EINTR)
+ return(SYSERR);
+ errno = 0;
+ }
+ /* save terminal settings if in cannonical state */
+ if(ep->e_raw==0)
+ {
+ ep->e_savetty = *tty;
+ ep->e_savefd = fd;
+ }
+ }
+ return(0);
+}
+
+/*
+ * Set the terminal attributes
+ * If fd<0, then current attributes are invalidated
+ */
+
+int tty_set(int fd, int action, struct termios *tty)
+{
+ register Edit_t *ep = (Edit_t*)(sh_getinterp()->ed_context);
+ if(fd >=0)
+ {
+#ifdef future
+ if(ep->e_savefd>=0 && compare(&ep->e_savetty,tty,sizeof(struct termios)))
+ return(0);
+#endif
+ while(tcsetattr(fd, action, tty) == SYSERR)
+ {
+ if(errno !=EINTR)
+ return(SYSERR);
+ errno = 0;
+ }
+ ep->e_savetty = *tty;
+ }
+ ep->e_savefd = fd;
+ return(0);
+}
+
+#if SHOPT_ESH || SHOPT_VSH
+/*{ TTY_COOKED( fd )
+ *
+ * This routine will set the tty in cooked mode.
+ * It is also called by error.done().
+ *
+}*/
+
+void tty_cooked(register int fd)
+{
+ register Edit_t *ep = (Edit_t*)(sh_getinterp()->ed_context);
+ if(ep->e_raw==0)
+ return;
+ if(fd < 0)
+ fd = ep->e_savefd;
+#ifdef L_MASK
+ /* restore flags */
+ if(l_changed&L_MASK)
+ ioctl(fd,TIOCLSET,&l_mask);
+ if(l_changed&T_CHARS)
+ /* restore alternate break character */
+ ioctl(fd,TIOCSETC,&l_ttychars);
+ if(l_changed&L_CHARS)
+ /* restore alternate break character */
+ ioctl(fd,TIOCSLTC,&l_chars);
+ l_changed = 0;
+#endif /* L_MASK */
+ /*** don't do tty_set unless ttyparm has valid data ***/
+ if(tty_set(fd, TCSANOW, &ttyparm) == SYSERR)
+ return;
+ ep->e_raw = 0;
+ return;
+}
+
+/*{ TTY_RAW( fd )
+ *
+ * This routine will set the tty in raw mode.
+ *
+}*/
+
+int tty_raw(register int fd, int echomode)
+{
+ int echo = echomode;
+#ifdef L_MASK
+ struct ltchars lchars;
+#endif /* L_MASK */
+ register Edit_t *ep = (Edit_t*)(sh_getinterp()->ed_context);
+ if(ep->e_raw==RAWMODE)
+ return(echo?-1:0);
+ else if(ep->e_raw==ECHOMODE)
+ return(echo?0:-1);
+#if !SHOPT_RAWONLY
+ if(ep->e_raw != ALTMODE)
+#endif /* SHOPT_RAWONLY */
+ {
+ if(tty_get(fd,&ttyparm) == SYSERR)
+ return(-1);
+ }
+#if L_MASK || VENIX
+ if(ttyparm.sg_flags&LCASE)
+ return(-1);
+ if(!(ttyparm.sg_flags&ECHO))
+ {
+ if(!echomode)
+ return(-1);
+ echo = 0;
+ }
+ nttyparm = ttyparm;
+ if(!echo)
+ nttyparm.sg_flags &= ~(ECHO | TBDELAY);
+# ifdef CBREAK
+ nttyparm.sg_flags |= CBREAK;
+# else
+ nttyparm.sg_flags |= RAW;
+# endif /* CBREAK */
+ ep->e_erase = ttyparm.sg_erase;
+ ep->e_kill = ttyparm.sg_kill;
+ ep->e_eof = cntl('D');
+ ep->e_werase = cntl('W');
+ ep->e_lnext = cntl('V');
+ if( tty_set(fd, TCSADRAIN, &nttyparm) == SYSERR )
+ return(-1);
+ ep->e_ttyspeed = (ttyparm.sg_ospeed>=B1200?FAST:SLOW);
+# ifdef TIOCGLTC
+ /* try to remove effect of ^V and ^Y and ^O */
+ if(ioctl(fd,TIOCGLTC,&l_chars) != SYSERR)
+ {
+ lchars = l_chars;
+ lchars.t_lnextc = -1;
+ lchars.t_flushc = -1;
+ lchars.t_dsuspc = -1; /* no delayed stop process signal */
+ if(ioctl(fd,TIOCSLTC,&lchars) != SYSERR)
+ l_changed |= L_CHARS;
+ }
+# endif /* TIOCGLTC */
+#else
+ if (!(ttyparm.c_lflag & ECHO ))
+ {
+ if(!echomode)
+ return(-1);
+ echo = 0;
+ }
+# ifdef FLUSHO
+ ttyparm.c_lflag &= ~FLUSHO;
+# endif /* FLUSHO */
+ nttyparm = ttyparm;
+# ifndef u370
+ nttyparm.c_iflag &= ~(IGNPAR|PARMRK|INLCR|IGNCR|ICRNL);
+ nttyparm.c_iflag |= BRKINT;
+# else
+ nttyparm.c_iflag &=
+ ~(IGNBRK|PARMRK|INLCR|IGNCR|ICRNL|INPCK);
+ nttyparm.c_iflag |= (BRKINT|IGNPAR);
+# endif /* u370 */
+ if(echo)
+ nttyparm.c_lflag &= ~ICANON;
+ else
+ nttyparm.c_lflag &= ~(ICANON|ECHO|ECHOK);
+ nttyparm.c_cc[VTIME] = 0;
+ nttyparm.c_cc[VMIN] = 1;
+# ifdef VREPRINT
+ nttyparm.c_cc[VREPRINT] = _POSIX_DISABLE;
+# endif /* VREPRINT */
+# ifdef VDISCARD
+ nttyparm.c_cc[VDISCARD] = _POSIX_DISABLE;
+# endif /* VDISCARD */
+# ifdef VDSUSP
+ nttyparm.c_cc[VDSUSP] = _POSIX_DISABLE;
+# endif /* VDSUSP */
+# ifdef VWERASE
+ if(ttyparm.c_cc[VWERASE] == _POSIX_DISABLE)
+ ep->e_werase = cntl('W');
+ else
+ ep->e_werase = nttyparm.c_cc[VWERASE];
+ nttyparm.c_cc[VWERASE] = _POSIX_DISABLE;
+# else
+ ep->e_werase = cntl('W');
+# endif /* VWERASE */
+# ifdef VLNEXT
+ if(ttyparm.c_cc[VLNEXT] == _POSIX_DISABLE )
+ ep->e_lnext = cntl('V');
+ else
+ ep->e_lnext = nttyparm.c_cc[VLNEXT];
+ nttyparm.c_cc[VLNEXT] = _POSIX_DISABLE;
+# else
+ ep->e_lnext = cntl('V');
+# endif /* VLNEXT */
+ ep->e_eof = ttyparm.c_cc[VEOF];
+ ep->e_erase = ttyparm.c_cc[VERASE];
+ ep->e_kill = ttyparm.c_cc[VKILL];
+ if( tty_set(fd, TCSADRAIN, &nttyparm) == SYSERR )
+ return(-1);
+ ep->e_ttyspeed = (cfgetospeed(&ttyparm)>=B1200?FAST:SLOW);
+#endif
+ ep->e_raw = (echomode?ECHOMODE:RAWMODE);
+ return(0);
+}
+
+#if !SHOPT_RAWONLY
+
+/*
+ *
+ * Get tty parameters and make ESC and '\r' wakeup characters.
+ *
+ */
+
+# ifdef TIOCGETC
+int tty_alt(register int fd)
+{
+ register Edit_t *ep = (Edit_t*)(sh_getinterp()->ed_context);
+ int mask;
+ struct tchars ttychars;
+ switch(ep->e_raw)
+ {
+ case ECHOMODE:
+ return(-1);
+ case ALTMODE:
+ return(0);
+ case RAWMODE:
+ tty_cooked(fd);
+ }
+ l_changed = 0;
+ if( ep->e_ttyspeed == 0)
+ {
+ if((tty_get(fd,&ttyparm) != SYSERR))
+ ep->e_ttyspeed = (ttyparm.sg_ospeed>=B1200?FAST:SLOW);
+ ep->e_raw = ALTMODE;
+ }
+ if(ioctl(fd,TIOCGETC,&l_ttychars) == SYSERR)
+ return(-1);
+ if(ioctl(fd,TIOCLGET,&l_mask)==SYSERR)
+ return(-1);
+ ttychars = l_ttychars;
+ mask = LCRTBS|LCRTERA|LCTLECH|LPENDIN|LCRTKIL;
+ if((l_mask|mask) != l_mask)
+ l_changed = L_MASK;
+ if(ioctl(fd,TIOCLBIS,&mask)==SYSERR)
+ return(-1);
+ if(ttychars.t_brkc!=ESC)
+ {
+ ttychars.t_brkc = ESC;
+ l_changed |= T_CHARS;
+ if(ioctl(fd,TIOCSETC,&ttychars) == SYSERR)
+ return(-1);
+ }
+ return(0);
+}
+# else
+# ifndef PENDIN
+# define PENDIN 0
+# endif /* PENDIN */
+# ifndef IEXTEN
+# define IEXTEN 0
+# endif /* IEXTEN */
+
+int tty_alt(register int fd)
+{
+ register Edit_t *ep = (Edit_t*)(sh_getinterp()->ed_context);
+ switch(ep->e_raw)
+ {
+ case ECHOMODE:
+ return(-1);
+ case ALTMODE:
+ return(0);
+ case RAWMODE:
+ tty_cooked(fd);
+ }
+ if((tty_get(fd, &ttyparm)==SYSERR) || (!(ttyparm.c_lflag&ECHO)))
+ return(-1);
+# ifdef FLUSHO
+ ttyparm.c_lflag &= ~FLUSHO;
+# endif /* FLUSHO */
+ nttyparm = ttyparm;
+ ep->e_eof = ttyparm.c_cc[VEOF];
+# ifdef ECHOCTL
+ /* escape character echos as ^[ */
+ nttyparm.c_lflag |= (ECHOE|ECHOK|ECHOCTL|PENDIN|IEXTEN);
+ nttyparm.c_cc[VEOL] = ESC;
+# else
+ /* switch VEOL2 and EOF, since EOF isn't echo'd by driver */
+ nttyparm.c_lflag |= (ECHOE|ECHOK);
+ nttyparm.c_cc[VEOF] = ESC; /* make ESC the eof char */
+# ifdef VEOL2
+ nttyparm.c_iflag &= ~(IGNCR|ICRNL);
+ nttyparm.c_iflag |= INLCR;
+ nttyparm.c_cc[VEOL] = '\r'; /* make CR an eol char */
+ nttyparm.c_cc[VEOL2] = ep->e_eof; /* make EOF an eol char */
+# else
+ nttyparm.c_cc[VEOL] = ep->e_eof; /* make EOF an eol char */
+# endif /* VEOL2 */
+# endif /* ECHOCTL */
+# ifdef VREPRINT
+ nttyparm.c_cc[VREPRINT] = _POSIX_DISABLE;
+# endif /* VREPRINT */
+# ifdef VDISCARD
+ nttyparm.c_cc[VDISCARD] = _POSIX_DISABLE;
+# endif /* VDISCARD */
+# ifdef VWERASE
+ if(ttyparm.c_cc[VWERASE] == _POSIX_DISABLE)
+ nttyparm.c_cc[VWERASE] = cntl('W');
+ ep->e_werase = nttyparm.c_cc[VWERASE];
+# else
+ ep->e_werase = cntl('W');
+# endif /* VWERASE */
+# ifdef VLNEXT
+ if(ttyparm.c_cc[VLNEXT] == _POSIX_DISABLE )
+ nttyparm.c_cc[VLNEXT] = cntl('V');
+ ep->e_lnext = nttyparm.c_cc[VLNEXT];
+# else
+ ep->e_lnext = cntl('V');
+# endif /* VLNEXT */
+ ep->e_erase = ttyparm.c_cc[VERASE];
+ ep->e_kill = ttyparm.c_cc[VKILL];
+ if( tty_set(fd, TCSADRAIN, &nttyparm) == SYSERR )
+ return(-1);
+ ep->e_ttyspeed = (cfgetospeed(&ttyparm)>=B1200?FAST:SLOW);
+ ep->e_raw = ALTMODE;
+ return(0);
+}
+
+# endif /* TIOCGETC */
+#endif /* SHOPT_RAWONLY */
+
+/*
+ * ED_WINDOW()
+ *
+ * return the window size
+ */
+int ed_window(void)
+{
+ int rows,cols;
+ register char *cp = nv_getval(COLUMNS);
+ if(cp)
+ cols = (int)strtol(cp, (char**)0, 10)-1;
+ else
+ {
+ astwinsize(2,&rows,&cols);
+ if(--cols <0)
+ cols = DFLTWINDOW-1;
+ }
+ if(cols < MINWINDOW)
+ cols = MINWINDOW;
+ else if(cols > MAXWINDOW)
+ cols = MAXWINDOW;
+ return(cols);
+}
+
+/* E_FLUSH()
+ *
+ * Flush the output buffer.
+ *
+ */
+
+void ed_flush(Edit_t *ep)
+{
+ register int n = ep->e_outptr-ep->e_outbase;
+ register int fd = ERRIO;
+ if(n<=0)
+ return;
+ write(fd,ep->e_outbase,(unsigned)n);
+ ep->e_outptr = ep->e_outbase;
+}
+
+/*
+ * send the bell character ^G to the terminal
+ */
+
+void ed_ringbell(void)
+{
+ write(ERRIO,bellchr,1);
+}
+
+/*
+ * send a carriage return line feed to the terminal
+ */
+
+void ed_crlf(register Edit_t *ep)
+{
+#ifdef cray
+ ed_putchar(ep,'\r');
+#endif /* cray */
+#ifdef u370
+ ed_putchar(ep,'\r');
+#endif /* u370 */
+#ifdef VENIX
+ ed_putchar(ep,'\r');
+#endif /* VENIX */
+ ed_putchar(ep,'\n');
+ ed_flush(ep);
+}
+
+/* ED_SETUP( max_prompt_size )
+ *
+ * This routine sets up the prompt string
+ * The following is an unadvertised feature.
+ * Escape sequences in the prompt can be excluded from the calculated
+ * prompt length. This is accomplished as follows:
+ * - if the prompt string starts with "%\r, or contains \r%\r", where %
+ * represents any char, then % is taken to be the quote character.
+ * - strings enclosed by this quote character, and the quote character,
+ * are not counted as part of the prompt length.
+ */
+
+void ed_setup(register Edit_t *ep, int fd, int reedit)
+{
+ register char *pp;
+ register char *last;
+ char *ppmax;
+ int myquote = 0, n;
+ register int qlen = 1;
+ char inquote = 0;
+ ep->e_fd = fd;
+ ep->e_multiline = sh_isoption(SH_MULTILINE)!=0;
+#ifdef SIGWINCH
+ if(!(sh.sigflag[SIGWINCH]&SH_SIGFAULT))
+ {
+ signal(SIGWINCH,sh_fault);
+ sh.sigflag[SIGWINCH] |= SH_SIGFAULT;
+ }
+ sh_fault(SIGWINCH);
+#endif
+#if KSHELL
+ ep->e_stkptr = stakptr(0);
+ ep->e_stkoff = staktell();
+ if(!(last = sh.prompt))
+ last = "";
+ sh.prompt = 0;
+#else
+ last = ep->e_prbuff;
+#endif /* KSHELL */
+ if(sh.hist_ptr)
+ {
+ register History_t *hp = sh.hist_ptr;
+ ep->e_hismax = hist_max(hp);
+ ep->e_hismin = hist_min(hp);
+ }
+ else
+ {
+ ep->e_hismax = ep->e_hismin = ep->e_hloff = 0;
+ }
+ ep->e_hline = ep->e_hismax;
+ if(!sh_isoption(SH_VI) && !sh_isoption(SH_EMACS) && !sh_isoption(SH_GMACS))
+ ep->e_wsize = MAXLINE;
+ else
+ ep->e_wsize = ed_window()-2;
+ ep->e_winsz = ep->e_wsize+2;
+ ep->e_crlf = 1;
+ ep->e_plen = 0;
+ pp = ep->e_prompt;
+ ppmax = pp+PRSIZE-1;
+ *pp++ = '\r';
+ {
+ register int c;
+ while(c= *last++) switch(c)
+ {
+ case ESC:
+ {
+ int skip=0;
+ ep->e_crlf = 0;
+ *pp++ = c;
+ for(n=1; c = *last++; n++)
+ {
+ if(pp < ppmax)
+ *pp++ = c;
+ if(c=='\a')
+ break;
+ if(skip || (c>='0' && c<='9'))
+ continue;
+ if(n>1 && c==';')
+ skip = 1;
+ else if(n>2 || (c!= '[' && c!= ']'))
+ break;
+ }
+ qlen += (n+1);
+ break;
+ }
+ case '\b':
+ if(pp>ep->e_prompt+1)
+ pp--;
+ break;
+ case '\r':
+ if(pp == (ep->e_prompt+2)) /* quote char */
+ myquote = *(pp-1);
+ /*FALLTHROUGH*/
+
+ case '\n':
+ /* start again */
+ ep->e_crlf = 1;
+ qlen = 1;
+ inquote = 0;
+ pp = ep->e_prompt+1;
+ break;
+
+ case '\t':
+ /* expand tabs */
+ while((pp-ep->e_prompt)%TABSIZE)
+ {
+ if(pp >= ppmax)
+ break;
+ *pp++ = ' ';
+ }
+ break;
+
+ case '\a':
+ /* cut out bells */
+ break;
+
+ default:
+ if(c==myquote)
+ {
+ qlen += inquote;
+ inquote ^= 1;
+ }
+ if(pp < ppmax)
+ {
+ qlen += inquote;
+ *pp++ = c;
+ if(!inquote && !is_print(c))
+ ep->e_crlf = 0;
+ }
+ }
+ }
+ if(pp-ep->e_prompt > qlen)
+ ep->e_plen = pp - ep->e_prompt - qlen;
+ *pp = 0;
+ if((ep->e_wsize -= ep->e_plen) < 7)
+ {
+ register int shift = 7-ep->e_wsize;
+ ep->e_wsize = 7;
+ pp = ep->e_prompt+1;
+ strcpy(pp,pp+shift);
+ ep->e_plen -= shift;
+ last[-ep->e_plen-2] = '\r';
+ }
+ sfsync(sfstderr);
+ if(fd == sffileno(sfstderr))
+ {
+ /* can't use output buffer when reading from stderr */
+ static char *buff;
+ if(!buff)
+ buff = (char*)malloc(MAXLINE);
+ ep->e_outbase = ep->e_outptr = buff;
+ ep->e_outlast = ep->e_outptr + MAXLINE;
+ return;
+ }
+ qlen = sfset(sfstderr,SF_READ,0);
+ /* make sure SF_READ not on */
+ ep->e_outbase = ep->e_outptr = (char*)sfreserve(sfstderr,SF_UNBOUND,SF_LOCKR);
+ ep->e_outlast = ep->e_outptr + sfvalue(sfstderr);
+ if(qlen)
+ sfset(sfstderr,SF_READ,1);
+ sfwrite(sfstderr,ep->e_outptr,0);
+ ep->e_eol = reedit;
+ if(ep->e_multiline)
+ {
+#ifdef _cmd_tput
+ char *term;
+ if(!ep->e_term)
+ ep->e_term = nv_search("TERM",sh.var_tree,0);
+ if(ep->e_term && (term=nv_getval(ep->e_term)) && strlen(term)<sizeof(ep->e_termname) && strcmp(term,ep->e_termname))
+ {
+ sh_trap(".sh.subscript=$(tput cuu1 2>/dev/null)",0);
+ if(pp=nv_getval(SH_SUBSCRNOD))
+ strncpy(CURSOR_UP,pp,sizeof(CURSOR_UP)-1);
+ nv_unset(SH_SUBSCRNOD);
+ strcpy(ep->e_termname,term);
+ }
+#endif
+ ep->e_wsize = MAXLINE - (ep->e_plen-2);
+ }
+ if(ep->e_default && (pp = nv_getval(ep->e_default)))
+ {
+ n = strlen(pp);
+ if(n > LOOKAHEAD)
+ n = LOOKAHEAD;
+ ep->e_lookahead = n;
+ while(n-- > 0)
+ ep->e_lbuf[n] = *pp++;
+ ep->e_default = 0;
+ }
+}
+
+/*
+ * Do read, restart on interrupt unless SH_SIGSET or SH_SIGTRAP is set
+ * Use sfpkrd() to poll() or select() to wait for input if possible
+ * Unfortunately, systems that get interrupted from slow reads update
+ * this access time for for the terminal (in violation of POSIX).
+ * The fixtime() macro, resets the time to the time at entry in
+ * this case. This is not necessary for systems that can handle
+ * sfpkrd() correctly (i,e., those that support poll() or select()
+ */
+int ed_read(void *context, int fd, char *buff, int size, int reedit)
+{
+ register Edit_t *ep = (Edit_t*)context;
+ register int rv= -1;
+ register int delim = (ep->e_raw==RAWMODE?'\r':'\n');
+ int mode = -1;
+ int (*waitevent)(int,long,int) = sh.waitevent;
+ if(ep->e_raw==ALTMODE)
+ mode = 1;
+ if(size < 0)
+ {
+ mode = 1;
+ size = -size;
+ }
+ sh_onstate(SH_TTYWAIT);
+ errno = EINTR;
+ sh.waitevent = 0;
+ while(rv<0 && errno==EINTR)
+ {
+ if(sh.trapnote&(SH_SIGSET|SH_SIGTRAP))
+ goto done;
+ /* an interrupt that should be ignored */
+ errno = 0;
+ if(!waitevent || (rv=(*waitevent)(fd,-1L,0))>=0)
+ rv = sfpkrd(fd,buff,size,delim,-1L,mode);
+ }
+ if(rv < 0)
+ {
+#ifdef _hdr_utime
+# define fixtime() if(isdevtty)utime(ep->e_tty,&utimes)
+ int isdevtty=0;
+ struct stat statb;
+ struct utimbuf utimes;
+ if(errno==0 && !ep->e_tty)
+ {
+ if((ep->e_tty=ttyname(fd)) && stat(ep->e_tty,&statb)>=0)
+ {
+ ep->e_tty_ino = statb.st_ino;
+ ep->e_tty_dev = statb.st_dev;
+ }
+ }
+ if(ep->e_tty_ino && fstat(fd,&statb)>=0 && statb.st_ino==ep->e_tty_ino && statb.st_dev==ep->e_tty_dev)
+ {
+ utimes.actime = statb.st_atime;
+ utimes.modtime = statb.st_mtime;
+ isdevtty=1;
+ }
+#else
+# define fixtime()
+#endif /* _hdr_utime */
+ while(1)
+ {
+ rv = read(fd,buff,size);
+ if(rv>=0 || errno!=EINTR)
+ break;
+ if(sh.trapnote&(SH_SIGSET|SH_SIGTRAP))
+ goto done;
+ /* an interrupt that should be ignored */
+ fixtime();
+ }
+ }
+ else if(rv>=0 && mode>0)
+ rv = read(fd,buff,rv>0?rv:1);
+done:
+ sh.waitevent = waitevent;
+ sh_offstate(SH_TTYWAIT);
+ return(rv);
+}
+
+
+/*
+ * put <string> of length <nbyte> onto lookahead stack
+ * if <type> is non-zero, the negation of the character is put
+ * onto the stack so that it can be checked for KEYTRAP
+ * putstack() returns 1 except when in the middle of a multi-byte char
+ */
+static int putstack(Edit_t *ep,char string[], register int nbyte, int type)
+{
+ register int c;
+#if SHOPT_MULTIBYTE
+ char *endp, *p=string;
+ int size, offset = ep->e_lookahead + nbyte;
+ *(endp = &p[nbyte]) = 0;
+ endp = &p[nbyte];
+ do
+ {
+ c = (int)((*p) & STRIP);
+ if(c< 0x80 && c!='<')
+ {
+ if (type)
+ c = -c;
+# ifndef CBREAK
+ if(c == '\0')
+ {
+ /*** user break key ***/
+ ep->e_lookahead = 0;
+# if KSHELL
+ sh_fault(SIGINT);
+ siglongjmp(ep->e_env, UINTR);
+# endif /* KSHELL */
+ }
+# endif /* CBREAK */
+
+ }
+ else
+ {
+ again:
+ if((c=mbchar(p)) >=0)
+ {
+ p--; /* incremented below */
+ if(type)
+ c = -c;
+ }
+#ifdef EILSEQ
+ else if(errno == EILSEQ)
+ errno = 0;
+#endif
+ else if((endp-p) < mbmax())
+ {
+ if ((c=ed_read(ep,ep->e_fd,endp, 1,0)) == 1)
+ {
+ *++endp = 0;
+ goto again;
+ }
+ return(c);
+ }
+ else
+ {
+ ed_ringbell();
+ c = -(int)((*p) & STRIP);
+ offset += mbmax()-1;
+ }
+ }
+ ep->e_lbuf[--offset] = c;
+ p++;
+ }
+ while (p < endp);
+ /* shift lookahead buffer if necessary */
+ if(offset -= ep->e_lookahead)
+ {
+ for(size=offset;size < nbyte;size++)
+ ep->e_lbuf[ep->e_lookahead+size-offset] = ep->e_lbuf[ep->e_lookahead+size];
+ }
+ ep->e_lookahead += nbyte-offset;
+#else
+ while (nbyte > 0)
+ {
+ c = string[--nbyte] & STRIP;
+ ep->e_lbuf[ep->e_lookahead++] = (type?-c:c);
+# ifndef CBREAK
+ if( c == '\0' )
+ {
+ /*** user break key ***/
+ ep->e_lookahead = 0;
+# if KSHELL
+ sh_fault(SIGINT);
+ siglongjmp(ep->e_env, UINTR);
+# endif /* KSHELL */
+ }
+# endif /* CBREAK */
+ }
+#endif /* SHOPT_MULTIBYTE */
+ return(1);
+}
+
+/*
+ * routine to perform read from terminal for vi and emacs mode
+ * <mode> can be one of the following:
+ * -2 vi insert mode - key binding is in effect
+ * -1 vi control mode - key binding is in effect
+ * 0 normal command mode - key binding is in effect
+ * 1 edit keys not mapped
+ * 2 Next key is literal
+ */
+int ed_getchar(register Edit_t *ep,int mode)
+{
+ register int n, c;
+ char readin[LOOKAHEAD+1];
+ if(!ep->e_lookahead)
+ {
+ ed_flush(ep);
+ ep->e_inmacro = 0;
+ /* The while is necessary for reads of partial multbyte chars */
+ if((n=ed_read(ep,ep->e_fd,readin,-LOOKAHEAD,0)) > 0)
+ n = putstack(ep,readin,n,1);
+ }
+ if(ep->e_lookahead)
+ {
+ /* check for possible key mapping */
+ if((c = ep->e_lbuf[--ep->e_lookahead]) < 0)
+ {
+ if(mode<=0 && sh.st.trap[SH_KEYTRAP])
+ {
+ n=1;
+ if((readin[0]= -c) == ESC)
+ {
+ while(1)
+ {
+ if(!ep->e_lookahead)
+ {
+ if((c=sfpkrd(ep->e_fd,readin+n,1,'\r',(mode?400L:-1L),0))>0)
+ putstack(ep,readin+n,c,1);
+ }
+ if(!ep->e_lookahead)
+ break;
+ if((c=ep->e_lbuf[--ep->e_lookahead])>=0)
+ {
+ ep->e_lookahead++;
+ break;
+ }
+ c = -c;
+ readin[n++] = c;
+ if(c>='0' && c<='9' && n>2)
+ continue;
+ if(n>2 || (c!= '[' && c!= 'O'))
+ break;
+ }
+ }
+ if(n=keytrap(ep,readin,n,LOOKAHEAD-n,mode))
+ {
+ putstack(ep,readin,n,0);
+ c = ep->e_lbuf[--ep->e_lookahead];
+ }
+ else
+ c = ed_getchar(ep,mode);
+ }
+ else
+ c = -c;
+ }
+ /*** map '\r' to '\n' ***/
+ if(c == '\r' && mode!=2)
+ c = '\n';
+ if(ep->e_tabcount && !(c=='\t'||c==ESC || c=='\\' || c=='=' || c==cntl('L') || isdigit(c)))
+ ep->e_tabcount = 0;
+ }
+ else
+ siglongjmp(ep->e_env,(n==0?UEOF:UINTR));
+ return(c);
+}
+
+void ed_ungetchar(Edit_t *ep,register int c)
+{
+ if (ep->e_lookahead < LOOKAHEAD)
+ ep->e_lbuf[ep->e_lookahead++] = c;
+ return;
+}
+
+/*
+ * put a character into the output buffer
+ */
+
+void ed_putchar(register Edit_t *ep,register int c)
+{
+ char buf[8];
+ register char *dp = ep->e_outptr;
+ register int i,size=1;
+ buf[0] = c;
+#if SHOPT_MULTIBYTE
+ /* check for place holder */
+ if(c == MARKER)
+ return;
+ if((size = mbconv(buf, (wchar_t)c)) > 1)
+ {
+ for (i = 0; i < (size-1); i++)
+ *dp++ = buf[i];
+ c = buf[i];
+ }
+ else
+ {
+ buf[0] = c;
+ size = 1;
+ }
+#endif /* SHOPT_MULTIBYTE */
+ if (buf[0] == '_' && size==1)
+ {
+ *dp++ = ' ';
+ *dp++ = '\b';
+ }
+ *dp++ = c;
+ *dp = '\0';
+ if(dp >= ep->e_outlast)
+ ed_flush(ep);
+ else
+ ep->e_outptr = dp;
+}
+
+/*
+ * returns the line and column corresponding to offset <off> in the physical buffer
+ * if <cur> is non-zero and <= <off>, then correspodning <curpos> will start the search
+ */
+Edpos_t ed_curpos(Edit_t *ep,genchar *phys, int off, int cur, Edpos_t curpos)
+{
+ register genchar *sp=phys;
+ register int c=1, col=ep->e_plen;
+ Edpos_t pos;
+#if SHOPT_MULTIBYTE
+ char p[16];
+#endif /* SHOPT_MULTIBYTE */
+ if(cur && off>=cur)
+ {
+ sp += cur;
+ off -= cur;
+ pos = curpos;
+ col = pos.col;
+ }
+ else
+ pos.line = 0;
+ while(off-->0)
+ {
+ if(c)
+ c = *sp++;
+#if SHOPT_MULTIBYTE
+ if(c && (mbconv(p, (wchar_t)c))==1 && p[0]=='\n')
+#else
+ if(c=='\n')
+#endif /* SHOPT_MULTIBYTE */
+ col = 0;
+ else
+ col++;
+ if(col > ep->e_winsz)
+ col = 0;
+ if(col==0)
+ pos.line++;
+ }
+ pos.col = col;
+ return(pos);
+}
+
+static void ed_putstring(register Edit_t *ep, const char *str)
+{
+ register int c;
+ while(c = *str++)
+ ed_putchar(ep,c);
+}
+
+int ed_setcursor(register Edit_t *ep,genchar *physical,register int old,register int new,int first)
+{
+ static int oldline;
+ register int delta;
+ Edpos_t newpos;
+
+ delta = new - old;
+ if( delta == 0 )
+ return(new);
+ if(ep->e_multiline)
+ {
+ ep->e_curpos = ed_curpos(ep, physical, old,0,ep->e_curpos);
+ newpos = ed_curpos(ep, physical, new,old,ep->e_curpos);
+ if(ep->e_curpos.col==0 && ep->e_curpos.line>0 && oldline<ep->e_curpos.line && delta<0)
+ ed_putstring(ep,"\r\n");
+ oldline = newpos.line;
+ if(ep->e_curpos.line > newpos.line)
+ {
+ int n;
+ for(;ep->e_curpos.line > newpos.line; ep->e_curpos.line--)
+ ed_putstring(ep,CURSOR_UP);
+ if(newpos.line==0 && (n=ep->e_plen- ep->e_curpos.col)>0)
+ {
+ ep->e_curpos.col += n;
+ ed_putchar(ep,'\r');
+ if(!ep->e_crlf)
+ ed_putstring(ep,ep->e_prompt);
+ else
+ {
+ int m = ep->e_winsz+1-ep->e_plen;
+ ed_putchar(ep,'\n');
+ n = ep->e_plen;
+ if(m < ed_genlen(physical))
+ {
+ while(physical[m] && n-->0)
+ ed_putchar(ep,physical[m++]);
+ }
+ while(n-->0)
+ ed_putchar(ep,' ');
+ ed_putstring(ep,CURSOR_UP);
+ }
+ }
+ }
+ else if(ep->e_curpos.line < newpos.line)
+ {
+ for(;ep->e_curpos.line < newpos.line;ep->e_curpos.line++)
+ ed_putchar(ep,'\n');
+ ed_putchar(ep,'\r');
+ ep->e_curpos.col = 0;
+ }
+ delta = newpos.col - ep->e_curpos.col;
+ old = new - delta;
+ }
+ else
+ newpos.line=0;
+ if(delta<0)
+ {
+ /*** move to left ***/
+ delta = -delta;
+ /*** attempt to optimize cursor movement ***/
+ if(!ep->e_crlf || (2*delta <= ((old-first)+(newpos.line?0:ep->e_plen))) )
+ {
+ for( ; delta; delta-- )
+ ed_putchar(ep,'\b');
+ }
+ else
+ {
+ if(newpos.line==0)
+ ed_putstring(ep,ep->e_prompt);
+ old = first;
+ delta = new-first;
+ }
+ }
+ while(delta-->0)
+ ed_putchar(ep,physical[old++]);
+ return(new);
+}
+
+/*
+ * copy virtual to physical and return the index for cursor in physical buffer
+ */
+int ed_virt_to_phys(Edit_t *ep,genchar *virt,genchar *phys,int cur,int voff,int poff)
+{
+ register genchar *sp = virt;
+ register genchar *dp = phys;
+ register int c;
+ genchar *curp = sp + cur;
+ genchar *dpmax = phys+MAXLINE;
+ int d, r;
+ sp += voff;
+ dp += poff;
+ for(r=poff;c= *sp;sp++)
+ {
+ if(curp == sp)
+ r = dp - phys;
+#if SHOPT_MULTIBYTE
+ d = mbwidth((wchar_t)c);
+ if(d==1 && is_cntrl(c))
+ d = -1;
+ if(d>1)
+ {
+ /* multiple width character put in place holders */
+ *dp++ = c;
+ while(--d >0)
+ *dp++ = MARKER;
+ /* in vi mode the cursor is at the last character */
+ if(dp>=dpmax)
+ break;
+ continue;
+ }
+ else
+#else
+ d = (is_cntrl(c)?-1:1);
+#endif /* SHOPT_MULTIBYTE */
+ if(d<0)
+ {
+ if(c=='\t')
+ {
+ c = dp-phys;
+ if(sh_isoption(SH_VI))
+ c += ep->e_plen;
+ c = TABSIZE - c%TABSIZE;
+ while(--c>0)
+ *dp++ = ' ';
+ c = ' ';
+ }
+ else
+ {
+ *dp++ = '^';
+ c = printchar(c);
+ }
+ /* in vi mode the cursor is at the last character */
+ if(curp == sp && sh_isoption(SH_VI))
+ r = dp - phys;
+ }
+ *dp++ = c;
+ if(dp>=dpmax)
+ break;
+ }
+ *dp = 0;
+ return(r);
+}
+
+#if SHOPT_MULTIBYTE
+/*
+ * convert external representation <src> to an array of genchars <dest>
+ * <src> and <dest> can be the same
+ * returns number of chars in dest
+ */
+
+int ed_internal(const char *src, genchar *dest)
+{
+ register const unsigned char *cp = (unsigned char *)src;
+ register int c;
+ register wchar_t *dp = (wchar_t*)dest;
+ if(dest == (genchar*)roundof(cp-(unsigned char*)0,sizeof(genchar)))
+ {
+ genchar buffer[MAXLINE];
+ c = ed_internal(src,buffer);
+ ed_gencpy((genchar*)dp,buffer);
+ return(c);
+ }
+ while(*cp)
+ *dp++ = mbchar(cp);
+ *dp = 0;
+ return(dp-(wchar_t*)dest);
+}
+
+/*
+ * convert internal representation <src> into character array <dest>.
+ * The <src> and <dest> may be the same.
+ * returns number of chars in dest.
+ */
+
+int ed_external(const genchar *src, char *dest)
+{
+ register genchar wc;
+ register int c,size;
+ register char *dp = dest;
+ char *dpmax = dp+sizeof(genchar)*MAXLINE-2;
+ if((char*)src == dp)
+ {
+ char buffer[MAXLINE*sizeof(genchar)];
+ c = ed_external(src,buffer);
+
+#ifdef _lib_wcscpy
+ wcscpy((wchar_t *)dest,(const wchar_t *)buffer);
+#else
+ strcpy(dest,buffer);
+#endif
+ return(c);
+ }
+ while((wc = *src++) && dp<dpmax)
+ {
+ if((size = mbconv(dp, wc)) < 0)
+ {
+ /* copy the character as is */
+ size = 1;
+ *dp = wc;
+ }
+ dp += size;
+ }
+ *dp = 0;
+ return(dp-dest);
+}
+
+/*
+ * copy <sp> to <dp>
+ */
+
+void ed_gencpy(genchar *dp,const genchar *sp)
+{
+ dp = (genchar*)roundof((char*)dp-(char*)0,sizeof(genchar));
+ sp = (const genchar*)roundof((char*)sp-(char*)0,sizeof(genchar));
+ while(*dp++ = *sp++);
+}
+
+/*
+ * copy at most <n> items from <sp> to <dp>
+ */
+
+void ed_genncpy(register genchar *dp,register const genchar *sp, int n)
+{
+ dp = (genchar*)roundof((char*)dp-(char*)0,sizeof(genchar));
+ sp = (const genchar*)roundof((char*)sp-(char*)0,sizeof(genchar));
+ while(n-->0 && (*dp++ = *sp++));
+}
+
+/*
+ * find the string length of <str>
+ */
+
+int ed_genlen(register const genchar *str)
+{
+ register const genchar *sp = str;
+ sp = (const genchar*)roundof((char*)sp-(char*)0,sizeof(genchar));
+ while(*sp++);
+ return(sp-str-1);
+}
+#endif /* SHOPT_MULTIBYTE */
+#endif /* SHOPT_ESH || SHOPT_VSH */
+
+#ifdef future
+/*
+ * returns 1 when <n> bytes starting at <a> and <b> are equal
+ */
+static int compare(register const char *a,register const char *b,register int n)
+{
+ while(n-->0)
+ {
+ if(*a++ != *b++)
+ return(0);
+ }
+ return(1);
+}
+#endif
+
+#if SHOPT_OLDTERMIO
+
+# include <sys/termio.h>
+
+#ifndef ECHOCTL
+# define ECHOCTL 0
+#endif /* !ECHOCTL */
+#define ott ep->e_ott
+
+/*
+ * For backward compatibility only
+ * This version will use termios when possible, otherwise termio
+ */
+
+
+tcgetattr(int fd, struct termios *tt)
+{
+ register Edit_t *ep = (Edit_t*)(sh_getinterp()->ed_context);
+ register int r,i;
+ ep->e_tcgeta = 0;
+ ep->e_echoctl = (ECHOCTL!=0);
+ if((r=ioctl(fd,TCGETS,tt))>=0 || errno!=EINVAL)
+ return(r);
+ if((r=ioctl(fd,TCGETA,&ott)) >= 0)
+ {
+ tt->c_lflag = ott.c_lflag;
+ tt->c_oflag = ott.c_oflag;
+ tt->c_iflag = ott.c_iflag;
+ tt->c_cflag = ott.c_cflag;
+ for(i=0; i<NCC; i++)
+ tt->c_cc[i] = ott.c_cc[i];
+ ep->e_tcgeta++;
+ ep->e_echoctl = 0;
+ }
+ return(r);
+}
+
+tcsetattr(int fd,int mode,struct termios *tt)
+{
+ register Edit_t *ep = (Edit_t*)(sh_getinterp()->ed_context);
+ register int r;
+ if(ep->e_tcgeta)
+ {
+ register int i;
+ ott.c_lflag = tt->c_lflag;
+ ott.c_oflag = tt->c_oflag;
+ ott.c_iflag = tt->c_iflag;
+ ott.c_cflag = tt->c_cflag;
+ for(i=0; i<NCC; i++)
+ ott.c_cc[i] = tt->c_cc[i];
+ if(tt->c_lflag&ECHOCTL)
+ {
+ ott.c_lflag &= ~(ECHOCTL|IEXTEN);
+ ott.c_iflag &= ~(IGNCR|ICRNL);
+ ott.c_iflag |= INLCR;
+ ott.c_cc[VEOF]= ESC; /* ESC -> eof char */
+ ott.c_cc[VEOL] = '\r'; /* CR -> eol char */
+ ott.c_cc[VEOL2] = tt->c_cc[VEOF]; /* EOF -> eol char */
+ }
+ switch(mode)
+ {
+ case TCSANOW:
+ mode = TCSETA;
+ break;
+ case TCSADRAIN:
+ mode = TCSETAW;
+ break;
+ case TCSAFLUSH:
+ mode = TCSETAF;
+ }
+ return(ioctl(fd,mode,&ott));
+ }
+ return(ioctl(fd,mode,tt));
+}
+#endif /* SHOPT_OLDTERMIO */
+
+#if KSHELL
+/*
+ * Execute keyboard trap on given buffer <inbuff> of given size <isize>
+ * <mode> < 0 for vi insert mode
+ */
+static int keytrap(Edit_t *ep,char *inbuff,register int insize, int bufsize, int mode)
+{
+ register char *cp;
+ int savexit;
+#if SHOPT_MULTIBYTE
+ char buff[MAXLINE];
+ ed_external(ep->e_inbuf,cp=buff);
+#else
+ cp = ep->e_inbuf;
+#endif /* SHOPT_MULTIBYTE */
+ inbuff[insize] = 0;
+ ep->e_col = ep->e_cur;
+ if(mode== -2)
+ {
+ ep->e_col++;
+ *ep->e_vi_insert = ESC;
+ }
+ else
+ *ep->e_vi_insert = 0;
+ nv_putval(ED_CHRNOD,inbuff,NV_NOFREE);
+ nv_putval(ED_COLNOD,(char*)&ep->e_col,NV_NOFREE|NV_INTEGER);
+ nv_putval(ED_TXTNOD,(char*)cp,NV_NOFREE);
+ nv_putval(ED_MODENOD,ep->e_vi_insert,NV_NOFREE);
+ savexit = sh.savexit;
+ sh_trap(sh.st.trap[SH_KEYTRAP],0);
+ sh.savexit = savexit;
+ if((cp = nv_getval(ED_CHRNOD)) == inbuff)
+ nv_unset(ED_CHRNOD);
+ else
+ {
+ strncpy(inbuff,cp,bufsize);
+ insize = strlen(inbuff);
+ }
+ nv_unset(ED_TXTNOD);
+ return(insize);
+}
+#endif /* KSHELL */
+
+void *ed_open(Shell_t *shp)
+{
+ Edit_t *ed = newof(0,Edit_t,1,0);
+ ed->sh = shp;
+ strcpy(ed->e_macro,"_??");
+ return((void*)ed);
+}
diff --git a/usr/src/lib/libshell/common/edit/emacs.c b/usr/src/lib/libshell/common/edit/emacs.c
new file mode 100644
index 0000000000..0882693cc9
--- /dev/null
+++ b/usr/src/lib/libshell/common/edit/emacs.c
@@ -0,0 +1,1444 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/* Original version by Michael T. Veach
+ * Adapted for ksh by David Korn */
+/* EMACS_MODES: c tabstop=4
+
+One line screen editor for any program
+
+*/
+
+
+/* The following is provided by:
+ *
+ * Matthijs N. Melchior
+ * AT&T Network Systems International
+ * APT Nederland
+ * HV BZ335 x2962
+ * hvlpb!mmelchio
+ *
+ * These are now on by default
+ *
+ * ESH_NFIRST
+ * - A ^N as first history related command after the prompt will move
+ * to the next command relative to the last known history position.
+ * It will not start at the position where the last command was entered
+ * as is done by the ^P command. Every history related command will
+ * set both the current and last position. Executing a command will
+ * only set the current position.
+ *
+ * ESH_KAPPEND
+ * - Successive kill and delete commands will accumulate their data
+ * in the kill buffer, by appending or prepending as appropriate.
+ * This mode will be reset by any command not adding something to the
+ * kill buffer.
+ *
+ * ESH_BETTER
+ * - Some enhancements:
+ * - argument for a macro is passed to its replacement
+ * - ^X^H command to find out about history position (debugging)
+ * - ^X^D command to show any debugging info
+ *
+ * I do not pretend these for changes are completely independent,
+ * but you can use them to seperate features.
+ */
+
+#include <ast.h>
+#include <ctype.h>
+#include "FEATURE/cmds"
+#if KSHELL
+# include "defs.h"
+#endif /* KSHELL */
+#include "io.h"
+
+#include "history.h"
+#include "edit.h"
+#include "terminal.h"
+
+#define ESH_NFIRST
+#define ESH_KAPPEND
+#define ESH_BETTER
+
+#undef putchar
+#define putchar(ed,c) ed_putchar(ed,c)
+#define beep() ed_ringbell()
+
+
+#if SHOPT_MULTIBYTE
+# define gencpy(a,b) ed_gencpy(a,b)
+# define genncpy(a,b,n) ed_genncpy(a,b,n)
+# define genlen(str) ed_genlen(str)
+ static int print(int);
+ static int _isword(int);
+# define isword(c) _isword(out[c])
+
+#else
+# define gencpy(a,b) strcpy((char*)(a),(char*)(b))
+# define genncpy(a,b,n) strncpy((char*)(a),(char*)(b),n)
+# define genlen(str) strlen(str)
+# define print(c) isprint(c)
+# define isword(c) (isalnum(out[c]) || (out[c]=='_'))
+#endif /*SHOPT_MULTIBYTE */
+
+typedef struct _emacs_
+{
+ genchar *screen; /* pointer to window buffer */
+ genchar *cursor; /* Cursor in real screen */
+ int mark;
+ int in_mult;
+ char cr_ok;
+ char CntrlO;
+ char overflow; /* Screen overflow flag set */
+ char scvalid; /* Screen is up to date */
+ int offset; /* Screen offset */
+ enum
+ {
+ CRT=0, /* Crt terminal */
+ PAPER /* Paper terminal */
+ } terminal;
+ Histloc_t _location;
+ int prevdirection;
+ Edit_t *ed; /* pointer to edit data */
+} Emacs_t;
+
+#define editb (*ep->ed)
+#define eol editb.e_eol
+#define cur editb.e_cur
+#define hline editb.e_hline
+#define hloff editb.e_hloff
+#define hismin editb.e_hismin
+#define usrkill editb.e_kill
+#define usrlnext editb.e_lnext
+#define usreof editb.e_eof
+#define usrerase editb.e_erase
+#define crallowed editb.e_crlf
+#define Prompt editb.e_prompt
+#define plen editb.e_plen
+#define kstack editb.e_killbuf
+#define lstring editb.e_search
+#define lookahead editb.e_lookahead
+#define env editb.e_env
+#define raw editb.e_raw
+#define histlines editb.e_hismax
+#define w_size editb.e_wsize
+#define drawbuff editb.e_inbuf
+#define killing editb.e_mode
+#define location ep->_location
+
+#define LBUF 100
+#define KILLCHAR UKILL
+#define ERASECHAR UERASE
+#define EOFCHAR UEOF
+#define LNEXTCHAR ULNEXT
+#define DELETE ('a'==97?0177:7)
+
+/**********************
+A large lookahead helps when the user is inserting
+characters in the middle of the line.
+************************/
+
+
+typedef enum
+{
+ FIRST, /* First time thru for logical line, prompt on screen */
+ REFRESH, /* Redraw entire screen */
+ APPEND, /* Append char before cursor to screen */
+ UPDATE, /* Update the screen as need be */
+ FINAL /* Update screen even if pending look ahead */
+} Draw_t;
+
+static void draw(Emacs_t*,Draw_t);
+static int escape(Emacs_t*,genchar*, int);
+static void putstring(Emacs_t*,char*);
+static void search(Emacs_t*,genchar*,int);
+static void setcursor(Emacs_t*,int, int);
+static void show_info(Emacs_t*,const char*);
+static void xcommands(Emacs_t*,int);
+
+int ed_emacsread(void *context, int fd,char *buff,int scend, int reedit)
+{
+ Edit_t *ed = (Edit_t*)context;
+ register int c;
+ register int i;
+ register genchar *out;
+ register int count;
+ register Emacs_t *ep = ed->e_emacs;
+ int adjust,oadjust;
+ char backslash;
+ genchar *kptr;
+ char prompt[PRSIZE];
+ genchar Screen[MAXLINE];
+ if(!ep)
+ {
+ ep = ed->e_emacs = newof(0,Emacs_t,1,0);
+ ep->ed = ed;
+ ep->prevdirection = 1;
+ location.hist_command = -5;
+ }
+ Prompt = prompt;
+ ep->screen = Screen;
+ if(tty_raw(ERRIO,0) < 0)
+ {
+ return(reedit?reedit:ed_read(context, fd,buff,scend,0));
+ }
+ raw = 1;
+ /* This mess in case the read system call fails */
+
+ ed_setup(ep->ed,fd,reedit);
+ out = (genchar*)buff;
+#if SHOPT_MULTIBYTE
+ out = (genchar*)roundof((char*)out-(char*)0,sizeof(genchar));
+ ed_internal(buff,out);
+#endif /* SHOPT_MULTIBYTE */
+ if(!kstack)
+ {
+ kstack = (genchar*)malloc(CHARSIZE*MAXLINE);
+ kstack[0] = '\0';
+ }
+ drawbuff = out;
+#ifdef ESH_NFIRST
+ if (location.hist_command == -5) /* to be initialized */
+ {
+ kstack[0] = '\0'; /* also clear kstack... */
+ location.hist_command = hline;
+ location.hist_line = hloff;
+ }
+ if (location.hist_command <= hismin) /* don't start below minimum */
+ {
+ location.hist_command = hismin + 1;
+ location.hist_line = 0;
+ }
+ ep->in_mult = hloff; /* save pos in last command */
+#endif /* ESH_NFIRST */
+ i = sigsetjmp(env,0);
+ if (i !=0)
+ {
+ tty_cooked(ERRIO);
+ if (i == UEOF)
+ {
+ return(0); /* EOF */
+ }
+ return(-1); /* some other error */
+ }
+ out[reedit] = 0;
+ if(scend+plen > (MAXLINE-2))
+ scend = (MAXLINE-2)-plen;
+ ep->mark = 0;
+ cur = eol;
+ draw(ep,reedit?REFRESH:FIRST);
+ adjust = -1;
+ backslash = 0;
+ if (ep->CntrlO)
+ {
+#ifdef ESH_NFIRST
+ ed_ungetchar(ep->ed,cntl('N'));
+#else
+ location = hist_locate(sh.hist_ptr,location.hist_command,location.hist_line,1);
+ if (location.hist_command < histlines)
+ {
+ hline = location.hist_command;
+ hloff = location.hist_line;
+ hist_copy((char*)kstack,MAXLINE, hline,hloff);
+# if SHOPT_MULTIBYTE
+ ed_internal((char*)kstack,kstack);
+# endif /* SHOPT_MULTIBYTE */
+ ed_ungetchar(ep->ed,cntl('Y'));
+ }
+#endif /* ESH_NFIRST */
+ }
+ ep->CntrlO = 0;
+ while ((c = ed_getchar(ep->ed,0)) != (-1))
+ {
+ if (backslash)
+ {
+ backslash = 0;
+ if (c==usrerase||c==usrkill||(!print(c) &&
+ (c!='\r'&&c!='\n')))
+ {
+ /* accept a backslashed character */
+ cur--;
+ out[cur++] = c;
+ out[eol] = '\0';
+ draw(ep,APPEND);
+ continue;
+ }
+ }
+ if (c == usrkill)
+ {
+ c = KILLCHAR ;
+ }
+ else if (c == usrerase)
+ {
+ c = ERASECHAR ;
+ }
+ else if (c == usrlnext)
+ {
+ c = LNEXTCHAR ;
+ }
+ else if ((c == usreof)&&(eol == 0))
+ {
+ c = EOFCHAR;
+ }
+#ifdef ESH_KAPPEND
+ if (--killing <= 0) /* reset killing flag */
+ killing = 0;
+#endif
+ oadjust = count = adjust;
+ if(count<0)
+ count = 1;
+ adjust = -1;
+ i = cur;
+ switch(c)
+ {
+ case LNEXTCHAR:
+ c = ed_getchar(ep->ed,2);
+ goto do_default_processing;
+ case cntl('V'):
+ show_info(ep,fmtident(e_version));
+ continue;
+ case '\0':
+ ep->mark = i;
+ continue;
+ case cntl('X'):
+ xcommands(ep,count);
+ continue;
+ case EOFCHAR:
+ ed_flush(ep->ed);
+ tty_cooked(ERRIO);
+ return(0);
+#ifdef u370
+ case cntl('S') :
+ case cntl('Q') :
+ continue;
+#endif /* u370 */
+ case '\t':
+ if(cur>0 && ep->ed->sh->nextprompt)
+ {
+ if(ep->ed->e_tabcount==0)
+ {
+ ep->ed->e_tabcount=1;
+ ed_ungetchar(ep->ed,ESC);
+ goto do_escape;
+ }
+ else if(ep->ed->e_tabcount==1)
+ {
+ ed_ungetchar(ep->ed,'=');
+ goto do_escape;
+ }
+ ep->ed->e_tabcount = 0;
+ }
+ do_default_processing:
+ default:
+
+ if ((eol+1) >= (scend)) /* will not fit on line */
+ {
+ ed_ungetchar(ep->ed,c); /* save character for next line */
+ goto process;
+ }
+ for(i= ++eol; i>cur; i--)
+ out[i] = out[i-1];
+ backslash = (c == '\\');
+ out[cur++] = c;
+ draw(ep,APPEND);
+ continue;
+ case cntl('Y') :
+ {
+ c = genlen(kstack);
+ if ((c + eol) > scend)
+ {
+ beep();
+ continue;
+ }
+ ep->mark = i;
+ for(i=eol;i>=cur;i--)
+ out[c+i] = out[i];
+ kptr=kstack;
+ while (i = *kptr++)
+ out[cur++] = i;
+ draw(ep,UPDATE);
+ eol = genlen(out);
+ continue;
+ }
+ case '\n':
+ case '\r':
+ c = '\n';
+ goto process;
+
+ case DELETE: /* delete char 0x7f */
+ case '\b': /* backspace, ^h */
+ case ERASECHAR :
+ if (count > i)
+ count = i;
+#ifdef ESH_KAPPEND
+ kptr = &kstack[count]; /* move old contents here */
+ if (killing) /* prepend to killbuf */
+ {
+ c = genlen(kstack) + CHARSIZE; /* include '\0' */
+ while(c--) /* copy stuff */
+ kptr[c] = kstack[c];
+ }
+ else
+ *kptr = 0; /* this is end of data */
+ killing = 2; /* we are killing */
+ i -= count;
+ eol -= count;
+ genncpy(kstack,out+i,cur-i);
+#else
+ while ((count--)&&(i>0))
+ {
+ i--;
+ eol--;
+ }
+ genncpy(kstack,out+i,cur-i);
+ kstack[cur-i] = 0;
+#endif /* ESH_KAPPEND */
+ gencpy(out+i,out+cur);
+ ep->mark = i;
+ goto update;
+ case cntl('W') :
+#ifdef ESH_KAPPEND
+ ++killing; /* keep killing flag */
+#endif
+ if (ep->mark > eol )
+ ep->mark = eol;
+ if (ep->mark == i)
+ continue;
+ if (ep->mark > i)
+ {
+ adjust = ep->mark - i;
+ ed_ungetchar(ep->ed,cntl('D'));
+ continue;
+ }
+ adjust = i - ep->mark;
+ ed_ungetchar(ep->ed,usrerase);
+ continue;
+ case cntl('D') :
+ ep->mark = i;
+#ifdef ESH_KAPPEND
+ if (killing)
+ kptr = &kstack[genlen(kstack)]; /* append here */
+ else
+ kptr = kstack;
+ killing = 2; /* we are now killing */
+#else
+ kptr = kstack;
+#endif /* ESH_KAPPEND */
+ while ((count--)&&(eol>0)&&(i<eol))
+ {
+ *kptr++ = out[i];
+ eol--;
+ while(1)
+ {
+ if ((out[i] = out[(i+1)])==0)
+ break;
+ i++;
+ }
+ i = cur;
+ }
+ *kptr = '\0';
+ goto update;
+ case cntl('C') :
+ case cntl('F') :
+ {
+ int cntlC = (c==cntl('C'));
+ while (count-- && eol>i)
+ {
+ if (cntlC)
+ {
+ c = out[i];
+#if SHOPT_MULTIBYTE
+ if((c&~STRIP)==0 && islower(c))
+#else
+ if(islower(c))
+#endif /* SHOPT_MULTIBYTE */
+ {
+ c += 'A' - 'a';
+ out[i] = c;
+ }
+ }
+ i++;
+ }
+ goto update;
+ }
+ case cntl(']') :
+ c = ed_getchar(ep->ed,1);
+ if ((count == 0) || (count > eol))
+ {
+ beep();
+ continue;
+ }
+ if (out[i])
+ i++;
+ while (i < eol)
+ {
+ if (out[i] == c && --count==0)
+ goto update;
+ i++;
+ }
+ i = 0;
+ while (i < cur)
+ {
+ if (out[i] == c && --count==0)
+ break;
+ i++;
+ };
+
+update:
+ cur = i;
+ draw(ep,UPDATE);
+ continue;
+
+ case cntl('B') :
+ if (count > i)
+ count = i;
+ i -= count;
+ goto update;
+ case cntl('T') :
+ if ((sh_isoption(SH_EMACS))&& (eol!=i))
+ i++;
+ if (i >= 2)
+ {
+ c = out[i - 1];
+ out[i-1] = out[i-2];
+ out[i-2] = c;
+ }
+ else
+ {
+ if(sh_isoption(SH_EMACS))
+ i--;
+ beep();
+ continue;
+ }
+ goto update;
+ case cntl('A') :
+ i = 0;
+ goto update;
+ case cntl('E') :
+ i = eol;
+ goto update;
+ case cntl('U') :
+ adjust = 4*count;
+ continue;
+ case KILLCHAR :
+ cur = 0;
+ oadjust = -1;
+ case cntl('K') :
+ if(oadjust >= 0)
+ {
+#ifdef ESH_KAPPEND
+ killing = 2; /* set killing signal */
+#endif
+ ep->mark = count;
+ ed_ungetchar(ep->ed,cntl('W'));
+ continue;
+ }
+ i = cur;
+ eol = i;
+ ep->mark = i;
+#ifdef ESH_KAPPEND
+ if (killing) /* append to kill buffer */
+ gencpy(&kstack[genlen(kstack)], &out[i]);
+ else
+ gencpy(kstack,&out[i]);
+ killing = 2; /* set killing signal */
+#else
+ gencpy(kstack,&out[i]);
+#endif /* ESH_KAPPEND */
+ out[i] = 0;
+ draw(ep,UPDATE);
+ if (c == KILLCHAR)
+ {
+ if (ep->terminal == PAPER)
+ {
+ putchar(ep->ed,'\n');
+ putstring(ep,Prompt);
+ }
+ c = ed_getchar(ep->ed,0);
+ if (c != usrkill)
+ {
+ ed_ungetchar(ep->ed,c);
+ continue;
+ }
+ if (ep->terminal == PAPER)
+ ep->terminal = CRT;
+ else
+ {
+ ep->terminal = PAPER;
+ putchar(ep->ed,'\n');
+ putstring(ep,Prompt);
+ }
+ }
+ continue;
+ case cntl('L'):
+ ed_crlf(ep->ed);
+ draw(ep,REFRESH);
+ continue;
+ case cntl('[') :
+ do_escape:
+ adjust = escape(ep,out,oadjust);
+ continue;
+ case cntl('R') :
+ search(ep,out,count);
+ goto drawline;
+ case cntl('P') :
+ if (count <= hloff)
+ hloff -= count;
+ else
+ {
+ hline -= count - hloff;
+ hloff = 0;
+ }
+#ifdef ESH_NFIRST
+ if (hline <= hismin)
+#else
+ if (hline < hismin)
+#endif /* ESH_NFIRST */
+ {
+ hline = hismin+1;
+ beep();
+#ifndef ESH_NFIRST
+ continue;
+#endif
+ }
+ goto common;
+
+ case cntl('O') :
+ location.hist_command = hline;
+ location.hist_line = hloff;
+ ep->CntrlO = 1;
+ c = '\n';
+ goto process;
+ case cntl('N') :
+#ifdef ESH_NFIRST
+ hline = location.hist_command; /* start at saved position */
+ hloff = location.hist_line;
+#endif /* ESH_NFIRST */
+ location = hist_locate(sh.hist_ptr,hline,hloff,count);
+ if (location.hist_command > histlines)
+ {
+ beep();
+#ifdef ESH_NFIRST
+ location.hist_command = histlines;
+ location.hist_line = ep->in_mult;
+#else
+ continue;
+#endif /* ESH_NFIRST */
+ }
+ hline = location.hist_command;
+ hloff = location.hist_line;
+ common:
+#ifdef ESH_NFIRST
+ location.hist_command = hline; /* save current position */
+ location.hist_line = hloff;
+#endif
+ hist_copy((char*)out,MAXLINE, hline,hloff);
+#if SHOPT_MULTIBYTE
+ ed_internal((char*)(out),out);
+#endif /* SHOPT_MULTIBYTE */
+ drawline:
+ eol = genlen(out);
+ cur = eol;
+ draw(ep,UPDATE);
+ continue;
+ }
+
+ }
+
+process:
+
+ if (c == (-1))
+ {
+ lookahead = 0;
+ beep();
+ *out = '\0';
+ }
+ draw(ep,FINAL);
+ tty_cooked(ERRIO);
+ if(ed->e_nlist)
+ {
+ ed->e_nlist = 0;
+ stakset(ed->e_stkptr,ed->e_stkoff);
+ }
+ if(c == '\n')
+ {
+ out[eol++] = '\n';
+ out[eol] = '\0';
+ ed_crlf(ep->ed);
+ }
+#if SHOPT_MULTIBYTE
+ ed_external(out,buff);
+#endif /* SHOPT_MULTIBYTE */
+ i = strlen(buff);
+ if (i)
+ return(i);
+ return(-1);
+}
+
+static void show_info(Emacs_t *ep,const char *str)
+{
+ register genchar *out = drawbuff;
+ register int c;
+ genchar string[LBUF];
+ int sav_cur = cur;
+ /* save current line */
+ genncpy(string,out,sizeof(string)/sizeof(*string));
+ *out = 0;
+ cur = 0;
+#if SHOPT_MULTIBYTE
+ ed_internal(str,out);
+#else
+ gencpy(out,str);
+#endif /* SHOPT_MULTIBYTE */
+ draw(ep,UPDATE);
+ c = ed_getchar(ep->ed,0);
+ if(c!=' ')
+ ed_ungetchar(ep->ed,c);
+ /* restore line */
+ cur = sav_cur;
+ genncpy(out,string,sizeof(string)/sizeof(*string));
+ draw(ep,UPDATE);
+}
+
+static void putstring(Emacs_t* ep,register char *sp)
+{
+ register int c;
+ while (c= *sp++)
+ putchar(ep->ed,c);
+}
+
+
+static int escape(register Emacs_t* ep,register genchar *out,int count)
+{
+ register int i,value;
+ int digit,ch;
+ digit = 0;
+ value = 0;
+ while ((i=ed_getchar(ep->ed,0)),isdigit(i))
+ {
+ value *= 10;
+ value += (i - '0');
+ digit = 1;
+ }
+ if (digit)
+ {
+ ed_ungetchar(ep->ed,i) ;
+#ifdef ESH_KAPPEND
+ ++killing; /* don't modify killing signal */
+#endif
+ return(value);
+ }
+ value = count;
+ if(value<0)
+ value = 1;
+ switch(ch=i)
+ {
+ case cntl('V'):
+ show_info(ep,fmtident(e_version));
+ return(-1);
+ case ' ':
+ ep->mark = cur;
+ return(-1);
+
+#ifdef ESH_KAPPEND
+ case '+': /* M-+ = append next kill */
+ killing = 2;
+ return -1; /* no argument for next command */
+#endif
+
+ case 'p': /* M-p == ^W^Y (copy stack == kill & yank) */
+ ed_ungetchar(ep->ed,cntl('Y'));
+ ed_ungetchar(ep->ed,cntl('W'));
+#ifdef ESH_KAPPEND
+ killing = 0; /* start fresh */
+#endif
+ return(-1);
+
+ case 'l': /* M-l == lower-case */
+ case 'd':
+ case 'c':
+ case 'f':
+ {
+ i = cur;
+ while(value-- && i<eol)
+ {
+ while ((out[i])&&(!isword(i)))
+ i++;
+ while ((out[i])&&(isword(i)))
+ i++;
+ }
+ if(ch=='l')
+ {
+ value = i-cur;
+ while (value-- > 0)
+ {
+ i = out[cur];
+#if SHOPT_MULTIBYTE
+ if((i&~STRIP)==0 && isupper(i))
+#else
+ if(isupper(i))
+#endif /* SHOPT_MULTIBYTE */
+ {
+ i += 'a' - 'A';
+ out[cur] = i;
+ }
+ cur++;
+ }
+ draw(ep,UPDATE);
+ return(-1);
+ }
+
+ else if(ch=='f')
+ goto update;
+ else if(ch=='c')
+ {
+ ed_ungetchar(ep->ed,cntl('C'));
+ return(i-cur);
+ }
+ else
+ {
+ if (i-cur)
+ {
+ ed_ungetchar(ep->ed,cntl('D'));
+#ifdef ESH_KAPPEND
+ ++killing; /* keep killing signal */
+#endif
+ return(i-cur);
+ }
+ beep();
+ return(-1);
+ }
+ }
+
+
+ case 'b':
+ case DELETE :
+ case '\b':
+ case 'h':
+ {
+ i = cur;
+ while(value-- && i>0)
+ {
+ i--;
+ while ((i>0)&&(!isword(i)))
+ i--;
+ while ((i>0)&&(isword(i-1)))
+ i--;
+ }
+ if(ch=='b')
+ goto update;
+ else
+ {
+ ed_ungetchar(ep->ed,usrerase);
+#ifdef ESH_KAPPEND
+ ++killing;
+#endif
+ return(cur-i);
+ }
+ }
+
+ case '>':
+ ed_ungetchar(ep->ed,cntl('N'));
+#ifdef ESH_NFIRST
+ if (ep->in_mult)
+ {
+ location.hist_command = histlines;
+ location.hist_line = ep->in_mult - 1;
+ }
+ else
+ {
+ location.hist_command = histlines - 1;
+ location.hist_line = 0;
+ }
+#else
+ hline = histlines-1;
+ hloff = 0;
+#endif /* ESH_NFIRST */
+ return(0);
+
+ case '<':
+ ed_ungetchar(ep->ed,cntl('P'));
+ hloff = 0;
+#ifdef ESH_NFIRST
+ hline = hismin + 1;
+ return 0;
+#else
+ return(hline-hismin);
+#endif /* ESH_NFIRST */
+
+
+ case '#':
+ ed_ungetchar(ep->ed,'\n');
+ ed_ungetchar(ep->ed,(out[0]=='#')?cntl('D'):'#');
+ ed_ungetchar(ep->ed,cntl('A'));
+ return(-1);
+ case '_' :
+ case '.' :
+ {
+ genchar name[MAXLINE];
+ char buf[MAXLINE];
+ char *ptr;
+ ptr = hist_word(buf,MAXLINE,(count?count:-1));
+#if !KSHELL
+ if(ptr==0)
+ {
+ beep();
+ break;
+ }
+#endif /* KSHELL */
+ if ((eol - cur) >= sizeof(name))
+ {
+ beep();
+ return(-1);
+ }
+ ep->mark = cur;
+ gencpy(name,&out[cur]);
+ while(*ptr)
+ {
+ out[cur++] = *ptr++;
+ eol++;
+ }
+ gencpy(&out[cur],name);
+ draw(ep,UPDATE);
+ return(-1);
+ }
+#if KSHELL
+
+ /* file name expansion */
+ case cntl('[') : /* filename completion */
+ i = '\\';
+ case '*': /* filename expansion */
+ case '=': /* escape = - list all matching file names */
+ ep->mark = cur;
+ if(ed_expand(ep->ed,(char*)out,&cur,&eol,i,count) < 0)
+ {
+ if(ep->ed->e_tabcount==1)
+ {
+ ep->ed->e_tabcount=2;
+ ed_ungetchar(ep->ed,cntl('\t'));
+ return(-1);
+ }
+ beep();
+ }
+ else if(i=='=')
+ {
+ draw(ep,REFRESH);
+ if(count>0)
+ ep->ed->e_tabcount=0;
+ else
+ {
+ i=ed_getchar(ep->ed,0);
+ ed_ungetchar(ep->ed,i);
+ if(isdigit(i))
+ ed_ungetchar(ep->ed,ESC);
+ }
+ }
+ else
+ {
+ if(i=='\\' && cur>ep->mark && (out[cur-1]=='/' || out[cur-1]==' '))
+ ep->ed->e_tabcount=0;
+ draw(ep,UPDATE);
+ }
+ return(-1);
+
+ /* search back for character */
+ case cntl(']'): /* feature not in book */
+ {
+ int c = ed_getchar(ep->ed,1);
+ if ((value == 0) || (value > eol))
+ {
+ beep();
+ return(-1);
+ }
+ i = cur;
+ if (i > 0)
+ i--;
+ while (i >= 0)
+ {
+ if (out[i] == c && --value==0)
+ goto update;
+ i--;
+ }
+ i = eol;
+ while (i > cur)
+ {
+ if (out[i] == c && --value==0)
+ break;
+ i--;
+ };
+
+ }
+ update:
+ cur = i;
+ draw(ep,UPDATE);
+ return(-1);
+
+#ifdef _cmd_tput
+ case cntl('L'): /* clear screen */
+ sh_trap("tput clear", 0);
+ draw(ep,REFRESH);
+ return(-1);
+#endif
+ case '[': /* feature not in book */
+ switch(i=ed_getchar(ep->ed,1))
+ {
+ case 'A':
+ ed_ungetchar(ep->ed,cntl('P'));
+ return(-1);
+ case 'B':
+ ed_ungetchar(ep->ed,cntl('N'));
+ return(-1);
+ case 'C':
+ ed_ungetchar(ep->ed,cntl('F'));
+ return(-1);
+ case 'D':
+ ed_ungetchar(ep->ed,cntl('B'));
+ return(-1);
+ case 'H':
+ ed_ungetchar(ep->ed,cntl('A'));
+ return(-1);
+ case 'Y':
+ ed_ungetchar(ep->ed,cntl('E'));
+ return(-1);
+ default:
+ ed_ungetchar(ep->ed,i);
+ }
+ i = '_';
+
+ default:
+ /* look for user defined macro definitions */
+ if(ed_macro(ep->ed,i))
+# ifdef ESH_BETTER
+ return(count); /* pass argument to macro */
+# else
+ return(-1);
+# endif /* ESH_BETTER */
+#else
+ update:
+ cur = i;
+ draw(ep,UPDATE);
+ return(-1);
+
+ default:
+#endif /* KSHELL */
+ beep();
+ return(-1);
+ }
+}
+
+
+/*
+ * This routine process all commands starting with ^X
+ */
+
+static void xcommands(register Emacs_t *ep,int count)
+{
+ register int i = ed_getchar(ep->ed,0);
+ NOT_USED(count);
+ switch(i)
+ {
+ case cntl('X'): /* exchange dot and mark */
+ if (ep->mark > eol)
+ ep->mark = eol;
+ i = ep->mark;
+ ep->mark = cur;
+ cur = i;
+ draw(ep,UPDATE);
+ return;
+
+#if KSHELL
+# ifdef ESH_BETTER
+ case cntl('E'): /* invoke emacs on current command */
+ if(ed_fulledit(ep->ed)==-1)
+ beep();
+ else
+ {
+#if SHOPT_MULTIBYTE
+ ed_internal((char*)drawbuff,drawbuff);
+#endif /* SHOPT_MULTIBYTE */
+ ed_ungetchar(ep->ed,'\n');
+ }
+ return;
+
+# define itos(i) fmtbase((long)(i),0,0)/* want signed conversion */
+
+ case cntl('H'): /* ^X^H show history info */
+ {
+ char hbuf[MAXLINE];
+
+ strcpy(hbuf, "Current command ");
+ strcat(hbuf, itos(hline));
+ if (hloff)
+ {
+ strcat(hbuf, " (line ");
+ strcat(hbuf, itos(hloff+1));
+ strcat(hbuf, ")");
+ }
+ if ((hline != location.hist_command) ||
+ (hloff != location.hist_line))
+ {
+ strcat(hbuf, "; Previous command ");
+ strcat(hbuf, itos(location.hist_command));
+ if (location.hist_line)
+ {
+ strcat(hbuf, " (line ");
+ strcat(hbuf, itos(location.hist_line+1));
+ strcat(hbuf, ")");
+ }
+ }
+ show_info(ep,hbuf);
+ return;
+ }
+# if 0 /* debugging, modify as required */
+ case cntl('D'): /* ^X^D show debugging info */
+ {
+ char debugbuf[MAXLINE];
+
+ strcpy(debugbuf, "count=");
+ strcat(debugbuf, itos(count));
+ strcat(debugbuf, " eol=");
+ strcat(debugbuf, itos(eol));
+ strcat(debugbuf, " cur=");
+ strcat(debugbuf, itos(cur));
+ strcat(debugbuf, " crallowed=");
+ strcat(debugbuf, itos(crallowed));
+ strcat(debugbuf, " plen=");
+ strcat(debugbuf, itos(plen));
+ strcat(debugbuf, " w_size=");
+ strcat(debugbuf, itos(w_size));
+
+ show_info(ep,debugbuf);
+ return;
+ }
+# endif /* debugging code */
+# endif /* ESH_BETTER */
+#endif /* KSHELL */
+
+ default:
+ beep();
+ return;
+ }
+}
+
+static void search(Emacs_t* ep,genchar *out,int direction)
+{
+#ifndef ESH_NFIRST
+ Histloc_t location;
+#endif
+ register int i,sl;
+ genchar str_buff[LBUF];
+ register genchar *string = drawbuff;
+ /* save current line */
+ int sav_cur = cur;
+ genncpy(str_buff,string,sizeof(str_buff)/sizeof(*str_buff));
+ string[0] = '^';
+ string[1] = 'R';
+ string[2] = '\0';
+ sl = 2;
+ cur = sl;
+ draw(ep,UPDATE);
+ while ((i = ed_getchar(ep->ed,1))&&(i != '\r')&&(i != '\n'))
+ {
+ if (i==usrerase || i==DELETE || i=='\b' || i==ERASECHAR)
+ {
+ if (sl > 2)
+ {
+ string[--sl] = '\0';
+ cur = sl;
+ draw(ep,UPDATE);
+ }
+ else
+ beep();
+ continue;
+ }
+ if (i==usrkill)
+ {
+ beep();
+ goto restore;
+ }
+ if (i == '\\')
+ {
+ string[sl++] = '\\';
+ string[sl] = '\0';
+ cur = sl;
+ draw(ep,APPEND);
+ i = ed_getchar(ep->ed,1);
+ string[--sl] = '\0';
+ }
+ string[sl++] = i;
+ string[sl] = '\0';
+ cur = sl;
+ draw(ep,APPEND);
+ }
+ i = genlen(string);
+
+ if (direction < 1)
+ {
+ ep->prevdirection = -ep->prevdirection;
+ direction = 1;
+ }
+ else
+ direction = -1;
+ if (i != 2)
+ {
+#if SHOPT_MULTIBYTE
+ ed_external(string,(char*)string);
+#endif /* SHOPT_MULTIBYTE */
+ strncpy(lstring,((char*)string)+2,SEARCHSIZE);
+ ep->prevdirection = direction;
+ }
+ else
+ direction = ep->prevdirection ;
+ location = hist_find(sh.hist_ptr,(char*)lstring,hline,1,direction);
+ i = location.hist_command;
+ if(i>0)
+ {
+ hline = i;
+#ifdef ESH_NFIRST
+ hloff = location.hist_line = 0; /* display first line of multi line command */
+#else
+ hloff = location.hist_line;
+#endif /* ESH_NFIRST */
+ hist_copy((char*)out,MAXLINE, hline,hloff);
+#if SHOPT_MULTIBYTE
+ ed_internal((char*)out,out);
+#endif /* SHOPT_MULTIBYTE */
+ return;
+ }
+ if (i < 0)
+ {
+ beep();
+#ifdef ESH_NFIRST
+ location.hist_command = hline;
+ location.hist_line = hloff;
+#else
+ hloff = 0;
+ hline = histlines;
+#endif /* ESH_NFIRST */
+ }
+restore:
+ genncpy(string,str_buff,sizeof(str_buff)/sizeof(*str_buff));
+ cur = sav_cur;
+ return;
+}
+
+
+/* Adjust screen to agree with inputs: logical line and cursor */
+/* If 'first' assume screen is blank */
+/* Prompt is always kept on the screen */
+
+static void draw(register Emacs_t *ep,Draw_t option)
+{
+#define NORMAL ' '
+#define LOWER '<'
+#define BOTH '*'
+#define UPPER '>'
+
+ register genchar *sptr; /* Pointer within screen */
+ genchar nscreen[2*MAXLINE]; /* New entire screen */
+ genchar *ncursor; /* New cursor */
+ register genchar *nptr; /* Pointer to New screen */
+ char longline; /* Line overflow */
+ genchar *logcursor;
+ genchar *nscend; /* end of logical screen */
+ register int i;
+
+ nptr = nscreen;
+ sptr = drawbuff;
+ logcursor = sptr + cur;
+ longline = NORMAL;
+
+ if (option == FIRST || option == REFRESH)
+ {
+ ep->overflow = NORMAL;
+ ep->cursor = ep->screen;
+ ep->offset = 0;
+ ep->cr_ok = crallowed;
+ if (option == FIRST)
+ {
+ ep->scvalid = 1;
+ return;
+ }
+ *ep->cursor = '\0';
+ putstring(ep,Prompt); /* start with prompt */
+ }
+
+ /*********************
+ Do not update screen if pending characters
+ **********************/
+
+ if ((lookahead)&&(option != FINAL))
+ {
+
+ ep->scvalid = 0; /* Screen is out of date, APPEND will not work */
+
+ return;
+ }
+
+ /***************************************
+ If in append mode, cursor at end of line, screen up to date,
+ the previous character was a 'normal' character,
+ and the window has room for another character.
+ Then output the character and adjust the screen only.
+ *****************************************/
+
+
+ i = *(logcursor-1); /* last character inserted */
+
+ if ((option == APPEND)&&(ep->scvalid)&&(*logcursor == '\0')&&
+ print(i)&&((ep->cursor-ep->screen)<(w_size-1)))
+ {
+ putchar(ep->ed,i);
+ *ep->cursor++ = i;
+ *ep->cursor = '\0';
+ return;
+ }
+
+ /* copy the line */
+ ncursor = nptr + ed_virt_to_phys(ep->ed,sptr,nptr,cur,0,0);
+ nptr += genlen(nptr);
+ sptr += genlen(sptr);
+ nscend = nptr - 1;
+ if(sptr == logcursor)
+ ncursor = nptr;
+
+ /*********************
+ Does ncursor appear on the screen?
+ If not, adjust the screen offset so it does.
+ **********************/
+
+ i = ncursor - nscreen;
+
+ if ((ep->offset && i<=ep->offset)||(i >= (ep->offset+w_size)))
+ {
+ /* Center the cursor on the screen */
+ ep->offset = i - (w_size>>1);
+ if (--ep->offset < 0)
+ ep->offset = 0;
+ }
+
+ /*********************
+ Is the range of screen[0] thru screen[w_size] up-to-date
+ with nscreen[offset] thru nscreen[offset+w_size] ?
+ If not, update as need be.
+ ***********************/
+
+ nptr = &nscreen[ep->offset];
+ sptr = ep->screen;
+
+ i = w_size;
+
+ while (i-- > 0)
+ {
+
+ if (*nptr == '\0')
+ {
+ *(nptr + 1) = '\0';
+ *nptr = ' ';
+ }
+ if (*sptr == '\0')
+ {
+ *(sptr + 1) = '\0';
+ *sptr = ' ';
+ }
+ if (*nptr == *sptr)
+ {
+ nptr++;
+ sptr++;
+ continue;
+ }
+ setcursor(ep,sptr-ep->screen,*nptr);
+ *sptr++ = *nptr++;
+#if SHOPT_MULTIBYTE
+ while(*nptr==MARKER)
+ {
+ if(*sptr=='\0')
+ *(sptr + 1) = '\0';
+ *sptr++ = *nptr++;
+ i--;
+ ep->cursor++;
+ }
+#endif /* SHOPT_MULTIBYTE */
+ }
+
+ /******************
+
+ Screen overflow checks
+
+ ********************/
+
+ if (nscend >= &nscreen[ep->offset+w_size])
+ {
+ if (ep->offset > 0)
+ longline = BOTH;
+ else
+ longline = UPPER;
+ }
+ else
+ {
+ if (ep->offset > 0)
+ longline = LOWER;
+ }
+
+ /* Update screen overflow indicator if need be */
+
+ if (longline != ep->overflow)
+ {
+ setcursor(ep,w_size,longline);
+ ep->overflow = longline;
+ }
+ i = (ncursor-nscreen) - ep->offset;
+ setcursor(ep,i,0);
+ if(option==FINAL && ep->ed->e_multiline)
+ setcursor(ep,nscend-nscreen,0);
+ ep->scvalid = 1;
+ return;
+}
+
+/*
+ * put the cursor to the <newp> position within screen buffer
+ * if <c> is non-zero then output this character
+ * cursor is set to reflect the change
+ */
+
+static void setcursor(register Emacs_t *ep,register int newp,int c)
+{
+ register int oldp = ep->cursor - ep->screen;
+ newp = ed_setcursor(ep->ed, ep->screen, oldp, newp, 0);
+ if(c)
+ {
+ putchar(ep->ed,c);
+ newp++;
+ }
+ ep->cursor = ep->screen+newp;
+ return;
+}
+
+#if SHOPT_MULTIBYTE
+static int print(register int c)
+{
+ return((c&~STRIP)==0 && isprint(c));
+}
+
+static int _isword(register int c)
+{
+ return((c&~STRIP) || isalnum(c) || c=='_');
+}
+#endif /* SHOPT_MULTIBYTE */
diff --git a/usr/src/lib/libshell/common/edit/hexpand.c b/usr/src/lib/libshell/common/edit/hexpand.c
new file mode 100644
index 0000000000..e9dbac5bcb
--- /dev/null
+++ b/usr/src/lib/libshell/common/edit/hexpand.c
@@ -0,0 +1,736 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * bash style history expansion
+ *
+ * Author:
+ * Karsten Fleischer
+ * Omnium Software Engineering
+ * An der Luisenburg 7
+ * D-51379 Leverkusen
+ * Germany
+ *
+ * <K.Fleischer@omnium.de>
+ */
+
+
+#include "defs.h"
+#include "edit.h"
+
+#if ! SHOPT_HISTEXPAND
+
+NoN(hexpand)
+
+#else
+
+#include <ctype.h>
+
+static char *modifiers = "htrepqxs&";
+static int mod_flags[] = { 0, 0, 0, 0, HIST_PRINT, HIST_QUOTE, HIST_QUOTE|HIST_QUOTE_BR, 0, 0 };
+
+#define DONE() {flag |= HIST_ERROR; cp = 0; stakseek(0); goto done;}
+
+struct subst
+{
+ char *str[2]; /* [0] is "old", [1] is "new" string */
+};
+
+
+/*
+ * parse an /old/new/ string, delimiter expected as first char.
+ * if "old" not specified, keep sb->str[0]
+ * if "new" not specified, set sb->str[1] to empty string
+ * read up to third delimeter char, \n or \0, whichever comes first.
+ * return adress is one past the last valid char in s:
+ * - the address containing \n or \0 or
+ * - one char beyond the third delimiter
+ */
+
+static char *parse_subst(const char *s, struct subst *sb)
+{
+ char *cp,del;
+ int off,n = 0;
+
+ /* build the strings on the stack, mainly for '&' substition in "new" */
+ off = staktell();
+
+ /* init "new" with empty string */
+ if(sb->str[1])
+ free(sb->str[1]);
+ sb->str[1] = strdup("");
+
+ /* get delimiter */
+ del = *s;
+
+ cp = (char*) s + 1;
+
+ while(n < 2)
+ {
+ if(*cp == del || *cp == '\n' || *cp == '\0')
+ {
+ /* delimiter or EOL */
+ if(staktell() != off)
+ {
+ /* dupe string on stack and rewind stack */
+ stakputc('\0');
+ if(sb->str[n])
+ free(sb->str[n]);
+ sb->str[n] = strdup(stakptr(off));
+ stakseek(off);
+ }
+ n++;
+
+ /* if not delimiter, we've reached EOL. Get outta here. */
+ if(*cp != del)
+ break;
+ }
+ else if(*cp == '\\')
+ {
+ if(*(cp+1) == del) /* quote delimiter */
+ {
+ stakputc(del);
+ cp++;
+ }
+ else if(*(cp+1) == '&' && n == 1)
+ { /* quote '&' only in "new" */
+ stakputc('&');
+ cp++;
+ }
+ else
+ stakputc('\\');
+ }
+ else if(*cp == '&' && n == 1 && sb->str[0])
+ /* substitute '&' with "old" in "new" */
+ stakputs(sb->str[0]);
+ else
+ stakputc(*cp);
+ cp++;
+ }
+
+ /* rewind stack */
+ stakseek(off);
+
+ return cp;
+}
+
+/*
+ * history expansion main routine
+ */
+
+int hist_expand(const char *ln, char **xp)
+{
+ int off, /* stack offset */
+ q, /* quotation flags */
+ p, /* flag */
+ c, /* current char */
+ flag=0; /* HIST_* flags */
+ Sfoff_t n, /* history line number, counter, etc. */
+ i, /* counter */
+ w[2]; /* word range */
+ char *sp, /* stack pointer */
+ *cp, /* current char in ln */
+ *str, /* search string */
+ *evp, /* event/word designator string, for error msgs */
+ *cc=0, /* copy of current line up to cp; temp ptr */
+ hc[3], /* default histchars */
+ *qc="\'\"`"; /* quote characters */
+ Sfio_t *ref=0, /* line referenced by event designator */
+ *tmp=0, /* temporary line buffer */
+ *tmp2=0;/* temporary line buffer */
+ Histloc_t hl; /* history location */
+ static Namval_t *np = 0; /* histchars variable */
+ static struct subst sb = {0,0}; /* substition strings */
+ static Sfio_t *wm=0; /* word match from !?string? event designator */
+
+ if(!wm)
+ wm = sfopen(NULL, NULL, "swr");
+
+ hc[0] = '!';
+ hc[1] = '^';
+ hc[2] = 0;
+ if((np = nv_open("histchars",sh.var_tree,0)) && (cp = nv_getval(np)))
+ {
+ if(cp[0])
+ {
+ hc[0] = cp[0];
+ if(cp[1])
+ {
+ hc[1] = cp[1];
+ if(cp[2])
+ hc[2] = cp[2];
+ }
+ }
+ }
+
+ /* save shell stack */
+ if(off = staktell())
+ sp = stakfreeze(0);
+
+ cp = (char*)ln;
+
+ while(cp && *cp)
+ {
+ /* read until event/quick substitution/comment designator */
+ if((*cp != hc[0] && *cp != hc[1] && *cp != hc[2])
+ || (*cp == hc[1] && cp != ln))
+ {
+ if(*cp == '\\') /* skip escaped designators */
+ stakputc(*cp++);
+ else if(*cp == '\'') /* skip quoted designators */
+ {
+ do
+ stakputc(*cp);
+ while(*++cp && *cp != '\'');
+ }
+ stakputc(*cp++);
+ continue;
+ }
+
+ if(hc[2] && *cp == hc[2]) /* history comment designator, skip rest of line */
+ {
+ stakputc(*cp++);
+ stakputs(cp);
+ DONE();
+ }
+
+ n = -1;
+ str = 0;
+ flag &= HIST_EVENT; /* save event flag for returning later */
+ evp = cp;
+ ref = 0;
+
+ if(*cp == hc[1]) /* shortcut substitution */
+ {
+ flag |= HIST_QUICKSUBST;
+ goto getline;
+ }
+
+ if(*cp == hc[0] && *(cp+1) == hc[0]) /* refer to line -1 */
+ {
+ cp += 2;
+ goto getline;
+ }
+
+ switch(c = *++cp) {
+ case ' ':
+ case '\t':
+ case '\n':
+ case '\0':
+ case '=':
+ case '(':
+ stakputc(hc[0]);
+ continue;
+ case '#': /* the line up to current position */
+ flag |= HIST_HASH;
+ cp++;
+ n = staktell(); /* terminate string and dup */
+ stakputc('\0');
+ cc = strdup(stakptr(0));
+ stakseek(n); /* remove null byte again */
+ ref = sfopen(ref, cc, "s"); /* open as file */
+ n = 0; /* skip history file referencing */
+ break;
+ case '-': /* back reference by number */
+ if(!isdigit(*(cp+1)))
+ goto string_event;
+ cp++;
+ case '0': /* reference by number */
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ n = 0;
+ while(isdigit(*cp))
+ n = n * 10 + (*cp++) - '0';
+ if(c == '-')
+ n = -n;
+ break;
+ case '$':
+ n = -1;
+ case ':':
+ break;
+ case '?':
+ cp++;
+ flag |= HIST_QUESTION;
+ string_event:
+ default:
+ /* read until end of string or word designator/modifier */
+ str = cp;
+ while(*cp)
+ {
+ cp++;
+ if((!(flag&HIST_QUESTION) &&
+ (*cp == ':' || isspace(*cp)
+ || *cp == '^' || *cp == '$'
+ || *cp == '*' || *cp == '-'
+ || *cp == '%')
+ )
+ || ((flag&HIST_QUESTION) && (*cp == '?' || *cp == '\n')))
+ {
+ c = *cp;
+ *cp = '\0';
+ }
+ }
+ break;
+ }
+
+getline:
+ flag |= HIST_EVENT;
+ if(str) /* !string or !?string? event designator */
+ {
+
+ /* search history for string */
+ hl = hist_find(sh.hist_ptr, str,
+ sh.hist_ptr->histind,
+ flag&HIST_QUESTION, -1);
+ if((n = hl.hist_command) == -1)
+ n = 0; /* not found */
+ }
+ if(n)
+ {
+ if(n < 0) /* determine index for backref */
+ n = sh.hist_ptr->histind + n;
+ /* search and use history file if found */
+ if(n > 0 && hist_seek(sh.hist_ptr, n) != -1)
+ ref = sh.hist_ptr->histfp;
+
+ }
+ if(!ref)
+ {
+ /* string not found or command # out of range */
+ c = *cp;
+ *cp = '\0';
+ errormsg(SH_DICT, ERROR_ERROR, "%s: event not found", evp);
+ *cp = c;
+ DONE();
+ }
+
+ if(str) /* string search: restore orig. line */
+ {
+ if(flag&HIST_QUESTION)
+ *cp++ = c; /* skip second question mark */
+ else
+ *cp = c;
+ }
+
+ /* colon introduces either word designators or modifiers */
+ if(*(evp = cp) == ':')
+ cp++;
+
+ w[0] = 0; /* -1 means last word, -2 means match from !?string? */
+ w[1] = -1; /* -1 means last word, -2 means suppress last word */
+
+ if(flag & HIST_QUICKSUBST) /* shortcut substitution */
+ goto getsel;
+
+ n = 0;
+ while(n < 2)
+ {
+ switch(c = *cp++) {
+ case '^': /* first word */
+ if(n == 0)
+ {
+ w[0] = w[1] = 1;
+ goto skip;
+ }
+ else
+ goto skip2;
+ case '$': /* last word */
+ w[n] = -1;
+ goto skip;
+ case '%': /* match from !?string? event designator */
+ if(n == 0)
+ {
+ if(!str)
+ {
+ w[0] = 0;
+ w[1] = -1;
+ ref = wm;
+ }
+ else
+ {
+ w[0] = -2;
+ w[1] = sftell(ref) + hl.hist_char;
+ }
+ sfseek(wm, 0, SEEK_SET);
+ goto skip;
+ }
+ default:
+ skip2:
+ cp--;
+ n = 2;
+ break;
+ case '*': /* until last word */
+ if(n == 0)
+ w[0] = 1;
+ w[1] = -1;
+ skip:
+ flag |= HIST_WORDDSGN;
+ n = 2;
+ break;
+ case '-': /* until last word or specified index */
+ w[1] = -2;
+ flag |= HIST_WORDDSGN;
+ n = 1;
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': /* specify index */
+ if((*evp == ':') || w[1] == -2)
+ {
+ w[n] = c - '0';
+ while(isdigit(c=*cp++))
+ w[n] = w[n] * 10 + c - '0';
+ flag |= HIST_WORDDSGN;
+ if(n == 0)
+ w[1] = w[0];
+ n++;
+ }
+ else
+ n = 2;
+ cp--;
+ break;
+ }
+ }
+
+ if(w[0] != -2 && w[1] > 0 && w[0] > w[1])
+ {
+ c = *cp;
+ *cp = '\0';
+ errormsg(SH_DICT, ERROR_ERROR, "%s: bad word specifier", evp);
+ *cp = c;
+ DONE();
+ }
+
+ /* no valid word designator after colon, rewind */
+ if(!(flag & HIST_WORDDSGN) && (*evp == ':'))
+ cp = evp;
+
+getsel:
+ /* open temp buffer, let sfio do the (re)allocation */
+ tmp = sfopen(NULL, NULL, "swr");
+
+ /* push selected words into buffer, squash
+ whitespace into single blank or a newline */
+ n = i = q = 0;
+
+ while((c = sfgetc(ref)) > 0)
+ {
+ if(isspace(c))
+ {
+ flag |= (c == '\n' ? HIST_NEWLINE : 0);
+ continue;
+ }
+
+ if(n >= w[0] && ((w[0] != -2) ? (w[1] < 0 || n <= w[1]) : 1))
+ {
+ if(w[0] < 0)
+ sfseek(tmp, 0, SEEK_SET);
+ else
+ i = sftell(tmp);
+
+ if(i > 0)
+ sfputc(tmp, flag & HIST_NEWLINE ? '\n' : ' ');
+
+ flag &= ~HIST_NEWLINE;
+ p = 1;
+ }
+ else
+ p = 0;
+
+ do
+ {
+ cc = strchr(qc, c);
+ q ^= cc ? 1<<(int)(cc - qc) : 0;
+ if(p)
+ sfputc(tmp, c);
+ }
+ while((c = sfgetc(ref)) > 0 && (!isspace(c) || q));
+
+ if(w[0] == -2 && sftell(ref) > w[1])
+ break;
+
+ flag |= (c == '\n' ? HIST_NEWLINE : 0);
+ n++;
+ }
+ if(w[0] != -2 && w[1] >= 0 && w[1] >= n)
+ {
+ c = *cp;
+ *cp = '\0';
+ errormsg(SH_DICT, ERROR_ERROR, "%s: bad word specifier", evp);
+ *cp = c;
+ DONE();
+ }
+ else if(w[1] == -2) /* skip last word */
+ sfseek(tmp, i, SEEK_SET);
+
+ /* remove trailing newline */
+ if(sftell(tmp))
+ {
+ sfseek(tmp, -1, SEEK_CUR);
+ if(sfgetc(tmp) == '\n')
+ sfungetc(tmp, '\n');
+ }
+
+ sfputc(tmp, '\0');
+
+ if(str)
+ {
+ if(wm)
+ sfclose(wm);
+ wm = tmp;
+ }
+
+ if(cc && (flag&HIST_HASH))
+ {
+ /* close !# temp file */
+ sfclose(ref);
+ flag &= ~HIST_HASH;
+ free(cc);
+ cc = 0;
+ }
+
+ evp = cp;
+
+ /* selected line/words are now in buffer, now go for the modifiers */
+ while(*cp == ':' || (flag & HIST_QUICKSUBST))
+ {
+ if(flag & HIST_QUICKSUBST)
+ {
+ flag &= ~HIST_QUICKSUBST;
+ c = 's';
+ cp--;
+ }
+ else
+ c = *++cp;
+
+ sfseek(tmp, 0, SEEK_SET);
+ tmp2 = sfopen(tmp2, NULL, "swr");
+
+ if(c == 'g') /* global substitution */
+ {
+ flag |= HIST_GLOBALSUBST;
+ c = *++cp;
+ }
+
+ if(cc = strchr(modifiers, c))
+ flag |= mod_flags[cc - modifiers];
+ else
+ {
+ errormsg(SH_DICT, ERROR_ERROR, "%c: unrecognized history modifier", c);
+ DONE();
+ }
+
+ if(c == 'h' || c == 'r') /* head or base */
+ {
+ n = -1;
+ while((c = sfgetc(tmp)) > 0)
+ { /* remember position of / or . */
+ if((c == '/' && *cp == 'h') || (c == '.' && *cp == 'r'))
+ n = sftell(tmp2);
+ sfputc(tmp2, c);
+ }
+ if(n > 0)
+ { /* rewind to last / or . */
+ sfseek(tmp2, n, SEEK_SET);
+ /* end string there */
+ sfputc(tmp2, '\0');
+ }
+ }
+ else if(c == 't' || c == 'e') /* tail or suffix */
+ {
+ n = 0;
+ while((c = sfgetc(tmp)) > 0)
+ { /* remember position of / or . */
+ if((c == '/' && *cp == 't') || (c == '.' && *cp == 'e'))
+ n = sftell(tmp);
+ }
+ /* rewind to last / or . */
+ sfseek(tmp, n, SEEK_SET);
+ /* copy from there on */
+ while((c = sfgetc(tmp)) > 0)
+ sfputc(tmp2, c);
+ }
+ else if(c == 's' || c == '&')
+ {
+ cp++;
+
+ if(c == 's')
+ {
+ /* preset old with match from !?string? */
+ if(!sb.str[0] && wm)
+ sb.str[0] = strdup(sfsetbuf(wm, (Void_t*)1, 0));
+ cp = parse_subst(cp, &sb);
+ }
+
+ if(!sb.str[0] || !sb.str[1])
+ {
+ c = *cp;
+ *cp = '\0';
+ errormsg(SH_DICT, ERROR_ERROR,
+ "%s%s: no previous substitution",
+ (flag & HIST_QUICKSUBST) ? ":s" : "",
+ evp);
+ *cp = c;
+ DONE();
+ }
+
+ /* need pointer for strstr() */
+ str = sfsetbuf(tmp, (Void_t*)1, 0);
+
+ flag |= HIST_SUBSTITUTE;
+ while(flag & HIST_SUBSTITUTE)
+ {
+ /* find string */
+ if(cc = strstr(str, sb.str[0]))
+ { /* replace it */
+ c = *cc;
+ *cc = '\0';
+ sfputr(tmp2, str, -1);
+ sfputr(tmp2, sb.str[1], -1);
+ *cc = c;
+ str = cc + strlen(sb.str[0]);
+ }
+ else if(!sftell(tmp2))
+ { /* not successfull */
+ c = *cp;
+ *cp = '\0';
+ errormsg(SH_DICT, ERROR_ERROR,
+ "%s%s: substitution failed",
+ (flag & HIST_QUICKSUBST) ? ":s" : "",
+ evp);
+ *cp = c;
+ DONE();
+ }
+ /* loop if g modifier specified */
+ if(!cc || !(flag & HIST_GLOBALSUBST))
+ flag &= ~HIST_SUBSTITUTE;
+ }
+ /* output rest of line */
+ sfputr(tmp2, str, -1);
+ if(*cp)
+ cp--;
+ }
+
+ if(sftell(tmp2))
+ { /* if any substitions done, swap buffers */
+ if(wm != tmp)
+ sfclose(tmp);
+ tmp = tmp2;
+ tmp2 = 0;
+ }
+ cc = 0;
+ if(*cp)
+ cp++;
+ }
+
+ /* flush temporary buffer to stack */
+ if(tmp)
+ {
+ sfseek(tmp, 0, SEEK_SET);
+
+ if(flag & HIST_QUOTE)
+ stakputc('\'');
+
+ while((c = sfgetc(tmp)) > 0)
+ {
+ if(isspace(c))
+ {
+ flag = flag & ~HIST_NEWLINE;
+
+ /* squash white space to either a
+ blank or a newline */
+ do
+ flag |= (c == '\n' ? HIST_NEWLINE : 0);
+ while((c = sfgetc(tmp)) > 0 && isspace(c));
+
+ sfungetc(tmp, c);
+
+ c = (flag & HIST_NEWLINE) ? '\n' : ' ';
+
+ if(flag & HIST_QUOTE_BR)
+ {
+ stakputc('\'');
+ stakputc(c);
+ stakputc('\'');
+ }
+ else
+ stakputc(c);
+ }
+ else if((c == '\'') && (flag & HIST_QUOTE))
+ {
+ stakputc('\'');
+ stakputc('\\');
+ stakputc(c);
+ stakputc('\'');
+ }
+ else
+ stakputc(c);
+ }
+ if(flag & HIST_QUOTE)
+ stakputc('\'');
+ }
+ }
+
+ stakputc('\0');
+
+done:
+ if(cc && (flag&HIST_HASH))
+ {
+ /* close !# temp file */
+ sfclose(ref);
+ free(cc);
+ cc = 0;
+ }
+
+ /* error? */
+ if(staktell() && !(flag & HIST_ERROR))
+ *xp = strdup(stakfreeze(1));
+
+ /* restore shell stack */
+ if(off)
+ stakset(sp,off);
+ else
+ stakseek(0);
+
+ /* drop temporary files */
+
+ if(tmp && tmp != wm)
+ sfclose(tmp);
+ if(tmp2)
+ sfclose(tmp2);
+
+ return (flag & HIST_ERROR ? HIST_ERROR : flag & HIST_FLAG_RETURN_MASK);
+}
+
+#endif
diff --git a/usr/src/lib/libshell/common/edit/history.c b/usr/src/lib/libshell/common/edit/history.c
new file mode 100644
index 0000000000..f98140fc0f
--- /dev/null
+++ b/usr/src/lib/libshell/common/edit/history.c
@@ -0,0 +1,1109 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * History file manipulation routines
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+/*
+ * Each command in the history file starts on an even byte is null terminated.
+ * The first byte must contain the special character HIST_UNDO and the second
+ * byte is the version number. The sequence HIST_UNDO 0, following a command,
+ * nullifies the previous command. A six byte sequence starting with
+ * HIST_CMDNO is used to store the command number so that it is not necessary
+ * to read the file from beginning to end to get to the last block of
+ * commands. This format of this sequence is different in version 1
+ * then in version 0. Version 1 allows commands to use the full 8 bit
+ * character set. It can understand version 0 format files.
+ */
+
+
+#define HIST_MAX (sizeof(int)*HIST_BSIZE)
+#define HIST_BIG (0100000-1024) /* 1K less than maximum short */
+#define HIST_LINE 32 /* typical length for history line */
+#define HIST_MARKSZ 6
+#define HIST_RECENT 600
+#define HIST_UNDO 0201 /* invalidate previous command */
+#define HIST_CMDNO 0202 /* next 3 bytes give command number */
+#define HIST_BSIZE 4096 /* size of history file buffer */
+#define HIST_DFLT 512 /* default size of history list */
+
+#define _HIST_PRIVATE \
+ off_t histcnt; /* offset into history file */\
+ off_t histmarker; /* offset of last command marker */ \
+ int histflush; /* set if flushed outside of hflush() */\
+ int histmask; /* power of two mask for histcnt */ \
+ char histbuff[HIST_BSIZE+1]; /* history file buffer */ \
+ int histwfail; \
+ off_t histcmds[2]; /* offset for recent commands, must be last */
+
+#define hist_ind(hp,c) ((int)((c)&(hp)->histmask))
+
+#include <ast.h>
+#include <sfio.h>
+#include "FEATURE/time"
+#include <error.h>
+#include <ctype.h>
+#include <ls.h>
+#if KSHELL
+# include "defs.h"
+# include "variables.h"
+# include "path.h"
+# include "builtins.h"
+# include "io.h"
+#endif /* KSHELL */
+#include "history.h"
+
+#if !KSHELL
+# define new_of(type,x) ((type*)malloc((unsigned)sizeof(type)+(x)))
+# define NIL(type) ((type)0)
+# define path_relative(x) (x)
+# ifdef __STDC__
+# define nv_getval(s) getenv(#s)
+# else
+# define nv_getval(s) getenv("s")
+# endif /* __STDC__ */
+# define e_unknown "unknown"
+# define sh_translate(x) (x)
+ char login_sh = 0;
+ char hist_fname[] = "/.history";
+#endif /* KSHELL */
+
+#ifndef O_BINARY
+# define O_BINARY 0
+#endif /* O_BINARY */
+
+int _Hist = 0;
+static void hist_marker(char*,long);
+static void hist_trim(History_t*, int);
+static int hist_nearend(History_t*,Sfio_t*, off_t);
+static int hist_check(int);
+static int hist_clean(int);
+#ifdef SF_BUFCONST
+ static ssize_t hist_write(Sfio_t*, const void*, size_t, Sfdisc_t*);
+ static int hist_exceptf(Sfio_t*, int, void*, Sfdisc_t*);
+#else
+ static int hist_write(Sfio_t*, const void*, int, Sfdisc_t*);
+ static int hist_exceptf(Sfio_t*, int, Sfdisc_t*);
+#endif
+
+
+static int histinit;
+static mode_t histmode;
+static History_t *wasopen;
+static History_t *hist_ptr;
+
+#if SHOPT_ACCTFILE
+ static int acctfd;
+ static char *logname;
+# include <pwd.h>
+
+ int acctinit(void)
+ {
+ register char *cp, *acctfile;
+ Namval_t *np = nv_search("ACCTFILE",sh.var_tree,0);
+
+ if(!np || !(acctfile=nv_getval(np)))
+ return(0);
+ if(!(cp = getlogin()))
+ {
+ struct passwd *userinfo = getpwuid(getuid());
+ if(userinfo)
+ cp = userinfo->pw_name;
+ else
+ cp = "unknown";
+ }
+ logname = strdup(cp);
+
+ if((acctfd=sh_open(acctfile,
+ O_BINARY|O_WRONLY|O_APPEND|O_CREAT,S_IRUSR|S_IWUSR))>=0 &&
+ (unsigned)acctfd < 10)
+ {
+ int n;
+ if((n = fcntl(acctfd, F_DUPFD, 10)) >= 0)
+ {
+ close(acctfd);
+ acctfd = n;
+ }
+ }
+ if(acctfd < 0)
+ {
+ acctfd = 0;
+ return(0);
+ }
+ if(strmatch(acctfile,e_devfdNN))
+ {
+ char newfile[16];
+ sfsprintf(newfile,sizeof(newfile),"%.8s%d\0",e_devfdNN,acctfd);
+ nv_putval(np,newfile,NV_RDONLY);
+ }
+ else
+ fcntl(acctfd,F_SETFD,FD_CLOEXEC);
+ return(1);
+ }
+#endif /* SHOPT_ACCTFILE */
+
+static const unsigned char hist_stamp[2] = { HIST_UNDO, HIST_VERSION };
+static const Sfdisc_t hist_disc = { NULL, hist_write, NULL, hist_exceptf, NULL};
+
+static void hist_touch(void *handle)
+{
+ touch((char*)handle, (time_t)0, (time_t)0, 0);
+}
+
+/*
+ * open the history file
+ * if HISTNAME is not given and userid==0 then no history file.
+ * if login_sh and HISTFILE is longer than HIST_MAX bytes then it is
+ * cleaned up.
+ * hist_open() returns 1, if history file is open
+ */
+int sh_histinit(void)
+{
+ register int fd;
+ register History_t *hp;
+ register char *histname;
+ char *fname=0;
+ int histmask, maxlines, hist_start=0;
+ register char *cp;
+ register off_t hsize = 0;
+
+ if(sh.hist_ptr=hist_ptr)
+ return(1);
+ if(!(histname = nv_getval(HISTFILE)))
+ {
+ int offset = staktell();
+ if(cp=nv_getval(HOME))
+ stakputs(cp);
+ stakputs(hist_fname);
+ stakputc(0);
+ stakseek(offset);
+ histname = stakptr(offset);
+ }
+#ifdef future
+ if(hp=wasopen)
+ {
+ /* reuse history file if same name */
+ wasopen = 0;
+ sh.hist_ptr = hist_ptr = hp;
+ if(strcmp(histname,hp->histname)==0)
+ return(1);
+ else
+ hist_free();
+ }
+#endif
+retry:
+ cp = path_relative(histname);
+ if(!histinit)
+ histmode = S_IRUSR|S_IWUSR;
+ if((fd=open(cp,O_BINARY|O_APPEND|O_RDWR|O_CREAT,histmode))>=0)
+ {
+ hsize=lseek(fd,(off_t)0,SEEK_END);
+ }
+ if((unsigned)fd <=2)
+ {
+ int n;
+ if((n=fcntl(fd,F_DUPFD,10))>=0)
+ {
+ close(fd);
+ fd=n;
+ }
+ }
+ /* make sure that file has history file format */
+ if(hsize && hist_check(fd))
+ {
+ close(fd);
+ hsize = 0;
+ if(unlink(cp)>=0)
+ goto retry;
+ fd = -1;
+ }
+ if(fd < 0)
+ {
+#if KSHELL
+ /* don't allow root a history_file in /tmp */
+ if(sh.userid)
+#endif /* KSHELL */
+ {
+ if(!(fname = pathtmp(NIL(char*),0,0,NIL(int*))))
+ return(0);
+ fd = open(fname,O_BINARY|O_APPEND|O_CREAT|O_RDWR,S_IRUSR|S_IWUSR);
+ }
+ }
+ if(fd<0)
+ return(0);
+ /* set the file to close-on-exec */
+ fcntl(fd,F_SETFD,FD_CLOEXEC);
+ if(cp=nv_getval(HISTSIZE))
+ maxlines = (unsigned)strtol(cp, (char**)0, 10);
+ else
+ maxlines = HIST_DFLT;
+ for(histmask=16;histmask <= maxlines; histmask <<=1 );
+ if(!(hp=new_of(History_t,(--histmask)*sizeof(off_t))))
+ {
+ close(fd);
+ return(0);
+ }
+ sh.hist_ptr = hist_ptr = hp;
+ hp->histsize = maxlines;
+ hp->histmask = histmask;
+ hp->histfp= sfnew(NIL(Sfio_t*),hp->histbuff,HIST_BSIZE,fd,SF_READ|SF_WRITE|SF_APPENDWR|SF_SHARE);
+ memset((char*)hp->histcmds,0,sizeof(off_t)*(hp->histmask+1));
+ hp->histind = 1;
+ hp->histcmds[1] = 2;
+ hp->histcnt = 2;
+ hp->histname = strdup(histname);
+ hp->histdisc = hist_disc;
+ if(hsize==0)
+ {
+ /* put special characters at front of file */
+ sfwrite(hp->histfp,(char*)hist_stamp,2);
+ sfsync(hp->histfp);
+ }
+ /* initialize history list */
+ else
+ {
+ int first,last;
+ off_t mark,size = (HIST_MAX/4)+maxlines*HIST_LINE;
+ hp->histind = first = hist_nearend(hp,hp->histfp,hsize-size);
+ hist_eof(hp); /* this sets histind to last command */
+ if((hist_start = (last=(int)hp->histind)-maxlines) <=0)
+ hist_start = 1;
+ mark = hp->histmarker;
+ while(first > hist_start)
+ {
+ size += size;
+ first = hist_nearend(hp,hp->histfp,hsize-size);
+ hp->histind = first;
+ }
+ histinit = hist_start;
+ hist_eof(hp);
+ if(!histinit)
+ {
+ sfseek(hp->histfp,hp->histcnt=hsize,SEEK_SET);
+ hp->histind = last;
+ hp->histmarker = mark;
+ }
+ histinit = 0;
+ }
+ if(fname)
+ {
+ unlink(fname);
+ free((void*)fname);
+ }
+ if(hist_clean(fd) && hist_start>1 && hsize > HIST_MAX)
+ {
+#ifdef DEBUG
+ sfprintf(sfstderr,"%d: hist_trim hsize=%d\n",getpid(),hsize);
+ sfsync(sfstderr);
+#endif /* DEBUG */
+ hist_trim(hp,(int)hp->histind-maxlines);
+ }
+ sfdisc(hp->histfp,&hp->histdisc);
+#if KSHELL
+ (HISTCUR)->nvalue.lp = (&hp->histind);
+#endif /* KSHELL */
+ sh_timeradd(1000L*(HIST_RECENT-30), 1, hist_touch, (void*)hp->histname);
+#if SHOPT_ACCTFILE
+ if(sh_isstate(SH_INTERACTIVE))
+ acctinit();
+#endif /* SHOPT_ACCTFILE */
+ return(1);
+}
+
+/*
+ * close the history file and free the space
+ */
+
+void hist_close(register History_t *hp)
+{
+ sfclose(hp->histfp);
+ free((char*)hp);
+ hist_ptr = 0;
+ sh.hist_ptr = 0;
+#if SHOPT_ACCTFILE
+ if(acctfd)
+ {
+ close(acctfd);
+ acctfd = 0;
+ }
+#endif /* SHOPT_ACCTFILE */
+}
+
+/*
+ * check history file format to see if it begins with special byte
+ */
+static int hist_check(register int fd)
+{
+ unsigned char magic[2];
+ lseek(fd,(off_t)0,SEEK_SET);
+ if((read(fd,(char*)magic,2)!=2) || (magic[0]!=HIST_UNDO))
+ return(1);
+ return(0);
+}
+
+/*
+ * clean out history file OK if not modified in HIST_RECENT seconds
+ */
+static int hist_clean(int fd)
+{
+ struct stat statb;
+ return(fstat(fd,&statb)>=0 && (time((time_t*)0)-statb.st_mtime) >= HIST_RECENT);
+}
+
+/*
+ * Copy the last <n> commands to a new file and make this the history file
+ */
+
+static void hist_trim(History_t *hp, int n)
+{
+ register char *cp;
+ register int incmd=1, c=0;
+ register History_t *hist_new, *hist_old = hp;
+ char *buff, *endbuff, *tmpname=0;
+ off_t oldp,newp;
+ struct stat statb;
+ unlink(hist_old->histname);
+ if(access(hist_old->histname,F_OK) >= 0)
+ {
+ /* The unlink can fail on windows 95 */
+ int fd;
+ char *last, *name=hist_old->histname;
+ close(sffileno(hist_old->histfp));
+ tmpname = (char*)malloc(strlen(name)+14);
+ if(last = strrchr(name,'/'))
+ {
+ *last = 0;
+ pathtmp(tmpname,name,"hist",NIL(int*));
+ *last = '/';
+ }
+ else
+ pathtmp(tmpname,".","hist",NIL(int*));
+ if(rename(name,tmpname) < 0)
+ tmpname = name;
+ fd = open(tmpname,O_RDONLY);
+ sfsetfd(hist_old->histfp,fd);
+ if(tmpname==name)
+ tmpname = 0;
+ }
+ hp = hist_ptr = 0;
+ if(fstat(sffileno(hist_old->histfp),&statb)>=0)
+ {
+ histinit = 1;
+ histmode = statb.st_mode;
+ }
+ if(!sh_histinit())
+ {
+ /* use the old history file */
+ hist_ptr = hist_old;
+ return;
+ }
+ hist_new = hist_ptr;
+ hist_ptr = hist_old;
+ if(--n < 0)
+ n = 0;
+ newp = hist_seek(hist_old,++n);
+ while(1)
+ {
+ if(!incmd)
+ {
+ c = hist_ind(hist_new,++hist_new->histind);
+ hist_new->histcmds[c] = hist_new->histcnt;
+ if(hist_new->histcnt > hist_new->histmarker+HIST_BSIZE/2)
+ {
+ char locbuff[HIST_MARKSZ];
+ hist_marker(locbuff,hist_new->histind);
+ sfwrite(hist_new->histfp,locbuff,HIST_MARKSZ);
+ hist_new->histcnt += HIST_MARKSZ;
+ hist_new->histmarker = hist_new->histcmds[hist_ind(hist_new,c)] = hist_new->histcnt;
+ }
+ oldp = newp;
+ newp = hist_seek(hist_old,++n);
+ if(newp <=oldp)
+ break;
+ }
+ if(!(buff=(char*)sfreserve(hist_old->histfp,SF_UNBOUND,0)))
+ break;
+ *(endbuff=(cp=buff)+sfvalue(hist_old->histfp)) = 0;
+ /* copy to null byte */
+ incmd = 0;
+ while(*cp++);
+ if(cp > endbuff)
+ incmd = 1;
+ else if(*cp==0)
+ cp++;
+ if(cp > endbuff)
+ cp = endbuff;
+ c = cp-buff;
+ hist_new->histcnt += c;
+ sfwrite(hist_new->histfp,buff,c);
+ }
+ hist_ptr = hist_new;
+ hist_cancel(hist_ptr);
+ sfclose(hist_old->histfp);
+ if(tmpname)
+ {
+ unlink(tmpname);
+ free(tmpname);
+ }
+ free((char*)hist_old);
+}
+
+/*
+ * position history file at size and find next command number
+ */
+static int hist_nearend(History_t *hp, Sfio_t *iop, register off_t size)
+{
+ register unsigned char *cp, *endbuff;
+ register int n, incmd=1;
+ unsigned char *buff, marker[4];
+ if(size <= 2L || sfseek(iop,size,SEEK_SET)<0)
+ goto begin;
+ /* skip to marker command and return the number */
+ /* numbering commands occur after a null and begin with HIST_CMDNO */
+ while(cp=buff=(unsigned char*)sfreserve(iop,SF_UNBOUND,SF_LOCKR))
+ {
+ n = sfvalue(iop);
+ *(endbuff=cp+n) = 0;
+ while(1)
+ {
+ /* check for marker */
+ if(!incmd && *cp++==HIST_CMDNO && *cp==0)
+ {
+ n = cp+1 - buff;
+ incmd = -1;
+ break;
+ }
+ incmd = 0;
+ while(*cp++);
+ if(cp>endbuff)
+ {
+ incmd = 1;
+ break;
+ }
+ if(*cp==0 && ++cp>endbuff)
+ break;
+ }
+ size += n;
+ sfread(iop,(char*)buff,n);
+ if(incmd < 0)
+ {
+ if((n=sfread(iop,(char*)marker,4))==4)
+ {
+ n = (marker[0]<<16)|(marker[1]<<8)|marker[2];
+ if(n < size/2)
+ {
+ hp->histmarker = hp->histcnt = size+4;
+ return(n);
+ }
+ n=4;
+ }
+ if(n >0)
+ size += n;
+ incmd = 0;
+ }
+ }
+begin:
+ sfseek(iop,(off_t)2,SEEK_SET);
+ hp->histmarker = hp->histcnt = 2L;
+ return(1);
+}
+
+/*
+ * This routine reads the history file from the present position
+ * to the end-of-file and puts the information in the in-core
+ * history table
+ * Note that HIST_CMDNO is only recognized at the beginning of a command
+ * and that HIST_UNDO as the first character of a command is skipped
+ * unless it is followed by 0. If followed by 0 then it cancels
+ * the previous command.
+ */
+
+void hist_eof(register History_t *hp)
+{
+ register char *cp,*first,*endbuff;
+ register int incmd = 0;
+ register off_t count = hp->histcnt;
+ int n,skip=0;
+ sfseek(hp->histfp,count,SEEK_SET);
+ while(cp=(char*)sfreserve(hp->histfp,SF_UNBOUND,0))
+ {
+ n = sfvalue(hp->histfp);
+ *(endbuff = cp+n) = 0;
+ first = cp += skip;
+ while(1)
+ {
+ while(!incmd)
+ {
+ if(cp>first)
+ {
+ count += (cp-first);
+ n = hist_ind(hp, ++hp->histind);
+#ifdef future
+ if(count==hp->histcmds[n])
+ {
+ sfprintf(sfstderr,"count match n=%d\n",n);
+ if(histinit)
+ {
+ histinit = 0;
+ return;
+ }
+ }
+ else if(n>=histinit)
+#endif
+ hp->histcmds[n] = count;
+ first = cp;
+ }
+ switch(*((unsigned char*)(cp++)))
+ {
+ case HIST_CMDNO:
+ if(*cp==0)
+ {
+ hp->histmarker=count+2;
+ cp += (HIST_MARKSZ-1);
+ hp->histind--;
+#ifdef future
+ if(cp <= endbuff)
+ {
+ unsigned char *marker = (unsigned char*)(cp-4);
+ int n = ((marker[0]<<16)
+|(marker[1]<<8)|marker[2]);
+ if((n<count/2) && n != (hp->histind+1))
+ errormsg(SH_DICT,2,"index=%d marker=%d", hp->histind, n);
+ }
+#endif
+ }
+ break;
+ case HIST_UNDO:
+ if(*cp==0)
+ {
+ cp+=1;
+ hp->histind-=2;
+ }
+ break;
+ default:
+ cp--;
+ incmd = 1;
+ }
+ if(cp > endbuff)
+ {
+ cp++;
+ goto refill;
+ }
+ }
+ first = cp;
+ while(*cp++);
+ if(cp > endbuff)
+ break;
+ incmd = 0;
+ while(*cp==0)
+ {
+ if(++cp > endbuff)
+ goto refill;
+ }
+ }
+ refill:
+ count += (--cp-first);
+ skip = (cp-endbuff);
+ if(!incmd && !skip)
+ hp->histcmds[hist_ind(hp,++hp->histind)] = count;
+ }
+ hp->histcnt = count;
+}
+
+/*
+ * This routine will cause the previous command to be cancelled
+ */
+
+void hist_cancel(register History_t *hp)
+{
+ register int c;
+ if(!hp)
+ return;
+ sfputc(hp->histfp,HIST_UNDO);
+ sfputc(hp->histfp,0);
+ sfsync(hp->histfp);
+ hp->histcnt += 2;
+ c = hist_ind(hp,--hp->histind);
+ hp->histcmds[c] = hp->histcnt;
+}
+
+/*
+ * flush the current history command
+ */
+
+void hist_flush(register History_t *hp)
+{
+ register char *buff;
+ if(hp)
+ {
+ if(buff=(char*)sfreserve(hp->histfp,0,SF_LOCKR))
+ {
+ hp->histflush = sfvalue(hp->histfp)+1;
+ sfwrite(hp->histfp,buff,0);
+ }
+ else
+ hp->histflush=0;
+ if(sfsync(hp->histfp)<0)
+ {
+ hist_close(hp);
+ if(!sh_histinit())
+ sh_offoption(SH_HISTORY);
+ }
+ hp->histflush = 0;
+ }
+}
+
+/*
+ * This is the write discipline for the history file
+ * When called from hist_flush(), trailing newlines are deleted and
+ * a zero byte. Line sequencing is added as required
+ */
+
+#ifdef SF_BUFCONST
+static ssize_t hist_write(Sfio_t *iop,const void *buff,register size_t insize,Sfdisc_t* handle)
+#else
+static int hist_write(Sfio_t *iop,const void *buff,register int insize,Sfdisc_t* handle)
+#endif
+{
+ register History_t *hp = (History_t*)handle;
+ register char *bufptr = ((char*)buff)+insize;
+ register int c,size = insize;
+ register off_t cur;
+ int saved=0;
+ char saveptr[HIST_MARKSZ];
+ if(!hp->histflush)
+ return(write(sffileno(iop),(char*)buff,size));
+ if((cur = lseek(sffileno(iop),(off_t)0,SEEK_END)) <0)
+ {
+ errormsg(SH_DICT,2,"hist_flush: EOF seek failed errno=%d",errno);
+ return(-1);
+ }
+ hp->histcnt = cur;
+ /* remove whitespace from end of commands */
+ while(--bufptr >= (char*)buff)
+ {
+ c= *bufptr;
+ if(!isspace(c))
+ {
+ if(c=='\\' && *(bufptr+1)!='\n')
+ bufptr++;
+ break;
+ }
+ }
+ /* don't count empty lines */
+ if(++bufptr <= (char*)buff)
+ return(insize);
+ *bufptr++ = '\n';
+ *bufptr++ = 0;
+ size = bufptr - (char*)buff;
+#if SHOPT_ACCTFILE
+ if(acctfd)
+ {
+ int timechars, offset;
+ offset = staktell();
+ stakputs(buff);
+ stakseek(staktell() - 1);
+ timechars = sfprintf(staksp, "\t%s\t%x\n",logname,time(NIL(long *)));
+ lseek(acctfd, (off_t)0, SEEK_END);
+ write(acctfd, stakptr(offset), size - 2 + timechars);
+ stakseek(offset);
+
+ }
+#endif /* SHOPT_ACCTFILE */
+ if(size&01)
+ {
+ size++;
+ *bufptr++ = 0;
+ }
+ hp->histcnt += size;
+ c = hist_ind(hp,++hp->histind);
+ hp->histcmds[c] = hp->histcnt;
+ if(hp->histflush>HIST_MARKSZ && hp->histcnt > hp->histmarker+HIST_BSIZE/2)
+ {
+ memcpy((void*)saveptr,(void*)bufptr,HIST_MARKSZ);
+ saved=1;
+ hp->histcnt += HIST_MARKSZ;
+ hist_marker(bufptr,hp->histind);
+ hp->histmarker = hp->histcmds[hist_ind(hp,c)] = hp->histcnt;
+ size += HIST_MARKSZ;
+ }
+ errno = 0;
+ size = write(sffileno(iop),(char*)buff,size);
+ if(saved)
+ memcpy((void*)bufptr,(void*)saveptr,HIST_MARKSZ);
+ if(size>=0)
+ {
+ hp->histwfail = 0;
+ return(insize);
+ }
+ return(-1);
+}
+
+/*
+ * Put history sequence number <n> into buffer <buff>
+ * The buffer must be large enough to hold HIST_MARKSZ chars
+ */
+
+static void hist_marker(register char *buff,register long cmdno)
+{
+ *buff++ = HIST_CMDNO;
+ *buff++ = 0;
+ *buff++ = (cmdno>>16);
+ *buff++ = (cmdno>>8);
+ *buff++ = cmdno;
+ *buff++ = 0;
+}
+
+/*
+ * return byte offset in history file for command <n>
+ */
+off_t hist_tell(register History_t *hp, int n)
+{
+ return(hp->histcmds[hist_ind(hp,n)]);
+}
+
+/*
+ * seek to the position of command <n>
+ */
+off_t hist_seek(register History_t *hp, int n)
+{
+ return(sfseek(hp->histfp,hp->histcmds[hist_ind(hp,n)],SEEK_SET));
+}
+
+/*
+ * write the command starting at offset <offset> onto file <outfile>.
+ * if character <last> appears before newline it is deleted
+ * each new-line character is replaced with string <nl>.
+ */
+
+void hist_list(register History_t *hp,Sfio_t *outfile, off_t offset,int last, char *nl)
+{
+ register int oldc=0;
+ register int c;
+ if(offset<0 || !hp)
+ {
+ sfputr(outfile,sh_translate(e_unknown),'\n');
+ return;
+ }
+ sfseek(hp->histfp,offset,SEEK_SET);
+ while((c = sfgetc(hp->histfp)) != EOF)
+ {
+ if(c && oldc=='\n')
+ sfputr(outfile,nl,-1);
+ else if(last && (c==0 || (c=='\n' && oldc==last)))
+ return;
+ else if(oldc)
+ sfputc(outfile,oldc);
+ oldc = c;
+ if(c==0)
+ return;
+ }
+ return;
+}
+
+/*
+ * find index for last line with given string
+ * If flag==0 then line must begin with string
+ * direction < 1 for backwards search
+*/
+
+Histloc_t hist_find(register History_t*hp,char *string,register int index1,int flag,int direction)
+{
+ register int index2;
+ off_t offset;
+ int *coffset=0;
+ Histloc_t location;
+ location.hist_command = -1;
+ location.hist_char = 0;
+ location.hist_line = 0;
+ if(!hp)
+ return(location);
+ /* leading ^ means beginning of line unless escaped */
+ if(flag)
+ {
+ index2 = *string;
+ if(index2=='\\')
+ string++;
+ else if(index2=='^')
+ {
+ flag=0;
+ string++;
+ }
+ }
+ if(flag)
+ coffset = &location.hist_char;
+ index2 = (int)hp->histind;
+ if(direction<0)
+ {
+ index2 -= hp->histsize;
+ if(index2<1)
+ index2 = 1;
+ if(index1 <= index2)
+ return(location);
+ }
+ else if(index1 >= index2)
+ return(location);
+ while(index1!=index2)
+ {
+ direction>0?++index1:--index1;
+ offset = hist_tell(hp,index1);
+ if((location.hist_line=hist_match(hp,offset,string,coffset))>=0)
+ {
+ location.hist_command = index1;
+ return(location);
+ }
+#if KSHELL
+ /* allow a search to be aborted */
+ if(sh.trapnote&SH_SIGSET)
+ break;
+#endif /* KSHELL */
+ }
+ return(location);
+}
+
+/*
+ * search for <string> in history file starting at location <offset>
+ * If coffset==0 then line must begin with string
+ * returns the line number of the match if successful, otherwise -1
+ */
+
+int hist_match(register History_t *hp,off_t offset,char *string,int *coffset)
+{
+ register unsigned char *first, *cp;
+ register int m,n,c=1,line=0;
+#if SHOPT_MULTIBYTE
+ mbinit();
+#endif /* SHOPT_MULTIBYTE */
+ sfseek(hp->histfp,offset,SEEK_SET);
+ if(!(cp = first = (unsigned char*)sfgetr(hp->histfp,0,0)))
+ return(-1);
+ m = sfvalue(hp->histfp);
+ n = strlen(string);
+ while(m > n)
+ {
+ if(*cp==*string && memcmp(cp,string,n)==0)
+ {
+ if(coffset)
+ *coffset = (cp-first);
+ return(line);
+ }
+ if(!coffset)
+ break;
+ if(*cp=='\n')
+ line++;
+#if SHOPT_MULTIBYTE
+ if((c=mbsize(cp)) < 0)
+ c = 1;
+#endif /* SHOPT_MULTIBYTE */
+ cp += c;
+ m -= c;
+ }
+ return(-1);
+}
+
+
+#if SHOPT_ESH || SHOPT_VSH
+/*
+ * copy command <command> from history file to s1
+ * at most <size> characters copied
+ * if s1==0 the number of lines for the command is returned
+ * line=linenumber for emacs copy and only this line of command will be copied
+ * line < 0 for full command copy
+ * -1 returned if there is no history file
+ */
+
+int hist_copy(char *s1,int size,int command,int line)
+{
+ register int c;
+ register History_t *hp = sh_getinterp()->hist_ptr;
+ register int count = 0;
+ register char *s1max = s1+size;
+ if(!hp)
+ return(-1);
+ hist_seek(hp,command);
+ while ((c = sfgetc(hp->histfp)) && c!=EOF)
+ {
+ if(c=='\n')
+ {
+ if(count++ ==line)
+ break;
+ else if(line >= 0)
+ continue;
+ }
+ if(s1 && (line<0 || line==count))
+ {
+ if(s1 >= s1max)
+ {
+ *--s1 = 0;
+ break;
+ }
+ *s1++ = c;
+ }
+
+ }
+ sfseek(hp->histfp,(off_t)0,SEEK_END);
+ if(s1==0)
+ return(count);
+ if(count && (c= *(s1-1)) == '\n')
+ s1--;
+ *s1 = '\0';
+ return(count);
+}
+
+/*
+ * return word number <word> from command number <command>
+ */
+
+char *hist_word(char *string,int size,int word)
+{
+ register int c;
+ register char *s1 = string;
+ register unsigned char *cp = (unsigned char*)s1;
+ register int flag = 0;
+ History_t *hp = hist_ptr;
+ if(!hp)
+#if KSHELL
+ {
+ strncpy(string,sh.lastarg,size);
+ return(string);
+ }
+#else
+ return(NIL(char*));
+#endif /* KSHELL */
+ hist_copy(string,size,(int)hp->histind-1,-1);
+ for(;c = *cp;cp++)
+ {
+ c = isspace(c);
+ if(c && flag)
+ {
+ *cp = 0;
+ if(--word==0)
+ break;
+ flag = 0;
+ }
+ else if(c==0 && flag==0)
+ {
+ s1 = (char*)cp;
+ flag++;
+ }
+ }
+ *cp = 0;
+ if(s1 != string)
+ strcpy(string,s1);
+ return(string);
+}
+
+#endif /* SHOPT_ESH */
+
+#if SHOPT_ESH
+/*
+ * given the current command and line number,
+ * and number of lines back or foward,
+ * compute the new command and line number.
+ */
+
+Histloc_t hist_locate(History_t *hp,register int command,register int line,int lines)
+{
+ Histloc_t next;
+ line += lines;
+ if(!hp)
+ {
+ command = -1;
+ goto done;
+ }
+ if(lines > 0)
+ {
+ register int count;
+ while(command <= hp->histind)
+ {
+ count = hist_copy(NIL(char*),0, command,-1);
+ if(count > line)
+ goto done;
+ line -= count;
+ command++;
+ }
+ }
+ else
+ {
+ register int least = (int)hp->histind-hp->histsize;
+ while(1)
+ {
+ if(line >=0)
+ goto done;
+ if(--command < least)
+ break;
+ line += hist_copy(NIL(char*),0, command,-1);
+ }
+ command = -1;
+ }
+done:
+ next.hist_line = line;
+ next.hist_command = command;
+ return(next);
+}
+#endif /* SHOPT_ESH */
+
+
+/*
+ * Handle history file exceptions
+ */
+#ifdef SF_BUFCONST
+static int hist_exceptf(Sfio_t* fp, int type, void *data, Sfdisc_t *handle)
+#else
+static int hist_exceptf(Sfio_t* fp, int type, Sfdisc_t *handle)
+#endif
+{
+ register int newfd,oldfd;
+ History_t *hp = (History_t*)handle;
+ if(type==SF_WRITE)
+ {
+ if(errno==ENOSPC || hp->histwfail++ >= 10)
+ return(0);
+ /* write failure could be NFS problem, try to re-open */
+ close(oldfd=sffileno(fp));
+ if((newfd=open(hp->histname,O_BINARY|O_APPEND|O_CREAT|O_RDWR,S_IRUSR|S_IWUSR)) >= 0)
+ {
+ if(fcntl(newfd, F_DUPFD, oldfd) !=oldfd)
+ return(-1);
+ fcntl(oldfd,F_SETFD,FD_CLOEXEC);
+ close(newfd);
+ if(lseek(oldfd,(off_t)0,SEEK_END) < hp->histcnt)
+ {
+ register int index = hp->histind;
+ lseek(oldfd,(off_t)2,SEEK_SET);
+ hp->histcnt = 2;
+ hp->histind = 1;
+ hp->histcmds[1] = 2;
+ hist_eof(hp);
+ hp->histmarker = hp->histcnt;
+ hp->histind = index;
+ }
+ return(1);
+ }
+ errormsg(SH_DICT,2,"History file write error-%d %s: file unrecoverable",errno,hp->histname);
+ return(-1);
+ }
+ return(0);
+}
diff --git a/usr/src/lib/libshell/common/edit/vi.c b/usr/src/lib/libshell/common/edit/vi.c
new file mode 100644
index 0000000000..5d6fa8e56f
--- /dev/null
+++ b/usr/src/lib/libshell/common/edit/vi.c
@@ -0,0 +1,2635 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/* Adapted for ksh by David Korn */
+/*+ VI.C P.D. Sullivan
+ *
+ * One line editor for the shell based on the vi editor.
+ *
+ * Questions to:
+ * P.D. Sullivan
+ * cbosgd!pds
+-*/
+
+
+#if KSHELL
+# include "defs.h"
+#else
+# include <ast.h>
+# include "FEATURE/options"
+#endif /* KSHELL */
+#include <ctype.h>
+#include "io.h"
+
+#include "history.h"
+#include "edit.h"
+#include "terminal.h"
+#include "FEATURE/time"
+
+#if SHOPT_OLDTERMIO
+# undef ECHOCTL
+# define echoctl (vp->ed->e_echoctl)
+#else
+# ifdef ECHOCTL
+# define echoctl ECHOCTL
+# else
+# define echoctl 0
+# endif /* ECHOCTL */
+#endif /*SHOPT_OLDTERMIO */
+
+#ifndef FIORDCHK
+# define NTICKS 5 /* number of ticks for typeahead */
+#endif /* FIORDCHK */
+
+#define MAXCHAR MAXLINE-2 /* max char per line */
+
+#if SHOPT_MULTIBYTE
+# include "lexstates.h"
+# define gencpy(a,b) ed_gencpy(a,b)
+# define genncpy(a,b,n) ed_genncpy(a,b,n)
+# define genlen(str) ed_genlen(str)
+# define digit(c) ((c&~STRIP)==0 && isdigit(c))
+# define is_print(c) ((c&~STRIP) || isprint(c))
+# if !_lib_iswprint && !defined(iswprint)
+# define iswprint(c) ((c&~0177) || isprint(c))
+# endif
+ static int _isalph(int);
+ static int _ismetach(int);
+ static int _isblank(int);
+# undef isblank
+# define isblank(v) _isblank(virtual[v])
+# define isalph(v) _isalph(virtual[v])
+# define ismetach(v) _ismetach(virtual[v])
+#else
+ static genchar _c;
+# define gencpy(a,b) strcpy((char*)(a),(char*)(b))
+# define genncpy(a,b,n) strncpy((char*)(a),(char*)(b),n)
+# define genlen(str) strlen(str)
+# define isalph(v) ((_c=virtual[v])=='_'||isalnum(_c))
+# undef isblank
+# define isblank(v) isspace(virtual[v])
+# define ismetach(v) ismeta(virtual[v])
+# define digit(c) isdigit(c)
+# define is_print(c) isprint(c)
+#endif /* SHOPT_MULTIBYTE */
+
+#if ( 'a' == 97) /* ASCII? */
+# define fold(c) ((c)&~040) /* lower and uppercase equivalent */
+#else
+# define fold(c) ((c)|0100) /* lower and uppercase equivalent */
+#endif
+
+#ifndef iswascii
+#define iswascii(c) (!((c)&(~0177)))
+#endif
+
+typedef struct _vi_
+{
+ int direction;
+ int lastmacro;
+ char addnl; /* boolean - add newline flag */
+ char last_find; /* last find command */
+ char last_cmd; /* last command */
+ char repeat_set;
+ char nonewline;
+ int findchar; /* last find char */
+ genchar *lastline;
+ int first_wind; /* first column of window */
+ int last_wind; /* last column in window */
+ int lastmotion; /* last motion */
+ int long_char; /* line bigger than window */
+ int long_line; /* line bigger than window */
+ int ocur_phys; /* old current physical position */
+ int ocur_virt; /* old last virtual position */
+ int ofirst_wind; /* old window first col */
+ int o_v_char; /* prev virtual[ocur_virt] */
+ int repeat; /* repeat count for motion cmds */
+ int lastrepeat; /* last repeat count for motion cmds */
+ int u_column; /* undo current column */
+ int U_saved; /* original virtual saved */
+ genchar *U_space; /* used for U command */
+ genchar *u_space; /* used for u command */
+#ifdef FIORDCHK
+ clock_t typeahead; /* typeahead occurred */
+#else
+ int typeahead; /* typeahead occurred */
+#endif /* FIORDCHK */
+#if SHOPT_MULTIBYTE
+ int bigvi;
+#endif
+ Edit_t *ed; /* pointer to edit data */
+} Vi_t;
+
+#define editb (*vp->ed)
+
+#undef putchar
+#define putchar(c) ed_putchar(vp->ed,c)
+
+#define crallowed editb.e_crlf
+#define cur_virt editb.e_cur /* current virtual column */
+#define cur_phys editb.e_pcur /* current phys column cursor is at */
+#define curhline editb.e_hline /* current history line */
+#define first_virt editb.e_fcol /* first allowable column */
+#define globals editb.e_globals /* local global variables */
+#define histmin editb.e_hismin
+#define histmax editb.e_hismax
+#define last_phys editb.e_peol /* last column in physical */
+#define last_virt editb.e_eol /* last column */
+#define lsearch editb.e_search /* last search string */
+#define lookahead editb.e_lookahead /* characters in buffer */
+#define previous editb.e_lbuf /* lookahead buffer */
+#define max_col editb.e_llimit /* maximum column */
+#define Prompt editb.e_prompt /* pointer to prompt */
+#define plen editb.e_plen /* length of prompt */
+#define physical editb.e_physbuf /* physical image */
+#define usreof editb.e_eof /* user defined eof char */
+#define usrerase editb.e_erase /* user defined erase char */
+#define usrlnext editb.e_lnext /* user defined next literal */
+#define usrkill editb.e_kill /* user defined kill char */
+#define virtual editb.e_inbuf /* pointer to virtual image buffer */
+#define window editb.e_window /* window buffer */
+#define w_size editb.e_wsize /* window size */
+#define inmacro editb.e_inmacro /* true when in macro */
+#define yankbuf editb.e_killbuf /* yank/delete buffer */
+
+
+#define ABORT -2 /* user abort */
+#define APPEND -10 /* append chars */
+#define BAD -1 /* failure flag */
+#define BIGVI -15 /* user wants real vi */
+#define CONTROL -20 /* control mode */
+#define ENTER -25 /* enter flag */
+#define GOOD 0 /* success flag */
+#define INPUT -30 /* input mode */
+#define INSERT -35 /* insert mode */
+#define REPLACE -40 /* replace chars */
+#define SEARCH -45 /* search flag */
+#define TRANSLATE -50 /* translate virt to phys only */
+
+#define INVALID (-1) /* invalid column */
+
+static const char paren_chars[] = "([{)]}"; /* for % command */
+
+static void cursor(Vi_t*, int);
+static void del_line(Vi_t*,int);
+static int getcount(Vi_t*,int);
+static void getline(Vi_t*,int);
+static int getrchar(Vi_t*);
+static int mvcursor(Vi_t*,int);
+static void pr_string(Vi_t*,const char*);
+static void putstring(Vi_t*,int, int);
+static void refresh(Vi_t*,int);
+static void replace(Vi_t*,int, int);
+static void restore_v(Vi_t*);
+static void save_last(Vi_t*);
+static void save_v(Vi_t*);
+static int search(Vi_t*,int);
+static void sync_cursor(Vi_t*);
+static int textmod(Vi_t*,int,int);
+
+/*+ VI_READ( fd, shbuf, nchar )
+ *
+ * This routine implements a one line version of vi and is
+ * called by _filbuf.c
+ *
+-*/
+
+/*
+ * if reedit is non-zero, initialize edit buffer with reedit chars
+ */
+int ed_viread(void *context, int fd, register char *shbuf, int nchar, int reedit)
+{
+ Edit_t *ed = (Edit_t*)context;
+ register int i; /* general variable */
+ register int term_char; /* read() termination character */
+ register Vi_t *vp = ed->e_vi;
+ char prompt[PRSIZE+2]; /* prompt */
+ genchar Physical[2*MAXLINE]; /* physical image */
+ genchar Ubuf[MAXLINE]; /* used for U command */
+ genchar ubuf[MAXLINE]; /* used for u command */
+ genchar Window[MAXLINE]; /* window image */
+ int Globals[9]; /* local global variables */
+ int esc_or_hang=0; /* <ESC> or hangup */
+ char cntl_char=0; /* TRUE if control character present */
+#if SHOPT_RAWONLY
+# define viraw 1
+#else
+ int viraw = (sh_isoption(SH_VIRAW) || sh.st.trap[SH_KEYTRAP]);
+# ifndef FIORDCHK
+ clock_t oldtime, newtime;
+ struct tms dummy;
+# endif /* FIORDCHK */
+#endif /* SHOPT_RAWONLY */
+ if(!vp)
+ {
+ ed->e_vi = vp = newof(0,Vi_t,1,0);
+ vp->lastline = (genchar*)malloc(MAXLINE*CHARSIZE);
+ vp->direction = -1;
+ vp->ed = ed;
+ }
+
+ /*** setup prompt ***/
+
+ Prompt = prompt;
+ ed_setup(vp->ed,fd, reedit);
+ shbuf[reedit] = 0;
+
+#if !SHOPT_RAWONLY
+ if(!viraw)
+ {
+ /*** Change the eol characters to '\r' and eof ***/
+ /* in addition to '\n' and make eof an ESC */
+ if(tty_alt(ERRIO) < 0)
+ return(reexit?reedit:ed_read(context, fd, shbuf, nchar,0));
+
+#ifdef FIORDCHK
+ ioctl(fd,FIORDCHK,&vp->typeahead);
+#else
+ /* time the current line to determine typeahead */
+ oldtime = times(&dummy);
+#endif /* FIORDCHK */
+#if KSHELL
+ /* abort of interrupt has occurred */
+ if(sh.trapnote&SH_SIGSET)
+ i = -1;
+ else
+#endif /* KSHELL */
+ /*** Read the line ***/
+ i = ed_read(context, fd, shbuf, nchar, 0);
+#ifndef FIORDCHK
+ newtime = times(&dummy);
+ vp->typeahead = ((newtime-oldtime) < NTICKS);
+#endif /* FIORDCHK */
+ if(echoctl)
+ {
+ if( i <= 0 )
+ {
+ /*** read error or eof typed ***/
+ tty_cooked(ERRIO);
+ return(i);
+ }
+ term_char = shbuf[--i];
+ if( term_char == '\r' )
+ term_char = '\n';
+ if( term_char=='\n' || term_char==ESC )
+ shbuf[i--] = '\0';
+ else
+ shbuf[i+1] = '\0';
+ }
+ else
+ {
+ register int c = shbuf[0];
+
+ /*** Save and remove the last character if its an eol, ***/
+ /* changing '\r' to '\n' */
+
+ if( i == 0 )
+ {
+ /*** ESC was typed as first char of line ***/
+ esc_or_hang = 1;
+ term_char = ESC;
+ shbuf[i--] = '\0'; /* null terminate line */
+ }
+ else if( i<0 || c==usreof )
+ {
+ /*** read error or eof typed ***/
+ tty_cooked(ERRIO);
+ if( c == usreof )
+ i = 0;
+ return(i);
+ }
+ else
+ {
+ term_char = shbuf[--i];
+ if( term_char == '\r' )
+ term_char = '\n';
+#if !defined(VEOL2) && !defined(ECHOCTL)
+ if(term_char=='\n')
+ {
+ tty_cooked(ERRIO);
+ return(i+1);
+ }
+#endif
+ if( term_char=='\n' || term_char==usreof )
+ {
+ /*** remove terminator & null terminate ***/
+ shbuf[i--] = '\0';
+ }
+ else
+ {
+ /** terminator was ESC, which is not xmitted **/
+ term_char = ESC;
+ shbuf[i+1] = '\0';
+ }
+ }
+ }
+ }
+ else
+#endif /* SHOPT_RAWONLY */
+ {
+ /*** Set raw mode ***/
+
+#if !SHOPT_RAWONLY
+ if( editb.e_ttyspeed == 0 )
+ {
+ /*** never did TCGETA, so do it ***/
+ /* avoids problem if user does 'sh -o viraw' */
+ tty_alt(ERRIO);
+ }
+#endif /* SHOPT_RAWONLY */
+ if(tty_raw(ERRIO,0) < 0 )
+ return(reedit?reedit:ed_read(context, fd, shbuf, nchar,0));
+ i = last_virt-1;
+ }
+
+ /*** Initialize some things ***/
+
+ virtual = (genchar*)shbuf;
+#if SHOPT_MULTIBYTE
+ virtual = (genchar*)roundof((char*)virtual-(char*)0,sizeof(genchar));
+ shbuf[i+1] = 0;
+ i = ed_internal(shbuf,virtual)-1;
+#endif /* SHOPT_MULTIBYTE */
+ globals = Globals;
+ cur_phys = i + 1;
+ cur_virt = i;
+ first_virt = 0;
+ vp->first_wind = 0;
+ last_virt = i;
+ last_phys = i;
+ vp->last_wind = i;
+ vp->long_line = ' ';
+ vp->long_char = ' ';
+ vp->o_v_char = '\0';
+ vp->ocur_phys = 0;
+ vp->ocur_virt = MAXCHAR;
+ vp->ofirst_wind = 0;
+ physical = Physical;
+ vp->u_column = INVALID - 1;
+ vp->U_space = Ubuf;
+ vp->u_space = ubuf;
+ window = Window;
+ window[0] = '\0';
+
+ if(!yankbuf)
+ yankbuf = (genchar*)malloc(MAXLINE*CHARSIZE);
+ if( vp->last_cmd == '\0' )
+ {
+ /*** first time for this shell ***/
+
+ vp->last_cmd = 'i';
+ vp->findchar = INVALID;
+ vp->lastmotion = '\0';
+ vp->lastrepeat = 1;
+ vp->repeat = 1;
+ *yankbuf = 0;
+ }
+
+ /*** fiddle around with prompt length ***/
+ if( nchar+plen > MAXCHAR )
+ nchar = MAXCHAR - plen;
+ max_col = nchar - 2;
+
+ if( !viraw )
+ {
+ int kill_erase = 0;
+ for(i=(echoctl?last_virt:0); i<last_virt; ++i )
+ {
+ /*** change \r to \n, check for control characters, ***/
+ /* delete appropriate ^Vs, */
+ /* and estimate last physical column */
+
+ if( virtual[i] == '\r' )
+ virtual[i] = '\n';
+ if(!echoctl)
+ {
+ register int c = virtual[i];
+ if( c<=usrerase)
+ {
+ /*** user typed escaped erase or kill char ***/
+ cntl_char = 1;
+ if(is_print(c))
+ kill_erase++;
+ }
+ else if( !is_print(c) )
+ {
+ cntl_char = 1;
+
+ if( c == usrlnext )
+ {
+ if( i == last_virt )
+ {
+ /*** eol/eof was escaped ***/
+ /* so replace ^V with it */
+ virtual[i] = term_char;
+ break;
+ }
+
+ /*** delete ^V ***/
+ gencpy((&virtual[i]), (&virtual[i+1]));
+ --cur_virt;
+ --last_virt;
+ }
+ }
+ }
+ }
+
+ /*** copy virtual image to window ***/
+ if(last_virt > 0)
+ last_phys = ed_virt_to_phys(vp->ed,virtual,physical,last_virt,0,0);
+ if( last_phys >= w_size )
+ {
+ /*** line longer than window ***/
+ vp->last_wind = w_size - 1;
+ }
+ else
+ vp->last_wind = last_phys;
+ genncpy(window, virtual, vp->last_wind+1);
+
+ if( term_char!=ESC && (last_virt==INVALID
+ || virtual[last_virt]!=term_char) )
+ {
+ /*** Line not terminated with ESC or escaped (^V) ***/
+ /* eol, so return after doing a total update */
+ /* if( (speed is greater or equal to 1200 */
+ /* and something was typed) and */
+ /* (control character present */
+ /* or typeahead occurred) ) */
+
+ tty_cooked(ERRIO);
+ if( editb.e_ttyspeed==FAST && last_virt!=INVALID
+ && (vp->typeahead || cntl_char) )
+ {
+ refresh(vp,TRANSLATE);
+ pr_string(vp,Prompt);
+ putstring(vp,0, last_phys+1);
+ if(echoctl)
+ ed_crlf(vp->ed);
+ else
+ while(kill_erase-- > 0)
+ putchar(' ');
+ }
+
+ if( term_char=='\n' )
+ {
+ if(!echoctl)
+ ed_crlf(vp->ed);
+ virtual[++last_virt] = '\n';
+ }
+ vp->last_cmd = 'i';
+ save_last(vp);
+#if SHOPT_MULTIBYTE
+ virtual[last_virt+1] = 0;
+ last_virt = ed_external(virtual,shbuf);
+ return(last_virt);
+#else
+ return(++last_virt);
+#endif /* SHOPT_MULTIBYTE */
+ }
+
+ /*** Line terminated with escape, or escaped eol/eof, ***/
+ /* so set raw mode */
+
+ if( tty_raw(ERRIO,0) < 0 )
+ {
+ tty_cooked(ERRIO);
+ /*
+ * The following prevents drivers that return 0 on
+ * causing an infinite loop
+ */
+ if(esc_or_hang)
+ return(-1);
+ virtual[++last_virt] = '\n';
+#if SHOPT_MULTIBYTE
+ virtual[last_virt+1] = 0;
+ last_virt = ed_external(virtual,shbuf);
+ return(last_virt);
+#else
+ return(++last_virt);
+#endif /* SHOPT_MULTIBYTE */
+ }
+
+ if(echoctl) /*** for cntl-echo erase the ^[ ***/
+ pr_string(vp,"\b\b\b\b \b\b");
+
+
+ if(crallowed)
+ {
+ /*** start over since there may be ***/
+ /*** a control char, or cursor might not ***/
+ /*** be at left margin (this lets us know ***/
+ /*** where we are ***/
+ cur_phys = 0;
+ window[0] = '\0';
+ pr_string(vp,Prompt);
+ if( term_char==ESC && (last_virt<0 || virtual[last_virt]!=ESC))
+ refresh(vp,CONTROL);
+ else
+ refresh(vp,INPUT);
+ }
+ else
+ {
+ /*** just update everything internally ***/
+ refresh(vp,TRANSLATE);
+ }
+ }
+
+ /*** Handle usrintr, usrquit, or EOF ***/
+
+ i = sigsetjmp(editb.e_env,0);
+ if( i != 0 )
+ {
+ virtual[0] = '\0';
+ tty_cooked(ERRIO);
+
+ switch(i)
+ {
+ case UEOF:
+ /*** EOF ***/
+ return(0);
+
+ case UINTR:
+ /** interrupt **/
+ return(-1);
+ }
+ return(-1);
+ }
+
+ /*** Get a line from the terminal ***/
+
+ vp->U_saved = 0;
+ if(reedit)
+ refresh(vp,INPUT);
+ if(viraw)
+ getline(vp,APPEND);
+ else if(last_virt>=0 && virtual[last_virt]==term_char)
+ getline(vp,APPEND);
+ else
+ getline(vp,ESC);
+ if(vp->ed->e_multiline)
+ cursor(vp, last_phys);
+ /*** add a new line if user typed unescaped \n ***/
+ /* to cause the shell to process the line */
+ tty_cooked(ERRIO);
+ if(ed->e_nlist)
+ {
+ ed->e_nlist = 0;
+ stakset(ed->e_stkptr,ed->e_stkoff);
+ }
+ if( vp->addnl )
+ {
+ virtual[++last_virt] = '\n';
+ ed_crlf(vp->ed);
+ }
+ if( ++last_virt >= 0 )
+ {
+#if SHOPT_MULTIBYTE
+ if(vp->bigvi)
+ {
+ vp->bigvi = 0;
+ shbuf[last_virt-1] = '\n';
+ }
+ else
+ {
+ virtual[last_virt] = 0;
+ last_virt = ed_external(virtual,shbuf);
+ }
+#endif /* SHOPT_MULTIBYTE */
+ return(last_virt);
+ }
+ else
+ return(-1);
+}
+
+
+/*{ APPEND( char, mode )
+ *
+ * This routine will append char after cur_virt in the virtual image.
+ * mode = APPEND, shift chars right before appending
+ * REPLACE, replace char if possible
+ *
+}*/
+
+static void append(Vi_t *vp,int c, int mode)
+{
+ register int i,j;
+
+ if( last_virt<max_col && last_phys<max_col )
+ {
+ if( mode==APPEND || (cur_virt==last_virt && last_virt>=0))
+ {
+ j = (cur_virt>=0?cur_virt:0);
+ for(i = ++last_virt; i > j; --i)
+ virtual[i] = virtual[i-1];
+ }
+ virtual[++cur_virt] = c;
+ }
+ else
+ ed_ringbell();
+ return;
+}
+
+/*{ BACKWORD( nwords, cmd )
+ *
+ * This routine will position cur_virt at the nth previous word.
+ *
+}*/
+
+static void backword(Vi_t *vp,int nwords, register int cmd)
+{
+ register int tcur_virt = cur_virt;
+ while( nwords-- && tcur_virt > first_virt )
+ {
+ if( !isblank(tcur_virt) && isblank(tcur_virt-1)
+ && tcur_virt>first_virt )
+ --tcur_virt;
+ else if(cmd != 'B')
+ {
+ register int last = isalph(tcur_virt-1);
+ register int cur = isalph(tcur_virt);
+ if((!cur && last) || (cur && !last))
+ --tcur_virt;
+ }
+ while( isblank(tcur_virt) && tcur_virt>=first_virt )
+ --tcur_virt;
+ if( cmd == 'B' )
+ {
+ while( !isblank(tcur_virt) && tcur_virt>=first_virt )
+ --tcur_virt;
+ }
+ else
+ {
+ if(isalph(tcur_virt))
+ while( isalph(tcur_virt) && tcur_virt>=first_virt )
+ --tcur_virt;
+ else
+ while( !isalph(tcur_virt) && !isblank(tcur_virt)
+ && tcur_virt>=first_virt )
+ --tcur_virt;
+ }
+ cur_virt = ++tcur_virt;
+ }
+ return;
+}
+
+/*{ CNTLMODE()
+ *
+ * This routine implements the vi command subset.
+ * The cursor will always be positioned at the char of interest.
+ *
+}*/
+
+static int cntlmode(Vi_t *vp)
+{
+ register int c;
+ register int i;
+ genchar tmp_u_space[MAXLINE]; /* temporary u_space */
+ genchar *real_u_space; /* points to real u_space */
+ int tmp_u_column = INVALID; /* temporary u_column */
+ int was_inmacro;
+
+ if(!vp->U_saved)
+ {
+ /*** save virtual image if never done before ***/
+ virtual[last_virt+1] = '\0';
+ gencpy(vp->U_space, virtual);
+ vp->U_saved = 1;
+ }
+
+ save_last(vp);
+
+ real_u_space = vp->u_space;
+ curhline = histmax;
+ first_virt = 0;
+ vp->repeat = 1;
+ if( cur_virt > INVALID )
+ {
+ /*** make sure cursor is at the last char ***/
+ sync_cursor(vp);
+ }
+
+ /*** Read control char until something happens to cause a ***/
+ /* return to APPEND/REPLACE mode */
+
+ while( c=ed_getchar(vp->ed,-1) )
+ {
+ vp->repeat_set = 0;
+ was_inmacro = inmacro;
+ if( c == '0' )
+ {
+ /*** move to leftmost column ***/
+ cur_virt = 0;
+ sync_cursor(vp);
+ continue;
+ }
+
+ if( digit(c) )
+ {
+ c = getcount(vp,c);
+ if( c == '.' )
+ vp->lastrepeat = vp->repeat;
+ }
+
+ /*** see if it's a move cursor command ***/
+
+ if(mvcursor(vp,c))
+ {
+ sync_cursor(vp);
+ vp->repeat = 1;
+ continue;
+ }
+
+ /*** see if it's a repeat of the last command ***/
+
+ if( c == '.' )
+ {
+ c = vp->last_cmd;
+ vp->repeat = vp->lastrepeat;
+ i = textmod(vp,c, c);
+ }
+ else
+ {
+ i = textmod(vp,c, 0);
+ }
+
+ /*** see if it's a text modification command ***/
+
+ switch(i)
+ {
+ case BAD:
+ break;
+
+ default: /** input mode **/
+ if(!was_inmacro)
+ {
+ vp->last_cmd = c;
+ vp->lastrepeat = vp->repeat;
+ }
+ vp->repeat = 1;
+ if( i == GOOD )
+ continue;
+ return(i);
+ }
+
+ switch( c )
+ {
+ /***** Other stuff *****/
+
+ case cntl('L'): /** Redraw line **/
+ /*** print the prompt and ***/
+ /* force a total refresh */
+ if(vp->nonewline==0)
+ putchar('\n');
+ vp->nonewline = 0;
+ pr_string(vp,Prompt);
+ window[0] = '\0';
+ cur_phys = vp->first_wind;
+ vp->ofirst_wind = INVALID;
+ vp->long_line = ' ';
+ break;
+
+ case cntl('V'):
+ {
+ register const char *p = fmtident(e_version);
+ save_v(vp);
+ del_line(vp,BAD);
+ while(c = *p++)
+ append(vp,c,APPEND);
+ refresh(vp,CONTROL);
+ ed_getchar(vp->ed,-1);
+ restore_v(vp);
+ break;
+ }
+
+ case '/': /** Search **/
+ case '?':
+ case 'N':
+ case 'n':
+ save_v(vp);
+ switch( search(vp,c) )
+ {
+ case GOOD:
+ /*** force a total refresh ***/
+ window[0] = '\0';
+ goto newhist;
+
+ case BAD:
+ /*** no match ***/
+ ed_ringbell();
+
+ default:
+ if( vp->u_column == INVALID )
+ del_line(vp,BAD);
+ else
+ restore_v(vp);
+ break;
+ }
+ break;
+
+ case 'j': /** get next command **/
+ case '+': /** get next command **/
+ curhline += vp->repeat;
+ if( curhline > histmax )
+ {
+ curhline = histmax;
+ goto ringbell;
+ }
+ else if(curhline==histmax && tmp_u_column!=INVALID )
+ {
+ vp->u_space = tmp_u_space;
+ vp->u_column = tmp_u_column;
+ restore_v(vp);
+ vp->u_space = real_u_space;
+ break;
+ }
+ save_v(vp);
+ cur_virt = INVALID;
+ goto newhist;
+
+ case 'k': /** get previous command **/
+ case '-': /** get previous command **/
+ if( curhline == histmax )
+ {
+ vp->u_space = tmp_u_space;
+ i = vp->u_column;
+ save_v(vp);
+ vp->u_space = real_u_space;
+ tmp_u_column = vp->u_column;
+ vp->u_column = i;
+ }
+
+ curhline -= vp->repeat;
+ if( curhline <= histmin )
+ {
+ curhline += vp->repeat;
+ goto ringbell;
+ }
+ save_v(vp);
+ cur_virt = INVALID;
+ newhist:
+ if(curhline!=histmax || cur_virt==INVALID)
+ hist_copy((char*)virtual, MAXLINE, curhline,-1);
+ else
+ {
+ strcpy((char*)virtual,(char*)vp->u_space);
+#if SHOPT_MULTIBYTE
+ ed_internal((char*)vp->u_space,vp->u_space);
+#endif /* SHOPT_MULTIBYTE */
+ }
+#if SHOPT_MULTIBYTE
+ ed_internal((char*)virtual,virtual);
+#endif /* SHOPT_MULTIBYTE */
+ if((last_virt=genlen(virtual)-1) >= 0 && cur_virt == INVALID)
+ cur_virt = 0;
+ break;
+
+
+ case 'u': /** undo the last thing done **/
+ restore_v(vp);
+ break;
+
+ case 'U': /** Undo everything **/
+ save_v(vp);
+ if( virtual[0] == '\0' )
+ goto ringbell;
+ else
+ {
+ gencpy(virtual, vp->U_space);
+ last_virt = genlen(vp->U_space) - 1;
+ cur_virt = 0;
+ }
+ break;
+
+#if KSHELL
+ case 'v':
+ if(vp->repeat_set==0)
+ goto vcommand;
+#endif /* KSHELL */
+
+ case 'G': /** goto command repeat **/
+ if(vp->repeat_set==0)
+ vp->repeat = histmin+1;
+ if( vp->repeat <= histmin || vp->repeat > histmax )
+ {
+ goto ringbell;
+ }
+ curhline = vp->repeat;
+ save_v(vp);
+ if(c == 'G')
+ {
+ cur_virt = INVALID;
+ goto newhist;
+ }
+
+#if KSHELL
+ vcommand:
+ if(ed_fulledit(vp->ed)==GOOD)
+ return(BIGVI);
+ else
+ goto ringbell;
+#endif /* KSHELL */
+
+ case '#': /** insert(delete) # to (no)comment command **/
+ if( cur_virt != INVALID )
+ {
+ register genchar *p = &virtual[last_virt+1];
+ *p = 0;
+ /*** see whether first char is comment char ***/
+ c = (virtual[0]=='#');
+ while(p-- >= virtual)
+ {
+ if(*p=='\n' || p<virtual)
+ {
+ if(c) /* delete '#' */
+ {
+ if(p[1]=='#')
+ {
+ last_virt--;
+ gencpy(p+1,p+2);
+ }
+ }
+ else
+ {
+ cur_virt = p-virtual;
+ append(vp,'#', APPEND);
+ }
+ }
+ }
+ if(c)
+ {
+ curhline = histmax;
+ cur_virt = 0;
+ break;
+ }
+ refresh(vp,INPUT);
+ }
+
+ case '\n': /** send to shell **/
+ return(ENTER);
+
+ case ESC:
+ /* don't ring bell if next char is '[' */
+ if(!lookahead)
+ {
+ char x;
+ if(sfpkrd(editb.e_fd,&x,1,'\r',400L,-1)>0)
+ ed_ungetchar(vp->ed,x);
+ }
+ if(lookahead)
+ {
+ ed_ungetchar(vp->ed,c=ed_getchar(vp->ed,1));
+ if(c=='[')
+ {
+ vp->repeat = 1;
+ continue;
+ }
+ }
+ default:
+ ringbell:
+ ed_ringbell();
+ vp->repeat = 1;
+ continue;
+ }
+
+ refresh(vp,CONTROL);
+ vp->repeat = 1;
+ }
+/* NOTREACHED */
+ return(0);
+}
+
+/*{ CURSOR( new_current_physical )
+ *
+ * This routine will position the virtual cursor at
+ * physical column x in the window.
+ *
+}*/
+
+static void cursor(Vi_t *vp,register int x)
+{
+#if SHOPT_MULTIBYTE
+ while(physical[x]==MARKER)
+ x++;
+#endif /* SHOPT_MULTIBYTE */
+ cur_phys = ed_setcursor(vp->ed, physical, cur_phys,x,vp->first_wind);
+}
+
+/*{ DELETE( nchars, mode )
+ *
+ * Delete nchars from the virtual space and leave cur_virt positioned
+ * at cur_virt-1.
+ *
+ * If mode = 'c', do not save the characters deleted
+ * = 'd', save them in yankbuf and delete.
+ * = 'y', save them in yankbuf but do not delete.
+ *
+}*/
+
+static void cdelete(Vi_t *vp,register int nchars, int mode)
+{
+ register int i;
+ register genchar *cp;
+
+ if( cur_virt < first_virt )
+ {
+ ed_ringbell();
+ return;
+ }
+ if( nchars > 0 )
+ {
+ cp = virtual+cur_virt;
+ vp->o_v_char = cp[0];
+ if( (cur_virt-- + nchars) > last_virt )
+ {
+ /*** set nchars to number actually deleted ***/
+ nchars = last_virt - cur_virt;
+ }
+
+ /*** save characters to be deleted ***/
+
+ if( mode != 'c' )
+ {
+ i = cp[nchars];
+ cp[nchars] = 0;
+ gencpy(yankbuf,cp);
+ cp[nchars] = i;
+ }
+
+ /*** now delete these characters ***/
+
+ if( mode != 'y' )
+ {
+ gencpy(cp,cp+nchars);
+ last_virt -= nchars;
+ }
+ }
+ return;
+}
+
+/*{ DEL_LINE( mode )
+ *
+ * This routine will delete the line.
+ * mode = GOOD, do a save_v()
+ *
+}*/
+static void del_line(register Vi_t *vp, int mode)
+{
+ if( last_virt == INVALID )
+ return;
+
+ if( mode == GOOD )
+ save_v(vp);
+
+ cur_virt = 0;
+ first_virt = 0;
+ cdelete(vp,last_virt+1, BAD);
+ refresh(vp,CONTROL);
+
+ cur_virt = INVALID;
+ cur_phys = 0;
+ vp->findchar = INVALID;
+ last_phys = INVALID;
+ last_virt = INVALID;
+ vp->last_wind = INVALID;
+ vp->first_wind = 0;
+ vp->o_v_char = '\0';
+ vp->ocur_phys = 0;
+ vp->ocur_virt = MAXCHAR;
+ vp->ofirst_wind = 0;
+ window[0] = '\0';
+ return;
+}
+
+/*{ DELMOTION( motion, mode )
+ *
+ * Delete thru motion.
+ *
+ * mode = 'd', save deleted characters, delete
+ * = 'c', do not save characters, change
+ * = 'y', save characters, yank
+ *
+ * Returns 1 if operation successful; else 0.
+ *
+}*/
+
+static int delmotion(Vi_t *vp,int motion, int mode)
+{
+ register int begin, end, delta;
+ /* the following saves a register */
+
+ if( cur_virt == INVALID )
+ return(0);
+ if( mode != 'y' )
+ save_v(vp);
+ begin = cur_virt;
+
+ /*** fake out the motion routines by appending a blank ***/
+
+ virtual[++last_virt] = ' ';
+ end = mvcursor(vp,motion);
+ virtual[last_virt--] = 0;
+ if(!end)
+ return(0);
+
+ end = cur_virt;
+ if( mode=='c' && end>begin && strchr("wW", motion) )
+ {
+ /*** called by change operation, user really expects ***/
+ /* the effect of the eE commands, so back up to end of word */
+ while( end>begin && isblank(end-1) )
+ --end;
+ if( end == begin )
+ ++end;
+ }
+
+ delta = end - begin;
+ if( delta >= 0 )
+ {
+ cur_virt = begin;
+ if( strchr("eE;,TtFf%", motion) )
+ ++delta;
+ }
+ else
+ {
+ delta = -delta + (motion=='%');
+ }
+
+ cdelete(vp,delta, mode);
+ if( mode == 'y' )
+ cur_virt = begin;
+ return(1);
+}
+
+
+/*{ ENDWORD( nwords, cmd )
+ *
+ * This routine will move cur_virt to the end of the nth word.
+ *
+}*/
+
+static void endword(Vi_t *vp, int nwords, register int cmd)
+{
+ register int tcur_virt = cur_virt;
+ while( nwords-- )
+ {
+ if( !isblank(tcur_virt) && tcur_virt<=last_virt )
+ ++tcur_virt;
+ while( isblank(tcur_virt) && tcur_virt<=last_virt )
+ ++tcur_virt;
+ if( cmd == 'E' )
+ {
+ while( !isblank(tcur_virt) && tcur_virt<=last_virt )
+ ++tcur_virt;
+ }
+ else
+ {
+ if( isalph(tcur_virt) )
+ while( isalph(tcur_virt) && tcur_virt<=last_virt )
+ ++tcur_virt;
+ else
+ while( !isalph(tcur_virt) && !isblank(tcur_virt)
+ && tcur_virt<=last_virt )
+ ++tcur_virt;
+ }
+ if( tcur_virt > first_virt )
+ tcur_virt--;
+ }
+ cur_virt = tcur_virt;
+ return;
+}
+
+/*{ FORWARD( nwords, cmd )
+ *
+ * This routine will move cur_virt forward to the next nth word.
+ *
+}*/
+
+static void forward(Vi_t *vp,register int nwords, int cmd)
+{
+ register int tcur_virt = cur_virt;
+ while( nwords-- )
+ {
+ if( cmd == 'W' )
+ {
+ while( !isblank(tcur_virt) && tcur_virt < last_virt )
+ ++tcur_virt;
+ }
+ else
+ {
+ if( isalph(tcur_virt) )
+ {
+ while( isalph(tcur_virt) && tcur_virt<last_virt )
+ ++tcur_virt;
+ }
+ else
+ {
+ while( !isalph(tcur_virt) && !isblank(tcur_virt)
+ && tcur_virt < last_virt )
+ ++tcur_virt;
+ }
+ }
+ while( isblank(tcur_virt) && tcur_virt < last_virt )
+ ++tcur_virt;
+ }
+ cur_virt = tcur_virt;
+ return;
+}
+
+
+
+/*{ GETCOUNT(c)
+ *
+ * Set repeat to the user typed number and return the terminating
+ * character.
+ *
+}*/
+
+static int getcount(register Vi_t *vp,register int c)
+{
+ register int i;
+
+ /*** get any repeat count ***/
+
+ if( c == '0' )
+ return(c);
+
+ vp->repeat_set++;
+ i = 0;
+ while( digit(c) )
+ {
+ i = i*10 + c - '0';
+ c = ed_getchar(vp->ed,-1);
+ }
+
+ if( i > 0 )
+ vp->repeat *= i;
+ return(c);
+}
+
+
+/*{ GETLINE( mode )
+ *
+ * This routine will fetch a line.
+ * mode = APPEND, allow escape to cntlmode subroutine
+ * appending characters.
+ * = REPLACE, allow escape to cntlmode subroutine
+ * replacing characters.
+ * = SEARCH, no escape allowed
+ * = ESC, enter control mode immediately
+ *
+ * The cursor will always be positioned after the last
+ * char printed.
+ *
+ * This routine returns when cr, nl, or (eof in column 0) is
+ * received (column 0 is the first char position).
+ *
+}*/
+
+static void getline(register Vi_t* vp,register int mode)
+{
+ register int c;
+ register int tmp;
+ int max_virt=0, last_save=0;
+ genchar saveline[MAXLINE];
+
+ vp->addnl = 1;
+
+ if( mode == ESC )
+ {
+ /*** go directly to control mode ***/
+ goto escape;
+ }
+
+ for(;;)
+ {
+ if( (c=ed_getchar(vp->ed,mode==SEARCH?1:-2)) == usreof )
+ c = UEOF;
+ else if( c == usrerase )
+ c = UERASE;
+ else if( c == usrkill )
+ c = UKILL;
+ else if( c == editb.e_werase )
+ c = UWERASE;
+ else if( c == usrlnext )
+ c = ULNEXT;
+
+ if( c == ULNEXT)
+ {
+ /*** implement ^V to escape next char ***/
+ c = ed_getchar(vp->ed,2);
+ append(vp,c, mode);
+ refresh(vp,INPUT);
+ continue;
+ }
+
+ switch( c )
+ {
+ case ESC: /** enter control mode **/
+ if(!sh_isoption(SH_VI))
+ {
+ append(vp,c, mode);
+ break;
+ }
+ if( mode == SEARCH )
+ {
+ ed_ringbell();
+ continue;
+ }
+ else
+ {
+ escape:
+ if( mode == REPLACE )
+ {
+ c = max_virt-cur_virt;
+ if(c > 0 && last_save>=cur_virt)
+ {
+ genncpy((&virtual[cur_virt]),&saveline[cur_virt],c);
+ if(last_virt>=last_save)
+ last_virt=last_save-1;
+ refresh(vp,INPUT);
+ }
+ --cur_virt;
+ }
+ tmp = cntlmode(vp);
+ if( tmp == ENTER || tmp == BIGVI )
+ {
+#if SHOPT_MULTIBYTE
+ vp->bigvi = (tmp==BIGVI);
+#endif /* SHOPT_MULTIBYTE */
+ return;
+ }
+ if( tmp == INSERT )
+ {
+ mode = APPEND;
+ continue;
+ }
+ mode = tmp;
+ if(mode==REPLACE)
+ {
+ c = last_save = last_virt+1;
+ if(c >= MAXLINE)
+ c = MAXLINE-1;
+ genncpy(saveline, virtual, c);
+ }
+ }
+ break;
+
+ case UERASE: /** user erase char **/
+ /*** treat as backspace ***/
+
+ case '\b': /** backspace **/
+ if( virtual[cur_virt] == '\\' )
+ {
+ cdelete(vp,1, BAD);
+ append(vp,usrerase, mode);
+ }
+ else
+ {
+ if( mode==SEARCH && cur_virt==0 )
+ {
+ first_virt = 0;
+ cdelete(vp,1, BAD);
+ return;
+ }
+ if(mode==REPLACE || (last_save>0 && last_virt<=last_save))
+ {
+ if(cur_virt<=first_virt)
+ ed_ringbell();
+ else if(mode==REPLACE)
+ --cur_virt;
+ mode = REPLACE;
+ sync_cursor(vp);
+ continue;
+ }
+ else
+ cdelete(vp,1, BAD);
+ }
+ break;
+
+ case UWERASE: /** delete back word **/
+ if( cur_virt > first_virt &&
+ !isblank(cur_virt) &&
+ !ispunct(virtual[cur_virt]) &&
+ isblank(cur_virt-1) )
+ {
+ cdelete(vp,1, BAD);
+ }
+ else
+ {
+ tmp = cur_virt;
+ backword(vp,1, 'W');
+ cdelete(vp,tmp - cur_virt + 1, BAD);
+ }
+ break;
+
+ case UKILL: /** user kill line char **/
+ if( virtual[cur_virt] == '\\' )
+ {
+ cdelete(vp,1, BAD);
+ append(vp,usrkill, mode);
+ }
+ else
+ {
+ if( mode == SEARCH )
+ {
+ cur_virt = 1;
+ delmotion(vp, '$', BAD);
+ }
+ else if(first_virt)
+ {
+ tmp = cur_virt;
+ cur_virt = first_virt;
+ cdelete(vp,tmp - cur_virt + 1, BAD);
+ }
+ else
+ del_line(vp,GOOD);
+ }
+ break;
+
+ case UEOF: /** eof char **/
+ if( cur_virt != INVALID )
+ continue;
+ vp->addnl = 0;
+
+ case '\n': /** newline or return **/
+ if( mode != SEARCH )
+ save_last(vp);
+ refresh(vp,INPUT);
+ return;
+
+ case '\t': /** command completion **/
+ if(mode!=SEARCH && last_virt>=0 && (vp->ed->e_tabcount|| !isblank(cur_virt)) && vp->ed->sh->nextprompt)
+ {
+ if(vp->ed->e_tabcount==0)
+ {
+ ed_ungetchar(vp->ed,'\\');
+ vp->ed->e_tabcount=1;
+ goto escape;
+ }
+ else if(vp->ed->e_tabcount==1)
+ {
+ ed_ungetchar(vp->ed,'=');
+ goto escape;
+ }
+ vp->ed->e_tabcount = 0;
+ }
+ /* FALL THRU*/
+ default:
+ if( mode == REPLACE )
+ {
+ if( cur_virt < last_virt )
+ {
+ replace(vp,c, 1);
+ if(cur_virt>max_virt)
+ max_virt = cur_virt;
+ continue;
+ }
+ cdelete(vp,1, BAD);
+ mode = APPEND;
+ max_virt = last_virt+3;
+ }
+ append(vp,c, mode);
+ break;
+ }
+ refresh(vp,INPUT);
+
+ }
+}
+
+/*{ MVCURSOR( motion )
+ *
+ * This routine will move the virtual cursor according to motion
+ * for repeat times.
+ *
+ * It returns GOOD if successful; else BAD.
+ *
+}*/
+
+static int mvcursor(register Vi_t* vp,register int motion)
+{
+ register int count;
+ register int tcur_virt;
+ register int incr = -1;
+ register int bound = 0;
+
+ switch(motion)
+ {
+ /***** Cursor move commands *****/
+
+ case '0': /** First column **/
+ tcur_virt = 0;
+ break;
+
+ case '^': /** First nonblank character **/
+ tcur_virt = first_virt;
+ while( isblank(tcur_virt) && tcur_virt < last_virt )
+ ++tcur_virt;
+ break;
+
+ case '|':
+ tcur_virt = vp->repeat-1;
+ if(tcur_virt <= last_virt)
+ break;
+ /* fall through */
+
+ case '$': /** End of line **/
+ tcur_virt = last_virt;
+ break;
+
+ case '[':
+ switch(motion=getcount(vp,ed_getchar(vp->ed,-1)))
+ {
+ case 'A':
+ ed_ungetchar(vp->ed,'k');
+ return(1);
+ case 'B':
+ ed_ungetchar(vp->ed,'j');
+ return(1);
+ case 'C':
+ motion = last_virt;
+ incr = 1;
+ goto walk;
+ case 'D':
+ motion = first_virt;
+ goto walk;
+ case 'H':
+ tcur_virt = 0;
+ break;
+ case 'Y':
+ tcur_virt = last_virt;
+ break;
+ default:
+ ed_ungetchar(vp->ed,motion);
+ return(0);
+ }
+ break;
+
+ case 'h': /** Left one **/
+ case '\b':
+ motion = first_virt;
+ goto walk;
+
+ case ' ':
+ case 'l': /** Right one **/
+ motion = last_virt;
+ incr = 1;
+ walk:
+ tcur_virt = cur_virt;
+ if( incr*tcur_virt < motion)
+ {
+ tcur_virt += vp->repeat*incr;
+ if( incr*tcur_virt > motion)
+ tcur_virt = motion;
+ }
+ else
+ return(0);
+ break;
+
+ case 'B':
+ case 'b': /** back word **/
+ tcur_virt = cur_virt;
+ backword(vp,vp->repeat, motion);
+ if( cur_virt == tcur_virt )
+ return(0);
+ return(1);
+
+ case 'E':
+ case 'e': /** end of word **/
+ tcur_virt = cur_virt;
+ if(tcur_virt >=0)
+ endword(vp, vp->repeat, motion);
+ if( cur_virt == tcur_virt )
+ return(0);
+ return(1);
+
+ case ',': /** reverse find old char **/
+ case ';': /** find old char **/
+ switch(vp->last_find)
+ {
+ case 't':
+ case 'f':
+ if(motion==';')
+ {
+ bound = last_virt;
+ incr = 1;
+ }
+ goto find_b;
+
+ case 'T':
+ case 'F':
+ if(motion==',')
+ {
+ bound = last_virt;
+ incr = 1;
+ }
+ goto find_b;
+
+ default:
+ return(0);
+ }
+
+
+ case 't': /** find up to new char forward **/
+ case 'f': /** find new char forward **/
+ bound = last_virt;
+ incr = 1;
+
+ case 'T': /** find up to new char backward **/
+ case 'F': /** find new char backward **/
+ vp->last_find = motion;
+ if((vp->findchar=getrchar(vp))==ESC)
+ return(1);
+find_b:
+ tcur_virt = cur_virt;
+ count = vp->repeat;
+ while( count-- )
+ {
+ while( incr*(tcur_virt+=incr) <= bound
+ && virtual[tcur_virt] != vp->findchar );
+ if( incr*tcur_virt > bound )
+ {
+ return(0);
+ }
+ }
+ if( fold(vp->last_find) == 'T' )
+ tcur_virt -= incr;
+ break;
+
+ case '%':
+ {
+ int nextmotion;
+ int nextc;
+ tcur_virt = cur_virt;
+ while( tcur_virt <= last_virt
+ && strchr(paren_chars,virtual[tcur_virt])==(char*)0)
+ tcur_virt++;
+ if(tcur_virt > last_virt )
+ return(0);
+ nextc = virtual[tcur_virt];
+ count = strchr(paren_chars,nextc)-paren_chars;
+ if(count < 3)
+ {
+ incr = 1;
+ bound = last_virt;
+ nextmotion = paren_chars[count+3];
+ }
+ else
+ nextmotion = paren_chars[count-3];
+ count = 1;
+ while(count >0 && incr*(tcur_virt+=incr) <= bound)
+ {
+ if(virtual[tcur_virt] == nextmotion)
+ count--;
+ else if(virtual[tcur_virt]==nextc)
+ count++;
+ }
+ if(count)
+ return(0);
+ break;
+ }
+
+ case 'W':
+ case 'w': /** forward word **/
+ tcur_virt = cur_virt;
+ forward(vp,vp->repeat, motion);
+ if( tcur_virt == cur_virt )
+ return(0);
+ return(1);
+
+ default:
+ return(0);
+ }
+ cur_virt = tcur_virt;
+
+ return(1);
+}
+
+/*
+ * print a string
+ */
+
+static void pr_string(register Vi_t *vp, register const char *sp)
+{
+ /*** copy string sp ***/
+ register char *ptr = editb.e_outptr;
+ while(*sp)
+ *ptr++ = *sp++;
+ editb.e_outptr = ptr;
+ return;
+}
+
+/*{ PUTSTRING( column, nchars )
+ *
+ * Put nchars starting at column of physical into the workspace
+ * to be printed.
+ *
+}*/
+
+static void putstring(register Vi_t *vp,register int col, register int nchars)
+{
+ while( nchars-- )
+ putchar(physical[col++]);
+ return;
+}
+
+/*{ REFRESH( mode )
+ *
+ * This routine will refresh the crt so the physical image matches
+ * the virtual image and display the proper window.
+ *
+ * mode = CONTROL, refresh in control mode, ie. leave cursor
+ * positioned at last char printed.
+ * = INPUT, refresh in input mode; leave cursor positioned
+ * after last char printed.
+ * = TRANSLATE, perform virtual to physical translation
+ * and adjust left margin only.
+ *
+ * +-------------------------------+
+ * | | | virtual | | |
+ * +-------------------------------+
+ * cur_virt last_virt
+ *
+ * +-----------------------------------------------+
+ * | | | physical | | |
+ * +-----------------------------------------------+
+ * cur_phys last_phys
+ *
+ * 0 w_size - 1
+ * +-----------------------+
+ * | | | window |
+ * +-----------------------+
+ * cur_window = cur_phys - first_wind
+}*/
+
+static void refresh(register Vi_t* vp, int mode)
+{
+ register int p;
+ register int regb;
+ register int first_w = vp->first_wind;
+ int p_differ;
+ int new_lw;
+ int ncur_phys;
+ int opflag; /* search optimize flag */
+
+# define w regb
+# define v regb
+
+ /*** find out if it's necessary to start translating at beginning ***/
+
+ if(lookahead>0)
+ {
+ p = previous[lookahead-1];
+ if(p != ESC && p != '\n' && p != '\r')
+ mode = TRANSLATE;
+ }
+ v = cur_virt;
+ if( v<vp->ocur_virt || vp->ocur_virt==INVALID
+ || ( v==vp->ocur_virt
+ && (!is_print(virtual[v]) || !is_print(vp->o_v_char))) )
+ {
+ opflag = 0;
+ p = 0;
+ v = 0;
+ }
+ else
+ {
+ opflag = 1;
+ p = vp->ocur_phys;
+ v = vp->ocur_virt;
+ if( !is_print(virtual[v]) )
+ {
+ /*** avoid double ^'s ***/
+ ++p;
+ ++v;
+ }
+ }
+ virtual[last_virt+1] = 0;
+ ncur_phys = ed_virt_to_phys(vp->ed,virtual,physical,cur_virt,v,p);
+ p = genlen(physical);
+ if( --p < 0 )
+ last_phys = 0;
+ else
+ last_phys = p;
+
+ /*** see if this was a translate only ***/
+
+ if( mode == TRANSLATE )
+ return;
+
+ /*** adjust left margin if necessary ***/
+
+ if( ncur_phys<first_w || ncur_phys>=(first_w + w_size) )
+ {
+ cursor(vp,first_w);
+ first_w = ncur_phys - (w_size>>1);
+ if( first_w < 0 )
+ first_w = 0;
+ vp->first_wind = cur_phys = first_w;
+ }
+
+ /*** attempt to optimize search somewhat to find ***/
+ /*** out where physical and window images differ ***/
+
+ if( first_w==vp->ofirst_wind && ncur_phys>=vp->ocur_phys && opflag==1 )
+ {
+ p = vp->ocur_phys;
+ w = p - first_w;
+ }
+ else
+ {
+ p = first_w;
+ w = 0;
+ }
+
+ for(; (p<=last_phys && w<=vp->last_wind); ++p, ++w)
+ {
+ if( window[w] != physical[p] )
+ break;
+ }
+ p_differ = p;
+
+ if( (p>last_phys || p>=first_w+w_size) && w>vp->last_wind
+ && cur_virt==vp->ocur_virt )
+ {
+ /*** images are identical ***/
+ return;
+ }
+
+ /*** copy the physical image to the window image ***/
+
+ if( last_virt != INVALID )
+ {
+ while( p <= last_phys && w < w_size )
+ window[w++] = physical[p++];
+ }
+ new_lw = w;
+
+ /*** erase trailing characters if needed ***/
+
+ while( w <= vp->last_wind )
+ window[w++] = ' ';
+ vp->last_wind = --w;
+
+ p = p_differ;
+
+ /*** move cursor to start of difference ***/
+
+ cursor(vp,p);
+
+ /*** and output difference ***/
+
+ w = p - first_w;
+ while( w <= vp->last_wind )
+ putchar(window[w++]);
+
+ cur_phys = w + first_w;
+ vp->last_wind = --new_lw;
+
+ if( last_phys >= w_size )
+ {
+ if( first_w == 0 )
+ vp->long_char = '>';
+ else if( last_phys < (first_w+w_size) )
+ vp->long_char = '<';
+ else
+ vp->long_char = '*';
+ }
+ else
+ vp->long_char = ' ';
+
+ if( vp->long_line != vp->long_char )
+ {
+ /*** indicate lines longer than window ***/
+ while( w++ < w_size )
+ {
+ putchar(' ');
+ ++cur_phys;
+ }
+ putchar(vp->long_char);
+ ++cur_phys;
+ vp->long_line = vp->long_char;
+ }
+
+ vp->ocur_phys = ncur_phys;
+ vp->ocur_virt = cur_virt;
+ vp->ofirst_wind = first_w;
+
+ if( mode==INPUT && cur_virt>INVALID )
+ ++ncur_phys;
+
+ cursor(vp,ncur_phys);
+ ed_flush(vp->ed);
+ return;
+}
+
+/*{ REPLACE( char, increment )
+ *
+ * Replace the cur_virt character with char. This routine attempts
+ * to avoid using refresh().
+ *
+ * increment = 1, increment cur_virt after replacement.
+ * = 0, leave cur_virt where it is.
+ *
+}*/
+
+static void replace(register Vi_t *vp, register int c, register int increment)
+{
+ register int cur_window;
+
+ if( cur_virt == INVALID )
+ {
+ /*** can't replace invalid cursor ***/
+ ed_ringbell();
+ return;
+ }
+ cur_window = cur_phys - vp->first_wind;
+ if( vp->ocur_virt == INVALID || !is_print(c)
+ || !is_print(virtual[cur_virt])
+ || !is_print(vp->o_v_char)
+#if SHOPT_MULTIBYTE
+ || !iswascii(c) || mbwidth(vp->o_v_char)>1
+ || !iswascii(virtual[cur_virt])
+#endif /* SHOPT_MULTIBYTE */
+ || (increment && (cur_window==w_size-1)
+ || !is_print(virtual[cur_virt+1])) )
+ {
+ /*** must use standard refresh routine ***/
+
+ cdelete(vp,1, BAD);
+ append(vp,c, APPEND);
+ if( increment && cur_virt<last_virt )
+ ++cur_virt;
+ refresh(vp,CONTROL);
+ }
+ else
+ {
+ virtual[cur_virt] = c;
+ physical[cur_phys] = c;
+ window[cur_window] = c;
+ putchar(c);
+ if(increment)
+ {
+ c = virtual[++cur_virt];
+ ++cur_phys;
+ }
+ else
+ {
+ putchar('\b');
+ }
+ vp->o_v_char = c;
+ ed_flush(vp->ed);
+ }
+ return;
+}
+
+/*{ RESTORE_V()
+ *
+ * Restore the contents of virtual space from u_space.
+ *
+}*/
+
+static void restore_v(register Vi_t *vp)
+{
+ register int tmpcol;
+ genchar tmpspace[MAXLINE];
+
+ if( vp->u_column == INVALID-1 )
+ {
+ /*** never saved anything ***/
+ ed_ringbell();
+ return;
+ }
+ gencpy(tmpspace, vp->u_space);
+ tmpcol = vp->u_column;
+ save_v(vp);
+ gencpy(virtual, tmpspace);
+ cur_virt = tmpcol;
+ last_virt = genlen(tmpspace) - 1;
+ vp->ocur_virt = MAXCHAR; /** invalidate refresh optimization **/
+ return;
+}
+
+/*{ SAVE_LAST()
+ *
+ * If the user has typed something, save it in last line.
+ *
+}*/
+
+static void save_last(register Vi_t* vp)
+{
+ register int i;
+
+ if( (i = cur_virt - first_virt + 1) > 0 )
+ {
+ /*** save last thing user typed ***/
+ if(i >= MAXLINE)
+ i = MAXLINE-1;
+ genncpy(vp->lastline, (&virtual[first_virt]), i);
+ vp->lastline[i] = '\0';
+ }
+ return;
+}
+
+/*{ SAVE_V()
+ *
+ * This routine will save the contents of virtual in u_space.
+ *
+}*/
+
+static void save_v(register Vi_t *vp)
+{
+ if(!inmacro)
+ {
+ virtual[last_virt + 1] = '\0';
+ gencpy(vp->u_space, virtual);
+ vp->u_column = cur_virt;
+ }
+ return;
+}
+
+/*{ SEARCH( mode )
+ *
+ * Search history file for regular expression.
+ *
+ * mode = '/' require search string and search new to old
+ * mode = '?' require search string and search old to new
+ * mode = 'N' repeat last search in reverse direction
+ * mode = 'n' repeat last search
+ *
+}*/
+
+/*
+ * search for <string> in the current command
+ */
+static int curline_search(Vi_t *vp, const char *string)
+{
+ register int len=strlen(string);
+ register const char *dp,*cp=string, *dpmax;
+#if SHOPT_MULTIBYTE
+ ed_external(vp->u_space,(char*)vp->u_space);
+#endif /* SHOPT_MULTIBYTE */
+ for(dp=(char*)vp->u_space,dpmax=dp+strlen(dp)-len; dp<=dpmax; dp++)
+ {
+ if(*dp==*cp && memcmp(cp,dp,len)==0)
+ return(dp-(char*)vp->u_space);
+ }
+#if SHOPT_MULTIBYTE
+ ed_internal((char*)vp->u_space,vp->u_space);
+#endif /* SHOPT_MULTIBYTE */
+ return(-1);
+}
+
+static int search(register Vi_t* vp,register int mode)
+{
+ register int new_direction;
+ register int oldcurhline;
+ register int i;
+ Histloc_t location;
+
+ if( mode == '/' || mode == '?')
+ {
+ /*** new search expression ***/
+ del_line(vp,BAD);
+ append(vp,mode, APPEND);
+ refresh(vp,INPUT);
+ first_virt = 1;
+ getline(vp,SEARCH);
+ first_virt = 0;
+ virtual[last_virt + 1] = '\0'; /*** make null terminated ***/
+ vp->direction = mode=='/' ? -1 : 1;
+ }
+
+ if( cur_virt == INVALID )
+ {
+ /*** no operation ***/
+ return(ABORT);
+ }
+
+ if( cur_virt==0 || fold(mode)=='N' )
+ {
+ /*** user wants repeat of last search ***/
+ del_line(vp,BAD);
+ strcpy( ((char*)virtual)+1, lsearch);
+#if SHOPT_MULTIBYTE
+ *((char*)virtual) = '/';
+ ed_internal((char*)virtual,virtual);
+#endif /* SHOPT_MULTIBYTE */
+ }
+
+ if( mode == 'N' )
+ new_direction = -vp->direction;
+ else
+ new_direction = vp->direction;
+
+
+ /*** now search ***/
+
+ oldcurhline = curhline;
+#if SHOPT_MULTIBYTE
+ ed_external(virtual,(char*)virtual);
+#endif /* SHOPT_MULTIBYTE */
+ if(mode=='?' && (i=curline_search(vp,((char*)virtual)+1))>=0)
+ {
+ location.hist_command = curhline;
+ location.hist_char = i;
+ }
+ else
+ {
+ i = INVALID;
+ if( new_direction==1 && curhline >= histmax )
+ curhline = histmin + 1;
+ location = hist_find(sh.hist_ptr,((char*)virtual)+1, curhline, 1, new_direction);
+ }
+ cur_virt = i;
+ strncpy(lsearch, ((char*)virtual)+1, SEARCHSIZE);
+ if( (curhline=location.hist_command) >=0 )
+ {
+ vp->ocur_virt = INVALID;
+ return(GOOD);
+ }
+
+ /*** could not find matching line ***/
+
+ curhline = oldcurhline;
+ return(BAD);
+}
+
+/*{ SYNC_CURSOR()
+ *
+ * This routine will move the physical cursor to the same
+ * column as the virtual cursor.
+ *
+}*/
+
+static void sync_cursor(register Vi_t *vp)
+{
+ register int p;
+ register int v;
+ register int c;
+ int new_phys;
+
+ if( cur_virt == INVALID )
+ return;
+
+ /*** find physical col that corresponds to virtual col ***/
+
+ new_phys = 0;
+ if(vp->first_wind==vp->ofirst_wind && cur_virt>vp->ocur_virt && vp->ocur_virt!=INVALID)
+ {
+ /*** try to optimize search a little ***/
+ p = vp->ocur_phys + 1;
+#if SHOPT_MULTIBYTE
+ while(physical[p]==MARKER)
+ p++;
+#endif /* SHOPT_MULTIBYTE */
+ v = vp->ocur_virt + 1;
+ }
+ else
+ {
+ p = 0;
+ v = 0;
+ }
+ for(; v <= last_virt; ++p, ++v)
+ {
+#if SHOPT_MULTIBYTE
+ int d;
+ c = virtual[v];
+ if((d = mbwidth(c)) > 1)
+ {
+ if( v != cur_virt )
+ p += (d-1);
+ }
+ else if(!iswprint(c))
+#else
+ c = virtual[v];
+ if(!isprint(c))
+#endif /* SHOPT_MULTIBYTE */
+ {
+ if( c == '\t' )
+ {
+ p -= ((p+editb.e_plen)%TABSIZE);
+ p += (TABSIZE-1);
+ }
+ else
+ {
+ ++p;
+ }
+ }
+ if( v == cur_virt )
+ {
+ new_phys = p;
+ break;
+ }
+ }
+
+ if( new_phys < vp->first_wind || new_phys >= vp->first_wind + w_size )
+ {
+ /*** asked to move outside of window ***/
+
+ window[0] = '\0';
+ refresh(vp,CONTROL);
+ return;
+ }
+
+ cursor(vp,new_phys);
+ ed_flush(vp->ed);
+ vp->ocur_phys = cur_phys;
+ vp->ocur_virt = cur_virt;
+ vp->o_v_char = virtual[vp->ocur_virt];
+
+ return;
+}
+
+/*{ TEXTMOD( command, mode )
+ *
+ * Modify text operations.
+ *
+ * mode != 0, repeat previous operation
+ *
+}*/
+
+static int textmod(register Vi_t *vp,register int c, int mode)
+{
+ register int i;
+ register genchar *p = vp->lastline;
+ register int trepeat = vp->repeat;
+ genchar *savep;
+
+ if(mode && (fold(vp->lastmotion)=='F' || fold(vp->lastmotion)=='T'))
+ vp->lastmotion = ';';
+
+ if( fold(c) == 'P' )
+ {
+ /*** change p from lastline to yankbuf ***/
+ p = yankbuf;
+ }
+
+addin:
+ switch( c )
+ {
+ /***** Input commands *****/
+
+#if KSHELL
+ case '\t':
+ if(vp->ed->e_tabcount!=1)
+ return(BAD);
+ c = '=';
+ case '*': /** do file name expansion in place **/
+ case '\\': /** do file name completion in place **/
+ if( cur_virt == INVALID )
+ return(BAD);
+ case '=': /** list file name expansions **/
+ save_v(vp);
+ i = last_virt;
+ ++last_virt;
+ mode = cur_virt-1;
+ virtual[last_virt] = 0;
+ if(ed_expand(vp->ed,(char*)virtual, &cur_virt, &last_virt, c, vp->repeat_set?vp->repeat:-1)<0)
+ {
+ if(vp->ed->e_tabcount)
+ {
+ vp->ed->e_tabcount=2;
+ ed_ungetchar(vp->ed,'\t');
+ --last_virt;
+ return(APPEND);
+ }
+ last_virt = i;
+ ed_ringbell();
+ }
+ else if(c == '=' && !vp->repeat_set)
+ {
+ last_virt = i;
+ vp->nonewline++;
+ ed_ungetchar(vp->ed,cntl('L'));
+ return(GOOD);
+ }
+ else
+ {
+ --cur_virt;
+ --last_virt;
+ vp->ocur_virt = MAXCHAR;
+ if(c=='=' || (mode<cur_virt && (virtual[cur_virt]==' ' || virtual[cur_virt]=='/')))
+ vp->ed->e_tabcount = 0;
+ return(APPEND);
+ }
+ break;
+
+ case '@': /** macro expansion **/
+ if( mode )
+ c = vp->lastmacro;
+ else
+ if((c=getrchar(vp))==ESC)
+ return(GOOD);
+ if(!inmacro)
+ vp->lastmacro = c;
+ if(ed_macro(vp->ed,c))
+ {
+ save_v(vp);
+ inmacro++;
+ return(GOOD);
+ }
+ ed_ringbell();
+ return(BAD);
+
+#endif /* KSHELL */
+ case '_': /** append last argument of prev command **/
+ save_v(vp);
+ {
+ genchar tmpbuf[MAXLINE];
+ if(vp->repeat_set==0)
+ vp->repeat = -1;
+ p = (genchar*)hist_word((char*)tmpbuf,MAXLINE,vp->repeat);
+#if !KSHELL
+ if(p==0)
+ {
+ ed_ringbell();
+ break;
+ }
+#endif /* KSHELL */
+#if SHOPT_MULTIBYTE
+ ed_internal((char*)p,tmpbuf);
+ p = tmpbuf;
+#endif /* SHOPT_MULTIBYTE */
+ i = ' ';
+ do
+ {
+ append(vp,i,APPEND);
+ }
+ while(i = *p++);
+ return(APPEND);
+ }
+
+ case 'A': /** append to end of line **/
+ cur_virt = last_virt;
+ sync_cursor(vp);
+
+ case 'a': /** append **/
+ if( fold(mode) == 'A' )
+ {
+ c = 'p';
+ goto addin;
+ }
+ save_v(vp);
+ if( cur_virt != INVALID )
+ {
+ first_virt = cur_virt + 1;
+ cursor(vp,cur_phys + 1);
+ ed_flush(vp->ed);
+ }
+ return(APPEND);
+
+ case 'I': /** insert at beginning of line **/
+ cur_virt = first_virt;
+ sync_cursor(vp);
+
+ case 'i': /** insert **/
+ if( fold(mode) == 'I' )
+ {
+ c = 'P';
+ goto addin;
+ }
+ save_v(vp);
+ if( cur_virt != INVALID )
+ {
+ vp->o_v_char = virtual[cur_virt];
+ first_virt = cur_virt--;
+ }
+ return(INSERT);
+
+ case 'C': /** change to eol **/
+ c = '$';
+ goto chgeol;
+
+ case 'c': /** change **/
+ if( mode )
+ c = vp->lastmotion;
+ else
+ c = getcount(vp,ed_getchar(vp->ed,-1));
+chgeol:
+ vp->lastmotion = c;
+ if( c == 'c' )
+ {
+ del_line(vp,GOOD);
+ return(APPEND);
+ }
+
+ if(!delmotion(vp, c, 'c'))
+ return(BAD);
+
+ if( mode == 'c' )
+ {
+ c = 'p';
+ trepeat = 1;
+ goto addin;
+ }
+ first_virt = cur_virt + 1;
+ return(APPEND);
+
+ case 'D': /** delete to eol **/
+ c = '$';
+ goto deleol;
+
+ case 'd': /** delete **/
+ if( mode )
+ c = vp->lastmotion;
+ else
+ c = getcount(vp,ed_getchar(vp->ed,-1));
+deleol:
+ vp->lastmotion = c;
+ if( c == 'd' )
+ {
+ del_line(vp,GOOD);
+ break;
+ }
+ if(!delmotion(vp, c, 'd'))
+ return(BAD);
+ if( cur_virt < last_virt )
+ ++cur_virt;
+ break;
+
+ case 'P':
+ if( p[0] == '\0' )
+ return(BAD);
+ if( cur_virt != INVALID )
+ {
+ i = virtual[cur_virt];
+ if(!is_print(i))
+ vp->ocur_virt = INVALID;
+ --cur_virt;
+ }
+
+ case 'p': /** print **/
+ if( p[0] == '\0' )
+ return(BAD);
+
+ if( mode != 's' && mode != 'c' )
+ {
+ save_v(vp);
+ if( c == 'P' )
+ {
+ /*** fix stored cur_virt ***/
+ ++vp->u_column;
+ }
+ }
+ if( mode == 'R' )
+ mode = REPLACE;
+ else
+ mode = APPEND;
+ savep = p;
+ for(i=0; i<trepeat; ++i)
+ {
+ while(c= *p++)
+ append(vp,c,mode);
+ p = savep;
+ }
+ break;
+
+ case 'R': /* Replace many chars **/
+ if( mode == 'R' )
+ {
+ c = 'P';
+ goto addin;
+ }
+ save_v(vp);
+ if( cur_virt != INVALID )
+ first_virt = cur_virt;
+ return(REPLACE);
+
+ case 'r': /** replace **/
+ if( mode )
+ c = *p;
+ else
+ if((c=getrchar(vp))==ESC)
+ return(GOOD);
+ *p = c;
+ save_v(vp);
+ while(trepeat--)
+ replace(vp,c, trepeat!=0);
+ return(GOOD);
+
+ case 'S': /** Substitute line - cc **/
+ c = 'c';
+ goto chgeol;
+
+ case 's': /** substitute **/
+ save_v(vp);
+ cdelete(vp,vp->repeat, BAD);
+ if( mode )
+ {
+ c = 'p';
+ trepeat = 1;
+ goto addin;
+ }
+ first_virt = cur_virt + 1;
+ return(APPEND);
+
+ case 'Y': /** Yank to end of line **/
+ c = '$';
+ goto yankeol;
+
+ case 'y': /** yank thru motion **/
+ if( mode )
+ c = vp->lastmotion;
+ else
+ c = getcount(vp,ed_getchar(vp->ed,-1));
+yankeol:
+ vp->lastmotion = c;
+ if( c == 'y' )
+ {
+ gencpy(yankbuf, virtual);
+ }
+ else if(!delmotion(vp, c, 'y'))
+ {
+ return(BAD);
+ }
+ break;
+
+ case 'x': /** delete repeat chars forward - dl **/
+ c = 'l';
+ goto deleol;
+
+ case 'X': /** delete repeat chars backward - dh **/
+ c = 'h';
+ goto deleol;
+
+ case '~': /** invert case and advance **/
+ if( cur_virt != INVALID )
+ {
+ save_v(vp);
+ i = INVALID;
+ while(trepeat-->0 && i!=cur_virt)
+ {
+ i = cur_virt;
+ c = virtual[cur_virt];
+#if SHOPT_MULTIBYTE
+ if((c&~STRIP)==0)
+#endif /* SHOPT_MULTIBYTE */
+ if( isupper(c) )
+ c = tolower(c);
+ else if( islower(c) )
+ c = toupper(c);
+ replace(vp,c, 1);
+ }
+ return(GOOD);
+ }
+ else
+ return(BAD);
+
+ default:
+ return(BAD);
+ }
+ refresh(vp,CONTROL);
+ return(GOOD);
+}
+
+
+#if SHOPT_MULTIBYTE
+ static int _isalph(register int v)
+ {
+#ifdef _lib_iswalnum
+ return(iswalnum(v) || v=='_');
+#else
+ return((v&~STRIP) || isalnum(v) || v=='_');
+#endif
+ }
+
+
+ static int _isblank(register int v)
+ {
+ return((v&~STRIP)==0 && isspace(v));
+ }
+
+ static int _ismetach(register int v)
+ {
+ return((v&~STRIP)==0 && ismeta(v));
+ }
+
+#endif /* SHOPT_MULTIBYTE */
+
+/*
+ * get a character, after ^V processing
+ */
+static int getrchar(register Vi_t *vp)
+{
+ register int c;
+ if((c=ed_getchar(vp->ed,1))== usrlnext)
+ c = ed_getchar(vp->ed,2);
+ return(c);
+}
diff --git a/usr/src/lib/libshell/common/features/cmds b/usr/src/lib/libshell/common/features/cmds
new file mode 100644
index 0000000000..106198caa1
--- /dev/null
+++ b/usr/src/lib/libshell/common/features/cmds
@@ -0,0 +1 @@
+cmd newgrp,test,id,wc,cut,logname,universe,pfexec,tput
diff --git a/usr/src/lib/libshell/common/features/dynamic b/usr/src/lib/libshell/common/features/dynamic
new file mode 100644
index 0000000000..1835d41282
--- /dev/null
+++ b/usr/src/lib/libshell/common/features/dynamic
@@ -0,0 +1,12 @@
+hdr,sys dlfcn,dl,ldr,dll
+hdr dlldefs
+lib dlopen,shl_load,loadbind,dllload,dllfind
+cat{
+ #if !defined(SHOPT_FS_3D) && ( _lib_dllfind || _lib_dlopen || _lib_shl_load || _lib_loadbind )
+ # define SHOPT_FS_3D 1
+ #endif /* !SHOPT_FS_3D */
+ #if SHOPT_FS_3D
+ # undef mount
+ # include <fs3d.h>
+ #endif /* SHOPT_FS_3D */
+}end
diff --git a/usr/src/lib/libshell/common/features/externs b/usr/src/lib/libshell/common/features/externs
new file mode 100644
index 0000000000..58701306be
--- /dev/null
+++ b/usr/src/lib/libshell/common/features/externs
@@ -0,0 +1,12 @@
+set prototyped
+hdr nc,exec_attr
+mem exception.name,_exception.name math.h
+lib setreuid,setregid,nice,sigflag,fork,spawnveg
+lib pathnative,pathposix,uwin_path,uwin_unpath,fts_notify
+lib fchdir
+
+reference unistd.h
+
+extern nice int (int)
+extern setreuid int (uid_t,uid_t)
+extern setregid int (gid_t,gid_t)
diff --git a/usr/src/lib/libshell/common/features/locale b/usr/src/lib/libshell/common/features/locale
new file mode 100644
index 0000000000..ee9bcae6fe
--- /dev/null
+++ b/usr/src/lib/libshell/common/features/locale
@@ -0,0 +1,25 @@
+hdr locale,wchar
+lib locale,localeconv,wctype,iswctype,iswblank
+cat{
+ #if _PACKAGE_ast
+ # undef _hdr_locale
+ # define _hdr_locale 1
+ #else
+ # ifdef _hdr_locale
+ # include <locale.h>
+ # ifndef LC_MESSAGES
+ # define LC_MESSAGES LC_ALL
+ # endif /* LC_MESSAGES */
+ # endif /* _hdr_locale */
+ #endif /* _PACKAGE_ast */
+ #ifdef _hdr_locale
+ # ifdef _lib_localeconv
+ static struct lconv *lp;
+ # define GETDECIMAL(x) (((lp=localeconv()) && lp->decimal_point && *lp->decimal_point) ? *lp->decimal_point : '.' )
+ # else
+ # define GETDECIMAL(x) ('.')
+ # endif /* _lib_localeconv */
+ #else
+ # define GETDECIMAL(x) ('.')
+ #endif /* _hdr_locale */
+}end
diff --git a/usr/src/lib/libshell/common/features/math b/usr/src/lib/libshell/common/features/math
new file mode 100644
index 0000000000..2a720e673c
--- /dev/null
+++ b/usr/src/lib/libshell/common/features/math
@@ -0,0 +1,4 @@
+lib,npt absl,acosl,acoshl,asinl,asinhl,atanl,atan2l,expl,cosl,coshl math.h
+lib,npt fabsl,powl,hypotl,fmodl,logl,sinl,sinhl,sqrtl,tanl,tanhl math.h
+lib,npt strtold,isinf,isinfl,isnan,isnanl,isnormal,isnormall math.h
+lib,npt finite,finitel,isfinite math.h
diff --git a/usr/src/lib/libshell/common/features/math.sh b/usr/src/lib/libshell/common/features/math.sh
new file mode 100644
index 0000000000..1e407e57f7
--- /dev/null
+++ b/usr/src/lib/libshell/common/features/math.sh
@@ -0,0 +1,158 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+: generate the ksh math builtin table
+: include math.tab
+
+# @(#)math.sh (AT&T Research) 2007-02-02
+
+command=$0
+iffeflags="-n -v -F ast_standards.h"
+iffehdrs="math.h ieeefp.h"
+iffelibs="-lm"
+table=/dev/null
+
+eval $1
+shift
+table=$1
+
+names=
+tests=
+
+: read the table
+
+exec < $table
+while read type args name aka comment
+do case $type in
+ [fi]) names="$names $name"
+ tests="$tests,$name,${name}l"
+ eval TYPE_$name=$type ARGS_$name=$args AKA_$name=$aka
+ ;;
+ esac
+done
+
+: check the math library
+
+eval `iffe $iffeflags -c "$cc" - typ long.double : lib $tests $iffehdrs $iffelibs 2>&$stderr`
+lib=
+for name in $names
+do eval x='$'_lib_${name}l y='$'_lib_${name}
+ case $x in
+ 1) lib="$lib,${name}l" ;;
+ esac
+ case $y in
+ 1) case $x in
+ '') lib="$lib,${name}" ;;
+ esac
+ ;;
+ esac
+done
+eval `iffe $iffeflags -c "$cc" - dat,npt,mac $lib $iffehdrs $iffelibs 2>&$stderr`
+
+cat <<!
+#pragma prototyped
+
+/* : : generated by $command from $table : : */
+
+typedef Sfdouble_t (*Math_f)(Sfdouble_t,...);
+
+!
+echo "#include <ast_standards.h>"
+echo "#include <math.h>"
+case $_hdr_ieeefp in
+1) echo "#include <ieeefp.h>"
+ echo
+ ;;
+esac
+
+: generate the intercept functions and table entries
+
+nl='
+'
+ht=' '
+tab=
+for name in $names
+do eval x='$'_lib_${name}l y='$'_lib_${name} r='$'TYPE_${name} a='$'ARGS_${name} aka='$'AKA_${name}
+ case $x:$y in
+ 1:*) f=${name}l
+ t=Sfdouble_t
+ local=
+ ;;
+ *:1) f=${name}
+ t=double
+ local=$_typ_long_double
+ ;;
+ *) continue
+ ;;
+ esac
+ eval n='$'_npt_$f m='$'_mac_$f d='$'_dat_$f
+ case $r in
+ i) L=int r=int R=1 ;;
+ *) L=Sfdouble_t r=$t R=0 ;;
+ esac
+ case $d:$m:$n in
+ 1:*:*|*:1:*)
+ ;;
+ *:*:1) code="extern $r $f("
+ sep=
+ for p in 1 2 3 4 5 6 7
+ do code="$code${sep}$t"
+ case $a in
+ $p) break ;;
+ esac
+ sep=","
+ done
+ code="$code);"
+ echo "$code"
+ ;;
+ esac
+ case $local:$m:$n:$d in
+ 1:*:*:*|*:1:*:*|*:*::)
+ args=
+ code="static $L local_$f("
+ sep=
+ for p in 1 2 3 4 5 6 7 8 9
+ do args="$args${sep}a$p"
+ code="$code${sep}Sfdouble_t a$p"
+ case $a in
+ $p) break ;;
+ esac
+ sep=","
+ done
+ code="$code){return $f($args);}"
+ echo "$code"
+ f=local_$f
+ ;;
+ esac
+ for x in $name $aka
+ do tab="$tab$nl$ht\"\\0${R}${a}${x}\",$ht(Math_f)$f,"
+ done
+done
+tab="$tab$nl$ht\"\",$ht$ht(Math_f)0"
+
+cat <<!
+
+/*
+ * first byte is two-digit octal number. Last digit is number of args
+ * first digit is 0 if return value is double, 1 for integer
+ */
+const struct mathtab shtab_math[] =
+{$tab
+};
+!
diff --git a/usr/src/lib/libshell/common/features/options b/usr/src/lib/libshell/common/features/options
new file mode 100644
index 0000000000..9c713d150e
--- /dev/null
+++ b/usr/src/lib/libshell/common/features/options
@@ -0,0 +1,46 @@
+# SHOPT_* option probe
+
+tst cross{
+ : check for shell magic #!
+ cat > /tmp/file$$ <<!
+ #! /bin/echo
+ exit 1
+ !
+ chmod 755 /tmp/file$$
+ if /tmp/file$$ > /dev/null
+ then echo "#define SHELLMAGIC 1"
+ fi
+ rm -f /tmp/file$$
+
+ option() # name value
+ {
+ case $2 in
+ 0) echo "#ifndef SHOPT_$1"
+ echo "# define SHOPT_$1 1"
+ echo "#endif"
+ ;;
+ *) echo "#undef SHOPT_$1"
+ ;;
+ esac
+ }
+
+ test -d /dev/fd
+ option DEVFD $?
+ case `echo a | tr a '\012' | wc -l` in
+ *1*) option MULTIBYTE 0 ;;
+ esac
+ test -x /bin/pfexec -o -x /usr/bin/pfexec
+ option PFSH $?
+ /bin/test ! -l . 2> /dev/null
+ option TEST_L $?
+ test -f /etc/ksh.kshrc -o -f /etc/bash.bashrc &&
+ option SYSRC 0
+ test -f /bin/universe && univ=`/bin/universe` > /dev/null 2>&1 -a ucb = "$univ"
+ option UCB $?
+}end
+
+cat{
+ #if !_PACKAGE_ast && ( (MB_LEN_MAX-1)<=0 || !defined(_lib_mbtowc) )
+ # undef SHOPT_MULTIBYTE
+ #endif
+}end
diff --git a/usr/src/lib/libshell/common/features/poll b/usr/src/lib/libshell/common/features/poll
new file mode 100644
index 0000000000..7211a47806
--- /dev/null
+++ b/usr/src/lib/libshell/common/features/poll
@@ -0,0 +1,149 @@
+hdr,sys poll,socket,netinet/in
+lib select,poll,socket
+lib htons,htonl sys/types.h sys/socket.h netinet/in.h
+lib getaddrinfo sys/types.h sys/socket.h netdb.h
+typ fd_set sys/socket.h sys/select.h
+tst pipe_socketpair note{ use socketpair() for peekable pipe() }end execute{
+ #include <ast.h>
+ #include <signal.h>
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ static void handler(sig)
+ int sig;
+ {
+ _exit(0);
+ }
+ int main()
+ {
+ int n;
+ int pfd[2];
+ int sfd[2];
+ char buf[256];
+ pid_t pid;
+ static char msg[] = "hello world\n";
+ close(0);
+ if (pipe(pfd) < 0 ||
+ socketpair(AF_UNIX, SOCK_STREAM, 0, sfd) < 0 ||
+ shutdown(sfd[0], 1) < 0 ||
+ shutdown(sfd[1], 0) < 0)
+ return(1);
+ if ((pid = fork()) < 0)
+ return(1);
+ if (pid)
+ {
+ close(pfd[1]);
+ close(sfd[1]);
+ wait(&n);
+ if (sfpkrd(pfd[0], buf, sizeof(buf), '\n', -1, 1) >= 0 ||
+ sfpkrd(sfd[0], buf, sizeof(buf), '\n', -1, 1) < 0)
+ return(1);
+ }
+ else
+ {
+ close(pfd[0]);
+ close(sfd[0]);
+ write(pfd[1], msg, sizeof(msg) - 1);
+ write(sfd[1], msg, sizeof(msg) - 1);
+ return(0);
+ }
+ close(pfd[0]);
+ close(sfd[0]);
+ signal(SIGPIPE, handler);
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, sfd) < 0 ||
+ shutdown(sfd[0], 1) < 0 ||
+ shutdown(sfd[1], 0) < 0)
+ return(1);
+ close(sfd[0]);
+ write(sfd[1], msg, sizeof(msg) - 1);
+ return(1);
+ }
+}end
+tst socketpair_devfd note{ /dev/fd/N handles socketpair() }end execute{
+ #include <ast.h>
+ #include <fs3d.h>
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ int main()
+ {
+ int devfd;
+ int n;
+ int sfd[2];
+ fs3d(FS3D_OFF);
+ close(0);
+ open("/dev/null", O_RDONLY);
+ if ((n = open("/dev/fd/0", O_RDONLY)) < 0)
+ return(1);
+ close(n);
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, sfd) < 0 ||
+ shutdown(sfd[0], 1) < 0 ||
+ shutdown(sfd[1], 0) < 0)
+ return(1);
+ close(0);
+ dup(sfd[0]);
+ close(sfd[0]);
+ if ((n = open("/dev/fd/0", O_RDONLY)) < 0)
+ return(1);
+ return(0);
+ }
+}end
+tst socketpair_shutdown_mode note{ fchmod() after socketpair() shutdown() }end execute{
+ #include <ast.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <sys/socket.h>
+ int main()
+ {
+ int sfd[2];
+ struct stat st0;
+ struct stat st1;
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, sfd) < 0 ||
+ shutdown(sfd[0], 1) < 0 ||
+ shutdown(sfd[1], 0) < 0)
+ return(1);
+ if (fstat(sfd[0], &st0) < 0 || fstat(sfd[1], &st1) < 0)
+ return(1);
+ if ((st0.st_mode & (S_IRUSR|S_IWUSR)) == S_IRUSR &&
+ (st1.st_mode & (S_IRUSR|S_IWUSR)) == S_IWUSR)
+ return(1);
+ if (fchmod(sfd[0], S_IRUSR) < 0 ||
+ fstat(sfd[0], &st0) < 0 ||
+ (st0.st_mode & (S_IRUSR|S_IWUSR)) != S_IRUSR)
+ return(1);
+ if (fchmod(sfd[1], S_IWUSR) < 0 ||
+ fstat(sfd[1], &st1) < 0 ||
+ (st1.st_mode & (S_IRUSR|S_IWUSR)) != S_IWUSR)
+ return(1);
+ return(0);
+ }
+}end
+cat{
+ #pragma prototyped
+ #ifdef _lib_poll
+ # define poll _SYS_poll
+ #else
+ # undef _hdr_poll
+ # undef _sys_poll
+ #endif /* _lib_poll */
+ #ifdef _hdr_poll
+ # include <poll.h>
+ #else
+ # ifdef _sys_poll
+ # include <sys/poll.h>
+ # endif /* _sys_poll */
+ #endif /* _hdr_poll */
+ #ifdef _lib_poll
+ # undef poll
+ extern int poll(struct pollfd*,unsigned long,int);
+ #endif /* _lib_poll */
+ #ifdef _lib_select
+ # ifndef FD_ZERO
+ # define FD_ZERO(x) (*(x)=0)
+ # endif /* FD_ZERO */
+ # ifndef FD_SET
+ # define FD_SET(n,x) (*(x)|=(1L<<(n)))
+ # endif /* FD_SET */
+ # ifndef _typ_fd_set
+ typedef long fd_set;
+ # endif /*_typ_fd_set */
+ #endif /* _lib_select */
+}end
diff --git a/usr/src/lib/libshell/common/features/rlimits b/usr/src/lib/libshell/common/features/rlimits
new file mode 100644
index 0000000000..a9e4294ed1
--- /dev/null
+++ b/usr/src/lib/libshell/common/features/rlimits
@@ -0,0 +1,3 @@
+hdr,sys resource,vlimit
+lib getrlimit,ulimit,vlimit
+typ rlim_t sys/resource.h
diff --git a/usr/src/lib/libshell/common/features/setjmp b/usr/src/lib/libshell/common/features/setjmp
new file mode 100644
index 0000000000..a3504ee3e2
--- /dev/null
+++ b/usr/src/lib/libshell/common/features/setjmp
@@ -0,0 +1,18 @@
+lib sigsetjmp,_setjmp,_longjmp
+typ sigjmp_buf setjmp.h
+cat{
+ #undef sigsetjmp
+ #undef siglongjmp
+ #undef sigjmp_buf
+ #define sigjmp_buf jmp_buf
+ #ifdef _lib__setjmp
+ # define sigsetjmp(a,b) _setjmp(a)
+ #else
+ # define sigsetjmp(a,b) setjmp(a)
+ #endif /* _lib__setjmp */
+ #ifdef _lib__longjmp
+ # define siglongjmp(a,b) _longjmp(a,b)
+ #else
+ # define siglongjmp(a,b) longjmp(a,b)
+ #endif /* _lib__longjmp */
+}end
diff --git a/usr/src/lib/libshell/common/features/sigfeatures b/usr/src/lib/libshell/common/features/sigfeatures
new file mode 100644
index 0000000000..1999dc11bb
--- /dev/null
+++ b/usr/src/lib/libshell/common/features/sigfeatures
@@ -0,0 +1,49 @@
+lib sigblock,sigrelse,sigsetmask,sigprocmask,sigvec
+typ sigset_t ast.h signal.h
+mem sigvec.sv_mask signal.h
+cat{
+ #ifndef _mem_sigvec_sv_mask
+ # undef _lib_sigvec
+ #endif
+ #ifdef _lib_sigprocmask
+ # define sh_sigaction(s,action) do { sigset_t ss;\
+ sigemptyset(&ss);\
+ sigaddset(&ss,(s));\
+ sigprocmask(action,&ss,0); \
+ }while(0)
+ # define sigrelease(s) sh_sigaction(s,SIG_UNBLOCK)
+ # define sigblock(s) sh_sigaction(s,SIG_BLOCK)
+ # define sig_begin() sh_sigaction(0,SIG_SETMASK)
+ #else
+ # ifndef _lib_sigblock
+ # define sigblock(s)
+ # endif
+ # ifdef _lib_sigsetmask
+ # define sigrelease(s) sigsetmask(0)
+ # define sig_begin() sigsetmask(0)
+ # else
+ # ifdef _lib_sigrelse
+ # define sigrelease sigrelse
+ # define sig_begin()
+ # else
+ # define sig_begin() (0)
+ # define sigrelease(s) (0)
+ # endif /* _lib_sigrelse */
+ # endif /* _lib_sigsetmask */
+ #endif /* _lib_sigprocmask */
+}end
+tst output{
+ #include <signal.h>
+ int main()
+ {
+ #ifdef SIGRTMIN
+ printf("#undef _SIGRTMIN\n");
+ printf("#define _SIGRTMIN %d\n", SIGRTMIN);
+ #endif
+ #ifdef SIGRTMAX
+ printf("#undef _SIGRTMAX\n");
+ printf("#define _SIGRTMAX %d\n", SIGRTMAX);
+ #endif
+ return 0;
+ }
+}end
diff --git a/usr/src/lib/libshell/common/features/time b/usr/src/lib/libshell/common/features/time
new file mode 100644
index 0000000000..f8d2129841
--- /dev/null
+++ b/usr/src/lib/libshell/common/features/time
@@ -0,0 +1,35 @@
+hdr utime
+lib gettimeofday,setitimer
+mem timeval.tv_usec sys/time.h
+tst lib_2_timeofday note{ 2 arg gettimeofday() }end link{
+ #include <sys/types.h>
+ #include <sys/time.h>
+ int main()
+ {
+ struct timeval tv;
+ struct timezone tz;
+ return gettimeofday(&tv, &tz);
+ }
+}end
+tst lib_1_timeofday note{ 1 arg gettimeofday() }end link{
+ #include <sys/types.h>
+ #include <sys/time.h>
+ int main()
+ {
+ struct timeval tv;
+ return gettimeofday(&tv);
+ }
+}end
+cat{
+ #undef _def_time
+ #include <times.h>
+ #define _def_time 1
+ #undef timeofday
+ #if _lib_2_timeofday
+ #define timeofday(p) gettimeofday(p,(struct timezone*)0)
+ #else
+ #if _lib_1_timeofday
+ #define timeofday(p) gettimeofday(p)
+ #endif
+ #endif
+}end
diff --git a/usr/src/lib/libshell/common/features/ttys b/usr/src/lib/libshell/common/features/ttys
new file mode 100644
index 0000000000..693dbd1be1
--- /dev/null
+++ b/usr/src/lib/libshell/common/features/ttys
@@ -0,0 +1,3 @@
+hdr termios,termio,sgtty
+sys termios,termio,ioctl,bsdtty,nttyio,filio
+lib tcgetattr,tcgetpgrp termios.h
diff --git a/usr/src/lib/libshell/common/fun/dirs b/usr/src/lib/libshell/common/fun/dirs
new file mode 100644
index 0000000000..0329970f3b
--- /dev/null
+++ b/usr/src/lib/libshell/common/fun/dirs
@@ -0,0 +1,108 @@
+#
+# DIRECTORY MANIPULATION FUNCTIONS, REPLACES CD
+#
+# Uses global parameters _push_max _push_top _push_stack
+integer _push_max=${CDSTACK-32} _push_top=${CDSTACK-32}
+unalias cd
+alias cd=_cd
+# Display directory stack -- $HOME displayed as ~
+function dirs
+{
+ typeset dir="${PWD#$HOME/}"
+ case $dir in
+ $HOME)
+ dir=\~
+ ;;
+ /*) ;;
+ *) dir=\~/$dir
+ esac
+ PS3=
+ select i in "$dir" "${_push_stack[@]}"
+ do :
+ done < /dev/null
+}
+
+# Change directory and put directory on front of stack
+function _cd
+{
+ typeset dir=
+ integer n=0 type=4
+ case $1 in
+ -|-1|2) # \cd -
+ n=_push_top type=1
+ ;;
+ -[1-9]*([0-9])) # \cd -n
+ n=_push_top+${1#-}-1 type=2
+ ;;
+ 1) # keep present directory
+ print -r - "$PWD"
+ return
+ ;;
+ [1-9]*([0-9])) # \cd n
+ n=_push_top+${1}-2 type=2
+ ;;
+ *) if ((_push_top <= 0))
+ then type=3 n=_push_max
+ fi
+ esac
+ if ((type<3))
+ then if ((n >= _push_max+1))
+ then print -u2 cd: Directory stack not that deep.
+ return 1
+ else dir=${_push_stack[n]}
+ fi
+ fi
+ case $dir in
+ \~*) dir=$HOME${dir#\~}
+ esac
+ \cd "${dir:-$@}" >| /dev/null || return 1
+ dir=${OLDPWD#$HOME/}
+ case $TERM in
+ 630)
+ print "\033[?${#PWD};2v$PWD\c"
+ ;;
+ esac
+ case $dir in
+ $HOME)
+ dir=\~
+ ;;
+ /*) ;;
+ *) dir=\~/$dir
+ esac
+ case $type in
+ 1) # swap first two elements
+ _push_stack[_push_top]=$dir
+ ;;
+ 2|3) # put $dir on top and shift down by one until top
+ integer i=_push_top
+ for dir in "$dir" "${_push_stack[@]}"
+ do ((i > n)) && break
+ _push_stack[i]=$dir
+ i=i+1
+ done
+ ;;
+ 4) # push name
+ _push_stack[_push_top=_push_top-1]=$dir
+ ;;
+ esac
+ print -r - "$PWD"
+}
+
+# Menu driven change directory command
+function mcd
+{
+ typeset dir="${PWD#$HOME/}"
+ case $dir in
+ $HOME)
+ dir=\~
+ ;;
+ /*) ;;
+ *) dir=\~/$dir
+ esac
+ PS3='Select by number or enter a name: '
+ select dir in "$dir" "${_push_stack[@]}"
+ do if _cd $REPLY
+ then return
+ fi
+ done
+}
diff --git a/usr/src/lib/libshell/common/fun/gnaw b/usr/src/lib/libshell/common/fun/gnaw
new file mode 100644
index 0000000000..159d420207
--- /dev/null
+++ b/usr/src/lib/libshell/common/fun/gnaw
@@ -0,0 +1,1029 @@
+#!/bin/ksh93
+
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+#
+# gnaw - a simple ksh93 technology demo
+#
+# Note that this script has been written with the main idea to show
+# many of ksh93's new features (comparing to ksh88/bash) and not
+# as an example of efficient&&clean script code.
+#
+
+# Solaris needs /usr/xpg4/bin/ because the tools in /usr/bin are not POSIX-conformant
+export PATH=/usr/xpg4/bin:/bin:/usr/bin
+
+function print_setcursorpos
+{
+ print -n "${vtcode[cup_${1}_${2}]}"
+}
+
+function beep
+{
+ ${quiet} || print -n "${vtcode["bel"]}"
+}
+
+function fatal_error
+{
+ print -u 2 "${progname}: $@"
+ exit 1
+}
+
+function print_levelmap
+{
+ integer screen_y_offset=$1
+ integer start_y_pos=$2 # start at this line in the map
+ integer max_numlines=$3 # maximum lines we're allowed to render
+ integer x
+ integer y
+ line=""
+
+ print_setcursorpos 0 ${screen_y_offset}
+
+ for (( y=start_y_pos; (y-start_y_pos) < max_numlines && y < levelmap["max_y"] ; y++ )) ; do
+ line=""
+ for (( x=0 ; x < levelmap["max_x"] ; x++ )) ; do
+ line+="${levelmap["${x}_${y}"]}"
+ done
+
+ print "${line} "
+ done
+
+ # print lines filled with spaces for each line not filled
+ # by the level map
+ line="${vtcode["spaceline"]:0:${levelmap["max_x"]}}"
+ for (( ; (y-start_y_pos) < max_numlines ; y++ )) ; do
+ print "${line} "
+ done
+}
+
+function level_completed
+{
+ render_buffer="$(
+ print -n "${vtcode["clear"]}"
+ cat <<ENDOFTEXT
+
+ # ###### # # ###### #
+ # # # # # #
+ # ##### # # ##### #
+ # # # # # #
+ # # # # # #
+ ###### ###### ## ###### ######
+
+ (Good job)
+
+ ##### #### # # ######
+ # # # # ## # #
+ # # # # # # # #####
+ # # # # # # # #
+ # # # # # ## #
+ ##### #### # # ######
+
+
+ENDOFTEXT
+
+ printf " SCORE: --> %s <--\n" "${player["score"]}"
+ printf " LIVES: --> %s <--\n" "${player["lives"]}"
+ )"
+ print "${render_buffer}"
+
+ # wait five seconds and swallow any user input
+ for (( i=0 ; i < 50 ; i++ )) ; do
+ read -t 0.1 -n 1 dummy
+ done
+
+ print "Press any key to continue..."
+ # wait five secs or for a key
+ read -t 5 -n 1 dummy
+}
+
+function game_over
+{
+ render_buffer="$(
+ print -n "${vtcode["clear"]}"
+ cat <<ENDOFTEXT
+
+ #### ## # # ######
+ # # # # ## ## #
+ # # # # ## # #####
+ # ### ###### # # #
+ # # # # # # #
+ #### # # # # ######
+
+ (LOSER!)
+
+ #### # # ###### #####
+ # # # # # # #
+ # # # # ##### # #
+ # # # # # #####
+ # # # # # # #
+ #### ## ###### # #
+
+ENDOFTEXT
+
+ printf "\n SCORE: --> %s <--\n" "${player["score"]}"
+ )"
+ print "${render_buffer}"
+
+ # wait five seconds and swallow any user input
+ for (( i=0 ; i < 50 ; i++ )) ; do
+ read -t 0.1 -n 1 dummy
+ done
+
+ print "Press any key to continue..."
+ # wait five secs or for a key
+ read -t 5 -n 1 dummy
+}
+
+function run_logo
+{
+ render_buffer="$(
+ cat <<ENDOFTEXT
+
+ ##### # # # # # ###
+# # ## # # # # # # ###
+# # # # # # # # # ###
+# #### # # # # # # # # #
+# # # # # ####### # # #
+# # # ## # # # # # ###
+ ##### # # # # ## ## ###
+ENDOFTEXT
+ )"
+ print "${vtcode["clear"]}${render_buffer}"
+
+ # wait two seconds and swallow any user input
+ for (( i=0 ; i < 20 ; i++ )) ; do
+ read -t 0.1 -n 1 dummy
+ done
+
+ print "\n (The KornShell 93 maze game)"
+
+ attract_mode
+}
+
+function attract_mode
+{
+(
+ # Now present some info, line-by-line in an endless loop
+ # until the user presses a key (we turn the "magic" return
+ # code for that)
+ magic_return_code=69
+ IFS="|" ; # Make sure we do not swallow whitespaces
+ while true ; do
+ (
+ exec 5<&0
+
+ (cat <<ENDOFTEXT
+
+
+
+
+
+ ################
+ ########################
+ ############################
+ ####### ###### #######
+ ###### ###### ########
+ ####### ###### #######
+ ##############################
+ ##############################
+ ##############################
+ ##############################
+ ##############################
+ ######### ######## #########
+ # #### #### #### #
+
+
+
+
+
+
+ Written by
+
+ Roland Mainz
+ (roland.mainz@nrubsig.org)
+
+
+
+
+
+
+ ##############
+ ########################
+ #################**############
+ ################################
+ ############################
+ ######################
+ ################
+ ######################
+ ############################
+ ################################
+ ##############################
+ ########################
+ ##############
+
+
+
+
+
+
+
+ High scores:
+
+ * 'chin' 8200 pt
+ * 'gisburn' 7900 pt
+ * 'tpenta' 5520 pt
+ * 'kupfer' 5510 pt
+ * 'noname' 5000 pt
+ * 'noname' 4000 pt
+ * 'livad' 3120 pt
+ * 'noname' 3000 pt
+ * 'noname' 2000 pt
+ * 'noname' 1000 pt
+
+ENDOFTEXT
+
+ # clear screen, line-by-line
+ for (( i=0 ; i < LINES ; i++ )) ; do print "" ; done
+ ) | (while read line ; do
+ read -t 0.3 -n 1 c <&5
+ [ "$c" != "" ] && exit ${magic_return_code}
+ print "${line}"
+ done)
+ [ $? -eq ${magic_return_code} ] && exit ${magic_return_code}
+ )
+ [ $? -eq ${magic_return_code} ] && return 0
+
+ sleep 2
+ done
+)
+}
+
+function run_menu
+{
+ integer numlevels=0
+ integer selected_level=0
+
+ # built list of available levels based on the "function levelmap_.*"
+ # built into this script
+ typeset -f | egrep "^function.*levelmap_.*" | sed 's/^function //' |
+ while read l ; do
+ levellist[numlevels]="$l"
+ numlevels+=1
+ done
+
+ # swallow any queued user input (e.g. drain stdin)
+ read -t 0.1 -n 100 dummy
+
+ while true ; do
+ # menu loop with timeout (which switches to "attract mode")
+ while true ; do
+ print -n "${vtcode["clear"]}"
+
+ cat <<ENDOFTEXT
+>======================================\
+> /-\ .--. |
+> | OO| / _.-' .-. .-. .-. .-. |
+> | | \ '-. '-' '-' '-' '-' |
+> ^^^^^ '--' |
+>======\ /================\ .-. |
+> | | | '-' |
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ENDOFTEXT
+ print " GNAW - the ksh93 maze game"
+ print "\n\tMenu:"
+
+ print "\t - [L]evels:"
+ for (( i=0 ; i < numlevels ; i++ )) ; do
+ printf "\t %s %s \n" "$([ $i -eq $selected_level ] && print -n "*" || print -n " ")" "${levellist[i]##levelmap_}"
+ done
+
+ print "\t - Rendering options:"
+ printf "\t [%s] Use [U]nicode\n" "$([ $game_use_unicode -eq 1 ] && print -n "x" || print -n "_")"
+ printf "\t [%s] Use [C]olors\n" "$([ $game_use_colors -eq 1 ] && print -n "x" || print -n "_")"
+
+ print "\t - [S]tart - [Q]uit"
+
+ # wait 30 secs (before we switch to "attract mode")
+ c="" ; read -t 30 -n 1 c
+ case "$c" in
+ 'l') selected_level=$(((selected_level+numlevels+1) % numlevels)) ;;
+ 'L') selected_level=$(((selected_level+numlevels-1) % numlevels)) ;;
+ ~(Ei)s)
+ [ ${game_use_colors} -eq 1 ] && print "${vtcode["bg_black"]}"
+ case "${game_use_colors}${game_use_unicode}" in
+ "00") main_loop "${levellist[selected_level]}" ;;
+ "01") main_loop "${levellist[selected_level]}" | map_filter 0 1 ;;
+ "10") main_loop "${levellist[selected_level]}" | map_filter 1 0 ;;
+ "11") main_loop "${levellist[selected_level]}" | map_filter 1 1 ;;
+ esac
+ print "${vtcode["vtreset"]}"
+ ;;
+ ~(Ei)q|$'\E')
+ # make sure we do not exit on a cursor key (e.g. <esc>[A,B,C,D)
+ read -t 0.01 -n 1 c
+ if [ "$c" = "[" ] ; then
+ # this was a cursor key sequence, just eat the 3rd charcater
+ read -t 0.01 -n 1 c
+ else
+ exit 0
+ fi
+ ;;
+ ~(Ei)u) game_use_unicode=$(((game_use_unicode+2+1) % 2)) ;;
+ ~(Ei)c) game_use_colors=$(((game_use_colors+2+1) % 2)) ;;
+ "") break ;; # timeout, switch to attract mode
+ *) beep ;;
+ esac
+ done
+
+ print -n "${vtcode["clear"]}"
+ attract_mode
+ done
+}
+
+function levelmap_stripes
+{
+cat <<ENDOFLEVEL
+###################################
+#....... ............... P #
+#########..#################..### #
+#########..#################..### #
+#....... .. ..............# #
+############### ################ #
+############### ################ #
+#............. M ..............# #
+##..##################### ###### #
+##..##################### ###### #
+#....... ........... .......# #
+######## ############ ######### #
+# #### ############ ######### #
+# #.................. ......# #
+# ############################### #
+# #
+###################################
+ENDOFLEVEL
+}
+
+function levelmap_livad
+{
+cat <<ENDOFLEVEL
+#####################################################
+# #
+# ############## ############### ################ #
+# #............ P ..............# #
+# .#############################################.# #
+# #.#.......... ............#. #
+# #.#.########## ############### ############.#.# #
+# #...#........ ..........#...# #
+# #...#.#####################################.#.#.# #
+# #...#.#...... ........#...#.# #
+# #.#.#...###### #########################.#.#.#.# #
+# .#.....#.... M ......#...#.#.# #
+# #.#.#...####################### ########.#.#.#.# #
+# #...#.#...... ........#...#.# #
+# #...#.######## ############### ##########.#.#.# #
+# #...#........ ..........#...# #
+# #.#.#########################################.#.# #
+# #.#.......... ............#. #
+# .############ ############### ##############.# #
+# #............ ..............# #
+# ################################################# #
+# #
+#####################################################
+ENDOFLEVEL
+}
+
+function levelmap_classic1
+{
+cat <<ENDOFLEVEL
+#########################
+#.P.........#...........#
+#.####.####.#.####.####.#
+#.# #.# #.#.# #.# #.#
+#.# #.# #.#.# #.# #.#
+#.####.####.#.####.####.#
+#.......................#
+#.####.#.#######.#.####.#
+#.# #.#.# #.#.# #.#
+#.####.#.#######.#.####.#
+#......#....#....#......#
+######.####.#.####.######
+###### # # ######
+###### # ## ## # ######
+###### # # # # ######
+# # M # #
+###### # ####### # ######
+###### # # ######
+###### # ####### # ######
+###### # # # # ######
+######.#.#######.#.######
+#...........#...........#
+#.###.###...#...###.###.#
+#...#...............#...#
+###.#....#######....#.###
+# #.#..#.# #.#..#.# #
+###....#.#######.#....###
+#......#....#....#......#
+#.#########.#.#########.#
+#.......................#
+#########################
+ENDOFLEVEL
+}
+
+function levelmap_classic2
+{
+cat <<ENDOFLEVEL
+#######################
+#.P...#.........#.....#
+#.###.#.#######.#.###.#
+#.....................#
+###.#.####.#.####.#.###
+###.#......#......#.###
+###.###.#######.###.###
+###.................###
+###.###.### ###.###.###
+###.#...#M #...#.###
+###.#.#.#######.#.#.###
+#.....#.........#.....#
+###.#####..#..#####.###
+###........#........###
+###.###.#######.###.###
+#.....................#
+#.###.####.#.####.###.#
+#.###.#....#....#.###.#
+#.###.#.#######.#.###.#
+#.....................#
+#######################
+ENDOFLEVEL
+}
+
+function levelmap_easy
+{
+cat <<ENDOFLEVEL
+##################
+# .............. #
+# . ###### #
+# . # M # #
+# . # # #
+# . ### ## #
+# . # #
+# . ### #
+# . #
+# .......... #
+# .......... P #
+##################
+ENDOFLEVEL
+}
+
+function levelmap_sunsolaristext
+{
+cat <<ENDOFLEVEL
+################################################
+# .#### . # #....# #
+# # # # #....# #
+# #### # # #.#..# M #
+# # # # #..#.# #
+# # # # # #...## #
+# #### #### #....# #
+# #
+# #### #### # ## ##### # #### #
+# # #. .# # # # #....# # # #
+# #### # # # # P # #....# # #### #
+# # # ### #.#### #.### # # #
+# # .# #. .. # # #...# # # # #
+# #### #### ###### . # ....# # ####. #
+################################################
+ENDOFLEVEL
+}
+
+function read_levelmap
+{
+ map="$( $1 )"
+
+ integer y=0
+ integer x=0
+ integer maxx=0
+ integer numdots=0
+
+ print "$map" |
+ while read line ; do
+ x=0
+ while (( x < ${#line} )) ; do
+ c="${line:x:1}"
+
+ case $c in
+ ".") numdots+=1 ;;
+ "M")
+ levelmap["monsterstartpos_x"]="$x"
+ levelmap["monsterstartpos_y"]="$y"
+ c=" "
+ ;;
+ "P")
+ levelmap["playerstartpos_x"]="$x"
+ levelmap["playerstartpos_y"]="$y"
+ c=" "
+ ;;
+ esac
+
+ levelmap["${x}_${y}"]="$c"
+ let x++
+ done
+ maxx=$x
+ let y++
+ done
+
+ levelmap["max_x"]=${maxx}
+ levelmap["max_y"]=${y}
+ levelmap["numdots"]=${numdots}
+
+ if [ "${levelmap["monsterstartpos_x"]}" = "" ] ; then
+ fatal_error "read_levelmap: monsterstartpos_x is empty."
+ fi
+ if [ "${levelmap["playerstartpos_x"]}" = "" ] ; then
+ fatal_error "read_levelmap: playerstartpos_x is empty."
+ fi
+
+ return 0
+}
+
+function player.set
+{
+ case "${.sh.subscript}" in
+ pos_y)
+ if [ "${levelmap["${player["pos_x"]}_${.sh.value}"]}" = "#" ] ; then
+ .sh.value=${player["pos_y"]}
+ beep
+ fi
+ ;;
+
+ pos_x)
+ if [ "${levelmap["${.sh.value}_${player["pos_y"]}"]}" = "#" ] ; then
+ .sh.value=${player["pos_x"]}
+ beep
+ fi
+ ;;
+ esac
+}
+
+function monster.set
+{
+ case "${.sh.subscript}" in
+ *_pos_y)
+ if [ "${levelmap["${monster[${currmonster}_"pos_x"]}_${.sh.value}"]}" = "#" ] ; then
+ .sh.value=${monster[${currmonster}_"pos_y"]}
+ # turn homing off when the monster hit a wall
+ monster[${currmonster}_"homing"]=0
+ fi
+ ;;
+
+ *_pos_x)
+ if [ "${levelmap["${.sh.value}_${monster[${currmonster}_"pos_y"]}"]}" = "#" ] ; then
+ .sh.value=${monster[${currmonster}_"pos_x"]}
+ # turn homing off when the monster hit a wall
+ monster[${currmonster}_"homing"]=0
+ fi
+ ;;
+ esac
+}
+
+function render_game
+{
+ # render_buffer is some kind of "background buffer" to "double buffer"
+ # all output and combine it in one write to reduce flickering in the
+ # terminal
+ render_buffer="$(
+ screen_y_offset=1
+ start_y_pos=0
+ render_num_lines=${levelmap["max_y"]}
+
+ if (( (LINES-3) < levelmap["max_y"] )) ; then
+ start_y_pos=$((player["pos_y"] / 2))
+ render_num_lines=$((LINES-5))
+ fi
+
+ #print -n "${vtcode["clear"]}"
+ print_setcursorpos 0 0
+
+ # print score (note the " " around "%d" are neccesary to clean up cruft
+ # when we overwrite the level
+ printf "SCORE: %05d DOTS: %.3d LIVES: %2.d " "${player["score"]}" "${levelmap["numdots"]}" "${player["lives"]}"
+ print_levelmap ${screen_y_offset} ${start_y_pos} ${render_num_lines}
+
+ # render player
+ print_setcursorpos ${player["pos_x"]} $((player["pos_y"]+screen_y_offset-start_y_pos))
+ print -n "@"
+
+ # render monsters
+ for currmonster in ${monsterlist} ; do
+ let m_pos_x=monster[${currmonster}_"pos_x"]
+ let m_pos_y=monster[${currmonster}_"pos_y"]+screen_y_offset-start_y_pos
+
+ if (( m_pos_y >= screen_y_offset && m_pos_y < render_num_lines )) ; then
+ print_setcursorpos ${m_pos_x} ${m_pos_y}
+ print -n "x"
+ fi
+ done
+
+ # status block
+ print_setcursorpos 0 $((render_num_lines+screen_y_offset))
+ emptyline=" "
+ print -n " >> ${player["message"]} <<${emptyline:0:${#emptyline}-${#player["message"]}}"
+ )"
+ print "${render_buffer}"
+# print "renderbuffersize=$(print "${render_buffer}" | wc -c) "
+}
+
+function main_loop
+{
+ float sleep_per_cycle=0.2
+ float seconds_before_read
+ integer num_cycles=0
+ float rs
+
+ print -n "${vtcode["clear"]}"
+
+ read_levelmap "$1"
+
+ # player init
+ player["pos_x"]=${levelmap["playerstartpos_x"]}
+ player["pos_y"]=${levelmap["playerstartpos_y"]}
+ player["score"]=0 # player score
+ player["lives"]=5 # number of lives
+ player["invulnerable"]=10 # cycles how long the player remains invulnerable
+ player["message"]="Go..."
+
+ monsterlist="maw claw jitterbug tentacle grendel"
+
+ for currmonster in ${monsterlist} ; do
+ monster[${currmonster}_"pos_x"]=${levelmap["monsterstartpos_x"]}
+ monster[${currmonster}_"pos_y"]=${levelmap["monsterstartpos_y"]}
+ monster[${currmonster}_"xstep"]=0
+ monster[${currmonster}_"ystep"]=0
+ monster[${currmonster}_"homing"]=0
+ done
+
+ # main game cycle loop
+ while true ; do
+ num_cycles+=1
+ seconds_before_read=${SECONDS}
+ c="" ; read -t ${sleep_per_cycle} -n 1 c
+
+ if [ "$c" != "" ] ; then
+ # special case handling for cursor keys which are usually composed
+ # of three characters (e.g. "<ESC>[D"). If only <ESC> is hit we
+ # quicky exit
+ if [ "$c" = $'\E' ] ; then
+ read -t 0.1 -n 1 c
+ if [ "$c" != "[" ] ; then
+ return 0
+ fi
+
+ # we assume the user is using the cursor keys, this |read|
+ # should fetch the 3rd byte of the three-character sequence
+ # for the cursor keys
+ read -t 0.1 -n 1 c
+ fi
+
+ # if the user hit a key the "read" above was interrupted
+ # and didn't wait exactly |sleep_per_cycle| seconds.
+ # We wait here some moments (|rs|="remaining seconds") to
+ # avoid that the game gets "faster" when more user input
+ # is given.
+ rs=$((sleep_per_cycle-(SECONDS-seconds_before_read)))
+ (( rs > 0.001 )) && sleep ${rs}
+
+ player["message"]=""
+
+ case "$c" in
+ j|D|4) let player["pos_x"]-=1 ;;
+ k|C|6) let player["pos_x"]+=1 ;;
+ i|A|8) let player["pos_y"]-=1 ;;
+ m|B|2) let player["pos_y"]+=1 ;;
+
+ q) return 0 ;;
+ esac
+
+ if [ "${levelmap["${player["pos_x"]}_${player["pos_y"]}"]}" = "." ] ; then
+ levelmap["${player["pos_x"]}_${player["pos_y"]}"]=" "
+ let levelmap["numdots"]-=1
+
+ let player["score"]+=10
+ player["message"]='GNAW!!'
+
+ if [ ${levelmap["numdots"]} -le 0 ] ; then
+ level_completed
+ return 0
+ fi
+ fi
+ fi
+
+ # generic player status change
+ if [ ${player["invulnerable"]} -gt 0 ] ; then
+ let player["invulnerable"]-=1
+ fi
+ if [ ${player["lives"]} -le 0 ] ; then
+ game_over
+ return 0
+ fi
+
+ # move monsters
+ for currmonster in ${monsterlist} ; do
+ # make monster as half as slow then the others when it is following the user
+ if [ ${monster[${currmonster}_"homing"]} -gt 0 ] ; then
+ [ $((num_cycles % 2)) -gt 0 ] && continue
+ fi
+
+ if [ ${monster[${currmonster}_"pos_x"]} = ${player["pos_x"]} ] ; then
+ if [ $((monster[${currmonster}_"pos_y"]-player["pos_y"])) -gt 0 ] ; then
+ let monster[${currmonster}_"xstep"]=+0 monster[${currmonster}_"ystep"]=-1
+ else
+ let monster[${currmonster}_"xstep"]=+0 monster[${currmonster}_"ystep"]=+1
+ fi
+ monster[${currmonster}_"homing"]=1
+ if [ ${player["invulnerable"]} -le 0 ] ; then
+ player["message"]="Attention: ${currmonster} is chasing you"
+ fi
+ elif [ ${monster[${currmonster}_"pos_y"]} = ${player["pos_y"]} ] ; then
+ if [ $((monster[${currmonster}_"pos_x"]-player["pos_x"])) -gt 0 ] ; then
+ let monster[${currmonster}_"xstep"]=-1 monster[${currmonster}_"ystep"]=-0
+ else
+ let monster[${currmonster}_"xstep"]=+1 monster[${currmonster}_"ystep"]=+0
+ fi
+ monster[${currmonster}_"homing"]=1
+ if [ ${player["invulnerable"]} -le 0 ] ; then
+ player["message"]="Attention: ${currmonster} is chasing you"
+ fi
+ else
+ if [ ${monster[${currmonster}_"homing"]} -eq 0 ] ; then
+ case $((SECONDS % 6 + RANDOM % 4)) in
+ 0) let monster[${currmonster}_"xstep"]=+0 monster[${currmonster}_"ystep"]=+0 ;;
+ 2) let monster[${currmonster}_"xstep"]=+0 monster[${currmonster}_"ystep"]=+1 ;;
+ 3) let monster[${currmonster}_"xstep"]=+1 monster[${currmonster}_"ystep"]=+0 ;;
+ 5) let monster[${currmonster}_"xstep"]=+0 monster[${currmonster}_"ystep"]=-1 ;;
+ 6) let monster[${currmonster}_"xstep"]=-1 monster[${currmonster}_"ystep"]=+0 ;;
+ esac
+ fi
+ fi
+
+ let monster[${currmonster}_"pos_x"]=monster[${currmonster}_"pos_x"]+monster[${currmonster}_"xstep"]
+ let monster[${currmonster}_"pos_y"]=monster[${currmonster}_"pos_y"]+monster[${currmonster}_"ystep"]
+
+ # check if a monster hit the player
+ if [ ${player["invulnerable"]} -le 0 ] ; then
+ if [ ${monster[${currmonster}_"pos_x"]} -eq ${player["pos_x"]} -a \
+ ${monster[${currmonster}_"pos_y"]} -eq ${player["pos_y"]} ] ; then
+ # if player was hit by a monster take one life and
+ # make him invulnerable for 10 cycles to avoid that
+ # the next cycle steals more lives
+ player["message"]="Ouuuchhhh"
+ player["invulnerable"]=10
+ let player["lives"]-=1
+
+ beep ; beep ; sleep 0.3 ; beep ; beep
+ fi
+ fi
+ done
+
+ render_game
+ done
+}
+
+# program start
+function map_filter
+{
+# Choose between the old "sed"-based codepath and the new ksh93-native one
+# The old codepath no longer used except for the unicode mode because
+# we do not have control over the point where "sed" flushes it's buffer
+# which completely defeats the doube-buffering code. Unfortunately the new
+# codepath has problems in UTF-8 mode (bug in ksh93 ?) which forces us to
+# use the old codepath in this case.
+if [ $2 -eq 1 ] ; then
+(
+ filter1=""
+ filter2=""
+
+ # should we add the color map ?
+ if [ $1 -eq 1 ] ; then
+ filter1="s/#/${vtcode["fg_blue"]}#/g;\
+ s/x/${vtcode["fg_red"]}x/g;\
+ s/@/${vtcode["fg_yellow"]}@/g;\
+ s/ /${vtcode["fg_grey"]} /g;\
+ s/\./${vtcode["fg_lightred"]}./g;"
+ fi
+
+ # should we add the unicode map ?
+ if [ $2 -eq 1 ] ; then
+ filter2="s/@/$(printf '\u[24d2]')/g;s/x/$(printf '\u[2605]')/g;s/#/$(printf '\u[25a6]')/g"
+ fi
+
+ sed -e "${filter1}" -e "${filter2}"
+)
+else
+(
+ if [ $1 -eq 1 ] ; then
+ ch_player="${vtcode["fg_yellow"]}"
+ ch_monster="${vtcode["fg_red"]}"
+ ch_wall="${vtcode["fg_blue"]}"
+ else
+ ch_player=""
+ ch_monster=""
+ ch_wall=""
+ fi
+
+ if [ $2 -eq 1 ] ; then
+ # unicode map
+ ch_player+="$(printf '\u[24d2]')"
+ ch_monster+="$(printf '\u[2605]')"
+ ch_wall+="$(printf '\u[25a6]')"
+ else
+ # ascii map
+ ch_player+="@"
+ ch_monster+="x"
+ ch_wall+="#"
+ fi
+
+ IFS="|" # make sure we don't swallow spaces/tabs
+ while read var ; do
+ var="${var// /${vtcode["fg_grey"]} }"
+ var="${var//\./${vtcode["fg_lightred"]}.}"
+ var="${var//@/${ch_player}}"
+ var="${var//x/${ch_monster}}"
+ var="${var//#/${ch_wall}}"
+
+ print "${var}"
+ done
+)
+fi
+}
+
+function exit_trap
+{
+ # restore stty settings
+ stty ${SAVED_STTY}
+
+ print "bye."
+}
+
+function usage
+{
+ OPTIND=0
+ getopts -a "${progname}" "${USAGE}" OPT '-?'
+ exit 2
+}
+
+# program start
+progname="${0}"
+quiet=false
+
+# make sure we use the ksh93 "cat" builtin which supports the "-u" option
+builtin cat
+builtin wc
+builtin printf # we need this for positional parameters ('printf "%2\$s %1\$s" hello world' = "world hello")
+builtin sleep
+
+# global variables
+typeset -A levelmap
+typeset -A player
+typeset -A monster
+# global rendering options
+integer game_use_colors=0
+integer game_use_unicode=0
+
+USAGE=$'
+[-?
+@(#)\$Id: gnaw (Roland Mainz) 2007-06-05 \$
+]
+[+NAME?gnaw - maze game written in ksh93]
+[+DESCRIPTION?\bgnaw\b is a maze game.
+ The player maneuvers a yellow '@' sign to navigate a maze while eating
+ small dots. A level is finished when all the dots are eaten. Five monsters
+ (maw, claw, jitterbug, tentacle and grendel) also wander the maze in an attempt
+ to catch the '@'. Each level begins with all ghosts in their home, and '@' near
+ the bottom of the maze. The monsters are released from the home one by one at the
+ start of each level and start their rentless hunt after the player.]
+[q:quiet?Disable use of terminal bell.]
+[+SEE ALSO?\bksh93\b(1)]
+'
+
+while getopts -a "${progname}" "${USAGE}" OPT ; do
+# printmsg "## OPT=|${OPT}|, OPTARG=|${OPTARG}|"
+ case ${OPT} in
+ q) quiet=true ;;
+ *) usage ;;
+ esac
+done
+shift ${OPTIND}-1
+
+# save stty values and register the exit trap which restores these values on exit
+SAVED_STTY="$(stty -g)"
+trap exit_trap EXIT
+
+print "Loading..."
+
+# set stty values, "-icanon min 1 time 0 -inpck" should improve input latency,
+# "-echo" turns the terminal echo off
+stty -icanon min 1 time 0 -inpck -echo
+
+# "resize" cannot fetch the terminal width/height for some terminals
+case ${TERM} in
+ sun | sun-color)
+ export COLUMNS=80 LINES=25
+ ;;
+ vt52)
+ export COLUMNS=80 LINES=24
+ ;;
+ *)
+ # get width/height from current terminal
+ [ -x "/usr/X11/bin/resize" ] && eval "$(/usr/X11/bin/resize -u)" ||
+ [ -x "/usr/X11R6/bin/resize" ] && eval "$(/usr/X11R6/bin/resize -u)" ||
+ [ -x "/usr/openwin/bin/resize" ] && eval "$(/usr/openwin/bin/resize -u)" ||
+ fatal_error "resize not found."
+ ;;
+esac
+
+# prechecks
+(( COLUMNS < 60 )) && fatal_error "Terminal width must be larger than 60 columns (currently ${COLUMNS})."
+
+typeset -A vtcode
+# color values taken from http://frexx.de/xterm-256-notes/, other
+# codes from http://vt100.net/docs/vt100-tm/
+vtcode=(
+ ["bg_black"]="$(print -n "\E[40m")"
+ ["fg_black"]="$(print -n "\E[30m")"
+ ["fg_red"]="$(print -n "\E[31m")"
+ ["fg_lightred"]="$(print -n "\E[1;31m")"
+ ["fg_green"]="$(print -n "\E[32m")"
+ ["fg_lightgreen"]="$(print -n "\E[1;32m")"
+ ["fg_yellow"]="$(print -n "\E[33m")"
+ ["fg_lightyellow"]="$(print -n "\E[1;33m")"
+ ["fg_blue"]="$(print -n "\E[34m")"
+ ["fg_lightblue"]="$(print -n "\E[1;34m")"
+ ["fg_grey"]="$(print -n "\E[1;37m")"
+ ["fg_white"]="$(print -n "\E[37m")"
+
+ # misc other vt stuff
+ ["vtreset"]="$(tput reset)"
+ ["clear"]="$(tput clear)"
+ ["bel"]="$(tput bel)"
+ ["spaceline"]="$(for (( i=0 ; i < COLUMNS ; i++ )) ; do print -n " " ; done)"
+)
+
+# get terminal sequence to move cursor to position x,y
+# (see http://vt100.net/docs/vt100-ug/chapter3.html#CPR)
+case ${TERM} in
+ xterm | xterm-color | vt100 | vt220 | dtterm | sun | sun-color)
+ cup="$(infocmp -1 | \
+ egrep '^[[:space:]]*cup=' | \
+ sed -e 's/.*cup=//' \
+ -e 's/%[%id]*p1[%id]*/%2\\\$d/g' \
+ -e 's/%[%id]*p2[%id]*/%1\\\$d/g' \
+ -e 's/,$//')"
+ for (( x=0 ; x < COLUMNS ; x++ )) ; do
+ for (( y=0 ; y < LINES ; y++ )) ; do
+ vtcode[cup_${x}_${y}]="$(printf "${cup}" $((x + 1)) $((y + 1)) )"
+ done
+ done
+ ;;
+ *)
+ printf "# Unrecognised terminal type '%s', fetching %dx%d items from terminfo database, please wait...\n" "${TERM}" "${COLUMNS}" "${LINES}"
+ for (( x=0 ; x < COLUMNS ; x++ )) ; do
+ for (( y=0 ; y < LINES ; y++ )) ; do
+ vtcode[cup_${x}_${y}]="$(tput cup ${y} ${x})"
+ done
+ done
+ ;;
+esac
+
+print "${vtcode["vtreset"]}"
+
+run_logo
+run_menu
+
+# EOF.
+
diff --git a/usr/src/lib/libshell/common/fun/mandelbrotset1 b/usr/src/lib/libshell/common/fun/mandelbrotset1
new file mode 100644
index 0000000000..fd39f387ec
--- /dev/null
+++ b/usr/src/lib/libshell/common/fun/mandelbrotset1
@@ -0,0 +1,234 @@
+#!/bin/ksh93
+
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+#
+# mandelbrotset1 - a simple mandelbrot set generation and
+# parallel execution demo
+#
+
+# Solaris needs /usr/xpg4/bin/ because the tools in /usr/bin are not POSIX-conformant
+export PATH=/usr/xpg4/bin:/bin:/usr/bin:/usr/X11/bin:/usr/X11R6/bin:/usr/openwin/bin
+
+function printmsg
+{
+ print -u 2 "$@"
+}
+
+function fatal_error
+{
+ print -u 2 "${progname}: $@"
+ exit 1
+}
+
+function print_color
+{
+ print -n "${symbollist:${1}:1}"
+}
+
+function mandelbrot
+{
+ float x=$1
+ float y=$2
+ float xx
+ float yy
+ float x1=$3
+ float y1=$4
+ integer iteration=$5
+ integer max_iteration=$6
+ float mag
+
+ for (( mag=0 ; mag < max_mag && iteration < max_iteration ; iteration++ )) ; do
+ (( xx=x*x ))
+ (( yy=y*y ))
+ (( mag=xx+yy ))
+
+ (( y=x*y*2+y1 ))
+ (( x=xx-yy+x1 ))
+ done
+
+ print ${iteration}
+
+ return 0
+}
+
+function loop_serial
+{
+ for (( y=y_min ; y < y_max ; y+=stepwidth )) ; do
+ for (( x=x_min ; x < x_max ; x+=stepwidth )) ; do
+ print_color $(mandelbrot ${x} ${y} ${x} ${y} 1 ${symbollistlen})
+ done
+
+ print
+ done
+}
+
+function loop_parallel
+{
+ integer numjobs=0
+ # the following calculation suffers from rounding errors
+ integer lines_per_job=$(( ((m_height+(numcpus-1)) / numcpus) ))
+
+ printmsg "# lines_per_job=${lines_per_job}"
+ printmsg "# numcpus=${numcpus}"
+
+ # "renice" worker jobs
+ set -o bgnice
+
+ if [ "${TMPDIR}" = "" ] ; then
+ TMPDIR="/tmp"
+ fi
+
+ # try to generate a job identifer prefix which is unique across multiple hosts
+ jobident="job_host_$(uname -n)pid_$$_ppid${PPID}"
+
+ printmsg $"## prepare..."
+ for (( y=y_min ; y < y_max ; y+=(stepwidth*lines_per_job) )) ; do
+ rm -f "${TMPDIR}/mandelbrot_${jobident}_child_$y.joboutput"
+
+ let numjobs++
+ done
+
+ printmsg $"## running ${numjobs} children..."
+ for (( y=y_min ; y < y_max ; y+=(stepwidth*lines_per_job) )) ; do
+ (
+ for (( ; y < y_max && lines_per_job-- > 0 ; y+=stepwidth )) ; do
+ for (( x=x_min ; x < x_max ; x+=stepwidth )) ; do
+ print_color $(mandelbrot ${x} ${y} ${x} ${y} 1 ${symbollistlen})
+ done
+
+ print
+ done >"${TMPDIR}/mandelbrot_${jobident}_child_$y.joboutput"
+ ) &
+ done
+
+ printmsg $"## waiting for ${numjobs} children..."
+ wait
+
+ printmsg $"## output:"
+ for (( y=y_min ; y < y_max ; y+=(stepwidth*lines_per_job) )) ; do
+ print "$(cat "${TMPDIR}/mandelbrot_${jobident}_child_$y.joboutput")"
+ rm "${TMPDIR}/mandelbrot_${jobident}_child_$y.joboutput"
+ done
+}
+
+function usage
+{
+ OPTIND=0
+ getopts -a "${progname}" "${USAGE}" OPT '-?'
+ exit 2
+}
+
+# main
+builtin printf
+builtin cat
+builtin rm
+builtin sleep
+builtin uname # loop_parallel needs the ksh93 builtin version to generate unique job file names
+
+float x_max
+float x_min
+float y_max
+float y_min
+float m_width
+float m_height
+float max_mag
+float stepwidth
+integer numcpus
+
+# make sure ${COLUMN} and ${LINES} are set
+eval $(resize -u)
+
+symbollist=' .:0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%#'
+symbollistlen=$(( ${#symbollist} - 1))
+mode="parallel"
+progname="${0}"
+max_mag=400
+stepwidth=0.1
+numcpus=16
+
+let m_width=COLUMNS-1 m_height=LINES-2
+
+progname="${0}"
+
+USAGE=$'
+[-?
+@(#)\$Id: mandelbrotset1 (Roland Mainz) 2007-06-05 \$
+]
+[+NAME?mandelbrotset1 - generate mandelbrot set fractals with ksh93]
+[+DESCRIPTION?\bmandelbrotset1\b mandelbrot set fractal generator
+ which runs either in serial or parallel mode (using multiple worker jobs).]
+[w:width?Width of fractal.]:[width]
+[h:height?Height of fractal.]:[height]
+[s:symbols?Symbols to build the fractal from.]:[symbolstring]
+[m:mag?Magnification level.]:[magnificationlevel]
+[p:stepwidth?Width per step.]:[widthperstep]
+[S:serial?Run in serial mode.]
+[P:parallel?Run in parallel mode.]
+[M:mode?Execution mode.]:[mode]
+[C:numcpus?Number of processors used for parallel execution.]:[numcpus]
+[+SEE ALSO?\bjuliaset1\b(1), \bksh93\b(1)]
+'
+
+while getopts -a "${progname}" "${USAGE}" OPT ; do
+# printmsg "## OPT=|${OPT}|, OPTARG=|${OPTARG}|"
+ case ${OPT} in
+ w) m_width="${OPTARG}" ;;
+ h) m_height="${OPTARG}" ;;
+ s) symbollist="${OPTARG}" ;;
+ m) max_mag="${OPTARG}" ;;
+ p) stepwidth="${OPTARG}" ;;
+ S) mode="serial" ;;
+ P) mode="parallel" ;;
+ M) mode="${OPTARG}" ;;
+ C) numcpus="${OPTARG}" ;;
+ *) usage ;;
+ esac
+done
+shift ${OPTIND}-1
+
+printmsg "# width=${m_width}"
+printmsg "# height=${m_height}"
+printmsg "# max_mag=${max_mag}"
+printmsg "# stepwidth=${stepwidth}"
+printmsg "# symbollist='${symbollist}'"
+printmsg "# mode=${mode}"
+
+symbollistlen=$(( ${#symbollist} - 1))
+
+let x_max=m_width*stepwidth/2. x_min=-x_max
+let y_max=m_height*stepwidth/2. y_min=-y_max
+
+case "${mode}" in
+ parallel) loop_parallel ;;
+ serial) loop_serial ;;
+ *) fatal_error $"Unknown mode \"${mode}\"."
+esac
+
+# EOF.
diff --git a/usr/src/lib/libshell/common/fun/popd b/usr/src/lib/libshell/common/fun/popd
new file mode 100644
index 0000000000..1bc9346f40
--- /dev/null
+++ b/usr/src/lib/libshell/common/fun/popd
@@ -0,0 +1,111 @@
+#
+# DIRECTORY MANIPULATION FUNCTIONS PUSHD, POPD AND DIRS
+#
+# Uses global parameters _push_max _push_top _push_stack
+integer _push_max=100 _push_top=100
+# Display directory stack -- $HOME displayed as ~
+function dirs
+{
+ typeset dir="${PWD#$HOME/}"
+ case $dir in
+ $HOME)
+ dir=\~
+ ;;
+ /*) ;;
+ *) dir=\~/$dir
+ esac
+ print -r - "$dir ${_push_stack[@]}"
+}
+
+# Change directory and put directory on front of stack
+function pushd
+{
+ typeset dir= type=0
+ integer i
+ case $1 in
+ "") # pushd
+ if ((_push_top >= _push_max))
+ then print pushd: No other directory.
+ return 1
+ fi
+ type=1 dir=${_push_stack[_push_top]}
+ ;;
+ +[1-9]|+[1-9][0-9]) # pushd +n
+ integer i=_push_top$1-1
+ if ((i >= _push_max))
+ then print pushd: Directory stack not that deep.
+ return 1
+ fi
+ type=2 dir=${_push_stack[i]}
+ ;;
+ *) if ((_push_top <= 0))
+ then print pushd: Directory stack overflow.
+ return 1
+ fi
+ esac
+ case $dir in
+ \~*) dir=$HOME${dir#\~}
+ esac
+ cd "${dir:-$1}" > /dev/null || return 1
+ dir=${OLDPWD#$HOME/}
+ case $dir in
+ $HOME)
+ dir=\~
+ ;;
+ /*) ;;
+ *) dir=\~/$dir
+ esac
+ case $type in
+ 0) # pushd name
+ _push_stack[_push_top=_push_top-1]=$dir
+ ;;
+ 1) # pushd
+ _push_stack[_push_top]=$dir
+ ;;
+ 2) # push +n
+ type=${1#+} i=_push_top-1
+ set -- "${_push_stack[@]}" "$dir" "${_push_stack[@]}"
+ shift $type
+ for dir
+ do (((i=i+1) < _push_max)) || break
+ _push_stack[i]=$dir
+ done
+ esac
+ dirs
+}
+
+# Pops the top directory
+function popd
+{
+ typeset dir
+ if ((_push_top >= _push_max))
+ then print popd: Nothing to pop.
+ return 1
+ fi
+ case $1 in
+ "")
+ dir=${_push_stack[_push_top]}
+ case $dir in
+ \~*) dir=$HOME${dir#\~}
+ esac
+ cd "$dir" || return 1
+ ;;
+ +[1-9]|+[1-9][0-9])
+ typeset savedir
+ integer i=_push_top$1-1
+ if ((i >= _push_max))
+ then print pushd: Directory stack not that deep.
+ return 1
+ fi
+ while ((i > _push_top))
+ do _push_stack[i]=${_push_stack[i-1]}
+ i=i-1
+ done
+ ;;
+ *) print pushd: Bad directory.
+ return 1
+ esac
+ unset '_push_stack[_push_top]'
+ _push_top=_push_top+1
+ dirs
+}
diff --git a/usr/src/lib/libshell/common/fun/pushd b/usr/src/lib/libshell/common/fun/pushd
new file mode 100644
index 0000000000..1bc9346f40
--- /dev/null
+++ b/usr/src/lib/libshell/common/fun/pushd
@@ -0,0 +1,111 @@
+#
+# DIRECTORY MANIPULATION FUNCTIONS PUSHD, POPD AND DIRS
+#
+# Uses global parameters _push_max _push_top _push_stack
+integer _push_max=100 _push_top=100
+# Display directory stack -- $HOME displayed as ~
+function dirs
+{
+ typeset dir="${PWD#$HOME/}"
+ case $dir in
+ $HOME)
+ dir=\~
+ ;;
+ /*) ;;
+ *) dir=\~/$dir
+ esac
+ print -r - "$dir ${_push_stack[@]}"
+}
+
+# Change directory and put directory on front of stack
+function pushd
+{
+ typeset dir= type=0
+ integer i
+ case $1 in
+ "") # pushd
+ if ((_push_top >= _push_max))
+ then print pushd: No other directory.
+ return 1
+ fi
+ type=1 dir=${_push_stack[_push_top]}
+ ;;
+ +[1-9]|+[1-9][0-9]) # pushd +n
+ integer i=_push_top$1-1
+ if ((i >= _push_max))
+ then print pushd: Directory stack not that deep.
+ return 1
+ fi
+ type=2 dir=${_push_stack[i]}
+ ;;
+ *) if ((_push_top <= 0))
+ then print pushd: Directory stack overflow.
+ return 1
+ fi
+ esac
+ case $dir in
+ \~*) dir=$HOME${dir#\~}
+ esac
+ cd "${dir:-$1}" > /dev/null || return 1
+ dir=${OLDPWD#$HOME/}
+ case $dir in
+ $HOME)
+ dir=\~
+ ;;
+ /*) ;;
+ *) dir=\~/$dir
+ esac
+ case $type in
+ 0) # pushd name
+ _push_stack[_push_top=_push_top-1]=$dir
+ ;;
+ 1) # pushd
+ _push_stack[_push_top]=$dir
+ ;;
+ 2) # push +n
+ type=${1#+} i=_push_top-1
+ set -- "${_push_stack[@]}" "$dir" "${_push_stack[@]}"
+ shift $type
+ for dir
+ do (((i=i+1) < _push_max)) || break
+ _push_stack[i]=$dir
+ done
+ esac
+ dirs
+}
+
+# Pops the top directory
+function popd
+{
+ typeset dir
+ if ((_push_top >= _push_max))
+ then print popd: Nothing to pop.
+ return 1
+ fi
+ case $1 in
+ "")
+ dir=${_push_stack[_push_top]}
+ case $dir in
+ \~*) dir=$HOME${dir#\~}
+ esac
+ cd "$dir" || return 1
+ ;;
+ +[1-9]|+[1-9][0-9])
+ typeset savedir
+ integer i=_push_top$1-1
+ if ((i >= _push_max))
+ then print pushd: Directory stack not that deep.
+ return 1
+ fi
+ while ((i > _push_top))
+ do _push_stack[i]=${_push_stack[i-1]}
+ i=i-1
+ done
+ ;;
+ *) print pushd: Bad directory.
+ return 1
+ esac
+ unset '_push_stack[_push_top]'
+ _push_top=_push_top+1
+ dirs
+}
diff --git a/usr/src/lib/libshell/common/fun/rssread b/usr/src/lib/libshell/common/fun/rssread
new file mode 100644
index 0000000000..e561cb3587
--- /dev/null
+++ b/usr/src/lib/libshell/common/fun/rssread
@@ -0,0 +1,414 @@
+#!/bin/ksh93
+
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+#
+# rssread - a simple RSS2.0 reader with RSS to XHTML to
+# plaintext conversion.
+#
+
+# Solaris needs /usr/xpg4/bin/ because the tools in /usr/bin are not POSIX-conformant
+export PATH=/usr/xpg4/bin:/bin:/usr/bin
+
+function printmsg
+{
+ print -u 2 "$@"
+}
+
+function debugmsg
+{
+# printmsg "$@"
+true
+}
+
+function fatal_error
+{
+ print -u 2 "${progname}: $@"
+ exit 1
+}
+
+function cat_http
+{
+(
+ protocol="${1%://*}"
+ path1="${1#*://}" # "http://foo.bat.net/x/y.html" ----> "foo.bat.net/x/y.html"
+
+ host="${path1%%/*}"
+ path="${path1#*/}"
+ port="${host##*:}"
+
+ # If URL did not contain a port number in the host part then look at the
+ # protocol to get the port number
+ if [ "${port}" = "${host}" ] ; then
+ case "${protocol}" in
+ "http") port=80 ;;
+ *) port="$(getent services "${protocol}" | sed 's/[^0-9]*//;s/\/.*//')" ;;
+ esac
+ else
+ host="${host%:*}"
+ fi
+
+ printmsg "protocol=${protocol} port=${port} host=${host} path=${path}"
+
+ # prechecks
+ [ "${protocol}" = "" ] && fatal_error "protocol not set."
+ [ "${port}" = "" ] && fatal_error "port not set."
+ [ "${host}" = "" ] && fatal_error "host not set."
+ [ "${path}" = "" ] && fatal_error "path not set."
+
+ # open TCP channel
+ exec 3<>"/dev/tcp/${host}/${port}"
+
+ # send HTTP request
+ request="GET /${path} HTTP/1.0\n"
+ request+="Host: ${host}\n"
+ request+="User-Agent: ksh93/rssread (2007-01-16; $(uname -s -r -p))\n"
+ print "${request}\n" >&3
+
+ # collect response and send it to stdout
+ cat <&3
+)
+}
+
+function html_entity_to_ascii
+{
+ typeset -A entity_cache
+
+ # Todo: Add more HTML/MathML entities here
+ entity_cache["nbsp"]=" "
+ entity_cache["lt"]="<"
+ entity_cache["gt"]=">"
+ entity_cache["amp"]="&"
+ entity_cache["quot"]="\""
+ entity_cache["apos"]="'"
+
+ buf=""
+ while read -r -N 1 c ; do
+ if [ "$c" != "&" ] ; then
+ printf "%s" "${c}"
+ continue
+ fi
+
+ entity=""
+ while read -r -N 1 c ; do
+ case "$c" in
+ ";")
+ break
+ ;;
+ ~(Eilr)[a-z0-9#])
+ entity+="$c"
+ continue
+ ;;
+ *)
+ debugmsg "error &${entity}${c}#"
+
+ print -n "${entity}${c}"
+ entity=""
+ continue 2
+ ;;
+ esac
+ done
+
+ value=""
+ if [ "${entity_cache["${entity}"]}" != "" ] ; then
+ debugmsg "match #${entity}# = #${entity_cache["${entity}"]}#"
+ value="${entity_cache["${entity}"]}"
+ else
+ if [ "${entity:0:1}" = "#" ] ; then
+ # decimal literal
+ value="$(printf "\u[$(printf "%x" "${entity:1:8}")]")"
+ elif [[ "${entity:0:7}" = ~(Eilr)[0-9a-f]* ]] ; then
+ # hexadecimal literal
+ value="$(printf "\u[${entity:0:7}]")"
+ else
+ # unknown literal - pass-through
+ value="<ENT=${entity}>"
+ fi
+
+ entity_cache["${entity}"]="${value}"
+
+ debugmsg "lookup #${entity}# = #${entity_cache["${entity}"]}#"
+ fi
+
+ printf "%s" "$value"
+ done
+}
+
+# dumb xhtml handler - no CSS, tables, images, iframes or nested
+# structures are supported (and we assume that the input is correct
+# xhtml). The code was written in a trial&&error manner and should be
+# rewritten to parse xhtml correctly.
+function handle_html
+{
+ # we can't use global variables here when multiple callbacks use the same
+ # callback function - but we can use the callback associative array for
+ # variable storage instead
+ nameref callbacks=${1}
+ tag_type="$2"
+ tag_value="$3"
+
+ case "${tag_type}" in
+ tag_begin)
+ case "${tag_value}" in
+ br*) printf "\n" ;;
+ hr*) printf "\n-------------------------------------\n" ;;
+ pre*) callbacks["html_pre"]=1 ;;
+ p*) printf "\n" ;;
+ esac
+ ;;
+
+ tag_end)
+ case "${tag_value}" in
+ pre*) callbacks["html_pre"]=0 ;;
+ esac
+ ;;
+
+ tag_text)
+ if [ ${callbacks["html_pre"]} -eq 1 ] ; then
+ printf "%s" "${tag_value}"
+ else
+ # compress spaces/newlines/tabs/etc.
+ printf "%s" "${tag_value/+([\n\r\t\v[:space:][:blank:]])/ }"
+ fi
+ ;;
+
+ document_start)
+ callbacks["html_pre"]=0
+ ;;
+ document_end) ;;
+ esac
+}
+
+function handle_rss
+{
+ # we can't use global variables here when multiple callbacks use the same
+ # callback function - but we can use the callback associative array for
+ # variable storage instead
+ nameref callbacks=${1}
+ tag_type="$2"
+ tag_value="$3"
+
+ case "${tag_type}" in
+ tag_begin)
+ case "${tag_value}" in
+ item*)
+ item["title"]=""
+ item["link"]=""
+ item["tag"]=""
+ item["description"]=""
+ ;;
+ esac
+ callbacks["textbuf"]=""
+ ;;
+ tag_end)
+ case "${tag_value}" in
+ item*)
+ # note that each RSS item needs to be converted seperately from RSS to HTML to plain text
+ # to make sure that the state of one RSS item doesn't affect others
+ (
+ printf $"<br />#### RSS item: title: %s ####" "${item["title"]}"
+ printf $"<br />## author: %s" "${item["author"]}"
+ printf $"<br />## link: %s" "${item["link"]}"
+ printf $"<br />## date: %s" "${item["pubDate"]}"
+ printf $"<br />## begin description:"
+ printf $"<br />%s<br />" "${item["description"]}"
+ printf $"<br />## end description<br />"
+ print # extra newline to make sure the sed pipeline gets flushed
+ ) |
+ html_entity_to_ascii | # convert XML entities (e.g. decode RSS content to HTML code)
+ xml_tok "xhtmltok_cb" | # convert HTML to plain text
+ html_entity_to_ascii # convert HTML entities
+ ;;
+ title*) item["title"]="${callbacks["textbuf"]}" ; callbacks["textbuf"]="" ;;
+ link*) item["link"]="${callbacks["textbuf"]}" ; callbacks["textbuf"]="" ;;
+ dc:creator* | author*) item["author"]="${callbacks["textbuf"]}" ; callbacks["textbuf"]="" ;;
+ dc:date* | pubDate*) item["pubDate"]="${callbacks["textbuf"]}" ; callbacks["textbuf"]="" ;;
+ description*) item["description"]="${callbacks["textbuf"]}" ; callbacks["textbuf"]="" ;;
+ esac
+ callbacks["textbuf"]=""
+ ;;
+ tag_text)
+ callbacks["textbuf"]+="${tag_value}"
+ ;;
+ document_start) ;;
+ document_end) ;;
+ esac
+}
+
+function xml_tok
+{
+ typeset buf=""
+ typeset c=""
+
+ nameref callbacks=${1}
+
+ [ ! -z "${callbacks["document_start"]}" ] && ${callbacks["document_start"]} "${1}" "document_start"
+
+ while read -N 1 c -d '\0'; do
+ isendtag=false
+
+ if [ "$c" = "<" ] ; then
+ if [ "$buf" != "" ] ; then
+ [ ! -z "${callbacks["tag_text"]}" ] && ${callbacks["tag_text"]} "${1}" "tag_text" "$buf"
+ buf=""
+ fi
+
+ read -N 1 c -d '\0'
+ if [ "$c" = "/" ] ; then
+ isendtag=true
+ else
+ buf="$c"
+ fi
+ read -d '>' c
+ buf+="$c"
+
+ if ${isendtag} ; then
+ [ ! -z "${callbacks["tag_end"]}" ] && ${callbacks["tag_end"]} "${1}" "tag_end" "$buf"
+ else
+ [ ! -z "${callbacks["tag_begin"]}" ] && ${callbacks["tag_begin"]} "${1}" "tag_begin" "$buf"
+
+ # handle tags like <br/> (which are start- and end-tag in one piece)
+ if [[ "${buf}" = ~(Er).*/ ]] ; then
+ [ ! -z "${callbacks["tag_end"]}" ] && ${callbacks["tag_end"]} "${1}" "tag_end" "$buf"
+ fi
+ fi
+ buf=""
+ else
+ buf+="$c"
+ fi
+ done
+
+ [ ! -z "${callbacks["document_end"]}" ] && ${callbacks["document_start"]} "${1}" "document_end" "exit_success"
+
+ print # final newline to make filters like "sed" happy
+}
+
+# return the value of LC_MESSAGES needed for subprocesses which
+# want to run in a different locale/encoding
+function get_lc_messages
+{
+ [ "${LC_ALL}" != "" ] && { print "${LC_ALL}" ; return 0 ; }
+ [ "${LC_MESSAGES}" != "" ] && { print "${LC_MESSAGES}" ; return 0 ; }
+ [ "${LANG}" != "" ] && { print "${LANG}" ; return 0 ; }
+ print "C" ; return 0
+}
+
+function usage
+{
+ OPTIND=0
+ getopts -a "${progname}" "${USAGE}" OPT '-?'
+ exit 2
+}
+
+# make sure we use the ksh93 builtin versions
+builtin cat
+builtin printf
+
+typeset -A rsstok_cb # callbacks for xml_tok
+rsstok_cb["tag_begin"]="handle_rss"
+rsstok_cb["tag_end"]="handle_rss"
+rsstok_cb["tag_text"]="handle_rss"
+rsstok_cb["textbuf"]=""
+
+typeset -A xhtmltok_cb # callbacks for xml_tok
+xhtmltok_cb["tag_begin"]="handle_html"
+xhtmltok_cb["tag_end"]="handle_html"
+xhtmltok_cb["tag_text"]="handle_html"
+xhtmltok_cb["textbuf"]=""
+xhtmltok_cb["html_pre"]=0
+
+typeset -A item
+
+typeset -A bookmark_urls
+
+# "ramdom" urls for testing
+bookmark_urls=(
+ ["google_blogs_ksh"]="http://blogsearch.google.com/blogsearch_feeds?hl=en&scoring=d&q=ksh&ie=utf-8&num=100&output=rss"
+ ["ksh93_integration"]="http://www.opensolaris.org/rss/os/project/ksh93-integration/announcements/rss2.xml"
+ ["blogs_sun_com"]="http://blogs.sun.com/main/feed/entries/rss"
+ ["jmcp"]="http://www.jmcp.homeunix.com/roller/rss/jmcp"
+ ["katakai"]="http://blogs.sun.com/katakai/feed/entries/rss"
+ ["planetsun"]="http://www.planetsun.org/rss20.xml"
+ ["planetsolaris"]="http://www.planetsolaris.org/rss20.xml"
+ ["planetopensolaris"]="http://planet.opensolaris.org/rss20.xml"
+)
+
+progname="${0}"
+
+USAGE=$'
+[-?
+@(#)\$Id: rssread (Roland Mainz) 2007-06-05 \$
+]
+[+NAME?rssread - fetch RSS messages and convert them to plain text]
+[+DESCRIPTION?\brssread\b RSS to plain text converter
+ which fetches RSS streams via HTTP and converts them from RSS to HTML to plain UTF-8 text.]
+
+[ url ]
+
+[+SEE ALSO?\bksh93\b(1)]
+'
+
+while getopts -a "${progname}" "${USAGE}" OPT ; do
+# printmsg "## OPT=|${OPT}|, OPTARG=|${OPTARG}|"
+ case ${OPT} in
+ *) usage ;;
+ esac
+done
+shift ${OPTIND}-1
+
+url="$1"
+
+if [ "$url" = "" ] ; then
+ fatal_error $"No url given."
+fi
+
+if [ "${bookmark_urls[${url}]}" != "" ] ; then
+ printmsg $"Using bookmark ${url} = ${bookmark_urls[${url}]}"
+ url="${bookmark_urls[${url}]}"
+fi
+
+(
+ # set unicode locale since RSS is encoded in UTF-8
+ # (and make sure $LC_MESSAGES is set to the parent
+ # process's locale that all error messages are using
+ # the callers locale/encoding)
+ export \
+ LC_MESSAGES="$(get_lc_messages)" \
+ LC_MONETARY="en_US.UTF-8" \
+ LC_NUMERIC="en_US.UTF-8" \
+ LC_COLLATE="en_US.UTF-8" \
+ LC_CTYPE="en_US.UTF-8" \
+ LC_TIME="en_US.UTF-8" \
+ LANG="en_US.UTF-8"
+
+ cat_http "$url" |
+ xml_tok "rsstok_cb"
+) # | iconv -f "UTF-8" - -
+
+#EOF.
diff --git a/usr/src/lib/libshell/common/fun/termclock b/usr/src/lib/libshell/common/fun/termclock
new file mode 100644
index 0000000000..9bf0cf6d85
--- /dev/null
+++ b/usr/src/lib/libshell/common/fun/termclock
@@ -0,0 +1,267 @@
+#!/bin/ksh93
+
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+#
+# termclock - a simple analog clock for terminals
+#
+
+# Solaris needs /usr/xpg4/bin/ because the tools in /usr/bin are not POSIX-conformant
+export PATH=/usr/xpg4/bin:/bin:/usr/bin
+
+function fatal_error
+{
+ print -u 2 "${progname}: $@"
+ exit 1
+}
+
+# cache tput values (to avoid |fork()|'ing a "tput" child every second)
+function tput_cup
+{
+ integer y="$1" x="$2"
+ nameref c=tput_cup_cache["${y}_${x}"]
+
+ if [ "$c" == "" ] ; then
+ # fast path for known terminal types
+ if [[ ${TERM} = ~(Elr)(vt100|vt220|xterm|xterm-color|dtterm) ]] ; then
+ c="$(printf "\E[%d;%dH" $((y+1)) $((x+1)))"
+ else
+ c="$(tput cup $y $x)"
+ fi
+ fi
+
+ print -n "$c"
+}
+
+function draw_clock
+{
+ float angle a
+ float x y
+
+ for(( angle=0.0 ; angle < 360. ; angle+=6 )) ; do
+ (( a=angle/360.*(2*M_PI) ))
+
+ (( x=clock.len_x*cos(a) ))
+ (( y=clock.len_y*sin(a) ))
+ tput_cup $(( y+clock.middle_y )) $(( x+clock.middle_x ))
+
+ # add "mark" every 30 degrees
+ if (( int(angle)%30 == 0 )) ; then
+ print -n "0"
+ else
+ print -n "x"
+ fi
+ done
+}
+
+function draw_hand
+{
+ float angle="$1" a
+ typeset ch="$2"
+ float length="$3"
+ float x y
+
+ (( a=angle/360.*(2*M_PI) ))
+
+ for(( s=0.0 ; s < 10. ; s+=0.5 )) ; do
+ (( x=(clock.len_x*(s/10.)*(length/100.))*cos(a) ))
+ (( y=(clock.len_y*(s/10.)*(length/100.))*sin(a) ))
+
+ tput_cup $(( y+clock.middle_y )) $(( x+clock.middle_x ))
+ print -n "${ch}"
+ done
+}
+
+function draw_clock_hand
+{
+ nameref hand=$1
+
+ draw_hand $(( 360.*(hand.val/hand.scale)-90. )) "${hand.ch}" ${hand.length}
+}
+
+function clear_clock_hand
+{
+ nameref hand=$1
+
+ draw_hand $(( 360.*(hand.val/hand.scale)-90. )) " " ${hand.length}
+}
+
+function main_loop
+{
+ typeset c
+
+ # note: we can't use subshells when writing to the double-buffer file because this
+ # will render the tput value cache useless
+ while true ; do
+ if ${init_screen} ; then
+ init_screen="false"
+
+ # "resize" is needed because older versions of ksh93 may have
+ # trouble with getting the right terminal size at startup
+ [ -x "/usr/X11/bin/resize" ] && eval "$(/usr/X11/bin/resize -u)" ||
+ [ -x "/usr/X11R6/bin/resize" ] && eval "$(/usr/X11R6/bin/resize -u)" ||
+ [ -x "/usr/openwin/bin/resize" ] && eval "$(/usr/openwin/bin/resize -u)" ||
+ fatal_error "resize not found."
+
+ (( clock.middle_x=COLUMNS/2.-.5 ))
+ (( clock.middle_y=LINES/2.-.5 ))
+ (( clock.len_x=COLUMNS/2-2 ))
+ (( clock.len_y=LINES/2-2 ))
+
+ {
+ clear
+ draw_clock
+ } >&6
+ fi
+
+ {
+ (( $(date +"hours.val=%H , minutes.val=%M , seconds.val=%S") ))
+
+ # small trick to get a smooth "analog" flair
+ (( hours.val+=minutes.val/60. ))
+ (( minutes.val+=seconds.val/60. ))
+
+ draw_clock_hand seconds
+ draw_clock_hand minutes
+ draw_clock_hand hours
+
+ # move cursor to home position
+ tput_cup 0 0
+ } >&6
+
+ 6<#((0))
+ cat <&6
+
+ 6<&- ; rm -f "${scratchfile}" ; exec 6<>"${scratchfile}"
+
+ c="" ; read -t ${update_interval} -n 1 c
+ if [ "$c" != "" ] ; then
+ case "$c" in
+ ~(Ei)q | $'\E') return 0 ;;
+ esac
+ fi
+
+ {
+ clear_clock_hand hours
+ clear_clock_hand minutes
+ clear_clock_hand seconds
+ } >&6
+ done
+}
+
+function usage
+{
+ OPTIND=0
+ getopts -a "${progname}" "${USAGE}" OPT '-?'
+ exit 2
+}
+
+# program start
+progname="${0}"
+
+builtin date
+builtin rm
+builtin printf
+
+typeset -A tput_cup_cache
+
+float -r M_PI=3.14159265358979323846
+
+clock=(
+ float middle_x
+ float middle_y
+ integer len_x
+ integer len_y
+)
+
+typeset init_screen="true"
+
+# set clock properties
+seconds=( float val
+ typeset ch
+ float scale
+ integer length )
+minutes=( float val
+ typeset ch
+ float scale
+ integer length )
+hours=( float val
+ typeset ch
+ float scale
+ integer length )
+
+seconds.length=90 seconds.scale=60 seconds.ch="s"
+minutes.length=75 minutes.scale=60 minutes.ch="m"
+hours.length=50 hours.scale=12 hours.ch="h"
+
+float update_interval=0.9
+
+USAGE=$'
+[-?
+@(#)\$Id: termclock (Roland Mainz) 2007-06-05 \$
+]
+[+NAME?termclock - analog clock for terminals]
+[+DESCRIPTION?\btermclock\b is an analog clock for terminals.
+ The termclock program displays the time in analog or digital
+ form. The time is continuously updated at a frequency which
+ may be specified by the user.]
+[u:update?Update interval (defaults to 0.9 seconds).]:[interval]
+[+SEE ALSO?\bksh93\b(1), \bxclock\b(1)]
+'
+
+while getopts -a "${progname}" "${USAGE}" OPT ; do
+# printmsg "## OPT=|${OPT}|, OPTARG=|${OPTARG}|"
+ case ${OPT} in
+ u) update_interval=${OPTARG} ;;
+ *) usage ;;
+ esac
+done
+shift ${OPTIND}-1
+
+# prechecks
+which tput >/dev/null || fatal_error "tput not found."
+which mktemp >/dev/null || fatal_error "mktemp not found."
+(( update_interval < 0. || update_interval > 7200. )) && fatal_error "invalid update_interval value."
+
+# create temporary file for double-buffering and register an EXIT trap
+# to remove this file when the shell interpreter exits
+scratchfile="$(mktemp /tmp/termclock.pid$$.XXXXXX)"
+if [ -z "${scratchfile}" ]; then exit 1; fi
+trap 'rm -f "${scratchfile}"' EXIT
+rm -f "${scratchfile}" ; exec 6<>"${scratchfile}"
+
+# regiter trap to handle window size changes
+trap 'init_screen="true"' WINCH
+
+main_loop
+
+# exiting - put cursor below clock
+tput_cup $((LINES-2)) 0
+
+# EOF.
diff --git a/usr/src/lib/libshell/common/fun/title b/usr/src/lib/libshell/common/fun/title
new file mode 100644
index 0000000000..cf3efdcb00
--- /dev/null
+++ b/usr/src/lib/libshell/common/fun/title
@@ -0,0 +1,57 @@
+# add to (+), delete from (-), set [=], or print (.) window title
+# arguments are eval'd before printing
+# title text string exported in TITLE_TEXT
+
+function title # [ + | - | = | . ] title ...
+{
+ typeset x t="$TITLE_TEXT"
+
+ case $1 in
+ +) shift
+ case $# in
+ 0) ;;
+ *) for x
+ do case " $t " in
+ *" $x "*) ;;
+ " ") t=$x ;;
+ *) t="$t $x" ;;
+ esac
+ done
+ case $t in
+ $TITLE_TEXT) return 1 ;;
+ esac
+ ;;
+ esac
+ ;;
+ -) shift
+ case $# in
+ 0) ;;
+ *) for x
+ do case " $t " in
+ *" $x "*) t="${t%?( )$x*}${t##*$x?( )}" ;;
+ esac
+ done
+ case $t in
+ $TITLE_TEXT) return 1 ;;
+ esac
+ ;;
+ esac
+ ;;
+ .) print -r -- "$TITLE_TEXT"
+ return 0
+ ;;
+ =) shift
+ t="$*"
+ ;;
+ *) t="$*"
+ ;;
+ esac
+ export TITLE_TEXT="$t"
+ eval x=\"$t\"
+ case $TERM in
+ 630*) print -nr -- $'\E[?'"${#x}"$';0v'"${x}" ;;
+ uwin*|*vt100|xterm*) print -nr -- $'\E]0;'"${x}"$'\a' ;;
+ *) return 1 ;;
+ esac
+ return 0
+}
diff --git a/usr/src/lib/libshell/common/include/argnod.h b/usr/src/lib/libshell/common/include/argnod.h
new file mode 100644
index 0000000000..fd93e5b215
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/argnod.h
@@ -0,0 +1,147 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef ARG_RAW
+/*
+ * struct to hold a word argument
+ * Written by David Korn
+ *
+ */
+
+#include <stak.h>
+
+struct ionod
+{
+ unsigned iofile;
+ char *ioname;
+ struct ionod *ionxt;
+ struct ionod *iolst;
+ char *iodelim;
+ off_t iooffset;
+ long iosize;
+ char *iovname;
+};
+
+struct comnod
+{
+ int comtyp;
+ struct ionod *comio;
+ struct argnod *comarg;
+ struct argnod *comset;
+ void *comnamp;
+ void *comnamq;
+ void *comstate;
+ int comline;
+};
+
+#define COMBITS 4
+#define COMMSK ((1<<COMBITS)-1)
+#define COMSCAN (01<<COMBITS)
+#define COMFIXED (02<<COMBITS)
+
+struct slnod /* struct for link list of stacks */
+{
+ struct slnod *slnext;
+ struct slnod *slchild;
+ Stak_t *slptr;
+};
+
+/*
+ * This struct is use to hold $* lists and arrays
+ */
+
+struct dolnod
+{
+ short dolrefcnt; /* reference count */
+ short dolmax; /* size of dolval array */
+ short dolnum; /* number of elements */
+ short dolbot; /* current first element */
+ struct dolnod *dolnxt; /* used when list are chained */
+ char *dolval[1]; /* array of value pointers */
+};
+
+/*
+ * This struct is used to hold word arguments of variable size during
+ * parsing and during expansion. The flags indicate what processing
+ * is required on the argument.
+ */
+
+struct argnod
+{
+ union
+ {
+ struct argnod *ap;
+ char *cp;
+ } argnxt;
+ union
+ {
+ struct argnod *ap;
+ char *cp;
+ int len;
+ } argchn;
+ unsigned char argflag;
+ char argval[4];
+};
+
+
+
+/* The following should evaluate to the offset of argval in argnod */
+#define ARGVAL offsetof(struct argnod,argval[0])
+#define sh_argstr(ap) ((ap)->argflag&ARG_RAW?sh_fmtq((ap)->argval):(ap)->argval)
+#define ARG_SPARE 1
+
+
+/* legal argument flags */
+#define ARG_RAW 0x1 /* string needs no processing */
+#define ARG_MAKE 0x2 /* bit set during argument expansion */
+#define ARG_COMSUB 0x2 /* command sub */
+#define ARG_MAC 0x4 /* string needs macro expansion */
+#define ARG_EXP 0x8 /* string needs file expansion */
+#define ARG_ASSIGN 0x10 /* argument is an assignment */
+#define ARG_QUOTED 0x20 /* word contained quote characters */
+#define ARG_MESSAGE 0x40 /* contains international string */
+#define ARG_APPEND 0x80 /* for += assignment */
+/* The following can be passed as options to sh_macexpand() */
+#define ARG_ARITH 0x100 /* arithmetic expansion */
+#define ARG_OPTIMIZE 0x200 /* try to optimize */
+#define ARG_NOGLOB 0x400 /* no file name expansion */
+#define ARG_LET 0x800 /* processing let command arguments */
+
+extern char **sh_argbuild(int*,const struct comnod*,int);
+extern struct dolnod *sh_argcreate(char*[]);
+extern char *sh_argdolminus(void);
+extern struct dolnod *sh_argfree(struct dolnod*,int);
+extern struct dolnod *sh_argnew(char*[],struct dolnod**);
+extern int sh_argopts(int,char*[]);
+extern void sh_argreset(struct dolnod*,struct dolnod*);
+extern void sh_argset(char*[]);
+extern struct dolnod *sh_arguse(void);
+
+extern const char e_heading[];
+extern const char e_off[];
+extern const char e_on[];
+extern const char e_sptbnl[];
+extern const char e_subst[];
+extern const char e_option[];
+extern const char e_exec[];
+extern const char e_devfdNN[];
+extern const char e_devfdstd[];
+
+#endif /* ARG_RAW */
diff --git a/usr/src/lib/libshell/common/include/builtins.h b/usr/src/lib/libshell/common/include/builtins.h
new file mode 100644
index 0000000000..8c79075fce
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/builtins.h
@@ -0,0 +1,200 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#ifndef SYSDECLARE
+
+#include <option.h>
+#include "FEATURE/options"
+#include "FEATURE/dynamic"
+#include "shtable.h"
+
+#define SYSLOGIN (sh.bltin_cmds)
+#define SYSEXEC (sh.bltin_cmds+1)
+#define SYSSET (sh.bltin_cmds+2)
+#define SYSTRUE (sh.bltin_cmds+4)
+#define SYSCOMMAND (sh.bltin_cmds+5)
+#define SYSCD (sh.bltin_cmds+6)
+#define SYSBREAK (sh.bltin_cmds+7)
+#define SYSCONT (sh.bltin_cmds+8)
+#define SYSTYPESET (sh.bltin_cmds+9)
+#define SYSTEST (sh.bltin_cmds+10)
+#define SYSBRACKET (sh.bltin_cmds+11)
+#define SYSLET (sh.bltin_cmds+12)
+#define SYSEXPORT (sh.bltin_cmds+13)
+#if SHOPT_BASH
+# define SYSLOCAL (sh.bltin_cmds+14)
+#else
+# define SYSLOCAL 0
+#endif
+
+/* entry point for shell special builtins */
+
+#if _BLD_shell && defined(__EXPORT__)
+# define extern __EXPORT__
+#endif
+
+extern int b_alias(int, char*[],void*);
+extern int b_break(int, char*[],void*);
+extern int b_dot_cmd(int, char*[],void*);
+extern int b_exec(int, char*[],void*);
+extern int b_eval(int, char*[],void*);
+extern int b_return(int, char*[],void*);
+extern int B_login(int, char*[],void*);
+extern int b_true(int, char*[],void*);
+extern int b_false(int, char*[],void*);
+extern int b_readonly(int, char*[],void*);
+extern int b_set(int, char*[],void*);
+extern int b_shift(int, char*[],void*);
+extern int b_trap(int, char*[],void*);
+extern int b_typeset(int, char*[],void*);
+extern int b_unset(int, char*[],void*);
+extern int b_unalias(int, char*[],void*);
+
+/* The following are for job control */
+#if defined(SIGCLD) || defined(SIGCHLD)
+ extern int b_jobs(int, char*[],void*);
+ extern int b_kill(int, char*[],void*);
+# ifdef SIGTSTP
+ extern int b_bg(int, char*[],void*);
+# endif /* SIGTSTP */
+#endif
+
+/* The following utilities are built-in because of side-effects */
+extern int b_builtin(int, char*[],void*);
+extern int b_cd(int, char*[],void*);
+extern int b_command(int, char*[],void*);
+extern int b_getopts(int, char*[],void*);
+extern int b_hist(int, char*[],void*);
+extern int b_let(int, char*[],void*);
+extern int b_read(int, char*[],void*);
+extern int b_ulimit(int, char*[],void*);
+extern int b_umask(int, char*[],void*);
+#ifdef _cmd_universe
+ extern int b_universe(int, char*[],void*);
+#endif /* _cmd_universe */
+#if SHOPT_FS_3D
+ extern int b_vpath(int, char*[],void*);
+#endif /* SHOPT_FS_3D */
+extern int b_wait(int, char*[],void*);
+extern int b_whence(int, char*[],void*);
+
+extern int b_alarm(int, char*[],void*);
+extern int b_print(int, char*[],void*);
+extern int b_printf(int, char*[],void*);
+extern int b_pwd(int, char*[],void*);
+extern int b_sleep(int, char*[],void*);
+extern int b_test(int, char*[],void*);
+#if !SHOPT_ECHOPRINT
+ extern int B_echo(int, char*[],void*);
+#endif /* SHOPT_ECHOPRINT */
+
+#undef extern
+
+extern const char e_alrm1[];
+extern const char e_alrm2[];
+extern const char e_badfun[];
+extern const char e_baddisc[];
+extern const char e_nofork[];
+extern const char e_nosignal[];
+extern const char e_nolabels[];
+extern const char e_notimp[];
+extern const char e_nosupport[];
+extern const char e_badbase[];
+extern const char e_overlimit[];
+
+extern const char e_eneedsarg[];
+extern const char e_toodeep[];
+extern const char e_badname[];
+extern const char e_badwrite[];
+extern const char e_badsyntax[];
+#ifdef _cmd_universe
+ extern const char e_nouniverse[];
+#endif /* _cmd_universe */
+extern const char e_histopen[];
+extern const char e_condition[];
+extern const char e_badrange[];
+extern const char e_numeric[];
+extern const char e_trap[];
+extern const char e_direct[];
+extern const char e_defedit[];
+extern const char e_cneedsarg[];
+extern const char e_defined[];
+#if SHOPT_FS_3D
+ extern const char e_cantset[];
+ extern const char e_cantget[];
+ extern const char e_mapping[];
+ extern const char e_versions[];
+#endif /* SHOPT_FS_3D */
+
+/* for option parsing */
+extern const char sh_set[];
+extern const char sh_optalarm[];
+extern const char sh_optalias[];
+extern const char sh_optbreak[];
+extern const char sh_optbuiltin[];
+extern const char sh_optcd[];
+extern const char sh_optcommand[];
+extern const char sh_optcont[];
+extern const char sh_optdot[];
+#ifndef ECHOPRINT
+ extern const char sh_optecho[];
+#endif /* !ECHOPRINT */
+extern const char sh_opteval[];
+extern const char sh_optexec[];
+extern const char sh_optexit[];
+extern const char sh_optexport[];
+extern const char sh_optgetopts[];
+extern const char sh_optbg[];
+extern const char sh_optdisown[];
+extern const char sh_optfg[];
+extern const char sh_opthist[];
+extern const char sh_optjobs[];
+extern const char sh_optkill[];
+extern const char sh_optksh[];
+extern const char sh_optlet[];
+extern const char sh_optprint[];
+extern const char sh_optprintf[];
+extern const char sh_optpwd[];
+extern const char sh_optread[];
+extern const char sh_optreadonly[];
+extern const char sh_optreturn[];
+extern const char sh_optset[];
+extern const char sh_optshift[];
+extern const char sh_optsleep[];
+extern const char sh_opttrap[];
+extern const char sh_opttypeset[];
+extern const char sh_optulimit[];
+extern const char sh_optumask[];
+extern const char sh_optunalias[];
+extern const char sh_optwait[];
+#ifdef _cmd_universe
+ extern const char sh_optuniverse[];
+#endif /* _cmd_universe */
+extern const char sh_optunset[];
+#if SHOPT_FS_3D
+ extern const char sh_optvpath[];
+ extern const char sh_optvmap[];
+#endif /* SHOPT_FS_3D */
+extern const char sh_optwhence[];
+#endif /* SYSDECLARE */
+
+extern const char e_dict[];
+
diff --git a/usr/src/lib/libshell/common/include/defs.h b/usr/src/lib/libshell/common/include/defs.h
new file mode 100644
index 0000000000..91a3d2c3e1
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/defs.h
@@ -0,0 +1,377 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * Shell interface private definitions
+ *
+ */
+
+#include <ast.h>
+#include <sfio.h>
+#include <error.h>
+#include "FEATURE/options"
+#include <cdt.h>
+#include <history.h>
+#include "fault.h"
+#include "argnod.h"
+
+#ifndef pointerof
+#define pointerof(x) ((void*)((char*)0+(x)))
+#endif
+
+#define env_change() (++ast.env_serial)
+#if SHOPT_ENV
+# include <env.h>
+#else
+# define Env_t void
+# define sh_envput(e,p) env_change()
+# define env_delete(e,p) env_change()
+#endif
+
+/*
+ * note that the first few fields have to be the same as for
+ * Shscoped_t in <shell.h>
+ */
+struct sh_scoped
+{
+ struct sh_scoped *prevst; /* pointer to previous state */
+ int dolc;
+ char **dolv;
+ char *cmdname;
+ char *filename;
+ int lineno;
+ Dt_t *save_tree; /* var_tree for calling function */
+ struct sh_scoped *self; /* pointer to copy of this scope*/
+ Dt_t *var_local; /* local level variables for name() */
+ struct slnod *staklist; /* link list of function stacks */
+ int states;
+ int breakcnt;
+ int execbrk;
+ int loopcnt;
+ int firstline;
+ int32_t optindex;
+ int32_t optnum;
+ int32_t tmout; /* value for TMOUT */
+ short optchar;
+ short opterror;
+ int ioset;
+ unsigned short trapmax;
+ char *trap[SH_DEBUGTRAP+1];
+ char **trapcom;
+ char **otrapcom;
+ void *timetrap;
+};
+
+struct limits
+{
+ long arg_max; /* max arg+env exec() size */
+ int open_max; /* maximum number of file descriptors */
+ int clk_tck; /* number of ticks per second */
+ int child_max; /* maxumum number of children */
+ int ngroups_max; /* maximum number of process groups */
+ unsigned char posix_version; /* posix version number */
+ unsigned char posix_jobcontrol;/* non-zero for job control systems */
+ unsigned char fs3d; /* non-zero for 3-d file system */
+};
+
+#define _SH_PRIVATE \
+ struct sh_scoped st; /* scoped information */ \
+ struct limits lim; /* run time limits */ \
+ Sfio_t *heredocs; /* current here-doc temp file */ \
+ Sfio_t *funlog; /* for logging function definitions */ \
+ int **fdptrs; /* pointer to file numbers */ \
+ int savexit; \
+ char *lastarg; \
+ char *lastpath; /* last alsolute path found */ \
+ int path_err; /* last error on path search */ \
+ Dt_t *track_tree; /* for tracked aliases*/ \
+ Namval_t *bltin_nodes; /* pointer to built-in variables */ \
+ Dt_t *var_base; /* global level variables */ \
+ Namval_t *namespace; /* current active namespace*/ \
+ Namval_t *last_table; /* last table used in last nv_open */ \
+ Sfio_t *outpool; /* ouput stream pool */ \
+ long timeout; /* read timeout */ \
+ short curenv; /* current subshell number */ \
+ short jobenv; /* subshell number for jobs */ \
+ int nextprompt; /* next prompt is PS<nextprompt> */ \
+ Namval_t *bltin_cmds; /* pointer to built-in commands */ \
+ Namval_t *posix_fun; /* points to last name() function */ \
+ int infd; /* input file descriptor */ \
+ char *outbuff; /* pointer to output buffer */ \
+ char *errbuff; /* pointer to stderr buffer */ \
+ char *prompt; /* pointer to prompt string */ \
+ char *shname; /* shell name */ \
+ char *shpath; /* path name of shell */ \
+ char *user; /* name of real user for pfsh */ \
+ char *comdiv; /* points to sh -c argument */ \
+ char *prefix; /* prefix for compound assignment */ \
+ sigjmp_buf *jmplist; /* longjmp return stack */ \
+ char **sigmsg; /* points to signal messages */ \
+ int oldexit; \
+ uid_t userid,euserid; /* real and effective user id */ \
+ gid_t groupid,egroupid;/* real and effective group id */ \
+ pid_t pid; /* process id of shell */ \
+ pid_t bckpid; /* background process id */ \
+ pid_t cpid; \
+ int32_t ppid; /* parent process id of shell */ \
+ int topfd; \
+ int sigmax; /* maximum number of signals */ \
+ int savesig; \
+ unsigned char *sigflag; /* pointer to signal states */ \
+ char intrap; \
+ char login_sh; \
+ char lastbase; \
+ char forked; \
+ char binscript; \
+ char deftype; \
+ char used_pos; /* used postional parameter */\
+ unsigned char lastsig; /* last signal received */ \
+ char *readscript; /* set before reading a script */ \
+ int *inpipe; /* input pipe pointer */ \
+ int *outpipe; /* output pipe pointer */ \
+ int cpipe[2]; \
+ int coutpipe; \
+ int inuse_bits; \
+ struct argnod *envlist; \
+ struct dolnod *arglist; \
+ int fn_depth; \
+ int dot_depth; \
+ int hist_depth; \
+ int xargmin; \
+ int xargmax; \
+ int xargexit; \
+ mode_t mask; \
+ long nforks; \
+ Env_t *env; \
+ void *init_context; \
+ void *mac_context; \
+ void *lex_context; \
+ void *arg_context; \
+ void *ed_context; \
+ void *job_context; \
+ void *pathlist; \
+ void *defpathlist; \
+ void *cdpathlist; \
+ char **argaddr; \
+ void *optlist; \
+ int optcount ; \
+ struct sh_scoped global; \
+ struct checkpt checkbase; \
+ Shinit_f userinit; \
+ Shbltin_f bltinfun; \
+ Shwait_f waitevent; \
+ char *cur_line; \
+ char *rcfile; \
+ char **login_files; \
+ short offsets[10]; \
+ Sfio_t **sftable; \
+ unsigned char *fdstatus; \
+ const char *pwd; \
+ History_t *hist_ptr; \
+ char universe; \
+ void *jmpbuffer; \
+ void *mktype; \
+ Sfio_t *strbuf; \
+ Dt_t *last_root; \
+ char ifstable[256]; \
+ Shopt_t offoptions;
+
+#include <shell.h>
+
+
+/* error exits from various parts of shell */
+#define NIL(type) ((type)0)
+
+#define new_of(type,x) ((type*)malloc((unsigned)sizeof(type)+(x)))
+
+#define exitset() (sh.savexit=sh.exitval)
+
+#ifndef SH_DICT
+#define SH_DICT (void*)e_dict
+#endif
+
+#ifndef SH_CMDLIB_DIR
+#define SH_CMDLIB_DIR "/opt/ast/bin"
+#endif
+
+/* states */
+/* low numbered states are same as options */
+#define SH_NOFORK 0 /* set when fork not necessary, not a state */
+#define SH_COMPLETE 0 /* set for command completion */
+#define SH_FORKED 7 /* set when process has been forked */
+#define SH_PROFILE 8 /* set when processing profiles */
+#define SH_NOALIAS 9 /* do not expand non-exported aliases */
+#define SH_NOTRACK 10 /* set to disable sftrack() function */
+#define SH_STOPOK 11 /* set for stopable builtins */
+#define SH_GRACE 12 /* set for timeout grace period */
+#define SH_TIMING 13 /* set while timing pipelines */
+#define SH_DEFPATH 14 /* set when using default path */
+#define SH_INIT 15 /* set when initializing the shell */
+#define SH_TTYWAIT 16 /* waiting for keyboard input */
+#define SH_FCOMPLETE 17 /* set for filename completion */
+#define SH_PREINIT 18 /* set with SH_INIT before parsing options */
+
+#define SH_BASH 41
+#define SH_BRACEEXPAND 42
+#define SH_POSIX 46
+#define SH_MULTILINE 47
+
+#define SH_NOPROFILE 78
+#define SH_NOUSRPROFILE 79
+#define SH_LOGIN_SHELL 67
+#define SH_COMMANDLINE 0x100
+#define SH_BASHEXTRA 0x200
+#define SH_BASHOPT 0x400
+
+#define SH_ID "ksh" /* ksh id */
+#define SH_STD "sh" /* standard sh id */
+
+/* defines for sh_type() */
+
+#define SH_TYPE_SH 001
+#define SH_TYPE_KSH 002
+#define SH_TYPE_BASH 004
+#define SH_TYPE_LOGIN 010
+#define SH_TYPE_PROFILE 020
+#define SH_TYPE_RESTRICTED 040
+
+#if SHOPT_BASH
+# ifndef SHOPT_HISTEXPAND
+# define SHOPT_HISTEXPAND 1
+# endif
+/*
+ * define for all the bash options
+ */
+# define SH_CDABLE_VARS 51
+# define SH_CDSPELL 52
+# define SH_CHECKHASH 53
+# define SH_CHECKWINSIZE 54
+# define SH_CMDHIST 55
+# define SH_DOTGLOB 56
+# define SH_EXECFAIL 57
+# define SH_EXPAND_ALIASES 58
+# define SH_EXTGLOB 59
+# define SH_HOSTCOMPLETE 63
+# define SH_HUPONEXIT 64
+# define SH_INTERACTIVE_COMM 65
+# define SH_LITHIST 66
+# define SH_MAILWARN 68
+# define SH_NOEMPTYCMDCOMPL 69
+# define SH_NOCASEGLOB 70
+# define SH_NULLGLOB 71
+# define SH_PHYSICAL 45
+# define SH_PROGCOMP 72
+# define SH_PROMPTVARS 73
+# define SH_RESTRICTED2 74
+# define SH_SHIFT_VERBOSE 75
+# define SH_SOURCEPATH 76
+# define SH_XPG_ECHO 77
+#endif
+
+#if SHOPT_HISTEXPAND
+# define SH_HISTAPPEND 60
+# define SH_HISTEXPAND 43
+# define SH_HISTORY2 44
+# define SH_HISTREEDIT 61
+# define SH_HISTVERIFY 62
+#endif
+
+#ifndef PIPE_BUF
+# define PIPE_BUF 512
+#endif
+
+#define MATCH_MAX 64
+
+extern int sh_addlib(void*);
+extern void *sh_argopen(Shell_t*);
+extern Namval_t *sh_assignok(Namval_t*,int);
+extern char *sh_checkid(char*,char*);
+extern int sh_debug(const char*,const char*,const char*,char *const[],int);
+extern int sh_echolist(Sfio_t*, int, char**);
+extern struct argnod *sh_endword(int);
+extern char **sh_envgen(void);
+#if SHOPT_ENV
+extern void sh_envput(Env_t*, Namval_t*);
+#endif
+extern void sh_envnolocal(Namval_t*,void*);
+extern Sfdouble_t sh_arith(const char*);
+extern void *sh_arithcomp(char*);
+extern pid_t sh_fork(int,int*);
+extern pid_t _sh_fork(pid_t, int ,int*);
+extern char *sh_mactrim(char*,int);
+extern int sh_macexpand(struct argnod*,struct argnod**,int);
+extern void sh_machere(Sfio_t*, Sfio_t*, char*);
+extern void *sh_macopen(Shell_t*);
+extern char *sh_macpat(struct argnod*,int);
+extern char *sh_mactry(char*);
+extern void sh_printopts(Shopt_t,int,Shopt_t*);
+extern int sh_readline(Shell_t*,char**,int,int,long);
+extern Sfio_t *sh_sfeval(char*[]);
+extern void sh_setmatch(const char*,int,int,int[]);
+extern Dt_t *sh_subaliastree(int);
+extern Dt_t *sh_subfuntree(int);
+extern int sh_subsavefd(int);
+extern void sh_subtmpfile(void);
+extern char *sh_substitute(const char*,const char*,char*);
+extern const char *_sh_translate(const char*);
+extern int sh_trace(char*[],int);
+extern void sh_trim(char*);
+extern int sh_type(const char*);
+extern void sh_utol(const char*, char*);
+extern int sh_whence(char**,int);
+
+#ifndef ERROR_dictionary
+# define ERROR_dictionary(s) (s)
+#endif
+#define sh_translate(s) _sh_translate(ERROR_dictionary(s))
+
+#define WBITS (sizeof(long)*8)
+#define WMASK (0xff)
+
+#define is_option(s,x) ((s)->v[((x)&WMASK)/WBITS] & (1L << ((x) % WBITS)))
+#define on_option(s,x) ((s)->v[((x)&WMASK)/WBITS] |= (1L << ((x) % WBITS)))
+#define off_option(s,x) ((s)->v[((x)&WMASK)/WBITS] &= ~(1L << ((x) % WBITS)))
+#define sh_isoption(x) is_option(&sh.options,x)
+#define sh_onoption(x) on_option(&sh.options,x)
+#define sh_offoption(x) off_option(&sh.options,x)
+
+
+#define sh_state(x) ( 1<<(x))
+#define sh_isstate(x) (sh.st.states&sh_state(x))
+#define sh_onstate(x) (sh.st.states |= sh_state(x))
+#define sh_offstate(x) (sh.st.states &= ~sh_state(x))
+#define sh_getstate() (sh.st.states)
+#define sh_setstate(x) (sh.st.states = (x))
+
+#define sh_sigcheck() do{if(sh.trapnote&SH_SIGSET)sh_exit(SH_EXITSIG);} while(0)
+
+extern int32_t sh_mailchk;
+extern const char e_dict[];
+
+/* sh_printopts() mode flags -- set --[no]option by default */
+
+#define PRINT_VERBOSE 0x01 /* option on|off list */
+#define PRINT_ALL 0x02 /* list unset iptions too */
+#define PRINT_NO_HEADER 0x04 /* omit listing header */
+#define PRINT_SHOPT 0x08 /* shopt -s|-u */
+#define PRINT_TABLE 0x10 /* table of all options */
diff --git a/usr/src/lib/libshell/common/include/edit.h b/usr/src/lib/libshell/common/include/edit.h
new file mode 100644
index 0000000000..ddbd45c24b
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/edit.h
@@ -0,0 +1,257 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef SEARCHSIZE
+/*
+ * edit.h - common data structure for vi and emacs edit options
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#define SEARCHSIZE 80
+
+#include "FEATURE/options"
+#include "FEATURE/locale"
+#if !SHOPT_VSH && !SHOPT_ESH
+# define ed_winsize() (SEARCHSIZE)
+#else
+
+#if !KSHELL
+# include <setjmp.h>
+# include <sig.h>
+# include <ctype.h>
+#endif /* KSHELL */
+
+#include "FEATURE/setjmp"
+#include "terminal.h"
+
+#define STRIP 0377
+#define LOOKAHEAD 80
+
+#if SHOPT_MULTIBYTE
+# ifndef ESS_MAXCHAR
+# include "national.h"
+# endif /* ESS_MAXCHAR */
+ typedef wchar_t genchar;
+# define CHARSIZE (sizeof(wchar_t)<=2?3:sizeof(wchar_t))
+#else
+ typedef char genchar;
+# define CHARSIZE 1
+#endif /* SHOPT_MULTIBYTE */
+
+#define TABSIZE 8
+#define PRSIZE 160
+#define MAXLINE 1024 /* longest edit line permitted */
+
+typedef struct _edit_pos
+{
+ unsigned short line;
+ unsigned short col;
+} Edpos_t;
+
+typedef struct edit
+{
+ sigjmp_buf e_env;
+ int e_kill;
+ int e_erase;
+ int e_werase;
+ int e_eof;
+ int e_lnext;
+ int e_fchar;
+ int e_plen; /* length of prompt string */
+ int e_crlf; /* zero if cannot return to beginning of line */
+ int e_llimit; /* line length limit */
+ int e_hline; /* current history line number */
+ int e_hloff; /* line number offset for command */
+ int e_hismin; /* minimum history line number */
+ int e_hismax; /* maximum history line number */
+ int e_raw; /* set when in raw mode or alt mode */
+ int e_cur; /* current line position */
+ int e_eol; /* end-of-line position */
+ int e_pcur; /* current physical line position */
+ int e_peol; /* end of physical line position */
+ int e_mode; /* edit mode */
+ int e_lookahead; /* index in look-ahead buffer */
+ int e_repeat;
+ int e_saved;
+ int e_fcol; /* first column */
+ int e_ucol; /* column for undo */
+ int e_wsize; /* width of display window */
+ char *e_outbase; /* pointer to start of output buffer */
+ char *e_outptr; /* pointer to position in output buffer */
+ char *e_outlast; /* pointer to end of output buffer */
+ genchar *e_inbuf; /* pointer to input buffer */
+ char *e_prompt; /* pointer to buffer containing the prompt */
+ genchar *e_ubuf; /* pointer to the undo buffer */
+ genchar *e_killbuf; /* pointer to delete buffer */
+ char e_search[SEARCHSIZE]; /* search string */
+ genchar *e_Ubuf; /* temporary workspace buffer */
+ genchar *e_physbuf; /* temporary workspace buffer */
+ int e_lbuf[LOOKAHEAD];/* pointer to look-ahead buffer */
+ int e_fd; /* file descriptor */
+ int e_ttyspeed; /* line speed, also indicates tty parms are valid */
+ int e_tabcount;
+#ifdef _hdr_utime
+ ino_t e_tty_ino;
+ dev_t e_tty_dev;
+ char *e_tty;
+#endif
+#if SHOPT_OLDTERMIO
+ char e_echoctl;
+ char e_tcgeta;
+ struct termio e_ott;
+#endif
+#if SHOPT_MULTIBYTE
+ int e_curchar;
+ int e_cursize;
+#endif
+ int *e_globals; /* global variables */
+ genchar *e_window; /* display window image */
+ char e_inmacro; /* processing macro expansion */
+#if KSHELL
+ char e_vi_insert[2]; /* for sh_keytrap */
+ int32_t e_col; /* for sh_keytrap */
+#else
+ char e_prbuff[PRSIZE]; /* prompt buffer */
+#endif /* KSHELL */
+ struct termios e_ttyparm; /* initial tty parameters */
+ struct termios e_nttyparm; /* raw tty parameters */
+ struct termios e_savetty; /* saved terminal state */
+ int e_savefd; /* file descriptor for saved terminal state */
+ char e_macro[4]; /* macro buffer */
+ void *e_vi; /* vi specific data */
+ void *e_emacs; /* emacs specific data */
+ Shell_t *sh; /* interpreter pointer */
+ char *e_stkptr; /* saved stack pointer */
+ int e_stkoff; /* saved stack offset */
+ char **e_clist; /* completion list after <ESC>= */
+ int e_nlist; /* number of elements on completion list */
+ int e_multiline; /* allow multiple lines for editing */
+ int e_winsz; /* columns in window */
+ Edpos_t e_curpos; /* cursor line and column */
+ Namval_t *e_default; /* variable containing default value */
+ Namval_t *e_term; /* TERM variable */
+ char e_termname[80]; /* terminal name */
+} Edit_t;
+
+#undef MAXWINDOW
+#define MAXWINDOW 300 /* maximum width window */
+#define FAST 2
+#define SLOW 1
+#define ESC cntl('[')
+#define UEOF -2 /* user eof char synonym */
+#define UINTR -3 /* user intr char synonym */
+#define UERASE -4 /* user erase char synonym */
+#define UKILL -5 /* user kill char synonym */
+#define UWERASE -6 /* user word erase char synonym */
+#define ULNEXT -7 /* user next literal char synonym */
+
+#if ( 'a' == 97) /* ASCII? */
+# define cntl(x) (x&037)
+#else
+# define cntl(c) (c=='D'?55:(c=='E'?45:(c=='F'?46:(c=='G'?'\a':(c=='H'?'\b': \
+ (c=='I'?'\t':(c=='J'?'\n':(c=='T'?60:(c=='U'?61:(c=='V'?50: \
+ (c=='W'?38:(c=='Z'?63:(c=='['?39:(c==']'?29: \
+ (c<'J'?c+1-'A':(c+10-'J'))))))))))))))))
+#endif
+
+#if !KSHELL
+# define STRIP 0377
+# define GMACS 1
+# define EMACS 2
+# define VIRAW 4
+# define EDITVI 8
+# define NOHIST 16
+# define EDITMASK 15
+# define is_option(m) (opt_flag&(m))
+ extern char opt_flag;
+# ifdef SYSCALL
+# define read(fd,buff,n) syscall(3,fd,buff,n)
+# else
+# define read(fd,buff,n) rEAd(fd,buff,n)
+# endif /* SYSCALL */
+#endif /* KSHELL */
+
+extern void ed_crlf(Edit_t*);
+extern void ed_putchar(Edit_t*, int);
+extern void ed_ringbell(void);
+extern void ed_setup(Edit_t*,int, int);
+extern void ed_flush(Edit_t*);
+extern int ed_getchar(Edit_t*,int);
+extern int ed_virt_to_phys(Edit_t*,genchar*,genchar*,int,int,int);
+extern int ed_window(void);
+extern void ed_ungetchar(Edit_t*,int);
+extern int ed_viread(void*, int, char*, int, int);
+extern int ed_read(void*, int, char*, int, int);
+extern int ed_emacsread(void*, int, char*, int, int);
+extern Edpos_t ed_curpos(Edit_t*, genchar*, int, int, Edpos_t);
+extern int ed_setcursor(Edit_t*, genchar*, int, int, int);
+#if KSHELL
+ extern int ed_macro(Edit_t*,int);
+ extern int ed_expand(Edit_t*, char[],int*,int*,int,int);
+ extern int ed_fulledit(Edit_t*);
+ extern void *ed_open(Shell_t*);
+#endif /* KSHELL */
+# if SHOPT_MULTIBYTE
+ extern int ed_internal(const char*, genchar*);
+ extern int ed_external(const genchar*, char*);
+ extern void ed_gencpy(genchar*,const genchar*);
+ extern void ed_genncpy(genchar*,const genchar*,int);
+ extern int ed_genlen(const genchar*);
+ extern int ed_setwidth(const char*);
+# endif /* SHOPT_MULTIBYTE */
+
+extern const char e_runvi[];
+#if !KSHELL
+ extern const char e_version[];
+#endif /* KSHELL */
+
+#if SHOPT_HISTEXPAND
+
+/* flags */
+
+#define HIST_EVENT 0x1 /* event designator seen */
+#define HIST_QUESTION 0x2 /* question mark event designator */
+#define HIST_HASH 0x4 /* hash event designator */
+#define HIST_WORDDSGN 0x8 /* word designator seen */
+#define HIST_QUICKSUBST 0x10 /* quick substition designator seen */
+#define HIST_SUBSTITUTE 0x20 /* for substition loop */
+#define HIST_NEWLINE 0x40 /* newline in squashed white space */
+
+/* modifier flags */
+
+#define HIST_PRINT 0x100 /* print new command */
+#define HIST_QUOTE 0x200 /* quote resulting history line */
+#define HIST_QUOTE_BR 0x400 /* quote every word on space break */
+#define HIST_GLOBALSUBST 0x800 /* apply substition globally */
+
+#define HIST_ERROR 0x1000 /* an error ocurred */
+
+/* flags to be returned */
+
+#define HIST_FLAG_RETURN_MASK (HIST_EVENT|HIST_PRINT|HIST_ERROR)
+
+extern int hist_expand(const char *, char **);
+#endif
+
+#endif
+#endif
diff --git a/usr/src/lib/libshell/common/include/env.h b/usr/src/lib/libshell/common/include/env.h
new file mode 100644
index 0000000000..f888913c34
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/env.h
@@ -0,0 +1,50 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef _ENV_H
+#define _ENV_H 1
+
+#ifdef _BLD_env
+# ifdef __EXPORT__
+# define export __EXPORT__
+# endif
+#else
+ typedef void *Env_t;
+#endif
+
+/* for use with env_open */
+#define ENV_STABLE (-1)
+
+/* for third agument to env_add */
+#define ENV_MALLOCED 1
+#define ENV_STRDUP 2
+
+extern void env_close(Env_t*);
+extern int env_add(Env_t*, const char*, int);
+extern int env_delete(Env_t*, const char*);
+extern char **env_get(Env_t*);
+extern Env_t *env_open(char**,int);
+extern Env_t *env_scope(Env_t*,int);
+
+#undef extern
+
+#endif
+
+
diff --git a/usr/src/lib/libshell/common/include/fault.h b/usr/src/lib/libshell/common/include/fault.h
new file mode 100644
index 0000000000..107b337f68
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/fault.h
@@ -0,0 +1,124 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef SH_SIGBITS
+/*
+ * UNIX shell
+ * S. R. Bourne
+ * Rewritten by David Korn
+ *
+ */
+
+#include <sig.h>
+#include <setjmp.h>
+#include <error.h>
+#include <sfio.h>
+#include "FEATURE/setjmp"
+#include "FEATURE/sigfeatures"
+
+#ifndef SIGWINCH
+# ifdef SIGWIND
+# define SIGWINCH SIGWIND
+# else
+# ifdef SIGWINDOW
+# define SIGWINCH SIGWINDOW
+# endif
+# endif
+#endif
+
+typedef void (*SH_SIGTYPE)(int,void(*)(int));
+
+#define SH_FORKLIM 16 /* fork timeout interval */
+
+#define SH_TRAP 0200 /* bit for internal traps */
+#define SH_ERRTRAP 0 /* trap for non-zero exit status */
+#define SH_KEYTRAP 1 /* trap for keyboard event */
+#define SH_DEBUGTRAP 4 /* must be last internal trap */
+
+#define SH_SIGBITS 8
+#define SH_SIGFAULT 1 /* signal handler is sh_fault */
+#define SH_SIGOFF 2 /* signal handler is SIG_IGN */
+#define SH_SIGSET 4 /* pending signal */
+#define SH_SIGTRAP 010 /* pending trap */
+#define SH_SIGDONE 020 /* default is exit */
+#define SH_SIGIGNORE 040 /* default is ingore signal */
+#define SH_SIGINTERACTIVE 0100 /* handle interactive specially */
+#define SH_SIGTSTP 0200 /* tstp signal received */
+#define SH_SIGALRM 0200 /* timer alarm received */
+#define SH_SIGTERM SH_SIGOFF /* term signal received */
+
+/*
+ * These are longjmp values
+ */
+
+#define SH_JMPDOT 2
+#define SH_JMPEVAL 3
+#define SH_JMPTRAP 4
+#define SH_JMPIO 5
+#define SH_JMPCMD 6
+#define SH_JMPFUN 7
+#define SH_JMPERRFN 8
+#define SH_JMPSUB 9
+#define SH_JMPERREXIT 10
+#define SH_JMPEXIT 11
+#define SH_JMPSCRIPT 12
+
+struct openlist
+{
+ Sfio_t *strm;
+ struct openlist *next;
+};
+
+struct checkpt
+{
+ sigjmp_buf buff;
+ sigjmp_buf *prev;
+ int topfd;
+ int mode;
+ struct openlist *olist;
+#if (ERROR_VERSION >= 20030214L)
+ Error_context_t err;
+#else
+ struct errorcontext err;
+#endif
+};
+
+#define sh_pushcontext(bp,n) ( (bp)->mode=(n) , (bp)->olist=0, \
+ (bp)->topfd=sh.topfd, (bp)->prev=sh.jmplist, \
+ (bp)->err = *ERROR_CONTEXT_BASE, \
+ sh.jmplist = (sigjmp_buf*)(&(bp)->buff) \
+ )
+#define sh_popcontext(bp) (sh.jmplist=(bp)->prev, errorpop(&((bp)->err)))
+
+extern void sh_fault(int);
+extern void sh_done(int);
+extern void sh_chktrap(void);
+extern void sh_sigclear(int);
+extern void sh_sigdone(void);
+extern void sh_siginit(void);
+extern void sh_sigtrap(int);
+extern void sh_sigreset(int);
+extern void sh_timetraps(void);
+extern void *sh_timeradd(unsigned long,int ,void (*)(void*),void*);
+extern void timerdel(void*);
+
+extern const char e_alarm[];
+
+#endif /* !SH_SIGBITS */
diff --git a/usr/src/lib/libshell/common/include/fcin.h b/usr/src/lib/libshell/common/include/fcin.h
new file mode 100644
index 0000000000..c147a8fdef
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/fcin.h
@@ -0,0 +1,62 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef fcgetc
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * Fast character input with sfio text streams and strings
+ *
+ */
+
+#include <sfio.h>
+
+typedef struct _fcin
+{
+ Sfio_t *_fcfile; /* input file pointer */
+ unsigned char *fcbuff; /* pointer to input buffer */
+ unsigned char *fclast; /* pointer to end of input buffer */
+ unsigned char *fcptr; /* pointer to next input char */
+ unsigned char fcchar; /* saved character */
+ void (*fcfun)(Sfio_t*,const char*,int); /* advance function */
+ int fcleft; /* for multibyte boundary */
+ Sfoff_t fcoff; /* offset for last read */
+} Fcin_t;
+
+#define fcfile() (_Fcin._fcfile)
+#define fcgetc(c) (((c=fcget()) || (c=fcfill())), c)
+#define fcget() ((int)(*_Fcin.fcptr++))
+#define fcpeek(n) ((int)_Fcin.fcptr[n])
+#define fcseek(n) ((char*)(_Fcin.fcptr+=(n)))
+#define fcfirst() ((char*)_Fcin.fcbuff)
+#define fcsopen(s) (_Fcin._fcfile=(Sfio_t*)0,_Fcin.fcbuff=_Fcin.fcptr=(unsigned char*)(s))
+#define fctell() (_Fcin.fcoff + (_Fcin.fcptr-_Fcin.fcbuff))
+#define fcsave(x) (*(x) = _Fcin)
+#define fcrestore(x) (_Fcin = *(x))
+extern int fcfill(void);
+extern int fcfopen(Sfio_t*);
+extern int fcclose(void);
+void fcnotify(void(*)(Sfio_t*,const char*,int));
+extern int fcmbstate(const char*,int*,int*);
+
+extern Fcin_t _Fcin; /* used by macros */
+
+#endif /* fcgetc */
diff --git a/usr/src/lib/libshell/common/include/history.h b/usr/src/lib/libshell/common/include/history.h
new file mode 100644
index 0000000000..f97cd8b4a4
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/history.h
@@ -0,0 +1,75 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef HIST_VERSION
+/*
+ * Interface for history mechanism
+ * written by David Korn
+ *
+ */
+
+#include <ast.h>
+
+#define HIST_CHAR '!'
+#define HIST_VERSION 1 /* history file format version no. */
+
+typedef struct
+{
+ Sfdisc_t histdisc; /* discipline for history */
+ Sfio_t *histfp; /* history file stream pointer */
+ char *histname; /* name of history file */
+ int32_t histind; /* current command number index */
+ int histsize; /* number of accessible history lines */
+#ifdef _HIST_PRIVATE
+ _HIST_PRIVATE
+#endif /* _HIST_PRIVATE */
+} History_t;
+
+typedef struct
+{
+ int hist_command;
+ int hist_line;
+ int hist_char;
+} Histloc_t;
+
+/* the following are readonly */
+extern const char hist_fname[];
+
+extern int _Hist;
+#define hist_min(hp) ((_Hist=((int)((hp)->histind-(hp)->histsize)))>=0?_Hist:0)
+#define hist_max(hp) ((int)((hp)->histind))
+/* these are the history interface routines */
+extern int sh_histinit(void);
+extern void hist_cancel(History_t*);
+extern void hist_close(History_t*);
+extern int hist_copy(char*, int, int, int);
+extern void hist_eof(History_t*);
+extern Histloc_t hist_find(History_t*,char*,int, int, int);
+extern void hist_flush(History_t*);
+extern void hist_list(History_t*,Sfio_t*, off_t, int, char*);
+extern int hist_match(History_t*,off_t, char*, int*);
+extern off_t hist_tell(History_t*,int);
+extern off_t hist_seek(History_t*,int);
+extern char *hist_word(char*, int, int);
+#if SHOPT_ESH
+ extern Histloc_t hist_locate(History_t*,int, int, int);
+#endif /* SHOPT_ESH */
+
+#endif /* HIST_VERSION */
diff --git a/usr/src/lib/libshell/common/include/io.h b/usr/src/lib/libshell/common/include/io.h
new file mode 100644
index 0000000000..b8881bee84
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/io.h
@@ -0,0 +1,123 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * UNIX shell
+ * David Korn
+ *
+ */
+
+#include <ast.h>
+#include <sfio.h>
+
+#ifndef IOBSIZE
+# define IOBSIZE SF_BUFSIZE
+#endif /* IOBSIZE */
+#define IOMAXTRY 20
+
+#ifndef SF_CLOSING
+#define SF_CLOSING SF_CLOSE
+#endif
+#ifndef SF_APPENDWR
+#define SF_APPENDWR SF_APPEND
+#endif
+
+/* used for output of shell errors */
+#define ERRIO 2
+
+#define IOREAD 001
+#define IOWRITE 002
+#define IODUP 004
+#define IOSEEK 010
+#define IONOSEEK 020
+#define IOTTY 040
+#define IOCLEX 0100
+#define IOCLOSE (IOSEEK|IONOSEEK)
+
+#define IOSUBSHELL 0x8000 /* must be larger than any file descriptor */
+
+/*
+ * The remainder of this file is only used when compiled with shell
+ */
+
+#if KSHELL
+
+#ifndef ARG_RAW
+ struct ionod;
+#endif /* !ARG_RAW */
+
+#define sh_inuse(f2) (sh.fdptrs[f2])
+
+extern int sh_iocheckfd(int);
+extern void sh_ioinit(void);
+extern int sh_iomovefd(int);
+extern int sh_iorenumber(int,int);
+extern void sh_pclose(int[]);
+extern void sh_iorestore(int,int);
+#if defined(__EXPORT__) && defined(_BLD_DLL) && defined(_BLD_shell)
+ __EXPORT__
+#endif
+extern Sfio_t *sh_iostream(int);
+extern int sh_redirect(struct ionod*,int);
+extern void sh_iosave(int,int);
+extern void sh_iounsave(void);
+extern int sh_chkopen(const char*);
+extern int sh_ioaccess(int,int);
+extern int sh_devtofd(const char*);
+extern int sh_source(Shell_t*, Sfio_t*, const char*);
+
+/* the following are readonly */
+extern const char e_pexists[];
+extern const char e_query[];
+extern const char e_history[];
+extern const char e_argtype[];
+extern const char e_create[];
+extern const char e_tmpcreate[];
+extern const char e_exists[];
+extern const char e_file[];
+extern const char e_formspec[];
+extern const char e_badregexp[];
+extern const char e_open[];
+extern const char e_notseek[];
+extern const char e_noread[];
+extern const char e_badseek[];
+extern const char e_badpattern[];
+extern const char e_toomany[];
+extern const char e_pipe[];
+extern const char e_unknown[];
+extern const char e_devnull[];
+extern const char e_profile[];
+extern const char e_sysprofile[];
+#if SHOPT_SYSRC
+extern const char e_sysrc[];
+#endif
+#if SHOPT_BASH
+#if SHOPT_SYSRC
+extern const char e_bash_sysrc[];
+#endif
+extern const char e_bash_rc[];
+extern const char e_bash_login[];
+extern const char e_bash_logout[];
+extern const char e_bash_profile[];
+#endif
+extern const char e_stdprompt[];
+extern const char e_supprompt[];
+extern const char e_ambiguous[];
+#endif /* KSHELL */
diff --git a/usr/src/lib/libshell/common/include/jobs.h b/usr/src/lib/libshell/common/include/jobs.h
new file mode 100644
index 0000000000..c4998eabca
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/jobs.h
@@ -0,0 +1,159 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef JOB_NFLAG
+/*
+ * Interface to job control for shell
+ * written by David Korn
+ *
+ */
+
+#define JOBTTY 2
+
+#include <ast.h>
+#include <sfio.h>
+#ifndef SIGINT
+# include <signal.h>
+#endif /* !SIGINT */
+#include "FEATURE/options"
+
+#undef JOBS
+#if defined(SIGCLD) && !defined(SIGCHLD)
+# define SIGCHLD SIGCLD
+#endif
+#ifdef SIGCHLD
+# define JOBS 1
+# include "terminal.h"
+# ifdef FIOLOOKLD
+ /* Ninth edition */
+ extern int tty_ld, ntty_ld;
+# define OTTYDISC tty_ld
+# define NTTYDISC ntty_ld
+# endif /* FIOLOOKLD */
+#else
+# undef SIGTSTP
+# undef SH_MONITOR
+# define SH_MONITOR 0
+# define job_set(x)
+# define job_reset(x)
+#endif
+
+struct process
+{
+ struct process *p_nxtjob; /* next job structure */
+ struct process *p_nxtproc; /* next process in current job */
+ pid_t p_pid; /* process id */
+ pid_t p_pgrp; /* process group */
+ pid_t p_fgrp; /* process group when stopped */
+ short p_job; /* job number of process */
+ unsigned short p_exit; /* exit value or signal number */
+ unsigned short p_flag; /* flags - see below */
+ int p_env; /* subshell environment number */
+#ifdef JOBS
+ off_t p_name; /* history file offset for command */
+ struct termios p_stty; /* terminal state for job */
+#endif /* JOBS */
+};
+
+struct jobs
+{
+ struct process *pwlist; /* head of process list */
+ pid_t curpgid; /* current process gid id */
+ pid_t parent; /* set by fork() */
+ pid_t mypid; /* process id of shell */
+ pid_t mypgid; /* process group id of shell */
+ pid_t mytgid; /* terminal group id of shell */
+ unsigned int in_critical; /* >0 => in critical region */
+ int savesig; /* active signal */
+ int numpost; /* number of posted jobs */
+ short fd; /* tty descriptor number */
+#ifdef JOBS
+ int suspend; /* suspend character */
+ int linedisc; /* line dicipline */
+#endif /* JOBS */
+ char jobcontrol; /* turned on for real job control */
+ char waitsafe; /* wait will not block */
+ char waitall; /* wait for all jobs in pipe */
+ char toclear; /* job table needs clearing */
+ unsigned char *freejobs; /* free jobs numbers */
+};
+
+/* flags for joblist */
+#define JOB_LFLAG 1
+#define JOB_NFLAG 2
+#define JOB_PFLAG 4
+#define JOB_NLFLAG 8
+
+extern struct jobs job;
+
+#ifdef JOBS
+
+#define job_lock() (job.in_critical++)
+#define job_unlock() do{if(!--job.in_critical&&job.savesig)job_reap(job.savesig);}while(0)
+
+extern const char e_jobusage[];
+extern const char e_done[];
+extern const char e_running[];
+extern const char e_coredump[];
+extern const char e_no_proc[];
+extern const char e_no_job[];
+extern const char e_jobsrunning[];
+extern const char e_nlspace[];
+extern const char e_access[];
+extern const char e_terminate[];
+extern const char e_no_jctl[];
+extern const char e_signo[];
+#ifdef SIGTSTP
+ extern const char e_no_start[];
+#endif /* SIGTSTP */
+#ifdef NTTYDISC
+ extern const char e_newtty[];
+ extern const char e_oldtty[];
+#endif /* NTTYDISC */
+#endif /* JOBS */
+
+/*
+ * The following are defined in jobs.c
+ */
+
+extern void job_clear(void);
+extern void job_bwait(char**);
+extern int job_walk(Sfio_t*,int(*)(struct process*,int),int,char*[]);
+extern int job_kill(struct process*,int);
+extern void job_wait(pid_t);
+extern int job_post(pid_t,pid_t);
+extern void *job_subsave(void);
+extern void job_subrestore(void*);
+#ifdef JOBS
+ extern void job_init(int);
+ extern int job_close(void);
+ extern int job_list(struct process*,int);
+ extern int job_terminate(struct process*,int);
+ extern int job_switch(struct process*,int);
+ extern void job_fork(pid_t);
+ extern int job_reap(int);
+#else
+# define job_init(flag)
+# define job_close() (0)
+# define job_fork(p)
+#endif /* JOBS */
+
+
+#endif /* !JOB_NFLAG */
diff --git a/usr/src/lib/libshell/common/include/lexstates.h b/usr/src/lib/libshell/common/include/lexstates.h
new file mode 100644
index 0000000000..8e3cdbfef6
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/lexstates.h
@@ -0,0 +1,151 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef S_BREAK
+#define S_BREAK 1 /* end of token */
+#define S_EOF 2 /* end of buffer */
+#define S_NL 3 /* new-line when not a token */
+#define S_RES 4 /* first character of reserved word */
+#define S_NAME 5 /* other identifier characters */
+#define S_REG 6 /* non-special characters */
+#define S_TILDE 7 /* first char is tilde */
+#define S_PUSH 8
+#define S_POP 9
+#define S_BRACT 10
+#define S_LIT 11 /* literal quote character */
+#define S_NLTOK 12 /* new-line token */
+#define S_OP 13 /* operator character */
+#define S_PAT 14 /* pattern characters * and ? */
+#define S_EPAT 15 /* pattern char when followed by ( */
+#define S_EQ 16 /* assignment character */
+#define S_COM 17 /* comment character */
+#define S_MOD1 18 /* ${...} modifier character - old quoting */
+#define S_MOD2 19 /* ${...} modifier character - new quoting */
+#define S_ERR 20 /* invalid character in ${...} */
+#define S_SPC1 21 /* special prefix characters after $ */
+#define S_SPC2 22 /* special characters after $ */
+#define S_DIG 23 /* digit character after $*/
+#define S_ALP 24 /* alpahbetic character after $ */
+#define S_LBRA 25 /* left brace after $ */
+#define S_RBRA 26 /* right brace after $ */
+#define S_PAR 27 /* set for $( */
+#define S_ENDCH 28 /* macro expansion terminator */
+#define S_SLASH 29 /* / character terminates ~ expansion */
+#define S_COLON 30 /* for character : */
+#define S_LABEL 31 /* for goto label */
+#define S_EDOL 32 /* ends $identifier */
+#define S_BRACE 33 /* left brace */
+#define S_DOT 34 /* . char */
+#define S_META 35 /* | & ; < > inside ${...} reserved for future use */
+#define S_SPACE S_BREAK /* IFS space characters */
+#define S_DELIM S_RES /* IFS delimter characters */
+#define S_MBYTE S_NAME /* IFS first byte of multi-byte char */
+#define S_BLNK 36 /* space or tab */
+/* The following must be the highest numbered states */
+#define S_QUOTE 37 /* double quote character */
+#define S_GRAVE 38 /* old comsub character */
+#define S_ESC 39 /* escape character */
+#define S_DOL 40 /* $ subsitution character */
+#define S_ESC2 41 /* escape character inside '...' */
+
+/* These are the lexical state table names */
+#define ST_BEGIN 0
+#define ST_NAME 1
+#define ST_NORM 2
+#define ST_LIT 3
+#define ST_QUOTE 4
+#define ST_NESTED 5
+#define ST_DOL 6
+#define ST_BRACE 7
+#define ST_DOLNAME 8
+#define ST_MACRO 9
+#define ST_QNEST 10
+#define ST_NONE 11
+
+#include "FEATURE/locale"
+
+#if _hdr_wchar
+# include <wchar.h>
+# if _hdr_wctype
+# include <wctype.h>
+# undef isalpha
+# define isalpha(x) iswalpha(x)
+# if defined(iswblank) || _lib_iswblank
+# undef isblank
+# define isblank(x) iswblank(x)
+# else
+# if _lib_wctype && _lib_iswctype
+# define _lib_iswblank -1
+# undef isblank
+# define isblank(x) local_iswblank(x)
+ extern int local_iswblank(wchar_t);
+# endif
+# endif
+# endif
+#endif
+#ifndef isblank
+# define isblank(x) ((x)==' '||(x)=='\t')
+#endif
+
+#undef LEN
+#if SHOPT_MULTIBYTE
+ static int NXT, LEN;
+# define isaname(c) ((c)>0xff?isalpha(c): sh_lexstates[ST_NAME][(c)]==0)
+# define isaletter(c) ((c)>0xff?isalpha(c): sh_lexstates[ST_DOL][(c)]==S_ALP && (c)!='.')
+#else
+# undef mbwide
+# define mbwide() (0)
+# define LEN 1
+# define isaname(c) (sh_lexstates[ST_NAME][c]==0)
+# define isaletter(c) (sh_lexstates[ST_DOL][c]==S_ALP && (c)!='.')
+#endif
+#define STATE(s,c) (mbwide()?(c=fcmbstate(s,&NXT,&LEN),NXT):s[c=fcget()])
+#define isadigit(c) (sh_lexstates[ST_DOL][c]==S_DIG)
+#define isastchar(c) ((c)=='@' || (c)=='*')
+#define isexp(c) (sh_lexstates[ST_MACRO][c]==S_PAT||(c)=='$'||(c)=='`')
+#define ismeta(c) (sh_lexstates[ST_NAME][c]==S_BREAK)
+
+extern char *sh_lexstates[ST_NONE];
+extern const char *sh_lexrstates[ST_NONE];
+extern const char e_lexversion[];
+extern const char e_lexspace[];
+extern const char e_lexslash[];
+extern const char e_lexlabignore[];
+extern const char e_lexlabunknown[];
+extern const char e_lexsyntax1[];
+extern const char e_lexsyntax2[];
+extern const char e_lexsyntax3[];
+extern const char e_lexobsolete1[];
+extern const char e_lexobsolete2[];
+extern const char e_lexobsolete3[];
+extern const char e_lexobsolete4[];
+extern const char e_lexobsolete5[];
+extern const char e_lexobsolete6[];
+extern const char e_lexusebrace[];
+extern const char e_lexusequote[];
+extern const char e_lexescape[];
+extern const char e_lexquote[];
+extern const char e_lexnested[];
+extern const char e_lexbadchar[];
+extern const char e_lexlongquote[];
+extern const char e_lexfuture[];
+extern const char e_lexzerobyte[];
+extern const char e_lexemptyfor[];
+#endif
diff --git a/usr/src/lib/libshell/common/include/name.h b/usr/src/lib/libshell/common/include/name.h
new file mode 100644
index 0000000000..04ed23e7d0
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/name.h
@@ -0,0 +1,208 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef _NV_PRIVATE
+/*
+ * This is the implementation header file for name-value pairs
+ */
+
+#define _NV_PRIVATE \
+ Namfun_t *nvfun; /* pointer to trap functions */ \
+ union Value nvalue; /* value field */ \
+ char *nvenv; /* pointer to environment name */
+
+#include <ast.h>
+#include <cdt.h>
+#include "shtable.h"
+
+/* Nodes can have all kinds of values */
+union Value
+{
+ const char *cp;
+ int *ip;
+ char c;
+ int i;
+ unsigned int u;
+ int32_t *lp;
+ Sflong_t *llp; /* for long long arithmetic */
+ int16_t s;
+ double *dp; /* for floating point arithmetic */
+ Sfdouble_t *ldp; /* for long floating point arithmetic */
+ struct Namarray *array; /* for array node */
+ struct Namval *np; /* for Namval_t node */
+ union Value *up; /* for indirect node */
+ struct Ufunction *rp; /* shell user defined functions */
+ struct Namfun *funp; /* discipline pointer */
+ struct Namref *nrp; /* name reference */
+ int (*bfp)(int,char*[],void*);/* builtin entry point function pointer */
+};
+
+#include "nval.h"
+
+/* used for arrays */
+
+#define ARRAY_MAX (1L<<ARRAY_BITS) /* maximum number of elements in an array */
+#define ARRAY_MASK (ARRAY_MAX-1) /* For index values */
+
+#define ARRAY_INCR 32 /* number of elements to grow when array
+ bound exceeded. Must be a power of 2 */
+#define ARRAY_FILL (8L<<ARRAY_BITS) /* used with nv_putsub() */
+#define ARRAY_NOCLONE (16L<<ARRAY_BITS) /* do not clone array disc */
+#define ARRAY_NOCHILD (32L<<ARRAY_BITS) /* skip compound arrays */
+#define ARRAY_SETSUB (64L<<ARRAY_BITS) /* set subscript */
+#define NV_ASETSUB 8 /* set subscript */
+
+/* These flags are used as options to array_get() */
+#define ARRAY_ASSIGN 0
+#define ARRAY_LOOKUP 1
+#define ARRAY_DELETE 2
+
+
+struct Namref
+{
+ Namval_t *np;
+ Namval_t *table;
+ Dt_t *root;
+ char *sub;
+};
+
+/* This describes a user shell function node */
+struct Ufunction
+{
+ int *ptree; /* address of parse tree */
+ int lineno; /* line number of function start */
+ off_t hoffset; /* offset into source or history file */
+ Namval_t *nspace; /* pointer to name space */
+ char *fname; /* file name where function defined */
+};
+
+#ifndef ARG_RAW
+ struct argnod;
+#endif /* !ARG_RAW */
+
+/* attributes of Namval_t items */
+
+/* The following attributes are for internal use */
+#define NV_NOCHANGE (NV_EXPORT|NV_IMPORT|NV_RDONLY|NV_TAGGED|NV_NOFREE)
+#define NV_ATTRIBUTES (~(NV_NOSCOPE|NV_ARRAY|NV_NOARRAY|NV_IDENT|NV_ASSIGN|NV_REF|NV_VARNAME))
+#define NV_PARAM NV_NODISC /* expansion use positional params */
+
+/* This following are for use with nodes which are not name-values */
+#define NV_TYPE 0x1000000
+#define NV_FUNCTION (NV_RJUST|NV_FUNCT) /* value is shell function */
+#define NV_FPOSIX NV_LJUST /* posix function semantics */
+#define NV_FTMP NV_ZFILL /* function source in tmpfile */
+
+#define NV_NOPRINT (NV_LTOU|NV_UTOL) /* do not print */
+#define NV_NOALIAS (NV_NOPRINT|NV_IMPORT)
+#define NV_NOEXPAND NV_RJUST /* do not expand alias */
+#define NV_BLTIN (NV_NOPRINT|NV_EXPORT)
+#define BLT_ENV (NV_RDONLY) /* non-stoppable,
+ * can modify enviornment */
+#define BLT_SPC (NV_LJUST) /* special built-ins */
+#define BLT_EXIT (NV_RJUST) /* exit value can be > 255 */
+#define BLT_DCL (NV_TAGGED) /* declaration command */
+#define nv_isref(n) (nv_isattr((n),NV_REF)==NV_REF)
+#define nv_istable(n) (nv_isattr((n),NV_TABLE|NV_LJUST|NV_RJUST)==NV_TABLE)
+#define is_abuiltin(n) (nv_isattr(n,NV_BLTIN)==NV_BLTIN)
+#define is_afunction(n) (nv_isattr(n,NV_FUNCTION)==NV_FUNCTION)
+#define nv_funtree(n) ((n)->nvalue.rp->ptree)
+#define funptr(n) ((n)->nvalue.bfp)
+
+#define NV_SUBQUOTE (NV_ADD<<1) /* used with nv_endsubscript */
+
+/* NAMNOD MACROS */
+/* ... for attributes */
+
+#define nv_setattr(n,f) ((n)->nvflag = (f))
+#define nv_context(n) ((void*)(n)->nvfun) /* for builtins */
+/* The following are for name references */
+#define nv_refnode(n) ((n)->nvalue.nrp->np)
+#define nv_reftree(n) ((n)->nvalue.nrp->root)
+#define nv_reftable(n) ((n)->nvalue.nrp->table)
+#define nv_refsub(n) ((n)->nvalue.nrp->sub)
+#if SHOPT_OO
+# define nv_class(np) (nv_isattr(np,NV_REF|NV_IMPORT)?0:(Namval_t*)((np)->nvenv))
+#endif /* SHOPT_OO */
+
+/* ... etc */
+
+#define nv_setsize(n,s) ((n)->nvsize = (s))
+#undef nv_size
+#define nv_size(np) ((np)->nvsize)
+#define nv_isnull(np) (!(np)->nvalue.cp && !(np)->nvfun && !nv_isattr(np,NV_SHORT))
+
+/* ... for arrays */
+
+#define array_elem(ap) ((ap)->nelem&ARRAY_MASK)
+#define array_assoc(ap) ((ap)->fun)
+
+extern int array_maxindex(Namval_t*);
+extern char *nv_endsubscript(Namval_t*, char*, int);
+extern Namfun_t *nv_cover(Namval_t*);
+extern Namarr_t *nv_arrayptr(Namval_t*);
+extern int nv_setnotify(Namval_t*,char **);
+extern int nv_unsetnotify(Namval_t*,char **);
+extern void nv_setlist(struct argnod*, int);
+extern void nv_optimize(Namval_t*);
+extern void nv_outname(Sfio_t*,char*, int);
+extern void nv_scope(struct argnod*);
+extern void nv_unref(Namval_t*);
+extern void _nv_unset(Namval_t*,int);
+extern int nv_clone(Namval_t*, Namval_t*, int);
+extern void *nv_diropen(const char*);
+extern char *nv_dirnext(void*);
+extern void nv_dirclose(void*);
+extern char *nv_getvtree(Namval_t*, Namfun_t*);
+extern void nv_attribute(Namval_t*, Sfio_t*, char*, int);
+extern Namval_t *nv_bfsearch(const char*, Dt_t*, Namval_t**, char**);
+extern Namval_t *nv_mkclone(Namval_t*);
+extern Namval_t *nv_mktype(Namval_t**, int);
+extern void nv_addnode(Namval_t*, int);
+extern Namval_t *nv_parent(Namval_t*);
+extern char *nv_getbuf(size_t);
+extern Namval_t *nv_mount(Namval_t*, const char *name, Dt_t*);
+extern Namval_t *nv_arraychild(Namval_t*, Namval_t*, int);
+extern int nv_compare(Dt_t*, Void_t*, Void_t*, Dtdisc_t*);
+
+extern const Namdisc_t RESTRICTED_disc;
+extern char nv_local;
+extern Dtdisc_t _Nvdisc;
+extern const char e_subscript[];
+extern const char e_nullset[];
+extern const char e_notset[];
+extern const char e_noparent[];
+extern const char e_readonly[];
+extern const char e_badfield[];
+extern const char e_restricted[];
+extern const char e_ident[];
+extern const char e_varname[];
+extern const char e_noalias[];
+extern const char e_noarray[];
+extern const char e_aliname[];
+extern const char e_badexport[];
+extern const char e_badref[];
+extern const char e_noref[];
+extern const char e_selfref[];
+extern const char e_envmarker[];
+extern const char e_badlocale[];
+extern const char e_loop[];
+extern const char e_redef[];
+#endif /* _NV_PRIVATE */
diff --git a/usr/src/lib/libshell/common/include/national.h b/usr/src/lib/libshell/common/include/national.h
new file mode 100644
index 0000000000..837015011a
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/national.h
@@ -0,0 +1,37 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * national.h - definitions for multibyte character sets
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#if SHOPT_MULTIBYTE
+
+# ifndef MARKER
+# define MARKER 0xdfff /* Must be invalid character */
+# endif
+
+ extern int sh_strchr(const char*,const char*);
+
+#endif /* SHOPT_MULTIBYTE */
diff --git a/usr/src/lib/libshell/common/include/nval.h b/usr/src/lib/libshell/common/include/nval.h
new file mode 100644
index 0000000000..6d02dc0a3b
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/nval.h
@@ -0,0 +1,305 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef NV_DEFAULT
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * Interface definitions of structures for name-value pairs
+ * These structures are used for named variables, functions and aliases
+ *
+ */
+
+
+#include <ast.h>
+#include <cdt.h>
+
+/* for compatibility with old hash library */
+#define Hashtab_t Dt_t
+#define HASH_BUCKET 1
+#define HASH_NOSCOPE 2
+#define HASH_SCOPE 4
+#define hashscope(x) dtvnext(x)
+
+typedef struct Namval Namval_t;
+typedef struct Namfun Namfun_t;
+typedef struct Namdisc Namdisc_t;
+typedef struct Nambfun Nambfun_t;
+typedef struct Namarray Namarr_t;
+typedef struct Nambltin Nambltin_t;
+typedef struct Namtype Namtype_t;
+
+/*
+ * This defines the template for nodes that have their own assignment
+ * and or lookup functions
+ */
+struct Namdisc
+{
+ size_t dsize;
+ void (*putval)(Namval_t*, const char*, int, Namfun_t*);
+ char *(*getval)(Namval_t*, Namfun_t*);
+ Sfdouble_t (*getnum)(Namval_t*, Namfun_t*);
+ char *(*setdisc)(Namval_t*, const char*, Namval_t*, Namfun_t*);
+ Namval_t *(*createf)(Namval_t*, const char*, int, Namfun_t*);
+ Namfun_t *(*clonef)(Namval_t*, Namval_t*, int, Namfun_t*);
+ char *(*namef)(Namval_t*, Namfun_t*);
+ Namval_t *(*nextf)(Namval_t*, Dt_t*, Namfun_t*);
+ Namval_t *(*typef)(Namval_t*, Namfun_t*);
+ int (*readf)(Namval_t*, Sfio_t*, int, Namfun_t*);
+};
+
+struct Namfun
+{
+ const Namdisc_t *disc;
+ char nofree;
+ char funs;
+ unsigned short dsize;
+ Namfun_t *next;
+ char *last;
+ Namval_t *type;
+};
+
+struct Nambfun
+{
+ Namfun_t fun;
+ int num;
+ const char **bnames;
+ Namval_t *bltins[1];
+};
+
+/* This is an array template header */
+struct Namarray
+{
+ Namfun_t hdr;
+ long nelem; /* number of elements */
+ void *(*fun)(Namval_t*,const char*,int); /* associative arrays */
+ Namval_t *parent; /* for multi-dimensional */
+};
+
+/* Passed as third argument to a builtin when NV_BLTINOPT is set on node */
+struct Nambltin
+{
+ void *shp;
+ Namval_t *np;
+ void *ptr;
+ void *data;
+ int flags;
+};
+
+struct Namtype
+{
+ void *shp;
+ Namval_t *np;
+ const char *optstring;
+ void *optinfof;
+};
+
+/* attributes of name-value node attribute flags */
+
+#define NV_DEFAULT 0
+/* This defines the attributes for an attributed name-value pair node */
+struct Namval
+{
+ Dtlink_t nvlink; /* space for cdt links */
+ char *nvname; /* pointer to name of the node */
+ unsigned short nvflag; /* attributes */
+ unsigned short nvsize; /* size or base */
+#ifdef _NV_PRIVATE
+ _NV_PRIVATE
+#else
+ Namfun_t *nvfun;
+ char *nvalue;
+ char *nvprivate;
+#endif /* _NV_PRIVATE */
+};
+
+#define NV_CLASS ".sh.type"
+#define NV_MINSZ (sizeof(struct Namval)-sizeof(Dtlink_t)-sizeof(char*))
+#define nv_namptr(p,n) ((Namval_t*)((char*)(p)+(n)*NV_MINSZ-sizeof(Dtlink_t)))
+
+/* The following attributes are for internal use */
+#define NV_NOFREE 0x200 /* don't free the space when releasing value */
+#define NV_ARRAY 0x400 /* node is an array */
+#define NV_REF 0x4000 /* reference bit */
+#define NV_TABLE 0x800 /* node is a dictionary table */
+#define NV_IMPORT 0x1000 /* value imported from environment */
+#define NV_MINIMAL NV_IMPORT /* node does not contain all fields */
+
+#define NV_INTEGER 0x2 /* integer attribute */
+/* The following attributes are valid only when NV_INTEGER is off */
+#define NV_LTOU 0x4 /* convert to uppercase */
+#define NV_UTOL 0x8 /* convert to lowercase */
+#define NV_ZFILL 0x10 /* right justify and fill with leading zeros */
+#define NV_RJUST 0x20 /* right justify and blank fill */
+#define NV_LJUST 0x40 /* left justify and blank fill */
+#define NV_BINARY 0x100 /* fixed size data buffer */
+#define NV_RAW NV_LJUST /* used only with NV_BINARY */
+#define NV_HOST (NV_RJUST|NV_LJUST) /* map to host filename */
+
+/* The following attributes do not effect the value */
+#define NV_RDONLY 0x1 /* readonly bit */
+#define NV_EXPORT 0x2000 /* export bit */
+#define NV_TAGGED 0x8000 /* user define tag bit */
+
+/* The following are used with NV_INTEGER */
+#define NV_SHORT (NV_RJUST) /* when integers are not long */
+#define NV_LONG (NV_UTOL) /* for long long and long double */
+#define NV_UNSIGN (NV_LTOU) /* for unsigned quantities */
+#define NV_DOUBLE (NV_ZFILL) /* for floating point */
+#define NV_EXPNOTE (NV_LJUST) /* for scientific notation */
+
+/* options for nv_open */
+
+#define NV_APPEND 0x10000 /* append value */
+#define NV_MOVE 0x20000 /* for use with nv_clone */
+#define NV_ADD 8
+ /* add node if not found */
+#define NV_ASSIGN NV_NOFREE /* assignment is possible */
+#define NV_NOASSIGN 0 /* backward compatibility */
+#define NV_NOARRAY 0x200000 /* array name not possible */
+#define NV_IARRAY 0x400000 /* for indexed array */
+#define NV_NOREF NV_REF /* don't follow reference */
+#define NV_IDENT 0x80 /* name must be identifier */
+#define NV_VARNAME 0x20000 /* name must be ?(.)id*(.id) */
+#define NV_NOADD 0x40000 /* do not add node */
+#define NV_NOSCOPE 0x80000 /* look only in current scope */
+#define NV_NOFAIL 0x100000 /* return 0 on failure, no msg */
+#define NV_NODISC NV_IDENT /* ignore disciplines */
+
+#define NV_FUNCT NV_IDENT /* option for nv_create */
+#define NV_BLTINOPT NV_ZFILL /* save state for optimization*/
+
+#define NV_PUBLIC (~(NV_NOSCOPE|NV_ASSIGN|NV_IDENT|NV_VARNAME|NV_NOADD))
+
+/* numeric types */
+#define NV_INT16 (NV_SHORT|NV_INTEGER)
+#define NV_UINT16 (NV_UNSIGN|NV_SHORT|NV_INTEGER)
+#define NV_INT32 (NV_INTEGER)
+#define NV_UNT32 (NV_UNSIGN|NV_INTEGER)
+#define NV_INT64 (NV_LONG|NV_INTEGER)
+#define NV_UINT64 (NV_UNSIGN|NV_LONG|NV_INTEGER)
+#define NV_FLOAT (NV_SHORT|NV_DOUBLE|NV_INTEGER)
+#define NV_LDOUBLE (NV_LONG|NV_DOUBLE|NV_INTEGER)
+
+/* name-value pair macros */
+#define nv_isattr(np,f) ((np)->nvflag & (f))
+#define nv_onattr(n,f) ((n)->nvflag |= (f))
+#define nv_offattr(n,f) ((n)->nvflag &= ~(f))
+#define nv_isarray(np) (nv_isattr((np),NV_ARRAY))
+
+/* The following are operations for associative arrays */
+#define NV_AINIT 1 /* initialize */
+#define NV_AFREE 2 /* free array */
+#define NV_ANEXT 3 /* advance to next subscript */
+#define NV_ANAME 4 /* return subscript name */
+#define NV_ADELETE 5 /* delete current subscript */
+#define NV_AADD 6 /* add subscript if not found */
+#define NV_ACURRENT 7 /* return current subscript Namval_t* */
+
+/* The following are for nv_disc */
+#define NV_FIRST 1
+#define NV_LAST 2
+#define NV_POP 3
+#define NV_CLONE 4
+
+/* The following are operations for nv_putsub() */
+#define ARRAY_BITS 24
+#define ARRAY_ADD (1L<<ARRAY_BITS) /* add subscript if not found */
+#define ARRAY_SCAN (2L<<ARRAY_BITS) /* For ${array[@]} */
+#define ARRAY_UNDEF (4L<<ARRAY_BITS) /* For ${array} */
+
+
+/* These are disciplines provided by the library for use with nv_discfun */
+#define NV_DCADD 0 /* used to add named disciplines */
+#define NV_DCRESTRICT 1 /* variable that are restricted in rsh */
+
+#if defined(__EXPORT__) && defined(_DLL)
+# ifdef _BLD_shell
+# define extern __EXPORT__
+# else
+# define extern __IMPORT__
+# endif /* _BLD_shell */
+#endif /* _DLL */
+/* prototype for array interface*/
+extern Namarr_t *nv_setarray(Namval_t*,void*(*)(Namval_t*,const char*,int));
+extern void *nv_associative(Namval_t*,const char*,int);
+extern int nv_aindex(Namval_t*);
+extern int nv_nextsub(Namval_t*);
+extern char *nv_getsub(Namval_t*);
+extern Namval_t *nv_putsub(Namval_t*, char*, long);
+extern Namval_t *nv_opensub(Namval_t*);
+
+/* name-value pair function prototypes */
+extern int nv_adddisc(Namval_t*, const char**, Namval_t**);
+extern int nv_clone(Namval_t*, Namval_t*, int);
+extern void nv_close(Namval_t*);
+extern void *nv_context(Namval_t*);
+extern Namval_t *nv_create(const char*, Dt_t*, int,Namfun_t*);
+extern Dt_t *nv_dict(Namval_t*);
+extern Sfdouble_t nv_getn(Namval_t*, Namfun_t*);
+extern Sfdouble_t nv_getnum(Namval_t*);
+extern char *nv_getv(Namval_t*, Namfun_t*);
+extern char *nv_getval(Namval_t*);
+extern Namfun_t *nv_hasdisc(Namval_t*, const Namdisc_t*);
+extern int nv_isnull(Namval_t*);
+extern Namval_t *nv_lastdict(void);
+extern void nv_newattr(Namval_t*,unsigned,int);
+extern Namval_t *nv_open(const char*,Dt_t*,int);
+extern void nv_putval(Namval_t*,const char*,int);
+extern void nv_putv(Namval_t*,const char*,int,Namfun_t*);
+extern int nv_scan(Dt_t*,void(*)(Namval_t*,void*),void*,int,int);
+extern Namval_t *nv_scoped(Namval_t*);
+extern char *nv_setdisc(Namval_t*,const char*,Namval_t*,Namfun_t*);
+extern void nv_setref(Namval_t*, Dt_t*,int);
+extern int nv_settype(Namval_t*, Namval_t*, int);
+extern void nv_setvec(Namval_t*,int,int,char*[]);
+extern void nv_setvtree(Namval_t*);
+extern int nv_setsize(Namval_t*,int);
+extern Namfun_t *nv_disc(Namval_t*,Namfun_t*,int);
+extern void nv_unset(Namval_t*);
+extern Namval_t *nv_search(const char *, Dt_t*, int);
+extern void nv_unscope(void);
+extern char *nv_name(Namval_t*);
+extern Namval_t *nv_type(Namval_t*);
+extern const Namdisc_t *nv_discfun(int);
+
+#ifdef _DLL
+# undef extern
+#endif /* _DLL */
+
+#define nv_size(np) nv_setsize((np),-1)
+#define nv_stack(np,nf) nv_disc(np,nf,0)
+
+#if 0
+/*
+ * The names of many functions were changed in early '95
+ * Here is a mapping to the old names
+ */
+# define nv_istype(np) nv_isattr(np)
+# define nv_newtype(np) nv_newattr(np)
+# define nv_namset(np,a,b) nv_open(np,a,b)
+# define nv_free(np) nv_unset(np)
+# define nv_settype(np,a,b,c) nv_setdisc(np,a,b,c)
+# define nv_search(np,a,b) nv_open(np,a,((b)?0:NV_NOADD))
+# define settype setdisc
+#endif
+
+#endif /* NV_DEFAULT */
diff --git a/usr/src/lib/libshell/common/include/path.h b/usr/src/lib/libshell/common/include/path.h
new file mode 100644
index 0000000000..2460be3cbf
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/path.h
@@ -0,0 +1,140 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef PATH_OFFSET
+
+/*
+ * UNIX shell path handling interface
+ * Written by David Korn
+ * These are the definitions for the lexical analyzer
+ */
+
+#include "FEATURE/options"
+#include <nval.h>
+
+#if !defined(SHOPT_SPAWN)
+# if _UWIN || _use_spawnveg || !_lib_fork
+# define SHOPT_SPAWN 1
+# endif
+#endif /* !SHOPT_SPAWN */
+
+#define PATH_PATH 0001
+#define PATH_FPATH 0002
+#define PATH_CDPATH 0004
+#define PATH_BFPATH 0010
+#define PATH_SKIP 0020
+#define PATH_BUILTIN_LIB 0040
+#define PATH_STD_DIR 0100 /* directory is on $(getconf PATH) */
+
+#define PATH_OFFSET 2 /* path offset for path_join */
+#define MAXDEPTH (sizeof(char*)==2?64:4096) /* maximum recursion depth*/
+
+/*
+ * path component structure for path searching
+ */
+typedef struct pathcomp
+{
+ struct pathcomp *next;
+ int refcount;
+ dev_t dev;
+ ino_t ino;
+ char *name;
+ char *lib;
+ char *blib;
+ void *bltin_lib;
+ unsigned short len;
+ unsigned short flags;
+ Shell_t *shp;
+} Pathcomp_t;
+
+#ifndef ARG_RAW
+ struct argnod;
+#endif /* !ARG_RAW */
+
+/* pathname handling routines */
+extern void path_newdir(Pathcomp_t*);
+extern Pathcomp_t *path_dirfind(Pathcomp_t*,const char*,int);
+extern Pathcomp_t *path_unsetfpath(Pathcomp_t*);
+extern Pathcomp_t *path_addpath(Pathcomp_t*,const char*,int);
+extern Pathcomp_t *path_dup(Pathcomp_t*);
+extern void path_delete(Pathcomp_t*);
+extern void path_alias(Namval_t*,Pathcomp_t*);
+extern Pathcomp_t *path_absolute(const char*, Pathcomp_t*);
+extern char *path_basename(const char*);
+extern char *path_fullname(const char*);
+extern int path_expand(const char*, struct argnod**);
+extern void path_exec(const char*,char*[],struct argnod*);
+extern pid_t path_spawn(const char*,char*[],char*[],Pathcomp_t*,int);
+#if defined(__EXPORT__) && defined(_BLD_DLL) && defined(_BLD_shell)
+# define extern __EXPORT__
+#endif
+extern int path_open(const char*,Pathcomp_t*);
+extern Pathcomp_t *path_get(const char*);
+#undef extern
+extern char *path_pwd(int);
+extern Pathcomp_t *path_nextcomp(Pathcomp_t*,const char*,Pathcomp_t*);
+extern int path_search(const char*,Pathcomp_t*,int);
+extern char *path_relative(const char*);
+extern int path_complete(const char*, const char*,struct argnod**);
+#if SHOPT_BRACEPAT
+ extern int path_generate(struct argnod*,struct argnod**);
+#endif /* SHOPT_BRACEPAT */
+
+/* constant strings needed for whence */
+extern const char e_timeformat[];
+extern const char e_badtformat[];
+extern const char e_dot[];
+extern const char e_pfsh[];
+extern const char e_pwd[];
+extern const char e_logout[];
+extern const char e_alphanum[];
+extern const char e_mailmsg[];
+extern const char e_suidprofile[];
+extern const char e_sysprofile[];
+extern const char e_traceprompt[];
+extern const char e_crondir[];
+#if SHOPT_SUID_EXEC
+ extern const char e_suidexec[];
+#endif /* SHOPT_SUID_EXEC */
+extern const char is_alias[];
+extern const char is_builtin[];
+extern const char is_builtver[];
+extern const char is_reserved[];
+extern const char is_talias[];
+extern const char is_xalias[];
+extern const char is_function[];
+extern const char is_ufunction[];
+#ifdef SHELLMAGIC
+ extern const char e_prohibited[];
+#endif /* SHELLMAGIC */
+
+#if SHOPT_ACCT
+# include "FEATURE/acct"
+# ifdef _sys_acct
+ extern void sh_accinit(void);
+ extern void sh_accbegin(const char*);
+ extern void sh_accend(void);
+ extern void sh_accsusp(void);
+# else
+# undef SHOPT_ACCT
+# endif /* _sys_acct */
+#endif /* SHOPT_ACCT */
+
+#endif /*! PATH_OFFSET */
diff --git a/usr/src/lib/libshell/common/include/shell.h b/usr/src/lib/libshell/common/include/shell.h
new file mode 100644
index 0000000000..66ccd20436
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/shell.h
@@ -0,0 +1,245 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef SH_INTERACTIVE
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * Interface definitions for shell command language
+ *
+ */
+
+#include <cmd.h>
+#include <cdt.h>
+#ifdef _SH_PRIVATE
+# include "name.h"
+#else
+# include <nval.h>
+#endif /* _SH_PRIVATE */
+
+#define SH_VERSION 20060510
+
+#undef NOT_USED
+#define NOT_USED(x) (&x,1)
+
+/* options */
+typedef struct
+{
+ unsigned long v[4];
+}
+Shopt_t;
+
+typedef void (*Shinit_f)(int);
+typedef int (*Shbltin_f)(int, char*[], void*);
+typedef int (*Shwait_f)(int, long, int);
+
+union Shnode_u;
+typedef union Shnode_u Shnode_t;
+
+#define SH_CFLAG 0
+#define SH_HISTORY 1 /* used also as a state */
+#define SH_ERREXIT 2 /* used also as a state */
+#define SH_VERBOSE 3 /* used also as a state */
+#define SH_MONITOR 4 /* used also as a state */
+#define SH_INTERACTIVE 5 /* used also as a state */
+#define SH_RESTRICTED 6
+#define SH_XTRACE 7
+#define SH_KEYWORD 8
+#define SH_NOUNSET 9
+#define SH_NOGLOB 10
+#define SH_ALLEXPORT 11
+#define SH_PFSH 12
+#define SH_IGNOREEOF 13
+#define SH_NOCLOBBER 14
+#define SH_MARKDIRS 15
+#define SH_BGNICE 16
+#define SH_VI 17
+#define SH_VIRAW 18
+#define SH_TFLAG 19
+#define SH_TRACKALL 20
+#define SH_SFLAG 21
+#define SH_NOEXEC 22
+#define SH_GMACS 24
+#define SH_EMACS 25
+#define SH_PRIVILEGED 26
+#define SH_SUBSHARE 27 /* subshell shares state with parent */
+#define SH_NOLOG 28
+#define SH_NOTIFY 29
+#define SH_DICTIONARY 30
+#define SH_PIPEFAIL 32
+#define SH_GLOBSTARS 33
+#define SH_XARGS 34
+#define SH_RC 35
+#define SH_SHOWME 36
+
+/*
+ * passed as flags to builtins in Nambltin_t struct when BLT_OPTIM is on
+ */
+#define SH_BEGIN_OPTIM 0x1
+#define SH_END_OPTIM 0x2
+
+/* The following type is used for error messages */
+
+/* error messages */
+extern const char e_defpath[];
+extern const char e_found[];
+extern const char e_nospace[];
+extern const char e_format[];
+extern const char e_number[];
+extern const char e_restricted[];
+extern const char e_recursive[];
+extern char e_version[];
+
+typedef struct sh_scope
+{
+ struct sh_scope *par_scope;
+ int argc;
+ char **argv;
+ char *cmdname;
+ char *filename;
+ int lineno;
+ Dt_t *var_tree;
+ struct sh_scope *self;
+} Shscope_t;
+
+/*
+ * Saves the state of the shell
+ */
+
+typedef struct sh_static
+{
+ Shopt_t options; /* set -o options */
+ Dt_t *var_tree; /* for shell variables */
+ Dt_t *fun_tree; /* for shell functions */
+ Dt_t *alias_tree; /* for alias names */
+ Dt_t *bltin_tree; /* for builtin commands */
+ Shscope_t *topscope; /* pointer to top-level scope */
+ int inlineno; /* line number of current input file */
+ int exitval; /* most recent exit value */
+ unsigned char trapnote; /* set when trap/signal is pending */
+ char subshell; /* set for virtual subshell */
+#ifdef _SH_PRIVATE
+ _SH_PRIVATE
+#endif /* _SH_PRIVATE */
+} Shell_t;
+
+/* flags for sh_parse */
+#define SH_NL 1 /* Treat new-lines as ; */
+#define SH_EOF 2 /* EOF causes syntax error */
+
+/* symbolic values for sh_iogetiop */
+#define SH_IOCOPROCESS (-2)
+#define SH_IOHISTFILE (-3)
+
+/* symbolic value for sh_fdnotify */
+#define SH_FDCLOSE (-1)
+
+#if defined(__EXPORT__) && defined(_DLL)
+# ifdef _BLD_shell
+# define extern __EXPORT__
+# endif /* _BLD_shell */
+#endif /* _DLL */
+
+extern Dt_t *sh_bltin_tree(void);
+extern void sh_subfork(void);
+extern Shell_t *sh_init(int,char*[],Shinit_f);
+extern int sh_reinit(char*[]);
+extern int sh_eval(Sfio_t*,int);
+extern void sh_delay(double);
+extern void *sh_parse(Shell_t*, Sfio_t*,int);
+extern int sh_trap(const char*,int);
+extern int sh_fun(Namval_t*,Namval_t*, char*[]);
+extern int sh_funscope(int,char*[],int(*)(void*),void*,int);
+extern Sfio_t *sh_iogetiop(int,int);
+extern int sh_main(int, char*[], void(*)(int));
+extern void sh_menu(Sfio_t*, int, char*[]);
+extern Namval_t *sh_addbuiltin(const char*, int(*)(int, char*[],void*), void*);
+extern char *sh_fmtq(const char*);
+extern char *sh_fmtqf(const char*, int, int);
+extern Sfdouble_t sh_strnum(const char*, char**, int);
+extern int sh_access(const char*,int);
+extern int sh_close(int);
+extern int sh_dup(int);
+extern void sh_exit(int);
+extern int sh_fcntl(int, int, ...);
+extern Sfio_t *sh_fd2sfio(int);
+extern int (*sh_fdnotify(int(*)(int,int)))(int,int);
+extern Shell_t *sh_getinterp(void);
+extern int sh_open(const char*, int, ...);
+extern int sh_openmax(void);
+extern Sfio_t *sh_pathopen(const char*);
+extern ssize_t sh_read(int, void*, size_t);
+extern ssize_t sh_write(int, const void*, size_t);
+extern off_t sh_seek(int, off_t, int);
+extern int sh_pipe(int[]);
+extern mode_t sh_umask(mode_t);
+extern void *sh_waitnotify(Shwait_f);
+extern Shscope_t *sh_getscope(int,int);
+extern Shscope_t *sh_setscope(Shscope_t*);
+extern void sh_sigcheck(void);
+extern unsigned long sh_isoption(int);
+extern unsigned long sh_onoption(int);
+extern unsigned long sh_offoption(int);
+extern int sh_waitsafe(void);
+extern int sh_exec(const Shnode_t*,int);
+
+#if SHOPT_DYNAMIC
+ extern void **sh_getliblist(void);
+#endif /* SHOPT_DYNAMIC */
+
+/*
+ * direct access to sh is obsolete, use sh_getinterp() instead
+ */
+#if !defined(_SH_PRIVATE) && defined(__IMPORT__) && !defined(_BLD_shell)
+ extern __IMPORT__ Shell_t sh;
+#else
+ extern Shell_t sh;
+#endif
+
+#ifdef _DLL
+# undef extern
+#endif /* _DLL */
+
+#ifndef _SH_PRIVATE
+# define access(a,b) sh_access(a,b)
+# define close(a) sh_close(a)
+# define exit(a) sh_exit(a)
+# define fcntl(a,b,c) sh_fcntl(a,b,c)
+# define pipe(a) sh_pipe(a)
+# define read(a,b,c) sh_read(a,b,c)
+# define write(a,b,c) sh_write(a,b,c)
+# define umask(a) sh_umask(a)
+# define dup sh_dup
+# if _lib_lseek64
+# define open64 sh_open
+# define lseek64 sh_seek
+# else
+# define open sh_open
+# define lseek sh_seek
+# endif
+#endif /* !_SH_PRIVATE */
+
+#define SH_SIGSET 4
+#define SH_EXITSIG 0400 /* signal exit bit */
+#define SH_EXITMASK (SH_EXITSIG-1) /* normal exit status bits */
+#define SH_RUNPROG -1022 /* needs to be negative and < 256 */
+
+#endif /* SH_INTERACTIVE */
diff --git a/usr/src/lib/libshell/common/include/shlex.h b/usr/src/lib/libshell/common/include/shlex.h
new file mode 100644
index 0000000000..56de279d6c
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/shlex.h
@@ -0,0 +1,152 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef NOTSYM
+/*
+ * UNIX shell
+ * Written by David Korn
+ * These are the definitions for the lexical analyzer
+ */
+
+#include <cdt.h>
+#include "FEATURE/options"
+#include "shnodes.h"
+#include "shtable.h"
+#include "lexstates.h"
+
+struct shlex_t
+{
+ Shell_t *sh; /* pointer to the interpreter */
+ struct argnod *arg; /* current word */
+ struct ionod *heredoc; /* pending here document list */
+ int token; /* current token number */
+ int lastline; /* last line number */
+ int lasttok; /* previous token number */
+ int digits; /* numerical value with word token */
+ char aliasok; /* on when alias is legal */
+ char assignok; /* on when name=value is legal */
+ int inlineno; /* saved value of sh.inlineno */
+ int firstline; /* saved value of sh.st.firstline */
+ int comsub; /* parsing command substitution */
+#if SHOPT_KIA
+ Sfio_t *kiafile; /* kia output file */
+ Sfio_t *kiatmp; /* kia reference file */
+ unsigned long script; /* script entity number */
+ unsigned long fscript; /* script file entity number */
+ unsigned long current; /* current entity number */
+ unsigned long unknown; /* <unknown> entity number */
+ off_t kiabegin; /* offset of first entry */
+ char *scriptname; /* name of script file */
+ Dt_t *entity_tree; /* for entity ids */
+#endif /* SHOPT_KIA */
+};
+
+/* symbols for parsing */
+#define NL '\n'
+#define NOTSYM '!'
+#define SYMRES 0400 /* reserved word symbols */
+#define DOSYM (SYMRES|01)
+#define FISYM (SYMRES|02)
+#define ELIFSYM (SYMRES|03)
+#define ELSESYM (SYMRES|04)
+#define INSYM (SYMRES|05)
+#define THENSYM (SYMRES|06)
+#define DONESYM (SYMRES|07)
+#define ESACSYM (SYMRES|010)
+#define IFSYM (SYMRES|011)
+#define FORSYM (SYMRES|012)
+#define WHILESYM (SYMRES|013)
+#define UNTILSYM (SYMRES|014)
+#define CASESYM (SYMRES|015)
+#define FUNCTSYM (SYMRES|016)
+#define SELECTSYM (SYMRES|017)
+#define TIMESYM (SYMRES|020)
+#define NSPACESYM (SYMRES|021)
+
+#define SYMREP 01000 /* symbols for doubled characters */
+#define BREAKCASESYM (SYMREP|';')
+#define ANDFSYM (SYMREP|'&')
+#define ORFSYM (SYMREP|'|')
+#define IOAPPSYM (SYMREP|'>')
+#define IODOCSYM (SYMREP|'<')
+#define EXPRSYM (SYMREP|'(')
+#define BTESTSYM (SYMREP|'[')
+#define ETESTSYM (SYMREP|']')
+
+#define SYMMASK 0170000
+#define SYMPIPE 010000 /* trailing '|' */
+#define SYMLPAR 020000 /* trailing LPAREN */
+#define SYMAMP 040000 /* trailing '&' */
+#define SYMGT 0100000 /* trailing '>' */
+#define SYMSEMI 0110000 /* trailing ';' */
+#define SYMSHARP 0120000 /* trailing '#' */
+#define IOSEEKSYM (SYMSHARP|'<')
+#define IOMOV0SYM (SYMAMP|'<')
+#define IOMOV1SYM (SYMAMP|'>')
+#define FALLTHRUSYM (SYMAMP|';')
+#define COOPSYM (SYMAMP|'|')
+#define IORDWRSYM (SYMGT|'<')
+#define IOCLOBSYM (SYMPIPE|'>')
+#define IPROCSYM (SYMLPAR|'<')
+#define OPROCSYM (SYMLPAR|'>')
+#define EOFSYM 04000 /* end-of-file */
+#define TESTUNOP 04001
+#define TESTBINOP 04002
+#define LABLSYM 04003
+#define IOVNAME 04004
+
+/* additional parser flag, others in <shell.h> */
+#define SH_EMPTY 04
+#define SH_NOIO 010
+#define SH_ASSIGN 020
+#define SH_FUNDEF 040
+#define SH_ARRAY 0100
+#define SH_SEMI 0200 /* semi-colon after NL ok */
+
+#define SH_COMPASSIGN 010 /* allow compound assignments only */
+
+typedef struct _shlex_
+{
+ struct shlex_t _shlex;
+#ifdef _SHLEX_PRIVATE
+ _SHLEX_PRIVATE
+#endif
+} Lex_t;
+
+#define shlex (((Lex_t*)(sh.lex_context))->_shlex)
+extern const char e_unexpected[];
+extern const char e_unmatched[];
+extern const char e_endoffile[];
+extern const char e_newline[];
+
+/* odd chars */
+#define LBRACE '{'
+#define RBRACE '}'
+#define LPAREN '('
+#define RPAREN ')'
+#define LBRACT '['
+#define RBRACT ']'
+
+extern int sh_lex();
+extern Lex_t *sh_lexopen(Lex_t*, Shell_t*, int);
+extern void sh_lexskip(int,int,int);
+extern void sh_syntax(void);
+
+#endif /* !NOTSYM */
diff --git a/usr/src/lib/libshell/common/include/shnodes.h b/usr/src/lib/libshell/common/include/shnodes.h
new file mode 100644
index 0000000000..b688edb4c5
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/shnodes.h
@@ -0,0 +1,222 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef _SHNODES_H
+#define _SHNODES_H 1
+/*
+ * UNIX shell
+ * Written by David Korn
+ *
+ */
+
+
+#include <ast.h>
+#include "argnod.h"
+
+/* command tree for tretyp */
+#define FINT (02<<COMBITS) /* non-interruptable */
+#define FAMP (04<<COMBITS) /* background */
+#define FPIN (010<<COMBITS) /* input is a pipe */
+#define FPOU (040<<COMBITS) /* output is a pipe */
+#define FPCL (0100<<COMBITS) /* close the pipe */
+#define FCOOP (0200<<COMBITS) /* cooperating process */
+#define FSHOWME (0400<<COMBITS) /* set for showme commands */
+#define FPOSIX (02<<COMBITS) /* posix semantics function */
+#define FLINENO (04<<COMBITS) /* for/case has line number */
+
+#define TNEGATE (01<<COMBITS) /* ! inside [[...]] */
+#define TBINARY (02<<COMBITS) /* binary operator in [[...]] */
+#define TUNARY (04<<COMBITS) /* unary operator in [[...]] */
+#define TTEST (010<<COMBITS)
+#define TPAREN (TBINARY|TUNARY)
+#define TSHIFT (COMBITS+4)
+#define TNSPACE (TFUN|COMSCAN)
+
+#define TCOM 0
+#define TPAR 1
+#define TFIL 2
+#define TLST 3
+#define TIF 4
+#define TWH 5
+#define TUN (TWH|COMSCAN)
+#define TTST 6
+#define TSW 7
+#define TAND 8
+#define TORF 9
+#define TFORK 10
+#define TFOR 11
+#define TSELECT (TFOR|COMSCAN)
+#define TARITH 12
+#define TTIME 13
+#define TSETIO 14
+#define TFUN 15
+
+/* this node is a proforma for those that follow */
+
+struct trenod
+{
+ int tretyp;
+ struct ionod *treio;
+};
+
+
+struct forknod
+{
+ int forktyp;
+ struct ionod *forkio;
+ Shnode_t *forktre;
+ int forkline;
+};
+
+
+struct ifnod
+{
+ int iftyp;
+ Shnode_t *iftre;
+ Shnode_t *thtre;
+ Shnode_t *eltre;
+};
+
+struct whnod
+{
+ int whtyp;
+ Shnode_t *whtre;
+ Shnode_t *dotre;
+ struct arithnod *whinc;
+};
+
+struct fornod
+{
+ int fortyp;
+ char *fornam;
+ Shnode_t *fortre;
+ struct comnod *forlst;
+ int forline;
+};
+
+struct swnod
+{
+ int swtyp;
+ struct argnod *swarg;
+ struct regnod *swlst;
+ struct ionod *swio;
+ int swline;
+};
+
+struct regnod
+{
+ struct argnod *regptr;
+ Shnode_t *regcom;
+ struct regnod *regnxt;
+ char regflag;
+};
+
+struct parnod
+{
+ int partyp;
+ Shnode_t *partre;
+};
+
+struct lstnod
+{
+ int lsttyp;
+ Shnode_t *lstlef;
+ Shnode_t *lstrit;
+};
+
+/* tst is same as lst, but with extra field for line number */
+struct tstnod
+{
+ struct lstnod tstlst;
+ int tstline;
+};
+
+struct functnod
+{
+ int functtyp;
+ char *functnam;
+ Shnode_t *functtre;
+ int functline;
+ off_t functloc;
+ struct slnod *functstak;
+ struct comnod *functargs;
+};
+
+struct arithnod
+{
+ int artyp;
+ int arline;
+ struct argnod *arexpr;
+ void *arcomp;
+};
+
+
+/* types of ionodes stored in iofile */
+#define IOUFD 0x3f /* file descriptor number mask */
+#define IOPUT 0x40 /* > redirection operator */
+#define IOAPP 0x80 /* >> redirection operator */
+#define IODOC 0x100 /* << redirection operator */
+#define IOMOV 0x200 /* <& or >& operators */
+#define IOCLOB 0x400 /* noclobber bit */
+#define IORDW 0x800 /* <> redirection operator */
+#define IORAW 0x1000 /* no expansion needed for filename */
+#define IOSTRG 0x2000 /* here-document stored as incore string */
+#define IOSTRIP 0x4000 /* strip leading tabs for here-document */
+#define IOQUOTE 0x8000 /* here-document delimiter was quoted */
+#define IOVNM 0x10000 /* iovname field is non-zero */
+#define IOLSEEK 0x20000 /* seek operators <# or ># */
+#define IOARITH 0x40000 /* arithmetic seek <# ((expr)) */
+#define IOCOPY IOCLOB /* copy skipped lines onto standard output */
+
+union Shnode_u
+{
+ struct argnod arg;
+ struct ionod io;
+ struct whnod wh;
+ struct swnod sw;
+ struct ifnod if_;
+ struct dolnod dol;
+ struct comnod com;
+ struct trenod tre;
+ struct forknod fork;
+ struct fornod for_;
+ struct regnod reg;
+ struct parnod par;
+ struct lstnod lst;
+ struct tstnod tst;
+ struct functnod funct;
+ struct arithnod ar;
+};
+
+extern void sh_freeup(void);
+extern void sh_funstaks(struct slnod*,int);
+extern Sfio_t *sh_subshell(Shnode_t*, int, int);
+#if defined(__EXPORT__) && defined(_BLD_DLL) && defined(_BLD_shell)
+ __EXPORT__
+#endif
+extern int sh_tdump(Sfio_t*, const Shnode_t*);
+extern Shnode_t *sh_dolparen(void);
+extern Shnode_t *sh_trestore(Sfio_t*);
+#if SHOPT_KIA
+ extern int kiaclose(void);
+ extern unsigned long kiaentity(const char*,int,int,int,int,unsigned long,int,int,const char*);
+#endif /* SHOPT_KIA */
+
+#endif /* _SHNODES_H */
diff --git a/usr/src/lib/libshell/common/include/shtable.h b/usr/src/lib/libshell/common/include/shtable.h
new file mode 100644
index 0000000000..fc4e8e471f
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/shtable.h
@@ -0,0 +1,65 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef _SHTABLE_H
+
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * Interface definitions read-only data tables for shell
+ *
+ */
+
+#define _SHTABLE_H 1
+
+typedef struct shtable1
+{
+ const char *sh_name;
+ unsigned sh_number;
+} Shtable_t;
+
+struct shtable2
+{
+ const char *sh_name;
+ unsigned sh_number;
+ const char *sh_value;
+};
+
+struct shtable3
+{
+ const char *sh_name;
+ unsigned sh_number;
+ int (*sh_value)(int, char*[], void*);
+};
+
+#define sh_lookup(name,value) (sh_locate(name,(Shtable_t*)(value),sizeof(*(value)))->sh_number)
+extern const Shtable_t shtab_testops[];
+extern const Shtable_t shtab_options[];
+extern const Shtable_t shtab_attributes[];
+extern const struct shtable2 shtab_variables[];
+extern const struct shtable2 shtab_aliases[];
+extern const struct shtable2 shtab_signals[];
+extern const struct shtable3 shtab_builtins[];
+extern const Shtable_t shtab_reserved[];
+extern const Shtable_t *sh_locate(const char*, const Shtable_t*, int);
+extern int sh_lookopt(const char*, int*);
+
+#endif /* SH_TABLE_H */
diff --git a/usr/src/lib/libshell/common/include/streval.h b/usr/src/lib/libshell/common/include/streval.h
new file mode 100644
index 0000000000..bbf51bd9d7
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/streval.h
@@ -0,0 +1,195 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef SEQPOINT
+/*
+ * D. G. Korn
+ *
+ * arithmetic expression evaluator
+ */
+
+/* The following only is needed for const */
+#include <ast.h>
+#include <math.h>
+#if _AST_VERSION >= 20030127L
+# include <ast_float.h>
+#endif
+
+#if _ast_fltmax_double
+#define LDBL_LLONG_MAX DBL_LLONG_MAX
+#define LDBL_ULLONG_MAX DBL_ULLONG_MAX
+#define LDBL_LLONG_MIN DBL_LLONG_MIN
+#endif
+
+#ifndef LDBL_LLONG_MAX
+# ifdef LLONG_MAX
+# define LDBL_LLONG_MAX ((Sfdouble_t)LLONG_MAX)
+# else
+# ifdef LLONG_MAX
+# define LDBL_LLONG_MAX ((Sfdouble_t)LLONG_MAX)
+# else
+# define LDBL_LLONG_MAX ((Sfdouble_t)((((Sflong_t)1) << (8*sizeof(Sflong_t)-1)) -1 ))
+# endif
+# endif
+#endif
+#ifndef LDBL_ULLONG_MAX
+# ifdef ULLONG_MAX
+# define LDBL_ULLONG_MAX ((Sfdouble_t)ULLONG_MAX)
+# else
+# define LDBL_ULLONG_MAX (2.*((Sfdouble_t)LDBL_LLONG_MAX))
+# endif
+#endif
+#ifndef LDBL_LLONG_MIN
+# ifdef LLONG_MIN
+# define LDBL_LLONG_MIN ((Sfdouble_t)LLONG_MIN)
+# else
+# define LDBL_LLONG_MIN (-LDBL_LLONG_MAX)
+# endif
+#endif
+#ifndef LDBL_DIG
+# define LDBL_DIG DBL_DIG
+#endif
+
+struct lval
+{
+ char *value;
+ Sfdouble_t (*fun)(Sfdouble_t,...);
+ const char *expr;
+ short flag;
+ char isfloat;
+ char nargs;
+ short emode;
+ short level;
+ short elen;
+};
+
+struct mathtab
+{
+ char fname[16];
+ Sfdouble_t (*fnptr)(Sfdouble_t,...);
+};
+
+typedef struct _arith_
+{
+ unsigned char *code;
+ const char *expr;
+ Sfdouble_t (*fun)(const char**,struct lval*,int,Sfdouble_t);
+ short size;
+ short staksize;
+ short emode;
+ short elen;
+} Arith_t;
+#define ARITH_COMP 04 /* set when compile separate from execute */
+
+#define MAXPREC 15 /* maximum precision level */
+#define SEQPOINT 0200 /* sequence point */
+#define NOASSIGN 0100 /* assignment legal with this operator */
+#define RASSOC 040 /* right associative */
+#define NOFLOAT 020 /* illegal with floating point */
+#define PRECMASK 017 /* precision bit mask */
+
+#define A_EOF 1
+#define A_NEQ 2
+#define A_NOT 3
+#define A_MOD 4
+#define A_ANDAND 5
+#define A_AND 6
+#define A_LPAR 7
+#define A_RPAR 8
+#define A_POW 9
+#define A_TIMES 10
+#define A_PLUSPLUS 11
+#define A_PLUS 12
+#define A_COMMA 13
+#define A_MINUSMINUS 14
+#define A_MINUS 15
+#define A_DIV 16
+#define A_LSHIFT 17
+#define A_LE 18
+#define A_LT 19
+#define A_EQ 20
+#define A_ASSIGN 21
+#define A_COLON 22
+#define A_RSHIFT 23
+#define A_GE 24
+#define A_GT 25
+#define A_QCOLON 26
+#define A_QUEST 27
+#define A_XOR 28
+#define A_OROR 29
+#define A_OR 30
+#define A_TILDE 31
+#define A_REG 32
+#define A_DIG 33
+#define A_INCR 34
+#define A_DECR 35
+#define A_PUSHV 36
+#define A_PUSHL 37
+#define A_PUSHN 38
+#define A_PUSHF 39
+#define A_STORE 40
+#define A_POP 41
+#define A_SWAP 42
+#define A_UMINUS 43
+#define A_JMPZ 44
+#define A_JMPNZ 45
+#define A_JMP 46
+#define A_CALL0 47
+#define A_CALL1 48
+#define A_CALL2 49
+#define A_CALL3 50
+#define A_DOT 51
+#define A_LIT 52
+#define A_NOTNOT 53
+
+
+/* define error messages */
+extern const unsigned char strval_precedence[35];
+extern const char strval_states[64];
+extern const char e_moretokens[];
+extern const char e_argcount[];
+extern const char e_paren[];
+extern const char e_badnum[];
+extern const char e_badcolon[];
+extern const char e_recursive[];
+extern const char e_divzero[];
+extern const char e_synbad[];
+extern const char e_notlvalue[];
+extern const char e_function[];
+extern const char e_questcolon[];
+extern const char e_incompatible[];
+extern const char e_domain[];
+extern const char e_overflow[];
+extern const char e_singularity[];
+extern const char e_dict[];
+extern const char e_charconst[];
+extern const struct mathtab shtab_math[];
+
+/* function code for the convert function */
+
+#define LOOKUP 0
+#define ASSIGN 1
+#define VALUE 2
+#define MESSAGE 3
+
+extern Sfdouble_t strval(const char*,char**,Sfdouble_t(*)(const char**,struct lval*,int,Sfdouble_t),int);
+extern Arith_t *arith_compile(const char*,char**,Sfdouble_t(*)(const char**,struct lval*,int,Sfdouble_t),int);
+extern Sfdouble_t arith_exec(Arith_t*);
+#endif /* !SEQPOINT */
diff --git a/usr/src/lib/libshell/common/include/terminal.h b/usr/src/lib/libshell/common/include/terminal.h
new file mode 100644
index 0000000000..1712c12bab
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/terminal.h
@@ -0,0 +1,195 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#ifndef _terminal_
+#define _terminal_ 1
+
+#include "FEATURE/ttys"
+/*
+ * terminal interface
+ * complicated by the fact that there are so many variations
+ * This will use POSIX <termios.h> interface where available
+ */
+
+#ifdef _hdr_termios
+# include <termios.h>
+# if __sgi__ || sgi /* special hack to eliminate ^M problem */
+# ifndef ECHOCTL
+# define ECHOCTL ECHOE
+# endif /* ECHOCTL */
+# ifndef CNSUSP
+# define CNSUSP CNSWTCH
+# endif /* CNSUSP */
+# endif /* sgi */
+# ifdef _NEXT_SOURCE
+# define _lib_tcgetattr 1
+# define _lib_tcgetpgrp 1
+# endif /* _NEXT_SOURCE */
+#else
+# if defined(_sys_termios) && defined(_lib_tcgetattr)
+# include <sys/termios.h>
+# define _hdr_termios
+# else
+# undef _sys_termios
+# endif /* _sys_termios */
+#endif /* _hdr_termios */
+
+#ifdef _hdr_termios
+# undef _hdr_sgtty
+# undef tcgetattr
+# undef tcsetattr
+# undef tcgetpgrp
+# undef tcsetpgrp
+# undef cfgetospeed
+# ifndef TCSANOW
+# define TCSANOW TCSETS
+# define TCSADRAIN TCSETSW
+# define TCSAFLUSH TCSETSF
+# endif /* TCSANOW */
+ /* The following corrects bugs in some implementations */
+# if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
+# define TCSAFLUSH TCSADFLUSH
+# endif /* TCSADFLUSH */
+# ifndef _lib_tcgetattr
+# undef tcgetattr
+# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
+# undef tcsetattr
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# undef cfgetospeed
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# endif /* _lib_tcgetattr */
+# undef TIOCGETC
+# if SHOPT_OLDTERMIO /* use both termios and termio */
+# ifdef _hdr_termio
+# include <termio.h>
+# else
+# ifdef _sys_termio
+# include <sys/termio.h>
+# define _hdr_termio 1
+# else
+# undef SHOPT_OLDTERMIO
+# endif /* _sys_termio */
+# endif /* _hdr_termio */
+# endif /* SHOPT_OLDTERMIO */
+#else
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# undef SHOPT_OLDTERMIO
+# ifdef _hdr_termio
+# include <termio.h>
+# else
+# ifdef _sys_termio
+# include <sys/termio.h>
+# define _hdr_termio 1
+# endif /* _sys_termio */
+# endif /* _hdr_termio */
+# ifdef _hdr_termio
+# define termios termio
+# undef TIOCGETC
+# define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+
+# ifdef _sys_bsdtty
+# include <sys/bsdtty.h>
+# endif /* _sys_bsdtty */
+# else
+# ifdef _hdr_sgtty
+# include <sgtty.h>
+# ifndef LPENDIN
+# ifdef _sys_nttyio
+# include <sys/nttyio.h>
+# endif /* _sys_nttyio */
+# endif /* LPENDIN */
+# define termios sgttyb
+# ifdef TIOCSETN
+# undef TCSETAW
+# endif /* TIOCSETN */
+# ifdef TIOCGETP
+# define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty)
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# else
+# define tcgetattr(fd,tty) gtty(fd, tty)
+# define tcsetattr(fd,action,tty) stty(fd, tty)
+# endif /* TIOCGETP */
+# endif /* _hdr_sgtty */
+# endif /* hdr_termio */
+
+# ifndef TCSANOW
+# ifdef TCSETAW
+# define TCSANOW TCSETA
+# ifdef u370
+ /* delays are too long, don't wait for output to drain */
+# define TCSADRAIN TCSETA
+# else
+# define TCSADRAIN TCSETAW
+# endif /* u370 */
+# define TCSAFLUSH TCSETAF
+# else
+# ifdef TIOCSETN
+# define TCSANOW TIOCSETN
+# define TCSADRAIN TIOCSETN
+# define TCSAFLUSH TIOCSETP
+# endif /* TIOCSETN */
+# endif /* TCSETAW */
+# endif /* TCSANOW */
+#endif /* _hdr_termios */
+
+/* set ECHOCTL if driver can echo control charaters as ^c */
+#ifdef LCTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LCTLECH
+# endif /* !ECHOCTL */
+#endif /* LCTLECH */
+#ifdef LNEW_CTLECH
+# ifndef ECHOCTL
+# define ECHOCTL LNEW_CTLECH
+# endif /* !ECHOCTL */
+#endif /* LNEW_CTLECH */
+#ifdef LNEW_PENDIN
+# ifndef PENDIN
+# define PENDIN LNEW_PENDIN
+# endif /* !PENDIN */
+#endif /* LNEW_PENDIN */
+#ifndef ECHOCTL
+# ifndef VEOL
+# define RAWONLY 1
+# endif /* !VEOL */
+#endif /* !ECHOCTL */
+
+#ifdef _sys_filio
+# ifndef FIONREAD
+# include <sys/filio.h>
+# endif /* FIONREAD */
+#endif /* _sys_filio */
+/* set FIORDCHK if you can check for characters in input queue */
+#ifdef FIONREAD
+# ifndef FIORDCHK
+# define FIORDCHK FIONREAD
+# endif /* !FIORDCHK */
+#endif /* FIONREAD */
+
+extern int tty_alt(int);
+extern void tty_cooked(int);
+extern int tty_get(int,struct termios*);
+extern int tty_raw(int,int);
+extern int tty_check(int);
+extern int tty_set(int, int, struct termios*);
+
+#endif /* _terminal_ */
diff --git a/usr/src/lib/libshell/common/include/test.h b/usr/src/lib/libshell/common/include/test.h
new file mode 100644
index 0000000000..b1ece6fcfa
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/test.h
@@ -0,0 +1,71 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef TEST_ARITH
+/*
+ * UNIX shell
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#include "FEATURE/options"
+#include "shtable.h"
+/*
+ * These are the valid test operators
+ */
+
+#define TEST_ARITH 040 /* arithmetic operators */
+#define TEST_BINOP 0200 /* binary operator */
+#define TEST_PATTERN 0100 /* turn off bit for pattern compares */
+
+#define TEST_NE (TEST_ARITH|9)
+#define TEST_EQ (TEST_ARITH|4)
+#define TEST_GE (TEST_ARITH|5)
+#define TEST_GT (TEST_ARITH|6)
+#define TEST_LE (TEST_ARITH|7)
+#define TEST_LT (TEST_ARITH|8)
+#define TEST_OR (TEST_BINOP|1)
+#define TEST_AND (TEST_BINOP|2)
+#define TEST_SNE (TEST_PATTERN|1)
+#define TEST_SEQ (TEST_PATTERN|14)
+#define TEST_PNE 1
+#define TEST_PEQ 14
+#define TEST_EF 3
+#define TEST_NT 10
+#define TEST_OT 12
+#define TEST_SLT 15
+#define TEST_SGT 16
+#define TEST_END 8
+#define TEST_REP 20
+
+extern int test_unop(int, const char*);
+extern int test_inode(const char*, const char*);
+extern int test_binop(int, const char*, const char*);
+
+extern const char sh_opttest[];
+extern const char test_opchars[];
+extern const char e_argument[];
+extern const char e_missing[];
+extern const char e_badop[];
+extern const char e_tstbegin[];
+extern const char e_tstend[];
+
+#endif /* TEST_ARITH */
diff --git a/usr/src/lib/libshell/common/include/timeout.h b/usr/src/lib/libshell/common/include/timeout.h
new file mode 100644
index 0000000000..3248b562c1
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/timeout.h
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * UNIX shell
+ *
+ * AT&T Labs
+ *
+ */
+
+#define TGRACE 60 /* grace period before termination */
+ /* The time_warn message contains this number */
+extern const char e_timeout[];
+extern const char e_timewarn[];
diff --git a/usr/src/lib/libshell/common/include/ulimit.h b/usr/src/lib/libshell/common/include/ulimit.h
new file mode 100644
index 0000000000..b31d12b494
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/ulimit.h
@@ -0,0 +1,175 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef _ULIMIT_H
+#define _ULIMIT_H 1
+/*
+ * This is for the ulimit built-in command
+ */
+
+#include "FEATURE/time"
+#include "FEATURE/rlimits"
+#if defined(_sys_resource) && defined(_lib_getrlimit)
+# include <sys/resource.h>
+# if !defined(RLIMIT_FSIZE) && defined(_sys_vlimit)
+ /* This handles hp/ux problem */
+# include <sys/vlimit.h>
+# define RLIMIT_FSIZE (LIM_FSIZE-1)
+# define RLIMIT_DATA (LIM_DATA-1)
+# define RLIMIT_STACK (LIM_STACK-1)
+# define RLIMIT_CORE (LIM_CORE-1)
+# define RLIMIT_CPU (LIM_CPU-1)
+# ifdef LIM_MAXRSS
+# define RLIMIT_RSS (LIM_MAXRSS-1)
+# endif /* LIM_MAXRSS */
+# endif
+# undef _lib_ulimit
+#else
+# ifdef _sys_vlimit
+# include <sys/vlimit.h>
+# undef _lib_ulimit
+# define RLIMIT_FSIZE LIM_FSIZE
+# define RLIMIT_DATA LIM_DATA
+# define RLIMIT_STACK LIM_STACK
+# define RLIMIT_CORE LIM_CORE
+# define RLIMIT_CPU LIM_CPU
+# ifdef LIM_MAXRSS
+# define RLIMIT_RSS LIM_MAXRSS
+# endif /* LIM_MAXRSS */
+# else
+# ifdef _lib_ulimit
+# define vlimit ulimit
+# endif /* _lib_ulimit */
+# endif /* _lib_vlimit */
+#endif
+
+#ifdef RLIM_INFINITY
+# define INFINITY RLIM_INFINITY
+#else
+# ifndef INFINITY
+# define INFINITY ((rlim_t)-1L)
+# endif /* INFINITY */
+#endif /* RLIM_INFINITY */
+
+#if defined(_lib_getrlimit) || defined(_lib_vlimit) || defined(_lib_ulimit)
+# ifndef RLIMIT_CPU
+# define RLIMIT_CPU 0
+# endif /* !RLIMIT_CPU */
+# ifndef RLIMIT_DATA
+# define RLIMIT_DATA 0
+# endif /* !RLIMIT_DATA */
+# ifndef RLIMIT_RSS
+# define RLIMIT_RSS 0
+# endif /* !RLIMIT_RSS */
+# ifndef RLIMIT_STACK
+# define RLIMIT_STACK 0
+# endif /* !RLIMIT_STACK */
+# ifndef RLIMIT_CORE
+# define RLIMIT_CORE 0
+# endif /* !RLIMIT_CORE */
+# ifndef RLIMIT_VMEM
+# define RLIMIT_VMEM 0
+# endif /* !RLIMIT_VMEM */
+# ifndef RLIMIT_NOFILE
+# define RLIMIT_NOFILE 0
+# endif /* !RLIMIT_NOFILE */
+#else
+# define _no_ulimit
+#endif
+#ifndef _typ_rlim_t
+ typedef long rlim_t;
+#endif
+
+#if !defined(RLIMIT_NOFILE) && defined(RLIMIT_OFILE)
+#define RLIMIT_NOFILE RLIMIT_OFILE
+#endif
+
+#ifndef RLIMIT_UNKNOWN
+#define RLIMIT_UNKNOWN (-9999)
+#endif
+#ifndef RLIMIT_AS
+#define RLIMIT_AS RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_CORE
+#define RLIMIT_CORE RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_CPU
+#define RLIMIT_CPU RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_DATA
+#define RLIMIT_DATA RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_FSIZE
+#define RLIMIT_FSIZE RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_LOCKS
+#define RLIMIT_LOCKS RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_MEMLOCK
+#define RLIMIT_MEMLOCK RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_NOFILE
+#define RLIMIT_NOFILE RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_NPROC
+#define RLIMIT_NPROC RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_PIPE
+#define RLIMIT_PIPE RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_RSS
+#define RLIMIT_RSS RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_SBSIZE
+#define RLIMIT_SBSIZE RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_STACK
+#define RLIMIT_STACK RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_PTHREAD
+#define RLIMIT_PTHREAD RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_VMEM
+#define RLIMIT_VMEM RLIMIT_UNKNOWN
+#endif
+
+#define LIM_COUNT 0
+#define LIM_BLOCK 1
+#define LIM_BYTE 2
+#define LIM_KBYTE 3
+#define LIM_SECOND 4
+
+typedef struct Limit_s
+{
+ const char name[8];
+ const char* description;
+ int index;
+ const char* conf;
+ unsigned char option;
+ unsigned char type;
+} Limit_t;
+
+extern const Limit_t shtab_limits[];
+extern const int shtab_units[];
+
+extern const char e_unlimited[];
+extern const char* e_units[];
+
+#endif /* _ULIMIT_H */
diff --git a/usr/src/lib/libshell/common/include/variables.h b/usr/src/lib/libshell/common/include/variables.h
new file mode 100644
index 0000000000..2ceefcf9f7
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/variables.h
@@ -0,0 +1,104 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#ifndef SH_VALNOD
+
+#include <option.h>
+#include "FEATURE/options"
+#include "FEATURE/dynamic"
+
+/* The following defines are coordinated with data in data/variables.c */
+
+#define PATHNOD (sh.bltin_nodes)
+#define PS1NOD (sh.bltin_nodes+1)
+#define PS2NOD (sh.bltin_nodes+2)
+#define IFSNOD (sh.bltin_nodes+3)
+#define PWDNOD (sh.bltin_nodes+4)
+#define HOME (sh.bltin_nodes+5)
+#define MAILNOD (sh.bltin_nodes+6)
+#define REPLYNOD (sh.bltin_nodes+7)
+#define SHELLNOD (sh.bltin_nodes+8)
+#define EDITNOD (sh.bltin_nodes+9)
+#define MCHKNOD (sh.bltin_nodes+10)
+#define RANDNOD (sh.bltin_nodes+11)
+#define ENVNOD (sh.bltin_nodes+12)
+#define HISTFILE (sh.bltin_nodes+13)
+#define HISTSIZE (sh.bltin_nodes+14)
+#define HISTEDIT (sh.bltin_nodes+15)
+#define HISTCUR (sh.bltin_nodes+16)
+#define FCEDNOD (sh.bltin_nodes+17)
+#define CDPNOD (sh.bltin_nodes+18)
+#define MAILPNOD (sh.bltin_nodes+19)
+#define PS3NOD (sh.bltin_nodes+20)
+#define OLDPWDNOD (sh.bltin_nodes+21)
+#define VISINOD (sh.bltin_nodes+22)
+#define COLUMNS (sh.bltin_nodes+23)
+#define LINES (sh.bltin_nodes+24)
+#define PPIDNOD (sh.bltin_nodes+25)
+#define L_ARGNOD (sh.bltin_nodes+26)
+#define TMOUTNOD (sh.bltin_nodes+27)
+#define SECONDS (sh.bltin_nodes+28)
+#define LINENO (sh.bltin_nodes+29)
+#define OPTARGNOD (sh.bltin_nodes+30)
+#define OPTINDNOD (sh.bltin_nodes+31)
+#define PS4NOD (sh.bltin_nodes+32)
+#define FPATHNOD (sh.bltin_nodes+33)
+#define LANGNOD (sh.bltin_nodes+34)
+#define LCALLNOD (sh.bltin_nodes+35)
+#define LCCOLLNOD (sh.bltin_nodes+36)
+#define LCTYPENOD (sh.bltin_nodes+37)
+#define LCMSGNOD (sh.bltin_nodes+38)
+#define LCNUMNOD (sh.bltin_nodes+39)
+#define FIGNORENOD (sh.bltin_nodes+40)
+#define DOTSHNOD (sh.bltin_nodes+41)
+#define ED_CHRNOD (sh.bltin_nodes+42)
+#define ED_COLNOD (sh.bltin_nodes+43)
+#define ED_TXTNOD (sh.bltin_nodes+44)
+#define ED_MODENOD (sh.bltin_nodes+45)
+#define SH_NAMENOD (sh.bltin_nodes+46)
+#define SH_SUBSCRNOD (sh.bltin_nodes+47)
+#define SH_VALNOD (sh.bltin_nodes+48)
+#define SH_VERSIONNOD (sh.bltin_nodes+49)
+#define SH_DOLLARNOD (sh.bltin_nodes+50)
+#define SH_MATCHNOD (sh.bltin_nodes+51)
+#define SH_COMMANDNOD (sh.bltin_nodes+52)
+#define SH_PATHNAMENOD (sh.bltin_nodes+53)
+#define SH_FUNNAMENOD (sh.bltin_nodes+54)
+#define SH_SUBSHELLNOD (sh.bltin_nodes+55)
+#define SH_LEVELNOD (sh.bltin_nodes+56)
+#if SHOPT_FS_3D
+# define VPATHNOD (sh.bltin_nodes+57)
+# define NFS_3D 1
+#else
+# define NFS_3D 0
+#endif /* SHOPT_FS_3D */
+#if SHOPT_VPIX
+# define DOSPATHNOD (sh.bltin_nodes+57+NFS_3D)
+# define VPIXNOD (sh.bltin_nodes+58+NFS_3D)
+# define NVPIX (NFS_3D+2)
+#else
+# define NVPIX NFS_3D
+#endif /* SHOPT_VPIX */
+#ifdef apollo
+# define SYSTYPENOD (sh.bltin_nodes+57+NVPIX)
+#endif /* apollo */
+
+#endif /* SH_VALNOD */
diff --git a/usr/src/lib/libshell/common/include/version.h b/usr/src/lib/libshell/common/include/version.h
new file mode 100644
index 0000000000..dafdfcbd68
--- /dev/null
+++ b/usr/src/lib/libshell/common/include/version.h
@@ -0,0 +1,20 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#define SH_RELEASE "1993-12-28 s+"
diff --git a/usr/src/lib/libshell/common/llib-lshell b/usr/src/lib/libshell/common/llib-lshell
new file mode 100644
index 0000000000..49bb9889e7
--- /dev/null
+++ b/usr/src/lib/libshell/common/llib-lshell
@@ -0,0 +1,138 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * lib/libshell/common/llib-lshell
+ *
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*LINTLIBRARY*/
+/*PROTOLIB1*/
+
+#include <shell.h>
+#include <nval.h>
+
+/* automatically generated data start here */
+extern const char e_defpath[];
+extern const char e_found[];
+extern const char e_nospace[];
+extern const char e_format[];
+extern const char e_number[];
+extern const char e_restricted[];
+extern const char e_recursive[];
+extern char e_version[];
+extern Dt_t *sh_bltin_tree (void);
+extern void sh_subfork (void);
+extern Shell_t *sh_init (int,char*[],Shinit_f);
+extern int sh_reinit (char*[]);
+extern int sh_eval (Sfio_t*,int);
+extern void sh_delay (double);
+extern void *sh_parse (Shell_t*, Sfio_t*,int);
+extern int sh_trap (const char*,int);
+extern int sh_fun (Namval_t*,Namval_t*, char*[]);
+extern int sh_funscope (int,char*[],int(*)(void*),void*,int);
+extern Sfio_t *sh_iogetiop (int,int);
+extern int sh_main (int, char*[], void(*)(int));
+extern void sh_menu (Sfio_t*, int, char*[]);
+extern Namval_t *sh_addbuiltin (const char*, int(*)(int, char*[],void*), void*);
+extern char *sh_fmtq (const char*);
+extern char *sh_fmtqf (const char*, int, int);
+extern Sfdouble_t sh_strnum (const char*, char**, int);
+extern int sh_access (const char*,int);
+extern int sh_close (int);
+extern int sh_dup (int);
+extern void sh_exit (int);
+extern int sh_fcntl (int, int, ...);
+extern Sfio_t *sh_fd2sfio (int);
+extern Shell_t *sh_getinterp (void);
+extern int sh_open (const char*, int, ...);
+extern int sh_openmax (void);
+extern Sfio_t *sh_pathopen (const char*);
+extern ssize_t sh_read (int, void*, size_t);
+extern ssize_t sh_write (int, const void*, size_t);
+extern off_t sh_seek (int, off_t, int);
+extern int sh_pipe (int[]);
+extern mode_t sh_umask (mode_t);
+extern void *sh_waitnotify (Shwait_f);
+extern Shscope_t *sh_getscope (int,int);
+extern Shscope_t *sh_setscope (Shscope_t*);
+extern void sh_sigcheck (void);
+extern unsigned long sh_isoption (int);
+extern unsigned long sh_onoption (int);
+extern unsigned long sh_offoption (int);
+extern int sh_waitsafe (void);
+extern int sh_exec (const Shnode_t*,int);
+extern int sh_waitsafe(void);
+extern int sh_exec(const Shnode_t*,int);
+extern void **sh_getliblist(void);
+extern Shell_t sh;
+extern Namarr_t *nv_setarray (Namval_t*,void*(*)(Namval_t*,const char*,int));
+extern void *nv_associative (Namval_t*,const char*,int);
+extern int nv_aindex (Namval_t*);
+extern int nv_nextsub (Namval_t*);
+extern char *nv_getsub (Namval_t*);
+extern Namval_t *nv_putsub (Namval_t*, char*, long);
+extern Namval_t *nv_opensub (Namval_t*);
+extern int nv_adddisc (Namval_t*, const char**, Namval_t**);
+extern int nv_clone (Namval_t*, Namval_t*, int);
+extern void nv_close (Namval_t*);
+extern void *nv_context (Namval_t*);
+extern Namval_t *nv_create (const char*, Dt_t*, int,Namfun_t*);
+extern Dt_t *nv_dict (Namval_t*);
+extern Sfdouble_t nv_getn (Namval_t*, Namfun_t*);
+extern Sfdouble_t nv_getnum (Namval_t*);
+extern char *nv_getv (Namval_t*, Namfun_t*);
+extern char *nv_getval (Namval_t*);
+extern Namfun_t *nv_hasdisc (Namval_t*, const Namdisc_t*);
+extern int nv_isnull (Namval_t*);
+extern Namval_t *nv_lastdict (void);
+extern void nv_newattr (Namval_t*,unsigned,int);
+extern Namval_t *nv_open (const char*,Dt_t*,int);
+extern void nv_putval (Namval_t*,const char*,int);
+extern void nv_putv (Namval_t*,const char*,int,Namfun_t*);
+extern int nv_scan (Dt_t*,void(*)(Namval_t*,void*),void*,int,int);
+extern Namval_t *nv_scoped (Namval_t*);
+extern char *nv_setdisc (Namval_t*,const char*,Namval_t*,Namfun_t*);
+extern void nv_setref (Namval_t*, Dt_t*,int);
+extern int nv_settype (Namval_t*, Namval_t*, int);
+extern void nv_setvec (Namval_t*,int,int,char*[]);
+extern void nv_setvtree (Namval_t*);
+extern int nv_setsize (Namval_t*,int);
+extern Namfun_t *nv_disc (Namval_t*,Namfun_t*,int);
+extern void nv_unset (Namval_t*);
+extern Namval_t *nv_search (const char *, Dt_t*, int);
+extern void nv_unscope (void);
+extern char *nv_name (Namval_t*);
+extern Namval_t *nv_type (Namval_t*);
+extern const Namdisc_t *nv_discfun (int);
+/* end of automatically generated data */
+
+/* Manually added based on libshell/common/include/builtins.h */
+extern int b_printf(int, char*[],void*);
+extern int B_echo(int, char*[],void*);
+extern int b_print(int, char*[],void*);
+extern int b_pwd(int, char*[],void*);
+extern int b_sleep(int, char*[],void*);
+extern int b_test(int, char*[],void*);
diff --git a/usr/src/lib/libshell/common/nval.3 b/usr/src/lib/libshell/common/nval.3
new file mode 100644
index 0000000000..4acfc70b64
--- /dev/null
+++ b/usr/src/lib/libshell/common/nval.3
@@ -0,0 +1,619 @@
+.fp 5 CW
+.TH NVAL 3 "12 Feb 2003"
+.PP
+.SH NAME
+.PP
+\fBnval\fR \- the \f5ksh\fP name/value library
+.PP
+.SH SYNOPSIS
+.ta .8i 1.6i 2.4i 3.2i 4.0i
+.SS "HEADERS/LIBRARIES"
+.nf
+.ft 5
+#include <nval.h>
+libshell.a -lshell
+.ft R
+.fi
+.SS "DATA TYPES"
+.nf
+.ft 5
+Namval_t;
+Namfun_t;
+Namarr_t;
+Namdisc_t;
+.ft R
+.fi
+.SS "OPENING/CLOSING"
+.nf
+.ft 5
+Namval_t *nv_open(const char *\fIname\fP, Dt_t *\fIdict\fP, int \fIflags\fP);
+Namval_t *nv_create(const char *\fIname\fP, Dt_t *\fIdict\fP, int \fIflags\fP, Namfun_t *\fIfp\fP);
+void nv_close(Namval_t *\fInp\fP);
+.ft R
+.fi
+.SS "GETTING AND SETTING VALUES"
+.nf
+.ft 5
+char *nv_getval(Namval_t *\fInp\fP);
+Sfdouble_t nv_getnum(Namval_t *\fInp\fP);
+char *nv_name(Namval_t *\fInp\fP);
+void nv_putval(Namval_t *\fInp\fP, const char *\fIval\fP, int \fIflags\fP);
+void nv_unset(Namval_t *\fInp\fP);
+int nv_clone(Namval_t *\fIsrc\fP, Namval_t *\fIdest\fP, int \fIflags\fP);
+.ft R
+.fi
+.SS "ATTRIBUTES AND SIZE"
+.nf
+.ft 5
+int nv_isnull(Namval_t *\fInp\fP);
+int nv_setsize(Namval_t *\fInp\fP, int \fIsize\fP);
+int nv_size(Namval_t *\fInp\fP);
+unsigned nv_isattr(Namval_t *\fInp\fP, unsigned \fIflags\fP);
+unsigned nv_onattr(Namval_t *\fInp\fP, unsigned \fIflags\fP);
+unsigned nv_offattr(Namval_t *\fInp\fP, unsigned \fIflags\fP);
+void nv_newattr(Namval_t *\fInp\fP, unsigned \fIflags\fP, int \fIsize\fP);
+.ft R
+.fi
+
+.SS "ARRAY HANDLING"
+.nf
+.ft 5
+unsigned nv_isarray(Namval_t *\fInp\fP);
+Namarr_t *nv_setarray(Namval_t *\fInp\fP,void*(*\fIfun\fP)(Namval_t*,const char*,int));
+Namval_t *nv_putsub(Namval_t *\fInp\fP, char *\fIname\fP, long \fImode\fP);
+Namval_t *nv_opensub(Namval_t *\fInp\fP);
+void nv_setvec(Namval_t *\fInp\fP, int \fIappend\fP, int \fIargc\fP, char *\fIargv\fP[]);
+char *nv_getsub(Namval_t *\fInp\fP);
+int nv_nextsub(Namval_t *\fInp\fP);
+int nv_aindex(Namval_t *\fInp\fP);
+.ft R
+.fi
+.SS "DISCIPLINES"
+.nf
+.ft 5
+Namfun_t *nv_disc(Namval_t *\fInp\fP, Namfun_t *\fIfp\fP, int \fIflags\fP);
+Namfun_t *nv_hasdisc(Namval_t *\fInp\fP, const Namdisc_t *\fIdp\fP);
+char *nv_getv(Namval_t *\fInp\fP, Namfun_t *\fIfp\fP);
+Sfdouble_t nv_getn(Namval_t *\fInp\fP, Namfun_t *\fIfp\fP);
+void nv_putv(Namval_t *\fInp\fP, const char *\fIval\fP, int \fIflags\fP, Namfun_t *\fIfp\fP);
+char *nv_setdisc(Namval_t *\fInp\fP, const char *\fIa\fP, Namval_t *\fIf\fP, Namfun_t *\fIfp\fP);
+char *nv_adddisc(Namval_t *\fInp\fP, const char **\fInames\fP);
+const Namdisc_t *nv_discfun(int \fIwhich\fP);
+.ft R
+.fi
+.SS "MISCELLANEOUS FUNCTIONS"
+.nf
+.ft 5
+int nv_scan(Dt_t *\fIdict\fP, void(*\fIfn\fP)(Namval_t*,void*), void *\fIdata\fP, int \fImask\fP, int \fIflags\fP);
+Dt_t nv_dict(Namval_t *\fInp\fP);
+void nv_setvtree(Namval_t *\fInp\fP);
+void nv_setref(Namval_t *\fInp\fP, Dt_t *\fIdp\fP, int \fIflags\fP);
+Namval_t *nv_lastdict(void);
+.ft R
+.fi
+.PP
+.SH DESCRIPTION
+.PP
+\fINval\fP is a library of functions for interacting with name-value
+pairs as used in \f5ksh\fP.
+It is built on top the container dictionary type library facility
+in \f5libcdt\fP. (See cdt(3)).
+Each name-value pair is represented by a
+type named \f5Namval_t\fP.
+A \f5Namval_t\fP contains the name, value and
+attributes of a variable.
+Some attributes can have an associated number that
+represents the field width, arithmetic base, or precision.
+Additionally, each name-value pair can be associated with
+one or more processing disciplines that affect
+its behavior.
+.PP
+The function \f5nv_open()\fP returns a pointer to a name-value
+pair corresponding to the given \fIname\fP.
+It can also assign a value and give attributes to a name-value pair.
+The argument \fIdict\fP defines the dictionary to search.
+A \f5NULL\fP value causes the shell global variable dictionary to be searched.
+.PP
+The \fIflags\fP argument consists of the bitwise-or of zero or more
+of the attributes listed later and zero or more of the following:
+.IP
+\f5NV_VARNAME\fP:
+An invalid variable name causes an error.
+.IP
+\f5NV_IDENTIFIER\fP:
+A variable name that is not an identifier causes an error.
+.IP
+\f5NV_ASSIGN\fP:
+The \fIname\fP argument can contain an assignment.
+.IP
+\f5NV_NOARRAY\fP:
+The \fIname\fP argument cannot contain a subscript.
+.IP
+\f5NV_NOREF\fP:
+Do not follow references when finding the name-value pair.
+.IP
+\f5NV_NOADD\fP:
+The name-value pair will not be added if it doesn't exist.
+Instead, a \f5NULL\fP pointer will be returned.
+.IP
+\f5NV_NOSCOPE\fP:
+Only the top level scope is used.
+.IP
+\f5NV_NOFAIL\fP:
+Just return \f5NULL\fP when an error occurs.
+By default an error message is displayed and the current command
+is aborted.
+.IP
+.PP
+If a name-value pair by this name does not already exist, it is
+created unless \fIflags\fP contains the \f5NV_NOADD\fP flag.
+If \f5NV_VARNAME\fP, \f5NV_IDENTIFIER\fP and \f5NV_ASSIGN\fP are
+all not specified, then no validity check is performed on the \fIname\fP
+argument and no further processing is performed.
+Otherwise, if \f5NV_ASSIGN\fP is specified, then the characters up
+to the first \f5=\fP or \f5+=\fP are used to find the name-value pair,
+and the characters after the \f5=\fP are used to define
+the value that will be assigned to this name-value pair.
+If \fIname\fP does not contain an \f5=\fP, than no assignment
+will be made.
+If the first identifier in \fIname\fP is a reference and is not
+preceded by a \fB.\fP,
+it will be replaced by the value of the reference
+to find the name of a variable.
+Unless \fIflags\fP contains the \f5NV_NOREF\fP flag,
+if the name-value pair give by \fIname\fP has the \f5NV_REF\fP
+attribute, it will be replaced by the variable whose name
+is the value of this name-value pair.
+If \f5NV_ASSIGN\fP is set in the \fIflags\fP argument,
+the \fIname\fP variable can contain an \f5=\fP
+and a value that will be assigned to the name-value pair.
+Any attributes appearing in the \fIflags\fP argument
+will be applied to the name-value pair after any value is assigned.
+.PP
+It is possible for an application to create additional dictionaries
+with the cdt library and associate them with name-value pairs.
+The \f5nv_dict()\fP function returns the dictionary associated with
+the specified name-value pair, or if no dictionary was specified,
+\f5NULL\fP is returned.
+The \f5nv_lastdict()\fP function returns a pointer the the
+name-value pair that contains
+the last dictionary searched on the previous \f5nv_open()\fP.
+.PP
+The \f5nv_close()\fP indicates that the pointer returned by
+\f5nv_open()\fP or \f5nv_opensub()\fP will not be referenced again. If the
+name-value pair is unset, and not referenced elsewhere,
+the name-value pair may be freed.
+.PP
+The \f5nv_name()\fP function returns the name of the given name-value
+pair \fInp\fP.
+The \f5nv_setsize()\fP function returns the size of the field for
+justified variables, the arithmetic base for integer variables,
+and the precision or number of places after the decimal point
+for floating point variables. If \fIsize\fP is greater than or
+equal to zero, the current size is changed to this value.
+The \f5nv_size()\fP function is equivalent to \f5nv_setsize()\fP
+with the second argument negative.
+.PP
+The \f5nv_getval()\fP function returns the value of the given
+name-value pair as a string. A \f5NULL\fP return value indicates
+that the name-value pair is unset.
+The \f5nv_getnum()\fP function returns the value of the given
+name-value pair as a double precision number using the \f5Sfio\fP
+library (See Sfio(3)) type \f5Sfdouble_t\fP.
+For name-value pairs without the \f5NV_INTEGER\fP attribute,
+the string value is evaluated as an arithmetic expression to
+arrive at a numerical value.
+.PP
+The \f5nv_putval()\fP function is used to assign a \fIvalue\fP to
+the name-value pair \fInp\fP.
+The \fIflags\fP argument consists zero or more of the bitwise-or
+of \f5NV_LONG\fP, \f5NV_SHORT\fP, \f5NV_DOUBLE\fP, \f5NV_INTEGER\fP,
+\f5NV_RDONLY\fP, \f5NV_REF\fP, \f5NV_BINARY\fP, and \f5NV_NOFREE\fP.
+The presence of \f5NV_RDONLY\fP allows the assignment to occur
+even if the name-value pair has the \f5NV_RDONLY\fP attribute.
+The presence of \f5NV_INTEGER\fP indicates that the \fIvalue\fP
+argument is actually a pointer to a numerical type.
+By default this type is \f5long\fP, but can be modified with
+\f5NV_LONG\fP, \f5NV_SHORT\fP, and \f5NV_DOUBLE\fP
+to represent \f5long long\fP, \f5short\fP, \f5double\fP, \f5long double\fP,
+and \f5float\fP.
+The presence of \f5NV_REF\fP indicates that the \fIvalue\fP
+argument is actually a pointer to a name-value pair
+and \f5np\fP should become a reference to this name-value pair.
+If \f5NV_NOFREE\fP is specified, \fIvalue\fP itself becomes
+the value of the name-value pair \fInp\fP.
+Otherwise, a copy of the value is stored
+as the value for \fInp\fP.
+.PP
+The \f5nv_unset()\fP function clears out the value and attributes
+of the given name-value function but does not free the name-value
+pair.
+.PP
+The following attributes can be associated with a name-value pair:
+.IP
+\f5NV_EXPORT\fP:
+The export attribute.
+.IP
+\f5NV_RDONLY\fP:
+The readonly attribute.
+.IP
+\f5NV_LTOU\fP:
+Lower case characters are converted to upper case characters.
+.IP
+\f5NV_UTOL\fP:
+Upper case characters are converted to lower case characters.
+.IP
+\f5NV_RJUST\fP:
+Right justify and blank fill.
+This attribute has an associated size that defines the
+string length of the value.
+.IP
+\f5NV_LJUST\fP:
+Left justify and blank fill.
+This attribute has an associated size that defines the
+string length of the value.
+.IP
+\f5NV_ZFILL\fP:
+Without \f5NV_LJUST\fP, right justifies and fills with leading zeros.
+With \f5NV_LJUST\fP, left justify and strip leading zeros.
+Left justify and blank fill.
+This attribute has an associated size that defines the
+string length of the value.
+.IP
+\f5NV_TAGGED\fP:
+Indicates the tagged attribute.
+.IP
+\f5NV_INTEGER\fP:
+Causes value to be represented by a number.
+This attribute has an associated number that defines the
+arithmetic base to be used when the value is expanded as a string.
+.IP
+\f5NV_DOUBLE\fP:
+Used in conjunction with \f5NV_INTEGER\fP to cause value
+to be stored as a double precision floating point number.
+This attribute has an associated number that defines the
+number of places after the decimal point to be used when
+the value is expanded as a string.
+.IP
+\f5NV_EXPNOTE\fP:
+Used in conjunction with \f5NV_INTEGER\fP and \f5NV_DOUBLE\fP to
+cause the value to be represented in scientific notation when
+expanded as a string.
+This attribute has an associated number that defines the
+the precision of the mantissa.
+.IP
+\f5NV_BINARY\fP:
+The name-value pair contains a buffer of binary data and \f5nv_size()\fP
+is the number of bytes for this data. By default the value
+will be represented by the base64 encoding of the buffer.
+The \f5NV_LJUST\fP flag may also be specified and causes the buffer
+size to be fixed and data either truncated or filled with \f50\fP bytes.
+.IP
+\f5NV_REF\fP:
+The name-value pair is a name reference variable.
+.IP
+\f5NV_NODISC\fP:
+All discipline functions are ignored when performing assignments
+and lookups.
+.PP
+The \f5nv_isattr()\fP function can test whether or not any of
+the attributes given by \fIflags\fP is set.
+The \f5nv_onattr()\fP and \f5nv_offattr()\fP functions turn attributes
+on or off respectively. Only attributes that do not affect the
+value can be set in this way.
+The \f5nv_newattr()\fP function can be used to change the
+attributes and size of the given name-value pair which may result
+in the value being changed to conform to the new attributes and size.
+The \fIsize\fP argument is needed for attributes that require
+an additional argument such as justifies variables.
+Changing the attribute may require changing the value
+to agree with the new attributes.
+For an array variable, the values for each of the
+subscripts will be changed.
+.PP
+The \f5nv_isarray()\fP function returns a non-zero value if the specified
+name-value pair is an array.
+.PP
+The \f5nv_scan()\fP function is used to walk through
+all name-value pairs in the dictionary given by \fIdict\fP.
+If the \f5flags\fP variable contains the \f5NV_NOSCOPE\fP
+flag, then only the top scope will be examined.
+The remaining flags will be used in conjunction with \fImask\fP
+to further restrict the walk.
+If \fImask\fP is non-zero, only the nodes for which
+\f5nv_isattr(\fP\fInode\fP\f5,\fP\fImask\fP\f5)\fP
+is equal to \fIflags\fP will be visited.
+If \fIfn\fP is non-zero, then this function will be executed
+for each name-value pair in the walk.
+The arguments to \fIfn\fP will be a pointer to the name-value pair
+and the \fIdata\fP pointer passed to \f5nv_scan()\fP.
+The number of elements visited will be returned.
+.PP
+The \f5nv_clone()\fP function is used make a copy of the contents of
+name-value pair \fIsrc\fP to another name-value pair \fIdest\fP.
+.PP
+Disciplines provide a way to
+intercept the lookup and assignment operations,
+to manage the creation of sub-variables,
+and to extend the operations permitted on a name-value pair.
+A discipline consists of a set of one or more functions and related
+data that are used to override and extend the operations
+on a name-value pair.
+A discipline is defined by the types
+\f5Namfun_t\fP and \f5Namdisc_t\fP.
+The \f5Namdisc_t\fP is not modified by any of these functions and
+can therefore be shared by several name-value pairs.
+It contains following public fields in the order listed:
+.nf
+ \f5size_t dsize;\fP
+ \f5void (*putval)(Namval_t*,const char*,int,Namfun_t*);\fP
+ \f5char *(*getval)(Namval_t*,Namfun_t*);\fP
+ \f5double (*getnum)(Namval_t*,Namfun_t*);\fP
+ \f5char *(*setdisc)(Namval_t*,const char*,Namval_t*,Namfun_t*);\fP
+ \f5Namval_t *(*createf)(Namval_t*,const char*,Namfun_t*);\fP
+ \f5Namfun_t *(*clonef)(Namval_t*,Namval_t*,int,Namfun_t*);\fP
+ \f5char *(*namef)(Namval_t*,Namfun_t*);\fP
+ \f5Namval_t *(*nextf)(Namval_t*,Dt_t*,Namfun_t*);\fP
+ \f5Namval_t *(*typef)(Namval_t*,Namfun_t*);\fP
+.fi
+The \f5Namfun_t\fP type contains a member named
+\f5disc\fP which points to a \f5Namdisc_t\fP structure.
+To create a discipline with additional user data,
+define a structure with an instance of \f5Namfun_t\fP
+as the first element.
+An application must initialize the \f5Namfun_t\fP portion of
+the structure to zero and then set the \fIdisc\fP field to point
+to the \f5Namdisc_t\fP structure.
+The \f5dsize\fP field of the \f5Namdisc_t\fP structure must be
+the size of this structure. A value of 0,
+indicates that there are no additional fields and is equivalent
+to \f5sizeof(Namfun_t)\fP.
+If different instances of this structure uses different sizes, then
+the \f5size\fP field in the \f5Namfun_t\fP can must be set to
+this size and overrides the value in the \f5Namdisc_t\fP structure.
+.PP
+When a variable is referenced by calling the \f5nv_getval()\fP function,
+and the \f5NV_NODISC\fP attribute is not set,
+the \f5getval()\fP discipline function is called with a pointer
+to the name-value pair, \fInp\fP, and a pointer to the discipline,
+\fIfp\fP.
+Inside the \f5getval()\fP function, the \f5nv_getv()\fP function
+can be called to get the value of the name-value pair that
+would have resulted if the discipline were not used.
+The \f5getnum()\fP discipline is called whenever a numerical
+value is needed for the name-value pair \fInp\fP
+and the \f5NV_NODISC\fP attribute is not set,
+The \f5nv_getn()\fP function can be called from within
+the \f5getnum()\fP discipline to get the value that would
+have resulted if there were no \f5getnum()\fP discipline.
+.PP
+The \f5putval\fP\f5()\fP discipline function is used to
+override the assignment of values
+to a name-value pair.
+It is called whenever a value is assigned with \f5nv_putval()\fP
+and the \f5NV_NODISC\fP attribute is not set,
+or when a name-value pair is unset with \f5nv_unset()\fP.
+When a name-value pair is unset, \f5putval\fP\f5()\fP
+is called with \fIvalue\fP set to \f5NULL\fP.
+The \f5nv_putv()\fP function is used within the \f5putval()\fP
+to perform the assignment or unset that would have occurred
+if the discipline had not been installed.
+.PP
+The \f5createf()\fP discipline function is called from
+\f5nv_open()\fP or \f5nv_create()\fP when the name-value pair preceding a
+.B \s+2.\s-2
+is found.
+This function is passed the name-value pointer plus the remaining string and
+the current \fIflags\fP argument.
+The \f5createf()\fP discipline function
+must return the created name-value pair, otherwise the default action
+will be taken.
+If the name-value pair that is returned is the same as the
+one given, then the the behavior will be the same as if
+an invalid name had been given to \f5nv_open()\fP.
+The \f5nv_create()\fP function may be called within
+the \f5createf()\fP discipline function
+to perform the action that would have occurred
+by an earlier \f5nv_open()\fP function.
+.PP
+The \f5setdisc()\fP discipline function is used
+to extend the set of available shell level discipline functions
+associated with a name-value pair by allowing
+builtins or functions whose name is of the
+form \fIvarname\fP\f5.\fP\fIaction\fP to be defined.
+By default, each name-value pair can have a \f5get\fP,
+\f5set\fP, and \f5unset\fP discipline associated with it.
+Whenever a builtin or function whose name is of the
+form \fIvarname\fP\f5.\fP\fIaction\fP is defined or is unset,
+and \fIaction\fP is not \f5get\fP,
+\f5set\fP, or \f5unset\fP, the \fIsetdisc\fP\f5()\fP function is invoked
+with the same argument format as \f5nv_setdisc\fP\f5()\fP.
+The argument \fIf\fP points to the name-value pair associated
+with the function being defined, or \f5NULL\fP if the function is
+being unset.
+If the given action \fIa\fP is not known by this discipline,
+it should return the value returned by calling
+\f5nv_setdisc(\fP\fInp\fP\f5,\fP\fIa\fP\f5,\fP\fIf\fP\f5,\fP\fIfp\fP\f5)\fP
+so that it can be searched for in previously stacked disciplines.
+Otherwise, the \fIsetdisc\fP\f5()\fP function should save the function
+name-value pair pointer, and return a non-\f5NULL\fP value.
+The name-value pointer to the function can be used to invoke
+the function at an application defined point.
+If the action \fIa\fP is \f5NULL\fP, then \fIf\fP points to
+an action name instead of a name-value pair pointer.
+The \fIsetdisc\fP\f5()\fP must return the
+name of the action that follows the action name given by
+\fIf\fP. If \fIf\fP is also \f5NULL\fP, the name of the first action
+must be returned.
+This allows an application to get the list of valid discipline
+action names allowed by a given name-value pair.
+.PP
+The \f5nv_adddisc()\fP function is a higher level function that
+adds a \fIsetdisc\fP discipline to the name-value pair that allows
+shell level disciplines to be created for each of the name specified
+in \f5names\fP.
+.PP
+The \f5nv_discfun()\fP function can be used to get a pointer to
+discipline functions that are provided by the library.
+Currently, the only one that is provided is the ones used to
+implement \f5nv_adddisc()\fP which can be returned with an
+argument of \f5NV_DCADD\fP.
+.PP
+The \f5clonef()\fP discipline function is called by \f5nv_clone()\fP
+when making a copy of the \f5Namfun_t\fP discipline to the new node.
+The first argument is the original node, the second argument is
+the new node, and the third argument is the flags that were passed
+down to \f5nv_clone()\fP.
+It must return a new instance of the \f5Namfun_t*\fP \f5fp\fP.
+If omitted, then memory whose size is determinated by the \f5size\fP
+field of \f5fp\fP, if non-zero, or \f5fp->disc\fP, will be allocated
+and copied from \f5fp\fP.
+.PP
+The \f5namef()\fP discipline function returns the name for this name-value pair.
+.PP
+The \f5nextf()\fP is used for walking through the list of sub-variables
+associated with this name-value pair. If the dictionary argument is
+\f5NULL\fP, it must return the first sub-variable. Otherwise,
+it must return the next sub-variable, or \f5NULL\fP if there are
+no more variables.
+.PP
+A discipline is installed or removed with the
+\f5nv_disc()\fP function.
+The following flags can be specified:
+.IP
+\f5NV_FIRST\fP:
+If \fIfp\fP is non-\f5NULL\fP, the discipline is moved to the top
+of the stack or pushed onto the top of the stack of disciplines
+associated with the given name-value
+pair \fInp\fP if not already present.
+Otherwise, the top of the discipline stack is returned.
+.IP
+\f5NV_LAST\fP:
+If \fIfp\fP is non-\f5NULL\fP, the discipline is moved to the bottom
+of the stack or pushed onto the bottom of the stack of disciplines
+associated with the given name-value
+pair \fInp\fP if not already present.
+Otherwise, the bottom of the discipline stack is returned.
+.IP
+\f5NV_POP\fP:
+If \fIfp\fP is non-\f5NULL\fP and it is on the stack,
+it is removed and \fIfp\fP is returned. If \fIfp\fP is non-\f5NULL\fP
+and is not on the stack, \f5NULL\fP is returned.
+Otherwise, the the top discipline is popped
+and returned.
+.IP
+\f5NV_CLONE\fP:
+If \fIfp\fP is non-\f5NULL\fP and it is on the stack,
+it is replace by a copy created by \f5malloc\fP(3).
+The \f5nofree\fP field is set to \f50\fP.
+The new discipline is returned.
+Otherwise, \f5NULL\fP is returned.
+.IP
+\f50\fP:
+If \fIfp\fP is non-\f5NULL\fP then it is equivalent to \f5NV_FIRST\fP.
+Otherwise, it is equivalent to \f5NV_POP\fP.
+.PP
+The
+\f5nv_hasdisc()\fP function can be used to tell whether a discipline
+whose discipline functions are those defined in \fIdp\fP.
+A pointer to this discipline is returned.
+.PP
+The \f5nv_aindex()\fP function returns
+the current index for
+the indexed array given by the name-value pair pointer \fInp\fP.
+The return value is negative if \fInp\fP refers to
+an associative array.
+.PP
+The \f5nv_setarray()\fP function is used to create an associative array
+from a name-value pair node.
+The function \fIfun\fP defines the semantics of the associative
+array.
+Using \fIfun\fP equal to \f5nv_associative()\fP implements the default
+associative array semantics
+that are used with \f5typeset\ -A\fP.
+The function \fIfun\fP will be called with third argument as follows:
+.IP
+\f5NV_AINIT\fP:
+This will be called at initialization.
+The function you supply must return a pointer to a structure
+that contains the type \f5Namarr_t\fP as the first element.
+All other calls receive this value as an argument.
+.IP
+\f5NV_AFREE\fP:
+This will be called after all elements of the name-value pair have been
+deleted and the array is to be freed.
+.IP
+\f5NV_ADELETE\fP:
+The current element should be deleted.
+.IP
+\f5NV_ANEXT\fP:
+This means that the array subscript should be advanced to the
+next subscript. A \f5NULL\fP return indicates that there are
+no more subscripts.
+.IP
+\f5NV_ANAME\fP:
+The name of the current subscript must be returned.
+.IP
+\f5NV_ACURRENT\fP:
+Returns a pointer to a name-value pair corresponding to the
+current subscript, or \f5NULL\fP if this array type doesn't
+create represent each element as a name-value pair.
+.PP
+If \fInp\fP refers to an array,
+the \f5nv_getsub()\fP returns a pointer to
+the name of the current subscript.
+Otherwise, \f5nv_getsub()\fP
+returns \f5NULL\fP.
+.PP
+The \f5nv_opensub()\fP function returns
+a pointer to the name-value pair corresponding
+to the current subscript in an associative array.
+Note that the \f5nv_close()\fP function should be called
+when the pointer is no longer needed.
+.PP
+The \f5nv_putsub()\fP function is used to
+set the subscript for the next reference to \f5np\fP.
+If the \f5name\fP argument is not \f5NULL\fP,
+it defines the value of the next subscript.
+The \f5mode\fP argument can contain one or more of the following flags:
+.IP
+\f5ARRAY_ADD\fP:
+Add the subscript if not found.
+Otherwise, \f5nv_putsub()\fP returns \f5NULL\fP if the
+given subscript is not found.
+.IP
+\f5ARRAY_SCAN\fP:
+Begin a walk through the subscripts starting at the subscript
+given by \f5name\fP. If \f5name\fP is \f5NULL\fP
+the walk is started from the beginning.
+.IP
+\f5ARRAY_UNDEF\fP:
+This causes any current scan to terminate and leaves the
+subscript in an undefined state.
+.PP
+If \f5ARRAY_ADD\fP is not given and the subscript
+does not exist, a \f5NULL\fP value is returned.
+.PP
+The \f5nv_nextsub()\fP function is used to advance to the
+next subscript.
+It returns 0 if there are no more subscripts or if called
+when not in a scan.
+.PP
+The \f5nv_setref()\fP function makes the name-value pair \f5np\fP
+into a reference to the variable whose name is given by
+the value of \f5np\fP. The \f5nv_open()\fP open function is
+called with this name, the dictionary given by \f5dp\fP,
+and the \f5flags\fP argument.
+A \f5NULL\fP value causes the shell global variable dictionary to be searched.
+.PP
+The \f5nv_setvtree()\fP function makes the name-value pair \f5np\fP
+into a tree structured variable so that \f5nv_getval()\fP
+will return a string containing all the names and values of
+children nodes in a format that can be used in
+a shell compound assignment.
+.PP
+.SH SEE ALSO
+cdt(3)
+shell(3)
+.SH AUTHOR
+David G. Korn (dgk@research.att.com).
diff --git a/usr/src/lib/libshell/common/sh.1 b/usr/src/lib/libshell/common/sh.1
new file mode 100644
index 0000000000..61393046b6
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh.1
@@ -0,0 +1,7453 @@
+.\"
+.\" David Korn
+.\" AT&T Bell Laboratories
+.\"
+.\" @(#)sh.1 (dgk@research.att.com) 12/28/93
+.\"
+.nr Z 1 \" set to 1 when command name is ksh, 2 for ksh93
+.ds OK [\|
+.ds CK \|]
+.ds ' \s+4\v@.3m@\'\v@-.3m@\s-4
+.ds ` \s+4\v@.3m@\`\v@-.3m@\s-4
+.if \nZ=0 \{\
+.TH SH 1
+.\}
+.if \nZ=1 \{\
+.TH KSH 1 "User Environment Utilities" "RDS Standard"
+.\}
+.if \nZ=2 \{\
+.TH KSH93 1
+.\}
+.SH NAME
+.if \nZ=0 \{\
+sh, rsh, pfsh \- shell, the
+.\}
+.if \nZ=1 \{\
+.\}
+ksh, rksh, pfksh \- KornShell, a
+.if \nZ=2 \{\
+ksh93, rksh93, pfksh93 \- KornShell, a
+.\}
+standard/restricted command and programming language
+.SH SYNOPSIS
+.if \nZ=0 \{\
+.B sh
+.if \nZ=1 \{\
+.\}
+.B ksh
+.\}
+.if \nZ=2 \{\
+.B ksh93
+.\}
+[
+.B \(+-abcefhikmnoprstuvxBCDP
+] [
+.B \-R
+file ] [
+.B \(+-o
+option ] .\|.\|. [
+.B \-
+] [ arg .\|.\|. ]
+.br
+.if \nZ=0 \{\
+.B rsh
+.\}
+.if \nZ=1 \{\
+.B rksh
+.\}
+.if \nZ=2 \{\
+.B rksh93
+.\}
+[
+.B \(+-abcefhikmnoprstuvxBCD
+] [
+.B \-R
+file ] [
+.B \(+-o
+option ] .\|.\|. [
+.B \-
+] [ arg .\|.\|. ]
+.SH DESCRIPTION
+.if \nZ=0 .I Sh\^
+.if \nZ=1 .I Ksh\^
+.if \nZ=2 .I Ksh93\^
+is a command and programming language
+that executes commands read from a terminal
+or a file.
+.if \nZ=0 .I Rsh\^
+.if \nZ=1 .I Rksh\^
+.if \nZ=2 .I Rksh93\^
+is a restricted version of the
+.if \nZ=0 standard
+command interpreter
+.if \nZ=0 .IR sh ;
+.if \nZ=1 .IR ksh ;
+.if \nZ=2 .IR ksh93 ;
+it is used to set up login names and execution environments whose
+capabilities are more controlled than those of the standard shell.
+.if \nZ=0 .I Rpfsh\^
+.if \nZ=1 .I Rpfksh\^
+.if \nZ=2 .I Rpfksh93\^
+is a profile shell version of the
+.if \nZ=0 standard
+command interpreter
+.if \nZ=0 .IR sh ;
+.if \nZ=1 .IR ksh ;
+.if \nZ=2 .IR ksh93 ;
+it is used to to execute commands with the attributes specified by
+the user's profiles (see
+.IR pfexec (1)).
+See
+.I Invocation\^
+below
+for the meaning of arguments to the shell.
+.SS Definitions.
+A
+.I metacharacter\^
+is one of the following characters:
+.PP
+.RS
+\f3; & ( ) \(bv < > new-line space tab\fP
+.RE
+.PP
+A
+.I blank\^
+is a
+.B tab
+or a
+.BR space .
+An
+.I identifier\^
+is a sequence of letters, digits, or underscores
+starting with a letter or underscore.
+Identifiers are used as components of
+.I variable\^
+names.
+A
+.I vname\^
+is a sequence of one or more identifiers
+separated by a \fB\s+2.\s-2\fP and optionally preceded
+by a \fB\s+2.\s-2\fP.
+Vnames are used as function and variable names.
+A
+.I word\^
+is a sequence of
+.I characters\^
+from the character set defined by the current locale,
+excluding non-quoted
+.IR metacharacters .
+.PP
+A
+.I command\^
+is a sequence of characters in the syntax
+of the shell language.
+The shell reads each command and
+carries out the desired action either directly or by invoking
+separate utilities.
+A built-in command is a command that is carried out by the
+shell itself without creating a separate process.
+Some commands are built-in purely for convenience
+and are not documented here.
+Built-ins that cause
+side effects in the shell environment and
+built-ins that are found before performing a
+path search (see
+.I Execution\^
+below)
+are documented here.
+For historical reasons, some of
+these built-ins behave differently than
+other built-ins and are called
+.IR "special built-ins" .
+.SS Commands.
+A
+.I simple-command\^
+is a list of variable assignments
+(see
+.I Variable Assignments\^
+below)
+or a sequence of
+.I blank\^
+separated words
+which may be preceded by a list of variable assignments
+(see
+.I Environment\^
+below).
+The first word specifies the name of the command to
+be executed.
+Except as specified below,
+the remaining words are passed as arguments
+to the invoked command.
+The command name is passed as argument 0
+(see
+.IR exec (2)).
+The
+.I value\^
+of a simple-command is its exit status; 0-255
+if it terminates normally; 256+\f2signum\^\fP if
+it terminates abnormally (the name of the signal corresponding
+to the exit status can be
+obtained via the
+.B \-l
+option of the
+.B kill\^
+built-in utility).
+.PP
+A
+.I pipeline\^
+is a sequence of one or more
+.I commands\^
+separated by
+.BR \(bv .
+The standard output of each command but the last
+is connected by a
+.IR pipe (2)
+to the standard input of the next command.
+Each command,
+except possibly the last,
+is run as a separate process;
+the shell waits for the last command to terminate.
+The exit status of a pipeline is the exit
+status of the last command unless the
+.B pipefail
+option is enabled.
+Each pipeline can be preceded by the
+.I "reserved word"
+.B !
+which causes the exit status of the pipeline to become
+0 if the exit status of the last command is non-zero, and
+1 if the exit status of the last command is 0.
+.PP
+A
+.I list\^
+is a sequence of one or more
+pipelines
+separated by
+.BR ; ,
+.BR & ,
+.BR \(bv& ,
+.BR && ,
+or
+.BR \(bv\|\(bv ,
+and optionally terminated by
+.BR ; ,
+.BR & ,
+or
+.BR \(bv& .
+Of these five symbols,
+.BR ; ,
+.BR & ,
+and
+.B \(bv&
+have equal precedence,
+which is lower than that of
+.B &&
+and
+.BR \(bv\|\(bv .
+The symbols
+.B &&
+and
+.B \(bv\|\(bv
+also have equal precedence.
+A semicolon
+.RB ( ; )
+causes sequential execution of the preceding pipeline; an ampersand
+.RB ( & )
+causes asynchronous execution of the preceding pipeline (i.e., the shell does
+.I not\^
+wait for that pipeline to finish).
+The symbol
+.B \(bv&
+causes asynchronous execution of the preceding pipeline
+with a two-way pipe established to the parent shell;
+the standard input and output of the spawned pipeline
+can be written to and read from by the parent shell
+by applying
+the redirection operators
+.B <&
+and
+.B >&
+with arg
+.B p
+to commands and by using
+.B \-p
+option of
+the built-in commands
+.B read
+and
+.B print
+described later.
+The symbol
+.B &&
+.RB (\| \(bv\|\(bv \^)
+causes the
+.I list\^
+following it to be executed only if the preceding
+pipeline
+returns a zero (non-zero) value.
+One or more new-lines may appear in a
+.I list\^
+instead of a semicolon,
+to delimit a command.
+The first
+.I item \^
+of the first
+.I pipeline\^
+of a
+.I list\^
+that is a simple command not beginning
+with a redirection, and not occuring within a
+.BR while ,
+.BR until ,
+or
+.B if
+.IR list ,
+can be prededed by a semicolon.
+This semicolon
+is ignored unless the
+.B showme
+option is enabled as described with
+the
+.B set
+built-in below.
+.PP
+A
+.I command\^
+is either a simple-command
+or one of the following.
+Unless otherwise stated,
+the value returned by a command is that of the
+last simple-command executed in the command.
+.TP
+\f3for\fP \f2vname\^\fP \*(OK \f3in\fP \f2word\^\fP .\|.\|. \*(CK \f3;do\fP \f2list\^\fP \f3;done\fP
+Each time a
+.B for
+command is executed,
+.I vname\^
+is set to the next
+.I word\^
+taken from the
+.B in
+.I word\^
+list.
+If
+.BI in " word\^"
+\&.\|.\|.
+is omitted, then
+the
+.B for
+command executes the \f3do\fP \f2list\^\fP once for each positional parameter
+that is set starting from
+.B 1
+(see
+.I "Parameter Expansion\^"
+below).
+Execution ends when there are no more words in the list.
+.TP
+\f3for ((\fP \*(OK\f2expr1\^\fP\*(CK \f3;\fP \*(OK\f2expr2\^\fP\*(CK \f3;\fP \*(OK\f2expr3\^\fP\*(CK \f3))\fP \f3;do\fP \f2list\^\fP \f3;done\fP
+The arithmetic expression
+.I expr1
+is evaluated first
+(see
+.I "Arithmetic evaluation"
+below).
+The arithmetic expression
+.I expr2
+is repeatedly evaluated until it evaluates to zero and when non-zero,
+.I list
+is executed and the arithmetic expression
+.I expr3
+evaluated.
+If any expression
+is omitted, then it behaves as if it evaluated to 1.
+.TP
+\f3select\fP \f2vname\^\fP \*(OK \f3in\fP \f2word\^\fP .\|.\|. \*(CK \f3;do\fP \f2list\^\fP \f3;done\fP
+A
+.B select
+command prints on standard error (file descriptor 2) the set of
+.IR word s,
+each preceded by a number.
+If
+.BI in " word\^"
+\&.\|.\|.
+is omitted, then
+the
+positional parameters starting from
+.B 1
+are used instead
+(see
+.I "Parameter Expansion\^"
+below).
+The
+.SM
+.B PS3
+prompt is printed
+and a line is read from the standard input.
+If this line consists of the number
+of one of the listed
+.IR word s,
+then the value of the variable
+.I vname\^
+is set to the
+.I word\^
+corresponding to this number.
+If this line is empty, the selection list is
+printed again.
+Otherwise the value of the variable
+.I vname\^
+is set to
+.IR null .
+The contents of the line read from standard input is
+saved in
+the variable
+.SM
+.BR REPLY .
+The
+.I list\^
+is executed for each selection until a
+.B break\^
+or
+.I end-of-file\^
+is encountered.
+If the
+.SM
+.B REPLY
+variable is set to
+.I null\^
+by the execution of
+.IR list ,
+then the selection list is printed before
+displaying the
+.SM
+.B PS3
+prompt for the next selection.
+.TP
+\f3case\fP \f2word\^\fP \f3in\fP \*(OK \*(OK\f3(\fP\*(CK\f2pattern\^\fP \*(OK \(bv \f2pattern\^\fP \*(CK .\|.\|. \f3)\fP \f2list\^\fP \f3;;\fP \*(CK .\|.\|. \f3esac\fP
+A
+.B case
+command executes the
+.I list\^
+associated with the first
+.I pattern\^
+that matches
+.IR word .
+The form of the patterns is
+the same as that used for
+file-name generation (see
+.I "File Name Generation\^"
+below).
+The
+.B ;;
+operator causes execution of
+.B case
+to terminate.
+If
+.B ;&
+is used in place of
+.B ;;
+the next subsequent list, if any, is executed.
+.TP
+\f3if\fP \f2list\^\fP \f3;then\fP \f2list\^\fP \*(OK \
+\f3;elif\fP \f2list\^\fP \f3;then\fP \f2list\^\fP \*(CK .\|.\|. \
+\*(OK \f3;else\fP \f2list\^\fP \*(CK \f3;f\&i\fP
+The
+.I list\^
+following \f3if\fP is executed and,
+if it
+returns a zero exit status, the
+.I list\^
+following
+the first
+.B then
+is executed.
+Otherwise, the
+.I list\^
+following \f3elif\fP
+is executed and, if its value is zero,
+the
+.I list\^
+following
+the next
+.B then
+is executed.
+Failing each successive
+.B elif
+.IR list\^ ,
+the
+.B else
+.I list\^
+is executed.
+If the
+.B if
+.I list\^
+has non-zero exit status
+and there is no
+.B else
+.IR list ,
+then the
+.B if
+command returns a zero exit status.
+.TP
+.PD 0
+\f3while\fP \f2list\^\fP \f3;do\fP \f2list\^\fP \f3;done\fP
+.TP
+\f3until\fP \f2list\^\fP \f3;do\fP \f2list\^\fP \f3;done\fP
+.PD
+A
+.B while
+command repeatedly executes the
+.B while
+.I list\^
+and, if the exit status of the last command in the list is zero, executes
+the
+.B do
+.IR list ;
+otherwise the loop terminates.
+If no commands in the
+.B do
+.I list\^
+are executed, then the
+.B while
+command returns a zero exit status;
+.B until
+may be used in place of
+.B while
+to negate
+the loop termination test.
+.TP
+\f3((\fP\f2expression\^\fP\f3))\fP
+.br
+The
+.I expression\^
+is evaluated using the rules for arithmetic evaluation described below.
+If the value of the arithmetic expression is non-zero, the exit
+status is 0, otherwise the exit status is 1.
+.TP
+\f3(\fP\f2list\^\fP\f3)\fP
+.br
+Execute
+.I list\^
+in a separate environment.
+Note, that if two adjacent open parentheses are
+needed for nesting, a space must be inserted to avoid
+evaluation as an arithmetic command as described above.
+.TP
+\f3{ \fP\f2list\^\fP\f3;}\fP
+.br
+.I list\^
+is simply executed.
+Note that unlike the metacharacters
+.B (
+and
+.BR ) ,
+.B {
+and
+.B }
+are
+.IR "reserved word" s
+and must occur
+at the beginning of a line or after a
+.B ;
+in order to be recognized.
+.TP
+\f3[[\fP\f2 expression \^\fP\f3]]\fP
+.br
+Evaluates
+.I expression\^
+and returns a zero exit status when
+.I expression\^
+is true.
+See
+.I "Conditional Expressions\^"
+below, for a description of
+.IR expression .
+.TP
+.PD 0
+\f3function\fP \f2varname\^\fP \f3{\fP \f2list\^\fP \f3;}\fP
+.TP
+\f2varname\^\fP \f3() {\fP \f2list\^\fP \f3;}\fP
+.PD
+Define a function which is referenced by
+.IR varname .
+A function whose
+.I varname\^
+contains a
+.B \s+2.\s-2
+is called a discipline function and the portion
+of the
+.I varname\^
+preceding the last
+.B \s+2.\s-2
+must refer to an existing variable.
+The body of the function is the
+.I list\^
+of commands between
+.B {
+and
+.BR } .
+A function defined with the \f3function\fP \f2varname\^\fP
+syntax can also be used as an argument to the \f3.\fP
+special built-in command to get the equivalent behavior
+as if the \f2varname\^\fP\f3()\fP syntax were used to define it.
+(See
+.I Functions\^
+below.)
+.TP
+\f3time\fP \*(OK \f2pipeline\^\fP \*(CK
+.br
+If \f2pipeline\^\fP is omitted the user and system time for
+the current shell and completed child processes is printed
+on standard error.
+Otherwise,
+.I pipeline\^
+is executed and the elapsed time as well as
+the user and system time are printed on standard error.
+The
+.SM
+.B TIMEFORMAT
+variable may be set to a format string that specifies how the timing
+information should be displayed.
+See
+.B "Shell Variables"
+below
+for a description of the
+.SM
+.B TIMEFORMAT
+variable.
+.PP
+The following reserved words
+are recognized as reserved only when they are the first word of a command
+and are not quoted:
+.PP
+.if t .RS
+.B
+.if n if then else elif fi case esac for while until do done { } function select time [[ ]] !
+.if t if then else elif fi case esac for while until do done { } function select time [[ ]] !
+.if t .RE
+.SS Variable Assignments.
+One or more variable assignments can start a simple command
+or can be arguments to the
+.BR typeset ,
+.BR export ,
+or
+.B readonly
+special built-in commands.
+The syntax for an \f2assignment\^\fP is of the form:
+.TP
+.PD 0
+\f2varname\^\fP\f3=\fP\f2word\^\fP
+.TP
+\f2varname\^\fP\f3[\fP\f2word\^\fP\f3]\fP=\fP\f2word\^\fP
+.PD
+No space is permitted between \f2varname\^\fP and the \f3=\fP or
+between \f3=\fP and \fIword\^\fP.
+.TP
+\f2varname\^\fP\f3=(\fP\f2assign_list\^\fP\f3)\fP
+No space is permitted between \f2varname\^\fP and the \f3=\fP.
+An \f2assign_list\^\fP can be one of the following:
+.RS 15
+.PD 0
+.TP
+\f2word\^\fP ...
+Indexed array assignment.
+.TP
+\f3[\fP\f2word\^\fP\f3]=\fP\f2word\^\fP .\|.\|.
+Associative array assignment.
+If preceded by
+.B typeset \-a
+this will create an indexed array instead.
+.TP
+\f2assignment\^\fP .\|.\|.
+Compound variable assignment.
+This creates a compound variable \f2varname\^\fP with
+sub-variables of the form \f2varname\^\fP\f3.\fP\f2name\^\fP,
+where \f2name\^\fP is the name portion of \f2assignment\^\fP.
+The value of \f2varname\^\fP will contain all the assignment elements.
+Additional assignments made to sub-variables of \f2varname\^\fP
+will also be displayed as part of the value of \f2varname\^\fP.
+If no \f2assignment\fPs are specified, \f2varname\^\fP will be
+a compound variable allowing subsequence child elements to be defined.
+.TP
+\f3typeset\fP \*(OK\f2options\fP\*(CK \f2assignment\^\fP .\|.\|.
+Nested variable assignment. Multiple assignments
+can be specified by separating each of them with a \f3;\fP.
+The previous value is unset before the assignment.
+.PD
+.RE
+.P
+In addition, a \f3+=\fP can be used in place of the \f3=\fP
+to signify adding to or appending to the previous value.
+When \f3+=\fP is applied to an arithmetic type, \f2word\^\fP
+is evaluated as an arithmetic expression and added to the current value.
+When applied to a string variable, the value defined by \f2word\^\fP
+is appended to the value. For compound assignments, the previous
+value is not unset and the new values are appended to the
+current ones provided that the types are compatible.
+.SS Comments.
+.PD 0
+A word beginning with
+.B #
+causes that word and all the following characters up to a new-line
+to be ignored.
+.SS Aliasing.
+The first word of each command is replaced by the text of an
+.B alias
+if an
+.B alias
+for this word has been defined.
+An
+.B alias
+name consists of any number of characters excluding metacharacters,
+quoting characters,
+file expansion characters,
+parameter expansion and command substitution
+characters,
+and
+.BR = .
+The replacement string can contain any
+valid shell script
+including the metacharacters listed above.
+The first word of each command in the
+replaced text,
+other than
+any that are in the process of being replaced,
+will be tested for aliases.
+If the last character of the alias value is a
+.I blank\^
+then the word following the alias will also be checked for alias
+substitution.
+Aliases can be used to redefine
+built-in commands but cannot be used to redefine
+the reserved words listed above.
+Aliases can be created and listed with the
+.B alias
+command and can be removed with the
+.B unalias
+command.
+.PP
+.I Aliasing\^
+is performed when
+scripts are read,
+not while they are executed.
+Therefore,
+for an alias to take effect,
+the
+.B
+alias
+definition command has to be executed before
+the command which references the alias is read.
+.PP
+The following aliases
+are compiled into the shell
+but can be unset or redefined:
+.RS 20
+.PD 0
+.TP
+.B "autoload=\(fmtypeset \-fu\(fm"
+.TP
+.B "command=\(fmcommand \(fm"
+.TP
+.B "fc=hist"
+.TP
+.B "float=\(fmtypeset \-lE\(fm"
+.TP
+.B "functions=\(fmtypeset \-f\(fm"
+.TP
+.B "hash=\(fmalias \-t \-\^\-\(fm"
+.TP
+.B "history=\(fmhist \-l\(fm"
+.TP
+.B "integer=\(fmtypeset \-li\(fm"
+.TP
+.B "nameref=\(fmtypeset \-n\(fm"
+.TP
+.B "nohup=\(fmnohup \(fm"
+.TP
+.B "r=\(fmhist \-s\(fm"
+.TP
+.B "redirect=\(fmcommand exec\(fm"
+.TP
+.B "source=\(fmcommand \s+2.\s-2\(fm"
+.TP
+.B "stop=\(fmkill \-s \s-1STOP\s+1\(fm"
+.TP
+.B "suspend=\(fmkill \-s \s-1STOP\s+1 $$\(fm"
+.TP
+.B "times=\(fm{ { time;} 2>&1;}\(fm"
+.TP
+.B "type=\(fmwhence \-v\(fm"
+.PD
+.RE
+.SS Tilde Substitution.
+After alias substitution is performed, each word
+is checked to see if it begins with an unquoted
+.BR \(ap .
+For tilde substitution,
+.I word\^
+also refers to the
+.I word\^
+portion of parameter expansion
+(see
+.I "Parameter Expansion\^"
+below).
+If it does, then the word up to a
+.B /
+is checked to see if it matches a user name in the
+password database (See
+.IR getpwname (3).)
+If a match is found, the
+.B \(ap
+and the matched login name are replaced by the
+login directory of the matched user.
+If no match is found, the original text is left unchanged.
+A
+.B \(ap
+by itself, or in front of a
+.BR / ,
+is replaced by
+.SM
+.BR $HOME .
+A
+.B \(ap
+followed by a
+.B +
+or
+.B \-
+is replaced by the value of
+.B
+.SM $PWD
+and
+.B
+.SM $OLDPWD
+respectively.
+.PP
+In addition,
+when expanding a
+.IR "variable assignment" ,
+.I tilde
+substitution is attempted when
+the value of the assignment
+begins with a
+.BR \(ap ,
+and when a
+.B \(ap
+appears after a
+.BR : .
+The
+.B :
+also terminates a
+.B \(ap
+login name.
+.SS Command Substitution.
+The standard output from a command enclosed in
+parentheses preceded by a dollar sign (
+.B $(\|)
+)
+or a pair of grave accents (\^\f3\*`\^\*`\fP\^)
+may be used as part or all
+of a word;
+trailing new-lines are removed.
+In the second (obsolete) form, the string between the quotes is processed
+for special quoting characters before the command is executed (see
+.I Quoting\^
+below).
+The command substitution
+\^\f3$(\^cat file\^)\fP\^
+can be replaced by the equivalent but faster
+\^\f3$(\^<file\^)\fP\^.
+The command substitution
+\^\f3$(\^\fP\f2n\^\fP\f3<#\^)\fP
+will expand to the current byte offset for file descriptor
+.IR n .
+.SS Arithmetic Substitution.
+An arithmetic expression enclosed in double
+parentheses preceded by a dollar sign (
+.B $((\|))
+)
+is replaced by the value of the arithmetic expression
+within the double parentheses.
+.SS Process Substitution.
+This feature is only available on
+versions of the UNIX operating system that support the
+.B /dev/fd
+directory for naming open files.
+Each command argument of the form
+\f3<(\fP\f2list\^\fP\f3)\fP
+or
+\f3>(\fP\f2list\^\fP\f3)\fP
+will run process
+.I list
+asynchronously connected to some file in
+.BR /dev/fd .
+The name of this file will become the argument to the command.
+If the form with
+.B >
+is selected then writing on this file will provide input for
+.IR list .
+If
+.B <
+is used,
+then the file passed as an argument will contain the output of the
+.I list
+process.
+For example,
+.PP
+.RS
+\f3paste <(cut \-f1\fP \f2file1\fP\f3) <(cut \-f3\fP \f2file2\f3) | tee >(\fP\f2process1\fP\f3) >(\fP\f2process2\fP\f3)\fP
+.RE
+.PP
+.I cuts
+fields 1 and 3 from
+the files
+.I file1
+and
+.I file2
+respectively,
+.I pastes
+the results together, and
+sends it
+to the processes
+.I process1
+and
+.IR process2 ,
+as well as putting it onto the standard output.
+Note that the file, which is passed as an argument to the command,
+is a UNIX
+.IR pipe (2)
+so programs that expect to
+.IR lseek (2)
+on the file will not work.
+.SS Parameter Expansion.
+A
+.I parameter\^
+is a
+.IR variable ,
+one or more digits,
+or any of the characters
+.BR \(** ,
+.BR @ ,
+.BR # ,
+.BR ? ,
+.BR \- ,
+.BR $ ,
+and
+.BR !\\^ .
+A
+.I variable\^
+is denoted by a \f2vname\fP.
+To create a variable whose
+.I vname\^
+contains a \f3\s+2.\s-2\fP,
+a variable whose
+.I vname\^
+consists of everything before the last \f3\s+2.\s-2\fP must already exist.
+A
+.I variable\^
+has a
+.I value\^
+and zero or more
+.IR attributes .
+.I Variables\^
+can be assigned
+.I values\^
+and
+.I attributes
+by using the
+.B typeset\^
+special built-in command.
+The attributes supported by the shell are described
+later with the
+.B typeset\^
+special built-in command.
+Exported variables pass values and attributes to
+the environment.
+.PP
+The shell supports both indexed and associative arrays.
+An element of an array variable is referenced by a
+.IR subscript .
+A
+.I subscript\^
+for an indexed array is denoted by
+an
+.I arithmetic expression\^
+(see
+.I "Arithmetic evaluation"
+below)
+between a
+.B [
+and a
+.BR ] .
+To assign values to an indexed array, use
+\f3set \-A\fP \f2vname\fP \f2value\fP .\|.\|. .
+The value of all
+subscripts must be in the
+range of
+0 through 1,048,575.
+Indexed arrays need not be declared.
+Any reference to a variable
+with a valid subscript is
+legal and an array will be created if necessary.
+.PP
+An associative array is created with the
+.B \-A
+option to
+.BR typeset.
+A
+.I subscript\^
+for an associative array is denoted by
+a string enclosed between
+.B [
+and
+.BR ] .
+.PP
+Referencing any array without a subscript
+is equivalent to referencing the array with subscript 0.
+.PP
+The
+.I value\^
+of a
+.I variable\^
+may be assigned by writing:
+.PP
+.RS
+.IB vname = value\^\|
+\*(OK
+.IB vname = value\^
+\*(CK .\|.\|.
+.RE
+.PP
+.PD 0
+or
+.PP
+.RS
+.IB vname [ subscript ]= value\^\|
+\*(OK
+.IB vname [ subscript ]= value\^
+\*(CK .\|.\|.
+.sp .5
+.RE
+Note that no space is allowed before or after the
+.BR = .
+.sp .5
+.PP
+.PD 0
+A
+.I nameref\^
+is a variable that is a reference to another variable.
+A nameref is created with the
+.B \-n
+attribute of
+.BR typeset .
+The value of the variable at the time of the
+.B typeset
+command becomes the variable that will be referenced whenever
+the nameref variable is used.
+The name of a nameref cannot contain a \fB\s+2.\s-2\fP.
+When a variable or function name contains a \fB\s+2.\s-2\fP, and the portion
+of the name up to the first \fB\s+2.\s-2\fP matches the
+name of a nameref, the variable referred to is obtained by
+replacing the nameref portion with the name of the variable
+referenced by the nameref.
+If a nameref is used as the index of a \fBfor\fP loop,
+a name reference is established for each item in the list.
+A nameref provides a convenient way to refer to the variable
+inside a function whose name is passed as an argument to a function.
+For example, if the name of a variable is passed as the first
+argument to a function, the command
+.PP
+.RS
+\fBtypeset \-n var=$1\fR
+.RE
+.PP
+inside the function causes references and assignments to
+.B var
+to be references and assignments to the variable whose
+name has been passed to the function.
+.sp .5
+.PP
+If either of the floating point attributes,
+.BR \-E ,
+or
+.BR \-F ,
+or the integer attribute,
+.BR \-i ,
+is set for
+.IR vname ,
+then the
+.I value\^
+is subject to arithmetic evaluation as described below.
+.sp .5
+.PP
+Positional parameters,
+parameters denoted by a number,
+may be assigned values with the
+.B set\^
+special built-in command.
+Parameter
+.B $0
+is set from argument zero when the shell
+is invoked.
+.sp .5
+.PP
+The character
+.B $
+is used to introduce substitutable
+.IR parameters .
+.TP
+\f3${\fP\f2parameter\^\fP\f3}\fP
+The shell
+reads all the characters from
+.B ${
+to the matching
+.B }
+as part of the same word even if it contains
+braces or metacharacters.
+The value, if any, of the parameter is substituted.
+The braces are required when
+.I parameter\^
+is followed by a letter, digit, or underscore
+that is not to be interpreted as part of its name,
+when the variable name contains a \fB\s+2.\s-2\fP,
+or when a variable is subscripted.
+If
+.I parameter\^
+is one or more digits then it is a positional parameter.
+A positional parameter of more than one digit must be
+enclosed in braces.
+If
+.I parameter\^
+is
+.B \(**
+or
+.BR @ ,
+then all the positional
+parameters, starting with
+.BR $1 ,
+are substituted
+(separated by a field separator character).
+If an array
+.I vname\^
+with subscript
+.B \(**
+or
+.B @
+is used,
+then the value
+for each of the
+elements
+is substituted,
+separated by
+the first character of
+the value of
+.SM
+.BR IFS .
+.TP
+\f3${#\fP\f2parameter\^\fP\f3}\fP
+If
+.I parameter\^
+is
+.B \(**
+or
+.BR @ ,
+the number of positional parameters is substituted.
+Otherwise, the length of the value of the
+.I parameter\^
+is substituted.
+.TP
+.PD 0
+\f3${#\fP\f2vname\fP\f3[*]}\fP
+.TP
+.PD
+\f3${#\fP\f2vname\fP\f3[@]}\fP
+The number of elements in the array
+.I vname\^
+is substituted.
+.TP
+\f3${!\fP\f2vname\^\fP\f3}\fP
+Expands to the name of the variable referred to by
+.IR vname .
+This will be
+.I vname\^
+except when
+.I vname\^
+is a name reference.
+.TP
+\f3${!\fP\f2vname\^\fP\f3[\f2subscript\^\f3]}\fP
+Expands to name of the subscript unless
+.I subscript\^
+is
+.B *
+or
+.BR @ .
+When
+.I subscript\^
+is
+.BR * ,
+the list of array subscripts for \f2vname\^\fP
+is generated.
+For a variable that is not an array, the value is 0 if the variable
+is set. Otherwise it is null.
+When
+.I subscript\^
+is
+.BR @ ,
+same as above, except that when used in double quotes,
+each array subscript yields a separate
+argument.
+.TP
+\f3${!\fP\f2prefix\^\fP\f3*}\fP
+Expands to the names of the variables whose names begin with
+.IR prefix .
+.TP
+\f3${\fP\f2parameter\^\fP\f3:\-\fP\f2word\^\fP\f3}\fP
+If
+.I parameter\^
+is set and is non-null then substitute its value;
+otherwise substitute
+.IR word .
+.TP
+\f3${\fP\f2parameter\^\fP\f3:=\fP\f2word\^\fP\f3}\fP
+If
+.I parameter\^
+is not set or is null then set it to
+.IR word ;
+the value of the parameter is then substituted.
+Positional parameters may not be assigned to
+in this way.
+.TP
+\f3${\fP\f2parameter\^\fP\f3:?\fP\f2word\^\fP\f3}\fP
+If
+.I parameter\^
+is set and is non-null then substitute its value;
+otherwise, print
+.I word\^
+and exit from the shell (if not interactive).
+If
+.I word\^
+is omitted then a standard message is printed.
+.TP
+\f3${\fP\f2parameter\^\fP\f3:+\fP\f2word\^\fP\f3}\fP
+If
+.I parameter\^
+is set and is non-null then substitute
+.IR word ;
+otherwise substitute nothing.
+.PP
+In the above,
+.I word\^
+is not evaluated unless it is
+to be used as the substituted string,
+so that, in the following example,
+.B pwd
+is executed only if
+.B d
+is not set or is null:
+.PP
+.RS
+print \|${d:\-\^$(\^pwd\^)\^}
+.RE
+.PP
+If the colon (
+.B : )
+is omitted from the above expressions,
+then the shell only checks whether
+.I parameter\^
+is set or not.
+.TP
+.PD 0
+\f3${\fP\f2parameter\^\fP\f3:\fP\f2offset\^\fP\f3:\fP\f2length\^\fP\f3}\fP
+.TP
+\f3${\fP\f2parameter\^\fP\f3:\fP\f2offset\^\fP\f3}\fP
+Expands to the portion of the value of
+.I parameter\^
+starting at the character (counting from
+.BR 0\^ )
+determined by expanding
+.I offset\^
+as an arithmetic expression and consisting of the
+number of characters determined by the arithmetic expression
+defined by
+.IR length.
+In the second form, the remainder of the value is used.
+If
+A negative
+.I offset\^
+counts backwards from the end of
+.IR parameter .
+Note that one or more
+.IR blank s
+is required in front of a minus sign
+to prevent the shell from interpreting the operator as
+.BR :\- .
+If
+.I parameter\^
+is
+.B \(**
+or
+.BR @ ,
+or is an array name indexed by
+.B \(**
+or
+.BR @ ,
+then
+.I offset\^
+and
+.I length\^
+refer to the array index and number
+of elements respectively.
+A negative
+.I offset\^
+is taken relative to one greater than the highest subscript
+for indexed arrays.
+The order for associate arrays is unspecified.
+.TP
+.PD 0
+\f3${\fP\f2parameter\^\fP\f3#\fP\f2pattern\^\fP\f3}\fP
+.TP
+\f3${\fP\f2parameter\^\fP\f3##\fP\f2pattern\^\fP\f3}\fP
+.PD
+If
+the shell
+.I pattern\^
+matches the beginning of the value of
+.IR parameter ,
+then the value of
+this expansion is the value of the
+.I parameter\^
+with the matched portion deleted;
+otherwise the value of this
+.I parameter\^
+is substituted.
+In the first form the smallest matching pattern is deleted and in the
+second form the largest matching pattern is deleted.
+When
+.I parameter\^
+is
+.BR @ ,
+.BR * ,
+or an array variable with subscript
+.B @
+or
+.BR * ,
+the substring operation is applied to each element in turn.
+.TP
+.PD 0
+\f3${\fP\f2parameter\^\fP\f3%\fP\f2pattern\^\fP\f3}\fP
+.TP
+\f3${\fP\f2parameter\^\fP\f3%%\fP\f2pattern\^\fP\f3}\fP
+.PD
+If
+the shell
+.I pattern\^
+matches the end of the value of
+.IR parameter ,
+then the value of
+this expansion is the value of the
+.I parameter\^
+with the matched part deleted;
+otherwise substitute the value of
+.IR parameter .
+In the first form the smallest matching pattern is deleted and in the
+second form the largest matching pattern is deleted.
+When
+.I parameter\^
+is
+.BR @ ,
+.BR * ,
+or an array variable with subscript
+.B @
+or
+.BR * ,
+the substring operation is applied to each element in turn.
+.TP
+.PD 0
+\f3${\fP\f2parameter\^\fP\f3/\fP\f2pattern\^\fP\f3/\f2string\^\fP\f3}\fP
+.TP
+\f3${\fP\f2parameter\^\fP\f3//\fP\f2pattern\^\fP\f3/\f2string\^\fP\f3}\fP
+.TP
+\f3${\fP\f2parameter\^\fP\f3/#\fP\f2pattern\^\fP\f3/\f2string\^\fP\f3}\fP
+.TP
+\f3${\fP\f2parameter\^\fP\f3/%\fP\f2pattern\^\fP\f3/\f2string\^\fP\f3}\fP
+.PD
+Expands
+.I parameter\^
+and replaces the longest match of
+.I pattern\^
+with the given
+.IR string.
+Each occurrence of \f3\e\fP\f2n\^\fP in
+.I string
+is replaced by the portion of \f2parameter\^\fP
+that matches the \f2n\^\fP-th sub-pattern.
+In the first form,
+only the first occurrence of
+.I pattern\^
+is replaced.
+In the second form,
+each match for
+.I pattern\^
+is replaced by the given
+.IR string.
+The third form restricts the pattern match to the beginning of the string
+while the fourth form restricts the pattern match to the end of
+the string.
+When
+.I string\^
+is null, the
+.I pattern\^
+will be deleted and the
+.B /
+in front of
+.I string\^
+may be omitted.
+When
+.I parameter\^
+is
+.BR @ ,
+.BR * ,
+or an array variable with subscript
+.B @
+or
+.BR * ,
+the substitution operation is applied to each element in turn.
+In this case, the
+.I string\^
+portion of
+.I word\^
+will be re-evaluated for each element.
+.PP
+The following
+parameters
+are automatically set by the shell:
+.RS
+.PD 0
+.TP
+.B #
+The number of positional parameters in decimal.
+.TP
+.B \-
+Options supplied to the shell on invocation or by
+the
+.B set
+command.
+.TP
+.B ?
+The decimal value returned by the last executed command.
+.TP
+.B $
+The process number of this shell.
+.TP
+.B _
+Initially, the value of
+.B _
+is an absolute pathname of the shell or script being executed
+as passed in the
+.IR environment .
+Subsequently it is assigned the last argument of the previous command.
+This parameter is not set for commands which are asynchronous.
+This parameter is also used to hold the name of the matching
+.B
+.SM MAIL
+file when checking for mail.
+.TP
+.B !
+The process number of the last background command invoked or
+the most recent job put in the background with the
+.B bg
+built-in command.
+.TP
+.B .sh.command
+When processing a
+.SM
+.B DEBUG
+trap, this variable contains the current command line
+that is about to run.
+.TP
+.B .sh.edchar
+This variable contains the value of the keyboard character
+(or sequence of characters if the first character is an ESC, ascii
+.BR 033\^ )
+that has
+been entered when processing a
+.B
+.SM KEYBD
+trap
+(see
+.I "Key Bindings\^"
+below).
+If the value is changed as part of the trap action, then the new
+value replaces the key (or key sequence) that caused the trap.
+.TP
+.B .sh.edcol
+The character position of the cursor at the time of the most recent
+.B
+.SM KEYBD
+trap.
+.TP
+.B .sh.edmode
+The value is set to ESC when processing a
+.B
+.SM KEYBD
+trap while in
+.B vi
+insert mode. (See
+.I "Vi Editing Mode"\^
+below.)
+Otherwise,
+.B .sh.edmode
+is null when processing a
+.B
+.SM KEYBD
+trap.
+.TP
+.B .sh.edtext
+The characters in the input buffer at the time of the most recent
+.B
+.SM KEYBD
+trap.
+The value is null when not processing a
+.B
+.SM KEYBD
+trap.
+.TP
+.B .sh.file
+The pathname of the file than contains the current command.
+.TP
+.B .sh.fun
+The name of the current function that is being executed.
+.TP
+.B .sh.match
+An indexed array which stores the most recent match and sub-pattern
+matches after conditional pattern matches that match and after
+variables expansions using the operators
+.BR # ,
+.BR % ,
+or
+.BR / .
+The
+.BR 0 -th
+element stores the complete match and the
+.IR i\^ -th.
+element stores the
+.IR i\^ -th
+submatch.
+The
+.B .sh.match
+variable
+becomes unset when the variable that has expanded
+is assigned a new value.
+.TP
+.B .sh.name
+Set to the name of the variable at the time that a
+discipline function is invoked.
+.TP
+.B .sh.subscript
+Set to the name subscript of the variable at the time that a
+discipline function is invoked.
+.TP
+.B .sh.subshell
+The current depth for subshells and command substitution.
+.TP
+.B .sh.value
+Set to the value of the variable at the time that the
+.B set
+or
+.B append
+discipline function is invoked.
+.TP
+.B .sh.version
+Set to a value that identifies the version of this shell.
+.TP
+.B
+.SM LINENO
+The current line number within the script or
+function being executed.
+.TP
+.B
+.SM OLDPWD
+The previous working directory set by the
+.B cd
+command.
+.TP
+.B
+.SM OPTARG
+The value of the last option argument processed by the
+.B getopts
+built-in command.
+.TP
+.B
+.SM OPTIND
+The index of the last option argument processed by the
+.B getopts
+built-in command.
+.TP
+.B
+.SM PPID
+The process number of the parent of the shell.
+.TP
+.B
+.SM PWD
+The present working directory set by the
+.B cd
+command.
+.TP
+.B
+.SM RANDOM
+Each time this variable is referenced, a random integer,
+uniformly distributed between 0 and 32767, is generated.
+The sequence of random numbers can be initialized by assigning
+a numeric value to
+.SM
+.BR RANDOM .
+.TP
+.B
+.SM REPLY
+This variable is set by the
+.B select
+statement and by
+the
+.B read
+built-in command when no arguments are supplied.
+.TP
+.B
+.SM SECONDS
+Each time this variable is referenced, the number of
+seconds since shell invocation is returned.
+If this variable is
+assigned a value, then the value returned upon reference will
+be the value that was assigned plus the number of seconds since the assignment.
+.PD
+.RE
+.PP
+The following
+variables
+are used by the shell:
+.RS
+.PD 0
+.TP
+.B
+.SM CDPATH
+The search path for the
+.B cd
+command.
+.TP
+.B
+.SM COLUMNS
+If this variable is set,
+the value is used to define the width of the edit window
+for the shell edit modes and for printing
+.B select
+lists.
+.TP
+.B
+.SM EDITOR
+If the
+.B
+.SM VISUAL
+variable is not set,
+the value of this variable will be checked for the patterns
+as described with
+.B
+.SM VISUAL
+below and the corresponding editing option
+(see Special Command
+.B set
+below)
+will be turned on.
+.TP
+.SM
+.B ENV
+If this variable is set, then
+parameter expansion, command substitution, and arithmetic substitution
+are performed on
+the value to generate
+the pathname of the script that will be
+executed when the shell
+is invoked
+(see
+.I Invocation\^
+below).
+This file is typically used for
+.B alias
+and
+.B function
+definitions.
+The default value is \fB$HOME/.kshrc\fP.
+.TP
+.B
+.SM FCEDIT
+Obsolete name for
+the default editor name for the
+.B hist
+command.
+.B
+.SM FCEDIT
+is not used when
+.B
+.SM HISTEDIT
+is set.
+.TP
+.SM
+.B FIGNORE
+A pattern that defines the set of filenames that will be
+ignored when performing filename matching.
+.TP
+.SM
+.B FPATH
+The search path for function definitions.
+The directories in this path are searched for a file with the same name
+as the function or command when a function with the
+.B \-u
+attribute is referenced and when a command is not found.
+If an executable file with the name of that command is found,
+then it is read and executed
+in the current environment.
+Unlike
+.SM
+.BR PATH ,
+the current directory must be represented
+explictily by
+.B .
+rather than by adjacent
+.B :
+characters or a beginning or ending
+.BR : .
+.TP
+.B
+.SM HISTCMD
+Number of the current command in the history file.
+.TP
+.B
+.SM HISTEDIT
+Name for
+the default editor name for the
+.B hist
+command.
+.TP
+.SM
+.B HISTFILE
+If this variable is set when the shell is invoked, then
+the value is the pathname of the file that will be
+used to store the command history (see
+.I "Command Re-entry\^"
+below).
+.TP
+.SM
+.B HISTSIZE
+If this variable is set when the shell is invoked, then
+the number of previously entered commands that
+are accessible by this shell
+will be greater than or equal to this number.
+The default is 512.
+.TP
+.B
+.SM HOME
+The default argument (home directory) for the
+.B cd
+command.
+.TP
+.SM
+.B IFS
+Internal field separators,
+normally
+.BR space ,
+.BR tab ,
+and
+.B new-line
+that are used to separate the results of
+command substitution or parameter expansion
+and to separate fields with the built-in command
+.BR read .
+The first character of the
+.SM
+.B IFS
+variable is used to separate arguments for the
+.B
+"$\(**"
+substitution (see
+.I Quoting
+below).
+Each single occurrence of
+an
+.SM
+.B IFS
+character in the string to be split,
+that is not in the \f2isspace\^\fP character class, and any
+adjacent characters in
+.SM
+.B IFS
+that are in the \f2isspace\^\fP character class, delimit a field.
+One or more
+characters in
+.SM
+.B IFS
+that belong to the \f2isspace\^\fP character class,
+delimit a field.
+In addition, if the same \f2isspace\^\fP character appears
+consecutively inside
+.SM
+.BR IFS ,
+this character is treated as if it were not in the \f2isspace\^\fP
+class, so that if
+.SM
+.BR IFS
+consists of two
+.B tab
+characters,
+then two adjacent
+.B tab
+characters delimit a null field.
+.TP
+.B
+.SM LANG
+This variable determines the locale category for any
+category not specifically selected with a variable
+starting with
+.B
+.SM LC_
+or
+.SM
+.BR LANG .
+.TP
+.B
+.SM LC_ALL
+This variable overrides the value of the
+.B
+.SM LANG
+variable and any other
+.B
+.SM LC_
+variable.
+.TP
+.B
+.SM LC_COLLATE
+This variable determines the locale category for character
+collation information.
+.TP
+.B
+.SM LC_CTYPE
+This variable determines the locale category for character
+handling functions.
+It determines the character classes for pattern matching (see
+.I "File Name Generation\^"
+below).
+.TP
+.B
+.SM LC_NUMERIC
+This variable determines the locale category for the
+decimal point character.
+.TP
+.B
+.SM LINES
+If this variable is set,
+the value is used to determine the column length for printing
+.B select
+lists.
+Select lists will print vertically until about two-thirds of
+.B
+.SM LINES
+lines are filled.
+.TP
+.B
+.SM MAIL
+If this variable is set to the name of a mail file
+.I and\^
+the
+.B
+.SM MAILPATH
+variable is not set,
+then the shell informs the user of arrival of mail
+in the specified file.
+.TP
+.B
+.SM MAILCHECK
+This variable specifies how often (in seconds) the
+shell will check for changes in the modification time
+of any of the files specified by the
+.B
+.SM MAILPATH
+or
+.B
+.SM MAIL
+variables.
+The default value is 600 seconds.
+When the time has elapsed
+the shell will check before issuing the next prompt.
+.TP
+.B
+.SM MAILPATH
+A colon (
+.B :
+)
+separated list of file names.
+If this variable is set,
+then the shell informs the user of
+any modifications to the specified files
+that have occurred within the last
+.B
+.SM MAILCHECK
+seconds.
+Each file name can be followed by a
+.B ?
+and a message that will be printed.
+The message will undergo parameter expansion, command substitution,
+and arithmetic substitution
+with the variable
+.B $_
+defined as the name of the file that has changed.
+The default message is
+.I you have mail in $_\^.
+.TP
+.B
+.SM PATH
+The search path for commands (see
+.I Execution\^
+below).
+The user may not change
+.B \s-1PATH\s+1
+if executing under
+.if \nZ=0 .B rsh
+.if \nZ=1 .B rksh
+.if \nZ=2 .B rksh93
+(except in
+.BR .profile\^).
+.TP
+.SM
+.B PS1
+The value of this variable is expanded for parameter
+expansion, command substitution, and arithmetic substitution to define the
+primary prompt string which by default is
+.RB `` "$\|\|\|" ''.
+The character
+.B !
+in the primary prompt string is replaced by the
+.I command\^
+number (see
+.I "Command Re-entry\^"
+below).
+Two successive occurrences of
+.B !
+will produce a single
+.B !
+when the prompt string is printed.
+.TP
+.SM
+.B PS2
+Secondary prompt string, by default
+.RB `` "> \|" ''.
+.TP
+.SM
+.B PS3
+Selection prompt string
+used within a
+.B select
+loop, by default
+.RB `` "#? \|" ''.
+.TP
+.SM
+.B PS4
+The value of this variable is expanded for parameter evaluation,
+command substitution, and arithmetic substitution
+and precedes each line of an execution trace.
+By default,
+.SM
+.B PS4
+is
+.RB `` "+ \|" ''.
+In addition
+when
+.SM
+.B PS4
+is unset,
+the execution trace prompt is also
+.RB `` "+ \|" ''.
+.TP
+.SM
+.B SHELL
+The pathname of the
+.I shell\^
+is kept in the environment.
+At invocation, if the basename of this variable is
+.BR rsh ,
+.BR rksh ,
+or
+.BR krsh ,
+then the shell becomes restricted.
+If it is
+.BR pfsh
+or
+.BR pfksh ,
+then the shell becomes a profile shell (see
+.IR pfexec (1)).
+.TP
+.SM
+.B TIMEFORMAT
+The value of this parameter is used as a format string specifying
+how the timing information for pipelines prefixed with the
+.B time
+reserved word should be displayed.
+The \fB%\fP character introduces a format sequence that is
+expanded to a time value or other information.
+The format sequences and their meanings are as follows.
+.sp .5
+.RS
+.PD 0
+.TP 10
+.B %%
+A literal \fB%\fP.
+.TP
+.B %[\fIp\fP][l]R
+The elapsed time in seconds.
+.TP
+.B %[\fIp\fP][l]U
+The number of CPU seconds spent in user mode.
+.TP
+.B %[\fIp\fP][l]S
+The number of CPU seconds spent in system mode.
+.TP
+.B %P
+The CPU percentage, computed as (U + S) / R.
+.PD
+.RE
+.IP
+The braces denote optional portions.
+The optional \fIp\fP is a digit specifying the \fIprecision\fP,
+the number of fractional digits after a decimal point.
+A value of 0 causes no decimal point or fraction to be output.
+At most three places after the decimal point can be displayed;
+values of \fIp\fP greater than 3 are treated as 3.
+If \fIp\fP is not specified, the value 3 is used.
+.IP
+The optional \fBl\fP specifies a longer format, including
+hours if greater than zero,
+minutes, and seconds of the form \fIHH\fPh\fIMM\fPm\fISS\fP.\fIFF\fPs.
+The value of \fIp\fP determines whether or not the fraction is
+included.
+.IP
+All other characters are output without change and a trailing
+newline is added.
+If unset, the default value, \fB$'\enreal\et%2lR\enuser\et%2lU\ensys\t%2lS'\fP,
+is used. If the value is null, no timing information is displayed.
+.TP
+.B
+.SM TMOUT
+If set to a value greater than zero,
+.B
+.SM TMOUT
+will be the default timeout value for the
+.B read
+built-in command.
+The
+.B select
+compound command terminates after
+.B
+.SM TMOUT
+seconds when input is from a terminal.
+Otherwise,
+the shell will terminate if a line is not entered within
+the prescribed number of seconds while reading from a terminal.
+(Note that the shell can be compiled with a maximum bound
+for this value which cannot be exceeded.)
+.TP
+.B
+.SM VISUAL
+If the value of this variable matches the pattern
+.IR *[Vv][Ii]* ,
+then the
+.B vi
+option
+(see Special Command
+.B set
+below)
+is turned on.
+If the value matches the pattern
+.I *gmacs* ,
+the
+.B gmacs
+option is turned on.
+If the value matches the pattern
+.IR *macs* ,
+then the
+.B emacs
+option
+will be turned on.
+The value of
+.B
+.SM VISUAL
+overrides the value of
+.B
+.SM EDITOR.
+.PD
+.RE
+.PP
+The shell gives default values to
+\f3\s-1PATH\s+1\fP, \f3\s-1PS1\s+1\fP, \f3\s-1PS2\s+1\fP,
+\f3\s-1PS3\s+1\fP, \f3\s-1PS4\s+1\fP, \f3\s-1MAILCHECK\s+1\fP, \f3\s-1FCEDIT\s+1\fP,
+\f3\s-1TMOUT\s+1\fP and \f3\s-1IFS\s+1\fP,
+while
+.SM
+.BR HOME ,
+.SM
+.BR SHELL ,
+.SM
+.BR ENV ,
+and
+.SM
+.B MAIL
+are
+not set at all by the shell (although
+.SM
+.B HOME
+.I is\^
+set by
+.IR login (1)).
+On some systems
+.SM
+.B MAIL
+and
+.SM
+.B SHELL
+are also
+set by
+.IR login (1).
+.SS Field Splitting.
+After parameter expansion and command substitution,
+the results of substitutions are scanned for the field separator
+characters (those found in
+.SM
+.B IFS\^\c
+)
+and split into distinct fields where such characters are found.
+Explicit null fields (\^\f3"\^"\fP or \f3\(fm\^\(fm\fP\^) are retained.
+Implicit null fields
+(those resulting from
+.I parameters\^
+that have no values or command substitutions with no output) are removed.
+.PP
+If the
+.B braceexpand
+.RB ( \-B )
+option is set then each of the fields resulting from
+.SM
+.B IFS
+are checked to see if they contain one or more of the brace patterns
+.BR {*,*} ,
+.BI { l1 .. l2 }
+,
+.BI { n1 .. n2 }
+,
+.BI { n1 .. n2 %
+.IB fmt }
+,
+.BI { n1 .. n2
+.BI .. n3 }
+, or
+.BI { n1 .. n2
+.BI .. n3 % fmt }
+, where
+.B *
+represents any character,
+.IR l1\^ , l2\^
+are letters and
+.IR n1\^ , n2\^ , n3\^
+are signed numbers and
+.I fmt\^
+is a format specified as used by
+.BR printf .
+In each case, fields are created
+by prepending the characters before the
+.B {
+and appending the characters after the
+.B }
+to each of the strings generated by the characters between
+the
+.B {
+and
+.BR } .
+The resulting fields are checked to see if they have any
+brace patterns.
+.PP
+In the first form, a field is created for each string between
+.BR {
+and
+.BR , ,
+between
+.BR ,
+and
+.BR , ,
+and between
+.BR ,
+and
+.BR } .
+The string represented by
+.B *
+can contain embedded matching
+.B {
+and
+.B }
+without quoting.
+Otherwise, each
+.B {
+and
+.B }
+with
+.B *
+must be quoted.
+.PP
+In the seconds form,
+.I l1\^
+and
+.I l2\^
+must both be either upper case or both be lower case characters
+in the C locale. In this case a field is created for each character
+from
+.I l1\^
+thru
+.IR l2\^ .
+.PP
+In the remaining forms, a field is created for each number starting at
+.I n1\^
+and continuing until it reaches
+.I n2\^
+incrementing
+.I n1\^
+by
+.IR n3\^ .
+The cases where
+.I n3\^
+is not specified behave as if
+.I n3\^
+where
+.B 1
+if
+.IB n1 <= n2
+and
+.B \-1
+otherwise.
+If forms which specify
+.BI % fmt\^
+any format flags, widths and precisions can be specified
+and
+.I fmt\^
+can end in any of the specifiers
+.BR cdiouxX .
+For example,
+.B {a,z}{1..5..3%02d}{b..c}x
+expands to the 8 fields,
+.BR a01bx ,
+.BR a01cx ,
+.BR a04bx ,
+.BR a04cx ,
+.BR z01bx ,
+.BR z01cx ,
+.B z04bx
+and
+.BR z4cx .
+.SS File Name Generation.
+Following splitting, each field is scanned for the characters
+.BR \(** ,
+.BR ? ,
+.BR ( ,
+and
+.B \*(OK\^
+unless the
+.B \-f
+option has been set.
+If one of these characters appears,
+then the word is regarded as a
+.IR pattern .
+Each file name component that contains any pattern character
+is replaced with a lexicographically sorted set of names
+that matches the pattern
+from
+that directory.
+If no file name is found that matches the pattern, then
+that component of the filename is left unchanged unless
+the pattern is prefixed with
+.B \(ap(N)\fP
+in which case it is removed as described below.
+If
+.SM
+.B FIGNORE
+is set,
+then each file name component
+that matches the pattern defined by the value of
+.SM
+.B FIGNORE
+is ignored when generating the matching filenames.
+The names
+.B .
+and
+.B ..
+are also ignored.
+If
+.SM
+.B FIGNORE
+is not set,
+the character
+.B .
+at the start of each file name component
+will be ignored unless the first character of the pattern
+corresponding to this component is the character
+.BR .
+itself.
+Note, that for other
+uses of pattern matching the
+.B /
+and
+.B .
+are not treated specially.
+.PP
+.PD 0
+.RS
+.TP
+.B \(**
+Matches any string, including the null string.
+When used for filename expansion,
+if the
+.B globstar
+option is on, two adjacent
+.BR \(** 's
+by itself
+will match all files and zero or more directories
+and subdirectories.
+If followed by a
+.B /
+than only directories and subdirectories will match.
+.TP
+.B ?
+Matches any single character.
+.TP
+.BR \*(OK \^.\|.\|.\^ \*(CK
+Matches any one of the enclosed characters.
+A pair of characters separated by
+.B \-
+matches any
+character lexically between the pair, inclusive.
+If the first character following the opening
+.B \*(OK\^
+is a
+.B !
+then any character not enclosed is matched.
+A
+.B \-
+can be included in the character set by putting it as the
+first or last character.
+.br
+Within
+.B \*(OK\^
+and
+.BR \*(CK\^ ,
+character classes can be specified with the syntax
+\f3[:\fP\f2class\fP\f3:]\fP
+where class is one of the following classes defined in the ANSI-C standard:
+(Note that \f3word\fP is equivalent to \f3alnum\fP plus the character \f3_\fP).
+.PP
+.if t .RS
+.B
+.if n alnum alpha blank cntrl digit graph lower print punct space upper word xdigit
+.if t alnum alpha blank cntrl digit graph lower print punct space upper word xdigit
+.br
+Within
+.B \*(OK\^
+and
+.BR \*(CK\^ ,
+an equivalence class can be specified with the syntax
+\f3[=\fP\f2c\fP\f3=]\fP
+which matches all characters with the same primary
+collation weight (as defined by the current locale) as
+the character \f2c\fP.
+.br
+Within
+.B \*(OK\^
+and
+.BR \*(CK\^ ,
+\f3[.\fP\f2symbol\fP\f3.]\fP
+matches the collating symbol \f2symbol\fP.
+.if t .RE
+.PD
+.RE
+A
+.I pattern-list
+is a list of one or more patterns separated from each other
+with a
+.B &
+or
+.BR \(bv .
+A
+.B &
+signifies that all patterns must be matched whereas
+.BR \(bv
+requires that only one pattern be matched.
+Composite patterns can be formed with one or more of the following sub-patterns:
+.PD 0
+.RS
+.TP
+\f3?(\fP\f2pattern-list\^\fP\f3)\fP
+Optionally matches any one of the given patterns.
+.TP
+\f3*(\fP\f2pattern-list\^\fP\f3)\fP
+Matches zero or more occurrences of the given patterns.
+.TP
+\f3+(\fP\f2pattern-list\^\fP\f3)\fP
+Matches one or more occurrences of the given patterns.
+.TP
+\f3{\fP\f2n\^\fP\f3}\fP(\fP\f2pattern-list\^\fP\f3)\fP
+Matches \f2n\^\fP occurrences of the given patterns.
+.TP
+\f3{\fP\f2m\^\fP\f3,\fP\f2n\^\fP\f3}\fP(\fP\f2pattern-list\^\fP\f3)\fP
+Matches from \f2m\^\fP to \f2n\^\fP occurrences of the given patterns.
+If \f2m\^\fP is omitted, \f30\fP will be used. If \f2n\^\fP
+is omitted at least \f2m\^\fP occurrences will be matched.
+.TP
+\f3\&@\&(\fP\f2pattern-list\^\fP\f3)\fP
+Matches exactly one of the given patterns.
+.br
+.TP
+\f3!(\fP\f2pattern-list\^\fP\f3)\fP
+Matches anything except one of the given patterns.
+.PD
+.RE
+By default, each pattern, or sub-pattern will match the
+longest string possible consistent with generating
+the longest overall match. If more than one match is
+possible, the one starting closest to the beginning
+of the string will be chosen. However, for each of the above
+compound patterns a \f3\-\fP can be inserted in front of the \f3(\fP
+to cause the shortest match to the specified \f2pattern-list\^\fP
+to be used.
+.PP
+When \f2pattern-list\^\fP is contained within parenthesis,
+the backslash character \f3\e\fP is treated specially even
+when inside a character class. All ANSI-C character escapes are
+recognized and match the specified character. In addition
+the following escape sequences are recognized:
+.PD 0
+.RS
+.TP
+.B \ed
+Matches any character in the \f3digit\fP class.
+.TP
+.B \eD
+Matches any character not in the \f3digit\fP class.
+.TP
+.B \es
+Matches any character in the \f3space\fP class.
+.TP
+.B \eS
+Matches any character not in the \f3space\fP class.
+.TP
+.B \ew
+Matches any character in the \f3word\fP class.
+.TP
+.B \eW
+Matches any character not in the \f3word\fP class.
+.PD
+.RE
+.PP
+A pattern of the form
+\f3%(\fP\f2pattern-pair\^\fP(s)\f3)\fP
+is a sub-pattern that
+can be used to match nested character expressions.
+Each
+.I pattern-pair\^
+is a two character sequence which cannot contain
+.B &
+or
+.BR \(bv .
+The first
+.I pattern-pair\^
+specifies the starting and ending characters for the match.
+Each subsequent
+.I pattern-pair\^
+represents the beginning and ending characters of a nested group that
+will be skipped over when counting starting and ending character matches.
+The behavior is unspecified when the first character of a
+.I pattern-pair\^
+is alpha-numeric
+except for the following:
+.PD 0
+.RS
+.TP
+.B D
+Causes the ending character to terminate the search for this pattern without
+finding a match.
+.TP
+.B E
+Causes the ending character to be interpreted as an escape character.
+.TP
+.B L
+Causes the ending character to be interpreted as a quote character
+causing all characters to be ignored when looking for a match.
+.TP
+.B Q
+Causes the ending character to be interpreted as a quote character
+causing all characters other than any escape character to be ignored
+when looking for a match.
+.PD
+.RE
+Thus,
+\f3%(\^{\^}Q"E\e\^)\fP,
+matches characters starting at
+.B {
+until the matching
+.B }
+is found not counting any
+.B {
+or
+.B }
+that is inside a double quoted string or preceded by the escape character
+.BR \e .
+Without the
+.B {\^}
+this pattern matches any C language string.
+.PP
+Each sub-pattern in a composite pattern is numbered,
+starting at 1, by the location of the \f3(\fP within
+the pattern.
+The sequence \f3\e\fP\f2n\^\fP, where \f2n\^\fP
+is a single digit and \f3\e\fP\f2n\^\fP comes after
+the \f2n\fP-th. sub-pattern,
+matches the same string as the sub-pattern itself.
+.PP
+Finally a pattern can contain sub-patterns of the form
+\f3\(ap(\fP\f2options\^\fP\f3:\fP\f2pattern-list\^\fP\f3)\fP.
+where either \f2options\^\fP or \f3:\fP\f2pattern-list\^\fP
+can be omitted. Unlike, the other compound patterns,
+these sub-patterns are not counted in the numbered sub-patterns.
+If \f2options\^\fP is present, it can consist of one or more
+of the following:
+.PD 0
+.RS
+.TP
+.B +
+Enable the following options. This is the default.
+.TP
+.B \-
+Disable the following options.
+.TP
+.B E
+The remainder of the pattern uses extended regular expression syntax
+like the
+.IR egrep (1)
+command.
+.TP
+.B F
+The remainder of the pattern uses
+.IR fgrep (1)
+expression syntax.
+.TP
+.B G
+The remainder of the pattern uses basic regular expression syntax
+like the
+.IR grep (1)
+command.
+.TP
+.B K
+The remainder of the pattern uses shell pattern syntax.
+This is the default.
+.TP
+.B N
+This is ignored. However, when it is the first letter and is
+used with file name generation, and no matches occur,
+the file pattern expands to the empty string.
+.TP
+.B i
+Treat the match as case insensitive.
+.TP
+.B g
+File the longest match (greedy). This is the default.
+.TP
+.B l
+Left anchor the pattern. This is the default for
+.B K
+style patterns.
+.TP
+.B r
+Right anchor the pattern. This is the default for
+.B K
+style patterns.
+.PD
+.RE
+If both \f2options\^\fP and \f3:\fP\f2pattern-list\^\fP
+are specified, then the options apply only to \f2pattern-list\^\fP.
+Otherwise, these options remain in effect until they are disabled
+by a subsequent \f3\(ap(\fP\f2...\^\fP\f3)\fP or at the end of
+the sub-pattern containing \f3\(ap(\fP\f2...\^\fP\f3)\fP.
+.SS Quoting.
+Each of the
+.I metacharacters\^
+listed earlier (see
+.I Definitions\^
+above)
+has a special meaning to the shell
+.TP
+.B i
+Treat the match as case insensitive.
+.TP
+.B g
+File the longest match (greedy). This is the default.
+.PD
+.RE
+If both \f2options\^\fP and \f3:\fP\f2pattern-list\^\fP
+are specified, then the options apply only to \f2pattern-list\^\fP.
+Otherwise, these options remain in effect until they are disabled
+by a subsequent \f3\(ap(\fP\f2...\^\fP\f3)\fP or at the end of
+the sub-pattern containing \f3\(ap(\fP\f2...\^\fP\f3)\fP.
+.SS Quoting.
+Each of the
+.I metacharacters\^
+listed earlier (see
+.I Definitions\^
+above)
+has a special meaning to the shell
+and causes termination of a word unless quoted.
+A character may be
+.I quoted\^
+(i.e., made to stand for itself)
+by preceding
+it with a
+.BR \e .
+The pair
+.B \enew-line
+is removed.
+All characters enclosed between a pair of single quote marks
+(\^\f3\(fm\^\(fm\fP\^)
+that is not preceded by a
+.B $
+are quoted.
+A single quote cannot appear within the single quotes.
+A single quoted string preceded by an unquoted
+.B $
+is processed as an ANSI-C string
+except for the following:
+.PD 0
+.TP
+.B \e0
+Causes the remainder of the string to be ignored.
+.TP
+.B \eE
+Equivalent to the escape character
+(ascii
+.BR 033 ),
+.TP
+.B \ee
+Equivalent to the escape character
+(ascii
+.BR 033 ),
+.TP
+.BI \ec x
+Expands to the character control-\f2x\fP.
+.TP
+.BI \eC[. name .]
+Expands to the collating element \f2name\fP.
+.PD
+.PP
+Inside double quote marks
+(\f3"\^"\fP),
+parameter and command substitution occur and
+.B \e
+quotes the characters
+.BR \e ,
+.BR \*` ,
+\f3"\fP,
+and
+.BR $ .
+A
+.B $
+in front of a double quoted string will be ignored
+in the "C" or "POSIX" locale, and may cause
+the string to be replaced by a locale specific string otherwise.
+The meaning of
+.B "$\(**"
+and
+.B "$@"
+is identical when not quoted or when used as a variable assignment value
+or as a file name.
+However, when used as a command argument,
+.B
+"$\(**"
+is equivalent to
+\f3"$1\fP\f2d\fP\f3\|$2\fP\f2d\fP\|.\|.\|.\f3"\fP,
+where
+.I d
+is the first character of the
+.SM
+.B IFS
+variable, whereas
+.B
+"$@"
+is equivalent to
+.B
+"$1"\|
+.B
+"$2"\|
+\&.\|.\|.\^.
+Inside grave quote marks
+(\f3\*`\^\*`\fP),
+.B \e
+quotes the characters
+.BR \e ,
+.BR \*` ,
+and
+.BR $ .
+If the grave quotes occur within double quotes, then
+.B \e
+also quotes the character
+\f3"\fP.
+.PP
+The special meaning of reserved words or aliases can be removed by quoting any
+character of the reserved word.
+The recognition of function names or built-in command names listed below
+cannot be altered by quoting them.
+.SS Arithmetic Evaluation.
+The shell performs arithmetic evaluation for
+arithmetic substitution, to evaluate an arithmetic command,
+to evaluate an indexed array subscript,
+and to evaluate arguments to
+the built-in commands
+.B shift\^
+and
+.BR let .
+Evaluations are performed using
+double precision floating point
+arithmetic or long double precision floating point for
+systems that provide this data type.
+Floating point constants follow the ANSI-C programming language
+floating point conventions.
+Integer constants follow the ANSI-C programming language
+integer constant conventions although only single byte
+character constants are recognized and character casts
+are not recognized.
+In addition constants can be of the form
+\*(OK\f2base\f3#\^\f1\*(CK\f2n\^\fP
+where
+.I base\^
+is a decimal number between two and sixty-four
+representing the arithmetic base
+and
+.I n\^
+is a number in that base.
+The digits above 9 are represented
+by the lower case letters, the upper case letters,
+.BR @ ,
+and
+.B _
+respectively.
+For bases less than or equal to 36, upper and lower case
+characters can be used interchangeably.
+.PP
+An arithmetic expression uses the same syntax, precedence, and
+associativity of
+expression as the C language.
+All the C language operators
+that apply to floating point quantities can be used.
+In addition, the operator
+.B **
+can be used for exponentiation.
+It has higher precedence than multiplication as is left associative.
+In addition, when the value of an arithmetic variable
+or sub-expression can be represented as a long integer,
+all C language integer arithmetic operations can be performed.
+Variables can be referenced by name within an arithmetic expression
+without using the parameter expansion syntax.
+When a variable is referenced, its value is evaluated as
+an arithmetic expression.
+.PP
+Any of the following math library functions that are in the C math library
+can be used within an arithmetic expression:
+.PP
+.if t .RS
+.B
+.if n abs acos acosh asin asinh atan atan2 atanh cbrt copysign cos cosh erf erfc exp exp2 expm1 fabs fdim finite floor fma fmax fmod hypot ilogb int isinf isnan lgamma log log2 logb nearbyint nextafter nexttoward pow remainder rint round sin sinh sqrt tan tanh tgamma trunc
+.if t abs acos acosh asin asinh atan atan2 atanh cbrt copysign cos cosh erf erfc exp exp2 expm1 fabs fdim finite floor fma fmax fmod hypot ilogb int isinf isnan lgamma log log2 logb nearbyint nextafter nextroward pow rint round sin sinh sqrt tan tanh tgamma trunc
+.if t .RE
+.PP
+An internal representation of a
+.I variable\^
+as a double precision floating point can be specified with the
+\f3\-E\fP \*(OK\f2n\^\fP\*(CK
+or
+\f3\-F\fP \*(OK\f2n\^\fP\*(CK
+option of the
+.B typeset
+special built-in command.
+The
+.B \-E
+option causes the expansion of the value to be represented using
+scientific notation when it is expanded.
+The optional option argument
+.I n
+defines the number of significant figures.
+The
+.B \-F
+option causes the expansion to be represented as a floating decimal number
+when it is expanded.
+The optional option argument
+.I n
+defines the number of places after the decimal point in this case.
+.PP
+An internal integer representation of a
+.I variable\^
+can be specified with the
+\f3\-i\fP \*(OK\f2n\^\fP\*(CK
+option of the
+.B typeset
+special built-in command.
+The optional option argument
+.I n
+specifies an arithmetic base to be used when expanding the variable.
+If you do not specify an arithmetic base,
+base 10 will be used.
+.PP
+Arithmetic evaluation is performed on the value of each
+assignment to a variable with the
+.BR \-E ,
+.BR \-F ,
+or
+.B \-i
+attribute.
+Assigning a floating point number to a
+variable whose type is an integer causes the fractional
+part to be truncated.
+.PP
+.SS Prompting.
+When used interactively,
+the shell prompts with the value of
+.SM
+.B PS1
+after expanding it for parameter expansion, command substitution, and
+arithmetic substitution,
+before reading a command.
+In addition, each single
+.B !
+in the prompt is replaced by the command number.
+A
+.B !!
+is required to place
+.B !
+in the prompt.
+If at any time a new-line is typed and further input is needed
+to complete a command, then the secondary prompt
+(i.e., the value of
+.BR \s-1PS2\s+1 )
+is issued.
+.SS Conditional Expressions.
+A
+.I "conditional expression"
+is used with the
+.B [[
+compound command to test attributes of files and to compare
+strings.
+Field splitting and file name generation are
+not performed on the words between
+.B [[
+and
+.BR ]] .
+Each expression can be constructed from one or more
+of the following unary or binary expressions:
+.PD 0
+.TP
+\f2string\fP
+True, if
+.I string
+is not null.
+.TP
+\f3\-a\fP \f2file\fP
+Same as \f3\-e\fP below.
+This is obsolete.
+.TP
+\f3\-b\fP \f2file\fP
+True, if
+.I file\^
+exists and is a block special file.
+.TP
+\f3\-c\fP \f2file\fP
+True, if
+.I file\^
+exists and is a character special file.
+.TP
+\f3\-d\fP \f2file\fP
+True, if
+.I file\^
+exists and is a directory.
+.TP
+\f3\-e\fP \f2file\fP
+True, if
+.I file\^
+exists.
+.TP
+\f3\-f\fP \f2file\fP
+True, if
+.I file\^
+exists and is an ordinary file.
+.TP
+\f3\-g\fP \f2file\fP
+True, if
+.I file\^
+exists and it has its setgid bit set.
+.TP
+\f3\-k\fP \f2file\fP
+True, if
+.I file\^
+exists and it has its sticky bit set.
+.TP
+\f3\-n\fP \f2string\fP
+True, if length of
+.I string\^
+is non-zero.
+.TP
+\f3\-o\fP \f3?\fP\f2option\fP
+True, if option named
+.I option\^
+is a valid option name.
+.TP
+\f3\-o\fP \f2option\fP
+True, if option named
+.I option\^
+is on.
+.TP
+\f3\-p\fP \f2file\fP
+True, if
+.I file\^
+exists and is a fifo special file or a pipe.
+.TP
+\f3\-r\fP \f2file\fP
+True, if
+.I file\^
+exists and is readable by current process.
+.TP
+\f3\-s\fP \f2file\fP
+True, if
+.I file\^
+exists and has size greater than zero.
+.TP
+\f3\-t\fP \f2fildes\fP
+True, if file descriptor number
+.I fildes\^
+is open and associated with a terminal device.
+.TP
+\f3\-u\fP \f2file\fP
+True, if
+.I file\^
+exists and it has its setuid bit set.
+.TP
+\f3\-w\fP \f2file\fP
+True, if
+.I file\^
+exists and is writable by current process.
+.TP
+\f3\-x\fP \f2file\fP
+True, if
+.I file\^
+exists and is executable by current process.
+If
+.I file\^
+exists and is a directory, then true if the current process
+has permission to search in the directory.
+.TP
+\f3\-z\fP \f2string\fP
+True, if length of
+.I string\^
+is zero.
+.TP
+\f3\-L\fP \f2file\fP
+True, if
+.I file\^
+exists and is a symbolic link.
+.TP
+\f3\-h\fP \f2file\fP
+True, if
+.I file\^
+exists and is a symbolic link.
+.TP
+\f3\-N\fP \f2file\fP
+True, if
+.I file\^
+exists and the modification time is greater than the last access time.
+.TP
+\f3\-O\fP \f2file\fP
+True, if
+.I file\^
+exists and is owned by the effective user id of this process.
+.TP
+\f3\-G\fP \f2file\fP
+True, if
+.I file\^
+exists and its group matches the effective group id of this process.
+.TP
+\f3\-S\fP \f2file\fP
+True, if
+.I file\^
+exists and is a socket.
+.TP
+\f2file1\fP \f3\-nt\fP \f2file2\fP
+True, if
+.I file1\^
+exists and
+.I file2\^
+does not, or
+.I file1\^
+is newer than
+.IR file2 .
+.TP
+\f2file1\fP \f3\-ot\fP \f2file2\fP
+True, if
+.I file2\^
+exists and
+.I file1\^
+does not, or
+.I file1\^
+is older than
+.IR file2 .
+.TP
+\f2file1\fP \f3\-ef\fP \f2file2\fP
+True, if
+.I file1\^
+and
+.I file2\^
+exist and refer to the same file.
+.TP
+\f2string\fP \f3==\fP \f2pattern\fP
+True, if
+.I string\^
+matches
+.IR pattern .
+Any part of
+.I pattern\^
+can be quoted to cause it to be matched as a string.
+With a successful match to a pattern, the
+.B .sh.match
+array variable will contain the match and sub-pattern matches.
+.TP
+\f2string\fP \f3=\fP \f2pattern\fP
+Same as \f3==\fP above, but is obsolete.
+.TP
+\f2string\fP \f3!=\fP \f2pattern\fP
+True, if
+.I string\^
+does not match
+.IR pattern .
+With the
+.I string\^
+matches the
+.I pattern\^
+the
+.B .sh.match
+array variable will contain the match and sub-pattern matches.
+.TP
+\f2string\fP \f3=\(ap\fP \f2ere\fP
+True if
+.I string\^
+matches the pattern
+.BI \(ap(E) ere\^
+where
+.I ere\^
+is an extended regular expression.
+.TP
+\f2string1\fP \f3<\fP \f2string2\fP
+True, if
+.I string1\^
+comes before
+.I string2\^
+based on ASCII value of their characters.
+.TP
+\f2string1\fP \f3>\fP \f2string2\fP
+True, if
+.I string1\^
+comes after
+.I string2\^
+based on ASCII value of their characters.
+.PP
+The following obsolete arithmetic comparisons are also permitted:
+.PD 0
+.TP
+\f2exp1\fP \f3\-eq\fP \f2exp2\fP
+True, if
+.I exp1\^
+is equal to
+.IR exp2 .
+.TP
+\f2exp1\fP \f3\-ne\fP \f2exp2\fP
+True, if
+.I exp1\^
+is not equal to
+.IR exp2 .
+.TP
+\f2exp1\fP \f3\-lt\fP \f2exp2\fP
+True, if
+.I exp1\^
+is less than
+.IR exp2 .
+.TP
+\f2exp1\fP \f3\-gt\fP \f2exp2\fP
+True, if
+.I exp1\^
+is greater than
+.IR exp2 .
+.TP
+\f2exp1\fP \f3\-le\fP \f2exp2\fP
+True, if
+.I exp1\^
+is less than or equal to
+.IR exp2 .
+.TP
+\f2exp1\fP \f3\-ge\fP \f2exp2\fP
+True, if
+.I exp1\^
+is greater than or equal to
+.IR exp2 .
+.PD
+.PP
+In each of the above expressions, if
+.I file\^
+is of the form
+\f3/dev/fd/\fP\f2n\fP,
+where
+.I n\^
+is an integer,
+then the test is applied to the open file whose
+descriptor number is
+.IR n .
+.PP
+A compound expression can be constructed from these primitives by
+using any of the following, listed in decreasing order of precedence.
+.PD 0
+.TP
+\f3(\fP\f2expression\fP\f3)\fP
+True, if
+.I expression\^
+is true.
+Used to group expressions.
+.TP
+\f3!\fP \f2expression\fP
+True if
+.I expression\^
+is false.
+.TP
+\f2expression1\fP \f3&&\fP \f2expression2\fP
+True, if
+.I expression1\^
+and
+.I expression2\^
+are both true.
+.TP
+\f2expression1\fP \f3\(bv\(bv\fP \f2expression2\fP
+True, if either
+.I expression1\^
+or
+.I expression2\^
+is true.
+.PD
+.SS Input/Output.
+Before a command is executed, its input and output
+may be redirected using a special notation interpreted by the shell.
+The following may appear anywhere in a simple-command
+or may precede or follow a
+.I command\^
+and are
+.I not\^
+passed on to the invoked command.
+Command substitution, parameter expansion,
+and arithmetic substitution occur before
+.I word\^
+or
+.I digit\^
+is used except as noted below.
+File name generation
+occurs only if the shell is interactive and
+the pattern matches a single file.
+Field splitting is not performed.
+.PP
+In each of the following redirections, if
+.I file\^
+is of the form
+\f3/dev/sctp/\fP\f2host\fP\f3/\fP\f2port\fP,
+\f3/dev/tcp/\fP\f2host\fP\f3/\fP\f2port\fP,
+or
+\f3/dev/udp/\fP\f2host\fP\f3/\fP\f2port\fP,
+where
+.I host\^
+is a hostname or host address,
+and
+.I port\^
+is a service given by name or an integer port number,
+then the redirection attempts to make a
+\f3tcp\fP, \f3sctp\fP or \f3udp\fP connection to the corresponding
+socket.
+.PP
+No intervening space is allowed between the characters of redirection operators.
+.TP 14
+.BI < word
+Use file
+.I word\^
+as standard input (file descriptor 0).
+.TP
+.BI > word
+Use file
+.I word\^
+as standard output (file descriptor 1).
+If the file does not exist then it is created.
+If the file exists, and the
+.B noclobber
+option is on,
+this causes an error;
+otherwise, it is truncated to zero length.
+.TP
+.BI >| word
+Sames as
+.BR > ,
+except that it overrides the
+.B noclobber
+option.
+.TP
+.BI >> word
+Use file
+.I word\^
+as standard output.
+If the file exists, then output is appended to it (by first seeking to the end-of-file);
+otherwise, the file is created.
+.TP
+.BI <> word
+Open file
+.I word\^
+for reading and writing
+as standard input.
+.TP
+\f3<<\fP\*(OK\f3\-\fP\*(CK\f2word\fP
+The shell input is read up to a line that is the same as
+.IR word
+after any quoting has been removed,
+or to an end-of-file.
+No parameter substitution, command substitution, arithmetic substitution or
+file name generation is performed on
+.IR word .
+The resulting document,
+called a
+.IR here-document ,
+becomes
+the standard input.
+If any character of
+.I word\^
+is quoted, then no interpretation
+is placed upon the characters of the document;
+otherwise, parameter expansion, command substitution, and arithmetic
+substitution occur,
+.B \enew-line
+is ignored,
+and
+.B \e
+must be used to quote the characters
+.BR \e ,
+.BR $ ,
+.BR \*` .
+If
+.B \-
+is appended to
+.BR << ,
+then all leading tabs are stripped from
+.I word\^
+and from the document.
+If
+.B #
+is appended to
+.BR << ,
+then leading spaces and tabs will be stripped off the first
+line of the document and up to an equivalent indentation will
+be stripped from the remaining lines and from
+.IR word .
+A tab stop is assumend to occur at every 8 columns for the
+purposes of determining the indentation.
+.TP
+\f3<<<\fP\f2word\fP
+A short form of here document in which \f2word\fP becomes the
+contents of the here-document after any
+parameter expansion, command substitution, and arithmetic
+substitution occur.
+.TP
+.BI <& digit
+The standard input is duplicated from file descriptor
+.I digit
+(see
+.IR dup (2)).
+Similarly for the standard output using
+\f3>&\^\f2digit\fR.
+.TP
+.BI <& digit \-
+The file descriptor given by
+.I digit
+is moved to standard input.
+Similarly for the standard output using
+\f3>&\^\f2digit\f3\-\fR.
+.TP
+.B <&\-
+The standard input is closed.
+Similarly for the standard output using
+.BR >&\- .
+.TP
+.B <&p
+The input from the co-process is moved to standard input.
+.TP
+.B >&p
+The output to the co-process is moved to standard output.
+.TP
+.BI <# \^\^\^ (( expr ))
+Evaluate arithmetic expression
+.I expr\^
+and position file descriptor 0
+to the resulting value
+bytes from the start of the file.
+The variables
+.B CUR
+and
+.B EOF
+evaluate to the current offset and end-of-file offset
+respectively when evaluating
+.IR expr.
+.TP
+.BI ># \^\^\^ (( offset ))
+The same as
+.B <#
+except applies to file descriptor 1.
+.TP
+.BI <# pattern
+Seeks forward to the beginning of the next line containing
+.IR pattern .
+.TP
+.BI <## pattern
+The same as
+.B <#
+except that the portion of the file that is skipped is copied to
+standard output.
+.PP
+If one of the above is preceded by a digit,
+with no intervening space, then the
+file descriptor number referred to is that specified
+by the digit
+(instead of the default 0 or 1).
+If one of the above, other than
+.BR >&\-
+and the
+.B >#
+and
+.B >#
+forms,
+is preceded by
+.BI { varname }
+with no intervening space,
+then a file descriptor number > 10
+will be selected by
+the shell and stored in the variable
+.IR varname .
+If
+.B >&\-
+or the any of the
+.B >#
+and
+.B >#
+forms
+is preceded by
+.BI { varname }
+the value of
+.I varname\^
+defines the file descriptor to close or position.
+For example:
+.PP
+.RS
+\fB\&.\|.\|. \|2>&1\fR
+.RE
+.PP
+means file descriptor 2 is to be opened
+for writing as a duplicate
+of file descriptor 1 and
+.PP
+.RS
+\fBexec {n}<file\fR
+.RE
+.PP
+means open file named
+.B file
+for reading and store
+the file descriptor number in variable
+.BR n .
+.PP
+The order in which redirections are specified is significant.
+The shell evaluates each redirection in terms of the
+.RI ( "file descriptor" ", " file )
+association at the time of evaluation.
+For example:
+.PP
+.RS
+\fB\&.\|.\|. \|1>\f2fname\^\fP 2>&1\fR
+.RE
+.PP
+first associates file descriptor 1 with file
+.IR fname\^ .
+It then associates file descriptor 2 with the file associated with file
+descriptor 1 (i.e.
+.IR fname\^ ).
+If the order of redirections were reversed, file descriptor 2 would be associated
+with the terminal (assuming file descriptor 1 had been) and then file descriptor
+1 would be associated with file
+.IR fname\^ .
+.PP
+If a command is followed by
+.B &
+and job control is not active,
+then the default standard input
+for the command
+is the empty file
+.BR /dev/null .
+Otherwise, the environment for the execution of a command contains the
+file descriptors of the invoking shell as modified by
+input/output specifications.
+.SS Environment.
+The
+.I environment\^
+(see
+.IR environ (7))
+is a list of name-value pairs that is passed to
+an executed program in the same way as a normal argument list.
+The names must be
+.I identifiers\^
+and the values are character strings.
+The shell interacts with the environment in several ways.
+On invocation, the shell scans the environment
+and creates a
+variable
+for each name found,
+giving it the corresponding value and attributes and marking it
+.IR export .
+Executed commands inherit the environment.
+If the user modifies the values of these
+variables
+or creates new ones,
+using the
+.B export
+or
+.B typeset \-x
+commands, they become part of the
+environment.
+The environment seen by any executed command is thus composed
+of any name-value pairs originally inherited by the shell,
+whose values may be modified by the current shell,
+plus any additions
+which must be noted in
+.B export
+or
+.B typeset \-x
+commands.
+.PP
+The environment for any
+.I simple-command\^
+or function
+may be augmented by prefixing it with one or more variable assignments.
+A variable assignment argument is a word of the form
+.IR identifier=value .
+Thus:
+.PP
+.RS
+\fB\s-1TERM\s+1=450 \|cmd \|args\fR and
+.br
+\fB(export \|\s-1TERM\s+1; \|\s-1TERM\s+1=450; \|cmd \|args)\fR
+.RE
+.PP
+are equivalent (as far as the above execution of
+.I cmd\^
+is concerned except for special built-in commands listed below \-
+those that are
+preceded with a dagger).
+.PP
+If the obsolete
+.B \-k
+option is set,
+.I all\^
+variable assignment arguments are placed in the environment,
+even if they occur after the command name.
+The following
+first prints
+.B "a=b c"
+and then
+.BR c :
+.PP
+.RS
+.nf
+.ft B
+echo \|a=b \|c
+set \|\-k
+echo \|a=b \|c
+.ft R
+.fi
+.RE
+This feature is intended for use with scripts written
+for early versions of the shell and its use in new scripts
+is strongly discouraged.
+It is likely to disappear someday.
+.SS Functions.
+.PP
+For historical reasons, there are two
+ways to define functions,
+the
+.IB name (\^)
+syntax and
+the
+.B function
+.I name\^
+syntax, described in the
+.I Commands
+section above.
+Shell functions are read in and stored internally.
+Alias names are resolved when the function is read.
+Functions are executed like commands with the arguments
+passed as positional parameters.
+(See
+.I Execution
+below.)
+.PP
+Functions defined by the
+.B function
+.I name
+syntax and called by name execute in the same process as the caller and
+share all files
+and present working directory with the
+caller.
+Traps caught by the caller are reset to their default action
+inside the function.
+A trap condition that is not caught or ignored by the
+function causes the function to terminate and the condition
+to be passed on to the caller.
+A trap on
+.SM
+.B EXIT
+set inside a function
+is executed
+in the environment
+of the caller
+after the function completes.
+Ordinarily,
+variables are shared between the calling program
+and the function.
+However,
+the
+.B typeset
+special built-in command used within a function
+defines local variables whose scope includes
+the current function.
+They can be passed to functions that they call in the
+variable assignment list the precedes the call or as arguments
+passed as name references.
+Errors within functions return control to the caller.
+.PP
+Functions defined with the
+.IB name (\^)
+syntax and functions defined with the
+.B function
+.I name
+syntax that are invoked with the \f3\s+2.\s-2\fP
+special built-in
+are executed in the caller's
+environment and share all variables
+and traps with the caller.
+Errors within these function executions cause the script that contains
+them to abort.
+.PP
+The special built-in command
+.B return
+is used to return
+from function calls.
+.PP
+Function names
+can be listed with the
+.B \-f
+or
+.B +f
+option of the
+.B typeset
+special built-in command.
+The text of functions, when available, will also
+be listed with
+.BR \-f .
+Functions can be undefined with the
+.B \-f
+option of the
+.B unset
+special built-in command.
+.PP
+Ordinarily, functions are unset when the shell executes a shell script.
+Functions that need to be defined across separate
+invocations of the shell should
+be placed in a directory and the
+.B
+.SM
+FPATH
+variable should contain the name of this directory.
+They may also
+be specified in the
+.B
+.SM
+ENV
+file.
+.SS Discipline Functions.
+Each variable can have zero or more discipline functions
+associated with it.
+The shell initially understands the discipline names \f3get\fP,
+\f3set\fP, \f3append\fP, and \f3unset\fP but on most systems
+others can be added at run time via the
+C programming interface extension provided by the
+.B builtin
+built-in utility.
+If the \f3get\fP discipline is defined for a variable, it is invoked
+whenever the given variable is referenced.
+If the variable \f3.sh.value\fP is assigned a value inside
+the discipline function, the referenced variable will evaluate
+to this value instead.
+If the \f3set\fP discipline is defined for a variable, it is invoked
+whenever the given variable is assigned a value.
+If the \f3append\fP discipline is defined for a variable, it is invoked
+whenever a value is appended to the given variable.
+The variable \f3.sh.value\fP is given the value
+of the variable before invoking the discipline, and
+the variable will be assigned the value of \f3.sh.value\fP
+after the discipline completes.
+If \f3.sh.value\fP is unset inside the discipline, then
+that value is unchanged.
+If the \f3unset\fP discipline is defined for a variable, it is invoked
+whenever the given variable is unset.
+The variable will not be unset unless it is unset explicitly
+from within this discipline function.
+.PP
+The variable
+.B .sh.name
+contains the name of the variable for which the discipline function is called,
+.B .sh.subscript
+is the subscript of the variable, and
+.B .sh.value
+will contain the value being assigned inside the
+.B .set
+discipline function.
+For the \f3set\fP discipline,
+changing
+.B .sh.value
+will change the value that gets assigned.
+.SS Jobs.
+.PP
+If the
+.B monitor
+option of the
+.B set
+command is turned on,
+an interactive shell associates a \fIjob\fR with each pipeline.
+It keeps
+a table of current jobs, printed by the
+.B jobs
+command, and assigns them small integer numbers.
+When a job is started asynchronously with
+.BR & ,
+the shell prints a line which looks
+like:
+.PP
+.DT
+ [1] 1234
+.PP
+indicating that the job which was started asynchronously was job number
+1 and had one (top-level) process, whose process id was 1234.
+.PP
+This paragraph and the next require features that are
+not in all versions of UNIX and may not apply.
+If you are running a job and wish to do something else you may hit the key
+\fB^Z\fR (control-Z) which sends a STOP signal to the current job.
+The shell will then normally indicate that the job has been `Stopped',
+and print another prompt.
+You can then manipulate the state of this job,
+putting it in the background with the
+.B bg
+command, or run some other
+commands and then eventually bring the job back into the foreground with
+the foreground command
+.BR fg .
+A \fB^Z\fR takes effect immediately and
+is like an interrupt in that pending output and unread input are discarded
+when it is typed.
+.PP
+A job being run in the background will stop if it tries to read
+from the terminal.
+Background jobs are normally allowed to produce output,
+but this can be disabled by giving the command
+.BR "stty tostop" .
+If you set this
+tty option, then background jobs will stop when they try to produce
+output like they do when they try to read input.
+.PP
+There are several ways to refer to jobs in the shell.
+A job can be referred to by the process id of any process of the job
+or by one of the following:
+.PD 0
+.TP
+.BI % number
+The job with the given number.
+.TP
+.BI % string
+Any job whose command line begins with
+.IR string .
+.TP
+.BI %? string
+Any job whose command line contains
+.IR string .
+.TP
+.BI %%
+Current job.
+.TP
+.BI %+
+Equivalent to
+.BR %% .
+.TP
+.BI %\-
+Previous job.
+.PD
+.PP
+The shell learns immediately whenever a process changes state.
+It normally informs you whenever a job becomes blocked so that
+no further progress is possible, but only just before it prints
+a prompt.
+This is done so that it does not otherwise disturb your work.
+The
+.B notify
+option of the
+.B set
+command causes
+the shell to print these job change messages
+as soon as they occur.
+.PP
+When the
+.B monitor
+option is on, each background job that completes
+triggers any trap set for
+.BR CHLD .
+.PP
+When you try to leave the shell while jobs are running or stopped, you will
+be warned that `You have stopped(running) jobs.'
+You may use the
+.B jobs
+command to see what they are.
+If you immediately try to
+exit again, the shell will not warn you a second time, and the stopped
+jobs will be terminated.
+When a login shell receives a HUP signal, it sends
+a HUP signal to each job that has not been disowned with the
+.B disown
+built-in command described below.
+.SS Signals.
+The \s-1INT\s+1 and \s-1QUIT\s+1 signals for an invoked
+command are ignored if the command is followed by
+.B &
+and the
+.B monitor
+option is not active.
+Otherwise, signals have the values
+inherited by the shell from its parent
+(but see also
+the
+.B trap
+built-in command below).
+.SS Execution.
+Each time a command is read, the above substitutions
+are carried out.
+If the command name matches one
+of the
+.I "Special Built-in Commands\^"
+listed below,
+it is executed within the
+current shell process.
+Next, the command name is checked to see if
+it matches a user defined function.
+If it does,
+the positional parameters are saved
+and then reset to the arguments of the
+.I function\^
+call.
+A function is also executed in the
+current shell process.
+When the
+.I function\^
+completes or issues a
+.BR return ,
+the positional parameter list is restored.
+For functions defined with the
+.B function
+.I name\^
+syntax,
+any trap set on
+.SM
+.B EXIT
+within the function is executed.
+The exit value of a
+.I function\^
+is the value of the last command executed.
+If a command name is not a
+.I "special built-in command\^"
+or a user defined
+.IR function ,
+but it is one of the built-in commands listed below,
+it is executed in the current shell process.
+.PP
+The shell variable
+.B
+.SM PATH
+defines the search path for
+the directory containing the command.
+Alternative directory names are separated by
+a colon
+.RB ( : ).
+The default path is
+.B /bin:/usr/bin:
+(specifying
+.BR /bin ,
+.BR /usr/bin ,
+and the current directory
+in that order).
+The current directory can be specified by
+two or more adjacent colons, or by a colon
+at the beginning or end of the path list.
+If the command name contains a \f3/\fP, then the search path
+is not used.
+Otherwise, each directory in the path is
+searched for an executable file
+of the given name
+that is not a directory.
+If found, and if the shell
+determines that there is a built-in version
+of a command corresponding to a given pathname,
+this built-in is invoked in the current process.
+If found, and this directory is also contained in the value of the
+.B
+.SM FPATH
+variable,
+then this file is loaded into the current shell environment
+as if it were the argument to the \fB.\fP command
+except that only preset aliases are expanded,
+and a function of the given name is executed
+as described above.
+If not found, and the file
+.B .paths
+is found, and the this file contains a line of the form
+.BI FPATH= path
+where
+.I path\^
+names an
+existing directory, and this directory contains
+a file of the given name,
+then this file is loaded into the current shell environment
+as if it were the argument to the \fB.\fP special built-in command
+and a function of the given name is executed.
+Otherwise, if found,
+a process is created and
+an attempt is made to execute the command via
+.IR exec (2).
+.P
+When an executable is found, the directory where it is found
+in is searched for a file named
+.BR .paths .
+If this file is found and it contains a line of the form
+.BI BUILTIN_LIB= value\^
+, then the library named by
+.I value\^
+will be searched for as if it were an option argument to
+.BR "builtin -f" ,
+and if it contains a built-in of the specified name
+this will be executed instead of a command by this name.
+Otherwise, if this file is found and it contains a line of the form
+.IB name\^ = value\^
+in the first or second line, then the environment variable
+.I name\^
+is modified by prepending the directory specified by
+.I value\^
+to the directory list.
+If
+.I value\^
+is not an absolute directory, then it
+specifies a directory relative to the directory that the
+executable was found.
+If the environment variable
+.I name\^
+does not already exist it will be added to the environment
+list for the specified command.
+.P
+If the file has execute permission but is not an
+.B a.out
+file,
+it is assumed to be a file containing shell commands.
+A separate shell is spawned to read it.
+All non-exported variables are removed in this case.
+If the shell command
+file doesn't have read permission,
+or if the
+.I setuid
+and/or
+.I setgid
+bits are set on the file,
+then the shell executes an agent whose job it is to
+set up the permissions and execute the shell with the
+shell command file passed down as an open file.
+A parenthesized command is executed in
+a sub-shell without removing non-exported variables.
+.SS Command Re-entry.
+The text of the last
+.B
+.SM
+HISTSIZE
+(default 512)
+commands entered from a terminal device
+is saved in a
+.I history
+file.
+The file
+.B \s-1$HOME\s+1/.sh_history
+is used if the
+.B
+.SM
+HISTFILE
+variable is not set
+or if the file it names is not writable.
+A shell can access the commands of
+all
+.I interactive
+shells which use the same named
+.SM
+.BR HISTFILE .
+The built-in command
+.B hist\^
+is used to list or
+edit a portion of this file.
+The portion of the file to be edited or listed can be selected by
+number or by giving the first character or
+characters of the command.
+A single command or range of commands can be specified.
+If you do not specify an editor program as
+an argument to
+.B hist\^
+then the value of the variable
+.SM
+.B HISTEDIT
+is used.
+If
+.SM
+.B HISTEDIT
+is unset, the obsolete variable
+.SM
+.B FCEDIT
+is used.
+If
+.SM
+.B FCEDIT
+is not defined, then
+.B /bin/ed
+is used.
+The edited command(s) is printed and re-executed upon
+leaving the editor unless you quit without writing.
+The
+.B \-s
+option
+(and in obsolete versions, the editor name
+.BR \-\^ )
+is used to skip the editing phase and
+to re-execute the command.
+In this case a substitution parameter of the form
+\f2old\fP\f3=\fP\f2new\fP
+can be used to modify the command before execution.
+For example, with the preset alias
+.BR r ,
+which is aliased to
+.BR "\(fmhist \-s\(fm" ,
+typing
+`\f3r bad=good c\fP'
+will re-execute the most recent command which starts with the letter
+.BR c ,
+replacing the first occurrence of the string
+.B bad
+with the string
+.BR good .
+.SS In-line Editing Options.
+Normally, each command line entered from a terminal device is simply
+typed followed by a \f3new-line\fP (`RETURN' or `LINE\ FEED').
+If either the
+.BR emacs ,
+.BR gmacs ,
+or
+.B vi
+option is active, the user can edit the command line.
+To be in either of these edit modes
+.B set
+the corresponding
+option.
+An editing option is automatically selected each time the
+.SM
+.B VISUAL
+or
+.SM
+.B EDITOR
+variable is assigned a value ending in either of these
+option names.
+.PP
+The editing features require that the user's terminal
+accept `RETURN' as carriage return without line feed
+and that a space (`\ ') must overwrite the current character on
+the screen.
+.PP
+Unless the
+.B multiline
+option is on,
+the editing modes implement a concept where the user is looking through a
+window at the current line.
+The window width is the value of
+.SM
+.B COLUMNS
+if it is defined, otherwise 80.
+If the window width is too small to display the prompt and leave
+at least 8 columns to enter input, the prompt is truncated from the
+left.
+If the line is longer than the window width minus two, a mark is
+displayed at the end of the window to notify the user.
+As the cursor moves and reaches the window boundaries the window will be
+centered about the cursor.
+The mark is a
+.BR > " (<" ,
+.BR * )
+if the line extends on the
+right (left, both) side(s) of the window.
+.PP
+The search commands in each edit mode provide access to the history file.
+Only strings are matched, not patterns, although a leading
+.B ^
+in the string restricts the match
+to begin at the first character in the line.
+.PP
+Each of the edit modes has an operation to list the files
+or commands that match a partially entered word.
+When applied to the first word on the line,
+or the first word after a
+.BR ; ,
+.BR \(bv ,
+.BR & ,
+or
+.BR ( ,
+and the word does not begin with
+.B \(ap
+or contain a
+.BR / ,
+the list of aliases, functions, and executable commands
+defined by the
+.B
+.SM PATH
+variable that could match the partial word is displayed.
+Otherwise, the list of files that match the given
+word is displayed.
+If the partially entered word does not contain any
+file expansion characters, a
+.B *
+is appended before generating these lists.
+After displaying the generated list, the input line
+is redrawn.
+These operations are called command name listing and file name listing,
+respectively.
+There are additional operations, referred to as command name
+completion and file name completion, which compute the list
+of matching commands or files, but instead of printing the list,
+replace
+the current word with a complete or partial match.
+For file name completion,
+if the match is unique, a
+.B /
+is appended if the file is a directory and a space is
+appended if the file is not a directory.
+Otherwise, the longest common prefix for all the matching
+files replaces the word.
+For command name completion, only the portion of the file names
+after the last
+.B /
+are used to find the longest command prefix.
+If only a single name matches this prefix, then the
+word is replaced with the command name followed by a space.
+When using a
+.I tab\^
+for completion that does not yield a unique match,
+a subsequent
+.I tab\^
+will provide a numbered list of matching alternatives.
+A specific selection can be made by entering the
+selection number followed by a
+.IR tab .
+.SS Key Bindings.
+The
+.B
+.SM KEYBD
+trap can be used to intercept keys as they are typed
+and change the characters that are actually seen by
+the shell.
+This trap is executed after each character
+(or sequence of characters when the first character is ESC)
+is entered while reading from a terminal.
+The variable
+.B .sh.edchar
+contains the character or character sequence which
+generated the trap.
+Changing the value of
+.B .sh.edchar
+in the trap action causes the shell to behave as if the
+new value were entered from the keyboard rather than
+the original value.
+.PP
+The variable
+.B .sh.edcol
+is set to the input column number of the cursor at the time
+of the input.
+The variable
+.B .sh.edmode
+is set to
+ESC
+when in
+.B vi
+insert mode (see below) and is null otherwise.
+By prepending
+.B ${.sh.editmode}
+to a value assigned to
+.B .sh.edchar
+it will cause the shell
+to change to control mode if it is not already in this mode.
+.PP
+This trap is not invoked for characters entered as arguments to
+editing directives, or while reading input for a character search.
+.SS Emacs Editing Mode.
+This mode is entered by enabling either the
+.B emacs
+or
+.B gmacs
+option.
+The only difference between these two modes is the way
+they handle
+.BR ^T .
+To edit, the user
+moves the cursor to the point needing correction and
+then inserts or deletes characters or words as needed.
+All the editing commands are control characters or escape
+sequences.
+The notation for control characters is caret
+.RB ( ^ )
+followed
+by the character.
+For example,
+.B ^F
+is the notation for control
+.BR F .
+This is entered by depressing `f' while holding down the
+`CTRL' (control) key.
+The `SHIFT' key is
+.I not
+depressed.
+(The notation
+.B ^?
+indicates the DEL (delete) key.)
+.PP
+The notation for escape sequences is
+.B M-
+followed by a
+character.
+For example,
+.B M-f
+(pronounced Meta f)
+is entered by depressing ESC
+(ascii
+.BR 033 )
+followed by `f'.
+.RB ( M-F
+would be the notation for ESC followed by `SHIFT' (capital) `F'.)
+.PP
+All edit commands
+operate from any place on the line
+(not just at the beginning).
+Neither the `RETURN' nor the `LINE FEED' key is
+entered after edit commands except when noted.
+.PP
+.PD 0
+.TP 10
+.BI ^F
+Move cursor forward (right) one character.
+.PP
+.TP 10
+.BI M-[C
+Move cursor forward (right) one character.
+.PP
+.TP 10
+.BI M-f
+Move cursor forward one word.
+(The
+.B emacs
+editor's idea of a word is a string of characters
+consisting of only letters, digits and underscores.)
+.PP
+.TP 10
+.BI ^B
+Move cursor backward (left) one character.
+.PP
+.TP 10
+.BI M-[D
+Move cursor backward (left) one character.
+.PP
+.TP 10
+.BI M-b
+Move cursor backward one word.
+.PP
+.TP 10
+.BI ^A
+Move cursor to start of line.
+.PP
+.TP 10
+.BI M-[H
+Move cursor to start of line.
+.PP
+.TP 10
+.BI ^E
+Move cursor to end of line.
+.PP
+.TP 10
+.BI M-[Y
+Move cursor to end of line.
+.PP
+.TP 10
+.BI ^] char
+Move cursor forward to character
+.I char
+on current line.
+.PP
+.TP 10
+.BI M-^] char
+Move cursor backward to character
+.I char
+on current line.
+.PP
+.TP 10
+.BI ^X^X
+Interchange the cursor and mark.
+.PP
+.TP 10
+.I erase
+(User defined erase character as defined
+by the
+.IR stty (1)
+command, usually
+.B ^H
+or
+.BR # .)
+Delete previous character.
+.PP
+.TP 10
+.I lnext
+(User defined literal next character as defined
+by the
+.IR stty (1)
+command.
+or
+.B ^V
+if not defined.)
+Removes the next character's
+editing features (if any).
+.PP
+.TP 10
+.BI ^D
+Delete current character.
+.PP
+.TP 10
+.BI M-d
+Delete current word.
+.PP
+.TP 10
+.BI M-^H
+(Meta-backspace) Delete previous word.
+.PP
+.TP 10
+.BI M-h
+Delete previous word.
+.PP
+.TP 10
+.BI M-^?
+(Meta-DEL) Delete previous word (if your interrupt character is
+.B ^?
+(DEL, the default) then this command will not work).
+.PP
+.TP 10
+.BI ^T
+Transpose current character with previous character
+and advance the cursor
+in
+.I emacs
+mode.
+Transpose two previous characters in
+.I gmacs
+mode.
+.PP
+.TP 10
+.BI ^C
+Capitalize current character.
+.PP
+.TP 10
+.BI M-c
+Capitalize current word.
+.PP
+.TP 10
+.BI M-l
+Change the current word to lower case.
+.PP
+.TP 10
+.BI ^K
+Delete from the cursor to the end of the line.
+If preceded by a numerical parameter whose value is less than the
+current cursor position, then delete from given position
+up to the cursor.
+If preceded by a numerical parameter whose value is greater than the
+current cursor position, then delete from cursor up to
+given cursor position.
+.PP
+.TP 10
+.BI ^W
+Kill from the cursor to the mark.
+.PP
+.TP 10
+.BI M-p
+Push the region from the cursor to the mark on the stack.
+.PP
+.TP 10
+.I kill
+(User defined kill character as defined
+by the stty command, usually
+.B ^G
+or
+.BR @ .)
+Kill the entire current line.
+If two
+.I kill
+characters are entered in succession, all
+kill characters from then on cause a line feed
+(useful when using paper terminals).
+.PP
+.TP 10
+.BI ^Y
+Restore last item removed from line. (Yank item back to the line.)
+.PP
+.TP 10
+.BI ^L
+Line feed and print current line.
+.PP
+.TP 10
+.BI M-^L
+Clear the screen.
+.PP
+.TP 10
+.BI ^@
+(Null character) Set mark.
+.PP
+.TP 10
+.BI M- space
+(Meta space) Set mark.
+.PP
+.TP 10
+.BI ^J
+(New\ line) Execute the current line.
+.PP
+.TP 10
+.BI ^M
+(Return) Execute the current line.
+.PP
+.TP 10
+.I eof
+End-of-file character,
+normally
+.BR ^D ,
+is processed as an End-of-file only
+if the current line is null.
+.PP
+.TP 10
+.BI ^P
+Fetch previous command.
+Each time
+.B ^P
+is entered
+the previous command back in time is accessed.
+Moves back one line when not on the first line of a multi-line command.
+.PP
+.TP 10
+.BI M-[A
+Equivalent to
+.BR ^P.
+.PP
+.TP 10
+.BI M-<
+Fetch the least recent (oldest) history line.
+.PP
+.TP 10
+.BI M->
+Fetch the most recent (youngest) history line.
+.PP
+.TP 10
+.BI ^N
+Fetch next command line.
+Each time
+.B ^N
+is entered
+the next command line forward in time is accessed.
+.PP
+.TP 10
+.BI M-[B
+Equivalent to
+.BR ^N.
+.PP
+.TP 10
+.BI ^R string
+Reverse search history for a previous command line containing
+.IR string .
+If a parameter of zero is given, the search is forward.
+.I String
+is terminated by a `RETURN' or `NEW\ LINE'.
+If string is preceded by a
+.BR ^ ,
+the matched line must begin with
+.IR string .
+If
+.I string
+is omitted,
+then the next command line containing the most recent
+.I string
+is accessed.
+In this case a parameter of zero
+reverses the direction of the search.
+.PP
+.TP 10
+.B ^O
+Operate \- Execute the current line and fetch
+the next line relative to current line from the
+history file.
+.PP
+.TP 10
+.BI M- digits
+(Escape) Define numeric parameter, the digits
+are taken as a parameter to the next command.
+The commands that accept a parameter are
+.BR ^F ,
+.BR ^B ,
+.IR erase ,
+.BR ^C ,
+.BR ^D ,
+.BR ^K ,
+.BR ^R ,
+.BR ^P ,
+.BR ^N ,
+.BR ^] ,
+.BR M-. ,
+.BR M-^] ,
+.BR M-_ ,
+.BR M-= ,
+.BR M-b ,
+.BR M-c ,
+.BR M-d ,
+.BR M-f ,
+.BR M-h ,
+.B M-l
+and
+.BR M-^H .
+.PP
+.TP 10
+.BI M- letter
+Soft-key \- Your alias list is searched for an
+alias by the name
+.BI _ letter
+and if an alias of this name is defined, its
+value will be inserted on the input queue.
+The
+.I letter
+must not be one of the above meta-functions.
+.PP
+.TP 10
+.BI M-[ letter
+Soft-key \- Your alias list is searched for an
+alias by the name
+.BI _\&_ letter
+and if an alias of this name is defined, its
+value will be inserted on the input queue.
+The can be used to program functions keys on many terminals.
+.PP
+.TP 10
+.B M-.
+The last word of the previous command is inserted
+on the line.
+If preceded by a numeric parameter, the value
+of this parameter determines which word to insert rather than
+the last word.
+.PP
+.TP 10
+.B M-_
+Same as
+.BR M-. .
+.PP
+.TP 10
+.B M-*
+Attempt file name generation on the current word.
+An asterisk is appended if the word doesn't match any file
+or contain any special
+pattern characters.
+.PP
+.TP 10
+.B M-ESC
+Command or file name completion as described above.
+.PP
+.TP 10
+.BI ^I " tab"
+Attempts command or file name completion as described above.
+If a partial completion occurs, repeating this will
+behave as if
+.B M-=
+were entered.
+If no match is found or entered after
+.IR space\^ ,
+a
+.I tab\^
+is inserted.
+.PP
+.TP 10
+.B M-=
+If not preceded by a numeric parameter,
+it generates the list of matching commands or
+file names as described above.
+Otherwise, the word under the cursor is replaced by
+the item corresponding to the value of the numeric parameter
+from the most recently generated command or file list.
+If the cursor is not on a word, it is inserted instead.
+.PP
+.TP 10
+.BI ^U
+Multiply parameter of next command by 4.
+.PP
+.TP 10
+.BI \e
+Escape next character.
+Editing characters, the user's erase, kill and
+interrupt (normally
+.BR ^? )
+characters
+may be entered
+in a command line or in a search string if preceded by a
+.BR \e .
+The
+.B \e
+removes the next character's
+editing features (if any).
+.PP
+.TP 10
+.B M-^V
+Display version of the shell.
+.PP
+.TP 10
+.B M-#
+If the line does not begin with a
+.BR # ,
+a
+.B #
+is inserted
+at the beginning of the line
+and after each new-line,
+and the line is entered.
+This causes a comment to be inserted in the history file.
+If the line begins with a
+.BR # ,
+the
+.B #
+is deleted and one
+.B #
+after each new-line is also deleted.
+.PD
+.SS Vi Editing Mode.
+There are two typing modes.
+Initially, when you enter a command you are in the
+.I input\^
+mode.
+To edit, the user enters
+.I control\^
+mode by typing ESC
+.RB ( 033 )
+and moves the cursor to the point needing correction and
+then inserts or deletes characters or words as needed.
+Most control commands accept an optional repeat
+.I count
+prior to the command.
+.PP
+When in
+.B vi
+mode on most systems,
+canonical processing is initially enabled and the
+command will be echoed again if the speed is 1200 baud or greater and it
+contains any control characters or less than one second has elapsed
+since the prompt was printed.
+The ESC character terminates canonical processing for the remainder of the command
+and the user can then modify the command line.
+This scheme has the advantages of canonical processing with the type-ahead
+echoing of raw mode.
+.PP
+If the option
+.B viraw
+is also set, the terminal will always have canonical processing
+disabled.
+This mode is implicit for systems that do not support two
+alternate end of line delimiters,
+and may be helpful for certain terminals.
+.SS "\ \ \ \ \ Input Edit Commands"
+.PP
+.RS
+By default the editor is in input mode.
+.PD 0
+.TP 10
+.I erase
+(User defined erase character as defined
+by the stty command, usually
+.B ^H
+or
+.BR # .)
+Delete previous character.
+.TP 10
+.BI ^W
+Delete the previous blank separated word.
+On some systems the \f3viraw\fP option
+may be required for this to work.
+.TP 10
+.I eof
+As the first character of the line causes
+the shell to terminate unless the \f3ignoreeof\fP
+option is set.
+Otherwise this character is ignored.
+.TP 10
+.I lnext
+(User defined literal next character as defined
+by the
+.IR stty (1)
+or
+.B ^V
+if not defined.)
+Removes the next character's
+editing features (if any).
+On some systems the \f3viraw\fP option
+may be required for this to work.
+.TP 10
+.BI \e
+Escape the next
+.I erase
+or
+.I kill
+character.
+.TP 10
+.BI ^I " tab"
+Attempts command or file name completion as described above
+and returns to input mode.
+If a partial completion occurs, repeating this will
+behave as if
+.B =
+were entered from control mode.
+If no match is found or entered after
+.IR space\^ ,
+a
+.I tab\^
+is inserted.
+.RE
+.SS "\ \ \ \ \ Motion Edit Commands"
+.RS
+These commands will move the cursor.
+.TP 10
+[\f2count\fP]\f3l\fP
+Cursor forward (right) one character.
+.TP 10
+[\f2count\fP]\f3[C\fP
+Cursor forward (right) one character.
+.TP 10
+[\f2count\fP]\f3w\fP
+Cursor forward one alpha-numeric word.
+.TP 10
+[\f2count\fP]\f3W\fP
+Cursor to the beginning of the next word that follows a blank.
+.TP 10
+[\f2count\fP]\f3e\fP
+Cursor to end of word.
+.TP 10
+[\f2count\fP]\f3E\fP
+Cursor to end of the current blank delimited word.
+.TP 10
+[\f2count\fP]\f3h\fP
+Cursor backward (left) one character.
+.TP 10
+[\f2count\fP]\f3[D\fP
+Cursor backward (left) one character.
+.TP 10
+[\f2count\fP]\f3b\fP
+Cursor backward one word.
+.TP 10
+[\f2count\fP]\f3B\fP
+Cursor to preceding blank separated word.
+.TP 10
+[\f2count\fP]\f3\(bv\fP
+Cursor to column
+.IR count .
+.TP 10
+[\f2count\fP]\f3f\fP\f2c\fP
+Find the next character \fIc\fP in the current line.
+.TP 10
+[\f2count\fP]\f3F\fP\f2c\fP
+Find the previous character \fIc\fP in the current line.
+.TP 10
+[\f2count\fP]\f3t\fP\f2c\fP
+Equivalent to
+.B f
+followed by
+.BR h .
+.TP 10
+[\f2count\fP]\f3T\fP\f2c\fP
+Equivalent to
+.B F
+followed by
+.BR l .
+.TP 10
+[\f2count\fP]\f3;\fP
+Repeats
+.I count
+times,
+the last single character find command,
+.BR f ,
+.BR F ,
+.BR t ,
+or
+.BR T .
+.TP 10
+[\f2count\fP]\f3,\fP
+Reverses the last single character find command
+.I count
+times.
+.TP 10
+.B 0
+Cursor to start of line.
+.TP 10
+.B ^
+Cursor to start of line.
+.TP 10
+.B [H
+Cursor to first non-blank character in line.
+.TP 10
+.B $
+Cursor to end of line.
+.TP 10
+.B [Y
+Cursor to end of line.
+.TP 10
+.B %
+Moves to balancing
+.BR ( ,
+.BR ) ,
+.BR { ,
+.BR } ,
+.BR [ ,
+or
+.BR ] .
+If cursor is not on one of the above characters,
+the remainder of the line is searched for the first
+occurrence of one of the above characters first.
+.RE
+.SS "\ \ \ \ \ Search Edit Commands"
+.RS
+These commands access your command history.
+.TP 10
+[\f2count\fP]\f3k\fP
+Fetch previous command.
+Each time
+.B k
+is entered
+the previous command back in time is accessed.
+.TP 10
+[\f2count\fP]\f3\-\fP
+Equivalent to
+.BR k .
+.TP 10
+[\f2count\fP]\f3[A\fP
+Equivalent to
+.BR k .
+.TP 10
+[\f2count\fP]\f3j\fP
+Fetch next command.
+Each time
+.B j
+is entered
+the next command forward in time is accessed.
+.TP 10
+[\f2count\fP]\f3+\fP
+Equivalent to
+.BR j .
+.TP 10
+[\f2count\fP]\f3[B\fP
+Equivalent to
+.BR j .
+.TP 10
+[\f2count\fP]\f3G\fP
+The command number
+.I count
+is fetched.
+The default is the least recent history command.
+.TP 10
+.BI / string
+Search backward through history for a previous command containing
+.IR string .
+.I String
+is terminated by a `RETURN' or `NEW\ LINE'.
+If string is preceded by a
+.BR ^ ,
+the matched line must begin with
+.IR string .
+If \fIstring\fP is null, the previous string will be used.
+.TP 10
+.BI ? string
+Same as
+.B /
+except that search will be in the forward direction.
+.TP 10
+.B n
+Search for next match of the last pattern to
+.B /
+or
+.B ?
+commands.
+.TP 10
+.B N
+Search for next match of the last pattern to
+.B /
+or
+.BR ? ,
+but in reverse direction.
+.RE
+.SS "\ \ \ \ \ Text Modification Edit Commands"
+.RS
+These commands will modify the line.
+.TP 10
+.B a
+Enter input mode and enter text after the current character.
+.TP 10
+.B A
+Append text to the end of the line.
+Equivalent to
+.BR $a .
+.TP 10
+[\f2count\fP]\f3c\fP\f2motion\fP
+.TP 10
+\f3c\fP[\f2count\fP]\f2motion\fP
+Delete current character through the character that
+.I motion
+would move the cursor to and enter input mode.
+If \fImotion\fP is
+.BR c ,
+the entire line will be deleted and
+input mode entered.
+.TP 10
+.B C
+Delete the current character through the end of line and enter input mode.
+Equivalent to
+.BR c$ .
+.TP 10
+.B S
+Equivalent to
+.BR cc .
+.TP 10
+[\f2count\fP]\f3s\fP
+Replace characters under the cursor in input mode.
+.TP 10
+.B D
+Delete the current character through the end of line.
+Equivalent to
+.BR d$ .
+.TP 10
+[\f2count\fP]\f3d\fP\f2motion\fP
+.TP 10
+\f3d\fP[\f2count\fP]\f2motion\fP
+Delete current character through the character that
+.I motion
+would move to.
+If \fImotion\fP is
+.B d ,
+the entire line will be deleted.
+.TP 10
+.B i
+Enter input mode and insert text before the current character.
+.TP 10
+.B I
+Insert text before the beginning of the line.
+Equivalent to
+.BR 0i .
+.TP 10
+[\f2count\fP]\f3P\fP
+Place the previous text modification before the cursor.
+.TP 10
+[\f2count\fP]\f3p\fP
+Place the previous text modification after the cursor.
+.TP 10
+.B R
+Enter input mode and
+replace characters on the screen with characters you type overlay fashion.
+.TP 10
+[\f2count\fP]\f3r\fP\f2c\fP
+Replace the
+.I count
+character(s) starting at the current cursor position with
+.IR c ,
+and advance the cursor.
+.TP 10
+[\f2count\fP]\f3x\fP
+Delete current character.
+.TP 10
+[\f2count\fP]\f3X\fP
+Delete preceding character.
+.TP 10
+[\f2count\fP]\f3.\fP
+Repeat the previous text modification command.
+.TP 10
+[\f2count\fP]\f3\(ap\fP
+Invert the case of the
+.I count
+character(s) starting at the current cursor position and advance the cursor.
+.TP 10
+[\f2count\fP]\f3_\fP
+Causes the
+.I count\^
+word of the previous command to be appended and
+input mode entered.
+The last word is used
+if
+.I count\^
+is omitted.
+.TP 10
+.B *
+Causes an
+.B *
+to be appended to the current word and file name generation attempted.
+If no match is found,
+it rings the bell.
+Otherwise, the word is replaced
+by the matching pattern and input mode is entered.
+.TP 10
+.B \e
+Command or file name completion as described above.
+.RE
+.SS "\ \ \ \ \ Other Edit Commands"
+.RS
+Miscellaneous commands.
+.TP 10
+[\f2count\fP]\f3y\fP\f2motion\fP
+.TP 10
+\f3y\fP[\f2count\fP]\f2motion\fP
+Yank current character through character that
+.I motion
+would move the cursor to and puts them into the delete buffer.
+The text and cursor are unchanged.
+.TP 10
+.B yy
+Yanks the entire line.
+.TP 10
+.B Y
+Yanks from current position to end of line.
+Equivalent to
+.BR y$ .
+.TP 10
+.B u
+Undo the last text modifying command.
+.TP 10
+.B U
+Undo all the text modifying commands performed on the line.
+.TP 10
+[\f2count\fP]\f3v\fP
+Returns the command
+.BI "hist \-e ${\s-1VISUAL\s+1:\-${\s-1EDITOR\s+1:\-vi}}" " count"
+in the input buffer.
+If
+.I count\^
+is omitted, then the current line is used.
+.TP 10
+.BI ^L
+Line feed and print current line.
+Has effect only in control mode.
+.TP 10
+.BI ^J
+(New\ line) Execute the current line, regardless of mode.
+.TP 10
+.BI ^M
+(Return) Execute the current line, regardless of mode.
+.TP 10
+.B #
+If the first character of the command is a
+.BR # ,
+then this command deletes this
+.B #
+and each
+.B #
+that follows a newline.
+Otherwise,
+sends the line after
+inserting a
+.B #
+in front of each line in the command.
+Useful for causing the current line to be
+inserted in the history as a comment and
+uncommenting previously commented commands
+in the history file.
+.TP 10
+[\f2count\fP]\f3=\fP
+If \f2count\fP is not specified,
+it generates the list of matching commands or
+file names as described above.
+Otherwise, the word under the the cursor is replaced by the
+\f2count\fP item from the most recently generated command or file list.
+If the cursor is not on a word, it is inserted instead.
+.TP 10
+.BI @ letter
+Your alias list is searched for an
+alias by the name
+.BI _ letter
+and if an alias of this name is defined, its
+value will be inserted on the input queue for processing.
+.TP 10
+.BI ^V
+Display version of the shell.
+.RE
+.PD
+.SS Built-in Commands.
+The following simple-commands are executed in the shell process.
+Input/Output redirection is permitted.
+Unless otherwise indicated, the output is written on file descriptor 1
+and the exit status, when there is no syntax error, is zero.
+Except for
+.BR : ,
+.BR true ,
+.BR false ,
+.BR echo ,
+.BR newgrp ,
+and
+.BR login ,
+all built-in commands accept
+.B \-\-
+to indicate end of options.
+They also interpret the option
+.B \-\-man
+as a request to display the man page onto
+standard error and
+.B \-?
+as a help request which prints a
+.I usage\^
+message
+on standard error.
+Commands that are preceded by one or two \(dg symbols
+are special built-in commands and
+are treated specially in the following ways:
+.PD 0
+.TP
+1.
+Variable assignment lists preceding the command
+remain in effect when the command completes.
+.TP
+2.
+I/O redirections are processed after variable assignments.
+.TP
+3.
+Errors
+cause a script
+that contains them to abort.
+.TP
+4.
+They are not valid function names.
+.TP
+5.
+Words
+following a command preceded by \(dg\(dg
+that are in the format of a variable assignment
+are expanded with the same rules as a variable assignment.
+This means that
+tilde substitution is performed after the
+.B =
+sign and field splitting and file name generation are not
+performed.
+.PD
+.TP
+\(dg \f3:\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
+The command only expands parameters.
+.br
+.ne 2
+.TP
+\(dg \f3\|. \f2name\^\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
+If
+.I name\^
+is a function defined with the
+.B function
+.I name\^
+reserved word syntax,
+the function is executed in the current environment
+(as if it had been defined with the
+.IB name ()
+syntax.)
+Otherwise if
+.I name\^
+refers to a file, the
+file is read in its entirety and the commands are
+executed in the current shell environment.
+The search path
+specified by
+.B
+.SM PATH
+is used to find the directory containing the file.
+If any arguments
+.I arg\^
+are given,
+they become the positional parameters while processing
+the
+.B .
+command and the original positional parameters are restored upon completion.
+Otherwise the positional parameters are unchanged.
+The exit status is the exit status of the last command executed.
+.TP
+\(dg\(dg \f3alias\fP \*(OK \f3\-ptx\fP \*(CK \*(OK \f2name\fP\*(OK \f3=\fP\f2value\^\fP \*(CK \*(CK .\|.\|.
+.B alias\^
+with no arguments prints the list of aliases
+in the form
+.I name=value\^
+on standard output.
+The
+.B \-p
+option
+causes the word
+.B alias
+to be inserted before each one.
+When one or more arguments are given,
+an
+.I alias\^
+is defined
+for each
+.I name\^
+whose
+.I value\^
+is given.
+A trailing space in
+.I value\^
+causes the next word to be checked for
+alias substitution.
+The obsolete
+.B \-t
+option is used to set and list tracked aliases.
+The value of a tracked alias is the full pathname
+corresponding to the given
+.IR name .
+The value becomes undefined when the value of
+.SM
+.B PATH
+is reset but the alias remains tracked.
+Without the
+.B \-t
+option,
+for each
+.I name\^
+in the argument list
+for which no
+.I value\^
+is given, the name
+and value of the alias is printed.
+The obsolete
+.B \-x
+option has no effect.
+The exit status is non-zero if a
+.I name\^
+is given, but no value, and no alias has been defined for the
+.IR name\^ .
+.TP
+\f3bg\fP \*(OK \f2job\^\fP.\|.\|. \*(CK
+This command is only on systems that support job control.
+Puts each specified
+.I job\^
+into the background.
+The current job is put in the background
+if
+.I job\^
+is not specified.
+See
+.I Jobs
+for a description of the format of
+.IR job .
+.TP
+\(dg \f3break\fP \*(OK \f2n\^\fP \*(CK
+Exit from the enclosing
+.BR for\^ ,
+.BR while\^ ,
+.BR until\^ ,
+or
+.B select\^
+loop, if any.
+If
+.I n\^
+is specified, then break
+.I n\^
+levels.
+.TP
+\f3builtin\fP \*(OK \f3\-ds\fP \*(CK \*(OK \f3\-f\fP \f2file\^\fP \*(CK \*(OK \f2name\^\fP .\|.\|. \*(CK
+If
+.I name\^
+is not specified,
+and no
+.B \-f
+option is specified,
+the built-ins are printed on standard output.
+The
+.B \-s
+option prints only the special built-ins.
+Otherwise, each
+.I name\^
+represents the pathname whose basename is the name of the built-in.
+The entry point function name is determined by prepending
+.B b_
+to the built-in name.
+The ISO C/C++ prototype is
+\f3b_\fP\f2mycommand\fP\f3(int\fP \f2argc\fP, \f3char *\fP\f2argv\fP\f3[]\fP, \f3void *\fP\f2context\fP\f3)\fP
+for the builtin command
+.I mycommand\^
+where
+.I argv\^
+is array an of
+.I argc\^
+elements and context is an optional pointer to a
+.B Shell_t
+structure as described in
+.BR <ast/shell.h> .
+.sp .5
+Special built-ins cannot be bound to a pathname or deleted.
+The
+.B \-d
+option deletes each of the given built-ins.
+On systems that support dynamic loading, the
+.B \-f
+option names a shared library containing the code for built-ins.
+The shared library prefix and/or suffix, which depend on the system,
+can be omitted.
+Once a library is loaded, its symbols become available
+for subsequent invocations of
+.BR builtin .
+Multiple libraries can be specified with separate invocations
+of the
+.B builtin
+command.
+Libraries are searched in the reverse order in which they are specified.
+When a library is loaded, it looks for a function in the library
+whose name is
+.B lib_init()
+and invokes this function with an argument of
+.BR 0 .
+.TP
+.PD 0
+\f3cd\fP \*(OK \f3\-LP\fP \*(CK \*(OK \f2arg\^\fP \*(CK
+.TP
+\f3cd\fP \*(OK \f3\-LP\fP \*(CK \f2old\^\fP \f2new\^\fP
+.PD
+This command can be in either of two forms.
+In the first form it
+changes the current directory to
+.IR arg .
+If
+.I arg\^
+is
+.B \-
+the directory is changed to the previous
+directory.
+The shell
+variable
+.B
+.SM HOME
+is the default
+.IR arg .
+The variable
+.SM
+.B PWD
+is set to the current directory.
+The shell variable
+.B
+.SM CDPATH
+defines the search path for
+the directory containing
+.IR arg .
+Alternative directory names are separated by
+a colon
+.RB ( : ).
+The default path is
+.B <null>
+(specifying the current directory).
+Note that the current directory is specified by a null path name,
+which can appear immediately after the equal sign
+or between the colon delimiters anywhere else in the path list.
+If
+.I arg
+begins with a \f3/\fP then the search path
+is not used.
+Otherwise, each directory in the path is
+searched for
+.IR arg .
+.sp .5
+The second form of
+.B cd
+substitutes the string
+.I new
+for the string
+.I old
+in the current directory name,
+.SM
+.BR PWD ,
+and tries to change to this new directory.
+.sp .5
+By default, symbolic link names are treated literally when
+finding the directory name.
+This is equivalent to the
+.B \-L
+option.
+The
+.B \-P
+option causes
+symbolic links to be resolved when determining the directory.
+The last instance of
+.B \-L
+or
+.B \-P
+on the command line
+determines which method is used.
+.sp .5
+The
+.B cd\^
+command may not be executed by
+.if \nZ=0 .B rsh\^.
+.if \nZ=1 .B rksh\^.
+.if \nZ=1 .B rksh93\^.
+.TP
+\f3command\fP \*(OK \f3\-pvxV\fP \*(CK \f2name\^\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
+Without the
+.B \-v
+or
+.B \-V
+options,
+.B command
+executes
+.I name\^
+with the arguments given by
+.IR arg .
+The
+.B \-p
+option causes
+a default path to be searched
+rather than the one defined by the value of
+.SM
+.BR PATH .
+Functions will not be searched for when finding
+.IR name .
+In addition, if
+.I name\^
+refers to a special built-in,
+none of the special properties associated with the leading
+daggers will be honored.
+(For example, the predefined alias
+.B "redirect=\(fmcommand exec\(fm"
+prevents a script from terminating when an invalid
+redirection is given.)
+With the
+.B \-x
+option,
+if command execution would result in a failure because
+there are too many arguments, errno
+.SM
+.BR E2BIG ,
+the shell will invoke command
+.I name\^
+multiple times with a subset of the arguments on each invocation.
+Arguments that occur prior to the first word that
+expands to multiple arguments and after the last word
+that expands to multiple arguments will be passed on each invocation.
+The exit status will be the maximum invocation exit status.
+With the
+.B \-v
+option,
+.B command
+is equivalent to the built-in
+.B whence
+command described below.
+The
+.B \-V
+option causes
+.B command
+to act like
+.BR "whence \-v" .
+.TP
+\(dg \f3continue\fP \*(OK \f2n\^\fP \*(CK
+Resume the next iteration of the enclosing
+.BR for\^ ,
+.BR while\^ ,
+.BR until\^ ,
+or
+.B select\^
+loop.
+If
+.I n\^
+is specified, then resume at the
+.IR n -th
+enclosing loop.
+.TP
+\f3disown\fP \*(OK \f2job\^\fP.\|.\|. \*(CK
+Causes the shell not to send a HUP signal to
+each given
+.IR job ,
+or all active jobs if
+.I job
+is omitted,
+when a login shell terminates.
+.TP
+\f3echo\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
+When the first
+.I arg\^
+does not begin with a \-, and
+none of the arguments contain a \e,
+then
+.B echo
+prints each of its arguments separated by a space
+and terminated by a new-line.
+Otherwise, the behavior of
+.B echo
+is system dependent
+and
+.B print
+or
+.B printf
+described below should be used.
+See
+.IR echo (1)
+for usage and description.
+.TP
+\(dg \f3eval\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
+The arguments are read as input
+to the shell
+and the resulting command(s) executed.
+.TP
+\(dg \f3exec\fP \*(OK \f3\-c\fP \*(CK \*(OK \f3\-a\fP \f2name\^\fP \*(CK \*(OK \f2arg\^\fP .\|.\|. \*(CK
+If
+.I arg\^
+is given,
+the command specified by
+the arguments is executed in place of this shell
+without creating a new process.
+The
+.B \-c
+option causes the environment to be cleared before applying
+variable assignments associated with the
+.B exec
+invocation.
+The
+.B \-a
+option
+causes
+.I name\^
+rather than the first
+.IR arg ,
+to become
+.B argv[0]
+for the new process.
+Input/output arguments may appear and
+affect the current process.
+If
+.I arg\^
+is not given,
+the effect of this command is to
+modify file descriptors
+as prescribed by the input/output redirection list.
+In this case,
+any file descriptor numbers greater than 2 that are
+opened with this mechanism are closed when invoking
+another program.
+.TP
+\(dg \f3exit\fP \*(OK \f2n\^\fP \*(CK
+Causes the shell to exit
+with the exit status specified by
+.IR n .
+The value will be the least significant 8 bits of the specified status.
+If
+.I n\^
+is omitted, then the exit status is that of the last command executed.
+An end-of-file will also cause the shell to exit
+except for a
+shell which has the
+.B ignoreeof
+option (see
+.B set
+below) turned on.
+.TP
+\(dg\(dg \f3export\fP \*(OK \f3\-p\fP \*(CK \*(OK \f2name\^\fP\*(OK\f3=\fP\f2value\^\fP\*(CK \*(CK .\|.\|.
+If
+.I name\^
+is not given,
+the names and values of each variable with
+the export attribute are printed with the values
+quoted in a manner that allows them to be re-input.
+The
+.B \-p
+option
+causes the word
+.B export
+to be inserted before each one.
+Otherwise, the given
+.IR name s
+are marked for automatic
+export to the
+.I environment\^
+of subsequently-executed commands.
+.TP
+\f3false\fP
+Does nothing, and exits 1. Used with
+.B until
+for infinite loops.
+.TP
+\f3fg\fP \*(OK \f2job\^\fP.\|.\|. \*(CK
+This command is only on systems that support job control.
+Each
+.I job\^
+specified is brought to the foreground and waited for in
+the specified order.
+Otherwise, the current job is
+brought into the foreground.
+See
+.I Jobs
+for a description of the format of
+.IR job .
+.TP
+\f3getconf\fP \*(OK \f2name\^\fP \*(OK \f2pathname\^\fP \*(CK \*(CK
+Prints the current value of the configuration parameter given by
+.IR name .
+The configuration parameters are defined by the IEEE POSIX 1003.1
+and IEEE POSIX 1003.2 standards.
+(See
+.IR pathconf (2)
+and
+.IR sysconf (2).)
+The
+.I pathname
+argument is required for parameters whose value depends on
+the location in the file system.
+If no arguments are given,
+.B getconf
+prints the names and values of the current configuration
+parameters.
+The pathname
+.B /
+is used for each of the parameters that requires
+.IR pathname .
+.TP
+\f3getopts\fP \*(OK \f3\ -a\fP \f2name\^\fP \*(CK \f2optstring vname\^\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
+Checks
+.I arg
+for legal options.
+If
+.I arg
+is omitted,
+the positional parameters are used.
+An option argument begins with a
+.B +
+or a
+.BR \- .
+An option not beginning with
+.B +
+or
+.B \-
+or the argument
+.B \-\|\-
+ends the options.
+Options beginning with
+.B +
+are only recognized when
+.I optstring\^
+begins with a
+.BR + .
+.I optstring\^
+contains the letters that
+.B getopts
+recognizes.
+If a letter is followed by a
+.BR : ,
+that option is expected to have an argument.
+The options can be separated from the argument by blanks.
+The option
+.B \-?
+causes
+.B getopts
+to generate a usage message on standard error.
+The
+.B \-a
+argument can be used to specify the name to use for the
+usage message, which defaults to
+.BR $0 .
+.sp .5
+.B
+getopts
+places the next option letter it finds inside variable
+.I vname\^
+each time it is invoked.
+The option letter will be prepended with a
+.B +
+when
+.I arg
+begins with a
+.BR + .
+The index of the next
+.I arg
+is stored in
+.SM
+.BR OPTIND .
+The option argument,
+if any,
+gets stored in
+.SM
+.BR OPTARG .
+.sp .5
+A leading
+.B :
+in
+.I optstring
+causes
+.B getopts
+to store the letter of an invalid
+option in
+.SM
+.BR OPTARG ,
+and to set
+.I vname
+to
+.B ?
+for an unknown option and to
+.B :
+when a required option argument is missing.
+Otherwise,
+.B getopts
+prints an error message.
+The exit status is non-zero when there are no more options.
+.sp .5
+There is no way to specify any of the options
+.BR : ,
+.BR + ,
+.BR \- ,
+.BR ? ,
+.BR [ ,
+and
+.BR ] .
+The option
+.B #
+can only be specified as the first option.
+.TP
+.PD 0
+\f3hist\fP \*(OK \f3\-e\fP \f2ename\^\fP \ \*(CK \*(OK \f3\-nlr\^\fP \*(CK \*(OK \f2first\^\fP \*(OK \f2last\^\fP \*(CK \*(CK
+.TP
+\f3hist \-s \fP \*(OK \f2old\fP\f3\=\fP\f2new\^\fP \*(CK \*(OK \f2command\^\fP \*(CK
+.PD
+In the first form,
+a range of commands from
+.I first\^
+to
+.I last\^
+is selected from the last
+.SM
+.B HISTSIZE
+commands that were typed at the terminal.
+The arguments
+.I first\^
+and
+.I last\^
+may be specified as a number or as a string.
+A string is used to locate the most recent command starting with
+the given string.
+A negative number is used as an offset to the current command number.
+If the
+.B \-l
+option
+is selected,
+the commands are listed on standard output.
+Otherwise, the editor program
+.I ename\^
+is invoked on a file containing these
+keyboard commands.
+If
+.I ename\^
+is not supplied, then the value of the variable
+.SM
+.B HISTEDIT
+is used.
+If
+.SM
+.B HISTEDIT
+is not set, then
+.SM
+.B FCEDIT
+(default
+.BR /bin/ed\^ )
+is used as the editor.
+When editing is complete, the edited command(s)
+is executed if the changes have been saved.
+If
+.I last\^
+is not specified,
+then it will be set to
+.IR first .
+If
+.I first\^
+is not specified,
+the default is the previous command
+for editing and \-16 for listing.
+The option
+.B \-r
+reverses the order of the commands and
+the option
+.B \-n
+suppresses command numbers when listing.
+In the second form,
+.I command\^
+is interpreted as
+.I first\^
+described above
+and defaults to the last command executed.
+The resulting command is executed
+after the optional substitution
+\f2old\^\fP\f3=\fP\f2new\^\fP
+is performed.
+.TP
+\f3jobs\fP \*(OK \f3\-lnp\^\fP \*(CK \*(OK \f2job\^\fP \.\|.\|. \*(CK
+Lists information about each given job; or all active jobs if
+.I job
+is omitted.
+The
+.B \-l
+option lists process ids in addition to the normal information.
+The
+.B \-n
+option only displays jobs that have stopped or exited since last
+notified.
+The
+.B \-p
+option causes only the process group to be listed.
+See
+.I Jobs
+for a description of the format of
+.IR job .
+.TP
+.PD 0
+\f3kill\fP \*(OK \f3\-s\fP \f2signame\^\fP \*(CK \f2job\^\fP .\|.\|.
+.TP
+.PD 0
+\f3kill\fP \*(OK \f3\-n\fP \f2signum\^\fP \*(CK \f2job\^\fP .\|.\|.
+.TP
+\f3kill\fP \f3\-l\fP \*(OK \f2sig\^\fP .\|.\|. \*(CK
+.PD
+Sends either the TERM (terminate) signal or the
+specified signal to the specified jobs or processes.
+Signals are either given by number with the
+.B \-n
+option or by name with the
+.B \-s
+option
+(as given in
+.BR <signal.h> ,
+stripped of the prefix ``SIG'' with
+the exception that SIGCLD is named CHLD).
+For backward compatibility, the
+.B n
+and
+.B s
+can be omitted and the number or name placed immediately
+after the
+.BR \- .
+If the signal being sent is TERM (terminate) or HUP (hangup),
+then the job or process will be sent a CONT (continue) signal
+if it is stopped.
+The argument
+.I job\^
+can be the process id of a process that is not a member of one of the
+active jobs.
+See
+.I Jobs
+for a description of the format of
+.IR job .
+In the third form,
+.BR "kill \-l" ,
+if
+.I sig\^
+is not specified,
+the signal names are listed.
+Otherwise, for each
+.I sig\^
+that is a name, the corresponding signal number is listed.
+For each
+.I sig\^
+that is a number, the signal name corresponding to the
+least significant 8 bits of
+.I sig\^
+is listed.
+.TP
+\f3let\fP \f2arg\^\fP .\|.\|.
+Each
+.I arg
+is a separate
+.I "arithmetic expression"
+to be evaluated.
+See
+.I "Arithmetic Evaluation"
+above, for a description of arithmetic expression evaluation.
+.sp .5
+The exit status is
+0 if the value of the last expression
+is non-zero, and 1 otherwise.
+.TP
+\(dg \f3newgrp\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
+Equivalent to
+.BI "exec /bin/newgrp" " arg\^"
+\&.\|.\|.\^.
+.TP
+\f3print\fP \*(OK \f3\-Renprs\^\fP \*(CK \*(OK \f3\-u\fP \f2unit\^\fP\*(CK \*(OK \f3\-f\fP \f2format\^\fP \*(CK \*(OK \f2arg\^\fP .\|.\|. \*(CK
+With no options or with option
+.B \-
+or
+.BR \-\|\- ,
+each
+.I arg
+is printed
+on standard output.
+The
+.B \-f
+option causes the arguments to be printed as
+described by
+.BR printf .
+In this case, any
+.BR e ,
+.BR n ,
+.BR r ,
+.B R
+options are ignored.
+Otherwise,
+unless the
+.B \-R
+or
+.BR \-r ,
+are specified, the following
+escape conventions will be applied:
+.RS
+.PD 0
+.TP
+.B \ea
+The alert character (ascii
+.BR 07 ).
+.TP
+.B \eb
+The backspace character (ascii
+.BR 010 ).
+.TP
+.B \ec
+Causes
+.B print
+to end without processing more arguments and
+not adding a new-line.
+.TP
+.B \ef
+The formfeed character (ascii
+.BR 014 ).
+.TP
+.B \en
+The new-line character (ascii
+.BR 012 ).
+.TP
+.B \er
+The carriage return character (ascii
+.BR 015 ).
+.TP
+.B \et
+The tab character (ascii
+.BR 011 ).
+.TP
+.B \ev
+The vertical tab character (ascii
+.BR 013 ).
+.TP
+.B \eE
+The escape character (ascii
+.BR 033 ).
+.TP
+.B \e\e
+The backslash character \e.
+.TP
+.BI \e0 x
+The character defined by the 1, 2, or 3-digit octal
+string given by \fIx\fP.
+.PD
+.PP
+The
+.B \-R
+option will print all subsequent arguments and options
+other than
+.BR \-n .
+The
+.B \-e
+causes the above escape conventions to be applied
+This is the default behavior.
+It reverses the effect of an earlier
+.BR \-r .
+The
+.B \-p
+option causes the
+arguments to be written onto the pipe
+of the process spawned with
+.B \(bv&
+instead of standard output.
+The
+.B \-s
+option causes the
+arguments to be written onto the history file
+instead of standard output.
+The
+.B \-u
+option can be used to specify a one digit
+file descriptor unit number
+.I unit\^
+on which the
+output will be placed.
+The default is 1.
+If the option
+.B \-n
+is used, no
+.B new-line\^
+is added to the output.
+.RE
+.TP
+\f3printf\fP \f2format\^\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
+The arguments
+.I arg\^
+are printed on standard output
+in accordance with the ANSI-C
+formatting rules associated with the format string
+.IR format .
+If the number of arguments exceeds the number of
+format specifications, the
+.B format\^
+string is reused to format remaining arguments.
+The following extensions can also be used:
+.BL
+.LI
+A
+.B %b
+format can be used instead of
+.B %s
+to cause escape sequences in the corresponding
+.I arg\^
+to be expanded as described in
+.BR print.
+.LI
+A
+.B %B
+option causes each of the arguments to be treated
+as variable names and the binary value of variable
+will be printed.
+This is most useful for variables whose attribute
+is
+.BR \-b .
+.LI
+A
+.B %H
+format can be used instead of
+.B %s
+to cause characters in
+.I arg\^
+that are special in HTML and XML
+to be output to be output as their entity name.
+.LI
+A
+.B %P
+format can be used instead of
+.B %s
+to cause
+.I arg\^
+to be interpreted as an extended regular
+expression and be printed as a shell pattern.
+.LI
+A
+.B %R
+format can be used instead of
+.B %s
+to cause
+.I arg\^
+interpreted as a shell pattern
+and to be printed as an extended regular expression.
+.LI
+A
+.B %q
+format can be used instead of
+.B %s
+to cause the resulting string to be quoted in a manner than can
+be reinput to the shell.
+.LI
+A
+.BI %( date-format )T
+format can be use to treat an argument as a date/time string
+and to format the date/time according to the
+.I date-format\^
+as defined for the
+.BR date (1)
+command.
+.LI
+A
+.B %Z
+format will output a byte whose value is 0.
+.LI
+The precision field of the
+.B %d
+format can be followed by a
+.B .
+and the output base.
+In this case, the
+.B #
+flag character caues
+.IB base #
+to be prepended.
+.LI
+The
+.B #
+flag when used with the
+.B d
+specifier without an output base,
+causes the output to be displayed in thousands units with one of the suffixes
+.B "k M G T P E"
+to indicate the unit.
+.LI
+The
+.B #
+flag when used with the
+.B i
+specifier causes the output to be displayed in 1024 with one of the suffixes
+.B "Ki Mi Gi Ti Pi Ei"
+to indicate the unit.
+.LI
+The
+.B =
+flag has been added to center the output within the specified field width.
+.LE
+.TP
+\f3pwd\fP \*(OK \f3\-LP\fP \*(CK
+Outputs the value of the current working
+directory.
+The
+.B \-L
+option is the default; it prints the logical name of the current directory.
+If the
+.B \-P
+option is given,
+all symbolic links are resolved from the name.
+The last instance of
+.B \-L
+or
+.B \-P
+on the command line
+determines which method is used.
+.TP
+\f3read\fP \*(OK \f3\-Aprs\^\fP \*(CK \*(OK \f3\-d\fP \f2delim\^\fP\*(CK \*(OK \f3\-n\fP \f2n\^\fP\*(CK \*(OK \*(OK \f3\-N\fP \f2n\^\fP\*(CK \*(OK \*(OK \f3\-t\fP \f2timeout\^\fP\*(CK \*(OK \f3\-u\fP \f2unit\^\fP\*(CK \*(OK \f2vname\f3?\f2prompt\^\f1 \*(CK \*(OK \f2vname\^\fP .\|.\|. \*(CK
+The shell input mechanism.
+One line is read and
+is broken up into fields using the characters in
+.B
+.SM IFS
+as separators.
+The escape character,
+.BR \e ,
+is used to remove any special meaning for the next
+character and for line continuation.
+The
+.B \-d
+option
+causes the read to continue to the first character of
+.I delim\^
+rather than new-line.
+The
+.B \-n
+option causes at most
+.I n\^
+bytes to read rather a full line
+but will return when reading from a slow device
+as soon as any characters have been read.
+The
+.B \-N
+option causes exactly
+.I n\^
+to be read unless an end-of-file has been encountered or
+the read times out because of the
+.B \-t
+option.
+In raw mode,
+.B \-r,
+the
+.B \e
+character is not treated specially.
+The first
+field is assigned to the first
+.IR vname ,
+the second field
+to the second
+.IR vname ,
+etc., with leftover fields assigned to the last
+.IR vname .
+When
+.IR vname
+has the binary attribute and
+.B \-n
+or
+.B \-N
+is specified, the bytes that are read are stored directly
+into the variable.
+If the
+.B \-v
+is specified, then the value of the first
+.I vname\^
+will be used as a default value when reading from a terminal device.
+The
+.B \-A
+option causes the variable
+.I vname\^
+to be unset and each field that is read to be stored in
+successive elements of the indexed array
+.IR vname.
+The
+.B \-p
+option causes the input line
+to be taken from the input pipe
+of a process spawned by the shell
+using
+.BR \(bv& .
+If the
+.B \-s
+option is present,
+the input will be saved as a command in the history file.
+The option
+.B \-u
+can be used to specify a one digit file
+descriptor unit
+.I unit\^
+to read from.
+The file descriptor can be opened with the
+.B exec\^
+special built-in command.
+The default value of unit
+.I n\^
+is 0.
+The option
+.B \-t
+is used to specify a timeout in
+seconds when reading from a terminal or pipe.
+If
+.I vname\^
+is omitted, then
+.SM
+.B REPLY
+is used as the default
+.IR vname .
+An end-of-file with the
+.B \-p
+option causes cleanup for this process
+so that another can be spawned.
+If the first argument contains a
+.BR ? ,
+the remainder of this word is used as a
+.I prompt\^
+on standard error
+when the shell is interactive.
+The exit status is 0 unless an end-of-file is encountered
+or
+.B read
+has timed out.
+.TP
+\(dg\(dg \f3readonly\fP \*(OK \f3\-p\fP \*(CK \*(OK \f2vname\fP\*(OK\f3=\fP\f2value\^\fP\*(CK \*(CK .\|.\|.
+If
+.I vname\^
+is not given,
+the names and values of each variable with
+the readonly attribute is printed with the values
+quoted in a manner that allows them to be re-inputted.
+The
+.B \-p
+option
+causes the word
+.B readonly
+to be inserted before each one.
+Otherwise, the given
+.IR vname s
+are marked
+readonly and these
+names cannot be changed
+by subsequent assignment.
+.TP
+\(dg \f3return\fP \*(OK \f2n\^\fP \*(CK
+Causes a shell
+.I function
+or
+\f3\|.\fP
+script to return
+to the invoking script
+with the exit status specified by
+.IR n .
+The value will be the least significant 8 bits of the specified status.
+If
+.I n\^
+is omitted, then the return status is that of the last command executed.
+If
+.B return
+is invoked while not in a
+.I function
+or a
+\f3\|.\fP
+script,
+then it behaves the same as
+.BR exit .
+.TP
+\(dg \f3set\fP \*(OK \f3\(+-CGabefhkmnoprstuvx\fP \*(CK \*(OK \f3\(+-o\fP \*(OK \f2option\^\fP \*(CK \*(CK .\|.\|. \*(OK \f3\(+-A\fP \f2vname\^\fP \*(CK \*(OK \f2arg\^\fP .\|.\|. \*(CK
+The options for this command have meaning as follows:
+.RS
+.PD 0
+.TP 8
+.B \-A
+Array assignment.
+Unset the variable
+.I vname
+and assign values sequentially from the
+.I arg\^
+list.
+If
+.B +A
+is used, the variable
+.I vname
+is not unset first.
+.TP 8
+.B \-B
+Enable brace pattern field generation.
+This is the default behavior.
+.TP 8
+.B \-C
+Prevents redirection
+.B >
+from truncating existing files.
+Files that are created are opened with the O_EXCL mode.
+Requires
+.B >\(bv
+to truncate a file when turned on.
+.TP 8
+.B \-G
+Causes the pattern
+.B \(**\(**
+by itself to match files and zero or more directories and sub-directories
+when used for file name generation.
+If followed by a
+.B /
+only directories and sub-directories are matched.
+.TP 8
+.B \-a
+All subsequent variables that are defined are automatically exported.
+.TP 8
+.B \-b
+Prints job completion messages as soon as a background job changes
+state rather than waiting for the next prompt.
+.TP 8
+.B \-e
+If a command has a non-zero exit status,
+execute the
+.SM
+.B ERR
+trap, if set,
+and exit.
+This mode is disabled while reading profiles.
+.TP 8
+.B \-f
+Disables file name generation.
+.TP 8
+.B \-h
+Each command
+becomes a tracked alias when first encountered.
+.TP 8
+.B \-k
+(Obsolete). All variable assignment arguments are placed in the environment for a command,
+not just those that precede the command name.
+.TP 8
+.B \-m
+Background jobs will run in a separate process group
+and a line will print upon completion.
+The exit status of background jobs is reported in a completion message.
+On systems with job control,
+this option is turned on automatically for
+interactive shells.
+.TP 8
+.B \-n
+Read commands and check them for syntax errors, but do not execute them.
+Ignored for interactive shells.
+.TP 8
+.B \-o
+The following argument can be one of the following option names:
+.RS
+.TP 8
+.B allexport
+Same as
+.BR \-a .
+.TP 8
+.B errexit
+Same as
+.BR \-e .
+.TP 8
+.B bgnice
+All background jobs are run at a lower priority.
+This is the default mode.
+.TP 8
+.B bracexpand
+Sans as
+.BR \-B .
+.TP 8
+.B emacs
+Puts you in an
+.I emacs
+style in-line editor for command entry.
+.TP 8
+.B globstar
+Same as
+.BR \-G .
+.TP 8
+.B gmacs
+Puts you in a
+.I gmacs
+style in-line editor for command entry.
+.TP 8
+.B ignoreeof
+The shell will not exit on end-of-file.
+The command
+.B exit
+must be used.
+.TP 8
+.B keyword
+Same as
+.BR \-k .
+.TP 8
+.B markdirs
+All directory names resulting from file name generation have a trailing
+.B /
+appended.
+.TP 8
+.B monitor
+Same as
+.BR \-m .
+.TP 8
+.B multiline
+The built-in editors will use multiple lines on the screen for lines
+that are longer than the width of the screen. This may not work
+for all terminals.
+.TP 8
+.B noclobber
+Same as
+.BR \-C .
+.TP 8
+.B noexec
+Same as
+.BR \-n .
+.TP 8
+.B noglob
+Same as
+.BR \-f .
+.TP 8
+.B nolog
+Do not save function definitions in the history file.
+.TP 8
+.B notify
+Same as
+.BR \-b .
+.TP 8
+.B nounset
+Same as
+.BR \-u .
+.TP 8
+.B pipefail
+A pipeline will not complete until all components
+of the pipeline have completed, and the return value
+will be the value of the last non-zero command
+to fail or zero of no command has failed.
+.TP 8
+.B showme
+When enabled, simple commands or pipelines preceded by a a semicolon
+.RB ( ; )
+will be displayed as if the
+.B xtrace
+option were enabled but will not be executed.
+Otherwise, the leading
+.B ;
+will be ignored.
+.TP 8
+.B privileged
+Same as
+.BR \-p .
+.TP 8
+.B verbose
+Same as
+.BR \-v .
+.TP 8
+.B trackall
+Same as
+.BR \-h .
+.TP 8
+.B vi
+Puts you in insert mode of a
+.I vi\^
+style in-line editor
+until you hit the escape character
+.BR 033 .
+This puts you in control mode.
+A return sends the line.
+.TP 8
+.B viraw
+Each character is processed as it is typed
+in
+.I vi\^
+mode.
+.TP 8
+.B xtrace
+Same as
+.BR \-x .
+.PP
+If no option name is supplied, then the current option settings are printed.
+.RE
+.TP 8
+.B \-p
+Disables processing of the
+.B \s-1$HOME\s+1/.profile
+file and uses the file
+.B /etc/suid_profile
+instead of the
+.SM
+.B ENV
+file.
+This mode is on whenever the effective uid (gid)
+is not equal to the real uid (gid).
+Turning this off causes the effective uid and gid to be
+set to the real uid and gid.
+.TP 8
+.B \-r
+Enables the restricted shell. This option cannot be unset
+once set.
+.TP 8
+.B \-s
+Sort the positional parameters lexicographically.
+.TP 8
+.B \-t
+(Obsolete). Exit after reading and executing one command.
+.TP 8
+.B \-u
+Treat unset parameters as an error when substituting.
+.TP 8
+.B \-v
+Print shell input lines as they are read.
+.TP 8
+.B \-x
+Print commands and their arguments as they are executed.
+.TP 8
+.B \-\|\-
+Do not change any of the options; useful in setting
+.B $1
+to a value beginning with
+.BR \- .
+If no arguments follow this option then the positional parameters are unset.
+.PD
+.PP
+As an obsolete feature,
+if the first
+.I arg\^
+is
+.B \-
+then the
+.B \-x
+and
+.B \-v
+options are turned off and the next
+.I arg
+is treated as the first argument.
+Using
+.B \+
+rather than
+.B \-
+causes these options to be turned off.
+These options can also be used upon invocation of the shell.
+The current set of options may be found in
+.BR $\- .
+Unless
+.B \-A
+is specified,
+the remaining arguments are positional
+parameters and are assigned, in order, to
+.B $1
+.B $2
+\&.\|.\|.\^.
+If no arguments are given, then the names and values
+of all variables are printed on the standard output.
+.RE
+.TP
+\(dg \f3shift\fP \*(OK \f2n\^\fP \*(CK
+.br
+The positional parameters from
+\f3$\fP\f2n\fP\f3+1\fP
+\&.\|.\|.
+are renamed
+.B $1
+\&.\|.\|.\^
+, default
+.I n\^
+is 1.
+The parameter
+.I n\^
+can be any arithmetic expression that evaluates to a non-negative
+number less than or equal to
+.BR $# .
+.TP
+\f3sleep\fP \f2seconds\^\fP
+Suspends execution for the number of decimal seconds or fractions of a
+second given by
+.IR seconds .
+.TP
+\(dg \f3trap\fP \*(OK \f3\-p\fP \*(CK \*(OK \f2action\^\fP \*(CK \*(OK \f2sig\^\fP \*(CK .\|.\|.
+The
+.B \-p
+option causes the trap
+action associated with each trap as specified by the arguments
+to be printed with appropriate quoting.
+Otherwise,
+.I action\^
+will be processed as if it were an argument to
+.B eval
+when the shell
+receives signal(s)
+.IR sig .
+Each
+.I sig\^
+can be given as a number or as the name of the signal.
+Trap commands are executed in order of signal number.
+Any attempt to set a trap on a signal that
+was ignored on entry to the current shell
+is ineffective.
+If
+.I action\^
+is omitted and the first
+.I sig\^
+is a number, or if
+.I action\^
+is
+.BR \- ,
+then the trap(s) for each
+.I sig\^
+are reset
+to their original values.
+If
+.I action\^
+is the null
+string then this signal is ignored by the shell and by the commands
+it invokes.
+If
+.I sig\^
+is
+.SM
+.B ERR
+then
+.I action\^
+will be executed whenever a command has a non-zero exit status.
+If
+.I sig\^
+is
+.SM
+.B DEBUG
+then
+.I action\^
+will be executed before each command.
+The variable
+.B .sh.command
+will contain the contents of the current command line
+when
+.I action\^
+is running.
+If
+.I sig\^
+is
+.B 0
+or
+.SM
+.B EXIT
+and the
+.B trap
+statement is executed inside the body of a function defined with the
+.B function
+.I name\^
+syntax,
+then the command
+.I action\^
+is executed
+after the function completes.
+If
+.I sig\^
+is
+.B 0
+or
+.SM
+.B EXIT
+for a
+.B trap
+set outside any function
+then the command
+.I action\^
+is executed
+on exit from the shell.
+If
+.I sig\^
+is
+.SM
+.BR KEYBD ,
+then
+.I action\^
+will be executed whenever a key is read
+while in
+.BR emacs ,
+.BR gmacs ,
+or
+.B vi\^
+mode.
+The
+.B trap
+command
+with no arguments prints a list
+of commands associated with each signal number.
+.TP
+\f3true\fP
+Does nothing, and exits 0. Used with
+.B while
+for infinite loops.
+.TP
+\(dg\(dg \f3typeset\fP \*(OK \f3\(+-AHflabnprtux\^\fP \*(CK \*(OK \f3\(+-EFLRZi\*(OK\f2n\^\fP\*(CK \*(CK \*(OK \f2vname\^\fP\*(OK\f3=\fP\f2value\^\fP \*(CK \^ \*(CK .\|.\|.
+Sets attributes and values for shell variables and functions.
+When invoked inside a function defined with the
+.B function
+.I name\^
+syntax,
+a new instance of the variable
+.I vname\^
+is created,
+and the variable's value and type are restored
+when the function completes.
+The following list of attributes may be specified:
+.RS
+.PD 0
+.TP
+.B \-A
+Declares
+.I vname\^
+to be an associative array.
+Subscripts are strings rather than arithmetic
+expressions.
+.TP
+.B \-a
+Declares
+.I vname\^
+to be an indexed array.
+This is optional unless except for compound variable assignments.
+.TP
+.B \-E
+Declares
+.I vname\^
+to be a double precision floating point number.
+If
+.I n\^
+is non-zero, it defines the number of significant figures
+that are used when expanding
+.IR vname .
+Otherwise, ten significant figures will be used.
+.TP
+.B \-F
+Declares
+.I vname\^
+to be a double precision floating point number.
+If
+.I n\^
+is non-zero, it defines the number of places after the
+decimal point that are used when expanding
+.IR vname .
+Otherwise ten places after the decimal point will be used.
+.TP
+.B \-H
+This option provides UNIX to host-name file mapping on non-UNIX
+machines.
+.TP
+.B \-L
+Left justify and remove leading blanks from
+.IR value .
+If
+.I n\^
+is non-zero, it defines the width
+of the field,
+otherwise it is determined by the width of the value of
+first assignment.
+When the variable is assigned to, it is
+filled on the right with blanks or truncated, if necessary, to
+fit into the field.
+The
+.B \-R
+option is turned off.
+.TP
+.B \-R
+Right justify and fill with leading blanks.
+If
+.I n\^
+is non-zero, it defines the width
+of the field,
+otherwise it is determined by the width of the value of
+first assignment.
+The field is left filled with blanks or
+truncated from the end if the
+variable is reassigned.
+The
+.B \-L
+option is turned off.
+.TP
+.B \-Z
+Right justify and fill with leading zeros if
+the first non-blank character is a digit and the
+.B \-L
+option has not been set.
+Remove leading zeros if the
+.B \-L
+option is also set.
+If
+.I n\^
+is non-zero, it defines the width
+of the field,
+otherwise it is determined by the width of the value of
+first assignment.
+.TP
+.B \-f
+The names refer to function names rather than
+variable names.
+No assignments can be made and the only other
+valid options are
+.BR \-t ,
+.B \-u
+and
+.BR \-x .
+The
+.B \-t
+option
+turns on execution tracing for this function.
+The
+.B \-u
+option
+causes this function to be marked undefined.
+The
+.SM
+.B FPATH
+variable will be searched to find the function definition
+when the function is referenced.
+If no options other than
+.B \-f
+is specified, then the function definition will be displayed
+on standard output. If
+.B +f
+is specified, then a line containing the function name followed
+by a shell comment containing the line number and path name of the
+file where this function was defined, if any, is displayed.
+.TP
+.B \-b
+The variable can hold any number of bytes of data.
+The data can be text or binary.
+The value is represented by the base64 encoding of the data.
+If
+.B \-Z
+is also specified, the size in bytes of the
+data in the buffer will be determined by the size associated with the
+.BR \-Z .
+If the base64 string assigned results in more data, it will be
+truncated. Otherwise, it will be filled with bytes
+whose value is zero.
+The
+.B printf
+format
+.B %B
+can be used to output the actual data in this buffer instead
+of the base64 encoding of the data.
+.TP
+.B \-i
+Declares
+.I vname\^
+to be represented internally as integer.
+The right hand side of an assignment is evaluated as an
+arithmetic expression when assigning to an integer.
+If
+.I n\^
+is non-zero, it defines the output arithmetic base,
+otherwise the output base will be ten.
+.TP
+.B \-l
+All upper-case characters are
+converted to lower-case.
+The upper-case option,
+.BR \-u ,
+is turned off.
+.TP
+.B \-n
+Declares
+.I vname\^
+to be a reference to the variable whose name is
+defined by the value of variable
+.IR vname .
+This is usually used to reference a variable inside
+a function whose name has been passed as an argument.
+.TP
+.B \-r
+The given
+.IR vname s
+are marked
+readonly and these
+names cannot be changed
+by subsequent assignment.
+.TP
+.B \-t
+Tags the variables.
+Tags are user definable and have no special
+meaning to the shell.
+.TP
+.B \-u
+All lower-case characters are converted
+to upper-case.
+The lower-case option,
+.BR \-l ,
+is turned off.
+.TP
+.B \-x
+The given
+.IR vname s
+are marked for automatic
+export to the
+.I environment\^
+of subsequently-executed commands.
+Variables whose names contain a \fB\s+2.\s-2\fP
+cannot be exported.
+.PD
+.PP
+The
+.B \-i
+attribute cannot be specified along with
+.BR \-R ,
+.BR \-L ,
+.BR \-Z ,
+or
+.BR \-f .
+.PP
+Using
+.B \+
+rather than
+.B \-
+causes these options to be turned off.
+If no
+.I vname\^
+arguments are given,
+a list of
+.I vnames\^
+(and optionally the
+.IR values\^ )
+of the
+.I variables\^
+is printed.
+(Using
+.B \+
+rather than
+.B \-
+keeps the
+values from being printed.)
+The
+.B \-p
+option causes
+.B typeset
+followed by the option letters
+to be printed before each name
+rather than the names of the options.
+If any option other than
+.B \-p
+is given,
+only those variables
+which have all of the given
+options are printed.
+Otherwise, the
+.IR vname s
+and
+.I attributes\^
+of all
+.I variables\^
+that have attributes
+are printed.
+.RE
+.TP
+\f3ulimit\fP \*(OK \f3\-HSacdfmnpstv\fP \*(CK \*(OK \f2limit\^\fP \*(CK
+Set or display a resource limit.
+The available resource limits are listed below.
+Many systems do not support one or more of these limits.
+The limit for a specified resource is set when
+.I limit\^
+is specified.
+The value of
+.I limit\^
+can be a number in the unit specified below with each resource,
+or the value
+.BR unlimited .
+The
+.B \-H
+and
+.B \-S
+options specify whether the hard limit or the
+soft limit for the given resource is set.
+A hard limit cannot be increased once it is set. A soft
+limit can be increased up to the value of the hard limit.
+If neither the
+.B H
+nor
+.B S
+options is specified, the limit applies to both.
+The current resource limit is printed when
+.I limit\^
+is omitted.
+In this case, the soft limit is printed unless
+.B H
+is specified.
+When more than one resource is specified, then the limit
+name and unit is printed before the value.
+.RS
+.PD 0
+.TP
+.B \-a
+Lists all of the current resource limits.
+.TP
+.B \-c
+The number of 512-byte blocks on the size of core dumps.
+.TP
+.B \-d
+The number of K-bytes on the size of the data area.
+.TP
+.B \-f
+The number of 512-byte blocks on files that can be written by the
+current process or by child processes (files of any size may be read).
+.TP
+.B \-m
+The number of K-bytes on the size of physical memory.
+.TP
+.B \-n
+The number of file descriptors plus 1.
+.TP
+.B \-p
+The number of 512-byte blocks for pipe buffering.
+.TP
+.B \-s
+The number of K-bytes on the size of the stack area.
+.TP
+.B \-t
+The number of CPU seconds to be used by each process.
+.TP
+.B \-v
+The number of K-bytes for virtual memory.
+.PD
+.PP
+If no option is given,
+.B \-f
+is assumed.
+.RE
+.TP
+\f3umask\fP \*(OK \f3\-S\fP \*(CK \*(OK \f2mask\^\fP \*(CK
+The user file-creation mask is set to
+.I mask\^
+(see
+.IR umask (2)).
+.I mask
+can either be an octal number or
+a symbolic value as described in
+.IR chmod (1).
+If a symbolic value is given,
+the new
+umask value is the complement of the result of
+applying
+.I mask\^
+to the complement of the previous umask value.
+If
+.I mask\^
+is omitted, the current value of the mask is printed.
+The
+.B \-S
+option causes the mode to be printed as a symbolic
+value. Otherwise, the
+mask is printed in octal.
+.TP
+\(dg \f3unalias\fP \*(OK \f3\-a\fP \*(CK \f2name\^\fP .\|.\|.
+The aliases
+given by the list of
+.IR name s
+are removed from the alias list.
+The
+.B \-a
+option causes all the
+aliases to be unset.
+.TP
+\(dg\f3unset\fP \*(OK \f3\-fnv\fP \*(CK \f2vname\^\fP .\|.\|.
+The variables given by the list of
+.IR vname s
+are unassigned,
+i.e.,
+their values and attributes are erased.
+Readonly variables cannot be unset.
+If the
+.B \-f
+option
+is set, then the names refer to
+.I function\^
+names.
+If the
+.B \-v
+option is set, then the names refer to
+.I variable\^
+names.
+The
+.B \-f
+option overrides
+.BR \-v .
+If
+.B \-n
+is set and
+.I name\^
+is a name reference, then
+.I name\^
+will be unset rather than the variable
+that it references.
+The default is equivalent to
+.BR \-v .
+Unsetting
+.SM
+.BR LINENO ,
+.SM
+.BR MAILCHECK ,
+.SM
+.BR OPTARG ,
+.SM
+.BR OPTIND ,
+.SM
+.BR RANDOM ,
+.SM
+.BR SECONDS ,
+.SM
+.BR TMOUT ,
+and
+.SM
+.B _
+removes their special meaning even if they are
+subsequently assigned to.
+.TP
+\f3wait\fP \*(OK \f2job\^\fP .\|.\|. \*(CK
+Wait for the specified
+.I job
+and
+report its termination status.
+If
+.I job\^
+is not given, then all currently active child processes are waited for.
+The exit status from this command is that of
+the last process waited for if
+.I job\^
+is specified; otherwise it is zero.
+See
+.I Jobs
+for a description of the format of
+.IR job .
+.TP
+\f3whence\fP \*(OK \f3\-afpv\fP \*(CK \f2name\^\fP .\|.\|.
+For each
+.IR name ,
+indicate how it
+would be interpreted if used as a command name.
+.sp .5
+The
+.B \-v
+option
+produces a more verbose report.
+The
+.B \-f
+options skips the search for functions.
+The
+.B \-p
+option
+does a path search for
+.I name\^
+even if name is an alias, a function, or a reserved word.
+The
+.B \-a
+option
+is similar to the
+.B \-v
+option but causes
+all interpretations of the given name to be reported.
+.SS Invocation.
+If the shell is invoked by
+.IR exec (2),
+and the first character of argument zero
+.RB ( $0 )
+is
+.BR \- ,
+then the shell is assumed to be a
+.I login
+shell and
+commands are read from
+.B /etc/profile
+and then from either
+.B .profile
+in the current directory or
+.BR \s-1$HOME\s+1/.profile ,
+if either file exists.
+Next, for interactive shells, commands are read from
+the file named by
+performing parameter expansion, command substitution,
+and arithmetic substitution on
+the value of the environment variable
+.SM
+.B ENV
+if the file exists.
+If the
+.B \-s
+option is not present and
+.I arg\^
+and a file by the name of
+.I arg\^
+exits, then it reads and executes this script.
+Otherwise, if the first
+.I arg\^
+does not contain a
+.BR / ,
+a path search is performed on the first
+.I arg\^
+to determine the name of the script to execute.
+The script
+.I arg\^
+must have execute permission and any
+.I setuid
+and
+.I setgid
+settings will be ignored.
+If the script is not found on the path,
+.I arg\^
+is processed as if it named a built-in command or function.
+Commands are then read as described below;
+the following options are interpreted by the shell
+when it is invoked:
+.PP
+.PD 0
+.TP 10
+.BI \-c
+If the
+.B \-c
+option is present, then
+commands are read from the first
+.IR arg .
+Any remaining arguments become
+positional parameters starting at
+.BR 0 .
+.TP
+.B \-s
+If the
+.B \-s
+option is present or if no
+arguments remain,
+then commands are read from the standard input.
+Shell output,
+except for the output of the
+.I Special Commands\^
+listed above,
+is written to
+file descriptor 2.
+.TP
+.B \-i
+If the
+.B \-i
+option is present or
+if the shell input and output are attached to a terminal (as told by
+.IR tcgetattr (2)),
+then this shell is
+.IR interactive .
+In this case \s-1TERM\s+1 is ignored (so that \f3kill 0\fP
+does not kill an interactive shell) and \s-1INTR\s+1 is caught and ignored
+(so that
+.B wait
+is interruptible).
+In all cases, \s-1QUIT\s+1 is ignored by the shell.
+.TP
+.B \-r
+If the
+.B \-r
+option is present, the shell is a restricted shell.
+.TP
+.B \-D
+A list of all double quoted strings that are preceded by a
+.B $
+will be printed on standard output and the shell will exit.
+This set of strings will be subject to language translation
+when the locale is not C or POSIX.
+No commands will be executed.
+.PD
+.TP
+.B \-P
+If
+.B \-P
+or
+.B \-o profile
+is present, the shell is a profile shell (see
+.IR pfexec (1)).
+.TP
+.BI \-R " filename\^"
+The
+.B \-R
+.I filename\^
+option is used
+to generate a cross reference database
+that can be used by a separate utility
+to find definitions and references for variables and commands.
+.PP
+The remaining options and arguments are described under the
+.B set
+command above.
+An optional
+.B \-
+as the first argument is ignored.
+.if \nZ=0 \{.SS Rsh Only.
+.I Rsh\}
+.if \nZ=1 \{.SS Rksh Only.
+.I Rksh\}
+.if \nZ=2 \{.SS Rksh93 Only.
+.I Rksh93\}
+is used to set up login names and execution environments whose
+capabilities are more controlled than those of the standard shell.
+The actions of
+.if \nZ=0 .B rsh\^
+.if \nZ=1 .B rksh\^
+.if \nZ=2 .B rksh93\^
+are identical to those of
+.if \nZ=0 .BR sh\^ ,
+.if \nZ=1 .BR ksh\^ ,
+.if \nZ=2 .BR ksh93\^ ,
+except that the following are disallowed:
+.RS
+.PD 0
+.PP
+Unsetting the restricted option.
+.br
+changing directory (see
+.IR cd (1)),
+.br
+setting or unsetting the value or attributes of
+.SM
+.BR SHELL ,
+.SM
+.BR ENV ,
+.SM
+.BR FPATH ,
+or
+.SM
+.BR PATH\*S,
+.br
+specifying path or
+command names containing
+.BR / ,
+.br
+redirecting output
+.RB ( > ,
+.BR >| ,
+.BR <> ,
+and
+.BR >> ).
+.br
+adding or deleting built-in commands.
+.br
+using
+.B "command -p"
+to invoke a command.
+.PD
+.RE
+.PP
+The restrictions above are enforced
+after \f3.profile\fP and the
+.SM
+.B ENV
+files are interpreted.
+.PP
+When a command to be executed is found to be a shell procedure,
+.if \nZ=0 \{.B rsh\^
+invokes
+.I sh\^\}
+.if \nZ=1 \{.B rksh\^
+invokes
+.I ksh\^\}
+.if \nZ=2 \{.B rksh93\^
+invokes
+.I ksh93\^\}
+to execute it.
+Thus, it is possible to provide to the end-user shell procedures
+that have access to the full power of
+the standard shell,
+while imposing a limited menu of commands;
+this scheme assumes that the end-user does not have write and
+execute permissions in the same directory.
+.PP
+The net effect of these rules is that the writer of the
+.B .profile
+has complete control over user actions,
+by performing guaranteed setup actions
+and leaving the user in an appropriate directory
+(probably
+.I not\^
+the login directory).
+.PP
+The system administrator often sets up a directory
+of commands
+(e.g.,
+.BR /usr/rbin )
+that can be safely invoked by
+.if \nZ=0 .BR rsh .
+.if \nZ=1 .BR rksh .
+.if \nZ=2 .BR rksh93 .
+.SH EXIT STATUS
+Errors detected by the shell, such as syntax errors,
+cause the shell
+to return a non-zero exit status.
+If the shell is being used non-interactively,
+then execution of the shell file is abandoned
+unless the error occurs inside a subshell in which case
+the subshell is abandoned.
+Otherwise, the shell returns the exit status of
+the last command executed (see also the
+.B exit
+command above).
+Run time errors detected by the shell are reported by
+printing the command or function name and the error condition.
+If the line number that the error occurred on is greater than one,
+then the line number is also printed in square brackets
+.RB ( "[]" )
+after the command or function name.
+.SH FILES
+/etc/profile
+The system wide initialization file, executed for login shells.
+.RE
+.if \nZ=2 \{.br
+/etc/ksh.kshrc
+.RS
+The system wide startup file, executed for interactive shells.
+.RE\}
+.br
+\s-1$HOME\s+1/\f3.\fPprofile
+.RS
+The personal initialization file, executed for login shells after /etc/profile.
+.RE
+.br
+\s-1$HOME\s+1/\f3.\fP.kshrc
+.RS
+Default personal initialization file, executed for interactive shells when
+.SM
+.B ENV
+is not set.
+.RE
+.br
+/etc/suid_profile
+.RS
+Alternative initialization file, executed when instead of personal initialization file when the real and effective user or group id do not match.
+.RE
+.br
+/dev/null
+.RS
+NULL device
+.RE
+.SH SEE ALSO
+cat(1),
+cd(1),
+chmod(1),
+cut(1),
+egrep(1),
+echo(1),
+emacs(1),
+env(1),
+fgrep(1),
+gmacs(1),
+grep(1),
+newgrp(1),
+pfexec(1),
+stty(1),
+test(1),
+umask(1),
+vi(1),
+dup(2),
+exec(2),
+fork(2),
+getpwnam(3),
+ioctl(2),
+lseek(2),
+paste(1),
+pathconf(2),
+pipe(2),
+sysconf(2),
+umask(2),
+ulimit(2),
+wait(2),
+rand(3),
+a.out(5),
+profile(5),
+environ(7).
+.PP
+Morris I. Bolsky and David G. Korn,
+.IR "The New KornShell Command and Programming Language" ,
+Prentice Hall, 1995.
+.PP
+.I "POSIX \- Part 2: Shell and Utilities,"
+IEEE Std 1003.2-1992, ISO/IEC 9945-2, IEEE, 1993.
+.SH CAVEATS
+.PP
+If a command
+is executed, and then a command with the same name is
+installed in a directory in the search path before the directory where the
+original command was found, the shell will continue to
+.I exec\^
+the original command.
+Use the
+.B \-t
+option of the
+.B alias\^
+command to correct this situation.
+.PP
+Some very old shell scripts contain a
+.B ^
+as a synonym for the pipe character
+.BR \(bv .
+.PP
+Using the
+.B hist\^
+built-in command within a compound command will cause the whole
+command to disappear from the history file.
+.PP
+The built-in command \f3\|.\fP \f2file\^\fP
+reads the whole file before any commands are executed.
+Therefore,
+.B alias
+and
+.B unalias
+commands in the file
+will not apply to any commands defined in the file.
+.PP
+Traps are not processed while a job is waiting for a foreground process.
+Thus, a trap on
+.B CHLD
+won't be executed until the foreground job terminates.
+.PP
+It is a good idea to leave a space after the comma operator in
+arithmetic expressions to prevent the comma from being interpreted
+as the decimal point character in certain locales.
diff --git a/usr/src/lib/libshell/common/sh.memo b/usr/src/lib/libshell/common/sh.memo
new file mode 100644
index 0000000000..9f321e6eeb
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh.memo
@@ -0,0 +1,3248 @@
+. \" use troff -mm
+.nr C 3
+.nr N 2
+.SA 1 \" right justified
+.ND "December 21, 1993"
+.TL "311466-6713" "61175" \" charging case filing case
+Introduction to \f5ksh-93\fP
+.AU "David G. Korn" DGK MH 11267 7975 3C-526B "(research!dgk)"
+.TM 11267-931221-26 \" technical memo + TM numbers
+.MT 1 \" memo type
+.OK Shell "Command interpreter" Language UNIX \" keyword
+.AS 2 \" abstract start for TM
+\f5ksh-93\fP is a
+major rewrite of \f5ksh\fP,
+a program that serves as a command language
+(shell) for the UNIX*
+.FS *
+UNIX is a registered trademark of Novell.
+.FE
+operating system.
+As with \f5ksh\fP, \f5ksh-93\fP
+is essentially compatible with the System V version of the Bourne shell\*(Rf,
+.RS
+S. R. Bourne,
+.I "An Introduction to the UNIX
+Shell,"
+BSTJ - Vol. 57, No. 6 part 2, pages 1947-1972, 1978.
+.RF
+and compatible with previous versions of \f5ksh\fP.
+\f5ksh-93\fP is intended to comply with the IEEE POSIX 1003.2
+and ISO 9945-2\*(Rf
+.RS
+.I "POSIX \- Part 2: Shell and Utilities,"
+IEEE Std 1003.2-1992, ISO/IEC 9945-2, IEEE, 1993.
+.RF
+shell standard.
+In addition to changes in the language required
+by these standards, the primary focus of \f5ksh-93\fP
+is related to shell programming.
+\f5ksh-93\fP provides the programming power of several
+other interpretive languages such as \f5awk\fP\*(Rf,
+.RS
+Al Aho,
+Brian Kernighan,
+and
+Peter Weinberger,
+.I "The AWK Programming Language,"
+Addison Wesley, 1988.
+.RF
+\f5FIT\fP\*(Rf,
+.RS
+Lloyd H. Nakatani and Laurence W. Ruedisueli,
+.I "The FIT Programming Language Primer",
+TM 1126-920301-03, 1992.
+.RF
+\f5PERL\fP\*(Rf,
+.RS
+Larry Wall and Randal Schwartz,
+.I "Programming perl,"
+O'Reilly & Assoc, 1990.
+.RF
+and
+\f5tcl\fP\*(Rf.
+.RS
+John K. Ousterhout,
+.I "Tcl: An Embeddable Command Language",
+Proceedings of the Washington USENIX meeting, pp. 133-146, 1990.
+.RF
+.P
+This memo
+assumes that the reader is already familiar with the Bourne shell.
+It introduces most of the features of \f5ksh-93\fP
+relative to the Bourne shell; both
+as a command language and as a programming language.
+The Appendix contains
+a sample script written in \f5ksh-93\fP.
+.AE \" abstract end
+.H 1 "INTRODUCTION"
+.P
+The term "shell" is used to describe a program that provides
+a command language
+interface.
+Because the UNIX*\
+.FS *
+UNIX is a registered trademark of USL
+.FE
+system shell is a user level program, and not part of
+the operating system itself,
+anyone can write a new shell or modify an existing one.
+This has caused an evolutionary progress
+in the design and implementation of shells,
+with the better ones surviving.
+The most widely available UNIX system shells are the Bourne shell\*(Rf,
+.RS
+S. R. Bourne,
+.IR "An Introduction to the UNIX Shell" ,
+Bell System Technical Journal,
+Vol. 57, No. 6, Part 2, pp. 1947-1972, July 1978.
+.RF
+written by Steve Bourne
+at AT&T Bell Laboratories,
+the C shell\*(Rf,
+.RS
+W. Joy,
+.IR "An Introduction to the C Shell" ,
+Unix Programmer's Manual, Berkeley Software Distribution,
+University of California, Berkeley, 1980.
+.RF
+written by Bill Joy at the University of California, Berkeley,
+and the KornShell language \*(Rf,
+.RS
+Morris Bolsky and David Korn,
+.IR "The KornShell Command and Programming Language" ,
+Prentice Hall, 1989.
+.RF
+written by David Korn
+at AT&T Bell Laboratories.
+The Bourne shell is available on almost all versions of the UNIX
+system.
+The C Shell is available with all Berkeley Software Distribution (BSD) UNIX systems and on many other systems.
+The KornShell
+is available on System V Release 4 systems.
+In addition, it is available on many other systems.
+The source for the KornShell language is available from the AT&T Toolchest,
+an electronic software distribution system.
+It runs on all known versions of the UNIX system and
+on many UNIX system look-alikes.
+.P
+There have been several articles comparing the UNIX system shells.
+Jason Levitt\*(Rf
+.RS
+Jason Levitt,
+.IR "The Korn Shell: An Emerging Standard" ,
+UNIX/World, pp. 74-81, September 1986.
+.RF
+highlights some of the new features
+introduced by the KornShell language.
+Rich Bilancia\*(Rf
+.RS
+Rich Bilancia,
+.IR "Proficiency and Power are Yours With the Korn Shell" ,
+UNIX/World, pp. 103-107, September 1987.
+.RF
+explains some of the advantages of using the KornShell language.
+John Sebes\*(Rf
+.RS
+John Sebes,
+.I "Comparing UNIX Shells,"
+UNIX Papers,
+Edited by the Waite Group, Howard W. Sams & Co., 1987.
+.RF
+provides a more detailed comparison of the three shells,
+both as a command language and as a programming language.
+.P
+The KornShell language is a superset of the
+Bourne shell. The KornShell language has many of the popular C shell features,
+plus additional features of its own.
+Its initial popularity stems primarily from its improvements as
+a command language.
+The primary interactive benefit of the KornShell command language
+is a visual command line editor that allows you to
+make corrections to your current command line
+or to earlier command lines,
+without having to retype them.
+.P
+However,
+in the long run,
+the power of the KornShell language as a high-level programming language,
+as described by Dolotta and Mashey\*(Rf,
+.RS
+T. A. Dolotta and J. R. Mashey,
+.I "Using the shell as a Primary Programming Tool,"
+Proc. 2nd. Int. Conf. on Software Engineering, 1976,
+pages 169-176.
+.RF
+may prove to be of greater significance.
+\f5ksh-93\fP provides the programming power of several
+other interpretive languages such as \f5awk\fP,
+\f5FIT\fP,
+\f5PERL\fP,
+and
+\f5tcl\fP.
+An application that was originally written in the C programming language
+was rewritten in the KornShell language.
+More than 20,000 lines of C code were replaced with KornShell scripts
+totaling fewer than 700 lines.
+In most instances there was no perceptible difference in performance
+between the two versions of the code.
+.P
+The KornShell language has been embedded into windowing systems
+allowing graphical user interfaces to be developed in shell
+rather than having to build applications that need to be
+compiled.
+The \f5wksh\fP program\*(Rf
+.RS
+J. S. Pendergrast,
+.IR "WKSH - Korn Shell with X-Windows Support",
+USL. 1991.
+.RF
+provides a method of developing OpenLook or Motif
+applications as \f5ksh\fP scripts.
+.P
+This memo is an introduction to \f5ksh-93\fP,
+the program that implements an enhanced version
+of the KornShell language.
+It is referred to as \f5ksh\fP in the rest of this memo.
+The memo describes the KornShell language based on the
+features of the 12/28/93 release of \f5ksh\fP.
+This memo is not a tutorial, only an introduction.
+The second edition of reference [9] gives
+a more complete treatment of the KornShell language.
+.P
+A concerted effort has been made to achieve both System V Bourne shell
+compatibility and IEEE POSIX compatibility
+so that scripts written for either of these shells
+can run without modification with \f5ksh\fP.
+In addition, \f5ksh-93\fP attempts to
+be compatible with older versions of \f5ksh\fP.
+When there are conflicts between versions of the shell,
+\f5ksh-93\fP selects the behavior dictated by the IEEE POSIX
+standard.
+The description of features in this memo assumes
+that the reader is already familiar with the Bourne shell.
+.H 1 "COMMAND LANGUAGE"
+There is no separate command language.
+All features of the language, except job control,
+can be
+used both within a script and interactively from a terminal.
+However, features that are more likely to be used
+while running commands interactively from a terminal
+are presented here.
+.H 2 "Setting Options"
+By convention, UNIX commands
+consist of a command name followed by options and other arguments.
+Options are either of the form \f5-\fP\fIletter\fP,
+or \f5-\fP\fIletter value\fP.
+In the former case, several options may be grouped after a single \f5-\fP.
+The argument \f5--\fP signifies an end to the option list and is
+only required when the first non-option argument begins with
+a \f5-\fP.
+Most commands print an error message which
+shows which options are permitted
+when given incorrect arguments.
+In addition, the option sequence \f5-?\fP causes most commands
+to print a usage message which lists the valid options.
+.P
+Ordinarily, \f5ksh\fP executes a command by
+using the command name to locate a program to run
+and by running the program as a separate process.
+Some commands, referred to as
+.IR built-ins ,
+are carried out by \f5ksh\fP itself,
+without creating a separate process.
+The reasons that some commands are built-in are presented later.
+In nearly all cases the distinction
+between a command that is built-in and one that
+is not is invisible to the user.
+However, nearly
+all commands that are built-in follow command line conventions.
+.P
+\f5ksh\fP has several options that can be set by the user
+as command line arguments at invocation and as option arguments to the
+\f5set\fP command.
+Most other options can be set with a single letter option or as a name
+that follows the \f5-o\fP option.
+Use
+\f5set\ -o\fP
+to display the current option settings.
+Some of these options, such as
+.B interactive
+and
+.B monitor
+(see
+.I "Job Control"
+below),
+are enabled automatically by \f5ksh\fP
+when the shell is connected to a terminal device.
+Other options, such as
+.B noclobber
+and
+.BR ignoreeof ,
+are normally placed in a startup file.
+The
+.B noclobber
+option causes
+\f5ksh\fP
+to print an error message when you use
+.B >
+to redirect output to a file that already exists.
+If you want to redirect to an existing file, then
+you have to use
+.B >|
+to override
+the
+.B noclobber
+option.
+The
+.B ignoreeof
+option
+is used to prevent the
+.I end-of-file
+character, normally
+.B ^D
+(Control- d),
+from exiting the shell and possibly logging you out.
+You must type \f5exit\fP
+to log out.
+Most of the options are described in this memo as appropriate.
+.H 2 "Command Aliases"
+.P
+Command aliases provide a mechanism of associating a command name and
+arguments with a shorter name.
+Aliases are defined with the \f5alias\fP
+built-in.
+The form of an \f5alias\fP
+command definition is:
+.ce
+\f5alias\fP \fIname\fP\f5=\fP\fIvalue\fP
+As with most other shell assignments, no space is allowed before or after
+the \f5=\fP.
+The characters of an alias name cannot be characters that are
+special to the shell.
+The replacement string,
+.I value,
+can contain any valid shell script,
+including meta-characters such as pipe symbols and i/o-redirection
+provided that they are quoted.
+Unlike
+\f5csh\fP,
+aliases in
+\f5ksh\fP
+cannot take arguments.
+The equivalent functionality of aliases with arguments can
+be achieved with shell functions, described later.
+.P
+As a command is being read,
+the command name is checked against a list of
+.I alias
+names.
+If it is found,
+the name is replaced by the alias value associated with the
+.I alias
+and then rescanned.
+When rescanning the value for an alias, alias substitutions
+are performed except for an alias that is currently being processed.
+This prevents infinite loops in alias substitutions.
+For example with the aliases, \f5alias\ l=ls\ 'ls=ls\ -C'\fP,
+the command name \f5l\fP becomes \f5ls\fP, which becomes \f5ls\ -C\fP.
+Ordinarily, only the command name word is processed for alias substitution.
+However, if the value of an alias ends in a space,
+then the word following the alias is also checked for alias substitution.
+This makes it possible
+to define an alias whose first argument is the name of a command
+and have alias substitution performed on this argument,
+for example
+\f5nohup='nohup\ '\fP.
+.P
+Aliases can be used to redefine built-in commands so that
+the alias,
+.ce
+\f5alias test=./test\fP
+can be used to look for \f5test\fP
+in your current working directory rather than
+using the built-in \f5test\fP command.
+Reserved words such as
+\f5for\fP and \f5while\fP
+cannot be changed by aliasing.
+The command \f5alias\fP,
+without arguments, generates
+a list of aliases and corresponding alias values.
+The \f5unalias\fP command removes the name and text of an alias.
+.P
+Aliases are used to save typing and to improve readability of scripts.
+Several aliases are predefined by \f5ksh\fP.
+For example, the predefined alias
+.ce
+\f5alias integer='typeset -i'\fP
+allows the integer variables \f5i\fP and \f5j\fP
+to be declared and initialized with the command
+.ce
+\f5integer i=0 j=1\fP
+.P
+While aliases can be defined in scripts,
+it is not recommended.
+The location of an alias command can be important
+since aliases are only processed when a command is read.
+A \fB\s+2.\s-2\fP
+procedure (the shell equivalent of an include file)
+is read all at once (unlike
+start up files
+which are read a command at
+a time) so that any aliases defined there will not effect any commands
+within this script.
+Predefined aliases do not have this problem.
+.H 2 "Command Re-entry"
+.P
+When run interactively,
+\f5ksh\fP saves the
+commands you type at a terminal in a file.
+If the variable
+\fB\s-1HISTFILE\s+1\fP
+is set to the name of a file to which the user
+has write access,
+then the commands are stored in this
+.I history
+file.
+Otherwise the file
+\fB$\s-1HOME\s+1/.sh_history\fP
+is checked for write access and if this fails
+an unnamed file is used to hold the history lines.
+Commands are always appended to this file.
+Instances of \f5ksh\fP
+that run concurrently and use the same history file
+name, share access to the history file so that a command
+entered in one shell will be available for editing in another
+shell.
+The file may be truncated when \f5ksh\fP
+determines that no other shell is using the history file.
+The number of commands accessible to the user is determined by the value of the
+\fB\s-1HISTSIZE\s+1\fP
+variable at the time the shell is invoked.
+The default value is 256.
+Each command may consist of one or more lines since a compound
+command is considered one command.
+If the character
+.B !
+is placed within the
+.I "primary prompt"
+string,
+\fB\s-1PS1\s+1\fP,
+then it is replaced by the command number each time the prompt is given.
+.P
+A built-in command named \f5hist\fP
+is used to list and/or edit
+any of these saved commands.
+The option
+.B \-l
+is used to specify listing of previous commands.
+The command can always be specified with
+a range of one or more commands.
+The range can be specified by giving the command
+number, relative or absolute, or by giving
+the first character or characters of the command.
+When given without specifying the range,
+the last 16
+commands are listed, each
+preceded by the command number.
+.P
+If the listing option is not selected,
+then the range of commands specified,
+or the last command if no range is given,
+is passed to an editor program before
+being re-executed by \f5ksh\fP.
+The editor to be used may be specified
+with the option
+.B \-e
+and following it with the editor name.
+If this option is not specified, the
+value of the shell variable
+\fB\s-1HISTEDIT\s+1\fP
+is used as the name of the editor,
+providing that this variable has a non-null value.
+If this variable is not set, or is null,
+and the
+.B \-e
+option has not been selected,
+then
+\f5/bin/ed\fP
+is used.
+When editing has been complete,
+the edited text automatically becomes
+the input for \f5ksh\fP.
+As this text is read by \f5ksh\fP, it is echoed onto the terminal.
+.P
+The
+.B \-s
+option causes the editing to be bypassed
+and just re-executes the command.
+In this case only a single command can be specified as the range
+and an optional argument of the form
+\fIold\fP\fB=\fP\fInew\fP
+may be added which requests a simple string substitution
+prior to evaluation.
+A convenient alias,
+.ce
+\f5alias r='hist -s'\fP
+has been pre-defined so that
+the single key-stroke
+\f5r\fP
+can be used to re-execute the previous command
+and the key-stroke sequence,
+\f5r\ abc=def\ c\fP
+can be used to re-execute the last command that starts with
+the letter \f5c\fP
+with the first occurrence of the string \f5abc\fP
+replaced with the string \f5def\fP.
+Typing
+\f5r\ c\ >\ file\fP
+re-executes the most recent command starting with the letter \f5c\fP,
+with standard output redirected to
+.IR file .
+.H 2 "In-line editing"
+.P
+Lines typed from a terminal frequently need changes made
+before entering them.
+With the Bourne shell the only method to fix up commands
+is by backspacing or killing the whole line.
+\f5ksh\fP offers options that allow the user to edit parts of the
+current command line before submitting the command.
+The in-line edit options make the command line into a single
+line screen edit window.
+When the command is longer than the width of the terminal,
+only a portion of the command is visible.
+Moving within the line automatically makes that portion visible.
+Editing can be performed on this window until the
+.I return
+key is pressed.
+The editing modes have editing directives that access the history file
+in which previous commands are saved.
+A user can copy any of the most recent
+\fB\s-1HISTSIZE\s+1\fP
+commands from this file into the input edit window.
+You can locate commands by searching or by position.
+.P
+The in-line editing options do not use the
+.I termcap
+or
+.I terminfo
+databases.
+They work on most standard terminals.
+They only require that the backspace character moves the cursor left
+and the space character overwrites the current character on the screen
+and moves the cursor to the right.
+Very few terminals or terminal emulators do not have
+this behavior.
+.P
+There is a choice of editor options.
+The
+.BR emacs ,
+.BR gmacs ,
+or
+.B vi
+option is selected by turning on the
+corresponding
+option of the \f5set\fP
+command.
+If the value of the
+\fB\s-1EDITOR\s+1\fP
+or
+\fB\s-1VISUAL\s+1\fP
+variables ends with any of these suffixes
+the corresponding option is turned on.
+A large subset of each of these editors'
+features is available within the shell. Additional
+functions, such as file name completion, have also been added.
+.P
+In the
+.B emacs
+or
+.B gmacs
+mode the user positions the cursor to the point
+needing correction and inserts, deletes, or replaces
+characters as needed.
+The only difference between these two modes is the
+meaning of the directive
+.BR ^T .
+Control keys and escape sequences are used for cursor
+positioning and control functions.
+The available editing functions are listed in the manual page.
+.P
+The
+.B vi
+editing mode
+starts in insert mode and enters control mode when the
+user types ESC ( 033 ).
+The
+.I return
+key, which submits the current command for processing,
+can be entered from either mode.
+The cursor can be anywhere on the line.
+A subset of commonly used
+.I vi
+editing directives are available.
+The
+.B k
+and
+.B j
+directives that normally move up and down by one
+.IR line ,
+move up and down one
+.I command
+in the history file,
+copying the command into the input edit window.
+For reasons of efficiency,
+the terminal is kept in canonical mode until an
+ESC
+is typed.
+On some terminals,
+and on earlier versions of the UNIX operating system,
+this doesn't work correctly.
+The
+.B viraw
+option,
+which always uses
+.I raw
+or
+.I cbreak
+mode,
+must be used in this case.
+.P
+Most of the code for the editing options does not rely on the
+\f5ksh\fP code and can be used in a stand-alone mode with most any command
+to add in-line edit capability.
+However,
+all versions of the in-line editors have some features that
+use some shell specific code. For example,
+with all edit modes, the
+ESC-=
+directive applied to command words
+(the first word on the line,
+or the first word after a
+.BR ; ,
+.BR | ,
+.BR ( ,
+or
+.BR & )
+lists all aliases, functions, or commands
+that match the portion of the given current word.
+When applied to other words, this directive
+prints the names of files that match the current
+word.
+The ESC\fB-*\fP directive
+adds the expanded list of matching files to the command line.
+A trailing
+.B *
+is added to the word if it doesn't contain any file pattern matching
+characters before the expansion.
+In
+.B emacs
+and
+.B gmacs
+mode,
+ESC-ESC
+indicates command completion when applied to
+command names, otherwise it indicates pathname completion.
+With command or pathname completion,
+the list generated by the
+ESC-= directive is examined to find
+the longest common prefix.
+With command completion, only the last component of
+the pathname is used to compute the longest command prefix.
+If the longest common prefix is a complete match,
+then the word is replaced by the pathname, and a
+.B /
+is appended if
+pathname is a directory, otherwise a space is added.
+In
+.B vi
+mode,
+.B \e
+from control mode gives the same behavior.
+.H 2 "Key Binding"
+.P
+It is possible to intercept keys as they are entered and
+apply new meanings or bindings.
+A trap named
+\fB\s-1KEYBD\s+1\fP
+is evaluated each time
+\f5ksh\fP processes characters entered
+from the keyboard,
+other than those typed
+while entering a search string or an argument to an
+edit directive such as
+.B r
+in vi-mode.
+The action associated with this trap can change the value of
+the entered key to cause the key to perform a different
+operation.
+.P
+When the
+\fB\s-1KEYBD\s+1\fP
+trap is entered,
+the \fB.sh.edtext\fP
+variable contains the contents of the current input line
+and the \fB.sh.edcol\fP
+variable gives the current cursor position within this line.
+The \fB.sh.edmode\fP
+variable contains the
+.B ESC
+character when the trap is entered from
+.B vi
+insert mode.
+Otherwise, this value is null.
+The \fB.sh.edchar\fP
+variable contains the character or
+escape sequence that caused the trap.
+A key sequence is either a single character,
+.B ESC
+followed by a single character,
+or
+.B ESC[
+followed by a single character.
+In the \fBvi\fP edit mode,
+the characters after the
+.B ESC
+must be entered within half a second after the
+.BR ESC .
+The value of \fB.sh.edchar\fP
+at the end of the trap will be used as
+the input sequence.
+.P
+Using the associative array facility of \f5ksh\fP described later,
+and the function facility of \f5ksh\fP, it is easy to write
+a single trap so that keys can be bound dynamically. For example,
+.sp
+.nf
+.in .5i
+.ta 4i
+\f5typeset -A Keytable
+trap 'eval "${Keytable[${.sh.edchar}]}"' KEYBD
+function keybind # key action
+{
+ typeset key=$(print -f "%q" "$2")
+ case $# in
+ 2) Keytable[$1]='.sh.edchar=${.sh.edmode}'"$key"
+ ;;
+ 1) unset Keytable[$1]
+ ;;
+ *) print -u2 "Usage: $0 key [action]"
+ ;;
+ esac
+}\fP
+.ta
+.in
+.fi
+.sp
+.H 2 "Job Control"
+.P
+The job control mechanism
+is almost identical to the version introduced in \f5csh\fP
+of the Berkeley UNIX operating system,
+version 4.1 and later.
+The job control feature allows the user to stop and
+restart programs, and to move programs to and from the
+foreground and the background.
+It will only work on systems that provide support for
+these features.
+However,
+even systems without job control have a
+.B monitor
+option which, when enabled, will report the progress
+of background jobs and enable the user to \f5kill\fP
+jobs by job number or job name.
+.P
+An interactive shell associates a
+.I job
+with each pipeline typed in from the terminal
+and assigns it a small integer number
+called the job number.
+If the job is run asynchronously,
+the job number is printed at the terminal.
+At any given time, only one job owns the terminal,
+i.e., keyboard signals are only sent to the processes in one job.
+When \f5ksh\fP creates a foreground job,
+it gives it ownership of the terminal.
+If you are running a job and wish to stop
+it you hit the key
+.B ^Z
+(control-\fBZ\fP)
+which sends a
+\fB\s-1STOP\s+1\fP
+signal to all processes in the current job.
+The shell receives notification that the processes
+have stopped and takes back control of the terminal.
+.P
+There are commands to continue programs in the foreground
+and background.
+There are several ways to refer to jobs.
+The character
+.B %
+introduces a job name.
+You can refer to jobs by name or number as described in the manual page.
+The built-in command \f5bg\fP
+allows you to continue a job in the background,
+while the built-in command \f5fg\fP
+allows you to continue a job in the foreground even
+though you may have started it in the background.
+.P
+A job being run in the background will stop if it tries
+to read from the terminal.
+It is also possible to stop background jobs that try to write on
+the terminal by setting the terminal options
+appropriately.
+.P
+There is a built-in command \f5jobs\fP
+that lists the status of all running and stopped jobs.
+In addition,
+you are informed of the change of state (running or stopped)
+of any background
+jobs just before each prompt.
+If you want to be notified about background job completions
+as soon as they occur without waiting for a prompt, then use the
+.B notify
+option.
+When you try to exit the shell while jobs are stopped or running,
+you will receive a message from \f5ksh\fP.
+If you ignore this message and try to exit again,
+all stopped processes will be terminated.
+In addition, for login shells, the
+\fB\s-1HUP\s+1\fP
+signal will be sent to
+all background jobs
+unless the job has been disowned with the
+.B disown
+command.
+.P
+A built-in version of \f5kill\fP
+makes it possible to use
+.I job
+numbers as targets for signals.
+Signals can be selected by number or name.
+The name of the signal is the name found in the
+.I include
+file
+.B /usr/include/sys/signal.h
+with the prefix
+.B \s-1SIG\s+1
+removed.
+The
+.B \-l
+option of \f5kill\fP
+provides a means to map individual signal names to and from
+signal number.
+In addition, if no signal name or number is given,
+\f5kill\ -l\fP
+generates a list of valid signal names.
+.H 2 "Changing Directories"
+By default,
+\f5ksh\fP
+maintains a logical view of the file system hierarchy
+which makes symbolic links transparent.
+For systems that have symbolic links,
+this means that if \f5/bin\fP is a symbolic link to \f5/usr/bin\fP
+and you change directory to \f5/bin\fP, \f5pwd\fP will indicate
+that you are in \f5/bin\fP, not \f5/usr/bin\fP.
+\f5pwd\ -P\fP
+generates the physical pathname of the present working
+directory by resolving all the symbolic links.
+By default,
+the \f5cd\fP
+command will take you where you expect to go even if you cross
+symbolic links.
+A subsequent \f5cd\ ..\fP in the example above
+will place you in \f5/\fP, not \f5/usr\fP.
+On systems with symbolic links,
+\f5cd\ -P\fP
+causes
+.B ..
+to be treated physically.
+.P
+\f5ksh\fP remembers your last directory
+in the variable
+\fB\s-1OLDPWD\s+1\fP.
+The \f5cd\fP
+built-in can be given with argument
+.B \-
+to return to the previous directory
+and print the name of the directory.
+Note that \f5cd\ -\fP
+done twice returns you to the starting directory,
+not the second previous directory.
+A directory
+.I stack
+manager has been written as shell
+.I functions
+to
+.I push
+and
+.I pop
+directories from the stack.
+.H 2 "Prompts"
+.P
+When \f5ksh\fP
+reads commands from a terminal,
+it issues a prompt whenever it is ready
+to accept more input and then
+waits for the user to respond.
+The
+\fB\s-1TMOUT\s+1\fP
+variable
+can be set to be the number of seconds that the shell will wait for
+input before terminating.
+A 60 second warning message is printed
+before terminating.
+.P
+The shell uses two prompts.
+The primary prompt,
+defined by the value of the
+\fB\s-1PS1\s+1\fP
+variable,
+is issued at the start of each command.
+The secondary prompt,
+defined by the value of the
+\fB\s-1PS2\s+1\fP
+variable,
+is issued when more input is needed to complete a command.
+.P
+\f5ksh\fP allows the user to specify a list of files or directories
+to check before issuing the
+\fB\s-1PS1\s+1\fP
+prompt.
+The variable
+\fB\s-1MAILPATH\s+1\fP
+is a colon (
+.B :
+) separated list of file names to be checked for changes
+periodically. The user is notified
+before the next prompt.
+Each of the names in this list can be followed by a
+.B ?
+and a message to be given when a change has been detected in the file.
+The prompt will be evaluated for parameter expansion, command
+substitution and arithmetic expansion which are described later.
+The parameter
+.B $_
+within a mail message will evaluate to the name of the file that
+has changed.
+The parameter
+\fB\s-1MAILCHECK\s+1\fP
+is used to specify the minimal interval in seconds before
+new mail is checked for.
+.P
+In addition to replacing each
+.B !
+in the prompt with the command number,
+\f5ksh\fP expands
+the value of the
+.B \s-1PS1\s+1
+variable
+for parameter expansions, arithmetic expansions,
+and command substitutions as described below
+to generate the prompt.
+The expansion characters that are to be applied when
+the prompt is issued must be quoted to prevent the
+expansions from occurring when assigning the value to
+.B \s-1PS1\s+1.
+For example,
+\f3\s-1PS1\s+1="$\s-1PWD\s+1"\fP
+causes
+.B \s-1PS1\s+1
+to be set to the value of
+.B \s-1PWD\s+1
+at the time of the assignment whereas
+.B \s-1PS1\s+1='$\s-1PWD\s+1'
+causes
+.B \s-1PWD\s+1
+to be expanded at the time the prompt is issued.
+.P
+Command substitution may require a separate process
+to execute and cause the prompt display to be somewhat
+slow, especially
+when the return key is pressed several times in a row.
+Therefore, its use
+within
+.B \s-1PS1\s+1
+is discouraged.
+Some variables are maintained by \f5ksh\fP
+so that their values can be used with
+.B \s-1PS1\s+1.
+The
+.B \s-1PWD\s+1
+variable stores the pathname of the current working directory.
+The value of
+.B \s-1SECONDS\s+1
+variable
+is the value of the most
+recent assignment plus the elapsed time.
+By default, the time is measured in milli-seconds,
+but since
+.B \s-1SECONDS\s+1
+is a floating point variable, the
+number of places after the decimal point in the expanded
+value can be
+specified with
+\f5typeset\ -F\fP\fIplaces\fP\f5\ SECONDS\fP.
+In a roundabout way, this variable
+can be used to generate a time stamp into the
+.B \s-1PS1\s+1
+prompt without creating a process at each prompt.
+The following code explains how you can do this on
+System V. On BSD, you need a different command to initialize
+the
+.B \s-1SECONDS\s+1
+variable.
+\f5
+.sp
+.nf
+.in .5i
+# . this script and use $TIME as part of your PS1 string to
+# get the time of day in your prompt
+typeset -RZ2 _x1 _x2 _x3
+(( SECONDS=$(date '+3600*%H+60*%M+%S') ))
+_s='_x1=(SECONDS/3600)%24,_x2=(SECONDS/60)%60,_x3=SECONDS%60,0'
+TIME='"${_d[_s]}$_x1:$_x2:$_x3"'
+# PS1=${TIME}whatever
+.fi
+.ta
+.in
+.sp
+\fP
+.H 2 "Tilde substitution"
+.P
+The character
+.B \(ap
+at the beginning of a word has special meaning to \f5ksh\fP.
+If the characters after the
+.B \(ap
+up to a
+.B /
+match a user login name in the password database, then the
+.B \(ap
+and the name are replaced by
+that user's login directory.
+If no match is found, the original word
+is unchanged.
+A
+.B \(ap
+by itself, or in front of a
+.BR / ,
+is replaced by the value of the
+\fB\s-1HOME\s+1\fP
+parameter.
+A
+.B \(ap
+followed by a
+.B +
+or
+.B \-
+is replaced by the value of
+.B $\s-1PWD\s+1
+or
+.B $\s-1OLDPWD\s+1
+respectively.
+.H 2 "Output formats"
+The output of built-in commands and traces have values quoted so that they
+can be re-input to the shell.
+This makes it easy to cut and paste shell output on systems
+which use a pointing device such as a mouse.
+In addition, output can be saved in a file for reuse.
+.P
+.H 2 "The \fB\s-1ENV\s+1\fP file"
+When an interactive \f5ksh\fP starts, it evaluates the
+.B $\s-1ENV\s+1
+variable to arrive at a file name.
+If this value is not null,
+\f5ksh\fP attempts to read and process
+commands in a file by this name.
+Earlier versions of \f5ksh\fP read the \fB\s-1ENV\s+1\fP file
+for all invocations of the shell primarily to allow
+function definitions to be available for all shell
+invocations.
+The function search path, \fB\s-1FPATH\s+1\fP, described later,
+eliminated the primary need for this capability and it was
+removed because the high performance cost was no longer
+deemed acceptable.
+.H 1 "PROGRAMMING LANGUAGE"
+The KornShell vastly extends the set of applications that
+can be implemented efficiently at the shell level.
+It does this by providing simple yet powerful mechanisms
+to perform arithmetic, pattern matching,
+substring generation,
+and arrays.
+Users can write applications as separate functions that can
+be defined in the same file or in a library of functions
+stored in a directory and loaded on demand.
+.H 2 "String Processing"
+The shell is primarily a string processing language.
+By default, variables hold variable length strings.
+There are no limits to the length of strings. Storage
+management is handled by the shell automatically.
+Declarations are not required.
+With most programming languages, string constants are designated
+by enclosing characters in single quotes or double quotes.
+Since most of the words in the language are strings, the shell
+requires quotes only when a string contains characters that
+are normally processed specially by the shell, but their
+literal meaning is intended.
+However, since the shell is a string processing language,
+and some characters can occur as literals and as language metacharacters,
+quoting is an important part of the language.
+.P
+There are four quoting mechanisms in \f5ksh\fP.
+The simplest is to enclose a sequence of characters inside single quotes.
+All characters between a pair of single quotes have their literal meaning;
+the single quote itself cannot appear.
+A
+.B $
+immediately preceding
+a single quoted string
+causes all the characters until the matching single quote
+to be interpreted as an ANSI-C language string.
+Thus, \f5'\en'\fP represents characters \f5\e\fP and
+\f5n\fP, whereas, \f5$'\en'\fP
+represents the new-line character.
+Double quoted strings remove the special meaning of all characters
+except
+.BR $ ,
+.BR \(ga ,
+and
+.BR \e ,
+so that parameter expansion and command substitution (defined below)
+are performed.
+The final mechanism for quoting a character is by preceding it with the
+escape character
+.BR \e\^ .
+This mechanism works outside of quoted strings and for the characters
+.BR $ ,
+.BR \(ga ,
+\fB"\fP,
+and
+.B \e
+in double quoted strings.
+.P
+Variables are designated by
+one or more
+strings of alphanumeric
+characters beginning with an alphabetic character
+separated by a \fB\s+2.\s-2\fP.
+Upper and lower case characters are distinct, so that the variable
+.B A
+and
+.B a
+are names of different variables.
+There is no
+limit to the length of the name of a variable.
+You do not have to declare variables.
+You can assign a value to a variable by writing the name of the
+variable, followed by an equal sign, followed by a character string
+that represents its value.
+To create a variable whose name
+contains a \fB\s+2.\s-2\fP,
+the variable whose name consists of
+the characters before the last \fB\s+2.\s-2\fP
+must already exist.
+You reference a variable by
+putting the name inside curly braces and
+preceding the braces with a dollar sign.
+The braces may be omitted when the name
+is alphanumeric.
+If \f5x\fP and \f5y\fP
+are two shell variables, then
+to define a new variable,
+\f5z\fP,
+whose value is
+the concatenation of the values of
+\f5x\fP and \f5y\fP,
+you just say
+\f5z=$x$y\fP.
+It is that easy.
+.P
+The
+.B $
+can be thought of as meaning
+"value of."
+You can also capture the output of any command with the notation
+.BI $( command ) .
+This is referred to as command substitution.
+For example,
+\f5x=$(date)\fP
+assigns the output from the \f5date\fP
+command to the variable \f5x\fP.
+Command substitution in the
+Bourne shell is denoted by enclosing the command between
+backquotes,
+(\fB\(ga\^\(ga\fP).
+This notation
+suffers from some
+complicated quoting rules.
+Thus, it is hard to write \f5sed\fP
+patterns which contains back slashes within command substitution.
+Putting the pattern in single quotes
+is of little help.
+\f5ksh\fP accepts the Bourne shell command substitution syntax
+for backward compatibility.
+The
+.BI $( command )
+notation allows
+the \fIcommand\fP itself to contain quoted strings even if the substitution
+occurs within double quotes. Nesting is legal.
+.P
+The special command substitution of the form
+\f5$(cat\ file)\fP
+can be replaced by
+\f5$(<\ file)\fP,
+which is faster because
+the \f5cat\fP
+command doesn't have to run.
+.H 2 "Shell Parameters and Variables"
+.P
+There are three types of parameters used by \f5ksh\fP,
+special parameters, positional parameters, and named
+parameters which are called variables.
+\f5ksh\fP defines the same special parameters,
+.BR 0 ,
+.BR * ,
+.BR @ ,
+.BR # ,
+.BR ? ,
+.BR $ ,
+.BR ! ,
+and
+.BR \- ,
+as in the Bourne shell.
+.P
+Positional parameters are set when the shell is invoked,
+as arguments to the \f5set\fP built-in,
+and by calls to functions (see below) and \fB\s+2.\s-2\fP
+procedures.
+They are named by numbers starting at 1.
+.P
+The third type of parameter is a variable.
+As mentioned earlier,
+\f5ksh\fP uses variables whose names
+consist of one or more
+alpha-numeric strings separated by a \fB\s+2.\s-2\fP.
+There is no need to specify the
+.I type
+of a variable in the shell because, by default,
+variables store strings of arbitrary length
+and values will automatically be converted to numbers
+when used in an arithmetic context.
+However, \f5ksh\fP variables
+can have one or more
+.I attributes
+that control the internal representation of the variable,
+the way the variable is printed, and its access or
+scope.
+In addition,
+\f5ksh\fP
+allows variables to represent arrays of values
+and references to other variables.
+The \f5typeset\fP
+built-in command of \f5ksh\fP
+assigns attributes to variables.
+Two of the attributes,
+.I readonly
+and
+.IR export ,
+are available in the Bourne shell.
+Most of the remaining attributes are discussed here.
+The complete list of attributes appears in the manual.
+The \f5unset\fP
+built-in of \f5ksh\fP removes
+values and attributes of variables.
+When a variable is exported, certain of its attributes are also exported.
+.P
+Whenever a value is assigned to a variable,
+the value is transformed according to the attributes of the variable.
+Changing the attribute of a variable can change its value.
+The attributes
+.B \-L
+and
+.B \-R
+are for left and right field justification respectively.
+They are useful for aligning columns in a report.
+For each of these attributes, a width can be defined explicitly or else
+it is defined the first time an assignment is made to the variable.
+Each assignment causes justification of the field, truncating
+if necessary.
+Assignment to fixed sized variables
+provides one way to generate a substring consisting of
+a fixed number of characters from
+the beginning or end of a string.
+Other methods are discussed later.
+.P
+The attributes
+.B \-u
+and
+.B \-l
+are used for upper case and lower case
+formatting, respectively.
+Since it makes no sense to have both attributes on simultaneously,
+turning on either of these attributes turns the other off.
+The following script,
+using \f5read\fP and \f5print\fP which are described later,
+provides an example of the use of shell variables
+with attributes.
+This script reads a file of lines each consisting of five fields separated by
+.B :
+and prints fields 4 and 2 in upper case in columns 1-15, left justified,
+and columns 20-25 right-justified respectively.
+.sp
+.nf
+.in .5i
+.ta 3.4i
+\f5typeset -uL15 f4 # 15 character left justified
+typeset -uR6 f2 # 6 character right justified
+IFS=: # set field separator to :
+while read -r f1 f2 f3 f4 f5 # read line, split into fields
+do print -r -- "$f4 $f2" # print fields 4 and 2
+done\fP
+.fi
+.ta
+.in
+.sp
+.P
+The
+.BR \-i ,
+.BR \-E ,
+and
+.BR \-F ,
+attributes are used to represent numbers.
+Each can be followed by a decimal number.
+The
+.B \-i
+attribute causes the value to be represented as an integer and it
+can be followed by a number representing the numeric base when expanding
+its value.
+Whenever a value is assigned to an integer variable, it is evaluated
+as an arithmetic expression
+and then truncated to an integer.
+.P
+The
+.B \-E
+attribute causes the value to be represented in scientific
+notation whenever its value is expanded. The number following the
+.B \-E
+determines the number of significant figures, and defaults to 6.
+The
+.B \-F
+attribute causes the value to be represented with a fixed number
+of places after the decimal point.
+Assignments to variables with the
+.B \-E
+or
+.B \-F
+attributes cause the evaluation of the right hand side of the assignment.
+.P
+\f5ksh\fP allows one-dimensional
+.I arrays
+in addition to simple variables.
+There are two types of arrays; associative arrays
+and indexed arrays.
+The subscript for an associative array is an arbitrary
+string, whereas the subscript for an indexed array is
+an arithmetic expression that is evaluated to yield an integer
+index.
+Any variable can become an indexed array
+by referring to it with
+an integer
+.IR subscript .
+All elements of an array need not exist.
+Subscripts for arrays
+must evaluate to an
+integer between 0 and some maximum value, otherwise
+an error results.
+The maximum value may vary from one machine to another but
+is at least 4095.
+Evaluation of subscripts is described in
+the next section.
+Attributes apply to the whole array.
+.P
+Assignments to array variables can be made to individual elements
+via parameter
+assignment commands or the
+.B typeset
+built-in.
+Additionally, values can be assigned sequentially with
+compound assignment as described below, or by the
+.B \-A
+.I name
+option of the \f5set\fP command.
+Referencing of subscripted variables requires the character
+.BR $ ,
+but also requires braces around the array element name.
+The braces are needed to avoid conflicts with the
+file name generation mechanism.
+The form of any array element reference is:
+.ce
+.BI ${ name [ subscript ]}
+Subscript values of
+.B *
+and
+.B @
+can be used to generate all elements of an array,
+as they are used for expansion of positional parameters.
+The list of currently defined subscripts for a given
+variable can be generated with
+.BI ${! name [@]} ,
+or
+.BI ${! name [*]} .
+.P
+The
+.B \-n
+or
+.I nameref
+attribute causes the variable to be treated
+as a reference to the variable defined by its value.
+Once this attribute is set, all references to this variable
+become references to the variable named by the value
+of this variable.
+For example, if \f5foo=bar\fP, then setting the reference
+attribute on \f5foo\fP will cause all subsequent references
+to \f5foo\fP to behave as the variable whose name is \f5$foo\fP
+was referenced, which in this case is the variable \f5bar\fP.
+Unsetting this attribute breaks the association.
+Reference variables are usually used inside functions whose
+arguments are the names of shell variables.
+The names for reference variables cannot contain a \fB\s+2.\s-2\fP.
+Whenever a shell variable is referenced, the portion of the
+variable up to the first \fB\s+2.\s-2\fP
+is checked to see whether it matches the name of a reference
+variable.
+If it does, then the name of the variable actually used
+consists of the concatenation of the name of the variable
+defined by the reference plus the remaining portion of the
+original variable name.
+For example, using the predefined alias, \f5alias\ nameref='typeset\ -n'\fP,
+.sp
+.nf
+.in .5i
+.ta 3.4i
+\f5\^.bar.home.bam="hello world"
+nameref foo=.bar.home
+print ${foo.bam}
+\fBhello world\fP\fP
+.fi
+.ta
+.in
+.sp
+.H 2 "Compound Assignment"
+Compound assignments are used to assign values to arrays
+and compound data structures.
+The syntax for a compound assignment is
+.IB name =( assignment-list )
+where
+\fIname\fP
+is the name of the variable to which you want to assign values.
+No space is permitted between the variable name and the \fB=\fP
+but can appear between the \fB=\fP and the open parenthesis.
+New-lines can appear between the parentheses.
+.P
+The \fIassignment-list\fP can be in several different forms
+yielding different results.
+If \fIassignment-list\fP is simply a list of words, then
+the words are processed as they are with the \f5for\fP command
+and assigned sequentially as an indexed array.
+For example,
+.ce
+\f5foo=( * )\fP
+creates an indexed array \f5foo\fP and assigns the
+file names in the current directory to each index starting
+at zero.
+.P
+The second form for \fIassignment-list\fP is a list of assignments
+of the special form \fB[\fP\fIword\fP\fB]=\fP\fIword\fP.
+No space is permitted before or after the \fB=\fP.
+In this case, the variable given by \fIname\fP becomes
+an associative array with the given arguments as subscripts.
+For example,
+.ce
+\f5bar=( [color]=red [shape]=box )\fP
+creates an associate array named \f5bar\fP whose
+subscripts are \f5color\fP and \f5shape\fP.
+.P
+The third form for \fIassignment-list\fP is a list of
+normal assignments, including compound assignments.
+These assignments cause sub-variables to be assigned
+corresponding to the given assignments.
+In addition to assignments, the \fIassignment-list\fP
+can contain \f5typeset\fP commands.
+In addition to creating sub-variables,
+the effect of a compound assignment is to make
+the value of the original variable be a parenthesized
+assignment list of its components.
+For example, the assignment
+.sp
+.nf
+.in .5i
+.ta 3.4i
+\f5foo=(
+ left=bar
+ typeset -i count=3
+ point=(
+ x=50
+ y=60
+ )
+ colors=( red green yellow )
+ right=bam
+) \fP
+.ta
+.in
+.fi
+.sp
+is equivalent to the assignments
+.sp
+.nf
+.in .5i
+.ta 3.4i
+\f5foo.left=bar
+foo.count=3
+foo.point.x=50
+foo.point.y=60
+foo.colors=( red green yellow )
+foo.right=bam\fP
+.ta
+.in
+.fi
+.sp
+In addition, the value of \f5"$foo"\fP is
+.sp
+.nf
+.in .5i
+.ta 3.4i
+\f5(
+ colors=( red green yellow )
+ left=bar
+ typeset -i count=3
+ point=(
+ y=60
+ x=50
+ )
+ right=bam
+)\fP
+.ta
+.in
+.fi
+.sp
+.H 2 "Substring Generation"
+The expansion of a variable or parameter can be modified so that
+only a portion of the value results.
+It is often necessary to extract a portion of a shell variable or
+a portion of an array.
+There are several parameter expansion operators that can do this.
+One method to generate a substring is with an expansion of
+the form \fB${\fP\fIname\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP\fB}\fP
+where \fIoffset\^\fP is an arithmetic expression that defines the
+offset of the first character starting from 0, and
+\fIlength\^\fP is an arithmetic expression that defines the
+length of the substring.
+If
+.BI : length\^
+is omitted,
+the length of the value of
+.I name\^
+starting at
+.I offset\^
+is used.
+The
+.BI : offset : length
+operators can also be applied to array expansions and to parameters
+.B *
+and
+.B @
+to generate portions of an array.
+For example, the expansion, \fB${\fP\fIname\fP\fB[@]:\fP\fIoffset\fP\fB:\fP\fIlength\fP\fB}\fP, yields up to \fIlength\fP elements of the array \fIname\fP
+starting at the element \fIoffset\fP.
+.P
+The other parameter expansion modifiers use shell patterns
+to describe portions of the string to modify and delete.
+A description of shell patterns is contained below.
+When these
+modifiers are applied to special parameters
+.B @
+and
+.B *
+or to array parameters given as
+\fIname\fP\fB[@]\fP or \fIname\fP\fB[*]\fP,
+the operation is performed on each element.
+There are four parameter expansion modifiers that
+strip off leading and trailing substrings
+during parameter expansion
+by removing the characters matching a given pattern.
+An expansion of
+the form \fB${\fP\fIname\fP\fB#\fP\fIpattern\fP\fB}\fP
+causes the smallest matching prefix of the value of
+.I name\^
+to be removed.
+The largest prefix matching
+.I pattern\^
+is removed by using
+.B ##
+instead of
+.BR # .
+Similarly,
+an expansion of
+the form \fB${\fP\fIname\fP\fB%\fP\fIpattern\fP\fB}\fP
+causes the smallest matching substring at the end of
+.I name\^
+to be removed.
+Again, using
+.B %%
+instead of
+.BR % ,
+causes the largest matching trailing substring to be deleted.
+For example, if the shell variable
+.B file
+has value
+.BR foo.c ,
+then the expression
+.B ${file%.c}.o
+has value
+.BR foo.o .
+.P
+The value of an expansion can be changed by
+specifying a pattern that matches the part that needs to be changed
+after the
+the parameter expansion modifier
+.BR / .
+An expansion of the form
+\fB${\fP\fIname\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP\fB}\fP
+replaces the first match of \fIpattern\fP with
+the value of variable \fIname\fP to \fIstring\fP.
+The second
+.B /
+is not necessary when \fIstring\fP is null.
+The expansion
+\fB${\fP\fIname\fP\fB//\fP\fIpattern\fP\fB/\fP\fIstring\fP\fB}\fP
+changes all occurrences of the \fIpattern\fP into \fIstring\fP.
+The parameter expansion modifiers
+.B /#
+and
+.B /%
+cause the matching pattern to be anchored to the beginning and
+end respectively.
+.P
+Finally, there are parameter expansion modifiers that yield
+the name of the variable, the string length of the value, or the number
+of elements of an array.
+\fB${!\fP\fIname\fP\fB}\fP
+yields the name of the variable which will be \fIname\fP itself
+except when \fIname\fP is a reference variable. In this case
+it will yield the name of the variable it refers to.
+When applied to an array variable,
+\fB${!\fP\fIname\fP\fB[@]}\fP and
+\fB${!\fP\fIname\fP\fB[*]}\fP
+generate the names of all subscripts.
+\fB${#\fP\fIname\fP\fB}\fP
+will be the length in bytes of
+\fB$\fP\fIname\fP.
+For an array variable
+\fB${#\fP\fIname\fP\fB[*]}\fP
+gives the number of elements in the array.
+.H 2 "Arithmetic Evaluation"
+.P
+For the most part, the shell is a string processing
+language. However, the need for arithmetic has
+long been obvious.
+Many of the characters that are special to the
+Bourne shell are needed as arithmetic operators.
+To make arithmetic easy to use, and to maintain
+compatibility with the Bourne shell, \f5ksh\fP uses matching
+.B ((
+and
+.B ))
+to delineate arithmetic expressions.
+While single parentheses might have been
+more desirable, these already mean
+.I subshell\^
+so that another notation was required.
+The arithmetic expression
+inside the double parentheses
+follows the same syntax, associativity and precedence
+as the ANSI-C\*(Rf
+.RS
+American National Standard for Information Systems \- Programming
+Language \- C, ANSI X3.159-1989.
+.RF
+programming language.
+The characters between the matching double parentheses
+are processed with the same rules used for double
+quotes so that spaces can be used to aid readability
+without additional quoting.
+.P
+All arithmetic evaluations are performed using
+double precision floating point arithmetic.
+Floating point constants follow the same rules as
+the ANSI-C programming language.
+Integer arithmetic constants are written as
+.ce
+.IB base # number,
+where
+.I base\^
+is a decimal integer between
+two and sixty-four and
+.I number\^
+is any non-negative number.
+Base ten is used
+when no base is specified.
+The digits are represented by the characters
+.BR 0-9a-zA-Z_@ .
+For bases less than or equal to 36,
+upper and lower case characters can
+be used interchangeably to represent the digits
+from 10 thru 35.
+.P
+Arithmetic expressions are made from constants,
+variables, and operators.
+Parentheses may be used for grouping.
+The contents inside the double parentheses
+are processed with the same expansions as occurs in a double quoted string,
+so that all
+.B $
+expansions are performed before the expression is evaluated.
+However, there is usually no need to use the
+.B $
+to get the value of a variable
+because the arithmetic evaluator replaces the name of the variable
+by its value within an arithmetic expression.
+The
+.B $
+cannot be used when the variable is the subject of assignment
+or an increment operation.
+As a rule it is better not to use
+.B $
+in front of variables in an arithmetic expression.
+.P
+An arithmetic command of the form
+.B
+(( ... ))
+.R
+is a command that evaluates the enclosed arithmetic expression.
+For example, the command
+.ce
+\f5(( x++ ))\fP
+can be used to
+increment the variable \f5x\fP,
+assuming that \f5x\fP contains some numerical value.
+The arithmetic command is true (return value 0), when the resulting
+expression is non-zero, and false (return value 1) when the
+expression evaluates to zero.
+This makes the command easy to use with the \f5if\fP and \f5while\fP
+compound commands.
+.P
+The \f5for\fP compound command
+has been extended for use in arithmetic contexts.
+The syntax,
+.ce
+\f5for\fP \fB((\fP \fIexpr1\fP\fB;\fP \fIexpr2\fP \fB;\fP \fIexpr3 \fP\fB))\fP
+can be used as the first line of a \f5for\fP loop with the same semantics
+as the \f5for\fP statement in the ANSI-C programming language.
+.P
+Arithmetic evaluations can also be performed as part of the evaluation
+of a command line.
+The syntax
+.B
+$((\ ...\ ))
+.R
+expands to the value of the enclosed arithmetic expression.
+This expansion can occur wherever parameter expansion is performed.
+For example using the \f5ksh\fP command \f5print\fP (described
+later)
+.ce
+\f5print $((2+2))\fP
+prints the number 4.
+.P
+The following script prints the first
+.I n
+lines of its standard input onto its standard output,
+where
+.I n
+can be supplied as an optional argument whose default value is 20.
+.sp
+.nf
+.in .5i
+.ta 4i
+\f5integer n=${1-20} # set n
+while (( n-- >=0 )) && read -r line # at most n lines
+do print -r -- "$line"
+done\fP
+.fi
+.ta
+.in
+.sp
+.H 2 "Shell Expansions"
+.P
+The commands you enter from the terminal or from a script
+are divided into words and each word undergoes several
+expansions to generate the command name and its arguments.
+This is done in two phases.
+The first phase recognizes reserved words, spaces and operators
+to decide where command boundaries lie.
+Alias substitutions take place during this phase.
+The second phase performs expansions in the following order:
+.BL
+.LI
+Tilde substitution,
+parameter expansion,
+arithmetic expansion,
+and command substitution
+are performed from left to right.
+The option
+.B \-u
+or
+.BR nounset ,
+will cause an error to occur when any variable
+that is not set is expanded.
+.LI
+The characters that result from parameter expansion and
+command substitution above are checked with the characters
+in the
+\fB\s-1IFS\s+1\fP variable
+for possible
+field splitting.
+(See a description of \f5read\fP below to see how
+\fB\s-1IFS\s+1\fP is used.)
+Setting
+\fB\s-1IFS\s+1\fP to a null
+value causes field splitting to be skipped.
+.LI
+Pathname generation (as described below)
+is performed on each of the fields.
+Any field that doesn't match a pathname is left alone.
+The option,
+.B \-f
+or
+.BR noglob ,
+is used to disable pathname generation.
+.LE
+.H 2 "Pattern Matching"
+The shell is primarily a string processing language and uses
+patterns for matching file names as well as for matching strings.
+The characters
+.BR ? ,
+.BR * ,
+and
+.B [
+are processed specially
+by the shell when not quoted.
+These characters are used to form patterns that
+match strings.
+Patterns are used by the shell to match pathnames,
+to specify substrings,
+and for
+.B case
+commands.
+The character
+.B ?
+matches any one character.
+The character
+.B *
+matches zero or more characters.
+The character sequence
+.BR [ ... ]
+defines a character class
+that matches any character contained within
+.BR [\^] .
+A range of characters can be specified by putting a
+.B \-
+between the first and last character of the range.
+An exclamation mark,
+.BR ! ,
+immediately after the
+.BR [ ,
+means match all characters except the characters specified.
+For example, the pattern
+\f5a?c*.[!a-z]\fP
+matches any string beginning with an
+.BR a ,
+whose third character is a
+.BR c ,
+and that ends in
+.B .
+(dot) followed by any character except the lower case letters,
+.BR a\-z .
+The sequence \f5[:alpha:]\fP
+inside a character class, matches any set of characters in
+the ANSI-C
+.B alpha
+class.
+Similarly, \f5[:\fP\fIclass\fP\f5:]\fP matches
+each of the characters in the given \fIclass\fP
+for all the ANSI-C character classes.
+For example, \f5[[:alnum:]_]\fP
+matches any alpha-numeric character or the character
+.BR _ .
+.P
+\f5ksh\fP
+treats
+strings of the form
+.BI ( pattern-list
+.BR ) ,
+where
+.I pattern-list
+is a list of one or more patterns separated by a
+.BR \(bv ,
+specially when preceded by
+.BR * ,
+.BR ? ,
+.BR + ,
+.BR @ ,
+or
+.BR ! .
+A
+.B ?
+preceding
+.BI ( pattern-list )
+means that the pattern list enclosed in
+.B (\^)
+is optional.
+An
+.BI @( pattern-list )
+matches any pattern in the list of patterns enclosed in
+.BR () .
+A
+.BI *( pattern-list )
+matches any string that contains zero or more of each of the enclosed
+patterns,
+whereas
+.BI +( pattern-list )
+requires a match of one or more of any of the given patterns.
+For instance, the pattern
+.B +([0\-9])?(.)
+matches one or more digits optionally followed by a
+.BR . (dot).
+A
+.BI !( pattern-list )
+matches anything except any of the given patterns.
+For example,
+\f5print\ !(*.o)\fP
+displays all file names in the current directory that do not end in
+.BR .o .
+.P
+When patterns are used to generate pathnames when expanding
+commands several other rules apply.
+A separate match is made
+for each file name component of the pathname.
+Read permission is required for
+any portion of the pathname that contains any special
+pattern character.
+Search permission is required for every component except
+possibly the last.
+.P
+By default,
+file names in each directory that begin with \fB\s+2.\s-2\fP
+are skipped when performing a match.
+If the pattern to be matched starts with a leading \fB\s+2.\s-2\fP,
+then only files beginning with a \fB\s+2.\s-2\fP,
+are examined when reading each directory to find matching files.
+If the
+\fB\s-1FIGNORE\s+1\fP variable
+is set,
+then only files that do not match this pattern
+are considered.
+This overrides the special meaning of \fB\s+2.\s-2\fP
+in a pattern and in a file name.
+.P
+If the
+.B markdirs
+option is set,
+each matching pathname that is the name
+of a directory has a trailing
+.B /
+appended to the name.
+.P
+.H 2 "Conditional Expressions"
+The Bourne shell uses the \f5test\fP
+command, or the equivalent \f5[\fP
+command, to test files for attributes
+and to compare strings or numbers.
+The problem with \f5test\fP
+is that the shell has expanded the words of the \f5test\fP
+command and
+split them into arguments before \f5test\fP begins execution.
+\f5test\fP
+cannot distinguish between operators and operands.
+In most cases
+\f5test\ "$1"\fP
+will test whether argument 1 is non-null.
+However,
+if argument 1 is
+.BR \-f ,
+then \f5test\fP
+will treat
+.B \-f
+as an operator and
+yield a syntax error.
+One of the most frequent errors with
+\f5test\fP
+occurs when its operands are not within double quotes.
+In this case, the argument may expand to more than a single
+argument or to no argument at all. In either case this
+will likely cause a syntax error.
+What makes this most insidious is that these errors are frequently
+data dependent. A script that appears to run correctly may abort
+if given unexpected data.
+.P
+To get around these problems,
+\f5ksh\fP
+has a compound command for conditional expression testing
+as part of the language.
+The reserved words
+.B [[
+and
+.B ]]
+delimit the range of the command.
+Because they are reserved words, not operator characters,
+they require spaces to separate them
+from arguments.
+The words between
+.B [[
+and
+.B ]]
+are not processed for field splitting or for pathname generation.
+In addition, since \f5ksh\fP
+determines the operators before parameter expansion,
+expansions that yield no argument cause no problem.
+The operators within
+.BR [[ ... ]]
+are almost the same as those for the \f5test\fP
+command.
+All unary operators are of the form
+.BI \- letter
+and are followed by a single operand.
+Instead of
+.B \-a
+and
+.BR \-o ,
+.BR [[ ... ]]
+uses
+.B &&
+and
+.B \(bv\(bv
+to indicate "and" and "or".
+Parentheses are used without quoting for grouping.
+.P
+The right hand side of the string comparison operators
+.B ==
+and
+.B !=
+takes a pattern and tests whether the left hand operand
+matches this pattern. Quoting the pattern results
+is a string comparison rather than the pattern match.
+The operators
+.B <
+and
+.B >
+within
+.BR [[ ... ]]
+designate lexicographical comparison.
+.P
+In addition there are several other new comparison primitives.
+The binary operators
+.B \-ot
+and
+.B \-nt
+compare the modification times
+of two files to see which file is
+.I "older than"
+or
+.I "newer than"
+the other.
+The binary operator
+.B \-ef
+tests whether two files
+have the same device and i-node number,
+i.\ e., a link to the same file.
+.P
+The unary operator
+.B \-L
+returns true if its operand is a symbolic link.
+The unary operator
+.B \-O
+(\fB\-G\fP)
+returns true if the owner (or group) of the file operand matches
+that of the caller.
+The unary operator
+.B \-o
+returns true when its operand is the name of an option that is
+currently on.
+.P
+The following script illustrates some of the uses of
+.BR [[ ... ]] .
+The reference manual contains the complete list of operators.
+.sp
+.nf
+.in .5i
+.ta 4i
+\f5for i
+do # execute foo for numeric directory
+ if [[ \-d $i && $i == +([0\-9]) ]]
+ then foo
+ # otherwise if writable or executable file and not mine
+ elif [[ (\-w $i\(bv\(bv\-x $i) && ! \-O $i ]]
+ then bar
+ fi
+done\fP
+.fi
+.ta
+.in
+.sp
+.H 2 "Input and Output"
+\f5ksh\fP has
+extended I/O capabilities to enhance the
+use of the shell as a programming language.
+As with the Bourne shell,
+you use the I/O redirection operator,
+.BR < ,
+to control where input comes from,
+and the I/O redirection operator,
+.BR > ,
+to control where output goes to.
+Each of these operators can be preceded with a single digit that
+specifies a file unit number to associate with the file stream.
+Ordinarily you specify these I/O redirection operators with a specific
+command to which it applies.
+However, if you specify I/O redirections with the \f5exec\fP
+command,
+and don't specify arguments to \f5exec\fP,
+then the I/O redirection applies to the current program.
+For example, the command
+\f5exec\ <\ foobar\fP
+opens file \f5foobar\fP
+for reading.
+The \f5exec\fP
+command is also used to close files.
+A file descriptor unit can be opened as a copy of an existing
+file descriptor unit by using either of the
+.B <&
+or
+.B >&
+operators and putting the file descriptor unit of the original file
+after the
+.BR & .
+Thus, \f52>&1\fP means open standard error (file descriptor 2)
+as a copy of standard output (file descriptor 1).
+A file descriptor value of
+.B \-
+after the
+.B &
+indicates that the file should be closed.
+To close file unit 5, specify
+\f5exec\ 5<&-\fP.
+There are two additional redirection operators with \f5ksh\fP
+and the POSIX shell that are not part of the Bourne shell.
+The
+.B >|
+operator overrides the effect of the
+.B noclobber
+option described earlier.
+The
+.B <\^>
+operator causes a file to be opened for both reading and writing.
+.P
+\f5ksh\fP recognizes certain pathnames and treats them
+specially.
+Pathnames of the form
+.BI /dev/fd/ n\^
+are treated as equivalent to the file defined by file descriptor
+.IR n .
+These name can be used as the script argument to \f5ksh\fP
+and in conditional testing as described above.
+On underlying systems that support
+.B /dev/fd
+in the file system, these names can be passed to other commands.
+Pathnames of the form
+.BI /dev/tcp/ hostid / port
+and
+.BI /dev/udp/ hostid / port
+can be used to create
+.B tcp
+and
+.B udp
+connections to services given by the
+.I hostid\^
+number and
+.I port\^
+number.
+The
+.I hostid\^
+cannot use symbolic values. In practice these
+numbers are typically generated by command substitution.
+For example,
+\f5exec\ 5>\ /dev/tcp/$(service\ name)\fP
+would open file descriptor 5 for sending messages
+to hostid and port number defined by the output of \f5service\ name\fP.
+.P
+The Bourne shell has a built-in command \f5read\fP
+for reading lines from standard input (file descriptor 0)
+and splitting it into fields based on the value of the
+.B \s-1IFS\s+1
+variable, and a command \f5echo\fP
+to write strings to standard output.
+(On some systems, \f5echo\fP
+is not a built-in command and incurs considerable overhead to use.)
+Unfortunately, neither of these commands
+is able to perform some very basic tasks.
+For example.
+with the Bourne shell,
+the \f5read\fP
+built-in cannot read a single line that ends in
+.BR \e .
+With \f5ksh\fP
+the \f5read\fP
+built-in has a
+.B \-r
+option to remove the special meaning for
+.B \e
+which allows it to be
+treated as a regular
+character rather than the line continuation character.
+With the Bourne shell,
+there is no simple way to have more than one file open
+at any time for reading.
+\f5ksh\fP has options on the \f5read\fP
+command to specify the file
+descriptor for the input.
+The fields that are read from a line can be stored into an indexed
+array with the
+.B \-A
+option to read.
+This allows a line to be split into an arbitrary number of fields.
+.P
+The way the Bourne shell uses the
+\fB\s-1IFS\s+1\fP variable to
+split lines into fields greatly limits its utility.
+Often data files consist of lines that use a character such
+as
+.B :
+to delimit fields with two adjacent delimiters that denote
+a null field.
+The Bourne shell treats adjacent delimiters as a single
+field delimiter.
+With \f5ksh\fP,
+delimiters that are considered white space characters
+have the behavior of the Bourne shell, but other
+adjacent delimiters separate
+null fields.
+.P
+The \f5read\fP command is often used in scripts that interact
+with the user by prompting the user and then requesting some
+input.
+With the Bourne shell two commands are needed; one to
+prompt the user, the other to read the reply.
+\f5ksh\fP allows these two commands to be combined.
+The first argument of the \f5read\fP
+command can be followed by a
+.B ?
+and a prompt string which is used whenever the input
+device is a terminal.
+Because the prompt is associated with the \f5read\fP built-in,
+the built-in command line editors will be able to re-output
+the prompt whenever the line needs to be refreshed when
+reading from a terminal device.
+.P
+With the Bourne shell,
+there is no way to set a time limit for waiting for the user
+response to read.
+The
+.B \-t
+option to \f5read\fP takes a floating
+point argument that gives the time in seconds,
+or fractions of seconds that the shell should wait for a reply.
+.P
+The version of the \f5echo\fP command in System V
+treats certain sequences beginning with
+.B \e
+as control sequences.
+This makes it hard to output strings without interpretation.
+Most BSD derived systems do not interpret
+.B \e
+control sequences.
+Unfortunately, the BSD versions of \f5echo\fP accepts a
+.B \-n
+option to prevent a trailing new-line, but has no way to
+cause the string
+.B \-n
+to be printed.
+Neither of these versions is adequate. Also, because they
+are incompatible, it is very hard to write portable shell scripts
+using \f5echo\fP.
+The \f5ksh\fP built-in, \f5print\fP,
+outputs characters to the terminal or to a file and
+subsumes the functions of all versions of \f5echo\fP.
+Ordinarily, escape sequences in arguments beginning with
+.B \e
+are processed the same as for the System V \f5echo\fP command.
+However \f5print\fP follows the standard conventions for
+options and has options that make \f5print\fP very versatile.
+The
+.B \-r
+option can be used to output the arguments without any special meaning.
+The
+.B \-n
+option can be used here to suppress the trailing new-line
+that is ordinarily appended.
+As with \f5read\fP, it is possible to specify the file descriptor number
+as an option to the command to avoid having to use
+redirection operators with each occurrence of the command.
+.P
+The IEEE POSIX shell and utilities standard committee was unable
+to reconcile the differences between the System V and BSD
+versions of \f5echo\fP.
+They introduced a new command named \f5printf\fP
+which takes an ANSI-C format string and a list of options
+and outputs the strings using the ANSI-C formatting rules.
+Since \f5ksh\fP is POSIX conforming, it accepts \f5printf\fP.
+However, there is a
+.B \-f
+options to \f5print\fP that can be used to specify
+a format string which processes the arguments the same way that
+\f5printf\fP does.
+.P
+The format processing for \f5print\fP and \f5printf\fP has
+been extended slightly.
+There are three additional formatting directives.
+The
+.B %b
+format causes the
+.B \e
+escape sequences to be expanded as they are with the System V \f5echo\fP
+command.
+The
+.B %q
+format causes quotes to
+be placed on the output as required
+so that it can be used as shell input.
+Special characters in the output of most \f5ksh\fP built-in commands
+and in the output from an execution trace
+are quoted in an equivalent fashion.
+The
+.B %P
+format causes an extended regular expression string to
+be converted into a shell pattern.
+This is useful for writing shell applications that have
+to accept regular expressions as input.
+Finally, the escape sequence
+.B \e\^E
+which expands to the terminal escape character (octal 033)
+has been added.
+.P
+The shell is frequently used as a programming language for
+interactive dialogues.
+The
+\f5select\fP
+statement has been added to the language
+to make it easier to
+present menu selection alternatives to the
+user and evaluate the reply.
+The list of alternatives is numbered and put in columns.
+A user settable prompt,
+\fB\s-1PS3\s+1\fP,
+is issued and if the answer is
+a number corresponding to one of the alternatives,
+the select loop variable is set to this value.
+In any case, the
+.B \s-1REPLY\s+1
+variable is used to store the user entered reply.
+The shell variables
+.B \s-1LINES\s+1
+and
+.B \s-1COLUMNS\s+1
+are used to control the layout of select lists.
+.H 2 "Option Parsing"
+The \f5getopts\fP built-in command can be used
+to process command arguments in a manner consistent
+with the way \f5ksh\fP does for its own built-in commands.
+.P
+The \f5getopts\fP built-in allows users to specify options
+as separate arguments or to group options that do not
+take arguments together. Options that require arguments
+do not require space to separate them from the option argument.
+The
+.B \s-1OPTARG\s+1
+variable stores the value of the option argument
+after finding a variable that takes an argument.
+The
+.B \s-1OPTIND\s+1
+variable holds the index of the current options argument.
+After processing options, the arguments should be
+shifted by
+.B \s-1OPTIND\s+1\-1
+to make the
+remaining arguments be \f5"$@"\fP.
+.P
+The \f5getopts\fP argument description allows additional
+information to be specified along with the options
+that is used to generate \fIusage\fP messages for
+incorrect arguments and for the option argument \fB\-?\fP.
+The example in the APPENDIX uses \f5getopts\fP to process
+its arguments.
+.H 2 "Co-process"
+\f5ksh\fP can spawn a
+.I co-process
+by adding a
+.B "|&"
+after a command.
+This process will be run with its standard input and its
+standard output connected to the shell. The built-in command \f5print\fP
+with the
+.B \-p
+option will write into the standard input of this
+process and
+the built-in command \f5read\fP
+with the
+.B \-p
+option will read from the output of this process.
+.P
+In addition, the I/O redirection operators \fB<&\fP and \fB>&\fP can
+be used to move the input or output pipe of the co-process
+to a numbered file descriptor.
+Use \f5exec\ 3>&\ p\fP to move the input of the co-process
+to file descriptor \fB3\fP.
+After you have connected to file descriptor \fB3\fP, you
+can direct the output of any command to the co-process
+by running \fIcommand\fP\f5\ >&3\fP.
+Also, by moving the input of the co-process to a numbered descriptor,
+it is possible to run a second co-process.
+The output of both co-processes will be the file descriptor
+associated with \f5read\ -p\fP.
+You can use \f5exec\ 4<&\ p\fP to cause the output of these
+co-processes to go to file descriptor \fB4\fP of the shell.
+Once you have moved the pipe to descriptor \fB4\fP, it is possible
+to connect a server to the co-process by running \fIcommand\fP\f5\ 4<&\ p\fP
+or to close the co-process pipe with \f5exec\ 4<&\ -\fP.
+.H 2 "Functions"
+.P
+Function definitions are of the form
+.sp
+.in +.5i
+.nf
+\f5function\fP \fIname\fP
+.br
+.B {
+.br
+ any shell script
+.br
+.B }
+.fi
+.sp
+.in
+A function whose name contains a \fB\s+2.\s-2\fP
+is called a \fIdiscipline\fP function.
+The portion of the name after the last \fB\s+2.\s-2\fP
+is the name of the discipline.
+Discipline functions named \f5get\fP, \f5set\fP, and \f5unset\fP
+can be assigned to any variable to intercept lookups,
+assignments and unsetting of the variable
+defined by the portion of the name before the last \fB\s+2.\s-2\fP.
+Applications can create additional disciplines for variables
+that are created as part of user defined built-ins.
+The portion of the name before the last \fB\s+2.\s-2\fP
+must refer to the name of an existing variable.
+Thus, if \f5p\fP is a reference to \f5PATH\fP, then
+the function name \f5p.get\fP and \f5PATH.get\fP
+refer to the same function.
+.P
+The function is invoked either
+by specifying
+.I name
+as the command name
+and optionally following it with arguments
+or by using it as an option to the \fB\s+2.\s-2\fP
+built-in command.
+Positional parameters are saved before each
+function call and restored when completed.
+The arguments that follow the function name on the calling
+line become positional parameters inside the function.
+The \f5return\fP
+built-in can be used to cause the function to return to
+the statement following
+the point of invocation.
+.P
+Functions can also be defined with the System V notation,
+.sp
+.in +.5i
+.nf
+\fIname\fP \f5()\fP
+.br
+.B {
+.br
+ any shell script
+.br
+.B }
+.fi
+.sp
+.in
+Functions defined with this syntax cannot be used as the first
+argument to a \fB\s+2.\s-2\fP procedure.
+\f5ksh\fP accepts this notation for compatibility only.
+There is no need to use this notation when writing
+\f5ksh\fP scripts.
+.P
+Functions defined with the \f5function\fP\ \fIname\fP syntax
+and invoked by name
+are executed in the current shell environment
+and can share named variables with the calling program.
+Options, other than execution trace
+.BR \-x ,
+set by the calling program are
+passed down to a function.
+The options are
+not shared with
+the function so that any options set within a function are
+restored when the function exits.
+Traps ignored by the caller are ignored within the function
+and cannot be enabled.
+Traps caught by the calling program are reset to their
+default action within the function.
+In most instances, the default action is
+to cause the function to terminate.
+A trap on
+\fB\s-1EXIT\s+1\fP
+defined within a function executes after the function
+completes but
+before the caller resumes.
+Therefore,
+any variable assignments and
+any options set as part of a trap action will be effective
+after the caller resumes.
+.P
+By default, variables are inherited by the function and shared
+by the calling program.
+However,
+for functions defined with the \f5function\fP\ \fIname\fP syntax
+that are invoked by name,
+environment substitutions preceding the function call
+apply only to the scope of the function call.
+Also, variables whose names do not contain a \fB\s+2.\s-2\fP
+that are defined with the \f5typeset\fP
+built-in command are local to the function that they are declared in.
+Thus, for the function defined
+.sp
+.nf
+.in .5i
+\f5function name
+{
+ typeset -i x=10
+ let z=x+y
+ print $z
+}\fP
+.fi
+.ta
+.in
+.sp
+invoked as
+\f5y=13\ name\fP,
+\f5x\fP and \f5y\fP
+are local variables with respect to the function
+\f5name\fP
+while
+\f5z\fP
+is global.
+.P
+Functions defined with the \fIname\fP\f5()\fP syntax,
+and functions invoked as an argument to the \fB\s+2.\s-2\fP
+command,
+share everything other than positional parameters with the caller.
+Assignments that precede the call remain in effect after the
+function completes.
+.P
+Alias and function names are not passed down to shell scripts
+or carried across separate
+invocations of \f5ksh\fP.
+The
+.B $\s-1FPATH\s+1
+variable gives a colon separated list of directories that
+is searched for function definitions when trying to resolve
+the command name.
+Whenever a file name contained in
+.B $\s-1FPATH\s+1
+is found, the complete file is read and all functions
+contained within become defined.
+.P
+Calls that reference functions can be recursive.
+Except for special built-ins,
+function names take precedence over built-in names and names
+of programs when used as command names.
+To write a replacement function that invokes the command that
+you wish to replace,
+you can use the \f5command\fP built-in command.
+The arguments to \f5command\fP are the name and arguments
+of the program you want to execute.
+For example to write a
+.B cd
+function which changes the directory and prints out the directory name,
+you can write
+.sp
+.nf
+.in .5i
+\f5function cd
+{
+ if command cd "$@"
+ then print -r -- $PWD
+ fi
+}\fP
+.fi
+.ta
+.in
+.sp
+.P
+The
+\fB\s-1FPATH\s+1\fP
+variable is a colon separated list that \f5ksh\fP
+uses to search for function definitions.
+When
+\f5ksh\fP
+encounters an autoload function,
+it runs the
+.B .
+command on the script containing the function,
+and then executes the function.
+.P
+For interactive shells,
+function definitions may also be placed in the
+\fB\s-1ENV\s+1\fP
+file.
+However, this
+causes the shell to take longer to begin executing.
+.H 2 "Process Substitution"
+.P
+This feature is only available
+on versions of the UNIX operating system which support the
+.B /dev/fd
+directory for naming open files.
+Each command argument of the form
+\fB<(\fP\fIlist\^\fP\fB)\fP
+or
+\fB>(\fP\fIlist\^\fP\fB)\fP
+will run process
+.I list
+asynchronously connected to some file in the
+.B /dev/fd
+directory.
+The name of this file will become the argument to the command.
+If the form with
+.B >
+is selected then writing on this file will provide input for
+.IR list .
+If
+.B <
+is used,
+then the file passed as an argument will contain the output of the
+.I list
+process.
+For example,
+.sp
+.nf
+.in .5i
+\f5paste <(cut \-f1 \fP\fIfile1\fP\f5) <(cut \-f2 \fP\fIfile2\fP\f5) | tee >(\fP\fIprocess1\fP\f5) >(\fP\fIprocess2\fP\f5)\fP
+.fi
+.ta
+.in
+.sp
+extracts
+fields 1 and 3 from
+the files
+.I file1
+and
+.I file2
+respectively,
+places the
+results side by side, and
+sends it
+to the processes
+.I process1
+and
+.IR process2 ,
+as well as putting it onto the standard output.
+Note that the file which is passed as an argument to the command is
+a UNIX system
+.IR pipe (2)
+so that the programs that expect to
+.IR lseek (2)
+on the file will not work.
+.H 2 "Finding Commands"
+.P
+The addition of aliases, functions,
+and more built-ins
+has made it substantially more difficult to know what
+a given command name really means.
+.P
+Commands that begin with reserved words
+are an integral part of the shell language itself
+and typically define the control flow of the language.
+Some control flow commands are not reserved words in
+the language but are \fIspecial\fP built-ins.
+Special built-ins are built-ins that are considered a
+part of the language rather than user definable commands.
+The best examples of commands that fit this description
+are \f5break\fP and \f5continue\fP.
+Because they are not reserved words, they can be the
+result of shell expansions and are not effected by quoting.
+These commands have the following special properties:
+.BL
+.LI
+Assignments that precede them apply to the current shell process,
+not just to the given command.
+.LI
+An error in the format of these commands cause a shell script
+or function that contains them to abort.
+.LI
+They cannot be overridden by shell functions.
+.LE
+.P
+Other commands are built-in because they perform side effects
+on the current environment that would be nearly impossible
+to implement otherwise.
+Built-ins such as \f5cd\fP and \f5read\fP
+are examples of such built-ins.
+These built-ins are semantically equivalent to commands that
+are not built-in except that they don't take a path search
+to locate.
+.P
+A third reason to have a command built-in is so that
+it will be unaffected by the setting of the
+.B \s-1PATH\s+1
+variable.
+The \f5print\fP command fits this category.
+Scripts that use \f5print\fP will be portable
+to all sites that run \f5ksh\fP.
+.P
+The final reason for having a command be a built-in is
+for performance.
+On most systems it is more than an order of magnitude
+faster to initiate a command that is built-in than
+to create a separate process to run the command.
+Examples that fit this category are \f5test\fP
+and \f5pwd\fP.
+.P
+Given a command name \f5ksh\fP decides what it means using
+the following order:
+.BL
+.LI
+Reserved words define commands that form part of the shell
+grammar.
+They cannot be quoted.
+.LI
+Alias substitutions occur first as part of the reading of commands.
+Using quotes in the command name will prevent alias substitutions.
+.LI
+Special built-ins.
+.LI
+Functions.
+.LI
+Commands that are built-in that are not associated with a pathname
+such as \f5cd\fP and \f5print\fP.
+.LI
+If the command name contains a
+.BR / ,
+the program or script corresponding to the given name is executed.
+.LI
+A path search locates the pathname corresponding to the command.
+If the pathname where it is found matches the pathname associated
+with a built-in command, the built-in command is executed.
+If the directory where the command is found is listed in the
+.B \s-1FPATH\s+1
+variable, the file is read into the shell
+like a dot script, and a function by that name is invoked.
+Once a pathname is found, \f5ksh\fP remembers its location
+and only checks relative directories in \fB\s-1PATH\s+1\fP
+the next time the command name is used.
+Assigning a value to \fB\s-1PATH\s+1\fP
+causes \f5ksh\fP to forget the location of all command names.
+.LI
+The
+.B \s-1FPATH\s+1
+variable is searched and files found are treated as described above.
+.LE
+.P
+The first argument of the \f5command\fP built-in, described earlier,
+skips the checks for reserved words and for function definitions.
+In all other ways, \f5command\fP behaves like a built-in
+that is not associated with a pathname.
+As a result, if the first argument of \f5command\fP is
+a special built-in, the special properties of this built-in
+do not apply.
+For example, whereas, \f5exec\ 3<\ foo\fP will cause a script containing
+it to abort if the open fails, \f5command\ exec\ 3<\ foo\fP
+results in a non-zero exit status but does not abort the script.
+.P
+You can get a complete list of the special built-in commands
+with \f5builtin\ -s\fP.
+In addition \f5builtin\fP without arguments gives a list of
+the current built-ins and the pathname that they are associated with.
+A built-in can be bound to another pathname by giving
+the pathname for the built-in. The basename of this path must
+be the name of an existing built-in for this to succeed.
+Specifying the name of the built-in without a pathname causes
+this built-in to be found before a path search.
+A built-in can be deleted with the \fB\-d\fP option.
+.P
+On systems with run time loading of libraries, built-in commands
+can be added with the \f5builtin\fP command.
+Each command that is to be built-in must be written as a
+C function whose name is of the form \f5b_\fP\fIname\fP, where
+\fIname\fP is the name of the built-in that is to be added.
+The function has the same argument calling convention as
+\f5main\fP. The lower eight bits of the return value become
+the exit status for this built-in.
+Builtins are added by specifying the pathname of the library
+as an argument to the \fB\-f\fP option of \f5builtin\fP.
+.P
+The built-in command,
+\f5whence\fP,
+when used with the
+.B \-v
+option, tells how a given command is bound.
+A line is printed for each argument to \f5whence\fP
+telling what would happen if this argument were used as a command name.
+It reports on reserved words, aliases, built-ins, and
+functions.
+If the command is none of the above,
+it follows the path search rules and prints the full path-name,
+if any, otherwise it prints an error message.
+.H 2 "Symbolic Names"
+To avoid implementation dependencies, \f5ksh\fP
+accepts and generates symbolic names
+for built-ins that use numerical values in the Bourne shell.
+The
+.B \-S
+option of the
+\f5umask\fP built-in command
+accepts and displays
+default file creation permissions
+symbolically.
+It uses the same symbolic notation as the \f5chmod\fP command.
+.P
+The \f5trap\fP and \f5kill\fP built-in commands
+allows the signal names to be given symbolically.
+The names of signals and traps
+corresponding to signals are the same as the signal name with
+the
+.B \s-1SIG\s+1
+prefix removed.
+The trap
+.B 0
+is named
+\fB\s-1EXIT\s+1\fP.
+.H 2 "Additional Variables"
+In addition to the variables discussed earlier, \f5ksh\fP
+has other variables that it handles specially.
+The variable \fB\s-1RANDOM\s+1\fP
+produces a random number in the range 0 to 32767 each time it is referenced.
+Assignment to this variable sets the seed for the
+random number generator.
+.P
+The parameter \fB\s-1PPID\s+1\fP
+is used to generate the process id of the process which invoked this shell.
+.H 2 "Added Traps"
+A new trap named
+\fB\s-1ERR\s+1\fP
+has been added.
+This trap is invoked whenever the shell would exit if the
+.B \-e
+option were set.
+This trap is used by
+Fourth Generation Make\*(Rf
+.RS
+G. S. Fowler,
+.I "The Fourth Generation Make,"
+Proceedings of the Portland USENIX meeting, pp. 159-174, 1985.
+.RF
+which runs \f5ksh\fP
+as a co-process.
+.P
+A trap named
+\fB\s-1DEBUG\s+1\fP
+gets executed after each command.
+This trap can be used for debugging and other purposes.
+.P
+The
+\fB\s-1KEYBD\s+1\fP
+trap was described earlier.
+.H 2 Debugging
+The primary method for debugging Bourne shell scripts is to
+use the
+.B \-x
+option to enable the execution trace.
+After all
+the expansions have been performed,
+but before each command is executed,
+the trace writes to standard error the name and arguments
+of each command preceded by a
+.BR + .
+While the trace is very useful, there is no way
+to find out what line of source a given trace line
+corresponds to.
+With
+\f5ksh\fP
+the
+\fB\s-1PS4\s+1\fP
+variable
+is evaluated for parameter expansion and
+is displayed before each command,
+instead of the
+.BR + .
+.P
+The
+\fB\s-1LINENO\s+1\fP
+variable is set to the current line number relative to the
+beginning of the current script or function.
+It is most useful as part of the
+\fB\s-1PS4\s+1\fP
+prompt.
+.P
+The
+\fB\s-1DEBUG\s+1\fP
+trap can be used to write a break point shell
+debugger in \f5ksh\fP.
+An example of such a debugger is \f5kshdb\fP.\*(Rf
+.RS
+Bill Rosenblatt,
+.IR "Debugging Shell Scripts with \f5kshdb\fP" ,
+Unix World, Volume X, No. 5, 1993.
+.RF
+.H 2 "Timing Commands"
+.P
+Finding the time it takes to execute commands
+has been a serious problem with the Bourne shell.
+Since the \f5time\fP command is not part of the
+language, it is necessary to write a script
+in order to time a \f5for\fP or \f5while\fP loop.
+The extra time in invoking the shell and processing
+the script is accumulated along with the time
+to execute the script.
+.P
+More seriously, the Bourne shell does not give correct
+times for pipelines.
+The reason for this is that the times for some members
+of a pipeline are not counted when computing the time.
+As an extreme example,
+running \f5time\fP on the script
+.ce
+\f5cat < /dev/null | sort -u bigfile | wc\fP
+with the Bourne shell will show very little
+user and system time no matter how
+large \f5bigfile\fP is.
+.P
+To correct these problems,
+a reserved word \f5time\fP
+has been added to replace
+the \f5time\fP
+command.
+Any function, command or pipeline can be preceded by this reserved word
+to obtain information about the elapsed, user, and system times.
+Since I/O redirections bind to the command, not to
+\f5time\fP,
+parentheses should be used to redirect the timing information which
+is normally printed on file descriptor 2.
+.H 1 SECURITY
+There are several documented problems associated with the security of
+shell procedures\*(Rf.
+.RS
+F. T. Grampp and R. H. Morris,
+.I "UNIX Operating System Security,"
+AT&T Bell Labs Tech. Journal, Vol. 63, No. 8, Part 2, pp. 1649-1671, 1984.
+.RF
+These security holes occur primarily because a user can manipulate the
+.I environment
+to subvert the intent of a
+.I setuid
+shell procedure.
+Sometimes, shell procedures are initiated from
+binary programs, without the author's
+awareness, by library routines which invoke shells to carry out
+their tasks.
+When the binary program is run
+.I setuid
+then the shell procedure runs with the permissions afforded to the
+owner of the binary file.
+.P
+In the Bourne shell,
+the
+.B \s-1IFS\s+1
+parameter is used to split each word into separate command arguments.
+If a user knows that some
+.I setuid
+program will run
+\f5sh\ -c\ /bin/pwd\fP
+(or any other command in
+.BR /bin )
+then the user sets and exports
+.BR \s-1IFS\s+1=\^/ .
+Instead of running
+.B /bin/pwd
+the shell will run
+.B bin
+with
+.B pwd
+as an argument.
+The user puts his or her own \f5bin\fP
+program into the current directory.
+This program can
+create a copy of the shell,
+make this shell
+.IR setuid ,
+and then run the \f5/bin/pwd\fP
+program so that the original program continues to run successfully.
+This kind of penetration is not possible with
+\f5ksh\fP
+since the
+.B \s-1IFS\s+1
+parameter only splits arguments that result from command or parameter
+substitution.
+.P
+Some
+.I setuid
+programs run programs using
+.I system()
+without giving the full pathname.
+If the
+user sets the
+.B \s-1PATH\s+1
+variable so that the desired command will be found
+in his or her local bin, then the same technique described above can
+be employed to compromise the security of the system.
+To close up this and other security holes,
+\f5ksh\fP
+resets the effective user id to the real user id and the effective
+group id to the real group id unless the
+.I privileged
+option
+.RB ( \-p\^ )
+is specified at invocation.
+In
+this mode, the
+.B privileged
+mode, the
+.B .profile
+and
+.B \s-1ENV\s+1
+files are not processed.
+Instead, the file
+.B /etc/suid_profile
+is read and executed.
+This gives an administrator control over the
+environment to set the
+.B \s-1PATH\s+1
+variable or to log setuid shell invocations.
+Clearly security of the system is compromised if
+.B /etc
+or this file is publicly writable.
+.P
+Some versions of the UNIX operating system look for the characters
+\f5#!\fP
+as the first two characters of an executable file.
+If these characters are found, then the next word on this line is taken
+as the interpreter to
+invoke
+for this command and the interpreter is
+.IR exec ed
+with the name of the script as argument zero and argument one.
+If the
+.I setuid
+or
+.I setgid
+bits are on for this file, then the interpreter
+is run with the effective uid and/or gid set accordingly.
+This scheme has three major drawbacks.
+First of all,
+putting the pathname of the interpreter into the script
+makes the script less portable since the interpreter
+may be installed in a different directory on another system.
+Secondly, using the
+\f5#!\fP
+notation forces an
+.B exec
+of the interpreter even when the call is invoked from the interpreter
+which it must exec. This is inefficient since
+\f5ksh\fP can handle a failed exec much faster than starting up
+again.
+More importantly,
+.I setuid
+and
+.I setgid
+procedures provide an easy target for intrusion.
+By linking a
+.I setuid
+or
+.I setgid
+procedure to a name beginning with a
+.B \-
+the interpreter is fooled into thinking that it is being invoked with
+a command line option rather than the name of a file.
+When the interpreter is the shell, the user gets a privileged
+interactive shell.
+There is code in
+\f5ksh\fP
+to guard against this simple form of intrusion.
+.P
+A more reliable way to handle
+.I setuid
+and
+.I setgid
+procedures is provided with
+\f5ksh\fP.
+The technique does not require any changes to the operating system
+and provides better security.
+Another advantage to this method is that it also allows scripts which
+have execute permission but no read permission to run. Taking away read
+permission makes scripts more secure.
+.P
+The method relies on a setuid
+.B root
+program to authenticate the
+request and exec the shell with the correct mode bits to carry out
+the task. This shell is invoked with the requested file already open
+for reading. A script which cannot be opened for reading or which
+has its setuid and/or setgid bits turned on causes this setuid
+.B root
+program to get \fBexec\fPed.
+For security reasons, this program is given the full
+pathname
+\f5/etc/suid_exec\fP.
+A description of the implementation of the
+\f5/etc/suid_exec\fP
+program can be found in
+a separate paper\*(Rf.
+.RS
+D. G Korn
+.I "Parlez-vous Kanji?"
+TM-59554-860602-03, 1986.
+.RF
+.H 1 "CODE CHANGES"
+\f5ksh\fP is written in ANSI-C as a reusable library.
+The code can be compiled with C++ and older K&R C as well.
+The code uses the IEEE POSIX 1003.1 and ISO 9945-1 standard\*(Rf
+.RS
+.I "POSIX \- Part 1: System Application Program Interface,"
+IEEE Std 1003.1-1990, ISO/IEC 9945-1:1990.
+.RF
+wherever possible so that \f5ksh\fP should be able to run
+on any POSIX compliant system. In addition, it is possible
+to compile \f5ksh\fP for older systems.
+.P
+Unlike earlier version of the Bourne shell,
+\f5ksh\fP treats eight bit characters transparently
+without stripping off the
+leading bit.
+There is also a compile time switch to enable handling multi-byte
+and multi-width characters sets.
+.P
+On systems with dynamic libraries, it is possible to add built-in
+commands at run time with the built-in command \f5builtin\fP
+described earlier.
+It is also possible to embed \f5ksh\fP in applications in
+a manner analogous to \f5tcl\fP.
+.H 1 "EXAMPLE"
+.P
+An example of a \f5ksh\fP script is included
+in the Appendix.
+This one page program is a variant of the UNIX system
+\f5grep\fP(1) program.
+Pattern matching for this version of \f5grep\fP
+means shell patterns.
+.P
+The first half uses the \f5getopts\fP command to
+find the option flags.
+Nearly all options have been implemented.
+The second half goes through each line of each file
+to look for a pattern match.
+.P
+This program is not intended to serve as a
+replacement for \f5grep\fP
+which has been highly tuned for performance.
+It does
+illustrate the programming power of \f5ksh\fP.
+Note that no auxiliary processes are spawned by this script.
+It was written and debugged in under two hours.
+While performance is acceptable for small files,
+this program runs at only one tenth
+the speed of \f5grep\fP
+for large files.
+.H 1 "PERFORMANCE"
+.P
+\f5ksh\fP executes many scripts faster than the System V Bourne shell;
+in some cases more than 10 times as fast.
+The primary reason for this is that \f5ksh\fP creates fewer
+processes.
+The time to execute a built-in command or a function is one or two
+orders of magnitude faster than performing a \f5fork\fP() and
+\f5exec\fP() to create a separate process.
+Command substitution and commands inside parentheses
+are performed without creating another process, unless necessary
+to preserve correct behavior.
+.P
+Another reason for improved performance is the use of the \fBsfio\fP\*(Rf,
+.RS
+David Korn and Kiem-Phong Vo,
+.IR "SFIO - A Safe/Fast String/File I/O,"
+Proceedings of the Summer Usenix,
+pp. 235-255, 1991.
+.RF
+library for I/O. The \fBsfio\fP library buffers all I/O
+and buffers are flushed only when required.
+The algorithms used in \fBsfio\fP perform better than
+traditional versions of standard I/O so that programs that
+spend most of their time
+formatting output may actually perform better
+than versions written in C.
+.P
+Several of the internal algorithms have been changed
+so that the number of subroutine calls has been
+substantially reduced.
+\f5ksh\fP uses variable sized hash tables for variables.
+Scripts that rely heavily on referencing variables execute faster.
+More processing is performed while reading the script
+so that execution time is saved while running loops.
+These changes are not noticeable for scripts that \f5fork()\fP
+and run processes,
+but they reduce the time that it takes to interpret commands by
+more than a factor of two.
+.P
+Most importantly, \f5ksh\fP provide mechanisms to write applications
+that do not require as many processes.
+The arithmetic provided by the shell eliminates the need for the
+\f5expr\fP command.
+The pattern matching and substring capabilities eliminate the
+need to use \f5sed\fP or \f5awk\fP to process strings.
+.P
+The architecture of \f5ksh\fP makes it easy to make commands
+built-ins without changing the semantics at all.
+Systems that have run-time binding of libraries allow
+applications to be sped up by supplying the critical
+programs as shell built-in commands.
+Implementations on other systems can add built-in commands
+at compile time.
+The procedure for writing built-in commands that can be loaded
+at run time is in a separate document.\*(Rf,
+.RS
+David Korn,
+.IR "Guidelines for writing \f5ksh-93\fP built-in commands,"
+to be published, 1994.
+.RF
+.H 1 "CONCLUSION"
+.P
+The 1988 version of \f5ksh\fP has tens of thousands of regular users
+and is a suitable replacement for the Bourne shell.
+The 1993 version of \f5ksh\fP is essentially upward compatible with
+both the 1988 version of \f5ksh\fP and with the recent IEEE POSIX
+and ISO shell standard.
+The 1993 version offers many advantages for programming applications,
+and it has been rewritten so that it can be used in embedded applications.
+It also offers improved performance.
+.SG dgk \" signature typist initials
+\" .CS 14 24 38 0 0 16 \" cover sheet for TM
+.bp
+.ce
+\fIAPPENDIX\fP
+.nf
+\f5
+.ta .66i 1.33i 2i 2.66i 3.33i 4i 4.66i 5.33i 6i 6.66i 7.33i 8i
+.so grep.mm
+.fi
+\fP
+
+
diff --git a/usr/src/lib/libshell/common/sh/args.c b/usr/src/lib/libshell/common/sh/args.c
new file mode 100644
index 0000000000..ad1bf46a40
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/args.c
@@ -0,0 +1,846 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * UNIX shell
+ *
+ * S. R. Bourne
+ * Rewritten by David Korn
+ * AT&T Labs
+ *
+ */
+
+#include "defs.h"
+#include "path.h"
+#include "builtins.h"
+#include "terminal.h"
+#include "edit.h"
+#include "FEATURE/poll"
+#if SHOPT_KIA
+# include "shlex.h"
+# include "io.h"
+#endif /* SHOPT_KIA */
+#if SHOPT_PFSH
+# define PFSHOPT "P"
+#else
+# define PFSHOPT
+#endif
+#if SHOPT_BASH
+# define BASHOPT "\375\374\373"
+#else
+# define BASHOPT
+#endif
+#if SHOPT_HISTEXPAND
+# define HFLAG "H"
+#else
+# define HFLAG ""
+#endif
+
+#define SORT 1
+#define PRINT 2
+
+void sh_applyopts(Shopt_t);
+
+static int arg_expand(struct argnod*,struct argnod**,int);
+
+static char *null;
+
+/* The following order is determined by sh_optset */
+static const char optksh[] = PFSHOPT BASHOPT "DircabefhkmnpstuvxBCGEl" HFLAG;
+static const int flagval[] =
+{
+#if SHOPT_PFSH
+ SH_PFSH,
+#endif
+#if SHOPT_BASH
+ SH_NOPROFILE, SH_RC, SH_POSIX,
+#endif
+ SH_DICTIONARY, SH_INTERACTIVE, SH_RESTRICTED, SH_CFLAG,
+ SH_ALLEXPORT, SH_NOTIFY, SH_ERREXIT, SH_NOGLOB, SH_TRACKALL,
+ SH_KEYWORD, SH_MONITOR, SH_NOEXEC, SH_PRIVILEGED, SH_SFLAG, SH_TFLAG,
+ SH_NOUNSET, SH_VERBOSE, SH_XTRACE, SH_BRACEEXPAND, SH_NOCLOBBER,
+ SH_GLOBSTARS, SH_RC, SH_LOGIN_SHELL,
+#if SHOPT_HISTEXPAND
+ SH_HISTEXPAND,
+#endif
+ 0
+};
+
+#define NUM_OPTS (sizeof(flagval)/sizeof(*flagval))
+
+typedef struct _arg_
+{
+ Shell_t *shp;
+ struct dolnod *argfor; /* linked list of blocks to be cleaned up */
+ struct dolnod *dolh;
+ char flagadr[NUM_OPTS+1];
+#if SHOPT_KIA
+ char *kiafile;
+#endif /* SHOPT_KIA */
+} Arg_t;
+
+
+/* ======== option handling ======== */
+
+void *sh_argopen(Shell_t *shp)
+{
+ void *addr = newof(0,Arg_t,1,0);
+ Arg_t *ap = (Arg_t*)addr;
+ ap->shp = shp;
+ return(addr);
+}
+
+static int infof(Opt_t* op, Sfio_t* sp, const char* s, Optdisc_t* dp)
+{
+#if SHOPT_BASH
+ extern const char sh_bash1[], sh_bash2[];
+ if(strcmp(s,"bash1")==0)
+ {
+ if(sh_isoption(SH_BASH))
+ sfputr(sp,sh_bash1,-1);
+ }
+ else if(strcmp(s,"bash2")==0)
+ {
+ if(sh_isoption(SH_BASH))
+ sfputr(sp,sh_bash2,-1);
+ }
+ else if(*s==':' && sh_isoption(SH_BASH))
+ sfputr(sp,s,-1);
+ else
+#endif
+ if(*s!=':')
+ sfputr(sp,sh_set,-1);
+ return(1);
+}
+
+/*
+ * This routine turns options on and off
+ * The options "PDicr" are illegal from set command.
+ * The -o option is used to set option by name
+ * This routine returns the number of non-option arguments
+ */
+int sh_argopts(int argc,register char *argv[])
+{
+ register int n,o;
+ register Arg_t *ap = (Arg_t*)sh.arg_context;
+ Shopt_t newflags;
+ int setflag=0, action=0, trace=(int)sh_isoption(SH_XTRACE);
+ Namval_t *np = NIL(Namval_t*);
+ const char *cp;
+ int verbose,f;
+ Optdisc_t disc;
+ newflags=sh.options;
+ memset(&disc, 0, sizeof(disc));
+ disc.version = OPT_VERSION;
+ disc.infof = infof;
+ opt_info.disc = &disc;
+
+ if(argc>0)
+ setflag = 4;
+ else
+ argc = -argc;
+ while((n = optget(argv,setflag?sh_optset:sh_optksh)))
+ {
+ o=0;
+ f=*opt_info.option=='-';
+ switch(n)
+ {
+ case 'A':
+ np = nv_open(opt_info.arg,sh.var_tree,NV_NOASSIGN|NV_ARRAY|NV_VARNAME);
+ if(f)
+ nv_unset(np);
+ continue;
+#if SHOPT_BASH
+ case 'O': /* shopt options, only in bash mode */
+ if(!sh_isoption(SH_BASH))
+ errormsg(SH_DICT,ERROR_exit(1), e_option, opt_info.name);
+#endif
+ case 'o': /* set options */
+ byname:
+ if(!opt_info.arg||!*opt_info.arg||*opt_info.arg=='-')
+ {
+ action = PRINT;
+ /* print style: -O => shopt options
+ * bash => print unset options also, no heading
+ */
+ verbose = (f?PRINT_VERBOSE:PRINT_NO_HEADER)|
+ (n=='O'?PRINT_SHOPT:0)|
+ (sh_isoption(SH_BASH)?PRINT_ALL|PRINT_NO_HEADER:0)|
+ ((opt_info.arg&&(!*opt_info.arg||*opt_info.arg=='-'))?(PRINT_TABLE|PRINT_NO_HEADER):0);
+ continue;
+ }
+ o = sh_lookopt(opt_info.arg,&f);
+ if(o<=0
+ || (!sh_isoption(SH_BASH) && (o&SH_BASHEXTRA))
+ || ((!sh_isoption(SH_BASH) || n=='o') && (o&SH_BASHOPT))
+
+ || (setflag && (o&SH_COMMANDLINE)))
+ {
+ errormsg(SH_DICT,2, e_option, opt_info.arg);
+ error_info.errors++;
+ }
+ o &= 0xff;
+ if(sh_isoption(SH_RESTRICTED) && !f && o==SH_RESTRICTED)
+ errormsg(SH_DICT,ERROR_exit(1), e_restricted, opt_info.arg);
+ break;
+#if SHOPT_BASH
+ case -1: /* --rcfile */
+ sh.rcfile = opt_info.arg;
+ continue;
+ case -6: /* --version */
+ sfputr(sfstdout, "ksh bash emulation, version ",-1);
+ np = nv_open("BASH_VERSION",sh.var_tree,0);
+ sfputr(sfstdout, nv_getval(np),-1);
+ np = nv_open("MACHTYPE",sh.var_tree,0);
+ sfprintf(sfstdout, " (%s)\n", nv_getval(np));
+ sh_exit(0);
+
+ case -2: /* --noediting */
+ off_option(&newflags,SH_VI);
+ off_option(&newflags,SH_EMACS);
+ off_option(&newflags,SH_GMACS);
+ continue;
+
+ case -3: /* --profile */
+ f = !f;
+ /*FALLTHROUGH*/
+ case -4: /* --rc */
+ case -5: /* --posix */
+ /* mask lower 8 bits to find char in optksh string */
+ n&=0xff;
+ goto skip;
+#endif
+ case 'D':
+ on_option(&newflags,SH_NOEXEC);
+ goto skip;
+ case 's':
+ if(setflag)
+ {
+ action = SORT;
+ continue;
+ }
+#if SHOPT_KIA
+ goto skip;
+ case 'R':
+ if(setflag)
+ n = ':';
+ else
+ {
+ ap->kiafile = opt_info.arg;
+ n = 'n';
+ }
+ /* FALL THRU */
+#endif /* SHOPT_KIA */
+ skip:
+ default:
+ if(cp=strchr(optksh,n))
+ o = flagval[cp-optksh];
+ break;
+ case ':':
+ if(opt_info.name[0]=='-'&&opt_info.name[1]=='-')
+ {
+ opt_info.arg = argv[opt_info.index-1] + 2;
+ f = 1;
+ goto byname;
+ }
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ continue;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(0), "%s", opt_info.arg);
+ return(-1);
+ }
+ if(f)
+ {
+ if(o==SH_VI || o==SH_EMACS || o==SH_GMACS)
+ {
+ off_option(&newflags,SH_VI);
+ off_option(&newflags,SH_EMACS);
+ off_option(&newflags,SH_GMACS);
+ }
+ on_option(&newflags,o);
+ off_option(&sh.offoptions,o);
+ }
+ else
+ {
+ if(o==SH_XTRACE)
+ trace = 0;
+ off_option(&newflags,o);
+ if(setflag==0)
+ on_option(&sh.offoptions,o);
+ }
+ }
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage(NIL(char*)));
+ /* check for '-' or '+' argument */
+ if((cp=argv[opt_info.index]) && cp[1]==0 && (*cp=='+' || *cp=='-') &&
+ strcmp(argv[opt_info.index-1],"--"))
+ {
+ opt_info.index++;
+ off_option(&newflags,SH_XTRACE);
+ off_option(&newflags,SH_VERBOSE);
+ trace = 0;
+ }
+ if(trace)
+ sh_trace(argv,1);
+ argc -= opt_info.index;
+ argv += opt_info.index;
+ if(action==PRINT)
+ sh_printopts(newflags,verbose,0);
+ if(setflag)
+ {
+ if(action==SORT)
+ {
+ if(argc>0)
+ strsort(argv,argc,strcoll);
+ else
+ strsort(sh.st.dolv+1,sh.st.dolc,strcoll);
+ }
+ if(np)
+ {
+ nv_setvec(np,0,argc,argv);
+ nv_close(np);
+ }
+ else if(argc>0 || ((cp=argv[-1]) && strcmp(cp,"--")==0))
+ sh_argset(argv-1);
+ }
+ else if(is_option(&newflags,SH_CFLAG))
+ {
+ if(!(sh.comdiv = *argv++))
+ {
+ errormsg(SH_DICT,2,e_cneedsarg);
+ errormsg(SH_DICT,ERROR_usage(2),optusage(NIL(char*)));
+ }
+ argc--;
+ }
+ /* handling SH_INTERACTIVE and SH_PRIVILEGED has been moved to
+ * sh_applyopts(), so that the code can be reused from b_shopt(), too
+ */
+ sh_applyopts(newflags);
+#if SHOPT_KIA
+ if(ap->kiafile)
+ {
+ if(!(shlex.kiafile=sfopen(NIL(Sfio_t*),ap->kiafile,"w+")))
+ errormsg(SH_DICT,ERROR_system(3),e_create,ap->kiafile);
+ if(!(shlex.kiatmp=sftmp(2*SF_BUFSIZE)))
+ errormsg(SH_DICT,ERROR_system(3),e_tmpcreate);
+ sfputr(shlex.kiafile,";vdb;CIAO/ksh",'\n');
+ shlex.kiabegin = sftell(shlex.kiafile);
+ shlex.entity_tree = dtopen(&_Nvdisc,Dtbag);
+ shlex.scriptname = strdup(sh_fmtq(argv[0]));
+ shlex.script=kiaentity(shlex.scriptname,-1,'p',-1,0,0,'s',0,"");
+ shlex.fscript=kiaentity(shlex.scriptname,-1,'f',-1,0,0,'s',0,"");
+ shlex.unknown=kiaentity("<unknown>",-1,'p',-1,0,0,'0',0,"");
+ kiaentity("<unknown>",-1,'p',0,0,shlex.unknown,'0',0,"");
+ shlex.current = shlex.script;
+ ap->kiafile = 0;
+ }
+#endif /* SHOPT_KIA */
+ return(argc);
+}
+
+/* apply new options */
+
+void sh_applyopts(Shopt_t newflags)
+{
+ /* cannot set -n for interactive shells since there is no way out */
+ if(sh_isoption(SH_INTERACTIVE))
+ off_option(&newflags,SH_NOEXEC);
+ if(is_option(&newflags,SH_PRIVILEGED))
+ on_option(&newflags,SH_NOUSRPROFILE);
+ if(is_option(&newflags,SH_PRIVILEGED) != sh_isoption(SH_PRIVILEGED))
+ {
+ if(sh_isoption(SH_PRIVILEGED))
+ {
+ setuid(sh.userid);
+ setgid(sh.groupid);
+ if(sh.euserid==0)
+ {
+ sh.euserid = sh.userid;
+ sh.egroupid = sh.groupid;
+ }
+ }
+ else if((sh.userid!=sh.euserid && setuid(sh.euserid)<0) ||
+ (sh.groupid!=sh.egroupid && setgid(sh.egroupid)<0) ||
+ (sh.userid==sh.euserid && sh.groupid==sh.egroupid))
+ off_option(&newflags,SH_PRIVILEGED);
+ }
+#if SHOPT_BASH
+ on_option(&newflags,SH_CMDHIST);
+ on_option(&newflags,SH_CHECKHASH);
+ on_option(&newflags,SH_EXECFAIL);
+ on_option(&newflags,SH_EXPAND_ALIASES);
+ on_option(&newflags,SH_HISTAPPEND);
+ on_option(&newflags,SH_INTERACTIVE_COMM);
+ on_option(&newflags,SH_LITHIST);
+ on_option(&newflags,SH_NOEMPTYCMDCOMPL);
+
+ if(!is_option(&newflags,SH_XPG_ECHO) && sh_isoption(SH_XPG_ECHO))
+ astconf("UNIVERSE", 0, "ucb");
+ if(is_option(&newflags,SH_XPG_ECHO) && !sh_isoption(SH_XPG_ECHO))
+ astconf("UNIVERSE", 0, "att");
+ if(!is_option(&newflags,SH_PHYSICAL) && sh_isoption(SH_PHYSICAL))
+ astconf("PATH_RESOLVE", 0, "metaphysical");
+ if(is_option(&newflags,SH_PHYSICAL) && !sh_isoption(SH_PHYSICAL))
+ astconf("PATH_RESOLVE", 0, "physical");
+ if(is_option(&newflags,SH_HISTORY2) && !sh_isoption(SH_HISTORY2))
+ {
+ sh_onstate(SH_HISTORY);
+ sh_onoption(SH_HISTORY);
+ }
+ if(!is_option(&newflags,SH_HISTORY2) && sh_isoption(SH_HISTORY2))
+ {
+ sh_offstate(SH_HISTORY);
+ sh_offoption(SH_HISTORY);
+ }
+#endif
+ sh.options = newflags;
+}
+/*
+ * returns the value of $-
+ */
+char *sh_argdolminus(void)
+{
+ register const char *cp=optksh;
+ register Arg_t *ap = (Arg_t*)sh.arg_context;
+ register char *flagp=ap->flagadr;
+ while(cp< &optksh[NUM_OPTS])
+ {
+ int n = flagval[cp-optksh];
+ if(sh_isoption(n))
+ *flagp++ = *cp;
+ cp++;
+ }
+ *flagp = 0;
+ return(ap->flagadr);
+}
+
+/*
+ * set up positional parameters
+ */
+void sh_argset(char *argv[])
+{
+ register Arg_t *ap = (Arg_t*)sh.arg_context;
+ sh_argfree(ap->dolh,0);
+ ap->dolh = sh_argcreate(argv);
+ /* link into chain */
+ ap->dolh->dolnxt = ap->argfor;
+ ap->argfor = ap->dolh;
+ sh.st.dolc = ap->dolh->dolnum-1;
+ sh.st.dolv = ap->dolh->dolval;
+}
+
+/*
+ * free the argument list if the use count is 1
+ * If count is greater than 1 decrement count and return same blk
+ * Free the argument list if the use count is 1 and return next blk
+ * Delete the blk from the argfor chain
+ * If flag is set, then the block dolh is not freed
+ */
+struct dolnod *sh_argfree(struct dolnod *blk,int flag)
+{
+ register struct dolnod* argr=blk;
+ register struct dolnod* argblk;
+ register Arg_t *ap = (Arg_t*)sh.arg_context;
+ if(argblk=argr)
+ {
+ if((--argblk->dolrefcnt)==0)
+ {
+ argr = argblk->dolnxt;
+ if(flag && argblk==ap->dolh)
+ ap->dolh->dolrefcnt = 1;
+ else
+ {
+ /* delete from chain */
+ if(ap->argfor == argblk)
+ ap->argfor = argblk->dolnxt;
+ else
+ {
+ for(argr=ap->argfor;argr;argr=argr->dolnxt)
+ if(argr->dolnxt==argblk)
+ break;
+ if(!argr)
+ return(NIL(struct dolnod*));
+ argr->dolnxt = argblk->dolnxt;
+ argr = argblk->dolnxt;
+ }
+ free((void*)argblk);
+ }
+ }
+ }
+ return(argr);
+}
+
+/*
+ * grab space for arglist and copy args
+ * The strings are copied after the argment vector
+ */
+struct dolnod *sh_argcreate(register char *argv[])
+{
+ register struct dolnod *dp;
+ register char **pp=argv, *sp;
+ register int size=0,n;
+ /* count args and number of bytes of arglist */
+ while(sp= *pp++)
+ size += strlen(sp);
+ n = (pp - argv)-1;
+ dp=new_of(struct dolnod,n*sizeof(char*)+size+n);
+ dp->dolrefcnt=1; /* use count */
+ dp->dolnum = n;
+ dp->dolnxt = 0;
+ pp = dp->dolval;
+ sp = (char*)dp + sizeof(struct dolnod) + n*sizeof(char*);
+ while(n--)
+ {
+ *pp++ = sp;
+ sp = strcopy(sp, *argv++) + 1;
+ }
+ *pp = NIL(char*);
+ return(dp);
+}
+
+/*
+ * used to set new arguments for functions
+ */
+struct dolnod *sh_argnew(char *argi[], struct dolnod **savargfor)
+{
+ register Arg_t *ap = (Arg_t*)sh.arg_context;
+ register struct dolnod *olddolh = ap->dolh;
+ *savargfor = ap->argfor;
+ ap->dolh = 0;
+ ap->argfor = 0;
+ sh_argset(argi);
+ return(olddolh);
+}
+
+/*
+ * reset arguments as they were before function
+ */
+void sh_argreset(struct dolnod *blk, struct dolnod *afor)
+{
+ register Arg_t *ap = (Arg_t*)sh.arg_context;
+ while(ap->argfor=sh_argfree(ap->argfor,0));
+ ap->argfor = afor;
+ if(ap->dolh = blk)
+ {
+ sh.st.dolc = ap->dolh->dolnum-1;
+ sh.st.dolv = ap->dolh->dolval;
+ }
+}
+
+/*
+ * increase the use count so that an sh_argset will not make it go away
+ */
+struct dolnod *sh_arguse(void)
+{
+ register struct dolnod *dh;
+ register Arg_t *ap = (Arg_t*)sh.arg_context;
+ if(dh=ap->dolh)
+ dh->dolrefcnt++;
+ return(dh);
+}
+
+/*
+ * Print option settings on standard output
+ * if mode is inclusive or of PRINT_*
+ * if <mask> is set, only options with this mask value are displayed
+ */
+void sh_printopts(Shopt_t oflags,register int mode, Shopt_t *mask)
+{
+ register const Shtable_t *tp;
+ const char *name;
+ int on;
+ int value;
+ if(!(mode&PRINT_NO_HEADER))
+ sfputr(sfstdout,sh_translate(e_heading),'\n');
+ if(mode&PRINT_TABLE)
+ {
+ int w;
+ int c;
+ int r;
+ int i;
+
+ c = 0;
+ for(tp=shtab_options; value=tp->sh_number; tp++)
+ {
+ if(mask && !is_option(mask,value&0xff))
+ continue;
+ name = tp->sh_name;
+ if(name[0] == 'n' && name[1] == 'o' && name[2] != 't')
+ name += 2;
+ if(c<(w=strlen(name)))
+ c = w;
+ }
+ c += 4;
+ if((w = ed_window()) < (2*c))
+ w = 2*c;
+ r = w / c;
+ i = 0;
+ for(tp=shtab_options; value=tp->sh_number; tp++)
+ {
+ if(mask && !is_option(mask,value&0xff))
+ continue;
+ on = !!is_option(&oflags,value);
+ value &= 0xff;
+ name = tp->sh_name;
+ if(name[0] == 'n' && name[1] == 'o' && name[2] != 't')
+ {
+ name += 2;
+ on = !on;
+ }
+ if(++i>=r)
+ {
+ i = 0;
+ sfprintf(sfstdout, "%s%s\n", on ? "" : "no", name);
+ }
+ else
+ sfprintf(sfstdout, "%s%-*s", on ? "" : "no", on ? c : (c-2), name);
+ }
+ if(i)
+ sfputc(sfstdout,'\n');
+ return;
+ }
+#if SHOPT_RAWONLY
+ on_option(&oflags,SH_VIRAW);
+#endif
+ if(!(mode&(PRINT_ALL|PRINT_VERBOSE))) /* only print set options */
+ {
+ if(mode&PRINT_SHOPT)
+ sfwrite(sfstdout,"shopt -s",3);
+ else
+ sfwrite(sfstdout,"set",3);
+ }
+ for(tp=shtab_options; value=tp->sh_number; tp++)
+ {
+ if(mask && !is_option(mask,value&0xff))
+ continue;
+ if(sh_isoption(SH_BASH))
+ {
+ if (!(mode&PRINT_SHOPT) != !(value&SH_BASHOPT))
+ continue;
+ }
+ else if (value&(SH_BASHEXTRA|SH_BASHOPT))
+ continue;
+ on = !!is_option(&oflags,value);
+ name = tp->sh_name;
+ if(name[0] == 'n' && name[1] == 'o' && name[2] != 't')
+ {
+ name += 2;
+ on = !on;
+ }
+ if(mode&PRINT_VERBOSE)
+ {
+ sfputr(sfstdout,name,' ');
+ sfnputc(sfstdout,' ',24-strlen(name));
+ sfputr(sfstdout,on ? sh_translate(e_on) : sh_translate(e_off),'\n');
+ }
+ else if(mode&PRINT_ALL) /* print unset options also */
+ {
+ if(mode&PRINT_SHOPT)
+ sfprintf(sfstdout, "shopt -%c %s\n",
+ on?'s':'u',
+ name);
+ else
+ sfprintf(sfstdout, "set %co %s\n",
+ on?'-':'+',
+ name);
+ }
+ else if(!(value&SH_COMMANDLINE) && is_option(&oflags,value&0xff))
+ sfprintf(sfstdout," %s%s%s",(mode&PRINT_SHOPT)?"":"--",on?"":"no",name);
+ }
+ if(!(mode&(PRINT_VERBOSE|PRINT_ALL)))
+ sfputc(sfstdout,'\n');
+}
+
+/*
+ * build an argument list
+ */
+char **sh_argbuild(int *nargs, const struct comnod *comptr,int flag)
+{
+ register struct argnod *argp;
+ struct argnod *arghead=0;
+ sh.xargmin = 0;
+ {
+ register const struct comnod *ac = comptr;
+ register int n;
+ /* see if the arguments have already been expanded */
+ if(!ac->comarg)
+ {
+ *nargs = 0;
+ return(&null);
+ }
+ else if(!(ac->comtyp&COMSCAN))
+ {
+ register struct dolnod *ap = (struct dolnod*)ac->comarg;
+ *nargs = ap->dolnum;
+ ((struct comnod*)ac)->comtyp |= COMFIXED;
+ return(ap->dolval+ap->dolbot);
+ }
+ sh.lastpath = 0;
+ *nargs = 0;
+ if(ac)
+ {
+ if(ac->comnamp == SYSLET)
+ flag |= ARG_LET;
+ argp = ac->comarg;
+ while(argp)
+ {
+ n = arg_expand(argp,&arghead,flag);
+ if(n>1)
+ {
+ if(sh.xargmin==0)
+ sh.xargmin = *nargs;
+ sh.xargmax = *nargs+n;
+ }
+ *nargs += n;
+ argp = argp->argnxt.ap;
+ }
+ argp = arghead;
+ }
+ }
+ {
+ register char **comargn;
+ register int argn;
+ register char **comargm;
+ int argfixed = COMFIXED;
+ argn = *nargs;
+ /* allow room to prepend args */
+ argn += 1;
+
+ comargn=(char**)stakalloc((unsigned)(argn+1)*sizeof(char*));
+ comargm = comargn += argn;
+ *comargn = NIL(char*);
+ if(!argp)
+ {
+ /* reserve an extra null pointer */
+ *--comargn = 0;
+ return(comargn);
+ }
+ while(argp)
+ {
+ struct argnod *nextarg = argp->argchn.ap;
+ argp->argchn.ap = 0;
+ *--comargn = argp->argval;
+ if(!(argp->argflag&ARG_RAW) || (argp->argflag&ARG_EXP))
+ argfixed = 0;
+ if(!(argp->argflag&ARG_RAW))
+ sh_trim(*comargn);
+ if(!(argp=nextarg) || (argp->argflag&ARG_MAKE))
+ {
+ if((argn=comargm-comargn)>1)
+ strsort(comargn,argn,strcoll);
+ comargm = comargn;
+ }
+ }
+ ((struct comnod*)comptr)->comtyp |= argfixed;
+ return(comargn);
+ }
+}
+
+#if _pipe_socketpair && !_socketpair_devfd
+# define sh_pipe arg_pipe
+/*
+ * create a real pipe (not a socket) and print message on failure
+ */
+static int arg_pipe(register int pv[])
+{
+ int fd[2];
+ if(pipe(fd)<0 || (pv[0]=fd[0])<0 || (pv[1]=fd[1])<0)
+ errormsg(SH_DICT,ERROR_system(1),e_pipe);
+ pv[0] = sh_iomovefd(pv[0]);
+ pv[1] = sh_iomovefd(pv[1]);
+ sh.fdstatus[pv[0]] = IONOSEEK|IOREAD;
+ sh.fdstatus[pv[1]] = IONOSEEK|IOWRITE;
+ sh_subsavefd(pv[0]);
+ sh_subsavefd(pv[1]);
+ return(0);
+}
+#endif
+
+/* Argument expansion */
+static int arg_expand(register struct argnod *argp, struct argnod **argchain,int flag)
+{
+ register int count = 0;
+ argp->argflag &= ~ARG_MAKE;
+#if SHOPT_DEVFD
+ if(*argp->argval==0 && (argp->argflag&ARG_EXP))
+ {
+ /* argument of the form (cmd) */
+ register struct argnod *ap;
+ int monitor, fd, pv[2];
+ ap = (struct argnod*)stakseek(ARGVAL);
+ ap->argflag |= ARG_MAKE;
+ ap->argflag &= ~ARG_RAW;
+ ap->argchn.ap = *argchain;
+ *argchain = ap;
+ count++;
+ stakwrite(e_devfdNN,8);
+ sh_pipe(pv);
+ fd = argp->argflag&ARG_RAW;
+ stakputs(fmtbase((long)pv[fd],10,0));
+ ap = (struct argnod*)stakfreeze(1);
+ sh.inpipe = sh.outpipe = 0;
+ if(monitor = (sh_isstate(SH_MONITOR)!=0))
+ sh_offstate(SH_MONITOR);
+ if(fd)
+ {
+ sh.inpipe = pv;
+ sh_exec((Shnode_t*)argp->argchn.ap,(int)sh_isstate(SH_ERREXIT));
+ }
+ else
+ {
+ sh.outpipe = pv;
+ sh_exec((Shnode_t*)argp->argchn.ap,(int)sh_isstate(SH_ERREXIT));
+ }
+ if(monitor)
+ sh_onstate(SH_MONITOR);
+ close(pv[1-fd]);
+ sh_iosave(-pv[fd], sh.topfd);
+ }
+ else
+#endif /* SHOPT_DEVFD */
+ if(!(argp->argflag&ARG_RAW))
+ {
+#if SHOPT_OPTIMIZE
+ struct argnod *ap;
+ if(flag&ARG_OPTIMIZE)
+ argp->argchn.ap=0;
+ if(ap=argp->argchn.ap)
+ {
+ sh.optcount++;
+ count = 1;
+ ap->argchn.ap = *argchain;
+ ap->argflag |= ARG_RAW;
+ ap->argflag &= ~ARG_EXP;
+ *argchain = ap;
+ }
+ else
+#endif /* SHOPT_OPTIMIZE */
+ count = sh_macexpand(argp,argchain,flag);
+ }
+ else
+ {
+ argp->argchn.ap = *argchain;
+ *argchain = argp;
+ argp->argflag |= ARG_MAKE;
+ count++;
+ }
+ return(count);
+}
+
diff --git a/usr/src/lib/libshell/common/sh/arith.c b/usr/src/lib/libshell/common/sh/arith.c
new file mode 100644
index 0000000000..b81e798fae
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/arith.c
@@ -0,0 +1,363 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Shell arithmetic - uses streval library
+ * David Korn
+ * AT&T Labs
+ */
+
+#include "defs.h"
+#include <ctype.h>
+#include "lexstates.h"
+#include "name.h"
+#include "streval.h"
+#include "variables.h"
+
+#ifndef LLONG_MAX
+#define LLONG_MAX LONG_MAX
+#endif
+
+static Sfdouble_t Zero, NaN, Inf;
+static Namval_t Infnod =
+{
+ { 0 },
+ "Inf",
+ NV_NOFREE|NV_LDOUBLE,NV_RDONLY
+};
+
+static Namval_t NaNnod =
+{
+ { 0 },
+ "NaN",
+ NV_NOFREE|NV_LDOUBLE,NV_RDONLY
+};
+
+static Namval_t *scope(register Namval_t *np,register struct lval *lvalue,int assign)
+{
+ register Namarr_t *ap;
+ register int flag = lvalue->flag;
+ register char *sub=0;
+ if(lvalue->emode&ARITH_COMP)
+ {
+ char *cp = (char*)np;
+ register Namval_t *mp;
+ if(cp>=lvalue->expr && cp < lvalue->expr+lvalue->elen)
+ {
+ /* do bindiing to node now */
+ int c = cp[flag];
+ cp[flag] = 0;
+ np = nv_open(cp,sh.var_tree,NV_NOASSIGN|NV_VARNAME);
+ cp[flag] = c;
+ if(cp[flag+1]=='[')
+ flag++;
+ else
+ flag = 0;
+ }
+ else if(dtvnext(sh.var_tree) && (mp=nv_search((char*)np,sh.var_tree,HASH_NOSCOPE|HASH_SCOPE|HASH_BUCKET)))
+ {
+ while(nv_isref(mp))
+ {
+ sub = nv_refsub(mp);
+ mp = nv_refnode(mp);
+ }
+ np = mp;
+ }
+ }
+ if(flag || sub)
+ {
+ if(!sub)
+ sub = (char*)&lvalue->expr[flag];
+ if(((ap=nv_arrayptr(np)) && array_assoc(ap)) || (lvalue->emode&ARITH_COMP))
+ nv_endsubscript(np,sub,NV_ADD|NV_SUBQUOTE);
+ else
+ nv_putsub(np, NIL(char*),flag);
+ }
+ return(np);
+}
+
+static Sfdouble_t arith(const char **ptr, struct lval *lvalue, int type, Sfdouble_t n)
+{
+ register Sfdouble_t r= 0;
+ char *str = (char*)*ptr;
+ switch(type)
+ {
+ case ASSIGN:
+ {
+ register Namval_t *np = (Namval_t*)(lvalue->value);
+ np = scope(np,lvalue,1);
+ nv_putval(np, (char*)&n, NV_LDOUBLE);
+ r=nv_getnum(np);
+ break;
+ }
+ case LOOKUP:
+ {
+ register int c = *str;
+ register char *xp=str;
+ lvalue->value = (char*)0;
+ if(c=='.')
+ str++;
+ c = mbchar(str);
+ if(isaletter(c))
+ {
+ register Namval_t *np;
+ int dot=0;
+ char *cp;
+ while(1)
+ {
+ while(xp=str, c=mbchar(str), isaname(c));
+ str = xp;
+ if(c!='.')
+ break;
+ dot=1;
+ if((c = *++str) !='[')
+ continue;
+ str = nv_endsubscript((Namval_t*)0,cp=str,NV_SUBQUOTE)-1;
+ if(sh_checkid(cp+1,(char*)0))
+ str -=2;
+ }
+ if(c=='(')
+ {
+ int fsize = str- (char*)(*ptr);
+ const struct mathtab *tp;
+ c = **ptr;
+ lvalue->fun = 0;
+ if(fsize<=(sizeof(tp->fname)-2)) for(tp=shtab_math; *tp->fname; tp++)
+ {
+ if(*tp->fname > c)
+ break;
+ if(tp->fname[1]==c && tp->fname[fsize+1]==0 && strncmp(&tp->fname[1],*ptr,fsize)==0)
+ {
+ lvalue->fun = tp->fnptr;
+ lvalue->nargs = *tp->fname;
+ break;
+ }
+ }
+ if(lvalue->fun)
+ break;
+ lvalue->value = (char*)ERROR_dictionary(e_function);
+ return(r);
+ }
+ if((lvalue->emode&ARITH_COMP) && dot)
+ {
+ lvalue->value = (char*)*ptr;
+ lvalue->flag = str-lvalue->value;
+ break;
+ }
+ *str = 0;
+ if(sh_isoption(SH_NOEXEC))
+ np = L_ARGNOD;
+ else
+ {
+ int offset = staktell();
+ char *saveptr = stakfreeze(0);
+ Dt_t *root = (lvalue->emode&ARITH_COMP)?sh.var_base:sh.var_tree;
+ *str = c;
+ while(c=='[' || c=='.')
+ {
+ if(c=='[')
+ {
+ str = nv_endsubscript(np,cp=str,0);
+ if((c= *str)!='[' && c!='.')
+ {
+ str = cp;
+ c = '[';
+ break;
+ }
+ }
+ else
+ {
+ str++;
+ while(xp=str, c=mbchar(str), isaname(c));
+ str = xp;
+ }
+ }
+ *str = 0;
+ if(strcasecmp(*ptr,"Inf")==0)
+ {
+ Inf = 1.0/Zero;
+ Infnod.nvalue.ldp = &Inf;
+ np = &Infnod;
+ }
+ else if(strcasecmp(*ptr,"NaN")==0)
+ {
+ NaN = 0.0/Zero;
+ NaNnod.nvalue.ldp = &NaN;
+ np = &NaNnod;
+ }
+ else
+ np = nv_open(*ptr,root,NV_NOASSIGN|NV_VARNAME);
+ if(saveptr != stakptr(0))
+ stakset(saveptr,offset);
+ else
+ stakseek(offset);
+ }
+ *str = c;
+ lvalue->value = (char*)np;
+ if((lvalue->emode&ARITH_COMP) || (nv_isarray(np) && nv_aindex(np)<0))
+ {
+ /* bind subscript later */
+ lvalue->flag = 0;
+ if(c=='[')
+ {
+ lvalue->flag = (str-lvalue->expr);
+ do
+ str = nv_endsubscript(np,str,0);
+ while((c= *str)=='[');
+ }
+ break;
+ }
+ if(c=='[')
+ {
+ do
+ str = nv_endsubscript(np,str,NV_ADD|NV_SUBQUOTE);
+ while((c=*str)=='[');
+ }
+ else if(nv_isarray(np))
+ nv_putsub(np,NIL(char*),ARRAY_UNDEF);
+ if(nv_isattr(np,NV_INTEGER|NV_DOUBLE)==(NV_INTEGER|NV_DOUBLE))
+ lvalue->isfloat=1;
+ lvalue->flag = nv_aindex(np);
+ }
+ else
+ {
+ char lastbase=0, *val = xp, oerrno = errno;
+ errno = 0;
+ r = strtonll(val,&str, &lastbase,-1);
+ if(*str=='8' || *str=='9')
+ {
+ lastbase=10;
+ errno = 0;
+ r = strtonll(val,&str, &lastbase,-1);
+ }
+ if(lastbase<=1)
+ lastbase=10;
+ if(*val=='0')
+ {
+ while(*val=='0')
+ val++;
+ if(*val==0 || *val=='.' || *val=='x' || *val=='X')
+ val--;
+ }
+ if(r==LLONG_MAX && errno)
+ c='e';
+ else
+ c = *str;
+ if(c==GETDECIMAL(0) || c=='e' || c == 'E')
+ {
+ lvalue->isfloat=1;
+ r = strtold(val,&str);
+ }
+ else if(lastbase==10 && val[1])
+ {
+ if(val[2]=='#')
+ val += 3;
+ if((str-val)>2*sizeof(Sflong_t))
+ {
+ Sfdouble_t rr;
+ rr = strtold(val,&str);
+ if(rr!=r)
+ {
+ r = rr;
+ lvalue->isfloat=1;
+ }
+ }
+ }
+ errno = oerrno;
+ }
+ break;
+ }
+ case VALUE:
+ {
+ register Namval_t *np = (Namval_t*)(lvalue->value);
+ if(sh_isoption(SH_NOEXEC))
+ return(0);
+ np = scope(np,lvalue,0);
+ if(((lvalue->emode&2) || lvalue->level>1 || sh_isoption(SH_NOUNSET)) && nv_isnull(np) && !nv_isattr(np,NV_INTEGER))
+ {
+ *ptr = nv_name(np);
+ lvalue->value = (char*)ERROR_dictionary(e_notset);
+ lvalue->emode |= 010;
+ return(0);
+ }
+ r = nv_getnum(np);
+ if(nv_isattr(np,NV_INTEGER|NV_BINARY)==(NV_INTEGER|NV_BINARY))
+ lvalue->isfloat= (r!=(Sflong_t)r);
+ else if(nv_isattr(np,NV_INTEGER|NV_DOUBLE)==(NV_INTEGER|NV_DOUBLE))
+ lvalue->isfloat=1;
+ return(r);
+ }
+
+ case MESSAGE:
+ sfsync(NIL(Sfio_t*));
+#if 0
+ if(warn)
+ errormsg(SH_DICT,ERROR_warn(0),lvalue->value,*ptr);
+ else
+#endif
+ errormsg(SH_DICT,ERROR_exit((lvalue->emode&3)!=0),lvalue->value,*ptr);
+ }
+ *ptr = str;
+ return(r);
+}
+
+/*
+ * convert number defined by string to a Sfdouble_t
+ * ptr is set to the last character processed
+ * if mode>0, an error will be fatal with value <mode>
+ */
+
+Sfdouble_t sh_strnum(register const char *str, char** ptr, int mode)
+{
+ register Sfdouble_t d;
+ char base=0, *last;
+ if(*str==0)
+ {
+ if(ptr)
+ *ptr = (char*)str;
+ return(0);
+ }
+ errno = 0;
+ d = strtonll(str,&last,&base,-1);
+ if(*last || errno)
+ {
+ d = strval(str,&last,arith,mode);
+ if(!ptr && *last && mode>0)
+ errormsg(SH_DICT,ERROR_exit(1),e_lexbadchar,*last,str);
+ }
+ if(ptr)
+ *ptr = last;
+ return(d);
+}
+
+Sfdouble_t sh_arith(register const char *str)
+{
+ return(sh_strnum(str, (char**)0, 1));
+}
+
+void *sh_arithcomp(register char *str)
+{
+ const char *ptr = str;
+ Arith_t *ep;
+ ep = arith_compile(str,(char**)&ptr,arith,ARITH_COMP|1);
+ if(*ptr)
+ errormsg(SH_DICT,ERROR_exit(1),e_lexbadchar,*ptr,str);
+ return((void*)ep);
+}
diff --git a/usr/src/lib/libshell/common/sh/array.c b/usr/src/lib/libshell/common/sh/array.c
new file mode 100644
index 0000000000..5b33f20e5a
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/array.c
@@ -0,0 +1,865 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Array processing routines
+ *
+ * David Korn
+ * AT&T Labs
+ * dgk@research.att.com
+ *
+ */
+
+#include "defs.h"
+#include <stak.h>
+#include "name.h"
+
+#define NUMSIZE (4+(ARRAY_MAX>999)+(ARRAY_MAX>9999)+(ARRAY_MAX>99999))
+#define is_associative(ap) array_assoc((Namarr_t*)(ap))
+#define array_setbit(cp, n) (cp[(n)/CHAR_BIT] |= 1<<(((n)&(CHAR_BIT-1))))
+#define array_clrbit(cp, n) (cp[(n)/CHAR_BIT] &= ~(1<<(((n)&(CHAR_BIT-1)))))
+#define array_isbit(cp, n) (cp[(n)/CHAR_BIT] & 1<<(((n)&(CHAR_BIT-1))))
+#define NV_CHILD NV_EXPORT
+
+static char Empty[] = "";
+
+struct index_array
+{
+ Namarr_t header;
+ int cur; /* index of current element */
+ int maxi; /* maximum index for array */
+ unsigned char *bits; /* bit array for child subscripts */
+ union Value val[1]; /* array of value holders */
+};
+
+struct assoc_array
+{
+ Namarr_t header;
+ Dt_t *table;
+ Namval_t *pos;
+ Namval_t *nextpos;
+ Namval_t *cur;
+};
+
+/*
+ * replace discipline with new one
+ */
+static void array_setptr(register Namval_t *np, struct index_array *old, struct index_array *new)
+{
+ register Namfun_t **fp = &np->nvfun;
+ while(*fp && *fp!= &old->header.hdr)
+ fp = &((*fp)->next);
+ if(*fp)
+ {
+ new->header.hdr.next = (*fp)->next;
+ *fp = &new->header.hdr;
+ }
+ else sfprintf(sfstderr,"discipline not replaced\n");
+}
+
+/*
+ * Calculate the amount of space to be allocated to hold an
+ * indexed array into which <maxi> is a legal index. The number of
+ * elements that will actually fit into the array (> <maxi>
+ * but <= ARRAY_MAX) is returned.
+ *
+ */
+static int arsize(register int maxi)
+{
+ register int i = roundof(maxi,ARRAY_INCR);
+ return (i>ARRAY_MAX?ARRAY_MAX:i);
+}
+
+static struct index_array *array_grow(Namval_t*, struct index_array*,int);
+
+/* return index of highest element of an array */
+int array_maxindex(Namval_t *np)
+{
+ register struct index_array *ap = (struct index_array*)nv_arrayptr(np);
+ register int i = ap->maxi;
+ if(is_associative(ap))
+ return(-1);
+ while(i>0 && ap->val[--i].cp==0);
+ return(i+1);
+}
+
+static union Value *array_getup(Namval_t *np, Namarr_t *arp)
+{
+ register struct index_array *ap = (struct index_array*)arp;
+ register union Value *up;
+ if(!nv_isarray(np))
+ return(&np->nvalue);
+ if(is_associative(ap))
+ up = (union Value*)((*arp->fun)(np,NIL(char*),0));
+ else
+ {
+ if(ap->cur >= ap->maxi)
+ errormsg(SH_DICT,ERROR_exit(1),e_subscript,nv_name(np));
+ up = &(ap->val[ap->cur]);
+ }
+ return(up);
+}
+
+/*
+ * Get the Value pointer for an array.
+ * Delete space as necessary if flag is ARRAY_DELETE
+ * After the lookup is done the last @ or * subscript is incremented
+ */
+static Namval_t *array_find(Namval_t *np,Namarr_t *arp, int flag)
+{
+ register struct index_array *ap = (struct index_array*)arp;
+ register union Value *up;
+ Namval_t *mp;
+ int wasundef;
+ if(wasundef = ap->header.nelem&ARRAY_UNDEF)
+ {
+ ap->header.nelem &= ~ARRAY_UNDEF;
+ /* delete array is the same as delete array[@] */
+ if(flag&ARRAY_DELETE)
+ {
+ nv_putsub(np, NIL(char*), ARRAY_SCAN);
+ ap->header.nelem |= ARRAY_SCAN;
+ }
+ else /* same as array[0] */
+ {
+ if(is_associative(ap))
+ (*ap->header.fun)(np,"0",flag==ARRAY_ASSIGN?NV_AADD:0);
+ else
+ ap->cur = 0;
+ }
+ }
+ if(is_associative(ap))
+ {
+ mp = (Namval_t*)((*arp->fun)(np,NIL(char*),NV_ACURRENT));
+ if(!mp)
+ up = (union Value*)&mp;
+ else if(nv_isattr(mp,NV_CHILD))
+ {
+ if(wasundef && nv_isarray(mp->nvalue.np))
+ nv_putsub(mp->nvalue.np,NIL(char*),ARRAY_UNDEF);
+ return(mp->nvalue.np);
+ }
+ else
+ up = &mp->nvalue;
+ }
+ else
+ {
+ if(!(ap->header.nelem&ARRAY_SCAN) && ap->cur >= ap->maxi)
+ ap = array_grow(np, ap, (int)ap->cur);
+ if(ap->cur>=ap->maxi)
+ errormsg(SH_DICT,ERROR_exit(1),e_subscript,nv_name(np));
+ up = &(ap->val[ap->cur]);
+ if(up->np && array_isbit(ap->bits,ap->cur))
+ {
+ if(wasundef && nv_isarray(up->np))
+ nv_putsub(up->np,NIL(char*),ARRAY_UNDEF);
+ return(up->np);
+ }
+ }
+ np->nvalue.cp = up->cp;
+ if(!up->cp)
+ {
+ if(flag!=ARRAY_ASSIGN)
+ return(0);
+ ap->header.nelem++;
+ }
+ return(np);
+}
+
+static Namfun_t *array_clone(Namval_t *np, Namval_t *mp, int flags, Namfun_t *fp)
+{
+ Namarr_t *ap = (Namarr_t*)fp;
+ Namval_t *nq, *mq;
+ char *name, *sub=0;
+ int nelem = ap->nelem,offset=staktell();
+ struct index_array *aq, *ar;
+ if(nelem&ARRAY_NOCLONE)
+ return(0);
+ if(array_assoc(ap))
+ nv_setarray(mp,ap->fun);
+ else
+ {
+ nv_putsub(mp,NIL(char*),ap->nelem);
+ if(aq=(struct index_array*)nv_arrayptr(mp))
+ aq->bits = (unsigned char*)&aq->val[aq->maxi];
+ }
+ if(!(nelem&(ARRAY_SCAN|ARRAY_UNDEF)) && (sub=nv_getsub(np)))
+ sub = strdup(sub);
+ ar = (struct index_array*)ap;
+ nv_onattr(mp,nv_isattr(np,NV_INTEGER|NV_UTOL|NV_LTOU|NV_LJUST|NV_RJUST|NV_ZFILL|NV_BINARY));
+ nv_putsub(np,NIL(char*),ARRAY_SCAN);
+ do
+ {
+ if(array_assoc(ap))
+ name = (char*)((*ap->fun)(np,NIL(char*),NV_ANAME));
+ else
+ name = nv_getsub(np);
+ nv_putsub(mp,name,ARRAY_ADD);
+ if((!array_assoc(ap) && array_isbit(ar->bits,ar->cur) && (nq=np)) ||
+ (array_assoc(ap) && (nq = (Namval_t*)((*ap->fun)(np,NIL(char*),NV_ACURRENT))) && nv_isattr(nq, NV_CHILD)))
+ {
+ sfprintf(stkstd,"%s[%s]",nv_name(mp),name);
+ stakputc(0);
+ mq = nv_search(stakptr(offset), sh.var_tree, NV_ADD);
+ stakseek(offset);
+ if(mq)
+ {
+ nv_clone(nq->nvalue.np,mq,0);
+ if(array_assoc(ap))
+ {
+ nq = (Namval_t*)((*ap->fun)(mp,NIL(char*),NV_ACURRENT));
+ nq->nvalue.np = mp;
+ nv_onattr(nq,NV_CHILD);
+ }
+ else if(aq)
+ {
+ array_setbit(aq->bits,aq->cur);
+ aq->val[aq->cur].np = mq;
+ }
+ }
+ }
+ else if(nv_isattr(np,NV_INTEGER))
+ {
+ Sfdouble_t d= nv_getnum(np);
+ nv_putval(mp,(char*)&d,NV_LDOUBLE);
+ }
+ else
+ nv_putval(mp,nv_getval(np),NV_RDONLY);
+ }
+ while(nv_nextsub(np));
+ if(sub)
+ {
+ nv_putsub(np,sub,0L);
+ free((void*)sub);
+ }
+ ap->nelem = nelem;
+ ((Namarr_t*)mp->nvfun)->nelem = nelem;
+ return(nv_stack(mp,(Namfun_t*)0));
+}
+
+static char *array_getval(Namval_t *np, Namfun_t *disc)
+{
+ register Namarr_t *ap = (Namarr_t*)disc;
+ register Namval_t *mp;
+ if((mp=array_find(np,ap,ARRAY_LOOKUP))!=np)
+ return(mp?nv_getval(mp):0);
+ return(nv_getv(np,&ap->hdr));
+}
+
+static Sfdouble_t array_getnum(Namval_t *np, Namfun_t *disc)
+{
+ register Namarr_t *ap = (Namarr_t*)disc;
+ register Namval_t *mp;
+ if((mp=array_find(np,ap,ARRAY_LOOKUP))!=np)
+ return(mp?nv_getnum(mp):0);
+ return(nv_getn(np,&ap->hdr));
+}
+
+static void array_putval(Namval_t *np, const char *string, int flags, Namfun_t *dp)
+{
+ register Namarr_t *ap = (Namarr_t*)dp;
+ register union Value *up;
+ register Namval_t *mp;
+ register struct index_array *aq = (struct index_array*)ap;
+ do
+ {
+ mp = array_find(np,ap,string?ARRAY_ASSIGN:ARRAY_DELETE);
+ if(mp && mp!=np)
+ nv_putval(mp, string, flags);
+ if(!string)
+ {
+ if(mp)
+ {
+ if(mp!=np)
+ {
+ dtdelete(sh.var_tree,(void*)mp);
+ free((void*)mp);
+ }
+ if(is_associative(ap))
+ (*ap->fun)(np,NIL(char*),NV_ADELETE);
+ else if(mp!=np)
+ {
+ array_clrbit(aq->bits,aq->cur);
+ aq->val[aq->cur].cp = 0;
+ }
+ ap->nelem--;
+ }
+ if(array_elem(ap)==0 && ((ap->nelem&ARRAY_SCAN) || !is_associative(ap)))
+ {
+ if(is_associative(ap))
+ (*ap->fun)(np, NIL(char*), NV_AFREE);
+ nv_offattr(np,NV_ARRAY);
+ }
+ if(!mp || mp!=np)
+ continue;
+ }
+ /* prevent empty string from being deleted */
+ if(np->nvalue.cp == Empty)
+ np->nvalue.cp = 0;
+ nv_putv(np,string,flags,&ap->hdr);
+ up = array_getup(np,ap);
+ up->cp = np->nvalue.cp;
+ }
+ while(!string && nv_nextsub(np));
+ if(!string && !nv_isattr(np,NV_ARRAY))
+ {
+ Namfun_t *nfp;
+ if(nfp = nv_disc(np,(Namfun_t*)ap,NV_POP))
+ free((void*)nfp);
+ }
+}
+
+static const Namdisc_t array_disc =
+{
+ sizeof(Namarr_t),
+ array_putval,
+ array_getval,
+ array_getnum,
+ 0,
+ 0,
+ array_clone
+};
+
+/*
+ * Increase the size of the indexed array of elements in <arp>
+ * so that <maxi> is a legal index. If <arp> is 0, an array
+ * of the required size is allocated. A pointer to the
+ * allocated Namarr_t structure is returned.
+ * <maxi> becomes the current index of the array.
+ */
+static struct index_array *array_grow(Namval_t *np, register struct index_array *arp,int maxi)
+{
+ register struct index_array *ap;
+ register int i=0;
+ register int newsize = arsize(maxi+1);
+ if (maxi >= ARRAY_MAX)
+ errormsg(SH_DICT,ERROR_exit(1),e_subscript, fmtbase((long)maxi,10,0));
+ ap = new_of(struct index_array,(newsize-1)*sizeof(union Value*)+newsize/CHAR_BIT);
+ memset((void*)ap,0,sizeof(*ap));
+ ap->maxi = newsize;
+ ap->cur = maxi;
+ ap->bits = (unsigned char*)&ap->val[newsize];
+ memset(ap->bits, 0, newsize/CHAR_BIT);
+ if(arp)
+ {
+ ap->header = arp->header;
+ for(;i < arp->maxi;i++)
+ ap->val[i].cp = arp->val[i].cp;
+ memcpy(ap->bits, arp->bits, (arp->maxi/CHAR_BIT));
+ array_setptr(np,arp,ap);
+ free((void*)arp);
+ }
+ else
+ {
+ ap->header.fun = 0;
+ if((ap->val[0].cp=np->nvalue.cp))
+ i++;
+ else if(nv_hasdisc(np,&array_disc))
+ {
+ Namval_t *mp;
+ int offset = staktell();
+ sfprintf(stkstd,"%s[0]",nv_name(np));
+ stakputc(0);
+ mp = nv_search(stakptr(offset), sh.var_tree, NV_ADD);
+ stakseek(offset);
+ if(mp && nv_isnull(mp))
+ {
+ nv_clone(np,mp,0);
+ ap->val[0].np = mp;
+ array_setbit(ap->bits,0);
+ }
+ i++;
+ }
+ else if(nv_isattr(np,NV_INTEGER))
+ {
+ Sfdouble_t d= nv_getnum(np);
+ i++;
+ }
+ ap->header.nelem = i;
+ ap->header.hdr.nofree = 1;
+ ap->header.hdr.disc = &array_disc;
+ nv_disc(np,(Namfun_t*)ap, NV_LAST);
+ }
+ for(;i < newsize;i++)
+ ap->val[i].cp = 0;
+ return(ap);
+}
+
+Namarr_t *nv_arrayptr(register Namval_t *np)
+{
+ if(nv_isattr(np,NV_ARRAY))
+ return((Namarr_t*)nv_hasdisc(np, &array_disc));
+ return(0);
+}
+
+/*
+ * Verify that argument is an indexed array and convert to associative,
+ * freeing relevant storage
+ */
+static Namarr_t *nv_changearray(Namval_t *np, void *(*fun)(Namval_t*,const char*,int))
+{
+ register Namarr_t *ap;
+ char numbuff[NUMSIZE+1];
+ unsigned dot, digit, n;
+ union Value *up;
+ struct index_array *save_ap;
+ register char *string_index=&numbuff[NUMSIZE];
+ numbuff[NUMSIZE]='\0';
+
+ if(!fun || !(ap = nv_arrayptr(np)) || is_associative(ap))
+ return(NIL(Namarr_t*));
+
+ nv_stack(np,&ap->hdr);
+ save_ap = (struct index_array*)nv_stack(np,0);
+ ap = (Namarr_t*)((*fun)(np, NIL(char*), NV_AINIT));
+ ap->nelem = 0;
+ ap->fun = fun;
+ nv_onattr(np,NV_ARRAY);
+
+ for(dot = 0; dot < (unsigned)save_ap->maxi; dot++)
+ {
+ if(save_ap->val[dot].cp)
+ {
+ if ((digit = dot)== 0)
+ *--string_index = '0';
+ else while( n = digit )
+ {
+ digit /= 10;
+ *--string_index = '0' + (n-10*digit);
+ }
+ nv_putsub(np, string_index, ARRAY_ADD);
+ up = (union Value*)((*ap->fun)(np,NIL(char*),0));
+ ap->nelem++;
+ up->cp = save_ap->val[dot].cp;
+ save_ap->val[dot].cp = 0;
+ }
+ string_index = &numbuff[NUMSIZE];
+ }
+ free((void*)save_ap);
+ return(ap);
+}
+
+/*
+ * set the associative array processing method for node <np> to <fun>
+ * The array pointer is returned if sucessful.
+ */
+Namarr_t *nv_setarray(Namval_t *np, void *(*fun)(Namval_t*,const char*,int))
+{
+ register Namarr_t *ap;
+ char *value;
+ if(fun && (ap = nv_arrayptr(np)))
+ {
+ /*
+ * if it's already an indexed array, convert to
+ * associative structure
+ */
+ if(!is_associative(ap))
+ ap = nv_changearray(np, fun);
+ return(ap);
+ }
+ value = nv_getval(np);
+ if(fun && !ap && (ap = (Namarr_t*)((*fun)(np, NIL(char*), NV_AINIT))))
+ {
+ /* check for preexisting initialization and save */
+ ap->nelem = 0;
+ ap->fun = fun;
+ nv_onattr(np,NV_ARRAY);
+ if(value)
+ {
+ nv_putsub(np, "0", ARRAY_ADD);
+ nv_putval(np, value, 0);
+ }
+ return(ap);
+ }
+ return(NIL(Namarr_t*));
+}
+
+/*
+ * move parent subscript into child
+ */
+Namval_t *nv_arraychild(Namval_t *np, Namval_t *nq, int c)
+{
+ register Namarr_t *ap = nv_arrayptr(np);
+ union Value *up;
+ if(!(up = array_getup(np,ap)))
+ return((Namval_t*)0);
+ if(!nq)
+ return(array_find(np,ap, ARRAY_LOOKUP));
+ np->nvalue.cp = up->cp;
+ ap->nelem |= ARRAY_NOCLONE;
+ nv_clone(np, nq, NV_NODISC);
+ nv_offattr(nq,NV_ARRAY);
+ ap->nelem &= ~ARRAY_NOCLONE;
+ if(ap->fun)
+ {
+ up->np = (Namval_t*)((*ap->fun)(np,NIL(char*),NV_ACURRENT));
+ nv_onattr(up->np, NV_CHILD);
+ (up->np)->nvalue.np = nq;
+ }
+ else
+ {
+ struct index_array *aq = (struct index_array*)ap;
+ array_setbit(aq->bits,aq->cur);
+ up->np = nq;
+ }
+ if(c=='.')
+ nv_setvtree(nq);
+ return(nq);
+}
+
+/*
+ * This routine sets subscript of <np> to the next element, if any.
+ * The return value is zero, if there are no more elements
+ * Otherwise, 1 is returned.
+ */
+int nv_nextsub(Namval_t *np)
+{
+ register struct index_array *ap = (struct index_array*)nv_arrayptr(np);
+ register unsigned dot;
+ if(!ap || !(ap->header.nelem&ARRAY_SCAN))
+ return(0);
+ if(is_associative(ap))
+ {
+ struct assoc_array *aq;
+ if(aq=(*ap->header.fun)(np,NIL(char*),NV_ANEXT))
+ {
+ if(nv_isattr(aq->cur,NV_CHILD))
+ nv_putsub(aq->cur->nvalue.np,NIL(char*),ARRAY_UNDEF);
+ return(1);
+ }
+ ap->header.nelem &= ~(ARRAY_SCAN|ARRAY_NOCHILD);
+ return(0);
+ }
+ for(dot=ap->cur+1; dot < (unsigned)ap->maxi; dot++)
+ {
+ if(ap->val[dot].cp)
+ {
+ ap->cur = dot;
+ if(array_isbit(ap->bits, dot))
+ {
+
+ if(ap->header.nelem&ARRAY_NOCHILD)
+ continue;
+ nv_putsub(ap->val[dot].np,NIL(char*),ARRAY_UNDEF);
+ }
+ return(1);
+ }
+ }
+ ap->header.nelem &= ~(ARRAY_SCAN|ARRAY_NOCHILD);
+ ap->cur = 0;
+ return(0);
+}
+
+/*
+ * Set an array subscript for node <np> given the subscript <sp>
+ * An array is created if necessary.
+ * <mode> can be a number, plus or more of symbolic constants
+ * ARRAY_SCAN, ARRAY_UNDEF, ARRAY_ADD
+ * The node pointer is returned which can be NULL if <np> is
+ * not already array and the ARRAY_ADD bit of <mode> is not set.
+ * ARRAY_FILL sets the specified subscript to the empty string when
+ * ARRAY_ADD is specified and there is no value or sets all
+ * the elements up to the number specified if ARRAY_ADD is not specified
+ */
+Namval_t *nv_putsub(Namval_t *np,register char *sp,register long mode)
+{
+ register struct index_array *ap = (struct index_array*)nv_arrayptr(np);
+ register int size = (mode&ARRAY_MASK);
+ if(!ap || !ap->header.fun)
+ {
+ if(sp)
+ size = (int)sh_arith((char*)sp);
+ if(size >= ARRAY_MAX || (size < 0))
+ {
+ errormsg(SH_DICT,ERROR_exit(1),e_subscript, nv_name(np));
+ return(NIL(Namval_t*));
+ }
+ if(!ap || size>=ap->maxi)
+ {
+ if(size==0 && !(mode&ARRAY_FILL))
+ return(NIL(Namval_t*));
+ if(sh.subshell)
+ np = sh_assignok(np,1);
+ ap = array_grow(np, ap,size);
+ nv_onattr(np,NV_ARRAY);
+ }
+ ap->header.nelem &= ~ARRAY_UNDEF;
+ ap->header.nelem |= (mode&(ARRAY_SCAN|ARRAY_NOCHILD|ARRAY_UNDEF));
+ ap->cur = size;
+ if((mode&ARRAY_SCAN) && !ap->val[size].cp && !nv_nextsub(np))
+ np = 0;
+ if(mode&ARRAY_FILL)
+ {
+ if(!(mode&ARRAY_ADD))
+ {
+ int n;
+ for(n=0; n < size; n++)
+ {
+ if(!ap->val[n].cp)
+ ap->val[n].cp = Empty;
+ }
+ ap->header.nelem = n|(ap->header.nelem&(ARRAY_SCAN|ARRAY_UNDEF));
+ if(n=ap->maxi-ap->maxi)
+ memset(&ap->val[size],0,n*sizeof(union Value));
+ }
+ else if(!ap->val[size].cp)
+ {
+ if(sh.subshell)
+ np = sh_assignok(np,1);
+ ap->val[size].cp = Empty;
+ ap->header.nelem++;
+ }
+ }
+ else if(!(mode&ARRAY_SCAN))
+ {
+ ap->header.nelem &= ~ARRAY_SCAN;
+ if(array_isbit(ap->bits,size))
+ nv_putsub(ap->val[size].np,NIL(char*),ARRAY_UNDEF);
+ }
+ return((Namval_t*)np);
+ }
+ ap->header.nelem &= ~ARRAY_UNDEF;
+ if(!(mode&ARRAY_FILL))
+ ap->header.nelem &= ~ARRAY_SCAN;
+ ap->header.nelem |= (mode&(ARRAY_SCAN|ARRAY_NOCHILD|ARRAY_UNDEF));
+ if(sp)
+ {
+ union Value *up;
+ if(mode&ARRAY_SETSUB)
+ {
+ (*ap->header.fun)(np, sp, NV_ASETSUB);
+ return(np);
+ }
+ up = (union Value*)(*ap->header.fun)(np, sp, (mode&ARRAY_ADD)?NV_AADD:0);
+ if(up && !up->cp && (mode&ARRAY_ADD) && (mode&ARRAY_FILL))
+ {
+ if(sh.subshell)
+ np = sh_assignok(np,1);
+ up->cp = Empty;
+ ap->header.nelem++;
+ }
+ }
+ else if(mode&ARRAY_SCAN)
+ (*ap->header.fun)(np,(char*)np,0);
+ else if(mode&ARRAY_UNDEF)
+ (*ap->header.fun)(np, "",0);
+ if((mode&ARRAY_SCAN) && !nv_nextsub(np))
+ np = 0;
+ return(np);
+}
+
+/*
+ * process an array subscript for node <np> given the subscript <cp>
+ * returns pointer to character after the subscript
+ */
+char *nv_endsubscript(Namval_t *np, register char *cp, int mode)
+{
+ register int count=1, quoted=0, c;
+ register char *sp = cp+1;
+ /* first find matching ']' */
+ while(count>0 && (c= *++cp))
+ {
+ if(c=='\\' && (!(mode&NV_SUBQUOTE) || (c=cp[1])=='[' || c==']' || c=='\\' || c=='*' || c=='@'))
+ {
+ quoted=1;
+ cp++;
+ }
+ else if(c=='[')
+ count++;
+ else if(c==']')
+ count--;
+ }
+ *cp = 0;
+ if(quoted)
+ {
+ /* strip escape characters */
+ count = staktell();
+ stakwrite(sp,1+cp-sp);
+ sh_trim(sp=stakptr(count));
+ }
+ if(mode && np)
+ nv_putsub(np, sp, ARRAY_ADD|(cp[1]?ARRAY_FILL:mode&ARRAY_FILL));
+ if(quoted)
+ stakseek(count);
+ *cp++ = c;
+ return(cp);
+}
+
+
+Namval_t *nv_opensub(Namval_t* np)
+{
+ register struct index_array *ap = (struct index_array*)nv_arrayptr(np);
+ if(ap && is_associative(ap))
+ return((Namval_t*)((*ap->header.fun)(np,NIL(char*),NV_ACURRENT)));
+ return(NIL(Namval_t*));
+}
+
+char *nv_getsub(Namval_t* np)
+{
+ static char numbuff[NUMSIZE];
+ register struct index_array *ap;
+ register unsigned dot, n;
+ register char *cp = &numbuff[NUMSIZE];
+ if(!np || !(ap = (struct index_array*)nv_arrayptr(np)))
+ return(NIL(char*));
+ if(is_associative(ap))
+ return((char*)((*ap->header.fun)(np,NIL(char*),NV_ANAME)));
+ if((dot = ap->cur)==0)
+ *--cp = '0';
+ else while(n=dot)
+ {
+ dot /= 10;
+ *--cp = '0' + (n-10*dot);
+ }
+ return(cp);
+}
+
+/*
+ * If <np> is an indexed array node, the current subscript index
+ * returned, otherwise returns -1
+ */
+int nv_aindex(register Namval_t* np)
+{
+ Namarr_t *ap = nv_arrayptr(np);
+ if(!ap || is_associative(ap))
+ return(-1);
+ return(((struct index_array*)(ap))->cur&ARRAY_MASK);
+}
+
+
+/*
+ * This is the default implementation for associate arrays
+ */
+void *nv_associative(register Namval_t *np,const char *sp,int mode)
+{
+ register struct assoc_array *ap = (struct assoc_array*)nv_arrayptr(np);
+ register int type;
+ switch(mode)
+ {
+ case NV_AINIT:
+ if(ap = (struct assoc_array*)calloc(1,sizeof(struct assoc_array)))
+ {
+ ap->table = dtopen(&_Nvdisc,Dtbag);
+ ap->cur = 0;
+ ap->pos = 0;
+ ap->header.hdr.disc = &array_disc;
+ ap->header.hdr.nofree = 1;
+ nv_disc(np,(Namfun_t*)ap, NV_LAST);
+ }
+ return((void*)ap);
+ case NV_ADELETE:
+ if(ap->cur)
+ {
+ if(nv_isattr(ap->cur,NV_NOFREE))
+ nv_offattr(ap->cur,NV_NOFREE);
+ else
+ {
+ dtdelete(ap->table,(void*)ap->cur);
+ free((void*)ap->cur);
+ ap->cur = 0;
+ }
+ }
+ return((void*)ap);
+ case NV_AFREE:
+ ap->pos = 0;
+ dtclose(ap->table);
+ return((void*)ap);
+ case NV_ANEXT:
+ if(!ap->pos)
+ {
+ if(!(ap->pos=ap->cur))
+ ap->pos = (Namval_t*)dtfirst(ap->table);
+ }
+ else
+ ap->pos = ap->nextpos;
+ for(;ap->cur=ap->pos; ap->pos=ap->nextpos)
+ {
+ ap->nextpos = (Namval_t*)dtnext(ap->table,ap->pos);
+ if(ap->cur->nvalue.cp)
+ {
+ if((ap->header.nelem&ARRAY_NOCHILD) && nv_isattr(ap->cur,NV_CHILD))
+ continue;
+ return((void*)ap);
+ }
+ }
+ return(NIL(void*));
+ case NV_ASETSUB:
+ ap->cur = (Namval_t*)sp;
+ /* FALL THROUGH*/
+ case NV_ACURRENT:
+ return((void*)ap->cur);
+ case NV_ANAME:
+ if(ap->cur)
+ return((void*)nv_name(ap->cur));
+ return(NIL(void*));
+ default:
+ if(sp)
+ {
+ if(sp==(char*)np)
+ {
+ ap->cur = 0;
+ return(0);
+ }
+ else if(!(ap->header.nelem&ARRAY_SCAN))
+ ap->pos = 0;
+ type = nv_isattr(np,NV_PUBLIC&~(NV_ARRAY|NV_CHILD));
+ if((np=nv_search(sp,ap->table,mode?NV_ADD:0)) && nv_isnull(np))
+ nv_onattr(np,type);
+ ap->cur = np;
+ }
+ if(ap->cur)
+ return((void*)(&ap->cur->nvalue));
+ else
+ return((void*)(&ap->cur));
+ }
+}
+
+/*
+ * Assign values to an array
+ */
+void nv_setvec(register Namval_t *np,int append,register int argc,register char *argv[])
+{
+ int arg0=0;
+ struct index_array *ap=0;
+ if(nv_isarray(np))
+ {
+ ap = (struct index_array*)nv_arrayptr(np);
+ if(ap && is_associative(ap))
+ errormsg(SH_DICT,ERROR_exit(1),"cannot append index array to associate array %s",nv_name(np));
+ }
+ if(append)
+ {
+ if(ap)
+ {
+ arg0 = ap->maxi;
+ while(--arg0>0 && ap->val[arg0].cp==0);
+ arg0++;
+ }
+ else if(!nv_isnull(np))
+ arg0=1;
+ }
+ while(--argc >= 0)
+ {
+ if((argc+arg0)>0 || nv_isattr(np,NV_ARRAY))
+ nv_putsub(np,NIL(char*),(long)argc+arg0);
+ nv_putval(np,argv[argc],0);
+ }
+}
+
diff --git a/usr/src/lib/libshell/common/sh/bash.c b/usr/src/lib/libshell/common/sh/bash.c
new file mode 100644
index 0000000000..ecb10472b8
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/bash.c
@@ -0,0 +1,430 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * bash specific extensions
+ * originally provided by Karsten Fleischer
+ */
+
+#include "defs.h"
+#include "path.h"
+#include "io.h"
+#include "builtins.h"
+#include "name.h"
+
+#ifndef BASH_MAJOR
+# define BASH_MAJOR "1"
+# define BASH_MINOR "0"
+# define BASH_PATCH "0"
+# define BASH_BUILD "0"
+# define BASH_RELEASE "experimental"
+#endif
+#define BASH_VERSION BASH_MAJOR "." BASH_MINOR "." BASH_PATCH "(" BASH_BUILD ")-" BASH_RELEASE
+
+
+void sh_applyopts(Shopt_t);
+
+extern const char bash_pre_rc[];
+
+static char *login_files[4];
+
+const char sh_bash1[] =
+ "[B?Enable brace group expansion. This option is only availabe in bash "
+ "compatibility mode. In ksh mode, brace group expansion is always on.]"
+ "[P?Do not follow symbolic links, use physical directory structure "
+ "instead. Only available in bash compatibility mode.]";
+const char sh_bash2[] =
+"[l:login?Make the shell act as if it had been invoked as a login shell. "
+"Only available if invoked as \bbash\b.]"
+"[O]:?[shopt_option?\ashopt_option\a is one of the shell options accepted by "
+ "the \bshopt\b builtin. If \ashopt_option\a is present, \b-O\b sets "
+ "the value of that option; \b+O\b unsets it. If \ashopt_option\a is "
+ "not supplied, the names and values of the shell options accepted by "
+ "\bshopt\b are printed on the standard output. If the invocation "
+ "option is \b+O\b, the output is displayed in a format that may be "
+ "reused as input. Only available if invoked as \bbash\b.]"
+"[01:init-file|rcfile]:[file?Execute commands from \afile\a instead of the "
+ "standard personal initialization file ~/.bashrc if the shell is "
+ "interactive. Only available if invoked as \bbash\b.]"
+"[02:editing?For option compatibility with \bbash\b only. Ignored.]"
+"[03:profile?Read either the system-wide startup file or any of the "
+ "personal initialization files. On by default for interactive "
+ "shells. Only available if invoked as \bbash\b.]"
+"[04:rc?Read and execute the personal initialization file "
+ "\b$HOME/.bashrc\b. On by default for interactive shells. Only "
+ "available if invoked as \bbash\b.]"
+"[05:posix?If invoked as \bbash\b, turn on POSIX compatibility. \bBash\b in "
+ "POSIX mode is not the same as \bksh\b.]"
+"[06:version?Print version number and exit.]";
+
+const char sh_optshopt[] =
+"+[-1c?\n@(#)$Id: shopt (AT&T Research) 2003-02-13 $\n]"
+"[-author?Karsten Fleischer <K.Fleischer@omnium.de>]"
+USAGE_LICENSE
+"[+NAME?shopt - set/unset variables controlling optional shell behavior]"
+"[+DESCRIPTION?\bshopt\b sets or unsets variables controlling optional shell "
+ "behavior. With no options, or with the \b-p\b option, a list of all "
+ "settable options is displayed, with an indication of whether or not "
+ "each is set.]"
+"[p?Causes output to be displayed in a form that may be reused as input.]"
+"[s?Set each \aoptname\a.]"
+"[u?Unset each \aoptname\a.]"
+"[q?Suppress output (quiet mode). The return status indicates whether the "
+ "\aoptname\a is set or unset. If multiple \aoptname\a arguments are "
+ "given with \b-q\b, the return status is zero if all \aoptname\as are "
+ "enabled; non-zero otherwise.]"
+"[o?Restricts the values of \aoptname\a to be those defined for the \b-o\b "
+ "option to the set builtin.]"
+"[+?If either \b-s\b or \b-u\b is used with no \aoptname\a arguments, the "
+ "display is limited to those options which are set or unset.]"
+"[+?\bshopt\b supports all bash options. Some settings do not have any effect "
+ "or are are always on and cannot be changed.]"
+"[+?The value of \aoptname\a must be one of the following:]{"
+ "[+cdable_vars?If set, arguments to the \bcd\b command are "
+ "assumed to be names of variables whose values are to "
+ "be used if the usual \bcd\b proceeding fails.]"
+ "[+cdspell?Currently ignored.]"
+ "[+checkhash?Always on.]"
+ "[+checkwinsize?Currently ignored.]"
+ "[+cmdhist?Always on.]"
+ "[+dotglob?If set, include filenames beginning with a \b.\b "
+ "in the results of pathname expansion.]"
+ "[+execfail?Always on.]"
+ "[+expand_aliases?Always on.]"
+ "[+extglob?Enable extended pattern matching features.]"
+ "[+histappend?Always on.]"
+ "[+histreedit?If set and an edit mode is selected, the user "
+ "is given the opportunity to re-edit a failed history "
+ "substitution.]"
+ "[+histverify?If set and an edit mode is selected, the result "
+ "of a history substitution will not be executed "
+ "immediately but be placed in the edit buffer for "
+ "further modifications.]"
+ "[+hostcomplete?Currently ignored.]"
+ "[+huponexit?Currently ignored.]"
+ "[+interactive_comments?Always on.]"
+ "[+lithist?Always on.]"
+ "[+login_shell?This option is set if the shell is started as "
+ "a login shell. The value cannot be changed.]"
+ "[+mailwarn?Currently ignored.]"
+ "[+no_empty_cmd_completion?Always on.]"
+ "[+nocaseglob?Match filenames in a case-insensitive fashion "
+ "when performing filename expansion.]"
+ "[+nullglob?Allows filename patterns which match no files to "
+ "expand to a null string, rather than themselves.]"
+ "[+progcomp?Currently ignored.]"
+ "[+promptvars?Currently ignored.]"
+ "[+restricted_shell?This option is set if the shell is started "
+ "as a restricted shell. The value cannot be changed. "
+ "It is not reset during execution of startup files, "
+ "allowing the startup files to determine whether the "
+ "shell is restricted.]"
+ "[+shift_verbose?Currently ignored.]"
+ "[+sourcepath?If set, the \b.\b builtin uses the value of PATH "
+ "to find the directory containing the file supplied "
+ "as an argument.]"
+ "[+xpg_echo?If set, the \becho\b and \bprint\b builtins "
+ "expand backslash-escape sequences.]"
+"}"
+"\n"
+"\n[optname ...]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+?The return status when listing options is zero if all \aoptnames\a "
+ "are enabled, non-zero otherwise. When setting or unsetting options, "
+ "the return status is zero unless an \aoptname\a is not a valid shell "
+ "option.]"
+"}"
+
+"[+SEE ALSO?\bset\b(1)]"
+;
+
+/* GLOBIGNORE discipline. Turn on SH_DOTGLOB on set, turn off on unset. */
+
+static void put_globignore(register Namval_t* np, const char *val, int flags, Namfun_t *fp)
+{
+ if(val)
+ sh_onoption(SH_DOTGLOB);
+ else
+ sh_offoption(SH_DOTGLOB);
+
+ nv_putv(np,val,flags,fp);
+}
+
+const Namdisc_t SH_GLOBIGNORE_disc = { sizeof(Namfun_t), put_globignore };
+
+/* FUNCNAME discipline */
+
+struct funcname
+{
+ Namfun_t hdr;
+};
+
+static void put_funcname(register Namval_t* np,const char *val,int flags,Namfun_t *fp)
+{
+ /* bash silently returns with an error when FUNCNAME is set,
+ unsetting FUNCNAME is allowed */
+ if(val && !(flags&NV_RDONLY))
+ error_info.exit(1);
+
+ nv_putv(np,val,flags,fp);
+}
+
+const Namdisc_t SH_FUNCNAME_disc = { sizeof(struct funcname), put_funcname };
+
+#define SET_SET 1
+#define SET_UNSET 2
+#define SET_NOARGS 4
+
+/* shopt builtin */
+
+int b_shopt(int argc,register char *argv[],void *extra)
+{
+ Shell_t *shp = (Shell_t*)extra;
+ int n, f, ret=0;
+ Shopt_t newflags=shp->options, opt;
+ int verbose=PRINT_SHOPT|PRINT_ALL|PRINT_NO_HEADER|PRINT_VERBOSE;
+ int setflag=0, quietflag=0, oflag=0;
+ memset(&opt,0,sizeof(opt));
+#if SHOPT_RAWONLY
+ on_option(&newflags,SH_VIRAW);
+#endif
+ while((n = optget(argv,sh_optshopt)))
+ {
+ switch(n)
+ {
+ case 'p':
+ verbose&=~PRINT_VERBOSE;
+ break;
+ case 's':
+ case 'u':
+ setflag|=n=='s'?SET_SET:SET_UNSET;
+ if(setflag==(SET_SET|SET_UNSET))
+ {
+ errormsg(SH_DICT,ERROR_ERROR,"cannot set and unset options simultaneously");
+ error_info.errors++;
+ }
+ break;
+ case 'q':
+ quietflag=1;
+ break;
+ case 'o':
+ oflag=1;
+ verbose&=~PRINT_SHOPT;
+ break;
+ case ':':
+ errormsg(SH_DICT,2, "%s", opt_info.arg);
+ continue;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(0), "%s", opt_info.arg);
+ return(-1);
+ }
+ }
+ if(error_info.errors)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage(NIL(char*)));
+ argc -= opt_info.index;
+ if(argc==0)
+ {
+ /* no args, -s => mask=current options, -u mask=~(current options)
+ else mask=all bits */
+ if(setflag&SET_SET)
+ opt=newflags;
+ else if(setflag&SET_UNSET)
+ for(n=0;n<4;n++)
+ opt.v[n]=~newflags.v[n];
+ else
+ memset(&opt,0xff,sizeof(opt));
+ setflag=SET_NOARGS;
+ }
+ while(argc>0)
+ {
+ f=1;
+ n=sh_lookopt(argv[opt_info.index],&f);
+ if(n<=0||(setflag
+ && (is_option(&opt,SH_INTERACTIVE)
+ || is_option(&opt,SH_RESTRICTED)
+ || is_option(&opt,SH_RESTRICTED2)
+ || is_option(&opt,SH_BASH)
+ || is_option(&opt,SH_LOGIN_SHELL)))
+ ||(oflag&&(n&SH_BASHOPT)))
+ {
+ errormsg(SH_DICT,ERROR_ERROR, e_option, argv[opt_info.index]);
+ error_info.errors++;
+ ret=1;
+ }
+ else if(f)
+ on_option(&opt,n&0xff);
+ else
+ off_option(&opt,n&0xff);
+ opt_info.index++;
+ argc--;
+ }
+ if(setflag&(SET_SET|SET_UNSET))
+ {
+ if(setflag&SET_SET)
+ {
+ if(sh_isoption(SH_INTERACTIVE))
+ off_option(&opt,SH_NOEXEC);
+ if(is_option(&opt,SH_VI)||is_option(&opt,SH_EMACS)||is_option(&opt,SH_GMACS))
+ {
+ off_option(&newflags,SH_VI);
+ off_option(&newflags,SH_EMACS);
+ off_option(&newflags,SH_GMACS);
+ }
+ for(n=0;n<4;n++)
+ newflags.v[n] |= opt.v[n];
+ }
+ else if(setflag&SET_UNSET)
+ for(n=0;n<4;n++)
+ newflags.v[n] &= ~opt.v[n];
+ sh_applyopts(newflags);
+ shp->options = newflags;
+ if(is_option(&newflags,SH_XTRACE))
+ sh_trace(argv,1);
+ }
+ else if(!(setflag&SET_NOARGS)) /* no -s,-u but args, ret=0 if opt&mask==mask */
+ {
+ for(n=0;n<4;n++)
+ ret+=((newflags.v[n]&opt.v[n])!=opt.v[n]);
+ }
+ if(!quietflag&&!(setflag&(SET_SET|SET_UNSET)))
+ sh_printopts(newflags,verbose,&opt);
+ return(ret);
+}
+
+/* mode = 0: init, called two times
+ before parsing shell args with SH_PREINIT state turned on
+ second time after sh_init() is through and with SH_PREINIT state turned off
+ mode > 1: re-init
+ mode < 0: shutdown
+*/
+
+void bash_init(int mode)
+{
+ Sfio_t *iop;
+ Namval_t *np;
+ int n=0,xtrace,verbose;
+ if(mode>0)
+ goto reinit;
+ if(mode < 0)
+ {
+ /* termination code */
+ if(sh_isoption(SH_LOGIN_SHELL) && !sh_isoption(SH_POSIX))
+ sh_source(&sh, NiL, sh_mactry((char*)e_bash_logout));
+ return;
+ }
+
+ if(sh_isstate(SH_PREINIT))
+ { /* pre-init stage */
+ if(sh_isoption(SH_RESTRICTED))
+ sh_onoption(SH_RESTRICTED2);
+ sh_onoption(SH_HISTORY2);
+ sh_onoption(SH_INTERACTIVE_COMM);
+ sh_onoption(SH_SOURCEPATH);
+ sh_onoption(SH_HISTAPPEND);
+ sh_onoption(SH_CMDHIST);
+ sh_onoption(SH_LITHIST);
+ sh_onoption(SH_NOEMPTYCMDCOMPL);
+ if(sh.login_sh==2)
+ sh_onoption(SH_LOGIN_SHELL);
+ if(strcmp(astconf("CONFORMANCE",0,0),"standard")==0)
+ sh_onoption(SH_POSIX);
+ if(strcmp(astconf("UNIVERSE",0,0),"att")==0)
+ sh_onoption(SH_XPG_ECHO);
+ else
+ sh_offoption(SH_XPG_ECHO);
+ if(strcmp(astconf("PATH_RESOLVE",0,0),"physical")==0)
+ sh_onoption(SH_PHYSICAL);
+ else
+ sh_offoption(SH_PHYSICAL);
+
+ /* add builtins */
+ sh_addbuiltin("shopt", b_shopt, &sh);
+
+ /* set up some variables needed for --version
+ * needs to go here because --version option is parsed before the init script.
+ */
+ if(np=nv_open("HOSTTYPE",sh.var_tree,0))
+ nv_putval(np, BASH_HOSTTYPE, NV_NOFREE);
+ if(np=nv_open("MACHTYPE",sh.var_tree,0))
+ nv_putval(np, BASH_MACHTYPE, NV_NOFREE);
+ if(np=nv_open("BASH_VERSION",sh.var_tree,0))
+ nv_putval(np, BASH_VERSION, NV_NOFREE);
+ if(np=nv_open("BASH_VERSINFO",sh.var_tree,0))
+ {
+ char *argv[7];
+ argv[0] = BASH_MAJOR;
+ argv[1] = BASH_MINOR;
+ argv[2] = BASH_PATCH;
+ argv[3] = BASH_BUILD;
+ argv[4] = BASH_RELEASE;
+ argv[5] = BASH_MACHTYPE;
+ argv[6] = 0;
+ nv_setvec(np, 0, 6, argv);
+ nv_onattr(np,NV_RDONLY);
+ }
+ return;
+ }
+
+ /* rest of init stage */
+
+ /* restrict BASH_ENV */
+ if(np=nv_open("BASH_ENV",sh.var_tree,0))
+ {
+ const Namdisc_t *dp = nv_discfun(NV_DCRESTRICT);
+ Namfun_t *fp = calloc(dp->dsize,1);
+ fp->disc = dp;
+ nv_disc(np, fp, 0);
+ }
+
+ /* open GLOBIGNORE node */
+ if(np=nv_open("GLOBIGNORE",sh.var_tree,0))
+ {
+ const Namdisc_t *dp = &SH_GLOBIGNORE_disc;
+ Namfun_t *fp = calloc(dp->dsize,1);
+ fp->disc = dp;
+ nv_disc(np, fp, 0);
+ }
+
+ /* set startup files */
+ n=0;
+ if(!sh_isoption(SH_NOPROFILE))
+ {
+ if(!sh_isoption(SH_POSIX))
+ {
+ login_files[n++] = (char*)e_bash_profile;
+ login_files[n++] = (char*)e_bash_login;
+ }
+ login_files[n++] = (char*)e_profile;
+ }
+ sh.login_files = login_files;
+reinit:
+ xtrace = sh_isoption(SH_XTRACE);
+ sh_offoption(SH_XTRACE);
+ verbose = sh_isoption(SH_VERBOSE);
+ sh_offoption(SH_VERBOSE);
+ if(np = nv_open("SHELLOPTS", sh.var_tree, NV_NOADD))
+ nv_offattr(np,NV_RDONLY);
+ iop = sfopen(NULL, bash_pre_rc, "s");
+ sh_eval(iop,0);
+ if(xtrace)
+ sh_offoption(SH_XTRACE);
+ if(verbose)
+ sh_offoption(SH_VERBOSE);
+}
diff --git a/usr/src/lib/libshell/common/sh/defs.c b/usr/src/lib/libshell/common/sh/defs.c
new file mode 100644
index 0000000000..8b11839eb4
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/defs.c
@@ -0,0 +1,47 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * Ksh - AT&T Labs
+ * Written by David Korn
+ * This file defines all the read/write shell global variables
+ */
+
+#include "defs.h"
+#include "jobs.h"
+#include "shlex.h"
+#include "edit.h"
+#include "timeout.h"
+
+struct sh_static sh = {0};
+#ifdef __IMPORT__
+ struct sh_static *_imp__sh = &sh;
+#endif
+
+Dtdisc_t _Nvdisc =
+{
+ offsetof(Namval_t,nvname), -1 , 0, 0, 0, nv_compare
+};
+
+/* reserve room for writable state table */
+char *sh_lexstates[ST_NONE] = {0};
+
+struct jobs job = {0};
+int32_t sh_mailchk = 600;
+
diff --git a/usr/src/lib/libshell/common/sh/deparse.c b/usr/src/lib/libshell/common/sh/deparse.c
new file mode 100644
index 0000000000..74457d1092
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/deparse.c
@@ -0,0 +1,584 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * shell deparser
+ *
+ */
+
+#include "defs.h"
+#include "shnodes.h"
+#include "test.h"
+
+
+#define HUGE_INT (((unsigned)-1)>>1)
+#define BEGIN 0
+#define MIDDLE 1
+#define END 2
+#define PRE 1
+#define POST 2
+
+
+/* flags that can be specified with p_tree() */
+#define NO_NEWLINE 1
+#define NEED_BRACE 2
+#define NO_BRACKET 4
+
+static void p_comlist(const struct dolnod*,int);
+static void p_arg(const struct argnod*, int endchar, int opts);
+static void p_comarg(const struct comnod*);
+static void p_keyword(const char*,int);
+static void p_redirect(const struct ionod*);
+static void p_switch(const struct regnod*);
+static void here_body(const struct ionod*);
+static void p_tree(const Shnode_t*,int);
+
+static int level;
+static int begin_line;
+static int end_line;
+static char io_op[7];
+static char un_op[3] = "-?";
+static const struct ionod *here_doc;
+static Sfio_t *outfile;
+static const char *forinit = "";
+
+extern void sh_deparse(Sfio_t*, const Shnode_t*,int);
+
+void sh_deparse(Sfio_t *out, const Shnode_t *t,int tflags)
+{
+ outfile = out;
+ p_tree(t,tflags);
+}
+/*
+ * print script corresponding to shell tree <t>
+ */
+static void p_tree(register const Shnode_t *t,register int tflags)
+{
+ register char *cp;
+ int save = end_line;
+ int needbrace = (tflags&NEED_BRACE);
+ tflags &= ~NEED_BRACE;
+ if(tflags&NO_NEWLINE)
+ end_line = ' ';
+ else
+ end_line = '\n';
+ switch(t->tre.tretyp&COMMSK)
+ {
+ case TTIME:
+ if(t->tre.tretyp&COMSCAN)
+ p_keyword("!",BEGIN);
+ else
+ p_keyword("time",BEGIN);
+ if(t->par.partre)
+ p_tree(t->par.partre,tflags);
+ level--;
+ break;
+
+ case TCOM:
+ if(begin_line && level>0)
+ sfnputc(outfile,'\t',level);
+ begin_line = 0;
+ p_comarg((struct comnod*)t);
+ break;
+
+ case TSETIO:
+ if(t->tre.tretyp&FPCL)
+ tflags |= NEED_BRACE;
+ else
+ tflags = NO_NEWLINE|NEED_BRACE;
+ p_tree(t->fork.forktre,tflags);
+ p_redirect(t->fork.forkio);
+ break;
+
+ case TFORK:
+ if(needbrace)
+ tflags |= NEED_BRACE;
+ if(t->tre.tretyp&(FAMP|FCOOP))
+ {
+ tflags = NEED_BRACE|NO_NEWLINE;
+ end_line = ' ';
+ }
+ else if(t->fork.forkio)
+ tflags = NO_NEWLINE;
+ p_tree(t->fork.forktre,tflags);
+ if(t->fork.forkio)
+ p_redirect(t->fork.forkio);
+ if(t->tre.tretyp&FCOOP)
+ {
+ sfputr(outfile,"|&",'\n');
+ begin_line = 1;
+ }
+ else if(t->tre.tretyp&FAMP)
+ {
+ sfputr(outfile,"&",'\n');
+ begin_line = 1;
+ }
+ break;
+
+ case TIF:
+ p_keyword("if",BEGIN);
+ p_tree(t->if_.iftre,0);
+ p_keyword("then",MIDDLE);
+ p_tree(t->if_.thtre,0);
+ if(t->if_.eltre)
+ {
+ p_keyword("else",MIDDLE);
+ p_tree(t->if_.eltre,0);
+ }
+ p_keyword("fi",END);
+ break;
+
+ case TWH:
+ if(t->wh.whinc)
+ cp = "for";
+ else if(t->tre.tretyp&COMSCAN)
+ cp = "until";
+ else
+ cp = "while";
+ p_keyword(cp,BEGIN);
+ if(t->wh.whinc)
+ {
+ struct argnod *arg = (t->wh.whtre)->ar.arexpr;
+ sfprintf(outfile,"(( %s; ",forinit);
+ forinit = "";
+ sfputr(outfile,arg->argval,';');
+ arg = (t->wh.whinc)->arexpr;
+ sfprintf(outfile," %s))\n",arg->argval);
+ }
+ else
+ p_tree(t->wh.whtre,0);
+ t = t->wh.dotre;
+ goto dolist;
+
+ case TLST:
+ {
+ Shnode_t *tr = t->lst.lstrit;
+ if(tr->tre.tretyp==TWH && tr->wh.whinc && t->lst.lstlef->tre.tretyp==TARITH)
+ {
+ /* arithmetic for statement */
+ struct argnod *init = (t->lst.lstlef)->ar.arexpr;
+ forinit= init->argval;
+ p_tree(t->lst.lstrit,tflags);
+ break;
+ }
+ if(needbrace)
+ p_keyword("{",BEGIN);
+ p_tree(t->lst.lstlef,0);
+ if(needbrace)
+ tflags = 0;
+ p_tree(t->lst.lstrit,tflags);
+ if(needbrace)
+ p_keyword("}",END);
+ break;
+ }
+
+ case TAND:
+ cp = "&&";
+ goto andor;
+ case TORF:
+ cp = "||";
+ goto andor;
+ case TFIL:
+ cp = "|";
+ andor:
+ {
+ int bracket = 0;
+ if(t->tre.tretyp&TTEST)
+ {
+ tflags |= NO_NEWLINE;
+ if(!(tflags&NO_BRACKET))
+ {
+ p_keyword("[[",BEGIN);
+ tflags |= NO_BRACKET;
+ bracket=1;
+ }
+ }
+ p_tree(t->lst.lstlef,NEED_BRACE|NO_NEWLINE|(tflags&NO_BRACKET));
+ sfputr(outfile,cp,here_doc?'\n':' ');
+ if(here_doc)
+ {
+ here_body(here_doc);
+ here_doc = 0;
+ }
+ level++;
+ p_tree(t->lst.lstrit,tflags|NEED_BRACE);
+ if(bracket)
+ p_keyword("]]",END);
+ level--;
+ break;
+ }
+
+ case TPAR:
+ p_keyword("(",BEGIN);
+ p_tree(t->par.partre,0);
+ p_keyword(")",END);
+ break;
+
+ case TARITH:
+ {
+ register struct argnod *ap = t->ar.arexpr;
+ if(begin_line && level)
+ sfnputc(outfile,'\t',level);
+ sfprintf(outfile,"(( %s ))%c",ap->argval,end_line);
+ if(!(tflags&NO_NEWLINE))
+ begin_line=1;
+ break;
+ }
+
+ case TFOR:
+ cp = ((t->tre.tretyp&COMSCAN)?"select":"for");
+ p_keyword(cp,BEGIN);
+ sfputr(outfile,t->for_.fornam,' ');
+ if(t->for_.forlst)
+ {
+ sfputr(outfile,"in",' ');
+ tflags = end_line;
+ end_line = '\n';
+ p_comarg(t->for_.forlst);
+ end_line = tflags;
+ }
+ else
+ sfputc(outfile,'\n');
+ begin_line = 1;
+ t = t->for_.fortre;
+ dolist:
+ p_keyword("do",MIDDLE);
+ p_tree(t,0);
+ p_keyword("done",END);
+ break;
+
+ case TSW:
+ p_keyword("case",BEGIN);
+ p_arg(t->sw.swarg,' ',0);
+ if(t->sw.swlst)
+ {
+ begin_line = 1;
+ sfputr(outfile,"in",'\n');
+ tflags = end_line;
+ end_line = '\n';
+ p_switch(t->sw.swlst);
+ end_line = tflags;
+ }
+ p_keyword("esac",END);
+ break;
+
+ case TFUN:
+ if(t->tre.tretyp&FPOSIX)
+ {
+ sfprintf(outfile,"%s",t->funct.functnam);
+ p_keyword("()\n",BEGIN);
+ }
+ else
+ {
+ p_keyword("function",BEGIN);
+ tflags = (t->funct.functargs?' ':'\n');
+ sfputr(outfile,t->funct.functnam,tflags);
+ if(t->funct.functargs)
+ {
+ tflags = end_line;
+ end_line = '\n';
+ p_comarg(t->funct.functargs);
+ end_line = tflags;
+ }
+ }
+ begin_line = 1;
+ p_keyword("{\n",MIDDLE);
+ begin_line = 1;
+ p_tree(t->funct.functtre,0);
+ p_keyword("}",END);
+ break;
+ /* new test compound command */
+ case TTST:
+ if(!(tflags&NO_BRACKET))
+ p_keyword("[[",BEGIN);
+ if((t->tre.tretyp&TPAREN)==TPAREN)
+ {
+ p_keyword("(",BEGIN);
+ p_tree(t->lst.lstlef,NO_BRACKET|NO_NEWLINE);
+ p_keyword(")",END);
+ }
+ else
+ {
+ int flags = (t->tre.tretyp)>>TSHIFT;
+ if(t->tre.tretyp&TNEGATE)
+ sfputr(outfile,"!",' ');
+ if(t->tre.tretyp&TUNARY)
+ {
+ un_op[1] = flags;
+ sfputr(outfile,un_op,' ');
+ }
+ else
+ cp = ((char*)(shtab_testops+(flags&037)-1)->sh_name);
+ p_arg(&(t->lst.lstlef->arg),' ',0);
+ if(t->tre.tretyp&TBINARY)
+ {
+ sfputr(outfile,cp,' ');
+ p_arg(&(t->lst.lstrit->arg),' ',0);
+ }
+ }
+ if(!(tflags&NO_BRACKET))
+ p_keyword("]]",END);
+ }
+ while(begin_line && here_doc)
+ {
+ here_body(here_doc);
+ here_doc = 0;
+ }
+ end_line = save;
+ return;
+}
+
+/*
+ * print a keyword
+ * increment indent level for flag==BEGIN
+ * decrement indent level for flag==END
+ */
+static void p_keyword(const char *word,int flag)
+{
+ register int sep;
+ if(flag==END)
+ sep = end_line;
+ else if(*word=='[' || *word=='(')
+ sep = ' ';
+ else
+ sep = '\t';
+ if(flag!=BEGIN)
+ level--;
+ if(begin_line && level)
+ sfnputc(outfile,'\t',level);
+ sfputr(outfile,word,sep);
+ if(sep=='\n')
+ begin_line=1;
+ else
+ begin_line=0;
+ if(flag!=END)
+ level++;
+}
+
+static void p_arg(register const struct argnod *arg,register int endchar,int opts)
+{
+ register const char *cp;
+ register int flag;
+ do
+ {
+ if(!arg->argnxt.ap)
+ flag = endchar;
+ else if(opts&PRE)
+ {
+ /* case alternation lists in reverse order */
+ p_arg(arg->argnxt.ap,'|',opts);
+ flag = endchar;
+ }
+ else if(opts)
+ flag = ' ';
+ cp = arg->argval;
+ if(*cp==0 && opts==POST && arg->argchn.ap)
+ {
+ /* compound assignment */
+ struct fornod *fp=(struct fornod*)arg->argchn.ap;
+ sfprintf(outfile,"%s=(\n",fp->fornam);
+ sfnputc(outfile,'\t',++level);
+ p_tree(fp->fortre,0);
+ if(--level)
+ sfnputc(outfile,'\t',level);
+ sfputc(outfile,')');
+ }
+ else if((arg->argflag&ARG_RAW) && (cp[1] || (*cp!='[' && *cp!=']')))
+ cp = sh_fmtq(cp);
+ sfputr(outfile,cp,flag);
+ if(flag=='\n')
+ begin_line = 1;
+ arg = arg->argnxt.ap;
+ }
+ while((opts&POST) && arg);
+ return;
+}
+
+static void p_redirect(register const struct ionod *iop)
+{
+ register char *cp;
+ register int iof,iof2;
+ for(;iop;iop=iop->ionxt)
+ {
+ iof=iop->iofile;
+ cp = io_op;
+ if(iop->iovname)
+ {
+ sfwrite(outfile,"(;",2);
+ sfputr(outfile,iop->iovname,')');
+ cp++;
+ }
+ else
+ *cp = '0'+(iof&IOUFD);
+ if(iof&IOPUT)
+ {
+ if(*cp == '1' && !iop->iovname)
+ cp++;
+ io_op[1] = '>';
+ }
+ else
+ {
+ if(*cp == '0' && !iop->iovname)
+ cp++;
+ io_op[1] = '<';
+ }
+ io_op[2] = 0;
+ io_op[3] = 0;
+ if(iof&IOLSEEK)
+ {
+ io_op[1] = '#';
+ if(iof&IOARITH)
+ strcpy(&io_op[3]," ((");
+ }
+ else if(iof&IOMOV)
+ io_op[2] = '&';
+ else if(iof&(IORDW|IOAPP))
+ io_op[2] = '>';
+ else if(iof&IOCLOB)
+ io_op[2] = '|';
+ if(iop->iodelim)
+ {
+ /* here document */
+#ifdef xxx
+ iop->iolink = (char*)here_doc;
+#endif
+ here_doc = iop;
+ io_op[2] = '<';
+#ifdef future
+ if(iof&IOSTRIP)
+ io_op[3] = '-';
+#endif
+ }
+ sfputr(outfile,cp,' ');
+ if(iop->ionxt)
+ iof = ' ';
+ else
+ {
+ if((iof=end_line)=='\n')
+ begin_line = 1;
+ }
+ if((iof&IOLSEEK) && (iof&IOARITH))
+ iof2 = iof, iof = ' ';
+ if(iop->iodelim)
+ {
+ if(!(iop->iofile&IODOC))
+ sfwrite(outfile,"''",2);
+ sfputr(outfile,sh_fmtq(iop->iodelim),iof);
+ }
+ else if(iop->iofile&IORAW)
+ sfputr(outfile,sh_fmtq(iop->ioname),iof);
+ else
+ sfputr(outfile,iop->ioname,iof);
+ if((iof&IOLSEEK) && (iof&IOARITH))
+ sfputr(outfile, "))", iof2);
+ }
+ return;
+}
+
+static void p_comarg(register const struct comnod *com)
+{
+ register int flag = end_line;
+ if(com->comarg || com->comio)
+ flag = ' ';
+ if(com->comset)
+ p_arg(com->comset,flag,POST);
+ if(com->comarg)
+ {
+ if(!com->comio)
+ flag = end_line;
+ if(com->comtyp&COMSCAN)
+ p_arg(com->comarg,flag,POST);
+ else
+ p_comlist((struct dolnod*)com->comarg,flag);
+ }
+ if(com->comio)
+ p_redirect(com->comio);
+ return;
+}
+
+static void p_comlist(const struct dolnod *dol,int endchar)
+{
+ register char *cp, *const*argv;
+ register int flag = ' ', special;
+ argv = dol->dolval+ARG_SPARE;
+ cp = *argv;
+ special = (*cp=='[' && cp[1]==0);
+ do
+ {
+ if(cp)
+ argv++;
+ else
+ cp = "";
+ if(*argv==0)
+ {
+ if((flag=endchar)=='\n')
+ begin_line = 1;
+ special = (*cp==']' && cp[1]==0);
+ }
+ sfputr(outfile,special?cp:sh_fmtq(cp),flag);
+ special = 0;
+ }
+ while(cp = *argv);
+ return;
+}
+
+static void p_switch(register const struct regnod *reg)
+{
+ if(level>1)
+ sfnputc(outfile,'\t',level-1);
+ p_arg(reg->regptr,')',PRE);
+ begin_line = 0;
+ sfputc(outfile,'\t');
+ if(reg->regcom)
+ p_tree(reg->regcom,0);
+ level++;
+ if(reg->regflag)
+ p_keyword(";&",END);
+ else
+ p_keyword(";;",END);
+ if(reg->regnxt)
+ p_switch(reg->regnxt);
+ return;
+}
+
+/*
+ * output here documents
+ */
+static void here_body(register const struct ionod *iop)
+{
+ Sfio_t *infile;
+#ifdef xxx
+ if(iop->iolink)
+ here_body((struct inode*)iop->iolink);
+ iop->iolink = 0;
+#endif
+ if(iop->iofile&IOSTRG)
+ infile = sfnew((Sfio_t*)0,iop->ioname,iop->iosize,-1,SF_STRING|SF_READ);
+ else
+ sfseek(infile=sh.heredocs,iop->iooffset,SEEK_SET);
+ sfmove(infile,outfile,iop->iosize,-1);
+ if(iop->iofile&IOSTRG)
+ sfclose(infile);
+ sfputr(outfile,iop->iodelim,'\n');
+}
+
diff --git a/usr/src/lib/libshell/common/sh/env.c b/usr/src/lib/libshell/common/sh/env.c
new file mode 100644
index 0000000000..d7f7b0b6d7
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/env.c
@@ -0,0 +1,255 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+#include <cdt.h>
+
+#define env_change() (++ast.env_serial)
+
+typedef struct _venv_ Evar_t;
+struct _venv_
+{
+ union
+ {
+ Evar_t *next;
+ char *ptr;
+ } un;
+ Dtlink_t link;
+ int index;
+};
+
+typedef struct _env_
+{
+ Dt_t *dt;
+ Evar_t *freelist;
+ char **env;
+ int count;
+ int extra;
+ int max;
+ int flags;
+} Env_t;
+
+#define _BLD_env 1
+#include <env.h>
+
+#define ENV_VALID 2 /* set if env is valid */
+#define ENV_PMALLOC 1 /* set if Evar_t->un.ptr *s malloced */
+#define ENV_VMALLOC 2 /* set of Evar_t was malloced */
+#define ENV_BITS 3
+
+/*
+ * Compares the name portion of name=... only.
+ */
+static int compare(Dt_t *dt, Void_t* key1, Void_t* key2, Dtdisc_t* disc)
+{
+ register int c,d;
+ const unsigned char *s1=(unsigned const char*)key1;
+ const unsigned char *s2=(unsigned const char*)key2;
+ while((c= *s1++) && c!='=' && c==*s2)
+ s2++;
+ if(c=='=')
+ c = 0;
+ if((d=*s2)=='=')
+ d = 0;
+ return(c-d);
+}
+
+static Dtdisc_t env_disc =
+{
+ 0, -1,
+ sizeof(char*),
+ 0,
+ 0,
+ compare
+};
+
+/*
+ * return a pointer to the environment in sorted order
+ * NULL is returned if there if there is nospace
+ */
+char **env_get(Env_t* ep)
+{
+ register Evar_t *vp;
+ register int n=ep->extra;
+ if(ep->flags&ENV_VALID)
+ return(ep->env+n);
+ if(ep->count > ep->max)
+ {
+ if(ep->flags&ENV_MALLOCED)
+ free((void*)ep->env);
+ if(!(ep->env = (char**)malloc(sizeof(char*)*(ep->count+1))))
+ return(0);
+ ep->flags |= ENV_MALLOCED;
+ ep->max = ep->count;
+ }
+ for(vp=(Evar_t*)dtfirst(ep->dt);vp; vp=(Evar_t*)dtnext(ep->dt,vp))
+ {
+ vp->index = (n<<ENV_BITS) | (vp->index&((1<<ENV_BITS)-1));
+ ep->env[n++] = vp->un.ptr;
+ }
+ ep->env[n] = 0;
+ ep->flags |= ENV_VALID;
+ environ = ep->env+ep->extra;
+ return(ep->env+ep->extra);
+}
+
+/*
+ * add name=value pair given by <str> to <ep>
+ * if malloced is set, the variable will be freed when reassigned
+ * The environment list may become invalidated
+ * Returns 1 for success, 0 for failure
+ */
+int env_add(Env_t *ep, const char *str, int flags)
+{
+ Evar_t *vp = (Evar_t*)dtmatch(ep->dt,(void*)str);
+ if(vp && strcmp(str,vp->un.ptr)==0)
+ return(1);
+ if(flags&ENV_STRDUP)
+ str = strdup(str);
+ if(vp)
+ {
+ if(vp->index&ENV_PMALLOC)
+ free((void*)vp->un.ptr);
+ vp->un.ptr = (char*)str;
+ if(ep->env && (ep->flags&ENV_VALID))
+ ep->env[vp->index>>ENV_BITS] = vp->un.ptr;
+ }
+ else
+ {
+ ep->flags &= ~ENV_VALID;
+ if(vp = ep->freelist)
+ ep->freelist = vp->un.next;
+ else if(vp = newof((Evar_t*)0,Evar_t,2,0))
+ {
+ vp->index = ENV_VMALLOC;
+ ep->freelist = (vp+1);
+ ep->freelist->un.next = 0;
+ }
+ else
+ return(0);
+ vp->un.ptr = (void*)str;
+ if(!(vp=dtinsert(ep->dt,vp)))
+ return(0);
+ ep->count++;
+ }
+ if(flags)
+ vp->index |= ENV_PMALLOC;
+ else
+ vp->index &= ~ENV_PMALLOC;
+ env_change();
+ return(1);
+}
+
+/*
+ * delete name from <ep>
+ * The environment list may become invalidated
+ * Returns 1 for success, 0 for if name is not present
+ */
+int env_delete(Env_t *ep, const char *str)
+{
+ Evar_t *vp = (Evar_t*)dtmatch(ep->dt,(void*)str);
+ if(!vp)
+ return(0);
+ ep->flags &= ~ENV_VALID;
+ if(vp->index&ENV_PMALLOC)
+ free((void*)vp->un.ptr);
+ dtdelete(ep->dt,vp);
+ vp->un.next = ep->freelist;
+ ep->freelist = vp;
+ env_change();
+ return(1);
+}
+
+/*
+ * open up a structure to support environment variables
+ * initialize with environment give by <envp>
+ * If <extra> > 0, <extra> slots will be left at beginning of
+ * environment list when env_get() is involed.
+ * If <extra>==ENV_USABLE, then the original environ can be
+ * used and returned. Otherwise, a new one will be returned
+ */
+Env_t *env_open(char **envp, int extra)
+{
+ char **env;
+ Env_t *ep;
+ Evar_t *vp;
+ int n=2;
+ if(!(ep = newof((Env_t*)0,Env_t,1,0)))
+ return(0);
+ if(!(ep->dt = dtopen(&env_disc,Dtoset)))
+ return(0);
+ if(env=envp)
+ {
+ while(*env++);
+ n = (env+2)-envp;
+ }
+ if(extra==ENV_STABLE)
+ {
+ ep->env = envp;
+ ep->max = n-1;
+ }
+ else
+ ep->count = ep->extra = extra;
+ ep->freelist = vp = newof((Evar_t*)0,Evar_t,n,0);
+ vp->index = ENV_VMALLOC;
+ while(--n>0)
+ {
+ vp->un.next = (vp+1);
+ vp++;
+ }
+ vp->un.next = 0;
+ if(env)
+ {
+ for(env=envp; *env; env++)
+ env_add(ep,*env,0);
+ }
+ return(ep);
+}
+
+/*
+ * close <ep> and free up all space used by it
+ */
+void env_close(Env_t *ep)
+{
+ Evar_t *vp, *vpnext,*top;
+ if(ep->env && (ep->flags&ENV_MALLOCED))
+ free((void*)ep->env);
+ for(vp=(Evar_t*)dtfirst(ep->dt);vp; vp=vpnext)
+ {
+ vpnext = (Evar_t*)dtnext(ep->dt,vp);
+ env_delete(ep,vp->un.ptr);
+ }
+ for(top=0,vp = ep->freelist; vp; vp = vpnext)
+ {
+ vpnext = vp->un.next;
+ if(vp->index&ENV_VMALLOC)
+ {
+ vp->un.next = top;
+ top = vp;
+ }
+ }
+ for(vp=top; vp; vp = vpnext)
+ {
+ vpnext = vp->un.next;
+ free((void*)vp);
+ }
+ dtclose(ep->dt);
+}
diff --git a/usr/src/lib/libshell/common/sh/expand.c b/usr/src/lib/libshell/common/sh/expand.c
new file mode 100644
index 0000000000..097ed0da66
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/expand.c
@@ -0,0 +1,465 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * File name expansion
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#if KSHELL
+# include "defs.h"
+# include "variables.h"
+# include "test.h"
+#else
+# include <ast.h>
+# include <setjmp.h>
+#endif /* KSHELL */
+#include <glob.h>
+#include <ls.h>
+#include <stak.h>
+#include <ast_dir.h>
+#include "io.h"
+#include "path.h"
+
+#if !SHOPT_BRACEPAT
+# define SHOPT_BRACEPAT 0
+#endif
+
+#if KSHELL
+# define argbegin argnxt.cp
+ static const char *sufstr;
+ static int suflen;
+ static int scantree(Dt_t*,const char*, struct argnod**);
+#else
+# define sh_sigcheck() (0)
+# define sh_access access
+# define suflen 0
+#endif /* KSHELL */
+
+
+/*
+ * This routine builds a list of files that match a given pathname
+ * Uses external routine strgrpmatch() to match each component
+ * A leading . must match explicitly
+ *
+ */
+
+#ifndef GLOB_AUGMENTED
+# define GLOB_AUGMENTED 0
+#endif
+
+#define GLOB_RESCAN 1
+#define globptr() ((struct glob*)membase)
+
+static struct glob *membase;
+
+#if GLOB_VERSION >= 20010916L
+static char *nextdir(glob_t *gp, char *dir)
+{
+ Pathcomp_t *pp = (Pathcomp_t*)gp->gl_handle;
+ if(!dir)
+ pp = path_get("");
+ else
+ pp = pp->next;
+ gp->gl_handle = (void*)pp;
+ if(pp)
+ return(pp->name);
+ return(0);
+}
+#endif
+
+int path_expand(const char *pattern, struct argnod **arghead)
+{
+ glob_t gdata;
+ register struct argnod *ap;
+ register glob_t *gp= &gdata;
+ register int flags,extra=0;
+#if SHOPT_BASH
+ register int off;
+ register char *sp, *cp, *cp2;
+#endif
+ memset(gp,0,sizeof(gdata));
+ flags = GLOB_AUGMENTED|GLOB_NOCHECK|GLOB_NOSORT|GLOB_STACK|GLOB_LIST|GLOB_DISC;
+ if(sh_isoption(SH_MARKDIRS))
+ flags |= GLOB_MARK;
+ if(sh_isoption(SH_GLOBSTARS))
+ flags |= GLOB_STARSTAR;
+#if SHOPT_BASH
+#if 0
+ if(sh_isoption(SH_BASH) && !sh_isoption(SH_EXTGLOB))
+ flags &= ~GLOB_AUGMENTED;
+#endif
+ if(sh_isoption(SH_NULLGLOB))
+ flags &= ~GLOB_NOCHECK;
+ if(sh_isoption(SH_NOCASEGLOB))
+ flags |= GLOB_ICASE;
+#endif
+ if(sh_isstate(SH_COMPLETE))
+ {
+#if KSHELL
+ extra += scantree(sh.alias_tree,pattern,arghead);
+ extra += scantree(sh.fun_tree,pattern,arghead);
+# if GLOB_VERSION >= 20010916L
+ gp->gl_nextdir = nextdir;
+# endif
+#endif /* KSHELL */
+ flags |= GLOB_COMPLETE;
+ flags &= ~GLOB_NOCHECK;
+ }
+#if SHOPT_BASH
+ if(off = staktell())
+ sp = stakfreeze(0);
+ if(sh_isoption(SH_BASH))
+ {
+ /*
+ * For bash, FIGNORE is a colon separated list of suffixes to
+ * ignore when doing filename/command completion.
+ * GLOBIGNORE is similar to ksh FIGNORE, but colon separated
+ * instead of being an augmented shell pattern.
+ * Generate shell patterns out of those here.
+ */
+ if(sh_isstate(SH_FCOMPLETE))
+ cp=nv_getval(nv_scoped(FIGNORENOD));
+ else
+ {
+ static Namval_t *GLOBIGNORENOD;
+ if(!GLOBIGNORENOD)
+ GLOBIGNORENOD = nv_open("GLOBIGNORE",sh.var_tree,0);
+ cp=nv_getval(nv_scoped(GLOBIGNORENOD));
+ }
+ if(cp)
+ {
+ flags |= GLOB_AUGMENTED;
+ stakputs("@(");
+ if(!sh_isstate(SH_FCOMPLETE))
+ {
+ stakputs(cp);
+ for(cp=stakptr(off); *cp; cp++)
+ if(*cp == ':')
+ *cp='|';
+ }
+ else
+ {
+ cp2 = strtok(cp, ":");
+ if(!cp2)
+ cp2=cp;
+ do
+ {
+ stakputc('*');
+ stakputs(cp2);
+ if(cp2 = strtok(NULL, ":"))
+ {
+ *(cp2-1)=':';
+ stakputc('|');
+ }
+ } while(cp2);
+ }
+ stakputc(')');
+ gp->gl_fignore = stakfreeze(1);
+ }
+ else if(!sh_isstate(SH_FCOMPLETE) && sh_isoption(SH_DOTGLOB))
+ gp->gl_fignore = "";
+ }
+ else
+#endif
+ gp->gl_fignore = nv_getval(nv_scoped(FIGNORENOD));
+ if(suflen)
+ gp->gl_suffix = sufstr;
+ gp->gl_intr = &sh.trapnote;
+ suflen = 0;
+ if(memcmp(pattern,"~(N",3)==0)
+ flags &= ~GLOB_NOCHECK;
+ glob(pattern, flags, 0, gp);
+#if SHOPT_BASH
+ if(off)
+ stakset(sp,off);
+ else
+ stakseek(0);
+#endif
+ sh_sigcheck();
+ for(ap= (struct argnod*)gp->gl_list; ap; ap = ap->argnxt.ap)
+ {
+ ap->argchn.ap = ap->argnxt.ap;
+ if(!ap->argnxt.ap)
+ ap->argchn.ap = *arghead;
+ }
+ if(gp->gl_list)
+ *arghead = (struct argnod*)gp->gl_list;
+ return(gp->gl_pathc+extra);
+}
+
+#if KSHELL
+
+/*
+ * scan tree and add each name that matches the given pattern
+ */
+static int scantree(Dt_t *tree, const char *pattern, struct argnod **arghead)
+{
+ register Namval_t *np;
+ register struct argnod *ap;
+ register int nmatch=0;
+ register char *cp;
+ np = (Namval_t*)dtfirst(tree);
+ for(;np && !nv_isnull(np);(np = (Namval_t*)dtnext(tree,np)))
+ {
+ if(strmatch(cp=nv_name(np),pattern))
+ {
+ ap = (struct argnod*)stakseek(ARGVAL);
+ stakputs(cp);
+ ap = (struct argnod*)stakfreeze(1);
+ ap->argbegin = NIL(char*);
+ ap->argchn.ap = *arghead;
+ ap->argflag = ARG_RAW|ARG_MAKE;
+ *arghead = ap;
+ nmatch++;
+ }
+ }
+ return(nmatch);
+}
+
+/*
+ * file name completion
+ * generate the list of files found by adding an suffix to end of name
+ * The number of matches is returned
+ */
+
+int path_complete(const char *name,register const char *suffix, struct argnod **arghead)
+{
+ sufstr = suffix;
+ suflen = strlen(suffix);
+ return(path_expand(name,arghead));
+}
+
+#endif
+
+#if SHOPT_BRACEPAT
+
+static int checkfmt(Sfio_t* sp, void* vp, Sffmt_t* fp)
+{
+ return -1;
+}
+
+int path_generate(struct argnod *todo, struct argnod **arghead)
+/*@
+ assume todo!=0;
+ return count satisfying count>=1;
+@*/
+{
+ register char *cp;
+ register int brace;
+ register struct argnod *ap;
+ struct argnod *top = 0;
+ struct argnod *apin;
+ char *pat, *rescan;
+ char *format;
+ char comma, range=0;
+ int first, last, incr, count = 0;
+ char tmp[32], end[1];
+ todo->argchn.ap = 0;
+again:
+ apin = ap = todo;
+ todo = ap->argchn.ap;
+ cp = ap->argval;
+ range = comma = brace = 0;
+ /* first search for {...,...} */
+ while(1) switch(*cp++)
+ {
+ case '{':
+ if(brace++==0)
+ pat = cp;
+ break;
+ case '}':
+ if(--brace>0)
+ break;
+ if(brace==0 && comma && *cp!='(')
+ goto endloop1;
+ comma = brace = 0;
+ break;
+ case '.':
+ if(brace==1 && *cp=='.')
+ {
+ char *endc;
+ incr = 1;
+ if(isdigit(*pat) || *pat=='+' || *pat=='-')
+ {
+ first = strtol(pat,&endc,0);
+ if(endc==(cp-1))
+ {
+ last = strtol(cp+1,&endc,0);
+ if(*endc=='.' && endc[1]=='.')
+ incr = strtol(endc+2,&endc,0);
+ else if(last<first)
+ incr = -1;
+ if(incr)
+ {
+ if(*endc=='%')
+ {
+ Sffmt_t fmt;
+ memset(&fmt, 0, sizeof(fmt));
+ fmt.version = SFIO_VERSION;
+ fmt.form = endc;
+ fmt.extf = checkfmt;
+ sfprintf(sfstdout, "%!", &fmt);
+ if(!(fmt.flags&(SFFMT_LLONG|SFFMT_LDOUBLE)))
+ switch (fmt.fmt)
+ {
+ case 'c':
+ case 'd':
+ case 'i':
+ case 'o':
+ case 'u':
+ case 'x':
+ case 'X':
+ format = endc;
+ endc = fmt.form;
+ break;
+ }
+ }
+ else
+ format = "%d";
+ if(*endc=='}')
+ {
+ cp = endc+1;
+ range = 2;
+ goto endloop1;
+ }
+ }
+ }
+ }
+ else if((cp[2]=='}' || cp[2]=='.' && cp[3]=='.') && ((*pat>='a' && *pat<='z' && cp[1]>='a' && cp[1]<='z') || (*pat>='A' && *pat<='Z' && cp[1]>='A' && cp[1]<='Z')))
+ {
+ first = *pat;
+ last = cp[1];
+ cp += 2;
+ if(*cp=='.')
+ {
+ incr = strtol(cp+2,&endc,0);
+ cp = endc;
+ }
+ else if(first>last)
+ incr = -1;
+ if(incr && *cp=='}')
+ {
+ cp++;
+ range = 1;
+ goto endloop1;
+ }
+ }
+ cp++;
+ }
+ break;
+ case ',':
+ if(brace==1)
+ comma = 1;
+ break;
+ case '\\':
+ cp++;
+ break;
+ case 0:
+ /* insert on stack */
+ ap->argchn.ap = top;
+ top = ap;
+ if(todo)
+ goto again;
+ for(; ap; ap=apin)
+ {
+ apin = ap->argchn.ap;
+ if(!sh_isoption(SH_NOGLOB))
+ brace=path_expand(ap->argval,arghead);
+ else
+ {
+ ap->argchn.ap = *arghead;
+ *arghead = ap;
+ brace=1;
+ }
+ if(brace)
+ {
+ count += brace;
+ (*arghead)->argflag |= ARG_MAKE;
+ }
+ }
+ return(count);
+ }
+endloop1:
+ rescan = cp;
+ cp = pat-1;
+ *cp = 0;
+ while(1)
+ {
+ brace = 0;
+ if(range)
+ {
+ if(range==1)
+ {
+ pat[0] = first;
+ cp = &pat[1];
+ }
+ else
+ {
+ *(rescan - 1) = 0;
+ sfsprintf(pat=tmp,sizeof(tmp),format,first);
+ *(rescan - 1) = '}';
+ *(cp = end) = 0;
+ }
+ if(incr*(first+incr) > last*incr)
+ *cp = '}';
+ else
+ first += incr;
+ }
+ /* generate each pattern and put on the todo list */
+ else while(1) switch(*++cp)
+ {
+ case '\\':
+ cp++;
+ break;
+ case '{':
+ brace++;
+ break;
+ case ',':
+ if(brace==0)
+ goto endloop2;
+ break;
+ case '}':
+ if(--brace<0)
+ goto endloop2;
+ }
+ endloop2:
+ brace = *cp;
+ *cp = 0;
+ sh_sigcheck();
+ ap = (struct argnod*)stakseek(ARGVAL);
+ ap->argflag = ARG_RAW;
+ ap->argchn.ap = todo;
+ stakputs(apin->argval);
+ stakputs(pat);
+ stakputs(rescan);
+ todo = ap = (struct argnod*)stakfreeze(1);
+ if(brace == '}')
+ break;
+ if(!range)
+ pat = cp+1;
+ }
+ goto again;
+}
+
+#endif /* SHOPT_BRACEPAT */
diff --git a/usr/src/lib/libshell/common/sh/fault.c b/usr/src/lib/libshell/common/sh/fault.c
new file mode 100644
index 0000000000..2d71736187
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/fault.c
@@ -0,0 +1,573 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Fault handling routines
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#include "defs.h"
+#include <fcin.h>
+#include "io.h"
+#include "history.h"
+#include "shnodes.h"
+#include "variables.h"
+#include "jobs.h"
+#include "path.h"
+
+#define abortsig(sig) (sig==SIGABRT || sig==SIGBUS || sig==SIGILL || sig==SIGSEGV)
+
+static char indone;
+
+#if !_std_malloc
+# include <vmalloc.h>
+#endif
+#if defined(VMFL) && (VMALLOC_VERSION>=20031205L)
+ /*
+ * This exception handler is called after vmalloc() unlocks the region
+ */
+ static int malloc_done(Vmalloc_t* vm, int type, Void_t* val, Vmdisc_t* dp)
+ {
+ dp->exceptf = 0;
+ sh_exit(SH_EXITSIG);
+ return(0);
+ }
+#endif
+
+/*
+ * Most signals caught or ignored by the shell come here
+*/
+void sh_fault(register int sig)
+{
+ register int flag=0;
+ register char *trap;
+ register struct checkpt *pp = (struct checkpt*)sh.jmplist;
+ int action=0;
+ /* reset handler */
+ if(!(sig&SH_TRAP))
+ signal(sig, sh_fault);
+ sig &= ~SH_TRAP;
+#ifdef SIGWINCH
+ if(sig==SIGWINCH)
+ {
+ int rows=0, cols=0;
+ int32_t v;
+ astwinsize(2,&rows,&cols);
+ if(v = cols)
+ nv_putval(COLUMNS, (char*)&v, NV_INT32);
+ if(v = rows)
+ nv_putval(LINES, (char*)&v, NV_INT32);
+ }
+#endif /* SIGWINCH */
+ if(sh.savesig)
+ {
+ /* critical region, save and process later */
+ sh.savesig = sig;
+ return;
+ }
+
+ /* handle ignored signals */
+ if((trap=sh.st.trapcom[sig]) && *trap==0)
+ return;
+ flag = sh.sigflag[sig]&~SH_SIGOFF;
+ if(!trap)
+ {
+ if(flag&SH_SIGIGNORE)
+ return;
+ if(flag&SH_SIGDONE)
+ {
+ void *ptr=0;
+ if((flag&SH_SIGINTERACTIVE) && sh_isstate(SH_INTERACTIVE) && !sh_isstate(SH_FORKED) && ! sh.subshell)
+ {
+ /* check for TERM signal between fork/exec */
+ if(sig==SIGTERM && job.in_critical)
+ sh.trapnote |= SH_SIGTERM;
+ return;
+ }
+ sh.lastsig = sig;
+ sigrelease(sig);
+ if(pp->mode < SH_JMPFUN)
+ pp->mode = SH_JMPFUN;
+ else
+ pp->mode = SH_JMPEXIT;
+ if(sig==SIGABRT || (abortsig(sig) && (ptr = malloc(1))))
+ {
+ if(ptr)
+ free(ptr);
+ if(!sh.subshell)
+ sh_done(sig);
+ sh_exit(SH_EXITSIG);
+ }
+ /* mark signal and continue */
+ sh.trapnote |= SH_SIGSET;
+ if(sig < sh.sigmax)
+ sh.sigflag[sig] |= SH_SIGSET;
+#if defined(VMFL) && (VMALLOC_VERSION>=20031205L)
+ if(abortsig(sig))
+ {
+ /* abort inside malloc, process when malloc returns */
+ /* VMFL defined when using vmalloc() */
+ Vmdisc_t* dp = vmdisc(Vmregion,0);
+ if(dp)
+ dp->exceptf = malloc_done;
+ }
+#endif
+ return;
+ }
+ }
+ errno = 0;
+ if(pp->mode==SH_JMPCMD)
+ sh.lastsig = sig;
+ if(trap)
+ {
+ /*
+ * propogate signal to foreground group
+ */
+ if(sig==SIGHUP && job.curpgid)
+ killpg(job.curpgid,SIGHUP);
+ flag = SH_SIGTRAP;
+ }
+ else
+ {
+ sh.lastsig = sig;
+ flag = SH_SIGSET;
+#ifdef SIGTSTP
+ if(sig==SIGTSTP)
+ {
+ sh.trapnote |= SH_SIGTSTP;
+ if(pp->mode==SH_JMPCMD && sh_isstate(SH_STOPOK))
+ {
+ sigrelease(sig);
+ sh_exit(SH_EXITSIG);
+ flag = 0;
+ }
+ }
+#endif /* SIGTSTP */
+ }
+#ifdef ERROR_NOTIFY
+ if((error_info.flags&ERROR_NOTIFY) && sh.bltinfun)
+ action = (*sh.bltinfun)(-sig,(char**)0,(void*)0);
+#endif
+ if(action>0)
+ return;
+ sh.trapnote |= flag;
+ if(sig < sh.sigmax)
+ sh.sigflag[sig] |= flag;
+ if(pp->mode==SH_JMPCMD && sh_isstate(SH_STOPOK))
+ {
+ if(action<0)
+ return;
+ sigrelease(sig);
+ sh_exit(SH_EXITSIG);
+ }
+}
+
+/*
+ * initialize signal handling
+ */
+void sh_siginit(void)
+{
+ register int sig, n=SIGTERM+1;
+ register const struct shtable2 *tp = shtab_signals;
+ sig_begin();
+ /* find the largest signal number in the table */
+ while(*tp->sh_name)
+ {
+ if((sig=tp->sh_number&((1<<SH_SIGBITS)-1))>n && sig<SH_TRAP)
+ n = sig;
+ tp++;
+ }
+#if defined(_SC_SIGRT_MAX) && defined(_SIGRTMAX)
+ if((sig=SIGRTMAX+1)>n && sig<SH_TRAP)
+ n = sig;
+#endif
+ sh.sigmax = n;
+ sh.st.trapcom = (char**)calloc(n,sizeof(char*));
+ sh.sigflag = (unsigned char*)calloc(n,1);
+ sh.sigmsg = (char**)calloc(n,sizeof(char*));
+ for(tp=shtab_signals; sig=tp->sh_number; tp++)
+ {
+ n = (sig>>SH_SIGBITS);
+ if((sig &= ((1<<SH_SIGBITS)-1)) > sh.sigmax)
+ continue;
+ sig--;
+#if defined(_SC_SIGRT_MIN) && defined(_SIGRTMIN)
+ if(sig==_SIGRTMIN)
+ sig = SIGRTMIN;
+#endif
+#if defined(_SC_SIGRT_MAX) && defined(_SIGRTMAX)
+ if(sig==_SIGRTMAX)
+ sig = SIGRTMAX;
+#endif
+ if(sig>=0)
+ {
+ sh.sigflag[sig] = n;
+ if(*tp->sh_name)
+ sh.sigmsg[sig] = (char*)tp->sh_value;
+ }
+ }
+}
+
+/*
+ * Turn on trap handler for signal <sig>
+ */
+void sh_sigtrap(register int sig)
+{
+ register int flag;
+ void (*fun)(int);
+ sh.st.otrapcom = 0;
+ if(sig==0)
+ sh_sigdone();
+ else if(!((flag=sh.sigflag[sig])&(SH_SIGFAULT|SH_SIGOFF)))
+ {
+ /* don't set signal if already set or off by parent */
+ if((fun=signal(sig,sh_fault))==SIG_IGN)
+ {
+ signal(sig,SIG_IGN);
+ flag |= SH_SIGOFF;
+ }
+ else
+ {
+ flag |= SH_SIGFAULT;
+ if(sig==SIGALRM && fun!=SIG_DFL && fun!=sh_fault)
+ signal(sig,fun);
+ }
+ flag &= ~(SH_SIGSET|SH_SIGTRAP);
+ sh.sigflag[sig] = flag;
+ }
+}
+
+/*
+ * set signal handler so sh_done is called for all caught signals
+ */
+void sh_sigdone(void)
+{
+ register int flag, sig = sh.sigmax;
+ sh.sigflag[0] |= SH_SIGFAULT;
+ while(--sig>0)
+ {
+ flag = sh.sigflag[sig];
+ if((flag&(SH_SIGDONE|SH_SIGIGNORE|SH_SIGINTERACTIVE)) && !(flag&(SH_SIGFAULT|SH_SIGOFF)))
+ sh_sigtrap(sig);
+ }
+}
+
+/*
+ * Restore to default signals
+ * Free the trap strings if mode is non-zero
+ * If mode>1 then ignored traps cause signal to be ignored
+ */
+void sh_sigreset(register int mode)
+{
+ register char *trap;
+ register int flag, sig=sh.st.trapmax;
+ while(sig-- > 0)
+ {
+ if(trap=sh.st.trapcom[sig])
+ {
+ flag = sh.sigflag[sig]&~(SH_SIGTRAP|SH_SIGSET);
+ if(*trap)
+ {
+ if(mode)
+ free(trap);
+ sh.st.trapcom[sig] = 0;
+ }
+ else if(sig && mode>1)
+ {
+ signal(sig,SIG_IGN);
+ flag &= ~SH_SIGFAULT;
+ flag |= SH_SIGOFF;
+ }
+ sh.sigflag[sig] = flag;
+ }
+ }
+ for(sig=SH_DEBUGTRAP;sig>=0;sig--)
+ {
+ if(trap=sh.st.trap[sig])
+ {
+ if(mode)
+ free(trap);
+ sh.st.trap[sig] = 0;
+ }
+
+ }
+ sh.st.trapcom[0] = 0;
+ if(mode)
+ sh.st.trapmax = 0;
+ sh.trapnote=0;
+}
+
+/*
+ * free up trap if set and restore signal handler if modified
+ */
+void sh_sigclear(register int sig)
+{
+ register int flag = sh.sigflag[sig];
+ register char *trap;
+ sh.st.otrapcom=0;
+ if(!(flag&SH_SIGFAULT))
+ return;
+ flag &= ~(SH_SIGTRAP|SH_SIGSET);
+ if(trap=sh.st.trapcom[sig])
+ {
+ free(trap);
+ sh.st.trapcom[sig]=0;
+ }
+ sh.sigflag[sig] = flag;
+}
+
+/*
+ * check for traps
+ */
+
+void sh_chktrap(void)
+{
+ register int sig=sh.st.trapmax;
+ register char *trap;
+ if(!sh.trapnote)
+ sig=0;
+ sh.trapnote &= ~SH_SIGTRAP;
+ /* execute errexit trap first */
+ if(sh_isstate(SH_ERREXIT) && sh.exitval)
+ {
+ int sav_trapnote = sh.trapnote;
+ sh.trapnote &= ~SH_SIGSET;
+ if(sh.st.trap[SH_ERRTRAP])
+ sh_trap(sh.st.trap[SH_ERRTRAP],0);
+ sh.trapnote = sav_trapnote;
+ if(sh_isoption(SH_ERREXIT))
+ {
+ struct checkpt *pp = (struct checkpt*)sh.jmplist;
+ pp->mode = SH_JMPEXIT;
+ sh_exit(sh.exitval);
+ }
+ }
+ if(sh.sigflag[SIGALRM]&SH_SIGALRM)
+ sh_timetraps();
+ while(--sig>=0)
+ {
+ if(sh.sigflag[sig]&SH_SIGTRAP)
+ {
+ sh.sigflag[sig] &= ~SH_SIGTRAP;
+ if(trap=sh.st.trapcom[sig])
+ sh_trap(trap,0);
+ }
+ }
+}
+
+
+/*
+ * parse and execute the given trap string, stream or tree depending on mode
+ * mode==0 for string, mode==1 for stream, mode==2 for parse tree
+ */
+int sh_trap(const char *trap, int mode)
+{
+ int jmpval, savxit = sh.exitval;
+ int was_history = sh_isstate(SH_HISTORY);
+ int was_verbose = sh_isstate(SH_VERBOSE);
+ int staktop = staktell();
+ char *savptr = stakfreeze(0);
+ struct checkpt buff;
+ Fcin_t savefc;
+ fcsave(&savefc);
+ sh_offstate(SH_HISTORY);
+ sh_offstate(SH_VERBOSE);
+ sh.intrap++;
+ sh_pushcontext(&buff,SH_JMPTRAP);
+ jmpval = sigsetjmp(buff.buff,0);
+ if(jmpval == 0)
+ {
+ if(mode==2)
+ sh_exec((Shnode_t*)trap,sh_isstate(SH_ERREXIT));
+ else
+ {
+ Sfio_t *sp;
+ if(mode)
+ sp = (Sfio_t*)trap;
+ else
+ sp = sfopen(NIL(Sfio_t*),trap,"s");
+ sh_eval(sp,0);
+ }
+ }
+ else if(indone)
+ {
+ if(jmpval==SH_JMPSCRIPT)
+ indone=0;
+ else
+ {
+ if(jmpval==SH_JMPEXIT)
+ savxit = sh.exitval;
+ jmpval=SH_JMPTRAP;
+ }
+ }
+ sh_popcontext(&buff);
+ sh.intrap--;
+ sfsync(sh.outpool);
+ if(jmpval!=SH_JMPEXIT && jmpval!=SH_JMPFUN)
+ sh.exitval=savxit;
+ stakset(savptr,staktop);
+ fcrestore(&savefc);
+ if(was_history)
+ sh_onstate(SH_HISTORY);
+ if(was_verbose)
+ sh_onstate(SH_VERBOSE);
+ exitset();
+ if(jmpval>SH_JMPTRAP)
+ siglongjmp(*sh.jmplist,jmpval);
+ return(sh.exitval);
+}
+
+/*
+ * exit the current scope and jump to an earlier one based on pp->mode
+ */
+void sh_exit(register int xno)
+{
+ register struct checkpt *pp = (struct checkpt*)sh.jmplist;
+ register int sig=0;
+ register Sfio_t* pool;
+ sh.exitval=xno;
+ if(xno==SH_EXITSIG)
+ sh.exitval |= (sig=sh.lastsig);
+#ifdef SIGTSTP
+ if(sh.trapnote&SH_SIGTSTP)
+ {
+ /* ^Z detected by the shell */
+ sh.trapnote = 0;
+ sh.sigflag[SIGTSTP] = 0;
+ if(!sh.subshell && sh_isstate(SH_MONITOR) && !sh_isstate(SH_STOPOK))
+ return;
+ if(sh_isstate(SH_TIMING))
+ return;
+ /* Handles ^Z for shell builtins, subshells, and functs */
+ sh.lastsig = 0;
+ sh_onstate(SH_MONITOR);
+ sh_offstate(SH_STOPOK);
+ sh.trapnote = 0;
+ if(!sh.subshell && (sig=sh_fork(0,NIL(int*))))
+ {
+ job.curpgid = 0;
+ job.parent = (pid_t)-1;
+ job_wait(sig);
+ job.parent = 0;
+ sh.sigflag[SIGTSTP] = 0;
+ /* wait for child to stop */
+ sh.exitval = (SH_EXITSIG|SIGTSTP);
+ /* return to prompt mode */
+ pp->mode = SH_JMPERREXIT;
+ }
+ else
+ {
+ if(sh.subshell)
+ sh_subfork();
+ /* child process, put to sleep */
+ sh_offstate(SH_STOPOK);
+ sh_offstate(SH_MONITOR);
+ sh.sigflag[SIGTSTP] = 0;
+ /* stop child job */
+ killpg(job.curpgid,SIGTSTP);
+ /* child resumes */
+ job_clear();
+ sh.forked = 1;
+ sh.exitval = (xno&SH_EXITMASK);
+ return;
+ }
+ }
+#endif /* SIGTSTP */
+ /* unlock output pool */
+ sh_offstate(SH_NOTRACK);
+ if(!(pool=sfpool(NIL(Sfio_t*),sh.outpool,SF_WRITE)))
+ pool = sh.outpool; /* can't happen? */
+ sfclrlock(pool);
+#ifdef SIGPIPE
+ if(sh.lastsig==SIGPIPE)
+ sfpurge(pool);
+#endif /* SIGPIPE */
+ sfclrlock(sfstdin);
+ if(!pp)
+ sh_done(sig);
+ sh.prefix = 0;
+ if(pp->mode == SH_JMPSCRIPT && !pp->prev)
+ sh_done(sig);
+ siglongjmp(pp->buff,pp->mode);
+}
+
+/*
+ * This is the exit routine for the shell
+ */
+
+void sh_done(register int sig)
+{
+ register char *t;
+ register int savxit = sh.exitval;
+ sh.trapnote = 0;
+ indone=1;
+ if(sig==0)
+ sig = sh.lastsig;
+ if(sh.userinit)
+ (*sh.userinit)(-1);
+ if(t=sh.st.trapcom[0])
+ {
+ sh.st.trapcom[0]=0; /*should free but not long */
+ sh.oldexit = savxit;
+ sh_trap(t,0);
+ savxit = sh.exitval;
+ }
+ else
+ {
+ /* avoid recursive call for set -e */
+ sh_offstate(SH_ERREXIT);
+ sh_chktrap();
+ }
+ sh_freeup();
+#if SHOPT_ACCT
+ sh_accend();
+#endif /* SHOPT_ACCT */
+#if SHOPT_VSH || SHOPT_ESH
+ if(sh_isoption(SH_EMACS)||sh_isoption(SH_VI)||sh_isoption(SH_GMACS))
+ tty_cooked(-1);
+#endif
+#ifdef JOBS
+ if((sh_isoption(SH_INTERACTIVE) && sh.login_sh) || (!sh_isoption(SH_INTERACTIVE) && (sig==SIGHUP)))
+ job_walk(sfstderr,job_terminate,SIGHUP,NIL(char**));
+#endif /* JOBS */
+ job_close();
+ if(nv_search("VMTRACE", sh.var_tree,0))
+ strmatch((char*)0,(char*)0);
+ sfsync((Sfio_t*)sfstdin);
+ sfsync((Sfio_t*)sh.outpool);
+ sfsync((Sfio_t*)sfstdout);
+ if(sig)
+ {
+ /* generate fault termination code */
+ signal(sig,SIG_DFL);
+ sigrelease(sig);
+ kill(getpid(),sig);
+ pause();
+ }
+#if SHOPT_KIA
+ if(sh_isoption(SH_NOEXEC))
+ kiaclose();
+#endif /* SHOPT_KIA */
+ exit(savxit&SH_EXITMASK);
+}
+
diff --git a/usr/src/lib/libshell/common/sh/fcin.c b/usr/src/lib/libshell/common/sh/fcin.c
new file mode 100644
index 0000000000..aea98364f5
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/fcin.c
@@ -0,0 +1,211 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Routines to implement fast character input
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#include <ast.h>
+#include <sfio.h>
+#include <error.h>
+#include <fcin.h>
+
+Fcin_t _Fcin = {0};
+
+/*
+ * open stream <f> for fast character input
+ */
+int fcfopen(register Sfio_t* f)
+{
+ register int n;
+ char *buff;
+ Fcin_t save;
+ errno = 0;
+ _Fcin.fcbuff = _Fcin.fcptr;
+ _Fcin._fcfile = f;
+ fcsave(&save);
+ if(!(buff=(char*)sfreserve(f,SF_UNBOUND,SF_LOCKR)))
+ {
+ fcrestore(&save);
+ _Fcin.fcchar = 0;
+ _Fcin.fcptr = _Fcin.fcbuff = &_Fcin.fcchar;
+ _Fcin.fclast = 0;
+ _Fcin._fcfile = (Sfio_t*)0;
+ return(EOF);
+ }
+ n = sfvalue(f);
+ fcrestore(&save);
+ sfread(f,buff,0);
+ _Fcin.fcoff = sftell(f);;
+ buff = (char*)sfreserve(f,SF_UNBOUND,SF_LOCKR);
+ _Fcin.fclast = (_Fcin.fcptr=_Fcin.fcbuff=(unsigned char*)buff)+n;
+ if(sffileno(f) >= 0)
+ *_Fcin.fclast = 0;
+ return(n);
+}
+
+
+/*
+ * With _Fcin.fcptr>_Fcin.fcbuff, the stream pointer is advanced and
+ * If _Fcin.fclast!=0, performs an sfreserve() for the next buffer.
+ * If a notify function has been set, it is called
+ * If last is non-zero, and the stream is a file, 0 is returned when
+ * the previous character is a 0 byte.
+ */
+int fcfill(void)
+{
+ register int n;
+ register Sfio_t *f;
+ register unsigned char *last=_Fcin.fclast, *ptr=_Fcin.fcptr;
+ if(!(f=fcfile()))
+ {
+ /* see whether pointer has passed null byte */
+ if(ptr>_Fcin.fcbuff && *--ptr==0)
+ _Fcin.fcptr=ptr;
+ else
+ _Fcin.fcoff = 0;
+ return(0);
+ }
+ if(last)
+ {
+ if( ptr<last && ptr>_Fcin.fcbuff && *(ptr-1)==0)
+ return(0);
+ if(_Fcin.fcchar)
+ *last = _Fcin.fcchar;
+ if(ptr > last)
+ _Fcin.fcptr = ptr = last;
+ }
+ if((n = ptr-_Fcin.fcbuff) && _Fcin.fcfun)
+ (*_Fcin.fcfun)(f,(const char*)_Fcin.fcbuff,n);
+ sfread(f, (char*)_Fcin.fcbuff, n);
+ _Fcin.fcoff +=n;
+ _Fcin._fcfile = 0;
+ if(!last)
+ return(0);
+ else if(fcfopen(f) < 0)
+ return(EOF);
+ return(*_Fcin.fcptr++);
+}
+
+/*
+ * Synchronize and close the current stream
+ */
+int fcclose(void)
+{
+ register unsigned char *ptr;
+ if(_Fcin.fclast==0)
+ return(0);
+ if((ptr=_Fcin.fcptr)>_Fcin.fcbuff && *(ptr-1)==0)
+ _Fcin.fcptr--;
+ if(_Fcin.fcchar)
+ *_Fcin.fclast = _Fcin.fcchar;
+ _Fcin.fclast = 0;
+ _Fcin.fcleft = 0;
+ return(fcfill());
+}
+
+/*
+ * Set the notify function that is called for each fcfill()
+ */
+void fcnotify(void (*fun)(Sfio_t*,const char*,int))
+{
+ _Fcin.fcfun = fun;
+}
+
+#ifdef __EXPORT__
+# define extern __EXPORT__
+#endif
+
+#undef fcsave
+extern void fcsave(Fcin_t *fp)
+{
+ *fp = _Fcin;
+}
+
+#undef fcrestore
+extern void fcrestore(Fcin_t *fp)
+{
+ _Fcin = *fp;
+}
+
+struct Extra
+{
+ unsigned char buff[2*MB_LEN_MAX];
+ unsigned char *next;
+};
+
+int fcmbstate(const char *state, int *s, int *len)
+{
+ static struct Extra extra;
+ register int i, c, n;
+ if(_Fcin.fcleft)
+ {
+ if((c = mbsize(extra.next)) < 0)
+ c = 1;
+ if((_Fcin.fcleft -= c) <=0)
+ {
+ _Fcin.fcptr = (unsigned char*)fcfirst() - _Fcin.fcleft;
+ _Fcin.fcleft = 0;
+ }
+ *len = c;
+ if(c==1)
+ *s = state[*extra.next++];
+ else if(c==0)
+ _Fcin.fcleft = 0;
+ else
+ {
+ c = mbchar(extra.next);
+ *s = state['a'];
+ }
+ return(c);
+ }
+ switch(*len = mbsize(_Fcin.fcptr))
+ {
+ case -1:
+ if(_Fcin._fcfile && (n=(_Fcin.fclast-_Fcin.fcptr)) < MB_LEN_MAX)
+ {
+ memcmp(extra.buff, _Fcin.fcptr, n);
+ _Fcin.fcptr = _Fcin.fclast;
+ for(i=n; i < MB_LEN_MAX+n; i++)
+ {
+ if((extra.buff[i] = fcgetc(c))==0)
+ break;
+ }
+ _Fcin.fcleft = n;
+ extra.next = extra.buff;
+ return(fcmbstate(state,s,len));
+ }
+ *len = 1;
+ /* fall through */
+ case 0:
+ case 1:
+ *s = state[c=fcget()];
+ break;
+ default:
+ c = mbchar(_Fcin.fcptr);
+ *s = state['a'];
+ }
+ return(c);
+}
+
diff --git a/usr/src/lib/libshell/common/sh/init.c b/usr/src/lib/libshell/common/sh/init.c
new file mode 100644
index 0000000000..fbb6e5c6bc
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/init.c
@@ -0,0 +1,1465 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ *
+ * Shell initialization
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#include "defs.h"
+#include <stak.h>
+#include <ctype.h>
+#include <ccode.h>
+#include <pwd.h>
+#include "variables.h"
+#include "path.h"
+#include "fault.h"
+#include "name.h"
+#include "edit.h"
+#include "jobs.h"
+#include "io.h"
+#include "shlex.h"
+#include "builtins.h"
+#include "FEATURE/time"
+#include "FEATURE/dynamic"
+#include "lexstates.h"
+#include "version.h"
+
+#if SHOPT_MULTIBYTE
+ char e_version[] = "\n@(#)$Id: Version M "SH_RELEASE" $\0\n";
+#else
+ char e_version[] = "\n@(#)$Id: Version "SH_RELEASE" $\0\n";
+#endif /* SHOPT_MULTIBYTE */
+
+#if SHOPT_BASH
+ extern void bash_init(int);
+#endif
+
+#define RANDMASK 0x7fff
+#ifndef CLK_TCK
+# define CLK_TCK 60
+#endif /* CLK_TCK */
+
+#ifndef environ
+ extern char **environ;
+#endif
+
+#undef getconf
+#define getconf(x) strtol(astconf(x,NiL,NiL),NiL,0)
+
+struct seconds
+{
+ Namfun_t hdr;
+ Shell_t *sh;
+};
+
+struct rand
+{
+ Namfun_t hdr;
+ Shell_t *sh;
+ int32_t rand_last;
+};
+
+struct ifs
+{
+ Namfun_t hdr;
+ Shell_t *sh;
+ Namval_t *ifsnp;
+};
+
+struct shell
+{
+ Namfun_t hdr;
+ Shell_t *sh;
+};
+
+struct match
+{
+ Namfun_t hdr;
+ char *val;
+ char *rval;
+ int vsize;
+ int nmatch;
+ int lastsub;
+ int match[2*(MATCH_MAX+1)];
+};
+
+typedef struct _init_
+{
+ Shell_t *sh;
+#if SHOPT_FS_3D
+ Namfun_t VPATH_init;
+#endif /* SHOPT_FS_3D */
+ struct ifs IFS_init;
+ struct shell PATH_init;
+#ifdef PATH_BFPATH
+ struct shell FPATH_init;
+ struct shell CDPATH_init;
+#endif
+ struct shell SHELL_init;
+ struct shell ENV_init;
+ struct shell VISUAL_init;
+ struct shell EDITOR_init;
+ struct shell OPTINDEX_init;
+ struct seconds SECONDS_init;
+ struct rand RAND_init;
+ struct shell LINENO_init;
+ struct shell L_ARG_init;
+ struct match SH_MATCH_init;
+#ifdef _hdr_locale
+ struct shell LC_TYPE_init;
+ struct shell LC_NUM_init;
+ struct shell LC_COLL_init;
+ struct shell LC_MSG_init;
+ struct shell LC_ALL_init;
+ struct shell LANG_init;
+#endif /* _hdr_locale */
+} Init_t;
+
+static void env_init(Shell_t*);
+static Init_t *nv_init(Shell_t*);
+static Dt_t *inittree(Shell_t*,const struct shtable2*);
+
+#ifdef _WINIX
+# define EXE "?(.exe)"
+#else
+# define EXE
+#endif
+
+static int rand_shift;
+
+
+/*
+ * Invalidate all path name bindings
+ */
+static void rehash(register Namval_t *np,void *data)
+{
+ NOT_USED(data);
+ nv_onattr(np,NV_NOALIAS);
+}
+
+/*
+ * out of memory routine for stak routines
+ */
+static char *nospace(int unused)
+{
+ NOT_USED(unused);
+ errormsg(SH_DICT,ERROR_exit(3),e_nospace);
+ return(NIL(char*));
+}
+
+/* Trap for VISUAL and EDITOR variables */
+static void put_ed(register Namval_t* np,const char *val,int flags,Namfun_t *fp)
+{
+ register const char *cp, *name=nv_name(np);
+ if(*name=='E' && nv_getval(nv_scoped(VISINOD)))
+ goto done;
+ sh_offoption(SH_VI);
+ sh_offoption(SH_EMACS);
+ sh_offoption(SH_GMACS);
+ if(!(cp=val) && (*name=='E' || !(cp=nv_getval(nv_scoped(EDITNOD)))))
+ goto done;
+ /* turn on vi or emacs option if editor name is either*/
+ cp = path_basename(cp);
+ if(strmatch(cp,"*[Vv][Ii]*"))
+ sh_onoption(SH_VI);
+ else if(strmatch(cp,"*gmacs*"))
+ sh_onoption(SH_GMACS);
+ else if(strmatch(cp,"*macs*"))
+ sh_onoption(SH_EMACS);
+done:
+ nv_putv(np, val, flags, fp);
+}
+
+/* Trap for OPTINDEX */
+static void put_optindex(Namval_t* np,const char *val,int flags,Namfun_t *fp)
+{
+ Shell_t *shp = ((struct shell*)fp)->sh;
+ shp->st.opterror = shp->st.optchar = 0;
+ nv_putv(np, val, flags, fp);
+}
+
+static Sfdouble_t nget_optindex(register Namval_t* np, Namfun_t *fp)
+{
+ return((Sfdouble_t)*np->nvalue.lp);
+}
+
+/* Trap for restricted variables FPATH, PATH, SHELL, ENV */
+static void put_restricted(register Namval_t* np,const char *val,int flags,Namfun_t *fp)
+{
+ Shell_t *shp = ((struct shell*)fp)->sh;
+ int path_scoped = 0;
+#ifdef PATH_BFPATH
+ Pathcomp_t *pp;
+ char *name = nv_name(np);
+#endif
+ if(!(flags&NV_RDONLY) && sh_isoption(SH_RESTRICTED))
+ errormsg(SH_DICT,ERROR_exit(1),e_restricted,nv_name(np));
+ if(np==PATHNOD || (path_scoped=(strcmp(name,PATHNOD->nvname)==0)))
+ {
+#ifndef PATH_BFPATH
+ shp->lastpath = 0;
+#endif
+ nv_scan(shp->track_tree,rehash,(void*)0,NV_TAGGED,NV_TAGGED);
+ if(path_scoped && !val)
+ val = PATHNOD->nvalue.cp;
+ }
+ if(val && !(flags&NV_RDONLY) && np->nvalue.cp && strcmp(val,np->nvalue.cp)==0)
+ return;
+#ifdef PATH_BFPATH
+ if(shp->pathlist && np==FPATHNOD)
+ shp->pathlist = (void*)path_unsetfpath((Pathcomp_t*)shp->pathlist);
+#endif
+ nv_putv(np, val, flags, fp);
+#ifdef PATH_BFPATH
+ if(shp->pathlist)
+ {
+ val = np->nvalue.cp;
+ if(np==PATHNOD || path_scoped)
+ pp = (void*)path_addpath((Pathcomp_t*)shp->pathlist,val,PATH_PATH);
+ else if(val && np==FPATHNOD)
+ pp = (void*)path_addpath((Pathcomp_t*)shp->pathlist,val,PATH_FPATH);
+ else
+ return;
+ if(shp->pathlist = (void*)pp)
+ pp->shp = shp;
+ if(!val && (flags&NV_NOSCOPE))
+ {
+ Namval_t *mp = dtsearch(shp->var_tree,np);
+ if(mp && (val=nv_getval(mp)))
+ nv_putval(mp,val,NV_RDONLY);
+ }
+#if 0
+sfprintf(sfstderr,"%d: name=%s val=%s\n",getpid(),name,val);
+path_dump((Pathcomp_t*)shp->pathlist);
+#endif
+ }
+#endif
+}
+
+#ifdef PATH_BFPATH
+static void put_cdpath(register Namval_t* np,const char *val,int flags,Namfun_t *fp)
+{
+ Pathcomp_t *pp;
+ Shell_t *shp = ((struct shell*)fp)->sh;
+ nv_putv(np, val, flags, fp);
+ if(!shp->cdpathlist)
+ return;
+ val = np->nvalue.cp;
+ pp = (void*)path_addpath((Pathcomp_t*)shp->cdpathlist,val,PATH_CDPATH);
+ if(shp->cdpathlist = (void*)pp)
+ pp->shp = shp;
+}
+#endif
+
+#ifdef _hdr_locale
+ /*
+ * This function needs to be modified to handle international
+ * error message translations
+ */
+#if ERROR_VERSION >= 20000101L
+ static char* msg_translate(const char* catalog, const char* message)
+ {
+ NOT_USED(catalog);
+ return((char*)message);
+ }
+#else
+ static char* msg_translate(const char* message, int type)
+ {
+ NOT_USED(type);
+ return((char*)message);
+ }
+#endif
+
+ /* Trap for LC_ALL, LC_TYPE, LC_MESSAGES, LC_COLLATE and LANG */
+ static void put_lang(Namval_t* np,const char *val,int flags,Namfun_t *fp)
+ {
+ int type;
+ char *lc_all = nv_getval(LCALLNOD);
+ char *name = nv_name(np);
+ if(name==(LCALLNOD)->nvname)
+ type = LC_ALL;
+ else if(name==(LCTYPENOD)->nvname)
+ type = LC_CTYPE;
+ else if(name==(LCMSGNOD)->nvname)
+ type = LC_MESSAGES;
+ else if(name==(LCCOLLNOD)->nvname)
+ type = LC_COLLATE;
+ else if(name==(LCNUMNOD)->nvname)
+ type = LC_NUMERIC;
+ else if(name==(LANGNOD)->nvname && (!lc_all || *lc_all==0))
+ type = LC_ALL;
+ else
+ type= -1;
+ if(sh_isstate(SH_INIT) && type>=0 && type!=LC_ALL && lc_all && *lc_all)
+ type= -1;
+ if(type>=0)
+ {
+ if(!setlocale(type,val?val:""))
+ {
+ if(!sh_isstate(SH_INIT) || sh.login_sh==0)
+ errormsg(SH_DICT,0,e_badlocale,val);
+ return;
+ }
+ }
+ if(CC_NATIVE==CC_ASCII && (type==LC_ALL || type==LC_CTYPE))
+ {
+ if(sh_lexstates[ST_BEGIN]!=sh_lexrstates[ST_BEGIN])
+ free((void*)sh_lexstates[ST_BEGIN]);
+ if(ast.locale.set&(1<<AST_LC_CTYPE))
+ {
+ register int c;
+ char *state[4];
+ sh_lexstates[ST_BEGIN] = state[0] = (char*)malloc(4*(1<<CHAR_BIT));
+ memcpy(state[0],sh_lexrstates[ST_BEGIN],(1<<CHAR_BIT));
+ sh_lexstates[ST_NAME] = state[1] = state[0] + (1<<CHAR_BIT);
+ memcpy(state[1],sh_lexrstates[ST_NAME],(1<<CHAR_BIT));
+ sh_lexstates[ST_DOL] = state[2] = state[1] + (1<<CHAR_BIT);
+ memcpy(state[2],sh_lexrstates[ST_DOL],(1<<CHAR_BIT));
+ sh_lexstates[ST_BRACE] = state[3] = state[2] + (1<<CHAR_BIT);
+ memcpy(state[3],sh_lexrstates[ST_BRACE],(1<<CHAR_BIT));
+ for(c=0; c<(1<<CHAR_BIT); c++)
+ {
+ if(state[0][c]!=S_REG)
+ continue;
+ if(state[2][c]!=S_ERR)
+ continue;
+ if(isblank(c))
+ {
+ state[0][c]=0;
+ state[1][c]=S_BREAK;
+ state[2][c]=S_BREAK;
+ continue;
+ }
+ if(!isalpha(c))
+ continue;
+ state[0][c]=S_NAME;
+ if(state[1][c]==S_REG)
+ state[1][c]=0;
+ state[2][c]=S_ALP;
+ if(state[3][c]==S_ERR)
+ state[3][c]=0;
+ }
+ }
+ else
+ {
+ sh_lexstates[ST_BEGIN]=(char*)sh_lexrstates[ST_BEGIN];
+ sh_lexstates[ST_NAME]=(char*)sh_lexrstates[ST_NAME];
+ sh_lexstates[ST_DOL]=(char*)sh_lexrstates[ST_DOL];
+ sh_lexstates[ST_BRACE]=(char*)sh_lexrstates[ST_BRACE];
+ }
+ }
+#if ERROR_VERSION < 20000101L
+ if(type==LC_ALL || type==LC_MESSAGES)
+ error_info.translate = msg_translate;
+#endif
+ nv_putv(np, val, flags, fp);
+ }
+#endif /* _hdr_locale */
+
+/* Trap for IFS assignment and invalidates state table */
+static void put_ifs(register Namval_t* np,const char *val,int flags,Namfun_t *fp)
+{
+ register struct ifs *ip = (struct ifs*)fp;
+ ip->ifsnp = 0;
+ if(val != np->nvalue.cp)
+ nv_putv(np, val, flags, fp);
+
+}
+
+/*
+ * This is the lookup function for IFS
+ * It keeps the sh.ifstable up to date
+ */
+static char* get_ifs(register Namval_t* np, Namfun_t *fp)
+{
+ register struct ifs *ip = (struct ifs*)fp;
+ register char *cp, *value;
+ register int c,n;
+ register Shell_t *shp = ip->sh;
+ value = nv_getv(np,fp);
+ if(np!=ip->ifsnp)
+ {
+ ip->ifsnp = np;
+ memset(shp->ifstable,0,(1<<CHAR_BIT));
+ if(cp=value)
+ {
+#if SHOPT_MULTIBYTE
+ while(n=mbsize(cp),c= *(unsigned char*)cp)
+#else
+ while(c= *(unsigned char*)cp++)
+#endif /* SHOPT_MULTIBYTE */
+ {
+#if SHOPT_MULTIBYTE
+ cp++;
+ if(n>1)
+ {
+ cp += (n-1);
+ shp->ifstable[c] = S_MBYTE;
+ continue;
+ }
+#endif /* SHOPT_MULTIBYTE */
+ n = S_DELIM;
+ if(c== *cp)
+ cp++;
+ else if(c=='\n')
+ n = S_NL;
+ else if(isspace(c))
+ n = S_SPACE;
+ shp->ifstable[c] = n;
+ }
+ }
+ else
+ {
+ shp->ifstable[' '] = shp->ifstable['\t'] = S_SPACE;
+ shp->ifstable['\n'] = S_NL;
+ }
+ }
+ return(value);
+}
+
+/*
+ * these functions are used to get and set the SECONDS variable
+ */
+#ifdef timeofday
+# define dtime(tp) ((double)((tp)->tv_sec)+1e-6*((double)((tp)->tv_usec)))
+# define tms timeval
+#else
+# define dtime(tp) (((double)times(tp))/sh.lim.clk_tck)
+# define timeofday(a)
+#endif
+
+static void put_seconds(register Namval_t* np,const char *val,int flags,Namfun_t *fp)
+{
+ double d;
+ struct tms tp;
+ if(!val)
+ {
+ nv_stack(np, NIL(Namfun_t*));
+ nv_unset(np);
+ return;
+ }
+ if(!np->nvalue.dp)
+ {
+ nv_setsize(np,3);
+ np->nvalue.dp = new_of(double,0);
+ }
+ nv_putv(np, val, flags, fp);
+ d = *np->nvalue.dp;
+ timeofday(&tp);
+ *np->nvalue.dp = dtime(&tp)-d;
+}
+
+static char* get_seconds(register Namval_t* np, Namfun_t *fp)
+{
+ register int places = nv_size(np);
+ struct tms tp;
+ double d, offset = (np->nvalue.dp?*np->nvalue.dp:0);
+ NOT_USED(fp);
+ timeofday(&tp);
+ d = dtime(&tp)- offset;
+ sfprintf(sh.strbuf,"%.*f",places,d);
+ return(sfstruse(sh.strbuf));
+}
+
+static Sfdouble_t nget_seconds(register Namval_t* np, Namfun_t *fp)
+{
+ struct tms tp;
+ double offset = (np->nvalue.dp?*np->nvalue.dp:0);
+ NOT_USED(fp);
+ timeofday(&tp);
+ return(dtime(&tp)- offset);
+}
+
+/*
+ * These three functions are used to get and set the RANDOM variable
+ */
+static void put_rand(register Namval_t* np,const char *val,int flags,Namfun_t *fp)
+{
+ struct rand *rp = (struct rand*)fp;
+ register long n;
+ if(!val)
+ {
+ nv_stack(np, NIL(Namfun_t*));
+ nv_unset(np);
+ return;
+ }
+ if(flags&NV_INTEGER)
+ n = *(double*)val;
+ else
+ n = sh_arith(val);
+ srand((int)(n&RANDMASK));
+ rp->rand_last = -1;
+ if(!np->nvalue.lp)
+ np->nvalue.lp = &rp->rand_last;
+}
+
+/*
+ * get random number in range of 0 - 2**15
+ * never pick same number twice in a row
+ */
+static Sfdouble_t nget_rand(register Namval_t* np, Namfun_t *fp)
+{
+ register long cur, last= *np->nvalue.lp;
+ NOT_USED(fp);
+ do
+ cur = (rand()>>rand_shift)&RANDMASK;
+ while(cur==last);
+ *np->nvalue.lp = cur;
+ return((Sfdouble_t)cur);
+}
+
+static char* get_rand(register Namval_t* np, Namfun_t *fp)
+{
+ register long n = nget_rand(np,fp);
+ return(fmtbase(n, 10, 0));
+}
+
+/*
+ * These three routines are for LINENO
+ */
+static Sfdouble_t nget_lineno(Namval_t* np, Namfun_t *fp)
+{
+ double d=1;
+ if(error_info.line >0)
+ d = error_info.line;
+ else if(error_info.context && error_info.context->line>0)
+ d = error_info.context->line;
+ NOT_USED(np);
+ NOT_USED(fp);
+ return(d);
+}
+
+static void put_lineno(Namval_t* np,const char *val,int flags,Namfun_t *fp)
+{
+ register long n;
+ Shell_t *shp = ((struct shell*)fp)->sh;
+ if(!val)
+ {
+ nv_stack(np, NIL(Namfun_t*));
+ nv_unset(np);
+ return;
+ }
+ if(flags&NV_INTEGER)
+ n = *(double*)val;
+ else
+ n = sh_arith(val);
+ shp->st.firstline += nget_lineno(np,fp)+1-n;
+}
+
+static char* get_lineno(register Namval_t* np, Namfun_t *fp)
+{
+ register long n = nget_lineno(np,fp);
+ return(fmtbase(n, 10, 0));
+}
+
+static char* get_lastarg(Namval_t* np, Namfun_t *fp)
+{
+ NOT_USED(np);
+ return(sh.lastarg);
+}
+
+static void put_lastarg(Namval_t* np,const char *val,int flags,Namfun_t *fp)
+{
+ if(flags&NV_INTEGER)
+ {
+ sfprintf(sh.strbuf,"%.*g",12,*((double*)val));
+ val = sfstruse(sh.strbuf);
+ }
+ if(sh.lastarg && !nv_isattr(np,NV_NOFREE))
+ free((void*)sh.lastarg);
+ else
+ nv_offattr(np,NV_NOFREE);
+ if(val)
+ sh.lastarg = strdup(val);
+ else
+ sh.lastarg = 0;
+}
+
+static int hasgetdisc(register Namfun_t *fp)
+{
+ while(fp && !fp->disc->getnum && !fp->disc->getval)
+ fp = fp->next;
+ return(fp!=0);
+}
+
+/*
+ * store the most recent value for use in .sh.match
+ */
+void sh_setmatch(const char *v, int vsize, int nmatch, int match[])
+{
+ struct match *mp = (struct match*)(SH_MATCHNOD->nvfun);
+ register int i,n;
+ if(mp->nmatch = nmatch)
+ {
+ memcpy(mp->match,match,nmatch*2*sizeof(match[0]));
+ for(n=match[0],i=1; i < 2*nmatch; i++)
+ {
+ if(mp->match[i] < n)
+ n = mp->match[i];
+ }
+ for(vsize=0,i=0; i < 2*nmatch; i++)
+ {
+ if((mp->match[i] -= n) > vsize)
+ vsize = mp->match[i];
+ }
+ v += n;
+ if(vsize >= mp->vsize)
+ {
+ if(mp->vsize)
+ mp->val = (char*)realloc(mp->val,vsize+1);
+ else
+ mp->val = (char*)malloc(vsize+1);
+ mp->vsize = vsize;
+ }
+ memcpy(mp->val,v,vsize);
+ mp->val[vsize] = 0;
+ nv_putsub(SH_MATCHNOD, NIL(char*), nmatch|ARRAY_FILL);
+ mp->lastsub = -1;
+ }
+}
+
+#define array_scan(np) ((nv_arrayptr(np)->nelem&ARRAY_SCAN))
+
+static char* get_match(register Namval_t* np, Namfun_t *fp)
+{
+ struct match *mp = (struct match*)fp;
+ int sub,n;
+ char *val;
+ sub = nv_aindex(np);
+ if(sub>=mp->nmatch)
+ return(0);
+ if(sub==mp->lastsub)
+ return(mp->rval);
+ if(mp->rval)
+ {
+ free((void*)mp->rval);
+ mp->rval = 0;
+ }
+ n = mp->match[2*sub+1]-mp->match[2*sub];
+ if(n<=0)
+ return("");
+ val = mp->val+mp->match[2*sub];
+ if(mp->val[mp->match[2*sub+1]]==0)
+ return(val);
+ mp->rval = (char*)malloc(n+1);
+ mp->lastsub = sub;
+ memcpy(mp->rval,val,n);
+ mp->rval[n] = 0;
+ return(mp->rval);
+}
+
+static const Namdisc_t SH_MATCH_disc = { sizeof(struct match), 0, get_match };
+
+#if SHOPT_FS_3D
+ /*
+ * set or unset the mappings given a colon separated list of directories
+ */
+ static void vpath_set(char *str, int mode)
+ {
+ register char *lastp, *oldp=str, *newp=strchr(oldp,':');
+ if(!sh.lim.fs3d)
+ return;
+ while(newp)
+ {
+ *newp++ = 0;
+ if(lastp=strchr(newp,':'))
+ *lastp = 0;
+ mount((mode?newp:""),oldp,FS3D_VIEW,0);
+ newp[-1] = ':';
+ oldp = newp;
+ newp=lastp;
+ }
+ }
+
+ /* catch vpath assignments */
+ static void put_vpath(register Namval_t* np,const char *val,int flags,Namfun_t *fp)
+ {
+ register char *cp;
+ if(cp = nv_getval(np))
+ vpath_set(cp,0);
+ if(val)
+ vpath_set((char*)val,1);
+ nv_putv(np,val,flags,fp);
+ }
+ static const Namdisc_t VPATH_disc = { 0, put_vpath };
+ static Namfun_t VPATH_init = { &VPATH_disc, 1 };
+#endif /* SHOPT_FS_3D */
+
+
+static const Namdisc_t IFS_disc = { sizeof(struct ifs), put_ifs, get_ifs };
+const Namdisc_t RESTRICTED_disc = { sizeof(struct shell), put_restricted };
+#ifdef PATH_BFPATH
+static const Namdisc_t CDPATH_disc = { sizeof(struct shell), put_cdpath };
+#endif
+static const Namdisc_t EDITOR_disc = { sizeof(struct shell), put_ed };
+static const Namdisc_t OPTINDEX_disc = { sizeof(struct shell), put_optindex, 0, nget_optindex };
+static const Namdisc_t SECONDS_disc = { sizeof(struct seconds), put_seconds, get_seconds, nget_seconds };
+static const Namdisc_t RAND_disc = { sizeof(struct rand), put_rand, get_rand, nget_rand };
+static const Namdisc_t LINENO_disc = { sizeof(struct shell), put_lineno, get_lineno, nget_lineno };
+static const Namdisc_t L_ARG_disc = { sizeof(struct shell), put_lastarg, get_lastarg };
+
+#if SHOPT_NAMESPACE
+ static char* get_nspace(Namval_t* np, Namfun_t *fp)
+ {
+ if(sh.namespace)
+ return(nv_name(sh.namespace));
+ return((char*)np->nvalue.cp);
+ }
+ static const Namdisc_t NSPACE_disc = { 0, 0, get_nspace };
+ static Namfun_t NSPACE_init = { &NSPACE_disc, 1};
+#endif /* SHOPT_NAMESPACE */
+
+#ifdef _hdr_locale
+ static const Namdisc_t LC_disc = { sizeof(struct shell), put_lang };
+#endif /* _hdr_locale */
+
+/*
+ * This function will get called whenever a configuration parameter changes
+ */
+static int newconf(const char *name, const char *path, const char *value)
+{
+ register char *arg;
+ if(!name)
+ setenviron(value);
+ else if(strcmp(name,"UNIVERSE")==0 && strcmp(astconf(name,0,0),value))
+ {
+ sh.universe = 0;
+ /* set directory in new universe */
+ if(*(arg = path_pwd(0))=='/')
+ chdir(arg);
+ /* clear out old tracked alias */
+ stakseek(0);
+ stakputs(nv_getval(PATHNOD));
+ stakputc(0);
+ nv_putval(PATHNOD,stakseek(0),NV_RDONLY);
+ }
+ return(1);
+}
+
+#if (CC_NATIVE != CC_ASCII)
+ static void a2e(char *d, const char *s)
+ {
+ register const unsigned char *t;
+ register int i;
+ t = CCMAP(CC_ASCII, CC_NATIVE);
+ for(i=0; i<(1<<CHAR_BIT); i++)
+ d[t[i]] = s[i];
+ }
+
+ static void init_ebcdic(void)
+ {
+ int i;
+ char *cp = (char*)malloc(ST_NONE*(1<<CHAR_BIT));
+ for(i=0; i < ST_NONE; i++)
+ {
+ a2e(cp,sh_lexrstates[i]);
+ sh_lexstates[i] = cp;
+ cp += (1<<CHAR_BIT);
+ }
+ }
+#endif
+
+/*
+ * return SH_TYPE_* bitmask for path
+ * 0 for "not a shell"
+ */
+int sh_type(register const char *path)
+{
+ register const char* s;
+ register int t = 0;
+
+ if (s = (const char*)strrchr(path, '/'))
+ {
+ if (*path == '-')
+ t |= SH_TYPE_LOGIN;
+ s++;
+ }
+ else
+ s = path;
+ if (*s == '-')
+ {
+ s++;
+ t |= SH_TYPE_LOGIN;
+ }
+ for (;;)
+ {
+ if (!(t & (SH_TYPE_KSH|SH_TYPE_BASH)))
+ {
+ if (*s == 'k')
+ {
+ s++;
+ t |= SH_TYPE_KSH;
+ continue;
+ }
+#if SHOPT_BASH
+ if (*s == 'b' && *(s+1) == 'a')
+ {
+ s += 2;
+ t |= SH_TYPE_BASH;
+ continue;
+ }
+#endif
+ }
+ if (!(t & (SH_TYPE_PROFILE|SH_TYPE_RESTRICTED)))
+ {
+#if SHOPT_PFSH
+ if (*s == 'p' && *(s+1) == 'f')
+ {
+ s += 2;
+ t |= SH_TYPE_PROFILE;
+ continue;
+ }
+#endif
+ if (*s == 'r')
+ {
+ s++;
+ t |= SH_TYPE_RESTRICTED;
+ continue;
+ }
+ }
+ break;
+ }
+ if (*s++ != 's' || *s++ != 'h')
+ return 0;
+ t |= SH_TYPE_SH;
+ if ((t & SH_TYPE_KSH) && *s == '9' && *(s+1) == '3')
+ s += 2;
+#if _WINIX
+ if (*s == '.' && *(s+1) == 'e' && *(s+2) == 'x' && *(s+3) == 'e')
+ s += 4;
+#endif
+ if (*s)
+ t &= ~(SH_TYPE_PROFILE|SH_TYPE_RESTRICTED);
+ return t;
+}
+
+/*
+ * initialize the shell
+ */
+Shell_t *sh_init(register int argc,register char *argv[], void(*userinit)(int))
+{
+ register int n;
+ int type;
+ static char *login_files[3];
+ n = strlen(e_version);
+ if(e_version[n-1]=='$' && e_version[n-2]==' ')
+ e_version[n-2]=0;
+#if (CC_NATIVE == CC_ASCII)
+ memcpy(sh_lexstates,sh_lexrstates,ST_NONE*sizeof(char*));
+#else
+ init_ebcdic();
+#endif
+ umask(umask(0));
+ sh.mac_context = sh_macopen(&sh);
+ sh.arg_context = sh_argopen(&sh);
+ sh.lex_context = (void*)sh_lexopen(0,&sh,1);
+ sh.ed_context = (void*)ed_open(&sh);
+ sh.strbuf = sfstropen();
+ sfsetbuf(sh.strbuf,(char*)0,64);
+ sh_onstate(SH_INIT);
+ error_info.exit = sh_exit;
+ error_info.id = path_basename(argv[0]);
+#if ERROR_VERSION >= 20000102L
+ error_info.catalog = e_dict;
+#endif
+ sh.cpipe[0] = -1;
+ sh.coutpipe = -1;
+ sh.userid=getuid();
+ sh.euserid=geteuid();
+ sh.groupid=getgid();
+ sh.egroupid=getegid();
+ for(n=0;n < 10; n++)
+ {
+ /* don't use lower bits when rand() generates large numbers */
+ if(rand() > RANDMASK)
+ {
+ rand_shift = 3;
+ break;
+ }
+ }
+ sh.lim.clk_tck = getconf("CLK_TCK");
+ sh.lim.arg_max = getconf("ARG_MAX");
+ sh.lim.open_max = getconf("OPEN_MAX");
+ sh.lim.child_max = getconf("CHILD_MAX");
+ sh.lim.ngroups_max = getconf("NGROUPS_MAX");
+ sh.lim.posix_version = getconf("VERSION");
+ sh.lim.posix_jobcontrol = getconf("JOB_CONTROL");
+ if(sh.lim.arg_max <=0)
+ sh.lim.arg_max = ARG_MAX;
+ if(sh.lim.child_max <=0)
+ sh.lim.child_max = CHILD_MAX;
+ if(sh.lim.open_max <0)
+ sh.lim.open_max = OPEN_MAX;
+ if(sh.lim.open_max > (SHRT_MAX-2))
+ sh.lim.open_max = SHRT_MAX-2;
+ if(sh.lim.clk_tck <=0)
+ sh.lim.clk_tck = CLK_TCK;
+#if SHOPT_FS_3D
+ if(fs3d(FS3D_TEST))
+ sh.lim.fs3d = 1;
+#endif /* SHOPT_FS_3D */
+ sh_ioinit();
+ /* initialize signal handling */
+ sh_siginit();
+ stakinstall(NIL(Stak_t*),nospace);
+ /* set up memory for name-value pairs */
+ sh.init_context = nv_init(&sh);
+ /* read the environment */
+ if(argc>0)
+ {
+ type = sh_type(*argv);
+ if(type&SH_TYPE_LOGIN)
+ sh.login_sh = 2;
+ }
+ env_init(&sh);
+#if SHOPT_SPAWN
+ {
+ /*
+ * try to find the pathname for this interpreter
+ * try using environment variable _ or argv[0]
+ */
+ char *last, *cp=nv_getval(L_ARGNOD);
+ char buff[PATH_MAX+1];
+ sh.shpath = 0;
+ sfprintf(sh.strbuf,"/proc/%d/exe",getpid());
+ if((n=readlink(sfstruse(sh.strbuf),buff,sizeof(buff)-1))>0)
+ {
+ buff[n] = 0;
+ sh.shpath = strdup(buff);
+ }
+ else if((cp && (sh_type(cp)&SH_TYPE_SH)) || (argc>0 && strchr(cp= *argv,'/')))
+ {
+ if(*cp=='/')
+ sh.shpath = strdup(cp);
+ else if(cp = nv_getval(PWDNOD))
+ {
+ int offset = staktell();
+ stakputs(cp);
+ stakputc('/');
+ stakputs(argv[0]);
+ pathcanon(stakptr(offset),PATH_DOTDOT);
+ sh.shpath = strdup(stakptr(offset));
+ stakseek(offset);
+ }
+ }
+ }
+#endif
+ nv_putval(IFSNOD,(char*)e_sptbnl,NV_RDONLY);
+#if SHOPT_FS_3D
+ nv_stack(VPATHNOD, &VPATH_init);
+#endif /* SHOPT_FS_3D */
+ astconfdisc(newconf);
+#if SHOPT_TIMEOUT
+ sh.st.tmout = SHOPT_TIMEOUT;
+#endif /* SHOPT_TIMEOUT */
+ /* initialize jobs table */
+ job_clear();
+ if(argc>0)
+ {
+ /* check for restricted shell */
+ if(type&SH_TYPE_RESTRICTED)
+ sh_onoption(SH_RESTRICTED);
+#if SHOPT_PFSH
+ /* check for profile shell */
+ else if(type&SH_TYPE_PROFILE)
+ sh_onoption(SH_PFSH);
+#endif
+#if SHOPT_BASH
+ /* check for invocation as bash */
+ if(type&SH_TYPE_BASH)
+ {
+ sh.userinit = userinit = bash_init;
+ sh_onoption(SH_BASH);
+ sh_onstate(SH_PREINIT);
+ (*userinit)(0);
+ sh_offstate(SH_PREINIT);
+ }
+#endif
+ /* look for options */
+ /* sh.st.dolc is $# */
+ if((sh.st.dolc = sh_argopts(-argc,argv)) < 0)
+ {
+ sh.exitval = 2;
+ sh_done(0);
+ }
+ opt_info.disc = 0;
+ sh.st.dolv=argv+(argc-1)-sh.st.dolc;
+ sh.st.dolv[0] = argv[0];
+ if(sh.st.dolc < 1)
+ sh_onoption(SH_SFLAG);
+ if(!sh_isoption(SH_SFLAG))
+ {
+ sh.st.dolc--;
+ sh.st.dolv++;
+#if _WINIX
+ {
+ char* name;
+ name = sh.st.dolv[0];
+ if(name[1]==':' && (name[2]=='/' || name[2]=='\\'))
+ {
+#if _lib_pathposix
+ char* p;
+
+ if((n = pathposix(name, NIL(char*), 0)) > 0 && (p = (char*)malloc(++n)))
+ {
+ pathposix(name, p, n);
+ name = p;
+ }
+ else
+#endif
+ {
+ name[1] = name[0];
+ name[0] = name[2] = '/';
+ }
+ }
+ }
+#endif /* _WINIX */
+ }
+ }
+#if SHOPT_PFSH
+ if (sh_isoption(SH_PFSH))
+ {
+ struct passwd *pw = getpwuid(sh.userid);
+ if(pw)
+ sh.user = strdup(pw->pw_name);
+
+ }
+#endif
+ /* set[ug]id scripts require the -p flag */
+ if(sh.userid!=sh.euserid || sh.groupid!=sh.egroupid)
+ {
+#if SHOPT_P_SUID
+ /* require sh -p to run setuid and/or setgid */
+ if(!sh_isoption(SH_PRIVILEGED) && sh.euserid < SHOPT_P_SUID)
+ {
+ setuid(sh.euserid=sh.userid);
+ setgid(sh.egroupid=sh.groupid);
+ }
+ else
+#else
+ sh_onoption(SH_PRIVILEGED);
+#endif /* SHOPT_P_SUID */
+#ifdef SHELLMAGIC
+ /* careful of #! setuid scripts with name beginning with - */
+ if(sh.login_sh && argv[1] && strcmp(argv[0],argv[1])==0)
+ errormsg(SH_DICT,ERROR_exit(1),e_prohibited);
+#endif /*SHELLMAGIC*/
+ }
+ else
+ sh_offoption(SH_PRIVILEGED);
+ /* shname for $0 in profiles and . scripts */
+ if(strmatch(argv[1],e_devfdNN))
+ sh.shname = strdup(argv[0]);
+ else
+ sh.shname = strdup(sh.st.dolv[0]);
+ /*
+ * return here for shell script execution
+ * but not for parenthesis subshells
+ */
+ error_info.id = strdup(sh.st.dolv[0]); /* error_info.id is $0 */
+ sh.jmpbuffer = (void*)&sh.checkbase;
+ sh_pushcontext(&sh.checkbase,SH_JMPSCRIPT);
+ sh.st.self = &sh.global;
+ sh.topscope = (Shscope_t*)sh.st.self;
+ sh_offstate(SH_INIT);
+ login_files[0] = (char*)e_profile;
+ login_files[1] = ".profile";
+ sh.login_files = login_files;
+ if(sh.userinit=userinit)
+ (*userinit)(0);
+ return(&sh);
+}
+
+Shell_t *sh_getinterp(void)
+{
+ return(&sh);
+}
+
+/*
+ * reinitialize before executing a script
+ */
+int sh_reinit(char *argv[])
+{
+ Shopt_t opt;
+ dtclear(sh.fun_tree);
+ dtclose(sh.alias_tree);
+ sh.alias_tree = inittree(&sh,shtab_aliases);
+ sh.namespace = 0;
+ sh.inuse_bits = 0;
+ if(sh.userinit)
+ (*sh.userinit)(1);
+ if(sh.heredocs)
+ {
+ sfclose(sh.heredocs);
+ sh.heredocs = 0;
+ }
+ /* remove locals */
+ sh_onstate(SH_INIT);
+ nv_scan(sh.var_tree,sh_envnolocal,(void*)0,NV_EXPORT,0);
+ nv_scan(sh.var_tree,sh_envnolocal,(void*)0,NV_ARRAY,NV_ARRAY);
+ sh_offstate(SH_INIT);
+ memset(sh.st.trapcom,0,(sh.st.trapmax+1)*sizeof(char*));
+ memset((void*)&opt,0,sizeof(opt));
+ if(sh_isoption(SH_TRACKALL))
+ on_option(&opt,SH_TRACKALL);
+ if(sh_isoption(SH_EMACS))
+ on_option(&opt,SH_EMACS);
+ if(sh_isoption(SH_GMACS))
+ on_option(&opt,SH_GMACS);
+ if(sh_isoption(SH_VI))
+ on_option(&opt,SH_VI);
+ if(sh_isoption(SH_VIRAW))
+ on_option(&opt,SH_VIRAW);
+ sh.options = opt;
+ /* set up new args */
+ if(argv)
+ sh.arglist = sh_argcreate(argv);
+ if(sh.arglist)
+ sh_argreset(sh.arglist,NIL(struct dolnod*));
+ sh.envlist=0;
+ sh.curenv = 0;
+ sh.shname = error_info.id = strdup(sh.st.dolv[0]);
+ sh_offstate(SH_FORKED);
+ sh.fn_depth = sh.dot_depth = 0;
+ sh_sigreset(0);
+ return(1);
+}
+
+/*
+ * set when creating a local variable of this name
+ */
+Namfun_t *nv_cover(register Namval_t *np)
+{
+#ifdef PATH_BFPATH
+ if(np==IFSNOD || np==PATHNOD || np==SHELLNOD || np==FPATHNOD || np==CDPNOD || np==SECONDS)
+#else
+ if(np==IFSNOD || np==PATHNOD || np==SHELLNOD || np==SECONDS)
+#endif
+ return(np->nvfun);
+#ifdef _hdr_locale
+ if(np==LCALLNOD || np==LCTYPENOD || np==LCMSGNOD || np==LCCOLLNOD || np==LCNUMNOD || np==LANGNOD)
+ return(np->nvfun);
+#endif
+ return(0);
+}
+
+static Namtype_t typeset;
+static const char *shdiscnames[] = { "tilde", 0};
+
+/*
+ * Initialize the shell name and alias table
+ */
+static Init_t *nv_init(Shell_t *shp)
+{
+ Namval_t *np;
+ register Init_t *ip;
+ double d=0;
+ ip = newof(0,Init_t,1,0);
+ if(!ip)
+ return(0);
+ ip->sh = shp;
+ shp->var_base = shp->var_tree = inittree(shp,shtab_variables);
+ ip->IFS_init.hdr.disc = &IFS_disc;
+ ip->IFS_init.hdr.nofree = 1;
+ ip->IFS_init.sh = shp;
+ ip->PATH_init.hdr.disc = &RESTRICTED_disc;
+ ip->PATH_init.hdr.nofree = 1;
+ ip->PATH_init.sh = shp;
+#ifdef PATH_BFPATH
+ ip->FPATH_init.hdr.disc = &RESTRICTED_disc;
+ ip->FPATH_init.hdr.nofree = 1;
+ ip->FPATH_init.sh = shp;
+ ip->CDPATH_init.hdr.disc = &CDPATH_disc;
+ ip->CDPATH_init.hdr.nofree = 1;
+ ip->CDPATH_init.sh = shp;
+#endif
+ ip->SHELL_init.hdr.disc = &RESTRICTED_disc;
+ ip->SHELL_init.sh = shp;
+ ip->SHELL_init.hdr.nofree = 1;
+ ip->ENV_init.hdr.disc = &RESTRICTED_disc;
+ ip->ENV_init.hdr.nofree = 1;
+ ip->ENV_init.sh = shp;
+ ip->VISUAL_init.hdr.disc = &EDITOR_disc;
+ ip->VISUAL_init.hdr.nofree = 1;
+ ip->VISUAL_init.sh = shp;
+ ip->EDITOR_init.hdr.disc = &EDITOR_disc;
+ ip->EDITOR_init.hdr.nofree = 1;
+ ip->EDITOR_init.sh = shp;
+ ip->OPTINDEX_init.hdr.disc = &OPTINDEX_disc;
+ ip->OPTINDEX_init.hdr.nofree = 1;
+ ip->OPTINDEX_init.sh = shp;
+ ip->SECONDS_init.hdr.disc = &SECONDS_disc;
+ ip->SECONDS_init.hdr.nofree = 1;
+ ip->SECONDS_init.sh = shp;
+ ip->RAND_init.hdr.disc = &RAND_disc;
+ ip->RAND_init.hdr.nofree = 1;
+ ip->SH_MATCH_init.hdr.disc = &SH_MATCH_disc;
+ ip->SH_MATCH_init.hdr.nofree = 1;
+ ip->LINENO_init.hdr.disc = &LINENO_disc;
+ ip->LINENO_init.hdr.nofree = 1;
+ ip->LINENO_init.sh = shp;
+ ip->L_ARG_init.hdr.disc = &L_ARG_disc;
+ ip->L_ARG_init.hdr.nofree = 1;
+#ifdef _hdr_locale
+ ip->LC_TYPE_init.hdr.disc = &LC_disc;
+ ip->LC_TYPE_init.hdr.nofree = 1;
+ ip->LC_NUM_init.hdr.disc = &LC_disc;
+ ip->LC_NUM_init.hdr.nofree = 1;
+ ip->LC_COLL_init.hdr.disc = &LC_disc;
+ ip->LC_COLL_init.hdr.nofree = 1;
+ ip->LC_MSG_init.hdr.disc = &LC_disc;
+ ip->LC_MSG_init.hdr.nofree = 1;
+ ip->LC_ALL_init.hdr.disc = &LC_disc;
+ ip->LC_ALL_init.hdr.nofree = 1;
+ ip->LANG_init.hdr.disc = &LC_disc;
+ ip->LANG_init.hdr.nofree = 1;
+ ip->LC_TYPE_init.sh = shp;
+ ip->LC_NUM_init.sh = shp;
+ ip->LC_COLL_init.sh = shp;
+ ip->LC_MSG_init.sh = shp;
+ ip->LANG_init.sh = shp;
+#endif /* _hdr_locale */
+ nv_stack(IFSNOD, &ip->IFS_init.hdr);
+ nv_stack(PATHNOD, &ip->PATH_init.hdr);
+#ifdef PATH_BFPATH
+ nv_stack(FPATHNOD, &ip->FPATH_init.hdr);
+ nv_stack(CDPNOD, &ip->CDPATH_init.hdr);
+#endif
+ nv_stack(SHELLNOD, &ip->SHELL_init.hdr);
+ nv_stack(ENVNOD, &ip->ENV_init.hdr);
+ nv_stack(VISINOD, &ip->VISUAL_init.hdr);
+ nv_stack(EDITNOD, &ip->EDITOR_init.hdr);
+ nv_stack(OPTINDNOD, &ip->OPTINDEX_init.hdr);
+ nv_stack(SECONDS, &ip->SECONDS_init.hdr);
+ nv_stack(L_ARGNOD, &ip->L_ARG_init.hdr);
+ nv_putval(SECONDS, (char*)&d, NV_INTEGER|NV_DOUBLE);
+ nv_stack(RANDNOD, &ip->RAND_init.hdr);
+ d = (shp->pid&RANDMASK);
+ nv_putval(RANDNOD, (char*)&d, NV_INTEGER|NV_DOUBLE);
+ nv_stack(LINENO, &ip->LINENO_init.hdr);
+ nv_putsub(SH_MATCHNOD,(char*)0,10);
+ nv_onattr(SH_MATCHNOD,NV_RDONLY);
+ nv_stack(SH_MATCHNOD, &ip->SH_MATCH_init.hdr);
+#ifdef _hdr_locale
+ nv_stack(LCTYPENOD, &ip->LC_TYPE_init.hdr);
+ nv_stack(LCALLNOD, &ip->LC_ALL_init.hdr);
+ nv_stack(LCMSGNOD, &ip->LC_MSG_init.hdr);
+ nv_stack(LCCOLLNOD, &ip->LC_COLL_init.hdr);
+ nv_stack(LCNUMNOD, &ip->LC_NUM_init.hdr);
+ nv_stack(LANGNOD, &ip->LANG_init.hdr);
+#endif /* _hdr_locale */
+ (PPIDNOD)->nvalue.lp = (&shp->ppid);
+ (TMOUTNOD)->nvalue.lp = (&shp->st.tmout);
+ (MCHKNOD)->nvalue.lp = (&sh_mailchk);
+ (OPTINDNOD)->nvalue.lp = (&shp->st.optindex);
+ /* set up the seconds clock */
+ shp->alias_tree = inittree(shp,shtab_aliases);
+ shp->track_tree = dtopen(&_Nvdisc,Dtset);
+ shp->bltin_tree = inittree(shp,(const struct shtable2*)shtab_builtins);
+ typeset.shp = shp;
+ typeset.optstring = sh_opttypeset;
+ nv_search("typeset",shp->bltin_tree,0)->nvfun = (void*)&typeset;
+#if SHOPT_BASH
+ nv_search("local",shp->bltin_tree,0)->nvfun = (void*)&typeset;
+#endif
+ shp->fun_tree = dtopen(&_Nvdisc,Dtoset);
+ dtview(shp->fun_tree,shp->bltin_tree);
+#if SHOPT_NAMESPACE
+ if(np = nv_mount(DOTSHNOD, "global", shp->var_tree))
+ nv_onattr(np,NV_RDONLY);
+ np = nv_search("namespace",nv_dict(DOTSHNOD),NV_ADD);
+ nv_putval(np,".sh.global",NV_RDONLY|NV_NOFREE);
+ nv_stack(np, &NSPACE_init);
+#endif /* SHOPT_NAMESPACE */
+ np = nv_mount(DOTSHNOD, "type", dtopen(&_Nvdisc,Dtoset));
+ nv_adddisc(DOTSHNOD, shdiscnames, (Namval_t**)0);
+ return(ip);
+}
+
+/*
+ * initialize name-value pairs
+ */
+
+static Dt_t *inittree(Shell_t *shp,const struct shtable2 *name_vals)
+{
+ register Namval_t *np;
+ register const struct shtable2 *tp;
+ register unsigned n = 0;
+ register Dt_t *treep;
+ Dt_t *base_treep, *dict;
+ for(tp=name_vals;*tp->sh_name;tp++)
+ n++;
+ np = (Namval_t*)calloc(n,sizeof(Namval_t));
+ if(!shp->bltin_nodes)
+ shp->bltin_nodes = np;
+ else if(name_vals==(const struct shtable2*)shtab_builtins)
+ shp->bltin_cmds = np;
+ base_treep = treep = dtopen(&_Nvdisc,Dtoset);
+ for(tp=name_vals;*tp->sh_name;tp++,np++)
+ {
+ if((np->nvname = strrchr(tp->sh_name,'.')) && np->nvname!=((char*)tp->sh_name))
+ np->nvname++;
+ else
+ {
+ np->nvname = (char*)tp->sh_name;
+ treep = base_treep;
+ }
+ np->nvenv = 0;
+ if(name_vals==(const struct shtable2*)shtab_builtins)
+ np->nvalue.bfp = ((struct shtable3*)tp)->sh_value;
+ else
+ np->nvalue.cp = (char*)tp->sh_value;
+ nv_setattr(np,tp->sh_number);
+ if(nv_istable(np))
+ nv_mount(np,(const char*)0,dict=dtopen(&_Nvdisc,Dtoset));
+ if(nv_isattr(np,NV_INTEGER))
+ nv_setsize(np,10);
+ else
+ nv_setsize(np,0);
+ dtinsert(treep,np);
+ if(nv_istable(np))
+ treep = dict;
+ }
+ return(treep);
+}
+
+/*
+ * read in the process environment and set up name-value pairs
+ * skip over items that are not name-value pairs
+ */
+
+static void env_init(Shell_t *shp)
+{
+ register char *cp;
+ register Namval_t *np;
+ register char **ep=environ;
+ register char *next=0;
+#ifdef _ENV_H
+ shp->env = env_open(environ,3);
+ env_delete(shp->env,"_");
+#endif
+ if(ep)
+ {
+ while(cp= *ep++)
+ {
+ if(*cp=='A' && cp[1]=='_' && cp[2]=='_' && cp[3]=='z' && cp[4]=='=')
+ next = cp+4;
+ else if(np=nv_open(cp,shp->var_tree,(NV_EXPORT|NV_IDENT|NV_ASSIGN|NV_NOFAIL)))
+ {
+ nv_onattr(np,NV_IMPORT);
+ np->nvenv = cp;
+ nv_close(np);
+ }
+ }
+ while(cp=next)
+ {
+ if(next = strchr(++cp,'='))
+ *next = 0;
+ np = nv_search(cp+2,shp->var_tree,NV_ADD);
+ if(nv_isattr(np,NV_IMPORT|NV_EXPORT))
+ {
+ int flag = *(unsigned char*)cp-' ';
+ int size = *(unsigned char*)(cp+1)-' ';
+ if((flag&NV_INTEGER) && size==0)
+ {
+ /* check for floating*/
+ char *ep,*val = nv_getval(np);
+ strtol(val,&ep,10);
+ if(*ep=='.' || *ep=='e' || *ep=='E')
+ {
+ char *lp;
+ flag |= NV_DOUBLE;
+ if(*ep=='.')
+ {
+ strtol(ep+1,&lp,10);
+ if(*lp)
+ ep = lp;
+ }
+ if(*ep && *ep!='.')
+ {
+ flag |= NV_EXPNOTE;
+ size = ep-val;
+ }
+ else
+ size = strlen(ep);
+ size--;
+ }
+ }
+ nv_newattr(np,flag|NV_IMPORT|NV_EXPORT,size);
+ }
+ }
+ }
+#ifdef _ENV_H
+ env_delete(sh.env,e_envmarker);
+#endif
+ if(nv_isnull(PWDNOD) || nv_isattr(PWDNOD,NV_TAGGED))
+ {
+ nv_offattr(PWDNOD,NV_TAGGED);
+ path_pwd(0);
+ }
+ if((cp = nv_getval(SHELLNOD)) && (sh_type(cp)&SH_TYPE_RESTRICTED))
+ sh_onoption(SH_RESTRICTED); /* restricted shell */
+ return;
+}
+
+/*
+ * terminate shell and free up the space
+ */
+int sh_term(void)
+{
+ sfdisc(sfstdin,SF_POPDISC);
+ free((char*)sh.outbuff);
+ stakset(NIL(char*),0);
+ return(0);
+}
+
+/* function versions of these */
+
+#define DISABLE /* proto workaround */
+
+unsigned long sh_isoption DISABLE (int opt)
+{
+ return(sh_isoption(opt));
+}
+
+unsigned long sh_onoption DISABLE (int opt)
+{
+ return(sh_onoption(opt));
+}
+
+unsigned long sh_offoption DISABLE (int opt)
+{
+ return(sh_offoption(opt));
+}
+
+void sh_sigcheck DISABLE (void)
+{
+ sh_sigcheck();
+}
+
+Dt_t* sh_bltin_tree DISABLE (void)
+{
+ return(sh.bltin_tree);
+}
diff --git a/usr/src/lib/libshell/common/sh/io.c b/usr/src/lib/libshell/common/sh/io.c
new file mode 100644
index 0000000000..a14a941942
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/io.c
@@ -0,0 +1,2215 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * Input/output file processing
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#include "defs.h"
+#include <fcin.h>
+#include <ls.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <regex.h>
+#include "variables.h"
+#include "path.h"
+#include "io.h"
+#include "jobs.h"
+#include "shnodes.h"
+#include "history.h"
+#include "edit.h"
+#include "timeout.h"
+#include "FEATURE/externs"
+#include "FEATURE/dynamic"
+#include "FEATURE/poll"
+
+#ifdef FNDELAY
+# ifdef EAGAIN
+# if EAGAIN!=EWOULDBLOCK
+# undef EAGAIN
+# define EAGAIN EWOULDBLOCK
+# endif
+# else
+# define EAGAIN EWOULDBLOCK
+# endif /* EAGAIN */
+# ifndef O_NONBLOCK
+# define O_NONBLOCK FNDELAY
+# endif /* !O_NONBLOCK */
+#endif /* FNDELAY */
+
+#ifndef O_SERVICE
+# define O_SERVICE O_NOCTTY
+#endif
+
+#define RW_ALL (S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR|S_IWGRP|S_IWOTH)
+
+static void *timeout;
+static int (*fdnotify)(int,int);
+
+#if defined(_lib_socket) && defined(_sys_socket) && defined(_hdr_netinet_in)
+# include <sys/socket.h>
+# include <netdb.h>
+# include <netinet/in.h>
+# if !defined(htons) && !_lib_htons
+# define htons(x) (x)
+# endif
+# if !defined(htonl) && !_lib_htonl
+# define htonl(x) (x)
+# endif
+# if _pipe_socketpair
+# if _socketpair_shutdown_mode
+# define pipe(v) ((socketpair(AF_UNIX,SOCK_STREAM,0,v)<0||shutdown((v)[0],1)<0||fchmod((v)[0],S_IRUSR)<0||shutdown((v)[1],0)<0||fchmod((v)[1],S_IWUSR)<0)?(-1):0)
+# else
+# define pipe(v) ((socketpair(AF_UNIX,SOCK_STREAM,0,v)<0||shutdown((v)[0],1)<0||shutdown((v)[1],0)<0)?(-1):0)
+# endif
+# endif
+
+#if !_lib_getaddrinfo
+
+#undef EAI_SYSTEM
+
+#define EAI_SYSTEM 1
+
+#undef addrinfo
+#undef getaddrinfo
+#undef freeaddrinfo
+
+#define addrinfo local_addrinfo
+#define getaddrinfo local_getaddrinfo
+#define freeaddrinfo local_freeaddrinfo
+
+struct addrinfo
+{
+ int ai_flags;
+ int ai_family;
+ int ai_socktype;
+ int ai_protocol;
+ socklen_t ai_addrlen;
+ struct sockaddr* ai_addr;
+ struct addrinfo* ai_next;
+};
+
+static int
+getaddrinfo(const char* node, const char* service, const struct addrinfo* hint, struct addrinfo **addr)
+{
+ unsigned long ip_addr = 0;
+ unsigned short ip_port = 0;
+ struct addrinfo* ap;
+ struct hostent* hp;
+ struct sockaddr_in* ip;
+ char* prot;
+ long n;
+
+ if (!(hp = gethostbyname(node)) || hp->h_addrtype!=AF_INET || hp->h_length>sizeof(struct in_addr))
+ {
+ errno = EADDRNOTAVAIL;
+ return EAI_SYSTEM;
+ }
+ ip_addr = (unsigned long)((struct in_addr*)hp->h_addr)->s_addr;
+ if ((n = strtol(service, &prot, 10)) > 0 && n <= USHRT_MAX && !*prot)
+ ip_port = htons((unsigned short)n);
+ else
+ {
+ struct servent* sp;
+ const char* protocol = 0;
+
+ if (hint)
+ switch (hint->ai_socktype)
+ {
+ case SOCK_STREAM:
+ switch (hint->ai_protocol)
+ {
+ case 0:
+ protocol = "tcp";
+ break;
+#ifdef IPPROTO_SCTP
+ case IPPROTO_SCTP:
+ protocol = "sctp";
+ break;
+#endif
+ }
+ break;
+ case SOCK_DGRAM:
+ protocol = "udp";
+ break;
+ }
+ if (!protocol)
+ {
+ errno = EPROTONOSUPPORT;
+ return 1;
+ }
+ if (sp = getservbyname(service, protocol))
+ ip_port = sp->s_port;
+ }
+ if (!ip_port)
+ {
+ errno = EADDRNOTAVAIL;
+ return EAI_SYSTEM;
+ }
+ if (!(ap = newof(0, struct addrinfo, 1, sizeof(struct sockaddr_in))))
+ return EAI_SYSTEM;
+ if (hint)
+ *ap = *hint;
+ ap->ai_family = hp->h_addrtype;
+ ap->ai_addrlen = sizeof(struct sockaddr_in);
+ ap->ai_addr = (struct sockaddr *)(ap+1);
+ ip = (struct sockaddr_in *)ap->ai_addr;
+ ip->sin_family = AF_INET;
+ ip->sin_port = ip_port;
+ ip->sin_addr.s_addr = ip_addr;
+ *addr = ap;
+ return 0;
+}
+
+static void
+freeaddrinfo(struct addrinfo* ap)
+{
+ if (ap)
+ free(ap);
+}
+
+#endif
+
+/*
+ * return <protocol>/<host>/<service> fd
+ */
+
+typedef int (*Inetintr_f)(struct addrinfo*, void*);
+
+static int
+inetopen(const char* path, int server, Inetintr_f onintr, void* handle)
+{
+ register char* s;
+ register char* t;
+ int fd;
+ int oerrno;
+ struct addrinfo hint;
+ struct addrinfo* addr;
+ struct addrinfo* p;
+
+ memset(&hint, 0, sizeof(hint));
+ hint.ai_family = PF_UNSPEC;
+ switch (path[0])
+ {
+#ifdef IPPROTO_SCTP
+ case 's':
+ if (path[1]!='c' || path[2]!='t' || path[3]!='p' || path[4]!='/')
+ {
+ errno = ENOTDIR;
+ return -1;
+ }
+ hint.ai_socktype = SOCK_STREAM;
+ hint.ai_protocol = IPPROTO_SCTP;
+ path += 5;
+ break;
+#endif
+ case 't':
+ if (path[1]!='c' || path[2]!='p' || path[3]!='/')
+ {
+ errno = ENOTDIR;
+ return -1;
+ }
+ hint.ai_socktype = SOCK_STREAM;
+ path += 4;
+ break;
+ case 'u':
+ if (path[1]!='d' || path[2]!='p' || path[3]!='/')
+ {
+ errno = ENOTDIR;
+ return -1;
+ }
+ hint.ai_socktype = SOCK_DGRAM;
+ path += 4;
+ break;
+ default:
+ errno = ENOTDIR;
+ return -1;
+ }
+ if (!(s = strdup(path)))
+ return -1;
+ if (t = strchr(s, '/'))
+ {
+ *t++ = 0;
+ if (streq(s, "local"))
+ s = "localhost";
+ fd = getaddrinfo(s, t, &hint, &addr);
+ }
+ else
+ fd = -1;
+ free(s);
+ if (fd)
+ {
+ if (fd != EAI_SYSTEM)
+ errno = ENOTDIR;
+ return -1;
+ }
+ oerrno = errno;
+ errno = 0;
+ fd = -1;
+ for (p = addr; p; p = p->ai_next)
+ {
+ /*
+ * some api's don't take the hint
+ */
+
+ if (!p->ai_protocol)
+ p->ai_protocol = hint.ai_protocol;
+ if (!p->ai_socktype)
+ p->ai_socktype = hint.ai_socktype;
+ while ((fd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) >= 0)
+ {
+ if (server && !bind(fd, p->ai_addr, p->ai_addrlen) && !listen(fd, 5) || !server && !connect(fd, p->ai_addr, p->ai_addrlen))
+ goto done;
+ close(fd);
+ fd = -1;
+ if (errno != EINTR || !onintr)
+ break;
+ if ((*onintr)(addr, handle))
+ return -1;
+ }
+ }
+ done:
+ freeaddrinfo(addr);
+ if (fd >= 0)
+ errno = oerrno;
+ return fd;
+}
+
+#else
+
+#undef O_SERVICE
+
+#endif
+
+struct fdsave
+{
+ int orig_fd; /* original file descriptor */
+ int save_fd; /* saved file descriptor */
+ int subshell; /* saved for subshell */
+};
+
+static int subexcept(Sfio_t*, int, void*, Sfdisc_t*);
+static int eval_exceptf(Sfio_t*, int, void*, Sfdisc_t*);
+static int slowexcept(Sfio_t*, int, void*, Sfdisc_t*);
+static int pipeexcept(Sfio_t*, int, void*, Sfdisc_t*);
+static ssize_t piperead(Sfio_t*, void*, size_t, Sfdisc_t*);
+static ssize_t slowread(Sfio_t*, void*, size_t, Sfdisc_t*);
+static ssize_t subread(Sfio_t*, void*, size_t, Sfdisc_t*);
+static ssize_t tee_write(Sfio_t*,const void*,size_t,Sfdisc_t*);
+static int io_prompt(Sfio_t*,int);
+static int io_heredoc(register struct ionod*, const char*, int);
+static void sftrack(Sfio_t*,int,int);
+static const Sfdisc_t eval_disc = { NULL, NULL, NULL, eval_exceptf, NULL};
+static Sfdisc_t tee_disc = {NULL,tee_write,NULL,NULL,NULL};
+static Sfio_t *subopen(Sfio_t*, off_t, long);
+static const Sfdisc_t sub_disc = { subread, 0, 0, subexcept, 0 };
+
+struct subfile
+{
+ Sfdisc_t disc;
+ Sfio_t *oldsp;
+ off_t offset;
+ long size;
+ long left;
+};
+
+struct Eof
+{
+ Namfun_t hdr;
+ int fd;
+};
+
+static Sfdouble_t nget_cur_eof(register Namval_t* np, Namfun_t *fp)
+{
+ struct Eof *ep = (struct Eof*)fp;
+ Sfoff_t end, cur =lseek(ep->fd, (Sfoff_t)0, SEEK_CUR);
+ if(*np->nvname=='C')
+ return((Sfdouble_t)cur);
+ if(cur<0)
+ return((Sfdouble_t)-1);
+ end =lseek(ep->fd, (Sfoff_t)0, SEEK_END);
+ lseek(ep->fd, (Sfoff_t)0, SEEK_CUR);
+ return((Sfdouble_t)end);
+}
+
+static const Namdisc_t EOF_disc = { sizeof(struct Eof), 0, 0, nget_cur_eof};
+
+#define MATCH_BUFF (64*1024)
+struct Match
+{
+ Sfoff_t offset;
+ char *base;
+};
+
+static int matchf(void *handle, char *ptr, size_t size)
+{
+ struct Match *mp = (struct Match*)handle;
+ mp->offset += (ptr-mp->base);
+ return(1);
+}
+
+
+static struct fdsave *filemap;
+static short filemapsize;
+
+/* ======== input output and file copying ======== */
+
+void sh_ioinit(void)
+{
+ register int n;
+ filemapsize = 8;
+ filemap = (struct fdsave*)malloc(8*sizeof(struct fdsave));
+#if SHOPT_FASTPIPE
+ n = sh.lim.open_max+2;
+#else
+ n = sh.lim.open_max;
+#endif /* SHOPT_FASTPIPE */
+ sh.fdstatus = (unsigned char*)malloc((unsigned)n);
+ memset((char*)sh.fdstatus,0,n);
+ sh.fdptrs = (int**)malloc(n*sizeof(int*));
+ memset((char*)sh.fdptrs,0,n*sizeof(int*));
+ sh.sftable = (Sfio_t**)malloc(n*sizeof(Sfio_t*));
+ memset((char*)sh.sftable,0,n*sizeof(Sfio_t*));
+ sh.sftable[0] = sfstdin;
+ sh.sftable[1] = sfstdout;
+ sh.sftable[2] = sfstderr;
+ sfnotify(sftrack);
+ sh_iostream(0);
+ /* all write steams are in the same pool and share outbuff */
+ sh.outpool = sfopen(NIL(Sfio_t*),NIL(char*),"sw"); /* pool identifier */
+ sh.outbuff = (char*)malloc(IOBSIZE);
+ sh.errbuff = (char*)malloc(IOBSIZE/4);
+ sfsetbuf(sfstderr,sh.errbuff,IOBSIZE/4);
+ sfsetbuf(sfstdout,sh.outbuff,IOBSIZE);
+ sfpool(sfstdout,sh.outpool,SF_WRITE);
+ sfpool(sfstderr,sh.outpool,SF_WRITE);
+ sfset(sfstdout,SF_LINE,0);
+}
+
+/*
+ * create or initialize a stream corresponding to descriptor <fd>
+ * a buffer with room for a sentinal is allocated for a read stream.
+ * A discipline is inserted when read stream is a tty or a pipe
+ * For output streams, the buffer is set to sh.output and put into
+ * the sh.outpool synchronization pool
+ */
+Sfio_t *sh_iostream(register int fd)
+{
+ register Sfio_t *iop;
+ register int status = sh_iocheckfd(fd);
+ register int flags = SF_WRITE;
+ char *bp;
+#if SHOPT_FASTPIPE
+ if(fd>=sh.lim.open_max)
+ return(sh.sftable[fd]);
+#endif /* SHOPT_FASTPIPE */
+ if(status==IOCLOSE)
+ {
+ switch(fd)
+ {
+ case 0:
+ return(sfstdin);
+ case 1:
+ return(sfstdout);
+ case 2:
+ return(sfstderr);
+ }
+ return(NIL(Sfio_t*));
+ }
+ if(status&IOREAD)
+ {
+ if(!(bp = (char *)malloc(IOBSIZE+1)))
+ return(NIL(Sfio_t*));
+ flags |= SF_READ;
+ if(!(status&IOWRITE))
+ flags &= ~SF_WRITE;
+ }
+ else
+ bp = sh.outbuff;
+ if(status&IODUP)
+ flags |= SF_SHARE|SF_PUBLIC;
+ if((iop = sh.sftable[fd]) && sffileno(iop)>=0)
+ sfsetbuf(iop, bp, IOBSIZE);
+ else if(!(iop=sfnew((fd<=2?iop:0),bp,IOBSIZE,fd,flags)))
+ return(NIL(Sfio_t*));
+ if(status&IOREAD)
+ {
+ Sfdisc_t *dp;
+ sfset(iop,SF_MALLOC,1);
+ {
+ dp = newof(0,Sfdisc_t,1,0);
+ dp->exceptf = slowexcept;
+ if(status&IOTTY)
+ dp->readf = slowread;
+ else if(status&IONOSEEK)
+ {
+ dp->readf = piperead;
+ sfset(iop, SF_IOINTR,1);
+ }
+ else
+ dp->readf = 0;
+ dp->seekf = 0;
+ dp->writef = 0;
+ sfdisc(iop,dp);
+ }
+ }
+ else
+ sfpool(iop,sh.outpool,SF_WRITE);
+ sh.sftable[fd] = iop;
+ return(iop);
+}
+
+/*
+ * preserve the file descriptor or stream by moving it
+ */
+static void io_preserve(register Sfio_t *sp, register int f2)
+{
+ register int fd;
+ if(sp)
+ fd = sfsetfd(sp,10);
+ else
+ fd = sh_fcntl(f2,F_DUPFD,10);
+ if(f2==sh.infd)
+ sh.infd = fd;
+ if(fd<0)
+ errormsg(SH_DICT,ERROR_system(1),e_toomany);
+ if(sh.fdptrs[fd]=sh.fdptrs[f2])
+ {
+ if(f2==job.fd)
+ job.fd=fd;
+ *sh.fdptrs[fd] = fd;
+ sh.fdptrs[f2] = 0;
+ }
+ sh.sftable[fd] = sp;
+ sh.fdstatus[fd] = sh.fdstatus[f2];
+ if(fcntl(f2,F_GETFD,0)&1)
+ {
+ fcntl(fd,F_SETFD,FD_CLOEXEC);
+ sh.fdstatus[fd] |= IOCLEX;
+ }
+ sh.sftable[f2] = 0;
+}
+
+/*
+ * Given a file descriptor <f1>, move it to a file descriptor number <f2>
+ * If <f2> is needed move it, otherwise it is closed first.
+ * The original stream <f1> is closed.
+ * The new file descriptor <f2> is returned;
+ */
+int sh_iorenumber(register int f1,register int f2)
+{
+ register Sfio_t *sp = sh.sftable[f2];
+ if(f1!=f2)
+ {
+ /* see whether file descriptor is in use */
+ if(sh_inuse(f2) || (f2>2 && sp))
+ {
+ if(!(sh.inuse_bits&(1<<f2)))
+ io_preserve(sp,f2);
+ sp = 0;
+ }
+ else if(f2==0)
+ sh.st.ioset = 1;
+ sh_close(f2);
+ if(f2<=2 && sp)
+ {
+ register Sfio_t *spnew = sh_iostream(f1);
+ sh.fdstatus[f2] = (sh.fdstatus[f1]&~IOCLEX);
+ sfsetfd(spnew,f2);
+ sfswap(spnew,sp);
+ sfset(sp,SF_SHARE|SF_PUBLIC,1);
+ }
+ else
+ {
+ sh.fdstatus[f2] = (sh.fdstatus[f1]&~IOCLEX);
+ if((f2 = sh_fcntl(f1,F_DUPFD, f2)) < 0)
+ errormsg(SH_DICT,ERROR_system(1),e_file+4);
+ else if(f2 <= 2)
+ sh_iostream(f2);
+ }
+ if(sp)
+ sh.sftable[f1] = 0;
+ sh_close(f1);
+ }
+ return(f2);
+}
+
+/*
+ * close a file descriptor and update stream table and attributes
+ */
+int sh_close(register int fd)
+{
+ register Sfio_t *sp;
+ register int r = 0;
+ if(fd<0)
+ return(-1);
+ if(!(sp=sh.sftable[fd]) || sfclose(sp) < 0)
+ {
+ if(fdnotify)
+ (*fdnotify)(fd,SH_FDCLOSE);
+ r=close(fd);
+ }
+ if(fd>2)
+ sh.sftable[fd] = 0;
+ sh.fdstatus[fd] = IOCLOSE;
+ if(sh.fdptrs[fd])
+ *sh.fdptrs[fd] = -1;
+ sh.fdptrs[fd] = 0;
+ if(fd < 10)
+ sh.inuse_bits &= ~(1<<fd);
+ return(r);
+}
+
+static int
+onintr(struct addrinfo* addr, void* handle)
+{
+ Shell_t* sh = (Shell_t*)handle;
+
+ if (sh->trapnote&SH_SIGSET)
+ {
+ freeaddrinfo(addr);
+ sh_exit(SH_EXITSIG);
+ return -1;
+ }
+ if (sh->trapnote)
+ sh_chktrap();
+ return 0;
+}
+
+/*
+ * Mimic open(2) with checks for pseudo /dev/ files.
+ */
+int sh_open(register const char *path, int flags, ...)
+{
+ register int fd = -1;
+ mode_t mode;
+ char *e;
+ va_list ap;
+ va_start(ap, flags);
+ mode = (flags & O_CREAT) ? va_arg(ap, int) : 0;
+ va_end(ap);
+ errno = 0;
+ if(*path==0)
+ {
+ errno = ENOENT;
+ return(-1);
+ }
+ if (path[0]=='/' && path[1]=='d' && path[2]=='e' && path[3]=='v' && path[4]=='/')
+ {
+ switch (path[5])
+ {
+ case 'f':
+ if (path[6]=='d' && path[7]=='/')
+ {
+ fd = (int)strtol(path+8, &e, 10);
+ if (*e)
+ fd = -1;
+ }
+ break;
+ case 's':
+ if (path[6]=='t' && path[7]=='d')
+ switch (path[8])
+ {
+ case 'e':
+ if (path[9]=='r' && path[10]=='r' && !path[11])
+ fd = 2;
+ break;
+ case 'i':
+ if (path[9]=='n' && !path[10])
+ fd = 0;
+ break;
+ case 'o':
+ if (path[9]=='u' && path[10]=='t' && !path[11])
+ fd = 1;
+ break;
+ }
+ }
+#ifdef O_SERVICE
+ if (fd < 0)
+ {
+ if ((fd = inetopen(path+5, !!(flags & O_SERVICE), onintr, &sh)) < 0 && errno != ENOTDIR)
+ return -1;
+ if (fd >= 0)
+ goto ok;
+ }
+#endif
+ }
+ if (fd >= 0)
+ {
+ if((mode=sh_iocheckfd(fd))==IOCLOSE)
+ return(-1);
+ flags &= O_ACCMODE;
+ if(!(mode&IOWRITE) && ((flags==O_WRONLY) || (flags==O_RDWR)))
+ return(-1);
+ if(!(mode&IOREAD) && ((flags==O_RDONLY) || (flags==O_RDWR)))
+ return(-1);
+ if((fd=dup(fd))<0)
+ return(-1);
+ }
+ else while((fd = open(path, flags, mode)) < 0)
+ if(errno!=EINTR || sh.trapnote)
+ return(-1);
+#ifdef O_SERVICE
+ ok:
+#endif
+ flags &= O_ACCMODE;
+ if(flags==O_WRONLY)
+ mode = IOWRITE;
+ else if(flags==O_RDWR)
+ mode = (IOREAD|IOWRITE);
+ else
+ mode = IOREAD;
+ sh.fdstatus[fd] = mode;
+ return(fd);
+}
+
+/*
+ * Open a file for reading
+ * On failure, print message.
+ */
+int sh_chkopen(register const char *name)
+{
+ register int fd = sh_open(name,O_RDONLY,0);
+ if(fd < 0)
+ errormsg(SH_DICT,ERROR_system(1),e_open,name);
+ return(fd);
+}
+
+/*
+ * move open file descriptor to a number > 2
+ */
+int sh_iomovefd(register int fdold)
+{
+ register int fdnew;
+ if(fdold<0 || fdold>2)
+ return(fdold);
+ fdnew = sh_iomovefd(dup(fdold));
+ sh.fdstatus[fdnew] = (sh.fdstatus[fdold]&~IOCLEX);
+ close(fdold);
+ sh.fdstatus[fdold] = IOCLOSE;
+ return(fdnew);
+}
+
+/*
+ * create a pipe and print message on failure
+ */
+int sh_pipe(register int pv[])
+{
+ int fd[2];
+ if(pipe(fd)<0 || (pv[0]=fd[0])<0 || (pv[1]=fd[1])<0)
+ errormsg(SH_DICT,ERROR_system(1),e_pipe);
+ pv[0] = sh_iomovefd(pv[0]);
+ pv[1] = sh_iomovefd(pv[1]);
+ sh.fdstatus[pv[0]] = IONOSEEK|IOREAD;
+ sh.fdstatus[pv[1]] = IONOSEEK|IOWRITE;
+ sh_subsavefd(pv[0]);
+ sh_subsavefd(pv[1]);
+ return(0);
+}
+
+static int pat_seek(void *handle, const char *str, size_t sz)
+{
+ char **bp = (char**)handle;
+ *bp = (char*)str;
+ return(-1);
+}
+
+static int pat_line(const regex_t* rp, const char *buff, register size_t n)
+{
+ register const char *cp=buff, *sp;
+ while(n>0)
+ {
+ for(sp=cp; n-->0 && *cp++ != '\n';);
+ if(regnexec(rp,sp,cp-sp, 0, (regmatch_t*)0, 0)==0)
+ return(sp-buff);
+ }
+ return(cp-buff);
+}
+
+static int io_patseek(regex_t *rp, Sfio_t* sp, int flags)
+{
+ char *cp, *match;
+ int r, fd=sffileno(sp), close_exec = sh.fdstatus[fd]&IOCLEX;
+ int was_share,s=(PIPE_BUF>SF_BUFSIZE?SF_BUFSIZE:PIPE_BUF);
+ size_t n,m;
+ sh.fdstatus[sffileno(sp)] |= IOCLEX;
+ if(fd==0)
+ was_share = sfset(sp,SF_SHARE,1);
+ while((cp=sfreserve(sp, -s, SF_LOCKR)) || (cp=sfreserve(sp,SF_UNBOUND, SF_LOCKR)))
+ {
+ m = n = sfvalue(sp);
+ while(n>0 && cp[n-1]!='\n')
+ n--;
+ if(n)
+ m = n;
+ r = regrexec(rp,cp,m,0,(regmatch_t*)0, 0, '\n', (void*)&match, pat_seek);
+ if(r<0)
+ m = match-cp;
+ else if(r==2)
+ {
+ if((m = pat_line(rp,cp,m)) < n)
+ r = -1;
+ }
+ if(m && (flags&IOCOPY))
+ sfwrite(sfstdout,cp,m);
+ sfread(sp,cp,m);
+ if(r<0)
+ break;
+ }
+ if(!close_exec)
+ sh.fdstatus[sffileno(sp)] &= ~IOCLEX;
+ if(fd==0 && !(was_share&SF_SHARE))
+ sfset(sp, SF_SHARE,0);
+ return(0);
+}
+
+static Sfoff_t file_offset(int fn, char *fname)
+{
+ Sfio_t *sp = sh.sftable[fn];
+ char *cp;
+ Sfoff_t off;
+ struct Eof endf;
+ Namval_t *mp = nv_open("EOF",sh.var_tree,0);
+ Namval_t *pp = nv_open("CUR",sh.var_tree,0);
+ memset(&endf,0,sizeof(struct Eof));
+ endf.fd = fn;
+ endf.hdr.disc = &EOF_disc;
+ endf.hdr.nofree = 1;
+ if(mp)
+ nv_stack(mp, &endf.hdr);
+ if(pp)
+ nv_stack(pp, &endf.hdr);
+ if(sp)
+ sfsync(sp);
+ off = sh_strnum(fname, &cp, 0);
+ if(mp)
+ nv_stack(mp, NiL);
+ if(pp)
+ nv_stack(pp, NiL);
+ return(*cp?(Sfoff_t)-1:off);
+}
+
+/*
+ * close a pipe
+ */
+void sh_pclose(register int pv[])
+{
+ if(pv[0]>=2)
+ sh_close(pv[0]);
+ if(pv[1]>=2)
+ sh_close(pv[1]);
+ pv[0] = pv[1] = -1;
+}
+
+/*
+ * I/O redirection
+ * flag = 0 if files are to be restored
+ * flag = 2 if files are to be closed on exec
+ * flag = 3 when called from $( < ...), just open file and return
+ * flag = SH_SHOWME for trace only
+ */
+int sh_redirect(struct ionod *iop, int flag)
+{
+ Sfoff_t off;
+ register char *fname;
+ register int fd, iof;
+ const char *message = e_open;
+ int o_mode; /* mode flag for open */
+ static char io_op[7]; /* used for -x trace info */
+ int clexec=0, fn, traceon;
+ int r, indx = sh.topfd;
+ char *after="", *trace = sh.st.trap[SH_DEBUGTRAP];
+ Namval_t *np=0;
+ if(flag==2)
+ clexec = 1;
+ if(iop)
+ traceon = sh_trace(NIL(char**),0);
+ for(;iop;iop=iop->ionxt)
+ {
+ iof=iop->iofile;
+ fn = (iof&IOUFD);
+ io_op[0] = '0'+(iof&IOUFD);
+ if(iof&IOPUT)
+ {
+ io_op[1] = '>';
+ o_mode = O_WRONLY|O_CREAT;
+ }
+ else
+ {
+ io_op[1] = '<';
+ o_mode = O_RDONLY|O_NONBLOCK;
+ }
+ io_op[2] = 0;
+ io_op[3] = 0;
+ io_op[4] = 0;
+ fname = iop->ioname;
+ if(!(iof&IORAW))
+ {
+ if(iof&IOLSEEK)
+ {
+ struct argnod *ap = (struct argnod*)stakalloc(ARGVAL+strlen(iop->ioname));
+ memset(ap, 0, ARGVAL);
+ ap->argflag = ARG_MAC;
+ strcpy(ap->argval,iop->ioname);
+ fname=sh_macpat(ap,(iof&IOARITH)?ARG_ARITH:ARG_EXP);
+ }
+ else
+ fname=sh_mactrim(fname,(!sh_isoption(SH_NOGLOB)&&sh_isoption(SH_INTERACTIVE))?2:0);
+ }
+ errno=0;
+ if(iop->iovname)
+ {
+ np = nv_open(iop->iovname,sh.var_tree,NV_NOASSIGN|NV_VARNAME);
+ if(nv_isattr(np,NV_RDONLY))
+ errormsg(SH_DICT,ERROR_exit(1),e_readonly, nv_name(np));
+ io_op[0] = '}';
+ if((iof&IOMOV) && *fname=='-')
+ fn = nv_getnum(np);
+ }
+ if(iof&IOLSEEK)
+ {
+ io_op[2] = '#';
+ if(iof&IOARITH)
+ {
+ strcpy(&io_op[3]," ((");
+ after = "))";
+ }
+ else if(iof&IOCOPY)
+ io_op[3] = '#';
+ goto traceit;
+ }
+ if(*fname)
+ {
+ if(iof&IODOC)
+ {
+ if(traceon)
+ sfputr(sfstderr,io_op,'<');
+ fd = io_heredoc(iop,fname,traceon);
+ if(traceon && (flag==SH_SHOWME))
+ sh_close(fd);
+ fname = 0;
+ }
+ else if(iof&IOMOV)
+ {
+ int dupfd,toclose= -1;
+ io_op[2] = '&';
+ if((fd=fname[0])>='0' && fd<='9')
+ {
+ char *number = fname;
+ dupfd = strtol(fname,&number,10);
+ if(*number=='-')
+ {
+ toclose = dupfd;
+ number++;
+ }
+ if(*number || dupfd > IOUFD)
+ {
+ message = e_file;
+ goto fail;
+ }
+ if(sh.subshell && dupfd==1)
+ {
+ sh_subtmpfile();
+ dupfd = sffileno(sfstdout);
+ }
+ else if(sh.sftable[dupfd])
+ sfsync(sh.sftable[dupfd]);
+ }
+ else if(fd=='-' && fname[1]==0)
+ {
+ fd= -1;
+ goto traceit;
+ }
+ else if(fd=='p' && fname[1]==0)
+ {
+ if(iof&IOPUT)
+ dupfd = sh.coutpipe;
+ else
+ dupfd = sh.cpipe[0];
+ if(flag)
+ toclose = dupfd;
+ }
+ else
+ {
+ message = e_file;
+ goto fail;
+ }
+ if(flag==SH_SHOWME)
+ goto traceit;
+ if((fd=sh_fcntl(dupfd,F_DUPFD,3))<0)
+ goto fail;
+ sh_iocheckfd(dupfd);
+ sh.fdstatus[fd] = (sh.fdstatus[dupfd]&~IOCLEX);
+ if(toclose<0 && sh.fdstatus[fd]&IOREAD)
+ sh.fdstatus[fd] |= IODUP;
+ else if(dupfd==sh.cpipe[0])
+ sh_pclose(sh.cpipe);
+ else if(toclose>=0)
+ {
+ if(flag==0)
+ sh_iosave(toclose,indx); /* save file descriptor */
+ sh_close(toclose);
+ }
+ }
+ else if(iof&IORDW)
+ {
+ if(sh_isoption(SH_RESTRICTED))
+ errormsg(SH_DICT,ERROR_exit(1),e_restricted,fname);
+ io_op[2] = '>';
+ o_mode = O_RDWR|O_CREAT;
+ goto openit;
+ }
+ else if(!(iof&IOPUT))
+ {
+ if(flag==SH_SHOWME)
+ goto traceit;
+ fd=sh_chkopen(fname);
+ }
+ else if(sh_isoption(SH_RESTRICTED))
+ errormsg(SH_DICT,ERROR_exit(1),e_restricted,fname);
+ else
+ {
+ if(iof&IOAPP)
+ {
+ io_op[2] = '>';
+ o_mode |= O_APPEND;
+ }
+ else
+ {
+ o_mode |= O_TRUNC;
+ if(iof&IOCLOB)
+ io_op[2] = '|';
+ else if(sh_isoption(SH_NOCLOBBER))
+ {
+ struct stat sb;
+ if(stat(fname,&sb)>=0)
+ {
+#if SHOPT_FS_3D
+ if(S_ISREG(sb.st_mode)&&
+ (!sh.lim.fs3d || iview(&sb)==0))
+#else
+ if(S_ISREG(sb.st_mode))
+#endif /* SHOPT_FS_3D */
+ {
+ errno = EEXIST;
+ errormsg(SH_DICT,ERROR_system(1),e_exists,fname);
+ }
+ }
+ else
+ o_mode |= O_EXCL;
+ }
+ }
+ openit:
+ if(flag!=SH_SHOWME)
+ {
+ if((fd=sh_open(fname,o_mode,RW_ALL)) <0)
+ errormsg(SH_DICT,ERROR_system(1),((o_mode&O_CREAT)?e_create:e_open),fname);
+ }
+ }
+ traceit:
+ if(traceon && fname)
+ {
+ if(np)
+ sfprintf(sfstderr,"{%s",nv_name(np));
+ sfprintf(sfstderr,"%s %s%s%c",io_op,fname,after,iop->ionxt?' ':'\n');
+ }
+ if(flag==SH_SHOWME)
+ return(indx);
+ if(trace && fname)
+ {
+ char *argv[7], **av=argv;
+ av[3] = io_op;
+ av[4] = fname;
+ av[5] = 0;
+ av[6] = 0;
+ if(iof&IOARITH)
+ av[5] = after;
+ if(np)
+ {
+ av[0] = "{";
+ av[1] = nv_name(np);
+ av[2] = "}";
+ }
+ else
+ av +=3;
+ sh_debug(trace,(char*)0,(char*)0,av,ARG_NOGLOB);
+ }
+ if(iof&IOLSEEK)
+ {
+ Sfio_t *sp = sh.sftable[fn];
+ r = sh.fdstatus[fn];
+ if(!(r&(IOSEEK|IONOSEEK)))
+ r = sh_iocheckfd(fn);
+ sfsprintf(io_op,sizeof(io_op),"%d\0",fn);
+ if(r==IOCLOSE)
+ {
+ fname = io_op;
+ message = e_file;
+ goto fail;
+ }
+ if(iof&IOARITH)
+ {
+ if(r&IONOSEEK)
+ {
+ fname = io_op;
+ message = e_notseek;
+ goto fail;
+ }
+ message = e_badseek;
+ if((off = file_offset(fn,fname))<0)
+ goto fail;
+ if(sp)
+ r=sfseek(sp, off, SEEK_SET);
+ else
+ r=lseek(fn, off, SEEK_SET);
+ }
+ else
+ {
+ regex_t *rp;
+ extern const char e_notimp[];
+ if(!(r&IOREAD))
+ {
+ message = e_noread;
+ goto fail;
+ }
+ if(!(rp = regcache(fname, REG_SHELL|REG_NOSUB|REG_NEWLINE|REG_AUGMENTED|REG_FIRST|REG_LEFT|REG_RIGHT, &r)))
+ {
+ message = e_badpattern;
+ goto fail;
+ }
+ if(!sp)
+ sp = sh_iostream(fn);
+ r=io_patseek(rp,sp,iof);
+ if(sp && flag==3)
+ {
+ /* close stream but not fn */
+ sfsetfd(sp,-1);
+ sfclose(sp);
+ }
+ }
+ if(r<0)
+ goto fail;
+ if(flag==3)
+ return(fn);
+ continue;
+ }
+ if(!np)
+ {
+ if(flag==0)
+ {
+ if(fd==fn)
+ {
+ if((r=sh_fcntl(fd,F_DUPFD,10)) > 0)
+ {
+ fd = r;
+ sh_close(fn);
+ }
+ }
+ sh_iosave(fn,indx);
+ }
+ else if(sh_subsavefd(fn))
+ sh_iosave(fn,indx|IOSUBSHELL);
+ }
+ if(fd<0)
+ {
+ if(sh_inuse(fn) || fn==sh.infd)
+ {
+ if(fn>9 || !(sh.inuse_bits&(1<<fn)))
+ io_preserve(sh.sftable[fn],fn);
+ }
+ sh_close(fn);
+ }
+ if(flag==3)
+ return(fd);
+ if(fd>=0)
+ {
+ if(np)
+ {
+ int32_t v;
+ fn = fd;
+ if(fd<10)
+ {
+ if((fn=fcntl(fd,F_DUPFD,10)) < 0)
+ goto fail;
+ sh.fdstatus[fn] = sh.fdstatus[fd];
+ sh_close(fd);
+ fd = fn;
+ }
+ nv_unset(np);
+ nv_onattr(np,NV_INT32);
+ v = fn;
+ nv_putval(np,(char*)&v, NV_INT32);
+ sh_iocheckfd(fd);
+ }
+ else
+ {
+ fd = sh_iorenumber(sh_iomovefd(fd),fn);
+ if(fn>2 && fn<10)
+ sh.inuse_bits |= (1<<fn);
+ }
+ }
+ if(fd >2 && clexec)
+ {
+ fcntl(fd,F_SETFD,FD_CLOEXEC);
+ sh.fdstatus[fd] |= IOCLEX;
+ }
+ }
+ else
+ goto fail;
+ }
+ return(indx);
+fail:
+ errormsg(SH_DICT,ERROR_system(1),message,fname);
+ /* NOTREACHED */
+ return(0);
+}
+/*
+ * Create a tmp file for the here-document
+ */
+static int io_heredoc(register struct ionod *iop, const char *name, int traceon)
+{
+ register Sfio_t *infile = 0, *outfile;
+ register int fd;
+ if(!(iop->iofile&IOSTRG) && (!sh.heredocs || iop->iosize==0))
+ return(sh_open(e_devnull,O_RDONLY));
+ /* create an unnamed temporary file */
+ if(!(outfile=sftmp(0)))
+ errormsg(SH_DICT,ERROR_system(1),e_tmpcreate);
+ if(iop->iofile&IOSTRG)
+ {
+ if(traceon)
+ sfprintf(sfstderr,"< %s\n",name);
+ sfputr(outfile,name,'\n');
+ }
+ else
+ {
+ infile = subopen(sh.heredocs,iop->iooffset,iop->iosize);
+ if(traceon)
+ {
+ char *cp = sh_fmtq(iop->iodelim);
+ fd = (*cp=='$' || *cp=='\'')?' ':'\\';
+ sfprintf(sfstderr," %c%s\n",fd,cp);
+ sfdisc(outfile,&tee_disc);
+ }
+ if(iop->iofile&IOQUOTE)
+ {
+ /* This is a quoted here-document, not expansion */
+ sfmove(infile,outfile,SF_UNBOUND,-1);
+ sfclose(infile);
+ }
+ else
+ {
+ char *lastpath = sh.lastpath;
+ sh_machere(infile,outfile,iop->ioname);
+ sh.lastpath = lastpath;
+ if(infile)
+ sfclose(infile);
+ }
+ }
+ /* close stream outfile, but save file descriptor */
+ fd = sffileno(outfile);
+ sfsetfd(outfile,-1);
+ sfclose(outfile);
+ if(traceon && !(iop->iofile&IOSTRG))
+ sfputr(sfstderr,iop->ioname,'\n');
+ lseek(fd,(off_t)0,SEEK_SET);
+ sh.fdstatus[fd] = IOREAD;
+ return(fd);
+}
+
+/*
+ * This write discipline also writes the output on standard error
+ * This is used when tracing here-documents
+ */
+static ssize_t tee_write(Sfio_t *iop,const void *buff,size_t n,Sfdisc_t *unused)
+{
+ NOT_USED(unused);
+ sfwrite(sfstderr,buff,n);
+ return(write(sffileno(iop),buff,n));
+}
+
+/*
+ * copy file <origfd> into a save place
+ * The saved file is set close-on-exec
+ * if <origfd> < 0, then -origfd is saved, but not duped so that it
+ * will be closed with sh_iorestore.
+ */
+void sh_iosave(register int origfd, int oldtop)
+{
+/*@
+ assume oldtop>=0 && oldtop<sh.lim.open_max;
+@*/
+
+ register int savefd;
+ int flag = (oldtop&IOSUBSHELL);
+ oldtop &= ~IOSUBSHELL;
+ /* see if already saved, only save once */
+ for(savefd=sh.topfd; --savefd>=oldtop; )
+ {
+ if(filemap[savefd].orig_fd == origfd)
+ return;
+ }
+ /* make sure table is large enough */
+ if(sh.topfd >= filemapsize)
+ {
+ filemapsize += 8;
+ if(!(filemap = (struct fdsave*)realloc(filemap,filemapsize*sizeof(struct fdsave))))
+ errormsg(SH_DICT,ERROR_exit(4),e_nospace);
+
+ }
+#if SHOPT_DEVFD
+ if(origfd <0)
+ {
+ savefd = origfd;
+ origfd = -origfd;
+ }
+ else
+#endif /* SHOPT_DEVFD */
+ {
+ if((savefd = sh_fcntl(origfd, F_DUPFD, 10)) < 0 && errno!=EBADF)
+ errormsg(SH_DICT,ERROR_system(1),e_toomany);
+ }
+ filemap[sh.topfd].subshell = flag;
+ filemap[sh.topfd].orig_fd = origfd;
+ filemap[sh.topfd++].save_fd = savefd;
+ if(savefd >=0)
+ {
+ register Sfio_t* sp = sh.sftable[origfd];
+ /* make saved file close-on-exec */
+ sh_fcntl(savefd,F_SETFD,FD_CLOEXEC);
+ if(origfd==job.fd)
+ job.fd = savefd;
+ sh.fdstatus[savefd] = sh.fdstatus[origfd];
+ sh.fdptrs[savefd] = &filemap[sh.topfd-1].save_fd;
+ if(!(sh.sftable[savefd]=sp))
+ return;
+ sfsync(sp);
+ if(origfd <=2)
+ {
+ /* copy standard stream to new stream */
+ sp = sfswap(sp,NIL(Sfio_t*));
+ sh.sftable[savefd] = sp;
+ }
+ else
+ sh.sftable[origfd] = 0;
+ }
+}
+
+/*
+ * close all saved file descriptors
+ */
+void sh_iounsave(void)
+{
+ register int fd, savefd, newfd;
+ for(newfd=fd=0; fd < sh.topfd; fd++)
+ {
+ if((savefd = filemap[fd].save_fd)< 0)
+ filemap[newfd++] = filemap[fd];
+ else
+ {
+ sh.sftable[savefd] = 0;
+ sh_close(savefd);
+ }
+ }
+ sh.topfd = newfd;
+}
+
+/*
+ * restore saved file descriptors from <last> on
+ */
+void sh_iorestore(int last, int jmpval)
+{
+ register int origfd, savefd, fd;
+ int flag = (last&IOSUBSHELL);
+ last &= ~IOSUBSHELL;
+ for (fd = sh.topfd - 1; fd >= last; fd--)
+ {
+ if(!flag && filemap[fd].subshell)
+ continue;
+ if(jmpval==SH_JMPSCRIPT)
+ {
+ if ((savefd = filemap[fd].save_fd) >= 0)
+ {
+ sh.sftable[savefd] = 0;
+ sh_close(savefd);
+ }
+ continue;
+ }
+ origfd = filemap[fd].orig_fd;
+ sh_close(origfd);
+ if ((savefd = filemap[fd].save_fd) >= 0)
+ {
+ sh_fcntl(savefd, F_DUPFD, origfd);
+ if(savefd==job.fd)
+ job.fd=origfd;
+ sh.fdstatus[origfd] = sh.fdstatus[savefd];
+ /* turn off close-on-exec if flag if necessary */
+ if(sh.fdstatus[origfd]&IOCLEX)
+ fcntl(origfd,F_SETFD,FD_CLOEXEC);
+ if(origfd<=2)
+ {
+ sfswap(sh.sftable[savefd],sh.sftable[origfd]);
+ if(origfd==0)
+ sh.st.ioset = 0;
+ }
+ else
+ sh.sftable[origfd] = sh.sftable[savefd];
+ sh.sftable[savefd] = 0;
+ sh_close(savefd);
+ }
+ else
+ sh.fdstatus[origfd] = IOCLOSE;
+ }
+ if(!flag)
+ {
+ /* keep file descriptors for subshell restore */
+ for (fd = last ; fd < sh.topfd; fd++)
+ {
+ if(filemap[fd].subshell)
+ filemap[last++] = filemap[fd];
+ }
+ }
+ if(last < sh.topfd)
+ sh.topfd = last;
+}
+
+/*
+ * returns access information on open file <fd>
+ * returns -1 for failure, 0 for success
+ * <mode> is the same as for access()
+ */
+int sh_ioaccess(int fd,register int mode)
+{
+ register int flags;
+ if(mode==X_OK)
+ return(-1);
+ if((flags=sh_iocheckfd(fd))!=IOCLOSE)
+ {
+ if(mode==F_OK)
+ return(0);
+ if(mode==R_OK && (flags&IOREAD))
+ return(0);
+ if(mode==W_OK && (flags&IOWRITE))
+ return(0);
+ }
+ return(-1);
+}
+
+/*
+ * Handle interrupts for slow streams
+ */
+static int slowexcept(register Sfio_t *iop,int type,void *data,Sfdisc_t *handle)
+{
+ register int n,fno;
+ NOT_USED(handle);
+ if(type==SF_DPOP || type==SF_FINAL)
+ free((void*)handle);
+ if(type!=SF_READ)
+ return(0);
+ if((sh.trapnote&(SH_SIGSET|SH_SIGTRAP)) && errno!=EIO && errno!=ENXIO)
+ errno = EINTR;
+ fno = sffileno(iop);
+ if((n=sfvalue(iop))<=0)
+ {
+#ifndef FNDELAY
+# ifdef O_NDELAY
+ if(errno==0 && (n=fcntl(fno,F_GETFL,0))&O_NDELAY)
+ {
+ n &= ~O_NDELAY;
+ fcntl(fno, F_SETFL, n);
+ return(1);
+ }
+# endif /* O_NDELAY */
+#endif /* !FNDELAY */
+#ifdef O_NONBLOCK
+ if(errno==EAGAIN)
+ {
+ n = fcntl(fno,F_GETFL,0);
+ n &= ~O_NONBLOCK;
+ fcntl(fno, F_SETFL, n);
+ return(1);
+ }
+#endif /* O_NONBLOCK */
+ if(errno!=EINTR)
+ return(0);
+ n=1;
+ }
+ errno = 0;
+ if(sh.trapnote&SH_SIGSET)
+ {
+ if(isatty(fno))
+ sfputc(sfstderr,'\n');
+ sh_exit(SH_EXITSIG);
+ }
+ if(sh.trapnote&SH_SIGTRAP)
+ sh_chktrap();
+ return(n);
+}
+
+/*
+ * called when slowread times out
+ */
+static void time_grace(void *handle)
+{
+ NOT_USED(handle);
+ timeout = 0;
+ if(sh_isstate(SH_GRACE))
+ {
+ sh_offstate(SH_GRACE);
+ if(!sh_isstate(SH_INTERACTIVE))
+ return;
+ ((struct checkpt*)sh.jmplist)->mode = SH_JMPEXIT;
+ errormsg(SH_DICT,2,e_timeout);
+ sh.trapnote |= SH_SIGSET;
+ return;
+ }
+ errormsg(SH_DICT,0,e_timewarn);
+ sh_onstate(SH_GRACE);
+ sigrelease(SIGALRM);
+ sh.trapnote |= SH_SIGTRAP;
+}
+
+static ssize_t piperead(Sfio_t *iop,void *buff,register size_t size,Sfdisc_t *handle)
+{
+ int fd = sffileno(iop);
+ NOT_USED(handle);
+ if(sh.trapnote)
+ {
+ errno = EINTR;
+ return(-1);
+ }
+ if(sh_isstate(SH_INTERACTIVE) && io_prompt(iop,sh.nextprompt)<0 && errno==EIO)
+ return(0);
+ if(!(sh.fdstatus[sffileno(iop)]&IOCLEX) && (sfset(iop,0,0)&SF_SHARE))
+ size = ed_read(sh.ed_context, fd, (char*)buff, size,0);
+ else
+ size = sfrd(iop,buff,size,handle);
+ return(size);
+}
+/*
+ * This is the read discipline that is applied to slow devices
+ * This routine takes care of prompting for input
+ */
+static ssize_t slowread(Sfio_t *iop,void *buff,register size_t size,Sfdisc_t *handle)
+{
+ int (*readf)(void*, int, char*, int, int);
+ int reedit=0, rsize;
+#if SHOPT_HISTEXPAND
+ char *xp=0;
+#endif
+ NOT_USED(handle);
+# if SHOPT_ESH
+ if(sh_isoption(SH_EMACS) || sh_isoption(SH_GMACS))
+ readf = ed_emacsread;
+ else
+# endif /* SHOPT_ESH */
+# if SHOPT_VSH
+# if SHOPT_RAWONLY
+ if(sh_isoption(SH_VI) || ((SHOPT_RAWONLY-0) && mbwide()))
+# else
+ if(sh_isoption(SH_VI))
+# endif
+ readf = ed_viread;
+ else
+# endif /* SHOPT_VSH */
+ readf = ed_read;
+ if(sh.trapnote)
+ {
+ errno = EINTR;
+ return(-1);
+ }
+ while(1)
+ {
+ if(io_prompt(iop,sh.nextprompt)<0 && errno==EIO)
+ return(0);
+ if(sh.timeout)
+ timeout = (void*)sh_timeradd(sh_isstate(SH_GRACE)?1000L*TGRACE:1000L*sh.timeout,0,time_grace,NIL(void*));
+ rsize = (*readf)(sh.ed_context, sffileno(iop), (char*)buff, size, reedit);
+ if(timeout)
+ timerdel(timeout);
+ timeout=0;
+#if SHOPT_HISTEXPAND
+ if(rsize && *(char*)buff != '\n' && sh.nextprompt==1 && sh_isoption(SH_HISTEXPAND))
+ {
+ int r;
+ ((char*)buff)[rsize] = '\0';
+ if(xp)
+ {
+ free(xp);
+ xp = 0;
+ }
+ r = hist_expand(buff, &xp);
+ if((r & (HIST_EVENT|HIST_PRINT)) && !(r & HIST_ERROR) && xp)
+ {
+ strlcpy(buff, xp, size);
+ rsize = strlen(buff);
+ if(!sh_isoption(SH_HISTVERIFY) || readf==ed_read)
+ {
+ sfputr(sfstderr, xp, -1);
+ break;
+ }
+ reedit = rsize - 1;
+ continue;
+ }
+ if((r & HIST_ERROR) && sh_isoption(SH_HISTREEDIT))
+ {
+ reedit = rsize - 1;
+ continue;
+ }
+ if(r & (HIST_ERROR|HIST_PRINT))
+ {
+ *(char*)buff = '\n';
+ rsize = 1;
+ }
+ }
+#endif
+ break;
+ }
+ return(rsize);
+}
+
+/*
+ * check and return the attributes for a file descriptor
+ */
+
+int sh_iocheckfd(register int fd)
+{
+ register int flags, n;
+ if((n=sh.fdstatus[fd])&IOCLOSE)
+ return(n);
+ if(!(n&(IOREAD|IOWRITE)))
+ {
+#ifdef F_GETFL
+ if((flags=fcntl(fd,F_GETFL,0)) < 0)
+ return(sh.fdstatus[fd]=IOCLOSE);
+ if((flags&O_ACCMODE)!=O_WRONLY)
+ n |= IOREAD;
+ if((flags&O_ACCMODE)!=O_RDONLY)
+ n |= IOWRITE;
+#else
+ struct stat statb;
+ if((flags = fstat(fd,&statb))< 0)
+ return(sh.fdstatus[fd]=IOCLOSE);
+ n |= (IOREAD|IOWRITE);
+ if(read(fd,"",0) < 0)
+ n &= ~IOREAD;
+#endif /* F_GETFL */
+ }
+ if(!(n&(IOSEEK|IONOSEEK)))
+ {
+ struct stat statb;
+ /* /dev/null check is a workaround for select bug */
+ static ino_t null_ino;
+ static dev_t null_dev;
+ if(null_ino==0 && stat(e_devnull,&statb) >=0)
+ {
+ null_ino = statb.st_ino;
+ null_dev = statb.st_dev;
+ }
+ if(tty_check(fd))
+ n |= IOTTY;
+ if(lseek(fd,NIL(off_t),SEEK_CUR)<0)
+ {
+ n |= IONOSEEK;
+#ifdef S_ISSOCK
+ if((fstat(fd,&statb)>=0) && S_ISSOCK(statb.st_mode))
+ n |= IOREAD|IOWRITE;
+#endif /* S_ISSOCK */
+ }
+ else if((fstat(fd,&statb)>=0) && (
+ S_ISFIFO(statb.st_mode) ||
+#ifdef S_ISSOCK
+ S_ISSOCK(statb.st_mode) ||
+#endif /* S_ISSOCK */
+ /* The following is for sockets on the sgi */
+ (statb.st_ino==0 && (statb.st_mode & ~(S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR|S_IWGRP|S_IWOTH|S_IXUSR|S_IXGRP|S_IXOTH|S_ISUID|S_ISGID))==0) ||
+ (S_ISCHR(statb.st_mode) && (statb.st_ino!=null_ino || statb.st_dev!=null_dev))
+ ))
+ n |= IONOSEEK;
+ else
+ n |= IOSEEK;
+ }
+ sh.fdstatus[fd] = n;
+ return(n);
+}
+
+/*
+ * Display prompt PS<flag> on standard error
+ */
+
+static int io_prompt(Sfio_t *iop,register int flag)
+{
+ register char *cp;
+ char buff[1];
+ char *endprompt;
+ static short cmdno;
+ int sfflags;
+ if(flag<3 && !sh_isstate(SH_INTERACTIVE))
+ flag = 0;
+ if(flag==2 && sfpkrd(sffileno(iop),buff,1,'\n',0,1) >= 0)
+ flag = 0;
+ if(flag==0)
+ return(sfsync(sfstderr));
+ sfflags = sfset(sfstderr,SF_SHARE|SF_PUBLIC|SF_READ,0);
+ if(!(sh.prompt=(char*)sfreserve(sfstderr,0,0)))
+ sh.prompt = "";
+ switch(flag)
+ {
+ case 1:
+ {
+ register int c;
+#if defined(TIOCLBIC) && defined(LFLUSHO)
+ if(!sh_isoption(SH_VI) && !sh_isoption(SH_EMACS) && !sh_isoption(SH_GMACS))
+ {
+ /*
+ * re-enable output in case the user has
+ * disabled it. Not needed with edit mode
+ */
+ int mode = LFLUSHO;
+ ioctl(sffileno(sfstderr),TIOCLBIC,&mode);
+ }
+#endif /* TIOCLBIC */
+ cp = sh_mactry(nv_getval(nv_scoped(PS1NOD)));
+ for(;c= *cp;cp++)
+ {
+ if(c==HIST_CHAR)
+ {
+ /* look at next character */
+ c = *++cp;
+ /* print out line number if not !! */
+ if(c!= HIST_CHAR)
+ {
+ sfprintf(sfstderr,"%d", sh.hist_ptr?(int)sh.hist_ptr->histind:++cmdno);
+ }
+ if(c==0)
+ goto done;
+ }
+ sfputc(sfstderr,c);
+ }
+ goto done;
+ }
+ case 2:
+ cp = nv_getval(nv_scoped(PS2NOD));
+ break;
+ case 3:
+ cp = nv_getval(nv_scoped(PS3NOD));
+ break;
+ default:
+ goto done;
+ }
+ if(cp)
+ sfputr(sfstderr,cp,-1);
+done:
+ if(*sh.prompt && (endprompt=(char*)sfreserve(sfstderr,0,0)))
+ *endprompt = 0;
+ sfset(sfstderr,sfflags&SF_READ|SF_SHARE|SF_PUBLIC,1);
+ return(sfsync(sfstderr));
+}
+
+/*
+ * This discipline is inserted on write pipes to prevent SIGPIPE
+ * from causing an infinite loop
+ */
+static int pipeexcept(Sfio_t* iop, int mode, void *data, Sfdisc_t* handle)
+{
+ NOT_USED(iop);
+ if(mode==SF_DPOP || mode==SF_FINAL)
+ free((void*)handle);
+ else if(mode==SF_WRITE && errno==EINTR && sh.lastsig==SIGPIPE)
+ return(-1);
+ return(0);
+}
+
+/*
+ * keep track of each stream that is opened and closed
+ */
+static void sftrack(Sfio_t* sp,int flag, int newfd)
+{
+ register int fd = sffileno(sp);
+ register struct checkpt *pp;
+ register int mode;
+ if(flag==SF_SETFD || flag==SF_CLOSING)
+ {
+ if(newfd<0)
+ flag = SF_CLOSING;
+ if(fdnotify)
+ (*fdnotify)(sffileno(sp),flag==SF_CLOSING?-1:newfd);
+ }
+#ifdef DEBUG
+ if(flag==SF_READ || flag==SF_WRITE)
+ {
+ char *z = fmtbase((long)getpid(),0,0);
+ write(ERRIO,z,strlen(z));
+ write(ERRIO,": ",2);
+ write(ERRIO,"attempt to ",11);
+ if(flag==SF_READ)
+ write(ERRIO,"read from",9);
+ else
+ write(ERRIO,"write to",8);
+ write(ERRIO," locked stream\n",15);
+ return;
+ }
+#endif
+ if((unsigned)fd >= sh.lim.open_max)
+ return;
+ if(sh_isstate(SH_NOTRACK))
+ return;
+ mode = sfset(sp,0,0);
+ if(sp==sh.heredocs && fd < 10 && flag==SF_NEW)
+ {
+ fd = sfsetfd(sp,10);
+ fcntl(fd,F_SETFD,FD_CLOEXEC);
+ }
+ if(fd < 3)
+ return;
+ if(flag==SF_NEW)
+ {
+ if(!sh.sftable[fd] && sh.fdstatus[fd]==IOCLOSE)
+ {
+ sh.sftable[fd] = sp;
+ flag = (mode&SF_WRITE)?IOWRITE:0;
+ if(mode&SF_READ)
+ flag |= IOREAD;
+ sh.fdstatus[fd] = flag;
+#if 0
+ if(flag==IOWRITE)
+ sfpool(sp,sh.outpool,SF_WRITE);
+ else
+#else
+ if(flag!=IOWRITE)
+#endif
+ sh_iostream(fd);
+ }
+ if((pp=(struct checkpt*)sh.jmplist) && pp->mode==SH_JMPCMD)
+ {
+ struct openlist *item;
+ /*
+ * record open file descriptors so they can
+ * be closed in case a longjmp prevents
+ * built-ins from cleanup
+ */
+ item = new_of(struct openlist, 0);
+ item->strm = sp;
+ item->next = pp->olist;
+ pp->olist = item;
+ }
+ if(fdnotify)
+ (*fdnotify)(-1,sffileno(sp));
+ }
+ else if(flag==SF_CLOSING || (flag==SF_SETFD && newfd<=2))
+ {
+ sh.sftable[fd] = 0;
+ sh.fdstatus[fd]=IOCLOSE;
+ if(pp=(struct checkpt*)sh.jmplist)
+ {
+ struct openlist *item;
+ for(item=pp->olist; item; item=item->next)
+ {
+ if(item->strm == sp)
+ {
+ item->strm = 0;
+ break;
+ }
+ }
+ }
+ }
+}
+
+struct eval
+{
+ Sfdisc_t disc;
+ char **argv;
+ short slen;
+ char addspace;
+};
+
+/*
+ * Create a stream consisting of a space separated argv[] list
+ */
+
+Sfio_t *sh_sfeval(register char *argv[])
+{
+ register Sfio_t *iop;
+ register char *cp;
+ if(argv[1])
+ cp = "";
+ else
+ cp = argv[0];
+ iop = sfopen(NIL(Sfio_t*),(char*)cp,"s");
+ if(argv[1])
+ {
+ register struct eval *ep;
+ if(!(ep = new_of(struct eval,0)))
+ return(NIL(Sfio_t*));
+ ep->disc = eval_disc;
+ ep->argv = argv;
+ ep->slen = -1;
+ ep->addspace = 0;
+ sfdisc(iop,&ep->disc);
+ }
+ return(iop);
+}
+
+/*
+ * This code gets called whenever an end of string is found with eval
+ */
+
+static int eval_exceptf(Sfio_t *iop,int type, void *data, Sfdisc_t *handle)
+{
+ register struct eval *ep = (struct eval*)handle;
+ register char *cp;
+ register int len;
+
+ /* no more to do */
+ if(type!=SF_READ || !(cp = ep->argv[0]))
+ {
+ if(type==SF_CLOSING)
+ sfdisc(iop,SF_POPDISC);
+ else if(ep && (type==SF_DPOP || type==SF_FINAL))
+ free((void*)ep);
+ return(0);
+ }
+
+ if(!ep->addspace)
+ {
+ /* get the length of this string */
+ ep->slen = len = strlen(cp);
+ /* move to next string */
+ ep->argv++;
+ }
+ else /* insert space between arguments */
+ {
+ len = 1;
+ cp = " ";
+ }
+ /* insert the new string */
+ sfsetbuf(iop,cp,len);
+ ep->addspace = !ep->addspace;
+ return(1);
+}
+
+/*
+ * This routine returns a stream pointer to a segment of length <size> from
+ * the stream <sp> starting at offset <offset>
+ * The stream can be read with the normal stream operations
+ */
+
+static Sfio_t *subopen(Sfio_t* sp, off_t offset, long size)
+{
+ register struct subfile *disp;
+ if(sfseek(sp,offset,SEEK_SET) <0)
+ return(NIL(Sfio_t*));
+ if(!(disp = (struct subfile*)malloc(sizeof(struct subfile)+IOBSIZE+1)))
+ return(NIL(Sfio_t*));
+ disp->disc = sub_disc;
+ disp->oldsp = sp;
+ disp->offset = offset;
+ disp->size = disp->left = size;
+ sp = sfnew(NIL(Sfio_t*),(char*)(disp+1),IOBSIZE,sh.lim.open_max,SF_READ);
+ sfdisc(sp,&disp->disc);
+ return(sp);
+}
+
+/*
+ * read function for subfile discipline
+ */
+static ssize_t subread(Sfio_t* sp,void* buff,register size_t size,Sfdisc_t* handle)
+{
+ register struct subfile *disp = (struct subfile*)handle;
+ NOT_USED(sp);
+ if(disp->left == 0)
+ return(0);
+ if(size > disp->left)
+ size = disp->left;
+ disp->left -= size;
+ return(sfread(disp->oldsp,buff,size));
+}
+
+/*
+ * exception handler for subfile discipline
+ */
+static int subexcept(Sfio_t* sp,register int mode, void *data, Sfdisc_t* handle)
+{
+ register struct subfile *disp = (struct subfile*)handle;
+ if(mode==SF_CLOSING)
+ {
+ sfdisc(sp,SF_POPDISC);
+ return(0);
+ }
+ else if(disp && (mode==SF_DPOP || mode==SF_FINAL))
+ {
+ free((void*)disp);
+ return(0);
+ }
+#ifdef SF_ATEXIT
+ else if (mode==SF_ATEXIT)
+ {
+ sfdisc(sp, SF_POPDISC);
+ return(0);
+ }
+#endif
+ else if(mode==SF_READ)
+ return(0);
+ return(-1);
+}
+
+#define NROW 15 /* number of rows before going to multi-columns */
+#define LBLSIZ 3 /* size of label field and interfield spacing */
+/*
+ * print a list of arguments in columns
+ */
+void sh_menu(Sfio_t *outfile,int argn,char *argv[])
+{
+ register int i,j;
+ register char **arg;
+ int nrow, ncol=1, ndigits=1;
+ int fldsize, wsize = ed_window();
+ char *cp = nv_getval(nv_scoped(LINES));
+ nrow = (cp?1+2*((int)strtol(cp, (char**)0, 10)/3):NROW);
+ for(i=argn;i >= 10;i /= 10)
+ ndigits++;
+ if(argn < nrow)
+ {
+ nrow = argn;
+ goto skip;
+ }
+ i = 0;
+ for(arg=argv; *arg;arg++)
+ {
+ if((j=strlen(*arg)) > i)
+ i = j;
+ }
+ i += (ndigits+LBLSIZ);
+ if(i < wsize)
+ ncol = wsize/i;
+ if(argn > nrow*ncol)
+ {
+ nrow = 1 + (argn-1)/ncol;
+ }
+ else
+ {
+ ncol = 1 + (argn-1)/nrow;
+ nrow = 1 + (argn-1)/ncol;
+ }
+skip:
+ fldsize = (wsize/ncol)-(ndigits+LBLSIZ);
+ for(i=0;i<nrow;i++)
+ {
+ if(sh.trapnote&SH_SIGSET)
+ return;
+ j = i;
+ while(1)
+ {
+ arg = argv+j;
+ sfprintf(outfile,"%*d) %s",ndigits,j+1,*arg);
+ j += nrow;
+ if(j >= argn)
+ break;
+ sfnputc(outfile,' ',fldsize-strlen(*arg));
+ }
+ sfputc(outfile,'\n');
+ }
+}
+
+#undef read
+/*
+ * shell version of read() for user added builtins
+ */
+ssize_t sh_read(register int fd, void* buff, size_t n)
+{
+ register Sfio_t *sp;
+ if(sp=sh.sftable[fd])
+ return(sfread(sp,buff,n));
+ else
+ return(read(fd,buff,n));
+}
+
+#undef write
+/*
+ * shell version of write() for user added builtins
+ */
+ssize_t sh_write(register int fd, const void* buff, size_t n)
+{
+ register Sfio_t *sp;
+ if(sp=sh.sftable[fd])
+ return(sfwrite(sp,buff,n));
+ else
+ return(write(fd,buff,n));
+}
+
+#undef lseek
+/*
+ * shell version of lseek() for user added builtins
+ */
+off_t sh_seek(register int fd, off_t offset, int whence)
+{
+ register Sfio_t *sp;
+ if((sp=sh.sftable[fd]) && (sfset(sp,0,0)&(SF_READ|SF_WRITE)))
+ return(sfseek(sp,offset,whence));
+ else
+ return(lseek(fd,offset,whence));
+}
+
+#undef dup
+int sh_dup(register int old)
+{
+ register int fd = dup(old);
+ if(fd>=0)
+ {
+ if(sh.fdstatus[old] == IOCLOSE)
+ sh.fdstatus[old] = 0;
+ sh.fdstatus[fd] = (sh.fdstatus[old]&~IOCLEX);
+ if(fdnotify)
+ (*fdnotify)(old,fd);
+ }
+ return(fd);
+}
+
+#undef fcntl
+int sh_fcntl(register int fd, int op, ...)
+{
+ int newfd, arg;
+ va_list ap;
+ va_start(ap, op);
+ arg = va_arg(ap, int) ;
+ va_end(ap);
+ newfd = fcntl(fd,op,arg);
+ if(newfd>=0) switch(op)
+ {
+ case F_DUPFD:
+ if(sh.fdstatus[fd] == IOCLOSE)
+ sh.fdstatus[fd] = 0;
+ sh.fdstatus[newfd] = (sh.fdstatus[fd]&~IOCLEX);
+ if(fdnotify)
+ (*fdnotify)(fd,newfd);
+ break;
+ case F_SETFD:
+ if(sh.fdstatus[fd] == IOCLOSE)
+ sh.fdstatus[fd] = 0;
+ if(arg&FD_CLOEXEC)
+ sh.fdstatus[fd] |= IOCLEX;
+ else
+ sh.fdstatus[fd] &= ~IOCLEX;
+ }
+ return(newfd);
+}
+
+#undef umask
+mode_t sh_umask(mode_t m)
+{
+ sh.mask = m;
+ return(umask(m));
+}
+
+/*
+ * give file descriptor <fd> and <mode>, return an iostream pointer
+ * <mode> must be SF_READ or SF_WRITE
+ * <fd> must be a non-negative number ofr SH_IOCOPROCESS or SH_IOHISTFILE.
+ * returns NULL on failure and may set errno.
+ */
+
+Sfio_t *sh_iogetiop(int fd, int mode)
+{
+ int n;
+ Sfio_t *iop=0;
+ if(mode!=SF_READ && mode!=SF_WRITE)
+ {
+ errno = EINVAL;
+ return(iop);
+ }
+ switch(fd)
+ {
+ case SH_IOHISTFILE:
+ if(!sh_histinit())
+ return(iop);
+ fd = sffileno(sh.hist_ptr->histfp);
+ break;
+ case SH_IOCOPROCESS:
+ if(mode==SF_WRITE)
+ fd = sh.coutpipe;
+ else
+ fd = sh.cpipe[0];
+ break;
+ default:
+ if(fd<0 || fd >= sh.lim.open_max)
+ fd = -1;
+ }
+ if(fd<0)
+ {
+ errno = EBADF;
+ return(iop);
+ }
+ if(!(n=sh.fdstatus[fd]))
+ n = sh_iocheckfd(fd);
+ if(mode==SF_WRITE && !(n&IOWRITE))
+ return(iop);
+ if(mode==SF_READ && !(n&IOREAD))
+ return(iop);
+ if(!(iop = sh.sftable[fd]))
+ iop=sh_iostream(fd);
+ return(iop);
+}
+
+typedef int (*Notify_f)(int,int);
+
+Notify_f sh_fdnotify(Notify_f notify)
+{
+ Notify_f old;
+ old = fdnotify;
+ fdnotify = notify;
+ return(old);
+}
+
+Sfio_t *sh_fd2sfio(int fd)
+{
+ register int status;
+ Sfio_t *sp = sh.sftable[fd];
+ if(!sp && (status = sh_iocheckfd(fd))!=IOCLOSE)
+ {
+ register int flags=0;
+ if(status&IOREAD)
+ flags |= SF_READ;
+ if(status&IOWRITE)
+ flags |= SF_WRITE;
+ sp = sfnew(NULL, NULL, -1, fd,flags);
+ sh.sftable[fd] = sp;
+ }
+ return(sp);
+}
+
+Sfio_t *sh_pathopen(const char *cp)
+{
+ int n;
+#ifdef PATH_BFPATH
+ if((n=path_open(cp,path_get(cp))) < 0)
+ n = path_open(cp,(Pathcomp_t*)0);
+#else
+ if((n=path_open(cp,path_get(cp))) < 0)
+ n = path_open(cp,"");
+#endif
+ if(n < 0)
+ errormsg(SH_DICT,ERROR_system(1),e_open,cp);
+ return(sh_iostream(n));
+}
diff --git a/usr/src/lib/libshell/common/sh/jobs.c b/usr/src/lib/libshell/common/sh/jobs.c
new file mode 100644
index 0000000000..d397810f3d
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/jobs.c
@@ -0,0 +1,1706 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Job control for UNIX Shell
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ * Written October, 1982
+ * Rewritten April, 1988
+ * Revised January, 1992
+ */
+
+#include "defs.h"
+#include <ctype.h>
+#include <wait.h>
+#include "io.h"
+#include "jobs.h"
+#include "history.h"
+
+#if !defined(WCONTINUED) || !defined(WIFCONTINUED)
+# undef WCONTINUED
+# define WCONTINUED 0
+# undef WIFCONTINUED
+# define WIFCONTINUED(wstat) (0)
+#endif
+
+#define NJOB_SAVELIST 4
+
+/*
+ * temporary hack to get W* macros to work
+ */
+#undef wait
+#define wait ______wait
+/*
+ * This struct saves a link list of processes that have non-zero exit
+ * status, have had $! saved, but haven't been waited for
+ */
+struct jobsave
+{
+ struct jobsave *next;
+ pid_t pid;
+ unsigned short exitval;
+};
+
+static struct jobsave *job_savelist;
+static int njob_savelist;
+
+static void init_savelist(void)
+{
+ register struct jobsave *jp;
+ while(njob_savelist < NJOB_SAVELIST)
+ {
+ jp = newof(0,struct jobsave,1,0);
+ jp->next = job_savelist;
+ job_savelist = jp;
+ njob_savelist++;
+ }
+}
+
+/*
+ * return next on link list of jobsave free list
+ */
+static struct jobsave *jobsave_create(pid_t pid)
+{
+ register struct jobsave *jp = job_savelist;
+ if(jp)
+ {
+ njob_savelist--;
+ job_savelist = jp->next;
+ }
+ else
+ jp = newof(0,struct jobsave,1,0);
+ if(jp)
+ jp->pid = pid;
+ return(jp);
+}
+
+struct back_save
+{
+ int count;
+ struct jobsave *list;
+};
+
+#define BYTE(n) (((n)+CHAR_BIT-1)/CHAR_BIT)
+#define MAXMSG 25
+#define SH_STOPSIG (SH_EXITSIG<<1)
+
+#ifdef VSUSP
+# ifndef CNSUSP
+# ifdef _POSIX_VDISABLE
+# define CNSUSP _POSIX_VDISABLE
+# else
+# define CNSUSP 0
+# endif /* _POSIX_VDISABLE */
+# endif /* CNSUSP */
+# ifndef CSWTCH
+# ifdef CSUSP
+# define CSWTCH CSUSP
+# else
+# define CSWTCH ('z'&037)
+# endif /* CSUSP */
+# endif /* CSWTCH */
+#endif /* VSUSP */
+
+/* Process states */
+#define P_EXITSAVE 01
+#define P_STOPPED 02
+#define P_NOTIFY 04
+#define P_SIGNALLED 010
+#define P_STTY 020
+#define P_DONE 040
+#define P_COREDUMP 0100
+#define P_DISOWN 0200
+#define P_FG 0400
+
+static int job_chksave(pid_t);
+static struct process *job_bypid(pid_t);
+static struct process *job_byjid(int);
+static char *job_sigmsg(int);
+static int job_alloc(void);
+static void job_free(int);
+static struct process *job_unpost(struct process*,int);
+static void job_unlink(struct process*);
+static void job_prmsg(struct process*);
+static struct process *freelist;
+static char beenhere;
+static char possible;
+static struct process dummy;
+static char by_number;
+static Sfio_t *outfile;
+static pid_t lastpid;
+static struct back_save bck;
+
+
+#ifdef JOBS
+ static void job_set(struct process*);
+ static void job_reset(struct process*);
+ static void job_waitsafe(int);
+ static struct process *job_byname(char*);
+ static struct process *job_bystring(char*);
+ static struct termios my_stty; /* terminal state for shell */
+ static char *job_string;
+#else
+ extern const char e_coredump[];
+#endif /* JOBS */
+
+#ifdef SIGTSTP
+ static void job_unstop(struct process*);
+ static void job_fgrp(struct process*, int);
+# ifndef _lib_tcgetpgrp
+# ifdef TIOCGPGRP
+ static int _i_;
+# define tcgetpgrp(a) (ioctl(a, TIOCGPGRP, &_i_)>=0?_i_:-1)
+# endif /* TIOCGPGRP */
+ int tcsetpgrp(int fd,pid_t pgrp)
+ {
+ int pgid = pgrp;
+# ifdef TIOCGPGRP
+ return(ioctl(fd, TIOCSPGRP, &pgid));
+# else
+ return(-1);
+# endif /* TIOCGPGRP */
+ }
+# endif /* _lib_tcgetpgrp */
+#else
+# define job_unstop(pw)
+# undef CNSUSP
+#endif /* SIGTSTP */
+
+#ifndef OTTYDISC
+# undef NTTYDISC
+#endif /* OTTYDISC */
+
+#ifdef JOBS
+
+typedef int (*Waitevent_f)(int,long,int);
+
+/*
+ * Reap one job
+ * When called with sig==0, it does a blocking wait
+ */
+int job_reap(register int sig)
+{
+ register pid_t pid;
+ register struct process *pw;
+ struct process *px;
+ register int flags;
+ struct process dummy;
+ struct jobsave *jp;
+ int nochild=0, oerrno, wstat;
+ Waitevent_f waitevent = sh.waitevent;
+ static int wcontinued = WCONTINUED;
+#ifdef DEBUG
+ if(sfprintf(sfstderr,"ksh: job line %4d: reap pid=%d critical=%d signal=%d\n",__LINE__,getpid(),job.in_critical,sig) <=0)
+ write(2,"waitsafe\n",9);
+ sfsync(sfstderr);
+#endif /* DEBUG */
+ job.savesig = 0;
+ if(sig)
+ flags = WNOHANG|WUNTRACED|wcontinued;
+ else
+ flags = WUNTRACED|wcontinued;
+ sh.waitevent = 0;
+ oerrno = errno;
+ while(1)
+ {
+ if(!(flags&WNOHANG) && !sh.intrap && waitevent && job.pwlist)
+ {
+ if((*waitevent)(-1,-1L,0))
+ flags |= WNOHANG;
+ }
+ pid = waitpid((pid_t)-1,&wstat,flags);
+
+ /*
+ * some systems (linux 2.6) may return EINVAL
+ * when there are no continued children
+ */
+
+ if (pid<0 && errno==EINVAL && (flags&WCONTINUED))
+ pid = waitpid((pid_t)-1,&wstat,flags&=~WCONTINUED);
+ sh_sigcheck();
+ if(sig && pid<0 && errno==EINTR)
+ continue;
+ if(pid<=0)
+ break;
+ flags |= WNOHANG;
+ job.waitsafe++;
+ jp = 0;
+ if(!(pw=job_bypid(pid)))
+ {
+#ifdef DEBUG
+ sfprintf(sfstderr,"ksh: job line %4d: reap pid=%d critical=%d unknown job pid=%d pw=%x\n",__LINE__,getpid(),job.in_critical,pid,pw);
+#endif /* DEBUG */
+ pw = &dummy;
+ pw->p_exit = 0;
+ pw->p_pgrp = 0;
+ if(job.toclear)
+ job_clear();
+ if(bck.count++ > sh.lim.child_max)
+ job_chksave(0);
+ if(jp = jobsave_create(pid))
+ {
+ jp->next = bck.list;
+ bck.list = jp;
+ jp->exitval = 0;
+ }
+ pw->p_flag = 0;
+ lastpid = pw->p_pid = pid;
+ px = 0;
+ if(jp && WIFSTOPPED(wstat))
+ {
+ jp->exitval = SH_STOPSIG;
+ continue;
+ }
+ }
+#ifdef SIGTSTP
+ else
+ px=job_byjid(pw->p_job);
+ if(WIFSTOPPED(wstat))
+ {
+ if(px)
+ {
+ /* move to top of job list */
+ job_unlink(px);
+ px->p_nxtjob = job.pwlist;
+ job.pwlist = px;
+ }
+ pw->p_exit = WSTOPSIG(wstat);
+ pw->p_flag |= (P_NOTIFY|P_SIGNALLED|P_STOPPED);
+ if(pw->p_pgrp && pw->p_pgrp==job.curpgid && sh_isstate(SH_STOPOK))
+ sh_fault(pw->p_exit);
+ continue;
+ }
+ else if (WIFCONTINUED(wstat) && wcontinued)
+ {
+ pw->p_flag &= ~(P_NOTIFY|P_SIGNALLED|P_STOPPED);
+ pw->p_exit = 0;
+ }
+ else
+#endif /* SIGTSTP */
+ {
+ /* check for coprocess completion */
+ if(pid==sh.cpid)
+ {
+ sh_close(sh.coutpipe);
+ sh_close(sh.cpipe[1]);
+ sh.cpipe[1] = -1;
+ sh.coutpipe = -1;
+ }
+ if (WIFSIGNALED(wstat))
+ {
+ pw->p_flag &= ~P_STOPPED;
+ pw->p_flag |= (P_DONE|P_NOTIFY|P_SIGNALLED);
+ if (WTERMCORE(wstat))
+ pw->p_flag |= P_COREDUMP;
+ pw->p_exit = WTERMSIG(wstat);
+ /* if process in current jobs terminates from
+ * an interrupt, propogate to parent shell
+ */
+ if(pw->p_pgrp && pw->p_pgrp==job.curpgid && pw->p_exit==SIGINT && sh_isstate(SH_STOPOK))
+ {
+ pw->p_flag &= ~P_NOTIFY;
+ sh_offstate(SH_STOPOK);
+ sh_fault(SIGINT);
+ sh_onstate(SH_STOPOK);
+ }
+ }
+ else
+ {
+ pw->p_flag |= (P_DONE|P_NOTIFY);
+ if(WEXITSTATUS(wstat) > pw->p_exit)
+ pw->p_exit = WEXITSTATUS(wstat);
+ }
+ if(pw->p_pgrp==0)
+ pw->p_flag &= ~P_NOTIFY;
+ }
+ if(jp && pw== &dummy)
+ {
+ jp->exitval = pw->p_exit;
+ if(pw->p_flag&P_SIGNALLED)
+ jp->exitval |= SH_EXITSIG;
+ }
+#ifdef DEBUG
+ sfprintf(sfstderr,"ksh: job line %4d: reap pid=%d critical=%d job %d with pid %d flags=%o complete with status=%x exit=%d\n",__LINE__,getpid(),job.in_critical,pw->p_job,pid,pw->p_flag,wstat,pw->p_exit);
+ sfsync(sfstderr);
+#endif /* DEBUG*/
+ /* only top-level process in job should have notify set */
+ if(px && pw != px)
+ pw->p_flag &= ~P_NOTIFY;
+ }
+ if(errno==ECHILD)
+ {
+ errno = oerrno;
+ nochild = 1;
+ }
+ sh.waitevent = waitevent;
+ if(!sh.intrap && sh.st.trapcom[SIGCHLD])
+ {
+ sh.sigflag[SIGCHLD] |= SH_SIGTRAP;
+ sh.trapnote |= SH_SIGTRAP;
+ }
+ if(sh_isoption(SH_NOTIFY) && sh_isstate(SH_TTYWAIT))
+ {
+ outfile = sfstderr;
+ job_list(pw,JOB_NFLAG|JOB_NLFLAG);
+ job_unpost(pw,1);
+ sfsync(sfstderr);
+ }
+ if(sig)
+ signal(sig, job_waitsafe);
+ return(nochild);
+}
+
+/*
+ * This is the SIGCLD interrupt routine
+ */
+static void job_waitsafe(int sig)
+{
+ if(job.in_critical)
+ {
+ job.savesig = sig;
+ job.waitsafe++;
+ }
+ else
+ job_reap(sig);
+}
+
+/*
+ * initialize job control if possible
+ * if lflag is set the switching driver message will not print
+ */
+void job_init(int lflag)
+{
+ register int i,ntry=0;
+ job.fd = JOBTTY;
+ signal(SIGCHLD,job_waitsafe);
+# if defined(SIGCLD) && (SIGCLD!=SIGCHLD)
+ signal(SIGCLD,job_waitsafe);
+# endif
+ if(njob_savelist < NJOB_SAVELIST)
+ init_savelist();
+ if(!sh_isoption(SH_INTERACTIVE))
+ return;
+ /* use new line discipline when available */
+#ifdef NTTYDISC
+# ifdef FIOLOOKLD
+ if((job.linedisc = ioctl(JOBTTY, FIOLOOKLD, 0)) <0)
+# else
+ if(ioctl(JOBTTY,TIOCGETD,&job.linedisc) !=0)
+# endif /* FIOLOOKLD */
+ return;
+ if(job.linedisc!=NTTYDISC && job.linedisc!=OTTYDISC)
+ {
+ /* no job control when running with MPX */
+# if SHOPT_VSH
+ sh_onoption(SH_VIRAW);
+# endif /* SHOPT_VSH */
+ return;
+ }
+ if(job.linedisc==NTTYDISC)
+ job.linedisc = -1;
+#endif /* NTTYDISC */
+
+ job.mypgid = getpgrp();
+ /* some systems have job control, but not initialized */
+ if(job.mypgid<=0)
+ {
+ /* Get a controlling terminal and set process group */
+ /* This should have already been done by rlogin */
+ register int fd;
+ register char *ttynam;
+#ifndef SIGTSTP
+ setpgid(0,sh.pid);
+#endif /*SIGTSTP */
+ if(job.mypgid<0 || !(ttynam=ttyname(JOBTTY)))
+ return;
+ close(JOBTTY);
+ if((fd = open(ttynam,O_RDWR)) <0)
+ return;
+ if(fd!=JOBTTY)
+ sh_iorenumber(fd,JOBTTY);
+ job.mypgid = sh.pid;
+#ifdef SIGTSTP
+ tcsetpgrp(JOBTTY,sh.pid);
+ setpgid(0,sh.pid);
+#endif /* SIGTSTP */
+ }
+#ifdef SIGTSTP
+ if(possible = (setpgid(0,job.mypgid)>=0) || errno==EPERM)
+ {
+ /* wait until we are in the foreground */
+ while((job.mytgid=tcgetpgrp(JOBTTY)) != job.mypgid)
+ {
+ if(job.mytgid == -1)
+ return;
+ /* Stop this shell until continued */
+ signal(SIGTTIN,SIG_DFL);
+ kill(sh.pid,SIGTTIN);
+ /* resumes here after continue tries again */
+ if(ntry++ > IOMAXTRY)
+ {
+ errormsg(SH_DICT,0,e_no_start);
+ return;
+ }
+ }
+ }
+#endif /* SIGTTIN */
+
+#ifdef NTTYDISC
+ /* set the line discipline */
+ if(job.linedisc>=0)
+ {
+ int linedisc = NTTYDISC;
+# ifdef FIOPUSHLD
+ tty_get(JOBTTY,&my_stty);
+ if (ioctl(JOBTTY, FIOPOPLD, 0) < 0)
+ return;
+ if (ioctl(JOBTTY, FIOPUSHLD, &linedisc) < 0)
+ {
+ ioctl(JOBTTY, FIOPUSHLD, &job.linedisc);
+ return;
+ }
+ tty_set(JOBTTY,TCSANOW,&my_stty);
+# else
+ if(ioctl(JOBTTY,TIOCSETD,&linedisc) !=0)
+ return;
+# endif /* FIOPUSHLD */
+ if(lflag==0)
+ errormsg(SH_DICT,0,e_newtty);
+ else
+ job.linedisc = -1;
+ }
+#endif /* NTTYDISC */
+ if(!possible)
+ return;
+
+#ifdef SIGTSTP
+ /* make sure that we are a process group leader */
+ setpgid(0,sh.pid);
+# if defined(SA_NOCLDWAIT) && defined(_lib_sigflag)
+ sigflag(SIGCHLD, SA_NOCLDSTOP|SA_NOCLDWAIT, 0);
+# endif /* SA_NOCLDWAIT */
+ signal(SIGTTIN,SIG_IGN);
+ signal(SIGTTOU,SIG_IGN);
+ /* The shell now handles ^Z */
+ signal(SIGTSTP,sh_fault);
+ tcsetpgrp(JOBTTY,sh.pid);
+# ifdef CNSUSP
+ /* set the switch character */
+ tty_get(JOBTTY,&my_stty);
+ job.suspend = (unsigned)my_stty.c_cc[VSUSP];
+ if(job.suspend == (unsigned char)CNSUSP)
+ {
+ my_stty.c_cc[VSUSP] = CSWTCH;
+ tty_set(JOBTTY,TCSAFLUSH,&my_stty);
+ }
+# endif /* CNSUSP */
+ sh_onoption(SH_MONITOR);
+ job.jobcontrol++;
+ job.mypid = sh.pid;
+#endif /* SIGTSTP */
+ return;
+}
+
+
+/*
+ * see if there are any stopped jobs
+ * restore tty driver and pgrp
+ */
+int job_close(void)
+{
+ register struct process *pw;
+ register int count = 0, running = 0;
+ if(possible && !job.jobcontrol)
+ return(0);
+ else if(!possible && (!sh_isstate(SH_MONITOR) || sh_isstate(SH_FORKED)))
+ return(0);
+ else if(getpid() != job.mypid)
+ return(0);
+ job_lock();
+ if(!tty_check(0))
+ beenhere++;
+ for(pw=job.pwlist;pw;pw=pw->p_nxtjob)
+ {
+ if(!(pw->p_flag&P_STOPPED))
+ {
+ if(!(pw->p_flag&P_DONE))
+ running++;
+ continue;
+ }
+ if(beenhere)
+ killpg(pw->p_pgrp,SIGTERM);
+ count++;
+ }
+ if(beenhere++ == 0 && job.pwlist)
+ {
+ if(count)
+ {
+ errormsg(SH_DICT,0,e_terminate);
+ return(-1);
+ }
+ else if(running && sh.login_sh)
+ {
+ errormsg(SH_DICT,0,e_jobsrunning);
+ return(-1);
+ }
+ }
+ job_unlock();
+# ifdef SIGTSTP
+ if(possible && setpgid(0,job.mypgid)>=0)
+ tcsetpgrp(job.fd,job.mypgid);
+# endif /* SIGTSTP */
+# ifdef NTTYDISC
+ if(job.linedisc>=0)
+ {
+ /* restore old line discipline */
+# ifdef FIOPUSHLD
+ tty_get(job.fd,&my_stty);
+ if (ioctl(job.fd, FIOPOPLD, 0) < 0)
+ return(0);
+ if (ioctl(job.fd, FIOPUSHLD, &job.linedisc) < 0)
+ {
+ job.linedisc = NTTYDISC;
+ ioctl(job.fd, FIOPUSHLD, &job.linedisc);
+ return(0);
+ }
+ tty_set(job.fd,TCSAFLUSH,&my_stty);
+# else
+ if(ioctl(job.fd,TIOCSETD,&job.linedisc) !=0)
+ return(0);
+# endif /* FIOPUSHLD */
+ errormsg(SH_DICT,0,e_oldtty);
+ }
+# endif /* NTTYDISC */
+# ifdef CNSUSP
+ if(possible && job.suspend==CNSUSP)
+ {
+ tty_get(job.fd,&my_stty);
+ my_stty.c_cc[VSUSP] = CNSUSP;
+ tty_set(job.fd,TCSAFLUSH,&my_stty);
+ }
+# endif /* CNSUSP */
+ job.jobcontrol = 0;
+ return(0);
+}
+
+static void job_set(register struct process *pw)
+{
+ /* save current terminal state */
+ tty_get(job.fd,&my_stty);
+ if(pw->p_flag&P_STTY)
+ {
+ /* restore terminal state for job */
+ tty_set(job.fd,TCSAFLUSH,&pw->p_stty);
+ }
+#ifdef SIGTSTP
+ if((pw->p_flag&P_STOPPED) || tcgetpgrp(job.fd) == sh.pid)
+ tcsetpgrp(job.fd,pw->p_fgrp);
+ /* if job is stopped, resume it in the background */
+ job_unstop(pw);
+#endif /* SIGTSTP */
+}
+
+static void job_reset(register struct process *pw)
+{
+ /* save the terminal state for current job */
+#ifdef SIGTSTP
+ job_fgrp(pw,tcgetpgrp(job.fd));
+ if(tcsetpgrp(job.fd,sh.pid) !=0)
+ return;
+#endif /* SIGTSTP */
+ /* force the following tty_get() to do a tcgetattr() unless fg */
+ if(!(pw->p_flag&P_FG))
+ tty_set(-1, 0, NIL(struct termios*));
+ if(pw && (pw->p_flag&P_SIGNALLED) && pw->p_exit!=SIGHUP)
+ {
+ if(tty_get(job.fd,&pw->p_stty) == 0)
+ pw->p_flag |= P_STTY;
+ /* restore terminal state for job */
+ tty_set(job.fd,TCSAFLUSH,&my_stty);
+ }
+ beenhere = 0;
+}
+#endif /* JOBS */
+
+/*
+ * wait built-in command
+ */
+
+void job_bwait(char **jobs)
+{
+ register char *jp;
+ register struct process *pw;
+ register pid_t pid;
+ if(*jobs==0)
+ job_wait((pid_t)-1);
+ else while(jp = *jobs++)
+ {
+#ifdef JOBS
+ if(*jp == '%')
+ {
+ job_lock();
+ pw = job_bystring(jp);
+ job_unlock();
+ if(pw)
+ pid = pw->p_pid;
+ else
+ return;
+ }
+ else
+#endif /* JOBS */
+ pid = (int)strtol(jp, (char**)0, 10);
+ job_wait(-pid);
+ }
+}
+
+#ifdef JOBS
+/*
+ * execute function <fun> for each job
+ */
+
+int job_walk(Sfio_t *file,int (*fun)(struct process*,int),int arg,char *joblist[])
+{
+ register struct process *pw;
+ register int r = 0;
+ register char *jobid, **jobs=joblist;
+ register struct process *px;
+ job_string = 0;
+ outfile = file;
+ by_number = 0;
+ job_lock();
+ pw = job.pwlist;
+ if(jobs==0)
+ {
+ /* do all jobs */
+ for(;pw;pw=px)
+ {
+ px = pw->p_nxtjob;
+ if(pw->p_env != sh.jobenv)
+ continue;
+ if((*fun)(pw,arg))
+ r = 2;
+ }
+ }
+ else if(*jobs==0) /* current job */
+ {
+ /* skip over non-stop jobs */
+ while(pw && (pw->p_env!=sh.jobenv || pw->p_pgrp==0))
+ pw = pw->p_nxtjob;
+ if((*fun)(pw,arg))
+ r = 2;
+ }
+ else while(jobid = *jobs++)
+ {
+ job_string = jobid;
+ if(*jobid==0)
+ errormsg(SH_DICT,ERROR_exit(1),e_jobusage,job_string);
+ if(*jobid == '%')
+ pw = job_bystring(jobid);
+ else
+ {
+ int pid = (int)strtol(jobid, (char**)0, 10);
+ if(pid<0)
+ jobid++;
+ while(isdigit(*jobid))
+ jobid++;
+ if(*jobid)
+ errormsg(SH_DICT,ERROR_exit(1),e_jobusage,job_string);
+ if(!(pw = job_bypid(pid)))
+ {
+ pw = &dummy;
+ pw->p_pid = pid;
+ pw->p_pgrp = pid;
+ }
+ by_number = 1;
+ }
+ if((*fun)(pw,arg))
+ r = 2;
+ by_number = 0;
+ }
+ job_unlock();
+ return(r);
+}
+
+/*
+ * send signal <sig> to background process group if not disowned
+ */
+int job_terminate(register struct process *pw,register int sig)
+{
+ if(pw->p_pgrp && !(pw->p_flag&P_DISOWN))
+ job_kill(pw,sig);
+ return(0);
+}
+
+/*
+ * list the given job
+ * flag JOB_LFLAG for long listing
+ * flag JOB_NFLAG for list only jobs marked for notification
+ * flag JOB_PFLAG for process id(s) only
+ */
+
+int job_list(struct process *pw,register int flag)
+{
+ register struct process *px = pw;
+ register int n;
+ register const char *msg;
+ register int msize;
+ if(!pw || pw->p_job<=0)
+ return(1);
+ if(pw->p_env != sh.jobenv)
+ return(0);
+ if((flag&JOB_NFLAG) && (!(px->p_flag&P_NOTIFY)||px->p_pgrp==0))
+ return(0);
+ if((flag&JOB_PFLAG))
+ {
+ sfprintf(outfile,"%d\n",px->p_pgrp?px->p_pgrp:px->p_pid);
+ return(0);
+ }
+ if((px->p_flag&P_DONE) && job.waitall && !(flag&JOB_LFLAG))
+ return(0);
+ job_lock();
+ n = px->p_job;
+ if(px==job.pwlist)
+ msize = '+';
+ else if(px==job.pwlist->p_nxtjob)
+ msize = '-';
+ else
+ msize = ' ';
+ if(flag&JOB_NLFLAG)
+ sfputc(outfile,'\n');
+ sfprintf(outfile,"[%d] %c ",n, msize);
+ do
+ {
+ n = 0;
+ if(flag&JOB_LFLAG)
+ sfprintf(outfile,"%d\t",px->p_pid);
+ if(px->p_flag&P_SIGNALLED)
+ msg = job_sigmsg((int)(px->p_exit));
+ else if(px->p_flag&P_NOTIFY)
+ {
+ msg = sh_translate(e_done);
+ n = px->p_exit;
+ }
+ else
+ msg = sh_translate(e_running);
+ px->p_flag &= ~P_NOTIFY;
+ sfputr(outfile,msg,-1);
+ msize = strlen(msg);
+ if(n)
+ {
+ sfprintf(outfile,"(%d)",(int)n);
+ msize += (3+(n>10)+(n>100));
+ }
+ if(px->p_flag&P_COREDUMP)
+ {
+ msg = sh_translate(e_coredump);
+ sfputr(outfile, msg, -1);
+ msize += strlen(msg);
+ }
+ sfnputc(outfile,' ',MAXMSG>msize?MAXMSG-msize:1);
+ if(flag&JOB_LFLAG)
+ px = px->p_nxtproc;
+ else
+ {
+ while(px=px->p_nxtproc)
+ px->p_flag &= ~P_NOTIFY;
+ px = 0;
+ }
+ if(!px)
+ hist_list(sh.hist_ptr,outfile,pw->p_name,0,";");
+ else
+ sfputr(outfile, e_nlspace, -1);
+ }
+ while(px);
+ job_unlock();
+ return(0);
+}
+
+/*
+ * get the process group given the job number
+ * This routine returns the process group number or -1
+ */
+static struct process *job_bystring(register char *ajob)
+{
+ register struct process *pw=job.pwlist;
+ register int c;
+ if(*ajob++ != '%' || !pw)
+ return(NIL(struct process*));
+ c = *ajob;
+ if(isdigit(c))
+ pw = job_byjid((int)strtol(ajob, (char**)0, 10));
+ else if(c=='+' || c=='%')
+ ;
+ else if(c=='-')
+ {
+ if(pw)
+ pw = job.pwlist->p_nxtjob;
+ }
+ else
+ pw = job_byname(ajob);
+ if(pw && pw->p_flag)
+ return(pw);
+ return(NIL(struct process*));
+}
+
+/*
+ * Kill a job or process
+ */
+
+int job_kill(register struct process *pw,register int sig)
+{
+ register pid_t pid;
+ register int r;
+ const char *msg;
+#ifdef SIGTSTP
+ int stopsig = (sig==SIGSTOP||sig==SIGTSTP||sig==SIGTTIN||sig==SIGTTOU);
+#else
+# define stopsig 1
+#endif /* SIGTSTP */
+ job_lock();
+ errno = ECHILD;
+ if(pw==0)
+ goto error;
+ pid = pw->p_pid;
+ if(by_number)
+ {
+ if(pid==0 && job.jobcontrol)
+ r = job_walk(outfile, job_kill,sig, (char**)0);
+#ifdef SIGTSTP
+ if(sig==SIGSTOP && pid==sh.pid && sh.ppid==1)
+ {
+ /* can't stop login shell */
+ errno = EPERM;
+ r = -1;
+ }
+ else
+ {
+ if(pid>=0)
+ {
+ if((r = kill(pid,sig))>=0 && !stopsig)
+ {
+ if(pw->p_flag&P_STOPPED)
+ pw->p_flag &= ~(P_STOPPED|P_SIGNALLED);
+ if(sig)
+ kill(pid,SIGCONT);
+ }
+ }
+ else
+ {
+ if((r = killpg(-pid,sig))>=0 && !stopsig)
+ {
+ job_unstop(job_bypid(pw->p_pid));
+ if(sig)
+ killpg(-pid,SIGCONT);
+ }
+ }
+ }
+#else
+ if(pid>=0)
+ r = kill(pid,sig);
+ else
+ r = killpg(-pid,sig);
+#endif /* SIGTSTP */
+ }
+ else
+ {
+ if(pid = pw->p_pgrp)
+ {
+ r = killpg(pid,sig);
+#ifdef SIGTSTP
+ if(r>=0 && (sig==SIGHUP||sig==SIGTERM || sig==SIGCONT))
+ job_unstop(pw);
+#endif /* SIGTSTP */
+ if(r>=0)
+ sh_delay(.05);
+ }
+ while(pw && pw->p_pgrp==0 && (r=kill(pw->p_pid,sig))>=0)
+ {
+#ifdef SIGTSTP
+ if(sig==SIGHUP || sig==SIGTERM)
+ kill(pw->p_pid,SIGCONT);
+#endif /* SIGTSTP */
+ pw = pw->p_nxtproc;
+ }
+ }
+ if(r<0 && job_string)
+ {
+ error:
+ if(pw && by_number)
+ msg = sh_translate(e_no_proc);
+ else
+ msg = sh_translate(e_no_job);
+ if(errno == EPERM)
+ msg = sh_translate(e_access);
+ sfprintf(sfstderr,"kill: %s: %s\n",job_string, msg);
+ r = 2;
+ }
+ sh_delay(.001);
+ job_unlock();
+ return(r);
+}
+
+/*
+ * Get process structure from first letters of jobname
+ *
+ */
+
+static struct process *job_byname(char *name)
+{
+ register struct process *pw = job.pwlist;
+ register struct process *pz = 0;
+ register int *flag = 0;
+ register char *cp = name;
+ int offset;
+ if(!sh.hist_ptr)
+ return(NIL(struct process*));
+ if(*cp=='?')
+ cp++,flag= &offset;
+ for(;pw;pw=pw->p_nxtjob)
+ {
+ if(hist_match(sh.hist_ptr,pw->p_name,cp,flag)>=0)
+ {
+ if(pz)
+ errormsg(SH_DICT,ERROR_exit(1),e_jobusage,name-1);
+ pz = pw;
+ }
+ }
+ return(pz);
+}
+
+#else
+# define job_set(x)
+# define job_reset(x)
+#endif /* JOBS */
+
+
+
+/*
+ * Initialize the process posting array
+ */
+
+void job_clear(void)
+{
+ register struct process *pw, *px;
+ register struct process *pwnext;
+ register int j = BYTE(sh.lim.child_max);
+ register struct jobsave *jp,*jpnext;
+ job_lock();
+ for(pw=job.pwlist; pw; pw=pwnext)
+ {
+ pwnext = pw->p_nxtjob;
+ while(px=pw)
+ {
+ pw = pw->p_nxtproc;
+ free((void*)px);
+ }
+ }
+ for(jp=bck.list; jp;jp=jpnext)
+ {
+ jpnext = jp->next;
+ free((void*)jp);
+ }
+ bck.list = 0;
+ if(njob_savelist < NJOB_SAVELIST)
+ init_savelist();
+ job.pwlist = NIL(struct process*);
+ job.numpost=0;
+ job.waitall = 0;
+ job.curpgid = 0;
+ job.toclear = 0;
+ if(!job.freejobs)
+ job.freejobs = (unsigned char*)malloc((unsigned)(j+1));
+ while(j >=0)
+ job.freejobs[j--] = 0;
+ job_unlock();
+}
+
+/*
+ * put the process <pid> on the process list and return the job number
+ * if non-zero, <join> is the process id of the job to join
+ */
+
+int job_post(pid_t pid, pid_t join)
+{
+ register struct process *pw;
+ register History_t *hp = sh.hist_ptr;
+ sh.jobenv = sh.curenv;
+ if(njob_savelist < NJOB_SAVELIST)
+ init_savelist();
+ if(job.toclear)
+ {
+ job_clear();
+ return(0);
+ }
+ job_lock();
+ if(pw = job_bypid(pid))
+ job_unpost(pw,0);
+ if(join && (pw=job_bypid(join)))
+ {
+ /* if job to join is not first move it to front */
+ if((pw=job_byjid(pw->p_job)) != job.pwlist)
+ {
+ job_unlink(pw);
+ pw->p_nxtjob = job.pwlist;
+ job.pwlist = pw;
+ }
+ }
+ if(pw=freelist)
+ freelist = pw->p_nxtjob;
+ else
+ pw = new_of(struct process,0);
+ job.numpost++;
+ if(join && job.pwlist)
+ {
+ /* join existing current job */
+ pw->p_nxtjob = job.pwlist->p_nxtjob;
+ pw->p_nxtproc = job.pwlist;
+ pw->p_job = job.pwlist->p_job;
+ }
+ else
+ {
+ /* create a new job */
+ while((pw->p_job = job_alloc()) < 0)
+ job_wait((pid_t)1);
+ pw->p_nxtjob = job.pwlist;
+ pw->p_nxtproc = 0;
+ }
+ job.pwlist = pw;
+ pw->p_env = sh.curenv;
+ pw->p_pid = pid;
+ pw->p_flag = P_EXITSAVE;
+ pw->p_exit = sh.xargexit;
+ sh.xargexit = 0;
+ if(sh_isstate(SH_MONITOR))
+ {
+ if(killpg(job.curpgid,0)<0 && errno==ESRCH)
+ job.curpgid = pid;
+ pw->p_fgrp = job.curpgid;
+ }
+ else
+ pw->p_fgrp = 0;
+ pw->p_pgrp = pw->p_fgrp;
+#ifdef DEBUG
+ sfprintf(sfstderr,"ksh: job line %4d: post pid=%d critical=%d job=%d pid=%d pgid=%d savesig=%d join=%d\n",__LINE__,getpid(),job.in_critical,pw->p_job,
+ pw->p_pid,pw->p_pgrp,job.savesig,join);
+ sfsync(sfstderr);
+#endif /* DEBUG */
+#ifdef JOBS
+ if(hp && !sh_isstate(SH_PROFILE))
+ pw->p_name=hist_tell(sh.hist_ptr,(int)hp->histind-1);
+ else
+ pw->p_name = -1;
+#endif /* JOBS */
+ if(pid==lastpid)
+ {
+ int val = job_chksave(pid);
+ pw->p_exit = val>0?val:0;
+ if(pw->p_exit==SH_STOPSIG)
+ {
+ pw->p_flag |= (P_SIGNALLED|P_STOPPED);
+ pw->p_exit = 0;
+ }
+ else
+ pw->p_flag |= (P_DONE|P_NOTIFY);
+ }
+ lastpid = 0;
+ job_unlock();
+ return(pw->p_job);
+}
+
+/*
+ * Returns a process structure give a process id
+ */
+
+static struct process *job_bypid(pid_t pid)
+{
+ register struct process *pw, *px;
+ for(pw=job.pwlist; pw; pw=pw->p_nxtjob)
+ for(px=pw; px; px=px->p_nxtproc)
+ {
+ if(px->p_pid==pid)
+ return(px);
+ }
+ return(NIL(struct process*));
+}
+
+/*
+ * return a pointer to a job given the job id
+ */
+
+static struct process *job_byjid(int jobid)
+{
+ register struct process *pw;
+ for(pw=job.pwlist;pw; pw = pw->p_nxtjob)
+ {
+ if(pw->p_job==jobid)
+ break;
+ }
+ return(pw);
+}
+
+/*
+ * print a signal message
+ */
+static void job_prmsg(register struct process *pw)
+{
+ if(pw->p_exit!=SIGINT && pw->p_exit!=SIGPIPE)
+ {
+ register const char *msg, *dump;
+ msg = job_sigmsg((int)(pw->p_exit));
+ msg = sh_translate(msg);
+ if(pw->p_flag&P_COREDUMP)
+ dump = sh_translate(e_coredump);
+ else
+ dump = "";
+ if(sh_isstate(SH_INTERACTIVE))
+ sfprintf(sfstderr,"%s%s\n",msg,dump);
+ else
+ errormsg(SH_DICT,2,"%d: %s%s",pw->p_pid,msg,dump);
+ }
+}
+
+/*
+ * Wait for process pid to complete
+ * If pid < -1, then wait can be interrupted, -pid is waited for (wait builtin)
+ * pid=0 to unpost all done processes
+ * pid=1 to wait for at least one process to complete
+ * pid=-1 to wait for all runing processes
+ */
+
+void job_wait(register pid_t pid)
+{
+ register struct process *pw=0,*px;
+ register int jobid = 0;
+ int nochild;
+ char intr = 0;
+ if(pid <= 0)
+ {
+ if(pid==0)
+ goto done;
+ pid = -pid;
+ intr = 1;
+ }
+ job_lock();
+ if(pid > 1)
+ {
+ if(!(pw=job_bypid(pid)))
+ {
+ /* check to see whether job status has been saved */
+ if((sh.exitval = job_chksave(pid)) < 0)
+ sh.exitval = ERROR_NOENT;
+ exitset();
+ job_unlock();
+ return;
+ }
+ else if(intr && pw->p_env!=sh.curenv)
+ {
+ sh.exitval = ERROR_NOENT;
+ job_unlock();
+ return;
+ }
+ jobid = pw->p_job;
+ if(!intr)
+ pw->p_flag &= ~P_EXITSAVE;
+ if(pw->p_pgrp && job.parent!= (pid_t)-1)
+ job_set(job_byjid(jobid));
+ }
+#ifdef DEBUG
+ sfprintf(sfstderr,"ksh: job line %4d: wait pid=%d critical=%d job=%d pid=%d\n",__LINE__,getpid(),job.in_critical,jobid,pid);
+ if(pw)
+ sfprintf(sfstderr,"ksh: job line %4d: wait pid=%d critical=%d flags=%o\n",__LINE__,getpid(),job.in_critical,pw->p_flag);
+#endif /* DEBUG*/
+ errno = 0;
+ while(1)
+ {
+ if(job.waitsafe)
+ {
+ for(px=job.pwlist;px; px = px->p_nxtjob)
+ {
+ if(px!=pw && (px->p_flag&P_NOTIFY))
+ {
+ if(sh_isoption(SH_NOTIFY))
+ {
+ outfile = sfstderr;
+ job_list(px,JOB_NFLAG|JOB_NLFLAG);
+ sfsync(sfstderr);
+ }
+ else if(!sh_isoption(SH_INTERACTIVE) && (px->p_flag&P_SIGNALLED))
+ {
+ job_prmsg(px);
+ px->p_flag &= ~P_NOTIFY;
+ }
+ }
+ }
+ }
+ if(pw && (pw->p_flag&(P_DONE|P_STOPPED)))
+ {
+#ifdef SIGTSTP
+ if(pw->p_flag&P_STOPPED)
+ {
+ pw->p_flag |= P_EXITSAVE;
+ if(sh_isoption(SH_INTERACTIVE) && !sh_isstate(SH_FORKED))
+ {
+ if( pw->p_exit!=SIGTTIN && pw->p_exit!=SIGTTOU)
+ break;
+
+ killpg(pw->p_pgrp,SIGCONT);
+ }
+ else /* ignore stop when non-interactive */
+ pw->p_flag &= ~(P_NOTIFY|P_SIGNALLED|P_STOPPED|P_EXITSAVE);
+ }
+ else
+#endif /* SIGTSTP */
+ {
+ if(pw->p_flag&P_SIGNALLED)
+ {
+ pw->p_flag &= ~P_NOTIFY;
+ job_prmsg(pw);
+ }
+ else if(pw->p_flag&P_DONE)
+ pw->p_flag &= ~P_NOTIFY;
+ if(pw->p_job==jobid)
+ {
+ px = job_byjid(jobid);
+ /* last process in job */
+ if(sh_isoption(SH_PIPEFAIL))
+ {
+ /* last non-zero exit */
+ for(;px;px=px->p_nxtproc)
+ {
+ if(px->p_exit)
+ break;
+ }
+ if(!px)
+ px = pw;
+ }
+ else if(px!=pw)
+ px = 0;
+ if(px)
+ {
+ sh.exitval=px->p_exit;
+ if(px->p_flag&P_SIGNALLED)
+ sh.exitval |= SH_EXITSIG;
+ if(intr)
+ px->p_flag &= ~P_EXITSAVE;
+ }
+ }
+ if(!job.waitall)
+ {
+ if(!sh_isoption(SH_PIPEFAIL))
+ job_unpost(pw,1);
+ break;
+ }
+ else if(!(px=job_unpost(pw,1)))
+ break;
+ pw = px;
+ continue;
+ }
+ }
+ sfsync(sfstderr);
+ job.waitsafe = 0;
+ nochild = job_reap(job.savesig);
+ if(job.waitsafe)
+ continue;
+ if(nochild)
+ break;
+ if(sh.sigflag[SIGALRM]&SH_SIGTRAP)
+ sh_timetraps();
+ if((intr && sh.trapnote) || (pid==1 && !intr))
+ break;
+ }
+ job_unlock();
+ if(pid==1)
+ return;
+ exitset();
+ if(pw->p_pgrp)
+ {
+ job_reset(pw);
+ /* propogate keyboard interrupts to parent */
+ if((pw->p_flag&P_SIGNALLED) && pw->p_exit==SIGINT && !(sh.sigflag[SIGINT]&SH_SIGOFF))
+ sh_fault(SIGINT);
+#ifdef SIGTSTP
+ else if((pw->p_flag&P_STOPPED) && pw->p_exit==SIGTSTP)
+ {
+ job.parent = 0;
+ sh_fault(SIGTSTP);
+ }
+#endif /* SIGTSTP */
+ }
+ else
+ tty_set(-1, 0, NIL(struct termios*));
+done:
+ if(!job.waitall && sh_isoption(SH_PIPEFAIL))
+ return;
+ if(!sh.intrap)
+ {
+ job_lock();
+ for(pw=job.pwlist; pw; pw=px)
+ {
+ px = pw->p_nxtjob;
+ job_unpost(pw,0);
+ }
+ job_unlock();
+ }
+}
+
+/*
+ * move job to foreground if bgflag == 'f'
+ * move job to background if bgflag == 'b'
+ * disown job if bgflag == 'd'
+ */
+
+int job_switch(register struct process *pw,int bgflag)
+{
+ register const char *msg;
+ job_lock();
+ if(!pw || !(pw=job_byjid((int)pw->p_job)))
+ {
+ job_unlock();
+ return(1);
+ }
+ if(bgflag=='d')
+ {
+ for(; pw; pw=pw->p_nxtproc)
+ pw->p_flag |= P_DISOWN;
+ job_unlock();
+ return(0);
+ }
+#ifdef SIGTSTP
+ if(bgflag=='b')
+ {
+ sfprintf(outfile,"[%d]\t",(int)pw->p_job);
+ sh.bckpid = pw->p_pid;
+ msg = "&";
+ }
+ else
+ {
+ job_unlink(pw);
+ pw->p_nxtjob = job.pwlist;
+ job.pwlist = pw;
+ msg = "";
+ }
+ hist_list(sh.hist_ptr,outfile,pw->p_name,'&',";");
+ sfputr(outfile,msg,'\n');
+ sfsync(outfile);
+ if(bgflag=='f')
+ {
+ if(!(pw=job_unpost(pw,1)))
+ {
+ job_unlock();
+ return(1);
+ }
+ job.waitall = 1;
+ pw->p_flag |= P_FG;
+ job_wait(pw->p_pid);
+ job.waitall = 0;
+ }
+ else if(pw->p_flag&P_STOPPED)
+ job_unstop(pw);
+#endif /* SIGTSTP */
+ job_unlock();
+ return(0);
+}
+
+
+#ifdef SIGTSTP
+/*
+ * Set the foreground group associated with a job
+ */
+
+static void job_fgrp(register struct process *pw, int newgrp)
+{
+ for(; pw; pw=pw->p_nxtproc)
+ pw->p_fgrp = newgrp;
+}
+
+/*
+ * turn off STOP state of a process group and send CONT signals
+ */
+
+static void job_unstop(register struct process *px)
+{
+ register struct process *pw;
+ register int num = 0;
+ for(pw=px ;pw ;pw=pw->p_nxtproc)
+ {
+ if(pw->p_flag&P_STOPPED)
+ {
+ num++;
+ pw->p_flag &= ~(P_STOPPED|P_SIGNALLED|P_NOTIFY);
+ }
+ }
+ if(num!=0)
+ {
+ if(px->p_fgrp != px->p_pgrp)
+ killpg(px->p_fgrp,SIGCONT);
+ killpg(px->p_pgrp,SIGCONT);
+ }
+}
+#endif /* SIGTSTP */
+
+/*
+ * remove a job from table
+ * If all the processes have not completed, unpost first non-completed process
+ * Otherwise the job is removed and job_unpost returns NULL.
+ * pwlist is reset if the first job is removed
+ * if <notify> is non-zero, then jobs with pending notifications are unposted
+ */
+
+static struct process *job_unpost(register struct process *pwtop,int notify)
+{
+ register struct process *pw;
+ /* make sure all processes are done */
+#ifdef DEBUG
+ sfprintf(sfstderr,"ksh: job line %4d: drop pid=%d critical=%d pid=%d env=%d\n",__LINE__,getpid(),job.in_critical,pwtop->p_pid,pwtop->p_env);
+ sfsync(sfstderr);
+#endif /* DEBUG */
+ pwtop = pw = job_byjid((int)pwtop->p_job);
+ for(; pw && (pw->p_flag&P_DONE)&&(notify||!(pw->p_flag&P_NOTIFY)||pw->p_env); pw=pw->p_nxtproc);
+ if(pw)
+ return(pw);
+ /* all processes complete, unpost job */
+ job_unlink(pwtop);
+ for(pw=pwtop; pw; pw=pw->p_nxtproc)
+ {
+ /* save the exit status for background jobs */
+ if(pw->p_flag&P_EXITSAVE)
+ {
+ struct jobsave *jp;
+ /* save status for future wait */
+ if(bck.count++ > sh.lim.child_max)
+ job_chksave(0);
+ if(jp = jobsave_create(pw->p_pid))
+ {
+ jp->next = bck.list;
+ bck.list = jp;
+ jp->exitval = pw->p_exit;
+ if(pw->p_flag&P_SIGNALLED)
+ jp->exitval |= SH_EXITSIG;
+ }
+ pw->p_flag &= ~P_EXITSAVE;
+ }
+ pw->p_flag &= ~P_DONE;
+ job.numpost--;
+ pw->p_nxtjob = freelist;
+ freelist = pw;
+ }
+#ifdef DEBUG
+ sfprintf(sfstderr,"ksh: job line %4d: free pid=%d critical=%d job=%d\n",__LINE__,getpid(),job.in_critical,pwtop->p_job);
+ sfsync(sfstderr);
+#endif /* DEBUG */
+ job_free((int)pwtop->p_job);
+ return((struct process*)0);
+}
+
+/*
+ * unlink a job form the job list
+ */
+static void job_unlink(register struct process *pw)
+{
+ register struct process *px;
+ if(pw==job.pwlist)
+ {
+ job.pwlist = pw->p_nxtjob;
+ job.curpgid = 0;
+ return;
+ }
+ for(px=job.pwlist;px;px=px->p_nxtjob)
+ if(px->p_nxtjob == pw)
+ {
+ px->p_nxtjob = pw->p_nxtjob;
+ return;
+ }
+}
+
+/*
+ * get an unused job number
+ * freejobs is a bit vector, 0 is unused
+ */
+
+static int job_alloc(void)
+{
+ register int j=0;
+ register unsigned mask = 1;
+ register unsigned char *freeword;
+ register int jmax = BYTE(sh.lim.child_max);
+ /* skip to first word with a free slot */
+ for(j=0;job.freejobs[j] == UCHAR_MAX; j++);
+ if(j >= jmax)
+ {
+ register struct process *pw;
+ for(j=1; j < sh.lim.child_max; j++)
+ {
+ if((pw=job_byjid(j))&& !job_unpost(pw,0))
+ break;
+ }
+ j /= CHAR_BIT;
+ if(j >= jmax)
+ return(-1);
+ }
+ freeword = &job.freejobs[j];
+ j *= CHAR_BIT;
+ for(j++;mask&(*freeword);j++,mask <<=1);
+ *freeword |= mask;
+ return(j);
+}
+
+/*
+ * return a job number
+ */
+
+static void job_free(register int n)
+{
+ register int j = (--n)/CHAR_BIT;
+ register unsigned mask;
+ n -= j*CHAR_BIT;
+ mask = 1 << n;
+ job.freejobs[j] &= ~mask;
+}
+
+static char *job_sigmsg(int sig)
+{
+ static char signo[40];
+#ifdef apollo
+ /*
+ * This code handles the formatting for the apollo specific signal
+ * SIGAPOLLO.
+ */
+ extern char *apollo_error(void);
+
+ if ( sig == SIGAPOLLO )
+ return( apollo_error() );
+#endif /* apollo */
+ if(sig<sh.sigmax && sh.sigmsg[sig])
+ return(sh.sigmsg[sig]);
+#if defined(SIGRTMIN) && defined(SIGRTMAX)
+ if(sig>=SIGRTMIN && sig<=SIGRTMAX)
+ {
+ static char sigrt[20];
+ sfsprintf(sigrt,sizeof(sigrt),"SIGRTMIN+%d",sig-SIGRTMIN);
+ return(sigrt);
+ }
+#endif
+ sfsprintf(signo,sizeof(signo),sh_translate(e_signo),sig);
+ return(signo);
+}
+
+/*
+ * see whether exit status has been saved and delete it
+ * if pid==0, then oldest saved process is deleted
+ * If pid is not found a -1 is returned.
+ */
+static int job_chksave(register pid_t pid)
+{
+ register struct jobsave *jp = bck.list, *jpold=0;
+ register int r= -1;
+ while(jp)
+ {
+ if(jp->pid==pid)
+ break;
+ if(pid==0 && !jp->next)
+ break;
+ jpold = jp;
+ jp = jp->next;
+ }
+ if(jp)
+ {
+ r = 0;
+ if(pid)
+ r = jp->exitval;
+ if(jpold)
+ jpold->next = jp->next;
+ else
+ bck.list = jp->next;
+ bck.count--;
+ if(njob_savelist < NJOB_SAVELIST)
+ {
+ njob_savelist++;
+ jp->next = job_savelist;
+ job_savelist = jp;
+ }
+ else
+ free((void*)jp);
+ }
+ return(r);
+}
+
+void *job_subsave(void)
+{
+ struct back_save *bp = new_of(struct back_save,0);
+ job_lock();
+ *bp = bck;
+ bck.count = 0;
+ bck.list = 0;
+ job_unlock();
+ return((void*)bp);
+}
+
+void job_subrestore(void* ptr)
+{
+ register struct jobsave *jp,*jpnext;
+ register struct back_save *bp = (struct back_save*)ptr;
+ register struct process *pw, *px, *pwnext;
+ job_lock();
+ for(pw=job.pwlist; pw; pw=pwnext)
+ {
+ pwnext = pw->p_nxtjob;
+ if(pw->p_env != sh.curenv)
+ continue;
+ for(px=pw; px; px=px->p_nxtproc)
+ px->p_flag |= P_DONE;
+ job_unpost(pw,0);
+ }
+ for(jp=bck.list,bck= *bp; jp; jp=jpnext)
+ {
+ jpnext = jp->next;
+ free((void*)jp);
+ }
+ free(ptr);
+ job_unlock();
+}
+
+int sh_waitsafe(void)
+{
+ return(job.waitsafe);
+}
+
+void job_fork(pid_t parent)
+{
+#ifdef DEBUG
+ sfprintf(sfstderr,"ksh: job line %4d: fork pid=%d critical=%d parent=%d\n",__LINE__,getpid(),job.in_critical,parent);
+#endif /* DEBUG */
+ switch (parent)
+ {
+ case -1:
+ job_lock();
+ break;
+ case 0:
+ job_unlock();
+ job.waitsafe = 0;
+ job.in_critical = 0;
+ break;
+ default:
+ job_unlock();
+ break;
+ }
+}
diff --git a/usr/src/lib/libshell/common/sh/lex.c b/usr/src/lib/libshell/common/sh/lex.c
new file mode 100644
index 0000000000..c8502e3b7b
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/lex.c
@@ -0,0 +1,2276 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * KornShell lexical analyzer
+ *
+ * Written by David Korn
+ * AT&T Labs
+ *
+ */
+
+#include <ast.h>
+#include <stak.h>
+#include <fcin.h>
+#include <nval.h>
+#include "FEATURE/options"
+
+#if KSHELL
+# include "defs.h"
+#else
+# include <shell.h>
+# define nv_getval(np) ((np)->nvalue)
+ Shell_t sh = {1};
+#endif /* KSHELL */
+
+#include "argnod.h"
+#include "test.h"
+#include "lexstates.h"
+#include "io.h"
+
+#define TEST_RE 3
+#define SYNBAD 3 /* exit value for syntax errors */
+#define STACK_ARRAY 3 /* size of depth match stack growth */
+
+#if _lib_iswblank < 0 /* set in lexstates.h to enable this code */
+
+int
+local_iswblank(wchar_t wc)
+{
+ static int initialized;
+ static wctype_t wt;
+
+ if (!initialized)
+ {
+ initialized = 1;
+ wt = wctype("blank");
+ }
+ return(iswctype(wc, wt));
+}
+
+#endif
+
+/*
+ * This structure allows for arbitrary depth nesting of (...), {...}, [...]
+ */
+struct lexstate
+{
+ char incase; /* 1 for case pattern, 2 after case */
+ char intest; /* 1 inside [[...]] */
+ char testop1; /* 1 when unary test op legal */
+ char testop2; /* 1 when binary test op legal */
+ char reservok; /* >0 for reserved word legal */
+ char skipword; /* next word can't be reserved */
+ char last_quote; /* last multi-line quote character */
+ char comp_assign; /* inside compound assignment */
+};
+
+struct lexdata
+{
+ char nocopy;
+ char paren;
+ char dolparen;
+ char nest;
+ char docword;
+ char *docend;
+ char noarg;
+ char balance;
+ char warn;
+ char message;
+ char arith;
+ char *first;
+ int level;
+ int lastc;
+ int lex_max;
+ int *lex_match;
+ int lex_state;
+#if SHOPT_KIA
+ off_t kiaoff;
+#endif
+};
+
+#define _SHLEX_PRIVATE \
+ struct lexdata _lexd; \
+ struct lexstate _lex;
+
+#include "shlex.h"
+
+#define lexd lp->_lexd
+#define lex lp->_lex
+#undef shlex
+#define shlex lp->_shlex
+
+
+#define pushlevel(c,s) ((lexd.level>=lexd.lex_max?stack_grow(lp):1) &&\
+ ((lexd.lex_match[lexd.level++]=lexd.lastc),\
+ lexd.lastc=(((s)<<CHAR_BIT)|(c))))
+#define oldmode() (lexd.lastc>>CHAR_BIT)
+#define endchar() (lexd.lastc&0xff)
+#define setchar(c) (lexd.lastc = ((lexd.lastc&~0xff)|(c)))
+#define poplevel() (lexd.lastc=lexd.lex_match[--lexd.level])
+
+static char *fmttoken(Lex_t*, int, char*);
+#ifdef SF_BUFCONST
+ static int alias_exceptf(Sfio_t*, int, void*, Sfdisc_t*);
+#else
+ static int alias_exceptf(Sfio_t*, int, Sfdisc_t*);
+#endif
+static void setupalias(Lex_t*,const char*, Namval_t*);
+static int comsub(Lex_t*);
+static void nested_here(Lex_t*);
+static int here_copy(Lex_t*, struct ionod*);
+static int stack_grow(Lex_t*);
+static const Sfdisc_t alias_disc = { NULL, NULL, NULL, alias_exceptf, NULL };
+
+#if SHOPT_KIA
+
+static void refvar(int type)
+{
+ register Shell_t *shp = sh_getinterp();
+ register Lex_t *lp = (Lex_t*)shp->lex_context;
+ off_t off = (fcseek(0)-(type+1))-(lexd.first?lexd.first:fcfirst());
+ unsigned long r;
+ if(lexd.first)
+ {
+ off = (fcseek(0)-(type+1)) - lexd.first;
+ r=kiaentity(lexd.first+lexd.kiaoff+type,off-lexd.kiaoff,'v',-1,-1,shlex.current,'v',0,"");
+ }
+ else
+ {
+ int n,offset = staktell();
+ char *savptr,*begin;
+ off = offset + (fcseek(0)-(type+1)) - fcfirst();
+ if(lexd.kiaoff < offset)
+ {
+ /* variable starts on stak, copy remainder */
+ if(off>offset)
+ stakwrite(fcfirst()+type,off-offset);
+ n = staktell()-lexd.kiaoff;
+ begin = stakptr(lexd.kiaoff);
+ }
+ else
+ {
+ /* variable in data buffer */
+ begin = fcfirst()+(type+lexd.kiaoff-offset);
+ n = off-lexd.kiaoff;
+ }
+ savptr = stakfreeze(0);
+ r=kiaentity(begin,n,'v',-1,-1,shlex.current,'v',0,"");
+ stakset(savptr,offset);
+ }
+ sfprintf(shlex.kiatmp,"p;%..64d;v;%..64d;%d;%d;r;\n",shlex.current,r,shp->inlineno,shp->inlineno);
+}
+#endif /* SHOPT_KIA */
+
+/*
+ * This routine gets called when reading across a buffer boundary
+ * If lexd.nocopy is off, then current token is saved on the stack
+ */
+static void lex_advance(Sfio_t *iop, const char *buff, register int size)
+{
+ register Shell_t *shp = sh_getinterp();
+ register Lex_t *lp = (Lex_t*)shp->lex_context;
+ register Sfio_t *log= shp->funlog;
+#if KSHELL
+ /* write to history file and to stderr if necessary */
+ if(iop && !sfstacked(iop))
+ {
+ if(sh_isstate(SH_HISTORY) && shp->hist_ptr)
+ log = shp->hist_ptr->histfp;
+ sfwrite(log, (void*)buff, size);
+ if(sh_isstate(SH_VERBOSE))
+ sfwrite(sfstderr, buff, size);
+ }
+#endif
+ if(lexd.nocopy)
+ return;
+ if(lexd.first)
+ {
+ size -= (lexd.first-(char*)buff);
+ buff = lexd.first;
+ if(!lexd.noarg)
+ shlex.arg = (struct argnod*)stakseek(ARGVAL);
+#if SHOPT_KIA
+ lexd.kiaoff += ARGVAL;
+#endif /* SHOPT_KIA */
+ }
+ if(size>0 && (shlex.arg||lexd.noarg))
+ {
+ stakwrite(buff,size);
+ lexd.first = 0;
+ }
+}
+
+/*
+ * fill up another input buffer
+ * preserves lexical state
+ */
+static int lexfill(void)
+{
+ Shell_t *shp = sh_getinterp();
+ register int c;
+ register Lex_t *lp = (Lex_t*)shp->lex_context;
+ struct shlex_t savelex;
+ struct lexdata savedata;
+ struct lexstate savestate;
+ struct argnod *ap;
+ int aok;
+ savelex = shlex;
+ savedata = lexd;
+ savestate = lex;
+ ap = shlex.arg;
+ c = fcfill();
+ if(ap)
+ shlex.arg = ap;
+ lex = savestate;
+ lexd = savedata;
+ lexd.first = 0;
+ aok= shlex.aliasok;
+ ap = shlex.arg;
+ shlex = savelex;
+ shlex.arg = ap;
+ shlex.aliasok = aok;
+ return(c);
+}
+
+/*
+ * mode=1 for reinitialization
+ */
+Lex_t *sh_lexopen(Lex_t *lp, Shell_t *sp, int mode)
+{
+ fcnotify(lex_advance);
+ if(!lp)
+ {
+ lp = (Lex_t*)newof(0,Lex_t,1,0);
+ lp->_shlex.sh = sp;
+ }
+ lex.intest = lex.incase = lex.skipword = lexd.warn = 0;
+ lex.comp_assign = 0;
+ lex.reservok = 1;
+ if(!sh_isoption(SH_DICTIONARY) && sh_isoption(SH_NOEXEC))
+ lexd.warn=1;
+ if(!mode)
+ {
+ lexd.noarg = lexd.level= lexd.dolparen = 0;
+ lexd.nocopy = lexd.docword = lexd.nest = lexd.paren = 0;
+ }
+ shlex.comsub = 0;
+ return(lp);
+}
+
+#ifdef DBUG
+extern int lextoken(void);
+int sh_lex(void)
+{
+ Shell_t *shp = sh_getinterp();
+ register Lex_t *lp = (Lex_t*)shp->lex_context;
+ register int flag;
+ char *quoted, *macro, *split, *expand;
+ char tokstr[3];
+ register int tok = lextoken();
+ quoted = macro = split = expand = "";
+ if(tok==0 && (flag=shlex.arg->argflag))
+ {
+ if(flag&ARG_MAC)
+ macro = "macro:";
+ if(flag&ARG_EXP)
+ expand = "expand:";
+ if(flag&ARG_QUOTED)
+ quoted = "quoted:";
+ }
+ sfprintf(sfstderr,"line %d: %o:%s%s%s%s %s\n",shp->inlineno,tok,quoted,
+ macro, split, expand, fmttoken(lp,tok,tokstr));
+ return(tok);
+}
+#define sh_lex lextoken
+#endif
+
+/*
+ * Get the next word and put it on the top of the stak
+ * A pointer to the current word is stored in shlex.arg
+ * Returns the token type
+ */
+int sh_lex(void)
+{
+ register Shell_t *shp = sh_getinterp();
+ register const char *state;
+ register int n, c, mode=ST_BEGIN, wordflags=0;
+ register Lex_t *lp = (Lex_t*)shp->lex_context;
+ int inlevel=lexd.level, assignment=0, ingrave=0;
+ Sfio_t *sp;
+#if SHOPT_MULTIBYTE
+ LEN=1;
+#endif /* SHOPT_MULTIBYTE */
+ if(lexd.paren)
+ {
+ lexd.paren = 0;
+ return(shlex.token=LPAREN);
+ }
+ if(lex.incase)
+ shlex.assignok = 0;
+ else
+ shlex.assignok |= lex.reservok;
+ if(lex.comp_assign==2)
+ lex.comp_assign = lex.reservok = 0;
+ lexd.arith = (lexd.nest==1);
+ if(lexd.nest)
+ {
+ pushlevel(lexd.nest,ST_NONE);
+ lexd.nest = 0;
+ mode = lexd.lex_state;
+ }
+ else if(lexd.docword)
+ {
+ if(fcgetc(c)=='-' || c=='#')
+ {
+ lexd.docword++;
+ shlex.digits=(c=='#'?3:1);
+ }
+ else if(c=='<')
+ {
+ shlex.digits=2;
+ lexd.docword=0;
+ }
+ else if(c>0)
+ fcseek(-1);
+ }
+ if(!lexd.dolparen)
+ {
+ shlex.arg = 0;
+ if(mode!=ST_BEGIN)
+ lexd.first = fcseek(0);
+ else
+ lexd.first = 0;
+ }
+ shlex.lastline = sh.inlineno;
+ while(1)
+ {
+ /* skip over characters in the current state */
+ state = sh_lexstates[mode];
+ while((n=STATE(state,c))==0);
+ switch(n)
+ {
+ case S_BREAK:
+ fcseek(-1);
+ goto breakloop;
+ case S_EOF:
+ sp = fcfile();
+ if((n=lexfill()) > 0)
+ {
+ fcseek(-1);
+ continue;
+ }
+ /* check for zero byte in file */
+ if(n==0 && fcfile())
+ {
+ if(shp->readscript)
+ {
+ char *cp = error_info.id;
+ errno = ENOEXEC;
+ error_info.id = shp->readscript;
+ errormsg(SH_DICT,ERROR_system(ERROR_NOEXEC),e_exec,cp);
+ }
+ else
+ {
+ shlex.token = -1;
+ sh_syntax();
+ }
+ }
+ /* end-of-file */
+ if(mode==ST_BEGIN)
+ return(shlex.token=EOFSYM);
+ if(mode >ST_NORM && lexd.level>0)
+ {
+ switch(c=endchar())
+ {
+ case '$':
+ if(mode==ST_LIT)
+ {
+ c = '\'';
+ break;
+ }
+ mode = oldmode();
+ poplevel();
+ continue;
+ case RBRACT:
+ c = LBRACT;
+ break;
+ case 1: /* for ((...)) */
+ case RPAREN:
+ c = LPAREN;
+ break;
+ default:
+ c = LBRACE;
+ break;
+ case '"': case '`': case '\'':
+ lexd.balance = c;
+ break;
+ }
+ if(sp && !(sfset(sp,0,0)&SF_STRING))
+ {
+ shlex.lasttok = c;
+ shlex.token = EOFSYM;
+ sh_syntax();
+ }
+ lexd.balance = c;
+ }
+ goto breakloop;
+ case S_COM:
+ /* skip one or more comment line(s) */
+ lex.reservok = !lex.intest;
+ if((n=lexd.nocopy) && lexd.dolparen)
+ lexd.nocopy--;
+ do
+ {
+ while(fcgetc(c)>0 && c!='\n');
+ if(c<=0 || shlex.heredoc)
+ break;
+ while(shp->inlineno++,fcpeek(0)=='\n')
+ fcseek(1);
+ while(state[c=fcpeek(0)]==0)
+ fcseek(1);
+ }
+ while(c=='#');
+ lexd.nocopy = n;
+ if(c<0)
+ return(shlex.token=EOFSYM);
+ n = S_NLTOK;
+ shp->inlineno--;
+ /* FALL THRU */
+ case S_NLTOK:
+ /* check for here-document */
+ if(shlex.heredoc)
+ {
+ if(!lexd.dolparen)
+ lexd.nocopy++;
+ c = shp->inlineno;
+ if(here_copy(lp,shlex.heredoc)<=0 && shlex.lasttok)
+ {
+ shlex.lasttok = IODOCSYM;
+ shlex.token = EOFSYM;
+ shlex.lastline = c;
+ sh_syntax();
+ }
+ if(!lexd.dolparen)
+ lexd.nocopy--;
+ shlex.heredoc = 0;
+ }
+ lex.reservok = !lex.intest;
+ lex.skipword = 0;
+ /* FALL THRU */
+ case S_NL:
+ /* skip over new-lines */
+ lex.last_quote = 0;
+ while(shp->inlineno++,fcget()=='\n');
+ fcseek(-1);
+ if(n==S_NLTOK)
+ {
+ lex.comp_assign = 0;
+ return(shlex.token='\n');
+ }
+ case S_BLNK:
+ if(lex.incase<=TEST_RE)
+ continue;
+ /* implicit RPAREN for =~ test operator */
+ if(inlevel+1==lexd.level)
+ {
+ fcseek(-1);
+ c = RPAREN;
+ goto do_pop;
+ }
+ continue;
+ case S_OP:
+ /* return operator token */
+ if(c=='<' || c=='>')
+ {
+ if(lex.testop2)
+ lex.testop2 = 0;
+ else
+ {
+ shlex.digits = (c=='>');
+ lex.skipword = 1;
+ shlex.aliasok = lex.reservok;
+ lex.reservok = 0;
+ }
+ }
+ else
+ {
+ lex.reservok = !lex.intest;
+ if(c==RPAREN)
+ {
+ if(!lexd.dolparen)
+ lex.incase = 0;
+ return(shlex.token=c);
+ }
+ lex.testop1 = lex.intest;
+ }
+ if(fcgetc(n)>0)
+ fcseek(-1);
+ if(state[n]==S_OP || n=='#')
+ {
+ if(n==c)
+ {
+ if(c=='<')
+ lexd.docword=1;
+ else if(n==LPAREN)
+ {
+ lexd.nest=1;
+ shlex.lastline = shp->inlineno;
+ lexd.lex_state = ST_NESTED;
+ fcseek(1);
+ return(sh_lex());
+ }
+ c |= SYMREP;
+ }
+ else if(c=='(' || c==')')
+ return(shlex.token=c);
+ else if(c=='&')
+ {
+#if SHOPT_BASH
+ if(!sh_isoption(SH_POSIX) && n=='>')
+ {
+ shlex.digits = -1;
+ c = '>';
+ }
+ else
+#endif
+ n = 0;
+ }
+ else if(n=='&')
+ c |= SYMAMP;
+ else if(c!='<' && c!='>')
+ n = 0;
+ else if(n==LPAREN)
+ {
+ c |= SYMLPAR;
+ lex.reservok = 1;
+ lex.skipword = 0;
+ }
+ else if(n=='|')
+ c |= SYMPIPE;
+ else if(c=='<' && n=='>')
+ c = IORDWRSYM;
+ else if(n=='#' && (c=='<'||c=='>'))
+ c |= SYMSHARP;
+ else
+ n = 0;
+ if(n)
+ {
+ fcseek(1);
+ lex.incase = (c==BREAKCASESYM || c==FALLTHRUSYM);
+ }
+ else
+ {
+ if((n=fcpeek(0))!=RPAREN && n!=LPAREN && lexd.warn)
+ errormsg(SH_DICT,ERROR_warn(0),e_lexspace,shp->inlineno,c,n);
+ }
+ }
+ if(c==LPAREN && lex.comp_assign && !lex.intest && !lex.incase)
+ lex.comp_assign = 2;
+ else
+ lex.comp_assign = 0;
+ return(shlex.token=c);
+ case S_ESC:
+ /* check for \<new-line> */
+ fcgetc(n);
+ c=2;
+#if SHOPT_CRNL
+ if(n=='\r')
+ {
+ if(fcgetc(n)=='\n')
+ c=3;
+ else
+ {
+ n='\r';
+ fcseek(-1);
+ }
+ }
+#endif /* SHOPT_CRNL */
+ if(n=='\n')
+ {
+ Sfio_t *sp;
+ struct argnod *ap;
+ shp->inlineno++;
+ /* synchronize */
+ if(!(sp=fcfile()))
+ state=fcseek(0);
+ fcclose();
+ ap = shlex.arg;
+ if(sp)
+ fcfopen(sp);
+ else
+ fcsopen((char*)state);
+ /* remove \new-line */
+ n = staktell()-c;
+ stakseek(n);
+ shlex.arg = ap;
+ if(n<=ARGVAL)
+ {
+ mode = 0;
+ lexd.first = 0;
+ }
+ continue;
+ }
+ wordflags |= ARG_QUOTED;
+ if(mode==ST_DOL)
+ goto err;
+#ifndef STR_MAXIMAL
+ else if(mode==ST_NESTED && lexd.warn &&
+ endchar()==RBRACE &&
+ sh_lexstates[ST_DOL][n]==S_DIG
+ )
+ errormsg(SH_DICT,ERROR_warn(0),e_lexfuture,shp->inlineno,n);
+#endif /* STR_MAXIMAL */
+ break;
+ case S_NAME:
+ if(!lex.skipword)
+ lex.reservok *= 2;
+ /* FALL THRU */
+ case S_TILDE:
+ case S_RES:
+ if(!lexd.dolparen)
+ lexd.first = fcseek(0)-LEN;
+ else if(lexd.docword)
+ lexd.docend = fcseek(0)-LEN;
+ mode = ST_NAME;
+ if(c=='.')
+ fcseek(-1);
+ if(n!=S_TILDE)
+ continue;
+ fcgetc(n);
+ if(n>0)
+ fcseek(-1);
+ if(n==LPAREN)
+ goto epat;
+ wordflags = ARG_MAC;
+ mode = ST_NORM;
+ continue;
+ case S_REG:
+ if(mode==ST_BEGIN)
+ {
+ /* skip new-line joining */
+ if(c=='\\' && fcpeek(0)=='\n')
+ {
+ shp->inlineno++;
+ fcseek(1);
+ continue;
+ }
+ fcseek(-1);
+ if(!lexd.dolparen)
+ lexd.first = fcseek(0);
+ else if(lexd.docword)
+ lexd.docend = fcseek(0);
+ if(c=='[' && shlex.assignok>=SH_ASSIGN)
+ {
+ mode = ST_NAME;
+ continue;
+ }
+ }
+ mode = ST_NORM;
+ continue;
+ case S_LIT:
+ if(oldmode()==ST_NONE) /* in ((...)) */
+ {
+ if((c=fcpeek(0))==LPAREN || c==RPAREN || c=='$' || c==LBRACE || c==RBRACE || c=='[' || c==']')
+ {
+ if(fcpeek(1)=='\'')
+ fcseek(2);
+ }
+ continue;
+ }
+ wordflags |= ARG_QUOTED;
+ if(mode==ST_DOL)
+ {
+ if(endchar()!='$')
+ goto err;
+ if(oldmode()==ST_QUOTE) /* $' within "" or `` */
+ {
+ if(lexd.warn)
+ errormsg(SH_DICT,ERROR_warn(0),e_lexslash,shp->inlineno);
+ mode = ST_LIT;
+ }
+ }
+ if(mode!=ST_LIT)
+ {
+ if(lexd.warn && lex.last_quote && shp->inlineno > shlex.lastline)
+ errormsg(SH_DICT,ERROR_warn(0),e_lexlongquote,shlex.lastline,lex.last_quote);
+ lex.last_quote = 0;
+ shlex.lastline = shp->inlineno;
+ if(mode!=ST_DOL)
+ pushlevel('\'',mode);
+ mode = ST_LIT;
+ continue;
+ }
+ /* check for multi-line single-quoted string */
+ else if(shp->inlineno > shlex.lastline)
+ lex.last_quote = '\'';
+ mode = oldmode();
+ poplevel();
+ break;
+ case S_ESC2:
+ /* \ inside '' */
+ if(endchar()=='$')
+ {
+ fcgetc(n);
+ if(n=='\n')
+ shp->inlineno++;
+ }
+ continue;
+ case S_GRAVE:
+ if(lexd.warn && (mode!=ST_QUOTE || endchar()!='`'))
+ errormsg(SH_DICT,ERROR_warn(0),e_lexobsolete1,shp->inlineno);
+ wordflags |=(ARG_MAC|ARG_EXP);
+ if(mode==ST_QUOTE)
+ ingrave = !ingrave;
+ /* FALL THRU */
+ case S_QUOTE:
+ if(oldmode()==ST_NONE && lexd.arith) /* in ((...)) */
+ continue;
+ if(n==S_QUOTE)
+ wordflags |=ARG_QUOTED;
+ if(mode!=ST_QUOTE)
+ {
+ if(c!='"' || mode!=ST_QNEST)
+ {
+ if(lexd.warn && lex.last_quote && shp->inlineno > shlex.lastline)
+ errormsg(SH_DICT,ERROR_warn(0),e_lexlongquote,shlex.lastline,lex.last_quote);
+ lex.last_quote=0;
+ shlex.lastline = shp->inlineno;
+ pushlevel(c,mode);
+ }
+ ingrave = (c=='`');
+ mode = ST_QUOTE;
+ continue;
+ }
+ else if((n=endchar())==c)
+ {
+ if(shp->inlineno > shlex.lastline)
+ lex.last_quote = c;
+ mode = oldmode();
+ poplevel();
+ }
+ else if(c=='"' && n==RBRACE)
+ mode = ST_QNEST;
+ break;
+ case S_DOL:
+ /* don't check syntax inside `` */
+ if(mode==ST_QUOTE && ingrave)
+ continue;
+#if SHOPT_KIA
+ if(lexd.first)
+ lexd.kiaoff = fcseek(0)-lexd.first;
+ else
+ lexd.kiaoff = staktell()+fcseek(0)-fcfirst();
+#endif /* SHOPT_KIA */
+ pushlevel('$',mode);
+ mode = ST_DOL;
+ continue;
+ case S_PAR:
+ wordflags |= ARG_MAC;
+ mode = oldmode();
+ poplevel();
+ fcseek(-1);
+ wordflags |= comsub(lp);
+ continue;
+ case S_RBRA:
+ if((n=endchar()) == '$')
+ goto err;
+ if(mode!=ST_QUOTE || n==RBRACE)
+ {
+ mode = oldmode();
+ poplevel();
+ }
+ break;
+ case S_EDOL:
+ /* end $identifier */
+#if SHOPT_KIA
+ if(shlex.kiafile)
+ refvar(0);
+#endif /* SHOPT_KIA */
+ if(lexd.warn && c==LBRACT)
+ errormsg(SH_DICT,ERROR_warn(0),e_lexusebrace,shp->inlineno);
+ fcseek(-1);
+ mode = oldmode();
+ poplevel();
+ break;
+ case S_DOT:
+ /* make sure next character is alpha */
+ if(fcgetc(n)>0)
+ fcseek(-1);
+ if(isaletter(n) || n==LBRACT)
+ continue;
+ if(mode==ST_NAME)
+ {
+ if(n=='=')
+ continue;
+ break;
+ }
+ else if(n==RBRACE)
+ continue;
+ if(isastchar(n))
+ continue;
+ goto err;
+ case S_SPC1:
+ wordflags |= ARG_MAC;
+ if(endchar()==RBRACE)
+ {
+ setchar(c);
+ continue;
+ }
+ /* FALL THRU */
+ case S_ALP:
+ if(c=='.' && endchar()=='$')
+ goto err;
+ case S_SPC2:
+ case S_DIG:
+ wordflags |= ARG_MAC;
+ switch(endchar())
+ {
+ case '$':
+ if(n==S_ALP) /* $identifier */
+ mode = ST_DOLNAME;
+ else
+ {
+ mode = oldmode();
+ poplevel();
+ }
+ break;
+#if SHOPT_TYPEDEF
+ case '@':
+#endif /* SHOPT_TYPEDEF */
+ case '!':
+ if(n!=S_ALP)
+ goto dolerr;
+ case '#':
+ case RBRACE:
+ if(n==S_ALP)
+ {
+ setchar(RBRACE);
+ if(c=='.')
+ fcseek(-1);
+ mode = ST_BRACE;
+ }
+ else
+ {
+ if(fcgetc(c)>0)
+ fcseek(-1);
+ if(state[c]==S_ALP)
+ goto err;
+ if(n==S_DIG)
+ setchar('0');
+ else
+ setchar('!');
+ }
+ break;
+ case '0':
+ if(n==S_DIG)
+ break;
+ default:
+ goto dolerr;
+ }
+ break;
+ dolerr:
+ case S_ERR:
+ if((n=endchar()) == '$')
+ goto err;
+ if(c=='*' || (n=sh_lexstates[ST_BRACE][c])!=S_MOD1 && n!=S_MOD2)
+ {
+ /* see whether inside `...` */
+ mode = oldmode();
+ poplevel();
+ if((n = endchar()) != '`')
+ goto err;
+ pushlevel(RBRACE,mode);
+ }
+ else
+ setchar(RBRACE);
+ mode = ST_NESTED;
+ continue;
+ case S_MOD1:
+ if(oldmode()==ST_QUOTE || oldmode()==ST_NONE)
+ {
+ /* allow ' inside "${...}" */
+ if(c==':' && fcgetc(n)>0)
+ {
+ n = state[n];
+ fcseek(-1);
+ }
+ if(n==S_MOD1)
+ {
+ mode = ST_QUOTE;
+ continue;
+ }
+ }
+ /* FALL THRU */
+ case S_MOD2:
+#if SHOPT_KIA
+ if(shlex.kiafile)
+ refvar(1);
+#endif /* SHOPT_KIA */
+ if(c!=':' && fcgetc(n)>0)
+ {
+ if(n!=c)
+ c = 0;
+ if(!c || (fcgetc(n)>0))
+ {
+ fcseek(-1);
+ if(n==LPAREN)
+ {
+ if(c!='%')
+ {
+ shlex.token = n;
+ sh_syntax();
+ }
+ else if(lexd.warn)
+ errormsg(SH_DICT,ERROR_warn(0),e_lexquote,shp->inlineno,'%');
+ }
+ }
+ }
+ mode = ST_NESTED;
+ continue;
+ case S_LBRA:
+ if((c=endchar()) == '$')
+ {
+ setchar(RBRACE);
+ if(fcgetc(c)>0)
+ fcseek(-1);
+ if(state[c]!=S_ERR && c!=RBRACE)
+ continue;
+ }
+ err:
+ n = endchar();
+ mode = oldmode();
+ poplevel();
+ if(n!='$')
+ {
+ shlex.token = c;
+ sh_syntax();
+ }
+ else
+ {
+ if(lexd.warn && c!='/' && sh_lexstates[ST_NORM][c]!=S_BREAK && (c!='"' || mode==ST_QUOTE))
+ errormsg(SH_DICT,ERROR_warn(0),e_lexslash,shp->inlineno);
+ else if(c=='"' && mode!=ST_QUOTE)
+ wordflags |= ARG_MESSAGE;
+ fcseek(-1);
+ }
+ continue;
+ case S_META:
+ if(lexd.warn && endchar()==RBRACE)
+ errormsg(SH_DICT,ERROR_warn(0),e_lexusequote,shp->inlineno,c);
+ continue;
+ case S_PUSH:
+ pushlevel(RPAREN,mode);
+ mode = ST_NESTED;
+ continue;
+ case S_POP:
+ do_pop:
+ if(lexd.level <= inlevel)
+ break;
+ n = endchar();
+ if(c==RBRACT && !(n==RBRACT || n==RPAREN))
+ continue;
+ if((c==RBRACE||c==RPAREN) && n==RPAREN)
+ {
+ if(fcgetc(n)==LPAREN)
+ {
+ if(c!=RPAREN)
+ fcseek(-1);
+ continue;
+ }
+ if(n>0)
+ fcseek(-1);
+ n = RPAREN;
+ }
+ if(c==';' && n!=';')
+ {
+ if(lexd.warn && n==RBRACE)
+ errormsg(SH_DICT,ERROR_warn(0),e_lexusequote,shp->inlineno,c);
+ continue;
+ }
+ if(mode==ST_QNEST)
+ {
+ if(lexd.warn)
+ errormsg(SH_DICT,ERROR_warn(0),e_lexescape,shp->inlineno,c);
+ continue;
+ }
+ mode = oldmode();
+ poplevel();
+ /* quotes in subscript need expansion */
+ if(mode==ST_NAME && (wordflags&ARG_QUOTED))
+ wordflags |= ARG_MAC;
+ /* check for ((...)) */
+ if(n==1 && c==RPAREN)
+ {
+ if(fcgetc(n)==RPAREN)
+ {
+ if(mode==ST_NONE && !lexd.dolparen)
+ goto breakloop;
+ lex.reservok = 1;
+ lex.skipword = 0;
+ return(shlex.token=EXPRSYM);
+ }
+ /* backward compatibility */
+ if(lexd.dolparen)
+ fcseek(-1);
+ else
+ {
+ if(lexd.warn)
+ errormsg(SH_DICT,ERROR_warn(0),e_lexnested,shp->inlineno);
+ if(!(state=lexd.first))
+ state = fcfirst();
+ fcseek(state-fcseek(0));
+ if(shlex.arg)
+ {
+ shlex.arg = (struct argnod*)stakfreeze(1);
+ setupalias(lp,shlex.arg->argval,NIL(Namval_t*));
+ }
+ lexd.paren = 1;
+ }
+ return(shlex.token=LPAREN);
+ }
+ if(mode==ST_NONE)
+ return(0);
+ if(c!=n)
+ {
+ shlex.token = c;
+ sh_syntax();
+ }
+ if(c==RBRACE && (mode==ST_NAME||mode==ST_NORM))
+ goto epat;
+ continue;
+ case S_EQ:
+ assignment = shlex.assignok;
+ /* FALL THRU */
+ case S_COLON:
+ if(assignment)
+ {
+ if((c=fcget())=='~')
+ wordflags |= ARG_MAC;
+ else if(c!=LPAREN && assignment==SH_COMPASSIGN)
+ assignment = 0;
+ fcseek(-1);
+ }
+ break;
+ case S_LABEL:
+ if(lex.reservok && !lex.incase)
+ {
+ c = fcget();
+ fcseek(-1);
+ if(state[c]==S_BREAK)
+ {
+ assignment = -1;
+ goto breakloop;
+ }
+ }
+ break;
+ case S_BRACT:
+ /* check for possible subscript */
+ if((n=endchar())==RBRACT || n==RPAREN ||
+ (mode==ST_BRACE) ||
+ (oldmode()==ST_NONE) ||
+ (mode==ST_NAME && (shlex.assignok||lexd.level)))
+ {
+ pushlevel(RBRACT,mode);
+ wordflags |= ARG_QUOTED;
+ mode = ST_NESTED;
+ continue;
+ }
+ wordflags |= ARG_EXP;
+ break;
+ case S_BRACE:
+ {
+ int isfirst;
+ if(lexd.dolparen)
+ break;
+ isfirst = (lexd.first&&fcseek(0)==lexd.first+1);
+ fcgetc(n);
+ /* check for {} */
+ if(c==LBRACE && n==RBRACE)
+ break;
+ if(n>0)
+ fcseek(-1);
+ else if(lex.reservok)
+ break;
+ /* check for reserved word { or } */
+ if(lex.reservok && state[n]==S_BREAK && isfirst)
+ break;
+ if(sh_isoption(SH_BRACEEXPAND) && c==LBRACE && !assignment && state[n]!=S_BREAK
+ && !lex.incase && !lex.intest
+ && !lex.skipword)
+ {
+ wordflags |= ARG_EXP;
+ }
+ if(c==RBRACE && n==LPAREN)
+ goto epat;
+ break;
+ }
+ case S_PAT:
+ wordflags |= ARG_EXP;
+ /* FALL THRU */
+ case S_EPAT:
+ epat:
+ if(fcgetc(n)==LPAREN)
+ {
+ if(lex.incase==TEST_RE)
+ {
+ lex.incase++;
+ pushlevel(RPAREN,ST_NORM);
+ mode = ST_NESTED;
+ }
+ wordflags |= ARG_EXP;
+ pushlevel(RPAREN,mode);
+ mode = ST_NESTED;
+ continue;
+ }
+ if(n>0)
+ fcseek(-1);
+ if(n=='=' && c=='+' && mode==ST_NAME)
+ continue;
+ break;
+ }
+ lex.comp_assign = 0;
+ if(mode==ST_NAME)
+ mode = ST_NORM;
+ else if(mode==ST_NONE)
+ return(0);
+ }
+breakloop:
+ if(lexd.dolparen)
+ {
+ lexd.balance = 0;
+ if(lexd.docword)
+ nested_here(lp);
+ lexd.message = (wordflags&ARG_MESSAGE);
+ return(shlex.token=0);
+ }
+ if(!(state=lexd.first))
+ state = fcfirst();
+ n = fcseek(0)-(char*)state;
+ if(!shlex.arg)
+ shlex.arg = (struct argnod*)stakseek(ARGVAL);
+ if(n>0)
+ stakwrite(state,n);
+ /* add balancing character if necessary */
+ if(lexd.balance)
+ {
+ stakputc(lexd.balance);
+ lexd.balance = 0;
+ }
+ stakputc(0);
+ stakseek(staktell()-1);
+ state = stakptr(ARGVAL);
+ n = staktell()-ARGVAL;
+ lexd.first=0;
+ if(n==1)
+ {
+ /* check for numbered redirection */
+ n = state[0];
+ if((c=='<' || c=='>') && isadigit(n))
+ {
+ c = sh_lex();
+ shlex.digits = (n-'0');
+ return(c);
+ }
+ if(n==LBRACT)
+ c = 0;
+ else if(n=='~')
+ c = ARG_MAC;
+ else
+ c = (wordflags&ARG_EXP);
+ n = 1;
+ }
+ else if(n>2 && state[0]=='{' && state[n-1]=='}' && !lex.intest && !lex.incase && (c=='<' || c== '>') && sh_isoption(SH_BRACEEXPAND))
+ {
+ if(!strchr(state,','))
+ {
+ stakseek(staktell()-1);
+ shlex.arg = (struct argnod*)stakfreeze(1);
+ return(shlex.token=IOVNAME);
+ }
+ c = wordflags;
+ }
+ else
+ c = wordflags;
+ if(assignment<0)
+ {
+ stakseek(staktell()-1);
+ shlex.arg = (struct argnod*)stakfreeze(1);
+ lex.reservok = 1;
+ return(shlex.token=LABLSYM);
+ }
+ if(assignment || (lex.intest&&!lex.incase) || mode==ST_NONE)
+ c &= ~ARG_EXP;
+ if((c&ARG_EXP) && (c&ARG_QUOTED))
+ c |= ARG_MAC;
+ if(mode==ST_NONE)
+ {
+ /* eliminate trailing )) */
+ stakseek(staktell()-2);
+ }
+ if(c&ARG_MESSAGE)
+ {
+ if(sh_isoption(SH_DICTIONARY))
+ shlex.arg = sh_endword(2);
+ if(!sh_isoption(SH_NOEXEC))
+ {
+ shlex.arg = sh_endword(1);
+ c &= ~ARG_MESSAGE;
+ }
+ }
+ if(c==0 || (c&(ARG_MAC|ARG_EXP)) || (lexd.warn && !lexd.docword))
+ {
+ shlex.arg = (struct argnod*)stakfreeze(1);
+ shlex.arg->argflag = (c?c:ARG_RAW);
+ }
+ else if(mode==ST_NONE)
+ shlex.arg = sh_endword(-1);
+ else
+ shlex.arg = sh_endword(0);
+ state = shlex.arg->argval;
+ lex.comp_assign = assignment;
+ if(assignment)
+ shlex.arg->argflag |= ARG_ASSIGN;
+ else if(!lex.skipword)
+ shlex.assignok = 0;
+ shlex.arg->argchn.cp = 0;
+ shlex.arg->argnxt.ap = 0;
+ if(mode==ST_NONE)
+ return(shlex.token=EXPRSYM);
+ if(lex.intest)
+ {
+ if(lex.testop1)
+ {
+ lex.testop1 = 0;
+ if(n==2 && state[0]=='-' && state[2]==0 &&
+ strchr(test_opchars,state[1]))
+ {
+ if(lexd.warn && state[1]=='a')
+ errormsg(SH_DICT,ERROR_warn(0),e_lexobsolete2,shp->inlineno);
+ shlex.digits = state[1];
+ shlex.token = TESTUNOP;
+ }
+ else if(n==1 && state[0]=='!' && state[1]==0)
+ {
+ lex.testop1 = 1;
+ shlex.token = '!';
+ }
+ else
+ {
+ lex.testop2 = 1;
+ shlex.token = 0;
+ }
+ return(shlex.token);
+ }
+ lex.incase = 0;
+ c = sh_lookup(state,shtab_testops);
+ switch(c)
+ {
+ case TEST_END:
+ lex.testop2 = lex.intest = 0;
+ lex.reservok = 1;
+ shlex.token = ETESTSYM;
+ return(shlex.token);
+
+ case TEST_SEQ:
+ if(lexd.warn && state[1]==0)
+ errormsg(SH_DICT,ERROR_warn(0),e_lexobsolete3,shp->inlineno);
+ /* FALL THRU */
+ default:
+ if(lex.testop2)
+ {
+ if(lexd.warn && (c&TEST_ARITH))
+ errormsg(SH_DICT,ERROR_warn(0),e_lexobsolete4,shp->inlineno,state);
+ if(c&TEST_PATTERN)
+ lex.incase = 1;
+ else if(c==TEST_REP)
+ lex.incase = TEST_RE;
+ lex.testop2 = 0;
+ shlex.digits = c;
+ shlex.token = TESTBINOP;
+ return(shlex.token);
+ }
+
+ case TEST_OR: case TEST_AND:
+ case 0:
+ return(shlex.token=0);
+ }
+ }
+ if(lex.reservok /* && !lex.incase*/ && n<=2)
+ {
+ /* check for {, }, ! */
+ c = state[0];
+ if(n==1 && (c=='{' || c=='}' || c=='!'))
+ {
+ if(lexd.warn && c=='{' && lex.incase==2)
+ errormsg(SH_DICT,ERROR_warn(0),e_lexobsolete6,shp->inlineno);
+ if(lex.incase==1 && c==RBRACE)
+ lex.incase = 0;
+ return(shlex.token=c);
+ }
+ else if(!lex.incase && c==LBRACT && state[1]==LBRACT)
+ {
+ lex.intest = lex.testop1 = 1;
+ lex.testop2 = lex.reservok = 0;
+ return(shlex.token=BTESTSYM);
+ }
+ }
+ c = 0;
+ if(!lex.skipword)
+ {
+ if(n>1 && lex.reservok==1 && mode==ST_NAME &&
+ (c=sh_lookup(state,shtab_reserved)))
+ {
+ if(lex.incase)
+ {
+ if(lex.incase >1)
+ lex.incase = 1;
+ else if(c==ESACSYM)
+ lex.incase = 0;
+ else
+ c = 0;
+ }
+ else if(c==FORSYM || c==CASESYM || c==SELECTSYM || c==FUNCTSYM || c==NSPACESYM)
+ {
+ lex.skipword = 1;
+ lex.incase = 2*(c==CASESYM);
+ }
+ else
+ lex.skipword = 0;
+ if(c==INSYM)
+ lex.reservok = 0;
+ else if(c==TIMESYM)
+ {
+ /* yech - POSIX requires time -p */
+ while(fcgetc(n)==' ' || n=='\t');
+ if(n>0)
+ fcseek(-1);
+ if(n=='-')
+ c=0;
+ }
+ return(shlex.token=c);
+ }
+ if(!(wordflags&ARG_QUOTED) && (lex.reservok||shlex.aliasok))
+ {
+ /* check for aliases */
+ Namval_t* np;
+ if(!lex.incase && !assignment && fcpeek(0)!=LPAREN &&
+ (np=nv_search(state,shp->alias_tree,HASH_SCOPE))
+ && !nv_isattr(np,NV_NOEXPAND)
+#if KSHELL
+ && (!sh_isstate(SH_NOALIAS) || nv_isattr(np,NV_NOFREE))
+#endif /* KSHELL */
+ && (state=nv_getval(np)))
+ {
+ setupalias(lp,state,np);
+ nv_onattr(np,NV_NOEXPAND);
+ lex.reservok = 1;
+ shlex.assignok |= lex.reservok;
+ return(sh_lex());
+ }
+ }
+ lex.reservok = 0;
+ }
+ lex.skipword = lexd.docword = 0;
+ return(shlex.token=c);
+}
+
+/*
+ * read to end of command substitution
+ */
+static int comsub(register Lex_t *lp)
+{
+ register int n,c,count=1;
+ register int line=shlex.sh->inlineno;
+ char word[5];
+ int messages=0, assignok=shlex.assignok;
+ struct lexstate save;
+ save = lex;
+ sh_lexopen(lp,shlex.sh,1);
+ lexd.dolparen++;
+ lex.incase=0;
+ pushlevel(0,0);
+ if(sh_lex()==LPAREN)
+ {
+ while(1)
+ {
+ /* look for case and esac */
+ n=0;
+ while(1)
+ {
+ fcgetc(c);
+ /* skip leading white space */
+ if(n==0 && !sh_lexstates[ST_BEGIN][c])
+ continue;
+ if(n==4)
+ break;
+ if(sh_lexstates[ST_NAME][c])
+ goto skip;
+ word[n++] = c;
+ }
+ if(sh_lexstates[ST_NAME][c]==S_BREAK)
+ {
+ if(memcmp(word,"case",4)==0)
+ lex.incase=1;
+ else if(memcmp(word,"esac",4)==0)
+ lex.incase=0;
+ }
+ skip:
+ if(c && (c!='#' || n==0))
+ fcseek(-1);
+ if(c==RBRACE && lex.incase)
+ lex.incase=0;
+ switch(sh_lex())
+ {
+ case LPAREN: case IPROCSYM: case OPROCSYM:
+ if(!lex.incase)
+ count++;
+ break;
+ case RPAREN:
+ if(lex.incase)
+ lex.incase=0;
+ else if(--count<=0)
+ goto done;
+ break;
+ case EOFSYM:
+ shlex.lastline = line;
+ shlex.lasttok = LPAREN;
+ sh_syntax();
+ case IOSEEKSYM:
+ if(fcgetc(c)!='#' && c>0)
+ fcseek(-1);
+ break;
+ case IODOCSYM:
+ sh_lex();
+ break;
+ case 0:
+ messages |= lexd.message;
+ }
+ }
+ }
+done:
+ poplevel();
+ shlex.lastline = line;
+ lexd.dolparen--;
+ lex = save;
+ shlex.assignok = (endchar()==RBRACT?assignok:0);
+ return(messages);
+}
+
+/*
+ * here-doc nested in $(...)
+ * allocate ionode with delimiter filled in without disturbing stak
+ */
+static void nested_here(register Lex_t *lp)
+{
+ register struct ionod *iop;
+ register int n,offset;
+ struct argnod *arg = shlex.arg;
+ char *base;
+ if(offset=staktell())
+ base = stakfreeze(0);
+ n = fcseek(0)-lexd.docend;
+ iop = newof(0,struct ionod,1,n+ARGVAL);
+ iop->iolst = shlex.heredoc;
+ stakseek(ARGVAL);
+ stakwrite(lexd.docend,n);
+ shlex.arg = sh_endword(0);
+ iop->ioname = (char*)(iop+1);
+ strcpy(iop->ioname,shlex.arg->argval);
+ iop->iofile = (IODOC|IORAW);
+ if(lexd.docword>1)
+ iop->iofile |= IOSTRIP;
+ shlex.heredoc = iop;
+ shlex.arg = arg;
+ lexd.docword = 0;
+ if(offset)
+ stakset(base,offset);
+ else
+ stakseek(0);
+}
+
+/*
+ * skip to <close> character
+ * if <copy> is non,zero, then the characters are copied to the stack
+ * <state> is the initial lexical state
+ */
+void sh_lexskip(int close, register int copy, int state)
+{
+ register Lex_t *lp = (Lex_t*)sh.lex_context;
+ register char *cp;
+ lexd.nest = close;
+ lexd.lex_state = state;
+ lexd.noarg = 1;
+ if(copy)
+ fcnotify(lex_advance);
+ else
+ lexd.nocopy++;
+ sh_lex();
+ lexd.noarg = 0;
+ if(copy)
+ {
+ fcnotify(0);
+ if(!(cp=lexd.first))
+ cp = fcfirst();
+ if((copy = fcseek(0)-cp) > 0)
+ stakwrite(cp,copy);
+ }
+ else
+ lexd.nocopy--;
+}
+
+#if SHOPT_CRNL
+ ssize_t _sfwrite(Sfio_t *sp, const Void_t *buff, size_t n)
+ {
+ const char *cp = (const char*)buff, *next=cp, *ep = cp + n;
+ int m=0,k;
+ while(next = (const char*)memchr(next,'\r',ep-next))
+ if(*++next=='\n')
+ {
+ if(k=next-cp-1)
+ {
+ if((k=sfwrite(sp,cp,k)) < 0)
+ return(m>0?m:-1);
+ m += k;
+ }
+ cp = next;
+ }
+ if((k=sfwrite(sp,cp,ep-cp)) < 0)
+ return(m>0?m:-1);
+ return(m+k);
+ }
+# define sfwrite _sfwrite
+#endif /* SHOPT_CRNL */
+
+/*
+ * read in here-document from script
+ * quoted here documents, and here-documents without special chars are
+ * noted with the IOQUOTE flag
+ * returns 1 for complete here-doc, 0 for EOF
+ */
+
+static int here_copy(Lex_t *lp,register struct ionod *iop)
+{
+ register const char *state;
+ register int c,n;
+ register char *bufp,*cp;
+ register Sfio_t *sp=shlex.sh->heredocs, *funlog;
+ int stripcol=0,stripflg, nsave, special=0;
+ if(funlog=shlex.sh->funlog)
+ {
+ if(fcfill()>0)
+ fcseek(-1);
+ shlex.sh->funlog = 0;
+ }
+ if(iop->iolst)
+ here_copy(lp,iop->iolst);
+ iop->iooffset = sfseek(sp,(off_t)0,SEEK_END);
+ iop->iosize = 0;
+ iop->iodelim=iop->ioname;
+ /* check for and strip quoted characters in delimiter string */
+ if(stripflg=iop->iofile&IOSTRIP)
+ {
+ while(*iop->iodelim=='\t')
+ iop->iodelim++;
+ /* skip over leading tabs in document */
+ if(iop->iofile&IOLSEEK)
+ {
+ iop->iofile &= ~IOLSEEK;
+ while(fcgetc(c)=='\t' || c==' ')
+ {
+ if(c==' ')
+ stripcol++;
+ else
+ stripcol += 8 - stripcol%8;
+ }
+ }
+ else
+ while(fcgetc(c)=='\t');
+ if(c>0)
+ fcseek(-1);
+ }
+ if(iop->iofile&IOQUOTE)
+ state = sh_lexstates[ST_LIT];
+ else
+ state = sh_lexstates[ST_QUOTE];
+ bufp = fcseek(0);
+ n = S_NL;
+ while(1)
+ {
+ if(n!=S_NL)
+ {
+ /* skip over regular characters */
+ while((n=STATE(state,c))==0);
+ }
+ if(n==S_EOF || !(c=fcget()))
+ {
+ if(!lexd.dolparen && (c=(fcseek(0)-1)-bufp))
+ {
+ if(n==S_ESC)
+ c--;
+ if((c=sfwrite(sp,bufp,c))>0)
+ iop->iosize += c;
+ }
+ if((c=lexfill())<=0)
+ break;
+ if(n==S_ESC)
+ {
+#if SHOPT_CRNL
+ if(c=='\r' && (c=fcget())!=NL)
+ fcseek(-1);
+#endif /* SHOPT_CRNL */
+ if(c==NL)
+ fcseek(1);
+ else
+ sfputc(sp,'\\');
+ }
+ bufp = fcseek(-1);
+ }
+ else
+ fcseek(-1);
+ switch(n)
+ {
+ case S_NL:
+ shlex.sh->inlineno++;
+ if((stripcol && c==' ') || (stripflg && c=='\t'))
+ {
+ if(!lexd.dolparen)
+ {
+ /* write out line */
+ n = fcseek(0)-bufp;
+ if((n=sfwrite(sp,bufp,n))>0)
+ iop->iosize += n;
+ }
+ /* skip over tabs */
+ if(stripcol)
+ {
+ int col=0;
+ do
+ {
+ fcgetc(c);
+ if(c==' ')
+ col++;
+ else
+ col += 8 - col%8;
+ if(col>stripcol)
+ break;
+ }
+ while (c==' ' || c=='\t');
+ }
+ else while(c=='\t')
+ fcgetc(c);
+ if(c<=0)
+ goto done;
+ bufp = fcseek(-1);
+ }
+ if(c!=iop->iodelim[0])
+ break;
+ cp = fcseek(0);
+ nsave = n = 0;
+ while(1)
+ {
+ if(!(c=fcget()))
+ {
+ if(!lexd.dolparen && (c=cp-bufp))
+ {
+ if((c=sfwrite(sp,cp=bufp,c))>0)
+ iop->iosize+=c;
+ }
+ nsave = n;
+ if((c=lexfill())<=0)
+ {
+ c = iop->iodelim[n]==0;
+ goto done;
+ }
+ }
+#if SHOPT_CRNL
+ if(c=='\r' && (c=fcget())!=NL)
+ {
+ if(c)
+ fcseek(-1);
+ c='\r';
+ }
+#endif /* SHOPT_CRNL */
+ if(c==NL)
+ shlex.sh->inlineno++;
+ if(iop->iodelim[n]==0 && (c==NL||c==RPAREN))
+ {
+ if(!lexd.dolparen && (n=cp-bufp))
+ {
+ if((n=sfwrite(sp,bufp,n))>0)
+ iop->iosize += n;
+ }
+ shlex.sh->inlineno--;
+ if(c==RPAREN)
+ fcseek(-1);
+ goto done;
+ }
+ if(iop->iodelim[n++]!=c)
+ {
+ /*
+ * The match for delimiter failed.
+ * nsave>0 only when a buffer boundary
+ * was crossed while checking the
+ * delimiter
+ */
+ if(!lexd.dolparen && nsave>0)
+ {
+ if((n=sfwrite(sp,bufp,nsave))>0)
+ iop->iosize += n;
+ bufp = fcfirst();
+ }
+ if(c==NL)
+ fcseek(-1);
+ break;
+ }
+ }
+ break;
+ case S_ESC:
+ n=1;
+#if SHOPT_CRNL
+ if(c=='\r')
+ {
+ fcseek(1);
+ if(c=fcget())
+ fcseek(-1);
+ if(c==NL)
+ n=2;
+ else
+ {
+ special++;
+ break;
+ }
+ }
+#endif /* SHOPT_CRNL */
+ if(c==NL)
+ {
+ /* new-line joining */
+ shlex.sh->inlineno++;
+ if(!lexd.dolparen && (n=(fcseek(0)-bufp)-n)>0)
+ {
+ if((n=sfwrite(sp,bufp,n))>0)
+ iop->iosize += n;
+ bufp = fcseek(0)+1;
+ }
+ }
+ else
+ special++;
+ fcget();
+ break;
+
+ case S_GRAVE:
+ case S_DOL:
+ special++;
+ break;
+ }
+ n=0;
+ }
+done:
+ shlex.sh->funlog = funlog;
+ if(lexd.dolparen)
+ free((void*)iop);
+ else if(!special)
+ iop->iofile |= IOQUOTE;
+ return(c);
+}
+
+/*
+ * generates string for given token
+ */
+static char *fmttoken(Lex_t *lp, register int sym, char *tok)
+{
+ if(sym < 0)
+ return((char*)sh_translate(e_lexzerobyte));
+ if(sym==0)
+ return(shlex.arg?shlex.arg->argval:"?");
+ if(lex.intest && shlex.arg && *shlex.arg->argval)
+ return(shlex.arg->argval);
+ if(sym&SYMRES)
+ {
+ register const Shtable_t *tp=shtab_reserved;
+ while(tp->sh_number && tp->sh_number!=sym)
+ tp++;
+ return((char*)tp->sh_name);
+ }
+ if(sym==EOFSYM)
+ return((char*)sh_translate(e_endoffile));
+ if(sym==NL)
+ return((char*)sh_translate(e_newline));
+ tok[0] = sym;
+ if(sym&SYMREP)
+ tok[1] = sym;
+ else
+ {
+ switch(sym&SYMMASK)
+ {
+ case SYMAMP:
+ sym = '&';
+ break;
+ case SYMPIPE:
+ sym = '|';
+ break;
+ case SYMGT:
+ sym = '>';
+ break;
+ case SYMLPAR:
+ sym = LPAREN;
+ break;
+ case SYMSHARP:
+ sym = '#';
+ break;
+ default:
+ sym = 0;
+ }
+ tok[1] = sym;
+ }
+ tok[2] = 0;
+ return(tok);
+}
+
+/*
+ * print a bad syntax message
+ */
+
+void sh_syntax(void)
+{
+ register Shell_t *shp = sh_getinterp();
+ register const char *cp = sh_translate(e_unexpected);
+ register char *tokstr;
+ register Lex_t *lp = (Lex_t*)shp->lex_context;
+ register int tok = shlex.token;
+ char tokbuf[3];
+ Sfio_t *sp;
+ if((tok==EOFSYM) && shlex.lasttok)
+ {
+ tok = shlex.lasttok;
+ cp = sh_translate(e_unmatched);
+ }
+ else
+ shlex.lastline = shp->inlineno;
+ tokstr = fmttoken(lp,tok,tokbuf);
+ if((sp=fcfile()) || (shp->infd>=0 && (sp=shp->sftable[shp->infd])))
+ {
+ /* clear out any pending input */
+ register Sfio_t *top;
+ while(fcget()>0);
+ fcclose();
+ while(top=sfstack(sp,SF_POPSTACK))
+ sfclose(top);
+ }
+ else
+ fcclose();
+ shp->inlineno = shlex.inlineno;
+ shp->st.firstline = shlex.firstline;
+#if KSHELL
+ if(!sh_isstate(SH_INTERACTIVE) && !sh_isstate(SH_PROFILE))
+#else
+ if(shp->inlineno!=1)
+#endif
+ errormsg(SH_DICT,ERROR_exit(SYNBAD),e_lexsyntax1,shlex.lastline,tokstr,cp);
+ else
+ errormsg(SH_DICT,ERROR_exit(SYNBAD),e_lexsyntax2,tokstr,cp);
+}
+
+static char *stack_shift(register char *sp,char *dp)
+{
+ register char *ep;
+ register int offset = staktell();
+ register int left = offset-(sp-stakptr(0));
+ register int shift = (dp+1-sp);
+ offset += shift;
+ stakseek(offset);
+ sp = stakptr(offset);
+ ep = sp - shift;
+ while(left--)
+ *--sp = *--ep;
+ return(sp);
+}
+
+/*
+ * Assumes that current word is unfrozen on top of the stak
+ * If <mode> is zero, gets rid of quoting and consider argument as string
+ * and returns pointer to frozen arg
+ * If mode==1, just replace $"..." strings with international strings
+ * The result is left on the stak
+ * If mode==2, the each $"" string is printed on standard output
+ */
+struct argnod *sh_endword(int mode)
+{
+ register const char *state = sh_lexstates[ST_NESTED];
+ register int n;
+ register char *sp,*dp;
+ register int inquote=0, inlit=0; /* set within quoted strings */
+ struct argnod* argp=0;
+ char *ep=0, *xp=0;
+ int bracket=0;
+ stakputc(0);
+ sp = stakptr(ARGVAL);
+#if SHOPT_MULTIBYTE
+ if(mbwide())
+ {
+ do
+ {
+ int len;
+ switch(len = mbsize(sp))
+ {
+ case -1: /* illegal multi-byte char */
+ case 0:
+ case 1:
+ n=state[*sp++];
+ break;
+ default:
+ /*
+ * None of the state tables contain
+ * entries for multibyte characters,
+ * however, they should be treated
+ * the same as any other alph
+ * character. Therefore, we'll use
+ * the state of the 'a' character.
+ */
+ n=state['a'];
+ sp += len;
+ }
+ }
+ while(n == 0);
+ }
+ else
+#endif /* SHOPT_MULTIBYTE */
+ while((n=state[*sp++])==0);
+ dp = sp;
+ if(mode<0)
+ inquote = 1;
+ while(1)
+ {
+ switch(n)
+ {
+ case S_EOF:
+ stakseek(dp-stakptr(0));
+ if(mode<=0)
+ {
+ argp = (struct argnod*)stakfreeze(0);
+ argp->argflag = ARG_RAW|ARG_QUOTED;
+ }
+ return(argp);
+ case S_LIT:
+ if(!(inquote&1))
+ {
+ inlit = !inlit;
+ if(mode==0 || (mode<0 && bracket))
+ {
+ dp--;
+ if(ep)
+ {
+ *dp = 0;
+ dp = ep+stresc(ep);
+ }
+ ep = 0;
+ }
+ }
+ break;
+ case S_QUOTE:
+ if(mode<0 && !bracket)
+ break;
+ if(!inlit)
+ {
+ if(mode<=0)
+ dp--;
+ inquote = inquote^1;
+ if(ep)
+ {
+ char *msg;
+ if(mode==2)
+ {
+ sfprintf(sfstdout,"%.*s\n",dp-ep,ep);
+ ep = 0;
+ break;
+ }
+ *--dp = 0;
+#if ERROR_VERSION >= 20000317L
+ msg = ERROR_translate(0,error_info.id,0,ep);
+#else
+# if ERROR_VERSION >= 20000101L
+ msg = ERROR_translate(error_info.id,ep);
+# else
+ msg = ERROR_translate(ep,2);
+# endif
+#endif
+ n = strlen(msg);
+ dp = ep+n;
+ if(sp-dp <= 1)
+ {
+ sp = stack_shift(sp,dp);
+ dp = sp-1;
+ ep = dp-n;
+ }
+ memmove(ep,msg,n);
+ *dp++ = '"';
+ }
+ ep = 0;
+ }
+ break;
+ case S_DOL: /* check for $'...' and $"..." */
+ if(inlit)
+ break;
+ if(*sp==LPAREN || *sp==LBRACE)
+ {
+ inquote <<= 1;
+ break;
+ }
+ if(inquote&1)
+ break;
+ if(*sp=='\'' || *sp=='"')
+ {
+ if(*sp=='"')
+ inquote |= 1;
+ else
+ inlit = 1;
+ sp++;
+ if((mode==0||(mode<0&&bracket)) || (inquote&1))
+ {
+ if(mode==2)
+ ep = dp++;
+ else if(mode==1)
+ (ep=dp)[-1] = '"';
+ else
+ ep = --dp;
+ }
+ }
+ break;
+ case S_ESC:
+#if SHOPT_CRNL
+ if(*sp=='\r' && sp[1]=='\n')
+ sp++;
+#endif /* SHOPT_CRNL */
+ if(inlit || mode>0)
+ {
+ if(mode<0)
+ {
+ if(dp>=sp)
+ {
+ sp = stack_shift(sp,dp+1);
+ dp = sp-2;
+ }
+ *dp++ = '\\';
+ }
+ if(ep)
+ *dp++ = *sp++;
+ break;
+ }
+ n = *sp;
+#if SHOPT_DOS
+ if(!(inquote&1) && sh_lexstates[ST_NORM][n]==0)
+ break;
+#endif /* SHOPT_DOS */
+ if(!(inquote&1) || (sh_lexstates[ST_QUOTE][n] && n!=RBRACE))
+ {
+ if(n=='\n')
+ dp--;
+ else
+ dp[-1] = n;
+ sp++;
+ }
+ break;
+ case S_POP:
+ if(sp[-1]!=RBRACT)
+ break;
+ if(!inlit && !(inquote&1))
+ {
+ inquote >>= 1;
+ if(xp)
+ dp = sh_checkid(xp,dp);
+ xp = 0;
+ if(--bracket<=0 && mode<0)
+ inquote = 1;
+ }
+ else if((inlit||inquote) && mode<0)
+ {
+ dp[-1] = '\\';
+ if(dp>=sp)
+ {
+ sp = stack_shift(sp,dp);
+ dp = sp-1;
+ }
+ *dp++ = ']';
+ }
+ break;
+ case S_BRACT:
+ if(dp[-2]=='.')
+ xp = dp;
+ if(mode<0)
+ {
+ if(inlit || (bracket&&inquote))
+ {
+ dp[-1] = '\\';
+ if(dp>=sp)
+ {
+ sp = stack_shift(sp,dp);
+ dp = sp-1;
+ }
+ *dp++ = '[';
+ }
+ else if(bracket++==0)
+ inquote = 0;
+ }
+ break;
+ }
+#if SHOPT_MULTIBYTE
+ if(mbwide())
+ {
+ do
+ {
+ int len;
+ switch(len = mbsize(sp))
+ {
+ case -1: /* illegal multi-byte char */
+ case 0:
+ case 1:
+ n=state[*dp++ = *sp++];
+ break;
+ default:
+ /*
+ * None of the state tables contain
+ * entries for multibyte characters,
+ * however, they should be treated
+ * the same as any other alph
+ * character. Therefore, we'll use
+ * the state of the 'a' character.
+ */
+ while(len--)
+ *dp++ = *sp++;
+ n=state['a'];
+ }
+ }
+ while(n == 0);
+ }
+ else
+#endif /* SHOPT_MULTIBYTE */
+ while((n=state[*dp++ = *sp++])==0);
+ }
+}
+
+struct alias
+{
+ Sfdisc_t disc;
+ Namval_t *np;
+ int nextc;
+ int line;
+ char buf[2];
+ Lex_t *lp;
+};
+
+/*
+ * This code gets called whenever an end of string is found with alias
+ */
+
+#ifndef SF_ATEXIT
+# define SF_ATEXIT 0
+#endif
+/*
+ * This code gets called whenever an end of string is found with alias
+ */
+#ifdef SF_BUFCONST
+static int alias_exceptf(Sfio_t *iop,int type,void *data, Sfdisc_t *handle)
+#else
+static int alias_exceptf(Sfio_t *iop,int type,Sfdisc_t *handle)
+#endif
+{
+ register struct alias *ap = (struct alias*)handle;
+ register Namval_t *np;
+ register Lex_t *lp;
+ if(type==0 || type==SF_ATEXIT || !ap)
+ return(0);
+ lp = ap->lp;
+ np = ap->np;
+ if(type!=SF_READ)
+ {
+ if(type==SF_CLOSING)
+ {
+ register Sfdisc_t *dp = sfdisc(iop,SF_POPDISC);
+ if(dp!=handle)
+ sfdisc(iop,dp);
+ }
+ else if(type==SF_FINAL)
+ free((void*)ap);
+ goto done;
+ }
+ if(ap->nextc)
+ {
+ /* if last character is a blank, then next work can be alias */
+ register int c = fcpeek(-1);
+ if(isblank(c))
+ shlex.aliasok = 1;
+ *ap->buf = ap->nextc;
+ ap->nextc = 0;
+ sfsetbuf(iop,ap->buf,1);
+ return(1);
+ }
+done:
+ if(np)
+ nv_offattr(np,NV_NOEXPAND);
+ return(0);
+}
+
+
+static void setupalias(Lex_t *lp, const char *string,Namval_t *np)
+{
+ register Sfio_t *iop, *base;
+ struct alias *ap = (struct alias*)malloc(sizeof(struct alias));
+ ap->disc = alias_disc;
+ ap->lp = lp;
+ ap->buf[1] = 0;
+ if(ap->np = np)
+ {
+#if SHOPT_KIA
+ if(shlex.kiafile)
+ {
+ unsigned long r;
+ r=kiaentity(nv_name(np),-1,'p',0,0,shlex.current,'a',0,"");
+ sfprintf(shlex.kiatmp,"p;%..64d;p;%..64d;%d;%d;e;\n",shlex.current,r,shlex.sh->inlineno,shlex.sh->inlineno);
+ }
+#endif /* SHOPT_KIA */
+ if((ap->nextc=fcget())==0)
+ ap->nextc = ' ';
+ }
+ else
+ ap->nextc = 0;
+ iop = sfopen(NIL(Sfio_t*),(char*)string,"s");
+ sfdisc(iop, &ap->disc);
+ lexd.nocopy++;
+ if(!(base=fcfile()))
+ base = sfopen(NIL(Sfio_t*),fcseek(0),"s");
+ fcclose();
+ sfstack(base,iop);
+ fcfopen(base);
+ lexd.nocopy--;
+}
+
+/*
+ * grow storage stack for nested constructs by STACK_ARRAY
+ */
+static int stack_grow(Lex_t *lp)
+{
+ lexd.lex_max += STACK_ARRAY;
+ if(lexd.lex_match)
+ lexd.lex_match = (int*)realloc((char*)lexd.lex_match,sizeof(int)*lexd.lex_max);
+ else
+ lexd.lex_match = (int*)malloc(sizeof(int)*STACK_ARRAY);
+ return(lexd.lex_match!=0);
+}
+
diff --git a/usr/src/lib/libshell/common/sh/macro.c b/usr/src/lib/libshell/common/sh/macro.c
new file mode 100644
index 0000000000..8108050b14
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/macro.c
@@ -0,0 +1,2301 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Shell macro expander
+ * expands ~
+ * expands ${...}
+ * expands $(...)
+ * expands $((...))
+ * expands `...`
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#include "defs.h"
+#include <fcin.h>
+#include <pwd.h>
+#include "name.h"
+#include "variables.h"
+#include "shlex.h"
+#include "io.h"
+#include "shnodes.h"
+#include "path.h"
+#include "national.h"
+#include "streval.h"
+
+#undef STR_GROUP
+#ifndef STR_GROUP
+# define STR_GROUP 0
+#endif
+
+#if !SHOPT_MULTIBYTE
+#define mbchar(p) (*(unsigned char*)p++)
+#endif
+
+static int _c_;
+typedef struct _mac_
+{
+ Shell_t *shp; /* pointer to shell interpreter */
+ Sfio_t *sp; /* stream pointer for here-document */
+ struct argnod **arghead; /* address of head of argument list */
+ char *ifsp; /* pointer to IFS value */
+ int fields; /* number of fields */
+ short quoted; /* set when word has quotes */
+ unsigned char ifs; /* first char of IFS */
+ char quote; /* set within double quoted contexts */
+ char lit; /* set within single quotes */
+ char split; /* set when word splittin is possible */
+ char pattern; /* set when file expansion follows */
+ char patfound; /* set if pattern character found */
+ char assign; /* set for assignments */
+ char arith; /* set for ((...)) */
+ char let; /* set when expanding let arguments */
+ char zeros; /* strip leading zeros when set */
+ void *nvwalk; /* for name space walking*/
+} Mac_t;
+
+#define mac (*((Mac_t*)(sh.mac_context)))
+
+#undef ESCAPE
+#define ESCAPE '\\'
+#define isescchar(s) ((s)>S_QUOTE)
+#define isqescchar(s) ((s)>=S_QUOTE)
+#define isbracechar(c) ((c)==RBRACE || (_c_=sh_lexstates[ST_BRACE][c])==S_MOD1 ||_c_==S_MOD2)
+#define ltos(x) fmtbase((long)(x),0,0)
+
+/* type of macro expansions */
+#define M_BRACE 1 /* ${var} */
+#define M_TREE 2 /* ${var.} */
+#define M_SIZE 3 /* ${#var} */
+#define M_VNAME 4 /* ${!var} */
+#define M_SUBNAME 5 /* ${!var[sub]} */
+#define M_NAMESCAN 6 /* ${!var*} */
+#define M_NAMECOUNT 7 /* ${#var*} */
+#define M_TYPE 8 /* ${@var} */
+
+static int substring(const char*, const char*, int[], int);
+static void copyto(Mac_t*, int, int);
+static void comsubst(Mac_t*,int);
+static int varsub(Mac_t*);
+static void mac_copy(Mac_t*,const char*, int);
+static void tilde_expand2(int);
+static char *sh_tilde(const char*);
+static char *special(int);
+static void endfield(Mac_t*,int);
+static void mac_error(Namval_t*);
+static char *mac_getstring(char*);
+static int charlen(const char*,int);
+#if SHOPT_MULTIBYTE
+ static char *lastchar(const char*,const char*);
+#endif /* SHOPT_MULTIBYTE */
+
+void *sh_macopen(Shell_t *shp)
+{
+ void *addr = newof(0,Mac_t,1,0);
+ Mac_t *mp = (Mac_t*)addr;
+ mp->shp = shp;
+ return(addr);
+}
+
+/*
+ * perform only parameter substitution and catch failures
+ */
+char *sh_mactry(register char *string)
+{
+ if(string)
+ {
+ int jmp_val;
+ int savexit = sh.savexit;
+ struct checkpt buff;
+ sh_pushcontext(&buff,SH_JMPSUB);
+ jmp_val = sigsetjmp(buff.buff,0);
+ if(jmp_val == 0)
+ string = sh_mactrim(string,0);
+ sh_popcontext(&buff);
+ sh.savexit = savexit;
+ return(string);
+ }
+ return("");
+}
+
+/*
+ * Perform parameter expansion, command substitution, and arithmetic
+ * expansion on <str>.
+ * If <mode> greater than 1 file expansion is performed if the result
+ * yields a single pathname.
+ * If <mode> negative, than expansion rules for assignment are applied.
+ */
+char *sh_mactrim(char *str, register int mode)
+{
+ register Mac_t *mp = (Mac_t*)sh.mac_context;
+ Mac_t savemac;
+ savemac = *mp;
+ stakseek(0);
+ mp->arith = (mode==3);
+ mp->let = 0;
+ sh.argaddr = 0;
+ mp->pattern = (mode==1||mode==2);
+ mp->patfound = 0;
+ mp->assign = (mode<0);
+ mp->quoted = mp->lit = mp->split = mp->quote = 0;
+ mp->sp = 0;
+ if(mp->ifsp=nv_getval(nv_scoped(IFSNOD)))
+ mp->ifs = *mp->ifsp;
+ else
+ mp->ifs = ' ';
+ stakseek(0);
+ fcsopen(str);
+ copyto(mp,0,mp->arith);
+ str = stakfreeze(1);
+ if(mode==2)
+ {
+ /* expand only if unique */
+ struct argnod *arglist=0;
+ if((mode=path_expand(str,&arglist))==1)
+ str = arglist->argval;
+ else if(mode>1)
+ errormsg(SH_DICT,ERROR_exit(1),e_ambiguous,str);
+ sh_trim(str);
+ }
+ *mp = savemac;
+ return(str);
+}
+
+/*
+ * Perform all the expansions on the argument <argp>
+ */
+int sh_macexpand(register struct argnod *argp, struct argnod **arghead,int flag)
+{
+ register int flags = argp->argflag;
+ register char *str = argp->argval;
+ register Mac_t *mp = (Mac_t*)sh.mac_context;
+ char **saveargaddr = sh.argaddr;
+ Mac_t savemac;
+ savemac = *mp;
+ mp->sp = 0;
+ if(mp->ifsp=nv_getval(nv_scoped(IFSNOD)))
+ mp->ifs = *mp->ifsp;
+ else
+ mp->ifs = ' ';
+ if(flag&ARG_OPTIMIZE)
+ sh.argaddr = (char**)&argp->argchn.ap;
+ else
+ sh.argaddr = 0;
+ mp->arghead = arghead;
+ mp->quoted = mp->lit = mp->quote = 0;
+ mp->arith = ((flag&ARG_ARITH)!=0);
+ mp->let = ((flag&ARG_LET)!=0);
+ mp->split = !(flag&ARG_ASSIGN);
+ mp->assign = !mp->split;
+ mp->pattern = mp->split && !(flag&ARG_NOGLOB) && !sh_isoption(SH_NOGLOB);
+ str = argp->argval;
+ fcsopen(str);
+ mp->fields = 0;
+ if(!arghead)
+ {
+ mp->split = 0;
+ mp->pattern = ((flag&ARG_EXP)!=0);
+ stakseek(0);
+ }
+ else
+ {
+ stakseek(ARGVAL);
+ *stakptr(ARGVAL-1) = 0;
+ }
+ mp->patfound = 0;
+ copyto(mp,0,mp->arith);
+ if(!arghead)
+ {
+ argp->argchn.cp = stakfreeze(1);
+ if(sh.argaddr)
+ argp->argflag |= ARG_MAKE;
+ }
+ else
+ {
+ endfield(mp,mp->quoted);
+ flags = mp->fields;
+ if(flags==1 && sh.argaddr)
+ argp->argchn.ap = *arghead;
+ }
+ sh.argaddr = saveargaddr;
+ *mp = savemac;
+ return(flags);
+}
+
+/*
+ * Expand here document which is stored in <infile> or <string>
+ * The result is written to <outfile>
+ */
+void sh_machere(Sfio_t *infile, Sfio_t *outfile, char *string)
+{
+ register int c,n;
+ register const char *state = sh_lexstates[ST_QUOTE];
+ register char *cp;
+ register Mac_t *mp = (Mac_t*)sh.mac_context;
+ Fcin_t save;
+ Mac_t savemac;
+ savemac = *mp;
+ stakseek(0);
+ sh.argaddr = 0;
+ mp->sp = outfile;
+ mp->split = mp->assign = mp->pattern = mp->patfound = mp->lit = mp->arith = mp->let = 0;
+ mp->quote = 1;
+ mp->ifsp = nv_getval(nv_scoped(IFSNOD));
+ mp->ifs = ' ';
+ fcsave(&save);
+ if(infile)
+ fcfopen(infile);
+ else
+ fcsopen(string);
+ fcnotify(0);
+ cp = fcseek(0);
+ while(1)
+ {
+#if SHOPT_MULTIBYTE
+ if(mbwide())
+ {
+ do
+ {
+ ssize_t len;
+ switch(len = mbsize(cp))
+ {
+ case -1: /* illegal multi-byte char */
+ case 0:
+ case 1:
+ n=state[*(unsigned char*)cp++];
+ break;
+ default:
+ /* use state of alpah character */
+ n=state['a'];
+ cp += len;
+ }
+ }
+ while(n == 0);
+ }
+ else
+#endif /* SHOPT_MULTIBYTE */
+ while((n=state[*(unsigned char*)cp++])==0);
+ if(n==S_NL || n==S_QUOTE || n==S_RBRA)
+ continue;
+ if(c=(cp-1)-fcseek(0))
+ sfwrite(outfile,fcseek(0),c);
+ cp = fcseek(c+1);
+ switch(n)
+ {
+ case S_EOF:
+ if((n=fcfill()) <=0)
+ {
+ /* ignore 0 byte when reading from file */
+ if(n==0 && fcfile())
+ continue;
+ fcrestore(&save);
+ *mp = savemac;
+ return;
+ }
+ cp = fcseek(-1);
+ continue;
+ case S_ESC:
+ fcgetc(c);
+ cp=fcseek(-1);
+ if(c>0)
+ cp++;
+ if(!isescchar(state[c]))
+ sfputc(outfile,ESCAPE);
+ continue;
+ case S_GRAVE:
+ comsubst(mp,0);
+ break;
+ case S_DOL:
+ c = fcget();
+ if(c=='.')
+ goto regular;
+ again:
+ switch(n=sh_lexstates[ST_DOL][c])
+ {
+ case S_ALP: case S_SPC1: case S_SPC2:
+ case S_DIG: case S_LBRA:
+ {
+ Fcin_t save2;
+ int offset = staktell();
+ int offset2;
+ stakputc(c);
+ if(n==S_LBRA)
+ sh_lexskip(RBRACE,1,ST_BRACE);
+ else if(n==S_ALP)
+ {
+ while(fcgetc(c),isaname(c))
+ stakputc(c);
+ fcseek(-1);
+ }
+ stakputc(0);
+ offset2 = staktell();
+ fcsave(&save2);
+ fcsopen(stakptr(offset));
+ varsub(mp);
+ if(c=staktell()-offset2)
+ sfwrite(outfile,(char*)stakptr(offset2),c);
+ fcrestore(&save2);
+ stakseek(offset);
+ break;
+ }
+ case S_PAR:
+ comsubst(mp,1);
+ break;
+ case S_EOF:
+ if((c=fcfill()) > 0)
+ goto again;
+ /* FALL THRU */
+ default:
+ regular:
+ sfputc(outfile,'$');
+ fcseek(-1);
+ break;
+ }
+ }
+ cp = fcseek(0);
+ }
+}
+
+/*
+ * expand argument but do not trim pattern characters
+ */
+char *sh_macpat(register struct argnod *arg, int flags)
+{
+ register char *sp = arg->argval;
+ if((arg->argflag&ARG_RAW))
+ return(sp);
+ if(flags&ARG_OPTIMIZE)
+ arg->argchn.ap=0;
+ if(!(sp=arg->argchn.cp))
+ {
+ sh_macexpand(arg,NIL(struct argnod**),flags);
+ sp = arg->argchn.cp;
+ if(!(flags&ARG_OPTIMIZE) || !(arg->argflag&ARG_MAKE))
+ arg->argchn.cp = 0;
+ arg->argflag &= ~ARG_MAKE;
+ }
+ else
+ sh.optcount++;
+ return(sp);
+}
+
+/*
+ * Process the characters up to <endch> or end of input string
+ */
+static void copyto(register Mac_t *mp,int endch, int newquote)
+{
+ register int c,n;
+ register const char *state = sh_lexstates[ST_MACRO];
+ register char *cp,*first;
+ int tilde = -1;
+ int oldquote = mp->quote;
+ int ansi_c = 0;
+ int paren = 0;
+ int ere = 0;
+ int brace = 0;
+ Sfio_t *sp = mp->sp;
+ mp->sp = NIL(Sfio_t*);
+ mp->quote = newquote;
+ first = cp = fcseek(0);
+ if(!mp->quote && *cp=='~')
+ tilde = staktell();
+ /* handle // operator specially */
+ if(mp->pattern==2 && *cp=='/')
+ cp++;
+ while(1)
+ {
+#if SHOPT_MULTIBYTE
+ if(mbwide())
+ {
+ ssize_t len;
+ do
+ {
+ switch(len = mbsize(cp))
+ {
+ case -1: /* illegal multi-byte char */
+ case 0:
+ len = 1;
+ case 1:
+ n = state[*(unsigned char*)cp++];
+ break;
+ default:
+ /* treat as if alpha */
+ cp += len;
+ n=state['a'];
+ }
+ }
+ while(n == 0);
+ c = (cp-len) - first;
+ }
+ else
+#endif /* SHOPT_MULTIBYTE */
+ {
+ while((n=state[*(unsigned char*)cp++])==0);
+ c = (cp-1) - first;
+ }
+ switch(n)
+ {
+ case S_ESC:
+ if(ansi_c)
+ {
+ /* process ANSI-C escape character */
+ char *addr= --cp;
+ if(c)
+ stakwrite(first,c);
+ c = chresc(cp,&addr);
+ cp = addr;
+ first = fcseek(cp-first);
+#if SHOPT_MULTIBYTE
+ if(c > UCHAR_MAX && mbwide())
+ {
+ int i;
+ unsigned char mb[8];
+
+ n = wctomb((char*)mb, c);
+ for(i=0;i<n;i++)
+ stakputc(mb[i]);
+ }
+ else
+#endif /* SHOPT_MULTIBYTE */
+ stakputc(c);
+ if(c==ESCAPE && mp->pattern)
+ stakputc(ESCAPE);
+ break;
+ }
+ else if(sh_isoption(SH_BRACEEXPAND) && mp->pattern==4 && (*cp==',' || *cp==LBRACE || *cp==RBRACE || *cp=='.'))
+ break;
+ else if(mp->split && endch && !mp->quote && !mp->lit)
+ {
+ if(c)
+ mac_copy(mp,first,c);
+ cp = fcseek(c+2);
+ if(c= cp[-1])
+ {
+ stakputc(c);
+ if(c==ESCAPE)
+ stakputc(ESCAPE);
+ }
+ else
+ cp--;
+ first = cp;
+ break;
+ }
+ n = state[*(unsigned char*)cp];
+ if(n==S_ENDCH && *cp!=endch)
+ n = S_PAT;
+ if(mp->pattern)
+ {
+ /* preserve \digit for pattern matching */
+ /* also \alpha for extended patterns */
+ if(!mp->lit && !mp->quote && (n==S_DIG || ((paren+ere) && sh_lexstates[ST_DOL][*(unsigned char*)cp]==S_ALP)))
+ break;
+ /* followed by file expansion */
+ if(!mp->lit && (n==S_ESC || (!mp->quote &&
+ (n==S_PAT||n==S_ENDCH||n==S_SLASH||n==S_BRACT||*cp=='-'))))
+ {
+ cp += (n!=S_EOF);
+ break;
+ }
+ if(mp->lit || (mp->quote && !isqescchar(n) && n!=S_ENDCH))
+ {
+ /* add \ for file expansion */
+ stakwrite(first,c+1);
+ first = fcseek(c);
+ break;
+ }
+ }
+ if(mp->lit)
+ break;
+ if(!mp->quote || isqescchar(n) || n==S_ENDCH)
+ {
+ /* eliminate \ */
+ if(c)
+ stakwrite(first,c);
+ /* check new-line joining */
+ first = fcseek(c+1);
+ }
+ cp += (n!=S_EOF);
+ break;
+ case S_GRAVE: case S_DOL:
+ if(mp->lit)
+ break;
+ if(c)
+ {
+ if(mp->split && !mp->quote && endch)
+ mac_copy(mp,first,c);
+ else
+ stakwrite(first,c);
+ }
+ first = fcseek(c+1);
+ c = mp->pattern;
+ if(n==S_GRAVE)
+ comsubst(mp,0);
+ else if((n= *cp)==0 || !varsub(mp))
+ {
+ if(n=='\'' && !mp->quote)
+ ansi_c = 1;
+ else if(mp->quote || n!='"')
+ stakputc('$');
+ }
+ cp = first = fcseek(0);
+ if(*cp)
+ mp->pattern = c;
+ break;
+ case S_ENDCH:
+ if((mp->lit || cp[-1]!=endch || mp->quote!=newquote))
+ goto pattern;
+ if(endch==RBRACE && *cp==LPAREN && mp->pattern && brace)
+ goto pattern;
+ case S_EOF:
+ if(c)
+ {
+ if(mp->split && !mp->quote && !mp->lit && endch)
+ mac_copy(mp,first,c);
+ else
+ stakwrite(first,c);
+ }
+ c += (n!=S_EOF);
+ first = fcseek(c);
+ if(tilde>=0)
+ tilde_expand2(tilde);
+ goto done;
+ case S_QUOTE:
+ if(mp->lit || mp->arith)
+ break;
+ case S_LIT:
+ if(mp->arith)
+ {
+ if((*cp=='`' || *cp=='[') && cp[1]=='\'')
+ cp +=2;
+ break;
+ }
+ if(n==S_LIT && mp->quote)
+ break;
+ if(c)
+ {
+ if(mp->split && endch && !mp->quote && !mp->lit)
+ mac_copy(mp,first,c);
+ else
+ stakwrite(first,c);
+ }
+ first = fcseek(c+1);
+ if(n==S_LIT)
+ {
+ if(mp->quote)
+ continue;
+ if(mp->lit)
+ mp->lit = ansi_c = 0;
+ else
+ mp->lit = 1;
+ }
+ else
+ mp->quote = !mp->quote;
+ mp->quoted++;
+ break;
+ case S_BRACT:
+ if(mp->arith || ((mp->assign==1 || endch==RBRACT) &&
+ !(mp->quote || mp->lit)))
+ {
+ int offset=0,oldpat = mp->pattern;
+ int oldarith = mp->arith;
+ stakwrite(first,++c);
+ if(mp->assign==1 && first[c-2]=='.')
+ offset = staktell();
+ first = fcseek(c);
+ mp->pattern = 4;
+ mp->arith = 0;
+ copyto(mp,RBRACT,0);
+ mp->arith = oldarith;
+ mp->pattern = oldpat;
+ stakputc(RBRACT);
+ if(offset)
+ {
+ cp = stakptr(staktell());
+ if(sh_checkid(stakptr(offset),cp)!=cp)
+ stakseek(staktell()-2);
+ }
+ cp = first = fcseek(0);
+ break;
+ }
+ case S_PAT:
+ if(mp->pattern && !(mp->quote || mp->lit))
+ {
+ mp->patfound = mp->pattern;
+ if((n=cp[-1])==LPAREN)
+ {
+ paren++;
+ if((cp-first)>1 && cp[-2]=='~')
+ {
+ char *p = cp;
+ while((c=mbchar(p)) && c!=RPAREN && c!='E');
+ ere = c=='E';
+ }
+ }
+ else if(n==RPAREN)
+ --paren;
+ }
+ goto pattern;
+ case S_BRACE:
+ if(!(mp->quote || mp->lit))
+ {
+ mp->patfound = mp->split && sh_isoption(SH_BRACEEXPAND);
+ brace = 1;
+ }
+ pattern:
+ if(!mp->pattern || !(mp->quote || mp->lit))
+ {
+ /* mark beginning of {a,b} */
+ if(n==S_BRACE && endch==0 && mp->pattern)
+ mp->pattern=4;
+ if(n==S_SLASH && mp->pattern==2)
+ mp->pattern=3;
+ break;
+ }
+ if(mp->pattern==3)
+ break;
+ if(c)
+ stakwrite(first,c);
+ first = fcseek(c);
+ stakputc(ESCAPE);
+ break;
+ case S_EQ:
+ if(mp->assign==1)
+ {
+ if(*cp=='~' && !endch && !mp->quote && !mp->lit)
+ tilde = staktell()+(c+1);
+ mp->assign = 2;
+ }
+ break;
+ case S_SLASH:
+ case S_COLON:
+ if(tilde >=0)
+ {
+ if(c)
+ stakwrite(first,c);
+ first = fcseek(c);
+ tilde_expand2(tilde);
+ tilde = -1;
+ c=0;
+ }
+ if(n==S_COLON && mp->assign==2 && *cp=='~' && endch==0 && !mp->quote &&!mp->lit)
+ tilde = staktell()+(c+1);
+ else if(n==S_SLASH && mp->pattern==2)
+#if 0
+ goto pattern;
+#else
+ {
+ if(mp->quote || mp->lit)
+ goto pattern;
+ stakwrite(first,c+1);
+ first = fcseek(c+1);
+ c = staktell();
+ sh_lexskip(RBRACE,0,ST_NESTED);
+ stakseek(c);
+ cp = fcseek(-1);
+ stakwrite(first,cp-first);
+ first=cp;
+ }
+#endif
+ break;
+ }
+ }
+done:
+ mp->sp = sp;
+ mp->quote = oldquote;
+}
+
+/*
+ * copy <str> to stack performing sub-expression substitutions
+ */
+static void mac_substitute(Mac_t *mp, register char *cp,char *str,register int subexp[],int subsize)
+{
+ register int c,n;
+#if 0
+ register char *first=cp;
+#else
+ register char *first=fcseek(0);
+ char *ptr;
+ Mac_t savemac;
+ n = staktell();
+ savemac = *mp;
+ mp->pattern = 3;
+ mp->split = 0;
+ fcsopen(cp);
+ copyto(mp,0,0);
+ stakputc(0);
+ ptr = cp = strdup(stakptr(n));
+ stakseek(n);
+ *mp = savemac;
+ fcsopen(first);
+ first = cp;
+#endif
+ while(1)
+ {
+ while((c= *cp++) && c!=ESCAPE);
+ if(c==0)
+ break;
+ if((n= *cp++)=='\\' || n==RBRACE || (n>='0' && n<='9' && (n-='0')<subsize))
+ {
+ c = cp-first-2;
+ if(c)
+ mac_copy(mp,first,c);
+ first=cp;
+ if(n=='\\' || n==RBRACE)
+ {
+ first--;
+ continue;
+ }
+ if((c=subexp[2*n])>=0)
+ {
+ if((n=subexp[2*n+1]-c)>0)
+ mac_copy(mp,str+c,n);
+ }
+ }
+ else if(n==0)
+ break;
+ }
+ if(n=cp-first-1)
+ mac_copy(mp,first,n);
+#if 1
+ free(ptr);
+#endif
+}
+
+#if SHOPT_FILESCAN
+#define MAX_OFFSETS (sizeof(shp->offsets)/sizeof(shp->offsets[0]))
+#define MAX_ARGN (32*1024)
+
+/*
+ * compute the arguments $1 ... $n and $# from the current line as needed
+ * save line offsets in the offsets array.
+ */
+static char *getdolarg(Shell_t *shp, int n, int *size)
+{
+ register int c=S_DELIM, d=shp->ifstable['\\'];
+ register unsigned char *first,*last,*cp = (unsigned char*)shp->cur_line;
+ register int m=shp->offsets[0],delim=0;
+ if(m==0)
+ return(0);
+ if(m<0)
+ m = 0;
+ else if(n<=m)
+ m = n-1;
+ else
+ m--;
+ if(m >= MAX_OFFSETS-1)
+ m = MAX_OFFSETS-2;
+ cp += shp->offsets[m+1];
+ n -= m;
+ shp->ifstable['\\'] = 0;
+ shp->ifstable[0] = S_EOF;
+ while(1)
+ {
+ if(c==S_DELIM)
+ while(shp->ifstable[*cp++]==S_SPACE);
+ first = --cp;
+ if(++m < MAX_OFFSETS)
+ shp->offsets[m] = (first-(unsigned char*)shp->cur_line);
+ while((c=shp->ifstable[*cp++])==0);
+ last = cp-1;
+ if(c==S_SPACE)
+ while((c=shp->ifstable[*cp++])==S_SPACE);
+ if(--n==0 || c==S_EOF)
+ {
+ if(last==first && c==S_EOF && (!delim || (m>1)))
+ {
+ n++;
+ m--;
+ }
+ break;
+ }
+ delim = (c==S_DELIM);
+ }
+ shp->ifstable['\\'] = d;
+ if(m > shp->offsets[0])
+ shp->offsets[0] = m;
+ if(n)
+ first = last = 0;
+ if(size)
+ *size = last-first;
+ return((char*)first);
+}
+#endif /* SHOPT_FILESCAN */
+
+/*
+ * get the prefix after name reference resolution
+ */
+static char *prefix(char *id)
+{
+ Namval_t *np;
+ register char *cp = strchr(id,'.');
+ if(cp)
+ {
+ *cp = 0;
+ np = nv_search(id, sh.var_tree,0);
+ *cp = '.';
+ if(isastchar(cp[1]))
+ cp[1] = 0;
+ if(np && nv_isref(np))
+ {
+ int n;
+ char *sp;
+ sh.argaddr = 0;
+ while(nv_isref(np))
+ np = nv_refnode(np);
+ id = (char*)malloc(strlen(cp)+1+(n=strlen(sp=nv_name(np)))+1);
+ strcpy(&id[n],cp);
+ memcpy(id,sp,n);
+ return(id);
+ }
+ }
+ return(strdup(id));
+}
+
+/*
+ * copy to ']' onto the stack and return offset to it
+ */
+static int subcopy(Mac_t *mp, int flag)
+{
+ int split = mp->split;
+ int xpattern = mp->pattern;
+ int loc = staktell();
+ int xarith = mp->arith;
+ mp->split = 0;
+ mp->arith = 0;
+ mp->pattern = flag?4:0;
+ copyto(mp,RBRACT,0);
+ mp->pattern = xpattern;
+ mp->split = split;
+ mp->arith = xarith;
+ return(loc);
+}
+
+static int namecount(Mac_t *mp,const char *prefix)
+{
+ int count = 0;
+ mp->nvwalk = nv_diropen(prefix);
+ while(nv_dirnext(mp->nvwalk))
+ count++;
+ nv_dirclose(mp->nvwalk);
+ return(count);
+}
+
+static char *nextname(Mac_t *mp,const char *prefix, int len)
+{
+ char *cp;
+ if(len==0)
+ {
+ mp->nvwalk = nv_diropen(prefix);
+ return((char*)mp->nvwalk);
+ }
+ if(!(cp=nv_dirnext(mp->nvwalk)))
+ nv_dirclose(mp->nvwalk);
+ return(cp);
+}
+
+/*
+ * This routine handles $param, ${parm}, and ${param op word}
+ * The input stream is assumed to be a string
+ */
+static int varsub(Mac_t *mp)
+{
+ register int c;
+ register int type=0; /* M_xxx */
+ register char *v,*argp=0;
+ register Namval_t *np = NIL(Namval_t*);
+ register int dolg=0, mode=0;
+ Namarr_t *ap=0;
+ int dolmax=0, vsize= -1, offset= -1, nulflg, replen=0, bysub=0;
+ char idbuff[3], *id = idbuff, *pattern=0, *repstr;
+ int oldpat=mp->pattern,idnum=0,flag=0,d;
+retry1:
+ mp->zeros = 0;
+ idbuff[0] = 0;
+ idbuff[1] = 0;
+ c = fcget();
+ switch(c>0x7f?S_ALP:sh_lexstates[ST_DOL][c])
+ {
+ case S_RBRA:
+ if(type<M_SIZE)
+ goto nosub;
+ /* This code handles ${#} */
+ c = mode;
+ mode = type = 0;
+ /* FALL THRU */
+ case S_SPC1:
+ if(type==M_BRACE)
+ {
+ if(isaletter(mode=fcpeek(0)) || mode=='.')
+ {
+ if(c=='#')
+ type = M_SIZE;
+#ifdef SHOPT_TYPEDEF
+ else if(c=='@')
+ {
+ type = M_TYPE;
+ goto retry1;
+ }
+#endif /* SHOPT_TYPEDEF */
+ else
+ type = M_VNAME;
+ mode = c;
+ goto retry1;
+ }
+ else if(c=='#' && (isadigit(mode)||fcpeek(1)==RBRACE))
+ {
+ type = M_SIZE;
+ mode = c;
+ goto retry1;
+ }
+ }
+ /* FALL THRU */
+ case S_SPC2:
+ *id = c;
+ v = special(c);
+ if(isastchar(c))
+ {
+ mode = c;
+#if SHOPT_FILESCAN
+ if(sh.cur_line)
+ {
+ v = getdolarg(&sh,1,(int*)0);
+ dolmax = MAX_ARGN;
+ }
+ else
+#endif /* SHOPT_FILESCAN */
+ dolmax = sh.st.dolc+1;
+ dolg = (v!=0);
+ }
+ break;
+ case S_LBRA:
+ if(type)
+ goto nosub;
+ type = M_BRACE;
+ goto retry1;
+ case S_PAR:
+ if(type)
+ goto nosub;
+ comsubst(mp,1);
+ return(1);
+ case S_DIG:
+ c -= '0';
+ sh.argaddr = 0;
+ if(type)
+ {
+ register int d;
+ while((d=fcget()),isadigit(d))
+ c = 10*c + (d-'0');
+ fcseek(-1);
+ }
+ idnum = c;
+ if(c==0)
+ v = special(c);
+#if SHOPT_FILESCAN
+ else if(sh.cur_line)
+ {
+ sh.used_pos = 1;
+ v = getdolarg(&sh,c,&vsize);
+ }
+#endif /* SHOPT_FILESCAN */
+ else if(c <= sh.st.dolc)
+ {
+ sh.used_pos = 1;
+ v = sh.st.dolv[c];
+ }
+ else
+ v = 0;
+ break;
+ case S_ALP:
+ if(c=='.' && type==0)
+ goto nosub;
+ offset = staktell();
+ do
+ {
+ np = 0;
+ do
+ stakputc(c);
+ while(((c=fcget()),(c>0x7f||isaname(c)))||type && c=='.');
+ while(c==LBRACT && type)
+ {
+ sh.argaddr=0;
+ if((c=fcget(),isastchar(c)) && fcpeek(0)==RBRACT)
+ {
+ if(type==M_VNAME)
+ type = M_SUBNAME;
+ idbuff[0] = mode = c;
+ fcget();
+ c = fcget();
+ if(c=='.' || c==LBRACT)
+ {
+ stakputc(LBRACT);
+ stakputc(mode);
+ stakputc(RBRACT);
+ }
+ else
+ flag = NV_ARRAY;
+ break;
+ }
+ else
+ {
+ fcseek(-1);
+ if(type==M_VNAME)
+ type = M_SUBNAME;
+ stakputc(LBRACT);
+ v = stakptr(subcopy(mp,1));
+ stakputc(RBRACT);
+ c = fcget();
+ }
+ }
+ }
+ while(type && c=='.');
+ if(c==RBRACE && type && fcpeek(-2)=='.')
+ {
+ stakseek(staktell()-1);
+ type = M_TREE;
+ }
+ stakputc(0);
+ id=stakptr(offset);
+ if(isastchar(c) && type)
+ {
+ if(type==M_VNAME || type==M_SIZE)
+ {
+ idbuff[0] = mode = c;
+ if((d=fcpeek(0))==c)
+ idbuff[1] = fcget();
+ if(type==M_VNAME)
+ type = M_NAMESCAN;
+ else
+ type = M_NAMECOUNT;
+ break;
+ }
+ goto nosub;
+ }
+ flag |= NV_NOASSIGN|NV_VARNAME|NV_NOADD;
+ if(c=='=' || c=='?' || (c==':' && ((d=fcpeek(0))=='=' || d=='?')))
+ flag &= ~NV_NOADD;
+#if SHOPT_FILESCAN
+ if(sh.cur_line && *id=='R' && strcmp(id,"REPLY")==0)
+ {
+ sh.argaddr=0;
+ np = REPLYNOD;
+ }
+ else
+#endif /* SHOPT_FILESCAN */
+ if(sh.argaddr)
+ flag &= ~NV_NOADD;
+ np = nv_open(id,sh.var_tree,flag|NV_NOFAIL);
+ ap = np?nv_arrayptr(np):0;
+ if(type)
+ {
+ if(ap && isastchar(mode) && !(ap->nelem&ARRAY_SCAN))
+ nv_putsub(np,NIL(char*),ARRAY_SCAN);
+ if(!isbracechar(c))
+ goto nosub;
+ else
+ fcseek(-1);
+ }
+ else
+ fcseek(-1);
+ if((type==M_VNAME||type==M_SUBNAME) && sh.argaddr && strcmp(nv_name(np),id))
+ sh.argaddr = 0;
+ c = (type>M_BRACE && isastchar(mode));
+ if(np && (!c || !ap))
+ {
+ if(type==M_VNAME)
+ {
+ type = M_BRACE;
+ v = nv_name(np);
+ }
+#ifdef SHOPT_TYPEDEF
+ else if(type==M_TYPE)
+ {
+#if 0
+ Namval_t *nq = nv_type(np);
+#else
+ Namval_t *nq = 0;
+#endif
+ type = M_BRACE;
+ if(nq)
+ v = nv_name(nq);
+ else
+ {
+ nv_attribute(np,sh.strbuf,"typeset",1);
+ v = sfstruse(sh.strbuf);
+ }
+ }
+#endif /* SHOPT_TYPEDEF */
+#if SHOPT_FILESCAN
+ else if(sh.cur_line && np==REPLYNOD)
+ v = sh.cur_line;
+#endif /* SHOPT_FILESCAN */
+ else if(type==M_TREE)
+ v = nv_getvtree(np,(Namfun_t*)0);
+ else
+ {
+ v = nv_getval(np);
+ /* special case --- ignore leading zeros */
+ if( (mp->arith||mp->let) && (np->nvfun || nv_isattr(np,(NV_LJUST|NV_RJUST|NV_ZFILL))) && (offset==0 || !isalnum(*((unsigned char*)stakptr(offset-1)))))
+ mp->zeros = 1;
+ }
+ }
+ else
+ v = 0;
+ stakseek(offset);
+ if(ap)
+ {
+#if SHOPT_OPTIMIZE
+ if(sh.argaddr)
+ nv_optimize(np);
+#endif
+ if(isastchar(mode) && array_elem(ap)> !c)
+ dolg = -1;
+ else
+ dolg = 0;
+ }
+ break;
+ case S_EOF:
+ fcseek(-1);
+ default:
+ goto nosub;
+ }
+ c = fcget();
+ if(type>M_TREE)
+ {
+ if(c!=RBRACE)
+ mac_error(np);
+ if(type==M_NAMESCAN || type==M_NAMECOUNT)
+ {
+ id = prefix(id);
+ stakseek(offset);
+ if(type==M_NAMECOUNT)
+ {
+ c = namecount(mp,id);
+ v = ltos(c);
+ }
+ else
+ {
+ dolmax = strlen(id);
+ dolg = -1;
+ nextname(mp,id,0);
+ v = nextname(mp,id,dolmax);
+ }
+ }
+ else if(type==M_SUBNAME)
+ {
+ if(dolg<0)
+ {
+ v = nv_getsub(np);
+ bysub=1;
+ }
+ else if(v)
+ {
+ if(!ap || isastchar(mode))
+ v = "0";
+ else
+ v = nv_getsub(np);
+ }
+ }
+ else
+ {
+ if(!isastchar(mode))
+ c = charlen(v,vsize);
+ else if(dolg>0)
+ {
+#if SHOPT_FILESCAN
+ if(sh.cur_line)
+ {
+ getdolarg(&sh,MAX_ARGN,(int*)0);
+ c = sh.offsets[0];
+ }
+ else
+#endif /* SHOPT_FILESCAN */
+ c = sh.st.dolc;
+ }
+ else if(dolg<0)
+ c = array_elem(ap);
+ else
+ c = (v!=0);
+ dolg = dolmax = 0;
+ v = ltos(c);
+ }
+ c = RBRACE;
+ }
+ nulflg = 0;
+ if(type && c==':')
+ {
+ c = fcget();
+ if(sh_lexstates[ST_BRACE][c]==S_MOD1 && c!='*' && c!= ':')
+ nulflg=1;
+ else if(c!='%' && c!='#')
+ {
+ fcseek(-1);
+ c = ':';
+ }
+ }
+ if(type)
+ {
+ if(!isbracechar(c))
+ {
+ if(!nulflg)
+ mac_error(np);
+ fcseek(-1);
+ c = ':';
+ }
+ if(c!=RBRACE)
+ {
+ int newops = (c=='#' || c == '%' || c=='/');
+ offset = staktell();
+ if(c=='/' ||c==':' || ((!v || (nulflg && *v==0)) ^ (c=='+'||c=='#'||c=='%')))
+ {
+ int newquote = mp->quote;
+ int split = mp->split;
+ int quoted = mp->quoted;
+ int arith = mp->arith;
+ int zeros = mp->zeros;
+ if(newops)
+ {
+ type = fcget();
+ if(type=='%' || type=='#')
+ {
+ int d = fcget();
+ fcseek(-1);
+ if(d=='(')
+ type = 0;
+ }
+ fcseek(-1);
+ mp->pattern = 1+(c=='/');
+ mp->split = 0;
+ mp->quoted = 0;
+ mp->arith = mp->zeros = 0;
+ newquote = 0;
+ }
+ else if(c=='?' || c=='=')
+ mp->split = mp->pattern = 0;
+ copyto(mp,RBRACE,newquote);
+ if(!oldpat)
+ mp->patfound = 0;
+ mp->pattern = oldpat;
+ mp->split = split;
+ mp->quoted = quoted;
+ mp->arith = arith;
+ mp->zeros = zeros;
+ /* add null byte */
+ stakputc(0);
+ stakseek(staktell()-1);
+ }
+ else
+ {
+ sh_lexskip(RBRACE,0,(!newops&&mp->quote)?ST_QUOTE:ST_NESTED);
+ stakseek(offset);
+ }
+ argp=stakptr(offset);
+ }
+ }
+ else
+ {
+ fcseek(-1);
+ c=0;
+ }
+ if(c==':') /* ${name:expr1[:expr2]} */
+ {
+ char *ptr;
+ type = (int)sh_strnum(argp,&ptr,1);
+ if(isastchar(mode))
+ {
+ if(id==idbuff) /* ${@} or ${*} */
+ {
+ if(type<0 && (type+= dolmax)<0)
+ type = 0;
+ if(type==0)
+ v = special(dolg=0);
+#if SHOPT_FILESCAN
+ else if(sh.cur_line)
+ {
+ v = getdolarg(&sh,dolg=type,&vsize);
+ if(!v)
+ dolmax = type;
+ }
+#endif /* SHOPT_FILESCAN */
+ else if(type < dolmax)
+ v = sh.st.dolv[dolg=type];
+ else
+ v = 0;
+ }
+ else if(ap)
+ {
+ if(type<0)
+ {
+ if(array_assoc(ap))
+ type = -type;
+ else
+ type += array_maxindex(np);
+ }
+ if(array_assoc(ap))
+ {
+ while(type-- >0 && (v=0,nv_nextsub(np)))
+ v = nv_getval(np);
+ }
+ else if(type > 0)
+ {
+ if(nv_putsub(np,NIL(char*),type|ARRAY_SCAN))
+ v = nv_getval(np);
+ else
+ v = 0;
+ }
+ }
+ else if(type>0)
+ v = 0;
+ }
+ else if(v)
+ {
+ vsize = charlen(v,vsize);
+ if(type<0 && (type += vsize)<0)
+ type = 0;
+ if(vsize < type)
+ v = 0;
+#if SHOPT_MULTIBYTE
+ else if(mbwide())
+ {
+ mbinit();
+ while(type-->0)
+ {
+ if((c=mbsize(v))<1)
+ c = 1;
+ v += c;
+ }
+ c = ':';
+ }
+#endif /* SHOPT_MULTIBYTE */
+ else
+ v += type;
+ vsize -= type;
+ }
+ if(*ptr==':')
+ {
+ if((type = (int)sh_strnum(ptr+1,&ptr,1)) <=0)
+ v = 0;
+ else if(isastchar(mode))
+ {
+ if(dolg>=0)
+ {
+ if(dolg+type < dolmax)
+ dolmax = dolg+type;
+ }
+ else
+ dolmax = type;
+ }
+ else if(type < vsize)
+ {
+#if SHOPT_MULTIBYTE
+ if(mbwide())
+ {
+ char *vp = v;
+ mbinit();
+ while(type-->0)
+ {
+ if((c=mbsize(vp))<1)
+ c = 1;
+ vp += c;
+ }
+ type = vp-v;
+ c = ':';
+ }
+#endif /* SHOPT_MULTIBYTE */
+ vsize = type;
+ }
+ }
+ if(*ptr)
+ mac_error(np);
+ stakseek(offset);
+ argp = 0;
+ }
+ /* check for substring operations */
+ else if(c == '#' || c == '%' || c=='/')
+ {
+ if(c=='/')
+ {
+ if(type=='/' || type=='#' || type=='%')
+ {
+ c = type;
+ type = '/';
+ argp++;
+ }
+ else
+ type = 0;
+ }
+ else
+ {
+ if(type==c) /* ## or %% */
+ argp++;
+ else
+ type = 0;
+ }
+ pattern = strdup(argp);
+ if((type=='/' || c=='/') && (repstr = mac_getstring(pattern)))
+ replen = strlen(repstr);
+ if(v || c=='/' && offset>=0)
+ stakseek(offset);
+ }
+ /* check for quoted @ */
+ if(mode=='@' && mp->quote && !v && c!='-')
+ mp->quoted-=2;
+retry2:
+ if(v && (!nulflg || *v ) && c!='+')
+ {
+ register int d = (mode=='@'?' ':mp->ifs);
+ int match[2*(MATCH_MAX+1)], nmatch, vsize_last;
+ char *vlast;
+ while(1)
+ {
+ if(!v)
+ v= "";
+ if(c=='/' || c=='#' || c== '%')
+ {
+ flag = (type || c=='/')?STR_GROUP|STR_MAXIMAL:STR_GROUP;
+ if(c!='/')
+ flag |= STR_LEFT;
+ while(1)
+ {
+ vsize = strlen(v);
+ if(c=='%')
+ nmatch=substring(v,pattern,match,flag&STR_MAXIMAL);
+ else
+ nmatch=strgrpmatch(v,pattern,match,elementsof(match)/2,flag);
+ if(replen>0)
+ sh_setmatch(v,vsize,nmatch,match);
+ if(nmatch)
+ {
+ vlast = v;
+ vsize_last = vsize;
+ vsize = match[0];
+ }
+ else if(c=='#')
+ vsize = 0;
+ if(vsize)
+ mac_copy(mp,v,vsize);
+ if(nmatch && replen>0)
+ mac_substitute(mp,repstr,v,match,nmatch);
+ if(nmatch==0)
+ v += vsize;
+ else
+ v += match[1];
+ if(*v && c=='/' && type)
+ {
+ /* avoid infinite loop */
+ if(nmatch && match[1]==0)
+ v++;
+ continue;
+ }
+ vsize = -1;
+ break;
+ }
+ if(replen==0)
+ sh_setmatch(vlast,vsize_last,nmatch,match);
+ }
+ if(vsize)
+ mac_copy(mp,v,vsize>0?vsize:strlen(v));
+ if(dolg==0 && dolmax==0)
+ break;
+ if(dolg>=0)
+ {
+ if(++dolg >= dolmax)
+ break;
+#if SHOPT_FILESCAN
+ if(sh.cur_line)
+ {
+ if(dolmax==MAX_ARGN && isastchar(mode))
+ break;
+ if(!(v=getdolarg(&sh,dolg,&vsize)))
+ {
+ dolmax = dolg;
+ break;
+ }
+ }
+ else
+#endif /* SHOPT_FILESCAN */
+ v = sh.st.dolv[dolg];
+ }
+ else if(!np)
+ {
+ if(!(v = nextname(mp,id,dolmax)))
+ break;
+ }
+ else
+ {
+ if(dolmax && --dolmax <=0)
+ {
+ nv_putsub(np,NIL(char*),ARRAY_UNDEF);
+ break;
+ }
+ if(nv_nextsub(np) == 0)
+ break;
+ if(bysub)
+ v = nv_getsub(np);
+ else
+ v = nv_getval(np);
+ }
+ if(mp->split && (!mp->quote || mode=='@'))
+ {
+ if(!np)
+ mp->pattern = 0;
+ endfield(mp,mp->quoted);
+ mp->pattern = oldpat;
+ }
+ else if(d)
+ {
+ if(mp->sp)
+ sfputc(mp->sp,d);
+ else
+ stakputc(d);
+ }
+ }
+ if(pattern)
+ free((void*)pattern);
+ }
+ else if(argp)
+ {
+ if(c=='/' && replen>0 && pattern && strmatch("",pattern))
+ mac_substitute(mp,repstr,v,0,0);
+ if(c=='?')
+ {
+ if(np)
+ id = nv_name(np);
+ else if(idnum)
+ id = ltos(idnum);
+ if(*argp)
+ {
+ stakputc(0);
+ errormsg(SH_DICT,ERROR_exit(1),"%s: %s",id,argp);
+ }
+ else if(v)
+ errormsg(SH_DICT,ERROR_exit(1),e_nullset,id);
+ else
+ errormsg(SH_DICT,ERROR_exit(1),e_notset,id);
+ }
+ else if(c=='=')
+ {
+ if(np)
+ {
+ if(sh.subshell)
+ np = sh_assignok(np,1);
+ nv_putval(np,argp,0);
+ v = nv_getval(np);
+ nulflg = 0;
+ stakseek(offset);
+ goto retry2;
+ }
+ else
+ mac_error(np);
+ }
+ }
+ else if(sh_isoption(SH_NOUNSET) && (!np || nv_isnull(np) || (nv_isarray(np) && !np->nvalue.cp)))
+ {
+ if(np)
+ {
+ if(nv_isarray(np))
+ {
+ sfprintf(sh.strbuf,"%s[%s]\0",nv_name(np),nv_getsub(np));
+ id = nv_getsub(np);
+ id = sfstruse(sh.strbuf);
+ }
+ else
+ id = nv_name(np);
+ nv_close(np);
+ }
+ errormsg(SH_DICT,ERROR_exit(1),e_notset,id);
+ }
+ if(np)
+ nv_close(np);
+ return(1);
+nosub:
+ if(type)
+ mac_error(np);
+ fcseek(-1);
+ nv_close(np);
+ return(0);
+}
+
+/*
+ * This routine handles command substitution
+ * <type> is 0 for older `...` version
+ */
+static void comsubst(Mac_t *mp,int type)
+{
+ Sfdouble_t num;
+ register int c;
+ register char *str;
+ Sfio_t *sp;
+ Fcin_t save;
+ struct slnod *saveslp = sh.st.staklist;
+ struct _mac_ savemac;
+ int savtop = staktell();
+ char lastc, *savptr = stakfreeze(0);
+ int was_history = sh_isstate(SH_HISTORY);
+ int was_verbose = sh_isstate(SH_VERBOSE);
+ int newlines,bufsize;
+ register Shnode_t *t;
+ Namval_t *np;
+ sh.argaddr = 0;
+ savemac = *mp;
+ sh.st.staklist=0;
+ if(type)
+ {
+ sp = 0;
+ fcseek(-1);
+ t = sh_dolparen();
+ if(t && t->tre.tretyp==TARITH)
+ {
+ str = t->ar.arexpr->argval;
+ fcsave(&save);
+ if(!(t->ar.arexpr->argflag&ARG_RAW))
+ str = sh_mactrim(str,3);
+ num = sh_arith(str);
+ out_offset:
+ stakset(savptr,savtop);
+ *mp = savemac;
+ if((Sflong_t)num==num)
+ sfprintf(sh.strbuf,"%lld",(Sflong_t)num);
+ else
+ sfprintf(sh.strbuf,"%.*Lg",LDBL_DIG,num);
+ str = sfstruse(sh.strbuf);
+ mac_copy(mp,str,strlen(str));
+ sh.st.staklist = saveslp;
+ fcrestore(&save);
+ return;
+ }
+ }
+ else
+ {
+ while(fcgetc(c)!='`' && c)
+ {
+ if(c==ESCAPE)
+ {
+ fcgetc(c);
+ if(!(isescchar(sh_lexstates[ST_QUOTE][c]) ||
+ (c=='"' && mp->quote)) || (c=='$' && fcpeek(0)=='\''))
+ stakputc(ESCAPE);
+ }
+ stakputc(c);
+ }
+ c = staktell();
+ str=stakfreeze(1);
+ /* disable verbose and don't save in history file */
+ sh_offstate(SH_HISTORY);
+ sh_offstate(SH_VERBOSE);
+ if(mp->sp)
+ sfsync(mp->sp); /* flush before executing command */
+ sp = sfnew(NIL(Sfio_t*),str,c,-1,SF_STRING|SF_READ);
+ c = sh.inlineno;
+ sh.inlineno = error_info.line+sh.st.firstline;
+ t = (Shnode_t*)sh_parse(mp->shp, sp,SH_EOF|SH_NL);
+ sh.inlineno = c;
+ }
+#if KSHELL
+ if(t)
+ {
+ fcsave(&save);
+ sfclose(sp);
+ if(t->tre.tretyp==0 && !t->com.comarg)
+ {
+ /* special case $(<file) and $(<#file) */
+ register int fd;
+ int r;
+ struct checkpt buff;
+ struct ionod *ip=0;
+ sh_pushcontext(&buff,SH_JMPIO);
+ if((ip=t->tre.treio) &&
+ ((ip->iofile&IOLSEEK) || !(ip->iofile&IOUFD)) &&
+ (r=sigsetjmp(buff.buff,0))==0)
+ fd = sh_redirect(ip,3);
+ else
+ fd = sh_chkopen(e_devnull);
+ sh_popcontext(&buff);
+ if(r==0 && ip && (ip->iofile&IOLSEEK))
+ {
+ if(sp=sh.sftable[fd])
+ num = sftell(sp);
+ else
+ num = lseek(fd, (off_t)0, SEEK_CUR);
+ goto out_offset;
+ }
+ sp = sfnew(NIL(Sfio_t*),(char*)malloc(IOBSIZE+1),IOBSIZE,fd,SF_READ|SF_MALLOC);
+ }
+ else
+ sp = sh_subshell(t,sh_isstate(SH_ERREXIT),1);
+ fcrestore(&save);
+ }
+ else
+ sp = sfopen(NIL(Sfio_t*),"","sr");
+ sh_freeup();
+ sh.st.staklist = saveslp;
+ if(was_history)
+ sh_onstate(SH_HISTORY);
+ if(was_verbose)
+ sh_onstate(SH_VERBOSE);
+#else
+ sp = sfpopen(NIL(Sfio_t*),str,"r");
+#endif
+ *mp = savemac;
+ np = nv_scoped(IFSNOD);
+ nv_putval(np,mp->ifsp,0);
+ mp->ifsp = nv_getval(np);
+ stakset(savptr,savtop);
+ newlines = 0;
+ lastc = 0;
+ sfsetbuf(sp,(void*)sp,0);
+ bufsize = sfvalue(sp);
+ /* read command substitution output and put on stack or here-doc */
+ sfpool(sp, NIL(Sfio_t*), SF_WRITE);
+ while((str=(char*)sfreserve(sp,SF_UNBOUND,0)) && (c = sfvalue(sp))>0)
+ {
+#if SHOPT_CRNL
+ /* eliminate <cr> */
+ register char *dp;
+ char *buff = str;
+ while(c>1 && (*str !='\r'|| str[1]!='\n'))
+ {
+ c--;
+ str++;
+ }
+ dp = str;
+ while(c>1)
+ {
+ str++;
+ c--;
+ while(c>1 && (*str!='\r' || str[1]!='\n'))
+ {
+ c--;
+ *dp++ = *str++;
+ }
+ }
+ if(c)
+ *dp++ = *str++;
+ *dp = 0;
+ str = buff;
+ c = dp-str;
+#endif /* SHOPT_CRNL */
+ if(newlines >0)
+ {
+ if(mp->sp)
+ sfnputc(mp->sp,'\n',newlines);
+ else if(!mp->quote && mp->split && sh.ifstable['\n'])
+ endfield(mp,0);
+ else while(newlines--)
+ stakputc('\n');
+ newlines = 0;
+ }
+ else if(lastc)
+ {
+ mac_copy(mp,&lastc,1);
+ lastc = 0;
+ }
+ /* delay appending trailing new-lines */
+ while(str[--c]=='\n')
+ newlines++;
+ if(++c < bufsize)
+ str[c] = 0;
+ else
+ {
+ /* can't write past buffer so save last character */
+ lastc = str[--c];
+ str[c] = 0;
+ }
+ mac_copy(mp,str,c);
+ }
+ if(--newlines>0 && sh.ifstable['\n']==S_DELIM)
+ {
+ if(mp->sp)
+ sfnputc(mp->sp,'\n',newlines);
+ else if(!mp->quote && mp->split && sh.ifstable['\n'])
+ endfield(mp,0);
+ else while(newlines--)
+ stakputc('\n');
+ }
+ if(lastc)
+ mac_copy(mp,&lastc,1);
+ sfclose(sp);
+ return;
+}
+
+/*
+ * copy <str> onto the stack
+ */
+static void mac_copy(register Mac_t *mp,register const char *str, register int size)
+{
+ register char *state;
+ register const char *cp=str;
+ register int c,n,nopat;
+ nopat = (mp->quote||mp->assign==1||mp->arith);
+ if(mp->zeros)
+ {
+ /* prevent leading 0's from becomming octal constants */
+ while(size>1 && *str=='0')
+ str++,size--;
+ mp->zeros = 0;
+ cp = str;
+ }
+ if(mp->sp)
+ sfwrite(mp->sp,str,size);
+ else if(mp->pattern>=2 || (mp->pattern && nopat))
+ {
+ state = sh_lexstates[ST_MACRO];
+ /* insert \ before file expansion characters */
+ while(size-->0)
+ {
+ c = state[n= *(unsigned char*)cp++];
+ if(nopat&&(c==S_PAT||c==S_ESC||c==S_BRACT||c==S_ENDCH) && mp->pattern!=3)
+ c=1;
+ else if(mp->pattern==4 && (c==S_ESC||c==S_BRACT||c==S_ENDCH || isastchar(n)))
+ c=1;
+ else if(mp->pattern==2 && c==S_SLASH)
+ c=1;
+ else if(mp->pattern==3 && c==S_ESC && (state[*(unsigned char*)cp]==S_DIG||(*cp==ESCAPE)))
+ {
+ if(!(c=mp->quote))
+ cp++;
+ }
+ else
+ c=0;
+ if(c)
+ {
+ if(c = (cp-1) - str)
+ stakwrite(str,c);
+ stakputc(ESCAPE);
+ str = cp-1;
+ }
+ }
+ if(c = cp-str)
+ stakwrite(str,c);
+ }
+ else if(!mp->quote && mp->split && (mp->ifs||mp->pattern))
+ {
+ /* split words at ifs characters */
+ state = sh.ifstable;
+ if(mp->pattern)
+ {
+ char *sp = "&|()";
+ while(c = *sp++)
+ {
+ if(state[c]==0)
+ state[c] = S_EPAT;
+ }
+ sp = "*?[{";
+ while(c = *sp++)
+ {
+ if(state[c]==0)
+ state[c] = S_PAT;
+ }
+ if(state[ESCAPE]==0)
+ state[ESCAPE] = S_ESC;
+ }
+ while(size-->0)
+ {
+ if((n=state[c= *(unsigned char*)cp++])==S_ESC || n==S_EPAT)
+ {
+ /* don't allow extended patterns in this case */
+ mp->patfound = mp->pattern;
+ stakputc(ESCAPE);
+ }
+ else if(n==S_PAT)
+ mp->patfound = mp->pattern;
+ else if(n && mp->ifs)
+ {
+#if SHOPT_MULTIBYTE
+ if(n==S_MBYTE)
+ {
+ if(sh_strchr(mp->ifsp,cp-1)<0)
+ continue;
+ n = mbsize(cp-1) - 1;
+ if(n==-2)
+ n = 0;
+ cp += n;
+ size -= n;
+ n= S_DELIM;
+ }
+#endif /* SHOPT_MULTIBYTE */
+ if(n==S_SPACE || n==S_NL)
+ {
+ while(size>0 && ((n=state[c= *(unsigned char*)cp++])==S_SPACE||n==S_NL))
+ size--;
+#if SHOPT_MULTIBYTE
+ if(n==S_MBYTE && sh_strchr(mp->ifsp,cp-1)>=0)
+ {
+ n = mbsize(cp-1) - 1;
+ if(n==-2)
+ n = 0;
+ cp += n;
+ size -= n;
+ n=S_DELIM;
+ }
+ else
+#endif /* SHOPT_MULTIBYTE */
+ if(n==S_DELIM)
+ size--;
+ }
+ endfield(mp,n==S_DELIM||mp->quoted);
+ mp->patfound = 0;
+ if(n==S_DELIM)
+ while(size>0 && ((n=state[c= *(unsigned char*)cp++])==S_SPACE||n==S_NL))
+ size--;
+ if(size<=0)
+ break;
+ cp--;
+ continue;
+
+ }
+ stakputc(c);
+ }
+ if(mp->pattern)
+ {
+ cp = "&|()";
+ while(c = *cp++)
+ {
+ if(state[c]==S_EPAT)
+ state[c] = 0;
+ }
+ cp = "*?[{";
+ while(c = *cp++)
+ {
+ if(state[c]==S_PAT)
+ state[c] = 0;
+ }
+ if(sh.ifstable[ESCAPE]==S_ESC)
+ sh.ifstable[ESCAPE] = 0;
+ }
+ }
+ else
+ stakwrite(str,size);
+}
+
+/*
+ * Terminate field.
+ * If field is null count field if <split> is non-zero
+ * Do filename expansion of required
+ */
+static void endfield(register Mac_t *mp,int split)
+{
+ register struct argnod *argp;
+ register int count=0;
+ if(staktell() > ARGVAL || split)
+ {
+ argp = (struct argnod*)stakfreeze(1);
+ argp->argnxt.cp = 0;
+ argp->argflag = 0;
+ if(mp->patfound)
+ {
+ sh.argaddr = 0;
+#if SHOPT_BRACEPAT
+ count = path_generate(argp,mp->arghead);
+#else
+ count = path_expand(argp->argval,mp->arghead);
+#endif /* SHOPT_BRACEPAT */
+ if(count)
+ mp->fields += count;
+ else if(split) /* pattern is null string */
+ *argp->argval = 0;
+ else /* pattern expands to nothing */
+ count = -1;
+ }
+ if(count==0)
+ {
+ argp->argchn.ap = *mp->arghead;
+ *mp->arghead = argp;
+ mp->fields++;
+ }
+ if(count>=0)
+ {
+ (*mp->arghead)->argflag |= ARG_MAKE;
+ if(mp->assign || sh_isoption(SH_NOGLOB))
+ argp->argflag |= ARG_RAW|ARG_EXP;
+ }
+ stakseek(ARGVAL);
+ }
+ mp->quoted = mp->quote;
+}
+
+/*
+ * Finds the right substring of STRING using the expression PAT
+ * the longest substring is found when FLAG is set.
+ */
+static int substring(register const char *string,const char *pat,int match[], int flag)
+{
+ register const char *sp=string;
+ register int size,len,nmatch,n;
+ int smatch[2*(MATCH_MAX+1)];
+ if(flag)
+ {
+ if(n=strgrpmatch(sp,pat,smatch,elementsof(smatch)/2,STR_RIGHT|STR_MAXIMAL))
+ {
+ memcpy(match,smatch,n*2*sizeof(smatch[0]));
+ return(n);
+ }
+ return(0);
+ }
+ size = len = strlen(sp);
+ sp += size;
+ while(sp>=string)
+ {
+#if SHOPT_MULTIBYTE
+ if(mbwide())
+ sp = lastchar(string,sp);
+#endif /* SHOPT_MULTIBYTE */
+ if(n=strgrpmatch(sp,pat,smatch,elementsof(smatch)/2,STR_RIGHT|STR_LEFT|STR_MAXIMAL))
+ {
+ nmatch = n;
+ memcpy(match,smatch,n*2*sizeof(smatch[0]));
+ size = sp-string;
+ break;
+ }
+ sp--;
+ }
+ if(size==len)
+ return(0);
+ if(nmatch)
+ {
+ nmatch *=2;
+ while(--nmatch>=0)
+ match[nmatch] += size;
+ }
+ return(n);
+}
+
+#if SHOPT_MULTIBYTE
+ static char *lastchar(const char *string, const char *endstring)
+ {
+ register char *str = (char*)string;
+ register int c;
+ mbinit();
+ while(*str)
+ {
+ if((c=mbsize(str))<0)
+ c = 1;
+ if(str+c > endstring)
+ break;
+ str += c;
+ }
+ return(str);
+ }
+#endif /* SHOPT_MULTIBYTE */
+static int charlen(const char *string,int len)
+{
+ if(!string)
+ return(0);
+#if SHOPT_MULTIBYTE
+ if(mbwide())
+ {
+ register const char *str = string, *strmax=string+len;
+ register int n=0;
+ mbinit();
+ if(len>0)
+ {
+ while(str<strmax && mbchar(str))
+ n++;
+ }
+ else while(mbchar(str))
+ n++;
+ return(n);
+ }
+ else
+#endif /* SHOPT_MULTIBYTE */
+ {
+ if(len<0)
+ return(strlen(string));
+ return(len);
+ }
+}
+
+/*
+ * This is the default tilde discipline function
+ */
+static int sh_btilde(int argc, char *argv[], void *context)
+{
+ char *cp = sh_tilde(argv[1]);
+ NOT_USED(argc);
+ NOT_USED(context);
+ if(!cp)
+ cp = argv[1];
+ sfputr(sfstdout, cp, '\n');
+ return(0);
+}
+
+/*
+ * <offset> is byte offset for beginning of tilde string
+ */
+static void tilde_expand2(register int offset)
+{
+ char shtilde[10], *av[3], *ptr=stakfreeze(1);
+ Sfio_t *iop, *save=sfstdout;
+ Namval_t *np;
+ static int beenhere=0;
+ strcpy(shtilde,".sh.tilde");
+ np = nv_open(shtilde,sh.fun_tree, NV_VARNAME|NV_NOARRAY|NV_NOASSIGN|NV_NOFAIL);
+ if(np && !beenhere)
+ {
+ beenhere = 1;
+ sh_addbuiltin(shtilde,sh_btilde,0);
+ }
+ av[0] = ".sh.tilde";
+ av[1] = &ptr[offset];
+ av[2] = 0;
+ iop = sftmp(IOBSIZE+1);;
+ sfset(iop,SF_READ,0);
+ sfstdout = iop;
+ if(np)
+ sh_fun(np, (Namval_t*)0, av);
+ else
+ sh_btilde(2, av, &sh);
+ sfstdout = save;
+ stakset(ptr, offset);
+ sfseek(iop,(Sfoff_t)0,SEEK_SET);
+ sfset(iop,SF_READ,1);
+ if(ptr = sfreserve(iop, SF_UNBOUND, -1))
+ {
+ Sfoff_t n = sfvalue(iop);
+ while(ptr[n-1]=='\n')
+ n--;
+ if(n==1 && fcpeek(0)=='/' && ptr[n-1])
+ n--;
+ if(n)
+ stakwrite(ptr,n);
+ }
+ else
+ stakputs(av[1]);
+ sfclose(iop);
+}
+
+/*
+ * This routine is used to resolve ~ expansion.
+ * A ~ by itself is replaced with the users login directory.
+ * A ~- is replaced by the previous working directory in shell.
+ * A ~+ is replaced by the present working directory in shell.
+ * If ~name is replaced with login directory of name.
+ * If string doesn't start with ~ or ~... not found then 0 returned.
+ */
+
+static char *sh_tilde(register const char *string)
+{
+ register char *cp;
+ register int c;
+ register struct passwd *pw;
+ register Namval_t *np=0;
+ static Dt_t *logins_tree;
+ if(*string++!='~')
+ return(NIL(char*));
+ if((c = *string)==0)
+ {
+ if(!(cp=nv_getval(nv_scoped(HOME))))
+ cp = getlogin();
+ return(cp);
+ }
+ if((c=='-' || c=='+') && string[1]==0)
+ {
+ if(c=='+')
+ cp = nv_getval(nv_scoped(PWDNOD));
+ else
+ cp = nv_getval(nv_scoped(OLDPWDNOD));
+ return(cp);
+ }
+ if(logins_tree && (np=nv_search(string,logins_tree,0)))
+ return(nv_getval(np));
+ if(!(pw = getpwnam(string)))
+ return(NIL(char*));
+ if(!logins_tree)
+ logins_tree = dtopen(&_Nvdisc,Dtbag);
+ if(np=nv_search(string,logins_tree,NV_ADD))
+ nv_putval(np, pw->pw_dir,0);
+ return(pw->pw_dir);
+}
+
+/*
+ * return values for special macros
+ */
+static char *special(register int c)
+{
+ register Namval_t *np;
+ if(c!='$')
+ sh.argaddr = 0;
+ switch(c)
+ {
+ case '@':
+ case '*':
+ return(sh.st.dolc>0?sh.st.dolv[1]:NIL(char*));
+ case '#':
+#if SHOPT_FILESCAN
+ if(sh.cur_line)
+ {
+ getdolarg(&sh,MAX_ARGN,(int*)0);
+ return(ltos(sh.offsets[0]));
+ }
+#endif /* SHOPT_FILESCAN */
+ return(ltos(sh.st.dolc));
+ case '!':
+ if(sh.bckpid)
+ return(ltos(sh.bckpid));
+ break;
+ case '$':
+ if(nv_isnull(SH_DOLLARNOD))
+ return(ltos(sh.pid));
+ return(nv_getval(SH_DOLLARNOD));
+ case '-':
+ return(sh_argdolminus());
+ case '?':
+ return(ltos(sh.savexit));
+ case 0:
+ if(sh_isstate(SH_PROFILE) || !error_info.id || ((np=nv_search(error_info.id,sh.bltin_tree,0)) && nv_isattr(np,BLT_SPC)))
+ return(sh.shname);
+ else
+ return(error_info.id);
+ }
+ return(NIL(char*));
+}
+
+/*
+ * Handle macro expansion errors
+ */
+static void mac_error(Namval_t *np)
+{
+ if(np)
+ nv_close(np);
+ errormsg(SH_DICT,ERROR_exit(1),e_subst,fcfirst());
+}
+
+/*
+ * Given pattern/string, replace / with 0 and return pointer to string
+ * \ characters are stripped from string.
+ */
+static char *mac_getstring(char *pattern)
+{
+ register char *cp = pattern;
+ register int c;
+ while(c = *cp++)
+ {
+ if(c==ESCAPE)
+ cp++;
+ else if(c=='/')
+ {
+ cp[-1] = 0;
+ return(cp);
+ }
+ }
+ return(NIL(char*));
+}
diff --git a/usr/src/lib/libshell/common/sh/main.c b/usr/src/lib/libshell/common/sh/main.c
new file mode 100644
index 0000000000..0b2f4ac875
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/main.c
@@ -0,0 +1,769 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * UNIX shell
+ *
+ * S. R. Bourne
+ * Rewritten By David Korn
+ * AT&T Labs
+ *
+ */
+
+#include <ast.h>
+#include <sfio.h>
+#include <stak.h>
+#include <ls.h>
+#include <fcin.h>
+#include "defs.h"
+#include "variables.h"
+#include "path.h"
+#include "io.h"
+#include "jobs.h"
+#include "shnodes.h"
+#include "history.h"
+#include "timeout.h"
+#include "FEATURE/time"
+#include "FEATURE/pstat"
+#include "FEATURE/execargs"
+#include "FEATURE/externs"
+#ifdef _hdr_nc
+# include <nc.h>
+#endif /* _hdr_nc */
+
+#define CMD_LENGTH 64
+
+/* These routines are referenced by this module */
+static void exfile(Shell_t*, Sfio_t*,int);
+static void chkmail(Shell_t *shp, char*);
+#if defined(_lib_fork) && !defined(_NEXT_SOURCE)
+ static void fixargs(char**,int);
+#else
+# define fixargs(a,b)
+#endif
+
+#ifndef environ
+ extern char **environ;
+#endif
+
+static struct stat lastmail;
+static time_t mailtime;
+static char beenhere = 0;
+
+#ifdef _lib_sigvec
+ void clearsigmask(register int sig)
+ {
+ struct sigvec vec;
+ if(sigvec(sig,NIL(struct sigvec*),&vec)>=0 && vec.sv_mask)
+ {
+ vec.sv_mask = 0;
+ sigvec(sig,&vec,NIL(struct sigvec*));
+ }
+ }
+#endif /* _lib_sigvec */
+
+#ifdef _lib_fts_notify
+# include <fts.h>
+ /* check for interrupts during tree walks */
+ static int fts_sigcheck(FTS* fp, FTSENT* ep, void* context)
+ {
+ Shell_t *shp = (Shell_t*)context;
+ NOT_USED(fp);
+ NOT_USED(ep);
+ if(shp->trapnote&SH_SIGSET)
+ {
+ errno = EINTR;
+ return(-1);
+ }
+ return(0);
+ }
+#endif /* _lib_fts_notify */
+
+#ifdef PATH_BFPATH
+#define PATHCOMP NIL(Pathcomp_t*)
+#else
+#define PATHCOMP ""
+#endif
+
+/*
+ * search for file and exfile() it if it exists
+ * 1 returned if file found, 0 otherwise
+ */
+
+int sh_source(Shell_t *shp, Sfio_t *iop, const char *file)
+{
+ char* oid;
+ char* nid;
+ int fd;
+
+ if (!file || !*file || (fd = path_open(file, PATHCOMP)) < 0)
+ return 0;
+ oid = error_info.id;
+ nid = error_info.id = strdup(file);
+ shp->st.filename = path_fullname(stakptr(PATH_OFFSET));
+ exfile(shp, iop, fd);
+ error_info.id = oid;
+ free(nid);
+ return 1;
+}
+
+#ifdef S_ISSOCK
+#define REMOTE(m) (S_ISSOCK(m)||!(m))
+#else
+#define REMOTE(m) !(m)
+#endif
+
+int sh_main(int ac, char *av[], void (*userinit)(int))
+{
+ register char *name;
+ register int fdin;
+ register Sfio_t *iop;
+ register Shell_t *shp;
+ struct stat statb;
+ int i, rshflag; /* set for restricted shell */
+ char *command;
+#ifdef _lib_sigvec
+ /* This is to clear mask that my be left on by rlogin */
+ clearsigmask(SIGALRM);
+ clearsigmask(SIGHUP);
+ clearsigmask(SIGCHLD);
+#endif /* _lib_sigvec */
+#ifdef _hdr_nc
+ _NutConf(_NC_SET_SUFFIXED_SEARCHING, 1);
+#endif /* _hdr_nc */
+ fixargs(av,0);
+ shp = sh_init(ac,av,userinit);
+ time(&mailtime);
+ if(rshflag=sh_isoption(SH_RESTRICTED))
+ sh_offoption(SH_RESTRICTED);
+#ifdef _lib_fts_notify
+ fts_notify(fts_sigcheck,(void*)shp);
+#endif /* _lib_fts_notify */
+ if(sigsetjmp(*((sigjmp_buf*)shp->jmpbuffer),0))
+ {
+ /* begin script execution here */
+ sh_reinit((char**)0);
+ if(rshflag)
+ sh_onoption(SH_RESTRICTED);
+ }
+ shp->fn_depth = shp->dot_depth = 0;
+ command = error_info.id;
+ /* set pidname '$$' */
+ shp->pid = getpid();
+ srand(shp->pid&0x7fff);
+ shp->ppid = getppid();
+ if(nv_isnull(PS4NOD))
+ nv_putval(PS4NOD,e_traceprompt,NV_RDONLY);
+ path_pwd(1);
+ iop = (Sfio_t*)0;
+#if SHOPT_BRACEPAT
+ sh_onoption(SH_BRACEEXPAND);
+#endif
+ if((beenhere++)==0)
+ {
+ sh_onstate(SH_PROFILE);
+ if(shp->ppid==1)
+ shp->login_sh++;
+ if(shp->login_sh >= 2)
+ sh_onoption(SH_LOGIN_SHELL);
+ /* decide whether shell is interactive */
+ if(!sh_isoption(SH_TFLAG) && !sh_isoption(SH_CFLAG) && sh_isoption(SH_SFLAG) &&
+ tty_check(0) && tty_check(ERRIO))
+ {
+ sh_onoption(SH_INTERACTIVE);
+ sh_onoption(SH_BGNICE);
+ sh_onoption(SH_RC);
+ }
+ if(!sh_isoption(SH_RC) && (sh_isoption(SH_BASH) && !sh_isoption(SH_POSIX)
+#if SHOPT_REMOTE
+ || !fstat(0, &statb) && REMOTE(statb.st_mode)
+#endif
+ ))
+ sh_onoption(SH_RC);
+ for(i=0; i<elementsof(sh.offoptions.v); i++)
+ sh.options.v[i] &= ~sh.offoptions.v[i];
+ if(sh_isoption(SH_INTERACTIVE))
+ {
+#ifdef SIGXCPU
+ signal(SIGXCPU,SIG_DFL);
+#endif /* SIGXCPU */
+#ifdef SIGXFSZ
+ signal(SIGXFSZ,SIG_DFL);
+#endif /* SIGXFSZ */
+ sh_onoption(SH_MONITOR);
+ }
+ job_init(sh_isoption(SH_LOGIN_SHELL));
+ if(sh_isoption(SH_LOGIN_SHELL) && !sh_isoption(SH_NOPROFILE))
+ {
+ /* system profile */
+ sh_source(shp, iop, e_sysprofile);
+ if(!sh_isoption(SH_NOUSRPROFILE) && !sh_isoption(SH_PRIVILEGED))
+ {
+ char **files = shp->login_files;
+ while ((name = *files++) && !sh_source(shp, iop, sh_mactry(name)));
+ }
+ }
+ /* make sure PWD is set up correctly */
+ path_pwd(1);
+ if(!sh_isoption(SH_NOEXEC))
+ {
+ if(!sh_isoption(SH_NOUSRPROFILE) && !sh_isoption(SH_PRIVILEGED) && sh_isoption(SH_RC))
+ {
+#if SHOPT_BASH
+ if(sh_isoption(SH_BASH) && !sh_isoption(SH_POSIX))
+ {
+#if SHOPT_SYSRC
+ sh_source(shp, iop, e_bash_sysrc);
+#endif
+ sh_source(shp, iop, shp->rcfile ? shp->rcfile : sh_mactry((char*)e_bash_rc));
+ }
+ else
+#endif
+ {
+#if SHOPT_SYSRC
+ sh_source(shp, iop, e_sysrc);
+#endif
+ sh_source(shp, iop, sh_mactry(nv_getval(ENVNOD)));
+ }
+ }
+ else if(sh_isoption(SH_INTERACTIVE) && sh_isoption(SH_PRIVILEGED))
+ sh_source(shp, iop, e_suidprofile);
+ }
+ shp->st.cmdname = error_info.id = command;
+ sh_offstate(SH_PROFILE);
+ if(rshflag)
+ sh_onoption(SH_RESTRICTED);
+ /* open input file if specified */
+ if(shp->comdiv)
+ {
+ shell_c:
+ iop = sfnew(NIL(Sfio_t*),shp->comdiv,strlen(shp->comdiv),0,SF_STRING|SF_READ);
+ }
+ else
+ {
+ name = error_info.id;
+ error_info.id = shp->shname;
+ if(sh_isoption(SH_SFLAG))
+ fdin = 0;
+ else
+ {
+ char *sp;
+ /* open stream should have been passed into shell */
+ if(strmatch(name,e_devfdNN))
+ {
+ char *cp;
+ int type;
+ fdin = (int)strtol(name+8, (char**)0, 10);
+ if(fstat(fdin,&statb)<0)
+ errormsg(SH_DICT,ERROR_system(1),e_open,error_info.id);
+#if !_WINIX
+ /*
+ * try to undo effect of solaris 2.5+
+ * change for argv for setuid scripts
+ */
+ if(((type = sh_type(cp = av[0])) & SH_TYPE_SH) && (!(name = nv_getval(L_ARGNOD)) || !((type = sh_type(cp = name)) & SH_TYPE_SH)))
+ {
+ av[0] = (type & SH_TYPE_LOGIN) ? cp : path_basename(cp);
+ /* exec to change $0 for ps */
+ execv(pathshell(),av);
+ /* exec fails */
+ shp->st.dolv[0] = av[0];
+ fixargs(shp->st.dolv,1);
+ }
+#endif
+ name = av[0];
+ sh_offoption(SH_VERBOSE);
+ sh_offoption(SH_XTRACE);
+ }
+ else
+ {
+ int isdir = 0;
+ if((fdin=sh_open(name,O_RDONLY,0))>=0 &&(fstat(fdin,&statb)<0 || S_ISDIR(statb.st_mode)))
+ {
+ close(fdin);
+ isdir = 1;
+ fdin = -1;
+ }
+ else
+ shp->st.filename = path_fullname(name);
+ sp = 0;
+ if(fdin < 0 && !strchr(name,'/'))
+ {
+#ifdef PATH_BFPATH
+ if(path_absolute(name,NIL(Pathcomp_t*)))
+ sp = stakptr(PATH_OFFSET);
+#else
+ sp = path_absolute(name,NIL(char*));
+#endif
+ if(sp)
+ {
+ if((fdin=sh_open(sp,O_RDONLY,0))>=0)
+ shp->st.filename = path_fullname(sp);
+ }
+ }
+ if(fdin<0)
+ {
+ if(isdir)
+ errno = EISDIR;
+ error_info.id = av[0];
+ if(sp || errno!=ENOENT)
+ errormsg(SH_DICT,ERROR_system(ERROR_NOEXEC),e_open,name);
+ /* try sh -c 'name "$@"' */
+ sh_onoption(SH_CFLAG);
+ shp->comdiv = (char*)malloc(strlen(name)+7);
+ name = strcopy(shp->comdiv,name);
+ if(shp->st.dolc)
+ strcopy(name," \"$@\"");
+ goto shell_c;
+ }
+ if(fdin==0)
+ fdin = sh_iomovefd(fdin);
+ }
+ shp->readscript = shp->shname;
+ }
+ error_info.id = name;
+ shp->comdiv--;
+#if SHOPT_ACCT
+ sh_accinit();
+ if(fdin != 0)
+ sh_accbegin(error_info.id);
+#endif /* SHOPT_ACCT */
+ }
+ }
+ else
+ {
+ fdin = shp->infd;
+ fixargs(shp->st.dolv,1);
+ }
+ if(sh_isoption(SH_INTERACTIVE))
+ sh_onstate(SH_INTERACTIVE);
+ nv_putval(IFSNOD,(char*)e_sptbnl,NV_RDONLY);
+ exfile(shp,iop,fdin);
+ sh_done(0);
+ /* NOTREACHED */
+ return(0);
+}
+
+/*
+ * iop is not null when the input is a string
+ * fdin is the input file descriptor
+ */
+
+static void exfile(register Shell_t *shp, register Sfio_t *iop,register int fno)
+{
+ time_t curtime;
+ Shnode_t *t;
+ int maxtry=IOMAXTRY, tdone=0, execflags;
+ int states,jmpval;
+ struct checkpt buff;
+ sh_pushcontext(&buff,SH_JMPERREXIT);
+ /* open input stream */
+ nv_putval(SH_PATHNAMENOD, shp->st.filename ,NV_NOFREE);
+ if(!iop)
+ {
+ if(fno > 0)
+ {
+ int r;
+ if(fno < 10 && ((r=sh_fcntl(fno,F_DUPFD,10))>=10))
+ {
+ shp->fdstatus[r] = shp->fdstatus[fno];
+ sh_close(fno);
+ fno = r;
+ }
+ fcntl(fno,F_SETFD,FD_CLOEXEC);
+ shp->fdstatus[fno] |= IOCLEX;
+ iop = sh_iostream(fno);
+ }
+ else
+ iop = sfstdin;
+ }
+ else
+ fno = -1;
+ shp->infd = fno;
+ if(sh_isstate(SH_INTERACTIVE))
+ {
+ if(nv_isnull(PS1NOD))
+ nv_putval(PS1NOD,(shp->euserid?e_stdprompt:e_supprompt),NV_RDONLY);
+ sh_sigdone();
+ if(sh_histinit())
+ sh_onoption(SH_HISTORY);
+ }
+ else
+ {
+ if(!sh_isstate(SH_PROFILE))
+ {
+ buff.mode = SH_JMPEXIT;
+ sh_onoption(SH_TRACKALL);
+ sh_offoption(SH_MONITOR);
+ }
+ sh_offstate(SH_INTERACTIVE);
+ sh_offstate(SH_MONITOR);
+ sh_offstate(SH_HISTORY);
+ sh_offoption(SH_HISTORY);
+ }
+ states = sh_getstate();
+ jmpval = sigsetjmp(buff.buff,0);
+ if(jmpval)
+ {
+ Sfio_t *top;
+ sh_iorestore(0,jmpval);
+ hist_flush(shp->hist_ptr);
+ sfsync(shp->outpool);
+ shp->st.execbrk = shp->st.breakcnt = 0;
+ /* check for return from profile or env file */
+ if(sh_isstate(SH_PROFILE) && (jmpval==SH_JMPFUN || jmpval==SH_JMPEXIT))
+ goto done;
+ if(!sh_isoption(SH_INTERACTIVE) || sh_isstate(SH_FORKED) || (jmpval > SH_JMPERREXIT && job_close() >=0))
+ {
+ sh_offstate(SH_INTERACTIVE);
+ sh_offstate(SH_MONITOR);
+ goto done;
+ }
+ /* skip over remaining input */
+ if(top = fcfile())
+ {
+ while(fcget()>0);
+ fcclose();
+ while(top=sfstack(iop,SF_POPSTACK))
+ sfclose(top);
+ }
+ /* make sure that we own the terminal */
+#ifdef SIGTSTP
+ tcsetpgrp(job.fd,shp->pid);
+#endif /* SIGTSTP */
+ }
+ /* error return here */
+ sfclrerr(iop);
+ sh_setstate(states);
+ shp->st.optindex = 1;
+ opt_info.offset = 0;
+ shp->st.loopcnt = 0;
+ shp->trapnote = 0;
+ shp->intrap = 0;
+ error_info.line = 1;
+ shp->inlineno = 1;
+ shp->binscript = 0;
+ if(sfeof(iop))
+ goto eof_or_error;
+ /* command loop */
+ while(1)
+ {
+ shp->nextprompt = 1;
+ sh_freeup();
+ stakset(NIL(char*),0);
+ exitset();
+ sh_offstate(SH_STOPOK);
+ sh_offstate(SH_ERREXIT);
+ sh_offstate(SH_VERBOSE);
+ sh_offstate(SH_TIMING);
+ sh_offstate(SH_GRACE);
+ sh_offstate(SH_TTYWAIT);
+ if(sh_isoption(SH_VERBOSE))
+ sh_onstate(SH_VERBOSE);
+ sh_onstate(SH_ERREXIT);
+ /* -eim flags don't apply to profiles */
+ if(sh_isstate(SH_PROFILE))
+ {
+ sh_offstate(SH_INTERACTIVE);
+ sh_offstate(SH_ERREXIT);
+ sh_offstate(SH_MONITOR);
+ }
+ if(sh_isstate(SH_INTERACTIVE) && !tdone)
+ {
+ register char *mail;
+#ifdef JOBS
+ sh_offstate(SH_MONITOR);
+ if(sh_isoption(SH_MONITOR))
+ sh_onstate(SH_MONITOR);
+ if(job.pwlist)
+ {
+ job_walk(sfstderr,job_list,JOB_NFLAG,(char**)0);
+ job_wait((pid_t)0);
+ }
+#endif /* JOBS */
+ if((mail=nv_getval(MAILPNOD)) || (mail=nv_getval(MAILNOD)))
+ {
+ time(&curtime);
+ if ((curtime - mailtime) >= sh_mailchk)
+ {
+ chkmail(shp,mail);
+ mailtime = curtime;
+ }
+ }
+ if(shp->hist_ptr)
+ hist_eof(shp->hist_ptr);
+ /* sets timeout for command entry */
+ shp->timeout = shp->st.tmout;
+#if SHOPT_TIMEOUT
+ if(shp->timeout <= 0 || shp->timeout > SHOPT_TIMEOUT)
+ shp->timeout = SHOPT_TIMEOUT;
+#endif /* SHOPT_TIMEOUT */
+ shp->inlineno = 1;
+ error_info.line = 1;
+ shp->exitval = 0;
+ shp->trapnote = 0;
+ if(buff.mode == SH_JMPEXIT)
+ {
+ buff.mode = SH_JMPERREXIT;
+#ifdef DEBUG
+ errormsg(SH_DICT,ERROR_warn(0),"%d: mode changed to JMP_EXIT",getpid());
+#endif
+ }
+ }
+ errno = 0;
+ if(tdone || !sfreserve(iop,0,0))
+ {
+ eof_or_error:
+ if(sh_isstate(SH_INTERACTIVE) && !sferror(iop))
+ {
+ if(--maxtry>0 && sh_isoption(SH_IGNOREEOF) &&
+ !sferror(sfstderr) && (shp->fdstatus[fno]&IOTTY))
+ {
+ sfclrerr(iop);
+ errormsg(SH_DICT,0,e_logout);
+ continue;
+ }
+ else if(job_close()<0)
+ continue;
+ }
+ if(errno==0 && sferror(iop) && --maxtry>0)
+ {
+ sfclrlock(iop);
+ sfclrerr(iop);
+ continue;
+ }
+ goto done;
+ }
+ maxtry = IOMAXTRY;
+ if(sh_isstate(SH_INTERACTIVE) && shp->hist_ptr)
+ {
+ job_wait((pid_t)0);
+ hist_eof(shp->hist_ptr);
+ sfsync(sfstderr);
+ }
+ if(sh_isoption(SH_HISTORY))
+ sh_onstate(SH_HISTORY);
+ job.waitall = job.curpgid = 0;
+ error_info.flags |= ERROR_INTERACTIVE;
+ t = (Shnode_t*)sh_parse(shp,iop,0);
+ if(!sh_isstate(SH_INTERACTIVE) && !sh_isstate(SH_CFLAG))
+ error_info.flags &= ~ERROR_INTERACTIVE;
+ shp->readscript = 0;
+ if(sh_isstate(SH_INTERACTIVE) && shp->hist_ptr)
+ hist_flush(shp->hist_ptr);
+ sh_offstate(SH_HISTORY);
+ if(t)
+ {
+ execflags = sh_state(SH_ERREXIT)|sh_state(SH_INTERACTIVE);
+ /* The last command may not have to fork */
+ if(!sh_isstate(SH_PROFILE) && !sh_isstate(SH_INTERACTIVE) &&
+ (fno<0 || !(shp->fdstatus[fno]&(IOTTY|IONOSEEK)))
+ && !sfreserve(iop,0,0))
+ {
+ execflags |= sh_state(SH_NOFORK);
+ }
+ shp->st.execbrk = 0;
+ sh_exec(t,execflags);
+ if(shp->forked)
+ {
+ sh_offstate(SH_INTERACTIVE);
+ goto done;
+ }
+ /* This is for sh -t */
+ if(sh_isoption(SH_TFLAG) && !sh_isstate(SH_PROFILE))
+ tdone++;
+ }
+ }
+done:
+ sh_popcontext(&buff);
+ if(sh_isstate(SH_INTERACTIVE))
+ {
+ sfputc(sfstderr,'\n');
+ job_close();
+ }
+ if(jmpval == SH_JMPSCRIPT)
+ siglongjmp(*shp->jmplist,jmpval);
+ else if(jmpval == SH_JMPEXIT)
+ sh_done(0);
+ if(fno>0)
+ sh_close(fno);
+ if(shp->st.filename)
+ free((void*)shp->st.filename);
+ shp->st.filename = 0;
+}
+
+
+/* prints out messages if files in list have been modified since last call */
+static void chkmail(Shell_t *shp, char *files)
+{
+ register char *cp,*sp,*qp;
+ register char save;
+ struct argnod *arglist=0;
+ int offset = staktell();
+ char *savstak=stakptr(0);
+ struct stat statb;
+ if(*(cp=files) == 0)
+ return;
+ sp = cp;
+ do
+ {
+ /* skip to : or end of string saving first '?' */
+ for(qp=0;*sp && *sp != ':';sp++)
+ if((*sp == '?' || *sp=='%') && qp == 0)
+ qp = sp;
+ save = *sp;
+ *sp = 0;
+ /* change '?' to end-of-string */
+ if(qp)
+ *qp = 0;
+ do
+ {
+ /* see if time has been modified since last checked
+ * and the access time <= the modification time
+ */
+ if(stat(cp,&statb) >= 0 && statb.st_mtime >= mailtime
+ && statb.st_atime <= statb.st_mtime)
+ {
+ /* check for directory */
+ if(!arglist && S_ISDIR(statb.st_mode))
+ {
+ /* generate list of directory entries */
+ path_complete(cp,"/*",&arglist);
+ }
+ else
+ {
+ /*
+ * If the file has shrunk,
+ * or if the size is zero
+ * then don't print anything
+ */
+ if(statb.st_size &&
+ ( statb.st_ino != lastmail.st_ino
+ || statb.st_dev != lastmail.st_dev
+ || statb.st_size > lastmail.st_size))
+ {
+ /* save and restore $_ */
+ char *save = shp->lastarg;
+ shp->lastarg = cp;
+ errormsg(SH_DICT,0,sh_mactry(qp?qp+1:(char*)e_mailmsg));
+ shp->lastarg = save;
+ }
+ lastmail = statb;
+ break;
+ }
+ }
+ if(arglist)
+ {
+ cp = arglist->argval;
+ arglist = arglist->argchn.ap;
+ }
+ else
+ cp = 0;
+ }
+ while(cp);
+ if(qp)
+ *qp = '?';
+ *sp++ = save;
+ cp = sp;
+ }
+ while(save);
+ stakset(savstak,offset);
+}
+
+#undef EXECARGS
+#undef PSTAT
+#if defined(_hdr_execargs) && defined(pdp11)
+# include <execargs.h>
+# define EXECARGS 1
+#endif
+
+#if defined(_lib_pstat) && defined(_sys_pstat)
+# include <sys/pstat.h>
+# define PSTAT 1
+#endif
+
+#if defined(_lib_fork) && !defined(_NEXT_SOURCE)
+/*
+ * fix up command line for ps command
+ * mode is 0 for initialization
+ */
+static void fixargs(char **argv, int mode)
+{
+#if EXECARGS
+ *execargs=(char *)argv;
+#else
+ static char *buff;
+ static int command_len;
+ register char *cp;
+ int offset=0,size;
+# ifdef PSTAT
+ union pstun un;
+ if(mode==0)
+ {
+ struct pst_static st;
+ un.pst_static = &st;
+ if(pstat(PSTAT_STATIC, un, sizeof(struct pst_static), 1, 0)<0)
+ return;
+ command_len = st.command_length;
+ return;
+ }
+ stakseek(command_len+2);
+ buff = stakseek(0);
+# else
+ if(mode==0)
+ {
+ buff = argv[0];
+ while(cp = *argv++)
+ command_len += strlen(cp)+1;
+ if(environ && *environ==buff+command_len)
+ {
+ for(argv=environ; cp = *argv; cp++)
+ {
+ if(command_len > CMD_LENGTH)
+ {
+ command_len = CMD_LENGTH;
+ break;
+ }
+ *argv++ = strdup(cp);
+ command_len += strlen(cp)+1;
+ }
+ }
+ command_len -= 1;
+ return;
+ }
+# endif /* PSTAT */
+ if(command_len==0)
+ return;
+ while((cp = *argv++) && offset < command_len)
+ {
+ if(offset + (size=strlen(cp)) >= command_len)
+ size = command_len - offset;
+ memcpy(buff+offset,cp,size);
+ offset += size;
+ buff[offset++] = ' ';
+ }
+ buff[offset-1] = 0;
+# ifdef PSTAT
+ un.pst_command = stakptr(0);
+ pstat(PSTAT_SETCMD,un,0,0,0);
+# endif /* PSTAT */
+#endif /* EXECARGS */
+}
+#endif /* _lib_fork */
diff --git a/usr/src/lib/libshell/common/sh/name.c b/usr/src/lib/libshell/common/sh/name.c
new file mode 100644
index 0000000000..b9d5cbe9eb
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/name.c
@@ -0,0 +1,2382 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * AT&T Labs
+ *
+ */
+
+#define putenv ___putenv
+
+#include "defs.h"
+#include <ctype.h>
+#include "variables.h"
+#include "path.h"
+#include "lexstates.h"
+#include "timeout.h"
+#include "FEATURE/externs"
+#include "streval.h"
+
+static char *savesub = 0;
+
+#if !_lib_pathnative && _lib_uwin_path
+
+#define _lib_pathnative 1
+
+extern int uwin_path(const char*, char*, int);
+
+size_t
+pathnative(const char* path, char* buf, size_t siz)
+{
+ return uwin_path(path, buf, siz);
+}
+
+#endif /* _lib_pathnative */
+
+static void attstore(Namval_t*,void*);
+#ifndef _ENV_H
+static void pushnam(Namval_t*,void*);
+static char *staknam(Namval_t*, char*);
+#endif
+static void ltou(const char*,char*);
+static void rightjust(char*, int, int);
+
+struct adata
+{
+ char **argnam;
+ int attsize;
+ char *attval;
+};
+
+char nv_local = 0;
+#ifndef _ENV_H
+static void(*nullscan)(Namval_t*,void*);
+#endif
+
+#if ( SFIO_VERSION <= 20010201L )
+# define _data data
+#endif
+
+#if !SHOPT_MULTIBYTE
+# define mbchar(p) (*(unsigned char*)p++)
+#endif /* SHOPT_MULTIBYTE */
+
+/* ======== name value pair routines ======== */
+
+#include "shnodes.h"
+#include "builtins.h"
+
+static char *getbuf(size_t len)
+{
+ static char *buf;
+ static size_t buflen;
+ if(buflen < len)
+ {
+ if(buflen==0)
+ buf = (char*)malloc(len);
+ else
+ buf = (char*)realloc(buf,len);
+ buflen = len;
+ }
+ return(buf);
+}
+
+#ifdef _ENV_H
+void sh_envput(Env_t* ep,Namval_t *np)
+{
+ int offset = staktell();
+ Namarr_t *ap = nv_arrayptr(np);
+ char *val;
+ if(ap)
+ {
+ if(ap->nelem&ARRAY_UNDEF)
+ nv_putsub(np,"0",0L);
+ else if(!(val=nv_getsub(np)) || strcmp(val,"0"))
+ return;
+ }
+ if(!(val = nv_getval(np)))
+ return;
+ stakputs(nv_name(np));
+ stakputc('=');
+ stakputs(val);
+ stakseek(offset);
+ env_add(ep,stakptr(offset),ENV_STRDUP);
+}
+#endif
+
+/*
+ * output variable name in format for re-input
+ */
+void nv_outname(Sfio_t *out, char *name, int len)
+{
+ const char *cp=name, *sp;
+ int c, offset = staktell();
+ while(sp= strchr(cp,'['))
+ {
+ if(len>0 && cp+len <= sp)
+ break;
+ sfwrite(out,cp,++sp-cp);
+ stakseek(offset);
+ for(; c= *sp; sp++)
+ {
+ if(c==']')
+ break;
+ else if(c=='\\')
+ {
+ if(*sp=='[' || *sp==']' || *sp=='\\')
+ c = *sp++;
+ }
+ stakputc(c);
+ }
+ stakputc(0);
+ sfputr(out,sh_fmtq(stakptr(offset)),-1);
+ if(len>0)
+ {
+ sfputc(out,']');
+ return;
+ }
+ cp = sp;
+ }
+ if(*cp)
+ {
+ if(len>0)
+ sfwrite(out,cp,len);
+ else
+ sfputr(out,cp,-1);
+ }
+ stakseek(offset);
+}
+
+/*
+ * Perform parameter assignment for a linked list of parameters
+ * <flags> contains attributes for the parameters
+ */
+void nv_setlist(register struct argnod *arg,register int flags)
+{
+ register char *cp;
+ register Namval_t *np;
+ char *trap=sh.st.trap[SH_DEBUGTRAP];
+ int traceon = (sh_isoption(SH_XTRACE)!=0);
+ int array = (flags&(NV_ARRAY|NV_IARRAY));
+ flags &= ~(NV_TYPE|NV_ARRAY);
+ if(sh_isoption(SH_ALLEXPORT))
+ flags |= NV_EXPORT;
+ if(sh.prefix)
+ {
+ flags &= ~(NV_IDENT|NV_EXPORT);
+ flags |= NV_VARNAME;
+ }
+ for(;arg; arg=arg->argnxt.ap)
+ {
+ sh.used_pos = 0;
+ if(arg->argflag&ARG_MAC)
+ cp = sh_mactrim(arg->argval,-1);
+ else
+ {
+ Namval_t *mp;
+ stakseek(0);
+ if(*arg->argval==0 && arg->argchn.ap && !(arg->argflag&~(ARG_APPEND|ARG_QUOTED)))
+ {
+ int flag = (NV_VARNAME|NV_ARRAY|NV_ASSIGN);
+ struct fornod *fp=(struct fornod*)arg->argchn.ap;
+ register Shnode_t *tp=fp->fortre;
+ char *prefix = sh.prefix;
+ flag |= (flags&NV_NOSCOPE);
+ if(arg->argflag&ARG_QUOTED)
+ cp = sh_mactrim(fp->fornam,-1);
+ else
+ cp = fp->fornam;
+ error_info.line = fp->fortyp-sh.st.firstline;
+ if(sh.fn_depth && (Namval_t*)tp->com.comnamp==SYSTYPESET)
+ flag |= NV_NOSCOPE;
+ if(prefix && tp->com.comset && *cp=='[')
+ {
+ sh.prefix = 0;
+ np = nv_open(prefix,sh.var_tree,flag);
+ sh.prefix = prefix;
+ if(np)
+ {
+ if(!nv_isarray(np))
+ {
+ stakputc('.');
+ stakputs(cp);
+ cp = stakfreeze(1);
+ }
+ nv_close(np);
+ }
+ }
+ np = nv_open(cp,sh.var_tree,flag);
+ if(array)
+ {
+ if(!(flags&NV_APPEND))
+ nv_unset(np);
+ if(array&NV_ARRAY)
+ {
+ nv_setarray(np,nv_associative);
+ }
+ else
+ {
+ nv_onattr(np,NV_ARRAY);
+ }
+ }
+ /* check for array assignment */
+ if(tp->tre.tretyp!=TLST && tp->com.comarg && !tp->com.comset && !((mp=tp->com.comnamp) && nv_isattr(mp,BLT_DCL)))
+ {
+ int argc;
+ char **argv = sh_argbuild(&argc,&tp->com,0);
+ if(!(arg->argflag&ARG_APPEND))
+ {
+ nv_unset(np);
+ }
+ nv_setvec(np,(arg->argflag&ARG_APPEND),argc,argv);
+ if(traceon || trap)
+ {
+ int n = -1;
+ char *name = nv_name(np);
+ if(arg->argflag&ARG_APPEND)
+ n = '+';
+ if(trap)
+ sh_debug(trap,name,(char*)0,argv,(arg->argflag&ARG_APPEND)|ARG_ASSIGN);
+ if(traceon)
+ {
+ sh_trace(NIL(char**),0);
+ sfputr(sfstderr,name,n);
+ sfwrite(sfstderr,"=( ",3);
+ while(cp= *argv++)
+ sfputr(sfstderr,sh_fmtq(cp),' ');
+ sfwrite(sfstderr,")\n",2);
+ }
+ }
+ continue;
+ }
+ if(tp->tre.tretyp==TLST || !tp->com.comset || tp->com.comset->argval[0]!='[')
+ {
+ if(*cp!='.' && *cp!='[' && strchr(cp,'['))
+ {
+ nv_close(np);
+ np = nv_open(cp,sh.var_tree,flag);
+ }
+ if((arg->argflag&ARG_APPEND) && !nv_isarray(np))
+ nv_unset(np);
+ }
+ else
+ {
+ if(sh_isoption(SH_BASH) || (array&NV_IARRAY))
+ {
+ if(!(arg->argflag&ARG_APPEND))
+ nv_unset(np);
+ }
+ else if((arg->argflag&ARG_APPEND) && (!nv_isarray(np) || (nv_aindex(np)>=0)))
+ {
+ nv_unset(np);
+ nv_setarray(np,nv_associative);
+ }
+ else
+ nv_setarray(np,nv_associative);
+ }
+ if(prefix)
+ cp = stakcopy(nv_name(np));
+ sh.prefix = cp;
+ sh_exec(tp,sh_isstate(SH_ERREXIT));
+ sh.prefix = prefix;
+ if(nv_isarray(np) && (mp=nv_opensub(np)))
+ np = mp;
+ nv_setvtree(np);
+ continue;
+ }
+ cp = arg->argval;
+ }
+ if(sh.prefix && *cp=='.' && cp[1]=='=')
+ cp++;
+ np = nv_open(cp,sh.var_tree,flags);
+ if(!np->nvfun)
+ {
+ if(sh.used_pos)
+ nv_onattr(np,NV_PARAM);
+ else
+ nv_offattr(np,NV_PARAM);
+ }
+ if(traceon || trap)
+ {
+ register char *sp=cp;
+ char *name=nv_name(np);
+ char *sub=0;
+ int append = 0;
+ if(nv_isarray(np))
+ sub = savesub;
+ if(cp=strchr(sp,'='))
+ {
+ if(cp[-1]=='+')
+ append = ARG_APPEND;
+ cp++;
+ }
+ if(traceon)
+ {
+ sh_trace(NIL(char**),0);
+ nv_outname(sfstderr,name,-1);
+ if(sub)
+ sfprintf(sfstderr,"[%s]",sh_fmtq(sub));
+ if(cp)
+ {
+ if(append)
+ sfputc(sfstderr,'+');
+ sfprintf(sfstderr,"=%s\n",sh_fmtq(cp));
+ }
+ }
+ if(trap)
+ {
+ char *av[2];
+ av[0] = cp;
+ av[1] = 0;
+ sh_debug(trap,name,sub,av,append);
+ }
+ }
+ }
+}
+
+/*
+ * copy the subscript onto the stack
+ */
+static void stak_subscript(const char *sub, int last)
+{
+ register int c;
+ stakputc('[');
+ while(c= *sub++)
+ {
+ if(c=='[' || c==']' || c=='\\')
+ stakputc('\\');
+ stakputc(c);
+ }
+ stakputc(last);
+}
+
+/*
+ * construct a new name from a prefix and base name on the stack
+ */
+static char *copystack(const char *prefix, register const char *name, const char *sub)
+{
+ register int last=0,offset = staktell();
+ if(prefix)
+ {
+ stakputs(prefix);
+ if(*stakptr(staktell()-1)=='.')
+ stakseek(staktell()-1);
+ if(*name=='.' && name[1]=='[')
+ last = staktell()+2;
+ if(*name!='[' && *name!='.' && *name!='=' && *name!='+')
+ stakputc('.');
+ }
+ if(last)
+ {
+ stakputs(name);
+ if(sh_checkid(stakptr(last),(char*)0))
+ stakseek(staktell()-2);
+ }
+ if(sub)
+ stak_subscript(sub,']');
+ if(!last)
+ stakputs(name);
+ stakputc(0);
+ return(stakptr(offset));
+}
+
+/*
+ * grow this stack string <name> by <n> bytes and move from cp-1 to end
+ * right by <n>. Returns beginning of string on the stack
+ */
+static char *stack_extend(const char *cname, char *cp, int n)
+{
+ register char *name = (char*)cname;
+ int offset = name - stakptr(0);
+ int m = cp-name;
+ stakseek(strlen(name)+n+1);
+ name = stakptr(offset);
+ cp = name + m;
+ m = strlen(cp)+1;
+ while(m-->0)
+ cp[n+m]=cp[m];
+ return((char*)name);
+}
+
+Namval_t *nv_create(const char *name, Dt_t *root, int flags, Namfun_t *dp)
+{
+ char *cp=(char*)name, *sp, *xp;
+ register int c;
+ register Namval_t *np=0, *nq=0;
+ Namfun_t *fp=0;
+ long mode, add=0;
+ int copy=1,isref,top=0,noscope=(flags&NV_NOSCOPE);
+ if(root==sh.var_tree)
+ {
+ if(dtvnext(root))
+ top = 1;
+ else
+ flags &= ~NV_NOSCOPE;
+ }
+ if(!dp->disc)
+ copy = dp->nofree;
+ if(*cp=='.')
+ cp++;
+ while(1)
+ {
+ switch(c = *(unsigned char*)(sp = cp))
+ {
+ case '[':
+ if(flags&NV_NOARRAY)
+ {
+ dp->last = cp;
+ return(np);
+ }
+ cp = nv_endsubscript((Namval_t*)0,sp,0);
+ if(sp==name || sp[-1]=='.')
+ c = *(sp = cp);
+ goto skip;
+ case '.':
+ if(flags&NV_IDENT)
+ return(0);
+ if(root==sh.var_tree)
+ flags &= ~NV_EXPORT;
+ if(!copy && !(flags&NV_NOREF))
+ {
+ c = sp-name;
+ copy = cp-name;
+ dp->nofree = 1;
+ name = copystack((const char*)0, name,(const char*)0);
+ cp = (char*)name+copy;
+ sp = (char*)name+c;
+ c = '.';
+ }
+ skip:
+ case '+':
+ case '=':
+ *sp = 0;
+ case 0:
+ isref = 0;
+ dp->last = cp;
+ mode = (c=='.' || (flags&NV_NOADD))?add:NV_ADD;
+ if(flags&NV_NOSCOPE)
+ mode |= HASH_NOSCOPE;
+ if(top)
+ nq = nv_search(name,sh.var_base,0);
+ if(np = nv_search(name,root,mode))
+ {
+ isref = nv_isref(np);
+ if(top)
+ {
+ if(nq==np)
+ flags &= ~NV_NOSCOPE;
+ else if(nq)
+ {
+ if(nv_isnull(np) && c!='.' && (np->nvfun=nv_cover(nq)))
+ np->nvname = nq->nvname;
+ flags |= NV_NOSCOPE;
+ }
+ }
+ else if(add && nv_isnull(np) && c=='.')
+ nv_setvtree(np);
+ }
+ if(c)
+ *sp = c;
+ top = 0;
+ if(isref)
+ {
+ char *sub=0;
+ if(c=='.') /* don't optimize */
+ sh.argaddr = 0;
+ else if(flags&NV_NOREF)
+ {
+ if(c)
+ nv_unref(np);
+ return(np);
+ }
+ while(nv_isref(np))
+ {
+ root = nv_reftree(np);
+ sh.last_table = nv_reftable(np);
+ sub = nv_refsub(np);
+ np = nv_refnode(np);
+ if(sub && c!='.')
+ nv_putsub(np,sub,0L);
+ flags |= NV_NOSCOPE;
+ }
+ if(sub && c==0)
+ return(np);
+ if(np==nq)
+ flags &= ~(noscope?0:NV_NOSCOPE);
+ else if(c)
+ {
+ c = (cp-sp);
+ copy = strlen(cp=nv_name(np));
+ dp->nofree = 1;
+ name = copystack(cp,sp,sub);
+ sp = (char*)name + copy;
+ cp = sp+c;
+ c = *sp;
+ if(!noscope)
+ flags &= ~NV_NOSCOPE;
+ }
+ flags |= NV_NOREF;
+ }
+ sh.last_root = root;
+ do
+ {
+ if(!np)
+ {
+ if(*sp=='[' && *cp==0 && cp[-1]==']')
+ {
+ /*
+ * for backward compatibility
+ * evaluate subscript for
+ * possible side effects
+ */
+ cp[-1] = 0;
+ sh_arith(sp+1);
+ cp[-1] = ']';
+ }
+ return(np);
+ }
+ if(c=='[' || (c=='.' && nv_isarray(np)))
+ {
+ int n = 0;
+ if(c=='[')
+ {
+ n = mode|nv_isarray(np);
+ if(!mode && (flags&NV_ARRAY) && ((c=sp[1])=='*' || c=='@') && sp[2]==']')
+ {
+ /* not implemented yet */
+ dp->last = cp;
+ return(np);
+ }
+ if(n&&(flags&NV_ARRAY))
+ n |= ARRAY_FILL;
+ cp = nv_endsubscript(np,sp,n);
+ }
+ else
+ cp = sp;
+ if((c = *cp)=='.' || c=='[' || (n&ARRAY_FILL))
+
+ {
+ int m = cp-sp;
+ char *sub = m?nv_getsub(np):0;
+ if(!sub)
+ sub = "0";
+ n = strlen(sub)+2;
+ if(!copy)
+ {
+ copy = cp-name;
+ dp->nofree = 1;
+ name = copystack((const char*)0, name,(const char*)0);
+ cp = (char*)name+copy;
+ sp = cp-m;
+ }
+ if(n <= m)
+ {
+ if(n)
+ {
+ memcpy(sp+1,sub,n-2);
+ sp[n-1] = ']';
+ }
+ if(n < m)
+ cp=strcpy(sp+n,cp);
+ }
+ else
+ {
+ int r = n-m;
+ m = sp-name;
+ name = stack_extend(name, cp-1, r);
+ sp = (char*)name + m;
+ *sp = '[';
+ memcpy(sp+1,sub,n-2);
+ sp[n-1] = ']';
+ cp = sp+n;
+
+ }
+ }
+ else if(c==0 && mode && (n=nv_aindex(np))>0)
+ nv_putsub(np,(char*)0,n|ARRAY_FILL);
+ else if(n==0 && c==0)
+ {
+ /* subscript must be 0*/
+ cp[-1] = 0;
+ c = sh_arith(sp+1);
+ cp[-1] = ']';
+ if(c)
+ return(0);
+ }
+ dp->last = cp;
+ if(nv_isarray(np) && (c=='[' || c=='.' || (flags&NV_ARRAY)))
+ {
+ *(sp=cp) = 0;
+ nq = nv_search(name,root,mode);
+ *sp = c;
+ if(nq && nv_isnull(nq))
+ nq = nv_arraychild(np,nq,c);
+ if(!(np=nq))
+ return(np);
+ }
+ }
+ else if(nv_isarray(np))
+ nv_putsub(np,NIL(char*),ARRAY_UNDEF);
+ if(c=='.' && (fp=np->nvfun))
+ {
+ for(; fp; fp=fp->next)
+ {
+ if(fp->disc && fp->disc->createf)
+ break;
+ }
+ if(fp)
+ {
+ if((nq = (*fp->disc->createf)(np,cp+1,flags,fp)) == np)
+ {
+ add = NV_ADD;
+ break;
+ }
+ else if((np=nq) && (c = *(cp=dp->last=fp->last))==0)
+ return(np);
+ }
+ }
+ }
+ while(c=='[');
+ if(c!='.')
+ return(np);
+ cp++;
+ break;
+ default:
+ dp->last = cp;
+ if((c = mbchar(cp)) && !isaletter(c))
+ return(np);
+ while(xp=cp, c=mbchar(cp), isaname(c));
+ cp = xp;
+ }
+ }
+ return(np);
+}
+
+/*
+ * Put <arg> into associative memory.
+ * If <flags> & NV_ARRAY then follow array to next subscript
+ * If <flags> & NV_NOARRAY then subscript is not allowed
+ * If <flags> & NV_NOSCOPE then use the current scope only
+ * If <flags> & NV_ASSIGN then assignment is allowed
+ * If <flags> & NV_IDENT then name must be an identifier
+ * If <flags> & NV_VARNAME then name must be a valid variable name
+ * If <flags> & NV_NOADD then node will not be added if not found
+ * If <flags> & NV_NOREF then don't follow reference
+ * If <flags> & NV_NOFAIL then don't generate an error message on failure
+ * SH_INIT is only set while initializing the environment
+ */
+Namval_t *nv_open(const char *name, Dt_t *root, int flags)
+{
+ register char *cp=(char*)name;
+ register int c;
+ register Namval_t *np;
+ Namfun_t fun;
+ int append=0;
+ const char *msg = e_varname;
+ char *fname = 0;
+ int offset = staktell();
+ Dt_t *funroot;
+
+ memset(&fun,0,sizeof(fun));
+ sh.last_table = sh.namespace;
+ if(!root)
+ root = sh.var_tree;
+ sh.last_root = root;
+ if(root==sh_subfuntree(1))
+ {
+ flags |= NV_NOREF;
+ msg = e_badfun;
+ if((np=sh.namespace) || strchr(name,'.'))
+ {
+ name = cp = copystack(np?nv_name(np):0,name,(const char*)0);
+ fname = strrchr(cp,'.');
+ *fname = 0;
+ fun.nofree = 1;
+ flags &= ~NV_IDENT;
+ funroot = root;
+ root = sh.var_tree;
+ }
+ }
+ else if(!(flags&(NV_IDENT|NV_VARNAME|NV_ASSIGN)))
+ {
+ long mode = ((flags&NV_NOADD)?0:NV_ADD);
+ if(flags&NV_NOSCOPE)
+ mode |= HASH_SCOPE|HASH_NOSCOPE;
+ np = nv_search(name,root,mode);
+ if(np && !(flags&NV_REF))
+ {
+ while(nv_isref(np))
+ {
+ sh.last_table = nv_reftable(np);
+ np = nv_refnode(np);
+ }
+ }
+ return(np);
+ }
+ else if(sh.prefix && /**name!='.' &&*/ (flags&NV_ASSIGN))
+ {
+ name = cp = copystack(sh.prefix,name,(const char*)0);
+ fun.nofree = 1;
+ }
+ c = *(unsigned char*)cp;
+ if(root==sh.alias_tree)
+ {
+ msg = e_aliname;
+ while((c= *(unsigned char*)cp++) && (c!='=') && (c!='/') &&
+ (c>=0x200 || !(c=sh_lexstates[ST_NORM][c]) || c==S_EPAT));
+ if(sh.subshell && c=='=')
+ root = sh_subaliastree(1);
+ if(c= *--cp)
+ *cp = 0;
+ np = nv_search(name, root, (flags&NV_NOADD)?0:NV_ADD);
+ if(c)
+ *cp = c;
+ goto skip;
+ }
+ else if(flags&NV_IDENT)
+ msg = e_ident;
+ else if(c=='.')
+ {
+ c = *++cp;
+ flags |= NV_NOREF;
+ if(root==sh.var_tree)
+ root = sh.var_base;
+ sh.last_table = 0;
+ }
+ if(c= !isaletter(c))
+ goto skip;
+ np = nv_create(name, root, flags, &fun);
+ cp = fun.last;
+ if(fname)
+ {
+ c = ((flags&NV_NOSCOPE)?HASH_NOSCOPE:0)|((flags&NV_NOADD)?0:NV_ADD);
+ *fname = '.';
+ np = nv_search(name, funroot, c);
+ *fname = 0;
+ }
+ else if(*cp=='+' && cp[1]=='=')
+ {
+ append=NV_APPEND;
+ cp++;
+ }
+ c = *cp;
+skip:
+ if(c=='=' && np && (flags&NV_ASSIGN))
+ {
+ cp++;
+ if(sh_isstate(SH_INIT))
+ {
+ nv_putval(np, cp, NV_RDONLY);
+ if(np==PWDNOD)
+ nv_onattr(np,NV_TAGGED);
+ }
+ else
+ {
+ char *sub=0;
+ if(sh_isoption(SH_XTRACE) && nv_isarray(np))
+ sub = nv_getsub(np);
+ c = msg==e_aliname? 0: (append | (flags&NV_EXPORT));
+ nv_putval(np, cp, c);
+ savesub = sub;
+ }
+ nv_onattr(np, flags&NV_ATTRIBUTES);
+ }
+ else if(c)
+ {
+ if(flags&NV_NOFAIL)
+ return(0);
+ if(c=='.')
+ msg = e_noparent;
+ else if(c=='[')
+ msg = e_noarray;
+ errormsg(SH_DICT,ERROR_exit(1),msg,name);
+ }
+ if(fun.nofree)
+ stakseek(offset);
+ return(np);
+}
+
+#if SHOPT_MULTIBYTE
+ static int ja_size(char*, int, int);
+ static void ja_restore(void);
+ static char *savep;
+ static char savechars[8+1];
+#endif /* SHOPT_MULTIBYTE */
+
+/*
+ * put value <string> into name-value node <np>.
+ * If <np> is an array, then the element given by the
+ * current index is assigned to.
+ * If <flags> contains NV_RDONLY, readonly attribute is ignored
+ * If <flags> contains NV_INTEGER, string is a pointer to a number
+ * If <flags> contains NV_NOFREE, previous value is freed, and <string>
+ * becomes value of node and <flags> becomes attributes
+ */
+void nv_putval(register Namval_t *np, const char *string, int flags)
+{
+ register const char *sp=string;
+ register union Value *up;
+ register char *cp;
+ register int size = 0;
+ register int dot;
+ int was_local = nv_local;
+ if(!(flags&NV_RDONLY) && nv_isattr (np, NV_RDONLY))
+ errormsg(SH_DICT,ERROR_exit(1),e_readonly, nv_name(np));
+ /* The following could cause the shell to fork if assignment
+ * would cause a side effect
+ */
+ sh.argaddr = 0;
+ if(sh.subshell && !nv_local)
+ np = sh_assignok(np,1);
+ if(np->nvfun && !nv_isattr(np,NV_REF))
+ {
+ /* This function contains disc */
+ if(!nv_local)
+ {
+ nv_local=1;
+ nv_putv(np,sp,flags,np->nvfun);
+ if(sp && ((flags&NV_EXPORT) || nv_isattr(np,NV_EXPORT)))
+ sh_envput(sh.env,np);
+ return;
+ }
+ /* called from disc, assign the actual value */
+ }
+ flags &= ~NV_NODISC;
+ if(flags&(NV_NOREF|NV_NOFREE))
+ {
+ if(!nv_isnull(np) && np->nvalue.cp!=sp)
+ nv_unset(np);
+ nv_local=0;
+ np->nvalue.cp = (char*)sp;
+ nv_setattr(np,(flags&~NV_RDONLY)|NV_NOFREE);
+ return;
+ }
+ nv_local=0;
+ up= &np->nvalue;
+#if !SHOPT_BSH
+ if(nv_isattr(np,NV_EXPORT))
+ nv_offattr(np,NV_IMPORT);
+ else if(!nv_isattr(np,NV_MINIMAL))
+ np->nvenv = 0;
+#endif /* SHOPT_BSH */
+ if(nv_isattr (np, NV_INTEGER))
+ {
+ if(nv_isattr(np, NV_DOUBLE))
+ {
+ if(nv_isattr(np, NV_LONG) && sizeof(double)<sizeof(Sfdouble_t))
+ {
+ Sfdouble_t ld, old=0;
+ if(flags&NV_INTEGER)
+ {
+ if(flags&NV_LONG)
+ ld = *((Sfdouble_t*)sp);
+ else if(flags&NV_SHORT)
+ ld = *((float*)sp);
+ else
+ ld = *((double*)sp);
+ }
+ else
+ ld = sh_arith(sp);
+ if(!up->ldp)
+ up->ldp = new_of(Sfdouble_t,0);
+ else if(flags&NV_APPEND)
+ old = *(up->ldp);
+ *(up->ldp) = ld+old;
+ }
+ else
+ {
+ double d,od=0;
+ if(flags&NV_INTEGER)
+ {
+ if(flags&NV_LONG)
+ d = (double)(*(Sfdouble_t*)sp);
+ else if(flags&NV_SHORT)
+ d = (double)(*(float*)sp);
+ else
+ d = *(double*)sp;
+ }
+ else
+ d = sh_arith(sp);
+ if(!up->dp)
+ up->dp = new_of(double,0);
+ else if(flags&NV_APPEND)
+ od = *(up->dp);
+ *(up->dp) = d+od;
+ }
+ }
+ else
+ {
+ if(nv_isattr(np, NV_LONG) && sizeof(int32_t)<sizeof(Sflong_t))
+ {
+ Sflong_t ll=0,oll=0;
+ if(flags&NV_INTEGER)
+ {
+ if(flags&NV_DOUBLE)
+ {
+ if(flags&NV_LONG)
+ ll = *((Sfdouble_t*)sp);
+ else if(flags&NV_SHORT)
+ ll = *((float*)sp);
+ else
+ ll = *((double*)sp);
+ }
+ else if(nv_isattr(np,NV_UNSIGN))
+ {
+ if(flags&NV_LONG)
+ ll = *((Sfulong_t*)sp);
+ else if(flags&NV_SHORT)
+ ll = *((uint16_t*)sp);
+ else
+ ll = *((uint32_t*)sp);
+ }
+ else
+ {
+ if(flags&NV_LONG)
+ ll = *((Sflong_t*)sp);
+ else if(flags&NV_SHORT)
+ ll = *((uint16_t*)sp);
+ else
+ ll = *((uint32_t*)sp);
+ }
+ }
+ else if(sp)
+ ll = (Sflong_t)sh_arith(sp);
+ if(!up->llp)
+ up->llp = new_of(Sflong_t,0);
+ else if(flags&NV_APPEND)
+ oll = *(up->llp);
+ *(up->llp) = ll+oll;
+ }
+ else
+ {
+ int32_t l=0,ol=0;
+ if(flags&NV_INTEGER)
+ {
+ if(flags&NV_DOUBLE)
+ {
+ Sflong_t ll;
+ if(flags&NV_LONG)
+ ll = *((Sfdouble_t*)sp);
+ else if(flags&NV_SHORT)
+ ll = *((float*)sp);
+ else
+ ll = *((double*)sp);
+ l = (int32_t)ll;
+ }
+ else if(nv_isattr(np,NV_UNSIGN))
+ {
+ if(flags&NV_LONG)
+ l = *((Sfulong_t*)sp);
+ else if(flags&NV_SHORT)
+ l = *((uint16_t*)sp);
+ else
+ l = *(uint32_t*)sp;
+ }
+ else
+ {
+ if(flags&NV_LONG)
+ l = *((Sflong_t*)sp);
+ else if(flags&NV_SHORT)
+ l = *((int16_t*)sp);
+ else
+ l = *(int32_t*)sp;
+ }
+ }
+ else if(sp)
+ {
+ Sfdouble_t ld = sh_arith(sp);
+ if(ld<0)
+ l = (int32_t)ld;
+ else
+ l = (uint32_t)ld;
+ }
+ if(nv_size(np) <= 1)
+ nv_setsize(np,10);
+ if(nv_isattr (np, NV_SHORT))
+ {
+ int16_t s=0;
+ if(flags&NV_APPEND)
+ s = up->s;
+ up->s = s+(int16_t)l;
+ nv_onattr(np,NV_NOFREE);
+ }
+ else
+ {
+ if(!up->lp)
+ up->lp = new_of(int32_t,0);
+ else if(flags&NV_APPEND)
+ ol = *(up->lp);
+ *(up->lp) = l+ol;
+ }
+ }
+ }
+ }
+ else
+ {
+ const char *tofree=0;
+ int offset;
+#if _lib_pathnative
+ char buff[PATH_MAX];
+#endif /* _lib_pathnative */
+ if(flags&NV_INTEGER)
+ {
+ if(flags&NV_DOUBLE)
+ {
+ if(flags&NV_LONG)
+ sfprintf(sh.strbuf,"%.*Lg",LDBL_DIG,*((Sfdouble_t*)sp));
+ else
+ sfprintf(sh.strbuf,"%.*g",DBL_DIG,*((double*)sp));
+ }
+ else if(flags&NV_LONG)
+ sfprintf(sh.strbuf,"%lld\0",*((Sflong_t*)sp));
+ else
+ sfprintf(sh.strbuf,"%ld\0",*((int32_t*)sp));
+ sp = sfstruse(sh.strbuf);
+ }
+ if(nv_isattr(np, NV_HOST)==NV_HOST && sp)
+ {
+#ifdef _lib_pathnative
+ /*
+ * return the host file name given the UNIX name
+ */
+ pathnative(sp,buff,sizeof(buff));
+ if(buff[1]==':' && buff[2]=='/')
+ {
+ buff[2] = '\\';
+ if(*buff>='A' && *buff<='Z')
+ *buff += 'a'-'A';
+ }
+ sp = buff;
+#else
+ ;
+#endif /* _lib_pathnative */
+ }
+ else if((nv_isattr(np, NV_RJUST|NV_ZFILL|NV_LJUST)) && sp)
+ {
+ for(;*sp == ' '|| *sp=='\t';sp++);
+ if((nv_isattr(np,NV_ZFILL)) && (nv_isattr(np,NV_LJUST)))
+ for(;*sp=='0';sp++);
+ size = nv_size(np);
+#if SHOPT_MULTIBYTE
+ if(size)
+ size = ja_size((char*)sp,size,nv_isattr(np,NV_RJUST|NV_ZFILL));
+#endif /* SHOPT_MULTIBYTE */
+ }
+ if(!up->cp)
+ flags &= ~NV_APPEND;
+ if((flags&NV_APPEND) && !nv_isattr(np,NV_BINARY))
+ {
+ offset = staktell();
+ stakputs(up->cp);
+ stakputs(sp);
+ stakputc(0);
+ sp = stakptr(offset);
+ }
+ if(!nv_isattr(np, NV_NOFREE))
+ {
+ /* delay free in case <sp> points into free region */
+ tofree = up->cp;
+ }
+ nv_offattr(np,NV_NOFREE);
+ if (sp)
+ {
+ dot = strlen(sp);
+#if (_AST_VERSION>=20030127L)
+ if(nv_isattr(np,NV_BINARY))
+ {
+ int oldsize = (flags&NV_APPEND)?nv_size(np):0;
+ if(flags&NV_RAW)
+ {
+ if(tofree)
+ free((void*)tofree);
+ up->cp = sp;
+ return;
+ }
+ size = 0;
+ if(nv_isattr(np,NV_ZFILL))
+ size = nv_size(np);
+ if(size==0)
+ size = oldsize + (3*dot/4);
+ cp = (char*)malloc(size+1);
+ if(oldsize)
+ memcpy((void*)cp,(void*)up->cp,oldsize);
+ up->cp = cp;
+ if(size <= oldsize)
+ return;
+ dot = base64decode(sp,dot, (void**)0, cp+oldsize, size-oldsize,(void**)0);
+ dot += oldsize;
+ if(!nv_isattr(np,NV_ZFILL) || nv_size(np)==0)
+ nv_setsize(np,dot);
+ else if(nv_isattr(np,NV_ZFILL) && (size>dot))
+ memset((void*)&cp[dot],0,size-dot);
+ return;
+ }
+ else
+#endif
+ if(size==0 && nv_isattr(np,NV_LJUST|NV_RJUST|NV_ZFILL))
+ nv_setsize(np,size=dot);
+ else if(size > dot)
+ dot = size;
+ cp = (char*)malloc(((unsigned)dot+1));
+ }
+ else
+ cp = 0;
+ up->cp = cp;
+ if(sp)
+ {
+ if(nv_isattr(np, NV_LTOU))
+ ltou(sp,cp);
+ else if(nv_isattr (np, NV_UTOL))
+ sh_utol(sp,cp);
+ else
+ strcpy(cp, sp);
+ if(nv_isattr(np, NV_RJUST) && nv_isattr(np, NV_ZFILL))
+ rightjust(cp,size,'0');
+ else if(nv_isattr(np, NV_RJUST))
+ rightjust(cp,size,' ');
+ else if(nv_isattr(np, NV_LJUST))
+ {
+ register char *dp;
+ dp = strlen (cp) + cp;
+ *(cp = (cp + size)) = 0;
+ for (; dp < cp; *dp++ = ' ');
+ }
+#if SHOPT_MULTIBYTE
+ /* restore original string */
+ if(savep)
+ ja_restore();
+#endif /* SHOPT_MULTIBYTE */
+ }
+ if(flags&NV_APPEND)
+ stakseek(offset);
+ if(tofree)
+ free((void*)tofree);
+ }
+ if(!was_local && ((flags&NV_EXPORT) || nv_isattr(np,NV_EXPORT)))
+ sh_envput(sh.env,np);
+ return;
+}
+
+/*
+ *
+ * Right-justify <str> so that it contains no more than
+ * <size> characters. If <str> contains fewer than <size>
+ * characters, left-pad with <fill>. Trailing blanks
+ * in <str> will be ignored.
+ *
+ * If the leftmost digit in <str> is not a digit, <fill>
+ * will default to a blank.
+ */
+static void rightjust(char *str, int size, int fill)
+{
+ register int n;
+ register char *cp,*sp;
+ n = strlen(str);
+
+ /* ignore trailing blanks */
+ for(cp=str+n;n && *--cp == ' ';n--);
+ if (n == size)
+ return;
+ if(n > size)
+ {
+ *(str+n) = 0;
+ for (sp = str, cp = str+n-size; sp <= str+size; *sp++ = *cp++);
+ return;
+ }
+ else *(sp = str+size) = 0;
+ if (n == 0)
+ {
+ while (sp > str)
+ *--sp = ' ';
+ return;
+ }
+ while(n--)
+ {
+ sp--;
+ *sp = *cp--;
+ }
+ if(!isdigit(*str))
+ fill = ' ';
+ while(sp>str)
+ *--sp = fill;
+ return;
+}
+
+#if SHOPT_MULTIBYTE
+ /*
+ * handle left and right justified fields for multi-byte chars
+ * given physical size, return a logical size which reflects the
+ * screen width of multi-byte characters
+ * Multi-width characters replaced by spaces if they cross the boundary
+ * <type> is non-zero for right justified fields
+ */
+
+ static int ja_size(char *str,int size,int type)
+ {
+ register char *cp = str;
+ register int c, n=size;
+ register int outsize;
+ register char *oldcp=cp;
+ int oldn;
+ wchar_t w;
+ while(*cp)
+ {
+ oldn = n;
+ w = mbchar(cp);
+ outsize = mbwidth(w);
+ size -= outsize;
+ c = cp-oldcp;
+ n += (c-outsize);
+ oldcp = cp;
+ if(size<=0 && type==0)
+ break;
+ }
+ /* check for right justified fields that need truncating */
+ if(size <0)
+ {
+ if(type==0)
+ {
+ /* left justified and character crosses field boundary */
+ n = oldn;
+ /* save boundary char and replace with spaces */
+ size = c;
+ savechars[size] = 0;
+ while(size--)
+ {
+ savechars[size] = cp[size];
+ cp[size] = ' ';
+ }
+ savep = cp;
+ }
+ size = -size;
+ if(type)
+ n -= (ja_size(str,size,0)-size);
+ }
+ return(n);
+ }
+
+ static void ja_restore(void)
+ {
+ register char *cp = savechars;
+ while(*cp)
+ *savep++ = *cp++;
+ savep = 0;
+ }
+#endif /* SHOPT_MULTIBYTE */
+
+#ifndef _ENV_H
+static char *staknam(register Namval_t *np, char *value)
+{
+ register char *p,*q;
+ q = stakalloc(strlen(nv_name(np))+(value?strlen(value):0)+2);
+ p=strcopy(q,nv_name(np));
+ if(value)
+ {
+ *p++ = '=';
+ strcpy(p,value);
+ }
+ return(q);
+}
+#endif
+
+/*
+ * put the name and attribute into value of attributes variable
+ */
+#ifdef _ENV_H
+static void attstore(register Namval_t *np, void *data)
+{
+ register int flag, c = ' ';
+ NOT_USED(data);
+ if(!(nv_isattr(np,NV_EXPORT)))
+ return;
+ flag = nv_isattr(np,NV_RDONLY|NV_UTOL|NV_LTOU|NV_RJUST|NV_LJUST|NV_ZFILL|NV_INTEGER);
+ stakputc('=');
+ if((flag&NV_DOUBLE) && (flag&NV_INTEGER))
+ {
+ /* export doubles as integers for ksh88 compatibility */
+ stakputc(c+(flag&~(NV_DOUBLE|NV_EXPNOTE)));
+ }
+ else
+ {
+ stakputc(c+flag);
+ if(flag&NV_INTEGER)
+ c += nv_size(np);
+ }
+ stakputc(c);
+ stakputs(nv_name(np));
+}
+#else
+static void attstore(register Namval_t *np, void *data)
+{
+ register int flag = np->nvflag;
+ register struct adata *ap = (struct adata*)data;
+ if(!(flag&NV_EXPORT) || (flag&NV_FUNCT))
+ return;
+ flag &= (NV_RDONLY|NV_UTOL|NV_LTOU|NV_RJUST|NV_LJUST|NV_ZFILL|NV_INTEGER);
+ *ap->attval++ = '=';
+ if((flag&NV_DOUBLE) && (flag&NV_INTEGER))
+ {
+ /* export doubles as integers for ksh88 compatibility */
+ *ap->attval++ = ' '+(flag&~(NV_DOUBLE|NV_EXPNOTE));
+ *ap->attval = ' ';
+ }
+ else
+ {
+ *ap->attval++ = ' '+flag;
+ if(flag&NV_INTEGER)
+ *ap->attval = ' ' + nv_size(np);
+ else
+ *ap->attval = ' ';
+ }
+ ap->attval = strcopy(++ap->attval,nv_name(np));
+}
+#endif
+
+#ifndef _ENV_H
+static void pushnam(Namval_t *np, void *data)
+{
+ register char *value;
+ register struct adata *ap = (struct adata*)data;
+ if(nv_isattr(np,NV_IMPORT))
+ {
+ if(np->nvenv)
+ *ap->argnam++ = np->nvenv;
+ }
+ else if(value=nv_getval(np))
+ *ap->argnam++ = staknam(np,value);
+ if(nv_isattr(np,NV_RDONLY|NV_UTOL|NV_LTOU|NV_RJUST|NV_LJUST|NV_ZFILL|NV_INTEGER))
+ ap->attsize += (strlen(nv_name(np))+4);
+}
+#endif
+
+/*
+ * Generate the environment list for the child.
+ */
+
+#ifdef _ENV_H
+char **sh_envgen(void)
+{
+ int offset,tell;
+ register char **er;
+ env_delete(sh.env,"_");
+ er = env_get(sh.env);
+ offset = staktell();
+ stakputs(e_envmarker);
+ tell = staktell();
+ nv_scan(sh.var_tree, attstore,(void*)0,0,(NV_RDONLY|NV_UTOL|NV_LTOU|NV_RJUST|NV_LJUST|NV_ZFILL|NV_INTEGER));
+ if(tell ==staktell())
+ stakseek(offset);
+ else
+ *--er = stakfreeze(1)+offset;
+ return(er);
+}
+#else
+char **sh_envgen(void)
+{
+ register char **er;
+ register int namec;
+ register char *cp;
+ struct adata data;
+ /* L_ARGNOD gets generated automatically as full path name of command */
+ nv_offattr(L_ARGNOD,NV_EXPORT);
+ data.attsize = 6;
+ namec = nv_scan(sh.var_tree,nullscan,(void*)0,NV_EXPORT,NV_EXPORT);
+ er = (char**)stakalloc((namec+4)*sizeof(char*));
+ data.argnam = (er+=2);
+ nv_scan(sh.var_tree, pushnam,&data,NV_EXPORT, NV_EXPORT);
+ *data.argnam = (char*)stakalloc(data.attsize);
+ cp = data.attval = strcopy(*data.argnam,e_envmarker);
+ nv_scan(sh.var_tree, attstore,&data,0,(NV_RDONLY|NV_UTOL|NV_LTOU|NV_RJUST|NV_LJUST|NV_ZFILL|NV_INTEGER));
+ *data.attval = 0;
+ if(cp!=data.attval)
+ data.argnam++;
+ *data.argnam = 0;
+ return(er);
+}
+#endif
+
+struct scan
+{
+ void (*scanfn)(Namval_t*, void*);
+ int scanmask;
+ int scanflags;
+ int scancount;
+ void *scandata;
+};
+
+
+static int scanfilter(Dt_t *dict, void *arg, void *data)
+{
+ register Namval_t *np = (Namval_t*)arg;
+ register int k=np->nvflag;
+ register struct scan *sp = (struct scan*)data;
+ NOT_USED(dict);
+ if(sp->scanmask?(k&sp->scanmask)==sp->scanflags:(!sp->scanflags || (k&sp->scanflags)))
+ {
+ if(!np->nvalue.cp && !nv_isattr(np,~NV_DEFAULT))
+ return(0);
+ if(sp->scanfn)
+ {
+ if(nv_isarray(np))
+ nv_putsub(np,NIL(char*),0L);
+ (*sp->scanfn)(np,sp->scandata);
+ }
+ sp->scancount++;
+ }
+ return(0);
+}
+
+/*
+ * Walk through the name-value pairs
+ * if <mask> is non-zero, then only nodes with (nvflags&mask)==flags
+ * are visited
+ * If <mask> is zero, and <flags> non-zero, then nodes with one or
+ * more of <flags> is visited
+ * If <mask> and <flags> are zero, then all nodes are visted
+ */
+int nv_scan(Dt_t *root, void (*fn)(Namval_t*,void*), void *data,int mask, int flags)
+{
+ Dt_t *base=0;
+ struct scan sdata;
+ int (*hashfn)(Dt_t*, void*, void*);
+ sdata.scanmask = mask;
+ sdata.scanflags = flags&~NV_NOSCOPE;
+ sdata.scanfn = fn;
+ sdata.scancount = 0;
+ sdata.scandata = data;
+ hashfn = scanfilter;
+ if(flags&NV_NOSCOPE)
+ base = dtview((Dt_t*)root,0);
+ dtwalk(root, hashfn,&sdata);
+ if(base)
+ dtview((Dt_t*)root,base);
+ return(sdata.scancount);
+}
+
+/*
+ * create a new environment scope
+ */
+void nv_scope(struct argnod *envlist)
+{
+ register Dt_t *newscope;
+ newscope = dtopen(&_Nvdisc,Dtoset);
+ dtview(newscope,(Dt_t*)sh.var_tree);
+ sh.var_tree = (Dt_t*)newscope;
+ if(envlist)
+ nv_setlist(envlist,NV_EXPORT|NV_NOSCOPE|NV_IDENT|NV_ASSIGN);
+}
+
+/*
+ * Remove freeable local space associated with the nvalue field
+ * of nnod. This includes any strings representing the value(s) of the
+ * node, as well as its dope vector, if it is an array.
+ */
+
+void sh_envnolocal (register Namval_t *np, void *data)
+{
+ char *cp=0;
+ NOT_USED(data);
+ if(nv_isattr(np,NV_EXPORT) && nv_isarray(np))
+ {
+ nv_putsub(np,NIL(char*),0);
+ if(cp = nv_getval(np))
+ cp = strdup(cp);
+ }
+ if(nv_isattr(np,NV_EXPORT|NV_NOFREE))
+ {
+ if(nv_isref(np))
+ {
+ nv_offattr(np,NV_NOFREE|NV_REF);
+ free((void*)np->nvalue.nrp);
+ np->nvalue.cp = 0;
+ }
+ if(!cp)
+ return;
+ }
+ if(nv_isarray(np))
+ nv_putsub(np,NIL(char*),ARRAY_UNDEF);
+ _nv_unset(np,NV_RDONLY);
+ nv_setattr(np,0);
+ if(cp)
+ {
+ nv_putval(np,cp,0);
+ free((void*)cp);
+ }
+}
+
+/*
+ * Currently this is a dummy, but someday will be needed
+ * for reference counting
+ */
+void nv_close(Namval_t *np)
+{
+ NOT_USED(np);
+}
+
+static void table_unset(register Dt_t *root, int flags, Dt_t *oroot)
+{
+ register Namval_t *np,*nq;
+ for(np=(Namval_t*)dtfirst(root);np;np=nq)
+ {
+ _nv_unset(np,flags);
+ if(oroot && (nq=nv_search(nv_name(np),oroot,0)) && nv_isattr(nq,NV_EXPORT))
+ sh_envput(sh.env,nq);
+ nq = (Namval_t*)dtnext(root,np);
+ dtdelete(root,np);
+ free((void*)np);
+ }
+}
+
+/*
+ *
+ * Set the value of <np> to 0, and nullify any attributes
+ * that <np> may have had. Free any freeable space occupied
+ * by the value of <np>. If <np> denotes an array member, it
+ * will retain its attributes.
+ * <flags> can contain NV_RDONLY to override the readonly attribute
+ * being cleared.
+ */
+void _nv_unset(register Namval_t *np,int flags)
+{
+ register union Value *up;
+ if(!(flags&NV_RDONLY) && nv_isattr (np,NV_RDONLY))
+ errormsg(SH_DICT,ERROR_exit(1),e_readonly, nv_name(np));
+ if(is_afunction(np) && np->nvalue.ip)
+ {
+ register struct slnod *slp = (struct slnod*)(np->nvenv);
+ if(slp && !nv_isattr(np,NV_NOFREE))
+ {
+ /* free function definition */
+ register char *name=nv_name(np),*cp= strrchr(name,'.');
+ if(cp)
+ {
+ Namval_t *npv;
+ *cp = 0;
+ npv = nv_open(name,sh.var_tree,NV_NOARRAY|NV_VARNAME|NV_NOADD);
+ *cp++ = '.';
+ if(npv)
+ nv_setdisc(npv,cp,NIL(Namval_t*),(Namfun_t*)npv);
+ }
+ stakdelete(slp->slptr);
+ free((void*)np->nvalue.ip);
+ np->nvalue.ip = 0;
+ }
+ goto done;
+ }
+ if(sh.subshell && !nv_isnull(np))
+ np = sh_assignok(np,0);
+ nv_offattr(np,NV_NODISC);
+ if(np->nvfun && !nv_isref(np))
+ {
+ /* This function contains disc */
+ if(!nv_local)
+ {
+ nv_local=1;
+ nv_putv(np,NIL(char*),flags,np->nvfun);
+ return;
+ }
+ /* called from disc, assign the actual value */
+ nv_local=0;
+ }
+ up = &np->nvalue;
+ if(up->cp)
+ {
+ if(!nv_isattr (np, NV_NOFREE))
+ free((void*)up->cp);
+ up->cp = 0;
+ }
+done:
+ if(!nv_isarray(np) || !nv_arrayptr(np))
+ {
+ if(nv_isref(np))
+ free((void*)np->nvalue.nrp);
+ nv_setsize(np,0);
+ if(!nv_isattr(np,NV_MINIMAL) || nv_isattr(np,NV_EXPORT))
+ {
+ if(nv_isattr(np,NV_EXPORT) && !strchr(np->nvname,'['))
+ env_delete(sh.env,nv_name(np));
+ np->nvenv = 0;
+ nv_setattr(np,0);
+ }
+ else
+ nv_setattr(np,NV_MINIMAL);
+ }
+}
+
+void nv_unset(register Namval_t *np)
+{
+ _nv_unset(np,0);
+}
+
+/*
+ * return the node pointer in the highest level scope
+ */
+Namval_t *nv_scoped(register Namval_t *np)
+{
+ if(!dtvnext(sh.var_tree))
+ return(np);
+ return(dtsearch(sh.var_tree,np));
+}
+
+#if 1
+/*
+ * return space separated list of names of variables in given tree
+ */
+static char *tableval(Dt_t *root)
+{
+ static Sfio_t *out;
+ register Namval_t *np;
+ register int first=1;
+ register Dt_t *base = dtview(root,0);
+ if(out)
+ sfseek(out,(Sfoff_t)0,SEEK_SET);
+ else
+ out = sfnew((Sfio_t*)0,(char*)0,-1,-1,SF_WRITE|SF_STRING);
+ for(np=(Namval_t*)dtfirst(root);np;np=(Namval_t*)dtnext(root,np))
+ {
+ if(!nv_isnull(np) || np->nvfun || nv_isattr(np,~NV_NOFREE))
+ {
+ if(!first)
+ sfputc(out,' ');
+ else
+ first = 0;
+ sfputr(out,np->nvname,-1);
+ }
+ }
+ sfputc(out,0);
+ if(base)
+ dtview(root,base);
+ return((char*)out->_data);
+}
+#endif
+
+#if SHOPT_OPTIMIZE
+struct optimize
+{
+ Namfun_t hdr;
+ char **ptr;
+ struct optimize *next;
+ Namval_t *np;
+};
+
+static struct optimize *opt_free;
+
+static void optimize_clear(Namval_t* np, Namfun_t *fp)
+{
+ struct optimize *op = (struct optimize*)fp;
+ nv_stack(np,fp);
+ nv_stack(np,(Namfun_t*)0);
+ for(;op && op->np==np; op=op->next)
+ {
+ if(op->ptr)
+ {
+ *op->ptr = 0;
+ op->ptr = 0;
+ }
+ }
+}
+
+static void put_optimize(Namval_t* np,const char *val,int flags,Namfun_t *fp)
+{
+ nv_putv(np,val,flags,fp);
+ optimize_clear(np,fp);
+}
+
+static const Namdisc_t optimize_disc = {sizeof(struct optimize),put_optimize};
+
+void nv_optimize(Namval_t *np)
+{
+ register Namfun_t *fp;
+ register struct optimize *op, *xp;
+ if(sh.argaddr)
+ {
+ for(fp=np->nvfun; fp; fp = fp->next)
+ {
+ if(fp->disc->getnum || fp->disc->getval)
+ {
+ sh.argaddr = 0;
+ return;
+ }
+ if(fp->disc== &optimize_disc)
+ break;
+ }
+ if((xp= (struct optimize*)fp) && xp->ptr==sh.argaddr)
+ return;
+ if(op = opt_free)
+ opt_free = op->next;
+ else
+ op=(struct optimize*)calloc(1,sizeof(struct optimize));
+ op->ptr = sh.argaddr;
+ op->np = np;
+ if(xp)
+ {
+ op->hdr.disc = 0;
+ op->next = xp->next;
+ xp->next = op;
+ }
+ else
+ {
+ op->hdr.disc = &optimize_disc;
+ op->next = (struct optimize*)sh.optlist;
+ sh.optlist = (void*)op;
+ nv_stack(np,&op->hdr);
+ }
+ }
+}
+
+void sh_optclear(Shell_t *shp, void *old)
+{
+ register struct optimize *op,*opnext;
+ for(op=(struct optimize*)shp->optlist; op; op = opnext)
+ {
+ opnext = op->next;
+ if(op->ptr && op->hdr.disc)
+ {
+ nv_stack(op->np,&op->hdr);
+ nv_stack(op->np,(Namfun_t*)0);
+ }
+ op->next = opt_free;
+ opt_free = op;
+ }
+ shp->optlist = old;
+}
+
+#else
+# define optimize_clear(np,fp)
+#endif /* SHOPT_OPTIMIZE */
+
+/*
+ * Return a pointer to a character string that denotes the value
+ * of <np>. If <np> refers to an array, return a pointer to
+ * the value associated with the current index.
+ *
+ * If the value of <np> is an integer, the string returned will
+ * be overwritten by the next call to nv_getval.
+ *
+ * If <np> has no value, 0 is returned.
+ */
+
+char *nv_getval(register Namval_t *np)
+{
+ register union Value *up= &np->nvalue;
+ register int numeric;
+#if SHOPT_OPTIMIZE
+ if(!nv_local && sh.argaddr)
+ nv_optimize(np);
+#endif /* SHOPT_OPTIMIZE */
+ if(!np->nvfun && !nv_isattr(np,NV_ARRAY|NV_INTEGER|NV_FUNCT|NV_REF|NV_TABLE))
+ goto done;
+ if(nv_isref(np))
+ {
+ sh.last_table = nv_reftable(np);
+ return(nv_name(nv_refnode(np)));
+ }
+ if(np->nvfun)
+ {
+ if(!nv_local)
+ {
+ nv_local=1;
+ return(nv_getv(np, np->nvfun));
+ }
+ nv_local=0;
+ }
+ numeric = ((nv_isattr (np, NV_INTEGER)) != 0);
+ if(numeric)
+ {
+ Sflong_t ll;
+ if(!up->cp)
+ return("0");
+ if(nv_isattr (np,NV_DOUBLE))
+ {
+ Sfdouble_t ld;
+ double d;
+ char *format;
+ if(nv_isattr(np,NV_LONG))
+ {
+ ld = *up->ldp;
+ if(nv_isattr (np,NV_EXPNOTE))
+ format = "%.*Lg";
+ else
+ format = "%.*Lf";
+ sfprintf(sh.strbuf,format,nv_size(np),ld);
+ }
+ else
+ {
+ d = *up->dp;
+ if(nv_isattr (np,NV_EXPNOTE))
+ format = "%.*g";
+ else
+ format = "%.*f";
+ sfprintf(sh.strbuf,format,nv_size(np),d);
+ }
+ return(sfstruse(sh.strbuf));
+ }
+ else if(nv_isattr(np,NV_UNSIGN))
+ {
+ if(nv_isattr (np,NV_LONG))
+ ll = *(Sfulong_t*)up->llp;
+ else if(nv_isattr (np,NV_SHORT))
+ ll = (uint16_t)up->s;
+ else
+ ll = *(uint32_t*)(up->lp);
+ }
+ else if(nv_isattr (np,NV_LONG))
+ ll = *up->llp;
+ else if(nv_isattr (np,NV_SHORT))
+ ll = up->s;
+ else
+ ll = *(up->lp);
+ if((numeric=nv_size(np))==10)
+ {
+ if(nv_isattr(np,NV_UNSIGN))
+ {
+ sfprintf(sh.strbuf,"%I*u",sizeof(ll),ll);
+ return(sfstruse(sh.strbuf));
+ }
+ numeric = 0;
+ }
+ return(fmtbasell(ll,numeric, numeric&&numeric!=10));
+ }
+done:
+#if (_AST_VERSION>=20030127L)
+ /*
+ * if NV_RAW flag is on, return pointer to binary data
+ * otherwise, base64 encode the data and return this string
+ */
+ if(up->cp && nv_isattr(np,NV_BINARY) && !nv_isattr(np,NV_RAW))
+ {
+ char *cp;
+ int size= nv_size(np), insize=(4*size)/3+size/45+8;
+ base64encode(up->cp, size, (void**)0, cp=getbuf(insize), insize, (void**)0);
+ return(cp);
+ }
+#endif
+ if((numeric=nv_size(np)) && up->cp && up->cp[numeric])
+ {
+ char *cp = getbuf(numeric+1);
+ memcpy(cp,up->cp,numeric);
+ cp[numeric]=0;
+ return(cp);
+ }
+ return ((char*)up->cp);
+}
+
+Sfdouble_t nv_getnum(register Namval_t *np)
+{
+ register union Value *up;
+ register Sfdouble_t r=0;
+ register char *str;
+#if SHOPT_OPTIMIZE
+ if(!nv_local && sh.argaddr)
+ nv_optimize(np);
+#endif /* SHOPT_OPTIMIZE */
+ if(nv_istable(np))
+ errormsg(SH_DICT,ERROR_exit(1),e_number,nv_name(np));
+ if(np->nvfun)
+ {
+ if(!nv_local)
+ {
+ nv_local=1;
+ return(nv_getn(np, np->nvfun));
+ }
+ nv_local=0;
+ }
+ if(nv_isattr (np, NV_INTEGER))
+ {
+ up= &np->nvalue;
+ if(!up->lp)
+ r = 0;
+ else if(nv_isattr(np, NV_DOUBLE))
+ {
+ if(nv_isattr(np, NV_LONG))
+ r = *up->ldp;
+ else
+ r = *up->dp;
+ }
+ else if(nv_isattr(np, NV_UNSIGN))
+ {
+ if(nv_isattr(np, NV_LONG))
+ r = (Sflong_t)*((Sfulong_t*)up->llp);
+ else if(nv_isattr(np, NV_SHORT))
+ r = (Sflong_t)((uint16_t)up->s);
+ else
+ r = *((uint32_t*)up->lp);
+ }
+ else
+ {
+ if(nv_isattr(np, NV_LONG))
+ r = *up->llp;
+ else if(nv_isattr(np, NV_SHORT))
+ r = up->s;
+ else
+ r = *up->lp;
+ }
+ }
+ else if((str=nv_getval(np)) && *str!=0)
+ {
+ if(np->nvfun || nv_isattr(np,NV_LJUST|NV_RJUST|NV_ZFILL))
+ {
+ while(*str=='0')
+ str++;
+ }
+ r = sh_arith(str);
+ }
+ return(r);
+}
+/*
+ * Give <np> the attributes <newatts,> and change its current
+ * value to conform to <newatts>. The <size> of left and right
+ * justified fields may be given.
+ */
+void nv_newattr (register Namval_t *np, unsigned newatts, int size)
+{
+ register char *sp;
+ register char *cp = 0;
+ register unsigned int n;
+ Namarr_t *ap = 0;
+ int oldsize,oldatts;
+
+ /* check for restrictions */
+ if(sh_isoption(SH_RESTRICTED) && ((sp=nv_name(np))==nv_name(PATHNOD) || sp==nv_name(SHELLNOD) || sp==nv_name(ENVNOD) || sp==nv_name(FPATHNOD)))
+ errormsg(SH_DICT,ERROR_exit(1),e_restricted,nv_name(np));
+ /* handle attributes that do not change data separately */
+ n = np->nvflag;
+#if SHOPT_BSH
+ if(newatts&NV_EXPORT)
+ nv_offattr(np,NV_IMPORT);
+#endif /* SHOPT_BSH */
+ if(((n^newatts)&NV_EXPORT))
+ {
+ /* record changes to the environment */
+ if(n&NV_EXPORT)
+ env_delete(sh.env,nv_name(np));
+ else
+ sh_envput(sh.env,np);
+ }
+ if((size==0||(n&NV_INTEGER)) && ((n^newatts)&~NV_NOCHANGE)==0)
+ {
+ if(size)
+ nv_setsize(np,size);
+ nv_offattr(np, ~NV_NOFREE);
+ nv_onattr(np, newatts);
+ return;
+ }
+ /* for an array, change all the elements */
+ if((ap=nv_arrayptr(np)) && ap->nelem>0)
+ nv_putsub(np,NIL(char*),ARRAY_SCAN);
+ oldsize = nv_size(np);
+ oldatts = np->nvflag;
+ if(ap) /* add element to prevent array deletion */
+ ap->nelem++;
+ do
+ {
+ nv_setsize(np,oldsize);
+ np->nvflag = oldatts;
+ if (sp = nv_getval(np))
+ {
+ if(nv_isattr(np,NV_ZFILL))
+ while(*sp=='0') sp++;
+ cp = (char*)malloc((n=strlen (sp)) + 1);
+ strcpy(cp, sp);
+ if(ap)
+ {
+ Namval_t *mp;
+ ap->nelem &= ~ARRAY_SCAN;
+ if(mp=nv_opensub(np))
+ nv_onattr(mp,NV_NOFREE);
+ }
+ nv_unset(np);
+ if(ap)
+ ap->nelem |= ARRAY_SCAN;
+ if(size==0 && (newatts&(NV_LJUST|NV_RJUST|NV_ZFILL)))
+ size = n;
+ }
+ else
+ nv_unset(np);
+ nv_setsize(np,size);
+ np->nvflag &= NV_ARRAY;
+ np->nvflag |= newatts;
+ if (cp)
+ {
+ nv_putval (np, cp, NV_RDONLY);
+ free(cp);
+ }
+ }
+ while(ap && nv_nextsub(np));
+ if(ap)
+ ap->nelem--;
+ return;
+}
+
+#ifndef _NEXT_SOURCE
+static char *oldgetenv(const char *string)
+{
+ register char c0,c1;
+ register const char *cp, *sp;
+ register char **av = environ;
+ if(!string || (c0= *string)==0)
+ return(0);
+ if((c1=*++string)==0)
+ c1= '=';
+ while(cp = *av++)
+ {
+ if(cp[0]!=c0 || cp[1]!=c1)
+ continue;
+ sp = string;
+ while(*sp && *sp++ == *++cp);
+ if(*sp==0 && *++cp=='=')
+ return((char*)(cp+1));
+ }
+ return(0);
+}
+
+/*
+ * This version of getenv uses the hash storage to access environment values
+ */
+char *getenv(const char *name)
+/*@
+ assume name!=0;
+@*/
+{
+ register Namval_t *np;
+ if(!sh.var_tree)
+ return(oldgetenv(name));
+ if((np = nv_search(name,sh.var_tree,0)) && nv_isattr(np,NV_EXPORT))
+ return(nv_getval(np));
+ if(name[0] == 'P' && name[1] == 'A' && name[2] == 'T' && name[3] == 'H' && name[4] == 0)
+ return(oldgetenv(name));
+ return(0);
+}
+#endif /* _NEXT_SOURCE */
+
+#undef putenv
+/*
+ * This version of putenv uses the hash storage to assign environment values
+ */
+int putenv(const char *name)
+{
+ register Namval_t *np;
+ if(name)
+ {
+ np = nv_open(name,sh.var_tree,NV_EXPORT|NV_IDENT|NV_NOARRAY|NV_ASSIGN);
+ if(!strchr(name,'='))
+ nv_unset(np);
+ }
+ return(0);
+}
+
+
+/*
+ * Override libast setenv()
+ */
+char* setenviron(const char *name)
+{
+ register Namval_t *np;
+ if(name)
+ {
+ np = nv_open(name,sh.var_tree,NV_EXPORT|NV_IDENT|NV_NOARRAY|NV_ASSIGN);
+ if(strchr(name,'='))
+ return(nv_getval(np));
+ nv_unset(np);
+ }
+ return("");
+}
+
+/*
+ * copy <str1> to <str2> changing lower case to upper case
+ * <str2> must be big enough to hold <str1>
+ * <str1> and <str2> may point to the same place.
+ */
+
+static void ltou(register char const *str1,register char *str2)
+/*@
+ assume str1!=0 && str2!=0;
+ return x satisfying strlen(in str1)==strlen(in str2);
+@*/
+{
+ register int c;
+ for(; c= *((unsigned char*)str1); str1++,str2++)
+ {
+ if(islower(c))
+ *str2 = toupper(c);
+ else
+ *str2 = c;
+ }
+ *str2 = 0;
+}
+
+/*
+ * normalize <cp> and return pointer to subscript if any
+ */
+static char *lastdot(register char *cp)
+{
+ register char *dp=cp, *ep=0;
+ register int c;
+ while(c= *cp++)
+ {
+ *dp++ = c;
+ if(c=='[')
+ ep = cp;
+ else if(c=='.')
+ {
+ if(*cp=='[')
+ {
+ ep = nv_endsubscript((Namval_t*)0,cp,0);
+ c = ep-cp;
+ memcpy(dp,cp,c);
+ dp = sh_checkid(dp+1,dp+c);
+ cp = ep;
+ }
+ ep = 0;
+ }
+ }
+ *dp = 0;
+ return(ep);
+}
+
+/*
+ * Create a reference node from <np> to $np in dictionary <hp>
+ */
+void nv_setref(register Namval_t *np, Dt_t *hp, int flags)
+{
+ register Namval_t *nq, *nr;
+ register char *ep,*cp;
+ if(nv_isref(np))
+ return;
+ if(nv_isarray(np))
+ errormsg(SH_DICT,ERROR_exit(1),e_badref,nv_name(np));
+ if(!(cp=nv_getval(np)))
+ errormsg(SH_DICT,ERROR_exit(1),e_noref,nv_name(np));
+ if((ep = lastdot(cp)) && nv_isattr(np,NV_MINIMAL))
+ errormsg(SH_DICT,ERROR_exit(1),e_badref,nv_name(np));
+ if(!hp)
+ hp = sh.var_tree;
+ nr= nq = nv_open(cp, hp, flags|NV_NOREF);
+ while(nv_isref(nr))
+ {
+ sh.last_table = nv_reftable(nr);
+ hp = nv_reftree(nr);
+ nr = nv_refnode(nr);
+ }
+ if(nr==np)
+ {
+ if(sh.namespace && nv_dict(sh.namespace)==hp)
+ errormsg(SH_DICT,ERROR_exit(1),e_selfref,nv_name(np));
+ /* bind to earlier scope, or add to global scope */
+ if(!(hp=dtvnext(hp)) || (nq=nv_search((char*)np,hp,NV_ADD|HASH_BUCKET))==np)
+ errormsg(SH_DICT,ERROR_exit(1),e_selfref,nv_name(np));
+ }
+ if(ep)
+ {
+ /* cause subscript evaluation and return result */
+#if 0
+ nv_endsubscript(nq,ep,NV_ADD);
+#endif
+ ep = nv_getsub(nq);
+ }
+ nv_unset(np);
+ np->nvalue.nrp = newof(0,struct Namref,1,0);
+ np->nvalue.nrp->np = nq;
+ np->nvalue.nrp->root = hp;
+ if(ep)
+ np->nvalue.nrp->sub = strdup(ep);
+ np->nvalue.nrp->table = sh.last_table;
+ nv_onattr(np,NV_REF|NV_NOFREE);
+}
+
+/*
+ * get the scope corresponding to <index>
+ * whence uses the same values as lseeek()
+ */
+Shscope_t *sh_getscope(int index, int whence)
+{
+ register struct sh_scoped *sp, *topmost;
+ if(whence==SEEK_CUR)
+ sp = &sh.st;
+ else
+ {
+ if ((struct sh_scoped*)sh.topscope != sh.st.self)
+ topmost = (struct sh_scoped*)sh.topscope;
+ else
+ topmost = &(sh.st);
+ sp = topmost;
+ if(whence==SEEK_SET)
+ {
+ int n =0;
+ while(sp = sp->prevst)
+ n++;
+ index = n - index;
+ sp = topmost;
+ }
+ }
+ if(index < 0)
+ return((Shscope_t*)0);
+ while(index-- && (sp = sp->prevst));
+ return((Shscope_t*)sp);
+}
+
+/*
+ * make <scoped> the top scope and return previous scope
+ */
+Shscope_t *sh_setscope(Shscope_t *scope)
+{
+ Shscope_t *old = (Shscope_t*)sh.st.self;
+ *sh.st.self = sh.st;
+ sh.st = *((struct sh_scoped*)scope);
+ sh.var_tree = scope->var_tree;
+ return(old);
+}
+
+void nv_unscope(void)
+{
+ register Dt_t *root = sh.var_tree;
+ register Dt_t *dp = dtview(root,(Dt_t*)0);
+ table_unset(root,NV_RDONLY|NV_NOSCOPE,dp);
+ sh.var_tree=dp;
+ dtclose(root);
+}
+
+/*
+ * The inverse of creating a reference node
+ */
+void nv_unref(register Namval_t *np)
+{
+ Namval_t *nq;
+ if(!nv_isref(np))
+ return;
+ nq = nv_refnode(np);
+ nv_offattr(np,NV_NOFREE|NV_REF);
+ free((void*)np->nvalue.nrp);
+ np->nvalue.cp = strdup(nv_name(nq));
+#if SHOPT_OPTIMIZE
+ {
+ Namfun_t *fp;
+ for(fp=nq->nvfun; fp; fp = fp->next)
+ {
+ if(fp->disc== &optimize_disc)
+ {
+ optimize_clear(nq,fp);
+ return;
+ }
+ }
+ }
+#endif
+}
+
+/*
+ * These following are for binary compatibility with the old hash library
+ * They will be removed someday
+ */
+
+#if defined(__IMPORT__) && defined(__EXPORT__)
+# define extern __EXPORT__
+#endif
+
+#undef hashscope
+
+extern Dt_t *hashscope(Dt_t *root)
+{
+ return(dtvnext(root));
+}
+
+#undef hashfree
+
+extern Dt_t *hashfree(Dt_t *root)
+{
+ Dt_t *dp = dtvnext(root);
+ dtclose(root);
+ return(dp);
+}
+
+#undef hashname
+
+extern char *hashname(void *obj)
+{
+ Namval_t *np = (Namval_t*)obj;
+ return(np->nvname);
+}
+
+#undef hashlook
+
+extern void *hashlook(Dt_t *root, const char *name, int mode,int size)
+{
+ NOT_USED(size);
+ return((void*)nv_search(name,root,mode));
+}
+
+char *nv_name(register Namval_t *np)
+{
+ register Namval_t *table;
+ register Namfun_t *fp;
+ char *cp;
+ if(is_abuiltin(np) || is_afunction(np))
+ return(np->nvname);
+ if(nv_istable(np))
+#if 1
+ sh.last_table = nv_parent(np);
+#else
+ sh.last_table = nv_create(np,0, NV_LAST,(Namfun_t*)0);
+#endif
+ else if(!nv_isref(np))
+ {
+ for(fp= np->nvfun ; fp; fp=fp->next)
+ if(fp->disc && fp->disc->namef)
+ {
+ if(np==sh.last_table)
+ sh.last_table = 0;
+ return((*fp->disc->namef)(np,fp));
+ }
+ }
+ if(!(table=sh.last_table) || *np->nvname=='.' || table==sh.namespace || np==table)
+ return(np->nvname);
+ cp = nv_name(table);
+ sfprintf(sh.strbuf,"%s.%s",cp,np->nvname);
+ return(sfstruse(sh.strbuf));
+}
+
+Namval_t *nv_lastdict(void)
+{
+ return(sh.last_table);
+}
+
+#undef nv_context
+/*
+ * returns the data context for a builtin
+ */
+void *nv_context(Namval_t *np)
+{
+ return((void*)np->nvfun);
+}
+
+#define DISABLE /* proto workaround */
+
+int nv_isnull DISABLE (register Namval_t *np)
+{
+ return(nv_isnull(np));
+}
+
+#undef nv_setsize
+int nv_setsize(register Namval_t *np, int size)
+{
+ int oldsize = nv_size(np);
+ if(size>=0)
+ np->nvsize = size;
+ return(oldsize);
+}
diff --git a/usr/src/lib/libshell/common/sh/nvdisc.c b/usr/src/lib/libshell/common/sh/nvdisc.c
new file mode 100644
index 0000000000..533f5f7f5c
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/nvdisc.c
@@ -0,0 +1,1263 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * AT&T Labs
+ *
+ */
+
+#include "defs.h"
+#include "variables.h"
+#include "builtins.h"
+#include "path.h"
+
+static const char *discnames[] = { "get", "set", "append", "unset", 0 };
+
+int nv_compare(Dt_t* dict, Void_t *sp, Void_t *dp, Dtdisc_t *disc)
+{
+ if(sp==dp)
+ return(0);
+ return(strcmp((char*)sp,(char*)dp));
+}
+
+/*
+ * call the next getval function in the chain
+ */
+char *nv_getv(Namval_t *np, register Namfun_t *nfp)
+{
+ register Namfun_t *fp;
+ register char *cp;
+ if((fp = nfp) != NIL(Namfun_t*) && !nv_local)
+ fp = nfp = nfp->next;
+ nv_local=0;
+ for(; fp; fp=fp->next)
+ {
+ if(!fp->disc || (!fp->disc->getnum && !fp->disc->getval))
+ continue;
+ if(!nv_isattr(np,NV_NODISC) || fp==(Namfun_t*)nv_arrayptr(np))
+ break;
+ }
+ if(fp && fp->disc->getval)
+ cp = (*fp->disc->getval)(np,fp);
+ else if(fp && fp->disc->getnum)
+ {
+ sfprintf(sh.strbuf,"%.*Lg",12,(*fp->disc->getnum)(np,fp));
+ cp = sfstruse(sh.strbuf);
+ }
+ else
+ {
+ nv_local=1;
+ cp = nv_getval(np);
+ }
+ return(cp);
+}
+
+/*
+ * call the next getnum function in the chain
+ */
+Sfdouble_t nv_getn(Namval_t *np, register Namfun_t *nfp)
+{
+ register Namfun_t *fp;
+ register Sfdouble_t d=0;
+ char *str;
+ if((fp = nfp) != NIL(Namfun_t*) && !nv_local)
+ fp = nfp = nfp->next;
+ nv_local=0;
+ for(; fp; fp=fp->next)
+ {
+ if(!fp->disc->getnum && !fp->disc->getval)
+ continue;
+ if(!fp->disc->getnum && nv_isattr(np,NV_INTEGER))
+ continue;
+ if(!nv_isattr(np,NV_NODISC) || fp==(Namfun_t*)nv_arrayptr(np))
+ break;
+ }
+ if(fp && fp->disc->getnum)
+ d = (*fp->disc->getnum)(np,fp);
+ else if(nv_isattr(np,NV_INTEGER))
+ {
+ nv_local = 1;
+ d = nv_getnum(np);
+ }
+ else
+ {
+ if(fp && fp->disc->getval)
+ str = (*fp->disc->getval)(np,fp);
+ else
+ str = nv_getv(np,fp?fp:nfp);
+ if(str && *str)
+ {
+ while(*str=='0')
+ str++;
+ d = sh_arith(str);
+ }
+ }
+ return(d);
+}
+
+/*
+ * call the next assign function in the chain
+ */
+void nv_putv(Namval_t *np, const char *value, int flags, register Namfun_t *nfp)
+{
+ register Namfun_t *fp, *fpnext;
+ if((fp=nfp) != NIL(Namfun_t*) && !nv_local)
+ fp = nfp = nfp->next;
+ nv_local=0;
+ for(; fp; fp=fpnext)
+ {
+ fpnext = fp->next;
+ if(!fp->disc->putval)
+ {
+ if(!value)
+ {
+ nv_disc(np,fp,NV_POP);
+ if(!fp->nofree)
+ free((void*)fp);
+ }
+ continue;
+ }
+ if(!nv_isattr(np,NV_NODISC) || fp==(Namfun_t*)nv_arrayptr(np))
+ break;
+ }
+ if(fp && fp->disc->putval)
+ (*fp->disc->putval)(np,value, flags, fp);
+ else
+ {
+ nv_local=1;
+ if(value)
+ nv_putval(np, value, flags);
+ else
+ _nv_unset(np, flags&NV_RDONLY);
+ }
+}
+
+#if 0
+/*
+ * node creation discipline
+ */
+Namval_t *nv_create(register Namval_t* np,const char *name,int flag,register Namfun_t *fp)
+{
+ fp = fp?fp->next:np->nvfun;
+ while(fp && fp->disc && !fp->disc->createf)
+ fp = fp->next;
+ if(fp && fp->disc->createf)
+ return((*fp->disc->createf)(np,name,flag,fp));
+ return(NIL(Namval_t*));
+}
+#endif
+
+#define LOOKUP 0
+#define ASSIGN 1
+#define APPEND 2
+#define UNASSIGN 3
+#define BLOCKED ((Namval_t*)&nv_local)
+
+struct vardisc
+{
+ Namfun_t fun;
+ Namval_t *disc[4];
+};
+
+struct blocked
+{
+ struct blocked *next;
+ Namval_t *np;
+ int flags;
+ void *sub;
+ int isub;
+};
+
+static struct blocked *blist;
+
+#define isblocked(bp,type) ((bp)->flags & (1<<(type)))
+#define block(bp,type) ((bp)->flags |= (1<<(type)))
+#define unblock(bp,type) ((bp)->flags &= ~(1<<(type)))
+
+/*
+ * returns pointer to blocking structure
+ */
+static struct blocked *block_info(Namval_t *np, struct blocked *pp)
+{
+ register struct blocked *bp;
+ void *sub=0;
+ int isub=0;
+ if(nv_isarray(np) && (isub=nv_aindex(np)) < 0)
+ sub = nv_associative(np,(const char*)0,NV_ACURRENT);
+ for(bp=blist ; bp; bp=bp->next)
+ {
+ if(bp->np==np && bp->sub==sub && bp->isub==isub)
+ return(bp);
+ }
+ if(pp)
+ {
+ pp->np = np;
+ pp->flags = 0;
+ pp->isub = isub;
+ pp->sub = sub;
+ pp->next = blist;
+ blist = pp;
+ }
+ return(pp);
+}
+
+static void block_done(struct blocked *bp)
+{
+ blist = bp = bp->next;
+ if(bp && (bp->isub>=0 || bp->sub))
+ nv_putsub(bp->np, bp->sub,(bp->isub<0?0:bp->isub)|ARRAY_SETSUB);
+}
+
+/*
+ * free discipline if no more discipline functions
+ */
+static void chktfree(register Namval_t *np, register struct vardisc *vp)
+{
+ register int n;
+ for(n=0; n< sizeof(vp->disc)/sizeof(*vp->disc); n++)
+ {
+ if(vp->disc[n])
+ break;
+ }
+ if(n>=sizeof(vp->disc)/sizeof(*vp->disc))
+ {
+ /* no disc left so pop */
+ Namfun_t *fp;
+ if((fp=nv_stack(np, NIL(Namfun_t*))) && !fp->nofree)
+ free((void*)fp);
+ }
+}
+
+/*
+ * This function performs an assignment disc on the given node <np>
+ */
+static void assign(Namval_t *np,const char* val,int flags,Namfun_t *handle)
+{
+ int type = (flags&NV_APPEND)?APPEND:ASSIGN;
+ register struct vardisc *vp = (struct vardisc*)handle;
+ register Namval_t *nq = vp->disc[type];
+ struct blocked block, *bp = block_info(np, &block);
+ Namval_t node;
+ if(val || isblocked(bp,type))
+ {
+ if(!nq || isblocked(bp,type))
+ {
+ nv_putv(np,val,flags,handle);
+ goto done;
+ }
+ node = *SH_VALNOD;
+ if(!nv_isnull(SH_VALNOD))
+ {
+ nv_onattr(SH_VALNOD,NV_NOFREE);
+ nv_unset(SH_VALNOD);
+ }
+ if(flags&NV_INTEGER)
+ nv_onattr(SH_VALNOD,(flags&(NV_INTEGER|NV_LONG|NV_DOUBLE|NV_EXPNOTE|NV_SHORT)));
+ nv_putval(SH_VALNOD, val, (flags&NV_INTEGER)?flags:NV_NOFREE);
+ }
+ else
+ nq = vp->disc[type=UNASSIGN];
+ if(nq && !isblocked(bp,type))
+ {
+ int bflag;
+ block(bp,type);
+ if (type==APPEND && (bflag= !isblocked(bp,LOOKUP)))
+ block(bp,LOOKUP);
+ sh_fun(nq,np,(char**)0);
+ unblock(bp,type);
+ if(bflag)
+ unblock(bp,LOOKUP);
+ if(!vp->disc[type])
+ chktfree(np,vp);
+ }
+ if(val)
+ {
+ register char *cp;
+ Sfdouble_t d;
+ if(nv_isnull(SH_VALNOD))
+ cp=0;
+ else if(flags&NV_INTEGER)
+ {
+ d = nv_getnum(SH_VALNOD);
+ cp = (char*)(&d);
+ flags |= (NV_LONG|NV_DOUBLE);
+ flags &= ~NV_SHORT;
+ }
+ else
+ cp = nv_getval(SH_VALNOD);
+ if(cp)
+ nv_putv(np,cp,flags|NV_RDONLY,handle);
+ nv_unset(SH_VALNOD);
+ /* restore everything but the nvlink field */
+ memcpy(&SH_VALNOD->nvname, &node.nvname, sizeof(node)-sizeof(node.nvlink));
+ }
+ else if(sh_isstate(SH_INIT))
+ {
+ /* don't free functions during reinitialization */
+ nv_putv(np,val,flags,handle);
+ }
+ else if(!nq || !isblocked(bp,type))
+ {
+ Dt_t *root = sh_subfuntree(1);
+ int n;
+ Namarr_t *ap;
+ block(bp,type);
+ nv_putv(np, val, flags, handle);
+ if(nv_isarray(np) && (ap=nv_arrayptr(np)) && ap->nelem>0)
+ goto done;
+ for(n=0; n < sizeof(vp->disc)/sizeof(*vp->disc); n++)
+ {
+ if((nq=vp->disc[n]) && !nv_isattr(nq,NV_NOFREE))
+ {
+ nv_unset(nq);
+ dtdelete(root,nq);
+ }
+ }
+ unblock(bp,type);
+ nv_disc(np,handle,NV_POP);
+ if(!handle->nofree)
+ free(handle);
+ }
+done:
+ if(bp== &block)
+ block_done(bp);
+}
+
+/*
+ * This function executes a lookup disc and then performs
+ * the lookup on the given node <np>
+ */
+static char* lookup(Namval_t *np, Namfun_t *handle)
+{
+ register struct vardisc *vp = (struct vardisc*)handle;
+ struct blocked block, *bp = block_info(np, &block);
+ register Namval_t *nq = vp->disc[LOOKUP];
+ register char *cp=0;
+ Namval_t node;
+ if(nq && !isblocked(bp,LOOKUP))
+ {
+ node = *SH_VALNOD;
+ if(!nv_isnull(SH_VALNOD))
+ {
+ nv_onattr(SH_VALNOD,NV_NOFREE);
+ nv_unset(SH_VALNOD);
+ }
+ block(bp,LOOKUP);
+ sh_fun(nq,np,(char**)0);
+ unblock(bp,LOOKUP);
+ if(!vp->disc[LOOKUP])
+ chktfree(np,vp);
+ cp = nv_getval(SH_VALNOD);
+ if(!nv_isnull(&node))
+ {
+ if(cp)
+ cp = strdup(cp);
+ /* restore everything but the nvlink field */
+ memcpy(&SH_VALNOD->nvname, &node.nvname, sizeof(node)-sizeof(node.nvlink));
+ }
+ }
+ if(!cp)
+ cp = nv_getv(np,handle);
+ if(bp== &block)
+ block_done(bp);
+ return(cp);
+}
+
+static const Namdisc_t shdisc =
+{
+ sizeof(struct vardisc),
+ assign,
+ lookup
+};
+
+/*
+ * Set disc on given <event> to <action>
+ * If action==np, the current disc is returned
+ * A null return value indicates that no <event> is known for <np>
+ * If <event> is NULL, then return the event name after <action>
+ * If <event> is NULL, and <action> is NULL, return the first event
+ */
+char *nv_setdisc(register Namval_t* np,register const char *event,Namval_t *action,register Namfun_t *fp)
+{
+ register struct vardisc *vp = (struct vardisc*)np->nvfun;
+ register int type;
+ char *empty = "";
+ if(np == (Namval_t*)fp)
+ {
+ register const char *name;
+ register int getname=0;
+ /* top level call, check for get/set */
+ if(!event)
+ {
+ if(!action)
+ return((char*)discnames[0]);
+ getname=1;
+ event = (char*)action;
+ }
+ for(type=0; name=discnames[type]; type++)
+ {
+ if(strcmp(event,name)==0)
+ break;
+ }
+ if(getname)
+ {
+ event = 0;
+ if(name && !(name = discnames[++type]))
+ action = 0;
+ }
+ if(!name)
+ {
+ if((fp=(Namfun_t*)vp) && fp->disc->setdisc)
+ return((*fp->disc->setdisc)(np,event,action,fp));
+ }
+ else if(getname)
+ return((char*)name);
+ }
+ if(!fp)
+ return(NIL(char*));
+ if(np != (Namval_t*)fp)
+ {
+ /* not the top level */
+ while(fp = fp->next)
+ {
+ if(fp->disc->setdisc)
+ return((*fp->disc->setdisc)(np,event,action,fp));
+ }
+ return(NIL(char*));
+ }
+ /* Handle GET/SET/APPEND/UNSET disc */
+ if(vp && vp->fun.disc->putval!=assign)
+ vp = 0;
+ if(!vp)
+ {
+ if(action==np)
+ return((char*)action);
+ if(!(vp = newof(NIL(struct vardisc*),struct vardisc,1,0)))
+ return(0);
+ vp->fun.disc = &shdisc;
+ nv_stack(np, (Namfun_t*)vp);
+ }
+ if(action==np)
+ {
+ action = vp->disc[type];
+ empty = 0;
+ }
+ else if(action)
+ vp->disc[type] = action;
+ else
+ {
+ struct blocked *bp;
+ action = vp->disc[type];
+ vp->disc[type] = 0;
+ if(!(bp=block_info(np,(struct blocked*)0)) || !isblocked(bp,UNASSIGN))
+ chktfree(np,vp);
+ }
+ return(action?(char*)action:empty);
+}
+
+
+/*
+ * Set disc on given <event> to <action>
+ * If action==np, the current disc is returned
+ * A null return value indicates that no <event> is known for <np>
+ * If <event> is NULL, then return the event name after <action>
+ * If <event> is NULL, and <action> is NULL, return the first event
+ */
+static char *setdisc(register Namval_t* np,register const char *event,Namval_t *action,register Namfun_t *fp)
+{
+ register Nambfun_t *vp = (Nambfun_t*)fp;
+ register int type,getname=0;
+ register const char *name;
+ const char **discnames = vp->bnames;
+ /* top level call, check for discipline match */
+ if(!event)
+ {
+ if(!action)
+ return((char*)discnames[0]);
+ getname=1;
+ event = (char*)action;
+ }
+ for(type=0; name=discnames[type]; type++)
+ {
+ if(strcmp(event,name)==0)
+ break;
+ }
+ if(getname)
+ {
+ event = 0;
+ if(name && !(name = discnames[++type]))
+ action = 0;
+ }
+ if(!name)
+ return(nv_setdisc(np,event,action,fp));
+ else if(getname)
+ return((char*)name);
+ /* Handle the disciplines */
+ if(action==np)
+ action = vp->bltins[type];
+ else if(action)
+ vp->bltins[type] = action;
+ else
+ {
+ action = vp->bltins[type];
+ vp->bltins[type] = 0;
+ }
+ return(action?(char*)action:"");
+}
+
+static void putdisc(Namval_t* np, const char* val, int flag, Namfun_t* fp)
+{
+ nv_putv(np,val,flag,fp);
+ if(!val)
+ {
+ register Nambfun_t *vp = (Nambfun_t*)fp;
+ register int i;
+ for(i=0; vp->bnames[i]; i++)
+ {
+ register Namval_t *mp;
+ if((mp=vp->bltins[i]) && !nv_isattr(mp,NV_NOFREE))
+ {
+ if(is_abuiltin(mp))
+ {
+ if(mp->nvfun && !nv_isattr(mp,NV_NOFREE))
+ free((void*)mp->nvfun);
+ dtdelete(sh.bltin_tree,mp);
+ free((void*)mp);
+ }
+ }
+ }
+ nv_disc(np,fp,NV_POP);
+ if(!fp->nofree)
+ free((void*)fp);
+
+ }
+}
+
+static const Namdisc_t Nv_bdisc = { 0, putdisc, 0, 0, setdisc };
+
+static Namfun_t *nv_clone_disc(register Namfun_t *fp)
+{
+ register Namfun_t *nfp;
+ register int size;
+ if(!(size=fp->dsize) && (!fp->disc || !(size=fp->disc->dsize)))
+ size = sizeof(Namfun_t);
+ if(!(nfp=newof(NIL(Namfun_t*),Namfun_t,1,size-sizeof(Namfun_t))))
+ return(0);
+ memcpy(nfp,fp,size);
+ nfp->nofree = 0;
+ return(nfp);
+}
+
+int nv_adddisc(Namval_t *np, const char **names, Namval_t **funs)
+{
+ register Nambfun_t *vp;
+ register int n=0;
+ register const char **av=names;
+ if(av)
+ {
+ while(*av++)
+ n++;
+ }
+ if(!(vp = newof(NIL(Nambfun_t*),Nambfun_t,1,n*sizeof(Namval_t*))))
+ return(0);
+ vp->fun.dsize = sizeof(Nambfun_t)+n*sizeof(Namval_t*);
+ vp->fun.funs = 1;
+ if(funs)
+ memcpy((void*)vp->bltins, (void*)funs,n*sizeof(Namval_t*));
+ else while(n>=0)
+ vp->bltins[n--] = 0;
+ vp->fun.disc = &Nv_bdisc;
+ vp->bnames = names;
+ nv_stack(np,&vp->fun);
+ return(1);
+}
+
+/*
+ * push, pop, clone, or reorder disciplines onto node <np>
+ * mode can be one of
+ * NV_FIRST: Move or push <fp> to top of the stack or delete top
+ * NV_LAST: Move or push <fp> to bottom of stack or delete last
+ * NV_POP: Delete <fp> from top of the stack
+ * NV_CLONE: Replace fp with a copy created my malloc() and return it
+ */
+Namfun_t *nv_disc(register Namval_t *np, register Namfun_t* fp, int mode)
+{
+ Namfun_t *lp, **lpp;
+ if(nv_isref(np))
+ return(0);
+ if(mode==NV_CLONE && !fp)
+ return(0);
+ if(fp)
+ {
+ if((lp=np->nvfun)==fp)
+ {
+ if(mode==NV_CLONE)
+ {
+ lp = nv_clone_disc(fp);
+ return(np->nvfun=lp);
+ }
+ if(mode==NV_FIRST || mode==0)
+ return(fp);
+ np->nvfun = lp->next;
+ if(mode==NV_POP)
+ return(fp);
+ }
+ /* see if <fp> is on the list already */
+ lpp = &np->nvfun;
+ if(lp)
+ {
+ while(lp->next)
+ {
+ if(lp->next==fp)
+ {
+ if(mode==NV_CLONE)
+ {
+ fp = nv_clone_disc(fp);
+ lp->next = fp;
+ return(fp);
+ }
+ lp->next = fp->next;
+ if(mode==NV_POP)
+ return(fp);
+ if(mode!=NV_LAST)
+ break;
+ }
+ lp = lp->next;
+ }
+ if(mode==NV_LAST)
+ lpp = &lp->next;
+ }
+ if(mode==NV_POP)
+ return(0);
+ /* push */
+ nv_offattr(np,NV_NODISC);
+ if(mode==NV_LAST)
+ fp->next = 0;
+ else
+ {
+ if(fp->nofree && *lpp)
+ fp = nv_clone_disc(fp);
+ fp->next = *lpp;
+ }
+ *lpp = fp;
+ }
+ else
+ {
+ if(mode==NV_FIRST)
+ return(np->nvfun);
+ else if(mode==NV_LAST)
+ for(lp=np->nvfun; lp; fp=lp,lp=lp->next);
+ else if(fp = np->nvfun)
+ np->nvfun = fp->next;
+ }
+ return(fp);
+}
+
+/*
+ * returns discipline pointer if discipline with specified functions
+ * is on the discipline stack
+ */
+Namfun_t *nv_hasdisc(Namval_t *np, const Namdisc_t *dp)
+{
+ register Namfun_t *fp;
+ for(fp=np->nvfun; fp; fp = fp->next)
+ {
+ if(fp->disc== dp)
+ return(fp);
+ }
+ return(0);
+}
+
+struct notify
+{
+ Namfun_t hdr;
+ char **ptr;
+};
+
+static void put_notify(Namval_t* np,const char *val,int flags,Namfun_t *fp)
+{
+ struct notify *pp = (struct notify*)fp;
+ nv_putv(np,val,flags,fp);
+ nv_stack(np,fp);
+ nv_stack(np,(Namfun_t*)0);
+ *pp->ptr = 0;
+ if(!fp->nofree)
+ free((void*)fp);
+}
+
+static const Namdisc_t notify_disc = { 0, put_notify };
+
+int nv_unsetnotify(Namval_t *np, char **addr)
+{
+ register Namfun_t *fp;
+ for(fp=np->nvfun;fp;fp=fp->next)
+ {
+ if(fp->disc->putval==put_notify && ((struct notify*)fp)->ptr==addr)
+ {
+ nv_stack(np,fp);
+ nv_stack(np,(Namfun_t*)0);
+ if(!fp->nofree)
+ free((void*)fp);
+ return(1);
+ }
+ }
+ return(0);
+}
+
+int nv_setnotify(Namval_t *np, char **addr)
+{
+ struct notify *pp = newof(0,struct notify, 1,0);
+ if(!pp)
+ return(0);
+ pp->ptr = addr;
+ pp->hdr.disc = &notify_disc;
+ nv_stack(np,&pp->hdr);
+ return(1);
+}
+
+static void *newnode(const char *name)
+{
+ register int s;
+ register Namval_t *np = newof(0,Namval_t,1,s=strlen(name)+1);
+ if(np)
+ {
+ np->nvname = (char*)np+sizeof(Namval_t);
+ memcpy(np->nvname,name,s);
+ }
+ return((void*)np);
+}
+
+#if SHOPT_NAMESPACE
+/*
+ * clone a numeric value
+ */
+static void *num_clone(register Namval_t *np, void *val)
+{
+ register int size;
+ void *nval;
+ if(!val)
+ return(0);
+ if(nv_isattr(np,NV_DOUBLE))
+ {
+ if(nv_isattr(np,NV_LONG))
+ size = sizeof(Sfdouble_t);
+ else if(nv_isattr(np,NV_SHORT))
+ size = sizeof(float);
+ else
+ size = sizeof(double);
+ }
+ else
+ {
+ if(nv_isattr(np,NV_LONG))
+ size = sizeof(Sflong_t);
+ else if(nv_isattr(np,NV_SHORT))
+ size = sizeof(int16_t);
+ else
+ size = sizeof(int32_t);
+ }
+ if(!(nval = malloc(size)))
+ return(0);
+ memcpy(nval,val,size);
+ return(nval);
+}
+
+static void clone_all_disc( Namval_t *np, Namval_t *mp, int flags)
+{
+ register Namfun_t *fp, **mfp = &mp->nvfun, *nfp;
+ for(fp=np->nvfun; fp;fp=fp->next)
+ {
+ if(fp->funs && (flags&NV_NODISC))
+ nfp = 0;
+ if(fp->disc && fp->disc->clonef)
+ nfp = (*fp->disc->clonef)(np,mp,flags,fp);
+ else
+ nfp = nv_clone_disc(fp);
+ if(!nfp)
+ continue;
+ nfp->next = 0;
+ *mfp = nfp;
+ mfp = &nfp->next;
+ }
+}
+
+/*
+ * clone <mp> from <np> flags can be one of the following
+ * NV_APPEND - append <np> onto <mp>
+ * NV_MOVE - move <np> to <mp>
+ * NV_NOFREE - mark the new node as nofree
+ * NV_NODISC - discplines with funs non-zero will not be copied
+ */
+int nv_clone(Namval_t *np, Namval_t *mp, int flags)
+{
+ Namfun_t *fp;
+ if(fp=np->nvfun)
+ {
+ if(flags&NV_MOVE)
+ {
+ mp->nvfun = fp;
+ goto skip;
+ }
+ clone_all_disc(np, mp, flags);
+ }
+ if(flags&NV_APPEND)
+ return(1);
+skip:
+ nv_setsize(mp,nv_size(np));
+ if(!nv_isattr(mp,NV_MINIMAL) || nv_isattr(mp,NV_EXPORT))
+ mp->nvenv = (!nv_isattr(np,NV_MINIMAL)||nv_isattr(np,NV_EXPORT))?np->nvenv:0;
+ mp->nvalue.cp = np->nvalue.cp;
+ mp->nvflag = np->nvflag;
+ if(flags&NV_MOVE)
+ {
+ np->nvfun = 0;
+ np->nvalue.cp = 0;
+ if(!nv_isattr(np,NV_MINIMAL) || nv_isattr(mp,NV_EXPORT))
+ np->nvenv = 0;
+ np->nvflag = 0;
+ nv_setsize(np,0);
+ return(1);
+ }
+ if(nv_isattr(np,NV_INTEGER))
+ mp->nvalue.ip = (int*)num_clone(np,(void*)np->nvalue.ip);
+ else if(flags&NV_NOFREE)
+ nv_onattr(np,NV_NOFREE);
+ return(1);
+}
+
+/*
+ * The following discipline is for copy-on-write semantics
+ */
+static char* clone_getv(Namval_t *np, Namfun_t *handle)
+{
+ return(np->nvalue.np?nv_getval(np->nvalue.np):0);
+}
+
+static Sfdouble_t clone_getn(Namval_t *np, Namfun_t *handle)
+{
+ return(np->nvalue.np?nv_getnum(np->nvalue.np):0);
+}
+
+static void clone_putv(Namval_t *np,const char* val,int flags,Namfun_t *handle)
+{
+ Namfun_t *dp = nv_stack(np,(Namfun_t*)0);
+ Namval_t *mp = np->nvalue.np;
+ if(!sh.subshell)
+ free((void*)dp);
+ if(val)
+ nv_clone(mp,np,NV_NOFREE);
+ np->nvalue.cp = 0;
+ nv_putval(np,val,flags);
+}
+
+static const Namdisc_t clone_disc =
+{
+ 0,
+ clone_putv,
+ clone_getv,
+ clone_getn
+};
+
+Namval_t *nv_mkclone(Namval_t *mp)
+{
+ Namval_t *np;
+ Namfun_t *dp;
+ np = newof(0,Namval_t,1,0);
+ np->nvflag = mp->nvflag;
+ np->nvsize = mp->nvsize;
+ np->nvname = mp->nvname;
+ np->nvalue.np = mp;
+ np->nvflag = mp->nvflag;
+ dp = newof(0,Namfun_t,1,0);
+ dp->disc = &clone_disc;
+ nv_stack(np,dp);
+ dtinsert(nv_dict(sh.namespace),np);
+ return(np);
+}
+#endif /* SHOPT_NAMESPACE */
+
+Namval_t *nv_search(const char *name, Dt_t *root, int mode)
+{
+ register Namval_t *np;
+ register Dt_t *dp = 0;
+ if(mode&HASH_NOSCOPE)
+ dp = dtview(root,0);
+ if(mode&HASH_BUCKET)
+ {
+ Namval_t *mp = (void*)name;
+ if(!(np = dtsearch(root,mp)) && (mode&NV_ADD))
+ name = nv_name(mp);
+ }
+ else
+ {
+ if(*name=='.' && root==sh.var_tree)
+ root = sh.var_base;
+ np = dtmatch(root,(void*)name);
+ }
+ if(!np && (mode&NV_ADD))
+ {
+
+ if(sh.namespace && !(mode&HASH_NOSCOPE) && root==sh.var_tree)
+ root = nv_dict(sh.namespace);
+ else if(!dp && !(mode&HASH_NOSCOPE))
+ {
+ register Dt_t *next;
+ while(next=dtvnext(root))
+ root = next;
+ }
+ np = (Namval_t*)dtinsert(root,newnode(name));
+ }
+ if(dp)
+ dtview(root,dp);
+ return(np);
+}
+
+/*
+ * finds function or builtin for given name and the discipline variable
+ * if var!=0 the variable pointer is returned and the built-in name
+ * is put onto the stack at the current offset.
+ * otherwise, a pointer to the builtin (variable or type) is returned
+ * and var contains the poiner to the variable
+ * if last==0 and first component of name is a reference, nv_bfsearch()
+ will return 0.
+ */
+Namval_t *nv_bfsearch(const char *name, Dt_t *root, Namval_t **var, char **last)
+{
+ int offset = staktell();
+ register char *sp, *cp=0;
+ Namval_t *np, *nq;
+ if(var)
+ *var = 0;
+ /* check for . in the name before = */
+ for(sp=(char*)name+1; *sp; sp++)
+ {
+ if(*sp=='=')
+ return(0);
+ if(*sp=='.')
+ cp = sp;
+ }
+ if(!cp)
+ return(var?nv_search(name,root,0):0);
+ stakputs(name);
+ stakputc(0);
+ cp = stakptr(offset) + (cp-name);
+ if(last)
+ *last = cp;
+ *cp = 0;
+ nq=nv_open(stakptr(offset),0,NV_VARNAME|NV_NOASSIGN|NV_NOADD|NV_NOFAIL);
+ *cp = '.';
+ if(!nq)
+ {
+ np = 0;
+ goto done;
+ }
+ if(!var)
+ {
+ np = nq;
+ goto done;
+ }
+ *var = nq;
+ return((Namval_t*)nv_setdisc(nq,cp+1,nq,(Namfun_t*)nq));
+done:
+ stakseek(offset);
+ return(np);
+}
+
+/*
+ * add or replace built-in version of command commresponding to <path>
+ * The <bltin> argument is a pointer to the built-in
+ * if <extra>==1, the built-in will be deleted
+ * Special builtins cannot be added or deleted return failure
+ * The return value for adding builtins is a pointer to the node or NULL on
+ * failure. For delete NULL means success and the node that cannot be
+ * deleted is returned on failure.
+ */
+Namval_t *sh_addbuiltin(const char *path, int (*bltin)(int, char*[],void*),void *extra)
+{
+ register const char *name = path_basename(path);
+ char *cp;
+ register Namval_t *np, *nq=0;
+ int offset = staktell();
+ if(name==path && (nq=nv_bfsearch(name,sh.bltin_tree,(Namval_t**)0,&cp)))
+ path = name = stakptr(offset);
+ if(np = nv_search(path,sh.bltin_tree,0))
+ {
+ /* exists without a path */
+ if(extra == (void*)1)
+ {
+ if(np->nvfun && !nv_isattr(np,NV_NOFREE))
+ free((void*)np->nvfun);
+ dtdelete(sh.bltin_tree,np);
+ return(0);
+ }
+ if(!bltin)
+ return(np);
+ }
+ else for(np=(Namval_t*)dtfirst(sh.bltin_tree);np;np=(Namval_t*)dtnext(sh.bltin_tree,np))
+ {
+ if(strcmp(name,path_basename(nv_name(np))))
+ continue;
+ /* exists probably with different path so delete it */
+ if(strcmp(path,nv_name(np)))
+ {
+ if(nv_isattr(np,BLT_SPC))
+ return(np);
+ if(!bltin)
+ bltin = np->nvalue.bfp;
+ if(np->nvenv)
+ dtdelete(sh.bltin_tree,np);
+ if(extra == (void*)1)
+ return(0);
+ np = 0;
+ }
+ break;
+ }
+ if(!np && !(np = nv_search(path,sh.bltin_tree,bltin?NV_ADD:0)))
+ return(0);
+ if(nv_isattr(np,BLT_SPC))
+ return(np);
+ np->nvenv = 0;
+ np->nvfun = 0;
+ nv_setattr(np,0);
+ if(bltin)
+ {
+ np->nvalue.bfp = bltin;
+ nv_onattr(np,NV_BLTIN|NV_NOFREE);
+ np->nvfun = (Namfun_t*)extra;
+ }
+ if(nq)
+ {
+ cp=nv_setdisc(nq,cp+1,np,(Namfun_t*)nq);
+ nv_close(nq);
+ if(!cp)
+ errormsg(SH_DICT,ERROR_exit(1),e_baddisc,name);
+ }
+ if(extra == (void*)1)
+ return(0);
+ return(np);
+}
+
+#undef nv_stack
+extern Namfun_t *nv_stack(register Namval_t *np, register Namfun_t* fp)
+{
+ return(nv_disc(np,fp,0));
+}
+
+struct table
+{
+ Namfun_t fun;
+ Namval_t *parent;
+ Shell_t *shp;
+ Dt_t *dict;
+};
+
+Namval_t *nv_parent(Namval_t *np)
+{
+ if(!nv_istable(np))
+ return(0);
+ return(((struct table*)(np->nvfun))->parent);
+}
+
+static Namval_t *next_table(register Namval_t* np, Dt_t *root,Namfun_t *fp)
+{
+ struct table *tp = (struct table *)fp;
+ if(root)
+ return((Namval_t*)dtnext(root,np));
+ else
+ return((Namval_t*)dtfirst(tp->dict));
+}
+
+static Namval_t *create_table(Namval_t *np,const char *name,int flags,Namfun_t *fp)
+{
+ struct table *tp = (struct table *)fp;
+ tp->shp->last_table = np;
+ return(nv_create(name, tp->dict, flags, fp));
+}
+
+static Namfun_t *clone_table(Namval_t* np, Namval_t *mp, int flags, Namfun_t *fp)
+{
+ struct table *tp = (struct table*)fp;
+ struct table *ntp = (struct table*)nv_clone_disc(fp);
+ Dt_t *oroot=tp->dict,*nroot=dtopen(&_Nvdisc,Dtoset);
+ if(!nroot)
+ return(0);
+ memcpy((void*)ntp,(void*)fp,sizeof(struct table));
+ ntp->dict = nroot;
+ ntp->parent = nv_lastdict();
+ for(np=(Namval_t*)dtfirst(oroot);np;np=(Namval_t*)dtnext(oroot,np))
+ {
+ mp = (Namval_t*)dtinsert(nroot,newnode(np->nvname));
+ nv_clone(np,mp,flags);
+ }
+ return(&ntp->fun);
+}
+
+static void put_table(register Namval_t* np, const char* val, int flags, Namfun_t* fp)
+{
+ register Dt_t *root = ((struct table*)fp)->dict;
+ register Namval_t *nq, *mp;
+ Namarr_t *ap;
+ nv_putv(np,val,flags,fp);
+ if(val)
+ return;
+ if(nv_isarray(np) && (ap=nv_arrayptr(np)) && array_elem(ap))
+ return;
+ for(mp=(Namval_t*)dtfirst(root);mp;mp=nq)
+ {
+ _nv_unset(mp,flags);
+ nq = (Namval_t*)dtnext(root,mp);
+ dtdelete(root,mp);
+ free((void*)mp);
+ }
+ dtclose(root);
+ if(!fp->nofree)
+ free((void*)fp);
+}
+
+/*
+ * return space separated list of names of variables in given tree
+ */
+static char *get_table(Namval_t *np, Namfun_t *fp)
+{
+ register Dt_t *root = ((struct table*)fp)->dict;
+ static Sfio_t *out;
+ register int first=1;
+ register Dt_t *base = dtview(root,0);
+ if(out)
+ sfseek(out,(Sfoff_t)0,SEEK_SET);
+ else
+ out = sfnew((Sfio_t*)0,(char*)0,-1,-1,SF_WRITE|SF_STRING);
+ for(np=(Namval_t*)dtfirst(root);np;np=(Namval_t*)dtnext(root,np))
+ {
+ if(!nv_isnull(np) || np->nvfun || nv_isattr(np,~NV_NOFREE))
+ {
+ if(!first)
+ sfputc(out,' ');
+ else
+ first = 0;
+ sfputr(out,np->nvname,-1);
+ }
+ }
+ sfputc(out,0);
+ if(base)
+ dtview(root,base);
+ return((char*)out->_data);
+}
+
+static const Namdisc_t table_disc =
+{
+ sizeof(struct table),
+ put_table,
+ get_table,
+ 0,
+ 0,
+ create_table,
+ clone_table,
+ 0,
+ next_table,
+};
+
+Dt_t *nv_dict(Namval_t* np)
+{
+ struct table *tp = (struct table*)nv_hasdisc(np,&table_disc);
+ if(tp)
+ return(tp->dict);
+ np = sh.last_table;
+ while(np)
+ {
+ if(tp = (struct table*)nv_hasdisc(np,&table_disc))
+ return(tp->dict);
+#if 0
+ np = nv_create(np,(const char*)0, NV_FIRST, (Namfun_t*)0);
+#endif
+ }
+ return(sh.var_tree);
+}
+
+/*
+ * create a mountable name-value pair tree
+ */
+Namval_t *nv_mount(Namval_t *np, const char *name, Dt_t *dict)
+{
+ Namval_t *mp, *pp=0;
+ struct table *tp = newof((struct table*)0, struct table,1,0);
+ if(name)
+ {
+ if(nv_istable(np))
+ pp = np;
+ else
+ pp = nv_lastdict();
+ }
+ if(!(tp = newof((struct table*)0, struct table,1,0)))
+ return(0);
+ if(name)
+ {
+ Namfun_t *fp = pp->nvfun;
+ mp = (*fp->disc->createf)(pp,name,0,fp);
+ }
+ else
+ mp = np;
+ if(!nv_isnull(mp))
+ nv_unset(mp);
+ tp->shp = sh_getinterp();
+ tp->dict = dict;
+ tp->parent = pp;
+ tp->fun.disc = &table_disc;
+ nv_onattr(mp,NV_TABLE);
+ nv_disc(mp, &tp->fun, NV_LAST);
+ return(mp);
+}
+
+const Namdisc_t *nv_discfun(int which)
+{
+ switch(which)
+ {
+ case NV_DCADD:
+ return(&Nv_bdisc);
+ case NV_DCRESTRICT:
+ return(&RESTRICTED_disc);
+ }
+ return(0);
+}
+
+/*
+ * This function turns variable <np> to the type <tp>
+ */
+int nv_settype(Namval_t* np, Namval_t *tp, int flags)
+{
+ int isnull = nv_isnull(np);
+ char *val=0;
+ if(isnull)
+ flags &= ~NV_APPEND;
+ else
+ {
+ val = strdup(nv_getval(np));
+ if(!(flags&NV_APPEND))
+ _nv_unset(np, NV_RDONLY);
+ }
+ if(!nv_clone(tp,np,flags|NV_NOFREE))
+ return(0);
+ if(val)
+ {
+ nv_putval(np,val,NV_RDONLY);
+ free((void*)val);
+ }
+ return(0);
+}
+
diff --git a/usr/src/lib/libshell/common/sh/nvtree.c b/usr/src/lib/libshell/common/sh/nvtree.c
new file mode 100644
index 0000000000..82657e3a0c
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/nvtree.c
@@ -0,0 +1,679 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * code for tree nodes and name walking
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#include "defs.h"
+#include "name.h"
+#include "argnod.h"
+
+struct nvdir
+{
+ Dt_t *root;
+ Namval_t *hp;
+ Namval_t *table;
+ Namval_t *(*nextnode)(Namval_t*,Dt_t*,Namfun_t*);
+ Namfun_t *fun;
+ struct nvdir *prev;
+ int len;
+ int offset;
+ char data[1];
+};
+
+char *nv_getvtree(Namval_t*, Namfun_t *);
+static void put_tree(Namval_t*, const char*, int,Namfun_t*);
+
+static Namval_t *create_tree(Namval_t *np,const char *name,int flag,Namfun_t *dp)
+{
+ register Namfun_t *fp=dp;
+ while(fp=fp->next)
+ {
+ if(fp->disc && fp->disc->createf)
+ {
+ if(np=(*fp->disc->createf)(np,name,flag,fp))
+ dp->last = fp->last;
+ return(np);
+ }
+ }
+ return((flag&NV_NOADD)?0:np);
+}
+
+static const Namdisc_t treedisc =
+{
+ 0,
+ put_tree,
+ nv_getvtree,
+ 0,
+ 0,
+ create_tree
+};
+
+static char *nextdot(const char *str)
+{
+ register char *cp;
+ if(*str=='.')
+ str++;
+ if(*str =='[')
+ {
+ cp = nv_endsubscript((Namval_t*)0,(char*)str,0);
+ return(*cp=='.'?cp:0);
+ }
+ else
+ return(strchr(str,'.'));
+}
+
+static Namfun_t *nextdisc(Namval_t *np)
+{
+ register Namfun_t *fp;
+ if(nv_isref(np))
+ return(0);
+ for(fp=np->nvfun;fp;fp=fp->next)
+ {
+ if(fp && fp->disc && fp->disc->nextf)
+ return(fp);
+ }
+ return(0);
+}
+
+void *nv_diropen(const char *name)
+{
+ char *next,*last;
+ int c,len=strlen(name);
+ struct nvdir *save, *dp = new_of(struct nvdir,len);
+ Namval_t *np, fake;
+ Namfun_t *nfp;
+ if(!dp)
+ return(0);
+ memset((void*)dp, 0, sizeof(*dp));
+ last=dp->data;
+ if(name[len-1]=='*' || name[len-1]=='@')
+ len -= 1;
+ name = memcpy(last,name,len);
+ last[len] = 0;
+ dp->len = len;
+ dp->root = sh.var_tree;
+ dp->table = sh.last_table;
+ if(*name)
+ {
+ fake.nvname = (char*)name;
+ dp->hp = (Namval_t*)dtprev(dp->root,&fake);
+ dp->hp = (Namval_t*)dtnext(dp->root,dp->hp);
+ }
+ else
+ dp->hp = (Namval_t*)dtfirst(dp->root);
+ while(next= nextdot(last))
+ {
+ c = *next;
+ *next = 0;
+ np = nv_search(last,dp->root,0);
+ *next = c;
+ if(np && ((nfp=nextdisc(np)) || nv_istable(np)))
+ {
+ if(!(save = new_of(struct nvdir,0)))
+ return(0);
+ *save = *dp;
+ dp->prev = save;
+ if(nv_istable(np))
+ dp->root = nv_dict(np);
+ else
+ dp->root = (Dt_t*)dp;
+ dp->offset = last-(char*)name;
+ if(dp->offset<len)
+ dp->len = len-dp->offset;
+ else
+ dp->len = 0;
+ if(nfp)
+ {
+ dp->nextnode = nfp->disc->nextf;
+ dp->table = np;
+ dp->fun = nfp;
+ dp->hp = (*dp->nextnode)(np,(Dt_t*)0,nfp);
+ }
+ else
+ dp->nextnode = 0;
+ }
+ else
+ break;
+ last = next+1;
+ }
+ return((void*)dp);
+}
+
+
+static Namval_t *nextnode(struct nvdir *dp)
+{
+ if(dp->nextnode)
+ return((*dp->nextnode)(dp->hp,dp->root,dp->fun));
+ if(dp->len && memcmp(dp->data, dp->hp->nvname, dp->len))
+ return(0);
+ return((Namval_t*)dtnext(dp->root,dp->hp));
+}
+
+char *nv_dirnext(void *dir)
+{
+ register struct nvdir *save, *dp = (struct nvdir*)dir;
+ register Namval_t *np, *last_table;
+ register char *cp;
+ Namfun_t *nfp;
+ while(1)
+ {
+ while(np=dp->hp)
+ {
+ dp->hp = nextnode(dp);
+ if(nv_isnull(np))
+ continue;
+ last_table = sh.last_table;
+ sh.last_table = dp->table;
+ cp = nv_name(np);
+ sh.last_table = last_table;
+ if(!dp->len || memcmp(cp+dp->offset,dp->data,dp->len)==0)
+ {
+ if((nfp=nextdisc(np)) || nv_istable(np))
+ {
+ Dt_t *root;
+ if(nv_istable(np))
+ root = nv_dict(np);
+ else
+ root = (Dt_t*)dp;
+ /* check for recursive walk */
+ for(save=dp; save; save=save->prev)
+ {
+ if(save->root==root)
+ break;
+ }
+ if(save)
+ continue;
+ if(!(save = new_of(struct nvdir,0)))
+ return(0);
+ *save = *dp;
+ dp->prev = save;
+ dp->root = root;
+ dp->len = 0;
+ if(nfp && np->nvfun)
+ {
+ dp->nextnode = nfp->disc->nextf;
+ dp->table = np;
+ dp->fun = nfp;
+ dp->hp = (*dp->nextnode)(np,(Dt_t*)0,nfp);
+ }
+ else
+ dp->nextnode = 0;
+ }
+ return(cp);
+ }
+ }
+ if(!(save=dp->prev))
+ break;
+#if 0
+ sh.last_table = dp->table;
+#endif
+ *dp = *save;
+ free((void*)save);
+ }
+ return(0);
+}
+
+void nv_dirclose(void *dir)
+{
+ struct nvdir *dp = (struct nvdir*)dir;
+ if(dp->prev)
+ nv_dirclose((void*)dp->prev);
+ free(dir);
+}
+
+static void outtype(Namval_t *np, Namfun_t *fp, Sfio_t* out, const char *prefix)
+{
+ char *type=0;
+ Namval_t *tp = fp->type;
+ if(!tp && fp->disc && fp->disc->typef)
+ tp = (*fp->disc->typef)(np,fp);
+ for(fp=fp->next;fp;fp=fp->next)
+ {
+ if(fp->type || (fp->disc && fp->disc->typef &&(*fp->disc->typef)(np,fp)))
+ {
+ outtype(np,fp,out,prefix);
+ break;
+ }
+ }
+ if(prefix && *prefix=='t')
+ type = "-T";
+ else if(!prefix)
+ type = "type";
+ if(type)
+ sfprintf(out,"%s %s ",type,tp->nvname);
+}
+
+/*
+ * print the attributes of name value pair give by <np>
+ */
+void nv_attribute(register Namval_t *np,Sfio_t *out,char *prefix,int noname)
+{
+ register const Shtable_t *tp;
+ register char *cp;
+ register unsigned val;
+ register unsigned mask;
+ register unsigned attr;
+ Namfun_t *fp=0;
+ for(fp=np->nvfun;fp;fp=fp->next)
+ {
+ if(fp->type || (fp->disc && fp->disc->typef &&(*fp->disc->typef)(np,fp)))
+ break;
+ }
+#if 0
+ if(!fp && !nv_isattr(np,~NV_ARRAY))
+ {
+ if(!nv_isattr(np,NV_ARRAY) || nv_aindex(np)>=0)
+ return;
+ }
+#else
+ if(!fp && !nv_isattr(np,~NV_MINIMAL))
+ return;
+#endif
+
+ if ((attr=nv_isattr(np,~NV_NOFREE)) || fp)
+ {
+ if((attr&NV_NOPRINT)==NV_NOPRINT)
+ attr &= ~NV_NOPRINT;
+ if(!attr && !fp)
+ return;
+ if(prefix)
+ sfputr(out,prefix,' ');
+ for(tp = shtab_attributes; *tp->sh_name;tp++)
+ {
+ val = tp->sh_number;
+ mask = val;
+ if(fp && (val&NV_INTEGER))
+ break;
+ /*
+ * the following test is needed to prevent variables
+ * with E attribute from being given the F
+ * attribute as well
+ */
+ if(val==(NV_INTEGER|NV_DOUBLE) && (attr&NV_EXPNOTE))
+ continue;
+ if(val&NV_INTEGER)
+ mask |= NV_DOUBLE;
+ else if(val&NV_HOST)
+ mask = NV_HOST;
+ if((attr&mask)==val)
+ {
+ if(val==NV_ARRAY)
+ {
+ Namarr_t *ap = nv_arrayptr(np);
+ if(array_assoc(ap))
+ {
+ if(tp->sh_name[1]!='A')
+ continue;
+ }
+ else if(tp->sh_name[1]=='A')
+ continue;
+#if 0
+ cp = "associative";
+ else
+ cp = "indexed";
+ if(!prefix)
+ sfputr(out,cp,' ');
+ else if(*cp=='i')
+ tp++;
+#endif
+ }
+ if(prefix)
+ {
+ if(*tp->sh_name=='-')
+ sfprintf(out,"%.2s ",tp->sh_name);
+ }
+ else
+ sfputr(out,tp->sh_name+2,' ');
+ if ((val&(NV_LJUST|NV_RJUST|NV_ZFILL)) && !(val&NV_INTEGER) && val!=NV_HOST)
+ sfprintf(out,"%d ",nv_size(np));
+ }
+ if(val==NV_INTEGER && nv_isattr(np,NV_INTEGER))
+ {
+ if(nv_size(np) != 10)
+ {
+ if(nv_isattr(np, NV_DOUBLE))
+ cp = "precision";
+ else
+ cp = "base";
+ if(!prefix)
+ sfputr(out,cp,' ');
+ sfprintf(out,"%d ",nv_size(np));
+ }
+ break;
+ }
+ }
+ if(fp)
+ outtype(np,fp,out,prefix);
+ if(noname)
+ return;
+ sfputr(out,nv_name(np),'\n');
+ }
+}
+
+struct Walk
+{
+ Sfio_t *out;
+ Dt_t *root;
+ int noscope;
+ int indent;
+};
+
+static void outval(char *name, const char *vname, struct Walk *wp)
+{
+ register Namval_t *np, *nq;
+ register Namfun_t *fp;
+ int isarray=0, associative=0, special=0;
+ if(!(np=nv_open(vname,wp->root,NV_ARRAY|NV_VARNAME|NV_NOADD|NV_NOASSIGN|wp->noscope)))
+ return;
+ if(nv_isarray(np) && *name=='.')
+ special = 1;
+ if(!special && (fp=nv_hasdisc(np,&treedisc)))
+ {
+ if(!wp->out)
+ {
+ fp = nv_stack(np,fp);
+ if(fp = nv_stack(np,NIL(Namfun_t*)))
+ free((void*)fp);
+ np->nvfun = 0;
+ }
+ return;
+ }
+ if(nv_isnull(np))
+ return;
+ if(special || nv_isarray(np))
+ {
+ isarray=1;
+ associative= nv_aindex(np)<0;
+ if(array_elem(nv_arrayptr(np))==0)
+ isarray=2;
+ else
+ nq = nv_putsub(np,NIL(char*),ARRAY_SCAN|(wp->out?ARRAY_NOCHILD:0));
+ }
+ if(!wp->out)
+ {
+ _nv_unset(np,NV_RDONLY);
+ nv_close(np);
+ return;
+ }
+ if(isarray==1 && !nq)
+ return;
+ if(special)
+ {
+ associative = 1;
+ sfnputc(wp->out,'\t',wp->indent);
+ }
+ else
+ {
+ sfnputc(wp->out,'\t',wp->indent);
+ nv_attribute(np,wp->out,"typeset",'=');
+ nv_outname(wp->out,name,-1);
+ sfputc(wp->out,(isarray==2?'\n':'='));
+ if(isarray)
+ {
+ if(isarray==2)
+ return;
+ sfwrite(wp->out,"(\n",2);
+ sfnputc(wp->out,'\t',++wp->indent);
+ }
+ }
+ while(1)
+ {
+ char *fmtq,*ep;
+ if(isarray && associative)
+ {
+ if(!(fmtq = nv_getsub(np)))
+ break;
+ sfprintf(wp->out,"[%s]",sh_fmtq(fmtq));
+ sfputc(wp->out,'=');
+ }
+ if(!(fmtq = sh_fmtq(nv_getval(np))))
+ fmtq = "";
+ else if(!associative && (ep=strchr(fmtq,'=')))
+ {
+ char *qp = strchr(fmtq,'\'');
+ if(!qp || qp>ep)
+ {
+ sfwrite(wp->out,fmtq,ep-fmtq);
+ sfputc(wp->out,'\\');
+ fmtq = ep;
+ }
+ }
+ if(*name=='[' && !isarray)
+ sfprintf(wp->out,"(%s)\n",fmtq);
+ else
+ sfputr(wp->out,fmtq,'\n');
+ if(!nv_nextsub(np))
+ break;
+ sfnputc(wp->out,'\t',wp->indent);
+ }
+ if(isarray && !special)
+ {
+ sfnputc(wp->out,'\t',--wp->indent);
+ sfwrite(wp->out,")\n",2);
+ }
+}
+
+/*
+ * format initialization list given a list of assignments <argp>
+ */
+static char **genvalue(char **argv, const char *prefix, int n, struct Walk *wp)
+{
+ register char *cp,*nextcp,*arg;
+ register int m,r;
+ register Sfio_t *outfile = wp->out;
+ if(n==0)
+ m = strlen(prefix);
+ else if(cp=nextdot(prefix))
+ m = cp-prefix;
+ else
+ m = strlen(prefix)-1;
+ m++;
+ if(outfile)
+ {
+ sfwrite(outfile,"(\n",2);
+ wp->indent++;
+ }
+ for(; arg= *argv; argv++)
+ {
+ cp = arg + n;
+ if(n==0 && cp[m-1]!='.')
+ continue;
+ if(n && cp[m-1]==0)
+ break;
+ if(n==0 || strncmp(arg,prefix-n,m+n)==0)
+ {
+ cp +=m;
+ r = 0;
+ if(*cp=='.')
+ cp++,r++;
+ if(nextcp=nextdot(cp))
+ {
+ if(outfile)
+ {
+ sfnputc(outfile,'\t',wp->indent);
+ nv_outname(outfile,cp,nextcp-cp);
+ sfputc(outfile,'=');
+ }
+ argv = genvalue(argv,cp,n+m+r,wp);
+ if(outfile)
+ sfputc(outfile,'\n');
+ if(*argv)
+ continue;
+ break;
+ }
+ else if(outfile && argv[1] && memcmp(arg,argv[1],r=strlen(arg))==0 && argv[1][r]=='[')
+ {
+ Namval_t *np = nv_open(arg,wp->root,NV_VARNAME|NV_NOADD|NV_NOASSIGN|wp->noscope);
+ if(!np)
+ continue;
+ sfnputc(outfile,'\t',wp->indent);
+ nv_attribute(np,outfile,"typeset",1);
+ nv_close(np);
+ sfputr(outfile,arg+m+(n?n+1:0),'=');
+ argv = genvalue(++argv,cp,cp-arg ,wp);
+ sfputc(outfile,'\n');
+ }
+ else if(outfile && *cp=='[')
+ {
+ sfnputc(outfile,'\t',wp->indent);
+ sfputr(outfile,cp,'=');
+ argv = genvalue(++argv,cp,cp-arg ,wp);
+ sfputc(outfile,'\n');
+ }
+ else
+ outval(cp,arg,wp);
+ }
+ else
+ break;
+ }
+ if(outfile)
+ {
+ int c = prefix[m-1];
+ cp = (char*)prefix;
+ if(c=='.')
+ cp[m-1] = 0;
+ outval(".",prefix-n,wp);
+ if(c=='.')
+ cp[m-1] = c;
+ sfnputc(outfile,'\t',wp->indent-1);
+ sfputc(outfile,')');
+ }
+ return(--argv);
+}
+
+/*
+ * walk the virtual tree and print or delete name-value pairs
+ */
+static char *walk_tree(register Namval_t *np, int dlete)
+{
+ static Sfio_t *out;
+ struct Walk walk;
+ Sfio_t *outfile;
+ int savtop = staktell();
+ char *savptr = stakfreeze(0);
+ register struct argnod *ap=0;
+ struct argnod *arglist=0;
+ char *name,*cp, **argv;
+ char *subscript=0;
+ void *dir;
+ int n=0, noscope=(dlete&NV_NOSCOPE);
+ stakputs(nv_name(np));
+ if(subscript = nv_getsub(np))
+ {
+ stakputc('[');
+ stakputs(subscript);
+ stakputc(']');
+ stakputc('.');
+ }
+ name = stakfreeze(1);
+ dir = nv_diropen(name);
+ if(subscript)
+ name[strlen(name)-1] = 0;
+ while(cp = nv_dirnext(dir))
+ {
+ stakseek(ARGVAL);
+ stakputs(cp);
+ ap = (struct argnod*)stakfreeze(1);
+ ap->argflag = ARG_RAW;
+ ap->argchn.ap = arglist;
+ n++;
+ arglist = ap;
+ }
+ argv = (char**)stakalloc((n+1)*sizeof(char*));
+ argv += n;
+ *argv = 0;
+ for(; ap; ap=ap->argchn.ap)
+ *--argv = ap->argval;
+ nv_dirclose(dir);
+ if(dlete&1)
+ outfile = 0;
+ else if(!(outfile=out))
+ outfile = out = sfnew((Sfio_t*)0,(char*)0,-1,-1,SF_WRITE|SF_STRING);
+ else
+ sfseek(outfile,0L,SEEK_SET);
+ walk.out = outfile;
+ walk.root = sh.last_root;
+ walk.indent = 0;
+ walk.noscope = noscope;
+ genvalue(argv,name,0,&walk);
+ stakset(savptr,savtop);
+ if(!outfile)
+ return((char*)0);
+ sfputc(out,0);
+ return((char*)out->_data);
+}
+
+/*
+ * get discipline for compound initializations
+ */
+char *nv_getvtree(register Namval_t *np, Namfun_t *fp)
+{
+ NOT_USED(fp);
+ if(nv_isattr(np,NV_BINARY) && nv_isattr(np,NV_RAW))
+ return(nv_getv(np,fp));
+ if(nv_isattr(np,NV_ARRAY) && nv_arraychild(np,(Namval_t*)0,0)==np)
+ return(nv_getv(np,fp));
+ return(walk_tree(np,0));
+}
+
+/*
+ * put discipline for compound initializations
+ */
+static void put_tree(register Namval_t *np, const char *val, int flags,Namfun_t *fp)
+{
+ struct Namarray *ap;
+ int nleft = 0;
+ if(!nv_isattr(np,NV_INTEGER))
+ walk_tree(np,(flags&NV_NOSCOPE)|1);
+ nv_putv(np, val, flags,fp);
+ if(nv_isattr(np,NV_INTEGER))
+ return;
+ if(ap= nv_arrayptr(np))
+ nleft = array_elem(ap);
+ if(nleft==0)
+ {
+ fp = nv_stack(np,fp);
+ if(fp = nv_stack(np,NIL(Namfun_t*)))
+ {
+ free((void*)fp);
+ }
+ }
+}
+
+/*
+ * Insert discipline to cause $x to print current tree
+ */
+void nv_setvtree(register Namval_t *np)
+{
+ register Namfun_t *nfp;
+ if(nv_hasdisc(np, &treedisc))
+ return;
+ nfp = newof(NIL(void*),Namfun_t,1,0);
+ nfp->disc = &treedisc;
+ nv_stack(np, nfp);
+}
+
diff --git a/usr/src/lib/libshell/common/sh/parse.c b/usr/src/lib/libshell/common/sh/parse.c
new file mode 100644
index 0000000000..1cacd79e57
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/parse.c
@@ -0,0 +1,1757 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * UNIX shell
+ *
+ * S. R. Bourne
+ * Rewritten by David Korn
+ * AT&T Labs
+ *
+ * This is the parser for a shell language
+ */
+
+#if KSHELL
+#include "defs.h"
+#else
+#include <shell.h>
+#endif
+#include <ctype.h>
+#include <fcin.h>
+#include <error.h>
+#include "shlex.h"
+#include "history.h"
+#include "builtins.h"
+#include "test.h"
+#include "history.h"
+
+#define HERE_MEM 1024 /* size of here-docs kept in memory */
+
+#define hash nvlink.hl._hash
+
+/* These routines are local to this module */
+
+static Shnode_t *makeparent(int, Shnode_t*);
+static Shnode_t *makelist(int, Shnode_t*, Shnode_t*);
+static struct argnod *qscan(struct comnod*, int);
+static struct ionod *inout(struct ionod*, int);
+static Shnode_t *sh_cmd(int,int);
+static Shnode_t *term(int);
+static Shnode_t *list(int);
+static struct regnod *syncase(int);
+static Shnode_t *item(int);
+static Shnode_t *simple(int, struct ionod*);
+static int skipnl(int);
+static Shnode_t *test_expr(int);
+static Shnode_t *test_and(void);
+static Shnode_t *test_or(void);
+static Shnode_t *test_primary(void);
+
+#define sh_getlineno() (shlex.lastline)
+
+#ifndef NIL
+# define NIL(type) ((type)0)
+#endif /* NIL */
+#define CNTL(x) ((x)&037)
+
+
+#if !KSHELL
+static struct stdata
+{
+ struct slnod *staklist;
+ int cmdline;
+} st;
+#endif
+
+static int loop_level;
+static struct argnod *label_list;
+static struct argnod *label_last;
+
+#define getnode(type) ((Shnode_t*)stakalloc(sizeof(struct type)))
+
+#if SHOPT_KIA
+#include "path.h"
+/*
+ * write out entities for each item in the list
+ * type=='V' for variable assignment lists
+ * Otherwise type is determined by the command */
+static unsigned long writedefs(struct argnod *arglist, int line, int type, struct argnod *cmd)
+{
+ register struct argnod *argp = arglist;
+ register char *cp;
+ register int n,eline;
+ int width=0;
+ unsigned long r=0;
+ static char atbuff[20];
+ int justify=0;
+ char *attribute = atbuff;
+ unsigned long parent=shlex.script;
+ if(type==0)
+ {
+ parent = shlex.current;
+ type = 'v';
+ switch(*argp->argval)
+ {
+ case 'a':
+ type='p';
+ justify = 'a';
+ break;
+ case 'e':
+ *attribute++ = 'x';
+ break;
+ case 'r':
+ *attribute++ = 'r';
+ break;
+ case 'l':
+ break;
+ }
+ while(argp = argp->argnxt.ap)
+ {
+ if((n= *(cp=argp->argval))!='-' && n!='+')
+ break;
+ if(cp[1]==n)
+ break;
+ while((n= *++cp))
+ {
+ if(isdigit(n))
+ width = 10*width + n-'0';
+ else if(n=='L' || n=='R' || n =='Z')
+ justify=n;
+ else
+ *attribute++ = n;
+ }
+ }
+ }
+ else if(cmd)
+ parent=kiaentity(sh_argstr(cmd),-1,'p',-1,-1,shlex.unknown,'b',0,"");
+ *attribute = 0;
+ while(argp)
+ {
+ if((cp=strchr(argp->argval,'='))||(cp=strchr(argp->argval,'?')))
+ n = cp-argp->argval;
+ else
+ n = strlen(argp->argval);
+ eline = sh.inlineno-(shlex.token==NL);
+ r=kiaentity(argp->argval,n,type,line,eline,parent,justify,width,atbuff);
+ sfprintf(shlex.kiatmp,"p;%..64d;v;%..64d;%d;%d;s;\n",shlex.current,r,line,eline);
+ argp = argp->argnxt.ap;
+ }
+ return(r);
+}
+#endif /* SHOPT_KIA */
+/*
+ * Make a parent node for fork() or io-redirection
+ */
+static Shnode_t *makeparent(int flag, Shnode_t *child)
+{
+ register Shnode_t *par = getnode(forknod);
+ par->fork.forktyp = flag;
+ par->fork.forktre = child;
+ par->fork.forkio = 0;
+ par->fork.forkline = sh_getlineno()-1;
+ return(par);
+}
+
+static Shnode_t *getanode(struct argnod *ap)
+{
+ register Shnode_t *t = getnode(arithnod);
+ t->ar.artyp = TARITH;
+ t->ar.arline = sh_getlineno();
+ t->ar.arexpr = ap;
+ if(ap->argflag&ARG_RAW)
+ t->ar.arcomp = sh_arithcomp(ap->argval);
+ else
+ t->ar.arcomp = 0;
+ return(t);
+}
+
+/*
+ * Make a node corresponding to a command list
+ */
+static Shnode_t *makelist(int type, Shnode_t *l, Shnode_t *r)
+{
+ register Shnode_t *t;
+ if(!l || !r)
+ sh_syntax();
+ else
+ {
+ if((type&COMMSK) == TTST)
+ t = getnode(tstnod);
+ else
+ t = getnode(lstnod);
+ t->lst.lsttyp = type;
+ t->lst.lstlef = l;
+ t->lst.lstrit = r;
+ }
+ return(t);
+}
+
+/*
+ * entry to shell parser
+ * Flag can be the union of SH_EOF|SH_NL
+ */
+
+void *sh_parse(Shell_t *shp, Sfio_t *iop, int flag)
+{
+ register Shnode_t *t;
+ Fcin_t sav_input;
+ struct argnod *sav_arg = shlex.arg;
+ int sav_prompt = shp->nextprompt;
+ if(shp->binscript && sffileno(iop)==shp->infd)
+ return((void*)sh_trestore(iop));
+ fcsave(&sav_input);
+ shp->st.staklist = 0;
+ shlex.heredoc = 0;
+ shlex.inlineno = shp->inlineno;
+ shlex.firstline = shp->st.firstline;
+ shp->nextprompt = 1;
+ loop_level = 0;
+ label_list = label_last = 0;
+ if(sh_isoption(SH_INTERACTIVE))
+ sh_onstate(SH_INTERACTIVE);
+ if(sh_isoption(SH_VERBOSE))
+ sh_onstate(SH_VERBOSE);
+ sh_lexopen((Lex_t*)shp->lex_context,shp,0);
+ if(fcfopen(iop) < 0)
+ return(NIL(void*));
+ if(fcfile())
+ {
+ char *cp = fcfirst();
+ if( cp[0]==CNTL('k') && cp[1]==CNTL('s') && cp[2]==CNTL('h') && cp[3]==0)
+ {
+ int version;
+ fcseek(4);
+ fcgetc(version);
+ fcclose();
+ fcrestore(&sav_input);
+ shlex.arg = sav_arg;
+ if(version > 3)
+ errormsg(SH_DICT,ERROR_exit(1),e_lexversion);
+ if(sffileno(iop)==shp->infd)
+ shp->binscript = 1;
+ sfgetc(iop);
+ return((void*)sh_trestore(iop));
+ }
+ }
+ if((flag&SH_NL) && (shp->inlineno=error_info.line+shp->st.firstline)==0)
+ shp->inlineno=1;
+#if KSHELL
+ shp->nextprompt = 2;
+#endif
+ t = sh_cmd((flag&SH_EOF)?EOFSYM:'\n',SH_SEMI|SH_EMPTY|(flag&SH_NL));
+ fcclose();
+ fcrestore(&sav_input);
+ shlex.arg = sav_arg;
+ /* unstack any completed alias expansions */
+ if((sfset(iop,0,0)&SF_STRING) && !sfreserve(iop,0,-1))
+ {
+ Sfio_t *sp = sfstack(iop,NULL);
+ if(sp)
+ sfclose(sp);
+ }
+ shp->nextprompt = sav_prompt;
+ if(flag&SH_NL)
+ {
+ shp->st.firstline = shlex.firstline;
+ shp->inlineno = shlex.inlineno;
+ }
+ stakseek(0);
+ return((void*)t);
+}
+
+/*
+ * This routine parses up the matching right parenthesis and returns
+ * the parse tree
+ */
+Shnode_t *sh_dolparen(void)
+{
+ register Shnode_t *t=0;
+ register Lex_t *lp = (Lex_t*)sh.lex_context;
+ Sfio_t *sp = fcfile();
+ int line = sh.inlineno;
+ sh.inlineno = error_info.line+sh.st.firstline;
+ sh_lexopen(lp,&sh,1);
+ shlex.comsub = 1;
+ switch(sh_lex())
+ {
+ /* ((...)) arithmetic expression */
+ case EXPRSYM:
+ t = getanode(shlex.arg);
+ break;
+ case LPAREN:
+ t = sh_cmd(RPAREN,SH_NL|SH_EMPTY);
+ break;
+ }
+ shlex.comsub = 0;
+ if(!sp && (sp=fcfile()))
+ {
+ /*
+ * This code handles the case where string has been converted
+ * to a file by an alias setup
+ */
+ register int c;
+ char *cp;
+ if(fcgetc(c) > 0)
+ fcseek(-1);
+ cp = fcseek(0);
+ fcclose();
+ fcsopen(cp);
+ sfclose(sp);
+ }
+ sh.inlineno = line;
+ return(t);
+}
+
+/*
+ * remove temporary files and stacks
+ */
+
+void sh_freeup(void)
+{
+ if(sh.st.staklist)
+ sh_funstaks(sh.st.staklist,-1);
+ sh.st.staklist = 0;
+}
+
+/*
+ * increase reference count for each stack in function list when flag>0
+ * decrease reference count for each stack in function list when flag<=0
+ * stack is freed when reference count is zero
+ */
+
+void sh_funstaks(register struct slnod *slp,int flag)
+{
+ register struct slnod *slpold;
+ while(slpold=slp)
+ {
+ if(slp->slchild)
+ sh_funstaks(slp->slchild,flag);
+ slp = slp->slnext;
+ if(flag<=0)
+ stakdelete(slpold->slptr);
+ else
+ staklink(slpold->slptr);
+ }
+}
+/*
+ * cmd
+ * empty
+ * list
+ * list & [ cmd ]
+ * list [ ; cmd ]
+ */
+
+static Shnode_t *sh_cmd(register int sym, int flag)
+{
+ register Shnode_t *left, *right;
+ register int type = FINT|FAMP;
+ if(sym==NL)
+ shlex.lasttok = 0;
+ left = list(flag);
+ if(shlex.token==NL)
+ {
+ if(flag&SH_NL)
+ shlex.token=';';
+ }
+ else if(!left && !(flag&SH_EMPTY))
+ sh_syntax();
+ switch(shlex.token)
+ {
+ case COOPSYM: /* set up a cooperating process */
+ type |= (FPIN|FPOU|FPCL|FCOOP);
+ /* FALL THRU */
+ case '&':
+ if(left)
+ {
+ /* (...)& -> {...;} & */
+ if(left->tre.tretyp==TPAR)
+ left = left->par.partre;
+ left = makeparent(TFORK|type, left);
+ }
+ /* FALL THRU */
+ case ';':
+ if(!left)
+ sh_syntax();
+ if(right=sh_cmd(sym,flag|SH_EMPTY))
+ left=makelist(TLST, left, right);
+ break;
+ case EOFSYM:
+ if(sym==NL)
+ break;
+ default:
+ if(sym && sym!=shlex.token)
+ {
+ if(sym!=ELSESYM || (shlex.token!=ELIFSYM && shlex.token!=FISYM))
+ sh_syntax();
+ }
+ }
+ return(left);
+}
+
+/*
+ * list
+ * term
+ * list && term
+ * list || term
+ * unfortunately, these are equal precedence
+ */
+static Shnode_t *list(register int flag)
+{
+ register Shnode_t *t = term(flag);
+ register int token;
+ while(t && ((token=shlex.token)==ANDFSYM || token==ORFSYM))
+ t = makelist((token==ANDFSYM?TAND:TORF), t, term(SH_NL|SH_SEMI));
+ return(t);
+}
+
+/*
+ * term
+ * item
+ * item | term
+ */
+static Shnode_t *term(register int flag)
+{
+ register Shnode_t *t;
+ register int token;
+ if(flag&SH_NL)
+ token = skipnl(flag);
+ else
+ token = sh_lex();
+ /* check to see if pipeline is to be timed */
+ if(token==TIMESYM || token==NOTSYM)
+ {
+ t = getnode(parnod);
+ t->par.partyp=TTIME;
+ if(shlex.token==NOTSYM)
+ t->par.partyp |= COMSCAN;
+ t->par.partre = term(0);
+ }
+ else if((t=item(SH_NL|SH_EMPTY|(flag&SH_SEMI))) && shlex.token=='|')
+ {
+ register Shnode_t *tt;
+ int showme = t->tre.tretyp&FSHOWME;
+ t = makeparent(TFORK|FPOU,t);
+ if(tt=term(SH_NL))
+ {
+ switch(tt->tre.tretyp&COMMSK)
+ {
+ case TFORK:
+ tt->tre.tretyp |= FPIN|FPCL;
+ break;
+ case TFIL:
+ tt->lst.lstlef->tre.tretyp |= FPIN|FPCL;
+ break;
+ default:
+ tt= makeparent(TSETIO|FPIN|FPCL,tt);
+ }
+ t=makelist(TFIL,t,tt);
+ t->tre.tretyp |= showme;
+ }
+ else if(shlex.token)
+ sh_syntax();
+ }
+ return(t);
+}
+
+/*
+ * case statement
+ */
+static struct regnod* syncase(register int esym)
+{
+ register int tok = skipnl(0);
+ register struct regnod *r;
+ if(tok==esym)
+ return(NIL(struct regnod*));
+ r = (struct regnod*)stakalloc(sizeof(struct regnod));
+ r->regptr=0;
+ r->regflag=0;
+ if(tok==LPAREN)
+ skipnl(0);
+ while(1)
+ {
+ if(!shlex.arg)
+ sh_syntax();
+ shlex.arg->argnxt.ap=r->regptr;
+ r->regptr = shlex.arg;
+ if((tok=sh_lex())==RPAREN)
+ break;
+ else if(tok=='|')
+ sh_lex();
+ else
+ sh_syntax();
+ }
+ r->regcom=sh_cmd(0,SH_NL|SH_EMPTY|SH_SEMI);
+ if((tok=shlex.token)==BREAKCASESYM)
+ r->regnxt=syncase(esym);
+ else if(tok==FALLTHRUSYM)
+ {
+ r->regflag++;
+ r->regnxt=syncase(esym);
+ }
+ else
+ {
+ if(tok!=esym && tok!=EOFSYM)
+ sh_syntax();
+ r->regnxt=0;
+ }
+ if(shlex.token==EOFSYM)
+ return(NIL(struct regnod*));
+ return(r);
+}
+
+/*
+ * This routine creates the parse tree for the arithmetic for
+ * When called, shlex.arg contains the string inside ((...))
+ * When the first argument is missing, a while node is returned
+ * Otherise a list containing an arithmetic command and a while
+ * is returned.
+ */
+static Shnode_t *arithfor(register Shnode_t *tf)
+{
+ register Shnode_t *t, *tw = tf;
+ register int offset;
+ register struct argnod *argp;
+ register int n;
+ int argflag = shlex.arg->argflag;
+ /* save current input */
+ Fcin_t sav_input;
+ fcsave(&sav_input);
+ fcsopen(shlex.arg->argval);
+ /* split ((...)) into three expressions */
+ for(n=0; ; n++)
+ {
+ register int c;
+ argp = (struct argnod*)stakseek(ARGVAL);
+ argp->argnxt.ap = 0;
+ argp->argchn.cp = 0;
+ argp->argflag = argflag;
+ if(n==2)
+ break;
+ /* copy up to ; onto the stack */
+ sh_lexskip(';',1,ST_NESTED);
+ offset = staktell()-1;
+ if((c=fcpeek(-1))!=';')
+ break;
+ /* remove trailing white space */
+ while(offset>ARGVAL && ((c= *stakptr(offset-1)),isspace(c)))
+ offset--;
+ /* check for empty initialization expression */
+ if(offset==ARGVAL && n==0)
+ continue;
+ stakseek(offset);
+ /* check for empty condition and treat as while((1)) */
+ if(offset==ARGVAL)
+ stakputc('1');
+ argp = (struct argnod*)stakfreeze(1);
+ t = getanode(argp);
+ if(n==0)
+ tf = makelist(TLST,t,tw);
+ else
+ tw->wh.whtre = t;
+ }
+ while((offset=fcpeek(0)) && isspace(offset))
+ fcseek(1);
+ stakputs(fcseek(0));
+ argp = (struct argnod*)stakfreeze(1);
+ fcrestore(&sav_input);
+ if(n<2)
+ {
+ shlex.token = RPAREN|SYMREP;
+ sh_syntax();
+ }
+ /* check whether the increment is present */
+ if(*argp->argval)
+ {
+ t = getanode(argp);
+ tw->wh.whinc = (struct arithnod*)t;
+ }
+ else
+ tw->wh.whinc = 0;
+ sh_lexopen((Lex_t*)sh.lex_context, &sh,1);
+ if((n=sh_lex())==NL)
+ n = skipnl(0);
+ else if(n==';')
+ n = sh_lex();
+ if(n!=DOSYM && n!=LBRACE)
+ sh_syntax();
+ tw->wh.dotre = sh_cmd(n==DOSYM?DONESYM:RBRACE,SH_NL);
+ tw->wh.whtyp = TWH;
+ return(tf);
+
+}
+
+static Shnode_t *funct(void)
+{
+ register Shnode_t *t;
+ register int flag;
+ struct slnod *volatile slp=0;
+ Stak_t *savstak;
+ Sfoff_t first, last;
+ struct functnod *fp;
+ Sfio_t *iop;
+#if SHOPT_KIA
+ unsigned long current = shlex.current;
+#endif /* SHOPT_KIA */
+ int jmpval, saveloop=loop_level;
+ struct argnod *savelabel = label_last;
+ struct checkpt buff;
+ t = getnode(functnod);
+ t->funct.functline = sh.inlineno;
+ t->funct.functtyp=TFUN;
+ t->funct.functargs = 0;
+ if(!(flag = (shlex.token==FUNCTSYM)))
+ t->funct.functtyp |= FPOSIX;
+ else if(sh_lex())
+ sh_syntax();
+ if(!(iop=fcfile()))
+ {
+ iop = sfopen(NIL(Sfio_t*),fcseek(0),"s");
+ fcclose();
+ fcfopen(iop);
+ }
+ t->funct.functloc = first = fctell();
+ if(!sh.st.filename || sffileno(iop)<0)
+ {
+ if(fcfill() >= 0)
+ fcseek(-1);
+ if(sh_isstate(SH_HISTORY))
+ t->funct.functloc = sfseek(sh.hist_ptr->histfp,(off_t)0,SEEK_CUR);
+ else
+ {
+ /* copy source to temporary file */
+ t->funct.functloc = 0;
+ if(shlex.sh->heredocs)
+ t->funct.functloc = sfseek(shlex.sh->heredocs,(Sfoff_t)0, SEEK_END);
+ else
+ shlex.sh->heredocs = sftmp(HERE_MEM);
+ shlex.sh->funlog = shlex.sh->heredocs;
+ t->funct.functtyp |= FPIN;
+ }
+ }
+ t->funct.functnam= (char*)shlex.arg->argval;
+#if SHOPT_KIA
+ if(shlex.kiafile)
+ shlex.current = kiaentity(t->funct.functnam,-1,'p',-1,-1,shlex.script,'p',0,"");
+#endif /* SHOPT_KIA */
+ if(flag)
+ {
+ shlex.token = sh_lex();
+#if SHOPT_BASH
+ if(shlex.token == LPAREN)
+ {
+ if((shlex.token = sh_lex()) == RPAREN)
+ t->funct.functtyp |= FPOSIX;
+ else
+ sh_syntax();
+ }
+#endif
+ }
+ if(t->funct.functtyp&FPOSIX)
+ skipnl(0);
+ else
+ {
+ if(shlex.token==0)
+ t->funct.functargs = (struct comnod*)simple(SH_NOIO|SH_FUNDEF,NIL(struct ionod*));
+ while(shlex.token==NL)
+ shlex.token = sh_lex();
+ }
+ if((flag && shlex.token!=LBRACE) || shlex.token==EOFSYM)
+ sh_syntax();
+ sh_pushcontext(&buff,1);
+ jmpval = sigsetjmp(buff.buff,0);
+ if(jmpval == 0)
+ {
+ /* create a new stak frame to compile the command */
+ savstak = stakcreate(STAK_SMALL);
+ savstak = stakinstall(savstak, 0);
+ slp = (struct slnod*)stakalloc(sizeof(struct slnod)+sizeof(struct functnod));
+ slp->slchild = 0;
+ slp->slnext = sh.st.staklist;
+ sh.st.staklist = 0;
+ t->funct.functstak = (struct slnod*)slp;
+ /*
+ * store the pathname of function definition file on stack
+ * in name field of fake for node
+ */
+ fp = (struct functnod*)(slp+1);
+ fp->functtyp = TFUN|FAMP;
+ fp->functnam = 0;
+ fp->functline = t->funct.functline;
+ if(sh.st.filename)
+ fp->functnam = stakcopy(sh.st.filename);
+ loop_level = 0;
+ label_last = label_list;
+ if(!flag && shlex.token==0)
+ {
+ /* copy current word token to current stak frame */
+ struct argnod *ap;
+ flag = ARGVAL + strlen(shlex.arg->argval);
+ ap = (struct argnod*)stakalloc(flag);
+ memcpy(ap,shlex.arg,flag);
+ shlex.arg = ap;
+ }
+ t->funct.functtre = item(SH_NOIO);
+ }
+ sh_popcontext(&buff);
+ loop_level = saveloop;
+ label_last = savelabel;
+ /* restore the old stack */
+ if(slp)
+ {
+ slp->slptr = stakinstall(savstak,0);
+ slp->slchild = sh.st.staklist;
+ }
+#if SHOPT_KIA
+ shlex.current = current;
+#endif /* SHOPT_KIA */
+ if(jmpval)
+ {
+ if(slp && slp->slptr)
+ {
+ sh.st.staklist = slp->slnext;
+ stakdelete(slp->slptr);
+ }
+ siglongjmp(*sh.jmplist,jmpval);
+ }
+ sh.st.staklist = (struct slnod*)slp;
+ last = fctell();
+ fp->functline = (last-first);
+ fp->functtre = t;
+ if(shlex.sh->funlog)
+ {
+ if(fcfill()>0)
+ fcseek(-1);
+ shlex.sh->funlog = 0;
+ }
+#if SHOPT_KIA
+ if(shlex.kiafile)
+ kiaentity(t->funct.functnam,-1,'p',t->funct.functline,sh.inlineno-1,shlex.current,'p',0,"");
+#endif /* SHOPT_KIA */
+ return(t);
+}
+
+/*
+ * Compound assignment
+ */
+static struct argnod *assign(register struct argnod *ap)
+{
+ register int n;
+ register Shnode_t *t, **tp;
+ register struct comnod *ac;
+ int array=0;
+ Namval_t *np;
+ n = strlen(ap->argval)-1;
+ if(ap->argval[n]!='=')
+ sh_syntax();
+ if(ap->argval[n-1]=='+')
+ {
+ ap->argval[n--]=0;
+ array = ARG_APPEND;
+ }
+ /* shift right */
+ while(n > 0)
+ {
+ ap->argval[n] = ap->argval[n-1];
+ n--;
+ }
+ *ap->argval=0;
+ t = getnode(fornod);
+ t->for_.fornam = (char*)(ap->argval+1);
+ t->for_.fortyp = sh_getlineno();
+ tp = &t->for_.fortre;
+ ap->argchn.ap = (struct argnod*)t;
+ ap->argflag &= ARG_QUOTED;
+ ap->argflag |= array;
+ shlex.assignok = SH_ASSIGN;
+ array=0;
+ if((n=skipnl(0))==RPAREN || n==LPAREN)
+ {
+ int index= 0;
+ struct argnod **settail;
+ ac = (struct comnod*)getnode(comnod);
+ settail= &ac->comset;
+ memset((void*)ac,0,sizeof(*ac));
+ ac->comline = sh_getlineno();
+ while(n==LPAREN)
+ {
+ struct argnod *ap;
+ ap = (struct argnod*)stakseek(ARGVAL);
+ ap->argflag= ARG_ASSIGN;
+ sfprintf(stkstd,"[%d]=",index++);
+ ap = (struct argnod*)stakfreeze(1);
+ ap->argnxt.ap = 0;
+ ap = assign(ap);
+ ap->argflag |= ARG_MESSAGE;
+ *settail = ap;
+ settail = &(ap->argnxt.ap);
+ n = skipnl(0);
+ }
+ }
+ else if(n)
+ sh_syntax();
+ else if(!(shlex.arg->argflag&ARG_ASSIGN) && !((np=nv_search(shlex.arg->argval,sh.fun_tree,0)) && nv_isattr(np,BLT_DCL)))
+ array=SH_ARRAY;
+ while(1)
+ {
+ if((n=shlex.token)==RPAREN)
+ break;
+ if(n==FUNCTSYM || n==SYMRES)
+ ac = (struct comnod*)funct();
+ else
+ ac = (struct comnod*)simple(SH_NOIO|SH_ASSIGN|array,NIL(struct ionod*));
+ if((n=shlex.token)==RPAREN)
+ break;
+ if(n!=NL && n!=';')
+ sh_syntax();
+ shlex.assignok = SH_ASSIGN;
+ if((n=skipnl(0)) || array)
+ {
+ if(n==RPAREN)
+ break;
+ if(array || n!=FUNCTSYM)
+ sh_syntax();
+ }
+ if((n!=FUNCTSYM) && !(shlex.arg->argflag&ARG_ASSIGN) && !((np=nv_search(shlex.arg->argval,sh.fun_tree,0)) && nv_isattr(np,BLT_DCL)))
+ {
+ struct argnod *arg = shlex.arg;
+ if(n!=0)
+ sh_syntax();
+ /* check for sys5 style function */
+ if(sh_lex()!=LPAREN || sh_lex()!=RPAREN)
+ {
+ shlex.arg = arg;
+ shlex.token = 0;
+ sh_syntax();
+ }
+ shlex.arg = arg;
+ shlex.token = SYMRES;
+ }
+ t = makelist(TLST,(Shnode_t*)ac,t);
+ *tp = t;
+ tp = &t->lst.lstrit;
+ }
+ *tp = (Shnode_t*)ac;
+ shlex.assignok = 0;
+ return(ap);
+}
+
+/*
+ * item
+ *
+ * ( cmd ) [ < in ] [ > out ]
+ * word word* [ < in ] [ > out ]
+ * if ... then ... else ... fi
+ * for ... while ... do ... done
+ * case ... in ... esac
+ * begin ... end
+ */
+
+static Shnode_t *item(int flag)
+{
+ register Shnode_t *t;
+ register struct ionod *io;
+ register int tok = (shlex.token&0xff);
+ int savwdval = shlex.lasttok;
+ int savline = shlex.lastline;
+ int showme=0;
+ if(!(flag&SH_NOIO) && (tok=='<' || tok=='>'))
+ io=inout(NIL(struct ionod*),1);
+ else
+ io=0;
+ if((tok=shlex.token) && tok!=EOFSYM && tok!=FUNCTSYM)
+ {
+ shlex.lastline = sh_getlineno();
+ shlex.lasttok = shlex.token;
+ }
+ switch(tok)
+ {
+ /* [[ ... ]] test expression */
+ case BTESTSYM:
+ t = test_expr(ETESTSYM);
+ t->tre.tretyp &= ~TTEST;
+ break;
+ /* ((...)) arithmetic expression */
+ case EXPRSYM:
+ t = getanode(shlex.arg);
+ sh_lex();
+ goto done;
+
+ /* case statement */
+ case CASESYM:
+ {
+ int savetok = shlex.lasttok;
+ int saveline = shlex.lastline;
+ t = getnode(swnod);
+ if(sh_lex())
+ sh_syntax();
+ t->sw.swarg=shlex.arg;
+ t->sw.swtyp=TSW;
+ t->sw.swio = 0;
+ t->sw.swtyp |= FLINENO;
+ t->sw.swline = sh.inlineno;
+ if((tok=skipnl(0))!=INSYM && tok!=LBRACE)
+ sh_syntax();
+ if(!(t->sw.swlst=syncase(tok==INSYM?ESACSYM:RBRACE)) && shlex.token==EOFSYM)
+ {
+ shlex.lasttok = savetok;
+ shlex.lastline = saveline;
+ sh_syntax();
+ }
+ break;
+ }
+
+ /* if statement */
+ case IFSYM:
+ {
+ register Shnode_t *tt;
+ t = getnode(ifnod);
+ t->if_.iftyp=TIF;
+ t->if_.iftre=sh_cmd(THENSYM,SH_NL);
+ t->if_.thtre=sh_cmd(ELSESYM,SH_NL|SH_SEMI);
+ tok = shlex.token;
+ t->if_.eltre=(tok==ELSESYM?sh_cmd(FISYM,SH_NL|SH_SEMI):
+ (tok==ELIFSYM?(shlex.token=IFSYM, tt=item(SH_NOIO)):0));
+ if(tok==ELIFSYM)
+ {
+ if(!tt || tt->tre.tretyp!=TSETIO)
+ goto done;
+ t->if_.eltre = tt->fork.forktre;
+ tt->fork.forktre = t;
+ t = tt;
+ goto done;
+ }
+ break;
+ }
+
+ /* for and select statement */
+ case FORSYM:
+ case SELECTSYM:
+ {
+ t = getnode(fornod);
+ t->for_.fortyp=(shlex.token==FORSYM?TFOR:TSELECT);
+ t->for_.forlst=0;
+ t->for_.forline = sh.inlineno;
+ if(sh_lex())
+ {
+ if(shlex.token!=EXPRSYM || t->for_.fortyp!=TFOR)
+ sh_syntax();
+ /* arithmetic for */
+ t = arithfor(t);
+ break;
+ }
+ t->for_.fornam=(char*) shlex.arg->argval;
+ t->for_.fortyp |= FLINENO;
+#if SHOPT_KIA
+ if(shlex.kiafile)
+ writedefs(shlex.arg,sh.inlineno,'v',NIL(struct argnod*));
+#endif /* SHOPT_KIA */
+ while((tok=sh_lex())==NL);
+ if(tok==INSYM)
+ {
+ if(sh_lex())
+ {
+ if(shlex.token != NL && shlex.token !=';')
+ sh_syntax();
+ /* some Linux scripts assume this */
+ if(sh_isoption(SH_NOEXEC))
+ errormsg(SH_DICT,ERROR_warn(0),e_lexemptyfor,sh.inlineno-(shlex.token=='\n'));
+ t->for_.forlst = (struct comnod*)getnode(comnod);
+ (t->for_.forlst)->comarg = 0;
+ (t->for_.forlst)->comset = 0;
+ (t->for_.forlst)->comnamp = 0;
+ (t->for_.forlst)->comnamq = 0;
+ (t->for_.forlst)->comstate = 0;
+ (t->for_.forlst)->comio = 0;
+ (t->for_.forlst)->comtyp = 0;
+ }
+ else
+ t->for_.forlst=(struct comnod*)simple(SH_NOIO,NIL(struct ionod*));
+ if(shlex.token != NL && shlex.token !=';')
+ sh_syntax();
+ tok = skipnl(0);
+ }
+ /* 'for i;do cmd' is valid syntax */
+ else if(tok==';')
+ tok=sh_lex();
+ if(tok!=DOSYM && tok!=LBRACE)
+ sh_syntax();
+ loop_level++;
+ t->for_.fortre=sh_cmd(tok==DOSYM?DONESYM:RBRACE,SH_NL|SH_SEMI);
+ if(--loop_level==0)
+ label_last = label_list;
+ break;
+ }
+
+ /* This is the code for parsing function definitions */
+ case FUNCTSYM:
+ return(funct());
+
+#if SHOPT_NAMESPACE
+ case NSPACESYM:
+ t = getnode(fornod);
+ t->for_.fortyp=TNSPACE;
+ t->for_.forlst=0;
+ if(sh_lex())
+ sh_syntax();
+ t->for_.fornam=(char*) shlex.arg->argval;
+ while((tok=sh_lex())==NL);
+ if(tok!=LBRACE)
+ sh_syntax();
+ t->for_.fortre = sh_cmd(RBRACE,SH_NL);
+ break;
+#endif /* SHOPT_NAMESPACE */
+
+ /* while and until */
+ case WHILESYM:
+ case UNTILSYM:
+ t = getnode(whnod);
+ t->wh.whtyp=(shlex.token==WHILESYM ? TWH : TUN);
+ loop_level++;
+ t->wh.whtre = sh_cmd(DOSYM,SH_NL);
+ t->wh.dotre = sh_cmd(DONESYM,SH_NL|SH_SEMI);
+ if(--loop_level==0)
+ label_last = label_list;
+ t->wh.whinc = 0;
+ break;
+
+ case LABLSYM:
+ {
+ register struct argnod *argp = label_list;
+ while(argp)
+ {
+ if(strcmp(argp->argval,shlex.arg->argval)==0)
+ errormsg(SH_DICT,ERROR_exit(3),e_lexsyntax3,sh.inlineno,argp->argval);
+ argp = argp->argnxt.ap;
+ }
+ shlex.arg->argnxt.ap = label_list;
+ label_list = shlex.arg;
+ label_list->argchn.len = sh_getlineno();
+ label_list->argflag = loop_level;
+ skipnl(flag);
+ if(!(t = item(SH_NL)))
+ sh_syntax();
+ tok = (t->tre.tretyp&(COMSCAN|COMSCAN-1));
+ if(sh_isoption(SH_NOEXEC) && tok!=TWH && tok!=TUN && tok!=TFOR && tok!=TSELECT)
+ errormsg(SH_DICT,ERROR_warn(0),e_lexlabignore,label_list->argchn.len,label_list->argval);
+ return(t);
+ }
+
+ /* command group with {...} */
+ case LBRACE:
+ t = sh_cmd(RBRACE,SH_NL);
+ break;
+
+ case LPAREN:
+ t = getnode(parnod);
+ t->par.partre=sh_cmd(RPAREN,SH_NL);
+ t->par.partyp=TPAR;
+ break;
+
+ default:
+ if(io==0)
+ return(0);
+
+ case ';':
+ if(io==0)
+ {
+ if(!(flag&SH_SEMI))
+ return(0);
+ if(sh_lex()==';')
+ sh_syntax();
+ showme = FSHOWME;
+ }
+ /* simple command */
+ case 0:
+ t = (Shnode_t*)simple(flag,io);
+ t->tre.tretyp |= showme;
+ return(t);
+ }
+ sh_lex();
+ if(io=inout(io,0))
+ {
+ if((tok=t->tre.tretyp&COMMSK) != TFORK)
+ tok = TSETIO;
+ t=makeparent(tok,t);
+ t->tre.treio=io;
+ }
+done:
+ shlex.lasttok = savwdval;
+ shlex.lastline = savline;
+ return(t);
+}
+
+/*
+ * This is for a simple command, for list, or compound assignment
+ */
+static Shnode_t *simple(int flag, struct ionod *io)
+{
+ register struct comnod *t;
+ register struct argnod *argp;
+ register int tok;
+ struct argnod **argtail;
+ struct argnod **settail;
+ int argno = 0;
+ int assignment = 0;
+ int key_on = (!(flag&SH_NOIO) && sh_isoption(SH_KEYWORD));
+ int associative=0;
+ if((argp=shlex.arg) && (argp->argflag&ARG_ASSIGN) && argp->argval[0]=='[')
+ {
+ flag |= SH_ARRAY;
+ associative = 1;
+ }
+ t = (struct comnod*)getnode(comnod);
+ t->comio=io; /*initial io chain*/
+ /* set command line number for error messages */
+ t->comline = sh_getlineno();
+ argtail = &(t->comarg);
+ t->comset = 0;
+ t->comnamp = 0;
+ t->comnamq = 0;
+ t->comstate = 0;
+ settail = &(t->comset);
+ while(shlex.token==0)
+ {
+ argp = shlex.arg;
+ if(*argp->argval==LBRACE && (flag&SH_FUNDEF) && argp->argval[1]==0)
+ {
+ shlex.token = LBRACE;
+ break;
+ }
+ if(associative && argp->argval[0]!='[')
+ sh_syntax();
+ /* check for assignment argument */
+ if((argp->argflag&ARG_ASSIGN) && assignment!=2)
+ {
+ *settail = argp;
+ settail = &(argp->argnxt.ap);
+ shlex.assignok = (flag&SH_ASSIGN)?SH_ASSIGN:1;
+ if(assignment)
+ {
+ struct argnod *ap=argp;
+ char *last, *cp;
+ if(assignment==1)
+ {
+ last = strchr(argp->argval,'=');
+ if((cp=strchr(argp->argval,'[')) && (cp < last))
+ last = cp;
+ stakseek(ARGVAL);
+ stakwrite(argp->argval,last-argp->argval);
+ ap=(struct argnod*)stakfreeze(1);
+ ap->argflag = ARG_RAW;
+ ap->argchn.ap = 0;
+ }
+ *argtail = ap;
+ argtail = &(ap->argnxt.ap);
+ if(argno>=0)
+ argno++;
+ }
+ else /* alias substitutions allowed */
+ shlex.aliasok = 1;
+ }
+ else
+ {
+ if(!(argp->argflag&ARG_RAW))
+ argno = -1;
+ if(argno>=0 && argno++==0 && !(flag&SH_ARRAY) && *argp->argval!='/')
+ {
+ /* check for builtin command */
+ Namval_t *np=nv_bfsearch(argp->argval,sh.fun_tree, (Namval_t**)&t->comnamq,(char**)0);
+ if((t->comnamp=(void*)np) && is_abuiltin(np) &&
+ nv_isattr(np,BLT_DCL))
+ {
+ assignment = 1+(*argp->argval=='a');
+ key_on = 1;
+ }
+ }
+ *argtail = argp;
+ argtail = &(argp->argnxt.ap);
+ if(!(shlex.assignok=key_on) && !(flag&SH_NOIO))
+ shlex.assignok = SH_COMPASSIGN;
+ shlex.aliasok = 0;
+ }
+ retry:
+ tok = sh_lex();
+#if SHOPT_DEVFD
+ if((tok==IPROCSYM || tok==OPROCSYM))
+ {
+ Shnode_t *t;
+ int mode = (tok==OPROCSYM);
+ t = sh_cmd(RPAREN,SH_NL);
+ argp = (struct argnod*)stakalloc(sizeof(struct argnod));
+ *argp->argval = 0;
+ argno = -1;
+ *argtail = argp;
+ argtail = &(argp->argnxt.ap);
+ argp->argchn.ap = (struct argnod*)makeparent(mode?TFORK|FPIN|FAMP|FPCL:TFORK|FPOU,t);
+ argp->argflag = (ARG_EXP|mode);
+ goto retry;
+ }
+#endif /* SHOPT_DEVFD */
+ if(tok==LPAREN)
+ {
+ if(argp->argflag&ARG_ASSIGN)
+ {
+ argp = assign(argp);
+ if(associative)
+ shlex.assignok |= SH_ASSIGN;
+ goto retry;
+ }
+ else if(argno==1 && !t->comset)
+ {
+ /* SVR2 style function */
+ if(sh_lex() == RPAREN)
+ {
+ shlex.arg = argp;
+ return(funct());
+ }
+ shlex.token = LPAREN;
+ }
+ }
+ else if(flag&SH_ASSIGN)
+ {
+ if(tok==RPAREN)
+ break;
+ else if(tok==NL && (flag&SH_ARRAY))
+ goto retry;
+ }
+ if(!(flag&SH_NOIO))
+ {
+ if(io)
+ {
+ while(io->ionxt)
+ io = io->ionxt;
+ io->ionxt = inout((struct ionod*)0,0);
+ }
+ else
+ t->comio = io = inout((struct ionod*)0,0);
+ }
+ }
+ *argtail = 0;
+ t->comtyp = TCOM;
+#if SHOPT_KIA
+ if(shlex.kiafile && !(flag&SH_NOIO))
+ {
+ register Namval_t *np=(Namval_t*)t->comnamp;
+ unsigned long r=0;
+ int line = t->comline;
+ argp = t->comarg;
+ if(np)
+ r = kiaentity(nv_name(np),-1,'p',-1,0,shlex.unknown,'b',0,"");
+ else if(argp)
+ r = kiaentity(sh_argstr(argp),-1,'p',-1,0,shlex.unknown,'c',0,"");
+ if(r>0)
+ sfprintf(shlex.kiatmp,"p;%..64d;p;%..64d;%d;%d;c;\n",shlex.current,r,line,line);
+ if(t->comset && argno==0)
+ writedefs(t->comset,line,'v',t->comarg);
+ else if(np && nv_isattr(np,BLT_DCL))
+ writedefs(argp,line,0,NIL(struct argnod*));
+ else if(argp && strcmp(argp->argval,"read")==0)
+ writedefs(argp,line,0,NIL(struct argnod*));
+#if 0
+ else if(argp && strcmp(argp->argval,"unset")==0)
+ writedefs(argp,line,'u',NIL(struct argnod*));
+#endif
+ else if(argp && *argp->argval=='.' && argp->argval[1]==0 && (argp=argp->argnxt.ap))
+ {
+ r = kiaentity(sh_argstr(argp),-1,'p',0,0,shlex.script,'d',0,"");
+ sfprintf(shlex.kiatmp,"p;%..64d;p;%..64d;%d;%d;d;\n",shlex.current,r,line,line);
+ }
+ }
+#endif /* SHOPT_KIA */
+ if(t->comnamp && (argp=t->comarg->argnxt.ap))
+ {
+ Namval_t *np=(Namval_t*)t->comnamp;
+ if((np==SYSBREAK || np==SYSCONT) && (argp->argflag&ARG_RAW) && !isdigit(*argp->argval))
+ {
+ register char *cp = argp->argval;
+ /* convert break/continue labels to numbers */
+ tok = 0;
+ for(argp=label_list;argp!=label_last;argp=argp->argnxt.ap)
+ {
+ if(strcmp(cp,argp->argval))
+ continue;
+ tok = loop_level-argp->argflag;
+ if(tok>=1)
+ {
+ argp = t->comarg->argnxt.ap;
+ if(tok>9)
+ {
+ argp->argval[1] = '0'+tok%10;
+ argp->argval[2] = 0;
+ tok /= 10;
+ }
+ else
+ argp->argval[1] = 0;
+ *argp->argval = '0'+tok;
+ }
+ break;
+ }
+ if(sh_isoption(SH_NOEXEC) && tok==0)
+ errormsg(SH_DICT,ERROR_warn(0),e_lexlabunknown,sh.inlineno-(shlex.token=='\n'),cp);
+ }
+ else if(sh_isoption(SH_NOEXEC) && np==SYSSET && ((tok= *argp->argval)=='-'||tok=='+') &&
+ (argp->argval[1]==0||strchr(argp->argval,'k')))
+ errormsg(SH_DICT,ERROR_warn(0),e_lexobsolete5,sh.inlineno-(shlex.token=='\n'),argp->argval);
+ }
+ /* expand argument list if possible */
+ if(argno>0)
+ t->comarg = qscan(t,argno);
+ else if(t->comarg)
+ t->comtyp |= COMSCAN;
+ shlex.aliasok = 0;
+ return((Shnode_t*)t);
+}
+
+/*
+ * skip past newlines but issue prompt if interactive
+ */
+static int skipnl(int flag)
+{
+ register int token;
+ while((token=sh_lex())==NL);
+ if(token==';' && !(flag&SH_SEMI))
+ sh_syntax();
+ return(token);
+}
+
+/*
+ * check for and process and i/o redirections
+ * if flag>0 then an alias can be in the next word
+ * if flag<0 only one redirection will be processed
+ */
+static struct ionod *inout(struct ionod *lastio,int flag)
+{
+ register int iof = shlex.digits, token=shlex.token;
+ register struct ionod *iop;
+ char *iovname=0;
+#if SHOPT_BASH
+ register int errout=0;
+#endif
+ if(token==IOVNAME)
+ {
+ iovname=shlex.arg->argval+1;
+ token= sh_lex();
+ iof = 0;
+ }
+ switch(token&0xff)
+ {
+ case '<':
+ if(token==IODOCSYM)
+ iof |= (IODOC|IORAW);
+ else if(token==IOMOV0SYM)
+ iof |= IOMOV;
+ else if(token==IORDWRSYM)
+ iof |= IORDW;
+ else if((token&SYMSHARP) == SYMSHARP)
+ {
+ int n;
+ iof |= IOLSEEK;
+ if(fcgetc(n)=='#')
+ iof |= IOCOPY;
+ else if(n>0)
+ fcseek(-1);
+ }
+ break;
+
+ case '>':
+#if SHOPT_BASH
+ if(iof<0)
+ {
+ errout = 1;
+ iof = 1;
+ }
+#endif
+ iof |= IOPUT;
+ if(token==IOAPPSYM)
+ iof |= IOAPP;
+ else if(token==IOMOV1SYM)
+ iof |= IOMOV;
+ else if(token==IOCLOBSYM)
+ iof |= IOCLOB;
+ else if((token&SYMSHARP) == SYMSHARP)
+ iof |= IOLSEEK;
+ break;
+
+ default:
+ return(lastio);
+ }
+ shlex.digits=0;
+ iop=(struct ionod*) stakalloc(sizeof(struct ionod));
+ iop->iodelim = 0;
+ if(token=sh_lex())
+ {
+ if(token==RPAREN && (iof&IOLSEEK) && shlex.comsub)
+ {
+ shlex.arg = (struct argnod*)stakalloc(sizeof(struct argnod)+3);
+ strcpy(shlex.arg->argval,"CUR");
+ shlex.arg->argflag = ARG_RAW;
+ iof |= IOARITH;
+ fcseek(-1);
+ }
+ else if(token==EXPRSYM && (iof&IOLSEEK))
+ iof |= IOARITH;
+ else
+ sh_syntax();
+ }
+ iop->ioname=shlex.arg->argval;
+ iop->iovname = iovname;
+ if(iof&IODOC)
+ {
+ if(shlex.digits==2)
+ {
+ iof |= IOSTRG;
+ if(!(shlex.arg->argflag&ARG_RAW))
+ iof &= ~IORAW;
+ }
+ else
+ {
+ if(!shlex.sh->heredocs)
+ shlex.sh->heredocs = sftmp(HERE_MEM);
+ iop->iolst=shlex.heredoc;
+ shlex.heredoc=iop;
+ if(shlex.arg->argflag&ARG_QUOTED)
+ iof |= IOQUOTE;
+ if(shlex.digits==3)
+ iof |= IOLSEEK;
+ if(shlex.digits)
+ iof |= IOSTRIP;
+ }
+ }
+ else
+ {
+ iop->iolst = 0;
+ if(shlex.arg->argflag&ARG_RAW)
+ iof |= IORAW;
+ }
+ iop->iofile=iof;
+ if(flag>0)
+ /* allow alias substitutions and parameter assignments */
+ shlex.aliasok = shlex.assignok = 1;
+#if SHOPT_KIA
+ if(shlex.kiafile)
+ {
+ int n = sh.inlineno-(shlex.token=='\n');
+ if(!(iof&IOMOV))
+ {
+ unsigned long r=kiaentity((iof&IORAW)?sh_fmtq(iop->ioname):iop->ioname,-1,'f',0,0,shlex.script,'f',0,"");
+ sfprintf(shlex.kiatmp,"p;%..64d;f;%..64d;%d;%d;%c;%d\n",shlex.current,r,n,n,(iof&IOPUT)?((iof&IOAPP)?'a':'w'):((iof&IODOC)?'h':'r'),iof&IOUFD);
+ }
+ }
+#endif /* SHOPT_KIA */
+ if(flag>=0)
+ {
+ struct ionod *ioq=iop;
+ sh_lex();
+#if SHOPT_BASH
+ if(errout)
+ {
+ /* redirect standard output to standard error */
+ ioq = (struct ionod*)stakalloc(sizeof(struct ionod));
+ ioq->ioname = "1";
+ ioq->iolst = 0;
+ ioq->iodelim = 0;
+ ioq->iofile = IORAW|IOPUT|IOMOV|2;
+ iop->ionxt=ioq;
+ }
+#endif
+ ioq->ionxt=inout(lastio,flag);
+ }
+ else
+ iop->ionxt=0;
+ return(iop);
+}
+
+/*
+ * convert argument chain to argument list when no special arguments
+ */
+
+static struct argnod *qscan(struct comnod *ac,int argn)
+{
+ register char **cp;
+ register struct argnod *ap;
+ register struct dolnod* dp;
+ register int special=0;
+ /* special hack for test -t compatibility */
+ if((Namval_t*)ac->comnamp==SYSTEST)
+ special = 2;
+ else if(*(ac->comarg->argval)=='[' && ac->comarg->argval[1]==0)
+ special = 3;
+ if(special)
+ {
+ ap = ac->comarg->argnxt.ap;
+ if(argn==(special+1) && ap->argval[1]==0 && *ap->argval=='!')
+ ap = ap->argnxt.ap;
+ else if(argn!=special)
+ special=0;
+ }
+ if(special)
+ {
+ const char *message;
+ if(strcmp(ap->argval,"-t"))
+ {
+ message = "line %d: Invariant test";
+ special=0;
+ }
+ else
+ {
+ message = "line %d: -t requires argument";
+ argn++;
+ }
+ if(sh_isoption(SH_NOEXEC))
+ errormsg(SH_DICT,ERROR_warn(0),message,ac->comline);
+ }
+ /* leave space for an extra argument at the front */
+ dp = (struct dolnod*)stakalloc((unsigned)sizeof(struct dolnod) + ARG_SPARE*sizeof(char*) + argn*sizeof(char*));
+ cp = dp->dolval+ARG_SPARE;
+ dp->dolnum = argn;
+ dp->dolbot = ARG_SPARE;
+ ap = ac->comarg;
+ while(ap)
+ {
+ *cp++ = ap->argval;
+ ap = ap->argnxt.ap;
+ }
+ if(special==3)
+ {
+ cp[0] = cp[-1];
+ cp[-1] = "1";
+ cp++;
+ }
+ else if(special)
+ *cp++ = "1";
+ *cp = 0;
+ return((struct argnod*)dp);
+}
+
+static Shnode_t *test_expr(int sym)
+{
+ register Shnode_t *t = test_or();
+ if(shlex.token!=sym)
+ sh_syntax();
+ return(t);
+}
+
+static Shnode_t *test_or(void)
+{
+ register Shnode_t *t = test_and();
+ while(shlex.token==ORFSYM)
+ t = makelist(TORF|TTEST,t,test_and());
+ return(t);
+}
+
+static Shnode_t *test_and(void)
+{
+ register Shnode_t *t = test_primary();
+ while(shlex.token==ANDFSYM)
+ t = makelist(TAND|TTEST,t,test_primary());
+ return(t);
+}
+
+/*
+ * convert =~ into == ~(E)
+ */
+static void ere_match(void)
+{
+ Sfio_t *base, *iop = sfopen((Sfio_t*)0," ~(E)","s");
+ register int c;
+ while( fcgetc(c),(c==' ' || c=='\t'));
+ if(c)
+ fcseek(-1);
+ if(!(base=fcfile()))
+ base = sfopen(NIL(Sfio_t*),fcseek(0),"s");
+ fcclose();
+ sfstack(base,iop);
+ fcfopen(base);
+}
+
+static Shnode_t *test_primary(void)
+{
+ register struct argnod *arg;
+ register Shnode_t *t;
+ register int num,token;
+ token = skipnl(0);
+ num = shlex.digits;
+ switch(token)
+ {
+ case '(':
+ t = test_expr(')');
+ t = makelist(TTST|TTEST|TPAREN ,t, (Shnode_t*)pointerof(sh.inlineno));
+ break;
+ case '!':
+ if(!(t = test_primary()))
+ sh_syntax();
+ t->tre.tretyp |= TNEGATE;
+ return(t);
+ case TESTUNOP:
+ if(sh_lex())
+ sh_syntax();
+#if SHOPT_KIA
+ if(shlex.kiafile && !strchr("sntzoOG",num))
+ {
+ int line = sh.inlineno- (shlex.token==NL);
+ unsigned long r;
+ r=kiaentity(sh_argstr(shlex.arg),-1,'f',0,0,shlex.script,'t',0,"");
+ sfprintf(shlex.kiatmp,"p;%..64d;f;%..64d;%d;%d;t;\n",shlex.current,r,line,line);
+ }
+#endif /* SHOPT_KIA */
+ t = makelist(TTST|TTEST|TUNARY|(num<<TSHIFT),
+ (Shnode_t*)shlex.arg,(Shnode_t*)shlex.arg);
+ t->tst.tstline = sh.inlineno;
+ break;
+ /* binary test operators */
+ case 0:
+ arg = shlex.arg;
+ if((token=sh_lex())==TESTBINOP)
+ {
+ num = shlex.digits;
+ if(num==TEST_REP)
+ {
+ ere_match();
+ num = TEST_PEQ;
+ }
+ }
+ else if(token=='<')
+ num = TEST_SLT;
+ else if(token=='>')
+ num = TEST_SGT;
+ else if(token==ANDFSYM||token==ORFSYM||token==ETESTSYM||token==RPAREN)
+ {
+ t = makelist(TTST|TTEST|TUNARY|('n'<<TSHIFT),
+ (Shnode_t*)arg,(Shnode_t*)arg);
+ t->tst.tstline = sh.inlineno;
+ return(t);
+ }
+ else
+ sh_syntax();
+#if SHOPT_KIA
+ if(shlex.kiafile && (num==TEST_EF||num==TEST_NT||num==TEST_OT))
+ {
+ int line = sh.inlineno- (shlex.token==NL);
+ unsigned long r;
+ r=kiaentity(sh_argstr(shlex.arg),-1,'f',0,0,shlex.current,'t',0,"");
+ sfprintf(shlex.kiatmp,"p;%..64d;f;%..64d;%d;%d;t;\n",shlex.current,r,line,line);
+ }
+#endif /* SHOPT_KIA */
+ if(sh_lex())
+ sh_syntax();
+ if(num&TEST_PATTERN)
+ {
+ if(shlex.arg->argflag&(ARG_EXP|ARG_MAC))
+ num &= ~TEST_PATTERN;
+ }
+ t = getnode(tstnod);
+ t->lst.lsttyp = TTST|TTEST|TBINARY|(num<<TSHIFT);
+ t->lst.lstlef = (Shnode_t*)arg;
+ t->lst.lstrit = (Shnode_t*)shlex.arg;
+ t->tst.tstline = sh.inlineno;
+#if SHOPT_KIA
+ if(shlex.kiafile && (num==TEST_EF||num==TEST_NT||num==TEST_OT))
+ {
+ int line = sh.inlineno-(shlex.token==NL);
+ unsigned long r;
+ r=kiaentity(sh_argstr(shlex.arg),-1,'f',0,0,shlex.current,'t',0,"");
+ sfprintf(shlex.kiatmp,"p;%..64d;f;%..64d;%d;%d;t;\n",shlex.current,r,line,line);
+ }
+#endif /* SHOPT_KIA */
+ break;
+ default:
+ return(0);
+ }
+ skipnl(0);
+ return(t);
+}
+
+#if SHOPT_KIA
+/*
+ * return an entity checksum
+ * The entity is created if it doesn't exist
+ */
+unsigned long kiaentity(const char *name,int len,int type,int first,int last,unsigned long parent, int pkind, int width, const char *attr)
+{
+ Namval_t *np;
+ long offset = staktell();
+ stakputc(type);
+ if(len>0)
+ stakwrite(name,len);
+ else
+ {
+ if(type=='p')
+ stakputs(path_basename(name));
+ else
+ stakputs(name);
+ }
+ stakputc(0);
+ np = nv_search(stakptr(offset),shlex.entity_tree,NV_ADD);
+ stakseek(offset);
+ np->nvalue.i = pkind;
+ nv_setsize(np,width);
+ if(!nv_isattr(np,NV_TAGGED) && first>=0)
+ {
+ nv_onattr(np,NV_TAGGED);
+ if(!pkind)
+ pkind = '0';
+ if(len>0)
+ sfprintf(shlex.kiafile,"%..64d;%c;%.*s;%d;%d;%..64d;%..64d;%c;%d;%s\n",np->hash,type,len,name,first,last,parent,shlex.fscript,pkind,width,attr);
+ else
+ sfprintf(shlex.kiafile,"%..64d;%c;%s;%d;%d;%..64d;%..64d;%c;%d;%s\n",np->hash,type,name,first,last,parent,shlex.fscript,pkind,width,attr);
+ }
+ return(np->hash);
+}
+
+static void kia_add(register Namval_t *np, void *data)
+{
+ char *name = nv_name(np);
+ NOT_USED(data);
+ kiaentity(name+1,-1,*name,0,-1,(*name=='p'?shlex.unknown:shlex.script),np->nvalue.i,nv_size(np),"");
+}
+
+int kiaclose(void)
+{
+ register off_t off1,off2;
+ register int n;
+ if(shlex.kiafile)
+ {
+ unsigned long r = kiaentity(shlex.scriptname,-1,'p',-1,sh.inlineno-1,0,'s',0,"");
+ kiaentity(shlex.scriptname,-1,'p',1,sh.inlineno-1,r,'s',0,"");
+ kiaentity(shlex.scriptname,-1,'f',1,sh.inlineno-1,r,'s',0,"");
+ nv_scan(shlex.entity_tree,kia_add,(void*)0,NV_TAGGED,0);
+ off1 = sfseek(shlex.kiafile,(off_t)0,SEEK_END);
+ sfseek(shlex.kiatmp,(off_t)0,SEEK_SET);
+ sfmove(shlex.kiatmp,shlex.kiafile,SF_UNBOUND,-1);
+ off2 = sfseek(shlex.kiafile,(off_t)0,SEEK_END);
+#ifdef SF_BUFCONST
+ if(off2==off1)
+ n= sfprintf(shlex.kiafile,"DIRECTORY\nENTITY;%lld;%d\nDIRECTORY;",(Sflong_t)shlex.kiabegin,(size_t)(off1-shlex.kiabegin));
+ else
+ n= sfprintf(shlex.kiafile,"DIRECTORY\nENTITY;%lld;%d\nRELATIONSHIP;%lld;%d\nDIRECTORY;",(Sflong_t)shlex.kiabegin,(size_t)(off1-shlex.kiabegin),(Sflong_t)off1,(size_t)(off2-off1));
+ if(off2 >= INT_MAX)
+ off2 = -(n+12);
+ sfprintf(shlex.kiafile,"%010.10lld;%010d\n",(Sflong_t)off2+10, n+12);
+#else
+ if(off2==off1)
+ n= sfprintf(shlex.kiafile,"DIRECTORY\nENTITY;%d;%d\nDIRECTORY;",shlex.kiabegin,off1-shlex.kiabegin);
+ else
+ n= sfprintf(shlex.kiafile,"DIRECTORY\nENTITY;%d;%d\nRELATIONSHIP;%d;%d\nDIRECTORY;",shlex.kiabegin,off1-shlex.kiabegin,off1,off2-off1);
+ sfprintf(shlex.kiafile,"%010d;%010d\n",off2+10, n+12);
+#endif
+ }
+ return(sfclose(shlex.kiafile));
+}
+#endif /* SHOPT_KIA */
diff --git a/usr/src/lib/libshell/common/sh/path.c b/usr/src/lib/libshell/common/sh/path.c
new file mode 100644
index 0000000000..a07a9d6e00
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/path.c
@@ -0,0 +1,1697 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#include "defs.h"
+#include <fcin.h>
+#include <ls.h>
+#include <nval.h>
+#include <dlldefs.h>
+#include "variables.h"
+#include "path.h"
+#include "io.h"
+#include "jobs.h"
+#include "history.h"
+#include "test.h"
+#include "FEATURE/externs"
+#if SHOPT_PFSH
+# ifdef _hdr_exec_attr
+# include <exec_attr.h>
+# else
+# undef SHOPT_PFSH
+# endif
+#endif
+
+#define RW_ALL (S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR|S_IWGRP|S_IWOTH)
+#define LIBCMD "cmd"
+
+
+static int canexecute(char*,int);
+static void funload(Shell_t*,int,const char*);
+static void exscript(Shell_t*,char*, char*[], char**);
+static int path_chkpaths(Pathcomp_t*,Pathcomp_t*,Pathcomp_t*,int);
+
+static const char *std_path;
+
+static int onstdpath(const char *name)
+{
+ register const char *cp = std_path, *sp;
+ if(cp)
+ while(*cp)
+ {
+ for(sp=name; *sp && (*cp == *sp); sp++,cp++);
+ if(*sp==0 && (*cp==0 || *cp==':'))
+ return(1);
+ while(*cp && *cp++!=':');
+ }
+ return(0);
+}
+
+static int path_pfexecve(const char *path, char *argv[],char *const envp[])
+{
+#if SHOPT_PFSH
+ char resolvedpath[PATH_MAX + 1];
+ if(!sh_isoption(SH_PFSH))
+ return(execve(path, argv, envp));
+ /* Solaris implements realpath(3C) using the resolvepath(2) */
+ /* system call so we can save us to call access(2) first */
+ if (!realpath(path, resolvedpath))
+ return -1;
+
+ /* we can exec the command directly instead of via pfexec(1) if */
+ /* there is a matching entry without attributes in exec_attr(4) */
+ if (sh.user && *sh.user)
+ {
+ execattr_t *pf;
+ if(pf=getexecuser(sh.user, KV_COMMAND, resolvedpath, GET_ONE))
+ {
+ if (!pf->attr || pf->attr->length == 0)
+ {
+ int r = execve(path, argv, envp);
+ free_execattr(pf);
+ return r;
+ }
+ free_execattr(pf);
+ }
+ else
+ {
+ errno = ENOENT;
+ return -1;
+ }
+ }
+ --argv;
+ argv[0] = argv[1];
+ argv[1] = resolvedpath;
+ return(execve("/usr/bin/pfexec", argv, envp));
+#else
+ return(execve(path, argv, envp));
+#endif
+}
+
+
+static pid_t _spawnveg(const char *path, char* const argv[], char* const envp[], pid_t pid)
+{
+ int waitsafe = job.waitsafe;
+ job_lock();
+ pid = spawnveg(path,argv,envp,pid);
+ job.waitsafe = waitsafe;
+ job_unlock();
+ return(pid);
+}
+/*
+ * used with command -x to run the command in multiple passes
+ * spawn is non-zero when invoked via spawn
+ * the exitval is set to the maximum for each execution
+ */
+static pid_t path_xargs(const char *path, char *argv[],char *const envp[], int spawn)
+{
+ register char *cp, **av, **xv;
+ char **avlast= &argv[sh.xargmax], **saveargs=0;
+ char *const *ev;
+ long size, left;
+ int nlast=1,n,exitval=0;
+ pid_t pid;
+ if(sh.xargmin < 0)
+ return((pid_t)-1);
+ size = sh.lim.arg_max-1024;
+ for(ev=envp; cp= *ev; ev++)
+ size -= strlen(cp)-1;
+ for(av=argv; (cp= *av) && av< &argv[sh.xargmin]; av++)
+ size -= strlen(cp)-1;
+ for(av=avlast; cp= *av; av++,nlast++)
+ size -= strlen(cp)-1;
+ av = &argv[sh.xargmin];
+ if(!spawn)
+ job_clear();
+ sh.exitval = 0;
+ while(av<avlast)
+ {
+ for(xv=av,left=size; left>0 && av<avlast;)
+ left -= strlen(*av++)+1;
+ /* leave at least two for last */
+ if(left<0 && (avlast-av)<2)
+ av--;
+ if(xv==&argv[sh.xargmin])
+ {
+ n = nlast*sizeof(char*);
+ saveargs = (char**)malloc(n);
+ memcpy((void*)saveargs, (void*)av, n);
+ memcpy((void*)av,(void*)avlast,n);
+ }
+ else
+ {
+ for(n=sh.xargmin; xv < av; xv++)
+ argv[n++] = *xv;
+ for(xv=avlast; cp= *xv; xv++)
+ argv[n++] = cp;
+ argv[n] = 0;
+ }
+ if(saveargs || av<avlast || (exitval && !spawn))
+ {
+ if((pid=_spawnveg(path,argv,envp,0)) < 0)
+ return(-1);
+ job_post(pid,0);
+ job_wait(pid);
+ if(sh.exitval>exitval)
+ exitval = sh.exitval;
+ if(saveargs)
+ {
+ memcpy((void*)av,saveargs,n);
+ free((void*)saveargs);
+ saveargs = 0;
+ }
+ }
+ else if(spawn && !sh_isoption(SH_PFSH))
+ {
+ sh.xargexit = exitval;
+ return(_spawnveg(path,argv,envp,spawn>>1));
+ }
+ else
+ return((pid_t)path_pfexecve(path,argv,envp));
+ }
+ if(!spawn)
+ exit(exitval);
+ return((pid_t)-1);
+}
+
+/*
+ * make sure PWD is set up correctly
+ * Return the present working directory
+ * Invokes getcwd() if flag==0 and if necessary
+ * Sets the PWD variable to this value
+ */
+char *path_pwd(int flag)
+{
+ register char *cp;
+ register char *dfault = (char*)e_dot;
+ register int count = 0;
+ Shell_t *shp = &sh;
+ if(shp->pwd)
+ return((char*)shp->pwd);
+ while(1)
+ {
+ /* try from lowest to highest */
+ switch(count++)
+ {
+ case 0:
+ cp = nv_getval(PWDNOD);
+ break;
+ case 1:
+ cp = nv_getval(HOME);
+ break;
+ case 2:
+ cp = "/";
+ break;
+ case 3:
+ cp = (char*)e_crondir;
+ if(flag) /* skip next case when non-zero flag */
+ ++count;
+ break;
+ case 4:
+ {
+ if(cp=getcwd(NIL(char*),0))
+ {
+ nv_offattr(PWDNOD,NV_NOFREE);
+ nv_unset(PWDNOD);
+ PWDNOD->nvalue.cp = cp;
+ goto skip;
+ }
+ break;
+ }
+ case 5:
+ return(dfault);
+ }
+ if(cp && *cp=='/' && test_inode(cp,e_dot))
+ break;
+ }
+ if(count>1)
+ {
+ nv_offattr(PWDNOD,NV_NOFREE);
+ nv_putval(PWDNOD,cp,NV_RDONLY);
+ }
+skip:
+ nv_onattr(PWDNOD,NV_NOFREE|NV_EXPORT);
+ shp->pwd = (char*)(PWDNOD->nvalue.cp);
+ return(cp);
+}
+
+static void free_bltin(Namval_t *np,void *data)
+{
+ register Pathcomp_t *pp= (Pathcomp_t*)data;
+ if(pp->flags&PATH_STD_DIR)
+ {
+ int offset=staktell();;
+ if(strcmp(pp->name,"/bin")==0 || memcmp(pp->name,np->nvname,pp->len) || np->nvname[pp->len]!='/')
+ return;
+ stakputs("/bin");
+ stakputs(np->nvname+pp->len+1);
+ stakputc(0);
+ sh_addbuiltin(stakptr(offset),np->nvalue.bfp,NiL);
+ stakseek(offset);
+ return;
+ }
+ if((void*)np->nvenv==pp->bltin_lib)
+ dtdelete(sh_bltin_tree(),np);
+}
+
+/*
+ * delete current Pathcomp_t structure
+ */
+void path_delete(Pathcomp_t *first)
+{
+ register Pathcomp_t *pp=first, *old=0, *ppnext;
+ while(pp)
+ {
+ ppnext = pp->next;
+ if(--pp->refcount<=0)
+ {
+ if(pp->lib)
+ free((void*)pp->lib);
+ if(pp->blib)
+ free((void*)pp->blib);
+ if(pp->bltin_lib || (pp->flags&PATH_STD_DIR))
+ {
+ nv_scan(sh_bltin_tree(),free_bltin,pp,0,0);
+ if(pp->bltin_lib)
+ dlclose(pp->bltin_lib);
+ }
+ free((void*)pp);
+ if(old)
+ old->next = ppnext;
+ }
+ else
+ old = pp;
+ pp = ppnext;
+ }
+}
+
+/*
+ * returns library variable from .paths
+ * The value might be returned on the stack overwriting path
+ */
+static char *path_lib(Pathcomp_t *pp, char *path)
+{
+ register char *last = strrchr(path,'/');
+ register int r;
+ struct stat statb;
+ if(last)
+ *last = 0;
+ else
+ path = ".";
+ r = stat(path,&statb);
+ if(last)
+ *last = '/';
+ if(r>=0)
+ {
+ Pathcomp_t pcomp;
+ char save[8];
+ for( ;pp; pp=pp->next)
+ {
+ if(pp->ino==statb.st_ino && pp->dev==statb.st_dev)
+ return(pp->lib);
+ }
+ pcomp.len = 0;
+ if(last)
+ pcomp.len = last-path;
+ memcpy((void*)save, (void*)stakptr(PATH_OFFSET+pcomp.len),sizeof(save));
+ if(path_chkpaths((Pathcomp_t*)0,(Pathcomp_t*)0,&pcomp,PATH_OFFSET))
+ return(stakfreeze(1));
+ memcpy((void*)stakptr(PATH_OFFSET+pcomp.len),(void*)save,sizeof(save));
+ }
+ return(0);
+}
+
+#if 0
+void path_dump(register Pathcomp_t *pp)
+{
+ sfprintf(sfstderr,"dump\n");
+ while(pp)
+ {
+ sfprintf(sfstderr,"pp=%x dev=%d ino=%d len=%d flags=%o name=%.*s\n",
+ pp,pp->dev,pp->ino,pp->len,pp->flags,pp->len,pp->name);
+ pp = pp->next;
+ }
+}
+#endif
+
+/*
+ * write the next path to search on the current stack
+ * if last is given, all paths that come before <last> are skipped
+ * the next pathcomp is returned.
+ */
+Pathcomp_t *path_nextcomp(register Pathcomp_t *pp, const char *name, Pathcomp_t *last)
+{
+ stakseek(PATH_OFFSET);
+ if(*name=='/')
+ pp = 0;
+ else
+ {
+ for(;pp && pp!=last;pp=pp->next)
+ {
+ if(pp->flags&PATH_SKIP)
+ continue;
+ if(!last || *pp->name!='/')
+ break;
+ }
+ if(!pp) /* this should not happen */
+ pp = last;
+ }
+ if(pp && (pp->name[0]!='.' || pp->name[1]))
+ {
+ if(*pp->name!='/')
+ {
+ stakputs(path_pwd(1));
+ if(*stakptr(staktell()-1)!='/')
+ stakputc('/');
+ }
+ stakwrite(pp->name,pp->len);
+ if(pp->name[pp->len-1]!='/')
+ stakputc('/');
+ }
+ stakputs(name);
+ stakputc(0);
+ while(pp && pp!=last && (pp=pp->next))
+ {
+ if(!(pp->flags&PATH_SKIP))
+ return(pp);
+ }
+ return((Pathcomp_t*)0);
+}
+
+static Pathcomp_t* defpath_init(Shell_t *shp)
+{
+ Pathcomp_t *pp = (void*)path_addpath((Pathcomp_t*)0,(std_path),PATH_PATH);
+ if(shp->defpathlist = (void*)pp)
+ pp->shp = shp;
+ return(pp);
+}
+
+static void path_init(Shell_t *shp)
+{
+ const char *val;
+ Pathcomp_t *pp;
+ if(!std_path && !(std_path=astconf("PATH",NIL(char*),NIL(char*))))
+ std_path = e_defpath;
+ if(val=nv_scoped((PATHNOD))->nvalue.cp)
+ {
+ pp = (void*)path_addpath((Pathcomp_t*)shp->pathlist,val,PATH_PATH);
+ if(shp->pathlist = (void*)pp)
+ pp->shp = shp;
+ }
+ else
+ {
+ if(!(pp=(Pathcomp_t*)shp->defpathlist))
+ pp = defpath_init(shp);
+ shp->pathlist = (void*)path_dup(pp);
+ }
+ if(val=nv_scoped((FPATHNOD))->nvalue.cp)
+ {
+ pp = (void*)path_addpath((Pathcomp_t*)shp->pathlist,val,PATH_FPATH);
+ if(shp->pathlist = (void*)pp)
+ pp->shp = shp;
+ }
+}
+
+/*
+ * returns that pathlist to search
+ */
+Pathcomp_t *path_get(register const char *name)
+{
+ register Shell_t *shp = &sh;
+ register Pathcomp_t *pp=0;
+ if(*name && strchr(name,'/'))
+ return(0);
+ if(!sh_isstate(SH_DEFPATH))
+ {
+ if(!shp->pathlist)
+ path_init(shp);
+ pp = (Pathcomp_t*)shp->pathlist;
+ }
+ if(!pp && (!(PATHNOD)->nvalue.cp) || sh_isstate(SH_DEFPATH))
+ {
+ if(!(pp=(Pathcomp_t*)shp->defpathlist))
+ pp = defpath_init(shp);
+ }
+ return(pp);
+}
+
+/*
+ * open file corresponding to name using path give by <pp>
+ */
+static int path_opentype(const char *name, register Pathcomp_t *pp, int fun)
+{
+ register int fd= -1;
+ struct stat statb;
+ Pathcomp_t *oldpp;
+ Shell_t *shp;
+ if(pp)
+ shp = pp->shp;
+ else
+ {
+ shp = sh_getinterp();
+ if(!shp->pathlist)
+ path_init(shp);
+ }
+ if(!fun && strchr(name,'/'))
+ {
+ if(sh_isoption(SH_RESTRICTED))
+ errormsg(SH_DICT,ERROR_exit(1),e_restricted,name);
+ }
+ do
+ {
+ pp = path_nextcomp(oldpp=pp,name,0);
+ while(oldpp && (oldpp->flags&PATH_SKIP))
+ oldpp = oldpp->next;
+ if(fun && (!oldpp || !(oldpp->flags&PATH_FPATH)))
+ continue;
+ if((fd = sh_open(path_relative(stakptr(PATH_OFFSET)),O_RDONLY,0)) >= 0)
+ {
+ if(fstat(fd,&statb)<0 || S_ISDIR(statb.st_mode))
+ {
+ errno = EISDIR;
+ sh_close(fd);
+ fd = -1;
+ }
+ }
+ }
+ while( fd<0 && pp);
+ if(fd>=0 && (fd = sh_iomovefd(fd)) > 0)
+ {
+ fcntl(fd,F_SETFD,FD_CLOEXEC);
+ shp->fdstatus[fd] |= IOCLEX;
+ }
+ return(fd);
+}
+
+/*
+ * open file corresponding to name using path give by <pp>
+ */
+int path_open(const char *name, register Pathcomp_t *pp)
+{
+ return(path_opentype(name,pp,0));
+}
+
+/*
+ * given a pathname return the base name
+ */
+
+char *path_basename(register const char *name)
+{
+ register const char *start = name;
+ while (*name)
+ if ((*name++ == '/') && *name) /* don't trim trailing / */
+ start = name;
+ return ((char*)start);
+}
+
+char *path_fullname(const char *name)
+{
+ int len=strlen(name)+1,dirlen=0;
+ char *path,*pwd;
+ if(*name!='/')
+ {
+ pwd = path_pwd(1);
+ dirlen = strlen(pwd)+1;
+ }
+ path = (char*)malloc(len+dirlen);
+ if(dirlen)
+ {
+ memcpy((void*)path,(void*)pwd,dirlen);
+ path[dirlen-1] = '/';
+ }
+ memcpy((void*)&path[dirlen],(void*)name,len);
+ pathcanon(path,0);
+ return(path);
+}
+
+/*
+ * load functions from file <fno>
+ */
+static void funload(Shell_t *shp,int fno, const char *name)
+{
+ char *oldname=shp->st.filename, buff[IOBSIZE+1];
+ int savestates = sh_getstate();
+ sh_onstate(SH_NOLOG);
+ sh_onstate(SH_NOALIAS);
+ shp->readscript = (char*)name;
+ shp->st.filename = path_fullname(stakptr(PATH_OFFSET));
+ error_info.line = 0;
+ sh_eval(sfnew(NIL(Sfio_t*),buff,IOBSIZE,fno,SF_READ),0);
+ shp->readscript = 0;
+ free((void*)shp->st.filename);
+ shp->st.filename = oldname;
+ sh_setstate(savestates);
+}
+
+/*
+ * do a path search and track alias if requested
+ * if flag is 0, or if name not found, then try autoloading function
+ * if flag==2, returns 1 if name found on FPATH
+ * returns 1, if function was autoloaded.
+ * If endpath!=NULL, Path search ends when path matches endpath.
+ */
+
+int path_search(register const char *name,Pathcomp_t *endpath, int flag)
+{
+ register Namval_t *np;
+ register int fno;
+ Pathcomp_t *pp=0;
+ Shell_t *shp = &sh;
+ if(name && strchr(name,'/'))
+ {
+ stakseek(PATH_OFFSET);
+ stakputs(name);
+ if(canexecute(stakptr(PATH_OFFSET),0)<0)
+ {
+ *stakptr(PATH_OFFSET) = 0;
+ return(0);
+ }
+ if(*name=='/')
+ return(1);
+ stakseek(PATH_OFFSET);
+ stakputs(path_pwd(1));
+ stakputc('/');
+ stakputs(name);
+ stakputc(0);
+ return(0);
+ }
+ if(sh_isstate(SH_DEFPATH))
+ {
+ if(!shp->defpathlist)
+ defpath_init(shp);
+ }
+ else if(!shp->pathlist)
+ path_init(shp);
+ if(flag)
+ {
+ if(!(pp=path_absolute(name,endpath)) && endpath)
+ pp = path_absolute(name,NIL(Pathcomp_t*));
+ if(!pp && (np=nv_search(name,sh.fun_tree,HASH_NOSCOPE))&&np->nvalue.ip)
+ return(1);
+ if(!pp)
+ *stakptr(PATH_OFFSET) = 0;
+ }
+ if(flag==0 || !pp || (pp->flags&PATH_FPATH))
+ {
+ if(!pp)
+ pp=sh_isstate(SH_DEFPATH)?shp->defpathlist:shp->pathlist;
+ if(pp && strmatch(name,e_alphanum) && (fno=path_opentype(name,pp,1))>=0)
+ {
+ if(flag==2)
+ {
+ sh_close(fno);
+ return(1);
+ }
+ funload(shp,fno,name);
+ return(1);
+ }
+ *stakptr(PATH_OFFSET) = 0;
+ return(0);
+ }
+ else if(pp && !sh_isstate(SH_DEFPATH) && *name!='/')
+ {
+ if(np=nv_search(name,shp->track_tree,NV_ADD))
+ path_alias(np,pp);
+ }
+ return(0);
+}
+
+
+/*
+ * do a path search and find the full pathname of file name
+ * end search of path matches endpath without checking execute permission
+ */
+
+Pathcomp_t *path_absolute(register const char *name, Pathcomp_t *endpath)
+{
+ register int f,isfun;
+ int noexec=0;
+ Pathcomp_t *pp,*oldpp;
+ Shell_t *shp = &sh;
+ Namval_t *np;
+ shp->path_err = ENOENT;
+ if(!(pp=path_get("")))
+ return(0);
+ shp->path_err = 0;
+ while(1)
+ {
+ sh_sigcheck();
+ isfun = (pp->flags&PATH_FPATH);
+ if(oldpp=pp)
+ pp = path_nextcomp(pp,name,0);
+ if(endpath)
+ return(endpath);
+ if(!isfun && !sh_isoption(SH_RESTRICTED))
+ {
+ if(nv_search(stakptr(PATH_OFFSET),sh.bltin_tree,0))
+ return(oldpp);
+ if(oldpp->blib)
+ {
+ typedef int (*Fptr_t)(int, char*[], void*);
+ Fptr_t addr;
+ int n = staktell();
+ char *cp;
+ stakputs("b_");
+ stakputs(name);
+ stakputc(0);
+ if(!oldpp->bltin_lib)
+ {
+ if(cp = strrchr(oldpp->blib,'/'))
+ cp++;
+ else
+ cp = oldpp->blib;
+ if(strcmp(cp,LIBCMD)==0 && (addr=(Fptr_t)dlllook((void*)0,stakptr(n))))
+ {
+ np = sh_addbuiltin(stakptr(PATH_OFFSET),addr,NiL);
+ np->nvfun = (Namfun_t*)np->nvname;
+ return(oldpp);
+ }
+#if (_AST_VERSION>=20040404)
+ if (oldpp->bltin_lib = dllplug(SH_ID, oldpp->blib, NiL, RTLD_LAZY, NiL, 0))
+#else
+ if (oldpp->bltin_lib = dllfind(oldpp->blib, NiL, RTLD_LAZY, NiL, 0))
+#endif
+ sh_addlib(oldpp->bltin_lib);
+ }
+ if((addr=(Fptr_t)dlllook(oldpp->bltin_lib,stakptr(n))) &&
+ (!(np = sh_addbuiltin(stakptr(PATH_OFFSET),NiL,NiL)) || np->nvalue.bfp!=addr) &&
+ (np = sh_addbuiltin(stakptr(PATH_OFFSET),addr,NiL)))
+ {
+ np->nvenv = oldpp->bltin_lib;
+ return(oldpp);
+ }
+ }
+ }
+ f = canexecute(stakptr(PATH_OFFSET),isfun);
+ if(isfun && f>=0)
+ {
+ nv_onattr(nv_open(name,shp->fun_tree,NV_NOARRAY|NV_IDENT|NV_NOSCOPE),NV_LTOU|NV_FUNCTION);
+ close(f);
+ f = -1;
+ return(0);
+ }
+ else if(f>=0 && (oldpp->flags & PATH_STD_DIR))
+ {
+ int offset = staktell();
+ stakputs("/bin/");
+ stakputs(name);
+ stakputc(0);
+ np = nv_search(stakptr(offset),sh.bltin_tree,0);
+ stakseek(offset);
+ if(np)
+ {
+ np = sh_addbuiltin(stakptr(PATH_OFFSET),np->nvalue.bfp,NiL);
+ np->nvfun = (Namfun_t*)np->nvname;
+ }
+ }
+ if(!pp || f>=0)
+ break;
+ if(errno!=ENOENT)
+ noexec = errno;
+ }
+ if(f<0)
+ {
+ if(!endpath)
+ shp->path_err = (noexec?noexec:ENOENT);
+ return(0);
+ }
+ stakputc(0);
+ return(oldpp);
+}
+
+/*
+ * returns 0 if path can execute
+ * sets exec_err if file is found but can't be executable
+ */
+#undef S_IXALL
+#ifdef S_IXUSR
+# define S_IXALL (S_IXUSR|S_IXGRP|S_IXOTH)
+#else
+# ifdef S_IEXEC
+# define S_IXALL (S_IEXEC|(S_IEXEC>>3)|(S_IEXEC>>6))
+# else
+# define S_IXALL 0111
+# endif /*S_EXEC */
+#endif /* S_IXUSR */
+
+static int canexecute(register char *path, int isfun)
+{
+ struct stat statb;
+ register int fd=0;
+ path = path_relative(path);
+ if(isfun)
+ {
+ if((fd=open(path,O_RDONLY,0))<0 || fstat(fd,&statb)<0)
+ goto err;
+ }
+ else if(stat(path,&statb) < 0)
+ {
+#if _WINIX
+ /* check for .exe or .bat suffix */
+ char *cp;
+ if(errno==ENOENT && (!(cp=strrchr(path,'.')) || strlen(cp)>4 || strchr(cp,'/')))
+ {
+ int offset = staktell()-1;
+ stakseek(offset);
+ stakputs(".bat");
+ path = stakptr(PATH_OFFSET);
+ if(stat(path,&statb) < 0)
+ {
+ if(errno!=ENOENT)
+ goto err;
+ memcpy(stakptr(offset),".sh",4);
+ if(stat(path,&statb) < 0)
+ goto err;
+ }
+ }
+ else
+#endif /* _WINIX */
+ goto err;
+ }
+ errno = EPERM;
+ if(S_ISDIR(statb.st_mode))
+ errno = EISDIR;
+ else if((statb.st_mode&S_IXALL)==S_IXALL || sh_access(path,X_OK)>=0)
+ return(fd);
+ if(isfun && fd>=0)
+ sh_close(fd);
+err:
+ return(-1);
+}
+
+/*
+ * Return path relative to present working directory
+ */
+
+char *path_relative(register const char* file)
+{
+ register const char *pwd;
+ register const char *fp = file;
+ /* can't relpath when sh.pwd not set */
+ if(!(pwd=sh.pwd))
+ return((char*)fp);
+ while(*pwd==*fp)
+ {
+ if(*pwd++==0)
+ return((char*)e_dot);
+ fp++;
+ }
+ if(*pwd==0 && *fp == '/')
+ {
+ while(*++fp=='/');
+ if(*fp)
+ return((char*)fp);
+ return((char*)e_dot);
+ }
+ return((char*)file);
+}
+
+void path_exec(register const char *arg0,register char *argv[],struct argnod *local)
+{
+ char **envp;
+ const char *opath;
+ Pathcomp_t *libpath, *pp=0;
+ Shell_t *shp = &sh;
+ int slash=0;
+ nv_setlist(local,NV_EXPORT|NV_IDENT|NV_ASSIGN);
+ envp = sh_envgen();
+ if(strchr(arg0,'/'))
+ {
+ slash=1;
+ /* name containing / not allowed for restricted shell */
+ if(sh_isoption(SH_RESTRICTED))
+ errormsg(SH_DICT,ERROR_exit(1),e_restricted,arg0);
+ }
+ else
+ pp=path_get(arg0);
+ shp->path_err= ENOENT;
+ sfsync(NIL(Sfio_t*));
+ timerdel(NIL(void*));
+ /* find first path that has a library component */
+ if(pp || slash) do
+ {
+ sh_sigcheck();
+ if(libpath=pp)
+ {
+ pp = path_nextcomp(pp,arg0,0);
+ opath = stakfreeze(1)+PATH_OFFSET;
+ }
+ else
+ opath = arg0;
+ path_spawn(opath,argv,envp,libpath,0);
+ while(pp && (pp->flags&PATH_FPATH))
+ pp = path_nextcomp(pp,arg0,0);
+ }
+ while(pp);
+ /* force an exit */
+ ((struct checkpt*)shp->jmplist)->mode = SH_JMPEXIT;
+ if((errno=shp->path_err)==ENOENT)
+ errormsg(SH_DICT,ERROR_exit(ERROR_NOENT),e_found,arg0);
+ else
+ errormsg(SH_DICT,ERROR_system(ERROR_NOEXEC),e_exec,arg0);
+}
+
+pid_t path_spawn(const char *opath,register char **argv, char **envp, Pathcomp_t *libpath, int spawn)
+{
+ Shell_t *shp = sh_getinterp();
+ register char *path;
+ char **xp=0, *xval, *libenv = (libpath?libpath->lib:0);
+ Namval_t* np;
+ char *s, *v;
+ int r, n;
+ pid_t pid= -1;
+ /* leave room for inserting _= pathname in environment */
+ envp--;
+#if _lib_readlink
+ /* save original pathname */
+ stakseek(PATH_OFFSET);
+ stakputs(opath);
+ opath = stakfreeze(1)+PATH_OFFSET;
+ np=nv_search(argv[0],shp->track_tree,0);
+ while(libpath && !libpath->lib)
+ libpath=libpath->next;
+ if(libpath && (!np || nv_size(np)>0))
+ {
+ /* check for symlink and use symlink name */
+ char buff[PATH_MAX+1];
+ char save[PATH_MAX+1];
+ stakseek(PATH_OFFSET);
+ stakputs(opath);
+ path = stakptr(PATH_OFFSET);
+ while((n=readlink(path,buff,PATH_MAX))>0)
+ {
+ buff[n] = 0;
+ n = PATH_OFFSET;
+ r = 0;
+ if((v=strrchr(path,'/')) && *buff!='/')
+ {
+ if(buff[0]=='.' && buff[1]=='.' && (r = strlen(path) + 1) <= PATH_MAX)
+ memcpy(save, path, r);
+ else
+ r = 0;
+ n += (v+1-path);
+ }
+ stakseek(n);
+ stakputs(buff);
+ stakputc(0);
+ path = stakptr(PATH_OFFSET);
+ if(v && buff[0]=='.' && buff[1]=='.')
+ {
+ pathcanon(path, 0);
+ if(r && access(path,X_OK))
+ {
+ memcpy(path, save, r);
+ break;
+ }
+ }
+ if(libenv = path_lib(libpath,path))
+ break;
+ }
+ stakseek(0);
+ }
+#endif
+ if(libenv && (v = strchr(libenv,'=')))
+ {
+ n = v - libenv;
+ *v = 0;
+ np = nv_open(libenv,shp->var_tree,0);
+ *v = '=';
+ s = nv_getval(np);
+ stakputs(libenv);
+ if(s)
+ {
+ stakputc(':');
+ stakputs(s);
+ }
+ v = stakfreeze(1);
+ r = 1;
+ xp = envp + 2;
+ while (s = *xp++)
+ {
+ if (strneq(s, v, n) && s[n] == '=')
+ {
+ xval = *--xp;
+ *xp = v;
+ r = 0;
+ break;
+ }
+ }
+ if (r)
+ {
+ *envp-- = v;
+ xp = 0;
+ }
+ }
+ if(!opath)
+ opath = stakptr(PATH_OFFSET);
+ envp[0] = (char*)opath-PATH_OFFSET;
+ envp[0][0] = '_';
+ envp[0][1] = '=';
+ sfsync(sfstderr);
+ sh_sigcheck();
+ path = path_relative(opath);
+#ifdef SHELLMAGIC
+ if(*path!='/' && path!=opath)
+ {
+ /*
+ * The following code because execv(foo,) and execv(./foo,)
+ * may not yield the same results
+ */
+ char *sp = (char*)malloc(strlen(path)+3);
+ sp[0] = '.';
+ sp[1] = '/';
+ strcpy(sp+2,path);
+ path = sp;
+ }
+#endif /* SHELLMAGIC */
+ if(sh_isoption(SH_RESTRICTED))
+ {
+ int fd;
+ if((fd = sh_open(opath,O_RDONLY,0)) >= 0)
+ {
+ char buff[PATH_MAX];
+ n = read(fd,buff,sizeof(buff));
+ close(fd);
+ if(n>2 && buff[0]=='#' && buff[1]=='!')
+ {
+ for(s=buff; n>0 && *s!='\n'; n--,s++)
+ {
+ if(*s=='/')
+ errormsg(SH_DICT,ERROR_exit(1),e_restricted,opath);
+ }
+ }
+ }
+ }
+ if(spawn && !sh_isoption(SH_PFSH))
+ pid = _spawnveg(opath, &argv[0],envp, spawn>>1);
+ else
+ path_pfexecve(opath, &argv[0] ,envp);
+ if(xp)
+ *xp = xval;
+#ifdef SHELLMAGIC
+ if(*path=='.' && path!=opath)
+ {
+ free(path);
+ path = path_relative(opath);
+ }
+#endif /* SHELLMAGIC */
+ if(pid>0)
+ return(pid);
+retry:
+ switch(sh.path_err = errno)
+ {
+#ifdef apollo
+ /*
+ * On apollo's execve will fail with eacces when
+ * file has execute but not read permissions. So,
+ * for now we will pretend that EACCES and ENOEXEC
+ * mean the same thing.
+ */
+ case EACCES:
+#endif /* apollo */
+ case ENOEXEC:
+#if SHOPT_SUID_EXEC
+ case EPERM:
+ /* some systems return EPERM if setuid bit is on */
+#endif
+ errno = ENOEXEC;
+ if(spawn)
+ {
+#ifdef _lib_fork
+ if(sh.subshell)
+ return(-1);
+ do
+ {
+ if((pid=fork())>0)
+ return(pid);
+ }
+ while(_sh_fork(pid,0,(int*)0) < 0);
+#else
+ return(-1);
+#endif
+ }
+ exscript(shp,path,argv,envp);
+#ifndef apollo
+ case EACCES:
+ {
+ struct stat statb;
+ if(stat(path,&statb)>=0)
+ {
+ if(S_ISDIR(statb.st_mode))
+ errno = EISDIR;
+#ifdef S_ISSOCK
+ if(S_ISSOCK(statb.st_mode))
+ exscript(shp,path,argv,envp);
+#endif
+ }
+ }
+ /* FALL THROUGH */
+#endif /* !apollo */
+#ifdef ENAMETOOLONG
+ case ENAMETOOLONG:
+#endif /* ENAMETOOLONG */
+#if !SHOPT_SUID_EXEC
+ case EPERM:
+#endif
+ shp->path_err = errno;
+ return(-1);
+ case ENOTDIR:
+ case ENOENT:
+ case EINTR:
+#ifdef EMLINK
+ case EMLINK:
+#endif /* EMLINK */
+ return(-1);
+ case E2BIG:
+ if(sh.xargmin)
+ {
+ pid = path_xargs(opath, &argv[0] ,envp,spawn);
+ if(pid<0)
+ goto retry;
+ return(pid);
+ }
+ default:
+ errormsg(SH_DICT,ERROR_system(ERROR_NOEXEC),e_exec,path);
+ }
+ return 0;
+}
+
+/*
+ * File is executable but not machine code.
+ * Assume file is a Shell script and execute it.
+ */
+
+static void exscript(Shell_t *shp,register char *path,register char *argv[],char **envp)
+{
+ register Sfio_t *sp;
+ path = path_relative(path);
+ shp->comdiv=0;
+ shp->bckpid = 0;
+ shp->st.ioset=0;
+ /* clean up any cooperating processes */
+ if(shp->cpipe[0]>0)
+ sh_pclose(shp->cpipe);
+ if(shp->cpid && shp->outpipe)
+ sh_close(*shp->outpipe);
+ shp->cpid = 0;
+ if(sp=fcfile())
+ while(sfstack(sp,SF_POPSTACK));
+ job_clear();
+ if(shp->infd>0 && (shp->fdstatus[shp->infd]&IOCLEX))
+ sh_close(shp->infd);
+ sh_setstate(sh_state(SH_FORKED));
+ sfsync(sfstderr);
+#if SHOPT_SUID_EXEC && !SHOPT_PFSH
+ /* check if file cannot open for read or script is setuid/setgid */
+ {
+ static char name[] = "/tmp/euidXXXXXXXXXX";
+ register int n;
+ register uid_t euserid;
+ char *savet=0;
+ struct stat statb;
+ if((n=sh_open(path,O_RDONLY,0)) >= 0)
+ {
+ /* move <n> if n=0,1,2 */
+ n = sh_iomovefd(n);
+ if(fstat(n,&statb)>=0 && !(statb.st_mode&(S_ISUID|S_ISGID)))
+ goto openok;
+ sh_close(n);
+ }
+ if((euserid=geteuid()) != shp->userid)
+ {
+ strncpy(name+9,fmtbase((long)getpid(),10,0),sizeof(name)-10);
+ /* create a suid open file with owner equal effective uid */
+ if((n=open(name,O_CREAT|O_TRUNC|O_WRONLY,S_ISUID|S_IXUSR)) < 0)
+ goto fail;
+ unlink(name);
+ /* make sure that file has right owner */
+ if(fstat(n,&statb)<0 || statb.st_uid != euserid)
+ goto fail;
+ if(n!=10)
+ {
+ sh_close(10);
+ fcntl(n, F_DUPFD, 10);
+ sh_close(n);
+ n=10;
+ }
+ }
+ savet = *--argv;
+ *argv = path;
+ path_pfexecve(e_suidexec,argv,envp);
+ fail:
+ /*
+ * The following code is just for compatibility
+ */
+ if((n=open(path,O_RDONLY,0)) < 0)
+ errormsg(SH_DICT,ERROR_system(1),e_open,path);
+ if(savet)
+ *argv++ = savet;
+ openok:
+ shp->infd = n;
+ }
+#else
+ shp->infd = sh_chkopen(path);
+#endif
+ shp->infd = sh_iomovefd(shp->infd);
+#if SHOPT_ACCT
+ sh_accbegin(path) ; /* reset accounting */
+#endif /* SHOPT_ACCT */
+ shp->arglist = sh_argcreate(argv);
+ shp->lastarg = strdup(path);
+ /* save name of calling command */
+ shp->readscript = error_info.id;
+ /* close history file if name has changed */
+ if(shp->hist_ptr && (path=nv_getval(HISTFILE)) && strcmp(path,shp->hist_ptr->histname))
+ {
+ hist_close(shp->hist_ptr);
+ (HISTCUR)->nvalue.lp = 0;
+ }
+ sh_offstate(SH_FORKED);
+ siglongjmp(*shp->jmplist,SH_JMPSCRIPT);
+}
+
+#if SHOPT_ACCT
+# include <sys/acct.h>
+# include "FEATURE/time"
+
+ static struct acct sabuf;
+ static struct tms buffer;
+ static clock_t before;
+ static char *SHACCT; /* set to value of SHACCT environment variable */
+ static shaccton; /* non-zero causes accounting record to be written */
+ static int compress(time_t);
+ /*
+ * initialize accounting, i.e., see if SHACCT variable set
+ */
+ void sh_accinit(void)
+ {
+ SHACCT = getenv("SHACCT");
+ }
+ /*
+ * suspend accounting unitl turned on by sh_accbegin()
+ */
+ void sh_accsusp(void)
+ {
+ shaccton=0;
+#ifdef AEXPAND
+ sabuf.ac_flag |= AEXPND;
+#endif /* AEXPAND */
+ }
+
+ /*
+ * begin an accounting record by recording start time
+ */
+ void sh_accbegin(const char *cmdname)
+ {
+ if(SHACCT)
+ {
+ sabuf.ac_btime = time(NIL(time_t *));
+ before = times(&buffer);
+ sabuf.ac_uid = getuid();
+ sabuf.ac_gid = getgid();
+ strncpy(sabuf.ac_comm, (char*)path_basename(cmdname),
+ sizeof(sabuf.ac_comm));
+ shaccton = 1;
+ }
+ }
+ /*
+ * terminate an accounting record and append to accounting file
+ */
+ void sh_accend(void)
+ {
+ int fd;
+ clock_t after;
+
+ if(shaccton)
+ {
+ after = times(&buffer);
+ sabuf.ac_utime = compress(buffer.tms_utime + buffer.tms_cutime);
+ sabuf.ac_stime = compress(buffer.tms_stime + buffer.tms_cstime);
+ sabuf.ac_etime = compress( (time_t)(after-before));
+ fd = open( SHACCT , O_WRONLY | O_APPEND | O_CREAT,RW_ALL);
+ write(fd, (const char*)&sabuf, sizeof( sabuf ));
+ close( fd);
+ }
+ }
+
+ /*
+ * Produce a pseudo-floating point representation
+ * with 3 bits base-8 exponent, 13 bits fraction.
+ */
+ static int compress(register time_t t)
+ {
+ register int exp = 0, rund = 0;
+
+ while (t >= 8192)
+ {
+ exp++;
+ rund = t&04;
+ t >>= 3;
+ }
+ if (rund)
+ {
+ t++;
+ if (t >= 8192)
+ {
+ t >>= 3;
+ exp++;
+ }
+ }
+ return((exp<<13) + t);
+ }
+#endif /* SHOPT_ACCT */
+
+
+
+/*
+ * add a pathcomponent to the path search list and eliminate duplicates
+ * and non-existing absolute paths.
+ */
+static Pathcomp_t *path_addcomp(Pathcomp_t *first, Pathcomp_t *old,const char *name, int flag)
+{
+ register Pathcomp_t *pp, *oldpp;
+ struct stat statb;
+ int len, offset=staktell();
+ if(!(flag&PATH_BFPATH))
+ {
+ register const char *cp = name;
+ while(*cp && *cp!=':')
+ stakputc(*cp++);
+ len = staktell()-offset;
+ stakputc(0);
+ stakseek(offset);
+ name = (const char*)stakptr(offset);
+ }
+ else
+ len = strlen(name);
+ for(pp=first; pp; pp=pp->next)
+ {
+ if(memcmp(name,pp->name,len)==0 && (pp->name[len]==':' || pp->name[len]==0))
+ {
+ pp->flags |= flag;
+ return(first);
+ }
+ }
+ if(old && (old=path_dirfind(old,name,0)))
+ {
+ statb.st_ino = old->ino;
+ statb.st_dev = old->dev;
+ if(old->ino==0 && old->dev==0)
+ flag |= PATH_SKIP;
+ }
+ else if(stat(name,&statb)<0 || !S_ISDIR(statb.st_mode))
+ {
+ if(*name=='/')
+ {
+ if(strcmp(name,SH_CMDLIB_DIR))
+ return(first);
+ statb.st_dev = 1;
+ }
+ else
+ {
+ flag |= PATH_SKIP;
+ statb.st_dev = 0;
+ }
+ statb.st_ino = 0;
+ }
+ if(*name=='/' && onstdpath(name))
+ flag |= PATH_STD_DIR;
+ for(pp=first, oldpp=0; pp; oldpp=pp, pp=pp->next)
+ {
+ if(pp->ino==statb.st_ino && pp->dev==statb.st_dev)
+ {
+ /* if both absolute paths, eliminate second */
+ pp->flags |= flag;
+ if(*name=='/' && *pp->name=='/')
+ return(first);
+ /* keep the path but mark it as skip */
+ flag |= PATH_SKIP;
+ }
+ }
+ pp = newof((Pathcomp_t*)0,Pathcomp_t,1,len+1);
+ pp->refcount = 1;
+ memcpy((char*)(pp+1),name,len+1);
+ pp->name = (char*)(pp+1);
+ pp->len = len;
+ pp->dev = statb.st_dev;
+ pp->ino = statb.st_ino;
+ if(oldpp)
+ oldpp->next = pp;
+ else
+ first = pp;
+ pp->flags = flag;
+ if(pp->ino==0 && pp->dev==1)
+ {
+ pp->flags |= PATH_BUILTIN_LIB;
+ pp->blib = malloc(4);
+ strcpy(pp->blib,LIBCMD);
+ return(first);
+ }
+ if((flag&(PATH_PATH|PATH_SKIP))==PATH_PATH)
+ path_chkpaths(first,old,pp,offset);
+ return(first);
+}
+
+/*
+ * This function checks for the .paths file in directory in <pp>
+ * it assumes that the directory is on the stack at <offset>
+ */
+static int path_chkpaths(Pathcomp_t *first, Pathcomp_t* old,Pathcomp_t *pp, int offset)
+{
+ struct stat statb;
+ int k,m,n,fd;
+ char *sp,*cp,*ep;
+ stakseek(offset+pp->len);
+ if(pp->len==1 && *stakptr(offset)=='/')
+ stakseek(offset);
+ stakputs("/.paths");
+ if((fd=open(stakptr(offset),O_RDONLY))>=0)
+ {
+ fstat(fd,&statb);
+ n = statb.st_size;
+ stakseek(offset+pp->len+n+2);
+ sp = stakptr(offset+pp->len);
+ *sp++ = '/';
+ n=read(fd,cp=sp,n);
+ sp[n] = 0;
+ close(fd);
+ for(ep=0; n--; cp++)
+ {
+ if(*cp=='=')
+ {
+ ep = cp+1;
+ continue;
+ }
+ else if(*cp!='\r' && *cp!='\n')
+ continue;
+ if(*sp=='#' || sp==cp)
+ {
+ sp = cp+1;
+ continue;
+ }
+ *cp = 0;
+ m = ep ? (ep-sp) : 0;
+ if(!m || m==6 && memcmp((void*)sp,(void*)"FPATH=",6)==0)
+ {
+ if(first)
+ {
+ char *ptr = stakptr(offset+pp->len+1);
+ if(ep)
+ strcpy(ptr,ep);
+ path_addcomp(first,old,stakptr(offset),PATH_FPATH|PATH_BFPATH);
+ }
+ }
+ else if(m==12 && memcmp((void*)sp,(void*)"BUILTIN_LIB=",12)==0)
+ {
+ if(!(pp->flags & PATH_BUILTIN_LIB))
+ {
+ pp->flags |= PATH_BUILTIN_LIB;
+ if (*ep == '.' && !*(ep + 1))
+ pp->flags |= PATH_STD_DIR;
+ else
+ {
+ k = strlen(ep)+1;
+ if (*ep != '/')
+ k += pp->len+1;
+ pp->blib = sp = malloc(k);
+ if (*ep != '/')
+ {
+ strcpy(pp->blib,pp->name);
+ sp += pp->len;
+ *sp++ = '/';
+ }
+ strcpy(sp,ep);
+ }
+ }
+ }
+ else if(m)
+ {
+ pp->lib = (char*)malloc(cp-sp+pp->len+2);
+ memcpy((void*)pp->lib,(void*)sp,m);
+ memcpy((void*)&pp->lib[m],stakptr(offset),pp->len);
+ pp->lib[k=m+pp->len] = '/';
+ strcpy((void*)&pp->lib[k+1],ep);
+ pathcanon(&pp->lib[m],0);
+ if(!first)
+ {
+ stakseek(0);
+ stakputs(pp->lib);
+ free((void*)pp->lib);
+ return(1);
+ }
+ }
+ sp = cp+1;
+ ep = 0;
+ }
+ }
+ return(0);
+}
+
+
+Pathcomp_t *path_addpath(Pathcomp_t *first, register const char *path,int type)
+{
+ register const char *cp;
+ Pathcomp_t *old=0;
+ int offset = staktell();
+ char *savptr;
+
+ if(!path && type!=PATH_PATH)
+ return(first);
+ if(type!=PATH_FPATH)
+ {
+ old = first;
+ first = 0;
+ }
+ if(offset)
+ savptr = stakfreeze(0);
+ if(path) while(*(cp=path))
+ {
+ if(*cp==':')
+ {
+ if(type!=PATH_FPATH)
+ first = path_addcomp(first,old,".",type);
+ while(*++path == ':');
+ }
+ else
+ {
+ int c;
+ while(*path && *path!=':')
+ path++;
+ c = *path++;
+ first = path_addcomp(first,old,cp,type);
+ if(c==0)
+ break;
+ if(*path==0)
+ path--;
+ }
+ }
+ if(old)
+ {
+ if(!first && !path)
+ {
+ Pathcomp_t *pp = (Pathcomp_t*)old->shp->defpathlist;
+ if(!pp)
+ pp = defpath_init(old->shp);
+ first = path_dup(pp);
+ }
+ if(cp=(FPATHNOD)->nvalue.cp)
+ first = (void*)path_addpath((Pathcomp_t*)first,cp,PATH_FPATH);
+ path_delete(old);
+ }
+ if(offset)
+ stakset(savptr,offset);
+ else
+ stakseek(0);
+ return(first);
+}
+
+/*
+ * duplicate the path give by <first> by incremented reference counts
+ */
+Pathcomp_t *path_dup(Pathcomp_t *first)
+{
+ register Pathcomp_t *pp=first;
+ while(pp)
+ {
+ pp->refcount++;
+ pp = pp->next;
+ }
+ return(first);
+}
+
+/*
+ * called whenever the directory is changed
+ */
+void path_newdir(Pathcomp_t *first)
+{
+ register Pathcomp_t *pp=first, *next, *pq;
+ struct stat statb;
+ for(pp=first; pp; pp=pp->next)
+ {
+ pp->flags &= ~PATH_SKIP;
+ if(*pp->name=='/')
+ continue;
+ /* delete .paths component */
+ if((next=pp->next) && (next->flags&PATH_BFPATH))
+ {
+ pp->next = next->next;
+ if(--next->refcount<=0)
+ free((void*)next);
+ }
+ if(stat(pp->name,&statb)<0 || !S_ISDIR(statb.st_mode))
+ {
+ pp->dev = 0;
+ pp->ino = 0;
+ continue;
+ }
+ pp->dev = statb.st_dev;
+ pp->ino = statb.st_ino;
+ for(pq=first;pq!=pp;pq=pq->next)
+ {
+ if(pp->ino==pq->ino && pp->dev==pq->dev)
+ pp->flags |= PATH_SKIP;
+ }
+ for(pq=pp;pq=pq->next;)
+ {
+ if(pp->ino==pq->ino && pp->dev==pq->dev)
+ pq->flags |= PATH_SKIP;
+ }
+ if((pp->flags&(PATH_PATH|PATH_SKIP))==PATH_PATH)
+ {
+ /* try to insert .paths component */
+ int offset = staktell();
+ stakputs(pp->name);
+ stakseek(offset);
+ next = pp->next;
+ pp->next = 0;
+ path_chkpaths(first,(Pathcomp_t*)0,pp,offset);
+ if(pp->next)
+ pp = pp->next;
+ pp->next = next;
+ }
+ }
+#if 0
+ path_dump(first);
+#endif
+}
+
+Pathcomp_t *path_unsetfpath(Pathcomp_t *first)
+{
+ register Pathcomp_t *pp=first, *old=0;
+ while(pp)
+ {
+ if((pp->flags&PATH_FPATH) && !(pp->flags&PATH_BFPATH))
+ {
+ if(pp->flags&PATH_PATH)
+ pp->flags &= ~PATH_FPATH;
+ else
+ {
+ Pathcomp_t *ppsave=pp;
+ if(old)
+ old->next = pp->next;
+ else
+ first = pp->next;
+ pp = pp->next;
+ if(--ppsave->refcount<=0)
+ {
+ if(ppsave->lib)
+ free((void*)ppsave->lib);
+ free((void*)ppsave);
+ }
+ continue;
+ }
+
+ }
+ old = pp;
+ pp = pp->next;
+ }
+ return(first);
+}
+
+Pathcomp_t *path_dirfind(Pathcomp_t *first,const char *name,int c)
+{
+ register Pathcomp_t *pp=first;
+ while(pp)
+ {
+ if(memcmp(name,pp->name,pp->len)==0 && name[pp->len]==c)
+ return(pp);
+ pp = pp->next;
+ }
+ return(0);
+}
+
+/*
+ * get discipline for tracked alias
+ */
+static char *talias_get(Namval_t *np, Namfun_t *nvp)
+{
+ Pathcomp_t *pp = (Pathcomp_t*)np->nvalue.cp;
+ char *ptr;
+ if(!pp)
+ return(NULL);
+ path_nextcomp(pp,nv_name(np),pp);
+ ptr = stakfreeze(0);
+ return(ptr+PATH_OFFSET);
+}
+
+static void talias_put(register Namval_t* np,const char *val,int flags,Namfun_t *fp)
+{
+ if(!val && np->nvalue.cp)
+ {
+ Pathcomp_t *pp = (Pathcomp_t*)np->nvalue.cp;
+ if(--pp->refcount<=0)
+ free((void*)pp);
+ }
+ nv_putv(np,val,flags,fp);
+}
+
+static const Namdisc_t talias_disc = { 0, talias_put, talias_get };
+static Namfun_t talias_init = { &talias_disc, 1 };
+
+/*
+ * set tracked alias node <np> to value <pp>
+ */
+void path_alias(register Namval_t *np,register Pathcomp_t *pp)
+{
+ if(pp)
+ {
+ struct stat statb;
+ char *sp;
+ nv_offattr(np,NV_NOPRINT);
+ nv_stack(np,&talias_init);
+ np->nvalue.cp = (char*)pp;
+ pp->refcount++;
+ nv_setattr(np,NV_TAGGED|NV_NOFREE);
+ path_nextcomp(pp,nv_name(np),pp);
+ sp = stakptr(PATH_OFFSET);
+ if(sp && lstat(sp,&statb)>=0 && S_ISLNK(statb.st_mode))
+ nv_setsize(np,statb.st_size+1);
+ else
+ nv_setsize(np,0);
+ }
+ else
+ nv_unset(np);
+}
+
diff --git a/usr/src/lib/libshell/common/sh/pmain.c b/usr/src/lib/libshell/common/sh/pmain.c
new file mode 100644
index 0000000000..9cf8a886f9
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/pmain.c
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <shell.h>
+
+typedef int (*Shnote_f)(int, long, int);
+
+int main(int argc, char *argv[])
+{
+ sh_waitnotify((Shnote_f)0);
+ return(sh_main(argc, argv, 0));
+}
diff --git a/usr/src/lib/libshell/common/sh/shcomp.c b/usr/src/lib/libshell/common/sh/shcomp.c
new file mode 100644
index 0000000000..454ac3e5be
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/shcomp.c
@@ -0,0 +1,172 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * shell script to shell binary converter
+ *
+ */
+
+static const char usage[] =
+"[-?\n@(#)$Id: shcomp (AT&T Research) 2003-03-02 $\n]"
+USAGE_LICENSE
+"[+NAME?shcomp - compile a shell script]"
+"[+DESCRIPTION?Unless \b-D\b is specified, \bshcomp\b takes a shell script, "
+ "\ainfile\a, and creates a binary format file, \aoutfile\a, that "
+ "\bksh\b can read and execute with the same effect as the original "
+ "script.]"
+"[+?Since aliases are processed as the script is read, alias definitions "
+ "whose value requires variable expansion will not work correctly.]"
+"[+?If \b-D\b is specifed, all double quoted strings that are preceded by "
+ "\b$\b are output. These are the messages that need to be "
+ "translated to locale specific versions for internationalization.]"
+"[+?If \aoutfile\a is omitted, then the results will be written to "
+ "standard output. If \ainfile\a is also omitted, the shell script "
+ "will be read from standard input.]"
+"[D:dictionary?Generate a list of strings that need to be placed in a message "
+ "catalog for internationalization.]"
+"[n:noexec?Displays warning messages for obsolete or non-conforming "
+ "constructs.] "
+"[v:verbose?Displays input from \ainfile\a onto standard error as it "
+ "reads it.]"
+"\n"
+"\n[infile [outfile]]\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Successful completion.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+SEE ALSO?\bksh\b(1)]"
+;
+
+#include <shell.h>
+#include "shnodes.h"
+#include "sys/stat.h"
+
+#define CNTL(x) ((x)&037)
+#define VERSION 3
+static const char header[6] = { CNTL('k'),CNTL('s'),CNTL('h'),0,VERSION,0 };
+
+int main(int argc, char *argv[])
+{
+ Sfio_t *in, *out;
+ Shell_t *shp;
+ Namval_t *np;
+ Shnode_t *t;
+ char *cp;
+ int n, nflag=0, vflag=0, dflag=0;
+ error_info.id = argv[0];
+ while(n = optget(argv, usage )) switch(n)
+ {
+ case 'D':
+ dflag=1;
+ break;
+ case 'v':
+ vflag=1;
+ break;
+ case 'n':
+ nflag=1;
+ break;
+ case ':':
+ errormsg(SH_DICT,2,"%s",opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT,ERROR_usage(2),"%s",opt_info.arg);
+ break;
+ }
+ shp = sh_init(argc,argv,(Shinit_f)0);
+ argv += opt_info.index;
+ argc -= opt_info.index;
+ if(error_info.errors || argc>2)
+ errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
+ if(cp= *argv)
+ {
+ argv++;
+ in = sh_pathopen(cp);
+ }
+ else
+ in = sfstdin;
+ if(cp= *argv)
+ {
+ struct stat statb;
+ if(!(out = sfopen((Sfio_t*)0,cp,"w")))
+ errormsg(SH_DICT,ERROR_system(1),"%s: cannot create",cp);
+ if(fstat(sffileno(out),&statb) >=0)
+ chmod(cp,(statb.st_mode&~S_IFMT)|S_IXUSR|S_IXGRP|S_IXOTH);
+ }
+ else
+ out = sfstdout;
+ if(dflag)
+ {
+ sh_onoption(SH_DICTIONARY);
+ sh_onoption(SH_NOEXEC);
+ }
+ if(nflag)
+ sh_onoption(SH_NOEXEC);
+ if(vflag)
+ sh_onoption(SH_VERBOSE);
+ if(!dflag)
+ sfwrite(out,header,sizeof(header));
+ shp->inlineno = 1;
+ while(1)
+ {
+ stakset((char*)0,0);
+ if(t = (Shnode_t*)sh_parse(shp,in,0))
+ {
+ if(t->tre.tretyp==0 && t->com.comnamp && strcmp(nv_name((Namval_t*)t->com.comnamp),"alias")==0)
+ sh_exec(t,0);
+ if(!dflag && sh_tdump(out,t) < 0)
+ errormsg(SH_DICT,ERROR_exit(1),"dump failed");
+ }
+ else if(sfeof(in))
+ break;
+ if(sferror(in))
+ errormsg(SH_DICT,ERROR_system(1),"I/O error");
+ if(t && ((t->tre.tretyp&COMMSK)==TCOM) && (np=t->com.comnamp) && (cp=nv_name(np)))
+ {
+ if(strcmp(cp,"exit")==0)
+ break;
+ /* check for exec of a command */
+ if(strcmp(cp,"exec")==0)
+ {
+ if(t->com.comtyp&COMSCAN)
+ {
+ if(t->com.comarg->argnxt.ap)
+ break;
+ }
+ else
+ {
+ struct dolnod *ap = (struct dolnod*)t->com.comarg;
+ if(ap->dolnum>1)
+ break;
+ }
+ }
+ }
+ }
+ /* copy any remaining input */
+ sfmove(in,out,SF_UNBOUND,-1);
+ if(in!=sfstdin)
+ sfclose(in);
+ if(out!=sfstdout)
+ sfclose(out);
+ return(0);
+}
diff --git a/usr/src/lib/libshell/common/sh/streval.c b/usr/src/lib/libshell/common/sh/streval.c
new file mode 100644
index 0000000000..fd74d47cd6
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/streval.c
@@ -0,0 +1,904 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+/*
+ * D. G. Korn
+ * AT&T Labs
+ *
+ * arithmetic expression evaluator
+ *
+ * this version compiles the expression onto a stack
+ * and has a separate executor
+ */
+
+#include "streval.h"
+#include <ctype.h>
+#include <error.h>
+#include <stak.h>
+#include "FEATURE/externs"
+
+#ifndef ERROR_dictionary
+# define ERROR_dictionary(s) (s)
+#endif
+#ifndef SH_DICT
+# define SH_DICT "libshell"
+#endif
+
+#define MAXLEVEL 9
+#define SMALL_STACK 12
+
+/*
+ * The following are used with tokenbits() macro
+ */
+#define T_OP 0x3f /* mask for operator number */
+#define T_BINARY 0x40 /* binary operators */
+#define T_NOFLOAT 0x80 /* non floating point operator */
+#define A_LVALUE (2*MAXPREC+2)
+
+#define pow2size(x) ((x)<=2?2:(x)<=4?4:(x)<=8?8:(x)<=16?16:(x)<=32?32:64)
+#define round(x,size) (((x)+(size)-1)&~((size)-1))
+#define stakpush(v,val,type) ((((v)->offset=round(staktell(),pow2size(sizeof(type)))),\
+ stakseek((v)->offset+sizeof(type)), \
+ *((type*)stakptr((v)->offset)) = (val)),(v)->offset)
+#define roundptr(ep,cp,type) (((unsigned char*)(ep))+round(cp-((unsigned char*)(ep)),pow2size(sizeof(type))))
+
+static int level;
+
+struct vars /* vars stacked per invocation */
+{
+ const char *expr; /* current expression */
+ const char *nextchr; /* next char in current expression */
+ const char *errchr; /* next char after error */
+ const char *errstr; /* error string */
+ struct lval errmsg; /* error message text */
+ int offset; /* offset for pushchr macro */
+ int staksize; /* current stack size needed */
+ int stakmaxsize; /* maximum stack size needed */
+ unsigned char paren; /* parenthesis level */
+ char infun; /* incremented by comma inside function */
+ int emode;
+ Sfdouble_t (*convert)(const char**,struct lval*,int,Sfdouble_t);
+};
+
+typedef int (*Math_0_f)(Sfdouble_t);
+typedef Sfdouble_t (*Fun_t)(Sfdouble_t,...);
+typedef Sfdouble_t (*Math_1_f)(Sfdouble_t);
+typedef Sfdouble_t (*Math_2_f)(Sfdouble_t,Sfdouble_t);
+typedef Sfdouble_t (*Math_3_f)(Sfdouble_t,Sfdouble_t,Sfdouble_t);
+
+#define getchr(vp) (*(vp)->nextchr++)
+#define peekchr(vp) (*(vp)->nextchr)
+#define ungetchr(vp) ((vp)->nextchr--)
+
+#if ('a'==97) /* ASCII encodings */
+# define getop(c) (((c) >= sizeof(strval_states))? \
+ ((c)=='|'?A_OR:((c)=='^'?A_XOR:((c)=='~'?A_TILDE:A_REG))):\
+ strval_states[(c)])
+#else
+# define getop(c) (isdigit(c)?A_DIG:((c==' '||c=='\t'||c=='\n'||c=='"')?0: \
+ (c=='<'?A_LT:(c=='>'?A_GT:(c=='='?A_ASSIGN: \
+ (c=='+'?A_PLUS:(c=='-'?A_MINUS:(c=='*'?A_TIMES: \
+ (c=='/'?A_DIV:(c=='%'?A_MOD:(c==','?A_COMMA: \
+ (c=='&'?A_AND:(c=='!'?A_NOT:(c=='('?A_LPAR: \
+ (c==')'?A_RPAR:(c==0?A_EOF:(c==':'?A_COLON: \
+ (c=='?'?A_QUEST:(c=='|'?A_OR:(c=='^'?A_XOR: \
+ (c=='\''?A_LIT: \
+ (c=='.'?A_DOT:(c=='~'?A_TILDE:A_REG)))))))))))))))))))))))
+#endif
+
+#define seterror(v,msg) _seterror(v,ERROR_dictionary(msg))
+#define ERROR(vp,msg) return(seterror((vp),msg))
+
+/*
+ * set error message string and return(0)
+ */
+static int _seterror(struct vars *vp,const char *msg)
+{
+ if(!vp->errmsg.value)
+ vp->errmsg.value = (char*)msg;
+ vp->errchr = vp->nextchr;
+ vp->nextchr = "";
+ level = 0;
+ return(0);
+}
+
+
+static void arith_error(const char *message,const char *expr, int mode)
+{
+ level = 0;
+ mode = (mode&3)!=0;
+ errormsg(SH_DICT,ERROR_exit(mode),message,expr);
+}
+
+#if _ast_no_um2fm
+static Sfdouble_t U2F(Sfulong_t u)
+{
+ Sflong_t s = u;
+ Sfdouble_t f;
+
+ if (s >= 0)
+ return s;
+ s = u / 2;
+ f = s;
+ f *= 2;
+ if (u & 1)
+ f++;
+ return f;
+}
+#else
+#define U2F(x) x
+#endif
+
+Sfdouble_t arith_exec(Arith_t *ep)
+{
+ register Sfdouble_t num=0,*dp,*sp;
+ register unsigned char *cp = ep->code;
+ register int c,type=0;
+ register char *tp;
+ Sfdouble_t small_stack[SMALL_STACK+1];
+ const char *ptr = "";
+ Fun_t fun;
+ struct lval node;
+ node.emode = ep->emode;
+ node.expr = ep->expr;
+ node.elen = ep->elen;
+ if(level++ >=MAXLEVEL)
+ {
+ arith_error(e_recursive,ep->expr,ep->emode);
+ return(0);
+ }
+ if(ep->staksize < SMALL_STACK)
+ sp = small_stack;
+ else
+ sp = (Sfdouble_t*)stakalloc(ep->staksize*(sizeof(Sfdouble_t)+1));
+ tp = (char*)(sp+ep->staksize);
+ tp--,sp--;
+ while(c = *cp++)
+ {
+ if(c&T_NOFLOAT)
+ {
+ if(type==1 || ((c&T_BINARY) && (c&T_OP)!=A_MOD && tp[-1]==1))
+ arith_error(e_incompatible,ep->expr,ep->emode);
+ }
+ switch(c&T_OP)
+ {
+ case A_JMP: case A_JMPZ: case A_JMPNZ:
+ c &= T_OP;
+ cp = roundptr(ep,cp,short);
+ if((c==A_JMPZ && num) || (c==A_JMPNZ &&!num))
+ cp += sizeof(short);
+ else
+ cp = (unsigned char*)ep + *((short*)cp);
+ continue;
+ case A_NOTNOT:
+ num = (num!=0);
+ type=0;
+ break;
+ case A_PLUSPLUS:
+ (*ep->fun)(&ptr,&node,ASSIGN,num+1);
+ break;
+ case A_MINUSMINUS:
+ (*ep->fun)(&ptr,&node,ASSIGN,num-1);
+ break;
+ case A_INCR:
+ num = num+1;
+ num = (*ep->fun)(&ptr,&node,ASSIGN,num);
+ break;
+ case A_DECR:
+ num = num-1;
+ num = (*ep->fun)(&ptr,&node,ASSIGN,num);
+ break;
+ case A_SWAP:
+ num = sp[-1];
+ sp[-1] = *sp;
+ type = tp[-1];
+ tp[-1] = *tp;
+ break;
+ case A_POP:
+ sp--;
+ continue;
+ case A_PUSHV:
+ cp = roundptr(ep,cp,Sfdouble_t*);
+ dp = *((Sfdouble_t**)cp);
+ cp += sizeof(Sfdouble_t*);
+ c = *(short*)cp;
+ cp += sizeof(short);
+ node.value = (char*)dp;
+ node.flag = c;
+ node.isfloat=0;
+ node.level = level;
+ num = (*ep->fun)(&ptr,&node,VALUE,num);
+ if(node.value != (char*)dp)
+ arith_error(node.value,ptr,ep->emode);
+ *++sp = num;
+ type = node.isfloat;
+ if(num > LDBL_ULLONG_MAX || num < LDBL_LLONG_MIN)
+ type = 1;
+ else
+ {
+ Sfdouble_t d=num;
+ if(num > LDBL_LLONG_MAX && num <= LDBL_ULLONG_MAX)
+ {
+ type = 2;
+ d -= LDBL_LLONG_MAX;
+ }
+ if((Sflong_t)d!=d)
+ type = 1;
+ }
+ *++tp = type;
+ c = 0;
+ break;
+ case A_STORE:
+ cp = roundptr(ep,cp,Sfdouble_t*);
+ dp = *((Sfdouble_t**)cp);
+ cp += sizeof(Sfdouble_t*);
+ c = *(short*)cp;
+ if(c<0)
+ c = 0;
+ cp += sizeof(short);
+ node.value = (char*)dp;
+ node.flag = c;
+ num = (*ep->fun)(&ptr,&node,ASSIGN,num);
+ break;
+ case A_PUSHF:
+ cp = roundptr(ep,cp,Fun_t);
+ *++sp = (Sfdouble_t)(cp-ep->code);
+ cp += sizeof(Fun_t);
+ *++tp = *cp++;
+ continue;
+ case A_PUSHN:
+ cp = roundptr(ep,cp,Sfdouble_t);
+ num = *((Sfdouble_t*)cp);
+ cp += sizeof(Sfdouble_t);
+ *++sp = num;
+ *++tp = type = *cp++;
+ break;
+ case A_NOT:
+ type=0;
+ num = !num;
+ break;
+ case A_UMINUS:
+ num = -num;
+ break;
+ case A_TILDE:
+ num = ~((Sflong_t)(num));
+ break;
+ case A_PLUS:
+ num += sp[-1];
+ break;
+ case A_MINUS:
+ num = sp[-1] - num;
+ break;
+ case A_TIMES:
+ num *= sp[-1];
+ break;
+ case A_POW:
+ num = pow(sp[-1],num);
+ break;
+ case A_MOD:
+ if(!(Sflong_t)num)
+ arith_error(e_divzero,ep->expr,ep->emode);
+ if(type==2 || tp[-1]==2)
+ num = U2F((Sfulong_t)(sp[-1]) % (Sfulong_t)(num));
+ else
+ num = (Sflong_t)(sp[-1]) % (Sflong_t)(num);
+ break;
+ case A_DIV:
+ if(type==1 || tp[-1]==1)
+ {
+ num = sp[-1]/num;
+ type = 1;
+ }
+ else if((Sfulong_t)(num)==0)
+ arith_error(e_divzero,ep->expr,ep->emode);
+ else if(type==2 || tp[-1]==2)
+ num = U2F((Sfulong_t)(sp[-1]) / (Sfulong_t)(num));
+ else
+ num = (Sflong_t)(sp[-1]) / (Sflong_t)(num);
+ break;
+ case A_LSHIFT:
+ if(tp[-1]==2)
+ num = U2F((Sfulong_t)(sp[-1]) << (long)(num));
+ else
+ num = (Sflong_t)(sp[-1]) << (long)(num);
+ break;
+ case A_RSHIFT:
+ if(tp[-1]==2)
+ num = U2F((Sfulong_t)(sp[-1]) >> (long)(num));
+ else
+ num = (Sflong_t)(sp[-1]) >> (long)(num);
+ break;
+ case A_XOR:
+ if(type==2 || tp[-1]==2)
+ num = U2F((Sfulong_t)(sp[-1]) ^ (Sfulong_t)(num));
+ else
+ num = (Sflong_t)(sp[-1]) ^ (Sflong_t)(num);
+ break;
+ case A_OR:
+ if(type==2 || tp[-1]==2)
+ num = U2F((Sfulong_t)(sp[-1]) | (Sfulong_t)(num));
+ else
+ num = (Sflong_t)(sp[-1]) | (Sflong_t)(num);
+ break;
+ case A_AND:
+ if(type==2 || tp[-1]==2)
+ num = U2F((Sfulong_t)(sp[-1]) & (Sfulong_t)(num));
+ else
+ num = (Sflong_t)(sp[-1]) & (Sflong_t)(num);
+ break;
+ case A_EQ:
+ num = (sp[-1]==num);
+ type=0;
+ break;
+ case A_NEQ:
+ num = (sp[-1]!=num);
+ type=0;
+ break;
+ case A_LE:
+ num = (sp[-1]<=num);
+ type=0;
+ break;
+ case A_GE:
+ num = (sp[-1]>=num);
+ type=0;
+ break;
+ case A_GT:
+ num = (sp[-1]>num);
+ type=0;
+ break;
+ case A_LT:
+ num = (sp[-1]<num);
+ type=0;
+ break;
+ case A_CALL0:
+ sp--,tp--;
+ fun = *((Fun_t*)(ep->code+(int)(*sp)));
+ type = 0;
+ num = (*((Math_0_f)fun))(num);
+ break;
+ case A_CALL1:
+ sp--,tp--;
+ fun = *((Fun_t*)(ep->code+(int)(*sp)));
+ type = *tp;
+ num = (*fun)(num);
+ break;
+ case A_CALL2:
+ sp-=2,tp-=2;
+ fun = *((Fun_t*)(ep->code+(int)(*sp)));
+ type = *tp;
+ num = (*((Math_2_f)fun))(sp[1],num);
+ break;
+ case A_CALL3:
+ sp-=3,tp-=3;
+ fun = *((Fun_t*)(ep->code+(int)(*sp)));
+ type = *tp;
+ num = (*((Math_3_f)fun))(sp[1],sp[2],num);
+ break;
+ }
+ if(c&T_BINARY)
+ sp--,tp--;
+ *sp = num;
+ *tp = type;
+ }
+ if(level>0)
+ level--;
+ return(num);
+}
+
+/*
+ * This returns operator tokens or A_REG or A_NUM
+ */
+static int gettok(register struct vars *vp)
+{
+ register int c,op;
+ vp->errchr = vp->nextchr;
+ while(1)
+ {
+ c = getchr(vp);
+ switch(op=getop(c))
+ {
+ case 0:
+ vp->errchr = vp->nextchr;
+ continue;
+ case A_EOF:
+ vp->nextchr--;
+ break;
+ /*FALL THRU*/
+ case A_DIG: case A_REG: case A_DOT: case A_LIT:
+ if(op==A_DOT)
+ {
+ if((c=peekchr(vp))>='0' && c<='9')
+ op = A_DIG;
+ else
+ op = A_REG;
+ }
+ ungetchr(vp);
+ break;
+ case A_QUEST:
+ if(peekchr(vp)==':')
+ {
+ getchr(vp);
+ op = A_QCOLON;
+ }
+ break;
+ case A_LT: case A_GT:
+ if(peekchr(vp)==c)
+ {
+ getchr(vp);
+ op -= 2;
+ break;
+ }
+ /* FALL THRU */
+ case A_NOT: case A_COLON:
+ c = '=';
+ /* FALL THRU */
+ case A_ASSIGN:
+ case A_TIMES:
+ case A_PLUS: case A_MINUS:
+ case A_OR: case A_AND:
+ if(peekchr(vp)==c)
+ {
+ getchr(vp);
+ op--;
+ }
+ }
+ return(op);
+ }
+}
+
+/*
+ * evaluate a subexpression with precedence
+ */
+
+static int expr(register struct vars *vp,register int precedence)
+{
+ register int c, op;
+ int invalid,wasop=0;
+ struct lval lvalue,assignop;
+ const char *pos;
+ Sfdouble_t d;
+
+ lvalue.value = 0;
+ lvalue.fun = 0;
+again:
+ op = gettok(vp);
+ c = 2*MAXPREC+1;
+ switch(op)
+ {
+ case A_PLUS:
+ goto again;
+ case A_EOF:
+ if(precedence>5)
+ ERROR(vp,e_moretokens);
+ return(1);
+ case A_MINUS:
+ op = A_UMINUS;
+ goto common;
+ case A_NOT:
+ goto common;
+ case A_MINUSMINUS:
+ c = A_LVALUE;
+ op = A_DECR|T_NOFLOAT;
+ goto common;
+ case A_PLUSPLUS:
+ c = A_LVALUE;
+ op = A_INCR|T_NOFLOAT;
+ /* FALL THRU */
+ case A_TILDE:
+ op |= T_NOFLOAT;
+ common:
+ if(!expr(vp,c))
+ return(0);
+ stakputc(op);
+ break;
+ default:
+ vp->nextchr = vp->errchr;
+ wasop = 1;
+ }
+ invalid = wasop;
+ while(1)
+ {
+ assignop.value = 0;
+ op = gettok(vp);
+ if(op==A_DIG || op==A_REG || op==A_LIT)
+ {
+ if(!wasop)
+ ERROR(vp,e_synbad);
+ goto number;
+ }
+ if(wasop++ && op!=A_LPAR)
+ ERROR(vp,e_synbad);
+ /* check for assignment operation */
+ if(peekchr(vp)== '=' && !(strval_precedence[op]&NOASSIGN))
+ {
+ if((!lvalue.value || precedence > 3))
+ ERROR(vp,e_notlvalue);
+ if(precedence==3)
+ precedence = 2;
+ assignop = lvalue;
+ getchr(vp);
+ c = 3;
+ }
+ else
+ {
+ c = (strval_precedence[op]&PRECMASK);
+ if(c==MAXPREC || op==A_POW)
+ c++;
+ c *= 2;
+ }
+ /* from here on c is the new precedence level */
+ if(lvalue.value && (op!=A_ASSIGN))
+ {
+ if(vp->staksize++>=vp->stakmaxsize)
+ vp->stakmaxsize = vp->staksize;
+ stakputc(A_PUSHV);
+ stakpush(vp,lvalue.value,char*);
+ if(lvalue.flag<0)
+ lvalue.flag = 0;
+ stakpush(vp,lvalue.flag,short);
+ if(vp->nextchr==0)
+ ERROR(vp,e_badnum);
+ if(!(strval_precedence[op]&SEQPOINT))
+ lvalue.value = 0;
+ invalid = 0;
+ }
+ else if(precedence==A_LVALUE)
+ ERROR(vp,e_notlvalue);
+ if(invalid && op>A_ASSIGN)
+ ERROR(vp,e_synbad);
+ if(precedence >= c)
+ goto done;
+ if(strval_precedence[op]&RASSOC)
+ c--;
+ if((c < (2*MAXPREC+1)) && !(strval_precedence[op]&SEQPOINT))
+ {
+ wasop = 0;
+ if(!expr(vp,c))
+ return(0);
+ }
+ switch(op)
+ {
+ case A_RPAR:
+ if(!vp->paren)
+ ERROR(vp,e_paren);
+ if(invalid)
+ ERROR(vp,e_synbad);
+ goto done;
+
+ case A_COMMA:
+ wasop = 0;
+ if(vp->infun)
+ vp->infun++;
+ else
+ {
+ stakputc(A_POP);
+ vp->staksize--;
+ }
+ if(!expr(vp,c))
+ return(0);
+ lvalue.value = 0;
+ break;
+
+ case A_LPAR:
+ {
+ int infun = vp->infun;
+ Sfdouble_t (*fun)(Sfdouble_t,...);
+ int nargs = lvalue.nargs;
+ fun = lvalue.fun;
+ lvalue.fun = 0;
+ if(fun)
+ {
+ if(vp->staksize++>=vp->stakmaxsize)
+ vp->stakmaxsize = vp->staksize;
+ vp->infun=1;
+ stakputc(A_PUSHF);
+ stakpush(vp,fun,Fun_t);
+ stakputc(1);
+ }
+ else
+ vp->infun = 0;
+ if(!invalid)
+ ERROR(vp,e_synbad);
+ vp->paren++;
+ if(!expr(vp,1))
+ return(0);
+ vp->paren--;
+ if(fun)
+ {
+ int x= (nargs>7);
+ nargs &= 7;
+ if(vp->infun != nargs)
+ ERROR(vp,e_argcount);
+ if(vp->staksize+=nargs>=vp->stakmaxsize)
+ vp->stakmaxsize = vp->staksize+nargs;
+ stakputc(A_CALL0+nargs -x);
+ vp->staksize -= nargs;
+ }
+ vp->infun = infun;
+ if (gettok(vp) != A_RPAR)
+ ERROR(vp,e_paren);
+ wasop = 0;
+ break;
+ }
+
+ case A_PLUSPLUS:
+ case A_MINUSMINUS:
+ wasop=0;
+ op |= T_NOFLOAT;
+ case A_ASSIGN:
+ if(!lvalue.value)
+ ERROR(vp,e_notlvalue);
+ if(op==A_ASSIGN)
+ {
+ stakputc(A_STORE);
+ stakpush(vp,lvalue.value,char*);
+ stakpush(vp,lvalue.flag,short);
+ vp->staksize--;
+ }
+ else
+ stakputc(op);
+ lvalue.value = 0;
+ break;
+
+ case A_QUEST:
+ {
+ int offset1,offset2;
+ stakputc(A_JMPZ);
+ offset1 = stakpush(vp,0,short);
+ stakputc(A_POP);
+ if(!expr(vp,1))
+ return(0);
+ if(gettok(vp)!=A_COLON)
+ ERROR(vp,e_questcolon);
+ stakputc(A_JMP);
+ offset2 = stakpush(vp,0,short);
+ *((short*)stakptr(offset1)) = staktell();
+ stakputc(A_POP);
+ if(!expr(vp,3))
+ return(0);
+ *((short*)stakptr(offset2)) = staktell();
+ lvalue.value = 0;
+ wasop = 0;
+ break;
+ }
+
+ case A_COLON:
+ ERROR(vp,e_badcolon);
+ break;
+
+ case A_QCOLON:
+ case A_ANDAND:
+ case A_OROR:
+ {
+ int offset;
+ if(op==A_ANDAND)
+ op = A_JMPZ;
+ else
+ op = A_JMPNZ;
+ stakputc(op);
+ offset = stakpush(vp,0,short);
+ stakputc(A_POP);
+ if(!expr(vp,c))
+ return(0);
+ *((short*)stakptr(offset)) = staktell();
+ if(op!=A_QCOLON)
+ stakputc(A_NOTNOT);
+ lvalue.value = 0;
+ wasop=0;
+ break;
+ }
+ case A_AND: case A_OR: case A_XOR: case A_LSHIFT:
+ case A_RSHIFT: case A_MOD:
+ op |= T_NOFLOAT;
+ /* FALL THRU */
+ case A_PLUS: case A_MINUS: case A_TIMES: case A_DIV:
+ case A_EQ: case A_NEQ: case A_LT: case A_LE:
+ case A_GT: case A_GE: case A_POW:
+ stakputc(op|T_BINARY);
+ vp->staksize--;
+ break;
+ case A_NOT: case A_TILDE:
+ default:
+ ERROR(vp,e_synbad);
+ number:
+ wasop = 0;
+ if(*vp->nextchr=='L' && vp->nextchr[1]=='\'')
+ {
+ vp->nextchr++;
+ op = A_LIT;
+ }
+ pos = vp->nextchr;
+ lvalue.isfloat = 0;
+ lvalue.expr = vp->expr;
+ lvalue.emode = vp->emode;
+ if(op==A_LIT)
+ {
+ /* character constants */
+ if(pos[1]=='\\' && pos[2]=='\'' && pos[3]!='\'')
+ {
+ d = '\\';
+ vp->nextchr +=2;
+ }
+ else
+ d = chresc(pos+1,(char**)&vp->nextchr);
+ /* posix allows the trailing ' to be optional */
+ if(*vp->nextchr=='\'')
+ vp->nextchr++;
+ }
+ else
+ d = (*vp->convert)(&vp->nextchr, &lvalue, LOOKUP, 0);
+ if (vp->nextchr == pos)
+ {
+ if(vp->errmsg.value = lvalue.value)
+ vp->errstr = pos;
+ ERROR(vp,op==A_LIT?e_charconst:e_synbad);
+ }
+ if(op==A_DIG || op==A_LIT)
+ {
+ stakputc(A_PUSHN);
+ if(vp->staksize++>=vp->stakmaxsize)
+ vp->stakmaxsize = vp->staksize;
+ stakpush(vp,d,Sfdouble_t);
+ stakputc(lvalue.isfloat);
+ }
+
+ /* check for function call */
+ if(lvalue.fun)
+ continue;
+ break;
+ }
+ invalid = 0;
+ if(assignop.value)
+ {
+ if(vp->staksize++>=vp->stakmaxsize)
+ vp->stakmaxsize = vp->staksize;
+ if(assignop.flag<0)
+ assignop.flag = 0;
+ stakputc(A_STORE);
+ stakpush(vp,assignop.value,char*);
+ stakpush(vp,assignop.flag,short);
+ }
+ }
+ done:
+ vp->nextchr = vp->errchr;
+ return(1);
+}
+
+Arith_t *arith_compile(const char *string,char **last,Sfdouble_t(*fun)(const char**,struct lval*,int,Sfdouble_t),int emode)
+{
+ struct vars cur;
+ register Arith_t *ep;
+ int offset;
+ memset((void*)&cur,0,sizeof(cur));
+ cur.emode = emode;
+ cur.expr = cur.nextchr = string;
+ cur.convert = fun;
+ cur.emode = emode;
+ cur.errmsg.value = 0;
+ cur.errmsg.emode = emode;
+ stakseek(sizeof(Arith_t));
+ if(!expr(&cur,0) && cur.errmsg.value)
+ {
+ if(cur.errstr)
+ string = cur.errstr;
+ (*fun)( &string , &cur.errmsg, MESSAGE, 0);
+ cur.nextchr = cur.errchr;
+ }
+ stakputc(0);
+ offset = staktell();
+ ep = (Arith_t*)stakfreeze(0);
+ ep->expr = string;
+ ep->elen = strlen(string);
+ ep->code = (unsigned char*)(ep+1);
+ ep->fun = fun;
+ ep->emode = emode;
+ ep->size = offset - sizeof(Arith_t);
+ ep->staksize = cur.stakmaxsize+1;
+ if(last)
+ *last = (char*)(cur.nextchr);
+ return(ep);
+}
+
+/*
+ * evaluate an integer arithmetic expression in s
+ *
+ * (Sfdouble_t)(*convert)(char** end, struct lval* string, int type, Sfdouble_t value)
+ * is a user supplied conversion routine that is called when unknown
+ * chars are encountered.
+ * *end points to the part to be converted and must be adjusted by convert to
+ * point to the next non-converted character; if typ is MESSAGE then string
+ * points to an error message string
+ *
+ * NOTE: (*convert)() may call strval()
+ */
+
+Sfdouble_t strval(const char *s,char **end,Sfdouble_t(*conv)(const char**,struct lval*,int,Sfdouble_t),int emode)
+{
+ Arith_t *ep;
+ Sfdouble_t d;
+ char *sp=0;
+ int offset;
+ if(offset=staktell())
+ sp = stakfreeze(1);
+ ep = arith_compile(s,end,conv,emode);
+ ep->emode = emode;
+ d = arith_exec(ep);
+ stakset(sp?sp:(char*)ep,offset);
+ return(d);
+}
+
+#if _mem_name__exception
+#undef _mem_name_exception
+#define _mem_name_exception 1
+#undef exception
+#define exception _exception
+#undef matherr
+#endif
+
+#if _mem_name_exception
+
+#undef error
+
+#if _BLD_shell && defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+#ifndef DOMAIN
+#define DOMAIN _DOMAIN
+#endif
+#ifndef OVERFLOW
+#define OVERFLOW _OVERFLOW
+#endif
+#ifndef SING
+#define SING _SING
+#endif
+
+ extern int matherr(struct exception *ep)
+ {
+ const char *message;
+ switch(ep->type)
+ {
+#ifdef DOMAIN
+ case DOMAIN:
+ message = ERROR_dictionary(e_domain);
+ break;
+#endif
+#ifdef OVERFLOW
+ case OVERFLOW:
+ message = ERROR_dictionary(e_overflow);
+ break;
+#endif
+#ifdef SING
+ case SING:
+ message = ERROR_dictionary(e_singularity);
+ break;
+#endif
+ default:
+ return(1);
+ }
+ level=0;
+ errormsg(SH_DICT,ERROR_exit(1),message,ep->name);
+ return(0);
+ }
+
+#undef extern
+
+#endif /* _mem_name_exception */
diff --git a/usr/src/lib/libshell/common/sh/string.c b/usr/src/lib/libshell/common/sh/string.c
new file mode 100644
index 0000000000..2d5fcaaac3
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/string.c
@@ -0,0 +1,704 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * string processing routines for Korn shell
+ *
+ */
+
+#include <ast.h>
+#include <ast_wchar.h>
+#include "defs.h"
+#include <stak.h>
+#include <ctype.h>
+#include <ccode.h>
+#include "shtable.h"
+#include "lexstates.h"
+#include "national.h"
+
+#if !SHOPT_MULTIBYTE
+#define mbchar(p) (*(unsigned char*)p++)
+#endif
+
+#if _hdr_wctype
+# include <wctype.h>
+#endif
+
+#if !_lib_iswprint && !defined(iswprint)
+# define iswprint(c) (((c)&~0377) || isprint(c))
+#endif
+
+
+/*
+ * Table lookup routine
+ * <table> is searched for string <sp> and corresponding value is returned
+ * This is only used for small tables and is used to save non-sharable memory
+ */
+
+const Shtable_t *sh_locate(register const char *sp,const Shtable_t *table,int size)
+{
+ register int first;
+ register const Shtable_t *tp;
+ register int c;
+ static const Shtable_t empty = {0,0};
+ if(sp==0 || (first= *sp)==0)
+ return(&empty);
+ tp=table;
+ while((c= *tp->sh_name) && (CC_NATIVE!=CC_ASCII || c <= first))
+ {
+ if(first == c && strcmp(sp,tp->sh_name)==0)
+ return(tp);
+ tp = (Shtable_t*)((char*)tp+size);
+ }
+ return(&empty);
+}
+
+/*
+ * shtab_options lookup routine
+ */
+
+#define sep(c) ((c)=='-'||(c)=='_')
+
+int sh_lookopt(register const char *sp, int *invert)
+{
+ register int first;
+ register const Shtable_t *tp;
+ register int c;
+ register const char *s, *t, *sw, *tw;
+ int amb;
+ int hit;
+ int inv;
+ int no;
+ if(sp==0)
+ return(0);
+ if(*sp=='n' && *(sp+1)=='o' && (*(sp+2)!='t' || *(sp+3)!='i'))
+ {
+ sp+=2;
+ if(sep(*sp))
+ sp++;
+ *invert = !*invert;
+ }
+ if((first= *sp)==0)
+ return(0);
+ tp=shtab_options;
+ amb=hit=0;
+ for(;;)
+ {
+ t=tp->sh_name;
+ if(no = *t=='n' && *(t+1)=='o' && *(t+2)!='t')
+ t+=2;
+ if(!(c= *t))
+ break;
+ if(first == c)
+ {
+ if(strcmp(sp,t)==0)
+ {
+ *invert ^= no;
+ return(tp->sh_number);
+ }
+ s=sw=sp;
+ tw=t;
+ for(;;)
+ {
+ if(!*s || *s=='=')
+ {
+ if (*s == '=' && !strtol(s+1, NiL, 0))
+ no = !no;
+ if (!*t)
+ {
+ *invert ^= no;
+ return(tp->sh_number);
+ }
+ if (hit || amb)
+ {
+ hit = 0;
+ amb = 1;
+ }
+ else
+ {
+ hit = tp->sh_number;
+ inv = no;
+ }
+ break;
+ }
+ else if(!*t)
+ break;
+ else if(sep(*s))
+ sw = ++s;
+ else if(sep(*t))
+ tw = ++t;
+ else if(*s==*t)
+ {
+ s++;
+ t++;
+ }
+ else if(s==sw && t==tw)
+ break;
+ else
+ {
+ if(t!=tw)
+ {
+ while(*t && !sep(*t))
+ t++;
+ if(!*t)
+ break;
+ tw = ++t;
+ }
+ while (s>sw && *s!=*t)
+ s--;
+ }
+ }
+ }
+ tp = (Shtable_t*)((char*)tp+sizeof(*shtab_options));
+ }
+ if(hit)
+ *invert ^= inv;
+ return(hit);
+}
+
+/*
+ * look for the substring <oldsp> in <string> and replace with <newsp>
+ * The new string is put on top of the stack
+ */
+char *sh_substitute(const char *string,const char *oldsp,char *newsp)
+/*@
+ assume string!=NULL && oldsp!=NULL && newsp!=NULL;
+ return x satisfying x==NULL ||
+ strlen(x)==(strlen(in string)+strlen(in newsp)-strlen(in oldsp));
+@*/
+{
+ register const char *sp = string;
+ register const char *cp;
+ const char *savesp = 0;
+ stakseek(0);
+ if(*sp==0)
+ return((char*)0);
+ if(*(cp=oldsp) == 0)
+ goto found;
+#if SHOPT_MULTIBYTE
+ mbinit();
+#endif /* SHOPT_MULTIBYTE */
+ do
+ {
+ /* skip to first character which matches start of oldsp */
+ while(*sp && (savesp==sp || *sp != *cp))
+ {
+#if SHOPT_MULTIBYTE
+ /* skip a whole character at a time */
+ int c = mbsize(sp);
+ if(c < 0)
+ sp++;
+ while(c-- > 0)
+#endif /* SHOPT_MULTIBYTE */
+ stakputc(*sp++);
+ }
+ if(*sp == 0)
+ return((char*)0);
+ savesp = sp;
+ for(;*cp;cp++)
+ {
+ if(*cp != *sp++)
+ break;
+ }
+ if(*cp==0)
+ /* match found */
+ goto found;
+ sp = savesp;
+ cp = oldsp;
+ }
+ while(*sp);
+ return((char*)0);
+
+found:
+ /* copy new */
+ stakputs(newsp);
+ /* copy rest of string */
+ stakputs(sp);
+ return(stakfreeze(1));
+}
+
+/*
+ * TRIM(sp)
+ * Remove escape characters from characters in <sp> and eliminate quoted nulls.
+ */
+
+void sh_trim(register char *sp)
+/*@
+ assume sp!=NULL;
+ promise strlen(in sp) <= in strlen(sp);
+@*/
+{
+ register char *dp;
+ register int c;
+ if(sp)
+ {
+ dp = sp;
+ while(c= *sp)
+ {
+#if SHOPT_MULTIBYTE
+ int len;
+ if(mbwide() && (len=mbsize(sp))>1)
+ {
+ dp += len;
+ sp += len;
+ continue;
+ }
+#endif /* SHOPT_MULTIBYTE */
+ sp++;
+ if(c == '\\')
+ c = *sp++;
+ if(c)
+ *dp++ = c;
+ }
+ *dp = 0;
+ }
+}
+
+/*
+ * copy <str1> to <str2> changing upper case to lower case
+ * <str2> must be big enough to hold <str1>
+ * <str1> and <str2> may point to the same place.
+ */
+
+void sh_utol(register char const *str1,register char *str2)
+/*@
+ assume str1!=0 && str2!=0
+ return x satisfying strlen(in str1)==strlen(in str2);
+@*/
+{
+ register int c;
+ for(; c= *((unsigned char*)str1); str1++,str2++)
+ {
+ if(isupper(c))
+ *str2 = tolower(c);
+ else
+ *str2 = c;
+ }
+ *str2 = 0;
+}
+
+/*
+ * print <str> quoting chars so that it can be read by the shell
+ * puts null terminated result on stack, but doesn't freeze it
+ */
+char *sh_fmtq(const char *string)
+{
+ register const char *cp = string;
+ register int c, state;
+ int offset;
+ if(!cp)
+ return((char*)0);
+ offset = staktell();
+#if SHOPT_MULTIBYTE
+ state = ((c= mbchar(cp))==0);
+#else
+ state = ((c= *(unsigned char*)cp++)==0);
+#endif
+ if(isaletter(c))
+ {
+#if SHOPT_MULTIBYTE
+ while((c=mbchar(cp)),isaname(c));
+#else
+ while((c = *(unsigned char*)cp++),isaname(c));
+#endif
+ if(c==0)
+ return((char*)string);
+ if(c=='=')
+ {
+ if(*cp==0)
+ return((char*)string);
+ c = cp - string;
+ stakwrite(string,c);
+ string = cp;
+#if SHOPT_MULTIBYTE
+ c = mbchar(cp);
+#else
+ c = *(unsigned char*)cp++;
+#endif
+ }
+ }
+ if(c==0 || c=='#' || c=='~')
+ state = 1;
+#if SHOPT_MULTIBYTE
+ for(;c;c= mbchar(cp))
+#else
+ for(;c; c= *(unsigned char*)cp++)
+#endif
+ {
+#if SHOPT_MULTIBYTE
+ if(c>=0x200)
+ continue;
+ if(c=='\'' || !iswprint(c))
+#else
+ if(c=='\'' || !isprint(c))
+#endif /* SHOPT_MULTIBYTE */
+ state = 2;
+ else if(c==']' || (c!=':' && (c=sh_lexstates[ST_NORM][c]) && c!=S_EPAT))
+ state |=1;
+ }
+ if(state<2)
+ {
+ if(state==1)
+ stakputc('\'');
+ if(c = --cp - string)
+ stakwrite(string,c);
+ if(state==1)
+ stakputc('\'');
+ }
+ else
+ {
+ stakwrite("$'",2);
+ cp = string;
+#if SHOPT_MULTIBYTE
+ while(c= mbchar(cp))
+#else
+ while(c= *(unsigned char*)cp++)
+#endif
+ {
+ state=1;
+ switch(c)
+ {
+ case ('a'==97?'\033':39):
+ c = 'E';
+ break;
+ case '\n':
+ c = 'n';
+ break;
+ case '\r':
+ c = 'r';
+ break;
+ case '\t':
+ c = 't';
+ break;
+ case '\f':
+ c = 'f';
+ break;
+ case '\b':
+ c = 'b';
+ break;
+ case '\a':
+ c = 'a';
+ break;
+ case '\\': case '\'':
+ break;
+ default:
+#if SHOPT_MULTIBYTE
+ if(!iswprint(c))
+#else
+ if(!isprint(c))
+#endif
+ {
+ sfprintf(staksp,"\\%.3o",c);
+ continue;
+ }
+ state=0;
+ break;
+ }
+ if(state)
+ stakputc('\\');
+ stakputc(c);
+ }
+ stakputc('\'');
+ }
+ stakputc(0);
+ return(stakptr(offset));
+}
+
+/*
+ * print <str> quoting chars so that it can be read by the shell
+ * puts null terminated result on stack, but doesn't freeze it
+ * single!=0 limits quoting to '...'
+ * fold>0 prints raw newlines and inserts appropriately
+ * escaped newlines every (fold-x) chars
+ */
+char *sh_fmtqf(const char *string, int single, int fold)
+{
+ register const char *cp = string;
+ register const char *bp;
+ register const char *vp;
+ register int c;
+ register int n;
+ register int q;
+ register int a;
+ int offset;
+
+ if (--fold < 8)
+ fold = 0;
+ if (!cp || !*cp || !single && !fold || fold && strlen(string) < fold)
+ return sh_fmtq(cp);
+ offset = staktell();
+ single = single ? 1 : 3;
+ c = mbchar(string);
+ a = isaletter(c) ? '=' : 0;
+ vp = cp + 1;
+ do
+ {
+ q = 0;
+ n = fold;
+ bp = cp;
+ while ((!n || n-- > 0) && (c = mbchar(cp)))
+ {
+ if (a && !isaname(c))
+ a = 0;
+#if SHOPT_MULTIBYTE
+ if (c >= 0x200)
+ continue;
+ if (c == '\'' || !iswprint(c))
+#else
+ if (c == '\'' || !isprint(c))
+#endif /* SHOPT_MULTIBYTE */
+ {
+ q = single;
+ break;
+ }
+ if (c == '\n')
+ q = 1;
+ else if (c == a)
+ {
+ stakwrite(bp, cp - bp);
+ bp = cp;
+ vp = cp + 1;
+ a = 0;
+ }
+ else if ((c == '#' || c == '~') && cp == vp || c == ']' || c != ':' && (c = sh_lexstates[ST_NORM][c]) && c != S_EPAT)
+ q = 1;
+ }
+ if (q & 2)
+ {
+ stakputc('$');
+ stakputc('\'');
+ cp = bp;
+ n = fold - 3;
+ q = 1;
+ while (c = mbchar(cp))
+ {
+ switch (c)
+ {
+ case ('a'==97?'\033':39):
+ c = 'E';
+ break;
+ case '\n':
+ q = 0;
+ n = fold - 1;
+ break;
+ case '\r':
+ c = 'r';
+ break;
+ case '\t':
+ c = 't';
+ break;
+ case '\f':
+ c = 'f';
+ break;
+ case '\b':
+ c = 'b';
+ break;
+ case '\a':
+ c = 'a';
+ break;
+ case '\\':
+ if (*cp == 'n')
+ {
+ c = '\n';
+ q = 0;
+ n = fold - 1;
+ break;
+ }
+ case '\'':
+ break;
+ default:
+#if SHOPT_MULTIBYTE
+ if(!iswprint(c))
+#else
+ if(!isprint(c))
+#endif
+ {
+ if ((n -= 4) <= 0)
+ {
+ stakwrite("'\\\n$'", 5);
+ n = fold - 7;
+ }
+ sfprintf(staksp, "\\%03o", c);
+ continue;
+ }
+ q = 0;
+ break;
+ }
+ if ((n -= q + 1) <= 0)
+ {
+ if (!q)
+ {
+ stakputc('\'');
+ cp = bp;
+ break;
+ }
+ stakwrite("'\\\n$'", 5);
+ n = fold - 5;
+ }
+ if (q)
+ stakputc('\\');
+ else
+ q = 1;
+ stakputc(c);
+ bp = cp;
+ }
+ if (!c)
+ stakputc('\'');
+ }
+ else if (q & 1)
+ {
+ stakputc('\'');
+ cp = bp;
+ n = fold ? (fold - 2) : 0;
+ while (c = mbchar(cp))
+ {
+ if (c == '\n')
+ n = fold - 1;
+ else if (n && --n <= 0)
+ {
+ n = fold - 2;
+ stakwrite(bp, --cp - bp);
+ bp = cp;
+ stakwrite("'\\\n'", 4);
+ }
+ else if (n == 1 && *cp == '\'')
+ {
+ n = fold - 5;
+ stakwrite(bp, --cp - bp);
+ bp = cp;
+ stakwrite("'\\\n\\''", 6);
+ }
+ else if (c == '\'')
+ {
+ stakwrite(bp, cp - bp - 1);
+ bp = cp;
+ if (n && (n -= 4) <= 0)
+ {
+ n = fold - 5;
+ stakwrite("'\\\n\\''", 6);
+ }
+ else
+ stakwrite("'\\''", 4);
+ }
+ }
+ stakwrite(bp, cp - bp - 1);
+ stakputc('\'');
+ }
+ else if (n = fold)
+ {
+ cp = bp;
+ while (c = mbchar(cp))
+ {
+ if (--n <= 0)
+ {
+ n = fold;
+ stakwrite(bp, --cp - bp);
+ bp = cp;
+ stakwrite("\\\n", 2);
+ }
+ }
+ stakwrite(bp, cp - bp - 1);
+ }
+ else
+ stakwrite(bp, cp - bp);
+ if (c)
+ {
+ stakputc('\\');
+ stakputc('\n');
+ }
+ } while (c);
+ stakputc(0);
+ return(stakptr(offset));
+}
+
+#if SHOPT_MULTIBYTE
+ int sh_strchr(const char *string, register const char *dp)
+ {
+ wchar_t c, d;
+ register const char *cp=string;
+ mbinit();
+ d = mbchar(dp);
+ mbinit();
+ while(c = mbchar(cp))
+ {
+ if(c==d)
+ return(cp-string);
+ }
+ if(d==0)
+ return(cp-string);
+ return(-1);
+ }
+#endif /* SHOPT_MULTIBYTE */
+
+const char *_sh_translate(const char *message)
+{
+#if ERROR_VERSION >= 20000317L
+ return(ERROR_translate(0,0,e_dict,message));
+#else
+#if ERROR_VERSION >= 20000101L
+ return(ERROR_translate(e_dict,message));
+#else
+ return(ERROR_translate(message,1));
+#endif
+#endif
+}
+
+/*
+ * change '['identifier']' to identifier
+ * character before <str> must be a '['
+ * returns pointer to last character
+ */
+char *sh_checkid(char *str, char *last)
+{
+ register unsigned char *cp = (unsigned char*)str;
+ register unsigned char *v = cp;
+ register int c;
+ if(c= *cp++,isaletter(c))
+ while(c= *cp++,isaname(c));
+ if(c==']' && (!last || ((char*)cp==last)))
+ {
+ /* eliminate [ and ] */
+ while(v < cp)
+ {
+ v[-1] = *v;
+ v++;
+ }
+ if(last)
+ last -=2;
+ else
+ {
+ while(*v)
+ {
+ v[-2] = *v;
+ v++;
+ }
+ v[-2] = 0;
+ last = (char*)v;
+ }
+ }
+ return(last);
+}
+
+#if _AST_VERSION <= 20000317L
+char *fmtident(const char *string)
+{
+ return((char*)string);
+}
+#endif
diff --git a/usr/src/lib/libshell/common/sh/subshell.c b/usr/src/lib/libshell/common/sh/subshell.c
new file mode 100644
index 0000000000..550e299d42
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/subshell.c
@@ -0,0 +1,555 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * Create and manage subshells avoiding forks when possible
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#include "defs.h"
+#include <ls.h>
+#include "io.h"
+#include "fault.h"
+#include "shnodes.h"
+#include "shlex.h"
+#include "jobs.h"
+#include "variables.h"
+#include "path.h"
+
+#ifndef PIPE_BUF
+# define PIPE_BUF 512
+#endif
+
+/*
+ * Note that the following structure must be the same
+ * size as the Dtlink_t structure
+ */
+struct Link
+{
+ struct Link *next;
+ Namval_t *node;
+};
+
+/*
+ * The following structure is used for command substitution and (...)
+ */
+static struct subshell
+{
+ struct subshell *prev; /* previous subshell data */
+ struct subshell *pipe; /* subshell where output goes to pipe on fork */
+ Dt_t *var; /* variable table at time of subshell */
+ struct Link *svar; /* save shell variable table */
+ Dt_t *sfun; /* function scope for subshell */
+ Dt_t *salias;/* alias scope for subshell */
+#ifdef PATH_BFPATH
+ Pathcomp_t *pathlist; /* for PATH variable */
+#endif
+#if (ERROR_VERSION >= 20030214L)
+ struct Error_context_s *errcontext;
+#else
+ struct errorcontext *errcontext;
+#endif
+ Shopt_t options;/* save shell options */
+ pid_t subpid; /* child process id */
+ Sfio_t* saveout;/*saved standard output */
+ char *pwd; /* present working directory */
+ const char *shpwd; /* saved pointer to sh.pwd */
+ void *jobs; /* save job info */
+ mode_t mask; /* saved umask */
+ short tmpfd; /* saved tmp file descriptor */
+ short pipefd; /* read fd if pipe is created */
+ char jobcontrol;
+ char monitor;
+ unsigned char fdstatus;
+ int fdsaved; /* bit make for saved files */
+ int bckpid;
+} *subshell_data;
+
+static int subenv;
+
+/*
+ * This routine will turn the sftmp() file into a real /tmp file or pipe
+ * if the /tmp file create fails
+ */
+void sh_subtmpfile(void)
+{
+ if(sfset(sfstdout,0,0)&SF_STRING)
+ {
+ register int fd;
+ register struct checkpt *pp = (struct checkpt*)sh.jmplist;
+ register struct subshell *sp = subshell_data->pipe;
+ /* save file descriptor 1 if open */
+ if((sp->tmpfd = fd = fcntl(1,F_DUPFD,10)) >= 0)
+ {
+ fcntl(fd,F_SETFD,FD_CLOEXEC);
+ sh.fdstatus[fd] = sh.fdstatus[1]|IOCLEX;
+ close(1);
+ }
+ else if(errno!=EBADF)
+ errormsg(SH_DICT,ERROR_system(1),e_toomany);
+ /* popping a discipline forces a /tmp file create */
+ sfdisc(sfstdout,SF_POPDISC);
+ if((fd=sffileno(sfstdout))<0)
+ {
+ /* unable to create the /tmp file so use a pipe */
+ int fds[2];
+ Sfoff_t off;
+ sh_pipe(fds);
+ sp->pipefd = fds[0];
+ sh_fcntl(sp->pipefd,F_SETFD,FD_CLOEXEC);
+ /* write the data to the pipe */
+ if(off = sftell(sfstdout))
+ write(fds[1],sfsetbuf(sfstdout,(Void_t*)sfstdout,0),(size_t)off);
+ sfclose(sfstdout);
+ if((sh_fcntl(fds[1],F_DUPFD, 1)) != 1)
+ errormsg(SH_DICT,ERROR_system(1),e_file+4);
+ sh_close(fds[1]);
+ }
+ else
+ {
+ sh.fdstatus[fd] = IOREAD|IOWRITE;
+ sfsync(sfstdout);
+ if(fd==1)
+ fcntl(1,F_SETFD,0);
+ else
+ {
+ sfsetfd(sfstdout,1);
+ sh.fdstatus[1] = sh.fdstatus[fd];
+ sh.fdstatus[fd] = IOCLOSE;
+ }
+ }
+ sh_iostream(1);
+ sfset(sfstdout,SF_SHARE|SF_PUBLIC,1);
+ sfpool(sfstdout,sh.outpool,SF_WRITE);
+ if(pp && pp->olist && pp->olist->strm == sfstdout)
+ pp->olist->strm = 0;
+ }
+}
+
+/*
+ * This routine creates a temp file if necessary and creates a subshell.
+ * The parent routine longjmps back to sh_subshell()
+ * The child continues possibly with its standard output replaced by temp file
+ */
+void sh_subfork(void)
+{
+ register struct subshell *sp = subshell_data;
+ pid_t pid;
+ /* see whether inside $(...) */
+ if(sp->pipe)
+ sh_subtmpfile();
+ if(pid = sh_fork(0,NIL(int*)))
+ {
+ /* this is the parent part of the fork */
+ if(sp->subpid==0)
+ sp->subpid = pid;
+ siglongjmp(*sh.jmplist,SH_JMPSUB);
+ }
+ else
+ {
+ int16_t subshell;
+ /* this is the child part of the fork */
+ /* setting subpid to 1 causes subshell to exit when reached */
+ sh_onstate(SH_FORKED);
+ sh_onstate(SH_NOLOG);
+ sh_offstate(SH_MONITOR);
+ subshell_data = 0;
+ subshell = sh.subshell = 0;
+ nv_putval(SH_SUBSHELLNOD, (char*)&subshell, NV_INT16);
+ sp->subpid=0;
+ }
+}
+
+/*
+ * This routine will make a copy of the given node in the
+ * layer created by the most recent subshell_fork if the
+ * node hasn't already been copied
+ */
+Namval_t *sh_assignok(register Namval_t *np,int add)
+{
+ register Namval_t *mp;
+ register struct Link *lp;
+ register struct subshell *sp = (struct subshell*)subshell_data;
+ int save;
+ /* don't bother with this */
+ if(!sp->shpwd || (nv_isnull(np) && !add))
+ return(np);
+ /* don't bother to save if in newer scope */
+ if(nv_search((char*)np,sp->var,HASH_BUCKET)!=np)
+ return(np);
+ for(lp=subshell_data->svar; lp; lp = lp->next)
+ {
+ if(lp->node==np)
+ return(np);
+ }
+ mp = newof(0,Namval_t,1,0);
+ lp = (struct Link*)mp;
+ lp->node = np;
+ lp->next = subshell_data->svar;
+ subshell_data->svar = lp;
+ save = sh.subshell;
+ sh.subshell = 0;;
+ nv_clone(np,mp,NV_NOFREE);
+ sh.subshell = save;
+ return(np);
+}
+
+/*
+ * restore the variables
+ */
+static void nv_restore(struct subshell *sp)
+{
+ register struct Link *lp, *lq;
+ register Namval_t *mp, *np;
+ const char *save = sp->shpwd;
+ sp->shpwd = 0; /* make sure sh_assignok doesn't save with nv_unset() */
+ for(lp=sp->svar; lp; lp=lq)
+ {
+ np = (Namval_t*)lp;
+ mp = lp->node;
+ lq = lp->next;
+ if(nv_isarray(mp))
+ nv_putsub(mp,NIL(char*),ARRAY_SCAN);
+ _nv_unset(mp,NV_RDONLY);
+ nv_setsize(mp,nv_size(np));
+ if(!nv_isattr(np,NV_MINIMAL) || nv_isattr(np,NV_EXPORT))
+ mp->nvenv = np->nvenv;
+ mp->nvfun = np->nvfun;
+ mp->nvflag = np->nvflag;
+ if((mp==nv_scoped(PATHNOD)) || (mp==nv_scoped(IFSNOD)))
+ nv_putval(mp, np->nvalue.cp,0);
+ else
+ mp->nvalue.cp = np->nvalue.cp;
+ np->nvfun = 0;
+ if(nv_isattr(mp,NV_EXPORT))
+ {
+ char *name = nv_name(mp);
+ sh_envput(sh.env,mp);
+ if(*name=='_' && strcmp(name,"_AST_FEATURES")==0)
+ astconf(NiL, NiL, NiL);
+ }
+ else if(nv_isattr(np,NV_EXPORT))
+ env_delete(sh.env,nv_name(mp));
+ free((void*)np);
+ }
+ sp->shpwd=save;
+}
+
+/*
+ * return pointer to alias tree
+ * create new one if in a subshell and one doesn't exist and create is non-zero
+ */
+Dt_t *sh_subaliastree(int create)
+{
+ register struct subshell *sp = subshell_data;
+ if(!sp || sh.curenv==0)
+ return(sh.alias_tree);
+ if(!sp->salias && create)
+ {
+ sp->salias = dtopen(&_Nvdisc,Dtoset);
+ dtview(sp->salias,sh.alias_tree);
+ sh.alias_tree = sp->salias;
+ }
+ return(sp->salias);
+}
+
+/*
+ * return pointer to function tree
+ * create new one if in a subshell and one doesn't exist and create is non-zero
+ */
+Dt_t *sh_subfuntree(int create)
+{
+ register struct subshell *sp = subshell_data;
+ if(!sp || sh.curenv==0)
+ return(sh.fun_tree);
+ if(!sp->sfun && create)
+ {
+ sp->sfun = dtopen(&_Nvdisc,Dtoset);
+ dtview(sp->sfun,sh.fun_tree);
+ sh.fun_tree = sp->sfun;
+ }
+ return(sp->sfun);
+}
+
+static void table_unset(register Dt_t *root)
+{
+ register Namval_t *np,*nq;
+ for(np=(Namval_t*)dtfirst(root);np;np=nq)
+ {
+ _nv_unset(np,NV_RDONLY);
+ nq = (Namval_t*)dtnext(root,np);
+ dtdelete(root,np);
+ free((void*)np);
+ }
+}
+
+int sh_subsavefd(register int fd)
+{
+ register struct subshell *sp = subshell_data;
+ register int old=0;
+ if(sp)
+ {
+ old = !(sp->fdsaved&(1<<(fd-1)));
+ sp->fdsaved |= (1<<(fd-1));
+ }
+ return(old);
+}
+
+/*
+ * Run command tree <t> in a virtual sub-shell
+ * If comsub is not null, then output will be placed in temp file (or buffer)
+ * If comsub is not null, the return value will be a stream consisting of
+ * output of command <t>. Otherwise, NULL will be returned.
+ */
+
+Sfio_t *sh_subshell(Shnode_t *t, int flags, int comsub)
+{
+ Shell_t *shp = &sh;
+ struct subshell sub_data;
+ register struct subshell *sp = &sub_data;
+ int jmpval,nsig;
+ int savecurenv = shp->curenv;
+ int16_t subshell;
+ char *savsig;
+ Sfio_t *iop=0;
+ struct checkpt buff;
+ struct sh_scoped savst;
+ struct dolnod *argsav=0;
+ memset((char*)sp, 0, sizeof(*sp));
+ sfsync(shp->outpool);
+ argsav = sh_arguse();
+ if(shp->curenv==0)
+ {
+ subshell_data=0;
+ subenv = 0;
+ }
+ shp->curenv = ++subenv;
+ savst = shp->st;
+ sh_pushcontext(&buff,SH_JMPSUB);
+ subshell = shp->subshell+1;
+ nv_putval(SH_SUBSHELLNOD, (char*)&subshell, NV_INT16);
+ shp->subshell = subshell;
+ sp->prev = subshell_data;
+ subshell_data = sp;
+ sp->errcontext = &buff.err;
+ sp->var = shp->var_tree;
+ sp->options = shp->options;
+ sp->jobs = job_subsave();
+#ifdef PATH_BFPATH
+ /* make sure initialization has occurred */
+ if(!shp->pathlist)
+ path_get(".");
+ sp->pathlist = path_dup((Pathcomp_t*)shp->pathlist);
+#endif
+ if(!shp->pwd)
+ path_pwd(0);
+ sp->bckpid = shp->bckpid;
+ if(!comsub || !sh_isoption(SH_SUBSHARE))
+ {
+ sp->shpwd = shp->pwd;
+ sp->pwd = (shp->pwd?strdup(shp->pwd):0);
+ sp->mask = shp->mask;
+ /* save trap table */
+ shp->st.otrapcom = 0;
+ if((nsig=shp->st.trapmax*sizeof(char*))>0 || shp->st.trapcom[0])
+ {
+ nsig += sizeof(char*);
+ memcpy(savsig=malloc(nsig),(char*)&shp->st.trapcom[0],nsig);
+ /* this nonsense needed for $(trap) */
+ shp->st.otrapcom = (char**)savsig;
+ }
+ sh_sigreset(0);
+ }
+ jmpval = sigsetjmp(buff.buff,0);
+ if(jmpval==0)
+ {
+ if(comsub)
+ {
+ /* disable job control */
+ sp->jobcontrol = job.jobcontrol;
+ sp->monitor = (sh_isstate(SH_MONITOR)!=0);
+ job.jobcontrol=0;
+ sh_offstate(SH_MONITOR);
+ sp->pipe = sp;
+ /* save sfstdout and status */
+ sp->saveout = sfswap(sfstdout,NIL(Sfio_t*));
+ sp->fdstatus = shp->fdstatus[1];
+ sp->tmpfd = -1;
+ sp->pipefd = -1;
+ /* use sftmp() file for standard output */
+ if(!(iop = sftmp(PIPE_BUF)))
+ {
+ sfswap(sp->saveout,sfstdout);
+ errormsg(SH_DICT,ERROR_system(1),e_tmpcreate);
+ }
+ sfswap(iop,sfstdout);
+ sfset(sfstdout,SF_READ,0);
+ shp->fdstatus[1] = IOWRITE;
+ }
+ else if(sp->prev)
+ {
+ sp->pipe = sp->prev->pipe;
+ flags &= ~sh_state(SH_NOFORK);
+ }
+ sh_exec(t,flags);
+ }
+ if(jmpval!=SH_JMPSUB && shp->st.trapcom[0] && shp->subshell)
+ {
+ /* trap on EXIT not handled by child */
+ char *trap=shp->st.trapcom[0];
+ shp->st.trapcom[0] = 0; /* prevent recursion */
+ shp->oldexit = shp->exitval;
+ sh_trap(trap,0);
+ free(trap);
+ }
+ sh_popcontext(&buff);
+ if(shp->subshell==0) /* must be child process */
+ {
+ subshell_data = sp->prev;
+ if(jmpval==SH_JMPSCRIPT)
+ siglongjmp(*shp->jmplist,jmpval);
+ sh_done(0);
+ }
+ if(comsub)
+ {
+ /* re-enable job control */
+ job.jobcontrol = sp->jobcontrol;
+ if(sp->monitor)
+ sh_onstate(SH_MONITOR);
+ if(sp->pipefd>=0)
+ {
+ /* sftmp() file has been returned into pipe */
+ iop = sh_iostream(sp->pipefd);
+ sfdisc(iop,SF_POPDISC);
+ sfclose(sfstdout);
+ }
+ else
+ {
+ /* move tmp file to iop and restore sfstdout */
+ iop = sfswap(sfstdout,NIL(Sfio_t*));
+ if(!iop)
+ {
+ /* maybe locked try again */
+ sfclrlock(sfstdout);
+ iop = sfswap(sfstdout,NIL(Sfio_t*));
+ }
+ if(iop && sffileno(iop)==1)
+ {
+ int fd=sfsetfd(iop,3);
+ if(fd<0)
+ errormsg(SH_DICT,ERROR_system(1),e_toomany);
+ shp->sftable[fd] = iop;
+ fcntl(fd,F_SETFD,FD_CLOEXEC);
+ shp->fdstatus[fd] = (shp->fdstatus[1]|IOCLEX);
+ shp->fdstatus[1] = IOCLOSE;
+ }
+ sfset(iop,SF_READ,1);
+ }
+ sfswap(sp->saveout,sfstdout);
+ /* check if standard output was preserved */
+ if(sp->tmpfd>=0)
+ {
+ close(1);
+ fcntl(sp->tmpfd,F_DUPFD,1);
+ sh_close(sp->tmpfd);
+ }
+ shp->fdstatus[1] = sp->fdstatus;
+ }
+ if(sp->subpid)
+ job_wait(sp->subpid);
+ if(comsub && iop)
+ sfseek(iop,(off_t)0,SEEK_SET);
+ if(shp->subshell)
+ shp->subshell--;
+ subshell = shp->subshell;
+ nv_putval(SH_SUBSHELLNOD, (char*)&subshell, NV_INT16);
+#ifdef PATH_BFPATH
+ path_delete((Pathcomp_t*)shp->pathlist);
+ shp->pathlist = (void*)sp->pathlist;
+#endif
+ job_subrestore(sp->jobs);
+ shp->jobenv = savecurenv;
+ shp->bckpid = sp->bckpid;
+ if(sp->shpwd) /* restore environment if saved */
+ {
+ shp->options = sp->options;
+ nv_restore(sp);
+ if(sp->salias)
+ {
+ shp->alias_tree = dtview(sp->salias,0);
+ table_unset(sp->salias);
+ dtclose(sp->salias);
+ }
+ if(sp->sfun)
+ {
+ shp->fun_tree = dtview(sp->sfun,0);
+ table_unset(sp->sfun);
+ dtclose(sp->sfun);
+ }
+ sh_sigreset(1);
+ shp->st = savst;
+ shp->curenv = savecurenv;
+ if(nsig)
+ {
+ memcpy((char*)&shp->st.trapcom[0],savsig,nsig);
+ free((void*)savsig);
+ }
+ shp->options = sp->options;
+ if(!shp->pwd || strcmp(sp->pwd,shp->pwd))
+ {
+ /* restore PWDNOD */
+ Namval_t *pwdnod = nv_scoped(PWDNOD);
+ if(shp->pwd)
+ {
+ chdir(shp->pwd=sp->pwd);
+#ifdef PATH_BFPATH
+ path_newdir(shp->pathlist);
+#endif
+ }
+ if(nv_isattr(pwdnod,NV_NOFREE))
+ pwdnod->nvalue.cp = (const char*)sp->pwd;
+ }
+ else if(sp->shpwd != shp->pwd)
+ {
+ shp->pwd = sp->pwd;
+ if(PWDNOD->nvalue.cp==sp->shpwd)
+ PWDNOD->nvalue.cp = sp->pwd;
+ }
+ else
+ free((void*)sp->pwd);
+ if(sp->mask!=shp->mask)
+ umask(shp->mask);
+ }
+ subshell_data = sp->prev;
+ sh_argfree(argsav,0);
+ shp->trapnote = 0;
+ if(shp->topfd != buff.topfd)
+ sh_iorestore(buff.topfd|IOSUBSHELL,jmpval);
+ if(shp->exitval > SH_EXITSIG)
+ {
+ int sig = shp->exitval&SH_EXITMASK;
+ if(sig==SIGINT || sig== SIGQUIT)
+ sh_fault(sig);
+ }
+ return(iop);
+}
diff --git a/usr/src/lib/libshell/common/sh/suid_exec.c b/usr/src/lib/libshell/common/sh/suid_exec.c
new file mode 100644
index 0000000000..0495d29890
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/suid_exec.c
@@ -0,0 +1,509 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * This is a program to execute 'execute only' and suid/sgid shell scripts.
+ * This program must be owned by root and must have the set uid bit set.
+ * It must not have the set group id bit set. This program must be installed
+ * where the define parameter THISPROG indicates to work correctly on system V
+ *
+ * Written by David Korn
+ * AT&T Labs
+ * Enhanced by Rob Stampfli
+ */
+
+/* The file name of the script to execute is argv[0]
+ * Argv[1] is the program name
+ * The basic idea is to open the script as standard input, set the effective
+ * user and group id correctly, and then exec the shell.
+ * The complicated part is getting the effective uid of the caller and
+ * setting the effective uid/gid. The program which execs this program
+ * may pass file descriptor FDIN as an open file with mode SPECIAL if
+ * the effective user id is not the real user id. The effective
+ * user id for authentication purposes will be the owner of this
+ * open file. On systems without the setreuid() call, e[ug]id is set
+ * by copying this program to a /tmp/file, making it a suid and/or sgid
+ * program, and then execing this program.
+ * A forked version of this program waits until it can unlink the /tmp
+ * file and then exits. Actually, we fork() twice so the parent can
+ * wait for the child to complete. A pipe is used to guarantee that we
+ * do not remove the /tmp file too soon.
+ */
+
+#include <ast.h>
+#include "FEATURE/externs"
+#include <ls.h>
+#include <sig.h>
+#include <error.h>
+#include <sys/wait.h>
+#include "version.h"
+
+#define SPECIAL 04100 /* setuid execute only by owner */
+#define FDIN 10 /* must be same as /dev/fd below */
+#undef FDSYNC
+#define FDSYNC 11 /* used on sys5 to synchronize cleanup */
+#define FDVERIFY 12 /* used to validate /tmp process */
+#undef BLKSIZE
+#define BLKSIZE sizeof(char*)*1024
+#define THISPROG "/etc/suid_exec"
+#define DEFSHELL "/bin/sh"
+
+static void error_exit(const char*);
+static int in_dir(const char*, const char*);
+static int endsh(const char*);
+#ifndef _lib_setregid
+# undef _lib_setreuid
+#endif
+#ifndef _lib_setreuid
+ static void setids(int,uid_t,gid_t);
+ static int mycopy(int, int);
+ static void maketemp(char*);
+#else
+ static void setids(int,int,int);
+#endif /* _lib_setreuid */
+
+static const char version[] = "\n@(#)$Id: suid_exec "SH_RELEASE" $\n";
+static const char badopen[] = "cannot open";
+static const char badexec[] = "cannot exec";
+static const char devfd[] = "/dev/fd/10"; /* must match FDIN above */
+static char tmpname[] = "/tmp/SUIDXXXXXX";
+static char **arglist;
+
+static char *shell;
+static char *command;
+static uid_t ruserid;
+static uid_t euserid;
+static gid_t rgroupid;
+static gid_t egroupid;
+static struct stat statb;
+
+int main(int argc,char *argv[])
+{
+ register int m,n;
+ register char *p;
+ struct stat statx;
+ int mode;
+ uid_t effuid;
+ gid_t effgid;
+ NOT_USED(argc);
+ arglist = argv;
+ if((command = argv[1]) == 0)
+ error_exit(badexec);
+ ruserid = getuid();
+ euserid = geteuid();
+ rgroupid = getgid();
+ egroupid = getegid();
+ p = argv[0];
+#ifndef _lib_setreuid
+ maketemp(tmpname);
+ if(strcmp(p,tmpname)==0)
+ {
+ /* At this point, the presumption is that we are the
+ * version of THISPROG copied into /tmp, with the owner,
+ * group, and setuid/gid bits correctly set. This copy of
+ * the program is executable by anyone, so we must be careful
+ * not to allow just any invocation of it to succeed, since
+ * it is setuid/gid. Validate the proper execution by
+ * examining the FDVERIFY file descriptor -- if it is owned
+ * by root and is mode SPECIAL, then this is proof that it was
+ * passed by a program with superuser privileges -- hence we
+ * can presume legitimacy. Otherwise, bail out, as we suspect
+ * an impostor.
+ */
+ if(fstat(FDVERIFY,&statb) < 0 || statb.st_uid != 0 ||
+ (statb.st_mode & ~S_IFMT) != SPECIAL || close(FDVERIFY)<0)
+ error_exit(badexec);
+ /* This enables the grandchild to clean up /tmp file */
+ close(FDSYNC);
+ /* Make sure that this is a valid invocation of the clone.
+ * Perhaps unnecessary, given FDVERIFY, but what the heck...
+ */
+ if(stat(tmpname,&statb) < 0 || statb.st_nlink != 1 ||
+ !S_ISREG(statb.st_mode))
+ error_exit(badexec);
+ if(ruserid != euserid &&
+ ((statb.st_mode & S_ISUID) == 0 || statb.st_uid != euserid))
+ error_exit(badexec);
+ goto exec;
+ }
+ /* Make sure that this is the real setuid program, not the clone.
+ * It is possible by clever hacking to get past this point in the
+ * clone, but it doesn't do the hacker any good that I can see.
+ */
+ if(euserid)
+ error_exit(badexec);
+#endif /* _lib_setreuid */
+ /* Open the script for reading first and then validate it. This
+ * prevents someone from pulling a switcheroo while we are validating.
+ */
+ n = open(p,0);
+ if(n == FDIN)
+ {
+ n = dup(n);
+ close(FDIN);
+ }
+ if(n < 0)
+ error_exit(badopen);
+ /* validate execution rights to this script */
+ if(fstat(FDIN,&statb) < 0 || (statb.st_mode & ~S_IFMT) != SPECIAL)
+ euserid = ruserid;
+ else
+ euserid = statb.st_uid;
+ /* do it the easy way if you can */
+ if(euserid == ruserid && egroupid == rgroupid)
+ {
+ if(access(p,X_OK) < 0)
+ error_exit(badexec);
+ }
+ else
+ {
+ /* have to check access on each component */
+ while(*p++)
+ {
+ if(*p == '/' || *p == 0)
+ {
+ m = *p;
+ *p = 0;
+ if(eaccess(argv[0],X_OK) < 0)
+ error_exit(badexec);
+ *p = m;
+ }
+ }
+ p = argv[0];
+ }
+ if(fstat(n, &statb) < 0 || !S_ISREG(statb.st_mode))
+ error_exit(badopen);
+ if(stat(p, &statx) < 0 ||
+ statb.st_ino != statx.st_ino || statb.st_dev != statx.st_dev)
+ error_exit(badexec);
+ if(stat(THISPROG, &statx) < 0 ||
+ (statb.st_ino == statx.st_ino && statb.st_dev == statx.st_dev))
+ error_exit(badexec);
+ close(FDIN);
+ if(fcntl(n,F_DUPFD,FDIN) != FDIN)
+ error_exit(badexec);
+ close(n);
+
+ /* compute the desired new effective user and group id */
+ effuid = euserid;
+ effgid = egroupid;
+ mode = 0;
+ if(statb.st_mode & S_ISUID)
+ effuid = statb.st_uid;
+ if(statb.st_mode & S_ISGID)
+ effgid = statb.st_gid;
+
+ /* see if group needs setting */
+ if(effgid != egroupid)
+ if(effgid != rgroupid || setgid(rgroupid) < 0)
+ mode = S_ISGID;
+
+ /* now see if the uid needs setting */
+ if(mode)
+ {
+ if(effuid != ruserid)
+ mode |= S_ISUID;
+ }
+ else if(effuid)
+ {
+ if(effuid != ruserid || setuid(ruserid) < 0)
+ mode = S_ISUID;
+ }
+
+ if(mode)
+ setids(mode, effuid, effgid);
+#ifndef _lib_setreuid
+exec:
+#endif /* _lib_setreuid */
+ /* only use SHELL if file is in trusted directory and ends in sh */
+ shell = getenv("SHELL");
+ if(shell == 0 || !endsh(shell) || (
+ !in_dir("/bin",shell) &&
+ !in_dir("/usr/bin",shell) &&
+ !in_dir("/usr/lbin",shell) &&
+ !in_dir("/usr/local/bin",shell)))
+ shell = DEFSHELL;
+ argv[0] = command;
+ argv[1] = (char*)devfd;
+ execv(shell,argv);
+ error_exit(badexec);
+}
+
+/*
+ * return true of shell ends in sh of ksh
+ */
+
+static int endsh(register const char *shell)
+{
+ while(*shell)
+ shell++;
+ if(*--shell != 'h' || *--shell != 's')
+ return(0);
+ if(*--shell=='/')
+ return(1);
+ if(*shell=='k' && *--shell=='/')
+ return(1);
+ return(0);
+}
+
+
+/*
+ * return true of shell is in <dir> directory
+ */
+
+static int in_dir(register const char *dir,register const char *shell)
+{
+ while(*dir)
+ {
+ if(*dir++ != *shell++)
+ return(0);
+ }
+ /* return true if next character is a '/' */
+ return(*shell=='/');
+}
+
+static void error_exit(const char *message)
+{
+ sfprintf(sfstdout,"%s: %s\n",command,message);
+ exit(126);
+}
+
+
+/*
+ * This version of access checks against effective uid and effective gid
+ */
+
+int eaccess(register const char *name, register int mode)
+{
+ struct stat statb;
+ if (stat(name, &statb) == 0)
+ {
+ if(euserid == 0)
+ {
+ if(!S_ISREG(statb.st_mode) || mode != 1)
+ return(0);
+ /* root needs execute permission for someone */
+ mode = (S_IXUSR|S_IXGRP|S_IXOTH);
+ }
+ else if(euserid == statb.st_uid)
+ mode <<= 6;
+ else if(egroupid == statb.st_gid)
+ mode <<= 3;
+#ifdef _lib_getgroups
+ /* on some systems you can be in several groups */
+ else
+ {
+ static int maxgroups;
+ gid_t *groups=0;
+ register int n;
+ if(maxgroups==0)
+ {
+ /* first time */
+ if((maxgroups=getgroups(0,groups)) < 0)
+ {
+ /* pre-POSIX system */
+ maxgroups=NGROUPS_MAX;
+ }
+ }
+ groups = (gid_t*)malloc((maxgroups+1)*sizeof(gid_t));
+ n = getgroups(maxgroups,groups);
+ while(--n >= 0)
+ {
+ if(groups[n] == statb.st_gid)
+ {
+ mode <<= 3;
+ break;
+ }
+ }
+ }
+#endif /* _lib_getgroups */
+ if(statb.st_mode & mode)
+ return(0);
+ }
+ return(-1);
+}
+
+#ifdef _lib_setreuid
+static void setids(int mode,int owner,int group)
+{
+ if(mode & S_ISGID)
+ setregid(rgroupid,group);
+
+ /* set effective uid even if S_ISUID is not set. This is because
+ * we are *really* executing EUID root at this point. Even if S_ISUID
+ * is not set, the value for owner that is passsed should be correct.
+ */
+ setreuid(ruserid,owner);
+}
+
+#else
+/*
+ * This version of setids creats a /tmp file and copies itself into it.
+ * The "clone" file is made executable with appropriate suid/sgid bits.
+ * Finally, the clone is exec'ed. This file is unlinked by a grandchild
+ * of this program, who waits around until the text is free.
+ */
+
+static void setids(int mode,uid_t owner,gid_t group)
+{
+ register int n,m;
+ int pv[2];
+
+ /*
+ * Create a token to pass to the new program for validation.
+ * This token can only be procured by someone running with an
+ * effective userid of root, and hence gives the clone a way to
+ * certify that it was really invoked by THISPROG. Someone who
+ * is already root could spoof us, but why would they want to?
+ *
+ * Since we are root here, we must be careful: What if someone
+ * linked a valuable file to tmpname?
+ */
+ unlink(tmpname); /* should normally fail */
+#ifdef O_EXCL
+ if((n = open(tmpname, O_WRONLY | O_CREAT | O_EXCL, SPECIAL)) < 0 ||
+ unlink(tmpname) < 0)
+#else
+ if((n = open(tmpname, O_WRONLY | O_CREAT ,SPECIAL)) < 0 || unlink(tmpname) < 0)
+#endif
+ error_exit(badexec);
+ if(n != FDVERIFY)
+ {
+ close(FDVERIFY);
+ if(fcntl(n,F_DUPFD,FDVERIFY) != FDVERIFY)
+ error_exit(badexec);
+ }
+ mode |= S_IEXEC|(S_IEXEC>>3)|(S_IEXEC>>6);
+ /* create a pipe for synchronization */
+ if(pipe(pv) < 0)
+ error_exit(badexec);
+ if((n=fork()) == 0)
+ { /* child */
+ close(FDVERIFY);
+ close(pv[1]);
+ if((n=fork()) == 0)
+ { /* grandchild -- cleans up clone file */
+ signal(SIGHUP, SIG_IGN);
+ signal(SIGINT, SIG_IGN);
+ signal(SIGQUIT, SIG_IGN);
+ signal(SIGTERM, SIG_IGN);
+ read(pv[0],pv,1); /* wait for clone to close pipe */
+ while(unlink(tmpname) < 0 && errno == ETXTBSY)
+ sleep(1);
+ exit(0);
+ }
+ else if(n == -1)
+ exit(1);
+ else
+ {
+ /* Create a set[ug]id file that will become the clone.
+ * To make this atomic, without need for chown(), the
+ * child takes on desired user and group. The only
+ * downsize of this that I can see is that it may
+ * screw up some per- * user accounting.
+ */
+ if((m = open(THISPROG, O_RDONLY)) < 0)
+ exit(1);
+ if((mode & S_ISGID) && setgid(group) < 0)
+ exit(1);
+ if((mode & S_ISUID) && owner && setuid(owner) < 0)
+ exit(1);
+#ifdef O_EXCL
+ if((n = open(tmpname,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, mode)) < 0)
+#else
+ unlink(tmpname);
+ if((n = open(tmpname,O_WRONLY|O_CREAT|O_TRUNC, mode)) < 0)
+#endif /* O_EXCL */
+ exit(1);
+ /* populate the clone */
+ m = mycopy(m,n);
+ if(chmod(tmpname,mode) <0)
+ exit(1);
+ exit(m);
+ }
+ }
+ else if(n == -1)
+ error_exit(badexec);
+ else
+ {
+ arglist[0] = (char*)tmpname;
+ close(pv[0]);
+ /* move write end of pipe into FDSYNC */
+ if(pv[1] != FDSYNC)
+ {
+ close(FDSYNC);
+ if(fcntl(pv[1],F_DUPFD,FDSYNC) != FDSYNC)
+ error_exit(badexec);
+ }
+ /* wait for child to die */
+ while((m = wait(0)) != n)
+ if(m == -1 && errno != EINTR)
+ break;
+ /* Kill any setuid status at this point. That way, if the
+ * clone is not setuid, we won't exec it as root. Also, don't
+ * neglect to consider that someone could have switched the
+ * clone file on us.
+ */
+ if(setuid(ruserid) < 0)
+ error_exit(badexec);
+ execv(tmpname,arglist);
+ error_exit(badexec);
+ }
+}
+
+/*
+ * create a unique name into the <template>
+ */
+
+static void maketemp(char *template)
+{
+ register char *cp = template;
+ register pid_t n = getpid();
+ /* skip to end of string */
+ while(*++cp);
+ /* convert process id to string */
+ while(n > 0)
+ {
+ *--cp = (n%10) + '0';
+ n /= 10;
+ }
+
+}
+
+/*
+ * copy THISPROG into the open file number <fdo> and close <fdo>
+ */
+
+static int mycopy(int fdi, int fdo)
+{
+ char buffer[BLKSIZE];
+ register int n;
+
+ while((n = read(fdi,buffer,BLKSIZE)) > 0)
+ if(write(fdo,buffer,n) != n)
+ break;
+ close(fdi);
+ close(fdo);
+ return n;
+}
+
+#endif /* _lib_setreuid */
+
+
diff --git a/usr/src/lib/libshell/common/sh/tdump.c b/usr/src/lib/libshell/common/sh/tdump.c
new file mode 100644
index 0000000000..80ef55a9aa
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/tdump.c
@@ -0,0 +1,260 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * shell parse tree dump
+ *
+ */
+
+#include <ccode.h>
+#include "defs.h"
+#include "shnodes.h"
+#include "path.h"
+#include "io.h"
+
+static int p_comlist(const struct dolnod*);
+static int p_arg(const struct argnod*);
+static int p_comarg(const struct comnod*);
+static int p_redirect(const struct ionod*);
+static int p_switch(const struct regnod*);
+static int p_tree(const Shnode_t*);
+static int p_string(const char*);
+
+static Sfio_t *outfile;
+
+int sh_tdump(Sfio_t *out, const Shnode_t *t)
+{
+ outfile = out;
+ return(p_tree(t));
+}
+
+/*
+ * convert to ASCII to write and back again if needed
+ */
+static int outstring(Sfio_t *out, const char *string, int n)
+{
+ int r;
+ char *cp = (char*)string;
+ ccmaps(cp, n, CC_NATIVE, CC_ASCII);
+ r = sfwrite(out,cp,n);
+ ccmaps(cp, n, CC_ASCII, CC_NATIVE);
+ return(r);
+}
+
+/*
+ * print script corresponding to shell tree <t>
+ */
+static int p_tree(register const Shnode_t *t)
+{
+ if(!t)
+ return(sfputl(outfile,-1));
+ if(sfputl(outfile,t->tre.tretyp)<0)
+ return(-1);
+ switch(t->tre.tretyp&COMMSK)
+ {
+ case TTIME:
+ case TPAR:
+ return(p_tree(t->par.partre));
+ case TCOM:
+ return(p_comarg((struct comnod*)t));
+ case TSETIO:
+ case TFORK:
+ if(sfputu(outfile,t->fork.forkline)<0)
+ return(-1);
+ if(p_tree(t->fork.forktre)<0)
+ return(-1);
+ return(p_redirect(t->fork.forkio));
+ case TIF:
+ if(p_tree(t->if_.iftre)<0)
+ return(-1);
+ if(p_tree(t->if_.thtre)<0)
+ return(-1);
+ return(p_tree(t->if_.eltre));
+ case TWH:
+ if(t->wh.whinc)
+ {
+ if(p_tree((Shnode_t*)(t->wh.whinc))<0)
+ return(-1);
+ }
+ else
+ {
+ if(sfputl(outfile,-1)<0)
+ return(-1);
+ }
+ if(p_tree(t->wh.whtre)<0)
+ return(-1);
+ return(p_tree(t->wh.dotre));
+ case TLST:
+ case TAND:
+ case TORF:
+ case TFIL:
+ if(p_tree(t->lst.lstlef)<0)
+ return(-1);
+ return(p_tree(t->lst.lstrit));
+ case TARITH:
+ if(sfputu(outfile,t->ar.arline)<0)
+ return(-1);
+ return(p_arg(t->ar.arexpr));
+ case TFOR:
+ if(sfputu(outfile,t->for_.forline)<0)
+ return(-1);
+ if(p_tree(t->for_.fortre)<0)
+ return(-1);
+ if(p_string(t->for_.fornam)<0)
+ return(-1);
+ return(p_tree((Shnode_t*)t->for_.forlst));
+ case TSW:
+ if(sfputu(outfile,t->sw.swline)<0)
+ return(-1);
+ if(p_arg(t->sw.swarg)<0)
+ return(-1);
+ return(p_switch(t->sw.swlst));
+ case TFUN:
+ if(sfputu(outfile,t->funct.functline)<0)
+ return(-1);
+ if(p_string(t->funct.functnam)<0)
+ return(-1);
+ if(p_tree(t->funct.functtre)<0)
+ return(-1);
+ return(p_tree((Shnode_t*)t->funct.functargs));
+ case TTST:
+ if(sfputu(outfile,t->tst.tstline)<0)
+ return(-1);
+ if((t->tre.tretyp&TPAREN)==TPAREN)
+ return(p_tree(t->lst.lstlef));
+ else
+ {
+ if(p_arg(&(t->lst.lstlef->arg))<0)
+ return(-1);
+ if((t->tre.tretyp&TBINARY))
+ return(p_arg(&(t->lst.lstrit->arg)));
+ return(0);
+ }
+ }
+ return(-1);
+}
+
+static int p_arg(register const struct argnod *arg)
+{
+ register int n;
+ struct fornod *fp;
+ while(arg)
+ {
+ if((n = strlen(arg->argval)) || (arg->argflag&~ARG_APPEND))
+ fp=0;
+ else
+ {
+ fp=(struct fornod*)arg->argchn.ap;
+ n = strlen(fp->fornam)+1;
+ }
+ sfputu(outfile,n+1);
+ if(fp)
+ {
+ sfputc(outfile,0);
+ outstring(outfile,fp->fornam,n-1);
+ }
+ else
+ outstring(outfile,arg->argval,n);
+ sfputc(outfile,arg->argflag);
+ if(fp)
+ {
+ sfputu(outfile,fp->fortyp);
+ p_tree(fp->fortre);
+ }
+ arg = arg->argnxt.ap;
+ }
+ return(sfputu(outfile,0));
+}
+
+static int p_redirect(register const struct ionod *iop)
+{
+ while(iop)
+ {
+ if(iop->iovname)
+ sfputl(outfile,iop->iofile|IOVNM);
+ else
+ sfputl(outfile,iop->iofile);
+ p_string(iop->ioname);
+ if(iop->iodelim)
+ {
+ p_string(iop->iodelim);
+ sfputl(outfile,iop->iosize);
+ sfseek(sh.heredocs,iop->iooffset,SEEK_SET);
+ sfmove(sh.heredocs,outfile, iop->iosize,-1);
+ }
+ else
+ sfputu(outfile,0);
+ if(iop->iovname)
+ p_string(iop->iovname);
+ iop = iop->ionxt;
+ }
+ return(sfputl(outfile,-1));
+}
+
+static int p_comarg(register const struct comnod *com)
+{
+ p_redirect(com->comio);
+ p_arg(com->comset);
+ if(!com->comarg)
+ sfputl(outfile,-1);
+ else if(com->comtyp&COMSCAN)
+ p_arg(com->comarg);
+ else
+ p_comlist((struct dolnod*)com->comarg);
+ return(sfputu(outfile,com->comline));
+}
+
+static int p_comlist(const struct dolnod *dol)
+{
+ register char *cp, *const*argv;
+ register int n;
+ argv = dol->dolval+ARG_SPARE;
+ while(cp = *argv)
+ argv++;
+ n = argv - (dol->dolval+1);
+ sfputl(outfile,n);
+ argv = dol->dolval+ARG_SPARE;
+ while(cp = *argv++)
+ p_string(cp);
+ return(sfputu(outfile,0));
+}
+
+static int p_switch(register const struct regnod *reg)
+{
+ while(reg)
+ {
+ sfputl(outfile,reg->regflag);
+ p_arg(reg->regptr);
+ p_tree(reg->regcom);
+ reg = reg->regnxt;
+ }
+ return(sfputl(outfile,-1));
+}
+
+static int p_string(register const char *string)
+{
+ register size_t n=strlen(string);
+ if(sfputu(outfile,n+1)<0)
+ return(-1);
+ return(outstring(outfile,string,n));
+}
diff --git a/usr/src/lib/libshell/common/sh/timers.c b/usr/src/lib/libshell/common/sh/timers.c
new file mode 100644
index 0000000000..ae57a3336f
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/timers.c
@@ -0,0 +1,248 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include <ast.h>
+#include <sig.h>
+#include <error.h>
+#include "fault.h"
+#include "defs.h"
+#include "FEATURE/sigfeatures"
+#include "FEATURE/time"
+
+typedef struct _timer
+{
+ double wakeup;
+ double incr;
+ struct _timer *next;
+ void (*action)(void*);
+ void *handle;
+} Timer_t;
+
+#define IN_ADDTIMEOUT 1
+#define IN_SIGALRM 2
+#define DEFER_SIGALRM 4
+#define SIGALRM_CALL 8
+
+static Timer_t *tptop, *tpmin, *tpfree;
+static char time_state;
+
+static double getnow(void)
+{
+ register double now;
+#ifdef timeofday
+ struct timeval tp;
+ timeofday(&tp);
+ now = tp.tv_sec + 1.e-6*tp.tv_usec;
+
+#else
+ now = (double)time((time_t*)0);
+#endif /* timeofday */
+ return(now+.001);
+}
+
+/*
+ * set an alarm for <t> seconds
+ */
+static double setalarm(register double t)
+{
+#if defined(_lib_setitimer) && defined(ITIMER_REAL)
+ struct itimerval tnew, told;
+ tnew.it_value.tv_sec = t;
+ tnew.it_value.tv_usec = 1.e6*(t- (double)tnew.it_value.tv_sec);
+ if(t && tnew.it_value.tv_sec==0 && tnew.it_value.tv_usec<1000)
+ tnew.it_value.tv_usec = 1000;
+ tnew.it_interval.tv_sec = 0;
+ tnew.it_interval.tv_usec = 0;
+ if(setitimer(ITIMER_REAL,&tnew,&told) < 0)
+ errormsg(SH_DICT,ERROR_system(1),e_alarm);
+ t = told.it_value.tv_sec + 1.e-6*told.it_value.tv_usec;
+#else
+ unsigned seconds = (unsigned)t;
+ if(t && seconds<1)
+ seconds=1;
+ t = (double)alarm(seconds);
+#endif
+ return(t);
+}
+
+/* signal handler for alarm call */
+static void sigalrm(int sig)
+{
+ register Timer_t *tp, *tplast, *tpold, *tpnext;
+ double now;
+ static double left;
+ NOT_USED(sig);
+ left = 0;
+ if(time_state&SIGALRM_CALL)
+ time_state &= ~SIGALRM_CALL;
+ else if(alarm(0))
+ sh_fault(SIGALRM|SH_TRAP);
+ if(time_state)
+ {
+ if(time_state&IN_ADDTIMEOUT)
+ time_state |= DEFER_SIGALRM;
+ errno = EINTR;
+ return;
+ }
+ time_state |= IN_SIGALRM;
+ sigrelease(SIGALRM);
+ while(1)
+ {
+ now = getnow();
+ tpold = tpmin = 0;
+ for(tplast=0,tp=tptop; tp; tp=tpnext)
+ {
+ tpnext = tp->next;
+ if(tp->action)
+ {
+ if(tp->wakeup <=now)
+ {
+ if(!tpold || tpold->wakeup>tp->wakeup)
+ tpold = tp;
+ }
+ else
+ {
+ if(!tpmin || tpmin->wakeup>tp->wakeup)
+ tpmin=tp;
+ }
+ tplast = tp;
+ }
+ else
+ {
+ if(tplast)
+ tplast->next = tp->next;
+ else
+ tptop = tp->next;
+ tp->next = tpfree;
+ tpfree = tp;
+ }
+ }
+ if((tp=tpold) && tp->incr)
+ {
+ while((tp->wakeup += tp->incr) <= now);
+ if(!tpmin || tpmin->wakeup>tp->wakeup)
+ tpmin=tp;
+ }
+ if(tpmin && (left==0 || (tp && tpmin->wakeup < (now+left))))
+ {
+ if(left==0)
+ signal(SIGALRM,sigalrm);
+ left = setalarm(tpmin->wakeup-now);
+ if(left && (now+left) < tpmin->wakeup)
+ setalarm(left);
+ else
+ left=tpmin->wakeup-now;
+ }
+ if(tp)
+ {
+ void (*action)(void*);
+ action = tp->action;
+ if(!tp->incr)
+ tp->action = 0;
+ errno = EINTR;
+ time_state &= ~IN_SIGALRM;
+ (*action)(tp->handle);
+ time_state |= IN_SIGALRM;
+ }
+ else
+ break;
+ }
+ if(!tpmin)
+ signal(SIGALRM,(sh.sigflag[SIGALRM]&SH_SIGFAULT)?sh_fault:SIG_DFL);
+ time_state &= ~IN_SIGALRM;
+ errno = EINTR;
+}
+
+static void oldalrm(void *handle)
+{
+ Handler_t fn = *(Handler_t*)handle;
+ free(handle);
+ (*fn)(SIGALRM);
+}
+
+void *sh_timeradd(unsigned long msec,int flags,void (*action)(void*),void *handle)
+{
+ register Timer_t *tp;
+ double t;
+ Handler_t fn;
+ t = ((double)msec)/1000.;
+ if(t<=0 || !action)
+ return((void*)0);
+ if(tp=tpfree)
+ tpfree = tp->next;
+ else if(!(tp=(Timer_t*)malloc(sizeof(Timer_t))))
+ return((void*)0);
+ tp->wakeup = getnow() + t;
+ tp->incr = (flags?t:0);
+ tp->action = action;
+ tp->handle = handle;
+ time_state |= IN_ADDTIMEOUT;
+ tp->next = tptop;
+ tptop = tp;
+ if(!tpmin || tp->wakeup < tpmin->wakeup)
+ {
+ tpmin = tp;
+ fn = (Handler_t)signal(SIGALRM,sigalrm);
+ if((t= setalarm(t))>0 && fn && fn!=(Handler_t)sigalrm)
+ {
+ Handler_t *hp = (Handler_t*)malloc(sizeof(Handler_t));
+ if(hp)
+ {
+ *hp = fn;
+ sh_timeradd((long)(1000*t), 0, oldalrm, (void*)hp);
+ }
+ }
+ tp = tptop;
+ }
+ else if(tpmin && !tpmin->action)
+ time_state |= DEFER_SIGALRM;
+ time_state &= ~IN_ADDTIMEOUT;
+ if(time_state&DEFER_SIGALRM)
+ {
+ time_state=SIGALRM_CALL;
+ sigalrm(SIGALRM);
+ if(tp!=tptop)
+ tp=0;
+ }
+ return((void*)tp);
+}
+
+/*
+ * delete timer <tp>. If <tp> is NULL, all timers are deleted
+ */
+void timerdel(void *handle)
+{
+ register Timer_t *tp = (Timer_t*)handle;
+ if(tp)
+ tp->action = 0;
+ else
+ {
+ for(tp=tptop; tp; tp=tp->next)
+ tp->action = 0;
+ if(tpmin)
+ {
+ tpmin = 0;
+ setalarm((double)0);
+ }
+ signal(SIGALRM,(sh.sigflag[SIGALRM]&SH_SIGFAULT)?sh_fault:SIG_DFL);
+ }
+}
+
diff --git a/usr/src/lib/libshell/common/sh/trestore.c b/usr/src/lib/libshell/common/sh/trestore.c
new file mode 100644
index 0000000000..d866ca712f
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/trestore.c
@@ -0,0 +1,342 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * shell intermediate code reader
+ *
+ */
+
+#include <ccode.h>
+#include "defs.h"
+#include "shnodes.h"
+#include "path.h"
+#include "io.h"
+
+static struct dolnod *r_comlist(void);
+static struct argnod *r_arg(void);
+static struct ionod *r_redirect(void);
+static struct regnod *r_switch(void);
+static Shnode_t *r_tree(void);
+static char *r_string(void);
+static void r_comarg(struct comnod*);
+
+static Sfio_t *infile;
+
+#define getnode(type) ((Shnode_t*)stakalloc(sizeof(struct type)))
+
+Shnode_t *sh_trestore(Sfio_t *in)
+{
+ Shnode_t *t;
+ infile = in;
+ t = r_tree();
+ return(t);
+}
+/*
+ * read in a shell tree
+ */
+static Shnode_t *r_tree()
+{
+ long l = sfgetl(infile);
+ register int type;
+ register Shnode_t *t=0;
+ if(l<0)
+ return(t);
+ type = l;
+ switch(type&COMMSK)
+ {
+ case TTIME:
+ case TPAR:
+ t = getnode(parnod);
+ t->par.partre = r_tree();
+ break;
+ case TCOM:
+ t = getnode(comnod);
+ t->tre.tretyp = type;
+ r_comarg((struct comnod*)t);
+ break;
+ case TSETIO:
+ case TFORK:
+ t = getnode(forknod);
+ t->fork.forkline = sfgetu(infile);
+ t->fork.forktre = r_tree();
+ t->fork.forkio = r_redirect();
+ break;
+ case TIF:
+ t = getnode(ifnod);
+ t->if_.iftre = r_tree();
+ t->if_.thtre = r_tree();
+ t->if_.eltre = r_tree();
+ break;
+ case TWH:
+ t = getnode(whnod);
+ t->wh.whinc = (struct arithnod*)r_tree();
+ t->wh.whtre = r_tree();
+ t->wh.dotre = r_tree();
+ break;
+ case TLST:
+ case TAND:
+ case TORF:
+ case TFIL:
+ t = getnode(lstnod);
+ t->lst.lstlef = r_tree();
+ t->lst.lstrit = r_tree();
+ break;
+ case TARITH:
+ t = getnode(arithnod);
+ t->ar.arline = sfgetu(infile);
+ t->ar.arexpr = r_arg();
+ t->ar.arcomp = 0;
+ if((t->ar.arexpr)->argflag&ARG_RAW)
+ t->ar.arcomp = sh_arithcomp((t->ar.arexpr)->argval);
+ break;
+ case TFOR:
+ t = getnode(fornod);
+ t->for_.forline = 0;
+ if(type&FLINENO)
+ t->for_.forline = sfgetu(infile);
+ t->for_.fortre = r_tree();
+ t->for_.fornam = r_string();
+ t->for_.forlst = (struct comnod*)r_tree();
+ break;
+ case TSW:
+ t = getnode(swnod);
+ t->sw.swline = 0;
+ if(type&FLINENO)
+ t->sw.swline = sfgetu(infile);
+ t->sw.swarg = r_arg();
+ if(type&COMSCAN)
+ t->sw.swio = r_redirect();
+ else
+ t->sw.swio = 0;
+ t->sw.swlst = r_switch();
+ break;
+ case TFUN:
+ {
+ Stak_t *savstak;
+ struct slnod *slp;
+ t = getnode(functnod);
+ t->funct.functloc = -1;
+ t->funct.functline = sfgetu(infile);
+ t->funct.functnam = r_string();
+ savstak = stakcreate(STAK_SMALL);
+ savstak = stakinstall(savstak, 0);
+ slp = (struct slnod*)stakalloc(sizeof(struct slnod));
+ slp->slchild = 0;
+ slp->slnext = sh.st.staklist;
+ sh.st.staklist = 0;
+ t->funct.functtre = r_tree();
+ t->funct.functstak = slp;
+ slp->slptr = stakinstall(savstak,0);
+ slp->slchild = sh.st.staklist;
+ t->funct.functargs = (struct comnod*)r_tree();
+ break;
+ }
+ case TTST:
+ t = getnode(tstnod);
+ t->tst.tstline = sfgetu(infile);
+ if((type&TPAREN)==TPAREN)
+ t->lst.lstlef = r_tree();
+ else
+ {
+ t->lst.lstlef = (Shnode_t*)r_arg();
+ if((type&TBINARY))
+ t->lst.lstrit = (Shnode_t*)r_arg();
+ }
+ }
+ if(t)
+ t->tre.tretyp = type;
+ return(t);
+}
+
+static struct argnod *r_arg(void)
+{
+ register struct argnod *ap=0, *apold, *aptop=0;
+ register long l;
+ while((l=sfgetu(infile))>0)
+ {
+ ap = (struct argnod*)stakseek((unsigned)l+ARGVAL);
+ if(!aptop)
+ aptop = ap;
+ else
+ apold->argnxt.ap = ap;
+ if(--l > 0)
+ {
+ sfread(infile,ap->argval,(size_t)l);
+ ccmaps(ap->argval, l, CC_ASCII, CC_NATIVE);
+ }
+ ap->argval[l] = 0;
+ ap->argchn.cp = 0;
+ ap->argflag = sfgetc(infile);
+ if(ap->argflag&ARG_MESSAGE)
+ {
+ /* replace international messages */
+ ap = sh_endword(1);
+ ap->argflag &= ~ARG_MESSAGE;
+ if(!(ap->argflag&(ARG_MAC|ARG_EXP)))
+ ap = sh_endword(0);
+ else
+ {
+ ap = (struct argnod*)stakfreeze(0);
+ if(ap->argflag==0)
+ ap->argflag = ARG_RAW;
+ }
+ }
+ else
+ ap = (struct argnod*)stakfreeze(0);
+ if(*ap->argval==0 && (ap->argflag&~ARG_APPEND)==0)
+ {
+ struct fornod *fp = (struct fornod*)getnode(fornod);
+ fp->fortyp = sfgetu(infile);
+ fp->fortre = r_tree();
+ fp->fornam = ap->argval+1;
+ ap->argchn.ap = (struct argnod*)fp;
+ }
+ apold = ap;
+ }
+ if(ap)
+ ap->argnxt.ap = 0;
+ return(aptop);
+}
+
+static struct ionod *r_redirect(void)
+{
+ register long l;
+ register struct ionod *iop=0, *iopold, *ioptop=0;
+ while((l=sfgetl(infile))>=0)
+ {
+ iop = (struct ionod*)getnode(ionod);
+ if(!ioptop)
+ ioptop = iop;
+ else
+ iopold->ionxt = iop;
+ iop->iofile = l;
+ iop->ioname = r_string();
+ if(iop->iodelim = r_string())
+ {
+ iop->iosize = sfgetl(infile);
+ if(sh.heredocs)
+ iop->iooffset = sfseek(sh.heredocs,(off_t)0,SEEK_END);
+ else
+ {
+ sh.heredocs = sftmp(512);
+ iop->iooffset = 0;
+ }
+ sfmove(infile,sh.heredocs, iop->iosize, -1);
+ }
+ iopold = iop;
+ if(iop->iofile&IOVNM)
+ iop->iovname = r_string();
+ else
+ iop->iovname = 0;
+ iop->iofile &= ~IOVNM;
+ }
+ if(iop)
+ iop->ionxt = 0;
+ return(ioptop);
+}
+
+static void r_comarg(struct comnod *com)
+{
+ char *cmdname=0;
+ com->comio = r_redirect();
+ com->comset = r_arg();
+ com->comstate = 0;
+ if(com->comtyp&COMSCAN)
+ {
+ com->comarg = r_arg();
+ if(com->comarg->argflag==ARG_RAW)
+ cmdname = com->comarg->argval;
+ }
+ else if(com->comarg = (struct argnod*)r_comlist())
+ cmdname = ((struct dolnod*)(com->comarg))->dolval[ARG_SPARE];
+ com->comline = sfgetu(infile);
+ com->comnamq = 0;
+ if(cmdname)
+ {
+ char *cp;
+ com->comnamp = (void*)nv_search(cmdname,sh.fun_tree,0);
+ if(com->comnamp && (cp =strrchr(cmdname+1,'.')))
+ {
+ *cp = 0;
+ com->comnamp = (void*)nv_open(cmdname,sh.var_tree,NV_VARNAME|NV_NOADD|NV_NOARRAY);
+ *cp = '.';
+ }
+ }
+ else
+ com->comnamp = 0;
+}
+
+static struct dolnod *r_comlist(void)
+{
+ register struct dolnod *dol=0;
+ register long l;
+ register char **argv;
+ if((l=sfgetl(infile))>0)
+ {
+ dol = (struct dolnod*)stakalloc(sizeof(struct dolnod) + sizeof(char*)*(l+ARG_SPARE));
+ dol->dolnum = l;
+ dol->dolbot = ARG_SPARE;
+ argv = dol->dolval+ARG_SPARE;
+ while(*argv++ = r_string());
+ }
+ return(dol);
+}
+
+static struct regnod *r_switch(void)
+{
+ register long l;
+ struct regnod *reg=0,*regold,*regtop=0;
+ while((l=sfgetl(infile))>=0)
+ {
+ reg = (struct regnod*)getnode(regnod);
+ if(!regtop)
+ regtop = reg;
+ else
+ regold->regnxt = reg;
+ reg->regflag = l;
+ reg->regptr = r_arg();
+ reg->regcom = r_tree();
+ regold = reg;
+ }
+ if(reg)
+ reg->regnxt = 0;
+ return(regtop);
+}
+
+static char *r_string(void)
+{
+ register Sfio_t *in = infile;
+ register unsigned long l = sfgetu(in);
+ register char *ptr;
+ if(l == 0)
+ return(NIL(char*));
+ ptr = stakalloc((unsigned)l);
+ if(--l > 0)
+ {
+ if(sfread(in,ptr,(size_t)l)!=(size_t)l)
+ return(NIL(char*));
+ ccmaps(ptr, l, CC_ASCII, CC_NATIVE);
+ }
+ ptr[l] = 0;
+ return(ptr);
+}
diff --git a/usr/src/lib/libshell/common/sh/waitevent.c b/usr/src/lib/libshell/common/sh/waitevent.c
new file mode 100644
index 0000000000..fb7329f471
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/waitevent.c
@@ -0,0 +1,54 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "defs.h"
+/*
+ * This installs a hook to allow the processing of events when
+ * the shell is waiting for input and when the shell is
+ * waiting for job completion.
+ * The previous waitevent hook function is returned
+ */
+
+
+void *sh_waitnotify(int(*newevent)(int,long,int))
+{
+ int (*old)(int,long,int);
+ old = sh.waitevent;
+ sh.waitevent = newevent;
+ return((void*)old);
+}
+
+#if __OBSOLETE__ < 20080101
+/*
+ * this used to be a private symbol
+ * retain the old name for a bit for a smooth transition
+ */
+
+#if defined(__EXPORT__)
+#define extern __EXPORT__
+#endif
+
+extern void *_sh_waitnotify(int(*newevent)(int,long,int))
+{
+ return sh_waitnotify(newevent);
+}
+
+#endif
diff --git a/usr/src/lib/libshell/common/sh/xec.c b/usr/src/lib/libshell/common/sh/xec.c
new file mode 100644
index 0000000000..378492256e
--- /dev/null
+++ b/usr/src/lib/libshell/common/sh/xec.c
@@ -0,0 +1,2947 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * UNIX shell parse tree executer
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#include "defs.h"
+#include <fcin.h>
+#include "variables.h"
+#include "path.h"
+#include "name.h"
+#include "io.h"
+#include "shnodes.h"
+#include "jobs.h"
+#include "test.h"
+#include "builtins.h"
+#include "FEATURE/time"
+#include "FEATURE/externs"
+#include "FEATURE/locale"
+#include "streval.h"
+
+#if !_std_malloc
+# include <vmalloc.h>
+#endif
+
+#define SH_NTFORK SH_TIMING
+
+#if _lib_nice
+ extern int nice(int);
+#endif /* _lib_nice */
+#if !_lib_spawnveg
+# define spawnveg(a,b,c,d) spawnve(a,b,c)
+#endif /* !_lib_spawnveg */
+#if SHOPT_SPAWN
+ static pid_t sh_ntfork(const Shnode_t*,char*[],int*,int);
+#endif /* SHOPT_SPAWN */
+
+static void sh_funct(Namval_t*, int, char*[], struct argnod*,int);
+static int trim_eq(const char*, const char*);
+static void coproc_init(int pipes[]);
+
+static void *timeout;
+static char pipejob;
+
+struct funenv
+{
+ Namval_t *node;
+ struct argnod *env;
+};
+
+/* ======== command execution ========*/
+
+/*
+ * print time <t> in h:m:s format with precision <p>
+ */
+static void l_time(Sfio_t *outfile,register clock_t t,int p)
+{
+ register int min, sec, frac;
+ register int hr;
+ if(p)
+ {
+ frac = t%sh.lim.clk_tck;
+ frac = (frac*100)/sh.lim.clk_tck;
+ }
+ t /= sh.lim.clk_tck;
+ sec = t%60;
+ t /= 60;
+ min = t%60;
+ if(hr=t/60)
+ sfprintf(outfile,"%dh",hr);
+ if(p)
+ sfprintf(outfile,"%dm%d%c%0*ds",min,sec,GETDECIMAL(0),p,frac);
+ else
+ sfprintf(outfile,"%dm%ds",min,sec);
+}
+
+static int p_time(Sfio_t *out, const char *format, clock_t *tm)
+{
+ int c,p,l,n,offset = staktell();
+ const char *first;
+ double d;
+ for(first=format ; c= *format; format++)
+ {
+ if(c!='%')
+ continue;
+ stakwrite(first, format-first);
+ n = l = 0;
+ p = 3;
+ if((c= *++format) == '%')
+ {
+ first = format;
+ continue;
+ }
+ if(c>='0' && c <='9')
+ {
+ p = (c>'3')?3:(c-'0');
+ c = *++format;
+ }
+ else if(c=='P')
+ {
+ if(d=tm[0])
+ d = 100.*(((double)(tm[1]+tm[2]))/d);
+ p = 2;
+ goto skip;
+ }
+ if(c=='l')
+ {
+ l = 1;
+ c = *++format;
+ }
+ if(c=='U')
+ n = 1;
+ else if(c=='S')
+ n = 2;
+ else if(c!='R')
+ {
+ stakseek(offset);
+ errormsg(SH_DICT,ERROR_exit(0),e_badtformat,c);
+ return(0);
+ }
+ d = (double)tm[n]/sh.lim.clk_tck;
+ skip:
+ if(l)
+ l_time(stkstd, tm[n], p);
+ else
+ sfprintf(stkstd,"%.*f",p, d);
+ first = format+1;
+ }
+ if(format>first)
+ stakwrite(first, format-first);
+ stakputc('\n');
+ n = staktell()-offset;
+ sfwrite(out,stakptr(offset),n);
+ stakseek(offset);
+ return(n);
+}
+
+#if SHOPT_OPTIMIZE
+/*
+ * clear argument pointers that point into the stack
+ */
+static int p_arg(struct argnod*,int);
+static int p_switch(struct regnod*);
+static int p_comarg(register struct comnod *com)
+{
+ Namval_t *np=com->comnamp;
+ int n = p_arg(com->comset,ARG_ASSIGN);
+ if(com->comarg && (com->comtyp&COMSCAN))
+ n+= p_arg(com->comarg,0);
+ if(com->comstate && np)
+ {
+ /* call builtin to cleanup state */
+ Nambltin_t bdata;
+ bdata.shp = &sh;
+ bdata.np = com->comnamq;
+ bdata.ptr =nv_context(np);
+ bdata.data = com->comstate;
+ bdata.flags = SH_END_OPTIM;
+ (*funptr(np))(0,(char**)0, &bdata);
+ }
+ com->comstate = 0;
+ if(com->comarg && !np)
+ n++;
+ return(n);
+}
+
+extern void sh_optclear(Shell_t*, void*);
+
+static int sh_tclear(register Shnode_t *t)
+{
+ int n=0;
+ if(!t)
+ return(0);
+ switch(t->tre.tretyp&COMMSK)
+ {
+ case TTIME:
+ case TPAR:
+ return(sh_tclear(t->par.partre));
+ case TCOM:
+ return(p_comarg((struct comnod*)t));
+ case TSETIO:
+ case TFORK:
+ return(sh_tclear(t->fork.forktre));
+ case TIF:
+ n=sh_tclear(t->if_.iftre);
+ n+=sh_tclear(t->if_.thtre);
+ n+=sh_tclear(t->if_.eltre);
+ return(n);
+ case TWH:
+ if(t->wh.whinc)
+ n=sh_tclear((Shnode_t*)(t->wh.whinc));
+ n+=sh_tclear(t->wh.whtre);
+ n+=sh_tclear(t->wh.dotre);
+ return(n);
+ case TLST:
+ case TAND:
+ case TORF:
+ case TFIL:
+ n=sh_tclear(t->lst.lstlef);
+ return(n+sh_tclear(t->lst.lstrit));
+ case TARITH:
+ return(p_arg(t->ar.arexpr,ARG_ARITH));
+ case TFOR:
+ n=sh_tclear(t->for_.fortre);
+ return(n+sh_tclear((Shnode_t*)t->for_.forlst));
+ case TSW:
+ n=p_arg(t->sw.swarg,0);
+ return(n+p_switch(t->sw.swlst));
+ case TFUN:
+ n=sh_tclear(t->funct.functtre);
+ return(n+sh_tclear((Shnode_t*)t->funct.functargs));
+ case TTST:
+ if((t->tre.tretyp&TPAREN)==TPAREN)
+ return(sh_tclear(t->lst.lstlef));
+ else
+ {
+ n=p_arg(&(t->lst.lstlef->arg),0);
+ if(t->tre.tretyp&TBINARY)
+ n+=p_arg(&(t->lst.lstrit->arg),0);
+ }
+ }
+ return(n);
+}
+
+static int p_arg(register struct argnod *arg,int flag)
+{
+ while(arg)
+ {
+ if(strlen(arg->argval) || (arg->argflag==ARG_RAW))
+ arg->argchn.ap = 0;
+ else if(flag==0)
+ sh_tclear((Shnode_t*)arg->argchn.ap);
+ else
+ sh_tclear(((struct fornod*)arg->argchn.ap)->fortre);
+ arg = arg->argnxt.ap;
+ }
+ return(0);
+}
+
+static int p_switch(register struct regnod *reg)
+{
+ int n=0;
+ while(reg)
+ {
+ n+=p_arg(reg->regptr,0);
+ n+=sh_tclear(reg->regcom);
+ reg = reg->regnxt;
+ }
+ return(n);
+}
+# define OPTIMIZE_FLAG (ARG_OPTIMIZE)
+# define OPTIMIZE (flags&OPTIMIZE_FLAG)
+#else
+# define OPTIMIZE_FLAG (0)
+# define OPTIMIZE (0)
+# define sh_tclear(x)
+#endif /* SHOPT_OPTIMIZE */
+
+static void out_pattern(Sfio_t *iop, register const char *cp, int n)
+{
+ register int c;
+ do
+ {
+ switch(c= *cp)
+ {
+ case 0:
+ if(n<0)
+ return;
+ c = n;
+ break;
+ case '\n':
+ sfputr(iop,"$'\\n",'\'');
+ continue;
+ case '\\':
+ if (!(c = *++cp))
+ c = '\\';
+ /*FALLTHROUGH*/
+ case ' ':
+ case '<': case '>': case ';':
+ case '$': case '`': case '\t':
+ sfputc(iop,'\\');
+ break;
+ }
+ sfputc(iop,c);
+ }
+ while(*cp++);
+}
+
+static void out_string(Sfio_t *iop, register const char *cp, int c, int quoted)
+{
+ if(quoted)
+ {
+ int n = staktell();
+ cp = sh_fmtq(cp);
+ if(iop==stkstd && cp==stkptr(stkstd,n))
+ {
+ *stkptr(stkstd,stktell(stkstd)-1) = c;
+ return;
+ }
+ }
+ sfputr(iop,cp,c);
+}
+
+struct Level
+{
+ Namfun_t hdr;
+ short maxlevel;
+};
+
+/*
+ * this is for a debugger but it hasn't been tested yet
+ * if a debug script sets .sh.level it should set up the scope
+ * as if you were executing in that level
+ */
+static void put_level(Namval_t* np,const char *val,int flags,Namfun_t *fp)
+{
+ Shscope_t *sp;
+ struct Level *lp = (struct Level*)fp;
+ int16_t level, oldlevel = (int16_t)nv_getnum(np);
+ nv_putv(np,val,flags,fp);
+ level = nv_getnum(np);
+ if(level<0 || level > lp->maxlevel)
+ {
+ nv_putv(np, (char*)&oldlevel, flags, fp);
+ /* perhaps this should be an error */
+ return;
+ }
+ if(level==oldlevel)
+ return;
+ if(sp = sh_getscope(level,SEEK_SET))
+ {
+ sh_setscope(sp);
+ error_info.line = sp->lineno;
+ }
+ nv_putval(SH_PATHNAMENOD, sh.st.filename ,NV_NOFREE);
+}
+
+static const Namdisc_t level_disc = { 0, put_level };
+
+/*
+ * write the current common on the stack and make it available as .sh.command
+ */
+int sh_debug(const char *trap, const char *name, const char *subscript, char *const argv[], int flags)
+{
+ struct sh_scoped savst;
+ Shscope_t *sp, *topmost;
+ Namval_t *np = SH_COMMANDNOD;
+ struct Level lev;
+ char *sav = stakptr(0);
+ int n=4, offset=staktell();
+ const char *cp = "+=( ";
+ Sfio_t *iop = stkstd;
+ int16_t level;
+ if(name)
+ {
+ sfputr(iop,name,-1);
+ if(subscript)
+ {
+ sfputc(iop,'[');
+ out_string(iop,subscript,']',1);
+ }
+ if(!(flags&ARG_APPEND))
+ cp+=1, n-=1;
+ if(!(flags&ARG_ASSIGN))
+ n -= 2;
+ sfwrite(iop,cp,n);
+ }
+ if(!(flags&ARG_RAW))
+ out_string(iop, *argv++,' ', 0);
+ n = (flags&ARG_ARITH);
+ while(cp = *argv++)
+ {
+ if((flags&ARG_EXP) && argv[1]==0)
+ out_pattern(iop, cp,' ');
+ else
+ out_string(iop, cp,' ',n?0: (flags&(ARG_RAW|ARG_NOGLOB))||*argv);
+ }
+ if(flags&ARG_ASSIGN)
+ sfputc(iop,')');
+ else if(iop==stkstd)
+ *stakptr(staktell()-1) = 0;
+ np->nvalue.cp = stakfreeze(1);
+ sh.st.lineno = error_info.line;
+ /* now setup .sh.level variable */
+ topmost = sh_getscope(0,SEEK_END);
+ for(level=0, sp=topmost; sp; sp=sp->par_scope)
+ level++;
+ memset((void*)&lev,0,sizeof(lev));
+ lev.hdr.disc = &level_disc;
+ lev.maxlevel = --level;
+ nv_unset(SH_LEVELNOD);
+ nv_onattr(SH_LEVELNOD,NV_INT16|NV_NOFREE);
+ nv_putval(SH_LEVELNOD,(char*)&level,NV_INT16);
+ nv_disc(SH_LEVELNOD,&lev.hdr,NV_FIRST);
+ savst = sh.st;
+ sh.st.trap[SH_DEBUGTRAP] = 0;
+ n = sh_trap(trap,0);
+ np->nvalue.cp = 0;
+ nv_putval(SH_LEVELNOD,(char*)&level,NV_INT16);
+ nv_disc(SH_LEVELNOD,&lev.hdr,NV_POP);
+ nv_unset(SH_LEVELNOD);
+ nv_putval(SH_PATHNAMENOD, sh.st.filename ,NV_NOFREE);
+ sh.st = savst;
+ if(sav != stakptr(0))
+ stakset(sav,0);
+ else
+ stakseek(offset);
+ return(n);
+}
+
+/*
+ * Given stream <iop> compile and execute
+ */
+int sh_eval(register Sfio_t *iop, int mode)
+{
+ register Shnode_t *t;
+ Shell_t *shp = sh_getinterp();
+ struct slnod *saveslp = shp->st.staklist;
+ int jmpval;
+ struct checkpt *pp = (struct checkpt*)shp->jmplist;
+ struct checkpt buff;
+ static Sfio_t *io_save;
+ io_save = iop; /* preserve correct value across longjmp */
+ sh_pushcontext(&buff,SH_JMPEVAL);
+ buff.olist = pp->olist;
+ jmpval = sigsetjmp(buff.buff,0);
+ if(jmpval==0)
+ {
+ t = (Shnode_t*)sh_parse(shp,iop,SH_NL);
+ sfclose(iop);
+ io_save = 0;
+ if(!sh_isoption(SH_VERBOSE))
+ sh_offstate(SH_VERBOSE);
+ if(mode && shp->hist_ptr)
+ {
+ hist_flush(shp->hist_ptr);
+ mode = sh_state(SH_INTERACTIVE);
+ }
+ sh_exec(t,sh_isstate(SH_ERREXIT)|mode);
+ }
+ sh_popcontext(&buff);
+ if(io_save)
+ sfclose(io_save);
+ sh_freeup();
+ shp->st.staklist = saveslp;
+ if(jmpval>SH_JMPEVAL)
+ siglongjmp(*shp->jmplist,jmpval);
+ return(sh.exitval);
+}
+
+#if SHOPT_FASTPIPE
+static int pipe_exec(int pv[], Shnode_t *t, int errorflg)
+{
+ struct checkpt buff;
+ register Shnode_t *tchild = t->fork.forktre;
+ Namval_t *np;
+ Sfio_t *iop;
+ int jmpval,r;
+ if((tchild->tre.tretyp&COMMSK)!=TCOM || !(np=(Namval_t*)(tchild->com.comnamp)))
+ {
+ sh_pipe(pv);
+ return(sh_exec(t,errorflg));
+ }
+ pv[0] = sh.lim.open_max;
+ sh.fdstatus[pv[0]] = IOREAD|IODUP|IOSEEK;
+ pv[1] = sh.lim.open_max+1;
+ sh.fdstatus[pv[1]] = IOWRITE|IOSEEK;
+ iop = sftmp(IOBSIZE+1);
+ sh.sftable[sh.lim.open_max+1] = iop;
+ sh_pushcontext(&buff,SH_JMPIO);
+ if(t->tre.tretyp&FPIN)
+ sh_iosave(0,sh.topfd);
+ sh_iosave(1,sh.topfd);
+ jmpval = sigsetjmp(buff.buff,0);
+ if(jmpval==0)
+ {
+ if(t->tre.tretyp&FPIN)
+ sh_iorenumber(sh.inpipe[0],0);
+ sh_iorenumber(sh.lim.open_max+1,1);
+ r = sh_exec(tchild,errorflg);
+ if(sffileno(sfstdout)>=0)
+ pv[0] = sfsetfd(sfstdout,10);
+ iop = sfswap(sfstdout,0);
+ }
+ sh_popcontext(&buff);
+ sh.sftable[pv[0]] = iop;
+ sh.fdstatus[pv[0]] = IOREAD|IODUP|IOSEEK;
+ sfset(iop,SF_WRITE,0);
+ sfseek(iop,0L,SEEK_SET);
+ sh_iorestore(buff.topfd,jmpval);
+ if(jmpval>SH_JMPIO)
+ siglongjmp(*sh.jmplist,jmpval);
+ return(r);
+}
+#endif /* SHOPT_FASTPIPE */
+
+/*
+ * returns 1 when option -<c> is specified
+ */
+static int checkopt(char *argv[], int c)
+{
+ char *cp;
+ while(cp = *++argv)
+ {
+ if(*cp=='+')
+ continue;
+ if(*cp!='-' || cp[1]=='-')
+ break;
+ if(strchr(cp,c))
+ return(1);
+ }
+ return(0);
+}
+
+static void free_list(struct openlist *olist)
+{
+ struct openlist *item,*next;
+ for(item=olist;item;item=next)
+ {
+ next = item->next;
+ free((void*)item);
+ }
+}
+
+
+int sh_exec(register const Shnode_t *t, int flags)
+{
+ sh_sigcheck();
+ if(t && !sh.st.execbrk && !sh_isoption(SH_NOEXEC))
+ {
+ register int type = flags;
+ register char *com0 = 0;
+ int errorflg = (type&sh_state(SH_ERREXIT))|OPTIMIZE;
+ int execflg = (type&sh_state(SH_NOFORK));
+ int mainloop = (type&sh_state(SH_INTERACTIVE));
+#if SHOPT_SPAWN
+ int ntflag = (type&sh_state(SH_NTFORK));
+#endif
+ int topfd = sh.topfd;
+ char *sav=stakptr(0);
+ char *cp=0, **com=0;
+ int argn;
+ int skipexitset = 0;
+ int was_interactive = 0;
+ int was_errexit = sh_isstate(SH_ERREXIT);
+ int was_monitor = sh_isstate(SH_MONITOR);
+ int echeck = 0;
+ if(flags&sh_state(SH_INTERACTIVE))
+ {
+ pipejob = 0;
+ job.curpgid = 0;
+ flags &= ~sh_state(SH_INTERACTIVE);
+ }
+ sh_offstate(SH_ERREXIT);
+ sh_offstate(SH_DEFPATH);
+ if(was_errexit&flags)
+ sh_onstate(SH_ERREXIT);
+ if(was_monitor&flags)
+ sh_onstate(SH_MONITOR);
+ type = t->tre.tretyp;
+ if(!sh.intrap)
+ sh.oldexit=sh.exitval;
+ sh.exitval=0;
+ sh.lastsig = 0;
+ sh.lastpath = 0;
+ switch(type&COMMSK)
+ {
+ case TCOM:
+ {
+ register struct argnod *argp;
+ char *trap;
+ Namval_t *np, *nq, *last_table;
+ struct ionod *io;
+ int command=0;
+ error_info.line = t->com.comline-sh.st.firstline;
+ com = sh_argbuild(&argn,&(t->com),OPTIMIZE);
+ echeck = 1;
+ if(t->tre.tretyp&COMSCAN)
+ {
+ argp = t->com.comarg;
+ if(argp && *com && !(argp->argflag&ARG_RAW))
+ sh_sigcheck();
+ }
+ np = (Namval_t*)(t->com.comnamp);
+ nq = (Namval_t*)(t->com.comnamq);
+ com0 = com[0];
+ sh.xargexit = 0;
+ while(np==SYSCOMMAND)
+ {
+ register int n = b_command(0,com,&sh);
+ if(n==0)
+ break;
+ command += n;
+ np = 0;
+ if(!(com0= *(com+=n)))
+ break;
+ np = nv_bfsearch(com0, sh.bltin_tree, &nq, &cp);
+ }
+ if(sh.xargexit)
+ {
+ sh.xargmin -= command;
+ sh.xargmax -= command;
+ }
+ else
+ sh.xargmin = 0;
+ argn -= command;
+ if(!command && np && is_abuiltin(np))
+ np = dtsearch(sh.fun_tree,np);
+ if(com0 && !np && !strchr(com0,'/'))
+ {
+ Dt_t *root = command?sh.bltin_tree:sh.fun_tree;
+ np = nv_bfsearch(com0, root, &nq, &cp);
+#if SHOPT_NAMESPACE
+ if(sh.namespace && !nq && !cp)
+ {
+ int offset = staktell();
+ stakputs(nv_name(sh.namespace));
+ stakputc('.');
+ stakputs(com0);
+ stakseek(offset);
+ np = nv_bfsearch(stakptr(offset), root, &nq, &cp);
+ }
+#endif /* SHOPT_NAMESPACE */
+ }
+ io = t->tre.treio;
+ if(sh.envlist = argp = t->com.comset)
+ {
+ if(argn==0 || (np && !command && nv_isattr(np,BLT_SPC)))
+ {
+ register int flgs=NV_VARNAME|NV_ASSIGN;
+#if SHOPT_BASH
+ if(np==SYSLOCAL)
+ {
+ if(!nv_getval(SH_FUNNAMENOD))
+ errormsg(SH_DICT,ERROR_exit(1),"%s: can only be used in a function",com0);
+ if(!sh.st.var_local)
+ {
+ nv_scope((struct argnod*)0);
+ sh.st.var_local = sh.var_tree;
+ }
+
+ }
+ if(np==SYSTYPESET || np==SYSLOCAL)
+#else
+ if(np==SYSTYPESET)
+#endif
+ {
+ if(checkopt(com,'n'))
+ flgs |= NV_NOREF;
+#if SHOPT_TYPEDEF
+ else if(checkopt(com,'T'))
+ {
+ sh.prefix = NV_CLASS;
+ flgs |= NV_TYPE;
+
+ }
+#endif /* SHOPT_TYPEDEF */
+ if(checkopt(com,'A'))
+ flgs |= NV_ARRAY;
+ else if(checkopt(com,'a'))
+ flgs |= NV_IARRAY;
+ if((sh.fn_depth && !sh.prefix) || np==SYSLOCAL)
+ flgs |= NV_NOSCOPE;
+ }
+ else if(np==SYSEXPORT)
+ flgs |= NV_EXPORT;
+ else if(np)
+ flgs = NV_IDENT|NV_ASSIGN;
+#if 0
+ if(OPTIMIZE)
+ flgs |= NV_TAGGED;
+#endif
+ nv_setlist(argp,flgs);
+ argp = NULL;
+ }
+ }
+ last_table = sh.last_table;
+ sh.last_table = 0;
+ if((io||argn))
+ {
+ static char *argv[1];
+ if(argn==0)
+ {
+ /* fake 'true' built-in */
+ argn=1;
+ np = SYSTRUE;
+ *argv = nv_name(np);
+ com = argv;
+ }
+ /* set +x doesn't echo */
+ else if((np!=SYSSET) && sh_isoption(SH_XTRACE))
+ sh_trace(com-command,1);
+ else if((t->tre.tretyp&FSHOWME) && sh_isoption(SH_SHOWME))
+ {
+ int ison = sh_isoption(SH_XTRACE);
+ if(!ison)
+ sh_onoption(SH_XTRACE);
+ sh_trace(com-command,1);
+ if(io)
+ sh_redirect(io,SH_SHOWME);
+ if(!ison)
+ sh_offoption(SH_XTRACE);
+ break;
+ }
+ if(trap=sh.st.trap[SH_DEBUGTRAP])
+ sh_debug(trap,(char*)0, (char*)0, com, ARG_RAW);
+ if(io)
+ sfsync(sh.outpool);
+ sh.lastpath = 0;
+ if(!np && !strchr(com0,'/'))
+ {
+#ifdef PATH_BFPATH
+ if(path_search(com0,NIL(Pathcomp_t*),1))
+ np=nv_search(com0,sh.fun_tree,0);
+ else
+ {
+ if((np=nv_search(com0,sh.track_tree,0)) && !nv_isattr(np,NV_NOALIAS) && np->nvalue.cp)
+ np=nv_search(nv_getval(np),sh.bltin_tree,0);
+ else
+ np = 0;
+ }
+#else
+ if(path_search(com0,NIL(char*),1))
+ np=nv_search(com0,sh.fun_tree,0);
+ if(sh.lastpath)
+ np=nv_search(sh.lastpath,sh.bltin_tree,0);
+#endif
+ }
+ /* check for builtins */
+ if(np && is_abuiltin(np))
+ {
+ Nambltin_t bdata;
+ void *context;
+ int scope=0, jmpval, save_prompt,share;
+ struct checkpt buff;
+ unsigned long was_vi=0, was_emacs=0, was_gmacs=0;
+ struct stat statb;
+ if(strchr(nv_name(np),'/'))
+ {
+ /*
+ * disable editors for built-in
+ * versions of commands on PATH
+ */
+ was_vi = sh_isoption(SH_VI);
+ was_emacs = sh_isoption(SH_EMACS);
+ was_gmacs = sh_isoption(SH_GMACS);
+ sh_offoption(SH_VI);
+ sh_offoption(SH_EMACS);
+ sh_offoption(SH_GMACS);
+ }
+ sh_pushcontext(&buff,SH_JMPCMD);
+ jmpval = sigsetjmp(buff.buff,1);
+ if(jmpval == 0)
+ {
+ if(!(nv_isattr(np,BLT_ENV)))
+ error_info.flags |= ERROR_SILENT;
+ errorpush(&buff.err,0);
+ if(io)
+ {
+ struct openlist *item;
+ if(np==SYSLOGIN)
+ type=1;
+ else if(np==SYSEXEC)
+ type=1+!com[1];
+ else
+ type = (execflg && !sh.subshell && !sh.st.trapcom[0]);
+ sh_redirect(io,type);
+ for(item=buff.olist;item;item=item->next)
+ item->strm=0;
+ }
+ if(!(nv_isattr(np,BLT_ENV)))
+ {
+ if(!sh.pwd)
+ path_pwd(0);
+ if(sh.pwd)
+ stat(".",&statb);
+ share = sfset(sfstdin,SF_SHARE,0);
+ sh_onstate(SH_STOPOK);
+ sfpool(sfstderr,NIL(Sfio_t*),SF_WRITE);
+ sfset(sfstderr,SF_LINE,1);
+ save_prompt = sh.nextprompt;
+ sh.nextprompt = 0;
+ }
+ if(argp)
+ {
+ scope++;
+ nv_scope(argp);
+ }
+ opt_info.index = opt_info.offset = 0;
+ opt_info.disc = 0;
+ error_info.id = *com;
+ sh.exitval = 0;
+ if(!(context=nv_context(np)))
+ context = (void*)&sh;
+ sh.bltinfun = funptr(np);
+ if(nv_isattr(np,NV_BLTINOPT))
+ {
+ bdata.shp = &sh;
+ bdata.np = nq;
+ bdata.ptr = context;
+ bdata.data = t->com.comstate;
+ bdata.flags = (OPTIMIZE!=0);
+ context = (void*)&bdata;
+ }
+ if(execflg && !sh.subshell &&
+ !sh.st.trapcom[0] && !sh.st.trap[SH_ERRTRAP] && sh.fn_depth==0 && !nv_isattr(np,BLT_ENV))
+ {
+ /* do close-on-exec */
+ int fd;
+ for(fd=0; fd < sh.lim.open_max; fd++)
+ if((sh.fdstatus[fd]&IOCLEX)&&fd!=sh.infd)
+ sh_close(fd);
+ }
+ sh.exitval = (*sh.bltinfun)(argn,com,context);
+ if(error_info.flags&ERROR_INTERACTIVE)
+ tty_check(ERRIO);
+ if(nv_isattr(np,NV_BLTINOPT))
+ ((Shnode_t*)t)->com.comstate = bdata.data;
+ if(!nv_isattr(np,BLT_EXIT) && sh.exitval!=SH_RUNPROG)
+ sh.exitval &= SH_EXITMASK;
+ }
+ else
+ {
+ struct openlist *item;
+ for(item=buff.olist;item;item=item->next)
+ {
+ if(item->strm)
+ {
+ sfclrlock(item->strm);
+ if(sh.hist_ptr && item->strm == sh.hist_ptr->histfp)
+ hist_close(sh.hist_ptr);
+ else
+ sfclose(item->strm);
+ }
+ }
+ /* failure on special built-ins fatal */
+ if(jmpval<=SH_JMPCMD && (!nv_isattr(np,BLT_SPC) || command))
+ jmpval=0;
+ }
+ if(!(nv_isattr(np,BLT_ENV)))
+ {
+ if(sh.pwd)
+ {
+ struct stat stata;
+ stat(".",&stata);
+ /* restore directory changed */
+ if(statb.st_ino!=stata.st_ino || statb.st_dev!=stata.st_dev)
+ chdir(sh.pwd);
+ }
+ sh_offstate(SH_STOPOK);
+ if(share&SF_SHARE)
+ sfset(sfstdin,SF_PUBLIC|SF_SHARE,1);
+ sfset(sfstderr,SF_LINE,0);
+ sfpool(sfstderr,sh.outpool,SF_WRITE);
+ sfpool(sfstdin,NIL(Sfio_t*),SF_WRITE);
+ sh.nextprompt = save_prompt;
+ }
+ sh_popcontext(&buff);
+ errorpop(&buff.err);
+ error_info.flags &= ~ERROR_SILENT;
+ sh.bltinfun = 0;
+ if(buff.olist)
+ free_list(buff.olist);
+ if(was_vi)
+ sh_onoption(SH_VI);
+ else if(was_emacs)
+ sh_onoption(SH_EMACS);
+ else if(was_gmacs)
+ sh_onoption(SH_GMACS);
+ if(scope)
+ nv_unscope();
+ /* don't restore for subshell exec */
+ if((sh.topfd>topfd) && !(sh.subshell && np==SYSEXEC))
+ sh_iorestore(topfd,jmpval);
+ if(jmpval)
+ siglongjmp(*sh.jmplist,jmpval);
+ if(sh.exitval >=0)
+ goto setexit;
+ np = 0;
+ type=0;
+ }
+ /* check for functions */
+ if(!command && np && nv_isattr(np,NV_FUNCTION))
+ {
+ int indx,jmpval=0;
+ struct checkpt buff;
+ Namval_t node;
+ register struct slnod *slp;
+ if(!np->nvalue.ip)
+ {
+#ifdef PATH_BFPATH
+ indx = path_search(com0,NIL(Pathcomp_t*),0);
+#else
+ indx = path_search(com0,NIL(char*),0);
+#endif
+ if(indx==1)
+ np = nv_search(com0,sh.fun_tree,HASH_NOSCOPE);
+ if(!np->nvalue.ip)
+ {
+ if(indx==1)
+ {
+ errormsg(SH_DICT,ERROR_exit(0),e_defined,com0);
+ sh.exitval = ERROR_NOEXEC;
+ }
+ else
+ {
+ errormsg(SH_DICT,ERROR_exit(0),e_found,"function");
+ sh.exitval = ERROR_NOENT;
+ }
+ goto setexit;
+ }
+ }
+ /* increase refcnt for unset */
+ slp = (struct slnod*)np->nvenv;
+ sh_funstaks(slp->slchild,1);
+ staklink(slp->slptr);
+ if(nq)
+ {
+ struct Namref nr;
+ sh.last_table = last_table;
+ memset(&nr,0,sizeof(nr));
+ nr.np = nq;
+ nv_putval(SH_NAMENOD, nv_name(nq), NV_NOFREE);
+ memcpy(&node,L_ARGNOD,sizeof(node));
+ L_ARGNOD->nvalue.nrp = &nr;
+ L_ARGNOD->nvenv = 0;
+ L_ARGNOD->nvfun = (Namfun_t*)sh.last_table;
+ L_ARGNOD->nvflag = NV_REF|NV_NOFREE;
+ if(nv_arrayptr(nq))
+ {
+ nv_putval(SH_SUBSCRNOD,nv_getsub(nq),NV_NOFREE);
+ L_ARGNOD->nvenv = (char*)SH_SUBSCRNOD->nvalue.cp;
+ }
+ }
+ if(io)
+ {
+ indx = sh.topfd;
+ sh_pushcontext(&buff,SH_JMPCMD);
+ jmpval = sigsetjmp(buff.buff,0);
+ }
+ if(jmpval == 0)
+ {
+ if(io)
+ indx = sh_redirect(io,execflg);
+ sh_funct(np,argn,com,t->com.comset,(flags&~OPTIMIZE_FLAG));
+ }
+ if(io)
+ {
+ if(buff.olist)
+ free_list(buff.olist);
+ sh_popcontext(&buff);
+ sh_iorestore(indx,jmpval);
+ }
+ if(nq)
+ {
+ L_ARGNOD->nvalue.np = node.nvalue.np;
+ L_ARGNOD->nvenv = node.nvenv;
+ L_ARGNOD->nvflag = node.nvflag;
+ L_ARGNOD->nvfun = node.nvfun;
+ nv_unset(SH_NAMENOD);
+ nv_unset(SH_SUBSCRNOD);
+ }
+ sh_funstaks(slp->slchild,-1);
+ stakdelete(slp->slptr);
+ if(jmpval > SH_JMPFUN)
+ siglongjmp(*sh.jmplist,jmpval);
+ goto setexit;
+ }
+ }
+ else if(!io)
+ {
+ setexit:
+ exitset();
+ break;
+ }
+ }
+ case TFORK:
+ {
+ register pid_t parent;
+ int no_fork,jobid;
+ int pipes[2];
+ no_fork = (execflg && !(type&(FAMP|FPOU)) &&
+ !sh.subshell && !sh.st.trapcom[0] &&
+ !sh.st.trap[SH_ERRTRAP] && sh.fn_depth==0);
+ if(sh.subshell)
+ sh_subtmpfile();
+ if(sh_isstate(SH_PROFILE) || sh.dot_depth)
+ {
+ /* disable foreground job monitor */
+ if(!(type&FAMP))
+ sh_offstate(SH_MONITOR);
+#if SHOPT_DEVFD
+ else if(!(type&FINT))
+ sh_offstate(SH_MONITOR);
+#endif /* SHOPT_DEVFD */
+ }
+ if(no_fork)
+ job.parent=parent=0;
+ else
+ {
+ if(type&FCOOP)
+ coproc_init(pipes);
+ nv_getval(RANDNOD);
+#if SHOPT_AMP
+ if((type&(FAMP|FINT)) == (FAMP|FINT))
+ parent = sh_ntfork(t,com,&jobid,ntflag);
+ else
+ parent = sh_fork(type,&jobid);
+ if(parent<0)
+ break;
+#else
+#if SHOPT_SPAWN
+# ifdef _lib_fork
+ if(com)
+ parent = sh_ntfork(t,com,&jobid,ntflag);
+ else
+ parent = sh_fork(type,&jobid);
+# else
+ if((parent = sh_ntfork(t,com,&jobid,ntflag))<=0)
+ break;
+# endif /* _lib_fork */
+ if(parent<0)
+ break;
+#else
+ parent = sh_fork(type,&jobid);
+#endif /* SHOPT_SPAWN */
+#endif
+ }
+ if(job.parent=parent)
+ /* This is the parent branch of fork
+ * It may or may not wait for the child
+ */
+ {
+ if(type&FPCL)
+ sh_close(sh.inpipe[0]);
+ if(type&(FCOOP|FAMP))
+ sh.bckpid = parent;
+ if(!(type&(FAMP|FPOU)))
+ {
+ if(sh.topfd > topfd)
+ sh_iorestore(topfd,0);
+ job_wait(parent);
+ }
+ if(type&FAMP)
+ {
+ if(sh_isstate(SH_PROFILE) || sh_isstate(SH_INTERACTIVE))
+ {
+ /* print job number */
+#ifdef JOBS
+ sfprintf(sfstderr,"[%d]\t%d\n",jobid,parent);
+#else
+ sfprintf(sfstderr,"%d\n",parent);
+#endif /* JOBS */
+ }
+ }
+ break;
+ }
+ else
+ /*
+ * this is the FORKED branch (child) of execute
+ */
+ {
+ int jmpval;
+ struct checkpt buff;
+ if(no_fork)
+ sh_sigreset(2);
+ sh_pushcontext(&buff,SH_JMPEXIT);
+ jmpval = sigsetjmp(buff.buff,0);
+ if(jmpval)
+ goto done;
+ if((type&FINT) && !sh_isstate(SH_MONITOR))
+ {
+ /* default std input for & */
+ signal(SIGINT,SIG_IGN);
+ signal(SIGQUIT,SIG_IGN);
+ if(!sh.st.ioset)
+ {
+ if(sh_close(0)>=0)
+ sh_chkopen(e_devnull);
+ }
+ }
+ sh_offstate(SH_MONITOR);
+ /* pipe in or out */
+#ifdef _lib_nice
+ if((type&FAMP) && sh_isoption(SH_BGNICE))
+ nice(4);
+#endif /* _lib_nice */
+ if(type&FPIN)
+ {
+ sh_iorenumber(sh.inpipe[0],0);
+ if(!(type&FPOU) || (type&FCOOP))
+ sh_close(sh.inpipe[1]);
+ }
+ if(type&FPOU)
+ {
+ sh_iorenumber(sh.outpipe[1],1);
+ sh_pclose(sh.outpipe);
+ }
+ if((type&COMMSK)!=TCOM)
+ error_info.line = t->fork.forkline-sh.st.firstline;
+ sh_redirect(t->tre.treio,1);
+ if(sh.topfd)
+ sh_iounsave();
+ if((type&COMMSK)!=TCOM)
+ {
+ /* don't clear job table for out
+ pipes so that jobs comand can
+ be used in a pipeline
+ */
+ if(!no_fork && !(type&FPOU))
+ job_clear();
+ sh_exec(t->fork.forktre,flags|sh_state(SH_NOFORK));
+ }
+ else if(com0)
+ {
+ sh_offoption(SH_ERREXIT);
+ sh_freeup();
+ path_exec(com0,com,t->com.comset);
+ }
+ done:
+ sh_popcontext(&buff);
+ if(jmpval>SH_JMPEXIT)
+ siglongjmp(*sh.jmplist,jmpval);
+ sh_done(0);
+ }
+ }
+
+ case TSETIO:
+ {
+ /*
+ * don't create a new process, just
+ * save and restore io-streams
+ */
+ pid_t pid;
+ int jmpval, waitall;
+ struct checkpt buff;
+ if(sh.subshell)
+ {
+ flags &= ~sh_state(SH_NOFORK);
+ execflg = 0;
+ }
+ sh_pushcontext(&buff,SH_JMPIO);
+ if(type&FPIN)
+ {
+ was_interactive = sh_isstate(SH_INTERACTIVE);
+ sh_offstate(SH_INTERACTIVE);
+ if(!execflg)
+ sh_iosave(0,sh.topfd);
+ sh_iorenumber(sh.inpipe[0],0);
+ /*
+ * if read end of pipe is a simple command
+ * treat as non-sharable to improve performance
+ */
+ if((t->fork.forktre->tre.tretyp&COMMSK)==TCOM)
+ sfset(sfstdin,SF_PUBLIC|SF_SHARE,0);
+ waitall = job.waitall;
+ job.waitall = 0;
+ pid = job.parent;
+ }
+ else
+ error_info.line = t->fork.forkline-sh.st.firstline;
+ jmpval = sigsetjmp(buff.buff,0);
+ if(jmpval==0)
+ {
+ sh_redirect(t->fork.forkio,execflg);
+ (t->fork.forktre)->tre.tretyp |= t->tre.tretyp&FSHOWME;
+ sh_exec(t->fork.forktre,flags);
+ }
+ sh_popcontext(&buff);
+ sh_iorestore(buff.topfd,jmpval);
+ if(buff.olist)
+ free_list(buff.olist);
+ if(type&FPIN)
+ {
+ job.waitall = waitall;
+ type = sh.exitval;
+ if(!(type&SH_EXITSIG))
+ {
+ /* wait for remainder of pipline */
+ job_wait(waitall?pid:0);
+ if(type || !sh_isoption(SH_PIPEFAIL))
+ sh.exitval = type;
+ }
+ sh.st.ioset = 0;
+ }
+ if(jmpval>SH_JMPIO)
+ siglongjmp(*sh.jmplist,jmpval);
+ break;
+ }
+
+ case TPAR:
+ echeck = 1;
+ flags &= ~OPTIMIZE_FLAG;
+ if(!sh.subshell && !sh.st.trapcom[0] && !sh.st.trap[SH_ERRTRAP] && (flags&sh_state(SH_NOFORK)))
+ {
+ int jmpval;
+ struct checkpt buff;
+ sh_pushcontext(&buff,SH_JMPEXIT);
+ jmpval = sigsetjmp(buff.buff,0);
+ if(jmpval==0)
+ sh_exec(t->par.partre,flags);
+ sh_popcontext(&buff);
+ if(jmpval > SH_JMPEXIT)
+ siglongjmp(*sh.jmplist,jmpval);
+ sh_done(0);
+ }
+ else
+ sh_subshell(t->par.partre,flags,0);
+ break;
+
+ case TFIL:
+ {
+ /*
+ * This code sets up a pipe.
+ * All elements of the pipe are started by the parent.
+ * The last element executes in current environment
+ */
+ int pvo[2]; /* old pipe for multi-stage */
+ int pvn[2]; /* current set up pipe */
+ int savepipe = pipejob;
+ int showme = t->tre.tretyp&FSHOWME;
+ pid_t savepgid = job.curpgid;
+ if(sh.subshell)
+ sh_subtmpfile();
+ sh.inpipe = pvo;
+ sh.outpipe = pvn;
+ pvo[1] = -1;
+ if(sh_isoption(SH_PIPEFAIL))
+ job.waitall = 1;
+ else
+ job.waitall |= !pipejob && sh_isstate(SH_MONITOR);
+ do
+ {
+#if SHOPT_FASTPIPE
+ type = pipe_exec(pvn,t->lst.lstlef, errorflg);
+#else
+ /* create the pipe */
+ sh_pipe(pvn);
+ /* execute out part of pipe no wait */
+ (t->lst.lstlef)->tre.tretyp |= showme;
+ type = sh_exec(t->lst.lstlef, errorflg);
+#endif /* SHOPT_FASTPIPE */
+ pipejob=1;
+ /* save the pipe stream-ids */
+ pvo[0] = pvn[0];
+ /* close out-part of pipe */
+ sh_close(pvn[1]);
+ /* pipeline all in one process group */
+ t = t->lst.lstrit;
+ }
+ /* repeat until end of pipeline */
+ while(!type && t->tre.tretyp==TFIL);
+ sh.inpipe = pvn;
+ sh.outpipe = 0;
+ if(type == 0)
+ {
+ /*
+ * execute last element of pipeline
+ * in the current process
+ */
+ ((Shnode_t*)t)->tre.tretyp |= showme;
+ sh_exec(t,flags);
+ }
+ else
+ /* execution failure, close pipe */
+ sh_pclose(pvn);
+ pipejob = savepipe;
+#ifdef SIGTSTP
+ if(!pipejob && sh_isstate(SH_MONITOR))
+ tcsetpgrp(JOBTTY,sh.pid);
+#endif /*SIGTSTP */
+ job.curpgid = savepgid;
+ break;
+ }
+
+ case TLST:
+ {
+ /* a list of commands are executed here */
+ do
+ {
+ sh_exec(t->lst.lstlef,errorflg|OPTIMIZE);
+ t = t->lst.lstrit;
+ }
+ while(t->tre.tretyp == TLST);
+ sh_exec(t,flags);
+ break;
+ }
+
+ case TAND:
+ if(type&TTEST)
+ skipexitset++;
+ if(sh_exec(t->lst.lstlef,OPTIMIZE)==0)
+ sh_exec(t->lst.lstrit,flags);
+ break;
+
+ case TORF:
+ if(type&TTEST)
+ skipexitset++;
+ if(sh_exec(t->lst.lstlef,OPTIMIZE)!=0)
+ sh_exec(t->lst.lstrit,flags);
+ break;
+
+ case TFOR: /* for and select */
+ {
+ register char **args;
+ register int nargs;
+ register Namval_t *np;
+ int flag = errorflg|OPTIMIZE_FLAG;
+ struct dolnod *argsav=0;
+ struct comnod *tp;
+ char *cp, *trap, *nullptr = 0;
+ int nameref, refresh=1;
+ static char *av[5] = { "for", 0, "in" };
+#if SHOPT_OPTIMIZE
+ int jmpval = ((struct checkpt*)sh.jmplist)->mode;
+ struct checkpt buff;
+ void *optlist = sh.optlist;
+ sh.optlist = 0;
+ sh_tclear(t->for_.fortre);
+ sh_pushcontext(&buff,jmpval);
+ jmpval = sigsetjmp(buff.buff,0);
+ if(jmpval)
+ goto endfor;
+#endif /* SHOPT_OPTIMIZE */
+ error_info.line = t->for_.forline-sh.st.firstline;
+ if(!(tp=t->for_.forlst))
+ {
+ args=sh.st.dolv+1;
+ nargs = sh.st.dolc;
+ argsav=sh_arguse();
+ }
+ else
+ {
+ args=sh_argbuild(&argn,tp,0);
+ nargs = argn;
+ }
+ np = nv_open(t->for_.fornam, sh.var_tree,NV_NOASSIGN|NV_NOARRAY|NV_VARNAME|NV_NOREF);
+ nameref = nv_isref(np)!=0;
+ sh.st.loopcnt++;
+ cp = *args;
+ while(cp && sh.st.execbrk==0)
+ {
+ if(t->tre.tretyp&COMSCAN)
+ {
+ char *val;
+ int save_prompt;
+ /* reuse register */
+ if(refresh)
+ {
+ sh_menu(sfstderr,nargs,args);
+ refresh = 0;
+ }
+ save_prompt = sh.nextprompt;
+ sh.nextprompt = 3;
+ sh.timeout = 0;
+ sh.exitval=sh_readline(&sh,&nullptr,0,1,1000*sh.st.tmout);
+ sh.nextprompt = save_prompt;
+ if(sh.exitval||sfeof(sfstdin)||sferror(sfstdin))
+ {
+ sh.exitval = 1;
+ break;
+ }
+ if(!(val=nv_getval(nv_scoped(REPLYNOD))))
+ continue;
+ else
+ {
+ if(*(cp=val) == 0)
+ {
+ refresh++;
+ goto check;
+ }
+ while(type = *cp++)
+ if(type < '0' && type > '9')
+ break;
+ if(type!=0)
+ type = nargs;
+ else
+ type = (int)strtol(val, (char**)0, 10)-1;
+ if(type<0 || type >= nargs)
+ cp = "";
+ else
+ cp = args[type];
+ }
+ }
+ if(nameref)
+ nv_offattr(np,NV_REF);
+ else if(nv_isattr(np, NV_ARRAY))
+ nv_putsub(np,NIL(char*),0L);
+ nv_putval(np,cp,0);
+ if(nameref)
+ nv_setref(np,(Dt_t*)0,NV_VARNAME);
+ if(trap=sh.st.trap[SH_DEBUGTRAP])
+ {
+ av[0] = (t->tre.tretyp&COMSCAN)?"select":"for";
+ av[1] = t->for_.fornam;
+ av[3] = cp;
+ sh_debug(trap,(char*)0,(char*)0,av,0);
+ }
+ sh_exec(t->for_.fortre,flag);
+ flag &= ~OPTIMIZE_FLAG;
+ if(t->tre.tretyp&COMSCAN)
+ {
+ if((cp=nv_getval(nv_scoped(REPLYNOD))) && *cp==0)
+ refresh++;
+ }
+ else
+ cp = *++args;
+ check:
+ if(sh.st.breakcnt<0)
+ sh.st.execbrk = (++sh.st.breakcnt !=0);
+ }
+#if SHOPT_OPTIMIZE
+ endfor:
+ sh_popcontext(&buff);
+ sh_tclear(t->for_.fortre);
+ sh_optclear(&sh,optlist);
+ if(jmpval)
+ siglongjmp(*sh.jmplist,jmpval);
+#endif /*SHOPT_OPTIMIZE */
+ if(sh.st.breakcnt>0)
+ sh.st.execbrk = (--sh.st.breakcnt !=0);
+ sh.st.loopcnt--;
+ sh_argfree(argsav,0);
+ nv_close(np);
+ break;
+ }
+
+ case TWH: /* while and until */
+ {
+ register int r=0;
+ int first = OPTIMIZE_FLAG;
+ Shnode_t *tt = t->wh.whtre;
+#if SHOPT_FILESCAN
+ Sfio_t *iop=0;
+ int savein,fd;
+#endif /*SHOPT_FILESCAN*/
+#if SHOPT_OPTIMIZE
+ int jmpval = ((struct checkpt*)sh.jmplist)->mode;
+ struct checkpt buff;
+ void *optlist = sh.optlist;
+ sh.optlist = 0;
+ sh_tclear(t->wh.whtre);
+ sh_tclear(t->wh.dotre);
+ sh_pushcontext(&buff,jmpval);
+ jmpval = sigsetjmp(buff.buff,0);
+ if(jmpval)
+ goto endwhile;
+#endif /* SHOPT_OPTIMIZE */
+#if SHOPT_FILESCAN
+ if(type==TWH && tt->tre.tretyp==TCOM && !tt->com.comarg && tt->com.comio)
+ {
+ fd = sh_redirect(tt->com.comio,3);
+ savein = dup(0);
+ if(fd==0)
+ fd = savein;
+ iop = sfnew(NULL,NULL,SF_UNBOUND,fd,SF_READ);
+ close(0);
+ open("/dev/null",O_RDONLY);
+ sh.offsets[0] = -1;
+ sh.offsets[1] = 0;
+ if(tt->com.comset)
+ nv_setlist(tt->com.comset,NV_IDENT|NV_ASSIGN);
+ }
+#endif /*SHOPT_FILESCAN */
+ sh.st.loopcnt++;
+ while(sh.st.execbrk==0)
+ {
+#if SHOPT_FILESCAN
+ if(iop)
+ {
+ if(!(sh.cur_line=sfgetr(iop,'\n',SF_STRING)))
+ break;
+ }
+ else
+#endif /*SHOPT_FILESCAN */
+ if((sh_exec(tt,first)==0)!=(type==TWH))
+ break;
+ r = sh_exec(t->wh.dotre,first|errorflg);
+ if(sh.st.breakcnt<0)
+ sh.st.execbrk = (++sh.st.breakcnt !=0);
+ /* This is for the arithmetic for */
+ if(sh.st.execbrk==0 && t->wh.whinc)
+ sh_exec((Shnode_t*)t->wh.whinc,first);
+ first = 0;
+ errorflg &= ~OPTIMIZE_FLAG;
+#if SHOPT_FILESCAN
+ sh.offsets[0] = -1;
+ sh.offsets[1] = 0;
+#endif /*SHOPT_FILESCAN */
+ }
+#if SHOPT_OPTIMIZE
+ endwhile:
+ sh_popcontext(&buff);
+ sh_tclear(t->wh.whtre);
+ sh_tclear(t->wh.dotre);
+ sh_optclear(&sh,optlist);
+ if(jmpval)
+ siglongjmp(*sh.jmplist,jmpval);
+#endif /*SHOPT_OPTIMIZE */
+ if(sh.st.breakcnt>0)
+ sh.st.execbrk = (--sh.st.breakcnt !=0);
+ sh.st.loopcnt--;
+ sh.exitval= r;
+#if SHOPT_FILESCAN
+ if(iop)
+ {
+ sfclose(iop);
+ close(0);
+ dup(savein);
+ sh.cur_line = 0;
+ }
+#endif /*SHOPT_FILESCAN */
+ break;
+ }
+ case TARITH: /* (( expression )) */
+ {
+ register char *trap;
+ static char *arg[4]= {"((", 0, "))"};
+ error_info.line = t->ar.arline-sh.st.firstline;
+ if(!(t->ar.arexpr->argflag&ARG_RAW))
+ arg[1] = sh_macpat(t->ar.arexpr,OPTIMIZE|ARG_ARITH);
+ else
+ arg[1] = t->ar.arexpr->argval;
+ if(trap=sh.st.trap[SH_DEBUGTRAP])
+ sh_debug(trap,(char*)0, (char*)0, arg, ARG_ARITH);
+ if(sh_isoption(SH_XTRACE))
+ {
+ sh_trace(NIL(char**),0);
+ sfprintf(sfstderr,"((%s))\n",arg[1]);
+ }
+ if(t->ar.arcomp)
+ sh.exitval = !arith_exec((Arith_t*)t->ar.arcomp);
+ else
+ sh.exitval = !sh_arith(arg[1]);
+ break;
+ }
+
+ case TIF:
+ if(sh_exec(t->if_.iftre,OPTIMIZE)==0)
+ sh_exec(t->if_.thtre,flags);
+ else if(t->if_.eltre)
+ sh_exec(t->if_.eltre, flags);
+ else
+ sh.exitval=0; /* force zero exit for if-then-fi */
+ break;
+
+ case TSW:
+ {
+ Shnode_t *tt = (Shnode_t*)t;
+ char *trap, *r = sh_macpat(tt->sw.swarg,OPTIMIZE);
+ error_info.line = t->sw.swline-sh.st.firstline;
+ t= (Shnode_t*)(tt->sw.swlst);
+ if(trap=sh.st.trap[SH_DEBUGTRAP])
+ {
+ static char *av[4] = {"case", 0, "in" };
+ av[1] = r;
+ sh_debug(trap, (char*)0, (char*)0, av, 0);
+ }
+ while(t)
+ {
+ register struct argnod *rex=(struct argnod*)t->reg.regptr;
+ while(rex)
+ {
+ register char *s;
+ if(rex->argflag&ARG_MAC)
+ {
+ s = sh_macpat(rex,OPTIMIZE|ARG_EXP);
+ while(*s=='\\' && s[1]==0)
+ s+=2;
+ }
+ else
+ s = rex->argval;
+ type = (rex->argflag&ARG_RAW);
+ if((type && strcmp(r,s)==0) ||
+ (!type && (strmatch(r,s)
+ || trim_eq(r,s))))
+ {
+ do sh_exec(t->reg.regcom,(t->reg.regflag?0:flags));
+ while(t->reg.regflag &&
+ (t=(Shnode_t*)t->reg.regnxt));
+ t=0;
+ break;
+ }
+ else
+ rex=rex->argnxt.ap;
+ }
+ if(t)
+ t=(Shnode_t*)t->reg.regnxt;
+ }
+ break;
+ }
+
+ case TTIME:
+ {
+ /* time the command */
+ struct tms before,after;
+ const char *format = e_timeformat;
+ clock_t at, tm[3];
+#ifdef timeofday
+ struct timeval tb,ta;
+#else
+ clock_t bt;
+#endif /* timeofday */
+ if(type!=TTIME)
+ {
+ sh_exec(t->par.partre,OPTIMIZE);
+ sh.exitval = !sh.exitval;
+ break;
+ }
+ if(t->par.partre)
+ {
+ long timer_on;
+ timer_on = sh_isstate(SH_TIMING);
+#ifdef timeofday
+ timeofday(&tb);
+ times(&before);
+#else
+ bt = times(&before);
+#endif /* timeofday */
+ job.waitall = 1;
+ sh_onstate(SH_TIMING);
+ sh_exec(t->par.partre,OPTIMIZE);
+ if(!timer_on)
+ sh_offstate(SH_TIMING);
+ job.waitall = 0;
+ }
+ else
+ {
+#ifndef timeofday
+ bt = 0;
+#endif /* timeofday */
+ before.tms_utime = before.tms_cutime = 0;
+ before.tms_stime = before.tms_cstime = 0;
+ }
+#ifdef timeofday
+ times(&after);
+ timeofday(&ta);
+ at = sh.lim.clk_tck*(ta.tv_sec-tb.tv_sec);
+ at += ((sh.lim.clk_tck*(((1000000L/2)/sh.lim.clk_tck)+(ta.tv_usec-tb.tv_usec)))/1000000L);
+#else
+ at = times(&after) - bt;
+#endif /* timeofday */
+ tm[0] = at;
+ if(t->par.partre)
+ {
+ Namval_t *np = nv_open("TIMEFORMAT",sh.var_tree,NV_NOADD);
+ if(np)
+ {
+ format = nv_getval(np);
+ nv_close(np);
+ }
+ if(!format)
+ format = e_timeformat;
+ }
+ else
+ {
+ format = strchr(format+1,'\n')+1;
+#if 0
+ if(sh.optcount)
+ sfprintf(sfstderr,"%d optimizations\n",sh.optcount);
+#endif
+ }
+ tm[1] = after.tms_utime - before.tms_utime;
+ tm[1] += after.tms_cutime - before.tms_cutime;
+ tm[2] = after.tms_stime - before.tms_stime;
+ tm[2] += after.tms_cstime - before.tms_cstime;
+ if(format && *format)
+ p_time(sfstderr,sh_translate(format),tm);
+ break;
+ }
+ case TFUN:
+ {
+ register Namval_t *np;
+ register struct slnod *slp;
+ register char *fname = ((struct functnod*)t)->functnam;
+ register char *cp = strrchr(fname,'.');
+ register Namval_t *npv=0;
+#if SHOPT_NAMESPACE
+ if(t->tre.tretyp==TNSPACE)
+ {
+ Dt_t *root,*oldroot, *top=0;
+ Namval_t *oldnspace = sh.namespace;
+ int offset = staktell();
+ long optindex = sh.st.optindex;
+ if(cp)
+ errormsg(SH_DICT,ERROR_exit(1),e_ident,fname);
+ stakputc('.');
+ stakputs(fname);
+ stakputc(0);
+ np = nv_open(stakptr(offset),sh.var_base,NV_NOASSIGN|NV_NOARRAY|NV_VARNAME);
+ offset = staktell();
+ sh.namespace = np;
+ if(!(root=nv_dict(np)))
+ {
+ root = dtopen(&_Nvdisc,Dtoset);
+ nv_putval(np,(char*)root,NV_TABLE|NV_NOFREE);
+ sh.st.optindex = 1;
+ }
+ if(oldnspace && dtvnext(dtvnext(sh.var_tree)))
+ top = dtview(sh.var_tree,0);
+ else if(dtvnext(sh.var_tree))
+ top = dtview(sh.var_tree,0);
+ oldroot = sh.var_tree;
+ dtview(root,sh.var_base);
+ sh.var_tree = root;
+ if(top)
+ dtview(sh.var_tree,top);
+ sh_exec(t->for_.fortre,flags);
+ if(dtvnext(sh.var_tree))
+ top = dtview(sh.var_tree,0);
+ sh.var_tree = oldroot;
+ if(top)
+ dtview(top,sh.var_tree);
+ sh.namespace = oldnspace;
+ sh.st.optindex = optindex;
+ break;
+ }
+#endif /* SHOPT_NAMESPACE */
+ /* look for discipline functions */
+ error_info.line = t->funct.functline-sh.st.firstline;
+ /* Function names cannot be special builtin */
+ if(cp || sh.prefix)
+ {
+ int offset = staktell();
+ if(sh.prefix)
+ {
+ cp = sh.prefix;
+ sh.prefix = 0;
+ npv = nv_open(cp,sh.var_tree,NV_NOASSIGN|NV_NOARRAY|NV_VARNAME);
+ sh.prefix = cp;
+ cp = fname;
+ }
+ else
+ {
+ stakwrite(fname,cp-fname);
+ stakputc(0);
+ npv = nv_open(stakptr(offset),sh.var_tree,NV_NOASSIGN|NV_NOARRAY|NV_VARNAME);
+ }
+ offset = staktell();
+ stakputs(nv_name(npv));
+ if(*cp!='.')
+ stakputc('.');
+ stakputs(cp);
+ stakputc(0);
+ fname = stakptr(offset);
+ }
+ else if((np=nv_search(fname,sh.bltin_tree,0)) && nv_isattr(np,BLT_SPC))
+ errormsg(SH_DICT,ERROR_exit(1),e_badfun,fname);
+#if SHOPT_NAMESPACE
+ else if(sh.namespace)
+ {
+ int offset = staktell();
+ stakputs(nv_name(sh.namespace));
+ stakputc('.');
+ stakputs(fname);
+ stakputc(0);
+ fname = stakptr(offset);
+ }
+#endif /* SHOPT_NAMESPACE */
+ np = nv_open(fname,sh_subfuntree(1),NV_NOASSIGN|NV_NOARRAY|NV_VARNAME|NV_NOSCOPE);
+ if(npv)
+ {
+ if(!sh.mktype)
+ cp = nv_setdisc(npv,cp+1,np,(Namfun_t*)npv);
+ nv_close(npv);
+ if(!cp)
+ errormsg(SH_DICT,ERROR_exit(1),e_baddisc,fname);
+ }
+ if(np->nvalue.rp)
+ {
+ slp = (struct slnod*)np->nvenv;
+ sh_funstaks(slp->slchild,-1);
+ stakdelete(slp->slptr);
+ }
+ else
+ np->nvalue.rp = new_of(struct Ufunction,0);
+ if(t->funct.functstak)
+ {
+ struct functnod *fp;
+ slp = t->funct.functstak;
+ sh_funstaks(slp->slchild,1);
+ staklink(slp->slptr);
+ np->nvenv = (char*)slp;
+ nv_funtree(np) = (int*)(t->funct.functtre);
+ np->nvalue.rp->hoffset = t->funct.functloc;
+ np->nvalue.rp->lineno = t->funct.functline;
+ np->nvalue.rp->nspace = sh.namespace;
+ np->nvalue.rp->fname = 0;
+ fp = (struct functnod*)(slp+1);
+ if(fp->functtyp==(TFUN|FAMP))
+ np->nvalue.rp->fname = fp->functnam;
+ nv_setsize(np,fp->functline);
+ nv_offattr(np,NV_FPOSIX);
+ }
+ else
+ nv_unset(np);
+ if(type&FPOSIX)
+ nv_onattr(np,NV_FUNCTION|NV_FPOSIX);
+ else
+ nv_onattr(np,NV_FUNCTION);
+ if(type&FPIN)
+ nv_onattr(np,NV_FTMP);
+ break;
+ }
+
+ /* new test compound command */
+ case TTST:
+ {
+ register int n;
+ register char *left;
+ int negate = (type&TNEGATE)!=0;
+ if(type&TTEST)
+ skipexitset++;
+ error_info.line = t->tst.tstline-sh.st.firstline;
+ echeck = 1;
+ if((type&TPAREN)==TPAREN)
+ {
+ sh_exec(t->lst.lstlef,OPTIMIZE);
+ n = !sh.exitval;
+ }
+ else
+ {
+ register int traceon=0;
+ register char *right;
+ register char *trap;
+ char *argv[6];
+ n = type>>TSHIFT;
+ left = sh_macpat(&(t->lst.lstlef->arg),OPTIMIZE);
+ if(type&TBINARY)
+ right = sh_macpat(&(t->lst.lstrit->arg),((n==TEST_PEQ||n==TEST_PNE)?ARG_EXP:0)|OPTIMIZE);
+ if(trap=sh.st.trap[SH_DEBUGTRAP])
+ argv[0] = (type&TNEGATE)?((char*)e_tstbegin):"[[";
+ if(sh_isoption(SH_XTRACE))
+ {
+ traceon = sh_trace(NIL(char**),0);
+ sfwrite(sfstderr,e_tstbegin,(type&TNEGATE?5:3));
+ }
+ if(type&TUNARY)
+ {
+ if(traceon)
+ sfprintf(sfstderr,"-%c %s",n,sh_fmtq(left));
+ if(trap)
+ {
+ char unop[3];
+ unop[0] = '-';
+ unop[1] = n;
+ unop[2] = 0;
+ argv[1] = unop;
+ argv[2] = left;
+ argv[3] = "]]";
+ argv[4] = 0;
+ sh_debug(trap,(char*)0,(char*)0,argv, 0);
+ }
+ n = test_unop(n,left);
+ }
+ else if(type&TBINARY)
+ {
+ char *op;
+ int pattern = 0;
+ if(trap || traceon)
+ op = (char*)(shtab_testops+(n&037)-1)->sh_name;
+ type >>= TSHIFT;
+ if(type==TEST_PEQ || type==TEST_PNE)
+ pattern=ARG_EXP;
+ if(trap)
+ {
+ argv[1] = left;
+ argv[2] = op;
+ argv[3] = right;
+ argv[4] = "]]";
+ argv[5] = 0;
+ sh_debug(trap,(char*)0,(char*)0,argv, pattern);
+ }
+ n = test_binop(n,left,right);
+ if(traceon)
+ {
+ sfprintf(sfstderr,"%s %s ",sh_fmtq(left),op);
+ if(pattern)
+ out_pattern(sfstderr,right,-1);
+ else
+ sfputr(sfstderr,sh_fmtq(right),-1);
+ }
+ }
+ if(traceon)
+ sfwrite(sfstderr,e_tstend,4);
+ }
+ sh.exitval = ((!n)^negate);
+ if(!skipexitset)
+ exitset();
+ break;
+ }
+ }
+ if(sh.trapnote || (sh.exitval && sh_isstate(SH_ERREXIT)) &&
+ t && echeck)
+ sh_chktrap();
+ /* set $_ */
+ if(mainloop && com0)
+ {
+ /* store last argument here if it fits */
+ static char lastarg[32];
+ if(sh_isstate(SH_FORKED))
+ sh_done(0);
+ if(sh.lastarg!= lastarg && sh.lastarg)
+ free(sh.lastarg);
+ if(strlen(com[argn-1]) < sizeof(lastarg))
+ {
+ nv_onattr(L_ARGNOD,NV_NOFREE);
+ sh.lastarg = strcpy(lastarg,com[argn-1]);
+ }
+ else
+ {
+ nv_offattr(L_ARGNOD,NV_NOFREE);
+ sh.lastarg = strdup(com[argn-1]);
+ }
+ }
+ if(!skipexitset)
+ exitset();
+ if(!(OPTIMIZE))
+ {
+ if(sav != stakptr(0))
+ stakset(sav,0);
+ else if(staktell())
+ stakseek(0);
+ }
+ if(sh.trapnote&SH_SIGSET)
+ sh_exit(SH_EXITSIG|sh.lastsig);
+ if(was_interactive)
+ sh_onstate(SH_INTERACTIVE);
+ if(was_monitor && sh_isoption(SH_MONITOR))
+ sh_onstate(SH_MONITOR);
+ if(was_errexit)
+ sh_onstate(SH_ERREXIT);
+ }
+ return(sh.exitval);
+}
+
+/*
+ * test for equality with second argument trimmed
+ * returns 1 if r == trim(s) otherwise 0
+ */
+
+static int trim_eq(register const char *r,register const char *s)
+{
+ register char c;
+ while(c = *s++)
+ {
+ if(c=='\\')
+ c = *s++;
+ if(c && c != *r++)
+ return(0);
+ }
+ return(*r==0);
+}
+
+/*
+ * print out the command line if set -x is on
+ */
+
+int sh_trace(register char *argv[], register int nl)
+{
+ register char *cp;
+ register int bracket = 0;
+ if(sh_isoption(SH_XTRACE))
+ {
+ /* make this trace atomic */
+ sfset(sfstderr,SF_SHARE|SF_PUBLIC,0);
+ if(!(cp=nv_getval(nv_scoped(PS4NOD))))
+ cp = "+ ";
+ else
+ {
+ sh_offoption(SH_XTRACE);
+ cp = sh_mactry(cp);
+ sh_onoption(SH_XTRACE);
+ }
+ if(*cp)
+ sfputr(sfstderr,cp,-1);
+ if(argv)
+ {
+ char *argv0 = *argv;
+ nl = (nl?'\n':-1);
+ /* don't quote [ and [[ */
+ if(*(cp=argv[0])=='[' && (!cp[1] || !cp[2]&&cp[1]=='['))
+ {
+ sfputr(sfstderr,cp,*++argv?' ':nl);
+ bracket = 1;
+ }
+ while(cp = *argv++)
+ {
+ if(bracket==0 || *argv || *cp!=']')
+ cp = sh_fmtq(cp);
+ if(sh.prefix && cp!=argv0 && *cp!='-')
+ {
+ if(*cp=='.' && cp[1]==0)
+ cp = sh.prefix;
+ else
+ sfputr(sfstderr,sh.prefix,'.');
+ }
+ sfputr(sfstderr,cp,*argv?' ':nl);
+ }
+ sfset(sfstderr,SF_SHARE|SF_PUBLIC,1);
+ }
+ return(1);
+ }
+ return(0);
+}
+
+/*
+ * This routine creates a subshell by calling fork() or vfork()
+ * If ((flags&COMASK)==TCOM), then vfork() is permitted
+ * If fork fails, the shell sleeps for exponentially longer periods
+ * and tries again until a limit is reached.
+ * SH_FORKLIM is the max period between forks - power of 2 usually.
+ * Currently shell tries after 2,4,8,16, and 32 seconds and then quits
+ * Failures cause the routine to error exit.
+ * Parent links to here-documents are removed by the child
+ * Traps are reset by the child
+ * The process-id of the child is returned to the parent, 0 to the child.
+ */
+
+static void timed_out(void *handle)
+{
+ NOT_USED(handle);
+ timeout = 0;
+}
+
+
+/*
+ * called by parent and child after fork by sh_fork()
+ */
+pid_t _sh_fork(register pid_t parent,int flags,int *jobid)
+{
+ static long forkcnt = 1000L;
+ pid_t curpgid = job.curpgid;
+ pid_t postid = (flags&FAMP)?0:curpgid;
+ int sig;
+ if(parent<0)
+ {
+ if((forkcnt *= 2) > 1000L*SH_FORKLIM)
+ {
+ forkcnt=1000L;
+ errormsg(SH_DICT,ERROR_system(ERROR_NOEXEC),e_nofork);
+ }
+ sh_sigcheck();
+ timeout = (void*)sh_timeradd(forkcnt, 0, timed_out, NIL(void*));
+ job_wait((pid_t)1);
+ if(timeout)
+ {
+ timerdel(timeout);
+ forkcnt /= 2;
+ }
+ return(-1);
+ }
+ forkcnt=1000L;
+ if(parent)
+ {
+ int myjob;
+ sh.nforks++;
+ if(job.toclear)
+ job_clear();
+#ifdef JOBS
+ /* first process defines process group */
+ if(sh_isstate(SH_MONITOR))
+ {
+ /*
+ * errno==EPERM means that an earlier processes
+ * completed. Make parent the job group id.
+ */
+ if(postid==0)
+ job.curpgid = parent;
+ if(job.jobcontrol || (flags&FAMP))
+ {
+ if(setpgid(parent,job.curpgid)<0 && errno==EPERM)
+ setpgid(parent,parent);
+ }
+ }
+#endif /* JOBS */
+ if(!sh_isstate(SH_MONITOR) && job.waitall && postid==0)
+ job.curpgid = parent;
+ if(flags&FCOOP)
+ sh.cpid = parent;
+ myjob = job_post(parent,postid);
+ if(flags&FAMP)
+ job.curpgid = curpgid;
+ if(jobid)
+ *jobid = myjob;
+ return(parent);
+ }
+#if !_std_malloc
+ vmtrace(-1);
+#endif
+ /* This is the child process */
+ if(sh.trapnote&SH_SIGTERM)
+ sh_exit(SH_EXITSIG|SIGTERM);
+ sh.nforks=0;
+ timerdel(NIL(void*));
+#ifdef JOBS
+ if(!job.jobcontrol && !(flags&FAMP))
+ sh_offstate(SH_MONITOR);
+ if(sh_isstate(SH_MONITOR))
+ {
+ parent = getpid();
+ if(postid==0)
+ job.curpgid = parent;
+ while(setpgid(0,job.curpgid)<0 && job.curpgid!=parent)
+ job.curpgid = parent;
+# ifdef SIGTSTP
+ if(job.curpgid==parent && !(flags&FAMP))
+ tcsetpgrp(job.fd,job.curpgid);
+# endif /* SIGTSTP */
+ }
+# ifdef SIGTSTP
+ if(job.jobcontrol)
+ {
+ signal(SIGTTIN,SIG_DFL);
+ signal(SIGTTOU,SIG_DFL);
+ signal(SIGTSTP,SIG_DFL);
+ }
+# endif /* SIGTSTP */
+ job.jobcontrol = 0;
+#endif /* JOBS */
+ job.toclear = 1;
+ sh.login_sh = 0;
+ sh_offoption(SH_LOGIN_SHELL);
+ sh_onstate(SH_FORKED);
+ sh_onstate(SH_NOLOG);
+ sh.fn_depth = 0;
+#if SHOPT_ACCT
+ sh_accsusp();
+#endif /* SHOPT_ACCT */
+ /* Reset remaining signals to parent */
+ /* except for those `lost' by trap */
+ sh_sigreset(2);
+ sh.subshell = 0;
+ if((flags&FAMP) && sh.coutpipe>1)
+ sh_close(sh.coutpipe);
+ sig = sh.savesig;
+ sh.savesig = 0;
+ if(sig>0)
+ sh_fault(sig);
+ sh_sigcheck();
+ return(0);
+}
+
+pid_t sh_fork(int flags, int *jobid)
+{
+ register pid_t parent;
+ register int sig;
+#if SHOPT_FASTPIPE
+ if(sffileno(sfstdin)<0)
+ {
+ off_t current = sfseek(sfstdin,(off_t)0,SEEK_CUR);
+ sfseek(sfstdin,(off_t)0,SEEK_END);
+ sfdisc(sfstdin,SF_POPDISC);
+ fcntl(sffileno(sfstdin),F_SETFD,0);
+ sh_iostream(0);
+ sfseek(sfstdin,current,SEEK_SET);
+ }
+#endif /* SHOPT_FASTPIPE */
+ if(!sh.pathlist)
+ path_get("");
+ sfsync(NIL(Sfio_t*));
+ sh.trapnote &= ~SH_SIGTERM;
+ job_fork(-1);
+ sh.savesig = -1;
+ while(_sh_fork(parent=fork(),flags,jobid) < 0);
+ sig = sh.savesig;
+ sh.savesig = 0;
+ if(sig>0)
+ sh_fault(sig);
+ job_fork(parent);
+ return(parent);
+}
+
+/*
+ * add exports from previous scope to the new scope
+ */
+static void local_exports(register Namval_t *np, void *data)
+{
+ register Namval_t *mp;
+ register char *cp;
+ if(nv_isarray(np))
+ nv_putsub(np,NIL(char*),0);
+ if((cp = nv_getval(np)) && (mp = nv_search(nv_name(np), sh.var_tree, NV_ADD|HASH_NOSCOPE)) && nv_isnull(mp))
+ nv_putval(mp, cp, 0);
+}
+
+/*
+ * This routine is used to execute the given function <fun> in a new scope
+ * If <fun> is NULL, then arg points to a structure containing a pointer
+ * to a function that will be executed in the current environment.
+ */
+int sh_funscope(int argn, char *argv[],int(*fun)(void*),void *arg,int execflg)
+{
+ register char *trap;
+ register int nsig;
+ struct dolnod *argsav=0,*saveargfor;
+ struct sh_scoped savst, *prevscope = sh.st.self;
+ struct argnod *envlist=0;
+ Shopt_t savopt;
+ int jmpval;
+ int r = 0;
+ char *savstak;
+ struct funenv *fp;
+ struct checkpt buff;
+ Namval_t *nspace = sh.namespace;
+ savopt = sh.options;
+ sh.st.lineno = error_info.line;
+ *prevscope = sh.st;
+ sh_offoption(SH_ERREXIT);
+ sh.st.prevst = prevscope;
+ sh.st.self = &savst;
+ sh.topscope = (Shscope_t*)sh.st.self;
+ sh.st.opterror = sh.st.optchar = 0;
+ sh.st.optindex = 1;
+ sh.st.loopcnt = 0;
+ if(!fun)
+ {
+ fp = (struct funenv*)arg;
+ envlist = fp->env;
+ }
+ prevscope->save_tree = sh.var_tree;
+ nv_scope(envlist);
+ if(dtvnext(prevscope->save_tree)!= (sh.namespace?sh.var_base:0))
+ {
+ /* eliminate parent scope */
+ Dt_t *dt = dtview(sh.var_tree,0);
+ dtview(sh.var_tree,dtvnext(prevscope->save_tree));
+ nv_scan(prevscope->save_tree, local_exports,(void*)0, NV_EXPORT, NV_EXPORT|NV_NOSCOPE);
+ }
+ sh.st.save_tree = sh.var_tree;
+ if(!fun)
+ {
+ Namval_t *np;
+ if(nv_isattr(fp->node,NV_TAGGED))
+ sh_onoption(SH_XTRACE);
+ else
+ sh_offoption(SH_XTRACE);
+#if SHOPT_NAMESPACE
+ if((np=(fp->node)->nvalue.rp->nspace) && np!=sh.namespace)
+ {
+ Dt_t *dt = sh.var_tree;
+ dtview(dt,0);
+ dtview(dt,nv_dict(np));
+ sh.var_tree = nv_dict(np);
+ sh.namespace = np;
+ }
+#endif /* SHOPT_NAMESPACE */
+ }
+ sh.st.cmdname = argv[0];
+ /* save trap table */
+ if((nsig=sh.st.trapmax*sizeof(char*))>0 || sh.st.trapcom[0])
+ {
+ nsig += sizeof(char*);
+ memcpy(savstak=stakalloc(nsig),(char*)&sh.st.trapcom[0],nsig);
+ }
+ sh_sigreset(0);
+ argsav = sh_argnew(argv,&saveargfor);
+ sh_pushcontext(&buff,SH_JMPFUN);
+ errorpush(&buff.err,0);
+ error_info.id = argv[0];
+ sh.st.var_local = sh.var_tree;
+ jmpval = sigsetjmp(buff.buff,0);
+ if(!fun)
+ {
+ sh.st.filename = fp->node->nvalue.rp->fname;
+ nv_putval(SH_PATHNAMENOD, sh.st.filename ,NV_NOFREE);
+ nv_putval(SH_FUNNAMENOD,nv_name(fp->node),NV_NOFREE);
+ }
+ if(jmpval == 0)
+ {
+ if(sh.fn_depth++ > MAXDEPTH)
+ siglongjmp(*sh.jmplist,SH_JMPERRFN);
+ else if(fun)
+ r= (*fun)(arg);
+ else
+ {
+ sh_exec((Shnode_t*)(nv_funtree((fp->node))),execflg|SH_ERREXIT);
+ r = sh.exitval;
+ }
+ }
+ if(--sh.fn_depth==1 && jmpval==SH_JMPERRFN)
+ errormsg(SH_DICT,ERROR_exit(1),e_toodeep,argv[0]);
+ sh_popcontext(&buff);
+ if (sh.st.self != &savst)
+ sh.var_tree = (Dt_t*)savst.save_tree;
+ nv_unscope();
+ sh.namespace = nspace;
+ sh.var_tree = (Dt_t*)prevscope->save_tree;
+ sh_argreset(argsav,saveargfor);
+ trap = sh.st.trapcom[0];
+ sh.st.trapcom[0] = 0;
+ sh_sigreset(1);
+ if (sh.st.self != &savst)
+ *sh.st.self = sh.st;
+ sh.st = *prevscope;
+ sh.topscope = (Shscope_t*)prevscope;
+ nv_getval(nv_scoped(IFSNOD));
+ if(nsig)
+ memcpy((char*)&sh.st.trapcom[0],savstak,nsig);
+ sh.trapnote=0;
+ if(nsig)
+ stakset(savstak,0);
+ sh.options = savopt;
+ if(trap)
+ {
+ sh_trap(trap,0);
+ free(trap);
+ }
+ if(sh.exitval > SH_EXITSIG)
+ sh_fault(sh.exitval&SH_EXITMASK);
+ if(jmpval > SH_JMPFUN)
+ {
+ sh_chktrap();
+ siglongjmp(*sh.jmplist,jmpval);
+ }
+ return(r);
+}
+
+
+static void sh_funct(Namval_t *np,int argn, char *argv[],struct argnod *envlist,int execflg)
+{
+ struct funenv fun;
+ char *fname = nv_getval(SH_FUNNAMENOD);
+ if(nv_isattr(np,NV_FPOSIX))
+ {
+ char *save;
+ int loopcnt = sh.st.loopcnt;
+ sh.posix_fun = np;
+ opt_info.index = opt_info.offset = 0;
+ error_info.errors = 0;
+ save = argv[-1];
+ argv[-1] = 0;
+ nv_putval(SH_FUNNAMENOD, nv_name(np),NV_NOFREE);
+ sh.st.loopcnt = 0;
+ b_dot_cmd(argn+1,argv-1,&sh);
+ sh.st.loopcnt = loopcnt;
+ argv[-1] = save;
+ }
+ else
+ {
+ fun.env = envlist;
+ fun.node = np;
+ sh_funscope(argn,argv,0,&fun,execflg);
+ }
+ nv_putval(SH_FUNNAMENOD,fname,NV_NOFREE);
+ nv_putval(SH_PATHNAMENOD, sh.st.filename ,0);
+}
+
+/*
+ * external interface to execute a function without arguments
+ * <np> is the function node
+ * If <nq> is not-null, then sh.name and sh.subscript will be set
+ */
+int sh_fun(Namval_t *np, Namval_t *nq, char *argv[])
+{
+ register int offset;
+ register char *base;
+ Namval_t node;
+ int n=0;
+ char *av[2];
+ Fcin_t save;
+ fcsave(&save);
+ if((offset=staktell())>0)
+ base=stakfreeze(0);
+ if(!argv)
+ {
+ argv = av;
+ argv[1]=0;
+ }
+ argv[0] = nv_name(np);
+ while(argv[n])
+ n++;
+ if(nq)
+ {
+ /*
+ * set ${.sh.name} and ${.sh.subscript}
+ * set _ to reference for ${.sh.name}[$.sh.subscript]
+ */
+ struct Namref nr;
+ memset(&nr,0,sizeof(nr));
+ nr.np = nq;
+ nv_putval(SH_NAMENOD, nv_name(nq), NV_NOFREE);
+ memcpy(&node,L_ARGNOD,sizeof(node));
+ L_ARGNOD->nvalue.nrp = &nr;
+ L_ARGNOD->nvenv = 0;
+ L_ARGNOD->nvfun = (Namfun_t*)sh.last_table;
+ L_ARGNOD->nvflag = NV_REF|NV_NOFREE;
+ if(nv_arrayptr(nq))
+ {
+ nv_putval(SH_SUBSCRNOD,nv_getsub(nq),NV_NOFREE);
+ L_ARGNOD->nvenv = (char*)SH_SUBSCRNOD->nvalue.cp;
+ }
+ }
+ if(is_abuiltin(np))
+ {
+ int jmpval;
+ struct checkpt buff;
+ sh_pushcontext(&buff,SH_JMPCMD);
+ jmpval = sigsetjmp(buff.buff,1);
+ if(jmpval == 0)
+ {
+ void *context = nv_context(np);
+ errorpush(&buff.err,0);
+ error_info.id = argv[0];
+ opt_info.index = opt_info.offset = 0;
+ opt_info.disc = 0;
+ sh.exitval = 0;
+ if(!context)
+ context = (void*)&sh;
+ sh.exitval = (*funptr(np))(n,argv,context);
+ }
+ sh_popcontext(&buff);
+ if(jmpval>SH_JMPCMD)
+ siglongjmp(*sh.jmplist,jmpval);
+ }
+ else
+ sh_funct(np,n,argv,(struct argnod*)0,sh_isstate(SH_ERREXIT));
+ if(nq)
+ {
+ L_ARGNOD->nvalue.np = node.nvalue.np;
+ L_ARGNOD->nvenv = node.nvenv;
+ L_ARGNOD->nvflag = node.nvflag;
+ L_ARGNOD->nvfun = node.nvfun;
+ nv_unset(SH_NAMENOD);
+ nv_unset(SH_SUBSCRNOD);
+ }
+ fcrestore(&save);
+ if(offset>0)
+ stakset(base,offset);
+ return(sh.exitval);
+}
+
+/*
+ * This dummy routine is called by built-ins that do recursion
+ * on the file system (chmod, chgrp, chown). It causes
+ * the shell to invoke the non-builtin version in this case
+ */
+int cmdrecurse(int argc, char* argv[], int ac, char* av[])
+{
+ NOT_USED(argc);
+ NOT_USED(argv[0]);
+ NOT_USED(ac);
+ NOT_USED(av[0]);
+ return(SH_RUNPROG);
+}
+
+/*
+ * set up pipe for cooperating process
+ */
+static void coproc_init(int pipes[])
+{
+ int outfd;
+ if(sh.coutpipe>=0 && sh.cpid)
+ errormsg(SH_DICT,ERROR_exit(1),e_pexists);
+ sh.cpid = 0;
+ if(sh.cpipe[0]<=0 || sh.cpipe[1]<=0)
+ {
+ /* first co-process */
+ sh_pclose(sh.cpipe);
+ sh_pipe(sh.cpipe);
+ if((outfd=sh.cpipe[1]) < 10)
+ {
+ int fd=fcntl(sh.cpipe[1],F_DUPFD,10);
+ if(fd>=10)
+ {
+ sh.fdstatus[fd] = (sh.fdstatus[outfd]&~IOCLEX);
+ close(outfd);
+ sh.fdstatus[outfd] = IOCLOSE;
+ sh.cpipe[1] = fd;
+ }
+ }
+ if(fcntl(*sh.cpipe,F_SETFD,FD_CLOEXEC)>=0)
+ sh.fdstatus[sh.cpipe[0]] |= IOCLEX;
+ sh.fdptrs[sh.cpipe[0]] = sh.cpipe;
+
+ if(fcntl(sh.cpipe[1],F_SETFD,FD_CLOEXEC) >=0)
+ sh.fdstatus[sh.cpipe[1]] |= IOCLEX;
+ }
+ sh.outpipe = sh.cpipe;
+ sh_pipe(sh.inpipe=pipes);
+ sh.coutpipe = sh.inpipe[1];
+ sh.fdptrs[sh.coutpipe] = &sh.coutpipe;
+ if(fcntl(sh.outpipe[0],F_SETFD,FD_CLOEXEC)>=0)
+ sh.fdstatus[sh.outpipe[0]] |= IOCLEX;
+}
+
+#if SHOPT_SPAWN
+
+
+#if SHOPT_AMP || !defined(_lib_fork)
+/*
+ * print out function definition
+ */
+static void print_fun(register Namval_t* np, void *data)
+{
+ register char *format;
+ NOT_USED(data);
+ if(!is_afunction(np) || !np->nvalue.ip)
+ return;
+ if(nv_isattr(np,NV_FPOSIX))
+ format="%s()\n{ ";
+ else
+ format="function %s\n{ ";
+ sfprintf(sfstdout,format,nv_name(np));
+ sh_deparse(sfstdout,(Shnode_t*)(nv_funtree(np)),0);
+ sfwrite(sfstdout,"}\n",2);
+}
+
+/*
+ * create a shell script consisting of t->fork.forktre and execute it
+ */
+static int run_subshell(const Shnode_t *t,pid_t grp)
+{
+ static char prolog[] = "(print $(typeset +A);set; typeset -p; print .sh.dollar=$$;set +o)";
+ register int i, fd, trace = sh_isoption(SH_XTRACE);
+ int pin,pout;
+ pid_t pid;
+ char *arglist[2], *envlist[2], devfd[12], *cp;
+ Sfio_t *sp = sftmp(0);
+ envlist[0] = "_=" SH_ID;
+ envlist[1] = 0;
+ arglist[0] = error_info.id?error_info.id:sh.shname;
+ if(*arglist[0]=='-')
+ arglist[0]++;
+ arglist[1] = devfd;
+ strncpy(devfd,e_devfdNN,sizeof(devfd));
+ arglist[2] = 0;
+ sfstack(sfstdout,sp);
+ if(trace)
+ sh_offoption(SH_XTRACE);
+ sfwrite(sfstdout,"typeset -A -- ",14);
+ sh_trap(prolog,0);
+ nv_scan(sh.fun_tree, print_fun, (void*)0,0, 0);
+ if(sh.st.dolc>0)
+ {
+ /* pass the positional parameters */
+ char **argv = sh.st.dolv+1;
+ sfwrite(sfstdout,"set --",6);
+ while(*argv)
+ sfprintf(sfstdout," %s",sh_fmtq(*argv++));
+ sfputc(sfstdout,'\n');
+ }
+ pin = (sh.inpipe?sh.inpipe[1]:0);
+ pout = (sh.outpipe?sh.outpipe[0]:0);
+ for(i=3; i < 10; i++)
+ {
+ if(sh.fdstatus[i]&IOCLEX && i!=pin && i!=pout)
+ {
+ sfprintf(sfstdout,"exec %d<&%d\n",i,i);
+ fcntl(i,F_SETFD,0);
+ }
+ }
+ sfprintf(sfstdout,"LINENO=%d\n",t->fork.forkline);
+ if(trace)
+ {
+ sfwrite(sfstdout,"set -x\n",7);
+ sh_onoption(SH_XTRACE);
+ }
+ sfstack(sfstdout,NIL(Sfio_t*));
+ sh_deparse(sp,t->fork.forktre,0);
+ sfseek(sp,(Sfoff_t)0,SEEK_SET);
+ fd = sh_dup(sffileno(sp));
+ cp = devfd+8;
+ if(fd>9)
+ *cp++ = '0' + (fd/10);
+ *cp++ = '0' + fd%10;
+ *cp = 0;
+ sfclose(sp);
+ sfsync(NIL(Sfio_t*));
+ if(!sh.shpath)
+ sh.shpath = pathshell();
+ pid = spawnveg(sh.shpath,arglist,envlist,grp);
+ close(fd);
+ for(i=3; i < 10; i++)
+ {
+ if(sh.fdstatus[i]&IOCLEX && i!=pin && i!=pout)
+ fcntl(i,F_SETFD,FD_CLOEXEC);
+ }
+ if(pid <=0)
+ errormsg(SH_DICT,ERROR_system(ERROR_NOEXEC),e_exec,arglist[0]);
+ return(pid);
+}
+#endif /* !_lib_fork */
+
+static void sigreset(int mode)
+{
+ register char *trap;
+ register int sig=sh.st.trapmax;
+ while(sig-- > 0)
+ {
+ if((trap=sh.st.trapcom[sig]) && *trap==0)
+ signal(sig,mode?sh_fault:SIG_IGN);
+ }
+}
+
+/*
+ * A combined fork/exec for systems with slow or non-existent fork()
+ */
+static pid_t sh_ntfork(const Shnode_t *t,char *argv[],int *jobid,int flag)
+{
+ static pid_t spawnpid;
+ static int savetype;
+ static int savejobid;
+ Shell_t *shp = sh_getinterp();
+ struct checkpt buff;
+ int otype=0, scope=0, jmpval;
+ int jobwasset=0, sigwasset=0;
+ char **arge, *path;
+ pid_t grp = 0;
+ Pathcomp_t *pp;
+ if(flag)
+ {
+ otype = savetype;
+ savetype=0;
+ }
+# if SHOPT_AMP || !defined(_lib_fork)
+ if(!argv)
+ {
+ register Shnode_t *tchild = t->fork.forktre;
+ int optimize=0;
+ otype = t->tre.tretyp;
+ savetype = otype;
+ spawnpid = 0;
+# ifndef _lib_fork
+ if((tchild->tre.tretyp&COMMSK)==TCOM)
+ {
+ Namval_t *np = (Namval_t*)(tchild->com.comnamp);
+ if(np)
+ {
+ path = nv_name(np);
+ if(!nv_isattr(np,BLT_ENV))
+ np=0;
+ else if(strcmp(path,"echo")==0 || memcmp(path,"print",5)==0)
+ np=0;
+ }
+ else if(!tchild->com.comarg)
+ optimize=1;
+ else if(tchild->com.comtyp&COMSCAN)
+ {
+ if(tchild->com.comarg->argflag&ARG_RAW)
+ path = tchild->com.comarg->argval;
+ else
+ path = 0;
+ }
+ else
+ path = ((struct dolnod*)tchild->com.comarg)->dolval[ARG_SPARE];
+ if(!np && path && !nv_search(path,shp->fun_tree,0))
+ optimize=1;
+ }
+# endif
+ sh_pushcontext(&buff,SH_JMPIO);
+ jmpval = sigsetjmp(buff.buff,0);
+ {
+ if((otype&FINT) && !sh_isstate(SH_MONITOR))
+ {
+ signal(SIGQUIT,SIG_IGN);
+ signal(SIGINT,SIG_IGN);
+ if(!shp->st.ioset)
+ {
+ sh_iosave(0,buff.topfd);
+ sh_iorenumber(sh_chkopen(e_devnull),0);
+ }
+ }
+ if(otype&FPIN)
+ {
+ int fd = shp->inpipe[1];
+ sh_iosave(0,buff.topfd);
+ sh_iorenumber(shp->inpipe[0],0);
+ if(fd>=0 && (!(otype&FPOU) || (otype&FCOOP)) && fcntl(fd,F_SETFD,FD_CLOEXEC)>=0)
+ shp->fdstatus[fd] |= IOCLEX;
+ }
+ if(otype&FPOU)
+ {
+ sh_iosave(1,buff.topfd);
+ sh_iorenumber(sh_dup(shp->outpipe[1]),1);
+ if(fcntl(shp->outpipe[0],F_SETFD,FD_CLOEXEC)>=0)
+ shp->fdstatus[shp->outpipe[0]] |= IOCLEX;
+ }
+
+ if(t->fork.forkio)
+ sh_redirect(t->fork.forkio,0);
+ if(optimize==0)
+ {
+#ifdef SIGTSTP
+ if(job.jobcontrol)
+ {
+ signal(SIGTTIN,SIG_DFL);
+ signal(SIGTTOU,SIG_DFL);
+ }
+#endif /* SIGTSTP */
+#ifdef JOBS
+ if(sh_isstate(SH_MONITOR) && (job.jobcontrol || (otype&FAMP)))
+ {
+ if((otype&FAMP) || job.curpgid==0)
+ grp = 1;
+ else
+ grp = job.curpgid;
+ }
+#endif /* JOBS */
+ spawnpid = run_subshell(t,grp);
+ }
+ else
+ {
+ sh_exec(tchild,SH_NTFORK);
+ if(jobid)
+ *jobid = savejobid;
+ }
+ }
+ sh_popcontext(&buff);
+ if((otype&FINT) && !sh_isstate(SH_MONITOR))
+ {
+ signal(SIGQUIT,sh_fault);
+ signal(SIGINT,sh_fault);
+ }
+ if((otype&FPIN) && (!(otype&FPOU) || (otype&FCOOP)) && fcntl(shp->inpipe[1],F_SETFD,FD_CLOEXEC)>=0)
+ shp->fdstatus[shp->inpipe[1]] &= ~IOCLEX;
+ if(t->fork.forkio || otype)
+ sh_iorestore(buff.topfd,jmpval);
+ if(optimize==0)
+ {
+#ifdef SIGTSTP
+ if(job.jobcontrol)
+ {
+ signal(SIGTTIN,SIG_IGN);
+ signal(SIGTTOU,SIG_IGN);
+ }
+#endif /* SIGTSTP */
+ if(spawnpid>0)
+ _sh_fork(spawnpid,otype,jobid);
+ if(grp>0 && !(otype&FAMP))
+ {
+ while(tcsetpgrp(job.fd,job.curpgid)<0 && job.curpgid!=spawnpid)
+ job.curpgid = spawnpid;
+ }
+ }
+ savetype=0;
+ if(jmpval>SH_JMPIO)
+ siglongjmp(*shp->jmplist,jmpval);
+ if(spawnpid<0 && (otype&FCOOP))
+ {
+ sh_close(shp->coutpipe);
+ sh_close(shp->cpipe[1]);
+ shp->cpipe[1] = -1;
+ shp->coutpipe = -1;
+ }
+ shp->exitval = 0;
+ return(spawnpid);
+ }
+# endif /* !_lib_fork */
+ sh_pushcontext(&buff,SH_JMPCMD);
+ errorpush(&buff.err,ERROR_SILENT);
+ jmpval = sigsetjmp(buff.buff,0);
+ if(jmpval == 0)
+ {
+ if((otype&FINT) && !sh_isstate(SH_MONITOR))
+ {
+ signal(SIGQUIT,SIG_IGN);
+ signal(SIGINT,SIG_IGN);
+ }
+ spawnpid = -1;
+ if(t->com.comio)
+ sh_redirect(t->com.comio,0);
+ error_info.id = *argv;
+ if(t->com.comset)
+ {
+ scope++;
+ nv_scope(t->com.comset);
+ }
+ if(!strchr(path=argv[0],'/'))
+ {
+#ifdef PATH_BFPATH
+ Namval_t *np;
+ if((np=nv_search(path,shp->track_tree,0)) && !nv_isattr(np,NV_NOALIAS) && np->nvalue.cp)
+ path = nv_getval(np);
+ else if(path_absolute(path,NIL(Pathcomp_t*)))
+ {
+ path = stakptr(PATH_OFFSET);
+ stakfreeze(0);
+ }
+ else
+ {
+ pp=path_get(path);
+ while(pp)
+ {
+ if(pp->len==1 && *pp->name=='.')
+ break;
+ pp = pp->next;
+ }
+ if(!pp)
+ path = 0;
+ }
+#else
+ path = shp->lastpath;
+#endif
+ }
+ else if(sh_isoption(SH_RESTRICTED))
+ errormsg(SH_DICT,ERROR_exit(1),e_restricted,path);
+ if(!path)
+ {
+ spawnpid = -1;
+ goto fail;
+ }
+ arge = sh_envgen();
+ shp->exitval = 0;
+#ifdef SIGTSTP
+ if(job.jobcontrol)
+ {
+ signal(SIGTTIN,SIG_DFL);
+ signal(SIGTTOU,SIG_DFL);
+ jobwasset++;
+ }
+#endif /* SIGTSTP */
+#ifdef JOBS
+ if(sh_isstate(SH_MONITOR) && (job.jobcontrol || (otype&FAMP)))
+ {
+ if((otype&FAMP) || job.curpgid==0)
+ grp = 1;
+ else
+ grp = job.curpgid;
+ }
+#endif /* JOBS */
+
+ sfsync(NIL(Sfio_t*));
+ sigreset(0); /* set signals to ignore */
+ sigwasset++;
+ /* find first path that has a library component */
+ for(pp=path_get(argv[0]); pp && !pp->lib ; pp=pp->next);
+ spawnpid = path_spawn(path,argv,arge,pp,(grp<<1)|1);
+ if(spawnpid < 0 && errno==ENOEXEC)
+ {
+ char *devfd;
+ int fd = open(path,O_RDONLY);
+ argv[-1] = argv[0];
+ argv[0] = path;
+ if(fd>=0)
+ {
+ struct stat statb;
+ sfprintf(sh.strbuf,"/dev/fd/%d",fd);
+ if(stat(devfd=sfstruse(sh.strbuf),&statb)>=0)
+ argv[0] = devfd;
+ }
+ if(!shp->shpath)
+ shp->shpath = pathshell();
+ spawnpid = path_spawn(shp->shpath,&argv[-1],arge,pp,(grp<<1)|1);
+ if(fd>=0)
+ close(fd);
+ argv[0] = argv[-1];
+ }
+ fail:
+ if(spawnpid < 0) switch(errno=shp->path_err)
+ {
+ case ENOENT:
+ errormsg(SH_DICT,ERROR_system(ERROR_NOENT),e_found+4);
+ default:
+ errormsg(SH_DICT,ERROR_system(ERROR_NOEXEC),e_exec+4);
+ }
+ }
+ else
+ exitset();
+ sh_popcontext(&buff);
+ if(buff.olist)
+ free_list(buff.olist);
+#ifdef SIGTSTP
+ if(jobwasset)
+ {
+ signal(SIGTTIN,SIG_IGN);
+ signal(SIGTTOU,SIG_IGN);
+ }
+#endif /* SIGTSTP */
+ if(sigwasset)
+ sigreset(1); /* restore ignored signals */
+ if(scope)
+ {
+ nv_unscope();
+ if(jmpval==SH_JMPSCRIPT)
+ nv_setlist(t->com.comset,NV_EXPORT|NV_IDENT|NV_ASSIGN);
+ }
+ if(t->com.comio)
+ sh_iorestore(buff.topfd,jmpval);
+ if(jmpval>SH_JMPCMD)
+ siglongjmp(*shp->jmplist,jmpval);
+ if(spawnpid>0)
+ {
+ _sh_fork(spawnpid,otype,jobid);
+#ifdef JOBS
+ if(grp==1)
+ job.curpgid = spawnpid;
+# ifdef SIGTSTP
+ if(grp>0 && !(otype&FAMP))
+ {
+ while(tcsetpgrp(job.fd,job.curpgid)<0 && job.curpgid!=spawnpid)
+ job.curpgid = spawnpid;
+ }
+# endif /* SIGTSTP */
+#endif /* JOBS */
+ savejobid = *jobid;
+ if(otype)
+ return(0);
+ }
+ return(spawnpid);
+}
+
+# ifdef _was_lib_fork
+# define _lib_fork 1
+# endif
+# ifndef _lib_fork
+ pid_t fork(void)
+ {
+ errormsg(SH_DICT,ERROR_exit(3),e_notimp,"fork");
+ return(-1);
+ }
+# endif /* _lib_fork */
+#endif /* SHOPT_SPAWN */
+
+/*
+ * override procrun() since it is used in libcmd
+ */
+#include <proc.h>
+int procrun(const char *path, char *argv[])
+{
+ if(sh.subshell)
+ sh_subtmpfile();
+ return(procclose(procopen(path, argv, NiL, NiL, PROC_FOREGROUND|PROC_GID
+|PROC_UID)));
+}
diff --git a/usr/src/lib/libshell/common/shell.3 b/usr/src/lib/libshell/common/shell.3
new file mode 100644
index 0000000000..e6fbbf026e
--- /dev/null
+++ b/usr/src/lib/libshell/common/shell.3
@@ -0,0 +1,408 @@
+.fp 5 CW
+.TH SHELL 3 "28 Feb 2003"
+.PP
+.SH NAME
+.PP
+\fBshell\fR \- a \f5ksh\fP library interface
+.PP
+.SH SYNOPSIS
+.ta .8i 1.6i 2.4i 3.2i 4.0i 4.8i 5.6i
+.SS "HEADERS/LIBRARIES"
+.nf
+.ft 5
+#include <shell.h>
+libshell.a -lshell
+.ft R
+.fi
+.SS "DATA TYPES"
+.nf
+.ft 5
+Shell_t;
+Shopt_t;
+Shscope_t;
+Shbltin_f;
+Shinit_f;
+Shwait_f;
+.ft R
+.fi
+.SS "FUNCTIONS"
+.nf
+.ft 5
+int sh_main(int \fIargc\fP, char *\fIargv\fP[], Sh_init \fIfn\fP);
+Shell_t *sh_init(int \fIargc\fP, char *\fIargv\fP);
+Shell_t *sh_getinterp(void);
+
+Namval_t *sh_addbuiltin(const char *\fIname\fP,Sh_bltin_f \fIfn\fP,void *\fIarg\fP);
+
+unsigned int sh_isoption(int \fIoption\fP);
+unsigned int sh_onoption(int \fIoption\fP);
+unsigned int sh_offoption(int \fIoption\fP);
+
+void *sh_parse(Shell_t *\fIshp\fP, Sfio_t *\fIsp\fP, int \fIflags\fP);
+int sh_trap(const char *\fIstring\fP, int \fImode\fP);
+int sh_eval(Sfio_t *\fIsp\fP,int \fImode\fP);
+int sh_fun(Namval_t *\fIfunnode\fP, Namval_t *\fIvarnode\fP, char *\fIargv\fP[]);
+int sh_funscope(int \fIargc\fP,char *\fIargv\fP[],int(*\fIfn\fP)(void*),void *\fIarg\fP,int \fIflags\fP);
+Shscope_t *sh_getscope(int \fIindex\fP,int \fIwhence\fP);
+Shscope_t *sh_setscope(Shscope_t *\fIscope\fP);
+
+int (*sh_fdnotify(int(*\fIfn\fP)(int,int)))(int,int);
+char *sh_fmtq(const char *\fIstring\fP);
+void *sh_waitnotify(Shwait_f \fIfn\fP);
+void sh_delay(double \fIsec\fP);
+Sfio_t *sh_iogetiop(int \fIfd\fP, int \fImode\fP);
+int sh_sigcheck(void);
+.ft R
+.fi
+.PP
+.SH DESCRIPTION
+.PP
+The \fIShell\fP library is a set of functions used for
+writing extensions to \f5ksh\fP or writing commands
+that embed shell command processing.
+The include file \f5<shell.h>\fP contains the type definitions,
+function prototypes and symbolic constants defined by
+this interface. It also defines replacement definitions for
+the standard library functions
+\f5access()\fP,
+\f5close()\fP,
+\f5dup()\fP,
+\f5exit()\fP,
+\f5fcntl()\fP,
+\f5lseek()\fP,
+\f5open()\fP,
+\f5pipe()\fP,
+\f5read()\fP,
+and
+\f5write()\fP
+that must be used
+with all code
+intended to be compiled as built-in commands.
+.P
+The \f5<shell.h>\fP header includes \f5<ast.h>\fP which
+in turn includes the standard include files, \f5<stddef.h>\fP,
+\f5<stdlib.h>\fP, \f5<stdarg.h>\fP, \f5<limits.h>\fP,
+\f5<stdio.h>\fP, \f5<string.h>\fP, \f5<unistd.h>\fP,
+\f5<sys/types.h>\fP, \f5<fcntl.h>\fP, and \f5<locale.h>\fP.
+The \f5<shell.h>\fP header also includes the headers
+\f5<cdt.h>\fP,
+\f5<cmd.h>\fP,
+\f5<sfio.h>\fP,
+\f5<nval.h>\fP,
+\f5<stk.h>\fP,
+and \f5<error.h>\fP
+so that in most cases, programs only require the single
+header \f5<shell.h>\fP.
+.PP
+Programs can use this library in one of the following ways:
+.PD 0
+.TP
+.B 1
+To write builtin commands and/or other code that will be loaded
+into the shell by loading dynamic libraries
+at run time using the \f5builtin\fP(1) command.
+In this case the shell will look for a function named \f5lib_init\fP
+in your library and, if found, will execute this function with
+argument \f50\fP when the library is loaded.
+In addition, for each argument named on the \f5builtin\fP
+command line, it will look for a function named \f5b_\fP\fIname\fP\f5()\fP
+in your library and will \fIname\fP as a built-in.
+.TP
+.B 2
+To build separate a separate command that uses the shell as a
+library at compile or run time.
+In this case the \f5sh_init()\fP function must be called to
+initialize this library before any other commands in this library
+are invoked.
+The arguments \fIargc\fP and \fIargv\fP are the number
+of arguments and the vector of arguments as supplied by the shell.
+It returns a pointer the \f5Shell_t\fP.
+.TP
+.B 3
+To build a new version of \f5ksh\fP with extended capabilities,
+for example \f5tksh\fP(1).
+In this case, the user writes a \f5main()\fP function that
+calls \f5sh_main()\fP with the \fIargc\fP and \fIargv\fP arguments
+from \f5main\fP and pointer to function, \fIfn\fP as a third
+argument.. The function \fIfn\fP will
+be invoked with argument \f50\fP after \f5ksh\fP has done initialization,
+but before \f5ksh\fP has processed any start up files or executed
+any commands. The function \fIfn\fP
+will be invoked with an argument of \f51\fP before \f5ksh\fP
+begins to execute a script that has been invoked by name
+since \f5ksh\fP cleans up memory and long jumps back to
+the beginning of the shell in this case.
+The function \fIfn\fP will be called with argument \f5-1\fP before
+the shell exits.
+.PD
+.PP
+The \f5Shell_t\fP structure contains the following fields:
+.nf
+.ft 5
+ Shopt_t \fIoptions\fP; \fR/* set -o options */\fP
+ Dt_t *\fIvar_tree\fP; \fR/* shell variable dictionary */\fP
+ Dt_t *\fIfun_tree\fP; \fR/* shell function dictionary */\fP
+ Dt_t *\fIalias_tree\fP; \fR/* shell alias dictionary */\fP
+ Dt_t *\fIbltin_tree\fP; \fR/* shell built-in dictionary */\fP
+ Shscope_t *\fItopscope\fP; \fR/* pointer to top-level scope */\fP
+ char *\fIinfile_name\fP; \fR/* path name of current input file*/\fP
+ int \fIinlineno\fP; \fR/* line number of current input file*/\fP
+ int \fIexitval\fP; \fR/* most recent exit value*/\fP
+.ft R
+.fi
+This structure is returned by \f5sh_init()\fP but can also be retrieved
+by a call to \f5sh_getinterp()\fP.
+.PP
+All built-in commands to the shell are invoked with
+three arguments. The first two arguments give the
+number of arguments and the argument list
+and uses the same conventions as the \f5main()\fP function
+of a program. The third argument is a pointer that
+can be associated with each built-in.
+The \f5sh_addbuiltin()\fP function is used to add, replace or delete
+built-in commands.
+It takes the name of the built-in, \fIname\fP, a pointer
+to the function that implements the built-in, \fIfn\fP, and
+a pointer that will be passed to the function when
+it is invoked.
+If, \fIfn\fP is non-\f5NULL\fP the built-in command
+is added or replaced. Otherwise, the given
+built-in command will be deleted.
+The \fIname\fP argument can be in the format of a pathname.
+It cannot be the name of any of the special built-in commands.
+If \fIname\fP contains a \f5/\fP, the built-in is the basename of
+the pathname and the built-in will only be executed
+if the given pathname is encountered when performing
+a path search.
+When adding or replacing a built-in,
+\f5sh_addbuiltin()\fP function returns a pointer to
+the name-value pair corresponding to the built-in on success and \f5NULL\fP
+if it is unable to add or replace the built-in.
+When deleting a built-in, \f5NULL\fP is returned on success or
+if not found, and the name-value pair pointer is returned if the built-in
+cannot be deleted.
+.PP
+The functions \f5sh_onoption()\fP, \f5sh_offoption()\fP, \f5sh_isoption()\fP
+are used to set, unset, and test for shell options respectively.
+The \fIoption\fP argument can be any one of the following:
+.IP
+\f5SH_ALLEXPORT\fP:
+The \f5NV_EXPORT\fP attribute is given to each variable whose
+name is an identifier when a value is assigned.
+.IP
+\f5SH_BGNICE\fP:
+Each background process is run at a lower priority.
+.IP
+\f5SH_ERREXIT\fP:
+Causes a non-interactive shell to exit when a command,
+other than a conditional command, returns non-zero.
+.IP
+\f5SH_EMACS\fP:
+The emacs editing mode.
+.IP
+\f5SH_GMACS\fP:
+Same as the emacs editing mode except for the behavior of CONTROL-T.
+.IP
+\f5SH_HISTORY\fP:
+Indicates that the history file has been created and that
+commands can be logged.
+.IP
+\f5SH_IGNOREEOF\fP:
+Do not treat end-of-file as exit.
+.IP
+\f5SH_INTERACTIVE\fP:
+.IP
+Set for interactive shells.
+Do not set or unset this option.
+\f5SH_MARKDIRS\fP:
+A \fB/\fP is added to the end of each directory generated by pathname
+expansion.
+.IP
+\f5SH_MONITOR\fP:
+Indicates that the monitor option is enabled for job control.
+.IP
+\f5SH_NOCLOBBER\fP:
+The \fB>\fP redirection will fail if the file exists. Each file
+created with \fB>\fP will have the \f5O_EXCL\fP bit set as described
+in \f5<fcntl.h>\fP
+.IP
+\f5SH_NOGLOB\fP:
+Do not perform pathname expansion.
+.IP
+\f5SH_NOLOG\fP:
+Do not save function definitions in the history file.
+.IP
+\f5SH_NOTIFY\fP:
+Cause a message to be generated as soon as each background job completes.
+.IP
+\f5SH_NOUNSET\fP:
+Cause the shell to fail with an error of an unset variable is
+referenced.
+.IP
+\f5SH_PRIVILEGED\fP:
+.IP
+\f5SH_VERBOSE\fP:
+Cause each line to be echoed as it is read by the parser.
+.IP
+\f5SH_XTRACE\fP:
+Cause each command to be displayed after all expansions, but
+before execution.
+.IP
+\f5SH_VI\fP:
+The vi edit mode.
+.IP
+\f5SH_VIRAW\fP:
+Read character at a time rather than line at a time when
+in vi edit mode.
+.IP
+.PP
+The \f5sh_trap()\fP function can be used to compile and execute
+a string or file.
+A value of \f50\fP for \fImode\fP indicates that \fIname\fP
+refers to a string. A value of \f51\fP for \fImode\fP
+indicates that \fIname\fP is an \f5Sfio_t*\fP to an open stream.
+A value of \f52\fP for \fImode\fP indicates that \fIname\fP
+points to a parse tree that has been returned by \f5sh_parse()\fP.
+The complete file associated with the string or file
+is compiled and then executed so that aliases defined
+within the string or file will not take effect until
+the next command is executed.
+.PP
+The \f5sh_eval()\fP function executes a string or file
+stream \fIsp\fP.
+If \fImode\fP is non-zero and the history file has
+been created, the stream defined by \fIsp\fP
+will be appended to the history file as a command.
+.PP
+The \f5sh_parse()\fP function takes a pointer to the
+shell interpreter \fIshp\fP, a pointer to a string or file stream
+\fIsp\fP, and compilation flags, and returns a pointer
+to a parse tree of the compiled stream. This pointer can
+be used in subsequent calls to \f5sh_trap()\fP.
+The compilation flags can be zero or more of the following:
+.IP
+\f5SH_NL\fP:
+Treat new-lines as \fB;\fP.
+.IP
+\f5SH_EOF\fP:
+An end of file causes syntax error. By default it will
+be treated as a new-line.
+.PP
+\f5ksh\fP executes each function defined with the \f5function\fP
+reserved word in a separate scope. The \f5Shscope_t\fP type
+provides an interface to some of the information that
+is available on each scope. The structure contains
+the following public members:
+.nf
+ \f5Sh_scope_t *par_scope;\fP
+ \f5int argc;\fP
+ \f5char **argv;\fP
+ \f5char *cmdname;\fP
+ \f5Dt_t *var_tree;\fP
+.fi
+The \f5sh_getscope()\fP function can be used to the the
+scope information associated with existing scope.
+Scopes are numbered from \f50\fP for the global scope
+up to the current scope level. The \fIwhence\fP
+argument uses the symbolic constants associated with \f5lseek()\fP
+to indicate whether the \f5Iscope\fP argument is absolute,
+relative to the current scope, or relative to the topmost scope.
+The\f5sh_setscope()\fP function can be used to make a
+a known scope the current scope. It returns a pointer to the
+old current scope.
+.PP
+The \f5sh_funscope()\fP function can be used to run a function
+in a new scope. The arguments \fIargc\fP and \fIargv\fP
+are the number of arguments and the list of arguments
+respectively. If \fIfn\fP is non-\f5NULL\fP, then
+this function is invoked with \fIargc\fP, \fIargv\fP, and \fIarg\fP
+as arguments.
+.PP
+The \f5sh_fun()\fP function can be called within a
+discipline function or built-in extension to execute a
+discipline function script.
+The argument \fIfunnode\fP is a pointer to the shell function
+or built-in to execute.
+The argument \fIvarnode\fP is a pointer to the name
+value pair that has defined this discipline.
+The array \fIargv\fP is a \f5NULL\fP terminated list of
+arguments that are passed to the function.
+.PP
+By default, \f5ksh\fP only records but does not act
+on signals when running a built-in command.
+If a built-in takes a substantial amount of time
+to execute, then it should check for interrupts
+periodically by calling \f5sh_sigcheck()\fP.
+If a signal is pending, \f5sh_sigcheck()\fP will exit
+the function you are calling and return to the point
+where the most recent built-in was invoked, or where
+\f5sh_eval()\fP or \f5sh_trap()\fP was called.
+.PP
+The \f5sh_delay()\fP function is used to cause the
+shell to sleep for a period of time defined by \fIsec\fP.
+.PP
+The \f5sh_fmtq()\fP function can be used to convert a string
+into a string that is quoted so that it can be reinput
+to the shell. The quoted string returned by \f5sh_fmtq\fP
+may be returned on the current stack, so that it
+must be saved or copied.
+.PP
+The \f5sh_fdnotify()\fP function causes the function \fIfn\fP
+to be called whenever the shell duplicates or closes a file.
+It is provided for extensions that need to keep track of
+file descriptors that could be changed by shell commands.
+The function \fIfn\fP is called with two arguments.
+The first argument is the original file descriptor. The
+second argument is the new file descriptor for duplicating
+files, and \f5SH_FDCLOSE\fP when a file has been closed.
+The previously installed \f5sh_fdnotify()\fP function pointer
+is returned.
+.PP
+The \f5sh_waitnotify()\fP function causes the function \fIfn\fP
+to be called whenever the shell is waiting for input from
+a slow device or waiting for a process to complete.
+This function can process events and run shell commands
+until there is input, the timer is reached or a signal arises.
+It is called with three arguments. The first is the file
+descriptor from which the shell trying to read or \f5\-1\fP
+if the shell is waiting for a process to complete.
+The second is a timeout in milliseconds.
+A value of \f5\-1\fP for the timeout means that
+no timeout should be set.
+The third argument is 0 for input file descriptors
+and 1 for output file descriptor.
+The function needs to return a value \f5>0\fP if there
+is input on the file descriptor, and a value \f5<0\fP
+if the timeout is reached or a signal has occurred.
+A value of \f50\fP indicates
+that the function has returned without processing and that the shell
+should wait for input or process completion.
+The previous installed \f5sh_waitnotify()\fP function pointer is returned.
+.PP
+The \f5sh_iogetiop()\fP function returns a pointer to the
+Sfio stream corresponding to file descriptor number \fIfd\fP
+and the given mode \fImode\fP. The mode can be either
+\f5SF_READ\fP or \f5SF_WRITE\fP.
+The \fIfd\fP argument can the number of an open file descriptor or
+one of the following symbolic constants:
+.IP
+\f5SH_IOCOPROCESS\fP:
+The stream corresponding to the most recent co-process.
+.IP
+\f5SH_IOHISTFILE\fP:
+The stream corresponding to the history file.
+If no stream exists corresponding to \fIfd\fP or the stream
+can not be accessed in the specified mode, \f5NULL\fP is returned.
+.PP
+.SH SEE ALSO
+builtin(1)
+cdt(3)
+error(3)
+nval(3)
+sfio(3)
+stk(3)
+tksh(1)
+.PP
+.SH AUTHOR
+David G. Korn (dgk@research.att.com).
+
diff --git a/usr/src/lib/libshell/common/tests/alias.sh b/usr/src/lib/libshell/common/tests/alias.sh
new file mode 100644
index 0000000000..bf7f17f5f6
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/alias.sh
@@ -0,0 +1,83 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+integer Errors=0
+alias foo='print hello'
+if [[ $(foo) != hello ]]
+then err_exit 'foo, where foo is alias for "print hello" failed'
+fi
+if [[ $(foo world) != 'hello world' ]]
+then err_exit 'foo world, where foo is alias for "print hello" failed'
+fi
+alias foo='print hello '
+alias bar=world
+if [[ $(foo bar) != 'hello world' ]]
+then err_exit 'foo bar, where foo is alias for "print hello " failed'
+fi
+if [[ $(foo \bar) != 'hello bar' ]]
+then err_exit 'foo \bar, where foo is alias for "print hello " failed'
+fi
+alias bar='foo world'
+if [[ $(bar) != 'hello world' ]]
+then err_exit 'bar, where bar is alias for "foo world" failed'
+fi
+if [[ $(alias bar) != "bar='foo world'" ]]
+then err_exit 'alias bar, where bar is alias for "foo world" failed'
+fi
+unalias foo || err_exit "unalias foo failed"
+alias foo 2> /dev/null && err_exit "alias for non-existent alias foo returns true"
+unset bar
+alias bar="print foo$bar"
+bar=bar
+if [[ $(bar) != foo ]]
+then err_exit 'alias bar, where bar is alias for "print foo$bar" failed'
+fi
+unset bar
+alias bar='print hello'
+if [[ $bar != '' ]]
+then err_exit 'alias bar cause variable bar to be set'
+fi
+alias !!=print
+if [[ $(!! hello 2>/dev/null) != hello ]]
+then err_exit 'alias for !!=print not working'
+fi
+alias foo=echo
+if [[ $(print "$(foo bar)" ) != bar ]]
+then err_exit 'alias in command substitution not working'
+fi
+( unalias foo)
+if [[ $(foo bar 2> /dev/null) != bar ]]
+then err_exit 'alias not working after unalias in subshell'
+fi
+builtin -d rm 2> /dev/null
+if whence rm > /dev/null
+then [[ ! $(alias -t | grep rm= ) ]] && err_exit 'tracked alias not set'
+ PATH=$PATH
+ [[ $(alias -t | grep rm= ) ]] && err_exit 'tracked alias not cleared'
+fi
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/append.sh b/usr/src/lib/libshell/common/tests/append.sh
new file mode 100644
index 0000000000..7f3cad6021
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/append.sh
@@ -0,0 +1,72 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+integer Errors=0
+{
+x=abc
+x+=def ;} 2> /dev/null
+if [[ $x != abcdef ]]
+then err_exit 'abc+def != abcdef'
+fi
+integer i=3
+{ i+=4;} 2> /dev/null
+if (( i != 7 ))
+then err_exit '3+4!=7'
+fi
+iarray=( one two three )
+{ iarray+= (four five six) ;} 2> /dev/null
+if [[ ${iarray[@]} != 'one two three four five six' ]]
+then err_exit 'index array append fails'
+fi
+unset iarray
+iarray=one
+{ iarray+= (four five six) ;} 2> /dev/null
+if [[ ${iarray[@]} != 'one four five six' ]]
+then err_exit 'index array append to scalar fails'
+fi
+typeset -A aarray
+aarray=( [1]=1 [3]=4 [xyz]=xyz )
+aarray+=( [2]=2 [3]=3 [foo]=bar )
+if [[ ${aarray[3]} != 3 ]]
+then err_exit 'associative array append fails'
+fi
+if [[ ${#aarray[@]} != 5 ]]
+then err_exit 'number of elements of associative array append fails'
+fi
+point=(x=1 y=2)
+point+=( y=3 z=4)
+if [[ ${point.y} != 3 ]]
+then err_exit 'compound append fails'
+fi
+unset foo
+foo=one
+foo+=(two)
+if [[ ${foo[@]} != 'one two' ]]
+then err_exit 'array append to non array variable fails'
+fi
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/arith.sh b/usr/src/lib/libshell/common/tests/arith.sh
new file mode 100644
index 0000000000..ec3ada5df1
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/arith.sh
@@ -0,0 +1,466 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+trap '' FPE # NOTE: osf.alpha requires this (no ieee math)
+integer Errors=0
+integer x=1 y=2 z=3
+if (( 2+2 != 4 ))
+then err_exit 2+2!=4
+fi
+if ((x+y!=z))
+then err_exit x+y!=z
+fi
+if (($x+$y!=$z))
+then err_exit $x+$y!=$z
+fi
+if (((x|y)!=z))
+then err_exit "(x|y)!=z"
+fi
+if ((y >= z))
+then err_exit "y>=z"
+fi
+if ((y+3 != z+2))
+then err_exit "y+3!=z+2"
+fi
+if ((y<<2 != 1<<3))
+then err_exit "y<<2!=1<<3"
+fi
+if ((133%10 != 3))
+then err_exit "133%10!=3"
+ if (( 2.5 != 2.5 ))
+ then err_exit 2.5!=2.5
+ fi
+fi
+d=0
+((d || 1)) || err_exit 'd=0; ((d||1))'
+if (( d++!=0))
+then err_exit "d++!=0"
+fi
+if (( --d!=0))
+then err_exit "--d!=0"
+fi
+if (( (d++,6)!=6 && d!=1))
+then err_exit '(d++,6)!=6 && d!=1'
+fi
+d=0
+if (( (1?2+1:3*4+d++)!=3 || d!=0))
+then err_exit '(1?2+1:3*4+d++) !=3'
+fi
+for ((i=0; i < 20; i++))
+do :
+done
+if (( i != 20))
+then err_exit 'for (( expr)) failed'
+fi
+for ((i=0; i < 20; i++)); do : ; done
+if (( i != 20))
+then err_exit 'for (( expr));... failed'
+fi
+for ((i=0; i < 20; i++)) do : ; done
+if (( i != 20))
+then err_exit 'for (( expr))... failed'
+fi
+if (( (i?0:1) ))
+then err_exit '(( (i?0:1) )) failed'
+fi
+if (( (1 || 1 && 0) != 1 ))
+then err_exit '( (1 || 1 && 0) != 1) failed'
+fi
+if (( (_=1)+(_x=0)-_ ))
+then err_exit '(_=1)+(_x=0)-_ failed'
+fi
+if (( (3^6) != 5))
+then err_exit '((3^6) != 5) failed'
+fi
+integer x=1
+if (( (x=-x) != -1 ))
+then err_exit '(x=-x) != -1 failed'
+fi
+i=2
+if (( 1$(($i))3 != 123 ))
+then err_exit ' 1$(($i))3 failed'
+fi
+((pi=4*atan(1.)))
+point=(
+ float x
+ float y
+)
+(( point.x = cos(pi/6), point.y = sin(pi/6) ))
+if (( point.x*point.x + point.y*point.y > 1.01 ))
+then err_exit 'cos*cos +sin*sin > 1.01'
+fi
+if (( point.x*point.x + point.y*point.y < .99 ))
+then err_exit 'cos*cos +sin*sin < .99'
+fi
+if [[ $((y=x=1.5)) != 1 ]]
+then err_exit 'typecast not working in arithmetic evaluation'
+fi
+typeset -E x=1.5
+( ((x++)) ) 2>/dev/null
+if [[ $? == 0 ]]
+then err_exit 'postincrement of floating point allowed'
+fi
+( ((++x)) ) 2>/dev/null
+if [[ $? == 0 ]]
+then err_exit 'preincrement of floating point allowed'
+fi
+x=1.5
+( ((x%1.1)) ) 2>/dev/null
+if [[ $? == 0 ]]
+then err_exit 'floating point allowed with % operator'
+fi
+x=.125
+if [[ $(( 4 * x/2 )) != 0.25 ]]
+then err_exit '(( 4 * x/2 )) is not 0.25, with x=.125'
+fi
+if [[ $(( pow(2,3) )) != 8 ]]
+then err_exit '$(( pow(2,3) )) != 8'
+fi
+( [[ $(( pow(2,(3)) )) == 8 ]] ) 2> /dev/null
+if (( $? ))
+then err_exit '$(( pow(2,(3)) )) != 8'
+fi
+unset x
+integer x=1; integer x=1
+if [[ $x != 1 ]]
+then err_exit 'two consecutive integer x=1 not working'
+fi
+unset z
+{ z=$(typeset -RZ2 z2; (( z2 = 8 )); print $z2) ;} 2>/dev/null
+if [[ $z != "08" ]]
+then err_exit "typeset -RZ2 leading 0 decimal not working [z=$z]"
+fi
+{ z=$(typeset -RZ3 z3; (( z3 = 8 )); print $z3) ;} 2>/dev/null
+if [[ $z != "008" ]]
+then err_exit "typeset -RZ3 leading 0 decimal not working [z=$z]"
+fi
+unset z
+typeset -Z3 z=010
+(( z=z+1))
+if [[ $z != 011 ]]
+then err_exit "leading 0's in -Z not treated as decimal"
+fi
+unset x
+integer x=0
+if [[ $((x+=1)) != 1 ]] || ((x!=1))
+then err_exit "+= not working"
+ x=1
+fi
+x=1
+if [[ $((x*=5)) != 5 ]] || ((x!=5))
+then err_exit "*= not working"
+ x=5
+fi
+if [[ $((x%=4)) != 1 ]] || ((x!=1))
+then err_exit "%= not working"
+ x=1
+fi
+if [[ $((x|=6)) != 7 ]] || ((x!=7))
+then err_exit "|= not working"
+ x=7
+fi
+if [[ $((x&=5)) != 5 ]] || ((x!=5))
+then err_exit "&= not working"
+ x=5
+fi
+function newscope
+{
+ float x=1.5
+ (( x += 1 ))
+ print -r -- $x
+}
+if [[ $(newscope) != 2.5 ]]
+then err_exit "arithmetic using wrong scope"
+fi
+unset x
+integer y[3]=9 y[4]=2 i=3
+(( x = y[3] + y[4] ))
+if [[ $x != 11 ]]
+then err_exit "constant index array arithmetic failure"
+fi
+(( x = $empty y[3] + y[4] ))
+if [[ $x != 11 ]]
+then err_exit "empty constant index array arithmetic failure"
+fi
+(( x = y[i] + y[i+1] ))
+if [[ $x != 11 ]]
+then err_exit "variable subscript index array arithmetic failure"
+fi
+integer a[5]=3 a[2]=4
+(( x = y[a[5]] + y[a[2]] ))
+if [[ $x != 11 ]]
+then err_exit "nested subscript index array arithmetic failure"
+fi
+unset y
+typeset -Ai y
+y[three]=9 y[four]=2
+three=four
+four=three
+(( x = y[three] + y[four] ))
+if [[ $x != 11 ]]
+then err_exit "constant associative array arithmetic failure"
+fi
+(( x = y[$three] + y[$four] ))
+if [[ $x != 11 ]]
+then err_exit "variable subscript associative array arithmetic failure"
+fi
+$SHELL -nc '((a = 1))' 2> /dev/null || err_exit "sh -n fails with arithmetic"
+$SHELL -nc '((a.b++))' 2> /dev/null || err_exit "sh -n fails with arithmetic2"
+unset z
+float z=7.5
+if { (( z%2 != 1));} 2> /dev/null
+then err_exit '% not working on floating point'
+fi
+chr=(a ' ' '=' '\r' '\n' '\\' '\"' '$' "\\'" '[' ']' '(' ')' '<' '\xab' '\040' '`' '{' '}' '*' '\E')
+if (('a' == 97))
+then val=(97 32 61 13 10 92 34 36 39 91 93 40 41 60 171 32 96 123 125 42 27)
+else val=(129 64 126 13 21 224 127 91 125 173 189 77 93 76 171 32 121 192 208 92 39 21)
+fi
+q=0
+for ((i=0; i < ${#chr[@]}; i++))
+do if (( '${chr[i]}' != ${val[i]} ))
+ then err_exit "(( '${chr[i]}' != ${val[i]} ))"
+ fi
+ if [[ $(( '${chr[i]}' )) != ${val[i]} ]]
+ then err_exit "(( '${chr[i]}' )) != ${val[i]}"
+ fi
+ if [[ $(( L'${chr[i]}' )) != ${val[i]} ]]
+ then err_exit "(( '${chr[i]}' )) != ${val[i]}"
+ fi
+ if eval '((' "'${chr[i]}'" != ${val[i]} '))'
+ then err_exit "eval (( '${chr[i]}' != ${val[i]} ))"
+ fi
+ if eval '((' "'${chr[i]}'" != ${val[i]} ' + $q ))'
+ then err_exit "eval (( '${chr[i]}' != ${val[i]} ))"
+ fi
+done
+unset x
+typeset -ui x=4294967293
+[[ $x != 4294967293 ]] && err_exit "unsigned integers not working"
+x=32767
+x=x+1
+[[ $x != 32768 ]] && err_exit "unsigned integer addition not working"
+unset x
+float x=99999999999999999999999999
+if (( x < 1e20 ))
+then err_exit 'large integer constants not working'
+fi
+unset x y
+function foobar
+{
+ nameref x=$1
+ (( x +=1 ))
+ print $x
+}
+x=0 y=4
+if [[ $(foobar y) != 5 ]]
+then err_exit 'name references in arithmetic statements in functions broken'
+fi
+if (( 2**3 != pow(2,3) ))
+then err_exit '2**3 not working'
+fi
+if (( 2**3*2 != pow(2,3)*2 ))
+then err_exit '2**3*2 not working'
+fi
+if (( 4**3**2 != pow(4,pow(3,2)) ))
+then err_exit '4**3**2 not working'
+fi
+if (( (4**3)**2 != pow(pow(4,3),2) ))
+then err_exit '(4**3)**2 not working'
+fi
+typeset -Z3 x=11
+typeset -i x
+if (( x != 11 ))
+then err_exit '-Z3 not treated as decimal'
+fi
+unset x
+typeset -ui x=-1
+(( x >= 0 )) || err_exit 'unsigned integer not working'
+(( $x >= 0 )) || err_exit 'unsigned integer not working as $x'
+unset x
+typeset -ui42 x=50
+if [[ $x != 42#18 ]]
+then err_exit 'display of unsigned integers in non-decimal bases wrong'
+fi
+$SHELL -c 'i=0;(( ofiles[i] != -1 && (ofiles[i] < mins || mins == -1) ));exit 0' 2> /dev/null || err_exit 'lexical error with arithemtic expression'
+rm -f core
+$SHELL -c '(( +1 == 1))' 2> /dev/null || err_exit 'unary + not working'
+typeset -E20 val=123.01234567890
+[[ $val == 123.0123456789 ]] || err_exit "rounding error val=$val"
+if [[ $(print x$((10))=foo) != x10=foo ]]
+then err_exit 'parsing error with x$((10))=foo'
+fi
+$SHELL -c 'typeset x$((10))=foo' 2> /dev/null || err_exit 'typeset x$((10)) parse error'
+unset x
+x=$(( exp(log(2.0)) ))
+(( x > 1.999 && x < 2.001 )) || err_exit 'composite functions not working'
+unset x y n
+typeset -Z8 x=0 y=0
+integer n
+for (( n=0; n < 20; n++ ))
+do let "x = $x+1"
+ (( y = $y+1 ))
+done
+(( x == n )) || err_exit 'let with zero filled fields not working'
+(( y == n )) || err_exit '((...)) with zero filled fields not working'
+typeset -LZ3 x=10
+[[ $(($x)) == 10 && $((1$x)) == 1010 ]] || err_exit 'zero filled fields not preserving leading zeros'
+unset y
+[[ $(let y=$x;print $y) == 10 && $(let y=1$x;print $y) == 1010 ]] || err_exit 'zero filled fields not preserving leading zeros with let'
+unset i ip ipx
+typeset -i hex=( 172 30 18 1)
+typeset -iu ip=0 ipx=0
+integer i
+for ((i=0; i < 4; i++))
+do (( ip = (ip<<8) | hex[i]))
+done
+for ((i=0; i < 4; i++))
+do (( ipx = ip % 256 ))
+ (( ip /= 256 ))
+ (( ipx != hex[3-i] )) && err_exit "hex digit $((3-i)) not correct"
+done
+unset x
+x=010
+(( x == 8 )) || err_exit 'leading zeros not treated as octal arithmetic'
+(( $x == 8 )) || err_exit 'leading zeros not treated as octal arithmetic with $x'
+unset x
+typeset -Z x=010
+(( x == 10 )) || err_exit 'leading zeros not ignored for arithmetic'
+(( $x == 10 )) || err_exit 'leading zeros not ignored for arithmetic with $x'
+typeset -i i=x
+(( i == 10 )) || err_exit 'leading zeros not ignored for arithmetic assignment'
+(( ${x:0:1} == 0 )) || err_exit 'leading zero should not be stripped for x:a:b'
+c010=3
+(( c$x == 3 )) || err_exit 'leading zero with variable should not be stripped'
+[[ $( ($SHELL -c '((++1))' 2>&1)2>/dev/null ) == *lvalue* ]] || err_exit "((--1)) not generating error message"
+i=2
+(( "22" == 22 )) || err_exit "double quoted constants fail"
+(( "2$i" == 22 )) || err_exit "double quoted variables fail"
+(( "18+$i+2" == 22 )) || err_exit "double quoted expressions fail"
+# 04-04-28 bug fix
+unset i; typeset -i i=01-2
+(( i == -1 )) || err_exit "01-2 is not -1"
+
+trap 'rm -f /tmp/script$$ /tmp/data$$.[12]' EXIT
+cat > /tmp/script$$ <<-\!
+tests=$*
+typeset -A blop
+function blop.get
+{
+ .sh.value=777
+}
+function mkobj
+{
+ nameref obj=$1
+ obj=()
+ [[ $tests == *1* ]] && {
+ (( obj.foo = 1 ))
+ (( obj.bar = 2 ))
+ (( obj.baz = obj.foo + obj.bar )) # ok
+ echo $obj
+ }
+ [[ $tests == *2* ]] && {
+ (( obj.faz = faz = obj.foo + obj.bar )) # ok
+ echo $obj
+ }
+ [[ $tests == *3* ]] && {
+ # case 3, 'active' variable involved, w/ intermediate variable
+ (( obj.foz = foz = ${blop[1]} )) # coredump
+ echo $obj
+ }
+ [[ $tests == *4* ]] && {
+ # case 4, 'active' variable, in two steps
+ (( foz = ${blop[1]} )) # ok
+ (( obj.foz = foz )) # ok
+ echo $obj
+ }
+ [[ $tests == *5* ]] && {
+ # case 5, 'active' variable involved, w/o intermediate variable
+ (( obj.fuz = ${blop[1]} )) # coredump
+ echo $obj
+ }
+ [[ $tests == *6* ]] && {
+ echo $(( obj.baz = obj.foo + obj.bar )) # coredump
+ }
+ [[ $tests == *7* ]] && {
+ echo $(( obj.foo + obj.bar )) # coredump
+ }
+}
+mkobj bla
+!
+chmod +x /tmp/script$$
+[[ $(/tmp/script$$ 1) != '( bar=2 baz=3 foo=1 )' ]] 2>/dev/null && err_exit 'compound var arithmetic failed'
+[[ $(/tmp/script$$ 2) != '( faz=0 )' ]] 2>/dev/null && err_exit 'compound var arithmetic failed'
+[[ $(/tmp/script$$ 3) != '( foz=777 )' ]] 2>/dev/null && err_exit 'compound var arithmetic failed'
+[[ $(/tmp/script$$ 4) != '( foz=777 )' ]] 2>/dev/null && err_exit 'compound var arithmetic failed'
+[[ $(/tmp/script$$ 5) != '( fuz=777 )' ]] 2>/dev/null && err_exit 'compound var arithmetic failed'
+[[ $(/tmp/script$$ 6) != '0' ]] 2>/dev/null && err_exit 'compound var arithmetic failed'
+[[ $(/tmp/script$$ 7) != '0' ]] 2>/dev/null && err_exit 'compound var arithmetic failed'
+unset foo
+typeset -F1 foo=123456789.19
+[[ $foo == 123456789.2 ]] || err_exit 'typeset -F1 not working correctly'
+
+# divide by zero
+
+for expr in '1/(1/2)' '8%(1/2)' '8%(1.0/2)'
+do [[ $( ( $SHELL -c "( (($expr)) ) || print ok" ) 2>/dev/null ) == ok ]] || err_exit "divide by zero not trapped: $expr"
+done
+
+for expr in '1/(1.0/2)' '1/(1/2.0)'
+do [[ $( ( $SHELL -c "( print -r -- \$(($expr)) )" ) 2>/dev/null ) == 2 ]] || err_exit "invalid value for: $expr"
+done
+[[ $((5||0)) == 1 ]] || err_exit '$((5||0))'" == $((5||0)) should be 1"
+$SHELL -c 'integer x=3 y=2; (( (y += x += 2) == 7 && x==5))' 2> /dev/null || err_exit '((y += x += 2)) not working'
+$SHELL -c 'b=0; [[ $((b?a=1:b=9)) == 9 ]]' 2> /dev/null || err_exit 'b?a=1:b=9 not working'
+unset x
+(( x = 4*atan(1.0) ))
+[[ $x == "$((x))" ]] || err_exit '$x !- $((x)) when x is pi'
+$SHELL -c "[[ ${x//./} == {14,100}(\d) ]]" 2> /dev/null || err_exit 'pi has less than 14 significant places'
+if (( Inf+1 == Inf ))
+then [[ $(printf "%g\n" $((Inf))) == inf ]] || err_exit 'printf "%g\n" $((Inf)) fails'
+# [[ $(printf "%g\n" $((Nan))) == inf ]] || err_exit 'printf "%g\n" $((Nan)) fails'
+ [[ $(printf "%g\n" Inf) == inf ]] || err_exit 'printf "%g\n" Inf fails'
+ [[ $(printf "%g\n" NaN) == nan ]] || err_exit 'printf "%g\n" NaN fails'
+ [[ $(print -- $((Inf))) == inf ]] || err_exit 'print -- $((Inf)) fails'
+ (( 1.0/0.0 == Inf )) || err_exit '1.0/0.0 != Inf'
+ [[ $(print -- $((0.0/0.0))) == nan ]] || err_exit '0.0/0.0 != NaN'
+ (( Inf*Inf == Inf )) || err_exit 'Inf*Inf != Inf'
+ (( NaN != NaN )) || err_exit 'NaN == NaN'
+ (( -5*Inf == -Inf )) || err_exit '-5*Inf != -Inf'
+ [[ $(print -- $((sqrt(-1.0)))) == nan ]]|| err_exit 'sqrt(-1.0) != NaN'
+ (( pow(1.0,Inf) == 1.0 )) || err_exit 'pow(1.0,Inf) != 1.0'
+ (( pow(Inf,0.0) == 1.0 )) || err_exit 'pow(Inf,0.0) != 1.0'
+ [[ $(print -- $((NaN/Inf))) == nan ]] || err_exit 'NaN/Inf != NaN'
+ (( 4.0/Inf == 0.0 )) || err_exit '4.0/Inf != 0.0'
+else err_exit 'Inf and NaN not working'
+fi
+unset x y
+float x=14.555 y
+y=$(printf "%a" x)
+(( x == y )) || err_exit "output of printf %a not self preserving -- expected $x, got $y"
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/arrays.sh b/usr/src/lib/libshell/common/tests/arrays.sh
new file mode 100644
index 0000000000..7dd09fca0f
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/arrays.sh
@@ -0,0 +1,381 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+function fun
+{
+ integer i
+ unset xxx
+ for i in 0 1
+ do xxx[$i]=$i
+ done
+}
+
+Command=${0##*/}
+integer Errors=0
+set -A x zero one two three four 'five six'
+if [[ $x != zero ]]
+then err_exit '$x is not element 0'
+fi
+if [[ ${x[0]} != zero ]]
+then err_exit '${x[0] is not element 0'
+fi
+if (( ${#x[0]} != 4 ))
+then err_exit "length of ${x[0]} is not 4"
+fi
+if (( ${#x[@]} != 6 ))
+then err_exit 'number of elements of x is not 6'
+fi
+if [[ ${x[2]} != two ]]
+then err_exit ' element two is not 2'
+fi
+if [[ ${x[@]:2:1} != two ]]
+then err_exit ' ${x[@]:2:1} is not two'
+fi
+set -A y -- ${x[*]}
+if [[ $y != zero ]]
+then err_exit '$x is not element 0'
+fi
+if [[ ${y[0]} != zero ]]
+then err_exit '${y[0] is not element 0'
+fi
+if (( ${#y[@]} != 7 ))
+then err_exit 'number of elements of y is not 7'
+fi
+if [[ ${y[2]} != two ]]
+then err_exit ' element two is not 2'
+fi
+set +A y nine ten
+if [[ ${y[2]} != two ]]
+then err_exit ' element two is not 2'
+fi
+if [[ ${y[0]} != nine ]]
+then err_exit '${y[0] is not nine'
+fi
+unset y[4]
+if (( ${#y[@]} != 6 ))
+then err_exit 'number of elements of y is not 6'
+fi
+if (( ${#y[4]} != 0 ))
+then err_exit 'string length of unset element is not 0'
+fi
+unset foo
+if (( ${#foo[@]} != 0 ))
+then err_exit 'number of elements of unset variable foo is not 0'
+fi
+foo=''
+if (( ${#foo[0]} != 0 ))
+then err_exit 'string length of null element is not 0'
+fi
+if (( ${#foo[@]} != 1 ))
+then err_exit 'number of elements of null variable foo is not 1'
+fi
+unset foo
+foo[0]=foo
+foo[3]=bar
+unset foo[0]
+unset foo[3]
+if (( ${#foo[@]} != 0 ))
+then err_exit 'number of elements of left in variable foo is not 0'
+fi
+unset foo
+foo[3]=bar
+foo[0]=foo
+unset foo[3]
+unset foo[0]
+if (( ${#foo[@]} != 0 ))
+then err_exit 'number of elements of left in variable foo again is not 0'
+fi
+fun
+if (( ${#xxx[@]} != 2 ))
+then err_exit 'number of elements of left in variable xxx is not 2'
+fi
+fun
+if (( ${#xxx[@]} != 2 ))
+then err_exit 'number of elements of left in variable xxx again is not 2'
+fi
+set -A foo -- "${x[@]}"
+if (( ${#foo[@]} != 6 ))
+then err_exit 'number of elements of foo is not 6'
+fi
+if (( ${#PWD[@]} != 1 ))
+then err_exit 'number of elements of PWD is not 1'
+fi
+unset x
+x[2]=foo x[4]=bar
+if (( ${#x[@]} != 2 ))
+then err_exit 'number of elements of x is not 2'
+fi
+s[1]=1 c[1]=foo
+if [[ ${c[s[1]]} != foo ]]
+then err_exit 'c[1]=foo s[1]=1; ${c[s[1]]} != foo'
+fi
+unset s
+typeset -Ai s
+y=* z=[
+s[$y]=1
+s[$z]=2
+if (( ${#s[@]} != 2 ))
+then err_exit 'number of elements of is not 2'
+fi
+(( s[$z] = s[$z] + ${s[$y]} ))
+if [[ ${s[$z]} != 3 ]]
+then err_exit '[[ ${s[$z]} != 3 ]]'
+fi
+if (( s[$z] != 3 ))
+then err_exit '(( s[$z] != 3 ))'
+fi
+(( s[$y] = s[$y] + ${s[$z]} ))
+if [[ ${s[$y]} != 4 ]]
+then err_exit '[[ ${s[$y]} != 4 ]]'
+fi
+if (( s[$y] != 4 ))
+then err_exit '(( s[$y] != 4 ))'
+fi
+unset y
+set -A y 2 4 6
+typeset -i y
+z=${y[@]}
+typeset -R12 y
+typeset -i y
+if [[ ${y[@]} != "$z" ]]
+then err_exit 'error in array conversion from int to R12'
+fi
+if (( ${#y[@]} != 3 ))
+then err_exit 'error in count of array conversion from int to R12'
+fi
+unset abcdefg
+: ${abcdefg[1]}
+set | grep '^abcdefg$' >/dev/null && err_exit 'empty array variable in set list'
+unset x y
+x=1
+typeset -i y[$x]=4
+if [[ ${y[1]} != 4 ]]
+then err_exit 'arithmetic expressions in typeset not working'
+fi
+unset foo
+typeset foo=bar
+typeset -A foo
+if [[ ${foo[0]} != bar ]]
+then err_exit 'initial value not preserved when typecast to associative'
+fi
+unset foo
+foo=(one two)
+typeset -A foo
+foo[two]=3
+if [[ ${#foo[*]} != 3 ]]
+then err_exit 'conversion of indexed to associative array failed'
+fi
+set a b c d e f g h i j k l m
+if [[ ${#} != 13 ]]
+then err_exit '${#} not 13'
+fi
+unset xxx
+xxx=foo
+if [[ ${!xxx[@]} != 0 ]]
+then err_exit '${!xxx[@]} for scalar not 0'
+fi
+if [[ ${11} != k ]]
+then err_exit '${11} not working'
+fi
+if [[ ${@:4:1} != d ]]
+then err_exit '${@:4:1} not working'
+fi
+foovar1=abc
+foovar2=def
+if [[ ${!foovar@} != +(foovar[[:alnum:]]?([ ])) ]]
+then err_exit '${!foovar@} does not expand correctly'
+fi
+if [[ ${!foovar1} != foovar1 ]]
+then err_exit '${!foovar1} != foovar1'
+fi
+unset xxx
+: ${xxx[3]}
+if [[ ${!xxx[@]} ]]
+then err_exit '${!xxx[@]} should be null'
+fi
+integer i=0
+{
+ set -x
+ xxx[++i]=1
+ set +x
+} 2> /dev/null
+if (( i != 1))
+then err_exit 'execution trace side effects with array subscripts'
+fi
+unset list
+: $(set -A list foo bar)
+if (( ${#list[@]} != 0))
+then err_exit '$(set -A list ...) leaves side effects'
+fi
+unset list
+list= (foo bar bam)
+( set -A list one two three four)
+if [[ ${list[1]} != bar ]]
+then err_exit 'array not restored after subshell'
+fi
+XPATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:.:/sbin:/usr/sbin
+xpath=( $( IFS=: ; echo $XPATH ) )
+if [[ $(print -r "${xpath[@]##*/}") != 'bin bin ucb bin . sbin sbin' ]]
+then err_exit '${xpath[@]##*/} not applied to each element'
+fi
+foo=( zero one '' three four '' six)
+integer n=-1
+if [[ ${foo[@]:n} != six ]]
+then err_exit 'array offset of -1 not working'
+fi
+if [[ ${foo[@]: -3:1} != four ]]
+then err_exit 'array offset of -3:1 not working'
+fi
+$SHELL -c 'x=(if then else fi)' 2> /dev/null || err_exit 'reserved words in x=() assignment not working'
+unset foo
+foo=one
+foo=( $foo two)
+if [[ ${#foo[@]} != 2 ]]
+then err_exit 'array getting unset before right hand side evaluation'
+fi
+foo=(143 3643 38732)
+export foo
+typeset -i foo
+if [[ $($SHELL -c 'print $foo') != 143 ]]
+then err_exit 'exporting indexed array not exporting 0-th element'
+fi
+( $SHELL -c '
+ unset foo
+ typeset -A foo=([0]=143 [1]=3643 [2]=38732)
+ export foo
+ typeset -i foo
+ [[ $($SHELL -c "print $foo") == 143 ]]'
+) 2> /dev/null ||
+ err_exit 'exporting associative array not exporting 0-th element'
+unset foo
+typeset -A foo
+foo[$((10))]=ok 2> /dev/null || err_exit 'arithmetic expression as subscript not working'
+unset foo
+typeset -A foo
+integer foo=0
+[[ $foo == 0 ]] || err_exit 'zero element of associative array not being set'
+unset foo
+typeset -A foo=( [two]=1)
+for i in one three four five
+do : ${foo[$i]}
+done
+if [[ ${!foo[@]} != two ]]
+then err_exit 'Error in subscript names'
+fi
+unset x
+x=( 1 2 3)
+(x[1]=8)
+[[ ${x[1]} == 2 ]] || err_exit 'index array produce side effects in subshells'
+x=( 1 2 3)
+(
+ x+=(8)
+ [[ ${#x[@]} == 4 ]] || err_exit 'index array append in subshell error'
+)
+[[ ${#x[@]} == 3 ]] || err_exit 'index array append in subshell effects parent'
+x=( [one]=1 [two]=2 [three]=3)
+(x[two]=8)
+[[ ${x[two]} == 2 ]] || err_exit 'associative array produce side effects in subshells'
+unset x
+x=( [one]=1 [two]=2 [three]=3)
+(
+ x+=( [four]=4 )
+ [[ ${#x[@]} == 4 ]] || err_exit 'associative array append in subshell error'
+)
+[[ ${#x[@]} == 3 ]] || err_exit 'associative array append in subshell effects parent'
+unset x
+integer i
+for ((i=0; i < 40; i++))
+do x[i]=$i
+done
+[[ ${#x[@]} == 40 ]] || err_exit 'index arrays loosing values'
+[[ $( ($SHELL -c 'typeset -A var; (IFS=: ; set -A var a:b:c ;print ${var[@]});:' )2>/dev/null) == 'a b c' ]] || err_exit 'change associative to index failed'
+unset foo
+[[ $(foo=good
+for ((i=0; i < 2; i++))
+do [[ ${foo[i]} ]] && print ok
+done) == ok ]] || err_exit 'invalid optimization for subscripted variables'
+(
+x=([foo]=bar)
+set +A x bam
+) 2> /dev/null && err_exit 'set +A with associative array should be an error'
+unset bam foo
+foo=0
+typeset -A bam
+unset bam[foo]
+bam[foo]=value
+[[ $bam == value ]] && err_exit 'unset associative array element error'
+: only first element of an array can be exported
+unset bam
+trap 'rm -f /tmp/sharr$$' EXIT
+print 'print ${var[0]} ${var[1]}' > /tmp/sharr$$
+chmod +x /tmp/sharr$$
+[[ $($SHELL -c "var=(foo bar);export var;/tmp/sharr$$") == foo ]] || err_exit 'export array not exporting just first element'
+unset foo
+set -o allexport
+foo=one
+foo[1]=two
+foo[0]=three
+[[ $foo == three ]] || err_exit 'export all not working with arrays'
+cat > /tmp/sharr$$ <<- \!
+ typeset -A foo
+ print foo${foo[abc]}
+!
+# 04-05-24 bug fix
+unset foo
+[[ $($SHELL -c "typeset -A foo;/tmp/sharr$$") == foo ]] 2> /dev/null || err_exit 'empty associative arrays not being cleared correctly before scripts'
+[[ $($SHELL -c "typeset -A foo;foo[abc]=abc;/tmp/sharr$$") == foo ]] 2> /dev/null || err_exit 'associative arrays not being cleared correctly before scripts'
+unset foo
+foo=(one two)
+[[ ${foo[@]:1} == two ]] || err_exit '${foo[@]:1} == two'
+[[ ! ${foo[@]:2} ]] || err_exit '${foo[@]:2} not null'
+unset foo
+foo=one
+[[ ! ${foo[@]:1} ]] || err_exit '${foo[@]:1} not null'
+function EMPTY
+{
+ typeset i
+ typeset -n ARRAY=$1
+ for i in ${!ARRAY[@]}
+ do unset ARRAY[$i]
+ done
+}
+unset foo
+typeset -A foo
+foo[bar]=bam
+foo[x]=y
+EMPTY foo
+[[ $(typeset | grep foo$) == *associative* ]] || err_exit 'array lost associative attribute'
+[[ ! ${foo[@]} ]] || err_exit 'array not empty'
+[[ ! ${!foo[@]} ]] || err_exit 'array names not empty'
+unset foo
+foo=bar
+set -- "${foo[@]:1}"
+(( $# == 0 )) || err_exit '${foo[@]:1} should not have any values'
+unset bar
+: ${_foo[bar=4]}
+(( bar == 4 )) || err_exit 'subscript of unset variable not evaluated'
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/attributes.sh b/usr/src/lib/libshell/common/tests/attributes.sh
new file mode 100644
index 0000000000..8be16f1d42
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/attributes.sh
@@ -0,0 +1,216 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+integer Errors=0
+r=readonly u=Uppercase l=Lowercase i=22 i8=10 L=abc L5=def uL5=abcdef xi=20
+x=export t=tagged H=hostname LZ5=026 RZ5=026 Z5=123 lR5=ABcdef R5=def n=l
+for option in u l i i8 L L5 LZ5 RZ5 Z5 r x H t R5 uL5 lR5 xi n
+do typeset -$option $option
+done
+(r=newval) 2> /dev/null && err_exit readonly attribute fails
+i=i+5
+if ((i != 27))
+then err_exit integer attributes fails
+fi
+if [[ $i8 != 8#12 ]]
+then err_exit integer base 8 fails
+fi
+if [[ $u != UPPERCASE ]]
+then err_exit uppercase fails
+fi
+if [[ $l != lowercase ]]
+then err_exit lowercase fails
+fi
+if [[ $n != lowercase ]]
+then err_exit reference variables fail
+fi
+if [[ t=tagged != $(typeset -t) ]]
+then err_exit tagged fails
+fi
+if [[ t != $(typeset +t) ]]
+then err_exit tagged fails
+fi
+if [[ $Z5 != 00123 ]]
+then err_exit zerofill fails
+fi
+if [[ $RZ5 != 00026 ]]
+then err_exit right zerofill fails
+fi
+L=12345
+if [[ $L != 123 ]]
+then err_exit leftjust fails
+fi
+if [[ $L5 != "def " ]]
+then err_exit leftjust fails
+fi
+if [[ $uL5 != ABCDE ]]
+then err_exit leftjust uppercase fails
+fi
+if [[ $lR5 != bcdef ]]
+then err_exit rightjust fails
+fi
+if [[ $R5 != " def" ]]
+then err_exit rightjust fails
+fi
+if [[ $($SHELL -c 'echo $x') != export ]]
+then err_exit export fails
+fi
+if [[ $($SHELL -c 'xi=xi+4;echo $xi') != 24 ]]
+then err_exit export attributes fails
+fi
+x=$(foo=abc $SHELL <<!
+ foo=bar
+ $SHELL -c 'print \$foo'
+!
+)
+if [[ $x != bar ]]
+then err_exit 'environment variables require re-export'
+fi
+(typeset + ) > /dev/null 2>&1 || err_exit 'typeset + not working'
+(typeset -L-5 buf="A" 2>/dev/null)
+if [[ $? == 0 ]]
+then err_exit 'typeset allows negative field for left/right adjust'
+fi
+a=b
+readonly $a=foo
+if [[ $b != foo ]]
+then err_exit 'readonly $a=b not working'
+fi
+if [[ $(export | grep '^PATH=') != PATH=* ]]
+then err_exit 'export not working'
+fi
+picture=(
+ bitmap=/fruit
+ size=(typeset -E x=2.5)
+)
+string="$(print $picture)"
+if [[ "${string}" != *'size=( typeset -E'* ]]
+then err_exit 'print of compound exponential variable not working'
+fi
+sz=(typeset -E y=2.2)
+string="$(print $sz)"
+if [[ "${sz}" == *'typeset -E -F'* ]]
+then err_exit 'print of exponential shows both -E and -F attributes'
+fi
+print 'typeset -i m=48/4+1;print -- $m' > /tmp/ksh$$
+chmod +x /tmp/ksh$$
+typeset -Z2 m
+if [[ $(/tmp/ksh$$) != 13 ]]
+then err_exit 'attributes not cleared for script execution'
+fi
+typeset -Z LAST=00
+unset -f foo
+function foo
+{
+ if [[ $1 ]]
+ then LAST=$1
+ else ((LAST++))
+ fi
+}
+foo 1
+if (( ${#LAST} != 2 ))
+then err_exit 'LAST!=2'
+fi
+foo
+if (( ${#LAST} != 2 ))
+then err_exit 'LAST!=2'
+fi
+rm -rf /tmp/ksh$$
+set -a
+unset foo
+foo=bar
+if [[ $(export | grep ^foo=) != 'foo=bar' ]]
+then err_exit 'all export not working'
+fi
+unset foo
+read foo <<!
+bar
+!
+if [[ $(export | grep ^foo=) != 'foo=bar' ]]
+then err_exit 'all export not working with read'
+fi
+if [[ $(typeset | grep PS2) == PS2 ]]
+then err_exit 'typeset without arguments outputs names without attributes'
+fi
+unset a z q x
+w1=hello
+w2=world
+t1="$w1 $w2"
+if (( 'a' == 97 ))
+then b1=aGVsbG8gd29ybGQ=
+ b2=aGVsbG8gd29ybGRoZWxsbyB3b3JsZA==
+else b1=iIWTk5ZAppaZk4Q=
+ b2=iIWTk5ZAppaZk4SIhZOTlkCmlpmThA==
+fi
+z=$b1
+typeset -b x=$b1
+[[ $x == "$z" ]] || print -u2 'binary variable not expanding correctly'
+[[ $(printf "%B" x) == $t1 ]] || err_exit 'typeset -b not working'
+typeset -b -Z5 a=$b1
+[[ $(printf "%B" a) == $w1 ]] || err_exit 'typeset -b -Z5 not working'
+typeset -b q=$x$x
+[[ $q == $b2 ]] || err_exit 'typeset -b not working with concatination'
+[[ $(printf "%B" q) == $t1$t1 ]] || err_exit 'typeset -b concatination not working'
+x+=$b1
+[[ $x == $b2 ]] || err_exit 'typeset -b not working with append'
+[[ $(printf "%B" x) == $t1$t1 ]] || err_exit 'typeset -b append not working'
+typeset -b -Z20 z=$b1
+(( $(printf "%B" z | wc -c) == 20 )) || err_exit 'typeset -b -Z20 not storing 20 bytes'
+{
+ typeset -b v1 v2
+ read -N11 v1
+ read -N22 v2
+} << !
+hello worldhello worldhello world
+!
+[[ $v1 == "$b1" ]] || err_exit "v1=$v1 should be $b1"
+[[ $v2 == "$x" ]] || err_exit "v1=$v2 should be $x"
+[[ $(env '!=1' $SHELL -c 'echo ok' 2>/dev/null) == ok ]] || err_exit 'malformed environment terminates shell'
+unset var
+typeset -b var
+printf '12%Z34' | read -r -N 5 var
+[[ $var == MTIAMzQ= ]] || err_exit 'binary files with zeros not working'
+unset var
+if command typeset -usi var=0xfffff 2> /dev/null
+then (( $var == 0xffff )) || err_exit 'unsigned short integers not working'
+else err_exit 'typeset -usi cannot be used for unsigned short'
+fi
+[[ $($SHELL -c 'unset foo;typeset -Z2 foo; print ${foo:-3}' 2> /dev/null) == 3 ]] || err_exit '${foo:-3} not 3 when typeset -Z2 field undefined'
+[[ $($SHELL -c 'unset foo;typeset -Z2 foo; print ${foo:=3}' 2> /dev/null) == 03 ]] || err_exit '${foo:=-3} not 3 when typeset -Z2 foo undefined'
+unset foo bar
+unset -f fun
+function fun
+{
+ export foo=hello
+ typeset -x bar=world
+ [[ $foo == hello ]] || err_exit 'export scoping problem in function'
+}
+fun
+[[ $(export | grep foo) == 'foo=hello' ]] || err_exit 'export not working in functions'
+[[ $(export | grep bar) ]] && err_exit 'typeset -x not local'
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/basic.sh b/usr/src/lib/libshell/common/tests/basic.sh
new file mode 100644
index 0000000000..28755da226
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/basic.sh
@@ -0,0 +1,336 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+# test basic file operations like redirection, pipes, file expansion
+Command=${0##*/}
+integer Errors=0
+umask u=rwx,go=rx || err_exit "umask u=rws,go=rx failed"
+if [[ $(umask -S) != u=rwx,g=rx,o=rx ]]
+then err_exit 'umask -S incorrect'
+fi
+mkdir /tmp/ksh$$ || err_exit "mkdir /tmp/ksh$$ failed"
+trap "cd /; rm -rf /tmp/ksh$$" EXIT
+pwd=$PWD
+[[ $SHELL != /* ]] && SHELL=$pwd/$SHELL
+cd /tmp/ksh$$ || err_exit "cd /tmp/ksh$$ failed"
+# optimizer bug test
+> foobar
+for i in 1 2
+do print foobar*
+ rm -f foobar
+done > out$$
+if [[ "$(<out$$)" != "foobar"$'\n'"foobar*" ]]
+then print -u2 "optimizer bug with file expansion"
+fi
+rm -f out$$ foobar
+mkdir dir
+if [[ $(print */) != dir/ ]]
+then err_exit 'file expansion with trailing / not working'
+fi
+if [[ $(print *) != dir ]]
+then err_exit 'file expansion with single file not working'
+fi
+print hi > .foo
+if [[ $(print *) != dir ]]
+then err_exit 'file expansion leading . not working'
+fi
+date > dat1 || err_exit "date > dat1 failed"
+test -r dat1 || err_exit "dat1 is not readable"
+x=dat1
+cat <$x > dat2 || err_exit "cat < $x > dat2 failed"
+cat dat1 dat2 | cat | cat | cat > dat3 || err_exit "cat pipe failed"
+cat > dat4 <<!
+$(date)
+!
+cat dat1 dat2 | cat | cat | cat > dat5 &
+wait $!
+set -- dat*
+if (( $# != 5 ))
+then err_exit "dat* matches only $# files"
+fi
+if (command > foo\\abc) 2> /dev/null
+then set -- foo*
+ if [[ $1 != 'foo\abc' ]]
+ then err_exit 'foo* does not match foo\abc'
+ fi
+fi
+if ( : > TT* && : > TTfoo ) 2>/dev/null
+then set -- TT*
+ if (( $# < 2 ))
+ then err_exit 'TT* not expanding when file TT* exists'
+ fi
+fi
+cd ~- || err_exit "cd back failed"
+cat > /tmp/ksh$$/script <<- !
+ #! $SHELL
+ print -r -- \$0
+!
+chmod 755 /tmp/ksh$$/script
+if [[ $(/tmp/ksh$$/script) != "/tmp/ksh$$/script" ]]
+then err_exit '$0 not correct for #! script'
+fi
+rm -r /tmp/ksh$$ || err_exit "rm -r /tmp/ksh$$ failed"
+bar=foo
+eval foo=\$bar
+if [[ $foo != foo ]]
+then err_exit 'eval foo=\$bar not working'
+fi
+bar='foo=foo\ bar'
+eval $bar
+if [[ $foo != 'foo bar' ]]
+then err_exit 'eval foo=\$bar, with bar="foo\ bar" not working'
+fi
+cd /tmp
+cd ../../tmp || err_exit "cd ../../tmp failed"
+if [[ $PWD != /tmp ]]
+then err_exit 'cd ../../tmp is not /tmp'
+fi
+( sleep 2; cat <<!
+foobar
+!
+) | cat > /tmp/foobar$$ &
+wait $!
+foobar=$( < /tmp/foobar$$)
+if [[ $foobar != foobar ]]
+then err_exit "$foobar is not foobar"
+fi
+{
+ print foo
+ /bin/echo bar
+ print bam
+} > /tmp/foobar$$
+if [[ $( < /tmp/foobar$$) != $'foo\nbar\nbam' ]]
+then err_exit "Output file pointer not shared correctly."
+fi
+cat > /tmp/foobar$$ <<\!
+ print foo
+ /bin/echo bar
+ print bam
+!
+chmod +x /tmp/foobar$$
+if [[ $(/tmp/foobar$$) != $'foo\nbar\nbam' ]]
+then err_exit "Script not working."
+fi
+if [[ $(/tmp/foobar$$ | /bin/cat) != $'foo\nbar\nbam' ]]
+then err_exit "Script | cat not working."
+fi
+if [[ $( /tmp/foobar$$) != $'foo\nbar\nbam' ]]
+then err_exit "Output file pointer not shared correctly."
+fi
+rm -f /tmp/foobar$$
+x=$( (print foo) ; (print bar) )
+if [[ $x != $'foo\nbar' ]]
+then err_exit " ( (print foo);(print bar ) failed"
+fi
+x=$( (/bin/echo foo) ; (print bar) )
+if [[ $x != $'foo\nbar' ]]
+then err_exit " ( (/bin/echo);(print bar ) failed"
+fi
+x=$( (/bin/echo foo) ; (/bin/echo bar) )
+if [[ $x != $'foo\nbar' ]]
+then err_exit " ( (/bin/echo);(/bin/echo bar ) failed"
+fi
+cat > /tmp/ksh$$ <<\!
+if [[ -p /dev/fd/0 ]]
+then builtin cat
+ cat - > /dev/null
+ [[ -p /dev/fd/0 ]] && print ok
+else print no
+fi
+!
+chmod +x /tmp/ksh$$
+case $( (print) | /tmp/ksh$$;:) in
+ok) ;;
+no) err_exit "[[ -p /dev/fd/0 ]] fails for standard input pipe" ;;
+*) err_exit "builtin replaces standard input pipe" ;;
+esac
+print 'print $0' > /tmp/ksh$$
+print ". /tmp/ksh$$" > /tmp/ksh$$x
+chmod +x /tmp/ksh$$x
+if [[ $(/tmp/ksh$$x) != /tmp/ksh$$x ]]
+then err_exit '$0 not correct for . script'
+fi
+rm -r /tmp/ksh$$ /tmp/ksh$$x
+mkdir /tmp/ksh$$ || err_exit "mkdir /tmp/ksh$$ failed"
+cd /tmp/ksh$$ || err_exit "cd /tmp/ksh$$ failed"
+print ./b > ./a; print ./c > b; print ./d > c; print ./e > d; print "echo \"hello there\"" > e
+chmod 755 a b c d e
+x=$(./a)
+if [[ $x != "hello there" ]]
+then err_exit "nested scripts failed"
+fi
+x=$( (./a) | cat)
+if [[ $x != "hello there" ]]
+then err_exit "scripts in subshells fail"
+fi
+cd ~- || err_exit "cd back failed"
+rm -r /tmp/ksh$$ || err_exit "rm -r /tmp/ksh$$ failed"
+x=$( (/bin/echo foo) 2> /dev/null )
+if [[ $x != foo ]]
+then err_exit "subshell in command substitution fails"
+fi
+exec 1>&-
+x=$(print hello)
+if [[ $x != hello ]]
+then err_exit "command subsitution with stdout closed failed"
+fi
+cd $pwd
+x=$(cat <<\! | $SHELL
+/bin/echo | /bin/cat
+/bin/echo hello
+!
+)
+if [[ $x != $'\n'hello ]]
+then err_exit "$SHELL not working when standard input is a pipe"
+fi
+x=$( (/bin/echo hello) 2> /dev/null )
+if [[ $x != hello ]]
+then err_exit "subshell in command substitution with 1 closed fails"
+fi
+cat > /tmp/ksh$$ <<- \!
+read line 2> /dev/null
+print done
+!
+if [[ $($SHELL /tmp/ksh$$ <&-) != done ]]
+then err_exit "executing script with 0 closed fails"
+fi
+trap '' INT
+cat > /tmp/ksh$$ <<- \!
+trap 'print bad' INT
+kill -s INT $$
+print good
+!
+chmod +x /tmp/ksh$$
+if [[ $($SHELL /tmp/ksh$$) != good ]]
+then err_exit "traps ignored by parent not ignored"
+fi
+trap - INT
+cat > /tmp/ksh$$ <<- \!
+read line
+/bin/cat
+!
+if [[ $($SHELL /tmp/ksh$$ <<!
+one
+two
+!
+) != two ]]
+then err_exit "standard input not positioned correctly"
+fi
+word=$(print $'foo\nbar' | { read line; /bin/cat;})
+if [[ $word != bar ]]
+then err_exit "pipe to { read line; /bin/cat;} not working"
+fi
+word=$(print $'foo\nbar' | ( read line; /bin/cat) )
+if [[ $word != bar ]]
+then err_exit "pipe to ( read line; /bin/cat) not working"
+fi
+if [[ $(print x{a,b}y) != 'xay xby' ]]
+then err_exit 'brace expansion not working'
+fi
+if [[ $(for i in foo bar
+ do ( tgz=$(print $i)
+ print $tgz)
+ done) != $'foo\nbar' ]]
+then err_exit 'for loop subshell optimizer bug'
+fi
+unset a1
+optbug()
+{
+ set -A a1 foo bar bam
+ integer i
+ for ((i=0; i < 3; i++))
+ do
+ (( ${#a1[@]} < 2 )) && return 0
+ set -- "${a1[@]}"
+ shift
+ set -A a1 -- "$@"
+ done
+ return 1
+}
+optbug || err_exit 'array size optimzation bug'
+wait # not running --pipefile which would interfere with subsequent tests
+: $(jobs -p) # required to clear jobs for next jobs -p (interactive side effect)
+sleep 20 &
+if [[ $(jobs -p) != $! ]]
+then err_exit 'jobs -p not reporting a background job'
+fi
+sleep 20 &
+foo()
+{
+ set -- $(jobs -p)
+ (( $# == 2 )) || err_exit "$# jobs not reported -- 2 expected"
+}
+foo
+[[ $( (trap 'print alarm' ALRM; sleep 4) & sleep 2; kill -ALRM $!) == alarm ]] || err_exit 'ALRM signal not working'
+[[ $($SHELL -c 'trap "" HUP; $SHELL -c "(sleep 2;kill -HUP $$)& sleep 4;print done"') != done ]] && err_exit 'ignored traps not being ignored'
+[[ $($SHELL -c 'o=foobar; for x in foo bar; do (o=save);print $o;done' 2> /dev/null ) == $'foobar\nfoobar' ]] || err_exit 'for loop optimization subshell bug'
+command exec 3<> /dev/null
+if cat /dev/fd/3 >/dev/null 2>&1
+then [[ $($SHELL -c 'cat <(print foo)' 2> /dev/null) == foo ]] || err_exit 'process substitution not working'
+ [[ $($SHELL -c 'print $(cat <(print foo) )' 2> /dev/null) == foo ]] || err_exit 'process substitution in subshell not working'
+ [[ $($SHELL -c $'tee >(grep \'1$\' > /tmp/ksh'$$'x) > /dev/null <<- \!!!
+ line0
+ line1
+ line2
+ !!!
+ wait
+ cat /tmp/ksh'$$x 2> /dev/null) == line1 ]] || err_exit '>() process substitution fails'
+ > /tmp/ksh$$x
+ [[ $($SHELL -c $'
+ for i in 1
+ do tee >(grep \'1$\' > /tmp/ksh'$$'x) > /dev/null <<- \!!!
+ line0
+ line1
+ line2
+ !!!
+ done
+ wait
+ cat /tmp/ksh'$$x 2>> /dev/null) == line1 ]] || err_exit '>() process substitution fails in for loop'
+ [[ $({ $SHELL -c 'cat <(for i in x y z; do print $i; done)';} 2> /dev/null) == $'x\ny\nz' ]] ||
+ err_exit 'process substitution of compound commands not working'
+fi
+[[ $($SHELL -r 'command -p :' 2>&1) == *restricted* ]] || err_exit 'command -p not restricted'
+print cat > /tmp/ksh$$x
+chmod +x /tmp/ksh$$x
+[[ $($SHELL -c "print foo | /tmp/ksh$$x ;:" 2> /dev/null ) == foo ]] || err_exit 'piping into script fails'
+[[ $($SHELL -c 'X=1;print -r -- ${X:=$(expr "a(0)" : '"'a*(\([^)]\))')}'" 2> /dev/null) == 1 ]] || err_exit 'x=1;${x:=$(..."...")} failure'
+[[ $($SHELL -c 'print -r -- ${X:=$(expr "a(0)" : '"'a*(\([^)]\))')}'" 2> /dev/null) == 0 ]] || err_exit '${x:=$(..."...")} failure'
+if [[ -d /dev/fd && -w /dev/fd/3 ]]
+then [[ $(cat <(print hello) ) == hello ]] || err_exit "process substitution not working outside for or while loop"
+ $SHELL -c '[[ $(for i in 1;do cat <(print hello);done ) == hello ]]' 2> /dev/null|| err_exit "process substitution not working in for or while loop"
+fi
+exec 3> /dev/null
+print 'print foo "$@"' > /tmp/ksh$$x
+[[ $( print "(/tmp/ksh$$x bar)" | $SHELL 2>/dev/null) == 'foo bar' ]] || err_exit 'script pipe to shell fails'
+print "#! $SHELL" > /tmp/ksh$$x
+print 'print -- $0' >> /tmp/ksh$$x
+chmod +x /tmp/ksh$$x
+[[ $(/tmp/ksh$$x) == /tmp/ksh$$x ]] || err_exit "\$0 is $0 instead of /tmp/ksh$$x"
+rm -f /tmp/ksh$$x
+exec 3<&-
+( typeset -r foo=bar) 2> /dev/null || err_exit 'readonly variables set in a subshell cannot unset'
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/bracket.sh b/usr/src/lib/libshell/common/tests/bracket.sh
new file mode 100644
index 0000000000..25daf72c32
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/bracket.sh
@@ -0,0 +1,233 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+integer Errors=0
+null=''
+if [[ ! -z $null ]]
+then err_exit "-z: null string should be of zero length"
+fi
+file=/tmp/regress$$
+if [[ -z $file ]]
+then err_exit "-z: $file string should not be of zero length"
+fi
+trap "rm -f $file" EXIT
+rm -f $file
+if [[ -a $file ]]
+then err_exit "-a: $file shouldn't exist"
+fi
+> $file
+if [[ ! -a $file ]]
+then err_exit "-a: $file should exist"
+fi
+chmod 777 $file
+if [[ ! -r $file ]]
+then err_exit "-r: $file should be readable"
+fi
+if [[ ! -w $file ]]
+then err_exit "-w: $file should be writable"
+fi
+if [[ ! -w $file ]]
+then err_exit "-x: $file should be executable"
+fi
+if [[ ! -w $file || ! -r $file ]]
+then err_exit "-rw: $file should be readable/writable"
+fi
+if [[ -s $file ]]
+then err_exit "-s: $file should be of zero size"
+fi
+if [[ ! -f $file ]]
+then err_exit "-f: $file should be an ordinary file"
+fi
+if [[ -d $file ]]
+then err_exit "-f: $file should not be a directory file"
+fi
+if [[ ! -d . ]]
+then err_exit "-d: . should not be a directory file"
+fi
+if [[ -f /dev/null ]]
+then err_exit "-f: /dev/null should not be an ordinary file"
+fi
+chmod 000 $file
+if [[ -r $file ]]
+then err_exit "-r: $file should not be readable"
+fi
+if [[ ! -O $file ]]
+then err_exit "-r: $file should be owned by me"
+fi
+if [[ -w $file ]]
+then err_exit "-w: $file should not be writable"
+fi
+if [[ -w $file ]]
+then err_exit "-x: $file should not be executable"
+fi
+if [[ -w $file || -r $file ]]
+then err_exit "-rw: $file should not be readable/writable"
+fi
+if [[ -z x && -z x || ! -z x ]]
+then :
+else err_exit " wrong precedence"
+fi
+if [[ -z x && (-z x || ! -z x) ]]
+then err_exit " () grouping not working"
+fi
+if [[ foo < bar ]]
+then err_exit "foo comes before bar"
+fi
+[[ . -ef $(pwd) ]] || err_exit ". is not $PWD"
+set -o allexport
+[[ -o allexport ]] || err_exit '-o: did not set allexport option'
+if [[ -n $null ]]
+then err_exit "'$null' has non-zero length"
+fi
+if [[ ! -r /dev/fd/0 ]]
+then err_exit "/dev/fd/0 not open for reading"
+fi
+if [[ ! -w /dev/fd/2 ]]
+then err_exit "/dev/fd/2 not open for writing"
+fi
+sleep 1
+if [[ ! . -ot $file ]]
+then err_exit ". should be older than $file"
+fi
+if [[ /bin -nt $file ]]
+then err_exit "$file should be newer than /bin"
+fi
+if [[ $file != /tmp/* ]]
+then err_exit "$file should match /tmp/*"
+fi
+if [[ $file = '/tmp/*' ]]
+then err_exit "$file should not equal /tmp/*"
+fi
+[[ ! ( ! -z $null && ! -z x) ]] || err_exit "negation and grouping"
+[[ -z '' || -z '' || -z '' ]] || err_exit "three ors not working"
+[[ -z '' && -z '' && -z '' ]] || err_exit "three ors not working"
+(exit 8)
+if [[ $? -ne 8 || $? -ne 8 ]]
+then err_exit 'value $? within [[...]]'
+fi
+x='(x'
+if [[ '(x' != '('* ]]
+then err_exit " '(x' does not match '('* within [[...]]"
+fi
+if [[ '(x' != "("* ]]
+then err_exit ' "(x" does not match "("* within [[...]]'
+fi
+if [[ '(x' != \(* ]]
+then err_exit ' "(x" does not match \(* within [[...]]'
+fi
+if [[ 'x(' != *'(' ]]
+then err_exit " 'x(' does not match '('* within [[...]]"
+fi
+if [[ 'x&' != *'&' ]]
+then err_exit " 'x&' does not match '&'* within [[...]]"
+fi
+if [[ 'xy' = *'*' ]]
+then err_exit " 'xy' matches *'*' within [[...]]"
+fi
+if [[ 3 > 4 ]]
+then err_exit '3 < 4'
+fi
+if [[ 4 < 3 ]]
+then err_exit '3 > 4'
+fi
+if [[ 3x > 4x ]]
+then err_exit '3x < 4x'
+fi
+x='bin|dev|?'
+cd /
+if [[ $(print $x) != "$x" ]]
+then err_exit 'extended pattern matching on command arguments'
+fi
+if [[ dev != $x ]]
+then err_exit 'extended pattern matching not working on variables'
+fi
+if [[ -u $SHELL ]]
+then err_exit "setuid on $SHELL"
+fi
+if [[ -g $SHELL ]]
+then err_exit "setgid on $SHELL"
+fi
+test -d . -a '(' ! -f . ')' || err_exit 'test not working'
+if [[ '!' != ! ]]
+then err_exit 'quoting unary operator not working'
+fi
+chmod 600 $file
+exec 4> $file
+print -u4 foobar
+if [[ ! -s $file ]]
+then err_exit "-s: $file should be non-zero"
+fi
+exec 4>&-
+if [[ 011 -ne 11 ]]
+then err_exit "leading zeros in arithmetic compares not ignored"
+fi
+{
+ set -x
+ [[ foo > bar ]]
+} 2> /dev/null || { set +x; err_exit "foo<bar with -x enabled" ;}
+set +x
+(
+ eval "[[ (a) ]]"
+) 2> /dev/null || err_exit "[[ (a) ]] not working"
+> $file
+chmod 4755 "$file"
+if test -u $file && test ! -u $file
+then err_exit "test ! -u suidfile not working"
+fi
+for i in '(' ')' '[' ']'
+do [[ $i == $i ]] || err_exit "[[ $i != $i ]]"
+done
+(
+ [[ aaaa == {4}(a) ]] || err_exit 'aaaa != {4}(a)'
+ [[ aaaa == {2,5}(a) ]] || err_exit 'aaaa != {2,4}(a)'
+ [[ abcdcdabcd == {3,6}(ab|cd) ]] || err_exit 'abcdcdabcd == {3,4}(ab|cd)'
+ [[ abcdcdabcde == {5}(ab|cd)e ]] || err_exit 'abcdcdabcd == {5}(ab|cd)e'
+) || err_exit 'Errors with {..}(...) patterns'
+[[ D290.2003.02.16.temp == D290.+(2003.02.16).temp* ]] || err_exit 'pattern match bug with +(...)'
+rm -rf $file
+{
+[[ -N $file ]] && err_exit 'test -N /tmp/*: st_mtime>st_atime after creat'
+sleep 2
+print 'hello world'
+[[ -N $file ]] || err_exit 'test -N /tmp/*: st_mtime<=st_atime after write'
+sleep 2
+read
+[[ -N $file ]] && err_exit 'test -N /tmp/*: st_mtime>st_atime after read'
+} > $file < $file
+if rm -rf "$file" && ln -s / "$file"
+then [[ -L "$file" ]] || err_exit '-L not working'
+ [[ -L "$file"/ ]] && err_exit '-L with file/ not working'
+fi
+$SHELL -c 't=1234567890; [[ $t == @({10}(\d)) ]]' 2> /dev/null || err_exit ' @({10}(\d)) pattern not working'
+$SHELL -c '[[ att_ == ~(E)(att|cus)_.* ]]' 2> /dev/null || err_exit ' ~(E)(att|cus)_* pattern not working'
+$SHELL -c '[[ att_ =~ (att|cus)_.* ]]' 2> /dev/null || err_exit ' =~ ere not working'
+$SHELL -c '[[ abc =~ a(b)c ]]' 2> /dev/null || err_exit '[[ abc =~ a(b)c ]] fails'
+$SHELL -xc '[[ abc =~ \babc\b ]]' 2> /dev/null || err_exit '[[ abc =~ \babc\b ]] fails'
+[[ abc == ~(E)\babc\b ]] || err_exit '\b not preserved for ere when not in ()'
+[[ abc == ~(iEi)\babc\b ]] || err_exit '\b not preserved for ~(iEi) when not in ()'
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/builtins.sh b/usr/src/lib/libshell/common/tests/builtins.sh
new file mode 100644
index 0000000000..1d2dfe9157
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/builtins.sh
@@ -0,0 +1,451 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+# test shell builtin commands
+Command=${0##*/}
+integer Errors=0
+builtin getconf
+: ${foo=bar} || err_exit ": failed"
+[[ $foo = bar ]] || err_exit ": side effects failed"
+set -- - foobar
+[[ $# = 2 && $1 = - && $2 = foobar ]] || err_exit "set -- - foobar failed"
+set -- -x foobar
+[[ $# = 2 && $1 = -x && $2 = foobar ]] || err_exit "set -- -x foobar failed"
+getopts :x: foo || err_exit "getopts :x: returns false"
+[[ $foo = x && $OPTARG = foobar ]] || err_exit "getopts :x: failed"
+OPTIND=1
+getopts :r:s var -r
+if [[ $var != : || $OPTARG != r ]]
+then err_exit "'getopts :r:s var -r' not working"
+fi
+OPTIND=1
+getopts :d#u var -d 100
+if [[ $var != d || $OPTARG != 100 ]]
+then err_exit "'getopts :d#u var -d 100' not working var=$var"
+fi
+OPTIND=1
+while getopts 'ab' option -a -b
+do [[ $OPTIND == $((OPTIND)) ]] || err_exit "OPTIND optimization bug"
+done
+
+USAGE=$'[-][S:server?Operate on the specified \asubservice\a:]:[subservice:=pmserver]
+ {
+ [p:pmserver]
+ [r:repserver]
+ [11:notifyd]
+ }'
+set pmser p rep r notifyd -11
+while (( $# > 1 ))
+do OPTIND=1
+ getopts "$USAGE" OPT -S $1
+ [[ $OPT == S && $OPTARG == $2 ]] || err_exit "OPT=$OPT OPTARG=$OPTARG -- expected OPT=S OPTARG=$2"
+ shift 2
+done
+
+false ${foo=bar} && err_exit "false failed"
+read <<!
+hello world
+!
+[[ $REPLY = 'hello world' ]] || err_exit "read builtin failed"
+print x:y | IFS=: read a b
+if [[ $a != x ]]
+then err_exit "IFS=: read ... not working"
+fi
+read <<!
+hello \
+world
+!
+[[ $REPLY = 'hello world' ]] || err_exit "read continuation failed"
+read -d x <<!
+hello worldxfoobar
+!
+[[ $REPLY = 'hello world' ]] || err_exit "read builtin failed"
+read <<\!
+hello \
+ world \
+
+!
+[[ $REPLY == 'hello world' ]] || err_exit "read continuation2 failed"
+print "one\ntwo" | { read line
+ print $line | /bin/cat > /dev/null
+ read line
+}
+read <<\!
+\
+a\
+\
+\
+b
+!
+if [[ $REPLY != ab ]]
+then err_exit "read multiple continuation failed"
+fi
+if [[ $line != two ]]
+then err_exit "read from pipeline failed"
+fi
+line=two
+read line < /dev/null
+if [[ $line != "" ]]
+then err_exit "read from /dev/null failed"
+fi
+if [[ $(print -R -) != - ]]
+then err_exit "print -R not working correctly"
+fi
+if [[ $(print -- -) != - ]]
+then err_exit "print -- not working correctly"
+fi
+print -f "hello%nbar\n" size > /dev/null
+if (( size != 5 ))
+then err_exit "%n format of printf not working"
+fi
+print -n -u2 2>&1-
+[[ -w /dev/fd/1 ]] || err_exit "2<&1- with built-ins has side effects"
+x=$0
+if [[ $(eval 'print $0') != $x ]]
+then err_exit '$0 not correct for eval'
+fi
+unset x
+readonly x
+set -- $(readonly)
+if [[ " $@ " != *" x "* ]]
+then err_exit 'unset readonly variables are not displayed'
+fi
+if [[ $( for i in foo bar
+ do print $i
+ continue 10
+ done
+ ) != $'foo\nbar' ]]
+then err_exit 'continue breaks out of loop'
+fi
+(continue bad 2>/dev/null && err_exit 'continue bad should return an error')
+(break bad 2>/dev/null && err_exit 'break bad should return an error')
+(continue 0 2>/dev/null && err_exit 'continue 0 should return an error')
+(break 0 2>/dev/null && err_exit 'break 0 should return an error')
+breakfun() { break;}
+continuefun() { continue;}
+for fun in break continue
+do if [[ $( for i in foo
+ do ${fun}fun
+ print $i
+ done
+ ) != foo ]]
+ then err_exit "$fun call in ${fun}fun breaks out of for loop"
+ fi
+done
+if [[ $(print -f "%b" "\a\n\v\b\r\f\E\03\\oo") != $'\a\n\v\b\r\f\E\03\\oo' ]]
+then err_exit 'print -f "%b" not working'
+fi
+if [[ $(print -f "%P" "[^x].*b$") != '*[!x]*b' ]]
+then err_exit 'print -f "%P" not working'
+fi
+if [[ $(abc: for i in foo bar;do print $i;break abc;done) != foo ]]
+then err_exit 'break labels not working'
+fi
+if [[ $(command -v if) != if ]]
+then err_exit 'command -v not working'
+fi
+read -r var <<\!
+
+!
+if [[ $var != "" ]]
+then err_exit "read -r of blank line not working"
+fi
+mkdir -p /tmp/ksh$$/a/b/c 2>/dev/null || err_exit "mkdir -p failed"
+$SHELL -c "cd /tmp/ksh$$/a/b; cd c" 2>/dev/null || err_exit "initial script relative cd fails"
+rm -r /tmp/ksh$$ || err_exit "rm -r /tmp/ksh$$ failed"
+trap 'print HUP' HUP
+if [[ $(trap) != "trap -- 'print HUP' HUP" ]]
+then err_exit '$(trap) not working'
+fi
+if [[ $(trap -p HUP) != 'print HUP' ]]
+then err_exit '$(trap -p HUP) not working'
+fi
+[[ $($SHELL -c 'trap "print ok" SIGTERM; kill -s SIGTERM $$' 2> /dev/null) == ok
+ ]] || err_exit 'SIGTERM not recognized'
+[[ $($SHELL -c 'trap "print ok" sigterm; kill -s sigterm $$' 2> /dev/null) == ok
+ ]] || err_exit 'SIGTERM not recognized'
+${SHELL} -c 'kill -1 -$$' 2> /dev/null
+[[ $(kill -l $?) == HUP ]] || err_exit 'kill -1 -pid not working'
+${SHELL} -c 'kill -1 -$$' 2> /dev/null
+[[ $(kill -l $?) == HUP ]] || err_exit 'kill -n1 -pid not working'
+${SHELL} -c 'kill -s HUP -$$' 2> /dev/null
+[[ $(kill -l $?) == HUP ]] || err_exit 'kill -HUP -pid not working'
+n=123
+typeset -A base
+base[o]=8#
+base[x]=16#
+base[X]=16#
+for i in d i o u x X
+do if (( $(( ${base[$i]}$(printf "%$i" $n) )) != n ))
+ then err_exit "printf %$i not working"
+ fi
+done
+if [[ $( trap 'print done' EXIT) != done ]]
+then err_exit 'trap on EXIT not working'
+fi
+if [[ $( trap 'print done' EXIT; trap - EXIT) == done ]]
+then err_exit 'trap on EXIT not being cleared'
+fi
+if [[ $(type test) != 'test is a shell builtin' ]]
+then err_exit 'whence -v test not a builtin'
+fi
+builtin -d test
+if [[ $(type test) == *builtin* ]]
+then err_exit 'whence -v test after builtin -d incorrect'
+fi
+typeset -Z3 percent=$(printf '%o\n' "'%'")
+forrmat=\\${percent}s
+if [[ $(printf "$forrmat") != %s ]]
+then err_exit "printf $forrmat not working"
+fi
+if (( $(printf 'x\0y' | wc -c) != 3 ))
+then err_exit 'printf \0 not working'
+fi
+if [[ $(printf "%bx%s\n" 'f\to\cbar') != $'f\to' ]]
+then err_exit 'printf %bx%s\n not working'
+fi
+alpha=abcdefghijklmnop
+if [[ $(printf "%10.*s\n" 5 $alpha) != ' abcde' ]]
+then err_exit 'printf %10.%s\n not working'
+fi
+float x2=.0000625
+if [[ $(printf "%10.5E\n" x2) != 6.25000E-05 ]]
+then err_exit 'printf "%10.5E" not normalizing correctly'
+fi
+x2=.000000001
+if [[ $(printf "%g\n" x2 2>/dev/null) != 1e-09 ]]
+then err_exit 'printf "%g" not working correctly'
+fi
+#FIXME#($SHELL read -s foobar <<\!
+#FIXME#testing
+#FIXME#!
+#FIXME#) 2> /dev/null || err_exit ksh read -s var fails
+if [[ $(printf +3 2>/dev/null) != +3 ]]
+then err_exit 'printf is not processing formats beginning with + correctly'
+fi
+if printf "%d %d\n" 123bad 78 >/dev/null 2>/dev/null
+then err_exit "printf not exiting non-zero with conversion errors"
+fi
+if [[ $(trap --version 2> /dev/null;print done) != done ]]
+then err_exit 'trap builtin terminating after --version'
+fi
+if [[ $(set --version 2> /dev/null;print done) != done ]]
+then err_exit 'set builtin terminating after --veresion'
+fi
+unset -f foobar
+function foobar
+{
+ print 'hello world'
+}
+OPTIND=1
+if [[ $(getopts $'[+?X\ffoobar\fX]' v --man 2>&1) != *'Xhello world'X* ]]
+then err_exit '\f...\f not working in getopts usage strings'
+fi
+if [[ $(printf '%H\n' $'<>"& \'\tabc') != '&lt;&gt;&quot;&amp;&nbsp;&apos;&#9;abc' ]]
+then err_exit 'printf %H not working'
+fi
+if [[ $(printf '%R %R %R %R\n' 'a.b' '*.c' '^' '!(*.*)') != '^a\.b$ \.c$ ^\^$ ^(.*\..*)!$' ]]
+then err_exit 'printf %R not working'
+fi
+if [[ $(printf '%..:c\n' abc) != a:b:c ]]
+then err_exit "printf '%..:c' not working"
+fi
+if [[ $(printf '%..*c\n' : abc) != a:b:c ]]
+then err_exit "printf '%..*c' not working"
+fi
+if [[ $(printf '%..:s\n' abc def ) != abc:def ]]
+then err_exit "printf '%..:s' not working"
+fi
+if [[ $(printf '%..*s\n' : abc def) != abc:def ]]
+then err_exit "printf '%..*s' not working"
+fi
+[[ $(printf '%q\n') == '' ]] || err_exit 'printf "%q" with missing arguments'
+# we won't get hit by the one second boundary twice, right?
+[[ $(printf '%T\n' now) == "$(date)" ]] ||
+[[ $(printf '%T\n' now) == "$(date)" ]] ||
+err_exit 'printf "%T" now'
+behead()
+{
+ read line
+ left=$(cat)
+}
+print $'line1\nline2' | behead
+if [[ $left != line2 ]]
+then err_exit "read reading ahead on a pipe"
+fi
+read -n1 y <<!
+abc
+!
+if [[ $y != a ]]
+then err_exit 'read -n1 not working'
+fi
+print -n $'{ read -r line;print $line;}\nhello' > /tmp/ksh$$
+chmod 755 /tmp/ksh$$
+trap 'rm -rf /tmp/ksh$$' EXIT
+if [[ $($SHELL < /tmp/ksh$$) != hello ]]
+then err_exit 'read of incomplete line not working correctly'
+fi
+set -f
+set -- *
+if [[ $1 != '*' ]]
+then err_exit 'set -f not working'
+fi
+unset pid1 pid2
+false &
+pid1=$!
+pid2=$(
+ wait $pid1
+ (( $? == 127 )) || err_exit "job known to subshell"
+ print $!
+)
+wait $pid1
+(( $? == 1 )) || err_exit "wait not saving exit value"
+wait $pid2
+(( $? == 127 )) || err_exit "subshell job known to parent"
+set --noglob
+ifs=$IFS
+IFS=,
+set -- $(getconf LIBPATH)
+IFS=$ifs
+env=
+for v
+do IFS=:
+ set -- $v
+ IFS=$ifs
+ eval [[ \$$2 ]] && env="$env $2=\"\$$2\""
+done
+set --glob
+if [[ $(foo=bar; eval foo=\$foo $env exec -c \$SHELL -c \'print \$foo\') != bar ]]
+then err_exit '"name=value exec -c ..." not working'
+fi
+$SHELL -c 'OPTIND=-1000000; getopts a opt -a' 2> /dev/null
+[[ $? == 1 ]] || err_exit 'getopts with negative OPTIND not working'
+getopts 'n#num' opt -n 3
+[[ $OPTARG == 3 ]] || err_exit 'getopts with numerical arguments failed'
+if [[ $($SHELL -c $'printf \'%2$s %1$s\n\' world hello') != 'hello world' ]]
+then err_exit 'printf %2$s %1$s not working'
+fi
+((n=0))
+((n++)); ARGC[$n]=1 ARGV[$n]=""
+((n++)); ARGC[$n]=2 ARGV[$n]="-a"
+((n++)); ARGC[$n]=4 ARGV[$n]="-a -v 2"
+((n++)); ARGC[$n]=4 ARGV[$n]="-a -v 2 x"
+((n++)); ARGC[$n]=4 ARGV[$n]="-a -v 2 x y"
+for ((i=1; i<=n; i++))
+do set -- ${ARGV[$i]}
+ OPTIND=0
+ while getopts -a tst "av:" OPT
+ do :
+ done
+ if [[ $OPTIND != ${ARGC[$i]} ]]
+ then err_exit "\$OPTIND after getopts loop incorrect -- got $OPTIND, expected ${ARGC[$i]}"
+ fi
+done
+unset a
+{ read -N3 a; read -N1 b;} <<!
+abcdefg
+!
+[[ $a == abc ]] || err_exit 'read -N3 here-document not working'
+[[ $b == d ]] || err_exit 'read -N1 here-document not working'
+read -n3 a <<!
+abcdefg
+!
+[[ $a == abc ]] || err_exit 'read -n3 here-document not working'
+(print -n a;sleep 1; print -n bcde) | { read -N3 a; read -N1 b;}
+[[ $a == abc ]] || err_exit 'read -N3 from pipe not working'
+[[ $b == d ]] || err_exit 'read -N1 from pipe not working'
+(print -n a;sleep 1; print -n bcde) |read -n3 a
+[[ $a == a ]] || err_exit 'read -n3 from pipe not working'
+rm -f /tmp/fifo$$
+if mkfifo /tmp/fifo$$ 2> /dev/null
+then (print -n a; sleep 1;print -n bcde) > /tmp/fifo$$ &
+ {
+ read -u5 -n3 -t2 a || err_exit 'read -n3 from fifo timedout'
+ read -u5 -n1 -t2 b || err_exit 'read -n1 from fifo timedout'
+ } 5< /tmp/fifo$$
+ [[ $a == a ]] || err_exit 'read -n3 from fifo not working'
+ rm -f /tmp/fifo$$
+ mkfifo /tmp/fifo$$ 2> /dev/null
+ (print -n a; sleep 1;print -n bcde) > /tmp/fifo$$ &
+ {
+ read -u5 -N3 -t2 a || err_exit 'read -N3 from fifo timed out'
+ read -u5 -N1 -t2 b || err_exit 'read -N1 from fifo timedout'
+ } 5< /tmp/fifo$$
+ [[ $a == abc ]] || err_exit 'read -N3 from fifo not working'
+ [[ $b == d ]] || err_exit 'read -N1 from fifo not working'
+fi
+rm -f /tmp/fifo$$
+function longline
+{
+ integer i
+ for((i=0; i < $1; i++))
+ do print argument$i
+ done
+}
+# test command -x option
+integer sum=0 n=10000
+if ! ${SHELL:-ksh} -c 'print $#' count $(longline $n) > /dev/null 2>&1
+then for i in $(command command -x ${SHELL:-ksh} -c 'print $#;[[ $1 != argument0 ]]' count $(longline $n) 2> /dev/null)
+ do ((sum += $i))
+ done
+ (( sum == n )) || err_exit "command -x processed only $sum arguments"
+ command -p command -x ${SHELL:-ksh} -c 'print $#;[[ $1 == argument0 ]]' count $(longline $n) > /dev/null 2>&1
+ [[ $? != 1 ]] && err_exit 'incorrect exit status for command -x'
+fi
+# test command -x option with extra arguments
+integer sum=0 n=10000
+if ! ${SHELL:-ksh} -c 'print $#' count $(longline $n) > /dev/null 2>&1
+then for i in $(command command -x ${SHELL:-ksh} -c 'print $#;[[ $1 != argument0 ]]' count $(longline $n) one two three) #2> /dev/null)
+ do ((sum += $i))
+ done
+ (( sum > n )) || err_exit "command -x processed only $sum arguments"
+ (( (sum-n)%3==0 )) || err_exit "command -x processed only $sum arguments"
+ (( sum == n+3)) && err_exit "command -x processed only $sum arguments"
+ command -p command -x ${SHELL:-ksh} -c 'print $#;[[ $1 == argument0 ]]' count $(longline $n) > /dev/null 2>&1
+ [[ $? != 1 ]] && err_exit 'incorrect exit status for command -x'
+fi
+# test for debug trap
+[[ $(typeset -i i=0
+ trap 'print $i' DEBUG
+ while (( i <2))
+ do (( i++))
+ done) == $'0\n0\n1\n1\n2' ]] || err_exit "DEBUG trap not working"
+getconf UNIVERSE - ucb
+[[ $($SHELL -c 'echo -3') == -3 ]] || err_exit "echo -3 not working in ucb universe"
+typeset -F3 start_x=SECONDS total_t delay=0.02
+typeset reps=50 leeway=5
+sleep $(( 2 * leeway * reps * delay )) |
+for (( i=0 ; i < reps ; i++ ))
+do read -N1 -t $delay
+done
+(( total_t = SECONDS - start_x ))
+if (( total_t > leeway * reps * delay ))
+then err_exit "read -t in pipe taking $total_t secs - $(( reps * delay )) minimum - too long"
+elif (( total_t < reps * delay ))
+then err_exit "read -t in pipe taking $total_t secs - $(( reps * delay )) minimum - too fast"
+fi
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/case.sh b/usr/src/lib/libshell/common/tests/case.sh
new file mode 100644
index 0000000000..4090d30103
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/case.sh
@@ -0,0 +1,81 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+integer Errors=0
+
+bar=foo2
+bam=foo[3]
+for i in foo1 foo2 foo3 foo4 foo5 foo6
+do foo=0
+ case $i in
+ foo1) foo=1;;
+ $bar) foo=2;;
+ $bam) foo=3;;
+ foo[4]) foo=4;;
+ ${bar%?}5)
+ foo=5;;
+ "${bar%?}6")
+ foo=6;;
+ esac
+ if [[ $i != foo$foo ]]
+ then err_exit "$i not matching correct pattern"
+ fi
+done
+f="[ksh92]"
+case $f in
+\[*\]) ;;
+*) err_exit "$f does not match \[*\]";;
+esac
+
+if [[ $($SHELL -c '
+ x=$(case abc {
+ abc) { print yes;};;
+ *) print no;;
+ }
+ )
+ print -r -- "$x"' 2> /dev/null) != yes ]]
+then err_exit 'case abc {...} not working'
+fi
+[[ $($SHELL -c 'case a in
+a) print -n a > /dev/null ;&
+b) print b;;
+esac') != b ]] && err_exit 'bug in ;& at end of script'
+[[ $(VMDEBUG=1 $SHELL -c '
+ tmp=foo
+ for i in a b
+ do case $i in
+ a) : tmp=$tmp tmp.h=$tmp.h;;
+ b) ( tmp=bar )
+ for j in a
+ do print -r -- $tmp.h
+ done
+ ;;
+ esac
+ done
+') == foo.h ]] || err_exit "optimizer bug"
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/comvar.sh b/usr/src/lib/libshell/common/tests/comvar.sh
new file mode 100644
index 0000000000..5dc5c59a1c
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/comvar.sh
@@ -0,0 +1,197 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+#test for compound variables
+Command=${0##*/}
+integer Errors=0
+Point=(
+ float x=1. y=0.
+)
+eval p="$Point"
+if (( (p.x*p.x + p.y*p.y) > 1.01 ))
+then err_exit 'compound variable not working'
+fi
+nameref foo=p
+if [[ ${foo.x} != ${Point.x} ]]
+then err_exit 'reference to compound object not working'
+fi
+unset foo
+rec=(
+ name='Joe Blow'
+ born=(
+ month=jan
+ integer day=16
+ year=1980
+ )
+)
+eval newrec="$rec"
+if [[ ${newrec.name} != "${rec.name}" ]]
+then err_exit 'copying a compound object not working'
+fi
+if (( newrec.born.day != 16 ))
+then err_exit 'copying integer field of compound object not working'
+fi
+p_t=(
+ integer z=0
+ typeset -A tokens
+)
+unset x
+typeset -A x
+x=( [foo]=bar )
+if [[ ${x[@]} != bar ]]
+then err_exit 'compound assignemnt of associative arrays not working'
+fi
+unset -n foo x
+unset foo x
+foo=( x=3)
+nameref x=foo
+if [[ ${!x.@} != foo.x ]]
+then err_exit 'name references not expanded on prefix matching'
+fi
+unset x
+(
+ x=()
+ x.foo.bar=7
+ [[ ${x.foo.bar} == 7 ]] || err_exit '[[ ${x.foo.bar} != 7 ]]'
+ (( x.foo.bar == 7 ))|| err_exit '(( x.foo.bar != 7 ))'
+ [[ ${x.foo} == *bar=7* ]] || err_exit '[[ ${x.foo} != *bar=7* ]]'
+)
+foo=(integer x=3)
+if [[ ${foo} != *x=3* ]]
+then err_exit "compound variable with integer subvariable not working"
+fi
+$SHELL -c $'x=(foo=bar)\n[[ x == x ]]' 2> /dev/null ||
+ err_exit '[[ ... ]] not working after compound assignment'
+unset foo
+[[ ${!foo.@} ]] && err_exit 'unset compound variable leaves subvariables'
+suitable=(
+ label="Table Viewer"
+ langs="ksh"
+ uselang=ksh
+ launch=no
+ groups="default"
+ default=(
+ label="Table Viewer Preferences"
+ entrylist=" \
+ vieworigin viewsize viewcolor viewfontname viewfontsize \
+ showheader header showfooter footer showtitle title showlegends \
+ class_td_lg1_style class_tr_tr1_style \
+ class_th_th1_style class_td_td1_style \
+ fields fieldorder \
+ "
+ entries=(
+ vieworigin=(
+ type=coord var=vieworigin val="0 0" label="Window Position"
+ )
+ viewsize=(
+ type=coord var=viewsize val="400 400" label="Window Size"
+ )
+ viewcolor=(
+ type=2colors var=viewcolor val="gray black"
+ label="Window Colors"
+ )
+ viewfontname=(
+ type=fontname var=viewfontname val="Times-Roman"
+ label="Window Font Name"
+ )
+ viewfontsize=(
+ type=fontsize var=viewfontsize val=14 label="Window Font Size"
+ )
+
+ showheader=(
+ type=yesno var=showheader val=no label="Show Header"
+ )
+ header=(
+ type=text var=header val="" label="Header"
+ )
+
+ showfooter=(
+ type=yesno var=showfooter val=no label="Show Footer"
+ )
+ footer=(
+ type=text var=footer val="" label="Footer"
+ )
+
+ showtitle=(
+ type=yesno var=showtitle val=yes label="Show Title"
+ )
+ title=(
+ type=text var=title val="SWIFTUI - Table View" label="Title"
+ )
+
+ showlegends=(
+ type=yesno var=showlegends val=yes label="Show Legends"
+ )
+
+ class_td_lg1_style=(
+ type=style var=class_td_lg1_style
+ val="color: black; font-family: Times-Roman; font-size: 14pt"
+ label="Legend 1 Style"
+ )
+
+ class_tr_tr1_style=(
+ type=style var=class_tr_tr1_style val="background: black"
+ label="Table Row 1 Style"
+ )
+
+ class_th_th1_style=(
+ type=style var=class_th_th1_style
+ val="color: black; font-family: Times-Roman; font-size: 14pt; text-align: left"
+ label="Table Header 1 Style"
+ )
+
+ class_td_td1_style=(
+ type=style var=class_td_td1_style
+ val="color: black; font-family: Times-Roman; font-size: 14pt; text-align: left"
+ label="Table Cell 1 Style"
+ )
+
+ fields=(
+ type=text var=fields val= label="List of Fields"
+ )
+ fieldorder=(
+ type=text var=fieldorder val= label="Order of Fields"
+ )
+ )
+ )
+)
+[[ "${suitable}" == *entrylist=* ]] || err_exit 'compound variable expansion omitting fields'
+foo=( bar=foo barbar=bar)
+[[ $foo == *bar=foo* ]] || err_exit 'no prefix elements in compound variable output'
+function localvar
+{
+ typeset point=(typeset -i x=3 y=4)
+ (( (point.x*point.x + point.y*point.y) == 25 )) || err_exit "local compound variable not working"
+}
+point=(integer x=6 y=8)
+localvar
+ (( (point.x*point.x + point.y*point.y) == 100 )) || err_exit "global compound variable not preserved"
+[[ $($SHELL -c 'foo=();foo.[x]=(y z); print ${foo.x[@]}') == 'y z' ]] 2> /dev/null || err_exit 'foo=( [x]=(y z) not working'
+unset z
+( [[ ${z.foo.bar:-abc} == abc ]] 2> /dev/null) || err_exit ':- not working with compound variables'
+exit $((Errors))
+
diff --git a/usr/src/lib/libshell/common/tests/coprocess.sh b/usr/src/lib/libshell/common/tests/coprocess.sh
new file mode 100644
index 0000000000..5bbbdf759a
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/coprocess.sh
@@ -0,0 +1,218 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+# test the behavior of co-processes
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+integer Errors=0
+
+if [[ -d /cygdrive ]]
+then err_exit cygwin detected - coprocess tests disabled - enable at the risk of wedging your system
+ exit $((Errors))
+fi
+
+function ping # id
+{
+ integer x=0
+ while ((x < 5))
+ do read -r
+ print -r "$1 $REPLY"
+ done
+}
+
+cat |&
+print -p "hello"
+read -p line
+[[ $line == hello ]] || err_exit 'coprocessing fails'
+exec 5>&p 6<&p
+print -u5 'hello again' || err_exit 'write on u5 fails'
+read -u6 line
+[[ $line == 'hello again' ]] || err_exit 'coprocess after moving fds fails'
+exec 5<&- 6<&-
+
+ping three |&
+exec 3>&p
+ping four |&
+exec 4>&p
+ping pipe |&
+
+integer count
+for i in three four pipe four pipe four three pipe pipe three pipe
+do case $i in
+ three) to=-u3;;
+ four) to=-u4;;
+ pipe) to=-p;;
+ esac
+ count=count+1
+ print $to $i $count
+done
+
+while ((count > 0))
+do count=count-1
+ read -p
+# print -r - "$REPLY"
+ set -- $REPLY
+ if [[ $1 != $2 ]]
+ then err_exit "$1 does not match 2"
+ fi
+ case $1 in
+ three);;
+ four) ;;
+ pipe) ;;
+ *) err_exit "unknown message +|$REPLY|+"
+ esac
+done
+
+file=/tmp/regress$$
+trap "rm -f $file" EXIT
+cat > $file <<\!
+/bin/cat |&
+!
+chmod +x $file
+$file 2> /dev/null || err_exit "parent coprocess prevents script coprocess"
+exec 5<&p 6>&p
+exec 5<&- 6>&-
+${SHELL-ksh} |&
+print -p $'print hello | cat\nprint Done'
+read -t 5 -p
+read -t 5 -p
+if [[ $REPLY != Done ]]
+then err_exit "${SHELL-ksh} coprocess not working"
+fi
+exec 5<&p 6>&p
+exec 5<&- 6>&-
+count=0
+{
+echo line1 | grep 'line2'
+echo line2 | grep 'line1'
+} |&
+SECONDS=0
+while
+ read -p -t 10 line
+do
+ ((count = count + 1))
+ echo "Line $count: $line"
+done
+if (( SECONDS > 8 ))
+then err_exit 'read -p hanging'
+fi
+( sleep 3 |& sleep 1 && kill $!; sleep 1; sleep 3 |& sleep 1 && kill $! ) ||
+ err_exit "coprocess cleanup not working correctly"
+unset line
+(
+ integer n=0
+ while read line
+ do echo $line |&
+ if cat <&p
+ then ((n++))
+ wait $!
+ fi
+ done > /dev/null 2>&1 <<- !
+ line1
+ line2
+ line3
+ line4
+ line5
+ line6
+ line7
+ !
+ (( n==7 )) && print ok
+) | read -t 10 line
+if [[ $line != ok ]]
+then err_exit 'coprocess timing bug'
+fi
+(
+ /bin/cat |&
+ exec 6>&p
+ print -u6 ok
+ exec 6>&-
+ sleep 1
+ kill $! 2> /dev/null
+) && err_exit 'coprocess with subshell would hang'
+for sig in IOT ABRT
+do if ( trap - $sig ) 2> /dev/null
+ then if [[ $(
+ cat |&
+ pid=$!
+ trap "print TRAP" $sig
+ (
+ sleep 2
+ kill -$sig $$
+ sleep 2
+ kill -$sig $$
+ kill $pid
+ ) 2> /dev/null &
+ read -p
+ ) != $'TRAP\nTRAP' ]]
+ then err_exit 'traps when reading from coprocess not working'
+ fi
+ break
+ fi
+done
+
+trap 'sleep_pid=; kill $pid; err_exit "coprocess 1 hung"' TERM
+{ sleep 5; kill $$; } &
+sleep_pid=$!
+builtin cat
+cat |&
+pid=$!
+exec 5<&p 6>&p
+print -u6 hi; read -u5
+[[ $REPLY == hi ]] || err_exit 'REPLY is $REPLY not hi'
+exec 6>&-
+wait $pid
+trap - TERM
+[[ $sleep_pid ]] && kill $sleep_pid
+
+trap 'sleep_pid=; kill $pid; err_exit "coprocess 2 hung"' TERM
+{ sleep 5; kill $$; } &
+sleep_pid=$!
+cat |&
+pid=$!
+print foo >&p 2> /dev/null || err_exit 'first write of foo to coprocess failed'
+print foo >&p 2> /dev/null || err_exit 'second write of foo to coprocess failed'
+kill $pid
+wait $pid 2> /dev/null
+trap - TERM
+[[ $sleep_pid ]] && kill $sleep_pid
+
+trap 'sleep_pid=; kill $pid; err_exit "coprocess 3 hung"' TERM
+{ sleep 5; kill $$; } &
+sleep_pid=$!
+cat |&
+pid=$!
+print -p foo
+print -p bar
+read <&p || err_exit 'first read from coprocess failed'
+[[ $REPLY == foo ]] || err_exit "first REPLY is $REPLY not foo"
+read <&p || err_exit 'second read from coprocess failed'
+[[ $REPLY == bar ]] || err_exit "second REPLY is $REPLY not bar"
+kill $pid
+wait $pid 2> /dev/null
+trap - TERM
+[[ $sleep_pid ]] && kill $sleep_pid
+
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/exit.sh b/usr/src/lib/libshell/common/tests/exit.sh
new file mode 100644
index 0000000000..b099ccfecc
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/exit.sh
@@ -0,0 +1,81 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+function abspath
+{
+ base=$(basename $SHELL)
+ cd ${SHELL%/$base}
+ newdir=$(pwd)
+ cd ~-
+ print $newdir/$base
+}
+#test for proper exit of shell
+Command=${0##*/}
+integer Errors=0
+builtin getconf
+ABSHELL=$(abspath)
+mkdir /tmp/ksh$$ || err_exit "mkdir /tmp/ksh$$ failed"
+cd /tmp/ksh$$ || err_exit "cd /tmp/ksh$$ failed"
+print exit 0 >.profile
+${ABSHELL} <<!
+HOME=$PWD \
+PATH=$PATH \
+SHELL=$ABSSHELL \
+$(
+ set --noglob
+ ifs=$IFS
+ IFS=,
+ set -- $(getconf LIBPATH)
+ IFS=$ifs
+ for v
+ do IFS=:
+ set -- $v
+ IFS=$ifs
+ eval [[ \$$2 ]] && eval print -n \" \"\$2=\"\$$2\"
+ done
+) \
+exec -c -a -ksh ${ABSHELL} -c "exit 1" 1>/dev/null 2>&1
+!
+status=$(echo $?)
+if [[ -o noprivileged && $status != 0 ]]
+then err_exit 'exit in .profile is ignored'
+elif [[ -o privileged && $status == 0 ]]
+then err_exit 'privileged .profile not ignored'
+fi
+if [[ $(trap 'code=$?; echo $code; trap 0; exit $code' 0; exit 123) != 123 ]]
+then err_exit 'exit not setting $?'
+fi
+cat > run.sh <<- "EOF"
+ trap 'code=$?; echo $code; trap 0; exit $code' 0
+ ( trap 0; exit 123 )
+EOF
+if [[ $($SHELL ./run.sh) != 123 ]]
+then err_exit 'subshell trap on exit overwrites parent trap'
+fi
+cd ~- || err_exit "cd back failed"
+rm -r /tmp/ksh$$ || err_exit "rm -r /tmp/ksh$$ failed"
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/expand.sh b/usr/src/lib/libshell/common/tests/expand.sh
new file mode 100644
index 0000000000..70018b1feb
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/expand.sh
@@ -0,0 +1,123 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$Line]: "$@"
+ ((Errors++))
+}
+
+integer Errors=0
+Command=${0##*/}
+
+# {...} expansion tests -- ignore if not supported
+
+[[ $(print a{0,1}z) == "a0z a1z" ]] || exit 0
+
+integer Line=$LINENO+1
+set -- \
+ 'ff{c,b,a}' 'ffc ffb ffa' \
+ 'f{d,e,f}g' 'fdg feg ffg' \
+ '{l,n,m}xyz' 'lxyz nxyz mxyz' \
+ '{abc\,def}' '{abc,def}' \
+ '{abc}' '{abc}' \
+ '\{a,b,c,d,e}' '{a,b,c,d,e}' \
+ '{x,y,\{a,b,c}}' 'x} y} {a} b} c}' \
+ '{x\,y,\{abc\},trie}' 'x,y {abc} trie' \
+ '/usr/{ucb/{ex,edit},lib/{ex,how_ex}}' '/usr/ucb/ex /usr/ucb/edit /usr/lib/ex /usr/lib/how_ex' \
+ 'XXXX\{a,b,c\}' 'XXXX{a,b,c}' \
+ '{}' '{}' \
+ '{ }' '{ }' \
+ '}' '}' \
+ '{' '{' \
+ 'abcd{efgh' 'abcd{efgh' \
+ 'foo {1,2} bar' 'foo 1 2 bar' \
+ '`print -r -- foo {1,2} bar`' 'foo 1 2 bar' \
+ '$(print -r -- foo {1,2} bar)' 'foo 1 2 bar' \
+ '{1..10}' '1 2 3 4 5 6 7 8 9 10' \
+ '{0..10,braces}' '0..10 braces' \
+ '{{0..10},braces}' '0 1 2 3 4 5 6 7 8 9 10 braces' \
+ 'x{{0..10},braces}y' 'x0y x1y x2y x3y x4y x5y x6y x7y x8y x9y x10y xbracesy' \
+ '{3..3}' '3' \
+ 'x{3..3}y' 'x3y' \
+ '{10..1}' '10 9 8 7 6 5 4 3 2 1' \
+ '{10..1}y' '10y 9y 8y 7y 6y 5y 4y 3y 2y 1y' \
+ 'x{10..1}y' 'x10y x9y x8y x7y x6y x5y x4y x3y x2y x1y' \
+ '{a..f}' 'a b c d e f' \
+ '{f..a}' 'f e d c b a' \
+ '{a..A}' '{a..A}' \
+ '{A..a}' '{A..a}' \
+ '{f..f}' 'f' \
+ '{1..f}' '{1..f}' \
+ '{f..1}' '{f..1}' \
+ '0{1..9} {10..20}' '01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20' \
+ '{-1..-10}' '-1 -2 -3 -4 -5 -6 -7 -8 -9 -10' \
+ '{-19..0}' '-19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0' \
+ '{0..10}' '0 1 2 3 4 5 6 7 8 9 10' \
+ '{0..10..1}' '0 1 2 3 4 5 6 7 8 9 10' \
+ '{0..10..2}' '0 2 4 6 8 10' \
+ '{0..10..3}' '0 3 6 9' \
+ '{0..10..0}' '{0..10..0}' \
+ '{0..10..-1}' '0' \
+ '{10..0}' '10 9 8 7 6 5 4 3 2 1 0' \
+ '{10..0..-1}' '10 9 8 7 6 5 4 3 2 1 0' \
+ '{10..0..-2}' '10 8 6 4 2 0' \
+ '{10..0..-3}' '10 7 4 1' \
+ '{10..0..0}' '{10..0..0}' \
+ '{10..0..1}' '10' \
+ '{a..z..2}' 'a c e g i k m o q s u w y' \
+ '{y..b..-3}' 'y v s p m j g d' \
+ '{0..0x1000..0x200}' '0 512 1024 1536 2048 2560 3072 3584 4096' \
+ '{a,b}{0..2}{z,y}' 'a0z a0y a1z a1y a2z a2y b0z b0y b1z b1y b2z b2y' \
+ '{0..0100..8%03o}' '000 010 020 030 040 050 060 070 100' \
+ '{0..0100..040%020o}' '00000000000000000000 00000000000000000040 00000000000000000100' \
+ '{0..7%03..2u}' '000 001 010 011 100 101 110 111' \
+ '{0..10%llu}' '{0..10%llu}' \
+ '{0..10%s}' '{0..10%s}' \
+ '{0..10%dl}' '{0..10%dl}' \
+ '{a,b}{0..3%02..2u}{y,z}' 'a00y a00z a01y a01z a10y a10z a11y a11z b00y b00z b01y b01z b10y b10z b11y b11z' \
+
+while (($#>1))
+do ((Line++))
+ pattern=$1
+ shift
+ expected=$1
+ shift
+ got=$(eval print -r -- "$pattern")
+ [[ $got == $expected ]] || err_exit "'$pattern' failed -- expected '$expected' got '$got'"
+ #print -r -- " '$pattern' '$got' \\"
+done
+
+# ~(N) no expand glob pattern option
+set -- ~(N)/dev/null
+[[ $# == 1 && $1 == /dev/null ]] || err_exit "~(N)/dev/null not matching /dev/null"
+set -- ~(N)/dev/non_existant_file
+[[ $# == 0 ]] || err_exit "~(N)/dev/nonexistant not empty"
+set -- ""~(N)/dev/non_existant_file
+[[ $# == 1 && ! $1 ]] || err_exit '""~(N)/dev/nonexistant not null argument'
+set -- ~(N)/dev/non_existant_file""
+[[ $# == 1 && ! $1 ]] || err_exit '~(N)/dev/nonexistent"" not null argument'
+for i in ~(N)/dev/non_existent_file
+do err_exit "~(N)/dev/non_existent_file in for loop is $i"
+done
+for i in ""~(N)/dev/non_existent_file
+do [[ ! $i ]] || err_exit '""~(N)/dev/non_existent_file not null'
+done
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/functions.sh b/usr/src/lib/libshell/common/tests/functions.sh
new file mode 100644
index 0000000000..fd45cd1767
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/functions.sh
@@ -0,0 +1,758 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+integer Errors=0
+Command=${0##*/}
+integer foo=33
+bar=bye
+# check for global variables and $0
+function foobar
+{
+ case $1 in
+ 1) print -r - "$foo" "$bar";;
+ 2) print -r - "$0";;
+ 3) typeset foo=foo
+ integer bar=10
+ print -r - "$foo" "$bar";;
+ 4) trap 'foo=36' EXIT
+ typeset foo=20;;
+ esac
+}
+function print
+{
+ command print hi
+}
+if [[ $(print) != hi ]]
+then err_exit "command print not working inside print function"
+fi
+unset -f print
+
+if [[ $(foobar 1) != '33 bye' ]]
+then err_exit 'global variables not correct'
+fi
+
+if [[ $(foobar 2) != 'foobar' ]]
+then err_exit '$0 not correct'
+fi
+
+if [[ $(bar=foo foobar 1) != '33 foo' ]]
+then err_exit 'environment override not correct'
+fi
+if [[ $bar == foo ]]
+then err_exit 'scoping error'
+fi
+
+if [[ $(foobar 3) != 'foo 10' ]]
+then err_exit non-local variables
+fi
+
+foobar 4
+if [[ $foo != 36 ]]
+then err_exit EXIT trap in wrong scope
+fi
+unset -f foobar || err_exit "cannot unset function foobar"
+typeset -f foobar>/dev/null && err_exit "typeset -f has incorrect exit status"
+
+function foobar
+{
+ (return 0)
+}
+> /tmp/shtests$$.1
+{
+foobar
+if [ -r /tmp/shtests$$.1 ]
+then rm -r /tmp/shtests$$.1
+else err_exit 'return within subshell inside function error'
+fi
+}
+abc() print hi
+if [[ $(abc) != hi ]]
+then err_exit 'abc() print hi not working'
+fi
+( unset -f abc )
+if [[ $(abc 2>/dev/null) != hi ]]
+then err_exit 'abc() print hi not working after subshell unset'
+fi
+(
+ function f
+ {
+ exit 1
+ }
+ f
+ err_exit 'exit from function not working'
+)
+unset -f foo
+function foo
+{
+ x=2
+ (
+ x=3
+ cd /tmp
+ print bar
+ )
+ if [[ $x != 2 ]]
+ then err_exit 'value of x not restored after subshell inside function'
+ fi
+}
+x=1
+dir=$PWD
+if [[ $(foo) != bar ]]
+then err_exit 'cd inside nested subshell not working'
+fi
+if [[ $PWD != "$dir" ]]
+then err_exit 'cd inside nested subshell changes $PWD'
+fi
+fun() /bin/echo hello
+if [[ $(fun) != hello ]]
+then err_exit one line functions not working
+fi
+trap 'rm -f /tmp/script$$ /tmp/data$$.[12]' EXIT
+cat > /tmp/script$$ <<-\!
+ print -r -- "$1"
+!
+chmod +x /tmp/script$$
+function passargs
+{
+ /tmp/script$$ "$@"
+}
+if [[ $(passargs one) != one ]]
+then err_exit 'passing args from functions to scripts not working'
+fi
+cat > /tmp/script$$ <<-\!
+ trap 'exit 0' EXIT
+ function foo
+ {
+ /tmp > /dev/null 2>&1
+ }
+ foo
+!
+if ! /tmp/script$$
+then err_exit 'exit trap incorrectly triggered'
+fi
+if ! $SHELL -c /tmp/script$$
+then err_exit 'exit trap incorrectly triggered when invoked with -c'
+fi
+$SHELL -c "trap 'rm /tmp/script$$' EXIT"
+if [[ -f /tmp/script$$ ]]
+then err_exit 'exit trap not triggered when invoked with -c'
+fi
+cat > /tmp/script$$ <<- \EOF
+ foobar()
+ {
+ return
+ }
+ shift
+ foobar
+ print -r -- "$1"
+EOF
+chmod +x /tmp/script$$
+if [[ $( $SHELL /tmp/script$$ arg1 arg2) != arg2 ]]
+then err_exit 'arguments not restored by posix functions'
+fi
+function foo
+{
+ print hello
+}
+(
+ function foo
+ {
+ print bar
+ }
+ if [[ $(foo) != bar ]]
+ then err_exit 'function definitions inside subshells not working'
+ fi
+)
+if [[ $(foo) != hello ]]
+then err_exit 'function definitions inside subshells not restored'
+fi
+unset -f foo bar
+function bar
+{
+ print "$y"
+}
+
+function foo
+{
+ typeset x=3
+ y=$x bar
+}
+x=1
+if [[ $(foo) != 3 ]]
+then err_exit 'variable assignment list not using parent scope'
+fi
+unset -f foo$$
+trap "rm -f /tmp/foo$$" EXIT INT
+cat > /tmp/foo$$ <<!
+function foo$$
+{
+ print foo
+}
+!
+chmod +x /tmp/foo$$
+FPATH=/tmp
+autoload foo$$
+if [[ $(foo$$ 2>/dev/null) != foo ]]
+then err_exit 'autoload not working'
+fi
+unset -f foobar
+function foobar
+{
+ typeset -r x=3
+ return 0
+}
+( foobar ) 2> /dev/null || err_exit "cannot unset readonly variable in function"
+if $SHELL -n 2> /dev/null <<-!
+ abc()
+ !
+then err_exit 'abc() without a function body is not a syntax error'
+fi
+function winpath
+{
+ usage='q pathname ...'
+ typeset var format=s
+ while getopts "$usage" var
+ do case $var in
+ q) format=q;;
+ esac
+ done
+ print done
+}
+if [[ $( (winpath --man 2>/dev/null); print ok) != ok ]]
+then err_exit 'getopts --man in functions not working'
+fi
+if [[ $( (winpath -z 2>/dev/null); print ok) != ok ]]
+then err_exit 'getopts with bad option in functions not working'
+fi
+unset -f x
+function x
+{
+ print "$@"
+}
+typeset -ft x
+if [[ $(x x=y 2>/dev/null) != x=y ]]
+then err_exit 'name=value pair args not passed to traced functions'
+fi
+function bad
+{
+ false
+}
+trap 'val=false' ERR
+val=true
+bad
+if [[ $val != false ]]
+then err_exit 'set -e not working for functions'
+fi
+function bad
+{
+ false
+ return 0
+}
+val=true
+bad
+if [[ $val != true ]]
+then err_exit 'set -e not disabled for functions'
+fi
+bad()
+{
+ false
+ return 0
+}
+val=true
+bad
+if [[ $val != false ]]
+then err_exit 'set -e not inherited for posix functions'
+fi
+function myexport
+{
+ nameref var=$1
+ if (( $# > 1 ))
+ then export $1=$2
+ fi
+ if (( $# > 2 ))
+ then print $(myexport "$1" "$3" )
+ return
+ fi
+ typeset val
+ val=$(export | grep "^$1=")
+ print ${val#"$1="}
+
+}
+export dgk=base
+if [[ $(myexport dgk fun) != fun ]]
+then err_exit 'export inside function not working'
+fi
+val=$(export | grep "^dgk=")
+if [[ ${val#dgk=} != base ]]
+then err_exit 'export not restored after function call'
+fi
+if [[ $(myexport dgk fun fun2) != fun2 ]]
+then err_exit 'export inside function not working with recursive function'
+fi
+val=$(export | grep "^dgk=")
+if [[ ${val#dgk=} != base ]]
+then err_exit 'export not restored after recursive function call'
+fi
+if [[ $(dgk=try3 myexport dgk) != try3 ]]
+then err_exit 'name=value not added to export list with function call'
+fi
+val=$(export | grep "^dgk=")
+if [[ ${val#dgk=} != base ]]
+then err_exit 'export not restored name=value function call'
+fi
+unset zzz
+if [[ $(myexport zzz fun) != fun ]]
+then err_exit 'export inside function not working for zzz'
+fi
+if [[ $(export | grep "zzz=") ]]
+then err_exit 'zzz exported after function call'
+fi
+unset zzz
+typeset -u zzz
+function foo
+{
+ zzz=abc
+ print $zzz
+}
+if [[ $(foo)$(foo) != ABCABC ]]
+then err_exit 'attributes on unset variables not saved/restored'
+fi
+function xpd {
+ typeset i j=$1
+ for i
+ do print i=$i j=$j
+ [[ $i == a ]] && xpd b
+ done
+ }
+if [[ $(xpd a c) != $'i=a j=a\ni=b j=b\ni=c j=a' ]]
+then err_exit 'for loop function optimization error'
+fi
+
+typeset -A visited
+integer level=0
+function closure
+{
+ (( $# > 5 )) && return 1
+ ((level < 2)) && ((level++))
+ typeset tmp r=0
+ visited[$1]=1
+
+ for tmp in $level _$level
+ do
+ [[ ${visited[$tmp]} == 1 ]] && continue
+ closure $tmp $* || r=1
+ done
+ return $r
+}
+closure 0 || err_exit -u2 'for loop function optimization bug2'
+mkdir /tmp/ksh$$ || err_exit "mkdir /tmp/ksh$$ failed"
+cd /tmp/ksh$$ || err_exit "cd /tmp/ksh$$ failed"
+print 'false' > try
+chmod +x try
+cat > tst <<- EOF
+ function ignore
+ {
+ ./try
+ return 0
+ }
+ trap "print error; exit 1" ERR
+ ignore
+EOF
+if [[ $($SHELL < tst) == error ]]
+then err_exit 'ERR trap not cleared'
+fi
+FPATH=/tmp/ksh$$
+print ': This does nothing' > /tmp/ksh$$/foobar
+chmod +x /tmp/ksh$$/foobar
+unset -f foobar
+{ foobar;} 2> /dev/null
+if [[ $? != 126 ]]
+then err_exit 'function file without function definition processes wrong error'
+fi
+print 'set a b c' > dotscript
+[[ $(PATH=$PATH: $SHELL -c '. dotscript;print $#') == 3 ]] || err_exit 'positional parameters not preserved with . script without arguments'
+cd ~- || err_exit "cd back failed"
+cd /; rm -r /tmp/ksh$$ || err_exit "rm -r /tmp/ksh$$ failed"
+function errcheck
+{
+ trap 'print ERR; return 1' ERR
+ false
+ print ok
+}
+err=$(errcheck)
+[[ $err == ERR ]] || err_exit 'trap on ERR not working in a function'
+x="$(
+ function foobar
+ {
+ print ok
+ }
+ typeset -f foobar
+)"
+eval "$x" || err_exit 'typeset -f generates syntax error'
+[[ $(foobar) != ok ]] && err_exit 'typeset -f not generating function'
+unset -f a b c
+a()
+{
+ b
+ b
+ print ${.sh.fun}
+}
+b() { : ;}
+[[ $(a) == a ]] || err_exit '.sh.fun not set correctly in a function'
+print $'a(){\ndate\n}' | $SHELL 2> /dev/null || err_exit 'parser error in a(){;date;}'
+cat > /tmp/data$$.1 << '++EOF'
+ 1 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ 2 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ 3 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ 4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ 5 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ 6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ 7 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ 8 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ 9 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ 10 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ 11 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ 12 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ 13 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ 14 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ 15 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ 16 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ 17 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ 18 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ 19 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ 20 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+++EOF
+cat > /tmp/script$$ << '++EOF'
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+
+f()
+{
+cat <<\M
+++EOF
+cat /tmp/data$$.1 >> /tmp/script$$
+printf 'M\n}\n\nf\n\n' >> /tmp/script$$
+$SHELL -c /tmp/script$$ > /tmp/data$$.2
+cmp -s /tmp/data$$.[12] || err_exit 'error with long functions'
+rm -f /tmp/script$$ /tmp/data$$.[12]
+v=1
+function f
+{
+ typeset i
+ for i in 0 1
+ do typeset v
+ v=$i
+ [[ $v == $i ]] || return 1
+ done
+}
+f || err_exit "typeset optimization bug"
+function f
+{
+ print -r -- "$foo$bar"
+}
+function g
+{
+ print -r -- $(bar=bam f)
+}
+unset foo bar
+[[ $(foo=hello g) == hellobam ]] || err_exit 'function exports not passed on'
+[[ $(bar=hello g) == bam ]] || err_exit 'function exports not overridden'
+unset -f foo
+function foo
+{
+ typeset line=$1
+ set +n
+ while [[ $line ]]
+ do if [[ ! $varname ]]
+ then varname=${line%% *}
+ line=${line##"$varname"?( )}
+ [[ $line ]] && continue
+ else print ok
+ return
+ fi
+ varname=
+ done
+}
+[[ $(foo 'NUMBERED RECORDSIZE') == ok ]] || err_exit 'optimization error with undefined variable'
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/glob.sh b/usr/src/lib/libshell/common/tests/glob.sh
new file mode 100644
index 0000000000..4d5fa0b519
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/glob.sh
@@ -0,0 +1,303 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ ((errors++))
+}
+alias err_exit='err_exit $LINENO'
+
+integer aware=0 contrary=0 ignorant=0
+
+function test_glob
+{
+ typeset lineno expected drop arg got sep op val add del
+ if [[ $1 == --* ]]
+ then del=${1#--}
+ shift
+ fi
+ if [[ $1 == ++* ]]
+ then add=${1#++}
+ shift
+ fi
+ lineno=$1 expected=$2
+ shift 2
+ if (( contrary ))
+ then if [[ $expected == "<Beware> "* ]]
+ then expected=${expected#"<Beware> "}
+ expected="$expected <Beware>"
+ fi
+ if [[ $expected == *"<aXb> <abd>"* ]]
+ then expected=${expected/"<aXb> <abd>"/"<abd> <aXb>"}
+ fi
+ fi
+ for arg
+ do got="$got$sep<$arg>"
+ sep=" "
+ done
+ if (( ignorant && aware ))
+ then if [[ $del ]]
+ then got="<$del> $got"
+ fi
+ if [[ $add ]]
+ then expected="<$add> $expected"
+ fi
+ fi
+ if [[ $got != "$expected" ]]
+ then err_exit $lineno "glob: got '$got' expected '$expected'"
+ fi
+}
+
+function test_case
+{
+ typeset lineno expected subject pattern got
+ lineno=$1 expected=$2 subject=$3 pattern=$4
+ eval "
+ case $subject in
+ $pattern) got='<match>' ;;
+ *) got='<nomatch>' ;;
+ esac
+ "
+ if [[ $got != "$expected" ]]
+ then err_exit $lineno "case $subject in $pattern) got '$got' expected '$expected'"
+ fi
+}
+
+Command=${0##*/}
+tmp=/tmp/ksh$$
+integer errors=0
+unset undefined
+
+export LC_COLLATE=C
+
+mkdir $tmp || err_exit $LINENO "mkdir $tmp failed"
+trap "cd /; rm -rf $tmp" EXIT
+cd $tmp || err_exit $LINENO "cd $tmp failed"
+rm -rf *
+
+touch B b
+set -- *
+case $* in
+'b B') contrary=1 ;;
+b|B) ignorant=1 ;;
+esac
+set -- $(/bin/sh -c 'echo [a-c]')
+case $* in
+B) aware=1 ;;
+esac
+rm -rf *
+
+touch a b c d abc abd abe bb bcd ca cb dd de Beware
+mkdir bdir
+
+test_glob $LINENO '<a> <abc> <abd> <abe> <X*>' a* X*
+test_glob $LINENO '<a> <abc> <abd> <abe>' \a*
+
+if ( set --nullglob ) 2>/dev/null
+then
+ set --nullglob
+
+ test_glob $LINENO '<a> <abc> <abd> <abe>' a* X*
+
+ set --nonullglob
+fi
+
+if ( set --failglob ) 2>/dev/null
+then
+ set --failglob
+ mkdir tmp
+ touch tmp/l1 tmp/l2 tmp/l3
+
+ test_glob $LINENO '' tmp/l[12] tmp/*4 tmp/*3
+ test_glob $LINENO '' tmp/l[12] tmp/*4 tmp/*3
+
+ rm -r tmp
+ set --nofailglob
+fi
+
+test_glob $LINENO '<bdir/>' b*/
+test_glob $LINENO '<*>' \*
+test_glob $LINENO '<a*>' 'a*'
+test_glob $LINENO '<a*>' a\*
+test_glob $LINENO '<c> <ca> <cb> <a*> <*q*>' c* a\* *q*
+test_glob $LINENO '<**>' "*"*
+test_glob $LINENO '<**>' \**
+test_glob $LINENO '<\.\./*/>' "\.\./*/"
+test_glob $LINENO '<s/\..*//>' 's/\..*//'
+test_glob $LINENO '</^root:/{s/^[!:]*:[!:]*:\([!:]*\).*$/\1/>' "/^root:/{s/^[!:]*:[!:]*:\([!:]*\).*"'$'"/\1/"
+test_glob $LINENO '<abc> <abd> <abe> <bb> <cb>' [a-c]b*
+test_glob ++Beware $LINENO '<abd> <abe> <bb> <bcd> <bdir> <ca> <cb> <dd> <de>' [a-y]*[!c]
+test_glob $LINENO '<abd> <abe>' a*[!c]
+
+touch a-b aXb
+
+test_glob $LINENO '<a-b> <aXb>' a[X-]b
+
+touch .x .y
+
+test_glob --Beware $LINENO '<Beware> <d> <dd> <de>' [!a-c]*
+
+if mkdir a\*b 2>/dev/null
+then
+ touch a\*b/ooo
+
+ test_glob $LINENO '<a*b/ooo>' a\*b/*
+ test_glob $LINENO '<a*b/ooo>' a\*?/*
+ test_case $LINENO '<match>' '!7' '*\!*'
+ test_case $LINENO '<match>' 'r.*' '*.\*'
+ test_glob $LINENO '<abc>' a[b]c
+ test_glob $LINENO '<abc>' a["b"]c
+ test_glob $LINENO '<abc>' a[\b]c
+ test_glob $LINENO '<abc>' a?c
+ test_case $LINENO '<match>' 'abc' 'a"b"c'
+ test_case $LINENO '<match>' 'abc' 'a*c'
+ test_case $LINENO '<nomatch>' 'abc' '"a?c"'
+ test_case $LINENO '<nomatch>' 'abc' 'a\*c'
+ test_case $LINENO '<nomatch>' 'abc' 'a\[b]c'
+ test_case $LINENO '<match>' '"$undefined"' '""'
+ test_case $LINENO '<match>' 'abc' 'a["\b"]c'
+
+ rm -rf mkdir a\*b
+fi
+
+mkdir man
+mkdir man/man1
+touch man/man1/sh.1
+
+test_glob $LINENO '<man/man1/sh.1>' */man*/sh.*
+test_glob $LINENO '<man/man1/sh.1>' $(echo */man*/sh.*)
+test_glob $LINENO '<man/man1/sh.1>' "$(echo */man*/sh.*)"
+
+test_case $LINENO '<match>' 'abc' 'a***c'
+test_case $LINENO '<match>' 'abc' 'a*****?c'
+test_case $LINENO '<match>' 'abc' '?*****??'
+test_case $LINENO '<match>' 'abc' '*****??'
+test_case $LINENO '<match>' 'abc' '*****??c'
+test_case $LINENO '<match>' 'abc' '?*****?c'
+test_case $LINENO '<match>' 'abc' '?***?****c'
+test_case $LINENO '<match>' 'abc' '?***?****?'
+test_case $LINENO '<match>' 'abc' '?***?****'
+test_case $LINENO '<match>' 'abc' '*******c'
+test_case $LINENO '<match>' 'abc' '*******?'
+test_case $LINENO '<match>' 'abcdecdhjk' 'a*cd**?**??k'
+test_case $LINENO '<match>' 'abcdecdhjk' 'a**?**cd**?**??k'
+test_case $LINENO '<match>' 'abcdecdhjk' 'a**?**cd**?**??k***'
+test_case $LINENO '<match>' 'abcdecdhjk' 'a**?**cd**?**??***k'
+test_case $LINENO '<match>' 'abcdecdhjk' 'a**?**cd**?**??***k**'
+test_case $LINENO '<match>' 'abcdecdhjk' 'a****c**?**??*****'
+test_case $LINENO '<match>' "'-'" '[-abc]'
+test_case $LINENO '<match>' "'-'" '[abc-]'
+test_case $LINENO '<match>' "'\\'" '\\'
+test_case $LINENO '<match>' "'\\'" '[\\]'
+test_case $LINENO '<match>' "'\\'" "'\\'"
+test_case $LINENO '<match>' "'['" '[[]'
+test_case $LINENO '<match>' '[' '[[]'
+test_case $LINENO '<match>' "'['" '['
+test_case $LINENO '<match>' '[' '['
+test_case $LINENO '<match>' "'[abc'" "'['*"
+test_case $LINENO '<nomatch>' "'[abc'" '[*'
+test_case $LINENO '<match>' '[abc' "'['*"
+test_case $LINENO '<nomatch>' '[abc' '[*'
+test_case $LINENO '<match>' 'abd' "a[b/c]d"
+test_case $LINENO '<match>' 'a/d' "a[b/c]d"
+test_case $LINENO '<match>' 'acd' "a[b/c]d"
+test_case $LINENO '<match>' "']'" '[]]'
+test_case $LINENO '<match>' "'-'" '[]-]'
+test_case $LINENO '<match>' 'p' '[a-\z]'
+test_case $LINENO '<match>' '"/tmp"' '[/\\]*'
+test_case $LINENO '<nomatch>' 'abc' '??**********?****?'
+test_case $LINENO '<nomatch>' 'abc' '??**********?****c'
+test_case $LINENO '<nomatch>' 'abc' '?************c****?****'
+test_case $LINENO '<nomatch>' 'abc' '*c*?**'
+test_case $LINENO '<nomatch>' 'abc' 'a*****c*?**'
+test_case $LINENO '<nomatch>' 'abc' 'a********???*******'
+test_case $LINENO '<nomatch>' "'a'" '[]'
+test_case $LINENO '<nomatch>' 'a' '[]'
+test_case $LINENO '<nomatch>' "'['" '[abc'
+test_case $LINENO '<nomatch>' '[' '[abc'
+
+test_glob ++Beware $LINENO '<b> <bb> <bcd> <bdir>' b*
+test_glob $LINENO '<Beware> <b> <bb> <bcd> <bdir>' [bB]*
+
+if ( set --nocaseglob ) 2>/dev/null
+then
+ set --nocaseglob
+
+ test_glob $LINENO '<Beware> <b> <bb> <bcd> <bdir>' b*
+ test_glob $LINENO '<Beware> <b> <bb> <bcd> <bdir>' [b]*
+ test_glob $LINENO '<Beware> <b> <bb> <bcd> <bdir>' [bB]*
+
+ set --nonocaseglob
+fi
+
+if ( set -f ) 2>/dev/null
+then
+ set -f
+
+ test_glob $LINENO '<*>' *
+
+ set +f
+fi
+
+if ( set --noglob ) 2>/dev/null
+then
+ set --noglob
+
+ test_glob $LINENO '<*>' *
+
+ set --glob
+fi
+
+FIGNORE='.*|*'
+test_glob $LINENO '<*>' *
+
+FIGNORE='.*|*c|*e|?'
+test_glob $LINENO '<a-b> <aXb> <abd> <bb> <bcd> <bdir> <ca> <cb> <dd> <man>' *
+
+FIGNORE='.*|*b|*d|?'
+test_glob $LINENO '<Beware> <abc> <abe> <bdir> <ca> <de> <man>' *
+
+FIGNORE=
+test_glob $LINENO '<man/man1/sh.1>' */man*/sh.*
+
+unset FIGNORE
+test_glob $LINENO '<bb> <ca> <cb> <dd> <de>' ??
+test_glob $LINENO '<man/man1/sh.1>' */man*/sh.*
+
+GLOBIGNORE='.*:*'
+set -- *
+if [[ $1 == '*' ]]
+then
+ GLOBIGNORE='.*:*c:*e:?'
+ test_glob $LINENO '<>' *
+
+ GLOBIGNORE='.*:*b:*d:?'
+ test_glob $LINENO '<>' *
+
+ unset GLOBIGNORE
+ test_glob $LINENO '<>' *
+ test_glob $LINENO '<man/man1/sh.1>' */man*/sh.*
+
+ GLOBIGNORE=
+ test_glob $LINENO '<man/man1/sh.1>' */man*/sh.*
+fi
+
+exit $errors
diff --git a/usr/src/lib/libshell/common/tests/grep.sh b/usr/src/lib/libshell/common/tests/grep.sh
new file mode 100644
index 0000000000..db20206dbf
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/grep.sh
@@ -0,0 +1,102 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+integer Errors=0
+
+function grep
+{
+ #
+ # SHELL VERSION OF GREP
+ #
+ vflag= xflag= cflag= lflag= nflag=
+ set -f
+ while ((1)) # look for grep options
+ do case "$1" in
+ -v*) vflag=1;;
+ -x*) xflag=1;;
+ -c*) cflag=1;;
+ -l*) lflag=1;;
+ -n*) nflag=1;;
+ -b*) print 'b option not supported';;
+ -e*) shift;expr="$1";;
+ -f*) shift;expr=$(< $1);;
+ -*) print $0: 'unknown flag';return 2;;
+ *)
+ if test "$expr" = ''
+ then expr="$1";shift
+ fi
+ test "$xflag" || expr="*${expr}*"
+ break;;
+ esac
+ shift # next argument
+ done
+ noprint=$vflag$cflag$lflag # don't print if these flags are set
+ integer n=0 c=0 tc=0 nargs=$# # initialize counters
+ for i in "$@" # go thru the files
+ do if ((nargs<=1))
+ then fname=''
+ else fname="$i":
+ fi
+ test "$i" && exec 0< $i # open file if necessary
+ while read -r line # read in a line
+ do let n=n+1
+ case "$line" in
+ $expr) # line matches pattern
+ test "$noprint" || print -r -- "$fname${nflag:+$n:}$line"
+ let c=c+1 ;;
+ *) # not a match
+ if test "$vflag"
+ then print -r -- "$fname${nflag:+$n:}$line"
+ fi;;
+ esac
+ done
+ if test "$lflag" && ((c))
+ then print -r -- "$i"
+ fi
+ let tc=tc+c n=0 c=0
+ done
+ test "$cflag" && print $tc # print count if cflag is set
+ let tc # set the return value
+}
+
+trap 'rm -f /tmp/grep$$' EXIT
+cat > /tmp/grep$$ <<\!
+this is a food bar test
+to see how many lines find both foo and bar.
+Some line contain foo only,
+and some lines contain bar only.
+However, many lines contain both foo and also bar.
+A line containing foobar should also be counted.
+There should be six lines with foo and bar.
+There are only two line with out foo but with bar.
+!
+
+if (( $(grep -c 'foo*bar' /tmp/grep$$ ) != 6))
+then err_exit
+fi
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/heredoc.sh b/usr/src/lib/libshell/common/tests/heredoc.sh
new file mode 100644
index 0000000000..53835f2007
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/heredoc.sh
@@ -0,0 +1,213 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+integer Errors=0
+f=/tmp/here1$$
+g=/tmp/here2$$
+trap "rm -f $f $g" EXIT
+cat > $f <<!
+hello world
+!
+if [[ $(<$f) != 'hello world' ]]
+then err_exit "'hello world' here doc not working"
+fi
+cat > $g <<\!
+hello world
+!
+cmp $f $g 2> /dev/null || err_exit "'hello world' quoted here doc not working"
+cat > $g <<- !
+ hello world
+!
+cmp $f $g 2> /dev/null || err_exit "'hello world' tabbed here doc not working"
+cat > $g <<- \!
+ hello world
+!
+cmp $f $g 2> /dev/null || err_exit "'hello world' quoted tabbed here doc not working"
+x=hello
+cat > $g <<!
+$x world
+!
+cmp $f $g 2> /dev/null || err_exit "'$x world' here doc not working"
+cat > $g <<!
+$(print hello) world
+!
+cmp $f $g 2> /dev/null || err_exit "'$(print hello) world' here doc not working"
+cat > $f <<\!!
+!@#$%%^^&*()_+~"::~;'`<>?/.,{}[]
+!!
+if [[ $(<$f) != '!@#$%%^^&*()_+~"::~;'\''`<>?/.,{}[]' ]]
+then err_exit "'hello world' here doc not working"
+fi
+cat > $g <<!!
+!@#\$%%^^&*()_+~"::~;'\`<>?/.,{}[]
+!!
+cmp $f $g 2> /dev/null || err_exit "unquoted here doc not working"
+exec 3<<!
+ foo
+!
+if [[ $(<&3) != ' foo' ]]
+then err_exit "leading tabs stripped with <<!"
+fi
+$SHELL -c "
+eval `echo 'cat <<x'` "|| err_exit "eval `echo 'cat <<x'` core dumps"
+cat > /dev/null <<EOF # comments should not cause core dumps
+abc
+EOF
+cat >$g << :
+:
+:
+cmp /dev/null $g 2> /dev/null || err_exit "empty here doc not working"
+x=$(print $( cat <<HUP
+hello
+HUP
+)
+)
+if [[ $x != hello ]]
+then err_exit "here doc inside command sub not working"
+fi
+y=$(cat <<!
+${x:+${x}}
+!
+)
+if [[ $y != "${x:+${x}}" ]]
+then err_exit '${x:+${x}} not working in here document'
+fi
+$SHELL -c '
+x=0
+while (( x < 100 ))
+do ((x = x+1))
+ cat << EOF
+EOF
+done
+' 2> /dev/null || err_exit '100 empty here docs fails'
+{
+ print 'builtin -d cat
+ cat <<- EOF'
+ for ((i=0; i < 100; i++))
+ do print XXXXXXXXXXXXXXXXXXXX
+ done
+ print ' XXX$(date)XXXX
+ EOF'
+} > $f
+chmod +x "$f"
+$SHELL "$f" > /dev/null || err_exit "large here-doc with command substitution fails"
+x=$(/bin/cat <<!
+$0
+!
+)
+[[ "$x" == "$0" ]] || err_exit '$0 not correct inside here documents'
+$SHELL -c 'x=$(
+cat << EOF
+EOF)' 2> /dev/null || err_exit 'here-doc cannot be terminated by )'
+if [[ $( IFS=:;cat <<-!
+ $IFS$(print hi)$IFS
+ !) != :hi: ]]
+then err_exit '$IFS unset by command substitution in here docs'
+fi
+if x=$($SHELL -c 'cat <<< "hello world"' 2> /dev/null)
+then [[ $x == 'hello world' ]] || err_exit '<<< documents not working'
+ x=$($SHELL -c 'v="hello world";cat <<< $v' 2> /dev/null)
+ [[ $x == 'hello world' ]] || err_exit '<<< documents with $x not working'
+ x=$($SHELL -c 'v="hello world";cat <<< "$v"' 2> /dev/null)
+ [[ $x == 'hello world' ]] || err_exit '<<< documents with $x not working'
+else err_exit '<<< syntax not supported'
+fi
+if [[ $(cat << EOF #testing
+#abc
+abc
+EOF) != $'#abc\nabc' ]]
+then err_exit 'comments not preserved in here-documents'
+fi
+cat > "$f" <<- '!!!!'
+ builtin cat
+ : << EOF
+ $PWD
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ EOF
+ command exec 3>&- 4>&- 5>&- 6>&- 7>&- 8>&- 9>&-
+ x=abc
+ cat << EOF
+ $x
+ EOF
+!!!!
+chmod 755 "$f"
+if [[ $($SHELL "$f") != abc ]]
+then err_exit 'here document descritor was closed'
+fi
+cat > "$f" <<- '!!!!'
+ exec 0<&-
+ foobar()
+ {
+ /bin/cat <<- !
+ foobar
+ !
+ }
+ : << EOF
+ $PWD
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ EOF
+ print -r -- "$(foobar)"
+!!!!
+if [[ $($SHELL "$f") != foobar ]]
+then err_exit 'here document with stdin closed failed'
+fi
+printf $'cat <<# \\!!!\n\thello\n\t\tworld\n!!!' > $f
+[[ $($SHELL "$f") == $'hello\n\tworld' ]] || err_exit "<<# not working for quoted here documents"
+printf $'w=world;cat <<# !!!\n\thello\n\t\t$w\n!!!' > $f
+[[ $($SHELL "$f") == $'hello\n\tworld' ]] || err_exit "<<# not working for non-quoted here documents"
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/io.sh b/usr/src/lib/libshell/common/tests/io.sh
new file mode 100644
index 0000000000..649520482a
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/io.sh
@@ -0,0 +1,251 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+integer Errors=0
+# cut here
+function fun
+{
+ while command exec 3>&1
+ do break
+ done 2> /dev/null
+ print -u3 good
+}
+print 'read -r a;print -r -u$1 -- "$a"' > /tmp/mycat$$
+chmod 755 /tmp/mycat$$
+for ((i=3; i < 10; i++))
+do
+ eval "a=\$(print foo | /tmp/mycat$$" $i $i'>&1 > /dev/null |cat)' 2> /dev/null
+ [[ $a == foo ]] || err_exit "bad file descriptor $i in comsub script"
+done
+rm -f /tmp/mycat$$
+exec 3> /dev/null
+[[ $(fun) == good ]] || err_exit 'file 3 closed before subshell completes'
+exec 3>&-
+mkdir /tmp/ksh$$ || err_exit "mkdir /tmp/ksh$$ failed"
+trap 'rm -rf /tmp/ksh$$' EXIT
+cd /tmp/ksh$$ || err_exit "cd /tmp/ksh$$ failed"
+print foo > file1
+print bar >> file1
+if [[ $(<file1) != $'foo\nbar' ]]
+then err_exit 'append (>>) not working'
+fi
+set -o noclobber
+exec 3<> file1
+read -u3 line
+if [[ $line != foo ]]
+then err_exit '<> not working right with read'
+fi
+if ( 4> file1 ) 2> /dev/null
+then err_exit 'noclobber not causing exclusive open'
+fi
+set +o noclobber
+if command exec 4< /dev/fd/3
+then read -u4 line
+ if [[ $line != bar ]]
+ then '4< /dev/fd/3 not working correctly'
+ fi
+fi
+cat > close0 <<\!
+exec 0<&-
+echo $(./close1)
+!
+print "echo abc" > close1
+chmod +x close0 close1
+x=$(./close0)
+if [[ $x != "abc" ]]
+then err_exit "picked up file descriptor zero for opening script file"
+fi
+cat > close0 <<\!
+ for ((i=0; i < 1100; i++))
+ do exec 4< /dev/null
+ read -u4
+ done
+ exit 0
+!
+./close0 2> /dev/null || err_exit "multiple exec 4< /dev/null can fail"
+$SHELL -c '
+ trap "rm -f in$$ out$$" EXIT
+ for ((i = 0; i < 1000; i++))
+ do print -r -- "This is a test"
+ done > in$$
+ > out$$
+ exec 1<> out$$
+ builtin cat
+ print -r -- "$(cat in$$)"
+ cmp -s in$$ out$$' 2> /dev/null
+[[ $? == 0 ]] || err_exit 'builtin cat truncates files'
+cat >| script <<-\!
+print hello
+( exec 3<&- 4<&-)
+exec 3<&- 4<&-
+print world
+!
+chmod +x script
+[[ $( $SHELL ./script) == $'hello\nworld' ]] || err_exit 'closing 3 & 4 causes script to fail'
+cd ~- || err_exit "cd back failed"
+( exec > '' ) 2> /dev/null && err_exit '> "" does not fail'
+unset x
+( exec > ${x} ) 2> /dev/null && err_exit '> $x, where x null does not fail'
+exec <<!
+foo
+bar
+!
+( exec 0< /dev/null)
+read line
+if [[ $line != foo ]]
+then err_exit 'file descriptor not restored after exec in subshell'
+fi
+exec 3>&- 4>&-; cd /; rm -r /tmp/ksh$$ || err_exit "rm -r /tmp/ksh$$ failed"
+[[ $( {
+ read -r line;print -r -- "$line"
+ (
+ read -r line;print -r -- "$line"
+ ) & wait
+ while read -r line
+ do print -r -- "$line"
+ done
+ } << !
+line 1
+line 2
+line 3
+!) == $'line 1\nline 2\nline 3' ]] || err_exit 'read error with subshells'
+# 2004-05-11 bug fix
+cat > /tmp/io$$.1 <<- \++EOF++
+ script=/tmp/io$$.2
+ trap 'rm -f $script' EXIT
+ exec 9> $script
+ for ((i=3; i<9; i++))
+ do eval "while read -u$i; do : ;done $i</dev/null"
+ print -u9 "exec $i< /dev/null"
+ done
+ for ((i=0; i < 60; i++))
+ do print -u9 -f "%.80c\n" ' '
+ done
+ print -u9 'print ok'
+ exec 9<&-
+ chmod +x $script
+ $script
+++EOF++
+chmod +x /tmp/io$$.1
+[[ $($SHELL /tmp/io$$.1) == ok ]] || err_exit "parent i/o causes child script to fail"
+rm -rf /tmp/io$$.[12]
+# 2004-11-25 ancient /dev/fd/NN redirection bug fix
+x=$(
+ {
+ print -n 1
+ print -n 2 > /dev/fd/2
+ print -n 3
+ print -n 4 > /dev/fd/2
+ } 2>&1
+)
+[[ $x == "1234" ]] || err_exit "/dev/fd/NN redirection fails to dup"
+# 2004-12-20 redirction loss bug fix
+cat > /tmp/io$$.1 <<- \++EOF++
+ function a
+ {
+ trap 'print ok' EXIT
+ : > /dev/null
+ }
+ a
+++EOF++
+chmod +x /tmp/io$$.1
+[[ $(/tmp/io$$.1) == ok ]] || err_exit "trap on EXIT loses last command redirection"
+print > /dev/null {n}> /tmp/io$$.1
+[[ ! -s /tmp/io$$.1 ]] && newio=1
+rm -rf /tmp/io$$.1
+if [[ $newio && $(print hello | while read -u$n; do print $REPLY; done {n}<&0) != hello ]]
+then err_exit "{n}<&0 not working with for loop"
+fi
+[[ $({ read -r;read -u3 3<&0; print -- "$REPLY" ;} <<!
+hello
+world
+!) == world ]] || err_exit 'I/O not synchronized with <&'
+trap 'rm -f /tmp/seek$$; exit $((Errors+1))' EXIT
+x="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNSPQRSTUVWXYZ1234567890"
+for ((i=0; i < 62; i++))
+do printf "%.39c\n" ${x:i:1}
+done > /tmp/seek$$
+if command exec 3<> /tmp/seek$$
+then (( $(3<#) == 0 )) || err_exit "not at position 0"
+ (( $(3<# ((EOF))) == 40*62 )) || err_exit "not at end-of-file"
+ command exec 3<# ((40*8)) || err_exit "absolute seek fails"
+ read -u3
+ [[ $REPLY == +(i) ]] || err_exit "expecting iiii..."
+ [[ $(3<#) == $(3<# ((CUR)) ) ]] || err_exit '$(3<#)!=$(3<#((CUR)))'
+ command exec 3<# ((CUR+80))
+ read -u3
+ [[ $REPLY == {39}(l) ]] || err_exit "expecting lll..."
+ command exec 3<# ((EOF-80))
+ read -u3
+ [[ $REPLY == +(9) ]] || err_exit "expecting 999...; got $REPLY"
+ command exec 3># ((80))
+ print -u3 -f "%.39c\n" @
+ command exec 3># ((80))
+ read -u3
+ [[ $REPLY == +(@) ]] || err_exit "expecting @@@..."
+ read -u3
+ [[ $REPLY == +(d) ]] || err_exit "expecting ddd..."
+ command exec 3># ((EOF))
+ print -u3 -f "%.39c\n" ^
+ (( $(3<# ((CUR-0))) == 40*63 )) || err_exit "not at extended end-of-file"
+ command exec 3<# ((40*62))
+ read -u3
+ [[ $REPLY == +(^) ]] || err_exit "expecting ddd..."
+ command exec 3<# ((0))
+ command exec 3<# *jjjj*
+ read -u3
+ [[ $REPLY == {39}(j) ]] || err_exit "<# pattern failed"
+ [[ $(command exec 3<## *llll*) = {39}(k) ]] || err_exit "<## pattern not saving standard output"
+ read -u3
+ [[ $REPLY == {39}(l) ]] || err_exit "<## pattern failed to position"
+ command exec 3<# *abc*
+ read -u3 && err_exit "not found pattern not positioning at eof"
+ cat /tmp/seek$$ | read -r <# *WWW*
+ [[ $REPLY == *WWWWW* ]] || err_exit '<# not working for pipes'
+else err_exit "/tmp/seek$$: cannot open for reading"
+fi
+trap "" EXIT
+rm -f /tmp/seek$$
+$SHELL -ic '
+{
+ print -u2 || exit 2
+ print -u3 || exit 3
+ print -u4 || exit 4
+ print -u5 || exit 5
+ print -u6 || exit 6
+ print -u7 || exit 7
+ print -u8 || exit 8
+ print -u9 || exit 9
+} 3> /dev/null 4> /dev/null 5> /dev/null 6> /dev/null 7> /dev/null 8> /dev/null 9> /dev/null' > /dev/null 2>&1
+exitval=$?
+(( exitval )) && err_exit "print to unit $exitval failed"
+trap 'rm -rf /tmp/io.sh$$*' EXIT
+$SHELL -c "{ > /tmp/io.sh$$.1 ; date;} >&- 2> /dev/null" > /tmp/io.sh$$.2
+[[ -s /tmp/io.sh$$.1 || -s /tmp/io.sh$$.2 ]] && err_exit 'commands with standard output closed produce output'
+$SHELL -c "$SHELL -c ': 3>&1' 1>&- 2>/dev/null" && err_exit 'closed standard output not passed to subshell'
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/nameref.sh b/usr/src/lib/libshell/common/tests/nameref.sh
new file mode 100644
index 0000000000..a6c52ddaa8
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/nameref.sh
@@ -0,0 +1,229 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+integer Errors=0
+function checkref
+{
+ nameref foo=$1 bar=$2
+ if [[ $foo != $bar ]]
+ then err_exit "foo=$foo != bar=$bar"
+ fi
+ foo=hello
+ if [[ $foo != $bar ]]
+ then err_exit "foo=$foo != bar=$bar"
+ fi
+ foo.child=child
+ if [[ ${foo.child} != ${bar.child} ]]
+ then err_exit "foo.child=${foo.child} != bar=${bar.child}"
+ fi
+}
+
+name=first
+checkref name name
+name.child=second
+checkref name name
+.foo=top
+.foo.bar=next
+checkref .foo.bar .foo.bar
+if [[ ${.foo.bar} != hello ]]
+then err_exit ".foo.bar=${.foo.bar} != hello"
+fi
+if [[ ${.foo.bar.child} != child ]]
+then err_exit ".foo.bar.child=${.foo.bar.child} != child"
+fi
+function func1
+{
+ nameref color=$1
+ func2 color
+}
+
+function func2
+{
+ nameref color=$1
+ set -s -- ${!color[@]}
+ print -r -- "$@"
+}
+
+typeset -A color
+color[apple]=red
+color[grape]=purple
+color[banana]=yellow
+if [[ $(func1 color) != 'apple banana grape' ]]
+then err_exit "nameref or nameref not working"
+fi
+nameref x=.foo.bar
+if [[ ${!x} != .foo.bar ]]
+then err_exit "${!x} not working"
+fi
+typeset +n x $(typeset +n)
+unset x
+nameref x=.foo.bar
+function x.set
+{
+ [[ ${.sh.value} ]] && print hello
+}
+if [[ $(.foo.bar.set) != $(x.set) ]]
+then err_exit "function references not working"
+fi
+if [[ $(typeset +n) != x ]]
+then err_exit "typeset +n doesn't list names of reference variables"
+fi
+if [[ $(typeset -n) != x=.foo.bar ]]
+then err_exit "typeset +n doesn't list values of reference variables"
+fi
+file=/tmp/shtest$$
+typeset +n foo bar 2> /dev/null
+unset foo bar
+export bar=foo
+nameref foo=bar
+if [[ $foo != foo ]]
+then err_exit "value of nameref foo != $foo"
+fi
+trap "rm -f $file" EXIT INT
+cat > $file <<\!
+print -r -- $foo
+!
+chmod +x "$file"
+y=$( $file)
+if [[ $y != '' ]]
+then err_exit "reference variable not cleared"
+fi
+{
+ command nameref xx=yy
+ command nameref yy=xx
+} 2> /dev/null && err_exit "self reference not detected"
+typeset +n foo bar
+unset foo bar
+set foo
+nameref bar=$1
+foo=hello
+if [[ $bar != hello ]]
+then err_exit 'nameref of positional paramters outside of function not working'
+fi
+unset foo bar
+bar=123
+function foobar
+{
+ typeset -n foo=bar
+ typeset -n foo=bar
+}
+foobar 2> /dev/null || err_exit 'nameref not unsetting previous reference'
+(
+ nameref short=verylong
+ short=( A=a B=b )
+ if [[ ${verylong.A} != a ]]
+ then err_exit 'nameref short to longname compound assignment error'
+ fi
+) 2> /dev/null|| err_exit 'nameref short to longname compound assignment error'
+unset x
+if [[ $(var1=1 var2=2
+ for i in var1 var2
+ do nameref x=$i
+ print $x
+ done) != $'1\n2' ]]
+then err_exit 'for loop nameref optimization error'
+fi
+if [[ $(typeset -A var1 var2
+ var1[sub1]=1 var2[sub2]=1
+ for i in var1 var2
+ do
+ typeset -n array=$i
+ print ${!array[*]}
+ done) != $'sub1\nsub2' ]]
+then err_exit 'for loop nameref optimization test2 error'
+fi
+
+unset -n x foo bar
+if [[ $(nameref x=foo;for x in foo bar;do print ${!x};done) != $'foo\nbar' ]]
+then err_exit 'for loop optimization with namerefs not working'
+fi
+if [[ $(
+ p=(x=(r=3) y=(r=4))
+ for i in x y
+ do nameref x=p.$i
+ print ${x.r}
+ done
+) != $'3\n4' ]]
+then err_exit 'nameref optimization error'
+fi
+[[ $(
+unset x y var
+var=(foo=bar)
+for i in y var
+do typeset -n x=$i
+ if [[ ${!x.@} ]]
+ then print ok
+ fi
+ typeset +n x
+done) != ok ]] && err_exit 'invalid for loop optimization of name references'
+function setval # name value
+{
+ nameref arg=$1
+ nameref var=arg.bar
+ var=$2
+}
+foo=( integer bar=0)
+setval foo 5
+(( foo.bar == 5)) || err_exit 'nested nameref not working'
+function selfref
+{
+ typeset -n ps=$1
+ print -r -- "${ps}"
+}
+ps=(a=1 b=2)
+[[ $(selfref ps) == *a=1* ]] || err_exit 'local nameref cannot reference global variable of the same name'
+function subref
+{
+ typeset -n foo=$1
+ print -r -- ${foo.a}
+}
+[[ $(subref ps) == 1 ]] || err_exit 'local nameref cannot reference global variable child'
+
+function local
+{
+ typeset ps=(typeset -i a=3 b=4)
+ [[ $(subref ps) == 3 ]] || err_exit 'local nameref cannot reference caller compound variable'
+}
+local
+unset -f local
+function local
+{
+ qs=(integer a=3; integer b=4)
+}
+local 2> /dev/null || err_exit 'function local has non-zero exit status'
+[[ ${qs.a} == 3 ]] || err_exit 'function cannot set compound global variable'
+unset fun i
+foo=(x=hi)
+function fun
+{
+ nameref i=$1
+ print -r -- "${i.x}"
+}
+i=foo
+[[ $(fun $i) == hi ]] || err_exit 'nameref for compound variable with in function name of caller fails'
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/options.sh b/usr/src/lib/libshell/common/tests/options.sh
new file mode 100644
index 0000000000..2520cb2a2e
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/options.sh
@@ -0,0 +1,313 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+integer Errors=0
+if [[ $( ${SHELL-ksh} -s hello<<-\!
+ print $1
+ !
+ ) != hello ]]
+then err_exit "${SHELL-ksh} -s not working"
+fi
+x=$(
+ set -e
+ false && print bad
+ print good
+)
+if [[ $x != good ]]
+then err_exit 'sh -e not workuing'
+fi
+[[ $($SHELL -D -c 'print hi; print $"hello"') == '"hello"' ]] || err_exit 'ksh -D not working'
+
+tmp=/tmp/ksh$$
+mkdir $tmp
+rc=$tmp/.kshrc
+print $'function env_hit\n{\n\tprint OK\n}' > $rc
+
+export ENV=$rc
+if [[ -o privileged ]]
+then
+ [[ $(print env_hit | $SHELL 2>&1) == "OK" ]] &&
+ err_exit 'privileged nointeractive shell reads $ENV file'
+ [[ $(print env_hit | $SHELL -E 2>&1) == "OK" ]] &&
+ err_exit 'privileged -E reads $ENV file'
+ [[ $(print env_hit | $SHELL +E 2>&1) == "OK" ]] &&
+ err_exit 'privileged +E reads $ENV file'
+ [[ $(print env_hit | $SHELL --rc 2>&1) == "OK" ]] &&
+ err_exit 'privileged --rc reads $ENV file'
+ [[ $(print env_hit | $SHELL --norc 2>&1) == "OK" ]] &&
+ err_exit 'privileged --norc reads $ENV file'
+else
+ [[ $(print env_hit | $SHELL 2>&1) == "OK" ]] &&
+ err_exit 'nointeractive shell reads $ENV file'
+ [[ $(print env_hit | $SHELL -E 2>&1) == "OK" ]] ||
+ err_exit '-E ignores $ENV file'
+ [[ $(print env_hit | $SHELL +E 2>&1) == "OK" ]] &&
+ err_exit '+E reads $ENV file'
+ [[ $(print env_hit | $SHELL --rc 2>&1) == "OK" ]] ||
+ err_exit '--rc ignores $ENV file'
+ [[ $(print env_hit | $SHELL --norc 2>&1) == "OK" ]] &&
+ err_exit '--norc reads $ENV file'
+fi
+
+export ENV=
+if [[ -o privileged ]]
+then
+ [[ $(print env_hit | HOME=$tmp $SHELL 2>&1) == "OK" ]] &&
+ err_exit 'privileged nointeractive shell reads $HOME/.kshrc file'
+ [[ $(print env_hit | HOME=$tmp $SHELL -E 2>&1) == "OK" ]] &&
+ err_exit 'privileged -E ignores empty $ENV'
+ [[ $(print env_hit | HOME=$tmp $SHELL +E 2>&1) == "OK" ]] &&
+ err_exit 'privileged +E reads $HOME/.kshrc file'
+ [[ $(print env_hit | HOME=$tmp $SHELL --rc 2>&1) == "OK" ]] &&
+ err_exit 'privileged --rc ignores empty $ENV'
+ [[ $(print env_hit | HOME=$tmp $SHELL --norc 2>&1) == "OK" ]] &&
+ err_exit 'privileged --norc reads $HOME/.kshrc file'
+else
+ [[ $(print env_hit | HOME=$tmp $SHELL 2>&1) == "OK" ]] &&
+ err_exit 'nointeractive shell reads $HOME/.kshrc file'
+ [[ $(print env_hit | HOME=$tmp $SHELL -E 2>&1) == "OK" ]] &&
+ err_exit '-E ignores empty $ENV'
+ [[ $(print env_hit | HOME=$tmp $SHELL +E 2>&1) == "OK" ]] &&
+ err_exit '+E reads $HOME/.kshrc file'
+ [[ $(print env_hit | HOME=$tmp $SHELL --rc 2>&1) == "OK" ]] &&
+ err_exit '--rc ignores empty $ENV'
+ [[ $(print env_hit | HOME=$tmp $SHELL --norc 2>&1) == "OK" ]] &&
+ err_exit '--norc reads $HOME/.kshrc file'
+fi
+
+unset ENV
+if [[ -o privileged ]]
+then
+ [[ $(print env_hit | HOME=$tmp $SHELL 2>&1) == "OK" ]] &&
+ err_exit 'privileged nointeractive shell reads $HOME/.kshrc file'
+ [[ $(print env_hit | HOME=$tmp $SHELL -E 2>&1) == "OK" ]] &&
+ err_exit 'privileged -E reads $HOME/.kshrc file'
+ [[ $(print env_hit | HOME=$tmp $SHELL +E 2>&1) == "OK" ]] &&
+ err_exit 'privileged +E reads $HOME/.kshrc file'
+ [[ $(print env_hit | HOME=$tmp $SHELL --rc 2>&1) == "OK" ]] &&
+ err_exit 'privileged --rc reads $HOME/.kshrc file'
+ [[ $(print env_hit | HOME=$tmp $SHELL --norc 2>&1) == "OK" ]] &&
+ err_exit 'privileged --norc reads $HOME/.kshrc file'
+else
+ [[ $(print env_hit | HOME=$tmp $SHELL 2>&1) == "OK" ]] &&
+ err_exit 'nointeractive shell reads $HOME/.kshrc file'
+ [[ $(print env_hit | HOME=$tmp $SHELL -E 2>&1) == "OK" ]] ||
+ err_exit '-E ignores $HOME/.kshrc file'
+ [[ $(print env_hit | HOME=$tmp $SHELL +E 2>&1) == "OK" ]] &&
+ err_exit '+E reads $HOME/.kshrc file'
+ [[ $(print env_hit | HOME=$tmp $SHELL --rc 2>&1) == "OK" ]] ||
+ err_exit '--rc ignores $HOME/.kshrc file'
+ [[ $(print env_hit | HOME=$tmp $SHELL --norc 2>&1) == "OK" ]] &&
+ err_exit '--norc reads $HOME/.kshrc file'
+fi
+
+rm -rf $tmp
+
+if command set -G 2> /dev/null
+then mkdir /tmp/ksh$$
+ cd /tmp/ksh$$
+ mkdir bar foo
+ > bar.c > bam.c
+ > bar/foo.c > bar/bam.c
+ > foo/bam.c
+ set -- **.c
+ expected='bam.c bar.c'
+ [[ $* == $expected ]] ||
+ err_exit "-G **.c failed -- expected '$expected', got '$*'"
+ set -- **
+ expected='bam.c bar bar.c bar/bam.c bar/foo.c foo foo/bam.c'
+ [[ $* == $expected ]] ||
+ err_exit "-G ** failed -- expected '$expected', got '$*'"
+ set -- **/*.c
+ expected='bam.c bar.c bar/bam.c bar/foo.c foo/bam.c'
+ [[ $* == $expected ]] ||
+ err_exit "-G **/*.c failed -- expected '$expected', got '$*'"
+ set -- **/bam.c
+ expected='bam.c bar/bam.c foo/bam.c'
+ [[ $* == $expected ]] ||
+ err_exit "-G **/bam.c failed -- expected '$expected', got '$*'"
+ cd ~-
+ rm -rf /tmp/ksh$$
+fi
+
+mkdir /tmp/ksh$$
+cd /tmp/ksh$$
+t="<$$>.profile.<$$>"
+echo "echo '$t'" > .profile
+cp $SHELL ./-ksh
+if [[ -o privileged ]]
+then
+ [[ $(HOME=$PWD $SHELL -l </dev/null 2>&1) == *$t* ]] &&
+ err_exit 'privileged -l reads .profile'
+ [[ $(HOME=$PWD $SHELL --login </dev/null 2>&1) == *$t* ]] &&
+ err_exit 'privileged --login reads .profile'
+ [[ $(HOME=$PWD $SHELL --login-shell </dev/null 2>&1) == *$t* ]] &&
+ err_exit 'privileged --login-shell reads .profile'
+ [[ $(HOME=$PWD $SHELL --login_shell </dev/null 2>&1) == *$t* ]] &&
+ err_exit 'privileged --login_shell reads .profile'
+ [[ $(HOME=$PWD exec -a -ksh $SHELL </dev/null 2>&1) == *$t* ]] &&
+ err_exit 'privileged exec -a -ksh ksh reads .profile'
+ [[ $(HOME=$PWD ./-ksh -i </dev/null 2>&1) == *$t* ]] &&
+ err_exit 'privileged ./-ksh reads .profile'
+ [[ $(HOME=$PWD ./-ksh -ip </dev/null 2>&1) == *$t* ]] &&
+ err_exit 'privileged ./-ksh -p reads .profile'
+else
+ [[ $(HOME=$PWD $SHELL -l </dev/null 2>&1) == *$t* ]] ||
+ err_exit '-l ignores .profile'
+ [[ $(HOME=$PWD $SHELL --login </dev/null 2>&1) == *$t* ]] ||
+ err_exit '--login ignores .profile'
+ [[ $(HOME=$PWD $SHELL --login-shell </dev/null 2>&1) == *$t* ]] ||
+ err_exit '--login-shell ignores .profile'
+ [[ $(HOME=$PWD $SHELL --login_shell </dev/null 2>&1) == *$t* ]] ||
+ err_exit '--login_shell ignores .profile'
+ [[ $(HOME=$PWD exec -a -ksh $SHELL </dev/null 2>&1) == *$t* ]] ||
+ err_exit 'exec -a -ksh ksh ignores .profile'
+ [[ $(HOME=$PWD ./-ksh -i </dev/null 2>&1) == *$t* ]] ||
+ err_exit './-ksh ignores .profile'
+ [[ $(HOME=$PWD ./-ksh -ip </dev/null 2>&1) == *$t* ]] &&
+ err_exit './-ksh -p does not ignore .profile'
+fi
+cd ~-
+rm -rf /tmp/ksh$$
+
+
+# { exec interactive login_shell restricted xtrace } in the following test
+
+for opt in \
+ allexport all-export all_export \
+ bgnice bg-nice bg_nice \
+ clobber emacs \
+ errexit err-exit err_exit \
+ glob \
+ globstar glob-star glob_star \
+ gmacs \
+ ignoreeof ignore-eof ignore_eof \
+ keyword log markdirs monitor notify \
+ pipefail pipe-fail pipe_fail \
+ trackall track-all track_all \
+ unset verbose vi \
+ viraw vi-raw vi_raw
+do old=$opt
+ if [[ ! -o $opt ]]
+ then old=no$opt
+ fi
+
+ set --$opt || err_exit "set --$opt failed"
+ [[ -o $opt ]] || err_exit "[[ -o $opt ]] failed"
+ [[ -o no$opt ]] && err_exit "[[ -o no$opt ]] failed"
+ [[ -o no-$opt ]] && err_exit "[[ -o no-$opt ]] failed"
+ [[ -o no_$opt ]] && err_exit "[[ -o no_$opt ]] failed"
+ [[ -o ?$opt ]] || err_exit "[[ -o ?$opt ]] failed"
+ [[ -o ?no$opt ]] || err_exit "[[ -o ?no$opt ]] failed"
+ [[ -o ?no-$opt ]] || err_exit "[[ -o ?no-$opt ]] failed"
+ [[ -o ?no_$opt ]] || err_exit "[[ -o ?no_$opt ]] failed"
+
+ set --no$opt || err_exit "set --no$opt failed"
+ [[ -o no$opt ]] || err_exit "[[ -o no$opt ]] failed"
+ [[ -o $opt ]] && err_exit "[[ -o $opt ]] failed"
+
+ set --no-$opt || err_exit "set --no-$opt failed"
+ [[ -o no$opt ]] || err_exit "[[ -o no$opt ]] failed"
+ [[ -o $opt ]] && err_exit "[[ -o $opt ]] failed"
+
+ set --no_$opt || err_exit "set --no_$opt failed"
+ [[ -o no$opt ]] || err_exit "[[ -o no$opt ]] failed"
+ [[ -o $opt ]] && err_exit "[[ -o $opt ]] failed"
+
+ set -o $opt || err_exit "set -o $opt failed"
+ [[ -o $opt ]] || err_exit "[[ -o $opt ]] failed"
+ set -o $opt=1 || err_exit "set -o $opt=1 failed"
+ [[ -o $opt ]] || err_exit "[[ -o $opt ]] failed"
+ set -o no$opt=0 || err_exit "set -o no$opt=0 failed"
+ [[ -o $opt ]] || err_exit "[[ -o $opt ]] failed"
+ set --$opt=1 || err_exit "set --$opt=1 failed"
+ [[ -o $opt ]] || err_exit "[[ -o $opt ]] failed"
+ set --no$opt=0 || err_exit "set --no$opt=0 failed"
+ [[ -o $opt ]] || err_exit "[[ -o $opt ]] failed"
+
+ set -o no$opt || err_exit "set -o no$opt failed"
+ [[ -o no$opt ]] || err_exit "[[ -o no$opt ]] failed"
+ set -o $opt=0 || err_exit "set -o $opt=0 failed"
+ [[ -o no$opt ]] || err_exit "[[ -o no$opt ]] failed"
+ set -o no$opt=1 || err_exit "set -o no$opt=1 failed"
+ [[ -o no$opt ]] || err_exit "[[ -o no$opt ]] failed"
+ set --$opt=0 || err_exit "set --$opt=0 failed"
+ [[ -o no$opt ]] || err_exit "[[ -o no$opt ]] failed"
+ set --no$opt=1 || err_exit "set --no$opt=1 failed"
+ [[ -o no$opt ]] || err_exit "[[ -o no$opt ]] failed"
+
+ set -o no-$opt || err_exit "set -o no-$opt failed"
+ [[ -o no-$opt ]] || err_exit "[[ -o no-$opt ]] failed"
+
+ set -o no_$opt || err_exit "set -o no_$opt failed"
+ [[ -o no_$opt ]] || err_exit "[[ -o no_$opt ]] failed"
+
+ set +o $opt || err_exit "set +o $opt failed"
+ [[ -o no$opt ]] || err_exit "[[ -o no$opt ]] failed"
+
+ set +o no$opt || err_exit "set +o no$opt failed"
+ [[ -o $opt ]] || err_exit "[[ -o $opt ]] failed"
+
+ set +o no-$opt || err_exit "set +o no-$opt failed"
+ [[ -o $opt ]] || err_exit "[[ -o $opt ]] failed"
+
+ set +o no_$opt || err_exit "set +o no_$opt failed"
+ [[ -o $opt ]] || err_exit "[[ -o $opt ]] failed"
+
+ set --$old
+done
+
+for opt in \
+ exec interactive login_shell login-shell logi privileged \
+ rc restricted xtrace
+do [[ -o $opt ]]
+ y=$?
+ [[ -o no$opt ]]
+ n=$?
+ case $y$n in
+ 10|01) ;;
+ *) err_exit "[[ -o $opt ]] == [[ -o no$opt ]]" ;;
+ esac
+done
+
+for opt in \
+ foo foo-bar foo_bar
+do if [[ -o ?$opt ]]
+ then err_exit "[[ -o ?$opt ]] should fail"
+ fi
+ if [[ -o ?no$opt ]]
+ then err_exit "[[ -o ?no$opt ]] should fail"
+ fi
+done
+false | true | true || err_exit 'pipe not exiting exit value of last element'
+true | true | false && err_exit 'pipe not exiting false'
+set -o pipefail
+false | true | true && err_exit 'pipe with first not failing with pipefail'
+true | false | true && err_exit 'pipe middle not failing with pipefail'
+true | true | false && err_exit 'pipe last not failing with pipefail'
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/path.sh b/usr/src/lib/libshell/common/tests/path.sh
new file mode 100644
index 0000000000..7083aca713
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/path.sh
@@ -0,0 +1,186 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+integer Errors=0
+mkdir /tmp/ksh$$
+cd /tmp/ksh$$
+trap "PATH=$PATH; cd /; rm -rf /tmp/ksh$$" EXIT
+(PATH="/bin")
+[[ $($SHELL -c 'print -r -- "$PATH"') == "$PATH" ]] || err_exit 'export PATH lost in subshell'
+cat > bug1 <<- \EOF
+ print print ok > /tmp/ok$$
+ /bin/chmod 755 /tmp/ok$$
+ trap 'cd /; rm -f /tmp/ok$$' EXIT
+ function a
+ {
+ typeset -x PATH=/tmp
+ ok$$
+ }
+ path=$PATH
+ unset PATH
+ a
+ PATH=$path
+}
+EOF
+[[ $($SHELL ./bug1 2> /dev/null) == ok ]] || err_exit "PATH in function not working"
+cat > bug1 <<- \EOF
+ function lock_unlock
+ {
+ typeset PATH=/usr/bin
+ typeset -x PATH=''
+ }
+
+ PATH=/usr/bin
+ : $(PATH=/usr/bin getconf PATH)
+ typeset -ft lock_unlock
+ lock_unlock
+EOF
+($SHELL ./bug1) 2> /dev/null || err_exit "path_delete bug"
+mkdir tdir$$
+if $SHELL tdir$$ > /dev/null 2>&1
+then err_exit 'not an error to run ksh on a directory'
+fi
+
+print 'print hi' > ls
+if [[ $($SHELL ls 2> /dev/null) != hi ]]
+then err_exit "$SHELL name not executing version in current directory"
+fi
+if [[ $(ls -d . 2>/dev/null) == . && $(PATH=/bin:/usr/bin:$PATH ls -d . 2>/dev/null) != . ]]
+then err_exit 'PATH export in command substitution not working'
+fi
+pwd=$PWD
+# get rid of leading and trailing : and trailing :.
+PATH=${PATH%.}
+PATH=${PATH%:}
+PATH=${PATH#.}
+PATH=${PATH#:}
+path=$PATH
+var=$(whence date)
+dir=$(basename "$var")
+for i in 1 2 3 4 5 6 7 8 9 0
+do if ! whence notfound$i 2> /dev/null
+ then cmd=notfound$i
+ break
+ fi
+done
+print 'print hello' > date
+chmod +x date
+print 'print notfound' > $cmd
+chmod +x "$cmd"
+> foo
+chmod 755 foo
+for PATH in $path :$path $path: .:$path $path: $path:. $PWD::$path $PWD:.:$path $path:$PWD $path:.:$PWD
+do
+# print path=$PATH $(whence date)
+# print path=$PATH $(whence "$cmd")
+ date
+ "$cmd"
+done > /dev/null 2>&1
+builtin -d date 2> /dev/null
+if [[ $(PATH=:/usr/bin; date) != 'hello' ]]
+then err_exit "leading : in path not working"
+fi
+(
+ PATH=$PWD:
+ builtin chmod
+ print 'print cannot execute' > noexec
+ chmod 644 noexec
+ if [[ ! -x noexec ]]
+ then noexec > /dev/null 2>&1
+ else exit 126
+ fi
+)
+status=$?
+[[ $status == 126 ]] || err_exit "exit status of non-executable is $status -- 126 expected"
+builtin -d rm 2> /dev/null
+rm=$(whence rm)
+d=$(dirname "$rm")
+unset FPATH
+PATH=/dev/null
+if date > /dev/null 2>&1
+then err_exit 'programs in . should not be found'
+fi
+[[ $(whence ./foo) != "$PWD/"./foo ]] && err_exit 'whence ./foo not working'
+[[ $(whence "$PWD/foo") != "$PWD/foo" ]] && err_exit 'whence $PWD/foo not working'
+[[ $(whence ./xxxxx) ]] && err_exit 'whence ./xxxx not working'
+PATH=$d:
+cp "$rm" kshrm$$
+if [[ $(whence kshrm$$) != $PWD/kshrm$$ ]]
+then err_exit 'trailing : in pathname not working'
+fi
+cp "$rm" rm
+PATH=:$d
+if [[ $(whence rm) != $PWD/rm ]]
+then err_exit 'leading : in pathname not working'
+fi
+PATH=$d: whence rm > /dev/null
+if [[ $(whence rm) != $PWD/rm ]]
+then err_exit 'pathname not restored after scoping'
+fi
+mkdir bin
+print 'print ok' > bin/tst
+chmod +x bin/tst
+if [[ $(PATH=$PWD/bin tst 2>/dev/null) != ok ]]
+then err_exit '(PATH=$PWD/bin foo) does not find $PWD/bin/foo'
+fi
+cd /
+if whence ls > /dev/null
+then PATH=
+ if [[ $(whence rm) ]]
+ then err_exit 'setting PATH to Null not working'
+ fi
+ unset PATH
+ if [[ $(whence rm) != /*rm ]]
+ then err_exit 'unsetting path not working'
+ fi
+fi
+PATH=/dev:/tmp/ksh$$
+x=$(whence rm)
+typeset foo=$(PATH=/xyz:/abc :)
+y=$(whence rm)
+[[ $x != "$y" ]] && err_exit 'PATH not restored after command substitution'
+whence getconf > /dev/null && err_exit 'getconf should not be found'
+builtin /bin/getconf
+PATH=/bin
+PATH=$(getconf PATH)
+x=$(whence ls)
+PATH=.:$PWD:${x%/ls}
+[[ $(whence ls) == "$x" ]] || err_exit 'PATH search bug when .:$PWD in path'
+PATH=$PWD:.:${x%/ls}
+[[ $(whence ls) == "$x" ]] || err_exit 'PATH search bug when :$PWD:. in path'
+cd "${x%/ls}"
+[[ $(whence ls) == /* ]] || err_exit 'whence not generating absolute pathname'
+status=$($SHELL -c $'trap \'print $?\' EXIT;/a/b/c/d/e 2> /dev/null')
+[[ $status == 127 ]] || err_exit "not found command exit status $status -- expected 127"
+status=$($SHELL -c $'trap \'print $?\' EXIT;/dev/null 2> /dev/null')
+[[ $status == 126 ]] || err_exit "non executable command exit status $status -- expected 126"
+status=$($SHELL -c $'trap \'print $?\' ERR;/a/b/c/d/e 2> /dev/null')
+[[ $status == 127 ]] || err_exit "not found command with ERR trap exit status $status -- expected 127"
+status=$($SHELL -c $'trap \'print $?\' ERR;/dev/null 2> /dev/null')
+[[ $status == 126 ]] || err_exit "non executable command ERR trap exit status $status -- expected 126"
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/quoting.sh b/usr/src/lib/libshell/common/tests/quoting.sh
new file mode 100644
index 0000000000..9a9e23bd55
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/quoting.sh
@@ -0,0 +1,331 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+integer Errors=0
+if [[ 'hi there' != "hi there" ]]
+then err_exit "single quotes not the same as double quotes"
+fi
+x='hi there'
+if [[ $x != 'hi there' ]]
+then err_exit "$x not the same as 'hi there'"
+fi
+if [[ $x != "hi there" ]]
+then err_exit "$x not the same as \"hi there \""
+fi
+if [[ \a\b\c\*\|\"\ \\ != 'abc*|" \' ]]
+then err_exit " \\ differs from '' "
+fi
+if [[ "ab\'\"\$(" != 'ab\'\''"$(' ]]
+then err_exit " \"\" differs from '' "
+fi
+if [[ $(print -r - 'abc*|" \') != 'abc*|" \' ]]
+then err_exit "\$(print -r - '') differs from ''"
+fi
+if [[ $(print -r - "abc*|\" \\") != 'abc*|" \' ]]
+then err_exit "\$(print -r - '') differs from ''"
+fi
+if [[ "$(print -r - 'abc*|" \')" != 'abc*|" \' ]]
+then err_exit "\"\$(print -r - '')\" differs from ''"
+fi
+if [[ "$(print -r - "abc*|\" \\")" != 'abc*|" \' ]]
+then err_exit "\"\$(print -r - "")\" differs from ''"
+fi
+if [[ $(print -r - $(print -r - 'abc*|" \')) != 'abc*|" \' ]]
+then err_exit "nested \$(print -r - '') differs from ''"
+fi
+if [[ "$(print -r - $(print -r - 'abc*|" \'))" != 'abc*|" \' ]]
+then err_exit "\"nested \$(print -r - '')\" differs from ''"
+fi
+if [[ $(print -r - "$(print -r - 'abc*|" \')") != 'abc*|" \' ]]
+then err_exit "nested \"\$(print -r - '')\" differs from ''"
+fi
+unset x
+if [[ ${x-$(print -r - "abc*|\" \\")} != 'abc*|" \' ]]
+then err_exit "\${x-\$(print -r - '')} differs from ''"
+fi
+if [[ ${x-$(print -r - "a}c*|\" \\")} != 'a}c*|" \' ]]
+then err_exit "\${x-\$(print -r - '}')} differs from ''"
+fi
+x=$((echo foo)|(cat))
+if [[ $x != foo ]]
+then err_exit "((cmd)|(cmd)) failed"
+fi
+x=$(print -r -- "\"$HOME\"")
+if [[ $x != '"'$HOME'"' ]]
+then err_exit "nested double quotes failed"
+fi
+: ${z="a{b}c"}
+if [[ $z != 'a{b}c' ]]
+then err_exit '${z="a{b}c"} not correct'
+fi
+unset z
+: "${z="a{b}c"}"
+if [[ $z != 'a{b}c' ]]
+then err_exit '"${z="a{b}c"}" not correct'
+fi
+if [[ $(print -r -- "a\*b") != 'a\*b' ]]
+then err_exit '$(print -r -- "a\*b") differs from a\*b'
+fi
+unset x
+if [[ $(print -r -- "a\*b$x") != 'a\*b' ]]
+then err_exit '$(print -r -- "a\*b$x") differs from a\*b'
+fi
+x=hello
+set -- ${x+foo bar bam}
+if (( $# !=3 ))
+then err_exit '${x+foo bar bam} does not yield three arguments'
+fi
+set -- ${x+foo "bar bam"}
+if (( $# !=2 ))
+then err_exit '${x+foo "bar bam"} does not yield two arguments'
+fi
+set -- ${x+foo 'bar bam'}
+if (( $# !=2 ))
+then err_exit '${x+foo '\''bar bam'\''} does not yield two arguments'
+fi
+set -- ${x+foo $x bam}
+if (( $# !=3 ))
+then err_exit '${x+foo $x bam} does not yield three arguments'
+fi
+set -- ${x+foo "$x" bam}
+if (( $# !=3 ))
+then err_exit '${x+foo "$x" bam} does not yield three arguments'
+fi
+set -- ${x+"foo $x bam"}
+if (( $# !=1 ))
+then err_exit '${x+"foo $x bam"} does not yield one argument'
+fi
+set -- "${x+foo $x bam}"
+if (( $# !=1 ))
+then err_exit '"${x+foo $x bam}" does not yield one argument'
+fi
+set -- ${x+foo "$x "bam}
+if (( $# !=2 ))
+then err_exit '${x+foo "$x "bam} does not yield two arguments'
+fi
+x="ab$'cd"
+if [[ $x != 'ab$'"'cd" ]]
+then err_exit '$'"' inside double quotes not working"
+fi
+x=`print 'ab$'`
+if [[ $x != 'ab$' ]]
+then err_exit '$'"' inside `` quotes not working"
+fi
+unset a
+x=$(print -r -- "'\
+\
+")
+if [[ $x != "'" ]]
+then err_exit 'line continuation in double strings not working'
+fi
+x=$(print -r -- "'\
+$a\
+")
+if [[ $x != "'" ]]
+then err_exit 'line continuation in expanded double strings not working'
+fi
+x='\*'
+if [[ $(print -r -- $x) != '\*' ]]
+then err_exit 'x="\\*";$x != \*'
+fi
+x=' hello world '
+set -- $x
+if (( $# != 2 ))
+then err_exit 'field splitting error'
+fi
+x=$(print -r -- '1234567890123456789012345678901234567890123456789012345678901234567890 \
+1234567890123456789012345678901234567890123456789012345678901234567890 \
+1234567890123456789012345678901234567890123456789012345678901234567890 \
+1234567890123456789012345678901234567890123456789012345678901234567890 \
+1234567890123456789012345678901234567890123456789012345678901234567890 \
+1234567890123456789012345678901234567890123456789012345678901234567890 \
+1234567890123456789012345678901234567890123456789012345678901234567890 \
+1234567890123456789012345678901234567890123456789012345678901234567890 \
+1234567890123456789012345678901234567890123456789012345678901234567890 \
+1234567890123456789012345678901234567890123456789012345678901234567890 \
+1234567890123456789012345678901234567890123456789012345678901234567890 \
+1234567890123456789012345678901234567890123456789012345678901234567890 \
+1234567890123456789012345678901234567890123456789012345678901234567890 \
+1234567890123456789012345678901234567890123456789012345678901234567890 \
+1234567890123456789012345678901234567890123456789012345678901234567890')
+if (( ${#x} != (15*73-3) ))
+then err_exit "length of x, ${#x}, is incorrect should be $((15*73-3))"
+fi
+x='$hi'
+if [[ $x\$ != '$hi$' ]]
+then err_exit ' $x\$, with x=$hi, does not expand to $hi$'
+fi
+if [[ $x$ != '$hi$' ]]
+then err_exit ' $x$, with x=$hi, does not expand to $hi$'
+fi
+set -- $(/bin/echo foo;sleep 1;/bin/echo bar)
+if [[ $# != 2 ]]
+then err_exit 'word splitting after command substitution not working'
+fi
+unset q
+if [[ "${q:+'}q${q:+'}" != q ]]
+then err_exit 'expansion of "{q:+'\''}" not correct when q unset'
+fi
+q=1
+if [[ "${q:+'}q${q:+'}" != "'q'" ]]
+then err_exit 'expansion of "{q:+'\''}" not correct when q set'
+fi
+x=$'x\' #y'
+if [[ $x != "x' #y" ]]
+then err_exit "$'x\' #y'" not working
+fi
+x=$q$'x\' #y'
+if [[ $x != "1x' #y" ]]
+then err_exit "$q$'x\' #y'" not working
+fi
+IFS=,
+x='a,b\,c,d'
+set -- $x
+if [[ $2 != 'b\' ]]
+then err_exit "field splitting of $x with IFS=$IFS not working"
+fi
+foo=bar
+bar=$(print -r -- ${foo+\\n\ })
+if [[ $bar != '\n ' ]]
+then err_exit '${foo+\\n\ } expansion error'
+fi
+unset bar
+bar=$(print -r -- ${foo+\\n\ $bar})
+if [[ $bar != '\n ' ]]
+then err_exit '${foo+\\n\ $bar} expansion error with bar unset'
+fi
+x='\\(..\\)|&\|\|\\&\\|'
+if [[ $(print -r -- $x) != "$x" ]]
+then err_exit '$x, where x=\\(..\\)|&\|\|\\&\\| not working'
+fi
+x='\\('
+if [[ $(print -r -- a${x}b) != a"${x}"b ]]
+then err_exit 'a${x}b, where x=\\( not working'
+fi
+x=
+if [[ $(print -r -- $x'\\1') != '\\1' ]]
+then err_exit 'backreference inside single quotes broken'
+fi
+set -- ''
+set -- "$@"
+if (( $# != 1 ))
+then err_exit '"$@" not preserving nulls'
+fi
+x=
+if [[ $(print -r s"!\2${x}\1\a!") != 's!\2\1\a!' ]]
+then err_exit 'print -r s"!\2${x}\1\a!" not equal s!\2\1\a!'
+fi
+if [[ $(print -r $'foo\n\n\n') != foo ]]
+then err_exit 'trailing newlines on comsubstitution not removed'
+fi
+unset x
+if [[ ${x:='//'} != '//' ]]
+then err_exit '${x:='//'} != "//"'
+fi
+if [[ $(print -r "\"hi$\"") != '"hi$"' ]]
+then err_exit '$\ not correct inside ""'
+fi
+unset x
+if [[ "${x-a\}b}" != 'a}b' ]]
+then err_exit '"${x-a\}b}" != "a}b"'
+fi
+if [[ "\}\]$x\*\{\[\\" != '\}\]\*\{\[\' ]]
+then err_exit '"\}\]$x\*\{\[\\" != "\}\]\*\{\[\"'
+fi
+foo=yes
+if [[ $(print -r -- {\$foo}) != '{$foo}' ]]
+then err_exit '{\$foo}' not expanded correctly
+fi
+[[ foo == $(
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+###########################################################
+print foo) ]] || err_exit "command subsitution with long comments broken"
+subject='some/other/words'
+re='(?*)/(?*)/(?*)'
+[[ ${subject/${re}/\3} != words ]] && err_exit 'string replacement with \3 not working'
+[[ ${subject/${re}/'\3'} != '\3' ]] && err_exit 'string replacement with '"'\3'"' not working'
+[[ ${subject/${re}/"\\3"} != '\3' ]] && err_exit 'string replacement with "\\3" not working'
+[[ ${subject/${re}/"\3"} != '\3' ]] && err_exit 'string replacement with "\3" not working'
+string='\3'
+[[ ${subject/${re}/${string}} != words ]] && err_exit 'string replacement with $string not working with string=\3'
+[[ $(print -r "${subject/${re}/${string}}") != words ]] && err_exit 'string replacement with $string not working with string=\3 using print'
+[[ ${subject/${re}/"${string}"} != '\3' ]] && err_exit 'string replacement with "$string" not working with string=\3'
+[[ $(print -r "${subject/${re}/"${string}"}") != '\3' ]] && err_exit 'string replacement with "$string" not working with string=\3 using print'
+string='\\3'
+[[ ${subject/${re}/${string}} != '\3' ]] && err_exit 'string replacement with $string not working with string=\\3'
+[[ ${subject/${re}/"${string}"} != '\\3' ]] && err_exit 'string replacement with "$string" not working with string=\\3'
+[[ ${subject/${re}/\4} != '\4' ]] && err_exit 'string replacement with \4 not working'
+[[ ${subject/${re}/'\4'} != '\4' ]] && err_exit 'string replacement with '\4' not working'
+string='\4'
+[[ ${subject/${re}/${string}} != '\4' ]] && err_exit 'string replacement with $string not working with string=\4'
+[[ ${subject/${re}/"${string}"} != '\4' ]] && err_exit 'string replacement with "$string" not working with string=\4'
+string='&foo'
+[[ ${subject/${re}/${string}} != '&foo' ]] && err_exit 'string replacement with $string not working with string=&foo'
+[[ ${subject/${re}/"${string}"} != '&foo' ]] && err_exit 'string replacement with "$string" not working with string=&foo'
+{
+x=x
+x=${x:-`id | sed 's/^[^(]*(\([^)]*\)).*/\1/'`}
+} 2> /dev/null || err_exit 'skipping over `` failed'
+[[ $x == x ]] || err_exit 'assignment ${x:=`...`} failed'
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/quoting2.sh b/usr/src/lib/libshell/common/tests/quoting2.sh
new file mode 100644
index 0000000000..0532f72d7a
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/quoting2.sh
@@ -0,0 +1,200 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+integer Errors=0
+set -o noglob
+if [[ 'hi there' != "hi there" ]]
+then err_exit "single quotes not the same as double quotes"
+fi
+x='hi there'
+if [[ $x != 'hi there' ]]
+then err_exit "$x not the same as 'hi there'"
+fi
+if [[ $x != "hi there" ]]
+then err_exit "$x not the same as \"hi there \""
+fi
+if [[ \a\b\c\*\|\"\ \\ != 'abc*|" \' ]]
+then err_exit " \\ differs from '' "
+fi
+if [[ "ab\'\"\$(" != 'ab\'\''"$(' ]]
+then err_exit " \"\" differs from '' "
+fi
+if [[ $(print -r - 'abc*|" \') != 'abc*|" \' ]]
+then err_exit "\$(print -r - '') differs from ''"
+fi
+if [[ $(print -r - "abc*|\" \\") != 'abc*|" \' ]]
+then err_exit "\$(print -r - '') differs from ''"
+fi
+if [[ "$(print -r - 'abc*|" \')" != 'abc*|" \' ]]
+then err_exit "\"\$(print -r - '')\" differs from ''"
+fi
+if [[ "$(print -r - "abc*|\" \\")" != 'abc*|" \' ]]
+then err_exit "\"\$(print -r - "")\" differs from ''"
+fi
+if [[ $(print -r - "$(print -r - 'abc*|" \')") != 'abc*|" \' ]]
+then err_exit "nested \$(print -r - '') differs from ''"
+fi
+if [[ "$(print -r - $(print -r - 'abc*|" \'))" != 'abc*|" \' ]]
+then err_exit "\"nested \$(print -r - '')\" differs from ''"
+fi
+if [[ $(print -r - "$(print -r - 'abc*|" \')") != 'abc*|" \' ]]
+then err_exit "nested \"\$(print -r - '')\" differs from ''"
+fi
+unset x
+if [[ ${x-$(print -r - "abc*|\" \\")} != 'abc*|" \' ]]
+then err_exit "\${x-\$(print -r - '')} differs from ''"
+fi
+if [[ ${x-$(print -r - "a}c*|\" \\")} != 'a}c*|" \' ]]
+then err_exit "\${x-\$(print -r - '}')} differs from ''"
+fi
+x=$((echo foo)|(cat))
+if [[ $x != foo ]]
+then err_exit "((cmd)|(cmd)) failed"
+fi
+x=$(print -r -- "\"$HOME\"")
+if [[ $x != '"'$HOME'"' ]]
+then err_exit "nested double quotes failed"
+fi
+: ${z="a{b}c"}
+if [[ $z != 'a{b}c' ]]
+then err_exit '${z="a{b}c"} not correct'
+fi
+unset z
+: "${z="a{b}c"}"
+if [[ $z != 'a{b}c' ]]
+then err_exit '"${z="a{b}c"}" not correct'
+fi
+if [[ $(print -r -- "a\*b") != 'a\*b' ]]
+then err_exit '$(print -r -- "a\*b") differs from a\*b'
+fi
+unset x
+if [[ $(print -r -- "a\*b$x") != 'a\*b' ]]
+then err_exit '$(print -r -- "a\*b$x") differs from a\*b'
+fi
+x=hello
+set -- ${x+foo bar bam}
+if (( $# !=3 ))
+then err_exit '${x+foo bar bam} does not yield three arguments'
+fi
+set -- ${x+foo "bar bam"}
+if (( $# !=2 ))
+then err_exit '${x+foo "bar bam"} does not yield two arguments'
+fi
+set -- ${x+foo 'bar bam'}
+if (( $# !=2 ))
+then err_exit '${x+foo '\''bar bam'\''} does not yield two arguments'
+fi
+set -- ${x+foo $x bam}
+if (( $# !=3 ))
+then err_exit '${x+foo $x bam} does not yield three arguments'
+fi
+set -- ${x+foo "$x" bam}
+if (( $# !=3 ))
+then err_exit '${x+foo "$x" bam} does not yield three arguments'
+fi
+set -- ${x+"foo $x bam"}
+if (( $# !=1 ))
+then err_exit '${x+"foo $x bam"} does not yield one argument'
+fi
+set -- "${x+foo $x bam}"
+if (( $# !=1 ))
+then err_exit '"${x+foo $x bam}" does not yield one argument'
+fi
+set -- ${x+foo "$x "bam}
+if (( $# !=2 ))
+then err_exit '${x+foo "$x "bam} does not yield two arguments'
+fi
+x="ab$'cd"
+if [[ $x != 'ab$'"'cd" ]]
+then err_exit '$'"' inside double quotes not working"
+fi
+x=`print 'ab$'`
+if [[ $x != 'ab$' ]]
+then err_exit '$'"' inside `` quotes not working"
+fi
+unset a
+x=$(print -r -- "'\
+\
+")
+if [[ $x != "'" ]]
+then err_exit 'line continuation in double strings not working'
+fi
+x=$(print -r -- "'\
+$a\
+")
+if [[ $x != "'" ]]
+then err_exit 'line continuation in expanded double strings not working'
+fi
+x='\*'
+if [[ $(print -r -- $x) != '\*' ]]
+then err_exit 'x="\\*";$x != \*'
+fi
+if [[ $(print -r -- "\}" ) != '\}' ]]
+then err_exit '(print -r -- "\}"' not working
+fi
+if [[ $(print -r -- "\{" ) != '\{' ]]
+then err_exit 'print -r -- "\{"' not working
+fi
+# The following caused a syntax error on earlier versions
+foo=foo x=-
+if [[ `eval print \\${foo$x}` != foo* ]]
+then err_exit '`eval print \\${foo$x}`' not working
+fi
+if [[ "`eval print \\${foo$x}`" != foo* ]]
+then err_exit '"`eval print \\${foo$x}`"' not working
+fi
+if ( [[ $() != '' ]] )
+then err_exit '$() not working'
+fi
+x=a:b:c
+set -- $( IFS=:; print $x)
+if (( $# != 3))
+then err_exit 'IFS not working correctly with command substitution'
+fi
+$SHELL -n 2> /dev/null << \! || err_exit '$(...) bug with ( in comment'
+y=$(
+ # ( this line is a bug fix
+ print hi
+)
+!
+x=
+for j in glob noglob
+do for i in 'a\*b' 'a\ b' 'a\bc' 'a\*b' 'a\"b'
+ do eval [[ '$('print -r -- \'$i\'\$x')' != "'$i'" ]] && err_exit "quoting of $i\$x with $j enabled failed"
+ eval [[ '$('print -r -- \'$i\'\${x%*}')' != "'$i'" ]] && err_exit "quoting of $i\${x%*} with $j enabled failed"
+ if [[ $j == noglob ]]
+ then eval [[ '$('print -r -- \'$i\'\${x:-*}')' != "'$i''*'" ]] && err_exit "quoting of $i\${x:-*} with $j enabled failed"
+ fi
+ done
+ set -f
+done
+foo=foo
+[[ "$" == '$' ]] || err_exit '"$" != $'
+[[ "${foo}$" == 'foo$' ]] || err_exit 'foo=foo;"${foo}$" != foo$'
+[[ "${foo}${foo}$" == 'foofoo$' ]] || err_exit 'foo=foo;"${foo}${foo}$" != foofoo$'
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/return.sh b/usr/src/lib/libshell/common/tests/return.sh
new file mode 100644
index 0000000000..b3ee5b11ff
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/return.sh
@@ -0,0 +1,177 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+# test the behavior of return and exit with functions
+
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+integer Errors=0
+foo=NOVAL bar=NOVAL
+file=/tmp/shtest$$
+trap "rm -f $file" EXIT INT
+function foo
+{
+ typeset foo=NOEXIT
+ trap "foo=EXIT;rm -f $file" EXIT
+ > $file
+ if (( $1 == 0 ))
+ then return $2
+ elif (( $1 == 1 ))
+ then exit $2
+ else bar "$@"
+ fi
+}
+
+function bar
+{
+ typeset bar=NOEXIT
+ trap 'bar=EXIT' EXIT
+ if (( $1 == 2 ))
+ then return $2
+ elif (( $1 == 3 ))
+ then exit $2
+ fi
+}
+
+function funcheck
+{
+ [[ $foo = EXIT ]] || err_exit "foo "$@" : exit trap not set"
+ if [[ -f $file ]]
+ then rm -r $file
+ err_exit "foo $@: doesn't remove $file"
+ fi
+ foo=NOVAL bar=NOVAL
+}
+
+(exit 0) || err_exit "exit 0 is not zero"
+(return 0) || err_exit "return 0 is not zero"
+(exit) || err_exit "default exit value is not zero"
+(return) || err_exit "default return value is not zero"
+(exit 35)
+ret=$?
+if (( $ret != 35 ))
+then err_exit "exit 35 is $ret not 35"
+fi
+(return 35)
+ret=$?
+if (( $ret != 35 ))
+then err_exit "return 35 is $ret not 35"
+fi
+
+foo 0 0 || err_exit "foo 0 0: incorrect return"
+funcheck 0 0
+foo 0 3
+ret=$?
+if (( $ret != 3 ))
+then err_exit "foo 0 3: return is $ret not 3"
+fi
+funcheck 0 3
+foo 2 0 || err_exit "foo 2 0: incorrect return"
+[[ $bar = EXIT ]] || err_exit "foo 2 0: bar exit trap not set"
+funcheck 2 0
+foo 2 3
+ret=$?
+if (( $ret != 3 ))
+then err_exit "foo 2 3: return is $ret not 3"
+fi
+[[ $bar = EXIT ]] || err_exit "foo 2 3: bar exit trap not set"
+funcheck 2 3
+(foo 3 3)
+ret=$?
+if (( $ret != 3 ))
+then err_exit "foo 3 3: return is $ret not 3"
+fi
+foo=EXIT
+funcheck 3 3
+cat > $file <<!
+return 3
+exit 4
+!
+( . $file )
+ret=$?
+if (( $ret != 3 ))
+then err_exit "return in dot script is $ret should be 3"
+fi
+chmod 755 $file
+( $file )
+ret=$?
+if (( $ret != 3 ))
+then err_exit "return in script is $ret should be 3"
+fi
+cat > $file <<!
+: line 1
+# next line should fail and cause an exit
+: > /
+exit 4
+!
+( . $file ; exit 5 ) 2> /dev/null
+ret=$?
+if (( $ret != 1 ))
+then err_exit "error in dot script is $ret should be 1"
+fi
+( $file; exit 5 ) 2> /dev/null
+ret=$?
+if (( $ret != 5 ))
+then err_exit "error in script is $ret should be 5"
+fi
+cat > $file <<\!
+print -r -- "$0"
+!
+x=$( . $file)
+if [[ $x != $0 ]]
+then err_exit "\$0 in a dot script is $x. Should be $0"
+fi
+x=$($SHELL -i 2> /dev/null <<\!
+typeset -i x=1/0
+print hello
+!
+)
+if [[ $x != hello ]]
+then err_exit "interactive shell terminates with error in bltin"
+fi
+x=$( set -e
+ false
+ print bad
+ )
+if [[ $x != '' ]]
+then err_exit "set -e doesn't terminate script on error"
+fi
+x=$( set -e
+ trap 'exit 0' EXIT
+ false
+ print bad
+ )
+if (( $? != 0 ))
+then err_exit "exit 0 in trap should doesn't set exit value to 0"
+fi
+$SHELL <<\!
+trap 'exit 8' EXIT
+exit 1
+!
+if (( $? != 8 ))
+then err_exit "exit 8 in trap should set exit value to 8"
+fi
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/select.sh b/usr/src/lib/libshell/common/tests/select.sh
new file mode 100644
index 0000000000..aec1903fb7
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/select.sh
@@ -0,0 +1,63 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+integer Errors=0
+trap "rm -f /tmp/Sh$$*" EXIT
+PS3='ABC '
+
+cat > /tmp/Sh$$.1 <<\!
+1) foo
+2) bar
+3) bam
+!
+
+select i in foo bar bam
+do case $i in
+ foo) break;;
+ *) err_exit "select 1 not working"
+ break;;
+ esac
+done 2> /dev/null <<!
+1
+!
+
+unset i
+select i in foo bar bam
+do case $i in
+ foo) err_exit "select foo not working" 2>&3
+ break;;
+ *) if [[ $REPLY != foo ]]
+ then err_exit "select REPLY not correct" 2>&3
+ fi
+ ( set -u; : $i ) || err_exit "select: i not set to null" 2>&3
+ break;;
+ esac
+done 3>&2 2> /tmp/Sh$$.2 <<!
+foo
+!
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/shtests b/usr/src/lib/libshell/common/tests/shtests
new file mode 100644
index 0000000000..a094d8ed20
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/shtests
@@ -0,0 +1,63 @@
+# This program runs ksh regression tests
+# shtests [ name=value ... ] a.sh b.sh ...
+
+unset DISPLAY ENV FIGNORE
+LANG=C
+LC_ALL=C
+time=1
+while :
+do case $1 in
+ *=*) n=${1%%=*}
+ v=${1#*=}
+ eval $n=\'$v\'
+ export $n
+ ;;
+ -t|--t*)time=
+ ;;
+ *) break
+ ;;
+ esac
+ shift
+done
+export LANG LC_ALL PATH PWD SHELL
+PWD=`pwd`
+SHELL=${SHELL-ksh}
+case $0 in
+/*) d=`dirname $0`;;
+*/*) d=$PWD/`dirname $0`;;
+*) d=$PWD;;
+esac
+case $SHELL in
+/*) ;;
+*/*) SHELL=$d/$SHELL;;
+*) SHELL=$(whence $SHELL);;
+esac
+PATH=/bin:/usr/bin
+if [[ -d /usr/ucb ]]
+then PATH=$PATH:/usr/ucb
+fi
+PATH=$PATH:$d
+if [[ $INSTALLROOT && -r $INSTALLROOT/bin/.paths ]]
+then PATH=$INSTALLROOT/bin:$PATH
+fi
+for i in ${*-*.sh}
+do echo test $i begins ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"}
+ t=$(grep -c err_exit $i)
+ if (( $t ))
+ then (( t = $t - 1 ))
+ fi
+ T=test
+ if (( $t != 1 ))
+ then T=${T}s
+ fi
+ E=error
+ if $SHELL $i
+ then echo test $i passed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} "[ $t $T 0 ${E}s ]"
+ else e=$?
+ E=error
+ if (( $e != 1 ))
+ then E=${E}s
+ fi
+ echo test $i failed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} with exit code $e "[ $t $T $e $E ]"
+ fi
+done
diff --git a/usr/src/lib/libshell/common/tests/substring.sh b/usr/src/lib/libshell/common/tests/substring.sh
new file mode 100644
index 0000000000..2859d65671
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/substring.sh
@@ -0,0 +1,504 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+integer Errors=0 j=4
+base=/home/dgk/foo//bar
+string1=$base/abcabcabc
+if [[ ${string1:0} != "$string1" ]]
+then err_exit "string1:0"
+fi
+if [[ ${string1: -1} != "c" ]]
+then err_exit "string1: -1"
+fi
+if [[ ${string1:0:1000} != "$string1" ]]
+then err_exit "string1:0"
+fi
+if [[ ${string1:1} != "${string1#?}" ]]
+then err_exit "string1:1"
+fi
+if [[ ${string1:1:4} != home ]]
+then err_exit "string1:1:4"
+fi
+if [[ ${string1: -5:4} != bcab ]]
+then err_exit "string1: -5:4"
+fi
+if [[ ${string1:1:j} != home ]]
+then err_exit "string1:1:j"
+fi
+if [[ ${string1:(j?1:0):j} != home ]]
+then err_exit "string1:(j?1:0):j"
+fi
+if [[ ${string1%*zzz*} != "$string1" ]]
+then err_exit "string1%*zzz*"
+fi
+if [[ ${string1%%*zzz*} != "$string1" ]]
+then err_exit "string1%%*zzz*"
+fi
+if [[ ${string1#*zzz*} != "$string1" ]]
+then err_exit "string1#*zzz*"
+fi
+if [[ ${string1##*zzz*} != "$string1" ]]
+then err_exit "string1##*zzz*"
+fi
+if [[ ${string1%+(abc)} != "$base/abcabc" ]]
+then err_exit "string1%+(abc)"
+fi
+if [[ ${string1%%+(abc)} != "$base/" ]]
+then err_exit "string1%%+(abc)"
+fi
+if [[ ${string1%/*} != "$base" ]]
+then err_exit "string1%/*"
+fi
+if [[ "${string1%/*}" != "$base" ]]
+then err_exit '"string1%/*"'
+fi
+if [[ ${string1%"/*"} != "$string1" ]]
+then err_exit 'string1%"/*"'
+fi
+if [[ ${string1%%/*} != "" ]]
+then err_exit "string1%%/*"
+fi
+if [[ ${string1#*/bar} != /abcabcabc ]]
+then err_exit "string1#*bar"
+fi
+if [[ ${string1##*/bar} != /abcabcabc ]]
+then err_exit "string1#*bar"
+fi
+if [[ "${string1#@(*/bar|*/foo)}" != //bar/abcabcabc ]]
+then err_exit "string1#@(*/bar|*/foo)"
+fi
+if [[ ${string1##@(*/bar|*/foo)} != /abcabcabc ]]
+then err_exit "string1##@(*/bar|*/foo)"
+fi
+if [[ ${string1##*/@(bar|foo)} != /abcabcabc ]]
+then err_exit "string1##*/@(bar|foo)"
+fi
+foo=abc
+if [[ ${foo#a[b*} != abc ]]
+then err_exit "abc#a[b*} != abc"
+fi
+if [[ ${foo//[0-9]/bar} != abc ]]
+then err_exit '${foo//[0-9]/bar} not expanding correctly'
+fi
+foo='(abc)'
+if [[ ${foo#'('} != 'abc)' ]]
+then err_exit "(abc)#( != abc)"
+fi
+if [[ ${foo%')'} != '(abc' ]]
+then err_exit "(abc)%) != (abc"
+fi
+foo=a123b456c
+if [[ ${foo/[0-9]?/""} != a3b456c ]]
+then err_exit '${foo/[0-9]?/""} not expanding correctly'
+fi
+if [[ ${foo//[0-9]/""} != abc ]]
+then err_exit '${foo//[0-9]/""} not expanding correctly'
+fi
+if [[ ${foo/#a/b} != b123b456c ]]
+then err_exit '${foo/#a/b} not expanding correctly'
+fi
+if [[ ${foo/#?/b} != b123b456c ]]
+then err_exit '${foo/#?/b} not expanding correctly'
+fi
+if [[ ${foo/%c/b} != a123b456b ]]
+then err_exit '${foo/%c/b} not expanding correctly'
+fi
+if [[ ${foo/%?/b} != a123b456b ]]
+then err_exit '${foo/%?/b} not expanding correctly'
+fi
+while read -r pattern string expected
+do if (( expected ))
+ then if [[ $string != $pattern ]]
+ then err_exit "$pattern does not match $string"
+ fi
+ if [[ ${string##$pattern} != "" ]]
+ then err_exit "\${$string##$pattern} not null"
+ fi
+ if [ "${string##$pattern}" != '' ]
+ then err_exit "\"\${$string##$pattern}\" not null"
+ fi
+ if [[ ${string/$pattern} != "" ]]
+ then err_exit "\${$string/$pattern} not null"
+ fi
+ else if [[ $string == $pattern ]]
+ then err_exit "$pattern matches $string"
+ fi
+ fi
+done <<- \EOF
+ +(a)*+(a) aabca 1
+ !(*.o) foo.o 0
+ !(*.o) foo.c 1
+EOF
+xx=a/b/c/d/e
+yy=${xx#*/}
+if [[ $yy != b/c/d/e ]]
+then err_exit '${xx#*/} != a/b/c/d/e when xx=a/b/c/d/e'
+fi
+if [[ ${xx//\//\\} != 'a\b\c\d\e' ]]
+then err_exit '${xx//\//\\} not working'
+fi
+x=[123]def
+if [[ "${x//\[(*)\]/\{\1\}}" != {123}def ]]
+then err_exit 'closing brace escape not working'
+fi
+unset foo
+foo=one/two/three
+if [[ ${foo//'/'/_} != one_two_three ]]
+then err_exit 'single quoting / in replacements failed'
+fi
+if [[ ${foo//"/"/_} != one_two_three ]]
+then err_exit 'double quoting / in replacements failed'
+fi
+if [[ ${foo//\//_} != one_two_three ]]
+then err_exit 'escaping / in replacements failed'
+fi
+function myexport
+{
+ nameref var=$1
+ if (( $# > 1 ))
+ then export $1=$2
+ fi
+ if (( $# > 2 ))
+ then print $(myexport "$1" "$3" )
+ return
+ fi
+ typeset val
+ val=$(export | grep "^$1=")
+ print ${val#"$1="}
+
+}
+export dgk=base
+if [[ $(myexport dgk fun) != fun ]]
+then err_exit 'export inside function not working'
+fi
+val=$(export | grep "^dgk=")
+if [[ ${val#dgk=} != base ]]
+then err_exit 'export not restored after function call'
+fi
+if [[ $(myexport dgk fun fun2) != fun2 ]]
+then err_exit 'export inside function not working with recursive function'
+fi
+val=$(export | grep "^dgk=")
+if [[ ${val#dgk=} != base ]]
+then err_exit 'export not restored after recursive function call'
+fi
+if [[ $(dgk=try3 myexport dgk) != try3 ]]
+then err_exit 'name=value not added to export list with function call'
+fi
+val=$(export | grep "^dgk=")
+if [[ ${val#dgk=} != base ]]
+then err_exit 'export not restored name=value function call'
+fi
+unset zzz
+if [[ $(myexport zzz fun) != fun ]]
+then err_exit 'export inside function not working for zzz'
+fi
+if [[ $(export | grep "zzz=") ]]
+then err_exit 'zzz exported after function call'
+fi
+set -- foo/bar bam/yes last/file/done
+if [[ ${@/*\/@(*)/${.sh.match[1]}} != 'bar yes done' ]]
+then err_exit '.sh.match not working with $@'
+fi
+if [[ ${@/*\/@(*)/\1} != 'bar yes done' ]]
+then err_exit '\1 not working with $@'
+fi
+var=(foo/bar bam/yes last/file/done)
+if [[ ${var[@]/*\/@(*)/${.sh.match[1]}} != 'bar yes done' ]]
+then err_exit '.sh.match not working with ${var[@]}'
+fi
+if [[ ${var[@]/*\/@(*)/\1} != 'bar yes done' ]]
+then err_exit '\1 not working with ${var[@]}'
+fi
+var='abc_d2ef.462abc %%'
+if [[ ${var/+(\w)/Q} != 'Q.462abc %%' ]]
+then err_exit '${var/+(\w)/Q} not workding'
+fi
+if [[ ${var//+(\w)/Q} != 'Q.Q %%' ]]
+then err_exit '${var//+(\w)/Q} not workding'
+fi
+if [[ ${var//+(\S)/Q} != 'Q Q' ]]
+then err_exit '${var//+(\S)/Q} not workding'
+fi
+if [[ "$(LC_ALL=debug $SHELL <<- \+EOF+
+ x=a<2bc><3xyz>g
+ print ${#x}
+ +EOF+)" != 4
+ ]]
+then err_exit '${#x} not working with multibyte locales'
+fi
+foo='foo+bar+'
+[[ $(print -r -- ${foo//+/'|'}) != 'foo|bar|' ]] && err_exit "\${foobar//+/'|'}"
+[[ $(print -r -- ${foo//+/"|"}) != 'foo|bar|' ]] && err_exit '${foobar//+/"|"}'
+[[ $(print -r -- "${foo//+/'|'}") != 'foo|bar|' ]] && err_exit '"${foobar//+/'"'|'"'}"'
+[[ $(print -r -- "${foo//+/"|"}") != 'foo|bar|' ]] && err_exit '"${foobar//+/"|"}"'
+unset x
+x=abcedfg
+: ${x%@(d)f@(g)}
+[[ ${.sh.match[0]} == dfg ]] || err_exit '.sh.match[0] not dfg'
+[[ ${.sh.match[1]} == d ]] || err_exit '.sh.match[1] not d'
+[[ ${.sh.match[2]} == g ]] || err_exit '.sh.match[2] not g'
+x=abcedddfg
+: ${x%%+(d)f@(g)}
+[[ ${.sh.match[1]} == ddd ]] || err_exit '.sh.match[1] not ddd'
+unset a b
+a='\[abc @(*) def\]'
+b='[abc 123 def]'
+[[ ${b//$a/\1} == 123 ]] || err_exit "\${var/pattern} not working with \[ in pattern"
+unset X
+$SHELL -c '[[ ! ${X[@]:0:300} ]]' 2> /dev/null || err_exit '${X[@]:0:300} with X undefined fails'
+$SHELL -c '[[ ${@:0:300} == "$0" ]]' 2> /dev/null || err_exit '${@:0:300} with no arguments fails'
+i=20030704
+[[ ${i#{6}(?)} == 04 ]] || err_exit '${i#{6}(?)} not working'
+[[ ${i#{6,6}(?)} == 04 ]] || err_exit '${i#{6,6}(?)} not working'
+LC_ALL=posix
+i=" ."
+[[ $(printf "<%s>\n" ${i#' '}) == '<.>' ]] || err_exit 'printf "<%s>\n" ${i#' '} failed'
+unset x
+x=foo
+[[ "${x%o}(1)" == "fo(1)" ]] || err_exit 'print ${}() treated as pattern'
+unset i pattern string
+string=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz
+integer i
+for((i=0; i < ${#string}; i++))
+do pattern+='@(?)'
+done
+[[ $(string=$string $SHELL -c ": \${string/$pattern/}; print \${.sh.match[26]}") == Z ]] || err_exit -u2 'sh.match[26] not Z'
+: ${string/$pattern/}
+(( ${#.sh.match[@]} == 53 )) || err_exit '.sh.match has wrong number of elements'
+[[ ${.sh.match[@]:2:4} == 'B C D E' ]] || err_exit '${.sh.match[@]:2:4} incorrect'
+
+D=$';' E=$'\\\\' Q=$'"' S=$'\'' M='nested pattern substitution failed'
+
+x='-(-)-'
+[[ ${x/*%(())*/\1} == '(-)' ]] || err_exit $M
+x='-(-)-)-'
+[[ ${x/*%(())*/\1} == '(-)' ]] || err_exit $M
+x='-(-()-)-'
+[[ ${x/*%(())*/\1} == '()' ]] || err_exit $M
+x='-(-\)-)-'
+[[ ${x/*%(())*/\1} == '(-\)' ]] || err_exit $M
+x='-(-\\)-)-'
+[[ ${x/*%(())*/\1} == '(-\\)' ]] || err_exit $M
+x='-(-(-)-'
+[[ ${x/*%(())*/\1} == '(-)' ]] || err_exit $M
+x='-(-(-)-)-'
+[[ ${x/*%(())*/\1} == '(-)' ]] || err_exit $M
+x='-(-[-]-)-'
+[[ ${x/*%(()[])*/\1} == '(-[-]-)' ]] || err_exit $M
+x='-[-(-)-]-'
+[[ ${x/*%(()[])*/\1} == '(-)' ]] || err_exit $M
+x='-(-[-)-]-'
+[[ ${x/*%(()[])*/\1} == '-(-[-)-]-' ]] || err_exit $M
+x='-(-[-]-)-'
+[[ ${x/*%([]())*/\1} == '[-]' ]] || err_exit $M
+x='-[-(-)-]-'
+[[ ${x/*%([]())*/\1} == '[-(-)-]' ]] || err_exit $M
+x='-(-[-)-]-'
+[[ ${x/*%([]())*/\1} == '-(-[-)-]-' ]] || err_exit $M
+
+x='-((-))-'
+[[ ${x/*%(())*/\1} == '(-)' ]] || err_exit $M
+x='-((-))-'
+[[ ${x/~(-g)*%(())*/\1} == '((-))-' ]] || err_exit $M
+x='-((-))-'
+[[ ${x/~(-g:*)*%(())*/\1} == '(-)' ]] || err_exit $M
+x='-((-))-'
+[[ ${x/~(+g)*%(())*/\1} == '(-)' ]] || err_exit $M
+x='-((-))-'
+[[ ${x/~(+g:*)*%(())*/\1} == '(-)' ]] || err_exit $M
+x='-((-))-'
+[[ ${x/*(?)*%(())*(?)*/:\1:\2:\3:} == ':-(:(-):)-:' ]] || err_exit $M
+x='-((-))-'
+[[ ${x/~(-g)*(?)*%(())*(?)*/:\1:\2:\3:} == '::((-))::-' ]] || err_exit $M
+x='-((-))-'
+[[ ${x/~(-g:*(?))*%(())*(?)*/:\1:\2:\3:} == '::(-):)-:' ]] || err_exit $M
+x='-((-))-'
+[[ ${x/~(+g)*(?)*%(())*(?)*/:\1:\2:\3:} == ':-(:(-):)-:' ]] || err_exit $M
+x='-((-))-'
+[[ ${x/~(+g:*(?))*%(())*(?)*/:\1:\2:\3:} == ':-(:(-):)-:' ]] || err_exit $M
+x='call(a+b,x/(c/d),(0));'
+[[ ${x/+([[:alnum:]])*([[:space:]])(*%(()))*/:\1:\2:\3:} == ':call::(a+b,x/(c/d),(0)):' ]] || err_exit $M
+
+x='-(-;-)-'
+[[ ${x/*%(()D${D})*/\1} == '-(-;-)-' ]] || err_exit $M
+x='-(-);-'
+[[ ${x/*%(()D${D})*/\1} == '(-)' ]] || err_exit $M
+x='-(-)\;-'
+[[ ${x/*%(()D${D})*/\1} == '(-)' ]] || err_exit $M
+x='-(-\;-)-'
+[[ ${x/*%(()D${D}E${E})*/\1} == '(-\;-)' ]] || err_exit $M
+x='-(-)\;-'
+[[ ${x/*%(()D${D}E${E})*/\1} == '(-)' ]] || err_exit $M
+x='-(-(-)\;-)-'
+[[ ${x/*%(()D${D}E${E})*/\1} == '(-)' ]] || err_exit $M
+
+x='-(-")"-)-'
+[[ ${x/*%(()Q${Q})*/\1} == '(-")"-)' ]] || err_exit $M
+x='-(-\")"-)-'
+[[ ${x/*%(()Q${Q})*/\1} == '(-\")"-)' ]] || err_exit $M
+x='-(-\")\"-)-'
+[[ ${x/*%(()Q${Q})*/\1} == '(-\")\"-)' ]] || err_exit $M
+x=$'-(-\\\'")\\\'-)-'
+[[ ${x/*%(()Q${S}Q${Q})*/\1} == $'(-\\\'")\\\'-)' ]] || err_exit $M
+x=$'-(-\\\'")"-)-'
+[[ ${x/*%(()Q${S}Q${Q})*/\1} == $'-(-\\\'")"-)-' ]] || err_exit $M
+x=$'-(-\\\'")"\'-)-'
+[[ ${x/*%(()Q${S}Q${Q})*/\1} == $'(-\\\'")"\'-)' ]] || err_exit $M
+x=$'-(-\\"\')\'\\"-)-'
+[[ ${x/*%(()Q${S}Q${Q})*/\1} == $'(-\\"\')\'\\"-)' ]] || err_exit $M
+x=$'-(-\')\\\'\'-)-'
+[[ ${x/*%(()Q${S}Q${Q})*/\1} == $'-(-\')\\\'\'-)-' ]] || err_exit $M
+x=$'-(-\'")\'-)-'
+[[ ${x/*%(()L${S}Q${Q})*/\1} == $'(-\'")\'-)' ]] || err_exit $M
+x=$'-(-\\\'")"-)-'
+[[ ${x/*%(()L${S}Q${Q})*/\1} == $'-(-\\\'")"-)-' ]] || err_exit $M
+x=$'-(-\\\'")"\'-)-'
+[[ ${x/*%(()L${S}Q${Q})*/\1} == $'(-\\\'")"\'-)' ]] || err_exit $M
+x=$'-(-\\"\')\'\\"-)-'
+[[ ${x/*%(()L${S}Q${Q})*/\1} == $'(-\\"\')\'\\"-)' ]] || err_exit $M
+x=$'-(-\')\\\'\'-)-'
+[[ ${x/*%(()L${S}Q${Q})*/\1} == $'-(-\')\\\'\'-)-' ]] || err_exit $M
+x='-(-")"-)-'
+[[ ${x/*%(()Q${Q})*/\1} == '(-")"-)' ]] || err_exit $M
+x='-(-\")"-)-'
+[[ ${x/*%(()Q${Q})*/\1} == '(-\")"-)' ]] || err_exit $M
+x='-(-\")\"-)-'
+[[ ${x/*%(()Q${Q})*/\1} == '(-\")\"-)' ]] || err_exit $M
+
+x='-(-\)-)-'
+[[ ${x/*%(()E${E})*/\1} == '(-\)-)' ]] || err_exit $M
+x='-(-\\)-)-'
+[[ ${x/*%(()E${E})*/\1} == '(-\\)' ]] || err_exit $M
+x='-(-\")"-)-'
+[[ ${x/*%(()E${E}Q${Q})*/\1} == '(-\")' ]] || err_exit $M
+x='-(-\")\"-)-'
+[[ ${x/*%(()E${E}Q${Q})*/\1} == '(-\")' ]] || err_exit $M
+x=$'-(-\'")"-)-'
+[[ ${x/*%(()E${E}Q${S}Q${Q})*/\1} == $'-(-\'")"-)-' ]] || err_exit $M
+x=$'-(-\\\'")"-)-'
+[[ ${x/*%(()E${E}Q${S}Q${Q})*/\1} == $'(-\\\'")"-)' ]] || err_exit $M
+x=$'-(-\\"\')\'\\"-)-'
+[[ ${x/*%(()E${E}Q${S}Q${Q})*/\1} == $'(-\\"\')\'\\"-)' ]] || err_exit $M
+x=$'-(-\\\'")"-)-'
+[[ ${x/*%(()E${E}L${S}Q${Q})*/\1} == $'(-\\\'")"-)' ]] || err_exit $M
+x=$'-(-\\"\')\'\\"-)-'
+[[ ${x/*%(()E${E}L${S}Q${Q})*/\1} == $'(-\\"\')\'\\"-)' ]] || err_exit $M
+x=$'-(-\\"\')\\\'\\"-)-'
+[[ ${x/*%(()E${E}L${S}Q${Q})*/\1} == $'(-\\"\')\\\'\\"-)' ]] || err_exit $M
+x=$'-(-\\"\')\\\'\\"\'-)-'
+[[ ${x/*%(()E${E}L${S}Q${Q})*/\1} == $'-(-\\"\')\\\'\\"\'-)-' ]] || err_exit $M
+
+x='-(-;-)-'
+[[ ${x/*%(()D\;)*/\1} == '-(-;-)-' ]] || err_exit $M
+x='-(-);-'
+[[ ${x/*%(()D\;)*/\1} == '(-)' ]] || err_exit $M
+x='-(-)\;-'
+[[ ${x/*%(()D\;)*/\1} == '(-)' ]] || err_exit $M
+x='-(-\;-)-'
+[[ ${x/*%(()D\;E\\)*/\1} == '(-\;-)' ]] || err_exit $M
+x='-(-);-'
+[[ ${x/*%(()D\;E\\)*/\1} == '(-)' ]] || err_exit $M
+x='-(-)\;-'
+[[ ${x/*%(()D\;E\\)*/\1} == '(-)' ]] || err_exit $M
+x='-(-(-)\;-)-'
+[[ ${x/*%(()D\;E\\)*/\1} == '(-)' ]] || err_exit $M
+
+x='-(-")"-)-'
+[[ ${x/*%(()Q\")*/\1} == '(-")"-)' ]] || err_exit $M
+x='-(-\")"-)-'
+[[ ${x/*%(()Q\")*/\1} == '(-\")"-)' ]] || err_exit $M
+x='-(-\")\"-)-'
+[[ ${x/*%(()Q\")*/\1} == '(-\")\"-)' ]] || err_exit $M
+x=$'-(-\\\'")\\\'-)-'
+[[ ${x/*%(()Q\'Q\")*/\1} == $'(-\\\'")\\\'-)' ]] || err_exit $M
+x=$'-(-\\\'")"-)-'
+[[ ${x/*%(()Q\'Q\")*/\1} == $'-(-\\\'")"-)-' ]] || err_exit $M
+x=$'-(-\\\'")"\'-)-'
+[[ ${x/*%(()Q\'Q\")*/\1} == $'(-\\\'")"\'-)' ]] || err_exit $M
+x=$'-(-\\"\')\'\\"-)-'
+[[ ${x/*%(()Q\'Q\")*/\1} == $'(-\\"\')\'\\"-)' ]] || err_exit $M
+x=$'-(-\')\\\'\'-)-'
+[[ ${x/*%(()Q\'Q\")*/\1} == $'-(-\')\\\'\'-)-' ]] || err_exit $M
+x=$'-(-\'")\'-)-'
+[[ ${x/*%(()L\'Q\")*/\1} == $'(-\'")\'-)' ]] || err_exit $M
+x=$'-(-\\\'")"-)-'
+[[ ${x/*%(()L\'Q\")*/\1} == $'-(-\\\'")"-)-' ]] || err_exit $M
+x=$'-(-\\\'")"\'-)-'
+[[ ${x/*%(()L\'Q\")*/\1} == $'(-\\\'")"\'-)' ]] || err_exit $M
+x=$'-(-\\"\')\'\\"-)-'
+[[ ${x/*%(()L\'Q\")*/\1} == $'(-\\"\')\'\\"-)' ]] || err_exit $M
+x=$'-(-\')\\\'\'-)-'
+[[ ${x/*%(()L\'Q\")*/\1} == $'-(-\')\\\'\'-)-' ]] || err_exit $M
+x='-(-")"-)-'
+[[ ${x/*%(()Q\")*/\1} == '(-")"-)' ]] || err_exit $M
+x='-(-\")"-)-'
+[[ ${x/*%(()Q\")*/\1} == '(-\")"-)' ]] || err_exit $M
+x='-(-\")\"-)-'
+[[ ${x/*%(()Q\")*/\1} == '(-\")\"-)' ]] || err_exit $M
+
+x='-(-\)-)-'
+[[ ${x/*%(()E\\)*/\1} == '(-\)-)' ]] || err_exit $M
+x='-(-\\)-)-'
+[[ ${x/*%(()E\\)*/\1} == '(-\\)' ]] || err_exit $M
+x='-(-\")"-)-'
+[[ ${x/*%(()E\\Q\")*/\1} == '(-\")' ]] || err_exit $M
+x='-(-\")\"-)-'
+[[ ${x/*%(()E\\Q\")*/\1} == '(-\")' ]] || err_exit $M
+x=$'-(-\'")"-)-'
+[[ ${x/*%(()E\\Q\'Q\")*/\1} == $'-(-\'")"-)-' ]] || err_exit $M
+x=$'-(-\\\'")"-)-'
+[[ ${x/*%(()E\\Q\'Q\")*/\1} == $'(-\\\'")"-)' ]] || err_exit $M
+x=$'-(-\\"\')\'\\"-)-'
+[[ ${x/*%(()E\\Q\'Q\")*/\1} == $'(-\\"\')\'\\"-)' ]] || err_exit $M
+x=$'-(-\\\'")"-)-'
+[[ ${x/*%(()E\\L\'Q\")*/\1} == $'(-\\\'")"-)' ]] || err_exit $M
+x=$'-(-\\"\')\'\\"-)-'
+[[ ${x/*%(()E\\L\'Q\")*/\1} == $'(-\\"\')\'\\"-)' ]] || err_exit $M
+x=$'-(-\\"\')\\\'\\"-)-'
+[[ ${x/*%(()E\\L\'Q\")*/\1} == $'(-\\"\')\\\'\\"-)' ]] || err_exit $M
+x=$'-(-\\"\')\\\'\\"\'-)-'
+[[ ${x/*%(()E\\L\'Q\")*/\1} == $'-(-\\"\')\\\'\\"\'-)-' ]] || err_exit $M
+
+pattern=00
+var=100
+[[ $( print $(( ${var%%00} )) ) == 1 ]] || err_exit "arithmetic with embeddded patterns fails"
+[[ $( print $(( ${var%%$pattern} )) ) == 1 ]] || err_exit "arithmetic with embeddded pattern variables fails"
+if [[ ax == @(a)* ]] && [[ ${.sh.match[1]:0:${#.sh.match[1]}} != a ]]
+then err_exit '${.sh.match[1]:1:${#.sh.match[1]}} not expanding correctly'
+fi
+
+string='foo(d:\nt\box\something)bar'
+expected='d:\nt\box\something'
+[[ ${string/*\(+([!\)])\)*/\1} == "$expected" ]] || err_exit "substring expansion failed '${string/*\(+([!\)])\)*/\1}' returned -- '$expected' expected"
+if [[ $($SHELL -c $'export LC_ALL=en_US.UTF-8; print -r "\342\202\254\342\202\254\342\202\254\342\202\254w\342\202\254\342\202\254\342\202\254\342\202\254" | wc -m' 2>/dev/null) == 10 ]]
+then LC_ALL=en_US.UTF-8 $SHELL -c b1=$'"\342\202\254\342\202\254\342\202\254\342\202\254w\342\202\254\342\202\254\342\202\254\342\202\254"; [[ ${b1:4:1} == w ]]' || err_exit 'Multibyte ${var:offset:len} not working correctly'
+fi
+{ $SHELL -c 'unset x;[[ ${SHELL:$x} == $SHELL ]]';} 2> /dev/null || err_exit '${var:$x} fails when x is not set'
+{ $SHELL -c 'x=;[[ ${SHELL:$x} == $SHELL ]]';} 2> /dev/null || err_exit '${var:$x} fails when x is null'
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/sun_solaris_getconf.sh b/usr/src/lib/libshell/common/tests/sun_solaris_getconf.sh
new file mode 100644
index 0000000000..a8eaeb75f6
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/sun_solaris_getconf.sh
@@ -0,0 +1,160 @@
+#!/bin/ksh93
+
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+#
+# sun_solaris_getconf.sh - test the ksh93 getconf builtin for compatibility
+# with /usr/bin/getconf
+#
+
+# test setup
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+integer Errors=0
+
+
+# setup
+integer mismatch # counts mismatches between builtin and external command
+integer getconf_keys # counts tests (paranoid check to make sure the test loop works)
+export PATH=/usr/bin:/bin
+
+# prechecks
+[ ! -f "/bin/getconf" ] && err_exit '/bin/getconf not found.'
+[ ! -x "/bin/getconf" ] && err_exit '/bin/getconf not executable.'
+
+# compare builtin getconf output with /usr/bin/getconf
+function compare_normal
+{
+ mismach=0 getconf_keys=0
+ /usr/bin/getconf -a |
+ while read i ; do
+ let getconf_keys++
+ t="${i%:*}"
+
+ a="$(getconf "$t" 2>/dev/null)"
+ b="$(/usr/bin/getconf "$t" 2>/dev/null)"
+
+ if [ "$a" != "$b" ] ; then
+ print -u2 "getconf/normal built mismatch: |$t|:|$a| != |$b|"
+ let mismatch++
+ fi
+ done
+}
+
+# compare builtin getconf output with /usr/bin/getconf while passing a path argument
+function compare_path
+{
+ mismach=0 getconf_keys=0
+ /usr/bin/getconf -a |
+ while read i ; do
+ let getconf_keys++
+ t="${i%:*}"
+
+ a="$(getconf "$t" "/tmp" 2>/dev/null)"
+ b="$(/usr/bin/getconf "$t" "/tmp" 2>/dev/null)"
+
+ if [ "$a" != "$b" ] ; then
+ print -u2 "getconf/path built mismatch: |$t|:|$a| != |$b|"
+ let mismatch++
+ fi
+ done
+}
+
+# future versions of this test should test the following ${PATH}s, too:
+# "/usr/xpg6/bin:/usr/xpg4/bin:/bin:/usr/bin" \
+#"/usr/xpg4/bin:/bin:/usr/bin" \
+for i in \
+ "/bin:/usr/bin"
+do
+ export PATH="${i}"
+
+ ## test whether the getconf builtin is available
+ if [ "$(builtin | fgrep "/bin/getconf")" = "" ] ; then
+ err_exit '/bin/getconf not found in the list of builtins.'
+ fi
+
+
+ ## compare "getconf -a" output
+ if [ "$(getconf -a)" != "$(/usr/bin/getconf -a)" ] ; then
+ err_exit 'getconf -a output mismatch.'
+ fi
+
+
+ ## check for a key which is only supported by the AST builtin version of getconf:
+ if [ "$(getconf LIBPREFIX)" != "lib" ] ; then
+ err_exit 'getconf LIBPREFIX did not return "lib".'
+ fi
+
+
+ ## run normal test
+ compare_normal
+ [ ${getconf_keys} -eq 0 ] && err_exit "getconf/normal not working (PATH=${PATH})."
+ [ ${mismatch} -gt 0 ] && err_exit "getconf/normal test found ${mismatch} differences (PATH=${PATH})."
+
+ # run the same test in a seperate shell
+ # (we explicitly test this because ast-ksh.2007-01-11 picks up /usr/xpg6/bin/getconf
+ # if /usr/xpg6/bin/ comes in ${PATH} before /usr/bin (this happens only of ${PATH}
+ # contains /usr/xpg6/bin before ksh93 is started)).
+ ${SHELL} -c "integer mismatch ; \
+ integer getconf_keys ; \
+ $(functions) ; \
+ compare_normal ;
+ [ \${getconf_keys} -eq 0 ] && err_exit \"getconf/normal not working (PATH=\${PATH}).\" ; \
+ [ \${mismatch} -gt 0 ] && err_exit \"getconf/normal test found \${mismatch} differences (PATH=\${PATH}).\" ; \
+ exit $((Errors))"
+ let Errors+=$?
+
+
+ ## run test with path argument
+ compare_path
+ [ ${getconf_keys} -eq 0 ] && err_exit "getconf/path not working."
+ [ ${mismatch} -gt 0 ] && err_exit "getconf/path test found ${mismatch} differences."
+
+ # run the same test in a seperate shell
+ # (see comment above)
+ ${SHELL} -c "integer mismatch ; \
+ integer getconf_keys ; \
+ $(functions) ; \
+ compare_path ;
+ [ \${getconf_keys} -eq 0 ] && err_exit \"getconf/normal not working (PATH=\${PATH}).\" ; \
+ [ \${mismatch} -gt 0 ] && err_exit \"getconf/normal test found \${mismatch} differences (PATH=\${PATH}).\" ; \
+ exit $((Errors))"
+ let Errors+=$?
+done
+
+# test done
+exit $((Errors))
+
diff --git a/usr/src/lib/libshell/common/tests/tilde.sh b/usr/src/lib/libshell/common/tests/tilde.sh
new file mode 100644
index 0000000000..6ebfd8504c
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/tilde.sh
@@ -0,0 +1,87 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r $Command: "$@"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+function home # id
+{
+ typeset IFS=: pwd=/etc/passwd
+ set -o noglob
+ if [[ -f $pwd ]] && grep -c "^$1:" $pwd > /dev/null
+ then set -- $(grep "^$1:" $pwd)
+ print -r -- "$6"
+ else print .
+ fi
+}
+
+Command=${0##*/}
+integer Errors=0
+OLDPWD=/bin
+if [[ ~ != $HOME ]]
+then err_exit '~' not $HOME
+fi
+x=~
+if [[ $x != $HOME ]]
+then err_exit x=~ not $HOME
+fi
+x=x:~
+if [[ $x != x:$HOME ]]
+then err_exit x=x:~ not x:$HOME
+fi
+if [[ ~+ != $PWD ]]
+then err_exit '~' not $PWD
+fi
+x=~+
+if [[ $x != $PWD ]]
+then err_exit x=~+ not $PWD
+fi
+if [[ ~- != $OLDPWD ]]
+then err_exit '~' not $PWD
+fi
+x=~-
+if [[ $x != $OLDPWD ]]
+then err_exit x=~- not $OLDPWD
+fi
+for u in root Administrator
+do h=$(home $u)
+ if [[ $h != . ]]
+ then [[ ~$u -ef $h ]] || err_exit "~$u not $h"
+ x=~$u
+ [[ $x -ef $h ]] || "x=~$u not $h"
+ break
+ fi
+done
+x=~%%
+if [[ $x != '~%%' ]]
+then err_exit 'x='~%%' not '~%%
+fi
+x=~:~
+if [[ $x != "$HOME:$HOME" ]]
+then err_exit x=~:~ not $HOME:$HOME
+fi
+HOME=/
+[[ ~ == / ]] || err_exit '~ should be /'
+[[ ~/foo == /foo ]] || err_exit '~/foo should be /foo when ~==/'
+exit $((Errors))
diff --git a/usr/src/lib/libshell/common/tests/variables.sh b/usr/src/lib/libshell/common/tests/variables.sh
new file mode 100644
index 0000000000..bc499c890c
--- /dev/null
+++ b/usr/src/lib/libshell/common/tests/variables.sh
@@ -0,0 +1,558 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
+# and is licensed under the #
+# Common Public License, Version 1.0 #
+# by AT&T Knowledge Ventures #
+# #
+# A copy of the License is available at #
+# http://www.opensource.org/licenses/cpl1.0.txt #
+# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
+# #
+# Information and Software Systems Research #
+# AT&T Research #
+# Florham Park NJ #
+# #
+# David Korn <dgk@research.att.com> #
+# #
+########################################################################
+function err_exit
+{
+ print -u2 -n "\t"
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ let Errors+=1
+}
+alias err_exit='err_exit $LINENO'
+
+Command=${0##*/}
+integer Errors=0
+# RANDOM
+if (( RANDOM==RANDOM || $RANDOM==$RANDOM ))
+then err_exit RANDOM variable not working
+fi
+# SECONDS
+sleep 3
+if (( SECONDS < 2 ))
+then err_exit SECONDS variable not working
+fi
+# _
+set abc def
+if [[ $_ != def ]]
+then err_exit _ variable not working
+fi
+# ERRNO
+#set abc def
+#rm -f foobar#
+#ERRNO=
+#2> /dev/null < foobar#
+#if (( ERRNO == 0 ))
+#then err_exit ERRNO variable not working
+#fi
+# PWD
+if [[ ! $PWD -ef . ]]
+then err_exit PWD variable not working
+fi
+# PPID
+if [[ $($SHELL -c 'print $PPID') != $$ ]]
+then err_exit PPID variable not working
+fi
+# OLDPWD
+old=$PWD
+cd /
+if [[ $OLDPWD != $old ]]
+then err_exit OLDPWD variable not working
+fi
+cd $old || err_exit cd failed
+# REPLY
+read <<-!
+ foobar
+ !
+if [[ $REPLY != foobar ]]
+then err_exit REPLY variable not working
+fi
+integer save=$LINENO
+# LINENO
+LINENO=10
+#
+# These lines intentionally left blank
+#
+if (( LINENO != 13))
+then err_exit LINENO variable not working
+fi
+LINENO=save+10
+IFS=:
+x=a::b::c
+if [[ $x != a::b::c ]]
+then err_exit "Word splitting on constants"
+fi
+set -- $x
+if [[ $# != 5 ]]
+then err_exit ":: doesn't separate null arguments "
+fi
+set x
+if x$1=0 2> /dev/null
+then err_exit "x\$1=value treated as an assignment"
+fi
+# check for attributes across subshells
+typeset -i x=3
+y=1/0
+if ( typeset x=y) 2> /dev/null
+then print -u2 "attributes not passed to subshells"
+fi
+unset x
+function x.set
+{
+ nameref foo=${.sh.name}.save
+ foo=${.sh.value}
+ .sh.value=$0
+}
+x=bar
+if [[ $x != x.set ]]
+then err_exit 'x.set does not override assignment'
+fi
+x.get()
+{
+ nameref foo=${.sh.name}.save
+ .sh.value=$foo
+}
+
+if [[ $x != bar ]]
+then err_exit 'x.get does not work correctly'
+fi
+typeset +n foo
+unset foo
+foo=bar
+(
+ unset foo
+ set +u
+ if [[ $foo != '' ]]
+ then err_exit '$foo not null after unset in subsehll'
+ fi
+)
+if [[ $foo != bar ]]
+then err_exit 'unset foo in subshell produces side effect '
+fi
+unset foo
+if [[ $( { : ${foo?hi there} ; } 2>&1) != *'hi there' ]]
+then err_exit '${foo?hi there} with foo unset does not print hi there on 2'
+fi
+x=$0
+set foobar
+if [[ ${@:0} != "$x foobar" ]]
+then err_exit '${@:0} not expanding correctly'
+fi
+set --
+if [[ ${*:0:1} != "$0" ]]
+then err_exit '${@:0} not expanding correctly'
+fi
+ACCESS=0
+function COUNT.set
+{
+ (( ACCESS++ ))
+}
+COUNT=0
+(( COUNT++ ))
+if (( COUNT != 1 || ACCESS!=2 ))
+then err_exit " set discipline failure COUNT=$COUNT ACCESS=$ACCESS"
+fi
+LANG=C > /dev/null 2>&1
+if [[ $LANG != C ]]
+then err_exit "C locale not working"
+fi
+unset RANDOM
+unset -n foo
+foo=junk
+function foo.get
+{
+ .sh.value=stuff
+ unset -f foo.get
+}
+if [[ $foo != stuff ]]
+then err_exit "foo.get discipline not working"
+fi
+if [[ $foo != junk ]]
+then err_exit "foo.get discipline not working after unset"
+fi
+# special variables
+set -- 1 2 3 4 5 6 7 8 9 10
+sleep 1000 &
+if [[ $(print -r -- ${#10}) != 2 ]]
+then err_exit '${#10}, where ${10}=10 not working'
+fi
+for i in @ '*' ! '#' - '?' '$'
+do false
+ eval foo='$'$i bar='$'{$i}
+ if [[ ${foo} != "${bar}" ]]
+ then err_exit "\$$i not equal to \${$i}"
+ fi
+ command eval bar='$'{$i%?} 2> /dev/null || err_exit "\${$i%?} gives syntax error"
+ if [[ $i != [@*] && ${foo%?} != "$bar" ]]
+ then err_exit "\${$i%?} not correct"
+ fi
+ command eval bar='$'{$i#?} 2> /dev/null || err_exit "\${$i#?} gives syntax error"
+ if [[ $i != [@*] && ${foo#?} != "$bar" ]]
+ then err_exit "\${$i#?} not correct"
+ fi
+ command eval foo='$'{$i} bar='$'{#$i} || err_exit "\${#$i} gives synta
+x error"
+ if [[ $i != @([@*]) && ${#foo} != "$bar" ]]
+ then err_exit "\${#$i} not correct"
+ fi
+done
+kill $!
+unset x
+CDPATH=/
+x=$(cd tmp)
+if [[ $x != /tmp ]]
+then err_exit 'CDPATH does not display new directory'
+fi
+mkdir /tmp/ksh$$
+CDPATH=/:
+x=$(cd /tmp;cd ksh$$)
+if [[ $x ]]
+then err_exit 'CDPATH displays new directory when not used'
+fi
+x=$(cd tmp/ksh$$)
+if [[ $x != /tmp/ksh$$ ]]
+then err_exit "CDPATH tmp/ksh$$ does not display new directory"
+fi
+cd /
+rm -rf /tmp/ksh$$
+TMOUT=100
+(TMOUT=20)
+if (( TMOUT !=100 ))
+then err_exit 'setting TMOUT in subshell affects parent'
+fi
+unset y
+function setdisc # var
+{
+ eval function $1.get'
+ {
+ .sh.value=good
+ }
+ '
+}
+y=bad
+setdisc y
+if [[ $y != good ]]
+then err_exit 'setdisc function not working'
+fi
+integer x=$LINENO
+: $'\
+'
+if (( LINENO != x+3 ))
+then err_exit '\<newline> gets linenumber count wrong'
+fi
+set --
+set -- "${@-}"
+if (( $# !=1 ))
+then err_exit '"${@-}" not expanding to null string'
+fi
+for i in : % + / 3b '**' '***' '@@' '{' '[' '}' !! '*a' '@a' '$foo'
+do (eval : \${"$i"} 2> /dev/null) && err_exit "\${$i} not an syntax error"
+done
+unset IFS
+( IFS=' ' ; read -r a b c <<-!
+ x y z
+ !
+ if [[ $b ]]
+ then err_exit 'IFS=" " not causing adjacent space to be null string'
+ fi
+)
+read -r a b c <<-!
+x y z
+!
+if [[ $b != y ]]
+then err_exit 'IFS not restored after subshell'
+fi
+
+# The next part generates 3428 IFS set/read tests.
+
+unset IFS x
+function split
+{
+ i=$1 s=$2 r=$3
+ IFS=': '
+ set -- $i
+ IFS=' '
+ g="[$#]"
+ while :
+ do case $# in
+ 0) break ;;
+ esac
+ g="$g($1)"
+ shift
+ done
+ case "$g" in
+ "$s") ;;
+ *) err_exit "IFS=': '; set -- '$i'; expected '$s' got '$g'" ;;
+ esac
+ print "$i" | IFS=": " read arg rem; g="($arg)($rem)"
+ case "$g" in
+ "$r") ;;
+ *) err_exit "IFS=': '; read '$i'; expected '$r' got '$g'" ;;
+ esac
+}
+for str in \
+ '-' \
+ 'a' \
+ '- -' \
+ '- a' \
+ 'a -' \
+ 'a b' \
+ '- - -' \
+ '- - a' \
+ '- a -' \
+ '- a b' \
+ 'a - -' \
+ 'a - b' \
+ 'a b -' \
+ 'a b c'
+do
+ IFS=' '
+ set x $str
+ shift
+ case $# in
+ 0) continue ;;
+ esac
+ f1=$1
+ case $f1 in
+ '-') f1='' ;;
+ esac
+ shift
+ case $# in
+ 0) for d0 in '' ' '
+ do
+ for d1 in '' ' ' ':' ' :' ': ' ' : '
+ do
+ case $f1$d1 in
+ '') split "$d0$f1$d1" "[0]" "()()" ;;
+ ' ') ;;
+ *) split "$d0$f1$d1" "[1]($f1)" "($f1)()" ;;
+ esac
+ done
+ done
+ continue
+ ;;
+ esac
+ f2=$1
+ case $f2 in
+ '-') f2='' ;;
+ esac
+ shift
+ case $# in
+ 0) for d0 in '' ' '
+ do
+ for d1 in ' ' ':' ' :' ': ' ' : '
+ do
+ case ' ' in
+ $f1$d1|$d1$f2) continue ;;
+ esac
+ for d2 in '' ' ' ':' ' :' ': ' ' : '
+ do
+ case $f2$d2 in
+ '') split "$d0$f1$d1$f2$d2" "[1]($f1)" "($f1)()" ;;
+ ' ') ;;
+ *) split "$d0$f1$d1$f2$d2" "[2]($f1)($f2)" "($f1)($f2)" ;;
+ esac
+ done
+ done
+ done
+ continue
+ ;;
+ esac
+ f3=$1
+ case $f3 in
+ '-') f3='' ;;
+ esac
+ shift
+ case $# in
+ 0) for d0 in '' ' '
+ do
+ for d1 in ':' ' :' ': ' ' : '
+ do
+ case ' ' in
+ $f1$d1|$d1$f2) continue ;;
+ esac
+ for d2 in ' ' ':' ' :' ': ' ' : '
+ do
+ case $f2$d2 in
+ ' ') continue ;;
+ esac
+ case ' ' in
+ $f2$d2|$d2$f3) continue ;;
+ esac
+ for d3 in '' ' ' ':' ' :' ': ' ' : '
+ do
+ case $f3$d3 in
+ '') split "$d0$f1$d1$f2$d2$f3$d3" "[2]($f1)($f2)" "($f1)($f2)" ;;
+ ' ') ;;
+ *) x=$f2$d2$f3$d3
+ x=${x#' '}
+ x=${x%' '}
+ split "$d0$f1$d1$f2$d2$f3$d3" "[3]($f1)($f2)($f3)" "($f1)($x)"
+ ;;
+ esac
+ done
+ done
+ done
+ done
+ continue
+ ;;
+ esac
+done
+unset IFS
+
+if [[ $( (print ${12345:?}) 2>&1) != *12345* ]]
+then err_exit 'Incorrect error message with ${12345?}'
+fi
+unset foobar
+if [[ $( (print ${foobar:?}) 2>&1) != *foobar* ]]
+then err_exit 'Incorrect error message with ${foobar?}'
+fi
+unset bar
+if [[ $( (print ${bar:?bam}) 2>&1) != *bar*bam* ]]
+then err_exit 'Incorrect error message with ${foobar?}'
+fi
+{ $SHELL -c '
+function foo
+{
+ typeset SECONDS=0
+ sleep 1.5
+ print $SECONDS
+
+}
+x=$(foo)
+(( x >1 && x < 2 ))
+'
+} 2> /dev/null || err_exit 'SECONDS not working in function'
+trap 'rm -f /tmp/script$$ /tmp/out$$' EXIT
+cat > /tmp/script$$ <<-\!
+ posixfun()
+ {
+ unset x
+ nameref x=$1
+ print -r -- "$x"
+ }
+ function fun
+ {
+ nameref x=$1
+ print -r -- "$x"
+ }
+ if [[ $1 ]]
+ then file=${.sh.file}
+ else print -r -- "${.sh.file}"
+ fi
+!
+chmod +x /tmp/script$$
+. /tmp/script$$ 1
+[[ $file == /tmp/script$$ ]] || err_exit ".sh.file not working for dot scripts"
+[[ $($SHELL /tmp/script$$) == /tmp/script$$ ]] || err_exit ".sh.file not working for scripts"
+[[ $(posixfun .sh.file) == /tmp/script$$ ]] || err_exit ".sh.file not working for posix functions"
+[[ $(fun .sh.file) == /tmp/script$$ ]] || err_exit ".sh.file not working for functions"
+[[ $(posixfun .sh.fun) == posixfun ]] || err_exit ".sh.fun not working for posix functions"
+[[ $(fun .sh.fun) == fun ]] || err_exit ".sh.fun not working for functions"
+[[ $(posixfun .sh.subshell) == 1 ]] || err_exit ".sh.subshell not working for posix functions"
+[[ $(fun .sh.subshell) == 1 ]] || err_exit ".sh.subshell not working for functions"
+(
+ [[ $(posixfun .sh.subshell) == 2 ]] || err_exit ".sh.subshell not working for posix functions in subshells"
+ [[ $(fun .sh.subshell) == 2 ]] || err_exit ".sh.subshell not working for functions in subshells"
+ (( .sh.subshell == 1 )) || err_exit ".sh.subshell not working in a subshell"
+)
+TIMEFORMAT='this is a test'
+[[ $({ { time :;} 2>&1;}) == "$TIMEFORMAT" ]] || err_exit 'TIMEFORMAT not working'
+: ${.sh.version}
+[[ $(alias integer) == *.sh.* ]] && err_exit '.sh. prefixed to alias name'
+: ${.sh.version}
+[[ $(whence rm) == *.sh.* ]] && err_exit '.sh. prefixed to tracked alias name'
+: ${.sh.version}
+[[ $(cd /bin;env | grep PWD) == *.sh.* ]] && err_exit '.sh. prefixed to PWD'
+# unset discipline bug fix
+dave=dave
+function dave.unset
+{
+ unset dave
+}
+unset dave
+[[ $(typeset +f) == *dave.* ]] && err_exit 'unset discipline not removed'
+print 'print ${VAR}' > /tmp/script$$
+VAR=foo /tmp/script$$ > /tmp/out$$
+[[ $(</tmp/out$$) == foo ]] || err_exit 'environment variables not passed to scripts'
+(
+ unset dave
+ function dave.append
+ {
+ .sh.value+=$dave
+ dave=
+ }
+ dave=foo; dave+=bar
+ [[ $dave == barfoo ]] || exit 2
+) 2> /dev/null
+case $? in
+0) ;;
+1) err_exit 'append discipline not implemented';;
+*) err_exit 'append discipline not working';;
+esac
+.sh.foobar=hello
+{
+ function .sh.foobar.get
+ {
+ .sh.value=world
+ }
+} 2> /dev/null || err_exit "Can't add get discipline to .sh.foobar"
+[[ ${.sh.foobar} == world ]] || err_exit 'get discipline for .sh.foobar not working'
+x='a|b'
+IFS='|'
+set -- $x
+[[ $2 == b ]] || err_exit '$2 should be b after set'
+exec 3>&2 2> /dev/null
+set -x
+( IFS= ) 2> /dev/null
+set +x
+exec 2>&3-
+set -- $x
+[[ $2 == b ]] || err_exit '$2 should be b after subshell'
+: & pid=$!
+( : & )
+[[ $pid == $! ]] || err_exit '$! value not preserved across subshells'
+unset foo
+typeset -A foo
+function foo.set
+{
+ case ${.sh.subscript} in
+ bar) if ((.sh.value > 1 ))
+ then .sh.value=5
+ foo[barrier_hit]=yes
+ fi
+ ;;
+ barrier_hit)
+ if [[ ${.sh.value} = yes ]]
+ then foo[barrier_not_hit]=no
+ else foo[barrier_not_hit]=yes
+ fi
+ ;;
+ esac
+}
+foo[barrier_hit]=no
+foo[bar]=1
+(( foo[bar] == 1 )) || err_exit 'foo[bar] should be 1'
+[[ ${foo[barrier_hit]} == no ]] || err_exit 'foo[barrier_hit] should be no'
+[[ ${foo[barrier_not_hit]} == yes ]] || err_exit 'foo[barrier_not_hit] should be yes'
+foo[barrier_hit]=no
+foo[bar]=2
+(( foo[bar] == 5 )) || err_exit 'foo[bar] should be 5'
+[[ ${foo[barrier_hit]} == yes ]] || err_exit 'foo[barrier_hit] should be yes'
+[[ ${foo[barrier_not_hit]} == no ]] || err_exit 'foo[barrier_not_hit] should be no'
+unset x
+typeset -i x
+function x.set
+{
+ typeset sub=${.sh.subscript}
+ (( sub > 0 )) && (( x[sub-1]= x[sub-1] + .sh.value ))
+}
+x[0]=0 x[1]=1 x[2]=2 x[3]=3
+[[ ${x[@]} == '12 8 5 3' ]] || err_exit 'set discipline for indexed array not working correctly'
+((SECONDS=3*4))
+(( SECONDS < 12 || SECONDS > 12.1 )) && err_exit "SECONDS is $SECONDS and should be close to 12"
+exit $((Errors))
diff --git a/usr/src/lib/libshell/i386/Makefile b/usr/src/lib/libshell/i386/Makefile
new file mode 100644
index 0000000000..f91f0270e9
--- /dev/null
+++ b/usr/src/lib/libshell/i386/Makefile
@@ -0,0 +1,30 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/usr/src/lib/libshell/i386/include/ast/history.h b/usr/src/lib/libshell/i386/include/ast/history.h
new file mode 100644
index 0000000000..55ead66f9e
--- /dev/null
+++ b/usr/src/lib/libshell/i386/include/ast/history.h
@@ -0,0 +1,84 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+#ifndef HIST_VERSION
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+/*
+ * Interface for history mechanism
+ * written by David Korn
+ *
+ */
+
+#include <ast.h>
+
+#define HIST_CHAR '!'
+#define HIST_VERSION 1 /* history file format version no. */
+
+typedef struct
+{
+ Sfdisc_t histdisc; /* discipline for history */
+ Sfio_t *histfp; /* history file stream pointer */
+ char *histname; /* name of history file */
+ int32_t histind; /* current command number index */
+ int histsize; /* number of accessible history lines */
+#ifdef _HIST_PRIVATE
+ _HIST_PRIVATE
+#endif /* _HIST_PRIVATE */
+} History_t;
+
+typedef struct
+{
+ int hist_command;
+ int hist_line;
+ int hist_char;
+} Histloc_t;
+
+/* the following are readonly */
+extern __MANGLE__ const char hist_fname[];
+
+extern __MANGLE__ int _Hist;
+#define hist_min(hp) ((_Hist=((int)((hp)->histind-(hp)->histsize)))>=0?_Hist:0)
+#define hist_max(hp) ((int)((hp)->histind))
+/* these are the history interface routines */
+extern __MANGLE__ int sh_histinit __PROTO__((void));
+extern __MANGLE__ void hist_cancel __PROTO__((History_t*));
+extern __MANGLE__ void hist_close __PROTO__((History_t*));
+extern __MANGLE__ int hist_copy __PROTO__((char*, int, int, int));
+extern __MANGLE__ void hist_eof __PROTO__((History_t*));
+extern __MANGLE__ Histloc_t hist_find __PROTO__((History_t*,char*,int, int, int));
+extern __MANGLE__ void hist_flush __PROTO__((History_t*));
+extern __MANGLE__ void hist_list __PROTO__((History_t*,Sfio_t*, off_t, int, char*));
+extern __MANGLE__ int hist_match __PROTO__((History_t*,off_t, char*, int*));
+extern __MANGLE__ off_t hist_tell __PROTO__((History_t*,int));
+extern __MANGLE__ off_t hist_seek __PROTO__((History_t*,int));
+extern __MANGLE__ char *hist_word __PROTO__((char*, int, int));
+#if SHOPT_ESH
+ extern __MANGLE__ Histloc_t hist_locate __PROTO__((History_t*,int, int, int));
+#endif /* SHOPT_ESH */
+
+#endif /* HIST_VERSION */
diff --git a/usr/src/lib/libshell/i386/include/ast/nval.h b/usr/src/lib/libshell/i386/include/ast/nval.h
new file mode 100644
index 0000000000..06b18217b7
--- /dev/null
+++ b/usr/src/lib/libshell/i386/include/ast/nval.h
@@ -0,0 +1,317 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+#ifndef NV_DEFAULT
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * Interface definitions of structures for name-value pairs
+ * These structures are used for named variables, functions and aliases
+ *
+ */
+
+
+#include <ast.h>
+#include <cdt.h>
+
+/* for compatibility with old hash library */
+#define Hashtab_t Dt_t
+#define HASH_BUCKET 1
+#define HASH_NOSCOPE 2
+#define HASH_SCOPE 4
+#define hashscope(x) dtvnext(x)
+
+typedef struct Namval Namval_t;
+typedef struct Namfun Namfun_t;
+typedef struct Namdisc Namdisc_t;
+typedef struct Nambfun Nambfun_t;
+typedef struct Namarray Namarr_t;
+typedef struct Nambltin Nambltin_t;
+typedef struct Namtype Namtype_t;
+
+/*
+ * This defines the template for nodes that have their own assignment
+ * and or lookup functions
+ */
+struct Namdisc
+{
+ size_t dsize;
+ void (*putval) __PROTO__((Namval_t*, const char*, int, Namfun_t*));
+ char *(*getval) __PROTO__((Namval_t*, Namfun_t*));
+ Sfdouble_t (*getnum) __PROTO__((Namval_t*, Namfun_t*));
+ char *(*setdisc) __PROTO__((Namval_t*, const char*, Namval_t*, Namfun_t*));
+ Namval_t *(*createf) __PROTO__((Namval_t*, const char*, int, Namfun_t*));
+ Namfun_t *(*clonef) __PROTO__((Namval_t*, Namval_t*, int, Namfun_t*));
+ char *(*namef) __PROTO__((Namval_t*, Namfun_t*));
+ Namval_t *(*nextf) __PROTO__((Namval_t*, Dt_t*, Namfun_t*));
+ Namval_t *(*typef) __PROTO__((Namval_t*, Namfun_t*));
+ int (*readf) __PROTO__((Namval_t*, Sfio_t*, int, Namfun_t*));
+};
+
+struct Namfun
+{
+ const Namdisc_t *disc;
+ char nofree;
+ char funs;
+ unsigned short dsize;
+ Namfun_t *next;
+ char *last;
+ Namval_t *type;
+};
+
+struct Nambfun
+{
+ Namfun_t fun;
+ int num;
+ const char **bnames;
+ Namval_t *bltins[1];
+};
+
+/* This is an array template header */
+struct Namarray
+{
+ Namfun_t hdr;
+ long nelem; /* number of elements */
+ __V_ *(*fun) __PROTO__((Namval_t*,const char*,int)); /* associative arrays */
+ Namval_t *parent; /* for multi-dimensional */
+};
+
+/* Passed as third argument to a builtin when NV_BLTINOPT is set on node */
+struct Nambltin
+{
+ __V_ *shp;
+ Namval_t *np;
+ __V_ *ptr;
+ __V_ *data;
+ int flags;
+};
+
+struct Namtype
+{
+ __V_ *shp;
+ Namval_t *np;
+ const char *optstring;
+ __V_ *optinfof;
+};
+
+/* attributes of name-value node attribute flags */
+
+#define NV_DEFAULT 0
+/* This defines the attributes for an attributed name-value pair node */
+struct Namval
+{
+ Dtlink_t nvlink; /* space for cdt links */
+ char *nvname; /* pointer to name of the node */
+ unsigned short nvflag; /* attributes */
+ unsigned short nvsize; /* size or base */
+#ifdef _NV_PRIVATE
+ _NV_PRIVATE
+#else
+ Namfun_t *nvfun;
+ char *nvalue;
+ char *nvprivate;
+#endif /* _NV_PRIVATE */
+};
+
+#define NV_CLASS ".sh.type"
+#define NV_MINSZ (sizeof(struct Namval)-sizeof(Dtlink_t)-sizeof(char*))
+#define nv_namptr(p,n) ((Namval_t*)((char*)(p)+(n)*NV_MINSZ-sizeof(Dtlink_t)))
+
+/* The following attributes are for internal use */
+#define NV_NOFREE 0x200 /* don't free the space when releasing value */
+#define NV_ARRAY 0x400 /* node is an array */
+#define NV_REF 0x4000 /* reference bit */
+#define NV_TABLE 0x800 /* node is a dictionary table */
+#define NV_IMPORT 0x1000 /* value imported from environment */
+#define NV_MINIMAL NV_IMPORT /* node does not contain all fields */
+
+#define NV_INTEGER 0x2 /* integer attribute */
+/* The following attributes are valid only when NV_INTEGER is off */
+#define NV_LTOU 0x4 /* convert to uppercase */
+#define NV_UTOL 0x8 /* convert to lowercase */
+#define NV_ZFILL 0x10 /* right justify and fill with leading zeros */
+#define NV_RJUST 0x20 /* right justify and blank fill */
+#define NV_LJUST 0x40 /* left justify and blank fill */
+#define NV_BINARY 0x100 /* fixed size data buffer */
+#define NV_RAW NV_LJUST /* used only with NV_BINARY */
+#define NV_HOST (NV_RJUST|NV_LJUST) /* map to host filename */
+
+/* The following attributes do not effect the value */
+#define NV_RDONLY 0x1 /* readonly bit */
+#define NV_EXPORT 0x2000 /* export bit */
+#define NV_TAGGED 0x8000 /* user define tag bit */
+
+/* The following are used with NV_INTEGER */
+#define NV_SHORT (NV_RJUST) /* when integers are not long */
+#define NV_LONG (NV_UTOL) /* for long long and long double */
+#define NV_UNSIGN (NV_LTOU) /* for unsigned quantities */
+#define NV_DOUBLE (NV_ZFILL) /* for floating point */
+#define NV_EXPNOTE (NV_LJUST) /* for scientific notation */
+
+/* options for nv_open */
+
+#define NV_APPEND 0x10000 /* append value */
+#define NV_MOVE 0x20000 /* for use with nv_clone */
+#define NV_ADD 8
+ /* add node if not found */
+#define NV_ASSIGN NV_NOFREE /* assignment is possible */
+#define NV_NOASSIGN 0 /* backward compatibility */
+#define NV_NOARRAY 0x200000 /* array name not possible */
+#define NV_IARRAY 0x400000 /* for indexed array */
+#define NV_NOREF NV_REF /* don't follow reference */
+#define NV_IDENT 0x80 /* name must be identifier */
+#define NV_VARNAME 0x20000 /* name must be ?(.)id*(.id) */
+#define NV_NOADD 0x40000 /* do not add node */
+#define NV_NOSCOPE 0x80000 /* look only in current scope */
+#define NV_NOFAIL 0x100000 /* return 0 on failure, no msg */
+#define NV_NODISC NV_IDENT /* ignore disciplines */
+
+#define NV_FUNCT NV_IDENT /* option for nv_create */
+#define NV_BLTINOPT NV_ZFILL /* save state for optimization*/
+
+#define NV_PUBLIC (~(NV_NOSCOPE|NV_ASSIGN|NV_IDENT|NV_VARNAME|NV_NOADD))
+
+/* numeric types */
+#define NV_INT16 (NV_SHORT|NV_INTEGER)
+#define NV_UINT16 (NV_UNSIGN|NV_SHORT|NV_INTEGER)
+#define NV_INT32 (NV_INTEGER)
+#define NV_UNT32 (NV_UNSIGN|NV_INTEGER)
+#define NV_INT64 (NV_LONG|NV_INTEGER)
+#define NV_UINT64 (NV_UNSIGN|NV_LONG|NV_INTEGER)
+#define NV_FLOAT (NV_SHORT|NV_DOUBLE|NV_INTEGER)
+#define NV_LDOUBLE (NV_LONG|NV_DOUBLE|NV_INTEGER)
+
+/* name-value pair macros */
+#define nv_isattr(np,f) ((np)->nvflag & (f))
+#define nv_onattr(n,f) ((n)->nvflag |= (f))
+#define nv_offattr(n,f) ((n)->nvflag &= ~(f))
+#define nv_isarray(np) (nv_isattr((np),NV_ARRAY))
+
+/* The following are operations for associative arrays */
+#define NV_AINIT 1 /* initialize */
+#define NV_AFREE 2 /* free array */
+#define NV_ANEXT 3 /* advance to next subscript */
+#define NV_ANAME 4 /* return subscript name */
+#define NV_ADELETE 5 /* delete current subscript */
+#define NV_AADD 6 /* add subscript if not found */
+#define NV_ACURRENT 7 /* return current subscript Namval_t* */
+
+/* The following are for nv_disc */
+#define NV_FIRST 1
+#define NV_LAST 2
+#define NV_POP 3
+#define NV_CLONE 4
+
+/* The following are operations for nv_putsub() */
+#define ARRAY_BITS 24
+#define ARRAY_ADD (1L<<ARRAY_BITS) /* add subscript if not found */
+#define ARRAY_SCAN (2L<<ARRAY_BITS) /* For ${array[@]} */
+#define ARRAY_UNDEF (4L<<ARRAY_BITS) /* For ${array} */
+
+
+/* These are disciplines provided by the library for use with nv_discfun */
+#define NV_DCADD 0 /* used to add named disciplines */
+#define NV_DCRESTRICT 1 /* variable that are restricted in rsh */
+
+#if defined(__EXPORT__) && defined(_DLL)
+# ifdef _BLD_shell
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+# else
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+# endif /* _BLD_shell */
+#endif /* _DLL */
+/* prototype for array interface*/
+extern __MANGLE__ Namarr_t *nv_setarray __PROTO__((Namval_t*,__V_*(*)(Namval_t*,const char*,int)));
+extern __MANGLE__ __V_ *nv_associative __PROTO__((Namval_t*,const char*,int));
+extern __MANGLE__ int nv_aindex __PROTO__((Namval_t*));
+extern __MANGLE__ int nv_nextsub __PROTO__((Namval_t*));
+extern __MANGLE__ char *nv_getsub __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_putsub __PROTO__((Namval_t*, char*, long));
+extern __MANGLE__ Namval_t *nv_opensub __PROTO__((Namval_t*));
+
+/* name-value pair function prototypes */
+extern __MANGLE__ int nv_adddisc __PROTO__((Namval_t*, const char**, Namval_t**));
+extern __MANGLE__ int nv_clone __PROTO__((Namval_t*, Namval_t*, int));
+extern __MANGLE__ void nv_close __PROTO__((Namval_t*));
+extern __MANGLE__ __V_ *nv_context __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_create __PROTO__((const char*, Dt_t*, int,Namfun_t*));
+extern __MANGLE__ Dt_t *nv_dict __PROTO__((Namval_t*));
+extern __MANGLE__ Sfdouble_t nv_getn __PROTO__((Namval_t*, Namfun_t*));
+extern __MANGLE__ Sfdouble_t nv_getnum __PROTO__((Namval_t*));
+extern __MANGLE__ char *nv_getv __PROTO__((Namval_t*, Namfun_t*));
+extern __MANGLE__ char *nv_getval __PROTO__((Namval_t*));
+extern __MANGLE__ Namfun_t *nv_hasdisc __PROTO__((Namval_t*, const Namdisc_t*));
+extern __MANGLE__ int nv_isnull __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_lastdict __PROTO__((void));
+extern __MANGLE__ void nv_newattr __PROTO__((Namval_t*,unsigned,int));
+extern __MANGLE__ Namval_t *nv_open __PROTO__((const char*,Dt_t*,int));
+extern __MANGLE__ void nv_putval __PROTO__((Namval_t*,const char*,int));
+extern __MANGLE__ void nv_putv __PROTO__((Namval_t*,const char*,int,Namfun_t*));
+extern __MANGLE__ int nv_scan __PROTO__((Dt_t*,void(*)(Namval_t*,__V_*),__V_*,int,int));
+extern __MANGLE__ Namval_t *nv_scoped __PROTO__((Namval_t*));
+extern __MANGLE__ char *nv_setdisc __PROTO__((Namval_t*,const char*,Namval_t*,Namfun_t*));
+extern __MANGLE__ void nv_setref __PROTO__((Namval_t*, Dt_t*,int));
+extern __MANGLE__ int nv_settype __PROTO__((Namval_t*, Namval_t*, int));
+extern __MANGLE__ void nv_setvec __PROTO__((Namval_t*,int,int,char*[]));
+extern __MANGLE__ void nv_setvtree __PROTO__((Namval_t*));
+extern __MANGLE__ int nv_setsize __PROTO__((Namval_t*,int));
+extern __MANGLE__ Namfun_t *nv_disc __PROTO__((Namval_t*,Namfun_t*,int));
+extern __MANGLE__ void nv_unset __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_search __PROTO__((const char *, Dt_t*, int));
+extern __MANGLE__ void nv_unscope __PROTO__((void));
+extern __MANGLE__ char *nv_name __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_type __PROTO__((Namval_t*));
+extern __MANGLE__ const Namdisc_t *nv_discfun __PROTO__((int));
+
+#ifdef _DLL
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif /* _DLL */
+
+#define nv_size(np) nv_setsize((np),-1)
+#define nv_stack(np,nf) nv_disc(np,nf,0)
+
+#if 0
+/*
+ * The names of many functions were changed in early '95
+ * Here is a mapping to the old names
+ */
+# define nv_istype(np) nv_isattr(np)
+# define nv_newtype(np) nv_newattr(np)
+# define nv_namset(np,a,b) nv_open(np,a,b)
+# define nv_free(np) nv_unset(np)
+# define nv_settype(np,a,b,c) nv_setdisc(np,a,b,c)
+# define nv_search(np,a,b) nv_open(np,a,((b)?0:NV_NOADD))
+# define settype setdisc
+#endif
+
+#endif /* NV_DEFAULT */
diff --git a/usr/src/lib/libshell/i386/include/ast/shell.h b/usr/src/lib/libshell/i386/include/ast/shell.h
new file mode 100644
index 0000000000..37cafa932b
--- /dev/null
+++ b/usr/src/lib/libshell/i386/include/ast/shell.h
@@ -0,0 +1,256 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+#ifndef SH_INTERACTIVE
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * Interface definitions for shell command language
+ *
+ */
+
+#include <cmd.h>
+#include <cdt.h>
+#ifdef _SH_PRIVATE
+# include "name.h"
+#else
+# include <nval.h>
+#endif /* _SH_PRIVATE */
+
+#define SH_VERSION 20060510
+
+#undef NOT_USED
+#define NOT_USED(x) (&x,1)
+
+/* options */
+typedef struct
+{
+ unsigned long v[4];
+}
+Shopt_t;
+
+typedef void (*Shinit_f) __PROTO__((int));
+typedef int (*Shbltin_f) __PROTO__((int, char*[], __V_*));
+typedef int (*Shwait_f) __PROTO__((int, long, int));
+
+union Shnode_u;
+typedef union Shnode_u Shnode_t;
+
+#define SH_CFLAG 0
+#define SH_HISTORY 1 /* used also as a state */
+#define SH_ERREXIT 2 /* used also as a state */
+#define SH_VERBOSE 3 /* used also as a state */
+#define SH_MONITOR 4 /* used also as a state */
+#define SH_INTERACTIVE 5 /* used also as a state */
+#define SH_RESTRICTED 6
+#define SH_XTRACE 7
+#define SH_KEYWORD 8
+#define SH_NOUNSET 9
+#define SH_NOGLOB 10
+#define SH_ALLEXPORT 11
+#define SH_PFSH 12
+#define SH_IGNOREEOF 13
+#define SH_NOCLOBBER 14
+#define SH_MARKDIRS 15
+#define SH_BGNICE 16
+#define SH_VI 17
+#define SH_VIRAW 18
+#define SH_TFLAG 19
+#define SH_TRACKALL 20
+#define SH_SFLAG 21
+#define SH_NOEXEC 22
+#define SH_GMACS 24
+#define SH_EMACS 25
+#define SH_PRIVILEGED 26
+#define SH_SUBSHARE 27 /* subshell shares state with parent */
+#define SH_NOLOG 28
+#define SH_NOTIFY 29
+#define SH_DICTIONARY 30
+#define SH_PIPEFAIL 32
+#define SH_GLOBSTARS 33
+#define SH_XARGS 34
+#define SH_RC 35
+#define SH_SHOWME 36
+
+/*
+ * passed as flags to builtins in Nambltin_t struct when BLT_OPTIM is on
+ */
+#define SH_BEGIN_OPTIM 0x1
+#define SH_END_OPTIM 0x2
+
+/* The following type is used for error messages */
+
+/* error messages */
+extern __MANGLE__ const char e_defpath[];
+extern __MANGLE__ const char e_found[];
+extern __MANGLE__ const char e_nospace[];
+extern __MANGLE__ const char e_format[];
+extern __MANGLE__ const char e_number[];
+extern __MANGLE__ const char e_restricted[];
+extern __MANGLE__ const char e_recursive[];
+extern __MANGLE__ char e_version[];
+
+typedef struct sh_scope
+{
+ struct sh_scope *par_scope;
+ int argc;
+ char **argv;
+ char *cmdname;
+ char *filename;
+ int lineno;
+ Dt_t *var_tree;
+ struct sh_scope *self;
+} Shscope_t;
+
+/*
+ * Saves the state of the shell
+ */
+
+typedef struct sh_static
+{
+ Shopt_t options; /* set -o options */
+ Dt_t *var_tree; /* for shell variables */
+ Dt_t *fun_tree; /* for shell functions */
+ Dt_t *alias_tree; /* for alias names */
+ Dt_t *bltin_tree; /* for builtin commands */
+ Shscope_t *topscope; /* pointer to top-level scope */
+ int inlineno; /* line number of current input file */
+ int exitval; /* most recent exit value */
+ unsigned char trapnote; /* set when trap/signal is pending */
+ char subshell; /* set for virtual subshell */
+#ifdef _SH_PRIVATE
+ _SH_PRIVATE
+#endif /* _SH_PRIVATE */
+} Shell_t;
+
+/* flags for sh_parse */
+#define SH_NL 1 /* Treat new-lines as ; */
+#define SH_EOF 2 /* EOF causes syntax error */
+
+/* symbolic values for sh_iogetiop */
+#define SH_IOCOPROCESS (-2)
+#define SH_IOHISTFILE (-3)
+
+/* symbolic value for sh_fdnotify */
+#define SH_FDCLOSE (-1)
+
+#if defined(__EXPORT__) && defined(_DLL)
+# ifdef _BLD_shell
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+# endif /* _BLD_shell */
+#endif /* _DLL */
+
+extern __MANGLE__ Dt_t *sh_bltin_tree __PROTO__((void));
+extern __MANGLE__ void sh_subfork __PROTO__((void));
+extern __MANGLE__ Shell_t *sh_init __PROTO__((int,char*[],Shinit_f));
+extern __MANGLE__ int sh_reinit __PROTO__((char*[]));
+extern __MANGLE__ int sh_eval __PROTO__((Sfio_t*,int));
+extern __MANGLE__ void sh_delay __PROTO__((double));
+extern __MANGLE__ __V_ *sh_parse __PROTO__((Shell_t*, Sfio_t*,int));
+extern __MANGLE__ int sh_trap __PROTO__((const char*,int));
+extern __MANGLE__ int sh_fun __PROTO__((Namval_t*,Namval_t*, char*[]));
+extern __MANGLE__ int sh_funscope __PROTO__((int,char*[],int(*)(__V_*),__V_*,int));
+extern __MANGLE__ Sfio_t *sh_iogetiop __PROTO__((int,int));
+extern __MANGLE__ int sh_main __PROTO__((int, char*[], void(*)(int)));
+extern __MANGLE__ void sh_menu __PROTO__((Sfio_t*, int, char*[]));
+extern __MANGLE__ Namval_t *sh_addbuiltin __PROTO__((const char*, int(*)(int, char*[],__V_*), __V_*));
+extern __MANGLE__ char *sh_fmtq __PROTO__((const char*));
+extern __MANGLE__ char *sh_fmtqf __PROTO__((const char*, int, int));
+extern __MANGLE__ Sfdouble_t sh_strnum __PROTO__((const char*, char**, int));
+extern __MANGLE__ int sh_access __PROTO__((const char*,int));
+extern __MANGLE__ int sh_close __PROTO__((int));
+extern __MANGLE__ int sh_dup __PROTO__((int));
+extern __MANGLE__ void sh_exit __PROTO__((int));
+extern __MANGLE__ int sh_fcntl __PROTO__((int, int, ...));
+extern __MANGLE__ Sfio_t *sh_fd2sfio __PROTO__((int));
+extern __MANGLE__ int (*sh_fdnotify __PROTO__((int(*)(int,int)))) __PROTO__((int,int));
+extern __MANGLE__ Shell_t *sh_getinterp __PROTO__((void));
+extern __MANGLE__ int sh_open __PROTO__((const char*, int, ...));
+extern __MANGLE__ int sh_openmax __PROTO__((void));
+extern __MANGLE__ Sfio_t *sh_pathopen __PROTO__((const char*));
+extern __MANGLE__ ssize_t sh_read __PROTO__((int, __V_*, size_t));
+extern __MANGLE__ ssize_t sh_write __PROTO__((int, const __V_*, size_t));
+extern __MANGLE__ off_t sh_seek __PROTO__((int, off_t, int));
+extern __MANGLE__ int sh_pipe __PROTO__((int[]));
+extern __MANGLE__ mode_t sh_umask __PROTO__((mode_t));
+extern __MANGLE__ __V_ *sh_waitnotify __PROTO__((Shwait_f));
+extern __MANGLE__ Shscope_t *sh_getscope __PROTO__((int,int));
+extern __MANGLE__ Shscope_t *sh_setscope __PROTO__((Shscope_t*));
+extern __MANGLE__ void sh_sigcheck __PROTO__((void));
+extern __MANGLE__ unsigned long sh_isoption __PROTO__((int));
+extern __MANGLE__ unsigned long sh_onoption __PROTO__((int));
+extern __MANGLE__ unsigned long sh_offoption __PROTO__((int));
+extern __MANGLE__ int sh_waitsafe __PROTO__((void));
+extern __MANGLE__ int sh_exec __PROTO__((const Shnode_t*,int));
+
+#if SHOPT_DYNAMIC
+ extern __MANGLE__ __V_ **sh_getliblist __PROTO__((void));
+#endif /* SHOPT_DYNAMIC */
+
+/*
+ * direct access to sh is obsolete, use sh_getinterp() instead
+ */
+#if !defined(_SH_PRIVATE) && defined(__IMPORT__) && !defined(_BLD_shell)
+ extern __MANGLE__ __IMPORT__ Shell_t sh;
+#else
+ extern __MANGLE__ Shell_t sh;
+#endif
+
+#ifdef _DLL
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif /* _DLL */
+
+#ifndef _SH_PRIVATE
+# define access(a,b) sh_access(a,b)
+# define close(a) sh_close(a)
+# define exit(a) sh_exit(a)
+# define fcntl(a,b,c) sh_fcntl(a,b,c)
+# define pipe(a) sh_pipe(a)
+# define read(a,b,c) sh_read(a,b,c)
+# define write(a,b,c) sh_write(a,b,c)
+# define umask(a) sh_umask(a)
+# define dup sh_dup
+# if _lib_lseek64
+# define open64 sh_open
+# define lseek64 sh_seek
+# else
+# define open sh_open
+# define lseek sh_seek
+# endif
+#endif /* !_SH_PRIVATE */
+
+#define SH_SIGSET 4
+#define SH_EXITSIG 0400 /* signal exit bit */
+#define SH_EXITMASK (SH_EXITSIG-1) /* normal exit status bits */
+#define SH_RUNPROG -1022 /* needs to be negative and < 256 */
+
+#endif /* SH_INTERACTIVE */
diff --git a/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/acct b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/acct
new file mode 100644
index 0000000000..9d3441e51c
--- /dev/null
+++ b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/acct
@@ -0,0 +1,12 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_acct_ksh93
+#define _def_acct_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _lib_acct 1 /* acct() in default lib(s) */
+#define _sys_acct 1 /* #include <sys/acct.h> ok */
+#endif
diff --git a/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/cmds b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/cmds
new file mode 100644
index 0000000000..3ae7ddd4c9
--- /dev/null
+++ b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/cmds
@@ -0,0 +1,36 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/cmd/ksh93/features/cmds by iffe version 2007-04-04 : : */
+#ifndef _def_cmds_ksh93
+#define _def_cmds_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _cmd_newgrp 1 /* newgrp in ?(/usr)/(bin|etc|ucb) */
+#define _bin_newgrp 1 /* /bin/newgrp found */
+#define _usr_bin_newgrp 1 /* /usr/bin/newgrp found */
+#define _cmd_test 1 /* test in ?(/usr)/(bin|etc|ucb) */
+#define _bin_test 1 /* /bin/test found */
+#define _usr_bin_test 1 /* /usr/bin/test found */
+#define _usr_ucb_test 1 /* /usr/ucb/test found */
+#define _cmd_id 1 /* id in ?(/usr)/(bin|etc|ucb) */
+#define _bin_id 1 /* /bin/id found */
+#define _usr_bin_id 1 /* /usr/bin/id found */
+#define _cmd_wc 1 /* wc in ?(/usr)/(bin|etc|ucb) */
+#define _bin_wc 1 /* /bin/wc found */
+#define _usr_bin_wc 1 /* /usr/bin/wc found */
+#define _usr_ucb_wc 1 /* /usr/ucb/wc found */
+#define _cmd_cut 1 /* cut in ?(/usr)/(bin|etc|ucb) */
+#define _bin_cut 1 /* /bin/cut found */
+#define _usr_bin_cut 1 /* /usr/bin/cut found */
+#define _cmd_logname 1 /* logname in ?(/usr)/(bin|etc|ucb) */
+#define _bin_logname 1 /* /bin/logname found */
+#define _usr_bin_logname 1 /* /usr/bin/logname found */
+#define _cmd_pfexec 1 /* pfexec in ?(/usr)/(bin|etc|ucb) */
+#define _bin_pfexec 1 /* /bin/pfexec found */
+#define _usr_bin_pfexec 1 /* /usr/bin/pfexec found */
+#define _cmd_tput 1 /* tput in ?(/usr)/(bin|etc|ucb) */
+#define _bin_tput 1 /* /bin/tput found */
+#define _usr_bin_tput 1 /* /usr/bin/tput found */
+#endif
diff --git a/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/dynamic b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/dynamic
new file mode 100644
index 0000000000..8c50aac603
--- /dev/null
+++ b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/dynamic
@@ -0,0 +1,23 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/cmd/ksh93/features/dynamic by iffe version 2007-04-04 : : */
+#ifndef _def_dynamic_ksh93
+#define _def_dynamic_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_dlfcn 1 /* #include <dlfcn.h> ok */
+#define _sys_dl 1 /* #include <sys/dl.h> ok */
+#define _hdr_dlldefs 1 /* #include <dlldefs.h> ok */
+#define _lib_dlopen 1 /* dlopen() in default lib(s) */
+#define _lib_dllfind 1 /* dllfind() in default lib(s) */
+#if !defined(SHOPT_FS_3D) && ( _lib_dllfind || _lib_dlopen || _lib_shl_load || _lib_loadbind )
+# define SHOPT_FS_3D 1
+#endif /* !SHOPT_FS_3D */
+#if SHOPT_FS_3D
+# undef mount
+# include <fs3d.h>
+#endif /* SHOPT_FS_3D */
+
+#endif
diff --git a/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/execargs b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/execargs
new file mode 100644
index 0000000000..b368713166
--- /dev/null
+++ b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/execargs
@@ -0,0 +1,10 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_execargs_ksh93
+#define _def_execargs_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#endif
diff --git a/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/externs b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/externs
new file mode 100644
index 0000000000..311028856f
--- /dev/null
+++ b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/externs
@@ -0,0 +1,81 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/cmd/ksh93/features/externs by iffe version 2007-04-04 : : */
+
+#ifndef _def_externs_ksh93
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_externs_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_exec_attr 1 /* #include <exec_attr.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _mem_name_exception 1 /* name is a member of struct exception */
+#define _lib_setreuid 1 /* setreuid() in default lib(s) */
+#define _lib_setregid 1 /* setregid() in default lib(s) */
+#define _lib_nice 1 /* nice() in default lib(s) */
+#define _lib_sigflag 1 /* sigflag() in default lib(s) */
+#define _lib_fork 1 /* fork() in default lib(s) */
+#define _lib_spawnveg 1 /* spawnveg() in default lib(s) */
+#define _lib_fchdir 1 /* fchdir() in default lib(s) */
+#endif
diff --git a/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/locale b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/locale
new file mode 100644
index 0000000000..cda3b9fcbf
--- /dev/null
+++ b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/locale
@@ -0,0 +1,38 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/cmd/ksh93/features/locale by iffe version 2007-04-04 : : */
+#ifndef _def_locale_ksh93
+#define _def_locale_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_locale 1 /* #include <locale.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _lib_localeconv 1 /* localeconv() in default lib(s) */
+#define _lib_wctype 1 /* wctype() in default lib(s) */
+#define _lib_iswctype 1 /* iswctype() in default lib(s) */
+#define _lib_iswblank 1 /* iswblank() in default lib(s) */
+#if _PACKAGE_ast
+# undef _hdr_locale
+# define _hdr_locale 1
+#else
+# ifdef _hdr_locale
+# include <locale.h>
+# ifndef LC_MESSAGES
+# define LC_MESSAGES LC_ALL
+# endif /* LC_MESSAGES */
+# endif /* _hdr_locale */
+#endif /* _PACKAGE_ast */
+#ifdef _hdr_locale
+# ifdef _lib_localeconv
+ static struct lconv *lp;
+# define GETDECIMAL(x) (((lp=localeconv()) && lp->decimal_point && *lp->decimal_point) ? *lp->decimal_point : '.' )
+# else
+# define GETDECIMAL(x) ('.')
+# endif /* _lib_localeconv */
+#else
+# define GETDECIMAL(x) ('.')
+#endif /* _hdr_locale */
+
+#endif
diff --git a/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/math b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/math
new file mode 100644
index 0000000000..bba6bce5ff
--- /dev/null
+++ b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/math
@@ -0,0 +1,162 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/cmd/ksh93/features/math.sh by iffe version 2007-04-04 : : */
+#ifndef _def_math_ksh93
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_math_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+
+
+/* : : generated by iffe from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/cmd/ksh93/data/math.tab : : */
+
+typedef Sfdouble_t (*Math_f) __PROTO__((Sfdouble_t,...));
+
+#include <ast_standards.h>
+#include <math.h>
+#include <ieeefp.h>
+
+static Sfdouble_t local_finite __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return finite(a1);}
+static int local_fpclassify __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return fpclassify(a1);}
+static int local_isfinite __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return isfinite(a1);}
+static int local_isgreater __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return isgreater(a1,a2);}
+static int local_isgreaterequal __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return isgreaterequal(a1,a2);}
+static int local_isinf __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return isinf(a1);}
+static int local_isless __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return isless(a1,a2);}
+static int local_islessequal __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return islessequal(a1,a2);}
+static int local_islessgreater __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return islessgreater(a1,a2);}
+static int local_isnormal __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return isnormal(a1);}
+static int local_isunordered __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return isunordered(a1,a2);}
+static int local_signbit __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return signbit(a1);}
+
+/*
+ * first byte is two-digit octal number. Last digit is number of args
+ * first digit is 0 if return value is double, 1 for integer
+ */
+const struct mathtab shtab_math[] =
+{
+ "\001acos", (Math_f)acosl,
+ "\001acosh", (Math_f)acoshl,
+ "\001asin", (Math_f)asinl,
+ "\001asinh", (Math_f)asinhl,
+ "\001atan", (Math_f)atanl,
+ "\002atan2", (Math_f)atan2l,
+ "\001atanh", (Math_f)atanhl,
+ "\001cbrt", (Math_f)cbrtl,
+ "\002copysign", (Math_f)copysignl,
+ "\001cos", (Math_f)cosl,
+ "\001cosh", (Math_f)coshl,
+ "\001erf", (Math_f)erfl,
+ "\001erfc", (Math_f)erfcl,
+ "\001exp", (Math_f)expl,
+ "\001exp2", (Math_f)exp2l,
+ "\001expm1", (Math_f)expm1l,
+ "\001fabs", (Math_f)fabsl,
+ "\001abs", (Math_f)fabsl,
+ "\002fdim", (Math_f)fdiml,
+ "\001finite", (Math_f)local_finite,
+ "\001floor", (Math_f)floorl,
+ "\001int", (Math_f)floorl,
+ "\003fma", (Math_f)fmal,
+ "\002fmax", (Math_f)fmaxl,
+ "\002fmin", (Math_f)fminl,
+ "\002fmod", (Math_f)fmodl,
+ "\011fpclassify", (Math_f)local_fpclassify,
+ "\002hypot", (Math_f)hypotl,
+ "\011ilogb", (Math_f)ilogbl,
+ "\011isfinite", (Math_f)local_isfinite,
+ "\012isgreater", (Math_f)local_isgreater,
+ "\012isgreaterequal", (Math_f)local_isgreaterequal,
+ "\011isinf", (Math_f)local_isinf,
+ "\012isless", (Math_f)local_isless,
+ "\012islessequal", (Math_f)local_islessequal,
+ "\012islessgreater", (Math_f)local_islessgreater,
+ "\011isnan", (Math_f)isnanl,
+ "\011isnormal", (Math_f)local_isnormal,
+ "\012isunordered", (Math_f)local_isunordered,
+ "\001lgamma", (Math_f)lgammal,
+ "\001log", (Math_f)logl,
+ "\001log1p", (Math_f)log1pl,
+ "\001log2", (Math_f)log2l,
+ "\001logb", (Math_f)logbl,
+ "\001nearbyint", (Math_f)nearbyintl,
+ "\002nextafter", (Math_f)nextafterl,
+ "\002nexttoward", (Math_f)nexttowardl,
+ "\002pow", (Math_f)powl,
+ "\002remainder", (Math_f)remainderl,
+ "\001rint", (Math_f)rintl,
+ "\001round", (Math_f)roundl,
+ "\002scalb", (Math_f)scalbl,
+ "\002scalbn", (Math_f)scalbnl,
+ "\011signbit", (Math_f)local_signbit,
+ "\001sin", (Math_f)sinl,
+ "\001sinh", (Math_f)sinhl,
+ "\001sqrt", (Math_f)sqrtl,
+ "\001tan", (Math_f)tanl,
+ "\001tanh", (Math_f)tanhl,
+ "\001tgamma", (Math_f)tgammal,
+ "\001trunc", (Math_f)truncl,
+ "", (Math_f)0
+};
+#endif
diff --git a/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/options b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/options
new file mode 100644
index 0000000000..35a00af11e
--- /dev/null
+++ b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/options
@@ -0,0 +1,23 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/cmd/ksh93/features/options by iffe version 2007-04-04 : : */
+#ifndef _def_options_ksh93
+#define _def_options_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define SHELLMAGIC 1
+#ifndef SHOPT_DEVFD
+# define SHOPT_DEVFD 1
+#endif
+#ifndef SHOPT_PFSH
+# define SHOPT_PFSH 1
+#endif
+#undef SHOPT_TEST_L
+#undef SHOPT_UCB
+#if !_PACKAGE_ast && ( (MB_LEN_MAX-1)<=0 || !defined(_lib_mbtowc) )
+# undef SHOPT_MULTIBYTE
+#endif
+
+#endif
diff --git a/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/poll b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/poll
new file mode 100644
index 0000000000..418f251f69
--- /dev/null
+++ b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/poll
@@ -0,0 +1,119 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/cmd/ksh93/features/poll by iffe version 2007-04-04 : : */
+#ifndef _def_poll_ksh93
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_poll_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_poll 1 /* #include <poll.h> ok */
+#define _hdr_netinet_in 1 /* #include <netinet/in.h> ok */
+#define _sys_poll 1 /* #include <sys/poll.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _lib_select 1 /* select() in default lib(s) */
+#define _lib_poll 1 /* poll() in default lib(s) */
+#define _lib_socket 1 /* socket() in default lib(s) */
+#define _lib_htons 1 /* htons() in default lib(s) */
+#define _lib_htonl 1 /* htonl() in default lib(s) */
+#define _hdr_netdb 1 /* #include <netdb.h> ok */
+#define _lib_getaddrinfo 1 /* getaddrinfo() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _sys_select 1 /* #include <sys/select.h> ok */
+#define _typ_fd_set 1 /* fd_set is a type */
+#define _socketpair_devfd 1 /* /dev/fd/N handles socketpair() */
+
+#ifdef _lib_poll
+# define poll _SYS_poll
+#else
+# undef _hdr_poll
+# undef _sys_poll
+#endif /* _lib_poll */
+#ifdef _hdr_poll
+# include <poll.h>
+#else
+# ifdef _sys_poll
+# include <sys/poll.h>
+# endif /* _sys_poll */
+#endif /* _hdr_poll */
+#ifdef _lib_poll
+# undef poll
+ extern __MANGLE__ int poll __PROTO__((struct pollfd*,unsigned long,int));
+#endif /* _lib_poll */
+#ifdef _lib_select
+# ifndef FD_ZERO
+# define FD_ZERO(x) (*(x)=0)
+# endif /* FD_ZERO */
+# ifndef FD_SET
+# define FD_SET(n,x) (*(x)|=(1L<<(n)))
+# endif /* FD_SET */
+# ifndef _typ_fd_set
+ typedef long fd_set;
+# endif /*_typ_fd_set */
+#endif /* _lib_select */
+
+#endif
diff --git a/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/pstat b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/pstat
new file mode 100644
index 0000000000..480e62028b
--- /dev/null
+++ b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/pstat
@@ -0,0 +1,10 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_pstat_ksh93
+#define _def_pstat_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#endif
diff --git a/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/rlimits b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/rlimits
new file mode 100644
index 0000000000..d61331c9a1
--- /dev/null
+++ b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/rlimits
@@ -0,0 +1,19 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/cmd/ksh93/features/rlimits by iffe version 2007-04-04 : : */
+#ifndef _def_rlimits_ksh93
+#define _def_rlimits_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _sys_resource 1 /* #include <sys/resource.h> ok */
+#define _lib_getrlimit 1 /* getrlimit() in default lib(s) */
+#define _lib_ulimit 1 /* ulimit() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_rlim_t 1 /* rlim_t is a type */
+#endif
diff --git a/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/setjmp b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/setjmp
new file mode 100644
index 0000000000..0d7edb2e3e
--- /dev/null
+++ b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/setjmp
@@ -0,0 +1,35 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/cmd/ksh93/features/setjmp by iffe version 2007-04-04 : : */
+#ifndef _def_setjmp_ksh93
+#define _def_setjmp_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _lib_sigsetjmp 1 /* sigsetjmp() in default lib(s) */
+#define _lib__setjmp 1 /* _setjmp() in default lib(s) */
+#define _lib__longjmp 1 /* _longjmp() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_setjmp 1 /* #include <setjmp.h> ok */
+#define _typ_sigjmp_buf 1 /* sigjmp_buf is a type */
+#undef sigsetjmp
+#undef siglongjmp
+#undef sigjmp_buf
+#define sigjmp_buf jmp_buf
+#ifdef _lib__setjmp
+# define sigsetjmp(a,b) _setjmp(a)
+#else
+# define sigsetjmp(a,b) setjmp(a)
+#endif /* _lib__setjmp */
+#ifdef _lib__longjmp
+# define siglongjmp(a,b) _longjmp(a,b)
+#else
+# define siglongjmp(a,b) longjmp(a,b)
+#endif /* _lib__longjmp */
+
+#endif
diff --git a/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/sigfeatures b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/sigfeatures
new file mode 100644
index 0000000000..517ccfbc1f
--- /dev/null
+++ b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/sigfeatures
@@ -0,0 +1,54 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/cmd/ksh93/features/sigfeatures by iffe version 2007-04-04 : : */
+#ifndef _def_sigfeatures_ksh93
+#define _def_sigfeatures_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _lib_sigrelse 1 /* sigrelse() in default lib(s) */
+#define _lib_sigprocmask 1 /* sigprocmask() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_ast 1 /* #include <ast.h> ok */
+#define _hdr_signal 1 /* #include <signal.h> ok */
+#define _typ_sigset_t 1 /* sigset_t is a type */
+#ifndef _mem_sigvec_sv_mask
+# undef _lib_sigvec
+#endif
+#ifdef _lib_sigprocmask
+# define sh_sigaction(s,action) do { sigset_t ss;\
+ sigemptyset(&ss);\
+ sigaddset(&ss,(s));\
+ sigprocmask(action,&ss,0); \
+ }while(0)
+# define sigrelease(s) sh_sigaction(s,SIG_UNBLOCK)
+# define sigblock(s) sh_sigaction(s,SIG_BLOCK)
+# define sig_begin() sh_sigaction(0,SIG_SETMASK)
+#else
+# ifndef _lib_sigblock
+# define sigblock(s)
+# endif
+# ifdef _lib_sigsetmask
+# define sigrelease(s) sigsetmask(0)
+# define sig_begin() sigsetmask(0)
+# else
+# ifdef _lib_sigrelse
+# define sigrelease sigrelse
+# define sig_begin()
+# else
+# define sig_begin() (0)
+# define sigrelease(s) (0)
+# endif /* _lib_sigrelse */
+# endif /* _lib_sigsetmask */
+#endif /* _lib_sigprocmask */
+
+#undef _SIGRTMIN
+#define _SIGRTMIN 41
+#undef _SIGRTMAX
+#define _SIGRTMAX 48
+#endif
diff --git a/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/time b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/time
new file mode 100644
index 0000000000..f29ed94f58
--- /dev/null
+++ b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/time
@@ -0,0 +1,28 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/cmd/ksh93/features/time by iffe version 2007-04-04 : : */
+#ifndef _def_time_ksh93
+#define _def_time_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_utime 1 /* #include <utime.h> ok */
+#define _lib_gettimeofday 1 /* gettimeofday() in default lib(s) */
+#define _lib_setitimer 1 /* setitimer() in default lib(s) */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _mem_tv_usec_timeval 1 /* tv_usec is a member of struct timeval */
+#define _lib_2_timeofday 1 /* 2 arg gettimeofday() */
+#undef _def_time
+#include <times.h>
+#define _def_time 1
+#undef timeofday
+#if _lib_2_timeofday
+#define timeofday(p) gettimeofday(p,(struct timezone*)0)
+#else
+#if _lib_1_timeofday
+#define timeofday(p) gettimeofday(p)
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/ttys b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/ttys
new file mode 100644
index 0000000000..d558d9e668
--- /dev/null
+++ b/usr/src/lib/libshell/i386/src/cmd/ksh93/FEATURE/ttys
@@ -0,0 +1,19 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/src/cmd/ksh93/features/ttys by iffe version 2007-04-04 : : */
+#ifndef _def_ttys_ksh93
+#define _def_ttys_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_i386_32bit/arch/sol11.i386/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_termios 1 /* #include <termios.h> ok */
+#define _hdr_termio 1 /* #include <termio.h> ok */
+#define _hdr_sgtty 1 /* #include <sgtty.h> ok */
+#define _sys_termios 1 /* #include <sys/termios.h> ok */
+#define _sys_termio 1 /* #include <sys/termio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _lib_tcgetattr 1 /* tcgetattr() in default lib(s) */
+#define _lib_tcgetpgrp 1 /* tcgetpgrp() in default lib(s) */
+#endif
diff --git a/usr/src/lib/libshell/mapfile-vers b/usr/src/lib/libshell/mapfile-vers
new file mode 100644
index 0000000000..503d8fe439
--- /dev/null
+++ b/usr/src/lib/libshell/mapfile-vers
@@ -0,0 +1,170 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+SUNWprivate_1.1 {
+ global:
+ sh_bltin_tree;
+ sh_subfork;
+ sh_init;
+ sh_reinit;
+ sh_eval;
+ sh_delay;
+ sh_parse;
+ sh_tdump;
+ sh_trap;
+ sh_fun;
+ sh_funscope;
+ sh_iogetiop;
+ sh_main;
+ sh_menu;
+ sh_addbuiltin;
+ sh_fmtq;
+ sh_fmtqf;
+ sh_strnum;
+ sh_access;
+ sh_close;
+ sh_dup;
+ sh_exit;
+ sh_fcntl;
+ sh_getinterp;
+ sh_open;
+ sh_pathopen;
+ sh_read;
+ sh_write;
+ sh_seek;
+ sh_pipe;
+ sh_waitnotify;
+ sh_getscope;
+ sh_setscope;
+ sh_sigcheck;
+ sh_isoption;
+ sh_onoption;
+ sh_offoption;
+ sh_waitsafe;
+ sh_exec;
+ sh_getliblist;
+
+ nv_setarray;
+ nv_associative;
+ nv_aindex;
+ nv_nextsub;
+ nv_getsub;
+ nv_putsub;
+ nv_opensub;
+ nv_adddisc;
+ nv_clone;
+ nv_close;
+ nv_context;
+ nv_create;
+ nv_dict;
+ nv_getn;
+ nv_getnum;
+ nv_getv;
+ nv_getval;
+ nv_hasdisc;
+ nv_isnull;
+ nv_lastdict;
+ nv_newattr;
+ nv_open;
+ nv_putval;
+ nv_putv;
+ nv_scan;
+ nv_scoped;
+ nv_setdisc;
+ nv_setref;
+ nv_settype;
+ nv_setvec;
+ nv_setvtree;
+ nv_setsize;
+ nv_disc;
+ nv_unset;
+ nv_search;
+ nv_unscope;
+ nv_name;
+ nv_discfun;
+
+ # libshell overrides libast's |_ast_procrun()| (see sh/xec.c)
+ _ast_procrun;
+ local:
+ *;
+};
+
+# Builtin shell commands
+# (see libshell/common/include/builtins.h)
+# Note: We have to export all the |b_*()| symbols that the "builtin" command
+# can load builtins which are not enabled by the default OS/Net configuration.
+SUNWprivate_1.1 {
+ global:
+ B_echo;
+ B_login;
+ b_alarm;
+ b_alias;
+ b_bg;
+ b_break;
+ b_builtin;
+ b_cd;
+ b_close;
+ b_command;
+ b_dot_cmd;
+ b_dup;
+ b_eval;
+ b_exec;
+ b_false;
+ b_getopts;
+ b_hist;
+ b_jobs;
+ b_kill;
+ b_let;
+ b_open;
+ b_poll;
+ b_print;
+ b_printf;
+ b_pwd;
+ b_read;
+ b_readonly;
+ b_return;
+ b_rewind;
+ b_set;
+ b_shift;
+ b_sleep;
+ b_stat;
+ b_test;
+ b_tmpfile;
+ b_trap;
+ b_true;
+ b_typeset;
+ b_ulimit;
+ b_umask;
+ b_unalias;
+ b_unset;
+ b_vpath;
+ b_wait;
+ b_whence;
+ local:
+ *;
+};
diff --git a/usr/src/lib/libshell/misc/ERRATA.txt b/usr/src/lib/libshell/misc/ERRATA.txt
new file mode 100644
index 0000000000..8ef83974ff
--- /dev/null
+++ b/usr/src/lib/libshell/misc/ERRATA.txt
@@ -0,0 +1,327 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+#
+# ERRATA.txt
+#
+# Errata/problems/notes about problems in the current sources
+#
+
+######## Errata #001: ########
+Some constants which are larger than 2^32 seem to
+require either "LL" or "ULL" as suffix to get the build compiling - at least in
+OS/Net with it's very strict build flags the problem is that worse that I had
+to use "-Wno-error" in usr/src/lib/libast/Makefile.com for the gcc build to get
+it compiling:
+-- snip --
+pics/$(MACH)/src/lib/libast/conftab.o := CERRWARN +=
+-erroff=E_C99_INTEGER_PROMOTION
+pics/$(MACH)/src/lib/libast/conftab.o \
+pics/$(MACH64)/src/lib/libast/conftab.o := CERRWARN +=
+-erroff=E_INTEGRAL_CONSTANT_TOO_LARGE
+pics/$(MACH)/src/lib/libast/conftab.o \
+pics/$(MACH64)/src/lib/libast/conftab.o := CERRWARN +=
+-erroff=E_INTEGER_OVERFLOW_DETECTED
+pics/$(MACH)/src/lib/libast/conftab.o \
+pics/$(MACH64)/src/lib/libast/conftab.o := CERRWARN += -_gcc=-Wno-error
+pics/common/hash/
+-- snip --
+
+The following diff has been used to (temporarily work around the problem:
+-- snip --
+Index: src/lib/libast/sparcv9/src/lib/libast/conftab.c
+===================================================================
+--- src/lib/libast/sparcv9/src/lib/libast/conftab.c (revision 664)
++++ src/lib/libast/sparcv9/src/lib/libast/conftab.c (working copy)
+@@ -220,8 +220,8 @@
+ { "LFS_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_LINTFLAGS },
+ { "LINE_MAX", { 0, 0 }, { _POSIX2_LINE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_LINE_MAX },
+ { "LINK_MAX", { 0, 0 }, { _POSIX_LINK_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_LINK_MAX },
+-{ "LLONG_MAX", { 9223372036854775807, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+-{ "LLONG_MIN", { -9223372036854775808, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
++{ "LLONG_MAX", { 9223372036854775807LL, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
++{ "LLONG_MIN", { (-9223372036854775807LL-1LL), 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+ { "LOCALEDEF", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_LOCALEDEF },
+ { "LOGIN_NAME_MAX", { 0, 0 }, { _POSIX_LOGIN_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_LOGIN_NAME_MAX },
+ { "LOGNAME_MAX", { 0, 0 }, { 8, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, _SC_LOGNAME_MAX },
+@@ -407,7 +407,7 @@
+ { "UID_MAX", { 0, 0 }, { 60002, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+ { "UINT_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+ { "UIO_MAXIOV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+-{ "ULLONG_MAX", { 18446744073709551615, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
++{ "ULLONG_MAX", { 18446744073709551615ULL, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+ { "ULONG_MAX", { 4294967295, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+ { "UNIX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_UNIX },
+ { "UPE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_UPE },
+Index: src/lib/libast/sparc/src/lib/libast/conftab.c
+===================================================================
+--- src/lib/libast/sparc/src/lib/libast/conftab.c (revision 664)
++++ src/lib/libast/sparc/src/lib/libast/conftab.c (working copy)
+@@ -220,8 +220,8 @@
+ { "LFS_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_LINTFLAGS },
+ { "LINE_MAX", { 0, 0 }, { _POSIX2_LINE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_LINE_MAX },
+ { "LINK_MAX", { 0, 0 }, { _POSIX_LINK_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_LINK_MAX },
+-{ "LLONG_MAX", { 9223372036854775807, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+-{ "LLONG_MIN", { -9223372036854775808, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
++{ "LLONG_MAX", { 9223372036854775807LL, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
++{ "LLONG_MIN", { (-9223372036854775807LL-1LL), 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+ { "LOCALEDEF", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_LOCALEDEF },
+ { "LOGIN_NAME_MAX", { 0, 0 }, { _POSIX_LOGIN_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_LOGIN_NAME_MAX },
+ { "LOGNAME_MAX", { 0, 0 }, { 8, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, _SC_LOGNAME_MAX },
+@@ -407,7 +407,7 @@
+ { "UID_MAX", { 0, 0 }, { 60002, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+ { "UINT_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+ { "UIO_MAXIOV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+-{ "ULLONG_MAX", { 18446744073709551615, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
++{ "ULLONG_MAX", { 18446744073709551615ULL, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+ { "ULONG_MAX", { 4294967295, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+ { "UNIX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_UNIX },
+ { "UPE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_UPE },
+Index: src/lib/libast/i386/src/lib/libast/conftab.c
+===================================================================
+--- src/lib/libast/i386/src/lib/libast/conftab.c (revision 664)
++++ src/lib/libast/i386/src/lib/libast/conftab.c (working copy)
+@@ -220,8 +220,8 @@
+ { "LFS_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_LINTFLAGS },
+ { "LINE_MAX", { 0, 0 }, { _POSIX2_LINE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_LINE_MAX },
+ { "LINK_MAX", { 0, 0 }, { _POSIX_LINK_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_LINK_MAX },
+-{ "LLONG_MAX", { 9223372036854775807, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+-{ "LLONG_MIN", { -9223372036854775808, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
++{ "LLONG_MAX", { 9223372036854775807LL, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
++{ "LLONG_MIN", { (-9223372036854775807LL-1LL), 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+ { "LOCALEDEF", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_LOCALEDEF },
+ { "LOGIN_NAME_MAX", { 0, 0 }, { _POSIX_LOGIN_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_LOGIN_NAME_MAX },
+ { "LOGNAME_MAX", { 0, 0 }, { 8, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, _SC_LOGNAME_MAX },
+@@ -407,7 +407,7 @@
+ { "UID_MAX", { 0, 0 }, { 60002, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+ { "UINT_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+ { "UIO_MAXIOV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+-{ "ULLONG_MAX", { 18446744073709551615, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
++{ "ULLONG_MAX", { 18446744073709551615ULL, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+ { "ULONG_MAX", { 4294967295, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+ { "UNIX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_UNIX },
+ { "UPE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_UPE },
+Index: src/lib/libast/Makefile.com
+===================================================================
+--- src/lib/libast/Makefile.com (revision 664)
++++ src/lib/libast/Makefile.com (working copy)
+@@ -706,11 +706,7 @@
+ CERRWARN += -erroff=E_UNRECOGNIZED_PRAGMA_IGNORED
+ pics/$(MACH)/src/lib/libast/conftab.o := CERRWARN += -erroff=E_C99_INTEGER_PROMOTION
+ pics/$(MACH)/src/lib/libast/conftab.o \
+-pics/$(MACH64)/src/lib/libast/conftab.o := CERRWARN += -erroff=E_INTEGRAL_CONSTANT_TOO_LARGE
+-pics/$(MACH)/src/lib/libast/conftab.o \
+-pics/$(MACH64)/src/lib/libast/conftab.o := CERRWARN += -erroff=E_INTEGER_OVERFLOW_DETECTED
+-pics/$(MACH)/src/lib/libast/conftab.o \
+-pics/$(MACH64)/src/lib/libast/conftab.o := CERRWARN += -_gcc=-Wno-error
++pics/$(MACH64)/src/lib/libast/conftab.o := CERRWARN += -erroff=E_INIT_DOES_NOT_FIT
+ pics/common/hash/hashlook.o := CERRWARN += -erroff=E_CONST_PROMOTED_UNSIGNED_LONG
+ pics/common/hash/memhash.o := CERRWARN += -erroff=E_CONST_PROMOTED_UNSIGNED_LONG
+ pics/common/hash/memsum.o := CERRWARN += -erroff=E_CONST_PROMOTED_UNSIGNED_LONG
+Index: src/lib/libast/amd64/src/lib/libast/conftab.c
+===================================================================
+--- src/lib/libast/amd64/src/lib/libast/conftab.c (revision 664)
++++ src/lib/libast/amd64/src/lib/libast/conftab.c (working copy)
+@@ -220,8 +220,8 @@
+ { "LFS_LINTFLAGS", { 0, 0 }, { 0, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_STRING, CONF_POSIX, 1, CONF_confstr, _CS_LFS_LINTFLAGS },
+ { "LINE_MAX", { 0, 0 }, { _POSIX2_LINE_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_NOSECTION|CONF_MINMAX_DEF, CONF_POSIX, 2, CONF_sysconf, _SC_LINE_MAX },
+ { "LINK_MAX", { 0, 0 }, { _POSIX_LINK_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_pathconf, _PC_LINK_MAX },
+-{ "LLONG_MAX", { 9223372036854775807, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+-{ "LLONG_MIN", { -9223372036854775808, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
++{ "LLONG_MAX", { 9223372036854775807LL, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
++{ "LLONG_MIN", { (-9223372036854775807LL-1LL), 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+ { "LOCALEDEF", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_LOCALEDEF },
+ { "LOGIN_NAME_MAX", { 0, 0 }, { _POSIX_LOGIN_NAME_MAX, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_POSIX, 1, CONF_sysconf, _SC_LOGIN_NAME_MAX },
+ { "LOGNAME_MAX", { 0, 0 }, { 8, 0 }, CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, _SC_LOGNAME_MAX },
+@@ -407,7 +407,7 @@
+ { "UID_MAX", { 0, 0 }, { 60002, 0 }, CONF_LIMIT|CONF_MINMAX|CONF_UNDERSCORE|CONF_MINMAX_DEF, CONF_SVID, 1, CONF_sysconf, -1 },
+ { "UINT_MAX", { 0, 0 }, { 0, 0 }, CONF_LIMIT, CONF_C, 1, CONF_nop, -1 },
+ { "UIO_MAXIOV", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE, CONF_POSIX, 1, CONF_nop, -1 },
+-{ "ULLONG_MAX", { 18446744073709551615, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
++{ "ULLONG_MAX", { 18446744073709551615ULL, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+ { "ULONG_MAX", { 4294967295, 0 }, { 0, 0 }, CONF_LIMIT|CONF_LIMIT_DEF, CONF_C, 1, CONF_nop, -1 },
+ { "UNIX", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_STANDARD|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_XOPEN, 1, CONF_sysconf, _SC_XOPEN_UNIX },
+ { "UPE", { 0, 0 }, { 0, 0 }, CONF_FEATURE|CONF_UNDERSCORE|CONF_PREFIX_ONLY, CONF_POSIX, 2, CONF_sysconf, _SC_2_UPE },
+-- snip --
+
+This change works around the problems in the generated "conftab.c" ; I'll file a patch against
+"libast/common/comp/conf.sh" later to fix the problem in the upstream sources...
+
+######## Errata #002: ########
+A change to usr/src/lib/libcmd/common/date.c has been applied to prevent
+the string literals (backslashes added to prevent expansion) "%M\%" and "%Y\%"
+from being expanded by the SCCS version control software:
+
+-- snip --
+Index: src/lib/libcmd/common/date.c
+===================================================================
+--- src/lib/libcmd/common/date.c (revision 694)
++++ src/lib/libcmd/common/date.c (working copy)
+@@ -222,13 +222,13 @@
+ *argv++ = s;
+ if (streq(astconf("UNIVERSE", NiL, NiL), "att"))
+ {
+- tmxfmt(buf, sizeof(buf), "%m%d%H" "%M%Y.%S", now);
++ tmxfmt(buf, sizeof(buf), "%m%d%H" "%M" "%Y.%S", now);
+ if (adjust)
+ *argv++ = "-a";
+ }
+ else
+ {
+- tmxfmt(buf, sizeof(buf), "%Y%m%d%H" "%M.%S", now);
++ tmxfmt(buf, sizeof(buf), "%Y" "%m%d%H" "%M.%S", now);
+ if (network)
+ *argv++ = "-n";
+ if (tm_info.flags & TM_UTC)
+-- snip --
+
+
+######## Errata #003: ########
+A change to usr/src/lib/libshell/common/sh/jobs.c has been applied to handle
+a memory corruption condition caused by a call to |_ast_malloc()| from within
+a signal handler.
+-- snip --
+Index: src/lib/libshell/common/sh/jobs.c
+===================================================================
+--- src/lib/libshell/common/sh/jobs.c (revision 743)
++++ src/lib/libshell/common/sh/jobs.c (working copy)
+@@ -43,6 +24,8 @@
+ # define WIFCONTINUED(wstat) (0)
+ #endif
+
++#define NJOB_SAVELIST 4
++
+ /*
+ * temporary hack to get W* macros to work
+ */
+@@ -59,13 +42,35 @@
+ unsigned short exitval;
+ };
+
++static struct jobsave *job_savelist;
++static int njob_savelist;
++
++static void init_savelist(void)
++{
++ register struct jobsave *jp;
++ while(njob_savelist < NJOB_SAVELIST)
++ {
++ jp = newof(0,struct jobsave,1,0);
++ jp->next = job_savelist;
++ job_savelist = jp;
++ njob_savelist++;
++ }
++}
++
+ /*
+ * return next on link list of jobsave free list
+ */
+ static struct jobsave *jobsave_create(pid_t pid)
+ {
+- struct jobsave *jp;
+- if(jp = newof(0,struct jobsave,1,0))
++ register struct jobsave *jp = job_savelist;
++ if(jp)
++ {
++ njob_savelist--;
++ job_savelist = jp->next;
++ }
++ else
++ jp = newof(0,struct jobsave,1,0);
++ if(jp)
+ jp->pid = pid;
+ return(jp);
+ }
+@@ -372,6 +377,8 @@
+ # if defined(SIGCLD) && (SIGCLD!=SIGCHLD)
+ signal(SIGCLD,job_waitsafe);
+ # endif
++ if(njob_savelist < NJOB_SAVELIST)
++ init_savelist();
+ if(!sh_isoption(SH_INTERACTIVE))
+ return;
+ /* use new line discipline when available */
+@@ -994,6 +1001,8 @@
+ free((void*)jp);
+ }
+ bck.list = 0;
++ if(njob_savelist < NJOB_SAVELIST)
++ init_savelist();
+ job.pwlist = NIL(struct process*);
+ job.numpost=0;
+ job.waitall = 0;
+@@ -1016,6 +1025,8 @@
+ register struct process *pw;
+ register History_t *hp = sh.hist_ptr;
+ sh.jobenv = sh.curenv;
++ if(njob_savelist < NJOB_SAVELIST)
++ init_savelist();
+ if(job.toclear)
+ {
+ job_clear();
+@@ -1274,8 +1285,14 @@
+ px->p_flag &= ~P_EXITSAVE;
+ }
+ }
+- if(!(px=job_unpost(pw,1)) || !job.waitall)
++ if(!job.waitall)
++ {
++ if(!sh_isoption(SH_PIPEFAIL))
++ job_unpost(pw,1);
+ break;
++ }
++ else if(!(px=job_unpost(pw,1)))
++ break;
+ pw = px;
+ continue;
+ }
+@@ -1313,6 +1330,8 @@
+ else
+ tty_set(-1, 0, NIL(struct termios*));
+ done:
++ if(!job.waitall && sh_isoption(SH_PIPEFAIL))
++ return;
+ if(!sh.intrap)
+ {
+ job_lock();
+@@ -1594,7 +1613,14 @@
+ else
+ bck.list = jp->next;
+ bck.count--;
+- free((void*)jp);
++ if(njob_savelist < NJOB_SAVELIST)
++ {
++ njob_savelist++;
++ jp->next = job_savelist;
++ job_savelist = jp;
++ }
++ else
++ free((void*)jp);
+ }
+ return(r);
+ }
+-- snip --
+# EOF.
diff --git a/usr/src/lib/libshell/misc/buildksh93.ksh b/usr/src/lib/libshell/misc/buildksh93.ksh
new file mode 100644
index 0000000000..c463a1a815
--- /dev/null
+++ b/usr/src/lib/libshell/misc/buildksh93.ksh
@@ -0,0 +1,373 @@
+#!/bin/ksh
+
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+#
+# buildksh93.ksh - ast-ksh standalone build script for the
+# OpenSolaris ksh93-integration project
+#
+
+# ksh93s+ beta sources can be downloaded like this from the AT&T site:
+# wget --http-user="I accept www.opensource.org/licenses/cpl" --http-passwd="." 'http://www.research.att.com/sw/download/beta/INIT.2007-04-18.tgz'
+# wget --http-user="I accept www.opensource.org/licenses/cpl" --http-passwd="." 'http://www.research.att.com/sw/download/beta/ast-ksh.2007-04-18.tgz'
+
+function fatal_error
+{
+ printf "${0}: %s\n" "${1}" >&2
+ exit 1
+}
+
+buildmode="$1"
+
+if [ "${buildmode}" = "" ] ; then
+ fatal_error "buildmode required."
+fi
+
+set -e -x
+
+# make sure we use the C locale during building to avoid any unintended
+# side-effects
+export LANG=C
+export LC_ALL=$LANG LC_MONETARY=$LANG LC_NUMERIC=$LANG LC_MESSAGES=$LANG LC_COLLATE=$LANG LC_CTYPE=$LANG
+
+function print_solaris_builtin_header
+{
+cat <<ENDOFTEXT
+/* POSIX compatible commands */
+#ifdef _NOT_YET
+#define XPG6CMDLIST(f) { "/usr/xpg6/bin/" #f, NV_BLTIN|NV_NOFREE, bltin(f) },
+#define XPG4CMDLIST(f) { "/usr/xpg4/bin/" #f, NV_BLTIN|NV_NOFREE, bltin(f) },
+#else
+#define XPG6CMDLIST(f)
+#define XPG4CMDLIST(f)
+#endif /* NOT_YET */
+/* Commands which are 100% compatible with native Solaris versions (/bin is
+ * a softlink to ./usr/bin so both need to be listed here) */
+#define BINCMDLIST(f) { "/bin/" #f, NV_BLTIN|NV_NOFREE, bltin(f) },
+/* Make all ksh93 builtins accessible when /usr/ast/bin was added to ${PATH} */
+#define ASTCMDLIST(f) { "/usr/ast/bin/" #f, NV_BLTIN|NV_NOFREE, bltin(f) },
+
+/* undo ast_map.h #defines to avoid collision */
+#undef basename
+#undef dirname
+
+/* Generated data, do not edit. */
+XPG4CMDLIST(basename)
+ASTCMDLIST(basename)
+BINCMDLIST(cat)
+ASTCMDLIST(cat)
+XPG4CMDLIST(chgrp)
+ASTCMDLIST(chgrp)
+ASTCMDLIST(chmod)
+XPG4CMDLIST(chown)
+BINCMDLIST(chown)
+ASTCMDLIST(chown)
+ASTCMDLIST(cmp)
+ASTCMDLIST(comm)
+XPG4CMDLIST(cp)
+ASTCMDLIST(cp)
+ASTCMDLIST(cut)
+XPG4CMDLIST(date)
+ASTCMDLIST(date)
+ASTCMDLIST(dirname)
+XPG4CMDLIST(expr)
+ASTCMDLIST(expr)
+ASTCMDLIST(fds)
+ASTCMDLIST(fmt)
+ASTCMDLIST(fold)
+BINCMDLIST(head)
+ASTCMDLIST(head)
+XPG4CMDLIST(id)
+ASTCMDLIST(id)
+ASTCMDLIST(join)
+XPG4CMDLIST(ln)
+ASTCMDLIST(ln)
+ASTCMDLIST(logname)
+BINCMDLIST(mkdir)
+ASTCMDLIST(mkdir)
+ASTCMDLIST(mkfifo)
+XPG4CMDLIST(mv)
+ASTCMDLIST(mv)
+ASTCMDLIST(paste)
+ASTCMDLIST(pathchk)
+ASTCMDLIST(rev)
+XPG4CMDLIST(rm)
+ASTCMDLIST(rm)
+BINCMDLIST(rmdir)
+ASTCMDLIST(rmdir)
+XPG4CMDLIST(stty)
+ASTCMDLIST(stty)
+XPG4CMDLIST(tail)
+ASTCMDLIST(tail)
+BINCMDLIST(tee)
+ASTCMDLIST(tee)
+ASTCMDLIST(tty)
+ASTCMDLIST(uname)
+BINCMDLIST(uniq)
+ASTCMDLIST(uniq)
+BINCMDLIST(wc)
+ASTCMDLIST(wc)
+
+/* Mandatory for ksh93 test suite and AST scripts */
+BINCMDLIST(getconf)
+
+ENDOFTEXT
+}
+
+function build_shell
+{
+ set -e -x
+
+ # OS.cputype.XXbit.compiler
+ case "${buildmode}" in
+ *.linux.*)
+ # ksh93+AST config flags
+ BAST_FLAGS="-DSHOPT_CMDLIB_BLTIN=0 -DSH_CMDLIB_DIR=\\\"/usr/ast/bin\\\" -DSHOPT_SYSRC -D_map_libc=1"
+
+ # gcc flags
+ BGCC99="gcc -std=gnu99"
+ BGCC_CCFLAGS="${BON_FLAGS} ${BAST_FLAGS}"
+
+ case "${buildmode}" in
+ # Linux i386
+ *.i386.32bit.gcc*) HOSTTYPE="linux.i386" CC="${BGCC99} -fPIC" CC_SHAREDLIB="-shared" CCFLAGS="${BGCC_CCFLAGS}"
+ ;;
+ *)
+ fatal_error "build_shell: Illegal Linux type/compiler build mode \"${buildmode}\"."
+ ;;
+ esac
+ ;;
+ *.solaris.*)
+ # Notes:
+ # 1. Do not remove/modify these flags or their order before either
+ # asking the project leads at
+ # http://www.opensolaris.org/os/project/ksh93-integration/
+ # These flags all have a purpose, even if they look
+ # weird/redundant/etc. at the first look.
+ #
+ # 2. We use -KPIC here since -Kpic is too small on 64bit sparc and
+ # on 32bit it's close to the barrier so we use it for both 32bit and
+ # 64bit to avoid later suprises when people update libast in the
+ # future
+ #
+ # 3. "-D_map_libc=1" is needed to force map.c to add a "_ast_" prefix to all
+ # AST symbol names which may otherwise collide with Solaris/Linux libc
+ #
+ # 4. "-DSHOPT_SYSRC" enables /etc/ksh.kshrc support (AST default is currently
+ # to enable it if /etc/ksh.kshrc or /etc/bash.bashrc are available on the
+ # build machine).
+ #
+ # 5. -D_lib_socket=1 -lsocket -lnsl" was added to make sure ksh93 is compiled
+ # with networking support enabled, the current AST build infratructure has
+ # problems with detecting networking support in Solaris.
+ #
+ # 6. "-xc99=%all -D_XOPEN_SOURCE=600 -D__EXTENSIONS__=1" is used to force
+ # the compiler into C99 mode. Otherwise ksh93 will be much slower and lacks
+ # lots of arithmethic functions.
+ #
+ # 7. "-D_TS_ERRNO -D_REENTRANT" are flags taken from the default OS/Net
+ # build system.
+ #
+ # 8. "-xpagesize_stack=64K -xpagesize_heap=64K" is used on SPARC to
+ # enhance the performace
+ #
+ # 9. -DSHOPT_CMDLIB_BLTIN=0 -DSH_CMDLIB_DIR=\\\"/usr/ast/bin\\\" -DSHOPT_CMDLIB_HDR=\\\"/home/test001/ksh93/ast_ksh_20070322/solaris_cmdlist.h\\\"
+ # is used to bind all ksh93 builtins to a "virtual" directory
+ # called "/usr/ast/bin/" and to adjust the list of builtins
+ # enabled by default to those defined by PSARC 2006/550
+
+ solaris_builtin_header="$PWD/tmp_solaris_builtin_header.h"
+ print_solaris_builtin_header >"${solaris_builtin_header}"
+
+ # OS/Net build flags
+ BON_FLAGS="-D_TS_ERRNO -D_REENTRANT"
+
+ # ksh93+AST config flags
+ BAST_FLAGS="-DSHOPT_CMDLIB_BLTIN=0 -DSH_CMDLIB_DIR=\\\"/usr/ast/bin\\\" -DSHOPT_CMDLIB_HDR=\\\"${solaris_builtin_header}\\\" -DSHOPT_SYSRC -D_map_libc=1"
+
+ # Sun Studio flags
+ BSUNCC99="/opt/SUNWspro/bin/cc -xc99=%all -D_XOPEN_SOURCE=600 -D__EXTENSIONS__=1"
+ BSUNCC_APP_CCFLAGS_SPARC="-xpagesize_stack=64K -xpagesize_heap=64K" # use BSUNCC_APP_CCFLAGS_SPARC only for final executables
+ BSUNCC_CCFLAGS="${BON_FLAGS} -KPIC -g -xs -xspace -Xa -xstrconst -z combreloc -xildoff -errtags=yes ${BAST_FLAGS} -D_lib_socket=1 -lsocket -lnsl"
+
+ # gcc flags
+ BGCC99="/usr/sfw/bin/gcc -std=gnu99 -D_XOPEN_SOURCE=600 -D__EXTENSIONS__=1"
+ BGCC_CCFLAGS="${BON_FLAGS} ${BAST_FLAGS} -D_lib_socket=1 -lsocket -lnsl"
+
+
+ case "${buildmode}" in
+ *.i386.32bit.suncc*) HOSTTYPE="sol11.i386" CC="${BSUNCC99}" CC_SHAREDLIB="-G" CCFLAGS="${BSUNCC_CCFLAGS}" ;;
+ *.i386.64bit.suncc*) HOSTTYPE="sol11.i386" CC="${BSUNCC99} -xarch=amd64 -KPIC" CC_SHAREDLIB="-G" CCFLAGS="${BSUNCC_CCFLAGS}" ;;
+ *.sparc.32bit.suncc*) HOSTTYPE="sol11.sun4" CC="${BSUNCC99}" CC_SHAREDLIB="-G" CCFLAGS="${BSUNCC_CCFLAGS}" BSUNCC_APP_CCFLAGS="${BSUNCC_APP_CCFLAGS_SPARC}" ;;
+ *.sparc.64bit.suncc*) HOSTTYPE="sol11.sun4" CC="${BSUNCC99} -xarch=v9 -KPIC" CC_SHAREDLIB="-G" CCFLAGS="${BSUNCC_CCFLAGS}" BSUNCC_APP_CCFLAGS="${BSUNCC_APP_CCFLAGS_SPARC}" ;;
+
+ *.i386.32bit.gcc*) HOSTTYPE="sol11.i386" CC="${BGCC99} -fPIC" CC_SHAREDLIB="-shared" CCFLAGS="${BGCC_CCFLAGS}" ;;
+ *.i386.64bit.gcc*) HOSTTYPE="sol11.i386" CC="${BGCC99} -m64 -mtune=opteron -Ui386 -U__i386 -fPIC" CC_SHAREDLIB="-shared" CCFLAGS="${BGCC_CCFLAGS}" ;;
+ *.sparc.32bit.gcc*) HOSTTYPE="sol11.sun4" CC="${BGCC99} -m32 -mcpu=v8 -fPIC " CC_SHAREDLIB="-shared" CCFLAGS="${BGCC_CCFLAGS}" ;;
+ *.sparc.64bit.gcc*) HOSTTYPE="sol11.sun4" CC="${BGCC99} -m64 -mcpu=v9 -fPIC" CC_SHAREDLIB="-shared" CCFLAGS="${BGCC_CCFLAGS}" ;;
+
+ *)
+ fatal_error "build_shell: Illegal Solaris type/compiler build mode \"${buildmode}\"."
+ ;;
+ esac
+ ;;
+ *)
+ fatal_error "Illegal OS build mode \"${buildmode}\"."
+ ;;
+ esac
+
+ # some prechecks
+ [ -z "${CCFLAGS}" ] && fatal_error "build_shell: CCFLAGS is empty."
+ [ -z "${CC}" ] && fatal_error "build_shell: CC is empty."
+ [ -z "${HOSTTYPE}" ] && fatal_error "build_shell: HOSTTYPE is empty."
+ [ ! -f "bin/package" ] && fatal_error "build_shell: bin/package missing."
+ [ ! -x "bin/package" ] && fatal_error "build_shell: bin/package not executable."
+
+ export CCFLAGS CC HOSTTYPE
+
+ # build ksh93
+ bin/package make CCFLAGS="${CCFLAGS}" CC="${CC}" HOSTTYPE="${HOSTTYPE}"
+
+ root="${PWD}/arch/${HOSTTYPE}"
+ test -d "$root" || fatal_error "build_shell: directory ${root} not found."
+ log="${root}/lib/package/gen/make.out"
+
+ test -s $log || fatal_error "build_shell: no make.out log found."
+
+ if [[ "${buildmode}" != *.staticshell* ]] ; then
+ # libcmd causes some trouble since there is a squatter in solaris
+ # This has been fixed in Solaris 11/B48 but may require adjustments
+ # for older Solaris releases
+ for lib in libast libdll libcmd libshell ; do
+ test $? -eq 0 || exit 1
+ case "$lib" in
+ libshell)
+ base="lib/"
+ vers=1
+ link="-L${root}/lib/ -lcmd -ldll -last -lm"
+ ;;
+ libdll)
+ base="src/lib/${lib}"
+ vers=1
+ link="-ldl"
+ ;;
+ libast)
+ base="src/lib/${lib}"
+ vers=1
+ link="-lm"
+ ;;
+ *)
+ base="src/lib/${lib}"
+ vers=1
+ link="-L${root}/lib/ -last -lm"
+ ;;
+ esac
+
+ (
+ cd "${root}/${base}"
+ if [[ "${buildmode}" = *solaris* ]] ; then
+ ${CC} ${CC_SHAREDLIB} ${CCFLAGS} -Wl,-zallextract -Wl,-zmuldefs -o "${root}/lib/${lib}.so.${vers}" "${lib}.a" $link
+ else
+ ${CC} ${CC_SHAREDLIB} ${CCFLAGS} -Wl,--whole-archive -Wl,-zmuldefs "${lib}.a" -Wl,--no-whole-archive -o "${root}/lib/${lib}.so.${vers}" $link
+ fi
+
+ #rm ${lib}.a
+ mv "${lib}.a" "disabled_${lib}.a_"
+
+ cd "${root}/lib"
+ ln -sf "${lib}.so.${vers}" "${lib}.so"
+ )
+ done
+
+ (
+ base=src/cmd/ksh93
+ cd ${root}/${base}
+ rm -f ${root}/lib/libshell.a
+ rm -f ${root}/lib/libdll.a
+ rm -f ${root}/lib/libast.a
+
+ if [[ "${buildmode}" = *solaris* ]] ; then
+ ${CC} ${CCFLAGS} ${BSUNCC_APP_CCFLAGS} -L${root}/lib/ -o ksh pmain.o -lshell -Bstatic -lcmd -Bdynamic -ldll -last -lm -lsecdb
+ else
+ ${CC} ${CCFLAGS} ${BSUNCC_APP_CCFLAGS} -L${root}/lib/ -o ksh pmain.o -lshell -lcmd -ldll -last -lm
+ fi
+
+ ldd ksh
+ )
+ fi
+}
+
+function test_shell
+{
+ set -e -x
+
+ export SHELL="$(ls -1 $PWD/arch/*/src/cmd/ksh93/ksh)"
+ export LD_LIBRARY_PATH="$(ls -1ad $PWD/arch/*/lib):${LD_LIBRARY_PATH}"
+ export LD_LIBRARY_PATH_32="$(ls -1ad $PWD/arch/*/lib):${LD_LIBRARY_PATH_32}"
+ export LD_LIBRARY_PATH_64="$(ls -1ad $PWD/arch/*/lib):${LD_LIBRARY_PATH_64}"
+ print "## SHELL is |${SHELL}|"
+ print "## LD_LIBRARY_PATH is |${LD_LIBRARY_PATH}|"
+
+ [ ! -f "${SHELL}" ] && fatal_error "test_shell: |${SHELL}| is not a file."
+ [ ! -x "${SHELL}" ] && fatal_error "test_shell: |${SHELL}| is not executable."
+
+ case "${buildmode}" in
+ testshell.bcheck*)
+ for i in ./src/cmd/ksh93/tests/*.sh ; do
+ bc_logfile="$(basename "$i").$$.bcheck"
+ rm -f "${bc_logfile}"
+ /opt/SUNWspro/bin/bcheck -q -access -o "${bc_logfile}" ${SHELL} ./src/cmd/ksh93/tests/shtests \
+ LD_LIBRARY_PATH_64="$LD_LIBRARY_PATH_64" \
+ LD_LIBRARY_PATH="$LD_LIBRARY_PATH" \
+ LD_LIBRARY_PATH_32="$LD_LIBRARY_PATH_32"\
+ LANG=C LC_ALL=C \
+ "$i"
+ cat "${bc_logfile}"
+ done
+ ;;
+ testshell)
+ for i in ./src/cmd/ksh93/tests/*.sh ; do
+ ${SHELL} ./src/cmd/ksh93/tests/shtests \
+ LD_LIBRARY_PATH_64="$LD_LIBRARY_PATH_64" \
+ LD_LIBRARY_PATH="$LD_LIBRARY_PATH" \
+ LD_LIBRARY_PATH_32="$LD_LIBRARY_PATH_32"\
+ LANG=C LC_ALL=C \
+ "$i"
+ done
+ ;;
+ esac
+}
+
+# main
+case "${buildmode}" in
+ build.*) build_shell ;;
+ testshell*) test_shell ;;
+ *) fatal_error "Illegal build mode \"${buildmode}\"." ;;
+esac
+# EOF.
diff --git a/usr/src/lib/libshell/misc/buildksh93.readme b/usr/src/lib/libshell/misc/buildksh93.readme
new file mode 100644
index 0000000000..f221b17a4e
--- /dev/null
+++ b/usr/src/lib/libshell/misc/buildksh93.readme
@@ -0,0 +1,74 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+#
+# buildksh93.readme
+#
+
+* Intro:
+"buildksh93.ksh" is a small build script used to build the AT&T "ast-ksh"
+and "ast-open" packages using its native (nmake-based) build system
+which is needed to build the iffe-generated (header) files (each time
+for { 32bit SPARC, 64bit SPARC, 32bit i386, 64bit AMD64 }) which are
+moved later to their matching OS/Net build directories.
+
+
+* Note that buildksh93.ksh modifies the build behaviour of the AST build
+system, including enforcing C99/XPG6 semantics (which is MANDATORY!!)
+and feeding additional libraries (like libnsl, libsocket, librt etc.)
+to the feature look system (called "iffe" (="if feature exists")) to
+ensure all features needed for the Solaris version of ksh93 are
+properly found.
+
+
+* Example usage of the script (more information can be found in the
+script itself):
+## Download AT&T ksh93 sources
+$ wget --http-user="I accept www.opensource.org/licenses/cpl" --http-passwd="." 'http://www.research.att.com/sw/download/beta/INIT.2007-04-18.tgz'
+$ wget --http-user="I accept www.opensource.org/licenses/cpl" --http-passwd="." 'http://www.research.att.com/sw/download/beta/ast-ksh.2007-04-18.tgz'
+
+## Unpack the sources (32bit SPARC):
+$ mkdir build32_sparc
+$ cd build32_sparc
+$ gunzip -c ../INIT.2007-03-28.tgz | tar -xf -
+$ gunzip -c ../ast-ksh.2007-03-28.tgz | tar -xf -
+
+## Build ast-ksh for 32bit SPARC (build other build flags are:
+# - "build.solaris.sparc.32bit.suncc" - 32bit SPARC
+# - "build.solaris.sparc.64bit.suncc" - 64bit SPARC
+# - "build.solaris.i386.32bit.suncc" - 32bit x86/i386
+# - "build.solaris.i386.64bit.suncc" - 64bit x86/AMD64
+# )
+$ time nice ksh ../buildksh93.ksh "build.solaris.sparc.32bit.suncc" 2>&1 | tee -a buildlog.log
+
+## Test ksh93
+$ time nice ksh ../buildksh93.ksh "testshell" 2>&1 | tee -a buildlog.log
+
+## Generated binaries and headers can be found in the arch/$(PLATFORM)/
+## subdirectory.
+
+
+# EOF.
diff --git a/usr/src/lib/libshell/misc/filelist.txt b/usr/src/lib/libshell/misc/filelist.txt
new file mode 100644
index 0000000000..c5e55fd4d5
--- /dev/null
+++ b/usr/src/lib/libshell/misc/filelist.txt
@@ -0,0 +1,91 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+#
+# usr/src/lib/libshell/misc/filelist.txt
+# List deleted/moved/etc. files between AT& AST and OS/Net source repositories
+#
+# Format is <keyword> <filename>
+#
+# Currently know keywords are:
+# ON_DELETED = upstream file removed from OS/Net workspace
+#
+ON_DELETED usr/src/cmd/ast/msgcc/Mamfile
+ON_DELETED usr/src/lib/libast/amd64/src/lib/libast/ast.req
+ON_DELETED usr/src/lib/libast/amd64/src/lib/libast/conf
+ON_DELETED usr/src/lib/libast/amd64/src/lib/libast/conflim.h
+ON_DELETED usr/src/lib/libast/common/Makefile
+ON_DELETED usr/src/lib/libast/common/Mamfile
+ON_DELETED usr/src/lib/libast/common/astsa/README
+ON_DELETED usr/src/lib/libast/common/astsa/align.h
+ON_DELETED usr/src/lib/libast/common/astsa/ast.h
+ON_DELETED usr/src/lib/libast/common/astsa/astwinsize.c
+ON_DELETED usr/src/lib/libast/common/astsa/ccode.h
+ON_DELETED usr/src/lib/libast/common/astsa/lclib.h
+ON_DELETED usr/src/lib/libast/common/astsa/sig.h
+ON_DELETED usr/src/lib/libast/common/astsa/strmatch.c
+ON_DELETED usr/src/lib/libast/common/astsa/times.h
+ON_DELETED usr/src/lib/libast/common/comp/fakelink.h
+ON_DELETED usr/src/lib/libast/common/comp/fmtmsg.h
+ON_DELETED usr/src/lib/libast/common/comp/gross_sgi.h
+ON_DELETED usr/src/lib/libast/common/comp/syslog.h
+ON_DELETED usr/src/lib/libast/common/comp/sysloglib.h
+ON_DELETED usr/src/lib/libast/common/dir/dirstd.h
+ON_DELETED usr/src/lib/libast/common/misc/magic.tab
+ON_DELETED usr/src/lib/libast/common/port/atmain.C
+ON_DELETED usr/src/lib/libast/common/uwin/mathimpl.h
+ON_DELETED usr/src/lib/libast/common/uwin/mini.sym
+ON_DELETED usr/src/lib/libast/common/uwin/rlib.h
+ON_DELETED usr/src/lib/libast/i386/src/lib/libast/ast.req
+ON_DELETED usr/src/lib/libast/i386/src/lib/libast/conf
+ON_DELETED usr/src/lib/libast/i386/src/lib/libast/conflim.h
+ON_DELETED usr/src/lib/libast/sparc/src/lib/libast/ast.req
+ON_DELETED usr/src/lib/libast/sparc/src/lib/libast/conf
+ON_DELETED usr/src/lib/libast/sparc/src/lib/libast/conflim.h
+ON_DELETED usr/src/lib/libast/sparcv9/src/lib/libast/ast.req
+ON_DELETED usr/src/lib/libast/sparcv9/src/lib/libast/conf
+ON_DELETED usr/src/lib/libast/sparcv9/src/lib/libast/conflim.h
+ON_DELETED usr/src/lib/libcmd/common/Makefile
+ON_DELETED usr/src/lib/libcmd/common/Mamfile
+ON_DELETED usr/src/lib/libdll/common/Makefile
+ON_DELETED usr/src/lib/libdll/common/Mamfile
+ON_DELETED usr/src/lib/libpp/common/Makefile
+ON_DELETED usr/src/lib/libpp/common/Mamfile
+ON_DELETED usr/src/lib/libpp/common/probe.win32
+ON_DELETED usr/src/lib/libpp/i386/gentab
+ON_DELETED usr/src/lib/libpp/i386/ppkey.yacc
+ON_DELETED usr/src/lib/libpp/i386/probe
+ON_DELETED usr/src/lib/libpp/i386/probe.sh
+ON_DELETED usr/src/lib/libpp/sparc/gentab
+ON_DELETED usr/src/lib/libpp/sparc/ppkey.yacc
+ON_DELETED usr/src/lib/libpp/sparc/probe
+ON_DELETED usr/src/lib/libpp/sparc/probe.sh
+ON_DELETED usr/src/lib/libshell/common/Makefile
+ON_DELETED usr/src/lib/libshell/common/Mamfile
+ON_DELETED usr/src/lib/libshell/common/mamexec
+ON_DELETED usr/src/lib/libshell/common/mamstate.c
+ON_DELETED usr/src/lib/libshell/common/shopen.mk
+# EOF.
diff --git a/usr/src/lib/libshell/sparc/Makefile b/usr/src/lib/libshell/sparc/Makefile
new file mode 100644
index 0000000000..f91f0270e9
--- /dev/null
+++ b/usr/src/lib/libshell/sparc/Makefile
@@ -0,0 +1,30 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/usr/src/lib/libshell/sparc/include/ast/history.h b/usr/src/lib/libshell/sparc/include/ast/history.h
new file mode 100644
index 0000000000..55ead66f9e
--- /dev/null
+++ b/usr/src/lib/libshell/sparc/include/ast/history.h
@@ -0,0 +1,84 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+#ifndef HIST_VERSION
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+/*
+ * Interface for history mechanism
+ * written by David Korn
+ *
+ */
+
+#include <ast.h>
+
+#define HIST_CHAR '!'
+#define HIST_VERSION 1 /* history file format version no. */
+
+typedef struct
+{
+ Sfdisc_t histdisc; /* discipline for history */
+ Sfio_t *histfp; /* history file stream pointer */
+ char *histname; /* name of history file */
+ int32_t histind; /* current command number index */
+ int histsize; /* number of accessible history lines */
+#ifdef _HIST_PRIVATE
+ _HIST_PRIVATE
+#endif /* _HIST_PRIVATE */
+} History_t;
+
+typedef struct
+{
+ int hist_command;
+ int hist_line;
+ int hist_char;
+} Histloc_t;
+
+/* the following are readonly */
+extern __MANGLE__ const char hist_fname[];
+
+extern __MANGLE__ int _Hist;
+#define hist_min(hp) ((_Hist=((int)((hp)->histind-(hp)->histsize)))>=0?_Hist:0)
+#define hist_max(hp) ((int)((hp)->histind))
+/* these are the history interface routines */
+extern __MANGLE__ int sh_histinit __PROTO__((void));
+extern __MANGLE__ void hist_cancel __PROTO__((History_t*));
+extern __MANGLE__ void hist_close __PROTO__((History_t*));
+extern __MANGLE__ int hist_copy __PROTO__((char*, int, int, int));
+extern __MANGLE__ void hist_eof __PROTO__((History_t*));
+extern __MANGLE__ Histloc_t hist_find __PROTO__((History_t*,char*,int, int, int));
+extern __MANGLE__ void hist_flush __PROTO__((History_t*));
+extern __MANGLE__ void hist_list __PROTO__((History_t*,Sfio_t*, off_t, int, char*));
+extern __MANGLE__ int hist_match __PROTO__((History_t*,off_t, char*, int*));
+extern __MANGLE__ off_t hist_tell __PROTO__((History_t*,int));
+extern __MANGLE__ off_t hist_seek __PROTO__((History_t*,int));
+extern __MANGLE__ char *hist_word __PROTO__((char*, int, int));
+#if SHOPT_ESH
+ extern __MANGLE__ Histloc_t hist_locate __PROTO__((History_t*,int, int, int));
+#endif /* SHOPT_ESH */
+
+#endif /* HIST_VERSION */
diff --git a/usr/src/lib/libshell/sparc/include/ast/nval.h b/usr/src/lib/libshell/sparc/include/ast/nval.h
new file mode 100644
index 0000000000..06b18217b7
--- /dev/null
+++ b/usr/src/lib/libshell/sparc/include/ast/nval.h
@@ -0,0 +1,317 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+#ifndef NV_DEFAULT
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * Interface definitions of structures for name-value pairs
+ * These structures are used for named variables, functions and aliases
+ *
+ */
+
+
+#include <ast.h>
+#include <cdt.h>
+
+/* for compatibility with old hash library */
+#define Hashtab_t Dt_t
+#define HASH_BUCKET 1
+#define HASH_NOSCOPE 2
+#define HASH_SCOPE 4
+#define hashscope(x) dtvnext(x)
+
+typedef struct Namval Namval_t;
+typedef struct Namfun Namfun_t;
+typedef struct Namdisc Namdisc_t;
+typedef struct Nambfun Nambfun_t;
+typedef struct Namarray Namarr_t;
+typedef struct Nambltin Nambltin_t;
+typedef struct Namtype Namtype_t;
+
+/*
+ * This defines the template for nodes that have their own assignment
+ * and or lookup functions
+ */
+struct Namdisc
+{
+ size_t dsize;
+ void (*putval) __PROTO__((Namval_t*, const char*, int, Namfun_t*));
+ char *(*getval) __PROTO__((Namval_t*, Namfun_t*));
+ Sfdouble_t (*getnum) __PROTO__((Namval_t*, Namfun_t*));
+ char *(*setdisc) __PROTO__((Namval_t*, const char*, Namval_t*, Namfun_t*));
+ Namval_t *(*createf) __PROTO__((Namval_t*, const char*, int, Namfun_t*));
+ Namfun_t *(*clonef) __PROTO__((Namval_t*, Namval_t*, int, Namfun_t*));
+ char *(*namef) __PROTO__((Namval_t*, Namfun_t*));
+ Namval_t *(*nextf) __PROTO__((Namval_t*, Dt_t*, Namfun_t*));
+ Namval_t *(*typef) __PROTO__((Namval_t*, Namfun_t*));
+ int (*readf) __PROTO__((Namval_t*, Sfio_t*, int, Namfun_t*));
+};
+
+struct Namfun
+{
+ const Namdisc_t *disc;
+ char nofree;
+ char funs;
+ unsigned short dsize;
+ Namfun_t *next;
+ char *last;
+ Namval_t *type;
+};
+
+struct Nambfun
+{
+ Namfun_t fun;
+ int num;
+ const char **bnames;
+ Namval_t *bltins[1];
+};
+
+/* This is an array template header */
+struct Namarray
+{
+ Namfun_t hdr;
+ long nelem; /* number of elements */
+ __V_ *(*fun) __PROTO__((Namval_t*,const char*,int)); /* associative arrays */
+ Namval_t *parent; /* for multi-dimensional */
+};
+
+/* Passed as third argument to a builtin when NV_BLTINOPT is set on node */
+struct Nambltin
+{
+ __V_ *shp;
+ Namval_t *np;
+ __V_ *ptr;
+ __V_ *data;
+ int flags;
+};
+
+struct Namtype
+{
+ __V_ *shp;
+ Namval_t *np;
+ const char *optstring;
+ __V_ *optinfof;
+};
+
+/* attributes of name-value node attribute flags */
+
+#define NV_DEFAULT 0
+/* This defines the attributes for an attributed name-value pair node */
+struct Namval
+{
+ Dtlink_t nvlink; /* space for cdt links */
+ char *nvname; /* pointer to name of the node */
+ unsigned short nvflag; /* attributes */
+ unsigned short nvsize; /* size or base */
+#ifdef _NV_PRIVATE
+ _NV_PRIVATE
+#else
+ Namfun_t *nvfun;
+ char *nvalue;
+ char *nvprivate;
+#endif /* _NV_PRIVATE */
+};
+
+#define NV_CLASS ".sh.type"
+#define NV_MINSZ (sizeof(struct Namval)-sizeof(Dtlink_t)-sizeof(char*))
+#define nv_namptr(p,n) ((Namval_t*)((char*)(p)+(n)*NV_MINSZ-sizeof(Dtlink_t)))
+
+/* The following attributes are for internal use */
+#define NV_NOFREE 0x200 /* don't free the space when releasing value */
+#define NV_ARRAY 0x400 /* node is an array */
+#define NV_REF 0x4000 /* reference bit */
+#define NV_TABLE 0x800 /* node is a dictionary table */
+#define NV_IMPORT 0x1000 /* value imported from environment */
+#define NV_MINIMAL NV_IMPORT /* node does not contain all fields */
+
+#define NV_INTEGER 0x2 /* integer attribute */
+/* The following attributes are valid only when NV_INTEGER is off */
+#define NV_LTOU 0x4 /* convert to uppercase */
+#define NV_UTOL 0x8 /* convert to lowercase */
+#define NV_ZFILL 0x10 /* right justify and fill with leading zeros */
+#define NV_RJUST 0x20 /* right justify and blank fill */
+#define NV_LJUST 0x40 /* left justify and blank fill */
+#define NV_BINARY 0x100 /* fixed size data buffer */
+#define NV_RAW NV_LJUST /* used only with NV_BINARY */
+#define NV_HOST (NV_RJUST|NV_LJUST) /* map to host filename */
+
+/* The following attributes do not effect the value */
+#define NV_RDONLY 0x1 /* readonly bit */
+#define NV_EXPORT 0x2000 /* export bit */
+#define NV_TAGGED 0x8000 /* user define tag bit */
+
+/* The following are used with NV_INTEGER */
+#define NV_SHORT (NV_RJUST) /* when integers are not long */
+#define NV_LONG (NV_UTOL) /* for long long and long double */
+#define NV_UNSIGN (NV_LTOU) /* for unsigned quantities */
+#define NV_DOUBLE (NV_ZFILL) /* for floating point */
+#define NV_EXPNOTE (NV_LJUST) /* for scientific notation */
+
+/* options for nv_open */
+
+#define NV_APPEND 0x10000 /* append value */
+#define NV_MOVE 0x20000 /* for use with nv_clone */
+#define NV_ADD 8
+ /* add node if not found */
+#define NV_ASSIGN NV_NOFREE /* assignment is possible */
+#define NV_NOASSIGN 0 /* backward compatibility */
+#define NV_NOARRAY 0x200000 /* array name not possible */
+#define NV_IARRAY 0x400000 /* for indexed array */
+#define NV_NOREF NV_REF /* don't follow reference */
+#define NV_IDENT 0x80 /* name must be identifier */
+#define NV_VARNAME 0x20000 /* name must be ?(.)id*(.id) */
+#define NV_NOADD 0x40000 /* do not add node */
+#define NV_NOSCOPE 0x80000 /* look only in current scope */
+#define NV_NOFAIL 0x100000 /* return 0 on failure, no msg */
+#define NV_NODISC NV_IDENT /* ignore disciplines */
+
+#define NV_FUNCT NV_IDENT /* option for nv_create */
+#define NV_BLTINOPT NV_ZFILL /* save state for optimization*/
+
+#define NV_PUBLIC (~(NV_NOSCOPE|NV_ASSIGN|NV_IDENT|NV_VARNAME|NV_NOADD))
+
+/* numeric types */
+#define NV_INT16 (NV_SHORT|NV_INTEGER)
+#define NV_UINT16 (NV_UNSIGN|NV_SHORT|NV_INTEGER)
+#define NV_INT32 (NV_INTEGER)
+#define NV_UNT32 (NV_UNSIGN|NV_INTEGER)
+#define NV_INT64 (NV_LONG|NV_INTEGER)
+#define NV_UINT64 (NV_UNSIGN|NV_LONG|NV_INTEGER)
+#define NV_FLOAT (NV_SHORT|NV_DOUBLE|NV_INTEGER)
+#define NV_LDOUBLE (NV_LONG|NV_DOUBLE|NV_INTEGER)
+
+/* name-value pair macros */
+#define nv_isattr(np,f) ((np)->nvflag & (f))
+#define nv_onattr(n,f) ((n)->nvflag |= (f))
+#define nv_offattr(n,f) ((n)->nvflag &= ~(f))
+#define nv_isarray(np) (nv_isattr((np),NV_ARRAY))
+
+/* The following are operations for associative arrays */
+#define NV_AINIT 1 /* initialize */
+#define NV_AFREE 2 /* free array */
+#define NV_ANEXT 3 /* advance to next subscript */
+#define NV_ANAME 4 /* return subscript name */
+#define NV_ADELETE 5 /* delete current subscript */
+#define NV_AADD 6 /* add subscript if not found */
+#define NV_ACURRENT 7 /* return current subscript Namval_t* */
+
+/* The following are for nv_disc */
+#define NV_FIRST 1
+#define NV_LAST 2
+#define NV_POP 3
+#define NV_CLONE 4
+
+/* The following are operations for nv_putsub() */
+#define ARRAY_BITS 24
+#define ARRAY_ADD (1L<<ARRAY_BITS) /* add subscript if not found */
+#define ARRAY_SCAN (2L<<ARRAY_BITS) /* For ${array[@]} */
+#define ARRAY_UNDEF (4L<<ARRAY_BITS) /* For ${array} */
+
+
+/* These are disciplines provided by the library for use with nv_discfun */
+#define NV_DCADD 0 /* used to add named disciplines */
+#define NV_DCRESTRICT 1 /* variable that are restricted in rsh */
+
+#if defined(__EXPORT__) && defined(_DLL)
+# ifdef _BLD_shell
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+# else
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+# endif /* _BLD_shell */
+#endif /* _DLL */
+/* prototype for array interface*/
+extern __MANGLE__ Namarr_t *nv_setarray __PROTO__((Namval_t*,__V_*(*)(Namval_t*,const char*,int)));
+extern __MANGLE__ __V_ *nv_associative __PROTO__((Namval_t*,const char*,int));
+extern __MANGLE__ int nv_aindex __PROTO__((Namval_t*));
+extern __MANGLE__ int nv_nextsub __PROTO__((Namval_t*));
+extern __MANGLE__ char *nv_getsub __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_putsub __PROTO__((Namval_t*, char*, long));
+extern __MANGLE__ Namval_t *nv_opensub __PROTO__((Namval_t*));
+
+/* name-value pair function prototypes */
+extern __MANGLE__ int nv_adddisc __PROTO__((Namval_t*, const char**, Namval_t**));
+extern __MANGLE__ int nv_clone __PROTO__((Namval_t*, Namval_t*, int));
+extern __MANGLE__ void nv_close __PROTO__((Namval_t*));
+extern __MANGLE__ __V_ *nv_context __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_create __PROTO__((const char*, Dt_t*, int,Namfun_t*));
+extern __MANGLE__ Dt_t *nv_dict __PROTO__((Namval_t*));
+extern __MANGLE__ Sfdouble_t nv_getn __PROTO__((Namval_t*, Namfun_t*));
+extern __MANGLE__ Sfdouble_t nv_getnum __PROTO__((Namval_t*));
+extern __MANGLE__ char *nv_getv __PROTO__((Namval_t*, Namfun_t*));
+extern __MANGLE__ char *nv_getval __PROTO__((Namval_t*));
+extern __MANGLE__ Namfun_t *nv_hasdisc __PROTO__((Namval_t*, const Namdisc_t*));
+extern __MANGLE__ int nv_isnull __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_lastdict __PROTO__((void));
+extern __MANGLE__ void nv_newattr __PROTO__((Namval_t*,unsigned,int));
+extern __MANGLE__ Namval_t *nv_open __PROTO__((const char*,Dt_t*,int));
+extern __MANGLE__ void nv_putval __PROTO__((Namval_t*,const char*,int));
+extern __MANGLE__ void nv_putv __PROTO__((Namval_t*,const char*,int,Namfun_t*));
+extern __MANGLE__ int nv_scan __PROTO__((Dt_t*,void(*)(Namval_t*,__V_*),__V_*,int,int));
+extern __MANGLE__ Namval_t *nv_scoped __PROTO__((Namval_t*));
+extern __MANGLE__ char *nv_setdisc __PROTO__((Namval_t*,const char*,Namval_t*,Namfun_t*));
+extern __MANGLE__ void nv_setref __PROTO__((Namval_t*, Dt_t*,int));
+extern __MANGLE__ int nv_settype __PROTO__((Namval_t*, Namval_t*, int));
+extern __MANGLE__ void nv_setvec __PROTO__((Namval_t*,int,int,char*[]));
+extern __MANGLE__ void nv_setvtree __PROTO__((Namval_t*));
+extern __MANGLE__ int nv_setsize __PROTO__((Namval_t*,int));
+extern __MANGLE__ Namfun_t *nv_disc __PROTO__((Namval_t*,Namfun_t*,int));
+extern __MANGLE__ void nv_unset __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_search __PROTO__((const char *, Dt_t*, int));
+extern __MANGLE__ void nv_unscope __PROTO__((void));
+extern __MANGLE__ char *nv_name __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_type __PROTO__((Namval_t*));
+extern __MANGLE__ const Namdisc_t *nv_discfun __PROTO__((int));
+
+#ifdef _DLL
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif /* _DLL */
+
+#define nv_size(np) nv_setsize((np),-1)
+#define nv_stack(np,nf) nv_disc(np,nf,0)
+
+#if 0
+/*
+ * The names of many functions were changed in early '95
+ * Here is a mapping to the old names
+ */
+# define nv_istype(np) nv_isattr(np)
+# define nv_newtype(np) nv_newattr(np)
+# define nv_namset(np,a,b) nv_open(np,a,b)
+# define nv_free(np) nv_unset(np)
+# define nv_settype(np,a,b,c) nv_setdisc(np,a,b,c)
+# define nv_search(np,a,b) nv_open(np,a,((b)?0:NV_NOADD))
+# define settype setdisc
+#endif
+
+#endif /* NV_DEFAULT */
diff --git a/usr/src/lib/libshell/sparc/include/ast/shell.h b/usr/src/lib/libshell/sparc/include/ast/shell.h
new file mode 100644
index 0000000000..37cafa932b
--- /dev/null
+++ b/usr/src/lib/libshell/sparc/include/ast/shell.h
@@ -0,0 +1,256 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+#ifndef SH_INTERACTIVE
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * Interface definitions for shell command language
+ *
+ */
+
+#include <cmd.h>
+#include <cdt.h>
+#ifdef _SH_PRIVATE
+# include "name.h"
+#else
+# include <nval.h>
+#endif /* _SH_PRIVATE */
+
+#define SH_VERSION 20060510
+
+#undef NOT_USED
+#define NOT_USED(x) (&x,1)
+
+/* options */
+typedef struct
+{
+ unsigned long v[4];
+}
+Shopt_t;
+
+typedef void (*Shinit_f) __PROTO__((int));
+typedef int (*Shbltin_f) __PROTO__((int, char*[], __V_*));
+typedef int (*Shwait_f) __PROTO__((int, long, int));
+
+union Shnode_u;
+typedef union Shnode_u Shnode_t;
+
+#define SH_CFLAG 0
+#define SH_HISTORY 1 /* used also as a state */
+#define SH_ERREXIT 2 /* used also as a state */
+#define SH_VERBOSE 3 /* used also as a state */
+#define SH_MONITOR 4 /* used also as a state */
+#define SH_INTERACTIVE 5 /* used also as a state */
+#define SH_RESTRICTED 6
+#define SH_XTRACE 7
+#define SH_KEYWORD 8
+#define SH_NOUNSET 9
+#define SH_NOGLOB 10
+#define SH_ALLEXPORT 11
+#define SH_PFSH 12
+#define SH_IGNOREEOF 13
+#define SH_NOCLOBBER 14
+#define SH_MARKDIRS 15
+#define SH_BGNICE 16
+#define SH_VI 17
+#define SH_VIRAW 18
+#define SH_TFLAG 19
+#define SH_TRACKALL 20
+#define SH_SFLAG 21
+#define SH_NOEXEC 22
+#define SH_GMACS 24
+#define SH_EMACS 25
+#define SH_PRIVILEGED 26
+#define SH_SUBSHARE 27 /* subshell shares state with parent */
+#define SH_NOLOG 28
+#define SH_NOTIFY 29
+#define SH_DICTIONARY 30
+#define SH_PIPEFAIL 32
+#define SH_GLOBSTARS 33
+#define SH_XARGS 34
+#define SH_RC 35
+#define SH_SHOWME 36
+
+/*
+ * passed as flags to builtins in Nambltin_t struct when BLT_OPTIM is on
+ */
+#define SH_BEGIN_OPTIM 0x1
+#define SH_END_OPTIM 0x2
+
+/* The following type is used for error messages */
+
+/* error messages */
+extern __MANGLE__ const char e_defpath[];
+extern __MANGLE__ const char e_found[];
+extern __MANGLE__ const char e_nospace[];
+extern __MANGLE__ const char e_format[];
+extern __MANGLE__ const char e_number[];
+extern __MANGLE__ const char e_restricted[];
+extern __MANGLE__ const char e_recursive[];
+extern __MANGLE__ char e_version[];
+
+typedef struct sh_scope
+{
+ struct sh_scope *par_scope;
+ int argc;
+ char **argv;
+ char *cmdname;
+ char *filename;
+ int lineno;
+ Dt_t *var_tree;
+ struct sh_scope *self;
+} Shscope_t;
+
+/*
+ * Saves the state of the shell
+ */
+
+typedef struct sh_static
+{
+ Shopt_t options; /* set -o options */
+ Dt_t *var_tree; /* for shell variables */
+ Dt_t *fun_tree; /* for shell functions */
+ Dt_t *alias_tree; /* for alias names */
+ Dt_t *bltin_tree; /* for builtin commands */
+ Shscope_t *topscope; /* pointer to top-level scope */
+ int inlineno; /* line number of current input file */
+ int exitval; /* most recent exit value */
+ unsigned char trapnote; /* set when trap/signal is pending */
+ char subshell; /* set for virtual subshell */
+#ifdef _SH_PRIVATE
+ _SH_PRIVATE
+#endif /* _SH_PRIVATE */
+} Shell_t;
+
+/* flags for sh_parse */
+#define SH_NL 1 /* Treat new-lines as ; */
+#define SH_EOF 2 /* EOF causes syntax error */
+
+/* symbolic values for sh_iogetiop */
+#define SH_IOCOPROCESS (-2)
+#define SH_IOHISTFILE (-3)
+
+/* symbolic value for sh_fdnotify */
+#define SH_FDCLOSE (-1)
+
+#if defined(__EXPORT__) && defined(_DLL)
+# ifdef _BLD_shell
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+# endif /* _BLD_shell */
+#endif /* _DLL */
+
+extern __MANGLE__ Dt_t *sh_bltin_tree __PROTO__((void));
+extern __MANGLE__ void sh_subfork __PROTO__((void));
+extern __MANGLE__ Shell_t *sh_init __PROTO__((int,char*[],Shinit_f));
+extern __MANGLE__ int sh_reinit __PROTO__((char*[]));
+extern __MANGLE__ int sh_eval __PROTO__((Sfio_t*,int));
+extern __MANGLE__ void sh_delay __PROTO__((double));
+extern __MANGLE__ __V_ *sh_parse __PROTO__((Shell_t*, Sfio_t*,int));
+extern __MANGLE__ int sh_trap __PROTO__((const char*,int));
+extern __MANGLE__ int sh_fun __PROTO__((Namval_t*,Namval_t*, char*[]));
+extern __MANGLE__ int sh_funscope __PROTO__((int,char*[],int(*)(__V_*),__V_*,int));
+extern __MANGLE__ Sfio_t *sh_iogetiop __PROTO__((int,int));
+extern __MANGLE__ int sh_main __PROTO__((int, char*[], void(*)(int)));
+extern __MANGLE__ void sh_menu __PROTO__((Sfio_t*, int, char*[]));
+extern __MANGLE__ Namval_t *sh_addbuiltin __PROTO__((const char*, int(*)(int, char*[],__V_*), __V_*));
+extern __MANGLE__ char *sh_fmtq __PROTO__((const char*));
+extern __MANGLE__ char *sh_fmtqf __PROTO__((const char*, int, int));
+extern __MANGLE__ Sfdouble_t sh_strnum __PROTO__((const char*, char**, int));
+extern __MANGLE__ int sh_access __PROTO__((const char*,int));
+extern __MANGLE__ int sh_close __PROTO__((int));
+extern __MANGLE__ int sh_dup __PROTO__((int));
+extern __MANGLE__ void sh_exit __PROTO__((int));
+extern __MANGLE__ int sh_fcntl __PROTO__((int, int, ...));
+extern __MANGLE__ Sfio_t *sh_fd2sfio __PROTO__((int));
+extern __MANGLE__ int (*sh_fdnotify __PROTO__((int(*)(int,int)))) __PROTO__((int,int));
+extern __MANGLE__ Shell_t *sh_getinterp __PROTO__((void));
+extern __MANGLE__ int sh_open __PROTO__((const char*, int, ...));
+extern __MANGLE__ int sh_openmax __PROTO__((void));
+extern __MANGLE__ Sfio_t *sh_pathopen __PROTO__((const char*));
+extern __MANGLE__ ssize_t sh_read __PROTO__((int, __V_*, size_t));
+extern __MANGLE__ ssize_t sh_write __PROTO__((int, const __V_*, size_t));
+extern __MANGLE__ off_t sh_seek __PROTO__((int, off_t, int));
+extern __MANGLE__ int sh_pipe __PROTO__((int[]));
+extern __MANGLE__ mode_t sh_umask __PROTO__((mode_t));
+extern __MANGLE__ __V_ *sh_waitnotify __PROTO__((Shwait_f));
+extern __MANGLE__ Shscope_t *sh_getscope __PROTO__((int,int));
+extern __MANGLE__ Shscope_t *sh_setscope __PROTO__((Shscope_t*));
+extern __MANGLE__ void sh_sigcheck __PROTO__((void));
+extern __MANGLE__ unsigned long sh_isoption __PROTO__((int));
+extern __MANGLE__ unsigned long sh_onoption __PROTO__((int));
+extern __MANGLE__ unsigned long sh_offoption __PROTO__((int));
+extern __MANGLE__ int sh_waitsafe __PROTO__((void));
+extern __MANGLE__ int sh_exec __PROTO__((const Shnode_t*,int));
+
+#if SHOPT_DYNAMIC
+ extern __MANGLE__ __V_ **sh_getliblist __PROTO__((void));
+#endif /* SHOPT_DYNAMIC */
+
+/*
+ * direct access to sh is obsolete, use sh_getinterp() instead
+ */
+#if !defined(_SH_PRIVATE) && defined(__IMPORT__) && !defined(_BLD_shell)
+ extern __MANGLE__ __IMPORT__ Shell_t sh;
+#else
+ extern __MANGLE__ Shell_t sh;
+#endif
+
+#ifdef _DLL
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif /* _DLL */
+
+#ifndef _SH_PRIVATE
+# define access(a,b) sh_access(a,b)
+# define close(a) sh_close(a)
+# define exit(a) sh_exit(a)
+# define fcntl(a,b,c) sh_fcntl(a,b,c)
+# define pipe(a) sh_pipe(a)
+# define read(a,b,c) sh_read(a,b,c)
+# define write(a,b,c) sh_write(a,b,c)
+# define umask(a) sh_umask(a)
+# define dup sh_dup
+# if _lib_lseek64
+# define open64 sh_open
+# define lseek64 sh_seek
+# else
+# define open sh_open
+# define lseek sh_seek
+# endif
+#endif /* !_SH_PRIVATE */
+
+#define SH_SIGSET 4
+#define SH_EXITSIG 0400 /* signal exit bit */
+#define SH_EXITMASK (SH_EXITSIG-1) /* normal exit status bits */
+#define SH_RUNPROG -1022 /* needs to be negative and < 256 */
+
+#endif /* SH_INTERACTIVE */
diff --git a/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/acct b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/acct
new file mode 100644
index 0000000000..3224ea4e85
--- /dev/null
+++ b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/acct
@@ -0,0 +1,12 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_acct_ksh93
+#define _def_acct_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _lib_acct 1 /* acct() in default lib(s) */
+#define _sys_acct 1 /* #include <sys/acct.h> ok */
+#endif
diff --git a/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/cmds b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/cmds
new file mode 100644
index 0000000000..eb6f529a3d
--- /dev/null
+++ b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/cmds
@@ -0,0 +1,36 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/cmd/ksh93/features/cmds by iffe version 2007-04-04 : : */
+#ifndef _def_cmds_ksh93
+#define _def_cmds_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _cmd_newgrp 1 /* newgrp in ?(/usr)/(bin|etc|ucb) */
+#define _bin_newgrp 1 /* /bin/newgrp found */
+#define _usr_bin_newgrp 1 /* /usr/bin/newgrp found */
+#define _cmd_test 1 /* test in ?(/usr)/(bin|etc|ucb) */
+#define _bin_test 1 /* /bin/test found */
+#define _usr_bin_test 1 /* /usr/bin/test found */
+#define _usr_ucb_test 1 /* /usr/ucb/test found */
+#define _cmd_id 1 /* id in ?(/usr)/(bin|etc|ucb) */
+#define _bin_id 1 /* /bin/id found */
+#define _usr_bin_id 1 /* /usr/bin/id found */
+#define _cmd_wc 1 /* wc in ?(/usr)/(bin|etc|ucb) */
+#define _bin_wc 1 /* /bin/wc found */
+#define _usr_bin_wc 1 /* /usr/bin/wc found */
+#define _usr_ucb_wc 1 /* /usr/ucb/wc found */
+#define _cmd_cut 1 /* cut in ?(/usr)/(bin|etc|ucb) */
+#define _bin_cut 1 /* /bin/cut found */
+#define _usr_bin_cut 1 /* /usr/bin/cut found */
+#define _cmd_logname 1 /* logname in ?(/usr)/(bin|etc|ucb) */
+#define _bin_logname 1 /* /bin/logname found */
+#define _usr_bin_logname 1 /* /usr/bin/logname found */
+#define _cmd_pfexec 1 /* pfexec in ?(/usr)/(bin|etc|ucb) */
+#define _bin_pfexec 1 /* /bin/pfexec found */
+#define _usr_bin_pfexec 1 /* /usr/bin/pfexec found */
+#define _cmd_tput 1 /* tput in ?(/usr)/(bin|etc|ucb) */
+#define _bin_tput 1 /* /bin/tput found */
+#define _usr_bin_tput 1 /* /usr/bin/tput found */
+#endif
diff --git a/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/dynamic b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/dynamic
new file mode 100644
index 0000000000..5bc10f4878
--- /dev/null
+++ b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/dynamic
@@ -0,0 +1,23 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/cmd/ksh93/features/dynamic by iffe version 2007-04-04 : : */
+#ifndef _def_dynamic_ksh93
+#define _def_dynamic_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_dlfcn 1 /* #include <dlfcn.h> ok */
+#define _sys_dl 1 /* #include <sys/dl.h> ok */
+#define _hdr_dlldefs 1 /* #include <dlldefs.h> ok */
+#define _lib_dlopen 1 /* dlopen() in default lib(s) */
+#define _lib_dllfind 1 /* dllfind() in default lib(s) */
+#if !defined(SHOPT_FS_3D) && ( _lib_dllfind || _lib_dlopen || _lib_shl_load || _lib_loadbind )
+# define SHOPT_FS_3D 1
+#endif /* !SHOPT_FS_3D */
+#if SHOPT_FS_3D
+# undef mount
+# include <fs3d.h>
+#endif /* SHOPT_FS_3D */
+
+#endif
diff --git a/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/execargs b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/execargs
new file mode 100644
index 0000000000..bcb8d730d9
--- /dev/null
+++ b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/execargs
@@ -0,0 +1,10 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_execargs_ksh93
+#define _def_execargs_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#endif
diff --git a/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/externs b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/externs
new file mode 100644
index 0000000000..989fc9ca71
--- /dev/null
+++ b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/externs
@@ -0,0 +1,81 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/cmd/ksh93/features/externs by iffe version 2007-04-04 : : */
+
+#ifndef _def_externs_ksh93
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_externs_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_exec_attr 1 /* #include <exec_attr.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _mem_name_exception 1 /* name is a member of struct exception */
+#define _lib_setreuid 1 /* setreuid() in default lib(s) */
+#define _lib_setregid 1 /* setregid() in default lib(s) */
+#define _lib_nice 1 /* nice() in default lib(s) */
+#define _lib_sigflag 1 /* sigflag() in default lib(s) */
+#define _lib_fork 1 /* fork() in default lib(s) */
+#define _lib_spawnveg 1 /* spawnveg() in default lib(s) */
+#define _lib_fchdir 1 /* fchdir() in default lib(s) */
+#endif
diff --git a/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/locale b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/locale
new file mode 100644
index 0000000000..787bb2740e
--- /dev/null
+++ b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/locale
@@ -0,0 +1,38 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/cmd/ksh93/features/locale by iffe version 2007-04-04 : : */
+#ifndef _def_locale_ksh93
+#define _def_locale_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_locale 1 /* #include <locale.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _lib_localeconv 1 /* localeconv() in default lib(s) */
+#define _lib_wctype 1 /* wctype() in default lib(s) */
+#define _lib_iswctype 1 /* iswctype() in default lib(s) */
+#define _lib_iswblank 1 /* iswblank() in default lib(s) */
+#if _PACKAGE_ast
+# undef _hdr_locale
+# define _hdr_locale 1
+#else
+# ifdef _hdr_locale
+# include <locale.h>
+# ifndef LC_MESSAGES
+# define LC_MESSAGES LC_ALL
+# endif /* LC_MESSAGES */
+# endif /* _hdr_locale */
+#endif /* _PACKAGE_ast */
+#ifdef _hdr_locale
+# ifdef _lib_localeconv
+ static struct lconv *lp;
+# define GETDECIMAL(x) (((lp=localeconv()) && lp->decimal_point && *lp->decimal_point) ? *lp->decimal_point : '.' )
+# else
+# define GETDECIMAL(x) ('.')
+# endif /* _lib_localeconv */
+#else
+# define GETDECIMAL(x) ('.')
+#endif /* _hdr_locale */
+
+#endif
diff --git a/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/math b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/math
new file mode 100644
index 0000000000..44f582aa7a
--- /dev/null
+++ b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/math
@@ -0,0 +1,162 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/cmd/ksh93/features/math.sh by iffe version 2007-04-04 : : */
+#ifndef _def_math_ksh93
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_math_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+
+
+/* : : generated by iffe from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/cmd/ksh93/data/math.tab : : */
+
+typedef Sfdouble_t (*Math_f) __PROTO__((Sfdouble_t,...));
+
+#include <ast_standards.h>
+#include <math.h>
+#include <ieeefp.h>
+
+static Sfdouble_t local_finite __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return finite(a1);}
+static int local_fpclassify __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return fpclassify(a1);}
+static int local_isfinite __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return isfinite(a1);}
+static int local_isgreater __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return isgreater(a1,a2);}
+static int local_isgreaterequal __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return isgreaterequal(a1,a2);}
+static int local_isinf __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return isinf(a1);}
+static int local_isless __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return isless(a1,a2);}
+static int local_islessequal __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return islessequal(a1,a2);}
+static int local_islessgreater __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return islessgreater(a1,a2);}
+static int local_isnormal __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return isnormal(a1);}
+static int local_isunordered __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return isunordered(a1,a2);}
+static int local_signbit __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return signbit(a1);}
+
+/*
+ * first byte is two-digit octal number. Last digit is number of args
+ * first digit is 0 if return value is double, 1 for integer
+ */
+const struct mathtab shtab_math[] =
+{
+ "\001acos", (Math_f)acosl,
+ "\001acosh", (Math_f)acoshl,
+ "\001asin", (Math_f)asinl,
+ "\001asinh", (Math_f)asinhl,
+ "\001atan", (Math_f)atanl,
+ "\002atan2", (Math_f)atan2l,
+ "\001atanh", (Math_f)atanhl,
+ "\001cbrt", (Math_f)cbrtl,
+ "\002copysign", (Math_f)copysignl,
+ "\001cos", (Math_f)cosl,
+ "\001cosh", (Math_f)coshl,
+ "\001erf", (Math_f)erfl,
+ "\001erfc", (Math_f)erfcl,
+ "\001exp", (Math_f)expl,
+ "\001exp2", (Math_f)exp2l,
+ "\001expm1", (Math_f)expm1l,
+ "\001fabs", (Math_f)fabsl,
+ "\001abs", (Math_f)fabsl,
+ "\002fdim", (Math_f)fdiml,
+ "\001finite", (Math_f)local_finite,
+ "\001floor", (Math_f)floorl,
+ "\001int", (Math_f)floorl,
+ "\003fma", (Math_f)fmal,
+ "\002fmax", (Math_f)fmaxl,
+ "\002fmin", (Math_f)fminl,
+ "\002fmod", (Math_f)fmodl,
+ "\011fpclassify", (Math_f)local_fpclassify,
+ "\002hypot", (Math_f)hypotl,
+ "\011ilogb", (Math_f)ilogbl,
+ "\011isfinite", (Math_f)local_isfinite,
+ "\012isgreater", (Math_f)local_isgreater,
+ "\012isgreaterequal", (Math_f)local_isgreaterequal,
+ "\011isinf", (Math_f)local_isinf,
+ "\012isless", (Math_f)local_isless,
+ "\012islessequal", (Math_f)local_islessequal,
+ "\012islessgreater", (Math_f)local_islessgreater,
+ "\011isnan", (Math_f)isnanl,
+ "\011isnormal", (Math_f)local_isnormal,
+ "\012isunordered", (Math_f)local_isunordered,
+ "\001lgamma", (Math_f)lgammal,
+ "\001log", (Math_f)logl,
+ "\001log1p", (Math_f)log1pl,
+ "\001log2", (Math_f)log2l,
+ "\001logb", (Math_f)logbl,
+ "\001nearbyint", (Math_f)nearbyintl,
+ "\002nextafter", (Math_f)nextafterl,
+ "\002nexttoward", (Math_f)nexttowardl,
+ "\002pow", (Math_f)powl,
+ "\002remainder", (Math_f)remainderl,
+ "\001rint", (Math_f)rintl,
+ "\001round", (Math_f)roundl,
+ "\002scalb", (Math_f)scalbl,
+ "\002scalbn", (Math_f)scalbnl,
+ "\011signbit", (Math_f)local_signbit,
+ "\001sin", (Math_f)sinl,
+ "\001sinh", (Math_f)sinhl,
+ "\001sqrt", (Math_f)sqrtl,
+ "\001tan", (Math_f)tanl,
+ "\001tanh", (Math_f)tanhl,
+ "\001tgamma", (Math_f)tgammal,
+ "\001trunc", (Math_f)truncl,
+ "", (Math_f)0
+};
+#endif
diff --git a/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/options b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/options
new file mode 100644
index 0000000000..2ef857884d
--- /dev/null
+++ b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/options
@@ -0,0 +1,26 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/cmd/ksh93/features/options by iffe version 2007-04-04 : : */
+#ifndef _def_options_ksh93
+#define _def_options_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define SHELLMAGIC 1
+#ifndef SHOPT_DEVFD
+# define SHOPT_DEVFD 1
+#endif
+#ifndef SHOPT_PFSH
+# define SHOPT_PFSH 1
+#endif
+#undef SHOPT_TEST_L
+#ifndef SHOPT_SYSRC
+# define SHOPT_SYSRC 1
+#endif
+#undef SHOPT_UCB
+#if !_PACKAGE_ast && ( (MB_LEN_MAX-1)<=0 || !defined(_lib_mbtowc) )
+# undef SHOPT_MULTIBYTE
+#endif
+
+#endif
diff --git a/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/poll b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/poll
new file mode 100644
index 0000000000..35c699486f
--- /dev/null
+++ b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/poll
@@ -0,0 +1,119 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/cmd/ksh93/features/poll by iffe version 2007-04-04 : : */
+#ifndef _def_poll_ksh93
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_poll_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_poll 1 /* #include <poll.h> ok */
+#define _hdr_netinet_in 1 /* #include <netinet/in.h> ok */
+#define _sys_poll 1 /* #include <sys/poll.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _lib_select 1 /* select() in default lib(s) */
+#define _lib_poll 1 /* poll() in default lib(s) */
+#define _lib_socket 1 /* socket() in default lib(s) */
+#define _lib_htons 1 /* htons() in default lib(s) */
+#define _lib_htonl 1 /* htonl() in default lib(s) */
+#define _hdr_netdb 1 /* #include <netdb.h> ok */
+#define _lib_getaddrinfo 1 /* getaddrinfo() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _sys_select 1 /* #include <sys/select.h> ok */
+#define _typ_fd_set 1 /* fd_set is a type */
+#define _socketpair_devfd 1 /* /dev/fd/N handles socketpair() */
+
+#ifdef _lib_poll
+# define poll _SYS_poll
+#else
+# undef _hdr_poll
+# undef _sys_poll
+#endif /* _lib_poll */
+#ifdef _hdr_poll
+# include <poll.h>
+#else
+# ifdef _sys_poll
+# include <sys/poll.h>
+# endif /* _sys_poll */
+#endif /* _hdr_poll */
+#ifdef _lib_poll
+# undef poll
+ extern __MANGLE__ int poll __PROTO__((struct pollfd*,unsigned long,int));
+#endif /* _lib_poll */
+#ifdef _lib_select
+# ifndef FD_ZERO
+# define FD_ZERO(x) (*(x)=0)
+# endif /* FD_ZERO */
+# ifndef FD_SET
+# define FD_SET(n,x) (*(x)|=(1L<<(n)))
+# endif /* FD_SET */
+# ifndef _typ_fd_set
+ typedef long fd_set;
+# endif /*_typ_fd_set */
+#endif /* _lib_select */
+
+#endif
diff --git a/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/pstat b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/pstat
new file mode 100644
index 0000000000..ce6e94896f
--- /dev/null
+++ b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/pstat
@@ -0,0 +1,10 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_pstat_ksh93
+#define _def_pstat_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#endif
diff --git a/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/rlimits b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/rlimits
new file mode 100644
index 0000000000..41eb6091a6
--- /dev/null
+++ b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/rlimits
@@ -0,0 +1,19 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/cmd/ksh93/features/rlimits by iffe version 2007-04-04 : : */
+#ifndef _def_rlimits_ksh93
+#define _def_rlimits_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _sys_resource 1 /* #include <sys/resource.h> ok */
+#define _lib_getrlimit 1 /* getrlimit() in default lib(s) */
+#define _lib_ulimit 1 /* ulimit() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_rlim_t 1 /* rlim_t is a type */
+#endif
diff --git a/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/setjmp b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/setjmp
new file mode 100644
index 0000000000..76daa91aca
--- /dev/null
+++ b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/setjmp
@@ -0,0 +1,35 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/cmd/ksh93/features/setjmp by iffe version 2007-04-04 : : */
+#ifndef _def_setjmp_ksh93
+#define _def_setjmp_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _lib_sigsetjmp 1 /* sigsetjmp() in default lib(s) */
+#define _lib__setjmp 1 /* _setjmp() in default lib(s) */
+#define _lib__longjmp 1 /* _longjmp() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_setjmp 1 /* #include <setjmp.h> ok */
+#define _typ_sigjmp_buf 1 /* sigjmp_buf is a type */
+#undef sigsetjmp
+#undef siglongjmp
+#undef sigjmp_buf
+#define sigjmp_buf jmp_buf
+#ifdef _lib__setjmp
+# define sigsetjmp(a,b) _setjmp(a)
+#else
+# define sigsetjmp(a,b) setjmp(a)
+#endif /* _lib__setjmp */
+#ifdef _lib__longjmp
+# define siglongjmp(a,b) _longjmp(a,b)
+#else
+# define siglongjmp(a,b) longjmp(a,b)
+#endif /* _lib__longjmp */
+
+#endif
diff --git a/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/sigfeatures b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/sigfeatures
new file mode 100644
index 0000000000..b862dffb5e
--- /dev/null
+++ b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/sigfeatures
@@ -0,0 +1,54 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/cmd/ksh93/features/sigfeatures by iffe version 2007-04-04 : : */
+#ifndef _def_sigfeatures_ksh93
+#define _def_sigfeatures_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _lib_sigrelse 1 /* sigrelse() in default lib(s) */
+#define _lib_sigprocmask 1 /* sigprocmask() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_ast 1 /* #include <ast.h> ok */
+#define _hdr_signal 1 /* #include <signal.h> ok */
+#define _typ_sigset_t 1 /* sigset_t is a type */
+#ifndef _mem_sigvec_sv_mask
+# undef _lib_sigvec
+#endif
+#ifdef _lib_sigprocmask
+# define sh_sigaction(s,action) do { sigset_t ss;\
+ sigemptyset(&ss);\
+ sigaddset(&ss,(s));\
+ sigprocmask(action,&ss,0); \
+ }while(0)
+# define sigrelease(s) sh_sigaction(s,SIG_UNBLOCK)
+# define sigblock(s) sh_sigaction(s,SIG_BLOCK)
+# define sig_begin() sh_sigaction(0,SIG_SETMASK)
+#else
+# ifndef _lib_sigblock
+# define sigblock(s)
+# endif
+# ifdef _lib_sigsetmask
+# define sigrelease(s) sigsetmask(0)
+# define sig_begin() sigsetmask(0)
+# else
+# ifdef _lib_sigrelse
+# define sigrelease sigrelse
+# define sig_begin()
+# else
+# define sig_begin() (0)
+# define sigrelease(s) (0)
+# endif /* _lib_sigrelse */
+# endif /* _lib_sigsetmask */
+#endif /* _lib_sigprocmask */
+
+#undef _SIGRTMIN
+#define _SIGRTMIN 41
+#undef _SIGRTMAX
+#define _SIGRTMAX 48
+#endif
diff --git a/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/time b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/time
new file mode 100644
index 0000000000..5117dbe7c8
--- /dev/null
+++ b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/time
@@ -0,0 +1,28 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/cmd/ksh93/features/time by iffe version 2007-04-04 : : */
+#ifndef _def_time_ksh93
+#define _def_time_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_utime 1 /* #include <utime.h> ok */
+#define _lib_gettimeofday 1 /* gettimeofday() in default lib(s) */
+#define _lib_setitimer 1 /* setitimer() in default lib(s) */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _mem_tv_usec_timeval 1 /* tv_usec is a member of struct timeval */
+#define _lib_2_timeofday 1 /* 2 arg gettimeofday() */
+#undef _def_time
+#include <times.h>
+#define _def_time 1
+#undef timeofday
+#if _lib_2_timeofday
+#define timeofday(p) gettimeofday(p,(struct timezone*)0)
+#else
+#if _lib_1_timeofday
+#define timeofday(p) gettimeofday(p)
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/ttys b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/ttys
new file mode 100644
index 0000000000..39d165bbf9
--- /dev/null
+++ b/usr/src/lib/libshell/sparc/src/cmd/ksh93/FEATURE/ttys
@@ -0,0 +1,19 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/src/cmd/ksh93/features/ttys by iffe version 2007-04-04 : : */
+#ifndef _def_ttys_ksh93
+#define _def_ttys_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_32bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_termios 1 /* #include <termios.h> ok */
+#define _hdr_termio 1 /* #include <termio.h> ok */
+#define _hdr_sgtty 1 /* #include <sgtty.h> ok */
+#define _sys_termios 1 /* #include <sys/termios.h> ok */
+#define _sys_termio 1 /* #include <sys/termio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _lib_tcgetattr 1 /* tcgetattr() in default lib(s) */
+#define _lib_tcgetpgrp 1 /* tcgetpgrp() in default lib(s) */
+#endif
diff --git a/usr/src/lib/libshell/sparcv9/Makefile b/usr/src/lib/libshell/sparcv9/Makefile
new file mode 100644
index 0000000000..600ff73f12
--- /dev/null
+++ b/usr/src/lib/libshell/sparcv9/Makefile
@@ -0,0 +1,31 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+include ../../Makefile.lib.64
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/libshell/sparcv9/include/ast/history.h b/usr/src/lib/libshell/sparcv9/include/ast/history.h
new file mode 100644
index 0000000000..55ead66f9e
--- /dev/null
+++ b/usr/src/lib/libshell/sparcv9/include/ast/history.h
@@ -0,0 +1,84 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+#ifndef HIST_VERSION
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+/*
+ * Interface for history mechanism
+ * written by David Korn
+ *
+ */
+
+#include <ast.h>
+
+#define HIST_CHAR '!'
+#define HIST_VERSION 1 /* history file format version no. */
+
+typedef struct
+{
+ Sfdisc_t histdisc; /* discipline for history */
+ Sfio_t *histfp; /* history file stream pointer */
+ char *histname; /* name of history file */
+ int32_t histind; /* current command number index */
+ int histsize; /* number of accessible history lines */
+#ifdef _HIST_PRIVATE
+ _HIST_PRIVATE
+#endif /* _HIST_PRIVATE */
+} History_t;
+
+typedef struct
+{
+ int hist_command;
+ int hist_line;
+ int hist_char;
+} Histloc_t;
+
+/* the following are readonly */
+extern __MANGLE__ const char hist_fname[];
+
+extern __MANGLE__ int _Hist;
+#define hist_min(hp) ((_Hist=((int)((hp)->histind-(hp)->histsize)))>=0?_Hist:0)
+#define hist_max(hp) ((int)((hp)->histind))
+/* these are the history interface routines */
+extern __MANGLE__ int sh_histinit __PROTO__((void));
+extern __MANGLE__ void hist_cancel __PROTO__((History_t*));
+extern __MANGLE__ void hist_close __PROTO__((History_t*));
+extern __MANGLE__ int hist_copy __PROTO__((char*, int, int, int));
+extern __MANGLE__ void hist_eof __PROTO__((History_t*));
+extern __MANGLE__ Histloc_t hist_find __PROTO__((History_t*,char*,int, int, int));
+extern __MANGLE__ void hist_flush __PROTO__((History_t*));
+extern __MANGLE__ void hist_list __PROTO__((History_t*,Sfio_t*, off_t, int, char*));
+extern __MANGLE__ int hist_match __PROTO__((History_t*,off_t, char*, int*));
+extern __MANGLE__ off_t hist_tell __PROTO__((History_t*,int));
+extern __MANGLE__ off_t hist_seek __PROTO__((History_t*,int));
+extern __MANGLE__ char *hist_word __PROTO__((char*, int, int));
+#if SHOPT_ESH
+ extern __MANGLE__ Histloc_t hist_locate __PROTO__((History_t*,int, int, int));
+#endif /* SHOPT_ESH */
+
+#endif /* HIST_VERSION */
diff --git a/usr/src/lib/libshell/sparcv9/include/ast/nval.h b/usr/src/lib/libshell/sparcv9/include/ast/nval.h
new file mode 100644
index 0000000000..06b18217b7
--- /dev/null
+++ b/usr/src/lib/libshell/sparcv9/include/ast/nval.h
@@ -0,0 +1,317 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+#ifndef NV_DEFAULT
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * Interface definitions of structures for name-value pairs
+ * These structures are used for named variables, functions and aliases
+ *
+ */
+
+
+#include <ast.h>
+#include <cdt.h>
+
+/* for compatibility with old hash library */
+#define Hashtab_t Dt_t
+#define HASH_BUCKET 1
+#define HASH_NOSCOPE 2
+#define HASH_SCOPE 4
+#define hashscope(x) dtvnext(x)
+
+typedef struct Namval Namval_t;
+typedef struct Namfun Namfun_t;
+typedef struct Namdisc Namdisc_t;
+typedef struct Nambfun Nambfun_t;
+typedef struct Namarray Namarr_t;
+typedef struct Nambltin Nambltin_t;
+typedef struct Namtype Namtype_t;
+
+/*
+ * This defines the template for nodes that have their own assignment
+ * and or lookup functions
+ */
+struct Namdisc
+{
+ size_t dsize;
+ void (*putval) __PROTO__((Namval_t*, const char*, int, Namfun_t*));
+ char *(*getval) __PROTO__((Namval_t*, Namfun_t*));
+ Sfdouble_t (*getnum) __PROTO__((Namval_t*, Namfun_t*));
+ char *(*setdisc) __PROTO__((Namval_t*, const char*, Namval_t*, Namfun_t*));
+ Namval_t *(*createf) __PROTO__((Namval_t*, const char*, int, Namfun_t*));
+ Namfun_t *(*clonef) __PROTO__((Namval_t*, Namval_t*, int, Namfun_t*));
+ char *(*namef) __PROTO__((Namval_t*, Namfun_t*));
+ Namval_t *(*nextf) __PROTO__((Namval_t*, Dt_t*, Namfun_t*));
+ Namval_t *(*typef) __PROTO__((Namval_t*, Namfun_t*));
+ int (*readf) __PROTO__((Namval_t*, Sfio_t*, int, Namfun_t*));
+};
+
+struct Namfun
+{
+ const Namdisc_t *disc;
+ char nofree;
+ char funs;
+ unsigned short dsize;
+ Namfun_t *next;
+ char *last;
+ Namval_t *type;
+};
+
+struct Nambfun
+{
+ Namfun_t fun;
+ int num;
+ const char **bnames;
+ Namval_t *bltins[1];
+};
+
+/* This is an array template header */
+struct Namarray
+{
+ Namfun_t hdr;
+ long nelem; /* number of elements */
+ __V_ *(*fun) __PROTO__((Namval_t*,const char*,int)); /* associative arrays */
+ Namval_t *parent; /* for multi-dimensional */
+};
+
+/* Passed as third argument to a builtin when NV_BLTINOPT is set on node */
+struct Nambltin
+{
+ __V_ *shp;
+ Namval_t *np;
+ __V_ *ptr;
+ __V_ *data;
+ int flags;
+};
+
+struct Namtype
+{
+ __V_ *shp;
+ Namval_t *np;
+ const char *optstring;
+ __V_ *optinfof;
+};
+
+/* attributes of name-value node attribute flags */
+
+#define NV_DEFAULT 0
+/* This defines the attributes for an attributed name-value pair node */
+struct Namval
+{
+ Dtlink_t nvlink; /* space for cdt links */
+ char *nvname; /* pointer to name of the node */
+ unsigned short nvflag; /* attributes */
+ unsigned short nvsize; /* size or base */
+#ifdef _NV_PRIVATE
+ _NV_PRIVATE
+#else
+ Namfun_t *nvfun;
+ char *nvalue;
+ char *nvprivate;
+#endif /* _NV_PRIVATE */
+};
+
+#define NV_CLASS ".sh.type"
+#define NV_MINSZ (sizeof(struct Namval)-sizeof(Dtlink_t)-sizeof(char*))
+#define nv_namptr(p,n) ((Namval_t*)((char*)(p)+(n)*NV_MINSZ-sizeof(Dtlink_t)))
+
+/* The following attributes are for internal use */
+#define NV_NOFREE 0x200 /* don't free the space when releasing value */
+#define NV_ARRAY 0x400 /* node is an array */
+#define NV_REF 0x4000 /* reference bit */
+#define NV_TABLE 0x800 /* node is a dictionary table */
+#define NV_IMPORT 0x1000 /* value imported from environment */
+#define NV_MINIMAL NV_IMPORT /* node does not contain all fields */
+
+#define NV_INTEGER 0x2 /* integer attribute */
+/* The following attributes are valid only when NV_INTEGER is off */
+#define NV_LTOU 0x4 /* convert to uppercase */
+#define NV_UTOL 0x8 /* convert to lowercase */
+#define NV_ZFILL 0x10 /* right justify and fill with leading zeros */
+#define NV_RJUST 0x20 /* right justify and blank fill */
+#define NV_LJUST 0x40 /* left justify and blank fill */
+#define NV_BINARY 0x100 /* fixed size data buffer */
+#define NV_RAW NV_LJUST /* used only with NV_BINARY */
+#define NV_HOST (NV_RJUST|NV_LJUST) /* map to host filename */
+
+/* The following attributes do not effect the value */
+#define NV_RDONLY 0x1 /* readonly bit */
+#define NV_EXPORT 0x2000 /* export bit */
+#define NV_TAGGED 0x8000 /* user define tag bit */
+
+/* The following are used with NV_INTEGER */
+#define NV_SHORT (NV_RJUST) /* when integers are not long */
+#define NV_LONG (NV_UTOL) /* for long long and long double */
+#define NV_UNSIGN (NV_LTOU) /* for unsigned quantities */
+#define NV_DOUBLE (NV_ZFILL) /* for floating point */
+#define NV_EXPNOTE (NV_LJUST) /* for scientific notation */
+
+/* options for nv_open */
+
+#define NV_APPEND 0x10000 /* append value */
+#define NV_MOVE 0x20000 /* for use with nv_clone */
+#define NV_ADD 8
+ /* add node if not found */
+#define NV_ASSIGN NV_NOFREE /* assignment is possible */
+#define NV_NOASSIGN 0 /* backward compatibility */
+#define NV_NOARRAY 0x200000 /* array name not possible */
+#define NV_IARRAY 0x400000 /* for indexed array */
+#define NV_NOREF NV_REF /* don't follow reference */
+#define NV_IDENT 0x80 /* name must be identifier */
+#define NV_VARNAME 0x20000 /* name must be ?(.)id*(.id) */
+#define NV_NOADD 0x40000 /* do not add node */
+#define NV_NOSCOPE 0x80000 /* look only in current scope */
+#define NV_NOFAIL 0x100000 /* return 0 on failure, no msg */
+#define NV_NODISC NV_IDENT /* ignore disciplines */
+
+#define NV_FUNCT NV_IDENT /* option for nv_create */
+#define NV_BLTINOPT NV_ZFILL /* save state for optimization*/
+
+#define NV_PUBLIC (~(NV_NOSCOPE|NV_ASSIGN|NV_IDENT|NV_VARNAME|NV_NOADD))
+
+/* numeric types */
+#define NV_INT16 (NV_SHORT|NV_INTEGER)
+#define NV_UINT16 (NV_UNSIGN|NV_SHORT|NV_INTEGER)
+#define NV_INT32 (NV_INTEGER)
+#define NV_UNT32 (NV_UNSIGN|NV_INTEGER)
+#define NV_INT64 (NV_LONG|NV_INTEGER)
+#define NV_UINT64 (NV_UNSIGN|NV_LONG|NV_INTEGER)
+#define NV_FLOAT (NV_SHORT|NV_DOUBLE|NV_INTEGER)
+#define NV_LDOUBLE (NV_LONG|NV_DOUBLE|NV_INTEGER)
+
+/* name-value pair macros */
+#define nv_isattr(np,f) ((np)->nvflag & (f))
+#define nv_onattr(n,f) ((n)->nvflag |= (f))
+#define nv_offattr(n,f) ((n)->nvflag &= ~(f))
+#define nv_isarray(np) (nv_isattr((np),NV_ARRAY))
+
+/* The following are operations for associative arrays */
+#define NV_AINIT 1 /* initialize */
+#define NV_AFREE 2 /* free array */
+#define NV_ANEXT 3 /* advance to next subscript */
+#define NV_ANAME 4 /* return subscript name */
+#define NV_ADELETE 5 /* delete current subscript */
+#define NV_AADD 6 /* add subscript if not found */
+#define NV_ACURRENT 7 /* return current subscript Namval_t* */
+
+/* The following are for nv_disc */
+#define NV_FIRST 1
+#define NV_LAST 2
+#define NV_POP 3
+#define NV_CLONE 4
+
+/* The following are operations for nv_putsub() */
+#define ARRAY_BITS 24
+#define ARRAY_ADD (1L<<ARRAY_BITS) /* add subscript if not found */
+#define ARRAY_SCAN (2L<<ARRAY_BITS) /* For ${array[@]} */
+#define ARRAY_UNDEF (4L<<ARRAY_BITS) /* For ${array} */
+
+
+/* These are disciplines provided by the library for use with nv_discfun */
+#define NV_DCADD 0 /* used to add named disciplines */
+#define NV_DCRESTRICT 1 /* variable that are restricted in rsh */
+
+#if defined(__EXPORT__) && defined(_DLL)
+# ifdef _BLD_shell
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+# else
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __IMPORT__
+# endif /* _BLD_shell */
+#endif /* _DLL */
+/* prototype for array interface*/
+extern __MANGLE__ Namarr_t *nv_setarray __PROTO__((Namval_t*,__V_*(*)(Namval_t*,const char*,int)));
+extern __MANGLE__ __V_ *nv_associative __PROTO__((Namval_t*,const char*,int));
+extern __MANGLE__ int nv_aindex __PROTO__((Namval_t*));
+extern __MANGLE__ int nv_nextsub __PROTO__((Namval_t*));
+extern __MANGLE__ char *nv_getsub __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_putsub __PROTO__((Namval_t*, char*, long));
+extern __MANGLE__ Namval_t *nv_opensub __PROTO__((Namval_t*));
+
+/* name-value pair function prototypes */
+extern __MANGLE__ int nv_adddisc __PROTO__((Namval_t*, const char**, Namval_t**));
+extern __MANGLE__ int nv_clone __PROTO__((Namval_t*, Namval_t*, int));
+extern __MANGLE__ void nv_close __PROTO__((Namval_t*));
+extern __MANGLE__ __V_ *nv_context __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_create __PROTO__((const char*, Dt_t*, int,Namfun_t*));
+extern __MANGLE__ Dt_t *nv_dict __PROTO__((Namval_t*));
+extern __MANGLE__ Sfdouble_t nv_getn __PROTO__((Namval_t*, Namfun_t*));
+extern __MANGLE__ Sfdouble_t nv_getnum __PROTO__((Namval_t*));
+extern __MANGLE__ char *nv_getv __PROTO__((Namval_t*, Namfun_t*));
+extern __MANGLE__ char *nv_getval __PROTO__((Namval_t*));
+extern __MANGLE__ Namfun_t *nv_hasdisc __PROTO__((Namval_t*, const Namdisc_t*));
+extern __MANGLE__ int nv_isnull __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_lastdict __PROTO__((void));
+extern __MANGLE__ void nv_newattr __PROTO__((Namval_t*,unsigned,int));
+extern __MANGLE__ Namval_t *nv_open __PROTO__((const char*,Dt_t*,int));
+extern __MANGLE__ void nv_putval __PROTO__((Namval_t*,const char*,int));
+extern __MANGLE__ void nv_putv __PROTO__((Namval_t*,const char*,int,Namfun_t*));
+extern __MANGLE__ int nv_scan __PROTO__((Dt_t*,void(*)(Namval_t*,__V_*),__V_*,int,int));
+extern __MANGLE__ Namval_t *nv_scoped __PROTO__((Namval_t*));
+extern __MANGLE__ char *nv_setdisc __PROTO__((Namval_t*,const char*,Namval_t*,Namfun_t*));
+extern __MANGLE__ void nv_setref __PROTO__((Namval_t*, Dt_t*,int));
+extern __MANGLE__ int nv_settype __PROTO__((Namval_t*, Namval_t*, int));
+extern __MANGLE__ void nv_setvec __PROTO__((Namval_t*,int,int,char*[]));
+extern __MANGLE__ void nv_setvtree __PROTO__((Namval_t*));
+extern __MANGLE__ int nv_setsize __PROTO__((Namval_t*,int));
+extern __MANGLE__ Namfun_t *nv_disc __PROTO__((Namval_t*,Namfun_t*,int));
+extern __MANGLE__ void nv_unset __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_search __PROTO__((const char *, Dt_t*, int));
+extern __MANGLE__ void nv_unscope __PROTO__((void));
+extern __MANGLE__ char *nv_name __PROTO__((Namval_t*));
+extern __MANGLE__ Namval_t *nv_type __PROTO__((Namval_t*));
+extern __MANGLE__ const Namdisc_t *nv_discfun __PROTO__((int));
+
+#ifdef _DLL
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif /* _DLL */
+
+#define nv_size(np) nv_setsize((np),-1)
+#define nv_stack(np,nf) nv_disc(np,nf,0)
+
+#if 0
+/*
+ * The names of many functions were changed in early '95
+ * Here is a mapping to the old names
+ */
+# define nv_istype(np) nv_isattr(np)
+# define nv_newtype(np) nv_newattr(np)
+# define nv_namset(np,a,b) nv_open(np,a,b)
+# define nv_free(np) nv_unset(np)
+# define nv_settype(np,a,b,c) nv_setdisc(np,a,b,c)
+# define nv_search(np,a,b) nv_open(np,a,((b)?0:NV_NOADD))
+# define settype setdisc
+#endif
+
+#endif /* NV_DEFAULT */
diff --git a/usr/src/lib/libshell/sparcv9/include/ast/shell.h b/usr/src/lib/libshell/sparcv9/include/ast/shell.h
new file mode 100644
index 0000000000..37cafa932b
--- /dev/null
+++ b/usr/src/lib/libshell/sparcv9/include/ast/shell.h
@@ -0,0 +1,256 @@
+
+/* : : generated by proto : : */
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2007 AT&T Knowledge Ventures *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Knowledge Ventures *
+* *
+* A copy of the License is available at *
+* http://www.opensource.org/licenses/cpl1.0.txt *
+* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+
+#ifndef SH_INTERACTIVE
+#if !defined(__PROTO__)
+#include <prototyped.h>
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * Interface definitions for shell command language
+ *
+ */
+
+#include <cmd.h>
+#include <cdt.h>
+#ifdef _SH_PRIVATE
+# include "name.h"
+#else
+# include <nval.h>
+#endif /* _SH_PRIVATE */
+
+#define SH_VERSION 20060510
+
+#undef NOT_USED
+#define NOT_USED(x) (&x,1)
+
+/* options */
+typedef struct
+{
+ unsigned long v[4];
+}
+Shopt_t;
+
+typedef void (*Shinit_f) __PROTO__((int));
+typedef int (*Shbltin_f) __PROTO__((int, char*[], __V_*));
+typedef int (*Shwait_f) __PROTO__((int, long, int));
+
+union Shnode_u;
+typedef union Shnode_u Shnode_t;
+
+#define SH_CFLAG 0
+#define SH_HISTORY 1 /* used also as a state */
+#define SH_ERREXIT 2 /* used also as a state */
+#define SH_VERBOSE 3 /* used also as a state */
+#define SH_MONITOR 4 /* used also as a state */
+#define SH_INTERACTIVE 5 /* used also as a state */
+#define SH_RESTRICTED 6
+#define SH_XTRACE 7
+#define SH_KEYWORD 8
+#define SH_NOUNSET 9
+#define SH_NOGLOB 10
+#define SH_ALLEXPORT 11
+#define SH_PFSH 12
+#define SH_IGNOREEOF 13
+#define SH_NOCLOBBER 14
+#define SH_MARKDIRS 15
+#define SH_BGNICE 16
+#define SH_VI 17
+#define SH_VIRAW 18
+#define SH_TFLAG 19
+#define SH_TRACKALL 20
+#define SH_SFLAG 21
+#define SH_NOEXEC 22
+#define SH_GMACS 24
+#define SH_EMACS 25
+#define SH_PRIVILEGED 26
+#define SH_SUBSHARE 27 /* subshell shares state with parent */
+#define SH_NOLOG 28
+#define SH_NOTIFY 29
+#define SH_DICTIONARY 30
+#define SH_PIPEFAIL 32
+#define SH_GLOBSTARS 33
+#define SH_XARGS 34
+#define SH_RC 35
+#define SH_SHOWME 36
+
+/*
+ * passed as flags to builtins in Nambltin_t struct when BLT_OPTIM is on
+ */
+#define SH_BEGIN_OPTIM 0x1
+#define SH_END_OPTIM 0x2
+
+/* The following type is used for error messages */
+
+/* error messages */
+extern __MANGLE__ const char e_defpath[];
+extern __MANGLE__ const char e_found[];
+extern __MANGLE__ const char e_nospace[];
+extern __MANGLE__ const char e_format[];
+extern __MANGLE__ const char e_number[];
+extern __MANGLE__ const char e_restricted[];
+extern __MANGLE__ const char e_recursive[];
+extern __MANGLE__ char e_version[];
+
+typedef struct sh_scope
+{
+ struct sh_scope *par_scope;
+ int argc;
+ char **argv;
+ char *cmdname;
+ char *filename;
+ int lineno;
+ Dt_t *var_tree;
+ struct sh_scope *self;
+} Shscope_t;
+
+/*
+ * Saves the state of the shell
+ */
+
+typedef struct sh_static
+{
+ Shopt_t options; /* set -o options */
+ Dt_t *var_tree; /* for shell variables */
+ Dt_t *fun_tree; /* for shell functions */
+ Dt_t *alias_tree; /* for alias names */
+ Dt_t *bltin_tree; /* for builtin commands */
+ Shscope_t *topscope; /* pointer to top-level scope */
+ int inlineno; /* line number of current input file */
+ int exitval; /* most recent exit value */
+ unsigned char trapnote; /* set when trap/signal is pending */
+ char subshell; /* set for virtual subshell */
+#ifdef _SH_PRIVATE
+ _SH_PRIVATE
+#endif /* _SH_PRIVATE */
+} Shell_t;
+
+/* flags for sh_parse */
+#define SH_NL 1 /* Treat new-lines as ; */
+#define SH_EOF 2 /* EOF causes syntax error */
+
+/* symbolic values for sh_iogetiop */
+#define SH_IOCOPROCESS (-2)
+#define SH_IOHISTFILE (-3)
+
+/* symbolic value for sh_fdnotify */
+#define SH_FDCLOSE (-1)
+
+#if defined(__EXPORT__) && defined(_DLL)
+# ifdef _BLD_shell
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__ __EXPORT__
+# endif /* _BLD_shell */
+#endif /* _DLL */
+
+extern __MANGLE__ Dt_t *sh_bltin_tree __PROTO__((void));
+extern __MANGLE__ void sh_subfork __PROTO__((void));
+extern __MANGLE__ Shell_t *sh_init __PROTO__((int,char*[],Shinit_f));
+extern __MANGLE__ int sh_reinit __PROTO__((char*[]));
+extern __MANGLE__ int sh_eval __PROTO__((Sfio_t*,int));
+extern __MANGLE__ void sh_delay __PROTO__((double));
+extern __MANGLE__ __V_ *sh_parse __PROTO__((Shell_t*, Sfio_t*,int));
+extern __MANGLE__ int sh_trap __PROTO__((const char*,int));
+extern __MANGLE__ int sh_fun __PROTO__((Namval_t*,Namval_t*, char*[]));
+extern __MANGLE__ int sh_funscope __PROTO__((int,char*[],int(*)(__V_*),__V_*,int));
+extern __MANGLE__ Sfio_t *sh_iogetiop __PROTO__((int,int));
+extern __MANGLE__ int sh_main __PROTO__((int, char*[], void(*)(int)));
+extern __MANGLE__ void sh_menu __PROTO__((Sfio_t*, int, char*[]));
+extern __MANGLE__ Namval_t *sh_addbuiltin __PROTO__((const char*, int(*)(int, char*[],__V_*), __V_*));
+extern __MANGLE__ char *sh_fmtq __PROTO__((const char*));
+extern __MANGLE__ char *sh_fmtqf __PROTO__((const char*, int, int));
+extern __MANGLE__ Sfdouble_t sh_strnum __PROTO__((const char*, char**, int));
+extern __MANGLE__ int sh_access __PROTO__((const char*,int));
+extern __MANGLE__ int sh_close __PROTO__((int));
+extern __MANGLE__ int sh_dup __PROTO__((int));
+extern __MANGLE__ void sh_exit __PROTO__((int));
+extern __MANGLE__ int sh_fcntl __PROTO__((int, int, ...));
+extern __MANGLE__ Sfio_t *sh_fd2sfio __PROTO__((int));
+extern __MANGLE__ int (*sh_fdnotify __PROTO__((int(*)(int,int)))) __PROTO__((int,int));
+extern __MANGLE__ Shell_t *sh_getinterp __PROTO__((void));
+extern __MANGLE__ int sh_open __PROTO__((const char*, int, ...));
+extern __MANGLE__ int sh_openmax __PROTO__((void));
+extern __MANGLE__ Sfio_t *sh_pathopen __PROTO__((const char*));
+extern __MANGLE__ ssize_t sh_read __PROTO__((int, __V_*, size_t));
+extern __MANGLE__ ssize_t sh_write __PROTO__((int, const __V_*, size_t));
+extern __MANGLE__ off_t sh_seek __PROTO__((int, off_t, int));
+extern __MANGLE__ int sh_pipe __PROTO__((int[]));
+extern __MANGLE__ mode_t sh_umask __PROTO__((mode_t));
+extern __MANGLE__ __V_ *sh_waitnotify __PROTO__((Shwait_f));
+extern __MANGLE__ Shscope_t *sh_getscope __PROTO__((int,int));
+extern __MANGLE__ Shscope_t *sh_setscope __PROTO__((Shscope_t*));
+extern __MANGLE__ void sh_sigcheck __PROTO__((void));
+extern __MANGLE__ unsigned long sh_isoption __PROTO__((int));
+extern __MANGLE__ unsigned long sh_onoption __PROTO__((int));
+extern __MANGLE__ unsigned long sh_offoption __PROTO__((int));
+extern __MANGLE__ int sh_waitsafe __PROTO__((void));
+extern __MANGLE__ int sh_exec __PROTO__((const Shnode_t*,int));
+
+#if SHOPT_DYNAMIC
+ extern __MANGLE__ __V_ **sh_getliblist __PROTO__((void));
+#endif /* SHOPT_DYNAMIC */
+
+/*
+ * direct access to sh is obsolete, use sh_getinterp() instead
+ */
+#if !defined(_SH_PRIVATE) && defined(__IMPORT__) && !defined(_BLD_shell)
+ extern __MANGLE__ __IMPORT__ Shell_t sh;
+#else
+ extern __MANGLE__ Shell_t sh;
+#endif
+
+#ifdef _DLL
+#undef __MANGLE__
+#define __MANGLE__ __LINKAGE__
+#endif /* _DLL */
+
+#ifndef _SH_PRIVATE
+# define access(a,b) sh_access(a,b)
+# define close(a) sh_close(a)
+# define exit(a) sh_exit(a)
+# define fcntl(a,b,c) sh_fcntl(a,b,c)
+# define pipe(a) sh_pipe(a)
+# define read(a,b,c) sh_read(a,b,c)
+# define write(a,b,c) sh_write(a,b,c)
+# define umask(a) sh_umask(a)
+# define dup sh_dup
+# if _lib_lseek64
+# define open64 sh_open
+# define lseek64 sh_seek
+# else
+# define open sh_open
+# define lseek sh_seek
+# endif
+#endif /* !_SH_PRIVATE */
+
+#define SH_SIGSET 4
+#define SH_EXITSIG 0400 /* signal exit bit */
+#define SH_EXITMASK (SH_EXITSIG-1) /* normal exit status bits */
+#define SH_RUNPROG -1022 /* needs to be negative and < 256 */
+
+#endif /* SH_INTERACTIVE */
diff --git a/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/acct b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/acct
new file mode 100644
index 0000000000..2cd67703ae
--- /dev/null
+++ b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/acct
@@ -0,0 +1,12 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_acct_ksh93
+#define _def_acct_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _lib_acct 1 /* acct() in default lib(s) */
+#define _sys_acct 1 /* #include <sys/acct.h> ok */
+#endif
diff --git a/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/cmds b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/cmds
new file mode 100644
index 0000000000..fa6d8ed96f
--- /dev/null
+++ b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/cmds
@@ -0,0 +1,36 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/cmd/ksh93/features/cmds by iffe version 2007-04-04 : : */
+#ifndef _def_cmds_ksh93
+#define _def_cmds_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _cmd_newgrp 1 /* newgrp in ?(/usr)/(bin|etc|ucb) */
+#define _bin_newgrp 1 /* /bin/newgrp found */
+#define _usr_bin_newgrp 1 /* /usr/bin/newgrp found */
+#define _cmd_test 1 /* test in ?(/usr)/(bin|etc|ucb) */
+#define _bin_test 1 /* /bin/test found */
+#define _usr_bin_test 1 /* /usr/bin/test found */
+#define _usr_ucb_test 1 /* /usr/ucb/test found */
+#define _cmd_id 1 /* id in ?(/usr)/(bin|etc|ucb) */
+#define _bin_id 1 /* /bin/id found */
+#define _usr_bin_id 1 /* /usr/bin/id found */
+#define _cmd_wc 1 /* wc in ?(/usr)/(bin|etc|ucb) */
+#define _bin_wc 1 /* /bin/wc found */
+#define _usr_bin_wc 1 /* /usr/bin/wc found */
+#define _usr_ucb_wc 1 /* /usr/ucb/wc found */
+#define _cmd_cut 1 /* cut in ?(/usr)/(bin|etc|ucb) */
+#define _bin_cut 1 /* /bin/cut found */
+#define _usr_bin_cut 1 /* /usr/bin/cut found */
+#define _cmd_logname 1 /* logname in ?(/usr)/(bin|etc|ucb) */
+#define _bin_logname 1 /* /bin/logname found */
+#define _usr_bin_logname 1 /* /usr/bin/logname found */
+#define _cmd_pfexec 1 /* pfexec in ?(/usr)/(bin|etc|ucb) */
+#define _bin_pfexec 1 /* /bin/pfexec found */
+#define _usr_bin_pfexec 1 /* /usr/bin/pfexec found */
+#define _cmd_tput 1 /* tput in ?(/usr)/(bin|etc|ucb) */
+#define _bin_tput 1 /* /bin/tput found */
+#define _usr_bin_tput 1 /* /usr/bin/tput found */
+#endif
diff --git a/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/dynamic b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/dynamic
new file mode 100644
index 0000000000..8b12ce4b17
--- /dev/null
+++ b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/dynamic
@@ -0,0 +1,23 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/cmd/ksh93/features/dynamic by iffe version 2007-04-04 : : */
+#ifndef _def_dynamic_ksh93
+#define _def_dynamic_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_dlfcn 1 /* #include <dlfcn.h> ok */
+#define _sys_dl 1 /* #include <sys/dl.h> ok */
+#define _hdr_dlldefs 1 /* #include <dlldefs.h> ok */
+#define _lib_dlopen 1 /* dlopen() in default lib(s) */
+#define _lib_dllfind 1 /* dllfind() in default lib(s) */
+#if !defined(SHOPT_FS_3D) && ( _lib_dllfind || _lib_dlopen || _lib_shl_load || _lib_loadbind )
+# define SHOPT_FS_3D 1
+#endif /* !SHOPT_FS_3D */
+#if SHOPT_FS_3D
+# undef mount
+# include <fs3d.h>
+#endif /* SHOPT_FS_3D */
+
+#endif
diff --git a/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/execargs b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/execargs
new file mode 100644
index 0000000000..01f0d04e1f
--- /dev/null
+++ b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/execargs
@@ -0,0 +1,10 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_execargs_ksh93
+#define _def_execargs_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#endif
diff --git a/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/externs b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/externs
new file mode 100644
index 0000000000..f0d91c6237
--- /dev/null
+++ b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/externs
@@ -0,0 +1,81 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/cmd/ksh93/features/externs by iffe version 2007-04-04 : : */
+
+#ifndef _def_externs_ksh93
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_externs_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_exec_attr 1 /* #include <exec_attr.h> ok */
+#define _hdr_math 1 /* #include <math.h> ok */
+#define _mem_name_exception 1 /* name is a member of struct exception */
+#define _lib_setreuid 1 /* setreuid() in default lib(s) */
+#define _lib_setregid 1 /* setregid() in default lib(s) */
+#define _lib_nice 1 /* nice() in default lib(s) */
+#define _lib_sigflag 1 /* sigflag() in default lib(s) */
+#define _lib_fork 1 /* fork() in default lib(s) */
+#define _lib_spawnveg 1 /* spawnveg() in default lib(s) */
+#define _lib_fchdir 1 /* fchdir() in default lib(s) */
+#endif
diff --git a/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/locale b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/locale
new file mode 100644
index 0000000000..69712f8ea0
--- /dev/null
+++ b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/locale
@@ -0,0 +1,38 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/cmd/ksh93/features/locale by iffe version 2007-04-04 : : */
+#ifndef _def_locale_ksh93
+#define _def_locale_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_locale 1 /* #include <locale.h> ok */
+#define _hdr_wchar 1 /* #include <wchar.h> ok */
+#define _lib_localeconv 1 /* localeconv() in default lib(s) */
+#define _lib_wctype 1 /* wctype() in default lib(s) */
+#define _lib_iswctype 1 /* iswctype() in default lib(s) */
+#define _lib_iswblank 1 /* iswblank() in default lib(s) */
+#if _PACKAGE_ast
+# undef _hdr_locale
+# define _hdr_locale 1
+#else
+# ifdef _hdr_locale
+# include <locale.h>
+# ifndef LC_MESSAGES
+# define LC_MESSAGES LC_ALL
+# endif /* LC_MESSAGES */
+# endif /* _hdr_locale */
+#endif /* _PACKAGE_ast */
+#ifdef _hdr_locale
+# ifdef _lib_localeconv
+ static struct lconv *lp;
+# define GETDECIMAL(x) (((lp=localeconv()) && lp->decimal_point && *lp->decimal_point) ? *lp->decimal_point : '.' )
+# else
+# define GETDECIMAL(x) ('.')
+# endif /* _lib_localeconv */
+#else
+# define GETDECIMAL(x) ('.')
+#endif /* _hdr_locale */
+
+#endif
diff --git a/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/math b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/math
new file mode 100644
index 0000000000..efa9b09631
--- /dev/null
+++ b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/math
@@ -0,0 +1,162 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/cmd/ksh93/features/math.sh by iffe version 2007-04-04 : : */
+#ifndef _def_math_ksh93
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_math_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+
+
+/* : : generated by iffe from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/cmd/ksh93/data/math.tab : : */
+
+typedef Sfdouble_t (*Math_f) __PROTO__((Sfdouble_t,...));
+
+#include <ast_standards.h>
+#include <math.h>
+#include <ieeefp.h>
+
+static Sfdouble_t local_finite __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return finite(a1);}
+static int local_fpclassify __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return fpclassify(a1);}
+static int local_isfinite __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return isfinite(a1);}
+static int local_isgreater __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return isgreater(a1,a2);}
+static int local_isgreaterequal __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return isgreaterequal(a1,a2);}
+static int local_isinf __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return isinf(a1);}
+static int local_isless __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return isless(a1,a2);}
+static int local_islessequal __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return islessequal(a1,a2);}
+static int local_islessgreater __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return islessgreater(a1,a2);}
+static int local_isnormal __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return isnormal(a1);}
+static int local_isunordered __PARAM__((Sfdouble_t a1,Sfdouble_t a2), (a1, a2)) __OTORP__(Sfdouble_t a1;Sfdouble_t a2;){return isunordered(a1,a2);}
+static int local_signbit __PARAM__((Sfdouble_t a1), (a1)) __OTORP__(Sfdouble_t a1;){return signbit(a1);}
+
+/*
+ * first byte is two-digit octal number. Last digit is number of args
+ * first digit is 0 if return value is double, 1 for integer
+ */
+const struct mathtab shtab_math[] =
+{
+ "\001acos", (Math_f)acosl,
+ "\001acosh", (Math_f)acoshl,
+ "\001asin", (Math_f)asinl,
+ "\001asinh", (Math_f)asinhl,
+ "\001atan", (Math_f)atanl,
+ "\002atan2", (Math_f)atan2l,
+ "\001atanh", (Math_f)atanhl,
+ "\001cbrt", (Math_f)cbrtl,
+ "\002copysign", (Math_f)copysignl,
+ "\001cos", (Math_f)cosl,
+ "\001cosh", (Math_f)coshl,
+ "\001erf", (Math_f)erfl,
+ "\001erfc", (Math_f)erfcl,
+ "\001exp", (Math_f)expl,
+ "\001exp2", (Math_f)exp2l,
+ "\001expm1", (Math_f)expm1l,
+ "\001fabs", (Math_f)fabsl,
+ "\001abs", (Math_f)fabsl,
+ "\002fdim", (Math_f)fdiml,
+ "\001finite", (Math_f)local_finite,
+ "\001floor", (Math_f)floorl,
+ "\001int", (Math_f)floorl,
+ "\003fma", (Math_f)fmal,
+ "\002fmax", (Math_f)fmaxl,
+ "\002fmin", (Math_f)fminl,
+ "\002fmod", (Math_f)fmodl,
+ "\011fpclassify", (Math_f)local_fpclassify,
+ "\002hypot", (Math_f)hypotl,
+ "\011ilogb", (Math_f)ilogbl,
+ "\011isfinite", (Math_f)local_isfinite,
+ "\012isgreater", (Math_f)local_isgreater,
+ "\012isgreaterequal", (Math_f)local_isgreaterequal,
+ "\011isinf", (Math_f)local_isinf,
+ "\012isless", (Math_f)local_isless,
+ "\012islessequal", (Math_f)local_islessequal,
+ "\012islessgreater", (Math_f)local_islessgreater,
+ "\011isnan", (Math_f)isnanl,
+ "\011isnormal", (Math_f)local_isnormal,
+ "\012isunordered", (Math_f)local_isunordered,
+ "\001lgamma", (Math_f)lgammal,
+ "\001log", (Math_f)logl,
+ "\001log1p", (Math_f)log1pl,
+ "\001log2", (Math_f)log2l,
+ "\001logb", (Math_f)logbl,
+ "\001nearbyint", (Math_f)nearbyintl,
+ "\002nextafter", (Math_f)nextafterl,
+ "\002nexttoward", (Math_f)nexttowardl,
+ "\002pow", (Math_f)powl,
+ "\002remainder", (Math_f)remainderl,
+ "\001rint", (Math_f)rintl,
+ "\001round", (Math_f)roundl,
+ "\002scalb", (Math_f)scalbl,
+ "\002scalbn", (Math_f)scalbnl,
+ "\011signbit", (Math_f)local_signbit,
+ "\001sin", (Math_f)sinl,
+ "\001sinh", (Math_f)sinhl,
+ "\001sqrt", (Math_f)sqrtl,
+ "\001tan", (Math_f)tanl,
+ "\001tanh", (Math_f)tanhl,
+ "\001tgamma", (Math_f)tgammal,
+ "\001trunc", (Math_f)truncl,
+ "", (Math_f)0
+};
+#endif
diff --git a/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/options b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/options
new file mode 100644
index 0000000000..5ed6b7ba57
--- /dev/null
+++ b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/options
@@ -0,0 +1,26 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/cmd/ksh93/features/options by iffe version 2007-04-04 : : */
+#ifndef _def_options_ksh93
+#define _def_options_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define SHELLMAGIC 1
+#ifndef SHOPT_DEVFD
+# define SHOPT_DEVFD 1
+#endif
+#ifndef SHOPT_PFSH
+# define SHOPT_PFSH 1
+#endif
+#undef SHOPT_TEST_L
+#ifndef SHOPT_SYSRC
+# define SHOPT_SYSRC 1
+#endif
+#undef SHOPT_UCB
+#if !_PACKAGE_ast && ( (MB_LEN_MAX-1)<=0 || !defined(_lib_mbtowc) )
+# undef SHOPT_MULTIBYTE
+#endif
+
+#endif
diff --git a/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/poll b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/poll
new file mode 100644
index 0000000000..d0ed361519
--- /dev/null
+++ b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/poll
@@ -0,0 +1,119 @@
+
+/* : : generated by proto : : */
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/cmd/ksh93/features/poll by iffe version 2007-04-04 : : */
+#ifndef _def_poll_ksh93
+#if !defined(__PROTO__)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
+# if defined(__cplusplus)
+# define __LINKAGE__ "C"
+# else
+# define __LINKAGE__
+# endif
+# define __STDARG__
+# define __PROTO__(x) x
+# define __OTORP__(x)
+# define __PARAM__(n,o) n
+# if !defined(__STDC__) && !defined(__cplusplus)
+# if !defined(c_plusplus)
+# define const
+# endif
+# define signed
+# define void int
+# define volatile
+# define __V_ char
+# else
+# define __V_ void
+# endif
+# else
+# define __PROTO__(x) ()
+# define __OTORP__(x) x
+# define __PARAM__(n,o) o
+# define __LINKAGE__
+# define __V_ char
+# define const
+# define signed
+# define void int
+# define volatile
+# endif
+# define __MANGLE__ __LINKAGE__
+# if defined(__cplusplus) || defined(c_plusplus)
+# define __VARARG__ ...
+# else
+# define __VARARG__
+# endif
+# if defined(__STDARG__)
+# define __VA_START__(p,a) va_start(p,a)
+# else
+# define __VA_START__(p,a) va_start(p)
+# endif
+# if !defined(__INLINE__)
+# if defined(__cplusplus)
+# define __INLINE__ extern __MANGLE__ inline
+# else
+# if defined(_WIN32) && !defined(__GNUC__)
+# define __INLINE__ __inline
+# endif
+# endif
+# endif
+#endif
+#if !defined(__LINKAGE__)
+#define __LINKAGE__ /* 2004-08-11 transition */
+#endif
+
+#define _def_poll_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_poll 1 /* #include <poll.h> ok */
+#define _hdr_netinet_in 1 /* #include <netinet/in.h> ok */
+#define _sys_poll 1 /* #include <sys/poll.h> ok */
+#define _sys_socket 1 /* #include <sys/socket.h> ok */
+#define _lib_select 1 /* select() in default lib(s) */
+#define _lib_poll 1 /* poll() in default lib(s) */
+#define _lib_socket 1 /* socket() in default lib(s) */
+#define _lib_htons 1 /* htons() in default lib(s) */
+#define _lib_htonl 1 /* htonl() in default lib(s) */
+#define _hdr_netdb 1 /* #include <netdb.h> ok */
+#define _lib_getaddrinfo 1 /* getaddrinfo() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _sys_select 1 /* #include <sys/select.h> ok */
+#define _typ_fd_set 1 /* fd_set is a type */
+#define _socketpair_devfd 1 /* /dev/fd/N handles socketpair() */
+
+#ifdef _lib_poll
+# define poll _SYS_poll
+#else
+# undef _hdr_poll
+# undef _sys_poll
+#endif /* _lib_poll */
+#ifdef _hdr_poll
+# include <poll.h>
+#else
+# ifdef _sys_poll
+# include <sys/poll.h>
+# endif /* _sys_poll */
+#endif /* _hdr_poll */
+#ifdef _lib_poll
+# undef poll
+ extern __MANGLE__ int poll __PROTO__((struct pollfd*,unsigned long,int));
+#endif /* _lib_poll */
+#ifdef _lib_select
+# ifndef FD_ZERO
+# define FD_ZERO(x) (*(x)=0)
+# endif /* FD_ZERO */
+# ifndef FD_SET
+# define FD_SET(n,x) (*(x)|=(1L<<(n)))
+# endif /* FD_SET */
+# ifndef _typ_fd_set
+ typedef long fd_set;
+# endif /*_typ_fd_set */
+#endif /* _lib_select */
+
+#endif
diff --git a/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/pstat b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/pstat
new file mode 100644
index 0000000000..b051334549
--- /dev/null
+++ b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/pstat
@@ -0,0 +1,10 @@
+/* : : generated by iffe version 2007-04-04 : : */
+#ifndef _def_pstat_ksh93
+#define _def_pstat_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#endif
diff --git a/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/rlimits b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/rlimits
new file mode 100644
index 0000000000..0dad9c0146
--- /dev/null
+++ b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/rlimits
@@ -0,0 +1,19 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/cmd/ksh93/features/rlimits by iffe version 2007-04-04 : : */
+#ifndef _def_rlimits_ksh93
+#define _def_rlimits_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _sys_resource 1 /* #include <sys/resource.h> ok */
+#define _lib_getrlimit 1 /* getrlimit() in default lib(s) */
+#define _lib_ulimit 1 /* ulimit() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _typ_rlim_t 1 /* rlim_t is a type */
+#endif
diff --git a/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/setjmp b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/setjmp
new file mode 100644
index 0000000000..d1975c45ac
--- /dev/null
+++ b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/setjmp
@@ -0,0 +1,35 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/cmd/ksh93/features/setjmp by iffe version 2007-04-04 : : */
+#ifndef _def_setjmp_ksh93
+#define _def_setjmp_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _lib_sigsetjmp 1 /* sigsetjmp() in default lib(s) */
+#define _lib__setjmp 1 /* _setjmp() in default lib(s) */
+#define _lib__longjmp 1 /* _longjmp() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_setjmp 1 /* #include <setjmp.h> ok */
+#define _typ_sigjmp_buf 1 /* sigjmp_buf is a type */
+#undef sigsetjmp
+#undef siglongjmp
+#undef sigjmp_buf
+#define sigjmp_buf jmp_buf
+#ifdef _lib__setjmp
+# define sigsetjmp(a,b) _setjmp(a)
+#else
+# define sigsetjmp(a,b) setjmp(a)
+#endif /* _lib__setjmp */
+#ifdef _lib__longjmp
+# define siglongjmp(a,b) _longjmp(a,b)
+#else
+# define siglongjmp(a,b) longjmp(a,b)
+#endif /* _lib__longjmp */
+
+#endif
diff --git a/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/sigfeatures b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/sigfeatures
new file mode 100644
index 0000000000..37a2d05160
--- /dev/null
+++ b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/sigfeatures
@@ -0,0 +1,54 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/cmd/ksh93/features/sigfeatures by iffe version 2007-04-04 : : */
+#ifndef _def_sigfeatures_ksh93
+#define _def_sigfeatures_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _lib_sigrelse 1 /* sigrelse() in default lib(s) */
+#define _lib_sigprocmask 1 /* sigprocmask() in default lib(s) */
+#define _hdr_time 1 /* #include <time.h> ok */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _sys_times 1 /* #include <sys/times.h> ok */
+#define _hdr_stddef 1 /* #include <stddef.h> ok */
+#define _hdr_stdlib 1 /* #include <stdlib.h> ok */
+#define _hdr_ast 1 /* #include <ast.h> ok */
+#define _hdr_signal 1 /* #include <signal.h> ok */
+#define _typ_sigset_t 1 /* sigset_t is a type */
+#ifndef _mem_sigvec_sv_mask
+# undef _lib_sigvec
+#endif
+#ifdef _lib_sigprocmask
+# define sh_sigaction(s,action) do { sigset_t ss;\
+ sigemptyset(&ss);\
+ sigaddset(&ss,(s));\
+ sigprocmask(action,&ss,0); \
+ }while(0)
+# define sigrelease(s) sh_sigaction(s,SIG_UNBLOCK)
+# define sigblock(s) sh_sigaction(s,SIG_BLOCK)
+# define sig_begin() sh_sigaction(0,SIG_SETMASK)
+#else
+# ifndef _lib_sigblock
+# define sigblock(s)
+# endif
+# ifdef _lib_sigsetmask
+# define sigrelease(s) sigsetmask(0)
+# define sig_begin() sigsetmask(0)
+# else
+# ifdef _lib_sigrelse
+# define sigrelease sigrelse
+# define sig_begin()
+# else
+# define sig_begin() (0)
+# define sigrelease(s) (0)
+# endif /* _lib_sigrelse */
+# endif /* _lib_sigsetmask */
+#endif /* _lib_sigprocmask */
+
+#undef _SIGRTMIN
+#define _SIGRTMIN 41
+#undef _SIGRTMAX
+#define _SIGRTMAX 48
+#endif
diff --git a/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/time b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/time
new file mode 100644
index 0000000000..10e253c2a6
--- /dev/null
+++ b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/time
@@ -0,0 +1,28 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/cmd/ksh93/features/time by iffe version 2007-04-04 : : */
+#ifndef _def_time_ksh93
+#define _def_time_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_utime 1 /* #include <utime.h> ok */
+#define _lib_gettimeofday 1 /* gettimeofday() in default lib(s) */
+#define _lib_setitimer 1 /* setitimer() in default lib(s) */
+#define _sys_time 1 /* #include <sys/time.h> ok */
+#define _mem_tv_usec_timeval 1 /* tv_usec is a member of struct timeval */
+#define _lib_2_timeofday 1 /* 2 arg gettimeofday() */
+#undef _def_time
+#include <times.h>
+#define _def_time 1
+#undef timeofday
+#if _lib_2_timeofday
+#define timeofday(p) gettimeofday(p,(struct timezone*)0)
+#else
+#if _lib_1_timeofday
+#define timeofday(p) gettimeofday(p)
+#endif
+#endif
+
+#endif
diff --git a/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/ttys b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/ttys
new file mode 100644
index 0000000000..283a83c773
--- /dev/null
+++ b/usr/src/lib/libshell/sparcv9/src/cmd/ksh93/FEATURE/ttys
@@ -0,0 +1,19 @@
+/* : : generated from /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/src/cmd/ksh93/features/ttys by iffe version 2007-04-04 : : */
+#ifndef _def_ttys_ksh93
+#define _def_ttys_ksh93 1
+#define _sys_types 1 /* #include <sys/types.h> ok */
+#define _LIB_dll 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libdll.a is a library */
+#define _LIB_ast 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libast.a is a library */
+#define _LIB_m 1 /* -lm is a library */
+#define _LIB_cmd 1 /* /home/gisburn/ksh93/ast_ksh_20070418/build_sparc_64bit/arch/sol11.sun4/lib/libcmd.a is a library */
+#define _LIB_nsl 1 /* -lnsl is a library */
+#define _hdr_termios 1 /* #include <termios.h> ok */
+#define _hdr_termio 1 /* #include <termio.h> ok */
+#define _hdr_sgtty 1 /* #include <sgtty.h> ok */
+#define _sys_termios 1 /* #include <sys/termios.h> ok */
+#define _sys_termio 1 /* #include <sys/termio.h> ok */
+#define _sys_ioctl 1 /* #include <sys/ioctl.h> ok */
+#define _sys_filio 1 /* #include <sys/filio.h> ok */
+#define _lib_tcgetattr 1 /* tcgetattr() in default lib(s) */
+#define _lib_tcgetpgrp 1 /* tcgetpgrp() in default lib(s) */
+#endif
diff --git a/usr/src/pkgdefs/Makefile b/usr/src/pkgdefs/Makefile
index d4950df0f7..c58e7b553d 100644
--- a/usr/src/pkgdefs/Makefile
+++ b/usr/src/pkgdefs/Makefile
@@ -23,7 +23,7 @@
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-#ident "%Z%%M% %I% %E% SMI"
+# ident "%Z%%M% %I% %E% SMI"
#
include $(SRC)/Makefile.master
@@ -163,6 +163,7 @@ COMMON_SUBDIRS= \
SUNWarc \
SUNWarbel \
SUNWarcr \
+ SUNWastdev \
SUNWav1394 \
SUNWbart \
SUNWbge \
diff --git a/usr/src/pkgdefs/SUNW0on/prototype_com b/usr/src/pkgdefs/SUNW0on/prototype_com
index cea054d7c6..bb97b7cb47 100644
--- a/usr/src/pkgdefs/SUNW0on/prototype_com
+++ b/usr/src/pkgdefs/SUNW0on/prototype_com
@@ -73,6 +73,16 @@ f none usr/lib/locale/C/LC_MESSAGES/uxlibc.src 644 root sys
f none usr/lib/locale/C/LC_TIME/SUNW_OST_OSCMD.po 644 root sys
f none usr/lib/locale/C/LC_TIME/SUNW_OST_OSLIB.po 644 root sys
#
+# AT&T AST locale files
+# (file names and locations must be in sync with upstream definitions
+# to ensure compatibility between our version of AST/ksh93 and the
+# native one)
+#
+f none usr/lib/locale/C/LC_MESSAGES/libast 644 root sys
+f none usr/lib/locale/C/LC_MESSAGES/libcmd 644 root sys
+f none usr/lib/locale/C/LC_MESSAGES/libdll 644 root sys
+f none usr/lib/locale/C/LC_MESSAGES/libshell 644 root sys
+#
# Java locale directories
#
d none usr/share 755 root sys
diff --git a/usr/src/pkgdefs/SUNWarc/prototype_com b/usr/src/pkgdefs/SUNWarc/prototype_com
index c01efe2f3a..63332ac331 100644
--- a/usr/src/pkgdefs/SUNWarc/prototype_com
+++ b/usr/src/pkgdefs/SUNWarc/prototype_com
@@ -80,8 +80,6 @@ s none usr/lib/llib-lbsm=../../lib/llib-lbsm
s none usr/lib/llib-lbsm.ln=../../lib/llib-lbsm.ln
s none usr/lib/llib-lc=../../lib/llib-lc
s none usr/lib/llib-lc.ln=../../lib/llib-lc.ln
-f none usr/lib/llib-lcmd 644 root bin
-f none usr/lib/llib-lcmd.ln 644 root bin
f none usr/lib/llib-lcrypt 644 root bin
f none usr/lib/llib-lcrypt.ln 644 root bin
f none usr/lib/llib-lcfgadm 644 root bin
diff --git a/usr/src/pkgdefs/SUNWarc/prototype_i386 b/usr/src/pkgdefs/SUNWarc/prototype_i386
index eac70ec960..d44475eca0 100644
--- a/usr/src/pkgdefs/SUNWarc/prototype_i386
+++ b/usr/src/pkgdefs/SUNWarc/prototype_i386
@@ -72,7 +72,6 @@ s none usr/lib/amd64/llib-lbsm.ln=../../../lib/amd64/llib-lbsm.ln
s none usr/lib/amd64/llib-lpam.ln=../../../lib/amd64/llib-lpam.ln
s none usr/lib/amd64/llib-lc.ln=../../../lib/amd64/llib-lc.ln
f none usr/lib/amd64/llib-lcfgadm.ln 644 root bin
-f none usr/lib/amd64/llib-lcmd.ln 644 root bin
s none usr/lib/amd64/llib-lcontract.ln=../../../lib/amd64/llib-lcontract.ln
s none usr/lib/amd64/llib-lctf.ln=../../../lib/amd64/llib-lctf.ln
f none usr/lib/amd64/llib-lcrypt.ln 644 root bin
diff --git a/usr/src/pkgdefs/SUNWarc/prototype_sparc b/usr/src/pkgdefs/SUNWarc/prototype_sparc
index f07dc056ec..453df0720c 100644
--- a/usr/src/pkgdefs/SUNWarc/prototype_sparc
+++ b/usr/src/pkgdefs/SUNWarc/prototype_sparc
@@ -68,7 +68,6 @@ s none usr/lib/sparcv9/llib-lbsm.ln=../../../lib/sparcv9/llib-lbsm.ln
s none usr/lib/sparcv9/llib-lpam.ln=../../../lib/sparcv9/llib-lpam.ln
s none usr/lib/sparcv9/llib-lc.ln=../../../lib/sparcv9/llib-lc.ln
f none usr/lib/sparcv9/llib-lcfgadm.ln 644 root bin
-f none usr/lib/sparcv9/llib-lcmd.ln 644 root bin
s none usr/lib/sparcv9/llib-lcontract.ln=../../../lib/sparcv9/llib-lcontract.ln
s none usr/lib/sparcv9/llib-lctf.ln=../../../lib/sparcv9/llib-lctf.ln
f none usr/lib/sparcv9/llib-lcrypt.ln 644 root bin
diff --git a/usr/src/pkgdefs/SUNWastdev/Makefile b/usr/src/pkgdefs/SUNWastdev/Makefile
new file mode 100644
index 0000000000..828906af9d
--- /dev/null
+++ b/usr/src/pkgdefs/SUNWastdev/Makefile
@@ -0,0 +1,37 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+include ../Makefile.com
+
+DATAFILES += depend
+
+.KEEP_STATE:
+
+all: $(FILES)
+install: all pkg
+
+include ../Makefile.targ
diff --git a/usr/src/pkgdefs/SUNWastdev/pkginfo.tmpl b/usr/src/pkgdefs/SUNWastdev/pkginfo.tmpl
new file mode 100644
index 0000000000..d9420dabf6
--- /dev/null
+++ b/usr/src/pkgdefs/SUNWastdev/pkginfo.tmpl
@@ -0,0 +1,58 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+#
+# This required package information file describes characteristics of the
+# package, such as package abbreviation, full package name, package version,
+# and package architecture.
+#
+PKG="SUNWastdev"
+NAME="AT&T AST development utilities"
+ARCH="ISA"
+VERSION="ONVERS,REV=0.0.0"
+SUNW_PRODNAME="SunOS"
+SUNW_PRODVERS="RELEASE/VERSION"
+SUNW_PKGTYPE="usr"
+MAXINST="1000"
+CATEGORY="system"
+DESC="AT&T AST development utilities"
+VENDOR="Sun Microsystems, Inc."
+HOTLINE="Please contact your local service provider"
+EMAIL=""
+CLASSES="none"
+BASEDIR=/
+SUNW_PKGVERS="1.0"
+SUNW_PKG_ALLZONES="true"
+SUNW_PKG_HOLLOW="false"
+SUNW_PKG_THISZONE="false"
+#VSTOCK="<reserved by Release Engineering for package part #>"
+#ISTATES="<developer defined>"
+#RSTATES='<developer defined>'
+#ULIMIT="<developer defined>"
+#ORDER="<developer defined>"
+#PSTAMP="<developer defined>"
+#INTONLY="<developer defined>"
diff --git a/usr/src/pkgdefs/SUNWastdev/prototype_com b/usr/src/pkgdefs/SUNWastdev/prototype_com
new file mode 100644
index 0000000000..2ea8ed8cb4
--- /dev/null
+++ b/usr/src/pkgdefs/SUNWastdev/prototype_com
@@ -0,0 +1,59 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+# This required package information file contains a list of package contents.
+# The 'pkgmk' command uses this file to identify the contents of a package
+# and their location on the development machine when building the package.
+# Can be created via a text editor or through use of the 'pkgproto' command.
+
+#!search <pathname pathname ...> # where to find pkg objects
+#!include <filename> # include another 'prototype' file
+#!default <mode> <owner> <group> # default used if not specified on entry
+#!<param>=<value> # puts parameter in pkg environment
+
+# packaging files
+i pkginfo
+i copyright
+i depend
+#
+# source locations relative to the prototype file
+#
+# SUNWastdev
+#
+d none usr 755 root sys
+d none usr/ast 0755 root sys
+d none usr/ast/bin 0755 root bin
+f none usr/ast/bin/msgcc 0555 root bin
+f none usr/ast/bin/msgcpp 0555 root bin
+f none usr/ast/bin/msgcvt 0555 root bin
+f none usr/ast/bin/msggen 0555 root bin
+f none usr/ast/bin/msgget 0555 root bin
+d none usr/include 755 root bin
+d none usr/include/ast 755 root bin
+f none usr/include/ast/pp.h 644 root bin
+f none usr/include/ast/ppkey.h 644 root bin
+d none usr/lib 755 root bin
+f none usr/lib/libpp.so.1 755 root bin
diff --git a/usr/src/pkgdefs/SUNWastdev/prototype_i386 b/usr/src/pkgdefs/SUNWastdev/prototype_i386
new file mode 100644
index 0000000000..87c7f17525
--- /dev/null
+++ b/usr/src/pkgdefs/SUNWastdev/prototype_i386
@@ -0,0 +1,50 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+# This required package information file contains a list of package contents.
+# The 'pkgmk' command uses this file to identify the contents of a package
+# and their location on the development machine when building the package.
+# Can be created via a text editor or through use of the 'pkgproto' command.
+
+#!search <pathname pathname ...> # where to find pkg objects
+#!include <filename> # include another 'prototype' file
+#!default <mode> <owner> <group> # default used if not specified on entry
+#!<param>=<value> # puts parameter in pkg environment
+
+#
+# Include ISA independent files (prototype_com)
+#
+!include prototype_com
+#
+#
+#
+# List files which are I386 specific here
+#
+# source locations relative to the prototype file
+#
+#
+# SUNWastdev
+#
diff --git a/usr/src/pkgdefs/SUNWastdev/prototype_sparc b/usr/src/pkgdefs/SUNWastdev/prototype_sparc
new file mode 100644
index 0000000000..9af11dc701
--- /dev/null
+++ b/usr/src/pkgdefs/SUNWastdev/prototype_sparc
@@ -0,0 +1,50 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+# This required package information file contains a list of package contents.
+# The 'pkgmk' command uses this file to identify the contents of a package
+# and their location on the development machine when building the package.
+# Can be created via a text editor or through use of the 'pkgproto' command.
+
+#!search <pathname pathname ...> # where to find pkg objects
+#!include <filename> # include another 'prototype' file
+#!default <mode> <owner> <group> # default used if not specified on entry
+#!<param>=<value> # puts parameter in pkg environment
+
+#
+# Include ISA independent files (prototype_com)
+#
+!include prototype_com
+#
+#
+#
+# List files which are SPARC specific here
+#
+# source locations relative to the prototype file
+#
+#
+# SUNWastdev
+#
diff --git a/usr/src/pkgdefs/SUNWcsl/prototype_com b/usr/src/pkgdefs/SUNWcsl/prototype_com
index 41dd611a25..4275b9ce85 100644
--- a/usr/src/pkgdefs/SUNWcsl/prototype_com
+++ b/usr/src/pkgdefs/SUNWcsl/prototype_com
@@ -73,6 +73,7 @@ s none usr/lib/libadm.so=../../lib/libadm.so.1
s none usr/lib/libadm.so.1=../../lib/libadm.so.1
s none usr/lib/libaio.so=../../lib/libaio.so.1
s none usr/lib/libaio.so.1=../../lib/libaio.so.1
+f none usr/lib/libast.so.1 755 root bin
s none usr/lib/libavl.so.1=../../lib/libavl.so.1
s none usr/lib/libbsdmalloc.so=./libbsdmalloc.so.1
f none usr/lib/libbsdmalloc.so.1 755 root bin
@@ -115,6 +116,7 @@ f none usr/lib/libdisasm.so.1 755 root bin
s none usr/lib/libdisasm.so=./libdisasm.so.1
s none usr/lib/libdl.so=../../lib/libdl.so.1
s none usr/lib/libdl.so.1=../../lib/libdl.so.1
+f none usr/lib/libdll.so.1 755 root bin
s none usr/lib/libdlpi.so=../../lib/libdlpi.so.1
s none usr/lib/libdlpi.so.1=../../lib/libdlpi.so.1
s none usr/lib/libdoor.so=../../lib/libdoor.so.1
@@ -243,6 +245,7 @@ s none usr/lib/libsecdb.so=../../lib/libsecdb.so.1
s none usr/lib/libsecdb.so.1=../../lib/libsecdb.so.1
s none usr/lib/libsendfile.so=../../lib/libsendfile.so.1
s none usr/lib/libsendfile.so.1=../../lib/libsendfile.so.1
+f none usr/lib/libshell.so.1 755 root bin
s none usr/lib/libsip.so=./libsip.so.1
f none usr/lib/libsip.so.1 755 root bin
s none usr/lib/libsldap.so=libsldap.so.1
diff --git a/usr/src/pkgdefs/SUNWcsl/prototype_i386 b/usr/src/pkgdefs/SUNWcsl/prototype_i386
index fe05b87242..2c4c8f0cc8 100644
--- a/usr/src/pkgdefs/SUNWcsl/prototype_i386
+++ b/usr/src/pkgdefs/SUNWcsl/prototype_i386
@@ -226,6 +226,7 @@ s none usr/lib/amd64/libadm.so.1=../../../lib/amd64/libadm.so.1
s none usr/lib/amd64/libadm.so=../../../lib/amd64/libadm.so.1
s none usr/lib/amd64/libaio.so.1=../../../lib/amd64/libaio.so.1
s none usr/lib/amd64/libaio.so=../../../lib/amd64/libaio.so.1
+f none usr/lib/amd64/libast.so.1 755 root bin
s none usr/lib/amd64/libavl.so.1=../../../lib/amd64/libavl.so.1
s none usr/lib/amd64/libc.so.1=../../../lib/amd64/libc.so.1
s none usr/lib/amd64/libc.so=../../../lib/amd64/libc.so.1
@@ -241,6 +242,7 @@ f none usr/lib/amd64/libdisasm.so.1 755 root bin
s none usr/lib/amd64/libdisasm.so=libdisasm.so.1
s none usr/lib/amd64/libdl.so.1=../../../lib/amd64/libdl.so.1
s none usr/lib/amd64/libdl.so=../../../lib/amd64/libdl.so.1
+f none usr/lib/amd64/libdll.so.1 755 root bin
s none usr/lib/amd64/libdlpi.so.1=../../../lib/amd64/libdlpi.so.1
s none usr/lib/amd64/libdlpi.so=../../../lib/amd64/libdlpi.so.1
s none usr/lib/amd64/libdoor.so.1=../../../lib/amd64/libdoor.so.1
@@ -306,6 +308,7 @@ s none usr/lib/amd64/libsecdb.so.1=../../../lib/amd64/libsecdb.so.1
s none usr/lib/amd64/libsecdb.so=../../../lib/amd64/libsecdb.so.1
s none usr/lib/amd64/libsendfile.so.1=../../../lib/amd64/libsendfile.so.1
s none usr/lib/amd64/libsendfile.so=../../../lib/amd64/libsendfile.so.1
+f none usr/lib/amd64/libshell.so.1 755 root bin
f none usr/lib/amd64/libsip.so.1 755 root bin
s none usr/lib/amd64/libsip.so=./libsip.so.1
s none usr/lib/amd64/libsldap.so=libsldap.so.1
diff --git a/usr/src/pkgdefs/SUNWcsl/prototype_sparc b/usr/src/pkgdefs/SUNWcsl/prototype_sparc
index 58c7f4302c..f06137db12 100644
--- a/usr/src/pkgdefs/SUNWcsl/prototype_sparc
+++ b/usr/src/pkgdefs/SUNWcsl/prototype_sparc
@@ -215,6 +215,7 @@ s none usr/lib/sparcv9/libadm.so.1=../../../lib/sparcv9/libadm.so.1
s none usr/lib/sparcv9/libadm.so=../../../lib/sparcv9/libadm.so.1
s none usr/lib/sparcv9/libaio.so.1=../../../lib/sparcv9/libaio.so.1
s none usr/lib/sparcv9/libaio.so=../../../lib/sparcv9/libaio.so.1
+f none usr/lib/sparcv9/libast.so.1 755 root bin
s none usr/lib/sparcv9/libavl.so.1=../../../lib/sparcv9/libavl.so.1
s none usr/lib/sparcv9/libc.so.1=../../../lib/sparcv9/libc.so.1
s none usr/lib/sparcv9/libc.so=../../../lib/sparcv9/libc.so.1
@@ -230,6 +231,7 @@ s none usr/lib/sparcv9/libdevinfo.so.1=../../../lib/sparcv9/libdevinfo.so.1
s none usr/lib/sparcv9/libdevinfo.so=../../../lib/sparcv9/libdevinfo.so.1
s none usr/lib/sparcv9/libdl.so.1=../../../lib/sparcv9/libdl.so.1
s none usr/lib/sparcv9/libdl.so=../../../lib/sparcv9/libdl.so.1
+f none usr/lib/sparcv9/libdll.so.1 755 root bin
s none usr/lib/sparcv9/libdlpi.so.1=../../../lib/sparcv9/libdlpi.so.1
s none usr/lib/sparcv9/libdlpi.so=../../../lib/sparcv9/libdlpi.so.1
s none usr/lib/sparcv9/libdoor.so.1=../../../lib/sparcv9/libdoor.so.1
@@ -294,6 +296,7 @@ s none usr/lib/sparcv9/libsecdb.so.1=../../../lib/sparcv9/libsecdb.so.1
s none usr/lib/sparcv9/libsecdb.so=../../../lib/sparcv9/libsecdb.so.1
s none usr/lib/sparcv9/libsendfile.so.1=../../../lib/sparcv9/libsendfile.so.1
s none usr/lib/sparcv9/libsendfile.so=../../../lib/sparcv9/libsendfile.so.1
+f none usr/lib/sparcv9/libshell.so.1 755 root bin
f none usr/lib/sparcv9/libsip.so.1 755 root bin
s none usr/lib/sparcv9/libsip.so=./libsip.so.1
f none usr/lib/sparcv9/libsldap.so.1 755 root bin
diff --git a/usr/src/pkgdefs/SUNWcsr/prototype_com b/usr/src/pkgdefs/SUNWcsr/prototype_com
index 4f168c73fd..2d55e0ae59 100644
--- a/usr/src/pkgdefs/SUNWcsr/prototype_com
+++ b/usr/src/pkgdefs/SUNWcsr/prototype_com
@@ -189,6 +189,7 @@ e inittab etc/inittab 644 root sys
s none etc/install=../usr/sbin/install
e preserve etc/ioctl.syscon 644 root sys
s none etc/killall=../usr/sbin/killall
+e renameold etc/ksh.kshrc 644 root sys
s none etc/labelit=../usr/sbin/labelit
d none etc/lib 755 root sys
s none etc/lib/ld.so.1=../../lib/ld.so.1
diff --git a/usr/src/pkgdefs/SUNWcsu/prototype_com b/usr/src/pkgdefs/SUNWcsu/prototype_com
index 20b7a51e63..ebaecf2e1d 100644
--- a/usr/src/pkgdefs/SUNWcsu/prototype_com
+++ b/usr/src/pkgdefs/SUNWcsu/prototype_com
@@ -165,6 +165,7 @@ f none usr/bin/keylogout 555 root bin
l none usr/bin/kill=../../usr/bin/alias
f none usr/bin/kmfcfg 555 root bin
f none usr/bin/ksh 555 root bin
+l none usr/bin/ksh93=../../usr/lib/isaexec
f none usr/bin/line 555 root bin
f none usr/bin/listdgrp 555 root bin
f none usr/bin/listusers 555 root bin
@@ -232,6 +233,7 @@ l none usr/bin/read=../../usr/bin/alias
l none usr/bin/red=../../usr/bin/ed
f none usr/bin/renice 555 root bin
l none usr/bin/rksh=../../usr/bin/ksh
+l none usr/bin/rksh93=../../usr/lib/isaexec
f none usr/bin/rm 555 root bin
s none usr/bin/rmail=./mail
f none usr/bin/rmdir 555 root bin
diff --git a/usr/src/pkgdefs/SUNWcsu/prototype_i386 b/usr/src/pkgdefs/SUNWcsu/prototype_i386
index b2216cd289..05a10113d9 100644
--- a/usr/src/pkgdefs/SUNWcsu/prototype_i386
+++ b/usr/src/pkgdefs/SUNWcsu/prototype_i386
@@ -22,7 +22,7 @@
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-#ident "%Z%%M% %I% %E% SMI"
+# ident "%Z%%M% %I% %E% SMI"
#
# This required package information file contains a list of package contents.
# The 'pkgmk' command uses this file to identify the contents of a package
@@ -50,11 +50,13 @@ f none usr/bin/addbadsec 555 root bin
f none usr/bin/i86/amt 555 root bin
f none usr/bin/diskscan 555 root bin
d none usr/bin/i86 755 root bin
+f none usr/bin/i86/ksh93 555 root bin
f none usr/bin/i86/newtask 4555 root sys
f none usr/bin/i86/nohup 555 root bin
f none usr/bin/i86/prctl 555 root bin
f none usr/bin/i86/prstat 555 root bin
f none usr/bin/i86/ps 555 root bin
+l none usr/bin/i86/rksh93=ksh93
f none usr/bin/i86/savecore 555 root bin
f none usr/bin/i86/setuname 555 root bin
f none usr/bin/i86/uptime 4555 root bin
@@ -102,6 +104,7 @@ f none usr/sbin/i86/whodo 4555 root bin
d none usr/bin/amd64 755 root bin
f none usr/bin/amd64/amt 555 root bin
f none usr/bin/amd64/crle 555 root bin
+f none usr/bin/amd64/ksh93 555 root bin
f none usr/bin/amd64/ls 555 root bin
f none usr/bin/amd64/moe 555 root bin
f none usr/bin/amd64/newtask 4555 root sys
@@ -109,6 +112,7 @@ f none usr/bin/amd64/nohup 555 root bin
f none usr/bin/amd64/prctl 555 root bin
f none usr/bin/amd64/prstat 555 root bin
f none usr/bin/amd64/ps 555 root bin
+l none usr/bin/amd64/rksh93=ksh93
f none usr/bin/amd64/savecore 555 root bin
f none usr/bin/amd64/setuname 555 root bin
f none usr/bin/amd64/uptime 4555 root bin
diff --git a/usr/src/pkgdefs/SUNWcsu/prototype_sparc b/usr/src/pkgdefs/SUNWcsu/prototype_sparc
index 100ace3694..f0f6830bc1 100644
--- a/usr/src/pkgdefs/SUNWcsu/prototype_sparc
+++ b/usr/src/pkgdefs/SUNWcsu/prototype_sparc
@@ -47,10 +47,13 @@
# SUNWcsu
#
d none usr/bin/sparcv7 755 root bin
+f none usr/bin/sparcv7/ksh93 555 root bin
+l none usr/bin/sparcv7/rksh93=ksh93
f none usr/bin/sparcv7/savecore 555 root bin
d none usr/bin/sparcv9 755 root bin
f none usr/bin/sparcv9/amt 555 root bin
f none usr/bin/sparcv9/crle 555 root bin
+f none usr/bin/sparcv9/ksh93 555 root bin
f none usr/bin/sparcv9/ls 555 root bin
f none usr/bin/sparcv9/moe 555 root bin
f none usr/bin/sparcv9/newtask 4555 root sys
@@ -58,6 +61,7 @@ f none usr/bin/sparcv9/nohup 555 root bin
f none usr/bin/sparcv9/prctl 555 root bin
f none usr/bin/sparcv9/prstat 555 root bin
f none usr/bin/sparcv9/ps 555 root bin
+l none usr/bin/sparcv9/rksh93=ksh93
f none usr/bin/sparcv9/savecore 555 root bin
f none usr/bin/sparcv9/setuname 555 root bin
f none usr/bin/sparcv9/uptime 4555 root bin
diff --git a/usr/src/pkgdefs/SUNWhea/prototype_com b/usr/src/pkgdefs/SUNWhea/prototype_com
index efa640b229..454dc32de6 100644
--- a/usr/src/pkgdefs/SUNWhea/prototype_com
+++ b/usr/src/pkgdefs/SUNWhea/prototype_com
@@ -63,6 +63,107 @@ d none usr/include/asm 755 root bin
f none usr/include/asm/sunddi.h 644 root bin
f none usr/include/asm/thread.h 644 root bin
f none usr/include/assert.h 644 root bin
+d none usr/include/ast 755 root bin
+f none usr/include/ast/align.h 644 root bin
+f none usr/include/ast/ast.h 644 root bin
+f none usr/include/ast/ast_botch.h 644 root bin
+f none usr/include/ast/ast_ccode.h 644 root bin
+f none usr/include/ast/ast_common.h 644 root bin
+f none usr/include/ast/ast_dir.h 644 root bin
+f none usr/include/ast/ast_dirent.h 644 root bin
+f none usr/include/ast/ast_fcntl.h 644 root bin
+f none usr/include/ast/ast_float.h 644 root bin
+f none usr/include/ast/ast_fs.h 644 root bin
+f none usr/include/ast/ast_getopt.h 644 root bin
+f none usr/include/ast/ast_iconv.h 644 root bin
+f none usr/include/ast/ast_lib.h 644 root bin
+f none usr/include/ast/ast_limits.h 644 root bin
+f none usr/include/ast/ast_map.h 644 root bin
+f none usr/include/ast/ast_mmap.h 644 root bin
+f none usr/include/ast/ast_mode.h 644 root bin
+f none usr/include/ast/ast_nl_types.h 644 root bin
+f none usr/include/ast/ast_param.h 644 root bin
+f none usr/include/ast/ast_standards.h 644 root bin
+f none usr/include/ast/ast_std.h 644 root bin
+f none usr/include/ast/ast_stdio.h 644 root bin
+f none usr/include/ast/ast_sys.h 644 root bin
+f none usr/include/ast/ast_time.h 644 root bin
+f none usr/include/ast/ast_tty.h 644 root bin
+f none usr/include/ast/ast_types.h 644 root bin
+f none usr/include/ast/ast_version.h 644 root bin
+f none usr/include/ast/ast_vfork.h 644 root bin
+f none usr/include/ast/ast_wait.h 644 root bin
+f none usr/include/ast/ast_wchar.h 644 root bin
+f none usr/include/ast/ast_windows.h 644 root bin
+f none usr/include/ast/bytesex.h 644 root bin
+f none usr/include/ast/ccode.h 644 root bin
+f none usr/include/ast/cdt.h 644 root bin
+f none usr/include/ast/cmd.h 644 root bin
+f none usr/include/ast/cmdext.h 644 root bin
+f none usr/include/ast/debug.h 644 root bin
+f none usr/include/ast/dirent.h 644 root bin
+f none usr/include/ast/dlldefs.h 644 root bin
+f none usr/include/ast/dt.h 644 root bin
+f none usr/include/ast/endian.h 644 root bin
+f none usr/include/ast/error.h 644 root bin
+f none usr/include/ast/find.h 644 root bin
+f none usr/include/ast/fnmatch.h 644 root bin
+f none usr/include/ast/fnv.h 644 root bin
+f none usr/include/ast/fs3d.h 644 root bin
+f none usr/include/ast/fts.h 644 root bin
+f none usr/include/ast/ftw.h 644 root bin
+f none usr/include/ast/ftwalk.h 644 root bin
+f none usr/include/ast/getopt.h 644 root bin
+f none usr/include/ast/glob.h 644 root bin
+f none usr/include/ast/hash.h 644 root bin
+f none usr/include/ast/hashkey.h 644 root bin
+f none usr/include/ast/hashpart.h 644 root bin
+f none usr/include/ast/history.h 644 root bin
+f none usr/include/ast/iconv.h 644 root bin
+f none usr/include/ast/lc.h 644 root bin
+f none usr/include/ast/ls.h 644 root bin
+f none usr/include/ast/magic.h 644 root bin
+f none usr/include/ast/magicid.h 644 root bin
+f none usr/include/ast/mc.h 644 root bin
+f none usr/include/ast/mime.h 644 root bin
+f none usr/include/ast/mnt.h 644 root bin
+f none usr/include/ast/modecanon.h 644 root bin
+f none usr/include/ast/modex.h 644 root bin
+f none usr/include/ast/namval.h 644 root bin
+f none usr/include/ast/nl_types.h 644 root bin
+f none usr/include/ast/nval.h 644 root bin
+f none usr/include/ast/option.h 644 root bin
+f none usr/include/ast/preroot.h 644 root bin
+f none usr/include/ast/proc.h 644 root bin
+f none usr/include/ast/prototyped.h 644 root bin
+f none usr/include/ast/re_comp.h 644 root bin
+f none usr/include/ast/recfmt.h 644 root bin
+f none usr/include/ast/regex.h 644 root bin
+f none usr/include/ast/regexp.h 644 root bin
+f none usr/include/ast/sfdisc.h 644 root bin
+f none usr/include/ast/sfio.h 644 root bin
+f none usr/include/ast/sfio_s.h 644 root bin
+f none usr/include/ast/sfio_t.h 644 root bin
+f none usr/include/ast/shell.h 644 root bin
+f none usr/include/ast/sig.h 644 root bin
+f none usr/include/ast/stack.h 644 root bin
+f none usr/include/ast/stak.h 644 root bin
+f none usr/include/ast/stdio.h 644 root bin
+f none usr/include/ast/stk.h 644 root bin
+f none usr/include/ast/swap.h 644 root bin
+f none usr/include/ast/tar.h 644 root bin
+f none usr/include/ast/times.h 644 root bin
+f none usr/include/ast/tm.h 644 root bin
+f none usr/include/ast/tmx.h 644 root bin
+f none usr/include/ast/tok.h 644 root bin
+f none usr/include/ast/tv.h 644 root bin
+f none usr/include/ast/usage.h 644 root bin
+f none usr/include/ast/vdb.h 644 root bin
+f none usr/include/ast/vecargs.h 644 root bin
+f none usr/include/ast/vmalloc.h 644 root bin
+f none usr/include/ast/wait.h 644 root bin
+f none usr/include/ast/wchar.h 644 root bin
+f none usr/include/ast/wordexp.h 644 root bin
f none usr/include/atomic.h 644 root bin
f none usr/include/auth_attr.h 644 root bin
d none usr/include/bsm 755 root bin
diff --git a/usr/src/pkgdefs/SUNWosdem/prototype_com b/usr/src/pkgdefs/SUNWosdem/prototype_com
index de1b5a08af..e57fdaa163 100644
--- a/usr/src/pkgdefs/SUNWosdem/prototype_com
+++ b/usr/src/pkgdefs/SUNWosdem/prototype_com
@@ -2,9 +2,8 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
@@ -54,6 +53,47 @@ f none usr/demo/ELF/dispsyms.c 644 root bin
f none usr/demo/ELF/pcom.c 644 root bin
f none usr/demo/ELF/dcom.c 644 root bin
f none usr/demo/ELF/tpcom.c 644 root bin
+d none usr/demo/ksh 755 root bin
+d none usr/demo/ksh/fun 755 root bin
+f none usr/demo/ksh/fun/dirs 644 root bin
+f none usr/demo/ksh/fun/mandelbrotset1 644 root bin
+f none usr/demo/ksh/fun/gnaw 644 root bin
+f none usr/demo/ksh/fun/rssread 644 root bin
+f none usr/demo/ksh/fun/popd 644 root bin
+f none usr/demo/ksh/fun/pushd 644 root bin
+f none usr/demo/ksh/fun/termclock 644 root bin
+f none usr/demo/ksh/fun/title 644 root bin
+d none usr/demo/ksh/tests 755 root bin
+f none usr/demo/ksh/tests/alias.sh 644 root bin
+f none usr/demo/ksh/tests/append.sh 644 root bin
+f none usr/demo/ksh/tests/arith.sh 644 root bin
+f none usr/demo/ksh/tests/arrays.sh 644 root bin
+f none usr/demo/ksh/tests/attributes.sh 644 root bin
+f none usr/demo/ksh/tests/basic.sh 644 root bin
+f none usr/demo/ksh/tests/bracket.sh 644 root bin
+f none usr/demo/ksh/tests/builtins.sh 644 root bin
+f none usr/demo/ksh/tests/case.sh 644 root bin
+f none usr/demo/ksh/tests/comvar.sh 644 root bin
+f none usr/demo/ksh/tests/coprocess.sh 644 root bin
+f none usr/demo/ksh/tests/exit.sh 644 root bin
+f none usr/demo/ksh/tests/expand.sh 644 root bin
+f none usr/demo/ksh/tests/functions.sh 644 root bin
+f none usr/demo/ksh/tests/glob.sh 644 root bin
+f none usr/demo/ksh/tests/grep.sh 644 root bin
+f none usr/demo/ksh/tests/heredoc.sh 644 root bin
+f none usr/demo/ksh/tests/io.sh 644 root bin
+f none usr/demo/ksh/tests/nameref.sh 644 root bin
+f none usr/demo/ksh/tests/options.sh 644 root bin
+f none usr/demo/ksh/tests/path.sh 644 root bin
+f none usr/demo/ksh/tests/quoting.sh 644 root bin
+f none usr/demo/ksh/tests/quoting2.sh 644 root bin
+f none usr/demo/ksh/tests/return.sh 644 root bin
+f none usr/demo/ksh/tests/select.sh 644 root bin
+f none usr/demo/ksh/tests/shtests 644 root bin
+f none usr/demo/ksh/tests/substring.sh 644 root bin
+f none usr/demo/ksh/tests/sun_solaris_getconf.sh 644 root bin
+f none usr/demo/ksh/tests/tilde.sh 644 root bin
+f none usr/demo/ksh/tests/variables.sh 644 root bin
d none usr/demo/libexacct 755 root bin
f none usr/demo/libexacct/README 644 root bin
f none usr/demo/libexacct/Makefile 644 root bin
diff --git a/usr/src/pkgdefs/etc/exception_list_i386 b/usr/src/pkgdefs/etc/exception_list_i386
index 6df099403f..a007d45b0f 100644
--- a/usr/src/pkgdefs/etc/exception_list_i386
+++ b/usr/src/pkgdefs/etc/exception_list_i386
@@ -792,6 +792,36 @@ lib/llib-ltsol i386
#
usr/include/nss.h i386
#
+# AT&T AST (ksh93) files which are currently needed only to build OS/Net
+# (msgcc&co.)
+# libast
+usr/lib/libast.so i386
+usr/lib/llib-last i386
+usr/lib/llib-last.ln i386
+usr/lib/amd64/libast.so i386
+usr/lib/amd64/llib-last.ln i386
+# libcmd
+usr/lib/llib-lcmd i386
+usr/lib/llib-lcmd.ln i386
+usr/lib/amd64/llib-lcmd.ln i386
+# libdll
+usr/lib/libdll.so i386
+usr/lib/llib-ldll i386
+usr/lib/llib-ldll.ln i386
+usr/lib/amd64/libdll.so i386
+usr/lib/amd64/llib-ldll.ln i386
+# libpp (a helper library needed by AST's msgcc)
+usr/lib/libpp.so i386
+usr/lib/llib-lpp i386
+usr/lib/llib-lpp.ln i386
+usr/lib/locale/C/LC_MESSAGES/libpp i386
+# libshell
+usr/lib/libshell.so i386
+usr/lib/llib-lshell i386
+usr/lib/llib-lshell.ln i386
+usr/lib/amd64/libshell.so i386
+usr/lib/amd64/llib-lshell.ln i386
+#
# bmc (IPMI) interfaces shared within ON.
#
usr/include/sys/bmc_intf.h i386
diff --git a/usr/src/pkgdefs/etc/exception_list_sparc b/usr/src/pkgdefs/etc/exception_list_sparc
index 76fed77a34..dd113e4a9a 100644
--- a/usr/src/pkgdefs/etc/exception_list_sparc
+++ b/usr/src/pkgdefs/etc/exception_list_sparc
@@ -860,6 +860,36 @@ lib/llib-ltsol sparc
#
usr/include/nss.h sparc
#
+# AT&T AST (ksh93) files which are currently needed only to build OS/Net
+# (msgcc&co.)
+# libast
+usr/lib/libast.so sparc
+usr/lib/llib-last sparc
+usr/lib/llib-last.ln sparc
+usr/lib/sparcv9/libast.so sparc
+usr/lib/sparcv9/llib-last.ln sparc
+# libcmd
+usr/lib/llib-lcmd sparc
+usr/lib/llib-lcmd.ln sparc
+usr/lib/sparcv9/llib-lcmd.ln sparc
+# libdll
+usr/lib/libdll.so sparc
+usr/lib/llib-ldll sparc
+usr/lib/llib-ldll.ln sparc
+usr/lib/sparcv9/libdll.so sparc
+usr/lib/sparcv9/llib-ldll.ln sparc
+# libpp (a helper library needed by AST's msgcc)
+usr/lib/libpp.so sparc
+usr/lib/llib-lpp sparc
+usr/lib/llib-lpp.ln sparc
+usr/lib/locale/C/LC_MESSAGES/libpp sparc
+# libshell
+usr/lib/libshell.so sparc
+usr/lib/llib-lshell sparc
+usr/lib/llib-lshell.ln sparc
+usr/lib/sparcv9/libshell.so sparc
+usr/lib/sparcv9/llib-lshell.ln sparc
+#
# bmc (IPMI) interfaces shared within ON.
#
usr/include/sys/bmc_intf.h sparc
diff --git a/usr/src/tools/findunref/exception_list b/usr/src/tools/findunref/exception_list
index 00ecc3663b..ac2db0708f 100644
--- a/usr/src/tools/findunref/exception_list
+++ b/usr/src/tools/findunref/exception_list
@@ -34,12 +34,22 @@
#
# Ignore text files.
#
+*.[1-9]
+*.memo
+*.mm
*.txt
*/*[Rr][Ee][Aa][Dd][Mm][Ee]*
+*/BUGS
+*/COMPATIBILITY
+*/COPYRIGHT
*/ChangeLog
+*/DESIGN
+*/HISTORY
+*/NOTES
+*/OBSOLETE
*/READ_ME
+*/RELEASE*
*/TODO
-*/COPYRIGHT
#
# Ignore oddly-named text files scattered about -- someday these should be
@@ -62,6 +72,53 @@
./src/uts/intel/sys/acpi
#
+# Ignore ksh93/ast-related files that are only used to resync our build
+# configuration with upstream.
+#
+./src/lib/libast/*/src/lib/libast/FEATURE/*
+./src/lib/libast/common/comp/conf.*
+./src/lib/libast/common/features/*
+./src/lib/libast/common/include/ast_windows.h
+./src/lib/libast/common/port/lc.tab
+./src/lib/libast/common/port/lcgen.c
+./src/lib/libcmd/*/src/lib/libcmd/FEATURE/*
+./src/lib/libcmd/common/features/*
+./src/lib/libdll/*/src/lib/libdll/FEATURE/*
+./src/lib/libdll/common/features/*
+./src/lib/libpp/*/pp.*
+./src/lib/libpp/common/gentab.sh
+./src/lib/libpp/common/ppsym.c
+./src/lib/libpp/i386/ppdebug.h
+./src/lib/libpp/sparc/ppdebug.h
+./src/lib/libshell/*/src/cmd/ksh93/FEATURE/*
+./src/lib/libshell/common/data/math.tab
+./src/lib/libshell/common/features/*
+./src/lib/libshell/misc/buildksh93.ksh
+./src/lib/libshell/misc/buildksh93.readme
+
+#
+# Ignore ksh93/ast-related test programs.
+#
+./src/cmd/ast/msgcc/msgcc.tst
+./src/lib/libast/common/port/astmath.c
+
+#
+# Ignore ksh93/ast-related source components that are not currently
+# used but may be useful later.
+#
+./src/lib/libcmd/common/cksum.c
+./src/lib/libcmd/common/md5sum.c
+./src/lib/libcmd/common/sum.c
+./src/lib/libshell/common/bltins/mkservice.c
+./src/lib/libshell/common/bltins/shopen.c
+./src/lib/libshell/common/data/bash_pre_rc.sh
+./src/lib/libshell/common/include/env.h
+./src/lib/libshell/common/sh/bash.c
+./src/lib/libshell/common/sh/env.c
+./src/lib/libshell/common/sh/shcomp.c
+./src/lib/libshell/common/sh/suid_exec.c
+
+#
# Ignore any files built as part of the nightly program itself.
#
# ISUSED - let checkpaths know that the next entry is good.
diff --git a/usr/src/tools/opensolaris/license-list b/usr/src/tools/opensolaris/license-list
index e2931d3915..8ad7d7d16d 100644
--- a/usr/src/tools/opensolaris/license-list
+++ b/usr/src/tools/opensolaris/license-list
@@ -1,6 +1,7 @@
usr/closed/cmd/man/src/util/solbookv1/THIRDPARTYLICENSE
usr/closed/lib/smartcard/ocfserv/opencard/core/event/THIRDPARTYLICENSE
usr/src/cmd/agents/snmp/THIRDPARTYLICENSE
+usr/src/cmd/ast/THIRDPARTYLICENSE
usr/src/cmd/backup/dump/THIRDPARTYLICENSE
usr/src/cmd/bnu/THIRDPARTYLICENSE
usr/src/cmd/checkeq/THIRDPARTYLICENSE
@@ -67,16 +68,21 @@ usr/src/common/openssl/LICENSE
usr/src/grub/grub-0.95/COPYING
usr/src/lib/gss_mechs/mech_krb5/THIRDPARTYLICENSE
usr/src/lib/krb5/THIRDPARTYLICENSE
+usr/src/lib/libast/THIRDPARTYLICENSE
usr/src/lib/libbc/THIRDPARTYLICENSE
usr/src/lib/libbsdmalloc/THIRDPARTYLICENSE
+usr/src/lib/libcmd/THIRDPARTYLICENSE
+usr/src/lib/libdll/THIRDPARTYLICENSE
usr/src/lib/libgss/THIRDPARTYLICENSE
usr/src/lib/libinetutil/common/THIRDPARTYLICENSE
usr/src/lib/libkmf/THIRDPARTYLICENSE
usr/src/lib/libldap5/THIRDPARTYLICENSE
usr/src/lib/libmp/common/THIRDPARTYLICENSE
+usr/src/lib/libpp/THIRDPARTYLICENSE
usr/src/lib/libresolv/THIRDPARTYLICENSE
usr/src/lib/libresolv2/THIRDPARTYLICENSE
usr/src/lib/libsasl/THIRDPARTYLICENSE
+usr/src/lib/libshell/THIRDPARTYLICENSE
usr/src/lib/libtecla/THIRDPARTYLICENSE
usr/src/lib/pam_modules/authtok_check/THIRDPARTYLICENSE
usr/src/lib/passwdutil/THIRDPARTYLICENSE
diff --git a/usr/src/tools/scripts/bfu.sh b/usr/src/tools/scripts/bfu.sh
index 2bf009fa3c..7dd25a5f92 100644
--- a/usr/src/tools/scripts/bfu.sh
+++ b/usr/src/tools/scripts/bfu.sh
@@ -107,6 +107,7 @@ all_zones_files="
etc/krb5/kpropd.acl
etc/krb5/krb5.conf
etc/krb5/warn.conf
+ etc/ksh.kshrc
etc/logadm.conf
etc/logindevperm
etc/lp/Systems